@better-auth/expo 1.1.9 → 1.1.10-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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @better-auth/expo@1.1.9 build /home/runner/work/better-auth/better-auth/packages/expo
2
+ > @better-auth/expo@1.1.10-beta.2 build /home/runner/work/better-auth/better-auth/packages/expo
3
3
  > tsup --dts --minify --clean
4
4
 
5
5
  CLI Building entry: {"index":"src/index.ts","client":"src/client.ts"}
@@ -10,15 +10,15 @@
10
10
  CLI Cleaning output folder
11
11
  ESM Build start
12
12
  CJS Build start
13
- ESM dist/index.mjs 680.00 B
14
- ESM dist/client.mjs 2.53 KB
15
- ESM ⚡️ Build success in 24ms
16
- CJS dist/index.js 1.13 KB
17
- CJS dist/client.js 3.17 KB
18
- CJS ⚡️ Build success in 24ms
13
+ CJS dist/index.js 1.17 KB
14
+ CJS dist/client.js 2.96 KB
15
+ CJS ⚡️ Build success in 21ms
16
+ ESM dist/index.mjs 720.00 B
17
+ ESM dist/client.mjs 2.32 KB
18
+ ESM ⚡️ Build success in 21ms
19
19
  DTS Build start
20
- DTS ⚡️ Build success in 4492ms
20
+ DTS ⚡️ Build success in 4814ms
21
21
  DTS dist/index.d.mts 111.00 B
22
- DTS dist/client.d.mts 4.48 KB
22
+ DTS dist/client.d.mts 4.45 KB
23
23
  DTS dist/index.d.ts 111.00 B
24
- DTS dist/client.d.ts 4.48 KB
24
+ DTS dist/client.d.ts 4.45 KB
package/dist/client.d.mts CHANGED
@@ -32,7 +32,6 @@ declare const expoClient: (opts: ExpoClientOptions) => {
32
32
  * });
33
33
  */
34
34
  getCookie: () => string;
35
- useSession: () => any;
36
35
  };
37
36
  fetchPlugins: {
38
37
  id: string;
package/dist/client.d.ts CHANGED
@@ -32,7 +32,6 @@ declare const expoClient: (opts: ExpoClientOptions) => {
32
32
  * });
33
33
  */
34
34
  getCookie: () => string;
35
- useSession: () => any;
36
35
  };
