better-auth 1.2.0-beta.1 → 1.2.0-beta.11

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.
Files changed (205) hide show
  1. package/dist/adapters/drizzle.cjs +12 -5
  2. package/dist/adapters/drizzle.d.cts +6 -2
  3. package/dist/adapters/drizzle.d.ts +6 -2
  4. package/dist/adapters/drizzle.js +11 -4
  5. package/dist/adapters/kysely.cjs +5 -5
  6. package/dist/adapters/kysely.d.cts +6 -2
  7. package/dist/adapters/kysely.d.ts +6 -2
  8. package/dist/adapters/kysely.js +3 -3
  9. package/dist/adapters/memory.cjs +4 -4
  10. package/dist/adapters/memory.d.cts +6 -2
  11. package/dist/adapters/memory.d.ts +6 -2
  12. package/dist/adapters/memory.js +3 -3
  13. package/dist/adapters/mongodb.cjs +26 -8
  14. package/dist/adapters/mongodb.d.cts +6 -2
  15. package/dist/adapters/mongodb.d.ts +6 -2
  16. package/dist/adapters/mongodb.js +24 -6
  17. package/dist/adapters/prisma.cjs +18 -5
  18. package/dist/adapters/prisma.d.cts +6 -2
  19. package/dist/adapters/prisma.d.ts +6 -2
  20. package/dist/adapters/prisma.js +16 -3
  21. package/dist/adapters/test.cjs +1 -1
  22. package/dist/adapters/test.d.cts +2 -2
  23. package/dist/adapters/test.d.ts +2 -2
  24. package/dist/adapters/test.js +1 -1
  25. package/dist/api.cjs +48 -44
  26. package/dist/api.d.cts +3 -3
  27. package/dist/api.d.ts +3 -3
  28. package/dist/api.js +5 -5
  29. package/dist/{auth-DcMc3BIq.d.ts → auth-C-uLTIcY.d.ts} +12002 -7646
  30. package/dist/{auth-D4rdpxtI.d.cts → auth-lDfjrjVd.d.cts} +12002 -7646
  31. package/dist/{chunk-MGJLVQOV.js → chunk-2OAHQPLI.js} +100 -38
  32. package/dist/{chunk-5E75URIA.cjs → chunk-2Z6CVQHH.cjs} +0 -4
  33. package/dist/{chunk-WVLPJXQR.cjs → chunk-3FWLBBDV.cjs} +109 -51
  34. package/dist/{chunk-WDOY7YUW.cjs → chunk-6P33VPUY.cjs} +106 -44
  35. package/dist/{chunk-ADGXBH3Y.js → chunk-6XMAWIGH.js} +29 -26
  36. package/dist/{chunk-G7HOSQ5N.cjs → chunk-75MYIQ34.cjs} +15 -18
  37. package/dist/{chunk-YW3B2ST3.js → chunk-BY25AMN4.js} +116 -5
  38. package/dist/{chunk-LZ5DEQVH.cjs → chunk-C4T7TNDG.cjs} +3 -3
  39. package/dist/{chunk-PJ4KWXLQ.cjs → chunk-DH5E7574.cjs} +8 -8
  40. package/dist/{chunk-5RY45WFV.js → chunk-DIIVSN3J.js} +36 -13
  41. package/dist/{chunk-OSBTXYDD.cjs → chunk-GQKBG2VQ.cjs} +125 -14
  42. package/dist/{chunk-BKFMDM3P.js → chunk-HRI7BYTU.js} +115 -16
  43. package/dist/{chunk-6O2GLU2U.cjs → chunk-ICONG5HP.cjs} +18 -13
  44. package/dist/{chunk-3EY3LSQR.js → chunk-IVS5VS3V.js} +75 -36
  45. package/dist/{chunk-YRUDZRY3.cjs → chunk-IYCSNEDU.cjs} +79 -56
  46. package/dist/{chunk-NU4SXYJ5.cjs → chunk-JDAHD767.cjs} +198 -42
  47. package/dist/{chunk-UP6VJQDB.js → chunk-JHLVXVME.js} +17 -10
  48. package/dist/{chunk-WLXFBYQ6.cjs → chunk-JU56U5MW.cjs} +79 -9
  49. package/dist/{chunk-QFYRLTM5.cjs → chunk-JYPC7ZAL.cjs} +52 -49
  50. package/dist/{chunk-UHGAA4GH.cjs → chunk-KNVDJ4WK.cjs} +5 -5
  51. package/dist/{chunk-CVDYU5OC.js → chunk-M6SPJGF4.js} +5 -8
  52. package/dist/{chunk-BAPXDO3E.cjs → chunk-MKNA7SED.cjs} +125 -26
  53. package/dist/{chunk-GTM45OYP.cjs → chunk-NQFRXDEY.cjs} +3 -3
  54. package/dist/{chunk-FXNG3YQA.js → chunk-NXQP77NI.js} +146 -79
  55. package/dist/{chunk-FA6UYV37.js → chunk-PR54V2QL.js} +29 -10
  56. package/dist/{chunk-JLATHUM5.cjs → chunk-QBYD37C7.cjs} +21 -14
  57. package/dist/{chunk-E6LJZ5ME.js → chunk-QFIG4XKQ.js} +1 -1
  58. package/dist/{chunk-764RYNTE.cjs → chunk-QS2XIJC4.cjs} +63 -29
  59. package/dist/{chunk-GTQM7JU7.js → chunk-R42K7GPF.js} +3 -1
  60. package/dist/{chunk-3BWJXTLC.cjs → chunk-RHWADEUT.cjs} +81 -58
  61. package/dist/{chunk-JNZYTS3B.js → chunk-RS2A52JD.js} +1 -1
  62. package/dist/{chunk-5OBRFII2.js → chunk-SIAKIOPW.js} +81 -23
  63. package/dist/{chunk-V6RGXSG4.cjs → chunk-SVC7H7K4.cjs} +3 -1
  64. package/dist/{chunk-EM73ZZSP.cjs → chunk-TID6AR5K.cjs} +49 -30
  65. package/dist/{chunk-VXDYNCOX.js → chunk-TODG5RSV.js} +172 -19
  66. package/dist/{chunk-VPCROEJW.cjs → chunk-TZ2VLKIG.cjs} +170 -103
  67. package/dist/{chunk-WGCTQNSQ.js → chunk-UHBMFLSF.js} +1 -1
  68. package/dist/{chunk-PIWBUHRB.cjs → chunk-UPQLFVFU.cjs} +83 -43
  69. package/dist/{chunk-B5UCLTPZ.cjs → chunk-UQC2FUXC.cjs} +2 -1
  70. package/dist/{chunk-RGG6OEA3.js → chunk-VUXQHI6K.js} +60 -26
  71. package/dist/{chunk-2LQ7T2GE.js → chunk-WUUDJ3TF.js} +3 -3
  72. package/dist/{chunk-HZBNUY7E.js → chunk-WZ6OIVJK.js} +2 -1
  73. package/dist/{chunk-5XAVWKUN.js → chunk-X4X6WCXH.js} +74 -4
  74. package/dist/{chunk-NPO64SVN.js → chunk-ZFUBVSZD.js} +0 -4
  75. package/dist/{chunk-S6MI7ZLE.js → chunk-ZKNBNGHR.js} +12 -7
  76. package/dist/{chunk-5KMF6HGF.js → chunk-ZUGWIOG4.js} +75 -52
  77. package/dist/client/plugins.cjs +215 -21
  78. package/dist/client/plugins.d.cts +176 -10
  79. package/dist/client/plugins.d.ts +176 -10
  80. package/dist/client/plugins.js +214 -14
  81. package/dist/client.d.cts +6 -7
  82. package/dist/client.d.ts +6 -7
  83. package/dist/cookies.d.cts +2 -2
  84. package/dist/cookies.d.ts +2 -2
  85. package/dist/db.cjs +29 -29
  86. package/dist/db.d.cts +6 -6
  87. package/dist/db.d.ts +6 -6
  88. package/dist/db.js +3 -3
  89. package/dist/index-BX_H-j6k.d.cts +7755 -0
  90. package/dist/{index-Ba5bMY6A.d.cts → index-BuRgaJZR.d.cts} +194 -2
  91. package/dist/index-D5zWKzf9.d.ts +7755 -0
  92. package/dist/{index-XrJz4AYF.d.ts → index-moQjyfmm.d.ts} +194 -2
  93. package/dist/index.cjs +19 -19
  94. package/dist/index.d.cts +3 -3
  95. package/dist/index.d.ts +3 -3
  96. package/dist/index.js +9 -9
  97. package/dist/next-js.cjs +24 -24
  98. package/dist/next-js.d.cts +2 -2
  99. package/dist/next-js.d.ts +2 -2
  100. package/dist/next-js.js +23 -23
  101. package/dist/node.d.cts +2 -2
  102. package/dist/node.d.ts +2 -2
  103. package/dist/oauth2.cjs +9 -9
  104. package/dist/oauth2.d.cts +6 -5
  105. package/dist/oauth2.d.ts +6 -5
  106. package/dist/oauth2.js +2 -2
  107. package/dist/plugins/admin.cjs +7 -7
  108. package/dist/plugins/admin.d.cts +163 -32
  109. package/dist/plugins/admin.d.ts +163 -32
  110. package/dist/plugins/admin.js +6 -6
  111. package/dist/plugins/anonymous.cjs +7 -7
  112. package/dist/plugins/anonymous.d.cts +8 -4
  113. package/dist/plugins/anonymous.d.ts +8 -4
  114. package/dist/plugins/anonymous.js +6 -6
  115. package/dist/plugins/bearer.cjs +7 -7
  116. package/dist/plugins/bearer.d.cts +2 -2
  117. package/dist/plugins/bearer.d.ts +2 -2
  118. package/dist/plugins/bearer.js +6 -6
  119. package/dist/{plugin → plugins}/custom-session.cjs +7 -7
  120. package/dist/{plugin → plugins}/custom-session.d.cts +8 -4
  121. package/dist/{plugin → plugins}/custom-session.d.ts +8 -4
  122. package/dist/{plugin → plugins}/custom-session.js +6 -6
  123. package/dist/plugins/email-otp.cjs +7 -7
  124. package/dist/plugins/email-otp.d.cts +44 -16
  125. package/dist/plugins/email-otp.d.ts +44 -16
  126. package/dist/plugins/email-otp.js +6 -6
  127. package/dist/plugins/generic-oauth.cjs +7 -7
  128. package/dist/plugins/generic-oauth.d.cts +95 -6
  129. package/dist/plugins/generic-oauth.d.ts +95 -6
  130. package/dist/plugins/generic-oauth.js +6 -6
  131. package/dist/plugins/jwt.cjs +7 -7
  132. package/dist/plugins/jwt.d.cts +28 -6
  133. package/dist/plugins/jwt.d.ts +28 -6
  134. package/dist/plugins/jwt.js +6 -6
  135. package/dist/plugins/magic-link.cjs +7 -7
  136. package/dist/plugins/magic-link.d.cts +16 -4
  137. package/dist/plugins/magic-link.d.ts +16 -4
  138. package/dist/plugins/magic-link.js +6 -6
  139. package/dist/plugins/multi-session.cjs +7 -7
  140. package/dist/plugins/multi-session.d.cts +20 -8
  141. package/dist/plugins/multi-session.d.ts +20 -8
  142. package/dist/plugins/multi-session.js +6 -6
  143. package/dist/plugins/oidc-provider.cjs +7 -7
  144. package/dist/plugins/oidc-provider.d.cts +58 -15
  145. package/dist/plugins/oidc-provider.d.ts +58 -15
  146. package/dist/plugins/oidc-provider.js +6 -6
  147. package/dist/plugins/one-tap.cjs +7 -7
  148. package/dist/plugins/one-tap.d.cts +13 -2
  149. package/dist/plugins/one-tap.d.ts +13 -2
  150. package/dist/plugins/one-tap.js +6 -6
  151. package/dist/plugins/open-api.cjs +8 -8
  152. package/dist/plugins/open-api.d.cts +14 -6
  153. package/dist/plugins/open-api.d.ts +14 -6
  154. package/dist/plugins/open-api.js +7 -7
  155. package/dist/plugins/organization.cjs +7 -7
  156. package/dist/plugins/organization.d.cts +3 -3
  157. package/dist/plugins/organization.d.ts +3 -3
  158. package/dist/plugins/organization.js +6 -6
  159. package/dist/plugins/passkey.cjs +19 -31
  160. package/dist/plugins/passkey.d.cts +45 -148
  161. package/dist/plugins/passkey.d.ts +45 -148
  162. package/dist/plugins/passkey.js +5 -9
  163. package/dist/plugins/phone-number.cjs +7 -7
  164. package/dist/plugins/phone-number.d.cts +122 -9
  165. package/dist/plugins/phone-number.d.ts +122 -9
  166. package/dist/plugins/phone-number.js +6 -6
  167. package/dist/plugins/sso.cjs +27 -19
  168. package/dist/plugins/sso.d.cts +24 -8
  169. package/dist/plugins/sso.d.ts +24 -8
  170. package/dist/plugins/sso.js +14 -6
  171. package/dist/plugins/two-factor.cjs +7 -7
  172. package/dist/plugins/two-factor.d.cts +62 -22
  173. package/dist/plugins/two-factor.d.ts +62 -22
  174. package/dist/plugins/two-factor.js +6 -6
  175. package/dist/plugins/username.cjs +7 -7
  176. package/dist/plugins/username.d.cts +36 -4
  177. package/dist/plugins/username.d.ts +36 -4
  178. package/dist/plugins/username.js +6 -6
  179. package/dist/plugins.cjs +43 -43
  180. package/dist/plugins.d.cts +11 -7
  181. package/dist/plugins.d.ts +11 -7
  182. package/dist/plugins.js +23 -23
  183. package/dist/react.d.cts +7 -9
  184. package/dist/react.d.ts +7 -9
  185. package/dist/social.cjs +32 -20
  186. package/dist/social.d.cts +1 -1
  187. package/dist/social.d.ts +1 -1
  188. package/dist/social.js +3 -3
  189. package/dist/solid.d.cts +7 -7
  190. package/dist/solid.d.ts +7 -7
  191. package/dist/{state-Cm8el5M1.d.ts → state-CLmFUxz3.d.ts} +1 -1
  192. package/dist/{state-DcraY2_H.d.cts → state-CZgzjtR5.d.cts} +1 -1
  193. package/dist/svelte-kit.d.cts +2 -2
  194. package/dist/svelte-kit.d.ts +2 -2
  195. package/dist/svelte.d.cts +7 -7
  196. package/dist/svelte.d.ts +7 -7
  197. package/dist/types.d.cts +4 -4
  198. package/dist/types.d.ts +4 -4
  199. package/dist/vue.d.cts +7 -7
  200. package/dist/vue.d.ts +7 -7
  201. package/package.json +4 -4
  202. package/dist/chunk-4WCY4Y5J.js +0 -173
  203. package/dist/chunk-5AZFOKWY.cjs +0 -176
  204. package/dist/index-CvlKSqnF.d.cts +0 -4023
  205. package/dist/index-Ivs2EsUL.d.ts +0 -4023
