@supabase/gotrue-js 2.73.0-rc.3 → 2.73.0-rc.5

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 (65) hide show
  1. package/dist/main/GoTrueClient.d.ts +1 -1
  2. package/dist/main/GoTrueClient.d.ts.map +1 -1
  3. package/dist/main/GoTrueClient.js +43 -15
  4. package/dist/main/GoTrueClient.js.map +1 -1
  5. package/dist/main/lib/base64url.d.ts +3 -2
  6. package/dist/main/lib/base64url.d.ts.map +1 -1
  7. package/dist/main/lib/base64url.js.map +1 -1
  8. package/dist/main/lib/helpers.d.ts +2 -1
  9. package/dist/main/lib/helpers.d.ts.map +1 -1
  10. package/dist/main/lib/helpers.js.map +1 -1
  11. package/dist/main/lib/types.d.ts +140 -19
  12. package/dist/main/lib/types.d.ts.map +1 -1
  13. package/dist/main/lib/types.js +3 -2
  14. package/dist/main/lib/types.js.map +1 -1
  15. package/dist/main/lib/version.d.ts +1 -1
  16. package/dist/main/lib/version.js +1 -1
  17. package/dist/main/lib/webauthn.d.ts +274 -0
  18. package/dist/main/lib/webauthn.d.ts.map +1 -0
  19. package/dist/main/lib/webauthn.dom.d.ts +583 -0
  20. package/dist/main/lib/webauthn.dom.d.ts.map +1 -0
  21. package/dist/main/lib/webauthn.dom.js +4 -0
  22. package/dist/main/lib/webauthn.dom.js.map +1 -0
  23. package/dist/main/lib/webauthn.errors.d.ts +80 -0
  24. package/dist/main/lib/webauthn.errors.d.ts.map +1 -0
  25. package/dist/main/lib/webauthn.errors.js +265 -0
  26. package/dist/main/lib/webauthn.errors.js.map +1 -0
  27. package/dist/main/lib/webauthn.js +702 -0
  28. package/dist/main/lib/webauthn.js.map +1 -0
  29. package/dist/module/GoTrueClient.d.ts +1 -1
  30. package/dist/module/GoTrueClient.d.ts.map +1 -1
  31. package/dist/module/GoTrueClient.js +49 -21
  32. package/dist/module/GoTrueClient.js.map +1 -1
  33. package/dist/module/lib/base64url.d.ts +3 -2
  34. package/dist/module/lib/base64url.d.ts.map +1 -1
  35. package/dist/module/lib/base64url.js.map +1 -1
  36. package/dist/module/lib/helpers.d.ts +2 -1
  37. package/dist/module/lib/helpers.d.ts.map +1 -1
  38. package/dist/module/lib/helpers.js.map +1 -1
  39. package/dist/module/lib/types.d.ts +140 -19
  40. package/dist/module/lib/types.d.ts.map +1 -1
  41. package/dist/module/lib/types.js +2 -1
  42. package/dist/module/lib/types.js.map +1 -1
  43. package/dist/module/lib/version.d.ts +1 -1
  44. package/dist/module/lib/version.js +1 -1
  45. package/dist/module/lib/webauthn.d.ts +274 -0
  46. package/dist/module/lib/webauthn.d.ts.map +1 -0
  47. package/dist/module/lib/webauthn.dom.d.ts +583 -0
  48. package/dist/module/lib/webauthn.dom.d.ts.map +1 -0
  49. package/dist/module/lib/webauthn.dom.js +3 -0
  50. package/dist/module/lib/webauthn.dom.js.map +1 -0
  51. package/dist/module/lib/webauthn.errors.d.ts +80 -0
  52. package/dist/module/lib/webauthn.errors.d.ts.map +1 -0
  53. package/dist/module/lib/webauthn.errors.js +257 -0
  54. package/dist/module/lib/webauthn.errors.js.map +1 -0
  55. package/dist/module/lib/webauthn.js +685 -0
  56. package/dist/module/lib/webauthn.js.map +1 -0
  57. package/package.json +1 -1
  58. package/src/GoTrueClient.ts +198 -68
  59. package/src/lib/base64url.ts +4 -2
  60. package/src/lib/helpers.ts +2 -1
  61. package/src/lib/types.ts +205 -26
  62. package/src/lib/version.ts +1 -1
  63. package/src/lib/webauthn.dom.ts +636 -0
  64. package/src/lib/webauthn.errors.ts +317 -0
  65. package/src/lib/webauthn.ts +929 -0
