@blamejs/pki 0.6.54 → 0.7.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.
@@ -87,6 +87,15 @@ function assertKnownKeys(obj, known, E, code, message) {
87
87
  });
88
88
  }
89
89
 
90
+ // @enforced-by behavioral -- reading a property twice has no rename-proof code shape; the RED
91
+ // @enforced-by behavioral -- vectors that drive an accessor-backed option are the guard
92
+ function snapshotOptions(obj, known) {
93
+ var out = _create(null);
94
+ if (obj === null || obj === undefined) return out;
95
+ _forEach(_getOwnPropertyNames(known), function (k) { out[k] = obj[k]; });
96
+ return out;
97
+ }
98
+
90
99
  var _PRISTINE_OBJECT_PROTO = (function () {
91
100
  var s = _create(null);
92
101
  _forEach(["constructor", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable", "toLocaleString",
@@ -441,6 +450,7 @@ module.exports = intrinsic.freeze({
441
450
  isPlainRecord: isPlainRecord,
442
451
  optionsObject: optionsObject,
443
452
  refuseAccessorFields: refuseAccessorFields,
453
+ snapshotOptions: snapshotOptions,
444
454
  readableNames: readableNames,
445
455
  readableIndices: readableIndices
446
456
  });
package/lib/oid.js CHANGED
@@ -192,6 +192,13 @@ var FAMILIES = Object.assign(Object.create(null), {
192
192
  entrustAlg: { base: [1, 2, 840, 113533, 7, 66], of: {
193
193
  passwordBasedMac: 13, kemBasedMac: 16, dhBasedMac: 30 } },
194
194
 
195
+ /** @internal ANSI X9.42 (RFC 3279 sec. 2.3.3): the SubjectPublicKeyInfo algorithm an X.509
196
+ * Diffie-Hellman certificate names, whose parameters are DomainParameters rather than the PKCS#3
197
+ * DHParameter that pkcs3 below names. */
198
+ ansiX942: { base: [1, 2, 840, 10046, 2], of: { dhpublicnumber: 1 } },
199
+
200
+ pkcs3: { base: [1, 2, 840, 113549, 1, 3], of: { dhKeyAgreement: 1 } },
201
+
195
202
  pkcs12BagTypes: { base: [1, 2, 840, 113549, 1, 12, 10, 1], of: {
196
203
  keyBag: 1, pkcs8ShroudedKeyBag: 2, certBag: 3, crlBag: 4, secretBag: 5, safeContentsBag: 6 } },
197
204
 
@@ -226,6 +233,7 @@ var FAMILIES = Object.assign(Object.create(null), {
226
233
 
227
234
  pkixAlg: { base: [1, 3, 6, 1, 5, 5, 7, 6], of: {
228
235
  "id-alg-noSignature": 2,
236
+ "id-dhPop-static-HMAC-SHA1": 3, "id-alg-dhPOP": 4,
229
237
  "id-RSASSA-PSS-SHAKE128": 30, "id-RSASSA-PSS-SHAKE256": 31,
230
238
  "id-alg-xmss-hashsig": 34, "id-alg-xmssmt-hashsig": 35,
231
239
  "id-MLDSA44-RSA2048-PSS-SHA256": 37, "id-MLDSA44-RSA2048-PKCS15-SHA256": 38,
@@ -182,7 +182,22 @@ function pemDecodeLenient(text, label) {
182
182
  return _bufferFrom(_keepBase64(_strSlice(text, bodyStart, ei)), "base64");
183
183
  }
184
184
 
185
+ /** @internal Every refusal below is built from opts, so opts is checked before the first one can be
186
+ * reached. A caller that misspells a key otherwise gets a working accept path and a set of refusal
187
+ * paths that throw `undefined is not a constructor`: the input is still rejected, but as an untyped
188
+ * runtime error carrying no reason, and the label check silently passes everything. */
189
+ function _requireCoerceOpts(opts) {
190
+ if (!opts || typeof opts !== "object") throw new TypeError("coerceToDer requires an options object");
191
+ if (typeof opts.PemError !== "function") throw new TypeError("coerceToDer requires opts.PemError, an error constructor");
192
+ if (typeof opts.ErrorClass !== "function") throw new TypeError("coerceToDer requires opts.ErrorClass, an error constructor");
193
+ if (typeof opts.prefix !== "string" || opts.prefix === "") throw new TypeError("coerceToDer requires opts.prefix, a non-empty error-code prefix");
194
+ if (!(opts.pemLabel === null || typeof opts.pemLabel === "string")) {
195
+ throw new TypeError("coerceToDer requires opts.pemLabel, a PEM label to enforce or null to accept any");
196
+ }
197
+ }
198
+
185
199
  function coerceToDer(input, opts) {
200
+ _requireCoerceOpts(opts);
186
201
  if (typeof input === "string") return pemDecode(input, opts.pemLabel, opts.PemError);
187
202
  if (guard.bytes.isByteSource(input)) {
188
203
  var buf = guard.bytes.source(input, opts.ErrorClass, opts.prefix + "/bad-input", "parse");