@better-auth/passkey 1.5.6 → 1.6.0-beta.0

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.
@@ -1,727 +0,0 @@
1
- import * as _simplewebauthn_server0 from "@simplewebauthn/server";
2
- import { CredentialDeviceType } from "@simplewebauthn/server";
3
- import * as zod from "zod";
4
- import * as better_auth0 from "better-auth";
5
- import { InferOptionSchema } from "better-auth/types";
6
- import * as better_call0 from "better-call";
7
-
8
- //#region src/schema.d.ts
9
- declare const schema: {
10
- passkey: {
11
- fields: {
12
- name: {
13
- type: "string";
14
- required: false;
15
- };
16
- publicKey: {
17
- type: "string";
18
- required: true;
19
- };
20
- userId: {
21
- type: "string";
22
- references: {
23
- model: string;
24
- field: string;
25
- };
26
- required: true;
27
- index: true;
28
- };
29
- credentialID: {
30
- type: "string";
31
- required: true;
32
- index: true;
33
- };
34
- counter: {
35
- type: "number";
36
- required: true;
37
- };
38
- deviceType: {
39
- type: "string";
40
- required: true;
41
- };
42
- backedUp: {
43
- type: "boolean";
44
- required: true;
45
- };
46
- transports: {
47
- type: "string";
48
- required: false;
49
- };
50
- createdAt: {
51
- type: "date";
52
- required: false;
53
- };
54
- aaguid: {
55
- type: "string";
56
- required: false;
57
- };
58
- };
59
- };
60
- };
61
- //#endregion
62
- //#region src/types.d.ts
63
- /**
64
- * @internal
65
- */
66
- interface WebAuthnChallengeValue {
67
- expectedChallenge: string;
68
- userData: {
69
- id: string;
70
- };
71
- }
72
- interface PasskeyOptions {
73
- /**
74
- * A unique identifier for your website. 'localhost' is okay for
75
- * local dev
76
- *
77
- * @default "localhost"
78
- */
79
- rpID?: string | undefined;
80
- /**
81
- * Human-readable title for your website
82
- *
83
- * @default "Better Auth"
84
- */
85
- rpName?: string | undefined;
86
- /**
87
- * The URL at which registrations and authentications should occur.
88
- * `http://localhost` and `http://localhost:PORT` are also valid.
89
- * Do NOT include any trailing /
90
- *
91
- * if this isn't provided. The client itself will
92
- * pass this value.
93
- */
94
- origin?: (string | string[] | null) | undefined;
95
- /**
96
- * Allow customization of the authenticatorSelection options
97
- * during passkey registration.
98
- */
99
- authenticatorSelection?: AuthenticatorSelectionCriteria | undefined;
100
- /**
101
- * Advanced options
102
- */
103
- advanced?: {
104
- /**
105
- * Cookie name for storing WebAuthn challenge ID during authentication flow
106
- *
107
- * @default "better-auth-passkey"
108
- */
109
- webAuthnChallengeCookie?: string;
110
- } | undefined;
111
- /**
112
- * Schema for the passkey model
113
- */
114
- schema?: InferOptionSchema<typeof schema> | undefined;
115
- }
116
- type Passkey = {
117
- id: string;
118
- name?: string | undefined;
119
- publicKey: string;
120
- userId: string;
121
- credentialID: string;
122
- counter: number;
123
- deviceType: CredentialDeviceType;
124
- backedUp: boolean;
125
- transports?: string | undefined;
126
- createdAt: Date;
127
- aaguid?: string | undefined;
128
- };
129
- //#endregion
130
- //#region src/error-codes.d.ts
131
- declare const PASSKEY_ERROR_CODES: {
132
- CHALLENGE_NOT_FOUND: better_auth0.RawError<"CHALLENGE_NOT_FOUND">;
133
- YOU_ARE_NOT_ALLOWED_TO_REGISTER_THIS_PASSKEY: better_auth0.RawError<"YOU_ARE_NOT_ALLOWED_TO_REGISTER_THIS_PASSKEY">;
134
- FAILED_TO_VERIFY_REGISTRATION: better_auth0.RawError<"FAILED_TO_VERIFY_REGISTRATION">;
135
- PASSKEY_NOT_FOUND: better_auth0.RawError<"PASSKEY_NOT_FOUND">;
136
- AUTHENTICATION_FAILED: better_auth0.RawError<"AUTHENTICATION_FAILED">;
137
- UNABLE_TO_CREATE_SESSION: better_auth0.RawError<"UNABLE_TO_CREATE_SESSION">;
138
- FAILED_TO_UPDATE_PASSKEY: better_auth0.RawError<"FAILED_TO_UPDATE_PASSKEY">;
139
- PREVIOUSLY_REGISTERED: better_auth0.RawError<"PREVIOUSLY_REGISTERED">;
140
- REGISTRATION_CANCELLED: better_auth0.RawError<"REGISTRATION_CANCELLED">;
141
- AUTH_CANCELLED: better_auth0.RawError<"AUTH_CANCELLED">;
142
- UNKNOWN_ERROR: better_auth0.RawError<"UNKNOWN_ERROR">;
143
- };
144
- //#endregion
145
- //#region src/index.d.ts
146
- declare module "@better-auth/core" {
147
- interface BetterAuthPluginRegistry<AuthOptions, Options> {
148
- passkey: {
149
- creator: typeof passkey;
150
- };
151
- }
152
- }
153
- declare const passkey: (options?: PasskeyOptions | undefined) => {
154
- id: "passkey";
155
- endpoints: {
156
- generatePasskeyRegistrationOptions: better_call0.StrictEndpoint<"/passkey/generate-register-options", {
157
- method: "GET";
158
- use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
159
- session: {
160
- session: Record<string, any> & {
161
- id: string;
162
- createdAt: Date;
163
- updatedAt: Date;
164
- userId: string;
165
- expiresAt: Date;
166
- token: string;
167
- ipAddress?: string | null | undefined;
168
- userAgent?: string | null | undefined;
169
- };
170
- user: Record<string, any> & {
171
- id: string;
172
- createdAt: Date;
173
- updatedAt: Date;
174
- email: string;
175
- emailVerified: boolean;
176
- name: string;
177
- image?: string | null | undefined;
178
- };
179
- };
180
- }>)[];
181
- query: zod.ZodOptional<zod.ZodObject<{
182
- authenticatorAttachment: zod.ZodOptional<zod.ZodEnum<{
183
- platform: "platform";
184
- "cross-platform": "cross-platform";
185
- }>>;
186
- name: zod.ZodOptional<zod.ZodString>;
187
- }, better_auth0.$strip>>;
188
- metadata: {
189
- openapi: {
190
- operationId: string;
191
- description: string;
192
- responses: {
193
- 200: {
194
- description: string;
195
- parameters: {
196
- query: {
197
- authenticatorAttachment: {
198
- description: string;
199
- required: boolean;
200
- };
201
- name: {
202
- description: string;
203
- required: boolean;
204
- };
205
- };
206
- };
207
- content: {
208
- "application/json": {
209
- schema: {
210
- type: "object";
211
- properties: {
212
- challenge: {
213
- type: string;
214
- };
215
- rp: {
216
- type: string;
217
- properties: {
218
- name: {
219
- type: string;
220
- };
221
- id: {
222
- type: string;
223
- };
224
- };
225
- };
226
- user: {
227
- type: string;
228
- properties: {
229
- id: {
230
- type: string;
231
- };
232
- name: {
233
- type: string;
234
- };
235
- displayName: {
236
- type: string;
237
- };
238
- };
239
- };
240
- pubKeyCredParams: {
241
- type: string;
242
- items: {
243
- type: string;
244
- properties: {
245
- type: {
246
- type: string;
247
- };
248
- alg: {
249
- type: string;
250
- };
251
- };
252
- };
253
- };
254
- timeout: {
255
- type: string;
256
- };
257
- excludeCredentials: {
258
- type: string;
259
- items: {
260
- type: string;
261
- properties: {
262
- id: {
263
- type: string;
264
- };
265
- type: {
266
- type: string;
267
- };
268
- transports: {
269
- type: string;
270
- items: {
271
- type: string;
272
- };
273
- };
274
- };
275
- };
276
- };
277
- authenticatorSelection: {
278
- type: string;
279
- properties: {
280
- authenticatorAttachment: {
281
- type: string;
282
- };
283
- requireResidentKey: {
284
- type: string;
285
- };
286
- userVerification: {
287
- type: string;
288
- };
289
- };
290
- };
291
- attestation: {
292
- type: string;
293
- };
294
- extensions: {
295
- type: string;
296
- };
297
- };
298
- };
299
- };
300
- };
301
- };
302
- };
303
- };
304
- };
305
- }, _simplewebauthn_server0.PublicKeyCredentialCreationOptionsJSON>;
306
- generatePasskeyAuthenticationOptions: better_call0.StrictEndpoint<"/passkey/generate-authenticate-options", {
307
- method: "GET";
308
- metadata: {
309
- openapi: {
310
- operationId: string;
311
- description: string;
312
- responses: {
313
- 200: {
314
- description: string;
315
- content: {
316
- "application/json": {
317
- schema: {
318
- type: "object";
319
- properties: {
320
- challenge: {
321
- type: string;
322
- };
323
- rp: {
324
- type: string;
325
- properties: {
326
- name: {
327
- type: string;
328
- };
329
- id: {
330
- type: string;
331
- };
332
- };
333
- };
334
- user: {
335
- type: string;
336
- properties: {
337
- id: {
338
- type: string;
339
- };
340
- name: {
341
- type: string;
342
- };
343
- displayName: {
344
- type: string;
345
- };
346
- };
347
- };
348
- timeout: {
349
- type: string;
350
- };
351
- allowCredentials: {
352
- type: string;
353
- items: {
354
- type: string;
355
- properties: {
356
- id: {
357
- type: string;
358
- };
359
- type: {
360
- type: string;
361
- };
362
- transports: {
363
- type: string;
364
- items: {
365
- type: string;
366
- };
367
- };
368
- };
369
- };
370
- };
371
- userVerification: {
372
- type: string;
373
- };
374
- authenticatorSelection: {
375
- type: string;
376
- properties: {
377
- authenticatorAttachment: {
378
- type: string;
379
- };
380
- requireResidentKey: {
381
- type: string;
382
- };
383
- userVerification: {
384
- type: string;
385
- };
386
- };
387
- };
388
- extensions: {
389
- type: string;
390
- };
391
- };
392
- };
393
- };
394
- };
395
- };
396
- };
397
- };
398
- };
399
- }, _simplewebauthn_server0.PublicKeyCredentialRequestOptionsJSON>;
400
- verifyPasskeyRegistration: better_call0.StrictEndpoint<"/passkey/verify-registration", {
401
- method: "POST";
402
- body: zod.ZodObject<{
403
- response: zod.ZodAny;
404
- name: zod.ZodOptional<zod.ZodString>;
405
- }, better_auth0.$strip>;
406
- use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
407
- session: {
408
- session: Record<string, any> & {
409
- id: string;
410
- createdAt: Date;
411
- updatedAt: Date;
412
- userId: string;
413
- expiresAt: Date;
414
- token: string;
415
- ipAddress?: string | null | undefined;
416
- userAgent?: string | null | undefined;
417
- };
418
- user: Record<string, any> & {
419
- id: string;
420
- createdAt: Date;
421
- updatedAt: Date;
422
- email: string;
423
- emailVerified: boolean;
424
- name: string;
425
- image?: string | null | undefined;
426
- };
427
- };
428
- }>)[];
429
- metadata: {
430
- openapi: {
431
- operationId: string;
432
- description: string;
433
- responses: {
434
- 200: {
435
- description: string;
436
- content: {
437
- "application/json": {
438
- schema: {
439
- $ref: string;
440
- };
441
- };
442
- };
443
- };
444
- 400: {
445
- description: string;
446
- };
447
- };
448
- };
449
- };
450
- }, Passkey>;
451
- verifyPasskeyAuthentication: better_call0.StrictEndpoint<"/passkey/verify-authentication", {
452
- method: "POST";
453
- body: zod.ZodObject<{
454
- response: zod.ZodRecord<zod.ZodAny, zod.ZodAny>;
455
- }, better_auth0.$strip>;
456
- metadata: {
457
- openapi: {
458
- operationId: string;
459
- description: string;
460
- responses: {
461
- 200: {
462
- description: string;
463
- content: {
464
- "application/json": {
465
- schema: {
466
- type: "object";
467
- properties: {
468
- session: {
469
- $ref: string;
470
- };
471
- user: {
472
- $ref: string;
473
- };
474
- };
475
- };
476
- };
477
- };
478
- };
479
- };
480
- };
481
- $Infer: {
482
- body: {
483
- response: _simplewebauthn_server0.AuthenticationResponseJSON;
484
- };
485
- };
486
- };
487
- }, {
488
- session: {
489
- id: string;
490
- createdAt: Date;
491
- updatedAt: Date;
492
- userId: string;
493
- expiresAt: Date;
494
- token: string;
495
- ipAddress?: string | null | undefined;
496
- userAgent?: string | null | undefined;
497
- };
498
- }>;
499
- listPasskeys: better_call0.StrictEndpoint<"/passkey/list-user-passkeys", {
500
- method: "GET";
501
- use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
502
- session: {
503
- session: Record<string, any> & {
504
- id: string;
505
- createdAt: Date;
506
- updatedAt: Date;
507
- userId: string;
508
- expiresAt: Date;
509
- token: string;
510
- ipAddress?: string | null | undefined;
511
- userAgent?: string | null | undefined;
512
- };
513
- user: Record<string, any> & {
514
- id: string;
515
- createdAt: Date;
516
- updatedAt: Date;
517
- email: string;
518
- emailVerified: boolean;
519
- name: string;
520
- image?: string | null | undefined;
521
- };
522
- };
523
- }>)[];
524
- metadata: {
525
- openapi: {
526
- description: string;
527
- responses: {
528
- "200": {
529
- description: string;
530
- content: {
531
- "application/json": {
532
- schema: {
533
- type: "array";
534
- items: {
535
- $ref: string;
536
- required: string[];
537
- };
538
- description: string;
539
- };
540
- };
541
- };
542
- };
543
- };
544
- };
545
- };
546
- }, Passkey[]>;
547
- deletePasskey: better_call0.StrictEndpoint<"/passkey/delete-passkey", {
548
- method: "POST";
549
- body: zod.ZodObject<{
550
- id: zod.ZodString;
551
- }, better_auth0.$strip>;
552
- use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
553
- session: {
554
- session: Record<string, any> & {
555
- id: string;
556
- createdAt: Date;
557
- updatedAt: Date;
558
- userId: string;
559
- expiresAt: Date;
560
- token: string;
561
- ipAddress?: string | null | undefined;
562
- userAgent?: string | null | undefined;
563
- };
564
- user: Record<string, any> & {
565
- id: string;
566
- createdAt: Date;
567
- updatedAt: Date;
568
- email: string;
569
- emailVerified: boolean;
570
- name: string;
571
- image?: string | null | undefined;
572
- };
573
- };
574
- }>)[];
575
- metadata: {
576
- openapi: {
577
- description: string;
578
- responses: {
579
- "200": {
580
- description: string;
581
- content: {
582
- "application/json": {
583
- schema: {
584
- type: "object";
585
- properties: {
586
- status: {
587
- type: string;
588
- description: string;
589
- };
590
- };
591
- required: string[];
592
- };
593
- };
594
- };
595
- };
596
- };
597
- };
598
- };
599
- }, {
600
- status: boolean;
601
- }>;
602
- updatePasskey: better_call0.StrictEndpoint<"/passkey/update-passkey", {
603
- method: "POST";
604
- body: zod.ZodObject<{
605
- id: zod.ZodString;
606
- name: zod.ZodString;
607
- }, better_auth0.$strip>;
608
- use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
609
- session: {
610
- session: Record<string, any> & {
611
- id: string;
612
- createdAt: Date;
613
- updatedAt: Date;
614
- userId: string;
615
- expiresAt: Date;
616
- token: string;
617
- ipAddress?: string | null | undefined;
618
- userAgent?: string | null | undefined;
619
- };
620
- user: Record<string, any> & {
621
- id: string;
622
- createdAt: Date;
623
- updatedAt: Date;
624
- email: string;
625
- emailVerified: boolean;
626
- name: string;
627
- image?: string | null | undefined;
628
- };
629
- };
630
- }>)[];
631
- metadata: {
632
- openapi: {
633
- description: string;
634
- responses: {
635
- "200": {
636
- description: string;
637
- content: {
638
- "application/json": {
639
- schema: {
640
- type: "object";
641
- properties: {
642
- passkey: {
643
- $ref: string;
644
- };
645
- };
646
- required: string[];
647
- };
648
- };
649
- };
650
- };
651
- };
652
- };
653
- };
654
- }, {
655
- passkey: Passkey;
656
- }>;
657
- };
658
- schema: {
659
- passkey: {
660
- fields: {
661
- name: {
662
- type: "string";
663
- required: false;
664
- };
665
- publicKey: {
666
- type: "string";
667
- required: true;
668
- };
669
- userId: {
670
- type: "string";
671
- references: {
672
- model: string;
673
- field: string;
674
- };
675
- required: true;
676
- index: true;
677
- };
678
- credentialID: {
679
- type: "string";
680
- required: true;
681
- index: true;
682
- };
683
- counter: {
684
- type: "number";
685
- required: true;
686
- };
687
- deviceType: {
688
- type: "string";
689
- required: true;
690
- };
691
- backedUp: {
692
- type: "boolean";
693
- required: true;
694
- };
695
- transports: {
696
- type: "string";
697
- required: false;
698
- };
699
- createdAt: {
700
- type: "date";
701
- required: false;
702
- };
703
- aaguid: {
704
- type: "string";
705
- required: false;
706
- };
707
- };
708
- };
709
- };
710
- $ERROR_CODES: {
711
- CHALLENGE_NOT_FOUND: better_auth0.RawError<"CHALLENGE_NOT_FOUND">;
712
- YOU_ARE_NOT_ALLOWED_TO_REGISTER_THIS_PASSKEY: better_auth0.RawError<"YOU_ARE_NOT_ALLOWED_TO_REGISTER_THIS_PASSKEY">;
713
- FAILED_TO_VERIFY_REGISTRATION: better_auth0.RawError<"FAILED_TO_VERIFY_REGISTRATION">;
714
- PASSKEY_NOT_FOUND: better_auth0.RawError<"PASSKEY_NOT_FOUND">;
715
- AUTHENTICATION_FAILED: better_auth0.RawError<"AUTHENTICATION_FAILED">;
716
- UNABLE_TO_CREATE_SESSION: better_auth0.RawError<"UNABLE_TO_CREATE_SESSION">;
717
- FAILED_TO_UPDATE_PASSKEY: better_auth0.RawError<"FAILED_TO_UPDATE_PASSKEY">;
718
- PREVIOUSLY_REGISTERED: better_auth0.RawError<"PREVIOUSLY_REGISTERED">;
719
- REGISTRATION_CANCELLED: better_auth0.RawError<"REGISTRATION_CANCELLED">;
720
- AUTH_CANCELLED: better_auth0.RawError<"AUTH_CANCELLED">;
721
- UNKNOWN_ERROR: better_auth0.RawError<"UNKNOWN_ERROR">;
722
- };
723
- options: PasskeyOptions | undefined;
724
- };
725
- //#endregion
726
- export { WebAuthnChallengeValue as a, PasskeyOptions as i, PASSKEY_ERROR_CODES as n, Passkey as r, passkey as t };
727
- //# sourceMappingURL=index-B6ZC0I-g.d.mts.map