@better-auth/expo 1.0.0-canary.8 → 1.0.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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @better-auth/expo@1.0.0-canary.8 build /home/runner/work/better-auth/better-auth/packages/expo
2
+ > @better-auth/expo@1.0.0 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,14 +10,14 @@
10
10
  CLI Cleaning output folder
11
11
  ESM Build start
12
12
  CJS Build start
13
- ESM dist/index.mjs 744.00 B
13
+ ESM dist/index.mjs 680.00 B
14
14
  ESM dist/client.mjs 2.38 KB
15
- ESM ⚡️ Build success in 18ms
16
- CJS dist/index.js 1.20 KB
15
+ ESM ⚡️ Build success in 22ms
16
+ CJS dist/index.js 1.13 KB
17
17
  CJS dist/client.js 3.02 KB
18
- CJS ⚡️ Build success in 19ms
18
+ CJS ⚡️ Build success in 24ms
19
19
  DTS Build start
20
- DTS ⚡️ Build success in 4235ms
20
+ DTS ⚡️ Build success in 4191ms
21
21
  DTS dist/index.d.mts 111.00 B
22
22
  DTS dist/client.d.mts 4.45 KB
23
23
  DTS dist/index.d.ts 111.00 B
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,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of g(e))!d.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){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.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});
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});
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){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.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};
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-auth/expo",
3
- "version": "1.0.0-canary.8",
3
+ "version": "1.0.0",
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": "1.0.0-canary.8"
31
+ "better-auth": "1.0.0"
32
32
  },
33
33
  "peerDependencies": {
34
- "better-auth": "1.0.0-canary.8"
34
+ "better-auth": "1.0.0"
35
35
  },
36
36
  "dependencies": {
37
37
  "better-call": "^0.2.14",
package/src/index.ts CHANGED
@@ -37,33 +37,28 @@ export const expo: () => BetterAuthPlugin = () => {
37
37
  return context.path?.startsWith("/callback");
38
38
  },
39
39
  handler: async (ctx) => {
40
- const response = ctx.context.returned as Response;
41
- if (response.status === 302) {
42
- const location = response.headers.get("location");
43
- if (!location) {
44
- return;
45
- }
46
- const trustedOrigins = ctx.context.trustedOrigins.filter(
47
- (origin) => !origin.startsWith("http"),
48
- );
49
- const isTrustedOrigin = trustedOrigins.some((origin) =>
50
- location?.startsWith(origin),
51
- );
52
- if (!isTrustedOrigin) {
53
- return;
54
- }
55
- const cookie = response.headers.get("set-cookie");
40
+ const headers = ctx.responseHeader;
56
41
 
57
- if (!cookie) {
58
- return;
59
- }
60
- const url = new URL(location);
61
- url.searchParams.set("cookie", cookie);
62
- response.headers.set("location", url.toString());
63
- return {
64
- response,
65
- };
42
+ const location = headers.get("location");
43
+ if (!location) {
44
+ return;
66
45
  }
46
+ const trustedOrigins = ctx.context.trustedOrigins.filter(
47
+ (origin) => !origin.startsWith("http"),
48
+ );
49
+ const isTrustedOrigin = trustedOrigins.some((origin) =>
50
+ location?.startsWith(origin),
51
+ );
52
+ if (!isTrustedOrigin) {
53
+ return;
54
+ }
55
+ const cookie = headers.get("set-cookie");
56
+ if (!cookie) {
57
+ return;
58
+ }
59
+ const url = new URL(location);
60
+ url.searchParams.set("cookie", cookie);
61
+ ctx.setHeader("location", url.toString());
67
62
  },
68
63
  },
69
64
  ],