@blamejs/core 0.12.65 → 0.12.66
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 +2 -0
- package/README.md +1 -0
- package/index.js +2 -0
- package/lib/uri-template.js +286 -0
- package/package.json +1 -1
- package/sbom.cdx.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,8 @@ upgrading across more than a few patches at a time.
|
|
|
8
8
|
|
|
9
9
|
## v0.12.x
|
|
10
10
|
|
|
11
|
+
- v0.12.66 (2026-05-26) — **`b.uriTemplate` — RFC 6570 URI Template expansion.** Expand RFC 6570 URI Templates — the {var} syntax that OpenAPI links, HAL _links, and hypermedia API clients use to turn a template plus a set of variables into a concrete URI. The full Level 4 grammar is supported: every operator ({+var} reserved, {#var} fragment, {.var} label, {/var} path, {;var} path-style parameters, {?var} query, {&var} query continuation), the {var:3} prefix modifier, and the {var*} explode modifier for lists and associative arrays. b.uriTemplate.expand(template, vars) returns the expanded string; b.uriTemplate.compile(template) parses once for templates applied to many variable sets. A malformed template (unclosed expression, reserved operator, non-numeric prefix, unmatched brace) throws UriTemplateError. Verified against the official uritemplate-test conformance suite (all 135 spec, extended, and negative cases). **Added:** *`b.uriTemplate.expand` / `b.uriTemplate.compile`* — RFC 6570 URI Template expansion, full Level 4. `expand(template, vars)` substitutes variables into a template and returns the URI; `compile(template)` returns a reusable `{ expand }` for repeated use. Variable values may be strings, numbers, booleans, arrays (lists), or plain objects (associative arrays); undefined, null, and empty list/map variables are omitted. All eight operators, the `:N` prefix modifier, and the `*` explode modifier follow §3.2, including reserved-set encoding for `{+var}` / `{#var}`. Composes naturally with `b.hal`, `b.linkHeader`, and `b.openapi` link objects. A malformed template throws `UriTemplateError`.
|
|
12
|
+
|
|
11
13
|
- v0.12.65 (2026-05-26) — **`b.base32` — RFC 4648 Base32 encode / decode.** Encode and decode RFC 4648 Base32 — the case-insensitive alphabet behind TOTP / 2FA secrets, DNSSEC NSEC3 hashes, and human-transcribable identifiers. Both RFC 4648 variants are supported: the standard alphabet (the default) and the extended-hex alphabet. b.base32.encode pads to an 8-character boundary by default (pass padding: false for the bare form TOTP key URIs use); b.base32.decode is strict by default but accepts the real-world shapes humans produce — lower-case, embedded spaces and dashes, missing padding — under loose: true. Verified against the RFC 4648 §10 test vectors for both alphabets. The TOTP primitive now composes this codec instead of carrying its own Base32 implementation. **Added:** *`b.base32.encode` / `b.base32.decode`* — RFC 4648 Base32 codec. `encode(buf, opts)` takes a Buffer or Uint8Array and returns a Base32 string, padded to an 8-character boundary unless `padding: false`; `decode(str, opts)` returns a Buffer. The `variant` option selects the standard (`"rfc4648"`, default) or extended-hex (`"rfc4648-hex"`) alphabet. Decoding is strict by default — any character outside the alphabet throws `Base32Error` — and `loose: true` up-cases the input and ignores embedded spaces, dashes, and missing padding, which is how copied TOTP keys and hand-typed codes arrive. **Changed:** *TOTP composes `b.base32`* — `b.auth.totp` now encodes and decodes its secrets through `b.base32` rather than a private Base32 implementation. Behavior is unchanged — secrets are still emitted unpadded and parsed leniently (case-insensitive, ignoring spaces and dashes).
|
|
12
14
|
|
|
13
15
|
- v0.12.64 (2026-05-25) — **`b.jsonSchema` — JSON Schema 2020-12 validation.** Validate JSON against a JSON Schema 2020-12 document — the dialect OpenAPI 3.1 adopted and the most widely implemented schema language. b.jsonSchema.compile(schema) returns a reusable validator; b.jsonSchema.validate(schema, instance) compiles and runs in one call, returning { valid, errors } where each error names the failing instance location, keyword, and schema path. The full 2020-12 vocabulary is supported: every applicator (allOf / anyOf / oneOf / not / if-then-else, properties / patternProperties / additionalProperties / prefixItems / items / contains), the annotation-aware unevaluatedProperties / unevaluatedItems, every assertion keyword, and reference resolution ($ref / $anchor / $dynamicRef / $dynamicAnchor / $defs / $id base URIs). format is an annotation by default (opt in to assertion with assertFormat). External references resolve through an operator-supplied schema map — never a network fetch. Verified against the official JSON-Schema-Test-Suite (1292 of 1295 draft2020-12 cases; the remainder need the bundled dialect metaschema or $vocabulary selection, both opt-in). This is the standards-track counterpart to the fluent b.safeSchema builder and the portable b.jtd. **Added:** *`b.jsonSchema` — JSON Schema 2020-12* — `compile(schema, opts)` returns `{ validate, isValid }`; `validate(schema, instance, opts)` and `isValid(schema, instance, opts)` compile and run in one call. `validate` returns `{ valid, errors }`, each error a `{ instancePath, keyword, schemaPath, message }`. The full 2020-12 vocabulary is implemented — applicators, annotation-aware `unevaluatedProperties` / `unevaluatedItems`, every assertion keyword, and `$ref` / `$anchor` / `$dynamicRef` / `$dynamicAnchor` / `$defs` / `$id` resolution. `format` is an annotation by default (`assertFormat: true` to assert). External references resolve through `opts.schemas` (a URI→schema map), never a network fetch. Reach for it when the schema is an existing JSON Schema document (an API contract, OpenAPI component, or config schema); `b.safeSchema` remains the fluent in-process builder and `b.jtd` the portable codegen-friendly option. Validating a schema document against the dialect metaschema requires supplying that metaschema via `opts.schemas`, and `$vocabulary`-based keyword selection is not honored (every standard keyword always asserts).
|
package/README.md
CHANGED
|
@@ -99,6 +99,7 @@ The framework bundles the surface a typical Node app reaches for. Every primitiv
|
|
|
99
99
|
- **Signed webhooks + API encryption** — SLH-DSA-SHAKE-256f default; ML-DSA-65 opt-in; ECIES API encryption (`b.webhook`, `b.crypto`)
|
|
100
100
|
- **HPKE / HTTP signatures** — RFC 9180 HPKE with ML-KEM-1024 + HKDF-SHA3-512 + ChaCha20-Poly1305 (`b.crypto.hpke`); RFC 9421 HTTP Message Signatures with derived components and ed25519 / ML-DSA-65 (`b.crypto.httpSig`); RFC 9530 Content-Digest / Repr-Digest body-integrity fields (SHA-256 / SHA-512, legacy algorithms refused — `b.contentDigest`) to sign the digest rather than the whole body
|
|
101
101
|
- **Link header** — RFC 8288 Web Linking codec (`b.linkHeader.parse` / `serialize`): parse and build `Link: <uri>; rel="next"` relations, the standard REST pagination mechanism; quote-aware (a comma inside a quoted parameter never splits the list)
|
|
102
|
+
- **URI Templates** — RFC 6570 expansion (`b.uriTemplate.expand` / `compile`): full Level 4 — every operator, the `:N` prefix and `*` explode modifiers — turning `{/path}{?q*}` plus variables into a concrete URI; validated against the official uritemplate-test suite. The `{var}` syntax behind OpenAPI links and HAL `_links`
|
|
102
103
|
- **JSON Type Definition** — RFC 8927 validation (`b.jtd.validate` / `isValid`): portable, cross-implementation schema validation (all eight forms — type / enum / elements / properties / values / discriminator / ref / empty), returning instancePath / schemaPath errors; validated against the official 316-case suite. Interop companion to the fluent `b.safeSchema` builder
|
|
103
104
|
- **JSON Schema 2020-12** — the OpenAPI 3.1 dialect (`b.jsonSchema.compile` / `validate` / `isValid`): full vocabulary including every applicator, annotation-aware `unevaluatedProperties` / `unevaluatedItems`, and `$ref` / `$dynamicRef` / `$anchor` / `$id` resolution (external refs via an operator-supplied schema map, never a network fetch); `format` is an annotation unless `assertFormat` is set; returns located `{ valid, errors }`. Validated against the official JSON-Schema-Test-Suite. Standards-track counterpart to `b.safeSchema` and `b.jtd`
|
|
104
105
|
- **Base32** — RFC 4648 codec (`b.base32.encode` / `decode`): standard + extended-hex alphabets, padded or bare, strict or lenient decode (case-insensitive, ignoring spaces / dashes for copied TOTP keys); validated against the RFC 4648 §10 vectors. The codec behind `b.auth.totp` secrets
|
package/index.js
CHANGED
|
@@ -405,6 +405,7 @@ var jsonPath = require("./lib/json-path");
|
|
|
405
405
|
var jtd = require("./lib/jtd");
|
|
406
406
|
var jsonSchema = require("./lib/json-schema");
|
|
407
407
|
var base32 = require("./lib/base32");
|
|
408
|
+
var uriTemplate = require("./lib/uri-template");
|
|
408
409
|
var standardWebhooks = require("./lib/standard-webhooks");
|
|
409
410
|
var lro = require("./lib/lro");
|
|
410
411
|
var jsonApi = require("./lib/jsonapi");
|
|
@@ -431,6 +432,7 @@ module.exports = {
|
|
|
431
432
|
jtd: jtd,
|
|
432
433
|
jsonSchema: jsonSchema,
|
|
433
434
|
base32: base32,
|
|
435
|
+
uriTemplate: uriTemplate,
|
|
434
436
|
standardWebhooks: standardWebhooks,
|
|
435
437
|
lro: lro,
|
|
436
438
|
jsonApi: jsonApi,
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module b.uriTemplate
|
|
4
|
+
* @nav HTTP
|
|
5
|
+
* @title URI Templates
|
|
6
|
+
*
|
|
7
|
+
* @intro
|
|
8
|
+
* Expand <a href="https://www.rfc-editor.org/rfc/rfc6570">RFC 6570</a> URI
|
|
9
|
+
* Templates — the <code>{var}</code> syntax that OpenAPI links, HAL
|
|
10
|
+
* <code>_links</code>, and hypermedia API clients use to turn a template
|
|
11
|
+
* plus a set of variables into a concrete URI. The full Level 4 grammar
|
|
12
|
+
* is supported: every operator (<code>{+var}</code> reserved,
|
|
13
|
+
* <code>{#var}</code> fragment, <code>{.var}</code> label,
|
|
14
|
+
* <code>{/var}</code> path, <code>{;var}</code> path-style parameters,
|
|
15
|
+
* <code>{?var}</code> query, <code>{&var}</code> query continuation),
|
|
16
|
+
* the <code>{var:3}</code> prefix modifier, and the <code>{var*}</code>
|
|
17
|
+
* explode modifier for lists and associative arrays.
|
|
18
|
+
*
|
|
19
|
+
* <code>expand(template, vars)</code> returns the expanded string;
|
|
20
|
+
* <code>compile(template)</code> parses once and returns a reusable
|
|
21
|
+
* <code>{ expand }</code> for templates applied to many variable sets. A
|
|
22
|
+
* malformed template (an unclosed expression, an unknown operator, or a
|
|
23
|
+
* non-numeric prefix) throws <code>UriTemplateError</code>.
|
|
24
|
+
*
|
|
25
|
+
* @card
|
|
26
|
+
* RFC 6570 URI Template expansion (full Level 4 — every operator, the
|
|
27
|
+
* <code>:N</code> prefix and <code>*</code> explode modifiers) — the
|
|
28
|
+
* <code>{var}</code> syntax behind OpenAPI links and HAL hypermedia.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
var { defineClass } = require("./framework-error");
|
|
32
|
+
|
|
33
|
+
var UriTemplateError = defineClass("UriTemplateError", { alwaysPermanent: true });
|
|
34
|
+
|
|
35
|
+
var MAX_PREFIX = 10000; // allow:raw-byte-literal — RFC 6570 caps prefix length at 9999
|
|
36
|
+
|
|
37
|
+
// Operator table (RFC 6570 §2.2 / §3.2.1). first = prefix when any value is
|
|
38
|
+
// present; sep = separator between values; named = emit "name=value";
|
|
39
|
+
// ifemp = string used when a named value is empty; reserved = allow the
|
|
40
|
+
// reserved set through unencoded.
|
|
41
|
+
var OPERATORS = {
|
|
42
|
+
"": { first: "", sep: ",", named: false, ifemp: "", reserved: false },
|
|
43
|
+
"+": { first: "", sep: ",", named: false, ifemp: "", reserved: true },
|
|
44
|
+
"#": { first: "#", sep: ",", named: false, ifemp: "", reserved: true },
|
|
45
|
+
".": { first: ".", sep: ".", named: false, ifemp: "", reserved: false },
|
|
46
|
+
"/": { first: "/", sep: "/", named: false, ifemp: "", reserved: false },
|
|
47
|
+
";": { first: ";", sep: ";", named: true, ifemp: "", reserved: false },
|
|
48
|
+
"?": { first: "?", sep: "&", named: true, ifemp: "=", reserved: false },
|
|
49
|
+
"&": { first: "&", sep: "&", named: true, ifemp: "=", reserved: false },
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
var UNRESERVED = /[A-Za-z0-9\-._~]/;
|
|
53
|
+
// Reserved = gen-delims + sub-delims (RFC 3986 §2.2).
|
|
54
|
+
var RESERVED = /[:/?#[\]@!$&'()*+,;=]/;
|
|
55
|
+
|
|
56
|
+
function _pctEncode(str, allowReserved) {
|
|
57
|
+
var out = "";
|
|
58
|
+
for (var i = 0; i < str.length; i++) {
|
|
59
|
+
var ch = str.charAt(i);
|
|
60
|
+
// Preserve existing percent-encoded triplets when the reserved set is
|
|
61
|
+
// allowed (operators "+" and "#").
|
|
62
|
+
if (allowReserved && ch === "%" && /^[0-9A-Fa-f]{2}$/.test(str.substr(i + 1, 2))) {
|
|
63
|
+
out += str.substr(i, 3); i += 2; continue;
|
|
64
|
+
}
|
|
65
|
+
if (UNRESERVED.test(ch) || (allowReserved && RESERVED.test(ch))) { out += ch; continue; }
|
|
66
|
+
// Percent-encode the character's raw UTF-8 bytes (handles surrogate
|
|
67
|
+
// pairs). encodeURIComponent is not used — it leaves !*'() unencoded,
|
|
68
|
+
// which RFC 6570 unreserved-only expansion must escape.
|
|
69
|
+
var cp = str.codePointAt(i);
|
|
70
|
+
var bytes = Buffer.from(String.fromCodePoint(cp), "utf8");
|
|
71
|
+
for (var b = 0; b < bytes.length; b++) out += "%" + bytes[b].toString(16).toUpperCase().padStart(2, "0"); // allow:raw-byte-literal — hex radix
|
|
72
|
+
if (cp > 0xFFFF) i++; // consumed a surrogate pair // allow:raw-byte-literal — BMP boundary for surrogate-pair detection
|
|
73
|
+
}
|
|
74
|
+
return out;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function _allDigits(s) {
|
|
78
|
+
if (s.length === 0) return false;
|
|
79
|
+
for (var i = 0; i < s.length; i++) { var c = s.charCodeAt(i); if (c < 48 || c > 57) return false; } // allow:raw-byte-literal — ASCII '0'..'9' code-point bounds
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// A composite member/value is "defined" unless it is undefined or null
|
|
84
|
+
// (an empty string, 0, or false is defined and expands).
|
|
85
|
+
function _memberDefined(v) { return v !== undefined && v !== null; }
|
|
86
|
+
|
|
87
|
+
function _isDefined(v) {
|
|
88
|
+
if (v === undefined || v === null) return false;
|
|
89
|
+
if (Array.isArray(v)) return v.length > 0;
|
|
90
|
+
if (typeof v === "object") return Object.keys(v).length > 0;
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
function _toStr(v) {
|
|
94
|
+
if (typeof v === "string") return v;
|
|
95
|
+
if (typeof v === "number" || typeof v === "boolean") return String(v);
|
|
96
|
+
return String(v);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// A literal run may not contain a stray "}" (an unmatched expression close)
|
|
100
|
+
// — RFC 6570 literals exclude "{" and "}".
|
|
101
|
+
function _checkLiteral(lit) {
|
|
102
|
+
if (lit.indexOf("}") !== -1) throw new UriTemplateError("uri-template/unmatched-brace", "uriTemplate: unmatched '}' in template literal");
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Parse a template into an array of literal strings + expression objects.
|
|
106
|
+
function _parse(template) {
|
|
107
|
+
if (typeof template !== "string") throw new UriTemplateError("uri-template/bad-template", "uriTemplate: template must be a string");
|
|
108
|
+
var parts = [];
|
|
109
|
+
var i = 0;
|
|
110
|
+
while (i < template.length) {
|
|
111
|
+
var open = template.indexOf("{", i);
|
|
112
|
+
if (open === -1) { _checkLiteral(template.slice(i)); parts.push({ literal: template.slice(i) }); break; }
|
|
113
|
+
if (open > i) { _checkLiteral(template.slice(i, open)); parts.push({ literal: template.slice(i, open) }); }
|
|
114
|
+
var close = template.indexOf("}", open);
|
|
115
|
+
if (close === -1) throw new UriTemplateError("uri-template/unclosed", "uriTemplate: unclosed expression at index " + open);
|
|
116
|
+
parts.push(_parseExpr(template.slice(open + 1, close)));
|
|
117
|
+
i = close + 1;
|
|
118
|
+
}
|
|
119
|
+
return parts;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function _parseExpr(body) {
|
|
123
|
+
if (body.length === 0) throw new UriTemplateError("uri-template/empty-expression", "uriTemplate: empty expression {}");
|
|
124
|
+
var op = "";
|
|
125
|
+
var c0 = body.charAt(0);
|
|
126
|
+
if ("+#./;?&".indexOf(c0) !== -1) { op = c0; body = body.slice(1); }
|
|
127
|
+
else if ("=,!@|".indexOf(c0) !== -1) {
|
|
128
|
+
// Operators reserved by RFC 6570 §2.2 for future extensions → error.
|
|
129
|
+
throw new UriTemplateError("uri-template/reserved-operator", "uriTemplate: operator '" + c0 + "' is reserved");
|
|
130
|
+
}
|
|
131
|
+
var specs = body.split(",").map(function (raw) {
|
|
132
|
+
if (raw.length === 0) throw new UriTemplateError("uri-template/bad-varspec", "uriTemplate: empty variable name");
|
|
133
|
+
var explode = false, prefix = null;
|
|
134
|
+
var name = raw;
|
|
135
|
+
if (raw.charAt(raw.length - 1) === "*") { explode = true; name = raw.slice(0, -1); }
|
|
136
|
+
else {
|
|
137
|
+
var colon = raw.indexOf(":");
|
|
138
|
+
if (colon !== -1) {
|
|
139
|
+
name = raw.slice(0, colon);
|
|
140
|
+
var n = raw.slice(colon + 1);
|
|
141
|
+
if (!_allDigits(n)) throw new UriTemplateError("uri-template/bad-prefix", "uriTemplate: prefix length must be a non-negative integer");
|
|
142
|
+
prefix = parseInt(n, 10);
|
|
143
|
+
if (prefix >= MAX_PREFIX) throw new UriTemplateError("uri-template/bad-prefix", "uriTemplate: prefix length exceeds 9999");
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (!/^(?:[A-Za-z0-9_]|%[0-9A-Fa-f]{2})(?:\.?(?:[A-Za-z0-9_]|%[0-9A-Fa-f]{2}))*$/.test(name)) {
|
|
147
|
+
throw new UriTemplateError("uri-template/bad-varname", "uriTemplate: invalid variable name '" + name + "'");
|
|
148
|
+
}
|
|
149
|
+
return { name: name, explode: explode, prefix: prefix };
|
|
150
|
+
});
|
|
151
|
+
return { op: op, specs: specs };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function _expandExpr(expr, vars) {
|
|
155
|
+
var o = OPERATORS[expr.op];
|
|
156
|
+
var pieces = [];
|
|
157
|
+
expr.specs.forEach(function (spec) {
|
|
158
|
+
var value = vars[spec.name];
|
|
159
|
+
if (!_isDefined(value)) return;
|
|
160
|
+
|
|
161
|
+
if (typeof value !== "object") {
|
|
162
|
+
// Simple string/number/boolean value.
|
|
163
|
+
var s = _toStr(value);
|
|
164
|
+
if (spec.prefix !== null) s = _sliceChars(s, spec.prefix);
|
|
165
|
+
pieces.push(_named(o, spec.name, _pctEncode(s, o.reserved), s.length === 0));
|
|
166
|
+
} else if (Array.isArray(value)) {
|
|
167
|
+
if (spec.prefix !== null) throw new UriTemplateError("uri-template/prefix-on-list", "uriTemplate: prefix modifier cannot apply to a list");
|
|
168
|
+
// Undefined / null members are ignored (RFC 6570 §3.2.1); a list with
|
|
169
|
+
// no defined members is treated as undefined and omitted entirely.
|
|
170
|
+
var members = value.filter(_memberDefined);
|
|
171
|
+
if (members.length === 0) return;
|
|
172
|
+
if (!spec.explode) {
|
|
173
|
+
var joined = members.map(function (m) { return _pctEncode(_toStr(m), o.reserved); }).join(",");
|
|
174
|
+
pieces.push(_named(o, spec.name, joined, false));
|
|
175
|
+
} else {
|
|
176
|
+
members.forEach(function (m) {
|
|
177
|
+
pieces.push(_named(o, spec.name, _pctEncode(_toStr(m), o.reserved), _toStr(m).length === 0));
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
} else {
|
|
181
|
+
// Associative array (object). Pairs whose value is undefined / null
|
|
182
|
+
// are omitted (RFC 6570 §3.2.1).
|
|
183
|
+
if (spec.prefix !== null) throw new UriTemplateError("uri-template/prefix-on-map", "uriTemplate: prefix modifier cannot apply to a map");
|
|
184
|
+
var keys = Object.keys(value).filter(function (k) { return _memberDefined(value[k]); });
|
|
185
|
+
if (keys.length === 0) return;
|
|
186
|
+
if (!spec.explode) {
|
|
187
|
+
var pairs = [];
|
|
188
|
+
keys.forEach(function (k) { pairs.push(_pctEncode(k, o.reserved)); pairs.push(_pctEncode(_toStr(value[k]), o.reserved)); });
|
|
189
|
+
pieces.push(_named(o, spec.name, pairs.join(","), false));
|
|
190
|
+
} else {
|
|
191
|
+
keys.forEach(function (k) {
|
|
192
|
+
// Exploded map: the key becomes the name.
|
|
193
|
+
pieces.push(_namedPair(o, _pctEncode(k, o.reserved), _pctEncode(_toStr(value[k]), o.reserved)));
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
if (pieces.length === 0) return "";
|
|
199
|
+
return o.first + pieces.join(o.sep);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Build one "name=value" (or bare value) piece for a non-exploded or
|
|
203
|
+
// string varspec.
|
|
204
|
+
function _named(o, name, encodedValue, isEmpty) {
|
|
205
|
+
if (!o.named) return encodedValue;
|
|
206
|
+
if (isEmpty) return name + o.ifemp;
|
|
207
|
+
return name + "=" + encodedValue;
|
|
208
|
+
}
|
|
209
|
+
// Exploded map pair: key is already the name.
|
|
210
|
+
function _namedPair(o, encodedKey, encodedValue) {
|
|
211
|
+
if (!o.named) return encodedKey + "=" + encodedValue;
|
|
212
|
+
if (encodedValue.length === 0) return encodedKey + o.ifemp;
|
|
213
|
+
return encodedKey + "=" + encodedValue;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Truncate to N Unicode code points (RFC 6570 prefix length is in chars).
|
|
217
|
+
function _sliceChars(s, n) {
|
|
218
|
+
var out = "", count = 0;
|
|
219
|
+
for (var i = 0; i < s.length && count < n; i++) {
|
|
220
|
+
var cp = s.codePointAt(i);
|
|
221
|
+
out += String.fromCodePoint(cp);
|
|
222
|
+
if (cp > 0xFFFF) i++; // allow:raw-byte-literal — BMP boundary for surrogate pairs
|
|
223
|
+
count++;
|
|
224
|
+
}
|
|
225
|
+
return out;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* @primitive b.uriTemplate.compile
|
|
230
|
+
* @signature b.uriTemplate.compile(template)
|
|
231
|
+
* @since 0.12.66
|
|
232
|
+
* @status stable
|
|
233
|
+
* @related b.uriTemplate.expand, b.hal, b.linkHeader
|
|
234
|
+
*
|
|
235
|
+
* Parse an RFC 6570 URI Template once and return a reusable
|
|
236
|
+
* <code>{ expand(vars) }</code>, so a template applied to many variable
|
|
237
|
+
* sets is parsed a single time. Throws <code>UriTemplateError</code> if the
|
|
238
|
+
* template is malformed.
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* var t = b.uriTemplate.compile("/users/{id}{?fields*}");
|
|
242
|
+
* t.expand({ id: 7, fields: ["name", "email"] });
|
|
243
|
+
* // → "/users/7?fields=name&fields=email"
|
|
244
|
+
*/
|
|
245
|
+
function compile(template) {
|
|
246
|
+
var parts = _parse(template);
|
|
247
|
+
return {
|
|
248
|
+
expand: function (vars) {
|
|
249
|
+
vars = vars || {};
|
|
250
|
+
var out = "";
|
|
251
|
+
for (var i = 0; i < parts.length; i++) {
|
|
252
|
+
out += Object.prototype.hasOwnProperty.call(parts[i], "literal") ? parts[i].literal : _expandExpr(parts[i], vars);
|
|
253
|
+
}
|
|
254
|
+
return out;
|
|
255
|
+
},
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* @primitive b.uriTemplate.expand
|
|
261
|
+
* @signature b.uriTemplate.expand(template, vars)
|
|
262
|
+
* @since 0.12.66
|
|
263
|
+
* @status stable
|
|
264
|
+
* @related b.uriTemplate.compile
|
|
265
|
+
*
|
|
266
|
+
* Expand an RFC 6570 URI Template against a set of variables and return the
|
|
267
|
+
* resulting URI string. Variable values may be strings, numbers, booleans,
|
|
268
|
+
* arrays (lists), or plain objects (associative arrays); an undefined,
|
|
269
|
+
* null, or empty list/map variable is omitted. Reserved-set encoding,
|
|
270
|
+
* <code>:N</code> prefixes, and <code>*</code> explosion follow RFC 6570
|
|
271
|
+
* §3.2. Throws <code>UriTemplateError</code> on a malformed template.
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* b.uriTemplate.expand("{/path}/here{?q,limit}",
|
|
275
|
+
* { path: "search", q: "json schema", limit: 10 });
|
|
276
|
+
* // → "/search/here?q=json%20schema&limit=10"
|
|
277
|
+
*/
|
|
278
|
+
function expand(template, vars) {
|
|
279
|
+
return compile(template).expand(vars);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
module.exports = {
|
|
283
|
+
expand: expand,
|
|
284
|
+
compile: compile,
|
|
285
|
+
UriTemplateError: UriTemplateError,
|
|
286
|
+
};
|
package/package.json
CHANGED
package/sbom.cdx.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:4e9da547-078d-46ac-833b-3eae7e281a06",
|
|
6
6
|
"version": 1,
|
|
7
7
|
"metadata": {
|
|
8
|
-
"timestamp": "2026-05-
|
|
8
|
+
"timestamp": "2026-05-26T10:01:10.136Z",
|
|
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.12.
|
|
22
|
+
"bom-ref": "@blamejs/core@0.12.66",
|
|
23
23
|
"type": "application",
|
|
24
24
|
"name": "blamejs",
|
|
25
|
-
"version": "0.12.
|
|
25
|
+
"version": "0.12.66",
|
|
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.12.
|
|
29
|
+
"purl": "pkg:npm/%40blamejs/core@0.12.66",
|
|
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.12.
|
|
57
|
+
"ref": "@blamejs/core@0.12.66",
|
|
58
58
|
"dependsOn": []
|
|
59
59
|
}
|
|
60
60
|
]
|