@metamask-previews/passkey-controller 3.1.0-preview-3866c0ff1 → 3.1.0-preview-e3275932a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +0 -1
- package/dist/PasskeyController-method-action-types.cjs +7 -0
- package/dist/PasskeyController-method-action-types.cjs.map +1 -0
- package/dist/{PasskeyController-method-action-types.d.ts → PasskeyController-method-action-types.d.cts} +2 -2
- package/dist/PasskeyController-method-action-types.d.cts.map +1 -0
- package/dist/PasskeyController-method-action-types.d.mts +204 -0
- package/dist/PasskeyController-method-action-types.d.mts.map +1 -0
- package/dist/{PasskeyController-method-action-types.js → PasskeyController-method-action-types.mjs} +1 -1
- package/dist/PasskeyController-method-action-types.mjs.map +1 -0
- package/dist/PasskeyController.cjs +685 -0
- package/dist/PasskeyController.cjs.map +1 -0
- package/dist/{PasskeyController.d.ts → PasskeyController.d.cts} +6 -6
- package/dist/PasskeyController.d.cts.map +1 -0
- package/dist/PasskeyController.d.mts +208 -0
- package/dist/PasskeyController.d.mts.map +1 -0
- package/dist/PasskeyController.mjs +680 -0
- package/dist/PasskeyController.mjs.map +1 -0
- package/dist/ceremony-manager.cjs +135 -0
- package/dist/ceremony-manager.cjs.map +1 -0
- package/dist/{ceremony-manager.d.ts → ceremony-manager.d.cts} +2 -2
- package/dist/ceremony-manager.d.cts.map +1 -0
- package/dist/ceremony-manager.d.mts +72 -0
- package/dist/ceremony-manager.d.mts.map +1 -0
- package/dist/ceremony-manager.mjs +131 -0
- package/dist/ceremony-manager.mjs.map +1 -0
- package/dist/constants.cjs +39 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/{constants.d.ts → constants.d.cts} +12 -12
- package/dist/constants.d.cts.map +1 -0
- package/dist/constants.d.mts +36 -0
- package/dist/constants.d.mts.map +1 -0
- package/dist/{constants.js → constants.mjs} +1 -1
- package/dist/constants.mjs.map +1 -0
- package/dist/errors.cjs +57 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/{errors.d.ts → errors.d.cts} +2 -2
- package/dist/errors.d.cts.map +1 -0
- package/dist/errors.d.mts +34 -0
- package/dist/errors.d.mts.map +1 -0
- package/dist/{errors.js → errors.mjs} +1 -4
- package/dist/errors.mjs.map +1 -0
- package/dist/index.cjs +15 -0
- package/dist/index.cjs.map +1 -0
- package/dist/{index.d.ts → index.d.cts} +8 -8
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +8 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +5 -0
- package/dist/index.mjs.map +1 -0
- package/dist/key-derivation.cjs +44 -0
- package/dist/key-derivation.cjs.map +1 -0
- package/dist/{key-derivation.d.ts → key-derivation.d.cts} +3 -3
- package/dist/key-derivation.d.cts.map +1 -0
- package/dist/key-derivation.d.mts +20 -0
- package/dist/key-derivation.d.mts.map +1 -0
- package/dist/{key-derivation.js → key-derivation.mjs} +5 -5
- package/dist/key-derivation.mjs.map +1 -0
- package/dist/logger.cjs +9 -0
- package/dist/logger.cjs.map +1 -0
- package/dist/logger.d.cts +5 -0
- package/dist/logger.d.cts.map +1 -0
- package/dist/logger.d.mts +5 -0
- package/dist/logger.d.mts.map +1 -0
- package/dist/logger.mjs +6 -0
- package/dist/logger.mjs.map +1 -0
- package/dist/types.cjs +4 -0
- package/dist/types.cjs.map +1 -0
- package/dist/{types.d.ts → types.d.cts} +6 -6
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +132 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +2 -0
- package/dist/types.mjs.map +1 -0
- package/dist/utils/crypto.cjs +66 -0
- package/dist/utils/crypto.cjs.map +1 -0
- package/dist/utils/{crypto.d.ts → crypto.d.cts} +1 -1
- package/dist/utils/crypto.d.cts.map +1 -0
- package/dist/utils/crypto.d.mts +37 -0
- package/dist/utils/crypto.d.mts.map +1 -0
- package/dist/utils/{crypto.js → crypto.mjs} +7 -7
- package/dist/utils/crypto.mjs.map +1 -0
- package/dist/utils/encoding.cjs +42 -0
- package/dist/utils/encoding.cjs.map +1 -0
- package/dist/utils/{encoding.d.ts → encoding.d.cts} +1 -1
- package/dist/utils/encoding.d.cts.map +1 -0
- package/dist/utils/encoding.d.mts +22 -0
- package/dist/utils/encoding.d.mts.map +1 -0
- package/dist/utils/{encoding.js → encoding.mjs} +2 -2
- package/dist/utils/encoding.mjs.map +1 -0
- package/dist/webauthn/constants.cjs +74 -0
- package/dist/webauthn/constants.cjs.map +1 -0
- package/dist/webauthn/{constants.d.ts → constants.d.cts} +1 -1
- package/dist/webauthn/constants.d.cts.map +1 -0
- package/dist/webauthn/constants.d.mts +68 -0
- package/dist/webauthn/constants.d.mts.map +1 -0
- package/dist/webauthn/{constants.js → constants.mjs} +1 -1
- package/dist/webauthn/constants.mjs.map +1 -0
- package/dist/webauthn/decode-attestation-object.cjs +18 -0
- package/dist/webauthn/decode-attestation-object.cjs.map +1 -0
- package/dist/webauthn/{decode-attestation-object.d.ts → decode-attestation-object.d.cts} +2 -2
- package/dist/webauthn/decode-attestation-object.d.cts.map +1 -0
- package/dist/webauthn/decode-attestation-object.d.mts +10 -0
- package/dist/webauthn/decode-attestation-object.d.mts.map +1 -0
- package/dist/webauthn/{decode-attestation-object.js → decode-attestation-object.mjs} +2 -2
- package/dist/webauthn/decode-attestation-object.mjs.map +1 -0
- package/dist/webauthn/decode-client-data-json.cjs +17 -0
- package/dist/webauthn/decode-client-data-json.cjs.map +1 -0
- package/dist/webauthn/{decode-client-data-json.d.ts → decode-client-data-json.d.cts} +2 -2
- package/dist/webauthn/decode-client-data-json.d.cts.map +1 -0
- package/dist/webauthn/decode-client-data-json.d.mts +9 -0
- package/dist/webauthn/decode-client-data-json.d.mts.map +1 -0
- package/dist/webauthn/{decode-client-data-json.js → decode-client-data-json.mjs} +2 -2
- package/dist/webauthn/decode-client-data-json.mjs.map +1 -0
- package/dist/webauthn/match-expected-rp-id.cjs +26 -0
- package/dist/webauthn/match-expected-rp-id.cjs.map +1 -0
- package/dist/webauthn/{match-expected-rp-id.d.ts → match-expected-rp-id.d.cts} +1 -1
- package/dist/webauthn/match-expected-rp-id.d.cts.map +1 -0
- package/dist/webauthn/match-expected-rp-id.d.mts +11 -0
- package/dist/webauthn/match-expected-rp-id.d.mts.map +1 -0
- package/dist/webauthn/{match-expected-rp-id.js → match-expected-rp-id.mjs} +4 -4
- package/dist/webauthn/match-expected-rp-id.mjs.map +1 -0
- package/dist/webauthn/parse-authenticator-data.cjs +69 -0
- package/dist/webauthn/parse-authenticator-data.cjs.map +1 -0
- package/dist/webauthn/{parse-authenticator-data.d.ts → parse-authenticator-data.d.cts} +2 -2
- package/dist/webauthn/parse-authenticator-data.d.cts.map +1 -0
- package/dist/webauthn/parse-authenticator-data.d.mts +10 -0
- package/dist/webauthn/parse-authenticator-data.d.mts.map +1 -0
- package/dist/webauthn/{parse-authenticator-data.js → parse-authenticator-data.mjs} +2 -2
- package/dist/webauthn/parse-authenticator-data.mjs.map +1 -0
- package/dist/webauthn/types.cjs +3 -0
- package/dist/webauthn/types.cjs.map +1 -0
- package/dist/webauthn/{types.d.ts → types.d.cts} +2 -2
- package/dist/webauthn/types.d.cts.map +1 -0
- package/dist/webauthn/types.d.mts +113 -0
- package/dist/webauthn/types.d.mts.map +1 -0
- package/dist/webauthn/types.mjs +2 -0
- package/dist/webauthn/types.mjs.map +1 -0
- package/dist/webauthn/verify-authentication-response.cjs +133 -0
- package/dist/webauthn/verify-authentication-response.cjs.map +1 -0
- package/dist/webauthn/{verify-authentication-response.d.ts → verify-authentication-response.d.cts} +3 -3
- package/dist/webauthn/verify-authentication-response.d.cts.map +1 -0
- package/dist/webauthn/verify-authentication-response.d.mts +64 -0
- package/dist/webauthn/verify-authentication-response.d.mts.map +1 -0
- package/dist/webauthn/{verify-authentication-response.js → verify-authentication-response.mjs} +9 -9
- package/dist/webauthn/verify-authentication-response.mjs.map +1 -0
- package/dist/webauthn/verify-registration-response.cjs +242 -0
- package/dist/webauthn/verify-registration-response.cjs.map +1 -0
- package/dist/webauthn/{verify-registration-response.d.ts → verify-registration-response.d.cts} +3 -3
- package/dist/webauthn/verify-registration-response.d.cts.map +1 -0
- package/dist/webauthn/verify-registration-response.d.mts +81 -0
- package/dist/webauthn/verify-registration-response.d.mts.map +1 -0
- package/dist/webauthn/{verify-registration-response.js → verify-registration-response.mjs} +11 -11
- package/dist/webauthn/verify-registration-response.mjs.map +1 -0
- package/dist/webauthn/verify-signature.cjs +176 -0
- package/dist/webauthn/verify-signature.cjs.map +1 -0
- package/dist/webauthn/{verify-signature.d.ts → verify-signature.d.cts} +1 -1
- package/dist/webauthn/verify-signature.d.cts.map +1 -0
- package/dist/webauthn/verify-signature.d.mts +21 -0
- package/dist/webauthn/verify-signature.d.mts.map +1 -0
- package/dist/webauthn/{verify-signature.js → verify-signature.mjs} +7 -7
- package/dist/webauthn/verify-signature.mjs.map +1 -0
- package/package.json +17 -12
- package/dist/PasskeyController-method-action-types.d.ts.map +0 -1
- package/dist/PasskeyController-method-action-types.js.map +0 -1
- package/dist/PasskeyController.d.ts.map +0 -1
- package/dist/PasskeyController.js +0 -680
- package/dist/PasskeyController.js.map +0 -1
- package/dist/ceremony-manager.d.ts.map +0 -1
- package/dist/ceremony-manager.js +0 -135
- package/dist/ceremony-manager.js.map +0 -1
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -5
- package/dist/index.js.map +0 -1
- package/dist/key-derivation.d.ts.map +0 -1
- package/dist/key-derivation.js.map +0 -1
- package/dist/logger.d.ts +0 -4
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -6
- package/dist/logger.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/utils/crypto.d.ts.map +0 -1
- package/dist/utils/crypto.js.map +0 -1
- package/dist/utils/encoding.d.ts.map +0 -1
- package/dist/utils/encoding.js.map +0 -1
- package/dist/webauthn/constants.d.ts.map +0 -1
- package/dist/webauthn/constants.js.map +0 -1
- package/dist/webauthn/decode-attestation-object.d.ts.map +0 -1
- package/dist/webauthn/decode-attestation-object.js.map +0 -1
- package/dist/webauthn/decode-client-data-json.d.ts.map +0 -1
- package/dist/webauthn/decode-client-data-json.js.map +0 -1
- package/dist/webauthn/match-expected-rp-id.d.ts.map +0 -1
- package/dist/webauthn/match-expected-rp-id.js.map +0 -1
- package/dist/webauthn/parse-authenticator-data.d.ts.map +0 -1
- package/dist/webauthn/parse-authenticator-data.js.map +0 -1
- package/dist/webauthn/types.d.ts.map +0 -1
- package/dist/webauthn/types.js +0 -2
- package/dist/webauthn/types.js.map +0 -1
- package/dist/webauthn/verify-authentication-response.d.ts.map +0 -1
- package/dist/webauthn/verify-authentication-response.js.map +0 -1
- package/dist/webauthn/verify-registration-response.d.ts.map +0 -1
- package/dist/webauthn/verify-registration-response.js.map +0 -1
- package/dist/webauthn/verify-signature.d.ts.map +0 -1
- package/dist/webauthn/verify-signature.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode-attestation-object.cjs","sourceRoot":"","sources":["../../src/webauthn/decode-attestation-object.ts"],"names":[],"mappings":";;;AAAA,qDAA0D;AAI1D;;;;;;GAMG;AACH,SAAgB,uBAAuB,CACrC,iBAA6B;IAE7B,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAC/C,MAAM,CAAC,OAAO,CAAC,GAAG,IAAA,6BAAiB,EAAC,IAAI,EAAE,CAAC,CAAgC,CAAC;IAC5E,OAAO,OAAO,CAAC;AACjB,CAAC;AAND,0DAMC","sourcesContent":["import { decodePartialCBOR } from '@levischuck/tiny-cbor';\n\nimport type { AttestationObject } from './types.js';\n\n/**\n * CBOR-decode an attestationObject buffer into a Map with `fmt`, `attStmt`,\n * and `authData` entries.\n *\n * @param attestationObject - Raw attestation object bytes.\n * @returns Decoded AttestationObject map.\n */\nexport function decodeAttestationObject(\n attestationObject: Uint8Array,\n): AttestationObject {\n const copy = new Uint8Array(attestationObject);\n const [decoded] = decodePartialCBOR(copy, 0) as [AttestationObject, number];\n return decoded;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AttestationObject } from
|
|
1
|
+
import type { AttestationObject } from "./types.cjs";
|
|
2
2
|
/**
|
|
3
3
|
* CBOR-decode an attestationObject buffer into a Map with `fmt`, `attStmt`,
|
|
4
4
|
* and `authData` entries.
|
|
@@ -7,4 +7,4 @@ import type { AttestationObject } from './types.js';
|
|
|
7
7
|
* @returns Decoded AttestationObject map.
|
|
8
8
|
*/
|
|
9
9
|
export declare function decodeAttestationObject(attestationObject: Uint8Array): AttestationObject;
|
|
10
|
-
//# sourceMappingURL=decode-attestation-object.d.
|
|
10
|
+
//# sourceMappingURL=decode-attestation-object.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode-attestation-object.d.cts","sourceRoot":"","sources":["../../src/webauthn/decode-attestation-object.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,oBAAmB;AAEpD;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,iBAAiB,EAAE,UAAU,GAC5B,iBAAiB,CAInB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AttestationObject } from "./types.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* CBOR-decode an attestationObject buffer into a Map with `fmt`, `attStmt`,
|
|
4
|
+
* and `authData` entries.
|
|
5
|
+
*
|
|
6
|
+
* @param attestationObject - Raw attestation object bytes.
|
|
7
|
+
* @returns Decoded AttestationObject map.
|
|
8
|
+
*/
|
|
9
|
+
export declare function decodeAttestationObject(attestationObject: Uint8Array): AttestationObject;
|
|
10
|
+
//# sourceMappingURL=decode-attestation-object.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode-attestation-object.d.mts","sourceRoot":"","sources":["../../src/webauthn/decode-attestation-object.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,oBAAmB;AAEpD;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,iBAAiB,EAAE,UAAU,GAC5B,iBAAiB,CAInB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { decodePartialCBOR } from
|
|
1
|
+
import { decodePartialCBOR } from "@levischuck/tiny-cbor";
|
|
2
2
|
/**
|
|
3
3
|
* CBOR-decode an attestationObject buffer into a Map with `fmt`, `attStmt`,
|
|
4
4
|
* and `authData` entries.
|
|
@@ -11,4 +11,4 @@ export function decodeAttestationObject(attestationObject) {
|
|
|
11
11
|
const [decoded] = decodePartialCBOR(copy, 0);
|
|
12
12
|
return decoded;
|
|
13
13
|
}
|
|
14
|
-
//# sourceMappingURL=decode-attestation-object.
|
|
14
|
+
//# sourceMappingURL=decode-attestation-object.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode-attestation-object.mjs","sourceRoot":"","sources":["../../src/webauthn/decode-attestation-object.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,8BAA8B;AAI1D;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CACrC,iBAA6B;IAE7B,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAC/C,MAAM,CAAC,OAAO,CAAC,GAAG,iBAAiB,CAAC,IAAI,EAAE,CAAC,CAAgC,CAAC;IAC5E,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import { decodePartialCBOR } from '@levischuck/tiny-cbor';\n\nimport type { AttestationObject } from './types.js';\n\n/**\n * CBOR-decode an attestationObject buffer into a Map with `fmt`, `attStmt`,\n * and `authData` entries.\n *\n * @param attestationObject - Raw attestation object bytes.\n * @returns Decoded AttestationObject map.\n */\nexport function decodeAttestationObject(\n attestationObject: Uint8Array,\n): AttestationObject {\n const copy = new Uint8Array(attestationObject);\n const [decoded] = decodePartialCBOR(copy, 0) as [AttestationObject, number];\n return decoded;\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decodeClientDataJSON = void 0;
|
|
4
|
+
const encoding_js_1 = require("../utils/encoding.cjs");
|
|
5
|
+
/**
|
|
6
|
+
* Decode an authenticator's base64url-encoded clientDataJSON to JSON.
|
|
7
|
+
*
|
|
8
|
+
* @param data - Base64url-encoded clientDataJSON string.
|
|
9
|
+
* @returns Parsed ClientDataJSON object.
|
|
10
|
+
*/
|
|
11
|
+
function decodeClientDataJSON(data) {
|
|
12
|
+
const bytes = (0, encoding_js_1.base64URLToBytes)(data);
|
|
13
|
+
const text = new TextDecoder().decode(bytes);
|
|
14
|
+
return JSON.parse(text);
|
|
15
|
+
}
|
|
16
|
+
exports.decodeClientDataJSON = decodeClientDataJSON;
|
|
17
|
+
//# sourceMappingURL=decode-client-data-json.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode-client-data-json.cjs","sourceRoot":"","sources":["../../src/webauthn/decode-client-data-json.ts"],"names":[],"mappings":";;;AAAA,uDAAwD;AAGxD;;;;;GAKG;AACH,SAAgB,oBAAoB,CAAC,IAAY;IAC/C,MAAM,KAAK,GAAG,IAAA,8BAAgB,EAAC,IAAI,CAAC,CAAC;IACrC,MAAM,IAAI,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAmB,CAAC;AAC5C,CAAC;AAJD,oDAIC","sourcesContent":["import { base64URLToBytes } from '../utils/encoding.js';\nimport type { ClientDataJSON } from './types.js';\n\n/**\n * Decode an authenticator's base64url-encoded clientDataJSON to JSON.\n *\n * @param data - Base64url-encoded clientDataJSON string.\n * @returns Parsed ClientDataJSON object.\n */\nexport function decodeClientDataJSON(data: string): ClientDataJSON {\n const bytes = base64URLToBytes(data);\n const text = new TextDecoder().decode(bytes);\n return JSON.parse(text) as ClientDataJSON;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ClientDataJSON } from
|
|
1
|
+
import type { ClientDataJSON } from "./types.cjs";
|
|
2
2
|
/**
|
|
3
3
|
* Decode an authenticator's base64url-encoded clientDataJSON to JSON.
|
|
4
4
|
*
|
|
@@ -6,4 +6,4 @@ import type { ClientDataJSON } from './types.js';
|
|
|
6
6
|
* @returns Parsed ClientDataJSON object.
|
|
7
7
|
*/
|
|
8
8
|
export declare function decodeClientDataJSON(data: string): ClientDataJSON;
|
|
9
|
-
//# sourceMappingURL=decode-client-data-json.d.
|
|
9
|
+
//# sourceMappingURL=decode-client-data-json.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode-client-data-json.d.cts","sourceRoot":"","sources":["../../src/webauthn/decode-client-data-json.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAmB;AAEjD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAIjE"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ClientDataJSON } from "./types.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Decode an authenticator's base64url-encoded clientDataJSON to JSON.
|
|
4
|
+
*
|
|
5
|
+
* @param data - Base64url-encoded clientDataJSON string.
|
|
6
|
+
* @returns Parsed ClientDataJSON object.
|
|
7
|
+
*/
|
|
8
|
+
export declare function decodeClientDataJSON(data: string): ClientDataJSON;
|
|
9
|
+
//# sourceMappingURL=decode-client-data-json.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode-client-data-json.d.mts","sourceRoot":"","sources":["../../src/webauthn/decode-client-data-json.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAmB;AAEjD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAIjE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { base64URLToBytes } from
|
|
1
|
+
import { base64URLToBytes } from "../utils/encoding.mjs";
|
|
2
2
|
/**
|
|
3
3
|
* Decode an authenticator's base64url-encoded clientDataJSON to JSON.
|
|
4
4
|
*
|
|
@@ -10,4 +10,4 @@ export function decodeClientDataJSON(data) {
|
|
|
10
10
|
const text = new TextDecoder().decode(bytes);
|
|
11
11
|
return JSON.parse(text);
|
|
12
12
|
}
|
|
13
|
-
//# sourceMappingURL=decode-client-data-json.
|
|
13
|
+
//# sourceMappingURL=decode-client-data-json.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode-client-data-json.mjs","sourceRoot":"","sources":["../../src/webauthn/decode-client-data-json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,8BAA6B;AAGxD;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAY;IAC/C,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,IAAI,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAmB,CAAC;AAC5C,CAAC","sourcesContent":["import { base64URLToBytes } from '../utils/encoding.js';\nimport type { ClientDataJSON } from './types.js';\n\n/**\n * Decode an authenticator's base64url-encoded clientDataJSON to JSON.\n *\n * @param data - Base64url-encoded clientDataJSON string.\n * @returns Parsed ClientDataJSON object.\n */\nexport function decodeClientDataJSON(data: string): ClientDataJSON {\n const bytes = base64URLToBytes(data);\n const text = new TextDecoder().decode(bytes);\n return JSON.parse(text) as ClientDataJSON;\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.matchExpectedRPID = void 0;
|
|
4
|
+
const utils_1 = require("@metamask/utils");
|
|
5
|
+
const sha2_1 = require("@noble/hashes/sha2");
|
|
6
|
+
const encoding_js_1 = require("../utils/encoding.cjs");
|
|
7
|
+
/**
|
|
8
|
+
* Verify that an authenticator data rpIdHash matches one of the expected
|
|
9
|
+
* RP IDs by SHA-256 hashing each candidate and comparing.
|
|
10
|
+
*
|
|
11
|
+
* @param rpIdHash - The rpIdHash from authenticatorData (32 bytes).
|
|
12
|
+
* @param expectedRPIDs - One or more RP ID strings to check against.
|
|
13
|
+
* @returns The matching RP ID string.
|
|
14
|
+
* @throws If no expected RP ID matches.
|
|
15
|
+
*/
|
|
16
|
+
function matchExpectedRPID(rpIdHash, expectedRPIDs) {
|
|
17
|
+
for (const rpID of expectedRPIDs) {
|
|
18
|
+
const expectedHash = (0, sha2_1.sha256)(new TextEncoder().encode(rpID));
|
|
19
|
+
if ((0, utils_1.areUint8ArraysEqual)(rpIdHash, expectedHash)) {
|
|
20
|
+
return rpID;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
throw new Error(`Unexpected RP ID hash: received ${(0, encoding_js_1.bytesToHex)(rpIdHash)}`);
|
|
24
|
+
}
|
|
25
|
+
exports.matchExpectedRPID = matchExpectedRPID;
|
|
26
|
+
//# sourceMappingURL=match-expected-rp-id.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match-expected-rp-id.cjs","sourceRoot":"","sources":["../../src/webauthn/match-expected-rp-id.ts"],"names":[],"mappings":";;;AAAA,2CAAsD;AACtD,6CAA4C;AAE5C,uDAAkD;AAElD;;;;;;;;GAQG;AACH,SAAgB,iBAAiB,CAC/B,QAAoB,EACpB,aAAuB;IAEvB,KAAK,MAAM,IAAI,IAAI,aAAa,EAAE,CAAC;QACjC,MAAM,YAAY,GAAG,IAAA,aAAM,EAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5D,IAAI,IAAA,2BAAmB,EAAC,QAAQ,EAAE,YAAY,CAAC,EAAE,CAAC;YAChD,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,mCAAmC,IAAA,wBAAU,EAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AAC7E,CAAC;AAXD,8CAWC","sourcesContent":["import { areUint8ArraysEqual } from '@metamask/utils';\nimport { sha256 } from '@noble/hashes/sha2';\n\nimport { bytesToHex } from '../utils/encoding.js';\n\n/**\n * Verify that an authenticator data rpIdHash matches one of the expected\n * RP IDs by SHA-256 hashing each candidate and comparing.\n *\n * @param rpIdHash - The rpIdHash from authenticatorData (32 bytes).\n * @param expectedRPIDs - One or more RP ID strings to check against.\n * @returns The matching RP ID string.\n * @throws If no expected RP ID matches.\n */\nexport function matchExpectedRPID(\n rpIdHash: Uint8Array,\n expectedRPIDs: string[],\n): string {\n for (const rpID of expectedRPIDs) {\n const expectedHash = sha256(new TextEncoder().encode(rpID));\n if (areUint8ArraysEqual(rpIdHash, expectedHash)) {\n return rpID;\n }\n }\n throw new Error(`Unexpected RP ID hash: received ${bytesToHex(rpIdHash)}`);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match-expected-rp-id.d.cts","sourceRoot":"","sources":["../../src/webauthn/match-expected-rp-id.ts"],"names":[],"mappings":"AAKA;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,UAAU,EACpB,aAAa,EAAE,MAAM,EAAE,GACtB,MAAM,CAQR"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verify that an authenticator data rpIdHash matches one of the expected
|
|
3
|
+
* RP IDs by SHA-256 hashing each candidate and comparing.
|
|
4
|
+
*
|
|
5
|
+
* @param rpIdHash - The rpIdHash from authenticatorData (32 bytes).
|
|
6
|
+
* @param expectedRPIDs - One or more RP ID strings to check against.
|
|
7
|
+
* @returns The matching RP ID string.
|
|
8
|
+
* @throws If no expected RP ID matches.
|
|
9
|
+
*/
|
|
10
|
+
export declare function matchExpectedRPID(rpIdHash: Uint8Array, expectedRPIDs: string[]): string;
|
|
11
|
+
//# sourceMappingURL=match-expected-rp-id.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match-expected-rp-id.d.mts","sourceRoot":"","sources":["../../src/webauthn/match-expected-rp-id.ts"],"names":[],"mappings":"AAKA;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,UAAU,EACpB,aAAa,EAAE,MAAM,EAAE,GACtB,MAAM,CAQR"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { areUint8ArraysEqual } from
|
|
2
|
-
import { sha256 } from
|
|
3
|
-
import { bytesToHex } from
|
|
1
|
+
import { areUint8ArraysEqual } from "@metamask/utils";
|
|
2
|
+
import { sha256 } from "@noble/hashes/sha2";
|
|
3
|
+
import { bytesToHex } from "../utils/encoding.mjs";
|
|
4
4
|
/**
|
|
5
5
|
* Verify that an authenticator data rpIdHash matches one of the expected
|
|
6
6
|
* RP IDs by SHA-256 hashing each candidate and comparing.
|
|
@@ -19,4 +19,4 @@ export function matchExpectedRPID(rpIdHash, expectedRPIDs) {
|
|
|
19
19
|
}
|
|
20
20
|
throw new Error(`Unexpected RP ID hash: received ${bytesToHex(rpIdHash)}`);
|
|
21
21
|
}
|
|
22
|
-
//# sourceMappingURL=match-expected-rp-id.
|
|
22
|
+
//# sourceMappingURL=match-expected-rp-id.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match-expected-rp-id.mjs","sourceRoot":"","sources":["../../src/webauthn/match-expected-rp-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,wBAAwB;AACtD,OAAO,EAAE,MAAM,EAAE,2BAA2B;AAE5C,OAAO,EAAE,UAAU,EAAE,8BAA6B;AAElD;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAC/B,QAAoB,EACpB,aAAuB;IAEvB,KAAK,MAAM,IAAI,IAAI,aAAa,EAAE,CAAC;QACjC,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5D,IAAI,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC,EAAE,CAAC;YAChD,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,mCAAmC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AAC7E,CAAC","sourcesContent":["import { areUint8ArraysEqual } from '@metamask/utils';\nimport { sha256 } from '@noble/hashes/sha2';\n\nimport { bytesToHex } from '../utils/encoding.js';\n\n/**\n * Verify that an authenticator data rpIdHash matches one of the expected\n * RP IDs by SHA-256 hashing each candidate and comparing.\n *\n * @param rpIdHash - The rpIdHash from authenticatorData (32 bytes).\n * @param expectedRPIDs - One or more RP ID strings to check against.\n * @returns The matching RP ID string.\n * @throws If no expected RP ID matches.\n */\nexport function matchExpectedRPID(\n rpIdHash: Uint8Array,\n expectedRPIDs: string[],\n): string {\n for (const rpID of expectedRPIDs) {\n const expectedHash = sha256(new TextEncoder().encode(rpID));\n if (areUint8ArraysEqual(rpIdHash, expectedHash)) {\n return rpID;\n }\n }\n throw new Error(`Unexpected RP ID hash: received ${bytesToHex(rpIdHash)}`);\n}\n"]}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseAuthenticatorData = void 0;
|
|
4
|
+
const tiny_cbor_1 = require("@levischuck/tiny-cbor");
|
|
5
|
+
/* eslint-disable no-bitwise */
|
|
6
|
+
/**
|
|
7
|
+
* Parse an authenticator data buffer per §6.1 of the WebAuthn spec.
|
|
8
|
+
*
|
|
9
|
+
* @param authData - Raw authenticator data bytes.
|
|
10
|
+
* @returns Parsed authenticator data with flags, rpIdHash, counter, and
|
|
11
|
+
* optional attested credential data.
|
|
12
|
+
*/
|
|
13
|
+
function parseAuthenticatorData(authData) {
|
|
14
|
+
if (authData.byteLength < 37) {
|
|
15
|
+
throw new Error(`authenticatorData is ${authData.byteLength} bytes, expected at least 37`);
|
|
16
|
+
}
|
|
17
|
+
let pointer = 0;
|
|
18
|
+
const rpIdHash = authData.slice(pointer, pointer + 32);
|
|
19
|
+
pointer += 32;
|
|
20
|
+
const flagsByte = authData[pointer];
|
|
21
|
+
const flags = {
|
|
22
|
+
up: Boolean(flagsByte & (1 << 0)),
|
|
23
|
+
uv: Boolean(flagsByte & (1 << 2)),
|
|
24
|
+
be: Boolean(flagsByte & (1 << 3)),
|
|
25
|
+
bs: Boolean(flagsByte & (1 << 4)),
|
|
26
|
+
at: Boolean(flagsByte & (1 << 6)),
|
|
27
|
+
ed: Boolean(flagsByte & (1 << 7)),
|
|
28
|
+
flagsByte,
|
|
29
|
+
};
|
|
30
|
+
pointer += 1;
|
|
31
|
+
const counterView = new DataView(authData.buffer, authData.byteOffset + pointer, 4);
|
|
32
|
+
const counter = counterView.getUint32(0, false);
|
|
33
|
+
pointer += 4;
|
|
34
|
+
const result = {
|
|
35
|
+
rpIdHash,
|
|
36
|
+
flags,
|
|
37
|
+
counter,
|
|
38
|
+
};
|
|
39
|
+
if (flags.at) {
|
|
40
|
+
const aaguid = authData.slice(pointer, pointer + 16);
|
|
41
|
+
pointer += 16;
|
|
42
|
+
const credIDLenView = new DataView(authData.buffer, authData.byteOffset + pointer, 2);
|
|
43
|
+
const credIDLen = credIDLenView.getUint16(0, false);
|
|
44
|
+
pointer += 2;
|
|
45
|
+
const credentialID = authData.slice(pointer, pointer + credIDLen);
|
|
46
|
+
pointer += credIDLen;
|
|
47
|
+
const pubKeyBytes = authData.slice(pointer);
|
|
48
|
+
const [, nextOffset] = (0, tiny_cbor_1.decodePartialCBOR)(new Uint8Array(pubKeyBytes), 0);
|
|
49
|
+
const credentialPublicKey = authData.slice(pointer, pointer + nextOffset);
|
|
50
|
+
pointer += nextOffset;
|
|
51
|
+
result.aaguid = aaguid;
|
|
52
|
+
result.credentialID = credentialID;
|
|
53
|
+
result.credentialPublicKey = credentialPublicKey;
|
|
54
|
+
}
|
|
55
|
+
if (flags.ed) {
|
|
56
|
+
const remaining = authData.slice(pointer);
|
|
57
|
+
const [decoded, consumed] = (0, tiny_cbor_1.decodePartialCBOR)(new Uint8Array(remaining), 0);
|
|
58
|
+
result.extensionsData = decoded;
|
|
59
|
+
result.extensionsDataBuffer = remaining.slice(0, consumed);
|
|
60
|
+
pointer += consumed;
|
|
61
|
+
}
|
|
62
|
+
if (authData.byteLength > pointer) {
|
|
63
|
+
throw new Error('Leftover bytes detected while parsing authenticator data');
|
|
64
|
+
}
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
exports.parseAuthenticatorData = parseAuthenticatorData;
|
|
68
|
+
/* eslint-enable no-bitwise */
|
|
69
|
+
//# sourceMappingURL=parse-authenticator-data.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-authenticator-data.cjs","sourceRoot":"","sources":["../../src/webauthn/parse-authenticator-data.ts"],"names":[],"mappings":";;;AAAA,qDAA0D;AAO1D,+BAA+B;AAE/B;;;;;;GAMG;AACH,SAAgB,sBAAsB,CACpC,QAAoB;IAEpB,IAAI,QAAQ,CAAC,UAAU,GAAG,EAAE,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CACb,wBAAwB,QAAQ,CAAC,UAAU,8BAA8B,CAC1E,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,GAAG,CAAC,CAAC;IAEhB,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,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,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AApFD,wDAoFC;AAED,8BAA8B","sourcesContent":["import { decodePartialCBOR } from '@levischuck/tiny-cbor';\n\nimport type {\n ParsedAuthenticatorData,\n AuthenticatorDataFlags,\n} from './types.js';\n\n/* eslint-disable no-bitwise */\n\n/**\n * Parse an authenticator data buffer per §6.1 of the WebAuthn spec.\n *\n * @param authData - Raw authenticator data bytes.\n * @returns Parsed authenticator data with flags, rpIdHash, counter, and\n * optional attested credential data.\n */\nexport function parseAuthenticatorData(\n authData: Uint8Array,\n): ParsedAuthenticatorData {\n if (authData.byteLength < 37) {\n throw new Error(\n `authenticatorData is ${authData.byteLength} bytes, expected at least 37`,\n );\n }\n\n let pointer = 0;\n\n const rpIdHash = authData.slice(pointer, pointer + 32);\n pointer += 32;\n\n const flagsByte = authData[pointer];\n const flags: AuthenticatorDataFlags = {\n up: Boolean(flagsByte & (1 << 0)),\n uv: Boolean(flagsByte & (1 << 2)),\n be: Boolean(flagsByte & (1 << 3)),\n bs: Boolean(flagsByte & (1 << 4)),\n at: Boolean(flagsByte & (1 << 6)),\n ed: Boolean(flagsByte & (1 << 7)),\n flagsByte,\n };\n pointer += 1;\n\n const counterView = new DataView(\n authData.buffer,\n authData.byteOffset + pointer,\n 4,\n );\n const counter = counterView.getUint32(0, false);\n pointer += 4;\n\n const result: ParsedAuthenticatorData = {\n rpIdHash,\n flags,\n counter,\n };\n\n if (flags.at) {\n const aaguid = authData.slice(pointer, pointer + 16);\n pointer += 16;\n\n const credIDLenView = new DataView(\n authData.buffer,\n authData.byteOffset + pointer,\n 2,\n );\n const credIDLen = credIDLenView.getUint16(0, false);\n pointer += 2;\n\n const credentialID = authData.slice(pointer, pointer + credIDLen);\n pointer += credIDLen;\n\n const pubKeyBytes = authData.slice(pointer);\n const [, nextOffset] = decodePartialCBOR(\n new Uint8Array(pubKeyBytes),\n 0,\n ) as [unknown, number];\n const credentialPublicKey = authData.slice(pointer, pointer + nextOffset);\n pointer += nextOffset;\n\n result.aaguid = aaguid;\n result.credentialID = credentialID;\n result.credentialPublicKey = credentialPublicKey;\n }\n\n if (flags.ed) {\n const remaining = authData.slice(pointer);\n const [decoded, consumed] = decodePartialCBOR(\n new Uint8Array(remaining),\n 0,\n ) as [Map<string, unknown>, number];\n result.extensionsData = decoded;\n result.extensionsDataBuffer = remaining.slice(0, consumed);\n pointer += consumed;\n }\n\n if (authData.byteLength > pointer) {\n throw new Error('Leftover bytes detected while parsing authenticator data');\n }\n\n return result;\n}\n\n/* eslint-enable no-bitwise */\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ParsedAuthenticatorData } from
|
|
1
|
+
import type { ParsedAuthenticatorData } from "./types.cjs";
|
|
2
2
|
/**
|
|
3
3
|
* Parse an authenticator data buffer per §6.1 of the WebAuthn spec.
|
|
4
4
|
*
|
|
@@ -7,4 +7,4 @@ import type { ParsedAuthenticatorData } from './types.js';
|
|
|
7
7
|
* optional attested credential data.
|
|
8
8
|
*/
|
|
9
9
|
export declare function parseAuthenticatorData(authData: Uint8Array): ParsedAuthenticatorData;
|
|
10
|
-
//# sourceMappingURL=parse-authenticator-data.d.
|
|
10
|
+
//# sourceMappingURL=parse-authenticator-data.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-authenticator-data.d.cts","sourceRoot":"","sources":["../../src/webauthn/parse-authenticator-data.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,uBAAuB,EAExB,oBAAmB;AAIpB;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,UAAU,GACnB,uBAAuB,CAkFzB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ParsedAuthenticatorData } from "./types.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Parse an authenticator data buffer per §6.1 of the WebAuthn spec.
|
|
4
|
+
*
|
|
5
|
+
* @param authData - Raw authenticator data bytes.
|
|
6
|
+
* @returns Parsed authenticator data with flags, rpIdHash, counter, and
|
|
7
|
+
* optional attested credential data.
|
|
8
|
+
*/
|
|
9
|
+
export declare function parseAuthenticatorData(authData: Uint8Array): ParsedAuthenticatorData;
|
|
10
|
+
//# sourceMappingURL=parse-authenticator-data.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-authenticator-data.d.mts","sourceRoot":"","sources":["../../src/webauthn/parse-authenticator-data.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,uBAAuB,EAExB,oBAAmB;AAIpB;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,UAAU,GACnB,uBAAuB,CAkFzB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { decodePartialCBOR } from
|
|
1
|
+
import { decodePartialCBOR } from "@levischuck/tiny-cbor";
|
|
2
2
|
/* eslint-disable no-bitwise */
|
|
3
3
|
/**
|
|
4
4
|
* Parse an authenticator data buffer per §6.1 of the WebAuthn spec.
|
|
@@ -62,4 +62,4 @@ export function parseAuthenticatorData(authData) {
|
|
|
62
62
|
return result;
|
|
63
63
|
}
|
|
64
64
|
/* eslint-enable no-bitwise */
|
|
65
|
-
//# sourceMappingURL=parse-authenticator-data.
|
|
65
|
+
//# sourceMappingURL=parse-authenticator-data.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-authenticator-data.mjs","sourceRoot":"","sources":["../../src/webauthn/parse-authenticator-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,8BAA8B;AAO1D,+BAA+B;AAE/B;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CACpC,QAAoB;IAEpB,IAAI,QAAQ,CAAC,UAAU,GAAG,EAAE,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CACb,wBAAwB,QAAQ,CAAC,UAAU,8BAA8B,CAC1E,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,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;QAClC,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAC9E,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,8BAA8B","sourcesContent":["import { decodePartialCBOR } from '@levischuck/tiny-cbor';\n\nimport type {\n ParsedAuthenticatorData,\n AuthenticatorDataFlags,\n} from './types.js';\n\n/* eslint-disable no-bitwise */\n\n/**\n * Parse an authenticator data buffer per §6.1 of the WebAuthn spec.\n *\n * @param authData - Raw authenticator data bytes.\n * @returns Parsed authenticator data with flags, rpIdHash, counter, and\n * optional attested credential data.\n */\nexport function parseAuthenticatorData(\n authData: Uint8Array,\n): ParsedAuthenticatorData {\n if (authData.byteLength < 37) {\n throw new Error(\n `authenticatorData is ${authData.byteLength} bytes, expected at least 37`,\n );\n }\n\n let pointer = 0;\n\n const rpIdHash = authData.slice(pointer, pointer + 32);\n pointer += 32;\n\n const flagsByte = authData[pointer];\n const flags: AuthenticatorDataFlags = {\n up: Boolean(flagsByte & (1 << 0)),\n uv: Boolean(flagsByte & (1 << 2)),\n be: Boolean(flagsByte & (1 << 3)),\n bs: Boolean(flagsByte & (1 << 4)),\n at: Boolean(flagsByte & (1 << 6)),\n ed: Boolean(flagsByte & (1 << 7)),\n flagsByte,\n };\n pointer += 1;\n\n const counterView = new DataView(\n authData.buffer,\n authData.byteOffset + pointer,\n 4,\n );\n const counter = counterView.getUint32(0, false);\n pointer += 4;\n\n const result: ParsedAuthenticatorData = {\n rpIdHash,\n flags,\n counter,\n };\n\n if (flags.at) {\n const aaguid = authData.slice(pointer, pointer + 16);\n pointer += 16;\n\n const credIDLenView = new DataView(\n authData.buffer,\n authData.byteOffset + pointer,\n 2,\n );\n const credIDLen = credIDLenView.getUint16(0, false);\n pointer += 2;\n\n const credentialID = authData.slice(pointer, pointer + credIDLen);\n pointer += credIDLen;\n\n const pubKeyBytes = authData.slice(pointer);\n const [, nextOffset] = decodePartialCBOR(\n new Uint8Array(pubKeyBytes),\n 0,\n ) as [unknown, number];\n const credentialPublicKey = authData.slice(pointer, pointer + nextOffset);\n pointer += nextOffset;\n\n result.aaguid = aaguid;\n result.credentialID = credentialID;\n result.credentialPublicKey = credentialPublicKey;\n }\n\n if (flags.ed) {\n const remaining = authData.slice(pointer);\n const [decoded, consumed] = decodePartialCBOR(\n new Uint8Array(remaining),\n 0,\n ) as [Map<string, unknown>, number];\n result.extensionsData = decoded;\n result.extensionsDataBuffer = remaining.slice(0, consumed);\n pointer += consumed;\n }\n\n if (authData.byteLength > pointer) {\n throw new Error('Leftover bytes detected while parsing authenticator data');\n }\n\n return result;\n}\n\n/* eslint-enable no-bitwise */\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../src/webauthn/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n AuthenticatorTransportFuture,\n Base64URLString as Base64URL,\n} from '../types.js';\n\nexport type PublicKeyCredentialDescriptorJSON = {\n id: Base64URL;\n type: 'public-key';\n transports?: AuthenticatorTransportFuture[];\n};\n\nexport type PublicKeyCredentialHint =\n | 'hybrid'\n | 'security-key'\n | 'client-device';\n\nexport type PasskeyRegistrationOptions = {\n rp: { name: string; id?: string };\n user: {\n id: Base64URL;\n name: string;\n displayName: string;\n };\n challenge: Base64URL;\n pubKeyCredParams: { alg: number; type: 'public-key' }[];\n timeout?: number;\n excludeCredentials?: PublicKeyCredentialDescriptorJSON[];\n authenticatorSelection?: {\n authenticatorAttachment?: 'cross-platform' | 'platform';\n residentKey?: 'discouraged' | 'preferred' | 'required';\n requireResidentKey?: boolean;\n userVerification?: 'discouraged' | 'preferred' | 'required';\n };\n hints?: PublicKeyCredentialHint[];\n attestation?: 'direct' | 'enterprise' | 'indirect' | 'none';\n extensions?: Record<string, unknown>;\n};\n\nexport type PasskeyRegistrationResponse = {\n id: Base64URL;\n rawId: Base64URL;\n type: 'public-key';\n response: {\n clientDataJSON: Base64URL;\n attestationObject: Base64URL;\n transports?: string[];\n publicKeyAlgorithm?: number;\n publicKey?: Base64URL;\n authenticatorData?: Base64URL;\n };\n authenticatorAttachment?: 'cross-platform' | 'platform';\n clientExtensionResults: Record<string, unknown>;\n};\n\nexport type PasskeyAuthenticationOptions = {\n challenge: Base64URL;\n timeout?: number;\n rpId?: string;\n allowCredentials?: PublicKeyCredentialDescriptorJSON[];\n userVerification?: 'discouraged' | 'preferred' | 'required';\n hints?: PublicKeyCredentialHint[];\n extensions?: Record<string, unknown>;\n};\n\nexport type PasskeyAuthenticationResponse = {\n id: Base64URL;\n rawId: Base64URL;\n type: 'public-key';\n response: {\n clientDataJSON: Base64URL;\n authenticatorData: Base64URL;\n signature: Base64URL;\n userHandle?: Base64URL;\n };\n authenticatorAttachment?: 'cross-platform' | 'platform';\n clientExtensionResults: Record<string, unknown>;\n};\n\nexport type ClientDataJSON = {\n type: string;\n challenge: string;\n origin: string;\n crossOrigin?: boolean;\n tokenBinding?: {\n id?: string;\n status: 'present' | 'supported' | 'not-supported';\n };\n};\n\nexport type AttestationFormat =\n | 'fido-u2f'\n | 'packed'\n | 'android-safetynet'\n | 'android-key'\n | 'tpm'\n | 'apple'\n | 'none';\n\nexport type AttestationObject = {\n get(key: 'fmt'): AttestationFormat;\n get(key: 'attStmt'): AttestationStatement;\n get(key: 'authData'): Uint8Array;\n};\n\nexport type AttestationStatement = {\n get(key: 'sig'): Uint8Array | undefined;\n get(key: 'x5c'): Uint8Array[] | undefined;\n get(key: 'alg'): number | undefined;\n readonly size: number;\n};\n\nexport type AuthenticatorDataFlags = {\n up: boolean;\n uv: boolean;\n be: boolean;\n bs: boolean;\n at: boolean;\n ed: boolean;\n flagsByte: number;\n};\n\nexport type ParsedAuthenticatorData = {\n rpIdHash: Uint8Array;\n flags: AuthenticatorDataFlags;\n counter: number;\n aaguid?: Uint8Array;\n credentialID?: Uint8Array;\n credentialPublicKey?: Uint8Array;\n extensionsData?: Map<string, unknown>;\n extensionsDataBuffer?: Uint8Array;\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AuthenticatorTransportFuture, Base64URLString as Base64URL } from
|
|
1
|
+
import type { AuthenticatorTransportFuture, Base64URLString as Base64URL } from "../types.cjs";
|
|
2
2
|
export type PublicKeyCredentialDescriptorJSON = {
|
|
3
3
|
id: Base64URL;
|
|
4
4
|
type: 'public-key';
|
|
@@ -110,4 +110,4 @@ export type ParsedAuthenticatorData = {
|
|
|
110
110
|
extensionsData?: Map<string, unknown>;
|
|
111
111
|
extensionsDataBuffer?: Uint8Array;
|
|
112
112
|
};
|
|
113
|
-
//# sourceMappingURL=types.d.
|
|
113
|
+
//# sourceMappingURL=types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../src/webauthn/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,4BAA4B,EAC5B,eAAe,IAAI,SAAS,EAC7B,qBAAoB;AAErB,MAAM,MAAM,iCAAiC,GAAG;IAC9C,EAAE,EAAE,SAAS,CAAC;IACd,IAAI,EAAE,YAAY,CAAC;IACnB,UAAU,CAAC,EAAE,4BAA4B,EAAE,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAC/B,QAAQ,GACR,cAAc,GACd,eAAe,CAAC;AAEpB,MAAM,MAAM,0BAA0B,GAAG;IACvC,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAClC,IAAI,EAAE;QACJ,EAAE,EAAE,SAAS,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,SAAS,EAAE,SAAS,CAAC;IACrB,gBAAgB,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,YAAY,CAAA;KAAE,EAAE,CAAC;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kBAAkB,CA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,SAAS,CAAC;IACxC,GAAG,CAAC,GAAG,EAAE,KAAK,GAAG,UAAU,EAAE,GAAG,SAAS,CAAC;IAC1C,GAAG,CAAC,GAAG,EAAE,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,EAAE,EAAE,OAAO,CAAC;IACZ,EAAE,EAAE,OAAO,CAAC;IACZ,EAAE,EAAE,OAAO,CAAC;IACZ,EAAE,EAAE,OAAO,CAAC;IACZ,EAAE,EAAE,OAAO,CAAC;IACZ,EAAE,EAAE,OAAO,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,UAAU,CAAC;IACrB,KAAK,EAAE,sBAAsB,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,YAAY,CAAC,EAAE,UAAU,CAAC;IAC1B,mBAAmB,CAAC,EAAE,UAAU,CAAC;IACjC,cAAc,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,oBAAoB,CAAC,EAAE,UAAU,CAAC;CACnC,CAAC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { AuthenticatorTransportFuture, Base64URLString as Base64URL } from "../types.mjs";
|
|
2
|
+
export type PublicKeyCredentialDescriptorJSON = {
|
|
3
|
+
id: Base64URL;
|
|
4
|
+
type: 'public-key';
|
|
5
|
+
transports?: AuthenticatorTransportFuture[];
|
|
6
|
+
};
|
|
7
|
+
export type PublicKeyCredentialHint = 'hybrid' | 'security-key' | 'client-device';
|
|
8
|
+
export type PasskeyRegistrationOptions = {
|
|
9
|
+
rp: {
|
|
10
|
+
name: string;
|
|
11
|
+
id?: string;
|
|
12
|
+
};
|
|
13
|
+
user: {
|
|
14
|
+
id: Base64URL;
|
|
15
|
+
name: string;
|
|
16
|
+
displayName: string;
|
|
17
|
+
};
|
|
18
|
+
challenge: Base64URL;
|
|
19
|
+
pubKeyCredParams: {
|
|
20
|
+
alg: number;
|
|
21
|
+
type: 'public-key';
|
|
22
|
+
}[];
|
|
23
|
+
timeout?: number;
|
|
24
|
+
excludeCredentials?: PublicKeyCredentialDescriptorJSON[];
|
|
25
|
+
authenticatorSelection?: {
|
|
26
|
+
authenticatorAttachment?: 'cross-platform' | 'platform';
|
|
27
|
+
residentKey?: 'discouraged' | 'preferred' | 'required';
|
|
28
|
+
requireResidentKey?: boolean;
|
|
29
|
+
userVerification?: 'discouraged' | 'preferred' | 'required';
|
|
30
|
+
};
|
|
31
|
+
hints?: PublicKeyCredentialHint[];
|
|
32
|
+
attestation?: 'direct' | 'enterprise' | 'indirect' | 'none';
|
|
33
|
+
extensions?: Record<string, unknown>;
|
|
34
|
+
};
|
|
35
|
+
export type PasskeyRegistrationResponse = {
|
|
36
|
+
id: Base64URL;
|
|
37
|
+
rawId: Base64URL;
|
|
38
|
+
type: 'public-key';
|
|
39
|
+
response: {
|
|
40
|
+
clientDataJSON: Base64URL;
|
|
41
|
+
attestationObject: Base64URL;
|
|
42
|
+
transports?: string[];
|
|
43
|
+
publicKeyAlgorithm?: number;
|
|
44
|
+
publicKey?: Base64URL;
|
|
45
|
+
authenticatorData?: Base64URL;
|
|
46
|
+
};
|
|
47
|
+
authenticatorAttachment?: 'cross-platform' | 'platform';
|
|
48
|
+
clientExtensionResults: Record<string, unknown>;
|
|
49
|
+
};
|
|
50
|
+
export type PasskeyAuthenticationOptions = {
|
|
51
|
+
challenge: Base64URL;
|
|
52
|
+
timeout?: number;
|
|
53
|
+
rpId?: string;
|
|
54
|
+
allowCredentials?: PublicKeyCredentialDescriptorJSON[];
|
|
55
|
+
userVerification?: 'discouraged' | 'preferred' | 'required';
|
|
56
|
+
hints?: PublicKeyCredentialHint[];
|
|
57
|
+
extensions?: Record<string, unknown>;
|
|
58
|
+
};
|
|
59
|
+
export type PasskeyAuthenticationResponse = {
|
|
60
|
+
id: Base64URL;
|
|
61
|
+
rawId: Base64URL;
|
|
62
|
+
type: 'public-key';
|
|
63
|
+
response: {
|
|
64
|
+
clientDataJSON: Base64URL;
|
|
65
|
+
authenticatorData: Base64URL;
|
|
66
|
+
signature: Base64URL;
|
|
67
|
+
userHandle?: Base64URL;
|
|
68
|
+
};
|
|
69
|
+
authenticatorAttachment?: 'cross-platform' | 'platform';
|
|
70
|
+
clientExtensionResults: Record<string, unknown>;
|
|
71
|
+
};
|
|
72
|
+
export type ClientDataJSON = {
|
|
73
|
+
type: string;
|
|
74
|
+
challenge: string;
|
|
75
|
+
origin: string;
|
|
76
|
+
crossOrigin?: boolean;
|
|
77
|
+
tokenBinding?: {
|
|
78
|
+
id?: string;
|
|
79
|
+
status: 'present' | 'supported' | 'not-supported';
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
export type AttestationFormat = 'fido-u2f' | 'packed' | 'android-safetynet' | 'android-key' | 'tpm' | 'apple' | 'none';
|
|
83
|
+
export type AttestationObject = {
|
|
84
|
+
get(key: 'fmt'): AttestationFormat;
|
|
85
|
+
get(key: 'attStmt'): AttestationStatement;
|
|
86
|
+
get(key: 'authData'): Uint8Array;
|
|
87
|
+
};
|
|
88
|
+
export type AttestationStatement = {
|
|
89
|
+
get(key: 'sig'): Uint8Array | undefined;
|
|
90
|
+
get(key: 'x5c'): Uint8Array[] | undefined;
|
|
91
|
+
get(key: 'alg'): number | undefined;
|
|
92
|
+
readonly size: number;
|
|
93
|
+
};
|
|
94
|
+
export type AuthenticatorDataFlags = {
|
|
95
|
+
up: boolean;
|
|
96
|
+
uv: boolean;
|
|
97
|
+
be: boolean;
|
|
98
|
+
bs: boolean;
|
|
99
|
+
at: boolean;
|
|
100
|
+
ed: boolean;
|
|
101
|
+
flagsByte: number;
|
|
102
|
+
};
|
|
103
|
+
export type ParsedAuthenticatorData = {
|
|
104
|
+
rpIdHash: Uint8Array;
|
|
105
|
+
flags: AuthenticatorDataFlags;
|
|
106
|
+
counter: number;
|
|
107
|
+
aaguid?: Uint8Array;
|
|
108
|
+
credentialID?: Uint8Array;
|
|
109
|
+
credentialPublicKey?: Uint8Array;
|
|
110
|
+
extensionsData?: Map<string, unknown>;
|
|
111
|
+
extensionsDataBuffer?: Uint8Array;
|
|
112
|
+
};
|
|
113
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../src/webauthn/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,4BAA4B,EAC5B,eAAe,IAAI,SAAS,EAC7B,qBAAoB;AAErB,MAAM,MAAM,iCAAiC,GAAG;IAC9C,EAAE,EAAE,SAAS,CAAC;IACd,IAAI,EAAE,YAAY,CAAC;IACnB,UAAU,CAAC,EAAE,4BAA4B,EAAE,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAC/B,QAAQ,GACR,cAAc,GACd,eAAe,CAAC;AAEpB,MAAM,MAAM,0BAA0B,GAAG;IACvC,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAClC,IAAI,EAAE;QACJ,EAAE,EAAE,SAAS,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,SAAS,EAAE,SAAS,CAAC;IACrB,gBAAgB,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,YAAY,CAAA;KAAE,EAAE,CAAC;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kBAAkB,CAAC,EAAE,iCAAiC,EAAE,CAAC;IACzD,sBAAsB,CAAC,EAAE;QACvB,uBAAuB,CAAC,EAAE,gBAAgB,GAAG,UAAU,CAAC;QACxD,WAAW,CAAC,EAA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AM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,EAAE,EAAE,OAAO,CAAC;IACZ,EAAE,EAAE,OAAO,CAAC;IACZ,EAAE,EAAE,OAAO,CAAC;IACZ,EAAE,EAAE,OAAO,CAAC;IACZ,EAAE,EAAE,OAAO,CAAC;IACZ,EAAE,EAAE,OAAO,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,UAAU,CAAC;IACrB,KAAK,EAAE,sBAAsB,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,YAAY,CAAC,EAAE,UAAU,CAAC;IAC1B,mBAAmB,CAAC,EAAE,UAAU,CAAC;IACjC,cAAc,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,oBAAoB,CAAC,EAAE,UAAU,CAAC;CACnC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../src/webauthn/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n AuthenticatorTransportFuture,\n Base64URLString as Base64URL,\n} from '../types.js';\n\nexport type PublicKeyCredentialDescriptorJSON = {\n id: Base64URL;\n type: 'public-key';\n transports?: AuthenticatorTransportFuture[];\n};\n\nexport type PublicKeyCredentialHint =\n | 'hybrid'\n | 'security-key'\n | 'client-device';\n\nexport type PasskeyRegistrationOptions = {\n rp: { name: string; id?: string };\n user: {\n id: Base64URL;\n name: string;\n displayName: string;\n };\n challenge: Base64URL;\n pubKeyCredParams: { alg: number; type: 'public-key' }[];\n timeout?: number;\n excludeCredentials?: PublicKeyCredentialDescriptorJSON[];\n authenticatorSelection?: {\n authenticatorAttachment?: 'cross-platform' | 'platform';\n residentKey?: 'discouraged' | 'preferred' | 'required';\n requireResidentKey?: boolean;\n userVerification?: 'discouraged' | 'preferred' | 'required';\n };\n hints?: PublicKeyCredentialHint[];\n attestation?: 'direct' | 'enterprise' | 'indirect' | 'none';\n extensions?: Record<string, unknown>;\n};\n\nexport type PasskeyRegistrationResponse = {\n id: Base64URL;\n rawId: Base64URL;\n type: 'public-key';\n response: {\n clientDataJSON: Base64URL;\n attestationObject: Base64URL;\n transports?: string[];\n publicKeyAlgorithm?: number;\n publicKey?: Base64URL;\n authenticatorData?: Base64URL;\n };\n authenticatorAttachment?: 'cross-platform' | 'platform';\n clientExtensionResults: Record<string, unknown>;\n};\n\nexport type PasskeyAuthenticationOptions = {\n challenge: Base64URL;\n timeout?: number;\n rpId?: string;\n allowCredentials?: PublicKeyCredentialDescriptorJSON[];\n userVerification?: 'discouraged' | 'preferred' | 'required';\n hints?: PublicKeyCredentialHint[];\n extensions?: Record<string, unknown>;\n};\n\nexport type PasskeyAuthenticationResponse = {\n id: Base64URL;\n rawId: Base64URL;\n type: 'public-key';\n response: {\n clientDataJSON: Base64URL;\n authenticatorData: Base64URL;\n signature: Base64URL;\n userHandle?: Base64URL;\n };\n authenticatorAttachment?: 'cross-platform' | 'platform';\n clientExtensionResults: Record<string, unknown>;\n};\n\nexport type ClientDataJSON = {\n type: string;\n challenge: string;\n origin: string;\n crossOrigin?: boolean;\n tokenBinding?: {\n id?: string;\n status: 'present' | 'supported' | 'not-supported';\n };\n};\n\nexport type AttestationFormat =\n | 'fido-u2f'\n | 'packed'\n | 'android-safetynet'\n | 'android-key'\n | 'tpm'\n | 'apple'\n | 'none';\n\nexport type AttestationObject = {\n get(key: 'fmt'): AttestationFormat;\n get(key: 'attStmt'): AttestationStatement;\n get(key: 'authData'): Uint8Array;\n};\n\nexport type AttestationStatement = {\n get(key: 'sig'): Uint8Array | undefined;\n get(key: 'x5c'): Uint8Array[] | undefined;\n get(key: 'alg'): number | undefined;\n readonly size: number;\n};\n\nexport type AuthenticatorDataFlags = {\n up: boolean;\n uv: boolean;\n be: boolean;\n bs: boolean;\n at: boolean;\n ed: boolean;\n flagsByte: number;\n};\n\nexport type ParsedAuthenticatorData = {\n rpIdHash: Uint8Array;\n flags: AuthenticatorDataFlags;\n counter: number;\n aaguid?: Uint8Array;\n credentialID?: Uint8Array;\n credentialPublicKey?: Uint8Array;\n extensionsData?: Map<string, unknown>;\n extensionsDataBuffer?: Uint8Array;\n};\n"]}
|