@sonicjs-cms/core 2.8.1 → 2.8.3

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.
Files changed (86) hide show
  1. package/dist/{app-CYEm1ytG.d.cts → app-DnQ26Lho.d.cts} +3 -0
  2. package/dist/{app-CYEm1ytG.d.ts → app-DnQ26Lho.d.ts} +3 -0
  3. package/dist/{chunk-S6K2H2TS.cjs → chunk-3G7XX4UI.cjs} +9 -9
  4. package/dist/{chunk-S6K2H2TS.cjs.map → chunk-3G7XX4UI.cjs.map} +1 -1
  5. package/dist/{chunk-KAT3OKHE.js → chunk-5XAI2XUF.js} +33 -37
  6. package/dist/chunk-5XAI2XUF.js.map +1 -0
  7. package/dist/{chunk-H7AMQWVI.js → chunk-74XCYEI7.js} +3 -3
  8. package/dist/{chunk-H7AMQWVI.js.map → chunk-74XCYEI7.js.map} +1 -1
  9. package/dist/{chunk-FZRZYQYU.js → chunk-CH5UHZVM.js} +2604 -2364
  10. package/dist/chunk-CH5UHZVM.js.map +1 -0
  11. package/dist/{chunk-7Q2XPM2U.js → chunk-GTFMI24U.js} +21 -2
  12. package/dist/chunk-GTFMI24U.js.map +1 -0
  13. package/dist/{chunk-SKLRRFJJ.cjs → chunk-HXHVU5GM.cjs} +21 -2
  14. package/dist/chunk-HXHVU5GM.cjs.map +1 -0
  15. package/dist/{chunk-WDQZYCQO.cjs → chunk-JDIM5AG7.cjs} +32 -39
  16. package/dist/chunk-JDIM5AG7.cjs.map +1 -0
  17. package/dist/{chunk-VCH6HXVP.js → chunk-JJS7JZCH.js} +58 -4
  18. package/dist/chunk-JJS7JZCH.js.map +1 -0
  19. package/dist/chunk-K4Q4SFJJ.cjs +568 -0
  20. package/dist/chunk-K4Q4SFJJ.cjs.map +1 -0
  21. package/dist/{chunk-SHCYIZAN.cjs → chunk-LTKV7AE5.cjs} +58 -4
  22. package/dist/chunk-LTKV7AE5.cjs.map +1 -0
  23. package/dist/chunk-MNWKYY5E.cjs +44 -0
  24. package/dist/chunk-MNWKYY5E.cjs.map +1 -0
  25. package/dist/{chunk-JVRRG36J.cjs → chunk-R4WR3VTN.cjs} +2393 -2153
  26. package/dist/chunk-R4WR3VTN.cjs.map +1 -0
  27. package/dist/chunk-TQABQWOP.js +39 -0
  28. package/dist/chunk-TQABQWOP.js.map +1 -0
  29. package/dist/chunk-Y3VMEGY2.js +541 -0
  30. package/dist/chunk-Y3VMEGY2.js.map +1 -0
  31. package/dist/{collection-config-BF95LgQb.d.cts → collection-config-i8EaAF7z.d.cts} +2 -1
  32. package/dist/{collection-config-BF95LgQb.d.ts → collection-config-i8EaAF7z.d.ts} +2 -1
  33. package/dist/{filter-bar.template-By4jeiw_.d.cts → filter-bar.template-Daw8ZDoq.d.cts} +1 -0
  34. package/dist/{filter-bar.template-By4jeiw_.d.ts → filter-bar.template-Daw8ZDoq.d.ts} +1 -0
  35. package/dist/index.cjs +112 -111
  36. package/dist/index.cjs.map +1 -1
  37. package/dist/index.d.cts +6 -6
  38. package/dist/index.d.ts +6 -6
  39. package/dist/index.js +16 -15
  40. package/dist/index.js.map +1 -1
  41. package/dist/middleware.cjs +43 -23
  42. package/dist/middleware.d.cts +86 -6
  43. package/dist/middleware.d.ts +86 -6
  44. package/dist/middleware.js +2 -2
  45. package/dist/migrations-7X4RPH7O.cjs +13 -0
  46. package/dist/{migrations-76NR5BVF.cjs.map → migrations-7X4RPH7O.cjs.map} +1 -1
  47. package/dist/migrations-KHWFJ2HN.js +4 -0
  48. package/dist/{migrations-2NTJ44OR.js.map → migrations-KHWFJ2HN.js.map} +1 -1
  49. package/dist/{plugin-bootstrap-C7Mj00Ud.d.ts → plugin-bootstrap-CJozpgmI.d.cts} +1 -1
  50. package/dist/{plugin-bootstrap-DKB5f8-E.d.cts → plugin-bootstrap-DU5VmuHZ.d.ts} +1 -1
  51. package/dist/routes.cjs +29 -28
  52. package/dist/routes.d.cts +1 -1
  53. package/dist/routes.d.ts +1 -1
  54. package/dist/routes.js +6 -5
  55. package/dist/services.cjs +2 -2
  56. package/dist/services.d.cts +2 -2
  57. package/dist/services.d.ts +2 -2
  58. package/dist/services.js +1 -1
  59. package/dist/templates.cjs +20 -19
  60. package/dist/templates.d.cts +1 -1
  61. package/dist/templates.d.ts +1 -1
  62. package/dist/templates.js +3 -2
  63. package/dist/types.d.cts +1 -1
  64. package/dist/types.d.ts +1 -1
  65. package/dist/utils.cjs +24 -23
  66. package/dist/utils.d.cts +2 -2
  67. package/dist/utils.d.ts +2 -2
  68. package/dist/utils.js +2 -1
  69. package/dist/{version-vktVAxhe.d.cts → version-C_CXrN_T.d.cts} +5 -0
  70. package/dist/{version-vktVAxhe.d.ts → version-C_CXrN_T.d.ts} +5 -0
  71. package/migrations/032_user_profiles.sql +36 -0
  72. package/package.json +2 -2
  73. package/dist/chunk-7Q2XPM2U.js.map +0 -1
  74. package/dist/chunk-FZRZYQYU.js.map +0 -1
  75. package/dist/chunk-GIWIJNBH.cjs +0 -243
  76. package/dist/chunk-GIWIJNBH.cjs.map +0 -1
  77. package/dist/chunk-JVRRG36J.cjs.map +0 -1
  78. package/dist/chunk-KAT3OKHE.js.map +0 -1
  79. package/dist/chunk-QWTS6NSP.js +0 -221
  80. package/dist/chunk-QWTS6NSP.js.map +0 -1
  81. package/dist/chunk-SHCYIZAN.cjs.map +0 -1
  82. package/dist/chunk-SKLRRFJJ.cjs.map +0 -1
  83. package/dist/chunk-VCH6HXVP.js.map +0 -1
  84. package/dist/chunk-WDQZYCQO.cjs.map +0 -1
  85. package/dist/migrations-2NTJ44OR.js +0 -4
  86. package/dist/migrations-76NR5BVF.cjs +0 -13
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunkGIWIJNBH_cjs = require('./chunk-GIWIJNBH.cjs');
3
+ var chunkK4Q4SFJJ_cjs = require('./chunk-K4Q4SFJJ.cjs');
4
4
  require('./chunk-MPT5PA6U.cjs');
