@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.
@@ -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
- if (opts.nonceStore !== undefined && opts.nonceStore !== null) {
412
- if (typeof opts.nonceStore !== "object" ||
413
- typeof opts.nonceStore.checkAndInsert !== "function") {
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blamejs/core",
3
- "version": "0.7.1",
3
+ "version": "0.7.4",
4
4
  "description": "The Node framework that owns its stack.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "blamejs contributors",
@@ -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:818ba232-b5b3-42aa-9167-55dbae7228f0",
5
+ "serialNumber": "urn:uuid:ddc45497-46e6-4b4b-94ee-8cb0849c82cd",
6
6
  "version": 1,
7
7
  "metadata": {
8
- "timestamp": "2026-05-04T03:26:40.519Z",
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.1",
22
+ "bom-ref": "@blamejs/core@0.7.4",
23
23
  "type": "library",
24
24
  "name": "blamejs",
25
- "version": "0.7.1",
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.1",
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.1",
57
+ "ref": "@blamejs/core@0.7.4",
58
58
  "dependsOn": []
59
59
  }
60
60
  ]