@@ -1,9 +1,9 @@
1
1
  import * as better_call from 'better-call';
2
2
  import { z } from 'zod';
3
- import { U as User, I as InferOptionSchema } from '../auth-D4rdpxtI.cjs';
3
+ import { U as User, I as InferOptionSchema } from '../auth-lDfjrjVd.cjs';
4
4
  import 'kysely';
5
5
  import '../helper-Bi8FQwDD.cjs';
6
- import '../index-Ba5bMY6A.cjs';
6
+ import '../index-BuRgaJZR.cjs';
7
7
  import 'jose';
8
8
  import 'better-sqlite3';
9
9
 
@@ -28,6 +28,17 @@ interface PhoneNumberOptions {
28
28
  phoneNumber: string;
29
29
  code: string;
30
30
  }, request?: Request) => Promise<void> | void;
31
+ /**
32
+ * a callback to send otp on user requesting to reset their password
33
+ *
34
+ * @param data - contains phone number and code
35
+ * @param request - the request object
36
+ * @returns
37
+ */
38
+ sendForgetPasswordOTP?: (data: {
39
+ phoneNumber: string;
40
+ code: string;
41
+ }, request?: Request) => Promise<void> | void;
31
42
  /**
32
43
  * Expiry time of the OTP code in seconds
33
44
  * @default 300
@@ -44,7 +55,7 @@ interface PhoneNumberOptions {
44
55
  */
