@thinkingcat/auth-utils 1.0.50 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,634 +1,18 @@
1
- import type { JWT } from "next-auth/jwt";
2
- import type { Session } from "next-auth";
3
- import type { NextResponse, NextRequest } from 'next/server';
4
- export interface ResponseLike {
5
- cookies: {
6
- delete(name: string): void;
7
- set(name: string, value: string, options?: {
8
- httpOnly?: boolean;
9
- secure?: boolean;
10
- sameSite?: 'strict' | 'lax' | 'none';
11
- maxAge?: number;
12
- path?: string;
13
- domain?: string;
14
- }): void;
15
- };
16
- }
17
- export interface ServiceInfo {
18
- serviceId: string;
19
- role: string;
20
- joinedAt: string;
21
- lastAccessAt?: string;
22
- expiredAt?: string;
23
- status: string;
24
- }
25
- export interface SSOUpsertResponse {
26
- success: boolean;
27
- message?: string;
28
- user?: {
29
- id: string;
30
- email: string;
31
- name: string;
32
- };
33
- }
34
- export interface SSOErrorResponse {
35
- error: string;
36
- message?: string;
37
- }
38
- export interface SSORefreshTokenResponse {
39
- success: boolean;
40
- accessToken?: string;
41
- refreshToken?: string;
42
- user?: {
43
- id: string;
44
- email: string;
45
- name: string;
46
- };
47
- error?: string;
48
- }
49
- export interface SSOGetRefreshTokenResponse {
50
- success: boolean;
51
- refreshToken?: string;
52
- error?: string;
53
- }
54
- export interface SSORegisterResponse {
55
- success: boolean;
56
- message?: string;
57
- user?: {
58
- id: string;
59
- email: string;
60
- name: string;
61
- };
62
- }
63
- export interface JWTPayload {
64
- sub?: string;
65
- id?: string;
66
- email: string;
67
- name: string;
68
- role?: string;
69
- iat?: number;
70
- exp?: number;
71
- services?: ServiceInfo[];
72
- phoneVerified?: boolean;
73
- emailVerified?: boolean;
74
- smsVerified?: boolean;
75
- phone?: string;
76
- isPasswordReset?: boolean;
77
- decryptedEmail?: string;
78
- decryptedPhone?: string;
79
- emailHash?: string;
80
- maskedEmail?: string;
81
- phoneHash?: string;
82
- maskedPhone?: string;
83
- refreshToken?: string;
84
- accessToken?: string;
85
- accessTokenExpires?: number;
86
- serviceId?: string;
87
- [key: string]: unknown;
88
- }
89
- /**
90
- * 토큰 검증 및 디코딩
91
- * @param accessToken JWT access token
92
- * @param secret JWT 서명에 사용할 secret key
93
- * @returns 검증된 payload 또는 null
94
- */
95
- export declare function verifyToken(accessToken: string, secret: string): Promise<{
96
- payload: JWTPayload;
97
- } | null>;
98
- /**
99
- * payload에서 역할 추출 (서비스별)
100
- * @param payload JWT payload
101
- * @param serviceId 서비스 ID (필수)
102
- * @param defaultRole 기본 역할 (기본값: 'ADMIN')
103
- * @returns 추출된 역할
104
- */
105
- export declare function extractRoleFromPayload(payload: JWTPayload, serviceId: string, defaultRole?: string): string;
106
- /**
107
- * payload에서 NextAuth JWT 객체 생성
108
- * @param payload JWT payload
109
- * @param serviceId 서비스 ID (필수)
110
- * @returns NextAuth JWT 객체
111
- */
112
- export declare function createNextAuthJWT(payload: JWTPayload, serviceId: string): JWT;
113
- /**
114
- * NextAuth JWT를 인코딩된 세션 토큰으로 변환
115
- * @param jwt NextAuth JWT 객체
116
- * @param secret JWT 서명에 사용할 secret key
117
- * @param maxAge 토큰 유효 기간 (초, 기본값: 30일)
118
- * @returns 인코딩된 세션 토큰
119
- */
120
- export declare function encodeNextAuthToken(jwt: JWT, secret: string, maxAge?: number): Promise<string>;
121
- /**
122
- * 자체 토큰만 설정 (access token, refresh token)
123
- * @param response NextResponse 객체
124
- * @param accessToken access token
125
- * @param refreshToken refresh token (선택)
126
- * @param options 쿠키 설정 옵션
127
- * @param options.cookiePrefix 쿠키 이름 접두사 (필수)
128
- * @param options.isProduction 프로덕션 환경 여부 (기본값: false)
129
- */
130
- export declare function setCustomTokens(response: ResponseLike, accessToken: string, refreshToken: string, options?: {
131
- cookiePrefix?: string;
132
- isProduction?: boolean;
133
- cookieDomain?: string;
134
- }): void;
135
- export declare function setCustomTokens(response: ResponseLike, accessToken: string, options?: {
136
- refreshToken?: string;
137
- cookiePrefix?: string;
138
- isProduction?: boolean;
139
- cookieDomain?: string;
140
- }): void;
141
- /**
142
- * NextAuth 세션 토큰만 설정
143
- * @param response NextResponse 객체
144
- * @param sessionToken NextAuth session token
145
- * @param options 쿠키 설정 옵션
146
- * @param options.isProduction 프로덕션 환경 여부 (기본값: false)
147
- * @param options.cookieDomain 쿠키 도메인 (선택)
148
- */
149
- export declare function setNextAuthToken(response: ResponseLike, sessionToken: string, options?: {
150
- isProduction?: boolean;
151
- cookieDomain?: string;
152
- }): void;
153
- /**
154
- * 리다이렉트용 HTML 생성
155
- * @param redirectPath 리다이렉트할 경로
156
- * @param text 표시할 텍스트 (필수)
157
- * @returns HTML 문자열
158
- */
159
- export declare function createRedirectHTML(redirectPath: string, text: string): string;
160
- /**
161
- * access token과 refresh token을 사용하여 완전한 인증 세션 생성
162
- * @param accessToken access token
163
- * @param secret JWT 서명에 사용할 secret key
164
- * @param options 추가 옵션
165
- * @param options.req NextRequest 객체 (필수 - URL origin을 위해 필요)
166
- * @param options.refreshToken refresh token (선택)
167
- * @param options.redirectPath 리다이렉트할 경로 (HTTP 302 리다이렉트 사용)
168
- * @param options.text 응답 메시지 텍스트 (선택사항)
169
- * @param options.cookiePrefix 쿠키 이름 접두사 (필수)
170
- * @param options.isProduction 프로덕션 환경 여부 (기본값: false)
171
- * @param options.cookieDomain 쿠키 도메인 (선택)
172
- * @param options.serviceId 서비스 ID (필수)
173
- * @param options.licenseKey 라이센스 키 (필수)
174
- * @returns NextResponse 객체 (리다이렉트 또는 JSON 응답)
175
- */
176
- export declare function createAuthResponse(accessToken: string, secret: string, options: {
177
- req: NextRequest;
178
- refreshToken?: string;
179
- redirectPath?: string;
180
- text?: string;
181
- cookiePrefix?: string;
182
- isProduction?: boolean;
183
- cookieDomain?: string;
184
- serviceId: string;
185
- licenseKey: string;
186
- }): Promise<NextResponse>;
187
- /**
188
- * 서비스 구독 유효성 확인 함수
189
- * @param services 서비스 정보 배열
190
- * @param serviceId 확인할 서비스 ID
191
- * @param ssoBaseURL SSO 서버 기본 URL (필수)
192
- * @returns 구독 유효성 결과
193
- */
194
- export declare function validateServiceSubscription(services: ServiceInfo[], serviceId: string, ssoBaseURL: string): {
195
- isValid: boolean;
196
- redirectUrl?: string;
197
- service?: ServiceInfo;
198
- };
199
- /**
200
- * SSO 서버에서 refresh token을 사용하여 새로운 access token을 발급받는 함수
201
- * @param refreshToken refresh token
202
- * @param options 옵션
203
- * @param options.ssoBaseURL SSO 서버 기본 URL (필수)
204
- * @param options.authServiceKey 인증 서비스 키 (기본값: 환경 변수)
205
- * @returns SSO refresh token 응답
206
- */
207
- export declare function refreshSSOToken(refreshToken: string, options: {
208
- ssoBaseURL: string;
209
- authServiceKey?: string;
210
- }): Promise<SSORefreshTokenResponse>;
211
- /**
212
- * SSO 서버에서 사용자의 refresh token을 가져오는 함수
213
- * @param userId 사용자 ID
214
- * @param accessToken access token
215
- * @param options 옵션
216
- * @param options.ssoBaseURL SSO 서버 기본 URL (필수)
217
- * @param options.authServiceKey 인증 서비스 키 (기본값: 환경 변수)
218
- * @returns refresh token 또는 null
219
- */
220
- export declare function getRefreshTokenFromSSO(userId: string, accessToken: string, options: {
221
- ssoBaseURL: string;
222
- authServiceKey?: string;
223
- }): Promise<string | null>;
224
- export declare function verifyAndRefreshToken(req: NextRequest, secret: string, options: {
225
- cookiePrefix: string;
226
- serviceId: string;
227
- isProduction: boolean;
228
- cookieDomain?: string;
229
- text?: string;
230
- ssoBaseURL?: string;
231
- authServiceKey?: string;
232
- licenseKey: string;
233
- forceRefresh?: boolean;
234
- }): Promise<{
235
- isValid: boolean;
236
- response?: NextResponse;
237
- payload?: JWTPayload;
238
- error?: string;
239
- }>;
240
- /**
241
- * 에러 페이지로 리다이렉트하는 헬퍼 함수
242
- * @param req NextRequest 객체
243
- * @param code 에러 코드
244
- * @param message 에러 메시지
245
- * @param errorPath 에러 페이지 경로 (기본값: '/error')
246
- * @returns NextResponse 리다이렉트 응답
247
- */
248
- export declare function redirectToError(req: NextRequest, code: string, message: string, errorPath?: string): Promise<NextResponse>;
249
- /**
250
- * 인증 쿠키를 삭제하는 헬퍼 함수
251
- * @param response NextResponse 객체
252
- * @param cookiePrefix 쿠키 이름 접두사 (필수)
253
- * @returns NextResponse 객체
254
- */
255
- export declare function clearAuthCookies(response: NextResponse, cookiePrefix: string): NextResponse;
256
- /**
257
- * JWT에서 서비스별 역할을 추출하는 헬퍼 함수
258
- * @param token NextAuth JWT 객체 또는 null
259
- * @param serviceId 서비스 ID (필수)
260
- * @returns 추출된 역할 또는 undefined
261
- */
262
- export declare function getEffectiveRole(token: JWT | null, serviceId: string): string | undefined;
263
- /**
264
- * 구독이 필요한 경로인지 확인하는 헬퍼 함수
265
- * @param pathname 경로명
266
- * @param role 사용자 역할
267
- * @param subscriptionRequiredPaths 구독이 필요한 경로 배열
268
- * @param systemAdminRole 시스템 관리자 역할 (기본값: 'SYSTEM_ADMIN')
269
- * @returns 구독이 필요한지 여부
270
- */
271
- export declare function requiresSubscription(pathname: string, role: string, subscriptionRequiredPaths: string[], systemAdminRole?: string): boolean;
272
- /**
273
- * 역할 기반 접근 제어 헬퍼 함수
274
- * @param pathname 경로명
275
- * @param role 사용자 역할
276
- * @param roleConfig 역할별 경로 설정 객체
277
- * @returns 접근 허용 여부 및 메시지
278
- */
279
- export interface RoleAccessConfig {
280
- [role: string]: {
281
- paths: string[];
282
- message: string;
283
- allowedRoles?: string[];
284
- };
285
- }
286
- /**
287
- * 미들웨어 설정 인터페이스
288
- */
289
- export interface MiddlewareConfig {
290
- /** 공개 접근 가능한 경로 배열 */
291
- publicPaths?: string[];
292
- /** 구독이 필요한 경로 배열 */
293
- subscriptionRequiredPaths?: string[];
294
- /** 구독 상태 확인을 제외할 API 경로 배열 */
295
- subscriptionExemptApiPaths?: string[];
296
- /** 인증 관련 API 경로 배열 */
297
- authApiPaths?: string[];
298
- /** 역할별 대시보드 경로 객체 */
299
- rolePaths?: Record<string, string>;
300
- /** 역할 기반 접근 제어 설정 */
301
- roleAccessConfig?: RoleAccessConfig;
302
- /** 서비스 ID */
303
- serviceId?: string;
304
- /** 시스템 관리자 역할명 (기본값: 'SYSTEM_ADMIN') */
305
- systemAdminRole?: string;
306
- /** 에러 페이지 경로 (기본값: '/error') */
307
- errorPath?: string;
308
- }
309
- /**
310
- * 미들웨어 실행 옵션
311
- */
312
- export interface MiddlewareOptions {
313
- /** NextAuth Secret (필수) */
314
- secret: string;
315
- /** 프로덕션 환경 여부 (필수) */
316
- isProduction: boolean;
317
- /** 쿠키 도메인 (선택사항) */
318
- cookieDomain?: string;
319
- /** NextAuth 토큰을 가져오는 함수 (선택사항) */
320
- getNextAuthToken?: (req: NextRequest) => Promise<JWT | null>;
321
- /** SSO 서버 기본 URL (필수) */
322
- ssoBaseURL: string;
323
- /** 인증 서비스 키 (선택사항) */
324
- authServiceKey?: string;
325
- /** 라이센스 키 (필수) */
326
- licenseKey: string;
327
- }
328
- /**
329
- * NextAuth 쿠키 설정 생성
330
- * @param options 옵션
331
- * @param options.isProduction 프로덕션 환경 여부
332
- * @param options.cookieDomain 쿠키 도메인 (선택)
333
- * @returns NextAuth 쿠키 설정 객체
334
- */
335
- export declare function createNextAuthCookies(options: {
336
- isProduction?: boolean;
337
- cookieDomain?: string;
338
- }): {
339
- sessionToken: {
340
- name: string;
341
- options: {
342
- httpOnly: boolean;
343
- sameSite: 'lax' | 'none';
344
- path: string;
345
- secure: boolean;
346
- domain?: string;
347
- };
348
- };
349
- callbackUrl: {
350
- name: string;
351
- options: {
352
- sameSite: 'lax' | 'none';
353
- path: string;
354
- secure: boolean;
355
- domain?: string;
356
- };
357
- };
358
- csrfToken: {
359
- name: string;
360
- options: {
361
- httpOnly: boolean;
362
- sameSite: 'lax' | 'none';
363
- path: string;
364
- secure: boolean;
365
- domain?: string;
366
- };
367
- };
368
- };
369
- /**
370
- * NextAuth 기본 설정 생성
371
- * @param options 옵션
372
- * @param options.secret NextAuth secret
373
- * @param options.isProduction 프로덕션 환경 여부
374
- * @param options.cookieDomain 쿠키 도메인 (선택)
375
- * @param options.signInPath 로그인 페이지 경로 (기본값: '/login')
376
- * @param options.errorPath 에러 페이지 경로 (기본값: '/login')
377
- * @param options.nextAuthUrl NextAuth URL (선택)
378
- * @param options.sessionMaxAge 세션 최대 유지 시간 (초, 기본값: 30일)
379
- * @param options.jwtMaxAge JWT 최대 유지 시간 (초, 기본값: 30일)
380
- * @returns NextAuth 기본 설정 객체
381
- */
382
- export declare function createNextAuthBaseConfig(options: {
383
- secret: string;
384
- isProduction?: boolean;
385
- cookieDomain?: string;
386
- signInPath?: string;
387
- errorPath?: string;
388
- nextAuthUrl?: string;
389
- sessionMaxAge?: number;
390
- jwtMaxAge?: number;
391
- }): {
392
- session: {
393
- strategy: 'jwt';
394
- maxAge: number;
395
- };
396
- jwt: {
397
- maxAge: number;
398
- };
399
- providers: never[];
400
- url?: string;
401
- pages: {
402
- signIn: string;
403
- error: string;
404
- };
405
- cookies: ReturnType<typeof createNextAuthCookies>;
406
- secret: string;
407
- };
408
- /**
409
- * JWT 콜백에서 초기 로그인 시 토큰 생성 헬퍼
410
- * @param token 기존 토큰
411
- * @param user 사용자 정보
412
- * @param account 계정 정보
413
- * @returns 업데이트된 JWT 토큰
414
- */
415
- export declare function createInitialJWTToken(token: JWT, user: {
416
- id: string;
417
- email?: string | null;
418
- emailHash?: string | null;
419
- maskedEmail?: string | null;
420
- phoneHash?: string | null;
421
- maskedPhone?: string | null;
422
- role?: string;
423
- phone?: string | null;
424
- decryptedEmail?: string | null;
425
- decryptedPhone?: string | null;
426
- refreshToken?: string | null;
427
- }, account?: {
428
- serviceId?: string;
429
- } | null): JWT;
430
- /**
431
- * Session 콜백에서 빈 세션 반환 헬퍼
432
- * @param session 기존 세션
433
- * @returns 빈 세션 객체
434
- */
435
- export declare function createEmptySession(session: Session): Session;
436
- /**
437
- * Session 콜백에서 토큰 정보를 세션에 매핑하는 헬퍼
438
- * @param session 기존 세션
439
- * @param token JWT 토큰
440
- * @returns 업데이트된 세션
441
- */
442
- export declare function mapTokenToSession(session: Session, token: JWT): Session;
443
- /**
444
- * JWT 콜백을 위한 통합 헬퍼 함수
445
- * 초기 로그인, 토큰 갱신, 커스텀 토큰 읽기를 모두 처리
446
- * @param token 기존 JWT 토큰
447
- * @param user 사용자 정보 (초기 로그인 시)
448
- * @param account 계정 정보 (초기 로그인 시)
449
- * @param options 옵션
450
- * @param options.secret NextAuth secret (커스텀 토큰 읽기용)
451
- * @param options.licenseKey 라이센스 키 (커스텀 토큰 읽기용)
452
- * @param options.serviceId 서비스 ID (커스텀 토큰 읽기용)
453
- * @param options.cookieName 커스텀 토큰 쿠키 이름 (기본값: '{serviceId}_access_token')
454
- * @param options.debug 디버깅 로그 출력 여부 (기본값: false)
455
- * @returns 업데이트된 JWT 토큰
456
- */
457
- export declare function handleJWTCallback(token: JWT, user?: {
458
- id: string;
459
- email?: string | null;
460
- emailHash?: string | null;
461
- maskedEmail?: string | null;
462
- phoneHash?: string | null;
463
- maskedPhone?: string | null;
464
- role?: string;
465
- phone?: string | null;
466
- decryptedEmail?: string | null;
467
- decryptedPhone?: string | null;
468
- refreshToken?: string | null;
469
- } | null, account?: {
470
- serviceId?: string;
471
- } | null, options?: {
472
- secret?: string;
473
- licenseKey?: string;
474
- serviceId?: string;
475
- cookieName?: string;
476
- debug?: boolean;
477
- ssoBaseURL?: string;
478
- authServiceKey?: string;
479
- }): Promise<JWT>;
480
- /**
481
- * 쿠키에서 커스텀 토큰을 읽어서 NextAuth JWT로 변환하는 헬퍼 함수
482
- * NextAuth JWT 콜백에서 사용
483
- * @param cookieName 쿠키 이름 (예: 'checkon_access_token')
484
- * @param secret JWT 서명에 사용할 secret key
485
- * @param serviceId 서비스 ID (필수)
486
- * @param licenseKey 라이센스 키 (필수)
487
- * @returns NextAuth JWT 객체 또는 null
488
- */
489
- export declare function getJWTFromCustomTokenCookie(cookieName: string, secret: string, serviceId: string, licenseKey: string): Promise<JWT | null>;
490
- export declare function checkLicenseKey(licenseKey: string): Promise<void>;
491
- export declare function checkRoleAccess(pathname: string, role: string, roleConfig: RoleAccessConfig): {
492
- allowed: boolean;
493
- message?: string;
494
- };
495
- /**
496
- * SSO 로그인 페이지로 리다이렉트하는 헬퍼 함수
497
- * @param req NextRequest 객체
498
- * @param serviceId 서비스 ID
499
- * @param ssoBaseURL SSO 서버 기본 URL (필수)
500
- * @returns NextResponse 리다이렉트 응답
501
- */
502
- export declare function redirectToSSOLogin(req: NextRequest, serviceId: string, ssoBaseURL: string): Promise<NextResponse>;
503
- /**
504
- * 역할별 대시보드 경로로 리다이렉트하는 헬퍼 함수
505
- * @param req NextRequest 객체
506
- * @param role 사용자 역할
507
- * @param rolePaths 역할별 경로 설정 객체
508
- * @param defaultPath 기본 경로 (기본값: '/admin')
509
- * @returns NextResponse 리다이렉트 응답
510
- */
511
- export declare function redirectToRoleDashboard(req: NextRequest, role: string, rolePaths: Record<string, string>, defaultPath?: string): Promise<NextResponse>;
512
- /**
513
- * 토큰이 만료되었는지 확인하는 함수
514
- * @param token NextAuth JWT 객체
515
- * @returns 만료 여부
516
- */
517
- export declare function isTokenExpired(token: JWT | null): boolean;
518
- /**
519
- * 토큰이 유효한지 확인하는 함수 (만료 및 필수 필드 체크)
520
- * @param token NextAuth JWT 객체
521
- * @returns 유효성 여부
522
- */
523
- export declare function isValidToken(token: JWT | null): boolean;
524
- /**
525
- * 특정 역할을 가지고 있는지 확인하는 함수
526
- * @param token NextAuth JWT 객체
527
- * @param role 확인할 역할
528
- * @param serviceId 서비스 ID (필수)
529
- * @returns 역할 보유 여부
530
- */
531
- export declare function hasRole(token: JWT | null, role: string, serviceId: string): boolean;
532
- /**
533
- * 여러 역할 중 하나라도 가지고 있는지 확인하는 함수
534
- * @param token NextAuth JWT 객체
535
- * @param roles 확인할 역할 배열
536
- * @param serviceId 서비스 ID (필수)
537
- * @returns 역할 보유 여부
538
- */
539
- export declare function hasAnyRole(token: JWT | null, roles: string[], serviceId: string): boolean;
540
- /**
541
- * 공개 경로인지 확인하는 함수
542
- * @param pathname 경로명
543
- * @param publicPaths 공개 경로 배열
544
- * @returns 공개 경로 여부
545
- */
546
- export declare function isPublicPath(pathname: string, publicPaths: string[]): boolean;
547
- /**
548
- * API 경로인지 확인하는 함수
549
- * @param pathname 경로명
550
- * @returns API 경로 여부
551
- */
552
- export declare function isApiPath(pathname: string): boolean;
553
- /**
554
- * 보호된 API 경로인지 확인하는 함수
555
- * @param pathname 경로명
556
- * @param exemptPaths 제외할 경로 배열
557
- * @returns 보호된 API 경로 여부
558
- */
559
- export declare function isProtectedApiPath(pathname: string, exemptPaths?: string[]): boolean;
560
- /**
561
- * NextAuth 토큰과 자체 토큰을 모두 확인하는 통합 인증 체크 함수
562
- * @param req NextRequest 객체
563
- * @param secret JWT 서명에 사용할 secret key
564
- * @param options 옵션
565
- * @returns 인증 결과
566
- */
567
- export declare function checkAuthentication(req: NextRequest, secret: string, options: {
568
- cookiePrefix: string;
569
- serviceId: string;
570
- isProduction: boolean;
571
- cookieDomain?: string;
572
- text?: string;
573
- ssoBaseURL?: string;
574
- authServiceKey?: string;
575
- getNextAuthToken?: (req: NextRequest) => Promise<JWT | null>;
576
- licenseKey: string;
577
- }): Promise<{
578
- isAuthenticated: boolean;
579
- token?: JWT | null;
580
- payload?: JWTPayload;
581
- response?: NextResponse;
582
- error?: string;
583
- }>;
584
- /**
585
- * NextAuth 토큰과 자체 토큰을 모두 확인하는 미들웨어용 함수
586
- * NextAuth 토큰이 있으면 바로 통과, 없으면 자체 토큰을 확인
587
- * @param req NextRequest 객체
588
- * @param nextAuthToken NextAuth JWT 토큰 (null 가능)
589
- * @param secret JWT 서명에 사용할 secret key
590
- * @param options 옵션
591
- * @returns 인증 결과
592
- */
593
- export declare function verifyAndRefreshTokenWithNextAuth(req: NextRequest, nextAuthToken: JWT | null, secret: string, options: {
594
- cookiePrefix: string;
595
- serviceId: string;
596
- isProduction: boolean;
597
- cookieDomain?: string;
598
- text?: string;
599
- ssoBaseURL?: string;
600
- authServiceKey?: string;
601
- licenseKey: string;
602
- }): Promise<{
603
- isValid: boolean;
604
- response?: NextResponse;
605
- error?: string;
606
- payload?: JWTPayload;
607
- token?: JWT;
608
- }>;
609
- /**
610
- * 기본 미들웨어 설정을 생성하는 함수
611
- * @param config 커스텀 설정 (필수: serviceId 포함)
612
- * @param defaults 기본 설정값 (선택사항, 제공하지 않으면 최소 기본값 사용)
613
- * @returns 미들웨어 설정 객체
614
- */
615
- export declare function createMiddlewareConfig(config: Partial<MiddlewareConfig> & {
616
- serviceId: string;
617
- }, defaults?: {
618
- publicPaths?: string[];
619
- subscriptionRequiredPaths?: string[];
620
- subscriptionExemptApiPaths?: string[];
621
- authApiPaths?: string[];
622
- rolePaths?: Record<string, string>;
623
- systemAdminRole?: string;
624
- errorPath?: string;
625
- }): Required<Omit<MiddlewareConfig, 'serviceId'>> & Pick<MiddlewareConfig, 'serviceId'>;
626
- /**
627
- * 통합 미들웨어 핸들러 함수
628
- * 모든 인증, 권한, 구독 체크를 포함한 완전한 미들웨어 로직
629
- * @param req NextRequest 객체
630
- * @param config 미들웨어 설정
631
- * @param options 미들웨어 실행 옵션 (secret 필수)
632
- * @returns NextResponse 또는 null (다음 미들웨어로 진행)
633
- */
634
- export declare function handleMiddleware(req: NextRequest, config: Required<Omit<MiddlewareConfig, 'serviceId'>> & Pick<MiddlewareConfig, 'serviceId'>, options: MiddlewareOptions): Promise<NextResponse | null>;
1
+ export * from './types/index';
2
+ export * from './utils/logger';
3
+ export * from './utils/crypto';
4
+ export * from './utils/server';
5
+ export * from './utils/redirect';
6
+ export * from './utils/path';
7
+ export * from './utils/license';
8
+ export * from './core/jwt';
9
+ export * from './core/cookies';
10
+ export * from './core/auth-response';
11
+ export * from './core/roles';
12
+ export * from './core/verify';
13
+ export * from './sso/api';
14
+ export * from './nextauth/config';
15
+ export * from './nextauth/callbacks';
16
+ export * from './nextauth/session';
17
+ export * from './middleware/config';
18
+ export * from './middleware/handler';