@payez/next-mvp 4.1.11 → 4.1.12

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.
Files changed (91) hide show
  1. package/dist/api-handlers/auth/refresh.js +15 -38
  2. package/dist/auth/better-auth.js +12 -33
  3. package/dist/client/better-auth-client.d.ts +14 -2
  4. package/dist/lib/ensure-fresh-access-token.js +8 -42
  5. package/dist/lib/session-store.d.ts +0 -1
  6. package/dist/lib/session-store.js +29 -33
  7. package/dist/lib/startup-init.js +19 -19
  8. package/dist/lib/token-lifecycle.d.ts +0 -2
  9. package/dist/lib/token-lifecycle.js +3 -21
  10. package/package.json +4 -3
  11. package/scripts/check-internal-url-usage.sh +73 -73
  12. package/src/api/index.ts +17 -17
  13. package/src/api-handlers/account/masked-info.ts +45 -45
  14. package/src/api-handlers/account/profile.ts +80 -80
  15. package/src/api-handlers/account/recovery/initiate.ts +23 -23
  16. package/src/api-handlers/account/recovery/send-code.ts +25 -25
  17. package/src/api-handlers/account/recovery/verify-code.ts +25 -25
  18. package/src/api-handlers/account/reset-password.ts +23 -23
  19. package/src/api-handlers/account/send-code.ts +76 -76
  20. package/src/api-handlers/account/validate-password.ts +118 -118
  21. package/src/api-handlers/admin/stats.ts +249 -249
  22. package/src/api-handlers/anon/preferences.ts +123 -123
  23. package/src/api-handlers/auth/jwks.ts +20 -20
  24. package/src/api-handlers/auth/login.ts +240 -240
  25. package/src/api-handlers/auth/refresh.ts +15 -38
  26. package/src/api-handlers/auth/validate.ts +43 -43
  27. package/src/api-handlers/session/viability.ts +142 -142
  28. package/src/auth/better-auth.ts +450 -467
  29. package/src/auth/unauthenticated-routes.ts +2 -2
  30. package/src/client/better-auth-client.ts +70 -70
  31. package/src/client/fetchWithSession.ts +21 -21
  32. package/src/client/index.ts +13 -13
  33. package/src/client/useAnonSession.ts +131 -131
  34. package/src/components/admin/VibeAdminContext.tsx +87 -87
  35. package/src/config/logging-config.ts +82 -82
  36. package/src/config/unauthenticated-routes.ts +19 -19
  37. package/src/edge/internal-api-url.ts +65 -65
  38. package/src/edge/middleware.ts +42 -42
  39. package/src/hooks/useProfile.ts +75 -75
  40. package/src/lib/anon-session.ts +213 -213
  41. package/src/lib/auth-secret.ts +137 -137
  42. package/src/lib/demo-mode.ts +17 -17
  43. package/src/lib/ensure-fresh-access-token.ts +8 -42
  44. package/src/lib/idp-client-config.ts +559 -559
  45. package/src/lib/idp-fetch.ts +126 -126
  46. package/src/lib/internal-api.ts +171 -171
  47. package/src/lib/jwt-decode-client.ts +45 -45
  48. package/src/lib/rate-limit-service.ts +9 -9
  49. package/src/lib/redis.ts +26 -26
  50. package/src/lib/refresh-token-validator.ts +64 -64
  51. package/src/lib/secret-validation.ts +8 -8
  52. package/src/lib/session-store.ts +692 -695
  53. package/src/lib/session.ts +34 -34
  54. package/src/lib/startup-init.ts +251 -251
  55. package/src/lib/token-expiry.ts +40 -40
  56. package/src/lib/token-lifecycle.ts +470 -497
  57. package/src/lib/types/api-responses.ts +336 -336
  58. package/src/middleware/auth-decision.ts +43 -43
  59. package/src/models/DecodedAccessToken.ts +16 -16
  60. package/src/models/SessionModel.ts +264 -264
  61. package/src/pages/admin-roles/index.ts +9 -9
  62. package/src/pages/security/EnhancedSecurityPage.tsx +9 -9
  63. package/src/routes/account/index.ts +31 -31
  64. package/src/routes/account/masked-info.ts +36 -36
  65. package/src/routes/account/send-code.ts +39 -39
  66. package/src/routes/account/verify-email.ts +40 -40
  67. package/src/routes/account/verify-sms.ts +40 -40
  68. package/src/routes/auth/index.ts +22 -22
  69. package/src/routes/auth/refresh.ts +48 -48
  70. package/src/routes/auth/session.ts +166 -166
  71. package/src/routes/index.ts +17 -17
  72. package/src/routes/session/index.ts +7 -7
  73. package/src/routes/session/refresh-viability.ts +17 -17
  74. package/src/server/auth.ts +373 -373
  75. package/src/server/decode-session.ts +202 -202
  76. package/src/services/signalrActivityService.ts +258 -258
  77. package/src/theme/ThemeProvider.tsx +39 -39
  78. package/src/theme/default.ts +33 -33
  79. package/src/theme/index.ts +31 -31
  80. package/src/theme/types.ts +69 -69
  81. package/src/theme/useTheme.ts +57 -57
  82. package/src/theme/utils.ts +40 -40
  83. package/src/types/api.ts +12 -12
  84. package/src/types/auth.d.ts +23 -23
  85. package/src/types/auth.ts +22 -22
  86. package/src/types/logging.ts +11 -11
  87. package/src/types/recovery.ts +54 -54
  88. package/src/utils/api.ts +353 -353
  89. package/src/utils/circuitBreaker.ts +40 -40
  90. package/src/utils/error-message.ts +108 -108
  91. package/src/utils/layout/reservedSpace.ts +124 -124
