@better-auth/expo 0.7.3-beta.7 → 0.7.3-beta.9

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.
@@ -1,6 +1,6 @@
1
1
 
2
2
  
3
- > @better-auth/expo@0.7.3-beta.6 build /Users/apple/Desktop/development/better-auth-2/packages/expo
3
+ > @better-auth/expo@0.7.3-beta.8 build /Users/apple/Desktop/development/better-auth-2/packages/expo
4
4
  > tsup --dts --minify --clean
5
5
 
6
6
  CLI Building entry: {"index":"src/index.ts","client":"src/client.ts"}
@@ -11,15 +11,15 @@
11
11
  CLI Cleaning output folder
12
12
  ESM Build start
13
13
  CJS Build start
14
- ESM dist/client.mjs 2.24 KB
15
- ESM dist/index.mjs 736.00 B
16
- ESM ⚡️ Build success in 12ms
17
- CJS dist/client.js 2.87 KB
18
14
  CJS dist/index.js 1.19 KB
19
- CJS ⚡️ Build success in 12ms
15
+ CJS dist/client.js 2.95 KB
16
+ CJS ⚡️ Build success in 21ms
17
+ ESM dist/client.mjs 2.32 KB
18
+ ESM dist/index.mjs 736.00 B
19
+ ESM ⚡️ Build success in 21ms
20
20
  DTS Build start
21
- DTS ⚡️ Build success in 2301ms
21
+ DTS ⚡️ Build success in 3567ms
22
22
  DTS dist/index.d.mts 677.00 B
23
- DTS dist/client.d.mts 7.18 KB
23
+ DTS dist/client.d.mts 6.79 KB
24
24
  DTS dist/index.d.ts 677.00 B
25
- DTS dist/client.d.ts 7.18 KB
25
+ DTS dist/client.d.ts 6.79 KB
package/dist/client.d.mts CHANGED
@@ -11,7 +11,7 @@ interface ExpoClientOptions {
11
11
  storagePrefix?: string;
12
12
  disableCache?: boolean;
13
13
  }
