@better-auth/passkey 1.5.7-beta.1 → 1.6.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 +0,0 @@
1
- {"version":3,"file":"error-codes-BwAsYefH.mjs","names":[],"sources":["../src/error-codes.ts"],"sourcesContent":["import { defineErrorCodes } from \"@better-auth/core/utils/error-codes\";\n\nexport const PASSKEY_ERROR_CODES = defineErrorCodes({\n\tCHALLENGE_NOT_FOUND: \"Challenge not found\",\n\tYOU_ARE_NOT_ALLOWED_TO_REGISTER_THIS_PASSKEY:\n\t\t\"You are not allowed to register this passkey\",\n\tFAILED_TO_VERIFY_REGISTRATION: \"Failed to verify registration\",\n\tPASSKEY_NOT_FOUND: \"Passkey not found\",\n\tAUTHENTICATION_FAILED: \"Authentication failed\",\n\tUNABLE_TO_CREATE_SESSION: \"Unable to create session\",\n\tFAILED_TO_UPDATE_PASSKEY: \"Failed to update passkey\",\n\tPREVIOUSLY_REGISTERED: \"Previously registered\",\n\tREGISTRATION_CANCELLED: \"Registration cancelled\",\n\tAUTH_CANCELLED: \"Auth cancelled\",\n\tUNKNOWN_ERROR: \"Unknown error\",\n});\n"],"mappings":";;AAEA,MAAa,sBAAsB,iBAAiB;CACnD,qBAAqB;CACrB,8CACC;CACD,+BAA+B;CAC/B,mBAAmB;CACnB,uBAAuB;CACvB,0BAA0B;CAC1B,0BAA0B;CAC1B,uBAAuB;CACvB,wBAAwB;CACxB,gBAAgB;CAChB,eAAe;CACf,CAAC"}
@@ -1,692 +0,0 @@
1
- import * as _simplewebauthn_server0 from "@simplewebauthn/server";
2
- import { CredentialDeviceType } from "@simplewebauthn/server";
3
- import * as better_auth0 from "better-auth";
4
- import { InferOptionSchema } from "better-auth/types";
5
- import * as better_call0 from "better-call";
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
- * @internal
64
- */
65
- interface WebAuthnChallengeValue {
66
- expectedChallenge: string;
67
- userData: {
68
- id: string;
69
- };
70
- }
71
- interface PasskeyOptions {
72
- /**
73
- * A unique identifier for your website. 'localhost' is okay for
74
- * local dev
75
- *
76
- * @default "localhost"
77
- */
78
- rpID?: string | undefined;
79
- /**
80
- * Human-readable title for your website
81
- *
82
- * @default "Better Auth"
83
- */
84
- rpName?: string | undefined;
85
- /**
86
- * The URL at which registrations and authentications should occur.
87
- * `http://localhost` and `http://localhost:PORT` are also valid.
88
- * Do NOT include any trailing /
89
- *
90
- * if this isn't provided. The client itself will
91
- * pass this value.
92
- */
93
- origin?: (string | string[] | null) | undefined;
94
- /**
95
- * Allow customization of the authenticatorSelection options
96
- * during passkey registration.
97
- */
98
- authenticatorSelection?: AuthenticatorSelectionCriteria | undefined;
99
- /**
100
- * Advanced options
101
- */
102
- advanced?: {
103
- /**
104
- * Cookie name for storing WebAuthn challenge ID during authentication flow
105
- *
106
- * @default "better-auth-passkey"
107
- */
108
- webAuthnChallengeCookie?: string;
109
- } | undefined;
110
- /**
111
- * Schema for the passkey model
112
- */
113
- schema?: InferOptionSchema<typeof schema> | undefined;
114
- }
115
- type Passkey = {
116
- id: string;
117
- name?: string | undefined;
118
- publicKey: string;
119
- userId: string;
120
- credentialID: string;
121
- counter: number;
122
- deviceType: CredentialDeviceType;
123
- backedUp: boolean;
124
- transports?: string | undefined;
125
- createdAt: Date;
126
- aaguid?: string | undefined;
127
- };
128
- //#endregion
129
- //#region src/error-codes.d.ts
130
- declare const PASSKEY_ERROR_CODES: {
131
- CHALLENGE_NOT_FOUND: better_auth0.RawError<"CHALLENGE_NOT_FOUND">;
132
- YOU_ARE_NOT_ALLOWED_TO_REGISTER_THIS_PASSKEY: better_auth0.RawError<"YOU_ARE_NOT_ALLOWED_TO_REGISTER_THIS_PASSKEY">;
133
- FAILED_TO_VERIFY_REGISTRATION: better_auth0.RawError<"FAILED_TO_VERIFY_REGISTRATION">;
134
- PASSKEY_NOT_FOUND: better_auth0.RawError<"PASSKEY_NOT_FOUND">;
135
- AUTHENTICATION_FAILED: better_auth0.RawError<"AUTHENTICATION_FAILED">;
136
- UNABLE_TO_CREATE_SESSION: better_auth0.RawError<"UNABLE_TO_CREATE_SESSION">;
137
- FAILED_TO_UPDATE_PASSKEY: better_auth0.RawError<"FAILED_TO_UPDATE_PASSKEY">;
138
- PREVIOUSLY_REGISTERED: better_auth0.RawError<"PREVIOUSLY_REGISTERED">;
139
- REGISTRATION_CANCELLED: better_auth0.RawError<"REGISTRATION_CANCELLED">;
140
- AUTH_CANCELLED: better_auth0.RawError<"AUTH_CANCELLED">;
141
- UNKNOWN_ERROR: better_auth0.RawError<"UNKNOWN_ERROR">;
142
- };
143
- //#endregion
144
- //#region src/index.d.ts
145
- declare module "@better-auth/core" {
146
- interface BetterAuthPluginRegistry<AuthOptions, Options> {
147
- passkey: {
148
- creator: typeof passkey;
149
- };
150
- }
151
- }
152
- declare const passkey: (options?: PasskeyOptions | undefined) => {
153
- id: "passkey";
154
- endpoints: {
155
- generatePasskeyRegistrationOptions: better_call0.Endpoint<"/passkey/generate-register-options", "GET", undefined, {
156
- authenticatorAttachment?: "platform" | "cross-platform" | undefined;
157
- name?: string | undefined;
158
- } | undefined, [better_call0.Middleware<(inputContext: Record<string, any>) => 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
- }>>], _simplewebauthn_server0.PublicKeyCredentialCreationOptionsJSON, {
181
- openapi: {
182
- operationId: string;
183
- description: string;
184
- responses: {
185
- 200: {
186
- description: string;
187
- parameters: {
188
- query: {
189
- authenticatorAttachment: {
190
- description: string;
191
- required: boolean;
192
- };
193
- name: {
194
- description: string;
195
- required: boolean;
196
- };
197
- };
198
- };
199
- content: {
200
- "application/json": {
201
- schema: {
202
- type: "object";
203
- properties: {
204
- challenge: {
205
- type: string;
206
- };
207
- rp: {
208
- type: string;
209
- properties: {
210
- name: {
211
- type: string;
212
- };
213
- id: {
214
- type: string;
215
- };
216
- };
217
- };
218
- user: {
219
- type: string;
220
- properties: {
221
- id: {
222
- type: string;
223
- };
224
- name: {
225
- type: string;
226
- };
227
- displayName: {
228
- type: string;
229
- };
230
- };
231
- };
232
- pubKeyCredParams: {
233
- type: string;
234
- items: {
235
- type: string;
236
- properties: {
237
- type: {
238
- type: string;
239
- };
240
- alg: {
241
- type: string;
242
- };
243
- };
244
- };
245
- };
246
- timeout: {
247
- type: string;
248
- };
249
- excludeCredentials: {
250
- type: string;
251
- items: {
252
- type: string;
253
- properties: {
254
- id: {
255
- type: string;
256
- };
257
- type: {
258
- type: string;
259
- };
260
- transports: {
261
- type: string;
262
- items: {
263
- type: string;
264
- };
265
- };
266
- };
267
- };
268
- };
269
- authenticatorSelection: {
270
- type: string;
271
- properties: {
272
- authenticatorAttachment: {
273
- type: string;
274
- };
275
- requireResidentKey: {
276
- type: string;
277
- };
278
- userVerification: {
279
- type: string;
280
- };
281
- };
282
- };
283
- attestation: {
284
- type: string;
285
- };
286
- extensions: {
287
- type: string;
288
- };
289
- };
290
- };
291
- };
292
- };
293
- };
294
- };
295
- };
296
- }, undefined>;
297
- generatePasskeyAuthenticationOptions: better_call0.Endpoint<"/passkey/generate-authenticate-options", "GET", undefined, Record<string, any> | undefined, [], _simplewebauthn_server0.PublicKeyCredentialRequestOptionsJSON, {
298
- openapi: {
299
- operationId: string;
300
- description: string;
301
- responses: {
302
- 200: {
303
- description: string;
304
- content: {
305
- "application/json": {
306
- schema: {
307
- type: "object";
308
- properties: {
309
- challenge: {
310
- type: string;
311
- };
312
- rp: {
313
- type: string;
314
- properties: {
315
- name: {
316
- type: string;
317
- };
318
- id: {
319
- type: string;
320
- };
321
- };
322
- };
323
- user: {
324
- type: string;
325
- properties: {
326
- id: {
327
- type: string;
328
- };
329
- name: {
330
- type: string;
331
- };
332
- displayName: {
333
- type: string;
334
- };
335
- };
336
- };
337
- timeout: {
338
- type: string;
339
- };
340
- allowCredentials: {
341
- type: string;
342
- items: {
343
- type: string;
344
- properties: {
345
- id: {
346
- type: string;
347
- };
348
- type: {
349
- type: string;
350
- };
351
- transports: {
352
- type: string;
353
- items: {
354
- type: string;
355
- };
356
- };
357
- };
358
- };
359
- };
360
- userVerification: {
361
- type: string;
362
- };
363
- authenticatorSelection: {
364
- type: string;
365
- properties: {
366
- authenticatorAttachment: {
367
- type: string;
368
- };
369
- requireResidentKey: {
370
- type: string;
371
- };
372
- userVerification: {
373
- type: string;
374
- };
375
- };
376
- };
377
- extensions: {
378
- type: string;
379
- };
380
- };
381
- };
382
- };
383
- };
384
- };
385
- };
386
- };
387
- }, undefined>;
388
- verifyPasskeyRegistration: better_call0.Endpoint<"/passkey/verify-registration", "POST", {
389
- response: any;
390
- name?: string | undefined;
391
- }, Record<string, any> | undefined, [better_call0.Middleware<(inputContext: Record<string, any>) => 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
- }>>], Passkey, {
414
- openapi: {
415
- operationId: string;
416
- description: string;
417
- responses: {
418
- 200: {
419
- description: string;
420
- content: {
421
- "application/json": {
422
- schema: {
423
- $ref: string;
424
- };
425
- };
426
- };
427
- };
428
- 400: {
429
- description: string;
430
- };
431
- };
432
- };
433
- }, undefined>;
434
- verifyPasskeyAuthentication: better_call0.Endpoint<"/passkey/verify-authentication", "POST", {
435
- response: _simplewebauthn_server0.AuthenticationResponseJSON;
436
- }, Record<string, any> | undefined, [], {
437
- session: {
438
- id: string;
439
- createdAt: Date;
440
- updatedAt: Date;
441
- userId: string;
442
- expiresAt: Date;
443
- token: string;
444
- ipAddress?: string | null | undefined;
445
- userAgent?: string | null | undefined;
446
- };
447
- }, {
448
- openapi: {
449
- operationId: string;
450
- description: string;
451
- responses: {
452
- 200: {
453
- description: string;
454
- content: {
455
- "application/json": {
456
- schema: {
457
- type: "object";
458
- properties: {
459
- session: {
460
- $ref: string;
461
- };
462
- user: {
463
- $ref: string;
464
- };
465
- };
466
- };
467
- };
468
- };
469
- };
470
- };
471
- };
472
- $Infer: {
473
- body: {
474
- response: _simplewebauthn_server0.AuthenticationResponseJSON;
475
- };
476
- };
477
- }, undefined>;
478
- listPasskeys: better_call0.Endpoint<"/passkey/list-user-passkeys", "GET", undefined, Record<string, any> | undefined, [better_call0.Middleware<(inputContext: Record<string, any>) => Promise<{
479
- session: {
480
- session: Record<string, any> & {
481
- id: string;
482
- createdAt: Date;
483
- updatedAt: Date;
484
- userId: string;
485
- expiresAt: Date;
486
- token: string;
487
- ipAddress?: string | null | undefined;
488
- userAgent?: string | null | undefined;
489
- };
490
- user: Record<string, any> & {
491
- id: string;
492
- createdAt: Date;
493
- updatedAt: Date;
494
- email: string;
495
- emailVerified: boolean;
496
- name: string;
497
- image?: string | null | undefined;
498
- };
499
- };
500
- }>>], Passkey[], {
501
- openapi: {
502
- description: string;
503
- responses: {
504
- "200": {
505
- description: string;
506
- content: {
507
- "application/json": {
508
- schema: {
509
- type: "array";
510
- items: {
511
- $ref: string;
512
- required: string[];
513
- };
514
- description: string;
515
- };
516
- };
517
- };
518
- };
519
- };
520
- };
521
- }, undefined>;
522
- deletePasskey: better_call0.Endpoint<"/passkey/delete-passkey", "POST", {
523
- id: string;
524
- }, Record<string, any> | undefined, [better_call0.Middleware<(inputContext: Record<string, any>) => Promise<{
525
- session: {
526
- session: Record<string, any> & {
527
- id: string;
528
- createdAt: Date;
529
- updatedAt: Date;
530
- userId: string;
531
- expiresAt: Date;
532
- token: string;
533
- ipAddress?: string | null | undefined;
534
- userAgent?: string | null | undefined;
535
- };
536
- user: Record<string, any> & {
537
- id: string;
538
- createdAt: Date;
539
- updatedAt: Date;
540
- email: string;
541
- emailVerified: boolean;
542
- name: string;
543
- image?: string | null | undefined;
544
- };
545
- };
546
- }>>], {
547
- status: boolean;
548
- }, {
549
- openapi: {
550
- description: string;
551
- responses: {
552
- "200": {
553
- description: string;
554
- content: {
555
- "application/json": {
556
- schema: {
557
- type: "object";
558
- properties: {
559
- status: {
560
- type: string;
561
- description: string;
562
- };
563
- };
564
- required: string[];
565
- };
566
- };
567
- };
568
- };
569
- };
570
- };
571
- }, undefined>;
572
- updatePasskey: better_call0.Endpoint<"/passkey/update-passkey", "POST", {
573
- id: string;
574
- name: string;
575
- }, Record<string, any> | undefined, [better_call0.Middleware<(inputContext: Record<string, any>) => Promise<{
576
- session: {
577
- session: Record<string, any> & {
578
- id: string;
579
- createdAt: Date;
580
- updatedAt: Date;
581
- userId: string;
582
- expiresAt: Date;
583
- token: string;
584
- ipAddress?: string | null | undefined;
585
- userAgent?: string | null | undefined;
586
- };
587
- user: Record<string, any> & {
588
- id: string;
589
- createdAt: Date;
590
- updatedAt: Date;
591
- email: string;
592
- emailVerified: boolean;
593
- name: string;
594
- image?: string | null | undefined;
595
- };
596
- };
597
- }>>], {
598
- passkey: Passkey;
599
- }, {
600
- openapi: {
601
- description: string;
602
- responses: {
603
- "200": {
604
- description: string;
605
- content: {
606
- "application/json": {
607
- schema: {
608
- type: "object";
609
- properties: {
610
- passkey: {
611
- $ref: string;
612
- };
613
- };
614
- required: string[];
615
- };
616
- };
617
- };
618
- };
619
- };
620
- };
621
- }, undefined>;
622
- };
623
- schema: {
624
- passkey: {
625
- fields: {
626
- name: {
627
- type: "string";
628
- required: false;
629
- };
630
- publicKey: {
631
- type: "string";
632
- required: true;
633
- };
634
- userId: {
635
- type: "string";
636
- references: {
637
- model: string;
638
- field: string;
639
- };
640
- required: true;
641
- index: true;
642
- };
643
- credentialID: {
644
- type: "string";
645
- required: true;
646
- index: true;
647
- };
648
- counter: {
649
- type: "number";
650
- required: true;
651
- };
652
- deviceType: {
653
- type: "string";
654
- required: true;
655
- };
656
- backedUp: {
657
- type: "boolean";
658
- required: true;
659
- };
660
- transports: {
661
- type: "string";
662
- required: false;
663
- };
664
- createdAt: {
665
- type: "date";
666
- required: false;
667
- };
668
- aaguid: {
669
- type: "string";
670
- required: false;
671
- };
672
- };
673
- };
674
- };
675
- $ERROR_CODES: {
676
- CHALLENGE_NOT_FOUND: better_auth0.RawError<"CHALLENGE_NOT_FOUND">;
677
- YOU_ARE_NOT_ALLOWED_TO_REGISTER_THIS_PASSKEY: better_auth0.RawError<"YOU_ARE_NOT_ALLOWED_TO_REGISTER_THIS_PASSKEY">;
678
- FAILED_TO_VERIFY_REGISTRATION: better_auth0.RawError<"FAILED_TO_VERIFY_REGISTRATION">;
679
- PASSKEY_NOT_FOUND: better_auth0.RawError<"PASSKEY_NOT_FOUND">;
680
- AUTHENTICATION_FAILED: better_auth0.RawError<"AUTHENTICATION_FAILED">;
681
- UNABLE_TO_CREATE_SESSION: better_auth0.RawError<"UNABLE_TO_CREATE_SESSION">;
682
- FAILED_TO_UPDATE_PASSKEY: better_auth0.RawError<"FAILED_TO_UPDATE_PASSKEY">;
683
- PREVIOUSLY_REGISTERED: better_auth0.RawError<"PREVIOUSLY_REGISTERED">;
684
- REGISTRATION_CANCELLED: better_auth0.RawError<"REGISTRATION_CANCELLED">;
685
- AUTH_CANCELLED: better_auth0.RawError<"AUTH_CANCELLED">;
686
- UNKNOWN_ERROR: better_auth0.RawError<"UNKNOWN_ERROR">;
687
- };
688
- options: PasskeyOptions | undefined;
689
- };
690
- //#endregion
691
- export { WebAuthnChallengeValue as a, PasskeyOptions as i, PASSKEY_ERROR_CODES as n, Passkey as r, passkey as t };
692
- //# sourceMappingURL=index-BfRDyiNp.d.mts.map