@better-auth/expo 1.1.14 → 1.1.15-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.14 build /home/runner/work/better-auth/better-auth/packages/expo
2
+ > @better-auth/expo@1.1.15-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
- CJS dist/index.js 1.17 KB
14
- CJS dist/client.js 3.26 KB
15
- CJS ⚡️ Build success in 22ms
16
- ESM dist/index.mjs 720.00 B
17
13
  ESM dist/client.mjs 2.63 KB
18
- ESM ⚡️ Build success in 22ms
14
+ ESM dist/index.mjs 763.00 B
15
+ ESM ⚡️ Build success in 21ms
16
+ CJS dist/client.js 3.26 KB
17
+ CJS dist/index.js 1.21 KB
18
+ CJS ⚡️ Build success in 20ms
19
19
  DTS Build start
20
- DTS ⚡️ Build success in 4549ms
21
- DTS dist/index.d.mts 111.00 B
20
+ DTS ⚡️ Build success in 4744ms
21
+ DTS dist/index.d.mts 917.00 B
22
22
  DTS dist/client.d.mts 4.45 KB
23
- DTS dist/index.d.ts 111.00 B
23
+ DTS dist/index.d.ts 917.00 B
24
24
  DTS dist/client.d.ts 4.45 KB
package/dist/index.d.mts CHANGED
@@ -1,5 +1,31 @@
1
- import { BetterAuthPlugin } from 'better-auth';
1
+ import * as better_call from 'better-call';
2
+ import * as better_auth from 'better-auth';
2
3
 
3
- declare const expo: () => BetterAuthPlugin;
4
+ interface ExpoOptions {
5
+ /**
6
+ * Override origin header for expo api routes
7
+ */
8
+ overrideOrigin?: boolean;
9
+ }
10
+ declare const expo: (options?: ExpoOptions) => {
11
+ id: "expo";
12
+ init: (ctx: better_auth.AuthContext) => {
13
+ options: {
14
+ trustedOrigins: string[] | undefined;
15
+ };
16
+ };
17
+ onRequest(request: Request, ctx: better_auth.AuthContext): Promise<{
18
+ request: Request;
19
+ } | undefined>;
20
+ hooks: {
21
+ after: {
22
+ matcher(context: better_auth.HookEndpointContext<{
23
+ returned: better_call.APIError | Response | Record<string, any>;
24
+ endpoint: better_call.Endpoint;
25
+ }>): boolean;
26
+ handler: (ctx: better_auth.HookEndpointContext<{}>) => Promise<void>;
27
+ }[];
28
+ };
29
+ };
4
30
 
5
- export { expo };
31
+ export { type ExpoOptions, expo };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,31 @@
1
- import { BetterAuthPlugin } from 'better-auth';
1
+ import * as better_call from 'better-call';
2
+ import * as better_auth from 'better-auth';
2
3
 
3
- declare const expo: () => BetterAuthPlugin;
4
+ interface ExpoOptions {
5
+ /**
6
+ * Override origin header for expo api routes
7
+ */
8
+ overrideOrigin?: boolean;
9
+ }
10
+ declare const expo: (options?: ExpoOptions) => {
11
+ id: "expo";
12
+ init: (ctx: better_auth.AuthContext) => {
13
+ options: {
14
+ trustedOrigins: string[] | undefined;
15
+ };
16
+ };
17
+ onRequest(request: Request, ctx: better_auth.AuthContext): Promise<{
18
+ request: Request;
19
+ } | undefined>;
20
+ hooks: {
21
+ after: {
22
+ matcher(context: better_auth.HookEndpointContext<{
23
+ returned: better_call.APIError | Response | Record<string, any>;
24
+ endpoint: better_call.Endpoint;
25
+ }>): boolean;
26
+ handler: (ctx: better_auth.HookEndpointContext<{}>) => Promise<void>;
27
+ }[];
28
+ };
29
+ };
4
30
 
