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

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.
@@ -659,13 +659,15 @@ function authConfigTemplate() {
659
659
  createLogoutHandler,
660
660
  createNextAuthOptions,
661
661
  createSignupRouteHandler,
662
+ decodeCasdoorAccessToken,
663
+ isGlobalAdminEmail,
662
664
  type AuthBusinessAdapter,
663
665
  type AuthKitConfig,
664
666
  type AuthPersistenceAdapter,
665
667
  } from '@foldspace-fe/casdoor-next-auth-kit';
666
- import { isGlobalAdminEmail } from '@foldspace-fe/casdoor-next-auth-kit';
667
668
  import { paymentSuccessHandler as billingPaymentSuccessHandler } from '@/lib/billing/payment-success';
668
669
  import { paymentFinishedHandler as billingPaymentFinishedHandler } from '@/lib/billing/payment-finished';
670
+ import { syncUserRecord } from '@/lib/user/record';
669
671
 
670
672
  export function createAuthKitConfig(): AuthKitConfig {
671
673
  return {
@@ -687,12 +689,26 @@ export function createAuthKitConfig(): AuthKitConfig {
687
689
  export const authKitConfig = createAuthKitConfig();
688
690
 
689
691
  export const adapter: AuthBusinessAdapter = {
690
- onUserSync: async (profile) => {
691
- const email = profile.email ?? null;
692
- const isAdmin = Boolean(profile.isAdmin) || isGlobalAdminEmail(email);
692
+ onUserSync: async (profile, tokens) => {
693
+ const accessToken = tokens.accessToken ?? tokens.access_token ?? '';
694
+ const decodedAccessToken = accessToken ? decodeCasdoorAccessToken(accessToken) : null;
695
+ const email =
696
+ profile.email ??
697
+ (typeof decodedAccessToken?.email === 'string' ? decodedAccessToken.email : null);
698
+ const isAdmin =
699
+ Boolean(profile.isAdmin) ||
700
+ Boolean(decodedAccessToken?.isAdmin) ||
701
+ isGlobalAdminEmail(email);
693
702
 
694
703
  return {
695
- id: String(profile.id ?? profile.sub ?? email ?? 'casdoor-user'),
704
+ id: String(
705
+ profile.id ??
706
+ profile.sub ??
707
+ (typeof decodedAccessToken?.sub === 'string' ? decodedAccessToken.sub : null) ??
708
+ (typeof decodedAccessToken?.id === 'string' ? decodedAccessToken.id : null) ??
709
+ email ??
710
+ 'casdoor-user',
711
+ ),
696
712
  name: profile.name ?? profile.displayName ?? null,
697
713
  email,
698
714
  image: profile.picture ?? profile.avatarUrl ?? null,
@@ -707,12 +723,7 @@ export const adapter: AuthBusinessAdapter = {
707
723
 
708
724
  export const persistence: AuthPersistenceAdapter = {
709
725
  async syncAuthUser(user) {
710
- console.info('[casdoor-next-auth-kit] syncAuthUser received user', {
711
- id: user.id,
712
- email: user.email,
713
- isAdmin: user.isAdmin,
714
- role: user.role,
715
- });
726
+ await syncUserRecord(user);
716
727
  },
717
728
  async findAuthUser() {
718
729
  return null;
@@ -918,4 +929,4 @@ export {
918
929
  commerceProxyRouteTemplate,
919
930
  envTemplate
920
931
  };
921
- //# sourceMappingURL=chunk-WNDID6YX.js.map
932
+ //# sourceMappingURL=chunk-WPOURR7G.js.map
@@ -1 +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,YA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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":[]}
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 decodeCasdoorAccessToken,\n isGlobalAdminEmail,\n type AuthBusinessAdapter,\n type AuthKitConfig,\n type AuthPersistenceAdapter,\n} 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';\nimport { syncUserRecord } from '@/lib/user/record';\n\nexport function createAuthKitConfig(): AuthKitConfig {\n return {\n appUrl: process.env.APP_URL || '',\n nextauthSecret: process.env.NEXTAUTH_SECRET || 'dev-nextauth-secret',\n 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, tokens) => {\n const accessToken = tokens.accessToken ?? tokens.access_token ?? '';\n const decodedAccessToken = accessToken ? decodeCasdoorAccessToken(accessToken) : null;\n const email =\n profile.email ??\n (typeof decodedAccessToken?.email === 'string' ? decodedAccessToken.email : null);\n const isAdmin =\n Boolean(profile.isAdmin) ||\n Boolean(decodedAccessToken?.isAdmin) ||\n isGlobalAdminEmail(email);\n\n return {\n id: String(\n profile.id ??\n profile.sub ??\n (typeof decodedAccessToken?.sub === 'string' ? decodedAccessToken.sub : null) ??\n (typeof decodedAccessToken?.id === 'string' ? decodedAccessToken.id : null) ??\n email ??\n 'casdoor-user',\n ),\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 await syncUserRecord(user);\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,OA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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":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  authConfigTemplate
3
- } from "./chunk-WNDID6YX.js";
3
+ } from "./chunk-WPOURR7G.js";
4
4
  export {
5
5
  authConfigTemplate
6
6
  };
package/dist/cli.js CHANGED
@@ -28,7 +28,7 @@ import {
28
28
  signupAuthorizeRouteTemplate,
29
29
  writeGeneratedFile,
30
30
  writeTextFile
31
- } from "./chunk-WNDID6YX.js";
31
+ } from "./chunk-WPOURR7G.js";
32
32
 
33
33
  // package.json
34
34
  var package_default = {
package/dist/index.js CHANGED
@@ -28,7 +28,7 @@ import {
28
28
  readManagedEnvValue,
29
29
  sanitizeExistingEnvContent,
30
30
  signupAuthorizeRouteTemplate
31
- } from "./chunk-WNDID6YX.js";
31
+ } from "./chunk-WPOURR7G.js";
32
32
  import {
33
33
  buildBillingSubscriptionCatalog,
34
34
  createBillingPaymentFinishedResponse,
@@ -75,6 +75,7 @@ npx @foldspace-fe/casdoor-next-auth-kit@latest check
75
75
  - `useAuthUser` — 获取当前登录用户信息(含 Casdoor 用户字段)
76
76
  - `useAuthRole` — 获取当前用户的角色信息,用于权限判断
77
77
  - `role` 是一等认证字段,Casdoor profile、callback、JWT/session、`useAuthUser`、`useAuthRole` 和生成的 `auth-config.ts` 会一起维护它;`isAdmin` 仍然保留兼容推导,但不要只依赖它
78
+ - 生成的 `auth-config.ts` 需要在 `onUserSync` 里同时看 Casdoor profile 和 access token,优先用 `decodeCasdoorAccessToken(accessToken)` 兜底补齐 `email`、`sub` 和 `isAdmin`,再把最终用户对象交给 `syncUserRecord(user)` 落库
78
79
  - `useAuthActions` — 提供登录、注册、注销等认证操作方法
79
80
  - Casdoor 登录 / 注册入口处理器 — 处理用户进入认证流程的初始交互
80
81
  - callback / logout / nextauth 路由处理器 — 处理 OAuth 回调、注销和 NextAuth 路由请求
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foldspace-fe/casdoor-next-auth-kit",
3
- "version": "0.1.26",
3
+ "version": "0.1.27",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "repository": {