summaryrefslogtreecommitdiffhomepage
path: root/packages/server/src/helpers/parseAuthenticatorData.ts
diff options
context:
space:
mode:
authorMatthew Miller <matthew@millerti.me>2022-05-16 22:52:53 -0700
committerGitHub <noreply@github.com>2022-05-16 22:52:53 -0700
commit39a41ae7e86a4782017c2f489f7c66a9effdcaf3 (patch)
treeccc0cb0708cce781f7d6e189528b37bbd9a1a503 /packages/server/src/helpers/parseAuthenticatorData.ts
parent5c189bca1dc480e919bb82077b51829f29123375 (diff)
parent190a746b89e2cf3238c0070c08f8458e7751c5ea (diff)
Merge pull request #195 from MasterKale/feat/backup-state
feat/backup-state
Diffstat (limited to 'packages/server/src/helpers/parseAuthenticatorData.ts')
-rw-r--r--packages/server/src/helpers/parseAuthenticatorData.ts14
1 files changed, 10 insertions, 4 deletions
diff --git a/packages/server/src/helpers/parseAuthenticatorData.ts b/packages/server/src/helpers/parseAuthenticatorData.ts
index 911c9e0..6bf5b9a 100644
--- a/packages/server/src/helpers/parseAuthenticatorData.ts
+++ b/packages/server/src/helpers/parseAuthenticatorData.ts
@@ -18,11 +18,15 @@ export default function parseAuthenticatorData(authData: Buffer): ParsedAuthenti
const flagsBuf = authData.slice(pointer, (pointer += 1));
const flagsInt = flagsBuf[0];
+ // Bit positions can be referenced here:
+ // https://www.w3.org/TR/webauthn-2/#flags
const flags = {
- up: !!(flagsInt & 0x01),
- uv: !!(flagsInt & 0x04),
- at: !!(flagsInt & 0x40),
- ed: !!(flagsInt & 0x80),
+ up: !!(flagsInt & 1 << 0), // User Presence
+ uv: !!(flagsInt & 1 << 2), // User Verified
+ be: !!(flagsInt & 1 << 3), // Backup Eligibility
+ bs: !!(flagsInt & 1 << 4), // Backup State
+ at: !!(flagsInt & 1 << 6), // Attested Credential Data Present
+ ed: !!(flagsInt & 1 << 7), // Extension Data Present
flagsInt,
};
@@ -80,6 +84,8 @@ export type ParsedAuthenticatorData = {
flags: {
up: boolean;
uv: boolean;
+ be: boolean;
+ bs: boolean;
at: boolean;
ed: boolean;
flagsInt: number;