@sonicjs-cms/core 2.18.0 → 2.18.1
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/{chunk-OWJPOVFW.js → chunk-4R3NOOL3.js} +2 -2
- package/dist/{chunk-OWJPOVFW.js.map → chunk-4R3NOOL3.js.map} +1 -1
- package/dist/{chunk-DAESIIWY.cjs → chunk-C54YUA23.cjs} +2 -2
- package/dist/{chunk-DAESIIWY.cjs.map → chunk-C54YUA23.cjs.map} +1 -1
- package/dist/{chunk-3XP76LM7.cjs → chunk-DSUJ5YQH.cjs} +8 -8
- package/dist/{chunk-3XP76LM7.cjs.map → chunk-DSUJ5YQH.cjs.map} +1 -1
- package/dist/{chunk-YK5IEGQZ.js → chunk-EW5NOBVU.js} +2 -2
- package/dist/{chunk-YK5IEGQZ.js.map → chunk-EW5NOBVU.js.map} +1 -1
- package/dist/{chunk-GH3HYA7D.js → chunk-I2H5NGJQ.js} +4 -4
- package/dist/{chunk-GH3HYA7D.js.map → chunk-I2H5NGJQ.js.map} +1 -1
- package/dist/{chunk-NDS4S4AG.js → chunk-MGFRZO24.js} +3 -3
- package/dist/{chunk-NDS4S4AG.js.map → chunk-MGFRZO24.js.map} +1 -1
- package/dist/{chunk-74BFRAQS.cjs → chunk-SQ6FNXU2.cjs} +3 -3
- package/dist/{chunk-74BFRAQS.cjs.map → chunk-SQ6FNXU2.cjs.map} +1 -1
- package/dist/{chunk-LTJ7P7RT.cjs → chunk-SXXTQETM.cjs} +126 -124
- package/dist/chunk-SXXTQETM.cjs.map +1 -0
- package/dist/{chunk-56PLLVDG.cjs → chunk-T3Q5V33G.cjs} +2 -2
- package/dist/{chunk-56PLLVDG.cjs.map → chunk-T3Q5V33G.cjs.map} +1 -1
- package/dist/{chunk-RYRNZYND.js → chunk-XXDFQERJ.js} +12 -11
- package/dist/chunk-XXDFQERJ.js.map +1 -0
- package/dist/index.cjs +155 -145
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +24 -14
- package/dist/index.js.map +1 -1
- package/dist/middleware.cjs +32 -32
- package/dist/middleware.js +3 -3
- package/dist/migrations-IYNTWDC6.cjs +13 -0
- package/dist/{migrations-CW2IT5YP.cjs.map → migrations-IYNTWDC6.cjs.map} +1 -1
- package/dist/migrations-R337UD46.js +4 -0
- package/dist/{migrations-S42BOXI4.js.map → migrations-R337UD46.js.map} +1 -1
- package/dist/routes.cjs +28 -28
- package/dist/routes.js +5 -5
- package/dist/services.cjs +23 -23
- package/dist/services.js +2 -2
- package/dist/utils.cjs +11 -11
- package/dist/utils.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-LTJ7P7RT.cjs.map +0 -1
- package/dist/chunk-RYRNZYND.js.map +0 -1
- package/dist/migrations-CW2IT5YP.cjs +0 -13
- package/dist/migrations-S42BOXI4.js +0 -4
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkWAEQXGCX_cjs = require('./chunk-WAEQXGCX.cjs');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
4
|
+
var chunkDSUJ5YQH_cjs = require('./chunk-DSUJ5YQH.cjs');
|
|
5
|
+
var chunkT3Q5V33G_cjs = require('./chunk-T3Q5V33G.cjs');
|
|
6
|
+
var chunkC54YUA23_cjs = require('./chunk-C54YUA23.cjs');
|
|
7
7
|
var chunkOHYBNCVL_cjs = require('./chunk-OHYBNCVL.cjs');
|
|
8
8
|
var chunkUYJ6TJHX_cjs = require('./chunk-UYJ6TJHX.cjs');
|
|
9
9
|
var chunk635JAMSE_cjs = require('./chunk-635JAMSE.cjs');
|
|
10
|
-
var
|
|
10
|
+
var chunkSQ6FNXU2_cjs = require('./chunk-SQ6FNXU2.cjs');
|
|
11
11
|
var chunkRCQ2HIQD_cjs = require('./chunk-RCQ2HIQD.cjs');
|
|
12
12
|
var chunkMNWKYY5E_cjs = require('./chunk-MNWKYY5E.cjs');
|
|
13
13
|
var hono = require('hono');
|
|
@@ -189,7 +189,7 @@ apiContentCrudRoutes.get("/:id", async (c) => {
|
|
|
189
189
|
}, 500);
|
|
190
190
|
}
|
|
191
191
|
});
|
|
192
|
-
apiContentCrudRoutes.post("/",
|
|
192
|
+
apiContentCrudRoutes.post("/", chunkDSUJ5YQH_cjs.requireAuth(), chunkDSUJ5YQH_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
193
193
|
try {
|
|
194
194
|
const db = c.env.DB;
|
|
195
195
|
const user = c.get("user");
|
|
@@ -255,7 +255,7 @@ apiContentCrudRoutes.post("/", chunk3XP76LM7_cjs.requireAuth(), chunk3XP76LM7_cj
|
|
|
255
255
|
}, 500);
|
|
256
256
|
}
|
|
257
257
|
});
|
|
258
|
-
apiContentCrudRoutes.put("/:id",
|
|
258
|
+
apiContentCrudRoutes.put("/:id", chunkDSUJ5YQH_cjs.requireAuth(), chunkDSUJ5YQH_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
259
259
|
try {
|
|
260
260
|
const id = c.req.param("id");
|
|
261
261
|
const db = c.env.DB;
|
|
@@ -319,7 +319,7 @@ apiContentCrudRoutes.put("/:id", chunk3XP76LM7_cjs.requireAuth(), chunk3XP76LM7_
|
|
|
319
319
|
}, 500);
|
|
320
320
|
}
|
|
321
321
|
});
|
|
322
|
-
apiContentCrudRoutes.delete("/:id",
|
|
322
|
+
apiContentCrudRoutes.delete("/:id", chunkDSUJ5YQH_cjs.requireAuth(), chunkDSUJ5YQH_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
323
323
|
try {
|
|
324
324
|
const id = c.req.param("id");
|
|
325
325
|
const db = c.env.DB;
|
|
@@ -355,7 +355,7 @@ apiRoutes.use("*", async (c, next) => {
|
|
|
355
355
|
c.header("X-Response-Time", `${totalTime}ms`);
|
|
356
356
|
});
|
|
357
357
|
apiRoutes.use("*", async (c, next) => {
|
|
358
|
-
const cacheEnabled = await
|
|
358
|
+
const cacheEnabled = await chunkDSUJ5YQH_cjs.isPluginActive(c.env.DB, "core-cache");
|
|
359
359
|
c.set("cacheEnabled", cacheEnabled);
|
|
360
360
|
await next();
|
|
361
361
|
});
|
|
@@ -846,7 +846,7 @@ apiRoutes.get("/collections", async (c) => {
|
|
|
846
846
|
return c.json({ error: "Failed to fetch collections" }, 500);
|
|
847
847
|
}
|
|
848
848
|
});
|
|
849
|
-
apiRoutes.get("/content",
|
|
849
|
+
apiRoutes.get("/content", chunkDSUJ5YQH_cjs.optionalAuth(), async (c) => {
|
|
850
850
|
const executionStart = Date.now();
|
|
851
851
|
try {
|
|
852
852
|
const db = c.env.DB;
|
|
@@ -869,13 +869,13 @@ apiRoutes.get("/content", chunk3XP76LM7_cjs.optionalAuth(), async (c) => {
|
|
|
869
869
|
});
|
|
870
870
|
}
|
|
871
871
|
}
|
|
872
|
-
const filter =
|
|
872
|
+
const filter = chunkSQ6FNXU2_cjs.QueryFilterBuilder.parseFromQuery(queryParams);
|
|
873
873
|
const normalizedFilter = normalizePublicContentFilter(filter, c.get("user")?.role);
|
|
874
874
|
if (!normalizedFilter.limit) {
|
|
875
875
|
normalizedFilter.limit = 50;
|
|
876
876
|
}
|
|
877
877
|
normalizedFilter.limit = Math.min(normalizedFilter.limit, 1e3);
|
|
878
|
-
const builder3 = new
|
|
878
|
+
const builder3 = new chunkSQ6FNXU2_cjs.QueryFilterBuilder();
|
|
879
879
|
const queryResult = builder3.build("content", normalizedFilter);
|
|
880
880
|
if (queryResult.errors.length > 0) {
|
|
881
881
|
return c.json({
|
|
@@ -947,7 +947,7 @@ apiRoutes.get("/content", chunk3XP76LM7_cjs.optionalAuth(), async (c) => {
|
|
|
947
947
|
}, 500);
|
|
948
948
|
}
|
|
949
949
|
});
|
|
950
|
-
apiRoutes.get("/collections/:collection/content",
|
|
950
|
+
apiRoutes.get("/collections/:collection/content", chunkDSUJ5YQH_cjs.optionalAuth(), async (c) => {
|
|
951
951
|
const executionStart = Date.now();
|
|
952
952
|
try {
|
|
953
953
|
const collection = c.req.param("collection");
|
|
@@ -958,7 +958,7 @@ apiRoutes.get("/collections/:collection/content", chunk3XP76LM7_cjs.optionalAuth
|
|
|
958
958
|
if (!collectionResult) {
|
|
959
959
|
return c.json({ error: "Collection not found" }, 404);
|
|
960
960
|
}
|
|
961
|
-
const filter =
|
|
961
|
+
const filter = chunkSQ6FNXU2_cjs.QueryFilterBuilder.parseFromQuery(queryParams);
|
|
962
962
|
const normalizedFilter = normalizePublicContentFilter(filter, c.get("user")?.role);
|
|
963
963
|
if (!normalizedFilter.where) {
|
|
964
964
|
normalizedFilter.where = { and: [] };
|
|
@@ -975,7 +975,7 @@ apiRoutes.get("/collections/:collection/content", chunk3XP76LM7_cjs.optionalAuth
|
|
|
975
975
|
normalizedFilter.limit = 50;
|
|
976
976
|
}
|
|
977
977
|
normalizedFilter.limit = Math.min(normalizedFilter.limit, 1e3);
|
|
978
|
-
const builder3 = new
|
|
978
|
+
const builder3 = new chunkSQ6FNXU2_cjs.QueryFilterBuilder();
|
|
979
979
|
const queryResult = builder3.build("content", normalizedFilter);
|
|
980
980
|
if (queryResult.errors.length > 0) {
|
|
981
981
|
return c.json({
|
|
@@ -1096,7 +1096,7 @@ var fileValidationSchema = zod.z.object({
|
|
|
1096
1096
|
// 50MB max
|
|
1097
1097
|
});
|
|
1098
1098
|
var apiMediaRoutes = new hono.Hono();
|
|
1099
|
-
apiMediaRoutes.use("*",
|
|
1099
|
+
apiMediaRoutes.use("*", chunkDSUJ5YQH_cjs.requireAuth());
|
|
1100
1100
|
apiMediaRoutes.post("/upload", async (c) => {
|
|
1101
1101
|
try {
|
|
1102
1102
|
const user = c.get("user");
|
|
@@ -1840,8 +1840,8 @@ apiSystemRoutes.get("/env", (c) => {
|
|
|
1840
1840
|
});
|
|
1841
1841
|
var api_system_default = apiSystemRoutes;
|
|
1842
1842
|
var adminApiRoutes = new hono.Hono();
|
|
1843
|
-
adminApiRoutes.use("*",
|
|
1844
|
-
adminApiRoutes.use("*",
|
|
1843
|
+
adminApiRoutes.use("*", chunkDSUJ5YQH_cjs.requireAuth());
|
|
1844
|
+
adminApiRoutes.use("*", chunkDSUJ5YQH_cjs.requireRole(["admin", "editor"]));
|
|
1845
1845
|
adminApiRoutes.get("/stats", async (c) => {
|
|
1846
1846
|
try {
|
|
1847
1847
|
const db = c.env.DB;
|
|
@@ -2353,7 +2353,7 @@ adminApiRoutes.delete("/collections/:id", async (c) => {
|
|
|
2353
2353
|
});
|
|
2354
2354
|
adminApiRoutes.get("/migrations/status", async (c) => {
|
|
2355
2355
|
try {
|
|
2356
|
-
const { MigrationService: MigrationService2 } = await import('./migrations-
|
|
2356
|
+
const { MigrationService: MigrationService2 } = await import('./migrations-IYNTWDC6.cjs');
|
|
2357
2357
|
const db = c.env.DB;
|
|
2358
2358
|
const migrationService = new MigrationService2(db);
|
|
2359
2359
|
const status = await migrationService.getMigrationStatus();
|
|
@@ -2378,7 +2378,7 @@ adminApiRoutes.post("/migrations/run", async (c) => {
|
|
|
2378
2378
|
error: "Unauthorized. Admin access required."
|
|
2379
2379
|
}, 403);
|
|
2380
2380
|
}
|
|
2381
|
-
const { MigrationService: MigrationService2 } = await import('./migrations-
|
|
2381
|
+
const { MigrationService: MigrationService2 } = await import('./migrations-IYNTWDC6.cjs');
|
|
2382
2382
|
const db = c.env.DB;
|
|
2383
2383
|
const migrationService = new MigrationService2(db);
|
|
2384
2384
|
const result = await migrationService.runPendingMigrations();
|
|
@@ -2400,7 +2400,7 @@ adminApiRoutes.post("/migrations/run", async (c) => {
|
|
|
2400
2400
|
});
|
|
2401
2401
|
adminApiRoutes.get("/migrations/validate", async (c) => {
|
|
2402
2402
|
try {
|
|
2403
|
-
const { MigrationService: MigrationService2 } = await import('./migrations-
|
|
2403
|
+
const { MigrationService: MigrationService2 } = await import('./migrations-IYNTWDC6.cjs');
|
|
2404
2404
|
const db = c.env.DB;
|
|
2405
2405
|
const migrationService = new MigrationService2(db);
|
|
2406
2406
|
const validation = await migrationService.validateSchema();
|
|
@@ -5153,8 +5153,8 @@ var JWT_SECRET_FALLBACK = "your-super-secret-jwt-key-change-in-production";
|
|
|
5153
5153
|
async function setCsrfCookie(c, maxAge) {
|
|
5154
5154
|
const secret = c.env?.JWT_SECRET || JWT_SECRET_FALLBACK;
|
|
5155
5155
|
const isDev = c.env?.ENVIRONMENT === "development" || !c.env?.ENVIRONMENT;
|
|
5156
|
-
const csrfToken = await
|
|
5157
|
-
const cookieMaxAge = await
|
|
5156
|
+
const csrfToken = await chunkDSUJ5YQH_cjs.generateCsrfToken(secret);
|
|
5157
|
+
const cookieMaxAge = await chunkDSUJ5YQH_cjs.getJwtExpirySecondsFromDb(c.env?.DB, c.env);
|
|
5158
5158
|
cookie.setCookie(c, "csrf_token", csrfToken, {
|
|
5159
5159
|
httpOnly: false,
|
|
5160
5160
|
secure: !isDev,
|
|
@@ -5211,7 +5211,7 @@ var loginSchema = zod.z.object({
|
|
|
5211
5211
|
});
|
|
5212
5212
|
authRoutes.post(
|
|
5213
5213
|
"/register",
|
|
5214
|
-
|
|
5214
|
+
chunkDSUJ5YQH_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "register" }),
|
|
5215
5215
|
async (c) => {
|
|
5216
5216
|
try {
|
|
5217
5217
|
const db = c.env.DB;
|
|
@@ -5248,7 +5248,7 @@ authRoutes.post(
|
|
|
5248
5248
|
if (existingUser) {
|
|
5249
5249
|
return c.json({ error: "User with this email or username already exists" }, 400);
|
|
5250
5250
|
}
|
|
5251
|
-
const passwordHash = await
|
|
5251
|
+
const passwordHash = await chunkDSUJ5YQH_cjs.AuthManager.hashPassword(password);
|
|
5252
5252
|
const userId = crypto.randomUUID();
|
|
5253
5253
|
const now = /* @__PURE__ */ new Date();
|
|
5254
5254
|
await db.prepare(`
|
|
@@ -5282,8 +5282,8 @@ authRoutes.post(
|
|
|
5282
5282
|
await saveCustomData(db, userId, sanitized);
|
|
5283
5283
|
}
|
|
5284
5284
|
}
|
|
5285
|
-
const tokenTtl = await
|
|
5286
|
-
const token = await
|
|
5285
|
+
const tokenTtl = await chunkDSUJ5YQH_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
|
|
5286
|
+
const token = await chunkDSUJ5YQH_cjs.AuthManager.generateToken(userId, normalizedEmail, "viewer", c.env.JWT_SECRET, tokenTtl);
|
|
5287
5287
|
cookie.setCookie(c, "auth_token", token, {
|
|
5288
5288
|
httpOnly: true,
|
|
5289
5289
|
secure: true,
|
|
@@ -5316,7 +5316,7 @@ authRoutes.post(
|
|
|
5316
5316
|
);
|
|
5317
5317
|
authRoutes.post(
|
|
5318
5318
|
"/login",
|
|
5319
|
-
|
|
5319
|
+
chunkDSUJ5YQH_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "login" }),
|
|
5320
5320
|
async (c) => {
|
|
5321
5321
|
try {
|
|
5322
5322
|
const body = await c.req.json();
|
|
@@ -5339,20 +5339,20 @@ authRoutes.post(
|
|
|
5339
5339
|
if (!user) {
|
|
5340
5340
|
return c.json({ error: "Invalid email or password" }, 401);
|
|
5341
5341
|
}
|
|
5342
|
-
const isValidPassword = await
|
|
5342
|
+
const isValidPassword = await chunkDSUJ5YQH_cjs.AuthManager.verifyPassword(password, user.password_hash);
|
|
5343
5343
|
if (!isValidPassword) {
|
|
5344
5344
|
return c.json({ error: "Invalid email or password" }, 401);
|
|
5345
5345
|
}
|
|
5346
|
-
if (
|
|
5346
|
+
if (chunkDSUJ5YQH_cjs.AuthManager.isLegacyHash(user.password_hash)) {
|
|
5347
5347
|
try {
|
|
5348
|
-
const newHash = await
|
|
5348
|
+
const newHash = await chunkDSUJ5YQH_cjs.AuthManager.hashPassword(password);
|
|
5349
5349
|
await db.prepare("UPDATE users SET password_hash = ?, updated_at = ? WHERE id = ?").bind(newHash, Date.now(), user.id).run();
|
|
5350
5350
|
} catch (rehashError) {
|
|
5351
5351
|
console.error("Password rehash failed (non-fatal):", rehashError);
|
|
5352
5352
|
}
|
|
5353
5353
|
}
|
|
5354
|
-
const tokenTtl = await
|
|
5355
|
-
const token = await
|
|
5354
|
+
const tokenTtl = await chunkDSUJ5YQH_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
|
|
5355
|
+
const token = await chunkDSUJ5YQH_cjs.AuthManager.generateToken(user.id, user.email, user.role, c.env.JWT_SECRET, tokenTtl);
|
|
5356
5356
|
cookie.setCookie(c, "auth_token", token, {
|
|
5357
5357
|
httpOnly: true,
|
|
5358
5358
|
secure: true,
|
|
@@ -5404,7 +5404,7 @@ authRoutes.get("/logout", (c) => {
|
|
|
5404
5404
|
clearCsrfCookie(c);
|
|
5405
5405
|
return c.redirect("/auth/login?message=You have been logged out successfully");
|
|
5406
5406
|
});
|
|
5407
|
-
authRoutes.get("/me",
|
|
5407
|
+
authRoutes.get("/me", chunkDSUJ5YQH_cjs.requireAuth(), async (c) => {
|
|
5408
5408
|
try {
|
|
5409
5409
|
const user = c.get("user");
|
|
5410
5410
|
if (!user) {
|
|
@@ -5415,7 +5415,8 @@ authRoutes.get("/me", chunk3XP76LM7_cjs.requireAuth(), async (c) => {
|
|
|
5415
5415
|
if (!userData) {
|
|
5416
5416
|
return c.json({ error: "User not found" }, 404);
|
|
5417
5417
|
}
|
|
5418
|
-
|
|
5418
|
+
const customData = await getCustomData(db, user.userId);
|
|
5419
|
+
return c.json({ user: { ...userData, ...customData } });
|
|
5419
5420
|
} catch (error) {
|
|
5420
5421
|
console.error("Get user error:", error);
|
|
5421
5422
|
return c.json({ error: "Failed to get user" }, 500);
|
|
@@ -5423,7 +5424,7 @@ authRoutes.get("/me", chunk3XP76LM7_cjs.requireAuth(), async (c) => {
|
|
|
5423
5424
|
});
|
|
5424
5425
|
authRoutes.post(
|
|
5425
5426
|
"/refresh",
|
|
5426
|
-
|
|
5427
|
+
chunkDSUJ5YQH_cjs.rateLimit({ max: 60, windowMs: 60 * 1e3, keyPrefix: "refresh" }),
|
|
5427
5428
|
async (c) => {
|
|
5428
5429
|
try {
|
|
5429
5430
|
let token = c.req.header("Authorization")?.replace("Bearer ", "");
|
|
@@ -5432,8 +5433,8 @@ authRoutes.post(
|
|
|
5432
5433
|
return c.json({ error: "Authentication required" }, 401);
|
|
5433
5434
|
}
|
|
5434
5435
|
const db = c.env.DB;
|
|
5435
|
-
const grace = await
|
|
5436
|
-
const payload = await
|
|
5436
|
+
const grace = await chunkDSUJ5YQH_cjs.getJwtRefreshGraceSecondsFromDb(db, c.env);
|
|
5437
|
+
const payload = await chunkDSUJ5YQH_cjs.AuthManager.verifyToken(token, c.env.JWT_SECRET, grace);
|
|
5437
5438
|
if (!payload) {
|
|
5438
5439
|
return c.json({ error: "Invalid or expired token" }, 401);
|
|
5439
5440
|
}
|
|
@@ -5441,8 +5442,8 @@ authRoutes.post(
|
|
|
5441
5442
|
if (!row || !row.is_active) {
|
|
5442
5443
|
return c.json({ error: "User is not active" }, 401);
|
|
5443
5444
|
}
|
|
5444
|
-
const tokenTtl = await
|
|
5445
|
-
const newToken = await
|
|
5445
|
+
const tokenTtl = await chunkDSUJ5YQH_cjs.getJwtExpirySecondsFromDb(db, c.env);
|
|
5446
|
+
const newToken = await chunkDSUJ5YQH_cjs.AuthManager.generateToken(row.id, row.email, row.role, c.env.JWT_SECRET, tokenTtl);
|
|
5446
5447
|
cookie.setCookie(c, "auth_token", newToken, {
|
|
5447
5448
|
httpOnly: true,
|
|
5448
5449
|
secure: true,
|
|
@@ -5462,7 +5463,7 @@ authRoutes.post(
|
|
|
5462
5463
|
);
|
|
5463
5464
|
authRoutes.post(
|
|
5464
5465
|
"/register/form",
|
|
5465
|
-
|
|
5466
|
+
chunkDSUJ5YQH_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "register" }),
|
|
5466
5467
|
async (c) => {
|
|
5467
5468
|
try {
|
|
5468
5469
|
const db = c.env.DB;
|
|
@@ -5509,7 +5510,7 @@ authRoutes.post(
|
|
|
5509
5510
|
</div>
|
|
5510
5511
|
`);
|
|
5511
5512
|
}
|
|
5512
|
-
const passwordHash = await
|
|
5513
|
+
const passwordHash = await chunkDSUJ5YQH_cjs.AuthManager.hashPassword(password);
|
|
5513
5514
|
const role = isFirstUser ? "admin" : "viewer";
|
|
5514
5515
|
const userId = crypto.randomUUID();
|
|
5515
5516
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -5544,8 +5545,8 @@ authRoutes.post(
|
|
|
5544
5545
|
await saveCustomData(db, userId, sanitized);
|
|
5545
5546
|
}
|
|
5546
5547
|
}
|
|
5547
|
-
const tokenTtl = await
|
|
5548
|
-
const token = await
|
|
5548
|
+
const tokenTtl = await chunkDSUJ5YQH_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
|
|
5549
|
+
const token = await chunkDSUJ5YQH_cjs.AuthManager.generateToken(userId, normalizedEmail, role, c.env.JWT_SECRET, tokenTtl);
|
|
5549
5550
|
cookie.setCookie(c, "auth_token", token, {
|
|
5550
5551
|
httpOnly: true,
|
|
5551
5552
|
secure: false,
|
|
@@ -5577,7 +5578,7 @@ authRoutes.post(
|
|
|
5577
5578
|
);
|
|
5578
5579
|
authRoutes.post(
|
|
5579
5580
|
"/login/form",
|
|
5580
|
-
|
|
5581
|
+
chunkDSUJ5YQH_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "login" }),
|
|
5581
5582
|
async (c) => {
|
|
5582
5583
|
try {
|
|
5583
5584
|
const formData = await c.req.formData();
|
|
@@ -5601,7 +5602,7 @@ authRoutes.post(
|
|
|
5601
5602
|
</div>
|
|
5602
5603
|
`);
|
|
5603
5604
|
}
|
|
5604
|
-
const isValidPassword = await
|
|
5605
|
+
const isValidPassword = await chunkDSUJ5YQH_cjs.AuthManager.verifyPassword(password, user.password_hash);
|
|
5605
5606
|
if (!isValidPassword) {
|
|
5606
5607
|
return c.html(html.html`
|
|
5607
5608
|
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded">
|
|
@@ -5609,16 +5610,16 @@ authRoutes.post(
|
|
|
5609
5610
|
</div>
|
|
5610
5611
|
`);
|
|
5611
5612
|
}
|
|
5612
|
-
if (
|
|
5613
|
+
if (chunkDSUJ5YQH_cjs.AuthManager.isLegacyHash(user.password_hash)) {
|
|
5613
5614
|
try {
|
|
5614
|
-
const newHash = await
|
|
5615
|
+
const newHash = await chunkDSUJ5YQH_cjs.AuthManager.hashPassword(password);
|
|
5615
5616
|
await db.prepare("UPDATE users SET password_hash = ?, updated_at = ? WHERE id = ?").bind(newHash, Date.now(), user.id).run();
|
|
5616
5617
|
} catch (rehashError) {
|
|
5617
5618
|
console.error("Password rehash failed (non-fatal):", rehashError);
|
|
5618
5619
|
}
|
|
5619
5620
|
}
|
|
5620
|
-
const tokenTtl = await
|
|
5621
|
-
const token = await
|
|
5621
|
+
const tokenTtl = await chunkDSUJ5YQH_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
|
|
5622
|
+
const token = await chunkDSUJ5YQH_cjs.AuthManager.generateToken(user.id, user.email, user.role, c.env.JWT_SECRET, tokenTtl);
|
|
5622
5623
|
cookie.setCookie(c, "auth_token", token, {
|
|
5623
5624
|
httpOnly: true,
|
|
5624
5625
|
secure: false,
|
|
@@ -5659,7 +5660,7 @@ authRoutes.post(
|
|
|
5659
5660
|
);
|
|
5660
5661
|
authRoutes.post(
|
|
5661
5662
|
"/seed-admin",
|
|
5662
|
-
|
|
5663
|
+
chunkDSUJ5YQH_cjs.rateLimit({ max: 10, windowMs: 60 * 1e3, keyPrefix: "seed-admin" }),
|
|
5663
5664
|
async (c) => {
|
|
5664
5665
|
try {
|
|
5665
5666
|
const db = c.env.DB;
|
|
@@ -5681,7 +5682,7 @@ authRoutes.post(
|
|
|
5681
5682
|
`).run();
|
|
5682
5683
|
const existingAdmin = await db.prepare("SELECT id FROM users WHERE email = ? OR username = ?").bind("admin@sonicjs.com", "admin").first();
|
|
5683
5684
|
if (existingAdmin) {
|
|
5684
|
-
const passwordHash2 = await
|
|
5685
|
+
const passwordHash2 = await chunkDSUJ5YQH_cjs.AuthManager.hashPassword("sonicjs!");
|
|
5685
5686
|
await db.prepare("UPDATE users SET password_hash = ?, updated_at = ? WHERE id = ?").bind(passwordHash2, Date.now(), existingAdmin.id).run();
|
|
5686
5687
|
return c.json({
|
|
5687
5688
|
message: "Admin user already exists (password updated)",
|
|
@@ -5693,7 +5694,7 @@ authRoutes.post(
|
|
|
5693
5694
|
}
|
|
5694
5695
|
});
|
|
5695
5696
|
}
|
|
5696
|
-
const passwordHash = await
|
|
5697
|
+
const passwordHash = await chunkDSUJ5YQH_cjs.AuthManager.hashPassword("sonicjs!");
|
|
5697
5698
|
const userId = "admin-user-id";
|
|
5698
5699
|
const now = Date.now();
|
|
5699
5700
|
const adminEmail = "admin@sonicjs.com".toLowerCase();
|
|
@@ -5914,7 +5915,7 @@ authRoutes.post("/accept-invitation", async (c) => {
|
|
|
5914
5915
|
if (existingUsername) {
|
|
5915
5916
|
return c.json({ error: "Username is already taken" }, 400);
|
|
5916
5917
|
}
|
|
5917
|
-
const passwordHash = await
|
|
5918
|
+
const passwordHash = await chunkDSUJ5YQH_cjs.AuthManager.hashPassword(password);
|
|
5918
5919
|
const updateStmt = db.prepare(`
|
|
5919
5920
|
UPDATE users SET
|
|
5920
5921
|
username = ?,
|
|
@@ -5933,8 +5934,8 @@ authRoutes.post("/accept-invitation", async (c) => {
|
|
|
5933
5934
|
Date.now(),
|
|
5934
5935
|
invitedUser.id
|
|
5935
5936
|
).run();
|
|
5936
|
-
const tokenTtl = await
|
|
5937
|
-
const authToken = await
|
|
5937
|
+
const tokenTtl = await chunkDSUJ5YQH_cjs.getJwtExpirySecondsFromDb(c.env.DB, c.env);
|
|
5938
|
+
const authToken = await chunkDSUJ5YQH_cjs.AuthManager.generateToken(invitedUser.id, invitedUser.email, invitedUser.role, c.env.JWT_SECRET, tokenTtl);
|
|
5938
5939
|
cookie.setCookie(c, "auth_token", authToken, {
|
|
5939
5940
|
httpOnly: true,
|
|
5940
5941
|
secure: true,
|
|
@@ -5950,7 +5951,7 @@ authRoutes.post("/accept-invitation", async (c) => {
|
|
|
5950
5951
|
});
|
|
5951
5952
|
authRoutes.post(
|
|
5952
5953
|
"/request-password-reset",
|
|
5953
|
-
|
|
5954
|
+
chunkDSUJ5YQH_cjs.rateLimit({ max: 3, windowMs: 15 * 60 * 1e3, keyPrefix: "password-reset" }),
|
|
5954
5955
|
async (c) => {
|
|
5955
5956
|
try {
|
|
5956
5957
|
const formData = await c.req.formData();
|
|
@@ -6168,7 +6169,7 @@ authRoutes.post("/reset-password", async (c) => {
|
|
|
6168
6169
|
if (Date.now() > user.password_reset_expires) {
|
|
6169
6170
|
return c.json({ error: "Reset token has expired" }, 400);
|
|
6170
6171
|
}
|
|
6171
|
-
const newPasswordHash = await
|
|
6172
|
+
const newPasswordHash = await chunkDSUJ5YQH_cjs.AuthManager.hashPassword(password);
|
|
6172
6173
|
try {
|
|
6173
6174
|
const historyStmt = db.prepare(`
|
|
6174
6175
|
INSERT INTO password_history (id, user_id, password_hash, created_at)
|
|
@@ -9544,9 +9545,9 @@ function parseFieldValue(field, formData, options = {}) {
|
|
|
9544
9545
|
const { skipValidation = false } = options;
|
|
9545
9546
|
const value = formData.get(field.field_name);
|
|
9546
9547
|
const errors = [];
|
|
9547
|
-
const blocksConfig =
|
|
9548
|
+
const blocksConfig = chunkSQ6FNXU2_cjs.getBlocksFieldConfig(field.field_options);
|
|
9548
9549
|
if (blocksConfig) {
|
|
9549
|
-
const parsed =
|
|
9550
|
+
const parsed = chunkSQ6FNXU2_cjs.parseBlocksValue(value, blocksConfig);
|
|
9550
9551
|
if (!skipValidation && field.is_required && parsed.value.length === 0) {
|
|
9551
9552
|
parsed.errors.push(`${field.field_label} is required`);
|
|
9552
9553
|
}
|
|
@@ -9656,7 +9657,7 @@ function extractFieldData(fields, formData, options = {}) {
|
|
|
9656
9657
|
}
|
|
9657
9658
|
return { data, errors };
|
|
9658
9659
|
}
|
|
9659
|
-
adminContentRoutes.use("*",
|
|
9660
|
+
adminContentRoutes.use("*", chunkDSUJ5YQH_cjs.requireAuth());
|
|
9660
9661
|
async function getCollectionFields(db, collectionId) {
|
|
9661
9662
|
const cache = chunkWAEQXGCX_cjs.getCacheService(chunkWAEQXGCX_cjs.CACHE_CONFIGS.collection);
|
|
9662
9663
|
return cache.getOrSet(
|
|
@@ -9933,21 +9934,21 @@ adminContentRoutes.get("/new", async (c) => {
|
|
|
9933
9934
|
const tinymceEnabled = await isPluginActive2(db, "tinymce-plugin");
|
|
9934
9935
|
let tinymceSettings;
|
|
9935
9936
|
if (tinymceEnabled) {
|
|
9936
|
-
const pluginService = new
|
|
9937
|
+
const pluginService = new chunkT3Q5V33G_cjs.PluginService(db);
|
|
9937
9938
|
const tinymcePlugin2 = await pluginService.getPlugin("tinymce-plugin");
|
|
9938
9939
|
tinymceSettings = tinymcePlugin2?.settings;
|
|
9939
9940
|
}
|
|
9940
9941
|
const quillEnabled = await isPluginActive2(db, "quill-editor");
|
|
9941
9942
|
let quillSettings;
|
|
9942
9943
|
if (quillEnabled) {
|
|
9943
|
-
const pluginService = new
|
|
9944
|
+
const pluginService = new chunkT3Q5V33G_cjs.PluginService(db);
|
|
9944
9945
|
const quillPlugin = await pluginService.getPlugin("quill-editor");
|
|
9945
9946
|
quillSettings = quillPlugin?.settings;
|
|
9946
9947
|
}
|
|
9947
9948
|
const mdxeditorEnabled = await isPluginActive2(db, "easy-mdx");
|
|
9948
9949
|
let mdxeditorSettings;
|
|
9949
9950
|
if (mdxeditorEnabled) {
|
|
9950
|
-
const pluginService = new
|
|
9951
|
+
const pluginService = new chunkT3Q5V33G_cjs.PluginService(db);
|
|
9951
9952
|
const mdxeditorPlugin = await pluginService.getPlugin("easy-mdx");
|
|
9952
9953
|
mdxeditorSettings = mdxeditorPlugin?.settings;
|
|
9953
9954
|
}
|
|
@@ -10038,21 +10039,21 @@ adminContentRoutes.get("/:id/edit", async (c) => {
|
|
|
10038
10039
|
const tinymceEnabled = await isPluginActive2(db, "tinymce-plugin");
|
|
10039
10040
|
let tinymceSettings;
|
|
10040
10041
|
if (tinymceEnabled) {
|
|
10041
|
-
const pluginService = new
|
|
10042
|
+
const pluginService = new chunkT3Q5V33G_cjs.PluginService(db);
|
|
10042
10043
|
const tinymcePlugin2 = await pluginService.getPlugin("tinymce-plugin");
|
|
10043
10044
|
tinymceSettings = tinymcePlugin2?.settings;
|
|
10044
10045
|
}
|
|
10045
10046
|
const quillEnabled = await isPluginActive2(db, "quill-editor");
|
|
10046
10047
|
let quillSettings;
|
|
10047
10048
|
if (quillEnabled) {
|
|
10048
|
-
const pluginService = new
|
|
10049
|
+
const pluginService = new chunkT3Q5V33G_cjs.PluginService(db);
|
|
10049
10050
|
const quillPlugin = await pluginService.getPlugin("quill-editor");
|
|
10050
10051
|
quillSettings = quillPlugin?.settings;
|
|
10051
10052
|
}
|
|
10052
10053
|
const mdxeditorEnabled = await isPluginActive2(db, "easy-mdx");
|
|
10053
10054
|
let mdxeditorSettings;
|
|
10054
10055
|
if (mdxeditorEnabled) {
|
|
10055
|
-
const pluginService = new
|
|
10056
|
+
const pluginService = new chunkT3Q5V33G_cjs.PluginService(db);
|
|
10056
10057
|
const mdxeditorPlugin = await pluginService.getPlugin("easy-mdx");
|
|
10057
10058
|
mdxeditorSettings = mdxeditorPlugin?.settings;
|
|
10058
10059
|
}
|
|
@@ -10347,7 +10348,7 @@ adminContentRoutes.put("/:id", async (c) => {
|
|
|
10347
10348
|
`);
|
|
10348
10349
|
}
|
|
10349
10350
|
});
|
|
10350
|
-
adminContentRoutes.post("/preview",
|
|
10351
|
+
adminContentRoutes.post("/preview", chunkDSUJ5YQH_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
10351
10352
|
try {
|
|
10352
10353
|
const formData = await c.req.formData();
|
|
10353
10354
|
const collectionId = formData.get("collection_id");
|
|
@@ -10725,7 +10726,7 @@ adminContentRoutes.post("/:id/restore/:version", async (c) => {
|
|
|
10725
10726
|
return c.json({ success: false, error: "Failed to restore version" });
|
|
10726
10727
|
}
|
|
10727
10728
|
});
|
|
10728
|
-
adminContentRoutes.get("/:id/version/:version/preview",
|
|
10729
|
+
adminContentRoutes.get("/:id/version/:version/preview", chunkDSUJ5YQH_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
10729
10730
|
try {
|
|
10730
10731
|
const id = c.req.param("id");
|
|
10731
10732
|
const version = parseInt(c.req.param("version") || "0");
|
|
@@ -12724,14 +12725,14 @@ function renderUsersListPage(data) {
|
|
|
12724
12725
|
|
|
12725
12726
|
// src/routes/admin-users.ts
|
|
12726
12727
|
var userRoutes = new hono.Hono();
|
|
12727
|
-
userRoutes.use("*",
|
|
12728
|
-
userRoutes.use("/users/*",
|
|
12729
|
-
userRoutes.use("/users",
|
|
12730
|
-
userRoutes.use("/invite-user",
|
|
12731
|
-
userRoutes.use("/resend-invitation/*",
|
|
12732
|
-
userRoutes.use("/cancel-invitation/*",
|
|
12733
|
-
userRoutes.use("/activity-logs",
|
|
12734
|
-
userRoutes.use("/activity-logs/*",
|
|
12728
|
+
userRoutes.use("*", chunkDSUJ5YQH_cjs.requireAuth());
|
|
12729
|
+
userRoutes.use("/users/*", chunkDSUJ5YQH_cjs.requireRole(["admin"]));
|
|
12730
|
+
userRoutes.use("/users", chunkDSUJ5YQH_cjs.requireRole(["admin"]));
|
|
12731
|
+
userRoutes.use("/invite-user", chunkDSUJ5YQH_cjs.requireRole(["admin"]));
|
|
12732
|
+
userRoutes.use("/resend-invitation/*", chunkDSUJ5YQH_cjs.requireRole(["admin"]));
|
|
12733
|
+
userRoutes.use("/cancel-invitation/*", chunkDSUJ5YQH_cjs.requireRole(["admin"]));
|
|
12734
|
+
userRoutes.use("/activity-logs", chunkDSUJ5YQH_cjs.requireRole(["admin"]));
|
|
12735
|
+
userRoutes.use("/activity-logs/*", chunkDSUJ5YQH_cjs.requireRole(["admin"]));
|
|
12735
12736
|
userRoutes.get("/", (c) => {
|
|
12736
12737
|
return c.redirect("/admin/dashboard");
|
|
12737
12738
|
});
|
|
@@ -12901,7 +12902,7 @@ userRoutes.put("/profile", async (c) => {
|
|
|
12901
12902
|
}
|
|
12902
12903
|
await saveCustomData(db, user.userId, sanitized);
|
|
12903
12904
|
}
|
|
12904
|
-
await
|
|
12905
|
+
await chunkDSUJ5YQH_cjs.logActivity(
|
|
12905
12906
|
db,
|
|
12906
12907
|
user.userId,
|
|
12907
12908
|
"profile.update",
|
|
@@ -12964,7 +12965,7 @@ userRoutes.post("/profile/avatar", async (c) => {
|
|
|
12964
12965
|
SELECT first_name, last_name FROM users WHERE id = ?
|
|
12965
12966
|
`);
|
|
12966
12967
|
const userData = await userStmt.bind(user.userId).first();
|
|
12967
|
-
await
|
|
12968
|
+
await chunkDSUJ5YQH_cjs.logActivity(
|
|
12968
12969
|
db,
|
|
12969
12970
|
user.userId,
|
|
12970
12971
|
"profile.avatar_update",
|
|
@@ -13035,7 +13036,7 @@ userRoutes.post("/profile/password", async (c) => {
|
|
|
13035
13036
|
dismissible: true
|
|
13036
13037
|
}));
|
|
13037
13038
|
}
|
|
13038
|
-
const validPassword = await
|
|
13039
|
+
const validPassword = await chunkDSUJ5YQH_cjs.AuthManager.verifyPassword(currentPassword, userData.password_hash);
|
|
13039
13040
|
if (!validPassword) {
|
|
13040
13041
|
return c.html(renderAlert2({
|
|
13041
13042
|
type: "error",
|
|
@@ -13043,7 +13044,7 @@ userRoutes.post("/profile/password", async (c) => {
|
|
|
13043
13044
|
dismissible: true
|
|
13044
13045
|
}));
|
|
13045
13046
|
}
|
|
13046
|
-
const newPasswordHash = await
|
|
13047
|
+
const newPasswordHash = await chunkDSUJ5YQH_cjs.AuthManager.hashPassword(newPassword);
|
|
13047
13048
|
const historyStmt = db.prepare(`
|
|
13048
13049
|
INSERT INTO password_history (id, user_id, password_hash, created_at)
|
|
13049
13050
|
VALUES (?, ?, ?, ?)
|
|
@@ -13059,7 +13060,7 @@ userRoutes.post("/profile/password", async (c) => {
|
|
|
13059
13060
|
WHERE id = ?
|
|
13060
13061
|
`);
|
|
13061
13062
|
await updateStmt.bind(newPasswordHash, Date.now(), user.userId).run();
|
|
13062
|
-
await
|
|
13063
|
+
await chunkDSUJ5YQH_cjs.logActivity(
|
|
13063
13064
|
db,
|
|
13064
13065
|
user.userId,
|
|
13065
13066
|
"profile.password_change",
|
|
@@ -13126,7 +13127,7 @@ userRoutes.get("/users", async (c) => {
|
|
|
13126
13127
|
`);
|
|
13127
13128
|
const countResult = await countStmt.bind(...params).first();
|
|
13128
13129
|
const totalUsers = countResult?.total || 0;
|
|
13129
|
-
await
|
|
13130
|
+
await chunkDSUJ5YQH_cjs.logActivity(
|
|
13130
13131
|
db,
|
|
13131
13132
|
user.userId,
|
|
13132
13133
|
"users.list_view",
|
|
@@ -13284,7 +13285,7 @@ userRoutes.post("/users/new", async (c) => {
|
|
|
13284
13285
|
dismissible: true
|
|
13285
13286
|
}));
|
|
13286
13287
|
}
|
|
13287
|
-
const passwordHash = await
|
|
13288
|
+
const passwordHash = await chunkDSUJ5YQH_cjs.AuthManager.hashPassword(password);
|
|
13288
13289
|
const userId = crypto.randomUUID();
|
|
13289
13290
|
const createStmt = db.prepare(`
|
|
13290
13291
|
INSERT INTO users (
|
|
@@ -13307,7 +13308,7 @@ userRoutes.post("/users/new", async (c) => {
|
|
|
13307
13308
|
Date.now(),
|
|
13308
13309
|
Date.now()
|
|
13309
13310
|
).run();
|
|
13310
|
-
await
|
|
13311
|
+
await chunkDSUJ5YQH_cjs.logActivity(
|
|
13311
13312
|
db,
|
|
13312
13313
|
user.userId,
|
|
13313
13314
|
"user!.create",
|
|
@@ -13346,7 +13347,7 @@ userRoutes.get("/users/:id", async (c) => {
|
|
|
13346
13347
|
if (!userRecord) {
|
|
13347
13348
|
return c.json({ error: "User not found" }, 404);
|
|
13348
13349
|
}
|
|
13349
|
-
await
|
|
13350
|
+
await chunkDSUJ5YQH_cjs.logActivity(
|
|
13350
13351
|
db,
|
|
13351
13352
|
user.userId,
|
|
13352
13353
|
"user!.view",
|
|
@@ -13572,7 +13573,7 @@ userRoutes.put("/users/:id", async (c) => {
|
|
|
13572
13573
|
userId
|
|
13573
13574
|
).run();
|
|
13574
13575
|
if (newPassword) {
|
|
13575
|
-
const passwordHash = await
|
|
13576
|
+
const passwordHash = await chunkDSUJ5YQH_cjs.AuthManager.hashPassword(newPassword);
|
|
13576
13577
|
const updatePasswordStmt = db.prepare(`
|
|
13577
13578
|
UPDATE users SET password_hash = ?, updated_at = ? WHERE id = ?
|
|
13578
13579
|
`);
|
|
@@ -13626,7 +13627,7 @@ userRoutes.put("/users/:id", async (c) => {
|
|
|
13626
13627
|
).run();
|
|
13627
13628
|
}
|
|
13628
13629
|
}
|
|
13629
|
-
await
|
|
13630
|
+
await chunkDSUJ5YQH_cjs.logActivity(
|
|
13630
13631
|
db,
|
|
13631
13632
|
user.userId,
|
|
13632
13633
|
"user.update",
|
|
@@ -13671,7 +13672,7 @@ userRoutes.post("/users/:id/toggle", async (c) => {
|
|
|
13671
13672
|
UPDATE users SET is_active = ?, updated_at = ? WHERE id = ?
|
|
13672
13673
|
`);
|
|
13673
13674
|
await toggleStmt.bind(active ? 1 : 0, Date.now(), userId).run();
|
|
13674
|
-
await
|
|
13675
|
+
await chunkDSUJ5YQH_cjs.logActivity(
|
|
13675
13676
|
db,
|
|
13676
13677
|
user.userId,
|
|
13677
13678
|
active ? "user.activate" : "user.deactivate",
|
|
@@ -13712,7 +13713,7 @@ userRoutes.delete("/users/:id", async (c) => {
|
|
|
13712
13713
|
DELETE FROM users WHERE id = ?
|
|
13713
13714
|
`);
|
|
13714
13715
|
await deleteStmt.bind(userId).run();
|
|
13715
|
-
await
|
|
13716
|
+
await chunkDSUJ5YQH_cjs.logActivity(
|
|
13716
13717
|
db,
|
|
13717
13718
|
user.userId,
|
|
13718
13719
|
"user!.hard_delete",
|
|
@@ -13731,7 +13732,7 @@ userRoutes.delete("/users/:id", async (c) => {
|
|
|
13731
13732
|
UPDATE users SET is_active = 0, updated_at = ? WHERE id = ?
|
|
13732
13733
|
`);
|
|
13733
13734
|
await deleteStmt.bind(Date.now(), userId).run();
|
|
13734
|
-
await
|
|
13735
|
+
await chunkDSUJ5YQH_cjs.logActivity(
|
|
13735
13736
|
db,
|
|
13736
13737
|
user.userId,
|
|
13737
13738
|
"user!.soft_delete",
|
|
@@ -13797,7 +13798,7 @@ userRoutes.post("/invite-user", async (c) => {
|
|
|
13797
13798
|
Date.now(),
|
|
13798
13799
|
Date.now()
|
|
13799
13800
|
).run();
|
|
13800
|
-
await
|
|
13801
|
+
await chunkDSUJ5YQH_cjs.logActivity(
|
|
13801
13802
|
db,
|
|
13802
13803
|
user.userId,
|
|
13803
13804
|
"user!.invite_sent",
|
|
@@ -13854,7 +13855,7 @@ userRoutes.post("/resend-invitation/:id", async (c) => {
|
|
|
13854
13855
|
Date.now(),
|
|
13855
13856
|
userId
|
|
13856
13857
|
).run();
|
|
13857
|
-
await
|
|
13858
|
+
await chunkDSUJ5YQH_cjs.logActivity(
|
|
13858
13859
|
db,
|
|
13859
13860
|
user.userId,
|
|
13860
13861
|
"user!.invitation_resent",
|
|
@@ -13890,7 +13891,7 @@ userRoutes.delete("/cancel-invitation/:id", async (c) => {
|
|
|
13890
13891
|
}
|
|
13891
13892
|
const deleteStmt = db.prepare(`DELETE FROM users WHERE id = ?`);
|
|
13892
13893
|
await deleteStmt.bind(userId).run();
|
|
13893
|
-
await
|
|
13894
|
+
await chunkDSUJ5YQH_cjs.logActivity(
|
|
13894
13895
|
db,
|
|
13895
13896
|
user.userId,
|
|
13896
13897
|
"user!.invitation_cancelled",
|
|
@@ -13973,7 +13974,7 @@ userRoutes.get("/activity-logs", async (c) => {
|
|
|
13973
13974
|
...log,
|
|
13974
13975
|
details: log.details ? JSON.parse(log.details) : null
|
|
13975
13976
|
}));
|
|
13976
|
-
await
|
|
13977
|
+
await chunkDSUJ5YQH_cjs.logActivity(
|
|
13977
13978
|
db,
|
|
13978
13979
|
user.userId,
|
|
13979
13980
|
"activity.logs_viewed",
|
|
@@ -14080,7 +14081,7 @@ userRoutes.get("/activity-logs/export", async (c) => {
|
|
|
14080
14081
|
csvRows.push(row.join(","));
|
|
14081
14082
|
}
|
|
14082
14083
|
const csvContent = csvRows.join("\n");
|
|
14083
|
-
await
|
|
14084
|
+
await chunkDSUJ5YQH_cjs.logActivity(
|
|
14084
14085
|
db,
|
|
14085
14086
|
user.userId,
|
|
14086
14087
|
"activity.logs_exported",
|
|
@@ -15419,7 +15420,7 @@ var fileValidationSchema2 = zod.z.object({
|
|
|
15419
15420
|
// 50MB max
|
|
15420
15421
|
});
|
|
15421
15422
|
var adminMediaRoutes = new hono.Hono();
|
|
15422
|
-
adminMediaRoutes.use("*",
|
|
15423
|
+
adminMediaRoutes.use("*", chunkDSUJ5YQH_cjs.requireAuth());
|
|
15423
15424
|
adminMediaRoutes.get("/", async (c) => {
|
|
15424
15425
|
try {
|
|
15425
15426
|
const user = c.get("user");
|
|
@@ -16005,7 +16006,7 @@ adminMediaRoutes.put("/:id", async (c) => {
|
|
|
16005
16006
|
`);
|
|
16006
16007
|
}
|
|
16007
16008
|
});
|
|
16008
|
-
adminMediaRoutes.delete("/cleanup",
|
|
16009
|
+
adminMediaRoutes.delete("/cleanup", chunkDSUJ5YQH_cjs.requireRole("admin"), async (c) => {
|
|
16009
16010
|
try {
|
|
16010
16011
|
const db = c.env.DB;
|
|
16011
16012
|
const allMediaStmt = db.prepare("SELECT id, r2_key, filename FROM media WHERE deleted_at IS NULL");
|
|
@@ -18348,8 +18349,8 @@ function renderEmailSettingsContent(plugin, settings) {
|
|
|
18348
18349
|
|
|
18349
18350
|
// src/routes/admin-plugins.ts
|
|
18350
18351
|
var adminPluginRoutes = new hono.Hono();
|
|
18351
|
-
adminPluginRoutes.use("*",
|
|
18352
|
-
var AVAILABLE_PLUGINS = Object.values(
|
|
18352
|
+
adminPluginRoutes.use("*", chunkDSUJ5YQH_cjs.requireAuth());
|
|
18353
|
+
var AVAILABLE_PLUGINS = Object.values(chunkT3Q5V33G_cjs.PLUGIN_REGISTRY).map((p) => ({
|
|
18353
18354
|
id: p.id,
|
|
18354
18355
|
name: p.codeName,
|
|
18355
18356
|
display_name: p.displayName,
|
|
@@ -18369,7 +18370,7 @@ adminPluginRoutes.get("/", async (c) => {
|
|
|
18369
18370
|
if (user?.role !== "admin") {
|
|
18370
18371
|
return c.text("Access denied", 403);
|
|
18371
18372
|
}
|
|
18372
|
-
const pluginService = new
|
|
18373
|
+
const pluginService = new chunkT3Q5V33G_cjs.PluginService(db);
|
|
18373
18374
|
let installedPlugins = [];
|
|
18374
18375
|
let stats = { total: 0, active: 0, inactive: 0, errors: 0, uninstalled: 0 };
|
|
18375
18376
|
try {
|
|
@@ -18441,7 +18442,7 @@ adminPluginRoutes.get("/:id", async (c) => {
|
|
|
18441
18442
|
if (user?.role !== "admin") {
|
|
18442
18443
|
return c.redirect("/admin/plugins");
|
|
18443
18444
|
}
|
|
18444
|
-
const pluginService = new
|
|
18445
|
+
const pluginService = new chunkT3Q5V33G_cjs.PluginService(db);
|
|
18445
18446
|
const plugin = await pluginService.getPlugin(pluginId);
|
|
18446
18447
|
if (!plugin) {
|
|
18447
18448
|
return c.text("Plugin not found", 404);
|
|
@@ -18517,7 +18518,7 @@ adminPluginRoutes.post("/:id/activate", async (c) => {
|
|
|
18517
18518
|
if (user?.role !== "admin") {
|
|
18518
18519
|
return c.json({ error: "Access denied" }, 403);
|
|
18519
18520
|
}
|
|
18520
|
-
const pluginService = new
|
|
18521
|
+
const pluginService = new chunkT3Q5V33G_cjs.PluginService(db);
|
|
18521
18522
|
await pluginService.activatePlugin(pluginId);
|
|
18522
18523
|
return c.json({ success: true });
|
|
18523
18524
|
} catch (error) {
|
|
@@ -18534,7 +18535,7 @@ adminPluginRoutes.post("/:id/deactivate", async (c) => {
|
|
|
18534
18535
|
if (user?.role !== "admin") {
|
|
18535
18536
|
return c.json({ error: "Access denied" }, 403);
|
|
18536
18537
|
}
|
|
18537
|
-
const pluginService = new
|
|
18538
|
+
const pluginService = new chunkT3Q5V33G_cjs.PluginService(db);
|
|
18538
18539
|
await pluginService.deactivatePlugin(pluginId);
|
|
18539
18540
|
return c.json({ success: true });
|
|
18540
18541
|
} catch (error) {
|
|
@@ -18551,8 +18552,8 @@ adminPluginRoutes.post("/install", async (c) => {
|
|
|
18551
18552
|
return c.json({ error: "Access denied" }, 403);
|
|
18552
18553
|
}
|
|
18553
18554
|
const body = await c.req.json();
|
|
18554
|
-
const pluginService = new
|
|
18555
|
-
const registryEntry =
|
|
18555
|
+
const pluginService = new chunkT3Q5V33G_cjs.PluginService(db);
|
|
18556
|
+
const registryEntry = chunkT3Q5V33G_cjs.findPluginByCodeName(body.name) || chunkT3Q5V33G_cjs.PLUGIN_REGISTRY[body.name] || chunkT3Q5V33G_cjs.PLUGIN_REGISTRY[body.id];
|
|
18556
18557
|
if (!registryEntry) {
|
|
18557
18558
|
return c.json({ error: "Plugin not found in registry" }, 404);
|
|
18558
18559
|
}
|
|
@@ -18585,7 +18586,7 @@ adminPluginRoutes.post("/:id/uninstall", async (c) => {
|
|
|
18585
18586
|
if (user?.role !== "admin") {
|
|
18586
18587
|
return c.json({ error: "Access denied" }, 403);
|
|
18587
18588
|
}
|
|
18588
|
-
const pluginService = new
|
|
18589
|
+
const pluginService = new chunkT3Q5V33G_cjs.PluginService(db);
|
|
18589
18590
|
await pluginService.uninstallPlugin(pluginId);
|
|
18590
18591
|
return c.json({ success: true });
|
|
18591
18592
|
} catch (error) {
|
|
@@ -18603,7 +18604,7 @@ adminPluginRoutes.post("/:id/settings", async (c) => {
|
|
|
18603
18604
|
return c.json({ error: "Access denied" }, 403);
|
|
18604
18605
|
}
|
|
18605
18606
|
const settings = await c.req.json();
|
|
18606
|
-
const pluginService = new
|
|
18607
|
+
const pluginService = new chunkT3Q5V33G_cjs.PluginService(db);
|
|
18607
18608
|
await pluginService.updatePluginSettings(pluginId, settings);
|
|
18608
18609
|
if (pluginId === "core-auth") {
|
|
18609
18610
|
try {
|
|
@@ -19411,7 +19412,7 @@ function renderLogConfigPage(data) {
|
|
|
19411
19412
|
|
|
19412
19413
|
// src/routes/admin-logs.ts
|
|
19413
19414
|
var adminLogsRoutes = new hono.Hono();
|
|
19414
|
-
adminLogsRoutes.use("*",
|
|
19415
|
+
adminLogsRoutes.use("*", chunkDSUJ5YQH_cjs.requireAuth());
|
|
19415
19416
|
adminLogsRoutes.get("/", async (c) => {
|
|
19416
19417
|
try {
|
|
19417
19418
|
const user = c.get("user");
|
|
@@ -21739,9 +21740,9 @@ function renderStorageUsage(databaseSizeBytes, mediaSizeBytes) {
|
|
|
21739
21740
|
}
|
|
21740
21741
|
|
|
21741
21742
|
// src/routes/admin-dashboard.ts
|
|
21742
|
-
var VERSION =
|
|
21743
|
+
var VERSION = chunkSQ6FNXU2_cjs.getCoreVersion();
|
|
21743
21744
|
var router = new hono.Hono();
|
|
21744
|
-
router.use("*",
|
|
21745
|
+
router.use("*", chunkDSUJ5YQH_cjs.requireAuth());
|
|
21745
21746
|
router.get("/", async (c) => {
|
|
21746
21747
|
const user = c.get("user");
|
|
21747
21748
|
try {
|
|
@@ -23560,10 +23561,10 @@ function renderCollectionFormPage(data) {
|
|
|
23560
23561
|
|
|
23561
23562
|
// src/routes/admin-collections.ts
|
|
23562
23563
|
var adminCollectionsRoutes = new hono.Hono();
|
|
23563
|
-
adminCollectionsRoutes.use("*",
|
|
23564
|
-
adminCollectionsRoutes.post("*",
|
|
23565
|
-
adminCollectionsRoutes.put("*",
|
|
23566
|
-
adminCollectionsRoutes.delete("*",
|
|
23564
|
+
adminCollectionsRoutes.use("*", chunkDSUJ5YQH_cjs.requireAuth());
|
|
23565
|
+
adminCollectionsRoutes.post("*", chunkDSUJ5YQH_cjs.requireRole(["admin"]));
|
|
23566
|
+
adminCollectionsRoutes.put("*", chunkDSUJ5YQH_cjs.requireRole(["admin"]));
|
|
23567
|
+
adminCollectionsRoutes.delete("*", chunkDSUJ5YQH_cjs.requireRole(["admin"]));
|
|
23567
23568
|
adminCollectionsRoutes.get("/", async (c) => {
|
|
23568
23569
|
try {
|
|
23569
23570
|
const user = c.get("user");
|
|
@@ -25858,7 +25859,7 @@ function renderDatabaseToolsSettings(settings) {
|
|
|
25858
25859
|
|
|
25859
25860
|
// src/routes/admin-settings.ts
|
|
25860
25861
|
var adminSettingsRoutes = new hono.Hono();
|
|
25861
|
-
adminSettingsRoutes.use("*",
|
|
25862
|
+
adminSettingsRoutes.use("*", chunkDSUJ5YQH_cjs.requireAuth());
|
|
25862
25863
|
function getMockSettings(user) {
|
|
25863
25864
|
return {
|
|
25864
25865
|
general: {
|
|
@@ -26035,7 +26036,7 @@ adminSettingsRoutes.get("/database-tools", (c) => {
|
|
|
26035
26036
|
adminSettingsRoutes.get("/api/migrations/status", async (c) => {
|
|
26036
26037
|
try {
|
|
26037
26038
|
const db = c.env.DB;
|
|
26038
|
-
const migrationService = new
|
|
26039
|
+
const migrationService = new chunkC54YUA23_cjs.MigrationService(db);
|
|
26039
26040
|
const status = await migrationService.getMigrationStatus();
|
|
26040
26041
|
return c.json({
|
|
26041
26042
|
success: true,
|
|
@@ -26059,7 +26060,7 @@ adminSettingsRoutes.post("/api/migrations/run", async (c) => {
|
|
|
26059
26060
|
}, 403);
|
|
26060
26061
|
}
|
|
26061
26062
|
const db = c.env.DB;
|
|
26062
|
-
const migrationService = new
|
|
26063
|
+
const migrationService = new chunkC54YUA23_cjs.MigrationService(db);
|
|
26063
26064
|
const result = await migrationService.runPendingMigrations();
|
|
26064
26065
|
return c.json({
|
|
26065
26066
|
success: result.success,
|
|
@@ -26077,7 +26078,7 @@ adminSettingsRoutes.post("/api/migrations/run", async (c) => {
|
|
|
26077
26078
|
adminSettingsRoutes.get("/api/migrations/validate", async (c) => {
|
|
26078
26079
|
try {
|
|
26079
26080
|
const db = c.env.DB;
|
|
26080
|
-
const migrationService = new
|
|
26081
|
+
const migrationService = new chunkC54YUA23_cjs.MigrationService(db);
|
|
26081
26082
|
const validation = await migrationService.validateSchema();
|
|
26082
26083
|
return c.json({
|
|
26083
26084
|
success: true,
|
|
@@ -28016,7 +28017,7 @@ function renderFormCreatePage(data) {
|
|
|
28016
28017
|
|
|
28017
28018
|
// src/routes/admin-forms.ts
|
|
28018
28019
|
var adminFormsRoutes = new hono.Hono();
|
|
28019
|
-
adminFormsRoutes.use("*",
|
|
28020
|
+
adminFormsRoutes.use("*", chunkDSUJ5YQH_cjs.requireAuth());
|
|
28020
28021
|
adminFormsRoutes.get("/", async (c) => {
|
|
28021
28022
|
try {
|
|
28022
28023
|
const user = c.get("user");
|
|
@@ -28821,7 +28822,7 @@ publicFormsRoutes.post("/:identifier/submit", async (c) => {
|
|
|
28821
28822
|
`).bind(now, form.id).run();
|
|
28822
28823
|
let contentId = null;
|
|
28823
28824
|
try {
|
|
28824
|
-
contentId = await
|
|
28825
|
+
contentId = await chunkT3Q5V33G_cjs.createContentFromSubmission(
|
|
28825
28826
|
db,
|
|
28826
28827
|
sanitizedData,
|
|
28827
28828
|
{ id: form.id, name: form.name, display_name: form.display_name },
|
|
@@ -29189,9 +29190,9 @@ function renderAPIReferencePage(data) {
|
|
|
29189
29190
|
}
|
|
29190
29191
|
|
|
29191
29192
|
// src/routes/admin-api-reference.ts
|
|
29192
|
-
var VERSION2 =
|
|
29193
|
+
var VERSION2 = chunkSQ6FNXU2_cjs.getCoreVersion();
|
|
29193
29194
|
var router2 = new hono.Hono();
|
|
29194
|
-
router2.use("*",
|
|
29195
|
+
router2.use("*", chunkDSUJ5YQH_cjs.requireAuth());
|
|
29195
29196
|
router2.get("/", async (c) => {
|
|
29196
29197
|
const user = c.get("user");
|
|
29197
29198
|
try {
|
|
@@ -29274,6 +29275,7 @@ exports.auth_default = auth_default;
|
|
|
29274
29275
|
exports.createUserProfilesPlugin = createUserProfilesPlugin;
|
|
29275
29276
|
exports.defineUserProfile = defineUserProfile;
|
|
29276
29277
|
exports.getConfirmationDialogScript = getConfirmationDialogScript2;
|
|
29278
|
+
exports.getCustomData = getCustomData;
|
|
29277
29279
|
exports.getUserProfileConfig = getUserProfileConfig;
|
|
29278
29280
|
exports.public_forms_default = public_forms_default;
|
|
29279
29281
|
exports.renderConfirmationDialog = renderConfirmationDialog2;
|
|
@@ -29282,5 +29284,5 @@ exports.router2 = router2;
|
|
|
29282
29284
|
exports.test_cleanup_default = test_cleanup_default;
|
|
29283
29285
|
exports.userProfilesPlugin = userProfilesPlugin;
|
|
29284
29286
|
exports.userRoutes = userRoutes;
|
|
29285
|
-
//# sourceMappingURL=chunk-
|
|
29286
|
-
//# sourceMappingURL=chunk-
|
|
29287
|
+
//# sourceMappingURL=chunk-SXXTQETM.cjs.map
|
|
29288
|
+
//# sourceMappingURL=chunk-SXXTQETM.cjs.map
|