diff options
Diffstat (limited to 'packages/browser/src')
-rw-r--r-- | packages/browser/src/helpers/stringToArrayBuffer.ts (renamed from packages/browser/src/helpers/toUint8Array.ts) | 2 | ||||
-rw-r--r-- | packages/browser/src/methods/startAssertion.test.ts | 10 | ||||
-rw-r--r-- | packages/browser/src/methods/startAttestation.test.ts | 6 | ||||
-rw-r--r-- | packages/browser/src/methods/startAttestation.ts | 4 |
4 files changed, 11 insertions, 11 deletions
diff --git a/packages/browser/src/helpers/toUint8Array.ts b/packages/browser/src/helpers/stringToArrayBuffer.ts index 1e2243f..e3edd41 100644 --- a/packages/browser/src/helpers/toUint8Array.ts +++ b/packages/browser/src/helpers/stringToArrayBuffer.ts @@ -2,6 +2,6 @@ * A helper method to convert an arbitrary string sent from the server to a Uint8Array the * authenticator will expect. */ -export default function toUint8Array(value: string): Uint8Array { +export default function stringToArrayBuffer(value: string): ArrayBuffer { return new TextEncoder().encode(value); } diff --git a/packages/browser/src/methods/startAssertion.test.ts b/packages/browser/src/methods/startAssertion.test.ts index c077219..83c5a8b 100644 --- a/packages/browser/src/methods/startAssertion.test.ts +++ b/packages/browser/src/methods/startAssertion.test.ts @@ -6,7 +6,7 @@ import { } from '@simplewebauthn/typescript-types'; import supportsWebauthn from '../helpers/supportsWebauthn'; -import toUint8Array from '../helpers/toUint8Array'; +import stringToArrayBuffer from '../helpers/stringToArrayBuffer'; import bufferToBase64URLString from '../helpers/bufferToBase64URLString'; import startAssertion from './startAssertion'; @@ -23,7 +23,7 @@ const mockUserHandle = 'mockUserHandle'; // With ASCII challenge const goodOpts1: PublicKeyCredentialRequestOptionsJSON = { - challenge: bufferToBase64URLString(toUint8Array('fizz')), + challenge: bufferToBase64URLString(stringToArrayBuffer('fizz')), allowCredentials: [ { id: 'C0VGlvYFratUdAV1iCw-ULpUW8E-exHPXQChBfyVeJZCMfjMFcwDmOFgoMUz39LoMtCJUBW8WPlLkGT6q8qTCg', @@ -36,7 +36,7 @@ const goodOpts1: PublicKeyCredentialRequestOptionsJSON = { // With UTF-8 challenge const goodOpts2UTF8: PublicKeyCredentialRequestOptionsJSON = { - challenge: bufferToBase64URLString(toUint8Array('やれやれだぜ')), + challenge: bufferToBase64URLString(stringToArrayBuffer('やれやれだぜ')), allowCredentials: [], timeout: 1, }; @@ -78,7 +78,7 @@ test('should convert options before passing to navigator.credentials.get(...)', test('should support optional allowCredential', async () => { await startAssertion({ - challenge: bufferToBase64URLString(toUint8Array('fizz')), + challenge: bufferToBase64URLString(stringToArrayBuffer('fizz')), timeout: 1, }); @@ -87,7 +87,7 @@ test('should support optional allowCredential', async () => { test('should convert allow allowCredential to undefined when empty', async () => { await startAssertion({ - challenge: bufferToBase64URLString(toUint8Array('fizz')), + challenge: bufferToBase64URLString(stringToArrayBuffer('fizz')), timeout: 1, allowCredentials: [], }); diff --git a/packages/browser/src/methods/startAttestation.test.ts b/packages/browser/src/methods/startAttestation.test.ts index b4cfa52..0b77743 100644 --- a/packages/browser/src/methods/startAttestation.test.ts +++ b/packages/browser/src/methods/startAttestation.test.ts @@ -5,7 +5,7 @@ import { PublicKeyCredentialCreationOptionsJSON, } from '@simplewebauthn/typescript-types'; -import toUint8Array from '../helpers/toUint8Array'; +import stringToArrayBuffer from '../helpers/stringToArrayBuffer'; import supportsWebauthn from '../helpers/supportsWebauthn'; import bufferToBase64URLString from '../helpers/bufferToBase64URLString'; @@ -20,7 +20,7 @@ const mockAttestationObject = 'mockAtte'; const mockClientDataJSON = 'mockClie'; const goodOpts1: PublicKeyCredentialCreationOptionsJSON = { - challenge: bufferToBase64URLString(toUint8Array('fizz')), + challenge: bufferToBase64URLString(stringToArrayBuffer('fizz')), attestation: 'direct', pubKeyCredParams: [ { @@ -90,7 +90,7 @@ test('should return base64url-encoded response values', async done => { return new Promise(resolve => { resolve({ id: 'foobar', - rawId: toUint8Array('foobar'), + rawId: stringToArrayBuffer('foobar'), response: { attestationObject: Buffer.from(mockAttestationObject, 'ascii'), clientDataJSON: Buffer.from(mockClientDataJSON, 'ascii'), diff --git a/packages/browser/src/methods/startAttestation.ts b/packages/browser/src/methods/startAttestation.ts index 22ebe64..5601581 100644 --- a/packages/browser/src/methods/startAttestation.ts +++ b/packages/browser/src/methods/startAttestation.ts @@ -4,7 +4,7 @@ import { AttestationCredentialJSON, } from '@simplewebauthn/typescript-types'; -import toUint8Array from '../helpers/toUint8Array'; +import stringToArrayBuffer from '../helpers/stringToArrayBuffer'; import bufferToBase64URLString from '../helpers/bufferToBase64URLString'; import base64URLStringToBuffer from '../helpers/base64URLStringToBuffer'; import supportsWebauthn from '../helpers/supportsWebauthn'; @@ -28,7 +28,7 @@ export default async function startAttestation( challenge: base64URLStringToBuffer(creationOptionsJSON.challenge), user: { ...creationOptionsJSON.user, - id: toUint8Array(creationOptionsJSON.user.id), + id: stringToArrayBuffer(creationOptionsJSON.user.id), }, excludeCredentials: creationOptionsJSON.excludeCredentials.map(toPublicKeyCredentialDescriptor), }; |