@query-farm/vgi 0.25.2 → 0.25.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { list, asDate64Ms } from "./index.js";
1
+ import { dateMillisecond, list, bool, float64, asDate64Ms } from "./index.js";
2
2
  import type { RichValue, RawValue, ValueFor, Date32Type, Date64Type, Int64Type, Int32Type, Utf8Type, BoolType, TimestampType, DecimalType, FloatType, StructType, ListType, TypedField, Date32, TimestampMicros, UnscaledDecimal } from "./index.js";
3
3
  type Expect<T extends true> = T;
4
4
  type Equal<A, B> = (<G>() => G extends A ? 1 : 2) extends (<G>() => G extends B ? 1 : 2) ? true : false;
@@ -43,9 +43,9 @@ export type _AllChecks = [
43
43
  _r15
44
44
  ];
45
45
  export declare const _unusedFactories: {
46
- dateMillisecond: () => Date64Type;
47
- bool: () => BoolType;
48
- float64: () => FloatType;
46
+ dateMillisecond: typeof dateMillisecond;
47
+ bool: typeof bool;
48
+ float64: typeof float64;
49
49
  list: typeof list;
50
50
  asDate64Ms: typeof asDate64Ms;
51
51
  };
package/dist/index.js CHANGED
@@ -8394,45 +8394,48 @@ init_arrow();
8394
8394
  function isBytes(a) {
8395
8395
  return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
8396
8396
  }
