@metamask-previews/passkey-controller 3.1.0-preview-4f4c98e → 3.1.0-preview-eb263b0ee

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.
Files changed (207) hide show
  1. package/CHANGELOG.md +0 -1
  2. package/dist/PasskeyController-method-action-types.cjs +7 -0
  3. package/dist/PasskeyController-method-action-types.cjs.map +1 -0
  4. package/dist/{PasskeyController-method-action-types.d.ts → PasskeyController-method-action-types.d.cts} +2 -2
  5. package/dist/PasskeyController-method-action-types.d.cts.map +1 -0
  6. package/dist/PasskeyController-method-action-types.d.mts +204 -0
  7. package/dist/PasskeyController-method-action-types.d.mts.map +1 -0
  8. package/dist/{PasskeyController-method-action-types.js → PasskeyController-method-action-types.mjs} +1 -1
  9. package/dist/PasskeyController-method-action-types.mjs.map +1 -0
  10. package/dist/PasskeyController.cjs +685 -0
  11. package/dist/PasskeyController.cjs.map +1 -0
  12. package/dist/{PasskeyController.d.ts → PasskeyController.d.cts} +6 -6
  13. package/dist/PasskeyController.d.cts.map +1 -0
  14. package/dist/PasskeyController.d.mts +208 -0
  15. package/dist/PasskeyController.d.mts.map +1 -0
  16. package/dist/{PasskeyController.js → PasskeyController.mjs} +15 -15
  17. package/dist/PasskeyController.mjs.map +1 -0
  18. package/dist/ceremony-manager.cjs +135 -0
  19. package/dist/ceremony-manager.cjs.map +1 -0
  20. package/dist/{ceremony-manager.d.ts → ceremony-manager.d.cts} +2 -2
  21. package/dist/ceremony-manager.d.cts.map +1 -0
  22. package/dist/ceremony-manager.d.mts +72 -0
  23. package/dist/ceremony-manager.d.mts.map +1 -0
  24. package/dist/{ceremony-manager.js → ceremony-manager.mjs} +1 -1
  25. package/dist/ceremony-manager.mjs.map +1 -0
  26. package/dist/constants.cjs +39 -0
  27. package/dist/constants.cjs.map +1 -0
  28. package/dist/{constants.d.ts → constants.d.cts} +12 -12
  29. package/dist/constants.d.cts.map +1 -0
  30. package/dist/constants.d.mts +36 -0
  31. package/dist/constants.d.mts.map +1 -0
  32. package/dist/{constants.js → constants.mjs} +1 -1
  33. package/dist/constants.mjs.map +1 -0
  34. package/dist/errors.cjs +57 -0
  35. package/dist/errors.cjs.map +1 -0
  36. package/dist/{errors.d.ts → errors.d.cts} +2 -2
  37. package/dist/errors.d.cts.map +1 -0
  38. package/dist/errors.d.mts +34 -0
  39. package/dist/errors.d.mts.map +1 -0
  40. package/dist/{errors.js → errors.mjs} +1 -1
  41. package/dist/errors.mjs.map +1 -0
  42. package/dist/index.cjs +15 -0
  43. package/dist/index.cjs.map +1 -0
  44. package/dist/{index.d.ts → index.d.cts} +8 -8
  45. package/dist/index.d.cts.map +1 -0
  46. package/dist/index.d.mts +8 -0
  47. package/dist/index.d.mts.map +1 -0
  48. package/dist/index.mjs +5 -0
  49. package/dist/index.mjs.map +1 -0
  50. package/dist/key-derivation.cjs +44 -0
  51. package/dist/key-derivation.cjs.map +1 -0
  52. package/dist/{key-derivation.d.ts → key-derivation.d.cts} +3 -3
  53. package/dist/key-derivation.d.cts.map +1 -0
  54. package/dist/key-derivation.d.mts +20 -0
  55. package/dist/key-derivation.d.mts.map +1 -0
  56. package/dist/{key-derivation.js → key-derivation.mjs} +5 -5
  57. package/dist/key-derivation.mjs.map +1 -0
  58. package/dist/logger.cjs +9 -0
  59. package/dist/logger.cjs.map +1 -0
  60. package/dist/logger.d.cts +5 -0
  61. package/dist/logger.d.cts.map +1 -0
  62. package/dist/logger.d.mts +5 -0
  63. package/dist/logger.d.mts.map +1 -0
  64. package/dist/logger.mjs +6 -0
  65. package/dist/logger.mjs.map +1 -0
  66. package/dist/types.cjs +4 -0
  67. package/dist/types.cjs.map +1 -0
  68. package/dist/{types.d.ts → types.d.cts} +6 -6
  69. package/dist/types.d.cts.map +1 -0
  70. package/dist/types.d.mts +132 -0
  71. package/dist/types.d.mts.map +1 -0
  72. package/dist/types.mjs +2 -0
  73. package/dist/types.mjs.map +1 -0
  74. package/dist/utils/crypto.cjs +66 -0
  75. package/dist/utils/crypto.cjs.map +1 -0
  76. package/dist/utils/{crypto.d.ts → crypto.d.cts} +1 -1
  77. package/dist/utils/crypto.d.cts.map +1 -0
  78. package/dist/utils/crypto.d.mts +37 -0
  79. package/dist/utils/crypto.d.mts.map +1 -0
  80. package/dist/utils/{crypto.js → crypto.mjs} +7 -7
  81. package/dist/utils/crypto.mjs.map +1 -0
  82. package/dist/utils/encoding.cjs +42 -0
  83. package/dist/utils/encoding.cjs.map +1 -0
  84. package/dist/utils/{encoding.d.ts → encoding.d.cts} +1 -1
  85. package/dist/utils/encoding.d.cts.map +1 -0
  86. package/dist/utils/encoding.d.mts +22 -0
  87. package/dist/utils/encoding.d.mts.map +1 -0
  88. package/dist/utils/{encoding.js → encoding.mjs} +2 -2
  89. package/dist/utils/encoding.mjs.map +1 -0
  90. package/dist/webauthn/constants.cjs +74 -0
  91. package/dist/webauthn/constants.cjs.map +1 -0
  92. package/dist/webauthn/{constants.d.ts → constants.d.cts} +1 -1
  93. package/dist/webauthn/constants.d.cts.map +1 -0
  94. package/dist/webauthn/constants.d.mts +68 -0
  95. package/dist/webauthn/constants.d.mts.map +1 -0
  96. package/dist/webauthn/{constants.js → constants.mjs} +1 -1
  97. package/dist/webauthn/constants.mjs.map +1 -0
  98. package/dist/webauthn/decode-attestation-object.cjs +18 -0
  99. package/dist/webauthn/decode-attestation-object.cjs.map +1 -0
  100. package/dist/webauthn/{decode-attestation-object.d.ts → decode-attestation-object.d.cts} +2 -2
  101. package/dist/webauthn/decode-attestation-object.d.cts.map +1 -0
  102. package/dist/webauthn/decode-attestation-object.d.mts +10 -0
  103. package/dist/webauthn/decode-attestation-object.d.mts.map +1 -0
  104. package/dist/webauthn/{decode-attestation-object.js → decode-attestation-object.mjs} +2 -2
  105. package/dist/webauthn/decode-attestation-object.mjs.map +1 -0
  106. package/dist/webauthn/decode-client-data-json.cjs +17 -0
  107. package/dist/webauthn/decode-client-data-json.cjs.map +1 -0
  108. package/dist/webauthn/{decode-client-data-json.d.ts → decode-client-data-json.d.cts} +2 -2
  109. package/dist/webauthn/decode-client-data-json.d.cts.map +1 -0
  110. package/dist/webauthn/decode-client-data-json.d.mts +9 -0
  111. package/dist/webauthn/decode-client-data-json.d.mts.map +1 -0
  112. package/dist/webauthn/{decode-client-data-json.js → decode-client-data-json.mjs} +2 -2
  113. package/dist/webauthn/decode-client-data-json.mjs.map +1 -0
  114. package/dist/webauthn/match-expected-rp-id.cjs +26 -0
  115. package/dist/webauthn/match-expected-rp-id.cjs.map +1 -0
  116. package/dist/webauthn/{match-expected-rp-id.d.ts → match-expected-rp-id.d.cts} +1 -1
  117. package/dist/webauthn/match-expected-rp-id.d.cts.map +1 -0
  118. package/dist/webauthn/match-expected-rp-id.d.mts +11 -0
  119. package/dist/webauthn/match-expected-rp-id.d.mts.map +1 -0
  120. package/dist/webauthn/{match-expected-rp-id.js → match-expected-rp-id.mjs} +4 -4
  121. package/dist/webauthn/match-expected-rp-id.mjs.map +1 -0
  122. package/dist/webauthn/parse-authenticator-data.cjs +69 -0
  123. package/dist/webauthn/parse-authenticator-data.cjs.map +1 -0
  124. package/dist/webauthn/{parse-authenticator-data.d.ts → parse-authenticator-data.d.cts} +2 -2
  125. package/dist/webauthn/parse-authenticator-data.d.cts.map +1 -0
  126. package/dist/webauthn/parse-authenticator-data.d.mts +10 -0
  127. package/dist/webauthn/parse-authenticator-data.d.mts.map +1 -0
  128. package/dist/webauthn/{parse-authenticator-data.js → parse-authenticator-data.mjs} +2 -2
  129. package/dist/webauthn/parse-authenticator-data.mjs.map +1 -0
  130. package/dist/webauthn/types.cjs +3 -0
  131. package/dist/webauthn/types.cjs.map +1 -0
  132. package/dist/webauthn/{types.d.ts → types.d.cts} +2 -2
  133. package/dist/webauthn/types.d.cts.map +1 -0
  134. package/dist/webauthn/types.d.mts +113 -0
  135. package/dist/webauthn/types.d.mts.map +1 -0
  136. package/dist/webauthn/types.mjs +2 -0
  137. package/dist/webauthn/types.mjs.map +1 -0
  138. package/dist/webauthn/verify-authentication-response.cjs +133 -0
  139. package/dist/webauthn/verify-authentication-response.cjs.map +1 -0
  140. package/dist/webauthn/{verify-authentication-response.d.ts → verify-authentication-response.d.cts} +3 -3
  141. package/dist/webauthn/verify-authentication-response.d.cts.map +1 -0
  142. package/dist/webauthn/verify-authentication-response.d.mts +64 -0
  143. package/dist/webauthn/verify-authentication-response.d.mts.map +1 -0
  144. package/dist/webauthn/{verify-authentication-response.js → verify-authentication-response.mjs} +9 -9
  145. package/dist/webauthn/verify-authentication-response.mjs.map +1 -0
  146. package/dist/webauthn/verify-registration-response.cjs +242 -0
  147. package/dist/webauthn/verify-registration-response.cjs.map +1 -0
  148. package/dist/webauthn/{verify-registration-response.d.ts → verify-registration-response.d.cts} +3 -3
  149. package/dist/webauthn/verify-registration-response.d.cts.map +1 -0
  150. package/dist/webauthn/verify-registration-response.d.mts +81 -0
  151. package/dist/webauthn/verify-registration-response.d.mts.map +1 -0
  152. package/dist/webauthn/{verify-registration-response.js → verify-registration-response.mjs} +11 -11
  153. package/dist/webauthn/verify-registration-response.mjs.map +1 -0
  154. package/dist/webauthn/verify-signature.cjs +176 -0
  155. package/dist/webauthn/verify-signature.cjs.map +1 -0
  156. package/dist/webauthn/{verify-signature.d.ts → verify-signature.d.cts} +1 -1
  157. package/dist/webauthn/verify-signature.d.cts.map +1 -0
  158. package/dist/webauthn/verify-signature.d.mts +21 -0
  159. package/dist/webauthn/verify-signature.d.mts.map +1 -0
  160. package/dist/webauthn/{verify-signature.js → verify-signature.mjs} +7 -7
  161. package/dist/webauthn/verify-signature.mjs.map +1 -0
  162. package/package.json +17 -12
  163. package/dist/PasskeyController-method-action-types.d.ts.map +0 -1
  164. package/dist/PasskeyController-method-action-types.js.map +0 -1
  165. package/dist/PasskeyController.d.ts.map +0 -1
  166. package/dist/PasskeyController.js.map +0 -1
  167. package/dist/ceremony-manager.d.ts.map +0 -1
  168. package/dist/ceremony-manager.js.map +0 -1
  169. package/dist/constants.d.ts.map +0 -1
  170. package/dist/constants.js.map +0 -1
  171. package/dist/errors.d.ts.map +0 -1
  172. package/dist/errors.js.map +0 -1
  173. package/dist/index.d.ts.map +0 -1
  174. package/dist/index.js +0 -5
  175. package/dist/index.js.map +0 -1
  176. package/dist/key-derivation.d.ts.map +0 -1
  177. package/dist/key-derivation.js.map +0 -1
  178. package/dist/logger.d.ts +0 -4
  179. package/dist/logger.d.ts.map +0 -1
  180. package/dist/logger.js +0 -6
  181. package/dist/logger.js.map +0 -1
  182. package/dist/types.d.ts.map +0 -1
  183. package/dist/types.js +0 -2
  184. package/dist/types.js.map +0 -1
  185. package/dist/utils/crypto.d.ts.map +0 -1
  186. package/dist/utils/crypto.js.map +0 -1
  187. package/dist/utils/encoding.d.ts.map +0 -1
  188. package/dist/utils/encoding.js.map +0 -1
  189. package/dist/webauthn/constants.d.ts.map +0 -1
  190. package/dist/webauthn/constants.js.map +0 -1
  191. package/dist/webauthn/decode-attestation-object.d.ts.map +0 -1
  192. package/dist/webauthn/decode-attestation-object.js.map +0 -1
  193. package/dist/webauthn/decode-client-data-json.d.ts.map +0 -1
  194. package/dist/webauthn/decode-client-data-json.js.map +0 -1
  195. package/dist/webauthn/match-expected-rp-id.d.ts.map +0 -1
  196. package/dist/webauthn/match-expected-rp-id.js.map +0 -1
  197. package/dist/webauthn/parse-authenticator-data.d.ts.map +0 -1
  198. package/dist/webauthn/parse-authenticator-data.js.map +0 -1
  199. package/dist/webauthn/types.d.ts.map +0 -1
  200. package/dist/webauthn/types.js +0 -2
  201. package/dist/webauthn/types.js.map +0 -1
  202. package/dist/webauthn/verify-authentication-response.d.ts.map +0 -1
  203. package/dist/webauthn/verify-authentication-response.js.map +0 -1
  204. package/dist/webauthn/verify-registration-response.d.ts.map +0 -1
  205. package/dist/webauthn/verify-registration-response.js.map +0 -1
  206. package/dist/webauthn/verify-signature.d.ts.map +0 -1
  207. package/dist/webauthn/verify-signature.js.map +0 -1
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.bytesToHex = exports.base64URLToBytes = exports.bytesToBase64URL = void 0;
4
+ const utils_1 = require("@metamask/utils");
5
+ /**
6
+ * Encode a byte array as a base64url string (RFC 4648 §5).
7
+ *
8
+ * @param bytes - The bytes to encode.
9
+ * @returns Base64url-encoded string without padding.
10
+ */
11
+ function bytesToBase64URL(bytes) {
12
+ return (0, utils_1.bytesToBase64)(bytes)
13
+ .replace(/\+/gu, '-')
14
+ .replace(/\//gu, '_')
15
+ .replace(/[=]+$/u, '');
16
+ }
17
+ exports.bytesToBase64URL = bytesToBase64URL;
18
+ /**
19
+ * Decode a base64url string (RFC 4648 §5) into bytes.
20
+ *
21
+ * @param value - Base64url-encoded string.
22
+ * @returns Decoded bytes.
23
+ */
24
+ function base64URLToBytes(value) {
25
+ const standard = value.replace(/-/gu, '+').replace(/_/gu, '/');
26
+ const padLength = (4 - (standard.length % 4)) % 4;
27
+ return Uint8Array.from((0, utils_1.base64ToBytes)(standard + '='.repeat(padLength)));
28
+ }
29
+ exports.base64URLToBytes = base64URLToBytes;
30
+ /**
31
+ * Encode a byte array as a hexadecimal string.
32
+ *
33
+ * @param bytes - The bytes to encode.
34
+ * @returns Hex-encoded string.
35
+ */
36
+ function bytesToHex(bytes) {
37
+ return Array.from(bytes)
38
+ .map((byte) => byte.toString(16).padStart(2, '0'))
39
+ .join('');
40
+ }
41
+ exports.bytesToHex = bytesToHex;
42
+ //# sourceMappingURL=encoding.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encoding.cjs","sourceRoot":"","sources":["../../src/utils/encoding.ts"],"names":[],"mappings":";;;AAAA,2CAA+D;AAE/D;;;;;GAKG;AACH,SAAgB,gBAAgB,CAAC,KAAiB;IAChD,OAAO,IAAA,qBAAa,EAAC,KAAK,CAAC;SACxB,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AAC3B,CAAC;AALD,4CAKC;AAED;;;;;GAKG;AACH,SAAgB,gBAAgB,CAAC,KAAa;IAC5C,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAC/D,MAAM,SAAS,GAAG,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAClD,OAAO,UAAU,CAAC,IAAI,CAAC,IAAA,qBAAa,EAAC,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AAC1E,CAAC;AAJD,4CAIC;AAED;;;;;GAKG;AACH,SAAgB,UAAU,CAAC,KAAiB;IAC1C,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;SACrB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;SACjD,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC;AAJD,gCAIC","sourcesContent":["import { bytesToBase64, base64ToBytes } from '@metamask/utils';\n\n/**\n * Encode a byte array as a base64url string (RFC 4648 §5).\n *\n * @param bytes - The bytes to encode.\n * @returns Base64url-encoded string without padding.\n */\nexport function bytesToBase64URL(bytes: Uint8Array): string {\n return bytesToBase64(bytes)\n .replace(/\\+/gu, '-')\n .replace(/\\//gu, '_')\n .replace(/[=]+$/u, '');\n}\n\n/**\n * Decode a base64url string (RFC 4648 §5) into bytes.\n *\n * @param value - Base64url-encoded string.\n * @returns Decoded bytes.\n */\nexport function base64URLToBytes(value: string): Uint8Array {\n const standard = value.replace(/-/gu, '+').replace(/_/gu, '/');\n const padLength = (4 - (standard.length % 4)) % 4;\n return Uint8Array.from(base64ToBytes(standard + '='.repeat(padLength)));\n}\n\n/**\n * Encode a byte array as a hexadecimal string.\n *\n * @param bytes - The bytes to encode.\n * @returns Hex-encoded string.\n */\nexport function bytesToHex(bytes: Uint8Array): string {\n return Array.from(bytes)\n .map((byte) => byte.toString(16).padStart(2, '0'))\n .join('');\n}\n"]}
@@ -19,4 +19,4 @@ export declare function base64URLToBytes(value: string): Uint8Array;
19
19
  * @returns Hex-encoded string.
20
20
  */
21
21
  export declare function bytesToHex(bytes: Uint8Array): string;
22
- //# sourceMappingURL=encoding.d.ts.map
22
+ //# sourceMappingURL=encoding.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encoding.d.cts","sourceRoot":"","sources":["../../src/utils/encoding.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAK1D;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAI1D;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAIpD"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Encode a byte array as a base64url string (RFC 4648 §5).
3
+ *
4
+ * @param bytes - The bytes to encode.
5
+ * @returns Base64url-encoded string without padding.
6
+ */
7
+ export declare function bytesToBase64URL(bytes: Uint8Array): string;
8
+ /**
9
+ * Decode a base64url string (RFC 4648 §5) into bytes.
10
+ *
11
+ * @param value - Base64url-encoded string.
12
+ * @returns Decoded bytes.
13
+ */
14
+ export declare function base64URLToBytes(value: string): Uint8Array;
15
+ /**
16
+ * Encode a byte array as a hexadecimal string.
17
+ *
18
+ * @param bytes - The bytes to encode.
19
+ * @returns Hex-encoded string.
20
+ */
21
+ export declare function bytesToHex(bytes: Uint8Array): string;
22
+ //# sourceMappingURL=encoding.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encoding.d.mts","sourceRoot":"","sources":["../../src/utils/encoding.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAK1D;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAI1D;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAIpD"}
@@ -1,4 +1,4 @@
1
- import { bytesToBase64, base64ToBytes } from '@metamask/utils';
1
+ import { bytesToBase64, base64ToBytes } from "@metamask/utils";
2
2
  /**
3
3
  * Encode a byte array as a base64url string (RFC 4648 §5).
4
4
  *
@@ -33,4 +33,4 @@ export function bytesToHex(bytes) {
33
33
  .map((byte) => byte.toString(16).padStart(2, '0'))
34
34
  .join('');
35
35
  }
36
- //# sourceMappingURL=encoding.js.map
36
+ //# sourceMappingURL=encoding.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encoding.mjs","sourceRoot":"","sources":["../../src/utils/encoding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,wBAAwB;AAE/D;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAiB;IAChD,OAAO,aAAa,CAAC,KAAK,CAAC;SACxB,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AAC3B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAC/D,MAAM,SAAS,GAAG,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAClD,OAAO,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AAC1E,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,KAAiB;IAC1C,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;SACrB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;SACjD,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC","sourcesContent":["import { bytesToBase64, base64ToBytes } from '@metamask/utils';\n\n/**\n * Encode a byte array as a base64url string (RFC 4648 §5).\n *\n * @param bytes - The bytes to encode.\n * @returns Base64url-encoded string without padding.\n */\nexport function bytesToBase64URL(bytes: Uint8Array): string {\n return bytesToBase64(bytes)\n .replace(/\\+/gu, '-')\n .replace(/\\//gu, '_')\n .replace(/[=]+$/u, '');\n}\n\n/**\n * Decode a base64url string (RFC 4648 §5) into bytes.\n *\n * @param value - Base64url-encoded string.\n * @returns Decoded bytes.\n */\nexport function base64URLToBytes(value: string): Uint8Array {\n const standard = value.replace(/-/gu, '+').replace(/_/gu, '/');\n const padLength = (4 - (standard.length % 4)) % 4;\n return Uint8Array.from(base64ToBytes(standard + '='.repeat(padLength)));\n}\n\n/**\n * Encode a byte array as a hexadecimal string.\n *\n * @param bytes - The bytes to encode.\n * @returns Hex-encoded string.\n */\nexport function bytesToHex(bytes: Uint8Array): string {\n return Array.from(bytes)\n .map((byte) => byte.toString(16).padStart(2, '0'))\n .join('');\n}\n"]}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.COSEKEYS = exports.COSECRV = exports.COSEKTY = exports.COSEALG = void 0;
4
+ /**
5
+ * COSE Algorithms
6
+ *
7
+ * @see https://www.iana.org/assignments/cose/cose.xhtml#algorithms
8
+ */
9
+ var COSEALG;
10
+ (function (COSEALG) {
11
+ COSEALG[COSEALG["ES256"] = -7] = "ES256";
12
+ COSEALG[COSEALG["EdDSA"] = -8] = "EdDSA";
13
+ COSEALG[COSEALG["ES384"] = -35] = "ES384";
14
+ COSEALG[COSEALG["ES512"] = -36] = "ES512";
15
+ COSEALG[COSEALG["PS256"] = -37] = "PS256";
16
+ COSEALG[COSEALG["PS384"] = -38] = "PS384";
17
+ COSEALG[COSEALG["PS512"] = -39] = "PS512";
18
+ COSEALG[COSEALG["ES256K"] = -47] = "ES256K";
19
+ COSEALG[COSEALG["RS256"] = -257] = "RS256";
20
+ COSEALG[COSEALG["RS384"] = -258] = "RS384";
21
+ COSEALG[COSEALG["RS512"] = -259] = "RS512";
22
+ COSEALG[COSEALG["RS1"] = -65535] = "RS1";
23
+ })(COSEALG || (exports.COSEALG = COSEALG = {}));
24
+ /**
25
+ * COSE Key Types
26
+ *
27
+ * @see https://www.iana.org/assignments/cose/cose.xhtml#key-type
28
+ */
29
+ var COSEKTY;
30
+ (function (COSEKTY) {
31
+ COSEKTY[COSEKTY["OKP"] = 1] = "OKP";
32
+ COSEKTY[COSEKTY["EC2"] = 2] = "EC2";
33
+ COSEKTY[COSEKTY["RSA"] = 3] = "RSA";
34
+ })(COSEKTY || (exports.COSEKTY = COSEKTY = {}));
35
+ /**
36
+ * COSE Curves
37
+ *
38
+ * @see https://www.iana.org/assignments/cose/cose.xhtml#elliptic-curves
39
+ */
40
+ var COSECRV;
41
+ (function (COSECRV) {
42
+ COSECRV[COSECRV["P256"] = 1] = "P256";
43
+ COSECRV[COSECRV["P384"] = 2] = "P384";
44
+ COSECRV[COSECRV["P521"] = 3] = "P521";
45
+ COSECRV[COSECRV["ED25519"] = 6] = "ED25519";
46
+ COSECRV[COSECRV["SECP256K1"] = 8] = "SECP256K1";
47
+ })(COSECRV || (exports.COSECRV = COSECRV = {}));
48
+ /**
49
+ * COSE Key common and type-specific parameter labels.
50
+ *
51
+ * EC2 and RSA re-use the same numeric labels (-1, -2, -3) with different
52
+ * semantics, so this is a plain object instead of an enum to avoid
53
+ * duplicate-value violations.
54
+ *
55
+ * @see https://www.iana.org/assignments/cose/cose.xhtml#key-common-parameters
56
+ * @see https://www.iana.org/assignments/cose/cose.xhtml#key-type-parameters
57
+ */
58
+ exports.COSEKEYS = {
59
+ /** Key Type (common) */
60
+ Kty: 1,
61
+ /** Algorithm (common) */
62
+ Alg: 3,
63
+ /** EC2 / OKP: curve identifier */
64
+ Crv: -1,
65
+ /** EC2: x-coordinate / OKP: public key */
66
+ X: -2,
67
+ /** EC2: y-coordinate */
68
+ Y: -3,
69
+ /** RSA: modulus n (shares numeric label with Crv) */
70
+ N: -1,
71
+ /** RSA: exponent e (shares numeric label with X) */
72
+ E: -2,
73
+ };
74
+ //# sourceMappingURL=constants.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.cjs","sourceRoot":"","sources":["../../src/webauthn/constants.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,IAAY,OAaX;AAbD,WAAY,OAAO;IACjB,wCAAU,CAAA;IACV,wCAAU,CAAA;IACV,yCAAW,CAAA;IACX,yCAAW,CAAA;IACX,yCAAW,CAAA;IACX,yCAAW,CAAA;IACX,yCAAW,CAAA;IACX,2CAAY,CAAA;IACZ,0CAAY,CAAA;IACZ,0CAAY,CAAA;IACZ,0CAAY,CAAA;IACZ,wCAAY,CAAA;AACd,CAAC,EAbW,OAAO,uBAAP,OAAO,QAalB;AAED;;;;GAIG;AACH,IAAY,OAIX;AAJD,WAAY,OAAO;IACjB,mCAAO,CAAA;IACP,mCAAO,CAAA;IACP,mCAAO,CAAA;AACT,CAAC,EAJW,OAAO,uBAAP,OAAO,QAIlB;AAED;;;;GAIG;AACH,IAAY,OAMX;AAND,WAAY,OAAO;IACjB,qCAAQ,CAAA;IACR,qCAAQ,CAAA;IACR,qCAAQ,CAAA;IACR,2CAAW,CAAA;IACX,+CAAa,CAAA;AACf,CAAC,EANW,OAAO,uBAAP,OAAO,QAMlB;AAED;;;;;;;;;GASG;AACU,QAAA,QAAQ,GAAG;IACtB,wBAAwB;IACxB,GAAG,EAAE,CAAC;IACN,yBAAyB;IACzB,GAAG,EAAE,CAAC;IAEN,kCAAkC;IAClC,GAAG,EAAE,CAAC,CAAC;IACP,0CAA0C;IAC1C,CAAC,EAAE,CAAC,CAAC;IACL,wBAAwB;IACxB,CAAC,EAAE,CAAC,CAAC;IAEL,qDAAqD;IACrD,CAAC,EAAE,CAAC,CAAC;IACL,oDAAoD;IACpD,CAAC,EAAE,CAAC,CAAC;CACG,CAAC","sourcesContent":["/**\n * COSE Algorithms\n *\n * @see https://www.iana.org/assignments/cose/cose.xhtml#algorithms\n */\nexport enum COSEALG {\n ES256 = -7,\n EdDSA = -8,\n ES384 = -35,\n ES512 = -36,\n PS256 = -37,\n PS384 = -38,\n PS512 = -39,\n ES256K = -47,\n RS256 = -257,\n RS384 = -258,\n RS512 = -259,\n RS1 = -65535,\n}\n\n/**\n * COSE Key Types\n *\n * @see https://www.iana.org/assignments/cose/cose.xhtml#key-type\n */\nexport enum COSEKTY {\n OKP = 1,\n EC2 = 2,\n RSA = 3,\n}\n\n/**\n * COSE Curves\n *\n * @see https://www.iana.org/assignments/cose/cose.xhtml#elliptic-curves\n */\nexport enum COSECRV {\n P256 = 1,\n P384 = 2,\n P521 = 3,\n ED25519 = 6,\n SECP256K1 = 8,\n}\n\n/**\n * COSE Key common and type-specific parameter labels.\n *\n * EC2 and RSA re-use the same numeric labels (-1, -2, -3) with different\n * semantics, so this is a plain object instead of an enum to avoid\n * duplicate-value violations.\n *\n * @see https://www.iana.org/assignments/cose/cose.xhtml#key-common-parameters\n * @see https://www.iana.org/assignments/cose/cose.xhtml#key-type-parameters\n */\nexport const COSEKEYS = {\n /** Key Type (common) */\n Kty: 1,\n /** Algorithm (common) */\n Alg: 3,\n\n /** EC2 / OKP: curve identifier */\n Crv: -1,\n /** EC2: x-coordinate / OKP: public key */\n X: -2,\n /** EC2: y-coordinate */\n Y: -3,\n\n /** RSA: modulus n (shares numeric label with Crv) */\n N: -1,\n /** RSA: exponent e (shares numeric label with X) */\n E: -2,\n} as const;\n"]}
@@ -65,4 +65,4 @@ export declare const COSEKEYS: {
65
65
  /** RSA: exponent e (shares numeric label with X) */
66
66
  readonly E: -2;
67
67
  };
68
- //# sourceMappingURL=constants.d.ts.map
68
+ //# sourceMappingURL=constants.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.cts","sourceRoot":"","sources":["../../src/webauthn/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,oBAAY,OAAO;IACjB,KAAK,KAAK;IACV,KAAK,KAAK;IACV,KAAK,MAAM;IACX,KAAK,MAAM;IACX,KAAK,MAAM;IACX,KAAK,MAAM;IACX,KAAK,MAAM;IACX,MAAM,MAAM;IACZ,KAAK,OAAO;IACZ,KAAK,OAAO;IACZ,KAAK,OAAO;IACZ,GAAG,SAAS;CACb;AAED;;;;GAIG;AACH,oBAAY,OAAO;IACjB,GAAG,IAAI;IACP,GAAG,IAAI;IACP,GAAG,IAAI;CACR;AAED;;;;GAIG;AACH,oBAAY,OAAO;IACjB,IAAI,IAAI;IACR,IAAI,IAAI;IACR,IAAI,IAAI;IACR,OAAO,IAAI;IACX,SAAS,IAAI;CACd;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,QAAQ;IACnB,wBAAwB;;IAExB,yBAAyB;;IAGzB,kCAAkC;;IAElC,0CAA0C;;IAE1C,wBAAwB;;IAGxB,qDAAqD;;IAErD,oDAAoD;;CAE5C,CAAC"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * COSE Algorithms
3
+ *
4
+ * @see https://www.iana.org/assignments/cose/cose.xhtml#algorithms
5
+ */
6
+ export declare enum COSEALG {
7
+ ES256 = -7,
8
+ EdDSA = -8,
9
+ ES384 = -35,
10
+ ES512 = -36,
11
+ PS256 = -37,
12
+ PS384 = -38,
13
+ PS512 = -39,
14
+ ES256K = -47,
15
+ RS256 = -257,
16
+ RS384 = -258,
17
+ RS512 = -259,
18
+ RS1 = -65535
19
+ }
20
+ /**
21
+ * COSE Key Types
22
+ *
23
+ * @see https://www.iana.org/assignments/cose/cose.xhtml#key-type
24
+ */
25
+ export declare enum COSEKTY {
26
+ OKP = 1,
27
+ EC2 = 2,
28
+ RSA = 3
29
+ }
30
+ /**
31
+ * COSE Curves
32
+ *
33
+ * @see https://www.iana.org/assignments/cose/cose.xhtml#elliptic-curves
34
+ */
35
+ export declare enum COSECRV {
36
+ P256 = 1,
37
+ P384 = 2,
38
+ P521 = 3,
39
+ ED25519 = 6,
40
+ SECP256K1 = 8
41
+ }
42
+ /**
43
+ * COSE Key common and type-specific parameter labels.
44
+ *
45
+ * EC2 and RSA re-use the same numeric labels (-1, -2, -3) with different
46
+ * semantics, so this is a plain object instead of an enum to avoid
47
+ * duplicate-value violations.
48
+ *
49
+ * @see https://www.iana.org/assignments/cose/cose.xhtml#key-common-parameters
50
+ * @see https://www.iana.org/assignments/cose/cose.xhtml#key-type-parameters
51
+ */
52
+ export declare const COSEKEYS: {
53
+ /** Key Type (common) */
54
+ readonly Kty: 1;
55
+ /** Algorithm (common) */
56
+ readonly Alg: 3;
57
+ /** EC2 / OKP: curve identifier */
58
+ readonly Crv: -1;
59
+ /** EC2: x-coordinate / OKP: public key */
60
+ readonly X: -2;
61
+ /** EC2: y-coordinate */
62
+ readonly Y: -3;
63
+ /** RSA: modulus n (shares numeric label with Crv) */
64
+ readonly N: -1;
65
+ /** RSA: exponent e (shares numeric label with X) */
66
+ readonly E: -2;
67
+ };
68
+ //# sourceMappingURL=constants.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../../src/webauthn/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,oBAAY,OAAO;IACjB,KAAK,KAAK;IACV,KAAK,KAAK;IACV,KAAK,MAAM;IACX,KAAK,MAAM;IACX,KAAK,MAAM;IACX,KAAK,MAAM;IACX,KAAK,MAAM;IACX,MAAM,MAAM;IACZ,KAAK,OAAO;IACZ,KAAK,OAAO;IACZ,KAAK,OAAO;IACZ,GAAG,SAAS;CACb;AAED;;;;GAIG;AACH,oBAAY,OAAO;IACjB,GAAG,IAAI;IACP,GAAG,IAAI;IACP,GAAG,IAAI;CACR;AAED;;;;GAIG;AACH,oBAAY,OAAO;IACjB,IAAI,IAAI;IACR,IAAI,IAAI;IACR,IAAI,IAAI;IACR,OAAO,IAAI;IACX,SAAS,IAAI;CACd;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,QAAQ;IACnB,wBAAwB;;IAExB,yBAAyB;;IAGzB,kCAAkC;;IAElC,0CAA0C;;IAE1C,wBAAwB;;IAGxB,qDAAqD;;IAErD,oDAAoD;;CAE5C,CAAC"}
@@ -68,4 +68,4 @@ export const COSEKEYS = {
68
68
  /** RSA: exponent e (shares numeric label with X) */
69
69
  E: -2,
70
70
  };
71
- //# sourceMappingURL=constants.js.map
71
+ //# sourceMappingURL=constants.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../../src/webauthn/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAN,IAAY,OAaX;AAbD,WAAY,OAAO;IACjB,wCAAU,CAAA;IACV,wCAAU,CAAA;IACV,yCAAW,CAAA;IACX,yCAAW,CAAA;IACX,yCAAW,CAAA;IACX,yCAAW,CAAA;IACX,yCAAW,CAAA;IACX,2CAAY,CAAA;IACZ,0CAAY,CAAA;IACZ,0CAAY,CAAA;IACZ,0CAAY,CAAA;IACZ,wCAAY,CAAA;AACd,CAAC,EAbW,OAAO,KAAP,OAAO,QAalB;AAED;;;;GAIG;AACH,MAAM,CAAN,IAAY,OAIX;AAJD,WAAY,OAAO;IACjB,mCAAO,CAAA;IACP,mCAAO,CAAA;IACP,mCAAO,CAAA;AACT,CAAC,EAJW,OAAO,KAAP,OAAO,QAIlB;AAED;;;;GAIG;AACH,MAAM,CAAN,IAAY,OAMX;AAND,WAAY,OAAO;IACjB,qCAAQ,CAAA;IACR,qCAAQ,CAAA;IACR,qCAAQ,CAAA;IACR,2CAAW,CAAA;IACX,+CAAa,CAAA;AACf,CAAC,EANW,OAAO,KAAP,OAAO,QAMlB;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,wBAAwB;IACxB,GAAG,EAAE,CAAC;IACN,yBAAyB;IACzB,GAAG,EAAE,CAAC;IAEN,kCAAkC;IAClC,GAAG,EAAE,CAAC,CAAC;IACP,0CAA0C;IAC1C,CAAC,EAAE,CAAC,CAAC;IACL,wBAAwB;IACxB,CAAC,EAAE,CAAC,CAAC;IAEL,qDAAqD;IACrD,CAAC,EAAE,CAAC,CAAC;IACL,oDAAoD;IACpD,CAAC,EAAE,CAAC,CAAC;CACG,CAAC","sourcesContent":["/**\n * COSE Algorithms\n *\n * @see https://www.iana.org/assignments/cose/cose.xhtml#algorithms\n */\nexport enum COSEALG {\n ES256 = -7,\n EdDSA = -8,\n ES384 = -35,\n ES512 = -36,\n PS256 = -37,\n PS384 = -38,\n PS512 = -39,\n ES256K = -47,\n RS256 = -257,\n RS384 = -258,\n RS512 = -259,\n RS1 = -65535,\n}\n\n/**\n * COSE Key Types\n *\n * @see https://www.iana.org/assignments/cose/cose.xhtml#key-type\n */\nexport enum COSEKTY {\n OKP = 1,\n EC2 = 2,\n RSA = 3,\n}\n\n/**\n * COSE Curves\n *\n * @see https://www.iana.org/assignments/cose/cose.xhtml#elliptic-curves\n */\nexport enum COSECRV {\n P256 = 1,\n P384 = 2,\n P521 = 3,\n ED25519 = 6,\n SECP256K1 = 8,\n}\n\n/**\n * COSE Key common and type-specific parameter labels.\n *\n * EC2 and RSA re-use the same numeric labels (-1, -2, -3) with different\n * semantics, so this is a plain object instead of an enum to avoid\n * duplicate-value violations.\n *\n * @see https://www.iana.org/assignments/cose/cose.xhtml#key-common-parameters\n * @see https://www.iana.org/assignments/cose/cose.xhtml#key-type-parameters\n */\nexport const COSEKEYS = {\n /** Key Type (common) */\n Kty: 1,\n /** Algorithm (common) */\n Alg: 3,\n\n /** EC2 / OKP: curve identifier */\n Crv: -1,\n /** EC2: x-coordinate / OKP: public key */\n X: -2,\n /** EC2: y-coordinate */\n Y: -3,\n\n /** RSA: modulus n (shares numeric label with Crv) */\n N: -1,\n /** RSA: exponent e (shares numeric label with X) */\n E: -2,\n} as const;\n"]}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.decodeAttestationObject = void 0;
4
+ const tiny_cbor_1 = require("@levischuck/tiny-cbor");
5
+ /**
6
+ * CBOR-decode an attestationObject buffer into a Map with `fmt`, `attStmt`,
7
+ * and `authData` entries.
8
+ *
9
+ * @param attestationObject - Raw attestation object bytes.
10
+ * @returns Decoded AttestationObject map.
11
+ */
12
+ function decodeAttestationObject(attestationObject) {
13
+ const copy = new Uint8Array(attestationObject);
14
+ const [decoded] = (0, tiny_cbor_1.decodePartialCBOR)(copy, 0);
15
+ return decoded;
16
+ }
17
+ exports.decodeAttestationObject = decodeAttestationObject;
18
+ //# sourceMappingURL=decode-attestation-object.cjs.map
@@ -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 './types.js';
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.ts.map
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 '@levischuck/tiny-cbor';
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.js.map
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 './types.js';
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.ts.map
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 '../utils/encoding.js';
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.js.map
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"]}
@@ -8,4 +8,4 @@
8
8
  * @throws If no expected RP ID matches.
9
9
  */
10
10
  export declare function matchExpectedRPID(rpIdHash: Uint8Array, expectedRPIDs: string[]): string;
11
- //# sourceMappingURL=match-expected-rp-id.d.ts.map
11
+ //# sourceMappingURL=match-expected-rp-id.d.cts.map
@@ -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 '@metamask/utils';
2
- import { sha256 } from '@noble/hashes/sha2';
3
- import { bytesToHex } from '../utils/encoding.js';
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.js.map
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,OAAO,EAAE,OAAO,GAAG,EAAE,CAAC,CAAC;IACvD,OAAO,IAAI,EAAE,CAAC;IAEd,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IACpC,MAAM,KAAK,GAA2B;QACpC,EAAE,EAAE,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QACjC,EAAE,EAAE,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QACjC,EAAE,EAAE,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QACjC,EAAE,EAAE,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QACjC,EAAE,EAAE,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QACjC,EAAE,EAAE,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QACjC,SAAS;KACV,CAAC;IACF,OAAO,IAAI,CAAC,CAAC;IAEb,MAAM,WAAW,GAAG,IAAI,QAAQ,CAC9B,QAAQ,CAAC,MAAM,EACf,QAAQ,CAAC,UAAU,GAAG,OAAO,EAC7B,CAAC,CACF,CAAC;IACF,MAAM,OAAO,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAChD,OAAO,IAAI,CAAC,CAAC;IAEb,MAAM,MAAM,GAA4B;QACtC,QAAQ;QACR,KAAK;QACL,OAAO;KACR,CAAC;IAEF,IAAI,KAAK,CAAC,EAAE,EAAE,CAAC;QACb,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,EAAE,CAAC,CAAC;QACrD,OAAO,IAAI,EAAE,CAAC;QAEd,MAAM,aAAa,GAAG,IAAI,QAAQ,CAChC,QAAQ,CAAC,MAAM,EACf,QAAQ,CAAC,UAAU,GAAG,OAAO,EAC7B,CAAC,CACF,CAAC;QACF,MAAM,SAAS,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;QACpD,OAAO,IAAI,CAAC,CAAC;QAEb,MAAM,YAAY,GAAG,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC,CAAC;QAClE,OAAO,IAAI,SAAS,CAAC;QAErB,MAAM,WAAW,GAAG,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC5C,MAAM,CAAC,EAAE,UAAU,CAAC,GAAG,IAAA,6BAAiB,EACtC,IAAI,UAAU,CAAC,WAAW,CAAC,EAC3B,CAAC,CACmB,CAAC;QACvB,MAAM,mBAAmB,GAAG,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,UAAU,CAAC,CAAC;QAC1E,OAAO,IAAI,UAAU,CAAC;QAEtB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;QACvB,MAAM,CAAC,YAAY,GAAG,YAAY,CAAC;QACnC,MAAM,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;IACnD,CAAC;IAED,IAAI,KAAK,CAAC,EAAE,EAAE,CAAC;QACb,MAAM,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC1C,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,IAAA,6BAAiB,EAC3C,IAAI,UAAU,CAAC,SAAS,CAAC,EACzB,CAAC,CACgC,CAAC;QACpC,MAAM,CAAC,cAAc,GAAG,OAAO,CAAC;QAChC,MAAM,CAAC,oBAAoB,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;QAC3D,OAAO,IAAI,QAAQ,CAAC;IACtB,CAAC;IAED,IAAI,QAAQ,CAAC,UAAU,GAAG,OAAO,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAC9E,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 './types.js';
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.ts.map
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"}