@foldspace-fe/casdoor-next-auth-kit 0.1.6 → 0.1.8
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/README.md +0 -1
- package/dist/billing/index.d.ts +9 -4
- package/dist/billing/index.js +11 -4
- package/dist/casdoor/index.js +1 -1
- package/dist/chunk-NGKCQHB3.js +173 -0
- package/dist/chunk-NGKCQHB3.js.map +1 -0
- package/dist/{chunk-RGTVPBH7.js → chunk-O3FKI5NT.js} +13 -8
- package/dist/chunk-O3FKI5NT.js.map +1 -0
- package/dist/{chunk-6E27SZ7V.js → chunk-PFHMT4ZD.js} +42 -1
- package/dist/chunk-PFHMT4ZD.js.map +1 -0
- package/dist/{chunk-DONQHN4U.js → chunk-YXTDGBLC.js} +13 -3
- package/dist/chunk-YXTDGBLC.js.map +1 -0
- package/dist/cli.js +101 -39
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +15 -6
- package/dist/react/index.d.ts +3 -8
- package/dist/react/index.js +7 -12
- package/dist/react/index.js.map +1 -1
- package/dist/skills/casdoor-next-auth-kit/SKILL.md +241 -2
- package/dist/{types-BPsPs5Rv.d.ts → types-DwThfdu-.d.ts} +29 -4
- package/package.json +1 -1
- package/dist/chunk-6E27SZ7V.js.map +0 -1
- package/dist/chunk-DONQHN4U.js.map +0 -1
- package/dist/chunk-RGTVPBH7.js.map +0 -1
- package/dist/chunk-XMBHIEYL.js +0 -1
- package/dist/chunk-XMBHIEYL.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -2,8 +2,9 @@ import {
|
|
|
2
2
|
AUTH_KIT_ENV_FILES,
|
|
3
3
|
buildAuthPrismaSchemaTemplate,
|
|
4
4
|
buildManagedEnvTemplate,
|
|
5
|
-
getMissingManagedEnvKeys
|
|
6
|
-
|
|
5
|
+
getMissingManagedEnvKeys,
|
|
6
|
+
readManagedEnvValue
|
|
7
|
+
} from "./chunk-PFHMT4ZD.js";
|
|
7
8
|
|
|
8
9
|
// package.json
|
|
9
10
|
var package_default = {
|
|
@@ -75,8 +76,8 @@ var package_default = {
|
|
|
75
76
|
};
|
|
76
77
|
|
|
77
78
|
// src/cli/operations.ts
|
|
78
|
-
import
|
|
79
|
-
import
|
|
79
|
+
import fs3 from "fs";
|
|
80
|
+
import path3 from "path";
|
|
80
81
|
import { fileURLToPath } from "url";
|
|
81
82
|
|
|
82
83
|
// src/cli/fs.ts
|
|
@@ -117,6 +118,21 @@ function removePath(filePath) {
|
|
|
117
118
|
}
|
|
118
119
|
|
|
119
120
|
// src/cli/templates.ts
|
|
121
|
+
import fs2 from "fs";
|
|
122
|
+
import path2 from "path";
|
|
123
|
+
function getManagedEnvValue(key) {
|
|
124
|
+
for (const file of [".env.local", ".env", ".env.production", ".env.example"]) {
|
|
125
|
+
const filePath = path2.join(process.cwd(), file);
|
|
126
|
+
if (!fs2.existsSync(filePath)) {
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
const value = readManagedEnvValue(fs2.readFileSync(filePath, "utf8"), key);
|
|
130
|
+
if (value !== null) {
|
|
131
|
+
return value;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
120
136
|
function authLoginRouteTemplate() {
|
|
121
137
|
return `import { loginHandler } from '../../auth-config';
|
|
122
138
|
|
|
@@ -166,6 +182,12 @@ export const GET = logoutHandler;
|
|
|
166
182
|
`;
|
|
167
183
|
}
|
|
168
184
|
function authConfigTemplate() {
|
|
185
|
+
const billingPaymentSuccessHandlerImport = getManagedEnvValue("BILLING_PAYMENT_SUCCESS_HANDLER");
|
|
186
|
+
const billingPaymentFinishedHandlerImport = getManagedEnvValue("BILLING_PAYMENT_FINISHED_HANDLER");
|
|
187
|
+
const billingPaymentSuccessHandlerImportLine = billingPaymentSuccessHandlerImport ? `import { paymentSuccessHandler as billingPaymentSuccessHandler } from ${JSON.stringify(billingPaymentSuccessHandlerImport)};
|
|
188
|
+
` : "";
|
|
189
|
+
const billingPaymentFinishedHandlerImportLine = billingPaymentFinishedHandlerImport ? `import { paymentFinishedHandler as billingPaymentFinishedHandler } from ${JSON.stringify(billingPaymentFinishedHandlerImport)};
|
|
190
|
+
` : "";
|
|
169
191
|
return `import {
|
|
170
192
|
createCallbackHandler,
|
|
171
193
|
createCasdoorApiProxyHandler,
|
|
@@ -174,20 +196,19 @@ function authConfigTemplate() {
|
|
|
174
196
|
createLoginRouteHandler,
|
|
175
197
|
createLogoutHandler,
|
|
176
198
|
createNextAuthOptions,
|
|
177
|
-
createNextAuthRouteHandler,
|
|
178
199
|
createSignupRouteHandler,
|
|
179
200
|
type AuthBusinessAdapter,
|
|
180
201
|
type AuthKitConfig,
|
|
181
202
|
type AuthPersistenceAdapter,
|
|
182
203
|
type AuthUser,
|
|
183
204
|
} from '@foldspace-fe/casdoor-next-auth-kit';
|
|
184
|
-
import { db } from '@/lib/db';
|
|
205
|
+
${billingPaymentSuccessHandlerImportLine}${billingPaymentFinishedHandlerImportLine}import { db } from '@/lib/db';
|
|
185
206
|
import { isGlobalAdminEmail } from '@/lib/auth-roles';
|
|
186
207
|
import { syncUserRecord } from '@/lib/user-record';
|
|
187
208
|
|
|
188
209
|
export function createAuthKitConfig(): AuthKitConfig {
|
|
189
210
|
return {
|
|
190
|
-
appUrl: process.env.APP_URL ||
|
|
211
|
+
appUrl: process.env.APP_URL || '',
|
|
191
212
|
nextauthSecret: process.env.NEXTAUTH_SECRET || 'dev-nextauth-secret',
|
|
192
213
|
casdoor: {
|
|
193
214
|
serverUrl: process.env.NEXT_PUBLIC_CASDOOR_SERVER_URL || process.env.CASDOOR_SERVER_URL || '',
|
|
@@ -256,6 +277,9 @@ const persistence: AuthPersistenceAdapter = {
|
|
|
256
277
|
},
|
|
257
278
|
};
|
|
258
279
|
|
|
280
|
+
export const paymentSuccessHandler = ${billingPaymentSuccessHandlerImport ? "billingPaymentSuccessHandler" : "undefined"};
|
|
281
|
+
export const paymentFinishedHandler = ${billingPaymentFinishedHandlerImport ? "billingPaymentFinishedHandler" : "undefined"};
|
|
282
|
+
|
|
259
283
|
export const loginHandler = createLoginRouteHandler(authKitConfig);
|
|
260
284
|
export const signupHandler = createSignupRouteHandler(authKitConfig);
|
|
261
285
|
export const authorizeHandler = createAuthorizeRouteHandler(authKitConfig);
|
|
@@ -270,22 +294,56 @@ export const authOptions = createNextAuthOptions({
|
|
|
270
294
|
adapter,
|
|
271
295
|
persistence,
|
|
272
296
|
});
|
|
273
|
-
export const nextAuthHandlers = createNextAuthRouteHandler({
|
|
274
|
-
config: authKitConfig,
|
|
275
|
-
adapter,
|
|
276
|
-
persistence,
|
|
277
|
-
});
|
|
278
297
|
export const apiProxyHandler = createCasdoorApiProxyHandler(authKitConfig, '/auth/api', '/api');
|
|
279
298
|
export const commerceProxyHandler = createCasdoorCommerceProxyHandler(authKitConfig, '/auth/api/commerce', '/api/commerce');
|
|
280
299
|
`;
|
|
281
300
|
}
|
|
282
301
|
function nextAuthRouteTemplate() {
|
|
283
|
-
return `import
|
|
302
|
+
return `import NextAuth from 'next-auth';
|
|
303
|
+
import { createNextAuthOptions } from '@foldspace-fe/casdoor-next-auth-kit';
|
|
304
|
+
import { adapter, authKitConfig, persistence } from '../../../auth-config';
|
|
305
|
+
|
|
306
|
+
export const dynamic = 'force-dynamic';
|
|
307
|
+
export const runtime = 'nodejs';
|
|
308
|
+
|
|
309
|
+
const handler = NextAuth(
|
|
310
|
+
createNextAuthOptions({
|
|
311
|
+
config: authKitConfig,
|
|
312
|
+
adapter,
|
|
313
|
+
persistence,
|
|
314
|
+
}),
|
|
315
|
+
);
|
|
316
|
+
|
|
317
|
+
export const GET = handler;
|
|
318
|
+
export const POST = handler;
|
|
319
|
+
`;
|
|
320
|
+
}
|
|
321
|
+
function paymentSuccessRouteTemplate() {
|
|
322
|
+
return `import { createBillingPaymentSuccessRouteHandler } from '@foldspace-fe/casdoor-next-auth-kit';
|
|
323
|
+
import { authKitConfig, paymentSuccessHandler } from '../../../auth-config';
|
|
324
|
+
|
|
325
|
+
export const dynamic = 'force-dynamic';
|
|
326
|
+
export const runtime = 'nodejs';
|
|
327
|
+
|
|
328
|
+
export const GET = createBillingPaymentSuccessRouteHandler({
|
|
329
|
+
appUrl: authKitConfig.appUrl,
|
|
330
|
+
fallbackRedirect: '/auth/payment/finished',
|
|
331
|
+
handler: paymentSuccessHandler,
|
|
332
|
+
});
|
|
333
|
+
`;
|
|
334
|
+
}
|
|
335
|
+
function paymentFinishedRouteTemplate() {
|
|
336
|
+
return `import { createBillingPaymentFinishedRouteHandler } from '@foldspace-fe/casdoor-next-auth-kit';
|
|
337
|
+
import { authKitConfig, paymentFinishedHandler } from '../../../auth-config';
|
|
284
338
|
|
|
285
339
|
export const dynamic = 'force-dynamic';
|
|
340
|
+
export const runtime = 'nodejs';
|
|
286
341
|
|
|
287
|
-
export const GET =
|
|
288
|
-
|
|
342
|
+
export const GET = createBillingPaymentFinishedRouteHandler({
|
|
343
|
+
appUrl: authKitConfig.appUrl,
|
|
344
|
+
fallbackRedirect: '/',
|
|
345
|
+
handler: paymentFinishedHandler,
|
|
346
|
+
});
|
|
289
347
|
`;
|
|
290
348
|
}
|
|
291
349
|
function authIndexHtmlTemplate() {
|
|
@@ -329,10 +387,10 @@ function envTemplate(file, existingContent = "") {
|
|
|
329
387
|
|
|
330
388
|
// src/cli/operations.ts
|
|
331
389
|
var projectRoot = process.cwd();
|
|
332
|
-
var distRoot =
|
|
390
|
+
var distRoot = path3.dirname(fileURLToPath(import.meta.url));
|
|
333
391
|
var canonicalSkillPaths = [
|
|
334
|
-
|
|
335
|
-
|
|
392
|
+
path3.join(distRoot, "skills/casdoor-next-auth-kit"),
|
|
393
|
+
path3.resolve(distRoot, "..", "..", "..", "skills/casdoor-next-auth-kit")
|
|
336
394
|
];
|
|
337
395
|
var skillTarget = ".agents/skills/casdoor-next-auth-kit";
|
|
338
396
|
var targets = [
|
|
@@ -343,6 +401,8 @@ var targets = [
|
|
|
343
401
|
["app/(auth-kit)/signup/oauth/authorize/route.ts", signupAuthorizeRouteTemplate],
|
|
344
402
|
["app/(auth-kit)/auth/api/[...path]/route.ts", apiProxyRouteTemplate],
|
|
345
403
|
["app/(auth-kit)/api/auth/[...nextauth]/route.ts", nextAuthRouteTemplate],
|
|
404
|
+
["app/(auth-kit)/auth/payment/success/route.ts", paymentSuccessRouteTemplate],
|
|
405
|
+
["app/(auth-kit)/auth/payment/finished/route.ts", paymentFinishedRouteTemplate],
|
|
346
406
|
["app/(auth-kit)/callback/route.ts", callbackRouteTemplate],
|
|
347
407
|
["app/(auth-kit)/logout/route.ts", logoutRouteTemplate],
|
|
348
408
|
["app/(auth-kit)/auth/api/commerce/[...path]/route.ts", commerceProxyRouteTemplate],
|
|
@@ -357,6 +417,8 @@ var deprecatedTargets = [
|
|
|
357
417
|
"app/(auth-kit)/login/route.ts",
|
|
358
418
|
"app/(auth-kit)/signup/route.ts",
|
|
359
419
|
"app/(auth-kit)/signup/oauth/authorize/route.ts",
|
|
420
|
+
"app/(auth-kit)/auth/payment-success/route.ts",
|
|
421
|
+
"app/(auth-kit)/auth/payment/finished/page.tsx",
|
|
360
422
|
"app/auth/index-html.ts",
|
|
361
423
|
"app/auth/libs/index.ts",
|
|
362
424
|
"app/auth/libs/auth-config.ts",
|
|
@@ -378,17 +440,17 @@ var deprecatedTargets = [
|
|
|
378
440
|
"lib/auth-redirect.ts"
|
|
379
441
|
];
|
|
380
442
|
function logCreated(filePath) {
|
|
381
|
-
console.log(`+ ${
|
|
443
|
+
console.log(`+ ${path3.relative(projectRoot, filePath)}`);
|
|
382
444
|
}
|
|
383
445
|
function logUpdated(filePath) {
|
|
384
|
-
console.log(`~ ${
|
|
446
|
+
console.log(`~ ${path3.relative(projectRoot, filePath)}`);
|
|
385
447
|
}
|
|
386
448
|
function logRemoved(filePath) {
|
|
387
|
-
console.log(`- ${
|
|
449
|
+
console.log(`- ${path3.relative(projectRoot, filePath)}`);
|
|
388
450
|
}
|
|
389
451
|
function syncManagedEnvFiles() {
|
|
390
452
|
for (const file of AUTH_KIT_ENV_FILES) {
|
|
391
|
-
const filePath =
|
|
453
|
+
const filePath = path3.join(projectRoot, file);
|
|
392
454
|
const existed = exists(filePath);
|
|
393
455
|
const current = existed ? read(filePath) : "";
|
|
394
456
|
const next = envTemplate(file, current);
|
|
@@ -403,25 +465,25 @@ function syncManagedEnvFiles() {
|
|
|
403
465
|
}
|
|
404
466
|
}
|
|
405
467
|
function syncManagedSkillFile() {
|
|
406
|
-
const filePath =
|
|
468
|
+
const filePath = path3.join(projectRoot, skillTarget);
|
|
407
469
|
try {
|
|
408
|
-
const sourcePath = canonicalSkillPaths.find((candidate) =>
|
|
470
|
+
const sourcePath = canonicalSkillPaths.find((candidate) => fs3.existsSync(candidate));
|
|
409
471
|
if (!sourcePath) {
|
|
410
472
|
throw new Error(`Unable to locate canonical skill directory. Checked: ${canonicalSkillPaths.join(", ")}`);
|
|
411
473
|
}
|
|
412
474
|
removePath(filePath);
|
|
413
|
-
|
|
475
|
+
fs3.mkdirSync(filePath, { recursive: true });
|
|
414
476
|
logCreated(filePath);
|
|
415
|
-
for (const entry of
|
|
416
|
-
const sourceEntry =
|
|
417
|
-
const targetEntry =
|
|
477
|
+
for (const entry of fs3.readdirSync(sourcePath, { withFileTypes: true })) {
|
|
478
|
+
const sourceEntry = path3.join(sourcePath, entry.name);
|
|
479
|
+
const targetEntry = path3.join(filePath, entry.name);
|
|
418
480
|
if (entry.isDirectory()) {
|
|
419
|
-
|
|
420
|
-
console.log(`+ ${
|
|
481
|
+
fs3.cpSync(sourceEntry, targetEntry, { recursive: true });
|
|
482
|
+
console.log(`+ ${path3.relative(projectRoot, targetEntry)}/`);
|
|
421
483
|
continue;
|
|
422
484
|
}
|
|
423
|
-
|
|
424
|
-
console.log(`+ ${
|
|
485
|
+
fs3.copyFileSync(sourceEntry, targetEntry);
|
|
486
|
+
console.log(`+ ${path3.relative(projectRoot, targetEntry)}`);
|
|
425
487
|
}
|
|
426
488
|
} catch (error) {
|
|
427
489
|
console.warn(`Skipped skill sync for ${skillTarget}: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -429,7 +491,7 @@ function syncManagedSkillFile() {
|
|
|
429
491
|
}
|
|
430
492
|
async function initProject() {
|
|
431
493
|
for (const [rel, factory] of targets) {
|
|
432
|
-
const filePath =
|
|
494
|
+
const filePath = path3.join(projectRoot, rel);
|
|
433
495
|
if (!exists(filePath)) {
|
|
434
496
|
writeGeneratedFile(filePath, factory());
|
|
435
497
|
logCreated(filePath);
|
|
@@ -441,14 +503,14 @@ async function initProject() {
|
|
|
441
503
|
}
|
|
442
504
|
async function updateProject() {
|
|
443
505
|
for (const rel of deprecatedTargets) {
|
|
444
|
-
const filePath =
|
|
506
|
+
const filePath = path3.join(projectRoot, rel);
|
|
445
507
|
if (exists(filePath)) {
|
|
446
508
|
removePath(filePath);
|
|
447
509
|
logRemoved(filePath);
|
|
448
510
|
}
|
|
449
511
|
}
|
|
450
512
|
for (const [rel, factory] of targets) {
|
|
451
|
-
const filePath =
|
|
513
|
+
const filePath = path3.join(projectRoot, rel);
|
|
452
514
|
const next = "// generated by @foldspace-fe/casdoor-next-auth-kit\n" + factory();
|
|
453
515
|
if (!exists(filePath)) {
|
|
454
516
|
writeGeneratedFile(filePath, factory());
|
|
@@ -467,16 +529,16 @@ async function updateProject() {
|
|
|
467
529
|
console.log("Updated managed route shells, env files, and skill file.");
|
|
468
530
|
}
|
|
469
531
|
async function checkProject() {
|
|
470
|
-
const missingRoutes = targets.filter(([rel]) => !exists(
|
|
532
|
+
const missingRoutes = targets.filter(([rel]) => !exists(path3.join(projectRoot, rel))).map(([rel]) => rel);
|
|
471
533
|
const missingEnv = AUTH_KIT_ENV_FILES.filter((file) => {
|
|
472
|
-
const filePath =
|
|
534
|
+
const filePath = path3.join(projectRoot, file);
|
|
473
535
|
if (!exists(filePath)) {
|
|
474
536
|
return true;
|
|
475
537
|
}
|
|
476
538
|
return getMissingManagedEnvKeys(read(filePath)).length > 0;
|
|
477
539
|
});
|
|
478
|
-
const skillDir =
|
|
479
|
-
const missingSkill = exists(
|
|
540
|
+
const skillDir = path3.join(projectRoot, skillTarget);
|
|
541
|
+
const missingSkill = exists(path3.join(skillDir, "SKILL.md")) ? [] : [path3.join(skillTarget, "SKILL.md")];
|
|
480
542
|
const missing = [...missingRoutes, ...missingEnv, ...missingSkill];
|
|
481
543
|
if (missing.length > 0) {
|
|
482
544
|
console.error("Missing generated files:");
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../package.json","../src/cli/operations.ts","../src/cli/fs.ts","../src/cli/templates.ts","../src/cli/index.ts","../src/cli.ts"],"sourcesContent":["{\n \"name\": \"@foldspace-fe/casdoor-next-auth-kit\",\n \"version\": \"0.1.0\",\n \"private\": false,\n \"type\": \"module\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/foldspace-stack/casdoor-next-auth-kit\"\n },\n \"homepage\": \"https://github.com/foldspace-stack/casdoor-next-auth-kit#readme\",\n \"bugs\": {\n \"url\": \"https://github.com/foldspace-stack/casdoor-next-auth-kit/issues\"\n },\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n },\n \"./casdoor\": {\n \"types\": \"./dist/casdoor/index.d.ts\",\n \"default\": \"./dist/casdoor/index.js\"\n },\n \"./next\": {\n \"types\": \"./dist/next/index.d.ts\",\n \"default\": \"./dist/next/index.js\"\n },\n \"./billing\": {\n \"types\": \"./dist/billing/index.d.ts\",\n \"default\": \"./dist/billing/index.js\"\n },\n \"./react\": {\n \"types\": \"./dist/react/index.d.ts\",\n \"default\": \"./dist/react/index.js\"\n }\n },\n \"bin\": {\n \"casdoor-next-auth-kit\": \"./dist/cli.js\"\n },\n \"publishConfig\": {\n \"access\": \"public\",\n \"provenance\": true\n },\n \"files\": [\"dist\", \"README.md\"],\n \"scripts\": {\n \"build\": \"tsup && node ./scripts/copy-skill.mjs\",\n \"typecheck\": \"tsc -p tsconfig.json --noEmit\",\n \"dev\": \"tsup --watch\"\n },\n \"peerDependencies\": {\n \"next\": \">=16\",\n \"next-auth\": \"^4.24.0\",\n \"react\": \">=19\",\n \"react-dom\": \">=19\"\n },\n \"dependencies\": {\n \"jose\": \"^6.1.0\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^22.15.0\",\n \"@types/react\": \"^19.2.0\",\n \"@types/react-dom\": \"^19.2.0\",\n \"tsup\": \"^8.5.0\",\n \"typescript\": \"^5.6.3\"\n }\n}\n","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 packageJson from '../../package.json';\n\nimport { initProject, checkProject, updateProject } from './operations';\n\nfunction printUsage() {\n console.log('Usage: npx @foldspace-fe/casdoor-next-auth-kit@latest <init|update|check>');\n console.log(' npx @foldspace-fe/casdoor-next-auth-kit@latest --help');\n console.log(' npx @foldspace-fe/casdoor-next-auth-kit@latest --version');\n}\n\nexport async function runCli(argv: string[]) {\n const command = argv[0] ?? 'help';\n if (command === '--help' || command === '-h' || command === 'help') {\n printUsage();\n return;\n }\n if (command === '--version' || command === '-v') {\n console.log(packageJson.version);\n return;\n }\n if (command === 'init') return initProject();\n if (command === 'update') return updateProject();\n if (command === 'check') return checkProject();\n printUsage();\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":";;;;;;;;AAAA;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,SAAW;AAAA,EACX,MAAQ;AAAA,EACR,YAAc;AAAA,IACZ,MAAQ;AAAA,IACR,KAAO;AAAA,EACT;AAAA,EACA,UAAY;AAAA,EACZ,MAAQ;AAAA,IACN,KAAO;AAAA,EACT;AAAA,EACA,MAAQ;AAAA,EACR,OAAS;AAAA,EACT,SAAW;AAAA,IACT,KAAK;AAAA,MACH,OAAS;AAAA,MACT,SAAW;AAAA,IACb;AAAA,IACA,aAAa;AAAA,MACX,OAAS;AAAA,MACT,SAAW;AAAA,IACb;AAAA,IACA,UAAU;AAAA,MACR,OAAS;AAAA,MACT,SAAW;AAAA,IACb;AAAA,IACA,aAAa;AAAA,MACX,OAAS;AAAA,MACT,SAAW;AAAA,IACb;AAAA,IACA,WAAW;AAAA,MACT,OAAS;AAAA,MACT,SAAW;AAAA,IACb;AAAA,EACF;AAAA,EACA,K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AAS;AACzB,cAAQ,MAAM,OAAO,GAAG;AAAA,IAC1B;AACA,YAAQ,WAAW;AACnB;AAAA,EACF;AAEA,UAAQ,IAAI,gCAAgC;AAC9C;;;AGjMA,SAAS,aAAa;AACpB,UAAQ,IAAI,2EAA2E;AACvF,UAAQ,IAAI,8DAA8D;AAC1E,UAAQ,IAAI,iEAAiE;AAC/E;AAEA,eAAsB,OAAO,MAAgB;AAC3C,QAAM,UAAU,KAAK,CAAC,KAAK;AAC3B,MAAI,YAAY,YAAY,YAAY,QAAQ,YAAY,QAAQ;AAClE,eAAW;AACX;AAAA,EACF;AACA,MAAI,YAAY,eAAe,YAAY,MAAM;AAC/C,YAAQ,IAAI,gBAAY,OAAO;AAC/B;AAAA,EACF;AACA,MAAI,YAAY,OAAQ,QAAO,YAAY;AAC3C,MAAI,YAAY,SAAU,QAAO,cAAc;AAC/C,MAAI,YAAY,QAAS,QAAO,aAAa;AAC7C,aAAW;AACb;;;ACtBA,OAAO,QAAQ,KAAK,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,UAAU;AAC7C,UAAQ,MAAM,iBAAiB,QAAQ,MAAM,UAAU,KAAK;AAC5D,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["fs","path","path","fs"]}
|
|
1
|
+
{"version":3,"sources":["../package.json","../src/cli/operations.ts","../src/cli/fs.ts","../src/cli/templates.ts","../src/cli/index.ts","../src/cli.ts"],"sourcesContent":["{\n \"name\": \"@foldspace-fe/casdoor-next-auth-kit\",\n \"version\": \"0.1.0\",\n \"private\": false,\n \"type\": \"module\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/foldspace-stack/casdoor-next-auth-kit\"\n },\n \"homepage\": \"https://github.com/foldspace-stack/casdoor-next-auth-kit#readme\",\n \"bugs\": {\n \"url\": \"https://github.com/foldspace-stack/casdoor-next-auth-kit/issues\"\n },\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n },\n \"./casdoor\": {\n \"types\": \"./dist/casdoor/index.d.ts\",\n \"default\": \"./dist/casdoor/index.js\"\n },\n \"./next\": {\n \"types\": \"./dist/next/index.d.ts\",\n \"default\": \"./dist/next/index.js\"\n },\n \"./billing\": {\n \"types\": \"./dist/billing/index.d.ts\",\n \"default\": \"./dist/billing/index.js\"\n },\n \"./react\": {\n \"types\": \"./dist/react/index.d.ts\",\n \"default\": \"./dist/react/index.js\"\n }\n },\n \"bin\": {\n \"casdoor-next-auth-kit\": \"./dist/cli.js\"\n },\n \"publishConfig\": {\n \"access\": \"public\",\n \"provenance\": true\n },\n \"files\": [\"dist\", \"README.md\"],\n \"scripts\": {\n \"build\": \"tsup && node ./scripts/copy-skill.mjs\",\n \"typecheck\": \"tsc -p tsconfig.json --noEmit\",\n \"dev\": \"tsup --watch\"\n },\n \"peerDependencies\": {\n \"next\": \">=16\",\n \"next-auth\": \"^4.24.0\",\n \"react\": \">=19\",\n \"react-dom\": \">=19\"\n },\n \"dependencies\": {\n \"jose\": \"^6.1.0\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^22.15.0\",\n \"@types/react\": \"^19.2.0\",\n \"@types/react-dom\": \"^19.2.0\",\n \"tsup\": \"^8.5.0\",\n \"typescript\": \"^5.6.3\"\n }\n}\n","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 paymentFinishedRouteTemplate,\n paymentSuccessRouteTemplate,\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)/auth/payment/success/route.ts', paymentSuccessRouteTemplate],\n ['app/(auth-kit)/auth/payment/finished/route.ts', paymentFinishedRouteTemplate],\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-kit)/auth/payment-success/route.ts',\n 'app/(auth-kit)/auth/payment/finished/page.tsx',\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 fs from 'node:fs';\nimport path from 'node:path';\n\nimport { customBegin, customEnd } from './fs';\nimport { buildAuthPrismaSchemaTemplate } from '../prisma/schema-template';\nimport { AUTH_KIT_ENV_FILES, buildManagedEnvTemplate, readManagedEnvValue } from '../core/env';\n\nfunction getManagedEnvValue(key: string): string | null {\n for (const file of ['.env.local', '.env', '.env.production', '.env.example'] as const) {\n const filePath = path.join(process.cwd(), file);\n if (!fs.existsSync(filePath)) {\n continue;\n }\n\n const value = readManagedEnvValue(fs.readFileSync(filePath, 'utf8'), key);\n if (value !== null) {\n return value;\n }\n }\n\n return null;\n}\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 const billingPaymentSuccessHandlerImport = getManagedEnvValue('BILLING_PAYMENT_SUCCESS_HANDLER');\n const billingPaymentFinishedHandlerImport = getManagedEnvValue('BILLING_PAYMENT_FINISHED_HANDLER');\n const billingPaymentSuccessHandlerImportLine = billingPaymentSuccessHandlerImport\n ? `import { paymentSuccessHandler as billingPaymentSuccessHandler } from ${JSON.stringify(billingPaymentSuccessHandlerImport)};\\n`\n : '';\n const billingPaymentFinishedHandlerImportLine = billingPaymentFinishedHandlerImport\n ? `import { paymentFinishedHandler as billingPaymentFinishedHandler } from ${JSON.stringify(billingPaymentFinishedHandlerImport)};\\n`\n : '';\n\n return `import {\n createCallbackHandler,\n createCasdoorApiProxyHandler,\n createCasdoorCommerceProxyHandler,\n createAuthorizeRouteHandler,\n createLoginRouteHandler,\n createLogoutHandler,\n createNextAuthOptions,\n createSignupRouteHandler,\n type AuthBusinessAdapter,\n type AuthKitConfig,\n type AuthPersistenceAdapter,\n type AuthUser,\n} from '@foldspace-fe/casdoor-next-auth-kit';\n${billingPaymentSuccessHandlerImportLine}${billingPaymentFinishedHandlerImportLine}import { 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 || '',\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 paymentSuccessHandler = ${billingPaymentSuccessHandlerImport ? 'billingPaymentSuccessHandler' : 'undefined'};\nexport const paymentFinishedHandler = ${billingPaymentFinishedHandlerImport ? 'billingPaymentFinishedHandler' : 'undefined'};\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 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 NextAuth from 'next-auth';\nimport { createNextAuthOptions } from '@foldspace-fe/casdoor-next-auth-kit';\nimport { adapter, authKitConfig, persistence } from '../../../auth-config';\n\nexport const dynamic = 'force-dynamic';\nexport const runtime = 'nodejs';\n\nconst handler = NextAuth(\n createNextAuthOptions({\n config: authKitConfig,\n adapter,\n persistence,\n }),\n);\n\nexport const GET = handler;\nexport const POST = handler;\n`;\n}\n\nexport function paymentSuccessRouteTemplate() {\n return `import { createBillingPaymentSuccessRouteHandler } from '@foldspace-fe/casdoor-next-auth-kit';\nimport { authKitConfig, paymentSuccessHandler } from '../../../auth-config';\n\nexport const dynamic = 'force-dynamic';\nexport const runtime = 'nodejs';\n\nexport const GET = createBillingPaymentSuccessRouteHandler({\n appUrl: authKitConfig.appUrl,\n fallbackRedirect: '/auth/payment/finished',\n handler: paymentSuccessHandler,\n});\n`;\n}\n\nexport function paymentFinishedRouteTemplate() {\n return `import { createBillingPaymentFinishedRouteHandler } from '@foldspace-fe/casdoor-next-auth-kit';\nimport { authKitConfig, paymentFinishedHandler } from '../../../auth-config';\n\nexport const dynamic = 'force-dynamic';\nexport const runtime = 'nodejs';\n\nexport const GET = createBillingPaymentFinishedRouteHandler({\n appUrl: authKitConfig.appUrl,\n fallbackRedirect: '/',\n handler: paymentFinishedHandler,\n});\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 packageJson from '../../package.json';\n\nimport { initProject, checkProject, updateProject } from './operations';\n\nfunction printUsage() {\n console.log('Usage: npx @foldspace-fe/casdoor-next-auth-kit@latest <init|update|check>');\n console.log(' npx @foldspace-fe/casdoor-next-auth-kit@latest --help');\n console.log(' npx @foldspace-fe/casdoor-next-auth-kit@latest --version');\n}\n\nexport async function runCli(argv: string[]) {\n const command = argv[0] ?? 'help';\n if (command === '--help' || command === '-h' || command === 'help') {\n printUsage();\n return;\n }\n if (command === '--version' || command === '-v') {\n console.log(packageJson.version);\n return;\n }\n if (command === 'init') return initProject();\n if (command === 'update') return updateProject();\n if (command === 'check') return checkProject();\n printUsage();\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":";;;;;;;;;AAAA;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,SAAW;AAAA,EACX,MAAQ;AAAA,EACR,YAAc;AAAA,IACZ,MAAQ;AAAA,IACR,KAAO;AAAA,EACT;AAAA,EACA,UAAY;AAAA,EACZ,MAAQ;AAAA,IACN,KAAO;AAAA,EACT;AAAA,EACA,MAAQ;AAAA,EACR,OAAS;AAAA,EACT,SAAW;AAAA,IACT,KAAK;AAAA,MACH,OAAS;AAAA,MACT,SAAW;AAAA,IACb;AAAA,IACA,aAAa;AAAA,MACX,OAAS;AAAA,MACT,SAAW;AAAA,IACb;AAAA,IACA,UAAU;AAAA,MACR,OAAS;AAAA,MACT,SAAW;AAAA,IACb;AAAA,IACA,aAAa;AAAA,MACX,OAAS;AAAA,MACT,SAAW;AAAA,IACb;AAAA,IACA,WAAW;AAAA,MACT,OAAS;AAAA,MACT,SAAW;AAAA,IACb;AAAA,EACF;AAAA,EACA,KAAO;AAAA,IACL,yBAAyB;AAAA,EAC3B;AAAA,EACA,eAAiB;AAAA,IACf,QAAU;AAAA,IACV,YAAc;AAAA,EAChB;AAAA,EACA,OAAS,CAAC,QAAQ,WAAW;AAAA,EAC7B,SAAW;AAAA,IACT,OAAS;AAAA,IACT,WAAa;AAAA,IACb,KAAO;AAAA,EACT;AAAA,EACA,kBAAoB;AAAA,IAClB,MAAQ;AAAA,IACR,aAAa;AAAA,IACb,OAAS;AAAA,IACT,aAAa;AAAA,EACf;AAAA,EACA,cAAgB;AAAA,IACd,MAAQ;AAAA,EACV;AAAA,E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C,MAAI,YAAY,QAAS,QAAO,aAAa;AAC7C,aAAW;AACb;;;ACtBA,OAAO,QAAQ,KAAK,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,UAAU;AAC7C,UAAQ,MAAM,iBAAiB,QAAQ,MAAM,UAAU,KAAK;AAC5D,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["fs","path","fs","path","path","fs","path","fs"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ export { createAuthorizeEntryResponse, createCasdoorApiProxyHandler, createCasdo
|
|
|
5
5
|
export { C as CallbackHandlerOptions, c as createCallbackHandler, a as createCallbackResponse } from './callback-BTzHQK_r.js';
|
|
6
6
|
export { createAuthorizeRouteHandler, createLoginRouteHandler, createLogoutHandler, createSignupRouteHandler } from './next/index.js';
|
|
7
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,
|
|
9
|
-
export { buildBillingActionPayload, deriveBillingCreditsState, deriveBillingEntitlements,
|
|
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, x as BillingPaymentFinishedHandler, y as BillingPaymentFinishedRouteOptions, l as BillingPaymentHistoryItem, z as BillingPaymentSuccessContext, A as BillingPaymentSuccessHandler, C as BillingPaymentSuccessHandlerResult, D as BillingPaymentSuccessRouteOptions, E as BillingProductContextValue, F as BillingProductPurchaseConfig, q as BillingProductSnapshot, j as BillingProductState, p as BillingPurchaseStatus, b as BillingRuntimeConfig, o as BillingStatusState, G as BillingSubscriptionContextValue, i as BillingSubscriptionHistoryItem, H as BillingSubscriptionPurchaseConfig, h as BillingSubscriptionState } from './types-DwThfdu-.js';
|
|
9
|
+
export { buildBillingActionPayload, createBillingPaymentFinishedResponse, createBillingPaymentFinishedRouteHandler, createBillingPaymentSuccessResponse, createBillingPaymentSuccessRouteHandler, deriveBillingCreditsState, deriveBillingEntitlements, normalizeBillingCatalogConfig, normalizeBillingPurchaseStatus, normalizeBillingRuntimeConfig, resolveBillingInterval, resolveBillingItem, resolveBillingProductSnapshot, resolveBillingSubscriptionProduct } from './billing/index.js';
|
|
10
10
|
import 'next/server';
|
|
11
11
|
import 'next-auth';
|
|
12
12
|
|
|
@@ -49,6 +49,7 @@ declare function isGlobalAdminEmail(email: string | null | undefined): boolean;
|
|
|
49
49
|
|
|
50
50
|
declare const AUTH_KIT_ENV_FILES: ManagedEnvFile[];
|
|
51
51
|
declare const AUTH_KIT_ENV_VARIABLES: ManagedEnvVariableDefinition[];
|
|
52
|
+
declare function readManagedEnvValue(content: string, key: string): string | null;
|
|
52
53
|
declare function getManagedEnvValue(definition: ManagedEnvVariableDefinition, file: ManagedEnvFile): string;
|
|
53
54
|
declare function buildManagedEnvTemplate(file: ManagedEnvFile, existingContent?: string): string;
|
|
54
55
|
declare function getMissingManagedEnvKeys(content: string): string[];
|
|
@@ -74,4 +75,4 @@ declare function decodeSessionToken(params: JWTDecodeParams): Promise<JWT | null
|
|
|
74
75
|
declare const AUTH_PRISMA_SCHEMA_MODELS: PrismaSchemaModelDefinition[];
|
|
75
76
|
declare function buildAuthPrismaSchemaTemplate(models?: PrismaSchemaModelDefinition[]): string;
|
|
76
77
|
|
|
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 };
|
|
78
|
+
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, readManagedEnvValue, resolvePostLoginRedirect, sanitizeExistingEnvContent, setAuthRedirectCookie, setPublicOriginCookie, verifyState, verifyStateToken };
|
package/dist/index.js
CHANGED
|
@@ -6,14 +6,20 @@ import {
|
|
|
6
6
|
buildManagedEnvTemplate,
|
|
7
7
|
getManagedEnvValue,
|
|
8
8
|
getMissingManagedEnvKeys,
|
|
9
|
+
readManagedEnvValue,
|
|
9
10
|
sanitizeExistingEnvContent
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import
|
|
11
|
+
} from "./chunk-PFHMT4ZD.js";
|
|
12
|
+
import {
|
|
13
|
+
createBillingPaymentFinishedResponse,
|
|
14
|
+
createBillingPaymentFinishedRouteHandler,
|
|
15
|
+
createBillingPaymentSuccessResponse,
|
|
16
|
+
createBillingPaymentSuccessRouteHandler
|
|
17
|
+
} from "./chunk-NGKCQHB3.js";
|
|
12
18
|
import {
|
|
13
19
|
createCasdoorApiProxyHandler,
|
|
14
20
|
createCasdoorCommerceProxyHandler,
|
|
15
21
|
createCasdoorPageProxyHandler
|
|
16
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-YXTDGBLC.js";
|
|
17
23
|
import {
|
|
18
24
|
createAuthorizeRouteHandler,
|
|
19
25
|
createLoginRouteHandler,
|
|
@@ -64,7 +70,6 @@ import {
|
|
|
64
70
|
buildBillingActionPayload,
|
|
65
71
|
deriveBillingCreditsState,
|
|
66
72
|
deriveBillingEntitlements,
|
|
67
|
-
filterProductsByKind,
|
|
68
73
|
normalizeBillingCatalogConfig,
|
|
69
74
|
normalizeBillingPurchaseStatus,
|
|
70
75
|
normalizeBillingRuntimeConfig,
|
|
@@ -72,7 +77,7 @@ import {
|
|
|
72
77
|
resolveBillingItem,
|
|
73
78
|
resolveBillingProductSnapshot,
|
|
74
79
|
resolveBillingSubscriptionProduct
|
|
75
|
-
} from "./chunk-
|
|
80
|
+
} from "./chunk-O3FKI5NT.js";
|
|
76
81
|
import {
|
|
77
82
|
buildAuthJumpHref,
|
|
78
83
|
resolvePostLoginRedirect
|
|
@@ -93,6 +98,10 @@ export {
|
|
|
93
98
|
createAuthIndexHtml,
|
|
94
99
|
createAuthorizeEntryResponse,
|
|
95
100
|
createAuthorizeRouteHandler,
|
|
101
|
+
createBillingPaymentFinishedResponse,
|
|
102
|
+
createBillingPaymentFinishedRouteHandler,
|
|
103
|
+
createBillingPaymentSuccessResponse,
|
|
104
|
+
createBillingPaymentSuccessRouteHandler,
|
|
96
105
|
createCallbackHandler,
|
|
97
106
|
createCallbackResponse,
|
|
98
107
|
createCasdoorApiProxyHandler,
|
|
@@ -113,7 +122,6 @@ export {
|
|
|
113
122
|
exchangeCasdoorOAuthToken,
|
|
114
123
|
exchangeCodeForToken,
|
|
115
124
|
fetchCasdoorUserInfo,
|
|
116
|
-
filterProductsByKind,
|
|
117
125
|
generateStateToken,
|
|
118
126
|
getAuthRedirectTarget,
|
|
119
127
|
getCasdoorAuthorizeUrl,
|
|
@@ -134,6 +142,7 @@ export {
|
|
|
134
142
|
normalizeBillingRuntimeConfig,
|
|
135
143
|
parseStateToken,
|
|
136
144
|
pkceCookiePrefix,
|
|
145
|
+
readManagedEnvValue,
|
|
137
146
|
resolveBillingInterval,
|
|
138
147
|
resolveBillingItem,
|
|
139
148
|
resolveBillingProductSnapshot,
|
package/dist/react/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { Session } from 'next-auth';
|
|
|
5
5
|
import { useSession } from 'next-auth/react';
|
|
6
6
|
import { A as AuthSession } from '../options-JUwZSXu2.js';
|
|
7
7
|
export { a as AuthSessionUser, b as AuthTokenPayload } from '../options-JUwZSXu2.js';
|
|
8
|
-
import { B as BillingActionPayload, a as BillingItem, b as BillingRuntimeConfig, c as BillingCatalogConfig, d as BillingApiClient, e as BillingLoaders, f as BillingActionExecutor, g as BillingDefaults, h as BillingSubscriptionState, i as BillingSubscriptionHistoryItem, j as BillingProductState, k as BillingOrderHistoryItem, l as BillingPaymentHistoryItem, m as BillingCreditsState, n as BillingEntitlementState, o as BillingStatusState, p as BillingPurchaseStatus, q as BillingProductSnapshot, r as BillingCoreContextValue } from '../types-
|
|
8
|
+
import { B as BillingActionPayload, a as BillingItem, b as BillingRuntimeConfig, c as BillingCatalogConfig, d as BillingApiClient, e as BillingLoaders, f as BillingActionExecutor, g as BillingDefaults, h as BillingSubscriptionState, i as BillingSubscriptionHistoryItem, j as BillingProductState, k as BillingOrderHistoryItem, l as BillingPaymentHistoryItem, m as BillingCreditsState, n as BillingEntitlementState, o as BillingStatusState, p as BillingPurchaseStatus, q as BillingProductSnapshot, r as BillingCoreContextValue } from '../types-DwThfdu-.js';
|
|
9
9
|
import 'next-auth/jwt';
|
|
10
10
|
import '../types-DqVXdUge.js';
|
|
11
11
|
|
|
@@ -118,11 +118,7 @@ interface BillingProductsState {
|
|
|
118
118
|
error: string | null;
|
|
119
119
|
refresh: () => Promise<void>;
|
|
120
120
|
}
|
|
121
|
-
declare function useBillingProducts(
|
|
122
|
-
userId?: string;
|
|
123
|
-
catalogKey?: string;
|
|
124
|
-
kind?: 'product' | 'credits';
|
|
125
|
-
}): BillingProductsState;
|
|
121
|
+
declare function useBillingProducts(): BillingProductsState;
|
|
126
122
|
interface BillingAvailablePlansState {
|
|
127
123
|
plans: BillingItem[];
|
|
128
124
|
loading: boolean;
|
|
@@ -228,7 +224,6 @@ declare function useSubscribePlan(): BillingActionHookResult;
|
|
|
228
224
|
declare function useManageSubscription(): BillingActionHookResult;
|
|
229
225
|
declare function useUpgradePlan(): BillingActionHookResult;
|
|
230
226
|
declare function useCancelSubscription(): BillingActionHookResult;
|
|
231
|
-
declare function usePurchaseCredits(): BillingActionHookResult;
|
|
232
227
|
declare function usePurchaseProduct(): BillingActionHookResult;
|
|
233
228
|
interface BillingProductStateView {
|
|
234
229
|
product?: BillingProductState;
|
|
@@ -239,4 +234,4 @@ interface BillingProductStateView {
|
|
|
239
234
|
declare function useBillingProduct(productKey: string): BillingProductStateView;
|
|
240
235
|
declare function useBillingCatalogConfig(): BillingCatalogState;
|
|
241
236
|
|
|
242
|
-
export { type AuthActions, type AuthActionsOptions, AuthProvider, type AuthRole, AuthSession, type AuthUserSummary, type BillingActionHookResult, type BillingAvailablePlansState, type BillingAvailableProductsState, type BillingCatalogState, BillingCoreProvider, type BillingCoreProviderProps, type BillingCreditsProviderProps, type BillingCreditsStateView, type BillingEntitlementsStateView, type BillingItemState, type BillingOrderHistoryState, type BillingPaymentHistoryState, type BillingPipelineOptions, type BillingPipelineResult, type BillingProductProviderProps, type BillingProductStateView, type BillingProductsState, BillingProvider, type BillingProviderProps, type BillingPurchaseStatusView, type BillingRefreshView, type BillingStatusView, type BillingSubscriptionHistoryState, type BillingSubscriptionProductState, type BillingSubscriptionProviderProps, type BillingSubscriptionStateView, CreditsProvider, ProductProvider, SubscriptionProvider, useAuthActions, useAuthRole, useAuthSession, useAuthUser, useBillingAvailablePlans, useBillingAvailableProducts, useBillingCatalog, useBillingCatalogConfig, useBillingContext, useBillingCredits, useBillingEntitlements, useBillingItem, useBillingOrderHistory, useBillingPaymentHistory, useBillingPipeline, useBillingProduct, useBillingProducts, useBillingPurchaseStatus, useBillingRefresh, useBillingStatus, useBillingSubscription, useBillingSubscriptionHistory, useBillingSubscriptionProduct, useCancelSubscription, useManageSubscription,
|
|
237
|
+
export { type AuthActions, type AuthActionsOptions, AuthProvider, type AuthRole, AuthSession, type AuthUserSummary, type BillingActionHookResult, type BillingAvailablePlansState, type BillingAvailableProductsState, type BillingCatalogState, BillingCoreProvider, type BillingCoreProviderProps, type BillingCreditsProviderProps, type BillingCreditsStateView, type BillingEntitlementsStateView, type BillingItemState, type BillingOrderHistoryState, type BillingPaymentHistoryState, type BillingPipelineOptions, type BillingPipelineResult, type BillingProductProviderProps, type BillingProductStateView, type BillingProductsState, BillingProvider, type BillingProviderProps, type BillingPurchaseStatusView, type BillingRefreshView, type BillingStatusView, type BillingSubscriptionHistoryState, type BillingSubscriptionProductState, type BillingSubscriptionProviderProps, type BillingSubscriptionStateView, CreditsProvider, ProductProvider, SubscriptionProvider, useAuthActions, useAuthRole, useAuthSession, useAuthUser, useBillingAvailablePlans, useBillingAvailableProducts, useBillingCatalog, useBillingCatalogConfig, useBillingContext, useBillingCredits, useBillingEntitlements, useBillingItem, useBillingOrderHistory, useBillingPaymentHistory, useBillingPipeline, useBillingProduct, useBillingProducts, useBillingPurchaseStatus, useBillingRefresh, useBillingStatus, useBillingSubscription, useBillingSubscriptionHistory, useBillingSubscriptionProduct, useCancelSubscription, useManageSubscription, usePurchaseProduct, useSubscribePlan, useUpgradePlan };
|