14
- declare const expoClient: (opts: ExpoClientOptions) => {
14
+ declare const expoClient: (opts?: ExpoClientOptions) => {
15
15
  id: "expo";
16
16
  getActions(_: _better_fetch_fetch.BetterFetch, $store: Store): {};
17
17
  fetchPlugins: {
@@ -76,37 +76,37 @@ declare const expoClient: (opts: ExpoClientOptions) => {
76
76
  } | undefined): Promise<{
77
77
  url: string;
78
78
  options: {
79
- cache?: RequestCache | undefined;
80
- credentials?: RequestCredentials | undefined;
79
+ signal: AbortSignal;
80
+ cache?: RequestCache;
81
+ credentials?: RequestCredentials;
81
82
  headers?: (HeadersInit & (HeadersInit | {
82
83
  accept: "application/json" | "text/plain" | "application/octet-stream";
83
84
  "content-type": "application/json" | "text/plain" | "application/x-www-form-urlencoded" | "multipart/form-data" | "application/octet-stream";
84
85
  authorization: "Bearer" | "Basic";
85
86
  })) | undefined;
86
- integrity?: string | undefined;
87
- keepalive?: boolean | undefined;
88
- method?: string | undefined;
89
- mode?: RequestMode | undefined;
90
- priority?: RequestPriority | undefined;
91
- redirect?: RequestRedirect | undefined;
92
- referrer?: string | undefined;
93
- referrerPolicy?: ReferrerPolicy | undefined;
94
- signal?: (AbortSignal | null) | undefined;
95
- window?: null | undefined;
96
- onRequest?: (<T extends Record<string, any>>(context: _better_fetch_fetch.RequestContext<T>) => Promise<_better_fetch_fetch.RequestContext | void> | _better_fetch_fetch.RequestContext | void) | undefined;
97
- onResponse?: ((context: _better_fetch_fetch.ResponseContext) => Promise<Response | void | _better_fetch_fetch.ResponseContext> | Response | _better_fetch_fetch.ResponseContext | void) | undefined;
87
+ integrity?: string;
88
+ keepalive?: boolean;
89
+ method?: string;
90
+ mode?: RequestMode;
91
+ priority?: RequestPriority;
92
+ redirect?: RequestRedirect;
93
+ referrer?: string;
94
+ referrerPolicy?: ReferrerPolicy;
95
+ window?: null;
96
+ onRequest?: <T extends Record<string, any>>(context: _better_fetch_fetch.RequestContext<T>) => Promise<_better_fetch_fetch.RequestContext | void> | _better_fetch_fetch.RequestContext | void;
97
+ onResponse?: (context: _better_fetch_fetch.ResponseContext) => Promise<Response | void | _better_fetch_fetch.ResponseContext> | Response | _better_fetch_fetch.ResponseContext | void;
98
98
  onSuccess?: ((context: _better_fetch_fetch.SuccessContext<any>) => Promise<void> | void) | undefined;
99
- onError?: ((context: _better_fetch_fetch.ErrorContext) => Promise<void> | void) | undefined;
100
- onRetry?: ((response: _better_fetch_fetch.ResponseContext) => Promise<void> | void) | undefined;
99
+ onError?: (context: _better_fetch_fetch.ErrorContext) => Promise<void> | void;
100
+ onRetry?: (response: _better_fetch_fetch.ResponseContext) => Promise<void> | void;
101
101
  hookOptions?: {
102
102
  cloneResponse?: boolean;
103
- } | undefined;
104
- timeout?: number | undefined;
105
- customFetchImpl?: _better_fetch_fetch.FetchEsque | undefined;
106
- plugins?: _better_fetch_fetch.BetterFetchPlugin[] | undefined;
107
- baseURL?: string | undefined;
108
- throw?: boolean | undefined;
109
- auth?: ({
103
+ };
104
+ timeout?: number;
105
+ customFetchImpl?: _better_fetch_fetch.FetchEsque;
106
+ plugins?: _better_fetch_fetch.BetterFetchPlugin[];
107
+ baseURL?: string;
108
+ throw?: boolean;
109
+ auth?: {
110
110
  type: "Bearer";
111
111
  token: string | (() => string | undefined) | undefined;
112
112
  } | {
@@ -117,18 +117,18 @@ declare const expoClient: (opts: ExpoClientOptions) => {
117
117
  type: "Custom";
118
118
  prefix: string | (() => string | undefined) | undefined;
119
119
  value: string | (() => string | undefined) | undefined;
120
- }) | undefined;
120
+ };
121
121
  body?: any;
122
122
  query?: any;
123
123
  params?: any;
124
- duplex?: ("full" | "half") | undefined;
125
- jsonParser?: (<T>(text: string) => Promise<T | undefined>) | undefined;
126
- retry?: _better_fetch_fetch.RetryOptions | undefined;
127
- retryAttempt?: number | undefined;
128
- output?: (zod.ZodType | typeof Blob | typeof File) | undefined;
129
- errorSchema?: zod.ZodType | undefined;
130
- disableValidation?: boolean | undefined;
131
- } | undefined;
124
+ duplex?: "full" | "half";
125
+ jsonParser?: <T>(text: string) => Promise<T | undefined>;
126
+ retry?: _better_fetch_fetch.RetryOptions;
127
+ retryAttempt?: number;
128
+ output?: zod.ZodType | typeof Blob | typeof File;
129
+ errorSchema?: zod.ZodType;
130
+ disableValidation?: boolean;
131
+ };
132
132
  }>;
133
133
  }[];
134
134
  };
package/dist/client.d.ts CHANGED
@@ -11,7 +11,7 @@ interface ExpoClientOptions {
11
11
  storagePrefix?: string;
12
12
  disableCache?: boolean;
13
13
  }
