@blamejs/pki 0.1.31 → 0.2.0
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 +33 -0
- package/README.md +2 -1
- package/index.js +7 -0
- package/lib/asn1-der.js +31 -22
- package/lib/constants.js +29 -0
- package/lib/ct.js +13 -12
- package/lib/est.js +10 -10
- package/lib/framework-error.js +11 -0
- package/lib/guard-all.js +15 -0
- package/lib/guard-crypto.js +31 -1
- package/lib/guard-encoding.js +90 -0
- package/lib/guard-identifier.js +56 -0
- package/lib/guard-json.js +149 -0
- package/lib/guard-limits.js +58 -8
- package/lib/guard-name.js +61 -3
- package/lib/guard-range.js +40 -7
- package/lib/guard-text.js +7 -0
- package/lib/jose.js +17 -128
- package/lib/merkle.js +7 -16
- package/lib/oid.js +22 -9
- package/lib/path-validate.js +461 -56
- package/lib/schema-attrcert.js +5 -0
- package/lib/schema-cms.js +22 -1
- package/lib/schema-crmf.js +3 -5
- package/lib/schema-ocsp.js +5 -1
- package/lib/schema-pkix.js +92 -12
- package/lib/trust.js +707 -0
- package/lib/webcrypto.js +18 -7
- package/package.json +2 -2
- package/sbom.cdx.json +6 -6
package/lib/oid.js
CHANGED
|
@@ -39,6 +39,10 @@ var guard = require("./guard-all");
|
|
|
39
39
|
|
|
40
40
|
var OidError = frameworkError.OidError;
|
|
41
41
|
|
|
42
|
+
// (code, message) -> OidError, the factory shape the composed guards throw
|
|
43
|
+
// through so a malformed identifier keeps the oid/* typed verdict.
|
|
44
|
+
function _oidError(c, m) { return new OidError(c, m); }
|
|
45
|
+
|
|
42
46
|
// FAMILIES -- OIDs grouped by their shared base arc (the "similar starting
|
|
43
47
|
// variable" that defines a class). A member is `name: leaf`, where leaf is a
|
|
44
48
|
// trailing arc (number) or a short arc array for a multi-level leaf; the full
|
|
@@ -302,11 +306,18 @@ Object.keys(FAMILIES).forEach(function (fam) {
|
|
|
302
306
|
});
|
|
303
307
|
|
|
304
308
|
function _assertDotted(dotted, who) {
|
|
305
|
-
//
|
|
306
|
-
//
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
309
|
+
// SYNTAX only (canonical dotted form, no leading-zero arc that would round-trip
|
|
310
|
+
// to a DIFFERENT OID). For the LOOKUP entry points (name / has): a well-formed
|
|
311
|
+
// but non-encodable OID is simply not registered (a miss), not an error, so the
|
|
312
|
+
// X.660 arc bounds are waived (boundsCode null).
|
|
313
|
+
guard.identifier.assertCanonicalOid(dotted, _oidError, "oid/bad-input", who, null);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function _assertEncodable(dotted, who) {
|
|
317
|
+
// SYNTAX and the X.660 arc bounds -- for the paths that assert / convert a real
|
|
318
|
+
// encodable OID (toArcs / toDER / register), where an out-of-bounds arc is a
|
|
319
|
+
// hard reject (oid/bad-arc), so the string form agrees with the DER form.
|
|
320
|
+
guard.identifier.assertCanonicalOid(dotted, _oidError, "oid/bad-input", who, "oid/bad-arc");
|
|
310
321
|
}
|
|
311
322
|
|
|
312
323
|
// X.660 encodability: the root arc is 0..2 and, under roots 0 and 1, the
|
|
@@ -370,9 +381,11 @@ function has(dotted) {
|
|
|
370
381
|
* pki.oid.register("1.3.6.1.4.1.99999.1", "acmeWidgetPolicy");
|
|
371
382
|
*/
|
|
372
383
|
function register(dotted, n) {
|
|
373
|
-
_assertDotted
|
|
384
|
+
// _assertDotted now enforces the X.660 arc bounds on the string form too, so
|
|
385
|
+
// the separate arc-based check register used to run is redundant here (it is
|
|
386
|
+
// kept for registerFamily, which validates arcs it assembles, not a string).
|
|
387
|
+
_assertEncodable(dotted, "register");
|
|
374
388
|
if (typeof n !== "string" || n.length === 0) throw new OidError("oid/bad-input", "register: name must be a non-empty string");
|
|
375
|
-
_assertEncodableArcs(dotted.split(".").map(BigInt), "register");
|
|
376
389
|
_index(dotted, n);
|
|
377
390
|
}
|
|
378
391
|
|
|
@@ -432,7 +445,7 @@ function all() {
|
|
|
432
445
|
// Number where safe and BigInt where an arc exceeds 2^53 (rare, but a
|
|
433
446
|
// UUID-based OID arc can), so the round-trip never loses precision.
|
|
434
447
|
function toArcs(dotted) {
|
|
435
|
-
|
|
448
|
+
_assertEncodable(dotted, "toArcs");
|
|
436
449
|
return dotted.split(".").map(function (p) {
|
|
437
450
|
var b = BigInt(p);
|
|
438
451
|
return b <= 9007199254740991n ? Number(b) : b;
|
|
@@ -453,7 +466,7 @@ function fromArcs(arcs) {
|
|
|
453
466
|
|
|
454
467
|
// DER convenience -- thin pass-throughs to the codec so callers reach for
|
|
455
468
|
// one namespace when they have a dotted string in hand.
|
|
456
|
-
function toDER(dotted) {
|
|
469
|
+
function toDER(dotted) { _assertEncodable(dotted, "toDER"); return asn1.build.oid(dotted); }
|
|
457
470
|
function fromDER(input) {
|
|
458
471
|
var buf = guard.bytes.view(input, OidError, "oid/bad-input", "fromDER");
|
|
459
472
|
var node = asn1.decode(buf);
|