@foldspace-fe/casdoor-next-auth-kit 0.1.1

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.
Files changed (40) hide show
  1. package/dist/billing/index.d.ts +16 -0
  2. package/dist/billing/index.js +28 -0
  3. package/dist/billing/index.js.map +1 -0
  4. package/dist/callback-BTzHQK_r.d.ts +12 -0
  5. package/dist/casdoor/index.d.ts +28 -0
  6. package/dist/casdoor/index.js +40 -0
  7. package/dist/casdoor/index.js.map +1 -0
  8. package/dist/chunk-6E27SZ7V.js +291 -0
  9. package/dist/chunk-6E27SZ7V.js.map +1 -0
  10. package/dist/chunk-DONQHN4U.js +56 -0
  11. package/dist/chunk-DONQHN4U.js.map +1 -0
  12. package/dist/chunk-IQEVUR77.js +909 -0
  13. package/dist/chunk-IQEVUR77.js.map +1 -0
  14. package/dist/chunk-RGTVPBH7.js +182 -0
  15. package/dist/chunk-RGTVPBH7.js.map +1 -0
  16. package/dist/chunk-T2M5MVPE.js +20 -0
  17. package/dist/chunk-T2M5MVPE.js.map +1 -0
  18. package/dist/chunk-XMBHIEYL.js +1 -0
  19. package/dist/chunk-XMBHIEYL.js.map +1 -0
  20. package/dist/chunk-Y4GJ2AEI.js +192 -0
  21. package/dist/chunk-Y4GJ2AEI.js.map +1 -0
  22. package/dist/cli.d.ts +2 -0
  23. package/dist/cli.js +437 -0
  24. package/dist/cli.js.map +1 -0
  25. package/dist/index.d.ts +77 -0
  26. package/dist/index.js +148 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/next/index.d.ts +17 -0
  29. package/dist/next/index.js +24 -0
  30. package/dist/next/index.js.map +1 -0
  31. package/dist/options-JUwZSXu2.d.ts +40 -0
  32. package/dist/react/index.d.ts +242 -0
  33. package/dist/react/index.js +774 -0
  34. package/dist/react/index.js.map +1 -0
  35. package/dist/skills/casdoor-next-auth-kit/SKILL.md +158 -0
  36. package/dist/skills/casdoor-next-auth-kit/references/casdoor-api-reference.md +2387 -0
  37. package/dist/skills/casdoor-next-auth-kit/references/swagger.json +3686 -0
  38. package/dist/types-BPsPs5Rv.d.ts +337 -0
  39. package/dist/types-DqVXdUge.d.ts +121 -0
  40. package/package.json +69 -0
