@blamejs/pki 0.6.40 → 0.6.42

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.
Files changed (75) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +1 -1
  3. package/lib/acme.js +24 -13
  4. package/lib/asn1-der.js +5 -5
  5. package/lib/attrcert-sign.js +14 -14
  6. package/lib/cbor-det.js +2 -2
  7. package/lib/cmc-build.js +16 -16
  8. package/lib/cmc-verify.js +5 -5
  9. package/lib/cmp-build.js +29 -19
  10. package/lib/cmp-session.js +21 -16
  11. package/lib/cmp-verify.js +4 -4
  12. package/lib/cms-decrypt.js +8 -8
  13. package/lib/cms-encrypt.js +22 -22
  14. package/lib/cms-sign.js +17 -17
  15. package/lib/cms-verify.js +6 -6
  16. package/lib/composite-kem.js +1 -1
  17. package/lib/composite-sig.js +4 -4
  18. package/lib/constants.js +13 -9
  19. package/lib/crl-sign.js +17 -17
  20. package/lib/crmf-sign.js +11 -11
  21. package/lib/csr-sign.js +2 -2
  22. package/lib/ct.js +19 -11
  23. package/lib/edwards-point.js +2 -2
  24. package/lib/est.js +74 -43
  25. package/lib/guard-async.js +17 -1
  26. package/lib/guard-bytes.js +2 -2
  27. package/lib/guard-compress.js +5 -5
  28. package/lib/guard-identifier.js +45 -1
  29. package/lib/guard-name.js +272 -1
  30. package/lib/guard-time.js +3 -1
  31. package/lib/hpke.js +10 -10
  32. package/lib/http-digest.js +2 -2
  33. package/lib/http-transport.js +3 -3
  34. package/lib/inspect.js +9 -9
  35. package/lib/jose.js +14 -14
  36. package/lib/key.js +7 -7
  37. package/lib/lint.js +6 -4
  38. package/lib/merkle.js +2 -2
  39. package/lib/mime.js +2 -2
  40. package/lib/ocsp-verify.js +1 -1
  41. package/lib/ocsp.js +5 -5
  42. package/lib/oid.js +3 -3
  43. package/lib/path-validate.js +50 -120
  44. package/lib/pbes2.js +2 -2
  45. package/lib/pkcs12-build.js +15 -15
  46. package/lib/pki-build.js +2 -2
  47. package/lib/scep.js +47 -16
  48. package/lib/schema-all.js +1 -1
  49. package/lib/schema-attrcert.js +4 -3
  50. package/lib/schema-c509.js +23 -23
  51. package/lib/schema-cmc.js +6 -6
  52. package/lib/schema-cmp.js +3 -3
  53. package/lib/schema-cms.js +15 -8
  54. package/lib/schema-crmf.js +1 -1
  55. package/lib/schema-csr.js +1 -1
  56. package/lib/schema-engine.js +2 -1
  57. package/lib/schema-pkcs12.js +1 -1
  58. package/lib/schema-pkix.js +3 -0
  59. package/lib/schema-tsp.js +2 -2
  60. package/lib/shbs.js +2 -2
  61. package/lib/sign-scheme.js +9 -9
  62. package/lib/sigstore.js +9 -8
  63. package/lib/smime.js +12 -12
  64. package/lib/tls-cert-compress.js +6 -6
  65. package/lib/trust.js +179 -10
  66. package/lib/tsp-sign.js +11 -11
  67. package/lib/validator-attcert.js +2 -2
  68. package/lib/validator-cose.js +5 -5
  69. package/lib/validator-sig.js +3 -3
  70. package/lib/validator-tpm.js +5 -4
  71. package/lib/webauthn.js +12 -12
  72. package/lib/webcrypto.js +22 -14
  73. package/lib/x509-sign.js +8 -8
  74. package/package.json +1 -1
  75. package/sbom.cdx.json +6 -6
@@ -6,7 +6,7 @@ var async = require("./guard-async");
6
6
  var identifier = require("./guard-identifier");
7
7
  var time = require("./guard-time");
8
8
  var intrinsic = require("./guard-intrinsic");
9
- var util = { types: intrinsic.types };
9
+ var util = intrinsic.assign(intrinsic.create(null), { types: intrinsic.types });
10
10
  var _isArray = intrinsic.isArray;
11
11
  var _bufferFrom = intrinsic.bufferFrom;
12
12
  var _isView = intrinsic.isView;
@@ -65,7 +65,7 @@ function asyncStreamOf(x) {
65
65
  if (isByteSource(x) || x == null || (typeof x !== "object" && typeof x !== "function")) return null;
66
66
  var acquire = x[_asyncIterator];
67
67
  if (typeof acquire !== "function") return null;
68
- var stream = {};
68
+ var stream = intrinsic.create(null);
69
69
  stream[_asyncIterator] = function () { return _apply(acquire, x, _NO_ARGS); };
70
70
  return stream;
71
71
  }
@@ -15,17 +15,17 @@ var _sizeOf = _intrinsic.sizeOf;
15
15
  var _subarray = _intrinsic.uncurry(Uint8Array.prototype.subarray);
16
16
  var _hasOwn = _intrinsic.hasOwn;
17
17
 
