summaryrefslogtreecommitdiffhomepage
path: root/packages/server/src
diff options
context:
space:
mode:
authorMatthew Miller <matthew@millerti.me>2020-06-07 22:41:15 -0700
committerMatthew Miller <matthew@millerti.me>2020-06-07 22:41:15 -0700
commit2f0c14cd340226c842dffb087fe5ce9f648fc5ad (patch)
tree2528b6479e39e9ab45b0381b264b236fe22cc069 /packages/server/src
parenta2b231566244e25361f788cc4eb4321cfecdec01 (diff)
Add tokenBinding checks
Diffstat (limited to 'packages/server/src')
-rw-r--r--packages/server/src/attestation/verifyAttestationResponse.ts12
1 files changed, 11 insertions, 1 deletions
diff --git a/packages/server/src/attestation/verifyAttestationResponse.ts b/packages/server/src/attestation/verifyAttestationResponse.ts
index 374b79b..2ebf8d5 100644
--- a/packages/server/src/attestation/verifyAttestationResponse.ts
+++ b/packages/server/src/attestation/verifyAttestationResponse.ts
@@ -61,7 +61,7 @@ export default function verifyAttestationResponse(options: Options): VerifiedAtt
const clientDataJSON = decodeClientDataJSON(response.clientDataJSON);
- const { type, origin, challenge } = clientDataJSON;
+ const { type, origin, challenge, tokenBinding } = clientDataJSON;
// Make sure we're handling an attestation
if (type !== 'webauthn.create') {
@@ -81,6 +81,16 @@ export default function verifyAttestationResponse(options: Options): VerifiedAtt
throw new Error(`Unexpected attestation origin "${origin}", expected "${expectedOrigin}"`);
}
+ if (tokenBinding) {
+ if (!(tokenBinding instanceof Object)) {
+ throw new Error(`Unexpected value for TokenBinding "${tokenBinding}"`);
+ }
+
+ if (['present', 'supported', 'not-supported'].indexOf(tokenBinding.status) < 0) {
+ throw new Error(`Unexpected tokenBinding.status value of "${tokenBinding.status}"`);
+ }
+ }
+
const attestationObject = decodeAttestationObject(response.attestationObject);
const { fmt, authData, attStmt } = attestationObject;