@xk2800/nextjs-template 0.7.2-beta.0 → 0.7.2-beta.10
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/README.md +1 -0
- package/components/auth/{loginErrorRecovery.tsx → forms/login-error-recovery.tsx} +1 -1
- package/components/auth/{emailPasswordLogin.tsx → forms/login-form.tsx} +8 -8
- package/components/auth/{emailPasswordSignup.tsx → forms/signup-form.tsx} +11 -8
- package/components/auth/{authCard.tsx → layout/auth-card.tsx} +5 -5
- package/components/auth/{authShell.tsx → layout/auth-shell.tsx} +17 -5
- package/components/auth/{oneTap.tsx → methods/one-tap.tsx} +2 -2
- package/components/auth/{passkeyLogin.tsx → methods/passkey-login.tsx} +2 -2
- package/components/auth/{socialLogin.tsx → methods/social-login.tsx} +3 -3
- package/components/auth/{twoFactorVerifyForm.tsx → mfa/two-factor-verify-form.tsx} +5 -5
- package/components/auth/{forgotPasswordForm.tsx → recovery/forgot-password-form.tsx} +4 -4
- package/components/auth/{resetPasswordForm.tsx → recovery/reset-password-form.tsx} +4 -4
- package/components/auth/{deviceCheck.tsx → session/device-check.tsx} +3 -3
- package/components/auth/{logoutButtons.tsx → session/logout-buttons.tsx} +2 -2
- package/components/dashboard/admin/{activityLogsSection.tsx → activity-logs/activity-logs-section.tsx} +1 -1
- package/components/dashboard/admin/activity-logs/admin-activity-logs-table.tsx +375 -0
- package/components/dashboard/admin/activity-logs/audit-severity-badge.tsx +50 -0
- package/components/dashboard/admin/activity-logs/security-highlights-collapsible.tsx +129 -0
- package/components/dashboard/admin/{adminActivityLogsSkeleton.tsx → activity-logs/skeletons/activity-logs-skeleton.tsx} +2 -2
- package/components/dashboard/admin/{adminStatsGrid.tsx → home/admin-stats-grid.tsx} +1 -1
- package/components/dashboard/admin/{deviceThrottleCard.tsx → home/device-throttle-card.tsx} +8 -5
- package/components/dashboard/admin/{deviceThrottleTable.tsx → home/device-throttle-table.tsx} +3 -3
- package/components/dashboard/admin/{newDeviceCard.tsx → home/new-device-card.tsx} +6 -2
- package/components/dashboard/admin/{newDeviceTable.tsx → home/new-device-table.tsx} +4 -4
- package/components/dashboard/admin/{sharedDeviceCard.tsx → home/shared-device-card.tsx} +3 -3
- package/components/dashboard/admin/{sharedDeviceTable.tsx → home/shared-device-table.tsx} +3 -3
- package/components/dashboard/admin/{adminStatsGridSkeleton.tsx → home/skeletons/admin-stats-skeleton.tsx} +2 -2
- package/components/dashboard/admin/{broadcastActions.tsx → marketing/broadcast-actions.tsx} +3 -3
- package/components/dashboard/admin/{confirmSendDialog.tsx → marketing/confirm-send-dialog.tsx} +1 -1
- package/components/dashboard/admin/{marketingEmailForm.tsx → marketing/marketing-email-form.tsx} +7 -7
- package/components/dashboard/admin/{marketingSection.tsx → marketing/marketing-section.tsx} +6 -6
- package/components/dashboard/admin/{subscribersCard.tsx → marketing/subscribers-card.tsx} +3 -3
- package/components/dashboard/admin/{feedbackTestForm.tsx → system-settings/feedback-test-form.tsx} +4 -4
- package/components/dashboard/admin/{systemSettingsSkeleton.tsx → system-settings/skeletons/system-settings-skeleton.tsx} +2 -2
- package/components/dashboard/admin/system-settings/system-settings-form.tsx +362 -0
- package/components/dashboard/admin/{systemSettingsSection.tsx → system-settings/system-settings-section.tsx} +3 -2
- package/components/dashboard/admin/users/admin-user-actions.tsx +238 -0
- package/components/dashboard/admin/users/admin-user-profile-card.tsx +70 -0
- package/components/dashboard/admin/users/admin-user-security-card.tsx +47 -0
- package/components/dashboard/admin/users/admin-user-status-card.tsx +89 -0
- package/components/dashboard/admin/{adminUsersTable.tsx → users/admin-users-table.tsx} +129 -132
- package/components/dashboard/admin/{adminUserActivityLogCard.tsx → users/detail/admin-user-activity-log-card.tsx} +3 -3
- package/components/dashboard/admin/{adminUserActivityLogTable.tsx → users/detail/admin-user-activity-log-table.tsx} +3 -3
- package/components/dashboard/admin/{adminUserConsentCard.tsx → users/detail/admin-user-consent-card.tsx} +4 -4
- package/components/dashboard/admin/{adminUserDevicesCard.tsx → users/detail/admin-user-devices-card.tsx} +2 -2
- package/components/dashboard/admin/{adminUserLoginInfoCard.tsx → users/detail/admin-user-login-info-card.tsx} +3 -3
- package/components/dashboard/admin/{adminUserLoginInfoTable.tsx → users/detail/admin-user-login-info-table.tsx} +3 -3
- package/components/dashboard/admin/{adminUserSessionsCard.tsx → users/detail/admin-user-sessions-card.tsx} +5 -5
- package/components/dashboard/admin/{impersonationLogCard.tsx → users/impersonation-log-card.tsx} +10 -5
- package/components/dashboard/admin/users/impersonation-tab.tsx +255 -0
- package/components/dashboard/admin/users/invite-user-dialog.tsx +80 -0
- package/components/dashboard/admin/{revokeAllSessionsButton.tsx → users/revoke-all-sessions.tsx} +5 -3
- package/components/dashboard/admin/{adminUsersSkeleton.tsx → users/skeletons/admin-users-skeleton.tsx} +2 -2
- package/components/dashboard/admin/{usersSection.tsx → users/users-section.tsx} +1 -1
- package/components/dashboard/{errorFeedback.tsx → common/error-feedback.tsx} +1 -1
- package/components/dashboard/{feedbackDialog.tsx → common/feedback-dialog.tsx} +4 -4
- package/components/dashboard/{sectionErrorFallback.tsx → common/section-error-fallback.tsx} +1 -1
- package/components/dashboard/{verifyEmailButton.tsx → common/verify-email-button.tsx} +2 -2
- package/components/dashboard/{appSidebar.tsx → layout/app-sidebar.tsx} +11 -8
- package/components/dashboard/{dashboardHeader.tsx → layout/dashboard-header.tsx} +1 -1
- package/components/dashboard/{impersonationBanner.tsx → layout/impersonation-banner.tsx} +2 -2
- package/components/dashboard/layout/mobile-nav.tsx +95 -0
- package/components/dashboard/{navStyleToggle.tsx → layout/nav-style-toggle.tsx} +1 -1
- package/components/dashboard/{topNav.tsx → layout/top-nav.tsx} +19 -38
- package/components/dashboard/{installAppCard.tsx → overview/install-app-card.tsx} +2 -2
- package/components/dashboard/{accountDetailsCard.tsx → settings/account-details-card.tsx} +5 -5
- package/components/dashboard/{activityLogsCard.tsx → settings/activity-logs-card.tsx} +6 -6
- package/components/dashboard/{activityLogsSection.tsx → settings/activity-logs-section.tsx} +1 -1
- package/components/dashboard/{adminSection.tsx → settings/admin-section.tsx} +2 -2
- package/components/dashboard/{deleteAccountCard.tsx → settings/delete-account-card.tsx} +7 -7
- package/components/dashboard/{marketingUpdatesCard.tsx → settings/marketing-updates-card.tsx} +3 -3
- package/components/dashboard/{marketingUpdatesSection.tsx → settings/marketing-updates-section.tsx} +1 -1
- package/components/dashboard/{passkeysCard.tsx → settings/passkeys-card.tsx} +8 -8
- package/components/dashboard/{profileCard.tsx → settings/profile-card.tsx} +4 -4
- package/components/dashboard/{sessionsCard.tsx → settings/sessions/sessions-card.tsx} +6 -6
- package/components/dashboard/{sessionsSection.tsx → settings/sessions/sessions-section.tsx} +1 -1
- package/components/dashboard/{sessionsCardSkeleton.tsx → settings/sessions/skeletons/sessions-card-skeleton.tsx} +2 -2
- package/components/dashboard/{activityLogsCardSkeleton.tsx → settings/skeletons/activity-logs-card-skeleton.tsx} +2 -2
- package/components/dashboard/{twoFactorCard.tsx → settings/two-factor-card.tsx} +8 -8
- package/components/email/team/workspace-invite.tsx +51 -0
- package/components/email/{send-email-button.tsx → ui/send-email-button.tsx} +1 -1
- package/components/error-boundary.tsx +32 -0
- package/components/settings/appearance/appearance-section.tsx +64 -0
- package/components/settings/index.ts +5 -0
- package/components/settings/notifications/notifications-section.tsx +31 -0
- package/components/settings/profile/profile-section.tsx +38 -0
- package/components/settings/security/security-section.tsx +24 -0
- package/components/settings/settings-nav.tsx +35 -0
- package/components/site/{cookie-banner.tsx → compliance/cookie-banner.tsx} +6 -6
- package/components/site/push/push-notifications-card.tsx +117 -0
- package/components/ui/collapsible.tsx +9 -0
- package/components/ui/column-picker.tsx +1 -1
- package/components/ui/data-table.tsx +1 -1
- package/components/ui/dialog.tsx +46 -13
- package/components/ui/drawer.tsx +88 -0
- package/components/ui/tabs.tsx +52 -0
- package/dist/activity/logger.d.mts +2 -1
- package/dist/activity/logger.d.ts +2 -1
- package/dist/activity/logger.js +66 -16
- package/dist/activity/logger.js.map +1 -1
- package/dist/activity/logger.mjs +4 -4
- package/dist/activity/queries.d.mts +32 -21
- package/dist/activity/queries.d.ts +32 -21
- package/dist/activity/queries.js +86 -23
- package/dist/activity/queries.js.map +1 -1
- package/dist/activity/queries.mjs +27 -14
- package/dist/activity/queries.mjs.map +1 -1
- package/dist/admin/queries.d.mts +2 -1
- package/dist/admin/queries.d.ts +2 -1
- package/dist/admin/queries.js +48 -18
- package/dist/admin/queries.js.map +1 -1
- package/dist/admin/queries.mjs +9 -9
- package/dist/admin/queries.mjs.map +1 -1
- package/dist/api/feedback.js +284 -249
- package/dist/api/feedback.js.map +1 -1
- package/dist/api/feedback.mjs +14 -12
- package/dist/api/feedback.mjs.map +1 -1
- package/dist/api/marketing.js +302 -267
- package/dist/api/marketing.js.map +1 -1
- package/dist/api/marketing.mjs +16 -25
- package/dist/api/marketing.mjs.map +1 -1
- package/dist/auth/helpers.d.mts +63 -21
- package/dist/auth/helpers.d.ts +63 -21
- package/dist/auth/helpers.js +314 -268
- package/dist/auth/helpers.js.map +1 -1
- package/dist/auth/helpers.mjs +9 -9
- package/dist/auth/index.d.mts +86 -47
- package/dist/auth/index.d.ts +86 -47
- package/dist/auth/index.js +278 -245
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/index.mjs +8 -8
- package/dist/auth-client/index.d.mts +1214 -2526
- package/dist/auth-client/index.d.ts +1214 -2526
- package/dist/auth-client/index.js +37 -3
- package/dist/auth-client/index.js.map +1 -1
- package/dist/auth-client/index.mjs +19 -3
- package/dist/auth-client/index.mjs.map +1 -1
- package/dist/{chunk-KA2KMGPY.mjs → chunk-3BH6BVBQ.mjs} +17 -8
- package/dist/chunk-3BH6BVBQ.mjs.map +1 -0
- package/dist/chunk-D56ENLSX.mjs +6 -0
- package/dist/chunk-D56ENLSX.mjs.map +1 -0
- package/dist/{chunk-HUEDEAY3.mjs → chunk-DCPVEZS7.mjs} +14 -4
- package/dist/chunk-DCPVEZS7.mjs.map +1 -0
- package/dist/{chunk-NQELV53D.mjs → chunk-DWLMCMXF.mjs} +4 -4
- package/dist/chunk-DWLMCMXF.mjs.map +1 -0
- package/dist/{chunk-YH53UPUW.mjs → chunk-EXMUANQ3.mjs} +4 -4
- package/dist/chunk-EXMUANQ3.mjs.map +1 -0
- package/dist/{chunk-VHNGYAIG.mjs → chunk-IH6CMZIN.mjs} +213 -220
- package/dist/chunk-IH6CMZIN.mjs.map +1 -0
- package/dist/chunk-LADVCLEQ.mjs +43 -0
- package/dist/chunk-LADVCLEQ.mjs.map +1 -0
- package/dist/{chunk-A6JXMHOQ.mjs → chunk-NJBRKKLK.mjs} +46 -7
- package/dist/chunk-NJBRKKLK.mjs.map +1 -0
- package/dist/{chunk-6OAHCEDJ.mjs → chunk-QDUPSU5O.mjs} +5 -5
- package/dist/chunk-QDUPSU5O.mjs.map +1 -0
- package/dist/{chunk-JUSU6UZA.mjs → chunk-S23GC776.mjs} +41 -29
- package/dist/chunk-S23GC776.mjs.map +1 -0
- package/dist/{chunk-L242CZ64.mjs → chunk-TIR7KHXL.mjs} +3 -3
- package/dist/chunk-TIR7KHXL.mjs.map +1 -0
- package/dist/{chunk-4F6KE47S.mjs → chunk-ZOQHHFYA.mjs} +7 -4
- package/dist/chunk-ZOQHHFYA.mjs.map +1 -0
- package/dist/config/env.d.mts +3 -0
- package/dist/config/env.d.ts +3 -0
- package/dist/config/env.js +12 -2
- package/dist/config/env.js.map +1 -1
- package/dist/config/env.mjs +1 -1
- package/dist/db/index.d.mts +3 -7
- package/dist/db/index.d.ts +3 -7
- package/dist/db/index.js +61 -13
- package/dist/db/index.js.map +1 -1
- package/dist/db/index.mjs +3 -3
- package/dist/db/schema.d.mts +1 -1
- package/dist/db/schema.d.ts +1 -1
- package/dist/db/schema.js +14 -5
- package/dist/db/schema.js.map +1 -1
- package/dist/db/schema.mjs +1 -1
- package/dist/errors.d.mts +2 -1
- package/dist/errors.d.ts +2 -1
- package/dist/errors.js +62 -14
- package/dist/errors.js.map +1 -1
- package/dist/errors.mjs +4 -4
- package/dist/marketing/index.d.mts +4 -3
- package/dist/marketing/index.d.ts +4 -3
- package/dist/marketing/index.js +14 -4
- package/dist/marketing/index.js.map +1 -1
- package/dist/marketing/index.mjs +3 -3
- package/dist/{email-template-passkey-change-F5Q2SXHD.mjs → passkey-changed-KEGNTIPE.mjs} +2 -2
- package/dist/passkey-changed-KEGNTIPE.mjs.map +1 -0
- package/dist/{email-template-reset-password-QTCQNXOD.mjs → reset-password-64VQEXBW.mjs} +2 -2
- package/dist/reset-password-64VQEXBW.mjs.map +1 -0
- package/dist/{schema-DzC5zdOq.d.mts → schema-BujGgvAy.d.mts} +35 -2
- package/dist/{schema-DzC5zdOq.d.ts → schema-BujGgvAy.d.ts} +35 -2
- package/dist/sessions/queries.js +61 -13
- package/dist/sessions/queries.js.map +1 -1
- package/dist/sessions/queries.mjs +3 -3
- package/dist/sessions/queries.mjs.map +1 -1
- package/dist/settings/queries.d.mts +11 -2
- package/dist/settings/queries.d.ts +11 -2
- package/dist/settings/queries.js +84 -14
- package/dist/settings/queries.js.map +1 -1
- package/dist/settings/queries.mjs +4 -4
- package/dist/users/queries.d.mts +41 -21
- package/dist/users/queries.d.ts +41 -21
- package/dist/users/queries.js +117 -24
- package/dist/users/queries.js.map +1 -1
- package/dist/users/queries.mjs +57 -17
- package/dist/users/queries.mjs.map +1 -1
- package/dist/{email-template-verify-email-WZDCCAKK.mjs → verify-email-4KMNGDKN.mjs} +2 -2
- package/dist/verify-email-4KMNGDKN.mjs.map +1 -0
- package/lib/{auth-client.ts → auth/client.ts} +22 -2
- package/lib/{maintenance.ts → config/maintenance.ts} +0 -1
- package/lib/push/client.ts +39 -0
- package/lib/security/activity-severity.ts +57 -0
- package/lib/{request-info.ts → utils/request-info.ts} +7 -3
- package/package.json +177 -75
- package/scripts/check-deps.mjs +68 -0
- package/components/dashboard/admin/adminActivityLogsTable.tsx +0 -323
- package/components/dashboard/admin/adminUserStatusCard.tsx +0 -57
- package/components/dashboard/admin/systemSettingsForm.tsx +0 -289
- package/dist/chunk-4C7JHGT5.mjs +0 -30
- package/dist/chunk-4C7JHGT5.mjs.map +0 -1
- package/dist/chunk-4F6KE47S.mjs.map +0 -1
- package/dist/chunk-6OAHCEDJ.mjs.map +0 -1
- package/dist/chunk-A6JXMHOQ.mjs.map +0 -1
- package/dist/chunk-HUEDEAY3.mjs.map +0 -1
- package/dist/chunk-JUSU6UZA.mjs.map +0 -1
- package/dist/chunk-KA2KMGPY.mjs.map +0 -1
- package/dist/chunk-L242CZ64.mjs.map +0 -1
- package/dist/chunk-NQELV53D.mjs.map +0 -1
- package/dist/chunk-VHNGYAIG.mjs.map +0 -1
- package/dist/chunk-YH53UPUW.mjs.map +0 -1
- package/dist/email-template-passkey-change-F5Q2SXHD.mjs.map +0 -1
- package/dist/email-template-reset-password-QTCQNXOD.mjs.map +0 -1
- package/dist/email-template-verify-email-WZDCCAKK.mjs.map +0 -1
- /package/components/dashboard/{heartbeat.tsx → common/heartbeat.tsx} +0 -0
- /package/components/email/{email-template-reset-password.tsx → auth/reset-password.tsx} +0 -0
- /package/components/email/{email-template-verify-email.tsx → auth/verify-email.tsx} +0 -0
- /package/components/email/{email-template-welcome.tsx → auth/welcome.tsx} +0 -0
- /package/components/email/{email-template.tsx → layout/base-layout.tsx} +0 -0
- /package/components/email/{email-template-2.tsx → marketing/general-announcement.tsx} +0 -0
- /package/components/email/{email-template-banned.tsx → security/account-banned.tsx} +0 -0
- /package/components/email/{email-template-new-device.tsx → security/new-device-alert.tsx} +0 -0
- /package/components/email/{email-template-passkey-change.tsx → security/passkey-changed.tsx} +0 -0
- /package/lib/{cookie-consent.ts → security/cookie-consent.ts} +0 -0
- /package/lib/{cookie-names.ts → security/cookie-names.ts} +0 -0
- /package/lib/{device-fingerprint.ts → security/device-fingerprint.ts} +0 -0
- /package/lib/{formatters.ts → utils/formatters.ts} +0 -0
- /package/lib/{recalculate-columns.ts → utils/recalculate-columns.ts} +0 -0
|
@@ -4,6 +4,26 @@ import { passkeyClient } from "@better-auth/passkey/client"
|
|
|
4
4
|
|
|
5
5
|
const oneTapEnabled = process.env.NEXT_PUBLIC_AUTH_ENABLE_ONE_TAP === "true"
|
|
6
6
|
|
|
7
|
+
// better-auth's One Tap plugin calls navigator.credentials.preventSilentAccess() after
|
|
8
|
+
// sign-out without handling the promise. It rejects wherever the browser can't reach
|
|
9
|
+
// its credential service (headless/automated browsers, some privacy setups), surfacing
|
|
10
|
+
// as an unhandled rejection. Same hook, with the rejection swallowed.
|
|
11
|
+
function withSafeFedCMSignOut<T extends ReturnType<typeof oneTapClient>>(plugin: T): T {
|
|
12
|
+
plugin.fetchPlugins = plugin.fetchPlugins?.map((p) =>
|
|
13
|
+
p.id !== "fedcm-signout-handle" ? p : {
|
|
14
|
+
...p,
|
|
15
|
+
hooks: {
|
|
16
|
+
async onResponse(ctx) {
|
|
17
|
+
if (!ctx.request.url.toString().includes("/sign-out")) return
|
|
18
|
+
if (!("IdentityCredential" in window)) return
|
|
19
|
+
await navigator.credentials.preventSilentAccess().catch(() => {})
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
)
|
|
24
|
+
return plugin
|
|
25
|
+
}
|
|
26
|
+
|
|
7
27
|
export const authClient = createAuthClient({
|
|
8
28
|
baseURL: typeof window !== "undefined" ? window.location.origin : undefined,
|
|
9
29
|
|
|
@@ -12,7 +32,7 @@ export const authClient = createAuthClient({
|
|
|
12
32
|
twoFactorClient(),
|
|
13
33
|
passkeyClient(),
|
|
14
34
|
...(oneTapEnabled ? [
|
|
15
|
-
oneTapClient({
|
|
35
|
+
withSafeFedCMSignOut(oneTapClient({
|
|
16
36
|
clientId: process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID || "",
|
|
17
37
|
// Optional client configuration:
|
|
18
38
|
autoSelect: false,
|
|
@@ -26,7 +46,7 @@ export const authClient = createAuthClient({
|
|
|
26
46
|
baseDelay: 1000, // Base delay in ms (default: 1000)
|
|
27
47
|
maxAttempts: 5 // Maximum number of attempts before triggering onPromptNotification (default: 5)
|
|
28
48
|
}
|
|
29
|
-
})
|
|
49
|
+
}))
|
|
30
50
|
] : []),
|
|
31
51
|
]
|
|
32
52
|
})
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Browser side of the push example. Server side: lib/push.ts.
|
|
2
|
+
// The public key is passed in from a server component (read at runtime), so it
|
|
3
|
+
// doesn't have to be present at build time.
|
|
4
|
+
// Set when the user turns notifications on here, so a subscription the browser
|
|
5
|
+
// dropped can be recreated silently without overriding a deliberate "off".
|
|
6
|
+
export const PUSH_FLAG = 'push-enabled'
|
|
7
|
+
|
|
8
|
+
export const pushSupported = () =>
|
|
9
|
+
'serviceWorker' in navigator && 'PushManager' in window && 'Notification' in window
|
|
10
|
+
|
|
11
|
+
// The worker is only registered in production builds (app/layout.tsx).
|
|
12
|
+
export const getRegistration = () => navigator.serviceWorker.getRegistration('/sw.js')
|
|
13
|
+
|
|
14
|
+
function keyBytes(base64Url: string) {
|
|
15
|
+
const b64 = (base64Url + '='.repeat((4 - (base64Url.length % 4)) % 4)).replace(/-/g, '+').replace(/_/g, '/')
|
|
16
|
+
return Uint8Array.from(atob(b64), (c) => c.charCodeAt(0))
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const subscribe = (reg: ServiceWorkerRegistration, publicKey: string) =>
|
|
20
|
+
reg.pushManager.subscribe({ userVisibleOnly: true, applicationServerKey: keyBytes(publicKey) })
|
|
21
|
+
|
|
22
|
+
export const saveSubscription = (sub: PushSubscription) =>
|
|
23
|
+
fetch('/api/push', {
|
|
24
|
+
method: 'POST',
|
|
25
|
+
headers: { 'Content-Type': 'application/json' },
|
|
26
|
+
body: JSON.stringify(sub),
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
// Run on every dashboard open. Push services expire subscriptions on devices
|
|
30
|
+
// that stay unused for a while, and the server deletes them on 404/410, so
|
|
31
|
+
// without this a user who comes back after days would never get pushes again.
|
|
32
|
+
export async function syncPush(publicKey: string) {
|
|
33
|
+
if (!publicKey || !pushSupported() || Notification.permission !== 'granted') return
|
|
34
|
+
const reg = await getRegistration()
|
|
35
|
+
if (!reg) return
|
|
36
|
+
let sub = await reg.pushManager.getSubscription()
|
|
37
|
+
if (!sub && localStorage.getItem(PUSH_FLAG)) sub = await subscribe(reg, publicKey)
|
|
38
|
+
if (sub) await saveSubscription(sub)
|
|
39
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Pure mapping (safe for client + server) from an activity action to the
|
|
2
|
+
// severity and category the audit log UI shows and filters by. New actions
|
|
3
|
+
// default to info / system until classified here.
|
|
4
|
+
export type ActivitySeverity = 'info' | 'warning' | 'critical' | 'security'
|
|
5
|
+
export type ActivityCategory = 'auth' | 'users' | 'system'
|
|
6
|
+
|
|
7
|
+
const SEVERITY: Record<string, ActivitySeverity> = {
|
|
8
|
+
login_failed: 'warning',
|
|
9
|
+
session_revoked: 'warning',
|
|
10
|
+
passkey_removed: 'warning',
|
|
11
|
+
user_deleted: 'critical',
|
|
12
|
+
user_banned: 'critical',
|
|
13
|
+
role_changed: 'security',
|
|
14
|
+
impersonation_started: 'security',
|
|
15
|
+
impersonation_stopped: 'security',
|
|
16
|
+
settings_changed: 'security',
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const CATEGORY: Record<string, ActivityCategory> = {
|
|
20
|
+
login: 'auth',
|
|
21
|
+
logout: 'auth',
|
|
22
|
+
login_failed: 'auth',
|
|
23
|
+
password_changed: 'auth',
|
|
24
|
+
email_changed: 'auth',
|
|
25
|
+
session_revoked: 'auth',
|
|
26
|
+
passkey_added: 'auth',
|
|
27
|
+
passkey_removed: 'auth',
|
|
28
|
+
profile_updated: 'users',
|
|
29
|
+
user_deleted: 'users',
|
|
30
|
+
user_banned: 'users',
|
|
31
|
+
user_unbanned: 'users',
|
|
32
|
+
role_changed: 'users',
|
|
33
|
+
impersonation_started: 'users',
|
|
34
|
+
impersonation_stopped: 'users',
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const severityOf = (action: string): ActivitySeverity => SEVERITY[action] ?? 'info'
|
|
38
|
+
export const categoryOf = (action: string): ActivityCategory => CATEGORY[action] ?? 'system'
|
|
39
|
+
|
|
40
|
+
export const SEVERITY_LABELS: Record<ActivitySeverity, string> = {
|
|
41
|
+
info: 'Info', warning: 'Warning', critical: 'Critical', security: 'Security',
|
|
42
|
+
}
|
|
43
|
+
export const CATEGORY_LABELS: Record<ActivityCategory, string> = {
|
|
44
|
+
auth: 'Authentication', users: 'User management', system: 'System',
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** All known actions matching the filters, or undefined when neither filter is set. */
|
|
48
|
+
export function actionsFor(
|
|
49
|
+
allActions: readonly string[],
|
|
50
|
+
category?: string | null,
|
|
51
|
+
severity?: string | null,
|
|
52
|
+
): string[] | undefined {
|
|
53
|
+
if (!category && !severity) return undefined
|
|
54
|
+
return allActions.filter(
|
|
55
|
+
(a) => (!category || categoryOf(a) === category) && (!severity || severityOf(a) === severity),
|
|
56
|
+
)
|
|
57
|
+
}
|
|
@@ -18,12 +18,16 @@ export interface GeoInfo {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
22
|
-
* is
|
|
21
|
+
* Proxies append the address they saw to X-Forwarded-For, so the LAST entry
|
|
22
|
+
* is the one our own proxy added; earlier entries are caller-supplied and
|
|
23
|
+
* spoofable (they'd let an attacker dodge or frame an IP in the throttle).
|
|
24
|
+
* Falls back to x-real-ip, then null (local dev with no proxy).
|
|
25
|
+
* shortcut: assumes exactly one trusted proxy hop, so behind a CDN plus a
|
|
26
|
+
* proxy the last entry is the CDN's address; revisit if you stack proxies.
|
|
23
27
|
*/
|
|
24
28
|
export function getClientIp(headers: Headers | undefined | null): string | null {
|
|
25
29
|
const forwardedFor = headers?.get("x-forwarded-for")
|
|
26
|
-
if (forwardedFor) return forwardedFor.split(",")
|
|
30
|
+
if (forwardedFor) return forwardedFor.split(",").at(-1)!.trim()
|
|
27
31
|
|
|
28
32
|
return headers?.get("x-real-ip") ?? null
|
|
29
33
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xk2800/nextjs-template",
|
|
3
|
-
"version": "0.7.2-beta.
|
|
3
|
+
"version": "0.7.2-beta.10",
|
|
4
4
|
"private": false,
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -44,24 +44,31 @@
|
|
|
44
44
|
"components/providers",
|
|
45
45
|
"components/email",
|
|
46
46
|
"components/dashboard",
|
|
47
|
-
"components/
|
|
47
|
+
"components/settings",
|
|
48
|
+
"components/error-boundary.tsx",
|
|
49
|
+
"components/site/compliance/cookie-banner.tsx",
|
|
50
|
+
"components/site/push/push-notifications-card.tsx",
|
|
48
51
|
"lib/utils.ts",
|
|
49
|
-
"lib/auth
|
|
50
|
-
"lib/formatters.ts",
|
|
51
|
-
"lib/recalculate-columns.ts",
|
|
52
|
-
"lib/maintenance.ts",
|
|
53
|
-
"lib/cookie-names.ts",
|
|
54
|
-
"lib/
|
|
55
|
-
"lib/
|
|
56
|
-
"lib/
|
|
52
|
+
"lib/auth/client.ts",
|
|
53
|
+
"lib/utils/formatters.ts",
|
|
54
|
+
"lib/utils/recalculate-columns.ts",
|
|
55
|
+
"lib/config/maintenance.ts",
|
|
56
|
+
"lib/security/cookie-names.ts",
|
|
57
|
+
"lib/security/activity-severity.ts",
|
|
58
|
+
"lib/security/cookie-consent.ts",
|
|
59
|
+
"lib/security/device-fingerprint.ts",
|
|
60
|
+
"lib/utils/request-info.ts",
|
|
61
|
+
"lib/push/client.ts",
|
|
57
62
|
"hooks/use-dimensions.ts",
|
|
58
63
|
"hooks/use-mobile.ts",
|
|
59
64
|
"types/auth",
|
|
60
65
|
"styles/theme.css",
|
|
61
|
-
"README.md"
|
|
66
|
+
"README.md",
|
|
67
|
+
"scripts/check-deps.mjs"
|
|
62
68
|
],
|
|
63
69
|
"exports": {
|
|
64
70
|
"./package.json": "./package.json",
|
|
71
|
+
"./check-deps": "./scripts/check-deps.mjs",
|
|
65
72
|
"./auth": {
|
|
66
73
|
"types": "./dist/auth/index.d.ts",
|
|
67
74
|
"import": "./dist/auth/index.mjs",
|
|
@@ -153,16 +160,107 @@
|
|
|
153
160
|
"require": "./dist/api/marketing.js"
|
|
154
161
|
},
|
|
155
162
|
"./lib/utils": "./lib/utils.ts",
|
|
156
|
-
"./lib/formatters": "./lib/formatters.ts",
|
|
157
|
-
"./lib/recalculate-columns": "./lib/recalculate-columns.ts",
|
|
158
|
-
"./lib/maintenance": "./lib/maintenance.ts",
|
|
159
|
-
"./lib/cookie-consent": "./lib/cookie-consent.ts",
|
|
160
|
-
"./lib/cookie-names": "./lib/cookie-names.ts",
|
|
161
|
-
"./lib/device-fingerprint": "./lib/device-fingerprint.ts",
|
|
162
|
-
"./lib/request-info": "./lib/request-info.ts",
|
|
163
|
+
"./lib/formatters": "./lib/utils/formatters.ts",
|
|
164
|
+
"./lib/recalculate-columns": "./lib/utils/recalculate-columns.ts",
|
|
165
|
+
"./lib/maintenance": "./lib/config/maintenance.ts",
|
|
166
|
+
"./lib/cookie-consent": "./lib/security/cookie-consent.ts",
|
|
167
|
+
"./lib/cookie-names": "./lib/security/cookie-names.ts",
|
|
168
|
+
"./lib/device-fingerprint": "./lib/security/device-fingerprint.ts",
|
|
169
|
+
"./lib/request-info": "./lib/utils/request-info.ts",
|
|
170
|
+
"./lib/push-client": "./lib/push/client.ts",
|
|
163
171
|
"./hooks/use-dimensions": "./hooks/use-dimensions.ts",
|
|
164
172
|
"./hooks/use-mobile": "./hooks/use-mobile.ts",
|
|
165
173
|
"./styles/theme.css": "./styles/theme.css",
|
|
174
|
+
"./components/dashboard/accountDetailsCard": "./components/dashboard/settings/account-details-card.tsx",
|
|
175
|
+
"./components/dashboard/activityLogsCard": "./components/dashboard/settings/activity-logs-card.tsx",
|
|
176
|
+
"./components/dashboard/activityLogsCardSkeleton": "./components/dashboard/settings/skeletons/activity-logs-card-skeleton.tsx",
|
|
177
|
+
"./components/dashboard/activityLogsSection": "./components/dashboard/settings/activity-logs-section.tsx",
|
|
178
|
+
"./components/dashboard/adminSection": "./components/dashboard/settings/admin-section.tsx",
|
|
179
|
+
"./components/dashboard/appSidebar": "./components/dashboard/layout/app-sidebar.tsx",
|
|
180
|
+
"./components/dashboard/dashboardHeader": "./components/dashboard/layout/dashboard-header.tsx",
|
|
181
|
+
"./components/dashboard/deleteAccountCard": "./components/dashboard/settings/delete-account-card.tsx",
|
|
182
|
+
"./components/dashboard/errorFeedback": "./components/dashboard/common/error-feedback.tsx",
|
|
183
|
+
"./components/dashboard/feedbackDialog": "./components/dashboard/common/feedback-dialog.tsx",
|
|
184
|
+
"./components/dashboard/heartbeat": "./components/dashboard/common/heartbeat.tsx",
|
|
185
|
+
"./components/dashboard/impersonationBanner": "./components/dashboard/layout/impersonation-banner.tsx",
|
|
186
|
+
"./components/dashboard/installAppCard": "./components/dashboard/overview/install-app-card.tsx",
|
|
187
|
+
"./components/dashboard/marketingUpdatesCard": "./components/dashboard/settings/marketing-updates-card.tsx",
|
|
188
|
+
"./components/dashboard/marketingUpdatesSection": "./components/dashboard/settings/marketing-updates-section.tsx",
|
|
189
|
+
"./components/dashboard/mobileNav": "./components/dashboard/layout/mobile-nav.tsx",
|
|
190
|
+
"./components/dashboard/navStyleToggle": "./components/dashboard/layout/nav-style-toggle.tsx",
|
|
191
|
+
"./components/dashboard/passkeysCard": "./components/dashboard/settings/passkeys-card.tsx",
|
|
192
|
+
"./components/dashboard/profileCard": "./components/dashboard/settings/profile-card.tsx",
|
|
193
|
+
"./components/dashboard/sectionErrorFallback": "./components/dashboard/common/section-error-fallback.tsx",
|
|
194
|
+
"./components/dashboard/sessionsCard": "./components/dashboard/settings/sessions/sessions-card.tsx",
|
|
195
|
+
"./components/dashboard/sessionsCardSkeleton": "./components/dashboard/settings/sessions/skeletons/sessions-card-skeleton.tsx",
|
|
196
|
+
"./components/dashboard/sessionsSection": "./components/dashboard/settings/sessions/sessions-section.tsx",
|
|
197
|
+
"./components/dashboard/topNav": "./components/dashboard/layout/top-nav.tsx",
|
|
198
|
+
"./components/dashboard/twoFactorCard": "./components/dashboard/settings/two-factor-card.tsx",
|
|
199
|
+
"./components/dashboard/verifyEmailButton": "./components/dashboard/common/verify-email-button.tsx",
|
|
200
|
+
"./components/dashboard/admin/activityLogsSection": "./components/dashboard/admin/activity-logs/activity-logs-section.tsx",
|
|
201
|
+
"./components/dashboard/admin/adminActivityLogsSkeleton": "./components/dashboard/admin/activity-logs/skeletons/activity-logs-skeleton.tsx",
|
|
202
|
+
"./components/dashboard/admin/adminActivityLogsTable": "./components/dashboard/admin/activity-logs/admin-activity-logs-table.tsx",
|
|
203
|
+
"./components/dashboard/admin/adminStatsGrid": "./components/dashboard/admin/home/admin-stats-grid.tsx",
|
|
204
|
+
"./components/dashboard/admin/adminStatsGridSkeleton": "./components/dashboard/admin/home/skeletons/admin-stats-skeleton.tsx",
|
|
205
|
+
"./components/dashboard/admin/adminUserActions": "./components/dashboard/admin/users/admin-user-actions.tsx",
|
|
206
|
+
"./components/dashboard/admin/adminUserActivityLogCard": "./components/dashboard/admin/users/detail/admin-user-activity-log-card.tsx",
|
|
207
|
+
"./components/dashboard/admin/adminUserActivityLogTable": "./components/dashboard/admin/users/detail/admin-user-activity-log-table.tsx",
|
|
208
|
+
"./components/dashboard/admin/adminUserConsentCard": "./components/dashboard/admin/users/detail/admin-user-consent-card.tsx",
|
|
209
|
+
"./components/dashboard/admin/adminUserDevicesCard": "./components/dashboard/admin/users/detail/admin-user-devices-card.tsx",
|
|
210
|
+
"./components/dashboard/admin/adminUserLoginInfoCard": "./components/dashboard/admin/users/detail/admin-user-login-info-card.tsx",
|
|
211
|
+
"./components/dashboard/admin/adminUserLoginInfoTable": "./components/dashboard/admin/users/detail/admin-user-login-info-table.tsx",
|
|
212
|
+
"./components/dashboard/admin/adminUserProfileCard": "./components/dashboard/admin/users/admin-user-profile-card.tsx",
|
|
213
|
+
"./components/dashboard/admin/adminUserSecurityCard": "./components/dashboard/admin/users/admin-user-security-card.tsx",
|
|
214
|
+
"./components/dashboard/admin/adminUserSessionsCard": "./components/dashboard/admin/users/detail/admin-user-sessions-card.tsx",
|
|
215
|
+
"./components/dashboard/admin/adminUserStatusCard": "./components/dashboard/admin/users/admin-user-status-card.tsx",
|
|
216
|
+
"./components/dashboard/admin/adminUsersSkeleton": "./components/dashboard/admin/users/skeletons/admin-users-skeleton.tsx",
|
|
217
|
+
"./components/dashboard/admin/adminUsersTable": "./components/dashboard/admin/users/admin-users-table.tsx",
|
|
218
|
+
"./components/dashboard/admin/auditSeverityBadge": "./components/dashboard/admin/activity-logs/audit-severity-badge.tsx",
|
|
219
|
+
"./components/dashboard/admin/broadcastActions": "./components/dashboard/admin/marketing/broadcast-actions.tsx",
|
|
220
|
+
"./components/dashboard/admin/confirmSendDialog": "./components/dashboard/admin/marketing/confirm-send-dialog.tsx",
|
|
221
|
+
"./components/dashboard/admin/deviceThrottleCard": "./components/dashboard/admin/home/device-throttle-card.tsx",
|
|
222
|
+
"./components/dashboard/admin/deviceThrottleTable": "./components/dashboard/admin/home/device-throttle-table.tsx",
|
|
223
|
+
"./components/dashboard/admin/feedbackTestForm": "./components/dashboard/admin/system-settings/feedback-test-form.tsx",
|
|
224
|
+
"./components/dashboard/admin/impersonationLogCard": "./components/dashboard/admin/users/impersonation-log-card.tsx",
|
|
225
|
+
"./components/dashboard/admin/impersonationTab": "./components/dashboard/admin/users/impersonation-tab.tsx",
|
|
226
|
+
"./components/dashboard/admin/inviteUserDialog": "./components/dashboard/admin/users/invite-user-dialog.tsx",
|
|
227
|
+
"./components/dashboard/admin/marketingEmailForm": "./components/dashboard/admin/marketing/marketing-email-form.tsx",
|
|
228
|
+
"./components/dashboard/admin/marketingSection": "./components/dashboard/admin/marketing/marketing-section.tsx",
|
|
229
|
+
"./components/dashboard/admin/newDeviceCard": "./components/dashboard/admin/home/new-device-card.tsx",
|
|
230
|
+
"./components/dashboard/admin/newDeviceTable": "./components/dashboard/admin/home/new-device-table.tsx",
|
|
231
|
+
"./components/dashboard/admin/revokeAllSessionsButton": "./components/dashboard/admin/users/revoke-all-sessions.tsx",
|
|
232
|
+
"./components/dashboard/admin/securityHighlightsCollapsible": "./components/dashboard/admin/activity-logs/security-highlights-collapsible.tsx",
|
|
233
|
+
"./components/dashboard/admin/sharedDeviceCard": "./components/dashboard/admin/home/shared-device-card.tsx",
|
|
234
|
+
"./components/dashboard/admin/sharedDeviceTable": "./components/dashboard/admin/home/shared-device-table.tsx",
|
|
235
|
+
"./components/dashboard/admin/subscribersCard": "./components/dashboard/admin/marketing/subscribers-card.tsx",
|
|
236
|
+
"./components/dashboard/admin/systemSettingsForm": "./components/dashboard/admin/system-settings/system-settings-form.tsx",
|
|
237
|
+
"./components/dashboard/admin/systemSettingsSection": "./components/dashboard/admin/system-settings/system-settings-section.tsx",
|
|
238
|
+
"./components/dashboard/admin/systemSettingsSkeleton": "./components/dashboard/admin/system-settings/skeletons/system-settings-skeleton.tsx",
|
|
239
|
+
"./components/dashboard/admin/usersSection": "./components/dashboard/admin/users/users-section.tsx",
|
|
240
|
+
"./components/auth/authCard": "./components/auth/layout/auth-card.tsx",
|
|
241
|
+
"./components/auth/authShell": "./components/auth/layout/auth-shell.tsx",
|
|
242
|
+
"./components/auth/deviceCheck": "./components/auth/session/device-check.tsx",
|
|
243
|
+
"./components/auth/emailPasswordLogin": "./components/auth/forms/login-form.tsx",
|
|
244
|
+
"./components/auth/emailPasswordSignup": "./components/auth/forms/signup-form.tsx",
|
|
245
|
+
"./components/auth/forgotPasswordForm": "./components/auth/recovery/forgot-password-form.tsx",
|
|
246
|
+
"./components/auth/loginErrorRecovery": "./components/auth/forms/login-error-recovery.tsx",
|
|
247
|
+
"./components/auth/logoutButtons": "./components/auth/session/logout-buttons.tsx",
|
|
248
|
+
"./components/auth/oneTap": "./components/auth/methods/one-tap.tsx",
|
|
249
|
+
"./components/auth/passkeyLogin": "./components/auth/methods/passkey-login.tsx",
|
|
250
|
+
"./components/auth/resetPasswordForm": "./components/auth/recovery/reset-password-form.tsx",
|
|
251
|
+
"./components/auth/socialLogin": "./components/auth/methods/social-login.tsx",
|
|
252
|
+
"./components/auth/twoFactorVerifyForm": "./components/auth/mfa/two-factor-verify-form.tsx",
|
|
253
|
+
"./components/email/email-template-2": "./components/email/marketing/general-announcement.tsx",
|
|
254
|
+
"./components/email/email-template-banned": "./components/email/security/account-banned.tsx",
|
|
255
|
+
"./components/email/email-template-invite": "./components/email/team/workspace-invite.tsx",
|
|
256
|
+
"./components/email/email-template-new-device": "./components/email/security/new-device-alert.tsx",
|
|
257
|
+
"./components/email/email-template-passkey-change": "./components/email/security/passkey-changed.tsx",
|
|
258
|
+
"./components/email/email-template-reset-password": "./components/email/auth/reset-password.tsx",
|
|
259
|
+
"./components/email/email-template-verify-email": "./components/email/auth/verify-email.tsx",
|
|
260
|
+
"./components/email/email-template-welcome": "./components/email/auth/welcome.tsx",
|
|
261
|
+
"./components/email/email-template": "./components/email/layout/base-layout.tsx",
|
|
262
|
+
"./components/email/send-email-button": "./components/email/ui/send-email-button.tsx",
|
|
263
|
+
"./components/site/cookie-banner": "./components/site/compliance/cookie-banner.tsx",
|
|
166
264
|
"./components/*": "./components/*.tsx"
|
|
167
265
|
},
|
|
168
266
|
"typesVersions": {
|
|
@@ -228,7 +326,9 @@
|
|
|
228
326
|
"build": "npm run build:lib && next build",
|
|
229
327
|
"start": "next start",
|
|
230
328
|
"lint": "next lint",
|
|
231
|
-
"test": "bun
|
|
329
|
+
"test": "bun scripts/run-tests.ts",
|
|
330
|
+
"cy:open": "cypress open",
|
|
331
|
+
"cy:run": "cypress run",
|
|
232
332
|
"build:lib": "tsup",
|
|
233
333
|
"storybook": "storybook dev -p 6006",
|
|
234
334
|
"build-storybook": "storybook build",
|
|
@@ -251,81 +351,83 @@
|
|
|
251
351
|
"docs:dev": "cd docs && bun run dev"
|
|
252
352
|
},
|
|
253
353
|
"dependencies": {
|
|
254
|
-
"@better-auth/passkey": "^1.7.
|
|
255
|
-
"@fingerprintjs/fingerprintjs": "^5.
|
|
256
|
-
"@neondatabase/serverless": "^1.
|
|
257
|
-
"@paralleldrive/cuid2": "^3.0
|
|
258
|
-
"@react-email/components": "^1.0.
|
|
354
|
+
"@better-auth/passkey": "^1.7.27",
|
|
355
|
+
"@fingerprintjs/fingerprintjs": "^5.3.0",
|
|
356
|
+
"@neondatabase/serverless": "^1.2.1",
|
|
357
|
+
"@paralleldrive/cuid2": "^3.3.0",
|
|
358
|
+
"@react-email/components": "^1.0.12",
|
|
259
359
|
"bcrypt": "^6.0.0",
|
|
260
|
-
"better-auth": "^1.7.
|
|
261
|
-
"drizzle-orm": "^0.45.
|
|
360
|
+
"better-auth": "^1.7.27",
|
|
361
|
+
"drizzle-orm": "^0.45.4",
|
|
262
362
|
"geoip-lite": "^2.0.3",
|
|
263
|
-
"pg": "^8.
|
|
264
|
-
"radix-ui": "^1.
|
|
363
|
+
"pg": "^8.23.1",
|
|
364
|
+
"radix-ui": "^1.8.1",
|
|
265
365
|
"react-qr-code": "^2.2.0",
|
|
266
|
-
"resend": "^6.
|
|
366
|
+
"resend": "^6.39.0",
|
|
267
367
|
"server-only": "^0.0.1",
|
|
268
368
|
"ua-parser-js": "2.0.10",
|
|
269
|
-
"
|
|
270
|
-
"
|
|
369
|
+
"vaul": "^1.1.2",
|
|
370
|
+
"web-push": "^4.0.0",
|
|
371
|
+
"zod": "^4.6.7"
|
|
271
372
|
},
|
|
272
373
|
"peerDependencies": {
|
|
273
|
-
"next": "^
|
|
274
|
-
"react": "^19.
|
|
275
|
-
"react-dom": "^19.
|
|
276
|
-
"class-variance-authority": "^0.7.
|
|
277
|
-
"clsx": "^2.1.
|
|
278
|
-
"tailwind-merge": "^3.
|
|
279
|
-
"lucide-react": "^1.
|
|
280
|
-
"react-icons": "^5.
|
|
281
|
-
"next-themes": "^0.4.
|
|
282
|
-
"sonner": "^2.0.
|
|
374
|
+
"next": "^16.4.6",
|
|
375
|
+
"react": "^19.3.1",
|
|
376
|
+
"react-dom": "^19.3.1",
|
|
377
|
+
"class-variance-authority": "^0.7.1",
|
|
378
|
+
"clsx": "^2.1.1",
|
|
379
|
+
"tailwind-merge": "^3.7.1",
|
|
380
|
+
"lucide-react": "^1.77.0",
|
|
381
|
+
"react-icons": "^5.7.0",
|
|
382
|
+
"next-themes": "^0.4.6",
|
|
383
|
+
"sonner": "^2.0.8",
|
|
283
384
|
"cmdk": "^1.1.1",
|
|
284
|
-
"date-fns": "^4.
|
|
285
|
-
"react-day-picker": "^10.0.
|
|
286
|
-
"recharts": "^3.
|
|
385
|
+
"date-fns": "^4.4.0",
|
|
386
|
+
"react-day-picker": "^10.0.2",
|
|
387
|
+
"recharts": "^3.11.0"
|
|
287
388
|
},
|
|
288
389
|
"devDependencies": {
|
|
289
|
-
"@eslint/eslintrc": "^3",
|
|
290
|
-
"@inquirer/prompts": "^8.
|
|
291
|
-
"@storybook/addon-docs": "10.6.
|
|
292
|
-
"@storybook/nextjs-vite": "10.6.
|
|
293
|
-
"@tailwindcss/postcss": "^4",
|
|
390
|
+
"@eslint/eslintrc": "^3.3.7",
|
|
391
|
+
"@inquirer/prompts": "^8.8.0",
|
|
392
|
+
"@storybook/addon-docs": "10.6.8",
|
|
393
|
+
"@storybook/nextjs-vite": "10.6.8",
|
|
394
|
+
"@tailwindcss/postcss": "^4.3.5",
|
|
294
395
|
"@types/bcrypt": "^6.0.0",
|
|
295
396
|
"@types/geoip-lite": "^1.4.4",
|
|
296
|
-
"@types/node": "^26.
|
|
297
|
-
"@types/pg": "^8.
|
|
298
|
-
"@types/react": "^19.
|
|
299
|
-
"@types/react-dom": "^19",
|
|
397
|
+
"@types/node": "^26.6.6",
|
|
398
|
+
"@types/pg": "^8.23.1",
|
|
399
|
+
"@types/react": "^19.3.0",
|
|
400
|
+
"@types/react-dom": "^19.3.0",
|
|
300
401
|
"@types/ua-parser-js": "^0.7.39",
|
|
301
402
|
"@types/web-push": "^3.6.4",
|
|
302
|
-
"bun-types": "^1.4.
|
|
403
|
+
"bun-types": "^1.4.5",
|
|
303
404
|
"class-variance-authority": "^0.7.1",
|
|
304
405
|
"clsx": "^2.1.1",
|
|
305
406
|
"cmdk": "^1.1.1",
|
|
306
|
-
"
|
|
307
|
-
"
|
|
308
|
-
"
|
|
309
|
-
"
|
|
310
|
-
"eslint
|
|
311
|
-
"
|
|
312
|
-
"
|
|
407
|
+
"cypress": "^15.21.2",
|
|
408
|
+
"date-fns": "^4.4.0",
|
|
409
|
+
"dotenv": "^18.0.10",
|
|
410
|
+
"drizzle-kit": "^0.31.11",
|
|
411
|
+
"eslint": "^10.15.0",
|
|
412
|
+
"eslint-config-next": "16.4.6",
|
|
413
|
+
"lucide-react": "^1.77.0",
|
|
414
|
+
"next": "16.4.6",
|
|
313
415
|
"next-themes": "^0.4.6",
|
|
314
|
-
"playwright": "^1.
|
|
315
|
-
"react": "^19.
|
|
316
|
-
"react-day-picker": "^10.0.
|
|
317
|
-
"react-dom": "^19.
|
|
318
|
-
"react-icons": "^5.
|
|
319
|
-
"recharts": "^3.
|
|
320
|
-
"sonner": "^2.0.
|
|
321
|
-
"storybook": "10.6.
|
|
322
|
-
"tailwind-merge": "^3.
|
|
323
|
-
"tailwindcss": "^4",
|
|
324
|
-
"tsup": "^
|
|
325
|
-
"tsx": "^4.
|
|
326
|
-
"tw-animate-css": "^1.
|
|
416
|
+
"playwright": "^1.65.1",
|
|
417
|
+
"react": "^19.3.1",
|
|
418
|
+
"react-day-picker": "^10.0.2",
|
|
419
|
+
"react-dom": "^19.3.1",
|
|
420
|
+
"react-icons": "^5.7.0",
|
|
421
|
+
"recharts": "^3.11.0",
|
|
422
|
+
"sonner": "^2.0.8",
|
|
423
|
+
"storybook": "10.6.8",
|
|
424
|
+
"tailwind-merge": "^3.7.1",
|
|
425
|
+
"tailwindcss": "^4.3.5",
|
|
426
|
+
"tsup": "^9.0.0",
|
|
427
|
+
"tsx": "^4.23.15",
|
|
428
|
+
"tw-animate-css": "^1.4.0",
|
|
327
429
|
"typescript": "^6.0.3",
|
|
328
|
-
"vite": "^8.3.
|
|
430
|
+
"vite": "^8.3.8"
|
|
329
431
|
},
|
|
330
432
|
"peerDependenciesMeta": {
|
|
331
433
|
"cmdk": {
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Ships in @xk2800/nextjs-template and runs from the app's postinstall: lists packages
|
|
2
|
+
// where the app is older than what this template release declares. Warns only, never
|
|
3
|
+
// fails an install, and changes nothing. Runs on import and reads the app from cwd.
|
|
4
|
+
import { readFileSync } from 'node:fs';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
|
|
7
|
+
const readJson = (path) => JSON.parse(readFileSync(path, 'utf-8'));
|
|
8
|
+
|
|
9
|
+
// [major, minor, patch, prerelease] of a plain version
|
|
10
|
+
const parse = (v) => {
|
|
11
|
+
const m = v.match(/^(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:-([\w.-]+))?(?:\+[\w.-]+)?$/);
|
|
12
|
+
return m && [+m[1], +(m[2] ?? 0), +(m[3] ?? 0), m[4] ?? ''];
|
|
13
|
+
};
|
|
14
|
+
const compare = (a, b) => {
|
|
15
|
+
const [x, y] = [parse(a), parse(b)];
|
|
16
|
+
for (let i = 0; i < 3; i++) if (x[i] !== y[i]) return x[i] - y[i];
|
|
17
|
+
if (x[3] === y[3]) return 0;
|
|
18
|
+
if (!x[3] || !y[3]) return x[3] ? -1 : 1; // a prerelease is older than its release
|
|
19
|
+
return x[3].localeCompare(y[3], 'en', { numeric: true });
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// Lowest version a range allows. Only exact, ^, ~, >= and || of those; null for
|
|
23
|
+
// anything else (file:, workspace:, "latest", "*"), which is then not compared.
|
|
24
|
+
const floor = (range) => {
|
|
25
|
+
const versions = range.split('||').map((r) => r.trim().replace(/^(\^|~|>=)\s*/, ''));
|
|
26
|
+
return versions.every(parse) ? versions.sort(compare)[0] : null;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
const template = readJson(new URL('../package.json', import.meta.url));
|
|
31
|
+
const app = readJson(join(process.cwd(), 'package.json'));
|
|
32
|
+
const outdated = [];
|
|
33
|
+
for (const [section, dev] of [['dependencies', false], ['devDependencies', true]]) {
|
|
34
|
+
for (const [name, spec] of Object.entries(app[section] ?? {})) {
|
|
35
|
+
if (name === template.name) continue;
|
|
36
|
+
// A package can be a peer (loose) and a devDependency (what the template is built with): take the newest.
|
|
37
|
+
const wanted = ['dependencies', 'peerDependencies', 'devDependencies']
|
|
38
|
+
.map((s) => floor(template[s]?.[name] ?? '')).filter(Boolean).sort(compare).at(-1);
|
|
39
|
+
if (!wanted) continue;
|
|
40
|
+
let installed;
|
|
41
|
+
try { installed = readJson(join(process.cwd(), 'node_modules', name, 'package.json')).version; } catch { continue; }
|
|
42
|
+
if (!parse(installed ?? '') || compare(installed, wanted) >= 0) continue;
|
|
43
|
+
// keep the app's range style: ^ and ~ stay, an exact pin stays exact
|
|
44
|
+
const prefix = /^\d/.test(spec) ? '' : spec.startsWith('~') ? '~' : '^';
|
|
45
|
+
outdated.push({ name, installed, wanted, dev, prefix });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (outdated.length) {
|
|
49
|
+
const rows = [['package', 'yours', 'template'], ...outdated.map((o) => [o.name, o.installed, o.wanted])];
|
|
50
|
+
const [nameWidth, yoursWidth] = [0, 1].map((i) => Math.max(...rows.map((r) => r[i].length)));
|
|
51
|
+
const commands = new Map();
|
|
52
|
+
for (const o of outdated) {
|
|
53
|
+
const command = `bun add${o.dev ? ' -d' : ''}${o.prefix ? '' : ' --exact'}`;
|
|
54
|
+
commands.set(command, [...(commands.get(command) ?? []), `"${o.name}@${o.prefix}${o.wanted}"`]);
|
|
55
|
+
}
|
|
56
|
+
console.log([
|
|
57
|
+
'',
|
|
58
|
+
`${template.name} ${template.version} uses newer versions than your app:`,
|
|
59
|
+
...rows.map(([name, yours, theirs]) => ` ${name.padEnd(nameWidth)} ${yours.padEnd(yoursWidth)} ${theirs}`),
|
|
60
|
+
'',
|
|
61
|
+
'Optional. To update:',
|
|
62
|
+
...[...commands].map(([command, specs]) => ` ${command} ${specs.join(' ')}`),
|
|
63
|
+
'',
|
|
64
|
+
].join('\n'));
|
|
65
|
+
}
|
|
66
|
+
} catch (err) {
|
|
67
|
+
console.warn(`Skipped the template dependency check: ${err.message}`);
|
|
68
|
+
}
|