@volter/tabnode 0.5.49 → 0.5.51

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.
@@ -19252,14 +19252,14 @@ var safeBuffer = { exports: {} };
19252
19252
  var buffer = {};
19253
19253
  var ieee754 = {};
19254
19254
  /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
19255
- ieee754.read = function(buffer2, offset2, isLE, mLen, nBytes) {
19255
+ ieee754.read = function(buffer2, offset2, isLE2, mLen, nBytes) {
19256
19256
  var e2, m;
19257
19257
  var eLen = nBytes * 8 - mLen - 1;
19258
19258
  var eMax = (1 << eLen) - 1;
19259
19259
  var eBias = eMax >> 1;
19260
19260
  var nBits = -7;
19261
- var i10 = isLE ? nBytes - 1 : 0;
19262
- var d = isLE ? -1 : 1;
19261
+ var i10 = isLE2 ? nBytes - 1 : 0;
19262
+ var d = isLE2 ? -1 : 1;
19263
19263
  var s10 = buffer2[offset2 + i10];
19264
19264
  i10 += d;
19265
19265
  e2 = s10 & (1 << -nBits) - 1;
@@ -19282,14 +19282,14 @@ ieee754.read = function(buffer2, offset2, isLE, mLen, nBytes) {
19282
19282
  }
19283
19283
  return (s10 ? -1 : 1) * m * Math.pow(2, e2 - mLen);
19284
19284
  };
19285
- ieee754.write = function(buffer2, value, offset2, isLE, mLen, nBytes) {
19285
+ ieee754.write = function(buffer2, value, offset2, isLE2, mLen, nBytes) {
19286
19286
  var e2, m, c;
19287
19287
  var eLen = nBytes * 8 - mLen - 1;
19288
19288
  var eMax = (1 << eLen) - 1;
19289
19289
  var eBias = eMax >> 1;
19290
19290
  var rt2 = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
19291
- var i10 = isLE ? 0 : nBytes - 1;
19292
- var d = isLE ? 1 : -1;
19291
+ var i10 = isLE2 ? 0 : nBytes - 1;
19292
+ var d = isLE2 ? 1 : -1;
19293
19293
  var s10 = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
19294
19294
  value = Math.abs(value);
19295
19295
  if (isNaN(value) || value === Infinity) {
@@ -20180,10 +20180,10 @@ ieee754.write = function(buffer2, value, offset2, isLE, mLen, nBytes) {
20180
20180
  byteLength3 = byteLength3 >>> 0;
20181
20181
  if (!noAssert) checkOffset(offset2, byteLength3, this.length);
20182
20182
  let val = this[offset2];
20183
- let mul = 1;
20183
+ let mul3 = 1;
20184
20184
  let i10 = 0;
20185
- while (++i10 < byteLength3 && (mul *= 256)) {
20186
- val += this[offset2 + i10] * mul;
20185
+ while (++i10 < byteLength3 && (mul3 *= 256)) {
20186
+ val += this[offset2 + i10] * mul3;
20187
20187
  }
20188
20188
  return val;
20189
20189
  };
@@ -20194,9 +20194,9 @@ ieee754.write = function(buffer2, value, offset2, isLE, mLen, nBytes) {
20194
20194
  checkOffset(offset2, byteLength3, this.length);
20195
20195
  }
20196
20196
  let val = this[offset2 + --byteLength3];
20197
- let mul = 1;
20198
- while (byteLength3 > 0 && (mul *= 256)) {
20199
- val += this[offset2 + --byteLength3] * mul;
20197
+ let mul3 = 1;
20198
+ while (byteLength3 > 0 && (mul3 *= 256)) {
20199
+ val += this[offset2 + --byteLength3] * mul3;
20200
20200
  }
20201
20201
  return val;
20202
20202
  };
@@ -20254,13 +20254,13 @@ ieee754.write = function(buffer2, value, offset2, isLE, mLen, nBytes) {
20254
20254
  byteLength3 = byteLength3 >>> 0;
20255
20255
  if (!noAssert) checkOffset(offset2, byteLength3, this.length);
20256
20256
  let val = this[offset2];
20257
- let mul = 1;
20257
+ let mul3 = 1;
20258
20258
  let i10 = 0;
20259
- while (++i10 < byteLength3 && (mul *= 256)) {
20260
- val += this[offset2 + i10] * mul;
20259
+ while (++i10 < byteLength3 && (mul3 *= 256)) {
20260
+ val += this[offset2 + i10] * mul3;
20261
20261
  }
20262
- mul *= 128;
20263
- if (val >= mul) val -= Math.pow(2, 8 * byteLength3);
20262
+ mul3 *= 128;
20263
+ if (val >= mul3) val -= Math.pow(2, 8 * byteLength3);
20264
20264
  return val;
20265
20265
  };
20266
20266
  Buffer2.prototype.readIntBE = function readIntBE(offset2, byteLength3, noAssert) {
@@ -20268,13 +20268,13 @@ ieee754.write = function(buffer2, value, offset2, isLE, mLen, nBytes) {
20268
20268
  byteLength3 = byteLength3 >>> 0;
20269
20269
  if (!noAssert) checkOffset(offset2, byteLength3, this.length);
20270
20270
  let i10 = byteLength3;
20271
- let mul = 1;
20271
+ let mul3 = 1;
20272
20272
  let val = this[offset2 + --i10];
20273
- while (i10 > 0 && (mul *= 256)) {
20274
- val += this[offset2 + --i10] * mul;
20273
+ while (i10 > 0 && (mul3 *= 256)) {
20274
+ val += this[offset2 + --i10] * mul3;
20275
20275
  }
20276
- mul *= 128;
20277
- if (val >= mul) val -= Math.pow(2, 8 * byteLength3);
20276
+ mul3 *= 128;
20277
+ if (val >= mul3) val -= Math.pow(2, 8 * byteLength3);
20278
20278
  return val;
20279
20279
  };
20280
20280
  Buffer2.prototype.readInt8 = function readInt8(offset2, noAssert) {
@@ -20361,11 +20361,11 @@ ieee754.write = function(buffer2, value, offset2, isLE, mLen, nBytes) {
20361
20361
  const maxBytes = Math.pow(2, 8 * byteLength3) - 1;
20362
20362
  checkInt(this, value, offset2, byteLength3, maxBytes, 0);
20363
20363
  }
20364
- let mul = 1;
20364
+ let mul3 = 1;
20365
20365
  let i10 = 0;
20366
20366
  this[offset2] = value & 255;
20367
- while (++i10 < byteLength3 && (mul *= 256)) {
20368
- this[offset2 + i10] = value / mul & 255;
20367
+ while (++i10 < byteLength3 && (mul3 *= 256)) {
20368
+ this[offset2 + i10] = value / mul3 & 255;
20369
20369
  }
20370
20370
  return offset2 + byteLength3;
20371
20371
  };
@@ -20378,10 +20378,10 @@ ieee754.write = function(buffer2, value, offset2, isLE, mLen, nBytes) {
20378
20378
  checkInt(this, value, offset2, byteLength3, maxBytes, 0);
20379
20379
  }
20380
20380
  let i10 = byteLength3 - 1;
20381
- let mul = 1;
20381
+ let mul3 = 1;
20382
20382
  this[offset2 + i10] = value & 255;
20383
- while (--i10 >= 0 && (mul *= 256)) {
20384
- this[offset2 + i10] = value / mul & 255;
20383
+ while (--i10 >= 0 && (mul3 *= 256)) {
20384
+ this[offset2 + i10] = value / mul3 & 255;
20385
20385
  }
20386
20386
  return offset2 + byteLength3;
20387
20387
  };
@@ -20482,14 +20482,14 @@ ieee754.write = function(buffer2, value, offset2, isLE, mLen, nBytes) {
20482
20482
  checkInt(this, value, offset2, byteLength3, limit - 1, -limit);
20483
20483
  }
20484
20484
  let i10 = 0;
20485
- let mul = 1;
20485
+ let mul3 = 1;
20486
20486
  let sub = 0;
20487
20487
  this[offset2] = value & 255;
20488
- while (++i10 < byteLength3 && (mul *= 256)) {
20488
+ while (++i10 < byteLength3 && (mul3 *= 256)) {
20489
20489
  if (value < 0 && sub === 0 && this[offset2 + i10 - 1] !== 0) {
20490
20490
  sub = 1;
20491
20491
  }
20492
- this[offset2 + i10] = (value / mul >> 0) - sub & 255;
20492
+ this[offset2 + i10] = (value / mul3 >> 0) - sub & 255;
20493
20493
  }
20494
20494
  return offset2 + byteLength3;
20495
20495
  };
@@ -20501,14 +20501,14 @@ ieee754.write = function(buffer2, value, offset2, isLE, mLen, nBytes) {
20501
20501
  checkInt(this, value, offset2, byteLength3, limit - 1, -limit);
20502
20502
  }
20503
20503
  let i10 = byteLength3 - 1;
20504
- let mul = 1;
20504
+ let mul3 = 1;
20505
20505
  let sub = 0;
20506
20506
  this[offset2 + i10] = value & 255;
20507
- while (--i10 >= 0 && (mul *= 256)) {
20507
+ while (--i10 >= 0 && (mul3 *= 256)) {
20508
20508
  if (value < 0 && sub === 0 && this[offset2 + i10 + 1] !== 0) {
20509
20509
  sub = 1;
20510
20510
  }
20511
- this[offset2 + i10] = (value / mul >> 0) - sub & 255;
20511
+ this[offset2 + i10] = (value / mul3 >> 0) - sub & 255;
20512
20512
  }
20513
20513
  return offset2 + byteLength3;
20514
20514
  };
@@ -23009,23 +23009,23 @@ var sha_jsExports = sha_js.exports;
23009
23009
  var SHA = /* @__PURE__ */ getDefaultExportFromCjs(sha_jsExports);
23010
23010
  const fromNumH = (n8) => n8 / 2 ** 32 | 0;
23011
23011
  const fromNumL = (n8) => n8 >>> 0;
23012
- function setU64FromNum(view, byteOffset, n8, isLE) {
23012
+ function setU64FromNum(view, byteOffset, n8, isLE2) {
23013
23013
  const h = fromNumH(n8);
23014
23014
  const l = fromNumL(n8);
23015
- view.setUint32(byteOffset, isLE ? l : h, isLE);
23016
- view.setUint32(byteOffset + 4, isLE ? h : l, isLE);
23015
+ view.setUint32(byteOffset, isLE2 ? l : h, isLE2);
23016
+ view.setUint32(byteOffset + 4, isLE2 ? h : l, isLE2);
23017
23017
  }
23018
- function isBytes(a) {
23018
+ function isBytes$1(a) {
23019
23019
  return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
23020
23020
  }
23021
- const atitle = (title) => title ? `"${title}" ` : "";
23022
- function abytes(value, length, title = "") {
23023
- if (isBytes(value) && length === void 0)
23021
+ const atitle$1 = (title) => title ? `"${title}" ` : "";
23022
+ function abytes$1(value, length, title = "") {
23023
+ if (isBytes$1(value) && length === void 0)
23024
23024
  return value;
23025
- const bytes2 = isBytes(value);
23025
+ const bytes2 = isBytes$1(value);
23026
23026
  const ofLen = "";
23027
23027
  const got = bytes2 ? `length=${value.length}` : `type=${typeof value}`;
23028
- const message = atitle(title) + "expected Uint8Array" + ofLen + ", got " + got;
23028
+ const message = atitle$1(title) + "expected Uint8Array" + ofLen + ", got " + got;
23029
23029
  if (!bytes2)
23030
23030
  throw new TypeError(message);
23031
23031
  throw new RangeError(message);
@@ -23034,25 +23034,25 @@ const aobject = (value, label) => {
23034
23034
  if (value === null || typeof value !== "object" || Array.isArray(value))
23035
23035
  throw new TypeError((label === "object" ? "" : `"${label}" `) + "expected object, got type=" + typeof value);
23036
23036
  };
23037
- function aexists(instance, checkFinished = true) {
23037
+ function aexists$1(instance, checkFinished = true) {
23038
23038
  if (instance.destroyed)
23039
23039
  throw new Error("hash was destroyed");
23040
23040
  if (checkFinished && instance.finished)
23041
23041
  throw new Error("digest() was already called");
23042
23042
  }
23043
- function aoutput(out, instance) {
23044
- abytes(out, void 0, "output");
23043
+ function aoutput$1(out, instance) {
23044
+ abytes$1(out, void 0, "output");
23045
23045
  const min2 = instance.outputLen;
23046
23046
  if (!(out.length >= min2)) {
23047
23047
  throw new RangeError('"output" expected length >= ' + min2);
23048
23048
  }
23049
23049
  }
23050
- function clean(...arrays) {
23050
+ function clean$1(...arrays) {
23051
23051
  for (let i10 = 0; i10 < arrays.length; i10++) {
23052
23052
  arrays[i10].fill(0);
23053
23053
  }
23054
23054
  }
23055
- function createView(arr) {
23055
+ function createView$1(arr) {
23056
23056
  return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
23057
23057
  }
23058
23058
  function rotr(word, shift) {
@@ -23067,7 +23067,7 @@ const hasHexBuiltin = /* @__PURE__ */ (() => (
23067
23067
  ))();
23068
23068
  const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i10) => i10.toString(16).padStart(2, "0"));
23069
23069
  function bytesToHex(bytes2) {
23070
- abytes(bytes2);
23070
+ abytes$1(bytes2);
23071
23071
  if (hasHexBuiltin)
23072
23072
  return bytes2.toHex();
23073
23073
  let hex = "";
@@ -23108,7 +23108,7 @@ function Maj(a, b, c) {
23108
23108
  return a & b ^ a & c ^ b & c;
23109
23109
  }
23110
23110
  class HashMD {
23111
- constructor(blockLen, outputLen, padOffset, isLE) {
23111
+ constructor(blockLen, outputLen, padOffset, isLE2) {
23112
23112
  __publicField(this, "blockLen");
23113
23113
  __publicField(this, "outputLen");
23114
23114
  __publicField(this, "canXOF", false);
@@ -23124,20 +23124,20 @@ class HashMD {
23124
23124
  this.blockLen = blockLen;
23125
23125
  this.outputLen = outputLen;
23126
23126
  this.padOffset = padOffset;
23127
- this.isLE = isLE;
23127
+ this.isLE = isLE2;
23128
23128
  this.buffer = new Uint8Array(blockLen);
23129
- this.view = createView(this.buffer);
23129
+ this.view = createView$1(this.buffer);
23130
23130
  }
23131
23131
  update(data2) {
23132
- aexists(this);
23133
- abytes(data2);
23132
+ aexists$1(this);
23133
+ abytes$1(data2);
23134
23134
  const { view, buffer: buffer2, blockLen } = this;
23135
23135
  const len2 = data2.length;
23136
23136
  let processed = false;
23137
23137
  for (let pos = 0; pos < len2; ) {
23138
23138
  const take = Math.min(blockLen - this.pos, len2 - pos);
23139
23139
  if (take === blockLen) {
23140
- const dataView = createView(data2);
23140
+ const dataView = createView$1(data2);
23141
23141
  for (; blockLen <= len2 - pos; pos += blockLen)
23142
23142
  this.process(dataView, pos);
23143
23143
  processed = true;
@@ -23158,10 +23158,10 @@ class HashMD {
23158
23158
  return this;
23159
23159
  }
23160
23160
  digestInto(out) {
23161
- aexists(this);
23162
- aoutput(out, this);
23161
+ aexists$1(this);
23162
+ aoutput$1(out, this);
23163
23163
  this.finished = true;
23164
- const { buffer: buffer2, view, blockLen, isLE } = this;
23164
+ const { buffer: buffer2, view, blockLen, isLE: isLE2 } = this;
23165
23165
  let { pos } = this;
23166
23166
  buffer2[pos++] = 128;
23167
23167
  buffer2.fill(0, pos);
@@ -23169,17 +23169,17 @@ class HashMD {
23169
23169
  this.process(view, 0);
23170
23170
  buffer2.fill(0);
23171
23171
  }
23172
- setU64FromNum(view, blockLen - 8, this.length * 8, isLE);
23172
+ setU64FromNum(view, blockLen - 8, this.length * 8, isLE2);
23173
23173
  this.process(view, 0);
23174
23174
  this.roundClean();
23175
- const oview = out === buffer2 ? view : createView(out);
23175
+ const oview = out === buffer2 ? view : createView$1(out);
23176
23176
  const len2 = this.outputLen;
23177
23177
  const outLen = len2 / 4;
23178
23178
  const state = this.get();
23179
23179
  if (len2 % 4 || outLen > state.length)
23180
23180
  throw new Error("invalid outputLen");
23181
23181
  for (let i10 = 0; i10 < outLen; i10++)
23182
- oview.setUint32(4 * i10, state[i10], isLE);
23182
+ oview.setUint32(4 * i10, state[i10], isLE2);
23183
23183
  }
23184
23184
  digest() {
23185
23185
  const { buffer: buffer2, outputLen } = this;
@@ -23286,12 +23286,12 @@ class _MD5 extends HashMD {
23286
23286
  this.set(A10, B, C, D10);
23287
23287
  }
23288
23288
  roundClean() {
23289
- clean(MD5_W);
23289
+ clean$1(MD5_W);
23290
23290
  }
23291
23291
  destroy() {
23292
23292
  this.destroyed = true;
23293
23293
  this.set(0, 0, 0, 0);
23294
- clean(this.buffer);
23294
+ clean$1(this.buffer);
23295
23295
  }
23296
23296
  }
23297
23297
  const md5 = /* @__PURE__ */ createHasher(() => new _MD5());
@@ -23301,6 +23301,993 @@ const cryptoConstants = {
23301
23301
  RSA_PKCS1_OAEP_PADDING: 4,
23302
23302
  RSA_PKCS1_PSS_PADDING: 6
23303
23303
  };
23304
+ /*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */
23305
+ function isBytes(a) {
23306
+ return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
23307
+ }
23308
+ const atitle = (title) => title ? `"${title}" ` : "";
23309
+ function anumber(n8, title = "") {
23310
+ if (typeof n8 !== "number")
23311
+ throw new TypeError(atitle(title) + "expected number, got " + typeof n8);
23312
+ if (!Number.isSafeInteger(n8) || n8 < 0)
23313
+ throw new RangeError(atitle(title) + "expected integer >= 0, got " + n8);
23314
+ return n8;
23315
+ }
23316
+ function abytes(value, length, title = "") {
23317
+ if (isBytes(value) && (length === void 0 || value.length === length))
23318
+ return value;
23319
+ if (length !== void 0)
23320
+ anumber(length, "length");
23321
+ const bytes2 = isBytes(value);
23322
+ const ofLen = length !== void 0 ? ` of length ${length}` : "";
23323
+ const got = bytes2 ? `length=${value.length}` : `type=${typeof value}`;
23324
+ const message = atitle(title) + "expected Uint8Array" + ofLen + ", got " + got;
23325
+ if (!bytes2)
23326
+ throw new TypeError(message);
23327
+ throw new RangeError(message);
23328
+ }
23329
+ function aexists(instance, checkFinished = true) {
23330
+ if (instance.destroyed)
23331
+ throw new Error("hash was destroyed");
23332
+ if (checkFinished && instance.finished)
23333
+ throw new Error("digest() was already called");
23334
+ }
23335
+ function aoutput(out, instance) {
23336
+ abytes(out, void 0, "output");
23337
+ const min2 = instance.outputLen;
23338
+ if (!(out.length >= min2)) {
23339
+ throw new RangeError('"output" expected length >= ' + min2);
23340
+ }
23341
+ }
23342
+ function aoutput32(out, instance) {
23343
+ aoutput(out, instance);
23344
+ if (!isAligned32(out))
23345
+ throw new Error("invalid output, must be aligned");
23346
+ }
23347
+ function u8$1(arr) {
23348
+ return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
23349
+ }
23350
+ function u32(arr) {
23351
+ return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
23352
+ }
23353
+ function clean(...arrays) {
23354
+ for (let i10 = 0; i10 < arrays.length; i10++) {
23355
+ arrays[i10].fill(0);
23356
+ }
23357
+ }
23358
+ function createView(arr) {
23359
+ return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
23360
+ }
23361
+ const isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
23362
+ function byteSwap(word) {
23363
+ return word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
23364
+ }
23365
+ const swap8IfBE = isLE ? (n8) => n8 : (n8) => byteSwap(n8) >>> 0;
23366
+ function byteSwap32(arr) {
23367
+ for (let i10 = 0; i10 < arr.length; i10++) {
23368
+ arr[i10] = byteSwap(arr[i10]);
23369
+ }
23370
+ return arr;
23371
+ }
23372
+ const swap32IfBE = isLE ? (u) => u : byteSwap32;
23373
+ function overlapBytes(a, b) {
23374
+ if (!a.byteLength || !b.byteLength)
23375
+ return false;
23376
+ return a.buffer === b.buffer && // best we can do, may fail with an obscure Proxy
23377
+ a.byteOffset < b.byteOffset + b.byteLength && // a starts before b end
23378
+ b.byteOffset < a.byteOffset + a.byteLength;
23379
+ }
23380
+ function complexOverlapBytes(input, output) {
23381
+ if (overlapBytes(input, output) && input.byteOffset < output.byteOffset)
23382
+ throw new Error("complex overlap of input and output is not supported");
23383
+ }
23384
+ function wrapMacConstructor(keyLen, macCons, fromMsg) {
23385
+ const mac = macCons;
23386
+ const getArgs = fromMsg || (() => []);
23387
+ const macC = (msg2, key) => mac(key, ...getArgs(msg2)).update(msg2).digest();
23388
+ const tmp = mac(new Uint8Array(keyLen), ...getArgs(new Uint8Array(0)));
23389
+ macC.outputLen = tmp.outputLen;
23390
+ macC.blockLen = tmp.blockLen;
23391
+ macC.create = (key, ...args) => mac(key, ...args);
23392
+ return macC;
23393
+ }
23394
+ function getOutput(expectedLength, out, onlyAligned = true) {
23395
+ if (out === void 0)
23396
+ return new Uint8Array(expectedLength);
23397
+ abytes(out, expectedLength, "output");
23398
+ if (onlyAligned && !isAligned32(out))
23399
+ throw new Error("invalid output, must be aligned");
23400
+ return out;
23401
+ }
23402
+ function isAligned32(bytes2) {
23403
+ return bytes2.byteOffset % 4 === 0;
23404
+ }
23405
+ function copyBytes(bytes2) {
23406
+ return Uint8Array.from(abytes(bytes2));
23407
+ }
23408
+ const BLOCK_SIZE$1 = 16;
23409
+ const ZEROS16 = /* @__PURE__ */ new Uint8Array(16);
23410
+ const ZEROS32 = /* @__PURE__ */ u32(ZEROS16);
23411
+ const POLY$1 = 225;
23412
+ const mul2$1 = (s02, s12, s22, s32) => {
23413
+ const hiBit = s32 & 1;
23414
+ return {
23415
+ s3: s22 << 31 | s32 >>> 1,
23416
+ s2: s12 << 31 | s22 >>> 1,
23417
+ s1: s02 << 31 | s12 >>> 1,
23418
+ // NIST SP 800-38D §6.3 applies `V >> 1` and XORs R on carry. In this
23419
+ // 4x32-bit split, R = 0xe1 || 0^120 lives in the top byte of s0.
23420
+ s0: s02 >>> 1 ^ POLY$1 << 24 & -(hiBit & 1)
23421
+ // reduce % poly
23422
+ };
23423
+ };
23424
+ const swapLE = (n8) => (n8 >>> 0 & 255) << 24 | (n8 >>> 8 & 255) << 16 | (n8 >>> 16 & 255) << 8 | n8 >>> 24 & 255 | 0;
23425
+ const estimateWindow = (bytes2) => {
23426
+ if (bytes2 > 64 * 1024)
23427
+ return 8;
23428
+ if (bytes2 > 1024)
23429
+ return 4;
23430
+ return 2;
23431
+ };
23432
+ class GHASH {
23433
+ // We select bits per window adaptively based on expectedLength
23434
+ constructor(key, expectedLength) {
23435
+ __publicField(this, "blockLen", BLOCK_SIZE$1);
23436
+ __publicField(this, "outputLen", BLOCK_SIZE$1);
23437
+ __publicField(this, "s0", 0);
23438
+ __publicField(this, "s1", 0);
23439
+ __publicField(this, "s2", 0);
23440
+ __publicField(this, "s3", 0);
23441
+ __publicField(this, "finished", false);
23442
+ __publicField(this, "destroyed", false);
23443
+ __publicField(this, "t");
23444
+ __publicField(this, "W");
23445
+ __publicField(this, "windowSize");
23446
+ abytes(key, 16, "key");
23447
+ key = copyBytes(key);
23448
+ const kView = createView(key);
23449
+ let k02 = kView.getUint32(0, false);
23450
+ let k12 = kView.getUint32(4, false);
23451
+ let k22 = kView.getUint32(8, false);
23452
+ let k32 = kView.getUint32(12, false);
23453
+ const doubles = [];
23454
+ for (let i10 = 0; i10 < 128; i10++) {
23455
+ doubles.push({ s0: swapLE(k02), s1: swapLE(k12), s2: swapLE(k22), s3: swapLE(k32) });
23456
+ ({ s0: k02, s1: k12, s2: k22, s3: k32 } = mul2$1(k02, k12, k22, k32));
23457
+ }
23458
+ const W10 = estimateWindow(expectedLength || 1024);
23459
+ if (![1, 2, 4, 8].includes(W10))
23460
+ throw new Error("ghash: invalid window size, expected 2, 4 or 8");
23461
+ this.W = W10;
23462
+ const bits = 128;
23463
+ const windows = bits / W10;
23464
+ const windowSize = this.windowSize = 2 ** W10;
23465
+ const items = [];
23466
+ for (let w = 0; w < windows; w++) {
23467
+ for (let byte = 0; byte < windowSize; byte++) {
23468
+ let s02 = 0, s12 = 0, s22 = 0, s32 = 0;
23469
+ for (let j = 0; j < W10; j++) {
23470
+ const bit = byte >>> W10 - j - 1 & 1;
23471
+ if (!bit)
23472
+ continue;
23473
+ const { s0: d02, s1: d12, s2: d22, s3: d32 } = doubles[W10 * w + j];
23474
+ s02 ^= d02, s12 ^= d12, s22 ^= d22, s32 ^= d32;
23475
+ }
23476
+ items.push({ s0: s02, s1: s12, s2: s22, s3: s32 });
23477
+ }
23478
+ }
23479
+ this.t = items;
23480
+ }
23481
+ _updateBlock(s02, s12, s22, s32) {
23482
+ s02 ^= this.s0, s12 ^= this.s1, s22 ^= this.s2, s32 ^= this.s3;
23483
+ const { W: W10, t: t10, windowSize } = this;
23484
+ let o02 = 0, o12 = 0, o22 = 0, o32 = 0;
23485
+ const mask = (1 << W10) - 1;
23486
+ let w = 0;
23487
+ for (const num of [s02, s12, s22, s32]) {
23488
+ for (let bytePos = 0; bytePos < 4; bytePos++) {
23489
+ const byte = num >>> 8 * bytePos & 255;
23490
+ for (let bitPos = 8 / W10 - 1; bitPos >= 0; bitPos--) {
23491
+ const bit = byte >>> W10 * bitPos & mask;
23492
+ const { s0: e0, s1: e12, s2: e2, s3: e32 } = t10[w * windowSize + bit];
23493
+ o02 ^= e0, o12 ^= e12, o22 ^= e2, o32 ^= e32;
23494
+ w += 1;
23495
+ }
23496
+ }
23497
+ }
23498
+ this.s0 = o02;
23499
+ this.s1 = o12;
23500
+ this.s2 = o22;
23501
+ this.s3 = o32;
23502
+ }
23503
+ update(data2) {
23504
+ aexists(this);
23505
+ abytes(data2);
23506
+ data2 = copyBytes(data2);
23507
+ const b32 = u32(data2);
23508
+ const blocks = Math.floor(data2.length / BLOCK_SIZE$1);
23509
+ const left = data2.length % BLOCK_SIZE$1;
23510
+ for (let i10 = 0; i10 < blocks; i10++) {
23511
+ this._updateBlock(swap8IfBE(b32[i10 * 4 + 0]), swap8IfBE(b32[i10 * 4 + 1]), swap8IfBE(b32[i10 * 4 + 2]), swap8IfBE(b32[i10 * 4 + 3]));
23512
+ }
23513
+ if (left) {
23514
+ ZEROS16.set(data2.subarray(blocks * BLOCK_SIZE$1));
23515
+ this._updateBlock(swap8IfBE(ZEROS32[0]), swap8IfBE(ZEROS32[1]), swap8IfBE(ZEROS32[2]), swap8IfBE(ZEROS32[3]));
23516
+ clean(ZEROS32);
23517
+ }
23518
+ return this;
23519
+ }
23520
+ destroy() {
23521
+ this.destroyed = true;
23522
+ const { t: t10 } = this;
23523
+ for (const elm of t10) {
23524
+ elm.s0 = 0, elm.s1 = 0, elm.s2 = 0, elm.s3 = 0;
23525
+ }
23526
+ }
23527
+ digestInto(out) {
23528
+ aexists(this);
23529
+ aoutput32(out, this);
23530
+ this.finished = true;
23531
+ const { s0: s02, s1: s12, s2: s22, s3: s32 } = this;
23532
+ const o32 = u32(out);
23533
+ o32[0] = s02;
23534
+ o32[1] = s12;
23535
+ o32[2] = s22;
23536
+ o32[3] = s32;
23537
+ if (!isLE)
23538
+ swap32IfBE(o32.subarray(0, BLOCK_SIZE$1 / 4));
23539
+ }
23540
+ digest() {
23541
+ const res = new Uint8Array(BLOCK_SIZE$1);
23542
+ this.digestInto(res);
23543
+ this.destroy();
23544
+ return res;
23545
+ }
23546
+ }
23547
+ const BLOCK_SIZE = 16;
23548
+ const BLOCK_SIZE32 = 4;
23549
+ const EMPTY_BLOCK = /* @__PURE__ */ new Uint8Array(BLOCK_SIZE);
23550
+ const ONE_BLOCK = /* @__PURE__ */ Uint8Array.from([
23551
+ 0,
23552
+ 0,
23553
+ 0,
23554
+ 0,
23555
+ 0,
23556
+ 0,
23557
+ 0,
23558
+ 0,
23559
+ 0,
23560
+ 0,
23561
+ 0,
23562
+ 0,
23563
+ 0,
23564
+ 0,
23565
+ 0,
23566
+ 1
23567
+ ]);
23568
+ const POLY = 283;
23569
+ function validateKeyLength(key) {
23570
+ if (![16, 24, 32].includes(key.length))
23571
+ throw new Error('"aes key" expected Uint8Array of length 16/24/32, got length=' + key.length);
23572
+ }
23573
+ function mul2(n8) {
23574
+ return n8 << 1 ^ POLY & -(n8 >> 7);
23575
+ }
23576
+ function mul(a, b) {
23577
+ let res = 0;
23578
+ for (; b > 0; b >>= 1) {
23579
+ res ^= a & -(b & 1);
23580
+ a = mul2(a);
23581
+ }
23582
+ return res;
23583
+ }
23584
+ const sbox = /* @__PURE__ */ (() => {
23585
+ const t10 = new Uint8Array(256);
23586
+ for (let i10 = 0, x = 1; i10 < 256; i10++, x ^= mul2(x))
23587
+ t10[i10] = x;
23588
+ const box = new Uint8Array(256);
23589
+ box[0] = 99;
23590
+ for (let i10 = 0; i10 < 255; i10++) {
23591
+ let x = t10[255 - i10];
23592
+ x |= x << 8;
23593
+ box[t10[i10]] = (x ^ x >> 4 ^ x >> 5 ^ x >> 6 ^ x >> 7 ^ 99) & 255;
23594
+ }
23595
+ clean(t10);
23596
+ return box;
23597
+ })();
23598
+ const invSbox = /* @__PURE__ */ sbox.map((_, j) => sbox.indexOf(j));
23599
+ const rotr32_8 = (n8) => n8 << 24 | n8 >>> 8;
23600
+ const rotl32_8 = (n8) => n8 << 8 | n8 >>> 24;
23601
+ function genTtable(sbox2, fn2) {
23602
+ if (sbox2.length !== 256)
23603
+ throw new Error("wrong sbox length");
23604
+ const T02 = new Uint32Array(256).map((_, j) => fn2(sbox2[j]));
23605
+ const T12 = T02.map(rotl32_8);
23606
+ const T22 = T12.map(rotl32_8);
23607
+ const T32 = T22.map(rotl32_8);
23608
+ const T01 = new Uint32Array(256 * 256);
23609
+ const T23 = new Uint32Array(256 * 256);
23610
+ const sbox22 = new Uint16Array(256 * 256);
23611
+ for (let i10 = 0; i10 < 256; i10++) {
23612
+ for (let j = 0; j < 256; j++) {
23613
+ const idx = i10 * 256 + j;
23614
+ T01[idx] = T02[i10] ^ T12[j];
23615
+ T23[idx] = T22[i10] ^ T32[j];
23616
+ sbox22[idx] = sbox2[i10] << 8 | sbox2[j];
23617
+ }
23618
+ }
23619
+ return { sbox: sbox2, sbox2: sbox22, T0: T02, T1: T12, T2: T22, T3: T32, T01, T23 };
23620
+ }
23621
+ const tableEncoding = /* @__PURE__ */ genTtable(sbox, (s10) => mul(s10, 3) << 24 | s10 << 16 | s10 << 8 | mul(s10, 2));
23622
+ const tableDecoding = /* @__PURE__ */ genTtable(invSbox, (s10) => mul(s10, 11) << 24 | mul(s10, 13) << 16 | mul(s10, 9) << 8 | mul(s10, 14));
23623
+ const xPowers = /* @__PURE__ */ (() => {
23624
+ const p = new Uint8Array(16);
23625
+ for (let i10 = 0, x = 1; i10 < 16; i10++, x = mul2(x))
23626
+ p[i10] = x;
23627
+ return p;
23628
+ })();
23629
+ function expandKeyLE(key) {
23630
+ abytes(key);
23631
+ const len2 = key.length;
23632
+ validateKeyLength(key);
23633
+ const { sbox2 } = tableEncoding;
23634
+ const toClean = [];
23635
+ if (!isLE || !isAligned32(key))
23636
+ toClean.push(key = copyBytes(key));
23637
+ const k32 = swap32IfBE(u32(key));
23638
+ const Nk = k32.length;
23639
+ const subByte = (n8) => applySbox(sbox2, n8, n8, n8, n8);
23640
+ const xk = new Uint32Array(len2 + 28);
23641
+ xk.set(k32);
23642
+ for (let i10 = Nk; i10 < xk.length; i10++) {
23643
+ let t10 = xk[i10 - 1];
23644
+ if (i10 % Nk === 0)
23645
+ t10 = subByte(rotr32_8(t10)) ^ xPowers[i10 / Nk - 1];
23646
+ else if (Nk > 6 && i10 % Nk === 4)
23647
+ t10 = subByte(t10);
23648
+ xk[i10] = xk[i10 - Nk] ^ t10;
23649
+ }
23650
+ clean(...toClean);
23651
+ return xk;
23652
+ }
23653
+ function expandKeyDecLE(key) {
23654
+ const encKey = expandKeyLE(key);
23655
+ const xk = encKey.slice();
23656
+ const Nk = encKey.length;
23657
+ const { sbox2 } = tableEncoding;
23658
+ const { T0: T02, T1: T12, T2: T22, T3: T32 } = tableDecoding;
23659
+ for (let i10 = 0; i10 < Nk; i10 += 4) {
23660
+ for (let j = 0; j < 4; j++)
23661
+ xk[i10 + j] = encKey[Nk - i10 - 4 + j];
23662
+ }
23663
+ clean(encKey);
23664
+ for (let i10 = 4; i10 < Nk - 4; i10++) {
23665
+ const x = xk[i10];
23666
+ const w = applySbox(sbox2, x, x, x, x);
23667
+ xk[i10] = T02[w & 255] ^ T12[w >>> 8 & 255] ^ T22[w >>> 16 & 255] ^ T32[w >>> 24];
23668
+ }
23669
+ return xk;
23670
+ }
23671
+ function apply0123(T01, T23, s02, s12, s22, s32) {
23672
+ return T01[s02 << 8 & 65280 | s12 >>> 8 & 255] ^ T23[s22 >>> 8 & 65280 | s32 >>> 24 & 255];
23673
+ }
23674
+ function applySbox(sbox2, s02, s12, s22, s32) {
23675
+ return sbox2[s02 & 255 | s12 & 65280] | sbox2[s22 >>> 16 & 255 | s32 >>> 16 & 65280] << 16;
23676
+ }
23677
+ function encrypt(xk, s02, s12, s22, s32) {
23678
+ const { sbox2, T01, T23 } = tableEncoding;
23679
+ let k10 = 0;
23680
+ s02 ^= xk[k10++], s12 ^= xk[k10++], s22 ^= xk[k10++], s32 ^= xk[k10++];
23681
+ const rounds = xk.length / 4 - 2;
23682
+ for (let i10 = 0; i10 < rounds; i10++) {
23683
+ const t03 = xk[k10++] ^ apply0123(T01, T23, s02, s12, s22, s32);
23684
+ const t13 = xk[k10++] ^ apply0123(T01, T23, s12, s22, s32, s02);
23685
+ const t23 = xk[k10++] ^ apply0123(T01, T23, s22, s32, s02, s12);
23686
+ const t33 = xk[k10++] ^ apply0123(T01, T23, s32, s02, s12, s22);
23687
+ s02 = t03, s12 = t13, s22 = t23, s32 = t33;
23688
+ }
23689
+ const t02 = xk[k10++] ^ applySbox(sbox2, s02, s12, s22, s32);
23690
+ const t12 = xk[k10++] ^ applySbox(sbox2, s12, s22, s32, s02);
23691
+ const t22 = xk[k10++] ^ applySbox(sbox2, s22, s32, s02, s12);
23692
+ const t32 = xk[k10++] ^ applySbox(sbox2, s32, s02, s12, s22);
23693
+ return { s0: t02, s1: t12, s2: t22, s3: t32 };
23694
+ }
23695
+ function decrypt(xk, s02, s12, s22, s32) {
23696
+ const { sbox2, T01, T23 } = tableDecoding;
23697
+ let k10 = 0;
23698
+ s02 ^= xk[k10++], s12 ^= xk[k10++], s22 ^= xk[k10++], s32 ^= xk[k10++];
23699
+ const rounds = xk.length / 4 - 2;
23700
+ for (let i10 = 0; i10 < rounds; i10++) {
23701
+ const t03 = xk[k10++] ^ apply0123(T01, T23, s02, s32, s22, s12);
23702
+ const t13 = xk[k10++] ^ apply0123(T01, T23, s12, s02, s32, s22);
23703
+ const t23 = xk[k10++] ^ apply0123(T01, T23, s22, s12, s02, s32);
23704
+ const t33 = xk[k10++] ^ apply0123(T01, T23, s32, s22, s12, s02);
23705
+ s02 = t03, s12 = t13, s22 = t23, s32 = t33;
23706
+ }
23707
+ const t02 = xk[k10++] ^ applySbox(sbox2, s02, s32, s22, s12);
23708
+ const t12 = xk[k10++] ^ applySbox(sbox2, s12, s02, s32, s22);
23709
+ const t22 = xk[k10++] ^ applySbox(sbox2, s22, s12, s02, s32);
23710
+ const t32 = xk[k10++] ^ applySbox(sbox2, s32, s22, s12, s02);
23711
+ return { s0: t02, s1: t12, s2: t22, s3: t32 };
23712
+ }
23713
+ function ctrCounter(xk, nonce, src, dst) {
23714
+ abytes(nonce, BLOCK_SIZE, "nonce");
23715
+ abytes(src);
23716
+ const srcLen = src.length;
23717
+ dst = getOutput(srcLen, dst);
23718
+ complexOverlapBytes(src, dst);
23719
+ const ctr = nonce;
23720
+ const c32 = u32(ctr);
23721
+ const src32 = u32(src);
23722
+ const dst32 = u32(dst);
23723
+ for (let i10 = 0; i10 + 4 <= src32.length; i10 += 4) {
23724
+ const { s0: s02, s1: s12, s2: s22, s3: s32 } = encrypt(xk, swap8IfBE(c32[0]), swap8IfBE(c32[1]), swap8IfBE(c32[2]), swap8IfBE(c32[3]));
23725
+ dst32[i10 + 0] = src32[i10 + 0] ^ swap8IfBE(s02);
23726
+ dst32[i10 + 1] = src32[i10 + 1] ^ swap8IfBE(s12);
23727
+ dst32[i10 + 2] = src32[i10 + 2] ^ swap8IfBE(s22);
23728
+ dst32[i10 + 3] = src32[i10 + 3] ^ swap8IfBE(s32);
23729
+ for (let j = BLOCK_SIZE - 1, carry = 1; j >= 0; j--) {
23730
+ carry = carry + ctr[j] | 0;
23731
+ ctr[j] = carry & 255;
23732
+ carry >>>= 8;
23733
+ }
23734
+ }
23735
+ const start = BLOCK_SIZE * Math.floor(src32.length / BLOCK_SIZE32);
23736
+ if (start < srcLen) {
23737
+ const { s0: s02, s1: s12, s2: s22, s3: s32 } = encrypt(xk, swap8IfBE(c32[0]), swap8IfBE(c32[1]), swap8IfBE(c32[2]), swap8IfBE(c32[3]));
23738
+ const b32 = new Uint32Array([s02, s12, s22, s32]);
23739
+ swap32IfBE(b32);
23740
+ const buf = u8$1(b32);
23741
+ for (let i10 = start, pos = 0; i10 < srcLen; i10++, pos++)
23742
+ dst[i10] = src[i10] ^ buf[pos];
23743
+ clean(b32);
23744
+ }
23745
+ return dst;
23746
+ }
23747
+ function ctr32(xk, isLE2, nonce, src, dst) {
23748
+ abytes(nonce, BLOCK_SIZE, "nonce");
23749
+ abytes(src);
23750
+ dst = getOutput(src.length, dst);
23751
+ const ctr = nonce;
23752
+ const c32 = u32(ctr);
23753
+ const view = createView(ctr);
23754
+ const src32 = u32(src);
23755
+ const dst32 = u32(dst);
23756
+ const ctrPos = isLE2 ? 0 : 12;
23757
+ const srcLen = src.length;
23758
+ let ctrNum = view.getUint32(ctrPos, isLE2);
23759
+ for (let i10 = 0; i10 + 4 <= src32.length; i10 += 4) {
23760
+ const { s0: s02, s1: s12, s2: s22, s3: s32 } = encrypt(xk, swap8IfBE(c32[0]), swap8IfBE(c32[1]), swap8IfBE(c32[2]), swap8IfBE(c32[3]));
23761
+ dst32[i10 + 0] = src32[i10 + 0] ^ swap8IfBE(s02);
23762
+ dst32[i10 + 1] = src32[i10 + 1] ^ swap8IfBE(s12);
23763
+ dst32[i10 + 2] = src32[i10 + 2] ^ swap8IfBE(s22);
23764
+ dst32[i10 + 3] = src32[i10 + 3] ^ swap8IfBE(s32);
23765
+ ctrNum = ctrNum + 1 >>> 0;
23766
+ view.setUint32(ctrPos, ctrNum, isLE2);
23767
+ }
23768
+ const start = BLOCK_SIZE * Math.floor(src32.length / BLOCK_SIZE32);
23769
+ if (start < srcLen) {
23770
+ const { s0: s02, s1: s12, s2: s22, s3: s32 } = encrypt(xk, swap8IfBE(c32[0]), swap8IfBE(c32[1]), swap8IfBE(c32[2]), swap8IfBE(c32[3]));
23771
+ const b32 = new Uint32Array([s02, s12, s22, s32]);
23772
+ swap32IfBE(b32);
23773
+ const buf = u8$1(b32);
23774
+ for (let i10 = start, pos = 0; i10 < srcLen; i10++, pos++)
23775
+ dst[i10] = src[i10] ^ buf[pos];
23776
+ clean(b32);
23777
+ }
23778
+ return dst;
23779
+ }
23780
+ function isBytes32(a) {
23781
+ return a instanceof Uint32Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint32Array";
23782
+ }
23783
+ function encryptBlock(xk, block) {
23784
+ abytes(block, 16, "block");
23785
+ if (!isBytes32(xk))
23786
+ throw new Error("_encryptBlock accepts result of expandKeyLE");
23787
+ const b32 = u32(block);
23788
+ swap32IfBE(b32);
23789
+ let { s0: s02, s1: s12, s2: s22, s3: s32 } = encrypt(xk, b32[0], b32[1], b32[2], b32[3]);
23790
+ b32[0] = s02, b32[1] = s12, b32[2] = s22, b32[3] = s32;
23791
+ swap32IfBE(b32);
23792
+ return block;
23793
+ }
23794
+ function decryptBlock(xk, block) {
23795
+ abytes(block, 16, "block");
23796
+ if (!isBytes32(xk))
23797
+ throw new Error("_decryptBlock accepts result of expandKeyLE");
23798
+ const b32 = u32(block);
23799
+ swap32IfBE(b32);
23800
+ let { s0: s02, s1: s12, s2: s22, s3: s32 } = decrypt(xk, b32[0], b32[1], b32[2], b32[3]);
23801
+ b32[0] = s02, b32[1] = s12, b32[2] = s22, b32[3] = s32;
23802
+ swap32IfBE(b32);
23803
+ return block;
23804
+ }
23805
+ function dbl(block) {
23806
+ let carry = 0;
23807
+ for (let i10 = BLOCK_SIZE - 1; i10 >= 0; i10--) {
23808
+ const newCarry = (block[i10] & 128) >>> 7;
23809
+ block[i10] = block[i10] << 1 | carry;
23810
+ carry = newCarry;
23811
+ }
23812
+ block[BLOCK_SIZE - 1] ^= 135 & -carry;
23813
+ return block;
23814
+ }
23815
+ function xorBlock(a, b) {
23816
+ if (a.length !== b.length)
23817
+ throw new Error("xorBlock: blocks must have same length");
23818
+ for (let i10 = 0; i10 < a.length; i10++) {
23819
+ a[i10] = a[i10] ^ b[i10];
23820
+ }
23821
+ return a;
23822
+ }
23823
+ function xorend(a, b) {
23824
+ if (b.length > a.length) {
23825
+ throw new Error("xorend: expected len(B) <= len(A)");
23826
+ }
23827
+ const offset2 = a.length - b.length;
23828
+ for (let i10 = 0; i10 < b.length; i10++) {
23829
+ a[offset2 + i10] = a[offset2 + i10] ^ b[i10];
23830
+ }
23831
+ return a;
23832
+ }
23833
+ class _CMAC {
23834
+ constructor(key) {
23835
+ __publicField(this, "blockLen", BLOCK_SIZE);
23836
+ __publicField(this, "outputLen", BLOCK_SIZE);
23837
+ // CMAC can only decide between `K1` and `K2` once the true final block is known,
23838
+ // so updates process older blocks eagerly but keep one pending block buffered.
23839
+ __publicField(this, "buffer");
23840
+ __publicField(this, "pos");
23841
+ __publicField(this, "finished");
23842
+ __publicField(this, "destroyed");
23843
+ __publicField(this, "k1");
23844
+ __publicField(this, "k2");
23845
+ __publicField(this, "x");
23846
+ __publicField(this, "x32");
23847
+ __publicField(this, "xk");
23848
+ abytes(key);
23849
+ validateKeyLength(key);
23850
+ this.xk = expandKeyLE(key);
23851
+ this.buffer = new Uint8Array(BLOCK_SIZE);
23852
+ this.pos = 0;
23853
+ this.finished = false;
23854
+ this.destroyed = false;
23855
+ this.x = new Uint8Array(BLOCK_SIZE);
23856
+ this.x32 = u32(this.x);
23857
+ const L = new Uint8Array(BLOCK_SIZE);
23858
+ encryptBlock(this.xk, L);
23859
+ this.k1 = dbl(L);
23860
+ this.k2 = dbl(new Uint8Array(this.k1));
23861
+ }
23862
+ // Consumes 16 bytes of `data` starting at `pos`; `pos` avoids a per-block
23863
+ // subarray view allocation in update().
23864
+ process(data2, pos) {
23865
+ const { x, x32, xk } = this;
23866
+ for (let i10 = 0; i10 < BLOCK_SIZE; i10++)
23867
+ x[i10] ^= data2[pos + i10];
23868
+ swap32IfBE(x32);
23869
+ const { s0: s02, s1: s12, s2: s22, s3: s32 } = encrypt(xk, x32[0], x32[1], x32[2], x32[3]);
23870
+ x32[0] = s02, x32[1] = s12, x32[2] = s22, x32[3] = s32;
23871
+ swap32IfBE(x32);
23872
+ }
23873
+ update(data2) {
23874
+ aexists(this);
23875
+ abytes(data2);
23876
+ let pos = 0;
23877
+ if (this.pos) {
23878
+ const take = Math.min(BLOCK_SIZE - this.pos, data2.length);
23879
+ this.buffer.set(data2.subarray(0, take), this.pos);
23880
+ this.pos += take;
23881
+ pos = take;
23882
+ if (this.pos === BLOCK_SIZE && pos < data2.length) {
23883
+ this.process(this.buffer, 0);
23884
+ this.pos = 0;
23885
+ }
23886
+ }
23887
+ while (pos + BLOCK_SIZE < data2.length) {
23888
+ this.process(data2, pos);
23889
+ pos += BLOCK_SIZE;
23890
+ }
23891
+ if (pos < data2.length) {
23892
+ this.buffer.set(data2.subarray(pos), 0);
23893
+ this.pos = data2.length - pos;
23894
+ }
23895
+ return this;
23896
+ }
23897
+ // See {@link https://www.rfc-editor.org/rfc/rfc4493.html#section-2.4 | RFC 4493 Section 2.4}.
23898
+ digestInto(out) {
23899
+ aexists(this);
23900
+ aoutput32(out, this);
23901
+ this.finished = true;
23902
+ const view = out.subarray(0, this.outputLen);
23903
+ let last = new Uint8Array(BLOCK_SIZE);
23904
+ if (this.pos === BLOCK_SIZE) {
23905
+ last.set(this.buffer);
23906
+ xorBlock(last, this.k1);
23907
+ } else {
23908
+ last.set(this.buffer.subarray(0, this.pos));
23909
+ last[this.pos] = 128;
23910
+ xorBlock(last, this.k2);
23911
+ }
23912
+ view.set(this.x);
23913
+ xorBlock(view, last);
23914
+ encryptBlock(this.xk, view);
23915
+ clean(last);
23916
+ }
23917
+ digest() {
23918
+ const { buffer: buffer2, outputLen } = this;
23919
+ this.digestInto(buffer2);
23920
+ const res = buffer2.slice(0, outputLen);
23921
+ this.destroy();
23922
+ return res;
23923
+ }
23924
+ destroy() {
23925
+ const { buffer: buffer2, destroyed, x, xk, k1: k12, k2: k22 } = this;
23926
+ if (destroyed)
23927
+ return;
23928
+ this.destroyed = true;
23929
+ clean(buffer2, x, xk, k12, k22);
23930
+ }
23931
+ }
23932
+ const cmac = /* @__PURE__ */ wrapMacConstructor(16, (key) => new _CMAC(key));
23933
+ function s2v(key, strings2) {
23934
+ validateKeyLength(key);
23935
+ const len2 = strings2.length;
23936
+ if (len2 > 127) {
23937
+ throw new Error("s2v: expected <= 127 inputs");
23938
+ }
23939
+ if (len2 === 0)
23940
+ return cmac(ONE_BLOCK, key);
23941
+ let d = cmac(EMPTY_BLOCK, key);
23942
+ for (let i10 = 0; i10 < len2 - 1; i10++) {
23943
+ dbl(d);
23944
+ const cmacResult = cmac(strings2[i10], key);
23945
+ xorBlock(d, cmacResult);
23946
+ clean(cmacResult);
23947
+ }
23948
+ const s_n = strings2[len2 - 1];
23949
+ abytes(s_n);
23950
+ let t10;
23951
+ if (s_n.byteLength >= BLOCK_SIZE) {
23952
+ t10 = xorend(Uint8Array.from(s_n), d);
23953
+ } else {
23954
+ const paddedSn = new Uint8Array(BLOCK_SIZE);
23955
+ paddedSn.set(s_n);
23956
+ paddedSn[s_n.length] = 128;
23957
+ t10 = xorBlock(dbl(d), paddedSn);
23958
+ clean(paddedSn);
23959
+ }
23960
+ const result = cmac(t10, key);
23961
+ clean(d, t10);
23962
+ return result;
23963
+ }
23964
+ const unsafe = /* @__PURE__ */ Object.freeze({
23965
+ expandKeyLE,
23966
+ expandKeyDecLE,
23967
+ encrypt,
23968
+ decrypt,
23969
+ encryptBlock,
23970
+ decryptBlock,
23971
+ ctrCounter,
23972
+ ctr32,
23973
+ dbl,
23974
+ xorBlock,
23975
+ xorend,
23976
+ s2v
23977
+ });
23978
+ const CIPHERS = /^aes-(128|192|256)-(gcm|cbc|ctr|ecb)$/u;
23979
+ function cipherNames() {
23980
+ const names2 = [];
23981
+ for (const bits of [128, 192, 256]) for (const mode of ["cbc", "ctr", "ecb", "gcm"]) names2.push(`aes-${bits}-${mode}`);
23982
+ return names2;
23983
+ }
23984
+ const GCM_TAG_LENGTHS = /* @__PURE__ */ new Set([4, 8, 12, 13, 14, 15, 16]);
23985
+ function createCipherClasses(deps) {
23986
+ var _decrypt, _mode, _xk, _xkDec, _padding, _finished, _started, _pending, _chain, _counter, _keystream, _ghash, _tagMask, _ghashPending, _aadLength, _dataLength, _authTagLength, _authTag, _CipherBase_instances, getTag_fn, setTag_fn, process_fn, stream_fn, absorb_fn, blocks_fn, block_fn, finish_fn, finishGcm_fn;
23987
+ const { error } = deps;
23988
+ function parse4(algorithm) {
23989
+ if (typeof algorithm !== "string") throw Object.assign(new TypeError('The "cipher" argument must be of type string.'), { code: "ERR_INVALID_ARG_TYPE" });
23990
+ const match2 = CIPHERS.exec(algorithm.toLowerCase());
23991
+ if (!match2) throw error("ERR_CRYPTO_UNKNOWN_CIPHER", "Unknown cipher");
23992
+ return { keyLength: Number(match2[1]) / 8, mode: match2[2] };
23993
+ }
23994
+ function keyOf(key, keyLength) {
23995
+ const bytes2 = deps.secretKeyBytes(key) ?? deps.bytesOf(key);
23996
+ if (bytes2.length !== keyLength) throw Object.assign(new RangeError("Invalid key length"), { code: "ERR_CRYPTO_INVALID_KEYLEN" });
23997
+ return new Uint8Array(bytes2);
23998
+ }
23999
+ function ivOf(iv2, mode) {
24000
+ if (mode === "ecb") {
24001
+ if (iv2 === null || iv2 === void 0) return void 0;
24002
+ const bytes22 = deps.bytesOf(iv2);
24003
+ if (bytes22.length !== 0) throw Object.assign(new TypeError("Invalid initialization vector"), { code: "ERR_CRYPTO_INVALID_IV" });
24004
+ return void 0;
24005
+ }
24006
+ if (iv2 === null || iv2 === void 0) throw Object.assign(new TypeError("Invalid initialization vector"), { code: "ERR_CRYPTO_INVALID_IV" });
24007
+ const bytes2 = new Uint8Array(deps.bytesOf(iv2));
24008
+ if (mode === "gcm" ? bytes2.length === 0 : bytes2.length !== 16) throw Object.assign(new TypeError("Invalid initialization vector"), { code: "ERR_CRYPTO_INVALID_IV" });
24009
+ return bytes2;
24010
+ }
24011
+ function encryptBlock2(xk, block) {
24012
+ const out = new Uint8Array(16);
24013
+ out.set(block);
24014
+ return unsafe.encryptBlock(xk, out);
24015
+ }
24016
+ function decryptBlock2(xk, block) {
24017
+ const out = new Uint8Array(16);
24018
+ out.set(block);
24019
+ return unsafe.decryptBlock(xk, out);
24020
+ }
24021
+ function concat(a, b) {
24022
+ if (a.length === 0) return b;
24023
+ if (b.length === 0) return a;
24024
+ const out = new Uint8Array(a.length + b.length);
24025
+ out.set(a);
24026
+ out.set(b, a.length);
24027
+ return out;
24028
+ }
24029
+ function increment(counter, from) {
24030
+ for (let i10 = 15; i10 >= from; i10--) {
24031
+ counter[i10] = counter[i10] + 1 & 255;
24032
+ if (counter[i10] !== 0) return;
24033
+ }
24034
+ }
24035
+ let authTagOf;
24036
+ let expectTagOf;
24037
+ class CipherBase {
24038
+ constructor(decrypt2, algorithm, key, iv2, options) {
24039
+ __privateAdd(this, _CipherBase_instances);
24040
+ __privateAdd(this, _decrypt);
24041
+ __privateAdd(this, _mode);
24042
+ __privateAdd(this, _xk);
24043
+ __privateAdd(this, _xkDec);
24044
+ __privateAdd(this, _padding, true);
24045
+ __privateAdd(this, _finished, false);
24046
+ __privateAdd(this, _started, false);
24047
+ /** CBC/ECB: bytes not yet a whole block (and, decrypting with padding, the last whole block). */
24048
+ __privateAdd(this, _pending, new Uint8Array(0));
24049
+ /** CBC's chaining block. */
24050
+ __privateAdd(this, _chain);
24051
+ /** CTR/GCM: the next counter block and what is left of the current keystream block. */
24052
+ __privateAdd(this, _counter);
24053
+ __privateAdd(this, _keystream, new Uint8Array(0));
24054
+ /** GCM. */
24055
+ __privateAdd(this, _ghash);
24056
+ __privateAdd(this, _tagMask);
24057
+ __privateAdd(this, _ghashPending, new Uint8Array(0));
24058
+ __privateAdd(this, _aadLength, 0);
24059
+ __privateAdd(this, _dataLength, 0);
24060
+ __privateAdd(this, _authTagLength);
24061
+ __privateAdd(this, _authTag);
24062
+ const { keyLength, mode } = parse4(algorithm);
24063
+ __privateSet(this, _decrypt, decrypt2);
24064
+ __privateSet(this, _mode, mode);
24065
+ const keyBytes = keyOf(key, keyLength);
24066
+ const ivBytes = ivOf(iv2, mode);
24067
+ __privateSet(this, _xk, unsafe.expandKeyLE(keyBytes));
24068
+ __privateSet(this, _xkDec, decrypt2 && (mode === "cbc" || mode === "ecb") ? unsafe.expandKeyDecLE(keyBytes) : void 0);
24069
+ const tagLength = options == null ? void 0 : options.authTagLength;
24070
+ if (tagLength !== void 0) {
24071
+ if (mode !== "gcm") throw Object.assign(new TypeError(`Invalid authentication tag length: ${tagLength}`), { code: "ERR_CRYPTO_INVALID_AUTH_TAG" });
24072
+ if (!GCM_TAG_LENGTHS.has(tagLength)) throw Object.assign(new TypeError(`Invalid authentication tag length: ${tagLength}`), { code: "ERR_CRYPTO_INVALID_AUTH_TAG" });
24073
+ __privateSet(this, _authTagLength, tagLength);
24074
+ }
24075
+ if (mode === "cbc") __privateSet(this, _chain, ivBytes);
24076
+ if (mode === "ctr") __privateSet(this, _counter, new Uint8Array(ivBytes));
24077
+ if (mode === "gcm") {
24078
+ const h = encryptBlock2(__privateGet(this, _xk), new Uint8Array(16));
24079
+ let j02;
24080
+ if (ivBytes.length === 12) {
24081
+ j02 = new Uint8Array(16);
24082
+ j02.set(ivBytes);
24083
+ j02[15] = 1;
24084
+ } else {
24085
+ const lengths = new Uint8Array(16);
24086
+ new DataView(lengths.buffer).setBigUint64(8, BigInt(ivBytes.length * 8), false);
24087
+ const g = new GHASH(h);
24088
+ g.update(ivBytes).update(lengths);
24089
+ j02 = g.digest();
24090
+ }
24091
+ __privateSet(this, _tagMask, encryptBlock2(__privateGet(this, _xk), j02));
24092
+ __privateSet(this, _counter, new Uint8Array(j02));
24093
+ increment(__privateGet(this, _counter), 12);
24094
+ __privateSet(this, _ghash, new GHASH(h));
24095
+ }
24096
+ }
24097
+ setAutoPadding(autoPadding = true) {
24098
+ if (__privateGet(this, _finished)) throw error("ERR_CRYPTO_INVALID_STATE", "Invalid state for operation setAutoPadding");
24099
+ __privateSet(this, _padding, Boolean(autoPadding));
24100
+ return this;
24101
+ }
24102
+ setAAD(buffer2, _options3) {
24103
+ if (__privateGet(this, _mode) !== "gcm" || __privateGet(this, _started) || __privateGet(this, _finished)) throw error("ERR_CRYPTO_INVALID_STATE", "Invalid state for operation setAAD");
24104
+ const aad = deps.bytesOf(buffer2);
24105
+ __privateGet(this, _ghash).update(aad);
24106
+ __privateSet(this, _aadLength, __privateGet(this, _aadLength) + aad.length);
24107
+ return this;
24108
+ }
24109
+ update(data2, inputEncoding, outputEncoding) {
24110
+ if (__privateGet(this, _finished)) throw error("ERR_CRYPTO_INVALID_STATE", "Invalid state for operation update");
24111
+ __privateSet(this, _started, true);
24112
+ const input = typeof data2 === "string" ? deps.bytesOf(data2, inputEncoding) : deps.bytesOf(data2);
24113
+ return deps.encode(__privateMethod(this, _CipherBase_instances, process_fn).call(this, new Uint8Array(input)), outputEncoding);
24114
+ }
24115
+ final(outputEncoding) {
24116
+ if (__privateGet(this, _finished)) throw error("ERR_CRYPTO_INVALID_STATE", "Unsupported state");
24117
+ __privateSet(this, _finished, true);
24118
+ return deps.encode(__privateMethod(this, _CipherBase_instances, finish_fn).call(this), outputEncoding);
24119
+ }
24120
+ }
24121
+ _decrypt = new WeakMap();
24122
+ _mode = new WeakMap();
24123
+ _xk = new WeakMap();
24124
+ _xkDec = new WeakMap();
24125
+ _padding = new WeakMap();
24126
+ _finished = new WeakMap();
24127
+ _started = new WeakMap();
24128
+ _pending = new WeakMap();
24129
+ _chain = new WeakMap();
24130
+ _counter = new WeakMap();
24131
+ _keystream = new WeakMap();
24132
+ _ghash = new WeakMap();
24133
+ _tagMask = new WeakMap();
24134
+ _ghashPending = new WeakMap();
24135
+ _aadLength = new WeakMap();
24136
+ _dataLength = new WeakMap();
24137
+ _authTagLength = new WeakMap();
24138
+ _authTag = new WeakMap();
24139
+ _CipherBase_instances = new WeakSet();
24140
+ getTag_fn = function() {
24141
+ if (__privateGet(this, _mode) !== "gcm" || __privateGet(this, _decrypt) || !__privateGet(this, _finished) || !__privateGet(this, _authTag)) throw error("ERR_CRYPTO_INVALID_STATE", "Invalid state for operation getAuthTag");
24142
+ return __privateGet(this, _authTag);
24143
+ };
24144
+ setTag_fn = function(tag, encoding) {
24145
+ if (__privateGet(this, _mode) !== "gcm" || !__privateGet(this, _decrypt) || __privateGet(this, _finished)) throw error("ERR_CRYPTO_INVALID_STATE", "Invalid state for operation setAuthTag");
24146
+ const bytes2 = new Uint8Array(typeof tag === "string" ? deps.bytesOf(tag, encoding) : deps.bytesOf(tag));
24147
+ const allowed = __privateGet(this, _authTagLength) === void 0 ? GCM_TAG_LENGTHS.has(bytes2.length) : bytes2.length === __privateGet(this, _authTagLength);
24148
+ if (!allowed) throw Object.assign(new TypeError(`Invalid authentication tag length: ${bytes2.length}`), { code: "ERR_CRYPTO_INVALID_AUTH_TAG" });
24149
+ __privateSet(this, _authTag, bytes2);
24150
+ };
24151
+ process_fn = function(input) {
24152
+ switch (__privateGet(this, _mode)) {
24153
+ case "ctr":
24154
+ return __privateMethod(this, _CipherBase_instances, stream_fn).call(this, input);
24155
+ case "gcm": {
24156
+ if (__privateGet(this, _decrypt)) __privateMethod(this, _CipherBase_instances, absorb_fn).call(this, input);
24157
+ const out = __privateMethod(this, _CipherBase_instances, stream_fn).call(this, input);
24158
+ if (!__privateGet(this, _decrypt)) __privateMethod(this, _CipherBase_instances, absorb_fn).call(this, out);
24159
+ __privateSet(this, _dataLength, __privateGet(this, _dataLength) + input.length);
24160
+ return out;
24161
+ }
24162
+ default:
24163
+ return __privateMethod(this, _CipherBase_instances, blocks_fn).call(this, input);
24164
+ }
24165
+ };
24166
+ /** XOR with the counter's keystream, carrying a partial block across calls. */
24167
+ stream_fn = function(input) {
24168
+ const out = new Uint8Array(input.length);
24169
+ let at3 = 0;
24170
+ while (at3 < input.length) {
24171
+ if (__privateGet(this, _keystream).length === 0) {
24172
+ __privateSet(this, _keystream, encryptBlock2(__privateGet(this, _xk), __privateGet(this, _counter)));
24173
+ increment(__privateGet(this, _counter), __privateGet(this, _mode) === "gcm" ? 12 : 0);
24174
+ }
24175
+ const take = Math.min(__privateGet(this, _keystream).length, input.length - at3);
24176
+ for (let i10 = 0; i10 < take; i10++) out[at3 + i10] = input[at3 + i10] ^ __privateGet(this, _keystream)[i10];
24177
+ __privateSet(this, _keystream, __privateGet(this, _keystream).subarray(take));
24178
+ at3 += take;
24179
+ }
24180
+ return out;
24181
+ };
24182
+ /** GHASH over the ciphertext, in whole blocks: GHASH pads each update, so a partial block waits for the next. */
24183
+ absorb_fn = function(ciphertext) {
24184
+ const all = concat(__privateGet(this, _ghashPending), ciphertext);
24185
+ const whole = all.length - all.length % 16;
24186
+ if (whole > 0) __privateGet(this, _ghash).update(all.subarray(0, whole));
24187
+ __privateSet(this, _ghashPending, all.slice(whole));
24188
+ };
24189
+ /** CBC and ECB: every whole block now; decrypting with padding, the last whole block waits for `final`. */
24190
+ blocks_fn = function(input) {
24191
+ const all = concat(__privateGet(this, _pending), input);
24192
+ let whole = all.length - all.length % 16;
24193
+ if (__privateGet(this, _decrypt) && __privateGet(this, _padding) && whole === all.length && whole > 0) whole -= 16;
24194
+ const out = new Uint8Array(whole);
24195
+ for (let at3 = 0; at3 < whole; at3 += 16) out.set(__privateMethod(this, _CipherBase_instances, block_fn).call(this, all.subarray(at3, at3 + 16)), at3);
24196
+ __privateSet(this, _pending, all.slice(whole));
24197
+ return out;
24198
+ };
24199
+ block_fn = function(block) {
24200
+ if (__privateGet(this, _mode) === "ecb") return __privateGet(this, _decrypt) ? decryptBlock2(__privateGet(this, _xkDec), block) : encryptBlock2(__privateGet(this, _xk), block);
24201
+ if (__privateGet(this, _decrypt)) {
24202
+ const plain = decryptBlock2(__privateGet(this, _xkDec), block);
24203
+ for (let i10 = 0; i10 < 16; i10++) plain[i10] = plain[i10] ^ __privateGet(this, _chain)[i10];
24204
+ __privateSet(this, _chain, new Uint8Array(block));
24205
+ return plain;
24206
+ }
24207
+ const mixed = new Uint8Array(16);
24208
+ for (let i10 = 0; i10 < 16; i10++) mixed[i10] = block[i10] ^ __privateGet(this, _chain)[i10];
24209
+ const cipher = encryptBlock2(__privateGet(this, _xk), mixed);
24210
+ __privateSet(this, _chain, cipher);
24211
+ return cipher;
24212
+ };
24213
+ finish_fn = function() {
24214
+ if (__privateGet(this, _mode) === "ctr") return new Uint8Array(0);
24215
+ if (__privateGet(this, _mode) === "gcm") return __privateMethod(this, _CipherBase_instances, finishGcm_fn).call(this);
24216
+ const rest = __privateGet(this, _pending);
24217
+ __privateSet(this, _pending, new Uint8Array(0));
24218
+ if (!__privateGet(this, _decrypt)) {
24219
+ if (!__privateGet(this, _padding)) {
24220
+ if (rest.length !== 0) throw error("ERR_OSSL_WRONG_FINAL_BLOCK_LENGTH", "error:1C80006B:Provider routines::wrong final block length");
24221
+ return rest;
24222
+ }
24223
+ const pad2 = 16 - rest.length;
24224
+ const block = new Uint8Array(16);
24225
+ block.set(rest);
24226
+ block.fill(pad2, rest.length);
24227
+ return __privateMethod(this, _CipherBase_instances, block_fn).call(this, block);
24228
+ }
24229
+ if (!__privateGet(this, _padding)) {
24230
+ if (rest.length !== 0) throw error("ERR_OSSL_WRONG_FINAL_BLOCK_LENGTH", "error:1C80006B:Provider routines::wrong final block length");
24231
+ return rest;
24232
+ }
24233
+ if (rest.length !== 16) throw error("ERR_OSSL_WRONG_FINAL_BLOCK_LENGTH", "error:1C80006B:Provider routines::wrong final block length");
24234
+ const plain = __privateMethod(this, _CipherBase_instances, block_fn).call(this, rest);
24235
+ const pad = plain[15];
24236
+ let valid = pad >= 1 && pad <= 16;
24237
+ for (let i10 = 16 - pad; valid && i10 < 16; i10++) valid = plain[i10] === pad;
24238
+ if (!valid) throw error("ERR_OSSL_BAD_DECRYPT", "error:1C800064:Provider routines::bad decrypt");
24239
+ return plain.slice(0, 16 - pad);
24240
+ };
24241
+ finishGcm_fn = function() {
24242
+ if (__privateGet(this, _ghashPending).length) __privateGet(this, _ghash).update(__privateGet(this, _ghashPending));
24243
+ const lengths = new Uint8Array(16);
24244
+ const view = new DataView(lengths.buffer);
24245
+ view.setBigUint64(0, BigInt(__privateGet(this, _aadLength) * 8), false);
24246
+ view.setBigUint64(8, BigInt(__privateGet(this, _dataLength) * 8), false);
24247
+ const full = __privateGet(this, _ghash).update(lengths).digest();
24248
+ for (let i10 = 0; i10 < 16; i10++) full[i10] = full[i10] ^ __privateGet(this, _tagMask)[i10];
24249
+ if (!__privateGet(this, _decrypt)) {
24250
+ __privateSet(this, _authTag, full.slice(0, __privateGet(this, _authTagLength) ?? 16));
24251
+ return new Uint8Array(0);
24252
+ }
24253
+ const expected = __privateGet(this, _authTag);
24254
+ let same = expected !== void 0;
24255
+ if (expected) for (let i10 = 0; i10 < expected.length; i10++) same = same && full[i10] === expected[i10];
24256
+ if (!same) throw new Error("Unsupported state or unable to authenticate data");
24257
+ return new Uint8Array(0);
24258
+ };
24259
+ authTagOf = (cipher) => {
24260
+ var _a3;
24261
+ return __privateMethod(_a3 = cipher, _CipherBase_instances, getTag_fn).call(_a3);
24262
+ };
24263
+ expectTagOf = (cipher, tag, encoding) => {
24264
+ var _a3;
24265
+ return __privateMethod(_a3 = cipher, _CipherBase_instances, setTag_fn).call(_a3, tag, encoding);
24266
+ };
24267
+ class Cipheriv2 extends CipherBase {
24268
+ constructor(algorithm, key, iv2, options) {
24269
+ super(false, algorithm, key, iv2, options);
24270
+ }
24271
+ getAuthTag() {
24272
+ return deps.toBuffer(authTagOf(this));
24273
+ }
24274
+ }
24275
+ class Decipheriv2 extends CipherBase {
24276
+ constructor(algorithm, key, iv2, options) {
24277
+ super(true, algorithm, key, iv2, options);
24278
+ }
24279
+ setAuthTag(tag, encoding) {
24280
+ expectTagOf(this, tag, encoding);
24281
+ return this;
24282
+ }
24283
+ }
24284
+ return {
24285
+ Cipheriv: Cipheriv2,
24286
+ Decipheriv: Decipheriv2,
24287
+ createCipheriv: (algorithm, key, iv2, options) => new Cipheriv2(algorithm, key, iv2, options),
24288
+ createDecipheriv: (algorithm, key, iv2, options) => new Decipheriv2(algorithm, key, iv2, options)
24289
+ };
24290
+ }
23304
24291
  function createCryptoModule(require2) {
23305
24292
  var _state, _done, _inner, _outer, _done2, _algorithm, _data, _algorithm2, _data2, __keyData, __type, __algorithm;
23306
24293
  const bufferModule2 = require2 ? require2("buffer") : lazyModule("buffer");
@@ -23880,7 +24867,7 @@ ${body}
23880
24867
  return result === 0;
23881
24868
  }
23882
24869
  function getCiphers2() {
23883
- return ["aes-128-cbc", "aes-256-cbc", "aes-128-gcm", "aes-256-gcm"];
24870
+ return cipherNames();
23884
24871
  }
23885
24872
  function getHashes2() {
23886
24873
  return HASH_ALGORITHMS.slice();
@@ -24001,7 +24988,25 @@ ${body}
24001
24988
  }
24002
24989
  throw new Error(`Unsupported key format: ${keyInfo.format}`);
24003
24990
  }
24991
+ const { Cipheriv: Cipheriv2, Decipheriv: Decipheriv2, createCipheriv: createCipheriv2, createDecipheriv: createDecipheriv2 } = createCipherClasses({
24992
+ toBuffer: (bytes2) => Buffer2.from(bytes2),
24993
+ bytesOf: (value, encoding) => cryptoBytes(value, encoding, true),
24994
+ secretKeyBytes: (value) => {
24995
+ if (!(value instanceof KeyObject2)) return void 0;
24996
+ const info = keyInfoOf(value);
24997
+ if (info.type !== "secret" || !(info.keyData instanceof Uint8Array)) {
24998
+ throw Object.assign(new TypeError(`Invalid key object type ${info.type}, expected secret.`), { code: "ERR_CRYPTO_INVALID_KEY_OBJECT_TYPE" });
24999
+ }
25000
+ return info.keyData;
25001
+ },
25002
+ encode: (bytes2, encoding) => digestResult(bytes2, encoding),
25003
+ error: cryptoError
25004
+ });
24004
25005
  return {
25006
+ Cipheriv: Cipheriv2,
25007
+ Decipheriv: Decipheriv2,
25008
+ createCipheriv: createCipheriv2,
25009
+ createDecipheriv: createDecipheriv2,
24005
25010
  unsupported: unsupported2,
24006
25011
  randomBytes: randomBytes2,
24007
25012
  randomFill: randomFill2,
@@ -24030,12 +25035,16 @@ ${body}
24030
25035
  };
24031
25036
  }
24032
25037
  const cryptoModule = createCryptoModule();
24033
- const { randomBytes, randomFillSync, randomFill, randomUUID, randomInt, getRandomValues, unsupported, createHash, createHmac, hash, pbkdf2Sync, pbkdf2, sign, verify, createSign, createVerify, KeyObject, createSecretKey, createPublicKey, createPrivateKey, generateKeyPair, timingSafeEqual, getCiphers, getHashes } = cryptoModule;
25038
+ const { Cipheriv, Decipheriv, createCipheriv, createDecipheriv, randomBytes, randomFillSync, randomFill, randomUUID, randomInt, getRandomValues, unsupported, createHash, createHmac, hash, pbkdf2Sync, pbkdf2, sign, verify, createSign, createVerify, KeyObject, createSecretKey, createPublicKey, createPrivateKey, generateKeyPair, timingSafeEqual, getCiphers, getHashes } = cryptoModule;
24034
25039
  var cryptoShim = /* @__PURE__ */ Object.freeze({
24035
25040
  __proto__: null,
25041
+ Cipheriv,
25042
+ Decipheriv,
24036
25043
  KeyObject,
24037
25044
  constants: cryptoConstants,
25045
+ createCipheriv,
24038
25046
  createCryptoModule,
25047
+ createDecipheriv,
24039
25048
  createHash,
24040
25049
  createHmac,
24041
25050
  createPrivateKey,
@@ -32621,12 +33630,12 @@ class SHA2_32B extends HashMD {
32621
33630
  this.set(A10, B, C, D10, E7, F, G10, H);
32622
33631
  }
32623
33632
  roundClean() {
32624
- clean(SHA256_W);
33633
+ clean$1(SHA256_W);
32625
33634
  }
32626
33635
  destroy() {
32627
33636
  this.destroyed = true;
32628
33637
  this.set(0, 0, 0, 0, 0, 0, 0, 0);
32629
- clean(this.buffer);
33638
+ clean$1(this.buffer);
32630
33639
  }
32631
33640
  }
32632
33641
  class _SHA256 extends SHA2_32B {