@blamejs/core 0.18.37 → 0.18.39

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.
@@ -1,4 +1,4 @@
1
- // @blamejs/pki v0.5.10 — vendored (Apache-2.0). Zero-dep pure CJS.
1
+ // @blamejs/pki v0.5.11 — vendored (Apache-2.0). Zero-dep pure CJS.
2
2
  // https://github.com/blamejs/pki Exports: x509, crl, pkcs12, key, webcrypto, schema, csr, cms, ...
3
3
  // Backs lib/mtls-engine-default.js (PQC-capable CA + PKCS#12 engine).
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -141,7 +141,7 @@ var require_package = __commonJS({
141
141
  "node_modules/@blamejs/pki/package.json"(exports2, module2) {
142
142
  module2.exports = {
143
143
  name: "@blamejs/pki",
144
- version: "0.5.10",
144
+ version: "0.5.11",
145
145
  description: "Pure-JavaScript PKI toolkit that owns its stack \u2014 X.509, ASN.1/DER, CMS, PQC-first.",
146
146
  license: "Apache-2.0",
147
147
  author: "blamejs contributors",
@@ -713,6 +713,384 @@ var require_guard_async = __commonJS({
713
713
  }
714
714
  });
715
715
 
716
+ // node_modules/@blamejs/pki/lib/guard-identifier.js
717
+ var require_guard_identifier = __commonJS({
718
+ "node_modules/@blamejs/pki/lib/guard-identifier.js"(exports2, module2) {
719
+ "use strict";
720
+ var util = require("util");
721
+ function _isDottedDecimal(str) {
722
+ if (str.length === 0) return false;
723
+ var arcs = 0, digits = 0, leadingZero = false;
724
+ for (var i = 0; i < str.length; i++) {
725
+ var c = str.charCodeAt(i);
726
+ if (c === 46) {
727
+ if (digits === 0 || leadingZero) return false;
728
+ arcs++;
729
+ digits = 0;
730
+ leadingZero = false;
731
+ continue;
732
+ }
733
+ if (c < 48 || c > 57) return false;
734
+ if (digits === 1 && str.charCodeAt(i - 1) === 48) leadingZero = true;
735
+ digits++;
736
+ }
737
+ if (digits === 0 || leadingZero) return false;
738
+ return arcs >= 1;
739
+ }
740
+ function assertCanonicalOid(str, E, code, label, boundsCode) {
741
+ var who = label || "OID";
742
+ if (typeof str !== "string" || !_isDottedDecimal(str)) {
743
+ throw E(code, who + " must be a canonical dotted-decimal OID string of two or more arcs with no leading-zero component");
744
+ }
745
+ if (boundsCode === null) return str;
746
+ var bcode = boundsCode === void 0 ? code : boundsCode;
747
+ var parts = str.split(".");
748
+ var root = BigInt(parts[0]);
749
+ var second = BigInt(parts[1]);
750
+ if (root > 2n) throw E(bcode, who + " root arc must be 0, 1, or 2 (X.660)");
751
+ if (root < 2n && second > 39n) throw E(bcode, who + " second arc must be 0..39 under roots 0 and 1 (X.660)");
752
+ return str;
753
+ }
754
+ function assertKnownKeys(obj, known, E, code, message) {
755
+ _refuseUnenumerable(obj, E, code, "the options");
756
+ var describe = typeof message === "function" ? message : function(k) {
757
+ return message + JSON.stringify(k);
758
+ };
759
+ _readableNames(obj).forEach(function(k) {
760
+ if (Object.prototype.hasOwnProperty.call(known, k)) return;
761
+ throw E(code, describe(typeof k === "symbol" ? String(k) : k));
762
+ });
763
+ }
764
+ var _PRISTINE_OBJECT_PROTO = (function() {
765
+ var s = /* @__PURE__ */ Object.create(null);
766
+ [
767
+ "constructor",
768
+ "hasOwnProperty",
769
+ "isPrototypeOf",
770
+ "propertyIsEnumerable",
771
+ "toLocaleString",
772
+ "toString",
773
+ "valueOf",
774
+ "__defineGetter__",
775
+ "__defineSetter__",
776
+ "__lookupGetter__",
777
+ "__lookupSetter__",
778
+ "__proto__"
779
+ ].forEach(function(k) {
780
+ s[k] = 1;
781
+ });
782
+ return s;
783
+ })();
784
+ function _looksBuiltIn(d) {
785
+ return !!d && (!!d.get || !!d.set || typeof d.value === "function");
786
+ }
787
+ function _requireFactory(E) {
788
+ if (typeof E !== "function") {
789
+ throw new TypeError("guard.identifier needs an error factory called as E(code, message); a class is not one, so adapt it at the call site");
790
+ }
791
+ }
792
+ function _refuseUnenumerable(v, E, code, label) {
793
+ _requireFactory(E);
794
+ if (v === null || typeof v !== "object") return;
795
+ var visited = /* @__PURE__ */ new Set();
796
+ for (var o = v; o && !visited.has(o); o = Object.getPrototypeOf(o)) {
797
+ visited.add(o);
798
+ if (!util.types.isProxy(o)) continue;
799
+ throw E(code, label + (o === v ? " is" : " inherits from") + " a Proxy, whose reported keys need not match what it answers, so an option it holds cannot be found; pass a plain object");
800
+ }
801
+ }
802
+ function _isMethodOf(from, k, fn) {
803
+ var visited = /* @__PURE__ */ new Set();
804
+ for (var o = from; o && !visited.has(o); o = Object.getPrototypeOf(o)) {
805
+ visited.add(o);
806
+ var d = Object.getOwnPropertyDescriptor(o, k);
807
+ if (!d) continue;
808
+ return !d.get && !d.set && d.value === fn;
809
+ }
810
+ return false;
811
+ }
812
+ function _isArrayIndex(k) {
813
+ var n = Number(k);
814
+ return Number.isInteger(n) && n >= 0 && n < 4294967295 && String(n) === k;
815
+ }
816
+ function _isIndexedKind(v) {
817
+ return Array.isArray(v) || ArrayBuffer.isView(v) && !util.types.isDataView(v);
818
+ }
819
+ var _ARRAY_PROTO_MEMBERS = ["length", Symbol.unscopables];
820
+ var _REGEXP_PROTO_MEMBERS = [
821
+ "source",
822
+ "flags",
823
+ "global",
824
+ "ignoreCase",
825
+ "multiline",
826
+ "dotAll",
827
+ "unicode",
828
+ "unicodeSets",
829
+ "sticky",
830
+ "hasIndices"
831
+ ];
832
+ var _SIZED_PROTO_MEMBERS = ["size", Symbol.toStringTag];
833
+ var _WEAK_PROTO_MEMBERS = [Symbol.toStringTag];
834
+ var _ARRAYBUFFER_PROTO_MEMBERS = [
835
+ "byteLength",
836
+ "maxByteLength",
837
+ "resizable",
838
+ "detached",
839
+ Symbol.toStringTag
840
+ ];
841
+ var _SHARED_PROTO_MEMBERS = ["byteLength", "maxByteLength", "growable", Symbol.toStringTag];
842
+ var _DATAVIEW_PROTO_MEMBERS = ["buffer", "byteLength", "byteOffset", Symbol.toStringTag];
843
+ var _TYPED_PROTO_MEMBERS = ["buffer", "byteLength", "byteOffset", "length", Symbol.toStringTag];
844
+ var _CONCRETE_TYPED_MEMBERS = ["BYTES_PER_ELEMENT"];
845
+ var _BUFFER_PROTO_MEMBERS = ["parent", "offset"];
846
+ var _ARRAY_MEMBERS = _ARRAY_PROTO_MEMBERS;
847
+ var _REGEXP_MEMBERS = ["lastIndex"].concat(_REGEXP_PROTO_MEMBERS);
848
+ var _VIEW_MEMBERS = _TYPED_PROTO_MEMBERS.concat(_CONCRETE_TYPED_MEMBERS);
849
+ var _BUFFER_KIND_MEMBERS = _VIEW_MEMBERS.concat(_BUFFER_PROTO_MEMBERS);
850
+ var _DATAVIEW_MEMBERS = _DATAVIEW_PROTO_MEMBERS;
851
+ var _ARRAYBUFFER_MEMBERS = _ARRAYBUFFER_PROTO_MEMBERS;
852
+ var _SHARED_MEMBERS = _SHARED_PROTO_MEMBERS;
853
+ var _TYPED_ARRAY_PROTO = Object.getPrototypeOf(Uint8Array.prototype);
854
+ var _INTRINSIC_HOLDERS = (function() {
855
+ var m = /* @__PURE__ */ new Map([[_TYPED_ARRAY_PROTO, _TYPED_PROTO_MEMBERS]]);
856
+ function pair(ctor, members) {
857
+ if (ctor && ctor.prototype) m.set(ctor.prototype, members);
858
+ }
859
+ pair(Array, _ARRAY_PROTO_MEMBERS);
860
+ pair(RegExp, _REGEXP_PROTO_MEMBERS);
861
+ [Map, Set].forEach(function(c) {
862
+ pair(c, _SIZED_PROTO_MEMBERS);
863
+ });
864
+ [WeakMap, WeakSet].forEach(function(c) {
865
+ pair(c, _WEAK_PROTO_MEMBERS);
866
+ });
867
+ pair(ArrayBuffer, _ARRAYBUFFER_PROTO_MEMBERS);
868
+ pair(typeof SharedArrayBuffer === "function" ? SharedArrayBuffer : null, _SHARED_PROTO_MEMBERS);
869
+ pair(DataView, _DATAVIEW_PROTO_MEMBERS);
870
+ pair(Buffer, _BUFFER_PROTO_MEMBERS);
871
+ Object.getOwnPropertyNames(globalThis).forEach(function(n) {
872
+ var C;
873
+ try {
874
+ C = globalThis[n];
875
+ } catch (_e) {
876
+ return;
877
+ }
878
+ if (typeof C !== "function" || typeof C.BYTES_PER_ELEMENT !== "number") return;
879
+ if (!C.prototype || Object.getPrototypeOf(C.prototype) !== _TYPED_ARRAY_PROTO) return;
880
+ m.set(C.prototype, _CONCRETE_TYPED_MEMBERS);
881
+ });
882
+ return m;
883
+ })();
884
+ function _holderMembers(o) {
885
+ return _INTRINSIC_HOLDERS.has(o) ? _INTRINSIC_HOLDERS.get(o) : null;
886
+ }
887
+ function _isNodeBuffer(v) {
888
+ if (!util.types.isUint8Array(v)) return false;
889
+ var visited = /* @__PURE__ */ new Set();
890
+ for (var o = v; o && !visited.has(o); o = Object.getPrototypeOf(o)) {
891
+ visited.add(o);
892
+ if (o === Buffer.prototype) return true;
893
+ }
894
+ return false;
895
+ }
896
+ function _kindMembers(v) {
897
+ if (v === null || v === void 0) return [];
898
+ if (Array.isArray(v)) return _ARRAY_MEMBERS;
899
+ if (_isNodeBuffer(v)) return _BUFFER_KIND_MEMBERS;
900
+ if (util.types.isDataView(v)) return _DATAVIEW_MEMBERS;
901
+ if (ArrayBuffer.isView(v)) return _VIEW_MEMBERS;
902
+ if (util.types.isArrayBuffer(v)) return _ARRAYBUFFER_MEMBERS;
903
+ if (util.types.isSharedArrayBuffer(v)) return _SHARED_MEMBERS;
904
+ if (util.types.isRegExp(v)) return _REGEXP_MEMBERS;
905
+ if (util.types.isWeakMap(v) || util.types.isWeakSet(v)) return _WEAK_PROTO_MEMBERS;
906
+ if (util.types.isMap(v) || util.types.isSet(v)) return _SIZED_PROTO_MEMBERS;
907
+ return [];
908
+ }
909
+ function _isOwnStructuralName(v, k) {
910
+ return util.types.isRegExp(v) && k === "lastIndex";
911
+ }
912
+ function _looksIntrinsic(d) {
913
+ return !!d && (!!d.get || !!d.set || typeof d.value === "function" || d.writable === false || d.configurable === false);
914
+ }
915
+ function _shadowsAnother(v, k, holder) {
916
+ var visited = /* @__PURE__ */ new Set();
917
+ var past = false;
918
+ for (var o = v; o !== null && o !== void 0 && !visited.has(o); o = Object.getPrototypeOf(o)) {
919
+ visited.add(o);
920
+ if (o === holder) {
921
+ past = true;
922
+ continue;
923
+ }
924
+ if (past && Object.getOwnPropertyDescriptor(o, k)) return true;
925
+ }
926
+ return false;
927
+ }
928
+ function _readableNames(obj) {
929
+ var seen = /* @__PURE__ */ Object.create(null);
930
+ var out = [];
931
+ var o = obj === null || obj === void 0 ? null : Object(obj);
932
+ var indexedSelf = _isIndexedKind(o);
933
+ var members = _kindMembers(o);
934
+ var visited = /* @__PURE__ */ new Set();
935
+ while (o && !visited.has(o)) {
936
+ visited.add(o);
937
+ var inherited = o !== obj;
938
+ var above = Object.getPrototypeOf(o);
939
+ var atObjectProto = inherited && above === null;
940
+ Reflect.ownKeys(o).forEach(function(k) {
941
+ if (seen[k]) return;
942
+ if (indexedSelf && typeof k === "string" && _isArrayIndex(k)) return;
943
+ if (indexedSelf && k === "length" && !inherited) return;
944
+ if (_isOwnStructuralName(obj, k)) return;
945
+ var d = Object.getOwnPropertyDescriptor(o, k);
946
+ var here = _holderMembers(o);
947
+ if (inherited && _looksIntrinsic(d) && !_shadowsAnother(obj, k, o) && (here === null ? members.indexOf(k) !== -1 : here.indexOf(k) !== -1)) return;
948
+ if (atObjectProto) {
949
+ if (_PRISTINE_OBJECT_PROTO[k] && _looksBuiltIn(d)) return;
950
+ seen[k] = 1;
951
+ out.push(k);
952
+ return;
953
+ }
954
+ if (d && !d.get && !d.set && typeof d.value === "function" && (inherited || _isMethodOf(above, k, d.value))) return;
955
+ seen[k] = 1;
956
+ out.push(k);
957
+ });
958
+ o = above;
959
+ }
960
+ return out;
961
+ }
962
+ function readableNames(obj, E, code, label) {
963
+ _refuseUnenumerable(obj, E, code, label);
964
+ return _readableNames(obj);
965
+ }
966
+ function readableIndices(obj, E, code, label) {
967
+ _refuseUnenumerable(obj, E, code, label);
968
+ if (!Array.isArray(obj)) return [];
969
+ var own = Object.getOwnPropertyDescriptor(obj, "length");
970
+ var limit = own ? own.value : 0;
971
+ var seen = /* @__PURE__ */ Object.create(null);
972
+ var out = [];
973
+ var visited = /* @__PURE__ */ new Set();
974
+ for (var o = obj; o && !visited.has(o); o = Object.getPrototypeOf(o)) {
975
+ visited.add(o);
976
+ Reflect.ownKeys(o).forEach(function(k) {
977
+ if (typeof k !== "string" || !_isArrayIndex(k) || seen[k]) return;
978
+ if (Number(k) >= limit) return;
979
+ seen[k] = 1;
980
+ out.push(k);
981
+ });
982
+ }
983
+ return out.sort(function(a, b) {
984
+ return Number(a) - Number(b);
985
+ });
986
+ }
987
+ function _notAnOptionsBag(v) {
988
+ if (util.types.isBoxedPrimitive(v)) return "a boxed primitive";
989
+ if (util.types.isNativeError(v)) return "an Error";
990
+ if (util.types.isPromise(v)) return "a Promise";
991
+ if (util.types.isArgumentsObject(v)) return "an arguments object";
992
+ return null;
993
+ }
994
+ function optionsObject(opts, E, code, label) {
995
+ if (opts === null || opts === void 0) return /* @__PURE__ */ Object.create(null);
996
+ if (typeof opts !== "object") throw E(code, label + " must be an object");
997
+ _refuseUnenumerable(opts, E, code, label);
998
+ if (_isNodeBuffer(opts)) throw E(code, label + " must be an object");
999
+ var wrong = _notAnOptionsBag(opts);
1000
+ if (wrong) throw E(code, label + ": " + wrong + " is not an options bag; pass a plain object");
1001
+ return _settle(opts, E, code, label);
1002
+ }
1003
+ function _descriptorHolder(v, k) {
1004
+ var visited = /* @__PURE__ */ new Set();
1005
+ for (var o = v; o !== null && o !== void 0 && !visited.has(o); o = Object.getPrototypeOf(o)) {
1006
+ visited.add(o);
1007
+ var d = Object.getOwnPropertyDescriptor(o, k);
1008
+ if (d) return d;
1009
+ }
1010
+ return null;
1011
+ }
1012
+ function refuseAccessorFields(obj, names, E, code, label) {
1013
+ for (var i = 0; i < names.length; i++) {
1014
+ var holder = _descriptorHolder(obj, names[i]);
1015
+ if (holder && (holder.get || holder.set)) {
1016
+ throw E(code, label + " supplies " + JSON.stringify(typeof names[i] === "symbol" ? String(names[i]) : names[i]) + " through an accessor, whose value can differ between the check and the read; pass an object whose fields are plain values");
1017
+ }
1018
+ }
1019
+ }
1020
+ function _settle(opts, E, code, label) {
1021
+ function readAll(names) {
1022
+ for (var i = 0; i < names.length; i++) {
1023
+ try {
1024
+ void opts[names[i]];
1025
+ } catch (_e) {
1026
+ throw E(code, label + ": reading " + JSON.stringify(typeof names[i] === "symbol" ? String(names[i]) : names[i]) + " threw");
1027
+ }
1028
+ }
1029
+ }
1030
+ var before = _readableNames(opts);
1031
+ refuseAccessorFields(opts, before, E, code, label);
1032
+ readAll(before);
1033
+ var after = _readableNames(opts);
1034
+ var same = after.length === before.length;
1035
+ for (var j = 0; same && j < after.length; j++) same = before.indexOf(after[j]) !== -1;
1036
+ if (!same) {
1037
+ throw E(code, label + " changes which options it carries while they are read, so no set of them can be checked; pass an object whose properties are plain values");
1038
+ }
1039
+ return opts;
1040
+ }
1041
+ module2.exports = {
1042
+ assertCanonicalOid,
1043
+ assertKnownKeys,
1044
+ optionsObject,
1045
+ refuseAccessorFields,
1046
+ // Exported so a caller that forwards an options bag copies the same surface this module
1047
+ // accepts. A narrower enumeration such as `Object.keys` admits a name here and then drops
1048
+ // it on the way, which is worse than refusing it. The option is reported valid and then
1049
+ // does nothing at the place it was meant to act.
1050
+ readableNames,
1051
+ // Exported for the same reason as its sibling: a caller copying an array has to reach the
1052
+ // elements a read reaches, and the own keys are not that set.
1053
+ readableIndices
1054
+ };
1055
+ }
1056
+ });
1057
+
1058
+ // node_modules/@blamejs/pki/lib/guard-time.js
1059
+ var require_guard_time = __commonJS({
1060
+ "node_modules/@blamejs/pki/lib/guard-time.js"(exports2, module2) {
1061
+ "use strict";
1062
+ var util = require("util");
1063
+ var _dateGetTime = Date.prototype.getTime;
1064
+ function instantOf(value) {
1065
+ return _dateGetTime.call(value);
1066
+ }
1067
+ function assertValid(value, E, code, label) {
1068
+ if (!util.types.isDate(value) || isNaN(instantOf(value))) {
1069
+ throw E(code, (label || "value") + " must be a valid Date");
1070
+ }
1071
+ return value;
1072
+ }
1073
+ function within(instant, lower, upper, E, code, label, opts) {
1074
+ assertValid(instant, E, code, label);
1075
+ assertValid(lower, E, code, (label || "window") + " lower bound");
1076
+ assertValid(upper, E, code, (label || "window") + " upper bound");
1077
+ var t = instantOf(instant);
1078
+ var lo = instantOf(lower);
1079
+ var hi = instantOf(upper);
1080
+ return t >= lo && (opts && opts.upperInclusive ? t <= hi : t < hi);
1081
+ }
1082
+ function isDate(value) {
1083
+ return util.types.isDate(value);
1084
+ }
1085
+ module2.exports = {
1086
+ assertValid,
1087
+ instantOf,
1088
+ isDate,
1089
+ within
1090
+ };
1091
+ }
1092
+ });
1093
+
716
1094
  // node_modules/@blamejs/pki/lib/oid.js
717
1095
  var require_oid = __commonJS({
718
1096
  "node_modules/@blamejs/pki/lib/oid.js"(exports2, module2) {
@@ -2482,10 +2860,11 @@ var require_webcrypto = __commonJS({
2482
2860
  if (!ArrayBuffer.isView(typedArray) || typedArray instanceof Float32Array || typedArray instanceof Float64Array || typedArray instanceof DataView) {
2483
2861
  throw new WebCryptoError("webcrypto/data", "getRandomValues: expected an integer TypedArray");
2484
2862
  }
2485
- if (typedArray.byteLength > MAX_RANDOM_BYTES) {
2863
+ var out = guard.bytes.outputView(typedArray, WebCryptoError, "webcrypto/data", "getRandomValues");
2864
+ if (out.length > MAX_RANDOM_BYTES) {
2486
2865
  throw new WebCryptoError("webcrypto/data", "getRandomValues: byteLength exceeds " + MAX_RANDOM_BYTES);
2487
2866
  }
2488
- nodeCrypto.randomFillSync(guard.bytes.source(typedArray, WebCryptoError, "webcrypto/data", "getRandomValues"));
2867
+ nodeCrypto.randomFillSync(out);
2489
2868
  return typedArray;
2490
2869
  };
2491
2870
  Crypto.prototype.randomUUID = function randomUUID() {
@@ -2569,8 +2948,9 @@ var require_guard_parsed = __commonJS({
2569
2948
  "node_modules/@blamejs/pki/lib/guard-parsed.js"(exports2, module2) {
2570
2949
  "use strict";
2571
2950
  var bytes = require_guard_bytes();
2951
+ var time = require_guard_time();
2572
2952
  function _isBytes(x) {
2573
- return Buffer.isBuffer(x) || ArrayBuffer.isView(x) || x instanceof ArrayBuffer;
2953
+ return bytes.isByteSource(x);
2574
2954
  }
2575
2955
  function _isAttributeTypeAndValue(a) {
2576
2956
  return !!a && typeof a.type === "string" && _isOptName(a.name) && typeof a.value === "string";
@@ -2602,11 +2982,11 @@ var require_guard_parsed = __commonJS({
2602
2982
  return !!e && typeof e.oid === "string" && _isOptName(e.name) && typeof e.critical === "boolean" && e.value !== void 0;
2603
2983
  }
2604
2984
  function isCert(o) {
2605
- return !!o && typeof o === "object" && Buffer.isBuffer(o.tbsBytes) && typeof o.version === "number" && typeof o.serialNumber === "bigint" && typeof o.serialNumberHex === "string" && _isAlgorithmIdentifier(o.signatureAlgorithm) && _isAlgorithmIdentifier(o.tbsSignatureAlgorithm) && _isBitString(o.signatureValue) && !!o.validity && o.validity.notBefore instanceof Date && o.validity.notAfter instanceof Date && _isName(o.issuer) && _isName(o.subject) && !!o.subjectPublicKeyInfo && Buffer.isBuffer(o.subjectPublicKeyInfo.bytes) && _isAlgorithmIdentifier(o.subjectPublicKeyInfo.algorithm) && _isBitString(o.subjectPublicKeyInfo.publicKey) && Array.isArray(o.extensions) && o.extensions.every(_isExtensionEntry);
2985
+ return !!o && typeof o === "object" && Buffer.isBuffer(o.tbsBytes) && typeof o.version === "number" && typeof o.serialNumber === "bigint" && typeof o.serialNumberHex === "string" && _isAlgorithmIdentifier(o.signatureAlgorithm) && _isAlgorithmIdentifier(o.tbsSignatureAlgorithm) && _isBitString(o.signatureValue) && !!o.validity && time.isDate(o.validity.notBefore) && time.isDate(o.validity.notAfter) && _isName(o.issuer) && _isName(o.subject) && !!o.subjectPublicKeyInfo && Buffer.isBuffer(o.subjectPublicKeyInfo.bytes) && _isAlgorithmIdentifier(o.subjectPublicKeyInfo.algorithm) && _isBitString(o.subjectPublicKeyInfo.publicKey) && Array.isArray(o.extensions) && o.extensions.every(_isExtensionEntry);
2606
2986
  }
2607
2987
  function isCrl(o) {
2608
- return !!o && typeof o === "object" && Buffer.isBuffer(o.tbsBytes) && typeof o.version === "number" && _isAlgorithmIdentifier(o.signatureAlgorithm) && _isBitString(o.signatureValue) && _isName(o.issuer) && o.thisUpdate instanceof Date && (o.nextUpdate === null || o.nextUpdate instanceof Date) && Array.isArray(o.crlExtensions) && o.crlExtensions.every(_isCrlExtensionEntry) && Array.isArray(o.revokedCertificates) && o.revokedCertificates.every(function(e) {
2609
- return !!e && typeof e.serialNumber === "bigint" && typeof e.serialNumberHex === "string" && e.revocationDate instanceof Date && Array.isArray(e.crlEntryExtensions) && e.crlEntryExtensions.every(_isCrlExtensionEntry);
2988
+ return !!o && typeof o === "object" && Buffer.isBuffer(o.tbsBytes) && typeof o.version === "number" && _isAlgorithmIdentifier(o.signatureAlgorithm) && _isBitString(o.signatureValue) && _isName(o.issuer) && time.isDate(o.thisUpdate) && (o.nextUpdate === null || time.isDate(o.nextUpdate)) && Array.isArray(o.crlExtensions) && o.crlExtensions.every(_isCrlExtensionEntry) && Array.isArray(o.revokedCertificates) && o.revokedCertificates.every(function(e) {
2989
+ return !!e && typeof e.serialNumber === "bigint" && typeof e.serialNumberHex === "string" && time.isDate(e.revocationDate) && Array.isArray(e.crlEntryExtensions) && e.crlEntryExtensions.every(_isCrlExtensionEntry);
2610
2990
  });
2611
2991
  }
2612
2992
  function _safe(shape) {
@@ -2803,13 +3183,102 @@ var require_guard_bytes = __commonJS({
2803
3183
  "node_modules/@blamejs/pki/lib/guard-bytes.js"(exports2, module2) {
2804
3184
  "use strict";
2805
3185
  var async = require_guard_async();
3186
+ var identifier = require_guard_identifier();
3187
+ var time = require_guard_time();
3188
+ var util = require("util");
3189
+ function isByteSource(x) {
3190
+ return Buffer.isBuffer(x) || ArrayBuffer.isView(x) || _isArrayBuffer(x);
3191
+ }
3192
+ function _isArrayBuffer(v) {
3193
+ return util.types.isArrayBuffer(v);
3194
+ }
3195
+ var _TYPED_ARRAY_PROTO = Object.getPrototypeOf(Uint8Array.prototype);
3196
+ function _intrinsicGetter(proto, name, who) {
3197
+ var d = Object.getOwnPropertyDescriptor(proto, name);
3198
+ if (!d || typeof d.get !== "function") {
3199
+ throw new TypeError("guard.bytes: this runtime has no intrinsic " + who + "." + name + " accessor, so a view's backing store cannot be read without invoking the value's own");
3200
+ }
3201
+ return d.get;
3202
+ }
3203
+ var _taBuffer = _intrinsicGetter(_TYPED_ARRAY_PROTO, "buffer", "%TypedArray%.prototype");
3204
+ var _taByteOffset = _intrinsicGetter(_TYPED_ARRAY_PROTO, "byteOffset", "%TypedArray%.prototype");
3205
+ var _taByteLength = _intrinsicGetter(_TYPED_ARRAY_PROTO, "byteLength", "%TypedArray%.prototype");
3206
+ var _dvBuffer = _intrinsicGetter(DataView.prototype, "buffer", "DataView.prototype");
3207
+ var _dvByteOffset = _intrinsicGetter(DataView.prototype, "byteOffset", "DataView.prototype");
3208
+ var _dvByteLength = _intrinsicGetter(DataView.prototype, "byteLength", "DataView.prototype");
3209
+ function _storeOf(v) {
3210
+ return util.types.isDataView(v) ? _dvBuffer.call(v) : _taBuffer.call(v);
3211
+ }
3212
+ function _offsetOf(v) {
3213
+ return util.types.isDataView(v) ? _dvByteOffset.call(v) : _taByteOffset.call(v);
3214
+ }
3215
+ function _lengthOf(v) {
3216
+ return util.types.isDataView(v) ? _dvByteLength.call(v) : _taByteLength.call(v);
3217
+ }
3218
+ function _reView(v) {
3219
+ return Buffer.from(_storeOf(v), _offsetOf(v), _lengthOf(v));
3220
+ }
3221
+ var _CONCRETE_KINDS = Object.keys(util.types).filter(function(name) {
3222
+ return /^is[A-Za-z0-9]+Array$/.test(name);
3223
+ }).map(function(name) {
3224
+ return [util.types[name], globalThis[name.slice(2)]];
3225
+ }).filter(function(row) {
3226
+ return typeof row[0] === "function" && typeof row[1] === "function" && typeof row[1].BYTES_PER_ELEMENT === "number" && row[1].BYTES_PER_ELEMENT > 0;
3227
+ });
3228
+ function _concreteKindOf(v) {
3229
+ for (var i = 0; i < _CONCRETE_KINDS.length; i++) {
3230
+ if (_CONCRETE_KINDS[i][0](v)) return _CONCRETE_KINDS[i][1];
3231
+ }
3232
+ return null;
3233
+ }
3234
+ var _NAMED_KINDS = [
3235
+ ["isNativeError", "Error"],
3236
+ ["isRegExp", "RegExp"],
3237
+ ["isPromise", "Promise"],
3238
+ ["isWeakMap", "WeakMap"],
3239
+ ["isWeakSet", "WeakSet"],
3240
+ ["isMap", "Map"],
3241
+ ["isSet", "Set"],
3242
+ ["isDate", "Date"],
3243
+ ["isProxy", "Proxy"]
3244
+ ].filter(function(row) {
3245
+ return typeof util.types[row[0]] === "function";
3246
+ });
3247
+ function _kindName(v) {
3248
+ for (var i = 0; i < _NAMED_KINDS.length; i++) {
3249
+ if (util.types[_NAMED_KINDS[i][0]](v)) return _NAMED_KINDS[i][1];
3250
+ }
3251
+ return typeof v === "function" ? "function" : "value";
3252
+ }
3253
+ function _article(name) {
3254
+ return /^[AEIOU]/i.test(name) ? "an" : "a";
3255
+ }
3256
+ function outputView(input, ErrorClass, code, label) {
3257
+ if (!util.types.isUint8Array(input) && !ArrayBuffer.isView(input)) {
3258
+ throw _raise(ErrorClass, code, label + ": expected a Buffer / TypedArray to write into");
3259
+ }
3260
+ try {
3261
+ return _reView(input);
3262
+ } catch (e) {
3263
+ throw _raise(ErrorClass, code, label + ": output is not a usable byte view (detached backing buffer?)", e);
3264
+ }
3265
+ }
3266
+ function lengthOf(view2) {
3267
+ return _lengthOf(view2);
3268
+ }
3269
+ function _refuseShared(v, ErrorClass, code, label) {
3270
+ if (util.types.isSharedArrayBuffer(v) || ArrayBuffer.isView(v) && util.types.isSharedArrayBuffer(_storeOf(v))) {
3271
+ throw _raise(ErrorClass, code, label + ": shared memory cannot be used here, because another thread can rewrite it after it has been checked; pass a Buffer or a Uint8Array over memory this process owns");
3272
+ }
3273
+ }
2806
3274
  function _raise(E, code, message, cause) {
2807
3275
  return E.prototype instanceof Error ? new E(code, message, cause) : E(code, message, cause);
2808
3276
  }
2809
3277
  function view(input, ErrorClass, code, label) {
2810
- if (Buffer.isBuffer(input) || input instanceof Uint8Array) {
3278
+ _refuseShared(input, ErrorClass, code, label);
3279
+ if (util.types.isUint8Array(input)) {
2811
3280
  try {
2812
- return Buffer.from(input.buffer, input.byteOffset, input.byteLength);
3281
+ return _reView(input);
2813
3282
  } catch (e) {
2814
3283
  throw _raise(ErrorClass, code, label + ": input is not a usable byte view (detached backing buffer?)", e);
2815
3284
  }
@@ -2817,10 +3286,11 @@ var require_guard_bytes = __commonJS({
2817
3286
  throw _raise(ErrorClass, code, label + ": expected a Buffer / Uint8Array");
2818
3287
  }
2819
3288
  function source(input, ErrorClass, code, label) {
2820
- var isAb = input instanceof ArrayBuffer;
3289
+ _refuseShared(input, ErrorClass, code, label);
3290
+ var isAb = _isArrayBuffer(input);
2821
3291
  if (isAb || ArrayBuffer.isView(input)) {
2822
3292
  try {
2823
- return isAb ? Buffer.from(input) : Buffer.from(input.buffer, input.byteOffset, input.byteLength);
3293
+ return isAb ? Buffer.from(input) : _reView(input);
2824
3294
  } catch (e) {
2825
3295
  throw _raise(ErrorClass, code, label + ": input is not a usable byte source (detached backing buffer?)", e);
2826
3296
  }
@@ -2838,29 +3308,52 @@ var require_guard_bytes = __commonJS({
2838
3308
  var cap = o.maxDepth == null ? 64 : o.maxDepth;
2839
3309
  return _deep(value, ErrorClass, code, label, cap, 0, o.collect || null);
2840
3310
  }
2841
- var _CRYPTO_KEY_SURFACE = { type: 1, extractable: 1, algorithm: 1, usages: 1 };
2842
- var _ERROR_SURFACE = { message: 1, stack: 1, name: 1, cause: 1 };
2843
- var _REGEXP_SURFACE = {
2844
- lastIndex: 1,
2845
- source: 1,
2846
- flags: 1,
2847
- global: 1,
2848
- ignoreCase: 1,
2849
- multiline: 1,
2850
- sticky: 1,
2851
- unicode: 1,
2852
- unicodeSets: 1,
2853
- hasIndices: 1,
2854
- dotAll: 1
2855
- };
2856
- var _THENABLE_SURFACE = { then: 1, catch: 1, finally: 1 };
3311
+ function _surface(names) {
3312
+ var t = /* @__PURE__ */ Object.create(null);
3313
+ names.forEach(function(n) {
3314
+ t[n] = 1;
3315
+ });
3316
+ t[Symbol.toStringTag] = 1;
3317
+ return t;
3318
+ }
3319
+ var _CRYPTO_KEY_SURFACE = _surface([
3320
+ "type",
3321
+ "extractable",
3322
+ "algorithm",
3323
+ "usages",
3324
+ "asymmetricKeyType",
3325
+ "asymmetricKeyDetails",
3326
+ "_handle"
3327
+ ]);
3328
+ var _ERROR_SURFACE = _surface(["message", "stack", "name", "cause"]);
3329
+ var _REGEXP_SURFACE = _surface([
3330
+ "lastIndex",
3331
+ "source",
3332
+ "flags",
3333
+ "global",
3334
+ "ignoreCase",
3335
+ "multiline",
3336
+ "sticky",
3337
+ "unicode",
3338
+ "unicodeSets",
3339
+ "hasIndices",
3340
+ "dotAll"
3341
+ ]);
3342
+ var _THENABLE_SURFACE = _surface(["then", "catch", "finally"]);
2857
3343
  function _opaqueSurface(v, ErrorClass, code, label) {
2858
3344
  var proto = Object.getPrototypeOf(v);
2859
3345
  if (proto === Object.prototype || proto === null) return null;
2860
- if (v instanceof WeakMap || v instanceof WeakSet) return {};
3346
+ if (util.types.isWeakMap(v) || util.types.isWeakSet(v)) return {};
2861
3347
  if (v instanceof Error) return _ERROR_SURFACE;
2862
- if (v instanceof RegExp) return _REGEXP_SURFACE;
2863
- if (require_webcrypto().isCryptoKeyLike(v)) return _CRYPTO_KEY_SURFACE;
3348
+ if (util.types.isRegExp(v)) return _REGEXP_SURFACE;
3349
+ if (util.types.isKeyObject(v)) return _CRYPTO_KEY_SURFACE;
3350
+ var keyLike;
3351
+ try {
3352
+ keyLike = require_webcrypto().isCryptoKeyLike(v);
3353
+ } catch (e) {
3354
+ throw _raise(ErrorClass, code, label + ": reading the key surface threw", e);
3355
+ }
3356
+ if (keyLike) return _CRYPTO_KEY_SURFACE;
2864
3357
  var then;
2865
3358
  try {
2866
3359
  then = v.then;
@@ -2870,27 +3363,35 @@ var require_guard_bytes = __commonJS({
2870
3363
  if (typeof then === "function") return _THENABLE_SURFACE;
2871
3364
  return null;
2872
3365
  }
2873
- function _opaqueIsSafeToPass(v, surface) {
2874
- var keys = _reachableKeys(v);
2875
- for (var i = 0; i < keys.length; i++) {
2876
- if (surface[keys[i]]) continue;
2877
- if (!_wasEnumerable(v, keys[i])) continue;
2878
- return false;
3366
+ function _canChangeAfterTheCheck(v, name) {
3367
+ var visited = /* @__PURE__ */ new Set();
3368
+ for (var o = v; o && !visited.has(o); o = Object.getPrototypeOf(o)) {
3369
+ visited.add(o);
3370
+ var d = Object.getOwnPropertyDescriptor(o, name);
3371
+ if (!d) continue;
3372
+ if (d.get || d.set || d.writable || d.configurable) return true;
3373
+ return o !== v && Object.isExtensible(v);
2879
3374
  }
2880
- return true;
3375
+ return false;
2881
3376
  }
2882
- function _reachableKeys(v) {
2883
- var names = [];
2884
- var seen = /* @__PURE__ */ Object.create(null);
2885
- for (var o = v; o && o !== Object.prototype; o = Object.getPrototypeOf(o)) {
2886
- var own = Object.getOwnPropertyNames(o);
2887
- for (var i = 0; i < own.length; i++) {
2888
- if (own[i] === "constructor" || seen[own[i]]) continue;
2889
- seen[own[i]] = true;
2890
- names.push(own[i]);
2891
- }
3377
+ var _SETTLED_DEPTH = 4;
3378
+ function _settledValueIsFixed(value, ErrorClass, code, label, depth) {
3379
+ if (value === null || typeof value !== "object" && typeof value !== "function") return true;
3380
+ if (depth >= _SETTLED_DEPTH) return false;
3381
+ if (util.types.isProxy(value)) return false;
3382
+ var surface = _opaqueSurface(value, ErrorClass, code, label);
3383
+ if (!surface) return false;
3384
+ return _opaqueFieldOutsideSurface(value, surface, ErrorClass, code, label, depth + 1) === null;
3385
+ }
3386
+ function _opaqueFieldOutsideSurface(v, surface, ErrorClass, code, label, depth) {
3387
+ var keys = _namesToCopy(v, ErrorClass, code, label);
3388
+ for (var i = 0; i < keys.length; i++) {
3389
+ if (surface[keys[i]]) continue;
3390
+ if (typeof keys[i] === "symbol") continue;
3391
+ if (!_canChangeAfterTheCheck(v, keys[i]) && _settledValueIsFixed(v[keys[i]], ErrorClass, code, label, depth || 0)) continue;
3392
+ return keys[i];
2892
3393
  }
2893
- return names;
3394
+ return null;
2894
3395
  }
2895
3396
  function _copyBytesSameKind(v, ErrorClass, code, label, collect) {
2896
3397
  var src = source(v, ErrorClass, code, label);
@@ -2898,60 +3399,117 @@ var require_guard_bytes = __commonJS({
2898
3399
  new Uint8Array(owned).set(src);
2899
3400
  if (collect) collect.push(Buffer.from(owned, 0, src.length));
2900
3401
  if (Buffer.isBuffer(v)) return Buffer.from(owned, 0, src.length);
2901
- if (v instanceof ArrayBuffer) return owned;
2902
- if (v instanceof DataView) return new DataView(owned);
2903
- return new v.constructor(owned, 0, src.length / v.BYTES_PER_ELEMENT);
3402
+ if (_isArrayBuffer(v)) return owned;
3403
+ if (util.types.isDataView(v)) return new DataView(owned);
3404
+ var Ctor = _concreteKindOf(v);
3405
+ if (!Ctor) {
3406
+ throw _raise(ErrorClass, code, label + ": a " + (util.types.isTypedArray(v) ? "typed array of a kind this runtime added" : "byte view") + " cannot be copied while keeping its kind; pass a Buffer or a Uint8Array");
3407
+ }
3408
+ return new Ctor(owned, 0, src.length / Ctor.BYTES_PER_ELEMENT);
3409
+ }
3410
+ function _protoChainIsCyclic(v) {
3411
+ var visited = /* @__PURE__ */ new Set();
3412
+ for (var o = v; o; o = Object.getPrototypeOf(o)) {
3413
+ if (visited.has(o)) return true;
3414
+ visited.add(o);
3415
+ }
3416
+ return false;
3417
+ }
3418
+ function _protoChainHasProxy(v) {
3419
+ var visited = /* @__PURE__ */ new Set();
3420
+ for (var o = v; o && !visited.has(o); o = Object.getPrototypeOf(o)) {
3421
+ visited.add(o);
3422
+ if (util.types.isProxy(o)) return true;
3423
+ }
3424
+ return false;
3425
+ }
3426
+ function _plainCopy(copy) {
3427
+ return copy;
2904
3428
  }
2905
3429
  function _deep(v, ErrorClass, code, label, cap, depth, collect) {
2906
3430
  if (depth > cap) throw _raise(ErrorClass, code, label + " is nested too deeply to copy");
2907
3431
  if (v == null || typeof v !== "object") return v;
2908
- if (Buffer.isBuffer(v) || ArrayBuffer.isView(v) || v instanceof ArrayBuffer) {
3432
+ _refuseShared(v, ErrorClass, code, label);
3433
+ if (_protoChainHasProxy(v)) {
3434
+ throw _raise(ErrorClass, code, label + ": a Proxy cannot be copied faithfully, because the keys it reports need not be the ones it answers; pass a plain object");
3435
+ }
3436
+ if (_protoChainIsCyclic(v)) {
3437
+ throw _raise(ErrorClass, code, label + ": its prototype chain is a cycle, so it cannot be read or copied; pass a plain object");
3438
+ }
3439
+ if (Buffer.isBuffer(v) || ArrayBuffer.isView(v) || _isArrayBuffer(v)) {
2909
3440
  var bytesCopy = _copyBytesSameKind(v, ErrorClass, code, label, collect);
2910
3441
  _copyNamed(v, bytesCopy, ErrorClass, code, label, cap, depth, collect);
2911
3442
  return bytesCopy;
2912
3443
  }
2913
3444
  if (require_guard_parsed().isRecordedAsProduced(v)) return v;
2914
- if (v instanceof Date) return new Date(v.getTime());
3445
+ if (util.types.isDate(v)) {
3446
+ var dateCopy = new Date(time.instantOf(v));
3447
+ _copyNamed(v, dateCopy, ErrorClass, code, label, cap, depth, collect, _DATE_BEHAVIOR);
3448
+ return _plainCopy(dateCopy);
3449
+ }
2915
3450
  if (Array.isArray(v)) {
2916
3451
  var arr = [];
2917
- for (var i = 0; i < v.length; i++) arr.push(_deep(v[i], ErrorClass, code, label, cap, depth + 1, collect));
3452
+ var indexE = function(c, m) {
3453
+ return _raise(ErrorClass, c, m);
3454
+ };
3455
+ var indices = identifier.readableIndices(v, indexE, code, label);
3456
+ if (depth === 0) identifier.refuseAccessorFields(v, indices, indexE, code, label);
3457
+ indices.forEach(function(k) {
3458
+ var element;
3459
+ try {
3460
+ element = v[k];
3461
+ } catch (e) {
3462
+ throw _raise(ErrorClass, code, label + ": reading element " + k + " threw", e);
3463
+ }
3464
+ arr[k] = _deep(element, ErrorClass, code, label, cap, depth + 1, collect);
3465
+ });
3466
+ arr.length = v.length;
2918
3467
  _copyNamed(v, arr, ErrorClass, code, label, cap, depth, collect);
2919
- return arr;
3468
+ return _plainCopy(arr);
2920
3469
  }
2921
3470
  var surface = _opaqueSurface(v, ErrorClass, code, label);
2922
3471
  if (surface) {
2923
- if (_opaqueIsSafeToPass(v, surface)) return v;
2924
- throw _raise(ErrorClass, code, label + ": a " + (v.constructor && v.constructor.name || "value") + " carrying its own fields cannot be used here -- its state cannot be copied, so those fields would stay changeable after they were checked; pass the fields as a plain object");
3472
+ var carried = _opaqueFieldOutsideSurface(v, surface, ErrorClass, code, label);
3473
+ if (carried === null) return v;
3474
+ throw _raise(ErrorClass, code, label + ": " + _article(_kindName(v)) + " " + _kindName(v) + " carrying its own field " + JSON.stringify(String(carried)) + " cannot be used here -- its state cannot be copied, so that field would stay changeable after it was checked; pass the fields as a plain object");
3475
+ }
3476
+ if (util.types.isMap(v)) {
3477
+ return _plainCopy(_copyEntries(v, /* @__PURE__ */ new Map(), ErrorClass, code, label, cap, depth, collect));
3478
+ }
3479
+ if (util.types.isSet(v)) {
3480
+ return _plainCopy(_copyEntries(v, /* @__PURE__ */ new Set(), ErrorClass, code, label, cap, depth, collect));
2925
3481
  }
2926
- if (v instanceof Map) return _copyEntries(v, /* @__PURE__ */ new Map(), ErrorClass, code, label, cap, depth, collect);
2927
- if (v instanceof Set) return _copyEntries(v, /* @__PURE__ */ new Set(), ErrorClass, code, label, cap, depth, collect);
2928
- var out = Object.create(Object.getPrototypeOf(v));
3482
+ var out = Object.create(Object.getPrototypeOf(v) === null ? null : Object.prototype);
2929
3483
  _copyNamed(v, out, ErrorClass, code, label, cap, depth, collect);
2930
3484
  return out;
2931
3485
  }
2932
- function _namesToCopy(src, dst) {
2933
- var indexed = Array.isArray(dst) || ArrayBuffer.isView(dst);
2934
- var kind = indexed || dst instanceof Map || dst instanceof Set || dst instanceof ArrayBuffer;
2935
- if (!kind) return _reachableKeys(src);
2936
- var own = Object.getOwnPropertyNames(src);
2937
- var out = [];
2938
- for (var i = 0; i < own.length; i++) {
2939
- if (own[i] === "length" || indexed && String(Number(own[i])) === own[i]) continue;
2940
- out.push(own[i]);
2941
- }
2942
- return out;
3486
+ function _namesToCopy(src, ErrorClass, code, label, atArgument) {
3487
+ var E = function(c, m) {
3488
+ return _raise(ErrorClass, c, m);
3489
+ };
3490
+ var names = identifier.readableNames(src, E, code, label);
3491
+ if (atArgument) identifier.refuseAccessorFields(src, names, E, code, label);
3492
+ return names;
2943
3493
  }
2944
3494
  function _copyEntries(src, dst, ErrorClass, code, label, cap, depth, collect) {
2945
- src.forEach(function(value, key) {
3495
+ var walk = util.types.isSet(src) ? Set.prototype.forEach : Map.prototype.forEach;
3496
+ walk.call(src, function(value, key) {
2946
3497
  var copiedValue = _deep(value, ErrorClass, code, label, cap, depth + 1, collect);
2947
- if (dst instanceof Set) dst.add(copiedValue);
3498
+ if (util.types.isSet(dst)) dst.add(copiedValue);
2948
3499
  else dst.set(_deep(key, ErrorClass, code, label, cap, depth + 1, collect), copiedValue);
2949
3500
  });
2950
3501
  _copyNamed(src, dst, ErrorClass, code, label, cap, depth, collect);
2951
3502
  return dst;
2952
3503
  }
2953
- function _copyNamed(src, dst, ErrorClass, code, label, cap, depth, collect) {
2954
- var keys = _namesToCopy(src, dst);
3504
+ var _DATE_BEHAVIOR = (function() {
3505
+ var t = /* @__PURE__ */ Object.create(null);
3506
+ Reflect.ownKeys(Date.prototype).forEach(function(n) {
3507
+ t[n] = 1;
3508
+ });
3509
+ return t;
3510
+ })();
3511
+ function _copyNamed(src, dst, ErrorClass, code, label, cap, depth, collect, behavior) {
3512
+ var keys = _namesToCopy(src, ErrorClass, code, label, depth === 0);
2955
3513
  for (var k = 0; k < keys.length; k++) {
2956
3514
  var value;
2957
3515
  try {
@@ -2959,6 +3517,7 @@ var require_guard_bytes = __commonJS({
2959
3517
  } catch (e) {
2960
3518
  throw _raise(ErrorClass, code, label + ": reading " + JSON.stringify(keys[k]) + " threw", e);
2961
3519
  }
3520
+ if (behavior && behavior[keys[k]] && typeof value === "function") continue;
2962
3521
  Object.defineProperty(dst, keys[k], {
2963
3522
  value: typeof value === "function" ? value : _deep(value, ErrorClass, code, label, cap, depth + 1, collect),
2964
3523
  writable: true,
@@ -3010,6 +3569,9 @@ var require_guard_bytes = __commonJS({
3010
3569
  source,
3011
3570
  snapshot,
3012
3571
  snapshotSource,
3572
+ isByteSource,
3573
+ lengthOf,
3574
+ outputView,
3013
3575
  snapshotDeep,
3014
3576
  fixArguments,
3015
3577
  fixedCall
@@ -3182,32 +3744,6 @@ var require_guard_range = __commonJS({
3182
3744
  }
3183
3745
  });
3184
3746
 
3185
- // node_modules/@blamejs/pki/lib/guard-time.js
3186
- var require_guard_time = __commonJS({
3187
- "node_modules/@blamejs/pki/lib/guard-time.js"(exports2, module2) {
3188
- "use strict";
3189
- function assertValid(value, E, code, label) {
3190
- if (!(value instanceof Date) || isNaN(value.getTime())) {
3191
- throw E(code, (label || "value") + " must be a valid Date");
3192
- }
3193
- return value;
3194
- }
3195
- function within(instant, lower, upper, E, code, label, opts) {
3196
- assertValid(instant, E, code, label);
3197
- assertValid(lower, E, code, (label || "window") + " lower bound");
3198
- assertValid(upper, E, code, (label || "window") + " upper bound");
3199
- var t = instant.getTime();
3200
- var lo = lower.getTime();
3201
- var hi = upper.getTime();
3202
- return t >= lo && (opts && opts.upperInclusive ? t <= hi : t < hi);
3203
- }
3204
- module2.exports = {
3205
- assertValid,
3206
- within
3207
- };
3208
- }
3209
- });
3210
-
3211
3747
  // node_modules/@blamejs/pki/lib/guard-name.js
3212
3748
  var require_guard_name = __commonJS({
3213
3749
  "node_modules/@blamejs/pki/lib/guard-name.js"(exports2, module2) {
@@ -3679,55 +4215,6 @@ var require_guard_json = __commonJS({
3679
4215
  }
3680
4216
  });
3681
4217
 
3682
- // node_modules/@blamejs/pki/lib/guard-identifier.js
3683
- var require_guard_identifier = __commonJS({
3684
- "node_modules/@blamejs/pki/lib/guard-identifier.js"(exports2, module2) {
3685
- "use strict";
3686
- function _isDottedDecimal(str) {
3687
- if (str.length === 0) return false;
3688
- var arcs = 0, digits = 0, leadingZero = false;
3689
- for (var i = 0; i < str.length; i++) {
3690
- var c = str.charCodeAt(i);
3691
- if (c === 46) {
3692
- if (digits === 0 || leadingZero) return false;
3693
- arcs++;
3694
- digits = 0;
3695
- leadingZero = false;
3696
- continue;
3697
- }
3698
- if (c < 48 || c > 57) return false;
3699
- if (digits === 1 && str.charCodeAt(i - 1) === 48) leadingZero = true;
3700
- digits++;
3701
- }
3702
- if (digits === 0 || leadingZero) return false;
3703
- return arcs >= 1;
3704
- }
3705
- function assertCanonicalOid(str, E, code, label, boundsCode) {
3706
- var who = label || "OID";
3707
- if (typeof str !== "string" || !_isDottedDecimal(str)) {
3708
- throw E(code, who + " must be a canonical dotted-decimal OID string of two or more arcs with no leading-zero component");
3709
- }
3710
- if (boundsCode === null) return str;
3711
- var bcode = boundsCode === void 0 ? code : boundsCode;
3712
- var parts = str.split(".");
3713
- var root = BigInt(parts[0]);
3714
- var second = BigInt(parts[1]);
3715
- if (root > 2n) throw E(bcode, who + " root arc must be 0, 1, or 2 (X.660)");
3716
- if (root < 2n && second > 39n) throw E(bcode, who + " second arc must be 0..39 under roots 0 and 1 (X.660)");
3717
- return str;
3718
- }
3719
- function assertKnownKeys(obj, known, E, code, message) {
3720
- var describe = typeof message === "function" ? message : function(k) {
3721
- return message + JSON.stringify(k);
3722
- };
3723
- Object.keys(obj).forEach(function(k) {
3724
- if (!Object.prototype.hasOwnProperty.call(known, k)) throw E(code, describe(k));
3725
- });
3726
- }
3727
- module2.exports = { assertCanonicalOid, assertKnownKeys };
3728
- }
3729
- });
3730
-
3731
4218
  // node_modules/@blamejs/pki/lib/guard-header.js
3732
4219
  var require_guard_header = __commonJS({
3733
4220
  "node_modules/@blamejs/pki/lib/guard-header.js"(exports2, module2) {
@@ -4363,7 +4850,7 @@ var require_asn1_der = __commonJS({
4363
4850
  var d = /* @__PURE__ */ new Date(0);
4364
4851
  d.setUTCFullYear(year, month - 1, day);
4365
4852
  d.setUTCHours(hour, min, sec, ms);
4366
- if (isNaN(d.getTime())) throw new Asn1Error("asn1/bad-time", "unparseable time " + JSON.stringify(s));
4853
+ if (isNaN(guard.time.instantOf(d))) throw new Asn1Error("asn1/bad-time", "unparseable time " + JSON.stringify(s));
4367
4854
  if (d.getUTCFullYear() !== year || d.getUTCMonth() !== month - 1 || d.getUTCDate() !== day || d.getUTCHours() !== hour || d.getUTCMinutes() !== min || d.getUTCSeconds() !== sec) {
4368
4855
  throw new Asn1Error("asn1/bad-time", "time component out of range " + JSON.stringify(s));
4369
4856
  }
@@ -4938,7 +5425,7 @@ var require_cbor_det = __commonJS({
4938
5425
  }
4939
5426
  var ns = Number(secs);
4940
5427
  var d = new Date(ns < 0 ? -constants.TIME.seconds(-ns) : constants.TIME.seconds(ns));
4941
- if (isNaN(d.getTime())) throw new CborError("cbor/bad-time", "epoch time out of range");
5428
+ if (isNaN(guard.time.instantOf(d))) throw new CborError("cbor/bad-time", "epoch time out of range");
4942
5429
  return d;
4943
5430
  }
4944
5431
  function readOid(node) {
@@ -5071,12 +5558,12 @@ var require_cbor_det = __commonJS({
5071
5558
  },
5072
5559
  time: function(v) {
5073
5560
  var ms;
5074
- if (v instanceof Date) {
5075
- ms = v.getTime();
5561
+ if (guard.time.isDate(v)) {
5562
+ ms = guard.time.instantOf(v);
5076
5563
  if (Number.isNaN(ms)) throw new CborError("cbor/bad-time", "build.time: an Invalid Date has no epoch value");
5077
5564
  if (ms % 1e3 !== 0) throw new CborError("cbor/bad-time", "build.time: a Date with sub-second precision cannot be a second-granularity CBOR epoch; round to whole seconds");
5078
5565
  }
5079
- var secs = v instanceof Date ? BigInt(Math.floor(ms / 1e3)) : typeof v === "bigint" ? v : BigInt(v);
5566
+ var secs = guard.time.isDate(v) ? BigInt(Math.floor(ms / 1e3)) : typeof v === "bigint" ? v : BigInt(v);
5080
5567
  if (secs < -_MAX_EPOCH_SECONDS || secs > _MAX_EPOCH_SECONDS) throw new CborError("cbor/bad-time", "build.time: epoch seconds " + secs + " are outside the representable Date range");
5081
5568
  return build.tag(1, build.int(secs));
5082
5569
  },
@@ -7476,7 +7963,7 @@ var require_ct = __commonJS({
7476
7963
  if (typeof ti !== "object") throw _ctErr("ct/bad-log-list", "a CT log temporal_interval must be an object");
7477
7964
  var start = rfc3339.parse(ti.start_inclusive, _ctErr, "ct/bad-date", "temporal_interval.start_inclusive");
7478
7965
  var end = rfc3339.parse(ti.end_exclusive, _ctErr, "ct/bad-date", "temporal_interval.end_exclusive");
7479
- if (start.getTime() >= end.getTime()) throw _ctErr("ct/bad-log-list", "a CT log temporal_interval start_inclusive must be strictly before end_exclusive");
7966
+ if (guard.time.instantOf(start) >= guard.time.instantOf(end)) throw _ctErr("ct/bad-log-list", "a CT log temporal_interval start_inclusive must be strictly before end_exclusive");
7480
7967
  return { startInclusive: start, endExclusive: end };
7481
7968
  }
7482
7969
  function _parseLog(log, operatorName) {
@@ -7505,10 +7992,10 @@ var require_ct = __commonJS({
7505
7992
  function _sameTemporal(a, b) {
7506
7993
  if (a == null && b == null) return true;
7507
7994
  if (a == null || b == null) return false;
7508
- return a.startInclusive.getTime() === b.startInclusive.getTime() && a.endExclusive.getTime() === b.endExclusive.getTime();
7995
+ return guard.time.instantOf(a.startInclusive) === guard.time.instantOf(b.startInclusive) && guard.time.instantOf(a.endExclusive) === guard.time.instantOf(b.endExclusive);
7509
7996
  }
7510
7997
  function _logsAgree(a, b) {
7511
- return a.state.name === b.state.name && a.state.since.getTime() === b.state.since.getTime() && _sameTemporal(a.temporalInterval, b.temporalInterval);
7998
+ return a.state.name === b.state.name && guard.time.instantOf(a.state.since) === guard.time.instantOf(b.state.since) && _sameTemporal(a.temporalInterval, b.temporalInterval);
7512
7999
  }
7513
8000
  function parseLogList(json, opts) {
7514
8001
  void opts;
@@ -7550,7 +8037,7 @@ var require_ct = __commonJS({
7550
8037
  return { logs, byLogId, version, timestamp };
7551
8038
  }
7552
8039
  function _resolveNotAfter(entry, opts) {
7553
- if (opts.certNotAfter instanceof Date) return opts.certNotAfter;
8040
+ if (guard.time.isDate(opts.certNotAfter)) return opts.certNotAfter;
7554
8041
  if (entry && entry.entryType === 0 && entry.leafCert != null) {
7555
8042
  var x509 = require_schema_x509();
7556
8043
  try {
@@ -7570,7 +8057,7 @@ var require_ct = __commonJS({
7570
8057
  if (!log.state.trusted) {
7571
8058
  if (!log.state.conditional) throw _ctErr("ct/log-untrusted", "the CT log state '" + log.state.name + "' is not trusted");
7572
8059
  var ts = guard.range.uint64(sct.timestamp, _ctErr, "ct/bad-input", "sct.timestamp");
7573
- if (ts >= BigInt(log.state.since.getTime())) throw _ctErr("ct/log-untrusted", "the CT log is retired and the SCT is not timestamped before its retirement (" + log.state.since.toISOString() + ")");
8060
+ if (ts >= BigInt(guard.time.instantOf(log.state.since))) throw _ctErr("ct/log-untrusted", "the CT log is retired and the SCT is not timestamped before its retirement (" + log.state.since.toISOString() + ")");
7574
8061
  }
7575
8062
  if (log.temporalInterval) {
7576
8063
  var notAfter = _resolveNotAfter(entry, opts);
@@ -10716,12 +11203,12 @@ var require_schema_c509 = __commonJS({
10716
11203
  if (r.serialNumber == null && r.serialNumberHex == null) throw _err("c509/bad-input", "a C509 result must carry serialNumber or serialNumberHex");
10717
11204
  if (!r.signatureAlgorithm || typeof r.signatureAlgorithm.name !== "string") throw _err("c509/bad-input", "a C509 result must carry signatureAlgorithm.name");
10718
11205
  if (!r.subjectPublicKeyAlgorithm || typeof r.subjectPublicKeyAlgorithm.name !== "string") throw _err("c509/bad-input", "a C509 result must carry subjectPublicKeyAlgorithm.name");
10719
- if (!r.validity || !(r.validity.notBefore instanceof Date) || r.validity.notAfter !== null && !(r.validity.notAfter instanceof Date)) throw _err("c509/bad-input", "a C509 result must carry validity.notBefore (Date) and notAfter (Date or null)");
11206
+ if (!r.validity || !guard.time.isDate(r.validity.notBefore) || r.validity.notAfter !== null && !guard.time.isDate(r.validity.notAfter)) throw _err("c509/bad-input", "a C509 result must carry validity.notBefore (Date) and notAfter (Date or null)");
10720
11207
  if (!Array.isArray(r.extensions)) throw _err("c509/bad-input", "a C509 result must carry an extensions array");
10721
11208
  if (!Buffer.isBuffer(r.signatureValue)) throw _err("c509/bad-input", "a C509 result must carry a Buffer signatureValue");
10722
11209
  }
10723
11210
  function _validityUint(date, label) {
10724
- var secs = Math.floor(date.getTime() / 1e3);
11211
+ var secs = Math.floor(guard.time.instantOf(date) / 1e3);
10725
11212
  if (!isFinite(secs) || secs < 0) throw _err("c509/bad-validity", label + " is before the Unix epoch or not a valid date; C509 ~time is a non-negative CBOR epoch");
10726
11213
  return cbor.build.uint(BigInt(secs));
10727
11214
  }
@@ -10869,7 +11356,7 @@ var require_schema_c509 = __commonJS({
10869
11356
  // against a UTF8String of the same characters) would rebuild different bytes and break the
10870
11357
  // signature that covers them. Byte-identical is exactly the condition under which that is safe.
10871
11358
  issuer: c.issuer.bytes.equals(c.subject.bytes) ? null : _c509NameFromDer(c.issuer.bytes),
10872
- validity: { notBefore: c.validity.notBefore, notAfter: c.validity.notAfter.getTime() === _NO_EXPIRY ? null : c.validity.notAfter },
11359
+ validity: { notBefore: c.validity.notBefore, notAfter: guard.time.instantOf(c.validity.notAfter) === _NO_EXPIRY ? null : c.validity.notAfter },
10873
11360
  subject: _c509NameFromDer(c.subject.bytes),
10874
11361
  subjectPublicKeyAlgorithm: { name: "ecPublicKey", oid: c.subjectPublicKeyInfo.algorithm.oid, curve },
10875
11362
  subjectPublicKey: _compressEcPoint(asn1.read.bitString(spkiNode.children[1]).bytes, coordLen),
@@ -16683,6 +17170,7 @@ var require_ocsp_verify = __commonJS({
16683
17170
  "node_modules/@blamejs/pki/lib/ocsp-verify.js"(exports2, module2) {
16684
17171
  "use strict";
16685
17172
  var asn1 = require_asn1_der();
17173
+ var guard = require_guard_all();
16686
17174
  var oid = require_oid();
16687
17175
  var x509 = require_schema_x509();
16688
17176
  var compositeSig = require_composite_sig();
@@ -16781,7 +17269,7 @@ var require_ocsp_verify = __commonJS({
16781
17269
  if (!issuedByCa) continue;
16782
17270
  if (!isOctetAligned(rc.signatureValue)) continue;
16783
17271
  if (!await verifyWithSpki(rc.signatureAlgorithm, rc.signatureValue.bytes, issuer.workingPublicKey, rc.tbsBytes)) continue;
16784
- if (time < rc.validity.notBefore || time > rc.validity.notAfter) continue;
17272
+ if (guard.time.instantOf(time) < guard.time.instantOf(rc.validity.notBefore) || guard.time.instantOf(time) > guard.time.instantOf(rc.validity.notAfter)) continue;
16785
17273
  var eku;
16786
17274
  try {
16787
17275
  eku = decodeExt(rc, OID_EKU);
@@ -16824,14 +17312,14 @@ var require_ocsp_verify = __commonJS({
16824
17312
  var sr = br.responses[s];
16825
17313
  if (!await ocspCertIdMatches(sr.certID, cert, issuerNameCandidates, issuerKeyBits)) continue;
16826
17314
  if (ocspHasCriticalExtension(sr.singleExtensions)) continue;
16827
- if (sr.thisUpdate > time) continue;
16828
- if (!sr.nextUpdate || sr.nextUpdate < time) continue;
17315
+ if (guard.time.instantOf(sr.thisUpdate) > guard.time.instantOf(time)) continue;
17316
+ if (!sr.nextUpdate || guard.time.instantOf(sr.nextUpdate) < guard.time.instantOf(time)) continue;
16829
17317
  out.matched = true;
16830
17318
  out.thisUpdate = sr.thisUpdate;
16831
17319
  out.nextUpdate = sr.nextUpdate;
16832
17320
  var st = sr.certStatus;
16833
17321
  if (st.type === "revoked") {
16834
- if (historical && st.revocationTime instanceof Date && st.revocationTime.getTime() > time.getTime()) {
17322
+ if (historical && guard.time.isDate(st.revocationTime) && guard.time.instantOf(st.revocationTime) > guard.time.instantOf(time)) {
16835
17323
  out.sawGood = true;
16836
17324
  } else if (!out.revoked) {
16837
17325
  out.revoked = { revocationReason: st.revocationReason || null, reason: "certificate reported revoked by an authorized OCSP responder" + (st.revocationReason ? " (" + st.revocationReason + ")" : "") };
@@ -17647,7 +18135,7 @@ var require_crmf_sign = __commonJS({
17647
18135
  var parts = [];
17648
18136
  if (nb != null) parts.push(b.explicit(0, _b.timeDer(nb, "validity notBefore")));
17649
18137
  if (na != null) parts.push(b.explicit(1, _b.timeDer(na, "validity notAfter")));
17650
- if (nb != null && na != null && nb.getTime() > na.getTime()) throw _err("crmf/bad-validity", "notBefore must not be after notAfter");
18138
+ if (nb != null && na != null && guard.time.instantOf(nb) > guard.time.instantOf(na)) throw _err("crmf/bad-validity", "notBefore must not be after notAfter");
17651
18139
  return b.implicit(4, b.sequence(parts));
17652
18140
  }
17653
18141
  function _encodeCertTemplate(tpl, opts) {
@@ -19466,7 +19954,7 @@ var require_cms_sign = __commonJS({
19466
19954
  });
19467
19955
  }
19468
19956
  function _timeValue(when) {
19469
- var d = when instanceof Date ? when : /* @__PURE__ */ new Date();
19957
+ var d = guard.time.isDate(when) ? when : /* @__PURE__ */ new Date();
19470
19958
  return d.getUTCFullYear() < 2050 ? b.utcTime(d) : b.generalizedTime(d);
19471
19959
  }
19472
19960
  function _keyOnlyCertStandIn(spkiDer) {
@@ -19537,8 +20025,7 @@ var require_cms_sign = __commonJS({
19537
20025
  ], _sign);
19538
20026
  }
19539
20027
  function _sign(content, signers, opts) {
19540
- opts = opts || {};
19541
- if (typeof opts !== "object" || Buffer.isBuffer(opts)) throw _err("cms/bad-input", "pki.cms.sign options must be an object");
20028
+ opts = guard.identifier.optionsObject(opts, _err, "cms/bad-input", "pki.cms.sign options");
19542
20029
  guard.identifier.assertKnownKeys(opts, KNOWN_SIGN_OPTS, _err, "cms/bad-input", "unknown opts field ");
19543
20030
  var contentBuf = _toBuf(content, "content");
19544
20031
  var list = Array.isArray(signers) ? signers : [signers];
@@ -19734,8 +20221,7 @@ var require_cms_sign = __commonJS({
19734
20221
  ], _countersign);
19735
20222
  }
19736
20223
  function _countersign(cmsInput, signers, opts) {
19737
- opts = opts || {};
19738
- if (typeof opts !== "object" || Buffer.isBuffer(opts)) throw _err("cms/bad-input", "pki.cms.countersign options must be an object");
20224
+ opts = guard.identifier.optionsObject(opts, _err, "cms/bad-input", "pki.cms.countersign options");
19739
20225
  guard.identifier.assertKnownKeys(opts, KNOWN_COUNTERSIGN_OPTS, _err, "cms/bad-input", "unknown opts field ");
19740
20226
  var list = Array.isArray(signers) ? signers : [signers];
19741
20227
  if (!list.length) throw _err("cms/bad-input", "pki.cms.countersign requires at least one countersigner");
@@ -21476,8 +21962,7 @@ var require_cms_verify = __commonJS({
21476
21962
  });
21477
21963
  }
21478
21964
  function _verify(input, opts) {
21479
- opts = opts || {};
21480
- if (typeof opts !== "object" || Buffer.isBuffer(opts)) throw _err("cms/bad-input", "pki.cms.verify options must be an object");
21965
+ opts = guard.identifier.optionsObject(opts, _err, "cms/bad-input", "pki.cms.verify options");
21481
21966
  guard.identifier.assertKnownKeys(opts, _VERIFY_OPTS, _err, "cms/bad-input", "pki.cms.verify has an unknown option ");
21482
21967
  var parsed = guard.parsed.acceptDerived(input, "cms", function(bytes) {
21483
21968
  return cms.parse(_snapshotIfBytes(bytes, "pki.cms.verify"));
@@ -21533,7 +22018,7 @@ var require_cms_verify = __commonJS({
21533
22018
  return _snapshotIfBytes(v, "opts.trustAnchors[]");
21534
22019
  }
21535
22020
  if (v === null || typeof v !== "object") return v;
21536
- if (v instanceof Date) return new Date(v.getTime());
22021
+ if (guard.time.isDate(v)) return new Date(guard.time.instantOf(v));
21537
22022
  if (depth >= _ANCHOR_CLONE_DEPTH) {
21538
22023
  throw _err("cms/bad-input", "an opts.trustAnchors entry nests deeper than " + _ANCHOR_CLONE_DEPTH + " levels, so it cannot be copied before the chain is walked; pass the anchor as certificate DER or a { name, publicKey, algorithm } tuple");
21539
22024
  }
@@ -21557,7 +22042,7 @@ var require_cms_verify = __commonJS({
21557
22042
  }
21558
22043
  return {
21559
22044
  trustAnchors: anchors,
21560
- time: opts.time instanceof Date ? new Date(opts.time.getTime()) : opts.time,
22045
+ time: guard.time.isDate(opts.time) ? new Date(guard.time.instantOf(opts.time)) : opts.time,
21561
22046
  requiredEku: Array.isArray(opts.requiredEku) ? opts.requiredEku.slice() : opts.requiredEku,
21562
22047
  checkPurpose: opts.checkPurpose
21563
22048
  };
@@ -23326,8 +23811,34 @@ var require_path_validate = __commonJS({
23326
23811
  }
23327
23812
  return null;
23328
23813
  }
23814
+ var _VALIDATE_OPTS = {
23815
+ checkPurpose: 1,
23816
+ historicalMode: 1,
23817
+ initialAnyPolicyInhibit: 1,
23818
+ initialExcludedSubtrees: 1,
23819
+ initialExplicitPolicy: 1,
23820
+ initialPermittedSubtrees: 1,
23821
+ initialPolicyMappingInhibit: 1,
23822
+ maxPathCerts: 1,
23823
+ maxPolicyNodes: 1,
23824
+ requireRevocation: 1,
23825
+ requiredEku: 1,
23826
+ revocationChecker: 1,
23827
+ softFail: 1,
23828
+ time: 1,
23829
+ trustAnchor: 1,
23830
+ userInitialPolicySet: 1,
23831
+ verifier: 1
23832
+ };
23329
23833
  async function validate(path, opts) {
23330
- opts = opts || {};
23834
+ opts = guard.identifier.optionsObject(opts, E, "path/bad-input", "validate: opts");
23835
+ guard.identifier.assertKnownKeys(
23836
+ opts,
23837
+ _VALIDATE_OPTS,
23838
+ E,
23839
+ "path/bad-input",
23840
+ "pki.path.validate has an unknown option. The anchor here is `trustAnchor`, singular; pki.path.build takes `trustAnchors`. The unknown option was: "
23841
+ );
23331
23842
  if (!Array.isArray(path)) throw E("path/bad-input", "validate: path must be an array of certificates");
23332
23843
  var maxCerts = guard.limits.cap(opts.maxPathCerts, "validate: opts.maxPathCerts", constants.LIMITS.PATH_MAX_CERTS, { E, code: "path/bad-input", min: 1 });
23333
23844
  if (path.length > maxCerts) throw E("path/bad-input", "validate: the certification path has " + path.length + " certificates, exceeding the maxPathCerts limit (" + maxCerts + ")");
@@ -23401,12 +23912,12 @@ var require_path_validate = __commonJS({
23401
23912
  checks.push({ name: "kemKeyUsage", ok: kku.ok, code: kku.ok ? void 0 : kku.code });
23402
23913
  if (!kku.ok) failed = true;
23403
23914
  }
23404
- var t = opts.time;
23915
+ var t = guard.time.instantOf(opts.time);
23405
23916
  var vOk = true, vCode;
23406
- if (t < cert.validity.notBefore) {
23917
+ if (t < guard.time.instantOf(cert.validity.notBefore)) {
23407
23918
  vOk = false;
23408
23919
  vCode = "path/not-yet-valid";
23409
- } else if (t > cert.validity.notAfter) {
23920
+ } else if (t > guard.time.instantOf(cert.validity.notAfter)) {
23410
23921
  vOk = false;
23411
23922
  vCode = "path/expired";
23412
23923
  }
@@ -23528,7 +24039,7 @@ var require_path_validate = __commonJS({
23528
24039
  var distrustDate = assertAnchorConstraints(ta, checkPurpose);
23529
24040
  if (distrustDate != null) {
23530
24041
  anchorDistrustApplied = true;
23531
- if (cert.validity.notBefore > distrustDate) {
24042
+ if (guard.time.instantOf(cert.validity.notBefore) > guard.time.instantOf(distrustDate)) {
23532
24043
  checks.push({ name: "distrustAfter", ok: false, code: "path/distrusted-after" });
23533
24044
  failed = true;
23534
24045
  }
@@ -23789,7 +24300,7 @@ var require_path_validate = __commonJS({
23789
24300
  best = c;
23790
24301
  continue;
23791
24302
  }
23792
- var t = c.crl.thisUpdate.getTime(), bt = best.crl.thisUpdate.getTime();
24303
+ var t = guard.time.instantOf(c.crl.thisUpdate), bt = guard.time.instantOf(best.crl.thisUpdate);
23793
24304
  if (t > bt) {
23794
24305
  best = c;
23795
24306
  continue;
@@ -23903,8 +24414,8 @@ var require_path_validate = __commonJS({
23903
24414
  }
23904
24415
  }
23905
24416
  }
23906
- if (theCrl.thisUpdate > time) return null;
23907
- if (!theCrl.nextUpdate || theCrl.nextUpdate < time) return null;
24417
+ if (guard.time.instantOf(theCrl.thisUpdate) > guard.time.instantOf(time)) return null;
24418
+ if (!theCrl.nextUpdate || guard.time.instantOf(theCrl.nextUpdate) < guard.time.instantOf(time)) return null;
23908
24419
  var sigOk = await crlVerify.verifyCrlSignature(theCrl, issuer.workingPublicKey);
23909
24420
  if (!sigOk) return null;
23910
24421
  void sawIdp;
@@ -23914,7 +24425,7 @@ var require_path_validate = __commonJS({
23914
24425
  for (var r = 0; r < theCrl.revokedCertificates.length; r++) {
23915
24426
  var entry = theCrl.revokedCertificates[r];
23916
24427
  if (entry.serialNumberHex !== cert.serialNumberHex) continue;
23917
- if (historical && entry.revocationDate instanceof Date && entry.revocationDate.getTime() > time.getTime()) continue;
24428
+ if (historical && guard.time.isDate(entry.revocationDate) && guard.time.instantOf(entry.revocationDate) > guard.time.instantOf(time)) continue;
23918
24429
  var rc = crlEntryReason(entry);
23919
24430
  return rc === null ? 0 : rc;
23920
24431
  }
@@ -24105,7 +24616,7 @@ var require_path_validate = __commonJS({
24105
24616
  }
24106
24617
  function _verifyOcspParsed(parsedResponse, cert, issuerCert, time, opts) {
24107
24618
  opts = opts || {};
24108
- if (!(time instanceof Date) || isNaN(time.getTime())) {
24619
+ if (!guard.time.isDate(time) || isNaN(guard.time.instantOf(time))) {
24109
24620
  return Promise.reject(E("path/bad-input", "verifyOcspResponse: time must be a valid Date (the currency + responder-validity check date)"));
24110
24621
  }
24111
24622
  function unbound(reason) {
@@ -24252,7 +24763,7 @@ var require_path_validate = __commonJS({
24252
24763
  var ku = softDecode(cand, OID.keyUsage);
24253
24764
  if (ku && ku.value && ku.value.keyCertSign === true) score += 10;
24254
24765
  var v = cand.validity;
24255
- if (v && v.notBefore instanceof Date && v.notAfter instanceof Date && v.notBefore.getTime() <= time.getTime() && time.getTime() <= v.notAfter.getTime()) score += 5;
24766
+ if (v && guard.time.isDate(v.notBefore) && guard.time.isDate(v.notAfter) && guard.time.instantOf(v.notBefore) <= guard.time.instantOf(time) && guard.time.instantOf(time) <= guard.time.instantOf(v.notAfter)) score += 5;
24256
24767
  return score;
24257
24768
  }
24258
24769
  function _pushCandidates(frame, scored, stack, counter) {
@@ -24352,9 +24863,39 @@ var require_path_validate = __commonJS({
24352
24863
  }
24353
24864
  return out;
24354
24865
  }
24866
+ var _BUILD_OPTS = (function() {
24867
+ var o = {
24868
+ aiaTimeout: 1,
24869
+ candidates: 1,
24870
+ fetchAia: 1,
24871
+ intermediates: 1,
24872
+ maxAiaFetches: 1,
24873
+ maxAiaPerCert: 1,
24874
+ maxCandidatesConsidered: 1,
24875
+ maxDepth: 1,
24876
+ maxPathCerts: 1,
24877
+ maxResponseBytes: 1,
24878
+ time: 1,
24879
+ tls: 1,
24880
+ transport: 1,
24881
+ trustAnchors: 1,
24882
+ validate: 1
24883
+ };
24884
+ Object.keys(_VALIDATE_OPTS).forEach(function(k) {
24885
+ o[k] = 1;
24886
+ });
24887
+ delete o.trustAnchor;
24888
+ return o;
24889
+ })();
24355
24890
  async function build(leaf, opts) {
24356
- opts = opts || {};
24357
- if (typeof opts !== "object" || Buffer.isBuffer(opts)) throw E("path/bad-input", "build: opts must be an object");
24891
+ opts = guard.identifier.optionsObject(opts, E, "path/bad-input", "build: opts");
24892
+ guard.identifier.assertKnownKeys(
24893
+ opts,
24894
+ _BUILD_OPTS,
24895
+ E,
24896
+ "path/bad-input",
24897
+ "pki.path.build has an unknown option. The anchors here are `trustAnchors`, plural; pki.path.validate takes `trustAnchor`. The unknown option was: "
24898
+ );
24358
24899
  var leafCert;
24359
24900
  try {
24360
24901
  leafCert = coerceCert(leaf);
@@ -24429,12 +24970,13 @@ var require_path_validate = __commonJS({
24429
24970
  aiaTimeout: 1,
24430
24971
  maxResponseBytes: 1
24431
24972
  };
24432
- var forwarded = {};
24433
- Object.keys(opts).forEach(function(k) {
24434
- if (!BUILD_ONLY_OPT[k]) forwarded[k] = opts[k];
24973
+ var forwarded = /* @__PURE__ */ Object.create(null);
24974
+ Object.keys(_VALIDATE_OPTS).forEach(function(k) {
24975
+ if (Object.prototype.hasOwnProperty.call(BUILD_ONLY_OPT, k)) return;
24976
+ if (k in opts) forwarded[k] = opts[k];
24435
24977
  });
24436
24978
  function validateOpts(anchor) {
24437
- var vo = {};
24979
+ var vo = /* @__PURE__ */ Object.create(null);
24438
24980
  Object.keys(forwarded).forEach(function(f) {
24439
24981
  vo[f] = forwarded[f];
24440
24982
  });
@@ -26351,10 +26893,8 @@ var require_cmc_verify = __commonJS({
26351
26893
  return input;
26352
26894
  }
26353
26895
  function _copyAnyBytes(v) {
26354
- if (Buffer.isBuffer(v) || v instanceof Uint8Array) return guard.bytes.snapshot(v, CmcError, "cmc/bad-input", "a byte field of the request");
26355
- if (ArrayBuffer.isView(v)) return Buffer.from(new Uint8Array(v.buffer, v.byteOffset, v.byteLength));
26356
- if (v instanceof ArrayBuffer) return Buffer.from(new Uint8Array(v));
26357
- return v;
26896
+ if (!guard.bytes.isByteSource(v)) return v;
26897
+ return guard.bytes.snapshotSource(v, CmcError, "cmc/bad-input", "a byte field of the request");
26358
26898
  }
26359
26899
  function _snapshotSent(sent) {
26360
26900
  var out = {}, k;
@@ -26616,7 +27156,7 @@ var require_tsp_sign = __commonJS({
26616
27156
  if (!NODE_DIGEST[certHashAlg]) throw _err("tsp/unsupported-algorithm", "unsupported certHashAlgorithm " + JSON.stringify(certHashAlg));
26617
27157
  var imprint = b.sequence([_hashAlgId(mi.hashAlgorithm), b.octetString(Buffer.from(mi.hashedMessage))]);
26618
27158
  if (opts.genTime != null) guard.time.assertValid(opts.genTime, _err, "tsp/bad-input", "genTime");
26619
- var genTime = opts.genTime instanceof Date ? opts.genTime : /* @__PURE__ */ new Date();
27159
+ var genTime = guard.time.isDate(opts.genTime) ? opts.genTime : /* @__PURE__ */ new Date();
26620
27160
  var serial = guard.range.authoredInteger(opts.serialNumber, _err, "tsp/bad-input", "serialNumber");
26621
27161
  var fields = [b.integer(1n), _policy(opts.policy), imprint, b.integer(serial), b.generalizedTime(genTime)];
26622
27162
  if (opts.accuracy) fields.push(_accuracy(opts.accuracy));
@@ -26947,7 +27487,7 @@ var require_tsp_sign = __commonJS({
26947
27487
  if (opts.trustAnchor) {
26948
27488
  var pathRes = null;
26949
27489
  var floorT = tst.genTime;
26950
- var ceilT = tst.genTimeFraction != null && /[1-9]/.test(tst.genTimeFraction.slice(3)) ? new Date(floorT.getTime() + 1) : floorT;
27490
+ var ceilT = tst.genTimeFraction != null && /[1-9]/.test(tst.genTimeFraction.slice(3)) ? new Date(guard.time.instantOf(floorT) + 1) : floorT;
26951
27491
  try {
26952
27492
  var pool = (parsed.certificates || []).filter(function(c) {
26953
27493
  return c.tagClass === "universal";
@@ -27120,8 +27660,23 @@ var require_ocsp = __commonJS({
27120
27660
  [opts, "pki.ocsp.buildRequest options"]
27121
27661
  ], _buildRequest);
27122
27662
  }
27663
+ var _BUILD_REQUEST_OPTS = {
27664
+ hashAlgorithm: 1,
27665
+ nonce: 1,
27666
+ pem: 1,
27667
+ profile: 1,
27668
+ requestorName: 1,
27669
+ signer: 1
27670
+ };
27123
27671
  function _buildRequest(query, opts) {
27124
- opts = opts || {};
27672
+ opts = guard.identifier.optionsObject(opts, _err, "ocsp/bad-input", "pki.ocsp.buildRequest options");
27673
+ guard.identifier.assertKnownKeys(
27674
+ opts,
27675
+ _BUILD_REQUEST_OPTS,
27676
+ _err,
27677
+ "ocsp/bad-input",
27678
+ "pki.ocsp.buildRequest has an unknown option (the anti-replay nonce is `nonce`): "
27679
+ );
27125
27680
  var lightweight = opts.profile === "lightweight";
27126
27681
  var hashName = opts.hashAlgorithm || "sha1";
27127
27682
  if (lightweight && hashName !== "sha1") throw _err("ocsp/bad-input", "the lightweight profile requires a SHA-1 CertID (RFC 5019 sec. 2.1.1)");
@@ -27195,8 +27750,16 @@ var require_ocsp = __commonJS({
27195
27750
  [opts, "pki.ocsp.sign options"]
27196
27751
  ], _sign);
27197
27752
  }
27753
+ var _SIGN_OPTS = { embedCert: 1, extendedRevoke: 1, nonce: 1, pem: 1 };
27198
27754
  function _sign(responseData, responder, opts) {
27199
- opts = opts || {};
27755
+ opts = guard.identifier.optionsObject(opts, _err, "ocsp/bad-input", "pki.ocsp.sign options");
27756
+ guard.identifier.assertKnownKeys(
27757
+ opts,
27758
+ _SIGN_OPTS,
27759
+ _err,
27760
+ "ocsp/bad-input",
27761
+ "pki.ocsp.sign has an unknown option (the nonce to echo back is `nonce`): "
27762
+ );
27200
27763
  responseData = responseData || {};
27201
27764
  if (!responder || responder.cert == null || responder.key == null) throw _err("ocsp/bad-input", "a responder must be { cert, key }");
27202
27765
  var respCertDer = _normCertDer(responder.cert, "the responder certificate");
@@ -27254,8 +27817,8 @@ var require_ocsp = __commonJS({
27254
27817
  }
27255
27818
  function _asDate(d) {
27256
27819
  if (d == null) return null;
27257
- var dt = d instanceof Date ? d : new Date(d);
27258
- if (isNaN(dt.getTime())) throw _err("ocsp/bad-input", "an invalid date value " + JSON.stringify(d));
27820
+ var dt = guard.time.isDate(d) ? d : new Date(d);
27821
+ if (isNaN(guard.time.instantOf(dt))) throw _err("ocsp/bad-input", "an invalid date value " + JSON.stringify(d));
27259
27822
  return dt;
27260
27823
  }
27261
27824
  function _snapshotSignerKey(key, owned) {
@@ -27313,8 +27876,20 @@ var require_ocsp = __commonJS({
27313
27876
  if (code == null) throw _err("ocsp/bad-input", "an error responseStatus must be one of " + Object.keys(ERROR_STATUS).join(" / "));
27314
27877
  return b.sequence([b.enumerated(BigInt(code))]);
27315
27878
  }
27879
+ var _VERIFY_OPTS = { cert: 1, historicalMode: 1, issuer: 1, requestNonce: 1, time: 1 };
27316
27880
  function verify(response, opts) {
27317
- opts = opts || {};
27881
+ try {
27882
+ opts = guard.identifier.optionsObject(opts, _err, "ocsp/bad-input", "pki.ocsp.verify options");
27883
+ guard.identifier.assertKnownKeys(
27884
+ opts,
27885
+ _VERIFY_OPTS,
27886
+ _err,
27887
+ "ocsp/bad-input",
27888
+ "pki.ocsp.verify has an unknown option (the request nonce to bind against is `requestNonce`): "
27889
+ );
27890
+ } catch (e) {
27891
+ return Promise.reject(e);
27892
+ }
27318
27893
  if (opts.cert == null || opts.issuer == null) return Promise.reject(_err("ocsp/bad-input", "verify requires opts.cert and opts.issuer"));
27319
27894
  var parsed, cert, issuerCert, time;
27320
27895
  try {
@@ -27592,7 +28167,7 @@ var require_x509_sign = __commonJS({
27592
28167
  var serialTlv = _serialInteger(spec.serialNumber);
27593
28168
  guard.time.assertValid(spec.notBefore, _err, "x509/bad-input", "notBefore");
27594
28169
  guard.time.assertValid(spec.notAfter, _err, "x509/bad-input", "notAfter");
27595
- if (spec.notBefore.getTime() > spec.notAfter.getTime()) throw _err("x509/bad-input", "notBefore must not be after notAfter (RFC 5280 sec. 4.1.2.5)");
28170
+ if (guard.time.instantOf(spec.notBefore) > guard.time.instantOf(spec.notAfter)) throw _err("x509/bad-input", "notBefore must not be after notAfter (RFC 5280 sec. 4.1.2.5)");
27596
28171
  var validityDer = b.sequence([_timeDer(spec.notBefore, "notBefore"), _timeDer(spec.notAfter, "notAfter")]);
27597
28172
  var exts = _buildExtensions(spec.extensions, { spki, issuerSpki, issuerCert, subjectEmpty });
27598
28173
  if (subjectEmpty && !_hasCriticalSan(spec.extensions)) {
@@ -27886,7 +28461,7 @@ var require_attrcert_sign = __commonJS({
27886
28461
  function _encodeValidity(notBefore, notAfter) {
27887
28462
  guard.time.assertValid(notBefore, _err, "attrcert/bad-input", "notBeforeTime");
27888
28463
  guard.time.assertValid(notAfter, _err, "attrcert/bad-input", "notAfterTime");
27889
- if (notBefore.getTime() > notAfter.getTime()) throw _err("attrcert/bad-input", "notBeforeTime must not be after notAfterTime (RFC 5755 sec. 4.2.6)");
28464
+ if (guard.time.instantOf(notBefore) > guard.time.instantOf(notAfter)) throw _err("attrcert/bad-input", "notBeforeTime must not be after notAfterTime (RFC 5755 sec. 4.2.6)");
27890
28465
  return b.sequence([b.generalizedTime(notBefore), b.generalizedTime(notAfter)]);
27891
28466
  }
27892
28467
  function _encodeRole(role) {
@@ -28550,7 +29125,7 @@ var require_crl_sign = __commonJS({
28550
29125
  var nextU = null;
28551
29126
  if (spec.nextUpdate != null) {
28552
29127
  nextU = _timeDer(spec.nextUpdate, "nextUpdate");
28553
- if (spec.nextUpdate.getTime() < spec.thisUpdate.getTime()) throw _err("crl/bad-input", "nextUpdate must not be before thisUpdate (RFC 5280 sec. 5.1.2.5)");
29128
+ if (guard.time.instantOf(spec.nextUpdate) < guard.time.instantOf(spec.thisUpdate)) throw _err("crl/bad-input", "nextUpdate must not be before thisUpdate (RFC 5280 sec. 5.1.2.5)");
28554
29129
  }
28555
29130
  var extResult = _buildCrlExtensions(spec, { issuerCert, issuerSpki });
28556
29131
  var crlExts = extResult.exts;
@@ -28751,8 +29326,16 @@ var require_key = __commonJS({
28751
29326
  }
28752
29327
  return pkix.coerceToDer(input, { pemLabel: "PRIVATE KEY", PemError, ErrorClass: KeyError, prefix: "key" });
28753
29328
  }
29329
+ var _ENCRYPT_OPTS = { cipher: 1, iterations: 1, pem: 1, prf: 1, salt: 1 };
28754
29330
  async function encrypt(privateKey, password, opts) {
28755
- opts = opts || {};
29331
+ opts = guard.identifier.optionsObject(opts, _err, "key/bad-input", "pki.key.encrypt options");
29332
+ guard.identifier.assertKnownKeys(
29333
+ opts,
29334
+ _ENCRYPT_OPTS,
29335
+ _err,
29336
+ "key/bad-input",
29337
+ "pki.key.encrypt has an unknown option (the PBKDF2 count here is `iterations`; `maxIterations` is the decrypt-side cap): "
29338
+ );
28756
29339
  var der = await _toPrivateKeyDer(privateKey);
28757
29340
  try {
28758
29341
  pkcs8.parse(der);
@@ -28783,8 +29366,16 @@ var require_key = __commonJS({
28783
29366
  guard.secret.zeroize(dk, KeyError, "key/bad-input", "the password-derived encryption key");
28784
29367
  }
28785
29368
  }
29369
+ var _DECRYPT_OPTS = { maxIterations: 1, pem: 1 };
28786
29370
  async function decrypt(encrypted, password, opts) {
28787
- opts = opts || {};
29371
+ opts = guard.identifier.optionsObject(opts, _err, "key/bad-input", "pki.key.decrypt options");
29372
+ guard.identifier.assertKnownKeys(
29373
+ opts,
29374
+ _DECRYPT_OPTS,
29375
+ _err,
29376
+ "key/bad-input",
29377
+ "pki.key.decrypt has an unknown option (the PBKDF2 cap here is `maxIterations`; `iterations` is the encrypt-side count): "
29378
+ );
28788
29379
  if (opts.maxIterations != null && (typeof opts.maxIterations !== "number" || !isFinite(opts.maxIterations) || opts.maxIterations < 1 || Math.floor(opts.maxIterations) !== opts.maxIterations)) {
28789
29380
  throw _err("key/bad-input", "maxIterations must be a positive integer");
28790
29381
  }
@@ -28815,8 +29406,16 @@ var require_key = __commonJS({
28815
29406
  }
28816
29407
  return plaintext;
28817
29408
  }
29409
+ var _EXPORT_OPTS = { format: 1, label: 1 };
28818
29410
  async function export_(key, opts) {
28819
- opts = opts || {};
29411
+ opts = guard.identifier.optionsObject(opts, _err, "key/bad-input", "pki.key.export options");
29412
+ guard.identifier.assertKnownKeys(
29413
+ opts,
29414
+ _EXPORT_OPTS,
29415
+ _err,
29416
+ "key/bad-input",
29417
+ "pki.key.export has an unknown option. It serializes only. To protect a private key, call pki.key.encrypt(key, password) first and export its result. The unknown option was: "
29418
+ );
28820
29419
  if (!_isCryptoKey(key)) throw _err("key/bad-input", "export expects a WebCrypto CryptoKey");
28821
29420
  var defaultLabel;
28822
29421
  if (key.type === "private") defaultLabel = "PRIVATE KEY";
@@ -28828,8 +29427,16 @@ var require_key = __commonJS({
28828
29427
  if (fmt === "pem") return pkix.pemEncode(der, opts.label || defaultLabel, PemError);
28829
29428
  throw _err("key/bad-input", "unsupported format " + JSON.stringify(opts.format) + " (der / pem)");
28830
29429
  }
29430
+ var _IMPORT_OPTS = { algorithm: 1, extractable: 1, password: 1, usages: 1 };
28831
29431
  async function import_(input, opts) {
28832
- opts = opts || {};
29432
+ opts = guard.identifier.optionsObject(opts, _err, "key/bad-input", "pki.key.import options");
29433
+ guard.identifier.assertKnownKeys(
29434
+ opts,
29435
+ _IMPORT_OPTS,
29436
+ _err,
29437
+ "key/bad-input",
29438
+ "pki.key.import has an unknown option: "
29439
+ );
28833
29440
  var detected = _detectKeyInput(input);
28834
29441
  if (detected.format === "encrypted") {
28835
29442
  if (opts.password == null) throw _err("key/bad-input", "an ENCRYPTED PRIVATE KEY requires opts.password to import");
@@ -28846,8 +29453,16 @@ var require_key = __commonJS({
28846
29453
  throw _err("key/bad-input", "importKey failed", e);
28847
29454
  }
28848
29455
  }
29456
+ var _GENERATE_OPTS = { extractable: 1, usages: 1 };
28849
29457
  async function generate(algorithm, opts) {
28850
- opts = opts || {};
29458
+ opts = guard.identifier.optionsObject(opts, _err, "key/bad-input", "pki.key.generate options");
29459
+ guard.identifier.assertKnownKeys(
29460
+ opts,
29461
+ _GENERATE_OPTS,
29462
+ _err,
29463
+ "key/bad-input",
29464
+ "pki.key.generate has an unknown option (the WebCrypto spelling is `extractable`): "
29465
+ );
28851
29466
  var extractable = opts.extractable != null ? opts.extractable : true;
28852
29467
  var usages = opts.usages || _generateUsages(_algName(algorithm));
28853
29468
  var pair;
@@ -28860,8 +29475,16 @@ var require_key = __commonJS({
28860
29475
  if (!pair || !pair.privateKey || !pair.publicKey) throw _err("key/bad-input", "the algorithm does not generate an asymmetric key pair");
28861
29476
  return { privateKey: pair.privateKey, publicKey: pair.publicKey };
28862
29477
  }
29478
+ var _PUBLIC_FROM_PRIVATE_OPTS = { pem: 1 };
28863
29479
  async function publicFromPrivate(privateKey, opts) {
28864
- opts = opts || {};
29480
+ opts = guard.identifier.optionsObject(opts, _err, "key/bad-input", "pki.key.publicFromPrivate options");
29481
+ guard.identifier.assertKnownKeys(
29482
+ opts,
29483
+ _PUBLIC_FROM_PRIVATE_OPTS,
29484
+ _err,
29485
+ "key/bad-input",
29486
+ "pki.key.publicFromPrivate has an unknown option: "
29487
+ );
28865
29488
  var der = await _toPrivateKeyDer(privateKey);
28866
29489
  var spki;
28867
29490
  try {
@@ -30884,8 +31507,8 @@ var require_sigstore = __commonJS({
30884
31507
  function _toMs(x) {
30885
31508
  if (x == null) return null;
30886
31509
  if (typeof x === "number") return Number.isFinite(x) ? x : null;
30887
- if (x instanceof Date) {
30888
- var d = x.getTime();
31510
+ if (guard.time.isDate(x)) {
31511
+ var d = guard.time.instantOf(x);
30889
31512
  return isNaN(d) ? null : d;
30890
31513
  }
30891
31514
  if (typeof x === "string") {
@@ -31198,7 +31821,7 @@ var require_sigstore = __commonJS({
31198
31821
  }
31199
31822
  }
31200
31823
  if (integratedTime === null) throw lastErr;
31201
- var checkTime = opts.time instanceof Date ? opts.time.getTime() : C.TIME.seconds(integratedTime);
31824
+ var checkTime = guard.time.isDate(opts.time) ? guard.time.instantOf(opts.time) : C.TIME.seconds(integratedTime);
31202
31825
  await _verifyChain(leaf, _chainDers(vm), fulcioRoots, checkTime);
31203
31826
  var identity = _identity(leaf);
31204
31827
  var identityChecked = _checkIdentity(identity, opts.identity);
@@ -31944,8 +32567,8 @@ var require_est = __commonJS({
31944
32567
  return asn1.build.sequence([asn1.build.oid(typeOid), asn1.build.set(valueNodes)]);
31945
32568
  }
31946
32569
  function challengePasswordFromTlsUnique(channelBinding) {
31947
- if (!Buffer.isBuffer(channelBinding) || channelBinding.length === 0) throw E("est/bad-input", "challengePasswordFromTlsUnique requires the channel-binding bytes");
31948
- var b64 = channelBinding.toString("base64");
32570
+ if (!Buffer.isBuffer(channelBinding) || guard.bytes.lengthOf(channelBinding) === 0) throw E("est/bad-input", "challengePasswordFromTlsUnique requires the channel-binding bytes");
32571
+ var b64 = guard.bytes.view(channelBinding, EstError, "est/bad-input", "the channel-binding bytes").toString("base64");
31949
32572
  if (b64.length > 255) throw E("est/tls-unique-too-long", "the base64 tls-unique value exceeds 255 octets (RFC 7030 sec. 3.5)");
31950
32573
  return _attr(OID_CHALLENGE_PASSWORD, [asn1.build.printable(b64)]);
31951
32574
  }
@@ -32125,7 +32748,7 @@ var require_est = __commonJS({
32125
32748
  function step() {
32126
32749
  return transport({ method, url: url.href, headers: _headersFor(url), body, tls: _tlsFor(url), timeout: budgets.timeout, maxResponseBytes: budgets.maxResponseBytes }).then(function(res) {
32127
32750
  res = res || {};
32128
- var blen = Buffer.isBuffer(res.body) ? res.body.length : Buffer.byteLength(String(res.body == null ? "" : res.body), "utf8");
32751
+ var blen = Buffer.isBuffer(res.body) ? guard.bytes.lengthOf(res.body) : Buffer.byteLength(String(res.body == null ? "" : res.body), "utf8");
32129
32752
  if (blen > budgets.maxResponseBytes) throw E("est/response-too-large", "the response body (" + blen + " bytes) exceeds the " + budgets.maxResponseBytes + "-byte cap (RFC 7030 sec. 6)");
32130
32753
  var h = {
32131
32754
  location: _ciHeader(res.headers, "location"),
@@ -32221,7 +32844,7 @@ var require_est = __commonJS({
32221
32844
  return { retry: true, retryAfterSeconds: verdict.retryAfterSeconds, retryAfterDate: verdict.retryAfterDate };
32222
32845
  }
32223
32846
  if (verdict.status !== "ok") throw E("est/http-error", "an EST " + op + " response must be HTTP 200 or 202 (RFC 7030 sec. 4.1.3 / 4.2.3), got " + res.status);
32224
- var bodyLen = Buffer.isBuffer(res.body) ? res.body.length : Buffer.byteLength(String(res.body == null ? "" : res.body), "utf8");
32847
+ var bodyLen = Buffer.isBuffer(res.body) ? guard.bytes.lengthOf(res.body) : Buffer.byteLength(String(res.body == null ? "" : res.body), "utf8");
32225
32848
  if (bodyLen === 0) throw E("est/empty-body", "a 200 " + op + " response carried an empty body (RFC 7030 sec. 4.1.3 / 4.2.3)");
32226
32849
  var parsed = parseCertsOnly(transferDecode(res.body));
32227
32850
  if (op === "cacerts") return { certificates: parsed.certificates, crls: parsed.crls };
@@ -32381,10 +33004,8 @@ var require_est = __commonJS({
32381
33004
  };
32382
33005
  }
32383
33006
  function _copyBytes(v) {
32384
- if (Buffer.isBuffer(v) || v instanceof Uint8Array) return guard.bytes.snapshot(v, EstError, "est/bad-input", "a byte field of the request");
32385
- if (ArrayBuffer.isView(v)) return Buffer.from(new Uint8Array(v.buffer, v.byteOffset, v.byteLength));
32386
- if (v instanceof ArrayBuffer) return Buffer.from(new Uint8Array(v));
32387
- return v;
33007
+ if (!guard.bytes.isByteSource(v)) return v;
33008
+ return guard.bytes.snapshotSource(v, EstError, "est/bad-input", "a byte field of the request");
32388
33009
  }
32389
33010
  function _requestBinding(der) {
32390
33011
  var out = {
@@ -32526,7 +33147,7 @@ var require_est = __commonJS({
32526
33147
  "an EST /fullcmc response must be HTTP 200 or 202 (RFC 7030 sec. 4.3.2), got " + res.status
32527
33148
  );
32528
33149
  }
32529
- var bodyLen = Buffer.isBuffer(res.body) ? res.body.length : Buffer.byteLength(String(res.body == null ? "" : res.body), "utf8");
33150
+ var bodyLen = Buffer.isBuffer(res.body) ? guard.bytes.lengthOf(res.body) : Buffer.byteLength(String(res.body == null ? "" : res.body), "utf8");
32530
33151
  if (bodyLen === 0) throw E("est/empty-body", "a 200 /fullcmc response carried an empty body (RFC 7030 sec. 4.3.2)");
32531
33152
  var der = transferDecode(res.body);
32532
33153
  var pt200 = _partMediaType(_ciHeader(res.headers, "content-type"));
@@ -32694,7 +33315,7 @@ var require_est = __commonJS({
32694
33315
  var verdict = classifyResponse(res.status, res.headers, res.body, { op: "serverkeygen", now: opts.now });
32695
33316
  if (verdict.status === "retry") return { retry: true, retryAfterSeconds: verdict.retryAfterSeconds, retryAfterDate: verdict.retryAfterDate };
32696
33317
  if (verdict.status !== "ok") throw E("est/http-error", "an EST serverkeygen response must be HTTP 200 or 202 (RFC 7030 sec. 4.4.2), got " + res.status);
32697
- var bodyLen = Buffer.isBuffer(res.body) ? res.body.length : Buffer.byteLength(String(res.body == null ? "" : res.body), "utf8");
33318
+ var bodyLen = Buffer.isBuffer(res.body) ? guard.bytes.lengthOf(res.body) : Buffer.byteLength(String(res.body == null ? "" : res.body), "utf8");
32698
33319
  if (bodyLen === 0) throw E("est/empty-body", "a 200 serverkeygen response carried an empty body (RFC 7030 sec. 4.4.2)");
32699
33320
  _assertConfidentialCipher(res);
32700
33321
  var out = parseServerKeygenResponse(res.body, _ciHeader(res.headers, "content-type"), {
@@ -32749,7 +33370,7 @@ var require_est = __commonJS({
32749
33370
  if (verdict.status === "none-available") return { available: false, attrs: null };
32750
33371
  if (verdict.status === "retry") throw E("est/http-error", "a /csrattrs response must be HTTP 200, 204, or 404, not 202 (RFC 7030 sec. 4.5.2)");
32751
33372
  if (verdict.status !== "ok") throw E("est/http-error", "an EST csrattrs response must be HTTP 200 / 204 / 404 (RFC 7030 sec. 4.5.2), got " + res.status);
32752
- var bodyLen = Buffer.isBuffer(res.body) ? res.body.length : Buffer.byteLength(String(res.body == null ? "" : res.body), "utf8");
33373
+ var bodyLen = Buffer.isBuffer(res.body) ? guard.bytes.lengthOf(res.body) : Buffer.byteLength(String(res.body == null ? "" : res.body), "utf8");
32753
33374
  if (bodyLen === 0) throw E("est/empty-body", "a 200 csrattrs response carried an empty body (RFC 7030 sec. 4.5.2)");
32754
33375
  var attrs = csrattrsFmt.parse(transferDecode(res.body));
32755
33376
  return { available: true, attrs, plan: buildEnrollAttributes(attrs) };
@@ -34191,7 +34812,7 @@ var require_acme = __commonJS({
34191
34812
  Object.keys(res.headers || {}).forEach(function(k) {
34192
34813
  h[k.toLowerCase()] = res.headers[k];
34193
34814
  });
34194
- var blen = Buffer.isBuffer(res.body) ? res.body.length : Buffer.byteLength(String(res.body == null ? "" : res.body), "utf8");
34815
+ var blen = Buffer.isBuffer(res.body) ? guard.bytes.lengthOf(res.body) : Buffer.byteLength(String(res.body == null ? "" : res.body), "utf8");
34195
34816
  if (blen > budgets.maxResponseBytes) throw E("acme/response-too-large", "the response body (" + blen + " bytes) exceeds the " + budgets.maxResponseBytes + "-byte cap");
34196
34817
  if ((method === "GET" || method === "HEAD") && res.status >= 300 && res.status < 400) {
34197
34818
  if (redirects >= budgets.maxRedirects) throw E("acme/too-many-redirects", "the redirect budget of " + budgets.maxRedirects + " was exceeded");
@@ -34517,7 +35138,7 @@ var require_acme = __commonJS({
34517
35138
  if (typeof t !== "number" || !isFinite(t)) throw E("acme/bad-input", "the renewalInfo clock returned a non-finite value");
34518
35139
  return t;
34519
35140
  }
34520
- var notAfterMs = x509.parse(certDer).validity.notAfter.getTime();
35141
+ var notAfterMs = guard.time.instantOf(x509.parse(certDer).validity.notAfter);
34521
35142
  if (clk() > notAfterMs) throw E("acme/certificate-expired", "the certificate is already past its notAfter; a client MUST NOT check RenewalInfo after it has expired (RFC 9773 sec. 4.3)");
34522
35143
  var certId = ariCertId(certDer);
34523
35144
  return _resource("renewalInfo").then(function(base) {
@@ -34558,12 +35179,12 @@ var require_acme = __commonJS({
34558
35179
  }
34559
35180
  var notAfter = x509.parse(certDer).validity.notAfter;
34560
35181
  var now = clk();
34561
- if (now > notAfter.getTime()) throw E("acme/certificate-expired", "the certificate is already past its notAfter; there is nothing to renew (RFC 9773 sec. 4.3)");
35182
+ if (now > guard.time.instantOf(notAfter)) throw E("acme/certificate-expired", "the certificate is already past its notAfter; there is nothing to renew (RFC 9773 sec. 4.3)");
34562
35183
  if (o.replaced === true) throw E("acme/certificate-replaced", "the caller asserts this certificate has already been replaced (RFC 9773 sec. 4.3)");
34563
35184
  return _renewalInfo(certDer, clk, RENEWAL_RETRY_MAX_SECONDS).then(function(ri) {
34564
35185
  var w = ri.renewalInfo.suggestedWindow;
34565
35186
  var startMs = Date.parse(w.start), endMs = Date.parse(w.end);
34566
- var notAfterMs = notAfter.getTime();
35187
+ var notAfterMs = guard.time.instantOf(notAfter);
34567
35188
  var effEnd = Math.min(endMs, notAfterMs), effStart = Math.min(startMs, effEnd);
34568
35189
  var pw = o.previous && _isObject(o.previous.suggestedWindow) ? o.previous.suggestedWindow : null;
34569
35190
  var selectedMs;
@@ -34904,7 +35525,7 @@ var require_trust = __commonJS({
34904
35525
  var out = {};
34905
35526
  if (!src || typeof src !== "object") return out;
34906
35527
  Object.keys(src).forEach(function(k) {
34907
- out[k] = src[k] instanceof Date ? new Date(src[k].getTime()) : src[k];
35528
+ out[k] = guard.time.isDate(src[k]) ? new Date(guard.time.instantOf(src[k])) : src[k];
34908
35529
  });
34909
35530
  return out;
34910
35531
  }
@@ -34923,7 +35544,7 @@ var require_trust = __commonJS({
34923
35544
  var kx = Object.keys(x).sort(), ky = Object.keys(y).sort();
34924
35545
  if (kx.join(",") !== ky.join(",")) return false;
34925
35546
  return kx.every(function(k) {
34926
- return x[k].getTime() === y[k].getTime();
35547
+ return guard.time.instantOf(x[k]) === guard.time.instantOf(y[k]);
34927
35548
  });
34928
35549
  }
34929
35550
  function _purposesEqual(x, y) {
@@ -35276,8 +35897,9 @@ var require_inspect = __commonJS({
35276
35897
  return (n < 10 ? "0" : "") + n;
35277
35898
  }
35278
35899
  function _date(iso) {
35279
- var d = iso instanceof Date ? iso : new Date(iso);
35280
- if (isNaN(d.getTime())) return String(iso);
35900
+ var held = guard.time.isDate(iso) ? guard.time.instantOf(iso) : Date.parse(String(iso));
35901
+ if (isNaN(held)) return String(iso);
35902
+ var d = new Date(held);
35281
35903
  var day = d.getUTCDate(), dd = (day < 10 ? " " : "") + day;
35282
35904
  return MONTHS[d.getUTCMonth()] + " " + dd + " " + _two(d.getUTCHours()) + ":" + _two(d.getUTCMinutes()) + ":" + _two(d.getUTCSeconds()) + " " + d.getUTCFullYear() + " GMT";
35283
35905
  }
@@ -35756,7 +36378,7 @@ var require_inspect = __commonJS({
35756
36378
  var inner = pad + " ";
35757
36379
  if (ext.oid === OID_CRL_NUMBER && typeof ext.value === "bigint") return header + "\n" + inner + String(ext.value);
35758
36380
  if (ext.oid === OID_REASON_CODE && typeof ext.value === "number") return header + "\n" + inner + (NAMES.CRL_REASON[ext.value] || String(ext.value));
35759
- if (ext.oid === OID_INVALIDITY_DATE && ext.value instanceof Date) return header + "\n" + inner + _date(ext.value);
36381
+ if (ext.oid === OID_INVALIDITY_DATE && guard.time.isDate(ext.value)) return header + "\n" + inner + _date(ext.value);
35760
36382
  if (ext.oid === OID_DELTA_CRL_INDICATOR && Buffer.isBuffer(ext.value)) {
35761
36383
  try {
35762
36384
  return header + "\n" + inner + "BaseCRLNumber: " + String(asn1.read.integer(asn1.decode(ext.value)));
@@ -36098,7 +36720,7 @@ var require_lint = __commonJS({
36098
36720
  function _effective(rule, cert) {
36099
36721
  if (!rule.effectiveDate) return true;
36100
36722
  var nb = cert.validity && cert.validity.notBefore;
36101
- return nb instanceof Date && nb.getTime() >= rule.effectiveDate.getTime();
36723
+ return guard.time.isDate(nb) && guard.time.instantOf(nb) >= guard.time.instantOf(rule.effectiveDate);
36102
36724
  }
36103
36725
  function _runLints(rules2, cert, ctx) {
36104
36726
  var findings = [], counts = { fatal: 0, error: 0, warn: 0, notice: 0, pass: 0, na: 0, ne: 0 }, ran = [];
@@ -36275,7 +36897,7 @@ var require_lint = __commonJS({
36275
36897
  message: "the certificate notBefore must not be later than notAfter",
36276
36898
  check: function(cert) {
36277
36899
  var v = cert.validity;
36278
- return v.notBefore instanceof Date && v.notAfter instanceof Date && v.notBefore.getTime() > v.notAfter.getTime() ? true : null;
36900
+ return guard.time.isDate(v.notBefore) && guard.time.isDate(v.notAfter) && guard.time.instantOf(v.notBefore) > guard.time.instantOf(v.notAfter) ? true : null;
36279
36901
  }
36280
36902
  },
36281
36903
  {
@@ -36567,7 +37189,7 @@ var require_lint = __commonJS({
36567
37189
  var VALIDITY_SCHEDULE_START = VALIDITY_SCHEDULE[VALIDITY_SCHEDULE.length - 1].from;
36568
37190
  function _validityCeilingDays(notBefore) {
36569
37191
  for (var i = 0; i < VALIDITY_SCHEDULE.length; i++) {
36570
- if (notBefore.getTime() >= VALIDITY_SCHEDULE[i].from.getTime()) return VALIDITY_SCHEDULE[i].maxDays;
37192
+ if (guard.time.instantOf(notBefore) >= guard.time.instantOf(VALIDITY_SCHEDULE[i].from)) return VALIDITY_SCHEDULE[i].maxDays;
36571
37193
  }
36572
37194
  return VALIDITY_SCHEDULE[VALIDITY_SCHEDULE.length - 1].maxDays;
36573
37195
  }
@@ -36666,9 +37288,9 @@ var require_lint = __commonJS({
36666
37288
  effectiveDate: VALIDITY_SCHEDULE_START,
36667
37289
  check: function(cert) {
36668
37290
  var v = cert.validity;
36669
- if (!(v.notBefore instanceof Date) || !(v.notAfter instanceof Date)) return null;
37291
+ if (!guard.time.isDate(v.notBefore) || !guard.time.isDate(v.notAfter)) return null;
36670
37292
  var maxDays = _validityCeilingDays(v.notBefore);
36671
- var days = (v.notAfter.getTime() - v.notBefore.getTime()) / MS_PER_DAY;
37293
+ var days = (guard.time.instantOf(v.notAfter) - guard.time.instantOf(v.notBefore)) / MS_PER_DAY;
36672
37294
  return days > maxDays ? { context: { days: Math.round(days), maxDays } } : null;
36673
37295
  }
36674
37296
  }
@@ -36729,9 +37351,16 @@ var require_lint = __commonJS({
36729
37351
  return (SEVERITY[f.severity] || 0) >= floor;
36730
37352
  });
36731
37353
  }
37354
+ var _CERTIFICATE_OPTS = { profile: 1, severity: 1 };
36732
37355
  function certificate(input, opts) {
36733
- opts = opts || {};
36734
- if (typeof opts !== "object") throw _cfg("lint/bad-input", "pki.lint options must be an object");
37356
+ opts = guard.identifier.optionsObject(opts, _cfg, "lint/bad-input", "pki.lint options");
37357
+ guard.identifier.assertKnownKeys(
37358
+ opts,
37359
+ _CERTIFICATE_OPTS,
37360
+ _cfg,
37361
+ "lint/bad-input",
37362
+ "pki.lint.certificate has an unknown option: "
37363
+ );
36735
37364
  if (opts.severity != null && VALID_SEVERITY.indexOf(opts.severity) === -1) {
36736
37365
  throw _cfg("lint/bad-severity", 'unknown severity threshold "' + opts.severity + '" (known: ' + VALID_SEVERITY.join(", ") + ")");
36737
37366
  }
@@ -37116,11 +37745,11 @@ var require_webauthn_mds = __commonJS({
37116
37745
  "webauthn/bad-metadata-blob",
37117
37746
  "the metadata BLOB nextUpdate"
37118
37747
  );
37119
- return d.getTime() + constants.TIME.days(1);
37748
+ return guard.time.instantOf(d) + constants.TIME.days(1);
37120
37749
  }
37121
37750
  function assertFresh(metadata, at, label) {
37122
37751
  if (!metadata || metadata.allowStale === true || typeof metadata.nextUpdate !== "string") return;
37123
- var atMs = at instanceof Date ? at.getTime() : NaN;
37752
+ var atMs = guard.time.isDate(at) ? guard.time.instantOf(at) : NaN;
37124
37753
  var limit = _staleAfter(metadata.nextUpdate);
37125
37754
  if (!isFinite(atMs) || !isFinite(limit)) return;
37126
37755
  if (atMs >= limit) {
@@ -37151,7 +37780,7 @@ var require_webauthn_mds = __commonJS({
37151
37780
  throw _err("webauthn/metadata-rollback", "the metadata BLOB no " + payload.no + " does not exceed the previously held " + opts.previousNo);
37152
37781
  }
37153
37782
  var staleAfter = _staleAfter(payload.nextUpdate);
37154
- var atMs = at.getTime();
37783
+ var atMs = guard.time.instantOf(at);
37155
37784
  if (!isFinite(atMs) || !isFinite(staleAfter)) {
37156
37785
  throw _err("webauthn/bad-input", "the metadata freshness comparison has no usable instant");
37157
37786
  }
@@ -37323,7 +37952,7 @@ var require_webauthn_mds = __commonJS({
37323
37952
  "webauthn/bad-metadata-blob",
37324
37953
  "a status report effectiveDate"
37325
37954
  );
37326
- return d.getTime() <= atMs;
37955
+ return guard.time.instantOf(d) <= atMs;
37327
37956
  }
37328
37957
  function statusDenied(entry, metadata, leaf, at) {
37329
37958
  var policy = metadata && metadata.statusPolicy || "any";
@@ -37335,7 +37964,7 @@ var require_webauthn_mds = __commonJS({
37335
37964
  var isDated = function(r) {
37336
37965
  return r && typeof r.effectiveDate === "string" && rfc3339.isValidDate(r.effectiveDate);
37337
37966
  };
37338
- var atMs = at instanceof Date && isFinite(at.getTime()) ? at.getTime() : null;
37967
+ var atMs = guard.time.isDate(at) && isFinite(guard.time.instantOf(at)) ? guard.time.instantOf(at) : null;
37339
37968
  if (atMs !== null) {
37340
37969
  reports = reports.filter(function(r) {
37341
37970
  return !isDated(r) || _reportInForceAt(r, atMs);