5
- require('./chunk-SKLRRFJJ.cjs');
5
+ require('./chunk-HXHVU5GM.cjs');
6
6
  require('./chunk-RCQ2HIQD.cjs');
7
7
  require('./chunk-IGJUBJBW.cjs');
8
8
 
@@ -10,87 +10,107 @@ require('./chunk-IGJUBJBW.cjs');
10
10
 
11
11
  Object.defineProperty(exports, "AuthManager", {
12
12
  enumerable: true,
13
- get: function () { return chunkGIWIJNBH_cjs.AuthManager; }
13
+ get: function () { return chunkK4Q4SFJJ_cjs.AuthManager; }
14
14
  });
15
15
  Object.defineProperty(exports, "PermissionManager", {
16
16
  enumerable: true,
17
- get: function () { return chunkGIWIJNBH_cjs.PermissionManager; }
17
+ get: function () { return chunkK4Q4SFJJ_cjs.PermissionManager; }
18
18
  });
19
19
  Object.defineProperty(exports, "bootstrapMiddleware", {
20
20
  enumerable: true,
21
- get: function () { return chunkGIWIJNBH_cjs.bootstrapMiddleware; }
21
+ get: function () { return chunkK4Q4SFJJ_cjs.bootstrapMiddleware; }
22
22
  });
23
23
  Object.defineProperty(exports, "cacheHeaders", {
24
24
  enumerable: true,
25
- get: function () { return chunkGIWIJNBH_cjs.cacheHeaders; }
25
+ get: function () { return chunkK4Q4SFJJ_cjs.cacheHeaders; }
26
26
  });
27
27
  Object.defineProperty(exports, "compressionMiddleware", {
28
28
  enumerable: true,
29
- get: function () { return chunkGIWIJNBH_cjs.compressionMiddleware; }
29
+ get: function () { return chunkK4Q4SFJJ_cjs.compressionMiddleware; }
30
+ });
31
+ Object.defineProperty(exports, "csrfProtection", {
32
+ enumerable: true,
33
+ get: function () { return chunkK4Q4SFJJ_cjs.csrfProtection; }
30
34
  });
31
35
  Object.defineProperty(exports, "detailedLoggingMiddleware", {
32
36
  enumerable: true,
33
- get: function () { return chunkGIWIJNBH_cjs.detailedLoggingMiddleware; }
37
+ get: function () { return chunkK4Q4SFJJ_cjs.detailedLoggingMiddleware; }
38
+ });
39
+ Object.defineProperty(exports, "generateCsrfToken", {
40
+ enumerable: true,
41
+ get: function () { return chunkK4Q4SFJJ_cjs.generateCsrfToken; }
34
42
  });
35
43
  Object.defineProperty(exports, "getActivePlugins", {
36
44
  enumerable: true,
37
- get: function () { return chunkGIWIJNBH_cjs.getActivePlugins; }
45
+ get: function () { return chunkK4Q4SFJJ_cjs.getActivePlugins; }
38
46
  });
39
47
  Object.defineProperty(exports, "isPluginActive", {
40
48
  enumerable: true,
41
- get: function () { return chunkGIWIJNBH_cjs.isPluginActive; }
49
+ get: function () { return chunkK4Q4SFJJ_cjs.isPluginActive; }
42
50
  });
43
51
  Object.defineProperty(exports, "logActivity", {
44
52
  enumerable: true,
45
- get: function () { return chunkGIWIJNBH_cjs.logActivity; }
53
+ get: function () { return chunkK4Q4SFJJ_cjs.logActivity; }
46
54
  });
47
55
  Object.defineProperty(exports, "loggingMiddleware", {
48
56
  enumerable: true,
49
- get: function () { return chunkGIWIJNBH_cjs.loggingMiddleware; }
57
+ get: function () { return chunkK4Q4SFJJ_cjs.loggingMiddleware; }
50
58
  });
51
59
  Object.defineProperty(exports, "metricsMiddleware", {
52
60
  enumerable: true,
53
- get: function () { return chunkGIWIJNBH_cjs.metricsMiddleware; }
61
+ get: function () { return chunkK4Q4SFJJ_cjs.metricsMiddleware; }
54
62
  });
55
63
  Object.defineProperty(exports, "optionalAuth", {
56
64
  enumerable: true,
57
- get: function () { return chunkGIWIJNBH_cjs.optionalAuth; }
65
+ get: function () { return chunkK4Q4SFJJ_cjs.optionalAuth; }
58
66
  });
