@foldspace-fe/casdoor-next-auth-kit 0.1.24 → 0.1.26

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.
@@ -73,10 +73,12 @@ declare function buildCasdoorBuyProductParams(input: BillingCasdoorBuyProductReq
73
73
  declare function buildCasdoorBuyProductRequest(purchase: BillingPurchaseRequest, product: BillingCasdoorProductDetail, preferredProviderName?: string): BillingCasdoorBuyProductRequest;
74
74
  declare function normalizeCasdoorBuyProductResponse(response: BillingCasdoorBuyProductResponse, fallbackRedirectTo?: string): BillingActionExecutionResult;
75
75
 
76
+ declare function resolveBillingOrderRedirect(orderIdOrPaymentId?: string | null): string | null;
77
+
76
78
  declare function createBillingPaymentSuccessResponse(request: Request, options?: BillingPaymentSuccessRouteOptions): Promise<Response>;
77
79
  declare function createBillingPaymentSuccessRouteHandler(options?: BillingPaymentSuccessRouteOptions): (request: Request) => Promise<Response>;
78
80
 
79
81
  declare function createBillingPaymentFinishedResponse(request: Request, options?: BillingPaymentFinishedRouteOptions): Promise<Response>;
80
82
  declare function createBillingPaymentFinishedRouteHandler(options?: BillingPaymentFinishedRouteOptions): (request: Request) => Promise<Response>;
81
83
 
82
- export { BillingActionExecutionResult, BillingActionPayload, BillingCasdoorBuyProductRequest, BillingCasdoorBuyProductResponse, BillingCasdoorOrderDetail, BillingCasdoorProductDetail, BillingCasdoorSubscriptionDetail, BillingCatalogConfig, BillingCreditsState, BillingDefaults, BillingEntitlementState, BillingInterval, BillingItem, BillingOrderHistoryItem, BillingPaymentCallbackContext, BillingPaymentFinishedRouteOptions, BillingPaymentHistoryItem, BillingPaymentSuccessRouteOptions, BillingProductSnapshot, BillingProductState, BillingPurchasableEntry, BillingPurchaseRequest, BillingPurchaseStatus, BillingRuntimeConfig, type BillingSubscriptionCatalogBuilderOptions, type BillingSubscriptionCatalogItemInput, BillingSubscriptionHistoryItem, BillingSubscriptionState, type NormalizedCasdoorProductId, buildBillingActionPayload, buildBillingPaymentCallbackContext, buildBillingPurchaseRequest, buildBillingSubscriptionCatalog, buildCasdoorBuyProductParams, buildCasdoorBuyProductRequest, chooseCasdoorProviderName, createBillingPaymentFinishedResponse, createBillingPaymentFinishedRouteHandler, createBillingPaymentSuccessResponse, createBillingPaymentSuccessRouteHandler, deriveBillingCreditsState, deriveBillingEntitlements, filterBillingPurchasableItems, normalizeBillingCatalogConfig, normalizeBillingPurchaseStatus, normalizeBillingRuntimeConfig, normalizeCasdoorBuyProductResponse, normalizeCasdoorOrderHistoryItem, normalizeCasdoorPaymentHistoryItem, normalizeCasdoorProductId, normalizeCasdoorSubscriptionDetail, normalizeCasdoorSubscriptionHistoryItem, readBuyProductRedirectTo, resolveBillingInterval, resolveBillingItem, resolveBillingProductSnapshot, resolveBillingPurchasable, resolveBillingSubscriptionProduct };
84
+ export { BillingActionExecutionResult, BillingActionPayload, BillingCasdoorBuyProductRequest, BillingCasdoorBuyProductResponse, BillingCasdoorOrderDetail, BillingCasdoorProductDetail, BillingCasdoorSubscriptionDetail, BillingCatalogConfig, BillingCreditsState, BillingDefaults, BillingEntitlementState, BillingInterval, BillingItem, BillingOrderHistoryItem, BillingPaymentCallbackContext, BillingPaymentFinishedRouteOptions, BillingPaymentHistoryItem, BillingPaymentSuccessRouteOptions, BillingProductSnapshot, BillingProductState, BillingPurchasableEntry, BillingPurchaseRequest, BillingPurchaseStatus, BillingRuntimeConfig, type BillingSubscriptionCatalogBuilderOptions, type BillingSubscriptionCatalogItemInput, BillingSubscriptionHistoryItem, BillingSubscriptionState, type NormalizedCasdoorProductId, buildBillingActionPayload, buildBillingPaymentCallbackContext, buildBillingPurchaseRequest, buildBillingSubscriptionCatalog, buildCasdoorBuyProductParams, buildCasdoorBuyProductRequest, chooseCasdoorProviderName, createBillingPaymentFinishedResponse, createBillingPaymentFinishedRouteHandler, createBillingPaymentSuccessResponse, createBillingPaymentSuccessRouteHandler, deriveBillingCreditsState, deriveBillingEntitlements, filterBillingPurchasableItems, normalizeBillingCatalogConfig, normalizeBillingPurchaseStatus, normalizeBillingRuntimeConfig, normalizeCasdoorBuyProductResponse, normalizeCasdoorOrderHistoryItem, normalizeCasdoorPaymentHistoryItem, normalizeCasdoorProductId, normalizeCasdoorSubscriptionDetail, normalizeCasdoorSubscriptionHistoryItem, readBuyProductRedirectTo, resolveBillingInterval, resolveBillingItem, resolveBillingOrderRedirect, resolveBillingProductSnapshot, resolveBillingPurchasable, resolveBillingSubscriptionProduct };
@@ -3,8 +3,9 @@ import {
3
3
  createBillingPaymentFinishedResponse,
4
4
  createBillingPaymentFinishedRouteHandler,
5
5
  createBillingPaymentSuccessResponse,
6
- createBillingPaymentSuccessRouteHandler
7
- } from "../chunk-PILMR42A.js";
6
+ createBillingPaymentSuccessRouteHandler,
7
+ resolveBillingOrderRedirect
8
+ } from "../chunk-3SUYZDBE.js";
8
9
  import {
9
10
  buildBillingActionPayload,
10
11
  buildBillingPaymentCallbackContext,
@@ -58,6 +59,7 @@ export {
58
59
  readBuyProductRedirectTo,
59
60
  resolveBillingInterval,
60
61
  resolveBillingItem,
62
+ resolveBillingOrderRedirect,
61
63
  resolveBillingProductSnapshot,
62
64
  resolveBillingPurchasable,
63
65
  resolveBillingSubscriptionProduct
@@ -40,6 +40,14 @@ function buildBillingSubscriptionCatalog(plans, options) {
40
40
  };
41
41
  }
42
42
 
43
+ // src/billing/order-redirect.ts
44
+ function resolveBillingOrderRedirect(orderIdOrPaymentId) {
45
+ if (!orderIdOrPaymentId) {
46
+ return null;
47
+ }
48
+ return null;
49
+ }
50
+
43
51
  // src/billing/payment-route.ts
44
52
  import { NextResponse } from "next/server";
45
53
 
@@ -173,9 +181,10 @@ function createBillingPaymentFinishedRouteHandler(options = {}) {
173
181
 
174
182
  export {
175
183
  buildBillingSubscriptionCatalog,
184
+ resolveBillingOrderRedirect,
176
185
  createBillingPaymentSuccessResponse,
177
186
  createBillingPaymentSuccessRouteHandler,
178
187
  createBillingPaymentFinishedResponse,
179
188
  createBillingPaymentFinishedRouteHandler
180
189
  };
181
- //# sourceMappingURL=chunk-PILMR42A.js.map
190
+ //# sourceMappingURL=chunk-3SUYZDBE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/billing/subscription-catalog.ts","../src/billing/order-redirect.ts","../src/billing/payment-route.ts","../src/core/origin.ts","../src/billing/payment-success.ts","../src/billing/payment-finished.ts"],"sourcesContent":["import type {\n BillingCatalogConfig,\n BillingDefaults,\n BillingInterval,\n BillingItem,\n} from './types';\n\nexport interface BillingSubscriptionCatalogItemInput<TSource = unknown> {\n source: TSource;\n key: string;\n title: string;\n description?: string;\n productId: string;\n planId?: string;\n priceId?: string;\n interval?: BillingInterval;\n featured?: boolean;\n badge?: string;\n priceLabel?: string;\n priceValue?: number;\n features?: string[];\n metadata?: Record<string, string>;\n}\n\nexport interface BillingSubscriptionCatalogBuilderOptions<TSource = unknown> {\n catalogKey: string;\n title?: string;\n description?: string;\n portalPath?: string;\n successPath?: string;\n cancelPath?: string;\n purchasableIds?: string[];\n defaults?: BillingDefaults;\n mapPlan: (plan: TSource, index: number) => BillingSubscriptionCatalogItemInput<TSource>;\n}\n\nexport function buildBillingSubscriptionCatalog<TSource>(\n plans: readonly TSource[],\n options: BillingSubscriptionCatalogBuilderOptions<TSource>,\n): BillingCatalogConfig {\n const items = plans.map((plan, index) => {\n const mapped = options.mapPlan(plan, index);\n\n return {\n key: mapped.key,\n kind: 'subscription',\n title: mapped.title,\n description: mapped.description,\n featured: mapped.featured,\n badge: mapped.badge,\n priceLabel: mapped.priceLabel,\n priceValue: mapped.priceValue,\n interval: mapped.interval,\n features: mapped.features,\n backendRef: {\n productId: mapped.productId,\n planId: mapped.planId,\n priceId: mapped.priceId,\n },\n metadata: mapped.metadata,\n } satisfies BillingItem;\n });\n\n return {\n catalogKey: options.catalogKey,\n title: options.title,\n description: options.description,\n portalPath: options.portalPath,\n successPath: options.successPath,\n cancelPath: options.cancelPath,\n purchasableIds: options.purchasableIds ?? items.map((item) => item.key),\n purchasables: [],\n conversionRules: [],\n defaults: options.defaults ?? {},\n items,\n };\n}\n","export function resolveBillingOrderRedirect(orderIdOrPaymentId?: string | null): string | null {\n if (!orderIdOrPaymentId) {\n return null;\n }\n\n return null;\n}\n","import { NextResponse } from 'next/server';\n\nimport { resolvePublicOrigin } from '../core/origin';\nimport { buildBillingPaymentCallbackContext } from './runtime';\nimport type {\n BillingPaymentRouteBaseOptions,\n BillingPaymentFinishedRouteOptions,\n BillingPaymentFinishedContext,\n BillingPaymentFinishedHandler,\n BillingPaymentSuccessContext,\n BillingPaymentSuccessHandlerResult,\n BillingPaymentSuccessRouteOptions,\n} from './types';\n\nexport interface BillingPaymentRouteOptions extends BillingPaymentRouteBaseOptions {\n routePath: string;\n missingHandlerFile: string;\n handler?: BillingPaymentSuccessRouteOptions['handler'] | BillingPaymentFinishedRouteOptions['handler'];\n phase?: 'success' | 'failure' | 'finished';\n}\n\nfunction sanitizeRedirectPath(value: string | null | undefined, fallback: string): string {\n if (!value || !value.startsWith('/') || value.startsWith('//')) {\n return fallback;\n }\n\n return value;\n}\n\nfunction isDebugEnabled(): boolean {\n const value = process.env.BILLING_PAYMENT_SUCCESS_DEBUG;\n if (!value) {\n return false;\n }\n\n return ['1', 'true', 'yes', 'on'].includes(value.toLowerCase());\n}\n\nfunction resolveRedirectTarget(\n result: BillingPaymentSuccessHandlerResult | undefined,\n context: BillingPaymentSuccessContext,\n fallbackRedirect: string,\n): string {\n if (typeof result === 'string') {\n return sanitizeRedirectPath(result, fallbackRedirect);\n }\n\n if (result && typeof result === 'object' && 'redirectTo' in result) {\n return sanitizeRedirectPath(result.redirectTo ?? null, fallbackRedirect);\n }\n\n return sanitizeRedirectPath(context.redirectTo, fallbackRedirect);\n}\n\nfunction resolveFallbackTarget(fallbackRedirect: string): string {\n return sanitizeRedirectPath(fallbackRedirect, '/');\n}\n\nfunction logMissingPaymentHandler(\n context: BillingPaymentSuccessContext,\n fallbackRedirect: string,\n missingHandlerFile: string,\n routePath: string,\n): void {\n console.warn(\n `[casdoor-next-auth-kit] default billing handler at ${missingHandlerFile} has no business logic. ` +\n `Edit this file to handle ${routePath} with order/payment enrichment before redirecting. ` +\n `Falling back to ${fallbackRedirect}.`,\n {\n paymentOwner: context.paymentOwner,\n paymentName: context.paymentName,\n paymentId: context.paymentId,\n orderId: context.orderId,\n params: context.params,\n },\n );\n}\n\nexport async function createBillingPaymentRouteResponse(\n request: Request,\n options: BillingPaymentRouteOptions,\n) {\n const origin = resolvePublicOrigin(request, options.appUrl);\n const fallbackRedirect = options.fallbackRedirect ?? '/';\n const context = await buildBillingPaymentCallbackContext(request, options.phase);\n\n if (isDebugEnabled()) {\n console.info(`[casdoor-next-auth-kit] ${options.routePath} request`, {\n method: request.method,\n path: context.url.pathname,\n query: context.params,\n body: context.body,\n });\n }\n\n try {\n if (options.handler) {\n const handler = options.handler;\n const result =\n options.phase === 'finished'\n ? await (handler as BillingPaymentFinishedHandler)(context as BillingPaymentFinishedContext)\n : await (handler as NonNullable<BillingPaymentSuccessRouteOptions['handler']>)(context);\n if (result instanceof Response) {\n return result;\n }\n\n const target = resolveRedirectTarget(result, context, fallbackRedirect);\n return NextResponse.redirect(new URL(target, origin), 307);\n }\n\n logMissingPaymentHandler(context, fallbackRedirect, options.missingHandlerFile, options.routePath);\n const target = resolveFallbackTarget(fallbackRedirect);\n return NextResponse.redirect(new URL(target, origin), 307);\n } catch (error) {\n console.error(`[casdoor-next-auth-kit] ${options.routePath} handler failed:`, error);\n return new NextResponse('Billing payment handler failed', { status: 500 });\n }\n}\n","export function normalizeOrigin(value: string | null | undefined): string | null {\n if (!value) return null;\n try {\n return new URL(value).origin;\n } catch {\n return null;\n }\n}\n\nexport function getRequestOrigin(request: Request, appUrl?: string): string {\n const configured = normalizeOrigin(appUrl);\n if (configured) return configured;\n\n const referer = normalizeOrigin(request.headers.get('referer'));\n if (referer) return referer;\n\n const origin = normalizeOrigin(request.headers.get('origin'));\n if (origin) return origin;\n\n const forwardedProto = request.headers.get('x-forwarded-proto')?.split(',')[0]?.trim();\n const forwardedHost = request.headers.get('x-forwarded-host')?.split(',')[0]?.trim();\n if (forwardedProto && forwardedHost) {\n return forwardedProto + '://' + forwardedHost;\n }\n\n return new URL(request.url).origin;\n}\n\nexport function resolvePublicOrigin(request: Request, appUrl?: string): string {\n return getRequestOrigin(request, appUrl);\n}\n","import type { BillingPaymentSuccessHandler, BillingPaymentSuccessRouteOptions } from './types';\nimport { createBillingPaymentRouteResponse } from './payment-route';\n\nexport async function createBillingPaymentSuccessResponse(\n request: Request,\n options: BillingPaymentSuccessRouteOptions = {},\n) {\n return createBillingPaymentRouteResponse(request, {\n ...options,\n routePath: '/auth/payment/success',\n missingHandlerFile: 'lib/billing/payment-success.ts',\n fallbackRedirect: options.fallbackRedirect ?? '/auth/payment/finished',\n phase: options.phase ?? 'success',\n });\n}\n\nexport function createBillingPaymentSuccessRouteHandler(options: BillingPaymentSuccessRouteOptions = {}) {\n return async function GET(request: Request) {\n return createBillingPaymentSuccessResponse(request, options);\n };\n}\n\nexport type { BillingPaymentSuccessHandler };\n","import type { BillingPaymentFinishedHandler, BillingPaymentFinishedRouteOptions } from './types';\nimport { createBillingPaymentRouteResponse } from './payment-route';\n\nexport async function createBillingPaymentFinishedResponse(\n request: Request,\n options: BillingPaymentFinishedRouteOptions = {},\n) {\n return createBillingPaymentRouteResponse(request, {\n ...options,\n routePath: '/auth/payment/finished',\n missingHandlerFile: 'lib/billing/payment-finished.ts',\n fallbackRedirect: options.fallbackRedirect ?? '/',\n phase: options.phase ?? 'finished',\n });\n}\n\nexport function createBillingPaymentFinishedRouteHandler(options: BillingPaymentFinishedRouteOptions = {}) {\n return async function GET(request: Request) {\n return createBillingPaymentFinishedResponse(request, options);\n };\n}\n\nexport type { BillingPaymentFinishedHandler };\n"],"mappings":";;;;;AAoCO,SAAS,gCACd,OACA,SACsB;AACtB,QAAM,QAAQ,MAAM,IAAI,CAAC,MAAM,UAAU;AACvC,UAAM,SAAS,QAAQ,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kCAAkC,SAAS;AAAA,IAChD,GAAG;AAAA,IACH,WAAW;AAAA,IACX,oBAAoB;AAAA,IACpB,kBAAkB,QAAQ,oBAAoB;AAAA,IAC9C,OAAO,QAAQ,SAAS;AAAA,EAC1B,CAAC;AACH;AAEO,SAAS,wCAAwC,UAA6C,CAAC,GAAG;AACvG,SAAO,eAAe,IAAI,SAAkB;AAC1C,WAAO,oCAAoC,SAAS,OAAO;AAAA,EAC7D;AACF;;;ACjBA,eAAsB,qCACpB,SACA,UAA8C,CAAC,GAC/C;AACA,SAAO,kCAAkC,SAAS;AAAA,IAChD,GAAG;AAAA,IACH,WAAW;AAAA,IACX,oBAAoB;AAAA,IACpB,kBAAkB,QAAQ,oBAAoB;AAAA,IAC9C,OAAO,QAAQ,SAAS;AAAA,EAC1B,CAAC;AACH;AAEO,SAAS,yCAAyC,UAA8C,CAAC,GAAG;AACzG,SAAO,eAAe,IAAI,SAAkB;AAC1C,WAAO,qCAAqC,SAAS,OAAO;AAAA,EAC9D;AACF;","names":["target"]}
@@ -792,14 +792,17 @@ export const GET = createBillingPaymentFinishedRouteHandler({
792
792
  }
793
793
  function billingPaymentSuccessHandlerTemplate() {
794
794
  return `import type { BillingPaymentSuccessHandler } from '@foldspace-fe/casdoor-next-auth-kit/billing';
795
+ import { resolveBillingOrderRedirect } from './order-redirect';
795
796
 
796
797
  ${customBegin}
797
798
  const paymentSuccessHandlerImpl: BillingPaymentSuccessHandler = async (context) => {
799
+ const redirectTarget = resolveBillingOrderRedirect(context.orderId || context.paymentId);
798
800
  console.info('[casdoor-next-auth-kit] payment success callback received', {
799
801
  paymentId: context.paymentId,
800
802
  orderId: context.orderId,
801
803
  status: context.status,
802
804
  redirectTo: context.redirectTo,
805
+ redirectTarget,
803
806
  });
804
807
  return;
805
808
  };
@@ -810,14 +813,17 @@ export const paymentSuccessHandler: BillingPaymentSuccessHandler = paymentSucces
810
813
  }
811
814
  function billingPaymentFinishedHandlerTemplate() {
812
815
  return `import type { BillingPaymentFinishedHandler } from '@foldspace-fe/casdoor-next-auth-kit/billing';
816
+ import { resolveBillingOrderRedirect } from './order-redirect';
813
817
 
814
818
  ${customBegin}
815
819
  const paymentFinishedHandlerImpl: BillingPaymentFinishedHandler = async (context) => {
820
+ const redirectTarget = resolveBillingOrderRedirect(context.orderId || context.paymentId);
816
821
  console.info('[casdoor-next-auth-kit] payment finished callback received', {
817
822
  paymentId: context.paymentId,
818
823
  orderId: context.orderId,
819
824
  status: context.status,
820
825
  redirectTo: context.redirectTo,
826
+ redirectTarget,
821
827
  });
822
828
  return;
823
829
  };
@@ -826,6 +832,16 @@ ${customEnd}
826
832
  export const paymentFinishedHandler: BillingPaymentFinishedHandler = paymentFinishedHandlerImpl;
827
833
  `;
828
834
  }
835
+ function billingOrderRedirectTemplate() {
836
+ return `export function resolveBillingOrderRedirect(orderIdOrPaymentId?: string | null): string | null {
837
+ if (!orderIdOrPaymentId) {
838
+ return null;
839
+ }
840
+
841
+ return null;
842
+ }
843
+ `;
844
+ }
829
845
  function authIndexHtmlTemplate() {
830
846
  return `export { AUTH_INDEX_HTML, createAuthIndexHtml } from '@foldspace-fe/casdoor-next-auth-kit';
831
847
  `;
@@ -895,10 +911,11 @@ export {
895
911
  paymentFinishedRouteTemplate,
896
912
  billingPaymentSuccessHandlerTemplate,
897
913
  billingPaymentFinishedHandlerTemplate,
914
+ billingOrderRedirectTemplate,
898
915
  authIndexHtmlTemplate,
899
916
  prismaSchemaTemplate,
900
917
  apiProxyRouteTemplate,
901
918
  commerceProxyRouteTemplate,
902
919
  envTemplate
903
920
  };
904
- //# sourceMappingURL=chunk-YHPSOLXM.js.map
921
+ //# sourceMappingURL=chunk-WNDID6YX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/prisma/schema-template.ts","../src/core/env.ts","../src/cli/fs.ts","../src/cli/templates.ts"],"sourcesContent":["import type { PrismaSchemaFieldDefinition, PrismaSchemaModelDefinition } from '../types';\n\nexport const AUTH_PRISMA_SCHEMA_MODELS: PrismaSchemaModelDefinition[] = [\n {\n name: 'AuthUser',\n description: 'Shared authentication user record',\n fields: [\n { name: 'id', type: 'String', attributes: ['@id', '@default(cuid())'] },\n { name: 'email', type: 'String?', attributes: ['@unique'] },\n { name: 'name', type: 'String?' },\n { name: 'image', type: 'String?' },\n { name: 'isAdmin', type: 'Boolean', attributes: ['@default(false)'] },\n { name: 'role', type: 'String', attributes: ['@default(\"user\")'] },\n { name: 'tokenBalance', type: 'Int', attributes: ['@default(0)'] },\n { name: 'isVip', type: 'Boolean', attributes: ['@default(false)'] },\n { name: 'createdAt', type: 'DateTime', attributes: ['@default(now())'] },\n { name: 'updatedAt', type: 'DateTime', attributes: ['@updatedAt'] },\n ],\n blockAttributes: ['@@index([email])'],\n },\n {\n name: 'AuthMembership',\n description: 'Subscription membership snapshot',\n fields: [\n { name: 'id', type: 'String', attributes: ['@id', '@default(cuid())'] },\n { name: 'userId', type: 'String', attributes: ['@unique'] },\n { name: 'plan', type: 'String' },\n { name: 'status', type: 'String' },\n { name: 'startsAt', type: 'DateTime?' },\n { name: 'endsAt', type: 'DateTime?' },\n { name: 'createdAt', type: 'DateTime', attributes: ['@default(now())'] },\n { name: 'updatedAt', type: 'DateTime', attributes: ['@updatedAt'] },\n ],\n blockAttributes: ['@@index([userId])'],\n },\n {\n name: 'AuthOrder',\n description: 'Commerce order record',\n fields: [\n { name: 'id', type: 'String', attributes: ['@id', '@default(cuid())'] },\n { name: 'userId', type: 'String' },\n { name: 'kind', type: 'String' },\n { name: 'status', type: 'String' },\n { name: 'amount', type: 'Int' },\n { name: 'currency', type: 'String', attributes: ['@default(\"CNY\")'] },\n { name: 'payload', type: 'Json?' },\n { name: 'createdAt', type: 'DateTime', attributes: ['@default(now())'] },\n { name: 'updatedAt', type: 'DateTime', attributes: ['@updatedAt'] },\n ],\n blockAttributes: ['@@index([userId])'],\n },\n {\n name: 'AuthSubscription',\n description: 'Commerce subscription record',\n fields: [\n { name: 'id', type: 'String', attributes: ['@id', '@default(cuid())'] },\n { name: 'userId', type: 'String' },\n { name: 'productId', type: 'String' },\n { name: 'status', type: 'String' },\n { name: 'interval', type: 'String' },\n { name: 'startsAt', type: 'DateTime?' },\n { name: 'endsAt', type: 'DateTime?' },\n { name: 'createdAt', type: 'DateTime', attributes: ['@default(now())'] },\n { name: 'updatedAt', type: 'DateTime', attributes: ['@updatedAt'] },\n ],\n blockAttributes: ['@@index([userId])', '@@index([productId])'],\n },\n {\n name: 'AuthInvoice',\n description: 'Commerce invoice record',\n fields: [\n { name: 'id', type: 'String', attributes: ['@id', '@default(cuid())'] },\n { name: 'userId', type: 'String' },\n { name: 'orderId', type: 'String?' },\n { name: 'invoiceNo', type: 'String', attributes: ['@unique'] },\n { name: 'status', type: 'String' },\n { name: 'amount', type: 'Int' },\n { name: 'createdAt', type: 'DateTime', attributes: ['@default(now())'] },\n { name: 'updatedAt', type: 'DateTime', attributes: ['@updatedAt'] },\n ],\n blockAttributes: ['@@index([userId])', '@@index([orderId])'],\n },\n];\n\nfunction renderField(field: PrismaSchemaFieldDefinition): string {\n const attributes = field.attributes?.length ? ` ${field.attributes.join(' ')}` : '';\n return ` ${field.name} ${field.type}${attributes}`;\n}\n\nfunction renderModel(model: PrismaSchemaModelDefinition): string {\n const lines = [\n `/// ${model.description}`,\n `model ${model.name} {`,\n ...model.fields.map(renderField),\n ];\n\n if (model.blockAttributes?.length) {\n lines.push(...model.blockAttributes.map((attribute) => ` ${attribute}`));\n }\n\n lines.push('}');\n return lines.join('\\n');\n}\n\nexport function buildAuthPrismaSchemaTemplate(models: PrismaSchemaModelDefinition[] = AUTH_PRISMA_SCHEMA_MODELS): string {\n return [\n '// generated by @foldspace-fe/casdoor-next-auth-kit',\n '// merge these models into the host Prisma schema if you want a dedicated auth module',\n '',\n ...models.map(renderModel),\n ].join('\\n\\n');\n}\n","import type { ManagedEnvFile, ManagedEnvVariableDefinition } from '../types';\n\nexport const AUTH_KIT_ENV_FILES: ManagedEnvFile[] = ['.env', '.env.local', '.env.production', '.env.example'];\n\nexport const AUTH_KIT_ENV_VARIABLES: ManagedEnvVariableDefinition[] = [\n {\n key: 'APP_URL',\n description: '站点对外公开地址',\n example: 'https://your-domain.com',\n local: 'http://localhost:5177',\n production: 'https://your-domain.com',\n },\n {\n key: 'NEXTAUTH_URL',\n description: 'NextAuth 回调地址',\n example: 'http://localhost:5177',\n local: 'http://localhost:5177',\n production: 'https://your-domain.com',\n },\n {\n key: 'NEXTAUTH_SECRET',\n description: 'NextAuth JWT secret',\n example: 'replace-with-a-random-secret',\n local: 'replace-with-a-random-secret',\n production: 'replace-with-a-random-secret',\n },\n {\n key: 'GLOBAL_ADMIN_EMAILS',\n description: '全局管理员邮箱,逗号分隔',\n example: 'admin@example.com',\n local: 'admin@example.com',\n production: 'admin@example.com',\n },\n {\n key: 'AUTH_DEBUG',\n description: '是否开启认证调试日志',\n example: 'false',\n local: 'false',\n production: 'false',\n },\n {\n key: 'NEXT_PUBLIC_CASDOOR_SERVER_URL',\n description: 'Casdoor 服务地址',\n example: 'https://auth.example.com',\n local: 'https://auth.example.com',\n production: 'https://auth.example.com',\n },\n {\n key: 'NEXT_PUBLIC_CASDOOR_CLIENT_ID',\n description: 'Casdoor client id',\n example: 'your-casdoor-client-id',\n local: 'your-casdoor-client-id',\n production: 'your-casdoor-client-id',\n },\n {\n key: 'NEXT_PUBLIC_CASDOOR_APP_NAME',\n description: 'Casdoor app name',\n example: 'your-app-name',\n local: 'your-app-name',\n production: 'your-app-name',\n },\n {\n key: 'NEXT_PUBLIC_CASDOOR_ORGANIZATION_NAME',\n description: 'Casdoor organization name',\n example: 'your-org-name',\n local: 'your-org-name',\n production: 'your-org-name',\n },\n {\n key: 'NEXT_PUBLIC_CASDOOR_REDIRECT_PATH',\n description: 'Casdoor OAuth 回调路径',\n example: '/callback',\n local: '/callback',\n production: '/callback',\n },\n {\n key: 'NEXT_PUBLIC_CASDOOR_SIGNIN_PATH',\n description: 'Casdoor authorize 路径',\n example: '/login/oauth/authorize',\n local: '/login/oauth/authorize',\n production: '/login/oauth/authorize',\n },\n {\n key: 'NEXT_PUBLIC_AUTH_LOGOUT_REDIRECT_PATH',\n description: '注销后跳转路径,默认首页',\n example: '/',\n local: '/',\n production: '/',\n },\n {\n key: 'NEXT_PUBLIC_BILLING_PURCHASABLE_IDS',\n description: 'Billing 可购买项白名单,逗号分隔',\n example: 'membership-monthly,credits-50',\n local: 'membership-monthly,credits-50',\n production: 'membership-monthly,credits-50',\n },\n {\n key: 'NEXT_PUBLIC_CASDOOR_STATIC_ORIGIN',\n description: 'Casdoor 静态资源 origin',\n example: 'https://casdoor-static.foldspace.cn',\n local: 'https://casdoor-static.foldspace.cn',\n production: 'https://casdoor-static.foldspace.cn',\n },\n {\n key: 'CASDOOR_CLIENT_SECRET',\n description: 'Casdoor client secret',\n example: 'your-casdoor-client-secret',\n local: 'your-casdoor-client-secret',\n production: 'your-casdoor-client-secret',\n },\n {\n key: 'BILLING_PAYMENT_SUCCESS_DEBUG',\n description: '是否打印 payment-success 调试日志',\n example: 'false',\n local: 'false',\n production: 'false',\n },\n];\n\nfunction stringifyEnvValue(value: string): string {\n if (value === '') {\n return '\"\"';\n }\n\n if (/^[A-Za-z0-9_./:-]+$/.test(value)) {\n return value;\n }\n\n return JSON.stringify(value);\n}\n\nfunction stripQuotes(value: string): string {\n const trimmed = value.trim();\n if (\n (trimmed.startsWith('\"') && trimmed.endsWith('\"')) ||\n (trimmed.startsWith(\"'\") && trimmed.endsWith(\"'\"))\n ) {\n return trimmed.slice(1, -1);\n }\n\n return trimmed;\n}\n\nfunction parseEnvKeys(content: string): Set<string> {\n const keys = new Set<string>();\n for (const line of content.split(/\\r?\\n/)) {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith('#')) {\n continue;\n }\n\n const separatorIndex = trimmed.indexOf('=');\n if (separatorIndex === -1) {\n continue;\n }\n\n const key = trimmed.slice(0, separatorIndex).trim();\n if (key) {\n keys.add(key);\n }\n }\n return keys;\n}\n\nexport function readManagedEnvValue(content: string, key: string): string | null {\n for (const line of content.split(/\\r?\\n/)) {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith('#')) {\n continue;\n }\n\n const separatorIndex = trimmed.indexOf('=');\n if (separatorIndex === -1) {\n continue;\n }\n\n const currentKey = trimmed.slice(0, separatorIndex).trim();\n if (currentKey !== key) {\n continue;\n }\n\n const rawValue = trimmed.slice(separatorIndex + 1).trim();\n return stripQuotes(rawValue);\n }\n\n return null;\n}\n\nexport function getManagedEnvValue(definition: ManagedEnvVariableDefinition, file: ManagedEnvFile): string {\n if (file === '.env.example') {\n return definition.example;\n }\n if (file === '.env.production') {\n return definition.production ?? definition.example;\n }\n if (file === '.env.local') {\n return definition.local ?? definition.example;\n }\n return definition.base ?? definition.local ?? definition.production ?? definition.example;\n}\n\nexport function buildManagedEnvTemplate(file: ManagedEnvFile, existingContent = ''): string {\n const existingKeys = parseEnvKeys(existingContent);\n const lines: string[] = existingContent.trimEnd() ? existingContent.trimEnd().split(/\\r?\\n/) : [];\n const missing = AUTH_KIT_ENV_VARIABLES.filter((definition) => !existingKeys.has(definition.key));\n\n if (missing.length === 0 && existingContent) {\n return existingContent;\n }\n\n if (lines.length > 0) {\n lines.push('');\n }\n\n lines.push(`# Casdoor Next Auth Kit managed values for ${file}`);\n for (const definition of missing) {\n const value = getManagedEnvValue(definition, file);\n lines.push(`# ${definition.description}`);\n lines.push(`${definition.key}=${stringifyEnvValue(value)}`);\n lines.push('');\n }\n\n while (lines.length > 0 && lines[lines.length - 1] === '') {\n lines.pop();\n }\n\n return `${lines.join('\\n')}\\n`;\n}\n\nexport function getMissingManagedEnvKeys(content: string): string[] {\n const existingKeys = parseEnvKeys(content);\n return AUTH_KIT_ENV_VARIABLES.filter((definition) => !existingKeys.has(definition.key)).map(\n (definition) => definition.key,\n );\n}\n\nexport function sanitizeExistingEnvContent(content: string): string {\n return stripQuotes(content);\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.ts';\nimport { buildAuthPrismaSchemaTemplate } from '../prisma/schema-template.ts';\nimport { AUTH_KIT_ENV_FILES, buildManagedEnvTemplate } from '../core/env.ts';\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 callbackErrorPageTemplate() {\n return `import { ClearDomainCookiesButton } from './clear-domain-cookies-button';\n\nexport const dynamic = 'force-dynamic';\n\nexport default async function CallbackErrorPage({\n searchParams,\n}: {\n searchParams: Promise<{ title?: string; message?: string; details?: string }>;\n}) {\n const params = await searchParams;\n\n return (\n <main\n style={{\n minHeight: '100dvh',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n padding: '20px 16px',\n background:\n 'radial-gradient(circle at top, rgba(99, 102, 241, 0.12) 0, rgba(99, 102, 241, 0) 38%), linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%)',\n }}\n >\n <section\n style={{\n width: 'min(100%, 400px)',\n borderRadius: 28,\n padding: '24px 20px',\n boxSizing: 'border-box',\n background: 'rgba(255, 255, 255, 0.96)',\n border: '1px solid rgba(148, 163, 184, 0.2)',\n boxShadow: '0 22px 52px rgba(15, 23, 42, 0.12)',\n textAlign: 'center',\n backdropFilter: 'blur(10px)',\n }}\n >\n <div\n style={{\n width: 52,\n height: 52,\n margin: '0 auto 14px',\n display: 'grid',\n placeItems: 'center',\n borderRadius: 18,\n background: 'linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(249, 115, 22, 0.1))',\n color: '#b91c1c',\n fontSize: 28,\n lineHeight: 1,\n }}\n aria-hidden=\"true\"\n >\n !\n </div>\n <div\n style={{\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n marginBottom: 12,\n padding: '6px 12px',\n borderRadius: 9999,\n background: 'rgba(254, 226, 226, 0.9)',\n color: '#b91c1c',\n fontSize: 13,\n fontWeight: 600,\n letterSpacing: '0.04em',\n }}\n >\n 认证失败\n </div>\n <h2 style={{ margin: 0, fontSize: 24, lineHeight: 1.2, color: '#0f172a' }}>{params.title ?? 'Callback Error'}</h2>\n <p style={{ margin: '12px 0 0', color: '#334155', lineHeight: 1.6 }}>{params.message ?? 'Unknown callback failure.'}</p>\n {params.details ? (\n <pre\n style={{\n margin: '14px 0 0',\n maxHeight: 140,\n overflow: 'auto',\n padding: 14,\n borderRadius: 18,\n textAlign: 'left',\n whiteSpace: 'pre-wrap',\n wordBreak: 'break-word',\n background: '#f8fafc',\n color: '#0f172a',\n border: '1px solid rgba(148, 163, 184, 0.18)',\n fontSize: 13,\n lineHeight: 1.6,\n }}\n >\n {params.details}\n </pre>\n ) : null}\n${customBegin}\n <div style={{ display: 'flex', flexDirection: 'column', gap: 10, marginTop: 20 }}>\n <ClearDomainCookiesButton />\n <a href=\"/\" style={{ display: 'inline-flex', width: '100%', alignItems: 'center', justifyContent: 'center', minHeight: 44, padding: '0 16px', boxSizing: 'border-box', borderRadius: 9999, border: '1px solid rgba(148, 163, 184, 0.35)', color: '#0f172a', textDecoration: 'none', background: 'rgba(248, 250, 252, 0.9)' }}>返回首页</a>\n <a href=\"/auth/login\" style={{ display: 'inline-flex', width: '100%', alignItems: 'center', justifyContent: 'center', minHeight: 44, padding: '0 16px', boxSizing: 'border-box', borderRadius: 9999, border: '1px solid rgba(148, 163, 184, 0.35)', color: '#0f172a', textDecoration: 'none', background: 'rgba(248, 250, 252, 0.9)' }}>重新登录</a>\n <a href=\"/auth/signup\" style={{ display: 'inline-flex', width: '100%', alignItems: 'center', justifyContent: 'center', minHeight: 44, padding: '0 16px', boxSizing: 'border-box', borderRadius: 9999, border: '1px solid rgba(148, 163, 184, 0.35)', color: '#0f172a', textDecoration: 'none', background: 'rgba(248, 250, 252, 0.9)' }}>去注册</a>\n </div>\n${customEnd}\n </section>\n </main>\n );\n}\n`;\n}\n\nexport function callbackErrorClearCookiesButtonTemplate() {\n return `'use client';\n\nimport { useState } from 'react';\n\nconst AUTH_COOKIE_NAMES = [\n 'auth_origin',\n 'auth_redirect',\n 'oauth_state',\n 'pkce_code_verifier',\n 'next-auth.session-token',\n '__Secure-next-auth.session-token',\n 'next-auth.csrf-token',\n '__Secure-next-auth.csrf-token',\n '__Host-next-auth.csrf-token',\n];\n\nfunction getPathCandidates(pathname: string): string[] {\n const normalized = pathname.startsWith('/') ? pathname : '/' + pathname;\n const segments = normalized.split('/').filter(Boolean);\n const paths = new Set<string>(['/']);\n\n let current = '';\n for (const segment of segments) {\n current += '/' + segment;\n paths.add(current);\n }\n\n return [...paths];\n}\n\nfunction getDomainCandidates(hostname: string): string[] {\n const normalized = hostname.toLowerCase();\n if (\n normalized === 'localhost' ||\n normalized.endsWith('.localhost') ||\n /^\\\\d+\\\\.\\\\d+\\\\.\\\\d+\\\\.\\\\d+$/.test(normalized) ||\n /^\\\\[[^\\\\]]+\\\\]$/.test(normalized)\n ) {\n return [];\n }\n\n const parts = normalized.split('.');\n if (parts.length < 2) {\n return [];\n }\n\n const domains = new Set<string>();\n for (let index = 0; index < parts.length - 1; index++) {\n const suffix = parts.slice(index).join('.');\n domains.add(suffix);\n domains.add('.' + suffix);\n }\n\n return [...domains];\n}\n\nfunction expireCookie(name: string, path: string, domain?: string) {\n const pieces = [\n name + '=',\n 'Max-Age=0',\n 'Expires=Thu, 01 Jan 1970 00:00:00 GMT',\n 'Path=' + path,\n 'SameSite=Lax',\n ];\n\n if (domain) {\n pieces.push('Domain=' + domain);\n }\n\n if (window.location.protocol === 'https:') {\n pieces.push('Secure');\n }\n\n document.cookie = pieces.join('; ');\n}\n\n${customBegin}\nexport function ClearDomainCookiesButton() {\n const [cleared, setCleared] = useState(false);\n\n const handleClick = () => {\n if (typeof document === 'undefined' || typeof window === 'undefined') {\n return;\n }\n\n const names = new Set<string>(AUTH_COOKIE_NAMES);\n for (const entry of document.cookie.split(';')) {\n const [rawName] = entry.trim().split('=');\n if (rawName) {\n names.add(rawName);\n }\n }\n\n const pathCandidates = getPathCandidates(window.location.pathname);\n const domainCandidates = getDomainCandidates(window.location.hostname);\n\n for (const name of names) {\n for (const path of pathCandidates) {\n expireCookie(name, path);\n for (const domain of domainCandidates) {\n expireCookie(name, path, domain);\n }\n }\n }\n\n setCleared(true);\n };\n\n return (\n <button\n type=\"button\"\n onClick={handleClick}\n disabled={cleared}\n style={{\n display: 'inline-flex',\n width: '100%',\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: 44,\n padding: '0 16px',\n boxSizing: 'border-box',\n borderRadius: 9999,\n border: '1px solid rgba(148, 163, 184, 0.35)',\n color: '#0f172a',\n background: cleared ? 'rgba(220, 252, 231, 0.92)' : 'rgba(248, 250, 252, 0.9)',\n cursor: cleared ? 'default' : 'pointer',\n }}\n >\n {cleared ? '已清空' : '清空当前域 Cookie'}\n </button>\n );\n}\n${customEnd}\n`;\n}\n\nexport function authConfigTemplate() {\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} from '@foldspace-fe/casdoor-next-auth-kit';\nimport { isGlobalAdminEmail } from '@foldspace-fe/casdoor-next-auth-kit';\nimport { paymentSuccessHandler as billingPaymentSuccessHandler } from '@/lib/billing/payment-success';\nimport { paymentFinishedHandler as billingPaymentFinishedHandler } from '@/lib/billing/payment-finished';\n\nexport function createAuthKitConfig(): AuthKitConfig {\n return {\n appUrl: process.env.APP_URL || '',\n nextauthSecret: process.env.NEXTAUTH_SECRET || 'dev-nextauth-secret',\n logoutRedirectPath: process.env.NEXT_PUBLIC_AUTH_LOGOUT_REDIRECT_PATH || '/',\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\nexport const authKitConfig = createAuthKitConfig();\n\nexport const adapter: AuthBusinessAdapter = {\n onUserSync: async (profile) => {\n const email = profile.email ?? null;\n const isAdmin = Boolean(profile.isAdmin) || isGlobalAdminEmail(email);\n\n return {\n id: String(profile.id ?? profile.sub ?? email ?? 'casdoor-user'),\n name: profile.name ?? profile.displayName ?? null,\n email,\n image: profile.picture ?? profile.avatarUrl ?? null,\n isAdmin,\n role: isAdmin ? 'admin' : 'user',\n tokenBalance: 2580,\n isVip: true,\n };\n },\n isAdminEmail: isGlobalAdminEmail,\n};\n\nexport const persistence: AuthPersistenceAdapter = {\n async syncAuthUser(user) {\n console.info('[casdoor-next-auth-kit] syncAuthUser received user', {\n id: user.id,\n email: user.email,\n isAdmin: user.isAdmin,\n role: user.role,\n });\n },\n async findAuthUser() {\n return null;\n },\n};\n\nexport const paymentSuccessHandler = billingPaymentSuccessHandler;\nexport const paymentFinishedHandler = billingPaymentFinishedHandler;\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 phase: 'success',\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 phase: 'finished',\n});\n`;\n}\n\nexport function billingPaymentSuccessHandlerTemplate() {\n return `import type { BillingPaymentSuccessHandler } from '@foldspace-fe/casdoor-next-auth-kit/billing';\nimport { resolveBillingOrderRedirect } from './order-redirect';\n\n${customBegin}\nconst paymentSuccessHandlerImpl: BillingPaymentSuccessHandler = async (context) => {\n const redirectTarget = resolveBillingOrderRedirect(context.orderId || context.paymentId);\n console.info('[casdoor-next-auth-kit] payment success callback received', {\n paymentId: context.paymentId,\n orderId: context.orderId,\n status: context.status,\n redirectTo: context.redirectTo,\n redirectTarget,\n });\n return;\n};\n${customEnd}\n\nexport const paymentSuccessHandler: BillingPaymentSuccessHandler = paymentSuccessHandlerImpl;\n`;\n}\n\nexport function billingPaymentFinishedHandlerTemplate() {\n return `import type { BillingPaymentFinishedHandler } from '@foldspace-fe/casdoor-next-auth-kit/billing';\nimport { resolveBillingOrderRedirect } from './order-redirect';\n\n${customBegin}\nconst paymentFinishedHandlerImpl: BillingPaymentFinishedHandler = async (context) => {\n const redirectTarget = resolveBillingOrderRedirect(context.orderId || context.paymentId);\n console.info('[casdoor-next-auth-kit] payment finished callback received', {\n paymentId: context.paymentId,\n orderId: context.orderId,\n status: context.status,\n redirectTo: context.redirectTo,\n redirectTarget,\n });\n return;\n};\n${customEnd}\n\nexport const paymentFinishedHandler: BillingPaymentFinishedHandler = paymentFinishedHandlerImpl;\n`;\n}\n\nexport function billingOrderRedirectTemplate() {\n return `export function resolveBillingOrderRedirect(orderIdOrPaymentId?: string | null): string | null {\n if (!orderIdOrPaymentId) {\n return null;\n }\n\n return null;\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"],"mappings":";AAEO,IAAM,4BAA2D;AAAA,EACtE;AAAA,IACE,MAAM;AAAA,IACN,aAAa;AAAA,IACb,QAAQ;AAAA,MACN,EAAE,MAAM,MAAM,MAAM,UAAU,YAAY,CAAC,OAAO,kBAAkB,EAAE;AAAA,MACtE,EAAE,MAAM,SAAS,MAAM,WAAW,YAAY,CAAC,SAAS,EAAE;AAAA,MAC1D,EAAE,MAAM,QAAQ,MAAM,UAAU;AAAA,MAChC,EAAE,MAAM,SAAS,MAAM,UAAU;AAAA,MACjC,EAAE,MAAM,WAAW,MAAM,WAAW,YAAY,CAAC,iBAAiB,EAAE;AAAA,MACpE,EAAE,MAAM,QAAQ,MAAM,UAAU,YAAY,CAAC,kBAAkB,EAAE;AAAA,MACjE,EAAE,MAAM,gBAAgB,MAAM,OAAO,YAAY,CAAC,aAAa,EAAE;AAAA,MACjE,EAAE,MAAM,SAAS,MAAM,WAAW,YAAY,CAAC,iBAAiB,EAAE;AAAA,MAClE,EAAE,MAAM,aAAa,MAAM,YAAY,YAAY,CAAC,iBAAiB,EAAE;AAAA,MACvE,EAAE,MAAM,aAAa,MAAM,YAAY,YAAY,CAAC,YAAY,EAAE;AAAA,IACpE;AAAA,IACA,iBAAiB,CAAC,kBAAkB;AAAA,EACtC;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,aAAa;AAAA,IACb,QAAQ;AAAA,MACN,EAAE,MAAM,MAAM,MAAM,UAAU,YAAY,CAAC,OAAO,kBAAkB,EAAE;AAAA,MACtE,EAAE,MAAM,UAAU,MAAM,UAAU,YAAY,CAAC,SAA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+BAA+B;AAC7C,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaT;AAEO,SAAS,uCAAuC;AACrD,SAAO;AAAA;AAAA;AAAA,EAGP,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYX,SAAS;AAAA;AAAA;AAAA;AAIX;AAEO,SAAS,wCAAwC;AACtD,SAAO;AAAA;AAAA;AAAA,EAGP,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYX,SAAS;AAAA;AAAA;AAAA;AAIX;AAEO,SAAS,+BAA+B;AAC7C,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQT;AAEW,SAAS,wBAAwB;AACtC,SAAO;AAAA;AAET;AAEO,SAAS,uBAAuB;AACrC,SAAO,8BAA8B;AACvC;AAEG,SAAS,wBAAwB;AACtC,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYT;AAEO,SAAS,6BAA6B;AAC3C,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYT;AAEW,SAAS,YAAY,MAAyC,kBAAkB,IAAI;AACzF,SAAO,wBAAwB,MAAM,eAAe;AACtD;","names":[]}
@@ -22,10 +22,11 @@ declare function paymentSuccessRouteTemplate(): string;
22
22
  declare function paymentFinishedRouteTemplate(): string;
23
23
  declare function billingPaymentSuccessHandlerTemplate(): string;
24
24
  declare function billingPaymentFinishedHandlerTemplate(): string;
25
+ declare function billingOrderRedirectTemplate(): string;
25
26
  declare function authIndexHtmlTemplate(): string;
26
27
  declare function prismaSchemaTemplate(): string;
27
28
  declare function apiProxyRouteTemplate(): string;
28
29
  declare function commerceProxyRouteTemplate(): string;
29
30
  declare function envTemplate(file: typeof AUTH_KIT_ENV_FILES[number], existingContent?: string): string;
30
31
 
31
- export { AUTH_KIT_ENV_FILES as A, AUTH_KIT_ENV_VARIABLES as a, apiProxyRouteTemplate as b, authConfigTemplate as c, authIndexHtmlTemplate as d, authLoginRouteTemplate as e, authSignupRouteTemplate as f, authorizeRouteTemplate as g, billingPaymentFinishedHandlerTemplate as h, billingPaymentSuccessHandlerTemplate as i, buildManagedEnvTemplate as j, callbackErrorClearCookiesButtonTemplate as k, callbackErrorPageTemplate as l, callbackRouteTemplate as m, commerceProxyRouteTemplate as n, envTemplate as o, getManagedEnvValue as p, getMissingManagedEnvKeys as q, logoutRouteTemplate as r, nextAuthRouteTemplate as s, paymentFinishedRouteTemplate as t, paymentSuccessRouteTemplate as u, prismaSchemaTemplate as v, readManagedEnvValue as w, sanitizeExistingEnvContent as x, signupAuthorizeRouteTemplate as y };
32
+ export { AUTH_KIT_ENV_FILES as A, AUTH_KIT_ENV_VARIABLES as a, apiProxyRouteTemplate as b, authConfigTemplate as c, authIndexHtmlTemplate as d, authLoginRouteTemplate as e, authSignupRouteTemplate as f, authorizeRouteTemplate as g, billingOrderRedirectTemplate as h, billingPaymentFinishedHandlerTemplate as i, billingPaymentSuccessHandlerTemplate as j, buildManagedEnvTemplate as k, callbackErrorClearCookiesButtonTemplate as l, callbackErrorPageTemplate as m, callbackRouteTemplate as n, commerceProxyRouteTemplate as o, envTemplate as p, getManagedEnvValue as q, getMissingManagedEnvKeys as r, logoutRouteTemplate as s, nextAuthRouteTemplate as t, paymentFinishedRouteTemplate as u, paymentSuccessRouteTemplate as v, prismaSchemaTemplate as w, readManagedEnvValue as x, sanitizeExistingEnvContent as y, signupAuthorizeRouteTemplate as z };
@@ -1,2 +1,2 @@
1
- export { c as authConfigTemplate } from './cli-templates-IhA9gjyF.js';
1
+ export { c as authConfigTemplate } from './cli-templates-DG-bTL-1.js';
2
2
  import './types-COXcI8tx.js';
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  authConfigTemplate
3
- } from "./chunk-YHPSOLXM.js";
3
+ } from "./chunk-WNDID6YX.js";
4
4
  export {
5
5
  authConfigTemplate
6
6
  };
package/dist/cli.js CHANGED
@@ -7,6 +7,7 @@ import {
7
7
  authLoginRouteTemplate,
8
8
  authSignupRouteTemplate,
9
9
  authorizeRouteTemplate,
10
+ billingOrderRedirectTemplate,
10
11
  billingPaymentFinishedHandlerTemplate,
11
12
  billingPaymentSuccessHandlerTemplate,
12
13
  callbackErrorClearCookiesButtonTemplate,
@@ -27,7 +28,7 @@ import {
27
28
  signupAuthorizeRouteTemplate,
28
29
  writeGeneratedFile,
29
30
  writeTextFile
30
- } from "./chunk-YHPSOLXM.js";
31
+ } from "./chunk-WNDID6YX.js";
31
32
 
32
33
  // package.json
33
34
  var package_default = {
@@ -128,6 +129,7 @@ var targets = [
128
129
  ["app/(auth-kit)/auth/api/commerce/[...path]/route.ts", commerceProxyRouteTemplate],
129
130
  ["lib/billing/payment-success.ts", billingPaymentSuccessHandlerTemplate],
130
131
  ["lib/billing/payment-finished.ts", billingPaymentFinishedHandlerTemplate],
132
+ ["lib/billing/order-redirect.ts", billingOrderRedirectTemplate],
131
133
  ["app/(auth-kit)/index-html.ts", authIndexHtmlTemplate],
132
134
  ["prisma/auth-kit.prisma", prismaSchemaTemplate]
133
135
  ];
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../package.json","../src/cli/operations.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\": \"git+https://github.com/foldspace-stack/casdoor-next-auth-kit.git\"\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 \"test\": \"pnpm build && node --test --experimental-strip-types ./scripts/verify-casdoor-proxy.mjs ./test/*.test.ts\",\n \"lint\": \"tsc -p tsconfig.json --noEmit\",\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 callbackErrorClearCookiesButtonTemplate,\n callbackErrorPageTemplate,\n authorizeRouteTemplate,\n callbackRouteTemplate,\n billingPaymentFinishedHandlerTemplate,\n billingPaymentSuccessHandlerTemplate,\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)/callback/error/page.tsx', callbackErrorPageTemplate],\n ['app/(auth-kit)/callback/error/clear-domain-cookies-button.tsx', callbackErrorClearCookiesButtonTemplate],\n ['app/(auth-kit)/logout/route.ts', logoutRouteTemplate],\n ['app/(auth-kit)/auth/api/commerce/[...path]/route.ts', commerceProxyRouteTemplate],\n ['lib/billing/payment-success.ts', billingPaymentSuccessHandlerTemplate],\n ['lib/billing/payment-finished.ts', billingPaymentFinishedHandlerTemplate],\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-kit)/callback/error/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 if (rel === 'app/(auth-kit)/auth-config.ts') {\n const current = read(filePath);\n if (current !== next) {\n writeTextFile(filePath, next);\n logUpdated(filePath);\n }\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 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","#!/usr/bin/env node\nimport { 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,S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AAI,YAAY,OAAQ,QAAO,YAAY;AAC3C,MAAI,YAAY,SAAU,QAAO,cAAc;AAC/C,MAAI,YAAY,QAAS,QAAO,aAAa;AAC7C,aAAW;AACb;;;ACrBA,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":["current"]}
1
+ {"version":3,"sources":["../package.json","../src/cli/operations.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\": \"git+https://github.com/foldspace-stack/casdoor-next-auth-kit.git\"\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 \"test\": \"pnpm build && node --test --experimental-strip-types ./scripts/verify-casdoor-proxy.mjs ./test/*.test.ts\",\n \"lint\": \"tsc -p tsconfig.json --noEmit\",\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 callbackErrorClearCookiesButtonTemplate,\n callbackErrorPageTemplate,\n authorizeRouteTemplate,\n callbackRouteTemplate,\n billingPaymentFinishedHandlerTemplate,\n billingOrderRedirectTemplate,\n billingPaymentSuccessHandlerTemplate,\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)/callback/error/page.tsx', callbackErrorPageTemplate],\n ['app/(auth-kit)/callback/error/clear-domain-cookies-button.tsx', callbackErrorClearCookiesButtonTemplate],\n ['app/(auth-kit)/logout/route.ts', logoutRouteTemplate],\n ['app/(auth-kit)/auth/api/commerce/[...path]/route.ts', commerceProxyRouteTemplate],\n ['lib/billing/payment-success.ts', billingPaymentSuccessHandlerTemplate],\n ['lib/billing/payment-finished.ts', billingPaymentFinishedHandlerTemplate],\n ['lib/billing/order-redirect.ts', billingOrderRedirectTemplate],\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-kit)/callback/error/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 if (rel === 'app/(auth-kit)/auth-config.ts') {\n const current = read(filePath);\n if (current !== next) {\n writeTextFile(filePath, next);\n logUpdated(filePath);\n }\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 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","#!/usr/bin/env node\nimport { 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,M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AS;AAAA,EAC3D,CAAC;AACD,QAAM,WAAW,KAAK,KAAK,aAAa,WAAW;AACnD,QAAM,eAAe,OAAO,KAAK,KAAK,UAAU,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,aAAa,UAAU,CAAC;AACvG,QAAM,UAAU,CAAC,GAAG,eAAe,GAAG,YAAY,GAAG,YAAY;AAEjE,MAAI,QAAQ,SAAS,GAAG;AACtB,YAAQ,MAAM,0BAA0B;AACxC,eAAW,OAAO,SAAS;AACzB,cAAQ,MAAM,OAAO,GAAG;AAAA,IAC1B;AACA,YAAQ,WAAW;AACnB;AAAA,EACF;AAEA,UAAQ,IAAI,gCAAgC;AAC9C;;;AC3NA,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;;;ACrBA,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":["current"]}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { b as AuthKitConfig, a as AuthUser, e as AuthIndexHtmlOptions, P as PrismaSchemaModelDefinition } from './types-COXcI8tx.js';
2
2
  export { c as AuthBusinessAdapter, f as AuthDatabaseContract, g as AuthDatabaseFieldRequirement, h as AuthDatabaseTableRequirement, d as AuthPersistenceAdapter, i as AuthRuntimeContext, A as AuthUserRole, C as CasdoorUserInfo, M as ManagedEnvFile, j as ManagedEnvVariableDefinition, O as OAuthTokens, k as PrismaSchemaFieldDefinition } from './types-COXcI8tx.js';
3
- export { A as AUTH_KIT_ENV_FILES, a as AUTH_KIT_ENV_VARIABLES, b as apiProxyRouteTemplate, c as authConfigTemplate, d as authIndexHtmlTemplate, e as authLoginRouteTemplate, f as authSignupRouteTemplate, g as authorizeRouteTemplate, h as billingPaymentFinishedHandlerTemplate, i as billingPaymentSuccessHandlerTemplate, j as buildManagedEnvTemplate, k as callbackErrorClearCookiesButtonTemplate, l as callbackErrorPageTemplate, m as callbackRouteTemplate, n as commerceProxyRouteTemplate, o as envTemplate, p as getManagedEnvValue, q as getMissingManagedEnvKeys, r as logoutRouteTemplate, s as nextAuthRouteTemplate, t as paymentFinishedRouteTemplate, u as paymentSuccessRouteTemplate, v as prismaSchemaTemplate, w as readManagedEnvValue, x as sanitizeExistingEnvContent, y as signupAuthorizeRouteTemplate } from './cli-templates-IhA9gjyF.js';
3
+ export { A as AUTH_KIT_ENV_FILES, a as AUTH_KIT_ENV_VARIABLES, b as apiProxyRouteTemplate, c as authConfigTemplate, d as authIndexHtmlTemplate, e as authLoginRouteTemplate, f as authSignupRouteTemplate, g as authorizeRouteTemplate, h as billingOrderRedirectTemplate, i as billingPaymentFinishedHandlerTemplate, j as billingPaymentSuccessHandlerTemplate, k as buildManagedEnvTemplate, l as callbackErrorClearCookiesButtonTemplate, m as callbackErrorPageTemplate, n as callbackRouteTemplate, o as commerceProxyRouteTemplate, p as envTemplate, q as getManagedEnvValue, r as getMissingManagedEnvKeys, s as logoutRouteTemplate, t as nextAuthRouteTemplate, u as paymentFinishedRouteTemplate, v as paymentSuccessRouteTemplate, w as prismaSchemaTemplate, x as readManagedEnvValue, y as sanitizeExistingEnvContent, z as signupAuthorizeRouteTemplate } from './cli-templates-DG-bTL-1.js';
4
4
  import { JWTDecodeParams, JWT, JWTEncodeParams } from 'next-auth/jwt';
5
5
  export { A as AuthSummaryRole, a as AuthUserLike, b as AuthUserSummaryShape, c as buildAuthUserFromProfile, d as buildAuthUserFromToken, e as buildAuthUserSummary, r as resolveAuthUserRole } from './auth-role-C35sP1i6.js';
6
6
  export { createAuthorizeEntryResponse, createCasdoorApiProxyHandler, createCasdoorCommerceProxyHandler, createCasdoorPageProxyHandler, createLoginEntryResponse, createSignupEntryResponse, getCasdoorAuthorizeUrl, getCasdoorConfig, getCasdoorTokenUrl, getCasdoorUserInfoUrl } from './casdoor/index.js';
@@ -8,7 +8,7 @@ export { C as CallbackHandlerOptions, c as createCallbackHandler, a as createCal
8
8
  export { createAuthorizeRouteHandler, createLoginRouteHandler, createLogoutHandler, createSignupRouteHandler } from './next/index.js';
9
9
  export { A as AuthSession, a as AuthSessionUser, b as AuthTokenPayload, N as NextAuthRouteOptions, c as createNextAuthOptions, d as createNextAuthRouteHandler, r as resolveAuthUserFromToken } from './options-CpWDszxZ.js';
10
10
  export { z as BillingActionExecutionResult, f as BillingActionExecutor, A as BillingActionKind, B as BillingActionPayload, d as BillingApiClient, C as BillingCasdoorAccountDetail, D as BillingCasdoorAccountMultiFactorAuthDetail, E as BillingCasdoorAccountResponse, F as BillingCasdoorApiResponse, G as BillingCasdoorApplicationDetail, H as BillingCasdoorApplicationProviderDetail, I as BillingCasdoorApplicationResponse, J as BillingCasdoorApplicationSigninItemDetail, K as BillingCasdoorApplicationSigninMethodDetail, L as BillingCasdoorApplicationSignupItemDetail, M as BillingCasdoorBuyProductRequest, N as BillingCasdoorBuyProductResponse, O as BillingCasdoorErrorDetail, P as BillingCasdoorErrorPayload, t as BillingCasdoorOrderDetail, Q as BillingCasdoorOrderResponse, R as BillingCasdoorOrdersResponse, S as BillingCasdoorOrganizationDetail, T as BillingCasdoorOrganizationNamesResponse, U as BillingCasdoorOrganizationOption, V as BillingCasdoorPaymentDetail, W as BillingCasdoorPaymentResponse, u as BillingCasdoorPlanDetail, X as BillingCasdoorPlanResponse, v as BillingCasdoorPricingDetail, Y as BillingCasdoorPricingResponse, w as BillingCasdoorProductDetail, Z as BillingCasdoorProductResponse, _ as BillingCasdoorProviderDetail, $ as BillingCasdoorProviderOption, s as BillingCasdoorQueryState, x as BillingCasdoorSubscriptionDetail, a0 as BillingCasdoorSubscriptionResponse, a1 as BillingCasdoorSubscriptionsResponse, c as BillingCatalogConfig, a2 as BillingConversionRule, y as BillingCoreContextValue, a3 as BillingCreditsContextValue, m as BillingCreditsState, g as BillingDefaults, n as BillingEntitlementState, a4 as BillingInterval, a as BillingItem, a5 as BillingItemKind, e as BillingLoaders, a6 as BillingOrderCreatedContext, k as BillingOrderHistoryItem, a7 as BillingPaymentCallbackContext, a8 as BillingPaymentFinishedContext, a9 as BillingPaymentFinishedHandler, aa as BillingPaymentFinishedRouteOptions, l as BillingPaymentHistoryItem, ab as BillingPaymentRouteBaseOptions, ac as BillingPaymentSuccessContext, ad as BillingPaymentSuccessHandler, ae as BillingPaymentSuccessHandlerResult, af as BillingPaymentSuccessRouteOptions, ag as BillingProductContextValue, ah as BillingProductDetailState, ai as BillingProductPurchasableEntry, aj as BillingProductPurchaseConfig, r as BillingProductSnapshot, j as BillingProductState, ak as BillingPurchasableEntry, al as BillingPurchasableEntryBase, am as BillingPurchasableKind, an as BillingPurchasableWhitelist, ao as BillingPurchaseCompleteContext, ap as BillingPurchaseErrorContext, q as BillingPurchaseHooks, aq as BillingPurchaseRequest, p as BillingPurchaseStatus, b as BillingRuntimeConfig, o as BillingStatusState, ar as BillingSubscriptionContextValue, i as BillingSubscriptionHistoryItem, as as BillingSubscriptionPurchasableEntry, at as BillingSubscriptionPurchaseConfig, h as BillingSubscriptionState } from './types-oVIQpMut.js';
11
- export { BillingSubscriptionCatalogBuilderOptions, BillingSubscriptionCatalogItemInput, NormalizedCasdoorProductId, buildBillingActionPayload, buildBillingPaymentCallbackContext, buildBillingPurchaseRequest, buildBillingSubscriptionCatalog, buildCasdoorBuyProductParams, buildCasdoorBuyProductRequest, chooseCasdoorProviderName, createBillingPaymentFinishedResponse, createBillingPaymentFinishedRouteHandler, createBillingPaymentSuccessResponse, createBillingPaymentSuccessRouteHandler, deriveBillingCreditsState, deriveBillingEntitlements, filterBillingPurchasableItems, normalizeBillingCatalogConfig, normalizeBillingPurchaseStatus, normalizeBillingRuntimeConfig, normalizeCasdoorBuyProductResponse, normalizeCasdoorOrderHistoryItem, normalizeCasdoorPaymentHistoryItem, normalizeCasdoorProductId, normalizeCasdoorSubscriptionDetail, normalizeCasdoorSubscriptionHistoryItem, readBuyProductRedirectTo, resolveBillingInterval, resolveBillingItem, resolveBillingProductSnapshot, resolveBillingPurchasable, resolveBillingSubscriptionProduct } from './billing/index.js';
11
+ export { BillingSubscriptionCatalogBuilderOptions, BillingSubscriptionCatalogItemInput, NormalizedCasdoorProductId, buildBillingActionPayload, buildBillingPaymentCallbackContext, buildBillingPurchaseRequest, buildBillingSubscriptionCatalog, buildCasdoorBuyProductParams, buildCasdoorBuyProductRequest, chooseCasdoorProviderName, createBillingPaymentFinishedResponse, createBillingPaymentFinishedRouteHandler, createBillingPaymentSuccessResponse, createBillingPaymentSuccessRouteHandler, deriveBillingCreditsState, deriveBillingEntitlements, filterBillingPurchasableItems, normalizeBillingCatalogConfig, normalizeBillingPurchaseStatus, normalizeBillingRuntimeConfig, normalizeCasdoorBuyProductResponse, normalizeCasdoorOrderHistoryItem, normalizeCasdoorPaymentHistoryItem, normalizeCasdoorProductId, normalizeCasdoorSubscriptionDetail, normalizeCasdoorSubscriptionHistoryItem, readBuyProductRedirectTo, resolveBillingInterval, resolveBillingItem, resolveBillingOrderRedirect, resolveBillingProductSnapshot, resolveBillingPurchasable, resolveBillingSubscriptionProduct } from './billing/index.js';
12
12
  import 'next/server';
13
13
  import 'next-auth';
14
14
 
package/dist/index.js CHANGED
@@ -8,6 +8,7 @@ import {
8
8
  authLoginRouteTemplate,
9
9
  authSignupRouteTemplate,
10
10
  authorizeRouteTemplate,
11
+ billingOrderRedirectTemplate,
11
12
  billingPaymentFinishedHandlerTemplate,
12
13
  billingPaymentSuccessHandlerTemplate,
13
14
  buildAuthPrismaSchemaTemplate,
@@ -27,19 +28,46 @@ import {
27
28
  readManagedEnvValue,
28
29
  sanitizeExistingEnvContent,
29
30
  signupAuthorizeRouteTemplate
30
- } from "./chunk-YHPSOLXM.js";
31
+ } from "./chunk-WNDID6YX.js";
31
32
  import {
32
33
  buildBillingSubscriptionCatalog,
33
34
  createBillingPaymentFinishedResponse,
34
35
  createBillingPaymentFinishedRouteHandler,
35
36
  createBillingPaymentSuccessResponse,
36
- createBillingPaymentSuccessRouteHandler
37
- } from "./chunk-PILMR42A.js";
37
+ createBillingPaymentSuccessRouteHandler,
38
+ resolveBillingOrderRedirect
39
+ } from "./chunk-3SUYZDBE.js";
38
40
  import {
39
41
  createCasdoorApiProxyHandler,
40
42
  createCasdoorCommerceProxyHandler,
41
43
  createCasdoorPageProxyHandler
42
44
  } from "./chunk-5W4H2IMT.js";
45
+ import {
46
+ buildBillingActionPayload,
47
+ buildBillingPaymentCallbackContext,
48
+ buildBillingPurchaseRequest,
49
+ buildCasdoorBuyProductParams,
50
+ buildCasdoorBuyProductRequest,
51
+ chooseCasdoorProviderName,
52
+ deriveBillingCreditsState,
53
+ deriveBillingEntitlements,
54
+ filterBillingPurchasableItems,
55
+ normalizeBillingCatalogConfig,
56
+ normalizeBillingPurchaseStatus,
57
+ normalizeBillingRuntimeConfig,
58
+ normalizeCasdoorBuyProductResponse,
59
+ normalizeCasdoorOrderHistoryItem,
60
+ normalizeCasdoorPaymentHistoryItem,
61
+ normalizeCasdoorProductId,
62
+ normalizeCasdoorSubscriptionDetail,
63
+ normalizeCasdoorSubscriptionHistoryItem,
64
+ readBuyProductRedirectTo,
65
+ resolveBillingInterval,
66
+ resolveBillingItem,
67
+ resolveBillingProductSnapshot,
68
+ resolveBillingPurchasable,
69
+ resolveBillingSubscriptionProduct
70
+ } from "./chunk-FL6LOXEG.js";
43
71
  import {
44
72
  createAuthorizeRouteHandler,
45
73
  createLoginRouteHandler,
@@ -88,32 +116,6 @@ import {
88
116
  verifyState,
89
117
  verifyStateToken
90
118
  } from "./chunk-IPJT66SK.js";
91
- import {
92
- buildBillingActionPayload,
93
- buildBillingPaymentCallbackContext,
94
- buildBillingPurchaseRequest,
95
- buildCasdoorBuyProductParams,
96
- buildCasdoorBuyProductRequest,
97
- chooseCasdoorProviderName,
98
- deriveBillingCreditsState,
99
- deriveBillingEntitlements,
100
- filterBillingPurchasableItems,
101
- normalizeBillingCatalogConfig,
102
- normalizeBillingPurchaseStatus,
103
- normalizeBillingRuntimeConfig,
104
- normalizeCasdoorBuyProductResponse,
105
- normalizeCasdoorOrderHistoryItem,
106
- normalizeCasdoorPaymentHistoryItem,
107
- normalizeCasdoorProductId,
108
- normalizeCasdoorSubscriptionDetail,
109
- normalizeCasdoorSubscriptionHistoryItem,
110
- readBuyProductRedirectTo,
111
- resolveBillingInterval,
112
- resolveBillingItem,
113
- resolveBillingProductSnapshot,
114
- resolveBillingPurchasable,
115
- resolveBillingSubscriptionProduct
116
- } from "./chunk-FL6LOXEG.js";
117
119
  import {
118
120
  buildAuthJumpHref,
119
121
  buildAuthUserFromProfile,
@@ -135,6 +137,7 @@ export {
135
137
  authLoginRouteTemplate,
136
138
  authSignupRouteTemplate,
137
139
  authorizeRouteTemplate,
140
+ billingOrderRedirectTemplate,
138
141
  billingPaymentFinishedHandlerTemplate,
139
142
  billingPaymentSuccessHandlerTemplate,
140
143
  buildAuthJumpHref,
@@ -223,6 +226,7 @@ export {
223
226
  resolveAuthUserRole,
224
227
  resolveBillingInterval,
225
228
  resolveBillingItem,
229
+ resolveBillingOrderRedirect,
226
230
  resolveBillingProductSnapshot,
227
231
  resolveBillingPurchasable,
228
232
  resolveBillingSubscriptionProduct,
@@ -482,6 +482,8 @@ Billing 支付成功后,Casdoor 会回跳到宿主站内的两个固定回调
482
482
 
483
483
  `app/(auth-kit)/auth-config.ts` 必须显式导出 `authKitConfig`、`adapter`、`persistence`、`paymentSuccessHandler` 和 `paymentFinishedHandler`,route 文件必须能直接从这个文件拿到所需配置和 handler,不要只保留局部变量让 route 间接取值。
484
484
 
485
+ `lib/billing/order-redirect.ts` 是 billing 回跳归一化的共享 helper,`lib/billing/payment-success.ts` 和 `lib/billing/payment-finished.ts` 都会直接导入它;`npx ... update` 后如果这些 import 不见了,说明模板或生成结果已经不一致。
486
+
485
487
  billing 默认就是受管内容,CLI 必须同时生成 `lib/billing/payment-success.ts` 和 `lib/billing/payment-finished.ts`,`auth-config.ts` 直接导入这两个默认文件,不要要求宿主手工创建 `@/lib/billing/*`。
486
488
 
487
489
  如果默认处理器没有写入业务逻辑,路由仍会打印日志并回退到默认落点:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foldspace-fe/casdoor-next-auth-kit",
3
- "version": "0.1.24",
3
+ "version": "0.1.26",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "repository": {
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/billing/subscription-catalog.ts","../src/billing/payment-route.ts","../src/core/origin.ts","../src/billing/payment-success.ts","../src/billing/payment-finished.ts"],"sourcesContent":["import type {\n BillingCatalogConfig,\n BillingDefaults,\n BillingInterval,\n BillingItem,\n} from './types';\n\nexport interface BillingSubscriptionCatalogItemInput<TSource = unknown> {\n source: TSource;\n key: string;\n title: string;\n description?: string;\n productId: string;\n planId?: string;\n priceId?: string;\n interval?: BillingInterval;\n featured?: boolean;\n badge?: string;\n priceLabel?: string;\n priceValue?: number;\n features?: string[];\n metadata?: Record<string, string>;\n}\n\nexport interface BillingSubscriptionCatalogBuilderOptions<TSource = unknown> {\n catalogKey: string;\n title?: string;\n description?: string;\n portalPath?: string;\n successPath?: string;\n cancelPath?: string;\n purchasableIds?: string[];\n defaults?: BillingDefaults;\n mapPlan: (plan: TSource, index: number) => BillingSubscriptionCatalogItemInput<TSource>;\n}\n\nexport function buildBillingSubscriptionCatalog<TSource>(\n plans: readonly TSource[],\n options: BillingSubscriptionCatalogBuilderOptions<TSource>,\n): BillingCatalogConfig {\n const items = plans.map((plan, index) => {\n const mapped = options.mapPlan(plan, index);\n\n return {\n key: mapped.key,\n kind: 'subscription',\n title: mapped.title,\n description: mapped.description,\n featured: mapped.featured,\n badge: mapped.badge,\n priceLabel: mapped.priceLabel,\n priceValue: mapped.priceValue,\n interval: mapped.interval,\n features: mapped.features,\n backendRef: {\n productId: mapped.productId,\n planId: mapped.planId,\n priceId: mapped.priceId,\n },\n metadata: mapped.metadata,\n } satisfies BillingItem;\n });\n\n return {\n catalogKey: options.catalogKey,\n title: options.title,\n description: options.description,\n portalPath: options.portalPath,\n successPath: options.successPath,\n cancelPath: options.cancelPath,\n purchasableIds: options.purchasableIds ?? items.map((item) => item.key),\n purchasables: [],\n conversionRules: [],\n defaults: options.defaults ?? {},\n items,\n };\n}\n","import { NextResponse } from 'next/server';\n\nimport { resolvePublicOrigin } from '../core/origin';\nimport { buildBillingPaymentCallbackContext } from './runtime';\nimport type {\n BillingPaymentRouteBaseOptions,\n BillingPaymentFinishedRouteOptions,\n BillingPaymentFinishedContext,\n BillingPaymentFinishedHandler,\n BillingPaymentSuccessContext,\n BillingPaymentSuccessHandlerResult,\n BillingPaymentSuccessRouteOptions,\n} from './types';\n\nexport interface BillingPaymentRouteOptions extends BillingPaymentRouteBaseOptions {\n routePath: string;\n missingHandlerFile: string;\n handler?: BillingPaymentSuccessRouteOptions['handler'] | BillingPaymentFinishedRouteOptions['handler'];\n phase?: 'success' | 'failure' | 'finished';\n}\n\nfunction sanitizeRedirectPath(value: string | null | undefined, fallback: string): string {\n if (!value || !value.startsWith('/') || value.startsWith('//')) {\n return fallback;\n }\n\n return value;\n}\n\nfunction isDebugEnabled(): boolean {\n const value = process.env.BILLING_PAYMENT_SUCCESS_DEBUG;\n if (!value) {\n return false;\n }\n\n return ['1', 'true', 'yes', 'on'].includes(value.toLowerCase());\n}\n\nfunction resolveRedirectTarget(\n result: BillingPaymentSuccessHandlerResult | undefined,\n context: BillingPaymentSuccessContext,\n fallbackRedirect: string,\n): string {\n if (typeof result === 'string') {\n return sanitizeRedirectPath(result, fallbackRedirect);\n }\n\n if (result && typeof result === 'object' && 'redirectTo' in result) {\n return sanitizeRedirectPath(result.redirectTo ?? null, fallbackRedirect);\n }\n\n return sanitizeRedirectPath(context.redirectTo, fallbackRedirect);\n}\n\nfunction resolveFallbackTarget(fallbackRedirect: string): string {\n return sanitizeRedirectPath(fallbackRedirect, '/');\n}\n\nfunction logMissingPaymentHandler(\n context: BillingPaymentSuccessContext,\n fallbackRedirect: string,\n missingHandlerFile: string,\n routePath: string,\n): void {\n console.warn(\n `[casdoor-next-auth-kit] default billing handler at ${missingHandlerFile} has no business logic. ` +\n `Edit this file to handle ${routePath} with order/payment enrichment before redirecting. ` +\n `Falling back to ${fallbackRedirect}.`,\n {\n paymentOwner: context.paymentOwner,\n paymentName: context.paymentName,\n paymentId: context.paymentId,\n orderId: context.orderId,\n params: context.params,\n },\n );\n}\n\nexport async function createBillingPaymentRouteResponse(\n request: Request,\n options: BillingPaymentRouteOptions,\n) {\n const origin = resolvePublicOrigin(request, options.appUrl);\n const fallbackRedirect = options.fallbackRedirect ?? '/';\n const context = await buildBillingPaymentCallbackContext(request, options.phase);\n\n if (isDebugEnabled()) {\n console.info(`[casdoor-next-auth-kit] ${options.routePath} request`, {\n method: request.method,\n path: context.url.pathname,\n query: context.params,\n body: context.body,\n });\n }\n\n try {\n if (options.handler) {\n const handler = options.handler;\n const result =\n options.phase === 'finished'\n ? await (handler as BillingPaymentFinishedHandler)(context as BillingPaymentFinishedContext)\n : await (handler as NonNullable<BillingPaymentSuccessRouteOptions['handler']>)(context);\n if (result instanceof Response) {\n return result;\n }\n\n const target = resolveRedirectTarget(result, context, fallbackRedirect);\n return NextResponse.redirect(new URL(target, origin), 307);\n }\n\n logMissingPaymentHandler(context, fallbackRedirect, options.missingHandlerFile, options.routePath);\n const target = resolveFallbackTarget(fallbackRedirect);\n return NextResponse.redirect(new URL(target, origin), 307);\n } catch (error) {\n console.error(`[casdoor-next-auth-kit] ${options.routePath} handler failed:`, error);\n return new NextResponse('Billing payment handler failed', { status: 500 });\n }\n}\n","export function normalizeOrigin(value: string | null | undefined): string | null {\n if (!value) return null;\n try {\n return new URL(value).origin;\n } catch {\n return null;\n }\n}\n\nexport function getRequestOrigin(request: Request, appUrl?: string): string {\n const configured = normalizeOrigin(appUrl);\n if (configured) return configured;\n\n const referer = normalizeOrigin(request.headers.get('referer'));\n if (referer) return referer;\n\n const origin = normalizeOrigin(request.headers.get('origin'));\n if (origin) return origin;\n\n const forwardedProto = request.headers.get('x-forwarded-proto')?.split(',')[0]?.trim();\n const forwardedHost = request.headers.get('x-forwarded-host')?.split(',')[0]?.trim();\n if (forwardedProto && forwardedHost) {\n return forwardedProto + '://' + forwardedHost;\n }\n\n return new URL(request.url).origin;\n}\n\nexport function resolvePublicOrigin(request: Request, appUrl?: string): string {\n return getRequestOrigin(request, appUrl);\n}\n","import type { BillingPaymentSuccessHandler, BillingPaymentSuccessRouteOptions } from './types';\nimport { createBillingPaymentRouteResponse } from './payment-route';\n\nexport async function createBillingPaymentSuccessResponse(\n request: Request,\n options: BillingPaymentSuccessRouteOptions = {},\n) {\n return createBillingPaymentRouteResponse(request, {\n ...options,\n routePath: '/auth/payment/success',\n missingHandlerFile: 'lib/billing/payment-success.ts',\n fallbackRedirect: options.fallbackRedirect ?? '/auth/payment/finished',\n phase: options.phase ?? 'success',\n });\n}\n\nexport function createBillingPaymentSuccessRouteHandler(options: BillingPaymentSuccessRouteOptions = {}) {\n return async function GET(request: Request) {\n return createBillingPaymentSuccessResponse(request, options);\n };\n}\n\nexport type { BillingPaymentSuccessHandler };\n","import type { BillingPaymentFinishedHandler, BillingPaymentFinishedRouteOptions } from './types';\nimport { createBillingPaymentRouteResponse } from './payment-route';\n\nexport async function createBillingPaymentFinishedResponse(\n request: Request,\n options: BillingPaymentFinishedRouteOptions = {},\n) {\n return createBillingPaymentRouteResponse(request, {\n ...options,\n routePath: '/auth/payment/finished',\n missingHandlerFile: 'lib/billing/payment-finished.ts',\n fallbackRedirect: options.fallbackRedirect ?? '/',\n phase: options.phase ?? 'finished',\n });\n}\n\nexport function createBillingPaymentFinishedRouteHandler(options: BillingPaymentFinishedRouteOptions = {}) {\n return async function GET(request: Request) {\n return createBillingPaymentFinishedResponse(request, options);\n };\n}\n\nexport type { BillingPaymentFinishedHandler };\n"],"mappings":";;;;;AAoCO,SAAS,gCACd,OACA,SACsB;AACtB,QAAM,QAAQ,MAAM,IAAI,CAAC,MAAM,UAAU;AACvC,UAAM,SAAS,QAAQ,QAAQ,MAAM,KAAK;AAE1C,WAAO;AAAA,MACL,KAAK,OAAO;AAAA,MACZ,MAAM;AAAA,MACN,OAAO,OAAO;AAAA,MACd,aAAa,OAAO;AAAA,MACpB,UAAU,OAAO;AAAA,MACjB,OAAO,OAAO;AAAA,MACd,YAAY,OAAO;AAAA,MACnB,YAAY,OAAO;AAAA,MACnB,UAAU,OAAO;AAAA,MACjB,UAAU,OAAO;AAAA,MACjB,YAAY;AAAA,QACV,WAAW,OAAO;AAAA,QAClB,QAAQ,OAAO;AAAA,QACf,SAAS,OAAO;AAAA,MAClB;AAAA,MACA,UAAU,OAAO;AAAA,IACnB;AAAA,EACF,CAAC;AAED,SAAO;AAAA,IACL,YAAY,QAAQ;AAAA,IACpB,OAAO,QAAQ;AAAA,IACf,aAAa,QAAQ;AAAA,IACrB,YAAY,QAAQ;AAAA,IACpB,aAAa,QAAQ;AAAA,IACrB,YAAY,QAAQ;AAAA,IACpB,gBAAgB,QAAQ,kBAAkB,MAAM,IAAI,CAAC,SAAS,KAAK,GAAG;AAAA,IACtE,cAAc,CAAC;AAAA,IACf,iBAAiB,CAAC;AAAA,IAClB,UAAU,QAAQ,YAAY,CAAC;AAAA,IAC/B;AAAA,EACF;AACF;;;AC5EA,SA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AyB,SAAS,kBAAkB,QAAQ,oBAAoB,QAAQ,SAAS;AACjG,UAAM,SAAS,sBAAsB,gBAAgB;AACrD,WAAO,aAAa,SAAS,IAAI,IAAI,QAAQ,MAAM,GAAG,GAAG;AAAA,EAC3D,SAAS,OAAO;AACd,YAAQ,MAAM,2BAA2B,QAAQ,SAAS,oBAAoB,KAAK;AACnF,WAAO,IAAI,aAAa,kCAAkC,EAAE,QAAQ,IAAI,CAAC;AAAA,EAC3E;AACF;;;AElHA,eAAsB,oCACpB,SACA,UAA6C,CAAC,GAC9C;AACA,SAAO,kCAAkC,SAAS;AAAA,IAChD,GAAG;AAAA,IACH,WAAW;AAAA,IACX,oBAAoB;AAAA,IACpB,kBAAkB,QAAQ,oBAAoB;AAAA,IAC9C,OAAO,QAAQ,SAAS;AAAA,EAC1B,CAAC;AACH;AAEO,SAAS,wCAAwC,UAA6C,CAAC,GAAG;AACvG,SAAO,eAAe,IAAI,SAAkB;AAC1C,WAAO,oCAAoC,SAAS,OAAO;AAAA,EAC7D;AACF;;;ACjBA,eAAsB,qCACpB,SACA,UAA8C,CAAC,GAC/C;AACA,SAAO,kCAAkC,SAAS;AAAA,IAChD,GAAG;AAAA,IACH,WAAW;AAAA,IACX,oBAAoB;AAAA,IACpB,kBAAkB,QAAQ,oBAAoB;AAAA,IAC9C,OAAO,QAAQ,SAAS;AAAA,EAC1B,CAAC;AACH;AAEO,SAAS,yCAAyC,UAA8C,CAAC,GAAG;AACzG,SAAO,eAAe,IAAI,SAAkB;AAC1C,WAAO,qCAAqC,SAAS,OAAO;AAAA,EAC9D;AACF;","names":["target"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/prisma/schema-template.ts","../src/core/env.ts","../src/cli/fs.ts","../src/cli/templates.ts"],"sourcesContent":["import type { PrismaSchemaFieldDefinition, PrismaSchemaModelDefinition } from '../types';\n\nexport const AUTH_PRISMA_SCHEMA_MODELS: PrismaSchemaModelDefinition[] = [\n {\n name: 'AuthUser',\n description: 'Shared authentication user record',\n fields: [\n { name: 'id', type: 'String', attributes: ['@id', '@default(cuid())'] },\n { name: 'email', type: 'String?', attributes: ['@unique'] },\n { name: 'name', type: 'String?' },\n { name: 'image', type: 'String?' },\n { name: 'isAdmin', type: 'Boolean', attributes: ['@default(false)'] },\n { name: 'role', type: 'String', attributes: ['@default(\"user\")'] },\n { name: 'tokenBalance', type: 'Int', attributes: ['@default(0)'] },\n { name: 'isVip', type: 'Boolean', attributes: ['@default(false)'] },\n { name: 'createdAt', type: 'DateTime', attributes: ['@default(now())'] },\n { name: 'updatedAt', type: 'DateTime', attributes: ['@updatedAt'] },\n ],\n blockAttributes: ['@@index([email])'],\n },\n {\n name: 'AuthMembership',\n description: 'Subscription membership snapshot',\n fields: [\n { name: 'id', type: 'String', attributes: ['@id', '@default(cuid())'] },\n { name: 'userId', type: 'String', attributes: ['@unique'] },\n { name: 'plan', type: 'String' },\n { name: 'status', type: 'String' },\n { name: 'startsAt', type: 'DateTime?' },\n { name: 'endsAt', type: 'DateTime?' },\n { name: 'createdAt', type: 'DateTime', attributes: ['@default(now())'] },\n { name: 'updatedAt', type: 'DateTime', attributes: ['@updatedAt'] },\n ],\n blockAttributes: ['@@index([userId])'],\n },\n {\n name: 'AuthOrder',\n description: 'Commerce order record',\n fields: [\n { name: 'id', type: 'String', attributes: ['@id', '@default(cuid())'] },\n { name: 'userId', type: 'String' },\n { name: 'kind', type: 'String' },\n { name: 'status', type: 'String' },\n { name: 'amount', type: 'Int' },\n { name: 'currency', type: 'String', attributes: ['@default(\"CNY\")'] },\n { name: 'payload', type: 'Json?' },\n { name: 'createdAt', type: 'DateTime', attributes: ['@default(now())'] },\n { name: 'updatedAt', type: 'DateTime', attributes: ['@updatedAt'] },\n ],\n blockAttributes: ['@@index([userId])'],\n },\n {\n name: 'AuthSubscription',\n description: 'Commerce subscription record',\n fields: [\n { name: 'id', type: 'String', attributes: ['@id', '@default(cuid())'] },\n { name: 'userId', type: 'String' },\n { name: 'productId', type: 'String' },\n { name: 'status', type: 'String' },\n { name: 'interval', type: 'String' },\n { name: 'startsAt', type: 'DateTime?' },\n { name: 'endsAt', type: 'DateTime?' },\n { name: 'createdAt', type: 'DateTime', attributes: ['@default(now())'] },\n { name: 'updatedAt', type: 'DateTime', attributes: ['@updatedAt'] },\n ],\n blockAttributes: ['@@index([userId])', '@@index([productId])'],\n },\n {\n name: 'AuthInvoice',\n description: 'Commerce invoice record',\n fields: [\n { name: 'id', type: 'String', attributes: ['@id', '@default(cuid())'] },\n { name: 'userId', type: 'String' },\n { name: 'orderId', type: 'String?' },\n { name: 'invoiceNo', type: 'String', attributes: ['@unique'] },\n { name: 'status', type: 'String' },\n { name: 'amount', type: 'Int' },\n { name: 'createdAt', type: 'DateTime', attributes: ['@default(now())'] },\n { name: 'updatedAt', type: 'DateTime', attributes: ['@updatedAt'] },\n ],\n blockAttributes: ['@@index([userId])', '@@index([orderId])'],\n },\n];\n\nfunction renderField(field: PrismaSchemaFieldDefinition): string {\n const attributes = field.attributes?.length ? ` ${field.attributes.join(' ')}` : '';\n return ` ${field.name} ${field.type}${attributes}`;\n}\n\nfunction renderModel(model: PrismaSchemaModelDefinition): string {\n const lines = [\n `/// ${model.description}`,\n `model ${model.name} {`,\n ...model.fields.map(renderField),\n ];\n\n if (model.blockAttributes?.length) {\n lines.push(...model.blockAttributes.map((attribute) => ` ${attribute}`));\n }\n\n lines.push('}');\n return lines.join('\\n');\n}\n\nexport function buildAuthPrismaSchemaTemplate(models: PrismaSchemaModelDefinition[] = AUTH_PRISMA_SCHEMA_MODELS): string {\n return [\n '// generated by @foldspace-fe/casdoor-next-auth-kit',\n '// merge these models into the host Prisma schema if you want a dedicated auth module',\n '',\n ...models.map(renderModel),\n ].join('\\n\\n');\n}\n","import type { ManagedEnvFile, ManagedEnvVariableDefinition } from '../types';\n\nexport const AUTH_KIT_ENV_FILES: ManagedEnvFile[] = ['.env', '.env.local', '.env.production', '.env.example'];\n\nexport const AUTH_KIT_ENV_VARIABLES: ManagedEnvVariableDefinition[] = [\n {\n key: 'APP_URL',\n description: '站点对外公开地址',\n example: 'https://your-domain.com',\n local: 'http://localhost:5177',\n production: 'https://your-domain.com',\n },\n {\n key: 'NEXTAUTH_URL',\n description: 'NextAuth 回调地址',\n example: 'http://localhost:5177',\n local: 'http://localhost:5177',\n production: 'https://your-domain.com',\n },\n {\n key: 'NEXTAUTH_SECRET',\n description: 'NextAuth JWT secret',\n example: 'replace-with-a-random-secret',\n local: 'replace-with-a-random-secret',\n production: 'replace-with-a-random-secret',\n },\n {\n key: 'GLOBAL_ADMIN_EMAILS',\n description: '全局管理员邮箱,逗号分隔',\n example: 'admin@example.com',\n local: 'admin@example.com',\n production: 'admin@example.com',\n },\n {\n key: 'AUTH_DEBUG',\n description: '是否开启认证调试日志',\n example: 'false',\n local: 'false',\n production: 'false',\n },\n {\n key: 'NEXT_PUBLIC_CASDOOR_SERVER_URL',\n description: 'Casdoor 服务地址',\n example: 'https://auth.example.com',\n local: 'https://auth.example.com',\n production: 'https://auth.example.com',\n },\n {\n key: 'NEXT_PUBLIC_CASDOOR_CLIENT_ID',\n description: 'Casdoor client id',\n example: 'your-casdoor-client-id',\n local: 'your-casdoor-client-id',\n production: 'your-casdoor-client-id',\n },\n {\n key: 'NEXT_PUBLIC_CASDOOR_APP_NAME',\n description: 'Casdoor app name',\n example: 'your-app-name',\n local: 'your-app-name',\n production: 'your-app-name',\n },\n {\n key: 'NEXT_PUBLIC_CASDOOR_ORGANIZATION_NAME',\n description: 'Casdoor organization name',\n example: 'your-org-name',\n local: 'your-org-name',\n production: 'your-org-name',\n },\n {\n key: 'NEXT_PUBLIC_CASDOOR_REDIRECT_PATH',\n description: 'Casdoor OAuth 回调路径',\n example: '/callback',\n local: '/callback',\n production: '/callback',\n },\n {\n key: 'NEXT_PUBLIC_CASDOOR_SIGNIN_PATH',\n description: 'Casdoor authorize 路径',\n example: '/login/oauth/authorize',\n local: '/login/oauth/authorize',\n production: '/login/oauth/authorize',\n },\n {\n key: 'NEXT_PUBLIC_AUTH_LOGOUT_REDIRECT_PATH',\n description: '注销后跳转路径,默认首页',\n example: '/',\n local: '/',\n production: '/',\n },\n {\n key: 'NEXT_PUBLIC_BILLING_PURCHASABLE_IDS',\n description: 'Billing 可购买项白名单,逗号分隔',\n example: 'membership-monthly,credits-50',\n local: 'membership-monthly,credits-50',\n production: 'membership-monthly,credits-50',\n },\n {\n key: 'NEXT_PUBLIC_CASDOOR_STATIC_ORIGIN',\n description: 'Casdoor 静态资源 origin',\n example: 'https://casdoor-static.foldspace.cn',\n local: 'https://casdoor-static.foldspace.cn',\n production: 'https://casdoor-static.foldspace.cn',\n },\n {\n key: 'CASDOOR_CLIENT_SECRET',\n description: 'Casdoor client secret',\n example: 'your-casdoor-client-secret',\n local: 'your-casdoor-client-secret',\n production: 'your-casdoor-client-secret',\n },\n {\n key: 'BILLING_PAYMENT_SUCCESS_DEBUG',\n description: '是否打印 payment-success 调试日志',\n example: 'false',\n local: 'false',\n production: 'false',\n },\n];\n\nfunction stringifyEnvValue(value: string): string {\n if (value === '') {\n return '\"\"';\n }\n\n if (/^[A-Za-z0-9_./:-]+$/.test(value)) {\n return value;\n }\n\n return JSON.stringify(value);\n}\n\nfunction stripQuotes(value: string): string {\n const trimmed = value.trim();\n if (\n (trimmed.startsWith('\"') && trimmed.endsWith('\"')) ||\n (trimmed.startsWith(\"'\") && trimmed.endsWith(\"'\"))\n ) {\n return trimmed.slice(1, -1);\n }\n\n return trimmed;\n}\n\nfunction parseEnvKeys(content: string): Set<string> {\n const keys = new Set<string>();\n for (const line of content.split(/\\r?\\n/)) {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith('#')) {\n continue;\n }\n\n const separatorIndex = trimmed.indexOf('=');\n if (separatorIndex === -1) {\n continue;\n }\n\n const key = trimmed.slice(0, separatorIndex).trim();\n if (key) {\n keys.add(key);\n }\n }\n return keys;\n}\n\nexport function readManagedEnvValue(content: string, key: string): string | null {\n for (const line of content.split(/\\r?\\n/)) {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith('#')) {\n continue;\n }\n\n const separatorIndex = trimmed.indexOf('=');\n if (separatorIndex === -1) {\n continue;\n }\n\n const currentKey = trimmed.slice(0, separatorIndex).trim();\n if (currentKey !== key) {\n continue;\n }\n\n const rawValue = trimmed.slice(separatorIndex + 1).trim();\n return stripQuotes(rawValue);\n }\n\n return null;\n}\n\nexport function getManagedEnvValue(definition: ManagedEnvVariableDefinition, file: ManagedEnvFile): string {\n if (file === '.env.example') {\n return definition.example;\n }\n if (file === '.env.production') {\n return definition.production ?? definition.example;\n }\n if (file === '.env.local') {\n return definition.local ?? definition.example;\n }\n return definition.base ?? definition.local ?? definition.production ?? definition.example;\n}\n\nexport function buildManagedEnvTemplate(file: ManagedEnvFile, existingContent = ''): string {\n const existingKeys = parseEnvKeys(existingContent);\n const lines: string[] = existingContent.trimEnd() ? existingContent.trimEnd().split(/\\r?\\n/) : [];\n const missing = AUTH_KIT_ENV_VARIABLES.filter((definition) => !existingKeys.has(definition.key));\n\n if (missing.length === 0 && existingContent) {\n return existingContent;\n }\n\n if (lines.length > 0) {\n lines.push('');\n }\n\n lines.push(`# Casdoor Next Auth Kit managed values for ${file}`);\n for (const definition of missing) {\n const value = getManagedEnvValue(definition, file);\n lines.push(`# ${definition.description}`);\n lines.push(`${definition.key}=${stringifyEnvValue(value)}`);\n lines.push('');\n }\n\n while (lines.length > 0 && lines[lines.length - 1] === '') {\n lines.pop();\n }\n\n return `${lines.join('\\n')}\\n`;\n}\n\nexport function getMissingManagedEnvKeys(content: string): string[] {\n const existingKeys = parseEnvKeys(content);\n return AUTH_KIT_ENV_VARIABLES.filter((definition) => !existingKeys.has(definition.key)).map(\n (definition) => definition.key,\n );\n}\n\nexport function sanitizeExistingEnvContent(content: string): string {\n return stripQuotes(content);\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';\nimport { buildAuthPrismaSchemaTemplate } from '../prisma/schema-template';\nimport { 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 callbackErrorPageTemplate() {\n return `import { ClearDomainCookiesButton } from './clear-domain-cookies-button';\n\nexport const dynamic = 'force-dynamic';\n\nexport default async function CallbackErrorPage({\n searchParams,\n}: {\n searchParams: Promise<{ title?: string; message?: string; details?: string }>;\n}) {\n const params = await searchParams;\n\n return (\n <main\n style={{\n minHeight: '100dvh',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n padding: '20px 16px',\n background:\n 'radial-gradient(circle at top, rgba(99, 102, 241, 0.12) 0, rgba(99, 102, 241, 0) 38%), linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%)',\n }}\n >\n <section\n style={{\n width: 'min(100%, 400px)',\n borderRadius: 28,\n padding: '24px 20px',\n boxSizing: 'border-box',\n background: 'rgba(255, 255, 255, 0.96)',\n border: '1px solid rgba(148, 163, 184, 0.2)',\n boxShadow: '0 22px 52px rgba(15, 23, 42, 0.12)',\n textAlign: 'center',\n backdropFilter: 'blur(10px)',\n }}\n >\n <div\n style={{\n width: 52,\n height: 52,\n margin: '0 auto 14px',\n display: 'grid',\n placeItems: 'center',\n borderRadius: 18,\n background: 'linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(249, 115, 22, 0.1))',\n color: '#b91c1c',\n fontSize: 28,\n lineHeight: 1,\n }}\n aria-hidden=\"true\"\n >\n !\n </div>\n <div\n style={{\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n marginBottom: 12,\n padding: '6px 12px',\n borderRadius: 9999,\n background: 'rgba(254, 226, 226, 0.9)',\n color: '#b91c1c',\n fontSize: 13,\n fontWeight: 600,\n letterSpacing: '0.04em',\n }}\n >\n 认证失败\n </div>\n <h2 style={{ margin: 0, fontSize: 24, lineHeight: 1.2, color: '#0f172a' }}>{params.title ?? 'Callback Error'}</h2>\n <p style={{ margin: '12px 0 0', color: '#334155', lineHeight: 1.6 }}>{params.message ?? 'Unknown callback failure.'}</p>\n {params.details ? (\n <pre\n style={{\n margin: '14px 0 0',\n maxHeight: 140,\n overflow: 'auto',\n padding: 14,\n borderRadius: 18,\n textAlign: 'left',\n whiteSpace: 'pre-wrap',\n wordBreak: 'break-word',\n background: '#f8fafc',\n color: '#0f172a',\n border: '1px solid rgba(148, 163, 184, 0.18)',\n fontSize: 13,\n lineHeight: 1.6,\n }}\n >\n {params.details}\n </pre>\n ) : null}\n${customBegin}\n <div style={{ display: 'flex', flexDirection: 'column', gap: 10, marginTop: 20 }}>\n <ClearDomainCookiesButton />\n <a href=\"/\" style={{ display: 'inline-flex', width: '100%', alignItems: 'center', justifyContent: 'center', minHeight: 44, padding: '0 16px', boxSizing: 'border-box', borderRadius: 9999, border: '1px solid rgba(148, 163, 184, 0.35)', color: '#0f172a', textDecoration: 'none', background: 'rgba(248, 250, 252, 0.9)' }}>返回首页</a>\n <a href=\"/auth/login\" style={{ display: 'inline-flex', width: '100%', alignItems: 'center', justifyContent: 'center', minHeight: 44, padding: '0 16px', boxSizing: 'border-box', borderRadius: 9999, border: '1px solid rgba(148, 163, 184, 0.35)', color: '#0f172a', textDecoration: 'none', background: 'rgba(248, 250, 252, 0.9)' }}>重新登录</a>\n <a href=\"/auth/signup\" style={{ display: 'inline-flex', width: '100%', alignItems: 'center', justifyContent: 'center', minHeight: 44, padding: '0 16px', boxSizing: 'border-box', borderRadius: 9999, border: '1px solid rgba(148, 163, 184, 0.35)', color: '#0f172a', textDecoration: 'none', background: 'rgba(248, 250, 252, 0.9)' }}>去注册</a>\n </div>\n${customEnd}\n </section>\n </main>\n );\n}\n`;\n}\n\nexport function callbackErrorClearCookiesButtonTemplate() {\n return `'use client';\n\nimport { useState } from 'react';\n\nconst AUTH_COOKIE_NAMES = [\n 'auth_origin',\n 'auth_redirect',\n 'oauth_state',\n 'pkce_code_verifier',\n 'next-auth.session-token',\n '__Secure-next-auth.session-token',\n 'next-auth.csrf-token',\n '__Secure-next-auth.csrf-token',\n '__Host-next-auth.csrf-token',\n];\n\nfunction getPathCandidates(pathname: string): string[] {\n const normalized = pathname.startsWith('/') ? pathname : '/' + pathname;\n const segments = normalized.split('/').filter(Boolean);\n const paths = new Set<string>(['/']);\n\n let current = '';\n for (const segment of segments) {\n current += '/' + segment;\n paths.add(current);\n }\n\n return [...paths];\n}\n\nfunction getDomainCandidates(hostname: string): string[] {\n const normalized = hostname.toLowerCase();\n if (\n normalized === 'localhost' ||\n normalized.endsWith('.localhost') ||\n /^\\\\d+\\\\.\\\\d+\\\\.\\\\d+\\\\.\\\\d+$/.test(normalized) ||\n /^\\\\[[^\\\\]]+\\\\]$/.test(normalized)\n ) {\n return [];\n }\n\n const parts = normalized.split('.');\n if (parts.length < 2) {\n return [];\n }\n\n const domains = new Set<string>();\n for (let index = 0; index < parts.length - 1; index++) {\n const suffix = parts.slice(index).join('.');\n domains.add(suffix);\n domains.add('.' + suffix);\n }\n\n return [...domains];\n}\n\nfunction expireCookie(name: string, path: string, domain?: string) {\n const pieces = [\n name + '=',\n 'Max-Age=0',\n 'Expires=Thu, 01 Jan 1970 00:00:00 GMT',\n 'Path=' + path,\n 'SameSite=Lax',\n ];\n\n if (domain) {\n pieces.push('Domain=' + domain);\n }\n\n if (window.location.protocol === 'https:') {\n pieces.push('Secure');\n }\n\n document.cookie = pieces.join('; ');\n}\n\n${customBegin}\nexport function ClearDomainCookiesButton() {\n const [cleared, setCleared] = useState(false);\n\n const handleClick = () => {\n if (typeof document === 'undefined' || typeof window === 'undefined') {\n return;\n }\n\n const names = new Set<string>(AUTH_COOKIE_NAMES);\n for (const entry of document.cookie.split(';')) {\n const [rawName] = entry.trim().split('=');\n if (rawName) {\n names.add(rawName);\n }\n }\n\n const pathCandidates = getPathCandidates(window.location.pathname);\n const domainCandidates = getDomainCandidates(window.location.hostname);\n\n for (const name of names) {\n for (const path of pathCandidates) {\n expireCookie(name, path);\n for (const domain of domainCandidates) {\n expireCookie(name, path, domain);\n }\n }\n }\n\n setCleared(true);\n };\n\n return (\n <button\n type=\"button\"\n onClick={handleClick}\n disabled={cleared}\n style={{\n display: 'inline-flex',\n width: '100%',\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: 44,\n padding: '0 16px',\n boxSizing: 'border-box',\n borderRadius: 9999,\n border: '1px solid rgba(148, 163, 184, 0.35)',\n color: '#0f172a',\n background: cleared ? 'rgba(220, 252, 231, 0.92)' : 'rgba(248, 250, 252, 0.9)',\n cursor: cleared ? 'default' : 'pointer',\n }}\n >\n {cleared ? '已清空' : '清空当前域 Cookie'}\n </button>\n );\n}\n${customEnd}\n`;\n}\n\nexport function authConfigTemplate() {\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} from '@foldspace-fe/casdoor-next-auth-kit';\nimport { isGlobalAdminEmail } from '@foldspace-fe/casdoor-next-auth-kit';\nimport { paymentSuccessHandler as billingPaymentSuccessHandler } from '@/lib/billing/payment-success';\nimport { paymentFinishedHandler as billingPaymentFinishedHandler } from '@/lib/billing/payment-finished';\n\nexport function createAuthKitConfig(): AuthKitConfig {\n return {\n appUrl: process.env.APP_URL || '',\n nextauthSecret: process.env.NEXTAUTH_SECRET || 'dev-nextauth-secret',\n logoutRedirectPath: process.env.NEXT_PUBLIC_AUTH_LOGOUT_REDIRECT_PATH || '/',\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\nexport const authKitConfig = createAuthKitConfig();\n\nexport const adapter: AuthBusinessAdapter = {\n onUserSync: async (profile) => {\n const email = profile.email ?? null;\n const isAdmin = Boolean(profile.isAdmin) || isGlobalAdminEmail(email);\n\n return {\n id: String(profile.id ?? profile.sub ?? email ?? 'casdoor-user'),\n name: profile.name ?? profile.displayName ?? null,\n email,\n image: profile.picture ?? profile.avatarUrl ?? null,\n isAdmin,\n role: isAdmin ? 'admin' : 'user',\n tokenBalance: 2580,\n isVip: true,\n };\n },\n isAdminEmail: isGlobalAdminEmail,\n};\n\nexport const persistence: AuthPersistenceAdapter = {\n async syncAuthUser(user) {\n console.info('[casdoor-next-auth-kit] syncAuthUser received user', {\n id: user.id,\n email: user.email,\n isAdmin: user.isAdmin,\n role: user.role,\n });\n },\n async findAuthUser() {\n return null;\n },\n};\n\nexport const paymentSuccessHandler = billingPaymentSuccessHandler;\nexport const paymentFinishedHandler = billingPaymentFinishedHandler;\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 phase: 'success',\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 phase: 'finished',\n});\n`;\n}\n\nexport function billingPaymentSuccessHandlerTemplate() {\n return `import type { BillingPaymentSuccessHandler } from '@foldspace-fe/casdoor-next-auth-kit/billing';\n\n${customBegin}\nconst paymentSuccessHandlerImpl: BillingPaymentSuccessHandler = async (context) => {\n console.info('[casdoor-next-auth-kit] payment success callback received', {\n paymentId: context.paymentId,\n orderId: context.orderId,\n status: context.status,\n redirectTo: context.redirectTo,\n });\n return;\n};\n${customEnd}\n\nexport const paymentSuccessHandler: BillingPaymentSuccessHandler = paymentSuccessHandlerImpl;\n`;\n}\n\nexport function billingPaymentFinishedHandlerTemplate() {\n return `import type { BillingPaymentFinishedHandler } from '@foldspace-fe/casdoor-next-auth-kit/billing';\n\n${customBegin}\nconst paymentFinishedHandlerImpl: BillingPaymentFinishedHandler = async (context) => {\n console.info('[casdoor-next-auth-kit] payment finished callback received', {\n paymentId: context.paymentId,\n orderId: context.orderId,\n status: context.status,\n redirectTo: context.redirectTo,\n });\n return;\n};\n${customEnd}\n\nexport const paymentFinishedHandler: BillingPaymentFinishedHandler = paymentFinishedHandlerImpl;\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"],"mappings":";AAEO,IAAM,4BAA2D;AAAA,EACtE;AAAA,IACE,MAAM;AAAA,IACN,aAAa;AAAA,IACb,QAAQ;AAAA,MACN,EAAE,MAAM,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