better-auth 1.2.5-beta.9 → 1.2.6-beta.1
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-adapter/index.d.cts +3 -3
- package/dist/adapters/drizzle-adapter/index.d.mts +3 -3
- package/dist/adapters/drizzle-adapter/index.d.ts +3 -3
- package/dist/adapters/kysely-adapter/index.d.cts +3 -3
- package/dist/adapters/kysely-adapter/index.d.mts +3 -3
- package/dist/adapters/kysely-adapter/index.d.ts +3 -3
- package/dist/adapters/memory-adapter/index.d.cts +3 -3
- package/dist/adapters/memory-adapter/index.d.mts +3 -3
- package/dist/adapters/memory-adapter/index.d.ts +3 -3
- package/dist/adapters/mongodb-adapter/index.d.cts +3 -3
- package/dist/adapters/mongodb-adapter/index.d.mts +3 -3
- package/dist/adapters/mongodb-adapter/index.d.ts +3 -3
- package/dist/adapters/prisma-adapter/index.d.cts +3 -3
- package/dist/adapters/prisma-adapter/index.d.mts +3 -3
- package/dist/adapters/prisma-adapter/index.d.ts +3 -3
- package/dist/adapters/test.d.cts +3 -3
- package/dist/adapters/test.d.mts +3 -3
- package/dist/adapters/test.d.ts +3 -3
- package/dist/api/index.cjs +77 -75
- package/dist/api/index.d.cts +4 -4
- package/dist/api/index.d.mts +4 -4
- package/dist/api/index.d.ts +4 -4
- package/dist/api/index.mjs +6 -5
- package/dist/client/index.d.cts +4 -4
- package/dist/client/index.d.mts +4 -4
- package/dist/client/index.d.ts +4 -4
- package/dist/client/plugins/index.d.cts +4 -4
- package/dist/client/plugins/index.d.mts +4 -4
- package/dist/client/plugins/index.d.ts +4 -4
- package/dist/client/react/index.d.cts +4 -4
- package/dist/client/react/index.d.mts +4 -4
- package/dist/client/react/index.d.ts +4 -4
- package/dist/client/solid/index.d.cts +4 -4
- package/dist/client/solid/index.d.mts +4 -4
- package/dist/client/solid/index.d.ts +4 -4
- package/dist/client/svelte/index.d.cts +4 -4
- package/dist/client/svelte/index.d.mts +4 -4
- package/dist/client/svelte/index.d.ts +4 -4
- package/dist/client/vue/index.d.cts +4 -4
- package/dist/client/vue/index.d.mts +4 -4
- package/dist/client/vue/index.d.ts +4 -4
- package/dist/cookies/index.d.cts +3 -3
- package/dist/cookies/index.d.mts +3 -3
- package/dist/cookies/index.d.ts +3 -3
- package/dist/db/index.cjs +1 -1
- package/dist/db/index.d.cts +4 -4
- package/dist/db/index.d.mts +4 -4
- package/dist/db/index.d.ts +4 -4
- package/dist/db/index.mjs +1 -1
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +4 -4
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +4 -4
- package/dist/integrations/next-js.cjs +5 -5
- package/dist/integrations/next-js.d.cts +3 -3
- package/dist/integrations/next-js.d.mts +3 -3
- package/dist/integrations/next-js.d.ts +3 -3
- package/dist/integrations/next-js.mjs +4 -4
- package/dist/integrations/node.d.cts +3 -3
- package/dist/integrations/node.d.mts +3 -3
- package/dist/integrations/node.d.ts +3 -3
- package/dist/integrations/svelte-kit.d.cts +3 -3
- package/dist/integrations/svelte-kit.d.mts +3 -3
- package/dist/integrations/svelte-kit.d.ts +3 -3
- package/dist/oauth2/index.cjs +7 -6
- package/dist/oauth2/index.d.cts +14 -5
- package/dist/oauth2/index.d.mts +14 -5
- package/dist/oauth2/index.d.ts +14 -5
- package/dist/oauth2/index.mjs +1 -1
- package/dist/plugins/admin/index.cjs +3 -3
- package/dist/plugins/admin/index.d.cts +3 -3
- package/dist/plugins/admin/index.d.mts +3 -3
- package/dist/plugins/admin/index.d.ts +3 -3
- package/dist/plugins/admin/index.mjs +3 -3
- package/dist/plugins/anonymous/index.cjs +5 -5
- package/dist/plugins/anonymous/index.d.cts +3 -3
- package/dist/plugins/anonymous/index.d.mts +3 -3
- package/dist/plugins/anonymous/index.d.ts +3 -3
- package/dist/plugins/anonymous/index.mjs +2 -2
- package/dist/plugins/bearer/index.cjs +4 -4
- package/dist/plugins/bearer/index.d.cts +3 -3
- package/dist/plugins/bearer/index.d.mts +3 -3
- package/dist/plugins/bearer/index.d.ts +3 -3
- package/dist/plugins/bearer/index.mjs +2 -2
- package/dist/plugins/custom-session/index.cjs +4 -4
- package/dist/plugins/custom-session/index.d.cts +3 -3
- package/dist/plugins/custom-session/index.d.mts +3 -3
- package/dist/plugins/custom-session/index.d.ts +3 -3
- package/dist/plugins/custom-session/index.mjs +2 -2
- package/dist/plugins/email-otp/index.cjs +10 -10
- package/dist/plugins/email-otp/index.d.cts +3 -3
- package/dist/plugins/email-otp/index.d.mts +3 -3
- package/dist/plugins/email-otp/index.d.ts +3 -3
- package/dist/plugins/email-otp/index.mjs +2 -2
- package/dist/plugins/generic-oauth/index.cjs +43 -19
- package/dist/plugins/generic-oauth/index.d.cts +4 -4
- package/dist/plugins/generic-oauth/index.d.mts +4 -4
- package/dist/plugins/generic-oauth/index.d.ts +4 -4
- package/dist/plugins/generic-oauth/index.mjs +29 -5
- package/dist/plugins/index.cjs +22 -22
- package/dist/plugins/index.d.cts +4 -4
- package/dist/plugins/index.d.mts +4 -4
- package/dist/plugins/index.d.ts +4 -4
- package/dist/plugins/index.mjs +6 -6
- package/dist/plugins/jwt/index.cjs +6 -6
- package/dist/plugins/jwt/index.d.cts +3 -3
- package/dist/plugins/jwt/index.d.mts +3 -3
- package/dist/plugins/jwt/index.d.ts +3 -3
- package/dist/plugins/jwt/index.mjs +2 -2
- package/dist/plugins/magic-link/index.cjs +6 -6
- package/dist/plugins/magic-link/index.mjs +2 -2
- package/dist/plugins/multi-session/index.cjs +9 -9
- package/dist/plugins/multi-session/index.d.cts +3 -3
- package/dist/plugins/multi-session/index.d.mts +3 -3
- package/dist/plugins/multi-session/index.d.ts +3 -3
- package/dist/plugins/multi-session/index.mjs +2 -2
- package/dist/plugins/oauth-proxy/index.cjs +6 -6
- package/dist/plugins/oauth-proxy/index.d.cts +3 -3
- package/dist/plugins/oauth-proxy/index.d.mts +3 -3
- package/dist/plugins/oauth-proxy/index.d.ts +3 -3
- package/dist/plugins/oauth-proxy/index.mjs +2 -2
- package/dist/plugins/oidc-provider/index.cjs +14 -14
- package/dist/plugins/oidc-provider/index.d.cts +3 -3
- package/dist/plugins/oidc-provider/index.d.mts +3 -3
- package/dist/plugins/oidc-provider/index.d.ts +3 -3
- package/dist/plugins/oidc-provider/index.mjs +2 -2
- package/dist/plugins/one-tap/index.cjs +3 -3
- package/dist/plugins/one-tap/index.mjs +2 -2
- package/dist/plugins/open-api/index.cjs +4 -4
- package/dist/plugins/open-api/index.d.cts +3 -3
- package/dist/plugins/open-api/index.d.mts +3 -3
- package/dist/plugins/open-api/index.d.ts +3 -3
- package/dist/plugins/open-api/index.mjs +2 -2
- package/dist/plugins/organization/index.cjs +3 -3
- package/dist/plugins/organization/index.d.cts +3 -3
- package/dist/plugins/organization/index.d.mts +3 -3
- package/dist/plugins/organization/index.d.ts +3 -3
- package/dist/plugins/organization/index.mjs +3 -3
- package/dist/plugins/passkey/index.cjs +15 -15
- package/dist/plugins/passkey/index.d.cts +3 -3
- package/dist/plugins/passkey/index.d.mts +3 -3
- package/dist/plugins/passkey/index.d.ts +3 -3
- package/dist/plugins/passkey/index.mjs +2 -2
- package/dist/plugins/phone-number/index.cjs +13 -13
- package/dist/plugins/phone-number/index.d.cts +3 -3
- package/dist/plugins/phone-number/index.d.mts +3 -3
- package/dist/plugins/phone-number/index.d.ts +3 -3
- package/dist/plugins/phone-number/index.mjs +2 -2
- package/dist/plugins/sso/index.cjs +11 -11
- package/dist/plugins/sso/index.d.cts +2 -2
- package/dist/plugins/sso/index.d.mts +2 -2
- package/dist/plugins/sso/index.d.ts +2 -2
- package/dist/plugins/sso/index.mjs +3 -3
- package/dist/plugins/two-factor/index.cjs +20 -20
- package/dist/plugins/two-factor/index.d.cts +3 -3
- package/dist/plugins/two-factor/index.d.mts +3 -3
- package/dist/plugins/two-factor/index.d.ts +3 -3
- package/dist/plugins/two-factor/index.mjs +3 -3
- package/dist/plugins/username/index.cjs +9 -9
- package/dist/plugins/username/index.d.cts +3 -3
- package/dist/plugins/username/index.d.mts +3 -3
- package/dist/plugins/username/index.d.ts +3 -3
- package/dist/plugins/username/index.mjs +2 -2
- package/dist/shared/{better-auth.oyDBIJLs.mjs → better-auth.2rfXmCNS.mjs} +1 -1
- package/dist/shared/{better-auth.KTt7CS7L.mjs → better-auth.9knM1kR4.mjs} +1 -1
- package/dist/shared/{better-auth.DiMBK1Ep.mjs → better-auth.B2THyVQH.mjs} +54 -1
- package/dist/shared/{better-auth.C8tekzhG.cjs → better-auth.B7irTavj.cjs} +35 -35
- package/dist/shared/{better-auth.Dd96RDNl.d.ts → better-auth.BAfIsot3.d.ts} +41 -2
- package/dist/shared/{better-auth.Dunt9jpN.d.cts → better-auth.BBG0jAhH.d.mts} +2 -2
- package/dist/shared/{better-auth.CxMUffeh.d.cts → better-auth.BDAwKjlL.d.cts} +567 -46
- package/dist/shared/{better-auth.CbBX7Xla.mjs → better-auth.BK4Kh5QZ.mjs} +19 -17
- package/dist/shared/{better-auth.DgXCgiHI.cjs → better-auth.BLV8UOn8.cjs} +54 -0
- package/dist/shared/{better-auth.BjoUuJNr.d.mts → better-auth.BTnAiI8e.d.mts} +41 -2
- package/dist/shared/{better-auth.CzK7QJBv.d.cts → better-auth.CH6fRG6d.d.cts} +41 -2
- package/dist/shared/{better-auth.dzwyqpra.d.mts → better-auth.CTQDLJN7.d.mts} +567 -46
- package/dist/shared/{better-auth.CEuqoYDM.d.mts → better-auth.CtSY9Kmu.d.cts} +2 -2
- package/dist/shared/{better-auth.Cz2saE_0.d.cts → better-auth.DAnkIG1r.d.cts} +1 -1
- package/dist/shared/{better-auth.4ZqMps6Z.d.ts → better-auth.DCxEy-As.d.ts} +1 -1
- package/dist/shared/{better-auth.D7hUw1_Y.d.ts → better-auth.DIOWNBS2.d.ts} +1 -1
- package/dist/shared/{better-auth.ybwxmbrM.mjs → better-auth.DQ-pFMwp.mjs} +118 -5
- package/dist/shared/{better-auth.BxC2ipUB.d.mts → better-auth.DZPJQ81N.d.mts} +1 -1
- package/dist/shared/{better-auth.CL_N_Cfq.cjs → better-auth.DqGx7Ip8.cjs} +20 -20
- package/dist/shared/{better-auth.wspQErD2.cjs → better-auth.TNTVT6jt.cjs} +3 -3
- package/dist/shared/{better-auth.4J4_zAGP.cjs → better-auth.b0MLzqQX.cjs} +118 -4
- package/dist/shared/{better-auth.CdPDif0r.mjs → better-auth.cN4sTcuQ.mjs} +1 -1
- package/dist/shared/{better-auth.X0ynzeu1.cjs → better-auth.q7ChvjiM.cjs} +19 -17
- package/dist/shared/{better-auth.CixnJ90x.d.ts → better-auth.tpz8D0AA.d.ts} +567 -46
- package/dist/social-providers/index.cjs +197 -32
- package/dist/social-providers/index.d.cts +1 -1
- package/dist/social-providers/index.d.mts +1 -1
- package/dist/social-providers/index.d.ts +1 -1
- package/dist/social-providers/index.mjs +166 -1
- package/dist/types/index.d.cts +4 -4
- package/dist/types/index.d.mts +4 -4
- package/dist/types/index.d.ts +4 -4
- package/package.json +3 -3
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const random = require('../../shared/better-auth.CYeOI8C-.cjs');
|
|
4
4
|
const zod = require('zod');
|
|
5
|
-
const
|
|
5
|
+
const refreshToken = require('../../shared/better-auth.b0MLzqQX.cjs');
|
|
6
6
|
const betterCall = require('better-call');
|
|
7
7
|
const cookies_index = require('../../cookies/index.cjs');
|
|
8
8
|
const schema$1 = require('../../shared/better-auth.C5H9XEzZ.cjs');
|
|
@@ -10,7 +10,7 @@ require('../../shared/better-auth.DiSjtgs9.cjs');
|
|
|
10
10
|
require('../../shared/better-auth.GpOOav9x.cjs');
|
|
11
11
|
require('defu');
|
|
12
12
|
const crypto_index = require('../../crypto/index.cjs');
|
|
13
|
-
const verifyMiddleware = require('../../shared/better-auth.
|
|
13
|
+
const verifyMiddleware = require('../../shared/better-auth.TNTVT6jt.cjs');
|
|
14
14
|
const errorCode = require('../../shared/better-auth.C1-vpKly.cjs');
|
|
15
15
|
require('@better-auth/utils/hash');
|
|
16
16
|
require('@noble/ciphers/chacha');
|
|
@@ -29,7 +29,7 @@ const client = require('../../shared/better-auth.DnER2-iT.cjs');
|
|
|
29
29
|
require('@better-auth/utils/random');
|
|
30
30
|
require('../../social-providers/index.cjs');
|
|
31
31
|
require('@better-fetch/fetch');
|
|
32
|
-
require('../../shared/better-auth.
|
|
32
|
+
require('../../shared/better-auth.BLV8UOn8.cjs');
|
|
33
33
|
require('../../shared/better-auth.C1hdVENX.cjs');
|
|
34
34
|
require('../../shared/better-auth.ANpbi45u.cjs');
|
|
35
35
|
require('../../shared/better-auth.QbbyHMYf.cjs');
|
|
@@ -87,7 +87,7 @@ const backupCode2fa = (options) => {
|
|
|
87
87
|
return {
|
|
88
88
|
id: "backup_code",
|
|
89
89
|
endpoints: {
|
|
90
|
-
verifyBackupCode:
|
|
90
|
+
verifyBackupCode: refreshToken.createAuthEndpoint(
|
|
91
91
|
"/two-factor/verify-backup-code",
|
|
92
92
|
{
|
|
93
93
|
method: "POST",
|
|
@@ -166,14 +166,14 @@ const backupCode2fa = (options) => {
|
|
|
166
166
|
});
|
|
167
167
|
}
|
|
168
168
|
),
|
|
169
|
-
generateBackupCodes:
|
|
169
|
+
generateBackupCodes: refreshToken.createAuthEndpoint(
|
|
170
170
|
"/two-factor/generate-backup-codes",
|
|
171
171
|
{
|
|
172
172
|
method: "POST",
|
|
173
173
|
body: zod.z.object({
|
|
174
174
|
password: zod.z.string()
|
|
175
175
|
}),
|
|
176
|
-
use: [
|
|
176
|
+
use: [refreshToken.sessionMiddleware]
|
|
177
177
|
},
|
|
178
178
|
async (ctx) => {
|
|
179
179
|
const user = ctx.context.session.user;
|
|
@@ -205,7 +205,7 @@ const backupCode2fa = (options) => {
|
|
|
205
205
|
});
|
|
206
206
|
}
|
|
207
207
|
),
|
|
208
|
-
viewBackupCodes:
|
|
208
|
+
viewBackupCodes: refreshToken.createAuthEndpoint(
|
|
209
209
|
"/two-factor/view-backup-codes",
|
|
210
210
|
{
|
|
211
211
|
method: "GET",
|
|
@@ -257,7 +257,7 @@ const otp2fa = (options) => {
|
|
|
257
257
|
period: (options?.period || 3) * 60 * 1e3
|
|
258
258
|
};
|
|
259
259
|
const twoFactorTable = "twoFactor";
|
|
260
|
-
const send2FaOTP =
|
|
260
|
+
const send2FaOTP = refreshToken.createAuthEndpoint(
|
|
261
261
|
"/two-factor/send-otp",
|
|
262
262
|
{
|
|
263
263
|
method: "POST",
|
|
@@ -328,7 +328,7 @@ const otp2fa = (options) => {
|
|
|
328
328
|
return ctx.json({ status: true });
|
|
329
329
|
}
|
|
330
330
|
);
|
|
331
|
-
const verifyOTP =
|
|
331
|
+
const verifyOTP = refreshToken.createAuthEndpoint(
|
|
332
332
|
"/two-factor/verify-otp",
|
|
333
333
|
{
|
|
334
334
|
method: "POST",
|
|
@@ -436,11 +436,11 @@ const totp2fa = (options) => {
|
|
|
436
436
|
period: options?.period || 30
|
|
437
437
|
};
|
|
438
438
|
const twoFactorTable = "twoFactor";
|
|
439
|
-
const generateTOTP =
|
|
439
|
+
const generateTOTP = refreshToken.createAuthEndpoint(
|
|
440
440
|
"/totp/generate",
|
|
441
441
|
{
|
|
442
442
|
method: "POST",
|
|
443
|
-
use: [
|
|
443
|
+
use: [refreshToken.sessionMiddleware],
|
|
444
444
|
metadata: {
|
|
445
445
|
openapi: {
|
|
446
446
|
summary: "Generate TOTP code",
|
|
@@ -496,11 +496,11 @@ const totp2fa = (options) => {
|
|
|
496
496
|
return { code };
|
|
497
497
|
}
|
|
498
498
|
);
|
|
499
|
-
const getTOTPURI =
|
|
499
|
+
const getTOTPURI = refreshToken.createAuthEndpoint(
|
|
500
500
|
"/two-factor/get-totp-uri",
|
|
501
501
|
{
|
|
502
502
|
method: "POST",
|
|
503
|
-
use: [
|
|
503
|
+
use: [refreshToken.sessionMiddleware],
|
|
504
504
|
body: zod.z.object({
|
|
505
505
|
password: zod.z.string({
|
|
506
506
|
description: "User password"
|
|
@@ -568,7 +568,7 @@ const totp2fa = (options) => {
|
|
|
568
568
|
};
|
|
569
569
|
}
|
|
570
570
|
);
|
|
571
|
-
const verifyTOTP =
|
|
571
|
+
const verifyTOTP = refreshToken.createAuthEndpoint(
|
|
572
572
|
"/two-factor/verify-totp",
|
|
573
573
|
{
|
|
574
574
|
method: "POST",
|
|
@@ -731,7 +731,7 @@ const twoFactor = (options) => {
|
|
|
731
731
|
...totp.endpoints,
|
|
732
732
|
...otp$1.endpoints,
|
|
733
733
|
...backupCode.endpoints,
|
|
734
|
-
enableTwoFactor:
|
|
734
|
+
enableTwoFactor: refreshToken.createAuthEndpoint(
|
|
735
735
|
"/two-factor/enable",
|
|
736
736
|
{
|
|
737
737
|
method: "POST",
|
|
@@ -740,7 +740,7 @@ const twoFactor = (options) => {
|
|
|
740
740
|
description: "User password"
|
|
741
741
|
})
|
|
742
742
|
}),
|
|
743
|
-
use: [
|
|
743
|
+
use: [refreshToken.sessionMiddleware],
|
|
744
744
|
metadata: {
|
|
745
745
|
openapi: {
|
|
746
746
|
summary: "Enable two factor authentication",
|
|
@@ -782,7 +782,7 @@ const twoFactor = (options) => {
|
|
|
782
782
|
});
|
|
783
783
|
if (!isPasswordValid) {
|
|
784
784
|
throw new betterCall.APIError("BAD_REQUEST", {
|
|
785
|
-
message:
|
|
785
|
+
message: refreshToken.BASE_ERROR_CODES.INVALID_PASSWORD
|
|
786
786
|
});
|
|
787
787
|
}
|
|
788
788
|
const secret = random.generateRandomString(32);
|
|
@@ -840,7 +840,7 @@ const twoFactor = (options) => {
|
|
|
840
840
|
return ctx.json({ totpURI, backupCodes: backupCodes.backupCodes });
|
|
841
841
|
}
|
|
842
842
|
),
|
|
843
|
-
disableTwoFactor:
|
|
843
|
+
disableTwoFactor: refreshToken.createAuthEndpoint(
|
|
844
844
|
"/two-factor/disable",
|
|
845
845
|
{
|
|
846
846
|
method: "POST",
|
|
@@ -849,7 +849,7 @@ const twoFactor = (options) => {
|
|
|
849
849
|
description: "User password"
|
|
850
850
|
}).min(8)
|
|
851
851
|
}),
|
|
852
|
-
use: [
|
|
852
|
+
use: [refreshToken.sessionMiddleware],
|
|
853
853
|
metadata: {
|
|
854
854
|
openapi: {
|
|
855
855
|
summary: "Disable two factor authentication",
|
|
@@ -926,7 +926,7 @@ const twoFactor = (options) => {
|
|
|
926
926
|
matcher(context) {
|
|
927
927
|
return context.path === "/sign-in/email" || context.path === "/sign-in/username" || context.path === "/sign-in/phone-number";
|
|
928
928
|
},
|
|
929
|
-
handler:
|
|
929
|
+
handler: refreshToken.createAuthMiddleware(async (ctx) => {
|
|
930
930
|
const data = ctx.context.newSession;
|
|
931
931
|
if (!data) {
|
|
932
932
|
return;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import * as better_call from 'better-call';
|
|
3
|
-
import { U as User, I as InferOptionSchema, d as AuthEndpoint, G as GenericEndpointContext, S as Session, H as HookEndpointContext } from '../../shared/better-auth.
|
|
3
|
+
import { U as User, I as InferOptionSchema, d as AuthEndpoint, G as GenericEndpointContext, S as Session, H as HookEndpointContext } from '../../shared/better-auth.BDAwKjlL.cjs';
|
|
4
4
|
import { L as LiteralString } from '../../shared/better-auth.Bi8FQwDD.cjs';
|
|
5
5
|
import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
6
|
-
import '
|
|
7
|
-
import '../../shared/better-auth.CzK7QJBv.cjs';
|
|
6
|
+
import '../../shared/better-auth.CH6fRG6d.cjs';
|
|
8
7
|
import 'jose';
|
|
8
|
+
import 'kysely';
|
|
9
9
|
import 'better-sqlite3';
|
|
10
10
|
|
|
11
11
|
interface BackupCodeOptions {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import * as better_call from 'better-call';
|
|
3
|
-
import { U as User, I as InferOptionSchema, d as AuthEndpoint, G as GenericEndpointContext, S as Session, H as HookEndpointContext } from '../../shared/better-auth.
|
|
3
|
+
import { U as User, I as InferOptionSchema, d as AuthEndpoint, G as GenericEndpointContext, S as Session, H as HookEndpointContext } from '../../shared/better-auth.CTQDLJN7.mjs';
|
|
4
4
|
import { L as LiteralString } from '../../shared/better-auth.Bi8FQwDD.mjs';
|
|
5
5
|
import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
6
|
-
import '
|
|
7
|
-
import '../../shared/better-auth.BjoUuJNr.mjs';
|
|
6
|
+
import '../../shared/better-auth.BTnAiI8e.mjs';
|
|
8
7
|
import 'jose';
|
|
8
|
+
import 'kysely';
|
|
9
9
|
import 'better-sqlite3';
|
|
10
10
|
|
|
11
11
|
interface BackupCodeOptions {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import * as better_call from 'better-call';
|
|
3
|
-
import { U as User, I as InferOptionSchema, d as AuthEndpoint, G as GenericEndpointContext, S as Session, H as HookEndpointContext } from '../../shared/better-auth.
|
|
3
|
+
import { U as User, I as InferOptionSchema, d as AuthEndpoint, G as GenericEndpointContext, S as Session, H as HookEndpointContext } from '../../shared/better-auth.tpz8D0AA.js';
|
|
4
4
|
import { L as LiteralString } from '../../shared/better-auth.Bi8FQwDD.js';
|
|
5
5
|
import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
6
|
-
import '
|
|
7
|
-
import '../../shared/better-auth.Dd96RDNl.js';
|
|
6
|
+
import '../../shared/better-auth.BAfIsot3.js';
|
|
8
7
|
import 'jose';
|
|
8
|
+
import 'kysely';
|
|
9
9
|
import 'better-sqlite3';
|
|
10
10
|
|
|
11
11
|
interface BackupCodeOptions {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { g as generateRandomString } from '../../shared/better-auth.B4Qoxdgc.mjs';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { a as createAuthEndpoint, s as sessionMiddleware, c as createAuthMiddleware, B as BASE_ERROR_CODES } from '../../shared/better-auth.
|
|
3
|
+
import { a as createAuthEndpoint, s as sessionMiddleware, c as createAuthMiddleware, B as BASE_ERROR_CODES } from '../../shared/better-auth.DQ-pFMwp.mjs';
|
|
4
4
|
import { APIError } from 'better-call';
|
|
5
5
|
import { setSessionCookie, deleteSessionCookie } from '../../cookies/index.mjs';
|
|
6
6
|
import { m as mergeSchema } from '../../shared/better-auth.CepcSj5H.mjs';
|
|
@@ -8,7 +8,7 @@ import '../../shared/better-auth.8zoxzg-F.mjs';
|
|
|
8
8
|
import '../../shared/better-auth.DH3YjMQH.mjs';
|
|
9
9
|
import 'defu';
|
|
10
10
|
import { symmetricEncrypt, symmetricDecrypt } from '../../crypto/index.mjs';
|
|
11
|
-
import { v as verifyTwoFactorMiddleware, T as TRUST_DEVICE_COOKIE_NAME, a as TWO_FACTOR_COOKIE_NAME } from '../../shared/better-auth.
|
|
11
|
+
import { v as verifyTwoFactorMiddleware, T as TRUST_DEVICE_COOKIE_NAME, a as TWO_FACTOR_COOKIE_NAME } from '../../shared/better-auth.2rfXmCNS.mjs';
|
|
12
12
|
import { T as TWO_FACTOR_ERROR_CODES } from '../../shared/better-auth.BcoSd9tC.mjs';
|
|
13
13
|
import '@better-auth/utils/hash';
|
|
14
14
|
import '@noble/ciphers/chacha';
|
|
@@ -27,7 +27,7 @@ export { t as twoFactorClient } from '../../shared/better-auth.Ddw8bVyV.mjs';
|
|
|
27
27
|
import '@better-auth/utils/random';
|
|
28
28
|
import '../../social-providers/index.mjs';
|
|
29
29
|
import '@better-fetch/fetch';
|
|
30
|
-
import '../../shared/better-auth.
|
|
30
|
+
import '../../shared/better-auth.B2THyVQH.mjs';
|
|
31
31
|
import '../../shared/better-auth.CW6D9eSx.mjs';
|
|
32
32
|
import '../../shared/better-auth.DdzSJf-n.mjs';
|
|
33
33
|
import '../../shared/better-auth.BdyOG_p4.mjs';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const zod = require('zod');
|
|
4
|
-
const
|
|
4
|
+
const refreshToken = require('../../shared/better-auth.b0MLzqQX.cjs');
|
|
5
5
|
const betterCall = require('better-call');
|
|
6
6
|
const cookies_index = require('../../cookies/index.cjs');
|
|
7
7
|
const schema$1 = require('../../shared/better-auth.C5H9XEzZ.cjs');
|
|
@@ -12,7 +12,7 @@ const errorCode = require('../../shared/better-auth.C1-vpKly.cjs');
|
|
|
12
12
|
require('../../social-providers/index.cjs');
|
|
13
13
|
require('@better-fetch/fetch');
|
|
14
14
|
require('jose');
|
|
15
|
-
require('../../shared/better-auth.
|
|
15
|
+
require('../../shared/better-auth.BLV8UOn8.cjs');
|
|
16
16
|
require('../../shared/better-auth.C1hdVENX.cjs');
|
|
17
17
|
require('@better-auth/utils/hash');
|
|
18
18
|
require('@better-auth/utils/base64');
|
|
@@ -73,7 +73,7 @@ const username = (options) => {
|
|
|
73
73
|
return {
|
|
74
74
|
id: "username",
|
|
75
75
|
endpoints: {
|
|
76
|
-
signInUsername:
|
|
76
|
+
signInUsername: refreshToken.createAuthEndpoint(
|
|
77
77
|
"/sign-in/username",
|
|
78
78
|
{
|
|
79
79
|
method: "POST",
|
|
@@ -163,12 +163,12 @@ const username = (options) => {
|
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
165
|
if (!user.emailVerified && ctx.context.options.emailAndPassword?.requireEmailVerification) {
|
|
166
|
-
await
|
|
166
|
+
await refreshToken.sendVerificationEmailFn(ctx, user);
|
|
167
167
|
throw new betterCall.APIError("FORBIDDEN", {
|
|
168
168
|
message: ERROR_CODES.EMAIL_NOT_VERIFIED
|
|
169
169
|
});
|
|
170
170
|
}
|
|
171
|
-
const account
|
|
171
|
+
const account = await ctx.context.adapter.findOne({
|
|
172
172
|
model: "account",
|
|
173
173
|
where: [
|
|
174
174
|
{
|
|
@@ -181,12 +181,12 @@ const username = (options) => {
|
|
|
181
181
|
}
|
|
182
182
|
]
|
|
183
183
|
});
|
|
184
|
-
if (!account
|
|
184
|
+
if (!account) {
|
|
185
185
|
throw new betterCall.APIError("UNAUTHORIZED", {
|
|
186
186
|
message: ERROR_CODES.INVALID_USERNAME_OR_PASSWORD
|
|
187
187
|
});
|
|
188
188
|
}
|
|
189
|
-
const currentPassword = account
|
|
189
|
+
const currentPassword = account?.password;
|
|
190
190
|
if (!currentPassword) {
|
|
191
191
|
ctx.context.logger.error("Password not found", { username });
|
|
192
192
|
throw new betterCall.APIError("UNAUTHORIZED", {
|
|
@@ -212,7 +212,7 @@ const username = (options) => {
|
|
|
212
212
|
return ctx.json(null, {
|
|
213
213
|
status: 500,
|
|
214
214
|
body: {
|
|
215
|
-
message:
|
|
215
|
+
message: refreshToken.BASE_ERROR_CODES.FAILED_TO_CREATE_SESSION
|
|
216
216
|
}
|
|
217
217
|
});
|
|
218
218
|
}
|
|
@@ -244,7 +244,7 @@ const username = (options) => {
|
|
|
244
244
|
matcher(context) {
|
|
245
245
|
return context.path === "/sign-up/email" || context.path === "/update-user";
|
|
246
246
|
},
|
|
247
|
-
handler:
|
|
247
|
+
handler: refreshToken.createAuthMiddleware(async (ctx) => {
|
|
248
248
|
const username2 = ctx.body.username;
|
|
249
249
|
if (username2) {
|
|
250
250
|
const minUsernameLength = options?.minUsernameLength || 3;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import * as better_call from 'better-call';
|
|
3
|
-
import { I as InferOptionSchema, H as HookEndpointContext } from '../../shared/better-auth.
|
|
3
|
+
import { I as InferOptionSchema, H as HookEndpointContext } from '../../shared/better-auth.BDAwKjlL.cjs';
|
|
4
4
|
import '../../shared/better-auth.Bi8FQwDD.cjs';
|
|
5
|
-
import '
|
|
6
|
-
import '../../shared/better-auth.CzK7QJBv.cjs';
|
|
5
|
+
import '../../shared/better-auth.CH6fRG6d.cjs';
|
|
7
6
|
import 'jose';
|
|
7
|
+
import 'kysely';
|
|
8
8
|
import 'better-sqlite3';
|
|
9
9
|
|
|
10
10
|
declare const schema: {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import * as better_call from 'better-call';
|
|
3
|
-
import { I as InferOptionSchema, H as HookEndpointContext } from '../../shared/better-auth.
|
|
3
|
+
import { I as InferOptionSchema, H as HookEndpointContext } from '../../shared/better-auth.CTQDLJN7.mjs';
|
|
4
4
|
import '../../shared/better-auth.Bi8FQwDD.mjs';
|
|
5
|
-
import '
|
|
6
|
-
import '../../shared/better-auth.BjoUuJNr.mjs';
|
|
5
|
+
import '../../shared/better-auth.BTnAiI8e.mjs';
|
|
7
6
|
import 'jose';
|
|
7
|
+
import 'kysely';
|
|
8
8
|
import 'better-sqlite3';
|
|
9
9
|
|
|
10
10
|
declare const schema: {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import * as better_call from 'better-call';
|
|
3
|
-
import { I as InferOptionSchema, H as HookEndpointContext } from '../../shared/better-auth.
|
|
3
|
+
import { I as InferOptionSchema, H as HookEndpointContext } from '../../shared/better-auth.tpz8D0AA.js';
|
|
4
4
|
import '../../shared/better-auth.Bi8FQwDD.js';
|
|
5
|
-
import '
|
|
6
|
-
import '../../shared/better-auth.Dd96RDNl.js';
|
|
5
|
+
import '../../shared/better-auth.BAfIsot3.js';
|
|
7
6
|
import 'jose';
|
|
7
|
+
import 'kysely';
|
|
8
8
|
import 'better-sqlite3';
|
|
9
9
|
|
|
10
10
|
declare const schema: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { c as createAuthMiddleware, a as createAuthEndpoint, b as sendVerificationEmailFn, B as BASE_ERROR_CODES } from '../../shared/better-auth.
|
|
2
|
+
import { c as createAuthMiddleware, a as createAuthEndpoint, b as sendVerificationEmailFn, B as BASE_ERROR_CODES } from '../../shared/better-auth.DQ-pFMwp.mjs';
|
|
3
3
|
import { APIError } from 'better-call';
|
|
4
4
|
import { setSessionCookie } from '../../cookies/index.mjs';
|
|
5
5
|
import { m as mergeSchema } from '../../shared/better-auth.CepcSj5H.mjs';
|
|
@@ -10,7 +10,7 @@ import { T as TWO_FACTOR_ERROR_CODES } from '../../shared/better-auth.BcoSd9tC.m
|
|
|
10
10
|
import '../../social-providers/index.mjs';
|
|
11
11
|
import '@better-fetch/fetch';
|
|
12
12
|
import 'jose';
|
|
13
|
-
import '../../shared/better-auth.
|
|
13
|
+
import '../../shared/better-auth.B2THyVQH.mjs';
|
|
14
14
|
import '../../shared/better-auth.CW6D9eSx.mjs';
|
|
15
15
|
import '@better-auth/utils/hash';
|
|
16
16
|
import '@better-auth/utils/base64';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { APIError } from 'better-call';
|
|
2
|
-
import { c as createAuthMiddleware, g as getSessionFromCtx } from './better-auth.
|
|
2
|
+
import { c as createAuthMiddleware, g as getSessionFromCtx } from './better-auth.DQ-pFMwp.mjs';
|
|
3
3
|
import { setSessionCookie } from '../cookies/index.mjs';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import './better-auth.CepcSj5H.mjs';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { APIError } from 'better-call';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { c as createAuthMiddleware, s as sessionMiddleware, a as createAuthEndpoint, g as getSessionFromCtx, B as BASE_ERROR_CODES,
|
|
3
|
+
import { c as createAuthMiddleware, s as sessionMiddleware, a as createAuthEndpoint, g as getSessionFromCtx, B as BASE_ERROR_CODES, N as requestOnlySessionMiddleware } from './better-auth.DQ-pFMwp.mjs';
|
|
4
4
|
import './better-auth.8zoxzg-F.mjs';
|
|
5
5
|
import '@better-auth/utils/base64';
|
|
6
6
|
import '@better-auth/utils/hmac';
|
|
@@ -144,4 +144,57 @@ async function validateToken(token, jwksEndpoint) {
|
|
|
144
144
|
return verified;
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
|
|
147
|
+
async function refreshAccessToken({
|
|
148
|
+
refreshToken,
|
|
149
|
+
options,
|
|
150
|
+
tokenEndpoint,
|
|
151
|
+
authentication,
|
|
152
|
+
extraParams,
|
|
153
|
+
grantType = "refresh_token"
|
|
154
|
+
}) {
|
|
155
|
+
const body = new URLSearchParams();
|
|
156
|
+
const headers = {
|
|
157
|
+
"content-type": "application/x-www-form-urlencoded",
|
|
158
|
+
accept: "application/json"
|
|
159
|
+
};
|
|
160
|
+
body.set("grant_type", grantType);
|
|
161
|
+
body.set("refresh_token", refreshToken);
|
|
162
|
+
if (authentication === "basic") {
|
|
163
|
+
const encodedCredentials = btoa(
|
|
164
|
+
`${options.clientId}:${options.clientSecret}`
|
|
165
|
+
);
|
|
166
|
+
headers["authorization"] = `Basic ${encodedCredentials}`;
|
|
167
|
+
} else {
|
|
168
|
+
body.set("client_id", options.clientId);
|
|
169
|
+
body.set("client_secret", options.clientSecret);
|
|
170
|
+
}
|
|
171
|
+
if (extraParams) {
|
|
172
|
+
for (const [key, value] of Object.entries(extraParams)) {
|
|
173
|
+
body.set(key, value);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
const { data, error } = await betterFetch(tokenEndpoint, {
|
|
177
|
+
method: "POST",
|
|
178
|
+
body,
|
|
179
|
+
headers
|
|
180
|
+
});
|
|
181
|
+
if (error) {
|
|
182
|
+
throw error;
|
|
183
|
+
}
|
|
184
|
+
const tokens = {
|
|
185
|
+
accessToken: data.access_token,
|
|
186
|
+
refreshToken: data.refresh_token,
|
|
187
|
+
tokenType: data.token_type,
|
|
188
|
+
scopes: data.scope?.split(" "),
|
|
189
|
+
idToken: data.id_token
|
|
190
|
+
};
|
|
191
|
+
if (data.expires_in) {
|
|
192
|
+
const now = /* @__PURE__ */ new Date();
|
|
193
|
+
tokens.accessTokenExpiresAt = new Date(
|
|
194
|
+
now.getTime() + data.expires_in * 1e3
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
return tokens;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export { validateToken as a, getOAuth2Tokens as b, createAuthorizationURL as c, generateCodeChallenge as g, refreshAccessToken as r, validateAuthorizationCode as v };
|