@@ -1,9 +1,9 @@
1
- /**
2
- * Admin Roles Page exports
3
- *
4
- * - RolesAdminPage: Read-only admin interface for viewing roles and permissions (/admin/roles)
5
- *
6
- * MVP scope: Role creation/editing deferred to post-MVP.
7
- */
8
-
9
- export { default as RolesAdminPage } from './RolesAdminPage';
1
+ /**
2
+ * Admin Roles Page exports
3
+ *
4
+ * - RolesAdminPage: Read-only admin interface for viewing roles and permissions (/admin/roles)
5
+ *
6
+ * MVP scope: Role creation/editing deferred to post-MVP.
7
+ */
8
+
9
+ export { default as RolesAdminPage } from './RolesAdminPage';
@@ -200,9 +200,9 @@ export default function EnhancedSecurityPage() {
200
200
  const layout = useLayout();
201
201
  const colors = useColors();
202
202
 
203
- // Re-auth action types (moved for scope)
204
- type ReAuthAction = 'enable_2fa' | 'disable_2fa' | 'export_data' | 'delete_account' | null;
205
-
203
+ // Re-auth action types (moved for scope)
204
+ type ReAuthAction = 'enable_2fa' | 'disable_2fa' | 'export_data' | 'delete_account' | null;
205
+
206
206
  // Security data state (would come from API in production)
207
207
  const [securityData, setSecurityData] = useState<SecurityData | null>(null);
208
208
  const [loadingSecurityData, setLoadingSecurityData] = useState(true);
@@ -218,12 +218,12 @@ type ReAuthAction = 'enable_2fa' | 'disable_2fa' | 'export_data' | 'delete_accou
218
218
  new_password: '',
219
219
  confirm_password: '',
220
220
  });
