@better-auth/passkey 1.5.0-beta.2 → 1.5.0-beta.20

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