59
67
  Object.defineProperty(exports, "performanceLoggingMiddleware", {
60
68
  enumerable: true,
61
- get: function () { return chunkGIWIJNBH_cjs.performanceLoggingMiddleware; }
69
+ get: function () { return chunkK4Q4SFJJ_cjs.performanceLoggingMiddleware; }
70
+ });
71
+ Object.defineProperty(exports, "rateLimit", {
72
+ enumerable: true,
73
+ get: function () { return chunkK4Q4SFJJ_cjs.rateLimit; }
62
74
  });
63
75
  Object.defineProperty(exports, "requireActivePlugin", {
64
76
  enumerable: true,
65
- get: function () { return chunkGIWIJNBH_cjs.requireActivePlugin; }
77
+ get: function () { return chunkK4Q4SFJJ_cjs.requireActivePlugin; }
66
78
  });
67
79
  Object.defineProperty(exports, "requireActivePlugins", {
68
80
  enumerable: true,
69
- get: function () { return chunkGIWIJNBH_cjs.requireActivePlugins; }
81
+ get: function () { return chunkK4Q4SFJJ_cjs.requireActivePlugins; }
70
82
  });
71
83
  Object.defineProperty(exports, "requireAnyPermission", {
72
84
  enumerable: true,
73
- get: function () { return chunkGIWIJNBH_cjs.requireAnyPermission; }
85
+ get: function () { return chunkK4Q4SFJJ_cjs.requireAnyPermission; }
74
86
  });
75
87
  Object.defineProperty(exports, "requireAuth", {
76
88
  enumerable: true,
77
- get: function () { return chunkGIWIJNBH_cjs.requireAuth; }
89
+ get: function () { return chunkK4Q4SFJJ_cjs.requireAuth; }
78
90
  });
79
91
  Object.defineProperty(exports, "requirePermission", {
80
92
  enumerable: true,
81
- get: function () { return chunkGIWIJNBH_cjs.requirePermission; }
93
+ get: function () { return chunkK4Q4SFJJ_cjs.requirePermission; }
82
94
  });
83
95
  Object.defineProperty(exports, "requireRole", {
84
96
  enumerable: true,
85
- get: function () { return chunkGIWIJNBH_cjs.requireRole; }
97
+ get: function () { return chunkK4Q4SFJJ_cjs.requireRole; }
86
98
  });
87
99
  Object.defineProperty(exports, "securityHeaders", {
88
100
  enumerable: true,
89
- get: function () { return chunkGIWIJNBH_cjs.securityHeaders; }
101
+ get: function () { return chunkK4Q4SFJJ_cjs.securityHeadersMiddleware; }
90
102
  });
91
103
  Object.defineProperty(exports, "securityLoggingMiddleware", {
92
104
  enumerable: true,
93
- get: function () { return chunkGIWIJNBH_cjs.securityLoggingMiddleware; }
105
+ get: function () { return chunkK4Q4SFJJ_cjs.securityLoggingMiddleware; }
106
+ });
107
+ Object.defineProperty(exports, "validateCsrfToken", {
108
+ enumerable: true,
109
+ get: function () { return chunkK4Q4SFJJ_cjs.validateCsrfToken; }
110
+ });
111
+ Object.defineProperty(exports, "verifySecurityConfig", {
112
+ enumerable: true,
113
+ get: function () { return chunkK4Q4SFJJ_cjs.verifySecurityConfig; }
94
114
  });
95
115
  //# sourceMappingURL=middleware.cjs.map
96
116
  //# sourceMappingURL=middleware.cjs.map
@@ -1,12 +1,21 @@
1
1
  import * as hono from 'hono';
2
2
  import { Context, Next, MiddlewareHandler } from 'hono';
3
- import { S as SonicJSConfig } from './app-CYEm1ytG.cjs';
3
+ import { S as SonicJSConfig } from './app-DnQ26Lho.cjs';
4
4
  import '@cloudflare/workers-types';
5
5
 
6
6
  type Bindings = {
7
7
  DB: D1Database;
8
8
  KV: KVNamespace;
9
+ JWT_SECRET?: string;
10
+ CORS_ORIGINS?: string;
11
+ ENVIRONMENT?: string;
9
12
  };
13
+ /**
14
+ * Verify security-critical environment configuration at startup.
15
+ * Logs warnings in development, throws in production to prevent
16
+ * insecure deployments from silently running.
17
+ */
18
+ declare function verifySecurityConfig(env: Bindings): void;
10
19
  /**
11
20
  * Bootstrap middleware that ensures system initialization
12
21
  * Runs once per worker instance
@@ -23,10 +32,12 @@ type JWTPayload = {
23
32
  iat: number;
24
33
  };
25
34
  declare class AuthManager {
26
- static generateToken(userId: string, email: string, role: string): Promise<string>;
27
- static verifyToken(token: string): Promise<JWTPayload | null>;
35
+ static generateToken(userId: string, email: string, role: string, secret?: string): Promise<string>;
36
+ static verifyToken(token: string, secret?: string): Promise<JWTPayload | null>;
28
37
  static hashPassword(password: string): Promise<string>;
29
- static verifyPassword(password: string, hash: string): Promise<boolean>;
38
+ static hashPasswordLegacy(password: string): Promise<string>;
39
+ static verifyPassword(password: string, storedHash: string): Promise<boolean>;
40
+ static isLegacyHash(storedHash: string): boolean;
30
41
  /**
31
42
  * Set authentication cookie - useful for plugins implementing alternative auth methods
32
43
  * @param c - Hono context
@@ -56,6 +67,75 @@ declare const optionalAuth: () => (c: Context, next: Next) => Promise<void>;
56
67
  */
57
68
  declare const metricsMiddleware: () => MiddlewareHandler;
58
69
 
