@better-auth/expo 0.8.0 → 0.8.1-beta.2
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/.turbo/turbo-build.log +10 -10
- package/dist/client.d.mts +1 -12
- package/dist/client.d.ts +1 -12
- package/dist/client.js +1 -1
- package/dist/client.mjs +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +3 -3
- package/src/client.ts +2 -10
- package/src/index.ts +3 -3
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @better-auth/expo@0.
|
|
3
|
+
> @better-auth/expo@0.8.1-beta.1 build /Users/apple/Desktop/development/better-auth-2/packages/expo
|
|
4
4
|
> tsup --dts --minify --clean
|
|
5
5
|
|
|
6
6
|
[34mCLI[39m Building entry: {"index":"src/index.ts","client":"src/client.ts"}
|
|
@@ -11,15 +11,15 @@
|
|
|
11
11
|
[34mCLI[39m Cleaning output folder
|
|
12
12
|
[34mESM[39m Build start
|
|
13
13
|
[34mCJS[39m Build start
|
|
14
|
-
[32mESM[39m [1mdist/index.mjs [22m[
|
|
15
|
-
[32mESM[39m [1mdist/client.mjs [22m[32m2.
|
|
16
|
-
[32mESM[39m ⚡️ Build success in
|
|
17
|
-
[32mCJS[39m [1mdist/
|
|
18
|
-
[32mCJS[39m [1mdist/
|
|
19
|
-
[32mCJS[39m ⚡️ Build success in
|
|
14
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m744.00 B[39m
|
|
15
|
+
[32mESM[39m [1mdist/client.mjs [22m[32m2.32 KB[39m
|
|
16
|
+
[32mESM[39m ⚡️ Build success in 24ms
|
|
17
|
+
[32mCJS[39m [1mdist/index.js [22m[32m1.20 KB[39m
|
|
18
|
+
[32mCJS[39m [1mdist/client.js [22m[32m2.95 KB[39m
|
|
19
|
+
[32mCJS[39m ⚡️ Build success in 25ms
|
|
20
20
|
DTS Build start
|
|
21
|
-
DTS ⚡️ Build success in
|
|
21
|
+
DTS ⚡️ Build success in 3716ms
|
|
22
22
|
DTS dist/index.d.mts 688.00 B
|
|
23
|
-
DTS dist/client.d.mts
|
|
23
|
+
DTS dist/client.d.mts 3.96 KB
|
|
24
24
|
DTS dist/index.d.ts 688.00 B
|
|
25
|
-
DTS dist/client.d.ts
|
|
25
|
+
DTS dist/client.d.ts 3.96 KB
|
package/dist/client.d.mts
CHANGED
|
@@ -14,18 +14,7 @@ interface ExpoClientOptions {
|
|
|
14
14
|
}
|
|
15
15
|
declare const expoClient: (opts?: ExpoClientOptions) => {
|
|
16
16
|
id: "expo";
|
|
17
|
-
getActions(
|
|
18
|
-
signInWithIdToken?: undefined;
|
|
19
|
-
} | {
|
|
20
|
-
signInWithIdToken: (idToken: string) => Promise<{
|
|
21
|
-
data: unknown;
|
|
22
|
-
error: {
|
|
23
|
-
message?: string | undefined;
|
|
24
|
-
status: number;
|
|
25
|
-
statusText: string;
|
|
26
|
-
} | null;
|
|
27
|
-
}>;
|
|
28
|
-
};
|
|
17
|
+
getActions(_: _better_fetch_fetch.BetterFetch, $store: Store): {};
|
|
29
18
|
fetchPlugins: {
|
|
30
19
|
id: string;
|
|
31
20
|
name: string;
|
package/dist/client.d.ts
CHANGED
|
@@ -14,18 +14,7 @@ interface ExpoClientOptions {
|
|
|
14
14
|
}
|
|
15
15
|
declare const expoClient: (opts?: ExpoClientOptions) => {
|
|
16
16
|
id: "expo";
|
|
17
|
-
getActions(
|
|
18
|
-
signInWithIdToken?: undefined;
|
|
19
|
-
} | {
|
|
20
|
-
signInWithIdToken: (idToken: string) => Promise<{
|
|
21
|
-
data: unknown;
|
|
22
|
-
error: {
|
|
23
|
-
message?: string | undefined;
|
|
24
|
-
status: number;
|
|
25
|
-
statusText: string;
|
|
26
|
-
} | null;
|
|
27
|
-
}>;
|
|
28
|
-
};
|
|
17
|
+
getActions(_: _better_fetch_fetch.BetterFetch, $store: Store): {};
|
|
29
18
|
fetchPlugins: {
|
|
30
19
|
id: string;
|
|
31
20
|
name: string;
|
package/dist/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var x=Object.create;var m=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,A=Object.prototype.hasOwnProperty;var U=(e,t)=>{for(var r in t)m(e,r,{get:t[r],enumerable:!0})},b=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of O(t))!A.call(e,o)&&o!==r&&m(e,o,{get:()=>t[o],enumerable:!(i=L(t,o))||i.enumerable});return e};var f=(e,t,r)=>(r=e!=null?x(R(e)):{},b(t||!e||!e.__esModule?m(r,"default",{value:e,enumerable:!0}):r,e)),I=e=>b(m({},"__esModule",{value:!0}),e);var D={};U(D,{expoClient:()=>E});module.exports=I(D);var C=f(require("expo-web-browser")),p=f(require("expo-linking")),d=require("react-native"),P=f(require("expo-secure-store")),y=f(require("expo-constants"));function N(e){let t=new Map;return e.split(", ").forEach(i=>{let[o,...a]=i.split("; "),[l,n]=o.split("="),s={value:n};a.forEach(c=>{let[u,g]=c.split("=");s[u.toLowerCase()]=g}),t.set(l,s)}),t}function S(e){let t=N(e),r={};return t.forEach((i,o)=>{let a=i.expires,l=i["max-age"],n=a?new Date(String(a)):l?new Date(Date.now()+Number(l)):null;r[o]={value:i.value,expires:n}}),JSON.stringify(r)}function v(e){let t={};try{t=JSON.parse(e)}catch{}return Object.entries(t).reduce((i,[o,a])=>a.expires&&a.expires<new Date?i:`${i}; ${o}=${a.value}`,"")}function B(e){return p.createURL("",{scheme:e})}var E=e=>{let t=null,r=`${e?.storagePrefix||"better-auth"}_cookie`,i=`${e?.storagePrefix||"better-auth"}_session_data`,o=e?.storage||P,a=e?.scheme||y.default.platform?.scheme,l=d.Platform.OS==="web";if(!a&&!l)throw new Error("Scheme not found in app.json. Please provide a scheme in the options.");return{id:"expo",getActions(n,s){if(d.Platform.OS==="web")return{};t=s;let c=o.getItem(r);return c&&s.atoms.session.set({data:JSON.parse(c),error:null,isPending:!1}),{}},fetchPlugins:[{id:"expo",name:"Expo",hooks:{async onSuccess(n){if(l)return;let s=n.response.headers.get("set-cookie");if(s){let c=S(s||"");await o.setItem(r,c),t?.notify("$sessionSignal")}if(n.request.url.toString().includes("/get-session")&&!e?.disableCache){let c=n.data;o.setItem(i,JSON.stringify(c))}if(n.data.redirect&&n.request.url.toString().includes("/sign-in")){let u=JSON.parse(n.request.body)?.callbackURL,g=n.data?.url,h=await C.openAuthSessionAsync(g,u);if(h.type!=="success")return;let w=new URL(h.url),k=String(w.searchParams.get("cookie"));if(!k)return;o.setItem(r,S(k)),t?.notify("$sessionSignal")}}},async init(n,s){if(l)return{url:n,options:{...s,signal:new AbortController().signal}};s=s||{};let c=o.getItem(r),u=v(c||"{}");if(s.credentials="omit",s.headers={...s.headers,cookie:u,"expo-origin":B(a)},s.body?.callbackURL&&s.body.callbackURL.startsWith("/")){let g=p.createURL(s.body.callbackURL,{scheme:a});s.body.callbackURL=g}return n.includes("/sign-out")&&(await o.setItem(r,"{}"),t?.atoms.session?.set({data:null,error:null,isPending:!1}),o.setItem(i,"{}")),{url:n,options:{...s,signal:new AbortController().signal}}}}]}};0&&(module.exports={expoClient});
|
package/dist/client.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as k from"expo-web-browser";import*as
|
|
1
|
+
import*as k from"expo-web-browser";import*as m from"expo-linking";import{Platform as p}from"react-native";import*as S from"expo-secure-store";import C from"expo-constants";function y(s){let r=new Map;return s.split(", ").forEach(n=>{let[o,...i]=n.split("; "),[l,t]=o.split("="),e={value:t};i.forEach(a=>{let[u,g]=a.split("=");e[u.toLowerCase()]=g}),r.set(l,e)}),r}function h(s){let r=y(s),c={};return r.forEach((n,o)=>{let i=n.expires,l=n["max-age"],t=i?new Date(String(i)):l?new Date(Date.now()+Number(l)):null;c[o]={value:n.value,expires:t}}),JSON.stringify(c)}function w(s){let r={};try{r=JSON.parse(s)}catch{}return Object.entries(r).reduce((n,[o,i])=>i.expires&&i.expires<new Date?n:`${n}; ${o}=${i.value}`,"")}function x(s){return m.createURL("",{scheme:s})}var R=s=>{let r=null,c=`${s?.storagePrefix||"better-auth"}_cookie`,n=`${s?.storagePrefix||"better-auth"}_session_data`,o=s?.storage||S,i=s?.scheme||C.platform?.scheme,l=p.OS==="web";if(!i&&!l)throw new Error("Scheme not found in app.json. Please provide a scheme in the options.");return{id:"expo",getActions(t,e){if(p.OS==="web")return{};r=e;let a=o.getItem(c);return a&&e.atoms.session.set({data:JSON.parse(a),error:null,isPending:!1}),{}},fetchPlugins:[{id:"expo",name:"Expo",hooks:{async onSuccess(t){if(l)return;let e=t.response.headers.get("set-cookie");if(e){let a=h(e||"");await o.setItem(c,a),r?.notify("$sessionSignal")}if(t.request.url.toString().includes("/get-session")&&!s?.disableCache){let a=t.data;o.setItem(n,JSON.stringify(a))}if(t.data.redirect&&t.request.url.toString().includes("/sign-in")){let u=JSON.parse(t.request.body)?.callbackURL,g=t.data?.url,f=await k.openAuthSessionAsync(g,u);if(f.type!=="success")return;let b=new URL(f.url),d=String(b.searchParams.get("cookie"));if(!d)return;o.setItem(c,h(d)),r?.notify("$sessionSignal")}}},async init(t,e){if(l)return{url:t,options:{...e,signal:new AbortController().signal}};e=e||{};let a=o.getItem(c),u=w(a||"{}");if(e.credentials="omit",e.headers={...e.headers,cookie:u,"expo-origin":x(i)},e.body?.callbackURL&&e.body.callbackURL.startsWith("/")){let g=m.createURL(e.body.callbackURL,{scheme:i});e.body.callbackURL=g}return t.includes("/sign-out")&&(await o.setItem(c,"{}"),r?.atoms.session?.set({data:null,error:null,isPending:!1}),o.setItem(n,"{}")),{url:t,options:{...e,signal:new AbortController().signal}}}}]}};export{R as expoClient};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var o=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var
|
|
1
|
+
"use strict";var o=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var h=(t,e)=>{for(var r in e)o(t,r,{get:e[r],enumerable:!0})},p=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of g(e))!d.call(t,s)&&s!==r&&o(t,s,{get:()=>e[s],enumerable:!(i=c(e,s))||i.enumerable});return t};var l=t=>p(o({},"__esModule",{value:!0}),t);var f={};h(f,{expo:()=>O});module.exports=l(f);var O=()=>({id:"expo",init:t=>({options:{trustedOrigins:process.env.NODE_ENV==="development"?[...t.options.trustedOrigins||[],"exp://"]:t.options.trustedOrigins}}),async onRequest(t,e){if(t.headers.get("origin"))return;let r=t.headers.get("expo-origin");if(r)return t.headers.set("origin",r),{request:t}},hooks:{after:[{matcher(t){return t.path?.startsWith("/callback")},handler:async t=>{let e=t.context.returned;if(e.status===302){let r=e.headers.get("location");if(!r||!t.context.trustedOrigins.filter(n=>!n.startsWith("http")).some(n=>r?.startsWith(n)))return;let a=e.headers.get("set-cookie");if(!a)return;let u=new URL(r);return u.searchParams.set("cookie",a),e.headers.set("location",u.toString()),{response:e}}}}]}});0&&(module.exports={expo});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
var u=()=>({id:"expo",init:t=>({options:{trustedOrigins:process.env.NODE_ENV==="development"?[...t.options.trustedOrigins||[],"exp://"]:t.options.trustedOrigins}}),async onRequest(t,e){if(t.headers.get("origin"))return;let r=t.headers.get("expo-origin");if(r)return t.headers.set("origin",r),{request:t}},hooks:{after:[{matcher(t){return t.path?.startsWith("/callback")},handler:async t=>{let e=t.context.returned;if(e.status===302){let r=e.headers.get("location");if(!r||!t.context.trustedOrigins.filter(s=>!s.startsWith("http")).some(s=>r?.startsWith(s)))return;let i=e.headers.get("set-cookie");if(!i)return;let n=new URL(r);return n.searchParams.set("cookie",i),e.headers.set("location",n.toString()),{response:e}}}}]}});export{u as expo};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/expo",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1-beta.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"expo-secure-store": "~13.0.2",
|
|
29
29
|
"expo-web-browser": "~13.0.3",
|
|
30
30
|
"vitest": "^1.6.0",
|
|
31
|
-
"better-auth": "0.8.
|
|
31
|
+
"better-auth": "0.8.1-beta.2"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"better-auth": "0.8.
|
|
34
|
+
"better-auth": "0.8.1-beta.2"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"zod": "^3.23.8"
|
package/src/client.ts
CHANGED
|
@@ -104,7 +104,7 @@ export const expoClient = (opts?: ExpoClientOptions) => {
|
|
|
104
104
|
}
|
|
105
105
|
return {
|
|
106
106
|
id: "expo",
|
|
107
|
-
getActions(
|
|
107
|
+
getActions(_, $store) {
|
|
108
108
|
if (Platform.OS === "web") return {};
|
|
109
109
|
store = $store;
|
|
110
110
|
const localSession = storage.getItem(cookieName);
|
|
@@ -114,15 +114,7 @@ export const expoClient = (opts?: ExpoClientOptions) => {
|
|
|
114
114
|
error: null,
|
|
115
115
|
isPending: false,
|
|
116
116
|
});
|
|
117
|
-
return {
|
|
118
|
-
signInWithIdToken: async (idToken: string) => {
|
|
119
|
-
const { data, error } = await $fetch("/sign-in/id-token", {
|
|
120
|
-
method: "POST",
|
|
121
|
-
body: JSON.stringify({ idToken }),
|
|
122
|
-
});
|
|
123
|
-
return { data, error };
|
|
124
|
-
},
|
|
125
|
-
};
|
|
117
|
+
return {};
|
|
126
118
|
},
|
|
127
119
|
fetchPlugins: [
|
|
128
120
|
{
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { betterFetch } from "@better-fetch/fetch";
|
|
2
1
|
import type { BetterAuthPlugin } from "better-auth";
|
|
3
|
-
import { createAuthEndpoint } from "better-auth/api";
|
|
4
|
-
import { z } from "zod";
|
|
5
2
|
|
|
6
3
|
export const expo = () => {
|
|
7
4
|
return {
|
|
@@ -18,6 +15,9 @@ export const expo = () => {
|
|
|
18
15
|
};
|
|
19
16
|
},
|
|
20
17
|
async onRequest(request, ctx) {
|
|
18
|
+
if (request.headers.get("origin")) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
21
|
/**
|
|
22
22
|
* To bypass origin check from expo, we need to set the origin header to the expo-origin header
|
|
23
23
|
*/
|