@sonicjs-cms/core 2.17.2 → 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-ITGOUYVN.js → chunk-4R3NOOL3.js} +2 -2
- package/dist/{chunk-ITGOUYVN.js.map → chunk-4R3NOOL3.js.map} +1 -1
- package/dist/{chunk-LVGB5UU5.cjs → chunk-C54YUA23.cjs} +2 -2
- package/dist/{chunk-LVGB5UU5.cjs.map → chunk-C54YUA23.cjs.map} +1 -1
- package/dist/{chunk-P4RAIX7B.cjs → chunk-DSUJ5YQH.cjs} +8 -8
- package/dist/{chunk-P4RAIX7B.cjs.map → chunk-DSUJ5YQH.cjs.map} +1 -1
- package/dist/{chunk-NAYUXSNR.js → chunk-EW5NOBVU.js} +9 -3
- package/dist/chunk-EW5NOBVU.js.map +1 -0
- package/dist/{chunk-K6QVIOTA.js → chunk-I2H5NGJQ.js} +4 -4
- package/dist/{chunk-K6QVIOTA.js.map → chunk-I2H5NGJQ.js.map} +1 -1
- package/dist/{chunk-I2Z72YTD.js → chunk-MGFRZO24.js} +3 -3
- package/dist/{chunk-I2Z72YTD.js.map → chunk-MGFRZO24.js.map} +1 -1
- package/dist/{chunk-Q3W6LCEN.cjs → chunk-SQ6FNXU2.cjs} +3 -3
- package/dist/{chunk-Q3W6LCEN.cjs.map → chunk-SQ6FNXU2.cjs.map} +1 -1
- package/dist/{chunk-2VY2G7OR.cjs → chunk-SXXTQETM.cjs} +245 -125
- package/dist/chunk-SXXTQETM.cjs.map +1 -0
- package/dist/{chunk-FXWF5D5V.cjs → chunk-T3Q5V33G.cjs} +9 -3
- package/dist/chunk-T3Q5V33G.cjs.map +1 -0
- package/dist/{chunk-KJSZMIBF.js → chunk-XXDFQERJ.js} +131 -12
- package/dist/chunk-XXDFQERJ.js.map +1 -0
- package/dist/index.cjs +211 -158
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +80 -27
- 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-Q7C6F2RM.cjs.map → migrations-IYNTWDC6.cjs.map} +1 -1
- package/dist/migrations-R337UD46.js +4 -0
- package/dist/{migrations-IFZLGVV3.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-2VY2G7OR.cjs.map +0 -1
- package/dist/chunk-FXWF5D5V.cjs.map +0 -1
- package/dist/chunk-KJSZMIBF.js.map +0 -1
- package/dist/chunk-NAYUXSNR.js.map +0 -1
- package/dist/migrations-IFZLGVV3.js +0 -4
- package/dist/migrations-Q7C6F2RM.cjs +0 -13
|
@@ -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("/", chunkP4RAIX7B_cjs.requireAuth(), chunkP4RAIX7B_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", chunkP4RAIX7B_cjs.requireAuth(), chunkP4RAIX7B_
|
|
|
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", chunkP4RAIX7B_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", chunkP4RAIX7B_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", chunkP4RAIX7B_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", chunkP4RAIX7B_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", chunkP4RAIX7B_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", chunkP4RAIX7B_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");
|
|
@@ -17733,6 +17734,13 @@ function renderOTPLoginSettingsContent(plugin, settings) {
|
|
|
17733
17734
|
const rateLimitPerHour = settings.rateLimitPerHour || 5;
|
|
17734
17735
|
const allowNewUserRegistration = settings.allowNewUserRegistration || false;
|
|
17735
17736
|
const logoUrl = settings.logoUrl || "";
|
|
17737
|
+
const logoWidth = Number(settings.logoWidth) || 150;
|
|
17738
|
+
const logoBorderWidth = Number(settings.logoBorderWidth) || 0;
|
|
17739
|
+
const logoBorderColor = settings.logoBorderColor || "#ffffff";
|
|
17740
|
+
const loginUrl = settings.loginUrl || "";
|
|
17741
|
+
const loginButtonText = settings.loginButtonText || "";
|
|
17742
|
+
const previewButtonText = loginButtonText.trim() || `Sign in to ${siteName}`;
|
|
17743
|
+
const previewLogoBorder = logoBorderWidth > 0 && logoBorderColor ? `border: ${logoBorderWidth}px solid ${escapeHtmlAttr(logoBorderColor)}; border-radius: 8px;` : "";
|
|
17736
17744
|
return `
|
|
17737
17745
|
<div class="space-y-6">
|
|
17738
17746
|
<!-- Test OTP Section -->
|
|
@@ -17823,6 +17831,109 @@ function renderOTPLoginSettingsContent(plugin, settings) {
|
|
|
17823
17831
|
<h3 class="text-lg font-semibold text-white mb-4">Code Settings</h3>
|
|
17824
17832
|
|
|
17825
17833
|
<form id="settings-form" class="space-y-4">
|
|
17834
|
+
<div>
|
|
17835
|
+
<label for="setting_logoUrl" class="block text-sm font-medium text-gray-300 mb-2">
|
|
17836
|
+
Logo URL
|
|
17837
|
+
</label>
|
|
17838
|
+
<input
|
|
17839
|
+
type="url"
|
|
17840
|
+
id="setting_logoUrl"
|
|
17841
|
+
name="setting_logoUrl"
|
|
17842
|
+
value="${escapeHtmlAttr(logoUrl)}"
|
|
17843
|
+
placeholder="https://yourdomain.com/logo.png"
|
|
17844
|
+
class="w-full px-3 py-2 rounded-lg bg-white/5 border border-white/10 focus:border-blue-500 focus:outline-none text-white"
|
|
17845
|
+
/>
|
|
17846
|
+
<p class="text-xs text-gray-500 mt-1">Optional. Displayed at the top of the OTP email.</p>
|
|
17847
|
+
</div>
|
|
17848
|
+
|
|
17849
|
+
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
|
17850
|
+
<div>
|
|
17851
|
+
<label for="setting_logoWidth" class="block text-sm font-medium text-gray-300 mb-2">
|
|
17852
|
+
Logo Width (px)
|
|
17853
|
+
</label>
|
|
17854
|
+
<input
|
|
17855
|
+
type="number"
|
|
17856
|
+
id="setting_logoWidth"
|
|
17857
|
+
name="setting_logoWidth"
|
|
17858
|
+
min="20"
|
|
17859
|
+
max="600"
|
|
17860
|
+
value="${logoWidth}"
|
|
17861
|
+
class="w-full px-3 py-2 rounded-lg bg-white/5 border border-white/10 focus:border-blue-500 focus:outline-none text-white"
|
|
17862
|
+
/>
|
|
17863
|
+
<p class="text-xs text-gray-500 mt-1">Max width of the logo (20-600).</p>
|
|
17864
|
+
</div>
|
|
17865
|
+
|
|
17866
|
+
<div>
|
|
17867
|
+
<label for="setting_logoBorderWidth" class="block text-sm font-medium text-gray-300 mb-2">
|
|
17868
|
+
Border Thickness (px)
|
|
17869
|
+
</label>
|
|
17870
|
+
<input
|
|
17871
|
+
type="number"
|
|
17872
|
+
id="setting_logoBorderWidth"
|
|
17873
|
+
name="setting_logoBorderWidth"
|
|
17874
|
+
min="0"
|
|
17875
|
+
max="20"
|
|
17876
|
+
value="${logoBorderWidth}"
|
|
17877
|
+
class="w-full px-3 py-2 rounded-lg bg-white/5 border border-white/10 focus:border-blue-500 focus:outline-none text-white"
|
|
17878
|
+
/>
|
|
17879
|
+
<p class="text-xs text-gray-500 mt-1">0 disables the border.</p>
|
|
17880
|
+
</div>
|
|
17881
|
+
|
|
17882
|
+
<div>
|
|
17883
|
+
<label for="setting_logoBorderColor" class="block text-sm font-medium text-gray-300 mb-2">
|
|
17884
|
+
Border Color
|
|
17885
|
+
</label>
|
|
17886
|
+
<div class="flex gap-2">
|
|
17887
|
+
<input
|
|
17888
|
+
type="color"
|
|
17889
|
+
id="setting_logoBorderColor_picker"
|
|
17890
|
+
value="${escapeHtmlAttr(/^#[0-9a-fA-F]{6}$/.test(logoBorderColor) ? logoBorderColor : "#ffffff")}"
|
|
17891
|
+
oninput="document.getElementById('setting_logoBorderColor').value = this.value"
|
|
17892
|
+
class="w-12 h-10 rounded-lg bg-white/5 border border-white/10 cursor-pointer"
|
|
17893
|
+
/>
|
|
17894
|
+
<input
|
|
17895
|
+
type="text"
|
|
17896
|
+
id="setting_logoBorderColor"
|
|
17897
|
+
name="setting_logoBorderColor"
|
|
17898
|
+
value="${escapeHtmlAttr(logoBorderColor)}"
|
|
17899
|
+
placeholder="#ffffff"
|
|
17900
|
+
class="flex-1 px-3 py-2 rounded-lg bg-white/5 border border-white/10 focus:border-blue-500 focus:outline-none text-white"
|
|
17901
|
+
/>
|
|
17902
|
+
</div>
|
|
17903
|
+
<p class="text-xs text-gray-500 mt-1">Hex, rgb(), or named color.</p>
|
|
17904
|
+
</div>
|
|
17905
|
+
</div>
|
|
17906
|
+
|
|
17907
|
+
<div>
|
|
17908
|
+
<label for="setting_loginUrl" class="block text-sm font-medium text-gray-300 mb-2">
|
|
17909
|
+
Login URL
|
|
17910
|
+
</label>
|
|
17911
|
+
<input
|
|
17912
|
+
type="url"
|
|
17913
|
+
id="setting_loginUrl"
|
|
17914
|
+
name="setting_loginUrl"
|
|
17915
|
+
value="${escapeHtmlAttr(loginUrl)}"
|
|
17916
|
+
placeholder="https://yourdomain.com/login"
|
|
17917
|
+
class="w-full px-3 py-2 rounded-lg bg-white/5 border border-white/10 focus:border-blue-500 focus:outline-none text-white"
|
|
17918
|
+
/>
|
|
17919
|
+
<p class="text-xs text-gray-500 mt-1">Optional. If set, a "Sign in" button is added to the email.</p>
|
|
17920
|
+
</div>
|
|
17921
|
+
|
|
17922
|
+
<div>
|
|
17923
|
+
<label for="setting_loginButtonText" class="block text-sm font-medium text-gray-300 mb-2">
|
|
17924
|
+
Login Button Text
|
|
17925
|
+
</label>
|
|
17926
|
+
<input
|
|
17927
|
+
type="text"
|
|
17928
|
+
id="setting_loginButtonText"
|
|
17929
|
+
name="setting_loginButtonText"
|
|
17930
|
+
value="${escapeHtmlAttr(loginButtonText)}"
|
|
17931
|
+
placeholder="Sign in to ${escapeHtmlAttr(siteName)}"
|
|
17932
|
+
class="w-full px-3 py-2 rounded-lg bg-white/5 border border-white/10 focus:border-blue-500 focus:outline-none text-white"
|
|
17933
|
+
/>
|
|
17934
|
+
<p class="text-xs text-gray-500 mt-1">Optional. Defaults to "Sign in to ${siteName}".</p>
|
|
17935
|
+
</div>
|
|
17936
|
+
|
|
17826
17937
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
|
17827
17938
|
<div>
|
|
17828
17939
|
<label for="setting_codeLength" class="block text-sm font-medium text-gray-300 mb-2">
|
|
@@ -17916,7 +18027,7 @@ function renderOTPLoginSettingsContent(plugin, settings) {
|
|
|
17916
18027
|
|
|
17917
18028
|
<div class="bg-white rounded-lg overflow-hidden shadow-lg">
|
|
17918
18029
|
<div style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 30px 20px; text-align: center;">
|
|
17919
|
-
${logoUrl ? `<img src="${logoUrl}" alt="Logo" style="max-width:
|
|
18030
|
+
${logoUrl ? `<img src="${escapeHtmlAttr(logoUrl)}" alt="Logo" style="max-width: ${logoWidth}px; width: 100%; height: auto; margin: 0 auto 16px; ${previewLogoBorder}">` : ""}
|
|
17920
18031
|
<h3 style="margin: 0 0 8px 0; font-size: 24px; font-weight: 600;">Your Login Code</h3>
|
|
17921
18032
|
<p style="margin: 0; opacity: 0.95; font-size: 14px;">Enter this code to sign in to ${siteName}</p>
|
|
17922
18033
|
</div>
|
|
@@ -17928,6 +18039,14 @@ function renderOTPLoginSettingsContent(plugin, settings) {
|
|
|
17928
18039
|
</div>
|
|
17929
18040
|
</div>
|
|
17930
18041
|
|
|
18042
|
+
${loginUrl ? `
|
|
18043
|
+
<div style="text-align: center; margin: 0 0 20px 0;">
|
|
18044
|
+
<a href="${escapeHtmlAttr(loginUrl)}" style="display: inline-block; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; text-decoration: none; padding: 12px 28px; border-radius: 6px; font-weight: 600; font-size: 14px;">
|
|
18045
|
+
${escapeHtmlAttr(previewButtonText)}
|
|
18046
|
+
</a>
|
|
18047
|
+
</div>
|
|
18048
|
+
` : ""}
|
|
18049
|
+
|
|
17931
18050
|
<div style="background: #fff3cd; border-left: 4px solid #ffc107; padding: 12px 16px; margin: 0 0 20px 0; border-radius: 4px;">
|
|
17932
18051
|
<p style="margin: 0; font-size: 13px; color: #856404;">
|
|
17933
18052
|
<strong>\u26A0\uFE0F This code expires in ${codeExpiryMinutes} minutes</strong>
|
|
@@ -18230,8 +18349,8 @@ function renderEmailSettingsContent(plugin, settings) {
|
|
|
18230
18349
|
|
|
18231
18350
|
// src/routes/admin-plugins.ts
|
|
18232
18351
|
var adminPluginRoutes = new hono.Hono();
|
|
18233
|
-
adminPluginRoutes.use("*",
|
|
18234
|
-
var AVAILABLE_PLUGINS = Object.values(
|
|
18352
|
+
adminPluginRoutes.use("*", chunkDSUJ5YQH_cjs.requireAuth());
|
|
18353
|
+
var AVAILABLE_PLUGINS = Object.values(chunkT3Q5V33G_cjs.PLUGIN_REGISTRY).map((p) => ({
|
|
18235
18354
|
id: p.id,
|
|
18236
18355
|
name: p.codeName,
|
|
18237
18356
|
display_name: p.displayName,
|
|
@@ -18251,7 +18370,7 @@ adminPluginRoutes.get("/", async (c) => {
|
|
|
18251
18370
|
if (user?.role !== "admin") {
|
|
18252
18371
|
return c.text("Access denied", 403);
|
|
18253
18372
|
}
|
|
18254
|
-
const pluginService = new
|
|
18373
|
+
const pluginService = new chunkT3Q5V33G_cjs.PluginService(db);
|
|
18255
18374
|
let installedPlugins = [];
|
|
18256
18375
|
let stats = { total: 0, active: 0, inactive: 0, errors: 0, uninstalled: 0 };
|
|
18257
18376
|
try {
|
|
@@ -18323,7 +18442,7 @@ adminPluginRoutes.get("/:id", async (c) => {
|
|
|
18323
18442
|
if (user?.role !== "admin") {
|
|
18324
18443
|
return c.redirect("/admin/plugins");
|
|
18325
18444
|
}
|
|
18326
|
-
const pluginService = new
|
|
18445
|
+
const pluginService = new chunkT3Q5V33G_cjs.PluginService(db);
|
|
18327
18446
|
const plugin = await pluginService.getPlugin(pluginId);
|
|
18328
18447
|
if (!plugin) {
|
|
18329
18448
|
return c.text("Plugin not found", 404);
|
|
@@ -18399,7 +18518,7 @@ adminPluginRoutes.post("/:id/activate", async (c) => {
|
|
|
18399
18518
|
if (user?.role !== "admin") {
|
|
18400
18519
|
return c.json({ error: "Access denied" }, 403);
|
|
18401
18520
|
}
|
|
18402
|
-
const pluginService = new
|
|
18521
|
+
const pluginService = new chunkT3Q5V33G_cjs.PluginService(db);
|
|
18403
18522
|
await pluginService.activatePlugin(pluginId);
|
|
18404
18523
|
return c.json({ success: true });
|
|
18405
18524
|
} catch (error) {
|
|
@@ -18416,7 +18535,7 @@ adminPluginRoutes.post("/:id/deactivate", async (c) => {
|
|
|
18416
18535
|
if (user?.role !== "admin") {
|
|
18417
18536
|
return c.json({ error: "Access denied" }, 403);
|
|
18418
18537
|
}
|
|
18419
|
-
const pluginService = new
|
|
18538
|
+
const pluginService = new chunkT3Q5V33G_cjs.PluginService(db);
|
|
18420
18539
|
await pluginService.deactivatePlugin(pluginId);
|
|
18421
18540
|
return c.json({ success: true });
|
|
18422
18541
|
} catch (error) {
|
|
@@ -18433,8 +18552,8 @@ adminPluginRoutes.post("/install", async (c) => {
|
|
|
18433
18552
|
return c.json({ error: "Access denied" }, 403);
|
|
18434
18553
|
}
|
|
18435
18554
|
const body = await c.req.json();
|
|
18436
|
-
const pluginService = new
|
|
18437
|
-
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];
|
|
18438
18557
|
if (!registryEntry) {
|
|
18439
18558
|
return c.json({ error: "Plugin not found in registry" }, 404);
|
|
18440
18559
|
}
|
|
@@ -18467,7 +18586,7 @@ adminPluginRoutes.post("/:id/uninstall", async (c) => {
|
|
|
18467
18586
|
if (user?.role !== "admin") {
|
|
18468
18587
|
return c.json({ error: "Access denied" }, 403);
|
|
18469
18588
|
}
|
|
18470
|
-
const pluginService = new
|
|
18589
|
+
const pluginService = new chunkT3Q5V33G_cjs.PluginService(db);
|
|
18471
18590
|
await pluginService.uninstallPlugin(pluginId);
|
|
18472
18591
|
return c.json({ success: true });
|
|
18473
18592
|
} catch (error) {
|
|
@@ -18485,7 +18604,7 @@ adminPluginRoutes.post("/:id/settings", async (c) => {
|
|
|
18485
18604
|
return c.json({ error: "Access denied" }, 403);
|
|
18486
18605
|
}
|
|
18487
18606
|
const settings = await c.req.json();
|
|
18488
|
-
const pluginService = new
|
|
18607
|
+
const pluginService = new chunkT3Q5V33G_cjs.PluginService(db);
|
|
18489
18608
|
await pluginService.updatePluginSettings(pluginId, settings);
|
|
18490
18609
|
if (pluginId === "core-auth") {
|
|
18491
18610
|
try {
|
|
@@ -19293,7 +19412,7 @@ function renderLogConfigPage(data) {
|
|
|
19293
19412
|
|
|
19294
19413
|
// src/routes/admin-logs.ts
|
|
19295
19414
|
var adminLogsRoutes = new hono.Hono();
|
|
19296
|
-
adminLogsRoutes.use("*",
|
|
19415
|
+
adminLogsRoutes.use("*", chunkDSUJ5YQH_cjs.requireAuth());
|
|
19297
19416
|
adminLogsRoutes.get("/", async (c) => {
|
|
19298
19417
|
try {
|
|
19299
19418
|
const user = c.get("user");
|
|
@@ -21621,9 +21740,9 @@ function renderStorageUsage(databaseSizeBytes, mediaSizeBytes) {
|
|
|
21621
21740
|
}
|
|
21622
21741
|
|
|
21623
21742
|
// src/routes/admin-dashboard.ts
|
|
21624
|
-
var VERSION =
|
|
21743
|
+
var VERSION = chunkSQ6FNXU2_cjs.getCoreVersion();
|
|
21625
21744
|
var router = new hono.Hono();
|
|
21626
|
-
router.use("*",
|
|
21745
|
+
router.use("*", chunkDSUJ5YQH_cjs.requireAuth());
|
|
21627
21746
|
router.get("/", async (c) => {
|
|
21628
21747
|
const user = c.get("user");
|
|
21629
21748
|
try {
|
|
@@ -23442,10 +23561,10 @@ function renderCollectionFormPage(data) {
|
|
|
23442
23561
|
|
|
23443
23562
|
// src/routes/admin-collections.ts
|
|
23444
23563
|
var adminCollectionsRoutes = new hono.Hono();
|
|
23445
|
-
adminCollectionsRoutes.use("*",
|
|
23446
|
-
adminCollectionsRoutes.post("*",
|
|
23447
|
-
adminCollectionsRoutes.put("*",
|
|
23448
|
-
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"]));
|
|
23449
23568
|
adminCollectionsRoutes.get("/", async (c) => {
|
|
23450
23569
|
try {
|
|
23451
23570
|
const user = c.get("user");
|
|
@@ -25740,7 +25859,7 @@ function renderDatabaseToolsSettings(settings) {
|
|
|
25740
25859
|
|
|
25741
25860
|
// src/routes/admin-settings.ts
|
|
25742
25861
|
var adminSettingsRoutes = new hono.Hono();
|
|
25743
|
-
adminSettingsRoutes.use("*",
|
|
25862
|
+
adminSettingsRoutes.use("*", chunkDSUJ5YQH_cjs.requireAuth());
|
|
25744
25863
|
function getMockSettings(user) {
|
|
25745
25864
|
return {
|
|
25746
25865
|
general: {
|
|
@@ -25917,7 +26036,7 @@ adminSettingsRoutes.get("/database-tools", (c) => {
|
|
|
25917
26036
|
adminSettingsRoutes.get("/api/migrations/status", async (c) => {
|
|
25918
26037
|
try {
|
|
25919
26038
|
const db = c.env.DB;
|
|
25920
|
-
const migrationService = new
|
|
26039
|
+
const migrationService = new chunkC54YUA23_cjs.MigrationService(db);
|
|
25921
26040
|
const status = await migrationService.getMigrationStatus();
|
|
25922
26041
|
return c.json({
|
|
25923
26042
|
success: true,
|
|
@@ -25941,7 +26060,7 @@ adminSettingsRoutes.post("/api/migrations/run", async (c) => {
|
|
|
25941
26060
|
}, 403);
|
|
25942
26061
|
}
|
|
25943
26062
|
const db = c.env.DB;
|
|
25944
|
-
const migrationService = new
|
|
26063
|
+
const migrationService = new chunkC54YUA23_cjs.MigrationService(db);
|
|
25945
26064
|
const result = await migrationService.runPendingMigrations();
|
|
25946
26065
|
return c.json({
|
|
25947
26066
|
success: result.success,
|
|
@@ -25959,7 +26078,7 @@ adminSettingsRoutes.post("/api/migrations/run", async (c) => {
|
|
|
25959
26078
|
adminSettingsRoutes.get("/api/migrations/validate", async (c) => {
|
|
25960
26079
|
try {
|
|
25961
26080
|
const db = c.env.DB;
|
|
25962
|
-
const migrationService = new
|
|
26081
|
+
const migrationService = new chunkC54YUA23_cjs.MigrationService(db);
|
|
25963
26082
|
const validation = await migrationService.validateSchema();
|
|
25964
26083
|
return c.json({
|
|
25965
26084
|
success: true,
|
|
@@ -27898,7 +28017,7 @@ function renderFormCreatePage(data) {
|
|
|
27898
28017
|
|
|
27899
28018
|
// src/routes/admin-forms.ts
|
|
27900
28019
|
var adminFormsRoutes = new hono.Hono();
|
|
27901
|
-
adminFormsRoutes.use("*",
|
|
28020
|
+
adminFormsRoutes.use("*", chunkDSUJ5YQH_cjs.requireAuth());
|
|
27902
28021
|
adminFormsRoutes.get("/", async (c) => {
|
|
27903
28022
|
try {
|
|
27904
28023
|
const user = c.get("user");
|
|
@@ -28703,7 +28822,7 @@ publicFormsRoutes.post("/:identifier/submit", async (c) => {
|
|
|
28703
28822
|
`).bind(now, form.id).run();
|
|
28704
28823
|
let contentId = null;
|
|
28705
28824
|
try {
|
|
28706
|
-
contentId = await
|
|
28825
|
+
contentId = await chunkT3Q5V33G_cjs.createContentFromSubmission(
|
|
28707
28826
|
db,
|
|
28708
28827
|
sanitizedData,
|
|
28709
28828
|
{ id: form.id, name: form.name, display_name: form.display_name },
|
|
@@ -29071,9 +29190,9 @@ function renderAPIReferencePage(data) {
|
|
|
29071
29190
|
}
|
|
29072
29191
|
|
|
29073
29192
|
// src/routes/admin-api-reference.ts
|
|
29074
|
-
var VERSION2 =
|
|
29193
|
+
var VERSION2 = chunkSQ6FNXU2_cjs.getCoreVersion();
|
|
29075
29194
|
var router2 = new hono.Hono();
|
|
29076
|
-
router2.use("*",
|
|
29195
|
+
router2.use("*", chunkDSUJ5YQH_cjs.requireAuth());
|
|
29077
29196
|
router2.get("/", async (c) => {
|
|
29078
29197
|
const user = c.get("user");
|
|
29079
29198
|
try {
|
|
@@ -29156,6 +29275,7 @@ exports.auth_default = auth_default;
|
|
|
29156
29275
|
exports.createUserProfilesPlugin = createUserProfilesPlugin;
|
|
29157
29276
|
exports.defineUserProfile = defineUserProfile;
|
|
29158
29277
|
exports.getConfirmationDialogScript = getConfirmationDialogScript2;
|
|
29278
|
+
exports.getCustomData = getCustomData;
|
|
29159
29279
|
exports.getUserProfileConfig = getUserProfileConfig;
|
|
29160
29280
|
exports.public_forms_default = public_forms_default;
|
|
29161
29281
|
exports.renderConfirmationDialog = renderConfirmationDialog2;
|
|
@@ -29164,5 +29284,5 @@ exports.router2 = router2;
|
|
|
29164
29284
|
exports.test_cleanup_default = test_cleanup_default;
|
|
29165
29285
|
exports.userProfilesPlugin = userProfilesPlugin;
|
|
29166
29286
|
exports.userRoutes = userRoutes;
|
|
29167
|
-
//# sourceMappingURL=chunk-
|
|
29168
|
-
//# sourceMappingURL=chunk-
|
|
29287
|
+
//# sourceMappingURL=chunk-SXXTQETM.cjs.map
|
|
29288
|
+
//# sourceMappingURL=chunk-SXXTQETM.cjs.map
|