summaryrefslogtreecommitdiffhomepage
path: root/packages/server/src/authentication/verifyAuthenticationResponse.ts
diff options
context:
space:
mode:
authorMatthew Miller <matthew@millerti.me>2022-04-11 23:08:46 -0700
committerMatthew Miller <matthew@millerti.me>2022-05-15 21:49:33 -0700
commit2088c74bb0e05118f5f34a733dc8490730b23ecf (patch)
treed2f4316a5c383a55a2489e85841fe81832e0bfe9 /packages/server/src/authentication/verifyAuthenticationResponse.ts
parent5993fd43f579315217c9585dbc9825719640b7f2 (diff)
Return credential device type and backup state
Diffstat (limited to 'packages/server/src/authentication/verifyAuthenticationResponse.ts')
-rw-r--r--packages/server/src/authentication/verifyAuthenticationResponse.ts8
1 files changed, 8 insertions, 0 deletions
diff --git a/packages/server/src/authentication/verifyAuthenticationResponse.ts b/packages/server/src/authentication/verifyAuthenticationResponse.ts
index e7ec1ec..d804224 100644
--- a/packages/server/src/authentication/verifyAuthenticationResponse.ts
+++ b/packages/server/src/authentication/verifyAuthenticationResponse.ts
@@ -2,6 +2,7 @@ import base64url from 'base64url';
import {
AuthenticationCredentialJSON,
AuthenticatorDevice,
+ CredentialDeviceType,
} from '@simplewebauthn/typescript-types';
import decodeClientDataJSON from '../helpers/decodeClientDataJSON';
@@ -10,6 +11,7 @@ import convertPublicKeyToPEM from '../helpers/convertPublicKeyToPEM';
import verifySignature from '../helpers/verifySignature';
import parseAuthenticatorData from '../helpers/parseAuthenticatorData';
import isBase64URLString from '../helpers/isBase64URLString';
+import { parseBackupFlags } from '../helpers/parseBackupFlags';
export type VerifyAuthenticationResponseOpts = {
credential: AuthenticationCredentialJSON;
@@ -178,11 +180,15 @@ export default function verifyAuthenticationResponse(
);
}
+ const { credentialDeviceType, credentialBackedUp } = parseBackupFlags(flags);
+
const toReturn = {
verified: verifySignature(signature, signatureBase, publicKey),
authenticationInfo: {
newCounter: counter,
credentialID: authenticator.credentialID,
+ credentialDeviceType,
+ credentialBackedUp,
},
};
@@ -205,5 +211,7 @@ export type VerifiedAuthenticationResponse = {
authenticationInfo: {
credentialID: Buffer;
newCounter: number;
+ credentialDeviceType: CredentialDeviceType;
+ credentialBackedUp: boolean;
};
};