summaryrefslogtreecommitdiffhomepage
path: root/packages/server/src/authentication/generateAuthenticationOptions.test.ts
diff options
context:
space:
mode:
authorMatthew Miller <matthew@millerti.me>2024-02-22 21:42:59 -0800
committerMatthew Miller <matthew@millerti.me>2024-02-22 21:42:59 -0800
commit8bb37d15554210b7c8ba5f530d8ccb1ca4e88f1f (patch)
tree7d88265cb28db0d12565a6725e5286b1ec8e42a3 /packages/server/src/authentication/generateAuthenticationOptions.test.ts
parent67bb72ecc2d393d4f6f80ff01b56c1af1ae162ef (diff)
Expect base64url cred ID in authentication opts
Diffstat (limited to 'packages/server/src/authentication/generateAuthenticationOptions.test.ts')
-rw-r--r--packages/server/src/authentication/generateAuthenticationOptions.test.ts38
1 files changed, 17 insertions, 21 deletions
diff --git a/packages/server/src/authentication/generateAuthenticationOptions.test.ts b/packages/server/src/authentication/generateAuthenticationOptions.test.ts
index 7acb250..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,15 +115,13 @@ 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);