14
- declare const expoClient: (opts: ExpoClientOptions) => {
14
+ declare const expoClient: (opts?: ExpoClientOptions) => {
15
15
  id: "expo";
16
16
  getActions(_: _better_fetch_fetch.BetterFetch, $store: Store): {};
17
17
  fetchPlugins: {
@@ -76,37 +76,37 @@ declare const expoClient: (opts: ExpoClientOptions) => {
76
76
  } | undefined): Promise<{
77
77
  url: string;
78
78
  options: {
79
- cache?: RequestCache | undefined;
80
- credentials?: RequestCredentials | undefined;
79
+ signal: AbortSignal;
80
+ cache?: RequestCache;
81
+ credentials?: RequestCredentials;
81
82
  headers?: (HeadersInit & (HeadersInit | {
82
83
  accept: "application/json" | "text/plain" | "application/octet-stream";
83
84
  "content-type": "application/json" | "text/plain" | "application/x-www-form-urlencoded" | "multipart/form-data" | "application/octet-stream";
84
85
  authorization: "Bearer" | "Basic";
85
86
  })) | undefined;
86
- integrity?: string | undefined;
87
- keepalive?: boolean | undefined;
88
- method?: string | undefined;
89
- mode?: RequestMode | undefined;
90
- priority?: RequestPriority | undefined;
91
- redirect?: RequestRedirect | undefined;
92
- referrer?: string | undefined;
93
- referrerPolicy?: ReferrerPolicy | undefined;
94
- signal?: (AbortSignal | null) | undefined;
95
- window?: null | undefined;
96
- onRequest?: (<T extends Record<string, any>>(context: _better_fetch_fetch.RequestContext<T>) => Promise<_better_fetch_fetch.RequestContext | void> | _better_fetch_fetch.RequestContext | void) | undefined;
97
- onResponse?: ((context: _better_fetch_fetch.ResponseContext) => Promise<Response | void | _better_fetch_fetch.ResponseContext> | Response | _better_fetch_fetch.ResponseContext | void) | undefined;
87
+ integrity?: string;
88
+ keepalive?: boolean;
89
+ method?: string;
90
+ mode?: RequestMode;
91
+ priority?: RequestPriority;
92
+ redirect?: RequestRedirect;
93
+ referrer?: string;
94
+ referrerPolicy?: ReferrerPolicy;
95
+ window?: null;
96
+ onRequest?: <T extends Record<string, any>>(context: _better_fetch_fetch.RequestContext<T>) => Promise<_better_fetch_fetch.RequestContext | void> | _better_fetch_fetch.RequestContext | void;
97
+ onResponse?: (context: _better_fetch_fetch.ResponseContext) => Promise<Response | void | _better_fetch_fetch.ResponseContext> | Response | _better_fetch_fetch.ResponseContext | void;
98
98
  onSuccess?: ((context: _better_fetch_fetch.SuccessContext<any>) => Promise<void> | void) | undefined;
99
- onError?: ((context: _better_fetch_fetch.ErrorContext) => Promise<void> | void) | undefined;
100
- onRetry?: ((response: _better_fetch_fetch.ResponseContext) => Promise<void> | void) | undefined;
99
+ onError?: (context: _better_fetch_fetch.ErrorContext) => Promise<void> | void;
100
+ onRetry?: (response: _better_fetch_fetch.ResponseContext) => Promise<void> | void;
101
101
  hookOptions?: {
102
102
  cloneResponse?: boolean;
103
- } | undefined;
104
- timeout?: number | undefined;
105
- customFetchImpl?: _better_fetch_fetch.FetchEsque | undefined;
106
- plugins?: _better_fetch_fetch.BetterFetchPlugin[] | undefined;
107
- baseURL?: string | undefined;
108
- throw?: boolean | undefined;
109
- auth?: ({
103
+ };
104
+ timeout?: number;
105
+ customFetchImpl?: _better_fetch_fetch.FetchEsque;
106
+ plugins?: _better_fetch_fetch.BetterFetchPlugin[];
107
+ baseURL?: string;
108
+ throw?: boolean;
109
+ auth?: {
110
110
  type: "Bearer";
111
111
  token: string | (() => string | undefined) | undefined;
112
112
  } | {
@@ -117,18 +117,18 @@ declare const expoClient: (opts: ExpoClientOptions) => {
117
117
  type: "Custom";
118
118
  prefix: string | (() => string | undefined) | undefined;
119
119
  value: string | (() => string | undefined) | undefined;
120
- }) | undefined;
120
+ };
121
121
  body?: any;
122
122
  query?: any;
123
123
  params?: any;
124
- duplex?: ("full" | "half") | undefined;
125
- jsonParser?: (<T>(text: string) => Promise<T | undefined>) | undefined;
126
- retry?: _better_fetch_fetch.RetryOptions | undefined;
127
- retryAttempt?: number | undefined;
128
- output?: (zod.ZodType | typeof Blob | typeof File) | undefined;
129
- errorSchema?: zod.ZodType | undefined;
130
- disableValidation?: boolean | undefined;
131
- } | undefined;
124
+ duplex?: "full" | "half";
125
+ jsonParser?: <T>(text: string) => Promise<T | undefined>;
126
+ retry?: _better_fetch_fetch.RetryOptions;
127
+ retryAttempt?: number;
128
+ output?: zod.ZodType | typeof Blob | typeof File;
129
+ errorSchema?: zod.ZodType;
130
+ disableValidation?: boolean;
131
+ };
132
132
  }>;
133
133
  }[];
