@better-auth/expo 0.8.4-beta.4 → 0.8.4-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/.turbo/turbo-build.log +9 -9
- package/dist/client.d.mts +20 -2
- package/dist/client.d.ts +20 -2
- package/dist/client.js +1 -1
- package/dist/client.mjs +1 -1
- package/package.json +3 -3
- package/src/client.ts +32 -11
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @better-auth/expo@0.8.
|
|
3
|
+
> @better-auth/expo@0.8.4-beta.5 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
|
-
[32mCJS[39m [1mdist/index.js [22m[32m1.20 KB[39m
|
|
15
|
-
[32mCJS[39m [1mdist/client.js [22m[32m2.95 KB[39m
|
|
16
|
-
[32mCJS[39m ⚡️ Build success in 9ms
|
|
17
14
|
[32mESM[39m [1mdist/index.mjs [22m[32m744.00 B[39m
|
|
18
|
-
[32mESM[39m [1mdist/client.mjs [22m[32m2.
|
|
19
|
-
[32mESM[39m ⚡️ Build success in
|
|
15
|
+
[32mESM[39m [1mdist/client.mjs [22m[32m2.38 KB[39m
|
|
16
|
+
[32mESM[39m ⚡️ Build success in 12ms
|
|
17
|
+
[32mCJS[39m [1mdist/client.js [22m[32m3.02 KB[39m
|
|
18
|
+
[32mCJS[39m [1mdist/index.js [22m[32m1.20 KB[39m
|
|
19
|
+
[32mCJS[39m ⚡️ Build success in 11ms
|
|
20
20
|
DTS Build start
|
|
21
|
-
DTS ⚡️ Build success in
|
|
21
|
+
DTS ⚡️ Build success in 3123ms
|
|
22
22
|
DTS dist/index.d.mts 111.00 B
|
|
23
|
-
DTS dist/client.d.mts
|
|
23
|
+
DTS dist/client.d.mts 4.45 KB
|
|
24
24
|
DTS dist/index.d.ts 111.00 B
|
|
25
|
-
DTS dist/client.d.ts
|
|
25
|
+
DTS dist/client.d.ts 4.45 KB
|
package/dist/client.d.mts
CHANGED
|
@@ -12,9 +12,27 @@ interface ExpoClientOptions {
|
|
|
12
12
|
storagePrefix?: string;
|
|
13
13
|
disableCache?: boolean;
|
|
14
14
|
}
|
|
15
|
+
declare function getCookie(cookie: string): string;
|
|
15
16
|
declare const expoClient: (opts?: ExpoClientOptions) => {
|
|
16
17
|
id: "expo";
|
|
17
|
-
getActions(_: _better_fetch_fetch.BetterFetch, $store: Store): {
|
|
18
|
+
getActions(_: _better_fetch_fetch.BetterFetch, $store: Store): {
|
|
19
|
+
/**
|
|
20
|
+
* Get the stored cookie.
|
|
21
|
+
*
|
|
22
|
+
* You can use this to get the cookie stored in the device and use it in your fetch
|
|
23
|
+
* requests.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* const cookie = client.getCookie();
|
|
28
|
+
* fetch("https://api.example.com", {
|
|
29
|
+
* headers: {
|
|
30
|
+
* cookie,
|
|
31
|
+
* },
|
|
32
|
+
* });
|
|
33
|
+
*/
|
|
34
|
+
getCookie: () => string;
|
|
35
|
+
};
|
|
18
36
|
fetchPlugins: {
|
|
19
37
|
id: string;
|
|
20
38
|
name: string;
|
|
@@ -81,4 +99,4 @@ declare const expoClient: (opts?: ExpoClientOptions) => {
|
|
|
81
99
|
}[];
|
|
82
100
|
};
|
|
83
101
|
|
|
84
|
-
export { expoClient };
|
|
102
|
+
export { expoClient, getCookie };
|
package/dist/client.d.ts
CHANGED
|
@@ -12,9 +12,27 @@ interface ExpoClientOptions {
|
|
|
12
12
|
storagePrefix?: string;
|
|
13
13
|
disableCache?: boolean;
|
|
14
14
|
}
|
|
15
|
+
declare function getCookie(cookie: string): string;
|
|
15
16
|
declare const expoClient: (opts?: ExpoClientOptions) => {
|
|
16
17
|
id: "expo";
|
|
17
|
-
getActions(_: _better_fetch_fetch.BetterFetch, $store: Store): {
|
|
18
|
+
getActions(_: _better_fetch_fetch.BetterFetch, $store: Store): {
|
|
19
|
+
/**
|
|
20
|
+
* Get the stored cookie.
|
|
21
|
+
*
|
|
22
|
+
* You can use this to get the cookie stored in the device and use it in your fetch
|
|
23
|
+
* requests.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* const cookie = client.getCookie();
|
|
28
|
+
* fetch("https://api.example.com", {
|
|
29
|
+
* headers: {
|
|
30
|
+
* cookie,
|
|
31
|
+
* },
|
|
32
|
+
* });
|
|
33
|
+
*/
|
|
34
|
+
getCookie: () => string;
|
|
35
|
+
};
|
|
18
36
|
fetchPlugins: {
|
|
19
37
|
id: string;
|
|
20
38
|
name: string;
|
|
@@ -81,4 +99,4 @@ declare const expoClient: (opts?: ExpoClientOptions) => {
|
|
|
81
99
|
}[];
|
|
82
100
|
};
|
|
83
101
|
|
|
84
|
-
export { expoClient };
|
|
102
|
+
export { expoClient, getCookie };
|
package/dist/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var L=Object.create;var m=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var A=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var U=(e,t)=>{for(var s in t)m(e,s,{get:t[s],enumerable:!0})},S=(e,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of R(t))!I.call(e,r)&&r!==s&&m(e,r,{get:()=>t[r],enumerable:!(i=O(t,r))||i.enumerable});return e};var f=(e,t,s)=>(s=e!=null?L(A(e)):{},S(t||!e||!e.__esModule?m(s,"default",{value:e,enumerable:!0}):s,e)),P=e=>S(m({},"__esModule",{value:!0}),e);var D={};U(D,{expoClient:()=>E,getCookie:()=>p});module.exports=P(D);var y=f(require("expo-web-browser")),k=f(require("expo-linking")),d=require("react-native"),N=f(require("expo-secure-store")),w=f(require("expo-constants"));function v(e){let t=new Map;return e.split(", ").forEach(i=>{let[r,...c]=i.split("; "),[l,n]=r.split("="),o={value:n};c.forEach(a=>{let[u,g]=a.split("=");o[u.toLowerCase()]=g}),t.set(l,o)}),t}function C(e){let t=v(e),s={};return t.forEach((i,r)=>{let c=i.expires,l=i["max-age"],n=c?new Date(String(c)):l?new Date(Date.now()+Number(l)):null;s[r]={value:i.value,expires:n}}),JSON.stringify(s)}function p(e){let t={};try{t=JSON.parse(e)}catch{}return Object.entries(t).reduce((i,[r,c])=>c.expires&&c.expires<new Date?i:`${i}; ${r}=${c.value}`,"")}function B(e){return k.createURL("",{scheme:e})}var E=e=>{let t=null,s=`${e?.storagePrefix||"better-auth"}_cookie`,i=`${e?.storagePrefix||"better-auth"}_session_data`,r=e?.storage||N,c=e?.scheme||w.default.platform?.scheme,l=d.Platform.OS==="web";if(!c&&!l)throw new Error("Scheme not found in app.json. Please provide a scheme in the options.");return{id:"expo",getActions(n,o){if(d.Platform.OS!=="web"){t=o;let a=r.getItem(s);a&&o.atoms.session.set({data:JSON.parse(a),error:null,isPending:!1})}return{getCookie:()=>{let a=r.getItem(s);return p(a||"{}")}}},fetchPlugins:[{id:"expo",name:"Expo",hooks:{async onSuccess(n){if(l)return;let o=n.response.headers.get("set-cookie");if(o){let a=C(o||"");await r.setItem(s,a),t?.notify("$sessionSignal")}if(n.request.url.toString().includes("/get-session")&&!e?.disableCache){let a=n.data;r.setItem(i,JSON.stringify(a))}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 y.openAuthSessionAsync(g,u);if(h.type!=="success")return;let x=new URL(h.url),b=String(x.searchParams.get("cookie"));if(!b)return;r.setItem(s,C(b)),t?.notify("$sessionSignal")}}},async init(n,o){if(l)return{url:n,options:{...o,signal:new AbortController().signal}};o=o||{};let a=r.getItem(s),u=p(a||"{}");if(o.credentials="omit",o.headers={...o.headers,cookie:u,"expo-origin":B(c)},o.body?.callbackURL&&o.body.callbackURL.startsWith("/")){let g=k.createURL(o.body.callbackURL,{scheme:c});o.body.callbackURL=g}return n.includes("/sign-out")&&(await r.setItem(s,"{}"),t?.atoms.session?.set({data:null,error:null,isPending:!1}),r.setItem(i,"{}")),{url:n,options:{...o,signal:new AbortController().signal}}}}]}};0&&(module.exports={expoClient,getCookie});
|
package/dist/client.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import*as b from"expo-web-browser";import*as m from"expo-linking";import{Platform as p}from"react-native";import*as C from"expo-secure-store";import y from"expo-constants";function w(r){let o=new Map;return r.split(", ").forEach(i=>{let[s,...a]=i.split("; "),[l,t]=s.split("="),e={value:t};a.forEach(n=>{let[u,g]=n.split("=");e[u.toLowerCase()]=g}),o.set(l,e)}),o}function k(r){let o=w(r),c={};return o.forEach((i,s)=>{let a=i.expires,l=i["max-age"],t=a?new Date(String(a)):l?new Date(Date.now()+Number(l)):null;c[s]={value:i.value,expires:t}}),JSON.stringify(c)}function h(r){let o={};try{o=JSON.parse(r)}catch{}return Object.entries(o).reduce((i,[s,a])=>a.expires&&a.expires<new Date?i:`${i}; ${s}=${a.value}`,"")}function x(r){return m.createURL("",{scheme:r})}var R=r=>{let o=null,c=`${r?.storagePrefix||"better-auth"}_cookie`,i=`${r?.storagePrefix||"better-auth"}_session_data`,s=r?.storage||C,a=r?.scheme||y.platform?.scheme,l=p.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(t,e){if(p.OS!=="web"){o=e;let n=s.getItem(c);n&&e.atoms.session.set({data:JSON.parse(n),error:null,isPending:!1})}return{getCookie:()=>{let n=s.getItem(c);return h(n||"{}")}}},fetchPlugins:[{id:"expo",name:"Expo",hooks:{async onSuccess(t){if(l)return;let e=t.response.headers.get("set-cookie");if(e){let n=k(e||"");await s.setItem(c,n),o?.notify("$sessionSignal")}if(t.request.url.toString().includes("/get-session")&&!r?.disableCache){let n=t.data;s.setItem(i,JSON.stringify(n))}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 b.openAuthSessionAsync(g,u);if(f.type!=="success")return;let S=new URL(f.url),d=String(S.searchParams.get("cookie"));if(!d)return;s.setItem(c,k(d)),o?.notify("$sessionSignal")}}},async init(t,e){if(l)return{url:t,options:{...e,signal:new AbortController().signal}};e=e||{};let n=s.getItem(c),u=h(n||"{}");if(e.credentials="omit",e.headers={...e.headers,cookie:u,"expo-origin":x(a)},e.body?.callbackURL&&e.body.callbackURL.startsWith("/")){let g=m.createURL(e.body.callbackURL,{scheme:a});e.body.callbackURL=g}return t.includes("/sign-out")&&(await s.setItem(c,"{}"),o?.atoms.session?.set({data:null,error:null,isPending:!1}),s.setItem(i,"{}")),{url:t,options:{...e,signal:new AbortController().signal}}}}]}};export{R as expoClient,h as getCookie};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/expo",
|
|
3
|
-
"version": "0.8.4-beta.
|
|
3
|
+
"version": "0.8.4-beta.6",
|
|
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.4-beta.
|
|
31
|
+
"better-auth": "0.8.4-beta.6"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"better-auth": "0.8.4-beta.
|
|
34
|
+
"better-auth": "0.8.4-beta.6"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"better-call": "^0.2.14",
|
package/src/client.ts
CHANGED
|
@@ -71,7 +71,7 @@ function getSetCookie(header: string) {
|
|
|
71
71
|
return JSON.stringify(toSetCookie);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
function getCookie(cookie: string) {
|
|
74
|
+
export function getCookie(cookie: string) {
|
|
75
75
|
let parsed = {} as Record<string, StoredCookie>;
|
|
76
76
|
try {
|
|
77
77
|
parsed = JSON.parse(cookie) as Record<string, StoredCookie>;
|
|
@@ -105,16 +105,37 @@ export const expoClient = (opts?: ExpoClientOptions) => {
|
|
|
105
105
|
return {
|
|
106
106
|
id: "expo",
|
|
107
107
|
getActions(_, $store) {
|
|
108
|
-
if (Platform.OS
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
108
|
+
if (Platform.OS !== "web") {
|
|
109
|
+
store = $store;
|
|
110
|
+
const localSession = storage.getItem(cookieName);
|
|
111
|
+
localSession &&
|
|
112
|
+
$store.atoms.session.set({
|
|
113
|
+
data: JSON.parse(localSession),
|
|
114
|
+
error: null,
|
|
115
|
+
isPending: false,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
/**
|
|
120
|
+
* Get the stored cookie.
|
|
121
|
+
*
|
|
122
|
+
* You can use this to get the cookie stored in the device and use it in your fetch
|
|
123
|
+
* requests.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```ts
|
|
127
|
+
* const cookie = client.getCookie();
|
|
128
|
+
* fetch("https://api.example.com", {
|
|
129
|
+
* headers: {
|
|
130
|
+
* cookie,
|
|
131
|
+
* },
|
|
132
|
+
* });
|
|
133
|
+
*/
|
|
134
|
+
getCookie: () => {
|
|
135
|
+
const cookie = storage.getItem(cookieName);
|
|
136
|
+
return getCookie(cookie || "{}");
|
|
137
|
+
},
|
|
138
|
+
};
|
|
118
139
|
},
|
|
119
140
|
fetchPlugins: [
|
|
120
141
|
{
|