diff options
author | Matthew Miller <matthew@millerti.me> | 2024-02-24 16:45:51 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-24 16:45:51 -0800 |
commit | 6eb5ac62e778c6c39c936cfce3309b9aa852021d (patch) | |
tree | 1d33f0a5ea58d74d0b41e6cc407ef604d76c399e /packages/server/src/authentication/generateAuthenticationOptions.test.ts | |
parent | fe2245b9c1b7ada2099a6411c8ce2e6e6f18bbf9 (diff) | |
parent | b835ce41e1936765a49d7f7114116d78ddb67a1c (diff) |
Merge pull request #529 from MasterKale/fix/528-simplify-use-of-credential-id
fix/528-simplify-use-of-credential-id
Diffstat (limited to 'packages/server/src/authentication/generateAuthenticationOptions.test.ts')
-rw-r--r-- | packages/server/src/authentication/generateAuthenticationOptions.test.ts | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/packages/server/src/authentication/generateAuthenticationOptions.test.ts b/packages/server/src/authentication/generateAuthenticationOptions.test.ts index 8d55580..49d668e 100644 --- a/packages/server/src/authentication/generateAuthenticationOptions.test.ts +++ b/packages/server/src/authentication/generateAuthenticationOptions.test.ts @@ -11,13 +11,11 @@ Deno.test('should generate credential request options suitable for sending via J const options = await generateAuthenticationOptions({ allowCredentials: [ { - id: isoUint8Array.fromASCIIString('1234'), - type: 'public-key', + id: '1234', transports: ['usb', 'nfc'], }, { - id: isoUint8Array.fromASCIIString('5678'), - type: 'public-key', + id: '5678', transports: ['internal'], }, ], @@ -30,12 +28,12 @@ Deno.test('should generate credential request options suitable for sending via J challenge: challengeString, allowCredentials: [ { - id: 'MTIzNA', + id: '1234', type: 'public-key', transports: ['usb', 'nfc'], }, { - id: 'NTY3OA', + id: '5678', type: 'public-key', transports: ['internal'], }, @@ -51,8 +49,8 @@ Deno.test('defaults to 60 seconds if no timeout is specified', async () => { const options = await generateAuthenticationOptions({ challenge: challengeBuffer, allowCredentials: [ - { id: isoUint8Array.fromASCIIString('1234'), type: 'public-key' }, - { id: isoUint8Array.fromASCIIString('5678'), type: 'public-key' }, + { id: '1234' }, + { id: '5678' }, ], }); @@ -63,8 +61,8 @@ Deno.test('should set userVerification to "preferred" if not specified', async ( const options = await generateAuthenticationOptions({ challenge: challengeBuffer, allowCredentials: [ - { id: isoUint8Array.fromASCIIString('1234'), type: 'public-key' }, - { id: isoUint8Array.fromASCIIString('5678'), type: 'public-key' }, + { id: '1234' }, + { id: '5678' }, ], }); @@ -94,8 +92,8 @@ Deno.test('should set userVerification if specified', async () => { const options = await generateAuthenticationOptions({ challenge: challengeBuffer, allowCredentials: [ - { id: isoUint8Array.fromASCIIString('1234'), type: 'public-key' }, - { id: isoUint8Array.fromASCIIString('5678'), type: 'public-key' }, + { id: '1234' }, + { id: '5678' }, ], userVerification: 'required', }); @@ -107,8 +105,8 @@ Deno.test('should set extensions if specified', async () => { const options = await generateAuthenticationOptions({ challenge: challengeBuffer, allowCredentials: [ - { id: isoUint8Array.fromASCIIString('1234'), type: 'public-key' }, - { id: isoUint8Array.fromASCIIString('5678'), type: 'public-key' }, + { id: '1234' }, + { id: '5678' }, ], extensions: { appid: 'simplewebauthn' }, }); @@ -117,19 +115,17 @@ Deno.test('should set extensions if specified', async () => { }); Deno.test('should generate a challenge if one is not provided', async () => { - const opts = { + // @ts-ignore 2345 + const options = await generateAuthenticationOptions({ allowCredentials: [ - { id: isoUint8Array.fromASCIIString('1234'), type: 'public-key' }, - { id: isoUint8Array.fromASCIIString('5678'), type: 'public-key' }, + { id: '1234' }, + { id: '5678' }, ], - }; - - // @ts-ignore 2345 - const options = await generateAuthenticationOptions(opts); + }); // Assert basic properties of the challenge assert(options.challenge.length >= 16); - assert(isoBase64URL.isBase64url(options.challenge)); + assert(isoBase64URL.isBase64URL(options.challenge)); }); Deno.test('should treat string challenges as UTF-8 strings', async () => { |