@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/feedback.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { lookupErrorDetail, unexpectedErrorMessage } from '../chunk-KX2M6OEG.mjs';
|
|
2
|
-
import { auth } from '../chunk-
|
|
3
|
-
import '../chunk-
|
|
2
|
+
import { auth } from '../chunk-BZ6BJNYZ.mjs';
|
|
3
|
+
import '../chunk-KLQOKDIL.mjs';
|
|
4
4
|
import '../chunk-6OAHCEDJ.mjs';
|
|
5
5
|
import { getSystemSettings } from '../chunk-2BML32KG.mjs';
|
|
6
6
|
import { getResend, EMAIL_FROM } from '../chunk-OVKVD2HH.mjs';
|
package/dist/api/marketing.js
CHANGED
|
@@ -1135,7 +1135,7 @@ async function getBroadcastResend() {
|
|
|
1135
1135
|
}
|
|
1136
1136
|
|
|
1137
1137
|
// server/auth.ts
|
|
1138
|
-
async function logFailedLogin(ctx) {
|
|
1138
|
+
async function logFailedLogin(ctx, log) {
|
|
1139
1139
|
var _a, _b, _c;
|
|
1140
1140
|
try {
|
|
1141
1141
|
const raw = (_a = ctx.body) == null ? void 0 : _a.email;
|
|
@@ -1143,7 +1143,7 @@ async function logFailedLogin(ctx) {
|
|
|
1143
1143
|
if (!email) return;
|
|
1144
1144
|
const [user] = await db.select({ id: users.id }).from(users).where(drizzleOrm.eq(users.email, email)).limit(1);
|
|
1145
1145
|
if (!user) return;
|
|
1146
|
-
await
|
|
1146
|
+
await log({
|
|
1147
1147
|
userId: user.id,
|
|
1148
1148
|
action: "login_failed",
|
|
1149
1149
|
description: "Failed login attempt",
|
|
@@ -1154,14 +1154,14 @@ async function logFailedLogin(ctx) {
|
|
|
1154
1154
|
console.error("Failed to log login_failed activity", error);
|
|
1155
1155
|
}
|
|
1156
1156
|
}
|
|
1157
|
-
async function notifyPasskeyChange(ctx, action) {
|
|
1157
|
+
async function notifyPasskeyChange(ctx, action, log) {
|
|
1158
1158
|
var _a, _b, _c, _d;
|
|
1159
1159
|
try {
|
|
1160
1160
|
const session = await api.getSessionFromCtx(ctx);
|
|
1161
1161
|
const user = session == null ? void 0 : session.user;
|
|
1162
1162
|
if (!user) return;
|
|
1163
1163
|
const ip = getClientIp(ctx.headers);
|
|
1164
|
-
await
|
|
1164
|
+
await log({
|
|
1165
1165
|
userId: user.id,
|
|
1166
1166
|
action: action === "added" ? "passkey_added" : "passkey_removed",
|
|
1167
1167
|
description: `Passkey ${action}`,
|
|
@@ -1188,12 +1188,12 @@ async function notifyPasskeyChange(ctx, action) {
|
|
|
1188
1188
|
console.error("Failed to send passkey-change notification", error);
|
|
1189
1189
|
}
|
|
1190
1190
|
}
|
|
1191
|
-
async function packageSessionCreated(...[session, context]) {
|
|
1191
|
+
async function packageSessionCreated(log, ...[session, context]) {
|
|
1192
1192
|
var _a, _b, _c, _d;
|
|
1193
1193
|
const impersonatedBy = session.impersonatedBy;
|
|
1194
1194
|
if (impersonatedBy) {
|
|
1195
1195
|
const target = await db.select({ email: users.email }).from(users).where(drizzleOrm.eq(users.id, session.userId)).limit(1);
|
|
1196
|
-
await
|
|
1196
|
+
await log({
|
|
1197
1197
|
userId: impersonatedBy,
|
|
1198
1198
|
action: "impersonation_started",
|
|
1199
1199
|
description: `Admin started impersonating ${(_b = (_a = target[0]) == null ? void 0 : _a.email) != null ? _b : session.userId}`,
|
|
@@ -1215,7 +1215,7 @@ async function packageSessionCreated(...[session, context]) {
|
|
|
1215
1215
|
const geo = lookupGeoLocation(ipAddress);
|
|
1216
1216
|
const [{ count }] = await db.select({ count: drizzleOrm.sql`count(*)` }).from(sessions).where(drizzleOrm.eq(sessions.userId, session.userId));
|
|
1217
1217
|
const isFirstSession = Number(count) <= 1;
|
|
1218
|
-
await
|
|
1218
|
+
await log({
|
|
1219
1219
|
userId: session.userId,
|
|
1220
1220
|
action: "login",
|
|
1221
1221
|
description: isFirstSession ? "New account registered and signed in" : "User logged in",
|
|
@@ -1233,7 +1233,7 @@ async function packageSessionCreated(...[session, context]) {
|
|
|
1233
1233
|
}
|
|
1234
1234
|
}
|
|
1235
1235
|
function createAuth(overrides = {}) {
|
|
1236
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1236
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1237
1237
|
const socialProviders = __spreadValues(__spreadValues({}, config.AUTH_ENABLE_GOOGLE ? {
|
|
1238
1238
|
google: {
|
|
1239
1239
|
clientId: process.env.AUTH_GOOGLE_ID || process.env.GOOGLE_CLIENT_ID || "",
|
|
@@ -1248,16 +1248,17 @@ function createAuth(overrides = {}) {
|
|
|
1248
1248
|
);
|
|
1249
1249
|
}
|
|
1250
1250
|
const baseURL = process.env.NEXTAUTH_URL || process.env.BETTER_AUTH_URL || "http://localhost:3000";
|
|
1251
|
+
const log = (_a = overrides.logActivity) != null ? _a : logActivity;
|
|
1251
1252
|
const [twoFactorPlugin, twoFactorExtras] = twoFactorPlugins(baseURL, {
|
|
1252
1253
|
issuer: config.APP_NAME,
|
|
1253
|
-
passwordless: (
|
|
1254
|
-
challengeAfterOAuth: (
|
|
1254
|
+
passwordless: (_b = overrides.twoFactor) == null ? void 0 : _b.passwordless,
|
|
1255
|
+
challengeAfterOAuth: (_c = overrides.twoFactor) == null ? void 0 : _c.challengeAfterOAuth
|
|
1255
1256
|
});
|
|
1256
1257
|
const appHooks = {
|
|
1257
1258
|
id: "app-hooks",
|
|
1258
1259
|
hooks: {
|
|
1259
|
-
before: ((
|
|
1260
|
-
after: ((
|
|
1260
|
+
before: ((_d = overrides.hooks) == null ? void 0 : _d.before) ? [{ matcher: () => true, handler: overrides.hooks.before }] : [],
|
|
1261
|
+
after: ((_e = overrides.hooks) == null ? void 0 : _e.after) ? [{ matcher: () => true, handler: overrides.hooks.after }] : []
|
|
1261
1262
|
}
|
|
1262
1263
|
};
|
|
1263
1264
|
return betterAuth.betterAuth({
|
|
@@ -1339,7 +1340,7 @@ function createAuth(overrides = {}) {
|
|
|
1339
1340
|
// no password, so better-auth instead requires a session younger than
|
|
1340
1341
|
// `freshAge` (default 1 day). Every user-owned table cascades on delete.
|
|
1341
1342
|
// Impersonation and last-admin guards live in hooks.before below.
|
|
1342
|
-
deleteUser: { enabled: (
|
|
1343
|
+
deleteUser: { enabled: (_f = overrides.deleteUser) != null ? _f : true }
|
|
1343
1344
|
},
|
|
1344
1345
|
// Advanced options
|
|
1345
1346
|
advanced: __spreadProps(__spreadValues({}, overrides.advanced), {
|
|
@@ -1361,7 +1362,7 @@ function createAuth(overrides = {}) {
|
|
|
1361
1362
|
create: {
|
|
1362
1363
|
async after(session, context) {
|
|
1363
1364
|
var _a2, _b2, _c2, _d2;
|
|
1364
|
-
await packageSessionCreated(session, context);
|
|
1365
|
+
await packageSessionCreated(log, session, context);
|
|
1365
1366
|
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));
|
|
1366
1367
|
}
|
|
1367
1368
|
}
|
|
@@ -1431,7 +1432,7 @@ function createAuth(overrides = {}) {
|
|
|
1431
1432
|
const current = await api.getSessionFromCtx(ctx, { disableCookieCache: true });
|
|
1432
1433
|
if (current == null ? void 0 : current.session.impersonatedBy) {
|
|
1433
1434
|
const target = await db.select({ email: users.email }).from(users).where(drizzleOrm.eq(users.id, current.session.userId)).limit(1);
|
|
1434
|
-
await
|
|
1435
|
+
await log({
|
|
1435
1436
|
userId: current.session.impersonatedBy,
|
|
1436
1437
|
action: "impersonation_stopped",
|
|
1437
1438
|
description: `Admin stopped impersonating ${(_d2 = (_c2 = target[0]) == null ? void 0 : _c2.email) != null ? _d2 : current.session.userId}`,
|
|
@@ -1445,7 +1446,8 @@ function createAuth(overrides = {}) {
|
|
|
1445
1446
|
if (ctx.context.returned instanceof api.APIError) return;
|
|
1446
1447
|
await notifyPasskeyChange(
|
|
1447
1448
|
ctx,
|
|
1448
|
-
ctx.path === "/passkey/verify-registration" ? "added" : "removed"
|
|
1449
|
+
ctx.path === "/passkey/verify-registration" ? "added" : "removed",
|
|
1450
|
+
log
|
|
1449
1451
|
);
|
|
1450
1452
|
return;
|
|
1451
1453
|
}
|
|
@@ -1468,7 +1470,7 @@ function createAuth(overrides = {}) {
|
|
|
1468
1470
|
}
|
|
1469
1471
|
if (failed) {
|
|
1470
1472
|
await Promise.all(keys.map((key) => recordDeviceAttempt(key, __spreadProps(__spreadValues({}, meta), { kind: "signin" }))));
|
|
1471
|
-
await logFailedLogin(ctx);
|
|
1473
|
+
await logFailedLogin(ctx, log);
|
|
1472
1474
|
} else {
|
|
1473
1475
|
await Promise.all(keys.map((key) => clearDeviceThrottle(key)));
|
|
1474
1476
|
}
|
|
@@ -1523,7 +1525,7 @@ function createAuth(overrides = {}) {
|
|
|
1523
1525
|
// array and better-auth 1.7 then drops plugin fields (e.g. session.impersonatedBy).
|
|
1524
1526
|
...config.AUTH_ENABLE_ONE_TAP && Boolean(socialProviders.google) ? [plugins.oneTap()] : [],
|
|
1525
1527
|
appHooks,
|
|
1526
|
-
...(
|
|
1528
|
+
...(_g = overrides.plugins) != null ? _g : []
|
|
1527
1529
|
]
|
|
1528
1530
|
});
|
|
1529
1531
|
}
|