better-auth 1.6.18 → 1.6.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,10 @@
1
1
  import { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, UnionToIntersection } from "../../types/helper.mjs";
2
2
  import { InferActions, InferClientAPI, InferErrorCodes, IsSignal, SessionQueryParams } from "../types.mjs";
3
+ import { getClientConfig } from "../config.mjs";
3
4
  import { BetterAuthClientOptions } from "@better-auth/core";
4
5
  import { BASE_ERROR_CODES } from "@better-auth/core/error";
5
- import * as nanostores from "nanostores";
6
6
  import { Atom } from "nanostores";
7
- import * as _better_fetch_fetch0 from "@better-fetch/fetch";
8
- import { BetterFetchError } from "@better-fetch/fetch";
7
+ import { BetterFetchError, BetterFetchResponse } from "@better-fetch/fetch";
9
8
  export * from "nanostores";
10
9
  export * from "@better-fetch/fetch";
11
10
 
@@ -15,21 +14,16 @@ type InferResolvedHooks<O extends BetterAuthClientOptions> = O extends {
15
14
  } ? UnionToIntersection<Plugin extends {
16
15
  getAtoms?: infer GetAtoms;
17
16
  } ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => Atoms[key] } : {} : {} : {}> : {};
18
- declare function createAuthClient<Option extends BetterAuthClientOptions>(options?: Option | undefined): UnionToIntersection<InferResolvedHooks<Option>> & InferClientAPI<Option> & InferActions<Option> & {
17
+ type ClientConfig = ReturnType<typeof getClientConfig>;
18
+ type ClientSession<Option extends BetterAuthClientOptions> = InferClientAPI<Option> extends {
19
+ getSession: () => Promise<infer Res>;
20
+ } ? Res extends BetterFetchResponse<infer S> ? S : Res extends Record<string, any> ? Res : never : never;
21
+ /**
22
+ * Svelte client returned by `createAuthClient`.
23
+ */
24
+ type SvelteAuthClient<Option extends BetterAuthClientOptions> = UnionToIntersection<InferResolvedHooks<Option>> & InferClientAPI<Option> & InferActions<Option> & {
19
25
  useSession: () => Atom<{
20
- data: InferClientAPI<Option> extends {
21
- getSession: () => Promise<infer Res>;
22
- } ? Res extends {
23
- data: null;
24
- error: {
25
- message?: string | undefined;
26
- status: number;
27
- statusText: string;
28
- };
29
- } | {
30
- data: infer S;
31
- error: null;
32
- } ? S : Res extends Record<string, any> ? Res : never : never;
26
+ data: ClientSession<Option>;
33
27
  error: BetterFetchError | null;
34
28
  isPending: boolean;
35
29
  isRefetching: boolean;
@@ -37,94 +31,13 @@ declare function createAuthClient<Option extends BetterAuthClientOptions>(option
37
31
  query?: SessionQueryParams;
38
32
  } | undefined) => Promise<void>;
39
33
  }>;
40
- $fetch: _better_fetch_fetch0.BetterFetch<{
41
- plugins: (_better_fetch_fetch0.BetterFetchPlugin<Record<string, any>> | {
42
- id: string;
43
- name: string;
44
- hooks: {
45
- onSuccess(context: _better_fetch_fetch0.SuccessContext<any>): void;
46
- };
47
- } | {
48
- id: string;
49
- name: string;
50
- hooks: {
51
- onSuccess: ((context: _better_fetch_fetch0.SuccessContext<any>) => Promise<void> | void) | undefined;
52
- onError: ((context: _better_fetch_fetch0.ErrorContext) => Promise<void> | void) | undefined;
53
- onRequest: (<T extends Record<string, any>>(context: _better_fetch_fetch0.RequestContext<T>) => Promise<_better_fetch_fetch0.RequestContext | void> | _better_fetch_fetch0.RequestContext | void) | undefined;
54
- onResponse: ((context: _better_fetch_fetch0.ResponseContext) => Promise<Response | void | _better_fetch_fetch0.ResponseContext> | Response | _better_fetch_fetch0.ResponseContext | void) | undefined;
55
- };
56
- })[];
57
- priority?: RequestPriority | undefined;
58
- cache?: RequestCache | undefined;
59
- credentials?: RequestCredentials;
60
- integrity?: string | undefined;
61
- keepalive?: boolean | undefined;
62
- method: string;
63
- mode?: RequestMode | undefined;
64
- redirect?: RequestRedirect | undefined;
65
- referrer?: string | undefined;
66
- referrerPolicy?: ReferrerPolicy | undefined;
67
- signal?: (AbortSignal | null) | undefined;
68
- window?: null | undefined;
69
- onRetry?: ((response: _better_fetch_fetch0.ResponseContext) => Promise<void> | void) | undefined;
70
- hookOptions?: {
71
- cloneResponse?: boolean;
72
- } | undefined;
73
- timeout?: number | undefined;
74
- customFetchImpl: _better_fetch_fetch0.FetchEsque;
75
- baseURL: string;
76
- throw?: boolean | undefined;
77
- auth?: ({
78
- type: "Bearer";
79
- token: string | Promise<string | undefined> | (() => string | Promise<string | undefined> | undefined) | undefined;
80
- } | {
81
- type: "Basic";
82
- username: string | (() => string | undefined) | undefined;
83
- password: string | (() => string | undefined) | undefined;
84
- } | {
85
- type: "Custom";
86
- prefix: string | (() => string | undefined) | undefined;
87
- value: string | (() => string | undefined) | undefined;
88
- }) | undefined;
89
- headers?: {} | {
90
- [x: string]: string | undefined;
91
- accept?: ((string & {}) | "application/json" | "text/plain" | "application/octet-stream") | undefined;
92
- "content-type"?: ((string & {}) | "application/x-www-form-urlencoded" | "application/json" | "text/plain" | "application/octet-stream" | "multipart/form-data") | undefined;
93
- authorization?: ((string & {}) | `Bearer ${string}` | `Basic ${string}`) | undefined;
94
- } | undefined;
95
- body?: any;
96
- query?: any;
97
- params?: any;
98
- duplex?: "full" | "half" | undefined;
99
- jsonParser: (text: string) => Promise<any> | any;
100
- retry?: _better_fetch_fetch0.RetryOptions | undefined;
101
- retryAttempt?: number | undefined;
102
- output?: (_better_fetch_fetch0.StandardSchemaV1 | typeof Blob | typeof File) | undefined;
103
- errorSchema?: _better_fetch_fetch0.StandardSchemaV1 | undefined;
104
- disableValidation?: boolean | undefined;
105
- disableSignal?: boolean | undefined;
106
- }, unknown, unknown, {}>;
107
- $store: {
108
- notify: (signal?: (Omit<string, "$sessionSignal"> | "$sessionSignal") | undefined) => void;
109
- listen: (signal: Omit<string, "$sessionSignal"> | "$sessionSignal", listener: (value: boolean, oldValue?: boolean | undefined) => void) => void;
110
- atoms: Record<string, nanostores.WritableAtom<any>>;
111
- };
34
+ $fetch: ClientConfig["$fetch"];
35
+ $store: ClientConfig["$store"];
112
36
  $Infer: {
113
- Session: NonNullable<InferClientAPI<Option> extends {
114
- getSession: () => Promise<infer Res>;
115
- } ? Res extends {
116
- data: null;
117
- error: {
118
- message?: string | undefined;
119
- status: number;
120
- statusText: string;
121
- };
122
- } | {
123
- data: infer S;
124
- error: null;
125
- } ? S : Res extends Record<string, any> ? Res : never : never>;
37
+ Session: NonNullable<ClientSession<Option>>;
126
38
  };
127
39
  $ERROR_CODES: PrettifyDeep<InferErrorCodes<Option> & typeof BASE_ERROR_CODES>;
128
40
  };
