@sonicjs-cms/core 2.13.0 → 2.14.0
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-IYFSNRZN.js → chunk-23DP6TO5.js} +13 -10
- package/dist/chunk-23DP6TO5.js.map +1 -0
- package/dist/{chunk-DB2GJJTM.js → chunk-AFGOH2F6.js} +3 -3
- package/dist/{chunk-DB2GJJTM.js.map → chunk-AFGOH2F6.js.map} +1 -1
- package/dist/{chunk-HVTSE2SF.cjs → chunk-DRWSHIFG.cjs} +102 -99
- package/dist/chunk-DRWSHIFG.cjs.map +1 -0
- package/dist/{chunk-CO4B5EYF.js → chunk-GAVTTYMC.js} +3 -3
- package/dist/{chunk-CO4B5EYF.js.map → chunk-GAVTTYMC.js.map} +1 -1
- package/dist/{chunk-3VAKUFNQ.js → chunk-JKNKO6LA.js} +22 -5
- package/dist/chunk-JKNKO6LA.js.map +1 -0
- package/dist/{chunk-SER23XI4.cjs → chunk-KZ2MFGET.cjs} +22 -5
- package/dist/chunk-KZ2MFGET.cjs.map +1 -0
- package/dist/{chunk-XCP5GCBE.cjs → chunk-YULUPQZV.cjs} +3 -3
- package/dist/{chunk-XCP5GCBE.cjs.map → chunk-YULUPQZV.cjs.map} +1 -1
- package/dist/{chunk-EGUDIX6Q.cjs → chunk-YYMPHM3I.cjs} +4 -4
- package/dist/{chunk-EGUDIX6Q.cjs.map → chunk-YYMPHM3I.cjs.map} +1 -1
- package/dist/index.cjs +853 -99
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +763 -9
- package/dist/index.js.map +1 -1
- package/dist/middleware.cjs +28 -28
- package/dist/middleware.js +2 -2
- package/dist/migrations-F7KVA74T.cjs +13 -0
- package/dist/{migrations-GMHTJI7D.cjs.map → migrations-F7KVA74T.cjs.map} +1 -1
- package/dist/migrations-WKONKRN7.js +4 -0
- package/dist/{migrations-IVFIDOSO.js.map → migrations-WKONKRN7.js.map} +1 -1
- package/dist/{plugin-bootstrap-DVGLQrcO.d.cts → plugin-bootstrap-BGwBraaN.d.cts} +1 -0
- package/dist/{plugin-bootstrap-CZ1GDum7.d.ts → plugin-bootstrap-Drns7X9w.d.ts} +1 -0
- package/dist/routes.cjs +27 -27
- package/dist/routes.js +4 -4
- package/dist/services.cjs +2 -2
- package/dist/services.d.cts +1 -1
- package/dist/services.d.ts +1 -1
- package/dist/services.js +1 -1
- package/dist/utils.cjs +11 -11
- package/dist/utils.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-3VAKUFNQ.js.map +0 -1
- package/dist/chunk-HVTSE2SF.cjs.map +0 -1
- package/dist/chunk-IYFSNRZN.js.map +0 -1
- package/dist/chunk-SER23XI4.cjs.map +0 -1
- package/dist/migrations-GMHTJI7D.cjs +0 -13
- package/dist/migrations-IVFIDOSO.js +0 -4
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkNZWFCUDA_cjs = require('./chunk-NZWFCUDA.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunkYYMPHM3I_cjs = require('./chunk-YYMPHM3I.cjs');
|
|
5
5
|
var chunkI6FFGQIT_cjs = require('./chunk-I6FFGQIT.cjs');
|
|
6
|
-
var
|
|
6
|
+
var chunkKZ2MFGET_cjs = require('./chunk-KZ2MFGET.cjs');
|
|
7
7
|
var chunkQP3OHHON_cjs = require('./chunk-QP3OHHON.cjs');
|
|
8
8
|
var chunk6FHNRRJ3_cjs = require('./chunk-6FHNRRJ3.cjs');
|
|
9
|
-
var
|
|
9
|
+
var chunkYULUPQZV_cjs = require('./chunk-YULUPQZV.cjs');
|
|
10
10
|
var chunkRCQ2HIQD_cjs = require('./chunk-RCQ2HIQD.cjs');
|
|
11
11
|
var chunkMNWKYY5E_cjs = require('./chunk-MNWKYY5E.cjs');
|
|
12
12
|
var hono = require('hono');
|
|
@@ -188,7 +188,7 @@ apiContentCrudRoutes.get("/:id", async (c) => {
|
|
|
188
188
|
}, 500);
|
|
189
189
|
}
|
|
190
190
|
});
|
|
191
|
-
apiContentCrudRoutes.post("/",
|
|
191
|
+
apiContentCrudRoutes.post("/", chunkYYMPHM3I_cjs.requireAuth(), chunkYYMPHM3I_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
192
192
|
try {
|
|
193
193
|
const db = c.env.DB;
|
|
194
194
|
const user = c.get("user");
|
|
@@ -254,7 +254,7 @@ apiContentCrudRoutes.post("/", chunkEGUDIX6Q_cjs.requireAuth(), chunkEGUDIX6Q_cj
|
|
|
254
254
|
}, 500);
|
|
255
255
|
}
|
|
256
256
|
});
|
|
257
|
-
apiContentCrudRoutes.put("/:id",
|
|
257
|
+
apiContentCrudRoutes.put("/:id", chunkYYMPHM3I_cjs.requireAuth(), chunkYYMPHM3I_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
258
258
|
try {
|
|
259
259
|
const id = c.req.param("id");
|
|
260
260
|
const db = c.env.DB;
|
|
@@ -318,7 +318,7 @@ apiContentCrudRoutes.put("/:id", chunkEGUDIX6Q_cjs.requireAuth(), chunkEGUDIX6Q_
|
|
|
318
318
|
}, 500);
|
|
319
319
|
}
|
|
320
320
|
});
|
|
321
|
-
apiContentCrudRoutes.delete("/:id",
|
|
321
|
+
apiContentCrudRoutes.delete("/:id", chunkYYMPHM3I_cjs.requireAuth(), chunkYYMPHM3I_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
322
322
|
try {
|
|
323
323
|
const id = c.req.param("id");
|
|
324
324
|
const db = c.env.DB;
|
|
@@ -354,7 +354,7 @@ apiRoutes.use("*", async (c, next) => {
|
|
|
354
354
|
c.header("X-Response-Time", `${totalTime}ms`);
|
|
355
355
|
});
|
|
356
356
|
apiRoutes.use("*", async (c, next) => {
|
|
357
|
-
const cacheEnabled = await
|
|
357
|
+
const cacheEnabled = await chunkYYMPHM3I_cjs.isPluginActive(c.env.DB, "core-cache");
|
|
358
358
|
c.set("cacheEnabled", cacheEnabled);
|
|
359
359
|
await next();
|
|
360
360
|
});
|
|
@@ -845,7 +845,7 @@ apiRoutes.get("/collections", async (c) => {
|
|
|
845
845
|
return c.json({ error: "Failed to fetch collections" }, 500);
|
|
846
846
|
}
|
|
847
847
|
});
|
|
848
|
-
apiRoutes.get("/content",
|
|
848
|
+
apiRoutes.get("/content", chunkYYMPHM3I_cjs.optionalAuth(), async (c) => {
|
|
849
849
|
const executionStart = Date.now();
|
|
850
850
|
try {
|
|
851
851
|
const db = c.env.DB;
|
|
@@ -868,13 +868,13 @@ apiRoutes.get("/content", chunkEGUDIX6Q_cjs.optionalAuth(), async (c) => {
|
|
|
868
868
|
});
|
|
869
869
|
}
|
|
870
870
|
}
|
|
871
|
-
const filter =
|
|
871
|
+
const filter = chunkYULUPQZV_cjs.QueryFilterBuilder.parseFromQuery(queryParams);
|
|
872
872
|
const normalizedFilter = normalizePublicContentFilter(filter, c.get("user")?.role);
|
|
873
873
|
if (!normalizedFilter.limit) {
|
|
874
874
|
normalizedFilter.limit = 50;
|
|
875
875
|
}
|
|
876
876
|
normalizedFilter.limit = Math.min(normalizedFilter.limit, 1e3);
|
|
877
|
-
const builder3 = new
|
|
877
|
+
const builder3 = new chunkYULUPQZV_cjs.QueryFilterBuilder();
|
|
878
878
|
const queryResult = builder3.build("content", normalizedFilter);
|
|
879
879
|
if (queryResult.errors.length > 0) {
|
|
880
880
|
return c.json({
|
|
@@ -946,7 +946,7 @@ apiRoutes.get("/content", chunkEGUDIX6Q_cjs.optionalAuth(), async (c) => {
|
|
|
946
946
|
}, 500);
|
|
947
947
|
}
|
|
948
948
|
});
|
|
949
|
-
apiRoutes.get("/collections/:collection/content",
|
|
949
|
+
apiRoutes.get("/collections/:collection/content", chunkYYMPHM3I_cjs.optionalAuth(), async (c) => {
|
|
950
950
|
const executionStart = Date.now();
|
|
951
951
|
try {
|
|
952
952
|
const collection = c.req.param("collection");
|
|
@@ -957,7 +957,7 @@ apiRoutes.get("/collections/:collection/content", chunkEGUDIX6Q_cjs.optionalAuth
|
|
|
957
957
|
if (!collectionResult) {
|
|
958
958
|
return c.json({ error: "Collection not found" }, 404);
|
|
959
959
|
}
|
|
960
|
-
const filter =
|
|
960
|
+
const filter = chunkYULUPQZV_cjs.QueryFilterBuilder.parseFromQuery(queryParams);
|
|
961
961
|
const normalizedFilter = normalizePublicContentFilter(filter, c.get("user")?.role);
|
|
962
962
|
if (!normalizedFilter.where) {
|
|
963
963
|
normalizedFilter.where = { and: [] };
|
|
@@ -974,7 +974,7 @@ apiRoutes.get("/collections/:collection/content", chunkEGUDIX6Q_cjs.optionalAuth
|
|
|
974
974
|
normalizedFilter.limit = 50;
|
|
975
975
|
}
|
|
976
976
|
normalizedFilter.limit = Math.min(normalizedFilter.limit, 1e3);
|
|
977
|
-
const builder3 = new
|
|
977
|
+
const builder3 = new chunkYULUPQZV_cjs.QueryFilterBuilder();
|
|
978
978
|
const queryResult = builder3.build("content", normalizedFilter);
|
|
979
979
|
if (queryResult.errors.length > 0) {
|
|
980
980
|
return c.json({
|
|
@@ -1095,7 +1095,7 @@ var fileValidationSchema = zod.z.object({
|
|
|
1095
1095
|
// 50MB max
|
|
1096
1096
|
});
|
|
1097
1097
|
var apiMediaRoutes = new hono.Hono();
|
|
1098
|
-
apiMediaRoutes.use("*",
|
|
1098
|
+
apiMediaRoutes.use("*", chunkYYMPHM3I_cjs.requireAuth());
|
|
1099
1099
|
apiMediaRoutes.post("/upload", async (c) => {
|
|
1100
1100
|
try {
|
|
1101
1101
|
const user = c.get("user");
|
|
@@ -1839,8 +1839,8 @@ apiSystemRoutes.get("/env", (c) => {
|
|
|
1839
1839
|
});
|
|
1840
1840
|
var api_system_default = apiSystemRoutes;
|
|
1841
1841
|
var adminApiRoutes = new hono.Hono();
|
|
1842
|
-
adminApiRoutes.use("*",
|
|
1843
|
-
adminApiRoutes.use("*",
|
|
1842
|
+
adminApiRoutes.use("*", chunkYYMPHM3I_cjs.requireAuth());
|
|
1843
|
+
adminApiRoutes.use("*", chunkYYMPHM3I_cjs.requireRole(["admin", "editor"]));
|
|
1844
1844
|
adminApiRoutes.get("/stats", async (c) => {
|
|
1845
1845
|
try {
|
|
1846
1846
|
const db = c.env.DB;
|
|
@@ -2352,7 +2352,7 @@ adminApiRoutes.delete("/collections/:id", async (c) => {
|
|
|
2352
2352
|
});
|
|
2353
2353
|
adminApiRoutes.get("/migrations/status", async (c) => {
|
|
2354
2354
|
try {
|
|
2355
|
-
const { MigrationService: MigrationService2 } = await import('./migrations-
|
|
2355
|
+
const { MigrationService: MigrationService2 } = await import('./migrations-F7KVA74T.cjs');
|
|
2356
2356
|
const db = c.env.DB;
|
|
2357
2357
|
const migrationService = new MigrationService2(db);
|
|
2358
2358
|
const status = await migrationService.getMigrationStatus();
|
|
@@ -2377,26 +2377,29 @@ adminApiRoutes.post("/migrations/run", async (c) => {
|
|
|
2377
2377
|
error: "Unauthorized. Admin access required."
|
|
2378
2378
|
}, 403);
|
|
2379
2379
|
}
|
|
2380
|
-
const { MigrationService: MigrationService2 } = await import('./migrations-
|
|
2380
|
+
const { MigrationService: MigrationService2 } = await import('./migrations-F7KVA74T.cjs');
|
|
2381
2381
|
const db = c.env.DB;
|
|
2382
2382
|
const migrationService = new MigrationService2(db);
|
|
2383
2383
|
const result = await migrationService.runPendingMigrations();
|
|
2384
2384
|
return c.json({
|
|
2385
2385
|
success: result.success,
|
|
2386
2386
|
message: result.message,
|
|
2387
|
-
applied: result.applied
|
|
2387
|
+
applied: result.applied,
|
|
2388
|
+
errors: result.errors
|
|
2388
2389
|
});
|
|
2389
2390
|
} catch (error) {
|
|
2390
2391
|
console.error("Error running migrations:", error);
|
|
2392
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
2391
2393
|
return c.json({
|
|
2392
2394
|
success: false,
|
|
2393
|
-
error:
|
|
2395
|
+
error: `Failed to run migrations: ${errorMessage}`,
|
|
2396
|
+
errors: [errorMessage]
|
|
2394
2397
|
}, 500);
|
|
2395
2398
|
}
|
|
2396
2399
|
});
|
|
2397
2400
|
adminApiRoutes.get("/migrations/validate", async (c) => {
|
|
2398
2401
|
try {
|
|
2399
|
-
const { MigrationService: MigrationService2 } = await import('./migrations-
|
|
2402
|
+
const { MigrationService: MigrationService2 } = await import('./migrations-F7KVA74T.cjs');
|
|
2400
2403
|
const db = c.env.DB;
|
|
2401
2404
|
const migrationService = new MigrationService2(db);
|
|
2402
2405
|
const validation = await migrationService.validateSchema();
|
|
@@ -5149,7 +5152,7 @@ var JWT_SECRET_FALLBACK = "your-super-secret-jwt-key-change-in-production";
|
|
|
5149
5152
|
async function setCsrfCookie(c) {
|
|
5150
5153
|
const secret = c.env?.JWT_SECRET || JWT_SECRET_FALLBACK;
|
|
5151
5154
|
const isDev = c.env?.ENVIRONMENT === "development" || !c.env?.ENVIRONMENT;
|
|
5152
|
-
const csrfToken = await
|
|
5155
|
+
const csrfToken = await chunkYYMPHM3I_cjs.generateCsrfToken(secret);
|
|
5153
5156
|
cookie.setCookie(c, "csrf_token", csrfToken, {
|
|
5154
5157
|
httpOnly: false,
|
|
5155
5158
|
secure: !isDev,
|
|
@@ -5206,7 +5209,7 @@ var loginSchema = zod.z.object({
|
|
|
5206
5209
|
});
|
|
5207
5210
|
authRoutes.post(
|
|
5208
5211
|
"/register",
|
|
5209
|
-
|
|
5212
|
+
chunkYYMPHM3I_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "register" }),
|
|
5210
5213
|
async (c) => {
|
|
5211
5214
|
try {
|
|
5212
5215
|
const db = c.env.DB;
|
|
@@ -5243,7 +5246,7 @@ authRoutes.post(
|
|
|
5243
5246
|
if (existingUser) {
|
|
5244
5247
|
return c.json({ error: "User with this email or username already exists" }, 400);
|
|
5245
5248
|
}
|
|
5246
|
-
const passwordHash = await
|
|
5249
|
+
const passwordHash = await chunkYYMPHM3I_cjs.AuthManager.hashPassword(password);
|
|
5247
5250
|
const userId = crypto.randomUUID();
|
|
5248
5251
|
const now = /* @__PURE__ */ new Date();
|
|
5249
5252
|
await db.prepare(`
|
|
@@ -5277,7 +5280,7 @@ authRoutes.post(
|
|
|
5277
5280
|
await saveCustomData(db, userId, sanitized);
|
|
5278
5281
|
}
|
|
5279
5282
|
}
|
|
5280
|
-
const token = await
|
|
5283
|
+
const token = await chunkYYMPHM3I_cjs.AuthManager.generateToken(userId, normalizedEmail, "viewer", c.env.JWT_SECRET);
|
|
5281
5284
|
cookie.setCookie(c, "auth_token", token, {
|
|
5282
5285
|
httpOnly: true,
|
|
5283
5286
|
secure: true,
|
|
@@ -5311,7 +5314,7 @@ authRoutes.post(
|
|
|
5311
5314
|
);
|
|
5312
5315
|
authRoutes.post(
|
|
5313
5316
|
"/login",
|
|
5314
|
-
|
|
5317
|
+
chunkYYMPHM3I_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "login" }),
|
|
5315
5318
|
async (c) => {
|
|
5316
5319
|
try {
|
|
5317
5320
|
const body = await c.req.json();
|
|
@@ -5334,19 +5337,19 @@ authRoutes.post(
|
|
|
5334
5337
|
if (!user) {
|
|
5335
5338
|
return c.json({ error: "Invalid email or password" }, 401);
|
|
5336
5339
|
}
|
|
5337
|
-
const isValidPassword = await
|
|
5340
|
+
const isValidPassword = await chunkYYMPHM3I_cjs.AuthManager.verifyPassword(password, user.password_hash);
|
|
5338
5341
|
if (!isValidPassword) {
|
|
5339
5342
|
return c.json({ error: "Invalid email or password" }, 401);
|
|
5340
5343
|
}
|
|
5341
|
-
if (
|
|
5344
|
+
if (chunkYYMPHM3I_cjs.AuthManager.isLegacyHash(user.password_hash)) {
|
|
5342
5345
|
try {
|
|
5343
|
-
const newHash = await
|
|
5346
|
+
const newHash = await chunkYYMPHM3I_cjs.AuthManager.hashPassword(password);
|
|
5344
5347
|
await db.prepare("UPDATE users SET password_hash = ?, updated_at = ? WHERE id = ?").bind(newHash, Date.now(), user.id).run();
|
|
5345
5348
|
} catch (rehashError) {
|
|
5346
5349
|
console.error("Password rehash failed (non-fatal):", rehashError);
|
|
5347
5350
|
}
|
|
5348
5351
|
}
|
|
5349
|
-
const token = await
|
|
5352
|
+
const token = await chunkYYMPHM3I_cjs.AuthManager.generateToken(user.id, user.email, user.role, c.env.JWT_SECRET);
|
|
5350
5353
|
cookie.setCookie(c, "auth_token", token, {
|
|
5351
5354
|
httpOnly: true,
|
|
5352
5355
|
secure: true,
|
|
@@ -5399,7 +5402,7 @@ authRoutes.get("/logout", (c) => {
|
|
|
5399
5402
|
clearCsrfCookie(c);
|
|
5400
5403
|
return c.redirect("/auth/login?message=You have been logged out successfully");
|
|
5401
5404
|
});
|
|
5402
|
-
authRoutes.get("/me",
|
|
5405
|
+
authRoutes.get("/me", chunkYYMPHM3I_cjs.requireAuth(), async (c) => {
|
|
5403
5406
|
try {
|
|
5404
5407
|
const user = c.get("user");
|
|
5405
5408
|
if (!user) {
|
|
@@ -5416,13 +5419,13 @@ authRoutes.get("/me", chunkEGUDIX6Q_cjs.requireAuth(), async (c) => {
|
|
|
5416
5419
|
return c.json({ error: "Failed to get user" }, 500);
|
|
5417
5420
|
}
|
|
5418
5421
|
});
|
|
5419
|
-
authRoutes.post("/refresh",
|
|
5422
|
+
authRoutes.post("/refresh", chunkYYMPHM3I_cjs.requireAuth(), async (c) => {
|
|
5420
5423
|
try {
|
|
5421
5424
|
const user = c.get("user");
|
|
5422
5425
|
if (!user) {
|
|
5423
5426
|
return c.json({ error: "Not authenticated" }, 401);
|
|
5424
5427
|
}
|
|
5425
|
-
const token = await
|
|
5428
|
+
const token = await chunkYYMPHM3I_cjs.AuthManager.generateToken(user.userId, user.email, user.role, c.env.JWT_SECRET);
|
|
5426
5429
|
cookie.setCookie(c, "auth_token", token, {
|
|
5427
5430
|
httpOnly: true,
|
|
5428
5431
|
secure: true,
|
|
@@ -5439,7 +5442,7 @@ authRoutes.post("/refresh", chunkEGUDIX6Q_cjs.requireAuth(), async (c) => {
|
|
|
5439
5442
|
});
|
|
5440
5443
|
authRoutes.post(
|
|
5441
5444
|
"/register/form",
|
|
5442
|
-
|
|
5445
|
+
chunkYYMPHM3I_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "register" }),
|
|
5443
5446
|
async (c) => {
|
|
5444
5447
|
try {
|
|
5445
5448
|
const db = c.env.DB;
|
|
@@ -5486,7 +5489,7 @@ authRoutes.post(
|
|
|
5486
5489
|
</div>
|
|
5487
5490
|
`);
|
|
5488
5491
|
}
|
|
5489
|
-
const passwordHash = await
|
|
5492
|
+
const passwordHash = await chunkYYMPHM3I_cjs.AuthManager.hashPassword(password);
|
|
5490
5493
|
const role = isFirstUser ? "admin" : "viewer";
|
|
5491
5494
|
const userId = crypto.randomUUID();
|
|
5492
5495
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -5521,7 +5524,7 @@ authRoutes.post(
|
|
|
5521
5524
|
await saveCustomData(db, userId, sanitized);
|
|
5522
5525
|
}
|
|
5523
5526
|
}
|
|
5524
|
-
const token = await
|
|
5527
|
+
const token = await chunkYYMPHM3I_cjs.AuthManager.generateToken(userId, normalizedEmail, role, c.env.JWT_SECRET);
|
|
5525
5528
|
cookie.setCookie(c, "auth_token", token, {
|
|
5526
5529
|
httpOnly: true,
|
|
5527
5530
|
secure: false,
|
|
@@ -5554,7 +5557,7 @@ authRoutes.post(
|
|
|
5554
5557
|
);
|
|
5555
5558
|
authRoutes.post(
|
|
5556
5559
|
"/login/form",
|
|
5557
|
-
|
|
5560
|
+
chunkYYMPHM3I_cjs.rateLimit({ max: 30, windowMs: 60 * 1e3, keyPrefix: "login" }),
|
|
5558
5561
|
async (c) => {
|
|
5559
5562
|
try {
|
|
5560
5563
|
const formData = await c.req.formData();
|
|
@@ -5578,7 +5581,7 @@ authRoutes.post(
|
|
|
5578
5581
|
</div>
|
|
5579
5582
|
`);
|
|
5580
5583
|
}
|
|
5581
|
-
const isValidPassword = await
|
|
5584
|
+
const isValidPassword = await chunkYYMPHM3I_cjs.AuthManager.verifyPassword(password, user.password_hash);
|
|
5582
5585
|
if (!isValidPassword) {
|
|
5583
5586
|
return c.html(html.html`
|
|
5584
5587
|
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded">
|
|
@@ -5586,15 +5589,15 @@ authRoutes.post(
|
|
|
5586
5589
|
</div>
|
|
5587
5590
|
`);
|
|
5588
5591
|
}
|
|
5589
|
-
if (
|
|
5592
|
+
if (chunkYYMPHM3I_cjs.AuthManager.isLegacyHash(user.password_hash)) {
|
|
5590
5593
|
try {
|
|
5591
|
-
const newHash = await
|
|
5594
|
+
const newHash = await chunkYYMPHM3I_cjs.AuthManager.hashPassword(password);
|
|
5592
5595
|
await db.prepare("UPDATE users SET password_hash = ?, updated_at = ? WHERE id = ?").bind(newHash, Date.now(), user.id).run();
|
|
5593
5596
|
} catch (rehashError) {
|
|
5594
5597
|
console.error("Password rehash failed (non-fatal):", rehashError);
|
|
5595
5598
|
}
|
|
5596
5599
|
}
|
|
5597
|
-
const token = await
|
|
5600
|
+
const token = await chunkYYMPHM3I_cjs.AuthManager.generateToken(user.id, user.email, user.role, c.env.JWT_SECRET);
|
|
5598
5601
|
cookie.setCookie(c, "auth_token", token, {
|
|
5599
5602
|
httpOnly: true,
|
|
5600
5603
|
secure: false,
|
|
@@ -5636,7 +5639,7 @@ authRoutes.post(
|
|
|
5636
5639
|
);
|
|
5637
5640
|
authRoutes.post(
|
|
5638
5641
|
"/seed-admin",
|
|
5639
|
-
|
|
5642
|
+
chunkYYMPHM3I_cjs.rateLimit({ max: 10, windowMs: 60 * 1e3, keyPrefix: "seed-admin" }),
|
|
5640
5643
|
async (c) => {
|
|
5641
5644
|
try {
|
|
5642
5645
|
const db = c.env.DB;
|
|
@@ -5658,7 +5661,7 @@ authRoutes.post(
|
|
|
5658
5661
|
`).run();
|
|
5659
5662
|
const existingAdmin = await db.prepare("SELECT id FROM users WHERE email = ? OR username = ?").bind("admin@sonicjs.com", "admin").first();
|
|
5660
5663
|
if (existingAdmin) {
|
|
5661
|
-
const passwordHash2 = await
|
|
5664
|
+
const passwordHash2 = await chunkYYMPHM3I_cjs.AuthManager.hashPassword("sonicjs!");
|
|
5662
5665
|
await db.prepare("UPDATE users SET password_hash = ?, updated_at = ? WHERE id = ?").bind(passwordHash2, Date.now(), existingAdmin.id).run();
|
|
5663
5666
|
return c.json({
|
|
5664
5667
|
message: "Admin user already exists (password updated)",
|
|
@@ -5670,7 +5673,7 @@ authRoutes.post(
|
|
|
5670
5673
|
}
|
|
5671
5674
|
});
|
|
5672
5675
|
}
|
|
5673
|
-
const passwordHash = await
|
|
5676
|
+
const passwordHash = await chunkYYMPHM3I_cjs.AuthManager.hashPassword("sonicjs!");
|
|
5674
5677
|
const userId = "admin-user-id";
|
|
5675
5678
|
const now = Date.now();
|
|
5676
5679
|
const adminEmail = "admin@sonicjs.com".toLowerCase();
|
|
@@ -5891,7 +5894,7 @@ authRoutes.post("/accept-invitation", async (c) => {
|
|
|
5891
5894
|
if (existingUsername) {
|
|
5892
5895
|
return c.json({ error: "Username is already taken" }, 400);
|
|
5893
5896
|
}
|
|
5894
|
-
const passwordHash = await
|
|
5897
|
+
const passwordHash = await chunkYYMPHM3I_cjs.AuthManager.hashPassword(password);
|
|
5895
5898
|
const updateStmt = db.prepare(`
|
|
5896
5899
|
UPDATE users SET
|
|
5897
5900
|
username = ?,
|
|
@@ -5910,7 +5913,7 @@ authRoutes.post("/accept-invitation", async (c) => {
|
|
|
5910
5913
|
Date.now(),
|
|
5911
5914
|
invitedUser.id
|
|
5912
5915
|
).run();
|
|
5913
|
-
const authToken = await
|
|
5916
|
+
const authToken = await chunkYYMPHM3I_cjs.AuthManager.generateToken(invitedUser.id, invitedUser.email, invitedUser.role, c.env.JWT_SECRET);
|
|
5914
5917
|
cookie.setCookie(c, "auth_token", authToken, {
|
|
5915
5918
|
httpOnly: true,
|
|
5916
5919
|
secure: true,
|
|
@@ -5927,7 +5930,7 @@ authRoutes.post("/accept-invitation", async (c) => {
|
|
|
5927
5930
|
});
|
|
5928
5931
|
authRoutes.post(
|
|
5929
5932
|
"/request-password-reset",
|
|
5930
|
-
|
|
5933
|
+
chunkYYMPHM3I_cjs.rateLimit({ max: 3, windowMs: 15 * 60 * 1e3, keyPrefix: "password-reset" }),
|
|
5931
5934
|
async (c) => {
|
|
5932
5935
|
try {
|
|
5933
5936
|
const formData = await c.req.formData();
|
|
@@ -6145,7 +6148,7 @@ authRoutes.post("/reset-password", async (c) => {
|
|
|
6145
6148
|
if (Date.now() > user.password_reset_expires) {
|
|
6146
6149
|
return c.json({ error: "Reset token has expired" }, 400);
|
|
6147
6150
|
}
|
|
6148
|
-
const newPasswordHash = await
|
|
6151
|
+
const newPasswordHash = await chunkYYMPHM3I_cjs.AuthManager.hashPassword(password);
|
|
6149
6152
|
try {
|
|
6150
6153
|
const historyStmt = db.prepare(`
|
|
6151
6154
|
INSERT INTO password_history (id, user_id, password_hash, created_at)
|
|
@@ -9521,9 +9524,9 @@ function parseFieldValue(field, formData, options = {}) {
|
|
|
9521
9524
|
const { skipValidation = false } = options;
|
|
9522
9525
|
const value = formData.get(field.field_name);
|
|
9523
9526
|
const errors = [];
|
|
9524
|
-
const blocksConfig =
|
|
9527
|
+
const blocksConfig = chunkYULUPQZV_cjs.getBlocksFieldConfig(field.field_options);
|
|
9525
9528
|
if (blocksConfig) {
|
|
9526
|
-
const parsed =
|
|
9529
|
+
const parsed = chunkYULUPQZV_cjs.parseBlocksValue(value, blocksConfig);
|
|
9527
9530
|
if (!skipValidation && field.is_required && parsed.value.length === 0) {
|
|
9528
9531
|
parsed.errors.push(`${field.field_label} is required`);
|
|
9529
9532
|
}
|
|
@@ -9633,7 +9636,7 @@ function extractFieldData(fields, formData, options = {}) {
|
|
|
9633
9636
|
}
|
|
9634
9637
|
return { data, errors };
|
|
9635
9638
|
}
|
|
9636
|
-
adminContentRoutes.use("*",
|
|
9639
|
+
adminContentRoutes.use("*", chunkYYMPHM3I_cjs.requireAuth());
|
|
9637
9640
|
async function getCollectionFields(db, collectionId) {
|
|
9638
9641
|
const cache = chunkNZWFCUDA_cjs.getCacheService(chunkNZWFCUDA_cjs.CACHE_CONFIGS.collection);
|
|
9639
9642
|
return cache.getOrSet(
|
|
@@ -10324,7 +10327,7 @@ adminContentRoutes.put("/:id", async (c) => {
|
|
|
10324
10327
|
`);
|
|
10325
10328
|
}
|
|
10326
10329
|
});
|
|
10327
|
-
adminContentRoutes.post("/preview",
|
|
10330
|
+
adminContentRoutes.post("/preview", chunkYYMPHM3I_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
10328
10331
|
try {
|
|
10329
10332
|
const formData = await c.req.formData();
|
|
10330
10333
|
const collectionId = formData.get("collection_id");
|
|
@@ -10702,7 +10705,7 @@ adminContentRoutes.post("/:id/restore/:version", async (c) => {
|
|
|
10702
10705
|
return c.json({ success: false, error: "Failed to restore version" });
|
|
10703
10706
|
}
|
|
10704
10707
|
});
|
|
10705
|
-
adminContentRoutes.get("/:id/version/:version/preview",
|
|
10708
|
+
adminContentRoutes.get("/:id/version/:version/preview", chunkYYMPHM3I_cjs.requireRole(["admin", "editor", "author"]), async (c) => {
|
|
10706
10709
|
try {
|
|
10707
10710
|
const id = c.req.param("id");
|
|
10708
10711
|
const version = parseInt(c.req.param("version") || "0");
|
|
@@ -12703,14 +12706,14 @@ function renderUsersListPage(data) {
|
|
|
12703
12706
|
|
|
12704
12707
|
// src/routes/admin-users.ts
|
|
12705
12708
|
var userRoutes = new hono.Hono();
|
|
12706
|
-
userRoutes.use("*",
|
|
12707
|
-
userRoutes.use("/users/*",
|
|
12708
|
-
userRoutes.use("/users",
|
|
12709
|
-
userRoutes.use("/invite-user",
|
|
12710
|
-
userRoutes.use("/resend-invitation/*",
|
|
12711
|
-
userRoutes.use("/cancel-invitation/*",
|
|
12712
|
-
userRoutes.use("/activity-logs",
|
|
12713
|
-
userRoutes.use("/activity-logs/*",
|
|
12709
|
+
userRoutes.use("*", chunkYYMPHM3I_cjs.requireAuth());
|
|
12710
|
+
userRoutes.use("/users/*", chunkYYMPHM3I_cjs.requireRole(["admin"]));
|
|
12711
|
+
userRoutes.use("/users", chunkYYMPHM3I_cjs.requireRole(["admin"]));
|
|
12712
|
+
userRoutes.use("/invite-user", chunkYYMPHM3I_cjs.requireRole(["admin"]));
|
|
12713
|
+
userRoutes.use("/resend-invitation/*", chunkYYMPHM3I_cjs.requireRole(["admin"]));
|
|
12714
|
+
userRoutes.use("/cancel-invitation/*", chunkYYMPHM3I_cjs.requireRole(["admin"]));
|
|
12715
|
+
userRoutes.use("/activity-logs", chunkYYMPHM3I_cjs.requireRole(["admin"]));
|
|
12716
|
+
userRoutes.use("/activity-logs/*", chunkYYMPHM3I_cjs.requireRole(["admin"]));
|
|
12714
12717
|
userRoutes.get("/", (c) => {
|
|
12715
12718
|
return c.redirect("/admin/dashboard");
|
|
12716
12719
|
});
|
|
@@ -12880,7 +12883,7 @@ userRoutes.put("/profile", async (c) => {
|
|
|
12880
12883
|
}
|
|
12881
12884
|
await saveCustomData(db, user.userId, sanitized);
|
|
12882
12885
|
}
|
|
12883
|
-
await
|
|
12886
|
+
await chunkYYMPHM3I_cjs.logActivity(
|
|
12884
12887
|
db,
|
|
12885
12888
|
user.userId,
|
|
12886
12889
|
"profile.update",
|
|
@@ -12943,7 +12946,7 @@ userRoutes.post("/profile/avatar", async (c) => {
|
|
|
12943
12946
|
SELECT first_name, last_name FROM users WHERE id = ?
|
|
12944
12947
|
`);
|
|
12945
12948
|
const userData = await userStmt.bind(user.userId).first();
|
|
12946
|
-
await
|
|
12949
|
+
await chunkYYMPHM3I_cjs.logActivity(
|
|
12947
12950
|
db,
|
|
12948
12951
|
user.userId,
|
|
12949
12952
|
"profile.avatar_update",
|
|
@@ -13014,7 +13017,7 @@ userRoutes.post("/profile/password", async (c) => {
|
|
|
13014
13017
|
dismissible: true
|
|
13015
13018
|
}));
|
|
13016
13019
|
}
|
|
13017
|
-
const validPassword = await
|
|
13020
|
+
const validPassword = await chunkYYMPHM3I_cjs.AuthManager.verifyPassword(currentPassword, userData.password_hash);
|
|
13018
13021
|
if (!validPassword) {
|
|
13019
13022
|
return c.html(renderAlert2({
|
|
13020
13023
|
type: "error",
|
|
@@ -13022,7 +13025,7 @@ userRoutes.post("/profile/password", async (c) => {
|
|
|
13022
13025
|
dismissible: true
|
|
13023
13026
|
}));
|
|
13024
13027
|
}
|
|
13025
|
-
const newPasswordHash = await
|
|
13028
|
+
const newPasswordHash = await chunkYYMPHM3I_cjs.AuthManager.hashPassword(newPassword);
|
|
13026
13029
|
const historyStmt = db.prepare(`
|
|
13027
13030
|
INSERT INTO password_history (id, user_id, password_hash, created_at)
|
|
13028
13031
|
VALUES (?, ?, ?, ?)
|
|
@@ -13038,7 +13041,7 @@ userRoutes.post("/profile/password", async (c) => {
|
|
|
13038
13041
|
WHERE id = ?
|
|
13039
13042
|
`);
|
|
13040
13043
|
await updateStmt.bind(newPasswordHash, Date.now(), user.userId).run();
|
|
13041
|
-
await
|
|
13044
|
+
await chunkYYMPHM3I_cjs.logActivity(
|
|
13042
13045
|
db,
|
|
13043
13046
|
user.userId,
|
|
13044
13047
|
"profile.password_change",
|
|
@@ -13105,7 +13108,7 @@ userRoutes.get("/users", async (c) => {
|
|
|
13105
13108
|
`);
|
|
13106
13109
|
const countResult = await countStmt.bind(...params).first();
|
|
13107
13110
|
const totalUsers = countResult?.total || 0;
|
|
13108
|
-
await
|
|
13111
|
+
await chunkYYMPHM3I_cjs.logActivity(
|
|
13109
13112
|
db,
|
|
13110
13113
|
user.userId,
|
|
13111
13114
|
"users.list_view",
|
|
@@ -13263,7 +13266,7 @@ userRoutes.post("/users/new", async (c) => {
|
|
|
13263
13266
|
dismissible: true
|
|
13264
13267
|
}));
|
|
13265
13268
|
}
|
|
13266
|
-
const passwordHash = await
|
|
13269
|
+
const passwordHash = await chunkYYMPHM3I_cjs.AuthManager.hashPassword(password);
|
|
13267
13270
|
const userId = crypto.randomUUID();
|
|
13268
13271
|
const createStmt = db.prepare(`
|
|
13269
13272
|
INSERT INTO users (
|
|
@@ -13286,7 +13289,7 @@ userRoutes.post("/users/new", async (c) => {
|
|
|
13286
13289
|
Date.now(),
|
|
13287
13290
|
Date.now()
|
|
13288
13291
|
).run();
|
|
13289
|
-
await
|
|
13292
|
+
await chunkYYMPHM3I_cjs.logActivity(
|
|
13290
13293
|
db,
|
|
13291
13294
|
user.userId,
|
|
13292
13295
|
"user!.create",
|
|
@@ -13325,7 +13328,7 @@ userRoutes.get("/users/:id", async (c) => {
|
|
|
13325
13328
|
if (!userRecord) {
|
|
13326
13329
|
return c.json({ error: "User not found" }, 404);
|
|
13327
13330
|
}
|
|
13328
|
-
await
|
|
13331
|
+
await chunkYYMPHM3I_cjs.logActivity(
|
|
13329
13332
|
db,
|
|
13330
13333
|
user.userId,
|
|
13331
13334
|
"user!.view",
|
|
@@ -13551,7 +13554,7 @@ userRoutes.put("/users/:id", async (c) => {
|
|
|
13551
13554
|
userId
|
|
13552
13555
|
).run();
|
|
13553
13556
|
if (newPassword) {
|
|
13554
|
-
const passwordHash = await
|
|
13557
|
+
const passwordHash = await chunkYYMPHM3I_cjs.AuthManager.hashPassword(newPassword);
|
|
13555
13558
|
const updatePasswordStmt = db.prepare(`
|
|
13556
13559
|
UPDATE users SET password_hash = ?, updated_at = ? WHERE id = ?
|
|
13557
13560
|
`);
|
|
@@ -13605,7 +13608,7 @@ userRoutes.put("/users/:id", async (c) => {
|
|
|
13605
13608
|
).run();
|
|
13606
13609
|
}
|
|
13607
13610
|
}
|
|
13608
|
-
await
|
|
13611
|
+
await chunkYYMPHM3I_cjs.logActivity(
|
|
13609
13612
|
db,
|
|
13610
13613
|
user.userId,
|
|
13611
13614
|
"user.update",
|
|
@@ -13650,7 +13653,7 @@ userRoutes.post("/users/:id/toggle", async (c) => {
|
|
|
13650
13653
|
UPDATE users SET is_active = ?, updated_at = ? WHERE id = ?
|
|
13651
13654
|
`);
|
|
13652
13655
|
await toggleStmt.bind(active ? 1 : 0, Date.now(), userId).run();
|
|
13653
|
-
await
|
|
13656
|
+
await chunkYYMPHM3I_cjs.logActivity(
|
|
13654
13657
|
db,
|
|
13655
13658
|
user.userId,
|
|
13656
13659
|
active ? "user.activate" : "user.deactivate",
|
|
@@ -13691,7 +13694,7 @@ userRoutes.delete("/users/:id", async (c) => {
|
|
|
13691
13694
|
DELETE FROM users WHERE id = ?
|
|
13692
13695
|
`);
|
|
13693
13696
|
await deleteStmt.bind(userId).run();
|
|
13694
|
-
await
|
|
13697
|
+
await chunkYYMPHM3I_cjs.logActivity(
|
|
13695
13698
|
db,
|
|
13696
13699
|
user.userId,
|
|
13697
13700
|
"user!.hard_delete",
|
|
@@ -13710,7 +13713,7 @@ userRoutes.delete("/users/:id", async (c) => {
|
|
|
13710
13713
|
UPDATE users SET is_active = 0, updated_at = ? WHERE id = ?
|
|
13711
13714
|
`);
|
|
13712
13715
|
await deleteStmt.bind(Date.now(), userId).run();
|
|
13713
|
-
await
|
|
13716
|
+
await chunkYYMPHM3I_cjs.logActivity(
|
|
13714
13717
|
db,
|
|
13715
13718
|
user.userId,
|
|
13716
13719
|
"user!.soft_delete",
|
|
@@ -13776,7 +13779,7 @@ userRoutes.post("/invite-user", async (c) => {
|
|
|
13776
13779
|
Date.now(),
|
|
13777
13780
|
Date.now()
|
|
13778
13781
|
).run();
|
|
13779
|
-
await
|
|
13782
|
+
await chunkYYMPHM3I_cjs.logActivity(
|
|
13780
13783
|
db,
|
|
13781
13784
|
user.userId,
|
|
13782
13785
|
"user!.invite_sent",
|
|
@@ -13833,7 +13836,7 @@ userRoutes.post("/resend-invitation/:id", async (c) => {
|
|
|
13833
13836
|
Date.now(),
|
|
13834
13837
|
userId
|
|
13835
13838
|
).run();
|
|
13836
|
-
await
|
|
13839
|
+
await chunkYYMPHM3I_cjs.logActivity(
|
|
13837
13840
|
db,
|
|
13838
13841
|
user.userId,
|
|
13839
13842
|
"user!.invitation_resent",
|
|
@@ -13869,7 +13872,7 @@ userRoutes.delete("/cancel-invitation/:id", async (c) => {
|
|
|
13869
13872
|
}
|
|
13870
13873
|
const deleteStmt = db.prepare(`DELETE FROM users WHERE id = ?`);
|
|
13871
13874
|
await deleteStmt.bind(userId).run();
|
|
13872
|
-
await
|
|
13875
|
+
await chunkYYMPHM3I_cjs.logActivity(
|
|
13873
13876
|
db,
|
|
13874
13877
|
user.userId,
|
|
13875
13878
|
"user!.invitation_cancelled",
|
|
@@ -13952,7 +13955,7 @@ userRoutes.get("/activity-logs", async (c) => {
|
|
|
13952
13955
|
...log,
|
|
13953
13956
|
details: log.details ? JSON.parse(log.details) : null
|
|
13954
13957
|
}));
|
|
13955
|
-
await
|
|
13958
|
+
await chunkYYMPHM3I_cjs.logActivity(
|
|
13956
13959
|
db,
|
|
13957
13960
|
user.userId,
|
|
13958
13961
|
"activity.logs_viewed",
|
|
@@ -14059,7 +14062,7 @@ userRoutes.get("/activity-logs/export", async (c) => {
|
|
|
14059
14062
|
csvRows.push(row.join(","));
|
|
14060
14063
|
}
|
|
14061
14064
|
const csvContent = csvRows.join("\n");
|
|
14062
|
-
await
|
|
14065
|
+
await chunkYYMPHM3I_cjs.logActivity(
|
|
14063
14066
|
db,
|
|
14064
14067
|
user.userId,
|
|
14065
14068
|
"activity.logs_exported",
|
|
@@ -15398,7 +15401,7 @@ var fileValidationSchema2 = zod.z.object({
|
|
|
15398
15401
|
// 50MB max
|
|
15399
15402
|
});
|
|
15400
15403
|
var adminMediaRoutes = new hono.Hono();
|
|
15401
|
-
adminMediaRoutes.use("*",
|
|
15404
|
+
adminMediaRoutes.use("*", chunkYYMPHM3I_cjs.requireAuth());
|
|
15402
15405
|
adminMediaRoutes.get("/", async (c) => {
|
|
15403
15406
|
try {
|
|
15404
15407
|
const user = c.get("user");
|
|
@@ -15984,7 +15987,7 @@ adminMediaRoutes.put("/:id", async (c) => {
|
|
|
15984
15987
|
`);
|
|
15985
15988
|
}
|
|
15986
15989
|
});
|
|
15987
|
-
adminMediaRoutes.delete("/cleanup",
|
|
15990
|
+
adminMediaRoutes.delete("/cleanup", chunkYYMPHM3I_cjs.requireRole("admin"), async (c) => {
|
|
15988
15991
|
try {
|
|
15989
15992
|
const db = c.env.DB;
|
|
15990
15993
|
const allMediaStmt = db.prepare("SELECT id, r2_key, filename FROM media WHERE deleted_at IS NULL");
|
|
@@ -18209,7 +18212,7 @@ function renderEmailSettingsContent(plugin, settings) {
|
|
|
18209
18212
|
|
|
18210
18213
|
// src/routes/admin-plugins.ts
|
|
18211
18214
|
var adminPluginRoutes = new hono.Hono();
|
|
18212
|
-
adminPluginRoutes.use("*",
|
|
18215
|
+
adminPluginRoutes.use("*", chunkYYMPHM3I_cjs.requireAuth());
|
|
18213
18216
|
var AVAILABLE_PLUGINS = [
|
|
18214
18217
|
{
|
|
18215
18218
|
id: "third-party-faq",
|
|
@@ -19703,7 +19706,7 @@ function renderLogConfigPage(data) {
|
|
|
19703
19706
|
|
|
19704
19707
|
// src/routes/admin-logs.ts
|
|
19705
19708
|
var adminLogsRoutes = new hono.Hono();
|
|
19706
|
-
adminLogsRoutes.use("*",
|
|
19709
|
+
adminLogsRoutes.use("*", chunkYYMPHM3I_cjs.requireAuth());
|
|
19707
19710
|
adminLogsRoutes.get("/", async (c) => {
|
|
19708
19711
|
try {
|
|
19709
19712
|
const user = c.get("user");
|
|
@@ -22031,9 +22034,9 @@ function renderStorageUsage(databaseSizeBytes, mediaSizeBytes) {
|
|
|
22031
22034
|
}
|
|
22032
22035
|
|
|
22033
22036
|
// src/routes/admin-dashboard.ts
|
|
22034
|
-
var VERSION =
|
|
22037
|
+
var VERSION = chunkYULUPQZV_cjs.getCoreVersion();
|
|
22035
22038
|
var router = new hono.Hono();
|
|
22036
|
-
router.use("*",
|
|
22039
|
+
router.use("*", chunkYYMPHM3I_cjs.requireAuth());
|
|
22037
22040
|
router.get("/", async (c) => {
|
|
22038
22041
|
const user = c.get("user");
|
|
22039
22042
|
try {
|
|
@@ -23852,10 +23855,10 @@ function renderCollectionFormPage(data) {
|
|
|
23852
23855
|
|
|
23853
23856
|
// src/routes/admin-collections.ts
|
|
23854
23857
|
var adminCollectionsRoutes = new hono.Hono();
|
|
23855
|
-
adminCollectionsRoutes.use("*",
|
|
23856
|
-
adminCollectionsRoutes.post("*",
|
|
23857
|
-
adminCollectionsRoutes.put("*",
|
|
23858
|
-
adminCollectionsRoutes.delete("*",
|
|
23858
|
+
adminCollectionsRoutes.use("*", chunkYYMPHM3I_cjs.requireAuth());
|
|
23859
|
+
adminCollectionsRoutes.post("*", chunkYYMPHM3I_cjs.requireRole(["admin"]));
|
|
23860
|
+
adminCollectionsRoutes.put("*", chunkYYMPHM3I_cjs.requireRole(["admin"]));
|
|
23861
|
+
adminCollectionsRoutes.delete("*", chunkYYMPHM3I_cjs.requireRole(["admin"]));
|
|
23859
23862
|
adminCollectionsRoutes.get("/", async (c) => {
|
|
23860
23863
|
try {
|
|
23861
23864
|
const user = c.get("user");
|
|
@@ -26051,7 +26054,7 @@ function renderDatabaseToolsSettings(settings) {
|
|
|
26051
26054
|
|
|
26052
26055
|
// src/routes/admin-settings.ts
|
|
26053
26056
|
var adminSettingsRoutes = new hono.Hono();
|
|
26054
|
-
adminSettingsRoutes.use("*",
|
|
26057
|
+
adminSettingsRoutes.use("*", chunkYYMPHM3I_cjs.requireAuth());
|
|
26055
26058
|
function getMockSettings(user) {
|
|
26056
26059
|
return {
|
|
26057
26060
|
general: {
|
|
@@ -26219,7 +26222,7 @@ adminSettingsRoutes.get("/database-tools", (c) => {
|
|
|
26219
26222
|
adminSettingsRoutes.get("/api/migrations/status", async (c) => {
|
|
26220
26223
|
try {
|
|
26221
26224
|
const db = c.env.DB;
|
|
26222
|
-
const migrationService = new
|
|
26225
|
+
const migrationService = new chunkKZ2MFGET_cjs.MigrationService(db);
|
|
26223
26226
|
const status = await migrationService.getMigrationStatus();
|
|
26224
26227
|
return c.json({
|
|
26225
26228
|
success: true,
|
|
@@ -26243,7 +26246,7 @@ adminSettingsRoutes.post("/api/migrations/run", async (c) => {
|
|
|
26243
26246
|
}, 403);
|
|
26244
26247
|
}
|
|
26245
26248
|
const db = c.env.DB;
|
|
26246
|
-
const migrationService = new
|
|
26249
|
+
const migrationService = new chunkKZ2MFGET_cjs.MigrationService(db);
|
|
26247
26250
|
const result = await migrationService.runPendingMigrations();
|
|
26248
26251
|
return c.json({
|
|
26249
26252
|
success: result.success,
|
|
@@ -26261,7 +26264,7 @@ adminSettingsRoutes.post("/api/migrations/run", async (c) => {
|
|
|
26261
26264
|
adminSettingsRoutes.get("/api/migrations/validate", async (c) => {
|
|
26262
26265
|
try {
|
|
26263
26266
|
const db = c.env.DB;
|
|
26264
|
-
const migrationService = new
|
|
26267
|
+
const migrationService = new chunkKZ2MFGET_cjs.MigrationService(db);
|
|
26265
26268
|
const validation = await migrationService.validateSchema();
|
|
26266
26269
|
return c.json({
|
|
26267
26270
|
success: true,
|
|
@@ -28151,7 +28154,7 @@ function renderFormCreatePage(data) {
|
|
|
28151
28154
|
|
|
28152
28155
|
// src/routes/admin-forms.ts
|
|
28153
28156
|
var adminFormsRoutes = new hono.Hono();
|
|
28154
|
-
adminFormsRoutes.use("*",
|
|
28157
|
+
adminFormsRoutes.use("*", chunkYYMPHM3I_cjs.requireAuth());
|
|
28155
28158
|
adminFormsRoutes.get("/", async (c) => {
|
|
28156
28159
|
try {
|
|
28157
28160
|
const user = c.get("user");
|
|
@@ -29324,9 +29327,9 @@ function renderAPIReferencePage(data) {
|
|
|
29324
29327
|
}
|
|
29325
29328
|
|
|
29326
29329
|
// src/routes/admin-api-reference.ts
|
|
29327
|
-
var VERSION2 =
|
|
29330
|
+
var VERSION2 = chunkYULUPQZV_cjs.getCoreVersion();
|
|
29328
29331
|
var router2 = new hono.Hono();
|
|
29329
|
-
router2.use("*",
|
|
29332
|
+
router2.use("*", chunkYYMPHM3I_cjs.requireAuth());
|
|
29330
29333
|
router2.get("/", async (c) => {
|
|
29331
29334
|
const user = c.get("user");
|
|
29332
29335
|
try {
|
|
@@ -29417,5 +29420,5 @@ exports.router2 = router2;
|
|
|
29417
29420
|
exports.test_cleanup_default = test_cleanup_default;
|
|
29418
29421
|
exports.userProfilesPlugin = userProfilesPlugin;
|
|
29419
29422
|
exports.userRoutes = userRoutes;
|
|
29420
|
-
//# sourceMappingURL=chunk-
|
|
29421
|
-
//# sourceMappingURL=chunk-
|
|
29423
|
+
//# sourceMappingURL=chunk-DRWSHIFG.cjs.map
|
|
29424
|
+
//# sourceMappingURL=chunk-DRWSHIFG.cjs.map
|