diff options
Diffstat (limited to 'packages/browser/src')
-rw-r--r-- | packages/browser/src/methods/startAssertion.test.ts | 9 | ||||
-rw-r--r-- | packages/browser/src/methods/startAttestation.test.ts | 7 |
2 files changed, 7 insertions, 9 deletions
diff --git a/packages/browser/src/methods/startAssertion.test.ts b/packages/browser/src/methods/startAssertion.test.ts index c74b88f..f763391 100644 --- a/packages/browser/src/methods/startAssertion.test.ts +++ b/packages/browser/src/methods/startAssertion.test.ts @@ -4,7 +4,6 @@ import { } from '@simplewebauthn/typescript-types'; import supportsWebauthn from '../helpers/supportsWebauthn'; -import toUint8Array from '../helpers/toUint8Array'; import bufferToBase64URLString from '../helpers/bufferToBase64URLString'; import startAssertion from './startAssertion'; @@ -21,7 +20,7 @@ const mockUserHandle = 'mockUserHandle'; // With ASCII challenge const goodOpts1: PublicKeyCredentialRequestOptionsJSON = { - challenge: bufferToBase64URLString(toUint8Array('fizz')), + challenge: bufferToBase64URLString(Buffer.from('fizz', 'ascii')), allowCredentials: [ { id: 'C0VGlvYFratUdAV1iCw-ULpUW8E-exHPXQChBfyVeJZCMfjMFcwDmOFgoMUz39LoMtCJUBW8WPlLkGT6q8qTCg', @@ -34,7 +33,7 @@ const goodOpts1: PublicKeyCredentialRequestOptionsJSON = { // With UTF-8 challenge const goodOpts2UTF8: PublicKeyCredentialRequestOptionsJSON = { - challenge: bufferToBase64URLString(toUint8Array('やれやれだぜ')), + challenge: bufferToBase64URLString(Buffer.from('やれやれだぜ', 'utf-8')), allowCredentials: [], timeout: 1, }; @@ -88,7 +87,7 @@ test('should support optional allowCredential', async () => { ); await startAssertion({ - challenge: bufferToBase64URLString(toUint8Array('fizz')), + challenge: bufferToBase64URLString(Buffer.from('fizz', 'ascii')), timeout: 1, }); @@ -111,7 +110,7 @@ test('should convert allow allowCredential to undefined when empty', async () => ); await startAssertion({ - challenge: bufferToBase64URLString(toUint8Array('fizz')), + challenge: bufferToBase64URLString(Buffer.from('fizz', 'ascii')), timeout: 1, allowCredentials: [], }); diff --git a/packages/browser/src/methods/startAttestation.test.ts b/packages/browser/src/methods/startAttestation.test.ts index 0723213..ad71488 100644 --- a/packages/browser/src/methods/startAttestation.test.ts +++ b/packages/browser/src/methods/startAttestation.test.ts @@ -3,7 +3,6 @@ import { PublicKeyCredentialCreationOptionsJSON, } from '@simplewebauthn/typescript-types'; -import toUint8Array from '../helpers/toUint8Array'; import supportsWebauthn from '../helpers/supportsWebauthn'; import bufferToBase64URLString from '../helpers/bufferToBase64URLString'; @@ -18,7 +17,7 @@ const mockAttestationObject = 'mockAtte'; const mockClientDataJSON = 'mockClie'; const goodOpts1: PublicKeyCredentialCreationOptionsJSON = { - challenge: bufferToBase64URLString(toUint8Array('fizz')), + challenge: bufferToBase64URLString(Buffer.from('fizz', 'ascii')), attestation: 'direct', pubKeyCredParams: [ { @@ -69,7 +68,7 @@ test('should convert options before passing to navigator.credentials.create(...) // Make sure challenge and user.id are converted to Buffers expect(new Uint8Array(argsPublicKey.challenge)).toEqual(new Uint8Array([102, 105, 122, 122])); - expect(new Uint8Array(argsPublicKey.user.id)).toEqual(new Uint8Array([53, 54, 55, 56])); + expect(new Uint8Array(argsPublicKey.user.id)).toEqual(new Uint8Array([231, 174, 252])); // Confirm construction of excludeCredentials array expect(credId instanceof ArrayBuffer).toEqual(true); @@ -88,7 +87,7 @@ test('should return base64url-encoded response values', async done => { return new Promise(resolve => { resolve({ id: 'foobar', - rawId: toUint8Array('foobar'), + rawId: Buffer.from('foobar', 'ascii'), response: { attestationObject: Buffer.from(mockAttestationObject, 'ascii'), clientDataJSON: Buffer.from(mockClientDataJSON, 'ascii'), |