41
+ declare function createAuthClient<Option extends BetterAuthClientOptions>(options?: Option | undefined): SvelteAuthClient<Option>;
129
42
  //#endregion
130
- export { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, type UnionToIntersection, createAuthClient };
43
+ export { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, SvelteAuthClient, type UnionToIntersection, createAuthClient };
@@ -3,7 +3,7 @@ import { StripEmptyObjects, UnionToIntersection } from "../types/helper.mjs";
3
3
  import { InferRoutes } from "./path-to-object.mjs";
4
4
  import { Session as Session$1, User as User$1 } from "../types/models.mjs";
5
5
  import { Auth } from "../types/auth.mjs";
6
- import { BetterAuthClientOptions as BetterAuthClientOptions$1, BetterAuthClientPlugin, ClientAtomListener, ClientStore as ClientStore$1 } from "@better-auth/core";
6
+ import { BetterAuthClientOptions as BetterAuthClientOptions$1, BetterAuthClientPlugin, ClientAtomListener as ClientAtomListener$1, ClientStore as ClientStore$1 } from "@better-auth/core";
7
7
  import { DBFieldAttribute, InferDBFieldsOutput } from "@better-auth/core/db";
8
8
 
9
9
  //#region src/client/types.d.ts
@@ -48,4 +48,4 @@ type SessionQueryParams = {
48
48
  disableRefresh?: boolean | undefined;
49
49
  };
