@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.
package/dist/index.mjs CHANGED
@@ -18,8 +18,8 @@ var __privateWrapper = (obj, member, setter, getter) => ({
18
18
  }
19
19
  });
20
20
  var _a, _b, _asyncId, _triggerAsyncId, _c, _d, _e, _f, _g, _h, _i, _j, _ptr, _type, _maxHeaderSize, _headerBytes, _headers, _field, _value, _readingValue, _url, _statusMessage, _headersSent, _paused, _buffer, _bufferPtr, _bufferSize, _connections, _HTTPParser_instances, reset_fn, copyIn_fn, pushHeader_fn, countHeaderBytes_fn, _parsers, _strm, _writeState, _callback, _level, _strategy, _windowBits, _memLevel, _dictionary, _ended, _Zlib_instances, inflating_get, windowFor_fn, start_fn, fail_fn, report_fn, run_fn, end_fn, _writeState2, _callback2, _input, _output, _outputAt, _BrotliDecoderHandle_instances, run_fn2, _k, _resolveChain, _loadChain, _initializing, _initializeFailure, _RunModuleHooks_instances, run_fn3;
21
- import { u as uint8ToBase64, b as base64ToUint8, a as uint8ToBinaryString, c as uint8ToHex, P as PortBridge } from "./port-bridge-CixAESwA.js";
22
- import { g } from "./port-bridge-CixAESwA.js";
21
+ import { u as uint8ToBase64, b as base64ToUint8, a as uint8ToBinaryString, c as uint8ToHex, P as PortBridge } from "./port-bridge-Cergvxli.js";
22
+ import { g } from "./port-bridge-Cergvxli.js";
23
23
  import { defineCommand, Bash, getCommandNames } from "just-bash";
24
24
  import { imports, resolve as resolve$3 } from "resolve.exports";
25
25
  import { wrap, proxy } from "comlink";
@@ -19400,14 +19400,14 @@ var safeBuffer = { exports: {} };
19400
19400
  var buffer = {};
19401
19401
  var ieee754 = {};
19402
19402
  /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