221
- const [showPasswords, setShowPasswords] = useState({ current: false, new: false, confirm: false });
222
-
223
- // Re-authentication modal state (Security Addendum)
224
- const [reAuthModal, setReAuthModal] = useState<{
225
- isOpen: boolean;
226
- action: ReAuthAction;
221
+ const [showPasswords, setShowPasswords] = useState({ current: false, new: false, confirm: false });
222
+
223
+ // Re-authentication modal state (Security Addendum)
224
+ const [reAuthModal, setReAuthModal] = useState<{
225
+ isOpen: boolean;
226
+ action: ReAuthAction;
227
227
  }>({ isOpen: false, action: null });
228
228
  const [submitting, setSubmitting] = useState(false);
229
229
  const [error, setError] = useState('');
@@ -1,32 +1,32 @@
1
- /**
2
- * Account Route Exports
3
- *
4
- * Provides ready-to-use route exports for all 2FA/account management endpoints.
5
- * These routes handle the complete 2FA flow with zero configuration.
6
- *
7
- * @example
8
- * ```typescript
9
- * // Import individual routes
10
- * export { POST } from '@payez/next-mvp/routes/account/masked-info';
11
- * export { POST } from '@payez/next-mvp/routes/account/send-code';
12
- * export { POST } from '@payez/next-mvp/routes/account/verify-email';
13
- * export { POST } from '@payez/next-mvp/routes/account/verify-sms';
14
- * ```
15
- *
16
- * @version 2.3.0
17
- * @since auth-ready-v2
18
- */
19
-
20
- // Export individual route modules
21
- export * as maskedInfo from './masked-info';
22
- export * as sendCode from './send-code';
23
- export * as verifyEmail from './verify-email';
24
- export * as verifySms from './verify-sms';
25
- export * as updatePhone from './update-phone';
26
-
27
- // Re-export POST handlers for convenience (all 2FA endpoints use POST)
28
- export { POST as maskedInfoPOST } from './masked-info';
29
- export { POST as sendCodePOST } from './send-code';
30
- export { POST as verifyEmailPOST } from './verify-email';
31
- export { POST as verifySmsPOST } from './verify-sms';
1
+ /**
2
+ * Account Route Exports
3
+ *
4
+ * Provides ready-to-use route exports for all 2FA/account management endpoints.
5
+ * These routes handle the complete 2FA flow with zero configuration.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * // Import individual routes
10
+ * export { POST } from '@payez/next-mvp/routes/account/masked-info';
11
+ * export { POST } from '@payez/next-mvp/routes/account/send-code';
12
+ * export { POST } from '@payez/next-mvp/routes/account/verify-email';
13
+ * export { POST } from '@payez/next-mvp/routes/account/verify-sms';
14
+ * ```
15
+ *
16
+ * @version 2.3.0
17
+ * @since auth-ready-v2
18
+ */
19
+
20
+ // Export individual route modules
21
+ export * as maskedInfo from './masked-info';
22
+ export * as sendCode from './send-code';
23
+ export * as verifyEmail from './verify-email';
24
+ export * as verifySms from './verify-sms';
25
+ export * as updatePhone from './update-phone';
26
+
27
+ // Re-export POST handlers for convenience (all 2FA endpoints use POST)
28
+ export { POST as maskedInfoPOST } from './masked-info';
29
+ export { POST as sendCodePOST } from './send-code';
30
+ export { POST as verifyEmailPOST } from './verify-email';
31
+ export { POST as verifySmsPOST } from './verify-sms';
32
32
  export { POST as updatePhonePOST } from './update-phone';
@@ -1,37 +1,37 @@
1
- /**
2
- * Ready-to-Use Masked Info Route
3
- *
4
- * Provides a pre-configured handler for fetching masked contact information
5
- * during 2FA flow. Can be imported directly into your app's API routes with
6
- * zero configuration.
7
- *
8
- * @example
9
- * ```typescript
10
- * // app/api/account/masked-info/route.ts
11
- * export { POST } from '@payez/next-mvp/routes/account/masked-info';
12
- * ```
13
- *
14
- * @version 2.3.0
15
- * @since auth-ready-v2
16
- */
17
-
18
- // Re-export the POST handler from api-handlers
19
- // Note: IDP uses POST for masked-info endpoint
20
- export { POST } from '../../api-handlers/account/masked-info';
21
-
22
- /**
23
- * Pre-configured POST handler for masked contact information
24
- *
25
- * This endpoint is typically called during the 2FA flow to display masked
26
- * email/phone options to the user.
27
- *
28
- * Environment variables used:
29
- * - IDP_URL or NEXT_PUBLIC_IDP_URL (default: http://localhost:32785)
30
- * - CLIENT_ID or NEXT_PUBLIC_IDP_CLIENT_ID (required)
31
- * - BETTER_AUTH_SECRET (required — fetched from IDP at startup)
32
- *
33
- * Returns:
34
- * - Masked email addresses
35
- * - Masked phone numbers
36
- * - Contact method preferences
1
+ /**
2
+ * Ready-to-Use Masked Info Route
3
+ *
4
+ * Provides a pre-configured handler for fetching masked contact information
5
+ * during 2FA flow. Can be imported directly into your app's API routes with
6
+ * zero configuration.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * // app/api/account/masked-info/route.ts
11
+ * export { POST } from '@payez/next-mvp/routes/account/masked-info';
12
+ * ```
13
+ *
14
+ * @version 2.3.0
15
+ * @since auth-ready-v2
16
+ */
17
+
18
+ // Re-export the POST handler from api-handlers
19
+ // Note: IDP uses POST for masked-info endpoint
20
+ export { POST } from '../../api-handlers/account/masked-info';
21
+
22
+ /**
23
+ * Pre-configured POST handler for masked contact information
24
+ *
25
+ * This endpoint is typically called during the 2FA flow to display masked
26
+ * email/phone options to the user.
27
+ *
28
+ * Environment variables used:
29
+ * - IDP_URL or NEXT_PUBLIC_IDP_URL (default: http://localhost:32785)
30
+ * - CLIENT_ID or NEXT_PUBLIC_IDP_CLIENT_ID (required)
31
+ * - BETTER_AUTH_SECRET (required — fetched from IDP at startup)
32
+ *
33
+ * Returns:
34
+ * - Masked email addresses
35
+ * - Masked phone numbers
36
+ * - Contact method preferences
37
37
  */
@@ -1,40 +1,40 @@
1
- /**
2
- * Ready-to-Use Send Code Route
3
- *
4
- * Provides a pre-configured handler for sending 2FA verification codes
5
- * to the user's registered contact methods. Can be imported directly
6
- * into your app's API routes with zero configuration.
7
- *
8
- * @example
9
- * ```typescript
10
- * // app/api/account/send-code/route.ts
11
- * export { POST } from '@payez/next-mvp/routes/account/send-code';
12
- * ```
13
- *
14
- * @version 2.3.0
15
- * @since auth-ready-v2
16
- */
17
-
18
- // Re-export the POST handler from api-handlers
19
- export { POST } from '../../api-handlers/account/send-code';
20
-
21
- /**
22
- * Pre-configured POST handler for sending verification codes
23
- *
24
- * This endpoint triggers the IDP to send a verification code to the
25
- * user's selected contact method (email or SMS).
26
- *
27
- * Request body:
28
- * - method: 'email' | 'sms' - The contact method to use
29
- * - contactId: string - ID of the masked contact to send to
30
- *
31
- * Environment variables used:
32
- * - IDP_URL or NEXT_PUBLIC_IDP_URL (default: http://localhost:32785)
33
- * - CLIENT_ID or NEXT_PUBLIC_IDP_CLIENT_ID (required)
34
- * - BETTER_AUTH_SECRET (required — fetched from IDP at startup)
35
- *
36
- * Returns:
37
- * - Success status
38
- * - Rate limit information
39
- * - Cooldown timer if applicable
1
+ /**
2
+ * Ready-to-Use Send Code Route
3
+ *
4
+ * Provides a pre-configured handler for sending 2FA verification codes
5
+ * to the user's registered contact methods. Can be imported directly
6
+ * into your app's API routes with zero configuration.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * // app/api/account/send-code/route.ts
11
+ * export { POST } from '@payez/next-mvp/routes/account/send-code';
12
+ * ```
13
+ *
14
+ * @version 2.3.0
15
+ * @since auth-ready-v2
16
+ */
17
+
18
+ // Re-export the POST handler from api-handlers
19
+ export { POST } from '../../api-handlers/account/send-code';
20
+
21
+ /**
22
+ * Pre-configured POST handler for sending verification codes
23
+ *
24
+ * This endpoint triggers the IDP to send a verification code to the
25
+ * user's selected contact method (email or SMS).
26
+ *
27
+ * Request body:
28
+ * - method: 'email' | 'sms' - The contact method to use
29
+ * - contactId: string - ID of the masked contact to send to
30
+ *
31
+ * Environment variables used:
32
+ * - IDP_URL or NEXT_PUBLIC_IDP_URL (default: http://localhost:32785)
33
+ * - CLIENT_ID or NEXT_PUBLIC_IDP_CLIENT_ID (required)
34
+ * - BETTER_AUTH_SECRET (required — fetched from IDP at startup)
35
+ *
36
+ * Returns:
37
+ * - Success status
38
+ * - Rate limit information
39
+ * - Cooldown timer if applicable
40
40
  */
@@ -1,41 +1,41 @@
1
- /**
2
- * Ready-to-Use Verify Email Route
3
- *
4
- * Provides a pre-configured handler for verifying email-based 2FA codes.
5
- * Can be imported directly into your app's API routes with zero configuration.
6
- *
7
- * @example
8
- * ```typescript
9
- * // app/api/account/verify-email/route.ts
10
- * export { POST } from '@payez/next-mvp/routes/account/verify-email';
11
- * ```
12
- *
13
- * @version 2.3.0
14
- * @since auth-ready-v2
15
- */
16
-
17
- // Re-export the POST handler from api-handlers
18
- export { POST } from '../../api-handlers/account/verify-email';
19
-
20
- /**
21
- * Pre-configured POST handler for verifying email 2FA codes
22
- *
23
- * This endpoint verifies the code sent to the user's email address
24
- * and upgrades the provisional session to a full session.
25
- *
26
- * Request body:
27
- * - code: string - The 6-digit verification code
28
- * - emailId: string - ID of the email address used
29
- *
30
- * Environment variables used:
31
- * - IDP_URL or NEXT_PUBLIC_IDP_URL (default: http://localhost:32785)
32
- * - CLIENT_ID or NEXT_PUBLIC_IDP_CLIENT_ID (required)
33
- * - BETTER_AUTH_SECRET (required — fetched from IDP at startup)
34
- *
35
- * Returns:
36
- * - Upgraded access token with MFA claim
37
- * - New refresh token
38
- * - Session upgrade status
39
- * - AMR (Authentication Methods Reference) array
40
- * - ACR (Authentication Context Class) level
1
+ /**
2
+ * Ready-to-Use Verify Email Route
3
+ *
4
+ * Provides a pre-configured handler for verifying email-based 2FA codes.
5
+ * Can be imported directly into your app's API routes with zero configuration.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * // app/api/account/verify-email/route.ts
10
+ * export { POST } from '@payez/next-mvp/routes/account/verify-email';
11
+ * ```
12
+ *
13
+ * @version 2.3.0
14
+ * @since auth-ready-v2
15
+ */
16
+
17
+ // Re-export the POST handler from api-handlers
18
+ export { POST } from '../../api-handlers/account/verify-email';
19
+
20
+ /**
21
+ * Pre-configured POST handler for verifying email 2FA codes
22
+ *
23
+ * This endpoint verifies the code sent to the user's email address
24
+ * and upgrades the provisional session to a full session.
25
+ *
26
+ * Request body:
27
+ * - code: string - The 6-digit verification code
28
+ * - emailId: string - ID of the email address used
29
+ *
30
+ * Environment variables used:
31
+ * - IDP_URL or NEXT_PUBLIC_IDP_URL (default: http://localhost:32785)
32
+ * - CLIENT_ID or NEXT_PUBLIC_IDP_CLIENT_ID (required)
33
+ * - BETTER_AUTH_SECRET (required — fetched from IDP at startup)
34
+ *
35
+ * Returns:
36
+ * - Upgraded access token with MFA claim
37
+ * - New refresh token
38
+ * - Session upgrade status
39
+ * - AMR (Authentication Methods Reference) array
40
+ * - ACR (Authentication Context Class) level
41
41
  */
@@ -1,41 +1,41 @@
1
- /**
2
- * Ready-to-Use Verify SMS Route
3
- *
4
- * Provides a pre-configured handler for verifying SMS-based 2FA codes.
5
- * Can be imported directly into your app's API routes with zero configuration.
6
- *
7
- * @example
8
- * ```typescript
9
- * // app/api/account/verify-sms/route.ts
10
- * export { POST } from '@payez/next-mvp/routes/account/verify-sms';
11
- * ```
12
- *
13
- * @version 2.3.0
14
- * @since auth-ready-v2
15
- */
16
-
17
- // Re-export the POST handler from api-handlers
18
- export { POST } from '../../api-handlers/account/verify-sms';
19
-
20
- /**
21
- * Pre-configured POST handler for verifying SMS 2FA codes
22
- *
23
- * This endpoint verifies the code sent to the user's phone number
24
- * and upgrades the provisional session to a full session.
25
- *
26
- * Request body:
27
- * - code: string - The 6-digit verification code
28
- * - phoneId: string - ID of the phone number used
29
- *
30
- * Environment variables used:
31
- * - IDP_URL or NEXT_PUBLIC_IDP_URL (default: http://localhost:32785)
32
- * - CLIENT_ID or NEXT_PUBLIC_IDP_CLIENT_ID (required)
33
- * - BETTER_AUTH_SECRET (required — fetched from IDP at startup)
34
- *
35
- * Returns:
36
- * - Upgraded access token with MFA claim
37
- * - New refresh token
38
- * - Session upgrade status
39
- * - AMR (Authentication Methods Reference) array
40
- * - ACR (Authentication Context Class) level
1
+ /**
2
+ * Ready-to-Use Verify SMS Route
3
+ *
4
+ * Provides a pre-configured handler for verifying SMS-based 2FA codes.
5
+ * Can be imported directly into your app's API routes with zero configuration.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * // app/api/account/verify-sms/route.ts
10
+ * export { POST } from '@payez/next-mvp/routes/account/verify-sms';
11
+ * ```
12
+ *
13
+ * @version 2.3.0
14
+ * @since auth-ready-v2
15
+ */
16
+
17
+ // Re-export the POST handler from api-handlers
18
+ export { POST } from '../../api-handlers/account/verify-sms';
19
+
20
+ /**
21
+ * Pre-configured POST handler for verifying SMS 2FA codes
22
+ *
23
+ * This endpoint verifies the code sent to the user's phone number
24
+ * and upgrades the provisional session to a full session.
25
+ *
26
+ * Request body:
27
+ * - code: string - The 6-digit verification code
28
+ * - phoneId: string - ID of the phone number used
29
+ *
30
+ * Environment variables used:
31
+ * - IDP_URL or NEXT_PUBLIC_IDP_URL (default: http://localhost:32785)
32
+ * - CLIENT_ID or NEXT_PUBLIC_IDP_CLIENT_ID (required)
33
+ * - BETTER_AUTH_SECRET (required — fetched from IDP at startup)
34
+ *
35
+ * Returns:
36
+ * - Upgraded access token with MFA claim
37
+ * - New refresh token
38
+ * - Session upgrade status
39
+ * - AMR (Authentication Methods Reference) array
40
+ * - ACR (Authentication Context Class) level
41
41
  */
@@ -1,23 +1,23 @@
1
- /**
2
- * @payez/next-mvp Ready-to-Use Route Exports
3
- *
4
- * Pre-configured route handlers that can be imported directly
5
- * into your Next.js app with zero configuration.
6
- *
7
- * @version 2.0.0
8
- * @since auth-ready-v2
9
- */
10
-
11
- // Export individual route handlers
12
- export { POST as refreshPOST } from './refresh';
13
- export { GET as sessionGET, POST as sessionPOST } from './session';
14
- export { POST as logoutPOST } from './logout';
15
- export { GET as viabilityGET } from './viability';
16
- export { GET as nextAuthGET, POST as nextAuthPOST } from './nextauth';
17
-
18
- // Also export as namespaced objects for cleaner imports
19
- export * as refresh from './refresh';
20
- export * as session from './session';
21
- export * as logout from './logout';
22
- export * as viability from './viability';
1
+ /**
2
+ * @payez/next-mvp Ready-to-Use Route Exports
3
+ *
4
+ * Pre-configured route handlers that can be imported directly
5
+ * into your Next.js app with zero configuration.
6
+ *
7
+ * @version 2.0.0
8
+ * @since auth-ready-v2
9
+ */
10
+
11
+ // Export individual route handlers
12
+ export { POST as refreshPOST } from './refresh';
13
+ export { GET as sessionGET, POST as sessionPOST } from './session';
14
+ export { POST as logoutPOST } from './logout';
15
+ export { GET as viabilityGET } from './viability';
16
+ export { GET as nextAuthGET, POST as nextAuthPOST } from './nextauth';
17
+
18
+ // Also export as namespaced objects for cleaner imports
19
+ export * as refresh from './refresh';
20
+ export * as session from './session';
21
+ export * as logout from './logout';
22
+ export * as viability from './viability';
23
23
  export * as nextauth from './nextauth';
@@ -1,49 +1,49 @@
1
- /**
2
- * Ready-to-Use Refresh Token Route
3
- *
4
- * Provides a pre-configured refresh handler that can be imported directly
5
- * into your app's API routes with zero configuration.
6
- *
7
- * @example
8
- * ```typescript
9
- * // app/api/auth/refresh/route.ts
10
- * export { POST } from '@payez/next-mvp/routes/auth/refresh';
11
- * ```
12
- *
13
- * @version 2.0.0
14
- * @since auth-ready-v2
15
- */
16
-
17
- import { createRefreshHandler } from '../../api-handlers/auth/refresh';
18
-
19
- // Configuration is read at runtime from environment.
20
- function getConfig() {
21
- const idpBaseUrl = process.env.IDP_URL;
22
- if (!idpBaseUrl) {
23
- throw new Error('[IDP_URL] FATAL: IDP_URL environment variable is REQUIRED.');
24
- }
25
- return {
26
- idpBaseUrl,
27
- clientId: process.env.CLIENT_ID || process.env.NEXT_PUBLIC_IDP_CLIENT_ID || '',
28
- refreshEndpoint: process.env.REFRESH_ENDPOINT || '/api/ExternalAuth/refresh',
29
- };
30
- }
31
-
32
- /**
33
- * Pre-configured POST handler for token refresh
34
- *
35
- * Environment variables used:
36
- * - IDP_URL (REQUIRED)
37
- * - CLIENT_ID or NEXT_PUBLIC_IDP_CLIENT_ID (required)
38
- * - REFRESH_ENDPOINT (default: /api/ExternalAuth/refresh)
39
- */
40
- let _handler: ReturnType<typeof createRefreshHandler> | null = null;
41
-
42
- import { NextRequest } from 'next/server';
43
-
44
- export async function POST(req: NextRequest) {
45
- if (!_handler) {
46
- _handler = createRefreshHandler(getConfig());
47
- }
48
- return _handler(req);
1
+ /**
2
+ * Ready-to-Use Refresh Token Route
3
+ *
4
+ * Provides a pre-configured refresh handler that can be imported directly
5
+ * into your app's API routes with zero configuration.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * // app/api/auth/refresh/route.ts
10
+ * export { POST } from '@payez/next-mvp/routes/auth/refresh';
11
+ * ```
12
+ *
13
+ * @version 2.0.0
14
+ * @since auth-ready-v2
15
+ */
16
+
17
+ import { createRefreshHandler } from '../../api-handlers/auth/refresh';
18
+
19
+ // Configuration is read at runtime from environment.
20
+ function getConfig() {
21
+ const idpBaseUrl = process.env.IDP_URL;
22
+ if (!idpBaseUrl) {
23
+ throw new Error('[IDP_URL] FATAL: IDP_URL environment variable is REQUIRED.');
24
+ }
25
+ return {
26
+ idpBaseUrl,
27
+ clientId: process.env.CLIENT_ID || process.env.NEXT_PUBLIC_IDP_CLIENT_ID || '',
28
+ refreshEndpoint: process.env.REFRESH_ENDPOINT || '/api/ExternalAuth/refresh',
29
+ };
30
+ }
31
+
32
+ /**
33
+ * Pre-configured POST handler for token refresh
34
+ *
35
+ * Environment variables used:
36
+ * - IDP_URL (REQUIRED)
37
+ * - CLIENT_ID or NEXT_PUBLIC_IDP_CLIENT_ID (required)
38
+ * - REFRESH_ENDPOINT (default: /api/ExternalAuth/refresh)
39
+ */
40
+ let _handler: ReturnType<typeof createRefreshHandler> | null = null;
41
+
42
+ import { NextRequest } from 'next/server';
43
+
44
+ export async function POST(req: NextRequest) {
45
+ if (!_handler) {
46
+ _handler = createRefreshHandler(getConfig());
47
+ }
48
+ return _handler(req);
49
49
  }