50
50
  //#endregion
51
- export { type BetterAuthClientOptions$1 as BetterAuthClientOptions, type BetterAuthClientPlugin, type ClientAtomListener, type ClientStore$1 as ClientStore, InferActions, InferAdditionalFromClient, InferClientAPI, InferErrorCodes, InferSessionFromClient, InferUserFromClient, IsSignal, SessionQueryParams };
51
+ export { type BetterAuthClientOptions$1 as BetterAuthClientOptions, type BetterAuthClientPlugin, type ClientAtomListener$1 as ClientAtomListener, type ClientStore$1 as ClientStore, InferActions, InferAdditionalFromClient, InferClientAPI, InferErrorCodes, InferSessionFromClient, InferUserFromClient, IsSignal, SessionQueryParams };
@@ -1,11 +1,10 @@
1
1
  import { PrettifyDeep, UnionToIntersection } from "../types/helper.mjs";
2
2
  import { InferActions, InferClientAPI, InferErrorCodes, IsSignal, SessionQueryParams } from "./types.mjs";
3
+ import { getClientConfig } from "./config.mjs";
3
4
  import { BetterAuthClientOptions } from "@better-auth/core";
4
5
  import { BASE_ERROR_CODES } from "@better-auth/core/error";
5
- import * as nanostores from "nanostores";
6
6
  import { Atom } from "nanostores";
7
- import * as _better_fetch_fetch0 from "@better-fetch/fetch";
8
- import { BetterFetchError } from "@better-fetch/fetch";
7
+ import { BetterFetchError, BetterFetchResponse } from "@better-fetch/fetch";
9
8
 
10
9
  //#region src/client/vanilla.d.ts
11
10
  type InferResolvedHooks<O extends BetterAuthClientOptions> = O extends {
@@ -13,21 +12,16 @@ type InferResolvedHooks<O extends BetterAuthClientOptions> = O extends {
13
12
  } ? UnionToIntersection<Plugin extends {
14
13
  getAtoms?: infer GetAtoms;
15
14
  } ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: Atoms[key] } : {} : {} : {}> : {};