37
36
  fetchPlugins: {
38
37
  id: string;
package/dist/client.js CHANGED
@@ -1 +1 @@
1
- "use strict";var R=Object.create;var m=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var U=Object.getPrototypeOf,P=Object.prototype.hasOwnProperty;var N=(e,t)=>{for(var o in t)m(e,o,{get:t[o],enumerable:!0})},y=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of I(t))!P.call(e,s)&&s!==o&&m(e,s,{get:()=>t[s],enumerable:!(n=A(t,s))||n.enumerable});return e};var f=(e,t,o)=>(o=e!=null?R(U(e)):{},y(t||!e||!e.__esModule?m(o,"default",{value:e,enumerable:!0}):o,e)),v=e=>y(m({},"__esModule",{value:!0}),e);var J={};N(J,{expoClient:()=>D,getCookie:()=>k});module.exports=v(J);var x=f(require("expo-web-browser")),b=f(require("expo-linking")),p=require("react-native"),L=require("better-auth/react"),h=f(require("expo-constants"));function B(e){let t=new Map;return e.split(", ").forEach(n=>{let[s,...c]=n.split("; "),[l,u]=s.split("="),i={value:u};c.forEach(r=>{let[a,g]=r.split("=");i[a.toLowerCase()]=g}),t.set(l,i)}),t}function w(e){let t=B(e),o={};return t.forEach((n,s)=>{let c=n.expires,l=n["max-age"],u=c?new Date(String(c)):l?new Date(Date.now()+Number(l)):null;o[s]={value:n.value,expires:u}}),JSON.stringify(o)}function k(e){let t={};try{t=JSON.parse(e)}catch{}return Object.entries(t).reduce((n,[s,c])=>c.expires&&c.expires<new Date?n:`${n}; ${s}=${c.value}`,"")}function E(e){return b.createURL("",{scheme:e})}var D=e=>{let t=null,o=`${e?.storagePrefix||"better-auth"}_cookie`,n=`${e?.storagePrefix||"better-auth"}_session_data`,s=e?.storage,c=p.Platform.OS==="web",l=e?.scheme||h.default.expoConfig?.scheme||h.default.platform?.scheme,u=Array.isArray(l)?l[0]:l;if(!u&&!c)throw new Error("Scheme not found in app.json. Please provide a scheme in the options.");return{id:"expo",getActions(i,r){return{getCookie:()=>{let a=s.getItem(o);return k(a||"{}")},useSession:()=>{if(p.Platform.OS!=="web"&&!e.disableCache){t=r;let a=s.getItem(n);a&&r.atoms.session.set({data:JSON.parse(a),error:null,isPending:!1})}return(0,L.useStore)(r.atoms.session)}}},fetchPlugins:[{id:"expo",name:"Expo",hooks:{async onSuccess(i){if(c)return;let r=i.response.headers.get("set-cookie");if(r){let a=w(r||"");await s.setItem(o,a),t?.notify("$sessionSignal")}if(i.request.url.toString().includes("/get-session")&&!e?.disableCache){let a=i.data;s.setItem(n,JSON.stringify(a))}if(i.data?.redirect&&i.request.url.toString().includes("/sign-in")&&!i.request?.body.includes("idToken")){let g=JSON.parse(i.request.body)?.callbackURL,d=i.data?.url,S=await x.openAuthSessionAsync(d,g);if(S.type!=="success")return;let O=new URL(S.url),C=String(O.searchParams.get("cookie"));if(!C)return;s.setItem(o,w(C)),t?.notify("$sessionSignal")}}},async init(i,r){if(c)return{url:i,options:{...r,signal:new AbortController().signal}};r=r||{};let a=s.getItem(o),g=k(a||"{}");if(r.credentials="omit",r.headers={...r.headers,cookie:g,"expo-origin":E(u)},r.body?.callbackURL&&r.body.callbackURL.startsWith("/")){let d=b.createURL(r.body.callbackURL,{scheme:u});r.body.callbackURL=d}return i.includes("/sign-out")&&(await s.setItem(o,"{}"),t?.atoms.session?.set({data:null,error:null,isPending:!1}),s.setItem(n,"{}")),{url:i,options:{...r,signal:new AbortController().signal}}}}]}};0&&(module.exports={expoClient,getCookie});
1
+ "use strict";var R=Object.create;var m=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var U=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var P=(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 s of O(t))!I.call(e,s)&&s!==r&&m(e,s,{get:()=>t[s],enumerable:!(i=A(t,s))||i.enumerable});return e};var f=(e,t,r)=>(r=e!=null?R(U(e)):{},S(t||!e||!e.__esModule?m(r,"default",{value:e,enumerable:!0}):r,e)),N=e=>S(m({},"__esModule",{value:!0}),e);var $={};P($,{expoClient:()=>E,getCookie:()=>h});module.exports=N($);var w=f(require("expo-web-browser")),k=f(require("expo-linking")),x=require("react-native"),p=f(require("expo-constants"));function v(e){let t=new Map;return e.split(", ").forEach(i=>{let[s,...a]=i.split("; "),[l,u]=s.split("="),n={value:u};a.forEach(o=>{let[c,g]=o.split("=");n[c.toLowerCase()]=g}),t.set(l,n)}),t}function y(e){let t=v(e),r={};return t.forEach((i,s)=>{let a=i.expires,l=i["max-age"],u=a?new Date(String(a)):l?new Date(Date.now()+Number(l)):null;r[s]={value:i.value,expires:u}}),JSON.stringify(r)}function h(e){let t={};try{t=JSON.parse(e)}catch{}return Object.entries(t).reduce((i,[s,a])=>a.expires&&a.expires<new Date?i:`${i}; ${s}=${a.value}`,"")}function B(e){return k.createURL("",{scheme:e})}var E=e=>{let t=null,r=`${e?.storagePrefix||"better-auth"}_cookie`,i=`${e?.storagePrefix||"better-auth"}_session_data`,s=e?.storage,a=x.Platform.OS==="web",l=e?.scheme||p.default.expoConfig?.scheme||p.default.platform?.scheme,u=Array.isArray(l)?l[0]:l;if(!u&&!a)throw new Error("Scheme not found in app.json. Please provide a scheme in the options.");return{id:"expo",getActions(n,o){return t=o,{getCookie:()=>{let c=s.getItem(r);return h(c||"{}")}}},fetchPlugins:[{id:"expo",name:"Expo",hooks:{async onSuccess(n){if(a)return;let o=n.response.headers.get("set-cookie");if(o){let c=y(o||"");await s.setItem(r,c),t?.notify("$sessionSignal")}if(n.request.url.toString().includes("/get-session")&&!e?.disableCache){let c=n.data;s.setItem(i,JSON.stringify(c))}if(n.data?.redirect&&n.request.url.toString().includes("/sign-in")&&!n.request?.body.includes("idToken")){let g=JSON.parse(n.request.body)?.callbackURL,d=n.data?.url,b=await w.openAuthSessionAsync(d,g);if(b.type!=="success")return;let L=new URL(b.url),C=String(L.searchParams.get("cookie"));if(!C)return;s.setItem(r,y(C)),t?.notify("$sessionSignal")}}},async init(n,o){if(a)return{url:n,options:{...o,signal:new AbortController().signal}};o=o||{};let c=s.getItem(r),g=h(c||"{}");if(o.credentials="omit",o.headers={...o.headers,cookie:g,"expo-origin":B(u)},o.body?.callbackURL&&o.body.callbackURL.startsWith("/")){let d=k.createURL(o.body.callbackURL,{scheme:u});o.body.callbackURL=d}return n.includes("/sign-out")&&(await s.setItem(r,"{}"),t?.atoms.session?.set({data:null,error:null,isPending:!1}),s.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 C from"expo-web-browser";import*as d from"expo-linking";import{Platform as h}from"react-native";import{useStore as w}from"better-auth/react";import k from"expo-constants";function x(s){let o=new Map;return s.split(", ").forEach(n=>{let[r,...a]=n.split("; "),[l,u]=r.split("="),t={value:u};a.forEach(e=>{let[i,g]=e.split("=");t[i.toLowerCase()]=g}),o.set(l,t)}),o}function b(s){let o=x(s),c={};return o.forEach((n,r)=>{let a=n.expires,l=n["max-age"],u=a?new Date(String(a)):l?new Date(Date.now()+Number(l)):null;c[r]={value:n.value,expires:u}}),JSON.stringify(c)}function S(s){let o={};try{o=JSON.parse(s)}catch{}return Object.entries(o).reduce((n,[r,a])=>a.expires&&a.expires<new Date?n:`${n}; ${r}=${a.value}`,"")}function L(s){return d.createURL("",{scheme:s})}var I=s=>{let o=null,c=`${s?.storagePrefix||"better-auth"}_cookie`,n=`${s?.storagePrefix||"better-auth"}_session_data`,r=s?.storage,a=h.OS==="web",l=s?.scheme||k.expoConfig?.scheme||k.platform?.scheme,u=Array.isArray(l)?l[0]:l;if(!u&&!a)throw new Error("Scheme not found in app.json. Please provide a scheme in the options.");return{id:"expo",getActions(t,e){return{getCookie:()=>{let i=r.getItem(c);return S(i||"{}")},useSession:()=>{if(h.OS!=="web"&&!s.disableCache){o=e;let i=r.getItem(n);i&&e.atoms.session.set({data:JSON.parse(i),error:null,isPending:!1})}return w(e.atoms.session)}}},fetchPlugins:[{id:"expo",name:"Expo",hooks:{async onSuccess(t){if(a)return;let e=t.response.headers.get("set-cookie");if(e){let i=b(e||"");await r.setItem(c,i),o?.notify("$sessionSignal")}if(t.request.url.toString().includes("/get-session")&&!s?.disableCache){let i=t.data;r.setItem(n,JSON.stringify(i))}if(t.data?.redirect&&t.request.url.toString().includes("/sign-in")&&!t.request?.body.includes("idToken")){let g=JSON.parse(t.request.body)?.callbackURL,m=t.data?.url,f=await C.openAuthSessionAsync(m,g);if(f.type!=="success")return;let y=new URL(f.url),p=String(y.searchParams.get("cookie"));if(!p)return;r.setItem(c,b(p)),o?.notify("$sessionSignal")}}},async init(t,e){if(a)return{url:t,options:{...e,signal:new AbortController().signal}};e=e||{};let i=r.getItem(c),g=S(i||"{}");if(e.credentials="omit",e.headers={...e.headers,cookie:g,"expo-origin":L(u)},e.body?.callbackURL&&e.body.callbackURL.startsWith("/")){let m=d.createURL(e.body.callbackURL,{scheme:u});e.body.callbackURL=m}return t.includes("/sign-out")&&(await r.setItem(c,"{}"),o?.atoms.session?.set({data:null,error:null,isPending:!1}),r.setItem(n,"{}")),{url:t,options:{...e,signal:new AbortController().signal}}}}]}};export{I as expoClient,S as getCookie};
1
+ import*as C from"expo-web-browser";import*as d from"expo-linking";import{Platform as y}from"react-native";import h from"expo-constants";function w(r){let s=new Map;return r.split(", ").forEach(n=>{let[o,...i]=n.split("; "),[l,u]=o.split("="),t={value:u};i.forEach(e=>{let[c,g]=e.split("=");t[c.toLowerCase()]=g}),s.set(l,t)}),s}function k(r){let s=w(r),a={};return s.forEach((n,o)=>{let i=n.expires,l=n["max-age"],u=i?new Date(String(i)):l?new Date(Date.now()+Number(l)):null;a[o]={value:n.value,expires:u}}),JSON.stringify(a)}function b(r){let s={};try{s=JSON.parse(r)}catch{}return Object.entries(s).reduce((n,[o,i])=>i.expires&&i.expires<new Date?n:`${n}; ${o}=${i.value}`,"")}function x(r){return d.createURL("",{scheme:r})}var A=r=>{let s=null,a=`${r?.storagePrefix||"better-auth"}_cookie`,n=`${r?.storagePrefix||"better-auth"}_session_data`,o=r?.storage,i=y.OS==="web",l=r?.scheme||h.expoConfig?.scheme||h.platform?.scheme,u=Array.isArray(l)?l[0]:l;if(!u&&!i)throw new Error("Scheme not found in app.json. Please provide a scheme in the options.");return{id:"expo",getActions(t,e){return s=e,{getCookie:()=>{let c=o.getItem(a);return b(c||"{}")}}},fetchPlugins:[{id:"expo",name:"Expo",hooks:{async onSuccess(t){if(i)return;let e=t.response.headers.get("set-cookie");if(e){let c=k(e||"");await o.setItem(a,c),s?.notify("$sessionSignal")}if(t.request.url.toString().includes("/get-session")&&!r?.disableCache){let c=t.data;o.setItem(n,JSON.stringify(c))}if(t.data?.redirect&&t.request.url.toString().includes("/sign-in")&&!t.request?.body.includes("idToken")){let g=JSON.parse(t.request.body)?.callbackURL,m=t.data?.url,f=await C.openAuthSessionAsync(m,g);if(f.type!=="success")return;let S=new URL(f.url),p=String(S.searchParams.get("cookie"));if(!p)return;o.setItem(a,k(p)),s?.notify("$sessionSignal")}}},async init(t,e){if(i)return{url:t,options:{...e,signal:new AbortController().signal}};e=e||{};let c=o.getItem(a),g=b(c||"{}");if(e.credentials="omit",e.headers={...e.headers,cookie:g,"expo-origin":x(u)},e.body?.callbackURL&&e.body.callbackURL.startsWith("/")){let m=d.createURL(e.body.callbackURL,{scheme:u});e.body.callbackURL=m}return t.includes("/sign-out")&&(await o.setItem(a,"{}"),s?.atoms.session?.set({data:null,error:null,isPending:!1}),o.setItem(n,"{}")),{url:t,options:{...e,signal:new AbortController().signal}}}}]}};export{A as expoClient,b as getCookie};
package/dist/index.js CHANGED
@@ -1 +1 @@
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,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of g(e))!d.call(t,i)&&i!==r&&o(t,i,{get:()=>e[i],enumerable:!(s=c(e,i))||s.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.responseHeader,r=e.get("location");if(!r||!t.context.trustedOrigins.filter(n=>!n.startsWith("http")).some(n=>r?.startsWith(n)))return;let a=e.get("set-cookie");if(!a)return;let u=new URL(r);u.searchParams.set("cookie",a),t.setHeader("location",u.toString())}}]}});0&&(module.exports={expo});
1
+ "use strict";var o=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var d=(t,e)=>{for(var r in e)o(t,r,{get:e[r],enumerable:!0})},p=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of g(e))!h.call(t,i)&&i!==r&&o(t,i,{get:()=>e[i],enumerable:!(s=c(e,i))||s.enumerable});return t};var l=t=>p(o({},"__esModule",{value:!0}),t);var f={};d(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")||t.path?.startsWith("/oauth2/callback")},handler:async t=>{let e=t.responseHeader,r=e.get("location");if(!r||!t.context.trustedOrigins.filter(n=>!n.startsWith("http")).some(n=>r?.startsWith(n)))return;let a=e.get("set-cookie");if(!a)return;let u=new URL(r);u.searchParams.set("cookie",a),t.setHeader("location",u.toString())}}]}});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,r){if(t.headers.get("origin"))return;let e=t.headers.get("expo-origin");if(e)return t.headers.set("origin",e),{request:t}},hooks:{after:[{matcher(t){return t.path?.startsWith("/callback")},handler:async t=>{let r=t.responseHeader,e=r.get("location");if(!e||!t.context.trustedOrigins.filter(i=>!i.startsWith("http")).some(i=>e?.startsWith(i)))return;let s=r.get("set-cookie");if(!s)return;let n=new URL(e);n.searchParams.set("cookie",s),t.setHeader("location",n.toString())}}]}});export{u as expo};
1
+ var u=()=>({id:"expo",init:t=>({options:{trustedOrigins:process.env.NODE_ENV==="development"?[...t.options.trustedOrigins||[],"exp://"]:t.options.trustedOrigins}}),async onRequest(t,r){if(t.headers.get("origin"))return;let e=t.headers.get("expo-origin");if(e)return t.headers.set("origin",e),{request:t}},hooks:{after:[{matcher(t){return t.path?.startsWith("/callback")||t.path?.startsWith("/oauth2/callback")},handler:async t=>{let r=t.responseHeader,e=r.get("location");if(!e||!t.context.trustedOrigins.filter(i=>!i.startsWith("http")).some(i=>e?.startsWith(i)))return;let s=r.get("set-cookie");if(!s)return;let n=new URL(e);n.searchParams.set("cookie",s),t.setHeader("location",n.toString())}}]}});export{u as expo};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-auth/expo",
3
- "version": "1.1.9",
3
+ "version": "1.1.10-beta.2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -38,10 +38,10 @@
38
38
  "expo-secure-store": "~13.0.2",
39
39
  "expo-web-browser": "~13.0.3",
40
40
  "vitest": "^1.6.0",
41
- "better-auth": "1.1.9"
41
+ "better-auth": "1.1.10-beta.2"
42
42
  },
