passflow 0.0.0-stage → 0.2.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 +21 -0
- package/README.md +67 -2
- package/dist/cli.mjs +1759 -0
- package/package.json +42 -3
- package/skills/REVISION +1 -0
- package/skills/index.json +405 -0
- package/skills/passflow-nextjs/SKILL.md +205 -0
- package/skills/passflow-nextjs/assets/.env.example +5 -0
- package/skills/passflow-nextjs/assets/app/account/page.tsx +29 -0
- package/skills/passflow-nextjs/assets/app/actions.example.ts +21 -0
- package/skills/passflow-nextjs/assets/app/api/me/route.ts +22 -0
- package/skills/passflow-nextjs/assets/components/auth-links.tsx +11 -0
- package/skills/passflow-nextjs/assets/lib/call-api.example.ts +15 -0
- package/skills/passflow-nextjs/assets/lib/passflow.ts +4 -0
- package/skills/passflow-nextjs/assets/proxy.ts +10 -0
- package/skills/passflow-nextjs/references/guardrails.md +87 -0
- package/skills/passflow-nextjs/scripts/index.json +405 -0
- package/skills/passflow-nextjs/scripts/lib.sh +1069 -0
- package/skills/passflow-nextjs/scripts/verify.sh +467 -0
- package/skills/passflow-node-api/SKILL.md +189 -0
- package/skills/passflow-node-api/assets/examples/explain-rejection.ts +22 -0
- package/skills/passflow-node-api/assets/examples/express-routes.ts +22 -0
- package/skills/passflow-node-api/assets/examples/fastify-routes.ts +28 -0
- package/skills/passflow-node-api/assets/examples/hono-routes.ts +19 -0
- package/skills/passflow-node-api/assets/src/express-cors.ts +11 -0
- package/skills/passflow-node-api/assets/src/express.ts +13 -0
- package/skills/passflow-node-api/assets/src/fastify-cors.ts +11 -0
- package/skills/passflow-node-api/assets/src/fastify.ts +14 -0
- package/skills/passflow-node-api/assets/src/fetch-handler.ts +13 -0
- package/skills/passflow-node-api/assets/src/hono-cors.ts +11 -0
- package/skills/passflow-node-api/assets/src/hono.ts +16 -0
- package/skills/passflow-node-api/assets/src/passflow.ts +21 -0
- package/skills/passflow-node-api/references/guardrails.md +66 -0
- package/skills/passflow-node-api/scripts/index.json +405 -0
- package/skills/passflow-node-api/scripts/lib.sh +1069 -0
- package/skills/passflow-node-api/scripts/verify.sh +283 -0
- package/skills/passflow-react-vite/SKILL.md +225 -0
- package/skills/passflow-react-vite/assets/server/express-cors.ts +9 -0
- package/skills/passflow-react-vite/assets/server/express.ts +14 -0
- package/skills/passflow-react-vite/assets/server/fastify-cors.ts +11 -0
- package/skills/passflow-react-vite/assets/server/fastify.ts +15 -0
- package/skills/passflow-react-vite/assets/server/hono-cors.ts +8 -0
- package/skills/passflow-react-vite/assets/server/hono.ts +17 -0
- package/skills/passflow-react-vite/assets/server/passflow.ts +30 -0
- package/skills/passflow-react-vite/assets/server/tsconfig.json +14 -0
- package/skills/passflow-react-vite/assets/src/passflow.tsx +28 -0
- package/skills/passflow-react-vite/assets/src/require-sign-in.tsx +35 -0
- package/skills/passflow-react-vite/assets/src/use-api.ts +23 -0
- package/skills/passflow-react-vite/references/guardrails.md +82 -0
- package/skills/passflow-react-vite/scripts/index.json +405 -0
- package/skills/passflow-react-vite/scripts/lib.sh +1069 -0
- package/skills/passflow-react-vite/scripts/verify.sh +678 -0
- package/skills/passflow-tanstack-start/SKILL.md +182 -0
- package/skills/passflow-tanstack-start/assets/.env.example +5 -0
- package/skills/passflow-tanstack-start/assets/src/components/auth-links.tsx +10 -0
- package/skills/passflow-tanstack-start/assets/src/lib/call-api.example.ts +14 -0
- package/skills/passflow-tanstack-start/assets/src/lib/passflow.ts +14 -0
- package/skills/passflow-tanstack-start/assets/src/lib/server-functions.example.ts +20 -0
- package/skills/passflow-tanstack-start/assets/src/routes/account.tsx +25 -0
- package/skills/passflow-tanstack-start/assets/src/routes/api/me.ts +25 -0
- package/skills/passflow-tanstack-start/assets/src/start.ts +14 -0
- package/skills/passflow-tanstack-start/references/guardrails.md +73 -0
- package/skills/passflow-tanstack-start/scripts/index.json +405 -0
- package/skills/passflow-tanstack-start/scripts/lib.sh +1069 -0
- package/skills/passflow-tanstack-start/scripts/verify.sh +470 -0
package/package.json
CHANGED
|
@@ -1,6 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "passflow",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "The Passflow CLI. `npx passflow integrate` detects your stack, creates a Passflow app for it, writes its env file and installs the matching agent skill, so your coding agent can add Passflow sign-in.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://docs.usepassflow.com",
|
|
7
|
+
"bugs": {
|
|
8
|
+
"email": "support@passflow.cloud"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=22.12"
|
|
13
|
+
},
|
|
14
|
+
"bin": {
|
|
15
|
+
"passflow": "./dist/cli.mjs"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"skills",
|
|
20
|
+
"README.md",
|
|
21
|
+
"LICENSE"
|
|
22
|
+
],
|
|
23
|
+
"exports": {
|
|
24
|
+
"./package.json": "./package.json"
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@biomejs/biome": "2.6.4",
|
|
31
|
+
"@types/node": "^22.18.0",
|
|
32
|
+
"publint": "0.3.25",
|
|
33
|
+
"tsdown": "0.23.4",
|
|
34
|
+
"typescript": "^7.0.2",
|
|
35
|
+
"vitest": "^5.0.5"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsdown",
|
|
39
|
+
"lint": "biome ci .",
|
|
40
|
+
"format": "biome format . --write",
|
|
41
|
+
"typecheck": "tsc --noEmit",
|
|
42
|
+
"test": "vitest run",
|
|
43
|
+
"vendor-skills": "node scripts/vendor-skills.mjs"
|
|
44
|
+
}
|
|
6
45
|
}
|
package/skills/REVISION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
5d29ad1dffba5bdeeeb61352267f722547b1879b
|
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema": 1,
|
|
3
|
+
"package_managers": {
|
|
4
|
+
"supported": [
|
|
5
|
+
"npm",
|
|
6
|
+
"pnpm",
|
|
7
|
+
"yarn-classic"
|
|
8
|
+
],
|
|
9
|
+
"refused": [
|
|
10
|
+
"yarn-berry",
|
|
11
|
+
"bun"
|
|
12
|
+
],
|
|
13
|
+
"detect": [
|
|
14
|
+
{
|
|
15
|
+
"file": "pnpm-lock.yaml",
|
|
16
|
+
"manager": "pnpm"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"file": "package-lock.json",
|
|
20
|
+
"manager": "npm"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"file": "yarn.lock",
|
|
24
|
+
"manager": "yarn-classic"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"file": ".yarnrc.yml",
|
|
28
|
+
"manager": "yarn-berry"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"file": "bun.lock",
|
|
32
|
+
"manager": "bun"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"file": "bun.lockb",
|
|
36
|
+
"manager": "bun"
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
"stacks": [
|
|
41
|
+
{
|
|
42
|
+
"id": "tanstack-start",
|
|
43
|
+
"skill": "passflow-tanstack-start",
|
|
44
|
+
"detect": {
|
|
45
|
+
"all": [
|
|
46
|
+
{
|
|
47
|
+
"package": "@tanstack/react-start",
|
|
48
|
+
"range": ">=1.169.5"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"package": "@tanstack/react-router",
|
|
52
|
+
"range": ">=1.170.46"
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
"app_type": "bff",
|
|
57
|
+
"default_base_url": "http://localhost:3000",
|
|
58
|
+
"env_file": ".env.local",
|
|
59
|
+
"env_keys": [
|
|
60
|
+
"PASSFLOW_ISSUER",
|
|
61
|
+
"PASSFLOW_CLIENT_ID",
|
|
62
|
+
"PASSFLOW_CLIENT_SECRET",
|
|
63
|
+
"PASSFLOW_SECRET",
|
|
64
|
+
"APP_BASE_URL"
|
|
65
|
+
],
|
|
66
|
+
"secret_env_keys": [
|
|
67
|
+
"PASSFLOW_CLIENT_SECRET",
|
|
68
|
+
"PASSFLOW_SECRET"
|
|
69
|
+
],
|
|
70
|
+
"not_provisioned_env_keys": [],
|
|
71
|
+
"packages": [
|
|
72
|
+
{
|
|
73
|
+
"name": "@passflow/tanstack-react-start",
|
|
74
|
+
"version_env": "PASSFLOW_TANSTACK_REACT_START_VERSION",
|
|
75
|
+
"env_keys": [
|
|
76
|
+
"PASSFLOW_ISSUER",
|
|
77
|
+
"PASSFLOW_CLIENT_ID",
|
|
78
|
+
"PASSFLOW_CLIENT_SECRET",
|
|
79
|
+
"PASSFLOW_SECRET",
|
|
80
|
+
"APP_BASE_URL"
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
"allowed_paths": [
|
|
85
|
+
"src/**",
|
|
86
|
+
"app/**",
|
|
87
|
+
".gitignore",
|
|
88
|
+
"package.json",
|
|
89
|
+
"package-lock.json",
|
|
90
|
+
"pnpm-lock.yaml",
|
|
91
|
+
"yarn.lock"
|
|
92
|
+
],
|
|
93
|
+
"denied_paths": [
|
|
94
|
+
"next.config.*",
|
|
95
|
+
"vite.config.*",
|
|
96
|
+
"vitest.config.*",
|
|
97
|
+
"app.config.*",
|
|
98
|
+
"tsconfig*.json",
|
|
99
|
+
"jsconfig*.json",
|
|
100
|
+
"postcss.config.*",
|
|
101
|
+
"tailwind.config.*",
|
|
102
|
+
"eslint.config.*",
|
|
103
|
+
".eslintrc*",
|
|
104
|
+
"babel.config.*",
|
|
105
|
+
".babelrc*",
|
|
106
|
+
"turbo.json",
|
|
107
|
+
"nx.json",
|
|
108
|
+
"Dockerfile*",
|
|
109
|
+
"docker-compose*",
|
|
110
|
+
".github/**",
|
|
111
|
+
".env*",
|
|
112
|
+
"**/.env*",
|
|
113
|
+
"scripts/**",
|
|
114
|
+
".npmrc",
|
|
115
|
+
"**/.npmrc",
|
|
116
|
+
".yarnrc",
|
|
117
|
+
".yarnrc.yml",
|
|
118
|
+
".yarn/**",
|
|
119
|
+
".pnp.cjs",
|
|
120
|
+
".pnp.loader.mjs",
|
|
121
|
+
"pnpm-workspace.yaml",
|
|
122
|
+
"npm-shrinkwrap.json",
|
|
123
|
+
"bun.lock",
|
|
124
|
+
"bun.lockb"
|
|
125
|
+
]
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"id": "nextjs",
|
|
129
|
+
"skill": "passflow-nextjs",
|
|
130
|
+
"detect": {
|
|
131
|
+
"all": [
|
|
132
|
+
{
|
|
133
|
+
"package": "next",
|
|
134
|
+
"range": ">=16"
|
|
135
|
+
}
|
|
136
|
+
]
|
|
137
|
+
},
|
|
138
|
+
"app_type": "bff",
|
|
139
|
+
"default_base_url": "http://localhost:3000",
|
|
140
|
+
"env_file": ".env.local",
|
|
141
|
+
"env_keys": [
|
|
142
|
+
"PASSFLOW_ISSUER",
|
|
143
|
+
"PASSFLOW_CLIENT_ID",
|
|
144
|
+
"PASSFLOW_CLIENT_SECRET",
|
|
145
|
+
"PASSFLOW_SECRET",
|
|
146
|
+
"APP_BASE_URL"
|
|
147
|
+
],
|
|
148
|
+
"secret_env_keys": [
|
|
149
|
+
"PASSFLOW_CLIENT_SECRET",
|
|
150
|
+
"PASSFLOW_SECRET"
|
|
151
|
+
],
|
|
152
|
+
"not_provisioned_env_keys": [],
|
|
153
|
+
"packages": [
|
|
154
|
+
{
|
|
155
|
+
"name": "@passflow/nextjs",
|
|
156
|
+
"version_env": "PASSFLOW_NEXTJS_VERSION",
|
|
157
|
+
"env_keys": [
|
|
158
|
+
"PASSFLOW_ISSUER",
|
|
159
|
+
"PASSFLOW_CLIENT_ID",
|
|
160
|
+
"PASSFLOW_CLIENT_SECRET",
|
|
161
|
+
"PASSFLOW_SECRET",
|
|
162
|
+
"APP_BASE_URL"
|
|
163
|
+
]
|
|
164
|
+
}
|
|
165
|
+
],
|
|
166
|
+
"allowed_paths": [
|
|
167
|
+
"app/**",
|
|
168
|
+
"src/**",
|
|
169
|
+
"lib/**",
|
|
170
|
+
"components/**",
|
|
171
|
+
"proxy.ts",
|
|
172
|
+
"proxy.js",
|
|
173
|
+
"middleware.ts",
|
|
174
|
+
"middleware.js",
|
|
175
|
+
"src/proxy.ts",
|
|
176
|
+
"src/proxy.js",
|
|
177
|
+
"src/middleware.ts",
|
|
178
|
+
"src/middleware.js",
|
|
179
|
+
".gitignore",
|
|
180
|
+
"package.json",
|
|
181
|
+
"package-lock.json",
|
|
182
|
+
"pnpm-lock.yaml",
|
|
183
|
+
"yarn.lock"
|
|
184
|
+
],
|
|
185
|
+
"denied_paths": [
|
|
186
|
+
"next.config.*",
|
|
187
|
+
"vite.config.*",
|
|
188
|
+
"vitest.config.*",
|
|
189
|
+
"app.config.*",
|
|
190
|
+
"tsconfig*.json",
|
|
191
|
+
"jsconfig*.json",
|
|
192
|
+
"postcss.config.*",
|
|
193
|
+
"tailwind.config.*",
|
|
194
|
+
"eslint.config.*",
|
|
195
|
+
".eslintrc*",
|
|
196
|
+
"babel.config.*",
|
|
197
|
+
".babelrc*",
|
|
198
|
+
"turbo.json",
|
|
199
|
+
"nx.json",
|
|
200
|
+
"Dockerfile*",
|
|
201
|
+
"docker-compose*",
|
|
202
|
+
".github/**",
|
|
203
|
+
".env*",
|
|
204
|
+
"**/.env*",
|
|
205
|
+
"scripts/**",
|
|
206
|
+
".npmrc",
|
|
207
|
+
"**/.npmrc",
|
|
208
|
+
".yarnrc",
|
|
209
|
+
".yarnrc.yml",
|
|
210
|
+
".yarn/**",
|
|
211
|
+
".pnp.cjs",
|
|
212
|
+
".pnp.loader.mjs",
|
|
213
|
+
"pnpm-workspace.yaml",
|
|
214
|
+
"npm-shrinkwrap.json",
|
|
215
|
+
"bun.lock",
|
|
216
|
+
"bun.lockb"
|
|
217
|
+
]
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"id": "react-vite",
|
|
221
|
+
"skill": "passflow-react-vite",
|
|
222
|
+
"detect": {
|
|
223
|
+
"all": [
|
|
224
|
+
{
|
|
225
|
+
"package": "vite"
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
"package": "react"
|
|
229
|
+
}
|
|
230
|
+
]
|
|
231
|
+
},
|
|
232
|
+
"app_type": "spa",
|
|
233
|
+
"default_base_url": "http://localhost:5173",
|
|
234
|
+
"env_file": ".env.local",
|
|
235
|
+
"env_keys": [
|
|
236
|
+
"VITE_PASSFLOW_URL",
|
|
237
|
+
"VITE_PASSFLOW_APP_ID",
|
|
238
|
+
"VITE_API_URL",
|
|
239
|
+
"PASSFLOW_ISSUER",
|
|
240
|
+
"PASSFLOW_AUDIENCE",
|
|
241
|
+
"APP_BASE_URL"
|
|
242
|
+
],
|
|
243
|
+
"secret_env_keys": [],
|
|
244
|
+
"not_provisioned_env_keys": [
|
|
245
|
+
"VITE_API_URL"
|
|
246
|
+
],
|
|
247
|
+
"packages": [
|
|
248
|
+
{
|
|
249
|
+
"name": "@passflow/react",
|
|
250
|
+
"version_env": "PASSFLOW_REACT_VERSION",
|
|
251
|
+
"env_keys": [
|
|
252
|
+
"VITE_PASSFLOW_URL",
|
|
253
|
+
"VITE_PASSFLOW_APP_ID",
|
|
254
|
+
"VITE_API_URL"
|
|
255
|
+
]
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
"name": "@passflow/node",
|
|
259
|
+
"version_env": "PASSFLOW_NODE_VERSION",
|
|
260
|
+
"env_keys": [
|
|
261
|
+
"PASSFLOW_ISSUER",
|
|
262
|
+
"PASSFLOW_AUDIENCE",
|
|
263
|
+
"APP_BASE_URL"
|
|
264
|
+
]
|
|
265
|
+
}
|
|
266
|
+
],
|
|
267
|
+
"allowed_paths": [
|
|
268
|
+
"src/**",
|
|
269
|
+
"server/**",
|
|
270
|
+
"api/**",
|
|
271
|
+
".gitignore",
|
|
272
|
+
"package.json",
|
|
273
|
+
"package-lock.json",
|
|
274
|
+
"pnpm-lock.yaml",
|
|
275
|
+
"yarn.lock"
|
|
276
|
+
],
|
|
277
|
+
"denied_paths": [
|
|
278
|
+
"next.config.*",
|
|
279
|
+
"vite.config.*",
|
|
280
|
+
"vitest.config.*",
|
|
281
|
+
"app.config.*",
|
|
282
|
+
"tsconfig*.json",
|
|
283
|
+
"jsconfig*.json",
|
|
284
|
+
"postcss.config.*",
|
|
285
|
+
"tailwind.config.*",
|
|
286
|
+
"eslint.config.*",
|
|
287
|
+
".eslintrc*",
|
|
288
|
+
"babel.config.*",
|
|
289
|
+
".babelrc*",
|
|
290
|
+
"turbo.json",
|
|
291
|
+
"nx.json",
|
|
292
|
+
"Dockerfile*",
|
|
293
|
+
"docker-compose*",
|
|
294
|
+
".github/**",
|
|
295
|
+
".env*",
|
|
296
|
+
"**/.env*",
|
|
297
|
+
"scripts/**",
|
|
298
|
+
".npmrc",
|
|
299
|
+
"**/.npmrc",
|
|
300
|
+
".yarnrc",
|
|
301
|
+
".yarnrc.yml",
|
|
302
|
+
".yarn/**",
|
|
303
|
+
".pnp.cjs",
|
|
304
|
+
".pnp.loader.mjs",
|
|
305
|
+
"pnpm-workspace.yaml",
|
|
306
|
+
"npm-shrinkwrap.json",
|
|
307
|
+
"bun.lock",
|
|
308
|
+
"bun.lockb",
|
|
309
|
+
"index.html"
|
|
310
|
+
]
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
"id": "node-api",
|
|
314
|
+
"skill": "passflow-node-api",
|
|
315
|
+
"detect": {
|
|
316
|
+
"any": [
|
|
317
|
+
{
|
|
318
|
+
"package": "express"
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
"package": "fastify"
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
"package": "hono"
|
|
325
|
+
}
|
|
326
|
+
]
|
|
327
|
+
},
|
|
328
|
+
"app_type": null,
|
|
329
|
+
"default_base_url": null,
|
|
330
|
+
"env_file": ".env",
|
|
331
|
+
"env_keys": [
|
|
332
|
+
"PASSFLOW_ISSUER",
|
|
333
|
+
"PASSFLOW_AUDIENCE"
|
|
334
|
+
],
|
|
335
|
+
"secret_env_keys": [],
|
|
336
|
+
"not_provisioned_env_keys": [],
|
|
337
|
+
"packages": [
|
|
338
|
+
{
|
|
339
|
+
"name": "@passflow/node",
|
|
340
|
+
"version_env": "PASSFLOW_NODE_VERSION",
|
|
341
|
+
"env_keys": [
|
|
342
|
+
"PASSFLOW_ISSUER",
|
|
343
|
+
"PASSFLOW_AUDIENCE"
|
|
344
|
+
]
|
|
345
|
+
}
|
|
346
|
+
],
|
|
347
|
+
"allowed_paths": [
|
|
348
|
+
"src/**",
|
|
349
|
+
"server/**",
|
|
350
|
+
"lib/**",
|
|
351
|
+
"routes/**",
|
|
352
|
+
"index.ts",
|
|
353
|
+
"index.js",
|
|
354
|
+
"index.mjs",
|
|
355
|
+
"server.ts",
|
|
356
|
+
"server.js",
|
|
357
|
+
"server.mjs",
|
|
358
|
+
"app.ts",
|
|
359
|
+
"app.js",
|
|
360
|
+
"app.mjs",
|
|
361
|
+
"main.ts",
|
|
362
|
+
"main.js",
|
|
363
|
+
"main.mjs",
|
|
364
|
+
".gitignore",
|
|
365
|
+
"package.json",
|
|
366
|
+
"package-lock.json",
|
|
367
|
+
"pnpm-lock.yaml",
|
|
368
|
+
"yarn.lock"
|
|
369
|
+
],
|
|
370
|
+
"denied_paths": [
|
|
371
|
+
"next.config.*",
|
|
372
|
+
"vite.config.*",
|
|
373
|
+
"vitest.config.*",
|
|
374
|
+
"app.config.*",
|
|
375
|
+
"tsconfig*.json",
|
|
376
|
+
"jsconfig*.json",
|
|
377
|
+
"postcss.config.*",
|
|
378
|
+
"tailwind.config.*",
|
|
379
|
+
"eslint.config.*",
|
|
380
|
+
".eslintrc*",
|
|
381
|
+
"babel.config.*",
|
|
382
|
+
".babelrc*",
|
|
383
|
+
"turbo.json",
|
|
384
|
+
"nx.json",
|
|
385
|
+
"Dockerfile*",
|
|
386
|
+
"docker-compose*",
|
|
387
|
+
".github/**",
|
|
388
|
+
".env*",
|
|
389
|
+
"**/.env*",
|
|
390
|
+
"scripts/**",
|
|
391
|
+
".npmrc",
|
|
392
|
+
"**/.npmrc",
|
|
393
|
+
".yarnrc",
|
|
394
|
+
".yarnrc.yml",
|
|
395
|
+
".yarn/**",
|
|
396
|
+
".pnp.cjs",
|
|
397
|
+
".pnp.loader.mjs",
|
|
398
|
+
"pnpm-workspace.yaml",
|
|
399
|
+
"npm-shrinkwrap.json",
|
|
400
|
+
"bun.lock",
|
|
401
|
+
"bun.lockb"
|
|
402
|
+
]
|
|
403
|
+
}
|
|
404
|
+
]
|
|
405
|
+
}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: passflow-nextjs
|
|
3
|
+
description: Adds Passflow sign-in on the server to a Next.js 16 App Router app using @passflow/nextjs. A proxy serves /auth/login, /auth/callback and /auth/logout, the session lives in an encrypted HttpOnly cookie, and pages, layouts, server actions and route handlers check it. Use when asked to add Passflow sign-in, login or auth to a Next.js app, or to protect Next.js pages, server actions or API routes with Passflow. Applies when the root package.json depends on next 16 or newer and not on @tanstack/react-start (that has its own Passflow skill).
|
|
4
|
+
compatibility: Next.js 16 or newer with the App Router, React 19, Node.js 22.12 or newer; npm, pnpm or Yarn 1.
|
|
5
|
+
license: MIT
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Passflow for Next.js
|
|
9
|
+
|
|
10
|
+
## What this does
|
|
11
|
+
|
|
12
|
+
Adds sign-in on the server to a Next.js App Router app. `proxy.ts` serves `/auth/login`, `/auth/callback` and `/auth/logout` and refreshes the session when its access token is due. The session lives in an encrypted HttpOnly cookie, `__Host-passflow_session` on https and `passflow_session` on http localhost, split into `.0`, `.1`, … chunks when it is large. Sign-in keeps its state in a `__Host-passflow_txn` cookie (`passflow_txn` on http localhost). Both cookies use `Path=/`, and no token reaches the browser. Pages, layouts and server actions call `requireSession()`; route handlers call `getSession()` and answer 401.
|
|
13
|
+
|
|
14
|
+
## Where this runs
|
|
15
|
+
|
|
16
|
+
The steps are the same in both places, except where a step is labelled.
|
|
17
|
+
|
|
18
|
+
- **On the developer's machine** (`npx passflow integrate`): you have a shell. Run the commands shown for this place.
|
|
19
|
+
- **In a Passflow GitHub App run**: you have no shell. Your only tools are Read, Write, Edit, Glob, Grep and Skill, plus:
|
|
20
|
+
- `add_passflow_package({name})`, which adds one `@passflow/*` package with the project's package manager, scripts off;
|
|
21
|
+
- `run_build()` and `run_typecheck()`, which each return the exit code and a short tail of the output.
|
|
22
|
+
|
|
23
|
+
Never try to run `curl`, `cat`, `npx`, `node` or a script there. After you finish, the runner runs the install, `run_build()`, `run_typecheck()` and then `verify.sh static`. It never runs `verify.sh run`, because the issuer and the client secret stay out of the sandbox: the draft PR's description tells the developer to run `bash <skill>/scripts/verify.sh run` on their machine before merging.
|
|
24
|
+
|
|
25
|
+
## Preconditions
|
|
26
|
+
|
|
27
|
+
Check each one before you change a file. Every check reads files with Read, Glob or Grep, unless it is labelled. If one fails, stop and tell the user why.
|
|
28
|
+
|
|
29
|
+
1. **Stack.** Read the root `package.json`. It lists `next` in `dependencies` or `devDependencies`, and does not list `@tanstack/react-start` (that app uses the TanStack Start Passflow skill). The `next` range must admit only Next.js 16 or newer: `^16.1.0`, `16.4.6` and `>=16` pass; `^15.3.0` fails, and so does a range that cannot be compared (a tag such as `latest`, `workspace:`, a URL, `a || b`, `a - b`). If it fails, stop: the project needs Next.js 16 or newer, written as a version range. It is not treated as another stack, even when it also lists `vite` and `react`.
|
|
30
|
+
2. **App Router.** Glob for `app/` or `src/app/`. A Pages Router app (only `pages/`) is not supported: stop.
|
|
31
|
+
3. **Node.js 22.12 or newer.** *On the developer's machine:* `node --version`. *In a Passflow GitHub App run:* the runner checks for Node.js 22.12 or newer; you do not.
|
|
32
|
+
4. **Package manager.** Glob the project root for lockfiles and Read the `packageManager` field of `package.json`:
|
|
33
|
+
- a `packageManager` field that names `yarn@2` or newer, or `bun`, means Yarn Berry or Bun;
|
|
34
|
+
- otherwise the lockfiles, in this order: `pnpm-lock.yaml` → pnpm, `package-lock.json` → npm, `yarn.lock` → Yarn 1 (classic), `.yarnrc.yml` → Yarn Berry, `bun.lock` or `bun.lockb` → Bun. If any file present points to Yarn Berry or Bun, that decides; otherwise the first one present does. A `yarn.lock` with a `__metadata:` line (Grep for it) is also Yarn Berry;
|
|
35
|
+
- no lockfile at all: stop. The change needs a committed lockfile. Tell the user to install once with npm, pnpm or Yarn 1 (classic) and commit the lockfile;
|
|
36
|
+
- a `packageManager` field that names a manager other than the one the lockfile picks (for example `pnpm@9.0.0` beside `package-lock.json`): stop, and tell the user to make the two agree;
|
|
37
|
+
- an `npm-shrinkwrap.json` at the root: stop. This skill does not support it.
|
|
38
|
+
|
|
39
|
+
**Yarn Berry or Bun: stop.** Tell the user that this skill supports npm, pnpm and Yarn 1 (classic) only.
|
|
40
|
+
5. **Env files.** The app reads `PASSFLOW_ISSUER`, `PASSFLOW_CLIENT_ID`, `PASSFLOW_CLIENT_SECRET`, `PASSFLOW_SECRET` and `APP_BASE_URL` from `.env.local`.
|
|
41
|
+
- **You never create or edit any `.env*` file: not `.env`, not `.env.local`, not `.env.example`.** On the developer's machine, `npx passflow integrate` writes `.env.local` and `.env.example`. In a Passflow GitHub App run, the service writes `.env.example` with the public values filled in (`PASSFLOW_ISSUER`, `PASSFLOW_CLIENT_ID`, `APP_BASE_URL`) and the secrets empty (`PASSFLOW_CLIENT_SECRET`, `PASSFLOW_SECRET`). Empty secrets there are expected, not a failed setup.
|
|
42
|
+
- If `.env.local` is missing or a value is empty, do not invent values. The code changes, the build and the type check need no values.
|
|
43
|
+
- *On the developer's machine:* if `git ls-files --error-unmatch .env.local` succeeds, git tracks the file: stop. Tell the user to run `git rm --cached .env.local`, commit, and add `.env.local` to `.gitignore`.
|
|
44
|
+
- *In a Passflow GitHub App run:* the service refuses a repository with a committed `.env`, `.env.local` or `.env.*.local` before you start, so there is nothing to check.
|
|
45
|
+
- Never read out, print or repeat a value from an env file.
|
|
46
|
+
6. **What you may change in `package.json`.** Only add `@passflow/nextjs` to `dependencies`, through step 1. Never add any other dependency, and never edit `scripts`. If a step seems to need either, stop and put it in the message to the developer (step 11).
|
|
47
|
+
|
|
48
|
+
## Steps
|
|
49
|
+
|
|
50
|
+
1. **Install the package.**
|
|
51
|
+
- *On the developer's machine:* use the project's package manager. The version comes from `PASSFLOW_NEXTJS_VERSION`; unset means the latest release. Run the line as it is:
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
npm install "@passflow/nextjs${PASSFLOW_NEXTJS_VERSION:+@$PASSFLOW_NEXTJS_VERSION}"
|
|
55
|
+
pnpm add "@passflow/nextjs${PASSFLOW_NEXTJS_VERSION:+@$PASSFLOW_NEXTJS_VERSION}"
|
|
56
|
+
yarn add "@passflow/nextjs${PASSFLOW_NEXTJS_VERSION:+@$PASSFLOW_NEXTJS_VERSION}"
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
- *In a Passflow GitHub App run:* call `add_passflow_package({name: "@passflow/nextjs"})`. The service pins the version, and the tool adds that exact version. Never edit `package.json` or the lockfile by hand.
|
|
60
|
+
|
|
61
|
+
2. **Pick the root.** If the project has `src/app/`, every target below goes under `src/` (`src/lib/passflow.ts`, `src/proxy.ts`, `src/app/…`). Otherwise it goes under the project root. `proxy.ts` always sits beside `app/`.
|
|
62
|
+
|
|
63
|
+
3. **Check the import alias.** The assets import with the `@/` alias (`import { passflow } from '@/lib/passflow';`), which `create-next-app` sets up by default. Read `tsconfig.json` (or `jsconfig.json`) and look for `"@/*"` under `compilerOptions.paths`. It must point at `<root>`: `["./*"]` for a root layout, `["./src/*"]` for a `src/` layout.
|
|
64
|
+
- If it is there, copy the assets unchanged.
|
|
65
|
+
- If it is missing or points elsewhere, change only the import specifiers in the copied files to relative paths (for example `'@/lib/passflow'` in `app/account/page.tsx` becomes `'../../lib/passflow'`). Never change the calls, and do not add the alias to the project's config.
|
|
66
|
+
|
|
67
|
+
`proxy.ts` imports `'./lib/passflow'` relatively, which works in both layouts.
|
|
68
|
+
|
|
69
|
+
The package is ESM-only: import it as the assets do, never with `require()`.
|
|
70
|
+
|
|
71
|
+
4. **Copy the assets.** Read each asset and Write it to its target. Do not change the Passflow calls in them.
|
|
72
|
+
|
|
73
|
+
| Asset | Target | Adapt |
|
|
74
|
+
|---|---|---|
|
|
75
|
+
| `assets/lib/passflow.ts` | `<root>/lib/passflow.ts` | Nothing. |
|
|
76
|
+
| `assets/proxy.ts` | `<root>/proxy.ts` | If a proxy or middleware file exists, merge into it instead and add no file: step 5. |
|
|
77
|
+
| `assets/app/api/me/route.ts` | `<root>/app/api/me/route.ts`, or the path chosen below | Keep it: `verify.sh run` calls it. Check the app's routes first, below. |
|
|
78
|
+
| `assets/app/account/page.tsx` | `<root>/app/account/page.tsx` | An example protected page. If the app has its own page to protect, apply the pattern there (step 6) and skip this file. |
|
|
79
|
+
| `assets/components/auth-links.tsx` | `<root>/components/auth-links.tsx` | Render `<AuthLinks />` where the app shows its navigation, inside `<Suspense>` (step 8). |
|
|
80
|
+
| `assets/app/actions.example.ts` | not copied | The pattern for server actions (step 6). |
|
|
81
|
+
| `assets/lib/call-api.example.ts` | `<root>/lib/call-api.ts`, only if server code calls an API as the user | The pattern for sending the access token to an API (step 10). |
|
|
82
|
+
|
|
83
|
+
**Before you add `/api/me`,** look for an existing route at that path. Glob for `<root>/app/api/me/route.*` and `<root>/app/**/api/me/route.*` (a route group such as `app/(api)/api/me`), and Grep `next.config.*` for a rewrite of `/api/me`. If one exists, never overwrite it or add a second. Either protect that handler in place with the route-handler pattern from step 6, or copy the asset to an unused path such as `<root>/app/api/passflow/me/route.ts`. Name the path you used in the message to the developer (step 11), because `verify.sh run` then needs `--api /api/passflow/me`. In a Passflow GitHub App run, name it in your final summary: the summary goes into the draft PR's description, which tells the developer to run `verify.sh run --api <path>` before merging.
|
|
84
|
+
|
|
85
|
+
5. **Merge an existing proxy or middleware.** Before copying `assets/proxy.ts`, Glob for `proxy.ts`, `proxy.js`, `middleware.ts` and `middleware.js`, both in the project root and in `src/`.
|
|
86
|
+
- **None exists:** copy the asset to `<root>/proxy.ts`.
|
|
87
|
+
- **One exists beside `app/`** (in `<root>`): merge into that file with Edit. Never overwrite it and never add a second file: Next.js refuses to start with both a proxy and a middleware file. Keep its name, its extension and its function (`proxy` or `middleware`); do not rename, convert or delete it. `middleware` is the older name, which Next.js 16 still runs.
|
|
88
|
+
- **One exists only in the other place** (the project root of a `src/app/` project, or `src/` of a root `app/` project): Next.js does not run it. Do not merge into it or move it; stop and tell the user.
|
|
89
|
+
- **More than one exists:** stop and tell the user; the project must pick one.
|
|
90
|
+
- **The three sign-in routes go to Passflow first.** Make this the function's first statement, before any redirect, rewrite, locale handling or "signed in?" check the project already has. Otherwise an existing redirect can catch `/auth/callback`, and the user finishes sign-in on the Passflow page but never gets a session:
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
const { pathname } = request.nextUrl;
|
|
94
|
+
if (pathname === '/auth/login' || pathname === '/auth/callback' || pathname === '/auth/logout') {
|
|
95
|
+
return passflow.proxy(request);
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
- **Then keep the project's branches as they are.** A branch that returns its own redirect or rewrite keeps doing so, and does not call `passflow.proxy(request)`.
|
|
100
|
+
- **Wherever the function would return `NextResponse.next()`**, return Passflow's response instead, unchanged: it carries the refreshed session cookie and the request headers forwarded to the page.
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
return passflow.proxy(request);
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
To add a response header, set it on the response `passflow.proxy(request)` returns. Never build a new `NextResponse.next()` or `NextResponse.rewrite()` from it: either drops the refreshed cookie and the forwarded headers. A page reached through a rewrite branch still reads the session, but its access token is not refreshed on that request; if such a page calls an API with `getAccessToken()`, say so in the message to the developer.
|
|
107
|
+
- The `matcher` must cover `/auth/:path*` and every page and route handler that reads the session. If the project's matcher is narrower, widen it to the asset's matcher or add those paths.
|
|
108
|
+
- Import `passflow` as `proxy.ts` does: `import { passflow } from './lib/passflow';`. The snippets above have no type syntax, so they fit a `.js` file as they are.
|
|
109
|
+
|
|
110
|
+
6. **Protect each place that shows or changes private data.** Public pages get nothing.
|
|
111
|
+
|
|
112
|
+
| Place | Call | Signed out |
|
|
113
|
+
|---|---|---|
|
|
114
|
+
| Page or layout | `const { user } = await passflow.requireSession();` in an async component inside `<Suspense>` | Redirect to `/auth/login`, back to this page after sign-in |
|
|
115
|
+
| Server action | `const { user } = await passflow.requireSession();` as its first line | The rest of the action never runs; redirect to sign-in |
|
|
116
|
+
| Route handler | `const session = await passflow.getSession();` then `if (session === null) { return passflow.unauthorized(); }` | 401 with `Cache-Control: no-store`, never a redirect |
|
|
117
|
+
| Route handler that changes data | `if (!passflow.isSameOrigin(request)) { return new Response(null, { status: 403 }); }` before anything else, then the session check | 403 cross-origin |
|
|
118
|
+
|
|
119
|
+
`assets/app/account/page.tsx`, `assets/app/actions.example.ts` and `assets/app/api/me/route.ts` show each one in full; the `POST` handler answers 204 with no body where the app's own change would go. Import `passflow` from `@/lib/passflow`.
|
|
120
|
+
|
|
121
|
+
7. **cacheComponents.** Next.js 16 apps often set `cacheComponents: true` in `next.config.*` (Read it). Then the part of a page outside `<Suspense>` is prerendered and sent to every visitor, signed in or not, and the sign-in redirect can arrive in the stream after a 200. So:
|
|
122
|
+
- Render everything that needs a signed-in user inside the async component that calls `requireSession()`, as `Account` does in the asset. The page shell keeps layout only.
|
|
123
|
+
- Do not put `requireSession()` or `getSession()` in a `'use cache'` function or component.
|
|
124
|
+
|
|
125
|
+
8. **Sign-in and sign-out links.** `assets/components/auth-links.tsx` is one async server component:
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
export async function AuthLinks({ returnTo = '/' }: { returnTo?: string }) {
|
|
129
|
+
const session = await passflow.getSession();
|
|
130
|
+
if (session === null) {
|
|
131
|
+
return <a href={`/auth/login?returnTo=${encodeURIComponent(returnTo)}`}>Sign in</a>;
|
|
132
|
+
}
|
|
133
|
+
return <a href="/auth/logout">Sign out</a>;
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
It reads the session, so render it inside `<Suspense>` (with cacheComponents, outside one the build fails), and only from server components: a client component cannot render it. Pass `returnTo="/some/path"` to come back to that page after sign-in; only a same-origin path is honoured. Links to `/auth/login` and `/auth/logout` are always plain `<a href>`, never `next/link`. `/auth/logout` ignores prefetches and requests another site starts, so a prefetching `<Link>` never signs the user out by itself. A prefetching link to `/auth/login` can still start a sign-in before anyone clicks, and the client router cannot render a route the proxy serves. A plain `<a href>` keeps sign-in and sign-out working. A client component that needs a link writes a plain `<a href="/auth/login?returnTo=…">` or `<a href="/auth/logout">` itself.
|
|
138
|
+
|
|
139
|
+
9. **`APP_BASE_URL` is the origin the browser uses.** It is an origin only, such as `https://app.example.com` or `http://localhost:3000`, with no path, query or fragment. An app served under a sub-path is not supported: `npx passflow integrate` refuses a `--base-url` with a path. The package builds its redirects as absolute URLs on `APP_BASE_URL`, because the Next.js proxy refuses a relative `Location`, and the Passflow app's callback URL is `APP_BASE_URL` plus `/auth/callback`. If the browser opens the app on another origin (`127.0.0.1` against `localhost`, another port, a preview domain), sign-in lands on the wrong host and fails. Tell the developer; do not change it yourself.
|
|
140
|
+
|
|
141
|
+
10. **Keep tokens on the server.** The `Session` that `getSession()` and `requireSession()` return holds no token, so a page may pass `session.user` to a client component. Never import `lib/passflow` from a file marked `'use client'`.
|
|
142
|
+
|
|
143
|
+
Server code that calls an API as the signed-in user copies `assets/lib/call-api.example.ts`, which sends the access token as a bearer token:
|
|
144
|
+
|
|
145
|
+
```ts
|
|
146
|
+
const token = await passflow.getAccessToken();
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Call `fetchAsUser` from a server component, a server action or a route handler, with a URL the app chose, and return only the API's data. Never return the token from a server action, pass it as a prop to a client component, put it in a cookie or browser storage, or log it. The app itself never reads claims from the token: it reads `session.user`. The API that receives the token verifies it; for a Node.js API that is the Passflow Node API skill.
|
|
150
|
+
|
|
151
|
+
11. **Check your work, then tell the developer.**
|
|
152
|
+
- *On the developer's machine:* run `bash <skill>/scripts/verify.sh static` (see Verification) and fix what it reports.
|
|
153
|
+
- *In a Passflow GitHub App run:* call `run_build()` first, then `run_typecheck()`, and fix what they report. The build writes `next-env.d.ts`, which the type check needs. `run_typecheck()` runs the same check as `verify.sh static`: the `typecheck` script, else `tsc -b` for a `tsconfig.json` with `references`, else `tsc -p tsconfig.json`.
|
|
154
|
+
|
|
155
|
+
End with one message that lists what the developer does next, and change none of it yourself:
|
|
156
|
+
- the env file: if `.env.local` is missing, `cp .env.example .env.local`, then fill in the values from the Passflow portal or the run page (`npx passflow integrate` writes it instead). If `.env.example` lacks a name from `assets/.env.example`, list that name;
|
|
157
|
+
- the Passflow app's callback URL: `APP_BASE_URL` followed by `/auth/callback`;
|
|
158
|
+
- `bash <skill>/scripts/verify.sh run` once `.env.local` is filled in, with `--api <path>` when the route is not at `/api/me`;
|
|
159
|
+
- anything you stopped short of: a dependency or `package.json` script the app would need, a rewrite branch from step 5, an `APP_BASE_URL` that does not match the browser's origin (step 9).
|
|
160
|
+
|
|
161
|
+
## Guardrails
|
|
162
|
+
|
|
163
|
+
Read `references/guardrails.md` before you edit auth code. In short:
|
|
164
|
+
|
|
165
|
+
- The session check is in server code: `requireSession()` or `getSession()`. The proxy alone protects nothing.
|
|
166
|
+
- Close the backend too: every server action and route handler that touches private data checks the session, not only the page that links to it.
|
|
167
|
+
- With cacheComponents, signed-in content renders only under the component that calls `requireSession()`.
|
|
168
|
+
- No secret in a `NEXT_PUBLIC_` variable.
|
|
169
|
+
- No token in browser storage, in a server action's result or in a client component's props.
|
|
170
|
+
- Never decode a token by hand; read the user from the session, and let the API that receives the token verify it.
|
|
171
|
+
- Route handlers that change data call `isSameOrigin(request)` first.
|
|
172
|
+
- Sign-in and sign-out links are plain `<a href>`, never `next/link`.
|
|
173
|
+
- In an existing proxy or middleware, `/auth/login`, `/auth/callback` and `/auth/logout` go to `passflow.proxy(request)` before any other branch.
|
|
174
|
+
- Copy Passflow calls from `assets/`, never from memory.
|
|
175
|
+
- Never create or edit any `.env*` file, `.env.example` included. Never edit `package.json` scripts or add a dependency other than `@passflow/nextjs`.
|
|
176
|
+
|
|
177
|
+
## Verification
|
|
178
|
+
|
|
179
|
+
*On the developer's machine*, run from the project root; `<skill>` is this skill's directory:
|
|
180
|
+
|
|
181
|
+
```sh
|
|
182
|
+
bash <skill>/scripts/verify.sh static
|
|
183
|
+
bash <skill>/scripts/verify.sh run
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
*In a Passflow GitHub App run*, you run `run_build()` and `run_typecheck()` only (step 11). The runner then runs `verify.sh static` itself, and its result is part of the run. It never runs `verify.sh run`; the draft PR's description tells the developer to run it on their machine before merging, with `--api <path>` when the route moved.
|
|
187
|
+
|
|
188
|
+
- `static` needs no env values. It checks that `@passflow/nextjs` is a dependency and that exactly one proxy or middleware file (`.ts` or `.js`) beside `app/` calls `passflow.proxy`, and installs with lifecycle scripts off. It runs `build` first, because the build writes `next-env.d.ts`, and then type-checks: the `typecheck` script when there is one, else `tsc -b --noEmit` for a solution-style `tsconfig.json` (one with `references`), else `tsc -p tsconfig.json --noEmit`. It searches the client bundle in `.next/static` for the names `PASSFLOW_CLIENT_SECRET` and `PASSFLOW_SECRET` and for their values, and the prerendered pages in `.next/server/app` (`.html`, `.rsc`, `.body`, `.meta`) for their values. The values come from `.env.local` and from the process environment, such as a CI secret, and are never printed. It also scans the source for the guardrail breaks above, including a `'use client'` file that imports `lib/passflow`. It proves the copied calls compile and no secret reaches the browser.
|
|
189
|
+
- `run` needs the developer's `.env.local` with all five values, a `build` and a `start` script, a free port (default 3100, `--port` to change), and a reachable `PASSFLOW_ISSUER`: `/auth/login` reads the issuer's discovery document before it redirects, and answers 503 when the issuer gives no answer within 10 seconds or answers with a 5xx. It builds, starts the app and checks, signed out: `/account` (change with `--page`) has no `data-passflow-protected` content and redirects to `/auth/login`, in `Location` or in the stream; `/api/me` (change with `--api`) answers 401 with `Cache-Control: no-store`; `/auth/login` redirects to the issuer's `/oidc/authorize` with `code_challenge_method=S256` and sets an HttpOnly transaction cookie (`passflow_txn` over http, `__Host-passflow_txn` over https); a `POST` to `/api/me` from `https://evil.example` gets 403, and from `APP_BASE_URL`'s origin gets 401 (skipped when the route has no `POST`). It stops the server it started. It never signs in.
|
|
190
|
+
|
|
191
|
+
Each check prints `PASS`, `FAIL` or `SKIP`, then `RESULT pass` or `RESULT fail`. Exit 0 is a pass, 1 a failed check, 2 a refusal (unsupported stack or package manager, missing tool or env file).
|
|
192
|
+
|
|
193
|
+
## Troubleshooting
|
|
194
|
+
|
|
195
|
+
- **`TypeError` naming a `PASSFLOW_` variable or `APP_BASE_URL` on the first request.** `.env.local` is missing that value. The build passes without it, because config is read on first use. The developer fills it in; you do not.
|
|
196
|
+
- **`Cannot find module '@/lib/passflow'`.** The project has no `@/*` path, or it points at another directory. Change the import specifiers to relative paths (step 3).
|
|
197
|
+
- **Build error about uncached data or `cookies()` outside `<Suspense>`.** `<AuthLinks />` or a component that calls `getSession()` or `requireSession()` renders outside `<Suspense>`. Wrap it (steps 7 and 8).
|
|
198
|
+
- **Next.js refuses to start, or `verify.sh static` fails, because both a middleware and a proxy file exist.** The project had `middleware.ts` and `proxy.ts` was added beside it. Move the Passflow call into `middleware.ts` and remove the `proxy.ts` you added (step 5).
|
|
199
|
+
- **The signed-out page shows its content for a moment, or `verify.sh run` finds `data-passflow-protected`.** Signed-in content sits outside the component that calls `requireSession()`. Move it inside (step 7).
|
|
200
|
+
- **Sign-in loops back to the sign-in page, or ends on another page with no session.** The proxy's `matcher` skips the page or `/auth/callback`, or an existing redirect runs before Passflow sees `/auth/callback`. Use the asset's matcher and send the three sign-in routes to Passflow first (step 5).
|
|
201
|
+
- **A route handler answers with the sign-in page's HTML instead of 401.** It calls `requireSession()`. Route handlers use `getSession()` and `passflow.unauthorized()`.
|
|
202
|
+
- **`/auth/login` or the return to `/auth/callback` answers 503 `Sign-in is unavailable: the Passflow issuer could not be reached. Try again later.`** The app could not reach `PASSFLOW_ISSUER`: no answer within 10 seconds, a refused connection or an unknown host, or a 5xx from the issuer. Nothing retries; the user tries again later. Check the value for a typo and for a proxy or firewall in between. *On the developer's machine*, `curl -i "$PASSFLOW_ISSUER/.well-known/openid-configuration"` from the app's machine must answer 200.
|
|
203
|
+
- **Sign-in works on http localhost but not on the deployed https site, or the browser drops the session cookie.** On https the cookies are named `__Host-passflow_session` and `__Host-passflow_txn`, and the browser takes them only over https with `Path=/`. `APP_BASE_URL` must use `https://` there, and a proxy in front of the app must not rewrite the cookie's path or domain.
|
|
204
|
+
- **`Sign-in failed. Try again.` after the Passflow page, or sign-in ends on another host.** The browser uses an origin other than `APP_BASE_URL` (step 9). Open the app at exactly `APP_BASE_URL`, or have the developer correct it.
|
|
205
|
+
- **`npx passflow integrate` did not update this skill.** The CLI replaces only a skill folder it installed and that is still unchanged; a skill folder you changed is not overwritten. Delete the folder to get the new version.
|