16
- declare function createAuthClient<Option extends BetterAuthClientOptions>(options?: Option | undefined): UnionToIntersection<InferResolvedHooks<Option>> & InferClientAPI<Option> & InferActions<Option> & {
15
+ type ClientConfig = ReturnType<typeof getClientConfig>;
16
+ type ClientSession<Option extends BetterAuthClientOptions> = InferClientAPI<Option> extends {
17
+ getSession: () => Promise<infer Res>;
18
+ } ? Res extends BetterFetchResponse<infer S> ? S : Res extends Record<string, any> ? Res : never : never;
19
+ /**
20
+ * Client returned by `createAuthClient`.
21
+ */
22
+ type AuthClient<Option extends BetterAuthClientOptions> = UnionToIntersection<InferResolvedHooks<Option>> & InferClientAPI<Option> & InferActions<Option> & {
17
23
  useSession: Atom<{
18
- data: InferClientAPI<Option> extends {
19
- getSession: () => Promise<infer Res>;
20
- } ? Res extends {
21
- data: null;
22
- error: {
23
- message?: string | undefined;
24
- status: number;
25
- statusText: string;
26
- };
27
- } | {
28
- data: infer S;
29
- error: null;
30
- } ? S : Res extends Record<string, any> ? Res : never : never;
24
+ data: ClientSession<Option>;
31
25
  error: BetterFetchError | null;
32
26
  isPending: boolean;
33
27
  isRefetching: boolean;
@@ -35,95 +29,13 @@ declare function createAuthClient<Option extends BetterAuthClientOptions>(option
35
29
  query?: SessionQueryParams;
36
30
  } | undefined) => Promise<void>;
37
31
  }>;
38
- $fetch: _better_fetch_fetch0.BetterFetch<{
39
- plugins: (_better_fetch_fetch0.BetterFetchPlugin<Record<string, any>> | {
40
- id: string;
41
- name: string;
42
- hooks: {
43
- onSuccess(context: _better_fetch_fetch0.SuccessContext<any>): void;
44
- };
45
- } | {
46
- id: string;
47
- name: string;
48
- hooks: {
49
- onSuccess: ((context: _better_fetch_fetch0.SuccessContext<any>) => Promise<void> | void) | undefined;
50
- onError: ((context: _better_fetch_fetch0.ErrorContext) => Promise<void> | void) | undefined;
51
- onRequest: (<T extends Record<string, any>>(context: _better_fetch_fetch0.RequestContext<T>) => Promise<_better_fetch_fetch0.RequestContext | void> | _better_fetch_fetch0.RequestContext | void) | undefined;
52
- onResponse: ((context: _better_fetch_fetch0.ResponseContext) => Promise<Response | void | _better_fetch_fetch0.ResponseContext> | Response | _better_fetch_fetch0.ResponseContext | void) | undefined;
53
- };
54
- })[];
55
- priority?: RequestPriority | undefined;
56
- cache?: RequestCache | undefined;
57
- credentials?: RequestCredentials;
58
- integrity?: string | undefined;
59
- keepalive?: boolean | undefined;
60
- method: string;
61
- mode?: RequestMode | undefined;
62
- redirect?: RequestRedirect | undefined;
63
- referrer?: string | undefined;
64
- referrerPolicy?: ReferrerPolicy | undefined;
65
- signal?: (AbortSignal | null) | undefined;
66
- window?: null | undefined;
67
- onRetry?: ((response: _better_fetch_fetch0.ResponseContext) => Promise<void> | void) | undefined;
68
- hookOptions?: {
69
- cloneResponse?: boolean;
70
- } | undefined;
71
- timeout?: number | undefined;
72
- customFetchImpl: _better_fetch_fetch0.FetchEsque;
73
- baseURL: string;
74
- throw?: boolean | undefined;
75
- auth?: ({
76
- type: "Bearer";
77
- token: string | Promise<string | undefined> | (() => string | Promise<string | undefined> | undefined) | undefined;
78
- } | {
79
- type: "Basic";
80
- username: string | (() => string | undefined) | undefined;
81
- password: string | (() => string | undefined) | undefined;
82
- } | {
83
- type: "Custom";
84
- prefix: string | (() => string | undefined) | undefined;
85
- value: string | (() => string | undefined) | undefined;
86
- }) | undefined;
87
- headers?: {} | {
88
- [x: string]: string | undefined;
89
- accept?: ((string & {}) | "application/json" | "text/plain" | "application/octet-stream") | undefined;
90
- "content-type"?: ((string & {}) | "application/x-www-form-urlencoded" | "application/json" | "text/plain" | "application/octet-stream" | "multipart/form-data") | undefined;
91
- authorization?: ((string & {}) | `Bearer ${string}` | `Basic ${string}`) | undefined;
92
- } | undefined;
93
- body?: any;
94
- query?: any;
95
- params?: any;
96
- duplex?: "full" | "half" | undefined;
97
- jsonParser: (text: string) => Promise<any> | any;
98
- retry?: _better_fetch_fetch0.RetryOptions | undefined;
99
- retryAttempt?: number | undefined;
100
- output?: (_better_fetch_fetch0.StandardSchemaV1 | typeof Blob | typeof File) | undefined;
101
- errorSchema?: _better_fetch_fetch0.StandardSchemaV1 | undefined;
102
- disableValidation?: boolean | undefined;
103
- disableSignal?: boolean | undefined;
104
- }, unknown, unknown, {}>;
105
- $store: {
106
- notify: (signal?: (Omit<string, "$sessionSignal"> | "$sessionSignal") | undefined) => void;
107
- listen: (signal: Omit<string, "$sessionSignal"> | "$sessionSignal", listener: (value: boolean, oldValue?: boolean | undefined) => void) => void;
108
- atoms: Record<string, nanostores.WritableAtom<any>>;
109
- };
32
+ $fetch: ClientConfig["$fetch"];
33
+ $store: ClientConfig["$store"];
110
34
  $Infer: {
111
- Session: NonNullable<InferClientAPI<Option> extends {
112
- getSession: () => Promise<infer Res>;
113
- } ? Res extends {
114
- data: null;
115
- error: {
116
- message?: string | undefined;
117
- status: number;
118
- statusText: string;
119
- };
120
- } | {
121
- data: infer S;
122
- error: null;
123
- } ? S : Res extends Record<string, any> ? Res : never : never>;
35
+ Session: NonNullable<ClientSession<Option>>;
124
36
  };
125
37
  $ERROR_CODES: PrettifyDeep<InferErrorCodes<Option> & typeof BASE_ERROR_CODES>;
126
38
  };