70
+ /**
71
+ * CSRF Protection Middleware — Signed Double-Submit Cookie
72
+ *
73
+ * Stateless CSRF protection for Cloudflare Workers (no session store needed).
74
+ * Token format: `<nonce>.<hmac>` where HMAC-SHA256 is keyed with JWT_SECRET.
75
+ *
76
+ * Flow:
77
+ * GET — ensureCsrfCookie(): reuse existing valid cookie or set a new one
78
+ * POST/PUT/DELETE/PATCH — validate X-CSRF-Token header === csrf_token cookie, HMAC valid
79
+ *
80
+ * Exempt:
81
+ * - Safe methods (GET, HEAD, OPTIONS)
82
+ * - Auth routes that create sessions (/auth/login*, /auth/register*, etc.)
83
+ * - Public form submissions (/forms/*, /api/forms/*) — NOT /admin/forms/*
84
+ * - Requests with no auth_token cookie (Bearer-only or API-key-only)
85
+ */
86
+
87
+ /**
88
+ * Generate a signed CSRF token: `<nonce>.<hmac_signature>`
89
+ * - nonce = 32 random bytes, base64url-encoded
90
+ * - signature = HMAC-SHA256(nonce, secret), base64url-encoded
91
+ */
92
+ declare function generateCsrfToken(secret: string): Promise<string>;
93
+ /**
94
+ * Validate a signed CSRF token.
95
+ *
96
+ * Checks that the token has the correct `<nonce>.<signature>` format and that
97
+ * the HMAC signature is valid for the given secret. Uses crypto.subtle.verify
98
+ * which provides constant-time comparison.
99
+ *
100
+ * NOTE: No expiry check here — by design. The security property of signed
101
+ * double-submit comes from the unpredictability of the nonce + the
102
+ * secret-bound HMAC, not from time-bounding. The cookie's maxAge (86400s)
103
+ * handles expiry at the browser level.
104
+ */
105
+ declare function validateCsrfToken(token: string, secret: string): Promise<boolean>;
106
+ interface CsrfOptions {
107
+ /** Additional paths to exempt from CSRF validation. */
108
+ exemptPaths?: string[];
109
+ }
110
+ /**
111
+ * CSRF protection middleware (Signed Double-Submit Cookie).
112
+ *
113
+ * - GET/HEAD/OPTIONS: ensure a valid csrf_token cookie exists
114
+ * - POST/PUT/DELETE/PATCH: validate X-CSRF-Token header matches cookie, HMAC valid
115
+ * - Exempt: auth routes, public /forms/*, Bearer-only, API-key-only
116
+ */
117
+ declare function csrfProtection(options?: CsrfOptions): (c: Context, next: Next) => Promise<Response | void>;
118
+
119
+ interface RateLimitOptions {
120
+ max: number;
121
+ windowMs: number;
122
+ keyPrefix: string;
123
+ }
124
+ /**
125
+ * KV-based sliding window rate limiter middleware.
126
+ * Gracefully skips if CACHE_KV binding is not available.
127
+ */
128
+ declare function rateLimit(options: RateLimitOptions): (c: Context, next: Next) => Promise<void | (Response & hono.TypedResponse<{
129
+ error: string;
130
+ }, 429, "json">)>;
131
+
132
+ /**
133
+ * Security headers middleware.
134
+ * Sets standard security headers on every response.
135
+ * Skips HSTS in development to avoid local dev issues.
136
+ */
137
+ declare const securityHeadersMiddleware: () => (c: Context, next: Next) => Promise<void>;
138
+
59
139
  /**
60
140
  * Middleware Module Exports
61
141
  *
@@ -76,7 +156,7 @@ declare const securityLoggingMiddleware: any;
76
156
  declare const performanceLoggingMiddleware: any;
77
157
  declare const cacheHeaders: any;
78
158
  declare const compressionMiddleware: any;
79
- declare const securityHeaders: any;
159
+
80
160
  declare const PermissionManager: any;
81
161
  declare const requirePermission: any;
82
162
  declare const requireAnyPermission: any;
@@ -86,4 +166,4 @@ declare const requireActivePlugins: any;
86
166
  declare const getActivePlugins: any;
87
167
  declare const isPluginActive: any;
88
168
 
89
- export { AuthManager, type Permission, PermissionManager, type UserPermissions, bootstrapMiddleware, cacheHeaders, compressionMiddleware, detailedLoggingMiddleware, getActivePlugins, isPluginActive, logActivity, loggingMiddleware, metricsMiddleware, optionalAuth, performanceLoggingMiddleware, requireActivePlugin, requireActivePlugins, requireAnyPermission, requireAuth, requirePermission, requireRole, securityHeaders, securityLoggingMiddleware };
169
+ export { AuthManager, type Permission, PermissionManager, type UserPermissions, bootstrapMiddleware, cacheHeaders, compressionMiddleware, csrfProtection, detailedLoggingMiddleware, generateCsrfToken, getActivePlugins, isPluginActive, logActivity, loggingMiddleware, metricsMiddleware, optionalAuth, performanceLoggingMiddleware, rateLimit, requireActivePlugin, requireActivePlugins, requireAnyPermission, requireAuth, requirePermission, requireRole, securityHeadersMiddleware as securityHeaders, securityLoggingMiddleware, validateCsrfToken, verifySecurityConfig };
@@ -1,12 +1,21 @@
1
1
  import * as hono from 'hono';
2
2
  import { Context, Next, MiddlewareHandler } from 'hono';
3
- import { S as SonicJSConfig } from './app-CYEm1ytG.js';
3
+ import { S as SonicJSConfig } from './app-DnQ26Lho.js';
4
4
  import '@cloudflare/workers-types';
5
5
 
6
6
  type Bindings = {
7
7
  DB: D1Database;
8
8
  KV: KVNamespace;
9
+ JWT_SECRET?: string;
10
+ CORS_ORIGINS?: string;
11
+ ENVIRONMENT?: string;
9
12
  };
13
+ /**
14
+ * Verify security-critical environment configuration at startup.
15
+ * Logs warnings in development, throws in production to prevent
16
+ * insecure deployments from silently running.
17
+ */
18
+ declare function verifySecurityConfig(env: Bindings): void;
10
19
  /**
11
20
  * Bootstrap middleware that ensures system initialization
12
21
  * Runs once per worker instance
@@ -23,10 +32,12 @@ type JWTPayload = {
23
32
  iat: number;
24
33
  };
25
34
  declare class AuthManager {
26
- static generateToken(userId: string, email: string, role: string): Promise<string>;
27
- static verifyToken(token: string): Promise<JWTPayload | null>;
35
+ static generateToken(userId: string, email: string, role: string, secret?: string): Promise<string>;
36
+ static verifyToken(token: string, secret?: string): Promise<JWTPayload | null>;
28
37
  static hashPassword(password: string): Promise<string>;
29
- static verifyPassword(password: string, hash: string): Promise<boolean>;
38
+ static hashPasswordLegacy(password: string): Promise<string>;
39
+ static verifyPassword(password: string, storedHash: string): Promise<boolean>;
40
+ static isLegacyHash(storedHash: string): boolean;
30
41
  /**
31
42
  * Set authentication cookie - useful for plugins implementing alternative auth methods
32
43
  * @param c - Hono context
@@ -56,6 +67,75 @@ declare const optionalAuth: () => (c: Context, next: Next) => Promise<void>;
56
67
  */
