ox 0.12.4 → 0.13.1

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 (128) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/_cjs/core/P256.js +1 -1
  3. package/_cjs/core/P256.js.map +1 -1
  4. package/_cjs/core/WebAuthnP256.js +15 -256
  5. package/_cjs/core/WebAuthnP256.js.map +1 -1
  6. package/_cjs/core/WebCryptoP256.js +3 -1
  7. package/_cjs/core/WebCryptoP256.js.map +1 -1
  8. package/_cjs/core/internal/webauthn.js +5 -13
  9. package/_cjs/core/internal/webauthn.js.map +1 -1
  10. package/_cjs/index.docs.js +1 -0
  11. package/_cjs/index.docs.js.map +1 -1
  12. package/_cjs/tempo/KeyAuthorization.js +18 -3
  13. package/_cjs/tempo/KeyAuthorization.js.map +1 -1
  14. package/_cjs/tempo/SignatureEnvelope.js +26 -0
  15. package/_cjs/tempo/SignatureEnvelope.js.map +1 -1
  16. package/_cjs/tempo/TxEnvelopeTempo.js +5 -10
  17. package/_cjs/tempo/TxEnvelopeTempo.js.map +1 -1
  18. package/_cjs/version.js +1 -1
  19. package/_cjs/webauthn/Authentication.js +246 -0
  20. package/_cjs/webauthn/Authentication.js.map +1 -0
  21. package/_cjs/webauthn/Authenticator.js +55 -0
  22. package/_cjs/webauthn/Authenticator.js.map +1 -0
  23. package/_cjs/webauthn/Credential.js +53 -0
  24. package/_cjs/webauthn/Credential.js.map +1 -0
  25. package/_cjs/webauthn/Registration.js +349 -0
  26. package/_cjs/webauthn/Registration.js.map +1 -0
  27. package/_cjs/webauthn/Types.js +3 -0
  28. package/_cjs/webauthn/Types.js.map +1 -0
  29. package/_cjs/webauthn/index.js +9 -0
  30. package/_cjs/webauthn/index.js.map +1 -0
  31. package/_cjs/webauthn/internal/utils.js +53 -0
  32. package/_cjs/webauthn/internal/utils.js.map +1 -0
  33. package/_esm/core/P256.js +1 -1
  34. package/_esm/core/P256.js.map +1 -1
  35. package/_esm/core/WebAuthnP256.js +13 -261
  36. package/_esm/core/WebAuthnP256.js.map +1 -1
  37. package/_esm/core/WebCryptoP256.js +4 -1
  38. package/_esm/core/WebCryptoP256.js.map +1 -1
  39. package/_esm/core/internal/webauthn.js +5 -13
  40. package/_esm/core/internal/webauthn.js.map +1 -1
  41. package/_esm/erc8021/index.js +2 -2
  42. package/_esm/index.docs.js +1 -0
  43. package/_esm/index.docs.js.map +1 -1
  44. package/_esm/tempo/KeyAuthorization.js +66 -3
  45. package/_esm/tempo/KeyAuthorization.js.map +1 -1
  46. package/_esm/tempo/SignatureEnvelope.js +74 -0
  47. package/_esm/tempo/SignatureEnvelope.js.map +1 -1
  48. package/_esm/tempo/TransactionReceipt.js +1 -1
  49. package/_esm/tempo/TransactionRequest.js +1 -1
  50. package/_esm/tempo/TxEnvelopeTempo.js +5 -10
  51. package/_esm/tempo/TxEnvelopeTempo.js.map +1 -1
  52. package/_esm/version.js +1 -1
  53. package/_esm/webauthn/Authentication.js +453 -0
  54. package/_esm/webauthn/Authentication.js.map +1 -0
  55. package/_esm/webauthn/Authenticator.js +176 -0
  56. package/_esm/webauthn/Authenticator.js.map +1 -0
  57. package/_esm/webauthn/Credential.js +95 -0
  58. package/_esm/webauthn/Credential.js.map +1 -0
  59. package/_esm/webauthn/Registration.js +512 -0
  60. package/_esm/webauthn/Registration.js.map +1 -0
  61. package/_esm/webauthn/Types.js +2 -0
  62. package/_esm/webauthn/Types.js.map +1 -0
  63. package/_esm/webauthn/index.js +31 -0
  64. package/_esm/webauthn/index.js.map +1 -0
  65. package/_esm/webauthn/internal/utils.js +52 -0
  66. package/_esm/webauthn/internal/utils.js.map +1 -0
  67. package/_types/core/WebAuthnP256.d.ts +33 -208
  68. package/_types/core/WebAuthnP256.d.ts.map +1 -1
  69. package/_types/core/WebCryptoP256.d.ts +2 -0
  70. package/_types/core/WebCryptoP256.d.ts.map +1 -1
  71. package/_types/core/internal/webauthn.d.ts +2 -110
  72. package/_types/core/internal/webauthn.d.ts.map +1 -1
  73. package/_types/erc8021/index.d.ts +2 -2
  74. package/_types/index.docs.d.ts +1 -0
  75. package/_types/index.docs.d.ts.map +1 -1
  76. package/_types/tempo/KeyAuthorization.d.ts +57 -0
  77. package/_types/tempo/KeyAuthorization.d.ts.map +1 -1
  78. package/_types/tempo/SignatureEnvelope.d.ts +75 -0
  79. package/_types/tempo/SignatureEnvelope.d.ts.map +1 -1
  80. package/_types/tempo/Transaction.d.ts +2 -2
  81. package/_types/tempo/TransactionReceipt.d.ts +2 -2
  82. package/_types/tempo/TransactionRequest.d.ts +2 -2
  83. package/_types/tempo/TxEnvelopeTempo.d.ts.map +1 -1
  84. package/_types/version.d.ts +1 -1
  85. package/_types/webauthn/Authentication.d.ts +324 -0
  86. package/_types/webauthn/Authentication.d.ts.map +1 -0
  87. package/_types/webauthn/Authenticator.d.ts +182 -0
  88. package/_types/webauthn/Authenticator.d.ts.map +1 -0
  89. package/_types/webauthn/Credential.d.ts +77 -0
  90. package/_types/webauthn/Credential.d.ts.map +1 -0
  91. package/_types/webauthn/Registration.d.ts +308 -0
  92. package/_types/webauthn/Registration.d.ts.map +1 -0
  93. package/_types/webauthn/Types.d.ts +106 -0
  94. package/_types/webauthn/Types.d.ts.map +1 -0
  95. package/_types/webauthn/index.d.ts +33 -0
  96. package/_types/webauthn/index.d.ts.map +1 -0
  97. package/_types/webauthn/internal/utils.d.ts +17 -0
  98. package/_types/webauthn/internal/utils.d.ts.map +1 -0
  99. package/core/P256.ts +1 -1
  100. package/core/WebAuthnP256.ts +37 -582
  101. package/core/WebCryptoP256.ts +6 -1
  102. package/core/internal/webauthn.ts +6 -165
  103. package/erc8021/index.ts +2 -2
  104. package/index.docs.ts +1 -0
  105. package/package.json +31 -1
  106. package/tempo/KeyAuthorization.test.ts +139 -0
  107. package/tempo/KeyAuthorization.ts +82 -3
  108. package/tempo/SignatureEnvelope.test.ts +147 -0
  109. package/tempo/SignatureEnvelope.ts +113 -0
  110. package/tempo/Transaction.ts +2 -2
  111. package/tempo/TransactionReceipt.ts +2 -2
  112. package/tempo/TransactionRequest.ts +2 -2
  113. package/tempo/TxEnvelopeTempo.ts +5 -12
  114. package/tempo/e2e.test.ts +265 -0
  115. package/version.ts +1 -1
  116. package/webauthn/Authentication/package.json +6 -0
  117. package/webauthn/Authentication.ts +673 -0
  118. package/webauthn/Authenticator/package.json +6 -0
  119. package/webauthn/Authenticator.ts +259 -0
  120. package/webauthn/Credential/package.json +6 -0
  121. package/webauthn/Credential.ts +146 -0
  122. package/webauthn/Registration/package.json +6 -0
  123. package/webauthn/Registration.ts +805 -0
  124. package/webauthn/Types/package.json +6 -0
  125. package/webauthn/Types.ts +158 -0
  126. package/webauthn/index.ts +38 -0
  127. package/webauthn/internal/utils.ts +63 -0
  128. package/webauthn/package.json +6 -0