134
134
  };
package/dist/client.js CHANGED
@@ -1 +1 @@
1
- "use strict";var x=Object.create;var m=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var O=Object.getPrototypeOf,U=Object.prototype.hasOwnProperty;var I=(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 R(t))!U.call(e,o)&&o!==r&&m(e,o,{get:()=>t[o],enumerable:!(i=L(t,o))||i.enumerable});return e};var d=(e,t,r)=>(r=e!=null?x(O(e)):{},b(t||!e||!e.__esModule?m(r,"default",{value:e,enumerable:!0}):r,e)),A=e=>b(m({},"__esModule",{value:!0}),e);var $={};I($,{expoClient:()=>D});module.exports=A($);var C=d(require("expo-web-browser")),k=d(require("expo-linking")),f=require("react-native"),P=d(require("expo-secure-store")),y=d(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 h(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 E(e){return k.createURL("",{scheme:e})}var D=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=f.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(f.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=h(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,p=await C.openAuthSessionAsync(g,u);if(p.type!=="success")return;let w=new URL(p.url),S=String(w.searchParams.get("cookie"));if(!S)return;o.setItem(r,h(S)),t?.notify("$sessionSignal")}}},async init(n,s){if(l)return{url:n,options:s};s=s||{};let c=o.getItem(r),u=v(c||"{}");if(s.credentials="omit",s.headers={...s.headers,cookie:u,"expo-origin":E(a)},s.body?.callbackURL&&s.body.callbackURL.startsWith("/")){let g=k.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}}}]}};0&&(module.exports={expoClient});
1
+ "use strict";var x=Object.create;var m=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var A=Object.getPrototypeOf,O=Object.prototype.hasOwnProperty;var U=(e,t)=>{for(var r in t)m(e,r,{get:t[r],enumerable:!0})},S=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of R(t))!O.call(e,o)&&o!==r&&m(e,o,{get:()=>t[o],enumerable:!(i=L(t,o))||i.enumerable});return e};var d=(e,t,r)=>(r=e!=null?x(A(e)):{},S(t||!e||!e.__esModule?m(r,"default",{value:e,enumerable:!0}):r,e)),I=e=>S(m({},"__esModule",{value:!0}),e);var $={};U($,{expoClient:()=>D});module.exports=I($);var C=d(require("expo-web-browser")),k=d(require("expo-linking")),f=require("react-native"),P=d(require("expo-secure-store")),y=d(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 h(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 E(e){return k.createURL("",{scheme:e})}var D=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=f.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(f.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=h(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,p=await C.openAuthSessionAsync(g,u);if(p.type!=="success")return;let w=new URL(p.url),b=String(w.searchParams.get("cookie"));if(!b)return;o.setItem(r,h(b)),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":E(a)},s.body?.callbackURL&&s.body.callbackURL.startsWith("/")){let g=k.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 S from"expo-web-browser";import*as m from"expo-linking";import{Platform as k}from"react-native";import*as h 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 p(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 O=s=>{let r=null,c=`${s.storagePrefix||"better-auth"}_cookie`,n=`${s.storagePrefix||"better-auth"}_session_data`,o=s.storage||h,i=s.scheme||C.platform?.scheme,l=k.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(k.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=p(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,d=await S.openAuthSessionAsync(g,u);if(d.type!=="success")return;let b=new URL(d.url),f=String(b.searchParams.get("cookie"));if(!f)return;o.setItem(c,p(f)),r?.notify("$sessionSignal")}}},async init(t,e){if(l)return{url:t,options:e};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}}}]}};export{O as expoClient};
1
+ import*as b from"expo-web-browser";import*as m from"expo-linking";import{Platform as k}from"react-native";import*as h 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 p(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 A=s=>{let r=null,c=`${s?.storagePrefix||"better-auth"}_cookie`,n=`${s?.storagePrefix||"better-auth"}_session_data`,o=s?.storage||h,i=s?.scheme||C.platform?.scheme,l=k.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(k.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=p(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,d=await b.openAuthSessionAsync(g,u);if(d.type!=="success")return;let S=new URL(d.url),f=String(S.searchParams.get("cookie"));if(!f)return;o.setItem(c,p(f)),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{A as expoClient};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-auth/expo",
3
- "version": "0.7.3-beta.7",
3
+ "version": "0.7.3-beta.9",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -27,10 +27,10 @@
27
27
  "expo-secure-store": "~13.0.2",
28
28
  "expo-web-browser": "~13.0.3",
29
29
  "vitest": "^1.6.0",
30
- "better-auth": "0.7.3-beta.7"
30
+ "better-auth": "0.7.3-beta.9"
31
31
  },
32
32
  "peerDependencies": {
33
- "better-auth": "0.7.3-beta.7"
33
+ "better-auth": "0.7.3-beta.9"
34
34
  },
35
35
  "scripts": {
36
36
  "test": "vitest",
package/src/client.ts CHANGED
@@ -89,12 +89,12 @@ function getOrigin(scheme: string) {
89
89
  return schemeURI;
90
90
  }
91
91
 
92
- export const expoClient = (opts: ExpoClientOptions) => {
92
+ export const expoClient = (opts?: ExpoClientOptions) => {
93
93
  let store: Store | null = null;
94
- const cookieName = `${opts.storagePrefix || "better-auth"}_cookie`;
95
- const localCacheName = `${opts.storagePrefix || "better-auth"}_session_data`;
96
- const storage = opts.storage || SecureStore;
97
- const scheme = opts.scheme || Constants.platform?.scheme;
94
+ const cookieName = `${opts?.storagePrefix || "better-auth"}_cookie`;
95
+ const localCacheName = `${opts?.storagePrefix || "better-auth"}_session_data`;
96
+ const storage = opts?.storage || SecureStore;
97
+ const scheme = opts?.scheme || Constants.platform?.scheme;
98
98
  const isWeb = Platform.OS === "web";
99
99
  if (!scheme && !isWeb) {
100
100
  throw new Error(
@@ -131,7 +131,7 @@ export const expoClient = (opts: ExpoClientOptions) => {
131
131
 
132
132
  if (
133
133
  context.request.url.toString().includes("/get-session") &&
134
- !opts.disableCache
134
+ !opts?.disableCache
135
135
  ) {
136
136
  const data = context.data;
137
137
  storage.setItem(localCacheName, JSON.stringify(data));
@@ -158,7 +158,10 @@ export const expoClient = (opts: ExpoClientOptions) => {
158
158
  if (isWeb) {
159
159
  return {
160
160
  url,
161
- options,
161
+ options: {
162
+ ...options,
163
+ signal: new AbortController().signal,
164
+ },
162
165
  };
163
166
  }
164
167
  options = options || {};
@@ -189,7 +192,10 @@ export const expoClient = (opts: ExpoClientOptions) => {
189
192
  }
190
193
  return {
191
194
  url,
192
- options,
195
+ options: {
196
+ ...options,
197
+ signal: new AbortController().signal,
198
+ },
193
199
  };
194
200
  },
195
201
  },