@blamejs/pki 0.5.22 → 0.5.24

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.
@@ -33,6 +33,11 @@ var attrcert = require("./schema-attrcert");
33
33
  var x509 = require("./schema-x509");
34
34
  var signScheme = require("./sign-scheme");
35
35
  var guard = require("./guard-all");
36
+ var intrinsic = require("./guard-intrinsic");
37
+ // Membership is asked through an operation taken at load. Written out, the question reads two
38
+ // replaceable properties to answer one thing, and either answering true admits a name the table
39
+ // never carried -- here, an unrecognized critical extension counted as one this profile supports.
40
+ var _hasOwn = intrinsic.hasOwn;
36
41
  var pkix = require("./schema-pkix");
37
42
  var schema = require("./schema-engine");
38
43
  require("./path-validate"); // side-effect: path-validate injects its signature engine into attrcert-verify at load
@@ -373,10 +378,10 @@ function _buildAttributes(attrSpec) {
373
378
  // carrying, so BOTH extension forms meet it -- the object form and the pre-encoded array form, which
374
379
  // is the one that can name a pointer at all. `seen` is the OID-keyed set each branch already builds.
375
380
  function _assertRevocationSchemesExclusive(seen) {
376
- if (!Object.prototype.hasOwnProperty.call(seen, O("noRevAvail"))) return;
381
+ if (!_hasOwn(seen, O("noRevAvail"))) return;
377
382
  var names = Object.keys(REVOCATION_POINTERS);
378
383
  for (var i = 0; i < names.length; i++) {
379
- if (Object.prototype.hasOwnProperty.call(seen, names[i])) {
384
+ if (_hasOwn(seen, names[i])) {
380
385
  throw _err("attrcert/bad-input", "an attribute certificate must not carry both noRevAvail and a " +
381
386
  REVOCATION_POINTERS[names[i]] + " revocation pointer (RFC 5755 sec. 6)");
382
387
  }
@@ -762,7 +767,7 @@ function _unsupportedCritical(ac) {
762
767
  if (e.critical !== true) continue;
763
768
  // Own-property membership, so an extension OID that happens to name something on Object.prototype
764
769
  // cannot read as supported.
765
- if (!Object.prototype.hasOwnProperty.call(SUPPORTED_CRITICAL, e.oid)) return e.oid;
770
+ if (!_hasOwn(SUPPORTED_CRITICAL, e.oid)) return e.oid;
766
771
  // A supported OID whose value this build could not interpret is still unusable.
767
772
  if (e.decoded === null || e.decoded === undefined || e.decoded.opaque === true) return e.oid;
768
773
  }
@@ -887,7 +892,7 @@ function _fixVerifyOptions(opts) {
887
892
  var revocationStatus = null;
888
893
  if (o.revocationStatus !== undefined) {
889
894
  if (typeof o.revocationStatus !== "string" ||
890
- !Object.prototype.hasOwnProperty.call(REVOCATION_STATUS, o.revocationStatus)) {
895
+ !_hasOwn(REVOCATION_STATUS, o.revocationStatus)) {
891
896
  throw _err("attrcert/bad-input", 'pki.attrcert.verify opts.revocationStatus must be "notRevoked" or "revoked"');
892
897
  }
893
898
  revocationStatus = o.revocationStatus;
@@ -916,7 +921,7 @@ function _revocationScheme(ac) {
916
921
  var e = ac.extensions[i];
917
922
  if (e.name === "noRevAvail") out.noRevAvail = true;
918
923
  var p = REVOCATION_POINTERS[e.oid];
919
- if (p !== undefined && Object.prototype.hasOwnProperty.call(REVOCATION_POINTERS, e.oid)) out.pointer = p;
924
+ if (p !== undefined && _hasOwn(REVOCATION_POINTERS, e.oid)) out.pointer = p;
920
925
  }
921
926
  return out;
922
927
  }
package/lib/cmc-build.js CHANGED
@@ -33,6 +33,10 @@ var cmcFmt = require("./schema-cmc"); // to read the assembled message back bef
33
33
  var oid = require("./oid");
34
34
  var cmsSign = require("./cms-sign");
35
35
  var guard = require("./guard-all");
36
+ var intrinsic = require("./guard-intrinsic");
37
+ // Own-key membership through an operation taken at load. Written out, the question reads two
38
+ // replaceable properties to answer one thing, and here it decides which controls a request carries.
39
+ var _hasOwn = intrinsic.hasOwn;
36
40
  var frameworkError = require("./framework-error");
37
41
 
38
42
  var CmcError = frameworkError.CmcError;
@@ -710,7 +714,7 @@ function _copySigners(signer, owned) {
710
714
  if (!s || typeof s !== "object") return s;
711
715
  var out = {}, k;
712
716
  for (k in s) {
713
- if (!Object.prototype.hasOwnProperty.call(s, k)) continue;
717
+ if (!_hasOwn(s, k)) continue;
714
718
  out[k] = copyValue(s[k], k === "key");
715
719
  }
716
720
  return out;
@@ -725,7 +729,7 @@ function _copySigners(signer, owned) {
725
729
  if (!v || typeof v !== "object" || typeof v.type === "string") return v; // CryptoKey / scalar
726
730
  var c = {}, ck;
727
731
  for (ck in v) {
728
- if (!Object.prototype.hasOwnProperty.call(v, ck)) continue;
732
+ if (!_hasOwn(v, ck)) continue;
729
733
  var cv = v[ck];
730
734
  c[ck] = (Buffer.isBuffer(cv) || cv instanceof Uint8Array) ? _own(Buffer.from(cv), isSecret) : cv;
731
735
  }
package/lib/cmc-verify.js CHANGED
@@ -25,6 +25,10 @@ var cmc = require("./schema-cmc");
25
25
  var cmsVerify = require("./cms-verify"); // PD14: the carrier's signature MUST be verified
26
26
  var cmsDecrypt = require("./cms-decrypt"); // ... and an AuthenticatedData carrier by its MAC
27
27
  var guard = require("./guard-all");
28
+ var intrinsic = require("./guard-intrinsic");
29
+ // Own-key membership through an operation taken at load. Written out, the question reads two
30
+ // replaceable properties to answer one thing, and here it decides which controls a response carries.
31
+ var _hasOwn = intrinsic.hasOwn;
28
32
  var frameworkError = require("./framework-error");
29
33
 
30
34
  var CmcError = frameworkError.CmcError;
@@ -428,7 +432,7 @@ function _copyAnyBytes(v) {
428
432
 
429
433
  function _snapshotSent(sent) {
430
434
  var out = {}, k;
431
- for (k in sent) { if (Object.prototype.hasOwnProperty.call(sent, k)) out[k] = sent[k]; }
435
+ for (k in sent) { if (_hasOwn(sent, k)) out[k] = sent[k]; }
432
436
  // Normalized through the SAME authoring guard pki.cmc.build puts an authored
433
437
  // integer through. A Transaction Identifier is an unbounded INTEGER on the wire,
434
438
  // so one above Number.MAX_SAFE_INTEGER has already been rounded by the time it
@@ -458,7 +462,7 @@ function _snapshotSent(sent) {
458
462
  if (out.recipient && typeof out.recipient === "object") {
459
463
  var r = {}, rk;
460
464
  for (rk in out.recipient) {
461
- if (!Object.prototype.hasOwnProperty.call(out.recipient, rk)) continue;
465
+ if (!_hasOwn(out.recipient, rk)) continue;
462
466
  r[rk] = _copyAnyBytes(out.recipient[rk]);
463
467
  }
464
468
  out.recipient = r;
package/lib/cmp-verify.js CHANGED
@@ -339,14 +339,9 @@ function _rfc822Equal(a, b) {
339
339
  // SIGN lowercases to "k", so a host carrying it would compare EQUAL to the ASCII spelling
340
340
  // and two distinct domains would read as one identity. Fold only A-Z and leave every other
341
341
  // octet alone, so a non-ASCII host can differ from an ASCII one but never collide with it.
342
- function _lowerAsciiDomain(h) {
343
- var out = "";
344
- for (var i = 0; i < h.length; i++) {
345
- var c = _charCodeAt(h, i);
346
- out += (c >= 0x41 && c <= 0x5a) ? _fromCharCode(c + 32) : _charAt(h, i);
347
- }
348
- return out;
349
- }
342
+ // Through the toolkit's one definition of that fold, so no two name comparisons can disagree
343
+ // about which characters case-fold.
344
+ var _lowerAsciiDomain = guard.name.lowerAscii;
350
345
 
351
346
  // RFC 5280 sec. 4.2.1.6 / RFC 3986 sec. 6.2.2.1 URI comparison: the scheme and the authority host are
352
347
  // case-insensitive; every other component (userinfo, port, path, query, fragment) is byte-exact. Return
@@ -935,9 +930,9 @@ function _fixTime(v) {
935
930
  }
936
931
  function _fixVerifyOptions(opts, made) {
937
932
  if (opts == null) opts = {}; // ONLY null / undefined -> the default empty opts (a falsy false/0/"" is a bad config, not a default)
938
- // Through the toolkit's own options door, which this verb used to skip in favor of its own two
939
- // checks. The door does the thing those could not: it REFUSES an options bag whose fields are
940
- // accessors, and refuses one that changes which fields it carries while they are read.
933
+ // Through the toolkit's own options door rather than a pair of local field checks. The door
934
+ // REFUSES an options bag whose fields are accessors, and refuses one that changes which fields it
935
+ // carries while they are read; a local check on each field it needs can do neither.
941
936
  //
942
937
  // That is what closes this whole class rather than one member of it. An accessor is caller code
943
938
  // running inside the call, before the verb has done anything, and from there it can rewrite the
package/lib/cms-verify.js CHANGED
@@ -829,7 +829,7 @@ function _cloneAnchorValue(v, depth) {
829
829
  if (Array.isArray(v)) return v.map(function (e) { return _cloneAnchorValue(e, depth + 1); });
830
830
  var out = {}, k;
831
831
  for (k in v) {
832
- if (!Object.prototype.hasOwnProperty.call(v, k)) continue;
832
+ if (!intrinsic.hasOwn(v, k)) continue;
833
833
  out[k] = _cloneAnchorValue(v[k], depth + 1);
834
834
  }
835
835
  return out;
package/lib/crl-sign.js CHANGED
@@ -29,6 +29,11 @@ var crlSchema = require("./schema-crl");
29
29
  var x509Schema = require("./schema-x509");
30
30
  var signScheme = require("./sign-scheme");
31
31
  var guard = require("./guard-all");
32
+ var intrinsic = require("./guard-intrinsic");
33
+ // Membership is asked through an operation taken at load. Written out, the question reads two
34
+ // replaceable properties to answer one thing, and either of them answering true admits a name the
35
+ // table never carried -- here, a reason code the CRL profile does not define.
36
+ var _hasOwn = intrinsic.hasOwn;
32
37
  var frameworkError = require("./framework-error");
33
38
  var pkix = require("./schema-pkix");
34
39
  var schema = require("./schema-engine");
@@ -164,10 +169,10 @@ function _resolveReason(reason, isDelta) {
164
169
  var codeNum;
165
170
  if (typeof reason === "number") codeNum = reason;
166
171
  else if (typeof reason === "string") {
167
- if (!Object.prototype.hasOwnProperty.call(REASON_BY_NAME, reason)) throw _err("crl/bad-reason-code", "unknown CRLReason " + JSON.stringify(reason));
172
+ if (!_hasOwn(REASON_BY_NAME, reason)) throw _err("crl/bad-reason-code", "unknown CRLReason " + JSON.stringify(reason));
168
173
  codeNum = REASON_BY_NAME[reason];
169
174
  } else throw _err("crl/bad-reason-code", "reason must be a CRLReason name or number");
170
- if (!Object.prototype.hasOwnProperty.call(CRL_REASON, String(codeNum))) throw _err("crl/bad-reason-code", "undefined or reserved CRLReason " + codeNum + " (RFC 5280 sec. 5.3.1)");
175
+ if (!_hasOwn(CRL_REASON, String(codeNum))) throw _err("crl/bad-reason-code", "undefined or reserved CRLReason " + codeNum + " (RFC 5280 sec. 5.3.1)");
171
176
  if (codeNum === 8 && !isDelta) throw _err("crl/bad-reason-code", "removeFromCRL(8) may appear only in a delta CRL (RFC 5280 sec. 5.3.1)");
172
177
  return codeNum;
173
178
  }
@@ -284,7 +289,7 @@ function _buildCrlExtensions(spec, ctx) {
284
289
  // fixed criticality (assertValidExtension rejects an explicit critical=FALSE, so 3 children == critical,
285
290
  // 2 == non-critical) AND a well-formed value of the right type (INTEGER for cRLNumber/deltaCRLIndicator,
286
291
  // else a SEQUENCE), never emitted opaque.
287
- if (Object.prototype.hasOwnProperty.call(REQUIRED_CRITICALITY, extnId)) {
292
+ if (_hasOwn(REQUIRED_CRITICALITY, extnId)) {
288
293
  if ((node.children.length === 3) !== REQUIRED_CRITICALITY[extnId]) {
289
294
  throw _err("crl/bad-input", "pre-encoded " + (oid.name(extnId) || extnId) + " extension has the wrong criticality (RFC 5280 sec. 5.2 requires it " + (REQUIRED_CRITICALITY[extnId] ? "critical" : "non-critical") + ")");
290
295
  }
@@ -387,13 +392,13 @@ function _buildRevoked(entryList, isDelta) {
387
392
  // RFC 5280 sec. 5.3 -- a recognized entry extension is held to the profile even via the escape hatch:
388
393
  // its fixed criticality AND a well-formed value of the right type (reasonCode an ENUMERATED in the
389
394
  // legal set, invalidityDate a GeneralizedTime).
390
- if (Object.prototype.hasOwnProperty.call(REQUIRED_ENTRY_CRITICALITY, extnId)) {
395
+ if (_hasOwn(REQUIRED_ENTRY_CRITICALITY, extnId)) {
391
396
  if ((xnode.children.length === 3) !== REQUIRED_ENTRY_CRITICALITY[extnId]) throw _err("crl/bad-input", "pre-encoded entry extension " + (oid.name(extnId) || extnId) + " has the wrong criticality (RFC 5280 sec. 5.3 requires it " + (REQUIRED_ENTRY_CRITICALITY[extnId] ? "critical" : "non-critical") + ")");
392
397
  var einner = _extInner(xnode, oid.name(extnId) || extnId);
393
398
  if (extnId === O("reasonCode")) {
394
399
  if (einner.tagClass !== "universal" || einner.tagNumber !== TAGS.ENUMERATED) throw _err("crl/bad-reason-code", "pre-encoded reasonCode value must be an ENUMERATED (RFC 5280 sec. 5.3.1)");
395
400
  var rc = asn1.read.enumerated(einner);
396
- if (!Object.prototype.hasOwnProperty.call(CRL_REASON, rc.toString())) throw _err("crl/bad-reason-code", "pre-encoded reasonCode " + rc + " is undefined or reserved (RFC 5280 sec. 5.3.1)");
401
+ if (!_hasOwn(CRL_REASON, rc.toString())) throw _err("crl/bad-reason-code", "pre-encoded reasonCode " + rc + " is undefined or reserved (RFC 5280 sec. 5.3.1)");
397
402
  if (rc === 8n && !isDelta) throw _err("crl/bad-reason-code", "removeFromCRL(8) may appear only in a delta CRL (RFC 5280 sec. 5.3.1)");
398
403
  } else if (extnId === O("invalidityDate")) {
399
404
  if (einner.tagClass !== "universal" || einner.tagNumber !== TAGS.GENERALIZED_TIME) throw _err("crl/bad-input", "pre-encoded invalidityDate value must be a GeneralizedTime (RFC 5280 sec. 5.3.2)");
package/lib/ct.js CHANGED
@@ -44,6 +44,11 @@ var asn1 = require("./asn1-der.js");
44
44
  var constants = require("./constants.js");
45
45
  var frameworkError = require("./framework-error.js");
46
46
  var guard = require("./guard-all.js");
47
+ var intrinsic = require("./guard-intrinsic.js");
48
+ // Own-key membership through an operation taken at load. Written out, the question reads two
49
+ // replaceable properties to answer one thing, and here it decides whether a log state is one this
50
+ // toolkit trusts -- answering true for a name the table never carried trusts an untrusted log.
51
+ var _hasOwn = intrinsic.hasOwn;
47
52
  var ByteReader = require("./byte-reader.js");
48
53
  var ByteWriter = require("./byte-writer.js");
49
54
  var oid = require("./oid.js");
@@ -650,7 +655,7 @@ var LOG_STATE_TRUST = { pending: "no", qualified: "yes", usable: "yes", readonly
650
655
  function _parseLogState(state) {
651
656
  if (state == null || typeof state !== "object") throw _ctErr("ct/bad-state", "a CT log entry is missing its state");
652
657
  var keys = Object.keys(state);
653
- if (keys.length !== 1 || !Object.prototype.hasOwnProperty.call(LOG_STATE_TRUST, keys[0])) {
658
+ if (keys.length !== 1 || !_hasOwn(LOG_STATE_TRUST, keys[0])) {
654
659
  throw _ctErr("ct/bad-state", "a CT log state must carry exactly one recognized member (pending/qualified/usable/readonly/retired/rejected)");
655
660
  }
656
661
  var name = keys[0], member = state[name];
package/lib/est.js CHANGED
@@ -72,6 +72,10 @@ var OID_CMC_DATA_RETURN = oid.byName("id-cmc-dataReturn");
72
72
  var crmfFmt = require("./schema-crmf");
73
73
  var frameworkError = require("./framework-error");
74
74
  var guard = require("./guard-all");
75
+ var intrinsic = require("./guard-intrinsic");
76
+ // Own-key membership through an operation taken at load: written out it reads two replaceable
77
+ // properties to answer one question, and here it decides which fields of a response are copied.
78
+ var _hasOwn = intrinsic.hasOwn;
75
79
  var httpTransport = require("./http-transport");
76
80
  var httpDigest = require("./http-digest");
77
81
  var retryAfter = require("./http-retry-after");
@@ -1592,7 +1596,7 @@ function _assertAgrees(name, supplied, carried) {
1592
1596
  function _copyRecipient(r) {
1593
1597
  if (!r || typeof r !== "object") return r;
1594
1598
  var out = {}, k;
1595
- for (k in r) { if (Object.prototype.hasOwnProperty.call(r, k)) out[k] = _copyBytes(r[k]); }
1599
+ for (k in r) { if (_hasOwn(r, k)) out[k] = _copyBytes(r[k]); }
1596
1600
  return out;
1597
1601
  }
1598
1602
 
@@ -1606,10 +1610,10 @@ function _copyRecipient(r) {
1606
1610
  // transport function, a tls config).
1607
1611
  function _shallowCopy(o) {
1608
1612
  var out = {}, k;
1609
- for (k in o) { if (Object.prototype.hasOwnProperty.call(o, k)) out[k] = o[k]; }
1613
+ for (k in o) { if (_hasOwn(o, k)) out[k] = o[k]; }
1610
1614
  if (out.auth && typeof out.auth === "object") {
1611
1615
  var a = {}, ak;
1612
- for (ak in out.auth) { if (Object.prototype.hasOwnProperty.call(out.auth, ak)) a[ak] = out.auth[ak]; }
1616
+ for (ak in out.auth) { if (_hasOwn(out.auth, ak)) a[ak] = out.auth[ak]; }
1613
1617
  out.auth = a;
1614
1618
  }
1615
1619
  return out;
package/lib/guard-all.js CHANGED
@@ -51,6 +51,7 @@
51
51
  // its guard module, so a new boundary cannot re-inline the shape and forget the
52
52
  // defense.
53
53
 
54
+ var _freeze = require("./guard-intrinsic").freeze;
54
55
  var bytes = require("./guard-bytes");
55
56
  var text = require("./guard-text");
56
57
  var limits = require("./guard-limits");
@@ -74,7 +75,11 @@ var async_ = require("./guard-async");
74
75
  // live reads were never named. With one spelling, a module's own require IS the fact, and the check
75
76
  // reads it off the loaded module graph rather than guessing at the text.
76
77
 
77
- module.exports = {
78
+ // Frozen, like every module it gathers. A boundary reaches its guard as `guard.<family>.<fn>(...)`
79
+ // at the call, and the registry hands every module this same object, so one property assignment
80
+ // would replace a fail-closed check everywhere at once -- which is the substitution the family
81
+ // exists to refuse. Nothing writes to it after load.
82
+ module.exports = _freeze({
78
83
  bytes: bytes,
79
84
  text: text,
80
85
  limits: limits,
@@ -92,4 +97,4 @@ module.exports = {
92
97
  secret: secret,
93
98
  parsed: parsed,
94
99
  async: async_,
95
- };
100
+ });
@@ -46,4 +46,6 @@ function deferred(body) {
46
46
  catch (e) { return _reject(_Promise, e); }
47
47
  }
48
48
 
49
- module.exports = { deferred: deferred };
49
+ // Frozen for the reason the family header gives: a boundary reads its guard off this object at the
50
+ // call, so a writable export would let a caller replace the check rather than pass it.
51
+ module.exports = _intrinsic.freeze({ deferred: deferred });
@@ -1032,8 +1032,10 @@ function fixedCall(ErrorClass, code, args, body) {
1032
1032
  }), function () { if (handle) handle.release(); });
1033
1033
  }
1034
1034
 
1035
- module.exports = {
1035
+ // Frozen for the reason the family header gives: a boundary reads its guard off this object at the
1036
+ // call, so a writable export would let a caller replace the check rather than pass it.
1037
+ module.exports = intrinsic.freeze({
1036
1038
  view: view, source: source, snapshot: snapshot, snapshotSource: snapshotSource,
1037
1039
  isByteSource: isByteSource, lengthOf: lengthOf, outputView: outputView,
1038
1040
  snapshotDeep: snapshotDeep, fixArguments: fixArguments, fixedCall: fixedCall,
1039
- };
1041
+ });
@@ -181,4 +181,6 @@ function bounded(algorithm, stream, cap, E, codes, label) {
181
181
  // and a consumer offering an algorithm this list omits fails closed at `bounded`.
182
182
  function algorithms() { return _objectKeys(SAFE); }
183
183
 
184
- module.exports = { bounded: bounded, algorithms: algorithms };
184
+ // Frozen for the reason the family header gives: a boundary reads its guard off this object at the
185
+ // call, so a writable export would let a caller replace the check rather than pass it.
186
+ module.exports = _intrinsic.freeze({ bounded: bounded, algorithms: algorithms });
@@ -28,6 +28,7 @@
28
28
  // with unusedBits !== 0 fails closed before its bytes reach a verifier.
29
29
 
30
30
  var nodeCrypto = require("node:crypto");
31
+ var _freeze = require("./guard-intrinsic").freeze;
31
32
 
32
33
  // constantTimeEqual(a, b) -> boolean. Length-checked, then constant-time over
33
34
  // equal lengths. a and b are Buffers.
@@ -61,4 +62,6 @@ function assertOctetAligned(bitString, E, code, label) {
61
62
  return bitString;
62
63
  }
63
64
 
64
- module.exports = { constantTimeEqual: constantTimeEqual, isOctetAligned: isOctetAligned, assertOctetAligned: assertOctetAligned };
65
+ // Frozen for the reason the family header gives: a boundary reads its guard off this object at the
66
+ // call, so a writable export would let a caller replace the check rather than pass it.
67
+ module.exports = _freeze({ constantTimeEqual: constantTimeEqual, isOctetAligned: isOctetAligned, assertOctetAligned: assertOctetAligned });
package/lib/guard-der.js CHANGED
@@ -33,6 +33,7 @@
33
33
  // The byte comparison SET-OF ordering is decided by, taken at load. A replacement chooses which
34
34
  // encodings this guard calls correctly ordered. See guard-intrinsic for the whole captured set.
35
35
  var _compare = require("./guard-intrinsic").compare;
36
+ var _freeze = require("./guard-intrinsic").freeze;
36
37
  var _forEach = require("./guard-intrinsic").forEach;
37
38
  // The emptiness gate below decides whether bytes reach the decoder at all, and on a byte view
38
39
  // `length` is a replaceable accessor: one answering non-zero for an empty buffer sends nothing to
@@ -172,4 +173,6 @@ function tlv(content, E, code, label) {
172
173
  return content;
173
174
  }
174
175
 
175
- module.exports = { element: element, tlv: tlv };
176
+ // Frozen for the reason the family header gives: a boundary reads its guard off this object at the
177
+ // call, so a writable export would let a caller replace the check rather than pass it.
178
+ module.exports = _freeze({ element: element, tlv: tlv });
@@ -132,4 +132,6 @@ function hex(text, maxBytes, E, code, label) {
132
132
  return buf;
133
133
  }
134
134
 
135
- module.exports = { base64url: base64url, base64: base64, hex: hex };
135
+ // Frozen for the reason the family header gives: a boundary reads its guard off this object at the
136
+ // call, so a writable export would let a caller replace the check rather than pass it.
137
+ module.exports = _intrinsic.freeze({ base64url: base64url, base64: base64, hex: hex });
@@ -21,6 +21,7 @@ var C = require("./constants");
21
21
  // Taken at load. `byteLength` is what the RFC 5322 line limit is measured with, so a replacement
22
22
  // decides whether an over-long header line is refused. See guard-intrinsic for the whole set.
23
23
  var _byteLength = require("./guard-intrinsic").byteLength;
24
+ var _freeze = require("./guard-intrinsic").freeze;
24
25
  // The character-code read the RFC 5322 ftext and CR/LF/NUL checks are built on. One that never
25
26
  // reports a control byte is a header-injection defense that inspects nothing.
26
27
  var _charCodeAt = require("./guard-intrinsic").uncurry(String.prototype.charCodeAt);
@@ -60,4 +61,6 @@ function assertField(name, value, E, code) {
60
61
  return v;
61
62
  }
62
63
 
63
- module.exports = { assertField: assertField };
64
+ // Frozen for the reason the family header gives: a boundary reads its guard off this object at the
65
+ // call, so a writable export would let a caller replace the check rather than pass it.
66
+ module.exports = _freeze({ assertField: assertField });
@@ -851,7 +851,9 @@ function _settle(opts, E, code, label) {
851
851
  return opts;
852
852
  }
853
853
 
854
- module.exports = {
854
+ // Frozen for the reason the family header gives: a boundary reads its guard off this object at the
855
+ // call, so a writable export would let a caller replace the check rather than pass it.
856
+ module.exports = intrinsic.freeze({
855
857
  assertCanonicalOid: assertCanonicalOid,
856
858
  assertKnownKeys: assertKnownKeys,
857
859
  optionsObject: optionsObject,
@@ -864,4 +866,4 @@ module.exports = {
864
866
  // Exported for the same reason as its sibling: a caller copying an array has to reach the
865
867
  // elements a read reaches, and the own keys are not that set.
866
868
  readableIndices: readableIndices
867
- };
869
+ });
@@ -260,7 +260,12 @@ function sizeOf(value) {
260
260
  (value === null ? "null" : typeof value));
261
261
  }
262
262
 
263
- module.exports = {
263
+ // Frozen, and that is what makes the capture worth taking. A consumer binds these at load, but it
264
+ // also reads several of them as `intrinsic.<name>(...)` at the call itself, and the module registry
265
+ // hands every caller this same object: assigning one property would redirect that call in every
266
+ // module at once, which is the substitution the captures exist to refuse. Freezing costs nothing
267
+ // here because nothing writes to it after load.
268
+ module.exports = Object.freeze({
264
269
  uncurry: uncurry,
265
270
  getter: getter,
266
271
  sizeOf: sizeOf,
@@ -347,4 +352,4 @@ module.exports = {
347
352
  Set: _Set,
348
353
  Map: _Map,
349
354
  WeakMap: _WeakMap,
350
- };
355
+ });
package/lib/guard-json.js CHANGED
@@ -27,6 +27,7 @@ var text = require("./guard-text");
27
27
  // setter, and `fromCharCode` is how an escape becomes the character it names; a replacement for
28
28
  // either decides what this parser produces. See guard-intrinsic for the whole captured set.
29
29
  var _defineProperty = require("./guard-intrinsic").defineProperty;
30
+ var _freeze = require("./guard-intrinsic").freeze;
30
31
  var _fromCharCode = require("./guard-intrinsic").fromCharCode;
31
32
  // The character-code read the whole scanner is built on: whitespace, escapes and the control-byte
32
33
  // reject all consult it, so one that lies decides what this parser sees in the input.
@@ -209,4 +210,6 @@ function parse(input, ErrorClass, spec) {
209
210
  return result;
210
211
  }
211
212
 
212
- module.exports = { parse: parse };
213
+ // Frozen for the reason the family header gives: a boundary reads its guard off this object at the
214
+ // call, so a writable export would let a caller replace the check rather than pass it.
215
+ module.exports = _freeze({ parse: parse });
@@ -27,6 +27,7 @@ var constants = require("./constants");
27
27
  // one returning true admits a NaN or fractional cap, which makes the comparison it guards always
28
28
  // false. See guard-intrinsic for the whole captured set.
29
29
  var _isInteger = require("./guard-intrinsic").isInteger;
30
+ var _freeze = require("./guard-intrinsic").freeze;
30
31
  // And the size measurement, for the same reason one step further in: a cap compares against a
31
32
  // length, and on a byte view `length` is a replaceable accessor. One reporting a small number for a
32
33
  // large buffer leaves every byteCap below always-false, which is the size defense silently dead.
@@ -137,4 +138,6 @@ function byteCap(buf, max, E, code, label) {
137
138
  return buf;
138
139
  }
139
140
 
140
- module.exports = { cap: cap, depthCap: depthCap, counter: counter, byteCap: byteCap };
141
+ // Frozen for the reason the family header gives: a boundary reads its guard off this object at the
142
+ // call, so a writable export would let a caller replace the check rather than pass it.
143
+ module.exports = _freeze({ cap: cap, depthCap: depthCap, counter: counter, byteCap: byteCap });
package/lib/guard-list.js CHANGED
@@ -28,6 +28,8 @@
28
28
  // over `===` has nothing to replace, so it holds whatever the prototype says, in a module that has
29
29
  // been swept and in one that has not.
30
30
 
31
+ var _freeze = require("./guard-intrinsic").freeze;
32
+
31
33
  // contains(list, value) -> boolean. Strict-equality membership, the `indexOf(v) !== -1` rule.
32
34
  // A null / undefined list is honestly empty, never a throw: these run on verdict paths.
33
35
  // @enforced-by behavioral -- `.indexOf(x) !== -1` has no rename-proof form that separates a
@@ -77,9 +79,11 @@ function allMatch(list, predicate) {
77
79
  return true;
78
80
  }
79
81
 
80
- module.exports = {
82
+ // Frozen for the reason the family header gives: a boundary reads its guard off this object at the
83
+ // call, so a writable export would let a caller replace the check rather than pass it.
84
+ module.exports = _freeze({
81
85
  contains: contains,
82
86
  containsAll: containsAll,
83
87
  anyMatches: anyMatches,
84
88
  allMatch: allMatch,
85
- };
89
+ });
package/lib/guard-name.js CHANGED
@@ -273,7 +273,7 @@ function emailEqual(a, b) {
273
273
  var aHost = _strSlice(a, ai + 1), bHost = _strSlice(b, bi + 1);
274
274
  if (!_asciiHost(aHost) || !_asciiHost(bHost)) return "not-comparable";
275
275
  if (aLocal !== bLocal) return "no-match";
276
- return _lowerAscii(aHost) === _lowerAscii(bHost) ? "match" : "no-match";
276
+ return lowerAscii(aHost) === lowerAscii(bHost) ? "match" : "no-match";
277
277
  }
278
278
 
279
279
  // A host-part this comparison can decide: ASCII, and carrying no A-label. Anything else
@@ -292,11 +292,18 @@ function _asciiHost(h) {
292
292
  return true;
293
293
  }
294
294
 
295
+ // lowerAscii(s) -> string
295
296
  // ASCII-only lowercase. String.toLowerCase() is Unicode-aware and would fold characters
296
- // outside ASCII (the Kelvin sign lowercases to "k"), which is precisely the mapping the
297
- // host-part rule does not authorize; _asciiHost has already excluded those inputs, so this
298
- // stays a plain A-Z shift rather than inheriting a locale-sensitive transform.
299
- function _lowerAscii(s) {
297
+ // outside ASCII (the Kelvin sign lowercases to "k"), which is precisely the mapping a
298
+ // name comparison does not authorize: a name folded that way is one the certificate or
299
+ // message does not carry, and comparing it equal to a name that was asked for is the
300
+ // defect. Every case-insensitive name comparison in the toolkit -- a host part, a CMP
301
+ // domain, an ACME identifier set -- folds through this one definition, so none of them can
302
+ // disagree about which characters case-fold.
303
+ //
304
+ // @enforced-by guard-shape-reinlined
305
+ // @guard-shape 0x41\s*&&\s*[A-Za-z_$][\w$]*\s*<=\s*0x5[aA]\s*\)\s*\?[^:]*\+\s*(?:32|0x20)\s*\)
306
+ function lowerAscii(s) {
300
307
  var out = "";
301
308
  for (var i = 0; i < s.length; i++) {
302
309
  var c = _charCodeAt(s, i);
@@ -305,8 +312,11 @@ function _lowerAscii(s) {
305
312
  return out;
306
313
  }
307
314
 
308
- module.exports = {
315
+ // Frozen for the reason the family header gives: a boundary reads its guard off this object at the
316
+ // call, so a writable export would let a caller replace the check rather than pass it.
317
+ module.exports = intrinsic.freeze({
309
318
  assertNoControlBytes: assertNoControlBytes, assertPrintableIa5: assertPrintableIa5,
310
319
  dnEqual: dnEqual, rdnEqual: rdnEqual, emailEqual: emailEqual,
311
320
  escapeControlBytes: escapeControlBytes, escapeDnValue: escapeDnValue,
312
- };
321
+ lowerAscii: lowerAscii,
322
+ });
@@ -44,6 +44,7 @@ var time = require("./guard-time");
44
44
  // one answering `false` makes each of those checks reject a well-formed parsed structure -- the
45
45
  // fail-closed direction, and still a caller deciding what this guard recognizes.
46
46
  var _isArray = require("./guard-intrinsic").isArray;
47
+ var _freezeExports = require("./guard-intrinsic").freeze;
47
48
  // The copy that becomes the recorded provenance bytes. A replacement returning a buffer over the
48
49
  // caller's own memory would let those bytes change after they were recorded, which is the one
49
50
  // thing provenance exists to prevent.
@@ -598,10 +599,12 @@ function acceptDerived(input, kind, parse, E, code, label) {
598
599
  ".parse result: " + _WHY[kind]);
599
600
  }
600
601
 
601
- module.exports = {
602
+ // Frozen for the reason the family header gives: a boundary reads its guard off this object at the
603
+ // call, so a writable export would let a caller replace the check rather than pass it.
604
+ module.exports = _freezeExports({
602
605
  accept: accept, acceptDerived: acceptDerived,
603
606
  fromTrustedSource: fromTrustedSource, recordingParser: recordingParser,
604
607
  recordingWalker: recordingWalker,
605
608
  isCert: certShape, isCrl: crlShape, isRecorded: isRecorded,
606
609
  isRecordedAsProduced: isRecordedAsProduced,
607
- };
610
+ });
@@ -25,6 +25,7 @@
25
25
  // Number at all, so one answering true for an unsafe magnitude reopens the precision loss this
26
26
  // guard exists to prevent. See guard-intrinsic for the whole captured set.
27
27
  var _isSafeInteger = require("./guard-intrinsic").isSafeInteger;
28
+ var _freeze = require("./guard-intrinsic").freeze;
28
29
  // The narrow itself. This module exists to turn a bounded BigInt into a Number without losing the
29
30
  // bound, and `Number` is a writable property of globalThis, so a replacement returns whatever it
30
31
  // likes from a value this function has just certified as in range.
@@ -131,7 +132,9 @@ function authoredInteger(value, E, code, label) {
131
132
  throw E(code, label + " must be an integer (a safe-integer number, or a bigint for a large value)");
132
133
  }
133
134
 
134
- module.exports = {
135
+ // Frozen for the reason the family header gives: a boundary reads its guard off this object at the
136
+ // call, so a writable export would let a caller replace the check rather than pass it.
137
+ module.exports = _freeze({
135
138
  int: int, uint31: uint31, positiveInt31: positiveInt31, uint64: uint64,
136
139
  authoredInteger: authoredInteger,
137
- };
140
+ });
@@ -138,4 +138,6 @@ function cipherFinish(transform, input, ErrorClass, code, label) {
138
138
  }
139
139
  }
140
140
 
141
- module.exports = { zeroize: zeroize, zeroizeAll: zeroizeAll, cipherFinish: cipherFinish };
141
+ // Frozen for the reason the family header gives: a boundary reads its guard off this object at the
142
+ // call, so a writable export would let a caller replace the check rather than pass it.
143
+ module.exports = intrinsic.freeze({ zeroize: zeroize, zeroizeAll: zeroizeAll, cipherFinish: cipherFinish });
package/lib/guard-text.js CHANGED
@@ -99,4 +99,6 @@ function decode(input, maxBytes, ErrorClass, spec) {
99
99
  throw new ErrorClass(spec.badInput, spec.label + " expects a string or Buffer");
100
100
  }
101
101
 
102
- module.exports = { decode: decode };
102
+ // Frozen for the reason the family header gives: a boundary reads its guard off this object at the
103
+ // call, so a writable export would let a caller replace the check rather than pass it.
104
+ module.exports = intrinsic.freeze({ decode: decode });
package/lib/guard-time.js CHANGED
@@ -32,6 +32,7 @@
32
32
  // the global `isNaN` is writable, and one returning false makes an invalid Date pass the check
33
33
  // below, which is the fail-open direction.
34
34
  var util = { types: require("./guard-intrinsic").types };
35
+ var _freeze = require("./guard-intrinsic").freeze;
35
36
  var _isNaN = Number.isNaN;
36
37
 
37
38
  // assertValid(value, E, code, label) -> the same Date, once proven valid.
@@ -130,9 +131,11 @@ function isDate(value) {
130
131
  return util.types.isDate(value);
131
132
  }
132
133
 
133
- module.exports = {
134
+ // Frozen for the reason the family header gives: a boundary reads its guard off this object at the
135
+ // call, so a writable export would let a caller replace the check rather than pass it.
136
+ module.exports = _freeze({
134
137
  assertValid: assertValid,
135
138
  instantOf: instantOf,
136
139
  isDate: isDate,
137
140
  within: within,
138
- };
141
+ });
package/lib/hpke.js CHANGED
@@ -27,6 +27,10 @@
27
27
  var nodeCrypto = require("crypto");
28
28
  var frameworkError = require("./framework-error");
29
29
  var guard = require("./guard-all");
30
+ var intrinsic = require("./guard-intrinsic");
31
+ // Own-key membership through an operation taken at load. Written out, the question reads two
32
+ // replaceable properties to answer one thing, and here it decides which suite parameters are read.
33
+ var _hasOwn = intrinsic.hasOwn;
30
34
 
31
35
  var HpkeError = frameworkError.HpkeError;
32
36
  function _err(code, message, cause) { return new HpkeError(code, message, cause); }
@@ -423,7 +427,7 @@ function _mode(opts, keys, who) {
423
427
  guard.identifier.assertKnownKeys(opts, keys, _err, "hpke/bad-input", function (k) {
424
428
  var other = (keys === _SETUP_S_KEYS ? _SETUP_R_KEYS : _SETUP_S_KEYS);
425
429
  return "unknown HPKE " + who + " option " + JSON.stringify(k) +
426
- (Object.prototype.hasOwnProperty.call(other, k)
430
+ (_hasOwn(other, k)
427
431
  ? " -- that option belongs to the other end of the exchange, where it would authenticate or seed; here it would do nothing"
428
432
  : "") + " -- accepted: " + Object.keys(keys).sort().join(", ");
429
433
  });