@better-auth/expo 0.7.3-beta.8 → 0.7.3
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 +3 -55
- package/dist/client.d.ts +3 -55
- 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 +4 -3
- package/src/client.ts +15 -8
- package/src/index.ts +0 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @better-auth/expo@0.7.3-beta.
|
|
3
|
+
> @better-auth/expo@0.7.3-beta.11 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.
|
|
15
|
-
[32mCJS[39m [1mdist/client.js [22m[32m2.
|
|
16
|
-
[32mCJS[39m ⚡️ Build success in
|
|
17
|
-
[32mESM[39m [1mdist/index.mjs [22m[
|
|
18
|
-
[32mESM[39m [1mdist/client.mjs [22m[32m2.
|
|
19
|
-
[32mESM[39m ⚡️ Build success in
|
|
14
|
+
[32mCJS[39m [1mdist/index.js [22m[32m1.16 KB[39m
|
|
15
|
+
[32mCJS[39m [1mdist/client.js [22m[32m2.95 KB[39m
|
|
16
|
+
[32mCJS[39m ⚡️ Build success in 22ms
|
|
17
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m710.00 B[39m
|
|
18
|
+
[32mESM[39m [1mdist/client.mjs [22m[32m2.32 KB[39m
|
|
19
|
+
[32mESM[39m ⚡️ Build success in 22ms
|
|
20
20
|
DTS Build start
|
|
21
|
-
DTS ⚡️ Build success in
|
|
21
|
+
DTS ⚡️ Build success in 3693ms
|
|
22
22
|
DTS dist/index.d.mts 677.00 B
|
|
23
|
-
DTS dist/client.d.mts
|
|
23
|
+
DTS dist/client.d.mts 3.96 KB
|
|
24
24
|
DTS dist/index.d.ts 677.00 B
|
|
25
|
-
DTS dist/client.d.ts
|
|
25
|
+
DTS dist/client.d.ts 3.96 KB
|
package/dist/client.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as zod from 'zod';
|
|
2
2
|
import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
3
|
+
import { BetterFetchOption } from '@better-fetch/fetch';
|
|
3
4
|
import { Store } from 'better-auth';
|
|
4
5
|
|
|
5
6
|
interface ExpoClientOptions {
|
|
@@ -11,7 +12,7 @@ interface ExpoClientOptions {
|
|
|
11
12
|
storagePrefix?: string;
|
|
12
13
|
disableCache?: boolean;
|
|
13
14
|
}
|
|
14
|
-
declare const expoClient: (opts
|
|
15
|
+
declare const expoClient: (opts?: ExpoClientOptions) => {
|
|
15
16
|
id: "expo";
|
|
16
17
|
getActions(_: _better_fetch_fetch.BetterFetch, $store: Store): {};
|
|
17
18
|
fetchPlugins: {
|
|
@@ -75,60 +76,7 @@ declare const expoClient: (opts: ExpoClientOptions) => {
|
|
|
75
76
|
disableValidation?: boolean | undefined;
|
|
76
77
|
} | undefined): Promise<{
|
|
77
78
|
url: string;
|
|
78
|
-
options:
|
|
79
|
-
cache?: RequestCache | undefined;
|
|
80
|
-
credentials?: RequestCredentials | undefined;
|
|
81
|
-
headers?: (HeadersInit & (HeadersInit | {
|
|
82
|
-
accept: "application/json" | "text/plain" | "application/octet-stream";
|
|
83
|
-
"content-type": "application/json" | "text/plain" | "application/x-www-form-urlencoded" | "multipart/form-data" | "application/octet-stream";
|
|
84
|
-
authorization: "Bearer" | "Basic";
|
|
85
|
-
})) | 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;
|
|
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;
|
|
101
|
-
hookOptions?: {
|
|
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?: ({
|
|
110
|
-
type: "Bearer";
|
|
111
|
-
token: string | (() => string | undefined) | undefined;
|
|
112
|
-
} | {
|
|
113
|
-
type: "Basic";
|
|
114
|
-
username: string | (() => string | undefined) | undefined;
|
|
115
|
-
password: string | (() => string | undefined) | undefined;
|
|
116
|
-
} | {
|
|
117
|
-
type: "Custom";
|
|
118
|
-
prefix: string | (() => string | undefined) | undefined;
|
|
119
|
-
value: string | (() => string | undefined) | undefined;
|
|
120
|
-
}) | undefined;
|
|
121
|
-
body?: any;
|
|
122
|
-
query?: any;
|
|
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;
|
|
79
|
+
options: BetterFetchOption;
|
|
132
80
|
}>;
|
|
133
81
|
}[];
|
|
134
82
|
};
|
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as zod from 'zod';
|
|
2
2
|
import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
3
|
+
import { BetterFetchOption } from '@better-fetch/fetch';
|
|
3
4
|
import { Store } from 'better-auth';
|
|
4
5
|
|
|
5
6
|
interface ExpoClientOptions {
|
|
@@ -11,7 +12,7 @@ interface ExpoClientOptions {
|
|
|
11
12
|
storagePrefix?: string;
|
|
12
13
|
disableCache?: boolean;
|
|
13
14
|
}
|
|
14
|
-
declare const expoClient: (opts
|
|
15
|
+
declare const expoClient: (opts?: ExpoClientOptions) => {
|
|
15
16
|
id: "expo";
|
|
16
17
|
getActions(_: _better_fetch_fetch.BetterFetch, $store: Store): {};
|
|
17
18
|
fetchPlugins: {
|
|
@@ -75,60 +76,7 @@ declare const expoClient: (opts: ExpoClientOptions) => {
|
|
|
75
76
|
disableValidation?: boolean | undefined;
|
|
76
77
|
} | undefined): Promise<{
|
|
77
78
|
url: string;
|
|
78
|
-
options:
|
|
79
|
-
cache?: RequestCache | undefined;
|
|
80
|
-
credentials?: RequestCredentials | undefined;
|
|
81
|
-
headers?: (HeadersInit & (HeadersInit | {
|
|
82
|
-
accept: "application/json" | "text/plain" | "application/octet-stream";
|
|
83
|
-
"content-type": "application/json" | "text/plain" | "application/x-www-form-urlencoded" | "multipart/form-data" | "application/octet-stream";
|
|
84
|
-
authorization: "Bearer" | "Basic";
|
|
85
|
-
})) | 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;
|
|
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;
|
|
101
|
-
hookOptions?: {
|
|
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?: ({
|
|
110
|
-
type: "Bearer";
|
|
111
|
-
token: string | (() => string | undefined) | undefined;
|
|
112
|
-
} | {
|
|
113
|
-
type: "Basic";
|
|
114
|
-
username: string | (() => string | undefined) | undefined;
|
|
115
|
-
password: string | (() => string | undefined) | undefined;
|
|
116
|
-
} | {
|
|
117
|
-
type: "Custom";
|
|
118
|
-
prefix: string | (() => string | undefined) | undefined;
|
|
119
|
-
value: string | (() => string | undefined) | undefined;
|
|
120
|
-
}) | undefined;
|
|
121
|
-
body?: any;
|
|
122
|
-
query?: any;
|
|
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;
|
|
79
|
+
options: BetterFetchOption;
|
|
132
80
|
}>;
|
|
133
81
|
}[];
|
|
134
82
|
};
|
package/dist/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var x=Object.create;var m=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;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
|
|
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 d=Object.getOwnPropertyNames;var g=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 d(e))!g.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){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 u=()=>({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;
|
|
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){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.7.3
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"author": "",
|
|
21
21
|
"license": "ISC",
|
|
22
22
|
"devDependencies": {
|
|
23
|
+
"@better-fetch/fetch": "1.1.12",
|
|
23
24
|
"better-sqlite3": "^11.5.0",
|
|
24
25
|
"expo-constants": "~16.0.2",
|
|
25
26
|
"expo-crypto": "^13.0.2",
|
|
@@ -27,10 +28,10 @@
|
|
|
27
28
|
"expo-secure-store": "~13.0.2",
|
|
28
29
|
"expo-web-browser": "~13.0.3",
|
|
29
30
|
"vitest": "^1.6.0",
|
|
30
|
-
"better-auth": "0.7.3
|
|
31
|
+
"better-auth": "0.7.3"
|
|
31
32
|
},
|
|
32
33
|
"peerDependencies": {
|
|
33
|
-
"better-auth": "0.7.3
|
|
34
|
+
"better-auth": "0.7.3"
|
|
34
35
|
},
|
|
35
36
|
"scripts": {
|
|
36
37
|
"test": "vitest",
|
package/src/client.ts
CHANGED
|
@@ -4,6 +4,7 @@ import * as Linking from "expo-linking";
|
|
|
4
4
|
import { Platform } from "react-native";
|
|
5
5
|
import * as SecureStore from "expo-secure-store";
|
|
6
6
|
import Constants from "expo-constants";
|
|
7
|
+
import type { BetterFetchOption } from "@better-fetch/fetch";
|
|
7
8
|
|
|
8
9
|
interface CookieAttributes {
|
|
9
10
|
value: string;
|
|
@@ -89,12 +90,12 @@ function getOrigin(scheme: string) {
|
|
|
89
90
|
return schemeURI;
|
|
90
91
|
}
|
|
91
92
|
|
|
92
|
-
export const expoClient = (opts
|
|
93
|
+
export const expoClient = (opts?: ExpoClientOptions) => {
|
|
93
94
|
let store: Store | null = null;
|
|
94
|
-
const cookieName = `${opts
|
|
95
|
-
const localCacheName = `${opts
|
|
96
|
-
const storage = opts
|
|
97
|
-
const scheme = opts
|
|
95
|
+
const cookieName = `${opts?.storagePrefix || "better-auth"}_cookie`;
|
|
96
|
+
const localCacheName = `${opts?.storagePrefix || "better-auth"}_session_data`;
|
|
97
|
+
const storage = opts?.storage || SecureStore;
|
|
98
|
+
const scheme = opts?.scheme || Constants.platform?.scheme;
|
|
98
99
|
const isWeb = Platform.OS === "web";
|
|
99
100
|
if (!scheme && !isWeb) {
|
|
100
101
|
throw new Error(
|
|
@@ -131,7 +132,7 @@ export const expoClient = (opts: ExpoClientOptions) => {
|
|
|
131
132
|
|
|
132
133
|
if (
|
|
133
134
|
context.request.url.toString().includes("/get-session") &&
|
|
134
|
-
!opts
|
|
135
|
+
!opts?.disableCache
|
|
135
136
|
) {
|
|
136
137
|
const data = context.data;
|
|
137
138
|
storage.setItem(localCacheName, JSON.stringify(data));
|
|
@@ -158,7 +159,10 @@ export const expoClient = (opts: ExpoClientOptions) => {
|
|
|
158
159
|
if (isWeb) {
|
|
159
160
|
return {
|
|
160
161
|
url,
|
|
161
|
-
options
|
|
162
|
+
options: {
|
|
163
|
+
...options,
|
|
164
|
+
signal: new AbortController().signal,
|
|
165
|
+
} as BetterFetchOption,
|
|
162
166
|
};
|
|
163
167
|
}
|
|
164
168
|
options = options || {};
|
|
@@ -189,7 +193,10 @@ export const expoClient = (opts: ExpoClientOptions) => {
|
|
|
189
193
|
}
|
|
190
194
|
return {
|
|
191
195
|
url,
|
|
192
|
-
options
|
|
196
|
+
options: {
|
|
197
|
+
...options,
|
|
198
|
+
signal: new AbortController().signal,
|
|
199
|
+
} as BetterFetchOption,
|
|
193
200
|
};
|
|
194
201
|
},
|
|
195
202
|
},
|