19403
- ieee754.read = function(buffer2, offset2, isLE, mLen, nBytes) {
19403
+ ieee754.read = function(buffer2, offset2, isLE2, mLen, nBytes) {
19404
19404
  var e, m;
19405
19405
  var eLen = nBytes * 8 - mLen - 1;
19406
19406
  var eMax = (1 << eLen) - 1;
19407
19407
  var eBias = eMax >> 1;
19408
19408
  var nBits = -7;
19409
- var i2 = isLE ? nBytes - 1 : 0;
19410
- var d = isLE ? -1 : 1;
19409
+ var i2 = isLE2 ? nBytes - 1 : 0;
19410
+ var d = isLE2 ? -1 : 1;
19411
19411
  var s = buffer2[offset2 + i2];
19412
19412
  i2 += d;
19413
19413
  e = s & (1 << -nBits) - 1;
@@ -19430,14 +19430,14 @@ ieee754.read = function(buffer2, offset2, isLE, mLen, nBytes) {
19430
19430
  }
19431
19431
  return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
19432
19432
  };
19433
- ieee754.write = function(buffer2, value, offset2, isLE, mLen, nBytes) {
19433
+ ieee754.write = function(buffer2, value, offset2, isLE2, mLen, nBytes) {
19434
19434
  var e, m, c;
19435
19435
  var eLen = nBytes * 8 - mLen - 1;
19436
19436
  var eMax = (1 << eLen) - 1;
19437
19437
  var eBias = eMax >> 1;
19438
19438
  var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
19439
- var i2 = isLE ? 0 : nBytes - 1;
19440
- var d = isLE ? 1 : -1;
19439
+ var i2 = isLE2 ? 0 : nBytes - 1;
19440
+ var d = isLE2 ? 1 : -1;
19441
19441
  var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
19442
19442
  value = Math.abs(value);
19443
19443
  if (isNaN(value) || value === Infinity) {
@@ -20328,10 +20328,10 @@ ieee754.write = function(buffer2, value, offset2, isLE, mLen, nBytes) {
20328
20328
  byteLength3 = byteLength3 >>> 0;
20329
20329
  if (!noAssert) checkOffset(offset2, byteLength3, this.length);
20330
20330
  let val = this[offset2];
20331
- let mul = 1;
20331
+ let mul3 = 1;
20332
20332
  let i2 = 0;
20333
- while (++i2 < byteLength3 && (mul *= 256)) {
20334
- val += this[offset2 + i2] * mul;
20333
+ while (++i2 < byteLength3 && (mul3 *= 256)) {
20334
+ val += this[offset2 + i2] * mul3;
20335
20335
  }
20336
20336
  return val;
20337
20337
  };
@@ -20342,9 +20342,9 @@ ieee754.write = function(buffer2, value, offset2, isLE, mLen, nBytes) {
20342
20342
  checkOffset(offset2, byteLength3, this.length);
20343
20343
  }
20344
20344
  let val = this[offset2 + --byteLength3];
20345
- let mul = 1;
20346
- while (byteLength3 > 0 && (mul *= 256)) {
20347
- val += this[offset2 + --byteLength3] * mul;
20345
+ let mul3 = 1;
20346
+ while (byteLength3 > 0 && (mul3 *= 256)) {
20347
+ val += this[offset2 + --byteLength3] * mul3;
20348
20348
  }
20349
20349
  return val;
20350
20350
  };
@@ -20402,13 +20402,13 @@ ieee754.write = function(buffer2, value, offset2, isLE, mLen, nBytes) {
20402
20402
  byteLength3 = byteLength3 >>> 0;
20403
20403
  if (!noAssert) checkOffset(offset2, byteLength3, this.length);
20404
20404
  let val = this[offset2];
20405
- let mul = 1;
20405
+ let mul3 = 1;
20406
20406
  let i2 = 0;
20407
- while (++i2 < byteLength3 && (mul *= 256)) {
20408
- val += this[offset2 + i2] * mul;
20407
+ while (++i2 < byteLength3 && (mul3 *= 256)) {
20408
+ val += this[offset2 + i2] * mul3;
20409
20409
  }
20410
- mul *= 128;
20411
- if (val >= mul) val -= Math.pow(2, 8 * byteLength3);
20410
+ mul3 *= 128;
20411
+ if (val >= mul3) val -= Math.pow(2, 8 * byteLength3);
20412
20412
  return val;
20413
20413
  };
20414
20414
  Buffer2.prototype.readIntBE = function readIntBE(offset2, byteLength3, noAssert) {
@@ -20416,13 +20416,13 @@ ieee754.write = function(buffer2, value, offset2, isLE, mLen, nBytes) {
20416
20416
  byteLength3 = byteLength3 >>> 0;
20417
20417
  if (!noAssert) checkOffset(offset2, byteLength3, this.length);
20418
20418
  let i2 = byteLength3;
20419
- let mul = 1;
20419
+ let mul3 = 1;
20420
20420
  let val = this[offset2 + --i2];
20421
- while (i2 > 0 && (mul *= 256)) {
20422
- val += this[offset2 + --i2] * mul;
20421
+ while (i2 > 0 && (mul3 *= 256)) {
20422
+ val += this[offset2 + --i2] * mul3;
20423
20423
  }
20424
- mul *= 128;
20425
- if (val >= mul) val -= Math.pow(2, 8 * byteLength3);
20424
+ mul3 *= 128;
20425
+ if (val >= mul3) val -= Math.pow(2, 8 * byteLength3);
20426
20426
  return val;
20427
20427
  };
20428
20428
  Buffer2.prototype.readInt8 = function readInt8(offset2, noAssert) {
@@ -20509,11 +20509,11 @@ ieee754.write = function(buffer2, value, offset2, isLE, mLen, nBytes) {
20509
20509
  const maxBytes = Math.pow(2, 8 * byteLength3) - 1;
20510
20510
  checkInt(this, value, offset2, byteLength3, maxBytes, 0);
20511
20511
  }
20512
- let mul = 1;
20512
+ let mul3 = 1;
20513
20513
  let i2 = 0;
20514
20514
  this[offset2] = value & 255;
20515
- while (++i2 < byteLength3 && (mul *= 256)) {
20516
- this[offset2 + i2] = value / mul & 255;
20515
+ while (++i2 < byteLength3 && (mul3 *= 256)) {
20516
+ this[offset2 + i2] = value / mul3 & 255;
20517
20517
  }
20518
20518
  return offset2 + byteLength3;
20519
20519
  };
@@ -20526,10 +20526,10 @@ ieee754.write = function(buffer2, value, offset2, isLE, mLen, nBytes) {
20526
20526
  checkInt(this, value, offset2, byteLength3, maxBytes, 0);
20527
20527
  }
20528
20528
  let i2 = byteLength3 - 1;
20529
- let mul = 1;
20529
+ let mul3 = 1;
20530
20530
  this[offset2 + i2] = value & 255;
20531
- while (--i2 >= 0 && (mul *= 256)) {
20532
- this[offset2 + i2] = value / mul & 255;
20531
+ while (--i2 >= 0 && (mul3 *= 256)) {
20532
+ this[offset2 + i2] = value / mul3 & 255;
20533
20533
  }
20534
20534
  return offset2 + byteLength3;
20535
20535
  };
@@ -20630,14 +20630,14 @@ ieee754.write = function(buffer2, value, offset2, isLE, mLen, nBytes) {
20630
20630
  checkInt(this, value, offset2, byteLength3, limit - 1, -limit);
20631
20631
  }
20632
20632
  let i2 = 0;
20633
- let mul = 1;
20633
+ let mul3 = 1;
20634
20634
  let sub = 0;
20635
20635
  this[offset2] = value & 255;
20636
- while (++i2 < byteLength3 && (mul *= 256)) {
20636
+ while (++i2 < byteLength3 && (mul3 *= 256)) {
20637
20637
  if (value < 0 && sub === 0 && this[offset2 + i2 - 1] !== 0) {
20638
20638
  sub = 1;
20639
20639
  }
20640
- this[offset2 + i2] = (value / mul >> 0) - sub & 255;
20640
+ this[offset2 + i2] = (value / mul3 >> 0) - sub & 255;
20641
20641
  }
20642
20642
  return offset2 + byteLength3;
20643
20643
  };
@@ -20649,14 +20649,14 @@ ieee754.write = function(buffer2, value, offset2, isLE, mLen, nBytes) {
20649
20649
  checkInt(this, value, offset2, byteLength3, limit - 1, -limit);
20650
20650
  }
20651
20651
  let i2 = byteLength3 - 1;
20652
- let mul = 1;
20652
+ let mul3 = 1;
20653
20653
  let sub = 0;
20654
20654
  this[offset2 + i2] = value & 255;
20655
- while (--i2 >= 0 && (mul *= 256)) {
20655
+ while (--i2 >= 0 && (mul3 *= 256)) {
20656
20656
  if (value < 0 && sub === 0 && this[offset2 + i2 + 1] !== 0) {
20657
20657
  sub = 1;
20658
20658
  }
20659
- this[offset2 + i2] = (value / mul >> 0) - sub & 255;
20659
+ this[offset2 + i2] = (value / mul3 >> 0) - sub & 255;
20660
20660
  }
20661
20661
  return offset2 + byteLength3;
20662
20662
  };
@@ -21339,17 +21339,10 @@ var implementation$1 = function bind2(that) {
21339
21339
  var implementation = implementation$1;
21340
21340
  var functionBind = Function.prototype.bind || implementation;
21341
21341
  var functionCall = Function.prototype.call;
21342
- var functionApply;
21343
- var hasRequiredFunctionApply;
21344
- function requireFunctionApply() {
21345
- if (hasRequiredFunctionApply) return functionApply;
21346
- hasRequiredFunctionApply = 1;
21347
- functionApply = Function.prototype.apply;
21348
- return functionApply;
21349
- }
21342
+ var functionApply = Function.prototype.apply;
21350
21343
  var reflectApply = typeof Reflect !== "undefined" && Reflect && Reflect.apply;
21351
21344
  var bind$2 = functionBind;
21352
- var $apply$1 = requireFunctionApply();
21345
+ var $apply$1 = functionApply;
21353
21346
  var $call$2 = functionCall;
21354
21347
  var $reflectApply = reflectApply;
21355
21348
  var actualApply = $reflectApply || bind$2.call($call$2, $apply$1);
@@ -21469,7 +21462,7 @@ var hasSymbols = requireHasSymbols()();
21469
21462
  var getProto = requireGetProto();
21470
21463
  var $ObjectGPO = requireObject_getPrototypeOf();
21471
21464
  var $ReflectGPO = requireReflect_getPrototypeOf();
21472
- var $apply = requireFunctionApply();
21465
+ var $apply = functionApply;
21473
21466
  var $call = functionCall;
21474
21467
  var needsEval = {};
21475
21468
  var TypedArray = typeof Uint8Array === "undefined" || !getProto ? undefined$1 : getProto(Uint8Array);
@@ -22110,7 +22103,7 @@ function requireApplyBind() {
22110
22103
  if (hasRequiredApplyBind) return applyBind;
22111
22104
  hasRequiredApplyBind = 1;
22112
22105
  var bind3 = functionBind;
22113
- var $apply2 = requireFunctionApply();
22106
+ var $apply2 = functionApply;
22114
22107
  var actualApply$1 = actualApply;
22115
22108
  applyBind = function applyBind2() {
22116
22109
  return actualApply$1(bind3, $apply2, arguments);
@@ -23157,23 +23150,23 @@ var sha_jsExports = sha_js.exports;
23157
23150
  const SHA = /* @__PURE__ */ getDefaultExportFromCjs(sha_jsExports);
23158
23151
  const fromNumH = (n) => n / 2 ** 32 | 0;
23159
23152
  const fromNumL = (n) => n >>> 0;
23160
- function setU64FromNum(view, byteOffset, n, isLE) {
23153
+ function setU64FromNum(view, byteOffset, n, isLE2) {
23161
23154
  const h = fromNumH(n);
23162
23155
  const l = fromNumL(n);
23163
- view.setUint32(byteOffset, isLE ? l : h, isLE);
23164
- view.setUint32(byteOffset + 4, isLE ? h : l, isLE);
23156
+ view.setUint32(byteOffset, isLE2 ? l : h, isLE2);
23157
+ view.setUint32(byteOffset + 4, isLE2 ? h : l, isLE2);
23165
23158
  }
23166
- function isBytes(a) {
23159
+ function isBytes$1(a) {
23167
23160
  return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
23168
23161
  }
23169
- const atitle = (title) => title ? `"${title}" ` : "";
23170
- function abytes(value, length, title = "") {
23171
- if (isBytes(value) && length === void 0)
23162
+ const atitle$1 = (title) => title ? `"${title}" ` : "";
23163
+ function abytes$1(value, length, title = "") {
23164
+ if (isBytes$1(value) && length === void 0)
23172
23165
  return value;
23173
- const bytes2 = isBytes(value);
23166
+ const bytes2 = isBytes$1(value);
23174
23167
  const ofLen = "";
23175
23168
  const got = bytes2 ? `length=${value.length}` : `type=${typeof value}`;
23176
- const message = atitle(title) + "expected Uint8Array" + ofLen + ", got " + got;
23169
+ const message = atitle$1(title) + "expected Uint8Array" + ofLen + ", got " + got;
23177
23170
  if (!bytes2)
23178
23171
  throw new TypeError(message);
23179
23172
  throw new RangeError(message);
@@ -23182,25 +23175,25 @@ const aobject = (value, label) => {
23182
23175
  if (value === null || typeof value !== "object" || Array.isArray(value))
23183
23176
  throw new TypeError((label === "object" ? "" : `"${label}" `) + "expected object, got type=" + typeof value);
23184
23177
  };
23185
- function aexists(instance, checkFinished = true) {
23178
+ function aexists$1(instance, checkFinished = true) {
23186
23179
  if (instance.destroyed)
23187
23180
  throw new Error("hash was destroyed");
23188
23181
  if (checkFinished && instance.finished)
23189
23182
  throw new Error("digest() was already called");
23190
23183
  }
23191
- function aoutput(out, instance) {
23192
- abytes(out, void 0, "output");
23184
+ function aoutput$1(out, instance) {
23185
+ abytes$1(out, void 0, "output");
23193
23186
  const min2 = instance.outputLen;
23194
23187
  if (!(out.length >= min2)) {
23195
23188
  throw new RangeError('"output" expected length >= ' + min2);
23196
23189
  }
23197
23190
  }
23198
- function clean(...arrays) {
23191
+ function clean$1(...arrays) {
23199
23192
  for (let i2 = 0; i2 < arrays.length; i2++) {
23200
23193
  arrays[i2].fill(0);
23201
23194
  }
23202
23195
  }
23203
- function createView(arr) {
23196
+ function createView$1(arr) {
23204
23197
  return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
23205
23198
  }
23206
23199
  function rotr(word, shift) {
@@ -23215,7 +23208,7 @@ const hasHexBuiltin = /* @__PURE__ */ (() => (
23215
23208
  ))();
23216
23209
  const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i2) => i2.toString(16).padStart(2, "0"));
23217
23210
  function bytesToHex(bytes2) {
23218
- abytes(bytes2);
23211
+ abytes$1(bytes2);
23219
23212
  if (hasHexBuiltin)
23220
23213
  return bytes2.toHex();
23221
23214
  let hex = "";
@@ -23256,7 +23249,7 @@ function Maj(a, b, c) {
23256
23249
  return a & b ^ a & c ^ b & c;
23257
23250
  }
23258
23251
  class HashMD {
23259
- constructor(blockLen, outputLen, padOffset, isLE) {
23252
+ constructor(blockLen, outputLen, padOffset, isLE2) {
23260
23253
  __publicField(this, "blockLen");
23261
23254
  __publicField(this, "outputLen");
23262
23255
  __publicField(this, "canXOF", false);
@@ -23272,20 +23265,20 @@ class HashMD {
23272
23265
  this.blockLen = blockLen;
23273
23266
  this.outputLen = outputLen;
23274
23267
  this.padOffset = padOffset;
23275
- this.isLE = isLE;
23268
+ this.isLE = isLE2;
23276
23269
  this.buffer = new Uint8Array(blockLen);
23277
- this.view = createView(this.buffer);
23270
+ this.view = createView$1(this.buffer);
23278
23271
  }
23279
23272
  update(data2) {
23280
- aexists(this);
23281
- abytes(data2);
23273
+ aexists$1(this);
23274
+ abytes$1(data2);
23282
23275
  const { view, buffer: buffer2, blockLen } = this;
23283
23276
  const len2 = data2.length;
23284
23277
  let processed = false;
23285
23278
  for (let pos = 0; pos < len2; ) {
23286
23279
  const take = Math.min(blockLen - this.pos, len2 - pos);
23287
23280
  if (take === blockLen) {
23288
- const dataView = createView(data2);
23281
+ const dataView = createView$1(data2);
23289
23282
  for (; blockLen <= len2 - pos; pos += blockLen)
23290
23283
  this.process(dataView, pos);
23291
23284
  processed = true;
@@ -23306,10 +23299,10 @@ class HashMD {
23306
23299
  return this;
23307
23300
  }
23308
23301
  digestInto(out) {
23309
- aexists(this);
23310
- aoutput(out, this);
23302
+ aexists$1(this);
23303
+ aoutput$1(out, this);
23311
23304
  this.finished = true;
23312
- const { buffer: buffer2, view, blockLen, isLE } = this;
23305
+ const { buffer: buffer2, view, blockLen, isLE: isLE2 } = this;
23313
23306
  let { pos } = this;
23314
23307
  buffer2[pos++] = 128;
23315
23308
  buffer2.fill(0, pos);
@@ -23317,17 +23310,17 @@ class HashMD {
23317
23310
  this.process(view, 0);
23318
23311
  buffer2.fill(0);
23319
23312
  }
23320
- setU64FromNum(view, blockLen - 8, this.length * 8, isLE);
23313
+ setU64FromNum(view, blockLen - 8, this.length * 8, isLE2);
23321
23314
  this.process(view, 0);
23322
23315
  this.roundClean();
23323
- const oview = out === buffer2 ? view : createView(out);
23316
+ const oview = out === buffer2 ? view : createView$1(out);
23324
23317
  const len2 = this.outputLen;
23325
23318
  const outLen = len2 / 4;
23326
23319
  const state = this.get();
23327
23320
  if (len2 % 4 || outLen > state.length)
23328
23321
  throw new Error("invalid outputLen");
23329
23322
  for (let i2 = 0; i2 < outLen; i2++)
23330
- oview.setUint32(4 * i2, state[i2], isLE);
23323
+ oview.setUint32(4 * i2, state[i2], isLE2);
23331
23324
  }
23332
23325
  digest() {
23333
23326
  const { buffer: buffer2, outputLen } = this;
@@ -23434,12 +23427,12 @@ class _MD5 extends HashMD {
23434
23427
  this.set(A, B, C, D);
23435
23428
  }
23436
23429
  roundClean() {
23437
- clean(MD5_W);
23430
+ clean$1(MD5_W);
23438
23431
  }
23439
23432
  destroy() {
23440
23433
  this.destroyed = true;
23441
23434
  this.set(0, 0, 0, 0);
23442
- clean(this.buffer);
23435
+ clean$1(this.buffer);
23443
23436
  }
23444
23437
  }
23445
23438
  const md5 = /* @__PURE__ */ createHasher(() => new _MD5());
@@ -23449,6 +23442,993 @@ const cryptoConstants = {
23449
23442
  RSA_PKCS1_OAEP_PADDING: 4,
23450
23443
  RSA_PKCS1_PSS_PADDING: 6
23451
23444
  };
23445
+ /*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */
23446
+ function isBytes(a) {
23447
+ return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
23448
+ }
23449
+ const atitle = (title) => title ? `"${title}" ` : "";
23450
+ function anumber(n, title = "") {
23451
+ if (typeof n !== "number")
23452
+ throw new TypeError(atitle(title) + "expected number, got " + typeof n);
23453
+ if (!Number.isSafeInteger(n) || n < 0)
23454
+ throw new RangeError(atitle(title) + "expected integer >= 0, got " + n);
23455
+ return n;
23456
+ }
23457
+ function abytes(value, length, title = "") {
23458
+ if (isBytes(value) && (length === void 0 || value.length === length))
23459
+ return value;
23460
+ if (length !== void 0)
23461
+ anumber(length, "length");
23462
+ const bytes2 = isBytes(value);
23463
+ const ofLen = length !== void 0 ? ` of length ${length}` : "";
23464
+ const got = bytes2 ? `length=${value.length}` : `type=${typeof value}`;
23465
+ const message = atitle(title) + "expected Uint8Array" + ofLen + ", got " + got;
23466
+ if (!bytes2)
23467
+ throw new TypeError(message);
23468
+ throw new RangeError(message);
23469
+ }
23470
+ function aexists(instance, checkFinished = true) {
23471
+ if (instance.destroyed)
23472
+ throw new Error("hash was destroyed");
23473
+ if (checkFinished && instance.finished)
23474
+ throw new Error("digest() was already called");
23475
+ }
23476
+ function aoutput(out, instance) {
23477
+ abytes(out, void 0, "output");
23478
+ const min2 = instance.outputLen;
23479
+ if (!(out.length >= min2)) {
23480
+ throw new RangeError('"output" expected length >= ' + min2);
23481
+ }
23482
+ }
23483
+ function aoutput32(out, instance) {
23484
+ aoutput(out, instance);
23485
+ if (!isAligned32(out))
23486
+ throw new Error("invalid output, must be aligned");
23487
+ }
23488
+ function u8(arr) {
23489
+ return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
23490
+ }
23491
+ function u32(arr) {
23492
+ return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
23493
+ }
23494
+ function clean(...arrays) {
23495
+ for (let i2 = 0; i2 < arrays.length; i2++) {
23496
+ arrays[i2].fill(0);
23497
+ }
23498
+ }
23499
+ function createView(arr) {
23500
+ return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
23501
+ }
23502
+ const isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
23503
+ function byteSwap(word) {
23504
+ return word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
23505
+ }
23506
+ const swap8IfBE = isLE ? (n) => n : (n) => byteSwap(n) >>> 0;
23507
+ function byteSwap32(arr) {
23508
+ for (let i2 = 0; i2 < arr.length; i2++) {
23509
+ arr[i2] = byteSwap(arr[i2]);
23510
+ }
23511
+ return arr;
23512
+ }
23513
+ const swap32IfBE = isLE ? (u) => u : byteSwap32;
23514
+ function overlapBytes(a, b) {
23515
+ if (!a.byteLength || !b.byteLength)
23516
+ return false;
23517
+ return a.buffer === b.buffer && // best we can do, may fail with an obscure Proxy
23518
+ a.byteOffset < b.byteOffset + b.byteLength && // a starts before b end
23519
+ b.byteOffset < a.byteOffset + a.byteLength;
23520
+ }
23521
+ function complexOverlapBytes(input, output) {
23522
+ if (overlapBytes(input, output) && input.byteOffset < output.byteOffset)
23523
+ throw new Error("complex overlap of input and output is not supported");
23524
+ }
23525
+ function wrapMacConstructor(keyLen, macCons, fromMsg) {
23526
+ const mac = macCons;
23527
+ const getArgs = fromMsg || (() => []);
23528
+ const macC = (msg2, key) => mac(key, ...getArgs(msg2)).update(msg2).digest();
23529
+ const tmp = mac(new Uint8Array(keyLen), ...getArgs(new Uint8Array(0)));
23530
+ macC.outputLen = tmp.outputLen;
23531
+ macC.blockLen = tmp.blockLen;
23532
+ macC.create = (key, ...args) => mac(key, ...args);
23533
+ return macC;
23534
+ }
23535
+ function getOutput(expectedLength, out, onlyAligned = true) {
23536
+ if (out === void 0)
23537
+ return new Uint8Array(expectedLength);
23538
+ abytes(out, expectedLength, "output");
23539
+ if (onlyAligned && !isAligned32(out))
23540
+ throw new Error("invalid output, must be aligned");
23541
+ return out;
23542
+ }
23543
+ function isAligned32(bytes2) {
23544
+ return bytes2.byteOffset % 4 === 0;
23545
+ }
23546
+ function copyBytes(bytes2) {
23547
+ return Uint8Array.from(abytes(bytes2));
23548
+ }
23549
+ const BLOCK_SIZE$1 = 16;
23550
+ const ZEROS16 = /* @__PURE__ */ new Uint8Array(16);
23551
+ const ZEROS32 = /* @__PURE__ */ u32(ZEROS16);
23552
+ const POLY$1 = 225;
23553
+ const mul2$1 = (s0, s1, s2, s3) => {
23554
+ const hiBit = s3 & 1;
23555
+ return {
23556
+ s3: s2 << 31 | s3 >>> 1,
23557
+ s2: s1 << 31 | s2 >>> 1,
23558
+ s1: s0 << 31 | s1 >>> 1,
23559
+ // NIST SP 800-38D §6.3 applies `V >> 1` and XORs R on carry. In this
23560
+ // 4x32-bit split, R = 0xe1 || 0^120 lives in the top byte of s0.
23561
+ s0: s0 >>> 1 ^ POLY$1 << 24 & -(hiBit & 1)
23562
+ // reduce % poly
23563
+ };
23564
+ };
23565
+ const swapLE = (n) => (n >>> 0 & 255) << 24 | (n >>> 8 & 255) << 16 | (n >>> 16 & 255) << 8 | n >>> 24 & 255 | 0;
23566
+ const estimateWindow = (bytes2) => {
23567
+ if (bytes2 > 64 * 1024)
23568
+ return 8;
23569
+ if (bytes2 > 1024)
23570
+ return 4;
23571
+ return 2;
23572
+ };
23573
+ class GHASH {
23574
+ // We select bits per window adaptively based on expectedLength
23575
+ constructor(key, expectedLength) {
23576
+ __publicField(this, "blockLen", BLOCK_SIZE$1);
23577
+ __publicField(this, "outputLen", BLOCK_SIZE$1);
23578
+ __publicField(this, "s0", 0);
23579
+ __publicField(this, "s1", 0);
23580
+ __publicField(this, "s2", 0);
23581
+ __publicField(this, "s3", 0);
23582
+ __publicField(this, "finished", false);
23583
+ __publicField(this, "destroyed", false);
23584
+ __publicField(this, "t");
23585
+ __publicField(this, "W");
23586
+ __publicField(this, "windowSize");
23587
+ abytes(key, 16, "key");
23588
+ key = copyBytes(key);
23589
+ const kView = createView(key);
23590
+ let k0 = kView.getUint32(0, false);
23591
+ let k1 = kView.getUint32(4, false);
23592
+ let k2 = kView.getUint32(8, false);
23593
+ let k3 = kView.getUint32(12, false);
23594
+ const doubles = [];
23595
+ for (let i2 = 0; i2 < 128; i2++) {
23596
+ doubles.push({ s0: swapLE(k0), s1: swapLE(k1), s2: swapLE(k2), s3: swapLE(k3) });
23597
+ ({ s0: k0, s1: k1, s2: k2, s3: k3 } = mul2$1(k0, k1, k2, k3));
23598
+ }
23599
+ const W2 = estimateWindow(expectedLength || 1024);
23600
+ if (![1, 2, 4, 8].includes(W2))
23601
+ throw new Error("ghash: invalid window size, expected 2, 4 or 8");
23602
+ this.W = W2;
23603
+ const bits = 128;
23604
+ const windows = bits / W2;
23605
+ const windowSize = this.windowSize = 2 ** W2;
23606
+ const items = [];
23607
+ for (let w = 0; w < windows; w++) {
23608
+ for (let byte = 0; byte < windowSize; byte++) {
23609
+ let s0 = 0, s1 = 0, s2 = 0, s3 = 0;
23610
+ for (let j = 0; j < W2; j++) {
23611
+ const bit = byte >>> W2 - j - 1 & 1;
23612
+ if (!bit)
23613
+ continue;
23614
+ const { s0: d0, s1: d1, s2: d2, s3: d3 } = doubles[W2 * w + j];
23615
+ s0 ^= d0, s1 ^= d1, s2 ^= d2, s3 ^= d3;
23616
+ }
23617
+ items.push({ s0, s1, s2, s3 });
23618
+ }
23619
+ }
23620
+ this.t = items;
23621
+ }
23622
+ _updateBlock(s0, s1, s2, s3) {
23623
+ s0 ^= this.s0, s1 ^= this.s1, s2 ^= this.s2, s3 ^= this.s3;
23624
+ const { W: W2, t, windowSize } = this;
23625
+ let o0 = 0, o1 = 0, o2 = 0, o3 = 0;
23626
+ const mask = (1 << W2) - 1;
23627
+ let w = 0;
23628
+ for (const num of [s0, s1, s2, s3]) {
23629
+ for (let bytePos = 0; bytePos < 4; bytePos++) {
23630
+ const byte = num >>> 8 * bytePos & 255;
23631
+ for (let bitPos = 8 / W2 - 1; bitPos >= 0; bitPos--) {
23632
+ const bit = byte >>> W2 * bitPos & mask;
23633
+ const { s0: e0, s1: e1, s2: e2, s3: e3 } = t[w * windowSize + bit];
23634
+ o0 ^= e0, o1 ^= e1, o2 ^= e2, o3 ^= e3;
23635
+ w += 1;
23636
+ }
23637
+ }
23638
+ }
23639
+ this.s0 = o0;
23640
+ this.s1 = o1;
23641
+ this.s2 = o2;
23642
+ this.s3 = o3;
23643
+ }
23644
+ update(data2) {
23645
+ aexists(this);
23646
+ abytes(data2);
23647
+ data2 = copyBytes(data2);
23648
+ const b32 = u32(data2);
23649
+ const blocks = Math.floor(data2.length / BLOCK_SIZE$1);
23650
+ const left = data2.length % BLOCK_SIZE$1;
23651
+ for (let i2 = 0; i2 < blocks; i2++) {
23652
+ this._updateBlock(swap8IfBE(b32[i2 * 4 + 0]), swap8IfBE(b32[i2 * 4 + 1]), swap8IfBE(b32[i2 * 4 + 2]), swap8IfBE(b32[i2 * 4 + 3]));
23653
+ }
23654
+ if (left) {
23655
+ ZEROS16.set(data2.subarray(blocks * BLOCK_SIZE$1));
23656
+ this._updateBlock(swap8IfBE(ZEROS32[0]), swap8IfBE(ZEROS32[1]), swap8IfBE(ZEROS32[2]), swap8IfBE(ZEROS32[3]));
23657
+ clean(ZEROS32);
23658
+ }
23659
+ return this;
23660
+ }
23661
+ destroy() {
23662
+ this.destroyed = true;
23663
+ const { t } = this;
23664
+ for (const elm of t) {
23665
+ elm.s0 = 0, elm.s1 = 0, elm.s2 = 0, elm.s3 = 0;
23666
+ }
23667
+ }
23668
+ digestInto(out) {
23669
+ aexists(this);
23670
+ aoutput32(out, this);
23671
+ this.finished = true;
23672
+ const { s0, s1, s2, s3 } = this;
23673
+ const o32 = u32(out);
23674
+ o32[0] = s0;
23675
+ o32[1] = s1;
23676
+ o32[2] = s2;
23677
+ o32[3] = s3;
23678
+ if (!isLE)
23679
+ swap32IfBE(o32.subarray(0, BLOCK_SIZE$1 / 4));
23680
+ }
23681
+ digest() {
23682
+ const res = new Uint8Array(BLOCK_SIZE$1);
23683
+ this.digestInto(res);
23684
+ this.destroy();
23685
+ return res;
23686
+ }
23687
+ }
23688
+ const BLOCK_SIZE = 16;
23689
+ const BLOCK_SIZE32 = 4;
23690
+ const EMPTY_BLOCK = /* @__PURE__ */ new Uint8Array(BLOCK_SIZE);
23691
+ const ONE_BLOCK = /* @__PURE__ */ Uint8Array.from([
23692
+ 0,
23693
+ 0,
23694
+ 0,
23695
+ 0,
23696
+ 0,
23697
+ 0,
23698
+ 0,
23699
+ 0,
23700
+ 0,
23701
+ 0,
23702
+ 0,
23703
+ 0,
23704
+ 0,
23705
+ 0,
23706
+ 0,
23707
+ 1
23708
+ ]);
23709
+ const POLY = 283;
23710
+ function validateKeyLength(key) {
23711
+ if (![16, 24, 32].includes(key.length))
23712
+ throw new Error('"aes key" expected Uint8Array of length 16/24/32, got length=' + key.length);
23713
+ }
23714
+ function mul2(n) {
23715
+ return n << 1 ^ POLY & -(n >> 7);
23716
+ }
23717
+ function mul(a, b) {
23718
+ let res = 0;
23719
+ for (; b > 0; b >>= 1) {
23720
+ res ^= a & -(b & 1);
23721
+ a = mul2(a);
23722
+ }
23723
+ return res;
23724
+ }
23725
+ const sbox = /* @__PURE__ */ (() => {
23726
+ const t = new Uint8Array(256);
23727
+ for (let i2 = 0, x = 1; i2 < 256; i2++, x ^= mul2(x))
23728
+ t[i2] = x;
23729
+ const box = new Uint8Array(256);
23730
+ box[0] = 99;
23731
+ for (let i2 = 0; i2 < 255; i2++) {
23732
+ let x = t[255 - i2];
23733
+ x |= x << 8;
23734
+ box[t[i2]] = (x ^ x >> 4 ^ x >> 5 ^ x >> 6 ^ x >> 7 ^ 99) & 255;
23735
+ }
23736
+ clean(t);
23737
+ return box;
23738
+ })();
23739
+ const invSbox = /* @__PURE__ */ sbox.map((_, j) => sbox.indexOf(j));
23740
+ const rotr32_8 = (n) => n << 24 | n >>> 8;
23741
+ const rotl32_8 = (n) => n << 8 | n >>> 24;
23742
+ function genTtable(sbox2, fn) {
23743
+ if (sbox2.length !== 256)
23744
+ throw new Error("wrong sbox length");
23745
+ const T0 = new Uint32Array(256).map((_, j) => fn(sbox2[j]));
23746
+ const T1 = T0.map(rotl32_8);
23747
+ const T2 = T1.map(rotl32_8);
23748
+ const T3 = T2.map(rotl32_8);
23749
+ const T01 = new Uint32Array(256 * 256);
23750
+ const T23 = new Uint32Array(256 * 256);
23751
+ const sbox22 = new Uint16Array(256 * 256);
23752
+ for (let i2 = 0; i2 < 256; i2++) {
23753
+ for (let j = 0; j < 256; j++) {
23754
+ const idx = i2 * 256 + j;
23755
+ T01[idx] = T0[i2] ^ T1[j];
23756
+ T23[idx] = T2[i2] ^ T3[j];
23757
+ sbox22[idx] = sbox2[i2] << 8 | sbox2[j];
23758
+ }
23759
+ }
23760
+ return { sbox: sbox2, sbox2: sbox22, T0, T1, T2, T3, T01, T23 };
23761
+ }
23762
+ const tableEncoding = /* @__PURE__ */ genTtable(sbox, (s) => mul(s, 3) << 24 | s << 16 | s << 8 | mul(s, 2));
23763
+ const tableDecoding = /* @__PURE__ */ genTtable(invSbox, (s) => mul(s, 11) << 24 | mul(s, 13) << 16 | mul(s, 9) << 8 | mul(s, 14));
23764
+ const xPowers = /* @__PURE__ */ (() => {
23765
+ const p = new Uint8Array(16);
23766
+ for (let i2 = 0, x = 1; i2 < 16; i2++, x = mul2(x))
23767
+ p[i2] = x;
23768
+ return p;
23769
+ })();
23770
+ function expandKeyLE(key) {
23771
+ abytes(key);
23772
+ const len2 = key.length;
23773
+ validateKeyLength(key);
23774
+ const { sbox2 } = tableEncoding;
23775
+ const toClean = [];
23776
+ if (!isLE || !isAligned32(key))
23777
+ toClean.push(key = copyBytes(key));
23778
+ const k32 = swap32IfBE(u32(key));
23779
+ const Nk = k32.length;
23780
+ const subByte = (n) => applySbox(sbox2, n, n, n, n);
23781
+ const xk = new Uint32Array(len2 + 28);
23782
+ xk.set(k32);
23783
+ for (let i2 = Nk; i2 < xk.length; i2++) {
23784
+ let t = xk[i2 - 1];
23785
+ if (i2 % Nk === 0)
23786
+ t = subByte(rotr32_8(t)) ^ xPowers[i2 / Nk - 1];
23787
+ else if (Nk > 6 && i2 % Nk === 4)
23788
+ t = subByte(t);
23789
+ xk[i2] = xk[i2 - Nk] ^ t;
23790
+ }
23791
+ clean(...toClean);
23792
+ return xk;
23793
+ }
23794
+ function expandKeyDecLE(key) {
23795
+ const encKey = expandKeyLE(key);
23796
+ const xk = encKey.slice();
23797
+ const Nk = encKey.length;
23798
+ const { sbox2 } = tableEncoding;
23799
+ const { T0, T1, T2, T3 } = tableDecoding;
23800
+ for (let i2 = 0; i2 < Nk; i2 += 4) {
23801
+ for (let j = 0; j < 4; j++)
23802
+ xk[i2 + j] = encKey[Nk - i2 - 4 + j];
23803
+ }
23804
+ clean(encKey);
23805
+ for (let i2 = 4; i2 < Nk - 4; i2++) {
23806
+ const x = xk[i2];
23807
+ const w = applySbox(sbox2, x, x, x, x);
23808
+ xk[i2] = T0[w & 255] ^ T1[w >>> 8 & 255] ^ T2[w >>> 16 & 255] ^ T3[w >>> 24];
23809
+ }
23810
+ return xk;
23811
+ }
23812
+ function apply0123(T01, T23, s0, s1, s2, s3) {
23813
+ return T01[s0 << 8 & 65280 | s1 >>> 8 & 255] ^ T23[s2 >>> 8 & 65280 | s3 >>> 24 & 255];
23814
+ }
23815
+ function applySbox(sbox2, s0, s1, s2, s3) {
23816
+ return sbox2[s0 & 255 | s1 & 65280] | sbox2[s2 >>> 16 & 255 | s3 >>> 16 & 65280] << 16;
23817
+ }
23818
+ function encrypt(xk, s0, s1, s2, s3) {
23819
+ const { sbox2, T01, T23 } = tableEncoding;
23820
+ let k = 0;
23821
+ s0 ^= xk[k++], s1 ^= xk[k++], s2 ^= xk[k++], s3 ^= xk[k++];
23822
+ const rounds = xk.length / 4 - 2;
23823
+ for (let i2 = 0; i2 < rounds; i2++) {
23824
+ const t02 = xk[k++] ^ apply0123(T01, T23, s0, s1, s2, s3);
23825
+ const t12 = xk[k++] ^ apply0123(T01, T23, s1, s2, s3, s0);
23826
+ const t22 = xk[k++] ^ apply0123(T01, T23, s2, s3, s0, s1);
23827
+ const t32 = xk[k++] ^ apply0123(T01, T23, s3, s0, s1, s2);
23828
+ s0 = t02, s1 = t12, s2 = t22, s3 = t32;
23829
+ }
23830
+ const t0 = xk[k++] ^ applySbox(sbox2, s0, s1, s2, s3);
23831
+ const t1 = xk[k++] ^ applySbox(sbox2, s1, s2, s3, s0);
23832
+ const t2 = xk[k++] ^ applySbox(sbox2, s2, s3, s0, s1);
23833
+ const t3 = xk[k++] ^ applySbox(sbox2, s3, s0, s1, s2);
23834
+ return { s0: t0, s1: t1, s2: t2, s3: t3 };
23835
+ }
23836
+ function decrypt(xk, s0, s1, s2, s3) {
23837
+ const { sbox2, T01, T23 } = tableDecoding;
23838
+ let k = 0;
23839
+ s0 ^= xk[k++], s1 ^= xk[k++], s2 ^= xk[k++], s3 ^= xk[k++];
23840
+ const rounds = xk.length / 4 - 2;
23841
+ for (let i2 = 0; i2 < rounds; i2++) {
23842
+ const t02 = xk[k++] ^ apply0123(T01, T23, s0, s3, s2, s1);
23843
+ const t12 = xk[k++] ^ apply0123(T01, T23, s1, s0, s3, s2);
23844
+ const t22 = xk[k++] ^ apply0123(T01, T23, s2, s1, s0, s3);
23845
+ const t32 = xk[k++] ^ apply0123(T01, T23, s3, s2, s1, s0);
23846
+ s0 = t02, s1 = t12, s2 = t22, s3 = t32;
23847
+ }
23848
+ const t0 = xk[k++] ^ applySbox(sbox2, s0, s3, s2, s1);
23849
+ const t1 = xk[k++] ^ applySbox(sbox2, s1, s0, s3, s2);
23850
+ const t2 = xk[k++] ^ applySbox(sbox2, s2, s1, s0, s3);
23851
+ const t3 = xk[k++] ^ applySbox(sbox2, s3, s2, s1, s0);
23852
+ return { s0: t0, s1: t1, s2: t2, s3: t3 };
23853
+ }
23854
+ function ctrCounter(xk, nonce, src, dst) {
23855
+ abytes(nonce, BLOCK_SIZE, "nonce");
23856
+ abytes(src);
23857
+ const srcLen = src.length;
23858
+ dst = getOutput(srcLen, dst);
23859
+ complexOverlapBytes(src, dst);
23860
+ const ctr = nonce;
23861
+ const c32 = u32(ctr);
23862
+ const src32 = u32(src);
23863
+ const dst32 = u32(dst);
23864
+ for (let i2 = 0; i2 + 4 <= src32.length; i2 += 4) {
23865
+ const { s0, s1, s2, s3 } = encrypt(xk, swap8IfBE(c32[0]), swap8IfBE(c32[1]), swap8IfBE(c32[2]), swap8IfBE(c32[3]));
23866
+ dst32[i2 + 0] = src32[i2 + 0] ^ swap8IfBE(s0);
23867
+ dst32[i2 + 1] = src32[i2 + 1] ^ swap8IfBE(s1);
23868
+ dst32[i2 + 2] = src32[i2 + 2] ^ swap8IfBE(s2);
23869
+ dst32[i2 + 3] = src32[i2 + 3] ^ swap8IfBE(s3);
23870
+ for (let j = BLOCK_SIZE - 1, carry = 1; j >= 0; j--) {
23871
+ carry = carry + ctr[j] | 0;
23872
+ ctr[j] = carry & 255;
23873
+ carry >>>= 8;
23874
+ }
23875
+ }
23876
+ const start = BLOCK_SIZE * Math.floor(src32.length / BLOCK_SIZE32);
23877
+ if (start < srcLen) {
23878
+ const { s0, s1, s2, s3 } = encrypt(xk, swap8IfBE(c32[0]), swap8IfBE(c32[1]), swap8IfBE(c32[2]), swap8IfBE(c32[3]));
23879
+ const b32 = new Uint32Array([s0, s1, s2, s3]);
23880
+ swap32IfBE(b32);
23881
+ const buf = u8(b32);
23882
+ for (let i2 = start, pos = 0; i2 < srcLen; i2++, pos++)
23883
+ dst[i2] = src[i2] ^ buf[pos];
23884
+ clean(b32);
23885
+ }
23886
+ return dst;
23887
+ }
23888
+ function ctr32(xk, isLE2, nonce, src, dst) {
23889
+ abytes(nonce, BLOCK_SIZE, "nonce");
23890
+ abytes(src);
23891
+ dst = getOutput(src.length, dst);
23892
+ const ctr = nonce;
23893
+ const c32 = u32(ctr);
23894
+ const view = createView(ctr);
23895
+ const src32 = u32(src);
23896
+ const dst32 = u32(dst);
23897
+ const ctrPos = isLE2 ? 0 : 12;
23898
+ const srcLen = src.length;
23899
+ let ctrNum = view.getUint32(ctrPos, isLE2);
23900
+ for (let i2 = 0; i2 + 4 <= src32.length; i2 += 4) {
23901
+ const { s0, s1, s2, s3 } = encrypt(xk, swap8IfBE(c32[0]), swap8IfBE(c32[1]), swap8IfBE(c32[2]), swap8IfBE(c32[3]));
23902
+ dst32[i2 + 0] = src32[i2 + 0] ^ swap8IfBE(s0);
23903
+ dst32[i2 + 1] = src32[i2 + 1] ^ swap8IfBE(s1);
23904
+ dst32[i2 + 2] = src32[i2 + 2] ^ swap8IfBE(s2);
23905
+ dst32[i2 + 3] = src32[i2 + 3] ^ swap8IfBE(s3);
23906
+ ctrNum = ctrNum + 1 >>> 0;
23907
+ view.setUint32(ctrPos, ctrNum, isLE2);
23908
+ }
23909
+ const start = BLOCK_SIZE * Math.floor(src32.length / BLOCK_SIZE32);
23910
+ if (start < srcLen) {
23911
+ const { s0, s1, s2, s3 } = encrypt(xk, swap8IfBE(c32[0]), swap8IfBE(c32[1]), swap8IfBE(c32[2]), swap8IfBE(c32[3]));
23912
+ const b32 = new Uint32Array([s0, s1, s2, s3]);
23913
+ swap32IfBE(b32);
23914
+ const buf = u8(b32);
23915
+ for (let i2 = start, pos = 0; i2 < srcLen; i2++, pos++)
23916
+ dst[i2] = src[i2] ^ buf[pos];
23917
+ clean(b32);
23918
+ }
23919
+ return dst;
23920
+ }
23921
+ function isBytes32(a) {
23922
+ return a instanceof Uint32Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint32Array";
23923
+ }
23924
+ function encryptBlock(xk, block) {
23925
+ abytes(block, 16, "block");
23926
+ if (!isBytes32(xk))
23927
+ throw new Error("_encryptBlock accepts result of expandKeyLE");
23928
+ const b32 = u32(block);
23929
+ swap32IfBE(b32);
23930
+ let { s0, s1, s2, s3 } = encrypt(xk, b32[0], b32[1], b32[2], b32[3]);
23931
+ b32[0] = s0, b32[1] = s1, b32[2] = s2, b32[3] = s3;
23932
+ swap32IfBE(b32);
23933
+ return block;
23934
+ }
23935
+ function decryptBlock(xk, block) {
23936
+ abytes(block, 16, "block");
23937
+ if (!isBytes32(xk))
23938
+ throw new Error("_decryptBlock accepts result of expandKeyLE");
23939
+ const b32 = u32(block);
23940
+ swap32IfBE(b32);
23941
+ let { s0, s1, s2, s3 } = decrypt(xk, b32[0], b32[1], b32[2], b32[3]);
23942
+ b32[0] = s0, b32[1] = s1, b32[2] = s2, b32[3] = s3;
23943
+ swap32IfBE(b32);
23944
+ return block;
23945
+ }
23946
+ function dbl(block) {
23947
+ let carry = 0;
23948
+ for (let i2 = BLOCK_SIZE - 1; i2 >= 0; i2--) {
23949
+ const newCarry = (block[i2] & 128) >>> 7;
23950
+ block[i2] = block[i2] << 1 | carry;
23951
+ carry = newCarry;
23952
+ }
23953
+ block[BLOCK_SIZE - 1] ^= 135 & -carry;
23954
+ return block;
23955
+ }
23956
+ function xorBlock(a, b) {
23957
+ if (a.length !== b.length)
23958
+ throw new Error("xorBlock: blocks must have same length");
23959
+ for (let i2 = 0; i2 < a.length; i2++) {
23960
+ a[i2] = a[i2] ^ b[i2];
23961
+ }
23962
+ return a;
23963
+ }
23964
+ function xorend(a, b) {
23965
+ if (b.length > a.length) {
23966
+ throw new Error("xorend: expected len(B) <= len(A)");
23967
+ }
23968
+ const offset2 = a.length - b.length;
23969
+ for (let i2 = 0; i2 < b.length; i2++) {
23970
+ a[offset2 + i2] = a[offset2 + i2] ^ b[i2];
23971
+ }
23972
+ return a;
23973
+ }
23974
+ class _CMAC {
23975
+ constructor(key) {
23976
+ __publicField(this, "blockLen", BLOCK_SIZE);
23977
+ __publicField(this, "outputLen", BLOCK_SIZE);
23978
+ // CMAC can only decide between `K1` and `K2` once the true final block is known,
23979
+ // so updates process older blocks eagerly but keep one pending block buffered.
23980
+ __publicField(this, "buffer");
23981
+ __publicField(this, "pos");
23982
+ __publicField(this, "finished");
23983
+ __publicField(this, "destroyed");
23984
+ __publicField(this, "k1");
23985
+ __publicField(this, "k2");
23986
+ __publicField(this, "x");
23987
+ __publicField(this, "x32");
23988
+ __publicField(this, "xk");
23989
+ abytes(key);
23990
+ validateKeyLength(key);
23991
+ this.xk = expandKeyLE(key);
23992
+ this.buffer = new Uint8Array(BLOCK_SIZE);
23993
+ this.pos = 0;
23994
+ this.finished = false;
23995
+ this.destroyed = false;
23996
+ this.x = new Uint8Array(BLOCK_SIZE);
23997
+ this.x32 = u32(this.x);
23998
+ const L = new Uint8Array(BLOCK_SIZE);
23999
+ encryptBlock(this.xk, L);
24000
+ this.k1 = dbl(L);
24001
+ this.k2 = dbl(new Uint8Array(this.k1));
24002
+ }
24003
+ // Consumes 16 bytes of `data` starting at `pos`; `pos` avoids a per-block
24004
+ // subarray view allocation in update().
24005
+ process(data2, pos) {
24006
+ const { x, x32, xk } = this;
24007
+ for (let i2 = 0; i2 < BLOCK_SIZE; i2++)
24008
+ x[i2] ^= data2[pos + i2];
24009
+ swap32IfBE(x32);
24010
+ const { s0, s1, s2, s3 } = encrypt(xk, x32[0], x32[1], x32[2], x32[3]);
24011
+ x32[0] = s0, x32[1] = s1, x32[2] = s2, x32[3] = s3;
24012
+ swap32IfBE(x32);
24013
+ }
24014
+ update(data2) {
24015
+ aexists(this);
24016
+ abytes(data2);
24017
+ let pos = 0;
24018
+ if (this.pos) {
24019
+ const take = Math.min(BLOCK_SIZE - this.pos, data2.length);
24020
+ this.buffer.set(data2.subarray(0, take), this.pos);
24021
+ this.pos += take;
24022
+ pos = take;
24023
+ if (this.pos === BLOCK_SIZE && pos < data2.length) {
24024
+ this.process(this.buffer, 0);
24025
+ this.pos = 0;
24026
+ }
24027
+ }
24028
+ while (pos + BLOCK_SIZE < data2.length) {
24029
+ this.process(data2, pos);
24030
+ pos += BLOCK_SIZE;
24031
+ }
24032
+ if (pos < data2.length) {
24033
+ this.buffer.set(data2.subarray(pos), 0);
24034
+ this.pos = data2.length - pos;
24035
+ }
24036
+ return this;
24037
+ }
24038
+ // See {@link https://www.rfc-editor.org/rfc/rfc4493.html#section-2.4 | RFC 4493 Section 2.4}.
24039
+ digestInto(out) {
24040
+ aexists(this);
24041
+ aoutput32(out, this);
24042
+ this.finished = true;
24043
+ const view = out.subarray(0, this.outputLen);
24044
+ let last = new Uint8Array(BLOCK_SIZE);
24045
+ if (this.pos === BLOCK_SIZE) {
24046
+ last.set(this.buffer);
24047
+ xorBlock(last, this.k1);
24048
+ } else {
24049
+ last.set(this.buffer.subarray(0, this.pos));
24050
+ last[this.pos] = 128;
24051
+ xorBlock(last, this.k2);
24052
+ }
24053
+ view.set(this.x);
24054
+ xorBlock(view, last);
24055
+ encryptBlock(this.xk, view);
24056
+ clean(last);
24057
+ }
24058
+ digest() {
24059
+ const { buffer: buffer2, outputLen } = this;
24060
+ this.digestInto(buffer2);
24061
+ const res = buffer2.slice(0, outputLen);
24062
+ this.destroy();
24063
+ return res;
24064
+ }
24065
+ destroy() {
24066
+ const { buffer: buffer2, destroyed, x, xk, k1, k2 } = this;
24067
+ if (destroyed)
24068
+ return;
24069
+ this.destroyed = true;
24070
+ clean(buffer2, x, xk, k1, k2);
24071
+ }
24072
+ }
24073
+ const cmac = /* @__PURE__ */ wrapMacConstructor(16, (key) => new _CMAC(key));
24074
+ function s2v(key, strings) {
24075
+ validateKeyLength(key);
24076
+ const len2 = strings.length;
24077
+ if (len2 > 127) {
24078
+ throw new Error("s2v: expected <= 127 inputs");
24079
+ }
24080
+ if (len2 === 0)
24081
+ return cmac(ONE_BLOCK, key);
24082
+ let d = cmac(EMPTY_BLOCK, key);
24083
+ for (let i2 = 0; i2 < len2 - 1; i2++) {
24084
+ dbl(d);
24085
+ const cmacResult = cmac(strings[i2], key);
24086
+ xorBlock(d, cmacResult);
24087
+ clean(cmacResult);
24088
+ }
24089
+ const s_n = strings[len2 - 1];
24090
+ abytes(s_n);
24091
+ let t;
24092
+ if (s_n.byteLength >= BLOCK_SIZE) {
24093
+ t = xorend(Uint8Array.from(s_n), d);
24094
+ } else {
24095
+ const paddedSn = new Uint8Array(BLOCK_SIZE);
24096
+ paddedSn.set(s_n);
24097
+ paddedSn[s_n.length] = 128;
24098
+ t = xorBlock(dbl(d), paddedSn);
24099
+ clean(paddedSn);
24100
+ }
24101
+ const result = cmac(t, key);
24102
+ clean(d, t);
24103
+ return result;
24104
+ }
24105
+ const unsafe = /* @__PURE__ */ Object.freeze({
24106
+ expandKeyLE,
24107
+ expandKeyDecLE,
24108
+ encrypt,
24109
+ decrypt,
24110
+ encryptBlock,
24111
+ decryptBlock,
24112
+ ctrCounter,
24113
+ ctr32,
24114
+ dbl,
24115
+ xorBlock,
24116
+ xorend,
24117
+ s2v
24118
+ });
24119
+ const CIPHERS = /^aes-(128|192|256)-(gcm|cbc|ctr|ecb)$/u;
24120
+ function cipherNames() {
24121
+ const names2 = [];
24122
+ for (const bits of [128, 192, 256]) for (const mode of ["cbc", "ctr", "ecb", "gcm"]) names2.push(`aes-${bits}-${mode}`);
24123
+ return names2;
24124
+ }
24125
+ const GCM_TAG_LENGTHS = /* @__PURE__ */ new Set([4, 8, 12, 13, 14, 15, 16]);
24126
+ function createCipherClasses(deps) {
24127
+ 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;
24128
+ const { error } = deps;
24129
+ function parse4(algorithm) {
24130
+ if (typeof algorithm !== "string") throw Object.assign(new TypeError('The "cipher" argument must be of type string.'), { code: "ERR_INVALID_ARG_TYPE" });
24131
+ const match = CIPHERS.exec(algorithm.toLowerCase());
24132
+ if (!match) throw error("ERR_CRYPTO_UNKNOWN_CIPHER", "Unknown cipher");
24133
+ return { keyLength: Number(match[1]) / 8, mode: match[2] };
24134
+ }
24135
+ function keyOf(key, keyLength) {
24136
+ const bytes2 = deps.secretKeyBytes(key) ?? deps.bytesOf(key);
24137
+ if (bytes2.length !== keyLength) throw Object.assign(new RangeError("Invalid key length"), { code: "ERR_CRYPTO_INVALID_KEYLEN" });
24138
+ return new Uint8Array(bytes2);
24139
+ }
24140
+ function ivOf(iv, mode) {
24141
+ if (mode === "ecb") {
24142
+ if (iv === null || iv === void 0) return void 0;
24143
+ const bytes22 = deps.bytesOf(iv);
24144
+ if (bytes22.length !== 0) throw Object.assign(new TypeError("Invalid initialization vector"), { code: "ERR_CRYPTO_INVALID_IV" });
24145
+ return void 0;
24146
+ }
24147
+ if (iv === null || iv === void 0) throw Object.assign(new TypeError("Invalid initialization vector"), { code: "ERR_CRYPTO_INVALID_IV" });
24148
+ const bytes2 = new Uint8Array(deps.bytesOf(iv));
24149
+ if (mode === "gcm" ? bytes2.length === 0 : bytes2.length !== 16) throw Object.assign(new TypeError("Invalid initialization vector"), { code: "ERR_CRYPTO_INVALID_IV" });
24150
+ return bytes2;
24151
+ }
24152
+ function encryptBlock2(xk, block) {
24153
+ const out = new Uint8Array(16);
24154
+ out.set(block);
24155
+ return unsafe.encryptBlock(xk, out);
24156
+ }
24157
+ function decryptBlock2(xk, block) {
24158
+ const out = new Uint8Array(16);
24159
+ out.set(block);
24160
+ return unsafe.decryptBlock(xk, out);
24161
+ }
24162
+ function concat(a, b) {
24163
+ if (a.length === 0) return b;
24164
+ if (b.length === 0) return a;
24165
+ const out = new Uint8Array(a.length + b.length);
24166
+ out.set(a);
24167
+ out.set(b, a.length);
24168
+ return out;
24169
+ }
24170
+ function increment(counter, from) {
24171
+ for (let i2 = 15; i2 >= from; i2--) {
24172
+ counter[i2] = counter[i2] + 1 & 255;
24173
+ if (counter[i2] !== 0) return;
24174
+ }
24175
+ }
24176
+ let authTagOf;
24177
+ let expectTagOf;
24178
+ class CipherBase {
24179
+ constructor(decrypt2, algorithm, key, iv, options) {
24180
+ __privateAdd(this, _CipherBase_instances);
24181
+ __privateAdd(this, _decrypt);
24182
+ __privateAdd(this, _mode);
24183
+ __privateAdd(this, _xk);
24184
+ __privateAdd(this, _xkDec);
24185
+ __privateAdd(this, _padding, true);
24186
+ __privateAdd(this, _finished, false);
24187
+ __privateAdd(this, _started, false);
24188
+ /** CBC/ECB: bytes not yet a whole block (and, decrypting with padding, the last whole block). */
24189
+ __privateAdd(this, _pending, new Uint8Array(0));
24190
+ /** CBC's chaining block. */
24191
+ __privateAdd(this, _chain);
24192
+ /** CTR/GCM: the next counter block and what is left of the current keystream block. */
24193
+ __privateAdd(this, _counter);
24194
+ __privateAdd(this, _keystream, new Uint8Array(0));
24195
+ /** GCM. */
24196
+ __privateAdd(this, _ghash);
24197
+ __privateAdd(this, _tagMask);
24198
+ __privateAdd(this, _ghashPending, new Uint8Array(0));
24199
+ __privateAdd(this, _aadLength, 0);
24200
+ __privateAdd(this, _dataLength, 0);
24201
+ __privateAdd(this, _authTagLength);
24202
+ __privateAdd(this, _authTag);
24203
+ const { keyLength, mode } = parse4(algorithm);
24204
+ __privateSet(this, _decrypt, decrypt2);
24205
+ __privateSet(this, _mode, mode);
24206
+ const keyBytes = keyOf(key, keyLength);
24207
+ const ivBytes = ivOf(iv, mode);
24208
+ __privateSet(this, _xk, unsafe.expandKeyLE(keyBytes));
24209
+ __privateSet(this, _xkDec, decrypt2 && (mode === "cbc" || mode === "ecb") ? unsafe.expandKeyDecLE(keyBytes) : void 0);
24210
+ const tagLength = options == null ? void 0 : options.authTagLength;
24211
+ if (tagLength !== void 0) {
24212
+ if (mode !== "gcm") throw Object.assign(new TypeError(`Invalid authentication tag length: ${tagLength}`), { code: "ERR_CRYPTO_INVALID_AUTH_TAG" });
24213
+ if (!GCM_TAG_LENGTHS.has(tagLength)) throw Object.assign(new TypeError(`Invalid authentication tag length: ${tagLength}`), { code: "ERR_CRYPTO_INVALID_AUTH_TAG" });
24214
+ __privateSet(this, _authTagLength, tagLength);
24215
+ }
24216
+ if (mode === "cbc") __privateSet(this, _chain, ivBytes);
24217
+ if (mode === "ctr") __privateSet(this, _counter, new Uint8Array(ivBytes));
24218
+ if (mode === "gcm") {
24219
+ const h = encryptBlock2(__privateGet(this, _xk), new Uint8Array(16));
24220
+ let j0;
24221
+ if (ivBytes.length === 12) {
24222
+ j0 = new Uint8Array(16);
24223
+ j0.set(ivBytes);
24224
+ j0[15] = 1;
24225
+ } else {
24226
+ const lengths = new Uint8Array(16);
24227
+ new DataView(lengths.buffer).setBigUint64(8, BigInt(ivBytes.length * 8), false);
24228
+ const g2 = new GHASH(h);
24229
+ g2.update(ivBytes).update(lengths);
24230
+ j0 = g2.digest();
24231
+ }
24232
+ __privateSet(this, _tagMask, encryptBlock2(__privateGet(this, _xk), j0));
24233
+ __privateSet(this, _counter, new Uint8Array(j0));
24234
+ increment(__privateGet(this, _counter), 12);
24235
+ __privateSet(this, _ghash, new GHASH(h));
24236
+ }
24237
+ }
24238
+ setAutoPadding(autoPadding = true) {
24239
+ if (__privateGet(this, _finished)) throw error("ERR_CRYPTO_INVALID_STATE", "Invalid state for operation setAutoPadding");
24240
+ __privateSet(this, _padding, Boolean(autoPadding));
24241
+ return this;
24242
+ }
24243
+ setAAD(buffer2, _options2) {
24244
+ if (__privateGet(this, _mode) !== "gcm" || __privateGet(this, _started) || __privateGet(this, _finished)) throw error("ERR_CRYPTO_INVALID_STATE", "Invalid state for operation setAAD");
24245
+ const aad = deps.bytesOf(buffer2);
24246
+ __privateGet(this, _ghash).update(aad);
24247
+ __privateSet(this, _aadLength, __privateGet(this, _aadLength) + aad.length);
24248
+ return this;
24249
+ }
24250
+ update(data2, inputEncoding, outputEncoding) {
24251
+ if (__privateGet(this, _finished)) throw error("ERR_CRYPTO_INVALID_STATE", "Invalid state for operation update");
24252
+ __privateSet(this, _started, true);
24253
+ const input = typeof data2 === "string" ? deps.bytesOf(data2, inputEncoding) : deps.bytesOf(data2);
24254
+ return deps.encode(__privateMethod(this, _CipherBase_instances, process_fn).call(this, new Uint8Array(input)), outputEncoding);
24255
+ }
24256
+ final(outputEncoding) {
24257
+ if (__privateGet(this, _finished)) throw error("ERR_CRYPTO_INVALID_STATE", "Unsupported state");
24258
+ __privateSet(this, _finished, true);
24259
+ return deps.encode(__privateMethod(this, _CipherBase_instances, finish_fn).call(this), outputEncoding);
24260
+ }
24261
+ }
24262
+ _decrypt = new WeakMap();
24263
+ _mode = new WeakMap();
24264
+ _xk = new WeakMap();
24265
+ _xkDec = new WeakMap();
24266
+ _padding = new WeakMap();
24267
+ _finished = new WeakMap();
24268
+ _started = new WeakMap();
24269
+ _pending = new WeakMap();
24270
+ _chain = new WeakMap();
24271
+ _counter = new WeakMap();
24272
+ _keystream = new WeakMap();
24273
+ _ghash = new WeakMap();
24274
+ _tagMask = new WeakMap();
24275
+ _ghashPending = new WeakMap();
24276
+ _aadLength = new WeakMap();
24277
+ _dataLength = new WeakMap();
24278
+ _authTagLength = new WeakMap();
24279
+ _authTag = new WeakMap();
24280
+ _CipherBase_instances = new WeakSet();
24281
+ getTag_fn = function() {
24282
+ 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");
24283
+ return __privateGet(this, _authTag);
24284
+ };
24285
+ setTag_fn = function(tag, encoding) {
24286
+ if (__privateGet(this, _mode) !== "gcm" || !__privateGet(this, _decrypt) || __privateGet(this, _finished)) throw error("ERR_CRYPTO_INVALID_STATE", "Invalid state for operation setAuthTag");
24287
+ const bytes2 = new Uint8Array(typeof tag === "string" ? deps.bytesOf(tag, encoding) : deps.bytesOf(tag));
24288
+ const allowed = __privateGet(this, _authTagLength) === void 0 ? GCM_TAG_LENGTHS.has(bytes2.length) : bytes2.length === __privateGet(this, _authTagLength);
24289
+ if (!allowed) throw Object.assign(new TypeError(`Invalid authentication tag length: ${bytes2.length}`), { code: "ERR_CRYPTO_INVALID_AUTH_TAG" });
24290
+ __privateSet(this, _authTag, bytes2);
24291
+ };
24292
+ process_fn = function(input) {
24293
+ switch (__privateGet(this, _mode)) {
24294
+ case "ctr":
24295
+ return __privateMethod(this, _CipherBase_instances, stream_fn).call(this, input);
24296
+ case "gcm": {
24297
+ if (__privateGet(this, _decrypt)) __privateMethod(this, _CipherBase_instances, absorb_fn).call(this, input);
24298
+ const out = __privateMethod(this, _CipherBase_instances, stream_fn).call(this, input);
24299
+ if (!__privateGet(this, _decrypt)) __privateMethod(this, _CipherBase_instances, absorb_fn).call(this, out);
24300
+ __privateSet(this, _dataLength, __privateGet(this, _dataLength) + input.length);
24301
+ return out;
24302
+ }
24303
+ default:
24304
+ return __privateMethod(this, _CipherBase_instances, blocks_fn).call(this, input);
24305
+ }
24306
+ };
24307
+ /** XOR with the counter's keystream, carrying a partial block across calls. */
24308
+ stream_fn = function(input) {
24309
+ const out = new Uint8Array(input.length);
24310
+ let at2 = 0;
24311
+ while (at2 < input.length) {
24312
+ if (__privateGet(this, _keystream).length === 0) {
24313
+ __privateSet(this, _keystream, encryptBlock2(__privateGet(this, _xk), __privateGet(this, _counter)));
24314
+ increment(__privateGet(this, _counter), __privateGet(this, _mode) === "gcm" ? 12 : 0);
24315
+ }
24316
+ const take = Math.min(__privateGet(this, _keystream).length, input.length - at2);
24317
+ for (let i2 = 0; i2 < take; i2++) out[at2 + i2] = input[at2 + i2] ^ __privateGet(this, _keystream)[i2];
24318
+ __privateSet(this, _keystream, __privateGet(this, _keystream).subarray(take));
24319
+ at2 += take;
24320
+ }
24321
+ return out;
24322
+ };
24323
+ /** GHASH over the ciphertext, in whole blocks: GHASH pads each update, so a partial block waits for the next. */
24324
+ absorb_fn = function(ciphertext) {
24325
+ const all = concat(__privateGet(this, _ghashPending), ciphertext);
24326
+ const whole = all.length - all.length % 16;
24327
+ if (whole > 0) __privateGet(this, _ghash).update(all.subarray(0, whole));
24328
+ __privateSet(this, _ghashPending, all.slice(whole));
24329
+ };
24330
+ /** CBC and ECB: every whole block now; decrypting with padding, the last whole block waits for `final`. */
24331
+ blocks_fn = function(input) {
24332
+ const all = concat(__privateGet(this, _pending), input);
24333
+ let whole = all.length - all.length % 16;
24334
+ if (__privateGet(this, _decrypt) && __privateGet(this, _padding) && whole === all.length && whole > 0) whole -= 16;
24335
+ const out = new Uint8Array(whole);
24336
+ for (let at2 = 0; at2 < whole; at2 += 16) out.set(__privateMethod(this, _CipherBase_instances, block_fn).call(this, all.subarray(at2, at2 + 16)), at2);
24337
+ __privateSet(this, _pending, all.slice(whole));
24338
+ return out;
24339
+ };
24340
+ block_fn = function(block) {
24341
+ if (__privateGet(this, _mode) === "ecb") return __privateGet(this, _decrypt) ? decryptBlock2(__privateGet(this, _xkDec), block) : encryptBlock2(__privateGet(this, _xk), block);
24342
+ if (__privateGet(this, _decrypt)) {
24343
+ const plain = decryptBlock2(__privateGet(this, _xkDec), block);
24344
+ for (let i2 = 0; i2 < 16; i2++) plain[i2] = plain[i2] ^ __privateGet(this, _chain)[i2];
24345
+ __privateSet(this, _chain, new Uint8Array(block));
24346
+ return plain;
24347
+ }
24348
+ const mixed = new Uint8Array(16);
24349
+ for (let i2 = 0; i2 < 16; i2++) mixed[i2] = block[i2] ^ __privateGet(this, _chain)[i2];
24350
+ const cipher = encryptBlock2(__privateGet(this, _xk), mixed);
24351
+ __privateSet(this, _chain, cipher);
24352
+ return cipher;
24353
+ };
24354
+ finish_fn = function() {
24355
+ if (__privateGet(this, _mode) === "ctr") return new Uint8Array(0);
24356
+ if (__privateGet(this, _mode) === "gcm") return __privateMethod(this, _CipherBase_instances, finishGcm_fn).call(this);
24357
+ const rest = __privateGet(this, _pending);
24358
+ __privateSet(this, _pending, new Uint8Array(0));
24359
+ if (!__privateGet(this, _decrypt)) {
24360
+ if (!__privateGet(this, _padding)) {
24361
+ if (rest.length !== 0) throw error("ERR_OSSL_WRONG_FINAL_BLOCK_LENGTH", "error:1C80006B:Provider routines::wrong final block length");
24362
+ return rest;
24363
+ }
24364
+ const pad2 = 16 - rest.length;
24365
+ const block = new Uint8Array(16);
24366
+ block.set(rest);
24367
+ block.fill(pad2, rest.length);
24368
+ return __privateMethod(this, _CipherBase_instances, block_fn).call(this, block);
24369
+ }
24370
+ if (!__privateGet(this, _padding)) {
24371
+ if (rest.length !== 0) throw error("ERR_OSSL_WRONG_FINAL_BLOCK_LENGTH", "error:1C80006B:Provider routines::wrong final block length");
24372
+ return rest;
24373
+ }
24374
+ if (rest.length !== 16) throw error("ERR_OSSL_WRONG_FINAL_BLOCK_LENGTH", "error:1C80006B:Provider routines::wrong final block length");
24375
+ const plain = __privateMethod(this, _CipherBase_instances, block_fn).call(this, rest);
24376
+ const pad = plain[15];
24377
+ let valid = pad >= 1 && pad <= 16;
24378
+ for (let i2 = 16 - pad; valid && i2 < 16; i2++) valid = plain[i2] === pad;
24379
+ if (!valid) throw error("ERR_OSSL_BAD_DECRYPT", "error:1C800064:Provider routines::bad decrypt");
24380
+ return plain.slice(0, 16 - pad);
24381
+ };
24382
+ finishGcm_fn = function() {
24383
+ if (__privateGet(this, _ghashPending).length) __privateGet(this, _ghash).update(__privateGet(this, _ghashPending));
24384
+ const lengths = new Uint8Array(16);
24385
+ const view = new DataView(lengths.buffer);
24386
+ view.setBigUint64(0, BigInt(__privateGet(this, _aadLength) * 8), false);
24387
+ view.setBigUint64(8, BigInt(__privateGet(this, _dataLength) * 8), false);
24388
+ const full = __privateGet(this, _ghash).update(lengths).digest();
24389
+ for (let i2 = 0; i2 < 16; i2++) full[i2] = full[i2] ^ __privateGet(this, _tagMask)[i2];
24390
+ if (!__privateGet(this, _decrypt)) {
24391
+ __privateSet(this, _authTag, full.slice(0, __privateGet(this, _authTagLength) ?? 16));
24392
+ return new Uint8Array(0);
24393
+ }
24394
+ const expected = __privateGet(this, _authTag);
24395
+ let same = expected !== void 0;
24396
+ if (expected) for (let i2 = 0; i2 < expected.length; i2++) same = same && full[i2] === expected[i2];
24397
+ if (!same) throw new Error("Unsupported state or unable to authenticate data");
24398
+ return new Uint8Array(0);
24399
+ };
24400
+ authTagOf = (cipher) => {
24401
+ var _a2;
24402
+ return __privateMethod(_a2 = cipher, _CipherBase_instances, getTag_fn).call(_a2);
24403
+ };
24404
+ expectTagOf = (cipher, tag, encoding) => {
24405
+ var _a2;
24406
+ return __privateMethod(_a2 = cipher, _CipherBase_instances, setTag_fn).call(_a2, tag, encoding);
24407
+ };
24408
+ class Cipheriv2 extends CipherBase {
24409
+ constructor(algorithm, key, iv, options) {
24410
+ super(false, algorithm, key, iv, options);
24411
+ }
24412
+ getAuthTag() {
24413
+ return deps.toBuffer(authTagOf(this));
24414
+ }
24415
+ }
24416
+ class Decipheriv2 extends CipherBase {
24417
+ constructor(algorithm, key, iv, options) {
24418
+ super(true, algorithm, key, iv, options);
24419
+ }
24420
+ setAuthTag(tag, encoding) {
24421
+ expectTagOf(this, tag, encoding);
24422
+ return this;
24423
+ }
24424
+ }
24425
+ return {
24426
+ Cipheriv: Cipheriv2,
24427
+ Decipheriv: Decipheriv2,
24428
+ createCipheriv: (algorithm, key, iv, options) => new Cipheriv2(algorithm, key, iv, options),
24429
+ createDecipheriv: (algorithm, key, iv, options) => new Decipheriv2(algorithm, key, iv, options)
24430
+ };
24431
+ }
23452
24432
  function createCryptoModule(require2) {
23453
24433
  var _state, _done, _inner, _outer, _done2, _algorithm, _data, _algorithm2, _data2, __keyData, __type, __algorithm;
23454
24434
  const bufferModule2 = require2 ? require2("buffer") : lazyModule("buffer");
@@ -24028,7 +25008,7 @@ ${body}
24028
25008
  return result === 0;
24029
25009
  }
24030
25010
  function getCiphers2() {
24031
- return ["aes-128-cbc", "aes-256-cbc", "aes-128-gcm", "aes-256-gcm"];
25011
+ return cipherNames();
24032
25012
  }
24033
25013
  function getHashes2() {
24034
25014
  return HASH_ALGORITHMS.slice();
@@ -24149,7 +25129,25 @@ ${body}
24149
25129
  }
24150
25130
  throw new Error(`Unsupported key format: ${keyInfo.format}`);
24151
25131
  }
25132
+ const { Cipheriv: Cipheriv2, Decipheriv: Decipheriv2, createCipheriv: createCipheriv2, createDecipheriv: createDecipheriv2 } = createCipherClasses({
25133
+ toBuffer: (bytes2) => Buffer2.from(bytes2),
25134
+ bytesOf: (value, encoding) => cryptoBytes(value, encoding, true),
25135
+ secretKeyBytes: (value) => {
25136
+ if (!(value instanceof KeyObject2)) return void 0;
25137
+ const info = keyInfoOf(value);
25138
+ if (info.type !== "secret" || !(info.keyData instanceof Uint8Array)) {
25139
+ throw Object.assign(new TypeError(`Invalid key object type ${info.type}, expected secret.`), { code: "ERR_CRYPTO_INVALID_KEY_OBJECT_TYPE" });
25140
+ }
25141
+ return info.keyData;
25142
+ },
25143
+ encode: (bytes2, encoding) => digestResult(bytes2, encoding),
25144
+ error: cryptoError
25145
+ });
24152
25146
  return {
25147
+ Cipheriv: Cipheriv2,
25148
+ Decipheriv: Decipheriv2,
25149
+ createCipheriv: createCipheriv2,
25150
+ createDecipheriv: createDecipheriv2,
24153
25151
  unsupported: unsupported2,
24154
25152
  randomBytes: randomBytes2,
24155
25153
  randomFill: randomFill2,
@@ -24178,12 +25176,16 @@ ${body}
24178
25176
  };
24179
25177
  }
24180
25178
  const cryptoModule = createCryptoModule();
24181
- const { randomBytes, randomFillSync, randomFill, randomUUID, randomInt, getRandomValues, unsupported: unsupported$1, createHash, createHmac, hash, pbkdf2Sync, pbkdf2, sign, verify, createSign, createVerify, KeyObject, createSecretKey, createPublicKey, createPrivateKey, generateKeyPair, timingSafeEqual, getCiphers, getHashes } = cryptoModule;
25179
+ const { Cipheriv, Decipheriv, createCipheriv, createDecipheriv, randomBytes, randomFillSync, randomFill, randomUUID, randomInt, getRandomValues, unsupported: unsupported$1, createHash, createHmac, hash, pbkdf2Sync, pbkdf2, sign, verify, createSign, createVerify, KeyObject, createSecretKey, createPublicKey, createPrivateKey, generateKeyPair, timingSafeEqual, getCiphers, getHashes } = cryptoModule;
24182
25180
  const cryptoShim = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
24183
25181
  __proto__: null,
25182
+ Cipheriv,
25183
+ Decipheriv,
24184
25184
  KeyObject,
24185
25185
  constants: cryptoConstants,
25186
+ createCipheriv,
24186
25187
  createCryptoModule,
25188
+ createDecipheriv,
24187
25189
  createHash,
24188
25190
  createHmac,
24189
25191
  createPrivateKey,
@@ -32833,12 +33835,12 @@ class SHA2_32B extends HashMD {
32833
33835
  this.set(A, B, C, D, E, F, G, H);
32834
33836
  }
32835
33837
  roundClean() {
32836
- clean(SHA256_W);
33838
+ clean$1(SHA256_W);
32837
33839
  }
32838
33840
  destroy() {
32839
33841
  this.destroyed = true;
32840
33842
  this.set(0, 0, 0, 0, 0, 0, 0, 0);
32841
- clean(this.buffer);
33843
+ clean$1(this.buffer);
32842
33844
  }
32843
33845
  }
32844
33846
  class _SHA256 extends SHA2_32B {
@@ -40696,7 +41698,7 @@ class WorkerRuntime {
40696
41698
  this.worker = new Worker(
40697
41699
  new URL(
40698
41700
  /* @vite-ignore */
40699
- "/assets/runtime-worker-C1IV4qnr.js",
41701
+ "/assets/runtime-worker-Cu2mr9G9.js",
40700
41702
  import.meta.url
40701
41703
  ),
40702
41704
  { type: "module" }