127
- type AuthClient<Option extends BetterAuthClientOptions> = ReturnType<typeof createAuthClient<Option>>;
39
+ declare function createAuthClient<Option extends BetterAuthClientOptions>(options?: Option | undefined): AuthClient<Option>;
128
40
  //#endregion
129
41
  export { AuthClient, createAuthClient };
@@ -1,10 +1,9 @@
1
1
  import { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, UnionToIntersection } from "../../types/helper.mjs";
2
2
  import { InferActions, InferClientAPI, InferErrorCodes, IsSignal, SessionQueryParams } from "../types.mjs";
3
+ import { getClientConfig } from "../config.mjs";
3
4
  import { BetterAuthClientOptions } from "@better-auth/core";
4
5
  import { BASE_ERROR_CODES } from "@better-auth/core/error";
5
- import * as nanostores from "nanostores";
6
- import * as _better_fetch_fetch0 from "@better-fetch/fetch";
7
- import { BetterFetchError } from "@better-fetch/fetch";
6
+ import { BetterFetchError, BetterFetchResponse } from "@better-fetch/fetch";
8
7
  import { DeepReadonly, Ref } from "vue";
9
8
  export * from "nanostores";
10
9
  export * from "@better-fetch/fetch";
@@ -15,139 +14,42 @@ type InferResolvedHooks<O extends BetterAuthClientOptions> = O extends {
15
14
  } ? UnionToIntersection<Plugin extends {
16
15
  getAtoms?: infer GetAtoms;
17
16
  } ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => DeepReadonly<Ref<ReturnType<Atoms[key]["get"]>>> } : {} : {} : {}> : {};
