@blamejs/pki 0.8.11 → 0.8.14

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.
@@ -100,6 +100,38 @@ function snapshotOptions(obj, known) {
100
100
  return out;
101
101
  }
102
102
 
103
+ /** @internal The option names a bag carries, read the way assertKnownKeys read them: every own
104
+ * string key, whatever its descriptor says. Object.keys reports only the enumerable ones, so an
105
+ * option written with `enumerable: false` clears the door and then vanishes from the read.
106
+ * `known` narrows the result to the declared options. */
107
+ // @enforced-by option-bag-read-by-enumerable-key
108
+ function optionNames(obj, known) {
109
+ if (obj === null || obj === undefined) return [];
110
+ var out = [];
111
+ _forEach(_ownKeys(_Object(obj)), function (k) {
112
+ if (typeof k !== "string") return;
113
+ if (known !== null && known !== undefined && !_hasOwn(known, k)) return;
114
+ _append(out, k);
115
+ });
116
+ return out;
117
+ }
118
+
119
+ /** @internal A caller's options bag copied onto a prototype-less object, keyed by every own string
120
+ * property, not the enumerable ones alone. Each is read once, so an accessor-backed option
121
+ * answers the copy and not the later reads. Inherited properties are left behind: the copy is
122
+ * what the decisions read, and a name reaching it from a prototype is not one the caller set. */
123
+ // @enforced-by option-bag-read-by-enumerable-key
124
+ function ownOptions(obj) {
125
+ var out = _create(null);
126
+ if (obj === null || obj === undefined) return out;
127
+ var o = _Object(obj);
128
+ _forEach(_ownKeys(o), function (k) {
129
+ if (typeof k !== "string") return;
130
+ out[k] = o[k];
131
+ });
132
+ return out;
133
+ }
134
+
103
135
  var _PRISTINE_OBJECT_PROTO = (function () {
104
136
  var s = _create(null);
105
137
  _forEach(["constructor", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable", "toLocaleString",
@@ -528,6 +560,8 @@ module.exports = intrinsic.freeze({
528
560
  optionsObject: optionsObject,
529
561
  refuseAccessorFields: refuseAccessorFields,
530
562
  snapshotOptions: snapshotOptions,
563
+ optionNames: optionNames,
564
+ ownOptions: ownOptions,
531
565
  readableNames: readableNames,
532
566
  readableIndices: readableIndices
533
567
  });
package/lib/hpke.js CHANGED
@@ -228,7 +228,11 @@ function _extractAndExpand(kem, dh, kemContext) {
228
228
  try { return _labeledExpand(kdf, sid, eaePrk, "shared_secret", kemContext, kem.Nsecret); }
229
229
  finally { guard.secret.zeroize(eaePrk, HpkeError, "hpke/bad-input", "the KEM extract PRK"); }
230
230
  }
231
- function _kemId(kem) { for (var k in KEMS) if (KEMS[k] === kem) return Number(k); return 0; }
231
+ function _kemId(kem) {
232
+ var names = guard.identifier.optionNames(KEMS);
233
+ for (var i = 0; i < names.length; i++) if (KEMS[names[i]] === kem) return Number(names[i]);
234
+ return 0;
235
+ }
232
236
 
233
237
  function _ephemeral(kem, eph) {
234
238
  if (eph != null) {
@@ -429,7 +433,8 @@ var _COMMON_KEYS = intrinsic.assign(intrinsic.create(null), { mode: 1, info: 1,
429
433
  function _withCommon(extra) {
430
434
  var out = intrinsic.create(null);
431
435
  Object.keys(_COMMON_KEYS).forEach(function (k) { out[k] = 1; });
432
- Object.keys(extra).forEach(function (k) { out[k] = 1; });
436
+ var en = guard.identifier.optionNames(extra);
437
+ for (var ei = 0; ei < en.length; ei++) out[en[ei]] = 1;
433
438
  return out;
434
439
  }
435
440
  var _SETUP_S_KEYS = _withCommon({
@@ -279,10 +279,10 @@ function _copyableArray(a) {
279
279
  function snapshotProxy(p) {
280
280
  try {
281
281
  if (!_copyableRecord(p)) return p;
282
- var out = Object.assign(Object.create(null), p);
283
- if (_copyableRecord(p.auth)) out.auth = Object.assign(Object.create(null), p.auth);
282
+ var out = guard.identifier.ownOptions(p);
283
+ if (_copyableRecord(p.auth)) out.auth = guard.identifier.ownOptions(p.auth);
284
284
  if (_copyableRecord(p.tls)) {
285
- out.tls = Object.assign(Object.create(null), p.tls);
285
+ out.tls = guard.identifier.ownOptions(p.tls);
286
286
  var a = p.tls.anchors;
287
287
  if (_copyableArray(a)) {
288
288
  var copied = [];
@@ -492,7 +492,7 @@ function httpsTransport(defaults) {
492
492
  var bodyIsFn = typeof body === "function";
493
493
  if (!bodyIsFn && guard.bytes.isByteSource(body)) body = guard.bytes.source(body, E, C("bad-input"), "the request body");
494
494
 
495
- var reqHeaders = Object.assign(Object.create(null), request.headers || {});
495
+ var reqHeaders = guard.identifier.ownOptions(request.headers);
496
496
  Object.keys(reqHeaders).forEach(function (k) { var lk = k.toLowerCase(); if (lk === "proxy-authorization" || lk === "proxy-connection") delete reqHeaders[k]; });
497
497
  if (bodyIsFn) {
498
498
  Object.keys(reqHeaders).forEach(function (k) { var lk = k.toLowerCase(); if (lk === "content-length" || lk === "transfer-encoding" || lk === "expect") delete reqHeaders[k]; });
@@ -609,8 +609,7 @@ function httpsTransport(defaults) {
609
609
  if (settled) return;
610
610
  settled = true;
611
611
  clearTimer();
612
- var lower = Object.create(null);
613
- Object.keys(res.headers || {}).forEach(function (k) { lower[k.toLowerCase()] = res.headers[k]; });
612
+ var lower = guard.header.lowerCased(res.headers);
614
613
  resolve({
615
614
  status: res.statusCode,
616
615
  headers: lower,
@@ -199,9 +199,10 @@ function _reference(r, index) {
199
199
  * afterwards would otherwise name an identity nothing compared. A string is already a value; bytes
200
200
  * are the copy taken at the door. */
201
201
  function _reported(record) {
202
- var out = intrinsic.create(null), k;
203
- for (k in record) {
204
- if (intrinsic.hasOwn(record, k) && record[k] !== undefined) out[k] = record[k];
202
+ var out = intrinsic.create(null);
203
+ var names = guard.identifier.optionNames(record);
204
+ for (var i = 0; i < names.length; i++) {
205
+ if (record[names[i]] !== undefined) out[names[i]] = record[names[i]];
205
206
  }
206
207
  return intrinsic.freeze(out);
207
208
  }
package/lib/ocsp.js CHANGED
@@ -390,7 +390,10 @@ function _snapshotSignerKey(key, owned) {
390
390
  return copy;
391
391
  }
392
392
  if (key && typeof key === "object" && (key.mldsa != null || key.trad != null)) {
393
- return Object.assign({}, key, { mldsa: _snapshotSignerKey(key.mldsa, owned), trad: _snapshotSignerKey(key.trad, owned) });
393
+ var ks = guard.identifier.ownOptions(key);
394
+ ks.mldsa = _snapshotSignerKey(key.mldsa, owned);
395
+ ks.trad = _snapshotSignerKey(key.trad, owned);
396
+ return ks;
394
397
  }
395
398
  return key;
396
399
  }
@@ -925,8 +928,7 @@ function httpRequest(der, responderUrl, opts) {
925
928
  var HTTP_REQUEST_OPTS = Object.assign(Object.create(null), { method: 1 });
926
929
 
927
930
  function _frozenHeaders(h) {
928
- var out = Object.create(null), k;
929
- for (k in h) { if (Object.prototype.hasOwnProperty.call(h, k)) out[k] = h[k]; }
931
+ var out = guard.identifier.ownOptions(h);
930
932
  return Object.freeze(out);
931
933
  }
932
934
 
package/lib/oid.js CHANGED
@@ -217,7 +217,7 @@ var FAMILIES = Object.assign(Object.create(null), {
217
217
  hmacWithSHA1: 7, hmacWithSHA224: 8, hmacWithSHA256: 9,
218
218
  hmacWithSHA384: 10, hmacWithSHA512: 11 } },
219
219
 
220
- smimeCt: { base: [1, 2, 840, 113549, 1, 9, 16, 1], of: { authData: 2, tSTInfo: 4, compressedData: 9, encKeyWithID: 21, authEnvelopedData: 23 } },
220
+ smimeCt: { base: [1, 2, 840, 113549, 1, 9, 16, 1], of: { authData: 2, tSTInfo: 4, compressedData: 9, encKeyWithID: 21, authEnvelopedData: 23, trustAnchorList: 34 } },
221
221
 
222
222
  smimeOri: { base: [1, 2, 840, 113549, 1, 9, 16, 13], of: { kem: 3 } },
223
223