@better-auth/passkey 1.4.4-beta.1 → 1.4.4

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