@blamejs/core 0.6.7 → 0.6.12
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/CHANGELOG.md +17 -11
- package/README.md +1 -1
- package/lib/api-key.js +9 -9
- package/lib/archive.js +5 -5
- package/lib/audit.js +2 -2
- package/lib/auth/jwt.js +4 -4
- package/lib/backup/index.js +21 -5
- package/lib/break-glass.js +7 -6
- package/lib/cache.js +9 -9
- package/lib/constants.js +6 -6
- package/lib/credential-hash.js +9 -9
- package/lib/db-declare-view.js +2 -2
- package/lib/external-db-migrate.js +1 -1
- package/lib/http-client.js +3 -3
- package/lib/i18n.js +12 -12
- package/lib/log-stream-webhook.js +22 -4
- package/lib/mail.js +16 -1
- package/lib/middleware/body-parser.js +32 -0
- package/lib/middleware/cors.js +1 -1
- package/lib/middleware/csrf-protect.js +2 -2
- package/lib/middleware/rate-limit.js +2 -2
- package/lib/middleware/require-auth.js +9 -4
- package/lib/notify.js +2 -2
- package/lib/object-store/sigv4-bucket-ops.js +6 -5
- package/lib/object-store/sigv4.js +3 -3
- package/lib/observability.js +39 -13
- package/lib/otel-export.js +2 -2
- package/lib/pagination.js +6 -6
- package/lib/permissions.js +7 -7
- package/lib/protocol-dispatcher.js +2 -2
- package/lib/queue.js +11 -7
- package/lib/request-helpers.js +3 -3
- package/lib/restore.js +104 -0
- package/lib/retry.js +20 -19
- package/lib/safe-url.js +16 -0
- package/lib/seeders.js +9 -9
- package/lib/session.js +5 -2
- package/lib/slug.js +6 -6
- package/lib/testing.js +5 -5
- package/lib/validate-opts.js +2 -1
- package/lib/webhook.js +7 -7
- package/package.json +1 -1
package/lib/seeders.js
CHANGED
|
@@ -36,14 +36,14 @@
|
|
|
36
36
|
* truncating the seeded tables themselves; "unseed" isn't framework-
|
|
37
37
|
* knowable.
|
|
38
38
|
*
|
|
39
|
-
* Validation
|
|
39
|
+
* Validation policy:
|
|
40
40
|
*
|
|
41
|
-
* - create() opts →
|
|
42
|
-
* - run/status `env` arg →
|
|
43
|
-
* - seed file shape (missing run, etc) →
|
|
44
|
-
* - dependsOn cycle →
|
|
45
|
-
* - dependsOn missing →
|
|
46
|
-
* - audit emit failures →
|
|
41
|
+
* - create() opts → throw at boot
|
|
42
|
+
* - run/status `env` arg → throw at call site (explicit)
|
|
43
|
+
* - seed file shape (missing run, etc) → throw at load
|
|
44
|
+
* - dependsOn cycle → throw at load
|
|
45
|
+
* - dependsOn missing → throw at run
|
|
46
|
+
* - audit emit failures → drop silent (hot-path sink)
|
|
47
47
|
*
|
|
48
48
|
* Security defaults:
|
|
49
49
|
*
|
|
@@ -103,7 +103,7 @@ function _runSql(db, sql) {
|
|
|
103
103
|
throw _err("BAD_DB", "seeders: db handle exposes no DDL runner (exec / runSql)");
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
// ----
|
|
106
|
+
// ---- Call-site validation helpers (throw on bad input) ----
|
|
107
107
|
|
|
108
108
|
function _validateEnv(name, value) {
|
|
109
109
|
if (typeof value !== "string" || value.length === 0) {
|
|
@@ -399,7 +399,7 @@ function create(opts) {
|
|
|
399
399
|
|
|
400
400
|
function _emitObs(name, labels) {
|
|
401
401
|
try { observability().event(name, 1, labels || {}); }
|
|
402
|
-
catch (_e) { /*
|
|
402
|
+
catch (_e) { /* drop-silent — observability sink must not crash seeders */ }
|
|
403
403
|
}
|
|
404
404
|
|
|
405
405
|
function _emitAudit(action, info) {
|
package/lib/session.js
CHANGED
|
@@ -212,8 +212,11 @@ async function touch(token, opts) {
|
|
|
212
212
|
// assembly) and matches the call shape clusterStorage expects.
|
|
213
213
|
// extendBy resets expiresAt relative to NOW, not relative to the
|
|
214
214
|
// current expiresAt — a soaked session with continuous traffic
|
|
215
|
-
// shouldn't accumulate unbounded expiry.
|
|
216
|
-
|
|
215
|
+
// shouldn't accumulate unbounded expiry. The same MAX_TTL_MS
|
|
216
|
+
// ceiling create() and rotate() apply gates extendBy too — repeated
|
|
217
|
+
// touch() calls cannot push expiresAt past the framework's bound.
|
|
218
|
+
if (opts.extendBy !== undefined && opts.extendBy !== null) {
|
|
219
|
+
_validateTtl(opts.extendBy, "session.touch");
|
|
217
220
|
var newExpires = nowMs + opts.extendBy;
|
|
218
221
|
var result = await clusterStorage.execute(
|
|
219
222
|
"UPDATE _blamejs_sessions SET lastActivity = ?, expiresAt = ? " +
|
package/lib/slug.js
CHANGED
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
* symbols, and separators — Cyrillic, Greek, CJK, and other scripts pass
|
|
21
21
|
* through. Operators with non-Latin user content opt into preserveUnicode.
|
|
22
22
|
*
|
|
23
|
-
* Validation
|
|
23
|
+
* Validation policy:
|
|
24
24
|
*
|
|
25
|
-
* - Opts at first call (every public fn) →
|
|
26
|
-
* - title not a string →
|
|
27
|
-
* - title normalizes to empty →
|
|
28
|
-
* - unique() exhausts maxAttempts →
|
|
25
|
+
* - Opts at first call (every public fn) → throw at call site
|
|
26
|
+
* - title not a string → throw at call site
|
|
27
|
+
* - title normalizes to empty → return opts.fallback (tolerant)
|
|
28
|
+
* - unique() exhausts maxAttempts → throw SlugError at call site
|
|
29
29
|
*
|
|
30
30
|
* Out of scope (v1):
|
|
31
31
|
* - Word-by-word transliteration tables (Russian → English, Chinese →
|
|
@@ -61,7 +61,7 @@ var _RESERVED = Object.freeze([
|
|
|
61
61
|
"new", "edit", "delete", "create", "update",
|
|
62
62
|
]);
|
|
63
63
|
|
|
64
|
-
// ----
|
|
64
|
+
// ---- Call-site validation helpers (throw on bad input) ----
|
|
65
65
|
|
|
66
66
|
function _isPositiveInt(n) {
|
|
67
67
|
return typeof n === "number" && isFinite(n) && n >= 1 && Math.floor(n) === n;
|
package/lib/testing.js
CHANGED
|
@@ -82,7 +82,7 @@ var DEFAULTS = Object.freeze({
|
|
|
82
82
|
runMiddlewareTimeoutMs: 5000,
|
|
83
83
|
});
|
|
84
84
|
|
|
85
|
-
// ----
|
|
85
|
+
// ---- Call-site validation helpers (throw on bad input) ----
|
|
86
86
|
|
|
87
87
|
function _isPositiveInt(n) {
|
|
88
88
|
return typeof n === "number" && isFinite(n) && n >= 1 && Math.floor(n) === n;
|
|
@@ -268,7 +268,7 @@ function fakeHttpClient(responder) {
|
|
|
268
268
|
|
|
269
269
|
// ---- captureAudit ----
|
|
270
270
|
//
|
|
271
|
-
// Matches b.audit.safeEmit
|
|
271
|
+
// Matches b.audit.safeEmit's drop-silent contract. captured holds
|
|
272
272
|
// every event pushed; clear() empties; byAction(name) filters.
|
|
273
273
|
|
|
274
274
|
function captureAudit() {
|
|
@@ -276,9 +276,9 @@ function captureAudit() {
|
|
|
276
276
|
return {
|
|
277
277
|
captured: captured,
|
|
278
278
|
safeEmit: function (event) {
|
|
279
|
-
//
|
|
280
|
-
//
|
|
281
|
-
//
|
|
279
|
+
// Drop-silent on caller-side bugs that throw inside the capture
|
|
280
|
+
// push (shouldn't happen with array.push, but matches the real
|
|
281
|
+
// safeEmit's defensive shape).
|
|
282
282
|
try { captured.push(event); }
|
|
283
283
|
catch (_e) { /* drop-silent */ }
|
|
284
284
|
},
|
package/lib/validate-opts.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* validate-opts — shared
|
|
3
|
+
* validate-opts — shared call-site helper for primitive create() functions
|
|
4
|
+
* that throws on unknown / bad-shape opts at config time.
|
|
4
5
|
*
|
|
5
6
|
* Catches silent operator typos: `cors({ allowedOrigins: [] })` (wrong
|
|
6
7
|
* key name) currently looks like config but does nothing — the primitive
|
package/lib/webhook.js
CHANGED
|
@@ -57,12 +57,12 @@
|
|
|
57
57
|
* reference impl; operators plug in Redis/SQL by passing any object
|
|
58
58
|
* with `checkAndInsert(nonce, expireAt) → bool/Promise<bool>`.
|
|
59
59
|
*
|
|
60
|
-
* Validation
|
|
60
|
+
* Validation policy:
|
|
61
61
|
*
|
|
62
|
-
* - signer/verifier creation opts →
|
|
63
|
-
* - signer.sign body type →
|
|
64
|
-
* - signer.send url shape →
|
|
65
|
-
* - verifier.verify input shape →
|
|
62
|
+
* - signer/verifier creation opts → throw at config time
|
|
63
|
+
* - signer.sign body type → throw at call site
|
|
64
|
+
* - signer.send url shape → throw at call site (via safeUrl)
|
|
65
|
+
* - verifier.verify input shape → throw WebhookError at call site
|
|
66
66
|
* - nonceStore.checkAndInsert err → propagates (fail-closed)
|
|
67
67
|
*/
|
|
68
68
|
|
|
@@ -79,7 +79,7 @@ var observability = lazyRequire(function () { return require("./observability");
|
|
|
79
79
|
|
|
80
80
|
function _emitEvent(name, value, labels) {
|
|
81
81
|
try { observability().event(name, value, labels || {}); }
|
|
82
|
-
catch (_e) { /*
|
|
82
|
+
catch (_e) { /* hot-path observability sink — drops silent on internal throws */ }
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
var _err = WebhookError.factory;
|
|
@@ -111,7 +111,7 @@ var DEFAULTS = Object.freeze({
|
|
|
111
111
|
auditSuccess: true,
|
|
112
112
|
});
|
|
113
113
|
|
|
114
|
-
// ----
|
|
114
|
+
// ---- Call-site validation helpers (throw on bad input) ----
|
|
115
115
|
|
|
116
116
|
function _isPositiveInt(n) {
|
|
117
117
|
return typeof n === "number" && isFinite(n) && n >= 1 && Math.floor(n) === n;
|