better-auth 1.3.8-beta.1 → 1.3.8-beta.3
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.cjs +3 -3
- 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/drizzle-adapter/index.mjs +3 -3
- package/dist/adapters/index.cjs +3 -3
- package/dist/adapters/index.d.cts +4 -4
- package/dist/adapters/index.d.mts +4 -4
- package/dist/adapters/index.d.ts +4 -4
- package/dist/adapters/index.mjs +3 -3
- package/dist/adapters/kysely-adapter/index.cjs +4 -4
- 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/kysely-adapter/index.mjs +4 -4
- package/dist/adapters/memory-adapter/index.cjs +4 -4
- 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/memory-adapter/index.mjs +4 -4
- package/dist/adapters/mongodb-adapter/index.cjs +4 -4
- 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/mongodb-adapter/index.mjs +4 -4
- package/dist/adapters/prisma-adapter/index.cjs +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/prisma-adapter/index.mjs +3 -3
- package/dist/adapters/test.cjs +1 -1
- 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/adapters/test.mjs +1 -1
- package/dist/api/index.cjs +38 -37
- package/dist/api/index.d.cts +3 -3
- package/dist/api/index.d.mts +3 -3
- package/dist/api/index.d.ts +3 -3
- package/dist/api/index.mjs +9 -7
- package/dist/chunks/node-sqlite-dialect.cjs +171 -0
- package/dist/chunks/node-sqlite-dialect.mjs +165 -0
- package/dist/client/index.cjs +2 -2
- package/dist/client/index.d.cts +5 -5
- package/dist/client/index.d.mts +5 -5
- package/dist/client/index.d.ts +5 -5
- package/dist/client/index.mjs +2 -2
- package/dist/client/plugins/index.cjs +2 -0
- package/dist/client/plugins/index.d.cts +6 -5
- package/dist/client/plugins/index.d.mts +6 -5
- package/dist/client/plugins/index.d.ts +6 -5
- package/dist/client/plugins/index.mjs +1 -0
- package/dist/client/react/index.cjs +1 -1
- 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/react/index.mjs +1 -1
- package/dist/client/solid/index.cjs +1 -1
- package/dist/client/solid/index.d.cts +10 -10
- package/dist/client/solid/index.d.mts +10 -10
- package/dist/client/solid/index.d.ts +10 -10
- package/dist/client/solid/index.mjs +1 -1
- package/dist/client/svelte/index.cjs +1 -1
- package/dist/client/svelte/index.d.cts +10 -10
- package/dist/client/svelte/index.d.mts +10 -10
- package/dist/client/svelte/index.d.ts +10 -10
- package/dist/client/svelte/index.mjs +1 -1
- package/dist/client/vue/index.cjs +1 -1
- 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/client/vue/index.mjs +1 -1
- package/dist/cookies/index.cjs +20 -430
- 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/cookies/index.mjs +10 -424
- package/dist/db/index.cjs +6 -6
- 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 +6 -6
- package/dist/index.cjs +11 -10
- package/dist/index.d.cts +13 -13
- package/dist/index.d.mts +13 -13
- package/dist/index.d.ts +13 -13
- package/dist/index.mjs +11 -10
- package/dist/integrations/next-js.cjs +9 -6
- 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 +8 -5
- 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/react-start.cjs +9 -6
- package/dist/integrations/react-start.d.cts +3 -3
- package/dist/integrations/react-start.d.mts +3 -3
- package/dist/integrations/react-start.d.ts +3 -3
- package/dist/integrations/react-start.mjs +8 -5
- package/dist/integrations/svelte-kit.cjs +6 -5
- 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/integrations/svelte-kit.mjs +5 -4
- package/dist/oauth2/index.cjs +13 -10
- package/dist/oauth2/index.d.cts +34 -8
- package/dist/oauth2/index.d.mts +34 -8
- package/dist/oauth2/index.d.ts +34 -8
- package/dist/oauth2/index.mjs +11 -10
- package/dist/plugins/access/index.d.cts +1 -1
- package/dist/plugins/access/index.d.mts +1 -1
- package/dist/plugins/access/index.d.ts +1 -1
- package/dist/plugins/admin/access/index.d.cts +1 -1
- package/dist/plugins/admin/access/index.d.mts +1 -1
- package/dist/plugins/admin/access/index.d.ts +1 -1
- package/dist/plugins/admin/index.cjs +12 -11
- package/dist/plugins/admin/index.d.cts +7 -7
- package/dist/plugins/admin/index.d.mts +7 -7
- package/dist/plugins/admin/index.d.ts +7 -7
- package/dist/plugins/admin/index.mjs +12 -11
- package/dist/plugins/anonymous/index.cjs +12 -11
- 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 +6 -5
- package/dist/plugins/bearer/index.cjs +7 -6
- 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 +5 -4
- package/dist/plugins/captcha/index.d.cts +3 -3
- package/dist/plugins/captcha/index.d.mts +3 -3
- package/dist/plugins/captcha/index.d.ts +3 -3
- package/dist/plugins/custom-session/index.cjs +10 -9
- 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 +5 -4
- package/dist/plugins/device-authorization/index.cjs +922 -0
- package/dist/plugins/device-authorization/index.d.cts +638 -0
- package/dist/plugins/device-authorization/index.d.mts +638 -0
- package/dist/plugins/device-authorization/index.d.ts +638 -0
- package/dist/plugins/device-authorization/index.mjs +905 -0
- package/dist/plugins/email-otp/index.cjs +16 -15
- 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 +7 -6
- package/dist/plugins/generic-oauth/index.cjs +46 -31
- package/dist/plugins/generic-oauth/index.d.cts +5 -19
- package/dist/plugins/generic-oauth/index.d.mts +5 -19
- package/dist/plugins/generic-oauth/index.d.ts +5 -19
- package/dist/plugins/generic-oauth/index.mjs +38 -23
- package/dist/plugins/haveibeenpwned/index.cjs +5 -4
- package/dist/plugins/haveibeenpwned/index.d.cts +3 -3
- package/dist/plugins/haveibeenpwned/index.d.mts +3 -3
- package/dist/plugins/haveibeenpwned/index.d.ts +3 -3
- package/dist/plugins/haveibeenpwned/index.mjs +5 -4
- package/dist/plugins/index.cjs +30 -24
- package/dist/plugins/index.d.cts +8 -7
- package/dist/plugins/index.d.mts +8 -7
- package/dist/plugins/index.d.ts +8 -7
- package/dist/plugins/index.mjs +14 -11
- package/dist/plugins/jwt/index.cjs +58 -17
- package/dist/plugins/jwt/index.d.cts +14 -3
- package/dist/plugins/jwt/index.d.mts +14 -3
- package/dist/plugins/jwt/index.d.ts +14 -3
- package/dist/plugins/jwt/index.mjs +53 -12
- package/dist/plugins/magic-link/index.cjs +13 -12
- package/dist/plugins/magic-link/index.mjs +10 -9
- package/dist/plugins/multi-session/index.cjs +14 -13
- 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 +7 -6
- package/dist/plugins/oauth-proxy/index.cjs +8 -7
- 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 +5 -4
- package/dist/plugins/oidc-provider/index.cjs +6 -5
- package/dist/plugins/oidc-provider/index.d.cts +7 -7
- package/dist/plugins/oidc-provider/index.d.mts +7 -7
- package/dist/plugins/oidc-provider/index.d.ts +7 -7
- package/dist/plugins/oidc-provider/index.mjs +6 -5
- package/dist/plugins/one-tap/index.cjs +8 -7
- package/dist/plugins/one-tap/index.mjs +7 -6
- package/dist/plugins/one-time-token/index.cjs +11 -8
- package/dist/plugins/one-time-token/index.d.cts +3 -3
- package/dist/plugins/one-time-token/index.d.mts +3 -3
- package/dist/plugins/one-time-token/index.d.ts +3 -3
- package/dist/plugins/one-time-token/index.mjs +11 -8
- package/dist/plugins/open-api/index.cjs +7 -6
- 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 +5 -4
- package/dist/plugins/organization/access/index.d.cts +1 -1
- package/dist/plugins/organization/access/index.d.mts +1 -1
- package/dist/plugins/organization/access/index.d.ts +1 -1
- package/dist/plugins/organization/index.cjs +13 -12
- package/dist/plugins/organization/index.d.cts +7 -7
- package/dist/plugins/organization/index.d.mts +7 -7
- package/dist/plugins/organization/index.d.ts +7 -7
- package/dist/plugins/organization/index.mjs +13 -12
- package/dist/plugins/passkey/index.cjs +23 -22
- 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 +7 -6
- package/dist/plugins/phone-number/index.cjs +32 -31
- 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 +9 -8
- package/dist/plugins/siwe/index.cjs +11 -10
- package/dist/plugins/siwe/index.d.cts +41 -0
- package/dist/plugins/siwe/index.d.mts +41 -0
- package/dist/plugins/siwe/index.d.ts +41 -0
- package/dist/plugins/siwe/index.mjs +9 -8
- package/dist/plugins/sso/index.cjs +11 -10
- package/dist/plugins/sso/index.d.cts +5 -5
- package/dist/plugins/sso/index.d.mts +5 -5
- package/dist/plugins/sso/index.d.ts +5 -5
- package/dist/plugins/sso/index.mjs +7 -6
- package/dist/plugins/two-factor/index.cjs +47 -46
- 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 +5 -4
- package/dist/plugins/username/index.cjs +19 -18
- package/dist/plugins/username/index.d.cts +5 -5
- package/dist/plugins/username/index.d.mts +5 -5
- package/dist/plugins/username/index.d.ts +5 -5
- package/dist/plugins/username/index.mjs +10 -9
- package/dist/shared/{better-auth.CwsxfHfN.mjs → better-auth.B-xYKxwt.mjs} +9 -97
- package/dist/shared/{better-auth.Bf5MnLaK.d.cts → better-auth.B29NjI62.d.cts} +4 -4
- package/dist/shared/{better-auth.GpOOav9x.cjs → better-auth.B3274wGK.cjs} +7 -1
- package/dist/shared/{better-auth.p1GhhfhV.mjs → better-auth.B548OOOk.mjs} +32 -30
- package/dist/shared/better-auth.BMgeJg3r.cjs +17 -0
- package/dist/shared/{better-auth.BCerfnoo.cjs → better-auth.BNhZazTR.cjs} +20 -1
- package/dist/shared/{better-auth.DIfzDoPN.mjs → better-auth.BQNzC8cU.mjs} +1 -1
- package/dist/shared/{better-auth.gABN3TsS.mjs → better-auth.BSGkasIG.mjs} +2 -2
- package/dist/shared/{better-auth.6hiPn8Kd.d.mts → better-auth.BU9YW_qQ.d.cts} +6 -6
- package/dist/shared/{better-auth.0SyTY9U9.d.ts → better-auth.BWfwO5vl.d.cts} +21 -73
- package/dist/shared/{better-auth.BDEfedYa.d.mts → better-auth.BYJu3IQC.d.ts} +4 -4
- package/dist/shared/{better-auth.PgM8qMHr.mjs → better-auth.BZZKN1g7.mjs} +1 -1
- package/dist/shared/{better-auth.BtemoGGn.mjs → better-auth.B_3Nie7C.mjs} +2 -2
- package/dist/shared/{better-auth.CCCUvENJ.cjs → better-auth.BblrvPZ3.cjs} +1 -1
- package/dist/shared/better-auth.BfeJWAMn.mjs +497 -0
- package/dist/shared/{better-auth.DH3YjMQH.mjs → better-auth.BjBlybv-.mjs} +7 -1
- package/dist/shared/better-auth.BpA03GIs.mjs +15 -0
- package/dist/shared/{better-auth.DrzbcRgZ.cjs → better-auth.BpptWVxZ.cjs} +65 -64
- package/dist/shared/{better-auth.D85s0t2j.d.mts → better-auth.BqrGtIt2.d.mts} +1 -1
- package/dist/shared/{better-auth.C_0BlDB0.d.ts → better-auth.BvN9j5Ap.d.ts} +1 -1
- package/dist/shared/{better-auth.BS4wi0R-.d.mts → better-auth.Bxn_1Cii.d.ts} +21 -73
- package/dist/shared/{better-auth.DiE4yQHn.mjs → better-auth.C8Y2rhan.mjs} +5 -4
- package/dist/shared/{better-auth.Co0UDY4N.cjs → better-auth.CFZJKUMM.cjs} +10 -98
- package/dist/shared/{better-auth.CVQe8izV.mjs → better-auth.CGGao4aY.mjs} +7 -0
- package/dist/shared/{better-auth.NCWQv_ti.cjs → better-auth.CKjaHNrP.cjs} +39 -45
- package/dist/shared/{better-auth.CFtZttAn.cjs → better-auth.CL4S7WA5.cjs} +2 -2
- package/dist/shared/{better-auth.Bgs2SPcK.cjs → better-auth.CMnvkNNK.cjs} +2 -2
- package/dist/shared/{better-auth.BbDyeJdW.cjs → better-auth.CR4J09bm.cjs} +6 -5
- package/dist/shared/{better-auth.DMus0Wrm.mjs → better-auth.Cl1MyjEq.mjs} +254 -510
- package/dist/shared/{better-auth.Db2g2HxM.cjs → better-auth.CmdI9lHT.cjs} +1 -1
- package/dist/shared/{better-auth.DrQaSEU_.mjs → better-auth.CsvyivcG.mjs} +21 -27
- package/dist/shared/{better-auth.CVYnNkfw.cjs → better-auth.CtToz4qL.cjs} +7 -0
- package/dist/shared/{better-auth.YmpB7UaD.d.cts → better-auth.D2gg3ys1.d.cts} +1 -1
- package/dist/shared/{better-auth.Je5iPAGQ.d.mts → better-auth.D4yr0Ou1.d.ts} +200 -11
- package/dist/shared/{better-auth.HYhkNVyD.mjs → better-auth.D96SwENp.mjs} +20 -1
- package/dist/shared/better-auth.DF-MUmVw.mjs +479 -0
- package/dist/shared/{better-auth.BDR52Rf2.d.cts → better-auth.DTtXpZYr.d.cts} +2 -1
- package/dist/shared/{better-auth.BDR52Rf2.d.mts → better-auth.DTtXpZYr.d.mts} +2 -1
- package/dist/shared/{better-auth.BDR52Rf2.d.ts → better-auth.DTtXpZYr.d.ts} +2 -1
- package/dist/shared/{better-auth.BDBtglk1.mjs → better-auth.DVsI0DHa.mjs} +1 -1
- package/dist/shared/{better-auth.DX362szo.mjs → better-auth.DY8mXezF.mjs} +4 -3
- package/dist/shared/{better-auth.PFi3XfiT.mjs → better-auth.DZVMh_VM.mjs} +3 -2
- package/dist/shared/better-auth.DmBU2Klq.cjs +526 -0
- package/dist/shared/{better-auth._D1fz1Yx.d.ts → better-auth.DoFtnL_B.d.mts} +4 -4
- package/dist/shared/{better-auth.MrJBhiF6.mjs → better-auth.Dqe7GuxR.mjs} +4 -4
- package/dist/shared/{better-auth.CkqBZvXM.d.cts → better-auth.Du7MKGKS.d.cts} +200 -11
- package/dist/shared/{better-auth.X6YzBCDT.d.cts → better-auth.DymB1NxW.d.mts} +6 -6
- package/dist/shared/{better-auth.DnUZno9_.d.ts → better-auth.F1OUHOUm.d.mts} +200 -11
- package/dist/shared/{better-auth.CRyLLXtn.cjs → better-auth.UmJlYEfa.cjs} +395 -662
- package/dist/shared/{better-auth.WTr4EDT7.cjs → better-auth.cBJ0kvYy.cjs} +36 -35
- package/dist/shared/better-auth.l2-e84v_.cjs +491 -0
- package/dist/shared/{better-auth.CkEkCniR.d.cts → better-auth.oCjO5qEz.d.mts} +21 -73
- package/dist/shared/{better-auth.D4eTSyUO.cjs → better-auth.pXA_xs2e.cjs} +50 -48
- package/dist/shared/{better-auth.DrKKZc3v.cjs → better-auth.spuYC23a.cjs} +4 -4
- package/dist/shared/{better-auth.CLfudv58.d.ts → better-auth.tDeNcGKy.d.ts} +5 -5
- package/dist/shared/{better-auth.DbrEw0kN.cjs → better-auth.vPQBmXQL.cjs} +1 -1
- package/dist/social-providers/index.cjs +12 -10
- package/dist/social-providers/index.d.cts +2 -2
- package/dist/social-providers/index.d.mts +2 -2
- package/dist/social-providers/index.d.ts +2 -2
- package/dist/social-providers/index.mjs +11 -10
- package/dist/test-utils/index.cjs +16 -13
- package/dist/test-utils/index.d.cts +32 -116
- package/dist/test-utils/index.d.mts +32 -116
- package/dist/test-utils/index.d.ts +32 -116
- package/dist/test-utils/index.mjs +16 -13
- 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 +20 -4
|
@@ -4,13 +4,13 @@ export * from 'nanostores';
|
|
|
4
4
|
import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
5
5
|
import { BetterFetchError } from '@better-fetch/fetch';
|
|
6
6
|
export * from '@better-fetch/fetch';
|
|
7
|
-
import { C as ClientOptions, B as BetterAuthClientPlugin, I as IsSignal, a as InferClientAPI, b as InferActions, c as InferErrorCodes } from '../../shared/better-auth.
|
|
8
|
-
import { U as UnionToIntersection, P as PrettifyDeep } from '../../shared/better-auth.
|
|
9
|
-
import { f as BASE_ERROR_CODES } from '../../shared/better-auth.
|
|
7
|
+
import { C as ClientOptions, B as BetterAuthClientPlugin, I as IsSignal, a as InferClientAPI, b as InferActions, c as InferErrorCodes } from '../../shared/better-auth.BYJu3IQC.js';
|
|
8
|
+
import { U as UnionToIntersection, P as PrettifyDeep } from '../../shared/better-auth.DTtXpZYr.js';
|
|
9
|
+
import { f as BASE_ERROR_CODES } from '../../shared/better-auth.Bxn_1Cii.js';
|
|
10
10
|
import 'better-call';
|
|
11
11
|
import 'kysely';
|
|
12
12
|
import 'zod/v4';
|
|
13
|
-
import '../../shared/better-auth.
|
|
13
|
+
import '../../shared/better-auth.D4yr0Ou1.js';
|
|
14
14
|
import 'jose';
|
|
15
15
|
import 'zod/v4/core';
|
|
16
16
|
import 'zod';
|
|
@@ -25,15 +25,15 @@ declare function createAuthClient<Option extends ClientOptions>(options?: Option
|
|
|
25
25
|
data: InferClientAPI<Option> extends {
|
|
26
26
|
getSession: () => Promise<infer Res>;
|
|
27
27
|
} ? Res extends {
|
|
28
|
+
data: infer S;
|
|
29
|
+
error: null;
|
|
30
|
+
} | {
|
|
28
31
|
data: null;
|
|
29
32
|
error: {
|
|
30
33
|
message?: string | undefined;
|
|
31
34
|
status: number;
|
|
32
35
|
statusText: string;
|
|
33
36
|
};
|
|
34
|
-
} | {
|
|
35
|
-
data: infer S;
|
|
36
|
-
error: null;
|
|
37
37
|
} ? S : Res extends Record<string, any> ? Res : never : never;
|
|
38
38
|
error: BetterFetchError | null;
|
|
39
39
|
isPending: boolean;
|
|
@@ -113,15 +113,15 @@ declare function createAuthClient<Option extends ClientOptions>(options?: Option
|
|
|
113
113
|
Session: NonNullable<InferClientAPI<Option> extends {
|
|
114
114
|
getSession: () => Promise<infer Res>;
|
|
115
115
|
} ? Res extends {
|
|
116
|
+
data: infer S;
|
|
117
|
+
error: null;
|
|
118
|
+
} | {
|
|
116
119
|
data: null;
|
|
117
120
|
error: {
|
|
118
121
|
message?: string | undefined;
|
|
119
122
|
status: number;
|
|
120
123
|
statusText: string;
|
|
121
124
|
};
|
|
122
|
-
} | {
|
|
123
|
-
data: infer S;
|
|
124
|
-
error: null;
|
|
125
125
|
} ? S : Res extends Record<string, any> ? Res : never : never>;
|
|
126
126
|
};
|
|
127
127
|
$ERROR_CODES: PrettifyDeep<InferErrorCodes<Option> & typeof BASE_ERROR_CODES>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as getClientConfig, c as createDynamicPathProxy } from '../../shared/better-auth.
|
|
1
|
+
import { g as getClientConfig, c as createDynamicPathProxy } from '../../shared/better-auth.CGGao4aY.mjs';
|
|
2
2
|
import { c as capitalizeFirstLetter } from '../../shared/better-auth.D-2CmEwz.mjs';
|
|
3
3
|
import '@better-fetch/fetch';
|
|
4
4
|
import '../../shared/better-auth.CuS_eDdK.mjs';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const vue = require('vue');
|
|
4
|
-
const proxy = require('../../shared/better-auth.
|
|
4
|
+
const proxy = require('../../shared/better-auth.CtToz4qL.cjs');
|
|
5
5
|
const misc = require('../../shared/better-auth.BLDOwz3i.cjs');
|
|
6
6
|
require('@better-fetch/fetch');
|
|
7
7
|
require('../../shared/better-auth.DRmln2Nr.cjs');
|
|
@@ -4,13 +4,13 @@ import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
|
4
4
|
import { BetterFetchError } from '@better-fetch/fetch';
|
|
5
5
|
export * from '@better-fetch/fetch';
|
|
6
6
|
import { DeepReadonly, Ref } from 'vue';
|
|
7
|
-
import { C as ClientOptions, B as BetterAuthClientPlugin, I as IsSignal, a as InferClientAPI, b as InferActions, c as InferErrorCodes } from '../../shared/better-auth.
|
|
8
|
-
import { U as UnionToIntersection, P as PrettifyDeep } from '../../shared/better-auth.
|
|
9
|
-
import { f as BASE_ERROR_CODES } from '../../shared/better-auth.
|
|
7
|
+
import { C as ClientOptions, B as BetterAuthClientPlugin, I as IsSignal, a as InferClientAPI, b as InferActions, c as InferErrorCodes } from '../../shared/better-auth.B29NjI62.cjs';
|
|
8
|
+
import { U as UnionToIntersection, P as PrettifyDeep } from '../../shared/better-auth.DTtXpZYr.cjs';
|
|
9
|
+
import { f as BASE_ERROR_CODES } from '../../shared/better-auth.BWfwO5vl.cjs';
|
|
10
10
|
import 'better-call';
|
|
11
11
|
import 'kysely';
|
|
12
12
|
import 'zod/v4';
|
|
13
|
-
import '../../shared/better-auth.
|
|
13
|
+
import '../../shared/better-auth.Du7MKGKS.cjs';
|
|
14
14
|
import 'jose';
|
|
15
15
|
import 'zod/v4/core';
|
|
16
16
|
import 'zod';
|
|
@@ -4,13 +4,13 @@ import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
|
4
4
|
import { BetterFetchError } from '@better-fetch/fetch';
|
|
5
5
|
export * from '@better-fetch/fetch';
|
|
6
6
|
import { DeepReadonly, Ref } from 'vue';
|
|
7
|
-
import { C as ClientOptions, B as BetterAuthClientPlugin, I as IsSignal, a as InferClientAPI, b as InferActions, c as InferErrorCodes } from '../../shared/better-auth.
|
|
8
|
-
import { U as UnionToIntersection, P as PrettifyDeep } from '../../shared/better-auth.
|
|
9
|
-
import { f as BASE_ERROR_CODES } from '../../shared/better-auth.
|
|
7
|
+
import { C as ClientOptions, B as BetterAuthClientPlugin, I as IsSignal, a as InferClientAPI, b as InferActions, c as InferErrorCodes } from '../../shared/better-auth.DoFtnL_B.mjs';
|
|
8
|
+
import { U as UnionToIntersection, P as PrettifyDeep } from '../../shared/better-auth.DTtXpZYr.mjs';
|
|
9
|
+
import { f as BASE_ERROR_CODES } from '../../shared/better-auth.oCjO5qEz.mjs';
|
|
10
10
|
import 'better-call';
|
|
11
11
|
import 'kysely';
|
|
12
12
|
import 'zod/v4';
|
|
13
|
-
import '../../shared/better-auth.
|
|
13
|
+
import '../../shared/better-auth.F1OUHOUm.mjs';
|
|
14
14
|
import 'jose';
|
|
15
15
|
import 'zod/v4/core';
|
|
16
16
|
import 'zod';
|
|
@@ -4,13 +4,13 @@ import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
|
4
4
|
import { BetterFetchError } from '@better-fetch/fetch';
|
|
5
5
|
export * from '@better-fetch/fetch';
|
|
6
6
|
import { DeepReadonly, Ref } from 'vue';
|
|
7
|
-
import { C as ClientOptions, B as BetterAuthClientPlugin, I as IsSignal, a as InferClientAPI, b as InferActions, c as InferErrorCodes } from '../../shared/better-auth.
|
|
8
|
-
import { U as UnionToIntersection, P as PrettifyDeep } from '../../shared/better-auth.
|
|
9
|
-
import { f as BASE_ERROR_CODES } from '../../shared/better-auth.
|
|
7
|
+
import { C as ClientOptions, B as BetterAuthClientPlugin, I as IsSignal, a as InferClientAPI, b as InferActions, c as InferErrorCodes } from '../../shared/better-auth.BYJu3IQC.js';
|
|
8
|
+
import { U as UnionToIntersection, P as PrettifyDeep } from '../../shared/better-auth.DTtXpZYr.js';
|
|
9
|
+
import { f as BASE_ERROR_CODES } from '../../shared/better-auth.Bxn_1Cii.js';
|
|
10
10
|
import 'better-call';
|
|
11
11
|
import 'kysely';
|
|
12
12
|
import 'zod/v4';
|
|
13
|
-
import '../../shared/better-auth.
|
|
13
|
+
import '../../shared/better-auth.D4yr0Ou1.js';
|
|
14
14
|
import 'jose';
|
|
15
15
|
import 'zod/v4/core';
|
|
16
16
|
import 'zod';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { shallowRef, getCurrentScope, onScopeDispose, readonly, getCurrentInstance } from 'vue';
|
|
2
|
-
import { g as getClientConfig, c as createDynamicPathProxy } from '../../shared/better-auth.
|
|
2
|
+
import { g as getClientConfig, c as createDynamicPathProxy } from '../../shared/better-auth.CGGao4aY.mjs';
|
|
3
3
|
import { c as capitalizeFirstLetter } from '../../shared/better-auth.D-2CmEwz.mjs';
|
|
4
4
|
import '@better-fetch/fetch';
|
|
5
5
|
import '../../shared/better-auth.CuS_eDdK.mjs';
|
package/dist/cookies/index.cjs
CHANGED
|
@@ -1,435 +1,25 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
require('
|
|
3
|
+
require('../shared/better-auth.ANpbi45u.cjs');
|
|
4
|
+
require('../shared/better-auth.C1hdVENX.cjs');
|
|
5
|
+
require('../shared/better-auth.B6fIklBU.cjs');
|
|
6
|
+
require('@better-auth/utils/base64');
|
|
7
|
+
const cookies_index = require('../shared/better-auth.l2-e84v_.cjs');
|
|
8
|
+
require('@better-auth/utils/hmac');
|
|
9
|
+
require('../shared/better-auth.vPQBmXQL.cjs');
|
|
10
|
+
require('../shared/better-auth.DRmln2Nr.cjs');
|
|
11
|
+
require('@better-auth/utils/binary');
|
|
12
|
+
require('../shared/better-auth.B3274wGK.cjs');
|
|
12
13
|
|
|
13
|
-
const createTime = (value, format) => {
|
|
14
|
-
const toMilliseconds = () => {
|
|
15
|
-
switch (format) {
|
|
16
|
-
case "ms":
|
|
17
|
-
return value;
|
|
18
|
-
case "s":
|
|
19
|
-
return value * 1e3;
|
|
20
|
-
case "m":
|
|
21
|
-
return value * 1e3 * 60;
|
|
22
|
-
case "h":
|
|
23
|
-
return value * 1e3 * 60 * 60;
|
|
24
|
-
case "d":
|
|
25
|
-
return value * 1e3 * 60 * 60 * 24;
|
|
26
|
-
case "w":
|
|
27
|
-
return value * 1e3 * 60 * 60 * 24 * 7;
|
|
28
|
-
case "y":
|
|
29
|
-
return value * 1e3 * 60 * 60 * 24 * 365;
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
const time = {
|
|
33
|
-
t: `${value}${format}`,
|
|
34
|
-
value,
|
|
35
|
-
tFormat: format,
|
|
36
|
-
toMilliseconds,
|
|
37
|
-
toSeconds: () => time.toMilliseconds() / 1e3,
|
|
38
|
-
toMinutes: () => time.toSeconds() / 60,
|
|
39
|
-
toHours: () => time.toMinutes() / 60,
|
|
40
|
-
toDays: () => time.toHours() / 24,
|
|
41
|
-
toWeeks: () => time.toDays() / 7,
|
|
42
|
-
toYears: () => time.toDays() / 365,
|
|
43
|
-
getDate: () => new Date(Date.now() + time.toMilliseconds()),
|
|
44
|
-
add: (other) => {
|
|
45
|
-
const otherMs = typeof other === "string" ? parseTime(other).toMilliseconds() : other.toMilliseconds();
|
|
46
|
-
return createTime(time.toMilliseconds() + otherMs, "ms");
|
|
47
|
-
},
|
|
48
|
-
subtract: (other) => {
|
|
49
|
-
const otherMs = typeof other === "string" ? parseTime(other).toMilliseconds() : other.toMilliseconds();
|
|
50
|
-
return createTime(time.toMilliseconds() - otherMs, "ms");
|
|
51
|
-
},
|
|
52
|
-
multiply: (factor) => createTime(time.toMilliseconds() * factor, "ms"),
|
|
53
|
-
divide: (divisor) => createTime(time.toMilliseconds() / divisor, "ms"),
|
|
54
|
-
equals: (other) => {
|
|
55
|
-
const otherMs = typeof other === "string" ? parseTime(other).toMilliseconds() : other.toMilliseconds();
|
|
56
|
-
return time.toMilliseconds() === otherMs;
|
|
57
|
-
},
|
|
58
|
-
lessThan: (other) => {
|
|
59
|
-
const otherMs = typeof other === "string" ? parseTime(other).toMilliseconds() : other.toMilliseconds();
|
|
60
|
-
return time.toMilliseconds() < otherMs;
|
|
61
|
-
},
|
|
62
|
-
greaterThan: (other) => {
|
|
63
|
-
const otherMs = typeof other === "string" ? parseTime(other).toMilliseconds() : other.toMilliseconds();
|
|
64
|
-
return time.toMilliseconds() > otherMs;
|
|
65
|
-
},
|
|
66
|
-
format: (pattern) => {
|
|
67
|
-
const date = time.getDate();
|
|
68
|
-
return pattern.replace(/YYYY|MM|DD|HH|mm|ss/g, (match) => {
|
|
69
|
-
switch (match) {
|
|
70
|
-
case "YYYY":
|
|
71
|
-
return date.getFullYear().toString();
|
|
72
|
-
case "MM":
|
|
73
|
-
return (date.getMonth() + 1).toString().padStart(2, "0");
|
|
74
|
-
case "DD":
|
|
75
|
-
return date.getDate().toString().padStart(2, "0");
|
|
76
|
-
case "HH":
|
|
77
|
-
return date.getHours().toString().padStart(2, "0");
|
|
78
|
-
case "mm":
|
|
79
|
-
return date.getMinutes().toString().padStart(2, "0");
|
|
80
|
-
case "ss":
|
|
81
|
-
return date.getSeconds().toString().padStart(2, "0");
|
|
82
|
-
default:
|
|
83
|
-
return match;
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
},
|
|
87
|
-
fromNow: () => {
|
|
88
|
-
const ms = time.toMilliseconds();
|
|
89
|
-
if (ms < 0) return time.ago();
|
|
90
|
-
if (ms < 1e3) return "in a few seconds";
|
|
91
|
-
if (ms < 6e4) return `in ${Math.round(ms / 1e3)} seconds`;
|
|
92
|
-
if (ms < 36e5) return `in ${Math.round(ms / 6e4)} minutes`;
|
|
93
|
-
if (ms < 864e5) return `in ${Math.round(ms / 36e5)} hours`;
|
|
94
|
-
if (ms < 6048e5) return `in ${Math.round(ms / 864e5)} days`;
|
|
95
|
-
if (ms < 26298e5) return `in ${Math.round(ms / 6048e5)} weeks`;
|
|
96
|
-
if (ms < 315576e5) return `in ${Math.round(ms / 26298e5)} months`;
|
|
97
|
-
return `in ${Math.round(ms / 315576e5)} years`;
|
|
98
|
-
},
|
|
99
|
-
ago: () => {
|
|
100
|
-
const ms = -time.toMilliseconds();
|
|
101
|
-
if (ms < 0) return time.fromNow();
|
|
102
|
-
if (ms < 1e3) return "a few seconds ago";
|
|
103
|
-
if (ms < 6e4) return `${Math.round(ms / 1e3)} seconds ago`;
|
|
104
|
-
if (ms < 36e5) return `${Math.round(ms / 6e4)} minutes ago`;
|
|
105
|
-
if (ms < 864e5) return `${Math.round(ms / 36e5)} hours ago`;
|
|
106
|
-
if (ms < 6048e5) return `${Math.round(ms / 864e5)} days ago`;
|
|
107
|
-
if (ms < 26298e5) return `${Math.round(ms / 6048e5)} weeks ago`;
|
|
108
|
-
if (ms < 315576e5) return `${Math.round(ms / 26298e5)} months ago`;
|
|
109
|
-
return `${Math.round(ms / 315576e5)} years ago`;
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
return time;
|
|
113
|
-
};
|
|
114
|
-
const parseTime = (time) => {
|
|
115
|
-
const match = time.match(/^(\d+)(ms|s|m|h|d|w|y)$/);
|
|
116
|
-
if (!match) throw new Error("Invalid time format");
|
|
117
|
-
return createTime(parseInt(match[1]), match[2]);
|
|
118
|
-
};
|
|
119
14
|
|
|
120
|
-
function parseSetCookieHeader(setCookie) {
|
|
121
|
-
const cookies = /* @__PURE__ */ new Map();
|
|
122
|
-
const cookieArray = setCookie.split(", ");
|
|
123
|
-
cookieArray.forEach((cookieString) => {
|
|
124
|
-
const parts = cookieString.split(";").map((part) => part.trim());
|
|
125
|
-
const [nameValue, ...attributes] = parts;
|
|
126
|
-
const [name, ...valueParts] = nameValue.split("=");
|
|
127
|
-
const value = valueParts.join("=");
|
|
128
|
-
if (!name || value === void 0) {
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
const attrObj = { value };
|
|
132
|
-
attributes.forEach((attribute) => {
|
|
133
|
-
const [attrName, ...attrValueParts] = attribute.split("=");
|
|
134
|
-
const attrValue = attrValueParts.join("=");
|
|
135
|
-
const normalizedAttrName = attrName.trim().toLowerCase();
|
|
136
|
-
switch (normalizedAttrName) {
|
|
137
|
-
case "max-age":
|
|
138
|
-
attrObj["max-age"] = attrValue ? parseInt(attrValue.trim(), 10) : void 0;
|
|
139
|
-
break;
|
|
140
|
-
case "expires":
|
|
141
|
-
attrObj.expires = attrValue ? new Date(attrValue.trim()) : void 0;
|
|
142
|
-
break;
|
|
143
|
-
case "domain":
|
|
144
|
-
attrObj.domain = attrValue ? attrValue.trim() : void 0;
|
|
145
|
-
break;
|
|
146
|
-
case "path":
|
|
147
|
-
attrObj.path = attrValue ? attrValue.trim() : void 0;
|
|
148
|
-
break;
|
|
149
|
-
case "secure":
|
|
150
|
-
attrObj.secure = true;
|
|
151
|
-
break;
|
|
152
|
-
case "httponly":
|
|
153
|
-
attrObj.httponly = true;
|
|
154
|
-
break;
|
|
155
|
-
case "samesite":
|
|
156
|
-
attrObj.samesite = attrValue ? attrValue.trim().toLowerCase() : void 0;
|
|
157
|
-
break;
|
|
158
|
-
default:
|
|
159
|
-
attrObj[normalizedAttrName] = attrValue ? attrValue.trim() : true;
|
|
160
|
-
break;
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
cookies.set(name, attrObj);
|
|
164
|
-
});
|
|
165
|
-
return cookies;
|
|
166
|
-
}
|
|
167
|
-
function setCookieToHeader(headers) {
|
|
168
|
-
return (context) => {
|
|
169
|
-
const setCookieHeader = context.response.headers.get("set-cookie");
|
|
170
|
-
if (!setCookieHeader) {
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
const cookieMap = /* @__PURE__ */ new Map();
|
|
174
|
-
const existingCookiesHeader = headers.get("cookie") || "";
|
|
175
|
-
existingCookiesHeader.split(";").forEach((cookie) => {
|
|
176
|
-
const [name, ...rest] = cookie.trim().split("=");
|
|
177
|
-
if (name && rest.length > 0) {
|
|
178
|
-
cookieMap.set(name, rest.join("="));
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
const setCookieHeaders = setCookieHeader.split(",");
|
|
182
|
-
setCookieHeaders.forEach((header) => {
|
|
183
|
-
const cookies = parseSetCookieHeader(header);
|
|
184
|
-
cookies.forEach((value, name) => {
|
|
185
|
-
cookieMap.set(name, value.value);
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
const updatedCookies = Array.from(cookieMap.entries()).map(([name, value]) => `${name}=${value}`).join("; ");
|
|
189
|
-
headers.set("cookie", updatedCookies);
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
15
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
function createCookie(cookieName, overrideAttributes = {}) {
|
|
204
|
-
const prefix = options.advanced?.cookiePrefix || "better-auth";
|
|
205
|
-
const name = options.advanced?.cookies?.[cookieName]?.name || `${prefix}.${cookieName}`;
|
|
206
|
-
const attributes = options.advanced?.cookies?.[cookieName]?.attributes;
|
|
207
|
-
return {
|
|
208
|
-
name: `${secureCookiePrefix}${name}`,
|
|
209
|
-
attributes: {
|
|
210
|
-
secure: !!secureCookiePrefix,
|
|
211
|
-
sameSite: "lax",
|
|
212
|
-
path: "/",
|
|
213
|
-
httpOnly: true,
|
|
214
|
-
...crossSubdomainEnabled ? { domain } : {},
|
|
215
|
-
...options.advanced?.defaultCookieAttributes,
|
|
216
|
-
...overrideAttributes,
|
|
217
|
-
...attributes
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
return createCookie;
|
|
222
|
-
}
|
|
223
|
-
function getCookies(options) {
|
|
224
|
-
const createCookie = createCookieGetter(options);
|
|
225
|
-
const sessionMaxAge = options.session?.expiresIn || createTime(7, "d").toSeconds();
|
|
226
|
-
const sessionToken = createCookie("session_token", {
|
|
227
|
-
maxAge: sessionMaxAge
|
|
228
|
-
});
|
|
229
|
-
const sessionData = createCookie("session_data", {
|
|
230
|
-
maxAge: options.session?.cookieCache?.maxAge || 60 * 5
|
|
231
|
-
});
|
|
232
|
-
const dontRememberToken = createCookie("dont_remember");
|
|
233
|
-
return {
|
|
234
|
-
sessionToken: {
|
|
235
|
-
name: sessionToken.name,
|
|
236
|
-
options: sessionToken.attributes
|
|
237
|
-
},
|
|
238
|
-
/**
|
|
239
|
-
* This cookie is used to store the session data in the cookie
|
|
240
|
-
* This is useful for when you want to cache the session in the cookie
|
|
241
|
-
*/
|
|
242
|
-
sessionData: {
|
|
243
|
-
name: sessionData.name,
|
|
244
|
-
options: sessionData.attributes
|
|
245
|
-
},
|
|
246
|
-
dontRememberToken: {
|
|
247
|
-
name: dontRememberToken.name,
|
|
248
|
-
options: dontRememberToken.attributes
|
|
249
|
-
}
|
|
250
|
-
};
|
|
251
|
-
}
|
|
252
|
-
async function setCookieCache(ctx, session) {
|
|
253
|
-
const shouldStoreSessionDataInCookie = ctx.context.options.session?.cookieCache?.enabled;
|
|
254
|
-
if (shouldStoreSessionDataInCookie) {
|
|
255
|
-
const filteredSession = Object.entries(session.session).reduce(
|
|
256
|
-
(acc, [key, value]) => {
|
|
257
|
-
const fieldConfig = ctx.context.options.session?.additionalFields?.[key];
|
|
258
|
-
if (!fieldConfig || fieldConfig.returned !== false) {
|
|
259
|
-
acc[key] = value;
|
|
260
|
-
}
|
|
261
|
-
return acc;
|
|
262
|
-
},
|
|
263
|
-
{}
|
|
264
|
-
);
|
|
265
|
-
const sessionData = { session: filteredSession, user: session.user };
|
|
266
|
-
const expiresAtDate = date.getDate(
|
|
267
|
-
ctx.context.authCookies.sessionData.options.maxAge || 60,
|
|
268
|
-
"sec"
|
|
269
|
-
).getTime();
|
|
270
|
-
const data = base64.base64Url.encode(
|
|
271
|
-
JSON.stringify({
|
|
272
|
-
session: sessionData,
|
|
273
|
-
expiresAt: expiresAtDate,
|
|
274
|
-
signature: await hmac.createHMAC("SHA-256", "base64urlnopad").sign(
|
|
275
|
-
ctx.context.secret,
|
|
276
|
-
JSON.stringify({
|
|
277
|
-
...sessionData,
|
|
278
|
-
expiresAt: expiresAtDate
|
|
279
|
-
})
|
|
280
|
-
)
|
|
281
|
-
}),
|
|
282
|
-
{
|
|
283
|
-
padding: false
|
|
284
|
-
}
|
|
285
|
-
);
|
|
286
|
-
if (data.length > 4093) {
|
|
287
|
-
throw new index.BetterAuthError(
|
|
288
|
-
"Session data is too large to store in the cookie. Please disable session cookie caching or reduce the size of the session data"
|
|
289
|
-
);
|
|
290
|
-
}
|
|
291
|
-
ctx.setCookie(
|
|
292
|
-
ctx.context.authCookies.sessionData.name,
|
|
293
|
-
data,
|
|
294
|
-
ctx.context.authCookies.sessionData.options
|
|
295
|
-
);
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
async function setSessionCookie(ctx, session, dontRememberMe, overrides) {
|
|
299
|
-
const dontRememberMeCookie = await ctx.getSignedCookie(
|
|
300
|
-
ctx.context.authCookies.dontRememberToken.name,
|
|
301
|
-
ctx.context.secret
|
|
302
|
-
);
|
|
303
|
-
dontRememberMe = dontRememberMe !== void 0 ? dontRememberMe : !!dontRememberMeCookie;
|
|
304
|
-
const options = ctx.context.authCookies.sessionToken.options;
|
|
305
|
-
const maxAge = dontRememberMe ? void 0 : ctx.context.sessionConfig.expiresIn;
|
|
306
|
-
await ctx.setSignedCookie(
|
|
307
|
-
ctx.context.authCookies.sessionToken.name,
|
|
308
|
-
session.session.token,
|
|
309
|
-
ctx.context.secret,
|
|
310
|
-
{
|
|
311
|
-
...options,
|
|
312
|
-
maxAge,
|
|
313
|
-
...overrides
|
|
314
|
-
}
|
|
315
|
-
);
|
|
316
|
-
if (dontRememberMe) {
|
|
317
|
-
await ctx.setSignedCookie(
|
|
318
|
-
ctx.context.authCookies.dontRememberToken.name,
|
|
319
|
-
"true",
|
|
320
|
-
ctx.context.secret,
|
|
321
|
-
ctx.context.authCookies.dontRememberToken.options
|
|
322
|
-
);
|
|
323
|
-
}
|
|
324
|
-
await setCookieCache(ctx, session);
|
|
325
|
-
ctx.context.setNewSession(session);
|
|
326
|
-
if (ctx.context.options.secondaryStorage) {
|
|
327
|
-
await ctx.context.secondaryStorage?.set(
|
|
328
|
-
session.session.token,
|
|
329
|
-
JSON.stringify({
|
|
330
|
-
user: session.user,
|
|
331
|
-
session: session.session
|
|
332
|
-
}),
|
|
333
|
-
Math.floor(
|
|
334
|
-
(new Date(session.session.expiresAt).getTime() - Date.now()) / 1e3
|
|
335
|
-
)
|
|
336
|
-
);
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
function deleteSessionCookie(ctx, skipDontRememberMe) {
|
|
340
|
-
ctx.setCookie(ctx.context.authCookies.sessionToken.name, "", {
|
|
341
|
-
...ctx.context.authCookies.sessionToken.options,
|
|
342
|
-
maxAge: 0
|
|
343
|
-
});
|
|
344
|
-
ctx.setCookie(ctx.context.authCookies.sessionData.name, "", {
|
|
345
|
-
...ctx.context.authCookies.sessionData.options,
|
|
346
|
-
maxAge: 0
|
|
347
|
-
});
|
|
348
|
-
if (!skipDontRememberMe) {
|
|
349
|
-
ctx.setCookie(ctx.context.authCookies.dontRememberToken.name, "", {
|
|
350
|
-
...ctx.context.authCookies.dontRememberToken.options,
|
|
351
|
-
maxAge: 0
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
function parseCookies(cookieHeader) {
|
|
356
|
-
const cookies = cookieHeader.split("; ");
|
|
357
|
-
const cookieMap = /* @__PURE__ */ new Map();
|
|
358
|
-
cookies.forEach((cookie) => {
|
|
359
|
-
const [name, value] = cookie.split("=");
|
|
360
|
-
cookieMap.set(name, value);
|
|
361
|
-
});
|
|
362
|
-
return cookieMap;
|
|
363
|
-
}
|
|
364
|
-
const getSessionCookie = (request, config) => {
|
|
365
|
-
if (config?.cookiePrefix) {
|
|
366
|
-
if (config.cookieName) {
|
|
367
|
-
config.cookiePrefix = `${config.cookiePrefix}-`;
|
|
368
|
-
} else {
|
|
369
|
-
config.cookiePrefix = `${config.cookiePrefix}.`;
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
const headers = "headers" in request ? request.headers : request;
|
|
373
|
-
const req = request instanceof Request ? request : void 0;
|
|
374
|
-
url.getBaseURL(req?.url, config?.path, req);
|
|
375
|
-
const cookies = headers.get("cookie");
|
|
376
|
-
if (!cookies) {
|
|
377
|
-
return null;
|
|
378
|
-
}
|
|
379
|
-
const { cookieName = "session_token", cookiePrefix = "better-auth." } = config || {};
|
|
380
|
-
const name = `${cookiePrefix}${cookieName}`;
|
|
381
|
-
const secureCookieName = `__Secure-${name}`;
|
|
382
|
-
const parsedCookie = parseCookies(cookies);
|
|
383
|
-
const sessionToken = parsedCookie.get(name) || parsedCookie.get(secureCookieName);
|
|
384
|
-
if (sessionToken) {
|
|
385
|
-
return sessionToken;
|
|
386
|
-
}
|
|
387
|
-
return null;
|
|
388
|
-
};
|
|
389
|
-
const getCookieCache = async (request, config) => {
|
|
390
|
-
const headers = request instanceof Headers ? request : request.headers;
|
|
391
|
-
const cookies = headers.get("cookie");
|
|
392
|
-
if (!cookies) {
|
|
393
|
-
return null;
|
|
394
|
-
}
|
|
395
|
-
const { cookieName = "session_data", cookiePrefix = "better-auth" } = config || {};
|
|
396
|
-
const name = config?.isSecure !== void 0 ? config.isSecure ? `__Secure-${cookiePrefix}.${cookieName}` : `${cookiePrefix}.${cookieName}` : env.isProduction ? `__Secure-${cookiePrefix}.${cookieName}` : `${cookiePrefix}.${cookieName}`;
|
|
397
|
-
const parsedCookie = parseCookies(cookies);
|
|
398
|
-
const sessionData = parsedCookie.get(name);
|
|
399
|
-
if (sessionData) {
|
|
400
|
-
const sessionDataPayload = json.safeJSONParse(binary.binary.decode(base64.base64Url.decode(sessionData)));
|
|
401
|
-
if (!sessionDataPayload) {
|
|
402
|
-
return null;
|
|
403
|
-
}
|
|
404
|
-
const secret = config?.secret || env.env.BETTER_AUTH_SECRET;
|
|
405
|
-
if (!secret) {
|
|
406
|
-
throw new index.BetterAuthError(
|
|
407
|
-
"getCookieCache requires a secret to be provided. Either pass it as an option or set the BETTER_AUTH_SECRET environment variable"
|
|
408
|
-
);
|
|
409
|
-
}
|
|
410
|
-
const isValid = await hmac.createHMAC("SHA-256", "base64urlnopad").verify(
|
|
411
|
-
secret,
|
|
412
|
-
JSON.stringify({
|
|
413
|
-
...sessionDataPayload.session,
|
|
414
|
-
expiresAt: sessionDataPayload.expiresAt
|
|
415
|
-
}),
|
|
416
|
-
sessionDataPayload.signature
|
|
417
|
-
);
|
|
418
|
-
if (!isValid) {
|
|
419
|
-
return null;
|
|
420
|
-
}
|
|
421
|
-
return sessionDataPayload.session;
|
|
422
|
-
}
|
|
423
|
-
return null;
|
|
424
|
-
};
|
|
425
|
-
|
|
426
|
-
exports.createCookieGetter = createCookieGetter;
|
|
427
|
-
exports.deleteSessionCookie = deleteSessionCookie;
|
|
428
|
-
exports.getCookieCache = getCookieCache;
|
|
429
|
-
exports.getCookies = getCookies;
|
|
430
|
-
exports.getSessionCookie = getSessionCookie;
|
|
431
|
-
exports.parseCookies = parseCookies;
|
|
432
|
-
exports.parseSetCookieHeader = parseSetCookieHeader;
|
|
433
|
-
exports.setCookieCache = setCookieCache;
|
|
434
|
-
exports.setCookieToHeader = setCookieToHeader;
|
|
435
|
-
exports.setSessionCookie = setSessionCookie;
|
|
16
|
+
exports.createCookieGetter = cookies_index.createCookieGetter;
|
|
17
|
+
exports.deleteSessionCookie = cookies_index.deleteSessionCookie;
|
|
18
|
+
exports.getCookieCache = cookies_index.getCookieCache;
|
|
19
|
+
exports.getCookies = cookies_index.getCookies;
|
|
20
|
+
exports.getSessionCookie = cookies_index.getSessionCookie;
|
|
21
|
+
exports.parseCookies = cookies_index.parseCookies;
|
|
22
|
+
exports.parseSetCookieHeader = cookies_index.parseSetCookieHeader;
|
|
23
|
+
exports.setCookieCache = cookies_index.setCookieCache;
|
|
24
|
+
exports.setCookieToHeader = cookies_index.setCookieToHeader;
|
|
25
|
+
exports.setSessionCookie = cookies_index.setSessionCookie;
|
package/dist/cookies/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import 'better-call';
|
|
2
|
-
export { aD as BetterAuthCookies, aI as EligibleCookies, aB as createCookieGetter, aG as deleteSessionCookie, aK as getCookieCache, aC as getCookies, aJ as getSessionCookie, aH as parseCookies, aL as parseSetCookieHeader, aE as setCookieCache, D as setCookieToHeader, aF as setSessionCookie } from '../shared/better-auth.
|
|
2
|
+
export { aD as BetterAuthCookies, aI as EligibleCookies, aB as createCookieGetter, aG as deleteSessionCookie, aK as getCookieCache, aC as getCookies, aJ as getSessionCookie, aH as parseCookies, aL as parseSetCookieHeader, aE as setCookieCache, D as setCookieToHeader, aF as setSessionCookie } from '../shared/better-auth.BWfwO5vl.cjs';
|
|
3
3
|
import 'kysely';
|
|
4
4
|
import 'zod/v4';
|
|
5
|
-
import '../shared/better-auth.
|
|
6
|
-
import '../shared/better-auth.
|
|
5
|
+
import '../shared/better-auth.DTtXpZYr.cjs';
|
|
6
|
+
import '../shared/better-auth.Du7MKGKS.cjs';
|
|
7
7
|
import 'jose';
|
|
8
8
|
import 'zod/v4/core';
|
|
9
9
|
import 'zod';
|
package/dist/cookies/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import 'better-call';
|
|
2
|
-
export { aD as BetterAuthCookies, aI as EligibleCookies, aB as createCookieGetter, aG as deleteSessionCookie, aK as getCookieCache, aC as getCookies, aJ as getSessionCookie, aH as parseCookies, aL as parseSetCookieHeader, aE as setCookieCache, D as setCookieToHeader, aF as setSessionCookie } from '../shared/better-auth.
|
|
2
|
+
export { aD as BetterAuthCookies, aI as EligibleCookies, aB as createCookieGetter, aG as deleteSessionCookie, aK as getCookieCache, aC as getCookies, aJ as getSessionCookie, aH as parseCookies, aL as parseSetCookieHeader, aE as setCookieCache, D as setCookieToHeader, aF as setSessionCookie } from '../shared/better-auth.oCjO5qEz.mjs';
|
|
3
3
|
import 'kysely';
|
|
4
4
|
import 'zod/v4';
|
|
5
|
-
import '../shared/better-auth.
|
|
6
|
-
import '../shared/better-auth.
|
|
5
|
+
import '../shared/better-auth.DTtXpZYr.mjs';
|
|
6
|
+
import '../shared/better-auth.F1OUHOUm.mjs';
|
|
7
7
|
import 'jose';
|
|
8
8
|
import 'zod/v4/core';
|
|
9
9
|
import 'zod';
|
package/dist/cookies/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import 'better-call';
|
|
2
|
-
export { aD as BetterAuthCookies, aI as EligibleCookies, aB as createCookieGetter, aG as deleteSessionCookie, aK as getCookieCache, aC as getCookies, aJ as getSessionCookie, aH as parseCookies, aL as parseSetCookieHeader, aE as setCookieCache, D as setCookieToHeader, aF as setSessionCookie } from '../shared/better-auth.
|
|
2
|
+
export { aD as BetterAuthCookies, aI as EligibleCookies, aB as createCookieGetter, aG as deleteSessionCookie, aK as getCookieCache, aC as getCookies, aJ as getSessionCookie, aH as parseCookies, aL as parseSetCookieHeader, aE as setCookieCache, D as setCookieToHeader, aF as setSessionCookie } from '../shared/better-auth.Bxn_1Cii.js';
|
|
3
3
|
import 'kysely';
|
|
4
4
|
import 'zod/v4';
|
|
5
|
-
import '../shared/better-auth.
|
|
6
|
-
import '../shared/better-auth.
|
|
5
|
+
import '../shared/better-auth.DTtXpZYr.js';
|
|
6
|
+
import '../shared/better-auth.D4yr0Ou1.js';
|
|
7
7
|
import 'jose';
|
|
8
8
|
import 'zod/v4/core';
|
|
9
9
|
import 'zod';
|