45
56
  callbackOnVerification?: (data: {
46
57
  phoneNumber: string;
47
- user: UserWithPhoneNumber | null;
58
+ user: UserWithPhoneNumber;
48
59
  }, request?: Request) => void | Promise<void>;
49
60
  /**
50
61
  * Sign up user after phone number verification
@@ -83,7 +94,7 @@ declare const phoneNumber: (options?: PhoneNumberOptions) => {
83
94
  id: "phone-number";
84
95
  endpoints: {
85
96
  signInPhoneNumber: {
86
- <Context extends {
97
+ <C extends [{
87
98
  body: {
88
99
  password: string;
89
100
  phoneNumber: string;
@@ -98,7 +109,11 @@ declare const phoneNumber: (options?: PhoneNumberOptions) => {
98
109
  returnHeaders?: boolean | undefined;
99
110
  use?: better_call.Middleware[] | undefined;
100
111
  path?: string | undefined;
101
- }>(...inputCtx: better_call.HasRequiredKeys<Context> extends true ? [Context] : [(Context | undefined)?]): Promise<Context["asResponse"] extends true ? Response : Context["returnHeaders"] extends true ? {
112
+ }]>(...inputCtx: C): Promise<C extends [{
113
+ asResponse: true;
114
+ }] ? Response : C extends [{
115
+ returnHeaders: true;
116
+ }] ? {
102
117
  headers: Headers;
103
118
  response: {
104
119
  token: string;
@@ -158,7 +173,7 @@ declare const phoneNumber: (options?: PhoneNumberOptions) => {
158
173
  path: "/sign-in/phone-number";
159
174
  };
160
175
  sendPhoneNumberOTP: {
161
- <Context extends {
176
+ <C extends [{
162
177
  body: {
163
178
  phoneNumber: string;
164
179
  };
@@ -171,7 +186,11 @@ declare const phoneNumber: (options?: PhoneNumberOptions) => {
171
186
  returnHeaders?: boolean | undefined;
172
187
  use?: better_call.Middleware[] | undefined;
173
188
  path?: string | undefined;
174
- }>(...inputCtx: better_call.HasRequiredKeys<Context> extends true ? [Context] : [(Context | undefined)?]): Promise<Context["asResponse"] extends true ? Response : Context["returnHeaders"] extends true ? {
189
+ }]>(...inputCtx: C): Promise<C extends [{
190
+ asResponse: true;
191
+ }] ? Response : C extends [{
192
+ returnHeaders: true;
193
+ }] ? {
175
194
  headers: Headers;
176
195
  response: {
177
196
  code: string;
@@ -217,7 +236,7 @@ declare const phoneNumber: (options?: PhoneNumberOptions) => {
217
236
  path: "/phone-number/send-otp";
218
237
  };
219
238
  verifyPhoneNumber: {
220
- <Context extends {
239
+ <C extends [{
221
240
  body: {
222
241
  code: string;
223
242
  phoneNumber: string;
@@ -233,7 +252,11 @@ declare const phoneNumber: (options?: PhoneNumberOptions) => {
233
252
  returnHeaders?: boolean | undefined;
234
253
  use?: better_call.Middleware[] | undefined;
235
254
  path?: string | undefined;
236
- }>(...inputCtx: better_call.HasRequiredKeys<Context> extends true ? [Context] : [(Context | undefined)?]): Promise<Context["asResponse"] extends true ? Response : Context["returnHeaders"] extends true ? {
255
+ }]>(...inputCtx: C): Promise<C extends [{
256
+ asResponse: true;
257
+ }] ? Response : C extends [{
258
+ returnHeaders: true;
259
+ }] ? {
237
260
  headers: Headers;
238
261
  response: {
239
262
  status: boolean;
@@ -320,6 +343,94 @@ declare const phoneNumber: (options?: PhoneNumberOptions) => {
320
343
  };
321
344
  path: "/phone-number/verify";
322
345
  };
346
+ forgetPasswordPhoneNumber: {
347
+ <C extends [{
348
+ body: {
349
+ phoneNumber: string;
350
+ };
351
+ method?: "POST" | undefined;
352
+ query?: Record<string, any> | undefined;
353
+ params?: Record<string, any> | undefined;
354
+ request?: Request | undefined;
355
+ headers?: HeadersInit | undefined;
356
+ asResponse?: boolean | undefined;
357
+ returnHeaders?: boolean | undefined;
358
+ use?: better_call.Middleware[] | undefined;
359
+ path?: string | undefined;
360
+ }]>(...inputCtx: C): Promise<C extends [{
361
+ asResponse: true;
362
+ }] ? Response : C extends [{
363
+ returnHeaders: true;
364
+ }] ? {
365
+ headers: Headers;
366
+ response: {
367
+ status: boolean;
368
+ };
369
+ } : {
370
+ status: boolean;
371
+ }>;
372
+ options: {
373
+ method: "POST";
374
+ body: z.ZodObject<{
375
+ phoneNumber: z.ZodString;
376
+ }, "strip", z.ZodTypeAny, {
377
+ phoneNumber: string;
378
+ }, {
379
+ phoneNumber: string;
380
+ }>;
381
+ } & {
382
+ use: any[];
383
+ };
384
+ path: "/phone-number/forget-password";
385
+ };
386
+ resetPasswordPhoneNumber: {
387
+ <C extends [{
388
+ body: {
389
+ newPassword: string;
390
+ otp: string;
391
+ phoneNumber: string;
392
+ };
393
+ method?: "POST" | undefined;
394
+ query?: Record<string, any> | undefined;
395
+ params?: Record<string, any> | undefined;
396
+ request?: Request | undefined;
397
+ headers?: HeadersInit | undefined;
398
+ asResponse?: boolean | undefined;
399
+ returnHeaders?: boolean | undefined;
400
+ use?: better_call.Middleware[] | undefined;
401
+ path?: string | undefined;
402
+ }]>(...inputCtx: C): Promise<C extends [{
403
+ asResponse: true;
404
+ }] ? Response : C extends [{
405
+ returnHeaders: true;
406
+ }] ? {
407
+ headers: Headers;
408
+ response: {
409
+ status: boolean;
410
+ };
411
+ } : {
412
+ status: boolean;
413
+ }>;
414
+ options: {
415
+ method: "POST";
416
+ body: z.ZodObject<{
417
+ otp: z.ZodString;
418
+ phoneNumber: z.ZodString;
419
+ newPassword: z.ZodString;
420
+ }, "strip", z.ZodTypeAny, {
421
+ newPassword: string;
422
+ otp: string;
423
+ phoneNumber: string;
424
+ }, {
425
+ newPassword: string;
426
+ otp: string;
427
+ phoneNumber: string;
428
+ }>;
429
+ } & {
430
+ use: any[];
431
+ };
432
+ path: "/phone-number/reset-password";
433
+ };
323
434
  };
324
435
  schema: {
325
436
  user: {
@@ -345,6 +456,8 @@ declare const phoneNumber: (options?: PhoneNumberOptions) => {
345
456
  readonly INVALID_PHONE_NUMBER_OR_PASSWORD: "Invalid phone number or password";
346
457
  readonly UNEXPECTED_ERROR: "Unexpected error";
347
458
  readonly OTP_NOT_FOUND: "OTP not found";
459
+ readonly OTP_EXPIRED: "OTP expired";
460
+ readonly INVALID_OTP: "Invalid OTP";
348
461
  };
349
462
  };
350
463
  declare const schema: {
@@ -1,9 +1,9 @@
1
1
  import * as better_call from 'better-call';
2
2
  import { z } from 'zod';
3
- import { U as User, I as InferOptionSchema } from '../auth-DcMc3BIq.js';
3
+ import { U as User, I as InferOptionSchema } from '../auth-C-uLTIcY.js';
4
4
  import 'kysely';
5
5
  import '../helper-Bi8FQwDD.js';
6
- import '../index-XrJz4AYF.js';
6
+ import '../index-moQjyfmm.js';
7
7
  import 'jose';
8
8
  import 'better-sqlite3';
9
9
 
@@ -28,6 +28,17 @@ interface PhoneNumberOptions {
28
28
  phoneNumber: string;
29
29
  code: string;
30
30
  }, request?: Request) => Promise<void> | void;
31
+ /**
32
+ * a callback to send otp on user requesting to reset their password
33
+ *
34
+ * @param data - contains phone number and code
35
+ * @param request - the request object
36
+ * @returns
37
+ */
38
+ sendForgetPasswordOTP?: (data: {
39
+ phoneNumber: string;
40
+ code: string;
41
+ }, request?: Request) => Promise<void> | void;
31
42
  /**
32
43
  * Expiry time of the OTP code in seconds
33
44
  * @default 300
@@ -44,7 +55,7 @@ interface PhoneNumberOptions {
44
55
  */