@@ -0,0 +1,636 @@
1
+ // from https://github.com/MasterKale/SimpleWebAuthn/blob/master/packages/browser/src/types/index.ts
2
+
3
+ import { StrictOmit } from './types'
4
+
5
+ /**
6
+ * A variant of PublicKeyCredentialCreationOptions suitable for JSON transmission to the browser to
7
+ * (eventually) get passed into navigator.credentials.create(...) in the browser.
8
+ *
9
+ * This should eventually get replaced with official TypeScript DOM types when WebAuthn Level 3 types
10
+ * eventually make it into the language:
11
+ *
12
+ * @see {@link https://w3c.github.io/webauthn/#dictdef-publickeycredentialcreationoptionsjson W3C WebAuthn Spec - PublicKeyCredentialCreationOptionsJSON}
13
+ */
14
+ export interface PublicKeyCredentialCreationOptionsJSON {
15
+ /**
16
+ * Information about the Relying Party responsible for the request.
17
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialcreationoptions-rp W3C - rp}
18
+ */
19
+ rp: PublicKeyCredentialRpEntity
20
+ /**
21
+ * Information about the user account for which the credential is being created.
22
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialcreationoptions-user W3C - user}
23
+ */
24
+ user: PublicKeyCredentialUserEntityJSON
25
+ /**
26
+ * A server-generated challenge in base64url format.
27
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialcreationoptions-challenge W3C - challenge}
28
+ */
29
+ challenge: Base64URLString
30
+ /**
31
+ * Information about desired properties of the credential to be created.
32
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialcreationoptions-pubkeycredparams W3C - pubKeyCredParams}
33
+ */
34
+ pubKeyCredParams: PublicKeyCredentialParameters[]
35
+ /**
36
+ * Time in milliseconds that the caller is willing to wait for the operation to complete.
37
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialcreationoptions-timeout W3C - timeout}
38
+ */
39
+ timeout?: number
40
+ /**
41
+ * Credentials that the authenticator should not create a new credential for.
42
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialcreationoptions-excludecredentials W3C - excludeCredentials}
43
+ */
44
+ excludeCredentials?: PublicKeyCredentialDescriptorJSON[]
45
+ /**
46
+ * Criteria for authenticator selection.
47
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialcreationoptions-authenticatorselection W3C - authenticatorSelection}
48
+ */
49
+ authenticatorSelection?: AuthenticatorSelectionCriteria
50
+ /**
51
+ * Hints about what types of authenticators the user might want to use.
52
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialcreationoptions-hints W3C - hints}
53
+ */
54
+ hints?: PublicKeyCredentialHint[]
55
+ /**
56
+ * How the attestation statement should be transported.
57
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialcreationoptions-attestation W3C - attestation}
58
+ */
59
+ attestation?: AttestationConveyancePreference
60
+ /**
61
+ * The attestation statement formats that the Relying Party will accept.
62
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialcreationoptions-attestationformats W3C - attestationFormats}
63
+ */
64
+ attestationFormats?: AttestationFormat[]
65
+ /**
66
+ * Additional parameters requesting additional processing by the client and authenticator.
67
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialcreationoptions-extensions W3C - extensions}
68
+ */
69
+ extensions?: AuthenticationExtensionsClientInputs
70
+ }
71
+
72
+ /**
73
+ * A variant of PublicKeyCredentialRequestOptions suitable for JSON transmission to the browser to
74
+ * (eventually) get passed into navigator.credentials.get(...) in the browser.
75
+ *
76
+ * @see {@link https://w3c.github.io/webauthn/#dictdef-publickeycredentialrequestoptionsjson W3C WebAuthn Spec - PublicKeyCredentialRequestOptionsJSON}
77
+ */
78
+ export interface PublicKeyCredentialRequestOptionsJSON {
79
+ /**
80
+ * A server-generated challenge in base64url format.
81
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialrequestoptions-challenge W3C - challenge}
82
+ */
83
+ challenge: Base64URLString
84
+ /**
85
+ * Time in milliseconds that the caller is willing to wait for the operation to complete.
86
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialrequestoptions-timeout W3C - timeout}
87
+ */
88
+ timeout?: number
89
+ /**
90
+ * The relying party identifier claimed by the caller.
91
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialrequestoptions-rpid W3C - rpId}
92
+ */
93
+ rpId?: string
94
+ /**
95
+ * A list of credentials acceptable for authentication.
96
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialrequestoptions-allowcredentials W3C - allowCredentials}
97
+ */
98
+ allowCredentials?: PublicKeyCredentialDescriptorJSON[]
99
+ /**
100
+ * Whether user verification should be performed by the authenticator.
101
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialrequestoptions-userverification W3C - userVerification}
102
+ */
103
+ userVerification?: UserVerificationRequirement
104
+ /**
105
+ * Hints about what types of authenticators the user might want to use.
106
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialrequestoptions-hints W3C - hints}
107
+ */
108
+ hints?: PublicKeyCredentialHint[]
109
+ /**
110
+ * Additional parameters requesting additional processing by the client and authenticator.
111
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialrequestoptions-extensions W3C - extensions}
112
+ */
113
+ extensions?: AuthenticationExtensionsClientInputs
114
+ }
115
+
116
+ /**
117
+ * Represents a public key credential descriptor in JSON format.
118
+ * Used to identify credentials for exclusion or allowance during WebAuthn ceremonies.
119
+ *
120
+ * @see {@link https://w3c.github.io/webauthn/#dictdef-publickeycredentialdescriptorjson W3C WebAuthn Spec - PublicKeyCredentialDescriptorJSON}
121
+ */
122
+ export interface PublicKeyCredentialDescriptorJSON {
123
+ /**
124
+ * The credential ID in base64url format.
125
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialdescriptor-id W3C - id}
126
+ */
127
+ id: Base64URLString
128
+ /**
129
+ * The type of the public key credential (always "public-key").
130
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialdescriptor-type W3C - type}
131
+ */
132
+ type: PublicKeyCredentialType
133
+ /**
134
+ * How the authenticator communicates with clients.
135
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialdescriptor-transports W3C - transports}
136
+ */
137
+ transports?: AuthenticatorTransportFuture[]
138
+ }
139
+
140
+ /**
141
+ * Represents user account information in JSON format for WebAuthn registration.
142
+ * Contains identifiers and display information for the user being registered.
143
+ *
144
+ * @see {@link https://w3c.github.io/webauthn/#dictdef-publickeycredentialuserentityjson W3C WebAuthn Spec - PublicKeyCredentialUserEntityJSON}
145
+ */
146
+ export interface PublicKeyCredentialUserEntityJSON {
147
+ /**
148
+ * A unique identifier for the user account (base64url encoded).
149
+ * Maximum 64 bytes. Should not contain PII.
150
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialuserentity-id W3C - user.id}
151
+ */
152
+ id: string
153
+ /**
154
+ * A human-readable identifier for the account (e.g., email, username).
155
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialentity-name W3C - user.name}
156
+ */
157
+ name: string
158
+ /**
159
+ * A human-friendly display name for the user (e.g., "John Doe").
160
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialuserentity-displayname W3C - user.displayName}
161
+ */
162
+ displayName: string
163
+ }
164
+
165
+ /**
166
+ * Represents user account information for WebAuthn registration with binary data.
167
+ * Contains identifiers and display information for the user being registered.
168
+ *
169
+ * @see {@link https://w3c.github.io/webauthn/#dictdef-publickeycredentialuserentity W3C WebAuthn Spec - PublicKeyCredentialUserEntity}
170
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialUserEntity MDN - PublicKeyCredentialUserEntity}
171
+ */
172
+ export interface PublicKeyCredentialUserEntity {
173
+ /**
174
+ * A unique identifier for the user account.
175
+ * Maximum 64 bytes. Should not contain PII.
176
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialuserentity-id W3C - user.id}
177
+ */
178
+ id: BufferSource // ArrayBuffer | TypedArray | DataView
179
+
180
+ /**
181
+ * A human-readable identifier for the account.
182
+ * Typically an email, username, or phone number.
183
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialentity-name W3C - user.name}
184
+ */
185
+ name: string
186
+
187
+ /**
188
+ * A human-friendly display name for the user.
189
+ * Example: "John Doe"
190
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialuserentity-displayname W3C - user.displayName}
191
+ */
192
+ displayName: string
193
+ }
194
+
195
+ /**
196
+ * The credential returned from navigator.credentials.create() during WebAuthn registration.
197
+ * Contains the new credential's public key and attestation information.
198
+ *
199
+ * @see {@link https://w3c.github.io/webauthn/#registrationceremony W3C WebAuthn Spec - Registration}
200
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredential MDN - PublicKeyCredential}
201
+ */
202
+ export interface RegistrationCredential
203
+ extends PublicKeyCredentialFuture<RegistrationResponseJSON> {
204
+ response: AuthenticatorAttestationResponseFuture
205
+ }
206
+
207
+ /**
208
+ * A slightly-modified RegistrationCredential to simplify working with ArrayBuffers that
209
+ * are Base64URL-encoded in the browser so that they can be sent as JSON to the server.
210
+ *
211
+ * @see {@link https://w3c.github.io/webauthn/#dictdef-registrationresponsejson W3C WebAuthn Spec - RegistrationResponseJSON}
212
+ */
213
+ export interface RegistrationResponseJSON {
214
+ /**
215
+ * The credential ID (same as rawId for JSON).
216
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredential-id W3C - id}
217
+ */
218
+ id: Base64URLString
219
+ /**
220
+ * The raw credential ID in base64url format.
221
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredential-rawid W3C - rawId}
222
+ */
223
+ rawId: Base64URLString
224
+ /**
225
+ * The authenticator's response to the client's request to create a credential.
226
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredential-response W3C - response}
227
+ */
228
+ response: AuthenticatorAttestationResponseJSON
229
+ /**
230
+ * The authenticator attachment modality in effect at the time of credential creation.
231
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredential-authenticatorattachment W3C - authenticatorAttachment}
232
+ */
233
+ authenticatorAttachment?: AuthenticatorAttachment
234
+ /**
235
+ * The results of processing client extensions.
236
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredential-getclientextensionresults W3C - getClientExtensionResults}
237
+ */
238
+ clientExtensionResults: AuthenticationExtensionsClientOutputs
239
+ /**
240
+ * The type of the credential (always "public-key").
241
+ * @see {@link https://w3c.github.io/webauthn/#dom-credential-type W3C - type}
242
+ */
243
+ type: PublicKeyCredentialType
244
+ }
245
+
246
+ /**
247
+ * The credential returned from navigator.credentials.get() during WebAuthn authentication.
248
+ * Contains the assertion signature proving possession of the private key.
249
+ *
250
+ * @see {@link https://w3c.github.io/webauthn/#authentication W3C WebAuthn Spec - Authentication}
251
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredential MDN - PublicKeyCredential}
252
+ */
253
+ export interface AuthenticationCredential
254
+ extends PublicKeyCredentialFuture<AuthenticationResponseJSON> {
255
+ response: AuthenticatorAssertionResponse
256
+ }
257
+
258
+ /**
259
+ * A slightly-modified AuthenticationCredential to simplify working with ArrayBuffers that
260
+ * are Base64URL-encoded in the browser so that they can be sent as JSON to the server.
261
+ *
262
+ * @see {@link https://w3c.github.io/webauthn/#dictdef-authenticationresponsejson W3C WebAuthn Spec - AuthenticationResponseJSON}
263
+ */
264
+ export interface AuthenticationResponseJSON {
265
+ /**
266
+ * The credential ID (same as rawId for JSON).
267
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredential-id W3C - id}
268
+ */
269
+ id: Base64URLString
270
+ /**
271
+ * The raw credential ID in base64url format.
272
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredential-rawid W3C - rawId}
273
+ */
274
+ rawId: Base64URLString
275
+ /**
276
+ * The authenticator's response to the client's request to authenticate.
277
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredential-response W3C - response}
278
+ */
279
+ response: AuthenticatorAssertionResponseJSON
280
+ /**
281
+ * The authenticator attachment modality in effect at the time of authentication.
282
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredential-authenticatorattachment W3C - authenticatorAttachment}
283
+ */
284
+ authenticatorAttachment?: AuthenticatorAttachment
285
+ /**
286
+ * The results of processing client extensions.
287
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredential-getclientextensionresults W3C - getClientExtensionResults}
288
+ */
289
+ clientExtensionResults: AuthenticationExtensionsClientOutputs
290
+ /**
291
+ * The type of the credential (always "public-key").
292
+ * @see {@link https://w3c.github.io/webauthn/#dom-credential-type W3C - type}
293
+ */
294
+ type: PublicKeyCredentialType
295
+ }
296
+
297
+ /**
298
+ * A slightly-modified AuthenticatorAttestationResponse to simplify working with ArrayBuffers that
299
+ * are Base64URL-encoded in the browser so that they can be sent as JSON to the server.
300
+ *
301
+ * @see {@link https://w3c.github.io/webauthn/#dictdef-authenticatorattestationresponsejson W3C WebAuthn Spec - AuthenticatorAttestationResponseJSON}
302
+ */
303
+ export interface AuthenticatorAttestationResponseJSON {
304
+ /**
305
+ * JSON-serialized client data passed to the authenticator.
306
+ * @see {@link https://w3c.github.io/webauthn/#dom-authenticatorresponse-clientdatajson W3C - clientDataJSON}
307
+ */
308
+ clientDataJSON: Base64URLString
309
+ /**
310
+ * The attestation object in base64url format.
311
+ * @see {@link https://w3c.github.io/webauthn/#dom-authenticatorattestationresponse-attestationobject W3C - attestationObject}
312
+ */
313
+ attestationObject: Base64URLString
314
+ /**
315
+ * The authenticator data contained within the attestation object.
316
+ * Optional in L2, but becomes required in L3. Play it safe until L3 becomes Recommendation
317
+ * @see {@link https://w3c.github.io/webauthn/#dom-authenticatorattestationresponse-getauthenticatordata W3C - getAuthenticatorData}
318
+ */
319
+ authenticatorData?: Base64URLString
320
+ /**
321
+ * The transports that the authenticator supports.
322
+ * Optional in L2, but becomes required in L3. Play it safe until L3 becomes Recommendation
323
+ * @see {@link https://w3c.github.io/webauthn/#dom-authenticatorattestationresponse-gettransports W3C - getTransports}
324
+ */
325
+ transports?: AuthenticatorTransportFuture[]
326
+ /**
327
+ * The COSEAlgorithmIdentifier for the public key.
328
+ * Optional in L2, but becomes required in L3. Play it safe until L3 becomes Recommendation
329
+ * @see {@link https://w3c.github.io/webauthn/#dom-authenticatorattestationresponse-getpublickeyalgorithm W3C - getPublicKeyAlgorithm}
330
+ */
331
+ publicKeyAlgorithm?: COSEAlgorithmIdentifier
332
+ /**
333
+ * The public key in base64url format.
334
+ * @see {@link https://w3c.github.io/webauthn/#dom-authenticatorattestationresponse-getpublickey W3C - getPublicKey}
335
+ */
336
+ publicKey?: Base64URLString
337
+ }
338
+
339
+ /**
340
+ * A slightly-modified AuthenticatorAssertionResponse to simplify working with ArrayBuffers that
341
+ * are Base64URL-encoded in the browser so that they can be sent as JSON to the server.
342
+ *
343
+ * @see {@link https://w3c.github.io/webauthn/#dictdef-authenticatorassertionresponsejson W3C WebAuthn Spec - AuthenticatorAssertionResponseJSON}
344
+ */
345
+ export interface AuthenticatorAssertionResponseJSON {
346
+ /**
347
+ * JSON-serialized client data passed to the authenticator.
348
+ * @see {@link https://w3c.github.io/webauthn/#dom-authenticatorresponse-clientdatajson W3C - clientDataJSON}
349
+ */
350
+ clientDataJSON: Base64URLString
351
+ /**
352
+ * The authenticator data returned by the authenticator.
353
+ * @see {@link https://w3c.github.io/webauthn/#dom-authenticatorassertionresponse-authenticatordata W3C - authenticatorData}
354
+ */
355
+ authenticatorData: Base64URLString
356
+ /**
357
+ * The signature generated by the authenticator.
358
+ * @see {@link https://w3c.github.io/webauthn/#dom-authenticatorassertionresponse-signature W3C - signature}
359
+ */
360
+ signature: Base64URLString
361
+ /**
362
+ * The user handle returned by the authenticator, if any.
363
+ * @see {@link https://w3c.github.io/webauthn/#dom-authenticatorassertionresponse-userhandle W3C - userHandle}
364
+ */
365
+ userHandle?: Base64URLString
366
+ }
367
+
368
+ /**
369
+ * Public key credential information needed to verify authentication responses.
370
+ * Stores the credential's public key and metadata for server-side verification.
371
+ *
372
+ * @see {@link https://w3c.github.io/webauthn/#sctn-credential-storage-modality W3C WebAuthn Spec - Credential Storage}
373
+ */
374
+ export type WebAuthnCredential = {
375
+ /**
376
+ * The credential ID in base64url format.
377
+ * @see {@link https://w3c.github.io/webauthn/#credential-id W3C - Credential ID}
378
+ */
379
+ id: Base64URLString
380
+ /**
381
+ * The credential's public key.
382
+ * @see {@link https://w3c.github.io/webauthn/#credential-public-key W3C - Credential Public Key}
383
+ */
384
+ publicKey: Uint8Array_
385
+ /**
386
+ * Number of times this authenticator is expected to have been used.
387
+ * @see {@link https://w3c.github.io/webauthn/#signature-counter W3C - Signature Counter}
388
+ */
389
+ counter: number
390
+ /**
391
+ * The transports that the authenticator supports.
392
+ * From browser's `startRegistration()` -> RegistrationCredentialJSON.transports (API L2 and up)
393
+ * @see {@link https://w3c.github.io/webauthn/#dom-authenticatorattestationresponse-gettransports W3C - getTransports}
394
+ */
395
+ transports?: AuthenticatorTransportFuture[]
396
+ }
397
+
398
+ /**
399
+ * An attempt to communicate that this isn't just any string, but a Base64URL-encoded string.
400
+ * Base64URL encoding is used throughout WebAuthn for binary data transmission.
401
+ *
402
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc4648#section-5 RFC 4648 - Base64URL Encoding}
403
+ */
404
+ export type Base64URLString = string
405
+
406
+ /**
407
+ * AuthenticatorAttestationResponse in TypeScript's DOM lib is outdated (up through v3.9.7).
408
+ * Maintain an augmented version here so we can implement additional properties as the WebAuthn
409
+ * spec evolves.
410
+ *
411
+ * Properties marked optional are not supported in all browsers.
412
+ *
413
+ * @see {@link https://www.w3.org/TR/webauthn-2/#iface-authenticatorattestationresponse W3C WebAuthn Spec - AuthenticatorAttestationResponse}
414
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/AuthenticatorAttestationResponse MDN - AuthenticatorAttestationResponse}
415
+ */
416
+ export interface AuthenticatorAttestationResponseFuture extends AuthenticatorAttestationResponse {
417
+ /**
418
+ * Returns the transports that the authenticator supports.
419
+ * @see {@link https://w3c.github.io/webauthn/#dom-authenticatorattestationresponse-gettransports W3C - getTransports}
420
+ */
421
+ getTransports(): AuthenticatorTransportFuture[]
422
+ }
423
+
424
+ /**
425
+ * A super class of TypeScript's `AuthenticatorTransport` that includes support for the latest
426
+ * transports. Should eventually be replaced by TypeScript's when TypeScript gets updated to
427
+ * know about it (sometime after 4.6.3)
428
+ *
429
+ * @see {@link https://w3c.github.io/webauthn/#enum-transport W3C WebAuthn Spec - AuthenticatorTransport}
430
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/AuthenticatorAttestationResponse/getTransports MDN - getTransports}
431
+ */
432
+ export type AuthenticatorTransportFuture =
433
+ | 'ble'
434
+ | 'cable'
435
+ | 'hybrid'
436
+ | 'internal'
437
+ | 'nfc'
438
+ | 'smart-card'
439
+ | 'usb'
440
+
441
+ /**
442
+ * A super class of TypeScript's `PublicKeyCredentialDescriptor` that knows about the latest
443
+ * transports. Should eventually be replaced by TypeScript's when TypeScript gets updated to
444
+ * know about it (sometime after 4.6.3)
445
+ *
446
+ * @see {@link https://w3c.github.io/webauthn/#dictdef-publickeycredentialdescriptor W3C WebAuthn Spec - PublicKeyCredentialDescriptor}
447
+ */
448
+ export interface PublicKeyCredentialDescriptorFuture
449
+ extends Omit<PublicKeyCredentialDescriptor, 'transports'> {
450
+ /**
451
+ * How the authenticator communicates with clients.
452
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialdescriptor-transports W3C - transports}
453
+ */
454
+ transports?: AuthenticatorTransportFuture[]
455
+ }
456
+
457
+ /**
458
+ * Enhanced PublicKeyCredentialCreationOptions that knows about the latest features.
459
+ * Used for WebAuthn registration ceremonies.
460
+ *
461
+ * @see {@link https://w3c.github.io/webauthn/#dictdef-publickeycredentialcreationoptions W3C WebAuthn Spec - PublicKeyCredentialCreationOptions}
462
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions MDN - PublicKeyCredentialCreationOptions}
463
+ */
464
+ export interface PublicKeyCredentialCreationOptionsFuture
465
+ extends StrictOmit<PublicKeyCredentialCreationOptions, 'excludeCredentials' | 'user'> {
466
+ /**
467
+ * Credentials that the authenticator should not create a new credential for.
468
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialcreationoptions-excludecredentials W3C - excludeCredentials}
469
+ */
470
+ excludeCredentials?: PublicKeyCredentialDescriptorFuture[]
471
+ /**
472
+ * Information about the user account for which the credential is being created.
473
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialcreationoptions-user W3C - user}
474
+ */
475
+ user: PublicKeyCredentialUserEntity
476
+ /**
477
+ * Hints about what types of authenticators the user might want to use.
478
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialcreationoptions-hints W3C - hints}
479
+ */
480
+ hints?: PublicKeyCredentialHint[]
481
+ /**
482
+ * Criteria for authenticator selection.
483
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialcreationoptions-authenticatorselection W3C - authenticatorSelection}
484
+ */
485
+ authenticatorSelection?: AuthenticatorSelectionCriteria
486
+ /**
487
+ * Information about desired properties of the credential to be created.
488
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialcreationoptions-pubkeycredparams W3C - pubKeyCredParams}
489
+ */
490
+ pubKeyCredParams: PublicKeyCredentialParameters[]
491
+ /**
492
+ * Information about the Relying Party responsible for the request.
493
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialcreationoptions-rp W3C - rp}
494
+ */
495
+ rp: PublicKeyCredentialRpEntity
496
+ }
497
+
498
+ /**
499
+ * Enhanced PublicKeyCredentialRequestOptions that knows about the latest features.
500
+ * Used for WebAuthn authentication ceremonies.
501
+ *
502
+ * @see {@link https://w3c.github.io/webauthn/#dictdef-publickeycredentialrequestoptions W3C WebAuthn Spec - PublicKeyCredentialRequestOptions}
503
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialRequestOptions MDN - PublicKeyCredentialRequestOptions}
504
+ */
505
+ export interface PublicKeyCredentialRequestOptionsFuture
506
+ extends StrictOmit<PublicKeyCredentialRequestOptions, 'allowCredentials'> {
507
+ /**
508
+ * A list of credentials acceptable for authentication.
509
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialrequestoptions-allowcredentials W3C - allowCredentials}
510
+ */
511
+ allowCredentials?: PublicKeyCredentialDescriptorFuture[]
512
+ /**
513
+ * Hints about what types of authenticators the user might want to use.
514
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialrequestoptions-hints W3C - hints}
515
+ */
516
+ hints?: PublicKeyCredentialHint[]
517
+ /**
518
+ * The attestation conveyance preference for the authentication ceremony.
519
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredentialcreationoptions-attestation W3C - attestation}
520
+ */
521
+ attestation?: AttestationConveyancePreference
522
+ }
523
+
524
+ /**
525
+ * Union type for all WebAuthn credential responses in JSON format.
526
+ * Can be either a registration response (for new credentials) or authentication response (for existing credentials).
527
+ */
528
+ export type PublicKeyCredentialJSON = RegistrationResponseJSON | AuthenticationResponseJSON
529
+
530
+ /**
531
+ * A super class of TypeScript's `PublicKeyCredential` that knows about upcoming WebAuthn features.
532
+ * Includes WebAuthn Level 3 methods for JSON serialization and parsing.
533
+ *
534
+ * @see {@link https://w3c.github.io/webauthn/#publickeycredential W3C WebAuthn Spec - PublicKeyCredential}
535
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredential MDN - PublicKeyCredential}
536
+ */
537
+ export interface PublicKeyCredentialFuture<
538
+ T extends PublicKeyCredentialJSON = PublicKeyCredentialJSON
539
+ > extends PublicKeyCredential {
540
+ /**
541
+ * The type of the credential (always "public-key").
542
+ * @see {@link https://w3c.github.io/webauthn/#dom-credential-type W3C - type}
543
+ */
544
+ type: PublicKeyCredentialType
545
+ /**
546
+ * Checks if conditional mediation is available.
547
+ * @see {@link https://github.com/w3c/webauthn/issues/1745 GitHub - Conditional Mediation}
548
+ */
549
+ isConditionalMediationAvailable?(): Promise<boolean>
550
+ /**
551
+ * Parses JSON to create PublicKeyCredentialCreationOptions.
552
+ * @see {@link https://w3c.github.io/webauthn/#sctn-parseCreationOptionsFromJSON W3C - parseCreationOptionsFromJSON}
553
+ */
554
+ parseCreationOptionsFromJSON(
555
+ options: PublicKeyCredentialCreationOptionsJSON
556
+ ): PublicKeyCredentialCreationOptionsFuture
557
+ /**
558
+ * Parses JSON to create PublicKeyCredentialRequestOptions.
559
+ * @see {@link https://w3c.github.io/webauthn/#sctn-parseRequestOptionsFromJSON W3C - parseRequestOptionsFromJSON}
560
+ */
561
+ parseRequestOptionsFromJSON(
562
+ options: PublicKeyCredentialRequestOptionsJSON
563
+ ): PublicKeyCredentialRequestOptionsFuture
564
+ /**
565
+ * Serializes the credential to JSON format.
566
+ * @see {@link https://w3c.github.io/webauthn/#dom-publickeycredential-tojson W3C - toJSON}
567
+ */
568
+ toJSON(): T
569
+ }
570
+
571
+ /**
572
+ * The two types of credentials as defined by bit 3 ("Backup Eligibility") in authenticator data:
573
+ * - `"singleDevice"` credentials will never be backed up
574
+ * - `"multiDevice"` credentials can be backed up
575
+ *
576
+ * @see {@link https://w3c.github.io/webauthn/#sctn-authenticator-data W3C WebAuthn Spec - Authenticator Data}
577
+ */
578
+ export type CredentialDeviceType = 'singleDevice' | 'multiDevice'
579
+
580
+ /**
581
+ * Categories of authenticators that Relying Parties can pass along to browsers during
582
+ * registration. Browsers that understand these values can optimize their modal experience to
583
+ * start the user off in a particular registration flow:
584
+ *
585
+ * - `hybrid`: A platform authenticator on a mobile device
586
+ * - `security-key`: A portable FIDO2 authenticator capable of being used on multiple devices via a USB or NFC connection
587
+ * - `client-device`: The device that WebAuthn is being called on. Typically synonymous with platform authenticators
588
+ *
589
+ * These values are less strict than `authenticatorAttachment`
590
+ *
591
+ * @see {@link https://w3c.github.io/webauthn/#enumdef-publickeycredentialhint W3C WebAuthn Spec - PublicKeyCredentialHint}
592
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#hints MDN - hints}
593
+ */
594
+ export type PublicKeyCredentialHint = 'hybrid' | 'security-key' | 'client-device'
595
+
596
+ /**
597
+ * Values for an attestation object's `fmt`.
598
+ * Defines the format of the attestation statement from the authenticator.
599
+ *
600
+ * @see {@link https://www.iana.org/assignments/webauthn/webauthn.xhtml#webauthn-attestation-statement-format-ids IANA - WebAuthn Attestation Statement Format Identifiers}
601
+ * @see {@link https://w3c.github.io/webauthn/#sctn-attestation-formats W3C WebAuthn Spec - Attestation Statement Formats}
602
+ */
603
+ export type AttestationFormat =
604
+ | 'fido-u2f'
605
+ | 'packed'
606
+ | 'android-safetynet'
607
+ | 'android-key'
608
+ | 'tpm'
609
+ | 'apple'
610
+ | 'none'
611
+
612
+ /**
613
+ * Equivalent to `Uint8Array` before TypeScript 5.7, and `Uint8Array<ArrayBuffer>` in TypeScript 5.7
614
+ * and beyond.
615
+ *
616
+ * **Context**
617
+ *
618
+ * `Uint8Array` became a generic type in TypeScript 5.7, requiring types defined simply as
619
+ * `Uint8Array` to be refactored to `Uint8Array<ArrayBuffer>` starting in Deno 2.2. `Uint8Array` is
620
+ * _not_ generic in Deno 2.1.x and earlier, though, so this type helps bridge this gap.
621
+ *
622
+ * Inspired by Deno's std library:
623
+ *
624
+ * https://github.com/denoland/std/blob/b5a5fe4f96b91c1fe8dba5cc0270092dd11d3287/bytes/_types.ts#L11
625
+ */
626
+ export type Uint8Array_ = ReturnType<Uint8Array['slice']>
627
+
628
+ /**
629
+ * Specifies the preferred authenticator attachment modality.
630
+ * - `platform`: A platform authenticator attached to the client device (e.g., Touch ID, Windows Hello)
631
+ * - `cross-platform`: A roaming authenticator not attached to the client device (e.g., USB security key)
632
+ *
633
+ * @see {@link https://w3c.github.io/webauthn/#enum-attachment W3C WebAuthn Spec - AuthenticatorAttachment}
634
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions/authenticatorSelection#authenticatorattachment MDN - authenticatorAttachment}
635
+ */
636
+ export type AuthenticatorAttachment = 'cross-platform' | 'platform'