better-auth 1.2.0-beta.5 → 1.2.0-beta.6
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/adapters/drizzle.cjs +3 -3
- package/dist/adapters/drizzle.d.cts +1 -1
- package/dist/adapters/drizzle.d.ts +1 -1
- package/dist/adapters/drizzle.js +1 -1
- package/dist/adapters/kysely.cjs +3 -3
- package/dist/adapters/kysely.d.cts +1 -1
- package/dist/adapters/kysely.d.ts +1 -1
- package/dist/adapters/kysely.js +1 -1
- package/dist/adapters/memory.cjs +2 -2
- package/dist/adapters/memory.d.cts +1 -1
- package/dist/adapters/memory.d.ts +1 -1
- package/dist/adapters/memory.js +1 -1
- package/dist/adapters/mongodb.cjs +3 -3
- package/dist/adapters/mongodb.d.cts +1 -1
- package/dist/adapters/mongodb.d.ts +1 -1
- package/dist/adapters/mongodb.js +1 -1
- package/dist/adapters/prisma.cjs +3 -3
- package/dist/adapters/prisma.d.cts +1 -1
- package/dist/adapters/prisma.d.ts +1 -1
- package/dist/adapters/prisma.js +1 -1
- package/dist/adapters/test.d.cts +1 -1
- package/dist/adapters/test.d.ts +1 -1
- package/dist/api.cjs +41 -41
- package/dist/api.d.cts +1 -1
- package/dist/api.d.ts +1 -1
- package/dist/api.js +1 -1
- package/dist/{auth-BIKkqX3w.d.ts → auth-BfbTouIV.d.ts} +5 -5
- package/dist/{auth-DYJ8ix3G.d.cts → auth-CC4kpwks.d.cts} +5 -5
- package/dist/{chunk-7P2P7Y35.js → chunk-2F3IX7O2.js} +1 -1
- package/dist/{chunk-VG5Y5QXC.js → chunk-4KMR5H5T.js} +1 -1
- package/dist/{chunk-XXGFGD3E.js → chunk-52TDJNDX.js} +11 -10
- package/dist/{chunk-YTMPZIP7.js → chunk-5AOJMBJI.js} +25 -3
- package/dist/{chunk-HQFWDJO3.cjs → chunk-5ECP2UE2.cjs} +5 -5
- package/dist/{chunk-VLA6IUW4.js → chunk-5G6XUCMS.js} +51 -2
- package/dist/{chunk-7H42DKFN.cjs → chunk-5KTUVZ3H.cjs} +5 -5
- package/dist/{chunk-QBBUTLKA.cjs → chunk-5RR5WN52.cjs} +5 -5
- package/dist/{chunk-XWK7ZOPU.cjs → chunk-75SPUXMY.cjs} +8 -8
- package/dist/{chunk-5LTLUS6A.js → chunk-BZOIXJ2Q.js} +1 -1
- package/dist/{chunk-SOFKSYNA.js → chunk-CG2CK6HR.js} +1 -1
- package/dist/{chunk-YZFX73MG.cjs → chunk-DURU7ZRA.cjs} +20 -20
- package/dist/{chunk-CLHJAEU2.js → chunk-EQYRCOOF.js} +5 -2
- package/dist/{chunk-IBIVHEIM.js → chunk-FX2ZHENM.js} +1 -1
- package/dist/{chunk-G6W6UQWJ.js → chunk-GWJDRQJ3.js} +2 -2
- package/dist/{chunk-C5LREWPU.cjs → chunk-HUDPJXOF.cjs} +24 -24
- package/dist/{chunk-DSB4P3WF.cjs → chunk-IUGQVFPG.cjs} +6 -6
- package/dist/{chunk-K46S33M5.cjs → chunk-K6WRBJAV.cjs} +3 -3
- package/dist/{chunk-C37NPGBI.cjs → chunk-KAEQXMEV.cjs} +46 -46
- package/dist/{chunk-CV5JTF37.cjs → chunk-KAR56MJZ.cjs} +5 -2
- package/dist/{chunk-6FRITF4C.cjs → chunk-LIGJVOZ4.cjs} +4 -4
- package/dist/{chunk-WKBV4PRW.cjs → chunk-MKNDCNWD.cjs} +3 -3
- package/dist/{chunk-WKXM7XUV.cjs → chunk-N7UWN6ND.cjs} +16 -4
- package/dist/{chunk-TV24P5IW.cjs → chunk-OALLKKNX.cjs} +52 -30
- package/dist/{chunk-3BXU3Z5H.js → chunk-QKCLO6S5.js} +1 -1
- package/dist/{chunk-E3CHTKRP.js → chunk-QLKU77BF.js} +1 -1
- package/dist/{chunk-CYI7H6T2.js → chunk-RMPI2YZ3.js} +1 -1
- package/dist/{chunk-R62AOMGV.js → chunk-SCXZXQTZ.js} +16 -4
- package/dist/{chunk-G365UCY7.js → chunk-ST2CQ4A2.js} +2 -2
- package/dist/{chunk-5RIBF22K.cjs → chunk-U44XLDNH.cjs} +22 -21
- package/dist/{chunk-OLGASOBP.cjs → chunk-UZNKBUDH.cjs} +11 -11
- package/dist/{chunk-7S7YLBK4.js → chunk-V56HFQQX.js} +1 -1
- package/dist/{chunk-HCHSHY7R.cjs → chunk-WD65CNWK.cjs} +77 -28
- package/dist/{chunk-H4A3GCFC.cjs → chunk-XKCN2VRG.cjs} +5 -5
- package/dist/{chunk-QG2HKEKG.js → chunk-XREMX2NV.js} +1 -1
- package/dist/{chunk-MHZNWING.js → chunk-ZDYKAJ67.js} +110 -2
- package/dist/{chunk-6QI5735F.js → chunk-ZKMUJOIP.js} +1 -1
- package/dist/{chunk-LHWLPZ6K.cjs → chunk-ZUUQ3FFY.cjs} +113 -5
- package/dist/client/plugins.d.cts +2 -2
- package/dist/client/plugins.d.ts +2 -2
- package/dist/client.d.cts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/cookies.d.cts +1 -1
- package/dist/cookies.d.ts +1 -1
- package/dist/db.cjs +12 -12
- package/dist/db.d.cts +2 -2
- package/dist/db.d.ts +2 -2
- package/dist/db.js +1 -1
- package/dist/{index-DOB91DVD.d.ts → index-CtbEb8Ls.d.ts} +107 -1
- package/dist/{index-BL6paKGE.d.cts → index-F5NLq5XF.d.cts} +107 -1
- package/dist/index.cjs +11 -11
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/next-js.cjs +20 -20
- package/dist/next-js.d.cts +1 -1
- package/dist/next-js.d.ts +1 -1
- package/dist/next-js.js +19 -19
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/oauth2.d.cts +2 -2
- package/dist/oauth2.d.ts +2 -2
- package/dist/plugins/admin.cjs +3 -3
- package/dist/plugins/admin.d.cts +64 -8
- package/dist/plugins/admin.d.ts +64 -8
- package/dist/plugins/admin.js +2 -2
- package/dist/plugins/anonymous.cjs +3 -3
- package/dist/plugins/anonymous.d.cts +1 -1
- package/dist/plugins/anonymous.d.ts +1 -1
- package/dist/plugins/anonymous.js +2 -2
- package/dist/plugins/bearer.cjs +3 -3
- package/dist/plugins/bearer.d.cts +1 -1
- package/dist/plugins/bearer.d.ts +1 -1
- package/dist/plugins/bearer.js +2 -2
- package/dist/plugins/custom-session.cjs +3 -3
- package/dist/plugins/custom-session.d.cts +1 -1
- package/dist/plugins/custom-session.d.ts +1 -1
- package/dist/plugins/custom-session.js +2 -2
- package/dist/plugins/email-otp.cjs +3 -3
- package/dist/plugins/email-otp.d.cts +1 -1
- package/dist/plugins/email-otp.d.ts +1 -1
- package/dist/plugins/email-otp.js +2 -2
- package/dist/plugins/generic-oauth.cjs +3 -3
- package/dist/plugins/generic-oauth.d.cts +74 -1
- package/dist/plugins/generic-oauth.d.ts +74 -1
- package/dist/plugins/generic-oauth.js +2 -2
- package/dist/plugins/jwt.cjs +3 -3
- package/dist/plugins/jwt.d.cts +1 -1
- package/dist/plugins/jwt.d.ts +1 -1
- package/dist/plugins/jwt.js +2 -2
- package/dist/plugins/magic-link.cjs +3 -3
- package/dist/plugins/magic-link.d.cts +4 -0
- package/dist/plugins/magic-link.d.ts +4 -0
- package/dist/plugins/magic-link.js +2 -2
- package/dist/plugins/multi-session.cjs +3 -3
- package/dist/plugins/multi-session.d.cts +1 -1
- package/dist/plugins/multi-session.d.ts +1 -1
- package/dist/plugins/multi-session.js +2 -2
- package/dist/plugins/oidc-provider.cjs +3 -3
- package/dist/plugins/oidc-provider.js +2 -2
- package/dist/plugins/one-tap.cjs +3 -3
- package/dist/plugins/one-tap.js +2 -2
- package/dist/plugins/open-api.cjs +4 -4
- package/dist/plugins/open-api.d.cts +1 -1
- package/dist/plugins/open-api.d.ts +1 -1
- package/dist/plugins/open-api.js +3 -3
- package/dist/plugins/organization.cjs +3 -3
- package/dist/plugins/organization.d.cts +2 -2
- package/dist/plugins/organization.d.ts +2 -2
- package/dist/plugins/organization.js +2 -2
- package/dist/plugins/passkey.cjs +14 -14
- package/dist/plugins/passkey.d.cts +1 -1
- package/dist/plugins/passkey.d.ts +1 -1
- package/dist/plugins/passkey.js +1 -1
- package/dist/plugins/phone-number.cjs +3 -3
- package/dist/plugins/phone-number.d.cts +2 -2
- package/dist/plugins/phone-number.d.ts +2 -2
- package/dist/plugins/phone-number.js +2 -2
- package/dist/plugins/sso.cjs +9 -9
- package/dist/plugins/sso.d.cts +1 -1
- package/dist/plugins/sso.d.ts +1 -1
- package/dist/plugins/sso.js +1 -1
- package/dist/plugins/two-factor.cjs +3 -3
- package/dist/plugins/two-factor.d.cts +1 -1
- package/dist/plugins/two-factor.d.ts +1 -1
- package/dist/plugins/two-factor.js +2 -2
- package/dist/plugins/username.cjs +3 -3
- package/dist/plugins/username.d.cts +1 -1
- package/dist/plugins/username.d.ts +1 -1
- package/dist/plugins/username.js +2 -2
- package/dist/plugins.cjs +39 -39
- package/dist/plugins.d.cts +3 -3
- package/dist/plugins.d.ts +3 -3
- package/dist/plugins.js +19 -19
- package/dist/react.d.cts +2 -3
- package/dist/react.d.ts +2 -3
- package/dist/solid.d.cts +1 -1
- package/dist/solid.d.ts +1 -1
- package/dist/{state-DXzHe8jb.d.ts → state-BlyN0kTT.d.ts} +1 -1
- package/dist/{state-CEqdZ_y_.d.cts → state-ClV1x8my.d.cts} +1 -1
- package/dist/svelte-kit.d.cts +1 -1
- package/dist/svelte-kit.d.ts +1 -1
- package/dist/svelte.d.cts +1 -1
- package/dist/svelte.d.ts +1 -1
- package/dist/types.d.cts +3 -3
- package/dist/types.d.ts +3 -3
- package/dist/vue.d.cts +1 -1
- package/dist/vue.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkJUPDDQC4_cjs = require('./chunk-JUPDDQC4.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunkN7UWN6ND_cjs = require('./chunk-N7UWN6ND.cjs');
|
|
5
5
|
var chunkV6HE2MP7_cjs = require('./chunk-V6HE2MP7.cjs');
|
|
6
6
|
var chunkG2LZ73E2_cjs = require('./chunk-G2LZ73E2.cjs');
|
|
7
7
|
var chunk2HPSCSV7_cjs = require('./chunk-2HPSCSV7.cjs');
|
|
@@ -23,7 +23,7 @@ var emailOTP = (options) => {
|
|
|
23
23
|
return {
|
|
24
24
|
id: "email-otp",
|
|
25
25
|
endpoints: {
|
|
26
|
-
sendVerificationOTP:
|
|
26
|
+
sendVerificationOTP: chunkN7UWN6ND_cjs.createAuthEndpoint(
|
|
27
27
|
"/email-otp/send-verification-otp",
|
|
28
28
|
{
|
|
29
29
|
method: "POST",
|
|
@@ -63,7 +63,7 @@ var emailOTP = (options) => {
|
|
|
63
63
|
ctx.context.logger.error(
|
|
64
64
|
"send email verification is not implemented"
|
|
65
65
|
);
|
|
66
|
-
throw new
|
|
66
|
+
throw new chunkN7UWN6ND_cjs.APIError("BAD_REQUEST", {
|
|
67
67
|
message: "send email verification is not implemented"
|
|
68
68
|
});
|
|
69
69
|
}
|
|
@@ -110,7 +110,7 @@ var emailOTP = (options) => {
|
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
112
|
),
|
|
113
|
-
createVerificationOTP:
|
|
113
|
+
createVerificationOTP: chunkN7UWN6ND_cjs.createAuthEndpoint(
|
|
114
114
|
"/email-otp/create-verification-otp",
|
|
115
115
|
{
|
|
116
116
|
method: "POST",
|
|
@@ -152,7 +152,7 @@ var emailOTP = (options) => {
|
|
|
152
152
|
return otp;
|
|
153
153
|
}
|
|
154
154
|
),
|
|
155
|
-
getVerificationOTP:
|
|
155
|
+
getVerificationOTP: chunkN7UWN6ND_cjs.createAuthEndpoint(
|
|
156
156
|
"/email-otp/get-verification-otp",
|
|
157
157
|
{
|
|
158
158
|
method: "GET",
|
|
@@ -201,7 +201,7 @@ var emailOTP = (options) => {
|
|
|
201
201
|
});
|
|
202
202
|
}
|
|
203
203
|
),
|
|
204
|
-
verifyEmailOTP:
|
|
204
|
+
verifyEmailOTP: chunkN7UWN6ND_cjs.createAuthEndpoint(
|
|
205
205
|
"/email-otp/verify-email",
|
|
206
206
|
{
|
|
207
207
|
method: "POST",
|
|
@@ -240,7 +240,7 @@ var emailOTP = (options) => {
|
|
|
240
240
|
const email = ctx.body.email;
|
|
241
241
|
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
|
242
242
|
if (!emailRegex.test(email)) {
|
|
243
|
-
throw new
|
|
243
|
+
throw new chunkN7UWN6ND_cjs.APIError("BAD_REQUEST", {
|
|
244
244
|
message: ERROR_CODES.INVALID_EMAIL
|
|
245
245
|
});
|
|
246
246
|
}
|
|
@@ -248,18 +248,18 @@ var emailOTP = (options) => {
|
|
|
248
248
|
`email-verification-otp-${email}`
|
|
249
249
|
);
|
|
250
250
|
if (!verificationValue) {
|
|
251
|
-
throw new
|
|
251
|
+
throw new chunkN7UWN6ND_cjs.APIError("BAD_REQUEST", {
|
|
252
252
|
message: ERROR_CODES.INVALID_OTP
|
|
253
253
|
});
|
|
254
254
|
}
|
|
255
255
|
if (verificationValue.expiresAt < /* @__PURE__ */ new Date()) {
|
|
256
|
-
throw new
|
|
256
|
+
throw new chunkN7UWN6ND_cjs.APIError("BAD_REQUEST", {
|
|
257
257
|
message: ERROR_CODES.OTP_EXPIRED
|
|
258
258
|
});
|
|
259
259
|
}
|
|
260
260
|
const otp = ctx.body.otp;
|
|
261
261
|
if (verificationValue.value !== otp) {
|
|
262
|
-
throw new
|
|
262
|
+
throw new chunkN7UWN6ND_cjs.APIError("BAD_REQUEST", {
|
|
263
263
|
message: ERROR_CODES.INVALID_OTP
|
|
264
264
|
});
|
|
265
265
|
}
|
|
@@ -268,7 +268,7 @@ var emailOTP = (options) => {
|
|
|
268
268
|
);
|
|
269
269
|
const user = await ctx.context.internalAdapter.findUserByEmail(email);
|
|
270
270
|
if (!user) {
|
|
271
|
-
throw new
|
|
271
|
+
throw new chunkN7UWN6ND_cjs.APIError("BAD_REQUEST", {
|
|
272
272
|
message: ERROR_CODES.USER_NOT_FOUND
|
|
273
273
|
});
|
|
274
274
|
}
|
|
@@ -317,7 +317,7 @@ var emailOTP = (options) => {
|
|
|
317
317
|
});
|
|
318
318
|
}
|
|
319
319
|
),
|
|
320
|
-
signInEmailOTP:
|
|
320
|
+
signInEmailOTP: chunkN7UWN6ND_cjs.createAuthEndpoint(
|
|
321
321
|
"/sign-in/email-otp",
|
|
322
322
|
{
|
|
323
323
|
method: "POST",
|
|
@@ -361,18 +361,18 @@ var emailOTP = (options) => {
|
|
|
361
361
|
`sign-in-otp-${email}`
|
|
362
362
|
);
|
|
363
363
|
if (!verificationValue) {
|
|
364
|
-
throw new
|
|
364
|
+
throw new chunkN7UWN6ND_cjs.APIError("BAD_REQUEST", {
|
|
365
365
|
message: ERROR_CODES.INVALID_OTP
|
|
366
366
|
});
|
|
367
367
|
}
|
|
368
368
|
if (verificationValue.expiresAt < /* @__PURE__ */ new Date()) {
|
|
369
|
-
throw new
|
|
369
|
+
throw new chunkN7UWN6ND_cjs.APIError("BAD_REQUEST", {
|
|
370
370
|
message: ERROR_CODES.OTP_EXPIRED
|
|
371
371
|
});
|
|
372
372
|
}
|
|
373
373
|
const otp = ctx.body.otp;
|
|
374
374
|
if (verificationValue.value !== otp) {
|
|
375
|
-
throw new
|
|
375
|
+
throw new chunkN7UWN6ND_cjs.APIError("BAD_REQUEST", {
|
|
376
376
|
message: ERROR_CODES.INVALID_OTP
|
|
377
377
|
});
|
|
378
378
|
}
|
|
@@ -382,7 +382,7 @@ var emailOTP = (options) => {
|
|
|
382
382
|
const user = await ctx.context.internalAdapter.findUserByEmail(email);
|
|
383
383
|
if (!user) {
|
|
384
384
|
if (opts.disableSignUp) {
|
|
385
|
-
throw new
|
|
385
|
+
throw new chunkN7UWN6ND_cjs.APIError("BAD_REQUEST", {
|
|
386
386
|
message: ERROR_CODES.USER_NOT_FOUND
|
|
387
387
|
});
|
|
388
388
|
}
|
|
@@ -439,7 +439,7 @@ var emailOTP = (options) => {
|
|
|
439
439
|
});
|
|
440
440
|
}
|
|
441
441
|
),
|
|
442
|
-
forgetPasswordEmailOTP:
|
|
442
|
+
forgetPasswordEmailOTP: chunkN7UWN6ND_cjs.createAuthEndpoint(
|
|
443
443
|
"/forget-password/email-otp",
|
|
444
444
|
{
|
|
445
445
|
method: "POST",
|
|
@@ -475,7 +475,7 @@ var emailOTP = (options) => {
|
|
|
475
475
|
const email = ctx.body.email;
|
|
476
476
|
const user = await ctx.context.internalAdapter.findUserByEmail(email);
|
|
477
477
|
if (!user) {
|
|
478
|
-
throw new
|
|
478
|
+
throw new chunkN7UWN6ND_cjs.APIError("BAD_REQUEST", {
|
|
479
479
|
message: ERROR_CODES.USER_NOT_FOUND
|
|
480
480
|
});
|
|
481
481
|
}
|
|
@@ -498,7 +498,7 @@ var emailOTP = (options) => {
|
|
|
498
498
|
});
|
|
499
499
|
}
|
|
500
500
|
),
|
|
501
|
-
resetPasswordEmailOTP:
|
|
501
|
+
resetPasswordEmailOTP: chunkN7UWN6ND_cjs.createAuthEndpoint(
|
|
502
502
|
"/email-otp/reset-password",
|
|
503
503
|
{
|
|
504
504
|
method: "POST",
|
|
@@ -545,7 +545,7 @@ var emailOTP = (options) => {
|
|
|
545
545
|
}
|
|
546
546
|
);
|
|
547
547
|
if (!user) {
|
|
548
|
-
throw new
|
|
548
|
+
throw new chunkN7UWN6ND_cjs.APIError("BAD_REQUEST", {
|
|
549
549
|
message: ERROR_CODES.USER_NOT_FOUND
|
|
550
550
|
});
|
|
551
551
|
}
|
|
@@ -553,18 +553,18 @@ var emailOTP = (options) => {
|
|
|
553
553
|
`forget-password-otp-${email}`
|
|
554
554
|
);
|
|
555
555
|
if (!verificationValue) {
|
|
556
|
-
throw new
|
|
556
|
+
throw new chunkN7UWN6ND_cjs.APIError("BAD_REQUEST", {
|
|
557
557
|
message: ERROR_CODES.INVALID_OTP
|
|
558
558
|
});
|
|
559
559
|
}
|
|
560
560
|
if (verificationValue.expiresAt < /* @__PURE__ */ new Date()) {
|
|
561
|
-
throw new
|
|
561
|
+
throw new chunkN7UWN6ND_cjs.APIError("BAD_REQUEST", {
|
|
562
562
|
message: ERROR_CODES.OTP_EXPIRED
|
|
563
563
|
});
|
|
564
564
|
}
|
|
565
565
|
const otp = ctx.body.otp;
|
|
566
566
|
if (verificationValue.value !== otp) {
|
|
567
|
-
throw new
|
|
567
|
+
throw new chunkN7UWN6ND_cjs.APIError("BAD_REQUEST", {
|
|
568
568
|
message: ERROR_CODES.INVALID_OTP
|
|
569
569
|
});
|
|
570
570
|
}
|
|
@@ -602,7 +602,7 @@ var emailOTP = (options) => {
|
|
|
602
602
|
matcher(context) {
|
|
603
603
|
return !!(context.path?.startsWith("/sign-up") && opts.sendVerificationOnSignUp);
|
|
604
604
|
},
|
|
605
|
-
handler:
|
|
605
|
+
handler: chunkN7UWN6ND_cjs.createAuthMiddleware(async (ctx) => {
|
|
606
606
|
const response = await chunkJUPDDQC4_cjs.getEndpointResponse(ctx);
|
|
607
607
|
const email = response?.user.email;
|
|
608
608
|
if (email) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkN7UWN6ND_cjs = require('./chunk-N7UWN6ND.cjs');
|
|
4
4
|
var chunkV6HE2MP7_cjs = require('./chunk-V6HE2MP7.cjs');
|
|
5
5
|
var chunkG2LZ73E2_cjs = require('./chunk-G2LZ73E2.cjs');
|
|
6
6
|
var zod = require('zod');
|
|
@@ -10,7 +10,7 @@ var magicLink = (options) => {
|
|
|
10
10
|
return {
|
|
11
11
|
id: "magic-link",
|
|
12
12
|
endpoints: {
|
|
13
|
-
signInMagicLink:
|
|
13
|
+
signInMagicLink: chunkN7UWN6ND_cjs.createAuthEndpoint(
|
|
14
14
|
"/sign-in/magic-link",
|
|
15
15
|
{
|
|
16
16
|
method: "POST",
|
|
@@ -55,11 +55,11 @@ var magicLink = (options) => {
|
|
|
55
55
|
const user = await ctx.context.internalAdapter.findUserByEmail(email);
|
|
56
56
|
if (!user) {
|
|
57
57
|
throw new betterCall.APIError("BAD_REQUEST", {
|
|
58
|
-
message:
|
|
58
|
+
message: chunkN7UWN6ND_cjs.BASE_ERROR_CODES.USER_NOT_FOUND
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
const verificationToken = chunkG2LZ73E2_cjs.generateRandomString(32, "a-z", "A-Z");
|
|
62
|
+
const verificationToken = options?.generateToken ? await options.generateToken(email) : chunkG2LZ73E2_cjs.generateRandomString(32, "a-z", "A-Z");
|
|
63
63
|
await ctx.context.internalAdapter.createVerificationValue({
|
|
64
64
|
identifier: verificationToken,
|
|
65
65
|
value: JSON.stringify({ email, name: ctx.body.name }),
|
|
@@ -81,7 +81,7 @@ var magicLink = (options) => {
|
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
83
|
),
|
|
84
|
-
magicLinkVerify:
|
|
84
|
+
magicLinkVerify: chunkN7UWN6ND_cjs.createAuthEndpoint(
|
|
85
85
|
"/magic-link/verify",
|
|
86
86
|
{
|
|
87
87
|
method: "GET",
|
|
@@ -93,7 +93,7 @@ var magicLink = (options) => {
|
|
|
93
93
|
description: "URL to redirect after magic link verification, if not provided will return session"
|
|
94
94
|
}).optional()
|
|
95
95
|
}),
|
|
96
|
-
use: [
|
|
96
|
+
use: [chunkN7UWN6ND_cjs.originCheck((ctx) => ctx.query.callbackURL)],
|
|
97
97
|
requireHeaders: true,
|
|
98
98
|
metadata: {
|
|
99
99
|
openapi: {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkN7UWN6ND_cjs = require('./chunk-N7UWN6ND.cjs');
|
|
4
4
|
var zod = require('zod');
|
|
5
5
|
|
|
6
6
|
var customSession = (fn, options) => {
|
|
7
7
|
return {
|
|
8
8
|
id: "custom-session",
|
|
9
9
|
endpoints: {
|
|
10
|
-
getSession:
|
|
10
|
+
getSession: chunkN7UWN6ND_cjs.createAuthEndpoint(
|
|
11
11
|
"/get-session",
|
|
12
12
|
{
|
|
13
13
|
method: "GET",
|
|
@@ -30,7 +30,7 @@ var customSession = (fn, options) => {
|
|
|
30
30
|
)
|
|
31
31
|
},
|
|
32
32
|
async (ctx) => {
|
|
33
|
-
const session = await
|
|
33
|
+
const session = await chunkN7UWN6ND_cjs.getSessionFromCtx(ctx);
|
|
34
34
|
if (!session) {
|
|
35
35
|
return ctx.json(null);
|
|
36
36
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkN7UWN6ND_cjs = require('./chunk-N7UWN6ND.cjs');
|
|
4
4
|
var chunkV6HE2MP7_cjs = require('./chunk-V6HE2MP7.cjs');
|
|
5
5
|
var chunkG2LZ73E2_cjs = require('./chunk-G2LZ73E2.cjs');
|
|
6
6
|
var jose = require('jose');
|
|
@@ -136,7 +136,7 @@ async function authorize(ctx, options) {
|
|
|
136
136
|
error: "invalid_request"
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
|
-
const session = await
|
|
139
|
+
const session = await chunkN7UWN6ND_cjs.getSessionFromCtx(ctx);
|
|
140
140
|
if (!session) {
|
|
141
141
|
await ctx.setSignedCookie(
|
|
142
142
|
"oidc_login_prompt",
|
|
@@ -392,7 +392,7 @@ var oidcProvider = (options) => {
|
|
|
392
392
|
matcher() {
|
|
393
393
|
return true;
|
|
394
394
|
},
|
|
395
|
-
handler:
|
|
395
|
+
handler: chunkN7UWN6ND_cjs.createAuthMiddleware(async (ctx) => {
|
|
396
396
|
const cookie = await ctx.getSignedCookie(
|
|
397
397
|
"oidc_login_prompt",
|
|
398
398
|
ctx.context.secret
|
|
@@ -427,7 +427,7 @@ var oidcProvider = (options) => {
|
|
|
427
427
|
]
|
|
428
428
|
},
|
|
429
429
|
endpoints: {
|
|
430
|
-
getOpenIdConfig:
|
|
430
|
+
getOpenIdConfig: chunkN7UWN6ND_cjs.createAuthEndpoint(
|
|
431
431
|
"/.well-known/openid-configuration",
|
|
432
432
|
{
|
|
433
433
|
method: "GET"
|
|
@@ -437,7 +437,7 @@ var oidcProvider = (options) => {
|
|
|
437
437
|
return ctx.json(metadata);
|
|
438
438
|
}
|
|
439
439
|
),
|
|
440
|
-
oAuth2authorize:
|
|
440
|
+
oAuth2authorize: chunkN7UWN6ND_cjs.createAuthEndpoint(
|
|
441
441
|
"/oauth2/authorize",
|
|
442
442
|
{
|
|
443
443
|
method: "GET",
|
|
@@ -447,14 +447,14 @@ var oidcProvider = (options) => {
|
|
|
447
447
|
return authorize(ctx, opts);
|
|
448
448
|
}
|
|
449
449
|
),
|
|
450
|
-
oAuthConsent:
|
|
450
|
+
oAuthConsent: chunkN7UWN6ND_cjs.createAuthEndpoint(
|
|
451
451
|
"/oauth2/consent",
|
|
452
452
|
{
|
|
453
453
|
method: "POST",
|
|
454
454
|
body: zod.z.object({
|
|
455
455
|
accept: zod.z.boolean()
|
|
456
456
|
}),
|
|
457
|
-
use: [
|
|
457
|
+
use: [chunkN7UWN6ND_cjs.sessionMiddleware]
|
|
458
458
|
},
|
|
459
459
|
async (ctx) => {
|
|
460
460
|
const storedCode = await ctx.getSignedCookie(
|
|
@@ -462,27 +462,27 @@ var oidcProvider = (options) => {
|
|
|
462
462
|
ctx.context.secret
|
|
463
463
|
);
|
|
464
464
|
if (!storedCode) {
|
|
465
|
-
throw new
|
|
465
|
+
throw new chunkN7UWN6ND_cjs.APIError("UNAUTHORIZED", {
|
|
466
466
|
error_description: "No consent prompt found",
|
|
467
467
|
error: "invalid_grant"
|
|
468
468
|
});
|
|
469
469
|
}
|
|
470
470
|
const verification = await ctx.context.internalAdapter.findVerificationValue(storedCode);
|
|
471
471
|
if (!verification) {
|
|
472
|
-
throw new
|
|
472
|
+
throw new chunkN7UWN6ND_cjs.APIError("UNAUTHORIZED", {
|
|
473
473
|
error_description: "Invalid code",
|
|
474
474
|
error: "invalid_grant"
|
|
475
475
|
});
|
|
476
476
|
}
|
|
477
477
|
if (verification.expiresAt < /* @__PURE__ */ new Date()) {
|
|
478
|
-
throw new
|
|
478
|
+
throw new chunkN7UWN6ND_cjs.APIError("UNAUTHORIZED", {
|
|
479
479
|
error_description: "Code expired",
|
|
480
480
|
error: "invalid_grant"
|
|
481
481
|
});
|
|
482
482
|
}
|
|
483
483
|
const value = JSON.parse(verification.value);
|
|
484
484
|
if (!value.requireConsent || !value.state) {
|
|
485
|
-
throw new
|
|
485
|
+
throw new chunkN7UWN6ND_cjs.APIError("UNAUTHORIZED", {
|
|
486
486
|
error_description: "Consent not required",
|
|
487
487
|
error: "invalid_grant"
|
|
488
488
|
});
|
|
@@ -528,7 +528,7 @@ var oidcProvider = (options) => {
|
|
|
528
528
|
});
|
|
529
529
|
}
|
|
530
530
|
),
|
|
531
|
-
oAuth2token:
|
|
531
|
+
oAuth2token: chunkN7UWN6ND_cjs.createAuthEndpoint(
|
|
532
532
|
"/oauth2/token",
|
|
533
533
|
{
|
|
534
534
|
method: "POST",
|
|
@@ -540,7 +540,7 @@ var oidcProvider = (options) => {
|
|
|
540
540
|
async (ctx) => {
|
|
541
541
|
let { body } = ctx;
|
|
542
542
|
if (!body) {
|
|
543
|
-
throw new
|
|
543
|
+
throw new chunkN7UWN6ND_cjs.APIError("BAD_REQUEST", {
|
|
544
544
|
error_description: "request body not found",
|
|
545
545
|
error: "invalid_request"
|
|
546
546
|
});
|
|
@@ -549,7 +549,7 @@ var oidcProvider = (options) => {
|
|
|
549
549
|
body = Object.fromEntries(body.entries());
|
|
550
550
|
}
|
|
551
551
|
if (!(body instanceof Object)) {
|
|
552
|
-
throw new
|
|
552
|
+
throw new chunkN7UWN6ND_cjs.APIError("BAD_REQUEST", {
|
|
553
553
|
error_description: "request body is not an object",
|
|
554
554
|
error: "invalid_request"
|
|
555
555
|
});
|
|
@@ -565,7 +565,7 @@ var oidcProvider = (options) => {
|
|
|
565
565
|
} = body;
|
|
566
566
|
if (grant_type === "refresh_token") {
|
|
567
567
|
if (!refresh_token) {
|
|
568
|
-
throw new
|
|
568
|
+
throw new chunkN7UWN6ND_cjs.APIError("BAD_REQUEST", {
|
|
569
569
|
error_description: "refresh_token is required",
|
|
570
570
|
error: "invalid_request"
|
|
571
571
|
});
|
|
@@ -580,19 +580,19 @@ var oidcProvider = (options) => {
|
|
|
580
580
|
]
|
|
581
581
|
});
|
|
582
582
|
if (!token) {
|
|
583
|
-
throw new
|
|
583
|
+
throw new chunkN7UWN6ND_cjs.APIError("UNAUTHORIZED", {
|
|
584
584
|
error_description: "invalid refresh token",
|
|
585
585
|
error: "invalid_grant"
|
|
586
586
|
});
|
|
587
587
|
}
|
|
588
588
|
if (token.clientId !== client_id?.toString()) {
|
|
589
|
-
throw new
|
|
589
|
+
throw new chunkN7UWN6ND_cjs.APIError("UNAUTHORIZED", {
|
|
590
590
|
error_description: "invalid client_id",
|
|
591
591
|
error: "invalid_client"
|
|
592
592
|
});
|
|
593
593
|
}
|
|
594
594
|
if (token.refreshTokenExpiresAt < /* @__PURE__ */ new Date()) {
|
|
595
|
-
throw new
|
|
595
|
+
throw new chunkN7UWN6ND_cjs.APIError("UNAUTHORIZED", {
|
|
596
596
|
error_description: "refresh token expired",
|
|
597
597
|
error: "invalid_grant"
|
|
598
598
|
});
|
|
@@ -628,13 +628,13 @@ var oidcProvider = (options) => {
|
|
|
628
628
|
});
|
|
629
629
|
}
|
|
630
630
|
if (!code) {
|
|
631
|
-
throw new
|
|
631
|
+
throw new chunkN7UWN6ND_cjs.APIError("BAD_REQUEST", {
|
|
632
632
|
error_description: "code is required",
|
|
633
633
|
error: "invalid_request"
|
|
634
634
|
});
|
|
635
635
|
}
|
|
636
636
|
if (options.requirePKCE && !code_verifier) {
|
|
637
|
-
throw new
|
|
637
|
+
throw new chunkN7UWN6ND_cjs.APIError("BAD_REQUEST", {
|
|
638
638
|
error_description: "code verifier is missing",
|
|
639
639
|
error: "invalid_request"
|
|
640
640
|
});
|
|
@@ -643,13 +643,13 @@ var oidcProvider = (options) => {
|
|
|
643
643
|
code.toString()
|
|
644
644
|
);
|
|
645
645
|
if (!verificationValue) {
|
|
646
|
-
throw new
|
|
646
|
+
throw new chunkN7UWN6ND_cjs.APIError("UNAUTHORIZED", {
|
|
647
647
|
error_description: "invalid code",
|
|
648
648
|
error: "invalid_grant"
|
|
649
649
|
});
|
|
650
650
|
}
|
|
651
651
|
if (verificationValue.expiresAt < /* @__PURE__ */ new Date()) {
|
|
652
|
-
throw new
|
|
652
|
+
throw new chunkN7UWN6ND_cjs.APIError("UNAUTHORIZED", {
|
|
653
653
|
error_description: "code expired",
|
|
654
654
|
error: "invalid_grant"
|
|
655
655
|
});
|
|
@@ -658,25 +658,25 @@ var oidcProvider = (options) => {
|
|
|
658
658
|
verificationValue.id
|
|
659
659
|
);
|
|
660
660
|
if (!client_id || !client_secret) {
|
|
661
|
-
throw new
|
|
661
|
+
throw new chunkN7UWN6ND_cjs.APIError("UNAUTHORIZED", {
|
|
662
662
|
error_description: "client_id and client_secret are required",
|
|
663
663
|
error: "invalid_client"
|
|
664
664
|
});
|
|
665
665
|
}
|
|
666
666
|
if (!grant_type) {
|
|
667
|
-
throw new
|
|
667
|
+
throw new chunkN7UWN6ND_cjs.APIError("BAD_REQUEST", {
|
|
668
668
|
error_description: "grant_type is required",
|
|
669
669
|
error: "invalid_request"
|
|
670
670
|
});
|
|
671
671
|
}
|
|
672
672
|
if (grant_type !== "authorization_code") {
|
|
673
|
-
throw new
|
|
673
|
+
throw new chunkN7UWN6ND_cjs.APIError("BAD_REQUEST", {
|
|
674
674
|
error_description: "grant_type must be 'authorization_code'",
|
|
675
675
|
error: "unsupported_grant_type"
|
|
676
676
|
});
|
|
677
677
|
}
|
|
678
678
|
if (!redirect_uri) {
|
|
679
|
-
throw new
|
|
679
|
+
throw new chunkN7UWN6ND_cjs.APIError("BAD_REQUEST", {
|
|
680
680
|
error_description: "redirect_uri is required",
|
|
681
681
|
error: "invalid_request"
|
|
682
682
|
});
|
|
@@ -695,20 +695,20 @@ var oidcProvider = (options) => {
|
|
|
695
695
|
};
|
|
696
696
|
});
|
|
697
697
|
if (!client) {
|
|
698
|
-
throw new
|
|
698
|
+
throw new chunkN7UWN6ND_cjs.APIError("UNAUTHORIZED", {
|
|
699
699
|
error_description: "invalid client_id",
|
|
700
700
|
error: "invalid_client"
|
|
701
701
|
});
|
|
702
702
|
}
|
|
703
703
|
if (client.disabled) {
|
|
704
|
-
throw new
|
|
704
|
+
throw new chunkN7UWN6ND_cjs.APIError("UNAUTHORIZED", {
|
|
705
705
|
error_description: "client is disabled",
|
|
706
706
|
error: "invalid_client"
|
|
707
707
|
});
|
|
708
708
|
}
|
|
709
709
|
const isValidSecret = client.clientSecret === client_secret.toString();
|
|
710
710
|
if (!isValidSecret) {
|
|
711
|
-
throw new
|
|
711
|
+
throw new chunkN7UWN6ND_cjs.APIError("UNAUTHORIZED", {
|
|
712
712
|
error_description: "invalid client_secret",
|
|
713
713
|
error: "invalid_client"
|
|
714
714
|
});
|
|
@@ -717,19 +717,19 @@ var oidcProvider = (options) => {
|
|
|
717
717
|
verificationValue.value
|
|
718
718
|
);
|
|
719
719
|
if (value.clientId !== client_id.toString()) {
|
|
720
|
-
throw new
|
|
720
|
+
throw new chunkN7UWN6ND_cjs.APIError("UNAUTHORIZED", {
|
|
721
721
|
error_description: "invalid client_id",
|
|
722
722
|
error: "invalid_client"
|
|
723
723
|
});
|
|
724
724
|
}
|
|
725
725
|
if (value.redirectURI !== redirect_uri.toString()) {
|
|
726
|
-
throw new
|
|
726
|
+
throw new chunkN7UWN6ND_cjs.APIError("UNAUTHORIZED", {
|
|
727
727
|
error_description: "invalid redirect_uri",
|
|
728
728
|
error: "invalid_client"
|
|
729
729
|
});
|
|
730
730
|
}
|
|
731
731
|
if (value.codeChallenge && !code_verifier) {
|
|
732
|
-
throw new
|
|
732
|
+
throw new chunkN7UWN6ND_cjs.APIError("BAD_REQUEST", {
|
|
733
733
|
error_description: "code verifier is missing",
|
|
734
734
|
error: "invalid_request"
|
|
735
735
|
});
|
|
@@ -738,7 +738,7 @@ var oidcProvider = (options) => {
|
|
|
738
738
|
code_verifier
|
|
739
739
|
);
|
|
740
740
|
if (challenge !== value.codeChallenge) {
|
|
741
|
-
throw new
|
|
741
|
+
throw new chunkN7UWN6ND_cjs.APIError("UNAUTHORIZED", {
|
|
742
742
|
error_description: "code verification failed",
|
|
743
743
|
error: "invalid_request"
|
|
744
744
|
});
|
|
@@ -773,7 +773,7 @@ var oidcProvider = (options) => {
|
|
|
773
773
|
value.userId
|
|
774
774
|
);
|
|
775
775
|
if (!user) {
|
|
776
|
-
throw new
|
|
776
|
+
throw new chunkN7UWN6ND_cjs.APIError("UNAUTHORIZED", {
|
|
777
777
|
error_description: "user not found",
|
|
778
778
|
error: "invalid_grant"
|
|
779
779
|
});
|
|
@@ -834,7 +834,7 @@ var oidcProvider = (options) => {
|
|
|
834
834
|
);
|
|
835
835
|
}
|
|
836
836
|
),
|
|
837
|
-
oAuth2userInfo:
|
|
837
|
+
oAuth2userInfo: chunkN7UWN6ND_cjs.createAuthEndpoint(
|
|
838
838
|
"/oauth2/userinfo",
|
|
839
839
|
{
|
|
840
840
|
method: "GET",
|
|
@@ -844,14 +844,14 @@ var oidcProvider = (options) => {
|
|
|
844
844
|
},
|
|
845
845
|
async (ctx) => {
|
|
846
846
|
if (!ctx.request) {
|
|
847
|
-
throw new
|
|
847
|
+
throw new chunkN7UWN6ND_cjs.APIError("UNAUTHORIZED", {
|
|
848
848
|
error_description: "request not found",
|
|
849
849
|
error: "invalid_request"
|
|
850
850
|
});
|
|
851
851
|
}
|
|
852
852
|
const authorization = ctx.request.headers.get("authorization");
|
|
853
853
|
if (!authorization) {
|
|
854
|
-
throw new
|
|
854
|
+
throw new chunkN7UWN6ND_cjs.APIError("UNAUTHORIZED", {
|
|
855
855
|
error_description: "authorization header not found",
|
|
856
856
|
error: "invalid_request"
|
|
857
857
|
});
|
|
@@ -867,13 +867,13 @@ var oidcProvider = (options) => {
|
|
|
867
867
|
]
|
|
868
868
|
});
|
|
869
869
|
if (!accessToken) {
|
|
870
|
-
throw new
|
|
870
|
+
throw new chunkN7UWN6ND_cjs.APIError("UNAUTHORIZED", {
|
|
871
871
|
error_description: "invalid access token",
|
|
872
872
|
error: "invalid_token"
|
|
873
873
|
});
|
|
874
874
|
}
|
|
875
875
|
if (accessToken.accessTokenExpiresAt < /* @__PURE__ */ new Date()) {
|
|
876
|
-
throw new
|
|
876
|
+
throw new chunkN7UWN6ND_cjs.APIError("UNAUTHORIZED", {
|
|
877
877
|
error_description: "The Access Token expired",
|
|
878
878
|
error: "invalid_token"
|
|
879
879
|
});
|
|
@@ -882,7 +882,7 @@ var oidcProvider = (options) => {
|
|
|
882
882
|
accessToken.userId
|
|
883
883
|
);
|
|
884
884
|
if (!user) {
|
|
885
|
-
throw new
|
|
885
|
+
throw new chunkN7UWN6ND_cjs.APIError("UNAUTHORIZED", {
|
|
886
886
|
error_description: "user not found",
|
|
887
887
|
error: "invalid_token"
|
|
888
888
|
});
|
|
@@ -899,7 +899,7 @@ var oidcProvider = (options) => {
|
|
|
899
899
|
return ctx.json(userClaims);
|
|
900
900
|
}
|
|
901
901
|
),
|
|
902
|
-
registerOAuthApplication:
|
|
902
|
+
registerOAuthApplication: chunkN7UWN6ND_cjs.createAuthEndpoint(
|
|
903
903
|
"/oauth2/register",
|
|
904
904
|
{
|
|
905
905
|
method: "POST",
|
|
@@ -912,9 +912,9 @@ var oidcProvider = (options) => {
|
|
|
912
912
|
},
|
|
913
913
|
async (ctx) => {
|
|
914
914
|
const body = ctx.body;
|
|
915
|
-
const session = await
|
|
915
|
+
const session = await chunkN7UWN6ND_cjs.getSessionFromCtx(ctx);
|
|
916
916
|
if (!session && !options.allowDynamicClientRegistration) {
|
|
917
|
-
throw new
|
|
917
|
+
throw new chunkN7UWN6ND_cjs.APIError("UNAUTHORIZED", {
|
|
918
918
|
message: "Unauthorized"
|
|
919
919
|
});
|
|
920
920
|
}
|
|
@@ -944,11 +944,11 @@ var oidcProvider = (options) => {
|
|
|
944
944
|
});
|
|
945
945
|
}
|
|
946
946
|
),
|
|
947
|
-
getOAuthClient:
|
|
947
|
+
getOAuthClient: chunkN7UWN6ND_cjs.createAuthEndpoint(
|
|
948
948
|
"/oauth2/client/:id",
|
|
949
949
|
{
|
|
950
950
|
method: "GET",
|
|
951
|
-
use: [
|
|
951
|
+
use: [chunkN7UWN6ND_cjs.sessionMiddleware]
|
|
952
952
|
},
|
|
953
953
|
async (ctx) => {
|
|
954
954
|
const client = await ctx.context.adapter.findOne(
|
|
@@ -958,7 +958,7 @@ var oidcProvider = (options) => {
|
|
|
958
958
|
}
|
|
959
959
|
);
|
|
960
960
|
if (!client) {
|
|
961
|
-
throw new
|
|
961
|
+
throw new chunkN7UWN6ND_cjs.APIError("NOT_FOUND", {
|
|
962
962
|
error_description: "client not found",
|
|
963
963
|
error: "not_found"
|
|
964
964
|
});
|
|
@@ -92,13 +92,16 @@ function getWithHooks(adapter, ctx) {
|
|
|
92
92
|
for (const hook of hooks || []) {
|
|
93
93
|
const toRun = hook[model]?.create?.before;
|
|
94
94
|
if (toRun) {
|
|
95
|
-
const result = await toRun(
|
|
95
|
+
const result = await toRun(actualData);
|
|
96
96
|
if (result === false) {
|
|
97
97
|
return null;
|
|
98
98
|
}
|
|
99
99
|
const isObject = typeof result === "object" && "data" in result;
|
|
100
100
|
if (isObject) {
|
|
101
|
-
actualData =
|
|
101
|
+
actualData = {
|
|
102
|
+
...actualData,
|
|
103
|
+
...result.data
|
|
104
|
+
};
|
|
102
105
|
}
|
|
103
106
|
}
|
|
104
107
|
}
|