@spfn/auth 0.2.0-beta.32 → 0.2.0-beta.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{authenticate-Brx2N-Ip.d.ts → authenticate-CGslXjZb.d.ts} +1 -1
- package/dist/config.d.ts +40 -0
- package/dist/config.js +16 -0
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/server.d.ts +51 -51
- package/dist/server.js +32 -13
- package/dist/server.js.map +1 -1
- package/package.json +1 -1
|
@@ -542,7 +542,7 @@ declare const mainAuthRouter: _spfn_core_route.Router<{
|
|
|
542
542
|
id: number;
|
|
543
543
|
name: string;
|
|
544
544
|
displayName: string;
|
|
545
|
-
category: "
|
|
545
|
+
category: "custom" | "user" | "auth" | "rbac" | "system" | undefined;
|
|
546
546
|
}[];
|
|
547
547
|
userId: number;
|
|
548
548
|
email: string | null;
|
package/dist/config.d.ts
CHANGED
|
@@ -155,6 +155,26 @@ declare const authEnvSchema: {
|
|
|
155
155
|
} & {
|
|
156
156
|
key: "SPFN_AUTH_RESERVED_USERNAMES";
|
|
157
157
|
};
|
|
158
|
+
SPFN_AUTH_USERNAME_MIN_LENGTH: {
|
|
159
|
+
description: string;
|
|
160
|
+
default: number;
|
|
161
|
+
required: boolean;
|
|
162
|
+
examples: number[];
|
|
163
|
+
type: "number";
|
|
164
|
+
validator: (value: string) => number;
|
|
165
|
+
} & {
|
|
166
|
+
key: "SPFN_AUTH_USERNAME_MIN_LENGTH";
|
|
167
|
+
};
|
|
168
|
+
SPFN_AUTH_USERNAME_MAX_LENGTH: {
|
|
169
|
+
description: string;
|
|
170
|
+
default: number;
|
|
171
|
+
required: boolean;
|
|
172
|
+
examples: number[];
|
|
173
|
+
type: "number";
|
|
174
|
+
validator: (value: string) => number;
|
|
175
|
+
} & {
|
|
176
|
+
key: "SPFN_AUTH_USERNAME_MAX_LENGTH";
|
|
177
|
+
};
|
|
158
178
|
SPFN_API_URL: {
|
|
159
179
|
description: string;
|
|
160
180
|
default: string;
|
|
@@ -381,6 +401,26 @@ declare const env: _spfn_core_env.InferEnvType<{
|
|
|
381
401
|
} & {
|
|
382
402
|
key: "SPFN_AUTH_RESERVED_USERNAMES";
|
|
383
403
|
};
|
|
404
|
+
SPFN_AUTH_USERNAME_MIN_LENGTH: {
|
|
405
|
+
description: string;
|
|
406
|
+
default: number;
|
|
407
|
+
required: boolean;
|
|
408
|
+
examples: number[];
|
|
409
|
+
type: "number";
|
|
410
|
+
validator: (value: string) => number;
|
|
411
|
+
} & {
|
|
412
|
+
key: "SPFN_AUTH_USERNAME_MIN_LENGTH";
|
|
413
|
+
};
|
|
414
|
+
SPFN_AUTH_USERNAME_MAX_LENGTH: {
|
|
415
|
+
description: string;
|
|
416
|
+
default: number;
|
|
417
|
+
required: boolean;
|
|
418
|
+
examples: number[];
|
|
419
|
+
type: "number";
|
|
420
|
+
validator: (value: string) => number;
|
|
421
|
+
} & {
|
|
422
|
+
key: "SPFN_AUTH_USERNAME_MAX_LENGTH";
|
|
423
|
+
};
|
|
384
424
|
SPFN_API_URL: {
|
|
385
425
|
description: string;
|
|
386
426
|
default: string;
|
package/dist/config.js
CHANGED
|
@@ -165,6 +165,22 @@ var authEnvSchema = defineEnvSchema({
|
|
|
165
165
|
]
|
|
166
166
|
})
|
|
167
167
|
},
|
|
168
|
+
SPFN_AUTH_USERNAME_MIN_LENGTH: {
|
|
169
|
+
...envNumber({
|
|
170
|
+
description: "Minimum username length",
|
|
171
|
+
default: 3,
|
|
172
|
+
required: false,
|
|
173
|
+
examples: [2, 3, 4]
|
|
174
|
+
})
|
|
175
|
+
},
|
|
176
|
+
SPFN_AUTH_USERNAME_MAX_LENGTH: {
|
|
177
|
+
...envNumber({
|
|
178
|
+
description: "Maximum username length",
|
|
179
|
+
default: 30,
|
|
180
|
+
required: false,
|
|
181
|
+
examples: [20, 30, 50]
|
|
182
|
+
})
|
|
183
|
+
},
|
|
168
184
|
// ============================================================================
|
|
169
185
|
// API Configuration
|
|
170
186
|
// ============================================================================
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/config/index.ts","../src/config/schema.ts"],"sourcesContent":["/**\n * Core Package Configuration\n *\n * @example\n * ```typescript\n * import { registry } from '@spfn/core/config';\n *\n * const env = registry.validate();\n * console.log(env.DB_POOL_MAX);\n * ```\n *\n * @module config\n */\n\nimport { createEnvRegistry } from '@spfn/core/env';\nimport { authEnvSchema } from './schema';\n\nexport { authEnvSchema as envSchema } from './schema';\n\n/**\n * Environment registry\n */\nconst registry = createEnvRegistry(authEnvSchema);\nexport const env = registry.validate();","/**\n * Auth Environment Variable Schema\n *\n * Centralized schema definition for all environment variables used in @spfn/auth.\n * This provides type safety, validation, and documentation for Auth configuration.\n *\n * @module config/schema\n */\n\nimport {\n defineEnvSchema,\n envString,\n envNumber,\n createSecureSecretParser,\n createPasswordParser,\n} from '@spfn/core/env';\n\n/**\n * Auth environment variable schema\n *\n * Defines all Auth environment variables with:\n * - Type information\n * - Default values\n * - Validation rules\n * - Documentation\n *\n * @example\n * ```typescript\n * import { authEnvSchema } from '@spfn/auth/config';\n *\n * // Access schema information\n * console.log(authEnvSchema.SPFN_AUTH_SESSION_SECRET.description);\n * console.log(authEnvSchema.SPFN_AUTH_JWT_EXPIRES_IN.default);\n * ```\n */\nexport const authEnvSchema = defineEnvSchema({\n // ============================================================================\n // Session Configuration\n // ============================================================================\n SPFN_AUTH_SESSION_SECRET: {\n ...envString({\n description: 'Session encryption secret (minimum 32 characters for AES-256)',\n required: true,\n fallbackKeys: ['SESSION_SECRET'],\n validator: createSecureSecretParser({\n minLength: 32,\n minUniqueChars: 16,\n minEntropy: 3.5,\n }),\n sensitive: true,\n nextjs: true, // Required for Next.js RSC session validation\n examples: [\n 'my-super-secret-session-key-at-least-32-chars-long',\n 'use-a-cryptographically-secure-random-string-here',\n ],\n }),\n },\n\n SPFN_AUTH_SESSION_TTL: {\n ...envString({\n description: 'Session TTL (time to live) - supports duration strings like \\'7d\\', \\'12h\\', \\'45m\\'',\n default: '7d',\n required: false,\n nextjs: true, // May be needed for session validation in Next.js RSC\n examples: ['7d', '30d', '12h', '45m', '3600'],\n }),\n },\n\n // ============================================================================\n // JWT Configuration\n // ============================================================================\n SPFN_AUTH_JWT_SECRET: {\n ...envString({\n description: 'JWT signing secret for server-signed tokens (legacy mode)',\n default: 'dev-secret-key-change-in-production',\n required: false,\n examples: [\n 'your-jwt-secret-key-here',\n 'use-different-from-session-secret',\n ],\n }),\n },\n\n SPFN_AUTH_JWT_EXPIRES_IN: {\n ...envString({\n description: 'JWT token expiration time (e.g., \\'7d\\', \\'24h\\', \\'1h\\')',\n default: '7d',\n required: false,\n examples: ['7d', '24h', '1h', '30m'],\n }),\n },\n\n // ============================================================================\n // Security Configuration\n // ============================================================================\n SPFN_AUTH_BCRYPT_SALT_ROUNDS: {\n ...envNumber({\n description: 'Bcrypt salt rounds (cost factor, higher = more secure but slower)',\n default: 10,\n required: false,\n examples: [10, 12, 14],\n }),\n key: 'SPFN_AUTH_BCRYPT_SALT_ROUNDS',\n },\n\n SPFN_AUTH_VERIFICATION_TOKEN_SECRET: {\n ...envString({\n description: 'Verification token secret for email verification, password reset, etc.',\n required: true,\n examples: [\n 'your-verification-token-secret',\n 'can-be-different-from-jwt-secret',\n ],\n }),\n },\n\n // ============================================================================\n // Admin Account Configuration\n // ============================================================================\n SPFN_AUTH_ADMIN_ACCOUNTS: {\n ...envString({\n description: 'JSON array of admin accounts (recommended for multiple admins)',\n required: false,\n examples: [\n '[{\"email\":\"admin@example.com\",\"password\":\"secure-pass\",\"role\":\"admin\"}]',\n '[{\"email\":\"super@example.com\",\"password\":\"pass1\",\"role\":\"superadmin\"},{\"email\":\"admin@example.com\",\"password\":\"pass2\",\"role\":\"admin\"}]',\n ],\n }),\n },\n\n SPFN_AUTH_ADMIN_EMAILS: {\n ...envString({\n description: 'Comma-separated list of admin emails (legacy CSV format)',\n required: false,\n examples: [\n 'admin@example.com,user@example.com',\n 'super@example.com,admin@example.com,user@example.com',\n ],\n }),\n },\n\n SPFN_AUTH_ADMIN_PASSWORDS: {\n ...envString({\n description: 'Comma-separated list of admin passwords (legacy CSV format)',\n required: false,\n examples: [\n 'admin-pass,user-pass',\n 'super-pass,admin-pass,user-pass',\n ],\n }),\n },\n\n SPFN_AUTH_ADMIN_ROLES: {\n ...envString({\n description: 'Comma-separated list of admin roles (legacy CSV format)',\n required: false,\n examples: [\n 'admin,user',\n 'superadmin,admin,user',\n ],\n }),\n },\n\n SPFN_AUTH_ADMIN_EMAIL: {\n ...envString({\n description: 'Single admin email (simplest format)',\n required: false,\n examples: ['admin@example.com'],\n }),\n },\n\n SPFN_AUTH_ADMIN_PASSWORD: {\n ...envString({\n description: 'Single admin password (simplest format)',\n required: false,\n validator: createPasswordParser({\n minLength: 8,\n requireUppercase: true,\n requireLowercase: true,\n requireNumber: true,\n requireSpecial: true,\n }),\n sensitive: true,\n examples: ['SecureAdmin123!'],\n }),\n },\n\n // ============================================================================\n // Username Configuration\n // ============================================================================\n SPFN_AUTH_RESERVED_USERNAMES: {\n ...envString({\n description: 'Comma-separated list of reserved usernames that cannot be registered',\n required: false,\n default: 'admin,root,system,support,help,moderator,superadmin',\n examples: [\n 'admin,root,system,support,help',\n 'admin,root,system,support,help,moderator,superadmin,operator',\n ],\n }),\n },\n\n // ============================================================================\n // API Configuration\n // ============================================================================\n SPFN_API_URL: {\n ...envString({\n description: 'Internal API URL for server-to-server communication',\n default: 'http://localhost:8790',\n required: false,\n examples: [\n 'https://api.example.com',\n 'http://localhost:8790',\n ],\n }),\n },\n\n NEXT_PUBLIC_SPFN_API_URL: {\n ...envString({\n description: 'Public-facing API URL used for browser-facing redirects (e.g. OAuth callback). Falls back to SPFN_API_URL if not set.',\n required: false,\n examples: [\n 'https://api.example.com',\n 'http://localhost:8790',\n ],\n }),\n },\n\n SPFN_APP_URL: {\n ...envString({\n description: 'Next.js application URL (internal). Used for server-to-server communication.',\n default: 'http://localhost:3000',\n required: false,\n examples: [\n 'https://app.example.com',\n 'http://localhost:3000',\n ],\n }),\n },\n\n NEXT_PUBLIC_SPFN_APP_URL: {\n ...envString({\n description: 'Public-facing Next.js app URL for browser redirects (e.g. OAuth redirect). Falls back to SPFN_APP_URL if not set.',\n required: false,\n examples: [\n 'https://app.example.com',\n 'http://localhost:3000',\n ],\n }),\n },\n\n // ============================================================================\n // OAuth Configuration - Google\n // ============================================================================\n SPFN_AUTH_GOOGLE_CLIENT_ID: {\n ...envString({\n description: 'Google OAuth 2.0 Client ID. When set, Google OAuth routes are automatically enabled.',\n required: false,\n examples: ['123456789-abc123.apps.googleusercontent.com'],\n }),\n },\n\n SPFN_AUTH_GOOGLE_CLIENT_SECRET: {\n ...envString({\n description: 'Google OAuth 2.0 Client Secret',\n required: false,\n sensitive: true,\n examples: ['GOCSPX-abcdefghijklmnop'],\n }),\n },\n\n SPFN_AUTH_GOOGLE_SCOPES: {\n ...envString({\n description: 'Comma-separated Google OAuth scopes. Defaults to \"email,profile\" if not set.',\n required: false,\n examples: [\n 'email,profile',\n 'email,profile,https://www.googleapis.com/auth/gmail.readonly',\n 'email,profile,https://www.googleapis.com/auth/calendar.readonly',\n ],\n }),\n },\n\n SPFN_AUTH_GOOGLE_REDIRECT_URI: {\n ...envString({\n description: 'Google OAuth callback URL. Defaults to {NEXT_PUBLIC_SPFN_API_URL || SPFN_API_URL}/_auth/oauth/google/callback',\n required: false,\n examples: [\n 'https://api.example.com/_auth/oauth/google/callback',\n 'http://localhost:8790/_auth/oauth/google/callback',\n ],\n }),\n },\n\n SPFN_AUTH_OAUTH_SUCCESS_URL: {\n ...envString({\n description: 'OAuth callback page URL. This page should use OAuthCallback component to finalize session.',\n required: false,\n default: '/auth/callback',\n examples: [\n '/auth/callback',\n 'https://app.example.com/auth/callback',\n ],\n }),\n },\n\n SPFN_AUTH_OAUTH_ERROR_URL: {\n ...envString({\n description: 'URL to redirect after OAuth error. Use {error} placeholder for error message.',\n required: false,\n default: 'http://localhost:3000/auth/error?error={error}',\n examples: [\n 'https://app.example.com/auth/error?error={error}',\n 'http://localhost:3000/auth/error?error={error}',\n ],\n }),\n },\n});"],"mappings":";AAcA,SAAS,yBAAyB;;;ACLlC;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAoBA,IAAM,gBAAgB,gBAAgB;AAAA;AAAA;AAAA;AAAA,EAIzC,0BAA0B;AAAA,IACtB,GAAG,UAAU;AAAA,MACT,aAAa;AAAA,MACb,UAAU;AAAA,MACV,cAAc,CAAC,gBAAgB;AAAA,MAC/B,WAAW,yBAAyB;AAAA,QAChC,WAAW;AAAA,QACX,gBAAgB;AAAA,QAChB,YAAY;AAAA,MAChB,CAAC;AAAA,MACD,WAAW;AAAA,MACX,QAAQ;AAAA;AAAA,MACR,UAAU;AAAA,QACN;AAAA,QACA;AAAA,MACJ;AAAA,IACJ,CAAC;AAAA,EACL;AAAA,EAEA,uBAAuB;AAAA,IACnB,GAAG,UAAU;AAAA,MACT,aAAa;AAAA,MACb,SAAS;AAAA,MACT,UAAU;AAAA,MACV,QAAQ;AAAA;AAAA,MACR,UAAU,CAAC,MAAM,OAAO,OAAO,OAAO,MAAM;AAAA,IAChD,CAAC;AAAA,EACL;AAAA;AAAA;AAAA;AAAA,EAKA,sBAAsB;AAAA,IAClB,GAAG,UAAU;AAAA,MACT,aAAa;AAAA,MACb,SAAS;AAAA,MACT,UAAU;AAAA,MACV,UAAU;AAAA,QACN;AAAA,QACA;AAAA,MACJ;AAAA,IACJ,CAAC;AAAA,EACL;AAAA,EAEA,0BAA0B;AAAA,IACtB,GAAG,UAAU;AAAA,MACT,aAAa;AAAA,MACb,SAAS;AAAA,MACT,UAAU;AAAA,MACV,UAAU,CAAC,MAAM,OAAO,MAAM,KAAK;AAAA,IACvC,CAAC;AAAA,EACL;AAAA;AAAA;AAAA;AAAA,EAKA,8BAA8B;AAAA,IAC1B,GAAG,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,aAAa;AAAA,MACb,UAAU;AAAA,MACV,WAAW;AAAA,MACX,UAAU,CAAC,yBAAyB;AAAA,IACxC,CAAC;AAAA,EACL;AAAA,EAEA,yBAAyB;AAAA,IACrB,GAAG,UAAU;AAAA,MACT,aAAa;AAAA,MACb,UAAU;AAAA,MACV,UAAU;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,MACJ;AAAA,IACJ,CAAC;AAAA,EACL;AAAA,EAEA,+BAA+B;AAAA,IAC3B,GAAG,UAAU;AAAA,MACT,aAAa;AAAA,MACb,UAAU;AAAA,MACV,UAAU;AAAA,QACN;AAAA,QACA;AAAA,MACJ;AAAA,IACJ,CAAC;AAAA,EACL;AAAA,EAEA,6BAA6B;AAAA,IACzB,GAAG,UAAU;AAAA,MACT,aAAa;AAAA,MACb,UAAU;AAAA,MACV,SAAS;AAAA,MACT,UAAU;AAAA,QACN;AAAA,QACA;AAAA,MACJ;AAAA,IACJ,CAAC;AAAA,EACL;AAAA,EAEA,2BAA2B;AAAA,IACvB,GAAG,UAAU;AAAA,MACT,aAAa;AAAA,MACb,UAAU;AAAA,MACV,SAAS;AAAA,MACT,UAAU;AAAA,QACN;AAAA,QACA;AAAA,MACJ;AAAA,IACJ,CAAC;AAAA,EACL;AACJ,CAAC;;;ADvSD,IAAM,WAAW,kBAAkB,aAAa;AACzC,IAAM,MAAM,SAAS,SAAS;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/config/index.ts","../src/config/schema.ts"],"sourcesContent":["/**\n * Core Package Configuration\n *\n * @example\n * ```typescript\n * import { registry } from '@spfn/core/config';\n *\n * const env = registry.validate();\n * console.log(env.DB_POOL_MAX);\n * ```\n *\n * @module config\n */\n\nimport { createEnvRegistry } from '@spfn/core/env';\nimport { authEnvSchema } from './schema';\n\nexport { authEnvSchema as envSchema } from './schema';\n\n/**\n * Environment registry\n */\nconst registry = createEnvRegistry(authEnvSchema);\nexport const env = registry.validate();","/**\n * Auth Environment Variable Schema\n *\n * Centralized schema definition for all environment variables used in @spfn/auth.\n * This provides type safety, validation, and documentation for Auth configuration.\n *\n * @module config/schema\n */\n\nimport {\n defineEnvSchema,\n envString,\n envNumber,\n createSecureSecretParser,\n createPasswordParser,\n} from '@spfn/core/env';\n\n/**\n * Auth environment variable schema\n *\n * Defines all Auth environment variables with:\n * - Type information\n * - Default values\n * - Validation rules\n * - Documentation\n *\n * @example\n * ```typescript\n * import { authEnvSchema } from '@spfn/auth/config';\n *\n * // Access schema information\n * console.log(authEnvSchema.SPFN_AUTH_SESSION_SECRET.description);\n * console.log(authEnvSchema.SPFN_AUTH_JWT_EXPIRES_IN.default);\n * ```\n */\nexport const authEnvSchema = defineEnvSchema({\n // ============================================================================\n // Session Configuration\n // ============================================================================\n SPFN_AUTH_SESSION_SECRET: {\n ...envString({\n description: 'Session encryption secret (minimum 32 characters for AES-256)',\n required: true,\n fallbackKeys: ['SESSION_SECRET'],\n validator: createSecureSecretParser({\n minLength: 32,\n minUniqueChars: 16,\n minEntropy: 3.5,\n }),\n sensitive: true,\n nextjs: true, // Required for Next.js RSC session validation\n examples: [\n 'my-super-secret-session-key-at-least-32-chars-long',\n 'use-a-cryptographically-secure-random-string-here',\n ],\n }),\n },\n\n SPFN_AUTH_SESSION_TTL: {\n ...envString({\n description: 'Session TTL (time to live) - supports duration strings like \\'7d\\', \\'12h\\', \\'45m\\'',\n default: '7d',\n required: false,\n nextjs: true, // May be needed for session validation in Next.js RSC\n examples: ['7d', '30d', '12h', '45m', '3600'],\n }),\n },\n\n // ============================================================================\n // JWT Configuration\n // ============================================================================\n SPFN_AUTH_JWT_SECRET: {\n ...envString({\n description: 'JWT signing secret for server-signed tokens (legacy mode)',\n default: 'dev-secret-key-change-in-production',\n required: false,\n examples: [\n 'your-jwt-secret-key-here',\n 'use-different-from-session-secret',\n ],\n }),\n },\n\n SPFN_AUTH_JWT_EXPIRES_IN: {\n ...envString({\n description: 'JWT token expiration time (e.g., \\'7d\\', \\'24h\\', \\'1h\\')',\n default: '7d',\n required: false,\n examples: ['7d', '24h', '1h', '30m'],\n }),\n },\n\n // ============================================================================\n // Security Configuration\n // ============================================================================\n SPFN_AUTH_BCRYPT_SALT_ROUNDS: {\n ...envNumber({\n description: 'Bcrypt salt rounds (cost factor, higher = more secure but slower)',\n default: 10,\n required: false,\n examples: [10, 12, 14],\n }),\n key: 'SPFN_AUTH_BCRYPT_SALT_ROUNDS',\n },\n\n SPFN_AUTH_VERIFICATION_TOKEN_SECRET: {\n ...envString({\n description: 'Verification token secret for email verification, password reset, etc.',\n required: true,\n examples: [\n 'your-verification-token-secret',\n 'can-be-different-from-jwt-secret',\n ],\n }),\n },\n\n // ============================================================================\n // Admin Account Configuration\n // ============================================================================\n SPFN_AUTH_ADMIN_ACCOUNTS: {\n ...envString({\n description: 'JSON array of admin accounts (recommended for multiple admins)',\n required: false,\n examples: [\n '[{\"email\":\"admin@example.com\",\"password\":\"secure-pass\",\"role\":\"admin\"}]',\n '[{\"email\":\"super@example.com\",\"password\":\"pass1\",\"role\":\"superadmin\"},{\"email\":\"admin@example.com\",\"password\":\"pass2\",\"role\":\"admin\"}]',\n ],\n }),\n },\n\n SPFN_AUTH_ADMIN_EMAILS: {\n ...envString({\n description: 'Comma-separated list of admin emails (legacy CSV format)',\n required: false,\n examples: [\n 'admin@example.com,user@example.com',\n 'super@example.com,admin@example.com,user@example.com',\n ],\n }),\n },\n\n SPFN_AUTH_ADMIN_PASSWORDS: {\n ...envString({\n description: 'Comma-separated list of admin passwords (legacy CSV format)',\n required: false,\n examples: [\n 'admin-pass,user-pass',\n 'super-pass,admin-pass,user-pass',\n ],\n }),\n },\n\n SPFN_AUTH_ADMIN_ROLES: {\n ...envString({\n description: 'Comma-separated list of admin roles (legacy CSV format)',\n required: false,\n examples: [\n 'admin,user',\n 'superadmin,admin,user',\n ],\n }),\n },\n\n SPFN_AUTH_ADMIN_EMAIL: {\n ...envString({\n description: 'Single admin email (simplest format)',\n required: false,\n examples: ['admin@example.com'],\n }),\n },\n\n SPFN_AUTH_ADMIN_PASSWORD: {\n ...envString({\n description: 'Single admin password (simplest format)',\n required: false,\n validator: createPasswordParser({\n minLength: 8,\n requireUppercase: true,\n requireLowercase: true,\n requireNumber: true,\n requireSpecial: true,\n }),\n sensitive: true,\n examples: ['SecureAdmin123!'],\n }),\n },\n\n // ============================================================================\n // Username Configuration\n // ============================================================================\n SPFN_AUTH_RESERVED_USERNAMES: {\n ...envString({\n description: 'Comma-separated list of reserved usernames that cannot be registered',\n required: false,\n default: 'admin,root,system,support,help,moderator,superadmin',\n examples: [\n 'admin,root,system,support,help',\n 'admin,root,system,support,help,moderator,superadmin,operator',\n ],\n }),\n },\n\n SPFN_AUTH_USERNAME_MIN_LENGTH: {\n ...envNumber({\n description: 'Minimum username length',\n default: 3,\n required: false,\n examples: [2, 3, 4],\n }),\n },\n\n SPFN_AUTH_USERNAME_MAX_LENGTH: {\n ...envNumber({\n description: 'Maximum username length',\n default: 30,\n required: false,\n examples: [20, 30, 50],\n }),\n },\n\n // ============================================================================\n // API Configuration\n // ============================================================================\n SPFN_API_URL: {\n ...envString({\n description: 'Internal API URL for server-to-server communication',\n default: 'http://localhost:8790',\n required: false,\n examples: [\n 'https://api.example.com',\n 'http://localhost:8790',\n ],\n }),\n },\n\n NEXT_PUBLIC_SPFN_API_URL: {\n ...envString({\n description: 'Public-facing API URL used for browser-facing redirects (e.g. OAuth callback). Falls back to SPFN_API_URL if not set.',\n required: false,\n examples: [\n 'https://api.example.com',\n 'http://localhost:8790',\n ],\n }),\n },\n\n SPFN_APP_URL: {\n ...envString({\n description: 'Next.js application URL (internal). Used for server-to-server communication.',\n default: 'http://localhost:3000',\n required: false,\n examples: [\n 'https://app.example.com',\n 'http://localhost:3000',\n ],\n }),\n },\n\n NEXT_PUBLIC_SPFN_APP_URL: {\n ...envString({\n description: 'Public-facing Next.js app URL for browser redirects (e.g. OAuth redirect). Falls back to SPFN_APP_URL if not set.',\n required: false,\n examples: [\n 'https://app.example.com',\n 'http://localhost:3000',\n ],\n }),\n },\n\n // ============================================================================\n // OAuth Configuration - Google\n // ============================================================================\n SPFN_AUTH_GOOGLE_CLIENT_ID: {\n ...envString({\n description: 'Google OAuth 2.0 Client ID. When set, Google OAuth routes are automatically enabled.',\n required: false,\n examples: ['123456789-abc123.apps.googleusercontent.com'],\n }),\n },\n\n SPFN_AUTH_GOOGLE_CLIENT_SECRET: {\n ...envString({\n description: 'Google OAuth 2.0 Client Secret',\n required: false,\n sensitive: true,\n examples: ['GOCSPX-abcdefghijklmnop'],\n }),\n },\n\n SPFN_AUTH_GOOGLE_SCOPES: {\n ...envString({\n description: 'Comma-separated Google OAuth scopes. Defaults to \"email,profile\" if not set.',\n required: false,\n examples: [\n 'email,profile',\n 'email,profile,https://www.googleapis.com/auth/gmail.readonly',\n 'email,profile,https://www.googleapis.com/auth/calendar.readonly',\n ],\n }),\n },\n\n SPFN_AUTH_GOOGLE_REDIRECT_URI: {\n ...envString({\n description: 'Google OAuth callback URL. Defaults to {NEXT_PUBLIC_SPFN_API_URL || SPFN_API_URL}/_auth/oauth/google/callback',\n required: false,\n examples: [\n 'https://api.example.com/_auth/oauth/google/callback',\n 'http://localhost:8790/_auth/oauth/google/callback',\n ],\n }),\n },\n\n SPFN_AUTH_OAUTH_SUCCESS_URL: {\n ...envString({\n description: 'OAuth callback page URL. This page should use OAuthCallback component to finalize session.',\n required: false,\n default: '/auth/callback',\n examples: [\n '/auth/callback',\n 'https://app.example.com/auth/callback',\n ],\n }),\n },\n\n SPFN_AUTH_OAUTH_ERROR_URL: {\n ...envString({\n description: 'URL to redirect after OAuth error. Use {error} placeholder for error message.',\n required: false,\n default: 'http://localhost:3000/auth/error?error={error}',\n examples: [\n 'https://app.example.com/auth/error?error={error}',\n 'http://localhost:3000/auth/error?error={error}',\n ],\n }),\n },\n});"],"mappings":";AAcA,SAAS,yBAAyB;;;ACLlC;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAoBA,IAAM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A6C;AAAA,IAC5D,CAAC;AAAA,EACL;AAAA,EAEA,gCAAgC;AAAA,IAC5B,GAAG,UAAU;AAAA,MACT,aAAa;AAAA,MACb,UAAU;AAAA,MACV,WAAW;AAAA,MACX,UAAU,CAAC,yBAAyB;AAAA,IACxC,CAAC;AAAA,EACL;AAAA,EAEA,yBAAyB;AAAA,IACrB,GAAG,UAAU;AAAA,MACT,aAAa;AAAA,MACb,UAAU;AAAA,MACV,UAAU;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,MACJ;AAAA,IACJ,CAAC;AAAA,EACL;AAAA,EAEA,+BAA+B;AAAA,IAC3B,GAAG,UAAU;AAAA,MACT,aAAa;AAAA,MACb,UAAU;AAAA,MACV,UAAU;AAAA,QACN;AAAA,QACA;AAAA,MACJ;AAAA,IACJ,CAAC;AAAA,EACL;AAAA,EAEA,6BAA6B;AAAA,IACzB,GAAG,UAAU;AAAA,MACT,aAAa;AAAA,MACb,UAAU;AAAA,MACV,SAAS;AAAA,MACT,UAAU;AAAA,QACN;AAAA,QACA;AAAA,MACJ;AAAA,IACJ,CAAC;AAAA,EACL;AAAA,EAEA,2BAA2B;AAAA,IACvB,GAAG,UAAU;AAAA,MACT,aAAa;AAAA,MACb,UAAU;AAAA,MACV,SAAS;AAAA,MACT,UAAU;AAAA,QACN;AAAA,QACA;AAAA,MACJ;AAAA,IACJ,CAAC;AAAA,EACL;AACJ,CAAC;;;ADzTD,IAAM,WAAW,kBAAkB,aAAa;AACzC,IAAM,MAAM,SAAS,SAAS;","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _spfn_core_nextjs from '@spfn/core/nextjs';
|
|
2
|
-
import { R as RoleConfig, P as PermissionConfig, C as CheckAccountExistsResult, S as SendVerificationCodeResult, a as RegisterResult, L as LoginResult, b as RotateKeyResult, O as OAuthStartResult, U as UserProfile, c as ProfileInfo, m as mainAuthRouter } from './authenticate-
|
|
3
|
-
export { k as AuthInitOptions, A as AuthSession, I as INVITATION_STATUSES, n as InvitationStatus, K as KEY_ALGORITHM, l as KeyAlgorithmType, i as PERMISSION_CATEGORIES, j as PermissionCategory, e as SOCIAL_PROVIDERS, p as SocialProvider, d as USER_STATUSES, o as UserStatus, h as VERIFICATION_PURPOSES, g as VERIFICATION_TARGET_TYPES, f as VerificationPurpose, V as VerificationTargetType } from './authenticate-
|
|
2
|
+
import { R as RoleConfig, P as PermissionConfig, C as CheckAccountExistsResult, S as SendVerificationCodeResult, a as RegisterResult, L as LoginResult, b as RotateKeyResult, O as OAuthStartResult, U as UserProfile, c as ProfileInfo, m as mainAuthRouter } from './authenticate-CGslXjZb.js';
|
|
3
|
+
export { k as AuthInitOptions, A as AuthSession, I as INVITATION_STATUSES, n as InvitationStatus, K as KEY_ALGORITHM, l as KeyAlgorithmType, i as PERMISSION_CATEGORIES, j as PermissionCategory, e as SOCIAL_PROVIDERS, p as SocialProvider, d as USER_STATUSES, o as UserStatus, h as VERIFICATION_PURPOSES, g as VERIFICATION_TARGET_TYPES, f as VerificationPurpose, V as VerificationTargetType } from './authenticate-CGslXjZb.js';
|
|
4
4
|
import * as _spfn_core_route from '@spfn/core/route';
|
|
5
5
|
import { HttpMethod } from '@spfn/core/route';
|
|
6
6
|
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
@@ -168,7 +168,7 @@ declare const authApi: _spfn_core_nextjs.Client<_spfn_core_route.Router<{
|
|
|
168
168
|
id: number;
|
|
169
169
|
name: string;
|
|
170
170
|
displayName: string;
|
|
171
|
-
category: "
|
|
171
|
+
category: "custom" | "user" | "auth" | "rbac" | "system" | undefined;
|
|
172
172
|
}[];
|
|
173
173
|
userId: number;
|
|
174
174
|
email: string | null;
|
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { k as AuthInitOptions, l as KeyAlgorithmType, n as InvitationStatus, f as VerificationPurpose, j as PermissionCategory, p as SocialProvider, q as AuthContext } from './authenticate-
|
|
2
|
-
export { B as ChangePasswordParams, w as CheckAccountExistsParams, C as CheckAccountExistsResult, a6 as EmailSchema, I as INVITATION_STATUSES, K as KEY_ALGORITHM, y as LoginParams, L as LoginResult, z as LogoutParams, a2 as OAuthCallbackParams, a3 as OAuthCallbackResult, a1 as OAuthStartParams, O as OAuthStartResult, a8 as PasswordSchema, a7 as PhoneSchema, x as RegisterParams, Q as RegisterPublicKeyParams, a as RegisterResult, W as RevokeKeyParams, T as RotateKeyParams, b as RotateKeyResult, e as SOCIAL_PROVIDERS, F as SendVerificationCodeParams, S as SendVerificationCodeResult, a9 as TargetTypeSchema, d as USER_STATUSES, o as UserStatus, h as VERIFICATION_PURPOSES, g as VERIFICATION_TARGET_TYPES, aa as VerificationPurposeSchema, V as VerificationTargetType, G as VerifyCodeParams, H as VerifyCodeResult, m as authRouter, a4 as authenticate, Z as buildOAuthErrorUrl, v as changePasswordService, r as checkAccountExistsService, $ as getEnabledOAuthProviders, a0 as getGoogleAccessToken, _ as isOAuthProviderEnabled, t as loginService, u as logoutService, Y as oauthCallbackService, X as oauthStartService, a5 as optionalAuth, J as registerPublicKeyService, s as registerService, N as revokeKeyService, M as rotateKeyService, D as sendVerificationCodeService, E as verifyCodeService } from './authenticate-
|
|
1
|
+
import { k as AuthInitOptions, l as KeyAlgorithmType, n as InvitationStatus, f as VerificationPurpose, j as PermissionCategory, p as SocialProvider, q as AuthContext } from './authenticate-CGslXjZb.js';
|
|
2
|
+
export { B as ChangePasswordParams, w as CheckAccountExistsParams, C as CheckAccountExistsResult, a6 as EmailSchema, I as INVITATION_STATUSES, K as KEY_ALGORITHM, y as LoginParams, L as LoginResult, z as LogoutParams, a2 as OAuthCallbackParams, a3 as OAuthCallbackResult, a1 as OAuthStartParams, O as OAuthStartResult, a8 as PasswordSchema, a7 as PhoneSchema, x as RegisterParams, Q as RegisterPublicKeyParams, a as RegisterResult, W as RevokeKeyParams, T as RotateKeyParams, b as RotateKeyResult, e as SOCIAL_PROVIDERS, F as SendVerificationCodeParams, S as SendVerificationCodeResult, a9 as TargetTypeSchema, d as USER_STATUSES, o as UserStatus, h as VERIFICATION_PURPOSES, g as VERIFICATION_TARGET_TYPES, aa as VerificationPurposeSchema, V as VerificationTargetType, G as VerifyCodeParams, H as VerifyCodeResult, m as authRouter, a4 as authenticate, Z as buildOAuthErrorUrl, v as changePasswordService, r as checkAccountExistsService, $ as getEnabledOAuthProviders, a0 as getGoogleAccessToken, _ as isOAuthProviderEnabled, t as loginService, u as logoutService, Y as oauthCallbackService, X as oauthStartService, a5 as optionalAuth, J as registerPublicKeyService, s as registerService, N as revokeKeyService, M as rotateKeyService, D as sendVerificationCodeService, E as verifyCodeService } from './authenticate-CGslXjZb.js';
|
|
3
3
|
import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
|
|
4
4
|
import { UserProfile as UserProfile$1, ProfileInfo } from '@spfn/auth';
|
|
5
5
|
import { BaseRepository } from '@spfn/core/db';
|
|
@@ -1305,7 +1305,7 @@ declare function getAuthSessionService(userId: string | number | bigint): Promis
|
|
|
1305
1305
|
id: number;
|
|
1306
1306
|
name: string;
|
|
1307
1307
|
displayName: string;
|
|
1308
|
-
category: "
|
|
1308
|
+
category: "custom" | "user" | "auth" | "rbac" | "system" | undefined;
|
|
1309
1309
|
}[];
|
|
1310
1310
|
userId: number;
|
|
1311
1311
|
email: string | null;
|
|
@@ -2434,7 +2434,7 @@ declare const permissions: drizzle_orm_pg_core.PgTableWithColumns<{
|
|
|
2434
2434
|
tableName: "permissions";
|
|
2435
2435
|
dataType: "string";
|
|
2436
2436
|
columnType: "PgText";
|
|
2437
|
-
data: "
|
|
2437
|
+
data: "custom" | "user" | "auth" | "rbac" | "system";
|
|
2438
2438
|
driverParam: string;
|
|
2439
2439
|
notNull: false;
|
|
2440
2440
|
hasDefault: false;
|
|
@@ -2934,14 +2934,14 @@ declare class UsersRepository extends BaseRepository {
|
|
|
2934
2934
|
create(data: NewUser): Promise<{
|
|
2935
2935
|
email: string | null;
|
|
2936
2936
|
phone: string | null;
|
|
2937
|
-
|
|
2937
|
+
status: "active" | "inactive" | "suspended";
|
|
2938
2938
|
username: string | null;
|
|
2939
|
+
id: number;
|
|
2940
|
+
createdAt: Date;
|
|
2941
|
+
updatedAt: Date;
|
|
2939
2942
|
passwordHash: string | null;
|
|
2940
2943
|
passwordChangeRequired: boolean;
|
|
2941
2944
|
roleId: number;
|
|
2942
|
-
createdAt: Date;
|
|
2943
|
-
updatedAt: Date;
|
|
2944
|
-
status: "active" | "inactive" | "suspended";
|
|
2945
2945
|
emailVerifiedAt: Date | null;
|
|
2946
2946
|
phoneVerifiedAt: Date | null;
|
|
2947
2947
|
lastLoginAt: Date | null;
|
|
@@ -3010,14 +3010,14 @@ declare class UsersRepository extends BaseRepository {
|
|
|
3010
3010
|
deleteById(id: number): Promise<{
|
|
3011
3011
|
email: string | null;
|
|
3012
3012
|
phone: string | null;
|
|
3013
|
-
|
|
3013
|
+
status: "active" | "inactive" | "suspended";
|
|
3014
3014
|
username: string | null;
|
|
3015
|
+
id: number;
|
|
3016
|
+
createdAt: Date;
|
|
3017
|
+
updatedAt: Date;
|
|
3015
3018
|
passwordHash: string | null;
|
|
3016
3019
|
passwordChangeRequired: boolean;
|
|
3017
3020
|
roleId: number;
|
|
3018
|
-
createdAt: Date;
|
|
3019
|
-
updatedAt: Date;
|
|
3020
|
-
status: "active" | "inactive" | "suspended";
|
|
3021
3021
|
emailVerifiedAt: Date | null;
|
|
3022
3022
|
phoneVerifiedAt: Date | null;
|
|
3023
3023
|
lastLoginAt: Date | null;
|
|
@@ -3040,7 +3040,7 @@ declare class UsersRepository extends BaseRepository {
|
|
|
3040
3040
|
id: number;
|
|
3041
3041
|
name: string;
|
|
3042
3042
|
displayName: string;
|
|
3043
|
-
category: "
|
|
3043
|
+
category: "custom" | "user" | "auth" | "rbac" | "system" | undefined;
|
|
3044
3044
|
}[];
|
|
3045
3045
|
}>;
|
|
3046
3046
|
/**
|
|
@@ -3152,16 +3152,16 @@ declare class KeysRepository extends BaseRepository {
|
|
|
3152
3152
|
* Write primary 사용
|
|
3153
3153
|
*/
|
|
3154
3154
|
create(data: NewUserPublicKey): Promise<{
|
|
3155
|
-
publicKey: string;
|
|
3156
|
-
keyId: string;
|
|
3157
|
-
fingerprint: string;
|
|
3158
|
-
algorithm: "ES256" | "RS256";
|
|
3159
3155
|
userId: number;
|
|
3156
|
+
keyId: string;
|
|
3160
3157
|
id: number;
|
|
3161
3158
|
isActive: boolean;
|
|
3162
3159
|
createdAt: Date;
|
|
3163
|
-
|
|
3160
|
+
publicKey: string;
|
|
3161
|
+
algorithm: "ES256" | "RS256";
|
|
3162
|
+
fingerprint: string;
|
|
3164
3163
|
lastUsedAt: Date | null;
|
|
3164
|
+
expiresAt: Date | null;
|
|
3165
3165
|
revokedAt: Date | null;
|
|
3166
3166
|
revokedReason: string | null;
|
|
3167
3167
|
}>;
|
|
@@ -3188,16 +3188,16 @@ declare class KeysRepository extends BaseRepository {
|
|
|
3188
3188
|
* Write primary 사용
|
|
3189
3189
|
*/
|
|
3190
3190
|
deleteByKeyIdAndUserId(keyId: string, userId: number): Promise<{
|
|
3191
|
-
publicKey: string;
|
|
3192
|
-
keyId: string;
|
|
3193
|
-
fingerprint: string;
|
|
3194
|
-
algorithm: "ES256" | "RS256";
|
|
3195
3191
|
userId: number;
|
|
3192
|
+
keyId: string;
|
|
3196
3193
|
id: number;
|
|
3197
3194
|
isActive: boolean;
|
|
3198
3195
|
createdAt: Date;
|
|
3199
|
-
|
|
3196
|
+
publicKey: string;
|
|
3197
|
+
algorithm: "ES256" | "RS256";
|
|
3198
|
+
fingerprint: string;
|
|
3200
3199
|
lastUsedAt: Date | null;
|
|
3200
|
+
expiresAt: Date | null;
|
|
3201
3201
|
revokedAt: Date | null;
|
|
3202
3202
|
revokedReason: string | null;
|
|
3203
3203
|
}>;
|
|
@@ -3312,14 +3312,14 @@ declare class VerificationCodesRepository extends BaseRepository {
|
|
|
3312
3312
|
* Write primary 사용
|
|
3313
3313
|
*/
|
|
3314
3314
|
create(data: NewVerificationCode): Promise<{
|
|
3315
|
-
target: string;
|
|
3316
|
-
targetType: "email" | "phone";
|
|
3317
|
-
purpose: "registration" | "login" | "password_reset" | "email_change" | "phone_change";
|
|
3318
|
-
code: string;
|
|
3319
3315
|
id: number;
|
|
3320
3316
|
createdAt: Date;
|
|
3321
3317
|
updatedAt: Date;
|
|
3322
3318
|
expiresAt: Date;
|
|
3319
|
+
target: string;
|
|
3320
|
+
targetType: "email" | "phone";
|
|
3321
|
+
code: string;
|
|
3322
|
+
purpose: "registration" | "login" | "password_reset" | "email_change" | "phone_change";
|
|
3323
3323
|
usedAt: Date | null;
|
|
3324
3324
|
attempts: number;
|
|
3325
3325
|
}>;
|
|
@@ -3508,7 +3508,7 @@ declare class PermissionsRepository extends BaseRepository {
|
|
|
3508
3508
|
name: string;
|
|
3509
3509
|
displayName: string;
|
|
3510
3510
|
description: string | null;
|
|
3511
|
-
category: "
|
|
3511
|
+
category: "custom" | "user" | "auth" | "rbac" | "system" | null;
|
|
3512
3512
|
isBuiltin: boolean;
|
|
3513
3513
|
isSystem: boolean;
|
|
3514
3514
|
isActive: boolean;
|
|
@@ -3524,7 +3524,7 @@ declare class PermissionsRepository extends BaseRepository {
|
|
|
3524
3524
|
name: string;
|
|
3525
3525
|
displayName: string;
|
|
3526
3526
|
description: string | null;
|
|
3527
|
-
category: "
|
|
3527
|
+
category: "custom" | "user" | "auth" | "rbac" | "system" | null;
|
|
3528
3528
|
isBuiltin: boolean;
|
|
3529
3529
|
isSystem: boolean;
|
|
3530
3530
|
isActive: boolean;
|
|
@@ -3564,7 +3564,7 @@ declare class PermissionsRepository extends BaseRepository {
|
|
|
3564
3564
|
name: string;
|
|
3565
3565
|
displayName: string;
|
|
3566
3566
|
description: string | null;
|
|
3567
|
-
category: "
|
|
3567
|
+
category: "custom" | "user" | "auth" | "rbac" | "system" | null;
|
|
3568
3568
|
isBuiltin: boolean;
|
|
3569
3569
|
isSystem: boolean;
|
|
3570
3570
|
isActive: boolean;
|
|
@@ -3583,8 +3583,8 @@ declare class PermissionsRepository extends BaseRepository {
|
|
|
3583
3583
|
isActive: boolean;
|
|
3584
3584
|
createdAt: Date;
|
|
3585
3585
|
updatedAt: Date;
|
|
3586
|
-
category: "auth" | "custom" | "user" | "rbac" | "system" | null;
|
|
3587
3586
|
metadata: Record<string, any> | null;
|
|
3587
|
+
category: "custom" | "user" | "auth" | "rbac" | "system" | null;
|
|
3588
3588
|
}>;
|
|
3589
3589
|
}
|
|
3590
3590
|
declare const permissionsRepository: PermissionsRepository;
|
|
@@ -3629,9 +3629,9 @@ declare class RolePermissionsRepository extends BaseRepository {
|
|
|
3629
3629
|
*/
|
|
3630
3630
|
createMany(data: NewRolePermission[]): Promise<{
|
|
3631
3631
|
id: number;
|
|
3632
|
-
roleId: number;
|
|
3633
3632
|
createdAt: Date;
|
|
3634
3633
|
updatedAt: Date;
|
|
3634
|
+
roleId: number;
|
|
3635
3635
|
permissionId: number;
|
|
3636
3636
|
}[]>;
|
|
3637
3637
|
/**
|
|
@@ -3647,9 +3647,9 @@ declare class RolePermissionsRepository extends BaseRepository {
|
|
|
3647
3647
|
*/
|
|
3648
3648
|
setPermissionsForRole(roleId: number, permissionIds: number[]): Promise<{
|
|
3649
3649
|
id: number;
|
|
3650
|
-
roleId: number;
|
|
3651
3650
|
createdAt: Date;
|
|
3652
3651
|
updatedAt: Date;
|
|
3652
|
+
roleId: number;
|
|
3653
3653
|
permissionId: number;
|
|
3654
3654
|
}[]>;
|
|
3655
3655
|
}
|
|
@@ -3714,10 +3714,10 @@ declare class UserPermissionsRepository extends BaseRepository {
|
|
|
3714
3714
|
id: number;
|
|
3715
3715
|
createdAt: Date;
|
|
3716
3716
|
updatedAt: Date;
|
|
3717
|
-
permissionId: number;
|
|
3718
3717
|
expiresAt: Date | null;
|
|
3719
|
-
|
|
3718
|
+
permissionId: number;
|
|
3720
3719
|
granted: boolean;
|
|
3720
|
+
reason: string | null;
|
|
3721
3721
|
}>;
|
|
3722
3722
|
/**
|
|
3723
3723
|
* 사용자 권한 오버라이드 업데이트
|
|
@@ -3740,10 +3740,10 @@ declare class UserPermissionsRepository extends BaseRepository {
|
|
|
3740
3740
|
id: number;
|
|
3741
3741
|
createdAt: Date;
|
|
3742
3742
|
updatedAt: Date;
|
|
3743
|
-
permissionId: number;
|
|
3744
3743
|
expiresAt: Date | null;
|
|
3745
|
-
|
|
3744
|
+
permissionId: number;
|
|
3746
3745
|
granted: boolean;
|
|
3746
|
+
reason: string | null;
|
|
3747
3747
|
}>;
|
|
3748
3748
|
/**
|
|
3749
3749
|
* 사용자의 모든 권한 오버라이드 삭제
|
|
@@ -3822,7 +3822,6 @@ declare class UserProfilesRepository extends BaseRepository {
|
|
|
3822
3822
|
displayName: string;
|
|
3823
3823
|
createdAt: Date;
|
|
3824
3824
|
updatedAt: Date;
|
|
3825
|
-
metadata: Record<string, any> | null;
|
|
3826
3825
|
firstName: string | null;
|
|
3827
3826
|
lastName: string | null;
|
|
3828
3827
|
avatarUrl: string | null;
|
|
@@ -3835,6 +3834,7 @@ declare class UserProfilesRepository extends BaseRepository {
|
|
|
3835
3834
|
location: string | null;
|
|
3836
3835
|
company: string | null;
|
|
3837
3836
|
jobTitle: string | null;
|
|
3837
|
+
metadata: Record<string, any> | null;
|
|
3838
3838
|
}>;
|
|
3839
3839
|
/**
|
|
3840
3840
|
* 프로필 업데이트 (by ID)
|
|
@@ -3891,7 +3891,6 @@ declare class UserProfilesRepository extends BaseRepository {
|
|
|
3891
3891
|
displayName: string;
|
|
3892
3892
|
createdAt: Date;
|
|
3893
3893
|
updatedAt: Date;
|
|
3894
|
-
metadata: Record<string, any> | null;
|
|
3895
3894
|
firstName: string | null;
|
|
3896
3895
|
lastName: string | null;
|
|
3897
3896
|
avatarUrl: string | null;
|
|
@@ -3904,6 +3903,7 @@ declare class UserProfilesRepository extends BaseRepository {
|
|
|
3904
3903
|
location: string | null;
|
|
3905
3904
|
company: string | null;
|
|
3906
3905
|
jobTitle: string | null;
|
|
3906
|
+
metadata: Record<string, any> | null;
|
|
3907
3907
|
}>;
|
|
3908
3908
|
/**
|
|
3909
3909
|
* 프로필 삭제 (by User ID)
|
|
@@ -3914,7 +3914,6 @@ declare class UserProfilesRepository extends BaseRepository {
|
|
|
3914
3914
|
displayName: string;
|
|
3915
3915
|
createdAt: Date;
|
|
3916
3916
|
updatedAt: Date;
|
|
3917
|
-
metadata: Record<string, any> | null;
|
|
3918
3917
|
firstName: string | null;
|
|
3919
3918
|
lastName: string | null;
|
|
3920
3919
|
avatarUrl: string | null;
|
|
@@ -3927,6 +3926,7 @@ declare class UserProfilesRepository extends BaseRepository {
|
|
|
3927
3926
|
location: string | null;
|
|
3928
3927
|
company: string | null;
|
|
3929
3928
|
jobTitle: string | null;
|
|
3929
|
+
metadata: Record<string, any> | null;
|
|
3930
3930
|
}>;
|
|
3931
3931
|
/**
|
|
3932
3932
|
* 프로필 Upsert (by User ID)
|
|
@@ -3940,7 +3940,6 @@ declare class UserProfilesRepository extends BaseRepository {
|
|
|
3940
3940
|
displayName: string;
|
|
3941
3941
|
createdAt: Date;
|
|
3942
3942
|
updatedAt: Date;
|
|
3943
|
-
metadata: Record<string, any> | null;
|
|
3944
3943
|
firstName: string | null;
|
|
3945
3944
|
lastName: string | null;
|
|
3946
3945
|
avatarUrl: string | null;
|
|
@@ -3953,6 +3952,7 @@ declare class UserProfilesRepository extends BaseRepository {
|
|
|
3953
3952
|
location: string | null;
|
|
3954
3953
|
company: string | null;
|
|
3955
3954
|
jobTitle: string | null;
|
|
3955
|
+
metadata: Record<string, any> | null;
|
|
3956
3956
|
}>;
|
|
3957
3957
|
/**
|
|
3958
3958
|
* User ID로 프로필 데이터 조회 (formatted)
|
|
@@ -4080,15 +4080,15 @@ declare class InvitationsRepository extends BaseRepository {
|
|
|
4080
4080
|
*/
|
|
4081
4081
|
create(data: NewInvitation): Promise<{
|
|
4082
4082
|
email: string;
|
|
4083
|
+
status: "pending" | "accepted" | "expired" | "cancelled";
|
|
4083
4084
|
id: number;
|
|
4084
|
-
roleId: number;
|
|
4085
4085
|
createdAt: Date;
|
|
4086
4086
|
updatedAt: Date;
|
|
4087
|
-
|
|
4087
|
+
roleId: number;
|
|
4088
4088
|
metadata: Record<string, any> | null;
|
|
4089
|
+
expiresAt: Date;
|
|
4089
4090
|
token: string;
|
|
4090
4091
|
invitedBy: number;
|
|
4091
|
-
expiresAt: Date;
|
|
4092
4092
|
acceptedAt: Date | null;
|
|
4093
4093
|
cancelledAt: Date | null;
|
|
4094
4094
|
}>;
|
|
@@ -4114,15 +4114,15 @@ declare class InvitationsRepository extends BaseRepository {
|
|
|
4114
4114
|
*/
|
|
4115
4115
|
deleteById(id: number): Promise<{
|
|
4116
4116
|
email: string;
|
|
4117
|
+
status: "pending" | "accepted" | "expired" | "cancelled";
|
|
4117
4118
|
id: number;
|
|
4118
|
-
roleId: number;
|
|
4119
4119
|
createdAt: Date;
|
|
4120
4120
|
updatedAt: Date;
|
|
4121
|
-
|
|
4121
|
+
roleId: number;
|
|
4122
4122
|
metadata: Record<string, any> | null;
|
|
4123
|
+
expiresAt: Date;
|
|
4123
4124
|
token: string;
|
|
4124
4125
|
invitedBy: number;
|
|
4125
|
-
expiresAt: Date;
|
|
4126
4126
|
acceptedAt: Date | null;
|
|
4127
4127
|
cancelledAt: Date | null;
|
|
4128
4128
|
}>;
|
|
@@ -4789,14 +4789,14 @@ declare function getUser(c: Context | {
|
|
|
4789
4789
|
}): {
|
|
4790
4790
|
email: string | null;
|
|
4791
4791
|
phone: string | null;
|
|
4792
|
-
|
|
4792
|
+
status: "active" | "inactive" | "suspended";
|
|
4793
4793
|
username: string | null;
|
|
4794
|
+
id: number;
|
|
4795
|
+
createdAt: Date;
|
|
4796
|
+
updatedAt: Date;
|
|
4794
4797
|
passwordHash: string | null;
|
|
4795
4798
|
passwordChangeRequired: boolean;
|
|
4796
4799
|
roleId: number;
|
|
4797
|
-
createdAt: Date;
|
|
4798
|
-
updatedAt: Date;
|
|
4799
|
-
status: "active" | "inactive" | "suspended";
|
|
4800
4800
|
emailVerifiedAt: Date | null;
|
|
4801
4801
|
phoneVerifiedAt: Date | null;
|
|
4802
4802
|
lastLoginAt: Date | null;
|