summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMatthew Miller <matthew@millerti.me>2020-05-27 08:03:30 -0700
committerMatthew Miller <matthew@millerti.me>2020-05-27 08:05:49 -0700
commit286ec13aaa06a508ae9b6949c74d62d09087507a (patch)
treeb56c0b43d443112431bd8f616b04c0fbb6696161
parentced8fe122451fcc5f95152d750f387b9b4cd7f4e (diff)
Add support for extensions in attestation options
-rw-r--r--packages/server/src/attestation/generateAttestationOptions.test.ts17
-rw-r--r--packages/server/src/attestation/generateAttestationOptions.ts4
2 files changed, 20 insertions, 1 deletions
diff --git a/packages/server/src/attestation/generateAttestationOptions.test.ts b/packages/server/src/attestation/generateAttestationOptions.test.ts
index 723f5fc..2f5c439 100644
--- a/packages/server/src/attestation/generateAttestationOptions.test.ts
+++ b/packages/server/src/attestation/generateAttestationOptions.test.ts
@@ -71,7 +71,7 @@ test('defaults to 60 seconds if no timeout is specified', () => {
expect(options.timeout).toEqual(60000);
});
-test('defaults to direct attestation if no attestation type is specified', () => {
+test('defaults to none attestation if no attestation type is specified', () => {
const options = generateAttestationOptions({
serviceName: 'SimpleWebAuthn',
rpID: 'not.real',
@@ -103,3 +103,18 @@ test('should set authenticatorSelection if specified', () => {
userVerification: 'preferred',
});
});
+
+test('should set extensions if specified', () => {
+ const options = generateAttestationOptions({
+ serviceName: 'SimpleWebAuthn',
+ rpID: 'not.real',
+ challenge: 'totallyrandomvalue',
+ userID: '1234',
+ userName: 'usernameHere',
+ extensions: { appid: 'simplewebauthn' },
+ });
+
+ expect(options.extensions).toEqual({
+ appid: 'simplewebauthn',
+ });
+});
diff --git a/packages/server/src/attestation/generateAttestationOptions.ts b/packages/server/src/attestation/generateAttestationOptions.ts
index 59fc6f0..89ac86a 100644
--- a/packages/server/src/attestation/generateAttestationOptions.ts
+++ b/packages/server/src/attestation/generateAttestationOptions.ts
@@ -14,6 +14,7 @@ type Options = {
excludedBase64CredentialIDs?: string[],
suggestedTransports?: AuthenticatorTransport[],
authenticatorSelection?: AuthenticatorSelectionCriteria,
+ extensions?: AuthenticationExtensionsClientInputs,
};
/**
@@ -34,6 +35,7 @@ type Options = {
* @param suggestedTransports Suggested types of authenticators for attestation
* @param authenticatorSelection Advanced criteria for restricting the types of authenticators that
* may be used
+ * @param extensions Additional plugins the authenticator or browser should use during attestation
*/
export default function generateAttestationOptions(
options: Options,
@@ -50,6 +52,7 @@ export default function generateAttestationOptions(
excludedBase64CredentialIDs = [],
suggestedTransports = ['usb', 'ble', 'nfc', 'internal'],
authenticatorSelection,
+ extensions,
} = options;
return {
@@ -77,5 +80,6 @@ export default function generateAttestationOptions(
transports: suggestedTransports,
})),
authenticatorSelection,
+ extensions,
};
}