@tinycloud/cli 0.9.1-beta.8 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,7 +37,7 @@ import {
37
37
  tinycloudConfigPath,
38
38
  tinycloudHomePath
39
39
  } from "@tinycloud/operations/state";
40
- var CONFIG_DIR, PROFILES_DIR, CONFIG_FILE, DEFAULT_HOST, DEFAULT_OPENKEY_HOST, DEFAULT_OPENKEY_DEVICE_API_HOST, DEFAULT_PROFILE, DEFAULT_CHAIN_ID, ExitCode;
40
+ var CONFIG_DIR, PROFILES_DIR, CONFIG_FILE, DEFAULT_HOST, DEFAULT_OPENKEY_HOST, DEFAULT_PROFILE, DEFAULT_CHAIN_ID, ExitCode;
41
41
  var init_constants = __esm({
42
42
  "src/config/constants.ts"() {
43
43
  "use strict";
@@ -46,7 +46,6 @@ var init_constants = __esm({
46
46
  CONFIG_FILE = tinycloudConfigPath();
47
47
  DEFAULT_HOST = "https://node.tinycloud.xyz";
48
48
  DEFAULT_OPENKEY_HOST = "https://openkey.so";
49
- DEFAULT_OPENKEY_DEVICE_API_HOST = "https://api.openkey.so";
50
49
  DEFAULT_PROFILE = "default";
51
50
  DEFAULT_CHAIN_ID = 1;
52
51
  ExitCode = {
@@ -219,13 +218,6 @@ function formatTable(headers, rows) {
219
218
  );
220
219
  return [headerLine, separator, ...dataLines].join("\n");
221
220
  }
222
- function output(data, humanFormatter) {
223
- if (shouldOutputJson() || !humanFormatter) {
224
- outputJson(data);
225
- } else {
226
- process.stdout.write(humanFormatter() + "\n");
227
- }
228
- }
229
221
  function formatCheck(ok2, label, detail) {
230
222
  const icon = ok2 === "warn" ? theme.warn("\u26A0") : ok2 ? theme.success("\u2713") : theme.error("\u2717");
231
223
  const detailStr = detail ? ` ${theme.muted(`(${detail})`)}` : "";
@@ -376,14 +368,17 @@ var init_errors = __esm({
376
368
  this.metadata = metadata;
377
369
  this.name = "CLIError";
378
370
  }
371
+ code;
372
+ exitCode;
373
+ metadata;
379
374
  };
380
375
  }
381
376
  });
382
377
 
383
- // ../../node_modules/zod/v3/helpers/util.js
378
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/helpers/util.js
384
379
  var util, objectUtil, ZodParsedType, getParsedType;
385
380
  var init_util = __esm({
386
- "../../node_modules/zod/v3/helpers/util.js"() {
381
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/helpers/util.js"() {
387
382
  "use strict";
388
383
  (function(util3) {
389
384
  util3.assertEqual = (_) => {
@@ -415,10 +410,10 @@ var init_util = __esm({
415
410
  return obj[e];
416
411
  });
417
412
  };
418
- util3.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object2) => {
413
+ util3.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
419
414
  const keys = [];
420
- for (const key in object2) {
421
- if (Object.prototype.hasOwnProperty.call(object2, key)) {
415
+ for (const key in object) {
416
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
422
417
  keys.push(key);
423
418
  }
424
419
  }
@@ -518,10 +513,10 @@ var init_util = __esm({
518
513
  }
519
514
  });
520
515
 
521
- // ../../node_modules/zod/v3/ZodError.js
516
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/ZodError.js
522
517
  var ZodIssueCode, quotelessJson, ZodError;
523
518
  var init_ZodError = __esm({
524
- "../../node_modules/zod/v3/ZodError.js"() {
519
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/ZodError.js"() {
525
520
  "use strict";
526
521
  init_util();
527
522
  ZodIssueCode = util.arrayToEnum([
@@ -643,10 +638,10 @@ var init_ZodError = __esm({
643
638
  }
644
639
  });
645
640
 
646
- // ../../node_modules/zod/v3/locales/en.js
641
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/locales/en.js
647
642
  var errorMap, en_default;
648
643
  var init_en = __esm({
649
- "../../node_modules/zod/v3/locales/en.js"() {
644
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/locales/en.js"() {
650
645
  "use strict";
651
646
  init_ZodError();
652
647
  init_util();
@@ -754,7 +749,7 @@ var init_en = __esm({
754
749
  }
755
750
  });
756
751
 
757
- // ../../node_modules/zod/v3/errors.js
752
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/errors.js
758
753
  function setErrorMap(map) {
759
754
  overrideErrorMap = map;
760
755
  }
@@ -763,14 +758,14 @@ function getErrorMap() {
763
758
  }
764
759
  var overrideErrorMap;
765
760
  var init_errors2 = __esm({
766
- "../../node_modules/zod/v3/errors.js"() {
761
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/errors.js"() {
767
762
  "use strict";
768
763
  init_en();
769
764
  overrideErrorMap = en_default;
770
765
  }
771
766
  });
772
767
 
773
- // ../../node_modules/zod/v3/helpers/parseUtil.js
768
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/helpers/parseUtil.js
774
769
  function addIssueToContext(ctx, issueData) {
775
770
  const overrideMap = getErrorMap();
776
771
  const issue = makeIssue({
@@ -792,7 +787,7 @@ function addIssueToContext(ctx, issueData) {
792
787
  }
793
788
  var makeIssue, EMPTY_PATH, ParseStatus, INVALID, DIRTY, OK, isAborted, isDirty, isValid, isAsync;
794
789
  var init_parseUtil = __esm({
795
- "../../node_modules/zod/v3/helpers/parseUtil.js"() {
790
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/helpers/parseUtil.js"() {
796
791
  "use strict";
797
792
  init_errors2();
798
793
  init_en();
@@ -888,17 +883,17 @@ var init_parseUtil = __esm({
888
883
  }
889
884
  });
890
885
 
891
- // ../../node_modules/zod/v3/helpers/typeAliases.js
886
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/helpers/typeAliases.js
892
887
  var init_typeAliases = __esm({
893
- "../../node_modules/zod/v3/helpers/typeAliases.js"() {
888
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/helpers/typeAliases.js"() {
894
889
  "use strict";
895
890
  }
896
891
  });
897
892
 
898
- // ../../node_modules/zod/v3/helpers/errorUtil.js
893
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/helpers/errorUtil.js
899
894
  var errorUtil;
900
895
  var init_errorUtil = __esm({
901
- "../../node_modules/zod/v3/helpers/errorUtil.js"() {
896
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/helpers/errorUtil.js"() {
902
897
  "use strict";
903
898
  (function(errorUtil3) {
904
899
  errorUtil3.errToObj = (message) => typeof message === "string" ? { message } : message || {};
@@ -907,7 +902,7 @@ var init_errorUtil = __esm({
907
902
  }
908
903
  });
909
904
 
910
- // ../../node_modules/zod/v3/types.js
905
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/types.js
911
906
  function processCreateParams(params) {
912
907
  if (!params)
913
908
  return {};
@@ -1101,7 +1096,7 @@ function custom(check, _params = {}, fatal) {
1101
1096
  }
1102
1097
  var ParseInputLazyPath, handleResult, ZodType, cuidRegex, cuid2Regex, ulidRegex, uuidRegex, nanoidRegex, jwtRegex, durationRegex, emailRegex, _emojiRegex, emojiRegex, ipv4Regex, ipv4CidrRegex, ipv6Regex, ipv6CidrRegex, base64Regex, base64urlRegex, dateRegexSource, dateRegex, ZodString, ZodNumber, ZodBigInt, ZodBoolean, ZodDate, ZodSymbol, ZodUndefined, ZodNull, ZodAny, ZodUnknown, ZodNever, ZodVoid, ZodArray, ZodObject, ZodUnion, getDiscriminator, ZodDiscriminatedUnion, ZodIntersection, ZodTuple, ZodRecord, ZodMap, ZodSet, ZodFunction, ZodLazy, ZodLiteral, ZodEnum, ZodNativeEnum, ZodPromise, ZodEffects, ZodOptional, ZodNullable, ZodDefault, ZodCatch, ZodNaN, BRAND, ZodBranded, ZodPipeline, ZodReadonly, late, ZodFirstPartyTypeKind, instanceOfType, stringType, numberType, nanType, bigIntType, booleanType, dateType, symbolType, undefinedType, nullType, anyType, unknownType, neverType, voidType, arrayType, objectType, strictObjectType, unionType, discriminatedUnionType, intersectionType, tupleType, recordType, mapType, setType, functionType, lazyType, literalType, enumType, nativeEnumType, promiseType, effectsType, optionalType, nullableType, preprocessType, pipelineType, ostring, onumber, oboolean, coerce, NEVER;
1103
1098
  var init_types = __esm({
1104
- "../../node_modules/zod/v3/types.js"() {
1099
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/types.js"() {
1105
1100
  "use strict";
1106
1101
  init_ZodError();
1107
1102
  init_errors2();
@@ -4364,7 +4359,7 @@ var init_types = __esm({
4364
4359
  }
4365
4360
  });
4366
4361
 
4367
- // ../../node_modules/zod/v3/external.js
4362
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/external.js
4368
4363
  var external_exports = {};
4369
4364
  __export(external_exports, {
4370
4365
  BRAND: () => BRAND,
@@ -4476,7 +4471,7 @@ __export(external_exports, {
4476
4471
  void: () => voidType
4477
4472
  });
4478
4473
  var init_external = __esm({
4479
- "../../node_modules/zod/v3/external.js"() {
4474
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/external.js"() {
4480
4475
  "use strict";
4481
4476
  init_errors2();
4482
4477
  init_parseUtil();
@@ -4487,26 +4482,26 @@ var init_external = __esm({
4487
4482
  }
4488
4483
  });
4489
4484
 
4490
- // ../../node_modules/zod/index.js
4485
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/index.js
4491
4486
  var init_zod = __esm({
4492
- "../../node_modules/zod/index.js"() {
4487
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/index.js"() {
4493
4488
  "use strict";
4494
4489
  init_external();
4495
4490
  init_external();
4496
4491
  }
4497
4492
  });
4498
4493
 
4499
- // ../../node_modules/@noble/hashes/esm/cryptoNode.js
4494
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/hashes/esm/cryptoNode.js
4500
4495
  import * as nc from "crypto";
4501
4496
  var crypto2;
4502
4497
  var init_cryptoNode = __esm({
4503
- "../../node_modules/@noble/hashes/esm/cryptoNode.js"() {
4498
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/hashes/esm/cryptoNode.js"() {
4504
4499
  "use strict";
4505
4500
  crypto2 = nc && typeof nc === "object" && "webcrypto" in nc ? nc.webcrypto : nc && typeof nc === "object" && "randomBytes" in nc ? nc : void 0;
4506
4501
  }
4507
4502
  });
4508
4503
 
4509
- // ../../node_modules/@noble/hashes/esm/utils.js
4504
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/hashes/esm/utils.js
4510
4505
  function isBytes(a) {
4511
4506
  return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
4512
4507
  }
@@ -4539,9 +4534,6 @@ function aoutput(out, instance) {
4539
4534
  throw new Error("digestInto() expects output buffer of length at least " + min);
4540
4535
  }
4541
4536
  }
4542
- function u8(arr) {
4543
- return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
4544
- }
4545
4537
  function u32(arr) {
4546
4538
  return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
4547
4539
  }
@@ -4569,11 +4561,11 @@ function bytesToHex(bytes) {
4569
4561
  abytes(bytes);
4570
4562
  if (hasHexBuiltin)
4571
4563
  return bytes.toHex();
4572
- let hex2 = "";
4564
+ let hex = "";
4573
4565
  for (let i = 0; i < bytes.length; i++) {
4574
- hex2 += hexes[bytes[i]];
4566
+ hex += hexes[bytes[i]];
4575
4567
  }
4576
- return hex2;
4568
+ return hex;
4577
4569
  }
4578
4570
  function asciiToBase16(ch) {
4579
4571
  if (ch >= asciis._0 && ch <= asciis._9)
@@ -4584,21 +4576,21 @@ function asciiToBase16(ch) {
4584
4576
  return ch - (asciis.a - 10);
4585
4577
  return;
4586
4578
  }
4587
- function hexToBytes(hex2) {
4588
- if (typeof hex2 !== "string")
4589
- throw new Error("hex string expected, got " + typeof hex2);
4579
+ function hexToBytes(hex) {
4580
+ if (typeof hex !== "string")
4581
+ throw new Error("hex string expected, got " + typeof hex);
4590
4582
  if (hasHexBuiltin)
4591
- return Uint8Array.fromHex(hex2);
4592
- const hl = hex2.length;
4583
+ return Uint8Array.fromHex(hex);
4584
+ const hl = hex.length;
4593
4585
  const al = hl / 2;
4594
4586
  if (hl % 2)
4595
4587
  throw new Error("hex string expected, got unpadded hex of length " + hl);
4596
4588
  const array = new Uint8Array(al);
4597
4589
  for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
4598
- const n1 = asciiToBase16(hex2.charCodeAt(hi));
4599
- const n2 = asciiToBase16(hex2.charCodeAt(hi + 1));
4590
+ const n1 = asciiToBase16(hex.charCodeAt(hi));
4591
+ const n2 = asciiToBase16(hex.charCodeAt(hi + 1));
4600
4592
  if (n1 === void 0 || n2 === void 0) {
4601
- const char = hex2[hi] + hex2[hi + 1];
4593
+ const char = hex[hi] + hex[hi + 1];
4602
4594
  throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
4603
4595
  }
4604
4596
  array[ai] = n1 * 16 + n2;
@@ -4639,14 +4631,6 @@ function createHasher(hashCons) {
4639
4631
  hashC.create = () => hashCons();
4640
4632
  return hashC;
4641
4633
  }
4642
- function createXOFer(hashCons) {
4643
- const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
4644
- const tmp = hashCons({});
4645
- hashC.outputLen = tmp.outputLen;
4646
- hashC.blockLen = tmp.blockLen;
4647
- hashC.create = (opts) => hashCons(opts);
4648
- return hashC;
4649
- }
4650
4634
  function randomBytes(bytesLength = 32) {
4651
4635
  if (crypto2 && typeof crypto2.getRandomValues === "function") {
4652
4636
  return crypto2.getRandomValues(new Uint8Array(bytesLength));
@@ -4656,13 +4640,12 @@ function randomBytes(bytesLength = 32) {
4656
4640
  }
4657
4641
  throw new Error("crypto.getRandomValues must be defined");
4658
4642
  }
4659
- var isLE, swap8IfBE, swap32IfBE, hasHexBuiltin, hexes, asciis, Hash;
4643
+ var isLE, swap32IfBE, hasHexBuiltin, hexes, asciis, Hash;
4660
4644
  var init_utils = __esm({
4661
- "../../node_modules/@noble/hashes/esm/utils.js"() {
4645
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/hashes/esm/utils.js"() {
4662
4646
  "use strict";
4663
4647
  init_cryptoNode();
4664
4648
  isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
4665
- swap8IfBE = isLE ? (n) => n : (n) => byteSwap(n);
4666
4649
  swap32IfBE = isLE ? (u) => u : byteSwap32;
4667
4650
  hasHexBuiltin = /* @__PURE__ */ (() => (
4668
4651
  // @ts-ignore
@@ -4675,7 +4658,7 @@ var init_utils = __esm({
4675
4658
  }
4676
4659
  });
4677
4660
 
4678
- // ../../node_modules/@noble/hashes/esm/_md.js
4661
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/hashes/esm/_md.js
4679
4662
  function setBigUint64(view, byteOffset, value, isLE2) {
4680
4663
  if (typeof view.setBigUint64 === "function")
4681
4664
  return view.setBigUint64(byteOffset, value, isLE2);
@@ -4696,7 +4679,7 @@ function Maj(a, b, c) {
4696
4679
  }
4697
4680
  var HashMD, SHA256_IV, SHA512_IV;
4698
4681
  var init_md = __esm({
4699
- "../../node_modules/@noble/hashes/esm/_md.js"() {
4682
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/hashes/esm/_md.js"() {
4700
4683
  "use strict";
4701
4684
  init_utils();
4702
4685
  HashMD = class extends Hash {
@@ -4820,7 +4803,7 @@ var init_md = __esm({
4820
4803
  }
4821
4804
  });
4822
4805
 
4823
- // ../../node_modules/@noble/hashes/esm/_u64.js
4806
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/hashes/esm/_u64.js
4824
4807
  function fromBig(n, le = false) {
4825
4808
  if (le)
4826
4809
  return { h: Number(n & U32_MASK64), l: Number(n >> _32n & U32_MASK64) };
@@ -4842,7 +4825,7 @@ function add(Ah, Al, Bh, Bl) {
4842
4825
  }
4843
4826
  var U32_MASK64, _32n, shrSH, shrSL, rotrSH, rotrSL, rotrBH, rotrBL, rotlSH, rotlSL, rotlBH, rotlBL, add3L, add3H, add4L, add4H, add5L, add5H;
4844
4827
  var init_u64 = __esm({
4845
- "../../node_modules/@noble/hashes/esm/_u64.js"() {
4828
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/hashes/esm/_u64.js"() {
4846
4829
  "use strict";
4847
4830
  U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
4848
4831
  _32n = /* @__PURE__ */ BigInt(32);
@@ -4865,10 +4848,10 @@ var init_u64 = __esm({
4865
4848
  }
4866
4849
  });
4867
4850
 
4868
- // ../../node_modules/@noble/hashes/esm/sha2.js
4851
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/hashes/esm/sha2.js
4869
4852
  var SHA256_K, SHA256_W, SHA256, K512, SHA512_Kh, SHA512_Kl, SHA512_W_H, SHA512_W_L, SHA512, sha256, sha512;
4870
4853
  var init_sha2 = __esm({
4871
- "../../node_modules/@noble/hashes/esm/sha2.js"() {
4854
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/hashes/esm/sha2.js"() {
4872
4855
  "use strict";
4873
4856
  init_md();
4874
4857
  init_u64();
@@ -5212,7 +5195,7 @@ var init_sha2 = __esm({
5212
5195
  }
5213
5196
  });
5214
5197
 
5215
- // ../../node_modules/@noble/curves/esm/utils.js
5198
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/curves/esm/utils.js
5216
5199
  function _abool2(value, title = "") {
5217
5200
  if (typeof value !== "boolean") {
5218
5201
  const prefix = title && `"${title}"`;
@@ -5232,10 +5215,10 @@ function _abytes2(value, length4, title = "") {
5232
5215
  }
5233
5216
  return value;
5234
5217
  }
5235
- function hexToNumber(hex2) {
5236
- if (typeof hex2 !== "string")
5237
- throw new Error("hex string expected, got " + typeof hex2);
5238
- return hex2 === "" ? _0n : BigInt("0x" + hex2);
5218
+ function hexToNumber(hex) {
5219
+ if (typeof hex !== "string")
5220
+ throw new Error("hex string expected, got " + typeof hex);
5221
+ return hex === "" ? _0n : BigInt("0x" + hex);
5239
5222
  }
5240
5223
  function bytesToNumberBE(bytes) {
5241
5224
  return hexToNumber(bytesToHex(bytes));
@@ -5250,16 +5233,16 @@ function numberToBytesBE(n, len) {
5250
5233
  function numberToBytesLE(n, len) {
5251
5234
  return numberToBytesBE(n, len).reverse();
5252
5235
  }
5253
- function ensureBytes(title, hex2, expectedLength) {
5236
+ function ensureBytes(title, hex, expectedLength) {
5254
5237
  let res;
5255
- if (typeof hex2 === "string") {
5238
+ if (typeof hex === "string") {
5256
5239
  try {
5257
- res = hexToBytes(hex2);
5240
+ res = hexToBytes(hex);
5258
5241
  } catch (e) {
5259
5242
  throw new Error(title + " must be hex string or Uint8Array, cause: " + e);
5260
5243
  }
5261
- } else if (isBytes(hex2)) {
5262
- res = Uint8Array.from(hex2);
5244
+ } else if (isBytes(hex)) {
5245
+ res = Uint8Array.from(hex);
5263
5246
  } else {
5264
5247
  throw new Error(title + " must be hex string or Uint8Array");
5265
5248
  }
@@ -5292,11 +5275,11 @@ function bitLen(n) {
5292
5275
  ;
5293
5276
  return len;
5294
5277
  }
5295
- function _validateObject(object2, fields, optFields = {}) {
5296
- if (!object2 || typeof object2 !== "object")
5278
+ function _validateObject(object, fields, optFields = {}) {
5279
+ if (!object || typeof object !== "object")
5297
5280
  throw new Error("expected valid options object");
5298
5281
  function checkField(fieldName, expectedType, isOpt) {
5299
- const val = object2[fieldName];
5282
+ const val = object[fieldName];
5300
5283
  if (isOpt && val === void 0)
5301
5284
  return;
5302
5285
  const current = typeof val;
@@ -5319,7 +5302,7 @@ function memoized(fn) {
5319
5302
  }
5320
5303
  var _0n, _1n, isPosBig, bitMask, notImplemented;
5321
5304
  var init_utils2 = __esm({
5322
- "../../node_modules/@noble/curves/esm/utils.js"() {
5305
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/curves/esm/utils.js"() {
5323
5306
  "use strict";
5324
5307
  init_utils();
5325
5308
  init_utils();
@@ -5333,7 +5316,7 @@ var init_utils2 = __esm({
5333
5316
  }
5334
5317
  });
5335
5318
 
5336
- // ../../node_modules/@noble/curves/esm/abstract/modular.js
5319
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/curves/esm/abstract/modular.js
5337
5320
  function mod(a, b) {
5338
5321
  const result = a % b;
5339
5322
  return result >= _0n2 ? result : b + result;
@@ -5630,7 +5613,7 @@ function Field(ORDER, bitLenOrOpts, isLE2 = false, opts = {}) {
5630
5613
  }
5631
5614
  var _0n2, _1n2, _2n, _3n, _4n, _5n, _7n, _8n, _9n, _16n, isNegativeLE, FIELD_FIELDS;
5632
5615
  var init_modular = __esm({
5633
- "../../node_modules/@noble/curves/esm/abstract/modular.js"() {
5616
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/curves/esm/abstract/modular.js"() {
5634
5617
  "use strict";
5635
5618
  init_utils2();
5636
5619
  _0n2 = BigInt(0);
@@ -5666,7 +5649,7 @@ var init_modular = __esm({
5666
5649
  }
5667
5650
  });
5668
5651
 
5669
- // ../../node_modules/@noble/curves/esm/abstract/curve.js
5652
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/curves/esm/abstract/curve.js
5670
5653
  function negateCt(condition, item) {
5671
5654
  const neg = item.negate();
5672
5655
  return condition ? neg : item;
@@ -5799,7 +5782,7 @@ function _createCurveFields(type, CURVE, curveOpts = {}, FpFnLE) {
5799
5782
  }
5800
5783
  var _0n3, _1n3, pointPrecomputes, pointWindowSizes, wNAF;
5801
5784
  var init_curve = __esm({
5802
- "../../node_modules/@noble/curves/esm/abstract/curve.js"() {
5785
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/curves/esm/abstract/curve.js"() {
5803
5786
  "use strict";
5804
5787
  init_utils2();
5805
5788
  init_modular();
@@ -5937,7 +5920,7 @@ var init_curve = __esm({
5937
5920
  }
5938
5921
  });
5939
5922
 
5940
- // ../../node_modules/@noble/curves/esm/abstract/edwards.js
5923
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/curves/esm/abstract/edwards.js
5941
5924
  function isEdValidXY(Fp2, CURVE, x, y) {
5942
5925
  const x2 = Fp2.sqr(x);
5943
5926
  const y2 = Fp2.sqr(y);
@@ -6233,7 +6216,7 @@ function eddsa(Point2, cHash, eddsaOpts = {}) {
6233
6216
  });
6234
6217
  const { prehash } = eddsaOpts;
6235
6218
  const { BASE, Fp: Fp2, Fn: Fn2 } = Point2;
6236
- const randomBytes6 = eddsaOpts.randomBytes || randomBytes;
6219
+ const randomBytes5 = eddsaOpts.randomBytes || randomBytes;
6237
6220
  const adjustScalarBytes2 = eddsaOpts.adjustScalarBytes || ((bytes) => bytes);
6238
6221
  const domain = eddsaOpts.domain || ((data, ctx, phflag) => {
6239
6222
  _abool2(phflag, "phflag");
@@ -6315,7 +6298,7 @@ function eddsa(Point2, cHash, eddsaOpts = {}) {
6315
6298
  signature: 2 * _size,
6316
6299
  seed: _size
6317
6300
  };
6318
- function randomSecretKey(seed = randomBytes6(lengths.seed)) {
6301
+ function randomSecretKey(seed = randomBytes5(lengths.seed)) {
6319
6302
  return _abytes2(seed, lengths.seed, "seed");
6320
6303
  }
6321
6304
  function keygen(seed) {
@@ -6418,7 +6401,7 @@ function twistedEdwards(c) {
6418
6401
  }
6419
6402
  var _0n4, _1n4, _2n2, _8n2, PrimeEdwardsPoint;
6420
6403
  var init_edwards = __esm({
6421
- "../../node_modules/@noble/curves/esm/abstract/edwards.js"() {
6404
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/curves/esm/abstract/edwards.js"() {
6422
6405
  "use strict";
6423
6406
  init_utils2();
6424
6407
  init_curve();
@@ -6497,7 +6480,7 @@ var init_edwards = __esm({
6497
6480
  }
6498
6481
  });
6499
6482
 
6500
- // ../../node_modules/@noble/curves/esm/ed25519.js
6483
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/curves/esm/ed25519.js
6501
6484
  function ed25519_pow_2_252_3(x) {
6502
6485
  const _10n = BigInt(10), _20n = BigInt(20), _40n = BigInt(40), _80n = BigInt(80);
6503
6486
  const P = ed25519_CURVE_p;
@@ -6575,7 +6558,7 @@ function ristretto255_map(bytes) {
6575
6558
  }
6576
6559
  var _0n5, _1n5, _2n3, _3n2, _5n2, _8n3, ed25519_CURVE_p, ed25519_CURVE, ED25519_SQRT_M1, Fp, Fn, ed25519Defaults, ed25519, SQRT_M1, SQRT_AD_MINUS_ONE, INVSQRT_A_MINUS_D, ONE_MINUS_D_SQ, D_MINUS_ONE_SQ, invertSqrt, MAX_255B, bytes255ToNumberLE, _RistrettoPoint;
6577
6560
  var init_ed25519 = __esm({
6578
- "../../node_modules/@noble/curves/esm/ed25519.js"() {
6561
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/curves/esm/ed25519.js"() {
6579
6562
  "use strict";
6580
6563
  init_sha2();
6581
6564
  init_utils();
@@ -6636,8 +6619,8 @@ var init_ed25519 = __esm({
6636
6619
  return new __RistrettoPoint(ep);
6637
6620
  }
6638
6621
  /** @deprecated use `import { ristretto255_hasher } from '@noble/curves/ed25519.js';` */
6639
- static hashToCurve(hex2) {
6640
- return ristretto255_map(ensureBytes("ristrettoHash", hex2, 64));
6622
+ static hashToCurve(hex) {
6623
+ return ristretto255_map(ensureBytes("ristrettoHash", hex, 64));
6641
6624
  }
6642
6625
  static fromBytes(bytes) {
6643
6626
  abytes(bytes, 32);
@@ -6670,8 +6653,8 @@ var init_ed25519 = __esm({
6670
6653
  * Described in [RFC9496](https://www.rfc-editor.org/rfc/rfc9496#name-decode).
6671
6654
  * @param hex Ristretto-encoded 32 bytes. Not every 32-byte string is valid ristretto encoding
6672
6655
  */
6673
- static fromHex(hex2) {
6674
- return __RistrettoPoint.fromBytes(ensureBytes("ristrettoHex", hex2, 32));
6656
+ static fromHex(hex) {
6657
+ return __RistrettoPoint.fromBytes(ensureBytes("ristrettoHex", hex, 32));
6675
6658
  }
6676
6659
  static msm(points, scalars) {
6677
6660
  return pippenger(__RistrettoPoint, ed25519.Point.Fn, points, scalars);
@@ -6732,7 +6715,7 @@ var init_ed25519 = __esm({
6732
6715
  }
6733
6716
  });
6734
6717
 
6735
- // ../../node_modules/viem/_esm/utils/data/isHex.js
6718
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/data/isHex.js
6736
6719
  function isHex(value, { strict = true } = {}) {
6737
6720
  if (!value)
6738
6721
  return false;
@@ -6741,34 +6724,34 @@ function isHex(value, { strict = true } = {}) {
6741
6724
  return strict ? /^0x[0-9a-fA-F]*$/.test(value) : value.startsWith("0x");
6742
6725
  }
6743
6726
  var init_isHex = __esm({
6744
- "../../node_modules/viem/_esm/utils/data/isHex.js"() {
6727
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/data/isHex.js"() {
6745
6728
  "use strict";
6746
6729
  }
6747
6730
  });
6748
6731
 
6749
- // ../../node_modules/viem/_esm/utils/data/size.js
6732
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/data/size.js
6750
6733
  function size(value) {
6751
6734
  if (isHex(value, { strict: false }))
6752
6735
  return Math.ceil((value.length - 2) / 2);
6753
6736
  return value.length;
6754
6737
  }
6755
6738
  var init_size = __esm({
6756
- "../../node_modules/viem/_esm/utils/data/size.js"() {
6739
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/data/size.js"() {
6757
6740
  "use strict";
6758
6741
  init_isHex();
6759
6742
  }
6760
6743
  });
6761
6744
 
6762
- // ../../node_modules/viem/_esm/errors/version.js
6745
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/errors/version.js
6763
6746
  var version;
6764
6747
  var init_version = __esm({
6765
- "../../node_modules/viem/_esm/errors/version.js"() {
6748
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/errors/version.js"() {
6766
6749
  "use strict";
6767
- version = "2.45.1";
6750
+ version = "2.56.8";
6768
6751
  }
6769
6752
  });
6770
6753
 
6771
- // ../../node_modules/viem/_esm/errors/base.js
6754
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/errors/base.js
6772
6755
  function walk(err2, fn) {
6773
6756
  if (fn?.(err2))
6774
6757
  return err2;
@@ -6778,7 +6761,7 @@ function walk(err2, fn) {
6778
6761
  }
6779
6762
  var errorConfig, BaseError;
6780
6763
  var init_base = __esm({
6781
- "../../node_modules/viem/_esm/errors/base.js"() {
6764
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/errors/base.js"() {
6782
6765
  "use strict";
6783
6766
  init_version();
6784
6767
  errorConfig = {
@@ -6859,10 +6842,10 @@ var init_base = __esm({
6859
6842
  }
6860
6843
  });
6861
6844
 
6862
- // ../../node_modules/viem/_esm/errors/data.js
6845
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/errors/data.js
6863
6846
  var SizeExceedsPaddingSizeError;
6864
6847
  var init_data = __esm({
6865
- "../../node_modules/viem/_esm/errors/data.js"() {
6848
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/errors/data.js"() {
6866
6849
  "use strict";
6867
6850
  init_base();
6868
6851
  SizeExceedsPaddingSizeError = class extends BaseError {
@@ -6873,7 +6856,7 @@ var init_data = __esm({
6873
6856
  }
6874
6857
  });
6875
6858
 
6876
- // ../../node_modules/viem/_esm/utils/data/pad.js
6859
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/data/pad.js
6877
6860
  function pad(hexOrBytes, { dir, size: size2 = 32 } = {}) {
6878
6861
  if (typeof hexOrBytes === "string")
6879
6862
  return padHex(hexOrBytes, { dir, size: size2 });
@@ -6882,14 +6865,14 @@ function pad(hexOrBytes, { dir, size: size2 = 32 } = {}) {
6882
6865
  function padHex(hex_, { dir, size: size2 = 32 } = {}) {
6883
6866
  if (size2 === null)
6884
6867
  return hex_;
6885
- const hex2 = hex_.replace("0x", "");
6886
- if (hex2.length > size2 * 2)
6868
+ const hex = hex_.replace("0x", "");
6869
+ if (hex.length > size2 * 2)
6887
6870
  throw new SizeExceedsPaddingSizeError({
6888
- size: Math.ceil(hex2.length / 2),
6871
+ size: Math.ceil(hex.length / 2),
6889
6872
  targetSize: size2,
6890
6873
  type: "hex"
6891
6874
  });
6892
- return `0x${hex2[dir === "right" ? "padEnd" : "padStart"](size2 * 2, "0")}`;
6875
+ return `0x${hex[dir === "right" ? "padEnd" : "padStart"](size2 * 2, "0")}`;
6893
6876
  }
6894
6877
  function padBytes(bytes, { dir, size: size2 = 32 } = {}) {
6895
6878
  if (size2 === null)
@@ -6908,16 +6891,16 @@ function padBytes(bytes, { dir, size: size2 = 32 } = {}) {
6908
6891
  return paddedBytes;
6909
6892
  }
6910
6893
  var init_pad = __esm({
6911
- "../../node_modules/viem/_esm/utils/data/pad.js"() {
6894
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/data/pad.js"() {
6912
6895
  "use strict";
6913
6896
  init_data();
6914
6897
  }
6915
6898
  });
6916
6899
 
6917
- // ../../node_modules/viem/_esm/errors/encoding.js
6900
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/errors/encoding.js
6918
6901
  var IntegerOutOfRangeError, SizeOverflowError;
6919
6902
  var init_encoding = __esm({
6920
- "../../node_modules/viem/_esm/errors/encoding.js"() {
6903
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/errors/encoding.js"() {
6921
6904
  "use strict";
6922
6905
  init_base();
6923
6906
  IntegerOutOfRangeError = class extends BaseError {
@@ -6933,7 +6916,7 @@ var init_encoding = __esm({
6933
6916
  }
6934
6917
  });
6935
6918
 
6936
- // ../../node_modules/viem/_esm/utils/encoding/fromHex.js
6919
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/encoding/fromHex.js
6937
6920
  function assertSize(hexOrBytes, { size: size2 }) {
6938
6921
  if (size(hexOrBytes) > size2)
6939
6922
  throw new SizeOverflowError({
@@ -6941,21 +6924,21 @@ function assertSize(hexOrBytes, { size: size2 }) {
6941
6924
  maxSize: size2
6942
6925
  });
6943
6926
  }
6944
- function hexToBigInt(hex2, opts = {}) {
6927
+ function hexToBigInt(hex, opts = {}) {
6945
6928
  const { signed } = opts;
6946
6929
  if (opts.size)
6947
- assertSize(hex2, { size: opts.size });
6948
- const value = BigInt(hex2);
6930
+ assertSize(hex, { size: opts.size });
6931
+ const value = BigInt(hex);
6949
6932
  if (!signed)
6950
6933
  return value;
6951
- const size2 = (hex2.length - 2) / 2;
6934
+ const size2 = Math.ceil((hex.length - 2) / 2);
6952
6935
  const max = (1n << BigInt(size2) * 8n - 1n) - 1n;
6953
6936
  if (value <= max)
6954
6937
  return value;
6955
6938
  return value - BigInt(`0x${"f".padStart(size2 * 2, "f")}`) - 1n;
6956
6939
  }
6957
- function hexToNumber2(hex2, opts = {}) {
6958
- const value = hexToBigInt(hex2, opts);
6940
+ function hexToNumber2(hex, opts = {}) {
6941
+ const value = hexToBigInt(hex, opts);
6959
6942
  const number = Number(value);
6960
6943
  if (!Number.isSafeInteger(number))
6961
6944
  throw new IntegerOutOfRangeError({
@@ -6968,14 +6951,14 @@ function hexToNumber2(hex2, opts = {}) {
6968
6951
  return number;
6969
6952
  }
6970
6953
  var init_fromHex = __esm({
6971
- "../../node_modules/viem/_esm/utils/encoding/fromHex.js"() {
6954
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/encoding/fromHex.js"() {
6972
6955
  "use strict";
6973
6956
  init_encoding();
6974
6957
  init_size();
6975
6958
  }
6976
6959
  });
6977
6960
 
6978
- // ../../node_modules/viem/_esm/utils/encoding/toHex.js
6961
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/encoding/toHex.js
6979
6962
  function toHex(value, opts = {}) {
6980
6963
  if (typeof value === "number" || typeof value === "bigint")
6981
6964
  return numberToHex(value, opts);
@@ -6987,24 +6970,24 @@ function toHex(value, opts = {}) {
6987
6970
  return bytesToHex2(value, opts);
6988
6971
  }
6989
6972
  function boolToHex(value, opts = {}) {
6990
- const hex2 = `0x${Number(value)}`;
6973
+ const hex = `0x${Number(value)}`;
6991
6974
  if (typeof opts.size === "number") {
6992
- assertSize(hex2, { size: opts.size });
6993
- return pad(hex2, { size: opts.size });
6975
+ assertSize(hex, { size: opts.size });
6976
+ return pad(hex, { size: opts.size });
6994
6977
  }
6995
- return hex2;
6978
+ return hex;
6996
6979
  }
6997
6980
  function bytesToHex2(value, opts = {}) {
6998
6981
  let string2 = "";
6999
6982
  for (let i = 0; i < value.length; i++) {
7000
6983
  string2 += hexes2[value[i]];
7001
6984
  }
7002
- const hex2 = `0x${string2}`;
6985
+ const hex = `0x${string2}`;
7003
6986
  if (typeof opts.size === "number") {
7004
- assertSize(hex2, { size: opts.size });
7005
- return pad(hex2, { dir: "right", size: opts.size });
6987
+ assertSize(hex, { size: opts.size });
6988
+ return pad(hex, { dir: "right", size: opts.size });
7006
6989
  }
7007
- return hex2;
6990
+ return hex;
7008
6991
  }
7009
6992
  function numberToHex(value_, opts = {}) {
7010
6993
  const { signed, size: size2 } = opts;
@@ -7029,10 +7012,10 @@ function numberToHex(value_, opts = {}) {
7029
7012
  value: `${value_}${suffix}`
7030
7013
  });
7031
7014
  }
7032
- const hex2 = `0x${(signed && value < 0 ? (1n << BigInt(size2 * 8)) + BigInt(value) : value).toString(16)}`;
7015
+ const hex = `0x${(signed && value < 0 ? (1n << BigInt(size2 * 8)) + BigInt(value) : value).toString(16)}`;
7033
7016
  if (size2)
7034
- return pad(hex2, { size: size2 });
7035
- return hex2;
7017
+ return pad(hex, { size: size2 });
7018
+ return hex;
7036
7019
  }
7037
7020
  function stringToHex(value_, opts = {}) {
7038
7021
  const value = encoder.encode(value_);
@@ -7040,7 +7023,7 @@ function stringToHex(value_, opts = {}) {
7040
7023
  }
7041
7024
  var hexes2, encoder;
7042
7025
  var init_toHex = __esm({
7043
- "../../node_modules/viem/_esm/utils/encoding/toHex.js"() {
7026
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/encoding/toHex.js"() {
7044
7027
  "use strict";
7045
7028
  init_encoding();
7046
7029
  init_pad();
@@ -7050,7 +7033,7 @@ var init_toHex = __esm({
7050
7033
  }
7051
7034
  });
7052
7035
 
7053
- // ../../node_modules/viem/_esm/utils/encoding/toBytes.js
7036
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/encoding/toBytes.js
7054
7037
  function toBytes2(value, opts = {}) {
7055
7038
  if (typeof value === "number" || typeof value === "bigint")
7056
7039
  return numberToBytes(value, opts);
@@ -7079,12 +7062,12 @@ function charCodeToBase16(char) {
7079
7062
  return void 0;
7080
7063
  }
7081
7064
  function hexToBytes2(hex_, opts = {}) {
7082
- let hex2 = hex_;
7065
+ let hex = hex_;
7083
7066
  if (opts.size) {
7084
- assertSize(hex2, { size: opts.size });
7085
- hex2 = pad(hex2, { dir: "right", size: opts.size });
7067
+ assertSize(hex, { size: opts.size });
7068
+ hex = pad(hex, { dir: "right", size: opts.size });
7086
7069
  }
7087
- let hexString = hex2.slice(2);
7070
+ let hexString = hex.slice(2);
7088
7071
  if (hexString.length % 2)
7089
7072
  hexString = `0${hexString}`;
7090
7073
  const length4 = hexString.length / 2;
@@ -7100,8 +7083,8 @@ function hexToBytes2(hex_, opts = {}) {
7100
7083
  return bytes;
7101
7084
  }
7102
7085
  function numberToBytes(value, opts) {
7103
- const hex2 = numberToHex(value, opts);
7104
- return hexToBytes2(hex2);
7086
+ const hex = numberToHex(value, opts);
7087
+ return hexToBytes2(hex);
7105
7088
  }
7106
7089
  function stringToBytes(value, opts = {}) {
7107
7090
  const bytes = encoder2.encode(value);
@@ -7113,7 +7096,7 @@ function stringToBytes(value, opts = {}) {
7113
7096
  }
7114
7097
  var encoder2, charCodeMap;
7115
7098
  var init_toBytes = __esm({
7116
- "../../node_modules/viem/_esm/utils/encoding/toBytes.js"() {
7099
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/encoding/toBytes.js"() {
7117
7100
  "use strict";
7118
7101
  init_base();
7119
7102
  init_isHex();
@@ -7132,7 +7115,7 @@ var init_toBytes = __esm({
7132
7115
  }
7133
7116
  });
7134
7117
 
7135
- // ../../node_modules/@noble/hashes/esm/sha3.js
7118
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/hashes/esm/sha3.js
7136
7119
  function keccakP(s, rounds = 24) {
7137
7120
  const B = new Uint32Array(5 * 2);
7138
7121
  for (let round = 24 - rounds; round < 24; round++) {
@@ -7175,7 +7158,7 @@ function keccakP(s, rounds = 24) {
7175
7158
  }
7176
7159
  var _0n6, _1n6, _2n4, _7n2, _256n, _0x71n, SHA3_PI, SHA3_ROTL, _SHA3_IOTA, IOTAS, SHA3_IOTA_H, SHA3_IOTA_L, rotlH, rotlL, Keccak, gen, keccak_256;
7177
7160
  var init_sha3 = __esm({
7178
- "../../node_modules/@noble/hashes/esm/sha3.js"() {
7161
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/hashes/esm/sha3.js"() {
7179
7162
  "use strict";
7180
7163
  init_u64();
7181
7164
  init_utils();
@@ -7321,7 +7304,7 @@ var init_sha3 = __esm({
7321
7304
  }
7322
7305
  });
7323
7306
 
7324
- // ../../node_modules/viem/_esm/utils/hash/keccak256.js
7307
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/hash/keccak256.js
7325
7308
  function keccak256(value, to_) {
7326
7309
  const to = to_ || "hex";
7327
7310
  const bytes = keccak_256(isHex(value, { strict: false }) ? toBytes2(value) : value);
@@ -7330,7 +7313,7 @@ function keccak256(value, to_) {
7330
7313
  return toHex(bytes);
7331
7314
  }
7332
7315
  var init_keccak256 = __esm({
7333
- "../../node_modules/viem/_esm/utils/hash/keccak256.js"() {
7316
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/hash/keccak256.js"() {
7334
7317
  "use strict";
7335
7318
  init_sha3();
7336
7319
  init_isHex();
@@ -7339,10 +7322,10 @@ var init_keccak256 = __esm({
7339
7322
  }
7340
7323
  });
7341
7324
 
7342
- // ../../node_modules/viem/_esm/errors/address.js
7325
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/errors/address.js
7343
7326
  var InvalidAddressError;
7344
7327
  var init_address = __esm({
7345
- "../../node_modules/viem/_esm/errors/address.js"() {
7328
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/errors/address.js"() {
7346
7329
  "use strict";
7347
7330
  init_base();
7348
7331
  InvalidAddressError = class extends BaseError {
@@ -7359,10 +7342,10 @@ var init_address = __esm({
7359
7342
  }
7360
7343
  });
7361
7344
 
7362
- // ../../node_modules/viem/_esm/utils/lru.js
7345
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/lru.js
7363
7346
  var LruMap;
7364
7347
  var init_lru = __esm({
7365
- "../../node_modules/viem/_esm/utils/lru.js"() {
7348
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/lru.js"() {
7366
7349
  "use strict";
7367
7350
  LruMap = class extends Map {
7368
7351
  constructor(size2) {
@@ -7377,18 +7360,20 @@ var init_lru = __esm({
7377
7360
  }
7378
7361
  get(key) {
7379
7362
  const value = super.get(key);
7380
- if (super.has(key) && value !== void 0) {
7381
- this.delete(key);
7363
+ if (super.has(key)) {
7364
+ super.delete(key);
7382
7365
  super.set(key, value);
7383
7366
  }
7384
7367
  return value;
7385
7368
  }
7386
7369
  set(key, value) {
7370
+ if (super.has(key))
7371
+ super.delete(key);
7387
7372
  super.set(key, value);
7388
7373
  if (this.maxSize && this.size > this.maxSize) {
7389
- const firstKey = this.keys().next().value;
7390
- if (firstKey)
7391
- this.delete(firstKey);
7374
+ const firstKey = super.keys().next().value;
7375
+ if (firstKey !== void 0)
7376
+ super.delete(firstKey);
7392
7377
  }
7393
7378
  return this;
7394
7379
  }
@@ -7396,7 +7381,7 @@ var init_lru = __esm({
7396
7381
  }
7397
7382
  });
7398
7383
 
7399
- // ../../node_modules/viem/_esm/utils/address/getAddress.js
7384
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/address/getAddress.js
7400
7385
  function checksumAddress(address_, chainId) {
7401
7386
  if (checksumAddressCache.has(`${address_}.${chainId}`))
7402
7387
  return checksumAddressCache.get(`${address_}.${chainId}`);
@@ -7422,7 +7407,7 @@ function getAddress(address, chainId) {
7422
7407
  }
7423
7408
  var checksumAddressCache;
7424
7409
  var init_getAddress = __esm({
7425
- "../../node_modules/viem/_esm/utils/address/getAddress.js"() {
7410
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/address/getAddress.js"() {
7426
7411
  "use strict";
7427
7412
  init_address();
7428
7413
  init_toBytes();
@@ -7433,7 +7418,7 @@ var init_getAddress = __esm({
7433
7418
  }
7434
7419
  });
7435
7420
 
7436
- // ../../node_modules/viem/_esm/utils/address/isAddress.js
7421
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/address/isAddress.js
7437
7422
  function isAddress(address, options) {
7438
7423
  const { strict = true } = options ?? {};
7439
7424
  const cacheKey2 = `${address}.${strict}`;
@@ -7453,7 +7438,7 @@ function isAddress(address, options) {
7453
7438
  }
7454
7439
  var addressRegex, isAddressCache;
7455
7440
  var init_isAddress = __esm({
7456
- "../../node_modules/viem/_esm/utils/address/isAddress.js"() {
7441
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/address/isAddress.js"() {
7457
7442
  "use strict";
7458
7443
  init_lru();
7459
7444
  init_getAddress();
@@ -7462,7 +7447,7 @@ var init_isAddress = __esm({
7462
7447
  }
7463
7448
  });
7464
7449
 
7465
- // ../../node_modules/viem/_esm/utils/data/concat.js
7450
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/data/concat.js
7466
7451
  function concat(values) {
7467
7452
  if (typeof values[0] === "string")
7468
7453
  return concatHex(values);
@@ -7485,28 +7470,28 @@ function concatHex(values) {
7485
7470
  return `0x${values.reduce((acc, x) => acc + x.replace("0x", ""), "")}`;
7486
7471
  }
7487
7472
  var init_concat = __esm({
7488
- "../../node_modules/viem/_esm/utils/data/concat.js"() {
7473
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/data/concat.js"() {
7489
7474
  "use strict";
7490
7475
  }
7491
7476
  });
7492
7477
 
7493
- // ../../node_modules/viem/_esm/accounts/utils/publicKeyToAddress.js
7478
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/accounts/utils/publicKeyToAddress.js
7494
7479
  function publicKeyToAddress(publicKey) {
7495
7480
  const address = keccak256(`0x${publicKey.substring(4)}`).substring(26);
7496
7481
  return checksumAddress(`0x${address}`);
7497
7482
  }
7498
7483
  var init_publicKeyToAddress = __esm({
7499
- "../../node_modules/viem/_esm/accounts/utils/publicKeyToAddress.js"() {
7484
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/accounts/utils/publicKeyToAddress.js"() {
7500
7485
  "use strict";
7501
7486
  init_getAddress();
7502
7487
  init_keccak256();
7503
7488
  }
7504
7489
  });
7505
7490
 
7506
- // ../../node_modules/@noble/hashes/esm/hmac.js
7491
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/hashes/esm/hmac.js
7507
7492
  var HMAC, hmac;
7508
7493
  var init_hmac = __esm({
7509
- "../../node_modules/@noble/hashes/esm/hmac.js"() {
7494
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/hashes/esm/hmac.js"() {
7510
7495
  "use strict";
7511
7496
  init_utils();
7512
7497
  HMAC = class extends Hash {
@@ -7578,7 +7563,7 @@ var init_hmac = __esm({
7578
7563
  }
7579
7564
  });
7580
7565
 
7581
- // ../../node_modules/viem/node_modules/@noble/curves/esm/abstract/utils.js
7566
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/node_modules/@noble/curves/esm/abstract/utils.js
7582
7567
  function isBytes2(a) {
7583
7568
  return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
7584
7569
  }
@@ -7591,23 +7576,23 @@ function abool(title, value) {
7591
7576
  throw new Error(title + " boolean expected, got " + value);
7592
7577
  }
7593
7578
  function numberToHexUnpadded(num2) {
7594
- const hex2 = num2.toString(16);
7595
- return hex2.length & 1 ? "0" + hex2 : hex2;
7579
+ const hex = num2.toString(16);
7580
+ return hex.length & 1 ? "0" + hex : hex;
7596
7581
  }
7597
- function hexToNumber3(hex2) {
7598
- if (typeof hex2 !== "string")
7599
- throw new Error("hex string expected, got " + typeof hex2);
7600
- return hex2 === "" ? _0n7 : BigInt("0x" + hex2);
7582
+ function hexToNumber3(hex) {
7583
+ if (typeof hex !== "string")
7584
+ throw new Error("hex string expected, got " + typeof hex);
7585
+ return hex === "" ? _0n7 : BigInt("0x" + hex);
7601
7586
  }
7602
7587
  function bytesToHex3(bytes) {
7603
7588
  abytes2(bytes);
7604
7589
  if (hasHexBuiltin2)
7605
7590
  return bytes.toHex();
7606
- let hex2 = "";
7591
+ let hex = "";
7607
7592
  for (let i = 0; i < bytes.length; i++) {
7608
- hex2 += hexes3[bytes[i]];
7593
+ hex += hexes3[bytes[i]];
7609
7594
  }
7610
- return hex2;
7595
+ return hex;
7611
7596
  }
7612
7597
  function asciiToBase162(ch) {
7613
7598
  if (ch >= asciis2._0 && ch <= asciis2._9)
@@ -7618,21 +7603,21 @@ function asciiToBase162(ch) {
7618
7603
  return ch - (asciis2.a - 10);
7619
7604
  return;
7620
7605
  }
7621
- function hexToBytes3(hex2) {
7622
- if (typeof hex2 !== "string")
7623
- throw new Error("hex string expected, got " + typeof hex2);
7606
+ function hexToBytes3(hex) {
7607
+ if (typeof hex !== "string")
7608
+ throw new Error("hex string expected, got " + typeof hex);
7624
7609
  if (hasHexBuiltin2)
7625
- return Uint8Array.fromHex(hex2);
7626
- const hl = hex2.length;
7610
+ return Uint8Array.fromHex(hex);
7611
+ const hl = hex.length;
7627
7612
  const al = hl / 2;
7628
7613
  if (hl % 2)
7629
7614
  throw new Error("hex string expected, got unpadded hex of length " + hl);
7630
7615
  const array = new Uint8Array(al);
7631
7616
  for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
7632
- const n1 = asciiToBase162(hex2.charCodeAt(hi));
7633
- const n2 = asciiToBase162(hex2.charCodeAt(hi + 1));
7617
+ const n1 = asciiToBase162(hex.charCodeAt(hi));
7618
+ const n2 = asciiToBase162(hex.charCodeAt(hi + 1));
7634
7619
  if (n1 === void 0 || n2 === void 0) {
7635
- const char = hex2[hi] + hex2[hi + 1];
7620
+ const char = hex[hi] + hex[hi + 1];
7636
7621
  throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
7637
7622
  }
7638
7623
  array[ai] = n1 * 16 + n2;
@@ -7652,16 +7637,16 @@ function numberToBytesBE2(n, len) {
7652
7637
  function numberToBytesLE2(n, len) {
7653
7638
  return numberToBytesBE2(n, len).reverse();
7654
7639
  }
7655
- function ensureBytes2(title, hex2, expectedLength) {
7640
+ function ensureBytes2(title, hex, expectedLength) {
7656
7641
  let res;
7657
- if (typeof hex2 === "string") {
7642
+ if (typeof hex === "string") {
7658
7643
  try {
7659
- res = hexToBytes3(hex2);
7644
+ res = hexToBytes3(hex);
7660
7645
  } catch (e) {
7661
7646
  throw new Error(title + " must be hex string or Uint8Array, cause: " + e);
7662
7647
  }
7663
- } else if (isBytes2(hex2)) {
7664
- res = Uint8Array.from(hex2);
7648
+ } else if (isBytes2(hex)) {
7649
+ res = Uint8Array.from(hex);
7665
7650
  } else {
7666
7651
  throw new Error(title + " must be hex string or Uint8Array");
7667
7652
  }
@@ -7751,15 +7736,15 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
7751
7736
  };
7752
7737
  return genUntil;
7753
7738
  }
7754
- function validateObject2(object2, validators, optValidators = {}) {
7739
+ function validateObject2(object, validators, optValidators = {}) {
7755
7740
  const checkField = (fieldName, type, isOptional) => {
7756
7741
  const checkVal = validatorFns[type];
7757
7742
  if (typeof checkVal !== "function")
7758
7743
  throw new Error("invalid validator function");
7759
- const val = object2[fieldName];
7744
+ const val = object[fieldName];
7760
7745
  if (isOptional && val === void 0)
7761
7746
  return;
7762
- if (!checkVal(val, object2)) {
7747
+ if (!checkVal(val, object)) {
7763
7748
  throw new Error("param " + String(fieldName) + " is invalid. Expected " + type + ", got " + val);
7764
7749
  }
7765
7750
  };
@@ -7767,7 +7752,7 @@ function validateObject2(object2, validators, optValidators = {}) {
7767
7752
  checkField(fieldName, type, false);
7768
7753
  for (const [fieldName, type] of Object.entries(optValidators))
7769
7754
  checkField(fieldName, type, true);
7770
- return object2;
7755
+ return object;
7771
7756
  }
7772
7757
  function memoized2(fn) {
7773
7758
  const map = /* @__PURE__ */ new WeakMap();
@@ -7782,7 +7767,7 @@ function memoized2(fn) {
7782
7767
  }
7783
7768
  var _0n7, _1n7, hasHexBuiltin2, hexes3, asciis2, isPosBig2, bitMask2, u8n, u8fr, validatorFns;
7784
7769
  var init_utils3 = __esm({
7785
- "../../node_modules/viem/node_modules/@noble/curves/esm/abstract/utils.js"() {
7770
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/node_modules/@noble/curves/esm/abstract/utils.js"() {
7786
7771
  "use strict";
7787
7772
  _0n7 = /* @__PURE__ */ BigInt(0);
7788
7773
  _1n7 = /* @__PURE__ */ BigInt(1);
@@ -7802,13 +7787,13 @@ var init_utils3 = __esm({
7802
7787
  stringOrUint8Array: (val) => typeof val === "string" || isBytes2(val),
7803
7788
  isSafeInteger: (val) => Number.isSafeInteger(val),
7804
7789
  array: (val) => Array.isArray(val),
7805
- field: (val, object2) => object2.Fp.isValid(val),
7790
+ field: (val, object) => object.Fp.isValid(val),
7806
7791
  hash: (val) => typeof val === "function" && Number.isSafeInteger(val.outputLen)
7807
7792
  };
7808
7793
  }
7809
7794
  });
7810
7795
 
7811
- // ../../node_modules/viem/node_modules/@noble/curves/esm/abstract/modular.js
7796
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/node_modules/@noble/curves/esm/abstract/modular.js
7812
7797
  function mod2(a, b) {
7813
7798
  const result = a % b;
7814
7799
  return result >= _0n8 ? result : b + result;
@@ -8057,7 +8042,7 @@ function mapHashToField(key, fieldOrder, isLE2 = false) {
8057
8042
  }
8058
8043
  var _0n8, _1n8, _2n5, _3n3, _4n2, _5n3, _8n4, FIELD_FIELDS2;
8059
8044
  var init_modular2 = __esm({
8060
- "../../node_modules/viem/node_modules/@noble/curves/esm/abstract/modular.js"() {
8045
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/node_modules/@noble/curves/esm/abstract/modular.js"() {
8061
8046
  "use strict";
8062
8047
  init_utils();
8063
8048
  init_utils3();
@@ -8090,7 +8075,7 @@ var init_modular2 = __esm({
8090
8075
  }
8091
8076
  });
8092
8077
 
8093
- // ../../node_modules/viem/node_modules/@noble/curves/esm/abstract/curve.js
8078
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/node_modules/@noble/curves/esm/abstract/curve.js
8094
8079
  function constTimeNegate(condition, item) {
8095
8080
  const neg = item.negate();
8096
8081
  return condition ? neg : item;
@@ -8321,7 +8306,7 @@ function validateBasic(curve) {
8321
8306
  }
8322
8307
  var _0n9, _1n9, pointPrecomputes2, pointWindowSizes2;
8323
8308
  var init_curve2 = __esm({
8324
- "../../node_modules/viem/node_modules/@noble/curves/esm/abstract/curve.js"() {
8309
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/node_modules/@noble/curves/esm/abstract/curve.js"() {
8325
8310
  "use strict";
8326
8311
  init_modular2();
8327
8312
  init_utils3();
@@ -8332,7 +8317,7 @@ var init_curve2 = __esm({
8332
8317
  }
8333
8318
  });
8334
8319
 
8335
- // ../../node_modules/viem/node_modules/@noble/curves/esm/abstract/weierstrass.js
8320
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/node_modules/@noble/curves/esm/abstract/weierstrass.js
8336
8321
  function validateSigVerOpts(opts) {
8337
8322
  if (opts.lowS !== void 0)
8338
8323
  abool("lowS", opts.lowS);
@@ -8502,8 +8487,8 @@ function weierstrassPoints(opts) {
8502
8487
  * Converts hash string or Uint8Array to Point.
8503
8488
  * @param hex short/long ECDSA hex
8504
8489
  */
8505
- static fromHex(hex2) {
8506
- const P = Point2.fromAffine(fromBytes2(ensureBytes2("pointHex", hex2)));
8490
+ static fromHex(hex) {
8491
+ const P = Point2.fromAffine(fromBytes2(ensureBytes2("pointHex", hex)));
8507
8492
  P.assertValidity();
8508
8493
  return P;
8509
8494
  }
@@ -8858,15 +8843,15 @@ function weierstrass(curveDef) {
8858
8843
  Object.freeze(this);
8859
8844
  }
8860
8845
  // pair (bytes of r, bytes of s)
8861
- static fromCompact(hex2) {
8846
+ static fromCompact(hex) {
8862
8847
  const l = nByteLength;
8863
- hex2 = ensureBytes2("compactSignature", hex2, l * 2);
8864
- return new Signature(slcNum(hex2, 0, l), slcNum(hex2, l, 2 * l));
8848
+ hex = ensureBytes2("compactSignature", hex, l * 2);
8849
+ return new Signature(slcNum(hex, 0, l), slcNum(hex, l, 2 * l));
8865
8850
  }
8866
8851
  // DER encoded ECDSA signature
8867
8852
  // https://bitcoin.stackexchange.com/questions/57644/what-are-the-parts-of-a-bitcoin-transaction-input-script
8868
- static fromDER(hex2) {
8869
- const { r, s } = DER.toSig(ensureBytes2("DER", hex2));
8853
+ static fromDER(hex) {
8854
+ const { r, s } = DER.toSig(ensureBytes2("DER", hex));
8870
8855
  return new Signature(r, s);
8871
8856
  }
8872
8857
  /**
@@ -8997,7 +8982,7 @@ function weierstrass(curveDef) {
8997
8982
  function prepSig(msgHash, privateKey, opts = defaultSigOpts) {
8998
8983
  if (["recovered", "canonical"].some((k) => k in opts))
8999
8984
  throw new Error("sign() legacy options not supported");
9000
- const { hash, randomBytes: randomBytes6 } = CURVE;
8985
+ const { hash, randomBytes: randomBytes5 } = CURVE;
9001
8986
  let { lowS, prehash, extraEntropy: ent } = opts;
9002
8987
  if (lowS == null)
9003
8988
  lowS = true;
@@ -9009,7 +8994,7 @@ function weierstrass(curveDef) {
9009
8994
  const d = normPrivateKeyToScalar(privateKey);
9010
8995
  const seedArgs = [int2octets(d), int2octets(h1int)];
9011
8996
  if (ent != null && ent !== false) {
9012
- const e = ent === true ? randomBytes6(Fp2.BYTES) : ent;
8997
+ const e = ent === true ? randomBytes5(Fp2.BYTES) : ent;
9013
8998
  seedArgs.push(ensureBytes2("extraEntropy", e));
9014
8999
  }
9015
9000
  const seed = concatBytes3(...seedArgs);
@@ -9209,7 +9194,7 @@ function mapToCurveSimpleSWU(Fp2, opts) {
9209
9194
  }
9210
9195
  var DERErr, DER, _0n10, _1n10, _2n6, _3n4, _4n3;
9211
9196
  var init_weierstrass = __esm({
9212
- "../../node_modules/viem/node_modules/@noble/curves/esm/abstract/weierstrass.js"() {
9197
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/node_modules/@noble/curves/esm/abstract/weierstrass.js"() {
9213
9198
  "use strict";
9214
9199
  init_curve2();
9215
9200
  init_modular2();
@@ -9283,12 +9268,12 @@ var init_weierstrass = __esm({
9283
9268
  const { Err: E } = DER;
9284
9269
  if (num2 < _0n10)
9285
9270
  throw new E("integer: negative integers are not allowed");
9286
- let hex2 = numberToHexUnpadded(num2);
9287
- if (Number.parseInt(hex2[0], 16) & 8)
9288
- hex2 = "00" + hex2;
9289
- if (hex2.length & 1)
9271
+ let hex = numberToHexUnpadded(num2);
9272
+ if (Number.parseInt(hex[0], 16) & 8)
9273
+ hex = "00" + hex;
9274
+ if (hex.length & 1)
9290
9275
  throw new E("unexpected DER parsing assertion: unpadded hex");
9291
- return hex2;
9276
+ return hex;
9292
9277
  },
9293
9278
  decode(data) {
9294
9279
  const { Err: E } = DER;
@@ -9299,9 +9284,9 @@ var init_weierstrass = __esm({
9299
9284
  return bytesToNumberBE2(data);
9300
9285
  }
9301
9286
  },
9302
- toSig(hex2) {
9287
+ toSig(hex) {
9303
9288
  const { Err: E, _int: int, _tlv: tlv } = DER;
9304
- const data = ensureBytes2("signature", hex2);
9289
+ const data = ensureBytes2("signature", hex);
9305
9290
  const { v: seqBytes, l: seqLeftBytes } = tlv.decode(48, data);
9306
9291
  if (seqLeftBytes.length)
9307
9292
  throw new E("invalid signature: left bytes after parsing");
@@ -9327,7 +9312,7 @@ var init_weierstrass = __esm({
9327
9312
  }
9328
9313
  });
9329
9314
 
9330
- // ../../node_modules/viem/node_modules/@noble/curves/esm/_shortw_utils.js
9315
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/node_modules/@noble/curves/esm/_shortw_utils.js
9331
9316
  function getHash(hash) {
9332
9317
  return {
9333
9318
  hash,
@@ -9340,7 +9325,7 @@ function createCurve(curveDef, defHash) {
9340
9325
  return { ...create4(defHash), create: create4 };
9341
9326
  }
9342
9327
  var init_shortw_utils = __esm({
9343
- "../../node_modules/viem/node_modules/@noble/curves/esm/_shortw_utils.js"() {
9328
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/node_modules/@noble/curves/esm/_shortw_utils.js"() {
9344
9329
  "use strict";
9345
9330
  init_hmac();
9346
9331
  init_utils();
@@ -9348,7 +9333,7 @@ var init_shortw_utils = __esm({
9348
9333
  }
9349
9334
  });
9350
9335
 
9351
- // ../../node_modules/viem/node_modules/@noble/curves/esm/abstract/hash-to-curve.js
9336
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/node_modules/@noble/curves/esm/abstract/hash-to-curve.js
9352
9337
  function i2osp(value, length4) {
9353
9338
  anum(value);
9354
9339
  anum(length4);
@@ -9496,7 +9481,7 @@ function createHasher2(Point2, mapToCurve, defaults) {
9496
9481
  }
9497
9482
  var os2ip;
9498
9483
  var init_hash_to_curve = __esm({
9499
- "../../node_modules/viem/node_modules/@noble/curves/esm/abstract/hash-to-curve.js"() {
9484
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/node_modules/@noble/curves/esm/abstract/hash-to-curve.js"() {
9500
9485
  "use strict";
9501
9486
  init_modular2();
9502
9487
  init_utils3();
@@ -9504,7 +9489,7 @@ var init_hash_to_curve = __esm({
9504
9489
  }
9505
9490
  });
9506
9491
 
9507
- // ../../node_modules/viem/node_modules/@noble/curves/esm/secp256k1.js
9492
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/node_modules/@noble/curves/esm/secp256k1.js
9508
9493
  var secp256k1_exports = {};
9509
9494
  __export(secp256k1_exports, {
9510
9495
  encodeToCurve: () => encodeToCurve,
@@ -9608,7 +9593,7 @@ function schnorrVerify(signature, message, publicKey) {
9608
9593
  }
9609
9594
  var secp256k1P, secp256k1N, _0n11, _1n11, _2n7, divNearest, Fpk1, secp256k1, TAGGED_HASH_PREFIXES, pointToBytes, numTo32b, modP, modN, Point, GmulAdd, num, schnorr, isoMap, mapSWU, secp256k1_hasher, hashToCurve, encodeToCurve;
9610
9595
  var init_secp256k1 = __esm({
9611
- "../../node_modules/viem/node_modules/@noble/curves/esm/secp256k1.js"() {
9596
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/node_modules/@noble/curves/esm/secp256k1.js"() {
9612
9597
  "use strict";
9613
9598
  init_sha2();
9614
9599
  init_utils();
@@ -9736,7 +9721,7 @@ var init_secp256k1 = __esm({
9736
9721
  }
9737
9722
  });
9738
9723
 
9739
- // ../../node_modules/viem/_esm/utils/signature/recoverPublicKey.js
9724
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/signature/recoverPublicKey.js
9740
9725
  async function recoverPublicKey({ hash, signature }) {
9741
9726
  const hashHex = isHex(hash) ? hash : toHex(hash);
9742
9727
  const { secp256k1: secp256k12 } = await Promise.resolve().then(() => (init_secp256k1(), secp256k1_exports));
@@ -9767,7 +9752,7 @@ function toRecoveryBit(yParityOrV) {
9767
9752
  throw new Error("Invalid yParityOrV value");
9768
9753
  }
9769
9754
  var init_recoverPublicKey = __esm({
9770
- "../../node_modules/viem/_esm/utils/signature/recoverPublicKey.js"() {
9755
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/signature/recoverPublicKey.js"() {
9771
9756
  "use strict";
9772
9757
  init_isHex();
9773
9758
  init_size();
@@ -9776,29 +9761,19 @@ var init_recoverPublicKey = __esm({
9776
9761
  }
9777
9762
  });
9778
9763
 
9779
- // ../../node_modules/viem/_esm/utils/signature/recoverAddress.js
9764
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/signature/recoverAddress.js
9780
9765
  async function recoverAddress({ hash, signature }) {
9781
9766
  return publicKeyToAddress(await recoverPublicKey({ hash, signature }));
9782
9767
  }
9783
9768
  var init_recoverAddress = __esm({
9784
- "../../node_modules/viem/_esm/utils/signature/recoverAddress.js"() {
9769
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/signature/recoverAddress.js"() {
9785
9770
  "use strict";
9786
9771
  init_publicKeyToAddress();
9787
9772
  init_recoverPublicKey();
9788
9773
  }
9789
9774
  });
9790
9775
 
9791
- // ../../node_modules/@noble/hashes/esm/sha256.js
9792
- var sha2562;
9793
- var init_sha256 = __esm({
9794
- "../../node_modules/@noble/hashes/esm/sha256.js"() {
9795
- "use strict";
9796
- init_sha2();
9797
- sha2562 = sha256;
9798
- }
9799
- });
9800
-
9801
- // ../../node_modules/viem/_esm/utils/address/isAddressEqual.js
9776
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/address/isAddressEqual.js
9802
9777
  function isAddressEqual(a, b) {
9803
9778
  if (!isAddress(a, { strict: false }))
9804
9779
  throw new InvalidAddressError({ address: a });
@@ -9807,23 +9782,23 @@ function isAddressEqual(a, b) {
9807
9782
  return a.toLowerCase() === b.toLowerCase();
9808
9783
  }
9809
9784
  var init_isAddressEqual = __esm({
9810
- "../../node_modules/viem/_esm/utils/address/isAddressEqual.js"() {
9785
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/address/isAddressEqual.js"() {
9811
9786
  "use strict";
9812
9787
  init_address();
9813
9788
  init_isAddress();
9814
9789
  }
9815
9790
  });
9816
9791
 
9817
- // ../../node_modules/viem/_esm/constants/strings.js
9792
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/constants/strings.js
9818
9793
  var presignMessagePrefix;
9819
9794
  var init_strings = __esm({
9820
- "../../node_modules/viem/_esm/constants/strings.js"() {
9795
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/constants/strings.js"() {
9821
9796
  "use strict";
9822
9797
  presignMessagePrefix = "Ethereum Signed Message:\n";
9823
9798
  }
9824
9799
  });
9825
9800
 
9826
- // ../../node_modules/viem/_esm/utils/signature/toPrefixedMessage.js
9801
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/signature/toPrefixedMessage.js
9827
9802
  function toPrefixedMessage(message_) {
9828
9803
  const message = (() => {
9829
9804
  if (typeof message_ === "string")
@@ -9836,7 +9811,7 @@ function toPrefixedMessage(message_) {
9836
9811
  return concat([prefix, message]);
9837
9812
  }
9838
9813
  var init_toPrefixedMessage = __esm({
9839
- "../../node_modules/viem/_esm/utils/signature/toPrefixedMessage.js"() {
9814
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/signature/toPrefixedMessage.js"() {
9840
9815
  "use strict";
9841
9816
  init_strings();
9842
9817
  init_concat();
@@ -9845,36 +9820,36 @@ var init_toPrefixedMessage = __esm({
9845
9820
  }
9846
9821
  });
9847
9822
 
9848
- // ../../node_modules/viem/_esm/utils/signature/hashMessage.js
9823
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/signature/hashMessage.js
9849
9824
  function hashMessage(message, to_) {
9850
9825
  return keccak256(toPrefixedMessage(message), to_);
9851
9826
  }
9852
9827
  var init_hashMessage = __esm({
9853
- "../../node_modules/viem/_esm/utils/signature/hashMessage.js"() {
9828
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/signature/hashMessage.js"() {
9854
9829
  "use strict";
9855
9830
  init_keccak256();
9856
9831
  init_toPrefixedMessage();
9857
9832
  }
9858
9833
  });
9859
9834
 
9860
- // ../../node_modules/viem/_esm/utils/signature/recoverMessageAddress.js
9835
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/signature/recoverMessageAddress.js
9861
9836
  async function recoverMessageAddress({ message, signature }) {
9862
9837
  return recoverAddress({ hash: hashMessage(message), signature });
9863
9838
  }
9864
9839
  var init_recoverMessageAddress = __esm({
9865
- "../../node_modules/viem/_esm/utils/signature/recoverMessageAddress.js"() {
9840
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/signature/recoverMessageAddress.js"() {
9866
9841
  "use strict";
9867
9842
  init_hashMessage();
9868
9843
  init_recoverAddress();
9869
9844
  }
9870
9845
  });
9871
9846
 
9872
- // ../../node_modules/viem/_esm/utils/signature/verifyMessage.js
9847
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/signature/verifyMessage.js
9873
9848
  async function verifyMessage({ address, message, signature }) {
9874
9849
  return isAddressEqual(getAddress(address), await recoverMessageAddress({ message, signature }));
9875
9850
  }
9876
9851
  var init_verifyMessage = __esm({
9877
- "../../node_modules/viem/_esm/utils/signature/verifyMessage.js"() {
9852
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/signature/verifyMessage.js"() {
9878
9853
  "use strict";
9879
9854
  init_getAddress();
9880
9855
  init_isAddressEqual();
@@ -9882,367 +9857,15 @@ var init_verifyMessage = __esm({
9882
9857
  }
9883
9858
  });
9884
9859
 
9885
- // ../../node_modules/viem/_esm/index.js
9860
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/index.js
9886
9861
  var init_esm = __esm({
9887
- "../../node_modules/viem/_esm/index.js"() {
9862
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/index.js"() {
9888
9863
  "use strict";
9889
9864
  init_verifyMessage();
9890
9865
  }
9891
9866
  });
9892
9867
 
9893
- // ../../node_modules/@noble/hashes/esm/_blake.js
9894
- function G1s(a, b, c, d, x) {
9895
- a = a + b + x | 0;
9896
- d = rotr(d ^ a, 16);
9897
- c = c + d | 0;
9898
- b = rotr(b ^ c, 12);
9899
- return { a, b, c, d };
9900
- }
9901
- function G2s(a, b, c, d, x) {
9902
- a = a + b + x | 0;
9903
- d = rotr(d ^ a, 8);
9904
- c = c + d | 0;
9905
- b = rotr(b ^ c, 7);
9906
- return { a, b, c, d };
9907
- }
9908
- var init_blake = __esm({
9909
- "../../node_modules/@noble/hashes/esm/_blake.js"() {
9910
- "use strict";
9911
- init_utils();
9912
- }
9913
- });
9914
-
9915
- // ../../node_modules/@noble/hashes/esm/blake2.js
9916
- function compress(s, offset, msg, rounds, v0, v1, v2, v3, v42, v5, v62, v7, v8, v9, v10, v11, v12, v13, v14, v15) {
9917
- let j = 0;
9918
- for (let i = 0; i < rounds; i++) {
9919
- ({ a: v0, b: v42, c: v8, d: v12 } = G1s(v0, v42, v8, v12, msg[offset + s[j++]]));
9920
- ({ a: v0, b: v42, c: v8, d: v12 } = G2s(v0, v42, v8, v12, msg[offset + s[j++]]));
9921
- ({ a: v1, b: v5, c: v9, d: v13 } = G1s(v1, v5, v9, v13, msg[offset + s[j++]]));
9922
- ({ a: v1, b: v5, c: v9, d: v13 } = G2s(v1, v5, v9, v13, msg[offset + s[j++]]));
9923
- ({ a: v2, b: v62, c: v10, d: v14 } = G1s(v2, v62, v10, v14, msg[offset + s[j++]]));
9924
- ({ a: v2, b: v62, c: v10, d: v14 } = G2s(v2, v62, v10, v14, msg[offset + s[j++]]));
9925
- ({ a: v3, b: v7, c: v11, d: v15 } = G1s(v3, v7, v11, v15, msg[offset + s[j++]]));
9926
- ({ a: v3, b: v7, c: v11, d: v15 } = G2s(v3, v7, v11, v15, msg[offset + s[j++]]));
9927
- ({ a: v0, b: v5, c: v10, d: v15 } = G1s(v0, v5, v10, v15, msg[offset + s[j++]]));
9928
- ({ a: v0, b: v5, c: v10, d: v15 } = G2s(v0, v5, v10, v15, msg[offset + s[j++]]));
9929
- ({ a: v1, b: v62, c: v11, d: v12 } = G1s(v1, v62, v11, v12, msg[offset + s[j++]]));
9930
- ({ a: v1, b: v62, c: v11, d: v12 } = G2s(v1, v62, v11, v12, msg[offset + s[j++]]));
9931
- ({ a: v2, b: v7, c: v8, d: v13 } = G1s(v2, v7, v8, v13, msg[offset + s[j++]]));
9932
- ({ a: v2, b: v7, c: v8, d: v13 } = G2s(v2, v7, v8, v13, msg[offset + s[j++]]));
9933
- ({ a: v3, b: v42, c: v9, d: v14 } = G1s(v3, v42, v9, v14, msg[offset + s[j++]]));
9934
- ({ a: v3, b: v42, c: v9, d: v14 } = G2s(v3, v42, v9, v14, msg[offset + s[j++]]));
9935
- }
9936
- return { v0, v1, v2, v3, v4: v42, v5, v6: v62, v7, v8, v9, v10, v11, v12, v13, v14, v15 };
9937
- }
9938
- var BLAKE2;
9939
- var init_blake2 = __esm({
9940
- "../../node_modules/@noble/hashes/esm/blake2.js"() {
9941
- "use strict";
9942
- init_blake();
9943
- init_utils();
9944
- BLAKE2 = class extends Hash {
9945
- constructor(blockLen, outputLen) {
9946
- super();
9947
- this.finished = false;
9948
- this.destroyed = false;
9949
- this.length = 0;
9950
- this.pos = 0;
9951
- anumber(blockLen);
9952
- anumber(outputLen);
9953
- this.blockLen = blockLen;
9954
- this.outputLen = outputLen;
9955
- this.buffer = new Uint8Array(blockLen);
9956
- this.buffer32 = u32(this.buffer);
9957
- }
9958
- update(data) {
9959
- aexists(this);
9960
- data = toBytes(data);
9961
- abytes(data);
9962
- const { blockLen, buffer, buffer32 } = this;
9963
- const len = data.length;
9964
- const offset = data.byteOffset;
9965
- const buf = data.buffer;
9966
- for (let pos = 0; pos < len; ) {
9967
- if (this.pos === blockLen) {
9968
- swap32IfBE(buffer32);
9969
- this.compress(buffer32, 0, false);
9970
- swap32IfBE(buffer32);
9971
- this.pos = 0;
9972
- }
9973
- const take = Math.min(blockLen - this.pos, len - pos);
9974
- const dataOffset = offset + pos;
9975
- if (take === blockLen && !(dataOffset % 4) && pos + take < len) {
9976
- const data32 = new Uint32Array(buf, dataOffset, Math.floor((len - pos) / 4));
9977
- swap32IfBE(data32);
9978
- for (let pos32 = 0; pos + blockLen < len; pos32 += buffer32.length, pos += blockLen) {
9979
- this.length += blockLen;
9980
- this.compress(data32, pos32, false);
9981
- }
9982
- swap32IfBE(data32);
9983
- continue;
9984
- }
9985
- buffer.set(data.subarray(pos, pos + take), this.pos);
9986
- this.pos += take;
9987
- this.length += take;
9988
- pos += take;
9989
- }
9990
- return this;
9991
- }
9992
- digestInto(out) {
9993
- aexists(this);
9994
- aoutput(out, this);
9995
- const { pos, buffer32 } = this;
9996
- this.finished = true;
9997
- clean(this.buffer.subarray(pos));
9998
- swap32IfBE(buffer32);
9999
- this.compress(buffer32, 0, true);
10000
- swap32IfBE(buffer32);
10001
- const out32 = u32(out);
10002
- this.get().forEach((v, i) => out32[i] = swap8IfBE(v));
10003
- }
10004
- digest() {
10005
- const { buffer, outputLen } = this;
10006
- this.digestInto(buffer);
10007
- const res = buffer.slice(0, outputLen);
10008
- this.destroy();
10009
- return res;
10010
- }
10011
- _cloneInto(to) {
10012
- const { buffer, length: length4, finished, destroyed, outputLen, pos } = this;
10013
- to || (to = new this.constructor({ dkLen: outputLen }));
10014
- to.set(...this.get());
10015
- to.buffer.set(buffer);
10016
- to.destroyed = destroyed;
10017
- to.finished = finished;
10018
- to.length = length4;
10019
- to.pos = pos;
10020
- to.outputLen = outputLen;
10021
- return to;
10022
- }
10023
- clone() {
10024
- return this._cloneInto();
10025
- }
10026
- };
10027
- }
10028
- });
10029
-
10030
- // ../../node_modules/@noble/hashes/esm/blake3.js
10031
- var B3_Flags, B3_IV, B3_SIGMA, BLAKE3, blake3;
10032
- var init_blake3 = __esm({
10033
- "../../node_modules/@noble/hashes/esm/blake3.js"() {
10034
- "use strict";
10035
- init_md();
10036
- init_u64();
10037
- init_blake2();
10038
- init_utils();
10039
- B3_Flags = {
10040
- CHUNK_START: 1,
10041
- CHUNK_END: 2,
10042
- PARENT: 4,
10043
- ROOT: 8,
10044
- KEYED_HASH: 16,
10045
- DERIVE_KEY_CONTEXT: 32,
10046
- DERIVE_KEY_MATERIAL: 64
10047
- };
10048
- B3_IV = SHA256_IV.slice();
10049
- B3_SIGMA = /* @__PURE__ */ (() => {
10050
- const Id = Array.from({ length: 16 }, (_, i) => i);
10051
- const permute = (arr) => [2, 6, 3, 10, 7, 0, 4, 13, 1, 11, 12, 5, 9, 14, 15, 8].map((i) => arr[i]);
10052
- const res = [];
10053
- for (let i = 0, v = Id; i < 7; i++, v = permute(v))
10054
- res.push(...v);
10055
- return Uint8Array.from(res);
10056
- })();
10057
- BLAKE3 = class _BLAKE3 extends BLAKE2 {
10058
- constructor(opts = {}, flags = 0) {
10059
- super(64, opts.dkLen === void 0 ? 32 : opts.dkLen);
10060
- this.chunkPos = 0;
10061
- this.chunksDone = 0;
10062
- this.flags = 0 | 0;
10063
- this.stack = [];
10064
- this.posOut = 0;
10065
- this.bufferOut32 = new Uint32Array(16);
10066
- this.chunkOut = 0;
10067
- this.enableXOF = true;
10068
- const { key, context } = opts;
10069
- const hasContext = context !== void 0;
10070
- if (key !== void 0) {
10071
- if (hasContext)
10072
- throw new Error('Only "key" or "context" can be specified at same time');
10073
- const k = toBytes(key).slice();
10074
- abytes(k, 32);
10075
- this.IV = u32(k);
10076
- swap32IfBE(this.IV);
10077
- this.flags = flags | B3_Flags.KEYED_HASH;
10078
- } else if (hasContext) {
10079
- const ctx = toBytes(context);
10080
- const contextKey = new _BLAKE3({ dkLen: 32 }, B3_Flags.DERIVE_KEY_CONTEXT).update(ctx).digest();
10081
- this.IV = u32(contextKey);
10082
- swap32IfBE(this.IV);
10083
- this.flags = flags | B3_Flags.DERIVE_KEY_MATERIAL;
10084
- } else {
10085
- this.IV = B3_IV.slice();
10086
- this.flags = flags;
10087
- }
10088
- this.state = this.IV.slice();
10089
- this.bufferOut = u8(this.bufferOut32);
10090
- }
10091
- // Unused
10092
- get() {
10093
- return [];
10094
- }
10095
- set() {
10096
- }
10097
- b2Compress(counter, flags, buf, bufPos = 0) {
10098
- const { state: s, pos } = this;
10099
- const { h, l } = fromBig(BigInt(counter), true);
10100
- const { v0, v1, v2, v3, v4: v42, v5, v6: v62, v7, v8, v9, v10, v11, v12, v13, v14, v15 } = compress(B3_SIGMA, bufPos, buf, 7, s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], B3_IV[0], B3_IV[1], B3_IV[2], B3_IV[3], h, l, pos, flags);
10101
- s[0] = v0 ^ v8;
10102
- s[1] = v1 ^ v9;
10103
- s[2] = v2 ^ v10;
10104
- s[3] = v3 ^ v11;
10105
- s[4] = v42 ^ v12;
10106
- s[5] = v5 ^ v13;
10107
- s[6] = v62 ^ v14;
10108
- s[7] = v7 ^ v15;
10109
- }
10110
- compress(buf, bufPos = 0, isLast = false) {
10111
- let flags = this.flags;
10112
- if (!this.chunkPos)
10113
- flags |= B3_Flags.CHUNK_START;
10114
- if (this.chunkPos === 15 || isLast)
10115
- flags |= B3_Flags.CHUNK_END;
10116
- if (!isLast)
10117
- this.pos = this.blockLen;
10118
- this.b2Compress(this.chunksDone, flags, buf, bufPos);
10119
- this.chunkPos += 1;
10120
- if (this.chunkPos === 16 || isLast) {
10121
- let chunk = this.state;
10122
- this.state = this.IV.slice();
10123
- for (let last, chunks = this.chunksDone + 1; isLast || !(chunks & 1); chunks >>= 1) {
10124
- if (!(last = this.stack.pop()))
10125
- break;
10126
- this.buffer32.set(last, 0);
10127
- this.buffer32.set(chunk, 8);
10128
- this.pos = this.blockLen;
10129
- this.b2Compress(0, this.flags | B3_Flags.PARENT, this.buffer32, 0);
10130
- chunk = this.state;
10131
- this.state = this.IV.slice();
10132
- }
10133
- this.chunksDone++;
10134
- this.chunkPos = 0;
10135
- this.stack.push(chunk);
10136
- }
10137
- this.pos = 0;
10138
- }
10139
- _cloneInto(to) {
10140
- to = super._cloneInto(to);
10141
- const { IV, flags, state, chunkPos, posOut, chunkOut, stack, chunksDone } = this;
10142
- to.state.set(state.slice());
10143
- to.stack = stack.map((i) => Uint32Array.from(i));
10144
- to.IV.set(IV);
10145
- to.flags = flags;
10146
- to.chunkPos = chunkPos;
10147
- to.chunksDone = chunksDone;
10148
- to.posOut = posOut;
10149
- to.chunkOut = chunkOut;
10150
- to.enableXOF = this.enableXOF;
10151
- to.bufferOut32.set(this.bufferOut32);
10152
- return to;
10153
- }
10154
- destroy() {
10155
- this.destroyed = true;
10156
- clean(this.state, this.buffer32, this.IV, this.bufferOut32);
10157
- clean(...this.stack);
10158
- }
10159
- // Same as b2Compress, but doesn't modify state and returns 16 u32 array (instead of 8)
10160
- b2CompressOut() {
10161
- const { state: s, pos, flags, buffer32, bufferOut32: out32 } = this;
10162
- const { h, l } = fromBig(BigInt(this.chunkOut++));
10163
- swap32IfBE(buffer32);
10164
- const { v0, v1, v2, v3, v4: v42, v5, v6: v62, v7, v8, v9, v10, v11, v12, v13, v14, v15 } = compress(B3_SIGMA, 0, buffer32, 7, s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], B3_IV[0], B3_IV[1], B3_IV[2], B3_IV[3], l, h, pos, flags);
10165
- out32[0] = v0 ^ v8;
10166
- out32[1] = v1 ^ v9;
10167
- out32[2] = v2 ^ v10;
10168
- out32[3] = v3 ^ v11;
10169
- out32[4] = v42 ^ v12;
10170
- out32[5] = v5 ^ v13;
10171
- out32[6] = v62 ^ v14;
10172
- out32[7] = v7 ^ v15;
10173
- out32[8] = s[0] ^ v8;
10174
- out32[9] = s[1] ^ v9;
10175
- out32[10] = s[2] ^ v10;
10176
- out32[11] = s[3] ^ v11;
10177
- out32[12] = s[4] ^ v12;
10178
- out32[13] = s[5] ^ v13;
10179
- out32[14] = s[6] ^ v14;
10180
- out32[15] = s[7] ^ v15;
10181
- swap32IfBE(buffer32);
10182
- swap32IfBE(out32);
10183
- this.posOut = 0;
10184
- }
10185
- finish() {
10186
- if (this.finished)
10187
- return;
10188
- this.finished = true;
10189
- clean(this.buffer.subarray(this.pos));
10190
- let flags = this.flags | B3_Flags.ROOT;
10191
- if (this.stack.length) {
10192
- flags |= B3_Flags.PARENT;
10193
- swap32IfBE(this.buffer32);
10194
- this.compress(this.buffer32, 0, true);
10195
- swap32IfBE(this.buffer32);
10196
- this.chunksDone = 0;
10197
- this.pos = this.blockLen;
10198
- } else {
10199
- flags |= (!this.chunkPos ? B3_Flags.CHUNK_START : 0) | B3_Flags.CHUNK_END;
10200
- }
10201
- this.flags = flags;
10202
- this.b2CompressOut();
10203
- }
10204
- writeInto(out) {
10205
- aexists(this, false);
10206
- abytes(out);
10207
- this.finish();
10208
- const { blockLen, bufferOut } = this;
10209
- for (let pos = 0, len = out.length; pos < len; ) {
10210
- if (this.posOut >= blockLen)
10211
- this.b2CompressOut();
10212
- const take = Math.min(blockLen - this.posOut, len - pos);
10213
- out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);
10214
- this.posOut += take;
10215
- pos += take;
10216
- }
10217
- return out;
10218
- }
10219
- xofInto(out) {
10220
- if (!this.enableXOF)
10221
- throw new Error("XOF is not possible after digest call");
10222
- return this.writeInto(out);
10223
- }
10224
- xof(bytes) {
10225
- anumber(bytes);
10226
- return this.xofInto(new Uint8Array(bytes));
10227
- }
10228
- digestInto(out) {
10229
- aoutput(out, this);
10230
- if (this.finished)
10231
- throw new Error("digest() was already called");
10232
- this.enableXOF = false;
10233
- this.writeInto(out);
10234
- this.destroy();
10235
- return out;
10236
- }
10237
- digest() {
10238
- return this.digestInto(new Uint8Array(this.outputLen));
10239
- }
10240
- };
10241
- blake3 = /* @__PURE__ */ createXOFer((opts) => new BLAKE3(opts));
10242
- }
10243
- });
10244
-
10245
- // ../bootstrap/dist/index.js
9868
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@tinycloud/bootstrap/dist/index.js
10246
9869
  function actionKey(action) {
10247
9870
  if (action === "*") return "ALL";
10248
9871
  return action.toUpperCase().replace(/[^A-Z0-9]/g, "_");
@@ -10397,7 +10020,7 @@ function composeBootstrapSpaceManifest(space) {
10397
10020
  }
10398
10021
  var CAPABILITIES, KV, SQL, DUCKDB, CAPABILITIES2, HOOKS, ENCRYPTION, SPACE, CAPABILITY_REGISTRY, DEFAULT_MANIFEST_SPACE, ACCOUNT_REGISTRY_SPACE, ACCOUNT_REGISTRY_PATH, SECRETS_SPACE, BOOTSTRAP_DEFAULT_SPACE, BOOTSTRAP_PUBLIC_SPACE, BOOTSTRAP_ENCRYPTION_NETWORK_NAME, BOOTSTRAP_ENCRYPTION_NETWORK_RESOURCE_TEMPLATE, DEFAULT_EXPIRY_MS, VAULT_PERMISSION_SERVICE, ENCRYPTION_PERMISSION_SERVICE, ENCRYPTION_MANIFEST_SPACE, NETWORK_CREATE_ACTION, BOOTSTRAP_SPACE_NAMES, TINYCLOUD_DEFAULT_SPACE_MANIFEST, TINYCLOUD_APPLICATIONS_SPACE_MANIFEST, TINYCLOUD_ACCOUNT_SPACE_MANIFEST, TINYCLOUD_SECRETS_BOOTSTRAP_MANIFEST, TINYCLOUD_PUBLIC_SPACE_MANIFEST, BOOTSTRAP_SPACE_MANIFESTS, BOOTSTRAP_PERSISTED_APPLICATION_MANIFESTS, ACCOUNT_INDEX_SCHEMA, SECRET_RECORDS_SCHEMA, BOOTSTRAP_MANIFEST, ACCOUNT_MANIFEST_PERMISSIONS, BOOTSTRAP_DEFAULT_ONLY_SESSION_REQUEST, BOOTSTRAP_WIDENED_DEFAULT_SESSION_REQUEST, BOOTSTRAP_SESSION_REQUESTS, ACCOUNT_SESSION_RAW_ALLOWLIST, BOOTSTRAP_ALLOWLIST;
10399
10022
  var init_dist = __esm({
10400
- "../bootstrap/dist/index.js"() {
10023
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@tinycloud/bootstrap/dist/index.js"() {
10401
10024
  "use strict";
10402
10025
  CAPABILITIES = [
10403
10026
  { urn: "tinycloud.kv/get", service: "tinycloud.kv", status: "active" },
@@ -10786,9 +10409,9 @@ var init_dist = __esm({
10786
10409
  }
10787
10410
  });
10788
10411
 
10789
- // ../../node_modules/ms/index.js
10412
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/ms/index.js
10790
10413
  var require_ms = __commonJS({
10791
- "../../node_modules/ms/index.js"(exports, module) {
10414
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/ms/index.js"(exports, module) {
10792
10415
  "use strict";
10793
10416
  var s = 1e3;
10794
10417
  var m = s * 60;
@@ -10903,9 +10526,9 @@ var require_ms = __commonJS({
10903
10526
  }
10904
10527
  });
10905
10528
 
10906
- // ../sdk-services/dist/internal/decrypt-transport-response-error.cjs
10529
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@tinycloud/sdk-services/dist/internal/decrypt-transport-response-error.cjs
10907
10530
  var require_decrypt_transport_response_error = __commonJS({
10908
- "../sdk-services/dist/internal/decrypt-transport-response-error.cjs"(exports, module) {
10531
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@tinycloud/sdk-services/dist/internal/decrypt-transport-response-error.cjs"(exports, module) {
10909
10532
  "use strict";
10910
10533
  var __defProp4 = Object.defineProperty;
10911
10534
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -10940,7 +10563,7 @@ var require_decrypt_transport_response_error = __commonJS({
10940
10563
  }
10941
10564
  });
10942
10565
 
10943
- // ../sdk-services/dist/index.js
10566
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@tinycloud/sdk-services/dist/index.js
10944
10567
  function ok(data) {
10945
10568
  return { ok: true, data };
10946
10569
  }
@@ -12600,7 +12223,7 @@ function encErr(error) {
12600
12223
  }
12601
12224
  var import_decrypt_transport_response_error, ErrorCodes, defaultRetryPolicy, TelemetryEvents, REDACTED, SAFE_NUMBER_FIELDS, SAFE_BOOLEAN_FIELDS, DEBUG_FLAG, MAX_EVENTS, TinyCloudDebugLogger, tinyCloudDebugLogger, ServiceErrorSchema, GenericResultSchema, KVResponseHeadersSchema, GenericKVResponseSchema, KVListResponseSchema, KVListResultSchema, ServiceRequestEventSchema, ServiceResponseEventSchema, ServiceErrorEventSchema, ServiceRetryEventSchema, TelemetrySpanEventSchema, RetryPolicySchema, ServiceSessionSchema, BaseService, PrefixedKVService, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, KVAction, MAX_KV_BATCH_READ_ITEMS, KVService, SQLMigrations, DatabaseHandle, SQLAction, DDL_TOKENS, MIGRATIONS_TABLE, MIGRATIONS_SCHEMA, MIGRATIONS_META_NAMESPACE, MIGRATIONS_META_ID, SQLService, DuckDbDatabaseHandle, DuckDbAction, DuckDbService, AsyncQueue, HooksService, VaultVersionConfig, CURRENT_VAULT_VERSION, VaultHeaders, DB_NAME, DB_VERSION, STORE_NAME, WRAP_KEY_ID, DataVaultService, SECRET_NAME_RE, SECRET_PREFIX, SCOPED_SECRET_PREFIX, RESERVED_SECRET_SCOPES, HEX, URN_PREFIX, NETWORK_NAME_RE, PKH_EIP155_DID_RE, NetworkIdError, DEFAULT_ENCRYPTION_ALG, ENVELOPE_VERSION, DEFAULT_KEY_VERSION, DECRYPT_FACT_TYPE, DECRYPT_RESULT_TYPE, EncryptionService;
12602
12225
  var init_dist2 = __esm({
12603
- "../sdk-services/dist/index.js"() {
12226
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@tinycloud/sdk-services/dist/index.js"() {
12604
12227
  "use strict";
12605
12228
  init_zod();
12606
12229
  init_dist();
@@ -14671,7 +14294,7 @@ var init_dist2 = __esm({
14671
14294
  async handleErrorResponse(response, operation) {
14672
14295
  const errorText = await response.text();
14673
14296
  const errorBody = parseServiceErrorBody(errorText);
14674
- const errorCode2 = this.mapHttpStatusToErrorCode(
14297
+ const errorCode = this.mapHttpStatusToErrorCode(
14675
14298
  response.status,
14676
14299
  errorBody.error
14677
14300
  );
@@ -14689,7 +14312,7 @@ var init_dist2 = __esm({
14689
14312
  if (resource) meta.resource = resource;
14690
14313
  }
14691
14314
  return err(
14692
- serviceError(errorCode2, message, "sql", { meta })
14315
+ serviceError(errorCode, message, "sql", { meta })
14693
14316
  );
14694
14317
  }
14695
14318
  mapHttpStatusToErrorCode(status, serverError) {
@@ -15019,7 +14642,7 @@ var init_dist2 = __esm({
15019
14642
  async handleErrorResponse(response, operation) {
15020
14643
  const errorText = await response.text();
15021
14644
  const errorBody = parseServiceErrorBody(errorText);
15022
- const errorCode2 = this.mapHttpStatusToErrorCode(
14645
+ const errorCode = this.mapHttpStatusToErrorCode(
15023
14646
  response.status,
15024
14647
  errorBody.error
15025
14648
  );
@@ -15037,7 +14660,7 @@ var init_dist2 = __esm({
15037
14660
  if (resource) meta.resource = resource;
15038
14661
  }
15039
14662
  return err(
15040
- serviceError(errorCode2, message, "duckdb", { meta })
14663
+ serviceError(errorCode, message, "duckdb", { meta })
15041
14664
  );
15042
14665
  }
15043
14666
  mapHttpStatusToErrorCode(status, serverError) {
@@ -16803,10 +16426,7 @@ var init_dist2 = __esm({
16803
16426
  const descriptor = usable.data;
16804
16427
  const networkPublicKey = base64Decode2(descriptor.publicEncryptionKey);
16805
16428
  const result = encryptToNetwork(this.crypto, {
16806
- // Discovery returns the node's canonical network identifier. Persist
16807
- // that spelling in the envelope so a later response can be compared
16808
- // byte-for-byte (notably for checksummed did:pkh principals).
16809
- networkId: descriptor.networkId,
16429
+ networkId,
16810
16430
  networkPublicKey,
16811
16431
  plaintext,
16812
16432
  ...options?.aad !== void 0 ? { aad: options.aad } : {},
@@ -16968,7 +16588,7 @@ var init_dist2 = __esm({
16968
16588
  }
16969
16589
  });
16970
16590
 
16971
- // ../share-sdk/dist/index.js
16591
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@tinycloud/share-sdk/dist/index.js
16972
16592
  function setErrorMap2(map) {
16973
16593
  overrideErrorMap2 = map;
16974
16594
  }
@@ -17471,25 +17091,25 @@ function encodeTo(int, target, offset = 0) {
17471
17091
  function encodingLength(int) {
17472
17092
  return varint_default.encodingLength(int);
17473
17093
  }
17474
- function create(code22, digest3) {
17475
- const size2 = digest3.byteLength;
17094
+ function create(code22, digest4) {
17095
+ const size2 = digest4.byteLength;
17476
17096
  const sizeOffset = encodingLength(code22);
17477
17097
  const digestOffset = sizeOffset + encodingLength(size2);
17478
17098
  const bytes3 = new Uint8Array(digestOffset + size2);
17479
17099
  encodeTo(code22, bytes3, 0);
17480
17100
  encodeTo(size2, bytes3, sizeOffset);
17481
- bytes3.set(digest3, digestOffset);
17482
- return new Digest(code22, size2, digest3, bytes3);
17101
+ bytes3.set(digest4, digestOffset);
17102
+ return new Digest(code22, size2, digest4, bytes3);
17483
17103
  }
17484
17104
  function decode4(multihash) {
17485
17105
  const bytes3 = coerce22(multihash);
17486
17106
  const [code22, sizeOffset] = decode3(bytes3);
17487
17107
  const [size2, digestOffset] = decode3(bytes3.subarray(sizeOffset));
17488
- const digest3 = bytes3.subarray(sizeOffset + digestOffset);
17489
- if (digest3.byteLength !== size2) {
17108
+ const digest4 = bytes3.subarray(sizeOffset + digestOffset);
17109
+ if (digest4.byteLength !== size2) {
17490
17110
  throw new Error("Incorrect length");
17491
17111
  }
17492
- return new Digest(code22, size2, digest3, bytes3);
17112
+ return new Digest(code22, size2, digest4, bytes3);
17493
17113
  }
17494
17114
  function equals2(a, b) {
17495
17115
  if (a === b) {
@@ -17582,8 +17202,8 @@ function encodeCID(version2, code22, multihash) {
17582
17202
  return bytes3;
17583
17203
  }
17584
17204
  async function computeCid(bytes3) {
17585
- const digest3 = create(SHA256_CODE, sha256(new Uint8Array(bytes3)));
17586
- return CID.create(1, code, digest3).toString();
17205
+ const digest4 = create(SHA256_CODE, sha256(new Uint8Array(bytes3)));
17206
+ return CID.create(1, code, digest4).toString();
17587
17207
  }
17588
17208
  function isCanonicalRawCid(cidString) {
17589
17209
  let cid2;
@@ -17695,7 +17315,7 @@ function validateV3Invariants(value, ctx) {
17695
17315
  if (value.contentSource.encryptionNetwork !== value.encryptionNetwork) {
17696
17316
  ctx.addIssue({ code: external_exports2.ZodIssueCode.custom, path: ["encryptionNetwork"], message: "encryption network is not bound to the source" });
17697
17317
  }
17698
- if (value.attestedEnforcerBinding.enforcerDid !== value.target.nodeAudience || value.attestedEnforcerBinding.signature.signerDid !== value.attestedEnforcerBinding.nodeAudience || Date.parse(value.attestedEnforcerBinding.expiresAt) < Date.parse(value.expiry)) {
17318
+ if (value.attestedEnforcerBinding.enforcerDid !== value.target.nodeAudience || value.attestedEnforcerBinding.nodeAudience !== value.target.nodeAudience || value.attestedEnforcerBinding.signature.signerDid !== value.target.nodeAudience || Date.parse(value.attestedEnforcerBinding.expiresAt) < Date.parse(value.expiry)) {
17699
17319
  ctx.addIssue({ code: external_exports2.ZodIssueCode.custom, path: ["attestedEnforcerBinding"], message: "enforcer binding does not cover the target and share lifetime" });
17700
17320
  }
17701
17321
  if (value.policy.contentSource.shareId !== value.contentSource.shareId || value.policy.contentSource.kvResource !== value.contentSource.kvResource || value.policy.contentSource.selector !== value.contentSource.selector || value.policy.contentSource.encryptionNetwork !== value.encryptionNetwork || value.policy.contentSource.encryptedSymmetricKeyDigestHex !== value.contentSource.encryptedSymmetricKeyDigestHex || value.policy.contentSource.keyVersion !== value.contentSource.keyVersion || value.policy.contentSource.mode !== value.contentSource.mode || value.policy.contentSource.initialCiphertextDigestHex !== value.contentSource.initialCiphertextDigestHex) {
@@ -18039,42 +17659,6 @@ function serialize(value) {
18039
17659
  function canonicalize2(value) {
18040
17660
  return serialize(value);
18041
17661
  }
18042
- function verifyCompactUcanAuthorization(authorization, expectedCid) {
18043
- if (/\s/.test(authorization)) throw new TypeError("compact Authorization contains whitespace");
18044
- const segments = authorization.split(".");
18045
- if (segments.length !== 3 || segments.some((segment) => segment.length === 0)) throw new TypeError("compact Authorization must contain three segments");
18046
- const [headerSegment, payloadSegment, signatureSegment] = segments;
18047
- const headerBytes = fromBase64Url(headerSegment);
18048
- const payloadBytes = fromBase64Url(payloadSegment);
18049
- const signature = fromBase64Url(signatureSegment);
18050
- const decoder = new TextDecoder("utf-8", { fatal: true });
18051
- const header = JSON.parse(decoder.decode(headerBytes));
18052
- const payload = JSON.parse(decoder.decode(payloadBytes));
18053
- if (canonicalize2(header) !== decoder.decode(headerBytes) || canonicalize2(payload) !== decoder.decode(payloadBytes)) throw new TypeError("compact Authorization JSON is not canonical");
18054
- assertExactKeys(header, ["alg", "jwk", "typ", "ucv"], "protected header");
18055
- const jwk = object(header.jwk, "protected JWK");
18056
- assertExactKeys(jwk, ["alg", "crv", "kty", "x"], "protected JWK");
18057
- if (header.alg !== "EdDSA" || header.typ !== "JWT" || header.ucv !== "0.10.0" || jwk.alg !== "EdDSA" || jwk.crv !== "Ed25519" || jwk.kty !== "OKP" || typeof jwk.x !== "string") throw new TypeError("compact Authorization header is invalid");
18058
- assertExactKeys(payload, ["att", "aud", "exp", "fct", "iss", "nbf", "nnc", "prf"], "UCAN payload");
18059
- if (typeof payload.iss !== "string" || typeof payload.aud !== "string" || typeof payload.nnc !== "string" || !Number.isInteger(payload.nbf) || !Number.isInteger(payload.exp) || payload.nbf >= payload.exp || !Array.isArray(payload.prf) || payload.prf.some((proof) => typeof proof !== "string") || !Array.isArray(payload.fct) || payload.fct.length !== 1) throw new TypeError("compact Authorization payload is invalid");
18060
- const principal = payload.iss.split("#", 1)[0];
18061
- const publicKey = ed25519PublicKeyFromDidKey(principal);
18062
- if (!equal(publicKey, fromBase64Url(jwk.x))) throw new TypeError("compact Authorization JWK does not bind issuer");
18063
- if (!ed25519.verify(signature, new TextEncoder().encode(`${headerSegment}.${payloadSegment}`), publicKey, { zip215: false })) throw new TypeError("compact Authorization signature is invalid");
18064
- const cid2 = CID.createV1(85, create(30, blake3(new TextEncoder().encode(authorization)))).toString();
18065
- if (expectedCid !== void 0 && cid2 !== expectedCid) throw new TypeError("compact Authorization CID mismatch");
18066
- return { authorization, cid: cid2, header, payload };
18067
- }
18068
- function object(value, label) {
18069
- if (value === null || typeof value !== "object" || Array.isArray(value)) throw new TypeError(`${label} must be an object`);
18070
- return value;
18071
- }
18072
- function assertExactKeys(value, keys, label) {
18073
- if (Object.keys(value).length !== keys.length || Object.keys(value).some((key) => !keys.includes(key))) throw new TypeError(`${label} has unknown or missing fields`);
18074
- }
18075
- function equal(left, right) {
18076
- return left.length === right.length && left.every((byte, index) => byte === right[index]);
18077
- }
18078
17662
  function signingBytes(unsigned) {
18079
17663
  const domain = utf8Bytes(ENVELOPE_SIGNATURE_DOMAIN);
18080
17664
  const body = utf8Bytes(canonicalize2(unsigned));
@@ -18091,14 +17675,6 @@ function signingBytesV2(unsigned) {
18091
17675
  bytes3.set(body, domain.length);
18092
17676
  return bytes3;
18093
17677
  }
18094
- function signingBytesV3(unsigned) {
18095
- const domain = utf8Bytes(ENVELOPE_V3_SIGNATURE_DOMAIN);
18096
- const body = utf8Bytes(canonicalize2(unsigned));
18097
- const bytes3 = new Uint8Array(domain.length + body.length);
18098
- bytes3.set(domain);
18099
- bytes3.set(body, domain.length);
18100
- return bytes3;
18101
- }
18102
17678
  function signEnvelope(envelopeWithoutSig, ed25519PrivKey) {
18103
17679
  const unsigned = unsignedShareEnvelopeSchema.parse(envelopeWithoutSig);
18104
17680
  const publicKey = ed25519.getPublicKey(ed25519PrivKey);
@@ -18146,92 +17722,6 @@ async function verifyEnvelopeV2(envelope, options) {
18146
17722
  if (parsed.authorizationTarget.kind === "policy") return await computeCid(fromBase64Url(parsed.authorizationTarget.policyBytes)) === parsed.authorizationTarget.policyCid;
18147
17723
  return true;
18148
17724
  }
18149
- function verifyEnvelopeV3SignatureOnly(envelope) {
18150
- const parsed = shareEnvelopeV3Schema.parse(envelope);
18151
- const { signature, ...unsigned } = parsed;
18152
- return ed25519.verify(fromBase64Url(signature.value), sha2562(signingBytesV3(unsigned)), ed25519PublicKeyFromDidKey(signature.signerDid), ED25519_VERIFY_OPTS2);
18153
- }
18154
- async function verifyEnvelopeV3(envelope, options) {
18155
- const parsed = shareEnvelopeV3Schema.parse(envelope);
18156
- if (parsed.signature.signerDid !== options.expectedSignerDid || parsed.signature.signerDid !== parsed.policy.ownerDid || !verifyEnvelopeV3SignatureOnly(parsed)) return false;
18157
- const { policy } = parsed;
18158
- const unsignedPolicy = { ...policy };
18159
- delete unsignedPolicy.policyId;
18160
- delete unsignedPolicy.signature;
18161
- const policySignatureDomain = policy.schema === "xyz.tinycloud.policy/policy/v2" ? POLICY_V2_SIGNATURE_DOMAIN : POLICY_V1_SIGNATURE_DOMAIN;
18162
- const policyDigest = sha2562(new TextEncoder().encode(`${policySignatureDomain}${canonicalize2(unsignedPolicy)}`));
18163
- const policySignature = policy.signature;
18164
- if (policySignature.suite !== "Ed25519" || policySignature.signerDid !== policy.ownerDid) return false;
18165
- let policyPublicKey;
18166
- let policySignatureBytes;
18167
- try {
18168
- policyPublicKey = ed25519PublicKeyFromDidKey(policy.ownerDid);
18169
- policySignatureBytes = fromBase64Url(policySignature.value);
18170
- } catch {
18171
- return false;
18172
- }
18173
- if (policySignatureBytes.length !== 64 || !ed25519.verify(policySignatureBytes, policyDigest, policyPublicKey, ED25519_VERIFY_OPTS2)) return false;
18174
- const policyIdDigest = policyDigest;
18175
- if (policy.policyId !== `pol_${base32Lower(policyIdDigest)}`) return false;
18176
- const policyBytes = new TextEncoder().encode(canonicalize2(policy));
18177
- if (await computeCid(policyBytes) !== parsed.policyCid) return false;
18178
- const sourceDigest = sha2562(new TextEncoder().encode(`${CONTENT_SOURCE_V1_DOMAIN}${canonicalize2(policy.contentSource)}`));
18179
- if (hex(sourceDigest) !== parsed.contentSourceDigestHex) return false;
18180
- const sortedCapabilities = [...policy.capabilityCeiling].sort((left, right) => canonicalize2(left).localeCompare(canonicalize2(right)));
18181
- const capabilityCeilingHashHex = hex(sha2562(new TextEncoder().encode(`${POLICY_CAPABILITY_V1_DOMAIN}${canonicalize2(sortedCapabilities)}`)));
18182
- const nativeProjection2 = sortedCapabilities.map((capability) => capability.kind === "encryption" ? { service: "tinycloud.encryption", space: capability.resource, path: capability.resource, actions: [capability.action] } : { service: "tinycloud.kv", space: capability.resource.slice(0, capability.resource.indexOf("/kv/")), path: capability.resource.split("/kv/")[1], actions: [...capability.actions], caveat: { type: "xyz.tinycloud.resource/selector", kind: capability.selector, value: capability.resource } }).sort((left, right) => canonicalize2(left).localeCompare(canonicalize2(right)));
18183
- const nativeProjectionHashHex = hex(sha2562(new TextEncoder().encode(`${NATIVE_PROJECTION_V1_DOMAIN}${canonicalize2(nativeProjection2)}`)));
18184
- const expectedAttenuation = Object.fromEntries(sortedCapabilities.map((capability) => capability.kind === "encryption" ? [capability.resource, { [capability.action]: [{}] }] : [capability.resource, Object.fromEntries(capability.actions.map((action) => [action, [{ kind: capability.selector, type: "xyz.tinycloud.resource/selector", value: capability.resource }]]))]));
18185
- const kv = policy.capabilityCeiling.find((capability) => capability.kind === "kv");
18186
- const expectedKvActions = parsed.actions.flatMap((action) => action === "read" ? ["tinycloud.kv/get", "tinycloud.kv/metadata"] : action === "list" ? ["tinycloud.kv/list"] : ["tinycloud.kv/put"]);
18187
- const marker = parsed.contentSource.kvResource.indexOf("/kv/");
18188
- const resourceSpace = marker < 1 ? "" : parsed.contentSource.kvResource.slice(0, marker);
18189
- const resourcePath = marker < 1 ? "" : parsed.contentSource.kvResource.slice(marker + 4);
18190
- if (parsed.shareId !== parsed.contentSource.shareId || resourceSpace !== parsed.target.spaceId || resourcePath !== parsed.resource.path.replace(/\/$/, "") || parsed.resource.kind !== parsed.contentSource.selector || kv?.kind !== "kv" || expectedKvActions.some((action) => !kv.actions.includes(action)) || parsed.encryptionNetwork !== parsed.contentSource.encryptionNetwork || parsed.contentSource.keyVersion <= 0 || policy.expiresAt !== void 0 && Date.parse(parsed.expiry) > Date.parse(policy.expiresAt)) return false;
18191
- const binding = parsed.attestedEnforcerBinding;
18192
- const { signature: bindingSignature, ...unsignedBinding } = binding;
18193
- const expectedBindingDigestHex = hex(sha2562(new TextEncoder().encode(canonicalize2({ enforcerDid: binding.enforcerDid, nodeAudience: binding.nodeAudience }))));
18194
- if (binding.enforcerDid !== parsed.target.nodeAudience || binding.attestationBindingDigestHex !== expectedBindingDigestHex || bindingSignature.signerDid !== binding.nodeAudience || bindingSignature.suite !== "Ed25519" || Date.parse(binding.issuedAt) > Date.now() || Date.parse(binding.expiresAt) <= Date.now() || Date.parse(binding.expiresAt) < Date.parse(parsed.expiry)) return false;
18195
- try {
18196
- const digest3 = sha2562(new TextEncoder().encode(`${ATTESTED_ENFORCER_V2_DOMAIN}${canonicalize2(unsignedBinding)}`));
18197
- if (!ed25519.verify(fromBase64Url(bindingSignature.value), digest3, ed25519PublicKeyFromDidKey(binding.nodeAudience), ED25519_VERIFY_OPTS2)) return false;
18198
- } catch {
18199
- return false;
18200
- }
18201
- if (parsed.policyRoot.role !== "policy-authority" || parsed.enforcementRoot.role !== "policy-enforcement" || parsed.policyRoot.cid === parsed.enforcementRoot.cid) return false;
18202
- try {
18203
- const policyRoot = verifyCompactUcanAuthorization(parsed.policyRoot.authorization, parsed.policyRoot.cid);
18204
- const enforcementRoot = verifyCompactUcanAuthorization(parsed.enforcementRoot.authorization, parsed.enforcementRoot.cid);
18205
- const policyFact = policyRoot.payload.fct[0];
18206
- const enforcementFact = enforcementRoot.payload.fct[0];
18207
- const common = ["ownerDid", "policyId", "policyDigestHex", "policyCid", "contentSourceDigestHex", "capabilityCeilingHashHex", "nativeProjectionHashHex", "nodeAudience"];
18208
- const policyKeys = [...common, "role", "mode"];
18209
- const enforcementKeys = [...policyKeys, "enforcerDid"];
18210
- if (Object.keys(policyFact).length !== policyKeys.length || policyKeys.some((key) => !(key in policyFact)) || Object.keys(enforcementFact).length !== enforcementKeys.length || enforcementKeys.some((key) => !(key in enforcementFact)) || policyRoot.payload.prf.length !== 0 || enforcementRoot.payload.prf.length !== 0 || policyRoot.payload.iss.split("#", 1)[0] !== policy.ownerDid || enforcementRoot.payload.iss.split("#", 1)[0] !== policy.ownerDid || policyRoot.payload.nbf !== enforcementRoot.payload.nbf || policyRoot.payload.exp !== enforcementRoot.payload.exp || canonicalize2(policyRoot.payload.att) !== canonicalize2(expectedAttenuation) || canonicalize2(enforcementRoot.payload.att) !== canonicalize2(expectedAttenuation) || policyFact.role !== "policy-authority" || policyFact.mode !== "policy-source" || "enforcerDid" in policyFact || enforcementFact.role !== "policy-enforcement" || enforcementFact.mode !== "conditional-mint" || policyRoot.payload.aud !== `did:tinycloud:policy:${hex(policyIdDigest)}` || enforcementRoot.payload.aud !== binding.enforcerDid || enforcementFact.enforcerDid !== binding.enforcerDid || common.some((key) => policyFact[key] !== enforcementFact[key]) || policyFact.ownerDid !== policy.ownerDid || policyFact.policyId !== policy.policyId || policyFact.policyDigestHex !== hex(policyIdDigest) || policyFact.policyCid !== parsed.policyCid || policyFact.contentSourceDigestHex !== parsed.contentSourceDigestHex || policyFact.capabilityCeilingHashHex !== capabilityCeilingHashHex || policyFact.nativeProjectionHashHex !== nativeProjectionHashHex || policyFact.nodeAudience !== binding.nodeAudience || policyRoot.payload.exp * 1e3 < Date.parse(parsed.expiry)) return false;
18211
- } catch {
18212
- return false;
18213
- }
18214
- return true;
18215
- }
18216
- function hex(bytes3) {
18217
- return [...bytes3].map((byte) => byte.toString(16).padStart(2, "0")).join("");
18218
- }
18219
- function base32Lower(bytes3) {
18220
- const alphabet2 = "abcdefghijklmnopqrstuvwxyz234567";
18221
- let output2 = "";
18222
- let buffer = 0;
18223
- let bits = 0;
18224
- for (const byte of bytes3) {
18225
- buffer = buffer << 8 | byte;
18226
- bits += 8;
18227
- while (bits >= 5) {
18228
- output2 += alphabet2[buffer >>> bits - 5 & 31];
18229
- bits -= 5;
18230
- }
18231
- }
18232
- if (bits > 0) output2 += alphabet2[buffer << 5 - bits & 31];
18233
- return output2;
18234
- }
18235
17725
  function assertCanonicalCid(cidString) {
18236
17726
  const cid2 = CID.parse(cidString);
18237
17727
  if (cid2.version !== 1 || cid2.code !== code || cid2.multihash.code !== 18 || // sha2-256 (0x12) only, at the link layer too
@@ -18389,12 +17879,8 @@ async function readResponseBytes(response, limit, tooLargeCode) {
18389
17879
  function registryFetcher(options, limit, tooLargeCode = "max-bytes-exceeded", stage = "envelope") {
18390
17880
  if (options.fetchBlob !== void 0) return async (input) => {
18391
17881
  try {
18392
- options.signal?.throwIfAborted();
18393
- const bytes3 = await options.fetchBlob({ ...input, ...options.signal === void 0 ? {} : { signal: options.signal } });
18394
- options.signal?.throwIfAborted();
18395
- return boundedBytes(bytes3, limit, tooLargeCode);
17882
+ return boundedBytes(await options.fetchBlob(input), limit, tooLargeCode);
18396
17883
  } catch (error) {
18397
- if (options.signal?.aborted) throw options.signal.reason ?? error;
18398
17884
  if (error instanceof ShareReceiveError) throw error;
18399
17885
  throw new ShareReceiveError("fetch-failed", "registry unavailable", { stage });
18400
17886
  }
@@ -18404,26 +17890,17 @@ function registryFetcher(options, limit, tooLargeCode = "max-bytes-exceeded", st
18404
17890
  const base33 = options.registryBaseUrl.replace(/\/+$/, "");
18405
17891
  return async ({ cid: cid2 }) => {
18406
17892
  try {
18407
- options.signal?.throwIfAborted();
18408
- const response = await fetchFn(`${base33}/ipfs/${cid2}?format=raw`, {
18409
- headers: { accept: "application/vnd.ipld.raw" },
18410
- redirect: "error",
18411
- ...options.signal === void 0 ? {} : { signal: options.signal }
18412
- });
18413
- options.signal?.throwIfAborted();
17893
+ const response = await fetchFn(`${base33}/ipfs/${cid2}?format=raw`, { headers: { accept: "application/vnd.ipld.raw" }, redirect: "error" });
18414
17894
  if (!response.ok) throw new ShareReceiveError("fetch-failed", `registry returned ${response.status}`, { stage });
18415
- const bytes3 = await readResponseBytes(response, limit, tooLargeCode);
18416
- options.signal?.throwIfAborted();
18417
- return bytes3;
17895
+ return await readResponseBytes(response, limit, tooLargeCode);
18418
17896
  } catch (error) {
18419
- if (options.signal?.aborted) throw options.signal.reason ?? error;
18420
17897
  if (error instanceof ShareReceiveError) throw error;
18421
17898
  throw new ShareReceiveError("fetch-failed", "registry unavailable", { stage });
18422
17899
  }
18423
17900
  };
18424
17901
  }
18425
17902
  function metadataFor(envelope, origin) {
18426
- if (envelope.version === 2 || envelope.version === 3) {
17903
+ if (envelope.version === 2) {
18427
17904
  const targetKind3 = envelope.recipientMatcher.kind === "recipientDid" ? "recipientDid" : envelope.recipientMatcher.kind === "exactEmail" ? "email" : envelope.recipientMatcher.kind === "emailDomain" ? "emailDomain" : "bearer";
18428
17905
  return {
18429
17906
  protocol: "tinycloud-share",
@@ -18439,7 +17916,7 @@ function metadataFor(envelope, origin) {
18439
17916
  ...envelope.display.filename === void 0 ? {} : { filename: envelope.display.filename },
18440
17917
  ...envelope.display.mode === void 0 ? {} : { mode: envelope.display.mode }
18441
17918
  },
18442
- ...envelope.version === 2 && envelope.content !== void 0 ? { content: { cid: envelope.content.cid } } : {}
17919
+ ...envelope.content === void 0 ? {} : { content: { cid: envelope.content.cid } }
18443
17920
  };
18444
17921
  }
18445
17922
  return {
@@ -18464,10 +17941,8 @@ function parseEnvelope(bytes3) {
18464
17941
  const text = new TextDecoder("utf-8", { fatal: true }).decode(bytes3);
18465
17942
  const value = JSON.parse(text);
18466
17943
  if (canonicalize2(value) !== text) throw new Error("share envelope is not canonical JSON");
18467
- if (typeof value === "object" && value !== null && !Array.isArray(value)) {
18468
- const version2 = value.version;
18469
- if (version2 === 3) return shareEnvelopeV3Schema.parse(value);
18470
- if (version2 === 2) return shareEnvelopeV2Schema.parse(value);
17944
+ if (typeof value === "object" && value !== null && !Array.isArray(value) && value.version === 2) {
17945
+ return shareEnvelopeV2Schema.parse(value);
18471
17946
  }
18472
17947
  return shareEnvelopeSchema.parse(value);
18473
17948
  } catch {
@@ -18539,19 +18014,6 @@ async function verifyV2Envelope(envelope, linkOrigin, options) {
18539
18014
  if (options.trustedSignerDid === void 0 || envelope.signature.signerDid !== options.trustedSignerDid) throw new ShareReceiveError("signature-invalid", "an addressed signer trust root is required");
18540
18015
  }
18541
18016
  }
18542
- async function verifyV3Envelope(envelope, linkOrigin, options) {
18543
- if (options.expectedOrigin !== void 0 && linkOrigin !== options.expectedOrigin) {
18544
- throw new ShareReceiveError("origin-mismatch", "share link origin does not match the trusted origin");
18545
- }
18546
- try {
18547
- if (!await verifyEnvelopeV3(envelope, { expectedSignerDid: envelope.policy.ownerDid })) throw new Error("signature");
18548
- } catch {
18549
- throw new ShareReceiveError("signature-invalid", "share signature is invalid");
18550
- }
18551
- const expiry = Date.parse(envelope.expiry);
18552
- if (!Number.isFinite(expiry)) throw new ShareReceiveError("envelope-invalid", "share expiry is invalid");
18553
- if (expiry <= (options.now?.() ?? Date.now())) throw new ShareReceiveError("expired", "share has expired", { expiresAt: envelope.expiry });
18554
- }
18555
18017
  async function verifyV1PolicyEnvelope(envelope, linkOrigin, options) {
18556
18018
  if (envelope.authorizationTarget.kind !== "policy") throw new ShareReceiveError("unsupported-target", "share target is not an addressed policy", { reason: "policy-target" });
18557
18019
  if (envelope.target.origin !== linkOrigin || options.expectedOrigin !== void 0 && (linkOrigin !== options.expectedOrigin || envelope.target.origin !== options.expectedOrigin)) {
@@ -18583,18 +18045,12 @@ async function inspectShare(link2, options = {}) {
18583
18045
  const resolved = await resolveShareEnvelope(link2, options);
18584
18046
  if (resolved.envelope.version === 1 && resolved.envelope.authorizationTarget.kind === "policy") await verifyV1PolicyEnvelope(resolved.envelope, resolved.origin, options);
18585
18047
  else if (resolved.envelope.version === 1) await verifyResolved(resolved.envelope, resolved.origin, options);
18586
- else if (resolved.envelope.version === 2) await verifyV2Envelope(resolved.envelope, resolved.origin, options);
18587
- else await verifyV3Envelope(resolved.envelope, resolved.origin, options);
18588
- if (resolved.envelope.version === 2 || resolved.envelope.version === 3 || resolved.envelope.authorizationTarget.kind === "policy") options.onResolvedAddressedEnvelope?.(resolved.envelope, resolved.cid);
18048
+ else await verifyV2Envelope(resolved.envelope, resolved.origin, options);
18049
+ if (resolved.envelope.version === 2 || resolved.envelope.authorizationTarget.kind === "policy") options.onResolvedAddressedEnvelope?.(resolved.envelope, resolved.cid);
18589
18050
  return { metadata: metadataFor(resolved.envelope, resolved.origin), link: { origin: resolved.origin, cid: resolved.cid, kind: resolved.kind } };
18590
18051
  }
18591
18052
  async function receiveShare(link2, options = {}) {
18592
18053
  const resolved = await resolveShareEnvelope(link2, options);
18593
- if (resolved.envelope.version === 3) {
18594
- await verifyV3Envelope(resolved.envelope, resolved.origin, options);
18595
- options.onResolvedAddressedEnvelope?.(resolved.envelope, resolved.cid);
18596
- return { state: "authorization-required", method: resolved.envelope.recipientMatcher.kind === "recipientDid" ? "openkey-device" : "email-claim" };
18597
- }
18598
18054
  if (resolved.envelope.version === 2) {
18599
18055
  await verifyV2Envelope(resolved.envelope, resolved.origin, options);
18600
18056
  options.onResolvedAddressedEnvelope?.(resolved.envelope, resolved.cid);
@@ -18918,12 +18374,6 @@ async function publishShare(options) {
18918
18374
  envelopeKey?.fill(0);
18919
18375
  }
18920
18376
  }
18921
- function authorizationMethodForTarget(target) {
18922
- if (target.kind === "recipientDid") return "openkey-device";
18923
- if (target.kind === "email") return "email-claim";
18924
- if (target.kind === "emailDomain") return "email-claim";
18925
- return void 0;
18926
- }
18927
18377
  function equals3(aa, bb) {
18928
18378
  if (aa === bb) {
18929
18379
  return true;
@@ -19169,109 +18619,6 @@ function rfc46482({ name: name2, prefix, bitsPerChar, alphabet: alphabet2 }) {
19169
18619
  }
19170
18620
  });
19171
18621
  }
19172
- function validEmail(value) {
19173
- return /^[^@\s]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i.test(value);
19174
- }
19175
- function validDomain(value) {
19176
- return /^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)(?:\.(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?))+$/i.test(value);
19177
- }
19178
- function validRecipientDid(value) {
19179
- if (value.length === 0 || value.length > 2048 || /[\u0000-\u0020\u007f]/.test(value)) return false;
19180
- const parts = value.split(":");
19181
- if (parts.length < 3 || parts[0] !== "did" || !/^[a-z0-9]+$/.test(parts[1] ?? "")) return false;
19182
- const identifier = parts.slice(2);
19183
- if (identifier.some((part) => part.length === 0)) return false;
19184
- if (parts[1] === "web") {
19185
- const host = identifier[0] ?? "";
19186
- if (host.length > 253 || host.split(".").some((label) => !label || label.length > 63 || !/^[A-Za-z0-9-]+$/.test(label) || label.startsWith("-") || label.endsWith("-"))) return false;
19187
- return identifier.slice(1).every((part) => /^[A-Za-z0-9._%-]+$/.test(part));
19188
- }
19189
- if (parts[1] === "pkh") return identifier.length >= 3 && identifier.every((part) => /^[A-Za-z0-9._%-]+$/.test(part));
19190
- if (parts[1] === "key") {
19191
- try {
19192
- const bytes3 = base58btc2.decode(identifier.join(":"));
19193
- return bytes3.length === 34 && bytes3[0] === 237 && bytes3[1] === 1;
19194
- } catch {
19195
- return false;
19196
- }
19197
- }
19198
- return false;
19199
- }
19200
- function normalizeShareTarget(target) {
19201
- if (target.kind === "bearer") return target;
19202
- if (target.kind === "recipientDid") {
19203
- if (!validRecipientDid(target.did)) throw new TypeError("recipient DID is invalid");
19204
- return { kind: target.kind, did: target.did };
19205
- }
19206
- if (target.kind === "email") {
19207
- if (!validEmail(target.address)) throw new TypeError("recipient email is invalid");
19208
- const at = target.address.lastIndexOf("@");
19209
- return { kind: target.kind, address: `${target.address.slice(0, at)}@${target.address.slice(at + 1).toLowerCase()}` };
19210
- }
19211
- if (!validDomain(target.domain)) throw new TypeError("recipient email domain is invalid");
19212
- return { kind: target.kind, domain: target.domain.toLowerCase() };
19213
- }
19214
- function targetAuthorizationMethod(target) {
19215
- return authorizationMethodForTarget(target);
19216
- }
19217
- async function publishTargetShare(input) {
19218
- const target = normalizeShareTarget(input.target);
19219
- if (target.kind === "bearer") return publishShare(input);
19220
- if (input.targetAdapter === void 0) {
19221
- return {
19222
- state: "authorization-required",
19223
- method: targetAuthorizationMethod(target)
19224
- };
19225
- }
19226
- const source = input.source instanceof Uint8Array ? input.source.slice() : await (async () => {
19227
- const chunks = [];
19228
- let size2 = 0;
19229
- for await (const chunk of input.source) {
19230
- if (!(chunk instanceof Uint8Array)) throw new TypeError("addressed publication source yielded invalid bytes");
19231
- size2 += chunk.byteLength;
19232
- if (size2 > (input.maxBytes ?? 100 * 1024 * 1024)) throw new TypeError("addressed publication exceeds maxBytes");
19233
- chunks.push(chunk.slice());
19234
- }
19235
- const bytes3 = new Uint8Array(size2);
19236
- let offset = 0;
19237
- for (const chunk of chunks) {
19238
- bytes3.set(chunk, offset);
19239
- offset += chunk.byteLength;
19240
- }
19241
- return bytes3;
19242
- })();
19243
- const files = input.files === void 0 || input.files.length === 0 ? [{ bytes: source }] : input.files;
19244
- const limit = input.maxBytes ?? SHARE_CONTENT_LIMIT;
19245
- let totalBytes = 0;
19246
- for (const file of files) {
19247
- totalBytes += file.bytes.byteLength;
19248
- if (!Number.isSafeInteger(totalBytes) || totalBytes > limit) {
19249
- throw new SharePublishError("max-bytes-exceeded", "addressed publication exceeds the combined byte limit");
19250
- }
19251
- }
19252
- return input.targetAdapter.publish({
19253
- source,
19254
- filename: input.filename,
19255
- ...input.files === void 0 ? {} : { files: input.files },
19256
- ...input.mediaType === void 0 ? {} : { mediaType: input.mediaType },
19257
- ...input.resourceKind === void 0 ? {} : { resourceKind: input.resourceKind },
19258
- ...input.actions === void 0 ? {} : { actions: input.actions },
19259
- target,
19260
- expiresAt: input.expiresAt ?? new Date((input.now?.() ?? Date.now()) + 7 * 24 * 60 * 60 * 1e3),
19261
- origin: input.origin,
19262
- ...input.inline === void 0 ? {} : { inline: input.inline },
19263
- upload: {
19264
- ...input.registryBaseUrl === void 0 ? {} : { registryBaseUrl: input.registryBaseUrl },
19265
- ...input.fetchFn === void 0 ? {} : { fetchFn: input.fetchFn },
19266
- ...input.authorizeUpload === void 0 ? {} : { authorizeUpload: input.authorizeUpload },
19267
- ...input.authorizationOrigin === void 0 ? {} : { authorizationOrigin: input.authorizationOrigin },
19268
- ...input.credentials === void 0 ? {} : { credentials: input.credentials },
19269
- ...input.allowInsecureRegistry === void 0 ? {} : { allowInsecureRegistry: input.allowInsecureRegistry },
19270
- ...input.uploadBlob === void 0 ? {} : { uploadBlob: input.uploadBlob }
19271
- },
19272
- ...input.notify === void 0 ? {} : { notify: input.notify }
19273
- });
19274
- }
19275
18622
  function encode4(num2, out, offset) {
19276
18623
  out = out || [];
19277
18624
  offset = offset || 0;
@@ -19313,25 +18660,25 @@ function encodeTo2(int, target, offset = 0) {
19313
18660
  function encodingLength2(int) {
19314
18661
  return varint_default2.encodingLength(int);
19315
18662
  }
19316
- function create2(code3, digest3) {
19317
- const size2 = digest3.byteLength;
18663
+ function create2(code3, digest4) {
18664
+ const size2 = digest4.byteLength;
19318
18665
  const sizeOffset = encodingLength2(code3);
19319
18666
  const digestOffset = sizeOffset + encodingLength2(size2);
19320
18667
  const bytes3 = new Uint8Array(digestOffset + size2);
19321
18668
  encodeTo2(code3, bytes3, 0);
19322
18669
  encodeTo2(size2, bytes3, sizeOffset);
19323
- bytes3.set(digest3, digestOffset);
19324
- return new Digest2(code3, size2, digest3, bytes3);
18670
+ bytes3.set(digest4, digestOffset);
18671
+ return new Digest2(code3, size2, digest4, bytes3);
19325
18672
  }
19326
18673
  function decode8(multihash) {
19327
18674
  const bytes3 = coerce3(multihash);
19328
18675
  const [code3, sizeOffset] = decode7(bytes3);
19329
18676
  const [size2, digestOffset] = decode7(bytes3.subarray(sizeOffset));
19330
- const digest3 = bytes3.subarray(sizeOffset + digestOffset);
19331
- if (digest3.byteLength !== size2) {
18677
+ const digest4 = bytes3.subarray(sizeOffset + digestOffset);
18678
+ if (digest4.byteLength !== size2) {
19332
18679
  throw new Error("Incorrect length");
19333
18680
  }
19334
- return new Digest2(code3, size2, digest3, bytes3);
18681
+ return new Digest2(code3, size2, digest4, bytes3);
19335
18682
  }
19336
18683
  function equals4(a, b) {
19337
18684
  if (a === b) {
@@ -19423,6 +18770,115 @@ function encodeCID2(version2, code3, multihash) {
19423
18770
  bytes3.set(multihash, hashOffset);
19424
18771
  return bytes3;
19425
18772
  }
18773
+ function authorizationMethodForTarget(target) {
18774
+ if (target.kind === "recipientDid") return "openkey-device";
18775
+ if (target.kind === "email") return "email-claim";
18776
+ if (target.kind === "emailDomain") return "email-claim";
18777
+ return void 0;
18778
+ }
18779
+ function validEmail(value) {
18780
+ return /^[^@\s]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i.test(value);
18781
+ }
18782
+ function validDomain(value) {
18783
+ return /^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)(?:\.(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?))+$/i.test(value);
18784
+ }
18785
+ function validRecipientDid(value) {
18786
+ if (value.length === 0 || value.length > 2048 || /[\u0000-\u0020\u007f]/.test(value)) return false;
18787
+ const parts = value.split(":");
18788
+ if (parts.length < 3 || parts[0] !== "did" || !/^[a-z0-9]+$/.test(parts[1] ?? "")) return false;
18789
+ const identifier = parts.slice(2);
18790
+ if (identifier.some((part) => part.length === 0)) return false;
18791
+ if (parts[1] === "web") {
18792
+ const host = identifier[0] ?? "";
18793
+ if (host.length > 253 || host.split(".").some((label) => !label || label.length > 63 || !/^[A-Za-z0-9-]+$/.test(label) || label.startsWith("-") || label.endsWith("-"))) return false;
18794
+ return identifier.slice(1).every((part) => /^[A-Za-z0-9._%-]+$/.test(part));
18795
+ }
18796
+ if (parts[1] === "pkh") return identifier.length >= 3 && identifier.every((part) => /^[A-Za-z0-9._%-]+$/.test(part));
18797
+ if (parts[1] === "key") {
18798
+ try {
18799
+ const bytes3 = base58btc2.decode(identifier.join(":"));
18800
+ return bytes3.length === 34 && bytes3[0] === 237 && bytes3[1] === 1;
18801
+ } catch {
18802
+ return false;
18803
+ }
18804
+ }
18805
+ return false;
18806
+ }
18807
+ function normalizeShareTarget(target) {
18808
+ if (target.kind === "bearer") return target;
18809
+ if (target.kind === "recipientDid") {
18810
+ if (!validRecipientDid(target.did)) throw new TypeError("recipient DID is invalid");
18811
+ return { kind: target.kind, did: target.did };
18812
+ }
18813
+ if (target.kind === "email") {
18814
+ if (!validEmail(target.address)) throw new TypeError("recipient email is invalid");
18815
+ const at = target.address.lastIndexOf("@");
18816
+ return { kind: target.kind, address: `${target.address.slice(0, at)}@${target.address.slice(at + 1).toLowerCase()}` };
18817
+ }
18818
+ if (!validDomain(target.domain)) throw new TypeError("recipient email domain is invalid");
18819
+ return { kind: target.kind, domain: target.domain.toLowerCase() };
18820
+ }
18821
+ function targetAuthorizationMethod(target) {
18822
+ return authorizationMethodForTarget(target);
18823
+ }
18824
+ async function publishTargetShare(input) {
18825
+ const target = normalizeShareTarget(input.target);
18826
+ if (target.kind === "bearer") return publishShare(input);
18827
+ if (input.targetAdapter === void 0) {
18828
+ return {
18829
+ state: "authorization-required",
18830
+ method: targetAuthorizationMethod(target)
18831
+ };
18832
+ }
18833
+ const source = input.source instanceof Uint8Array ? input.source.slice() : await (async () => {
18834
+ const chunks = [];
18835
+ let size2 = 0;
18836
+ for await (const chunk of input.source) {
18837
+ if (!(chunk instanceof Uint8Array)) throw new TypeError("addressed publication source yielded invalid bytes");
18838
+ size2 += chunk.byteLength;
18839
+ if (size2 > (input.maxBytes ?? 100 * 1024 * 1024)) throw new TypeError("addressed publication exceeds maxBytes");
18840
+ chunks.push(chunk.slice());
18841
+ }
18842
+ const bytes3 = new Uint8Array(size2);
18843
+ let offset = 0;
18844
+ for (const chunk of chunks) {
18845
+ bytes3.set(chunk, offset);
18846
+ offset += chunk.byteLength;
18847
+ }
18848
+ return bytes3;
18849
+ })();
18850
+ const files = input.files === void 0 || input.files.length === 0 ? [{ bytes: source }] : input.files;
18851
+ const limit = input.maxBytes ?? SHARE_CONTENT_LIMIT;
18852
+ let totalBytes = 0;
18853
+ for (const file of files) {
18854
+ totalBytes += file.bytes.byteLength;
18855
+ if (!Number.isSafeInteger(totalBytes) || totalBytes > limit) {
18856
+ throw new SharePublishError("max-bytes-exceeded", "addressed publication exceeds the combined byte limit");
18857
+ }
18858
+ }
18859
+ return input.targetAdapter.publish({
18860
+ source,
18861
+ filename: input.filename,
18862
+ ...input.files === void 0 ? {} : { files: input.files },
18863
+ ...input.mediaType === void 0 ? {} : { mediaType: input.mediaType },
18864
+ ...input.resourceKind === void 0 ? {} : { resourceKind: input.resourceKind },
18865
+ ...input.actions === void 0 ? {} : { actions: input.actions },
18866
+ target,
18867
+ expiresAt: input.expiresAt ?? new Date((input.now?.() ?? Date.now()) + 7 * 24 * 60 * 60 * 1e3),
18868
+ origin: input.origin,
18869
+ ...input.inline === void 0 ? {} : { inline: input.inline },
18870
+ upload: {
18871
+ ...input.registryBaseUrl === void 0 ? {} : { registryBaseUrl: input.registryBaseUrl },
18872
+ ...input.fetchFn === void 0 ? {} : { fetchFn: input.fetchFn },
18873
+ ...input.authorizeUpload === void 0 ? {} : { authorizeUpload: input.authorizeUpload },
18874
+ ...input.authorizationOrigin === void 0 ? {} : { authorizationOrigin: input.authorizationOrigin },
18875
+ ...input.credentials === void 0 ? {} : { credentials: input.credentials },
18876
+ ...input.allowInsecureRegistry === void 0 ? {} : { allowInsecureRegistry: input.allowInsecureRegistry },
18877
+ ...input.uploadBlob === void 0 ? {} : { uploadBlob: input.uploadBlob }
18878
+ },
18879
+ ...input.notify === void 0 ? {} : { notify: input.notify }
18880
+ });
18881
+ }
19426
18882
  function historyRecordForPublishedShare(result, now = /* @__PURE__ */ new Date()) {
19427
18883
  const target = result.metadata.target.kind;
19428
18884
  const supplied = result.metadata.recipientMatcher;
@@ -19453,7 +18909,6 @@ function historyRecordForPublishedShare(result, now = /* @__PURE__ */ new Date()
19453
18909
  registeredAt: now.toISOString(),
19454
18910
  expiresAt: result.metadata.expiresAt,
19455
18911
  link: result.url,
19456
- ...result.deliveryMaterial === void 0 ? {} : { deliveryMaterial: result.deliveryMaterial },
19457
18912
  ...result.metadata.display.filename === void 0 ? {} : { filename: result.metadata.display.filename }
19458
18913
  };
19459
18914
  }
@@ -19489,11 +18944,11 @@ async function notifyShare(input) {
19489
18944
  }
19490
18945
  async function defaultIdempotencyKey(shareId, recipient) {
19491
18946
  const canonicalRecipient = canonicalize2(recipient.trim().toLowerCase());
19492
- const digest3 = new Uint8Array(await crypto.subtle.digest(
18947
+ const digest4 = new Uint8Array(await crypto.subtle.digest(
19493
18948
  "SHA-256",
19494
18949
  new TextEncoder().encode(canonicalRecipient)
19495
18950
  ));
19496
- return `tinycloud-share:${shareId}:${toBase64Url(digest3)}`;
18951
+ return `tinycloud-share:${shareId}:${toBase64Url(digest4)}`;
19497
18952
  }
19498
18953
  function targetKind2(record2) {
19499
18954
  if (record2.targetKind !== void 0) return record2.targetKind;
@@ -19543,16 +18998,13 @@ async function migrateShare(input) {
19543
18998
  const value = await receiveLegacyShare(input.link, input.reader);
19544
18999
  return { protocol: "tinycloud-share", version: 1, legacy: true, value, migrated: await input.publish(value) };
19545
19000
  }
19546
- var __defProp2, __export2, external_exports2, util2, objectUtil2, ZodParsedType2, getParsedType2, ZodIssueCode2, quotelessJson2, ZodError2, errorMap2, en_default2, overrideErrorMap2, makeIssue2, EMPTY_PATH2, ParseStatus2, INVALID2, DIRTY2, OK2, isAborted2, isDirty2, isValid2, isAsync2, errorUtil2, ParseInputLazyPath2, handleResult2, ZodType2, cuidRegex2, cuid2Regex2, ulidRegex2, uuidRegex2, nanoidRegex2, jwtRegex2, durationRegex2, emailRegex2, _emojiRegex2, emojiRegex2, ipv4Regex2, ipv4CidrRegex2, ipv6Regex2, ipv6CidrRegex2, base64Regex2, base64urlRegex2, dateRegexSource2, dateRegex2, ZodString2, ZodNumber2, ZodBigInt2, ZodBoolean2, ZodDate2, ZodSymbol2, ZodUndefined2, ZodNull2, ZodAny2, ZodUnknown2, ZodNever2, ZodVoid2, ZodArray2, ZodObject2, ZodUnion2, getDiscriminator2, ZodDiscriminatedUnion2, ZodIntersection2, ZodTuple2, ZodRecord2, ZodMap2, ZodSet2, ZodFunction2, ZodLazy2, ZodLiteral2, ZodEnum2, ZodNativeEnum2, ZodPromise2, ZodEffects2, ZodOptional2, ZodNullable2, ZodDefault2, ZodCatch2, ZodNaN2, BRAND2, ZodBranded2, ZodPipeline2, ZodReadonly2, late2, ZodFirstPartyTypeKind2, instanceOfType2, stringType2, numberType2, nanType2, bigIntType2, booleanType2, dateType2, symbolType2, undefinedType2, nullType2, anyType2, unknownType2, neverType2, voidType2, arrayType2, objectType2, strictObjectType2, unionType2, discriminatedUnionType2, intersectionType2, tupleType2, recordType2, mapType2, setType2, functionType2, lazyType2, literalType2, enumType2, nativeEnumType2, promiseType2, effectsType2, optionalType2, nullableType2, preprocessType2, pipelineType2, ostring2, onumber2, oboolean2, coerce2, NEVER2, empty, src, _brrp__multiformats_scope_baseX, base_x_default, Encoder, Decoder, ComposedDecoder, Codec, base32, base32upper, base32pad, base32padupper, base32hex, base32hexupper, base32hexpad, base32hexpadupper, base32z, base36, base36upper, base58btc, base58flickr, encode_1, MSB, REST, MSBALL, INT, decode2, MSB$1, REST$1, N1, N2, N3, N4, N5, N6, N7, N8, N9, length, varint, _brrp_varint, varint_default, Digest, cache, CID, DAG_PB_CODE, SHA_256_CODE, cidSymbol, code, SHA256_CODE, base64, base64pad, base64url, base64urlpad, ED25519_MULTICODEC_PREFIX, PUBLIC_KEY_LENGTH, base64UrlString, sessionJwkCommonFields, okpPrivateJwkSchema, ecPrivateJwkSchema, sessionJwkSchema, policyTargetSchema, bearerKeyTargetSchema, recipientDidTargetSchema, authorizationTargetSchema, resourceSelectorSchema, targetSchema, displaySchema, contentPointerSchema, signatureSchema, unsignedShareEnvelopeSchema, shareEnvelopeSchema, recipientMatcherSchema, shareActionSchema, kvContentSourceSchema, sqlContentSourceSchema, contentSourceSchema, v2TargetSchema, shareDecryptionSchema, ownerAuthoritySchema, contentMetadataSchema, unsignedShareEnvelopeV2BaseSchema, unsignedShareEnvelopeV2Schema, shareEnvelopeV2Schema, unifiedResourceSchema, unifiedEncryptionNetworkSchema, unifiedKvCapabilitySchema, unifiedEncryptionCapabilitySchema, unifiedCapabilitySchema, unifiedContentSourceSchema, unifiedPolicyV1Schema, policyCredentialRequirementV1Schema, unifiedPolicyV2Schema, unifiedPolicySchema, unifiedRootSchema, attestedEnforcerBindingV2Schema, v3TargetSchema, unsignedShareEnvelopeV3BaseSchema, unsignedShareEnvelopeV3Schema, shareEnvelopeV3Schema, BEARER_READ_ABILITY, READ_ABILITIES, ED25519_VERIFY_OPTS, ENVELOPE_AAD_LABEL, SEALED_BLOB_VERSION, AAD, KEY_LENGTH, NONCE_LENGTH, TAG_LENGTH, HEADER_LENGTH, ED25519_VERIFY_OPTS2, ENVELOPE_SIGNATURE_DOMAIN, ENVELOPE_V2_SIGNATURE_DOMAIN, ENVELOPE_V3_SIGNATURE_DOMAIN, POLICY_V1_SIGNATURE_DOMAIN, POLICY_V2_SIGNATURE_DOMAIN, CONTENT_SOURCE_V1_DOMAIN, POLICY_CAPABILITY_V1_DOMAIN, NATIVE_PROJECTION_V1_DOMAIN, ATTESTED_ENFORCER_V2_DOMAIN, KEY_LENGTH2, INLINE_PREFIX, MAX_INLINE_BYTES, SHARE_RESULT_VERSION, DEFAULT_MAX_SEALED_BLOB_BYTES, DEFAULT_MAX_CONTENT_BLOB_BYTES, CONTENT_SEALED_OVERHEAD, ShareReceiveError, SHARE_CONTENT_LIMIT, SHARE_SEALED_OVERHEAD, SHARE_PUBLISH_RESULT_VERSION, DEFAULT_SHARE_LIFETIME_MS, SharePublishError, empty2, src2, _brrp__multiformats_scope_baseX2, base_x_default2, Encoder2, Decoder2, ComposedDecoder2, Codec2, base58btc2, base58flickr2, textEncoder, base322, base32upper2, base32pad2, base32padupper2, base32hex2, base32hexupper2, base32hexpad2, base32hexpadupper2, base32z2, base362, base36upper2, encode_12, MSB2, REST2, MSBALL2, INT2, decode6, MSB$12, REST$12, N12, N22, N32, N42, N52, N62, N72, N82, N92, length2, varint2, _brrp_varint2, varint_default2, Digest2, cache2, CID2, DAG_PB_CODE2, SHA_256_CODE2, cidSymbol2, MAX_CONTENT_BYTES, ShareNotifyError, SHARE_V2_PROTOCOL, DOMAIN, PRESENTATION_DOMAIN, SESSION_DOMAIN, INVOCATION_DOMAIN;
19001
+ var __defProp2, __export2, external_exports2, util2, objectUtil2, ZodParsedType2, getParsedType2, ZodIssueCode2, quotelessJson2, ZodError2, errorMap2, en_default2, overrideErrorMap2, makeIssue2, EMPTY_PATH2, ParseStatus2, INVALID2, DIRTY2, OK2, isAborted2, isDirty2, isValid2, isAsync2, errorUtil2, ParseInputLazyPath2, handleResult2, ZodType2, cuidRegex2, cuid2Regex2, ulidRegex2, uuidRegex2, nanoidRegex2, jwtRegex2, durationRegex2, emailRegex2, _emojiRegex2, emojiRegex2, ipv4Regex2, ipv4CidrRegex2, ipv6Regex2, ipv6CidrRegex2, base64Regex2, base64urlRegex2, dateRegexSource2, dateRegex2, ZodString2, ZodNumber2, ZodBigInt2, ZodBoolean2, ZodDate2, ZodSymbol2, ZodUndefined2, ZodNull2, ZodAny2, ZodUnknown2, ZodNever2, ZodVoid2, ZodArray2, ZodObject2, ZodUnion2, getDiscriminator2, ZodDiscriminatedUnion2, ZodIntersection2, ZodTuple2, ZodRecord2, ZodMap2, ZodSet2, ZodFunction2, ZodLazy2, ZodLiteral2, ZodEnum2, ZodNativeEnum2, ZodPromise2, ZodEffects2, ZodOptional2, ZodNullable2, ZodDefault2, ZodCatch2, ZodNaN2, BRAND2, ZodBranded2, ZodPipeline2, ZodReadonly2, late2, ZodFirstPartyTypeKind2, instanceOfType2, stringType2, numberType2, nanType2, bigIntType2, booleanType2, dateType2, symbolType2, undefinedType2, nullType2, anyType2, unknownType2, neverType2, voidType2, arrayType2, objectType2, strictObjectType2, unionType2, discriminatedUnionType2, intersectionType2, tupleType2, recordType2, mapType2, setType2, functionType2, lazyType2, literalType2, enumType2, nativeEnumType2, promiseType2, effectsType2, optionalType2, nullableType2, preprocessType2, pipelineType2, ostring2, onumber2, oboolean2, coerce2, NEVER2, empty, src, _brrp__multiformats_scope_baseX, base_x_default, Encoder, Decoder, ComposedDecoder, Codec, base32, base32upper, base32pad, base32padupper, base32hex, base32hexupper, base32hexpad, base32hexpadupper, base32z, base36, base36upper, base58btc, base58flickr, encode_1, MSB, REST, MSBALL, INT, decode2, MSB$1, REST$1, N1, N2, N3, N4, N5, N6, N7, N8, N9, length, varint, _brrp_varint, varint_default, Digest, cache, CID, DAG_PB_CODE, SHA_256_CODE, cidSymbol, code, SHA256_CODE, base64, base64pad, base64url, base64urlpad, ED25519_MULTICODEC_PREFIX, PUBLIC_KEY_LENGTH, base64UrlString, sessionJwkCommonFields, okpPrivateJwkSchema, ecPrivateJwkSchema, sessionJwkSchema, policyTargetSchema, bearerKeyTargetSchema, recipientDidTargetSchema, authorizationTargetSchema, resourceSelectorSchema, targetSchema, displaySchema, contentPointerSchema, signatureSchema, unsignedShareEnvelopeSchema, shareEnvelopeSchema, recipientMatcherSchema, shareActionSchema, kvContentSourceSchema, sqlContentSourceSchema, contentSourceSchema, v2TargetSchema, shareDecryptionSchema, ownerAuthoritySchema, contentMetadataSchema, unsignedShareEnvelopeV2BaseSchema, unsignedShareEnvelopeV2Schema, shareEnvelopeV2Schema, unifiedResourceSchema, unifiedEncryptionNetworkSchema, unifiedKvCapabilitySchema, unifiedEncryptionCapabilitySchema, unifiedCapabilitySchema, unifiedContentSourceSchema, unifiedPolicySchema, unifiedRootSchema, attestedEnforcerBindingV2Schema, v3TargetSchema, unsignedShareEnvelopeV3BaseSchema, unsignedShareEnvelopeV3Schema, shareEnvelopeV3Schema, BEARER_READ_ABILITY, READ_ABILITIES, ED25519_VERIFY_OPTS, ENVELOPE_AAD_LABEL, SEALED_BLOB_VERSION, AAD, KEY_LENGTH, NONCE_LENGTH, TAG_LENGTH, HEADER_LENGTH, ED25519_VERIFY_OPTS2, ENVELOPE_SIGNATURE_DOMAIN, ENVELOPE_V2_SIGNATURE_DOMAIN, KEY_LENGTH2, INLINE_PREFIX, MAX_INLINE_BYTES, SHARE_RESULT_VERSION, DEFAULT_MAX_SEALED_BLOB_BYTES, DEFAULT_MAX_CONTENT_BLOB_BYTES, CONTENT_SEALED_OVERHEAD, ShareReceiveError, SHARE_CONTENT_LIMIT, SHARE_SEALED_OVERHEAD, SHARE_PUBLISH_RESULT_VERSION, DEFAULT_SHARE_LIFETIME_MS, SharePublishError, empty2, src2, _brrp__multiformats_scope_baseX2, base_x_default2, Encoder2, Decoder2, ComposedDecoder2, Codec2, base322, base32upper2, base32pad2, base32padupper2, base32hex2, base32hexupper2, base32hexpad2, base32hexpadupper2, base32z2, base362, base36upper2, base58btc2, base58flickr2, encode_12, MSB2, REST2, MSBALL2, INT2, decode6, MSB$12, REST$12, N12, N22, N32, N42, N52, N62, N72, N82, N92, length2, varint2, _brrp_varint2, varint_default2, Digest2, cache2, CID2, DAG_PB_CODE2, SHA_256_CODE2, cidSymbol2, MAX_CONTENT_BYTES, ShareNotifyError, SHARE_V2_PROTOCOL, DOMAIN, PRESENTATION_DOMAIN, SESSION_DOMAIN, INVOCATION_DOMAIN;
19547
19002
  var init_dist3 = __esm({
19548
- "../share-sdk/dist/index.js"() {
19003
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@tinycloud/share-sdk/dist/index.js"() {
19549
19004
  "use strict";
19550
19005
  init_sha2();
19551
19006
  init_ed25519();
19552
19007
  init_ed25519();
19553
- init_blake3();
19554
- init_ed25519();
19555
- init_sha256();
19556
19008
  init_ed25519();
19557
19009
  __defProp2 = Object.defineProperty;
19558
19010
  __export2 = (target, all) => {
@@ -23562,10 +23014,10 @@ var init_dist3 = __esm({
23562
23014
  /**
23563
23015
  * Creates a multihash digest.
23564
23016
  */
23565
- constructor(code22, size2, digest3, bytes3) {
23017
+ constructor(code22, size2, digest4, bytes3) {
23566
23018
  this.code = code22;
23567
23019
  this.size = size2;
23568
- this.digest = digest3;
23020
+ this.digest = digest4;
23569
23021
  this.bytes = bytes3;
23570
23022
  }
23571
23023
  };
@@ -23628,8 +23080,8 @@ var init_dist3 = __esm({
23628
23080
  toV1() {
23629
23081
  switch (this.version) {
23630
23082
  case 0: {
23631
- const { code: code22, digest: digest3 } = this.multihash;
23632
- const multihash = create(code22, digest3);
23083
+ const { code: code22, digest: digest4 } = this.multihash;
23084
+ const multihash = create(code22, digest4);
23633
23085
  return _CID.createV1(this.code, multihash);
23634
23086
  }
23635
23087
  case 1: {
@@ -23683,8 +23135,8 @@ var init_dist3 = __esm({
23683
23135
  return new _CID(version2, code22, multihash, bytes3 ?? encodeCID(version2, code22, multihash.bytes));
23684
23136
  } else if (value[cidSymbol] === true) {
23685
23137
  const { version: version2, multihash, code: code22 } = value;
23686
- const digest3 = decode4(multihash);
23687
- return _CID.create(version2, code22, digest3);
23138
+ const digest4 = decode4(multihash);
23139
+ return _CID.create(version2, code22, digest4);
23688
23140
  } else {
23689
23141
  return null;
23690
23142
  }
@@ -23694,11 +23146,11 @@ var init_dist3 = __esm({
23694
23146
  * @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
23695
23147
  * @param digest - (Multi)hash of the of the content.
23696
23148
  */
23697
- static create(version2, code22, digest3) {
23149
+ static create(version2, code22, digest4) {
23698
23150
  if (typeof code22 !== "number") {
23699
23151
  throw new Error("String codecs are no longer supported");
23700
23152
  }
23701
- if (!(digest3.bytes instanceof Uint8Array)) {
23153
+ if (!(digest4.bytes instanceof Uint8Array)) {
23702
23154
  throw new Error("Invalid digest");
23703
23155
  }
23704
23156
  switch (version2) {
@@ -23706,12 +23158,12 @@ var init_dist3 = __esm({
23706
23158
  if (code22 !== DAG_PB_CODE) {
23707
23159
  throw new Error(`Version 0 CID must use dag-pb (code: ${DAG_PB_CODE}) block encoding`);
23708
23160
  } else {
23709
- return new _CID(version2, code22, digest3, digest3.bytes);
23161
+ return new _CID(version2, code22, digest4, digest4.bytes);
23710
23162
  }
23711
23163
  }
23712
23164
  case 1: {
23713
- const bytes3 = encodeCID(version2, code22, digest3.bytes);
23714
- return new _CID(version2, code22, digest3, bytes3);
23165
+ const bytes3 = encodeCID(version2, code22, digest4.bytes);
23166
+ return new _CID(version2, code22, digest4, bytes3);
23715
23167
  }
23716
23168
  default: {
23717
23169
  throw new Error("Invalid version");
@@ -23721,8 +23173,8 @@ var init_dist3 = __esm({
23721
23173
  /**
23722
23174
  * Simplified version of `create` for CIDv0.
23723
23175
  */
23724
- static createV0(digest3) {
23725
- return _CID.create(0, DAG_PB_CODE, digest3);
23176
+ static createV0(digest4) {
23177
+ return _CID.create(0, DAG_PB_CODE, digest4);
23726
23178
  }
23727
23179
  /**
23728
23180
  * Simplified version of `create` for CIDv1.
@@ -23730,8 +23182,8 @@ var init_dist3 = __esm({
23730
23182
  * @param code - Content encoding format code.
23731
23183
  * @param digest - Multihash of the content.
23732
23184
  */
23733
- static createV1(code22, digest3) {
23734
- return _CID.create(1, code22, digest3);
23185
+ static createV1(code22, digest4) {
23186
+ return _CID.create(1, code22, digest4);
23735
23187
  }
23736
23188
  /**
23737
23189
  * Decoded a CID from its binary representation. The byte array must contain
@@ -23764,8 +23216,8 @@ var init_dist3 = __esm({
23764
23216
  throw new Error("Incorrect length");
23765
23217
  }
23766
23218
  const digestBytes3 = multihashBytes.subarray(specs.multihashSize - specs.digestSize);
23767
- const digest3 = new Digest(specs.multihashCode, specs.digestSize, digestBytes3, multihashBytes);
23768
- const cid2 = specs.version === 0 ? _CID.createV0(digest3) : _CID.createV1(specs.codec, digest3);
23219
+ const digest4 = new Digest(specs.multihashCode, specs.digestSize, digestBytes3, multihashBytes);
23220
+ const cid2 = specs.version === 0 ? _CID.createV0(digest4) : _CID.createV1(specs.codec, digest4);
23769
23221
  return [cid2, bytes3.subarray(specs.size)];
23770
23222
  }
23771
23223
  /**
@@ -24040,12 +23492,9 @@ var init_dist3 = __esm({
24040
23492
  unsignedShareEnvelopeV2Schema = unsignedShareEnvelopeV2BaseSchema.superRefine(validateV2Invariants);
24041
23493
  shareEnvelopeV2Schema = unsignedShareEnvelopeV2BaseSchema.extend({ signature: signatureSchema }).strict().superRefine(validateV2Invariants);
24042
23494
  unifiedResourceSchema = external_exports2.string().refine((value) => {
24043
- const marker = value.indexOf("/kv/");
24044
- if (marker < 1) return false;
24045
- const space = value.slice(0, marker);
24046
- const legacy = space.startsWith("tinycloud://");
24047
- if (legacy ? /[:/?#%]/.test(space.slice("tinycloud://".length)) : !space.startsWith("tinycloud:") || /[/?#%]/.test(space)) return false;
24048
- const path = value.slice(marker + 4);
23495
+ const match = /^tinycloud:\/\/([^/]+)\/kv\/(.+)$/.exec(value);
23496
+ if (match === null || /[:?#%]/.test(match[1])) return false;
23497
+ const path = match[2];
24049
23498
  return !path.startsWith("/") && !path.endsWith("/") && !path.includes("//") && path.split("/").every((segment) => segment.length > 0 && segment !== "." && segment !== "..");
24050
23499
  }, { message: "expected canonical TinyCloud KV resource" });
24051
23500
  unifiedEncryptionNetworkSchema = external_exports2.string().refine((value) => {
@@ -24083,7 +23532,7 @@ var init_dist3 = __esm({
24083
23532
  mode: external_exports2.union([external_exports2.literal("mutable"), external_exports2.literal("immutable")]),
24084
23533
  initialCiphertextDigestHex: external_exports2.string().regex(/^[0-9a-f]{64}$/).optional()
24085
23534
  }).strict();
24086
- unifiedPolicyV1Schema = external_exports2.object({
23535
+ unifiedPolicySchema = external_exports2.object({
24087
23536
  schema: external_exports2.literal("xyz.tinycloud.policy/policy/v1"),
24088
23537
  policyId: external_exports2.string().regex(/^pol_[a-z2-7]+$/),
24089
23538
  ownerDid: external_exports2.string().min(1),
@@ -24093,31 +23542,6 @@ var init_dist3 = __esm({
24093
23542
  capabilityCeiling: external_exports2.array(unifiedCapabilitySchema).min(2),
24094
23543
  signature: external_exports2.object({ suite: external_exports2.string().min(1), signerDid: external_exports2.string().min(1), value: external_exports2.string().min(1) }).strict()
24095
23544
  }).strict();
24096
- policyCredentialRequirementV1Schema = external_exports2.object({
24097
- type: external_exports2.literal("TinyCloudPolicyCredentialRequirement"),
24098
- version: external_exports2.literal(1),
24099
- requirementDigest: external_exports2.string().regex(/^[A-Za-z0-9_-]{43}$/),
24100
- descriptorDigest: external_exports2.string().regex(/^[A-Za-z0-9_-]{43}$/),
24101
- issuerDid: external_exports2.string().min(1),
24102
- issuerKid: external_exports2.string().min(1),
24103
- profile: external_exports2.object({ id: external_exports2.string().min(1), version: external_exports2.literal(1) }).strict(),
24104
- credentialType: external_exports2.object({ id: external_exports2.string().min(1), version: external_exports2.literal(1) }).strict()
24105
- }).strict();
24106
- unifiedPolicyV2Schema = external_exports2.object({
24107
- schema: external_exports2.literal("xyz.tinycloud.policy/policy/v2"),
24108
- policyId: external_exports2.string().regex(/^pol_[a-z2-7]+$/),
24109
- ownerDid: external_exports2.string().min(1),
24110
- createdAt: external_exports2.string().datetime({ offset: true }),
24111
- expiresAt: external_exports2.string().datetime({ offset: true }).optional(),
24112
- contentSource: unifiedContentSourceSchema,
24113
- capabilityCeiling: external_exports2.array(unifiedCapabilitySchema).min(2),
24114
- credentialRequirement: policyCredentialRequirementV1Schema,
24115
- signature: external_exports2.object({ suite: external_exports2.literal("Ed25519"), signerDid: external_exports2.string().min(1), value: external_exports2.string().min(1) }).strict()
24116
- }).strict();
24117
- unifiedPolicySchema = external_exports2.discriminatedUnion("schema", [
24118
- unifiedPolicyV1Schema,
24119
- unifiedPolicyV2Schema
24120
- ]);
24121
23545
  unifiedRootSchema = external_exports2.object({
24122
23546
  cid: external_exports2.string().min(1),
24123
23547
  authorization: external_exports2.string().regex(/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/),
@@ -24173,13 +23597,6 @@ var init_dist3 = __esm({
24173
23597
  ED25519_VERIFY_OPTS2 = { zip215: false };
24174
23598
  ENVELOPE_SIGNATURE_DOMAIN = "xyz.tinycloud.share/envelope/v1\0";
24175
23599
  ENVELOPE_V2_SIGNATURE_DOMAIN = "xyz.tinycloud.share/envelope/v2\0";
24176
- ENVELOPE_V3_SIGNATURE_DOMAIN = "xyz.tinycloud.share/envelope/v3\0";
24177
- POLICY_V1_SIGNATURE_DOMAIN = "xyz.tinycloud.policy/policy/v1\0";
24178
- POLICY_V2_SIGNATURE_DOMAIN = "xyz.tinycloud.policy/policy/v2\0";
24179
- CONTENT_SOURCE_V1_DOMAIN = "xyz.tinycloud.policy/ContentSource/v1\0";
24180
- POLICY_CAPABILITY_V1_DOMAIN = "xyz.tinycloud.policy/PolicyCapability/v1\0";
24181
- NATIVE_PROJECTION_V1_DOMAIN = "xyz.tinycloud.policy/NativeProjection/v1\0";
24182
- ATTESTED_ENFORCER_V2_DOMAIN = "xyz.tinycloud.policy/AttestedEnforcerBinding/v2\0";
24183
23600
  KEY_LENGTH2 = 32;
24184
23601
  INLINE_PREFIX = "#v=2&p=";
24185
23602
  MAX_INLINE_BYTES = 256 * 1024;
@@ -24303,17 +23720,6 @@ var init_dist3 = __esm({
24303
23720
  return this.decoder.decode(input);
24304
23721
  }
24305
23722
  };
24306
- base58btc2 = baseX2({
24307
- name: "base58btc",
24308
- prefix: "z",
24309
- alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
24310
- });
24311
- base58flickr2 = baseX2({
24312
- name: "base58flickr",
24313
- prefix: "Z",
24314
- alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"
24315
- });
24316
- textEncoder = new TextEncoder();
24317
23723
  base322 = rfc46482({
24318
23724
  prefix: "b",
24319
23725
  name: "base32",
@@ -24378,6 +23784,16 @@ var init_dist3 = __esm({
24378
23784
  name: "base36upper",
24379
23785
  alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
24380
23786
  });
23787
+ base58btc2 = baseX2({
23788
+ name: "base58btc",
23789
+ prefix: "z",
23790
+ alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
23791
+ });
23792
+ base58flickr2 = baseX2({
23793
+ name: "base58flickr",
23794
+ prefix: "Z",
23795
+ alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"
23796
+ });
24381
23797
  encode_12 = encode4;
24382
23798
  MSB2 = 128;
24383
23799
  REST2 = 127;
@@ -24413,10 +23829,10 @@ var init_dist3 = __esm({
24413
23829
  /**
24414
23830
  * Creates a multihash digest.
24415
23831
  */
24416
- constructor(code3, size2, digest3, bytes3) {
23832
+ constructor(code3, size2, digest4, bytes3) {
24417
23833
  this.code = code3;
24418
23834
  this.size = size2;
24419
- this.digest = digest3;
23835
+ this.digest = digest4;
24420
23836
  this.bytes = bytes3;
24421
23837
  }
24422
23838
  };
@@ -24479,8 +23895,8 @@ var init_dist3 = __esm({
24479
23895
  toV1() {
24480
23896
  switch (this.version) {
24481
23897
  case 0: {
24482
- const { code: code3, digest: digest3 } = this.multihash;
24483
- const multihash = create2(code3, digest3);
23898
+ const { code: code3, digest: digest4 } = this.multihash;
23899
+ const multihash = create2(code3, digest4);
24484
23900
  return _CID2.createV1(this.code, multihash);
24485
23901
  }
24486
23902
  case 1: {
@@ -24534,8 +23950,8 @@ var init_dist3 = __esm({
24534
23950
  return new _CID2(version2, code3, multihash, bytes3 ?? encodeCID2(version2, code3, multihash.bytes));
24535
23951
  } else if (value[cidSymbol2] === true) {
24536
23952
  const { version: version2, multihash, code: code3 } = value;
24537
- const digest3 = decode8(multihash);
24538
- return _CID2.create(version2, code3, digest3);
23953
+ const digest4 = decode8(multihash);
23954
+ return _CID2.create(version2, code3, digest4);
24539
23955
  } else {
24540
23956
  return null;
24541
23957
  }
@@ -24545,11 +23961,11 @@ var init_dist3 = __esm({
24545
23961
  * @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
24546
23962
  * @param digest - (Multi)hash of the of the content.
24547
23963
  */
24548
- static create(version2, code3, digest3) {
23964
+ static create(version2, code3, digest4) {
24549
23965
  if (typeof code3 !== "number") {
24550
23966
  throw new Error("String codecs are no longer supported");
24551
23967
  }
24552
- if (!(digest3.bytes instanceof Uint8Array)) {
23968
+ if (!(digest4.bytes instanceof Uint8Array)) {
24553
23969
  throw new Error("Invalid digest");
24554
23970
  }
24555
23971
  switch (version2) {
@@ -24557,12 +23973,12 @@ var init_dist3 = __esm({
24557
23973
  if (code3 !== DAG_PB_CODE2) {
24558
23974
  throw new Error(`Version 0 CID must use dag-pb (code: ${DAG_PB_CODE2}) block encoding`);
24559
23975
  } else {
24560
- return new _CID2(version2, code3, digest3, digest3.bytes);
23976
+ return new _CID2(version2, code3, digest4, digest4.bytes);
24561
23977
  }
24562
23978
  }
24563
23979
  case 1: {
24564
- const bytes3 = encodeCID2(version2, code3, digest3.bytes);
24565
- return new _CID2(version2, code3, digest3, bytes3);
23980
+ const bytes3 = encodeCID2(version2, code3, digest4.bytes);
23981
+ return new _CID2(version2, code3, digest4, bytes3);
24566
23982
  }
24567
23983
  default: {
24568
23984
  throw new Error("Invalid version");
@@ -24572,8 +23988,8 @@ var init_dist3 = __esm({
24572
23988
  /**
24573
23989
  * Simplified version of `create` for CIDv0.
24574
23990
  */
24575
- static createV0(digest3) {
24576
- return _CID2.create(0, DAG_PB_CODE2, digest3);
23991
+ static createV0(digest4) {
23992
+ return _CID2.create(0, DAG_PB_CODE2, digest4);
24577
23993
  }
24578
23994
  /**
24579
23995
  * Simplified version of `create` for CIDv1.
@@ -24581,8 +23997,8 @@ var init_dist3 = __esm({
24581
23997
  * @param code - Content encoding format code.
24582
23998
  * @param digest - Multihash of the content.
24583
23999
  */
24584
- static createV1(code3, digest3) {
24585
- return _CID2.create(1, code3, digest3);
24000
+ static createV1(code3, digest4) {
24001
+ return _CID2.create(1, code3, digest4);
24586
24002
  }
24587
24003
  /**
24588
24004
  * Decoded a CID from its binary representation. The byte array must contain
@@ -24615,8 +24031,8 @@ var init_dist3 = __esm({
24615
24031
  throw new Error("Incorrect length");
24616
24032
  }
24617
24033
  const digestBytes3 = multihashBytes.subarray(specs.multihashSize - specs.digestSize);
24618
- const digest3 = new Digest2(specs.multihashCode, specs.digestSize, digestBytes3, multihashBytes);
24619
- const cid2 = specs.version === 0 ? _CID2.createV0(digest3) : _CID2.createV1(specs.codec, digest3);
24034
+ const digest4 = new Digest2(specs.multihashCode, specs.digestSize, digestBytes3, multihashBytes);
24035
+ const cid2 = specs.version === 0 ? _CID2.createV0(digest4) : _CID2.createV1(specs.codec, digest4);
24620
24036
  return [cid2, bytes3.subarray(specs.size)];
24621
24037
  }
24622
24038
  /**
@@ -24697,7 +24113,7 @@ var init_dist3 = __esm({
24697
24113
  }
24698
24114
  });
24699
24115
 
24700
- // ../sdk-core/dist/index.js
24116
+ // ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@tinycloud/sdk-core/dist/index.js
24701
24117
  import { SiweMessage } from "siwe";
24702
24118
  function equals5(aa, bb) {
24703
24119
  if (aa === bb) {
@@ -25377,13 +24793,13 @@ function concat2(arrays, length22) {
25377
24793
  if (length22 == null) {
25378
24794
  length22 = arrays.reduce((acc, curr) => acc + curr.length, 0);
25379
24795
  }
25380
- const output2 = allocUnsafe(length22);
24796
+ const output = allocUnsafe(length22);
25381
24797
  let offset = 0;
25382
24798
  for (const arr of arrays) {
25383
- output2.set(arr, offset);
24799
+ output.set(arr, offset);
25384
24800
  offset += arr.length;
25385
24801
  }
25386
- return asUint8Array(output2);
24802
+ return asUint8Array(output);
25387
24803
  }
25388
24804
  function createCodec(name2, prefix, encode52, decode72) {
25389
24805
  return {
@@ -25779,13 +25195,13 @@ function createInMemoryLocalNodeIdentityStore() {
25779
25195
  }
25780
25196
  };
25781
25197
  }
25782
- function locationPayloadForRecord(record2) {
25198
+ function locationPayloadForRecord(record) {
25783
25199
  return {
25784
- version: record2.version,
25785
- subject: record2.subject,
25786
- multiaddrs: [...record2.multiaddrs],
25787
- updated_at: record2.updated_at,
25788
- sequence: record2.sequence
25200
+ version: record.version,
25201
+ subject: record.subject,
25202
+ multiaddrs: [...record.multiaddrs],
25203
+ updated_at: record.updated_at,
25204
+ sequence: record.sequence
25789
25205
  };
25790
25206
  }
25791
25207
  function canonicalLocationPayload(payload) {
@@ -25836,13 +25252,13 @@ function validateLocationRecord(input) {
25836
25252
  return { ...payload, signature };
25837
25253
  }
25838
25254
  async function verifyLocationRecord(input) {
25839
- const record2 = validateLocationRecord(input);
25840
- const payload = canonicalLocationPayload(locationPayloadForRecord(record2));
25841
- if (record2.subject.startsWith("did:pkh:")) {
25842
- return verifyPkhSignature(record2.subject, payload, record2.signature);
25255
+ const record = validateLocationRecord(input);
25256
+ const payload = canonicalLocationPayload(locationPayloadForRecord(record));
25257
+ if (record.subject.startsWith("did:pkh:")) {
25258
+ return verifyPkhSignature(record.subject, payload, record.signature);
25843
25259
  }
25844
- if (record2.subject.startsWith("did:key:")) {
25845
- return verifyDidKeySignature(record2.subject, payload, record2.signature);
25260
+ if (record.subject.startsWith("did:key:")) {
25261
+ return verifyDidKeySignature(record.subject, payload, record.signature);
25846
25262
  }
25847
25263
  return false;
25848
25264
  }
@@ -25949,18 +25365,18 @@ async function fetchRegistryLocalLinkCandidates(options2, fetchFn, existingCandi
25949
25365
  }
25950
25366
  const registryUrl = options2.registryUrl ?? DEFAULT_TINYCLOUD_LOCATION_REGISTRY_URL;
25951
25367
  try {
25952
- const record2 = await fetchLocationRecord(registryUrl, options2.subject, fetchFn);
25953
- if (!record2) {
25368
+ const record = await fetchLocationRecord(registryUrl, options2.subject, fetchFn);
25369
+ if (!record) {
25954
25370
  return [];
25955
25371
  }
25956
25372
  const shouldVerify = options2.verifyRecords ?? true;
25957
- if (shouldVerify && !await verifyLocationRecord(record2)) {
25373
+ if (shouldVerify && !await verifyLocationRecord(record)) {
25958
25374
  debugLog(
25959
25375
  `registry record signature invalid for ${options2.subject}; skipping local-link lookup`
25960
25376
  );
25961
25377
  return [];
25962
25378
  }
25963
- return extractLocalLinkUrls(record2).filter((url) => !existingCandidates.some((c) => c.url === url)).map((url) => ({
25379
+ return extractLocalLinkUrls(record).filter((url) => !existingCandidates.some((c) => c.url === url)).map((url) => ({
25964
25380
  source: "local-link",
25965
25381
  url,
25966
25382
  timeoutMs: LOCAL_LINK_PROBE_TIMEOUT_MS
@@ -25969,12 +25385,12 @@ async function fetchRegistryLocalLinkCandidates(options2, fetchFn, existingCandi
25969
25385
  return [];
25970
25386
  }
25971
25387
  }
25972
- function extractLocalLinkUrls(record2) {
25973
- if (!record2) {
25388
+ function extractLocalLinkUrls(record) {
25389
+ if (!record) {
25974
25390
  return [];
25975
25391
  }
25976
25392
  const urls = [];
25977
- for (const addr of record2.multiaddrs) {
25393
+ for (const addr of record.multiaddrs) {
25978
25394
  let url;
25979
25395
  try {
25980
25396
  url = multiaddrToHttpUrl(addr);
@@ -26078,7 +25494,7 @@ async function verifyPkhSignature(did, payload, signature) {
26078
25494
  }
26079
25495
  function verifyDidKeySignature(did, payload, signature) {
26080
25496
  const publicKey = ed25519PublicKeyFromDidKey2(did);
26081
- const signatureBytes = decodeBase64Url4(signature);
25497
+ const signatureBytes = decodeBase64Url3(signature);
26082
25498
  if (signatureBytes.length !== 64) {
26083
25499
  throw new LocationRecordValidationError(
26084
25500
  "did:key signature must be a base64url Ed25519 signature"
@@ -26108,7 +25524,7 @@ function ed25519PublicKeyFromDidKey2(did) {
26108
25524
  "did:key must be an Ed25519 public key"
26109
25525
  );
26110
25526
  }
26111
- function decodeBase64Url4(value) {
25527
+ function decodeBase64Url3(value) {
26112
25528
  const alphabet2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
26113
25529
  const bytes2 = [];
26114
25530
  let buffer = 0;
@@ -26129,9 +25545,9 @@ function decodeBase64Url4(value) {
26129
25545
  }
26130
25546
  return Uint8Array.from(bytes2);
26131
25547
  }
26132
- var import_ms, __defProp3, __typeError, __defNormalProp, __export3, __publicField, __accessCheck, __privateGet, __privateAdd, __privateSet, EnsDataSchema, SiweConfigSchema, ClientSessionSchema, objectHasOwn, base32_exports, empty3, src3, _brrp__multiformats_scope_baseX3, base_x_default3, Encoder3, Decoder3, ComposedDecoder3, Codec3, base323, base32upper3, base32pad3, base32padupper3, base32hex3, base32hexupper3, base32hexpad3, base32hexpadupper3, base32z3, base36_exports, base363, base36upper3, base58_exports, base58btc3, base58flickr3, encode_13, MSB3, REST3, MSBALL3, INT3, decode22, MSB$13, REST$13, N13, N23, N33, N43, N53, N63, N73, N83, N93, length3, varint3, _brrp_varint3, varint_default3, Digest3, cache3, _a, CID3, DAG_PB_CODE3, SHA_256_CODE3, cidSymbol3, textEncoder2, objectHasOwn2, CEILING_SERVICES, GRANTABLE_ACTIONS, base10_exports, base10, base16_exports, base16, base16upper, base2_exports, base22, base256emoji_exports, alphabet, alphabetBytesToChars, alphabetCharsToBytes, base256emoji, base64_exports, base642, base64pad2, base64url2, base64urlpad2, base8_exports, base8, identity_exports, identity, textEncoder22, textDecoder, identity_exports2, code2, name, encode42, identity2, sha2_browser_exports, DEFAULT_MIN_DIGEST_LENGTH, Hasher, sha25622, sha5122, bases, hashes, textEncoder3, objectHasOwn3, TRANSCRIPT_SHARE_BOOTSTRAP_SCHEMA, OWNER_NODE_ENDPOINT_SCHEMA, W3C_VC_CREDENTIAL_VERIFIER, objectHasOwn4, CompactHeaderSchema, CompactPayloadSchema, POLICY_ENGINE_CHALLENGE_RESPONSE_SCHEMA, POLICY_ENGINE_DENIAL_SCHEMA, POLICY_ENGINE_GRANT_PRESENTATION_DENIAL_CODES, JsonValueSchema, Rfc3339Schema, SignedRecordSchema, PolicyEngineSchema, OwnerNodeSchema, ResourceHintSchema, BootstrapSchema, SignatureSchema, ChallengeSchema, ChallengeResponseSchema, DenialSchema, ErrorEnvelopeDenialSchema, WireDelegationSchema, ResolveResponseSchema, DelegateReceiptSchema, SqlReadResponseSchema, KvReadResponseSchema, LISTEN_SQL_STATEMENT_CATALOG, LISTEN_SQL_STATEMENT_BY_NAME, JWKSchema, KeyTypeSchema, KeyInfoSchema, DelegationErrorSchema, DelegationSchema, DelegationStatusSchema, DelegationRevocationReceiptSchema, AccountDelegationResourceSchema, AccountDelegationDateSchema, AccountDelegationRecordSchema, AccountDelegationPageSchema, AccountDelegationQueryOptionsSchema, CapabilityEntrySchema, DelegationRecordSchema, CreateDelegationParamsSchema, DelegationChainSchema, DelegationChainV2Schema, DelegationDirectionSchema, DelegationFiltersSchema, SpaceOwnershipSchema, SpaceInfoSchema, ShareSchemaSchema, ShareLinkSchema, ShareLinkDataSchema, IngestOptionsSchema, GenerateShareParamsSchema, DelegationManagerConfigSchema, KeyProviderSchema, DelegationApiResponseSchema, DelegatedResourceSchema, CreateDelegationWasmParamsSchema, CreateDelegationWasmResultSchema, EPHEMERAL_MS, SIGNED_READ_URL_MS, SESSION_MS, SHARE_MS, APP_MS, MAX_MS, EXPIRY, DEFAULT_SIGNED_READ_URL_EXPIRY_MS2, EncodedShareDataSchema, ReceiveOptionsSchema, SharingServiceConfigSchema, DEFAULT_KNOWLEDGE_ROOT, ManifestValidationError, SERVICE_SHORT_TO_LONG, SERVICE_LONG_TO_SHORT, DEFAULT_MAX_INLINE_BYTES, MAX_SHARE_CONTENT_BYTES, MAX_SEALED_SHARE_CONTENT_BYTES, MAX_SHARE_ARTIFACT_BYTES, PUBLISHED_AAD, ShareRecipientTargetSchema, ShareResourceSchema, ShareActionSchema, ShareRecipientPolicySchema, ShareRecipientClientOptionsSchema, ShareNativeActionSchema, ShareWireActionSchema, ShareContentSourceSchema, ShareAddressedRecipientSchema, ShareAddressedDelegationRequestV2Schema, ShareAddressedDelegationEnvelopeV2Schema, ShareAddressedDelegationResponseV2Schema, ShareNativeResponseEntrySchema, ShareNativeResponseBase, ShareNativeResponseSchema, ResourceSchema, PortableDelegationSchema, MAX_NATIVE_CURSOR_BYTES, DEFAULT_EXPIRY_MS2, MAX_CONTENT_BYTES2, ethereumAddressPattern, EnsDataSchema2, PersistedTinyCloudSessionSchema, PersistedSessionDataSchema, TinyCloudSessionSchema, SpaceConfigSchema, SpaceServiceConfigSchema, SpaceDelegationParamsSchema, ServerDelegationInfoSchema, ServerDelegationsResponseSchema, ServerOwnedSpaceSchema, ServerOwnedSpacesResponseSchema, ServerCreateSpaceResponseSchema, ServerSpaceInfoResponseSchema, AutoApproveSpaceCreationHandler, defaultSpaceCreationHandler, N122, N222, N322, N422, N522, N622, N722, MSB22, REST22, string, ascii, BASES, bases_default, InvalidMultiaddrError, ValidationError, InvalidParametersError, UnknownProtocolError, Parser, MAX_IPV6_LENGTH, MAX_IPV4_LENGTH, parser, CODE_IP4, CODE_TCP, CODE_UDP, CODE_DCCP, CODE_IP6, CODE_IP6ZONE, CODE_IPCIDR, CODE_DNS, CODE_DNS4, CODE_DNS6, CODE_DNSADDR, CODE_SCTP, CODE_UDT, CODE_UTP, CODE_UNIX, CODE_P2P, CODE_ONION, CODE_ONION3, CODE_GARLIC64, CODE_GARLIC32, CODE_TLS, CODE_SNI, CODE_NOISE, CODE_QUIC, CODE_QUIC_V1, CODE_WEBTRANSPORT, CODE_CERTHASH, CODE_HTTP, CODE_HTTP_PATH, CODE_HTTPS, CODE_WS, CODE_WSS, CODE_P2P_WEBSOCKET_STAR, CODE_P2P_STARDUST, CODE_P2P_WEBRTC_STAR, CODE_P2P_WEBRTC_DIRECT, CODE_WEBRTC_DIRECT, CODE_WEBRTC, CODE_P2P_CIRCUIT, CODE_MEMORY, ip4ToBytes, ip6ToBytes, ip4ToString, ip6ToString, decoders, anybaseDecoder, validatePort, V, Registry, registry, codecs, inspect, symbol, _a2, _components, _string, _bytes, _Multiaddr, Multiaddr, ASSUME_HTTP_CODES, interpreters, word, boundry, v4, v6segment, v6, v46Exact, v4exact, v6exact, ipRegex, toString3, DEFAULT_TINYCLOUD_LOCATION_REGISTRY_URL, LOCAL_LOOPBACK_PROBE_TIMEOUT_MS, LOCAL_LINK_PROBE_TIMEOUT_MS, LOCAL_LINK_HOST_SUFFIX, LocationRecordValidationError, defaultLocalNodeIdentityStore, DNS_LABEL_REGEX;
25548
+ var import_ms, __defProp3, __typeError, __defNormalProp, __export3, __publicField, __accessCheck, __privateGet, __privateAdd, __privateSet, EnsDataSchema, SiweConfigSchema, ClientSessionSchema, objectHasOwn, base32_exports, empty3, src3, _brrp__multiformats_scope_baseX3, base_x_default3, Encoder3, Decoder3, ComposedDecoder3, Codec3, base323, base32upper3, base32pad3, base32padupper3, base32hex3, base32hexupper3, base32hexpad3, base32hexpadupper3, base32z3, base36_exports, base363, base36upper3, base58_exports, base58btc3, base58flickr3, encode_13, MSB3, REST3, MSBALL3, INT3, decode22, MSB$13, REST$13, N13, N23, N33, N43, N53, N63, N73, N83, N93, length3, varint3, _brrp_varint3, varint_default3, Digest3, cache3, _a, CID3, DAG_PB_CODE3, SHA_256_CODE3, cidSymbol3, textEncoder, objectHasOwn2, CEILING_SERVICES, GRANTABLE_ACTIONS, base10_exports, base10, base16_exports, base16, base16upper, base2_exports, base22, base256emoji_exports, alphabet, alphabetBytesToChars, alphabetCharsToBytes, base256emoji, base64_exports, base642, base64pad2, base64url2, base64urlpad2, base8_exports, base8, identity_exports, identity, textEncoder2, textDecoder, identity_exports2, code2, name, encode42, identity2, sha2_browser_exports, DEFAULT_MIN_DIGEST_LENGTH, Hasher, sha2562, sha5122, bases, hashes, textEncoder3, objectHasOwn3, TRANSCRIPT_SHARE_BOOTSTRAP_SCHEMA, OWNER_NODE_ENDPOINT_SCHEMA, W3C_VC_CREDENTIAL_VERIFIER, objectHasOwn4, CompactHeaderSchema, CompactPayloadSchema, POLICY_ENGINE_CHALLENGE_RESPONSE_SCHEMA, POLICY_ENGINE_DENIAL_SCHEMA, POLICY_ENGINE_GRANT_PRESENTATION_DENIAL_CODES, JsonValueSchema, Rfc3339Schema, SignedRecordSchema, PolicyEngineSchema, OwnerNodeSchema, ResourceHintSchema, BootstrapSchema, SignatureSchema, ChallengeSchema, ChallengeResponseSchema, DenialSchema, ErrorEnvelopeDenialSchema, WireDelegationSchema, ResolveResponseSchema, DelegateReceiptSchema, SqlReadResponseSchema, KvReadResponseSchema, LISTEN_SQL_STATEMENT_CATALOG, LISTEN_SQL_STATEMENT_BY_NAME, JWKSchema, KeyTypeSchema, KeyInfoSchema, DelegationErrorSchema, DelegationSchema, DelegationStatusSchema, DelegationRevocationReceiptSchema, AccountDelegationResourceSchema, AccountDelegationDateSchema, AccountDelegationRecordSchema, AccountDelegationPageSchema, AccountDelegationQueryOptionsSchema, CapabilityEntrySchema, DelegationRecordSchema, CreateDelegationParamsSchema, DelegationChainSchema, DelegationChainV2Schema, DelegationDirectionSchema, DelegationFiltersSchema, SpaceOwnershipSchema, SpaceInfoSchema, ShareSchemaSchema, ShareLinkSchema, ShareLinkDataSchema, IngestOptionsSchema, GenerateShareParamsSchema, DelegationManagerConfigSchema, KeyProviderSchema, DelegationApiResponseSchema, DelegatedResourceSchema, CreateDelegationWasmParamsSchema, CreateDelegationWasmResultSchema, EPHEMERAL_MS, SIGNED_READ_URL_MS, SESSION_MS, SHARE_MS, APP_MS, MAX_MS, EXPIRY, DEFAULT_SIGNED_READ_URL_EXPIRY_MS2, EncodedShareDataSchema, ReceiveOptionsSchema, SharingServiceConfigSchema, DEFAULT_KNOWLEDGE_ROOT, ManifestValidationError, SERVICE_SHORT_TO_LONG, SERVICE_LONG_TO_SHORT, DEFAULT_MAX_INLINE_BYTES, MAX_SHARE_CONTENT_BYTES, MAX_SEALED_SHARE_CONTENT_BYTES, MAX_SHARE_ARTIFACT_BYTES, PUBLISHED_AAD, ShareRecipientTargetSchema, ShareResourceSchema, ShareActionSchema, ShareRecipientPolicySchema, ShareRecipientClientOptionsSchema, ShareNativeActionSchema, ShareWireActionSchema, ShareContentSourceSchema, ShareAddressedRecipientSchema, ShareAddressedDelegationRequestV2Schema, ShareAddressedDelegationEnvelopeV2Schema, ShareAddressedDelegationResponseV2Schema, ShareNativeResponseEntrySchema, ShareNativeResponseBase, ShareNativeResponseSchema, ResourceSchema, PortableDelegationSchema, MAX_NATIVE_CURSOR_BYTES, DEFAULT_EXPIRY_MS2, MAX_CONTENT_BYTES2, ethereumAddressPattern, EnsDataSchema2, PersistedTinyCloudSessionSchema, PersistedSessionDataSchema, TinyCloudSessionSchema, SpaceConfigSchema, SpaceServiceConfigSchema, SpaceDelegationParamsSchema, ServerDelegationInfoSchema, ServerDelegationsResponseSchema, ServerOwnedSpaceSchema, ServerOwnedSpacesResponseSchema, ServerCreateSpaceResponseSchema, ServerSpaceInfoResponseSchema, AutoApproveSpaceCreationHandler, defaultSpaceCreationHandler, N122, N222, N322, N422, N522, N622, N722, MSB22, REST22, string, ascii, BASES, bases_default, InvalidMultiaddrError, ValidationError, InvalidParametersError, UnknownProtocolError, Parser, MAX_IPV6_LENGTH, MAX_IPV4_LENGTH, parser, CODE_IP4, CODE_TCP, CODE_UDP, CODE_DCCP, CODE_IP6, CODE_IP6ZONE, CODE_IPCIDR, CODE_DNS, CODE_DNS4, CODE_DNS6, CODE_DNSADDR, CODE_SCTP, CODE_UDT, CODE_UTP, CODE_UNIX, CODE_P2P, CODE_ONION, CODE_ONION3, CODE_GARLIC64, CODE_GARLIC32, CODE_TLS, CODE_SNI, CODE_NOISE, CODE_QUIC, CODE_QUIC_V1, CODE_WEBTRANSPORT, CODE_CERTHASH, CODE_HTTP, CODE_HTTP_PATH, CODE_HTTPS, CODE_WS, CODE_WSS, CODE_P2P_WEBSOCKET_STAR, CODE_P2P_STARDUST, CODE_P2P_WEBRTC_STAR, CODE_P2P_WEBRTC_DIRECT, CODE_WEBRTC_DIRECT, CODE_WEBRTC, CODE_P2P_CIRCUIT, CODE_MEMORY, ip4ToBytes, ip6ToBytes, ip4ToString, ip6ToString, decoders, anybaseDecoder, validatePort, V, Registry, registry, codecs, inspect, symbol, _a2, _components, _string, _bytes, _Multiaddr, Multiaddr, ASSUME_HTTP_CODES, interpreters, word, boundry, v4, v6segment, v6, v46Exact, v4exact, v6exact, ipRegex, toString3, DEFAULT_TINYCLOUD_LOCATION_REGISTRY_URL, LOCAL_LOOPBACK_PROBE_TIMEOUT_MS, LOCAL_LINK_PROBE_TIMEOUT_MS, LOCAL_LINK_HOST_SUFFIX, LocationRecordValidationError, defaultLocalNodeIdentityStore, DNS_LABEL_REGEX;
26133
25549
  var init_dist4 = __esm({
26134
- "../sdk-core/dist/index.js"() {
25550
+ "../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@tinycloud/sdk-core/dist/index.js"() {
26135
25551
  "use strict";
26136
25552
  init_zod();
26137
25553
  init_zod();
@@ -26675,7 +26091,7 @@ var init_dist4 = __esm({
26675
26091
  DAG_PB_CODE3 = 112;
26676
26092
  SHA_256_CODE3 = 18;
26677
26093
  cidSymbol3 = /* @__PURE__ */ Symbol.for("@ipld/js-cid/CID");
26678
- textEncoder2 = new TextEncoder();
26094
+ textEncoder = new TextEncoder();
26679
26095
  objectHasOwn2 = Object.hasOwn ?? Object.prototype.hasOwnProperty.call.bind(
26680
26096
  Object.prototype.hasOwnProperty
26681
26097
  );
@@ -26805,7 +26221,7 @@ var init_dist4 = __esm({
26805
26221
  encode: (buf) => toString(buf),
26806
26222
  decode: (str) => fromString(str)
26807
26223
  });
26808
- textEncoder22 = new TextEncoder();
26224
+ textEncoder2 = new TextEncoder();
26809
26225
  textDecoder = new TextDecoder();
26810
26226
  identity_exports2 = {};
26811
26227
  __export3(identity_exports2, {
@@ -26817,7 +26233,7 @@ var init_dist4 = __esm({
26817
26233
  identity2 = { code: code2, name, encode: encode42, digest };
26818
26234
  sha2_browser_exports = {};
26819
26235
  __export3(sha2_browser_exports, {
26820
- sha256: () => sha25622,
26236
+ sha256: () => sha2562,
26821
26237
  sha512: () => sha5122
26822
26238
  });
26823
26239
  DEFAULT_MIN_DIGEST_LENGTH = 20;
@@ -26854,7 +26270,7 @@ var init_dist4 = __esm({
26854
26270
  }
26855
26271
  }
26856
26272
  };
26857
- sha25622 = from22({
26273
+ sha2562 = from22({
26858
26274
  name: "sha2-256",
26859
26275
  code: 18,
26860
26276
  encode: sha("SHA-256")
@@ -30053,12 +29469,12 @@ async function loadPermissionRequest(source, profile) {
30053
29469
  }
30054
29470
  return resolvePermissionSpaces(raw.permissions, profile);
30055
29471
  }
30056
- async function loadManifestPermissions(source, profile) {
29472
+ async function loadManifestPermissions(source, profile, options = {}) {
30057
29473
  const raw = await loadManifestText(source);
30058
29474
  const manifest = JSON.parse(raw);
30059
29475
  if (typeof manifest.id === "string") {
30060
29476
  const resolved = resolveManifest(manifest);
30061
- return resolvePermissionSpaces(resolved.resources, profile);
29477
+ return resolvePermissionSpaces(resolved.resources, profile, options);
30062
29478
  }
30063
29479
  if (typeof manifest.app_id === "string") {
30064
29480
  const permissions = (manifest.permissions ?? []).filter((entry) => entry !== null && typeof entry === "object").map((entry) => {
@@ -30077,7 +29493,7 @@ async function loadManifestPermissions(source, profile) {
30077
29493
  };
30078
29494
  });
30079
29495
  permissions.push(...await secretPermissionsFromAppManifest(manifest, profile));
30080
- return resolvePermissionSpaces(permissions, profile);
29496
+ return resolvePermissionSpaces(permissions, profile, options);
30081
29497
  }
30082
29498
  throw new CLIError(
30083
29499
  "INVALID_MANIFEST",
@@ -30147,9 +29563,9 @@ function compactPermission(permission) {
30147
29563
  const actions = permission.actions.map((action) => action.startsWith(`${service}/`) ? action.slice(service.length + 1) : action).join(",");
30148
29564
  return `${service}:${space}:${permission.path}:${actions}`;
30149
29565
  }
30150
- async function resolvePermissionSpaces(entries, profile) {
29566
+ async function resolvePermissionSpaces(entries, profile, options = {}) {
30151
29567
  const profileConfig = await ProfileManager.getProfile(profile);
30152
- const allowLogicalSpaces = resolveProfilePosture(profileConfig) === "delegate-session";
29568
+ const allowLogicalSpaces = options.allowLogicalSpaces || resolveProfilePosture(profileConfig) === "delegate-session";
30153
29569
  const resolved = [];
30154
29570
  for (const entry of entries) {
30155
29571
  const service = normalizeService(entry.service);
@@ -30973,18 +30389,68 @@ Open this URL in a browser to authenticate:
30973
30389
  });
30974
30390
  }
30975
30391
 
30976
- // src/auth/device-auth.ts
30392
+ // src/auth/scoped-login.ts
30393
+ init_errors();
30977
30394
  init_constants();
30978
- init_profiles();
30979
- import {
30980
- createDecipheriv,
30981
- createHash,
30982
- createHmac,
30983
- createPublicKey,
30984
- diffieHellman,
30985
- generateKeyPairSync,
30986
- randomBytes as randomBytes3
30987
- } from "crypto";
30395
+ function normalizeSpace(space) {
30396
+ return space.replace(/(eip155:\d+:)(0x[0-9a-fA-F]{40})/, (_, prefix, address) => prefix + address.toLowerCase());
30397
+ }
30398
+ function validateLoginPermissions(permissions) {
30399
+ if (!permissions.length || permissions.some(
30400
+ (p) => !p.service?.startsWith("tinycloud.") || !p.space || !p.space.startsWith("tinycloud:") && !/^[A-Za-z0-9_-]+$/.test(p.space) || typeof p.path !== "string" || !p.actions?.length || p.actions.some((action) => !action.startsWith(`${p.service}/`))
30401
+ ) || new Set(permissions.map((p) => normalizeSpace(p.space))).size !== 1) {
30402
+ throw new CLIError("INVALID_LOGIN_SCOPE", "First login requires non-empty permissions in one TinyCloud space. Request additional spaces after login.", ExitCode.USAGE_ERROR);
30403
+ }
30404
+ }
30405
+ async function verifyScopedLogin(data, key, sessionDid, requested, expectedOwner) {
30406
+ let proof;
30407
+ try {
30408
+ if (typeof data.siwe !== "string" || typeof data.signature !== "string" || typeof data.address !== "string" || !Number.isSafeInteger(data.chainId) || typeof data.spaceId !== "string" || typeof data.delegationCid !== "string" || !data.delegationHeader || typeof data.delegationHeader !== "object" || typeof data.verificationMethod !== "string" || data.verificationMethod.split("#")[0] !== sessionDid.split("#")[0]) throw new Error();
30409
+ const { NodeWasmBindings: NodeWasmBindings2 } = await import("@tinycloud/node-sdk");
30410
+ proof = new NodeWasmBindings2().validatePersistedSession({
30411
+ delegationHeader: data.delegationHeader,
30412
+ delegationCid: data.delegationCid,
30413
+ spaceId: data.spaceId,
30414
+ jwk: key,
30415
+ address: data.address,
30416
+ chainId: data.chainId,
30417
+ siwe: data.siwe,
30418
+ signature: data.signature
30419
+ });
30420
+ if (!proof.verifiedRecap?.length || !proof.expiresAt || !Number.isFinite(Date.parse(proof.expiresAt))) throw new Error();
30421
+ } catch (error) {
30422
+ if (/expir/i.test(error instanceof Error ? error.message : String(error))) {
30423
+ throw new CLIError("AUTH_EXPIRED", "The approved session has expired. No scoped session was saved.", ExitCode.AUTH_REQUIRED);
30424
+ }
30425
+ throw new CLIError("OPENKEY_PROOF_INVALID", "OpenKey did not return a complete, verifiable session proof. No scoped session was saved.", ExitCode.AUTH_REQUIRED);
30426
+ }
30427
+ if (Date.parse(proof.expiresAt) <= Date.now()) {
30428
+ throw new CLIError("AUTH_EXPIRED", "The approved session has expired. No scoped session was saved.", ExitCode.AUTH_REQUIRED);
30429
+ }
30430
+ const ownerDid = `did:pkh:eip155:${data.chainId}:${data.address}`;
30431
+ if (expectedOwner && normalizeSpace(expectedOwner) !== normalizeSpace(ownerDid)) {
30432
+ throw new CLIError("OPENKEY_OWNER_MISMATCH", "The approved signing identity differs from the expected owner. No scoped session was saved.", ExitCode.PERMISSION_DENIED);
30433
+ }
30434
+ const spaceId = data.spaceId;
30435
+ const allowed = new Set(requested.flatMap((permission) => {
30436
+ const expectedSpace = permission.space.startsWith("tinycloud:") ? permission.space : `tinycloud:${ownerDid.slice(4)}:${permission.space}`;
30437
+ if (normalizeSpace(expectedSpace) !== normalizeSpace(spaceId)) {
30438
+ throw new CLIError("OPENKEY_SCOPE_MISMATCH", "The approved space differs from the requested space. No scoped session was saved.", ExitCode.PERMISSION_DENIED);
30439
+ }
30440
+ return permission.actions.map((action) => JSON.stringify([permission.service, normalizeSpace(expectedSpace), permission.path, action]));
30441
+ }));
30442
+ const permissions = proof.verifiedRecap.map((entry) => {
30443
+ const service = entry.service.startsWith("tinycloud.") ? entry.service : `tinycloud.${entry.service}`;
30444
+ const actions = entry.actions.map((action) => action.includes("/") ? action : `${service}/${action}`);
30445
+ for (const action of actions) {
30446
+ if (!allowed.has(JSON.stringify([service, normalizeSpace(entry.space), entry.path, action]))) {
30447
+ throw new CLIError("OPENKEY_GRANT_BROADENED", "The signed grant contains authority beyond the login manifest. No scoped session was saved.", ExitCode.PERMISSION_DENIED);
30448
+ }
30449
+ }
30450
+ return { service, space: entry.space, path: entry.path, actions };
30451
+ });
30452
+ return { ...data, jwk: key, ownerDid, permissions, expiresAt: proof.expiresAt, expiry: proof.expiresAt, expirationTime: proof.expiresAt };
30453
+ }
30988
30454
 
30989
30455
  // src/auth/local-key.ts
30990
30456
  import { TCWSessionManager, importKey, initPanicHook } from "@tinycloud/node-sdk-wasm";
@@ -31056,251 +30522,6 @@ async function localKeySignIn(options) {
31056
30522
  };
31057
30523
  }
31058
30524
 
31059
- // src/auth/device-auth.ts
31060
- var SHARE_DEVICE_DELEGATION_SECONDS = 30 * 24 * 60 * 60;
31061
- var SHARE_DEVICE_PERMISSIONS = [{
31062
- service: "tinycloud.capabilities",
31063
- space: "applications",
31064
- path: "",
31065
- actions: ["tinycloud.capabilities/read"]
31066
- }];
31067
- function digest2(value) {
31068
- return createHash("sha256").update(value).digest("base64url");
31069
- }
31070
- function canonicalOrigin(value, label) {
31071
- const url = new URL(value);
31072
- const loopback = url.hostname === "127.0.0.1" || url.hostname === "localhost";
31073
- if (url.origin !== value || url.protocol !== "https:" && !(loopback && url.protocol === "http:")) {
31074
- throw new Error(`${label} must be a canonical HTTPS origin`);
31075
- }
31076
- return value;
31077
- }
31078
- function jsonEqual(left, right) {
31079
- const canonical = (value) => Array.isArray(value) ? value.map(canonical) : value && typeof value === "object" ? Object.fromEntries(Object.entries(value).sort(([a], [b]) => a.localeCompare(b)).map(([key, entry]) => [key, canonical(entry)])) : value;
31080
- return JSON.stringify(canonical(left)) === JSON.stringify(canonical(right));
31081
- }
31082
- function validateStart(value) {
31083
- if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("OpenKey returned an invalid device authorization response");
31084
- const result = value;
31085
- if (typeof result.transactionId !== "string" || !/^[A-Za-z0-9_-]{20,}$/.test(result.transactionId) || typeof result.userCode !== "string" || !/^[A-Z2-9]{4}-[A-Z2-9]{4}$/.test(result.userCode) || typeof result.verificationUri !== "string" || typeof result.verificationUriComplete !== "string" || !Number.isSafeInteger(result.expiresIn) || Number(result.expiresIn) < 60 || !Number.isSafeInteger(result.interval) || Number(result.interval) < 1) throw new Error("OpenKey returned an invalid device authorization response");
31086
- canonicalOrigin(new URL(result.verificationUri).origin, "verification URI");
31087
- if (new URL(result.verificationUriComplete).origin !== new URL(result.verificationUri).origin) {
31088
- throw new Error("OpenKey returned an invalid verification URI");
31089
- }
31090
- return result;
31091
- }
31092
- async function responseJson(response) {
31093
- try {
31094
- return await response.json();
31095
- } catch {
31096
- throw new Error(`OpenKey device authorization failed (HTTP ${response.status})`);
31097
- }
31098
- }
31099
- function errorCode(value) {
31100
- return value && typeof value === "object" && typeof value.error === "string" ? value.error : void 0;
31101
- }
31102
- function publicSessionJwk(value) {
31103
- const publicJwk = publicJwkForDelegation(value);
31104
- const record = publicJwk;
31105
- if (record.kty !== "OKP" || record.crv !== "Ed25519" || typeof record.x !== "string") {
31106
- throw new Error("CLI session key is not a public Ed25519 JWK");
31107
- }
31108
- return publicJwk;
31109
- }
31110
- function publicRelayJwk(value) {
31111
- if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("OpenKey returned an invalid relay key");
31112
- const jwk = value;
31113
- if (jwk.kty !== "EC" || jwk.crv !== "P-256" || typeof jwk.x !== "string" || !/^[A-Za-z0-9_-]{43}$/.test(jwk.x) || typeof jwk.y !== "string" || !/^[A-Za-z0-9_-]{43}$/.test(jwk.y) || "d" in jwk) throw new Error("OpenKey returned an invalid relay key");
31114
- return { kty: "EC", crv: "P-256", x: jwk.x, y: jwk.y };
31115
- }
31116
- function decodeCanonicalBase64Url(value, label) {
31117
- if (typeof value !== "string" || !/^[A-Za-z0-9_-]+$/.test(value)) throw new Error(`OpenKey returned an invalid ${label}`);
31118
- const decoded = Buffer.from(value, "base64url");
31119
- if (decoded.toString("base64url") !== value) throw new Error(`OpenKey returned an invalid ${label}`);
31120
- return decoded;
31121
- }
31122
- function deriveRelayKey(sharedSecret, transactionId) {
31123
- const extracted = createHmac("sha256", Buffer.from(transactionId)).update(sharedSecret).digest();
31124
- return createHmac("sha256", extracted).update(Buffer.from("openkey-device-relay-v1")).update(Buffer.from([1])).digest();
31125
- }
31126
- function decryptRelayResult(envelope, transactionId, privateKey) {
31127
- if (!envelope || typeof envelope !== "object" || Array.isArray(envelope)) throw new Error("OpenKey returned an invalid encrypted relay result");
31128
- const relay = envelope;
31129
- if (relay.version !== 1 || relay.algorithm !== "ECDH-P256-A256GCM") throw new Error("OpenKey returned an unsupported encrypted relay result");
31130
- const peer = createPublicKey({ key: publicRelayJwk(relay.ephemeralPublicJwk), format: "jwk" });
31131
- const nonce = decodeCanonicalBase64Url(relay.nonce, "relay nonce");
31132
- const ciphertext = decodeCanonicalBase64Url(relay.ciphertext, "relay ciphertext");
31133
- if (nonce.length !== 12 || ciphertext.length <= 16) throw new Error("OpenKey returned an invalid encrypted relay result");
31134
- const sharedSecret = diffieHellman({ privateKey, publicKey: peer });
31135
- const key = deriveRelayKey(sharedSecret, transactionId);
31136
- const decipher = createDecipheriv("aes-256-gcm", key, nonce);
31137
- decipher.setAAD(Buffer.from(transactionId));
31138
- decipher.setAuthTag(ciphertext.subarray(ciphertext.length - 16));
31139
- let value;
31140
- try {
31141
- value = JSON.parse(Buffer.concat([decipher.update(ciphertext.subarray(0, -16)), decipher.final()]).toString("utf8"));
31142
- } catch {
31143
- throw new Error("OpenKey returned an unreadable encrypted relay result");
31144
- }
31145
- if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("OpenKey returned an invalid encrypted relay result");
31146
- return value;
31147
- }
31148
- function assertShareDelegationPermissions(value) {
31149
- if (!Array.isArray(value) || value.length !== 1) throw new Error("OpenKey returned a delegation outside the requested Share scope");
31150
- const permission = value[0];
31151
- if (!permission || permission.service !== "tinycloud.capabilities" && permission.service !== "capabilities" || permission.space !== "applications" && !(typeof permission.space === "string" && permission.space.endsWith(":applications")) || permission.path !== "" || !Array.isArray(permission.actions) || permission.actions.length !== 1 || permission.actions[0] !== "tinycloud.capabilities/read") throw new Error("OpenKey returned a delegation outside the requested Share scope");
31152
- }
31153
- function assertApprovedBinding(input) {
31154
- if (input.binding.transactionId !== input.transactionId || input.binding.sessionDid !== input.sessionDid || input.binding.nodeOrigin !== input.nodeOrigin || input.binding.shareOrigin !== input.shareOrigin || !jsonEqual(input.binding.permissions, SHARE_DEVICE_PERMISSIONS)) throw new Error("OpenKey returned a delegation with the wrong device binding");
31155
- const expiresAt = Date.parse(input.binding.delegationExpiresAt);
31156
- if (!Number.isFinite(expiresAt) || expiresAt <= Date.now() || expiresAt > Date.now() + SHARE_DEVICE_DELEGATION_SECONDS * 1e3 + 3e4) {
31157
- throw new Error("OpenKey returned a delegation outside the requested expiry window");
31158
- }
31159
- if (input.delegation.verificationMethod !== input.sessionDid) {
31160
- throw new Error("OpenKey returned a delegation for a different CLI session DID");
31161
- }
31162
- assertShareDelegationPermissions(input.delegation.permissions);
31163
- const delegationExpiryValue = input.delegation.expiresAt ?? input.delegation.expirationTime ?? input.delegation.expiry;
31164
- const delegationExpiresAt = typeof delegationExpiryValue === "string" ? Date.parse(delegationExpiryValue) : Number.NaN;
31165
- if (!Number.isFinite(delegationExpiresAt) || delegationExpiresAt !== expiresAt) {
31166
- throw new Error("OpenKey returned a delegation outside the approved expiry window");
31167
- }
31168
- if (!input.delegation.jwk || typeof input.delegation.jwk !== "object" || !jsonEqual(publicSessionJwk(input.delegation.jwk), input.publicJwk)) {
31169
- throw new Error("OpenKey returned a delegation for a different CLI session key");
31170
- }
31171
- const invalid = validateDelegationCallbackPayload(input.delegation);
31172
- if (invalid) throw new Error(`OpenKey returned an invalid delegation: ${invalid}`);
31173
- }
31174
- async function acquireShareDeviceDelegation(input) {
31175
- const openkeyHost = canonicalOrigin(input.openkeyHost ?? DEFAULT_OPENKEY_DEVICE_API_HOST, "OpenKey host");
31176
- const nodeOrigin = canonicalOrigin(input.nodeOrigin, "TinyCloud node origin");
31177
- const shareOrigin = canonicalOrigin(input.shareOrigin, "Share origin");
31178
- const fetchFn = input.fetchFn ?? globalThis.fetch;
31179
- const deviceSecret = randomBytes3(32).toString("base64url");
31180
- const codeVerifier = randomBytes3(32).toString("base64url");
31181
- const relayKeys = generateKeyPairSync("ec", { namedCurve: "prime256v1" });
31182
- const relayPublicJwk = publicRelayJwk(relayKeys.publicKey.export({ format: "jwk" }));
31183
- const publicJwk = publicSessionJwk(input.jwk);
31184
- const startResponse = await fetchFn(`${openkeyHost}/api/device-authorizations`, {
31185
- method: "POST",
31186
- credentials: "omit",
31187
- redirect: "error",
31188
- referrerPolicy: "no-referrer",
31189
- headers: { accept: "application/json", "content-type": "application/json" },
31190
- body: JSON.stringify({
31191
- deviceSecretHash: digest2(deviceSecret),
31192
- codeChallenge: digest2(codeVerifier),
31193
- relayPublicJwk,
31194
- sessionDid: input.sessionDid,
31195
- publicJwk,
31196
- permissions: SHARE_DEVICE_PERMISSIONS,
31197
- nodeOrigin,
31198
- shareOrigin,
31199
- delegationTtlSeconds: SHARE_DEVICE_DELEGATION_SECONDS
31200
- })
31201
- });
31202
- const startValue = await responseJson(startResponse);
31203
- if (!startResponse.ok) throw new Error(`OpenKey device authorization failed: ${errorCode(startValue) ?? startResponse.status}`);
31204
- const started = validateStart(startValue);
31205
- (input.emitInstructions ?? ((value) => {
31206
- process.stderr.write(`OpenKey device authorization
31207
- Visit: ${value.verificationUri}
31208
- Code: ${value.userCode}
31209
-
31210
- Waiting for approval\u2026
31211
- `);
31212
- }))({ verificationUri: started.verificationUri, verificationUriComplete: started.verificationUriComplete, userCode: started.userCode });
31213
- const deadline = Date.now() + started.expiresIn * 1e3;
31214
- let interval = started.interval;
31215
- const wait = input.wait ?? ((milliseconds) => new Promise((resolve4) => setTimeout(resolve4, milliseconds)));
31216
- while (Date.now() < deadline) {
31217
- await wait(interval * 1e3);
31218
- const response = await fetchFn(`${openkeyHost}/api/device-authorizations/token`, {
31219
- method: "POST",
31220
- credentials: "omit",
31221
- redirect: "error",
31222
- referrerPolicy: "no-referrer",
31223
- headers: { accept: "application/json", "content-type": "application/json" },
31224
- body: JSON.stringify({ transactionId: started.transactionId, deviceSecret, codeVerifier })
31225
- });
31226
- const value = await responseJson(response);
31227
- const code3 = errorCode(value);
31228
- if (response.status === 429 && code3 === "slow_down") {
31229
- interval += 1;
31230
- continue;
31231
- }
31232
- if (!response.ok) throw new Error(`OpenKey device authorization failed: ${code3 ?? response.status}`);
31233
- const result = value;
31234
- if (result.status === "pending") {
31235
- interval = Math.max(interval, result.interval);
31236
- continue;
31237
- }
31238
- if (result.status !== "approved" || !result.relay || !result.binding) {
31239
- throw new Error("OpenKey returned an invalid device authorization result");
31240
- }
31241
- const delegation = decryptRelayResult(result.relay, started.transactionId, relayKeys.privateKey);
31242
- assertApprovedBinding({ binding: result.binding, transactionId: started.transactionId, sessionDid: input.sessionDid, nodeOrigin, shareOrigin, publicJwk, delegation });
31243
- return delegation;
31244
- }
31245
- throw new Error("OpenKey device authorization expired before approval");
31246
- }
31247
- function mergePrivateJwkIntoSession(session, key) {
31248
- const sessionJwk = session.jwk;
31249
- if (!sessionJwk || typeof sessionJwk !== "object") return session;
31250
- const sessionJwkRecord = sessionJwk;
31251
- if (typeof sessionJwkRecord.d === "string" && sessionJwkRecord.d.length > 0) return session;
31252
- const privateParameter = key.d;
31253
- if (typeof privateParameter !== "string" || privateParameter.length === 0) return session;
31254
- return { ...session, jwk: { ...sessionJwkRecord, d: privateParameter } };
31255
- }
31256
- async function ensureShareDeviceAuthorization(input) {
31257
- let profile = await ProfileManager.getProfile(input.profileName).catch(() => null);
31258
- if (profile?.authMethod === "local" && input.allowReplaceLocal !== true) {
31259
- throw new Error("This profile uses a local owner key. Run `tc auth login --device` explicitly to replace its authentication posture.");
31260
- }
31261
- let key = await ProfileManager.getKey(input.profileName);
31262
- if (!key) {
31263
- const generated = generateKey2();
31264
- key = generated.jwk;
31265
- await ProfileManager.setKey(input.profileName, key);
31266
- }
31267
- const sessionDid = keyToDID(key);
31268
- profile = {
31269
- ...profile,
31270
- name: input.profileName,
31271
- host: input.nodeOrigin,
31272
- chainId: profile?.chainId ?? DEFAULT_CHAIN_ID,
31273
- spaceName: profile?.spaceName ?? "applications",
31274
- did: sessionDid,
31275
- sessionDid,
31276
- createdAt: profile?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
31277
- posture: "owner-openkey",
31278
- operatorType: profile?.operatorType ?? "human",
31279
- authMethod: "openkey",
31280
- openkeyHost: input.openkeyHost ?? profile?.openkeyHost
31281
- };
31282
- await ProfileManager.setProfile(input.profileName, profile);
31283
- const delegation = await acquireShareDeviceDelegation({
31284
- sessionDid,
31285
- jwk: key,
31286
- nodeOrigin: input.nodeOrigin,
31287
- shareOrigin: input.shareOrigin,
31288
- openkeyHost: input.openkeyHost ?? profile.openkeyHost,
31289
- fetchFn: input.fetchFn,
31290
- emitInstructions: input.emitInstructions,
31291
- wait: input.wait
31292
- });
31293
- const session = mergePrivateJwkIntoSession(delegation, key);
31294
- await ProfileManager.setSession(input.profileName, session);
31295
- const updatedProfile = {
31296
- ...profile,
31297
- ownerDid: typeof session.ownerDid === "string" ? session.ownerDid : profile.ownerDid,
31298
- spaceId: typeof session.spaceId === "string" ? session.spaceId : profile.spaceId
31299
- };
31300
- await ProfileManager.setProfile(input.profileName, updatedProfile);
31301
- return { profile: updatedProfile, delegation: session };
31302
- }
31303
-
31304
30525
  // src/commands/auth.ts
31305
30526
  init_theme();
31306
30527
  function resolveOpenKeyHost(profile) {
@@ -31308,7 +30529,7 @@ function resolveOpenKeyHost(profile) {
31308
30529
  }
31309
30530
  async function promptAuthMethod() {
31310
30531
  if (!isInteractive()) {
31311
- return "openkey";
30532
+ return "local";
31312
30533
  }
31313
30534
  const rl = createInterface2({
31314
30535
  input: process.stdin,
@@ -31334,20 +30555,19 @@ async function promptAuthMethod() {
31334
30555
  }
31335
30556
  function registerAuthCommand(program) {
31336
30557
  const auth = program.command("auth").description("Authentication management");
31337
- auth.command("login").description("Authenticate with TinyCloud").option("--device", "Use OpenKey device authorization (recommended for remote/headless use)").option("--paste", "Use manual paste mode instead of browser callback").option("--no-popup", "Print the OpenKey URL without opening a browser").option("--method <method>", "Authentication method: local or openkey").action(async (options, cmd) => {
30558
+ auth.command("login").description("Authenticate with TinyCloud").option("--paste", "Use manual paste mode instead of browser callback").option("--no-popup", "Print the OpenKey URL without opening a browser").option("--method <method>", "Authentication method: local or openkey").option("--manifest <fileOrBase64>", "Request only this manifest's permissions during OpenKey login (one space)").option("--expiry <duration>", "OpenKey session lifetime, e.g. 1h or 7d").option("--owner <did>", "Require this existing primary DID for scoped login").action(async (options, cmd) => {
31338
30559
  try {
31339
- if (options.device && options.paste) {
31340
- throw new CLIError("INVALID_ARGUMENT", "--device and --paste are mutually exclusive.", ExitCode.USAGE_ERROR);
31341
- }
31342
30560
  const globalOpts = cmd.optsWithGlobals();
31343
30561
  const ctx = await ProfileManager.resolveContext(globalOpts);
31344
- let method;
31345
- if (options.device && options.method === "local") {
31346
- throw new CLIError("INVALID_ARGUMENT", "--device requires --method openkey.", ExitCode.USAGE_ERROR);
30562
+ if ((options.manifest || options.expiry || options.owner) && options.method === "local") {
30563
+ throw new CLIError("INVALID_ARGUMENT", "--manifest, --expiry and --owner require OpenKey login.", ExitCode.USAGE_ERROR);
30564
+ }
30565
+ if (options.owner && !options.manifest) {
30566
+ throw new CLIError("INVALID_ARGUMENT", "--owner requires --manifest so the signed identity is verified.", ExitCode.USAGE_ERROR);
31347
30567
  }
31348
- if (options.device) {
31349
- method = "openkey";
31350
- } else if (options.method) {
30568
+ const permissions = options.manifest ? await loadManifestPermissions(options.manifest, ctx.profile, { allowLogicalSpaces: true }) : void 0;
30569
+ let method;
30570
+ if (options.method) {
31351
30571
  if (options.method !== "local" && options.method !== "openkey") {
31352
30572
  throw new CLIError(
31353
30573
  "INVALID_METHOD",
@@ -31357,7 +30577,7 @@ function registerAuthCommand(program) {
31357
30577
  }
31358
30578
  method = options.method;
31359
30579
  } else {
31360
- method = await promptAuthMethod();
30580
+ method = options.manifest || options.expiry ? "openkey" : await promptAuthMethod();
31361
30581
  }
31362
30582
  if (method === "local") {
31363
30583
  await handleLocalAuth(ctx.profile, ctx.host);
@@ -31365,7 +30585,9 @@ function registerAuthCommand(program) {
31365
30585
  await handleOpenKeyAuth(ctx.profile, ctx.host, {
31366
30586
  paste: options.paste,
31367
30587
  noPopup: options.popup === false,
31368
- device: options.device === true || !isInteractive() && options.paste !== true
30588
+ permissions,
30589
+ expiry: parseExpiryOption(options.expiry),
30590
+ expectedOwner: options.owner
31369
30591
  });
31370
30592
  }
31371
30593
  } catch (error) {
@@ -31953,15 +31175,15 @@ async function importRequestBoundDelegation(ctx, artifact) {
31953
31175
  );
31954
31176
  switch (result.status) {
31955
31177
  case "ok": {
31956
- const output2 = result.output;
31178
+ const output = result.output;
31957
31179
  outputJson({
31958
31180
  imported: true,
31959
- activated: output2.activated,
31181
+ activated: output.activated,
31960
31182
  kind: "tinycloud.auth.delegation",
31961
31183
  requestId: typeof artifact === "object" && artifact !== null && typeof artifact.requestId === "string" ? artifact.requestId : null,
31962
- delegationCid: output2.cid,
31963
- permissions: output2.effectivePermissions,
31964
- expiry: output2.expiry
31184
+ delegationCid: output.cid,
31185
+ permissions: output.effectivePermissions,
31186
+ expiry: output.expiry
31965
31187
  });
31966
31188
  return;
31967
31189
  }
@@ -32460,33 +31682,35 @@ async function handleLocalAuth(profileName, host, options = {}) {
32460
31682
  return { profile: updatedProfile, sessionResult };
32461
31683
  }
32462
31684
  async function handleOpenKeyAuth(profileName, host, options = {}) {
32463
- if (options.device) {
32464
- const result = await ensureShareDeviceAuthorization({
32465
- profileName,
32466
- nodeOrigin: host,
32467
- shareOrigin: "https://share.tinycloud.xyz",
32468
- openkeyHost: process.env.TC_OPENKEY_HOST,
32469
- allowReplaceLocal: true
32470
- });
32471
- outputJson({
32472
- authenticated: true,
32473
- profile: profileName,
32474
- did: result.profile.did,
32475
- spaceId: result.profile.spaceId ?? null,
32476
- authMethod: "openkey",
32477
- mode: "device"
32478
- });
32479
- return;
32480
- }
32481
31685
  const { profile, delegationData } = await refreshOpenKeySession(profileName, host, options);
32482
31686
  outputJson({
32483
31687
  authenticated: true,
32484
31688
  profile: profileName,
32485
31689
  did: profile.did,
32486
31690
  spaceId: delegationData.spaceId,
32487
- authMethod: "openkey"
31691
+ authMethod: "openkey",
31692
+ ...options.permissions ? { scoped: true, ownerDid: profile.ownerDid, host, permissions: delegationData.permissions, expiresAt: delegationData.expiresAt, activation: delegationData.hostActivated === true ? "confirmed-by-openkey" : "unverified" } : {}
32488
31693
  });
32489
31694
  }
31695
+ function mergePrivateJwkIntoSession(session, key) {
31696
+ const sessionJwk = session.jwk;
31697
+ if (!sessionJwk || typeof sessionJwk !== "object") {
31698
+ return session;
31699
+ }
31700
+ const sessionJwkRecord = sessionJwk;
31701
+ const sessionD = sessionJwkRecord.d;
31702
+ if (typeof sessionD === "string" && sessionD.length > 0) {
31703
+ return session;
31704
+ }
31705
+ const keyD = key.d;
31706
+ if (typeof keyD !== "string" || keyD.length === 0) {
31707
+ return session;
31708
+ }
31709
+ return {
31710
+ ...session,
31711
+ jwk: { ...sessionJwkRecord, d: keyD }
31712
+ };
31713
+ }
32490
31714
  async function refreshOpenKeySession(profileName, host, options = {}) {
32491
31715
  const key = await ProfileManager.getKey(profileName);
32492
31716
  if (!key) {
@@ -32497,18 +31721,23 @@ async function refreshOpenKeySession(profileName, host, options = {}) {
32497
31721
  );
32498
31722
  }
32499
31723
  const profile = await ProfileManager.getProfile(profileName);
31724
+ if (options.permissions !== void 0) validateLoginPermissions(options.permissions);
32500
31725
  const acquireOpenKey = options.openKeyAcquisition ?? startAuthFlow;
32501
31726
  const delegationData = await acquireOpenKey(profile.did, {
32502
31727
  paste: options.paste,
32503
31728
  noPopup: options.noPopup,
32504
31729
  jwk: key,
32505
31730
  host,
32506
- openkeyHost: resolveOpenKeyHost(profile)
31731
+ openkeyHost: resolveOpenKeyHost(profile),
31732
+ permissions: options.permissions,
31733
+ expiry: options.expiry,
31734
+ ...options.permissions ? { reason: "Allow this local TinyCloud profile to use the permissions in the installed application manifest." } : {}
32507
31735
  });
32508
- const sanitizedSession = mergePrivateJwkIntoSession(delegationData, key);
31736
+ const sanitizedSession = options.permissions ? await verifyScopedLogin(delegationData, key, profile.sessionDid ?? profile.did, options.permissions, options.expectedOwner ?? profile.ownerDid) : mergePrivateJwkIntoSession(delegationData, key);
32509
31737
  await ProfileManager.setSession(profileName, sanitizedSession);
32510
31738
  const updatedProfile = {
32511
31739
  ...profile,
31740
+ host,
32512
31741
  sessionDid: profile.sessionDid ?? profile.did,
32513
31742
  posture: profile.posture ?? "owner-openkey",
32514
31743
  operatorType: profile.operatorType ?? "human",
@@ -32652,6 +31881,99 @@ complete -c tc -l quiet -s q -d "Suppress non-essential output"
32652
31881
  `;
32653
31882
  }
32654
31883
 
31884
+ // package.json
31885
+ var package_default = {
31886
+ name: "@tinycloud/cli",
31887
+ version: "0.10.0",
31888
+ description: "TinyCloud CLI - manage data, delegations, and nodes from the terminal",
31889
+ author: "TinyCloud, Inc.",
31890
+ license: "EGPL",
31891
+ type: "module",
31892
+ main: "dist/index.js",
31893
+ types: "dist/index.d.ts",
31894
+ bin: {
31895
+ tc: "./bin/tc"
31896
+ },
31897
+ files: [
31898
+ "dist",
31899
+ "bin",
31900
+ "skills"
31901
+ ],
31902
+ engines: {
31903
+ node: ">=20"
31904
+ },
31905
+ scripts: {
31906
+ build: "tsup",
31907
+ clean: "rm -rf dist",
31908
+ dev: "tsup --watch",
31909
+ "generate:reference": "bun scripts/generate-reference.ts",
31910
+ "check:generated": "bun scripts/generate-reference.ts --check",
31911
+ "check:coverage": "bun scripts/check-coverage.ts",
31912
+ "smoke:delegated-secrets": "bun scripts/live-delegated-secrets-smoke.ts",
31913
+ "check:skill-pack": "node scripts/check-skill-pack.mjs",
31914
+ "test:scoped-login": "bun test src/auth/scoped-login.test.ts",
31915
+ "test:packed": "node scripts/test-packed-cli.mjs"
31916
+ },
31917
+ dependencies: {
31918
+ "@tinycloud/share-sdk": "0.2.0",
31919
+ "@tinycloud/share-envelope": "0.2.0",
31920
+ "@tinycloud/node-sdk": "2.11.0",
31921
+ "@tinycloud/node-sdk-wasm": "1.7.6",
31922
+ "@tinycloud/operations": "0.3.2",
31923
+ chalk: "^5.3.0",
31924
+ commander: "^14.0.0",
31925
+ open: "^11.0.0",
31926
+ ora: "^9.3.0",
31927
+ siwe: "^3.0.0"
31928
+ },
31929
+ devDependencies: {
31930
+ "@types/node": "^20",
31931
+ tsup: "^8.0.0",
31932
+ typescript: "^5.9.3"
31933
+ }
31934
+ };
31935
+
31936
+ // src/commands/context.ts
31937
+ init_profiles();
31938
+ init_space();
31939
+ init_formatter();
31940
+ init_errors();
31941
+ function registerContextCommand(program) {
31942
+ program.command("context").description("Report selected identity, host, space and local session state as JSON (does not test access)").option("--space <name|uri>", "Resolve this space in the selected profile").action(async (options, cmd) => {
31943
+ try {
31944
+ const ctx = await ProfileManager.resolveContext(cmd.optsWithGlobals());
31945
+ const profile = await ProfileManager.getProfile(ctx.profile);
31946
+ const session = await ProfileManager.getSession(ctx.profile);
31947
+ const spaceId = await resolveSpaceUri(options.space, ctx.profile) ?? (typeof session?.spaceId === "string" ? session.spaceId : profile.spaceId ?? null);
31948
+ const expiryValues = [
31949
+ session?.expiresAt,
31950
+ session?.expiry,
31951
+ session?.expirationTime,
31952
+ typeof session?.siwe === "string" ? session.siwe.match(/^Expiration Time:\s*(.+)$/m)?.[1] : void 0
31953
+ ];
31954
+ const expiry = expiryValues.find((value) => typeof value === "string" && Number.isFinite(Date.parse(value)));
31955
+ const expiresAt = typeof expiry === "string" ? new Date(expiry).toISOString() : null;
31956
+ outputJson({
31957
+ schemaVersion: 1,
31958
+ cliVersion: package_default.version,
31959
+ profile: ctx.profile,
31960
+ ownerDid: profile.ownerDid ?? null,
31961
+ sessionDid: profile.sessionDid ?? profile.did,
31962
+ host: ctx.host,
31963
+ spaceId,
31964
+ session: {
31965
+ state: session === null ? "missing" : expiresAt === null ? "unknown-expiry" : Date.parse(expiresAt) <= Date.now() ? "expired" : "present",
31966
+ expiresAt,
31967
+ evidence: "local-metadata"
31968
+ },
31969
+ access: "not-tested"
31970
+ });
31971
+ } catch (error) {
31972
+ handleError(error);
31973
+ }
31974
+ });
31975
+ }
31976
+
32655
31977
  // src/commands/delegation.ts
32656
31978
  init_profiles();
32657
31979
  init_formatter();
@@ -33062,36 +32384,6 @@ ${rowCount} row${rowCount === 1 ? "" : "s"} returned`) + "\n");
33062
32384
  });
33063
32385
  }
33064
32386
 
33065
- // src/commands/enable.ts
33066
- init_profiles();
33067
- init_errors();
33068
- init_formatter();
33069
- function registerEnableCommand(program) {
33070
- const enable = program.command("enable").description("Enable a narrowly scoped TinyCloud service");
33071
- enable.command("share").description("Approve Share publishing through OpenKey device authorization").action(async (_options, command) => {
33072
- try {
33073
- const context = await ProfileManager.resolveContext(command.optsWithGlobals());
33074
- const result = await ensureShareDeviceAuthorization({
33075
- profileName: context.profile,
33076
- nodeOrigin: context.host,
33077
- shareOrigin: "https://share.tinycloud.xyz",
33078
- openkeyHost: process.env.TC_OPENKEY_HOST,
33079
- allowReplaceLocal: true
33080
- });
33081
- const value = {
33082
- enabled: true,
33083
- service: "share",
33084
- profile: context.profile,
33085
- sessionDid: result.profile.sessionDid ?? result.profile.did,
33086
- expiresAt: result.delegation.expiresAt ?? result.delegation.expirationTime ?? result.delegation.expiry
33087
- };
33088
- output(value, () => `Share enabled for profile ${context.profile}.`);
33089
- } catch (error) {
33090
- handleError(error);
33091
- }
33092
- });
33093
- }
33094
-
33095
32387
  // src/commands/init.ts
33096
32388
  init_profiles();
33097
32389
  init_formatter();
@@ -34827,7 +34119,7 @@ function receiveJson(result, path) {
34827
34119
  // src/share/io.ts
34828
34120
  import { constants } from "fs";
34829
34121
  import { lstat, mkdir as mkdir3, mkdtemp, open as open3, readFile as readFile9, realpath, stat as stat2, link, rename as rename2, rm as rm2, unlink } from "fs/promises";
34830
- import { randomBytes as randomBytes4 } from "crypto";
34122
+ import { randomBytes as randomBytes3 } from "crypto";
34831
34123
  import { basename as basename2, join as join6, resolve as resolve2, sep } from "path";
34832
34124
  var MAX_SHARE_STDIN_BYTES = 100 * 1024 * 1024;
34833
34125
  var MAX_SHARE_URL_BYTES = 64 * 1024;
@@ -34906,7 +34198,7 @@ async function writeShareOutput(directory, filename, bytes, force) {
34906
34198
  const stagingDirectory = await mkdtemp(join6(stableDirectory, ".tinycloud-share-stage-"));
34907
34199
  const stagingInfo = await lstat(stagingDirectory);
34908
34200
  if (!stagingInfo.isDirectory() || (stagingInfo.mode & 511) !== 448) throw new Error("OUTPUT_EXISTS");
34909
- const stagingPath = join6(stagingDirectory, `.tinycloud-share-${randomBytes4(16).toString("hex")}.tmp`);
34201
+ const stagingPath = join6(stagingDirectory, `.tinycloud-share-${randomBytes3(16).toString("hex")}.tmp`);
34910
34202
  let temporaryPath;
34911
34203
  let handle;
34912
34204
  try {
@@ -34959,11 +34251,11 @@ function parseShareTarget(value) {
34959
34251
  if (value.includes("@")) return { kind: "email", address: value };
34960
34252
  throw new CLIError("INVALID_ARGUMENT", "--to must be anyone, a did:, an email address, or domain:example.com", 2);
34961
34253
  }
34962
- function publishServices(insecureLocalRegistry = false) {
34254
+ function publishServices() {
34963
34255
  return {
34964
34256
  ...shareServices.uploadBlob === void 0 ? {} : { uploadBlob: shareServices.uploadBlob },
34965
34257
  ...shareServices.authorizeUpload === void 0 ? {} : { authorizeUpload: shareServices.authorizeUpload },
34966
- ...shareServices.authorizeUpload === void 0 || insecureLocalRegistry ? {} : { authorizationOrigin: SHARE_ORIGIN },
34258
+ ...shareServices.authorizeUpload === void 0 ? {} : { authorizationOrigin: SHARE_ORIGIN },
34967
34259
  ...shareServices.credentials === void 0 ? {} : { credentials: shareServices.credentials },
34968
34260
  ...shareServices.fetchFn === void 0 ? {} : { fetchFn: shareServices.fetchFn }
34969
34261
  };
@@ -35009,9 +34301,6 @@ function inputUrl(value, stdin) {
35009
34301
  if (value === void 0 || value.length === 0) throw new CLIError("INVALID_ARGUMENT", "a share URL or - is required", 2);
35010
34302
  return Promise.resolve(value);
35011
34303
  }
35012
- function jsonOutput(options, command) {
35013
- return options.json === true || command.optsWithGlobals().json === true;
35014
- }
35015
34304
  function expires(value) {
35016
34305
  try {
35017
34306
  return new Date(Date.now() + parseDuration(value));
@@ -35062,9 +34351,8 @@ function assertAggregateInputLimit(inputs, maxBytes) {
35062
34351
  }
35063
34352
  function registerShareCommand(program) {
35064
34353
  const share = program.command("share").description("Publish and consume TinyCloud Share links");
35065
- share.command("publish <files...>").description("Publish one or more bounded files as a Share").option("--name <filename>", "Filename for stdin input").option("--to <target>", "Share target", "anyone").option("--notify", "Request idempotent email delivery for addressed targets").option("--expires <duration>", "Share lifetime", "7d").option("--max-bytes <bytes>", "Bound input bytes").option("--media-type <type>", "Media type for a single input").option("--action <actions...>", "Addressed permission: read, list, or edit").option("--prefix", "Publish multiple inputs beneath one addressed prefix").option("--binary", "Allow non-UTF-8 bearer content").option("--inline", "Embed the sealed envelope in the URL fragment").option("--compact", "Use a CID-addressed compact link (default)").option("--json", "Print versioned redacted JSON").option("--registry <url>", "Authenticated registry upload endpoint", DEFAULT_REGISTRY).option("--viewer-origin <origin>", "Canonical HTTPS viewer origin", SHARE_ORIGIN).option("--insecure-registry", "Allow an explicit localhost HTTP registry for hermetic tests").action(async (files, options, command) => {
34354
+ share.command("publish <files...>").description("Publish one or more bounded files as a Share").option("--name <filename>", "Filename for stdin input").option("--to <target>", "Share target", "anyone").option("--notify", "Request idempotent email delivery for addressed targets").option("--expires <duration>", "Share lifetime", "7d").option("--max-bytes <bytes>", "Bound input bytes").option("--media-type <type>", "Media type for a single input").option("--action <actions...>", "Addressed permission: read, list, or edit").option("--prefix", "Publish multiple inputs beneath one addressed prefix").option("--binary", "Allow non-UTF-8 bearer content").option("--inline", "Embed the sealed envelope in the URL fragment").option("--compact", "Use a CID-addressed compact link (default)").option("--json", "Print versioned redacted JSON").option("--registry <url>", "Authenticated registry upload endpoint", DEFAULT_REGISTRY).option("--viewer-origin <origin>", "Canonical HTTPS viewer origin", SHARE_ORIGIN).option("--insecure-registry", "Allow an explicit localhost HTTP registry for hermetic tests").action(async (files, options) => {
35066
34355
  try {
35067
- const json = jsonOutput(options, command);
35068
34356
  if (options.inline && options.compact) throw new CLIError("INVALID_ARGUMENT", "--inline and --compact are mutually exclusive", 2);
35069
34357
  const maxBytes = byteLimit(options.maxBytes);
35070
34358
  if (files.length === 0 || files.includes("-") && files.length > 1) throw new CLIError("INVALID_ARGUMENT", "stdin must be the only publish input", 2);
@@ -35093,10 +34381,10 @@ function registerShareCommand(program) {
35093
34381
  allowInsecureRegistry: options.insecureRegistry === true,
35094
34382
  notify: options.notify === true,
35095
34383
  targetAdapter: shareServices.targetAdapter,
35096
- ...publishServices(options.insecureRegistry === true)
34384
+ ...publishServices()
35097
34385
  });
35098
34386
  if ("state" in result) {
35099
- if (json) {
34387
+ if (options.json) {
35100
34388
  writeJson2({ protocol: "tinycloud-share", version: 1, authorization: authorizationRequiredJson(result) });
35101
34389
  process.exitCode = 6;
35102
34390
  return;
@@ -35109,27 +34397,25 @@ function registerShareCommand(program) {
35109
34397
  const delivery = await notifyShare({ shareId: record.shareId, recipient: target.address, record, adapter: shareServices.delivery });
35110
34398
  if (delivery.state === "partial-failure") process.exitCode = 9;
35111
34399
  }
35112
- if (json) writeJson2(redactPublishedShare(result));
34400
+ if (options.json) writeJson2(redactPublishedShare(result));
35113
34401
  else publishHuman(result);
35114
34402
  } catch (error) {
35115
34403
  handleError(shareCliError(error));
35116
34404
  }
35117
34405
  });
35118
- share.command("inspect [url]").description("Verify a share link and print safe metadata").option("--stdin", "Read the complete URL from stdin").option("--json", "Print versioned redacted JSON").option("--registry <url>", "Registry read endpoint", DEFAULT_READ_REGISTRY).option("--viewer-origin <origin>", "Require this canonical Share origin", SHARE_ORIGIN).action(async (url, options, command) => {
34406
+ share.command("inspect [url]").description("Verify a share link and print safe metadata").option("--stdin", "Read the complete URL from stdin").option("--json", "Print versioned redacted JSON").option("--registry <url>", "Registry read endpoint", DEFAULT_READ_REGISTRY).option("--viewer-origin <origin>", "Require this canonical Share origin", SHARE_ORIGIN).action(async (url, options) => {
35119
34407
  try {
35120
- const json = jsonOutput(options, command);
35121
34408
  const link2 = await inputUrl(url, options.stdin === true);
35122
34409
  const result = await inspectShare(link2, { registryBaseUrl: options.registry, expectedOrigin: options.viewerOrigin, ...fetchServices() });
35123
- if (json) writeJson2(result);
34410
+ if (options.json) writeJson2(result);
35124
34411
  else inspectHuman(result);
35125
34412
  } catch (error) {
35126
34413
  handleError(shareCliError(error));
35127
34414
  }
35128
34415
  });
35129
- share.command("receive [url]").description("Verify and receive a share link").option("--stdin", "Read the complete URL from stdin").option("--output <directory>", "Create the file in this directory").option("--stdout", "Write verified plaintext bytes to stdout").option("--force", "Allow replacing an existing non-symlink output").option("--max-bytes <bytes>", "Bound received content bytes").option("--resume-token <token>", "Resume a previously returned recipient authorization step").option("--authorization-proof-file <path>", "Read the JSON authorization proof from a file").option("--json", "Print versioned redacted JSON").option("--registry <url>", "Registry read endpoint", DEFAULT_READ_REGISTRY).option("--viewer-origin <origin>", "Require this canonical Share origin", SHARE_ORIGIN).option("--legacy", "Read a legacy tc1: link (read-only)").action(async (url, options, command) => {
34416
+ share.command("receive [url]").description("Verify and receive a share link").option("--stdin", "Read the complete URL from stdin").option("--output <directory>", "Create the file in this directory").option("--stdout", "Write verified plaintext bytes to stdout").option("--force", "Allow replacing an existing non-symlink output").option("--max-bytes <bytes>", "Bound received content bytes").option("--resume-token <token>", "Resume a previously returned recipient authorization step").option("--authorization-proof-file <path>", "Read the JSON authorization proof from a file").option("--json", "Print versioned redacted JSON").option("--registry <url>", "Registry read endpoint", DEFAULT_READ_REGISTRY).option("--viewer-origin <origin>", "Require this canonical Share origin", SHARE_ORIGIN).option("--legacy", "Read a legacy tc1: link (read-only)").action(async (url, options) => {
35130
34417
  try {
35131
- const json = jsonOutput(options, command);
35132
- if (options.stdout && json) throw new CLIError("INVALID_ARGUMENT", "--stdout and --json are mutually exclusive", 2);
34418
+ if (options.stdout && options.json) throw new CLIError("INVALID_ARGUMENT", "--stdout and --json are mutually exclusive", 2);
35133
34419
  const maxBytes = byteLimit(options.maxBytes);
35134
34420
  const link2 = await inputUrl(url, options.stdin === true);
35135
34421
  const proof = await authorizationProof(options);
@@ -35140,9 +34426,9 @@ function registerShareCommand(program) {
35140
34426
  process.stdout.write(Buffer.from(bytes));
35141
34427
  return;
35142
34428
  }
35143
- const output3 = await writeShareOutput(options.output ?? ".", "share.md", bytes, options.force === true);
35144
- if (json) writeJson2({ protocol: "tinycloud-share", version: 1, legacy: true, path: output3 });
35145
- else receiveHuman(output3);
34429
+ const output2 = await writeShareOutput(options.output ?? ".", "share.md", bytes, options.force === true);
34430
+ if (options.json) writeJson2({ protocol: "tinycloud-share", version: 1, legacy: true, path: output2 });
34431
+ else receiveHuman(output2);
35146
34432
  return;
35147
34433
  }
35148
34434
  const result = await receiveShare(link2, {
@@ -35155,7 +34441,7 @@ function registerShareCommand(program) {
35155
34441
  ...proof === void 0 ? {} : { authorizationProof: proof }
35156
34442
  });
35157
34443
  if ("state" in result) {
35158
- if (json) {
34444
+ if (options.json) {
35159
34445
  writeJson2({ protocol: "tinycloud-share", version: 1, authorization: authorizationRequiredJson(result) });
35160
34446
  process.exitCode = 6;
35161
34447
  return;
@@ -35166,16 +34452,15 @@ function registerShareCommand(program) {
35166
34452
  process.stdout.write(Buffer.from(result.bytes));
35167
34453
  return;
35168
34454
  }
35169
- const output2 = await writeShareOutput(options.output ?? ".", result.metadata.display.filename ?? "share.md", result.bytes, options.force === true);
35170
- if (json) receiveJson(result, output2);
35171
- else receiveHuman(output2);
34455
+ const output = await writeShareOutput(options.output ?? ".", result.metadata.display.filename ?? "share.md", result.bytes, options.force === true);
34456
+ if (options.json) receiveJson(result, output);
34457
+ else receiveHuman(output);
35172
34458
  } catch (error) {
35173
34459
  handleError(shareCliError(error));
35174
34460
  }
35175
34461
  });
35176
- share.command("migrate [url]").description("Read a legacy tc1 link and re-mint a modern Share link").option("--stdin", "Read the complete legacy link from stdin").option("--name <filename>", "Filename for the migrated content", "migrated.md").option("--to <target>", "Modern Share target", "anyone").option("--notify", "Request idempotent email delivery for addressed targets").option("--expires <duration>", "Modern share lifetime", "7d").option("--max-bytes <bytes>", "Bound migrated content bytes").option("--inline", "Embed the sealed envelope in the URL fragment").option("--registry <url>", "Authenticated registry upload endpoint", DEFAULT_REGISTRY).option("--viewer-origin <origin>", "Canonical HTTPS viewer origin", SHARE_ORIGIN).option("--insecure-registry", "Allow an explicit localhost HTTP registry for hermetic tests").option("--json", "Print versioned redacted JSON").action(async (url, options, command) => {
34462
+ share.command("migrate [url]").description("Read a legacy tc1 link and re-mint a modern Share link").option("--stdin", "Read the complete legacy link from stdin").option("--name <filename>", "Filename for the migrated content", "migrated.md").option("--to <target>", "Modern Share target", "anyone").option("--notify", "Request idempotent email delivery for addressed targets").option("--expires <duration>", "Modern share lifetime", "7d").option("--max-bytes <bytes>", "Bound migrated content bytes").option("--inline", "Embed the sealed envelope in the URL fragment").option("--registry <url>", "Authenticated registry upload endpoint", DEFAULT_REGISTRY).option("--viewer-origin <origin>", "Canonical HTTPS viewer origin", SHARE_ORIGIN).option("--insecure-registry", "Allow an explicit localhost HTTP registry for hermetic tests").option("--json", "Print versioned redacted JSON").action(async (url, options) => {
35177
34463
  try {
35178
- const json = jsonOutput(options, command);
35179
34464
  if (shareServices.legacyReader === void 0) throw new CLIError("UNSUPPORTED_LINK", "legacy migration requires an installed read-only tc1 adapter", 2);
35180
34465
  const link2 = await inputUrl(url, options.stdin === true);
35181
34466
  if (!isLegacyShareLink(link2)) throw new CLIError("UNSUPPORTED_LINK", "only tc1: links can be migrated", 2);
@@ -35197,7 +34482,7 @@ function registerShareCommand(program) {
35197
34482
  allowInsecureRegistry: options.insecureRegistry === true,
35198
34483
  notify: options.notify === true,
35199
34484
  targetAdapter: shareServices.targetAdapter,
35200
- ...publishServices(options.insecureRegistry === true)
34485
+ ...publishServices()
35201
34486
  });
35202
34487
  if ("state" in result) throw new CLIError(result.method === "openkey-device" ? "DEVICE_AUTH_REQUIRED" : "CLAIM_REQUIRED", "recipient authorization is required; continue through the configured authority adapter", 6);
35203
34488
  const record = await rememberPublishedShare(result);
@@ -35211,44 +34496,41 @@ function registerShareCommand(program) {
35211
34496
  return result;
35212
34497
  }
35213
34498
  });
35214
- if (json) writeJson2({ protocol: "tinycloud-share", version: 1, legacy: true, migrated: redactPublishedShare(migrated.migrated) });
34499
+ if (options.json) writeJson2({ protocol: "tinycloud-share", version: 1, legacy: true, migrated: redactPublishedShare(migrated.migrated) });
35215
34500
  else publishHuman(migrated.migrated);
35216
34501
  } catch (error) {
35217
34502
  handleError(shareCliError(error));
35218
34503
  }
35219
34504
  });
35220
- share.command("list").description("List encrypted sender history without complete bearer URLs").option("--json", "Print versioned redacted JSON").action(async (options, command) => {
34505
+ share.command("list").description("List encrypted sender history without complete bearer URLs").option("--json", "Print versioned redacted JSON").action(async (options) => {
35221
34506
  try {
35222
- const json = jsonOutput(options, command);
35223
34507
  if (shareServices.records === void 0) throw new CLIError("AUTH_REQUIRED", "sender history storage is not configured", 3);
35224
34508
  const result = await listShares(shareServices.records);
35225
- if (json) writeJson2({ protocol: "tinycloud-share", version: 1, shares: result });
34509
+ if (options.json) writeJson2({ protocol: "tinycloud-share", version: 1, shares: result });
35226
34510
  else process.stdout.write(result.map((item) => `${item.shareId} ${item.target} ${item.expiresAt}`).join("\n") + (result.length ? "\n" : ""));
35227
34511
  } catch (error) {
35228
34512
  handleError(shareCliError(error));
35229
34513
  }
35230
34514
  });
35231
- share.command("show <id>").description("Show one redacted sender-history record").option("--reveal-link", "Explicitly include the complete link").option("--json", "Print versioned redacted JSON").action(async (id, options, command) => {
34515
+ share.command("show <id>").description("Show one redacted sender-history record").option("--reveal-link", "Explicitly include the complete link").option("--json", "Print versioned redacted JSON").action(async (id, options) => {
35232
34516
  try {
35233
- const json = jsonOutput(options, command);
35234
- if (options.revealLink && json) throw new CLIError("INVALID_ARGUMENT", "--reveal-link cannot be combined with --json", 2);
34517
+ if (options.revealLink && options.json) throw new CLIError("INVALID_ARGUMENT", "--reveal-link cannot be combined with --json", 2);
35235
34518
  if (shareServices.records === void 0) throw new CLIError("AUTH_REQUIRED", "sender history storage is not configured", 3);
35236
34519
  const result = await showShare({ storage: shareServices.records, shareId: id, revealLink: options.revealLink === true, link: options.revealLink ? await shareServices.linkFor?.(id) : void 0 });
35237
- if (json) writeJson2({ protocol: "tinycloud-share", version: 1, share: result });
34520
+ if (options.json) writeJson2({ protocol: "tinycloud-share", version: 1, share: result });
35238
34521
  else writeJson2(result);
35239
34522
  } catch (error) {
35240
34523
  handleError(shareCliError(error));
35241
34524
  }
35242
34525
  });
35243
- share.command("notify <id>").description("Retry idempotent delivery without recreating the share").requiredOption("--to <address>", "Recipient email").option("--json", "Print versioned JSON").action(async (id, options, command) => {
34526
+ share.command("notify <id>").description("Retry idempotent delivery without recreating the share").requiredOption("--to <address>", "Recipient email").option("--json", "Print versioned JSON").action(async (id, options) => {
35244
34527
  try {
35245
- const json = jsonOutput(options, command);
35246
34528
  if (shareServices.delivery === void 0) throw new CLIError("AUTH_REQUIRED", "delivery authority is not configured", 3);
35247
34529
  if (shareServices.records === void 0) throw new CLIError("AUTH_REQUIRED", "sender history storage is not configured", 3);
35248
34530
  const record = await shareServices.records.get(id);
35249
34531
  if (record === void 0) throw new CLIError("NOT_FOUND", "share not found", 4);
35250
34532
  const result = await notifyShare({ shareId: id, recipient: options.to, record, adapter: shareServices.delivery });
35251
- if (json) writeJson2(result);
34533
+ if (options.json) writeJson2(result);
35252
34534
  else process.stdout.write(`${result.state}
35253
34535
  `);
35254
34536
  if (result.state === "partial-failure") process.exitCode = 9;
@@ -35256,9 +34538,8 @@ function registerShareCommand(program) {
35256
34538
  handleError(shareCliError(error));
35257
34539
  }
35258
34540
  });
35259
- share.command("revoke <id>").description("Revoke addressed shares; report bearer retention honestly").option("--ancestor", "Revoke the owner delegation ancestry").option("--json", "Print versioned JSON").action(async (id, options, command) => {
34541
+ share.command("revoke <id>").description("Revoke addressed shares; report bearer retention honestly").option("--ancestor", "Revoke the owner delegation ancestry").option("--json", "Print versioned JSON").action(async (id, options) => {
35260
34542
  try {
35261
- const json = jsonOutput(options, command);
35262
34543
  if (shareServices.records === void 0) throw new CLIError("AUTH_REQUIRED", "sender history storage is not configured", 3);
35263
34544
  const record = shareServices.getRecord ? await shareServices.getRecord(id) : await shareServices.records.get(id);
35264
34545
  if (record === void 0) throw new CLIError("NOT_FOUND", "share not found", 4);
@@ -35266,7 +34547,7 @@ function registerShareCommand(program) {
35266
34547
  if (result.state === "unsupported") {
35267
34548
  throw new CLIError("UNSUPPORTED_TARGET", result.reason, 2);
35268
34549
  }
35269
- if (json) writeJson2({ protocol: "tinycloud-share", version: 1, result });
34550
+ if (options.json) writeJson2({ protocol: "tinycloud-share", version: 1, result });
35270
34551
  else process.stdout.write(`${result.state}
35271
34552
  `);
35272
34553
  } catch (error) {
@@ -35280,7 +34561,7 @@ init_profiles();
35280
34561
  init_formatter();
35281
34562
  init_errors();
35282
34563
  init_constants();
35283
- import { randomBytes as randomBytes5 } from "crypto";
34564
+ import { randomBytes as randomBytes4 } from "crypto";
35284
34565
  import { mkdir as mkdir4, writeFile as writeFile6 } from "fs/promises";
35285
34566
  import { dirname as dirname3 } from "path";
35286
34567
  init_host();
@@ -35363,7 +34644,7 @@ it directly with \`tc space host <name>\` (no request needed).
35363
34644
  const artifact = {
35364
34645
  kind: "tinycloud.host.request",
35365
34646
  version: 1,
35366
- requestId: `hostreq_${Date.now().toString(36)}_${randomBytes5(4).toString("hex")}`,
34647
+ requestId: `hostreq_${Date.now().toString(36)}_${randomBytes4(4).toString("hex")}`,
35367
34648
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
35368
34649
  spaceName,
35369
34650
  spaceId,
@@ -36444,8 +35725,8 @@ function registerVarsCommand(program) {
36444
35725
  // src/command-registry.ts
36445
35726
  function registerTinyCloudCommands(program) {
36446
35727
  registerInitCommand(program);
35728
+ registerContextCommand(program);
36447
35729
  registerAuthCommand(program);
36448
- registerEnableCommand(program);
36449
35730
  registerKvCommand(program);
36450
35731
  registerSpaceCommand(program);
36451
35732
  registerDelegationCommand(program);