@better-auth/expo 1.7.0-beta.5 → 1.7.0-beta.6
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.js +21 -16
- package/dist/index.js +12 -4
- package/dist/plugins/index.js +1 -1
- package/dist/{version-B5BVt-3D.js → version-CwIAD4mm.js} +1 -1
- package/package.json +7 -7
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-CwIAD4mm.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";
|
|
@@ -254,6 +254,16 @@ const expoClient = (opts) => {
|
|
|
254
254
|
const storage = storageAdapter(opts?.storage);
|
|
255
255
|
const isWeb = Platform.OS === "web";
|
|
256
256
|
const cookiePrefix = opts?.cookiePrefix || "better-auth";
|
|
257
|
+
const clearSessionCache = async () => {
|
|
258
|
+
await storage.setItem(cookieName, "{}");
|
|
259
|
+
store?.atoms.session?.set({
|
|
260
|
+
...store.atoms.session.get(),
|
|
261
|
+
data: null,
|
|
262
|
+
error: null,
|
|
263
|
+
isPending: false
|
|
264
|
+
});
|
|
265
|
+
await storage.setItem(localCacheName, "{}");
|
|
266
|
+
};
|
|
257
267
|
const rawScheme = opts?.scheme || Constants.expoConfig?.scheme || Constants.platform?.scheme;
|
|
258
268
|
const scheme = Array.isArray(rawScheme) ? rawScheme[0] : rawScheme;
|
|
259
269
|
if (!scheme && !isWeb) throw new Error("Scheme not found in app.json. Please provide a scheme in the options.");
|
|
@@ -298,6 +308,7 @@ const expoClient = (opts) => {
|
|
|
298
308
|
const data = context.data;
|
|
299
309
|
await storage.setItem(localCacheName, JSON.stringify(data));
|
|
300
310
|
}
|
|
311
|
+
if (context.request.url.toString().includes("/sign-out")) await clearSessionCache();
|
|
301
312
|
if (context.data?.redirect && (context.request.url.toString().includes("/sign-in") || context.request.url.toString().includes("/link-social")) && !context.request?.body.includes("idToken")) {
|
|
302
313
|
const to = JSON.parse(context.request.body)?.callbackURL;
|
|
303
314
|
const signInURL = context.data?.url;
|
|
@@ -334,11 +345,14 @@ const expoClient = (opts) => {
|
|
|
334
345
|
};
|
|
335
346
|
options = options || {};
|
|
336
347
|
options.credentials = "omit";
|
|
337
|
-
if (options.body?.idToken !== void 0)
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
348
|
+
if (options.body?.idToken !== void 0) {
|
|
349
|
+
const cookie = url.includes("/link-social") ? getCookie(storage.getItem(cookieName) || "{}") : "";
|
|
350
|
+
options.headers = {
|
|
351
|
+
...options.headers,
|
|
352
|
+
...cookie ? { cookie } : {},
|
|
353
|
+
"x-skip-oauth-proxy": "true"
|
|
354
|
+
};
|
|
355
|
+
} else {
|
|
342
356
|
const cookie = getCookie(storage.getItem(cookieName) || "{}");
|
|
343
357
|
options.headers = {
|
|
344
358
|
...options.headers,
|
|
@@ -364,16 +378,7 @@ const expoClient = (opts) => {
|
|
|
364
378
|
options.body.errorCallbackURL = url;
|
|
365
379
|
}
|
|
366
380
|
}
|
|
367
|
-
if (url.includes("/sign-out"))
|
|
368
|
-
await storage.setItem(cookieName, "{}");
|
|
369
|
-
store?.atoms.session?.set({
|
|
370
|
-
...store.atoms.session.get(),
|
|
371
|
-
data: null,
|
|
372
|
-
error: null,
|
|
373
|
-
isPending: false
|
|
374
|
-
});
|
|
375
|
-
await storage.setItem(localCacheName, "{}");
|
|
376
|
-
}
|
|
381
|
+
if (url.includes("/sign-out")) await clearSessionCache();
|
|
377
382
|
}
|
|
378
383
|
return {
|
|
379
384
|
url,
|
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-CwIAD4mm.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";
|
|
@@ -12,14 +12,22 @@ const expoAuthorizationProxy = createAuthEndpoint("/expo-authorization-proxy", {
|
|
|
12
12
|
}),
|
|
13
13
|
metadata: HIDE_METADATA
|
|
14
14
|
}, async (ctx) => {
|
|
15
|
+
const { authorizationURL } = ctx.query;
|
|
16
|
+
if (authorizationURL.includes("#")) throw new APIError("BAD_REQUEST", { message: "Invalid authorizationURL" });
|
|
17
|
+
let url;
|
|
18
|
+
try {
|
|
19
|
+
url = new URL(authorizationURL);
|
|
20
|
+
} catch {
|
|
21
|
+
throw new APIError("BAD_REQUEST", { message: "Invalid authorizationURL" });
|
|
22
|
+
}
|
|
23
|
+
if (url.protocol !== "https:" || url.origin === new URL(ctx.context.baseURL).origin) throw new APIError("BAD_REQUEST", { message: "Invalid authorizationURL" });
|
|
15
24
|
const { oauthState } = ctx.query;
|
|
16
25
|
if (oauthState) {
|
|
17
26
|
const oauthStateCookie = ctx.context.createAuthCookie("oauth_state", { maxAge: 600 });
|
|
18
27
|
ctx.setCookie(oauthStateCookie.name, oauthState, oauthStateCookie.attributes);
|
|
19
|
-
return ctx.redirect(
|
|
28
|
+
return ctx.redirect(authorizationURL);
|
|
20
29
|
}
|
|
21
|
-
const
|
|
22
|
-
const state = new URL(authorizationURL).searchParams.get("state");
|
|
30
|
+
const state = url.searchParams.get("state");
|
|
23
31
|
if (!state) throw new APIError("BAD_REQUEST", { message: "Unexpected error" });
|
|
24
32
|
const stateCookie = ctx.context.createAuthCookie("state", { maxAge: 300 });
|
|
25
33
|
await ctx.setSignedCookie(stateCookie.name, state, ctx.context.secret, stateCookie.attributes);
|
package/dist/plugins/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/expo",
|
|
3
|
-
"version": "1.7.0-beta.
|
|
3
|
+
"version": "1.7.0-beta.6",
|
|
4
4
|
"description": "Better Auth integration for Expo and React Native applications.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -58,28 +58,28 @@
|
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@better-fetch/fetch": "1.
|
|
61
|
+
"@better-fetch/fetch": "1.3.1",
|
|
62
62
|
"better-call": "1.3.6",
|
|
63
63
|
"zod": "^4.3.6"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@better-fetch/fetch": "1.
|
|
66
|
+
"@better-fetch/fetch": "1.3.1",
|
|
67
67
|
"expo-constants": "~55.0.7",
|
|
68
68
|
"expo-linking": "~55.0.7",
|
|
69
69
|
"expo-network": "~55.0.8",
|
|
70
70
|
"expo-web-browser": "~55.0.9",
|
|
71
71
|
"react-native": "~0.84.1",
|
|
72
72
|
"tsdown": "0.21.1",
|
|
73
|
-
"@better-auth/core": "1.7.0-beta.
|
|
74
|
-
"better-auth": "1.7.0-beta.
|
|
73
|
+
"@better-auth/core": "1.7.0-beta.6",
|
|
74
|
+
"better-auth": "1.7.0-beta.6"
|
|
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-beta.
|
|
82
|
-
"better-auth": "^1.7.0-beta.
|
|
81
|
+
"@better-auth/core": "^1.7.0-beta.6",
|
|
82
|
+
"better-auth": "^1.7.0-beta.6"
|
|
83
83
|
},
|
|
84
84
|
"peerDependenciesMeta": {
|
|
85
85
|
"expo-constants": {
|