45
56
  callbackOnVerification?: (data: {
46
57
  phoneNumber: string;
47
- user: UserWithPhoneNumber | null;
58
+ user: UserWithPhoneNumber;
48
59
  }, request?: Request) => void | Promise<void>;
49
60
  /**
50
61
  * Sign up user after phone number verification
@@ -83,7 +94,7 @@ declare const phoneNumber: (options?: PhoneNumberOptions) => {
83
94
  id: "phone-number";
84
95
  endpoints: {
85
96
  signInPhoneNumber: {
86
- <Context extends {
97
+ <C extends [{
87
98
  body: {
88
99
  password: string;
89
100
  phoneNumber: string;
@@ -98,7 +109,11 @@ declare const phoneNumber: (options?: PhoneNumberOptions) => {
98
109
  returnHeaders?: boolean | undefined;
99
110
  use?: better_call.Middleware[] | undefined;
100
111
  path?: string | undefined;
101
- }>(...inputCtx: better_call.HasRequiredKeys<Context> extends true ? [Context] : [(Context | undefined)?]): Promise<Context["asResponse"] extends true ? Response : Context["returnHeaders"] extends true ? {
112
+ }]>(...inputCtx: C): Promise<C extends [{
113
+ asResponse: true;
114
+ }] ? Response : C extends [{
115
+ returnHeaders: true;
116
+ }] ? {
102
117
  headers: Headers;
103
118
  response: {
104
119
  token: string;
@@ -158,7 +173,7 @@ declare const phoneNumber: (options?: PhoneNumberOptions) => {
158
173
  path: "/sign-in/phone-number";
159
174
  };
160
175
  sendPhoneNumberOTP: {
161
- <Context extends {
176
+ <C extends [{
162
177
  body: {
163
178
  phoneNumber: string;
164
179
  };
@@ -171,7 +186,11 @@ declare const phoneNumber: (options?: PhoneNumberOptions) => {
171
186
  returnHeaders?: boolean | undefined;
172
187
  use?: better_call.Middleware[] | undefined;
173
188
  path?: string | undefined;
174
- }>(...inputCtx: better_call.HasRequiredKeys<Context> extends true ? [Context] : [(Context | undefined)?]): Promise<Context["asResponse"] extends true ? Response : Context["returnHeaders"] extends true ? {
189
+ }]>(...inputCtx: C): Promise<C extends [{
190
+ asResponse: true;
191
+ }] ? Response : C extends [{
192
+ returnHeaders: true;
193
+ }] ? {
175
194
  headers: Headers;
176
195
  response: {
177
196
  code: string;
@@ -217,7 +236,7 @@ declare const phoneNumber: (options?: PhoneNumberOptions) => {
217
236
  path: "/phone-number/send-otp";
218
237
  };
219
238
  verifyPhoneNumber: {
220
- <Context extends {
239
+ <C extends [{
221
240
  body: {
222
241
  code: string;
223
242
  phoneNumber: string;
@@ -233,7 +252,11 @@ declare const phoneNumber: (options?: PhoneNumberOptions) => {
233
252
  returnHeaders?: boolean | undefined;
234
253
  use?: better_call.Middleware[] | undefined;
235
254
  path?: string | undefined;
236
- }>(...inputCtx: better_call.HasRequiredKeys<Context> extends true ? [Context] : [(Context | undefined)?]): Promise<Context["asResponse"] extends true ? Response : Context["returnHeaders"] extends true ? {
255
+ }]>(...inputCtx: C): Promise<C extends [{
256
+ asResponse: true;
257
+ }] ? Response : C extends [{
258
+ returnHeaders: true;
259
+ }] ? {
237
260
  headers: Headers;
238
261
  response: {
239
262
  status: boolean;
@@ -320,6 +343,94 @@ declare const phoneNumber: (options?: PhoneNumberOptions) => {
320
343
  };
321
344
  path: "/phone-number/verify";
322
345
  };
346
+ forgetPasswordPhoneNumber: {
347
+ <C extends [{
348
+ body: {
349
+ phoneNumber: string;
350
+ };
351
+ method?: "POST" | undefined;
352
+ query?: Record<string, any> | undefined;
353
+ params?: Record<string, any> | undefined;
354
+ request?: Request | undefined;
355
+ headers?: HeadersInit | undefined;
356
+ asResponse?: boolean | undefined;
357
+ returnHeaders?: boolean | undefined;
358
+ use?: better_call.Middleware[] | undefined;
359
+ path?: string | undefined;
360
+ }]>(...inputCtx: C): Promise<C extends [{
361
+ asResponse: true;
362
+ }] ? Response : C extends [{
363
+ returnHeaders: true;
364
+ }] ? {
365
+ headers: Headers;
366
+ response: {
367
+ status: boolean;
368
+ };
369
+ } : {
370
+ status: boolean;
371
+ }>;
372
+ options: {
373
+ method: "POST";
374
+ body: z.ZodObject<{
375
+ phoneNumber: z.ZodString;
376
+ }, "strip", z.ZodTypeAny, {
377
+ phoneNumber: string;
378
+ }, {
379
+ phoneNumber: string;
380
+ }>;
381
+ } & {
382
+ use: any[];
383
+ };
384
+ path: "/phone-number/forget-password";
385
+ };
386
+ resetPasswordPhoneNumber: {
387
+ <C extends [{
388
+ body: {
389
+ newPassword: string;
390
+ otp: string;
391
+ phoneNumber: string;
392
+ };
393
+ method?: "POST" | undefined;
394
+ query?: Record<string, any> | undefined;
395
+ params?: Record<string, any> | undefined;
396
+ request?: Request | undefined;
397
+ headers?: HeadersInit | undefined;
398
+ asResponse?: boolean | undefined;
399
+ returnHeaders?: boolean | undefined;
400
+ use?: better_call.Middleware[] | undefined;
401
+ path?: string | undefined;
402
+ }]>(...inputCtx: C): Promise<C extends [{
403
+ asResponse: true;
404
+ }] ? Response : C extends [{
405
+ returnHeaders: true;
406
+ }] ? {
407
+ headers: Headers;
408
+ response: {
409
+ status: boolean;
410
+ };
411
+ } : {
412
+ status: boolean;
413
+ }>;
414
+ options: {
415
+ method: "POST";
416
+ body: z.ZodObject<{
417
+ otp: z.ZodString;
418
+ phoneNumber: z.ZodString;
419
+ newPassword: z.ZodString;
420
+ }, "strip", z.ZodTypeAny, {
421
+ newPassword: string;
422
+ otp: string;
423
+ phoneNumber: string;
424
+ }, {
425
+ newPassword: string;
426
+ otp: string;
427
+ phoneNumber: string;
428
+ }>;
429
+ } & {
430
+ use: any[];
431
+ };
432
+ path: "/phone-number/reset-password";
433
+ };
323
434
  };
324
435
  schema: {
325
436
  user: {
@@ -345,6 +456,8 @@ declare const phoneNumber: (options?: PhoneNumberOptions) => {
345
456
  readonly INVALID_PHONE_NUMBER_OR_PASSWORD: "Invalid phone number or password";
346
457
  readonly UNEXPECTED_ERROR: "Unexpected error";
347
458
  readonly OTP_NOT_FOUND: "OTP not found";
459
+ readonly OTP_EXPIRED: "OTP expired";
460
+ readonly INVALID_OTP: "Invalid OTP";
348
461
  };
349
462
  };
350
463
  declare const schema: {
@@ -1,12 +1,12 @@
1
- export { phoneNumber } from '../chunk-BKFMDM3P.js';
2
- import '../chunk-3EY3LSQR.js';
3
- import '../chunk-VXDYNCOX.js';
4
- import '../chunk-GTQM7JU7.js';
1
+ export { phoneNumber } from '../chunk-HRI7BYTU.js';
2
+ import '../chunk-IVS5VS3V.js';
3
+ import '../chunk-TODG5RSV.js';
4
+ import '../chunk-R42K7GPF.js';
5
5
  import '../chunk-XFCIANZX.js';
6
6
  import '../chunk-QQGZ3XGI.js';
7
- import '../chunk-HZBNUY7E.js';
7
+ import '../chunk-WZ6OIVJK.js';
8
8
  import '../chunk-KLDFBLYL.js';
9
- import '../chunk-NPO64SVN.js';
9
+ import '../chunk-ZFUBVSZD.js';
10
10
  import '../chunk-3XTQSPPA.js';
11
11
  import '../chunk-DBPOZRMS.js';
12
12
  import '../chunk-53IPO2PJ.js';
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var chunkPIWBUHRB_cjs = require('../chunk-PIWBUHRB.cjs');
4
- require('../chunk-NU4SXYJ5.cjs');
5
- var chunkV6RGXSG4_cjs = require('../chunk-V6RGXSG4.cjs');
3
+ var chunkUPQLFVFU_cjs = require('../chunk-UPQLFVFU.cjs');
4
+ require('../chunk-JDAHD767.cjs');
5
+ var chunkSVC7H7K4_cjs = require('../chunk-SVC7H7K4.cjs');
6
6
  require('../chunk-S5UORXJH.cjs');
7
7
  var chunkV6HE2MP7_cjs = require('../chunk-V6HE2MP7.cjs');
8
- require('../chunk-B5UCLTPZ.cjs');
8
+ require('../chunk-UQC2FUXC.cjs');
9
9
  require('../chunk-H74YRRNV.cjs');
10
- var chunk5E75URIA_cjs = require('../chunk-5E75URIA.cjs');
10
+ var chunk2Z6CVQHH_cjs = require('../chunk-2Z6CVQHH.cjs');
11
11
  require('../chunk-CCKQSGIR.cjs');
12
12
  require('../chunk-G2LZ73E2.cjs');
13
13
  require('../chunk-OA7Z7IZT.cjs');
@@ -22,7 +22,7 @@ var sso = (options) => {
22
22
  return {
23
23
  id: "sso",
24
24
  endpoints: {
25
- createOIDCProvider: chunkPIWBUHRB_cjs.createAuthEndpoint(
25
+ createOIDCProvider: chunkUPQLFVFU_cjs.createAuthEndpoint(
26
26
  "/sso/register",
27
27
  {
28
28
  method: "POST",
@@ -84,7 +84,7 @@ var sso = (options) => {
84
84
  description: "If organization plugin is enabled, the organization id to link the provider to"
85
85
  }).optional()
86
86
  }),
87
- use: [chunkPIWBUHRB_cjs.sessionMiddleware],
87
+ use: [chunkUPQLFVFU_cjs.sessionMiddleware],
88
88
  metadata: {
89
89
  openapi: {
90
90
  summary: "Register an OIDC provider",
@@ -101,7 +101,7 @@ var sso = (options) => {
101
101
  const body = ctx.body;
102
102
  const issuerValidator = zod.z.string().url();
103
103
  if (issuerValidator.safeParse(body.issuer).error) {
104
- throw new chunkPIWBUHRB_cjs.APIError("BAD_REQUEST", {
104
+ throw new chunkUPQLFVFU_cjs.APIError("BAD_REQUEST", {
105
105
  message: "Invalid issuer. Must be a valid URL"
106
106
  });
107
107
  }
@@ -136,7 +136,7 @@ var sso = (options) => {
136
136
  });
137
137
  }
138
138
  ),
139
- signInSSO: chunkPIWBUHRB_cjs.createAuthEndpoint(
139
+ signInSSO: chunkUPQLFVFU_cjs.createAuthEndpoint(
140
140
  "/sign-in/sso",
141
141
  {
142
142
  method: "POST",
@@ -158,6 +158,9 @@ var sso = (options) => {
158
158
  }).optional(),
159
159
  newUserCallbackURL: zod.z.string({
160
160
  description: "The URL to redirect to after login if the user is new"
161
+ }).optional(),
162
+ scopes: zod.z.array(zod.z.string(), {
163
+ description: "Scopes to request from the provider."
161
164
  }).optional()
162
165
  }),
163
166
  metadata: {
@@ -207,7 +210,7 @@ var sso = (options) => {
207
210
  const body = ctx.body;
208
211
  let { email, organizationSlug, domain } = body;
209
212
  if (!email && !organizationSlug && !domain) {
210
- throw new chunkPIWBUHRB_cjs.APIError("BAD_REQUEST", {
213
+ throw new chunkUPQLFVFU_cjs.APIError("BAD_REQUEST", {
211
214
  message: "email, organizationSlug or domain is required"
212
215
  });
213
216
  }
@@ -247,13 +250,13 @@ var sso = (options) => {
247
250
  };
248
251
  });
249
252
  if (!provider) {
250
- throw new chunkPIWBUHRB_cjs.APIError("NOT_FOUND", {
253
+ throw new chunkUPQLFVFU_cjs.APIError("NOT_FOUND", {
251
254
  message: "No provider found for the issuer"
252
255
  });
253
256
  }
254
- const state = await chunk5E75URIA_cjs.generateState(ctx);
257
+ const state = await chunk2Z6CVQHH_cjs.generateState(ctx);
255
258
  const redirectURI = `${ctx.context.baseURL}/sso/callback/${provider.providerId}`;
256
- const authorizationURL = await chunkV6RGXSG4_cjs.createAuthorizationURL({
259
+ const authorizationURL = await chunkSVC7H7K4_cjs.createAuthorizationURL({
257
260
  id: provider.issuer,
258
261
  options: {
259
262
  clientId: provider.oidcConfig.clientId,
@@ -262,7 +265,12 @@ var sso = (options) => {
262
265
  redirectURI,
263
266
  state: state.state,
264
267
  codeVerifier: provider.oidcConfig.pkce ? state.codeVerifier : void 0,
265
- scopes: ["openid", "email", "profile", "offline_access"],
268
+ scopes: ctx.body.scopes || [
269
+ "openid",
270
+ "email",
271
+ "profile",
272
+ "offline_access"
273
+ ],
266
274
  authorizationEndpoint: provider.oidcConfig.authorizationEndpoint
267
275
  });
268
276
  return ctx.json({
@@ -271,7 +279,7 @@ var sso = (options) => {
271
279
  });
272
280
  }
273
281
  ),
274
- callbackSSO: chunkPIWBUHRB_cjs.createAuthEndpoint(
282
+ callbackSSO: chunkUPQLFVFU_cjs.createAuthEndpoint(
275
283
  "/sso/callback/:providerId",
276
284
  {
277
285
  method: "GET",
@@ -296,7 +304,7 @@ var sso = (options) => {
296
304
  },
297
305
  async (ctx) => {
298
306
  const { code, state, error, error_description } = ctx.query;
299
- const stateData = await chunk5E75URIA_cjs.parseState(ctx);
307
+ const stateData = await chunk2Z6CVQHH_cjs.parseState(ctx);
300
308
  if (!stateData) {
301
309
  throw ctx.redirect(
302
310
  `${ctx.context.baseURL}/error?error=invalid_state`
@@ -346,7 +354,7 @@ var sso = (options) => {
346
354
  `${errorURL || callbackURL}/error?error=invalid_provider&error_description=token_endpoint_not_found`
347
355
  );
348
356
  }
349
- const tokenResponse = await chunkV6RGXSG4_cjs.validateAuthorizationCode({
357
+ const tokenResponse = await chunkSVC7H7K4_cjs.validateAuthorizationCode({
350
358
  code,
351
359
  codeVerifier: provider.oidcConfig.pkce ? stateData.codeVerifier : void 0,
352
360
  redirectURI: `${ctx.context.baseURL}/sso/callback/${provider.providerId}`,
@@ -377,7 +385,7 @@ var sso = (options) => {
377
385
  `${errorURL || callbackURL}/error?error=invalid_provider&error_description=jwks_endpoint_not_found`
378
386
  );
379
387
  }
380
- const verified = await chunkV6RGXSG4_cjs.validateToken(
388
+ const verified = await chunkSVC7H7K4_cjs.validateToken(
381
389
  tokenResponse.idToken,
382
390
  config.jwksEndpoint
383
391
  ).catch((e) => {
@@ -431,7 +439,7 @@ var sso = (options) => {
431
439
  `${errorURL || callbackURL}/error?error=invalid_provider&error_description=missing_user_info`
432
440
  );
433
441
  }
434
- const linked = await chunkPIWBUHRB_cjs.handleOAuthUserInfo(ctx, {
442
+ const linked = await chunkUPQLFVFU_cjs.handleOAuthUserInfo(ctx, {
435
443
  userInfo: {
436
444
  email: userInfo.email,
437
445
  name: userInfo.name || userInfo.email,
@@ -1,7 +1,7 @@
1
1
  import * as better_call from 'better-call';
2
2
  import { z } from 'zod';
3
- import { a as OAuth2Tokens } from '../index-Ba5bMY6A.cjs';
4
- import { U as User } from '../auth-D4rdpxtI.cjs';
3
+ import { a as OAuth2Tokens } from '../index-BuRgaJZR.cjs';
4
+ import { U as User } from '../auth-lDfjrjVd.cjs';
5
5
  import '../helper-Bi8FQwDD.cjs';
6
6
  import 'jose';
7
7
  import 'kysely';
@@ -59,7 +59,7 @@ declare const sso: (options?: SSOOptions) => {
59
59
  id: "sso";
60
60
  endpoints: {
61
61
  createOIDCProvider: {
62
- <Context extends {
62
+ <C extends [{
63
63
  body: {
64
64
  providerId: string;
65
65
  domain: string;
@@ -93,7 +93,11 @@ declare const sso: (options?: SSOOptions) => {
93
93
  returnHeaders?: boolean | undefined;
94
94
  use?: better_call.Middleware[] | undefined;
95
95
  path?: string | undefined;
96
- }>(...inputCtx: better_call.HasRequiredKeys<Context> extends true ? [Context] : [(Context | undefined)?]): Promise<Context["asResponse"] extends true ? Response : Context["returnHeaders"] extends true ? {
96
+ }]>(...inputCtx: C): Promise<C extends [{
97
+ asResponse: true;
98
+ }] ? Response : C extends [{
99
+ returnHeaders: true;
100
+ }] ? {
97
101
  headers: Headers;
98
102
  response: {
99
103
  oidcConfig: OIDCConfig;
@@ -247,11 +251,12 @@ declare const sso: (options?: SSOOptions) => {
247
251
  path: "/sso/register";
248
252
  };
249
253
  signInSSO: {
250
- <Context extends {
254
+ <C extends [{
251
255
  body: {
252
256
  callbackURL: string;
253
257
  email?: string | undefined;
254
258
  domain?: string | undefined;
259
+ scopes?: string[] | undefined;
255
260
  errorCallbackURL?: string | undefined;
256
261
  newUserCallbackURL?: string | undefined;
257
262
  organizationSlug?: string | undefined;
@@ -265,7 +270,11 @@ declare const sso: (options?: SSOOptions) => {
265
270
  returnHeaders?: boolean | undefined;
266
271
  use?: better_call.Middleware[] | undefined;
267
272
  path?: string | undefined;
268
- }>(...inputCtx: better_call.HasRequiredKeys<Context> extends true ? [Context] : [(Context | undefined)?]): Promise<Context["asResponse"] extends true ? Response : Context["returnHeaders"] extends true ? {
273
+ }]>(...inputCtx: C): Promise<C extends [{
274
+ asResponse: true;
275
+ }] ? Response : C extends [{
276
+ returnHeaders: true;
277
+ }] ? {
269
278
  headers: Headers;
270
279
  response: {
271
280
  url: string;
@@ -284,10 +293,12 @@ declare const sso: (options?: SSOOptions) => {
284
293
  callbackURL: z.ZodString;
285
294
  errorCallbackURL: z.ZodOptional<z.ZodString>;
286
295
  newUserCallbackURL: z.ZodOptional<z.ZodString>;
296
+ scopes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
287
297
  }, "strip", z.ZodTypeAny, {
288
298
  callbackURL: string;
289
299
  email?: string | undefined;
290
300
  domain?: string | undefined;
301
+ scopes?: string[] | undefined;
291
302
  errorCallbackURL?: string | undefined;
292
303
  newUserCallbackURL?: string | undefined;
293
304
  organizationSlug?: string | undefined;
@@ -295,6 +306,7 @@ declare const sso: (options?: SSOOptions) => {
295
306
  callbackURL: string;
296
307
  email?: string | undefined;
297
308
  domain?: string | undefined;
309
+ scopes?: string[] | undefined;
298
310
  errorCallbackURL?: string | undefined;
299
311
  newUserCallbackURL?: string | undefined;
300
312
  organizationSlug?: string | undefined;
@@ -347,7 +359,7 @@ declare const sso: (options?: SSOOptions) => {
347
359
  path: "/sign-in/sso";
348
360
  };
349
361
  callbackSSO: {
350
- <Context extends {
362
+ <C extends [{
351
363
  query: {
352
364
  state: string;
353
365
  code?: string | undefined;
@@ -365,7 +377,11 @@ declare const sso: (options?: SSOOptions) => {
365
377
  returnHeaders?: boolean | undefined;
366
378
  use?: better_call.Middleware[] | undefined;
367
379
  path?: string | undefined;
368
- }>(...inputCtx: better_call.HasRequiredKeys<Context> extends true ? [Context] : [(Context | undefined)?]): Promise<Context["asResponse"] extends true ? Response : Context["returnHeaders"] extends true ? {
380
+ }]>(...inputCtx: C): Promise<C extends [{
381
+ asResponse: true;
382
+ }] ? Response : C extends [{
383
+ returnHeaders: true;
384
+ }] ? {
369
385
  headers: Headers;
370
386
  response: never;
371
387
  } : never>;