@faire-auth/expo 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.
- package/LICENSE +661 -0
- package/README.md +95 -0
- package/dist/client.cjs +196 -0
- package/dist/client.d.cts +119 -0
- package/dist/client.d.mts +119 -0
- package/dist/client.mjs +167 -0
- package/dist/index.cjs +38 -0
- package/dist/index.d.cts +28 -0
- package/dist/index.d.mts +28 -0
- package/dist/index.mjs +37 -0
- package/package.json +84 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const require_client = require('./client.cjs');
|
|
2
|
+
let faire_auth_plugins = require("faire-auth/plugins");
|
|
3
|
+
|
|
4
|
+
//#region src/index.ts
|
|
5
|
+
const expo = (options) => {
|
|
6
|
+
return {
|
|
7
|
+
id: "expo",
|
|
8
|
+
init: (ctx) => {
|
|
9
|
+
return { options: { trustedOrigins: process.env.NODE_ENV === "development" ? ["exp://"] : [] } };
|
|
10
|
+
},
|
|
11
|
+
onRequest: (ctx) => {
|
|
12
|
+
if (!options?.overrideOrigin || ctx.req.header("origin")) return;
|
|
13
|
+
/**
|
|
14
|
+
* To bypass origin check from expo, we need to set the origin header to the expo-origin header
|
|
15
|
+
*/
|
|
16
|
+
const expoOrigin = ctx.req.header("expo-origin");
|
|
17
|
+
if (!expoOrigin) return;
|
|
18
|
+
ctx.req.raw.headers.set("origin", expoOrigin);
|
|
19
|
+
},
|
|
20
|
+
hooks: { after: [{
|
|
21
|
+
matcher: (ctx) => ctx.req.path.startsWith("/callback") || ctx.req.path.startsWith("/oauth2/callback"),
|
|
22
|
+
handler: (_authOptions) => (0, faire_auth_plugins.createHook)()(async (ctx) => {
|
|
23
|
+
const location = ctx.res.headers.get("location");
|
|
24
|
+
if (!location) return;
|
|
25
|
+
if (location.includes("/oauth-proxy-callback")) return;
|
|
26
|
+
if (![...ctx.get("context").trustedOrigins.values()].filter((origin) => !origin.startsWith("http")).some((origin) => location?.startsWith(origin))) return;
|
|
27
|
+
const cookie = ctx.res.headers.get("set-cookie");
|
|
28
|
+
if (!cookie) return;
|
|
29
|
+
const url = new URL(location);
|
|
30
|
+
url.searchParams.set("cookie", cookie);
|
|
31
|
+
ctx.header("location", url.toString());
|
|
32
|
+
})
|
|
33
|
+
}] }
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
exports.expo = expo;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as faire_auth0 from "faire-auth";
|
|
2
|
+
import * as _faire_auth_core_types0 from "@faire-auth/core/types";
|
|
3
|
+
import * as hono0 from "hono";
|
|
4
|
+
|
|
5
|
+
//#region src/index.d.ts
|
|
6
|
+
interface ExpoOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Override origin header for expo API routes
|
|
9
|
+
*/
|
|
10
|
+
overrideOrigin?: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare const expo: (options?: ExpoOptions) => {
|
|
13
|
+
id: "expo";
|
|
14
|
+
init: (ctx: _faire_auth_core_types0.AuthContext<faire_auth0.ContextVars<any>, _faire_auth_core_types0.FaireAuthOptions<faire_auth0.ContextVars<any>>>) => {
|
|
15
|
+
options: {
|
|
16
|
+
trustedOrigins: string[];
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
onRequest: (ctx: hono0.Context<faire_auth0.ContextVars<any>, any, {}>) => void;
|
|
20
|
+
hooks: {
|
|
21
|
+
after: {
|
|
22
|
+
matcher: (ctx: hono0.Context<faire_auth0.ContextVars<any>, any, {}>) => boolean;
|
|
23
|
+
handler: (_authOptions: _faire_auth_core_types0.FaireAuthOptions<any>) => (ctx: hono0.Context<faire_auth0.ContextVars<object>, string, {}>) => Promise<void>;
|
|
24
|
+
}[];
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
//#endregion
|
|
28
|
+
export { ExpoOptions, expo };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as faire_auth0 from "faire-auth";
|
|
2
|
+
import * as _faire_auth_core_types0 from "@faire-auth/core/types";
|
|
3
|
+
import * as hono0 from "hono";
|
|
4
|
+
|
|
5
|
+
//#region src/index.d.ts
|
|
6
|
+
interface ExpoOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Override origin header for expo API routes
|
|
9
|
+
*/
|
|
10
|
+
overrideOrigin?: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare const expo: (options?: ExpoOptions) => {
|
|
13
|
+
id: "expo";
|
|
14
|
+
init: (ctx: _faire_auth_core_types0.AuthContext<faire_auth0.ContextVars<any>, _faire_auth_core_types0.FaireAuthOptions<faire_auth0.ContextVars<any>>>) => {
|
|
15
|
+
options: {
|
|
16
|
+
trustedOrigins: string[];
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
onRequest: (ctx: hono0.Context<faire_auth0.ContextVars<any>, any, {}>) => void;
|
|
20
|
+
hooks: {
|
|
21
|
+
after: {
|
|
22
|
+
matcher: (ctx: hono0.Context<faire_auth0.ContextVars<any>, any, {}>) => boolean;
|
|
23
|
+
handler: (_authOptions: _faire_auth_core_types0.FaireAuthOptions<any>) => (ctx: hono0.Context<faire_auth0.ContextVars<object>, string, {}>) => Promise<void>;
|
|
24
|
+
}[];
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
//#endregion
|
|
28
|
+
export { ExpoOptions, expo };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createHook } from "faire-auth/plugins";
|
|
2
|
+
|
|
3
|
+
//#region src/index.ts
|
|
4
|
+
const expo = (options) => {
|
|
5
|
+
return {
|
|
6
|
+
id: "expo",
|
|
7
|
+
init: (ctx) => {
|
|
8
|
+
return { options: { trustedOrigins: process.env.NODE_ENV === "development" ? ["exp://"] : [] } };
|
|
9
|
+
},
|
|
10
|
+
onRequest: (ctx) => {
|
|
11
|
+
if (!options?.overrideOrigin || ctx.req.header("origin")) return;
|
|
12
|
+
/**
|
|
13
|
+
* To bypass origin check from expo, we need to set the origin header to the expo-origin header
|
|
14
|
+
*/
|
|
15
|
+
const expoOrigin = ctx.req.header("expo-origin");
|
|
16
|
+
if (!expoOrigin) return;
|
|
17
|
+
ctx.req.raw.headers.set("origin", expoOrigin);
|
|
18
|
+
},
|
|
19
|
+
hooks: { after: [{
|
|
20
|
+
matcher: (ctx) => ctx.req.path.startsWith("/callback") || ctx.req.path.startsWith("/oauth2/callback"),
|
|
21
|
+
handler: (_authOptions) => createHook()(async (ctx) => {
|
|
22
|
+
const location = ctx.res.headers.get("location");
|
|
23
|
+
if (!location) return;
|
|
24
|
+
if (location.includes("/oauth-proxy-callback")) return;
|
|
25
|
+
if (![...ctx.get("context").trustedOrigins.values()].filter((origin) => !origin.startsWith("http")).some((origin) => location?.startsWith(origin))) return;
|
|
26
|
+
const cookie = ctx.res.headers.get("set-cookie");
|
|
27
|
+
if (!cookie) return;
|
|
28
|
+
const url = new URL(location);
|
|
29
|
+
url.searchParams.set("cookie", cookie);
|
|
30
|
+
ctx.header("location", url.toString());
|
|
31
|
+
})
|
|
32
|
+
}] }
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { expo };
|
package/package.json
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@faire-auth/expo",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Faire Auth integration for Expo and React Native applications.",
|
|
6
|
+
"main": "dist/index.cjs",
|
|
7
|
+
"module": "dist/index.mjs",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/igoforth/faire-auth.git",
|
|
11
|
+
"directory": "packages/expo"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://www.faire-auth.com/docs/integrations/expo",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"dev-source": "./src/index.ts",
|
|
17
|
+
"import": {
|
|
18
|
+
"types": "./dist/index.d.mts",
|
|
19
|
+
"default": "./dist/index.mjs"
|
|
20
|
+
},
|
|
21
|
+
"require": {
|
|
22
|
+
"types": "./dist/index.d.cts",
|
|
23
|
+
"default": "./dist/index.cjs"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"./client": {
|
|
27
|
+
"dev-source": "./src/client.ts",
|
|
28
|
+
"import": {
|
|
29
|
+
"types": "./dist/client.d.mts",
|
|
30
|
+
"default": "./dist/client.mjs"
|
|
31
|
+
},
|
|
32
|
+
"require": {
|
|
33
|
+
"types": "./dist/client.d.cts",
|
|
34
|
+
"default": "./dist/client.cjs"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"keywords": [
|
|
39
|
+
"auth",
|
|
40
|
+
"expo",
|
|
41
|
+
"react-native",
|
|
42
|
+
"typescript",
|
|
43
|
+
"faire-auth"
|
|
44
|
+
],
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
},
|
|
48
|
+
"license": "MIT",
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@better-fetch/fetch": "^1.1.18",
|
|
51
|
+
"better-sqlite3": "^12.2.0",
|
|
52
|
+
"expo-constants": "~17.1.7",
|
|
53
|
+
"expo-crypto": "^13.0.2",
|
|
54
|
+
"expo-linking": "~7.1.7",
|
|
55
|
+
"expo-secure-store": "~14.2.3",
|
|
56
|
+
"expo-web-browser": "~14.2.0",
|
|
57
|
+
"publint": "^0.3.15",
|
|
58
|
+
"react-native": "^0.84.1",
|
|
59
|
+
"tsdown": "^0.16.0",
|
|
60
|
+
"faire-auth": "1.0.0"
|
|
61
|
+
},
|
|
62
|
+
"peerDependencies": {
|
|
63
|
+
"expo-constants": ">=17.0.0",
|
|
64
|
+
"expo-crypto": ">=13.0.0",
|
|
65
|
+
"expo-linking": ">=7.0.0",
|
|
66
|
+
"expo-secure-store": ">=14.0.0",
|
|
67
|
+
"expo-web-browser": ">=14.0.0",
|
|
68
|
+
"@faire-auth/core": "1.0.0",
|
|
69
|
+
"faire-auth": "1.0.0"
|
|
70
|
+
},
|
|
71
|
+
"dependencies": {
|
|
72
|
+
"@better-fetch/fetch": "^1.1.18",
|
|
73
|
+
"zod": "4.1.4"
|
|
74
|
+
},
|
|
75
|
+
"files": [
|
|
76
|
+
"dist"
|
|
77
|
+
],
|
|
78
|
+
"scripts": {
|
|
79
|
+
"test": "vitest",
|
|
80
|
+
"build": "tsdown",
|
|
81
|
+
"dev": "tsdown --watch",
|
|
82
|
+
"typecheck": "tsc --project tsconfig.json"
|
|
83
|
+
}
|
|
84
|
+
}
|