@better-auth/expo 0.7.6-beta.3 → 0.8.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/.turbo/turbo-build.log +11 -11
- package/dist/client.d.mts +12 -1
- package/dist/client.d.ts +12 -1
- package/dist/client.js +1 -1
- package/dist/client.mjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +6 -3
- package/src/client.ts +10 -2
- package/src/index.ts +3 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @better-auth/expo@0.7.6-beta.
|
|
3
|
+
> @better-auth/expo@0.7.6-beta.4 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/client.js [22m[
|
|
18
|
-
[32mCJS[39m [1mdist/index.js [22m[32m1.
|
|
14
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m774.00 B[39m
|
|
15
|
+
[32mESM[39m [1mdist/client.mjs [22m[32m2.47 KB[39m
|
|
16
|
+
[32mESM[39m ⚡️ Build success in 11ms
|
|
17
|
+
[32mCJS[39m [1mdist/client.js [22m[32m3.10 KB[39m
|
|
18
|
+
[32mCJS[39m [1mdist/index.js [22m[32m1.24 KB[39m
|
|
19
19
|
[32mCJS[39m ⚡️ Build success in 11ms
|
|
20
20
|
DTS Build start
|
|
21
|
-
DTS ⚡️ Build success in
|
|
22
|
-
DTS dist/index.d.mts
|
|
23
|
-
DTS dist/client.d.mts
|
|
24
|
-
DTS dist/index.d.ts
|
|
25
|
-
DTS dist/client.d.ts
|
|
21
|
+
DTS ⚡️ Build success in 3118ms
|
|
22
|
+
DTS dist/index.d.mts 688.00 B
|
|
23
|
+
DTS dist/client.d.mts 4.27 KB
|
|
24
|
+
DTS dist/index.d.ts 688.00 B
|
|
25
|
+
DTS dist/client.d.ts 4.27 KB
|
package/dist/client.d.mts
CHANGED
|
@@ -14,7 +14,18 @@ interface ExpoClientOptions {
|
|
|
14
14
|
}
|
|
15
15
|
declare const expoClient: (opts?: ExpoClientOptions) => {
|
|
16
16
|
id: "expo";
|
|
17
|
-
getActions(
|
|
17
|
+
getActions($fetch: _better_fetch_fetch.BetterFetch, $store: Store): {
|
|
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
|
+
};
|
|
18
29
|
fetchPlugins: {
|
|
19
30
|
id: string;
|
|
20
31
|
name: string;
|
package/dist/client.d.ts
CHANGED
|
@@ -14,7 +14,18 @@ interface ExpoClientOptions {
|
|
|
14
14
|
}
|
|
15
15
|
declare const expoClient: (opts?: ExpoClientOptions) => {
|
|
16
16
|
id: "expo";
|
|
17
|
-
getActions(
|
|
17
|
+
getActions($fetch: _better_fetch_fetch.BetterFetch, $store: Store): {
|
|
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
|
+
};
|
|
18
29
|
fetchPlugins: {
|
|
19
30
|
id: string;
|
|
20
31
|
name: string;
|
package/dist/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var O=Object.create;var d=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var A=(e,t)=>{for(var r in t)d(e,r,{get:t[r],enumerable:!0})},b=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of L(t))!I.call(e,n)&&n!==r&&d(e,n,{get:()=>t[n],enumerable:!(i=x(t,n))||i.enumerable});return e};var f=(e,t,r)=>(r=e!=null?O(R(e)):{},b(t||!e||!e.__esModule?d(r,"default",{value:e,enumerable:!0}):r,e)),U=e=>b(d({},"__esModule",{value:!0}),e);var D={};A(D,{expoClient:()=>E});module.exports=U(D);var C=f(require("expo-web-browser")),h=f(require("expo-linking")),p=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[n,...a]=i.split("; "),[l,o]=n.split("="),s={value:o};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,n)=>{let a=i.expires,l=i["max-age"],o=a?new Date(String(a)):l?new Date(Date.now()+Number(l)):null;r[n]={value:i.value,expires:o}}),JSON.stringify(r)}function v(e){let t={};try{t=JSON.parse(e)}catch{}return Object.entries(t).reduce((i,[n,a])=>a.expires&&a.expires<new Date?i:`${i}; ${n}=${a.value}`,"")}function B(e){return h.createURL("",{scheme:e})}var E=e=>{let t=null,r=`${e?.storagePrefix||"better-auth"}_cookie`,i=`${e?.storagePrefix||"better-auth"}_session_data`,n=e?.storage||P,a=e?.scheme||y.default.platform?.scheme,l=p.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(o,s){if(p.Platform.OS==="web")return{};t=s;let c=n.getItem(r);return c&&s.atoms.session.set({data:JSON.parse(c),error:null,isPending:!1}),{signInWithIdToken:async u=>{let{data:g,error:m}=await o("/sign-in/id-token",{method:"POST",body:JSON.stringify({idToken:u})});return{data:g,error:m}}}},fetchPlugins:[{id:"expo",name:"Expo",hooks:{async onSuccess(o){if(l)return;let s=o.response.headers.get("set-cookie");if(s){let c=S(s||"");await n.setItem(r,c),t?.notify("$sessionSignal")}if(o.request.url.toString().includes("/get-session")&&!e?.disableCache){let c=o.data;n.setItem(i,JSON.stringify(c))}if(o.data.redirect&&o.request.url.toString().includes("/sign-in")){let u=JSON.parse(o.request.body)?.callbackURL,g=o.data?.url,m=await C.openAuthSessionAsync(g,u);if(m.type!=="success")return;let w=new URL(m.url),k=String(w.searchParams.get("cookie"));if(!k)return;n.setItem(r,S(k)),t?.notify("$sessionSignal")}}},async init(o,s){if(l)return{url:o,options:{...s,signal:new AbortController().signal}};s=s||{};let c=n.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=h.createURL(s.body.callbackURL,{scheme:a});s.body.callbackURL=g}return o.includes("/sign-out")&&(await n.setItem(r,"{}"),t?.atoms.session?.set({data:null,error:null,isPending:!1}),n.setItem(i,"{}")),{url:o,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 d 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(o=>{let[n,...i]=o.split("; "),[l,t]=n.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((o,n)=>{let i=o.expires,l=o["max-age"],t=i?new Date(String(i)):l?new Date(Date.now()+Number(l)):null;c[n]={value:o.value,expires:t}}),JSON.stringify(c)}function w(s){let r={};try{r=JSON.parse(s)}catch{}return Object.entries(r).reduce((o,[n,i])=>i.expires&&i.expires<new Date?o:`${o}; ${n}=${i.value}`,"")}function O(s){return d.createURL("",{scheme:s})}var R=s=>{let r=null,c=`${s?.storagePrefix||"better-auth"}_cookie`,o=`${s?.storagePrefix||"better-auth"}_session_data`,n=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=n.getItem(c);return a&&e.atoms.session.set({data:JSON.parse(a),error:null,isPending:!1}),{signInWithIdToken:async u=>{let{data:g,error:m}=await t("/sign-in/id-token",{method:"POST",body:JSON.stringify({idToken:u})});return{data:g,error:m}}}},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 n.setItem(c,a),r?.notify("$sessionSignal")}if(t.request.url.toString().includes("/get-session")&&!s?.disableCache){let a=t.data;n.setItem(o,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,m=await k.openAuthSessionAsync(g,u);if(m.type!=="success")return;let b=new URL(m.url),f=String(b.searchParams.get("cookie"));if(!f)return;n.setItem(c,h(f)),r?.notify("$sessionSignal")}}},async init(t,e){if(l)return{url:t,options:{...e,signal:new AbortController().signal}};e=e||{};let a=n.getItem(c),u=w(a||"{}");if(e.credentials="omit",e.headers={...e.headers,cookie:u,"expo-origin":O(i)},e.body?.callbackURL&&e.body.callbackURL.startsWith("/")){let g=d.createURL(e.body.callbackURL,{scheme:i});e.body.callbackURL=g}return t.includes("/sign-out")&&(await n.setItem(c,"{}"),r?.atoms.session?.set({data:null,error:null,isPending:!1}),n.setItem(o,"{}")),{url:t,options:{...e,signal:new AbortController().signal}}}}]}};export{R as expoClient};
|
package/dist/index.d.mts
CHANGED
|
@@ -14,7 +14,7 @@ declare const expo: () => {
|
|
|
14
14
|
after: {
|
|
15
15
|
matcher(context: better_auth.HookEndpointContext<{}>): boolean;
|
|
16
16
|
handler: (ctx: better_auth.HookEndpointContext<{
|
|
17
|
-
returned: unknown;
|
|
17
|
+
returned: unknown | Response;
|
|
18
18
|
}>) => Promise<{
|
|
19
19
|
response: Response;
|
|
20
20
|
} | undefined>;
|
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ declare const expo: () => {
|
|
|
14
14
|
after: {
|
|
15
15
|
matcher(context: better_auth.HookEndpointContext<{}>): boolean;
|
|
16
16
|
handler: (ctx: better_auth.HookEndpointContext<{
|
|
17
|
-
returned: unknown;
|
|
17
|
+
returned: unknown | Response;
|
|
18
18
|
}>) => Promise<{
|
|
19
19
|
response: Response;
|
|
20
20
|
} | undefined>;
|
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 p=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var h=(t,e)=>{for(var r in e)o(t,r,{get:e[r],enumerable:!0})},g=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of p(e))!d.call(t,s)&&s!==r&&o(t,s,{get:()=>e[s],enumerable:!(i=c(e,s))||i.enumerable});return t};var f=t=>g(o({},"__esModule",{value:!0}),t);var l={};h(l,{expo:()=>m});module.exports=f(l);var x=require("@better-fetch/fetch"),b=require("better-auth/api"),A=require("zod"),m=()=>({id:"expo",init:t=>({options:{trustedOrigins:process.env.NODE_ENV==="development"?[...t.options.trustedOrigins||[],"exp://"]:t.options.trustedOrigins}}),async onRequest(t,e){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
|
-
var
|
|
1
|
+
import"@better-fetch/fetch";import"better-auth/api";import"zod";var f=()=>({id:"expo",init:t=>({options:{trustedOrigins:process.env.NODE_ENV==="development"?[...t.options.trustedOrigins||[],"exp://"]:t.options.trustedOrigins}}),async onRequest(t,e){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{f as expo};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/expo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -28,10 +28,13 @@
|
|
|
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.
|
|
31
|
+
"better-auth": "0.8.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"better-auth": "0.
|
|
34
|
+
"better-auth": "0.8.0"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"zod": "^3.23.8"
|
|
35
38
|
},
|
|
36
39
|
"scripts": {
|
|
37
40
|
"test": "vitest",
|
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($fetch, $store) {
|
|
108
108
|
if (Platform.OS === "web") return {};
|
|
109
109
|
store = $store;
|
|
110
110
|
const localSession = storage.getItem(cookieName);
|
|
@@ -114,7 +114,15 @@ export const expoClient = (opts?: ExpoClientOptions) => {
|
|
|
114
114
|
error: null,
|
|
115
115
|
isPending: false,
|
|
116
116
|
});
|
|
117
|
-
return {
|
|
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
|
+
};
|
|
118
126
|
},
|
|
119
127
|
fetchPlugins: [
|
|
120
128
|
{
|