8397
- function abool(b) {
8398
- if (typeof b !== "boolean")
8399
- throw new TypeError(`boolean expected, not ${b}`);
8397
+ var atitle = (title) => title ? `"${title}" ` : "";
8398
+ function abool(value, title = "") {
8399
+ if (typeof value !== "boolean")
8400
+ throw new TypeError(atitle(title) + "expected boolean, got type=" + typeof value);
8401
+ return value;
8400
8402
  }
8401
- function anumber(n) {
8403
+ function anumber(n, title = "") {
8402
8404
  if (typeof n !== "number")
8403
- throw new TypeError("number expected, got " + typeof n);
8405
+ throw new TypeError(atitle(title) + "expected number, got " + typeof n);
8404
8406
  if (!Number.isSafeInteger(n) || n < 0)
8405
- throw new RangeError("positive integer expected, got " + n);
8407
+ throw new RangeError(atitle(title) + "expected integer >= 0, got " + n);
8408
+ return n;
8406
8409
  }
8407
8410
  function abytes(value, length, title = "") {
8411
+ if (isBytes(value) && (length === undefined || value.length === length))
8412
+ return value;
8413
+ if (length !== undefined)
8414
+ anumber(length, "length");
8408
8415
  const bytes = isBytes(value);
8409
- const len = value?.length;
8410
- const needsLen = length !== undefined;
8411
- if (!bytes || needsLen && len !== length) {
8412
- const prefix = title && `"${title}" `;
8413
- const ofLen = needsLen ? ` of length ${length}` : "";
8414
- const got = bytes ? `length=${len}` : `type=${typeof value}`;
8415
- const message = prefix + "expected Uint8Array" + ofLen + ", got " + got;
8416
- if (!bytes)
8417
- throw new TypeError(message);
8418
- throw new RangeError(message);
8419
- }
8420
- return value;
8421
- }
8416
+ const ofLen = length !== undefined ? ` of length ${length}` : "";
8417
+ const got = bytes ? `length=${value.length}` : `type=${typeof value}`;
8418
+ const message = atitle(title) + "expected Uint8Array" + ofLen + ", got " + got;
8419
+ if (!bytes)
8420
+ throw new TypeError(message);
8421
+ throw new RangeError(message);
8422
+ }
8423
+ var aobject = (value, label) => {
8424
+ if (value === null || typeof value !== "object" || Array.isArray(value))
8425
+ throw new TypeError(label === "object" ? "expected valid options object" : `"${label}" expected object, got type=${typeof value}`);
8426
+ };
8422
8427
  function aexists(instance, checkFinished = true) {
8423
8428
  if (instance.destroyed)
8424
- throw new Error("Hash instance has been destroyed");
8429
+ throw new Error("hash was destroyed");
8425
8430
  if (checkFinished && instance.finished)
8426
- throw new Error("Hash#digest() has already been called");
8431
+ throw new Error("digest() was already called");
8427
8432
  }
8428
- function aoutput(out, instance, onlyAligned = false) {
8433
+ function aoutput(out, instance) {
8429
8434
  abytes(out, undefined, "output");
8430
8435
  const min = instance.outputLen;
8431
- if (out.length < min) {
8432
- throw new RangeError("digestInto() expects output buffer of length at least " + min);
8436
+ if (!(out.length >= min)) {
8437
+ throw new RangeError('"output" expected length >= ' + min);
8433
8438
  }
8434
- if (onlyAligned && !isAligned32(out))
8435
- throw new Error("invalid output, must be aligned");
8436
8439
  }
8437
8440
  function u32(arr) {
8438
8441
  return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
@@ -8446,21 +8449,25 @@ function createView(arr) {
8446
8449
  return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
8447
8450
  }
8448
8451
  var isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
8449
- var byteSwap = (word) => word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
8450
- var swap8IfBE = isLE ? (n) => n : (n) => byteSwap(n) >>> 0;
8451
- var byteSwap32 = (arr) => {
8452
- for (let i = 0;i < arr.length; i++)
8452
+ function byteSwap(word) {
8453
+ return word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
8454
+ }
8455
+ function byteSwap32(arr) {
8456
+ for (let i = 0;i < arr.length; i++) {
8453
8457
  arr[i] = byteSwap(arr[i]);
8458
+ }
8454
8459
  return arr;
8455
- };
8460
+ }
8456
8461
  var swap32IfBE = isLE ? (u) => u : byteSwap32;
8457
8462
  function checkOpts(defaults, opts) {
8458
- if (opts == null || typeof opts !== "object")
8459
- throw new Error("options must be defined");
8463
+ aobject(defaults, "defaults");
8464
+ aobject(opts, "opts");
8460
8465
  const merged = Object.assign(defaults, opts);
8461
8466
  return merged;
8462
8467
  }
8463
8468
  function equalBytes(a, b) {
8469
+ a = abytes(a);
8470
+ b = abytes(b);
8464
8471
  if (a.length !== b.length)
8465
8472
  return false;
8466
8473
  let diff = 0;
@@ -8486,8 +8493,14 @@ var wrapCipher = (params, constructor) => {
8486
8493
  abytes(nonce, params.varSizeNonce ? undefined : params.nonceLength, "nonce");
8487
8494
  }
8488
8495
  const tagl = params.tagLength;
8489
- if (tagl && args[1] !== undefined)
8490
- abytes(args[1], undefined, "AAD");
8496
+ const aadStart = params.nonceLength !== undefined ? 1 : 0;
8497
+ if (!params.withAAD) {
8498
+ for (let i = aadStart;i < args.length; i++)
8499
+ if (isBytes(args[i]))
8500
+ throw new Error("AAD not supported");
8501
+ }
8502
+ if (params.withAAD && args[aadStart] !== undefined)
8503
+ abytes(args[aadStart], undefined, "AAD");
8491
8504
  const cipher = constructor(key, ...args);
8492
8505
  const checkOutput = (fnLength, output) => {
8493
8506
  if (output !== undefined) {
@@ -8502,14 +8515,14 @@ var wrapCipher = (params, constructor) => {
8502
8515
  if (called)
8503
8516
  throw new Error("cannot encrypt() twice with same key + nonce");
8504
8517
  called = true;
8505
- abytes(data);
8518
+ abytes(data, undefined, "data");
8506
8519
  checkOutput(cipher.encrypt.length, output);
8507
8520
  return cipher.encrypt(data, output);
8508
8521
  },
8509
8522
  decrypt(data, output) {
8510
- abytes(data);
8523
+ abytes(data, undefined, "data");
8511
8524
  if (tagl && data.length < tagl)
8512
- throw new Error('"ciphertext" expected length bigger than tagLength=' + tagl);
8525
+ throw new Error('"ciphertext" expected length >= tagLength=' + tagl);
8513
8526
  checkOutput(cipher.decrypt.length, output);
8514
8527
  return cipher.decrypt(data, output);
8515
8528
  }
@@ -8522,9 +8535,7 @@ var wrapCipher = (params, constructor) => {
8522
8535
  function getOutput(expectedLength, out, onlyAligned = true) {
8523
8536
  if (out === undefined)
8524
8537
  return new Uint8Array(expectedLength);
8525
- abytes(out, undefined, "output");
8526
- if (out.length !== expectedLength)
8527
- throw new Error('"output" expected Uint8Array of length ' + expectedLength + ", got: " + out.length);
8538
+ abytes(out, expectedLength, "output");
8528
8539
  if (onlyAligned && !isAligned32(out))
8529
8540
  throw new Error("invalid output, must be aligned");
8530
8541
  return out;
@@ -8641,7 +8652,7 @@ function createCipher(core, opts) {
8641
8652
  let k32 = u32(k);
8642
8653
  if (extendNonceFn) {
8643
8654
  if (nonce.length !== 24)
8644
- throw new Error(`arx: extended nonce must be 24 bytes`);
8655
+ throw new Error("arx: extended nonce must be 24 bytes");
8645
8656
  const n16 = nonce.subarray(0, 16);
8646
8657
  if (isLE)
8647
8658
  extendNonceFn(sigma, k32, u32(n16), k32);
@@ -8677,6 +8688,7 @@ function createCipher(core, opts) {
8677
8688
  function u8to16(a, i) {
8678
8689
  return a[i++] & 255 | (a[i++] & 255) << 8;
8679
8690
  }
8691
+
8680
8692
  class Poly1305 {
8681
8693
  blockLen = 16;
8682
8694
  outputLen = 16;
@@ -9011,83 +9023,24 @@ function chachaCore(s, k, n, out, cnt, rounds = 20) {
9011
9023
  out[oi++] = y15 + x15 | 0;
9012
9024
  }
9013
9025
  function hchacha(s, k, i, out) {
9014
- let x00 = swap8IfBE(s[0]), x01 = swap8IfBE(s[1]), x02 = swap8IfBE(s[2]), x03 = swap8IfBE(s[3]), x04 = swap8IfBE(k[0]), x05 = swap8IfBE(k[1]), x06 = swap8IfBE(k[2]), x07 = swap8IfBE(k[3]), x08 = swap8IfBE(k[4]), x09 = swap8IfBE(k[5]), x10 = swap8IfBE(k[6]), x11 = swap8IfBE(k[7]), x12 = swap8IfBE(i[0]), x13 = swap8IfBE(i[1]), x14 = swap8IfBE(i[2]), x15 = swap8IfBE(i[3]);
9015
- for (let r = 0;r < 20; r += 2) {
9016
- x00 = x00 + x04 | 0;
9017
- x12 = rotl(x12 ^ x00, 16);
9018
- x08 = x08 + x12 | 0;
9019
- x04 = rotl(x04 ^ x08, 12);
9020
- x00 = x00 + x04 | 0;
9021
- x12 = rotl(x12 ^ x00, 8);
9022
- x08 = x08 + x12 | 0;
9023
- x04 = rotl(x04 ^ x08, 7);
9024
- x01 = x01 + x05 | 0;
9025
- x13 = rotl(x13 ^ x01, 16);
9026
- x09 = x09 + x13 | 0;
9027
- x05 = rotl(x05 ^ x09, 12);
9028
- x01 = x01 + x05 | 0;
9029
- x13 = rotl(x13 ^ x01, 8);
9030
- x09 = x09 + x13 | 0;
9031
- x05 = rotl(x05 ^ x09, 7);
9032
- x02 = x02 + x06 | 0;
9033
- x14 = rotl(x14 ^ x02, 16);
9034
- x10 = x10 + x14 | 0;
9035
- x06 = rotl(x06 ^ x10, 12);
9036
- x02 = x02 + x06 | 0;
9037
- x14 = rotl(x14 ^ x02, 8);
9038
- x10 = x10 + x14 | 0;
9039
- x06 = rotl(x06 ^ x10, 7);
9040
- x03 = x03 + x07 | 0;
9041
- x15 = rotl(x15 ^ x03, 16);
9042
- x11 = x11 + x15 | 0;
9043
- x07 = rotl(x07 ^ x11, 12);
9044
- x03 = x03 + x07 | 0;
9045
- x15 = rotl(x15 ^ x03, 8);
9046
- x11 = x11 + x15 | 0;
9047
- x07 = rotl(x07 ^ x11, 7);
9048
- x00 = x00 + x05 | 0;
9049
- x15 = rotl(x15 ^ x00, 16);
9050
- x10 = x10 + x15 | 0;
9051
- x05 = rotl(x05 ^ x10, 12);
9052
- x00 = x00 + x05 | 0;
9053
- x15 = rotl(x15 ^ x00, 8);
9054
- x10 = x10 + x15 | 0;
9055
- x05 = rotl(x05 ^ x10, 7);
9056
- x01 = x01 + x06 | 0;
9057
- x12 = rotl(x12 ^ x01, 16);
9058
- x11 = x11 + x12 | 0;
9059
- x06 = rotl(x06 ^ x11, 12);
9060
- x01 = x01 + x06 | 0;
9061
- x12 = rotl(x12 ^ x01, 8);
9062
- x11 = x11 + x12 | 0;
9063
- x06 = rotl(x06 ^ x11, 7);
9064
- x02 = x02 + x07 | 0;
9065
- x13 = rotl(x13 ^ x02, 16);
9066
- x08 = x08 + x13 | 0;
9067
- x07 = rotl(x07 ^ x08, 12);
9068
- x02 = x02 + x07 | 0;
9069
- x13 = rotl(x13 ^ x02, 8);
9070
- x08 = x08 + x13 | 0;
9071
- x07 = rotl(x07 ^ x08, 7);
9072
- x03 = x03 + x04 | 0;
9073
- x14 = rotl(x14 ^ x03, 16);
9074
- x09 = x09 + x14 | 0;
9075
- x04 = rotl(x04 ^ x09, 12);
9076
- x03 = x03 + x04 | 0;
9077
- x14 = rotl(x14 ^ x03, 8);
9078
- x09 = x09 + x14 | 0;
9079
- x04 = rotl(x04 ^ x09, 7);
9080
- }
9026
+ const s2 = isLE ? s : swap32IfBE(s.slice(0, 4));
9027
+ const k2 = isLE ? k : swap32IfBE(k.slice(0, 8));
9028
+ const i2 = isLE ? i : swap32IfBE(i.slice(0, 4));
9029
+ const t = new Uint32Array(16);
9030
+ chachaCore(s2, k2, i2.subarray(1), t, i2[0]);
9081
9031
  let oi = 0;
9082
- out[oi++] = x00;
9083
- out[oi++] = x01;
9084
- out[oi++] = x02;
9085
- out[oi++] = x03;
9086
- out[oi++] = x12;
9087
- out[oi++] = x13;
9088
- out[oi++] = x14;
9089
- out[oi++] = x15;
9032
+ out[oi++] = t[0] - s2[0] | 0;
9033
+ out[oi++] = t[1] - s2[1] | 0;
9034
+ out[oi++] = t[2] - s2[2] | 0;
9035
+ out[oi++] = t[3] - s2[3] | 0;
9036
+ out[oi++] = t[12] - i2[0] | 0;
9037
+ out[oi++] = t[13] - i2[1] | 0;
9038
+ out[oi++] = t[14] - i2[2] | 0;
9039
+ out[oi++] = t[15] - i2[3] | 0;
9090
9040
  swap32IfBE(out);
9041
+ if (!isLE)
9042
+ clean(s2, k2, i2);
9043
+ clean(t);
9091
9044
  }
9092
9045
  var xchacha20 = /* @__PURE__ */ createCipher(chachaCore, {
9093
9046
  counterRight: false,
@@ -9147,7 +9100,7 @@ var _poly1305_aead = (xorStream) => (key, nonce, AAD) => {
9147
9100
  }
9148
9101
  };
9149
9102
  };
9150
- var xchacha20poly1305 = /* @__PURE__ */ wrapCipher({ blockSize: 64, nonceLength: 24, tagLength: 16 }, /* @__PURE__ */ _poly1305_aead(xchacha20));
9103
+ var xchacha20poly1305 = /* @__PURE__ */ wrapCipher({ blockSize: 64, nonceLength: 24, tagLength: 16, withAAD: true }, /* @__PURE__ */ _poly1305_aead(xchacha20));
9151
9104
 
9152
9105
  // src/crypto.ts
9153
9106
  var _UTF8 = new TextEncoder;
@@ -11812,4 +11765,4 @@ export {
11812
11765
  ArgumentValidationError
11813
11766
  };
11814
11767
 
11815
- //# debugId=DE208C45586A782664756E2164756E21
11768
+ //# debugId=A73B01C43FCD566E64756E2164756E21