18
- declare function createAuthClient<Option extends BetterAuthClientOptions>(options?: Option | undefined): UnionToIntersection<InferResolvedHooks<Option>> & InferClientAPI<Option> & InferActions<Option> & {
19
- useSession: {
20
- (): DeepReadonly<Ref<{
21
- data: InferClientAPI<Option> extends {
22
- getSession: () => Promise<infer Res>;
23
- } ? Res extends {
24
- data: null;
25
- error: {
26
- message?: string | undefined;
27
- status: number;
28
- statusText: string;
29
- };
30
- } | {
31
- data: infer S;
32
- error: null;
33
- } ? S : Res extends Record<string, any> ? Res : never : never;
34
- isPending: boolean;
35
- isRefetching: boolean;
36
- error: BetterFetchError | null;
37
- refetch: (queryParams?: {
38
- query?: SessionQueryParams;
39
- } | undefined) => Promise<void>;
40
- }>>;
41
- <F extends (...args: any) => any>(useFetch: F): Promise<{
42
- data: Ref<InferClientAPI<Option> extends {
43
- getSession: () => Promise<infer Res>;
44
- } ? Res extends {
45
- data: null;
46
- error: {
47
- message?: string | undefined;
48
- status: number;
49
- statusText: string;
50
- };
51
- } | {
52
- data: infer S;
53
- error: null;
54
- } ? S : Res extends Record<string, any> ? Res : never : never>;
55
- isPending: false;
56
- error: Ref<{
57
- message?: string | undefined;
58
- status: number;
59
- statusText: string;
60
- }>;
17
+ type ClientConfig = ReturnType<typeof getClientConfig>;
18
+ type ClientSession<Option extends BetterAuthClientOptions> = InferClientAPI<Option> extends {
19
+ getSession: () => Promise<infer Res>;
20
+ } ? Res extends BetterFetchResponse<infer S> ? S : Res extends Record<string, any> ? Res : never : never;
21
+ type VueUseSession<Option extends BetterAuthClientOptions> = {
22
+ (): DeepReadonly<Ref<{
23
+ data: ClientSession<Option>;
24
+ isPending: boolean;
25
+ isRefetching: boolean;
26
+ error: BetterFetchError | null;
27
+ refetch: (queryParams?: {
28
+ query?: SessionQueryParams;
29
+ } | undefined) => Promise<void>;
30
+ }>>;
31
+ <F extends (...args: any) => any>(useFetch: F): Promise<{
32
+ data: Ref<ClientSession<Option>>;
33
+ isPending: false;
34
+ error: Ref<{
35
+ message?: string | undefined;
36
+ status: number;
37
+ statusText: string;
61
38
  }>;
62
- };
39
+ }>;
40
+ };
41
+ /**
42
+ * Vue client returned by `createAuthClient`.
43
+ */
44
+ type VueAuthClient<Option extends BetterAuthClientOptions> = UnionToIntersection<InferResolvedHooks<Option>> & InferClientAPI<Option> & InferActions<Option> & {
45
+ useSession: VueUseSession<Option>;
63
46
  $Infer: {
64
- Session: NonNullable<InferClientAPI<Option> extends {
65
- getSession: () => Promise<infer Res>;
66
- } ? Res extends {
67
- data: null;
68
- error: {
69
- message?: string | undefined;
70
- status: number;
71
- statusText: string;
72
- };
73
- } | {
74
- data: infer S;
75
- error: null;
76
- } ? S : Res extends Record<string, any> ? Res : never : never>;
77
- };
78
- $fetch: _better_fetch_fetch0.BetterFetch<{
79
- plugins: (_better_fetch_fetch0.BetterFetchPlugin<Record<string, any>> | {
80
- id: string;
81
- name: string;
82
- hooks: {
83
- onSuccess(context: _better_fetch_fetch0.SuccessContext<any>): void;
84
- };
85
- } | {
86
- id: string;
87
- name: string;
88
- hooks: {
89
- onSuccess: ((context: _better_fetch_fetch0.SuccessContext<any>) => Promise<void> | void) | undefined;
90
- onError: ((context: _better_fetch_fetch0.ErrorContext) => Promise<void> | void) | undefined;
91
- onRequest: (<T extends Record<string, any>>(context: _better_fetch_fetch0.RequestContext<T>) => Promise<_better_fetch_fetch0.RequestContext | void> | _better_fetch_fetch0.RequestContext | void) | undefined;
92
- onResponse: ((context: _better_fetch_fetch0.ResponseContext) => Promise<Response | void | _better_fetch_fetch0.ResponseContext> | Response | _better_fetch_fetch0.ResponseContext | void) | undefined;
93
- };
94
- })[];
95
- priority?: RequestPriority | undefined;
96
- cache?: RequestCache | undefined;
97
- credentials?: RequestCredentials;
98
- integrity?: string | undefined;
99
- keepalive?: boolean | undefined;
100
- method: string;
101
- mode?: RequestMode | undefined;
102
- redirect?: RequestRedirect | undefined;
103
- referrer?: string | undefined;
104
- referrerPolicy?: ReferrerPolicy | undefined;
105
- signal?: (AbortSignal | null) | undefined;
106
- window?: null | undefined;
107
- onRetry?: ((response: _better_fetch_fetch0.ResponseContext) => Promise<void> | void) | undefined;
108
- hookOptions?: {
109
- cloneResponse?: boolean;
110
- } | undefined;
111
- timeout?: number | undefined;
112
- customFetchImpl: _better_fetch_fetch0.FetchEsque;
113
- baseURL: string;
114
- throw?: boolean | undefined;
115
- auth?: ({
116
- type: "Bearer";
117
- token: string | Promise<string | undefined> | (() => string | Promise<string | undefined> | undefined) | undefined;
118
- } | {
119
- type: "Basic";
120
- username: string | (() => string | undefined) | undefined;
121
- password: string | (() => string | undefined) | undefined;
122
- } | {
123
- type: "Custom";
124
- prefix: string | (() => string | undefined) | undefined;
125
- value: string | (() => string | undefined) | undefined;
126
- }) | undefined;
127
- headers?: {} | {
128
- [x: string]: string | undefined;
129
- accept?: ((string & {}) | "application/json" | "text/plain" | "application/octet-stream") | undefined;
130
- "content-type"?: ((string & {}) | "application/x-www-form-urlencoded" | "application/json" | "text/plain" | "application/octet-stream" | "multipart/form-data") | undefined;
131
- authorization?: ((string & {}) | `Bearer ${string}` | `Basic ${string}`) | undefined;
132
- } | undefined;
133
- body?: any;
134
- query?: any;
135
- params?: any;
136
- duplex?: "full" | "half" | undefined;
137
- jsonParser: (text: string) => Promise<any> | any;
138
- retry?: _better_fetch_fetch0.RetryOptions | undefined;
139
- retryAttempt?: number | undefined;
140
- output?: (_better_fetch_fetch0.StandardSchemaV1 | typeof Blob | typeof File) | undefined;
141
- errorSchema?: _better_fetch_fetch0.StandardSchemaV1 | undefined;
142
- disableValidation?: boolean | undefined;
143
- disableSignal?: boolean | undefined;
144
- }, unknown, unknown, {}>;
145
- $store: {
146
- notify: (signal?: (Omit<string, "$sessionSignal"> | "$sessionSignal") | undefined) => void;
147
- listen: (signal: Omit<string, "$sessionSignal"> | "$sessionSignal", listener: (value: boolean, oldValue?: boolean | undefined) => void) => void;
148
- atoms: Record<string, nanostores.WritableAtom<any>>;
47
+ Session: NonNullable<ClientSession<Option>>;
149
48
  };
49
+ $fetch: ClientConfig["$fetch"];
50
+ $store: ClientConfig["$store"];
150
51
  $ERROR_CODES: PrettifyDeep<InferErrorCodes<Option> & typeof BASE_ERROR_CODES>;
151
52
  };
53
+ declare function createAuthClient<Option extends BetterAuthClientOptions>(options?: Option | undefined): VueAuthClient<Option>;
152
54
  //#endregion
153
- export { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, type UnionToIntersection, createAuthClient };
55
+ export { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, type UnionToIntersection, VueAuthClient, createAuthClient };
@@ -103,18 +103,8 @@ async function setCookieCache(ctx, session, dontRememberMe) {
103
103
  expiresAt: expiresAtDate
104
104
  }))
