@better-auth/expo 1.4.0-beta.9 → 1.4.0
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/client.d.mts +157 -103
- package/dist/client.mjs +343 -230
- package/dist/index.d.mts +52 -99
- package/dist/index.mjs +53 -99
- package/package.json +36 -22
- package/dist/client.cjs +0 -266
- package/dist/client.d.cts +0 -113
- package/dist/client.d.ts +0 -113
- package/dist/index.cjs +0 -105
- package/dist/index.d.cts +0 -104
- package/dist/index.d.ts +0 -104
package/dist/client.d.mts
CHANGED
|
@@ -1,113 +1,167 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import * as _better_fetch_fetch0 from "@better-fetch/fetch";
|
|
2
|
+
import { ClientFetchOption, ClientStore } from "@better-auth/core";
|
|
3
|
+
import { FocusManager, OnlineManager } from "better-auth/client";
|
|
4
4
|
|
|
5
|
+
//#region src/focus-manager.d.ts
|
|
6
|
+
declare function setupExpoFocusManager(): FocusManager;
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/online-manager.d.ts
|
|
9
|
+
declare function setupExpoOnlineManager(): OnlineManager;
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/client.d.ts
|
|
5
12
|
interface CookieAttributes {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
value: string;
|
|
14
|
+
expires?: Date | undefined;
|
|
15
|
+
"max-age"?: number | undefined;
|
|
16
|
+
domain?: string | undefined;
|
|
17
|
+
path?: string | undefined;
|
|
18
|
+
secure?: boolean | undefined;
|
|
19
|
+
httpOnly?: boolean | undefined;
|
|
20
|
+
sameSite?: ("Strict" | "Lax" | "None") | undefined;
|
|
14
21
|
}
|
|
15
22
|
declare function parseSetCookieHeader(header: string): Map<string, CookieAttributes>;
|
|
16
23
|
interface ExpoClientOptions {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
scheme?: string | undefined;
|
|
25
|
+
storage: {
|
|
26
|
+
setItem: (key: string, value: string) => any;
|
|
27
|
+
getItem: (key: string) => string | null;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Prefix for local storage keys (e.g., "my-app_cookie", "my-app_session_data")
|
|
31
|
+
* @default "better-auth"
|
|
32
|
+
*/
|
|
33
|
+
storagePrefix?: string | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Prefix(es) for server cookie names to filter (e.g., "better-auth.session_token")
|
|
36
|
+
* This is used to identify which cookies belong to better-auth to prevent
|
|
37
|
+
* infinite refetching when third-party cookies are set.
|
|
38
|
+
* Can be a single string or an array of strings to match multiple prefixes.
|
|
39
|
+
* @default "better-auth"
|
|
40
|
+
* @example "better-auth"
|
|
41
|
+
* @example ["better-auth", "my-app"]
|
|
42
|
+
*/
|
|
43
|
+
cookiePrefix?: string | string[] | undefined;
|
|
44
|
+
disableCache?: boolean | undefined;
|
|
24
45
|
}
|
|
25
|
-
declare function getSetCookie(header: string, prevCookie?: string): string;
|
|
46
|
+
declare function getSetCookie(header: string, prevCookie?: string | undefined): string;
|
|
26
47
|
declare function getCookie(cookie: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* Check if the Set-Cookie header contains better-auth cookies.
|
|
50
|
+
* This prevents infinite refetching when non-better-auth cookies (like third-party cookies) change.
|
|
51
|
+
*
|
|
52
|
+
* Supports multiple cookie naming patterns:
|
|
53
|
+
* - Default: "better-auth.session_token", "better-auth-passkey", "__Secure-better-auth.session_token"
|
|
54
|
+
* - Custom prefix: "myapp.session_token", "myapp-passkey", "__Secure-myapp.session_token"
|
|
55
|
+
* - Custom full names: "my_custom_session_token", "custom_session_data"
|
|
56
|
+
* - No prefix (cookiePrefix=""): matches any cookie with known suffixes
|
|
57
|
+
* - Multiple prefixes: ["better-auth", "my-app"] matches cookies starting with any of the prefixes
|
|
58
|
+
*
|
|
59
|
+
* @param setCookieHeader - The Set-Cookie header value
|
|
60
|
+
* @param cookiePrefix - The cookie prefix(es) to check for. Can be a string, array of strings, or empty string.
|
|
61
|
+
* @returns true if the header contains better-auth cookies, false otherwise
|
|
62
|
+
*/
|
|
63
|
+
declare function hasBetterAuthCookies(setCookieHeader: string, cookiePrefix: string | string[]): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Expo secure store does not support colons in the keys.
|
|
66
|
+
* This function replaces colons with underscores.
|
|
67
|
+
*
|
|
68
|
+
* @see https://github.com/better-auth/better-auth/issues/5426
|
|
69
|
+
*
|
|
70
|
+
* @param name cookie name to be saved in the storage
|
|
71
|
+
* @returns normalized cookie name
|
|
72
|
+
*/
|
|
73
|
+
declare function normalizeCookieName(name: string): string;
|
|
74
|
+
declare function storageAdapter(storage: {
|
|
75
|
+
getItem: (name: string) => string | null;
|
|
76
|
+
setItem: (name: string, value: string) => void;
|
|
77
|
+
}): {
|
|
78
|
+
getItem: (name: string) => string | null;
|
|
79
|
+
setItem: (name: string, value: string) => void;
|
|
80
|
+
};
|
|
27
81
|
declare const expoClient: (opts: ExpoClientOptions) => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
82
|
+
id: "expo";
|
|
83
|
+
getActions(_: _better_fetch_fetch0.BetterFetch, $store: ClientStore): {
|
|
84
|
+
/**
|
|
85
|
+
* Get the stored cookie.
|
|
86
|
+
*
|
|
87
|
+
* You can use this to get the cookie stored in the device and use it in your fetch
|
|
88
|
+
* requests.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```ts
|
|
92
|
+
* const cookie = client.getCookie();
|
|
93
|
+
* fetch("https://api.example.com", {
|
|
94
|
+
* headers: {
|
|
95
|
+
* cookie,
|
|
96
|
+
* },
|
|
97
|
+
* });
|
|
98
|
+
*/
|
|
99
|
+
getCookie: () => string;
|
|
100
|
+
};
|
|
101
|
+
fetchPlugins: {
|
|
102
|
+
id: string;
|
|
103
|
+
name: string;
|
|
104
|
+
hooks: {
|
|
105
|
+
onSuccess(context: _better_fetch_fetch0.SuccessContext<any>): Promise<void>;
|
|
46
106
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
disableValidation?: boolean | undefined;
|
|
106
|
-
} | undefined): Promise<{
|
|
107
|
-
url: string;
|
|
108
|
-
options: BetterFetchOption;
|
|
109
|
-
}>;
|
|
110
|
-
}[];
|
|
107
|
+
init(url: string, options: {
|
|
108
|
+
method?: string | undefined;
|
|
109
|
+
headers?: (HeadersInit & (HeadersInit | {
|
|
110
|
+
accept: "application/json" | "text/plain" | "application/octet-stream";
|
|
111
|
+
"content-type": "application/json" | "text/plain" | "application/x-www-form-urlencoded" | "multipart/form-data" | "application/octet-stream";
|
|
112
|
+
authorization: "Bearer" | "Basic";
|
|
113
|
+
})) | undefined;
|
|
114
|
+
redirect?: RequestRedirect | undefined;
|
|
115
|
+
cache?: RequestCache | undefined;
|
|
116
|
+
credentials?: RequestCredentials | undefined;
|
|
117
|
+
integrity?: string | undefined;
|
|
118
|
+
keepalive?: boolean | undefined;
|
|
119
|
+
mode?: RequestMode | undefined;
|
|
120
|
+
priority?: RequestPriority | undefined;
|
|
121
|
+
referrer?: string | undefined;
|
|
122
|
+
referrerPolicy?: ReferrerPolicy | undefined;
|
|
123
|
+
signal?: (AbortSignal | null) | undefined;
|
|
124
|
+
window?: null | undefined;
|
|
125
|
+
onRequest?: (<T extends Record<string, any>>(context: _better_fetch_fetch0.RequestContext<T>) => Promise<_better_fetch_fetch0.RequestContext | void> | _better_fetch_fetch0.RequestContext | void) | undefined;
|
|
126
|
+
onResponse?: ((context: _better_fetch_fetch0.ResponseContext) => Promise<Response | void | _better_fetch_fetch0.ResponseContext> | Response | _better_fetch_fetch0.ResponseContext | void) | undefined;
|
|
127
|
+
onSuccess?: ((context: _better_fetch_fetch0.SuccessContext<any>) => Promise<void> | void) | undefined;
|
|
128
|
+
onError?: ((context: _better_fetch_fetch0.ErrorContext) => Promise<void> | void) | undefined;
|
|
129
|
+
onRetry?: ((response: _better_fetch_fetch0.ResponseContext) => Promise<void> | void) | undefined;
|
|
130
|
+
hookOptions?: {
|
|
131
|
+
cloneResponse?: boolean;
|
|
132
|
+
} | undefined;
|
|
133
|
+
timeout?: number | undefined;
|
|
134
|
+
customFetchImpl?: _better_fetch_fetch0.FetchEsque | undefined;
|
|
135
|
+
plugins?: _better_fetch_fetch0.BetterFetchPlugin[] | undefined;
|
|
136
|
+
baseURL?: string | undefined;
|
|
137
|
+
throw?: boolean | undefined;
|
|
138
|
+
auth?: ({
|
|
139
|
+
type: "Bearer";
|
|
140
|
+
token: string | Promise<string | undefined> | (() => string | Promise<string | undefined> | undefined) | undefined;
|
|
141
|
+
} | {
|
|
142
|
+
type: "Basic";
|
|
143
|
+
username: string | (() => string | undefined) | undefined;
|
|
144
|
+
password: string | (() => string | undefined) | undefined;
|
|
145
|
+
} | {
|
|
146
|
+
type: "Custom";
|
|
147
|
+
prefix: string | (() => string | undefined) | undefined;
|
|
148
|
+
value: string | (() => string | undefined) | undefined;
|
|
149
|
+
}) | undefined;
|
|
150
|
+
body?: any;
|
|
151
|
+
query?: any;
|
|
152
|
+
params?: any;
|
|
153
|
+
duplex?: "full" | "half" | undefined;
|
|
154
|
+
jsonParser?: ((text: string) => Promise<any> | any) | undefined;
|
|
155
|
+
retry?: _better_fetch_fetch0.RetryOptions | undefined;
|
|
156
|
+
retryAttempt?: number | undefined;
|
|
157
|
+
output?: (_better_fetch_fetch0.StandardSchemaV1 | typeof Blob | typeof File) | undefined;
|
|
158
|
+
errorSchema?: _better_fetch_fetch0.StandardSchemaV1 | undefined;
|
|
159
|
+
disableValidation?: boolean | undefined;
|
|
160
|
+
} | undefined): Promise<{
|
|
161
|
+
url: string;
|
|
162
|
+
options: ClientFetchOption;
|
|
163
|
+
}>;
|
|
164
|
+
}[];
|
|
111
165
|
};
|
|
112
|
-
|
|
113
|
-
export { expoClient, getCookie, getSetCookie, parseSetCookieHeader };
|
|
166
|
+
//#endregion
|
|
167
|
+
export { expoClient, getCookie, getSetCookie, hasBetterAuthCookies, normalizeCookieName, parseSetCookieHeader, setupExpoFocusManager, setupExpoOnlineManager, storageAdapter };
|