@better-auth/expo 1.7.0-rc.1 → 1.7.0-rc.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/client.d.ts +13 -16
- package/dist/client.js +37 -5
- package/dist/index.d.ts +10 -15
- package/dist/index.js +1 -1
- package/dist/plugins/index.d.ts +1 -3
- package/dist/plugins/index.js +14 -1
- package/dist/{version-BpsSrKxb.js → version-xoFrTW0m.js} +1 -1
- package/package.json +6 -6
package/dist/client.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { parseSetCookieHeader } from "better-auth/cookies";
|
|
2
2
|
import { FocusManager, OnlineManager } from "better-auth/client";
|
|
3
|
-
import * as expo_web_browser0 from "expo-web-browser";
|
|
4
|
-
import * as _better_fetch_fetch0 from "@better-fetch/fetch";
|
|
5
3
|
import { ClientFetchOption, ClientStore } from "@better-auth/core";
|
|
6
|
-
|
|
7
4
|
//#region src/focus-manager.d.ts
|
|
8
5
|
declare function setupExpoFocusManager(): FocusManager;
|
|
9
6
|
//#endregion
|
|
@@ -52,7 +49,7 @@ interface ExpoClientOptions {
|
|
|
52
49
|
* });
|
|
53
50
|
* ```
|
|
54
51
|
*/
|
|
55
|
-
webBrowserOptions?:
|
|
52
|
+
webBrowserOptions?: import("expo-web-browser").AuthSessionOpenOptions;
|
|
56
53
|
}
|
|
57
54
|
declare function getSetCookie(header: string, prevCookie?: string | undefined): string;
|
|
58
55
|
declare function getCookie(cookie: string): string;
|
|
@@ -105,7 +102,7 @@ declare function storageAdapter(storage: {
|
|
|
105
102
|
declare const expoClient: (opts: ExpoClientOptions) => {
|
|
106
103
|
id: "expo";
|
|
107
104
|
version: string;
|
|
108
|
-
getActions(
|
|
105
|
+
getActions(_fetch: unknown, $store: ClientStore): {
|
|
109
106
|
/**
|
|
110
107
|
* Get the stored cookie.
|
|
111
108
|
*
|
|
@@ -127,7 +124,7 @@ declare const expoClient: (opts: ExpoClientOptions) => {
|
|
|
127
124
|
id: string;
|
|
128
125
|
name: string;
|
|
129
126
|
hooks: {
|
|
130
|
-
onSuccess(context:
|
|
127
|
+
onSuccess(context: import("@better-fetch/fetch").SuccessContext<any>): Promise<void>;
|
|
131
128
|
};
|
|
132
129
|
init(url: string, options: ({
|
|
133
130
|
priority?: RequestPriority | undefined;
|
|
@@ -142,17 +139,17 @@ declare const expoClient: (opts: ExpoClientOptions) => {
|
|
|
142
139
|
referrer?: string | undefined;
|
|
143
140
|
referrerPolicy?: ReferrerPolicy | undefined;
|
|
144
141
|
signal?: (AbortSignal | null) | undefined;
|
|
145
|
-
onRequest?: (<T extends Record<string, any>>(context:
|
|
146
|
-
onResponse?: ((context:
|
|
147
|
-
onSuccess?: ((context:
|
|
148
|
-
onError?: ((context:
|
|
149
|
-
onRetry?: ((response:
|
|
142
|
+
onRequest?: (<T extends Record<string, any>>(context: import("@better-fetch/fetch").RequestContext<T>) => Promise<import("@better-fetch/fetch").RequestContext | void> | import("@better-fetch/fetch").RequestContext | void) | undefined;
|
|
143
|
+
onResponse?: ((context: import("@better-fetch/fetch").ResponseContext) => Promise<Response | void | import("@better-fetch/fetch").ResponseContext> | Response | import("@better-fetch/fetch").ResponseContext | void) | undefined;
|
|
144
|
+
onSuccess?: ((context: import("@better-fetch/fetch").SuccessContext<any>) => Promise<void> | void) | undefined;
|
|
145
|
+
onError?: ((context: import("@better-fetch/fetch").ErrorContext) => Promise<void> | void) | undefined;
|
|
146
|
+
onRetry?: ((response: import("@better-fetch/fetch").ResponseContext) => Promise<void> | void) | undefined;
|
|
150
147
|
hookOptions?: {
|
|
151
148
|
cloneResponse?: boolean;
|
|
152
149
|
} | undefined;
|
|
153
150
|
timeout?: number | undefined;
|
|
154
|
-
customFetchImpl?:
|
|
155
|
-
plugins?:
|
|
151
|
+
customFetchImpl?: import("@better-fetch/fetch").FetchEsque | undefined;
|
|
152
|
+
plugins?: import("@better-fetch/fetch").BetterFetchPlugin[] | undefined;
|
|
156
153
|
baseURL?: string | undefined;
|
|
157
154
|
throw?: boolean | undefined;
|
|
158
155
|
auth?: ({
|
|
@@ -178,10 +175,10 @@ declare const expoClient: (opts: ExpoClientOptions) => {
|
|
|
178
175
|
params?: any;
|
|
179
176
|
duplex?: "full" | "half" | undefined;
|
|
180
177
|
jsonParser?: ((text: string) => Promise<any> | any) | undefined;
|
|
181
|
-
retry?:
|
|
178
|
+
retry?: import("@better-fetch/fetch").RetryOptions | undefined;
|
|
182
179
|
retryAttempt?: number | undefined;
|
|
183
|
-
output?: (
|
|
184
|
-
errorSchema?:
|
|
180
|
+
output?: (import("@better-fetch/fetch").StandardSchemaV1 | typeof Blob | typeof File) | undefined;
|
|
181
|
+
errorSchema?: import("@better-fetch/fetch").StandardSchemaV1 | undefined;
|
|
185
182
|
disableValidation?: boolean | undefined;
|
|
186
183
|
} & Record<string, any>) | undefined): Promise<{
|
|
187
184
|
url: string;
|
package/dist/client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as PACKAGE_VERSION } from "./version-
|
|
1
|
+
import { t as PACKAGE_VERSION } from "./version-xoFrTW0m.js";
|
|
2
2
|
import { safeJSONParse } from "@better-auth/core/utils/json";
|
|
3
3
|
import { SECURE_COOKIE_PREFIX, parseSetCookieHeader, parseSetCookieHeader as parseSetCookieHeader$1, stripSecureCookiePrefix } from "better-auth/cookies";
|
|
4
4
|
import Constants from "expo-constants";
|
|
@@ -81,6 +81,9 @@ if (Platform.OS !== "web") {
|
|
|
81
81
|
setupExpoFocusManager();
|
|
82
82
|
setupExpoOnlineManager();
|
|
83
83
|
}
|
|
84
|
+
function defineExpoClientPlugin(plugin) {
|
|
85
|
+
return plugin;
|
|
86
|
+
}
|
|
84
87
|
function getSetCookie(header, prevCookie) {
|
|
85
88
|
const parsed = parseSetCookieHeader$1(header);
|
|
86
89
|
const toSetCookie = safeJSONParse(prevCookie) ?? {};
|
|
@@ -212,6 +215,11 @@ const STORAGE_VALUE_LIMIT = 1800;
|
|
|
212
215
|
const CHUNK_MARKER = "ba-chunks:";
|
|
213
216
|
function storageAdapter(storage) {
|
|
214
217
|
return {
|
|
218
|
+
/**
|
|
219
|
+
* Reads a value, reassembling it if it was split across chunk keys. A value
|
|
220
|
+
* that fit is returned as-is (values written before chunking still read
|
|
221
|
+
* back); a missing chunk returns `null` so a torn write fails closed.
|
|
222
|
+
*/
|
|
215
223
|
getItem: (name) => {
|
|
216
224
|
const key = normalizeCookieName(name);
|
|
217
225
|
const stored = storage.getItem(key);
|
|
@@ -226,6 +234,14 @@ function storageAdapter(storage) {
|
|
|
226
234
|
}
|
|
227
235
|
return value;
|
|
228
236
|
},
|
|
237
|
+
/**
|
|
238
|
+
* Stores `value`, splitting it across chunk keys when it exceeds the
|
|
239
|
+
* per-write limit. The base key is cleared before the chunks are rewritten
|
|
240
|
+
* and set to the marker last, as the commit point, so a write interrupted
|
|
241
|
+
* partway through reads as absent rather than a mix of old and new chunks.
|
|
242
|
+
* Failures are logged, not thrown: persistence is best-effort and must not
|
|
243
|
+
* break the request.
|
|
244
|
+
*/
|
|
229
245
|
setItem: async (name, value) => {
|
|
230
246
|
const key = normalizeCookieName(name);
|
|
231
247
|
try {
|
|
@@ -267,10 +283,10 @@ const expoClient = (opts) => {
|
|
|
267
283
|
const rawScheme = opts?.scheme || Constants.expoConfig?.scheme || Constants.platform?.scheme;
|
|
268
284
|
const scheme = Array.isArray(rawScheme) ? rawScheme[0] : rawScheme;
|
|
269
285
|
if (!scheme && !isWeb) throw new Error("Scheme not found in app.json. Please provide a scheme in the options.");
|
|
270
|
-
return {
|
|
286
|
+
return defineExpoClientPlugin({
|
|
271
287
|
id: "expo",
|
|
272
288
|
version: PACKAGE_VERSION,
|
|
273
|
-
getActions(
|
|
289
|
+
getActions(_fetch, $store) {
|
|
274
290
|
store = $store;
|
|
275
291
|
const sessionAtom = $store.atoms.session;
|
|
276
292
|
if (!isWeb && !opts?.disableCache && sessionAtom) {
|
|
@@ -284,7 +300,23 @@ const expoClient = (opts) => {
|
|
|
284
300
|
error: null
|
|
285
301
|
});
|
|
286
302
|
}
|
|
287
|
-
return {
|
|
303
|
+
return {
|
|
304
|
+
/**
|
|
305
|
+
* Get the stored cookie.
|
|
306
|
+
*
|
|
307
|
+
* You can use this to get the cookie stored in the device and use it in your fetch
|
|
308
|
+
* requests.
|
|
309
|
+
*
|
|
310
|
+
* @example
|
|
311
|
+
* ```ts
|
|
312
|
+
* const cookie = client.getCookie();
|
|
313
|
+
* fetch("https://api.example.com", {
|
|
314
|
+
* headers: {
|
|
315
|
+
* cookie,
|
|
316
|
+
* },
|
|
317
|
+
* });
|
|
318
|
+
*/
|
|
319
|
+
getCookie: () => {
|
|
288
320
|
return getCookie(storage.getItem(cookieName) || "{}");
|
|
289
321
|
} };
|
|
290
322
|
},
|
|
@@ -386,7 +418,7 @@ const expoClient = (opts) => {
|
|
|
386
418
|
};
|
|
387
419
|
}
|
|
388
420
|
}]
|
|
389
|
-
};
|
|
421
|
+
});
|
|
390
422
|
};
|
|
391
423
|
//#endregion
|
|
392
424
|
export { expoClient, getCookie, getSetCookie, hasBetterAuthCookies, normalizeCookieName, parseSetCookieHeader, setupExpoFocusManager, setupExpoOnlineManager, storageAdapter };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import * as better_auth0 from "better-auth";
|
|
2
|
-
import * as zod from "zod";
|
|
3
|
-
import * as better_call0 from "better-call";
|
|
4
|
-
import * as zod_v4_core0 from "zod/v4/core";
|
|
5
|
-
|
|
6
1
|
//#region src/index.d.ts
|
|
7
2
|
interface ExpoOptions {
|
|
8
3
|
/**
|
|
@@ -21,32 +16,32 @@ declare module "@better-auth/core" {
|
|
|
21
16
|
declare const expo: (options?: ExpoOptions | undefined) => {
|
|
22
17
|
id: "expo";
|
|
23
18
|
version: string;
|
|
24
|
-
init: (ctx:
|
|
19
|
+
init: (ctx: import("better-auth").AuthContext) => {
|
|
25
20
|
options: {
|
|
26
21
|
trustedOrigins: string[];
|
|
27
22
|
};
|
|
28
23
|
};
|
|
29
|
-
onRequest(request: Request, ctx:
|
|
24
|
+
onRequest(request: Request, ctx: import("better-auth").AuthContext): Promise<{
|
|
30
25
|
request: Request;
|
|
31
26
|
} | undefined>;
|
|
32
27
|
hooks: {
|
|
33
28
|
after: {
|
|
34
|
-
matcher(context:
|
|
35
|
-
handler: (inputContext:
|
|
29
|
+
matcher(context: import("better-auth").HookEndpointContext): boolean;
|
|
30
|
+
handler: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>;
|
|
36
31
|
}[];
|
|
37
32
|
};
|
|
38
33
|
endpoints: {
|
|
39
|
-
expoAuthorizationProxy:
|
|
34
|
+
expoAuthorizationProxy: import("better-call").StrictEndpoint<"/expo-authorization-proxy", {
|
|
40
35
|
method: "GET";
|
|
41
|
-
query: zod.ZodObject<{
|
|
42
|
-
authorizationURL: zod.ZodString;
|
|
43
|
-
oauthState: zod.ZodOptional<zod.ZodString>;
|
|
44
|
-
},
|
|
36
|
+
query: import("zod").ZodObject<{
|
|
37
|
+
authorizationURL: import("zod").ZodString;
|
|
38
|
+
oauthState: import("zod").ZodOptional<import("zod").ZodString>;
|
|
39
|
+
}, import("zod/v4/core").$strip>;
|
|
45
40
|
metadata: {
|
|
46
41
|
readonly scope: "server";
|
|
47
42
|
};
|
|
48
43
|
}, {
|
|
49
|
-
status: ("OK" | "CREATED" | "ACCEPTED" | "NO_CONTENT" | "MULTIPLE_CHOICES" | "MOVED_PERMANENTLY" | "FOUND" | "SEE_OTHER" | "NOT_MODIFIED" | "TEMPORARY_REDIRECT" | "BAD_REQUEST" | "UNAUTHORIZED" | "PAYMENT_REQUIRED" | "FORBIDDEN" | "NOT_FOUND" | "METHOD_NOT_ALLOWED" | "NOT_ACCEPTABLE" | "PROXY_AUTHENTICATION_REQUIRED" | "REQUEST_TIMEOUT" | "CONFLICT" | "GONE" | "LENGTH_REQUIRED" | "PRECONDITION_FAILED" | "PAYLOAD_TOO_LARGE" | "URI_TOO_LONG" | "UNSUPPORTED_MEDIA_TYPE" | "RANGE_NOT_SATISFIABLE" | "EXPECTATION_FAILED" | "I'M_A_TEAPOT" | "MISDIRECTED_REQUEST" | "UNPROCESSABLE_ENTITY" | "LOCKED" | "FAILED_DEPENDENCY" | "TOO_EARLY" | "UPGRADE_REQUIRED" | "PRECONDITION_REQUIRED" | "TOO_MANY_REQUESTS" | "REQUEST_HEADER_FIELDS_TOO_LARGE" | "UNAVAILABLE_FOR_LEGAL_REASONS" | "INTERNAL_SERVER_ERROR" | "NOT_IMPLEMENTED" | "BAD_GATEWAY" | "SERVICE_UNAVAILABLE" | "GATEWAY_TIMEOUT" | "HTTP_VERSION_NOT_SUPPORTED" | "VARIANT_ALSO_NEGOTIATES" | "INSUFFICIENT_STORAGE" | "LOOP_DETECTED" | "NOT_EXTENDED" | "NETWORK_AUTHENTICATION_REQUIRED") |
|
|
44
|
+
status: ("OK" | "CREATED" | "ACCEPTED" | "NO_CONTENT" | "MULTIPLE_CHOICES" | "MOVED_PERMANENTLY" | "FOUND" | "SEE_OTHER" | "NOT_MODIFIED" | "TEMPORARY_REDIRECT" | "BAD_REQUEST" | "UNAUTHORIZED" | "PAYMENT_REQUIRED" | "FORBIDDEN" | "NOT_FOUND" | "METHOD_NOT_ALLOWED" | "NOT_ACCEPTABLE" | "PROXY_AUTHENTICATION_REQUIRED" | "REQUEST_TIMEOUT" | "CONFLICT" | "GONE" | "LENGTH_REQUIRED" | "PRECONDITION_FAILED" | "PAYLOAD_TOO_LARGE" | "URI_TOO_LONG" | "UNSUPPORTED_MEDIA_TYPE" | "RANGE_NOT_SATISFIABLE" | "EXPECTATION_FAILED" | "I'M_A_TEAPOT" | "MISDIRECTED_REQUEST" | "UNPROCESSABLE_ENTITY" | "LOCKED" | "FAILED_DEPENDENCY" | "TOO_EARLY" | "UPGRADE_REQUIRED" | "PRECONDITION_REQUIRED" | "TOO_MANY_REQUESTS" | "REQUEST_HEADER_FIELDS_TOO_LARGE" | "UNAVAILABLE_FOR_LEGAL_REASONS" | "INTERNAL_SERVER_ERROR" | "NOT_IMPLEMENTED" | "BAD_GATEWAY" | "SERVICE_UNAVAILABLE" | "GATEWAY_TIMEOUT" | "HTTP_VERSION_NOT_SUPPORTED" | "VARIANT_ALSO_NEGOTIATES" | "INSUFFICIENT_STORAGE" | "LOOP_DETECTED" | "NOT_EXTENDED" | "NETWORK_AUTHENTICATION_REQUIRED") | import("better-call").Status;
|
|
50
45
|
body: ({
|
|
51
46
|
message?: string;
|
|
52
47
|
code?: string;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as PACKAGE_VERSION } from "./version-
|
|
1
|
+
import { t as PACKAGE_VERSION } from "./version-xoFrTW0m.js";
|
|
2
2
|
import { createAuthMiddleware } from "@better-auth/core/api";
|
|
3
3
|
import { HIDE_METADATA } from "better-auth";
|
|
4
4
|
import { APIError, createAuthEndpoint } from "better-auth/api";
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import * as _better_fetch_fetch0 from "@better-fetch/fetch";
|
|
2
1
|
import { Awaitable } from "@better-auth/core";
|
|
3
|
-
|
|
4
2
|
//#region src/plugins/last-login-method.d.ts
|
|
5
3
|
interface LastLoginMethodClientConfig {
|
|
6
4
|
storage: {
|
|
@@ -25,7 +23,7 @@ declare const lastLoginMethodClient: (config: LastLoginMethodClientConfig) => {
|
|
|
25
23
|
id: string;
|
|
26
24
|
name: string;
|
|
27
25
|
hooks: {
|
|
28
|
-
onResponse: (ctx:
|
|
26
|
+
onResponse: (ctx: import("@better-fetch/fetch").ResponseContext) => Promise<void>;
|
|
29
27
|
};
|
|
30
28
|
}[];
|
|
31
29
|
getActions(): {
|
package/dist/plugins/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as PACKAGE_VERSION } from "../version-
|
|
1
|
+
import { t as PACKAGE_VERSION } from "../version-xoFrTW0m.js";
|
|
2
2
|
//#region src/plugins/last-login-method.ts
|
|
3
3
|
const paths = [
|
|
4
4
|
"/callback/",
|
|
@@ -29,12 +29,25 @@ const lastLoginMethodClient = (config) => {
|
|
|
29
29
|
}],
|
|
30
30
|
getActions() {
|
|
31
31
|
return {
|
|
32
|
+
/**
|
|
33
|
+
* Get the last used login method from storage
|
|
34
|
+
*
|
|
35
|
+
* @returns The last used login method or null if not found
|
|
36
|
+
*/
|
|
32
37
|
getLastUsedLoginMethod: () => {
|
|
33
38
|
return storage.getItem(lastLoginMethodName);
|
|
34
39
|
},
|
|
40
|
+
/**
|
|
41
|
+
* Clear the last used login method from storage
|
|
42
|
+
*/
|
|
35
43
|
clearLastUsedLoginMethod: async () => {
|
|
36
44
|
await storage.deleteItemAsync(lastLoginMethodName);
|
|
37
45
|
},
|
|
46
|
+
/**
|
|
47
|
+
* Check if a specific login method was the last used
|
|
48
|
+
* @param method The method to check
|
|
49
|
+
* @returns True if the method was the last used, false otherwise
|
|
50
|
+
*/
|
|
38
51
|
isLastUsedLoginMethod: (method) => {
|
|
39
52
|
return storage.getItem(lastLoginMethodName) === method;
|
|
40
53
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/expo",
|
|
3
|
-
"version": "1.7.0-rc.
|
|
3
|
+
"version": "1.7.0-rc.3",
|
|
4
4
|
"description": "Better Auth integration for Expo and React Native applications.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -69,17 +69,17 @@
|
|
|
69
69
|
"expo-network": "~56.0.5",
|
|
70
70
|
"expo-web-browser": "~56.0.5",
|
|
71
71
|
"react-native": "~0.86.0",
|
|
72
|
-
"tsdown": "0.
|
|
73
|
-
"@better-auth/core": "1.7.0-rc.
|
|
74
|
-
"better-auth": "1.7.0-rc.
|
|
72
|
+
"tsdown": "0.22.7",
|
|
73
|
+
"@better-auth/core": "1.7.0-rc.3",
|
|
74
|
+
"better-auth": "1.7.0-rc.3"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
77
|
"expo-constants": ">=17.0.0",
|
|
78
78
|
"expo-linking": ">=7.0.0",
|
|
79
79
|
"expo-network": ">=8.0.7",
|
|
80
80
|
"expo-web-browser": ">=14.0.0",
|
|
81
|
-
"@better-auth/core": "^1.7.0-rc.
|
|
82
|
-
"better-auth": "^1.7.0-rc.
|
|
81
|
+
"@better-auth/core": "^1.7.0-rc.3",
|
|
82
|
+
"better-auth": "^1.7.0-rc.3"
|
|
83
83
|
},
|
|
84
84
|
"peerDependenciesMeta": {
|
|
85
85
|
"expo-constants": {
|