diff options
author | Matthew Miller <matthew@millerti.me> | 2020-06-02 15:19:03 -0700 |
---|---|---|
committer | Matthew Miller <matthew@millerti.me> | 2020-06-02 15:19:03 -0700 |
commit | bb5e3e99f7e50b9cec607b4fda34dcbd1e04aae9 (patch) | |
tree | 2d9f2f8e7ce60a83e5409d073f74422bcc2df60e | |
parent | e82c9e9f813897015c9054aa6d279e8ca4279f07 (diff) |
Remove “base64” references from options generators
4 files changed, 13 insertions, 11 deletions
diff --git a/packages/server/src/assertion/generateAssertionOptions.test.ts b/packages/server/src/assertion/generateAssertionOptions.test.ts index bd2d48d..9cae665 100644 --- a/packages/server/src/assertion/generateAssertionOptions.test.ts +++ b/packages/server/src/assertion/generateAssertionOptions.test.ts @@ -61,7 +61,7 @@ test('should set extensions if specified', () => { const goodOpts1 = { challenge: 'totallyrandomvalue', - allowedBase64CredentialIDs: [ + allowedCredentialIDs: [ Buffer.from('1234', 'ascii').toString('base64'), Buffer.from('5678', 'ascii').toString('base64'), ], diff --git a/packages/server/src/assertion/generateAssertionOptions.ts b/packages/server/src/assertion/generateAssertionOptions.ts index ca699c6..6645e2e 100644 --- a/packages/server/src/assertion/generateAssertionOptions.ts +++ b/packages/server/src/assertion/generateAssertionOptions.ts @@ -1,10 +1,11 @@ import type { PublicKeyCredentialRequestOptionsJSON, + Base64URLString, } from '@simplewebauthn/typescript-types'; type Options = { challenge: string, - allowedBase64CredentialIDs: string[], + allowedCredentialIDs: Base64URLString[], suggestedTransports?: AuthenticatorTransport[], timeout?: number, userVerification?: UserVerificationRequirement, @@ -15,7 +16,7 @@ type Options = { * Prepare a value to pass into navigator.credentials.get(...) for authenticator "login" * * @param challenge Random string the authenticator needs to sign and pass back - * @param allowedBase64CredentialIDs Array of base64url-encoded authenticator IDs registered by the + * @param allowedCredentialIDs Array of base64url-encoded authenticator IDs registered by the * user for assertion * @param timeout How long (in ms) the user can take to complete assertion * @param suggestedTransports Suggested types of authenticators for assertion @@ -28,7 +29,7 @@ export default function generateAssertionOptions( ): PublicKeyCredentialRequestOptionsJSON { const { challenge, - allowedBase64CredentialIDs, + allowedCredentialIDs, suggestedTransports = ['usb', 'ble', 'nfc', 'internal'], timeout = 60000, userVerification, @@ -37,7 +38,7 @@ export default function generateAssertionOptions( return { challenge, - allowCredentials: allowedBase64CredentialIDs.map(id => ({ + allowCredentials: allowedCredentialIDs.map(id => ({ id, type: 'public-key', transports: suggestedTransports, diff --git a/packages/server/src/attestation/generateAttestationOptions.test.ts b/packages/server/src/attestation/generateAttestationOptions.test.ts index 2f5c439..2b83fa9 100644 --- a/packages/server/src/attestation/generateAttestationOptions.test.ts +++ b/packages/server/src/attestation/generateAttestationOptions.test.ts @@ -49,7 +49,7 @@ test('should map excluded credential IDs if specified', () => { challenge: 'totallyrandomvalue', userID: '1234', userName: 'usernameHere', - excludedBase64CredentialIDs: ['someIDhere'], + excludedCredentialIDs: ['someIDhere'], }); expect(options.excludeCredentials).toEqual([{ diff --git a/packages/server/src/attestation/generateAttestationOptions.ts b/packages/server/src/attestation/generateAttestationOptions.ts index 25008c0..d142740 100644 --- a/packages/server/src/attestation/generateAttestationOptions.ts +++ b/packages/server/src/attestation/generateAttestationOptions.ts @@ -1,5 +1,6 @@ -import { +import type { PublicKeyCredentialCreationOptionsJSON, + Base64URLString, } from '@simplewebauthn/typescript-types'; type Options = { @@ -11,7 +12,7 @@ type Options = { userDisplayName?: string, timeout?: number, attestationType?: AttestationConveyancePreference, - excludedBase64CredentialIDs?: string[], + excludedCredentialIDs?: Base64URLString[], suggestedTransports?: AuthenticatorTransport[], authenticatorSelection?: AuthenticatorSelectionCriteria, extensions?: AuthenticationExtensionsClientInputs, @@ -30,7 +31,7 @@ type Options = { * @param userDisplayName User's actual name * @param timeout How long (in ms) the user can take to complete attestation * @param attestationType Specific attestation statement - * @param excludedBase64CredentialIDs Array of base64url-encoded authenticator IDs registered by the + * @param excludedCredentialIDs Array of base64url-encoded authenticator IDs registered by the * user so the user can't register the same credential multiple times * @param suggestedTransports Suggested types of authenticators for attestation * @param authenticatorSelection Advanced criteria for restricting the types of authenticators that @@ -49,7 +50,7 @@ export default function generateAttestationOptions( userDisplayName = userName, timeout = 60000, attestationType = 'none', - excludedBase64CredentialIDs = [], + excludedCredentialIDs = [], suggestedTransports = ['usb', 'ble', 'nfc', 'internal'], authenticatorSelection, extensions, @@ -74,7 +75,7 @@ export default function generateAttestationOptions( ], timeout, attestation: attestationType, - excludeCredentials: excludedBase64CredentialIDs.map((id) => ({ + excludeCredentials: excludedCredentialIDs.map((id) => ({ id, type: 'public-key', transports: suggestedTransports, |