@sonicjs-cms/core 2.0.12 → 2.0.13
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-K5WUGEXH.cjs → chunk-2CP6535T.cjs} +114 -114
- package/dist/{chunk-K5WUGEXH.cjs.map → chunk-2CP6535T.cjs.map} +1 -1
- package/dist/{chunk-3OKKNBPD.cjs → chunk-HFFNEGZB.cjs} +4 -4
- package/dist/chunk-HFFNEGZB.cjs.map +1 -0
- package/dist/{chunk-AUVW4I3D.js → chunk-I3R77LQC.js} +2 -2
- package/dist/{chunk-AUVW4I3D.js.map → chunk-I3R77LQC.js.map} +1 -1
- package/dist/{chunk-RDJ2QLA2.cjs → chunk-JQIQRMPA.cjs} +2 -2
- package/dist/{chunk-RDJ2QLA2.cjs.map → chunk-JQIQRMPA.cjs.map} +1 -1
- package/dist/{chunk-RKNHW6QU.js → chunk-MOWI4WYE.js} +5 -5
- package/dist/chunk-MOWI4WYE.js.map +1 -0
- package/dist/{chunk-LBSKQKYL.js → chunk-PFNUOW6W.js} +3 -3
- package/dist/{chunk-LBSKQKYL.js.map → chunk-PFNUOW6W.js.map} +1 -1
- package/dist/{chunk-6B4ENDQM.js → chunk-QWIXOMHW.js} +9 -9
- package/dist/{chunk-6B4ENDQM.js.map → chunk-QWIXOMHW.js.map} +1 -1
- package/dist/{chunk-3F4LF7LW.cjs → chunk-U2WYUO32.cjs} +11 -11
- package/dist/{chunk-3F4LF7LW.cjs.map → chunk-U2WYUO32.cjs.map} +1 -1
- package/dist/{chunk-2HRF65VF.cjs → chunk-WFHLBYNA.cjs} +3 -3
- package/dist/{chunk-2HRF65VF.cjs.map → chunk-WFHLBYNA.cjs.map} +1 -1
- package/dist/{chunk-F4IGVB2V.cjs → chunk-WML2ZMHH.cjs} +4 -4
- package/dist/{chunk-F4IGVB2V.cjs.map → chunk-WML2ZMHH.cjs.map} +1 -1
- package/dist/{chunk-DSDHGJ4F.js → chunk-ZALNKBLS.js} +3 -3
- package/dist/{chunk-DSDHGJ4F.js.map → chunk-ZALNKBLS.js.map} +1 -1
- package/dist/{chunk-M2YDOOBC.js → chunk-ZNESOOF2.js} +3 -3
- package/dist/{chunk-M2YDOOBC.js.map → chunk-ZNESOOF2.js.map} +1 -1
- package/dist/index.cjs +118 -118
- package/dist/index.js +10 -10
- package/dist/middleware.cjs +23 -23
- package/dist/middleware.js +2 -2
- package/dist/migrations-GVG73ZJC.js +4 -0
- package/dist/{migrations-DURR3GZX.js.map → migrations-GVG73ZJC.js.map} +1 -1
- package/dist/migrations-S52MEE4J.cjs +13 -0
- package/dist/{migrations-P5BD7WQK.cjs.map → migrations-S52MEE4J.cjs.map} +1 -1
- package/dist/routes.cjs +26 -26
- package/dist/routes.js +6 -6
- package/dist/services.cjs +15 -15
- package/dist/services.js +3 -3
- package/dist/utils.cjs +20 -20
- package/dist/utils.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-3OKKNBPD.cjs.map +0 -1
- package/dist/chunk-RKNHW6QU.js.map +0 -1
- package/dist/migrations-DURR3GZX.js +0 -4
- package/dist/migrations-P5BD7WQK.cjs +0 -13
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkU2WYUO32_cjs = require('./chunk-U2WYUO32.cjs');
|
|
4
|
+
var chunkWML2ZMHH_cjs = require('./chunk-WML2ZMHH.cjs');
|
|
5
5
|
var chunk22EFGHAX_cjs = require('./chunk-22EFGHAX.cjs');
|
|
6
|
-
var
|
|
6
|
+
var chunkJQIQRMPA_cjs = require('./chunk-JQIQRMPA.cjs');
|
|
7
7
|
var chunkYU6QFFI4_cjs = require('./chunk-YU6QFFI4.cjs');
|
|
8
|
-
var
|
|
8
|
+
var chunkWFHLBYNA_cjs = require('./chunk-WFHLBYNA.cjs');
|
|
9
9
|
var chunkRCQ2HIQD_cjs = require('./chunk-RCQ2HIQD.cjs');
|
|
10
10
|
var hono = require('hono');
|
|
11
11
|
var cors = require('hono/cors');
|
|
@@ -44,7 +44,7 @@ apiContentCrudRoutes.get("/:id", async (c) => {
|
|
|
44
44
|
}, 500);
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
|
-
apiContentCrudRoutes.post("/",
|
|
47
|
+
apiContentCrudRoutes.post("/", chunkWML2ZMHH_cjs.requireAuth(), async (c) => {
|
|
48
48
|
try {
|
|
49
49
|
const db2 = c.env.DB;
|
|
50
50
|
const user = c.get("user");
|
|
@@ -85,7 +85,7 @@ apiContentCrudRoutes.post("/", chunkF4IGVB2V_cjs.requireAuth(), async (c) => {
|
|
|
85
85
|
now,
|
|
86
86
|
now
|
|
87
87
|
).run();
|
|
88
|
-
const cache =
|
|
88
|
+
const cache = chunkU2WYUO32_cjs.getCacheService(chunkU2WYUO32_cjs.CACHE_CONFIGS.api);
|
|
89
89
|
await cache.invalidate(`content:list:${collectionId}:*`);
|
|
90
90
|
await cache.invalidate("content-filtered:*");
|
|
91
91
|
const getStmt = db2.prepare("SELECT * FROM content WHERE id = ?");
|
|
@@ -110,7 +110,7 @@ apiContentCrudRoutes.post("/", chunkF4IGVB2V_cjs.requireAuth(), async (c) => {
|
|
|
110
110
|
}, 500);
|
|
111
111
|
}
|
|
112
112
|
});
|
|
113
|
-
apiContentCrudRoutes.put("/:id",
|
|
113
|
+
apiContentCrudRoutes.put("/:id", chunkWML2ZMHH_cjs.requireAuth(), async (c) => {
|
|
114
114
|
try {
|
|
115
115
|
const id = c.req.param("id");
|
|
116
116
|
const db2 = c.env.DB;
|
|
@@ -148,7 +148,7 @@ apiContentCrudRoutes.put("/:id", chunkF4IGVB2V_cjs.requireAuth(), async (c) => {
|
|
|
148
148
|
WHERE id = ?
|
|
149
149
|
`);
|
|
150
150
|
await updateStmt.bind(...params).run();
|
|
151
|
-
const cache =
|
|
151
|
+
const cache = chunkU2WYUO32_cjs.getCacheService(chunkU2WYUO32_cjs.CACHE_CONFIGS.api);
|
|
152
152
|
await cache.delete(cache.generateKey("content", id));
|
|
153
153
|
await cache.invalidate(`content:list:${existing.collection_id}:*`);
|
|
154
154
|
await cache.invalidate("content-filtered:*");
|
|
@@ -174,7 +174,7 @@ apiContentCrudRoutes.put("/:id", chunkF4IGVB2V_cjs.requireAuth(), async (c) => {
|
|
|
174
174
|
}, 500);
|
|
175
175
|
}
|
|
176
176
|
});
|
|
177
|
-
apiContentCrudRoutes.delete("/:id",
|
|
177
|
+
apiContentCrudRoutes.delete("/:id", chunkWML2ZMHH_cjs.requireAuth(), async (c) => {
|
|
178
178
|
try {
|
|
179
179
|
const id = c.req.param("id");
|
|
180
180
|
const db2 = c.env.DB;
|
|
@@ -185,7 +185,7 @@ apiContentCrudRoutes.delete("/:id", chunkF4IGVB2V_cjs.requireAuth(), async (c) =
|
|
|
185
185
|
}
|
|
186
186
|
const deleteStmt = db2.prepare("DELETE FROM content WHERE id = ?");
|
|
187
187
|
await deleteStmt.bind(id).run();
|
|
188
|
-
const cache =
|
|
188
|
+
const cache = chunkU2WYUO32_cjs.getCacheService(chunkU2WYUO32_cjs.CACHE_CONFIGS.api);
|
|
189
189
|
await cache.delete(cache.generateKey("content", id));
|
|
190
190
|
await cache.invalidate(`content:list:${existing.collection_id}:*`);
|
|
191
191
|
await cache.invalidate("content-filtered:*");
|
|
@@ -210,7 +210,7 @@ apiRoutes.use("*", async (c, next) => {
|
|
|
210
210
|
c.header("X-Response-Time", `${totalTime}ms`);
|
|
211
211
|
});
|
|
212
212
|
apiRoutes.use("*", async (c, next) => {
|
|
213
|
-
const cacheEnabled = await
|
|
213
|
+
const cacheEnabled = await chunkWML2ZMHH_cjs.isPluginActive(c.env.DB, "core-cache");
|
|
214
214
|
c.set("cacheEnabled", cacheEnabled);
|
|
215
215
|
await next();
|
|
216
216
|
});
|
|
@@ -258,7 +258,7 @@ apiRoutes.get("/collections", async (c) => {
|
|
|
258
258
|
try {
|
|
259
259
|
const db2 = c.env.DB;
|
|
260
260
|
const cacheEnabled = c.get("cacheEnabled");
|
|
261
|
-
const cache =
|
|
261
|
+
const cache = chunkU2WYUO32_cjs.getCacheService(chunkU2WYUO32_cjs.CACHE_CONFIGS.api);
|
|
262
262
|
const cacheKey = cache.generateKey("collections", "all");
|
|
263
263
|
if (cacheEnabled) {
|
|
264
264
|
const cacheResult = await cache.getWithSource(cacheKey);
|
|
@@ -335,12 +335,12 @@ apiRoutes.get("/content", async (c) => {
|
|
|
335
335
|
});
|
|
336
336
|
}
|
|
337
337
|
}
|
|
338
|
-
const filter =
|
|
338
|
+
const filter = chunkWFHLBYNA_cjs.QueryFilterBuilder.parseFromQuery(queryParams);
|
|
339
339
|
if (!filter.limit) {
|
|
340
340
|
filter.limit = 50;
|
|
341
341
|
}
|
|
342
342
|
filter.limit = Math.min(filter.limit, 1e3);
|
|
343
|
-
const builder3 = new
|
|
343
|
+
const builder3 = new chunkWFHLBYNA_cjs.QueryFilterBuilder();
|
|
344
344
|
const queryResult = builder3.build("content", filter);
|
|
345
345
|
if (queryResult.errors.length > 0) {
|
|
346
346
|
return c.json({
|
|
@@ -349,7 +349,7 @@ apiRoutes.get("/content", async (c) => {
|
|
|
349
349
|
}, 400);
|
|
350
350
|
}
|
|
351
351
|
const cacheEnabled = c.get("cacheEnabled");
|
|
352
|
-
const cache =
|
|
352
|
+
const cache = chunkU2WYUO32_cjs.getCacheService(chunkU2WYUO32_cjs.CACHE_CONFIGS.api);
|
|
353
353
|
const cacheKey = cache.generateKey("content-filtered", JSON.stringify({ filter, query: queryResult.sql }));
|
|
354
354
|
if (cacheEnabled) {
|
|
355
355
|
const cacheResult = await cache.getWithSource(cacheKey);
|
|
@@ -427,7 +427,7 @@ apiRoutes.get("/collections/:collection/content", async (c) => {
|
|
|
427
427
|
if (!collectionResult) {
|
|
428
428
|
return c.json({ error: "Collection not found" }, 404);
|
|
429
429
|
}
|
|
430
|
-
const filter =
|
|
430
|
+
const filter = chunkWFHLBYNA_cjs.QueryFilterBuilder.parseFromQuery(queryParams);
|
|
431
431
|
if (!filter.where) {
|
|
432
432
|
filter.where = { and: [] };
|
|
433
433
|
}
|
|
@@ -443,7 +443,7 @@ apiRoutes.get("/collections/:collection/content", async (c) => {
|
|
|
443
443
|
filter.limit = 50;
|
|
444
444
|
}
|
|
445
445
|
filter.limit = Math.min(filter.limit, 1e3);
|
|
446
|
-
const builder3 = new
|
|
446
|
+
const builder3 = new chunkWFHLBYNA_cjs.QueryFilterBuilder();
|
|
447
447
|
const queryResult = builder3.build("content", filter);
|
|
448
448
|
if (queryResult.errors.length > 0) {
|
|
449
449
|
return c.json({
|
|
@@ -452,7 +452,7 @@ apiRoutes.get("/collections/:collection/content", async (c) => {
|
|
|
452
452
|
}, 400);
|
|
453
453
|
}
|
|
454
454
|
const cacheEnabled = c.get("cacheEnabled");
|
|
455
|
-
const cache =
|
|
455
|
+
const cache = chunkU2WYUO32_cjs.getCacheService(chunkU2WYUO32_cjs.CACHE_CONFIGS.api);
|
|
456
456
|
const cacheKey = cache.generateKey("collection-content-filtered", `${collection}:${JSON.stringify({ filter, query: queryResult.sql })}`);
|
|
457
457
|
if (cacheEnabled) {
|
|
458
458
|
const cacheResult = await cache.getWithSource(cacheKey);
|
|
@@ -568,7 +568,7 @@ var fileValidationSchema = zod.z.object({
|
|
|
568
568
|
// 50MB max
|
|
569
569
|
});
|
|
570
570
|
var apiMediaRoutes = new hono.Hono();
|
|
571
|
-
apiMediaRoutes.use("*",
|
|
571
|
+
apiMediaRoutes.use("*", chunkWML2ZMHH_cjs.requireAuth());
|
|
572
572
|
apiMediaRoutes.post("/upload", async (c) => {
|
|
573
573
|
try {
|
|
574
574
|
const user = c.get("user");
|
|
@@ -1312,8 +1312,8 @@ apiSystemRoutes.get("/env", (c) => {
|
|
|
1312
1312
|
});
|
|
1313
1313
|
var api_system_default = apiSystemRoutes;
|
|
1314
1314
|
var adminApiRoutes = new hono.Hono();
|
|
1315
|
-
adminApiRoutes.use("*",
|
|
1316
|
-
adminApiRoutes.use("*",
|
|
1315
|
+
adminApiRoutes.use("*", chunkWML2ZMHH_cjs.requireAuth());
|
|
1316
|
+
adminApiRoutes.use("*", chunkWML2ZMHH_cjs.requireRole(["admin", "editor"]));
|
|
1317
1317
|
adminApiRoutes.get("/stats", async (c) => {
|
|
1318
1318
|
try {
|
|
1319
1319
|
const db2 = c.env.DB;
|
|
@@ -1722,7 +1722,7 @@ adminApiRoutes.delete("/collections/:id", async (c) => {
|
|
|
1722
1722
|
});
|
|
1723
1723
|
adminApiRoutes.get("/migrations/status", async (c) => {
|
|
1724
1724
|
try {
|
|
1725
|
-
const { MigrationService: MigrationService2 } = await import('./migrations-
|
|
1725
|
+
const { MigrationService: MigrationService2 } = await import('./migrations-S52MEE4J.cjs');
|
|
1726
1726
|
const db2 = c.env.DB;
|
|
1727
1727
|
const migrationService = new MigrationService2(db2);
|
|
1728
1728
|
const status = await migrationService.getMigrationStatus();
|
|
@@ -1747,7 +1747,7 @@ adminApiRoutes.post("/migrations/run", async (c) => {
|
|
|
1747
1747
|
error: "Unauthorized. Admin access required."
|
|
1748
1748
|
}, 403);
|
|
1749
1749
|
}
|
|
1750
|
-
const { MigrationService: MigrationService2 } = await import('./migrations-
|
|
1750
|
+
const { MigrationService: MigrationService2 } = await import('./migrations-S52MEE4J.cjs');
|
|
1751
1751
|
const db2 = c.env.DB;
|
|
1752
1752
|
const migrationService = new MigrationService2(db2);
|
|
1753
1753
|
const result = await migrationService.runPendingMigrations();
|
|
@@ -1766,7 +1766,7 @@ adminApiRoutes.post("/migrations/run", async (c) => {
|
|
|
1766
1766
|
});
|
|
1767
1767
|
adminApiRoutes.get("/migrations/validate", async (c) => {
|
|
1768
1768
|
try {
|
|
1769
|
-
const { MigrationService: MigrationService2 } = await import('./migrations-
|
|
1769
|
+
const { MigrationService: MigrationService2 } = await import('./migrations-S52MEE4J.cjs');
|
|
1770
1770
|
const db2 = c.env.DB;
|
|
1771
1771
|
const migrationService = new MigrationService2(db2);
|
|
1772
1772
|
const validation = await migrationService.validateSchema();
|
|
@@ -2211,7 +2211,7 @@ authRoutes.post(
|
|
|
2211
2211
|
if (existingUser) {
|
|
2212
2212
|
return c.json({ error: "User with this email or username already exists" }, 400);
|
|
2213
2213
|
}
|
|
2214
|
-
const passwordHash = await
|
|
2214
|
+
const passwordHash = await chunkWML2ZMHH_cjs.AuthManager.hashPassword(password);
|
|
2215
2215
|
const userId = crypto.randomUUID();
|
|
2216
2216
|
const now = /* @__PURE__ */ new Date();
|
|
2217
2217
|
await db2.prepare(`
|
|
@@ -2231,7 +2231,7 @@ authRoutes.post(
|
|
|
2231
2231
|
now.getTime(),
|
|
2232
2232
|
now.getTime()
|
|
2233
2233
|
).run();
|
|
2234
|
-
const token = await
|
|
2234
|
+
const token = await chunkWML2ZMHH_cjs.AuthManager.generateToken(userId, normalizedEmail, "viewer");
|
|
2235
2235
|
cookie.setCookie(c, "auth_token", token, {
|
|
2236
2236
|
httpOnly: true,
|
|
2237
2237
|
secure: true,
|
|
@@ -2272,7 +2272,7 @@ authRoutes.post("/login", async (c) => {
|
|
|
2272
2272
|
const { email, password } = validation.data;
|
|
2273
2273
|
const db2 = c.env.DB;
|
|
2274
2274
|
const normalizedEmail = email.toLowerCase();
|
|
2275
|
-
const cache =
|
|
2275
|
+
const cache = chunkU2WYUO32_cjs.getCacheService(chunkU2WYUO32_cjs.CACHE_CONFIGS.user);
|
|
2276
2276
|
let user = await cache.get(cache.generateKey("user", `email:${normalizedEmail}`));
|
|
2277
2277
|
if (!user) {
|
|
2278
2278
|
user = await db2.prepare("SELECT * FROM users WHERE email = ? AND is_active = 1").bind(normalizedEmail).first();
|
|
@@ -2284,11 +2284,11 @@ authRoutes.post("/login", async (c) => {
|
|
|
2284
2284
|
if (!user) {
|
|
2285
2285
|
return c.json({ error: "Invalid email or password" }, 401);
|
|
2286
2286
|
}
|
|
2287
|
-
const isValidPassword = await
|
|
2287
|
+
const isValidPassword = await chunkWML2ZMHH_cjs.AuthManager.verifyPassword(password, user.password_hash);
|
|
2288
2288
|
if (!isValidPassword) {
|
|
2289
2289
|
return c.json({ error: "Invalid email or password" }, 401);
|
|
2290
2290
|
}
|
|
2291
|
-
const token = await
|
|
2291
|
+
const token = await chunkWML2ZMHH_cjs.AuthManager.generateToken(user.id, user.email, user.role);
|
|
2292
2292
|
cookie.setCookie(c, "auth_token", token, {
|
|
2293
2293
|
httpOnly: true,
|
|
2294
2294
|
secure: true,
|
|
@@ -2337,7 +2337,7 @@ authRoutes.get("/logout", (c) => {
|
|
|
2337
2337
|
});
|
|
2338
2338
|
return c.redirect("/auth/login?message=You have been logged out successfully");
|
|
2339
2339
|
});
|
|
2340
|
-
authRoutes.get("/me",
|
|
2340
|
+
authRoutes.get("/me", chunkWML2ZMHH_cjs.requireAuth(), async (c) => {
|
|
2341
2341
|
try {
|
|
2342
2342
|
const user = c.get("user");
|
|
2343
2343
|
if (!user) {
|
|
@@ -2354,13 +2354,13 @@ authRoutes.get("/me", chunkF4IGVB2V_cjs.requireAuth(), async (c) => {
|
|
|
2354
2354
|
return c.json({ error: "Failed to get user" }, 500);
|
|
2355
2355
|
}
|
|
2356
2356
|
});
|
|
2357
|
-
authRoutes.post("/refresh",
|
|
2357
|
+
authRoutes.post("/refresh", chunkWML2ZMHH_cjs.requireAuth(), async (c) => {
|
|
2358
2358
|
try {
|
|
2359
2359
|
const user = c.get("user");
|
|
2360
2360
|
if (!user) {
|
|
2361
2361
|
return c.json({ error: "Not authenticated" }, 401);
|
|
2362
2362
|
}
|
|
2363
|
-
const token = await
|
|
2363
|
+
const token = await chunkWML2ZMHH_cjs.AuthManager.generateToken(user.userId, user.email, user.role);
|
|
2364
2364
|
cookie.setCookie(c, "auth_token", token, {
|
|
2365
2365
|
httpOnly: true,
|
|
2366
2366
|
secure: true,
|
|
@@ -2409,7 +2409,7 @@ authRoutes.post("/register/form", async (c) => {
|
|
|
2409
2409
|
</div>
|
|
2410
2410
|
`);
|
|
2411
2411
|
}
|
|
2412
|
-
const passwordHash = await
|
|
2412
|
+
const passwordHash = await chunkWML2ZMHH_cjs.AuthManager.hashPassword(password);
|
|
2413
2413
|
const userId = crypto.randomUUID();
|
|
2414
2414
|
const now = /* @__PURE__ */ new Date();
|
|
2415
2415
|
await db2.prepare(`
|
|
@@ -2429,7 +2429,7 @@ authRoutes.post("/register/form", async (c) => {
|
|
|
2429
2429
|
now.getTime(),
|
|
2430
2430
|
now.getTime()
|
|
2431
2431
|
).run();
|
|
2432
|
-
const token = await
|
|
2432
|
+
const token = await chunkWML2ZMHH_cjs.AuthManager.generateToken(userId, normalizedEmail, "admin");
|
|
2433
2433
|
cookie.setCookie(c, "auth_token", token, {
|
|
2434
2434
|
httpOnly: true,
|
|
2435
2435
|
secure: false,
|
|
@@ -2480,7 +2480,7 @@ authRoutes.post("/login/form", async (c) => {
|
|
|
2480
2480
|
</div>
|
|
2481
2481
|
`);
|
|
2482
2482
|
}
|
|
2483
|
-
const isValidPassword = await
|
|
2483
|
+
const isValidPassword = await chunkWML2ZMHH_cjs.AuthManager.verifyPassword(password, user.password_hash);
|
|
2484
2484
|
if (!isValidPassword) {
|
|
2485
2485
|
return c.html(html.html`
|
|
2486
2486
|
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded">
|
|
@@ -2488,7 +2488,7 @@ authRoutes.post("/login/form", async (c) => {
|
|
|
2488
2488
|
</div>
|
|
2489
2489
|
`);
|
|
2490
2490
|
}
|
|
2491
|
-
const token = await
|
|
2491
|
+
const token = await chunkWML2ZMHH_cjs.AuthManager.generateToken(user.id, user.email, user.role);
|
|
2492
2492
|
cookie.setCookie(c, "auth_token", token, {
|
|
2493
2493
|
httpOnly: true,
|
|
2494
2494
|
secure: false,
|
|
@@ -2547,7 +2547,7 @@ authRoutes.post("/seed-admin", async (c) => {
|
|
|
2547
2547
|
`).run();
|
|
2548
2548
|
const existingAdmin = await db2.prepare("SELECT id FROM users WHERE email = ? OR username = ?").bind("admin@sonicjs.com", "admin").first();
|
|
2549
2549
|
if (existingAdmin) {
|
|
2550
|
-
const passwordHash2 = await
|
|
2550
|
+
const passwordHash2 = await chunkWML2ZMHH_cjs.AuthManager.hashPassword("sonicjs!");
|
|
2551
2551
|
await db2.prepare("UPDATE users SET password_hash = ?, updated_at = ? WHERE id = ?").bind(passwordHash2, Date.now(), existingAdmin.id).run();
|
|
2552
2552
|
return c.json({
|
|
2553
2553
|
message: "Admin user already exists (password updated)",
|
|
@@ -2559,7 +2559,7 @@ authRoutes.post("/seed-admin", async (c) => {
|
|
|
2559
2559
|
}
|
|
2560
2560
|
});
|
|
2561
2561
|
}
|
|
2562
|
-
const passwordHash = await
|
|
2562
|
+
const passwordHash = await chunkWML2ZMHH_cjs.AuthManager.hashPassword("sonicjs!");
|
|
2563
2563
|
const userId = "admin-user-id";
|
|
2564
2564
|
const now = Date.now();
|
|
2565
2565
|
const adminEmail = "admin@sonicjs.com".toLowerCase();
|
|
@@ -2779,7 +2779,7 @@ authRoutes.post("/accept-invitation", async (c) => {
|
|
|
2779
2779
|
if (existingUsername) {
|
|
2780
2780
|
return c.json({ error: "Username is already taken" }, 400);
|
|
2781
2781
|
}
|
|
2782
|
-
const passwordHash = await
|
|
2782
|
+
const passwordHash = await chunkWML2ZMHH_cjs.AuthManager.hashPassword(password);
|
|
2783
2783
|
const updateStmt = db2.prepare(`
|
|
2784
2784
|
UPDATE users SET
|
|
2785
2785
|
username = ?,
|
|
@@ -2798,7 +2798,7 @@ authRoutes.post("/accept-invitation", async (c) => {
|
|
|
2798
2798
|
Date.now(),
|
|
2799
2799
|
invitedUser.id
|
|
2800
2800
|
).run();
|
|
2801
|
-
const authToken = await
|
|
2801
|
+
const authToken = await chunkWML2ZMHH_cjs.AuthManager.generateToken(invitedUser.id, invitedUser.email, invitedUser.role);
|
|
2802
2802
|
cookie.setCookie(c, "auth_token", authToken, {
|
|
2803
2803
|
httpOnly: true,
|
|
2804
2804
|
secure: true,
|
|
@@ -3028,7 +3028,7 @@ authRoutes.post("/reset-password", async (c) => {
|
|
|
3028
3028
|
if (Date.now() > user.password_reset_expires) {
|
|
3029
3029
|
return c.json({ error: "Reset token has expired" }, 400);
|
|
3030
3030
|
}
|
|
3031
|
-
const newPasswordHash = await
|
|
3031
|
+
const newPasswordHash = await chunkWML2ZMHH_cjs.AuthManager.hashPassword(password);
|
|
3032
3032
|
try {
|
|
3033
3033
|
const historyStmt = db2.prepare(`
|
|
3034
3034
|
INSERT INTO password_history (id, user_id, password_hash, created_at)
|
|
@@ -5925,9 +5925,9 @@ async function isPluginActive2(db2, pluginId) {
|
|
|
5925
5925
|
|
|
5926
5926
|
// src/routes/admin-content.ts
|
|
5927
5927
|
var adminContentRoutes = new hono.Hono();
|
|
5928
|
-
adminContentRoutes.use("*",
|
|
5928
|
+
adminContentRoutes.use("*", chunkWML2ZMHH_cjs.requireAuth());
|
|
5929
5929
|
async function getCollectionFields(db2, collectionId) {
|
|
5930
|
-
const cache =
|
|
5930
|
+
const cache = chunkU2WYUO32_cjs.getCacheService(chunkU2WYUO32_cjs.CACHE_CONFIGS.collection);
|
|
5931
5931
|
return cache.getOrSet(
|
|
5932
5932
|
cache.generateKey("fields", collectionId),
|
|
5933
5933
|
async () => {
|
|
@@ -5982,7 +5982,7 @@ async function getCollectionFields(db2, collectionId) {
|
|
|
5982
5982
|
);
|
|
5983
5983
|
}
|
|
5984
5984
|
async function getCollection(db2, collectionId) {
|
|
5985
|
-
const cache =
|
|
5985
|
+
const cache = chunkU2WYUO32_cjs.getCacheService(chunkU2WYUO32_cjs.CACHE_CONFIGS.collection);
|
|
5986
5986
|
return cache.getOrSet(
|
|
5987
5987
|
cache.generateKey("collection", collectionId),
|
|
5988
5988
|
async () => {
|
|
@@ -6271,7 +6271,7 @@ adminContentRoutes.get("/:id/edit", async (c) => {
|
|
|
6271
6271
|
const db2 = c.env.DB;
|
|
6272
6272
|
const url = new URL(c.req.url);
|
|
6273
6273
|
const referrerParams = url.searchParams.get("ref") || "";
|
|
6274
|
-
const cache =
|
|
6274
|
+
const cache = chunkU2WYUO32_cjs.getCacheService(chunkU2WYUO32_cjs.CACHE_CONFIGS.content);
|
|
6275
6275
|
const content = await cache.getOrSet(
|
|
6276
6276
|
cache.generateKey("content", id),
|
|
6277
6277
|
async () => {
|
|
@@ -6479,7 +6479,7 @@ adminContentRoutes.post("/", async (c) => {
|
|
|
6479
6479
|
now,
|
|
6480
6480
|
now
|
|
6481
6481
|
).run();
|
|
6482
|
-
const cache =
|
|
6482
|
+
const cache = chunkU2WYUO32_cjs.getCacheService(chunkU2WYUO32_cjs.CACHE_CONFIGS.content);
|
|
6483
6483
|
await cache.invalidate(`content:list:${collectionId}:*`);
|
|
6484
6484
|
const versionStmt = db2.prepare(`
|
|
6485
6485
|
INSERT INTO content_versions (id, content_id, version, data, author_id, created_at)
|
|
@@ -6627,7 +6627,7 @@ adminContentRoutes.put("/:id", async (c) => {
|
|
|
6627
6627
|
now,
|
|
6628
6628
|
id
|
|
6629
6629
|
).run();
|
|
6630
|
-
const cache =
|
|
6630
|
+
const cache = chunkU2WYUO32_cjs.getCacheService(chunkU2WYUO32_cjs.CACHE_CONFIGS.content);
|
|
6631
6631
|
await cache.delete(cache.generateKey("content", id));
|
|
6632
6632
|
await cache.invalidate(`content:list:${existingContent.collection_id}:*`);
|
|
6633
6633
|
const existingData = JSON.parse(existingContent.data || "{}");
|
|
@@ -6920,7 +6920,7 @@ adminContentRoutes.post("/bulk-action", async (c) => {
|
|
|
6920
6920
|
} else {
|
|
6921
6921
|
return c.json({ success: false, error: "Invalid action" });
|
|
6922
6922
|
}
|
|
6923
|
-
const cache =
|
|
6923
|
+
const cache = chunkU2WYUO32_cjs.getCacheService(chunkU2WYUO32_cjs.CACHE_CONFIGS.content);
|
|
6924
6924
|
for (const contentId of ids) {
|
|
6925
6925
|
await cache.delete(cache.generateKey("content", contentId));
|
|
6926
6926
|
}
|
|
@@ -6948,7 +6948,7 @@ adminContentRoutes.delete("/:id", async (c) => {
|
|
|
6948
6948
|
WHERE id = ?
|
|
6949
6949
|
`);
|
|
6950
6950
|
await deleteStmt.bind(now, id).run();
|
|
6951
|
-
const cache =
|
|
6951
|
+
const cache = chunkU2WYUO32_cjs.getCacheService(chunkU2WYUO32_cjs.CACHE_CONFIGS.content);
|
|
6952
6952
|
await cache.delete(cache.generateKey("content", id));
|
|
6953
6953
|
await cache.invalidate("content:list:*");
|
|
6954
6954
|
return c.html(`
|
|
@@ -7992,7 +7992,7 @@ function renderUserEditPage(data) {
|
|
|
7992
7992
|
<input
|
|
7993
7993
|
type="text"
|
|
7994
7994
|
name="first_name"
|
|
7995
|
-
value="${
|
|
7995
|
+
value="${chunkWFHLBYNA_cjs.escapeHtml(data.userToEdit.firstName || "")}"
|
|
7996
7996
|
required
|
|
7997
7997
|
class="w-full rounded-lg bg-white dark:bg-zinc-800 px-3 py-2 text-sm text-zinc-950 dark:text-white shadow-sm ring-1 ring-inset ring-zinc-950/10 dark:ring-white/10 placeholder:text-zinc-400 dark:placeholder:text-zinc-500 focus:outline-none focus:ring-2 focus:ring-zinc-950 dark:focus:ring-white transition-shadow"
|
|
7998
7998
|
/>
|
|
@@ -8003,7 +8003,7 @@ function renderUserEditPage(data) {
|
|
|
8003
8003
|
<input
|
|
8004
8004
|
type="text"
|
|
8005
8005
|
name="last_name"
|
|
8006
|
-
value="${
|
|
8006
|
+
value="${chunkWFHLBYNA_cjs.escapeHtml(data.userToEdit.lastName || "")}"
|
|
8007
8007
|
required
|
|
8008
8008
|
class="w-full rounded-lg bg-white dark:bg-zinc-800 px-3 py-2 text-sm text-zinc-950 dark:text-white shadow-sm ring-1 ring-inset ring-zinc-950/10 dark:ring-white/10 placeholder:text-zinc-400 dark:placeholder:text-zinc-500 focus:outline-none focus:ring-2 focus:ring-zinc-950 dark:focus:ring-white transition-shadow"
|
|
8009
8009
|
/>
|
|
@@ -8014,7 +8014,7 @@ function renderUserEditPage(data) {
|
|
|
8014
8014
|
<input
|
|
8015
8015
|
type="text"
|
|
8016
8016
|
name="username"
|
|
8017
|
-
value="${
|
|
8017
|
+
value="${chunkWFHLBYNA_cjs.escapeHtml(data.userToEdit.username || "")}"
|
|
8018
8018
|
required
|
|
8019
8019
|
class="w-full rounded-lg bg-white dark:bg-zinc-800 px-3 py-2 text-sm text-zinc-950 dark:text-white shadow-sm ring-1 ring-inset ring-zinc-950/10 dark:ring-white/10 placeholder:text-zinc-400 dark:placeholder:text-zinc-500 focus:outline-none focus:ring-2 focus:ring-zinc-950 dark:focus:ring-white transition-shadow"
|
|
8020
8020
|
/>
|
|
@@ -8025,7 +8025,7 @@ function renderUserEditPage(data) {
|
|
|
8025
8025
|
<input
|
|
8026
8026
|
type="email"
|
|
8027
8027
|
name="email"
|
|
8028
|
-
value="${
|
|
8028
|
+
value="${chunkWFHLBYNA_cjs.escapeHtml(data.userToEdit.email || "")}"
|
|
8029
8029
|
required
|
|
8030
8030
|
class="w-full rounded-lg bg-white dark:bg-zinc-800 px-3 py-2 text-sm text-zinc-950 dark:text-white shadow-sm ring-1 ring-inset ring-zinc-950/10 dark:ring-white/10 placeholder:text-zinc-400 dark:placeholder:text-zinc-500 focus:outline-none focus:ring-2 focus:ring-zinc-950 dark:focus:ring-white transition-shadow"
|
|
8031
8031
|
/>
|
|
@@ -8036,7 +8036,7 @@ function renderUserEditPage(data) {
|
|
|
8036
8036
|
<input
|
|
8037
8037
|
type="tel"
|
|
8038
8038
|
name="phone"
|
|
8039
|
-
value="${
|
|
8039
|
+
value="${chunkWFHLBYNA_cjs.escapeHtml(data.userToEdit.phone || "")}"
|
|
8040
8040
|
class="w-full rounded-lg bg-white dark:bg-zinc-800 px-3 py-2 text-sm text-zinc-950 dark:text-white shadow-sm ring-1 ring-inset ring-zinc-950/10 dark:ring-white/10 placeholder:text-zinc-400 dark:placeholder:text-zinc-500 focus:outline-none focus:ring-2 focus:ring-zinc-950 dark:focus:ring-white transition-shadow"
|
|
8041
8041
|
/>
|
|
8042
8042
|
</div>
|
|
@@ -8050,7 +8050,7 @@ function renderUserEditPage(data) {
|
|
|
8050
8050
|
class="col-start-1 row-start-1 w-full appearance-none rounded-md bg-white/5 dark:bg-white/5 py-1.5 pl-3 pr-8 text-base text-zinc-950 dark:text-white outline outline-1 -outline-offset-1 outline-zinc-500/30 dark:outline-zinc-400/30 *:bg-white dark:*:bg-zinc-800 focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-zinc-500 dark:focus-visible:outline-zinc-400 sm:text-sm/6"
|
|
8051
8051
|
>
|
|
8052
8052
|
${data.roles.map((role) => `
|
|
8053
|
-
<option value="${
|
|
8053
|
+
<option value="${chunkWFHLBYNA_cjs.escapeHtml(role.value)}" ${data.userToEdit.role === role.value ? "selected" : ""}>${chunkWFHLBYNA_cjs.escapeHtml(role.label)}</option>
|
|
8054
8054
|
`).join("")}
|
|
8055
8055
|
</select>
|
|
8056
8056
|
<svg viewBox="0 0 16 16" fill="currentColor" data-slot="icon" aria-hidden="true" class="pointer-events-none col-start-1 row-start-1 mr-2 size-5 self-center justify-self-end text-zinc-600 dark:text-zinc-400 sm:size-4">
|
|
@@ -8066,7 +8066,7 @@ function renderUserEditPage(data) {
|
|
|
8066
8066
|
name="bio"
|
|
8067
8067
|
rows="3"
|
|
8068
8068
|
class="w-full rounded-lg bg-white dark:bg-zinc-800 px-3 py-2 text-sm text-zinc-950 dark:text-white shadow-sm ring-1 ring-inset ring-zinc-950/10 dark:ring-white/10 placeholder:text-zinc-400 dark:placeholder:text-zinc-500 focus:outline-none focus:ring-2 focus:ring-zinc-950 dark:focus:ring-white transition-shadow"
|
|
8069
|
-
>${
|
|
8069
|
+
>${chunkWFHLBYNA_cjs.escapeHtml(data.userToEdit.bio || "")}</textarea>
|
|
8070
8070
|
</div>
|
|
8071
8071
|
</div>
|
|
8072
8072
|
|
|
@@ -8966,7 +8966,7 @@ function renderUsersListPage(data) {
|
|
|
8966
8966
|
|
|
8967
8967
|
// src/routes/admin-users.ts
|
|
8968
8968
|
var userRoutes = new hono.Hono();
|
|
8969
|
-
userRoutes.use("*",
|
|
8969
|
+
userRoutes.use("*", chunkWML2ZMHH_cjs.requireAuth());
|
|
8970
8970
|
userRoutes.get("/", (c) => {
|
|
8971
8971
|
return c.redirect("/admin/dashboard");
|
|
8972
8972
|
});
|
|
@@ -9065,12 +9065,12 @@ userRoutes.put("/profile", async (c) => {
|
|
|
9065
9065
|
const db2 = c.env.DB;
|
|
9066
9066
|
try {
|
|
9067
9067
|
const formData = await c.req.formData();
|
|
9068
|
-
const firstName =
|
|
9069
|
-
const lastName =
|
|
9070
|
-
const username =
|
|
9068
|
+
const firstName = chunkWFHLBYNA_cjs.sanitizeInput(formData.get("first_name")?.toString());
|
|
9069
|
+
const lastName = chunkWFHLBYNA_cjs.sanitizeInput(formData.get("last_name")?.toString());
|
|
9070
|
+
const username = chunkWFHLBYNA_cjs.sanitizeInput(formData.get("username")?.toString());
|
|
9071
9071
|
const email = formData.get("email")?.toString()?.trim().toLowerCase() || "";
|
|
9072
|
-
const phone =
|
|
9073
|
-
const bio =
|
|
9072
|
+
const phone = chunkWFHLBYNA_cjs.sanitizeInput(formData.get("phone")?.toString()) || null;
|
|
9073
|
+
const bio = chunkWFHLBYNA_cjs.sanitizeInput(formData.get("bio")?.toString()) || null;
|
|
9074
9074
|
const timezone = formData.get("timezone")?.toString() || "UTC";
|
|
9075
9075
|
const language = formData.get("language")?.toString() || "en";
|
|
9076
9076
|
const emailNotifications = formData.get("email_notifications") === "1";
|
|
@@ -9121,7 +9121,7 @@ userRoutes.put("/profile", async (c) => {
|
|
|
9121
9121
|
Date.now(),
|
|
9122
9122
|
user.userId
|
|
9123
9123
|
).run();
|
|
9124
|
-
await
|
|
9124
|
+
await chunkWML2ZMHH_cjs.logActivity(
|
|
9125
9125
|
db2,
|
|
9126
9126
|
user.userId,
|
|
9127
9127
|
"profile.update",
|
|
@@ -9184,7 +9184,7 @@ userRoutes.post("/profile/avatar", async (c) => {
|
|
|
9184
9184
|
SELECT first_name, last_name FROM users WHERE id = ?
|
|
9185
9185
|
`);
|
|
9186
9186
|
const userData = await userStmt.bind(user.userId).first();
|
|
9187
|
-
await
|
|
9187
|
+
await chunkWML2ZMHH_cjs.logActivity(
|
|
9188
9188
|
db2,
|
|
9189
9189
|
user.userId,
|
|
9190
9190
|
"profile.avatar_update",
|
|
@@ -9255,7 +9255,7 @@ userRoutes.post("/profile/password", async (c) => {
|
|
|
9255
9255
|
dismissible: true
|
|
9256
9256
|
}));
|
|
9257
9257
|
}
|
|
9258
|
-
const validPassword = await
|
|
9258
|
+
const validPassword = await chunkWML2ZMHH_cjs.AuthManager.verifyPassword(currentPassword, userData.password_hash);
|
|
9259
9259
|
if (!validPassword) {
|
|
9260
9260
|
return c.html(renderAlert2({
|
|
9261
9261
|
type: "error",
|
|
@@ -9263,7 +9263,7 @@ userRoutes.post("/profile/password", async (c) => {
|
|
|
9263
9263
|
dismissible: true
|
|
9264
9264
|
}));
|
|
9265
9265
|
}
|
|
9266
|
-
const newPasswordHash = await
|
|
9266
|
+
const newPasswordHash = await chunkWML2ZMHH_cjs.AuthManager.hashPassword(newPassword);
|
|
9267
9267
|
const historyStmt = db2.prepare(`
|
|
9268
9268
|
INSERT INTO password_history (id, user_id, password_hash, created_at)
|
|
9269
9269
|
VALUES (?, ?, ?, ?)
|
|
@@ -9279,7 +9279,7 @@ userRoutes.post("/profile/password", async (c) => {
|
|
|
9279
9279
|
WHERE id = ?
|
|
9280
9280
|
`);
|
|
9281
9281
|
await updateStmt.bind(newPasswordHash, Date.now(), user.userId).run();
|
|
9282
|
-
await
|
|
9282
|
+
await chunkWML2ZMHH_cjs.logActivity(
|
|
9283
9283
|
db2,
|
|
9284
9284
|
user.userId,
|
|
9285
9285
|
"profile.password_change",
|
|
@@ -9346,7 +9346,7 @@ userRoutes.get("/users", async (c) => {
|
|
|
9346
9346
|
`);
|
|
9347
9347
|
const countResult = await countStmt.bind(...params).first();
|
|
9348
9348
|
const totalUsers = countResult?.total || 0;
|
|
9349
|
-
await
|
|
9349
|
+
await chunkWML2ZMHH_cjs.logActivity(
|
|
9350
9350
|
db2,
|
|
9351
9351
|
user.userId,
|
|
9352
9352
|
"users.list_view",
|
|
@@ -9448,12 +9448,12 @@ userRoutes.post("/users/new", async (c) => {
|
|
|
9448
9448
|
const user = c.get("user");
|
|
9449
9449
|
try {
|
|
9450
9450
|
const formData = await c.req.formData();
|
|
9451
|
-
const firstName =
|
|
9452
|
-
const lastName =
|
|
9453
|
-
const username =
|
|
9451
|
+
const firstName = chunkWFHLBYNA_cjs.sanitizeInput(formData.get("first_name")?.toString());
|
|
9452
|
+
const lastName = chunkWFHLBYNA_cjs.sanitizeInput(formData.get("last_name")?.toString());
|
|
9453
|
+
const username = chunkWFHLBYNA_cjs.sanitizeInput(formData.get("username")?.toString());
|
|
9454
9454
|
const email = formData.get("email")?.toString()?.trim().toLowerCase() || "";
|
|
9455
|
-
const phone =
|
|
9456
|
-
const bio =
|
|
9455
|
+
const phone = chunkWFHLBYNA_cjs.sanitizeInput(formData.get("phone")?.toString()) || null;
|
|
9456
|
+
const bio = chunkWFHLBYNA_cjs.sanitizeInput(formData.get("bio")?.toString()) || null;
|
|
9457
9457
|
const role = formData.get("role")?.toString() || "viewer";
|
|
9458
9458
|
const password = formData.get("password")?.toString() || "";
|
|
9459
9459
|
const confirmPassword = formData.get("confirm_password")?.toString() || "";
|
|
@@ -9500,7 +9500,7 @@ userRoutes.post("/users/new", async (c) => {
|
|
|
9500
9500
|
dismissible: true
|
|
9501
9501
|
}));
|
|
9502
9502
|
}
|
|
9503
|
-
const passwordHash = await
|
|
9503
|
+
const passwordHash = await chunkWML2ZMHH_cjs.AuthManager.hashPassword(password);
|
|
9504
9504
|
const userId = crypto.randomUUID();
|
|
9505
9505
|
const createStmt = db2.prepare(`
|
|
9506
9506
|
INSERT INTO users (
|
|
@@ -9523,7 +9523,7 @@ userRoutes.post("/users/new", async (c) => {
|
|
|
9523
9523
|
Date.now(),
|
|
9524
9524
|
Date.now()
|
|
9525
9525
|
).run();
|
|
9526
|
-
await
|
|
9526
|
+
await chunkWML2ZMHH_cjs.logActivity(
|
|
9527
9527
|
db2,
|
|
9528
9528
|
user.userId,
|
|
9529
9529
|
"user!.create",
|
|
@@ -9561,7 +9561,7 @@ userRoutes.get("/users/:id", async (c) => {
|
|
|
9561
9561
|
if (!userRecord) {
|
|
9562
9562
|
return c.json({ error: "User not found" }, 404);
|
|
9563
9563
|
}
|
|
9564
|
-
await
|
|
9564
|
+
await chunkWML2ZMHH_cjs.logActivity(
|
|
9565
9565
|
db2,
|
|
9566
9566
|
user.userId,
|
|
9567
9567
|
"user!.view",
|
|
@@ -9654,12 +9654,12 @@ userRoutes.put("/users/:id", async (c) => {
|
|
|
9654
9654
|
const userId = c.req.param("id");
|
|
9655
9655
|
try {
|
|
9656
9656
|
const formData = await c.req.formData();
|
|
9657
|
-
const firstName =
|
|
9658
|
-
const lastName =
|
|
9659
|
-
const username =
|
|
9657
|
+
const firstName = chunkWFHLBYNA_cjs.sanitizeInput(formData.get("first_name")?.toString());
|
|
9658
|
+
const lastName = chunkWFHLBYNA_cjs.sanitizeInput(formData.get("last_name")?.toString());
|
|
9659
|
+
const username = chunkWFHLBYNA_cjs.sanitizeInput(formData.get("username")?.toString());
|
|
9660
9660
|
const email = formData.get("email")?.toString()?.trim().toLowerCase() || "";
|
|
9661
|
-
const phone =
|
|
9662
|
-
const bio =
|
|
9661
|
+
const phone = chunkWFHLBYNA_cjs.sanitizeInput(formData.get("phone")?.toString()) || null;
|
|
9662
|
+
const bio = chunkWFHLBYNA_cjs.sanitizeInput(formData.get("bio")?.toString()) || null;
|
|
9663
9663
|
const role = formData.get("role")?.toString() || "viewer";
|
|
9664
9664
|
const isActive = formData.get("is_active") === "1";
|
|
9665
9665
|
const emailVerified = formData.get("email_verified") === "1";
|
|
@@ -9710,7 +9710,7 @@ userRoutes.put("/users/:id", async (c) => {
|
|
|
9710
9710
|
Date.now(),
|
|
9711
9711
|
userId
|
|
9712
9712
|
).run();
|
|
9713
|
-
await
|
|
9713
|
+
await chunkWML2ZMHH_cjs.logActivity(
|
|
9714
9714
|
db2,
|
|
9715
9715
|
user.userId,
|
|
9716
9716
|
"user!.update",
|
|
@@ -9755,7 +9755,7 @@ userRoutes.post("/users/:id/toggle", async (c) => {
|
|
|
9755
9755
|
UPDATE users SET is_active = ?, updated_at = ? WHERE id = ?
|
|
9756
9756
|
`);
|
|
9757
9757
|
await toggleStmt.bind(active ? 1 : 0, Date.now(), userId).run();
|
|
9758
|
-
await
|
|
9758
|
+
await chunkWML2ZMHH_cjs.logActivity(
|
|
9759
9759
|
db2,
|
|
9760
9760
|
user.userId,
|
|
9761
9761
|
active ? "user.activate" : "user.deactivate",
|
|
@@ -9796,7 +9796,7 @@ userRoutes.delete("/users/:id", async (c) => {
|
|
|
9796
9796
|
DELETE FROM users WHERE id = ?
|
|
9797
9797
|
`);
|
|
9798
9798
|
await deleteStmt.bind(userId).run();
|
|
9799
|
-
await
|
|
9799
|
+
await chunkWML2ZMHH_cjs.logActivity(
|
|
9800
9800
|
db2,
|
|
9801
9801
|
user.userId,
|
|
9802
9802
|
"user!.hard_delete",
|
|
@@ -9815,7 +9815,7 @@ userRoutes.delete("/users/:id", async (c) => {
|
|
|
9815
9815
|
UPDATE users SET is_active = 0, updated_at = ? WHERE id = ?
|
|
9816
9816
|
`);
|
|
9817
9817
|
await deleteStmt.bind(Date.now(), userId).run();
|
|
9818
|
-
await
|
|
9818
|
+
await chunkWML2ZMHH_cjs.logActivity(
|
|
9819
9819
|
db2,
|
|
9820
9820
|
user.userId,
|
|
9821
9821
|
"user!.soft_delete",
|
|
@@ -9842,8 +9842,8 @@ userRoutes.post("/invite-user", async (c) => {
|
|
|
9842
9842
|
const formData = await c.req.formData();
|
|
9843
9843
|
const email = formData.get("email")?.toString()?.trim().toLowerCase() || "";
|
|
9844
9844
|
const role = formData.get("role")?.toString()?.trim() || "viewer";
|
|
9845
|
-
const firstName =
|
|
9846
|
-
const lastName =
|
|
9845
|
+
const firstName = chunkWFHLBYNA_cjs.sanitizeInput(formData.get("first_name")?.toString());
|
|
9846
|
+
const lastName = chunkWFHLBYNA_cjs.sanitizeInput(formData.get("last_name")?.toString());
|
|
9847
9847
|
if (!email || !firstName || !lastName) {
|
|
9848
9848
|
return c.json({ error: "Email, first name, and last name are required" }, 400);
|
|
9849
9849
|
}
|
|
@@ -9881,7 +9881,7 @@ userRoutes.post("/invite-user", async (c) => {
|
|
|
9881
9881
|
Date.now(),
|
|
9882
9882
|
Date.now()
|
|
9883
9883
|
).run();
|
|
9884
|
-
await
|
|
9884
|
+
await chunkWML2ZMHH_cjs.logActivity(
|
|
9885
9885
|
db2,
|
|
9886
9886
|
user.userId,
|
|
9887
9887
|
"user!.invite_sent",
|
|
@@ -9938,7 +9938,7 @@ userRoutes.post("/resend-invitation/:id", async (c) => {
|
|
|
9938
9938
|
Date.now(),
|
|
9939
9939
|
userId
|
|
9940
9940
|
).run();
|
|
9941
|
-
await
|
|
9941
|
+
await chunkWML2ZMHH_cjs.logActivity(
|
|
9942
9942
|
db2,
|
|
9943
9943
|
user.userId,
|
|
9944
9944
|
"user!.invitation_resent",
|
|
@@ -9974,7 +9974,7 @@ userRoutes.delete("/cancel-invitation/:id", async (c) => {
|
|
|
9974
9974
|
}
|
|
9975
9975
|
const deleteStmt = db2.prepare(`DELETE FROM users WHERE id = ?`);
|
|
9976
9976
|
await deleteStmt.bind(userId).run();
|
|
9977
|
-
await
|
|
9977
|
+
await chunkWML2ZMHH_cjs.logActivity(
|
|
9978
9978
|
db2,
|
|
9979
9979
|
user.userId,
|
|
9980
9980
|
"user!.invitation_cancelled",
|
|
@@ -10057,7 +10057,7 @@ userRoutes.get("/activity-logs", async (c) => {
|
|
|
10057
10057
|
...log,
|
|
10058
10058
|
details: log.details ? JSON.parse(log.details) : null
|
|
10059
10059
|
}));
|
|
10060
|
-
await
|
|
10060
|
+
await chunkWML2ZMHH_cjs.logActivity(
|
|
10061
10061
|
db2,
|
|
10062
10062
|
user.userId,
|
|
10063
10063
|
"activity.logs_viewed",
|
|
@@ -10164,7 +10164,7 @@ userRoutes.get("/activity-logs/export", async (c) => {
|
|
|
10164
10164
|
csvRows.push(row.join(","));
|
|
10165
10165
|
}
|
|
10166
10166
|
const csvContent = csvRows.join("\n");
|
|
10167
|
-
await
|
|
10167
|
+
await chunkWML2ZMHH_cjs.logActivity(
|
|
10168
10168
|
db2,
|
|
10169
10169
|
user.userId,
|
|
10170
10170
|
"activity.logs_exported",
|
|
@@ -11503,7 +11503,7 @@ var fileValidationSchema2 = zod.z.object({
|
|
|
11503
11503
|
// 50MB max
|
|
11504
11504
|
});
|
|
11505
11505
|
var adminMediaRoutes = new hono.Hono();
|
|
11506
|
-
adminMediaRoutes.use("*",
|
|
11506
|
+
adminMediaRoutes.use("*", chunkWML2ZMHH_cjs.requireAuth());
|
|
11507
11507
|
adminMediaRoutes.get("/", async (c) => {
|
|
11508
11508
|
try {
|
|
11509
11509
|
const user = c.get("user");
|
|
@@ -12082,7 +12082,7 @@ adminMediaRoutes.put("/:id", async (c) => {
|
|
|
12082
12082
|
`);
|
|
12083
12083
|
}
|
|
12084
12084
|
});
|
|
12085
|
-
adminMediaRoutes.delete("/cleanup",
|
|
12085
|
+
adminMediaRoutes.delete("/cleanup", chunkWML2ZMHH_cjs.requireRole("admin"), async (c) => {
|
|
12086
12086
|
try {
|
|
12087
12087
|
const db2 = c.env.DB;
|
|
12088
12088
|
const allMediaStmt = db2.prepare("SELECT id, r2_key, filename FROM media WHERE deleted_at IS NULL");
|
|
@@ -13686,7 +13686,7 @@ function formatTimestamp(timestamp) {
|
|
|
13686
13686
|
|
|
13687
13687
|
// src/routes/admin-plugins.ts
|
|
13688
13688
|
var adminPluginRoutes = new hono.Hono();
|
|
13689
|
-
adminPluginRoutes.use("*",
|
|
13689
|
+
adminPluginRoutes.use("*", chunkWML2ZMHH_cjs.requireAuth());
|
|
13690
13690
|
var AVAILABLE_PLUGINS = [
|
|
13691
13691
|
{
|
|
13692
13692
|
id: "third-party-faq",
|
|
@@ -14977,11 +14977,11 @@ function renderLogConfigPage(data) {
|
|
|
14977
14977
|
|
|
14978
14978
|
// src/routes/admin-logs.ts
|
|
14979
14979
|
var adminLogsRoutes = new hono.Hono();
|
|
14980
|
-
adminLogsRoutes.use("*",
|
|
14980
|
+
adminLogsRoutes.use("*", chunkWML2ZMHH_cjs.requireAuth());
|
|
14981
14981
|
adminLogsRoutes.get("/", async (c) => {
|
|
14982
14982
|
try {
|
|
14983
14983
|
const user = c.get("user");
|
|
14984
|
-
const logger =
|
|
14984
|
+
const logger = chunkU2WYUO32_cjs.getLogger(c.env.DB);
|
|
14985
14985
|
const query = c.req.query();
|
|
14986
14986
|
const page = parseInt(query.page || "1");
|
|
14987
14987
|
const limit = parseInt(query.limit || "50");
|
|
@@ -15061,7 +15061,7 @@ adminLogsRoutes.get("/:id", async (c) => {
|
|
|
15061
15061
|
try {
|
|
15062
15062
|
const id = c.req.param("id");
|
|
15063
15063
|
const user = c.get("user");
|
|
15064
|
-
const logger =
|
|
15064
|
+
const logger = chunkU2WYUO32_cjs.getLogger(c.env.DB);
|
|
15065
15065
|
const { logs } = await logger.getLogs({
|
|
15066
15066
|
limit: 1,
|
|
15067
15067
|
offset: 0,
|
|
@@ -15098,7 +15098,7 @@ adminLogsRoutes.get("/:id", async (c) => {
|
|
|
15098
15098
|
adminLogsRoutes.get("/config", async (c) => {
|
|
15099
15099
|
try {
|
|
15100
15100
|
const user = c.get("user");
|
|
15101
|
-
const logger =
|
|
15101
|
+
const logger = chunkU2WYUO32_cjs.getLogger(c.env.DB);
|
|
15102
15102
|
const configs = await logger.getAllConfigs();
|
|
15103
15103
|
const pageData = {
|
|
15104
15104
|
configs,
|
|
@@ -15122,7 +15122,7 @@ adminLogsRoutes.post("/config/:category", async (c) => {
|
|
|
15122
15122
|
const level = formData.get("level");
|
|
15123
15123
|
const retention = parseInt(formData.get("retention"));
|
|
15124
15124
|
const maxSize = parseInt(formData.get("max_size"));
|
|
15125
|
-
const logger =
|
|
15125
|
+
const logger = chunkU2WYUO32_cjs.getLogger(c.env.DB);
|
|
15126
15126
|
await logger.updateConfig(category, {
|
|
15127
15127
|
enabled,
|
|
15128
15128
|
level,
|
|
@@ -15151,7 +15151,7 @@ adminLogsRoutes.get("/export", async (c) => {
|
|
|
15151
15151
|
const category = query.category;
|
|
15152
15152
|
const startDate = query.start_date;
|
|
15153
15153
|
const endDate = query.end_date;
|
|
15154
|
-
const logger =
|
|
15154
|
+
const logger = chunkU2WYUO32_cjs.getLogger(c.env.DB);
|
|
15155
15155
|
const filter = {
|
|
15156
15156
|
limit: 1e4,
|
|
15157
15157
|
// Export up to 10k logs
|
|
@@ -15232,7 +15232,7 @@ adminLogsRoutes.post("/cleanup", async (c) => {
|
|
|
15232
15232
|
error: "Unauthorized. Admin access required."
|
|
15233
15233
|
}, 403);
|
|
15234
15234
|
}
|
|
15235
|
-
const logger =
|
|
15235
|
+
const logger = chunkU2WYUO32_cjs.getLogger(c.env.DB);
|
|
15236
15236
|
await logger.cleanupByRetention();
|
|
15237
15237
|
return c.html(html.html`
|
|
15238
15238
|
<div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded">
|
|
@@ -15254,7 +15254,7 @@ adminLogsRoutes.post("/search", async (c) => {
|
|
|
15254
15254
|
const search = formData.get("search");
|
|
15255
15255
|
const level = formData.get("level");
|
|
15256
15256
|
const category = formData.get("category");
|
|
15257
|
-
const logger =
|
|
15257
|
+
const logger = chunkU2WYUO32_cjs.getLogger(c.env.DB);
|
|
15258
15258
|
const filter = {
|
|
15259
15259
|
limit: 20,
|
|
15260
15260
|
offset: 0,
|
|
@@ -17305,9 +17305,9 @@ function renderStorageUsage(databaseSizeBytes, mediaSizeBytes) {
|
|
|
17305
17305
|
}
|
|
17306
17306
|
|
|
17307
17307
|
// src/routes/admin-dashboard.ts
|
|
17308
|
-
var VERSION =
|
|
17308
|
+
var VERSION = chunkWFHLBYNA_cjs.getCoreVersion();
|
|
17309
17309
|
var router = new hono.Hono();
|
|
17310
|
-
router.use("*",
|
|
17310
|
+
router.use("*", chunkWML2ZMHH_cjs.requireAuth());
|
|
17311
17311
|
router.get("/", async (c) => {
|
|
17312
17312
|
const user = c.get("user");
|
|
17313
17313
|
try {
|
|
@@ -19061,7 +19061,7 @@ function renderCollectionFormPage(data) {
|
|
|
19061
19061
|
|
|
19062
19062
|
// src/routes/admin-collections.ts
|
|
19063
19063
|
var adminCollectionsRoutes = new hono.Hono();
|
|
19064
|
-
adminCollectionsRoutes.use("*",
|
|
19064
|
+
adminCollectionsRoutes.use("*", chunkWML2ZMHH_cjs.requireAuth());
|
|
19065
19065
|
adminCollectionsRoutes.get("/", async (c) => {
|
|
19066
19066
|
try {
|
|
19067
19067
|
const user = c.get("user");
|
|
@@ -21122,7 +21122,7 @@ function renderDatabaseToolsSettings(settings) {
|
|
|
21122
21122
|
|
|
21123
21123
|
// src/routes/admin-settings.ts
|
|
21124
21124
|
var adminSettingsRoutes = new hono.Hono();
|
|
21125
|
-
adminSettingsRoutes.use("*",
|
|
21125
|
+
adminSettingsRoutes.use("*", chunkWML2ZMHH_cjs.requireAuth());
|
|
21126
21126
|
function getMockSettings(user) {
|
|
21127
21127
|
return {
|
|
21128
21128
|
general: {
|
|
@@ -21187,7 +21187,7 @@ adminSettingsRoutes.get("/", (c) => {
|
|
|
21187
21187
|
adminSettingsRoutes.get("/general", async (c) => {
|
|
21188
21188
|
const user = c.get("user");
|
|
21189
21189
|
const db2 = c.env.DB;
|
|
21190
|
-
const settingsService = new
|
|
21190
|
+
const settingsService = new chunkU2WYUO32_cjs.SettingsService(db2);
|
|
21191
21191
|
const generalSettings = await settingsService.getGeneralSettings(user?.email);
|
|
21192
21192
|
const mockSettings = getMockSettings(user);
|
|
21193
21193
|
mockSettings.general = generalSettings;
|
|
@@ -21290,7 +21290,7 @@ adminSettingsRoutes.get("/database-tools", (c) => {
|
|
|
21290
21290
|
adminSettingsRoutes.get("/api/migrations/status", async (c) => {
|
|
21291
21291
|
try {
|
|
21292
21292
|
const db2 = c.env.DB;
|
|
21293
|
-
const migrationService = new
|
|
21293
|
+
const migrationService = new chunkJQIQRMPA_cjs.MigrationService(db2);
|
|
21294
21294
|
const status = await migrationService.getMigrationStatus();
|
|
21295
21295
|
return c.json({
|
|
21296
21296
|
success: true,
|
|
@@ -21314,7 +21314,7 @@ adminSettingsRoutes.post("/api/migrations/run", async (c) => {
|
|
|
21314
21314
|
}, 403);
|
|
21315
21315
|
}
|
|
21316
21316
|
const db2 = c.env.DB;
|
|
21317
|
-
const migrationService = new
|
|
21317
|
+
const migrationService = new chunkJQIQRMPA_cjs.MigrationService(db2);
|
|
21318
21318
|
const result = await migrationService.runPendingMigrations();
|
|
21319
21319
|
return c.json({
|
|
21320
21320
|
success: result.success,
|
|
@@ -21332,7 +21332,7 @@ adminSettingsRoutes.post("/api/migrations/run", async (c) => {
|
|
|
21332
21332
|
adminSettingsRoutes.get("/api/migrations/validate", async (c) => {
|
|
21333
21333
|
try {
|
|
21334
21334
|
const db2 = c.env.DB;
|
|
21335
|
-
const migrationService = new
|
|
21335
|
+
const migrationService = new chunkJQIQRMPA_cjs.MigrationService(db2);
|
|
21336
21336
|
const validation = await migrationService.validateSchema();
|
|
21337
21337
|
return c.json({
|
|
21338
21338
|
success: true,
|
|
@@ -21489,7 +21489,7 @@ adminSettingsRoutes.post("/general", async (c) => {
|
|
|
21489
21489
|
}
|
|
21490
21490
|
const formData = await c.req.formData();
|
|
21491
21491
|
const db2 = c.env.DB;
|
|
21492
|
-
const settingsService = new
|
|
21492
|
+
const settingsService = new chunkU2WYUO32_cjs.SettingsService(db2);
|
|
21493
21493
|
const settings = {
|
|
21494
21494
|
siteName: formData.get("siteName"),
|
|
21495
21495
|
siteDescription: formData.get("siteDescription"),
|
|
@@ -21577,5 +21577,5 @@ exports.auth_default = auth_default;
|
|
|
21577
21577
|
exports.router = router;
|
|
21578
21578
|
exports.test_cleanup_default = test_cleanup_default;
|
|
21579
21579
|
exports.userRoutes = userRoutes;
|
|
21580
|
-
//# sourceMappingURL=chunk-
|
|
21581
|
-
//# sourceMappingURL=chunk-
|
|
21580
|
+
//# sourceMappingURL=chunk-2CP6535T.cjs.map
|
|
21581
|
+
//# sourceMappingURL=chunk-2CP6535T.cjs.map
|