-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (93 loc) · 4.68 KB
/
Copy pathcompatibility.yml
File metadata and controls
111 lines (93 loc) · 4.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: compatibility
on:
pull_request:
push:
branches: ["**"]
schedule:
- cron: "0 6 * * 1"
jobs:
adapters-latest:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Install and build package
run: |
pnpm install --frozen-lockfile
pnpm build
- name: Pack local package
run: |
mkdir -p /tmp/agecheck-pack
pnpm pack --pack-destination /tmp/agecheck-pack
ls -la /tmp/agecheck-pack
- name: Validate adapter compatibility against latest frameworks
shell: bash
run: |
set -euo pipefail
PKG_TGZ="$(ls /tmp/agecheck-pack/*.tgz | head -n1)"
check_project() {
local name="$1"
local deps_json="$2"
local code="$3"
local dir
dir="$(mktemp -d)"
cat > "${dir}/package.json" <<JSON
{
"name": "compat-${name}",
"private": true,
"type": "module",
"scripts": {
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@agecheck/node": "file:${PKG_TGZ}",
${deps_json}
},
"devDependencies": {
"typescript": "^5.9.2",
"@types/node": "^24.5.2"
}
}
JSON
cat > "${dir}/tsconfig.json" <<'JSON'
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"strict": true,
"skipLibCheck": true,
"exactOptionalPropertyTypes": true,
"noUncheckedIndexedAccess": true,
"types": ["node"]
},
"include": ["index.ts"]
}
JSON
printf "%b\n" "$code" > "${dir}/index.ts"
pnpm --dir "${dir}" install --no-frozen-lockfile
pnpm --dir "${dir}" typecheck
}
check_project \
"express" \
'"express": "latest", "@types/express": "latest"' \
'import express from "express";\nimport { AgeCheckSdk, createExpressGateMiddleware, createExpressVerifyHandler } from "@agecheck/node";\nconst app = express();\nconst sdk = new AgeCheckSdk({ deploymentMode: "production", verify: { requiredAge: 18 }, gate: { headerName: "X-Age-Gate", requiredValue: "true" }, cookie: { secret: "s".repeat(32) } });\napp.post("/verify", createExpressVerifyHandler(sdk));\napp.use("/restricted", createExpressGateMiddleware(sdk, { gatePath: "/ageverify" }));'
check_project \
"fastify" \
'"fastify": "latest"' \
'import Fastify from "fastify";\nimport { AgeCheckSdk, createFastifyGateHook, createFastifyVerifyHandler } from "@agecheck/node";\nconst app = Fastify();\nconst sdk = new AgeCheckSdk({ deploymentMode: "production", verify: { requiredAge: 18 }, gate: { headerName: "X-Age-Gate", requiredValue: "true" }, cookie: { secret: "s".repeat(32) } });\napp.post("/verify", createFastifyVerifyHandler(sdk));\napp.addHook("preHandler", async (req, reply) => { if (req.url.startsWith("/restricted")) await createFastifyGateHook(sdk, { gatePath: "/ageverify" })(req, reply); });'
check_project \
"hono" \
'"hono": "latest"' \
'import { Hono } from "hono";\nimport { AgeCheckSdk, createHonoGateMiddleware, createHonoVerifyHandler } from "@agecheck/node";\nconst app = new Hono();\nconst sdk = new AgeCheckSdk({ deploymentMode: "production", verify: { requiredAge: 18 }, gate: { headerName: "X-Age-Gate", requiredValue: "true" }, cookie: { secret: "s".repeat(32) } });\napp.post("/verify", createHonoVerifyHandler(sdk));\napp.use("/restricted/*", createHonoGateMiddleware(sdk));'
check_project \
"nuxt-vue" \
'"nuxt": "latest", "vue": "latest"' \
'import { AgeCheckSdk, createNuxtGateMiddleware, createNuxtVerifyHandler } from "@agecheck/node";\nconst sdk = new AgeCheckSdk({ deploymentMode: "production", verify: { requiredAge: 18 }, gate: { headerName: "X-Age-Gate", requiredValue: "true" }, cookie: { secret: "s".repeat(32) } });\nconst gate = createNuxtGateMiddleware(sdk);\nconst verify = createNuxtVerifyHandler(sdk, { readBody: async () => ({ provider: "other", payload: { agegateway_session: "abc" } }), providerVerifier: async () => ({ verified: true, provider: "other", level: "18+", session: "abc" }) });\nvoid gate;\nvoid verify;'