105
105
  }), { padding: false });
106
- if (data.length > 4093) {
107
- const sessionStore = createSessionStore(ctx.context.authCookies.sessionData.name, options, ctx);
108
- const cookies = sessionStore.chunk(data, options);
109
- sessionStore.setCookies(cookies);
110
- } else {
111
- const sessionStore = createSessionStore(ctx.context.authCookies.sessionData.name, options, ctx);
112
- if (sessionStore.hasChunks()) {
113
- const cleanCookies = sessionStore.clean();
114
- sessionStore.setCookies(cleanCookies);
115
- }
116
- ctx.setCookie(ctx.context.authCookies.sessionData.name, data, options);
117
- }
106
+ const sessionStore = createSessionStore(ctx.context.authCookies.sessionData.name, options, ctx);
107
+ sessionStore.setCookies(sessionStore.chunk(data, options));
118
108
  if (ctx.context.options.account?.storeAccountCookie && !hasPendingSetCookie(ctx, ctx.context.authCookies.accountData.name)) {
119
109
  const accountData = await getAccountCookie(ctx);
120
110
  if (accountData) if (!shouldBindAccountCookieToSessionUser(ctx.context.options) || accountData.userId === session.user.id) await setAccountCookie(ctx, accountData);
@@ -7,25 +7,8 @@ interface Cookie {
7
7
  attributes: CookieOptions;
8
8
  }
9
9
  declare const createSessionStore: (cookieName: string, cookieOptions: CookieOptions, ctx: GenericEndpointContext) => {
10
- /**
11
- * Get the full session data by joining all chunks
12
- */
13
- getValue(): string;
14
- /**
15
- * Check if there are existing chunks
16
- */
17
- hasChunks(): boolean;
18
- /**
19
- * Chunk a cookie value and return all cookies to set (including cleanup cookies)
20
- */
21
10
  chunk(value: string, options?: Partial<CookieOptions>): Cookie[];
22
- /**
23
- * Get cookies to clean up all chunks
24
- */
25
11
  clean(): Cookie[];
26
- /**
27
- * Set all cookies in the context
28
- */
29
12
  setCookies(cookies: Cookie[]): void;
30
13
  };
31
14
  declare function getChunkedCookie(ctx: GenericEndpointContext, cookieName: string): string | null;