43
43
  "peerDependencies": {
44
- "better-auth": "1.1.9"
44
+ "better-auth": "1.1.10-beta.2"
45
45
  },
46
46
  "dependencies": {
47
47
  "better-call": "^0.3.3",
package/src/client.ts CHANGED
@@ -2,7 +2,6 @@ import type { BetterAuthClientPlugin, Store } from "better-auth";
2
2
  import * as Browser from "expo-web-browser";
3
3
  import * as Linking from "expo-linking";
4
4
  import { Platform } from "react-native";
5
- import { useStore } from "better-auth/react";
6
5
  import Constants from "expo-constants";
7
6
  import type { BetterFetchOption } from "@better-fetch/fetch";
8
7
 
@@ -109,6 +108,7 @@ export const expoClient = (opts: ExpoClientOptions) => {
109
108
  return {
110
109
  id: "expo",
111
110
  getActions(_, $store) {
111
+ store = $store;
112
112
  return {
113
113
  /**
114
114
  * Get the stored cookie.
@@ -129,19 +129,6 @@ export const expoClient = (opts: ExpoClientOptions) => {
129
129
  const cookie = storage.getItem(cookieName);
130
130
  return getCookie(cookie || "{}");
131
131
  },
132
- useSession: () => {
133
- if (Platform.OS !== "web" && !opts.disableCache) {
134
- store = $store;
135
- const localSession = storage.getItem(localCacheName);
136
- localSession &&
137
- $store.atoms.session.set({
138
- data: JSON.parse(localSession),
139
- error: null,
140
- isPending: false,
141
- });
142
- }
143
- return useStore($store.atoms.session);
144
- },
145
132
  };
146
133
  },
147
134
  fetchPlugins: [
package/src/index.ts CHANGED
@@ -34,7 +34,10 @@ export const expo: () => BetterAuthPlugin = () => {
34
34
  after: [
35
35
  {
36
36
  matcher(context) {
37
- return context.path?.startsWith("/callback");
37
+ return (
38
+ context.path?.startsWith("/callback") ||
39
+ context.path?.startsWith("/oauth2/callback")
40
+ );
38
41
  },
39
42
  handler: async (ctx) => {
40
43
  const headers = ctx.responseHeader;