@blamejs/core 0.7.1 → 0.7.4
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 +6 -0
- package/README.md +2 -2
- package/index.js +2 -0
- package/lib/api-key.js +1 -10
- package/lib/cache-redis.js +1 -11
- package/lib/cache.js +11 -16
- package/lib/file-upload.js +933 -0
- package/lib/framework-error.js +13 -0
- package/lib/log-stream-syslog.js +1 -1
- package/lib/middleware/api-encrypt.js +415 -52
- package/lib/middleware/db-role-for.js +3 -8
- package/lib/notify.js +3 -5
- package/lib/object-store/azure-blob.js +42 -5
- package/lib/object-store/gcs.js +47 -7
- package/lib/object-store/sigv4.js +55 -7
- package/lib/pubsub-redis.js +1 -11
- package/lib/queue-redis.js +1 -8
- package/lib/redis-client.js +30 -0
- package/lib/request-helpers.js +21 -17
- package/lib/seeders.js +5 -17
- package/lib/static.js +699 -114
- package/lib/validate-opts.js +49 -0
- package/lib/webhook.js +3 -6
- package/package.json +1 -1
- package/sbom.cyclonedx.json +6 -6
package/lib/validate-opts.js
CHANGED
|
@@ -219,6 +219,53 @@ function requireNonEmptyString(value, label, errorClass, code) {
|
|
|
219
219
|
return value;
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
+
// optionalNonEmptyStringArray — required-shape validator for optional
|
|
223
|
+
// array-of-non-empty-strings opts (scopes / allowedFileTypes / dependsOn /
|
|
224
|
+
// rtlLanguages / eagerLocales / etc.). Replaces the recurring four-line
|
|
225
|
+
// cascade `if (opts.X !== undefined) { if (!Array.isArray) throw; for
|
|
226
|
+
// (i...) if (typeof !== "string" || === "") throw }` that 5+ primitives
|
|
227
|
+
// previously rolled by hand.
|
|
228
|
+
//
|
|
229
|
+
// undefined / null → returns the value unchanged (caller can default).
|
|
230
|
+
// non-array → throws via errorClass with the provided code.
|
|
231
|
+
// any non-string or empty-string element → throws with index-pointing message.
|
|
232
|
+
function optionalNonEmptyStringArray(value, label, errorClass, code) {
|
|
233
|
+
if (value === undefined || value === null) return value;
|
|
234
|
+
if (!Array.isArray(value)) {
|
|
235
|
+
_throw(errorClass, code, (label || "opt") +
|
|
236
|
+
" must be an array of non-empty strings, got " + typeof value,
|
|
237
|
+
"validate-opts/bad-string-array");
|
|
238
|
+
}
|
|
239
|
+
for (var i = 0; i < value.length; i += 1) {
|
|
240
|
+
if (typeof value[i] !== "string" || value[i].length === 0) {
|
|
241
|
+
_throw(errorClass, code, (label || "opt") +
|
|
242
|
+
"[" + i + "] must be a non-empty string",
|
|
243
|
+
"validate-opts/bad-string-array-element");
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return value;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// optionalObjectWithMethod — required-shape validator for optional opts
|
|
250
|
+
// that accept a "duck-typed handle": an object that exposes a specific
|
|
251
|
+
// method. Replaces the recurring `if (opts.X !== undefined && opts.X !==
|
|
252
|
+
// null) { if (typeof opts.X !== "object" || typeof opts.X.method !==
|
|
253
|
+
// "function") throw ... }` cascade shared by file-upload (permissions),
|
|
254
|
+
// notify (queue), seeders (db), webhook (nonceStore), and others.
|
|
255
|
+
//
|
|
256
|
+
// undefined / null → returns the value unchanged (caller can default).
|
|
257
|
+
// non-object OR missing method → throws via errorClass with the operator-
|
|
258
|
+
// facing description (e.g. "must be a b.permissions instance (check fn)").
|
|
259
|
+
function optionalObjectWithMethod(value, method, label, errorClass, code, description) {
|
|
260
|
+
if (value === undefined || value === null) return value;
|
|
261
|
+
if (typeof value !== "object" || typeof value[method] !== "function") {
|
|
262
|
+
_throw(errorClass, code, (label || "opt") + " " +
|
|
263
|
+
(description || ("must expose " + method + "() method")),
|
|
264
|
+
"validate-opts/bad-shaped-handle");
|
|
265
|
+
}
|
|
266
|
+
return value;
|
|
267
|
+
}
|
|
268
|
+
|
|
222
269
|
// makeAuditEmitter — closure factory parallel to safeAsync.makeDropCallback.
|
|
223
270
|
// Replaces the per-file `function _emit(action, info) { if (!audit) return;
|
|
224
271
|
// try { audit.safeEmit(Object.assign({ action: action }, info || {})); }
|
|
@@ -263,6 +310,8 @@ module.exports.optionalFiniteNonNegative = optionalFiniteNonNegative;
|
|
|
263
310
|
module.exports.optionalPositiveFinite = optionalPositiveFinite;
|
|
264
311
|
module.exports.optionalFunction = optionalFunction;
|
|
265
312
|
module.exports.optionalNonEmptyString = optionalNonEmptyString;
|
|
313
|
+
module.exports.optionalNonEmptyStringArray = optionalNonEmptyStringArray;
|
|
314
|
+
module.exports.optionalObjectWithMethod = optionalObjectWithMethod;
|
|
266
315
|
module.exports.requireNonEmptyString = requireNonEmptyString;
|
|
267
316
|
module.exports.observabilityShape = observabilityShape;
|
|
268
317
|
module.exports.requireObject = requireObject;
|
package/lib/webhook.js
CHANGED
|
@@ -408,12 +408,9 @@ function _validateVerifierOpts(opts) {
|
|
|
408
408
|
validateOpts.optionalFiniteNonNegative(opts.toleranceMs, "webhook.verifier: toleranceMs", WebhookError);
|
|
409
409
|
validateOpts.optionalFiniteNonNegative(opts.clockSkewMs, "webhook.verifier: clockSkewMs", WebhookError);
|
|
410
410
|
validateOpts.optionalNonEmptyString(opts.signatureHeader, "webhook.verifier: signatureHeader", WebhookError);
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
throw _err("BAD_OPT", "webhook.verifier: nonceStore must implement checkAndInsert(nonce, expireAt)");
|
|
415
|
-
}
|
|
416
|
-
}
|
|
411
|
+
validateOpts.optionalObjectWithMethod(opts.nonceStore, "checkAndInsert",
|
|
412
|
+
"webhook.verifier: nonceStore", WebhookError, "BAD_OPT",
|
|
413
|
+
"must implement checkAndInsert(nonce, expireAt)");
|
|
417
414
|
validateOpts.optionalFunction(opts.now, "webhook.verifier: now", WebhookError);
|
|
418
415
|
validateOpts.auditShape(opts.audit, "webhook.verifier", WebhookError);
|
|
419
416
|
validateOpts.optionalBoolean(opts.auditFailures, "webhook.verifier: auditFailures", WebhookError);
|
package/package.json
CHANGED
package/sbom.cyclonedx.json
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json",
|
|
3
3
|
"bomFormat": "CycloneDX",
|
|
4
4
|
"specVersion": "1.5",
|
|
5
|
-
"serialNumber": "urn:uuid:
|
|
5
|
+
"serialNumber": "urn:uuid:ddc45497-46e6-4b4b-94ee-8cb0849c82cd",
|
|
6
6
|
"version": 1,
|
|
7
7
|
"metadata": {
|
|
8
|
-
"timestamp": "2026-05-
|
|
8
|
+
"timestamp": "2026-05-04T16:54:01.026Z",
|
|
9
9
|
"lifecycles": [
|
|
10
10
|
{
|
|
11
11
|
"phase": "build"
|
|
@@ -19,14 +19,14 @@
|
|
|
19
19
|
}
|
|
20
20
|
],
|
|
21
21
|
"component": {
|
|
22
|
-
"bom-ref": "@blamejs/core@0.7.
|
|
22
|
+
"bom-ref": "@blamejs/core@0.7.4",
|
|
23
23
|
"type": "library",
|
|
24
24
|
"name": "blamejs",
|
|
25
|
-
"version": "0.7.
|
|
25
|
+
"version": "0.7.4",
|
|
26
26
|
"scope": "required",
|
|
27
27
|
"author": "blamejs contributors",
|
|
28
28
|
"description": "The Node framework that owns its stack.",
|
|
29
|
-
"purl": "pkg:npm/%40blamejs/core@0.7.
|
|
29
|
+
"purl": "pkg:npm/%40blamejs/core@0.7.4",
|
|
30
30
|
"properties": [],
|
|
31
31
|
"externalReferences": [
|
|
32
32
|
{
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"components": [],
|
|
55
55
|
"dependencies": [
|
|
56
56
|
{
|
|
57
|
-
"ref": "@blamejs/core@0.7.
|
|
57
|
+
"ref": "@blamejs/core@0.7.4",
|
|
58
58
|
"dependsOn": []
|
|
59
59
|
}
|
|
60
60
|
]
|