@payez/next-mvp 3.9.1 → 4.0.0
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/api/auth-handler.d.ts +1 -2
- package/dist/api/auth-handler.js +9 -9
- package/dist/api-handlers/account/change-password.js +110 -112
- package/dist/api-handlers/admin/analytics.d.ts +19 -20
- package/dist/api-handlers/admin/analytics.js +378 -379
- package/dist/api-handlers/admin/audit.d.ts +19 -20
- package/dist/api-handlers/admin/audit.js +213 -214
- package/dist/api-handlers/admin/index.d.ts +21 -22
- package/dist/api-handlers/admin/index.js +42 -43
- package/dist/api-handlers/admin/redis-sessions.d.ts +35 -36
- package/dist/api-handlers/admin/redis-sessions.js +203 -204
- package/dist/api-handlers/admin/sessions.d.ts +20 -21
- package/dist/api-handlers/admin/sessions.js +283 -284
- package/dist/api-handlers/admin/site-logs.d.ts +45 -46
- package/dist/api-handlers/admin/site-logs.js +317 -318
- package/dist/api-handlers/admin/stats.d.ts +20 -21
- package/dist/api-handlers/admin/stats.js +239 -240
- package/dist/api-handlers/admin/users.d.ts +19 -20
- package/dist/api-handlers/admin/users.js +221 -222
- package/dist/api-handlers/admin/vibe-data.d.ts +79 -80
- package/dist/api-handlers/admin/vibe-data.js +267 -268
- package/dist/api-handlers/auth/refresh.js +633 -635
- package/dist/api-handlers/auth/signout.js +186 -187
- package/dist/api-handlers/auth/status.js +4 -7
- package/dist/api-handlers/auth/update-session.d.ts +1 -1
- package/dist/api-handlers/auth/update-session.js +12 -14
- package/dist/api-handlers/auth/verify-code.d.ts +43 -43
- package/dist/api-handlers/auth/verify-code.js +90 -94
- package/dist/api-handlers/session/viability.js +114 -146
- package/dist/api-handlers/test/force-expire.js +59 -65
- package/dist/auth/auth-decision.js +182 -182
- package/dist/auth/better-auth.d.ts +3 -6
- package/dist/auth/better-auth.js +3 -6
- package/dist/auth/route-config.js +2 -2
- package/dist/auth/utils/token-utils.d.ts +83 -84
- package/dist/auth/utils/token-utils.js +218 -219
- package/dist/client/AuthContext.js +115 -112
- package/dist/client/better-auth-client.d.ts +1020 -1020
- package/dist/client/fetch-with-auth.js +2 -2
- package/dist/components/SessionSync.js +121 -119
- package/dist/components/account/MobileNavDrawer.js +64 -64
- package/dist/components/account/UserAvatarMenu.js +91 -88
- package/dist/components/admin/VibeAdminLayout.js +71 -69
- package/dist/hooks/useAuth.js +9 -7
- package/dist/hooks/useAuthSettings.js +93 -93
- package/dist/hooks/useAvailableProviders.d.ts +43 -45
- package/dist/hooks/useAvailableProviders.js +112 -108
- package/dist/hooks/useSessionExpiration.d.ts +2 -3
- package/dist/hooks/useSessionExpiration.js +2 -2
- package/dist/hooks/useViabilitySession.js +3 -2
- package/dist/index.js +4 -6
- package/dist/lib/app-slug.d.ts +95 -95
- package/dist/lib/app-slug.js +172 -172
- package/dist/lib/standardized-client-api.js +10 -5
- package/dist/lib/startup-init.js +21 -25
- package/dist/lib/test-aware-get-token.js +86 -81
- package/dist/lib/token-lifecycle.d.ts +78 -52
- package/dist/lib/token-lifecycle.js +360 -398
- package/dist/pages/admin-login/page.js +73 -83
- package/dist/pages/client-admin/ClientSiteAdminPage.js +179 -177
- package/dist/pages/login/page.js +202 -211
- package/dist/pages/showcase/ShowcasePage.js +142 -140
- package/dist/pages/test-env/EmergencyLogoutPage.js +99 -98
- package/dist/pages/test-env/JwtInspectPage.js +116 -114
- package/dist/pages/test-env/RefreshTokenPage.js +4 -2
- package/dist/pages/test-env/TestEnvPage.js +51 -49
- package/dist/pages/verify-code/page.js +412 -408
- package/dist/routes/auth/logout.d.ts +31 -31
- package/dist/routes/auth/logout.js +98 -113
- package/dist/routes/auth/nextauth.d.ts +14 -11
- package/dist/routes/auth/nextauth.js +25 -57
- package/dist/routes/auth/session.js +157 -179
- package/dist/routes/auth/viability.js +190 -201
- package/dist/server/auth.d.ts +50 -0
- package/dist/server/auth.js +62 -0
- package/dist/stores/authStore.js +19 -23
- package/dist/utils/logout.js +5 -5
- package/package.json +1 -3
- package/src/api/auth-handler.ts +550 -549
- package/src/api-handlers/account/change-password.ts +5 -8
- package/src/api-handlers/admin/analytics.ts +4 -6
- package/src/api-handlers/admin/audit.ts +5 -7
- package/src/api-handlers/admin/index.ts +1 -2
- package/src/api-handlers/admin/redis-sessions.ts +6 -8
- package/src/api-handlers/admin/sessions.ts +5 -7
- package/src/api-handlers/admin/site-logs.ts +8 -10
- package/src/api-handlers/admin/stats.ts +4 -6
- package/src/api-handlers/admin/users.ts +5 -7
- package/src/api-handlers/admin/vibe-data.ts +10 -12
- package/src/api-handlers/auth/refresh.ts +5 -7
- package/src/api-handlers/auth/signout.ts +5 -6
- package/src/api-handlers/auth/status.ts +4 -7
- package/src/api-handlers/auth/update-session.ts +123 -125
- package/src/api-handlers/auth/verify-code.ts +9 -13
- package/src/api-handlers/session/viability.ts +10 -47
- package/src/api-handlers/test/force-expire.ts +4 -11
- package/src/auth/auth-decision.ts +1 -1
- package/src/auth/better-auth.ts +138 -141
- package/src/auth/route-config.ts +219 -219
- package/src/auth/utils/token-utils.ts +0 -1
- package/src/client/AuthContext.tsx +6 -2
- package/src/client/fetch-with-auth.ts +47 -47
- package/src/components/SessionSync.tsx +6 -5
- package/src/components/account/MobileNavDrawer.tsx +3 -3
- package/src/components/account/UserAvatarMenu.tsx +6 -3
- package/src/components/admin/VibeAdminLayout.tsx +4 -2
- package/src/config/logger.ts +1 -1
- package/src/hooks/useAuth.ts +117 -115
- package/src/hooks/useAuthSettings.ts +2 -2
- package/src/hooks/useAvailableProviders.ts +9 -5
- package/src/hooks/useSessionExpiration.ts +101 -102
- package/src/hooks/useViabilitySession.ts +336 -335
- package/src/index.ts +60 -63
- package/src/lib/api-handler.ts +0 -1
- package/src/lib/app-slug.ts +6 -6
- package/src/lib/standardized-client-api.ts +901 -895
- package/src/lib/startup-init.ts +243 -247
- package/src/lib/test-aware-get-token.ts +22 -12
- package/src/lib/token-lifecycle.ts +12 -53
- package/src/pages/admin-login/page.tsx +9 -17
- package/src/pages/client-admin/ClientSiteAdminPage.tsx +4 -2
- package/src/pages/login/page.tsx +21 -28
- package/src/pages/showcase/ShowcasePage.tsx +4 -2
- package/src/pages/test-env/EmergencyLogoutPage.tsx +7 -6
- package/src/pages/test-env/JwtInspectPage.tsx +5 -3
- package/src/pages/test-env/RefreshTokenPage.tsx +157 -155
- package/src/pages/test-env/TestEnvPage.tsx +4 -2
- package/src/pages/verify-code/page.tsx +10 -6
- package/src/routes/auth/logout.ts +7 -25
- package/src/routes/auth/nextauth.ts +45 -71
- package/src/routes/auth/session.ts +25 -50
- package/src/routes/auth/viability.ts +7 -19
- package/src/server/auth.ts +60 -0
- package/src/stores/authStore.ts +1899 -1904
- package/src/utils/logout.ts +30 -30
- package/src/auth/auth-options.ts +0 -237
- package/src/auth/callbacks/index.ts +0 -7
- package/src/auth/callbacks/jwt.ts +0 -382
- package/src/auth/callbacks/session.ts +0 -243
- package/src/auth/callbacks/signin.ts +0 -56
- package/src/auth/events/index.ts +0 -5
- package/src/auth/events/signout.ts +0 -33
- package/src/auth/providers/credentials.ts +0 -256
- package/src/auth/providers/index.ts +0 -6
- package/src/auth/providers/oauth.ts +0 -114
- package/src/lib/nextauth-secret.ts +0 -121
- package/src/types/next-auth.d.ts +0 -15
|
@@ -1,112 +1,115 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
'use client';
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.AuthProvider = AuthProvider;
|
|
5
|
-
exports.useAuthConfig = useAuthConfig;
|
|
6
|
-
exports.useAuthMode = useAuthMode;
|
|
7
|
-
exports.useFederatedProviders = useFederatedProviders;
|
|
8
|
-
exports.useFederatedAuthEnabled = useFederatedAuthEnabled;
|
|
9
|
-
exports.useTraditionalAuthEnabled = useTraditionalAuthEnabled;
|
|
10
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
11
|
-
const react_1 = require("react");
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
'
|
|
25
|
-
'
|
|
26
|
-
'
|
|
27
|
-
'
|
|
28
|
-
'
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const [
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.AuthProvider = AuthProvider;
|
|
5
|
+
exports.useAuthConfig = useAuthConfig;
|
|
6
|
+
exports.useAuthMode = useAuthMode;
|
|
7
|
+
exports.useFederatedProviders = useFederatedProviders;
|
|
8
|
+
exports.useFederatedAuthEnabled = useFederatedAuthEnabled;
|
|
9
|
+
exports.useTraditionalAuthEnabled = useTraditionalAuthEnabled;
|
|
10
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
11
|
+
const react_1 = require("react");
|
|
12
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
13
|
+
const AuthContext = (0, react_1.createContext)(null);
|
|
14
|
+
const defaultConfig = {
|
|
15
|
+
mode: 'traditional',
|
|
16
|
+
providers: [],
|
|
17
|
+
enableRecovery: true,
|
|
18
|
+
enableEmailSignup: true,
|
|
19
|
+
allowPasswordReset: true,
|
|
20
|
+
};
|
|
21
|
+
// Map NextAuth provider IDs to our FederatedProvider type
|
|
22
|
+
const PROVIDER_MAP = {
|
|
23
|
+
'google': 'google',
|
|
24
|
+
'apple': 'apple',
|
|
25
|
+
'facebook': 'facebook',
|
|
26
|
+
'github': 'github',
|
|
27
|
+
'azure-ad': 'microsoft',
|
|
28
|
+
'microsoft-entra-id': 'microsoft',
|
|
29
|
+
};
|
|
30
|
+
// OAuth providers we support in UI (excludes credentials)
|
|
31
|
+
const OAUTH_PROVIDER_IDS = ['google', 'apple', 'facebook', 'github', 'azure-ad', 'microsoft-entra-id'];
|
|
32
|
+
function AuthProvider({ children, config, useDynamicProviders = true }) {
|
|
33
|
+
const [dynamicProviders, setDynamicProviders] = (0, react_1.useState)([]);
|
|
34
|
+
const [providersLoaded, setProvidersLoaded] = (0, react_1.useState)(!useDynamicProviders);
|
|
35
|
+
// Create QueryClient instance for React Query - used internally by MVP hooks
|
|
36
|
+
const [queryClient] = (0, react_1.useState)(() => new react_query_1.QueryClient({
|
|
37
|
+
defaultOptions: {
|
|
38
|
+
queries: {
|
|
39
|
+
staleTime: 60 * 1000, // 1 minute
|
|
40
|
+
retry: 1,
|
|
41
|
+
refetchOnWindowFocus: false,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
}));
|
|
45
|
+
// Fetch dynamic providers from NextAuth on mount
|
|
46
|
+
(0, react_1.useEffect)(() => {
|
|
47
|
+
if (!useDynamicProviders)
|
|
48
|
+
return;
|
|
49
|
+
let mounted = true;
|
|
50
|
+
async function fetchDynamicProviders() {
|
|
51
|
+
try {
|
|
52
|
+
// Better Auth doesn't have a getProviders equivalent.
|
|
53
|
+
// Use static provider map based on configured social providers.
|
|
54
|
+
const result = {
|
|
55
|
+
google: { id: 'google', name: 'Google' },
|
|
56
|
+
};
|
|
57
|
+
if (!mounted)
|
|
58
|
+
return;
|
|
59
|
+
if (result) {
|
|
60
|
+
// Filter to OAuth providers only and map to FederatedProvider type
|
|
61
|
+
const oauthProviders = Object.keys(result)
|
|
62
|
+
.filter(id => OAUTH_PROVIDER_IDS.includes(id))
|
|
63
|
+
.map(id => PROVIDER_MAP[id])
|
|
64
|
+
.filter((p) => p !== undefined);
|
|
65
|
+
setDynamicProviders(oauthProviders);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
// Fall back to static config providers on error
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
if (mounted) {
|
|
73
|
+
setProvidersLoaded(true);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
fetchDynamicProviders();
|
|
78
|
+
return () => {
|
|
79
|
+
mounted = false;
|
|
80
|
+
};
|
|
81
|
+
}, [useDynamicProviders]);
|
|
82
|
+
// Determine final providers list
|
|
83
|
+
const providers = useDynamicProviders && providersLoaded
|
|
84
|
+
? dynamicProviders
|
|
85
|
+
: (config?.providers ?? defaultConfig.providers);
|
|
86
|
+
const authConfig = {
|
|
87
|
+
...defaultConfig,
|
|
88
|
+
...config,
|
|
89
|
+
providers, // Override with dynamic providers if enabled
|
|
90
|
+
};
|
|
91
|
+
return ((0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: (0, jsx_runtime_1.jsx)(AuthContext.Provider, { value: authConfig, children: children }) }));
|
|
92
|
+
}
|
|
93
|
+
function useAuthConfig() {
|
|
94
|
+
const context = (0, react_1.useContext)(AuthContext);
|
|
95
|
+
if (!context) {
|
|
96
|
+
return defaultConfig;
|
|
97
|
+
}
|
|
98
|
+
return context;
|
|
99
|
+
}
|
|
100
|
+
function useAuthMode() {
|
|
101
|
+
const config = useAuthConfig();
|
|
102
|
+
return config.mode;
|
|
103
|
+
}
|
|
104
|
+
function useFederatedProviders() {
|
|
105
|
+
const config = useAuthConfig();
|
|
106
|
+
return config.providers;
|
|
107
|
+
}
|
|
108
|
+
function useFederatedAuthEnabled() {
|
|
109
|
+
const config = useAuthConfig();
|
|
110
|
+
return config.mode === 'federated' && config.providers.length > 0;
|
|
111
|
+
}
|
|
112
|
+
function useTraditionalAuthEnabled() {
|
|
113
|
+
const config = useAuthConfig();
|
|
114
|
+
return config.mode === 'traditional';
|
|
115
|
+
}
|