@better-auth/passkey 1.5.0 → 1.5.1-beta.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.
package/dist/client.d.mts CHANGED
@@ -1,5 +1,4 @@
1
- import { n as PasskeyOptions, r as WebAuthnChallengeValue, t as Passkey } from "./types-BEqo908g.mjs";
2
- import { passkey } from "./index.mjs";
1
+ import { i as WebAuthnChallengeValue, n as Passkey, r as PasskeyOptions, t as passkey } from "./index-D7iFzFli.mjs";
3
2
  import * as better_auth_client0 from "better-auth/client";
4
3
  import * as nanostores from "nanostores";
5
4
  import { atom } from "nanostores";
@@ -0,0 +1,708 @@
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/index.d.ts
131
+ declare module "@better-auth/core" {
132
+ interface BetterAuthPluginRegistry<AuthOptions, Options> {
133
+ passkey: {
134
+ creator: typeof passkey;
135
+ };
136
+ }
137
+ }
138
+ declare const passkey: (options?: PasskeyOptions | undefined) => {
139
+ id: "passkey";
140
+ endpoints: {
141
+ generatePasskeyRegistrationOptions: better_call0.StrictEndpoint<"/passkey/generate-register-options", {
142
+ method: "GET";
143
+ use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
144
+ session: {
145
+ session: Record<string, any> & {
146
+ id: string;
147
+ createdAt: Date;
148
+ updatedAt: Date;
149
+ userId: string;
150
+ expiresAt: Date;
151
+ token: string;
152
+ ipAddress?: string | null | undefined;
153
+ userAgent?: string | null | undefined;
154
+ };
155
+ user: Record<string, any> & {
156
+ id: string;
157
+ createdAt: Date;
158
+ updatedAt: Date;
159
+ email: string;
160
+ emailVerified: boolean;
161
+ name: string;
162
+ image?: string | null | undefined;
163
+ };
164
+ };
165
+ }>)[];
166
+ query: zod.ZodOptional<zod.ZodObject<{
167
+ authenticatorAttachment: zod.ZodOptional<zod.ZodEnum<{
168
+ platform: "platform";
169
+ "cross-platform": "cross-platform";
170
+ }>>;
171
+ name: zod.ZodOptional<zod.ZodString>;
172
+ }, better_auth0.$strip>>;
173
+ metadata: {
174
+ openapi: {
175
+ operationId: string;
176
+ description: string;
177
+ responses: {
178
+ 200: {
179
+ description: string;
180
+ parameters: {
181
+ query: {
182
+ authenticatorAttachment: {
183
+ description: string;
184
+ required: boolean;
185
+ };
186
+ name: {
187
+ description: string;
188
+ required: boolean;
189
+ };
190
+ };
191
+ };
192
+ content: {
193
+ "application/json": {
194
+ schema: {
195
+ type: "object";
196
+ properties: {
197
+ challenge: {
198
+ type: string;
199
+ };
200
+ rp: {
201
+ type: string;
202
+ properties: {
203
+ name: {
204
+ type: string;
205
+ };
206
+ id: {
207
+ type: string;
208
+ };
209
+ };
210
+ };
211
+ user: {
212
+ type: string;
213
+ properties: {
214
+ id: {
215
+ type: string;
216
+ };
217
+ name: {
218
+ type: string;
219
+ };
220
+ displayName: {
221
+ type: string;
222
+ };
223
+ };
224
+ };
225
+ pubKeyCredParams: {
226
+ type: string;
227
+ items: {
228
+ type: string;
229
+ properties: {
230
+ type: {
231
+ type: string;
232
+ };
233
+ alg: {
234
+ type: string;
235
+ };
236
+ };
237
+ };
238
+ };
239
+ timeout: {
240
+ type: string;
241
+ };
242
+ excludeCredentials: {
243
+ type: string;
244
+ items: {
245
+ type: string;
246
+ properties: {
247
+ id: {
248
+ type: string;
249
+ };
250
+ type: {
251
+ type: string;
252
+ };
253
+ transports: {
254
+ type: string;
255
+ items: {
256
+ type: string;
257
+ };
258
+ };
259
+ };
260
+ };
261
+ };
262
+ authenticatorSelection: {
263
+ type: string;
264
+ properties: {
265
+ authenticatorAttachment: {
266
+ type: string;
267
+ };
268
+ requireResidentKey: {
269
+ type: string;
270
+ };
271
+ userVerification: {
272
+ type: string;
273
+ };
274
+ };
275
+ };
276
+ attestation: {
277
+ type: string;
278
+ };
279
+ extensions: {
280
+ type: string;
281
+ };
282
+ };
283
+ };
284
+ };
285
+ };
286
+ };
287
+ };
288
+ };
289
+ };
290
+ }, _simplewebauthn_server0.PublicKeyCredentialCreationOptionsJSON>;
291
+ generatePasskeyAuthenticationOptions: better_call0.StrictEndpoint<"/passkey/generate-authenticate-options", {
292
+ method: "GET";
293
+ metadata: {
294
+ openapi: {
295
+ operationId: string;
296
+ description: string;
297
+ responses: {
298
+ 200: {
299
+ description: string;
300
+ content: {
301
+ "application/json": {
302
+ schema: {
303
+ type: "object";
304
+ properties: {
305
+ challenge: {
306
+ type: string;
307
+ };
308
+ rp: {
309
+ type: string;
310
+ properties: {
311
+ name: {
312
+ type: string;
313
+ };
314
+ id: {
315
+ type: string;
316
+ };
317
+ };
318
+ };
319
+ user: {
320
+ type: string;
321
+ properties: {
322
+ id: {
323
+ type: string;
324
+ };
325
+ name: {
326
+ type: string;
327
+ };
328
+ displayName: {
329
+ type: string;
330
+ };
331
+ };
332
+ };
333
+ timeout: {
334
+ type: string;
335
+ };
336
+ allowCredentials: {
337
+ type: string;
338
+ items: {
339
+ type: string;
340
+ properties: {
341
+ id: {
342
+ type: string;
343
+ };
344
+ type: {
345
+ type: string;
346
+ };
347
+ transports: {
348
+ type: string;
349
+ items: {
350
+ type: string;
351
+ };
352
+ };
353
+ };
354
+ };
355
+ };
356
+ userVerification: {
357
+ type: string;
358
+ };
359
+ authenticatorSelection: {
360
+ type: string;
361
+ properties: {
362
+ authenticatorAttachment: {
363
+ type: string;
364
+ };
365
+ requireResidentKey: {
366
+ type: string;
367
+ };
368
+ userVerification: {
369
+ type: string;
370
+ };
371
+ };
372
+ };
373
+ extensions: {
374
+ type: string;
375
+ };
376
+ };
377
+ };
378
+ };
379
+ };
380
+ };
381
+ };
382
+ };
383
+ };
384
+ }, _simplewebauthn_server0.PublicKeyCredentialRequestOptionsJSON>;
385
+ verifyPasskeyRegistration: better_call0.StrictEndpoint<"/passkey/verify-registration", {
386
+ method: "POST";
387
+ body: zod.ZodObject<{
388
+ response: zod.ZodAny;
389
+ name: zod.ZodOptional<zod.ZodString>;
390
+ }, better_auth0.$strip>;
391
+ use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
392
+ session: {
393
+ session: Record<string, any> & {
394
+ id: string;
395
+ createdAt: Date;
396
+ updatedAt: Date;
397
+ userId: string;
398
+ expiresAt: Date;
399
+ token: string;
400
+ ipAddress?: string | null | undefined;
401
+ userAgent?: string | null | undefined;
402
+ };
403
+ user: Record<string, any> & {
404
+ id: string;
405
+ createdAt: Date;
406
+ updatedAt: Date;
407
+ email: string;
408
+ emailVerified: boolean;
409
+ name: string;
410
+ image?: string | null | undefined;
411
+ };
412
+ };
413
+ }>)[];
414
+ metadata: {
415
+ openapi: {
416
+ operationId: string;
417
+ description: string;
418
+ responses: {
419
+ 200: {
420
+ description: string;
421
+ content: {
422
+ "application/json": {
423
+ schema: {
424
+ $ref: string;
425
+ };
426
+ };
427
+ };
428
+ };
429
+ 400: {
430
+ description: string;
431
+ };
432
+ };
433
+ };
434
+ };
435
+ }, Passkey>;
436
+ verifyPasskeyAuthentication: better_call0.StrictEndpoint<"/passkey/verify-authentication", {
437
+ method: "POST";
438
+ body: zod.ZodObject<{
439
+ response: zod.ZodRecord<zod.ZodAny, zod.ZodAny>;
440
+ }, better_auth0.$strip>;
441
+ metadata: {
442
+ openapi: {
443
+ operationId: string;
444
+ description: string;
445
+ responses: {
446
+ 200: {
447
+ description: string;
448
+ content: {
449
+ "application/json": {
450
+ schema: {
451
+ type: "object";
452
+ properties: {
453
+ session: {
454
+ $ref: string;
455
+ };
456
+ user: {
457
+ $ref: string;
458
+ };
459
+ };
460
+ };
461
+ };
462
+ };
463
+ };
464
+ };
465
+ };
466
+ $Infer: {
467
+ body: {
468
+ response: _simplewebauthn_server0.AuthenticationResponseJSON;
469
+ };
470
+ };
471
+ };
472
+ }, {
473
+ session: {
474
+ id: string;
475
+ createdAt: Date;
476
+ updatedAt: Date;
477
+ userId: string;
478
+ expiresAt: Date;
479
+ token: string;
480
+ ipAddress?: string | null | undefined;
481
+ userAgent?: string | null | undefined;
482
+ };
483
+ }>;
484
+ listPasskeys: better_call0.StrictEndpoint<"/passkey/list-user-passkeys", {
485
+ method: "GET";
486
+ use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
487
+ session: {
488
+ session: Record<string, any> & {
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
+ user: Record<string, any> & {
499
+ id: string;
500
+ createdAt: Date;
501
+ updatedAt: Date;
502
+ email: string;
503
+ emailVerified: boolean;
504
+ name: string;
505
+ image?: string | null | undefined;
506
+ };
507
+ };
508
+ }>)[];
509
+ metadata: {
510
+ openapi: {
511
+ description: string;
512
+ responses: {
513
+ "200": {
514
+ description: string;
515
+ content: {
516
+ "application/json": {
517
+ schema: {
518
+ type: "array";
519
+ items: {
520
+ $ref: string;
521
+ required: string[];
522
+ };
523
+ description: string;
524
+ };
525
+ };
526
+ };
527
+ };
528
+ };
529
+ };
530
+ };
531
+ }, Passkey[]>;
532
+ deletePasskey: better_call0.StrictEndpoint<"/passkey/delete-passkey", {
533
+ method: "POST";
534
+ body: zod.ZodObject<{
535
+ id: zod.ZodString;
536
+ }, better_auth0.$strip>;
537
+ use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
538
+ session: {
539
+ session: Record<string, any> & {
540
+ id: string;
541
+ createdAt: Date;
542
+ updatedAt: Date;
543
+ userId: string;
544
+ expiresAt: Date;
545
+ token: string;
546
+ ipAddress?: string | null | undefined;
547
+ userAgent?: string | null | undefined;
548
+ };
549
+ user: Record<string, any> & {
550
+ id: string;
551
+ createdAt: Date;
552
+ updatedAt: Date;
553
+ email: string;
554
+ emailVerified: boolean;
555
+ name: string;
556
+ image?: string | null | undefined;
557
+ };
558
+ };
559
+ }>)[];
560
+ metadata: {
561
+ openapi: {
562
+ description: string;
563
+ responses: {
564
+ "200": {
565
+ description: string;
566
+ content: {
567
+ "application/json": {
568
+ schema: {
569
+ type: "object";
570
+ properties: {
571
+ status: {
572
+ type: string;
573
+ description: string;
574
+ };
575
+ };
576
+ required: string[];
577
+ };
578
+ };
579
+ };
580
+ };
581
+ };
582
+ };
583
+ };
584
+ }, {
585
+ status: boolean;
586
+ }>;
587
+ updatePasskey: better_call0.StrictEndpoint<"/passkey/update-passkey", {
588
+ method: "POST";
589
+ body: zod.ZodObject<{
590
+ id: zod.ZodString;
591
+ name: zod.ZodString;
592
+ }, better_auth0.$strip>;
593
+ use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
594
+ session: {
595
+ session: Record<string, any> & {
596
+ id: string;
597
+ createdAt: Date;
598
+ updatedAt: Date;
599
+ userId: string;
600
+ expiresAt: Date;
601
+ token: string;
602
+ ipAddress?: string | null | undefined;
603
+ userAgent?: string | null | undefined;
604
+ };
605
+ user: Record<string, any> & {
606
+ id: string;
607
+ createdAt: Date;
608
+ updatedAt: Date;
609
+ email: string;
610
+ emailVerified: boolean;
611
+ name: string;
612
+ image?: string | null | undefined;
613
+ };
614
+ };
615
+ }>)[];
616
+ metadata: {
617
+ openapi: {
618
+ description: string;
619
+ responses: {
620
+ "200": {
621
+ description: string;
622
+ content: {
623
+ "application/json": {
624
+ schema: {
625
+ type: "object";
626
+ properties: {
627
+ passkey: {
628
+ $ref: string;
629
+ };
630
+ };
631
+ required: string[];
632
+ };
633
+ };
634
+ };
635
+ };
636
+ };
637
+ };
638
+ };
639
+ }, {
640
+ passkey: Passkey;
641
+ }>;
642
+ };
643
+ schema: {
644
+ passkey: {
645
+ fields: {
646
+ name: {
647
+ type: "string";
648
+ required: false;
649
+ };
650
+ publicKey: {
651
+ type: "string";
652
+ required: true;
653
+ };
654
+ userId: {
655
+ type: "string";
656
+ references: {
657
+ model: string;
658
+ field: string;
659
+ };
660
+ required: true;
661
+ index: true;
662
+ };
663
+ credentialID: {
664
+ type: "string";
665
+ required: true;
666
+ index: true;
667
+ };
668
+ counter: {
669
+ type: "number";
670
+ required: true;
671
+ };
672
+ deviceType: {
673
+ type: "string";
674
+ required: true;
675
+ };
676
+ backedUp: {
677
+ type: "boolean";
678
+ required: true;
679
+ };
680
+ transports: {
681
+ type: "string";
682
+ required: false;
683
+ };
684
+ createdAt: {
685
+ type: "date";
686
+ required: false;
687
+ };
688
+ aaguid: {
689
+ type: "string";
690
+ required: false;
691
+ };
692
+ };
693
+ };
694
+ };
695
+ $ERROR_CODES: {
696
+ CHALLENGE_NOT_FOUND: better_auth0.RawError<"CHALLENGE_NOT_FOUND">;
697
+ YOU_ARE_NOT_ALLOWED_TO_REGISTER_THIS_PASSKEY: better_auth0.RawError<"YOU_ARE_NOT_ALLOWED_TO_REGISTER_THIS_PASSKEY">;
698
+ FAILED_TO_VERIFY_REGISTRATION: better_auth0.RawError<"FAILED_TO_VERIFY_REGISTRATION">;
699
+ PASSKEY_NOT_FOUND: better_auth0.RawError<"PASSKEY_NOT_FOUND">;
700
+ AUTHENTICATION_FAILED: better_auth0.RawError<"AUTHENTICATION_FAILED">;
701
+ UNABLE_TO_CREATE_SESSION: better_auth0.RawError<"UNABLE_TO_CREATE_SESSION">;
702
+ FAILED_TO_UPDATE_PASSKEY: better_auth0.RawError<"FAILED_TO_UPDATE_PASSKEY">;
703
+ };
704
+ options: PasskeyOptions | undefined;
705
+ };
706
+ //#endregion
707
+ export { WebAuthnChallengeValue as i, Passkey as n, PasskeyOptions as r, passkey as t };
708
+ //# sourceMappingURL=index-D7iFzFli.d.mts.map