node-opcua-crypto-web 5.6.0 → 5.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index_web.js CHANGED
@@ -4662,7 +4662,7 @@ var require_util = __commonJS({
4662
4662
  function objectToString(o) {
4663
4663
  return Object.prototype.toString.call(o);
4664
4664
  }
4665
- function pad(n) {
4665
+ function pad2(n) {
4666
4666
  return n < 10 ? "0" + n.toString(10) : n.toString(10);
4667
4667
  }
4668
4668
  var months = [
@@ -4682,9 +4682,9 @@ var require_util = __commonJS({
4682
4682
  function timestamp() {
4683
4683
  var d = /* @__PURE__ */ new Date();
4684
4684
  var time = [
4685
- pad(d.getHours()),
4686
- pad(d.getMinutes()),
4687
- pad(d.getSeconds())
4685
+ pad2(d.getHours()),
4686
+ pad2(d.getMinutes()),
4687
+ pad2(d.getSeconds())
4688
4688
  ].join(":");
4689
4689
  return [d.getDate(), months[d.getMonth()], time].join(" ");
4690
4690
  }
@@ -12460,10 +12460,10 @@ var require_des = __commonJS({
12460
12460
  if (this.padding === false) {
12461
12461
  return buffer;
12462
12462
  }
12463
- var pad = buffer[buffer.length - 1];
12464
- for (var i = buffer.length - pad; i < buffer.length; i++)
12465
- assert8.equal(buffer[i], pad);
12466
- return buffer.slice(0, buffer.length - pad);
12463
+ var pad2 = buffer[buffer.length - 1];
12464
+ for (var i = buffer.length - pad2; i < buffer.length; i++)
12465
+ assert8.equal(buffer[i], pad2);
12466
+ return buffer.slice(0, buffer.length - pad2);
12467
12467
  };
12468
12468
  DES.prototype._encrypt = function _encrypt(state, lStart, rStart, out, off) {
12469
12469
  var l = lStart;
@@ -12715,10 +12715,10 @@ var require_cbc2 = __commonJS({
12715
12715
  return self2._prev;
12716
12716
  };
12717
12717
  exports2.decrypt = function(self2, block) {
12718
- var pad = self2._prev;
12718
+ var pad2 = self2._prev;
12719
12719
  self2._prev = block;
12720
12720
  var out = self2._cipher.decryptBlock(block);
12721
- return xor(out, pad);
12721
+ return xor(out, pad2);
12722
12722
  };
12723
12723
  }
12724
12724
  });
@@ -12764,8 +12764,8 @@ var require_cfb8 = __commonJS({
12764
12764
  init_inject_buffer();
12765
12765
  var Buffer2 = require_buffer().Buffer;
12766
12766
  function encryptByte(self2, byteParam, decrypt) {
12767
- var pad = self2._cipher.encryptBlock(self2._prev);
12768
- var out = pad[0] ^ byteParam;
12767
+ var pad2 = self2._cipher.encryptBlock(self2._prev);
12768
+ var out = pad2[0] ^ byteParam;
12769
12769
  self2._prev = Buffer2.concat([
12770
12770
  self2._prev.slice(1),
12771
12771
  Buffer2.from([decrypt ? byteParam : out])
@@ -12790,15 +12790,15 @@ var require_cfb1 = __commonJS({
12790
12790
  init_inject_buffer();
12791
12791
  var Buffer2 = require_buffer().Buffer;
12792
12792
  function encryptByte(self2, byteParam, decrypt) {
12793
- var pad;
12793
+ var pad2;
12794
12794
  var i = -1;
12795
12795
  var len = 8;
12796
12796
  var out = 0;
12797
12797
  var bit, value;
12798
12798
  while (++i < len) {
12799
- pad = self2._cipher.encryptBlock(self2._prev);
12799
+ pad2 = self2._cipher.encryptBlock(self2._prev);
12800
12800
  bit = byteParam & 1 << 7 - i ? 128 : 0;
12801
- value = pad[0] ^ bit;
12801
+ value = pad2[0] ^ bit;
12802
12802
  out += (value & 128) >> i % 8;
12803
12803
  self2._prev = shiftIn(self2._prev, decrypt ? bit : value);
12804
12804
  }
@@ -12839,9 +12839,9 @@ var require_ofb = __commonJS({
12839
12839
  while (self2._cache.length < chunk.length) {
12840
12840
  self2._cache = import_buffer.Buffer.concat([self2._cache, getBlock2(self2)]);
12841
12841
  }
12842
- var pad = self2._cache.slice(0, chunk.length);
12842
+ var pad2 = self2._cache.slice(0, chunk.length);
12843
12843
  self2._cache = self2._cache.slice(chunk.length);
12844
- return xor(chunk, pad);
12844
+ return xor(chunk, pad2);
12845
12845
  };
12846
12846
  }
12847
12847
  });
@@ -12896,9 +12896,9 @@ var require_ctr = __commonJS({
12896
12896
  self2._cache.writeUInt32BE(out[2], offset + 8);
12897
12897
  self2._cache.writeUInt32BE(out[3], offset + 12);
12898
12898
  }
12899
- var pad = self2._cache.slice(0, chunk.length);
12899
+ var pad2 = self2._cache.slice(0, chunk.length);
12900
12900
  self2._cache = self2._cache.slice(chunk.length);
12901
- return xor(chunk, pad);
12901
+ return xor(chunk, pad2);
12902
12902
  };
12903
12903
  }
12904
12904
  });
@@ -25823,7 +25823,7 @@ var require_utils2 = __commonJS({
25823
25823
  return res;
25824
25824
  }
25825
25825
  utils.toHex = toHex;
25826
- utils.encode = function encode3(arr, enc) {
25826
+ utils.encode = function encode9(arr, enc) {
25827
25827
  if (enc === "hex")
25828
25828
  return toHex(arr);
25829
25829
  else
@@ -26197,7 +26197,7 @@ var require_base = __commonJS({
26197
26197
  return [this.getY().isEven() ? 2 : 3].concat(x);
26198
26198
  return [4].concat(x, this.getY().toArray("be", len));
26199
26199
  };
26200
- BasePoint.prototype.encode = function encode3(enc, compact) {
26200
+ BasePoint.prototype.encode = function encode9(enc, compact) {
26201
26201
  return utils.encode(this._encode(compact), enc);
26202
26202
  };
26203
26203
  BasePoint.prototype.precompute = function precompute(power) {
@@ -27078,7 +27078,7 @@ var require_mont = __commonJS({
27078
27078
  Point.prototype.eq = function eq(other) {
27079
27079
  return this.getX().cmp(other.getX()) === 0;
27080
27080
  };
27081
- Point.prototype.normalize = function normalize2() {
27081
+ Point.prototype.normalize = function normalize5() {
27082
27082
  this.x = this.x.redMul(this.z.redInvm());
27083
27083
  this.z = this.curve.one;
27084
27084
  return this;
@@ -27341,7 +27341,7 @@ var require_edwards = __commonJS({
27341
27341
  Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) {
27342
27342
  return this.curve._wnafMulAdd(1, [this, p], [k1, k2], 2, true);
27343
27343
  };
27344
- Point.prototype.normalize = function normalize2() {
27344
+ Point.prototype.normalize = function normalize5() {
27345
27345
  if (this.zOne)
27346
27346
  return this;
27347
27347
  var zi = this.z.redInvm();
@@ -27694,7 +27694,7 @@ var require_common = __commonJS({
27694
27694
  assert8(this.pending === null);
27695
27695
  return this._digest(enc);
27696
27696
  };
27697
- BlockHash.prototype._pad = function pad() {
27697
+ BlockHash.prototype._pad = function pad2() {
27698
27698
  var len = this.pendingTotal;
27699
27699
  var bytes = this._delta8;
27700
27700
  var k = bytes - (len + this.padLength) % bytes;
@@ -33798,7 +33798,7 @@ var require_api = __commonJS({
33798
33798
  this.decoders[enc] = this._createNamed(asn12.decoders[enc]);
33799
33799
  return this.decoders[enc];
33800
33800
  };
33801
- Entity.prototype.decode = function decode3(data, enc, options) {
33801
+ Entity.prototype.decode = function decode9(data, enc, options) {
33802
33802
  return this._getDecoder(enc).decode(data, options);
33803
33803
  };
33804
33804
  Entity.prototype._getEncoder = function _getEncoder(enc) {
@@ -33807,7 +33807,7 @@ var require_api = __commonJS({
33807
33807
  this.encoders[enc] = this._createNamed(asn12.encoders[enc]);
33808
33808
  return this.encoders[enc];
33809
33809
  };
33810
- Entity.prototype.encode = function encode3(data, enc, reporter) {
33810
+ Entity.prototype.encode = function encode9(data, enc, reporter) {
33811
33811
  return this._getEncoder(enc).encode(data, reporter);
33812
33812
  };
33813
33813
  }
@@ -34139,7 +34139,7 @@ var require_node = __commonJS({
34139
34139
  res._baseState = cstate;
34140
34140
  return res;
34141
34141
  };
34142
- Node.prototype._wrap = function wrap() {
34142
+ Node.prototype._wrap = function wrap2() {
34143
34143
  var state = this._baseState;
34144
34144
  methods.forEach(function(method) {
34145
34145
  this[method] = function _wrappedMethod() {
@@ -34271,7 +34271,7 @@ var require_node = __commonJS({
34271
34271
  state.contains = item;
34272
34272
  return this;
34273
34273
  };
34274
- Node.prototype._decode = function decode3(input, options) {
34274
+ Node.prototype._decode = function decode9(input, options) {
34275
34275
  var state = this._baseState;
34276
34276
  if (state.parent === null)
34277
34277
  return input.wrapResult(state.children[0]._decode(input, options));
@@ -34427,7 +34427,7 @@ var require_node = __commonJS({
34427
34427
  Node.prototype._createEncoderBuffer = function createEncoderBuffer(data) {
34428
34428
  return new EncoderBuffer(data, this.reporter);
34429
34429
  };
34430
- Node.prototype._encode = function encode3(data, reporter, parent) {
34430
+ Node.prototype._encode = function encode9(data, reporter, parent) {
34431
34431
  var state = this._baseState;
34432
34432
  if (state["default"] !== null && state["default"] === data)
34433
34433
  return;
@@ -34438,7 +34438,7 @@ var require_node = __commonJS({
34438
34438
  return;
34439
34439
  return result;
34440
34440
  };
34441
- Node.prototype._encodeValue = function encode3(data, reporter, parent) {
34441
+ Node.prototype._encodeValue = function encode9(data, reporter, parent) {
34442
34442
  var state = this._baseState;
34443
34443
  if (state.parent === null)
34444
34444
  return state.children[0]._encode(data, reporter || new Reporter());
@@ -34646,7 +34646,7 @@ var require_der2 = __commonJS({
34646
34646
  this.tree._init(entity.body);
34647
34647
  }
34648
34648
  module2.exports = DERDecoder;
34649
- DERDecoder.prototype.decode = function decode3(data, options) {
34649
+ DERDecoder.prototype.decode = function decode9(data, options) {
34650
34650
  if (!(data instanceof base.DecoderBuffer))
34651
34651
  data = new base.DecoderBuffer(data, options);
34652
34652
  return this.tree._decode(data, options);
@@ -34906,7 +34906,7 @@ var require_pem = __commonJS({
34906
34906
  }
34907
34907
  inherits(PEMDecoder, DERDecoder);
34908
34908
  module2.exports = PEMDecoder;
34909
- PEMDecoder.prototype.decode = function decode3(data, options) {
34909
+ PEMDecoder.prototype.decode = function decode9(data, options) {
34910
34910
  var lines = data.toString().split(/[\r\n]+/g);
34911
34911
  var label = options.label.toUpperCase();
34912
34912
  var re = /^-----(BEGIN|END) ([^-]+)-----$/;
@@ -34966,7 +34966,7 @@ var require_der3 = __commonJS({
34966
34966
  this.tree._init(entity.body);
34967
34967
  }
34968
34968
  module2.exports = DEREncoder;
34969
- DEREncoder.prototype.encode = function encode3(data, reporter) {
34969
+ DEREncoder.prototype.encode = function encode9(data, reporter) {
34970
34970
  return this.tree._encode(data, reporter).join();
34971
34971
  };
34972
34972
  function DERNode(parent) {
@@ -35193,7 +35193,7 @@ var require_pem2 = __commonJS({
35193
35193
  }
35194
35194
  inherits(PEMEncoder, DEREncoder);
35195
35195
  module2.exports = PEMEncoder;
35196
- PEMEncoder.prototype.encode = function encode3(data, options) {
35196
+ PEMEncoder.prototype.encode = function encode9(data, options) {
35197
35197
  var buf = DEREncoder.prototype.encode.call(this, data);
35198
35198
  var p = buf.toString("base64");
35199
35199
  var out = ["-----BEGIN " + options.label + "-----"];
@@ -35644,16 +35644,16 @@ var require_sign2 = __commonJS({
35644
35644
  }
35645
35645
  hash = Buffer2.concat([tag, hash]);
35646
35646
  var len = priv.modulus.byteLength();
35647
- var pad = [0, 1];
35648
- while (hash.length + pad.length + 1 < len) {
35649
- pad.push(255);
35647
+ var pad2 = [0, 1];
35648
+ while (hash.length + pad2.length + 1 < len) {
35649
+ pad2.push(255);
35650
35650
  }
35651
- pad.push(0);
35651
+ pad2.push(0);
35652
35652
  var i = -1;
35653
35653
  while (++i < hash.length) {
35654
- pad.push(hash[i]);
35654
+ pad2.push(hash[i]);
35655
35655
  }
35656
- var out = crt(pad, priv);
35656
+ var out = crt(pad2, priv);
35657
35657
  return out;
35658
35658
  }
35659
35659
  function ecSign(hash, priv) {
@@ -35793,30 +35793,30 @@ var require_verify = __commonJS({
35793
35793
  }
35794
35794
  hash = Buffer2.concat([tag, hash]);
35795
35795
  var len = pub.modulus.byteLength();
35796
- var pad = [1];
35796
+ var pad2 = [1];
35797
35797
  var padNum = 0;
35798
- while (hash.length + pad.length + 2 < len) {
35799
- pad.push(255);
35798
+ while (hash.length + pad2.length + 2 < len) {
35799
+ pad2.push(255);
35800
35800
  padNum += 1;
35801
35801
  }
35802
- pad.push(0);
35802
+ pad2.push(0);
35803
35803
  var i = -1;
35804
35804
  while (++i < hash.length) {
35805
- pad.push(hash[i]);
35805
+ pad2.push(hash[i]);
35806
35806
  }
35807
- pad = Buffer2.from(pad);
35807
+ pad2 = Buffer2.from(pad2);
35808
35808
  var red = BN.mont(pub.modulus);
35809
35809
  sig = new BN(sig).toRed(red);
35810
35810
  sig = sig.redPow(new BN(pub.publicExponent));
35811
35811
  sig = Buffer2.from(sig.fromRed().toArray());
35812
35812
  var out = padNum < 8 ? 1 : 0;
35813
- len = Math.min(sig.length, pad.length);
35814
- if (sig.length !== pad.length) {
35813
+ len = Math.min(sig.length, pad2.length);
35814
+ if (sig.length !== pad2.length) {
35815
35815
  out = 1;
35816
35816
  }
35817
35817
  i = -1;
35818
35818
  while (++i < len) {
35819
- out |= sig[i] ^ pad[i];
35819
+ out |= sig[i] ^ pad2[i];
35820
35820
  }
35821
35821
  return out === 0;
35822
35822
  }
@@ -38804,9 +38804,9 @@ var require_browser11 = __commonJS({
38804
38804
  this.curve = new elliptic.ec(this.curveType.name);
38805
38805
  this.keys = void 0;
38806
38806
  }
38807
- ECDH.prototype.generateKeys = function(enc, format2) {
38807
+ ECDH.prototype.generateKeys = function(enc, format4) {
38808
38808
  this.keys = this.curve.genKeyPair();
38809
- return this.getPublicKey(enc, format2);
38809
+ return this.getPublicKey(enc, format4);
38810
38810
  };
38811
38811
  ECDH.prototype.computeSecret = function(other, inenc, enc) {
38812
38812
  inenc = inenc || "utf8";
@@ -38817,9 +38817,9 @@ var require_browser11 = __commonJS({
38817
38817
  var out = otherPub.mul(this.keys.getPrivate()).getX();
38818
38818
  return formatReturnValue(out, enc, this.curveType.byteLength);
38819
38819
  };
38820
- ECDH.prototype.getPublicKey = function(enc, format2) {
38821
- var key = this.keys.getPublic(format2 === "compressed", true);
38822
- if (format2 === "hybrid") {
38820
+ ECDH.prototype.getPublicKey = function(enc, format4) {
38821
+ var key = this.keys.getPublic(format4 === "compressed", true);
38822
+ if (format4 === "hybrid") {
38823
38823
  if (key[key.length - 1] % 2) {
38824
38824
  key[0] = 7;
38825
38825
  } else {
@@ -42183,19 +42183,20 @@ function skipChildren(buf, offset, count) {
42183
42183
  }
42184
42184
  return offset;
42185
42185
  }
42186
- function pemToDer(pem) {
42187
- const base642 = pem.replace(/-----[^-]+-----/g, "").replace(/\s+/g, "");
42186
+ function pemToDer(pem2) {
42187
+ const base642 = pem2.replace(/-----[^-]+-----/g, "").replace(/\s+/g, "");
42188
42188
  return import_buffer.Buffer.from(base642, "base64");
42189
42189
  }
42190
42190
  function derToPem(der, label) {
42191
42191
  const base642 = (import_buffer.Buffer.isBuffer(der) ? der : import_buffer.Buffer.from(der)).toString("base64");
42192
- let pem = `-----BEGIN ${label}-----
42192
+ let pem2 = `-----BEGIN ${label}-----
42193
42193
  `;
42194
42194
  for (let i = 0; i < base642.length; i += 64) {
42195
- pem += base642.substring(i, i + 64) + "\n";
42195
+ pem2 += `${base642.substring(i, i + 64)}
42196
+ `;
42196
42197
  }
42197
- pem += `-----END ${label}-----`;
42198
- return pem;
42198
+ pem2 += `-----END ${label}-----`;
42199
+ return pem2;
42199
42200
  }
42200
42201
  function extractSPKIFromCertDER(der) {
42201
42202
  let tlv = readTLV(der, 0);
@@ -42249,9 +42250,9 @@ function modulusLengthFromPrivateKeyDER(der, isPKCS8) {
42249
42250
  return len * 8;
42250
42251
  }
42251
42252
  function createPublicKey(input) {
42252
- const pem = typeof input === "string" ? input : input && input.key ? input.key.toString() : input.toString();
42253
- const isCert = pem.includes("BEGIN CERTIFICATE");
42254
- const der = pemToDer(pem);
42253
+ const pem2 = typeof input === "string" ? input : input?.key ? input.key.toString() : input.toString();
42254
+ const isCert = pem2.includes("BEGIN CERTIFICATE");
42255
+ const der = pemToDer(pem2);
42255
42256
  let spkiDer;
42256
42257
  if (isCert) {
42257
42258
  spkiDer = extractSPKIFromCertDER(der);
@@ -42272,9 +42273,9 @@ function createPublicKey(input) {
42272
42273
  };
42273
42274
  }
42274
42275
  function createPrivateKey(input) {
42275
- const pem = typeof input === "string" ? input : input.toString();
42276
- const der = pemToDer(pem);
42277
- const isPKCS8 = pem.includes("BEGIN PRIVATE KEY");
42276
+ const pem2 = typeof input === "string" ? input : input.toString();
42277
+ const der = pemToDer(pem2);
42278
+ const isPKCS8 = pem2.includes("BEGIN PRIVATE KEY");
42278
42279
  const modulusLength = modulusLengthFromPrivateKeyDER(der, isPKCS8);
42279
42280
  return {
42280
42281
  type: "private",
@@ -42285,10 +42286,10 @@ function createPrivateKey(input) {
42285
42286
  const tp = options?.type || "pkcs8";
42286
42287
  if (fmt === "pem") {
42287
42288
  if (tp === "pkcs1") {
42288
- if (pem.includes("BEGIN RSA PRIVATE KEY")) return pem;
42289
+ if (pem2.includes("BEGIN RSA PRIVATE KEY")) return pem2;
42289
42290
  throw new Error("PKCS8\u2192PKCS1 conversion not supported in browser shim");
42290
42291
  }
42291
- return pem;
42292
+ return pem2;
42292
42293
  }
42293
42294
  return der;
42294
42295
  }
@@ -43266,7 +43267,7 @@ var require_implementation3 = __commonJS({
43266
43267
  var $push = callBound("Array.prototype.push");
43267
43268
  var $propIsEnumerable = callBound("Object.prototype.propertyIsEnumerable");
43268
43269
  var originalGetSymbols = hasSymbols ? $Object.getOwnPropertySymbols : null;
43269
- module2.exports = function assign(target, source1) {
43270
+ module2.exports = function assign2(target, source1) {
43270
43271
  if (target == null) {
43271
43272
  throw new TypeError("target must be an object");
43272
43273
  }
@@ -43358,7 +43359,7 @@ var require_implementation4 = __commonJS({
43358
43359
  var numberIsNaN = function(value) {
43359
43360
  return value !== value;
43360
43361
  };
43361
- module2.exports = function is2(a, b) {
43362
+ module2.exports = function is5(a, b) {
43362
43363
  if (a === 0 && b === 0) {
43363
43364
  return 1 / a === 1 / b;
43364
43365
  }
@@ -45699,7 +45700,7 @@ var require_build = __commonJS({
45699
45700
  "use strict";
45700
45701
  init_inject_buffer();
45701
45702
  var ARRAY_BUFFER_NAME = "[object ArrayBuffer]";
45702
- var BufferSourceConverter3 = class _BufferSourceConverter {
45703
+ var BufferSourceConverter4 = class _BufferSourceConverter {
45703
45704
  static isArrayBuffer(data) {
45704
45705
  return Object.prototype.toString.call(data) === ARRAY_BUFFER_NAME;
45705
45706
  }
@@ -45781,8 +45782,8 @@ var require_build = __commonJS({
45781
45782
  };
45782
45783
  var STRING_TYPE = "string";
45783
45784
  var HEX_REGEX = /^[0-9a-f\s]+$/i;
45784
- var BASE64_REGEX = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
45785
- var BASE64URL_REGEX = /^[a-zA-Z0-9-_]+$/;
45785
+ var BASE64_REGEX2 = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
45786
+ var BASE64URL_REGEX2 = /^[a-zA-Z0-9-_]+$/;
45786
45787
  var Utf8Converter = class {
45787
45788
  static fromString(text) {
45788
45789
  const s = unescape(encodeURIComponent(text));
@@ -45793,7 +45794,7 @@ var require_build = __commonJS({
45793
45794
  return uintArray.buffer;
45794
45795
  }
45795
45796
  static toString(buffer) {
45796
- const buf = BufferSourceConverter3.toUint8Array(buffer);
45797
+ const buf = BufferSourceConverter4.toUint8Array(buffer);
45797
45798
  let encodedString = "";
45798
45799
  for (let i = 0; i < buf.length; i++) {
45799
45800
  encodedString += String.fromCharCode(buf[i]);
@@ -45804,7 +45805,7 @@ var require_build = __commonJS({
45804
45805
  };
45805
45806
  var Utf16Converter = class {
45806
45807
  static toString(buffer, littleEndian = false) {
45807
- const arrayBuffer = BufferSourceConverter3.toArrayBuffer(buffer);
45808
+ const arrayBuffer = BufferSourceConverter4.toArrayBuffer(buffer);
45808
45809
  const dataView = new DataView(arrayBuffer);
45809
45810
  let res = "";
45810
45811
  for (let i = 0; i < arrayBuffer.byteLength; i += 2) {
@@ -45822,18 +45823,18 @@ var require_build = __commonJS({
45822
45823
  return res;
45823
45824
  }
45824
45825
  };
45825
- var Convert3 = class _Convert {
45826
+ var Convert4 = class _Convert {
45826
45827
  static isHex(data) {
45827
45828
  return typeof data === STRING_TYPE && HEX_REGEX.test(data);
45828
45829
  }
45829
45830
  static isBase64(data) {
45830
- return typeof data === STRING_TYPE && BASE64_REGEX.test(data);
45831
+ return typeof data === STRING_TYPE && BASE64_REGEX2.test(data);
45831
45832
  }
45832
45833
  static isBase64Url(data) {
45833
- return typeof data === STRING_TYPE && BASE64URL_REGEX.test(data);
45834
+ return typeof data === STRING_TYPE && BASE64URL_REGEX2.test(data);
45834
45835
  }
45835
45836
  static ToString(buffer, enc = "utf8") {
45836
- const buf = BufferSourceConverter3.toUint8Array(buffer);
45837
+ const buf = BufferSourceConverter4.toUint8Array(buffer);
45837
45838
  switch (enc.toLowerCase()) {
45838
45839
  case "utf8":
45839
45840
  return this.ToUtf8String(buf);
@@ -45879,10 +45880,10 @@ var require_build = __commonJS({
45879
45880
  }
45880
45881
  }
45881
45882
  static ToBase64(buffer) {
45882
- const buf = BufferSourceConverter3.toUint8Array(buffer);
45883
+ const buf = BufferSourceConverter4.toUint8Array(buffer);
45883
45884
  if (typeof btoa !== "undefined") {
45884
- const binary = this.ToString(buf, "binary");
45885
- return btoa(binary);
45885
+ const binary2 = this.ToString(buf, "binary");
45886
+ return btoa(binary2);
45886
45887
  } else {
45887
45888
  return import_buffer.Buffer.from(buf).toString("base64");
45888
45889
  }
@@ -45901,8 +45902,8 @@ var require_build = __commonJS({
45901
45902
  return new Uint8Array(import_buffer.Buffer.from(formatted, "base64")).buffer;
45902
45903
  }
45903
45904
  }
45904
- static FromBase64Url(base64url) {
45905
- const formatted = this.formatString(base64url);
45905
+ static FromBase64Url(base64url2) {
45906
+ const formatted = this.formatString(base64url2);
45906
45907
  if (!formatted) {
45907
45908
  return new ArrayBuffer(0);
45908
45909
  }
@@ -45955,7 +45956,7 @@ var require_build = __commonJS({
45955
45956
  return resultView.buffer;
45956
45957
  }
45957
45958
  static ToBinary(buffer) {
45958
- const buf = BufferSourceConverter3.toUint8Array(buffer);
45959
+ const buf = BufferSourceConverter4.toUint8Array(buffer);
45959
45960
  let res = "";
45960
45961
  for (let i = 0; i < buf.length; i++) {
45961
45962
  res += String.fromCharCode(buf[i]);
@@ -45963,7 +45964,7 @@ var require_build = __commonJS({
45963
45964
  return res;
45964
45965
  }
45965
45966
  static ToHex(buffer) {
45966
- const buf = BufferSourceConverter3.toUint8Array(buffer);
45967
+ const buf = BufferSourceConverter4.toUint8Array(buffer);
45967
45968
  let result = "";
45968
45969
  const len = buf.length;
45969
45970
  for (let i = 0; i < len; i++) {
@@ -46012,8 +46013,8 @@ var require_build = __commonJS({
46012
46013
  return (data === null || data === void 0 ? void 0 : data.replace(/[\n\r\t ]/g, "")) || "";
46013
46014
  }
46014
46015
  };
46015
- Convert3.DEFAULT_UTF8_ENCODING = "utf8";
46016
- function assign(target, ...sources) {
46016
+ Convert4.DEFAULT_UTF8_ENCODING = "utf8";
46017
+ function assign2(target, ...sources) {
46017
46018
  const res = arguments[0];
46018
46019
  for (let i = 1; i < arguments.length; i++) {
46019
46020
  const obj = arguments[i];
@@ -46023,7 +46024,7 @@ var require_build = __commonJS({
46023
46024
  }
46024
46025
  return res;
46025
46026
  }
46026
- function combine2(...buf) {
46027
+ function combine3(...buf) {
46027
46028
  const totalByteLength = buf.map((item) => item.byteLength).reduce((prev, cur) => prev + cur);
46028
46029
  const res = new Uint8Array(totalByteLength);
46029
46030
  let currentPos = 0;
@@ -46034,7 +46035,7 @@ var require_build = __commonJS({
46034
46035
  });
46035
46036
  return res.buffer;
46036
46037
  }
46037
- function isEqual2(bytes1, bytes2) {
46038
+ function isEqual3(bytes1, bytes2) {
46038
46039
  if (!(bytes1 && bytes2)) {
46039
46040
  return false;
46040
46041
  }
@@ -46050,11 +46051,11 @@ var require_build = __commonJS({
46050
46051
  }
46051
46052
  return true;
46052
46053
  }
46053
- exports2.BufferSourceConverter = BufferSourceConverter3;
46054
- exports2.Convert = Convert3;
46055
- exports2.assign = assign;
46056
- exports2.combine = combine2;
46057
- exports2.isEqual = isEqual2;
46054
+ exports2.BufferSourceConverter = BufferSourceConverter4;
46055
+ exports2.Convert = Convert4;
46056
+ exports2.assign = assign2;
46057
+ exports2.combine = combine3;
46058
+ exports2.isEqual = isEqual3;
46058
46059
  }
46059
46060
  });
46060
46061
 
@@ -46902,15 +46903,15 @@ var createFastUninitializedBuffer = import_buffer.Buffer.allocUnsafe ? import_bu
46902
46903
 
46903
46904
  // ../node-opcua-crypto/source/hexy.ts
46904
46905
  init_inject_buffer();
46905
- function hexy(buffer, { width, format: format2 } = {}) {
46906
+ function hexy(buffer, { width, format: format4 } = {}) {
46906
46907
  width = width || 80;
46907
- if (format2 === "twos") {
46908
+ if (format4 === "twos") {
46908
46909
  width = 26 * 3;
46909
46910
  }
46910
46911
  const regex = new RegExp(`.{1,${width}}`, "g");
46911
46912
  const regexTwos = new RegExp(`.{1,${2}}`, "g");
46912
46913
  let fullHex = buffer.toString("hex");
46913
- if (format2 === "twos") {
46914
+ if (format4 === "twos") {
46914
46915
  fullHex = fullHex.match(regexTwos)?.join(" ") || "";
46915
46916
  }
46916
46917
  return fullHex.match(regex)?.join("\n") || "";
@@ -46933,24 +46934,24 @@ function removeTrailingLF(str) {
46933
46934
  const tmp = str.replace(/(\r|\n)+$/m, "").replace(/\r\n/gm, "\n");
46934
46935
  return tmp;
46935
46936
  }
46936
- function toPem(raw_key, pem) {
46937
+ function toPem(raw_key, pem2) {
46937
46938
  (0, import_node_assert2.default)(raw_key, "expecting a key");
46938
- (0, import_node_assert2.default)(typeof pem === "string");
46939
+ (0, import_node_assert2.default)(typeof pem2 === "string");
46939
46940
  if (Array.isArray(raw_key)) {
46940
- return raw_key.map((cert) => toPem(cert, pem)).join("\n");
46941
+ return raw_key.map((cert) => toPem(cert, pem2)).join("\n");
46941
46942
  }
46942
46943
  let pemType = identifyPemType(raw_key);
46943
46944
  if (pemType) {
46944
46945
  return import_buffer.Buffer.isBuffer(raw_key) ? removeTrailingLF(raw_key.toString("utf8")) : removeTrailingLF(raw_key);
46945
46946
  } else {
46946
- pemType = pem;
46947
+ pemType = pem2;
46947
46948
  (0, import_node_assert2.default)(["CERTIFICATE REQUEST", "CERTIFICATE", "RSA PRIVATE KEY", "PUBLIC KEY", "X509 CRL"].indexOf(pemType) >= 0);
46948
46949
  const buffer = raw_key;
46949
46950
  if (pemType === "CERTIFICATE" && buffer.length > 0) {
46950
46951
  try {
46951
46952
  const parts = split_der(buffer);
46952
46953
  if (parts.length > 1) {
46953
- return parts.map((cert) => toPem(cert, pem)).join("\n");
46954
+ return parts.map((cert) => toPem(cert, pem2)).join("\n");
46954
46955
  }
46955
46956
  } catch (_err) {
46956
46957
  }
@@ -47680,7 +47681,7 @@ async function verifyCertificateChain(certificateChain) {
47680
47681
  const certParent = certificateChain[index];
47681
47682
  const certParentInfo = exploreCertificate(certParent);
47682
47683
  const keyUsage = certParentInfo.tbsCertificate.extensions?.keyUsage;
47683
- if (!keyUsage || !keyUsage.keyCertSign) {
47684
+ if (!keyUsage?.keyCertSign) {
47684
47685
  return {
47685
47686
  status: "BadCertificateIssuerUseNotAllowed",
47686
47687
  reason: "One of the certificate in the chain has not keyUsage set for Certificate Signing"
@@ -48081,9 +48082,6 @@ var Subject = class _Subject {
48081
48082
  }
48082
48083
  };
48083
48084
 
48084
- // ../node-opcua-crypto/source/x509/coerce_private_key.ts
48085
- init_inject_buffer();
48086
-
48087
48085
  // ../node-opcua-crypto/source/x509/_crypto.ts
48088
48086
  init_inject_buffer();
48089
48087
  init_node_crypto_shim();
@@ -51407,6 +51405,9 @@ function verifySchema(inputBuffer, inputSchema) {
51407
51405
  return compareSchema(asn12.result, asn12.result, inputSchema);
51408
51406
  }
51409
51407
 
51408
+ // ../../node_modules/@peculiar/utils/build/esm/index.js
51409
+ init_inject_buffer();
51410
+
51410
51411
  // ../../node_modules/@peculiar/utils/build/esm/bytes/index.js
51411
51412
  init_inject_buffer();
51412
51413
 
@@ -51486,6 +51487,848 @@ function equal(a, b, options = {}) {
51486
51487
  // ../../node_modules/@peculiar/utils/build/esm/bytes/sequence.js
51487
51488
  init_inject_buffer();
51488
51489
 
51490
+ // ../../node_modules/@peculiar/utils/build/esm/encoding/index.js
51491
+ init_inject_buffer();
51492
+
51493
+ // ../../node_modules/@peculiar/utils/build/esm/encoding/binary.js
51494
+ var binary_exports = {};
51495
+ __export(binary_exports, {
51496
+ binary: () => binary,
51497
+ decode: () => decode,
51498
+ encode: () => encode,
51499
+ is: () => is
51500
+ });
51501
+ init_inject_buffer();
51502
+ function encode(data) {
51503
+ const bytes = toUint8Array(data);
51504
+ let result = "";
51505
+ for (const byte of bytes) {
51506
+ result += String.fromCharCode(byte);
51507
+ }
51508
+ return result;
51509
+ }
51510
+ function decode(text) {
51511
+ const result = new Uint8Array(text.length);
51512
+ for (let i = 0; i < text.length; i++) {
51513
+ result[i] = text.charCodeAt(i) & 255;
51514
+ }
51515
+ return result;
51516
+ }
51517
+ function is(text) {
51518
+ return typeof text === "string";
51519
+ }
51520
+ var binary = { encode, decode, is };
51521
+
51522
+ // ../../node_modules/@peculiar/utils/build/esm/encoding/hex.js
51523
+ var hex_exports = {};
51524
+ __export(hex_exports, {
51525
+ decode: () => decode2,
51526
+ encode: () => encode2,
51527
+ format: () => format,
51528
+ formats: () => formats,
51529
+ hex: () => hex,
51530
+ is: () => is2,
51531
+ normalize: () => normalize,
51532
+ parse: () => parse
51533
+ });
51534
+ init_inject_buffer();
51535
+ var HEX_CHARACTER_REGEX = /^[0-9a-f]$/i;
51536
+ var COMMON_SEPARATORS = [" ", " ", "\n", "\r", ":", "-", "."];
51537
+ function resolveSeparators(options) {
51538
+ if (options.separators === "none") {
51539
+ return [];
51540
+ }
51541
+ if (!options.separators || options.separators === "common") {
51542
+ return COMMON_SEPARATORS;
51543
+ }
51544
+ return options.separators;
51545
+ }
51546
+ function validateSeparator(separator) {
51547
+ if (!separator) {
51548
+ throw new TypeError("Hex separators must be non-empty strings");
51549
+ }
51550
+ }
51551
+ function matchSeparator(text, index, separators) {
51552
+ for (const separator of separators) {
51553
+ if (text.startsWith(separator, index)) {
51554
+ return separator;
51555
+ }
51556
+ }
51557
+ return void 0;
51558
+ }
51559
+ function detectCase(text) {
51560
+ const hasUpper = /[A-F]/.test(text);
51561
+ const hasLower = /[a-f]/.test(text);
51562
+ return hasUpper && !hasLower ? "upper" : "lower";
51563
+ }
51564
+ function detectLineSeparator(text) {
51565
+ const match = /\r\n|\n/.exec(text);
51566
+ if (!match) {
51567
+ return void 0;
51568
+ }
51569
+ return match[0] === "\r\n" ? "\r\n" : "\n";
51570
+ }
51571
+ function compactForDetection(text) {
51572
+ return text.replace(/[^0-9a-f]/gi, "");
51573
+ }
51574
+ function detectGroup(text) {
51575
+ const segments = text.match(/[0-9A-Fa-f]+|[^0-9A-Fa-f]+/g) ?? [];
51576
+ if (segments.length < 3) {
51577
+ return void 0;
51578
+ }
51579
+ const hexSegments = segments.filter((_, index) => index % 2 === 0);
51580
+ const separators = segments.filter((_, index) => index % 2 === 1);
51581
+ const separator = separators[0];
51582
+ if (!separator || separators.some((item) => item !== separator)) {
51583
+ return void 0;
51584
+ }
51585
+ if (hexSegments.some((segment) => segment.length === 0 || segment.length % 2 !== 0)) {
51586
+ return void 0;
51587
+ }
51588
+ const firstLength = hexSegments[0]?.length ?? 0;
51589
+ if (!firstLength) {
51590
+ return void 0;
51591
+ }
51592
+ if (hexSegments.slice(0, -1).some((segment) => segment.length !== firstLength)) {
51593
+ return void 0;
51594
+ }
51595
+ if ((hexSegments[hexSegments.length - 1]?.length ?? 0) > firstLength) {
51596
+ return void 0;
51597
+ }
51598
+ return {
51599
+ size: firstLength / 2,
51600
+ separator
51601
+ };
51602
+ }
51603
+ function detectFormat(text) {
51604
+ const trimmed = text.trim();
51605
+ const prefix = /^0x/i.test(trimmed) ? "0x" : "";
51606
+ const body = prefix ? trimmed.slice(2) : trimmed;
51607
+ const lineSeparator = detectLineSeparator(body);
51608
+ const lines = body.split(/\r\n|\n/).filter((line) => line.length > 0);
51609
+ const sampleLine = lines[0]?.trim() ?? "";
51610
+ const group = detectGroup(sampleLine);
51611
+ const format4 = {
51612
+ case: detectCase(trimmed),
51613
+ prefix
51614
+ };
51615
+ if (group) {
51616
+ format4.group = group;
51617
+ }
51618
+ if (lineSeparator && lines.length > 1) {
51619
+ const firstLineBytes = compactForDetection(lines[0] ?? "").length / 2;
51620
+ if (firstLineBytes > 0 && lines.slice(0, -1).every((line) => compactForDetection(line).length / 2 === firstLineBytes)) {
51621
+ format4.line = {
51622
+ bytesPerLine: firstLineBytes,
51623
+ separator: lineSeparator
51624
+ };
51625
+ }
51626
+ }
51627
+ return format4;
51628
+ }
51629
+ function normalizeText(text, options) {
51630
+ const allowPrefix = options.allowPrefix ?? true;
51631
+ const separators = [...resolveSeparators(options)].sort((left, right) => right.length - left.length);
51632
+ for (const separator of separators) {
51633
+ validateSeparator(separator);
51634
+ }
51635
+ let working = text.trim();
51636
+ if (/^0x/i.test(working)) {
51637
+ if (!allowPrefix) {
51638
+ throw new TypeError("Hexadecimal text must not include a 0x prefix");
51639
+ }
51640
+ working = working.slice(2);
51641
+ }
51642
+ let normalized = "";
51643
+ let lastTokenWasSeparator = false;
51644
+ for (let index = 0; index < working.length; ) {
51645
+ const character = working[index] ?? "";
51646
+ if (HEX_CHARACTER_REGEX.test(character)) {
51647
+ normalized += character;
51648
+ lastTokenWasSeparator = false;
51649
+ index += 1;
51650
+ continue;
51651
+ }
51652
+ const separator = matchSeparator(working, index, separators);
51653
+ if (!separator) {
51654
+ throw new TypeError("Input is not valid hexadecimal text");
51655
+ }
51656
+ if (options.strict && (lastTokenWasSeparator || normalized.length === 0)) {
51657
+ throw new TypeError("Hexadecimal text contains misplaced separators");
51658
+ }
51659
+ lastTokenWasSeparator = true;
51660
+ index += separator.length;
51661
+ }
51662
+ if (options.strict && lastTokenWasSeparator && normalized.length > 0) {
51663
+ throw new TypeError("Hexadecimal text must not end with a separator");
51664
+ }
51665
+ if (normalized.length % 2 !== 0) {
51666
+ if (!options.allowOddLength) {
51667
+ throw new TypeError("Hexadecimal text must contain an even number of characters");
51668
+ }
51669
+ normalized = `0${normalized}`;
51670
+ }
51671
+ return normalized.toLowerCase();
51672
+ }
51673
+ function groupPairs(pairs, group) {
51674
+ if (!group) {
51675
+ return pairs.join("");
51676
+ }
51677
+ if (!Number.isInteger(group.size) || group.size < 1) {
51678
+ throw new RangeError("Hex group size must be a positive integer");
51679
+ }
51680
+ const chunks = [];
51681
+ for (let index = 0; index < pairs.length; index += group.size) {
51682
+ chunks.push(pairs.slice(index, index + group.size).join(""));
51683
+ }
51684
+ return chunks.join(group.separator);
51685
+ }
51686
+ function normalize(text, options = {}) {
51687
+ return normalizeText(text, options);
51688
+ }
51689
+ function is2(text, options = {}) {
51690
+ if (typeof text !== "string") {
51691
+ return false;
51692
+ }
51693
+ try {
51694
+ normalize(text, options);
51695
+ return true;
51696
+ } catch {
51697
+ return false;
51698
+ }
51699
+ }
51700
+ function encode2(data, options = {}) {
51701
+ const bytes = toUint8Array(data);
51702
+ const casing = options.case ?? "lower";
51703
+ const pairs = Array.from(bytes, (byte) => {
51704
+ const text = byte.toString(16).padStart(2, "0");
51705
+ return casing === "upper" ? text.toUpperCase() : text;
51706
+ });
51707
+ let body = "";
51708
+ if (options.line) {
51709
+ const bytesPerLine = options.line.bytesPerLine;
51710
+ if (!Number.isInteger(bytesPerLine) || bytesPerLine < 1) {
51711
+ throw new RangeError("Hex bytesPerLine must be a positive integer");
51712
+ }
51713
+ const separator = options.line.separator ?? "\n";
51714
+ const lines = [];
51715
+ for (let index = 0; index < pairs.length; index += bytesPerLine) {
51716
+ lines.push(groupPairs(pairs.slice(index, index + bytesPerLine), options.group));
51717
+ }
51718
+ body = lines.join(separator);
51719
+ } else {
51720
+ body = groupPairs(pairs, options.group);
51721
+ }
51722
+ return `${options.prefix ?? ""}${body}`;
51723
+ }
51724
+ function decode2(text, options = {}) {
51725
+ const normalized = normalize(text, options);
51726
+ const result = new Uint8Array(normalized.length / 2);
51727
+ for (let i = 0; i < normalized.length; i += 2) {
51728
+ result[i / 2] = Number.parseInt(normalized.slice(i, i + 2), 16);
51729
+ }
51730
+ return result;
51731
+ }
51732
+ function parse(text, options = {}) {
51733
+ const normalized = normalize(text, options);
51734
+ return {
51735
+ bytes: decode2(normalized),
51736
+ format: detectFormat(text),
51737
+ normalized
51738
+ };
51739
+ }
51740
+ function format(data, value) {
51741
+ return encode2(data, value);
51742
+ }
51743
+ var formats = {
51744
+ compact: Object.freeze({}),
51745
+ upper: Object.freeze({ case: "upper" }),
51746
+ colon: Object.freeze({ group: { size: 1, separator: ":" } }),
51747
+ colonUpper: Object.freeze({ case: "upper", group: { size: 1, separator: ":" } }),
51748
+ groupsOf4: Object.freeze({ group: { size: 4, separator: " " } }),
51749
+ prefixed: Object.freeze({ prefix: "0x" })
51750
+ };
51751
+ var hex = { encode: encode2, decode: decode2, format, formats, is: is2, normalize, parse };
51752
+
51753
+ // ../../node_modules/@peculiar/utils/build/esm/encoding/utf8.js
51754
+ var utf8_exports = {};
51755
+ __export(utf8_exports, {
51756
+ decode: () => decode3,
51757
+ encode: () => encode3,
51758
+ utf8: () => utf8
51759
+ });
51760
+ init_inject_buffer();
51761
+ function encode3(text) {
51762
+ return new TextEncoder().encode(text);
51763
+ }
51764
+ function decode3(data) {
51765
+ return new TextDecoder("utf-8", { fatal: false }).decode(toUint8Array(data));
51766
+ }
51767
+ var utf8 = { encode: encode3, decode: decode3 };
51768
+
51769
+ // ../../node_modules/@peculiar/utils/build/esm/encoding/utf16.js
51770
+ var utf16_exports = {};
51771
+ __export(utf16_exports, {
51772
+ decode: () => decode4,
51773
+ encode: () => encode4,
51774
+ utf16: () => utf16
51775
+ });
51776
+ init_inject_buffer();
51777
+ function encode4(text, options = {}) {
51778
+ const result = new ArrayBuffer(text.length * 2);
51779
+ const view = new DataView(result);
51780
+ for (let i = 0; i < text.length; i++) {
51781
+ view.setUint16(i * 2, text.charCodeAt(i), options.littleEndian ?? false);
51782
+ }
51783
+ return new Uint8Array(result);
51784
+ }
51785
+ function decode4(data, options = {}) {
51786
+ const buffer = toArrayBuffer(data);
51787
+ const view = new DataView(buffer);
51788
+ let result = "";
51789
+ for (let i = 0; i < buffer.byteLength; i += 2) {
51790
+ result += String.fromCharCode(view.getUint16(i, options.littleEndian ?? false));
51791
+ }
51792
+ return result;
51793
+ }
51794
+ var utf16 = { encode: encode4, decode: decode4 };
51795
+
51796
+ // ../../node_modules/@peculiar/utils/build/esm/encoding/base64.js
51797
+ var base64_exports = {};
51798
+ __export(base64_exports, {
51799
+ base64: () => base64,
51800
+ decode: () => decode5,
51801
+ encode: () => encode5,
51802
+ is: () => is3,
51803
+ normalize: () => normalize2,
51804
+ pad: () => pad
51805
+ });
51806
+ init_inject_buffer();
51807
+ var BASE64_REGEX = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
51808
+ function nodeBuffer() {
51809
+ return globalThis.Buffer;
51810
+ }
51811
+ function normalize2(text) {
51812
+ return text.replace(/[\n\r\t ]/g, "");
51813
+ }
51814
+ function pad(text) {
51815
+ const remainder = text.length % 4;
51816
+ return remainder ? text + "=".repeat(4 - remainder) : text;
51817
+ }
51818
+ function is3(text) {
51819
+ if (typeof text !== "string") {
51820
+ return false;
51821
+ }
51822
+ const normalized = normalize2(text);
51823
+ return normalized === "" || BASE64_REGEX.test(normalized);
51824
+ }
51825
+ function encode5(data, _options) {
51826
+ const bytes = toUint8Array(data);
51827
+ const buffer = nodeBuffer();
51828
+ if (buffer) {
51829
+ return buffer.from(bytes).toString("base64");
51830
+ }
51831
+ return btoa(encode(bytes));
51832
+ }
51833
+ function decode5(text, _options) {
51834
+ const normalized = normalize2(text);
51835
+ if (!is3(normalized)) {
51836
+ throw new TypeError("Input is not valid Base64 text");
51837
+ }
51838
+ const buffer = nodeBuffer();
51839
+ if (buffer) {
51840
+ return new Uint8Array(buffer.from(normalized, "base64"));
51841
+ }
51842
+ return decode(atob(normalized));
51843
+ }
51844
+ var base64 = { encode: encode5, decode: decode5, is: is3, normalize: normalize2, pad };
51845
+
51846
+ // ../../node_modules/@peculiar/utils/build/esm/encoding/base64url.js
51847
+ var base64url_exports = {};
51848
+ __export(base64url_exports, {
51849
+ base64url: () => base64url,
51850
+ decode: () => decode6,
51851
+ encode: () => encode6,
51852
+ is: () => is4,
51853
+ normalize: () => normalize3
51854
+ });
51855
+ init_inject_buffer();
51856
+ var BASE64URL_REGEX = /^[A-Za-z0-9_-]*$/;
51857
+ function normalize3(text) {
51858
+ return text.replace(/[\n\r\t ]/g, "");
51859
+ }
51860
+ function is4(text) {
51861
+ return typeof text === "string" && BASE64URL_REGEX.test(normalize3(text));
51862
+ }
51863
+ function encode6(data, _options) {
51864
+ return base64.encode(data).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
51865
+ }
51866
+ function decode6(text, _options) {
51867
+ const normalized = normalize3(text);
51868
+ if (!is4(normalized)) {
51869
+ throw new TypeError("Input is not valid Base64Url text");
51870
+ }
51871
+ return base64.decode(base64.pad(normalized.replace(/-/g, "+").replace(/_/g, "/")));
51872
+ }
51873
+ var base64url = { encode: encode6, decode: decode6, is: is4, normalize: normalize3 };
51874
+
51875
+ // ../../node_modules/@peculiar/utils/build/esm/pem/index.js
51876
+ init_inject_buffer();
51877
+
51878
+ // ../../node_modules/@peculiar/utils/build/esm/pem/pem.js
51879
+ init_inject_buffer();
51880
+ var LABEL_REGEX = /^[A-Z0-9][A-Z0-9 ._-]*[A-Z0-9]$/i;
51881
+ var PEM_BLOCK_REGEX = /-----BEGIN ([^-]+)-----([\s\S]*?)-----END \1-----/g;
51882
+ function assertLabel(label) {
51883
+ if (!LABEL_REGEX.test(label)) {
51884
+ throw new TypeError(`Invalid PEM label '${label}'`);
51885
+ }
51886
+ }
51887
+ function wrap(text, lineLength) {
51888
+ const result = [];
51889
+ for (let i = 0; i < text.length; i += lineLength) {
51890
+ result.push(text.slice(i, i + lineLength));
51891
+ }
51892
+ return result;
51893
+ }
51894
+ function parseBody(body) {
51895
+ const normalized = body.trim().replace(/\r\n/g, "\n");
51896
+ const lines = normalized.split("\n").map((line) => line.trim()).filter(Boolean);
51897
+ const headers = {};
51898
+ let index = 0;
51899
+ for (; index < lines.length; index++) {
51900
+ const line = lines[index];
51901
+ const separator = line.indexOf(":");
51902
+ if (separator <= 0) {
51903
+ break;
51904
+ }
51905
+ headers[line.slice(0, separator).trim()] = line.slice(separator + 1).trim();
51906
+ }
51907
+ return {
51908
+ headers: Object.keys(headers).length ? headers : void 0,
51909
+ base64Lines: lines.slice(index),
51910
+ base64Text: lines.slice(index).join("")
51911
+ };
51912
+ }
51913
+ function detectNewline(text) {
51914
+ return /\r\n/.test(text) ? "\r\n" : "\n";
51915
+ }
51916
+ function collectBlocks(text, options = {}) {
51917
+ const blocks = [];
51918
+ const requestedLabel = options.label;
51919
+ let match;
51920
+ PEM_BLOCK_REGEX.lastIndex = 0;
51921
+ while (match = PEM_BLOCK_REGEX.exec(text)) {
51922
+ const label = match[1].trim();
51923
+ if (requestedLabel && label !== requestedLabel) {
51924
+ continue;
51925
+ }
51926
+ assertLabel(label);
51927
+ const parsed = parseBody(match[2]);
51928
+ blocks.push({
51929
+ label,
51930
+ data: base64.decode(parsed.base64Text),
51931
+ headers: parsed.headers,
51932
+ lineLength: parsed.base64Lines[0]?.length ?? 64,
51933
+ newline: detectNewline(match[0])
51934
+ });
51935
+ }
51936
+ if (options.strict && blocks.length === 0) {
51937
+ throw new TypeError(requestedLabel ? `No PEM block with label '${requestedLabel}' was found` : "No PEM blocks were found");
51938
+ }
51939
+ return blocks;
51940
+ }
51941
+ function encode7(label, data, options = {}) {
51942
+ assertLabel(label);
51943
+ const lineLength = options.lineLength ?? 64;
51944
+ if (!Number.isInteger(lineLength) || lineLength < 1) {
51945
+ throw new RangeError("PEM lineLength must be a positive integer");
51946
+ }
51947
+ const newline = options.newline ?? "\n";
51948
+ const lines = [`-----BEGIN ${label}-----`];
51949
+ if (options.headers) {
51950
+ for (const [name, value] of Object.entries(options.headers)) {
51951
+ lines.push(`${name}: ${value}`);
51952
+ }
51953
+ lines.push("");
51954
+ }
51955
+ lines.push(...wrap(base64.encode(data), lineLength));
51956
+ lines.push(`-----END ${label}-----`);
51957
+ return `${lines.join(newline)}${newline}`;
51958
+ }
51959
+ function decode7(text, options = {}) {
51960
+ return collectBlocks(text, options).map(({ lineLength: _lineLength, newline: _newline, ...block }) => block);
51961
+ }
51962
+ function decodeFirst(text, label) {
51963
+ const [block] = decode7(text, { label, strict: true });
51964
+ return block.data;
51965
+ }
51966
+ function parse2(text, options = {}) {
51967
+ const [block] = collectBlocks(text, { ...options, strict: true });
51968
+ const format4 = {
51969
+ label: block.label,
51970
+ headers: block.headers,
51971
+ lineLength: block.lineLength,
51972
+ newline: block.newline
51973
+ };
51974
+ return {
51975
+ bytes: block.data,
51976
+ format: format4,
51977
+ normalized: encode7(block.label, block.data, format4)
51978
+ };
51979
+ }
51980
+ function format2(data, value) {
51981
+ return encode7(value.label, data, value);
51982
+ }
51983
+ var pemConverter = {
51984
+ name: "pem",
51985
+ encode: (data, options) => {
51986
+ if (!options?.label) {
51987
+ throw new TypeError("PEM label is required");
51988
+ }
51989
+ return encode7(options.label, data, options);
51990
+ },
51991
+ decode: (text, options) => decodeFirst(text, options?.label),
51992
+ format: format2,
51993
+ is: (text) => typeof text === "string" && /-----BEGIN [^-]+-----/.test(text),
51994
+ parse: parse2
51995
+ };
51996
+
51997
+ // ../../node_modules/@peculiar/utils/build/esm/converters/index.js
51998
+ init_inject_buffer();
51999
+
52000
+ // ../../node_modules/@peculiar/utils/build/esm/converters/registry.js
52001
+ init_inject_buffer();
52002
+ function keyOf(name) {
52003
+ return name.trim().toLowerCase();
52004
+ }
52005
+ function toError(error) {
52006
+ return error instanceof Error ? error : new Error(String(error));
52007
+ }
52008
+ function removeConverter(converters, primaryNames, converter) {
52009
+ for (const alias of [converter.name, ...converter.aliases ?? []]) {
52010
+ converters.delete(keyOf(alias));
52011
+ }
52012
+ primaryNames.delete(keyOf(converter.name));
52013
+ }
52014
+ function requireCapability(converter, name, capability) {
52015
+ const method = converter[capability];
52016
+ if (typeof method !== "function") {
52017
+ throw new Error(`Converter '${name}' does not support ${capability}()`);
52018
+ }
52019
+ return method;
52020
+ }
52021
+ function detectConfidence(name, text, converter) {
52022
+ const normalizedName = keyOf(converter.name || name);
52023
+ const trimmed = text.trim();
52024
+ if (!trimmed) {
52025
+ return 0;
52026
+ }
52027
+ let accepted = false;
52028
+ if (converter.is) {
52029
+ accepted = converter.is(text);
52030
+ }
52031
+ let decodable = false;
52032
+ try {
52033
+ converter.decode(text);
52034
+ decodable = true;
52035
+ } catch {
52036
+ decodable = false;
52037
+ }
52038
+ if (!accepted && !decodable) {
52039
+ return 0;
52040
+ }
52041
+ switch (normalizedName) {
52042
+ case "pem":
52043
+ return /-----BEGIN [^-]+-----/.test(text) ? 1 : 0;
52044
+ case "hex": {
52045
+ const compact = trimmed.replace(/^0x/i, "").replace(/[\s:.-]/g, "");
52046
+ if (!compact || /[^0-9a-f]/i.test(compact) || compact.length % 2 !== 0) {
52047
+ return 0;
52048
+ }
52049
+ if (/^0x/i.test(trimmed) || /[:\s.-]/.test(trimmed)) {
52050
+ return 0.95;
52051
+ }
52052
+ if (/[a-f]/.test(trimmed) || /[A-F]/.test(trimmed)) {
52053
+ return 0.8;
52054
+ }
52055
+ return 0.45;
52056
+ }
52057
+ case "base64url":
52058
+ if (/[-_]/.test(trimmed)) {
52059
+ return 0.95;
52060
+ }
52061
+ if (/=/.test(trimmed)) {
52062
+ return 0.1;
52063
+ }
52064
+ return 0.6;
52065
+ case "base64":
52066
+ if (/[+/=]/.test(trimmed)) {
52067
+ return 0.9;
52068
+ }
52069
+ return 0.55;
52070
+ case "binary":
52071
+ case "utf8":
52072
+ case "utf16be":
52073
+ case "utf16le":
52074
+ return 0;
52075
+ default:
52076
+ return accepted && decodable ? 0.75 : 0.5;
52077
+ }
52078
+ }
52079
+ function createConverterRegistry(initialConverters = []) {
52080
+ const converters = /* @__PURE__ */ new Map();
52081
+ const primaryNames = /* @__PURE__ */ new Set();
52082
+ const api = {
52083
+ register(converter, options = {}) {
52084
+ if (!converter.name || !keyOf(converter.name)) {
52085
+ throw new TypeError("Converter name is required");
52086
+ }
52087
+ const names2 = [...new Set([converter.name, ...converter.aliases ?? []].map(keyOf))];
52088
+ const conflicts = /* @__PURE__ */ new Set();
52089
+ for (const name of names2) {
52090
+ const existing = converters.get(name);
52091
+ if (!existing) {
52092
+ continue;
52093
+ }
52094
+ if (!options.override) {
52095
+ throw new Error(`Converter '${name}' is already registered`);
52096
+ }
52097
+ conflicts.add(existing);
52098
+ }
52099
+ for (const conflicting of conflicts) {
52100
+ removeConverter(converters, primaryNames, conflicting);
52101
+ }
52102
+ for (const name of names2) {
52103
+ converters.set(name, converter);
52104
+ }
52105
+ primaryNames.add(keyOf(converter.name));
52106
+ return this;
52107
+ },
52108
+ unregister(name) {
52109
+ const converter = converters.get(keyOf(name));
52110
+ if (!converter) {
52111
+ return false;
52112
+ }
52113
+ removeConverter(converters, primaryNames, converter);
52114
+ return true;
52115
+ },
52116
+ has(name) {
52117
+ return converters.has(keyOf(name));
52118
+ },
52119
+ get(name) {
52120
+ const converter = converters.get(keyOf(name));
52121
+ if (!converter) {
52122
+ throw new Error(`Converter '${name}' is not registered`);
52123
+ }
52124
+ return converter;
52125
+ },
52126
+ list() {
52127
+ return [...primaryNames].map((name) => this.get(name));
52128
+ },
52129
+ encode(name, data, options) {
52130
+ return this.get(name).encode(data, options);
52131
+ },
52132
+ decode(name, text, options) {
52133
+ return this.get(name).decode(text, options);
52134
+ },
52135
+ tryDecode(name, text, options) {
52136
+ try {
52137
+ return { ok: true, bytes: this.decode(name, text, options) };
52138
+ } catch (error) {
52139
+ return { ok: false, error: toError(error) };
52140
+ }
52141
+ },
52142
+ normalize(name, text, options) {
52143
+ const converter = this.get(name);
52144
+ return requireCapability(converter, name, "normalize").call(converter, text, options);
52145
+ },
52146
+ parse(name, text, options) {
52147
+ const converter = this.get(name);
52148
+ return requireCapability(converter, name, "parse").call(converter, text, options);
52149
+ },
52150
+ format(name, data, format4) {
52151
+ const converter = this.get(name);
52152
+ return requireCapability(converter, name, "format").call(converter, data, format4);
52153
+ },
52154
+ transcode(text, options) {
52155
+ const bytes = this.decode(options.from, text, options.fromOptions);
52156
+ return this.encode(options.to, bytes, options.toOptions);
52157
+ },
52158
+ detect(text, options = {}) {
52159
+ const formatNames = options.formats?.length ? options.formats.map((name) => String(name)) : this.list().map((converter) => converter.name).filter((name) => !["binary", "utf8", "utf16be", "utf16le"].includes(keyOf(name)));
52160
+ const detections = /* @__PURE__ */ new Map();
52161
+ for (const requestedName of formatNames) {
52162
+ const converter = this.get(requestedName);
52163
+ const confidence = detectConfidence(requestedName, text, converter);
52164
+ if (confidence <= 0) {
52165
+ continue;
52166
+ }
52167
+ const format4 = converter.name;
52168
+ const current = detections.get(format4);
52169
+ if (!current || confidence > current.confidence) {
52170
+ detections.set(format4, { format: format4, confidence });
52171
+ }
52172
+ }
52173
+ return [...detections.values()].sort((left, right) => right.confidence - left.confidence);
52174
+ }
52175
+ };
52176
+ for (const converter of initialConverters) {
52177
+ api.register(converter);
52178
+ }
52179
+ return api;
52180
+ }
52181
+
52182
+ // ../../node_modules/@peculiar/utils/build/esm/converters/defaults.js
52183
+ init_inject_buffer();
52184
+ var binaryConverter = {
52185
+ name: "binary",
52186
+ aliases: ["latin1"],
52187
+ encode: binary_exports.encode,
52188
+ decode: binary_exports.decode,
52189
+ is: binary_exports.is
52190
+ };
52191
+ var hexConverter = {
52192
+ name: "hex",
52193
+ encode: hex_exports.encode,
52194
+ decode: hex_exports.decode,
52195
+ format: hex_exports.format,
52196
+ is: hex_exports.is,
52197
+ normalize: hex_exports.normalize,
52198
+ parse: hex_exports.parse
52199
+ };
52200
+ var base64Converter = {
52201
+ name: "base64",
52202
+ aliases: ["b64"],
52203
+ encode: base64_exports.encode,
52204
+ decode: base64_exports.decode,
52205
+ is: base64_exports.is,
52206
+ normalize: base64_exports.normalize
52207
+ };
52208
+ var base64urlConverter = {
52209
+ name: "base64url",
52210
+ aliases: ["base64-url", "b64url"],
52211
+ encode: base64url_exports.encode,
52212
+ decode: base64url_exports.decode,
52213
+ is: base64url_exports.is,
52214
+ normalize: base64url_exports.normalize
52215
+ };
52216
+ var utf8Converter = {
52217
+ name: "utf8",
52218
+ aliases: ["utf-8"],
52219
+ encode: (data) => utf8_exports.decode(data),
52220
+ decode: (text) => utf8_exports.encode(text),
52221
+ is: (text) => typeof text === "string"
52222
+ };
52223
+ var utf16beConverter = {
52224
+ name: "utf16be",
52225
+ aliases: ["utf16", "utf-16", "utf-16be"],
52226
+ encode: (data) => utf16_exports.decode(data),
52227
+ decode: (text) => utf16_exports.encode(text),
52228
+ is: (text) => typeof text === "string"
52229
+ };
52230
+ var utf16leConverter = {
52231
+ name: "utf16le",
52232
+ aliases: ["utf-16le", "ucs2", "usc2"],
52233
+ encode: (data) => utf16_exports.decode(data, { littleEndian: true }),
52234
+ decode: (text) => utf16_exports.encode(text, { littleEndian: true }),
52235
+ is: (text) => typeof text === "string"
52236
+ };
52237
+ var defaultConverters = [
52238
+ binaryConverter,
52239
+ hexConverter,
52240
+ base64Converter,
52241
+ base64urlConverter,
52242
+ utf8Converter,
52243
+ utf16beConverter,
52244
+ utf16leConverter,
52245
+ pemConverter
52246
+ ];
52247
+ var defaultConverterRegistry = createConverterRegistry(defaultConverters);
52248
+
52249
+ // ../../node_modules/@peculiar/utils/build/esm/converters/convert.js
52250
+ init_inject_buffer();
52251
+ function encode8(name, data, ...args) {
52252
+ return defaultConverterRegistry.encode(name, data, ...args);
52253
+ }
52254
+ function decode8(name, text, ...args) {
52255
+ return defaultConverterRegistry.decode(name, text, ...args);
52256
+ }
52257
+ function tryDecode(name, text, ...args) {
52258
+ return defaultConverterRegistry.tryDecode(name, text, ...args);
52259
+ }
52260
+ function normalize4(name, text, ...args) {
52261
+ return defaultConverterRegistry.normalize(name, text, ...args);
52262
+ }
52263
+ function parse3(name, text, ...args) {
52264
+ return defaultConverterRegistry.parse(name, text, ...args);
52265
+ }
52266
+ function format3(name, data, value) {
52267
+ return defaultConverterRegistry.format(name, data, value);
52268
+ }
52269
+ function transcode(text, options) {
52270
+ return defaultConverterRegistry.transcode(text, options);
52271
+ }
52272
+ function detect(text, options) {
52273
+ return defaultConverterRegistry.detect(text, options);
52274
+ }
52275
+ function normalizeEncodingName(encoding) {
52276
+ return encoding.toLowerCase();
52277
+ }
52278
+ var convert = {
52279
+ encode: encode8,
52280
+ decode: decode8,
52281
+ tryDecode,
52282
+ normalize: normalize4,
52283
+ parse: parse3,
52284
+ format: format3,
52285
+ transcode,
52286
+ detect,
52287
+ to(format4, data, ...args) {
52288
+ return encode8(format4, data, ...args);
52289
+ },
52290
+ from(format4, text, ...args) {
52291
+ return decode8(format4, text, ...args);
52292
+ },
52293
+ toString(data, encoding = "utf8") {
52294
+ return encode8(encoding, data);
52295
+ },
52296
+ fromString(text, encoding = "utf8") {
52297
+ if (normalizeEncodingName(encoding) === "hex") {
52298
+ return toArrayBuffer(hex_exports.decode(text, { allowOddLength: true }));
52299
+ }
52300
+ return toArrayBuffer(decode8(encoding, text));
52301
+ },
52302
+ toBase64: base64_exports.encode,
52303
+ fromBase64: (text) => toArrayBuffer(base64_exports.decode(text)),
52304
+ toBase64Url: base64url_exports.encode,
52305
+ fromBase64Url: (text) => toArrayBuffer(base64url_exports.decode(text)),
52306
+ toHex: hex_exports.encode,
52307
+ fromHex: (text) => toArrayBuffer(hex_exports.decode(text, { allowOddLength: true })),
52308
+ toBinary: binary_exports.encode,
52309
+ fromBinary: (text) => toArrayBuffer(binary_exports.decode(text)),
52310
+ toUtf8String: utf8_exports.decode,
52311
+ fromUtf8String: (text) => toArrayBuffer(utf8_exports.encode(text)),
52312
+ toUtf16String: (data, littleEndian = false) => utf16_exports.decode(data, { littleEndian }),
52313
+ fromUtf16String: (text, littleEndian = false) => toArrayBuffer(utf16_exports.encode(text, { littleEndian })),
52314
+ isHex: hex_exports.is,
52315
+ isBase64: base64_exports.is,
52316
+ isBase64Url: base64url_exports.is,
52317
+ formatString: base64_exports.normalize
52318
+ };
52319
+
52320
+ // ../../node_modules/@peculiar/utils/build/esm/legacy/index.js
52321
+ init_inject_buffer();
52322
+
52323
+ // ../../node_modules/@peculiar/utils/build/esm/legacy/buffer-source-converter.js
52324
+ init_inject_buffer();
52325
+
52326
+ // ../../node_modules/@peculiar/utils/build/esm/legacy/convert.js
52327
+ init_inject_buffer();
52328
+
52329
+ // ../../node_modules/@peculiar/utils/build/esm/legacy/functions.js
52330
+ init_inject_buffer();
52331
+
51489
52332
  // ../../node_modules/@peculiar/asn1-schema/build/es2015/enums.js
51490
52333
  init_inject_buffer();
51491
52334
  var AsnTypeTypes;
@@ -51654,6 +52497,10 @@ var AsnIntegerArrayBufferConverter = {
51654
52497
  fromASN: (value) => toArrayBuffer(value.valueBlock.valueHexView),
51655
52498
  toASN: (value) => new Integer({ valueHex: value })
51656
52499
  };
52500
+ var AsnIntegerBigIntConverter = {
52501
+ fromASN: (value) => value.toBigInt(),
52502
+ toASN: (value) => Integer.fromBigInt(value)
52503
+ };
51657
52504
  var AsnBitStringConverter = {
51658
52505
  fromASN: (value) => toArrayBuffer(value.valueBlock.valueHexView),
51659
52506
  toASN: (value) => new BitString({ valueHex: value })
@@ -52486,257 +53333,6 @@ init_inject_buffer();
52486
53333
 
52487
53334
  // ../../node_modules/@peculiar/asn1-x509/build/es2015/ip_converter.js
52488
53335
  init_inject_buffer();
52489
-
52490
- // ../../node_modules/@peculiar/utils/build/esm/encoding/index.js
52491
- init_inject_buffer();
52492
-
52493
- // ../../node_modules/@peculiar/utils/build/esm/encoding/binary.js
52494
- init_inject_buffer();
52495
-
52496
- // ../../node_modules/@peculiar/utils/build/esm/encoding/hex.js
52497
- var hex_exports = {};
52498
- __export(hex_exports, {
52499
- decode: () => decode,
52500
- encode: () => encode,
52501
- format: () => format,
52502
- formats: () => formats,
52503
- hex: () => hex,
52504
- is: () => is,
52505
- normalize: () => normalize,
52506
- parse: () => parse
52507
- });
52508
- init_inject_buffer();
52509
- var HEX_CHARACTER_REGEX = /^[0-9a-f]$/i;
52510
- var COMMON_SEPARATORS = [" ", " ", "\n", "\r", ":", "-", "."];
52511
- function resolveSeparators(options) {
52512
- if (options.separators === "none") {
52513
- return [];
52514
- }
52515
- if (!options.separators || options.separators === "common") {
52516
- return COMMON_SEPARATORS;
52517
- }
52518
- return options.separators;
52519
- }
52520
- function validateSeparator(separator) {
52521
- if (!separator) {
52522
- throw new TypeError("Hex separators must be non-empty strings");
52523
- }
52524
- }
52525
- function matchSeparator(text, index, separators) {
52526
- for (const separator of separators) {
52527
- if (text.startsWith(separator, index)) {
52528
- return separator;
52529
- }
52530
- }
52531
- return void 0;
52532
- }
52533
- function detectCase(text) {
52534
- const hasUpper = /[A-F]/.test(text);
52535
- const hasLower = /[a-f]/.test(text);
52536
- return hasUpper && !hasLower ? "upper" : "lower";
52537
- }
52538
- function detectLineSeparator(text) {
52539
- const match = /\r\n|\n/.exec(text);
52540
- if (!match) {
52541
- return void 0;
52542
- }
52543
- return match[0] === "\r\n" ? "\r\n" : "\n";
52544
- }
52545
- function compactForDetection(text) {
52546
- return text.replace(/[^0-9a-f]/gi, "");
52547
- }
52548
- function detectGroup(text) {
52549
- const segments = text.match(/[0-9A-Fa-f]+|[^0-9A-Fa-f]+/g) ?? [];
52550
- if (segments.length < 3) {
52551
- return void 0;
52552
- }
52553
- const hexSegments = segments.filter((_, index) => index % 2 === 0);
52554
- const separators = segments.filter((_, index) => index % 2 === 1);
52555
- const separator = separators[0];
52556
- if (!separator || separators.some((item) => item !== separator)) {
52557
- return void 0;
52558
- }
52559
- if (hexSegments.some((segment) => segment.length === 0 || segment.length % 2 !== 0)) {
52560
- return void 0;
52561
- }
52562
- const firstLength = hexSegments[0]?.length ?? 0;
52563
- if (!firstLength) {
52564
- return void 0;
52565
- }
52566
- if (hexSegments.slice(0, -1).some((segment) => segment.length !== firstLength)) {
52567
- return void 0;
52568
- }
52569
- if ((hexSegments[hexSegments.length - 1]?.length ?? 0) > firstLength) {
52570
- return void 0;
52571
- }
52572
- return {
52573
- size: firstLength / 2,
52574
- separator
52575
- };
52576
- }
52577
- function detectFormat(text) {
52578
- const trimmed = text.trim();
52579
- const prefix = /^0x/i.test(trimmed) ? "0x" : "";
52580
- const body = prefix ? trimmed.slice(2) : trimmed;
52581
- const lineSeparator = detectLineSeparator(body);
52582
- const lines = body.split(/\r\n|\n/).filter((line) => line.length > 0);
52583
- const sampleLine = lines[0]?.trim() ?? "";
52584
- const group = detectGroup(sampleLine);
52585
- const format2 = {
52586
- case: detectCase(trimmed),
52587
- prefix
52588
- };
52589
- if (group) {
52590
- format2.group = group;
52591
- }
52592
- if (lineSeparator && lines.length > 1) {
52593
- const firstLineBytes = compactForDetection(lines[0] ?? "").length / 2;
52594
- if (firstLineBytes > 0 && lines.slice(0, -1).every((line) => compactForDetection(line).length / 2 === firstLineBytes)) {
52595
- format2.line = {
52596
- bytesPerLine: firstLineBytes,
52597
- separator: lineSeparator
52598
- };
52599
- }
52600
- }
52601
- return format2;
52602
- }
52603
- function normalizeText(text, options) {
52604
- const allowPrefix = options.allowPrefix ?? true;
52605
- const separators = [...resolveSeparators(options)].sort((left, right) => right.length - left.length);
52606
- for (const separator of separators) {
52607
- validateSeparator(separator);
52608
- }
52609
- let working = text.trim();
52610
- if (/^0x/i.test(working)) {
52611
- if (!allowPrefix) {
52612
- throw new TypeError("Hexadecimal text must not include a 0x prefix");
52613
- }
52614
- working = working.slice(2);
52615
- }
52616
- let normalized = "";
52617
- let lastTokenWasSeparator = false;
52618
- for (let index = 0; index < working.length; ) {
52619
- const character = working[index] ?? "";
52620
- if (HEX_CHARACTER_REGEX.test(character)) {
52621
- normalized += character;
52622
- lastTokenWasSeparator = false;
52623
- index += 1;
52624
- continue;
52625
- }
52626
- const separator = matchSeparator(working, index, separators);
52627
- if (!separator) {
52628
- throw new TypeError("Input is not valid hexadecimal text");
52629
- }
52630
- if (options.strict && (lastTokenWasSeparator || normalized.length === 0)) {
52631
- throw new TypeError("Hexadecimal text contains misplaced separators");
52632
- }
52633
- lastTokenWasSeparator = true;
52634
- index += separator.length;
52635
- }
52636
- if (options.strict && lastTokenWasSeparator && normalized.length > 0) {
52637
- throw new TypeError("Hexadecimal text must not end with a separator");
52638
- }
52639
- if (normalized.length % 2 !== 0) {
52640
- if (!options.allowOddLength) {
52641
- throw new TypeError("Hexadecimal text must contain an even number of characters");
52642
- }
52643
- normalized = `0${normalized}`;
52644
- }
52645
- return normalized.toLowerCase();
52646
- }
52647
- function groupPairs(pairs, group) {
52648
- if (!group) {
52649
- return pairs.join("");
52650
- }
52651
- if (!Number.isInteger(group.size) || group.size < 1) {
52652
- throw new RangeError("Hex group size must be a positive integer");
52653
- }
52654
- const chunks = [];
52655
- for (let index = 0; index < pairs.length; index += group.size) {
52656
- chunks.push(pairs.slice(index, index + group.size).join(""));
52657
- }
52658
- return chunks.join(group.separator);
52659
- }
52660
- function normalize(text, options = {}) {
52661
- return normalizeText(text, options);
52662
- }
52663
- function is(text, options = {}) {
52664
- if (typeof text !== "string") {
52665
- return false;
52666
- }
52667
- try {
52668
- normalize(text, options);
52669
- return true;
52670
- } catch {
52671
- return false;
52672
- }
52673
- }
52674
- function encode(data, options = {}) {
52675
- const bytes = toUint8Array(data);
52676
- const casing = options.case ?? "lower";
52677
- const pairs = Array.from(bytes, (byte) => {
52678
- const text = byte.toString(16).padStart(2, "0");
52679
- return casing === "upper" ? text.toUpperCase() : text;
52680
- });
52681
- let body = "";
52682
- if (options.line) {
52683
- const bytesPerLine = options.line.bytesPerLine;
52684
- if (!Number.isInteger(bytesPerLine) || bytesPerLine < 1) {
52685
- throw new RangeError("Hex bytesPerLine must be a positive integer");
52686
- }
52687
- const separator = options.line.separator ?? "\n";
52688
- const lines = [];
52689
- for (let index = 0; index < pairs.length; index += bytesPerLine) {
52690
- lines.push(groupPairs(pairs.slice(index, index + bytesPerLine), options.group));
52691
- }
52692
- body = lines.join(separator);
52693
- } else {
52694
- body = groupPairs(pairs, options.group);
52695
- }
52696
- return `${options.prefix ?? ""}${body}`;
52697
- }
52698
- function decode(text, options = {}) {
52699
- const normalized = normalize(text, options);
52700
- const result = new Uint8Array(normalized.length / 2);
52701
- for (let i = 0; i < normalized.length; i += 2) {
52702
- result[i / 2] = Number.parseInt(normalized.slice(i, i + 2), 16);
52703
- }
52704
- return result;
52705
- }
52706
- function parse(text, options = {}) {
52707
- const normalized = normalize(text, options);
52708
- return {
52709
- bytes: decode(normalized),
52710
- format: detectFormat(text),
52711
- normalized
52712
- };
52713
- }
52714
- function format(data, value) {
52715
- return encode(data, value);
52716
- }
52717
- var formats = {
52718
- compact: Object.freeze({}),
52719
- upper: Object.freeze({ case: "upper" }),
52720
- colon: Object.freeze({ group: { size: 1, separator: ":" } }),
52721
- colonUpper: Object.freeze({ case: "upper", group: { size: 1, separator: ":" } }),
52722
- groupsOf4: Object.freeze({ group: { size: 4, separator: " " } }),
52723
- prefixed: Object.freeze({ prefix: "0x" })
52724
- };
52725
- var hex = { encode, decode, format, formats, is, normalize, parse };
52726
-
52727
- // ../../node_modules/@peculiar/utils/build/esm/encoding/utf8.js
52728
- init_inject_buffer();
52729
-
52730
- // ../../node_modules/@peculiar/utils/build/esm/encoding/utf16.js
52731
- init_inject_buffer();
52732
-
52733
- // ../../node_modules/@peculiar/utils/build/esm/encoding/base64.js
52734
- init_inject_buffer();
52735
-
52736
- // ../../node_modules/@peculiar/utils/build/esm/encoding/base64url.js
52737
- init_inject_buffer();
52738
-
52739
- // ../../node_modules/@peculiar/asn1-x509/build/es2015/ip_converter.js
52740
53336
  var IpConverter = class {
52741
53337
  static isIPv4(ip) {
52742
53338
  return /^(\d{1,3}\.){3}\d{1,3}$/.test(ip);
@@ -56608,8 +57204,8 @@ init_inject_buffer();
56608
57204
  // ../../node_modules/tsyringe/dist/esm5/lazy-helpers.js
56609
57205
  init_inject_buffer();
56610
57206
  var DelayedConstructor = (function() {
56611
- function DelayedConstructor2(wrap) {
56612
- this.wrap = wrap;
57207
+ function DelayedConstructor2(wrap2) {
57208
+ this.wrap = wrap2;
56613
57209
  this.reflectMethods = [
56614
57210
  "get",
56615
57211
  "getPrototypeOf",
@@ -58268,14 +58864,14 @@ var TextConverter = class {
58268
58864
  }
58269
58865
  static serializeObj(obj, deep = 0) {
58270
58866
  const res = [];
58271
- let pad = this.pad(deep++);
58867
+ let pad2 = this.pad(deep++);
58272
58868
  let value = "";
58273
58869
  const objValue = obj[TextObject.VALUE];
58274
58870
  if (objValue) {
58275
58871
  value = ` ${objValue}`;
58276
58872
  }
58277
- res.push(`${pad}${obj[TextObject.NAME]}:${value}`);
58278
- pad = this.pad(deep);
58873
+ res.push(`${pad2}${obj[TextObject.NAME]}:${value}`);
58874
+ pad2 = this.pad(deep);
58279
58875
  for (const key in obj) {
58280
58876
  if (typeof key === "symbol") {
58281
58877
  continue;
@@ -58283,9 +58879,9 @@ var TextConverter = class {
58283
58879
  const value2 = obj[key];
58284
58880
  const keyValue = key ? `${key}: ` : "";
58285
58881
  if (typeof value2 === "string" || typeof value2 === "number" || typeof value2 === "boolean") {
58286
- res.push(`${pad}${keyValue}${value2}`);
58882
+ res.push(`${pad2}${keyValue}${value2}`);
58287
58883
  } else if (value2 instanceof Date) {
58288
- res.push(`${pad}${keyValue}${value2.toUTCString()}`);
58884
+ res.push(`${pad2}${keyValue}${value2.toUTCString()}`);
58289
58885
  } else if (Array.isArray(value2)) {
58290
58886
  for (const obj2 of value2) {
58291
58887
  obj2[TextObject.NAME] = key;
@@ -58296,7 +58892,7 @@ var TextConverter = class {
58296
58892
  res.push(...this.serializeObj(value2, deep));
58297
58893
  } else if (import_pvtsutils.BufferSourceConverter.isBufferSource(value2)) {
58298
58894
  if (key) {
58299
- res.push(`${pad}${keyValue}`);
58895
+ res.push(`${pad2}${keyValue}`);
58300
58896
  res.push(...this.serializeBufferSource(value2, deep + 1));
58301
58897
  } else {
58302
58898
  res.push(...this.serializeBufferSource(value2, deep));
@@ -58312,7 +58908,7 @@ var TextConverter = class {
58312
58908
  return res;
58313
58909
  }
58314
58910
  static serializeBufferSource(buffer, deep = 0) {
58315
- const pad = this.pad(deep);
58911
+ const pad2 = this.pad(deep);
58316
58912
  const view = import_pvtsutils.BufferSourceConverter.toUint8Array(buffer);
58317
58913
  const res = [];
58318
58914
  for (let i = 0; i < view.length; ) {
@@ -58324,7 +58920,7 @@ var TextConverter = class {
58324
58920
  const hex2 = view[i++].toString(16).padStart(2, "0");
58325
58921
  row.push(hex2);
58326
58922
  }
58327
- res.push(`${pad}${row.join(" ")}`);
58923
+ res.push(`${pad2}${row.join(" ")}`);
58328
58924
  }
58329
58925
  return res;
58330
58926
  }
@@ -58359,8 +58955,8 @@ var AsnData = class _AsnData {
58359
58955
  }
58360
58956
  return false;
58361
58957
  }
58362
- toString(format2 = "text") {
58363
- switch (format2) {
58958
+ toString(format4 = "text") {
58959
+ switch (format4) {
58364
58960
  case "asn":
58365
58961
  return AsnConvert.toString(this.rawData);
58366
58962
  case "text":
@@ -58934,12 +59530,12 @@ var PemConverter = class {
58934
59530
  static isPem(data) {
58935
59531
  return typeof data === "string" && new RegExp(rPem, "g").test(data.replace(/\r/g, ""));
58936
59532
  }
58937
- static decodeWithHeaders(pem) {
58938
- pem = pem.replace(/\r/g, "");
59533
+ static decodeWithHeaders(pem2) {
59534
+ pem2 = pem2.replace(/\r/g, "");
58939
59535
  const pattern = new RegExp(rPem, "g");
58940
59536
  const res = [];
58941
59537
  let matches = null;
58942
- while (matches = pattern.exec(pem)) {
59538
+ while (matches = pattern.exec(pem2)) {
58943
59539
  const base642 = matches[3].replace(rEolPattern, "");
58944
59540
  const pemStruct = {
58945
59541
  type: matches[1],
@@ -58975,12 +59571,12 @@ var PemConverter = class {
58975
59571
  }
58976
59572
  return res;
58977
59573
  }
58978
- static decode(pem) {
58979
- const blocks = this.decodeWithHeaders(pem);
59574
+ static decode(pem2) {
59575
+ const blocks = this.decodeWithHeaders(pem2);
58980
59576
  return blocks.map((o) => o.rawData);
58981
59577
  }
58982
- static decodeFirst(pem) {
58983
- const items = this.decode(pem);
59578
+ static decodeFirst(pem2) {
59579
+ const items = this.decode(pem2);
58984
59580
  if (!items.length) {
58985
59581
  throw new RangeError("PEM string doesn't contain any objects");
58986
59582
  }
@@ -59018,18 +59614,18 @@ var PemConverter = class {
59018
59614
  });
59019
59615
  }
59020
59616
  }
59021
- static encodeStruct(pem) {
59617
+ static encodeStruct(pem2) {
59022
59618
  var _a3;
59023
- const upperCaseType = pem.type.toLocaleUpperCase();
59619
+ const upperCaseType = pem2.type.toLocaleUpperCase();
59024
59620
  const res = [];
59025
59621
  res.push(`-----BEGIN ${upperCaseType}-----`);
59026
- if ((_a3 = pem.headers) === null || _a3 === void 0 ? void 0 : _a3.length) {
59027
- for (const header of pem.headers) {
59622
+ if ((_a3 = pem2.headers) === null || _a3 === void 0 ? void 0 : _a3.length) {
59623
+ for (const header of pem2.headers) {
59028
59624
  res.push(`${header.key}: ${header.value}`);
59029
59625
  }
59030
59626
  res.push("");
59031
59627
  }
59032
- const base642 = import_pvtsutils.Convert.ToBase64(pem.rawData);
59628
+ const base642 = import_pvtsutils.Convert.ToBase64(pem2.rawData);
59033
59629
  for (let i = 0; i < base642.length; i += 64) {
59034
59630
  res.push(base642.substring(i, i + 64));
59035
59631
  }
@@ -59084,12 +59680,12 @@ var PemData = class _PemData extends AsnData {
59084
59680
  super(args[0]);
59085
59681
  }
59086
59682
  }
59087
- toString(format2 = "pem") {
59088
- switch (format2) {
59683
+ toString(format4 = "pem") {
59684
+ switch (format4) {
59089
59685
  case "pem":
59090
59686
  return PemConverter.encode(this.rawData, this.tag);
59091
59687
  default:
59092
- return super.toString(format2);
59688
+ return super.toString(format4);
59093
59689
  }
59094
59690
  }
59095
59691
  };
@@ -60464,7 +61060,7 @@ var X509Certificates = class extends Array {
60464
61060
  }
60465
61061
  }
60466
61062
  }
60467
- export(format2) {
61063
+ export(format4) {
60468
61064
  const signedData = new SignedData();
60469
61065
  signedData.version = 1;
60470
61066
  signedData.encapContentInfo.eContentType = id_data;
@@ -60475,10 +61071,10 @@ var X509Certificates = class extends Array {
60475
61071
  content: AsnConvert.serialize(signedData)
60476
61072
  });
60477
61073
  const raw = AsnConvert.serialize(cms);
60478
- if (format2 === "raw") {
61074
+ if (format4 === "raw") {
60479
61075
  return raw;
60480
61076
  }
60481
- return this.toString(format2);
61077
+ return this.toString(format4);
60482
61078
  }
60483
61079
  import(data) {
60484
61080
  const raw = PemData.toArrayBuffer(data);
@@ -60498,9 +61094,9 @@ var X509Certificates = class extends Array {
60498
61094
  while (this.pop()) {
60499
61095
  }
60500
61096
  }
60501
- toString(format2 = "pem") {
61097
+ toString(format4 = "pem") {
60502
61098
  const raw = this.export("raw");
60503
- switch (format2) {
61099
+ switch (format4) {
60504
61100
  case "pem":
60505
61101
  return PemConverter.encode(raw, "CMS");
60506
61102
  case "pem-chain":
@@ -61096,6 +61692,104 @@ function getCrypto() {
61096
61692
  return _crypto || crypto || node_crypto_shim_default;
61097
61693
  }
61098
61694
 
61695
+ // ../node-opcua-crypto/source/x509/build_ca_extensions.ts
61696
+ init_inject_buffer();
61697
+ async function buildAuthorityKeyIdentifierFromIssuer(issuerPublicKey, crypto4 = getCrypto()) {
61698
+ return x509_es_exports.AuthorityKeyIdentifierExtension.create(issuerPublicKey, false, crypto4);
61699
+ }
61700
+ function buildRevocationExtensions(params) {
61701
+ const extensions = [];
61702
+ if (params.crlDistributionUrl) {
61703
+ extensions.push(new x509_es_exports.CRLDistributionPointsExtension([params.crlDistributionUrl], false));
61704
+ }
61705
+ if (params.ocspResponderUrl || params.caIssuersUrl) {
61706
+ extensions.push(
61707
+ new x509_es_exports.AuthorityInfoAccessExtension(
61708
+ {
61709
+ ocsp: params.ocspResponderUrl,
61710
+ caIssuers: params.caIssuersUrl
61711
+ },
61712
+ false
61713
+ )
61714
+ );
61715
+ }
61716
+ return extensions;
61717
+ }
61718
+ var ID_CE_CRL_NUMBER = "2.5.29.20";
61719
+ function buildCrlNumberExtension(crlNumber) {
61720
+ const value = typeof crlNumber === "bigint" ? crlNumber : BigInt(crlNumber);
61721
+ return new x509_es_exports.Extension(ID_CE_CRL_NUMBER, false, AsnConvert.serialize(AsnIntegerBigIntConverter.toASN(value)));
61722
+ }
61723
+
61724
+ // ../node-opcua-crypto/source/x509/ca_signer.ts
61725
+ init_inject_buffer();
61726
+ var LocalPrivateKeySigner = class {
61727
+ algorithm;
61728
+ #privateKey;
61729
+ #publicKey;
61730
+ #crypto;
61731
+ constructor(keys, algorithm, crypto4 = getCrypto()) {
61732
+ this.#privateKey = keys.privateKey;
61733
+ this.#publicKey = keys.publicKey;
61734
+ this.algorithm = algorithm;
61735
+ this.#crypto = crypto4;
61736
+ }
61737
+ async getPublicKey() {
61738
+ return this.#crypto.subtle.exportKey("spki", this.#publicKey);
61739
+ }
61740
+ async sign(tbs) {
61741
+ return this.#crypto.subtle.sign(this.algorithm, this.#privateKey, tbs);
61742
+ }
61743
+ };
61744
+ async function webCryptoFromSigner(signer, baseCrypto = getCrypto()) {
61745
+ const publicKeyDer = await signer.getPublicKey();
61746
+ const publicKey = await baseCrypto.subtle.importKey("spki", publicKeyDer, signer.algorithm, true, ["verify"]);
61747
+ const privateKeyHandle = {
61748
+ type: "private",
61749
+ extractable: false,
61750
+ algorithm: signer.algorithm,
61751
+ usages: ["sign"]
61752
+ };
61753
+ const subtle = new Proxy(baseCrypto.subtle, {
61754
+ get(target, prop, receiver) {
61755
+ if (prop === "sign") {
61756
+ return async (algorithm, key, data) => {
61757
+ if (key !== privateKeyHandle) {
61758
+ return target.sign(algorithm, key, data);
61759
+ }
61760
+ const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
61761
+ return signer.sign(bytes);
61762
+ };
61763
+ }
61764
+ const value = Reflect.get(target, prop, receiver);
61765
+ return typeof value === "function" ? value.bind(target) : value;
61766
+ }
61767
+ });
61768
+ const crypto4 = new Proxy(baseCrypto, {
61769
+ get(target, prop, receiver) {
61770
+ if (prop === "subtle") {
61771
+ return subtle;
61772
+ }
61773
+ const value = Reflect.get(target, prop, receiver);
61774
+ return typeof value === "function" ? value.bind(target) : value;
61775
+ }
61776
+ });
61777
+ return { crypto: crypto4, privateKeyHandle, publicKey };
61778
+ }
61779
+ function isCaSigner(value) {
61780
+ return typeof value.sign === "function" && typeof value.getPublicKey === "function";
61781
+ }
61782
+ async function resolveCaSigningKey(signingKey, baseCrypto = getCrypto()) {
61783
+ if (isCaSigner(signingKey)) {
61784
+ const adapted = await webCryptoFromSigner(signingKey, baseCrypto);
61785
+ return { crypto: adapted.crypto, signingKey: adapted.privateKeyHandle };
61786
+ }
61787
+ return { crypto: baseCrypto, signingKey };
61788
+ }
61789
+
61790
+ // ../node-opcua-crypto/source/x509/coerce_private_key.ts
61791
+ init_inject_buffer();
61792
+
61099
61793
  // ../node-opcua-crypto/source/x509/create_key_pair.ts
61100
61794
  init_inject_buffer();
61101
61795
  var ENCRYPTED_PEM_HEADER = "-----BEGIN ENCRYPTED PRIVATE KEY-----";
@@ -61142,13 +61836,13 @@ async function derToPrivateKey(privDer) {
61142
61836
  );
61143
61837
  return importedKey;
61144
61838
  }
61145
- async function pemToPrivateKey(pem) {
61146
- if (pem.includes(ENCRYPTED_PEM_HEADER)) {
61839
+ async function pemToPrivateKey(pem2) {
61840
+ if (pem2.includes(ENCRYPTED_PEM_HEADER)) {
61147
61841
  throw new Error(
61148
61842
  "This private key is encrypted (PKCS#8 ENCRYPTED PRIVATE KEY). Encrypted private keys are not supported by the WebCrypto-based browser build; use the Node.js build's readPrivateKey()/readPrivateKeyAsync() with a passphrase instead."
61149
61843
  );
61150
61844
  }
61151
- const privDer = x509_es_exports.PemConverter.decode(pem);
61845
+ const privDer = x509_es_exports.PemConverter.decode(pem2);
61152
61846
  return derToPrivateKey(privDer[0]);
61153
61847
  }
61154
61848
 
@@ -61185,32 +61879,9 @@ async function _coercePrivateKey(privateKey) {
61185
61879
  throw new Error("Invalid privateKey");
61186
61880
  }
61187
61881
 
61188
- // ../node-opcua-crypto/source/x509/create_certificate_signing_request.ts
61882
+ // ../node-opcua-crypto/source/x509/create_certificate_from_csr.ts
61189
61883
  init_inject_buffer();
61190
61884
 
61191
- // ../node-opcua-crypto/source/x509/_build_public_key.ts
61192
- init_inject_buffer();
61193
- async function buildPublicKey(privateKey) {
61194
- const crypto4 = getCrypto();
61195
- const jwk = await crypto4.subtle.exportKey("jwk", privateKey);
61196
- delete jwk.d;
61197
- delete jwk.dp;
61198
- delete jwk.dq;
61199
- delete jwk.q;
61200
- delete jwk.qi;
61201
- jwk.key_ops = [
61202
- "encrypt",
61203
- "sign"
61204
- // "wrapKey"
61205
- ];
61206
- const publicKey = await crypto4.subtle.importKey("jwk", jwk, { name: "RSASSA-PKCS1-v1_5", hash: { name: "SHA-256" } }, true, [
61207
- // "encrypt",
61208
- // "sign",
61209
- // "wrapKey",
61210
- ]);
61211
- return publicKey;
61212
- }
61213
-
61214
61885
  // ../node-opcua-crypto/source/x509/_get_attributes.ts
61215
61886
  init_inject_buffer();
61216
61887
  var keyUsageApplication = x509_es_exports.KeyUsageFlags.keyEncipherment | x509_es_exports.KeyUsageFlags.nonRepudiation | x509_es_exports.KeyUsageFlags.dataEncipherment | x509_es_exports.KeyUsageFlags.keyCertSign | x509_es_exports.KeyUsageFlags.digitalSignature;
@@ -61242,6 +61913,81 @@ function getAttributes(purpose) {
61242
61913
  return { nsComment, basicConstraints, keyUsageExtension, usages };
61243
61914
  }
61244
61915
 
61916
+ // ../node-opcua-crypto/source/x509/create_certificate_from_csr.ts
61917
+ async function createCertificateFromCsr(options) {
61918
+ const crypto4 = getCrypto();
61919
+ const csr = new x509_es_exports.Pkcs10CertificateRequest(options.csr);
61920
+ const csrIsValid = await csr.verify(crypto4);
61921
+ if (!csrIsValid) {
61922
+ throw new Error("createCertificateFromCsr: the CSR signature does not verify \u2014 refusing to sign an unproven key");
61923
+ }
61924
+ const { basicConstraints, keyUsageExtension, usages } = getAttributes(options.purpose);
61925
+ const alternativeNameExtensions = [];
61926
+ for (const d of options.dns ?? []) {
61927
+ alternativeNameExtensions.push({ type: "dns", value: d });
61928
+ }
61929
+ for (const d of options.ip ?? []) {
61930
+ alternativeNameExtensions.push({ type: "ip", value: d });
61931
+ }
61932
+ if (options.applicationUri) {
61933
+ alternativeNameExtensions.push({ type: "url", value: options.applicationUri });
61934
+ }
61935
+ const extensions = [
61936
+ basicConstraints,
61937
+ new x509_es_exports.ExtendedKeyUsageExtension(keyUsageExtension, true),
61938
+ new x509_es_exports.KeyUsagesExtension(usages, true),
61939
+ await x509_es_exports.SubjectKeyIdentifierExtension.create(csr.publicKey),
61940
+ await buildAuthorityKeyIdentifierFromIssuer(options.issuerPublicKey, crypto4),
61941
+ new x509_es_exports.SubjectAlternativeNameExtension(alternativeNameExtensions),
61942
+ ...options.revocation ? buildRevocationExtensions(options.revocation) : []
61943
+ ];
61944
+ const notBefore = options.notBefore ?? /* @__PURE__ */ new Date();
61945
+ const validity = options.validity ?? 365;
61946
+ const notAfter = options.notAfter ?? new Date(notBefore.getTime() + validity * 24 * 60 * 60 * 1e3);
61947
+ const { crypto: signingCrypto, signingKey } = await resolveCaSigningKey(options.signingKey, crypto4);
61948
+ const cert = await x509_es_exports.X509CertificateGenerator.create(
61949
+ {
61950
+ serialNumber: options.serialNumber,
61951
+ subject: csr.subjectName,
61952
+ issuer: options.issuerName,
61953
+ notBefore,
61954
+ notAfter,
61955
+ signingAlgorithm: options.signingAlgorithm,
61956
+ publicKey: csr.publicKey,
61957
+ signingKey,
61958
+ extensions
61959
+ },
61960
+ signingCrypto
61961
+ );
61962
+ return { cert: cert.toString("pem"), der: cert.rawData };
61963
+ }
61964
+
61965
+ // ../node-opcua-crypto/source/x509/create_certificate_signing_request.ts
61966
+ init_inject_buffer();
61967
+
61968
+ // ../node-opcua-crypto/source/x509/_build_public_key.ts
61969
+ init_inject_buffer();
61970
+ async function buildPublicKey(privateKey) {
61971
+ const crypto4 = getCrypto();
61972
+ const jwk = await crypto4.subtle.exportKey("jwk", privateKey);
61973
+ delete jwk.d;
61974
+ delete jwk.dp;
61975
+ delete jwk.dq;
61976
+ delete jwk.q;
61977
+ delete jwk.qi;
61978
+ jwk.key_ops = [
61979
+ "encrypt",
61980
+ "sign"
61981
+ // "wrapKey"
61982
+ ];
61983
+ const publicKey = await crypto4.subtle.importKey("jwk", jwk, { name: "RSASSA-PKCS1-v1_5", hash: { name: "SHA-256" } }, true, [
61984
+ // "encrypt",
61985
+ // "sign",
61986
+ // "wrapKey",
61987
+ ]);
61988
+ return publicKey;
61989
+ }
61990
+
61245
61991
  // ../node-opcua-crypto/source/x509/create_certificate_signing_request.ts
61246
61992
  async function createCertificateSigningRequest({
61247
61993
  privateKey,
@@ -61294,6 +62040,37 @@ async function createCertificateSigningRequest({
61294
62040
  return { csr: csr.toString("pem"), der: csr };
61295
62041
  }
61296
62042
 
62043
+ // ../node-opcua-crypto/source/x509/create_crl.ts
62044
+ init_inject_buffer();
62045
+ async function createCrl(options) {
62046
+ const crypto4 = getCrypto();
62047
+ const thisUpdate = options.thisUpdate ?? /* @__PURE__ */ new Date();
62048
+ const nextUpdate = options.nextUpdate ?? new Date(thisUpdate.getTime() + 30 * 24 * 60 * 60 * 1e3);
62049
+ const extensions = [
62050
+ await buildAuthorityKeyIdentifierFromIssuer(options.issuerPublicKey, crypto4),
62051
+ buildCrlNumberExtension(options.crlNumber)
62052
+ ];
62053
+ const { crypto: signingCrypto, signingKey } = await resolveCaSigningKey(options.signingKey, crypto4);
62054
+ const crl = await x509_es_exports.X509CrlGenerator.create(
62055
+ {
62056
+ issuer: options.issuerName,
62057
+ thisUpdate,
62058
+ nextUpdate,
62059
+ signingAlgorithm: options.signingAlgorithm,
62060
+ signingKey,
62061
+ extensions,
62062
+ entries: options.entries.map((entry) => ({
62063
+ serialNumber: entry.serialNumber,
62064
+ revocationDate: entry.revocationDate ?? /* @__PURE__ */ new Date(),
62065
+ reason: entry.reason,
62066
+ invalidity: entry.invalidity
62067
+ }))
62068
+ },
62069
+ signingCrypto
62070
+ );
62071
+ return { crl: crl.toString("pem"), der: crl.rawData };
62072
+ }
62073
+
61297
62074
  // ../node-opcua-crypto/source/x509/create_self_signed_certificate.ts
61298
62075
  init_inject_buffer();
61299
62076
  async function createSelfSignedCertificate({
@@ -61340,7 +62117,11 @@ async function createSelfSignedCertificate({
61340
62117
  const name = s1;
61341
62118
  const cert = await x509_es_exports.X509CertificateGenerator.createSelfSigned(
61342
62119
  {
61343
- serialNumber: Date.now().toString(),
62120
+ // no serialNumber: @peculiar/x509 generates a cryptographically
62121
+ // random 16-byte serial when it is omitted. Date.now().toString()
62122
+ // was read back as a HEX string by the generator, not decimal, so
62123
+ // it produced a predictable, easily-colliding serial (two certs
62124
+ // created in the same millisecond got the same value).
61344
62125
  name,
61345
62126
  notBefore,
61346
62127
  notAfter,
@@ -61373,27 +62154,34 @@ function rsaLengthPrivateKey(key) {
61373
62154
  (0, import_node_assert6.default)(modulusLength, "Cannot determine modulus length from private key");
61374
62155
  return modulusLength / 8;
61375
62156
  }
61376
- function toPem2(raw_key, pem) {
62157
+ function toPem2(raw_key, pem2) {
61377
62158
  if (raw_key.hidden) {
61378
- return toPem2(raw_key.hidden, pem);
62159
+ return toPem2(raw_key.hidden, pem2);
61379
62160
  }
61380
62161
  (0, import_node_assert6.default)(raw_key, "expecting a key");
61381
- (0, import_node_assert6.default)(typeof pem === "string");
62162
+ (0, import_node_assert6.default)(typeof pem2 === "string");
61382
62163
  if (isKeyObject(raw_key)) {
61383
62164
  const _raw_key = raw_key;
61384
- if (pem === "RSA PRIVATE KEY") {
62165
+ if (pem2 === "RSA PRIVATE KEY") {
61385
62166
  return removeTrailingLF(_raw_key.export({ format: "pem", type: "pkcs1" }).toString());
61386
- } else if (pem === "PRIVATE KEY") {
62167
+ } else if (pem2 === "PRIVATE KEY") {
61387
62168
  return removeTrailingLF(_raw_key.export({ format: "pem", type: "pkcs8" }).toString());
61388
62169
  } else {
61389
62170
  throw new Error("Unsupported case!");
61390
62171
  }
61391
62172
  }
61392
- return toPem(raw_key, pem);
62173
+ return toPem(raw_key, pem2);
61393
62174
  }
61394
62175
  function coercePrivateKeyPem(privateKey) {
61395
62176
  return toPem2(privateKey, "PRIVATE KEY");
61396
62177
  }
62178
+ async function privateKeyToCryptoKey(key) {
62179
+ if (!(typeof key === "object" && key !== null && "hidden" in key)) {
62180
+ return key;
62181
+ }
62182
+ const pem2 = coercePrivateKeyPem(key);
62183
+ return pemToPrivateKey(pem2);
62184
+ }
61397
62185
  function coercePublicKeyPem(publicKey) {
61398
62186
  if (isKeyObject(publicKey)) {
61399
62187
  return publicKey.export({ format: "pem", type: "spki" }).toString();
@@ -61583,6 +62371,7 @@ function certificateMatchesPrivateKey(certificate, privateKey) {
61583
62371
  var asn1 = { readDirectoryName, readTag, readStruct, readAlgorithmIdentifier, readSignatureValueBin };
61584
62372
  export {
61585
62373
  CertificatePurpose,
62374
+ LocalPrivateKeySigner,
61586
62375
  PaddingAlgorithm,
61587
62376
  PfxIntegrityError,
61588
62377
  PfxMalformedError,
@@ -61593,6 +62382,9 @@ export {
61593
62382
  Subject,
61594
62383
  _coercePrivateKey,
61595
62384
  asn1,
62385
+ buildAuthorityKeyIdentifierFromIssuer,
62386
+ buildCrlNumberExtension,
62387
+ buildRevocationExtensions,
61596
62388
  certificateMatchesPrivateKey,
61597
62389
  clearExploreCertificateCache,
61598
62390
  coerceCertificate,
@@ -61605,7 +62397,9 @@ export {
61605
62397
  computeDerivedKeys,
61606
62398
  computePaddingFooter,
61607
62399
  convertPEMtoDER,
62400
+ createCertificateFromCsr,
61608
62401
  createCertificateSigningRequest,
62402
+ createCrl,
61609
62403
  createPrivateKeyFromNodeJSCrypto,
61610
62404
  createSelfSignedCertificate,
61611
62405
  decryptBufferWithDerivedKeys,
@@ -61621,6 +62415,7 @@ export {
61621
62415
  extractPublicKeyFromCertificateSync,
61622
62416
  generateKeyPair,
61623
62417
  generatePrivateKey,
62418
+ getCrypto,
61624
62419
  hexDump,
61625
62420
  identifyDERContent,
61626
62421
  identifyPemType,
@@ -61636,6 +62431,7 @@ export {
61636
62431
  privateDecrypt2 as privateDecrypt,
61637
62432
  privateDecrypt_long,
61638
62433
  privateDecrypt_native,
62434
+ privateKeyToCryptoKey,
61639
62435
  privateKeyToPEM,
61640
62436
  publicEncrypt2 as publicEncrypt,
61641
62437
  publicEncrypt_long,
@@ -61648,6 +62444,7 @@ export {
61648
62444
  reduceLength,
61649
62445
  removePadding,
61650
62446
  removeTrailingLF,
62447
+ resolveCaSigningKey,
61651
62448
  rsaLengthPrivateKey,
61652
62449
  rsaLengthPublicKey,
61653
62450
  rsaLengthRsaPublicKey,
@@ -61662,7 +62459,9 @@ export {
61662
62459
  verifyChunkSignatureWithDerivedKeys,
61663
62460
  verifyCrlIssuedByCertificate,
61664
62461
  verifyMessageChunkSignature,
61665
- verify_certificate_der_structure
62462
+ verify_certificate_der_structure,
62463
+ webCryptoFromSigner,
62464
+ x509_es_exports as x509
61666
62465
  };
61667
62466
  /*! Bundled license information:
61668
62467