5
- export { expo };
31
+ export { type ExpoOptions, expo };
package/dist/index.js CHANGED
@@ -1 +1 @@
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});
1
+ "use strict";var o=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var d=(e,t)=>{for(var r in t)o(e,r,{get:t[r],enumerable:!0})},h=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of g(t))!p.call(e,s)&&s!==r&&o(e,s,{get:()=>t[s],enumerable:!(i=u(t,s))||i.enumerable});return e};var l=e=>h(o({},"__esModule",{value:!0}),e);var f={};d(f,{expo:()=>O});module.exports=l(f);var O=e=>({id:"expo",init:t=>({options:{trustedOrigins:process.env.NODE_ENV==="development"?[...t.options.trustedOrigins||[],"exp://"]:t.options.trustedOrigins}}),async onRequest(t,r){if(!e?.overrideOrigin||t.headers.get("origin"))return;let i=t.headers.get("expo-origin");if(!i)return;let s=t.clone();return s.headers.set("origin",i),{request:s}},hooks:{after:[{matcher(t){return t.path?.startsWith("/callback")||t.path?.startsWith("/oauth2/callback")},handler:async t=>{let r=t.responseHeader,i=r.get("location");if(!i||!t.context.trustedOrigins.filter(n=>!n.startsWith("http")).some(n=>i?.startsWith(n)))return;let a=r.get("set-cookie");if(!a)return;let c=new URL(i);c.searchParams.set("cookie",a),t.setHeader("location",c.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")||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};
1
+ var u=a=>({id:"expo",init:t=>({options:{trustedOrigins:process.env.NODE_ENV==="development"?[...t.options.trustedOrigins||[],"exp://"]:t.options.trustedOrigins}}),async onRequest(t,r){if(!a?.overrideOrigin||t.headers.get("origin"))return;let e=t.headers.get("expo-origin");if(!e)return;let i=t.clone();return i.headers.set("origin",e),{request:i}},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(s=>!s.startsWith("http")).some(s=>e?.startsWith(s)))return;let n=r.get("set-cookie");if(!n)return;let o=new URL(e);o.searchParams.set("cookie",n),t.setHeader("location",o.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.14",
3
+ "version": "1.1.15-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.14"
41
+ "better-auth": "1.1.15-beta.2"
42
42
  },
43
43
  "peerDependencies": {
44
- "better-auth": "1.1.14"
44
+ "better-auth": "1.1.15-beta.2"
45
45
  },
46
46
  "dependencies": {
47
47
  "better-call": "^0.3.3",
package/src/index.ts CHANGED
@@ -1,6 +1,13 @@
1
1
  import type { BetterAuthPlugin } from "better-auth";
2
2
 
3
- export const expo: () => BetterAuthPlugin = () => {
3
+ export interface ExpoOptions {
4
+ /**
5
+ * Override origin header for expo api routes
6
+ */
7
+ overrideOrigin?: boolean;
8
+ }
9
+
10
+ export const expo = (options?: ExpoOptions) => {
4
11
  return {
5
12
  id: "expo",
6
13
  init: (ctx) => {
@@ -15,7 +22,7 @@ export const expo: () => BetterAuthPlugin = () => {
15
22
  };
16
23
  },
17
24
  async onRequest(request, ctx) {
18
- if (request.headers.get("origin")) {
25
+ if (!options?.overrideOrigin || request.headers.get("origin")) {
19
26
  return;
20
27
  }
21
28
  /**
@@ -25,9 +32,10 @@ export const expo: () => BetterAuthPlugin = () => {
25
32
  if (!expoOrigin) {
26
33
  return;
27
34
  }
28
- request.headers.set("origin", expoOrigin);
35
+ const req = request.clone();
36
+ req.headers.set("origin", expoOrigin);
29
37
  return {
30
- request,
38
+ request: req,
31
39
  };
32
40
  },
33
41
  hooks: {
@@ -66,5 +74,5 @@ export const expo: () => BetterAuthPlugin = () => {
66
74
  },
67
75
  ],
68
76
  },
69
- };
77
+ } satisfies BetterAuthPlugin;
70
78
  };