57
68
  declare const metricsMiddleware: () => MiddlewareHandler;
58
69
 
70
+ /**
71
+ * CSRF Protection Middleware — Signed Double-Submit Cookie
72
+ *
73
+ * Stateless CSRF protection for Cloudflare Workers (no session store needed).
74
+ * Token format: `<nonce>.<hmac>` where HMAC-SHA256 is keyed with JWT_SECRET.
75
+ *
76
+ * Flow:
77
+ * GET — ensureCsrfCookie(): reuse existing valid cookie or set a new one
78
+ * POST/PUT/DELETE/PATCH — validate X-CSRF-Token header === csrf_token cookie, HMAC valid
79
+ *
80
+ * Exempt:
81
+ * - Safe methods (GET, HEAD, OPTIONS)
82
+ * - Auth routes that create sessions (/auth/login*, /auth/register*, etc.)
83
+ * - Public form submissions (/forms/*, /api/forms/*) — NOT /admin/forms/*
84
+ * - Requests with no auth_token cookie (Bearer-only or API-key-only)
85
+ */
86
+
87
+ /**
88
+ * Generate a signed CSRF token: `<nonce>.<hmac_signature>`
89
+ * - nonce = 32 random bytes, base64url-encoded
90
+ * - signature = HMAC-SHA256(nonce, secret), base64url-encoded
91
+ */
92
+ declare function generateCsrfToken(secret: string): Promise<string>;
93
+ /**
94
+ * Validate a signed CSRF token.
95
+ *
96
+ * Checks that the token has the correct `<nonce>.<signature>` format and that
97
+ * the HMAC signature is valid for the given secret. Uses crypto.subtle.verify
98
+ * which provides constant-time comparison.
99
+ *
100
+ * NOTE: No expiry check here — by design. The security property of signed
101
+ * double-submit comes from the unpredictability of the nonce + the
102
+ * secret-bound HMAC, not from time-bounding. The cookie's maxAge (86400s)
103
+ * handles expiry at the browser level.
104
+ */
105
+ declare function validateCsrfToken(token: string, secret: string): Promise<boolean>;
106
+ interface CsrfOptions {
107
+ /** Additional paths to exempt from CSRF validation. */
108
+ exemptPaths?: string[];
109
+ }
110
+ /**
111
+ * CSRF protection middleware (Signed Double-Submit Cookie).
112
+ *
113
+ * - GET/HEAD/OPTIONS: ensure a valid csrf_token cookie exists
114
+ * - POST/PUT/DELETE/PATCH: validate X-CSRF-Token header matches cookie, HMAC valid
115
+ * - Exempt: auth routes, public /forms/*, Bearer-only, API-key-only
116
+ */
117
+ declare function csrfProtection(options?: CsrfOptions): (c: Context, next: Next) => Promise<Response | void>;
118
+
119
+ interface RateLimitOptions {
120
+ max: number;
121
+ windowMs: number;
122
+ keyPrefix: string;
123
+ }
124
+ /**
125
+ * KV-based sliding window rate limiter middleware.
126
+ * Gracefully skips if CACHE_KV binding is not available.
127
+ */
128
+ declare function rateLimit(options: RateLimitOptions): (c: Context, next: Next) => Promise<void | (Response & hono.TypedResponse<{
129
+ error: string;
130
+ }, 429, "json">)>;
131
+
132
+ /**
133
+ * Security headers middleware.
134
+ * Sets standard security headers on every response.
135
+ * Skips HSTS in development to avoid local dev issues.
136
+ */
137
+ declare const securityHeadersMiddleware: () => (c: Context, next: Next) => Promise<void>;
138
+
59
139
  /**
60
140
  * Middleware Module Exports
61
141
  *
@@ -76,7 +156,7 @@ declare const securityLoggingMiddleware: any;
76
156
  declare const performanceLoggingMiddleware: any;
77
157
  declare const cacheHeaders: any;
78
158
  declare const compressionMiddleware: any;
79
- declare const securityHeaders: any;
159
+
80
160
  declare const PermissionManager: any;
81
161
  declare const requirePermission: any;
82
162
  declare const requireAnyPermission: any;
@@ -86,4 +166,4 @@ declare const requireActivePlugins: any;
86
166
  declare const getActivePlugins: any;
87
167
  declare const isPluginActive: any;
88
168
 
89
- export { AuthManager, type Permission, PermissionManager, type UserPermissions, bootstrapMiddleware, cacheHeaders, compressionMiddleware, detailedLoggingMiddleware, getActivePlugins, isPluginActive, logActivity, loggingMiddleware, metricsMiddleware, optionalAuth, performanceLoggingMiddleware, requireActivePlugin, requireActivePlugins, requireAnyPermission, requireAuth, requirePermission, requireRole, securityHeaders, securityLoggingMiddleware };
169
+ export { AuthManager, type Permission, PermissionManager, type UserPermissions, bootstrapMiddleware, cacheHeaders, compressionMiddleware, csrfProtection, detailedLoggingMiddleware, generateCsrfToken, getActivePlugins, isPluginActive, logActivity, loggingMiddleware, metricsMiddleware, optionalAuth, performanceLoggingMiddleware, rateLimit, requireActivePlugin, requireActivePlugins, requireAnyPermission, requireAuth, requirePermission, requireRole, securityHeadersMiddleware as securityHeaders, securityLoggingMiddleware, validateCsrfToken, verifySecurityConfig };
@@ -1,6 +1,6 @@
1
- export { AuthManager, PermissionManager, bootstrapMiddleware, cacheHeaders, compressionMiddleware, detailedLoggingMiddleware, getActivePlugins, isPluginActive, logActivity, loggingMiddleware, metricsMiddleware, optionalAuth, performanceLoggingMiddleware, requireActivePlugin, requireActivePlugins, requireAnyPermission, requireAuth, requirePermission, requireRole, securityHeaders, securityLoggingMiddleware } from './chunk-QWTS6NSP.js';
1
+ export { AuthManager, PermissionManager, bootstrapMiddleware, cacheHeaders, compressionMiddleware, csrfProtection, detailedLoggingMiddleware, generateCsrfToken, getActivePlugins, isPluginActive, logActivity, loggingMiddleware, metricsMiddleware, optionalAuth, performanceLoggingMiddleware, rateLimit, requireActivePlugin, requireActivePlugins, requireAnyPermission, requireAuth, requirePermission, requireRole, securityHeadersMiddleware as securityHeaders, securityLoggingMiddleware, validateCsrfToken, verifySecurityConfig } from './chunk-Y3VMEGY2.js';
2
2
  import './chunk-YFJJU26H.js';
3
- import './chunk-7Q2XPM2U.js';
3
+ import './chunk-GTFMI24U.js';
4
4
  import './chunk-FICTAGD4.js';
5
5
  import './chunk-V4OQ3NZ2.js';
6
6
  //# sourceMappingURL=middleware.js.map
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ var chunkHXHVU5GM_cjs = require('./chunk-HXHVU5GM.cjs');
4
+ require('./chunk-IGJUBJBW.cjs');
5
+
6
+
7
+
8
+ Object.defineProperty(exports, "MigrationService", {
9
+ enumerable: true,
10
+ get: function () { return chunkHXHVU5GM_cjs.MigrationService; }
11
+ });
12
+ //# sourceMappingURL=migrations-7X4RPH7O.cjs.map
13
+ //# sourceMappingURL=migrations-7X4RPH7O.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"migrations-76NR5BVF.cjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"migrations-7X4RPH7O.cjs"}
@@ -0,0 +1,4 @@
1
+ export { MigrationService } from './chunk-GTFMI24U.js';
2
+ import './chunk-V4OQ3NZ2.js';
3
+ //# sourceMappingURL=migrations-KHWFJ2HN.js.map
4
+ //# sourceMappingURL=migrations-KHWFJ2HN.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"migrations-2NTJ44OR.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"migrations-KHWFJ2HN.js"}
@@ -1,4 +1,4 @@
1
- import { c as CollectionConfig, e as CollectionSyncResult } from './collection-config-BF95LgQb.js';
1
+ import { c as CollectionConfig, e as CollectionSyncResult } from './collection-config-i8EaAF7z.cjs';
2
2
  import { D1Database as D1Database$1 } from '@cloudflare/workers-types';
3
3
  import * as drizzle_zod from 'drizzle-zod';
4
4
  import * as drizzle_orm_sqlite_core from 'drizzle-orm/sqlite-core';
@@ -1,4 +1,4 @@
1
- import { c as CollectionConfig, e as CollectionSyncResult } from './collection-config-BF95LgQb.cjs';
1
+ import { c as CollectionConfig, e as CollectionSyncResult } from './collection-config-i8EaAF7z.js';
2
2
  import { D1Database as D1Database$1 } from '@cloudflare/workers-types';
3
3
  import * as drizzle_zod from 'drizzle-zod';
4
4
  import * as drizzle_orm_sqlite_core from 'drizzle-orm/sqlite-core';
package/dist/routes.cjs CHANGED
@@ -1,110 +1,111 @@
1
1
  'use strict';
2
2
 
3
- var chunkJVRRG36J_cjs = require('./chunk-JVRRG36J.cjs');
3
+ var chunkR4WR3VTN_cjs = require('./chunk-R4WR3VTN.cjs');
4
4
  require('./chunk-VNLR35GO.cjs');
5
- require('./chunk-GIWIJNBH.cjs');
5
+ require('./chunk-K4Q4SFJJ.cjs');
6
6
  require('./chunk-MPT5PA6U.cjs');
7
- require('./chunk-SKLRRFJJ.cjs');
8
- require('./chunk-SHCYIZAN.cjs');
7
+ require('./chunk-HXHVU5GM.cjs');
8
+ require('./chunk-LTKV7AE5.cjs');
9
9
  require('./chunk-6FHNRRJ3.cjs');
10
- require('./chunk-WDQZYCQO.cjs');
10
+ require('./chunk-JDIM5AG7.cjs');
11
11
  require('./chunk-P3XDZL6Q.cjs');
12
12
  require('./chunk-RCQ2HIQD.cjs');
13
+ require('./chunk-MNWKYY5E.cjs');
13
14
  require('./chunk-IGJUBJBW.cjs');
14
15
 
15
16
 
16
17
 
17
18
  Object.defineProperty(exports, "ROUTES_INFO", {
18
19
  enumerable: true,
19
- get: function () { return chunkJVRRG36J_cjs.ROUTES_INFO; }
20
+ get: function () { return chunkR4WR3VTN_cjs.ROUTES_INFO; }
20
21
  });
21
22
  Object.defineProperty(exports, "adminApiReferenceRoutes", {
22
23
  enumerable: true,
23
- get: function () { return chunkJVRRG36J_cjs.router2; }
24
+ get: function () { return chunkR4WR3VTN_cjs.router2; }
24
25
  });
25
26
  Object.defineProperty(exports, "adminApiRoutes", {
26
27
  enumerable: true,
27
- get: function () { return chunkJVRRG36J_cjs.admin_api_default; }
28
+ get: function () { return chunkR4WR3VTN_cjs.admin_api_default; }
28
29
  });
29
30
  Object.defineProperty(exports, "adminCheckboxRoutes", {
30
31
  enumerable: true,
31
- get: function () { return chunkJVRRG36J_cjs.adminCheckboxRoutes; }
32
+ get: function () { return chunkR4WR3VTN_cjs.adminCheckboxRoutes; }
32
33
  });
33
34
  Object.defineProperty(exports, "adminCodeExamplesRoutes", {
34
35
  enumerable: true,
35
- get: function () { return chunkJVRRG36J_cjs.admin_code_examples_default; }
36
+ get: function () { return chunkR4WR3VTN_cjs.admin_code_examples_default; }
36
37
  });
37
38
  Object.defineProperty(exports, "adminCollectionsRoutes", {
38
39
  enumerable: true,
39
- get: function () { return chunkJVRRG36J_cjs.adminCollectionsRoutes; }
40
+ get: function () { return chunkR4WR3VTN_cjs.adminCollectionsRoutes; }
40
41
  });
41
42
  Object.defineProperty(exports, "adminContentRoutes", {
42
43
  enumerable: true,
43
- get: function () { return chunkJVRRG36J_cjs.admin_content_default; }
44
+ get: function () { return chunkR4WR3VTN_cjs.admin_content_default; }
44
45
  });
45
46
  Object.defineProperty(exports, "adminDashboardRoutes", {
46
47
  enumerable: true,
47
- get: function () { return chunkJVRRG36J_cjs.router; }
48
+ get: function () { return chunkR4WR3VTN_cjs.router; }
48
49
  });
49
50
  Object.defineProperty(exports, "adminDesignRoutes", {
50
51
  enumerable: true,
51
- get: function () { return chunkJVRRG36J_cjs.adminDesignRoutes; }
52
+ get: function () { return chunkR4WR3VTN_cjs.adminDesignRoutes; }
52
53
  });
53
54
  Object.defineProperty(exports, "adminFormsRoutes", {
54
55
  enumerable: true,
55
- get: function () { return chunkJVRRG36J_cjs.adminFormsRoutes; }
56
+ get: function () { return chunkR4WR3VTN_cjs.adminFormsRoutes; }
56
57
  });
57
58
  Object.defineProperty(exports, "adminLogsRoutes", {
58
59
  enumerable: true,
59
- get: function () { return chunkJVRRG36J_cjs.adminLogsRoutes; }
60
+ get: function () { return chunkR4WR3VTN_cjs.adminLogsRoutes; }
60
61
  });
61
62
  Object.defineProperty(exports, "adminMediaRoutes", {
62
63
  enumerable: true,
63
- get: function () { return chunkJVRRG36J_cjs.adminMediaRoutes; }
64
+ get: function () { return chunkR4WR3VTN_cjs.adminMediaRoutes; }
64
65
  });
65
66
  Object.defineProperty(exports, "adminPluginRoutes", {
66
67
  enumerable: true,
67
- get: function () { return chunkJVRRG36J_cjs.adminPluginRoutes; }
68
+ get: function () { return chunkR4WR3VTN_cjs.adminPluginRoutes; }
68
69
  });
69
70
  Object.defineProperty(exports, "adminSettingsRoutes", {
70
71
  enumerable: true,
71
- get: function () { return chunkJVRRG36J_cjs.adminSettingsRoutes; }
72
+ get: function () { return chunkR4WR3VTN_cjs.adminSettingsRoutes; }
72
73
  });
73
74
  Object.defineProperty(exports, "adminTestimonialsRoutes", {
74
75
  enumerable: true,
75
- get: function () { return chunkJVRRG36J_cjs.admin_testimonials_default; }
76
+ get: function () { return chunkR4WR3VTN_cjs.admin_testimonials_default; }
76
77
  });
77
78
  Object.defineProperty(exports, "adminUsersRoutes", {
78
79
  enumerable: true,
79
- get: function () { return chunkJVRRG36J_cjs.userRoutes; }
80
+ get: function () { return chunkR4WR3VTN_cjs.userRoutes; }
80
81
  });
81
82
  Object.defineProperty(exports, "apiContentCrudRoutes", {
82
83
  enumerable: true,
83
- get: function () { return chunkJVRRG36J_cjs.api_content_crud_default; }
84
+ get: function () { return chunkR4WR3VTN_cjs.api_content_crud_default; }
84
85
  });
85
86
  Object.defineProperty(exports, "apiMediaRoutes", {
86
87
  enumerable: true,
87
- get: function () { return chunkJVRRG36J_cjs.api_media_default; }
88
+ get: function () { return chunkR4WR3VTN_cjs.api_media_default; }
88
89
  });
89
90
  Object.defineProperty(exports, "apiRoutes", {
90
91
  enumerable: true,
91
- get: function () { return chunkJVRRG36J_cjs.api_default; }
92
+ get: function () { return chunkR4WR3VTN_cjs.api_default; }
92
93
  });
93
94
  Object.defineProperty(exports, "apiSystemRoutes", {
94
95
  enumerable: true,
95
- get: function () { return chunkJVRRG36J_cjs.api_system_default; }
96
+ get: function () { return chunkR4WR3VTN_cjs.api_system_default; }
96
97
  });
97
98
  Object.defineProperty(exports, "authRoutes", {
98
99
  enumerable: true,
99
- get: function () { return chunkJVRRG36J_cjs.auth_default; }
100
+ get: function () { return chunkR4WR3VTN_cjs.auth_default; }
100
101
  });
101
102
  Object.defineProperty(exports, "publicFormsRoutes", {
102
103
  enumerable: true,
103
- get: function () { return chunkJVRRG36J_cjs.public_forms_default; }
104
+ get: function () { return chunkR4WR3VTN_cjs.public_forms_default; }
104
105
  });
105
106
  Object.defineProperty(exports, "testCleanupRoutes", {
106
107
  enumerable: true,
107
- get: function () { return chunkJVRRG36J_cjs.test_cleanup_default; }
108
+ get: function () { return chunkR4WR3VTN_cjs.test_cleanup_default; }
108
109
  });
109
110
  //# sourceMappingURL=routes.cjs.map
110
111
  //# sourceMappingURL=routes.cjs.map
package/dist/routes.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as hono_types from 'hono/types';
2
2
  import { Hono } from 'hono';
3
- import { B as Bindings$a, V as Variables$b } from './app-CYEm1ytG.cjs';
3
+ import { B as Bindings$a, V as Variables$b } from './app-DnQ26Lho.cjs';
4
4
  import { D1Database as D1Database$1, KVNamespace as KVNamespace$1, R2Bucket as R2Bucket$1 } from '@cloudflare/workers-types';
5
5
 
6
6
  interface Variables$a extends Variables$b {
package/dist/routes.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as hono_types from 'hono/types';
2
2
  import { Hono } from 'hono';
3
- import { B as Bindings$a, V as Variables$b } from './app-CYEm1ytG.js';
3
+ import { B as Bindings$a, V as Variables$b } from './app-DnQ26Lho.js';
4
4
  import { D1Database as D1Database$1, KVNamespace as KVNamespace$1, R2Bucket as R2Bucket$1 } from '@cloudflare/workers-types';
5
5
 
6
6
  interface Variables$a extends Variables$b {
package/dist/routes.js CHANGED
@@ -1,13 +1,14 @@
1
- export { ROUTES_INFO, router2 as adminApiReferenceRoutes, admin_api_default as adminApiRoutes, adminCheckboxRoutes, admin_code_examples_default as adminCodeExamplesRoutes, adminCollectionsRoutes, admin_content_default as adminContentRoutes, router as adminDashboardRoutes, adminDesignRoutes, adminFormsRoutes, adminLogsRoutes, adminMediaRoutes, adminPluginRoutes, adminSettingsRoutes, admin_testimonials_default as adminTestimonialsRoutes, userRoutes as adminUsersRoutes, api_content_crud_default as apiContentCrudRoutes, api_media_default as apiMediaRoutes, api_default as apiRoutes, api_system_default as apiSystemRoutes, auth_default as authRoutes, public_forms_default as publicFormsRoutes, test_cleanup_default as testCleanupRoutes } from './chunk-FZRZYQYU.js';
1
+ export { ROUTES_INFO, router2 as adminApiReferenceRoutes, admin_api_default as adminApiRoutes, adminCheckboxRoutes, admin_code_examples_default as adminCodeExamplesRoutes, adminCollectionsRoutes, admin_content_default as adminContentRoutes, router as adminDashboardRoutes, adminDesignRoutes, adminFormsRoutes, adminLogsRoutes, adminMediaRoutes, adminPluginRoutes, adminSettingsRoutes, admin_testimonials_default as adminTestimonialsRoutes, userRoutes as adminUsersRoutes, api_content_crud_default as apiContentCrudRoutes, api_media_default as apiMediaRoutes, api_default as apiRoutes, api_system_default as apiSystemRoutes, auth_default as authRoutes, public_forms_default as publicFormsRoutes, test_cleanup_default as testCleanupRoutes } from './chunk-CH5UHZVM.js';
2
2
  import './chunk-G44QUVNM.js';
3
- import './chunk-QWTS6NSP.js';
3
+ import './chunk-Y3VMEGY2.js';
4
4
  import './chunk-YFJJU26H.js';
5
- import './chunk-7Q2XPM2U.js';
6
- import './chunk-VCH6HXVP.js';
5
+ import './chunk-GTFMI24U.js';
6
+ import './chunk-JJS7JZCH.js';
7
7
  import './chunk-J5WGMRSU.js';
8
- import './chunk-KAT3OKHE.js';
8
+ import './chunk-5XAI2XUF.js';
9
9
  import './chunk-X7ZAEI5S.js';
10
10
  import './chunk-FICTAGD4.js';
11
+ import './chunk-TQABQWOP.js';
11
12
  import './chunk-V4OQ3NZ2.js';
12
13
  //# sourceMappingURL=routes.js.map
13
14
  //# sourceMappingURL=routes.js.map
package/dist/services.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  var chunkVNLR35GO_cjs = require('./chunk-VNLR35GO.cjs');
4
4
  var chunkMPT5PA6U_cjs = require('./chunk-MPT5PA6U.cjs');
5
- var chunkSKLRRFJJ_cjs = require('./chunk-SKLRRFJJ.cjs');
5
+ var chunkHXHVU5GM_cjs = require('./chunk-HXHVU5GM.cjs');
6
6
  require('./chunk-P3XDZL6Q.cjs');
7
7
  require('./chunk-IGJUBJBW.cjs');
8
8
 
@@ -106,7 +106,7 @@ Object.defineProperty(exports, "validateCollectionConfig", {
106
106
  });
107
107
  Object.defineProperty(exports, "MigrationService", {
108
108
  enumerable: true,
109
- get: function () { return chunkSKLRRFJJ_cjs.MigrationService; }
109
+ get: function () { return chunkHXHVU5GM_cjs.MigrationService; }
110
110
  });
111
111
  //# sourceMappingURL=services.cjs.map
112
112
  //# sourceMappingURL=services.cjs.map