@xk2800/nextjs-template 0.7.1-beta.17 → 0.7.1-beta.18
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/components/dashboard/admin/adminUsersTable.tsx +25 -12
- package/dist/activity/logger.d.mts +3 -1
- package/dist/activity/logger.d.ts +3 -1
- package/dist/activity/logger.js.map +1 -1
- package/dist/activity/logger.mjs +1 -1
- package/dist/activity/queries.d.mts +1 -1
- package/dist/activity/queries.d.ts +1 -1
- package/dist/api/feedback.js +20 -18
- package/dist/api/feedback.js.map +1 -1
- package/dist/api/feedback.mjs +2 -2
- package/dist/api/marketing.js +20 -18
- package/dist/api/marketing.js.map +1 -1
- package/dist/api/marketing.mjs +3 -3
- package/dist/auth/helpers.d.mts +3 -3
- package/dist/auth/helpers.d.ts +3 -3
- package/dist/auth/helpers.js +20 -18
- package/dist/auth/helpers.js.map +1 -1
- package/dist/auth/helpers.mjs +3 -3
- package/dist/auth/index.d.mts +9 -2
- package/dist/auth/index.d.ts +9 -2
- package/dist/auth/index.js +20 -18
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/index.mjs +2 -2
- package/dist/auth-client/index.d.mts +16 -16
- package/dist/auth-client/index.d.ts +16 -16
- package/dist/{chunk-BVCGLJYX.mjs → chunk-3BVXDGVH.mjs} +3 -3
- package/dist/{chunk-BVCGLJYX.mjs.map → chunk-3BVXDGVH.mjs.map} +1 -1
- package/dist/{chunk-QMGZKVBI.mjs → chunk-BZ6BJNYZ.mjs} +23 -21
- package/dist/chunk-BZ6BJNYZ.mjs.map +1 -0
- package/dist/{chunk-PSHG3WHD.mjs → chunk-KLQOKDIL.mjs} +2 -2
- package/dist/chunk-KLQOKDIL.mjs.map +1 -0
- package/dist/db/index.d.mts +1 -1
- package/dist/db/index.d.ts +1 -1
- package/dist/db/schema.d.mts +1 -1
- package/dist/db/schema.d.ts +1 -1
- package/dist/{schema-DIGqiX6c.d.mts → schema-B_3Oe9DD.d.mts} +1 -1
- package/dist/{schema-DIGqiX6c.d.ts → schema-B_3Oe9DD.d.ts} +1 -1
- package/dist/settings/queries.d.mts +1 -1
- package/dist/settings/queries.d.ts +1 -1
- package/package.json +1 -1
- package/dist/chunk-PSHG3WHD.mjs.map +0 -1
- package/dist/chunk-QMGZKVBI.mjs.map +0 -1
package/dist/api/marketing.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { unexpectedErrorMessage } from '../chunk-KX2M6OEG.mjs';
|
|
2
2
|
import { MARKETING_SEGMENT_ID, setSubscribed } from '../chunk-C6RGN6QA.mjs';
|
|
3
|
-
import { hasRole } from '../chunk-
|
|
4
|
-
import { auth } from '../chunk-
|
|
5
|
-
import '../chunk-
|
|
3
|
+
import { hasRole } from '../chunk-3BVXDGVH.mjs';
|
|
4
|
+
import { auth } from '../chunk-BZ6BJNYZ.mjs';
|
|
5
|
+
import '../chunk-KLQOKDIL.mjs';
|
|
6
6
|
import '../chunk-6OAHCEDJ.mjs';
|
|
7
7
|
import '../chunk-2BML32KG.mjs';
|
|
8
8
|
import { getBroadcastResend, EMAIL_FROM } from '../chunk-OVKVD2HH.mjs';
|
package/dist/auth/helpers.d.mts
CHANGED
|
@@ -27,8 +27,8 @@ declare const getCurrentSession: () => Promise<{
|
|
|
27
27
|
image?: string | null | undefined | undefined;
|
|
28
28
|
role: string | null | undefined;
|
|
29
29
|
banned: boolean | null | undefined;
|
|
30
|
-
banExpires?: Date | null | undefined;
|
|
31
30
|
banReason?: string | null | undefined;
|
|
31
|
+
banExpires?: Date | null | undefined;
|
|
32
32
|
twoFactorEnabled: boolean | null | undefined;
|
|
33
33
|
};
|
|
34
34
|
} | null>;
|
|
@@ -61,8 +61,8 @@ declare const requireAuth: () => Promise<{
|
|
|
61
61
|
image?: string | null | undefined | undefined;
|
|
62
62
|
role: string | null | undefined;
|
|
63
63
|
banned: boolean | null | undefined;
|
|
64
|
-
banExpires?: Date | null | undefined;
|
|
65
64
|
banReason?: string | null | undefined;
|
|
65
|
+
banExpires?: Date | null | undefined;
|
|
66
66
|
twoFactorEnabled: boolean | null | undefined;
|
|
67
67
|
};
|
|
68
68
|
}>;
|
|
@@ -95,8 +95,8 @@ declare function requireRole(requiredRole: 'user' | 'admin'): Promise<{
|
|
|
95
95
|
image?: string | null | undefined | undefined;
|
|
96
96
|
role: string | null | undefined;
|
|
97
97
|
banned: boolean | null | undefined;
|
|
98
|
-
banExpires?: Date | null | undefined;
|
|
99
98
|
banReason?: string | null | undefined;
|
|
99
|
+
banExpires?: Date | null | undefined;
|
|
100
100
|
twoFactorEnabled: boolean | null | undefined;
|
|
101
101
|
};
|
|
102
102
|
}>;
|
package/dist/auth/helpers.d.ts
CHANGED
|
@@ -27,8 +27,8 @@ declare const getCurrentSession: () => Promise<{
|
|
|
27
27
|
image?: string | null | undefined | undefined;
|
|
28
28
|
role: string | null | undefined;
|
|
29
29
|
banned: boolean | null | undefined;
|
|
30
|
-
banExpires?: Date | null | undefined;
|
|
31
30
|
banReason?: string | null | undefined;
|
|
31
|
+
banExpires?: Date | null | undefined;
|
|
32
32
|
twoFactorEnabled: boolean | null | undefined;
|
|
33
33
|
};
|
|
34
34
|
} | null>;
|
|
@@ -61,8 +61,8 @@ declare const requireAuth: () => Promise<{
|
|
|
61
61
|
image?: string | null | undefined | undefined;
|
|
62
62
|
role: string | null | undefined;
|
|
63
63
|
banned: boolean | null | undefined;
|
|
64
|
-
banExpires?: Date | null | undefined;
|
|
65
64
|
banReason?: string | null | undefined;
|
|
65
|
+
banExpires?: Date | null | undefined;
|
|
66
66
|
twoFactorEnabled: boolean | null | undefined;
|
|
67
67
|
};
|
|
68
68
|
}>;
|
|
@@ -95,8 +95,8 @@ declare function requireRole(requiredRole: 'user' | 'admin'): Promise<{
|
|
|
95
95
|
image?: string | null | undefined | undefined;
|
|
96
96
|
role: string | null | undefined;
|
|
97
97
|
banned: boolean | null | undefined;
|
|
98
|
-
banExpires?: Date | null | undefined;
|
|
99
98
|
banReason?: string | null | undefined;
|
|
99
|
+
banExpires?: Date | null | undefined;
|
|
100
100
|
twoFactorEnabled: boolean | null | undefined;
|
|
101
101
|
};
|
|
102
102
|
}>;
|
package/dist/auth/helpers.js
CHANGED
|
@@ -1125,7 +1125,7 @@ async function getResend() {
|
|
|
1125
1125
|
config.RESEND_BROADCAST_API_KEY || config.RESEND_API_KEY;
|
|
1126
1126
|
|
|
1127
1127
|
// server/auth.ts
|
|
1128
|
-
async function logFailedLogin(ctx) {
|
|
1128
|
+
async function logFailedLogin(ctx, log) {
|
|
1129
1129
|
var _a, _b, _c;
|
|
1130
1130
|
try {
|
|
1131
1131
|
const raw = (_a = ctx.body) == null ? void 0 : _a.email;
|
|
@@ -1133,7 +1133,7 @@ async function logFailedLogin(ctx) {
|
|
|
1133
1133
|
if (!email) return;
|
|
1134
1134
|
const [user] = await db.select({ id: users.id }).from(users).where(drizzleOrm.eq(users.email, email)).limit(1);
|
|
1135
1135
|
if (!user) return;
|
|
1136
|
-
await
|
|
1136
|
+
await log({
|
|
1137
1137
|
userId: user.id,
|
|
1138
1138
|
action: "login_failed",
|
|
1139
1139
|
description: "Failed login attempt",
|
|
@@ -1144,14 +1144,14 @@ async function logFailedLogin(ctx) {
|
|
|
1144
1144
|
console.error("Failed to log login_failed activity", error);
|
|
1145
1145
|
}
|
|
1146
1146
|
}
|
|
1147
|
-
async function notifyPasskeyChange(ctx, action) {
|
|
1147
|
+
async function notifyPasskeyChange(ctx, action, log) {
|
|
1148
1148
|
var _a, _b, _c, _d;
|
|
1149
1149
|
try {
|
|
1150
1150
|
const session = await api.getSessionFromCtx(ctx);
|
|
1151
1151
|
const user = session == null ? void 0 : session.user;
|
|
1152
1152
|
if (!user) return;
|
|
1153
1153
|
const ip = getClientIp(ctx.headers);
|
|
1154
|
-
await
|
|
1154
|
+
await log({
|
|
1155
1155
|
userId: user.id,
|
|
1156
1156
|
action: action === "added" ? "passkey_added" : "passkey_removed",
|
|
1157
1157
|
description: `Passkey ${action}`,
|
|
@@ -1178,12 +1178,12 @@ async function notifyPasskeyChange(ctx, action) {
|
|
|
1178
1178
|
console.error("Failed to send passkey-change notification", error);
|
|
1179
1179
|
}
|
|
1180
1180
|
}
|
|
1181
|
-
async function packageSessionCreated(...[session, context]) {
|
|
1181
|
+
async function packageSessionCreated(log, ...[session, context]) {
|
|
1182
1182
|
var _a, _b, _c, _d;
|
|
1183
1183
|
const impersonatedBy = session.impersonatedBy;
|
|
1184
1184
|
if (impersonatedBy) {
|
|
1185
1185
|
const target = await db.select({ email: users.email }).from(users).where(drizzleOrm.eq(users.id, session.userId)).limit(1);
|
|
1186
|
-
await
|
|
1186
|
+
await log({
|
|
1187
1187
|
userId: impersonatedBy,
|
|
1188
1188
|
action: "impersonation_started",
|
|
1189
1189
|
description: `Admin started impersonating ${(_b = (_a = target[0]) == null ? void 0 : _a.email) != null ? _b : session.userId}`,
|
|
@@ -1205,7 +1205,7 @@ async function packageSessionCreated(...[session, context]) {
|
|
|
1205
1205
|
const geo = lookupGeoLocation(ipAddress);
|
|
1206
1206
|
const [{ count }] = await db.select({ count: drizzleOrm.sql`count(*)` }).from(sessions).where(drizzleOrm.eq(sessions.userId, session.userId));
|
|
1207
1207
|
const isFirstSession = Number(count) <= 1;
|
|
1208
|
-
await
|
|
1208
|
+
await log({
|
|
1209
1209
|
userId: session.userId,
|
|
1210
1210
|
action: "login",
|
|
1211
1211
|
description: isFirstSession ? "New account registered and signed in" : "User logged in",
|
|
@@ -1223,7 +1223,7 @@ async function packageSessionCreated(...[session, context]) {
|
|
|
1223
1223
|
}
|
|
1224
1224
|
}
|
|
1225
1225
|
function createAuth(overrides = {}) {
|
|
1226
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1226
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1227
1227
|
const socialProviders = __spreadValues(__spreadValues({}, config.AUTH_ENABLE_GOOGLE ? {
|
|
1228
1228
|
google: {
|
|
1229
1229
|
clientId: process.env.AUTH_GOOGLE_ID || process.env.GOOGLE_CLIENT_ID || "",
|
|
@@ -1238,16 +1238,17 @@ function createAuth(overrides = {}) {
|
|
|
1238
1238
|
);
|
|
1239
1239
|
}
|
|
1240
1240
|
const baseURL = process.env.NEXTAUTH_URL || process.env.BETTER_AUTH_URL || "http://localhost:3000";
|
|
1241
|
+
const log = (_a = overrides.logActivity) != null ? _a : logActivity;
|
|
1241
1242
|
const [twoFactorPlugin, twoFactorExtras] = twoFactorPlugins(baseURL, {
|
|
1242
1243
|
issuer: config.APP_NAME,
|
|
1243
|
-
passwordless: (
|
|
1244
|
-
challengeAfterOAuth: (
|
|
1244
|
+
passwordless: (_b = overrides.twoFactor) == null ? void 0 : _b.passwordless,
|
|
1245
|
+
challengeAfterOAuth: (_c = overrides.twoFactor) == null ? void 0 : _c.challengeAfterOAuth
|
|
1245
1246
|
});
|
|
1246
1247
|
const appHooks = {
|
|
1247
1248
|
id: "app-hooks",
|
|
1248
1249
|
hooks: {
|
|
1249
|
-
before: ((
|
|
1250
|
-
after: ((
|
|
1250
|
+
before: ((_d = overrides.hooks) == null ? void 0 : _d.before) ? [{ matcher: () => true, handler: overrides.hooks.before }] : [],
|
|
1251
|
+
after: ((_e = overrides.hooks) == null ? void 0 : _e.after) ? [{ matcher: () => true, handler: overrides.hooks.after }] : []
|
|
1251
1252
|
}
|
|
1252
1253
|
};
|
|
1253
1254
|
return betterAuth.betterAuth({
|
|
@@ -1329,7 +1330,7 @@ function createAuth(overrides = {}) {
|
|
|
1329
1330
|
// no password, so better-auth instead requires a session younger than
|
|
1330
1331
|
// `freshAge` (default 1 day). Every user-owned table cascades on delete.
|
|
1331
1332
|
// Impersonation and last-admin guards live in hooks.before below.
|
|
1332
|
-
deleteUser: { enabled: (
|
|
1333
|
+
deleteUser: { enabled: (_f = overrides.deleteUser) != null ? _f : true }
|
|
1333
1334
|
},
|
|
1334
1335
|
// Advanced options
|
|
1335
1336
|
advanced: __spreadProps(__spreadValues({}, overrides.advanced), {
|
|
@@ -1351,7 +1352,7 @@ function createAuth(overrides = {}) {
|
|
|
1351
1352
|
create: {
|
|
1352
1353
|
async after(session, context) {
|
|
1353
1354
|
var _a2, _b2, _c2, _d2;
|
|
1354
|
-
await packageSessionCreated(session, context);
|
|
1355
|
+
await packageSessionCreated(log, session, context);
|
|
1355
1356
|
await ((_d2 = (_c2 = (_b2 = (_a2 = overrides.databaseHooks) == null ? void 0 : _a2.session) == null ? void 0 : _b2.create) == null ? void 0 : _c2.after) == null ? void 0 : _d2.call(_c2, session, context));
|
|
1356
1357
|
}
|
|
1357
1358
|
}
|
|
@@ -1421,7 +1422,7 @@ function createAuth(overrides = {}) {
|
|
|
1421
1422
|
const current = await api.getSessionFromCtx(ctx, { disableCookieCache: true });
|
|
1422
1423
|
if (current == null ? void 0 : current.session.impersonatedBy) {
|
|
1423
1424
|
const target = await db.select({ email: users.email }).from(users).where(drizzleOrm.eq(users.id, current.session.userId)).limit(1);
|
|
1424
|
-
await
|
|
1425
|
+
await log({
|
|
1425
1426
|
userId: current.session.impersonatedBy,
|
|
1426
1427
|
action: "impersonation_stopped",
|
|
1427
1428
|
description: `Admin stopped impersonating ${(_d2 = (_c2 = target[0]) == null ? void 0 : _c2.email) != null ? _d2 : current.session.userId}`,
|
|
@@ -1435,7 +1436,8 @@ function createAuth(overrides = {}) {
|
|
|
1435
1436
|
if (ctx.context.returned instanceof api.APIError) return;
|
|
1436
1437
|
await notifyPasskeyChange(
|
|
1437
1438
|
ctx,
|
|
1438
|
-
ctx.path === "/passkey/verify-registration" ? "added" : "removed"
|
|
1439
|
+
ctx.path === "/passkey/verify-registration" ? "added" : "removed",
|
|
1440
|
+
log
|
|
1439
1441
|
);
|
|
1440
1442
|
return;
|
|
1441
1443
|
}
|
|
@@ -1458,7 +1460,7 @@ function createAuth(overrides = {}) {
|
|
|
1458
1460
|
}
|
|
1459
1461
|
if (failed) {
|
|
1460
1462
|
await Promise.all(keys.map((key) => recordDeviceAttempt(key, __spreadProps(__spreadValues({}, meta), { kind: "signin" }))));
|
|
1461
|
-
await logFailedLogin(ctx);
|
|
1463
|
+
await logFailedLogin(ctx, log);
|
|
1462
1464
|
} else {
|
|
1463
1465
|
await Promise.all(keys.map((key) => clearDeviceThrottle(key)));
|
|
1464
1466
|
}
|
|
@@ -1513,7 +1515,7 @@ function createAuth(overrides = {}) {
|
|
|
1513
1515
|
// array and better-auth 1.7 then drops plugin fields (e.g. session.impersonatedBy).
|
|
1514
1516
|
...config.AUTH_ENABLE_ONE_TAP && Boolean(socialProviders.google) ? [plugins.oneTap()] : [],
|
|
1515
1517
|
appHooks,
|
|
1516
|
-
...(
|
|
1518
|
+
...(_g = overrides.plugins) != null ? _g : []
|
|
1517
1519
|
]
|
|
1518
1520
|
});
|
|
1519
1521
|
}
|