18
- var DECOMPRESS = {
18
+ var DECOMPRESS = _intrinsic.assign(_intrinsic.create(null), {
19
19
  zlib: zlib.inflateSync,
20
20
  brotli: zlib.brotliDecompressSync,
21
21
  zstd: zlib.zstdDecompressSync,
22
- };
22
+ });
23
23
 
24
- var _PROBE_COMPRESS = {
24
+ var _PROBE_COMPRESS = _intrinsic.assign(_intrinsic.create(null), {
25
25
  zlib: zlib.deflateSync,
26
26
  brotli: zlib.brotliCompressSync,
27
27
  zstd: zlib.zstdCompressSync,
28
- };
28
+ });
29
29
 
30
30
  function _reportsTruncation(name) {
31
31
  var compress = _PROBE_COMPRESS[name];
@@ -47,7 +47,7 @@ function _reportsTruncation(name) {
47
47
  return !cutAccepted;
48
48
  }
49
49
 
50
- var SAFE = {};
50
+ var SAFE = _intrinsic.create(null);
51
51
  _intrinsic.forEach(_objectKeys(DECOMPRESS), function (n) { if (_reportsTruncation(n)) SAFE[n] = true; });
52
52
 
53
53
  // @enforced-by guard-shape-reinlined
@@ -2,7 +2,7 @@
2
2
  // Copyright (c) blamejs contributors
3
3
  "use strict";
4
4
  var intrinsic = require("./guard-intrinsic");
5
- var util = { types: intrinsic.types };
5
+ var util = intrinsic.assign(intrinsic.create(null), { types: intrinsic.types });
6
6
  // @internal
7
7
 
8
8
  var _isArray = intrinsic.isArray;
@@ -32,6 +32,7 @@ var _Set = intrinsic.Set;
32
32
  var _Map = intrinsic.Map;
33
33
  var _charCodeAt = intrinsic.uncurry(String.prototype.charCodeAt);
34
34
  var _strSplit = intrinsic.uncurry(String.prototype.split);
35
+ var _fnToString = intrinsic.uncurry(Function.prototype.toString);
35
36
  var _hasOwn = intrinsic.hasOwn;
36
37
  var _String = intrinsic.String;
37
38
  var _Number = intrinsic.Number;
@@ -390,7 +391,50 @@ function _settle(opts, E, code, label) {
390
391
  return opts;
391
392
  }
392
393
 
394
+ /** @internal An injectable callback option, refused unless it is callable. A value that is present
395
+ * but not a function reaches the call site otherwise, where the operator gets a bare TypeError
396
+ * naming no option; and one read as absent sends the caller to whatever default the boundary
397
+ * installs, which for a transport is a real network client the caller was trying to replace. Take a
398
+ * value only when it is known to be present; `assertCallableOption` decides presence.
399
+ *
400
+ * Callable is all this asks. A class constructor answers "function" to typeof and still throws when
401
+ * called, but no test here separates one from an ordinary function: freezing a function leaves its
402
+ * prototype non-writable exactly as a class's is, and reading the source text mistakes a method
403
+ * named `class` for the keyword. The boundary that calls the value reports that throw as its own
404
+ * typed error (`guard.async.invoked`), which covers a class however it is disguised, binding it
405
+ * included, and rejects nothing a caller can legitimately pass. */
406
+ // @enforced-by behavioral -- the shape is a typeof test against a string literal, and the pattern
407
+ // @enforced-by behavioral -- scanner blanks every literal, so "function" cannot be told from
408
+ // @enforced-by behavioral -- "string" or "object"; a lexical rule would flag every type check in
409
+ // @enforced-by behavioral -- lib. The per-verb vectors across est, scep, acme, cmp and ct are the
410
+ // @enforced-by behavioral -- guard: each drives the shipped verb and asserts the typed refusal.
411
+ function assertCallable(value, E, code, label, shape) {
412
+ var wanted = label + " must be a function" + (shape ? " " + shape : "");
413
+ if (value === undefined) {
414
+ throw E(code, wanted + ", got undefined");
415
+ }
416
+ if (typeof value !== "function") {
417
+ throw E(code, wanted + ", got " + (value === null ? "null" : typeof value));
418
+ }
419
+ return value;
420
+ }
421
+
422
+ /** @internal The option form: an option counts as supplied when a name lookup finds the key, so a
423
+ * merge that produced `{ transport: undefined }` is a value the caller set rather than an option it
424
+ * left out. Presence is asked the way the boundary asks for the value, which is a plain lookup, so
425
+ * an inherited option from a defaults bag is checked rather than skipped; testing own keys alone
426
+ * would let an inherited null pass here and then be read as absent, selecting the default client.
427
+ * Only a key no lookup finds falls through to that default. */
428
+ // @enforced-by behavioral -- the per-verb vectors across est, scep, acme, cmp, ct and path drive the
429
+ // @enforced-by behavioral -- shipped verb and assert the typed refusal for each unusable value
430
+ function assertCallableOption(opts, key, E, code, label, shape) {
431
+ if (opts == null || !(key in _Object(opts))) return undefined;
432
+ return assertCallable(opts[key], E, code, label, shape);
433
+ }
434
+
393
435
  module.exports = intrinsic.freeze({
436
+ assertCallable: assertCallable,
437
+ assertCallableOption: assertCallableOption,
394
438
  assertCanonicalOid: assertCanonicalOid,
395
439
  assertKnownKeys: assertKnownKeys,
396
440
  assertPlainRecord: assertPlainRecord,
package/lib/guard-name.js CHANGED
@@ -4,6 +4,11 @@
4
4
  // @internal
5
5
 
6
6
  var intrinsic = require("./guard-intrinsic");
7
+ var _append = require("./guard-list").append;
8
+ var _assertCanonicalOid = require("./guard-identifier").assertCanonicalOid;
9
+ var _ipUtils = require("./ip-utils");
10
+ var _isIPv4 = _ipUtils.isIPv4;
11
+ var _expandIpv6Hex = _ipUtils.expandIpv6Hex;
7
12
 
8
13
  var _charCodeAt = intrinsic.uncurry(String.prototype.charCodeAt);
9
14
  var _charAt = intrinsic.uncurry(String.prototype.charAt);
@@ -11,6 +16,7 @@ var _toLowerCase = intrinsic.uncurry(String.prototype.toLowerCase);
11
16
  var _toUpperCase = intrinsic.uncurry(String.prototype.toUpperCase);
12
17
  var _strSlice = intrinsic.uncurry(String.prototype.slice);
13
18
  var _lastIndexOf = intrinsic.uncurry(String.prototype.lastIndexOf);
19
+ var _indexOf = intrinsic.uncurry(String.prototype.indexOf);
14
20
  var _numToString = intrinsic.uncurry(Number.prototype.toString);
15
21
  var _create = intrinsic.create;
16
22
  var _hasOwn = intrinsic.hasOwn;
@@ -152,7 +158,7 @@ function escapeControlBytes(str) {
152
158
  return out;
153
159
  }
154
160
 
155
- var DN_SPECIAL = { 0x2c: 1, 0x2b: 1, 0x22: 1, 0x5c: 1, 0x3c: 1, 0x3e: 1, 0x3b: 1 };
161
+ var DN_SPECIAL = intrinsic.assign(intrinsic.create(null), { 0x2c: 1, 0x2b: 1, 0x22: 1, 0x5c: 1, 0x3c: 1, 0x3e: 1, 0x3b: 1 });
156
162
  // @enforced-by behavioral -- the escaping has no rename-proof code shape distinct
157
163
  function escapeDnValue(v) {
158
164
  var s = _String(v), out = "";
@@ -197,9 +203,274 @@ function lowerAscii(s) {
197
203
  return out;
198
204
  }
199
205
 
206
+ function _charTable(chars) {
207
+ var t = _create(null);
208
+ for (var i = 0; i < chars.length; i++) t[_charCodeAt(chars, i)] = true;
209
+ return t;
210
+ }
211
+ var _FQDN_TABLE = _charTable("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-");
212
+ var _DIGDOT_TABLE = _charTable("0123456789.");
213
+ function _allCharsIn(s, table) {
214
+ if (s.length === 0) return false;
215
+ for (var i = 0; i < s.length; i++) if (!table[_charCodeAt(s, i)]) return false;
216
+ return true;
217
+ }
218
+
219
+ function stripTrailingDot(s) { return _charAt(s, s.length - 1) === "." ? _strSlice(s, 0, -1) : s; }
220
+
221
+ /** @internal A host name of two or more labels that is not an address, which is the form a URI
222
+ * name constraint is compared by (RFC 5280 sec. 4.2.1.10). */
223
+ function isFqdnHost(host) {
224
+ var h = stripTrailingDot(host);
225
+ if (h === "" || _indexOf(h, ".") === -1) return false;
226
+ if (!_allCharsIn(h, _FQDN_TABLE)) return false;
227
+ if (_allCharsIn(h, _DIGDOT_TABLE)) return false;
228
+ return true;
229
+ }
230
+
231
+ var _LDH_ALNUM = _charTable("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
232
+ var MAX_LABEL = 63;
233
+ var MAX_HOST = 253;
234
+ var MAX_LOCAL_PART = 64;
235
+
236
+ /** @internal One label of a host name (RFC 1034 sec. 3.5, RFC 1123 sec. 2.1): letters, digits and
237
+ * hyphens, with a hyphen at neither edge, and 63 characters at most. */
238
+ function _isHostLabel(s, from, to) {
239
+ var n = to - from;
240
+ if (n === 0 || n > MAX_LABEL) return false;
241
+ if (!_LDH_ALNUM[_charCodeAt(s, from)] || !_LDH_ALNUM[_charCodeAt(s, to - 1)]) return false;
242
+ for (var i = from + 1; i < to - 1; i++) {
243
+ var c = _charCodeAt(s, i);
244
+ if (!_LDH_ALNUM[c] && c !== 0x2d) return false;
245
+ }
246
+ return true;
247
+ }
248
+
249
+ /** @internal A host name written as labels separated by dots, carrying no trailing dot: the caller
250
+ * strips the one dot the comparison strips, so a second one is an empty label and is refused. */
251
+ function _isHostName(s) {
252
+ if (s.length === 0 || s.length > MAX_HOST) return false;
253
+ var start = 0;
254
+ for (var i = 0; i <= s.length; i++) {
255
+ if (i === s.length || _charCodeAt(s, i) === 0x2e) {
256
+ if (!_isHostLabel(s, start, i)) return false;
257
+ start = i + 1;
258
+ }
259
+ }
260
+ return true;
261
+ }
262
+
263
+ var _ATEXT_TABLE = _charTable("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!#$%&'*+-/=?^_`{|}~");
264
+
265
+ /** @internal A quoted local part (RFC 5321 sec. 4.1.2 Quoted-string): printable ASCII between
266
+ * quotes, where a backslash escapes the character after it. */
267
+ function _isQuotedLocal(s) {
268
+ var n = s.length;
269
+ if (n < 2 || _charCodeAt(s, n - 1) !== 0x22) return false;
270
+ for (var i = 1; i < n - 1; i++) {
271
+ var c = _charCodeAt(s, i);
272
+ if (c === 0x5c) {
273
+ i += 1;
274
+ if (i >= n - 1) return false;
275
+ var e = _charCodeAt(s, i);
276
+ if (e < 0x20 || e > 0x7e) return false;
277
+ continue;
278
+ }
279
+ if (c < 0x20 || c > 0x7e || c === 0x22) return false;
280
+ }
281
+ return true;
282
+ }
283
+
284
+ /** @internal The local part of a mailbox (RFC 5321 sec. 4.1.2): either a quoted string, or atoms
285
+ * separated by dots, which is the form a certificate's mailbox is compared against. */
286
+ function _isMailboxLocal(s) {
287
+ if (s.length === 0 || s.length > MAX_LOCAL_PART) return false;
288
+ if (_charCodeAt(s, 0) === 0x22) return _isQuotedLocal(s);
289
+ var pieceLen = 0;
290
+ for (var i = 0; i < s.length; i++) {
291
+ var c = _charCodeAt(s, i);
292
+ if (c === 0x2e) {
293
+ if (pieceLen === 0) return false;
294
+ pieceLen = 0;
295
+ continue;
296
+ }
297
+ if (!_ATEXT_TABLE[c]) return false;
298
+ pieceLen += 1;
299
+ }
300
+ return pieceLen > 0;
301
+ }
302
+
303
+ var _IPV6_TAG = "ipv6:";
304
+ /** @internal An address literal (RFC 5321 sec. 4.1.3), the other form a mailbox may name its domain
305
+ * in: an IPv4 address in brackets, or an IPv6 address behind the tag that introduces one. The
306
+ * comparison holds a mailbox constraint's domain to an exact match, so a literal is a domain it can
307
+ * reach a verdict on. */
308
+ function _isAddressLiteral(s) {
309
+ var n = s.length;
310
+ if (n < 3 || _charCodeAt(s, 0) !== 0x5b || _charCodeAt(s, n - 1) !== 0x5d) return false;
311
+ var inner = _strSlice(s, 1, n - 1);
312
+ if (_toLowerCase(_strSlice(inner, 0, _IPV6_TAG.length)) === _IPV6_TAG) {
313
+ return _expandIpv6Hex(_strSlice(inner, _IPV6_TAG.length)) !== null;
314
+ }
315
+ return _isIPv4(inner);
316
+ }
317
+
318
+ /** @internal The two halves of a mailbox, `null` when it carries no separator and the string
319
+ * "ambiguous" when it carries more than one. This is the split the rfc822Name comparison runs, so a
320
+ * constraint the comparison cannot separate is one this answers the same way. */
321
+ function splitMailbox(addr) {
322
+ var first = _indexOf(addr, "@");
323
+ if (first === -1) return null;
324
+ if (first !== _lastIndexOf(addr, "@")) return "ambiguous";
325
+ return [_strSlice(addr, 0, first), _strSlice(addr, first + 1)];
326
+ }
327
+
328
+ /** @internal A host name, optionally written as a subtree with a leading dot, and with the one
329
+ * trailing dot the comparison strips. */
330
+ function _hostConstraintBody(s) {
331
+ var h = stripTrailingDot(s);
332
+ return _charAt(h, 0) === "." ? _strSlice(h, 1) : h;
333
+ }
334
+
335
+ /** @internal Why a name-constraint base cannot be enforced, or null when it can. A base outside the
336
+ * form its tag names is not a narrower namespace: an empty dNSName base matches every name, and a
337
+ * base holding characters no host name can hold matches none, so the same value that reads as a
338
+ * restriction either lifts one or applies to nothing. The comparisons this mirrors are in
339
+ * lib/path-validate.js, and a base refused here is one they would answer with no verdict. */
340
+ function constraintBaseRefusal(tag, base) {
341
+ if (typeof base !== "string") return "must be a string for tag " + tag;
342
+ if (tag === 1) {
343
+ var mb = splitMailbox(base);
344
+ if (mb === null) {
345
+ if (_isAddressLiteral(base)) return null;
346
+ return _isHostName(_hostConstraintBody(base)) ? null
347
+ : "must be a mailbox, a host name, or a host name written as a subtree with a leading dot";
348
+ }
349
+ if (mb === "ambiguous") {
350
+ return "carries more than one at-sign, so the comparison cannot tell which one separates the mailbox";
351
+ }
352
+ if (!_isMailboxLocal(mb[0])) return "must carry the local part of a mailbox before its at-sign";
353
+ if (_isAddressLiteral(mb[1])) return null;
354
+ return _isHostName(stripTrailingDot(mb[1])) ? null
355
+ : "must end in the host name or bracketed address literal of a mailbox";
356
+ }
357
+ if (tag === 2) {
358
+ return _isHostName(_hostConstraintBody(base)) ? null
359
+ : "must be a host name, optionally written as a subtree with a leading dot";
360
+ }
361
+ if (tag === 6) {
362
+ var h = _hostConstraintBody(_toLowerCase(base));
363
+ var dotted = _isHostName(h) && _indexOf(h, ".") !== -1 && !_allCharsIn(h, _DIGDOT_TABLE);
364
+ return dotted ? null
365
+ : "must be a dotted host name, which is the part of a URI a certificate is compared by";
366
+ }
367
+ return null;
368
+ }
369
+
370
+ var _ATV_KEYS = ["type", "value", "name"];
371
+
372
+ /** @internal A distinguished name a caller supplied, copied into fresh plain objects by reading
373
+ * descriptors only. A Proxy answers its own reads and an accessor runs caller code, so either one
374
+ * at any level is refused before anything is copied: a name that decides what it says while it is
375
+ * being read can show a narrow value to a check and a wide one to the use, and where the name is a
376
+ * namespace restriction that is the difference between a certificate being refused and admitted. */
377
+ function copyDnRdns(rdns, E, code, who) {
378
+ assertPlainDnRdns(rdns, E, code, who);
379
+ /** @internal A name of no relative names is a prefix of every name, so as a constraint it reaches
380
+ * the same verdict on all of them. */
381
+ if (rdns.length === 0) throw E(code, who + " must name at least one relative distinguished name");
382
+ var out = [];
383
+ for (var i = 0; i < rdns.length; i++) {
384
+ var rd = intrinsic.getOwnPropertyDescriptor(rdns, i);
385
+ if (rd === undefined) throw E(code, who + " index " + i + " is a hole or is inherited; every entry must be its own");
386
+ var rdn = rd.value;
387
+ if (!_isArray(rdn)) throw E(code, who + "[" + i + "] must be an array of attributes");
388
+ if (rdn.length === 0) throw E(code, who + "[" + i + "] must carry at least one attribute");
389
+ var rdnOut = [];
390
+ for (var j = 0; j < rdn.length; j++) {
391
+ var ad = intrinsic.getOwnPropertyDescriptor(rdn, j);
392
+ if (ad === undefined) throw E(code, who + "[" + i + "] index " + j + " is a hole or is inherited; every entry must be its own");
393
+ var atv = ad.value;
394
+ if (atv === null || typeof atv !== "object") throw E(code, who + "[" + i + "][" + j + "] must be an attribute object carrying a type and a value");
395
+ var atvOut = {};
396
+ for (var k = 0; k < _ATV_KEYS.length; k++) {
397
+ var fd = intrinsic.getOwnPropertyDescriptor(atv, _ATV_KEYS[k]);
398
+ if (fd === undefined) continue;
399
+ intrinsic.defineProperty(atvOut, _ATV_KEYS[k], { value: fd.value, enumerable: true, configurable: true, writable: true });
400
+ }
401
+ if (!_hasOwn(atvOut, "type") || !_hasOwn(atvOut, "value")) {
402
+ throw E(code, who + "[" + i + "][" + j + "] must carry its type and value as own data properties");
403
+ }
404
+ /** @internal Every attribute a certificate's name is compared against is a string compared to
405
+ * a string, so an attribute holding anything else is equal to nothing it will ever meet, and
406
+ * NaN is not even equal to itself. A name built out of those is not a narrower namespace. */
407
+ _assertCanonicalOid(atvOut.type, E, code, who + "[" + i + "][" + j + "].type");
408
+ if (typeof atvOut.value !== "string") {
409
+ throw E(code, who + "[" + i + "][" + j + "].value must be a string, the form a name is compared in");
410
+ }
411
+ assertNoControlBytes(atvOut.value, E, code, who + "[" + i + "][" + j + "].value");
412
+ _append(rdnOut, atvOut);
413
+ }
414
+ _append(out, rdnOut);
415
+ }
416
+ return out;
417
+ }
418
+
419
+ /** @internal The shape check the copy above relies on. */
420
+ function assertPlainDnRdns(rdns, E, code, who) {
421
+ if (intrinsic.types.isProxy(rdns)) throw E(code, who + " must be a plain array, not a Proxy");
422
+ for (var i = 0; i < rdns.length; i++) {
423
+ var rd = intrinsic.getOwnPropertyDescriptor(rdns, i);
424
+ if (rd === undefined) continue;
425
+ if (!_hasOwn(rd, "value")) throw E(code, who + " entry " + i + " must be a data property, not an accessor");
426
+ var rdn = rd.value;
427
+ if (!_isArray(rdn)) continue;
428
+ if (intrinsic.types.isProxy(rdn)) throw E(code, who + "[" + i + "] must be a plain array, not a Proxy");
429
+ for (var j = 0; j < rdn.length; j++) {
430
+ var ad = intrinsic.getOwnPropertyDescriptor(rdn, j);
431
+ if (ad === undefined) continue;
432
+ if (!_hasOwn(ad, "value")) throw E(code, who + "[" + i + "] entry " + j + " must be a data property, not an accessor");
433
+ var atv = ad.value;
434
+ if (atv === null || typeof atv !== "object") continue;
435
+ if (intrinsic.types.isProxy(atv)) throw E(code, who + "[" + i + "][" + j + "] must not be a Proxy");
436
+ if (_isArray(atv)) throw E(code, who + "[" + i + "][" + j + "] must be an attribute object, not an array");
437
+ for (var k = 0; k < _ATV_KEYS.length; k++) {
438
+ var fd = intrinsic.getOwnPropertyDescriptor(atv, _ATV_KEYS[k]);
439
+ if (fd !== undefined && !_hasOwn(fd, "value")) {
440
+ throw E(code, who + "[" + i + "][" + j + "]." + _ATV_KEYS[k] + " must be a data property, not an accessor");
441
+ }
442
+ }
443
+ }
444
+ }
445
+ }
446
+
447
+ /** @internal The `rdns` of a directoryName base, captured the same way. An inherited Proxy answers
448
+ * `in` through its has trap, which is caller code running inside a read meant to be getter-free, so
449
+ * the prototype chain is walked before the property is asked for at all. Returns undefined when the
450
+ * base carries no rdns array, which the caller reads as "not a directoryName base". */
451
+ function capturedRdns(base, E, code, who) {
452
+ if (intrinsic.types.isProxy(base)) throw E(code, who + " must not be a Proxy");
453
+ var baseProto = intrinsic.getPrototypeOf(base);
454
+ while (baseProto !== null) {
455
+ if (intrinsic.types.isProxy(baseProto)) throw E(code, who + " must not inherit from a Proxy");
456
+ baseProto = intrinsic.getPrototypeOf(baseProto);
457
+ }
458
+ var d = intrinsic.getOwnPropertyDescriptor(base, "rdns");
459
+ if (d === undefined) {
460
+ if ("rdns" in base) throw E(code, who + " rdns must be an own data property, not inherited");
461
+ return undefined;
462
+ }
463
+ if (!_hasOwn(d, "value")) throw E(code, who + " rdns must be a data property, not an accessor");
464
+ if (!_isArray(d.value)) return undefined;
465
+ return copyDnRdns(d.value, E, code, who + " rdns");
466
+ }
467
+
200
468
  module.exports = intrinsic.freeze({
469
+ capturedRdns: capturedRdns, copyDnRdns: copyDnRdns,
201
470
  assertNoControlBytes: assertNoControlBytes, assertPrintableIa5: assertPrintableIa5,
202
471
  dnEqual: dnEqual, rdnEqual: rdnEqual, emailEqual: emailEqual, dpnCorresponds: dpnCorresponds,
203
472
  escapeControlBytes: escapeControlBytes, escapeDnValue: escapeDnValue,
204
473
  lowerAscii: lowerAscii,
474
+ stripTrailingDot: stripTrailingDot, isFqdnHost: isFqdnHost, splitMailbox: splitMailbox,
475
+ constraintBaseRefusal: constraintBaseRefusal,
205
476
  });
package/lib/guard-time.js CHANGED
@@ -3,7 +3,9 @@
3
3
  "use strict";
4
4
  // @internal
5
5
 
6
- var util = { types: require("./guard-intrinsic").types };
6
+ var _create = require("./guard-intrinsic").create;
7
+ var _assign = require("./guard-intrinsic").assign;
8
+ var util = _assign(_create(null), { types: require("./guard-intrinsic").types });
7
9
  var _freeze = require("./guard-intrinsic").freeze;
8
10
  var _isNaN = Number.isNaN;
9
11
  var _Date = Date;
package/lib/hpke.js CHANGED
@@ -102,8 +102,8 @@ function _labeledExpand(kdf, suiteId, prk, label, info, len) {
102
102
  }
103
103
 
104
104
 
105
- var OKP_SPKI = { X25519: "302a300506032b656e032100", X448: "3042300506032b656f033900" };
106
- var OKP_PKCS8 = { X25519: "302e020100300506032b656e04220420", X448: "3046020100300506032b656f043a0438" };
105
+ var OKP_SPKI = intrinsic.assign(intrinsic.create(null), { X25519: "302a300506032b656e032100", X448: "3042300506032b656f033900" });
106
+ var OKP_PKCS8 = intrinsic.assign(intrinsic.create(null), { X25519: "302e020100300506032b656e04220420", X448: "3046020100300506032b656f043a0438" });
107
107
 
108
108
  function _importPublic(kem, raw) {
109
109
  if (!Buffer.isBuffer(raw) || raw.length !== kem.Npub) {
@@ -318,9 +318,9 @@ function _recipPrivate(suite, sk) {
318
318
  }
319
319
  }
320
320
 
321
- var _COMMON_KEYS = { mode: 1, info: 1, psk: 1, pskId: 1 };
321
+ var _COMMON_KEYS = intrinsic.assign(intrinsic.create(null), { mode: 1, info: 1, psk: 1, pskId: 1 });
322
322
  function _withCommon(extra) {
323
- var out = {};
323
+ var out = intrinsic.create(null);
324
324
  Object.keys(_COMMON_KEYS).forEach(function (k) { out[k] = 1; });
325
325
  Object.keys(extra).forEach(function (k) { out[k] = 1; });
326
326
  return out;
@@ -348,12 +348,12 @@ function _mode(opts, keys, who) {
348
348
  }
349
349
 
350
350
  // @module @intro; a data registry, not a callable primitive).
351
- var suites = {
352
- KEM: { DHKEM_P256_HKDF_SHA256: 0x0010, DHKEM_P521_HKDF_SHA512: 0x0012, DHKEM_X25519_HKDF_SHA256: 0x0020, DHKEM_X448_HKDF_SHA512: 0x0021 },
353
- KDF: { HKDF_SHA256: 0x0001, HKDF_SHA512: 0x0003 },
354
- AEAD: { AES_128_GCM: 0x0001, AES_256_GCM: 0x0002, CHACHA20_POLY1305: 0x0003, EXPORT_ONLY: 0xFFFF },
355
- MODE: { BASE: MODE_BASE, PSK: MODE_PSK, AUTH: MODE_AUTH, AUTH_PSK: MODE_AUTH_PSK },
356
- };
351
+ var suites = intrinsic.assign(intrinsic.create(null), {
352
+ KEM: intrinsic.assign(intrinsic.create(null), { DHKEM_P256_HKDF_SHA256: 0x0010, DHKEM_P521_HKDF_SHA512: 0x0012, DHKEM_X25519_HKDF_SHA256: 0x0020, DHKEM_X448_HKDF_SHA512: 0x0021 }),
353
+ KDF: intrinsic.assign(intrinsic.create(null), { HKDF_SHA256: 0x0001, HKDF_SHA512: 0x0003 }),
354
+ AEAD: intrinsic.assign(intrinsic.create(null), { AES_128_GCM: 0x0001, AES_256_GCM: 0x0002, CHACHA20_POLY1305: 0x0003, EXPORT_ONLY: 0xFFFF }),
355
+ MODE: intrinsic.assign(intrinsic.create(null), { BASE: MODE_BASE, PSK: MODE_PSK, AUTH: MODE_AUTH, AUTH_PSK: MODE_AUTH_PSK }),
356
+ });
357
357
 
358
358
 
359
359
  /**
@@ -17,10 +17,10 @@ var ALGS = intrinsic.assign(intrinsic.create(null), {
17
17
  "SHA-256": { hash: "sha256", rank: 2, sess: false }, "SHA-256-SESS": { hash: "sha256", rank: 2, sess: true },
18
18
  "MD5": { hash: "md5", rank: 1, sess: false }, "MD5-SESS": { hash: "md5", rank: 1, sess: true },
19
19
  });
20
- var DEFAULT_CODES = {
20
+ var DEFAULT_CODES = intrinsic.assign(intrinsic.create(null), {
21
21
  unsupportedAlgorithm: "digest/unsupported-algorithm", weakAlgorithm: "digest/weak-algorithm",
22
22
  noQop: "digest/no-qop", badChallenge: "digest/bad-challenge",
23
- };
23
+ });
24
24
 
25
25
  function H(hash, s) { return crypto.createHash(hash).update(s, "latin1").digest("hex"); }
26
26
  function KD(hash, secret, data) { return H(hash, secret + ":" + data); }
@@ -440,7 +440,7 @@ function httpsTransport(defaults) {
440
440
  var bodyIsFn = typeof body === "function";
441
441
  if (!bodyIsFn && guard.bytes.isByteSource(body)) body = guard.bytes.source(body, E, C("bad-input"), "the request body");
442
442
 
443
- var reqHeaders = Object.assign({}, request.headers || {});
443
+ var reqHeaders = Object.assign(Object.create(null), request.headers || {});
444
444
  Object.keys(reqHeaders).forEach(function (k) { var lk = k.toLowerCase(); if (lk === "proxy-authorization" || lk === "proxy-connection") delete reqHeaders[k]; });
445
445
  if (bodyIsFn) {
446
446
  Object.keys(reqHeaders).forEach(function (k) { var lk = k.toLowerCase(); if (lk === "content-length" || lk === "transfer-encoding" || lk === "expect") delete reqHeaders[k]; });
@@ -553,7 +553,7 @@ function httpsTransport(defaults) {
553
553
  if (settled) return;
554
554
  settled = true;
555
555
  clearTimer();
556
- var lower = {};
556
+ var lower = Object.create(null);
557
557
  Object.keys(res.headers || {}).forEach(function (k) { lower[k.toLowerCase()] = res.headers[k]; });
558
558
  resolve({
559
559
  status: res.statusCode,
@@ -595,7 +595,7 @@ function httpsTransport(defaults) {
595
595
  if (!prep.proxy) { issue(prep.options); return; }
596
596
 
597
597
  var pinfo = prep.proxy;
598
- var pheaders = { Host: pinfo.originAuthority, Connection: "keep-alive" };
598
+ var pheaders = Object.assign(Object.create(null), { Host: pinfo.originAuthority, Connection: "keep-alive" });
599
599
  if (pinfo.auth) pheaders["Proxy-Authorization"] = _basicProxyHeader(pinfo.auth);
600
600
  var connectOpts = { host: pinfo.host, port: pinfo.port, method: "CONNECT", path: pinfo.originAuthority, headers: pheaders, agent: false };
601
601
  var cr;
package/lib/inspect.js CHANGED
@@ -95,9 +95,9 @@ function _serial(cert, indent) {
95
95
  return "Serial Number:\n" + " ".repeat(indent) + _hexColon(buf, {});
96
96
  }
97
97
 
98
- var CURVE_BITS = { "P-256": 256, "P-384": 384, "P-521": 521, "prime256v1": 256, "secp384r1": 384, "secp521r1": 521 };
98
+ var CURVE_BITS = Object.assign(Object.create(null), { "P-256": 256, "P-384": 384, "P-521": 521, "prime256v1": 256, "secp384r1": 384, "secp521r1": 521 });
99
99
  var NIST_NAME = NAMES.NIST_CURVE;
100
- var RSA_KEY_ALGS = { rsaEncryption: 1, rsassaPss: 1, rsaesOaep: 1 };
100
+ var RSA_KEY_ALGS = Object.assign(Object.create(null), { rsaEncryption: 1, rsassaPss: 1, rsaesOaep: 1 });
101
101
  function _keyBlock(spki, pad) {
102
102
  var algName = _algName(spki.algorithm);
103
103
  var out = [pad + "Public Key Algorithm: " + algName];
@@ -214,7 +214,7 @@ function _renderCrlDp(decoded, inner) {
214
214
  }
215
215
 
216
216
 
217
- var EXT_RENDERERS = {
217
+ var EXT_RENDERERS = Object.assign(Object.create(null), {
218
218
  keyUsage: function (decoded, inner) {
219
219
  return inner + Object.keys(KU_LABEL).filter(function (k) { return decoded[k]; }).map(function (k) { return KU_LABEL[k]; }).join(", ");
220
220
  },
@@ -301,7 +301,7 @@ var EXT_RENDERERS = {
301
301
  cRLDistributionPoints: _renderCrlDp,
302
302
  freshestCRL: _renderCrlDp,
303
303
  authorityInfoAccess: function (decoded, inner) {
304
- var LABEL = { caIssuers: "CA Issuers", ocsp: "OCSP" };
304
+ var LABEL = Object.assign(Object.create(null), { caIssuers: "CA Issuers", ocsp: "OCSP" });
305
305
  return (decoded || []).map(function (ad) {
306
306
  var m = null;
307
307
  try { m = oid.name(ad.accessMethod); } catch (_e) { /* allow:swallow-unverified display best-effort: an unregistered accessMethod OID falls back to the raw dotted OID below (inspection is best-effort, never a verdict) */ }
@@ -369,7 +369,7 @@ var EXT_RENDERERS = {
369
369
  }
370
370
  return akiLines.length ? akiLines.join("\n") : inner + "keyid:(none)";
371
371
  },
372
- };
372
+ });
373
373
  EXT_RENDERERS.msApplicationPolicies = EXT_RENDERERS.certificatePolicies;
374
374
 
375
375
 
@@ -378,7 +378,7 @@ function _renderExtValue(ext, decoded, inner) {
378
378
  return fn ? fn(decoded, inner) : null;
379
379
  }
380
380
 
381
- var _STRING_TAGS = { 12: 1, 19: 1, 22: 1, 20: 1, 26: 1, 27: 1, 30: 1 };
381
+ var _STRING_TAGS = Object.assign(Object.create(null), { 12: 1, 19: 1, 22: 1, 20: 1, 26: 1, 27: 1, 30: 1 });
382
382
  function _printable(buf) {
383
383
  return buf.length > 0 && buf.every(function (b) { return b >= 0x20 && b < 0x7f; });
384
384
  }
@@ -499,7 +499,7 @@ function _looksParsedCms(o) {
499
499
  var shape = _CMS_SHAPE[o.contentType];
500
500
  return shape ? shape(o) : false;
501
501
  }
502
- var _INSPECT_ENTRY = { pemLabel: null, PemError: InspectError, ErrorClass: InspectError, prefix: "inspect" };
502
+ var _INSPECT_ENTRY = Object.assign(Object.create(null), { pemLabel: null, PemError: InspectError, ErrorClass: InspectError, prefix: "inspect" });
503
503
  function _coerce(input, spec) {
504
504
  if (input && typeof input === "object" && !Buffer.isBuffer(input) && !(input instanceof Uint8Array) && input[spec.marker] !== undefined) {
505
505
  if (!spec.looksParsed(input)) throw _err("inspect/bad-input", "input has a " + spec.marker + " property but is not a complete " + spec.parsedName + " result");
@@ -657,7 +657,7 @@ function csrReport(input) {
657
657
 
658
658
  var OID_SIGNED_DATA = oid.byName("signedData");
659
659
  function _isObj(x) { return !!x && typeof x === "object"; }
660
- var _CMS_SHAPE = {};
660
+ var _CMS_SHAPE = Object.create(null);
661
661
  _CMS_SHAPE[OID_SIGNED_DATA] = function (o) { return Array.isArray(o.digestAlgorithms) && _isObj(o.encapContentInfo) && Array.isArray(o.signerInfos); };
662
662
  _CMS_SHAPE[oid.byName("envelopedData")] = function (o) { return Array.isArray(o.recipientInfos) && _isObj(o.encryptedContentInfo); };
663
663
  _CMS_SHAPE[oid.byName("encryptedData")] = function (o) { return _isObj(o.encryptedContentInfo); };
@@ -784,7 +784,7 @@ function cmsReport(input) {
784
784
  }
785
785
 
786
786
 
787
- var _INSPECT_BY_FORMAT = { x509: certificate, crl: crlReport, csr: csrReport, cms: cmsReport };
787
+ var _INSPECT_BY_FORMAT = Object.assign(Object.create(null), { x509: certificate, crl: crlReport, csr: csrReport, cms: cmsReport });
788
788
 
789
789
  /**
790
790
  * @primitive pki.inspect.any