package/dist/cli.js ADDED
@@ -0,0 +1,437 @@
1
+ import {
2
+ AUTH_KIT_ENV_FILES,
3
+ buildAuthPrismaSchemaTemplate,
4
+ buildManagedEnvTemplate,
5
+ getMissingManagedEnvKeys
6
+ } from "./chunk-6E27SZ7V.js";
7
+
8
+ // src/cli/operations.ts
9
+ import fs2 from "fs";
10
+ import path2 from "path";
11
+ import { fileURLToPath } from "url";
12
+
13
+ // src/cli/fs.ts
14
+ import fs from "fs";
15
+ import path from "path";
16
+ var generatedHeader = "// generated by @foldspace-fe/casdoor-next-auth-kit\n";
17
+ var customBegin = "// @foldspace-fe/casdoor-next-auth-kit:begin custom";
18
+ var customEnd = "// @foldspace-fe/casdoor-next-auth-kit:end custom";
19
+ function ensureDir(filePath) {
20
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
21
+ }
22
+ function writeGeneratedFile(filePath, content) {
23
+ ensureDir(filePath);
24
+ fs.writeFileSync(filePath, generatedHeader + content, "utf8");
25
+ }
26
+ function writeTextFile(filePath, content) {
27
+ ensureDir(filePath);
28
+ fs.writeFileSync(filePath, content, "utf8");
29
+ }
30
+ function exists(filePath) {
31
+ return fs.existsSync(filePath);
32
+ }
33
+ function read(filePath) {
34
+ return fs.readFileSync(filePath, "utf8");
35
+ }
36
+ function preserveCustomBlock(existing, next) {
37
+ const begin = existing.indexOf(customBegin);
38
+ const end = existing.indexOf(customEnd);
39
+ if (begin === -1 || end === -1 || end <= begin) return next;
40
+ const custom = existing.slice(begin, end + customEnd.length);
41
+ const targetBegin = next.indexOf(customBegin);
42
+ const targetEnd = next.indexOf(customEnd);
43
+ if (targetBegin === -1 || targetEnd === -1 || targetEnd <= targetBegin) return next;
44
+ return next.slice(0, targetBegin) + custom + next.slice(targetEnd + customEnd.length);
45
+ }
46
+ function removePath(filePath) {
47
+ fs.rmSync(filePath, { force: true, recursive: true });
48
+ }
49
+
50
+ // src/cli/templates.ts
51
+ function authLoginRouteTemplate() {
52
+ return `import { loginHandler } from '../../auth-config';
53
+
54
+ export const dynamic = 'force-dynamic';
55
+
56
+ export const GET = loginHandler;
57
+ `;
58
+ }
59
+ function authSignupRouteTemplate() {
60
+ return `import { signupHandler } from '../../auth-config';
61
+
62
+ export const dynamic = 'force-dynamic';
63
+
64
+ export const GET = signupHandler;
65
+ `;
66
+ }
67
+ function authorizeRouteTemplate() {
68
+ return `import { authorizeHandler } from '../../../auth-config';
69
+
70
+ export const dynamic = 'force-dynamic';
71
+
72
+ export const GET = authorizeHandler;
73
+ `;
74
+ }
75
+ function signupAuthorizeRouteTemplate() {
76
+ return `import { authorizeHandler } from '../../../auth-config';
77
+
78
+ export const dynamic = 'force-dynamic';
79
+
80
+ export const GET = authorizeHandler;
81
+ `;
82
+ }
83
+ function callbackRouteTemplate() {
84
+ return `import { callbackHandler } from '../auth-config';
85
+
86
+ export const dynamic = 'force-dynamic';
87
+
88
+ export const GET = callbackHandler;
89
+ `;
90
+ }
91
+ function logoutRouteTemplate() {
92
+ return `import { logoutHandler } from '../auth-config';
93
+
94
+ export const dynamic = 'force-dynamic';
95
+
96
+ export const GET = logoutHandler;
97
+ `;
98
+ }
99
+ function authConfigTemplate() {
100
+ return `import {
101
+ createCallbackHandler,
102
+ createCasdoorApiProxyHandler,
103
+ createCasdoorCommerceProxyHandler,
104
+ createAuthorizeRouteHandler,
105
+ createLoginRouteHandler,
106
+ createLogoutHandler,
107
+ createNextAuthOptions,
108
+ createNextAuthRouteHandler,
109
+ createSignupRouteHandler,
110
+ type AuthBusinessAdapter,
111
+ type AuthKitConfig,
112
+ type AuthPersistenceAdapter,
113
+ type AuthUser,
114
+ } from '@foldspace-fe/casdoor-next-auth-kit';
115
+ import { db } from '@/lib/db';
116
+ import { isGlobalAdminEmail } from '@/lib/auth-roles';
117
+ import { syncUserRecord } from '@/lib/user-record';
118
+
119
+ export function createAuthKitConfig(): AuthKitConfig {
120
+ return {
121
+ appUrl: process.env.APP_URL || process.env.NEXTAUTH_URL || '',
122
+ nextauthSecret: process.env.NEXTAUTH_SECRET || 'dev-nextauth-secret',
123
+ casdoor: {
124
+ serverUrl: process.env.NEXT_PUBLIC_CASDOOR_SERVER_URL || process.env.CASDOOR_SERVER_URL || '',
125
+ clientId: process.env.NEXT_PUBLIC_CASDOOR_CLIENT_ID || process.env.CASDOOR_CLIENT_ID || '',
126
+ clientSecret: process.env.CASDOOR_CLIENT_SECRET || '',
127
+ appName: process.env.NEXT_PUBLIC_CASDOOR_APP_NAME || '',
128
+ organizationName: process.env.NEXT_PUBLIC_CASDOOR_ORGANIZATION_NAME || '',
129
+ redirectPath: process.env.NEXT_PUBLIC_CASDOOR_REDIRECT_PATH || '/callback',
130
+ signinPath: process.env.NEXT_PUBLIC_CASDOOR_SIGNIN_PATH || '/login/oauth/authorize',
131
+ },
132
+ };
133
+ }
134
+
135
+ const authKitConfig = createAuthKitConfig();
136
+
137
+ const adapter: AuthBusinessAdapter = {
138
+ isAdminEmail: isGlobalAdminEmail,
139
+ };
140
+
141
+ const persistence: AuthPersistenceAdapter = {
142
+ async syncAuthUser(user) {
143
+ await syncUserRecord(user);
144
+ },
145
+ async findAuthUser({ id, email }) {
146
+ const user = id
147
+ ? await db.user.findUnique({
148
+ where: { id },
149
+ select: {
150
+ id: true,
151
+ name: true,
152
+ email: true,
153
+ image: true,
154
+ tokenBalance: true,
155
+ isVip: true,
156
+ isAdmin: true,
157
+ },
158
+ })
159
+ : email
160
+ ? await db.user.findFirst({
161
+ where: { email },
162
+ select: {
163
+ id: true,
164
+ name: true,
165
+ email: true,
166
+ image: true,
167
+ tokenBalance: true,
168
+ isVip: true,
169
+ isAdmin: true,
170
+ },
171
+ })
172
+ : null;
173
+
174
+ if (!user) {
175
+ return null;
176
+ }
177
+
178
+ return {
179
+ id: user.id,
180
+ name: user.name,
181
+ email: user.email,
182
+ image: user.image,
183
+ tokenBalance: Number(user.tokenBalance ?? 2580),
184
+ isVip: Boolean(user.isVip ?? true),
185
+ isAdmin: Boolean(user.isAdmin) || isGlobalAdminEmail(user.email),
186
+ } satisfies AuthUser;
187
+ },
188
+ };
189
+
190
+ export const loginHandler = createLoginRouteHandler(authKitConfig);
191
+ export const signupHandler = createSignupRouteHandler(authKitConfig);
192
+ export const authorizeHandler = createAuthorizeRouteHandler(authKitConfig);
193
+ export const callbackHandler = createCallbackHandler({
194
+ config: authKitConfig,
195
+ adapter,
196
+ persistence,
197
+ });
198
+ export const logoutHandler = createLogoutHandler(authKitConfig);
199
+ export const authOptions = createNextAuthOptions({
200
+ config: authKitConfig,
201
+ adapter,
202
+ persistence,
203
+ });
204
+ export const nextAuthHandlers = createNextAuthRouteHandler({
205
+ config: authKitConfig,
206
+ adapter,
207
+ persistence,
208
+ });
209
+ export const apiProxyHandler = createCasdoorApiProxyHandler(authKitConfig, '/auth/api', '/api');
210
+ export const commerceProxyHandler = createCasdoorCommerceProxyHandler(authKitConfig, '/auth/api/commerce', '/api/commerce');
211
+ `;
212
+ }
213
+ function nextAuthRouteTemplate() {
214
+ return `import { nextAuthHandlers } from '../../../auth-config';
215
+
216
+ export const dynamic = 'force-dynamic';
217
+
218
+ export const GET = nextAuthHandlers.GET;
219
+ export const POST = nextAuthHandlers.POST;
220
+ `;
221
+ }
222
+ function authIndexHtmlTemplate() {
223
+ return `export { AUTH_INDEX_HTML, createAuthIndexHtml } from '@foldspace-fe/casdoor-next-auth-kit';
224
+ `;
225
+ }
226
+ function prismaSchemaTemplate() {
227
+ return buildAuthPrismaSchemaTemplate();
228
+ }
229
+ function apiProxyRouteTemplate() {
230
+ return `import { apiProxyHandler } from '../../../auth-config';
231
+
232
+ export const dynamic = 'force-dynamic';
233
+
234
+ export const GET = apiProxyHandler;
235
+ export const HEAD = apiProxyHandler;
236
+ export const POST = apiProxyHandler;
237
+ export const PUT = apiProxyHandler;
238
+ export const PATCH = apiProxyHandler;
239
+ export const DELETE = apiProxyHandler;
240
+ export const OPTIONS = apiProxyHandler;
241
+ `;
242
+ }
243
+ function commerceProxyRouteTemplate() {
244
+ return `import { commerceProxyHandler } from '../../../../auth-config';
245
+
246
+ export const dynamic = 'force-dynamic';
247
+
248
+ export const GET = commerceProxyHandler;
249
+ export const HEAD = commerceProxyHandler;
250
+ export const POST = commerceProxyHandler;
251
+ export const PUT = commerceProxyHandler;
252
+ export const PATCH = commerceProxyHandler;
253
+ export const DELETE = commerceProxyHandler;
254
+ export const OPTIONS = commerceProxyHandler;
255
+ `;
256
+ }
257
+ function envTemplate(file, existingContent = "") {
258
+ return buildManagedEnvTemplate(file, existingContent);
259
+ }
260
+
261
+ // src/cli/operations.ts
262
+ var projectRoot = process.cwd();
263
+ var distRoot = path2.dirname(fileURLToPath(import.meta.url));
264
+ var canonicalSkillPaths = [
265
+ path2.join(distRoot, "skills/casdoor-next-auth-kit"),
266
+ path2.resolve(distRoot, "..", "..", "..", "skills/casdoor-next-auth-kit")
267
+ ];
268
+ var skillTarget = ".agents/skills/casdoor-next-auth-kit";
269
+ var targets = [
270
+ ["app/(auth-kit)/auth-config.ts", authConfigTemplate],
271
+ ["app/(auth-kit)/auth/login/route.ts", authLoginRouteTemplate],
272
+ ["app/(auth-kit)/auth/signup/route.ts", authSignupRouteTemplate],
273
+ ["app/(auth-kit)/login/oauth/authorize/route.ts", authorizeRouteTemplate],
274
+ ["app/(auth-kit)/signup/oauth/authorize/route.ts", signupAuthorizeRouteTemplate],
275
+ ["app/(auth-kit)/auth/api/[...path]/route.ts", apiProxyRouteTemplate],
276
+ ["app/(auth-kit)/api/auth/[...nextauth]/route.ts", nextAuthRouteTemplate],
277
+ ["app/(auth-kit)/callback/route.ts", callbackRouteTemplate],
278
+ ["app/(auth-kit)/logout/route.ts", logoutRouteTemplate],
279
+ ["app/(auth-kit)/auth/api/commerce/[...path]/route.ts", commerceProxyRouteTemplate],
280
+ ["app/(auth-kit)/index-html.ts", authIndexHtmlTemplate],
281
+ ["prisma/auth-kit.prisma", prismaSchemaTemplate]
282
+ ];
283
+ var deprecatedTargets = [
284
+ "app/(auth-kit)/api/casdoor/[...path]/route.ts",
285
+ "app/(auth-kit)/api/casdoor/commerce/[...path]/route.ts",
286
+ "app/(auth-kit)/auth/api/casdoor/[...path]/route.ts",
287
+ "app/(auth-kit)/auth/api/casdoor/commerce/[...path]/route.ts",
288
+ "app/(auth-kit)/login/route.ts",
289
+ "app/(auth-kit)/signup/route.ts",
290
+ "app/(auth-kit)/signup/oauth/authorize/route.ts",
291
+ "app/auth/index-html.ts",
292
+ "app/auth/libs/index.ts",
293
+ "app/auth/libs/auth-config.ts",
294
+ "app/auth/libs/casdoor-config.ts",
295
+ "app/auth/libs/session-token.ts",
296
+ "app/auth/libs/oauth-state.ts",
297
+ "app/auth/libs/page-proxy.ts",
298
+ "app/auth/libs/api-proxy.ts",
299
+ "app/auth/libs/casdoor-oauth.ts",
300
+ "app/auth/libs/nextauth-route.ts",
301
+ "app/auth/libs",
302
+ "lib/auth-kit/index.ts",
303
+ "lib/auth-kit/index-html.ts",
304
+ "lib/auth-kit",
305
+ "lib/casdoor-entry.ts",
306
+ "lib/auth.ts",
307
+ "lib/public-origin.ts",
308
+ "lib/request-security.ts",
309
+ "lib/auth-redirect.ts"
310
+ ];
311
+ function logCreated(filePath) {
312
+ console.log(`+ ${path2.relative(projectRoot, filePath)}`);
313
+ }
314
+ function logUpdated(filePath) {
315
+ console.log(`~ ${path2.relative(projectRoot, filePath)}`);
316
+ }
317
+ function logRemoved(filePath) {
318
+ console.log(`- ${path2.relative(projectRoot, filePath)}`);
319
+ }
320
+ function syncManagedEnvFiles() {
321
+ for (const file of AUTH_KIT_ENV_FILES) {
322
+ const filePath = path2.join(projectRoot, file);
323
+ const existed = exists(filePath);
324
+ const current = existed ? read(filePath) : "";
325
+ const next = envTemplate(file, current);
326
+ if (!existed || current !== next) {
327
+ writeTextFile(filePath, next);
328
+ if (!existed) {
329
+ logCreated(filePath);
330
+ } else {
331
+ logUpdated(filePath);
332
+ }
333
+ }
334
+ }
335
+ }
336
+ function syncManagedSkillFile() {
337
+ const filePath = path2.join(projectRoot, skillTarget);
338
+ try {
339
+ const sourcePath = canonicalSkillPaths.find((candidate) => fs2.existsSync(candidate));
340
+ if (!sourcePath) {
341
+ throw new Error(`Unable to locate canonical skill directory. Checked: ${canonicalSkillPaths.join(", ")}`);
342
+ }
343
+ removePath(filePath);
344
+ fs2.mkdirSync(filePath, { recursive: true });
345
+ logCreated(filePath);
346
+ for (const entry of fs2.readdirSync(sourcePath, { withFileTypes: true })) {
347
+ const sourceEntry = path2.join(sourcePath, entry.name);
348
+ const targetEntry = path2.join(filePath, entry.name);
349
+ if (entry.isDirectory()) {
350
+ fs2.cpSync(sourceEntry, targetEntry, { recursive: true });
351
+ console.log(`+ ${path2.relative(projectRoot, targetEntry)}/`);
352
+ continue;
353
+ }
354
+ fs2.copyFileSync(sourceEntry, targetEntry);
355
+ console.log(`+ ${path2.relative(projectRoot, targetEntry)}`);
356
+ }
357
+ } catch (error) {
358
+ console.warn(`Skipped skill sync for ${skillTarget}: ${error instanceof Error ? error.message : String(error)}`);
359
+ }
360
+ }
361
+ async function initProject() {
362
+ for (const [rel, factory] of targets) {
363
+ const filePath = path2.join(projectRoot, rel);
364
+ if (!exists(filePath)) {
365
+ writeGeneratedFile(filePath, factory());
366
+ logCreated(filePath);
367
+ }
368
+ }
369
+ syncManagedEnvFiles();
370
+ syncManagedSkillFile();
371
+ console.log("Initialized casdoor-next-auth-kit managed files.");
372
+ }
373
+ async function updateProject() {
374
+ for (const rel of deprecatedTargets) {
375
+ const filePath = path2.join(projectRoot, rel);
376
+ if (exists(filePath)) {
377
+ removePath(filePath);
378
+ logRemoved(filePath);
379
+ }
380
+ }
381
+ for (const [rel, factory] of targets) {
382
+ const filePath = path2.join(projectRoot, rel);
383
+ const next = "// generated by @foldspace-fe/casdoor-next-auth-kit\n" + factory();
384
+ if (!exists(filePath)) {
385
+ writeGeneratedFile(filePath, factory());
386
+ logCreated(filePath);
387
+ continue;
388
+ }
389
+ const current = read(filePath);
390
+ const updated = preserveCustomBlock(current, next);
391
+ if (current !== updated) {
392
+ writeTextFile(filePath, updated);
393
+ logUpdated(filePath);
394
+ }
395
+ }
396
+ syncManagedEnvFiles();
397
+ syncManagedSkillFile();
398
+ console.log("Updated managed route shells, env files, and skill file.");
399
+ }
400
+ async function checkProject() {
401
+ const missingRoutes = targets.filter(([rel]) => !exists(path2.join(projectRoot, rel))).map(([rel]) => rel);
402
+ const missingEnv = AUTH_KIT_ENV_FILES.filter((file) => {
403
+ const filePath = path2.join(projectRoot, file);
404
+ if (!exists(filePath)) {
405
+ return true;
406
+ }
407
+ return getMissingManagedEnvKeys(read(filePath)).length > 0;
408
+ });
409
+ const skillDir = path2.join(projectRoot, skillTarget);
410
+ const missingSkill = exists(path2.join(skillDir, "SKILL.md")) ? [] : [path2.join(skillTarget, "SKILL.md")];
411
+ const missing = [...missingRoutes, ...missingEnv, ...missingSkill];
412
+ if (missing.length > 0) {
413
+ console.error("Missing generated files:");
414
+ for (const rel of missing) {
415
+ console.error("- " + rel);
416
+ }
417
+ process.exitCode = 1;
418
+ return;
419
+ }
420
+ console.log("All managed files are present.");
421
+ }
422
+
423
+ // src/cli/index.ts
424
+ async function runCli(argv) {
425
+ const command = argv[0] ?? "help";
426
+ if (command === "init") return initProject();
427
+ if (command === "update") return updateProject();
428
+ if (command === "check") return checkProject();
429
+ console.log("Usage: npx @foldspace-fe/casdoor-next-auth-kit <init|update|check>");
430
+ }
431
+
432
+ // src/cli.ts
433
+ runCli(process.argv.slice(2)).catch((error) => {
434
+ console.error(error instanceof Error ? error.message : error);
435
+ process.exit(1);
436
+ });
437
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cli/operations.ts","../src/cli/fs.ts","../src/cli/templates.ts","../src/cli/index.ts","../src/cli.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport { AUTH_KIT_ENV_FILES, getMissingManagedEnvKeys } from '../core/env';\nimport { exists, preserveCustomBlock, read, removePath, writeGeneratedFile, writeTextFile } from './fs';\nimport {\n apiProxyRouteTemplate,\n authConfigTemplate,\n authIndexHtmlTemplate,\n authLoginRouteTemplate,\n authSignupRouteTemplate,\n authorizeRouteTemplate,\n callbackRouteTemplate,\n commerceProxyRouteTemplate,\n envTemplate,\n logoutRouteTemplate,\n nextAuthRouteTemplate,\n prismaSchemaTemplate,\n signupAuthorizeRouteTemplate,\n} from './templates';\n\nconst projectRoot = process.cwd();\nconst distRoot = path.dirname(fileURLToPath(import.meta.url));\nconst canonicalSkillPaths = [\n path.join(distRoot, 'skills/casdoor-next-auth-kit'),\n path.resolve(distRoot, '..', '..', '..', 'skills/casdoor-next-auth-kit'),\n];\nconst skillTarget = '.agents/skills/casdoor-next-auth-kit';\n\nconst targets = [\n ['app/(auth-kit)/auth-config.ts', authConfigTemplate],\n ['app/(auth-kit)/auth/login/route.ts', authLoginRouteTemplate],\n ['app/(auth-kit)/auth/signup/route.ts', authSignupRouteTemplate],\n ['app/(auth-kit)/login/oauth/authorize/route.ts', authorizeRouteTemplate],\n ['app/(auth-kit)/signup/oauth/authorize/route.ts', signupAuthorizeRouteTemplate],\n ['app/(auth-kit)/auth/api/[...path]/route.ts', apiProxyRouteTemplate],\n ['app/(auth-kit)/api/auth/[...nextauth]/route.ts', nextAuthRouteTemplate],\n ['app/(auth-kit)/callback/route.ts', callbackRouteTemplate],\n ['app/(auth-kit)/logout/route.ts', logoutRouteTemplate],\n ['app/(auth-kit)/auth/api/commerce/[...path]/route.ts', commerceProxyRouteTemplate],\n ['app/(auth-kit)/index-html.ts', authIndexHtmlTemplate],\n ['prisma/auth-kit.prisma', prismaSchemaTemplate],\n] as const;\n\nconst deprecatedTargets = [\n 'app/(auth-kit)/api/casdoor/[...path]/route.ts',\n 'app/(auth-kit)/api/casdoor/commerce/[...path]/route.ts',\n 'app/(auth-kit)/auth/api/casdoor/[...path]/route.ts',\n 'app/(auth-kit)/auth/api/casdoor/commerce/[...path]/route.ts',\n 'app/(auth-kit)/login/route.ts',\n 'app/(auth-kit)/signup/route.ts',\n 'app/(auth-kit)/signup/oauth/authorize/route.ts',\n 'app/auth/index-html.ts',\n 'app/auth/libs/index.ts',\n 'app/auth/libs/auth-config.ts',\n 'app/auth/libs/casdoor-config.ts',\n 'app/auth/libs/session-token.ts',\n 'app/auth/libs/oauth-state.ts',\n 'app/auth/libs/page-proxy.ts',\n 'app/auth/libs/api-proxy.ts',\n 'app/auth/libs/casdoor-oauth.ts',\n 'app/auth/libs/nextauth-route.ts',\n 'app/auth/libs',\n 'lib/auth-kit/index.ts',\n 'lib/auth-kit/index-html.ts',\n 'lib/auth-kit',\n 'lib/casdoor-entry.ts',\n 'lib/auth.ts',\n 'lib/public-origin.ts',\n 'lib/request-security.ts',\n 'lib/auth-redirect.ts',\n] as const;\n\nfunction logCreated(filePath: string) {\n console.log(`+ ${path.relative(projectRoot, filePath)}`);\n}\n\nfunction logUpdated(filePath: string) {\n console.log(`~ ${path.relative(projectRoot, filePath)}`);\n}\n\nfunction logRemoved(filePath: string) {\n console.log(`- ${path.relative(projectRoot, filePath)}`);\n}\n\nfunction syncManagedEnvFiles() {\n for (const file of AUTH_KIT_ENV_FILES) {\n const filePath = path.join(projectRoot, file);\n const existed = exists(filePath);\n const current = existed ? read(filePath) : '';\n const next = envTemplate(file, current);\n if (!existed || current !== next) {\n writeTextFile(filePath, next);\n if (!existed) {\n logCreated(filePath);\n } else {\n logUpdated(filePath);\n }\n }\n }\n}\n\nfunction syncManagedSkillFile() {\n const filePath = path.join(projectRoot, skillTarget);\n try {\n const sourcePath = canonicalSkillPaths.find((candidate) => fs.existsSync(candidate));\n if (!sourcePath) {\n throw new Error(`Unable to locate canonical skill directory. Checked: ${canonicalSkillPaths.join(', ')}`);\n }\n removePath(filePath);\n fs.mkdirSync(filePath, { recursive: true });\n logCreated(filePath);\n for (const entry of fs.readdirSync(sourcePath, { withFileTypes: true })) {\n const sourceEntry = path.join(sourcePath, entry.name);\n const targetEntry = path.join(filePath, entry.name);\n if (entry.isDirectory()) {\n fs.cpSync(sourceEntry, targetEntry, { recursive: true });\n console.log(`+ ${path.relative(projectRoot, targetEntry)}/`);\n continue;\n }\n fs.copyFileSync(sourceEntry, targetEntry);\n console.log(`+ ${path.relative(projectRoot, targetEntry)}`);\n }\n } catch (error) {\n console.warn(`Skipped skill sync for ${skillTarget}: ${error instanceof Error ? error.message : String(error)}`);\n }\n}\n\nexport async function initProject() {\n for (const [rel, factory] of targets) {\n const filePath = path.join(projectRoot, rel);\n if (!exists(filePath)) {\n writeGeneratedFile(filePath, factory());\n logCreated(filePath);\n }\n }\n\n syncManagedEnvFiles();\n syncManagedSkillFile();\n console.log('Initialized casdoor-next-auth-kit managed files.');\n}\n\nexport async function updateProject() {\n for (const rel of deprecatedTargets) {\n const filePath = path.join(projectRoot, rel);\n if (exists(filePath)) {\n removePath(filePath);\n logRemoved(filePath);\n }\n }\n\n for (const [rel, factory] of targets) {\n const filePath = path.join(projectRoot, rel);\n const next = '// generated by @foldspace-fe/casdoor-next-auth-kit\\n' + factory();\n if (!exists(filePath)) {\n writeGeneratedFile(filePath, factory());\n logCreated(filePath);\n continue;\n }\n\n const current = read(filePath);\n const updated = preserveCustomBlock(current, next);\n if (current !== updated) {\n writeTextFile(filePath, updated);\n logUpdated(filePath);\n }\n }\n\n syncManagedEnvFiles();\n syncManagedSkillFile();\n console.log('Updated managed route shells, env files, and skill file.');\n}\n\nexport async function checkProject() {\n const missingRoutes = targets.filter(([rel]) => !exists(path.join(projectRoot, rel))).map(([rel]) => rel);\n const missingEnv = AUTH_KIT_ENV_FILES.filter((file) => {\n const filePath = path.join(projectRoot, file);\n if (!exists(filePath)) {\n return true;\n }\n return getMissingManagedEnvKeys(read(filePath)).length > 0;\n });\n const skillDir = path.join(projectRoot, skillTarget);\n const missingSkill = exists(path.join(skillDir, 'SKILL.md')) ? [] : [path.join(skillTarget, 'SKILL.md')];\n const missing = [...missingRoutes, ...missingEnv, ...missingSkill];\n\n if (missing.length > 0) {\n console.error('Missing generated files:');\n for (const rel of missing) {\n console.error('- ' + rel);\n }\n process.exitCode = 1;\n return;\n }\n\n console.log('All managed files are present.');\n}\n"," import fs from 'node:fs';\n import path from 'node:path';\n\n export const generatedHeader = '// generated by @foldspace-fe/casdoor-next-auth-kit\\n';\n export const customBegin = '// @foldspace-fe/casdoor-next-auth-kit:begin custom';\n export const customEnd = '// @foldspace-fe/casdoor-next-auth-kit:end custom';\n\nexport function ensureDir(filePath: string) {\n fs.mkdirSync(path.dirname(filePath), { recursive: true });\n}\n\nexport function writeGeneratedFile(filePath: string, content: string) {\n ensureDir(filePath);\n fs.writeFileSync(filePath, generatedHeader + content, 'utf8');\n}\n\nexport function writeTextFile(filePath: string, content: string) {\n ensureDir(filePath);\n fs.writeFileSync(filePath, content, 'utf8');\n}\n\nexport function exists(filePath: string) {\n return fs.existsSync(filePath);\n}\n\n export function read(filePath: string) {\n return fs.readFileSync(filePath, 'utf8');\n }\n\nexport function preserveCustomBlock(existing: string, next: string) {\n const begin = existing.indexOf(customBegin);\n const end = existing.indexOf(customEnd);\n if (begin === -1 || end === -1 || end <= begin) return next;\n const custom = existing.slice(begin, end + customEnd.length);\n const targetBegin = next.indexOf(customBegin);\n const targetEnd = next.indexOf(customEnd);\n if (targetBegin === -1 || targetEnd === -1 || targetEnd <= targetBegin) return next;\n return next.slice(0, targetBegin) + custom + next.slice(targetEnd + customEnd.length);\n}\n\nexport function removePath(filePath: string) {\n fs.rmSync(filePath, { force: true, recursive: true });\n}\n"," import { customBegin, customEnd } from './fs';\n import { buildAuthPrismaSchemaTemplate } from '../prisma/schema-template';\n import { AUTH_KIT_ENV_FILES, buildManagedEnvTemplate } from '../core/env';\n\nexport function authLoginRouteTemplate() {\n return `import { loginHandler } from '../../auth-config';\n\nexport const dynamic = 'force-dynamic';\n\nexport const GET = loginHandler;\n`;\n}\n\nexport function authSignupRouteTemplate() {\n return `import { signupHandler } from '../../auth-config';\n\nexport const dynamic = 'force-dynamic';\n\nexport const GET = signupHandler;\n`;\n}\n\nexport function authorizeRouteTemplate() {\n return `import { authorizeHandler } from '../../../auth-config';\n\nexport const dynamic = 'force-dynamic';\n\nexport const GET = authorizeHandler;\n`;\n}\n\nexport function signupAuthorizeRouteTemplate() {\n return `import { authorizeHandler } from '../../../auth-config';\n\nexport const dynamic = 'force-dynamic';\n\nexport const GET = authorizeHandler;\n`;\n}\n\nexport function callbackRouteTemplate() {\n return `import { callbackHandler } from '../auth-config';\n\nexport const dynamic = 'force-dynamic';\n\nexport const GET = callbackHandler;\n`;\n}\n\nexport function logoutRouteTemplate() {\n return `import { logoutHandler } from '../auth-config';\n\nexport const dynamic = 'force-dynamic';\n\nexport const GET = logoutHandler;\n`;\n}\n\nexport function authConfigTemplate() {\n return `import {\n createCallbackHandler,\n createCasdoorApiProxyHandler,\n createCasdoorCommerceProxyHandler,\n createAuthorizeRouteHandler,\n createLoginRouteHandler,\n createLogoutHandler,\n createNextAuthOptions,\n createNextAuthRouteHandler,\n createSignupRouteHandler,\n type AuthBusinessAdapter,\n type AuthKitConfig,\n type AuthPersistenceAdapter,\n type AuthUser,\n} from '@foldspace-fe/casdoor-next-auth-kit';\nimport { db } from '@/lib/db';\nimport { isGlobalAdminEmail } from '@/lib/auth-roles';\nimport { syncUserRecord } from '@/lib/user-record';\n\nexport function createAuthKitConfig(): AuthKitConfig {\n return {\n appUrl: process.env.APP_URL || process.env.NEXTAUTH_URL || '',\n nextauthSecret: process.env.NEXTAUTH_SECRET || 'dev-nextauth-secret',\n casdoor: {\n serverUrl: process.env.NEXT_PUBLIC_CASDOOR_SERVER_URL || process.env.CASDOOR_SERVER_URL || '',\n clientId: process.env.NEXT_PUBLIC_CASDOOR_CLIENT_ID || process.env.CASDOOR_CLIENT_ID || '',\n clientSecret: process.env.CASDOOR_CLIENT_SECRET || '',\n appName: process.env.NEXT_PUBLIC_CASDOOR_APP_NAME || '',\n organizationName: process.env.NEXT_PUBLIC_CASDOOR_ORGANIZATION_NAME || '',\n redirectPath: process.env.NEXT_PUBLIC_CASDOOR_REDIRECT_PATH || '/callback',\n signinPath: process.env.NEXT_PUBLIC_CASDOOR_SIGNIN_PATH || '/login/oauth/authorize',\n },\n };\n}\n\nconst authKitConfig = createAuthKitConfig();\n\nconst adapter: AuthBusinessAdapter = {\n isAdminEmail: isGlobalAdminEmail,\n};\n\nconst persistence: AuthPersistenceAdapter = {\n async syncAuthUser(user) {\n await syncUserRecord(user);\n },\n async findAuthUser({ id, email }) {\n const user = id\n ? await db.user.findUnique({\n where: { id },\n select: {\n id: true,\n name: true,\n email: true,\n image: true,\n tokenBalance: true,\n isVip: true,\n isAdmin: true,\n },\n })\n : email\n ? await db.user.findFirst({\n where: { email },\n select: {\n id: true,\n name: true,\n email: true,\n image: true,\n tokenBalance: true,\n isVip: true,\n isAdmin: true,\n },\n })\n : null;\n\n if (!user) {\n return null;\n }\n\n return {\n id: user.id,\n name: user.name,\n email: user.email,\n image: user.image,\n tokenBalance: Number(user.tokenBalance ?? 2580),\n isVip: Boolean(user.isVip ?? true),\n isAdmin: Boolean(user.isAdmin) || isGlobalAdminEmail(user.email),\n } satisfies AuthUser;\n },\n};\n\nexport const loginHandler = createLoginRouteHandler(authKitConfig);\nexport const signupHandler = createSignupRouteHandler(authKitConfig);\nexport const authorizeHandler = createAuthorizeRouteHandler(authKitConfig);\nexport const callbackHandler = createCallbackHandler({\n config: authKitConfig,\n adapter,\n persistence,\n});\nexport const logoutHandler = createLogoutHandler(authKitConfig);\nexport const authOptions = createNextAuthOptions({\n config: authKitConfig,\n adapter,\n persistence,\n});\nexport const nextAuthHandlers = createNextAuthRouteHandler({\n config: authKitConfig,\n adapter,\n persistence,\n});\nexport const apiProxyHandler = createCasdoorApiProxyHandler(authKitConfig, '/auth/api', '/api');\nexport const commerceProxyHandler = createCasdoorCommerceProxyHandler(authKitConfig, '/auth/api/commerce', '/api/commerce');\n`;\n}\n\nexport function nextAuthRouteTemplate() {\n return `import { nextAuthHandlers } from '../../../auth-config';\n\nexport const dynamic = 'force-dynamic';\n\nexport const GET = nextAuthHandlers.GET;\nexport const POST = nextAuthHandlers.POST;\n`;\n}\n\n export function authIndexHtmlTemplate() {\n return `export { AUTH_INDEX_HTML, createAuthIndexHtml } from '@foldspace-fe/casdoor-next-auth-kit';\n`;\n }\n\n export function prismaSchemaTemplate() {\n return buildAuthPrismaSchemaTemplate();\n }\n\nexport function apiProxyRouteTemplate() {\n return `import { apiProxyHandler } from '../../../auth-config';\n\nexport const dynamic = 'force-dynamic';\n\nexport const GET = apiProxyHandler;\nexport const HEAD = apiProxyHandler;\nexport const POST = apiProxyHandler;\nexport const PUT = apiProxyHandler;\nexport const PATCH = apiProxyHandler;\nexport const DELETE = apiProxyHandler;\nexport const OPTIONS = apiProxyHandler;\n`;\n}\n\nexport function commerceProxyRouteTemplate() {\n return `import { commerceProxyHandler } from '../../../../auth-config';\n\nexport const dynamic = 'force-dynamic';\n\nexport const GET = commerceProxyHandler;\nexport const HEAD = commerceProxyHandler;\nexport const POST = commerceProxyHandler;\nexport const PUT = commerceProxyHandler;\nexport const PATCH = commerceProxyHandler;\nexport const DELETE = commerceProxyHandler;\nexport const OPTIONS = commerceProxyHandler;\n`;\n}\n\n export function envTemplate(file: typeof AUTH_KIT_ENV_FILES[number], existingContent = '') {\n return buildManagedEnvTemplate(file, existingContent);\n }\n","import { initProject, checkProject, updateProject } from './operations';\n\nexport async function runCli(argv: string[]) {\n const command = argv[0] ?? 'help';\n if (command === 'init') return initProject();\n if (command === 'update') return updateProject();\n if (command === 'check') return checkProject();\n console.log('Usage: npx @foldspace-fe/casdoor-next-auth-kit <init|update|check>');\n}\n","import { runCli } from './cli/index';\n\nrunCli(process.argv.slice(2)).catch((error) => {\n console.error(error instanceof Error ? error.message : error);\n process.exit(1);\n});\n"],"mappings":";;;;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AAC;","names":["fs","path","path","fs"]}
@@ -0,0 +1,77 @@
1
+ import { A as AuthKitConfig, c as AuthUser, M as ManagedEnvFile, d as ManagedEnvVariableDefinition, e as AuthIndexHtmlOptions, P as PrismaSchemaModelDefinition } from './types-DqVXdUge.js';
2
+ export { a as AuthBusinessAdapter, f as AuthDatabaseContract, g as AuthDatabaseFieldRequirement, h as AuthDatabaseTableRequirement, b as AuthPersistenceAdapter, i as AuthRuntimeContext, C as CasdoorUserInfo, O as OAuthTokens, j as PrismaSchemaFieldDefinition } from './types-DqVXdUge.js';
3
+ import { JWTDecodeParams, JWT, JWTEncodeParams } from 'next-auth/jwt';
4
+ export { createAuthorizeEntryResponse, createCasdoorApiProxyHandler, createCasdoorCommerceProxyHandler, createCasdoorPageProxyHandler, createLoginEntryResponse, createSignupEntryResponse, decodeCasdoorAccessToken, exchangeCasdoorOAuthToken, exchangeCodeForToken, fetchCasdoorUserInfo, getCasdoorAuthorizeUrl, getCasdoorConfig, getCasdoorTokenUrl, getCasdoorUserInfoUrl } from './casdoor/index.js';
5
+ export { C as CallbackHandlerOptions, c as createCallbackHandler, a as createCallbackResponse } from './callback-BTzHQK_r.js';
6
+ export { createAuthorizeRouteHandler, createLoginRouteHandler, createLogoutHandler, createSignupRouteHandler } from './next/index.js';
7
+ export { A as AuthSession, a as AuthSessionUser, b as AuthTokenPayload, N as NextAuthRouteOptions, c as createNextAuthOptions, d as createNextAuthRouteHandler } from './options-JUwZSXu2.js';
8
+ export { f as BillingActionExecutor, s as BillingActionKind, B as BillingActionPayload, d as BillingApiClient, c as BillingCatalogConfig, t as BillingConversionRule, r as BillingCoreContextValue, u as BillingCreditsContextValue, m as BillingCreditsState, g as BillingDefaults, n as BillingEntitlementState, v as BillingInterval, a as BillingItem, w as BillingItemKind, e as BillingLoaders, k as BillingOrderHistoryItem, l as BillingPaymentHistoryItem, x as BillingProductContextValue, y as BillingProductPurchaseConfig, q as BillingProductSnapshot, j as BillingProductState, p as BillingPurchaseStatus, b as BillingRuntimeConfig, o as BillingStatusState, z as BillingSubscriptionContextValue, i as BillingSubscriptionHistoryItem, A as BillingSubscriptionPurchaseConfig, h as BillingSubscriptionState } from './types-BPsPs5Rv.js';
9
+ export { buildBillingActionPayload, deriveBillingCreditsState, deriveBillingEntitlements, filterProductsByKind, normalizeBillingCatalogConfig, normalizeBillingPurchaseStatus, normalizeBillingRuntimeConfig, resolveBillingInterval, resolveBillingItem, resolveBillingProductSnapshot, resolveBillingSubscriptionProduct } from './billing/index.js';
10
+ import 'next/server';
11
+ import 'next-auth';
12
+
13
+ declare function normalizeAuthKitConfig(config: AuthKitConfig): AuthKitConfig;
14
+
15
+ declare const PUBLIC_ORIGIN_COOKIE_NAME = "auth_origin";
16
+ declare function getRequestOrigin(request: Request, appUrl?: string): string;
17
+ declare function setPublicOriginCookie(response: {
18
+ cookies: {
19
+ set: (...args: any[]) => void;
20
+ };
21
+ }, origin: string, secure: boolean): void;
22
+ declare function clearPublicOriginCookie(response: {
23
+ cookies: {
24
+ set: (...args: any[]) => void;
25
+ };
26
+ }, secure: boolean): void;
27
+ declare function getStoredPublicOrigin(request: Request): string | null;
28
+
29
+ declare function isSecureRequest(request: Request, appUrl?: string): boolean;
30
+
31
+ declare function buildAuthJumpHref(kind: 'login' | 'signup', redirect?: string, basePath?: string): string;
32
+ declare function resolvePostLoginRedirect(user: AuthUser, fallback?: string): string;
33
+
34
+ declare const AUTH_REDIRECT_COOKIE_NAME = "auth_redirect";
35
+ declare function getAuthRedirectTarget(request: Request): string | null;
36
+ declare function setAuthRedirectCookie(response: {
37
+ cookies: {
38
+ set: (...args: any[]) => void;
39
+ };
40
+ }, target: string, secure: boolean): void;
41
+ declare function clearAuthRedirectCookie(response: {
42
+ cookies: {
43
+ set: (...args: any[]) => void;
44
+ };
45
+ }, secure: boolean): void;
46
+
47
+ declare function getGlobalAdminEmails(): string[];
48
+ declare function isGlobalAdminEmail(email: string | null | undefined): boolean;
49
+
50
+ declare const AUTH_KIT_ENV_FILES: ManagedEnvFile[];
51
+ declare const AUTH_KIT_ENV_VARIABLES: ManagedEnvVariableDefinition[];
52
+ declare function getManagedEnvValue(definition: ManagedEnvVariableDefinition, file: ManagedEnvFile): string;
53
+ declare function buildManagedEnvTemplate(file: ManagedEnvFile, existingContent?: string): string;
54
+ declare function getMissingManagedEnvKeys(content: string): string[];
55
+ declare function sanitizeExistingEnvContent(content: string): string;
56
+
57
+ declare function createAuthIndexHtml(options?: AuthIndexHtmlOptions): string;
58
+ declare const AUTH_INDEX_HTML: string;
59
+
60
+ declare const pkceCookiePrefix = "pkce_code_verifier";
61
+ interface StatePayload {
62
+ nonce: string;
63
+ issuedAt: number;
64
+ }
65
+ declare function generateStateToken(): string;
66
+ declare function getPkceCookieName(state: string): string;
67
+ declare function verifyState(stateFromUrl: string): Promise<boolean>;
68
+ declare function parseStateToken(token: string | null | undefined): StatePayload | null;
69
+ declare function verifyStateToken(token: string | null | undefined): boolean;
70
+
71
+ declare function encodeSessionToken(params: JWTEncodeParams): Promise<string>;
72
+ declare function decodeSessionToken(params: JWTDecodeParams): Promise<JWT | null>;
73
+
74
+ declare const AUTH_PRISMA_SCHEMA_MODELS: PrismaSchemaModelDefinition[];
75
+ declare function buildAuthPrismaSchemaTemplate(models?: PrismaSchemaModelDefinition[]): string;
76
+
77
+ export { AUTH_INDEX_HTML, AUTH_KIT_ENV_FILES, AUTH_KIT_ENV_VARIABLES, AUTH_PRISMA_SCHEMA_MODELS, AUTH_REDIRECT_COOKIE_NAME, AuthIndexHtmlOptions, AuthKitConfig, AuthUser, ManagedEnvFile, ManagedEnvVariableDefinition, PUBLIC_ORIGIN_COOKIE_NAME, PrismaSchemaModelDefinition, type StatePayload, buildAuthJumpHref, buildAuthPrismaSchemaTemplate, buildManagedEnvTemplate, clearAuthRedirectCookie, clearPublicOriginCookie, createAuthIndexHtml, decodeSessionToken, encodeSessionToken, generateStateToken, getAuthRedirectTarget, getGlobalAdminEmails, getManagedEnvValue, getMissingManagedEnvKeys, getPkceCookieName, getRequestOrigin, getStoredPublicOrigin, isGlobalAdminEmail, isSecureRequest, normalizeAuthKitConfig, parseStateToken, pkceCookiePrefix, resolvePostLoginRedirect, sanitizeExistingEnvContent, setAuthRedirectCookie, setPublicOriginCookie, verifyState, verifyStateToken };