@@ -0,0 +1,95 @@
1
+ import * as Base64 from '../core/Base64.js';
2
+ import * as PublicKey from '../core/PublicKey.js';
3
+ import { base64UrlOptions, bufferSourceToBytes, bytesToArrayBuffer, responseKeys, } from './internal/utils.js';
4
+ /**
5
+ * Serializes a credential into a JSON-serializable
6
+ * format.
7
+ *
8
+ * @example
9
+ * ```ts twoslash
10
+ * import { Registration, Credential } from 'ox/webauthn'
11
+ *
12
+ * const credential = await Registration.create({ name: 'Example' })
13
+ *
14
+ * const serialized = Credential.serialize(credential) // [!code focus]
15
+ *
16
+ * // `serialized` is JSON-serializable — send it to a server, store it, etc.
17
+ * const json = JSON.stringify(serialized)
18
+ * ```
19
+ *
20
+ * @param credential - The credential to serialize.
21
+ * @returns The serialized credential.
22
+ */
23
+ export function serialize(credential) {
24
+ const { attestationObject, clientDataJSON, id, publicKey, raw } = credential;
25
+ const response = {};
26
+ for (const key of responseKeys) {
27
+ const value = raw.response[key];
28
+ if (value instanceof ArrayBuffer)
29
+ response[key] = Base64.fromBytes(new Uint8Array(value), base64UrlOptions);
30
+ }
31
+ return {
32
+ attestationObject: Base64.fromBytes(new Uint8Array(attestationObject), base64UrlOptions),
33
+ clientDataJSON: Base64.fromBytes(new Uint8Array(clientDataJSON), base64UrlOptions),
34
+ id,
35
+ publicKey: PublicKey.toHex(publicKey),
36
+ raw: {
37
+ id: raw.id,
38
+ type: raw.type,
39
+ authenticatorAttachment: raw.authenticatorAttachment,
40
+ rawId: Base64.fromBytes(bufferSourceToBytes(raw.rawId), base64UrlOptions),
41
+ response: response,
42
+ },
43
+ };
44
+ }
45
+ /**
46
+ * Deserializes a serialized credential.
47
+ *
48
+ * @example
49
+ * ```ts twoslash
50
+ * import { Credential } from 'ox/webauthn'
51
+ *
52
+ * const credential = Credential.deserialize({ // [!code focus]
53
+ * attestationObject: 'o2NmbXRkbm9uZQ...', // [!code focus]
54
+ * clientDataJSON: 'eyJ0eXBlIjoid2ViYXV0aG4uY3JlYXRlIn0', // [!code focus]
55
+ * id: 'm1-bMPuAqpWhCxHZQZTT6e-lSPntQbh3opIoGe7g4Qs', // [!code focus]
56
+ * publicKey: '0x04ab891400140fc4f8e941ce0ff90e419de9470acaca613bbd717a4775435031a7d884318e919fd3b3e5a631d866d8a380b44063e70f0c381ee16e0652f7f97554', // [!code focus]
57
+ * raw: { // [!code focus]
58
+ * id: 'm1-bMPuAqpWhCxHZQZTT6e-lSPntQbh3opIoGe7g4Qs', // [!code focus]
59
+ * type: 'public-key', // [!code focus]
60
+ * authenticatorAttachment: 'platform', // [!code focus]
61
+ * rawId: 'm1-bMPuAqpWhCxHZQZTT6e-lSPntQbh3opIoGe7g4Qs', // [!code focus]
62
+ * response: { // [!code focus]
63
+ * clientDataJSON: 'eyJ0eXBlIjoid2ViYXV0aG4uY3JlYXRlIn0', // [!code focus]
64
+ * }, // [!code focus]
65
+ * }, // [!code focus]
66
+ * }) // [!code focus]
67
+ * ```
68
+ *
69
+ * @param credential - The serialized credential.
70
+ * @returns The deserialized credential.
71
+ */
72
+ export function deserialize(credential) {
73
+ const { attestationObject, clientDataJSON, id, publicKey, raw } = credential;
74
+ const response = Object.create(null);
75
+ for (const key of responseKeys) {
76
+ const value = raw.response[key];
77
+ if (value)
78
+ response[key] = bytesToArrayBuffer(Base64.toBytes(value));
79
+ }
80
+ return {
81
+ attestationObject: bytesToArrayBuffer(Base64.toBytes(attestationObject)),
82
+ clientDataJSON: bytesToArrayBuffer(Base64.toBytes(clientDataJSON)),
83
+ id,
84
+ publicKey: PublicKey.from(publicKey),
85
+ raw: {
86
+ id: raw.id,
87
+ type: raw.type,
88
+ authenticatorAttachment: raw.authenticatorAttachment,
89
+ rawId: bytesToArrayBuffer(Base64.toBytes(raw.rawId)),
90
+ response: response,
91
+ getClientExtensionResults: () => ({}),
92
+ },
93
+ };
94
+ }
95
+ //# sourceMappingURL=Credential.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Credential.js","sourceRoot":"","sources":["../../webauthn/Credential.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAI3C,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA;AACjD,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,YAAY,GACb,MAAM,qBAAqB,CAAA;AAqB5B;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,SAAS,CAAC,UAAsB;IAC9C,MAAM,EAAE,iBAAiB,EAAE,cAAc,EAAE,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,UAAU,CAAA;IAE5E,MAAM,QAAQ,GAAG,EAA4B,CAAA;IAC7C,KAAK,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;QAC/B,MAAM,KAAK,GAAI,GAAG,CAAC,QAA+C,CAAC,GAAG,CAAC,CAAA;QACvE,IAAI,KAAK,YAAY,WAAW;YAC9B,QAAQ,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,gBAAgB,CAAC,CAAA;IAC7E,CAAC;IAED,OAAO;QACL,iBAAiB,EAAE,MAAM,CAAC,SAAS,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,EAAE;YACH,EAAE,EAAE,GAAG,CAAC,EAAE;YACV,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,uBAAuB,EAAE,GAAG,CAAC,uBAAuB;YACpD,KAAK,EAAE,kBAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACpD,QAAQ,EAAE,QAAkD;YAC5D,yBAAyB,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;SACtC;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,512 @@
1
+ import * as Base64 from '../core/Base64.js';
2
+ import * as Bytes from '../core/Bytes.js';
3
+ import * as Cbor from '../core/Cbor.js';
4
+ import * as CoseKey from '../core/CoseKey.js';
5
+ import * as Errors from '../core/Errors.js';
6
+ import * as Hash from '../core/Hash.js';
7
+ import * as Hex from '../core/Hex.js';
8
+ import * as internal from '../core/internal/webauthn.js';
9
+ import * as P256 from '../core/P256.js';
10
+ import * as PublicKey from '../core/PublicKey.js';
11
+ import * as Signature from '../core/Signature.js';
12
+ import { base64UrlOptions, bufferSourceToBytes, bytesToArrayBuffer, deserializeExtensions, responseKeys, serializeExtensions, } from './internal/utils.js';
13
+ export const createChallenge = Uint8Array.from([
14
+ 105, 171, 180, 181, 160, 222, 75, 198, 42, 42, 32, 31, 141, 37, 186, 233,
15
+ ]);
16
+ /**
17
+ * Creates a new WebAuthn P256 Credential, which can be stored and later used for signing.
18
+ *
19
+ * @example
20
+ * ```ts twoslash
21
+ * import { Registration } from 'ox/webauthn'
22
+ *
23
+ * const credential = await Registration.create({ name: 'Example' }) // [!code focus]
24
+ * // @log: {
25
+ * // @log: id: 'oZ48...',
26
+ * // @log: publicKey: { x: 51421...5123n, y: 12345...6789n },
27
+ * // @log: raw: PublicKeyCredential {},
28
+ * // @log: }
29
+ * ```
30
+ *
31
+ * @param options - Credential creation options.
32
+ * @returns A WebAuthn P256 credential.
33
+ */
34
+ export async function create(options) {
35
+ const { createFn = window.navigator.credentials.create.bind(window.navigator.credentials), ...rest } = options;
36
+ const creationOptions = 'publicKey' in rest
37
+ ? rest
38
+ : getOptions(rest);
39
+ try {
40
+ const credential = (await createFn(creationOptions));
41
+ if (!credential)
42
+ throw new CreateFailedError();
43
+ const response = credential.response;
44
+ const publicKey = await internal.parseCredentialPublicKey(response);
45
+ return {
46
+ attestationObject: response.attestationObject,
47
+ clientDataJSON: response.clientDataJSON,
48
+ id: credential.id,
49
+ publicKey,
50
+ raw: credential,
51
+ };
52
+ }
53
+ catch (error) {
54
+ throw new CreateFailedError({
55
+ cause: error,
56
+ });
57
+ }
58
+ }
59
+ /**
60
+ * Returns the creation options for a P256 WebAuthn Credential to be used with
61
+ * the Web Authentication API.
62
+ *
63
+ * @example
64
+ * ```ts twoslash
65
+ * import { Registration } from 'ox/webauthn'
66
+ *
67
+ * const options = Registration.getOptions({ name: 'Example' })
68
+ *
69
+ * const credential = await window.navigator.credentials.create(options)
70
+ * ```
71
+ *
72
+ * @param options - Options.
73
+ * @returns The credential creation options.
74
+ */
75
+ export function getOptions(options) {
76
+ const { attestation = 'none', authenticatorSelection = {
77
+ residentKey: 'preferred',
78
+ requireResidentKey: false,
79
+ userVerification: 'required',
80
+ }, challenge = createChallenge, excludeCredentialIds, extensions, name: name_, rp = {
81
+ id: window.location.hostname,
82
+ name: window.document.title,
83
+ }, user, } = options;
84
+ const name = (user?.name ?? name_);
85
+ return {
86
+ publicKey: {
87
+ attestation,
88
+ authenticatorSelection,
89
+ challenge: typeof challenge === 'string' ? Bytes.fromHex(challenge) : challenge,
90
+ ...(excludeCredentialIds
91
+ ? {
92
+ excludeCredentials: excludeCredentialIds?.map((id) => ({
93
+ id: Base64.toBytes(id),
94
+ type: 'public-key',
95
+ })),
96
+ }
97
+ : {}),
98
+ pubKeyCredParams: [
99
+ {
100
+ type: 'public-key',
101
+ alg: -7, // p256
102
+ },
103
+ ],
104
+ rp,
105
+ user: {
106
+ id: user?.id ?? Hash.keccak256(Bytes.fromString(name), { as: 'Bytes' }),
107
+ name,
108
+ displayName: user?.displayName ?? name,
109
+ },
110
+ ...(extensions && { extensions }),
111
+ },
112
+ };
113
+ }
114
+ /**
115
+ * Serializes a registration response into a JSON-serializable
116
+ * format, converting `ArrayBuffer` fields to base64url strings
117
+ * and the public key to a hex string.
118
+ *
119
+ * @example
120
+ * ```ts twoslash
121
+ * import { Registration } from 'ox/webauthn'
122
+ *
123
+ * const credential = await Registration.create({ name: 'Example' })
124
+ * const response = Registration.verify({
125
+ * credential,
126
+ * challenge: '0x...',
127
+ * origin: 'https://example.com',
128
+ * rpId: 'example.com',
129
+ * })
130
+ *
131
+ * const serialized = Registration.serializeResponse(response) // [!code focus]
132
+ *
133
+ * // `serialized` is JSON-serializable — send it to a server, store it, etc.
134
+ * const json = JSON.stringify(serialized)
135
+ * ```
136
+ *
137
+ * @param response - The registration response to serialize.
138
+ * @returns The serialized registration response.
139
+ */
140
+ export function serializeResponse(response) {
141
+ const { credential, ...rest } = response;
142
+ const rawResponse = {};
143
+ for (const key of responseKeys) {
144
+ const value = credential.raw.response[key];
145
+ if (value instanceof ArrayBuffer)
146
+ rawResponse[key] = Base64.fromBytes(new Uint8Array(value), base64UrlOptions);
147
+ }
148
+ return {
149
+ ...rest,
150
+ credential: {
151
+ attestationObject: Base64.fromBytes(new Uint8Array(credential.attestationObject), base64UrlOptions),
152
+ clientDataJSON: Base64.fromBytes(new Uint8Array(credential.clientDataJSON), base64UrlOptions),
153
+ id: credential.id,
154
+ publicKey: PublicKey.toHex(credential.publicKey),
155
+ raw: {
156
+ id: credential.raw.id,
157
+ type: credential.raw.type,
158
+ authenticatorAttachment: credential.raw.authenticatorAttachment,
159
+ rawId: Base64.fromBytes(bufferSourceToBytes(credential.raw.rawId), base64UrlOptions),
160
+ response: rawResponse,
161
+ },
162
+ },
163
+ };
164
+ }
165
+ /**
166
+ * Serializes credential creation options into a JSON-serializable
167
+ * format, converting `BufferSource` fields to base64url strings.
168
+ *
169
+ * @example
170
+ * ```ts twoslash
171
+ * import { Registration } from 'ox/webauthn'
172
+ *
173
+ * const options = Registration.getOptions({ name: 'Example' })
174
+ *
175
+ * const serialized = Registration.serializeOptions(options) // [!code focus]
176
+ *
177
+ * // `serialized` is JSON-serializable — send it to a server, store it, etc.
178
+ * const json = JSON.stringify(serialized)
179
+ * ```
180
+ *
181
+ * @param options - The credential creation options to serialize.
182
+ * @returns The serialized credential creation options.
183
+ */
184
+ export function serializeOptions(options) {
185
+ const publicKey = options.publicKey;
186
+ if (!publicKey)
187
+ return {};
188
+ const { challenge, excludeCredentials, extensions, user, ...rest } = publicKey;
189
+ return {
190
+ publicKey: {
191
+ ...rest,
192
+ challenge: Hex.fromBytes(bufferSourceToBytes(challenge)),
193
+ ...(excludeCredentials && {
194
+ excludeCredentials: excludeCredentials.map(({ id, ...rest }) => ({
195
+ ...rest,
196
+ id: Base64.fromBytes(bufferSourceToBytes(id), base64UrlOptions),
197
+ })),
198
+ }),
199
+ ...(extensions && {
200
+ extensions: serializeExtensions(extensions),
201
+ }),
202
+ user: {
203
+ ...user,
204
+ id: Base64.fromBytes(bufferSourceToBytes(user.id), base64UrlOptions),
205
+ },
206
+ },
207
+ };
208
+ }
209
+ /**
210
+ * Deserializes credential creation options that can be passed to
211
+ * `navigator.credentials.create()`.
212
+ *
213
+ * @example
214
+ * ```ts twoslash
215
+ * import { Registration } from 'ox/webauthn'
216
+ *
217
+ * const options = Registration.getOptions({ name: 'Example' })
218
+ * const serialized = Registration.serializeOptions(options)
219
+ *
220
+ * // ... send to server and back ...
221
+ *
222
+ * const deserialized = Registration.deserializeOptions(serialized) // [!code focus]
223
+ * const credential = await window.navigator.credentials.create(deserialized)
224
+ * ```
225
+ *
226
+ * @param options - The serialized credential creation options.
227
+ * @returns The deserialized credential creation options.
228
+ */
229
+ export function deserializeOptions(options) {
230
+ const publicKey = options.publicKey;
231
+ if (!publicKey)
232
+ return {};
233
+ const { challenge, excludeCredentials, extensions, user, ...rest } = publicKey;
234
+ return {
235
+ publicKey: {
236
+ ...rest,
237
+ challenge: Bytes.fromHex(challenge),
238
+ ...(excludeCredentials && {
239
+ excludeCredentials: excludeCredentials.map(({ id, ...rest }) => ({
240
+ ...rest,
241
+ id: Base64.toBytes(id),
242
+ })),
243
+ }),
244
+ ...(extensions && {
245
+ extensions: deserializeExtensions(extensions),
246
+ }),
247
+ user: {
248
+ ...user,
249
+ id: Base64.toBytes(user.id),
250
+ },
251
+ },
252
+ };
253
+ }
254
+ /**
255
+ * Deserializes a serialized registration response.
256
+ *
257
+ * @example
258
+ * ```ts twoslash
259
+ * import { Registration } from 'ox/webauthn'
260
+ *
261
+ * const response = Registration.deserializeResponse({ // [!code focus]
262
+ * credential: { // [!code focus]
263
+ * attestationObject: 'o2NmbXRkbm9uZQ...', // [!code focus]
264
+ * clientDataJSON: 'eyJ0eXBlIjoid2Vi...', // [!code focus]
265
+ * id: 'm1-bMPuAqpWhCxHZQZTT6e-lSPntQbh3opIoGe7g4Qs', // [!code focus]
266
+ * publicKey: '0x04ab891400...', // [!code focus]
267
+ * raw: { id: '...', type: 'public-key', authenticatorAttachment: 'platform', rawId: '...', response: { clientDataJSON: 'eyJ0eXBlIjoid2Vi...' } }, // [!code focus]
268
+ * }, // [!code focus]
269
+ * counter: 0, // [!code focus]
270
+ * }) // [!code focus]
271
+ * ```
272
+ *
273
+ * @param response - The serialized registration response.
274
+ * @returns The deserialized registration response.
275
+ */
276
+ export function deserializeResponse(response) {
277
+ const { credential, ...rest } = response;
278
+ const rawResponse = {};
279
+ for (const [key, value] of Object.entries(credential.raw.response))
280
+ rawResponse[key] = bytesToArrayBuffer(Base64.toBytes(value));
281
+ return {
282
+ ...rest,
283
+ credential: {
284
+ attestationObject: bytesToArrayBuffer(Base64.toBytes(credential.attestationObject)),
285
+ clientDataJSON: bytesToArrayBuffer(Base64.toBytes(credential.clientDataJSON)),
286
+ id: credential.id,
287
+ publicKey: PublicKey.from(credential.publicKey),
288
+ raw: {
289
+ id: credential.raw.id,
290
+ type: credential.raw.type,
291
+ authenticatorAttachment: credential.raw.authenticatorAttachment,
292
+ rawId: bytesToArrayBuffer(Base64.toBytes(credential.raw.rawId)),
293
+ response: rawResponse,
294
+ getClientExtensionResults: () => ({}),
295
+ },
296
+ },
297
+ };
298
+ }
299
+ /**
300
+ * Verifies a WebAuthn registration (credential creation) response. Validates the
301
+ * `clientDataJSON`, `attestationObject`, authenticator flags, challenge, origin, and
302
+ * relying party ID, then extracts the credential ID and public key.
303
+ *
304
+ * @example
305
+ * ```ts twoslash
306
+ * import { Registration } from 'ox/webauthn'
307
+ *
308
+ * const credential = await Registration.create({ name: 'Example' })
309
+ *
310
+ * const result = Registration.verify({ // [!code focus]
311
+ * credential, // [!code focus]
312
+ * challenge: '0x69abb4b5a0de4bc62a2a201f8d25bae9', // [!code focus]
313
+ * origin: 'https://example.com', // [!code focus]
314
+ * rpId: 'example.com', // [!code focus]
315
+ * }) // [!code focus]
316
+ * // @log: {
317
+ * // @log: credential: {
318
+ * // @log: id: 'oZ48...',
319
+ * // @log: publicKey: { prefix: 4, x: 51421...5123n, y: 12345...6789n },
320
+ * // @log: },
321
+ * // @log: counter: 0,
322
+ * // @log: userVerified: true,
323
+ * // @log: }
324
+ * ```
325
+ *
326
+ * @param options - Verification options.
327
+ * @returns The verified registration result.
328
+ */
329
+ export function verify(options) {
330
+ const { attestation = 'none', credential, origin, rpId, userVerification = 'required', } = options;
331
+ // 1. Decode and validate clientDataJSON
332
+ const clientDataJSONBytes = new Uint8Array(credential.clientDataJSON);
333
+ const clientDataJSON = Bytes.toString(clientDataJSONBytes);
334
+ const clientData = JSON.parse(clientDataJSON);
335
+ if (clientData.type !== 'webauthn.create')
336
+ throw new VerifyError(`Expected clientData.type "webauthn.create", got "${clientData.type}"`);
337
+ // Validate challenge
338
+ const challengeResult = (() => {
339
+ if (typeof options.challenge === 'function')
340
+ return options.challenge(clientData.challenge);
341
+ const challengeBytes = typeof options.challenge === 'string'
342
+ ? Bytes.fromHex(options.challenge)
343
+ : options.challenge;
344
+ const challenge = Base64.fromBytes(challengeBytes, base64UrlOptions);
345
+ return clientData.challenge === challenge;
346
+ })();
347
+ if (!challengeResult)
348
+ throw new VerifyError('Challenge mismatch');
349
+ // Validate origin
350
+ const origins = Array.isArray(origin) ? origin : [origin];
351
+ if (!origins.includes(clientData.origin))
352
+ throw new VerifyError(`Origin mismatch: expected ${JSON.stringify(origin)}, got "${clientData.origin}"`);
353
+ // 2. Decode attestationObject via CBOR
354
+ const attestationObjectBytes = new Uint8Array(credential.attestationObject);
355
+ const attestation_ = Cbor.decode(attestationObjectBytes);
356
+ // 3. Parse authenticatorData
357
+ const authData = attestation_.authData;
358
+ const rpIdHash = authData.slice(0, 32);
359
+ const expectedRpIdHash = Hash.sha256(Hex.fromString(rpId), { as: 'Bytes' });
360
+ if (!Bytes.isEqual(rpIdHash, expectedRpIdHash))
361
+ throw new VerifyError('rpId hash mismatch');
362
+ const flags = authData[32];
363
+ const up = (flags & 0x01) !== 0;
364
+ const uv = (flags & 0x04) !== 0;
365
+ const at = (flags & 0x40) !== 0;
366
+ const be = (flags & 0x08) !== 0;
367
+ const bs = (flags & 0x10) !== 0;
368
+ if (!up)
369
+ throw new VerifyError('User presence flag not set');
370
+ if (!at)
371
+ throw new VerifyError('Attested credential data flag not set');
372
+ if (userVerification === 'required' && !uv)
373
+ throw new VerifyError('User verification flag not set');
374
+ // If the BE bit is not set, the BS bit must not be set.
375
+ if (!be && bs)
376
+ throw new VerifyError('Backup state (BS) flag is set but backup eligibility (BE) flag is not');
377
+ // Minimum authData length: 37 (rpIdHash + flags + counter) + 16 (AAGUID) + 2 (credIdLen)
378
+ if (authData.length < 55)
379
+ throw new VerifyError('authData too short for attested credential data');
380
+ // Counter (4 bytes, big-endian, starting at offset 33)
381
+ const counter = ((authData[33] << 24) |
382
+ (authData[34] << 16) |
383
+ (authData[35] << 8) |
384
+ authData[36]) >>>
385
+ 0;
386
+ // Credential ID length (2 bytes at offset 53, big-endian)
387
+ const credIdLen = (authData[53] << 8) | authData[54];
388
+ if (55 + credIdLen > authData.length)
389
+ throw new VerifyError('credIdLen exceeds authData bounds');
390
+ // Credential ID (variable length starting at offset 55)
391
+ const credentialId = authData.slice(55, 55 + credIdLen);
392
+ // Verify credential ID consistency if caller-supplied id is present
393
+ if (credential.id !== undefined) {
394
+ const expectedId = Base64.fromBytes(credentialId, base64UrlOptions);
395
+ if (credential.id !== expectedId)
396
+ throw new VerifyError(`Credential ID mismatch: supplied "${credential.id}" does not match authData "${expectedId}"`);
397
+ }
398
+ // 4. Parse and validate COSE public key
399
+ const ed = (flags & 0x80) !== 0;
400
+ const coseKeyBytes = authData.slice(55 + credIdLen);
401
+ const coseKeyHex = Hex.fromBytes(coseKeyBytes);
402
+ const coseKeyData = Cbor.decode(coseKeyHex);
403
+ // Validate key type is EC2 (2), algorithm is ES256 (-7), and curve is P-256 (1)
404
+ if (coseKeyData['1'] !== 2 ||
405
+ coseKeyData['3'] !== -7 ||
406
+ coseKeyData['-1'] !== 1)
407
+ throw new VerifyError('COSE key must be EC2 (kty=2) with ES256 algorithm (alg=-7) on P-256 curve (crv=1)');
408
+ const publicKey = CoseKey.toPublicKey(coseKeyHex);
409
+ // Verify no unexpected trailing bytes after the COSE key.
410
+ // Re-encode the extracted public key as a COSE key to determine its expected length.
411
+ const expectedCoseKeyLen = Bytes.fromHex(CoseKey.fromPublicKey(publicKey)).length;
412
+ const trailingBytes = coseKeyBytes.length - expectedCoseKeyLen;
413
+ if (trailingBytes > 0 && !ed)
414
+ throw new VerifyError(`authData contains ${trailingBytes} unexpected trailing byte(s) after COSE key`);
415
+ // 5. Verify attestation statement (cryptographic binding of authData + clientDataJSON)
416
+ const clientDataHash = Hash.sha256(Bytes.fromString(clientDataJSON), {
417
+ as: 'Bytes',
418
+ });
419
+ const verificationData = Bytes.concat(authData, clientDataHash);
420
+ const { fmt, attStmt } = attestation_;
421
+ if (fmt === 'none') {
422
+ // "none" format has no attestation signature; only accept if caller opts in
423
+ if (attestation === 'required')
424
+ throw new VerifyError('Attestation format is "none" but attestation verification is required. ' +
425
+ 'Set `attestation: "none"` to accept unattested credentials.');
426
+ }
427
+ else if (fmt === 'packed') {
428
+ // Packed attestation: verify signature over authData || clientDataHash
429
+ const sig = attStmt.sig;
430
+ const alg = attStmt.alg;
431
+ if (!(sig instanceof Uint8Array) || typeof alg !== 'number')
432
+ throw new VerifyError('Invalid packed attestation statement: missing sig or alg');
433
+ if (alg !== -7)
434
+ throw new VerifyError(`Unsupported attestation algorithm: ${alg} (expected -7 / ES256)`);
435
+ if (attStmt.x5c) {
436
+ // Full attestation with certificate chain is not supported
437
+ throw new VerifyError('Packed attestation with x5c certificate chain is not supported. ' +
438
+ 'Use self attestation (no x5c) or set `attestation: "none"`.');
439
+ }
440
+ // Self attestation: verify using the credential public key
441
+ const attSignature = Signature.fromDerBytes(sig);
442
+ const verified = P256.verify({
443
+ hash: true,
444
+ payload: verificationData,
445
+ publicKey,
446
+ signature: attSignature,
447
+ });
448
+ if (!verified)
449
+ throw new VerifyError('Attestation signature verification failed');
450
+ }
451
+ else {
452
+ throw new VerifyError(`Unsupported attestation format: "${fmt}"`);
453
+ }
454
+ // 6. Build credential ID string
455
+ const id = credential.id ?? Base64.fromBytes(credentialId, base64UrlOptions);
456
+ // 7. Build raw credential
457
+ const raw = credential.raw ?? {
458
+ authenticatorAttachment: null,
459
+ getClientExtensionResults: () => ({}),
460
+ id,
461
+ rawId: bytesToArrayBuffer(credentialId),
462
+ response: {
463
+ attestationObject: credential.attestationObject,
464
+ clientDataJSON: credential.clientDataJSON,
465
+ },
466
+ type: 'public-key',
467
+ };
468
+ return {
469
+ credential: {
470
+ attestationObject: credential.attestationObject,
471
+ clientDataJSON: credential.clientDataJSON,
472
+ id,
473
+ publicKey,
474
+ raw,
475
+ },
476
+ counter,
477
+ ...(uv ? { userVerified: true } : {}),
478
+ ...(be ? { backedUp: bs } : {}),
479
+ ...(be
480
+ ? {
481
+ deviceType: bs ? 'multiDevice' : 'singleDevice',
482
+ }
483
+ : {}),
484
+ };
485
+ }
486
+ /** Thrown when WebAuthn registration verification fails. */
487
+ export class VerifyError extends Errors.BaseError {
488
+ constructor() {
489
+ super(...arguments);
490
+ Object.defineProperty(this, "name", {
491
+ enumerable: true,
492
+ configurable: true,
493
+ writable: true,
494
+ value: 'Registration.VerifyError'
495
+ });
496
+ }
497
+ }
498
+ /** Thrown when a WebAuthn P256 credential creation fails. */
499
+ export class CreateFailedError extends Errors.BaseError {
500
+ constructor({ cause } = {}) {
501
+ super('Failed to create credential.', {
502
+ cause,
503
+ });
504
+ Object.defineProperty(this, "name", {
505
+ enumerable: true,
506
+ configurable: true,
507
+ writable: true,
508
+ value: 'Registration.CreateFailedError'
509
+ });
510
+ }
511
+ }
512
+ //# sourceMappingURL=Registration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Registration.js","sourceRoot":"","sources":["../../webauthn/Registration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAC3C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAA;AACzC,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAA;AACvC,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAA;AAC7C,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAC3C,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAA;AACvC,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAA;AAErC,OAAO,KAAK,QAAQ,MAAM,8BAA8B,CAAA;AACxD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA;AACjD,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA;AAEjD,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACrB,YAAY,EACZ,mBAAmB,GACpB,MAAM,qBAAqB,CAAA;AAG5B,MAAM,CAAC,MAAM,eAAe,GAAG,UAAU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B,GAAG,CAAC,EAAE;YACJ,CAAC,CAAC;gBACE,UAAU,EAAE,EAAE,CAAC,CAAC,CAAE,aAAuB,CAAC,CAAC,CAAE,cAAwB;aACtE;YACH,CAAC,CAAC,EAAE,CAAC;KACR,CAAA;AACH,CAAC;AAiDD,4DAA4D;AAC5D,MAAM,OAAO,WAAY,SAAQ,MAAM,CAAC,SAAS;IAAjD;;QACoB;;;;mBAAO,0BAA0B;WAAA;IACrD,CAAC;CAAA;AAED,6DAA6D;AAC7D,MAAM,OAAO,iBAAkB,SAAQ,MAAM,CAAC,SAAgB;IAG5D,YAAY,EAAE,KAAK,KAAoC,EAAE;QACvD,KAAK,CAAC,8BAA8B,EAAE;YACpC,KAAK;SACN,CAAC,CAAA;QALc;;;;mBAAO,gCAAgC;WAAA;IAMzD,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Types.js","sourceRoot":"","sources":["../../webauthn/Types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Utility functions and types for WebAuthn authentication ceremonies (signing and verification).
3
+ *
4
+ * @category WebAuthn
5
+ */
6
+ export * as Authentication from './Authentication.js';
7
+ /**
8
+ * Utility functions for constructing and parsing authenticator data and client data JSON.
9
+ *
10
+ * @category WebAuthn
11
+ */
12
+ export * as Authenticator from './Authenticator.js';
13
+ /**
14
+ * Utility functions and types for WebAuthn P256 credentials.
15
+ *
16
+ * @category WebAuthn
17
+ */
18
+ export * as Credential from './Credential.js';
19
+ /**
20
+ * Utility functions and types for WebAuthn registration ceremonies (credential creation and verification).
21
+ *
22
+ * @category WebAuthn
23
+ */
24
+ export * as Registration from './Registration.js';
25
+ /**
26
+ * WebAuthn type definitions.
27
+ *
28
+ * @category WebAuthn
29
+ */
30
+ export * as Types from './Types.js';
31
+ //# sourceMappingURL=index.js.map