@tinycloud/cli 0.7.7-beta.3 → 0.7.7-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -36486,6 +36486,7 @@ var CAPABILITIES2 = deriveServiceConstants("capabilities");
36486
36486
  var HOOKS = deriveServiceConstants("hooks");
36487
36487
  var ENCRYPTION = deriveServiceConstants("encryption");
36488
36488
  var SPACE = deriveServiceConstants("space");
36489
+ var CAPABILITY_REGISTRY = CAPABILITIES;
36489
36490
 
36490
36491
  // ../bootstrap/dist/index.js
36491
36492
  var DEFAULT_MANIFEST_SPACE = "applications";
@@ -42361,7 +42362,8 @@ var SERVICE_SHORT_TO_LONG = Object.freeze({
42361
42362
  duckdb: "tinycloud.duckdb",
42362
42363
  capabilities: "tinycloud.capabilities",
42363
42364
  hooks: "tinycloud.hooks",
42364
- encryption: "tinycloud.encryption"
42365
+ encryption: "tinycloud.encryption",
42366
+ delegation: "tinycloud.delegation"
42365
42367
  });
42366
42368
  var ENCRYPTION_PERMISSION_SERVICE2 = "tinycloud.encryption";
42367
42369
  var ENCRYPTION_MANIFEST_SPACE2 = "encryption";
@@ -43176,7 +43178,6 @@ async function parseCapSpec(spec, profile) {
43176
43178
  const actionsCsv = spec.slice(lastColon + 1);
43177
43179
  const spaceAndPath = spec.slice(firstColon + 1, lastColon);
43178
43180
  const { space, path } = splitSpaceAndPath(spaceAndPath);
43179
- const resolvedSpace = await resolveSpaceUri(space, profile) ?? space;
43180
43181
  const actions = expandActionShortNames(
43181
43182
  service,
43182
43183
  actionsCsv.split(",").map((action) => action.trim()).filter(Boolean)
@@ -43184,7 +43185,9 @@ async function parseCapSpec(spec, profile) {
43184
43185
  if (actions.length === 0) {
43185
43186
  throw new CLIError("INVALID_CAP", `Capability "${spec}" has no actions.`, ExitCode.USAGE_ERROR);
43186
43187
  }
43187
- return { service, space: resolvedSpace, path, actions };
43188
+ return (await resolvePermissionSpaces([
43189
+ { service, space, path, actions }
43190
+ ], profile))[0];
43188
43191
  }
43189
43192
  async function loadPermissionRequest(source, profile) {
43190
43193
  const raw = JSON.parse(await readFile2(source, "utf8"));
@@ -43292,13 +43295,24 @@ function compactPermission(permission) {
43292
43295
  return `${service}:${space}:${permission.path}:${actions}`;
43293
43296
  }
43294
43297
  async function resolvePermissionSpaces(entries, profile) {
43298
+ const profileConfig = await ProfileManager.getProfile(profile);
43299
+ const allowLogicalSpaces = resolveProfilePosture(profileConfig) === "delegate-session";
43295
43300
  const resolved = [];
43296
43301
  for (const entry of entries) {
43297
43302
  const service = normalizeService(entry.service);
43303
+ let space;
43304
+ try {
43305
+ space = await resolveSpaceUri(entry.space, profile) ?? entry.space;
43306
+ } catch (error) {
43307
+ if (!allowLogicalSpaces || entry.space.startsWith("tinycloud:") || !(error instanceof CLIError) || error.code !== "ADDRESS_UNKNOWN") {
43308
+ throw error;
43309
+ }
43310
+ space = entry.space;
43311
+ }
43298
43312
  resolved.push({
43299
43313
  ...entry,
43300
43314
  service,
43301
- space: await resolveSpaceUri(entry.space, profile) ?? entry.space,
43315
+ space,
43302
43316
  actions: expandActionShortNames(service, entry.actions)
43303
43317
  });
43304
43318
  }
@@ -43836,17 +43850,19 @@ function registerAuthCommand(program2) {
43836
43850
  ExitCode.USAGE_ERROR
43837
43851
  );
43838
43852
  }
43853
+ const requested = await resolvePermissionSpaces(parsed.requested, ctx.profile);
43854
+ const resolvedRequest = { ...parsed, requested };
43839
43855
  const node = await ensureAuthenticated(ctx);
43840
43856
  await ensureDelegationAuthority({
43841
43857
  ctx,
43842
43858
  profile,
43843
43859
  node,
43844
- requested: parsed.requested,
43860
+ requested,
43845
43861
  expiryOption: parsed.requestedExpiry,
43846
43862
  reason: "Grant permissions requested by a TinyCloud auth request artifact.",
43847
43863
  yes: options.yes === true
43848
43864
  });
43849
- const grant = await grantAuthRequest(node, parsed);
43865
+ const grant = await grantAuthRequest(node, resolvedRequest);
43850
43866
  outputJson(grant);
43851
43867
  } catch (error) {
43852
43868
  handleError(error);
@@ -47424,228 +47440,24 @@ ${rowCount} row${rowCount === 1 ? "" : "s"} returned`) + "\n");
47424
47440
 
47425
47441
  // ../sdk-core/dist/index.js
47426
47442
  var import_siwe = __toESM(require_siwe(), 1);
47427
- var import_ms2 = __toESM(require_ms(), 1);
47428
-
47429
- // ../../node_modules/uint8arrays/dist/src/equals.js
47430
- function equals(a, b) {
47431
- if (a === b) {
47432
- return true;
47433
- }
47434
- if (a.byteLength !== b.byteLength) {
47435
- return false;
47436
- }
47437
- for (let i = 0; i < a.byteLength; i++) {
47438
- if (a[i] !== b[i]) {
47439
- return false;
47440
- }
47441
- }
47442
- return true;
47443
- }
47444
-
47445
- // ../../node_modules/uint8arrays/dist/src/alloc.node.js
47446
- import { Buffer as Buffer2 } from "buffer";
47447
-
47448
- // ../../node_modules/uint8arrays/dist/src/util/as-uint8array.node.js
47449
- function asUint8Array(buf) {
47450
- return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
47451
- }
47452
-
47453
- // ../../node_modules/uint8arrays/dist/src/alloc.node.js
47454
- function allocUnsafe(size = 0) {
47455
- return asUint8Array(Buffer2.allocUnsafe(size));
47456
- }
47457
-
47458
- // ../../node_modules/uint8-varint/dist/src/index.js
47459
- var N1 = Math.pow(2, 7);
47460
- var N2 = Math.pow(2, 14);
47461
- var N3 = Math.pow(2, 21);
47462
- var N4 = Math.pow(2, 28);
47463
- var N5 = Math.pow(2, 35);
47464
- var N6 = Math.pow(2, 42);
47465
- var N7 = Math.pow(2, 49);
47466
- var MSB = 128;
47467
- var REST = 127;
47468
- function encodingLength(value) {
47469
- if (value < N1) {
47470
- return 1;
47471
- }
47472
- if (value < N2) {
47473
- return 2;
47474
- }
47475
- if (value < N3) {
47476
- return 3;
47477
- }
47478
- if (value < N4) {
47479
- return 4;
47480
- }
47481
- if (value < N5) {
47482
- return 5;
47483
- }
47484
- if (value < N6) {
47485
- return 6;
47486
- }
47487
- if (value < N7) {
47488
- return 7;
47489
- }
47490
- if (Number.MAX_SAFE_INTEGER != null && value > Number.MAX_SAFE_INTEGER) {
47491
- throw new RangeError("Could not encode varint");
47492
- }
47493
- return 8;
47494
- }
47495
- function encodeUint8Array(value, buf, offset = 0) {
47496
- switch (encodingLength(value)) {
47497
- case 8: {
47498
- buf[offset++] = value & 255 | MSB;
47499
- value /= 128;
47500
- }
47501
- case 7: {
47502
- buf[offset++] = value & 255 | MSB;
47503
- value /= 128;
47504
- }
47505
- case 6: {
47506
- buf[offset++] = value & 255 | MSB;
47507
- value /= 128;
47508
- }
47509
- case 5: {
47510
- buf[offset++] = value & 255 | MSB;
47511
- value /= 128;
47512
- }
47513
- case 4: {
47514
- buf[offset++] = value & 255 | MSB;
47515
- value >>>= 7;
47516
- }
47517
- case 3: {
47518
- buf[offset++] = value & 255 | MSB;
47519
- value >>>= 7;
47520
- }
47521
- case 2: {
47522
- buf[offset++] = value & 255 | MSB;
47523
- value >>>= 7;
47524
- }
47525
- case 1: {
47526
- buf[offset++] = value & 255;
47527
- value >>>= 7;
47528
- break;
47529
- }
47530
- default:
47531
- throw new Error("unreachable");
47532
- }
47533
- return buf;
47534
- }
47535
- function decodeUint8Array(buf, offset) {
47536
- let b = buf[offset];
47537
- let res = 0;
47538
- res += b & REST;
47539
- if (b < MSB) {
47540
- return res;
47541
- }
47542
- b = buf[offset + 1];
47543
- res += (b & REST) << 7;
47544
- if (b < MSB) {
47545
- return res;
47546
- }
47547
- b = buf[offset + 2];
47548
- res += (b & REST) << 14;
47549
- if (b < MSB) {
47550
- return res;
47551
- }
47552
- b = buf[offset + 3];
47553
- res += (b & REST) << 21;
47554
- if (b < MSB) {
47555
- return res;
47556
- }
47557
- b = buf[offset + 4];
47558
- res += (b & REST) * N4;
47559
- if (b < MSB) {
47560
- return res;
47561
- }
47562
- b = buf[offset + 5];
47563
- res += (b & REST) * N5;
47564
- if (b < MSB) {
47565
- return res;
47566
- }
47567
- b = buf[offset + 6];
47568
- res += (b & REST) * N6;
47569
- if (b < MSB) {
47570
- return res;
47571
- }
47572
- b = buf[offset + 7];
47573
- res += (b & REST) * N7;
47574
- if (b < MSB) {
47575
- return res;
47576
- }
47577
- throw new RangeError("Could not decode varint");
47578
- }
47579
- function decodeUint8ArrayList(buf, offset) {
47580
- let b = buf.get(offset);
47581
- let res = 0;
47582
- res += b & REST;
47583
- if (b < MSB) {
47584
- return res;
47585
- }
47586
- b = buf.get(offset + 1);
47587
- res += (b & REST) << 7;
47588
- if (b < MSB) {
47589
- return res;
47590
- }
47591
- b = buf.get(offset + 2);
47592
- res += (b & REST) << 14;
47593
- if (b < MSB) {
47594
- return res;
47595
- }
47596
- b = buf.get(offset + 3);
47597
- res += (b & REST) << 21;
47598
- if (b < MSB) {
47599
- return res;
47600
- }
47601
- b = buf.get(offset + 4);
47602
- res += (b & REST) * N4;
47603
- if (b < MSB) {
47604
- return res;
47605
- }
47606
- b = buf.get(offset + 5);
47607
- res += (b & REST) * N5;
47608
- if (b < MSB) {
47609
- return res;
47610
- }
47611
- b = buf.get(offset + 6);
47612
- res += (b & REST) * N6;
47613
- if (b < MSB) {
47614
- return res;
47615
- }
47616
- b = buf.get(offset + 7);
47617
- res += (b & REST) * N7;
47618
- if (b < MSB) {
47619
- return res;
47620
- }
47621
- throw new RangeError("Could not decode varint");
47622
- }
47623
- function decode3(buf, offset = 0) {
47624
- if (buf instanceof Uint8Array) {
47625
- return decodeUint8Array(buf, offset);
47626
- } else {
47627
- return decodeUint8ArrayList(buf, offset);
47628
- }
47629
- }
47630
47443
 
47631
- // ../../node_modules/uint8arrays/dist/src/concat.node.js
47632
- import { Buffer as Buffer3 } from "buffer";
47633
- function concat2(arrays, length2) {
47634
- return asUint8Array(Buffer3.concat(arrays, length2));
47635
- }
47636
-
47637
- // ../../node_modules/uint8arrays/dist/src/from-string.node.js
47638
- import { Buffer as Buffer4 } from "buffer";
47639
-
47640
- // ../../node_modules/multiformats/dist/src/bases/base10.js
47641
- var base10_exports = {};
47642
- __export(base10_exports, {
47643
- base10: () => base10
47444
+ // ../../node_modules/multiformats/dist/src/bases/base32.js
47445
+ var base32_exports = {};
47446
+ __export(base32_exports, {
47447
+ base32: () => base32,
47448
+ base32hex: () => base32hex,
47449
+ base32hexpad: () => base32hexpad,
47450
+ base32hexpadupper: () => base32hexpadupper,
47451
+ base32hexupper: () => base32hexupper,
47452
+ base32pad: () => base32pad,
47453
+ base32padupper: () => base32padupper,
47454
+ base32upper: () => base32upper,
47455
+ base32z: () => base32z
47644
47456
  });
47645
47457
 
47646
47458
  // ../../node_modules/multiformats/dist/src/bytes.js
47647
47459
  var empty = new Uint8Array(0);
47648
- function equals2(aa, bb) {
47460
+ function equals(aa, bb) {
47649
47461
  if (aa === bb) {
47650
47462
  return true;
47651
47463
  }
@@ -47919,7 +47731,7 @@ function baseX({ name: name2, prefix, alphabet: alphabet2 }) {
47919
47731
  decode: (text) => coerce2(decode9(text))
47920
47732
  });
47921
47733
  }
47922
- function decode4(string2, alphabetIdx, bitsPerChar, name2) {
47734
+ function decode3(string2, alphabetIdx, bitsPerChar, name2) {
47923
47735
  let end = string2.length;
47924
47736
  while (string2[end - 1] === "=") {
47925
47737
  --end;
@@ -47985,143 +47797,47 @@ function rfc4648({ name: name2, prefix, bitsPerChar, alphabet: alphabet2 }) {
47985
47797
  return encode4(input, alphabet2, bitsPerChar);
47986
47798
  },
47987
47799
  decode(input) {
47988
- return decode4(input, alphabetIdx, bitsPerChar, name2);
47800
+ return decode3(input, alphabetIdx, bitsPerChar, name2);
47989
47801
  }
47990
47802
  });
47991
47803
  }
47992
47804
 
47993
- // ../../node_modules/multiformats/dist/src/bases/base10.js
47994
- var base10 = baseX({
47995
- prefix: "9",
47996
- name: "base10",
47997
- alphabet: "0123456789"
47998
- });
47999
-
48000
- // ../../node_modules/multiformats/dist/src/bases/base16.js
48001
- var base16_exports = {};
48002
- __export(base16_exports, {
48003
- base16: () => base16,
48004
- base16upper: () => base16upper
47805
+ // ../../node_modules/multiformats/dist/src/bases/base32.js
47806
+ var base32 = rfc4648({
47807
+ prefix: "b",
47808
+ name: "base32",
47809
+ alphabet: "abcdefghijklmnopqrstuvwxyz234567",
47810
+ bitsPerChar: 5
48005
47811
  });
48006
- var base16 = rfc4648({
48007
- prefix: "f",
48008
- name: "base16",
48009
- alphabet: "0123456789abcdef",
48010
- bitsPerChar: 4
47812
+ var base32upper = rfc4648({
47813
+ prefix: "B",
47814
+ name: "base32upper",
47815
+ alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",
47816
+ bitsPerChar: 5
48011
47817
  });
48012
- var base16upper = rfc4648({
48013
- prefix: "F",
48014
- name: "base16upper",
48015
- alphabet: "0123456789ABCDEF",
48016
- bitsPerChar: 4
47818
+ var base32pad = rfc4648({
47819
+ prefix: "c",
47820
+ name: "base32pad",
47821
+ alphabet: "abcdefghijklmnopqrstuvwxyz234567=",
47822
+ bitsPerChar: 5
48017
47823
  });
48018
-
48019
- // ../../node_modules/multiformats/dist/src/bases/base2.js
48020
- var base2_exports = {};
48021
- __export(base2_exports, {
48022
- base2: () => base22
47824
+ var base32padupper = rfc4648({
47825
+ prefix: "C",
47826
+ name: "base32padupper",
47827
+ alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",
47828
+ bitsPerChar: 5
48023
47829
  });
48024
- var base22 = rfc4648({
48025
- prefix: "0",
48026
- name: "base2",
48027
- alphabet: "01",
48028
- bitsPerChar: 1
47830
+ var base32hex = rfc4648({
47831
+ prefix: "v",
47832
+ name: "base32hex",
47833
+ alphabet: "0123456789abcdefghijklmnopqrstuv",
47834
+ bitsPerChar: 5
48029
47835
  });
48030
-
48031
- // ../../node_modules/multiformats/dist/src/bases/base256emoji.js
48032
- var base256emoji_exports = {};
48033
- __export(base256emoji_exports, {
48034
- base256emoji: () => base256emoji
48035
- });
48036
- var alphabet = Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}");
48037
- var alphabetBytesToChars = alphabet.reduce((p, c, i) => {
48038
- p[i] = c;
48039
- return p;
48040
- }, []);
48041
- var alphabetCharsToBytes = alphabet.reduce((p, c, i) => {
48042
- const codePoint = c.codePointAt(0);
48043
- if (codePoint == null) {
48044
- throw new Error(`Invalid character: ${c}`);
48045
- }
48046
- p[codePoint] = i;
48047
- return p;
48048
- }, []);
48049
- function encode5(data) {
48050
- return data.reduce((p, c) => {
48051
- p += alphabetBytesToChars[c];
48052
- return p;
48053
- }, "");
48054
- }
48055
- function decode5(str) {
48056
- const byts = [];
48057
- for (const char of str) {
48058
- const codePoint = char.codePointAt(0);
48059
- if (codePoint == null) {
48060
- throw new Error(`Invalid character: ${char}`);
48061
- }
48062
- const byt = alphabetCharsToBytes[codePoint];
48063
- if (byt == null) {
48064
- throw new Error(`Non-base256emoji character: ${char}`);
48065
- }
48066
- byts.push(byt);
48067
- }
48068
- return new Uint8Array(byts);
48069
- }
48070
- var base256emoji = from({
48071
- prefix: "\u{1F680}",
48072
- name: "base256emoji",
48073
- encode: encode5,
48074
- decode: decode5
48075
- });
48076
-
48077
- // ../../node_modules/multiformats/dist/src/bases/base32.js
48078
- var base32_exports = {};
48079
- __export(base32_exports, {
48080
- base32: () => base32,
48081
- base32hex: () => base32hex,
48082
- base32hexpad: () => base32hexpad,
48083
- base32hexpadupper: () => base32hexpadupper,
48084
- base32hexupper: () => base32hexupper,
48085
- base32pad: () => base32pad,
48086
- base32padupper: () => base32padupper,
48087
- base32upper: () => base32upper,
48088
- base32z: () => base32z
48089
- });
48090
- var base32 = rfc4648({
48091
- prefix: "b",
48092
- name: "base32",
48093
- alphabet: "abcdefghijklmnopqrstuvwxyz234567",
48094
- bitsPerChar: 5
48095
- });
48096
- var base32upper = rfc4648({
48097
- prefix: "B",
48098
- name: "base32upper",
48099
- alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",
48100
- bitsPerChar: 5
48101
- });
48102
- var base32pad = rfc4648({
48103
- prefix: "c",
48104
- name: "base32pad",
48105
- alphabet: "abcdefghijklmnopqrstuvwxyz234567=",
48106
- bitsPerChar: 5
48107
- });
48108
- var base32padupper = rfc4648({
48109
- prefix: "C",
48110
- name: "base32padupper",
48111
- alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",
48112
- bitsPerChar: 5
48113
- });
48114
- var base32hex = rfc4648({
48115
- prefix: "v",
48116
- name: "base32hex",
48117
- alphabet: "0123456789abcdefghijklmnopqrstuv",
48118
- bitsPerChar: 5
48119
- });
48120
- var base32hexupper = rfc4648({
48121
- prefix: "V",
48122
- name: "base32hexupper",
48123
- alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV",
48124
- bitsPerChar: 5
47836
+ var base32hexupper = rfc4648({
47837
+ prefix: "V",
47838
+ name: "base32hexupper",
47839
+ alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV",
47840
+ bitsPerChar: 5
48125
47841
  });
48126
47842
  var base32hexpad = rfc4648({
48127
47843
  prefix: "t",
@@ -48176,96 +47892,29 @@ var base58flickr = baseX({
48176
47892
  alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"
48177
47893
  });
48178
47894
 
48179
- // ../../node_modules/multiformats/dist/src/bases/base64.js
48180
- var base64_exports = {};
48181
- __export(base64_exports, {
48182
- base64: () => base64,
48183
- base64pad: () => base64pad,
48184
- base64url: () => base64url,
48185
- base64urlpad: () => base64urlpad
48186
- });
48187
- var base64 = rfc4648({
48188
- prefix: "m",
48189
- name: "base64",
48190
- alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
48191
- bitsPerChar: 6
48192
- });
48193
- var base64pad = rfc4648({
48194
- prefix: "M",
48195
- name: "base64pad",
48196
- alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
48197
- bitsPerChar: 6
48198
- });
48199
- var base64url = rfc4648({
48200
- prefix: "u",
48201
- name: "base64url",
48202
- alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",
48203
- bitsPerChar: 6
48204
- });
48205
- var base64urlpad = rfc4648({
48206
- prefix: "U",
48207
- name: "base64urlpad",
48208
- alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",
48209
- bitsPerChar: 6
48210
- });
48211
-
48212
- // ../../node_modules/multiformats/dist/src/bases/base8.js
48213
- var base8_exports = {};
48214
- __export(base8_exports, {
48215
- base8: () => base8
48216
- });
48217
- var base8 = rfc4648({
48218
- prefix: "7",
48219
- name: "base8",
48220
- alphabet: "01234567",
48221
- bitsPerChar: 3
48222
- });
48223
-
48224
- // ../../node_modules/multiformats/dist/src/bases/identity.js
48225
- var identity_exports = {};
48226
- __export(identity_exports, {
48227
- identity: () => identity
48228
- });
48229
- var identity = from({
48230
- prefix: "\0",
48231
- name: "identity",
48232
- encode: (buf) => toString(buf),
48233
- decode: (str) => fromString(str)
48234
- });
48235
-
48236
- // ../../node_modules/multiformats/dist/src/codecs/json.js
48237
- var textEncoder = new TextEncoder();
48238
- var textDecoder = new TextDecoder();
48239
-
48240
- // ../../node_modules/multiformats/dist/src/hashes/identity.js
48241
- var identity_exports2 = {};
48242
- __export(identity_exports2, {
48243
- identity: () => identity2
48244
- });
48245
-
48246
47895
  // ../../node_modules/multiformats/dist/src/vendor/varint.js
48247
- var encode_1 = encode6;
48248
- var MSB2 = 128;
48249
- var REST2 = 127;
48250
- var MSBALL = ~REST2;
47896
+ var encode_1 = encode5;
47897
+ var MSB = 128;
47898
+ var REST = 127;
47899
+ var MSBALL = ~REST;
48251
47900
  var INT = Math.pow(2, 31);
48252
- function encode6(num, out, offset) {
47901
+ function encode5(num, out, offset) {
48253
47902
  out = out || [];
48254
47903
  offset = offset || 0;
48255
47904
  var oldOffset = offset;
48256
47905
  while (num >= INT) {
48257
- out[offset++] = num & 255 | MSB2;
47906
+ out[offset++] = num & 255 | MSB;
48258
47907
  num /= 128;
48259
47908
  }
48260
47909
  while (num & MSBALL) {
48261
- out[offset++] = num & 255 | MSB2;
47910
+ out[offset++] = num & 255 | MSB;
48262
47911
  num >>>= 7;
48263
47912
  }
48264
47913
  out[offset] = num | 0;
48265
- encode6.bytes = offset - oldOffset + 1;
47914
+ encode5.bytes = offset - oldOffset + 1;
48266
47915
  return out;
48267
47916
  }
48268
- var decode6 = read;
47917
+ var decode4 = read;
48269
47918
  var MSB$1 = 128;
48270
47919
  var REST$1 = 127;
48271
47920
  function read(buf, offset) {
@@ -48282,28 +47931,28 @@ function read(buf, offset) {
48282
47931
  read.bytes = counter - offset;
48283
47932
  return res;
48284
47933
  }
48285
- var N12 = Math.pow(2, 7);
48286
- var N22 = Math.pow(2, 14);
48287
- var N32 = Math.pow(2, 21);
48288
- var N42 = Math.pow(2, 28);
48289
- var N52 = Math.pow(2, 35);
48290
- var N62 = Math.pow(2, 42);
48291
- var N72 = Math.pow(2, 49);
47934
+ var N1 = Math.pow(2, 7);
47935
+ var N2 = Math.pow(2, 14);
47936
+ var N3 = Math.pow(2, 21);
47937
+ var N4 = Math.pow(2, 28);
47938
+ var N5 = Math.pow(2, 35);
47939
+ var N6 = Math.pow(2, 42);
47940
+ var N7 = Math.pow(2, 49);
48292
47941
  var N8 = Math.pow(2, 56);
48293
47942
  var N9 = Math.pow(2, 63);
48294
47943
  var length = function(value) {
48295
- return value < N12 ? 1 : value < N22 ? 2 : value < N32 ? 3 : value < N42 ? 4 : value < N52 ? 5 : value < N62 ? 6 : value < N72 ? 7 : value < N8 ? 8 : value < N9 ? 9 : 10;
47944
+ return value < N1 ? 1 : value < N2 ? 2 : value < N3 ? 3 : value < N4 ? 4 : value < N5 ? 5 : value < N6 ? 6 : value < N7 ? 7 : value < N8 ? 8 : value < N9 ? 9 : 10;
48296
47945
  };
48297
47946
  var varint = {
48298
47947
  encode: encode_1,
48299
- decode: decode6,
47948
+ decode: decode4,
48300
47949
  encodingLength: length
48301
47950
  };
48302
47951
  var _brrp_varint = varint;
48303
47952
  var varint_default = _brrp_varint;
48304
47953
 
48305
47954
  // ../../node_modules/multiformats/dist/src/varint.js
48306
- function decode7(data, offset = 0) {
47955
+ function decode5(data, offset = 0) {
48307
47956
  const code2 = varint_default.decode(data, offset);
48308
47957
  return [code2, varint_default.decode.bytes];
48309
47958
  }
@@ -48311,37 +47960,37 @@ function encodeTo(int, target, offset = 0) {
48311
47960
  varint_default.encode(int, target, offset);
48312
47961
  return target;
48313
47962
  }
48314
- function encodingLength2(int) {
47963
+ function encodingLength(int) {
48315
47964
  return varint_default.encodingLength(int);
48316
47965
  }
48317
47966
 
48318
47967
  // ../../node_modules/multiformats/dist/src/hashes/digest.js
48319
47968
  function create(code2, digest2) {
48320
47969
  const size = digest2.byteLength;
48321
- const sizeOffset = encodingLength2(code2);
48322
- const digestOffset = sizeOffset + encodingLength2(size);
47970
+ const sizeOffset = encodingLength(code2);
47971
+ const digestOffset = sizeOffset + encodingLength(size);
48323
47972
  const bytes = new Uint8Array(digestOffset + size);
48324
47973
  encodeTo(code2, bytes, 0);
48325
47974
  encodeTo(size, bytes, sizeOffset);
48326
47975
  bytes.set(digest2, digestOffset);
48327
47976
  return new Digest(code2, size, digest2, bytes);
48328
47977
  }
48329
- function decode8(multihash) {
47978
+ function decode6(multihash) {
48330
47979
  const bytes = coerce2(multihash);
48331
- const [code2, sizeOffset] = decode7(bytes);
48332
- const [size, digestOffset] = decode7(bytes.subarray(sizeOffset));
47980
+ const [code2, sizeOffset] = decode5(bytes);
47981
+ const [size, digestOffset] = decode5(bytes.subarray(sizeOffset));
48333
47982
  const digest2 = bytes.subarray(sizeOffset + digestOffset);
48334
47983
  if (digest2.byteLength !== size) {
48335
47984
  throw new Error("Incorrect length");
48336
47985
  }
48337
47986
  return new Digest(code2, size, digest2, bytes);
48338
47987
  }
48339
- function equals3(a, b) {
47988
+ function equals2(a, b) {
48340
47989
  if (a === b) {
48341
47990
  return true;
48342
47991
  } else {
48343
47992
  const data = b;
48344
- return a.code === data.code && a.size === data.size && data.bytes instanceof Uint8Array && equals2(a.bytes, data.bytes);
47993
+ return a.code === data.code && a.size === data.size && data.bytes instanceof Uint8Array && equals(a.bytes, data.bytes);
48345
47994
  }
48346
47995
  }
48347
47996
  var Digest = class {
@@ -48360,89 +48009,6 @@ var Digest = class {
48360
48009
  }
48361
48010
  };
48362
48011
 
48363
- // ../../node_modules/multiformats/dist/src/hashes/identity.js
48364
- var code = 0;
48365
- var name = "identity";
48366
- var encode7 = coerce2;
48367
- function digest(input, options) {
48368
- if (options?.truncate != null && options.truncate !== input.byteLength) {
48369
- if (options.truncate < 0 || options.truncate > input.byteLength) {
48370
- throw new Error(`Invalid truncate option, must be less than or equal to ${input.byteLength}`);
48371
- }
48372
- input = input.subarray(0, options.truncate);
48373
- }
48374
- return create(code, encode7(input));
48375
- }
48376
- var identity2 = { code, name, encode: encode7, digest };
48377
-
48378
- // ../../node_modules/multiformats/dist/src/hashes/sha2.js
48379
- var sha2_exports = {};
48380
- __export(sha2_exports, {
48381
- sha256: () => sha2563,
48382
- sha512: () => sha5122
48383
- });
48384
- import crypto3 from "crypto";
48385
-
48386
- // ../../node_modules/multiformats/dist/src/hashes/hasher.js
48387
- var DEFAULT_MIN_DIGEST_LENGTH = 20;
48388
- function from2({ name: name2, code: code2, encode: encode8, minDigestLength, maxDigestLength }) {
48389
- return new Hasher(name2, code2, encode8, minDigestLength, maxDigestLength);
48390
- }
48391
- var Hasher = class {
48392
- name;
48393
- code;
48394
- encode;
48395
- minDigestLength;
48396
- maxDigestLength;
48397
- constructor(name2, code2, encode8, minDigestLength, maxDigestLength) {
48398
- this.name = name2;
48399
- this.code = code2;
48400
- this.encode = encode8;
48401
- this.minDigestLength = minDigestLength ?? DEFAULT_MIN_DIGEST_LENGTH;
48402
- this.maxDigestLength = maxDigestLength;
48403
- }
48404
- digest(input, options) {
48405
- if (options?.truncate != null) {
48406
- if (options.truncate < this.minDigestLength) {
48407
- throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);
48408
- }
48409
- if (this.maxDigestLength != null && options.truncate > this.maxDigestLength) {
48410
- throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`);
48411
- }
48412
- }
48413
- if (input instanceof Uint8Array) {
48414
- const result = this.encode(input);
48415
- if (result instanceof Uint8Array) {
48416
- return createDigest(result, this.code, options?.truncate);
48417
- }
48418
- return result.then((digest2) => createDigest(digest2, this.code, options?.truncate));
48419
- } else {
48420
- throw Error("Unknown type, must be binary type");
48421
- }
48422
- }
48423
- };
48424
- function createDigest(digest2, code2, truncate) {
48425
- if (truncate != null && truncate !== digest2.byteLength) {
48426
- if (truncate > digest2.byteLength) {
48427
- throw new Error(`Invalid truncate option, must be less than or equal to ${digest2.byteLength}`);
48428
- }
48429
- digest2 = digest2.subarray(0, truncate);
48430
- }
48431
- return create(code2, digest2);
48432
- }
48433
-
48434
- // ../../node_modules/multiformats/dist/src/hashes/sha2.js
48435
- var sha2563 = from2({
48436
- name: "sha2-256",
48437
- code: 18,
48438
- encode: (input) => coerce2(crypto3.createHash("sha256").update(input).digest())
48439
- });
48440
- var sha5122 = from2({
48441
- name: "sha2-512",
48442
- code: 19,
48443
- encode: (input) => coerce2(crypto3.createHash("sha512").update(input).digest())
48444
- });
48445
-
48446
48012
  // ../../node_modules/multiformats/dist/src/cid.js
48447
48013
  function format(link, base3) {
48448
48014
  const { bytes, version: version28 } = link;
@@ -48538,7 +48104,7 @@ var CID = class _CID {
48538
48104
  }
48539
48105
  static equals(self2, other) {
48540
48106
  const unknown = other;
48541
- return unknown != null && self2.code === unknown.code && self2.version === unknown.version && equals3(self2.multihash, unknown.multihash);
48107
+ return unknown != null && self2.code === unknown.code && self2.version === unknown.version && equals2(self2.multihash, unknown.multihash);
48542
48108
  }
48543
48109
  toString(base3) {
48544
48110
  return format(this, base3);
@@ -48576,7 +48142,7 @@ var CID = class _CID {
48576
48142
  return new _CID(version28, code2, multihash, bytes ?? encodeCID(version28, code2, multihash.bytes));
48577
48143
  } else if (value[cidSymbol] === true) {
48578
48144
  const { version: version28, multihash, code: code2 } = value;
48579
- const digest2 = decode8(multihash);
48145
+ const digest2 = decode6(multihash);
48580
48146
  return _CID.create(version28, code2, digest2);
48581
48147
  } else {
48582
48148
  return null;
@@ -48626,162 +48192,612 @@ var CID = class _CID {
48626
48192
  static createV1(code2, digest2) {
48627
48193
  return _CID.create(1, code2, digest2);
48628
48194
  }
48629
- /**
48630
- * Decoded a CID from its binary representation. The byte array must contain
48631
- * only the CID with no additional bytes.
48632
- *
48633
- * An error will be thrown if the bytes provided do not contain a valid
48634
- * binary representation of a CID.
48635
- */
48636
- static decode(bytes) {
48637
- const [cid, remainder] = _CID.decodeFirst(bytes);
48638
- if (remainder.length !== 0) {
48639
- throw new Error("Incorrect length");
48640
- }
48641
- return cid;
48195
+ /**
48196
+ * Decoded a CID from its binary representation. The byte array must contain
48197
+ * only the CID with no additional bytes.
48198
+ *
48199
+ * An error will be thrown if the bytes provided do not contain a valid
48200
+ * binary representation of a CID.
48201
+ */
48202
+ static decode(bytes) {
48203
+ const [cid, remainder] = _CID.decodeFirst(bytes);
48204
+ if (remainder.length !== 0) {
48205
+ throw new Error("Incorrect length");
48206
+ }
48207
+ return cid;
48208
+ }
48209
+ /**
48210
+ * Decoded a CID from its binary representation at the beginning of a byte
48211
+ * array.
48212
+ *
48213
+ * Returns an array with the first element containing the CID and the second
48214
+ * element containing the remainder of the original byte array. The remainder
48215
+ * will be a zero-length byte array if the provided bytes only contained a
48216
+ * binary CID representation.
48217
+ */
48218
+ static decodeFirst(bytes) {
48219
+ const specs = _CID.inspectBytes(bytes);
48220
+ const prefixSize = specs.size - specs.multihashSize;
48221
+ const multihashBytes = coerce2(bytes.subarray(prefixSize, prefixSize + specs.multihashSize));
48222
+ if (multihashBytes.byteLength !== specs.multihashSize) {
48223
+ throw new Error("Incorrect length");
48224
+ }
48225
+ const digestBytes = multihashBytes.subarray(specs.multihashSize - specs.digestSize);
48226
+ const digest2 = new Digest(specs.multihashCode, specs.digestSize, digestBytes, multihashBytes);
48227
+ const cid = specs.version === 0 ? _CID.createV0(digest2) : _CID.createV1(specs.codec, digest2);
48228
+ return [cid, bytes.subarray(specs.size)];
48229
+ }
48230
+ /**
48231
+ * Inspect the initial bytes of a CID to determine its properties.
48232
+ *
48233
+ * Involves decoding up to 4 varints. Typically this will require only 4 to 6
48234
+ * bytes but for larger multicodec code values and larger multihash digest
48235
+ * lengths these varints can be quite large. It is recommended that at least
48236
+ * 10 bytes be made available in the `initialBytes` argument for a complete
48237
+ * inspection.
48238
+ */
48239
+ static inspectBytes(initialBytes) {
48240
+ let offset = 0;
48241
+ const next = () => {
48242
+ const [i, length2] = decode5(initialBytes.subarray(offset));
48243
+ offset += length2;
48244
+ return i;
48245
+ };
48246
+ let version28 = next();
48247
+ let codec = DAG_PB_CODE;
48248
+ if (version28 === 18) {
48249
+ version28 = 0;
48250
+ offset = 0;
48251
+ } else {
48252
+ codec = next();
48253
+ }
48254
+ if (version28 !== 0 && version28 !== 1) {
48255
+ throw new RangeError(`Invalid CID version ${version28}`);
48256
+ }
48257
+ const prefixSize = offset;
48258
+ const multihashCode = next();
48259
+ const digestSize = next();
48260
+ const size = offset + digestSize;
48261
+ const multihashSize = size - prefixSize;
48262
+ return { version: version28, codec, multihashCode, digestSize, multihashSize, size };
48263
+ }
48264
+ /**
48265
+ * Takes cid in a string representation and creates an instance. If `base`
48266
+ * decoder is not provided will use a default from the configuration. It will
48267
+ * throw an error if encoding of the CID is not compatible with supplied (or
48268
+ * a default decoder).
48269
+ */
48270
+ static parse(source, base3) {
48271
+ const [prefix, bytes] = parseCIDtoBytes(source, base3);
48272
+ const cid = _CID.decode(bytes);
48273
+ if (cid.version === 0 && source[0] !== "Q") {
48274
+ throw Error("Version 0 CID string must not include multibase prefix");
48275
+ }
48276
+ baseCache(cid).set(prefix, source);
48277
+ return cid;
48278
+ }
48279
+ };
48280
+ function parseCIDtoBytes(source, base3) {
48281
+ switch (source[0]) {
48282
+ // CIDv0 is parsed differently
48283
+ case "Q": {
48284
+ const decoder = base3 ?? base58btc;
48285
+ return [
48286
+ base58btc.prefix,
48287
+ decoder.decode(`${base58btc.prefix}${source}`)
48288
+ ];
48289
+ }
48290
+ case base58btc.prefix: {
48291
+ const decoder = base3 ?? base58btc;
48292
+ return [base58btc.prefix, decoder.decode(source)];
48293
+ }
48294
+ case base32.prefix: {
48295
+ const decoder = base3 ?? base32;
48296
+ return [base32.prefix, decoder.decode(source)];
48297
+ }
48298
+ case base36.prefix: {
48299
+ const decoder = base3 ?? base36;
48300
+ return [base36.prefix, decoder.decode(source)];
48301
+ }
48302
+ default: {
48303
+ if (base3 == null) {
48304
+ throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");
48305
+ }
48306
+ return [source[0], base3.decode(source)];
48307
+ }
48308
+ }
48309
+ }
48310
+ function toStringV0(bytes, cache2, base3) {
48311
+ const { prefix } = base3;
48312
+ if (prefix !== base58btc.prefix) {
48313
+ throw Error(`Cannot string encode V0 in ${base3.name} encoding`);
48314
+ }
48315
+ const cid = cache2.get(prefix);
48316
+ if (cid == null) {
48317
+ const cid2 = base3.encode(bytes).slice(1);
48318
+ cache2.set(prefix, cid2);
48319
+ return cid2;
48320
+ } else {
48321
+ return cid;
48322
+ }
48323
+ }
48324
+ function toStringV1(bytes, cache2, base3) {
48325
+ const { prefix } = base3;
48326
+ const cid = cache2.get(prefix);
48327
+ if (cid == null) {
48328
+ const cid2 = base3.encode(bytes);
48329
+ cache2.set(prefix, cid2);
48330
+ return cid2;
48331
+ } else {
48332
+ return cid;
48333
+ }
48334
+ }
48335
+ var DAG_PB_CODE = 112;
48336
+ var SHA_256_CODE = 18;
48337
+ function encodeCID(version28, code2, multihash) {
48338
+ const codeOffset = encodingLength(version28);
48339
+ const hashOffset = codeOffset + encodingLength(code2);
48340
+ const bytes = new Uint8Array(hashOffset + multihash.byteLength);
48341
+ encodeTo(version28, bytes, 0);
48342
+ encodeTo(code2, bytes, codeOffset);
48343
+ bytes.set(multihash, hashOffset);
48344
+ return bytes;
48345
+ }
48346
+ var cidSymbol = /* @__PURE__ */ Symbol.for("@ipld/js-cid/CID");
48347
+
48348
+ // ../../node_modules/multiformats/dist/src/bases/base10.js
48349
+ var base10_exports = {};
48350
+ __export(base10_exports, {
48351
+ base10: () => base10
48352
+ });
48353
+ var base10 = baseX({
48354
+ prefix: "9",
48355
+ name: "base10",
48356
+ alphabet: "0123456789"
48357
+ });
48358
+
48359
+ // ../../node_modules/multiformats/dist/src/bases/base16.js
48360
+ var base16_exports = {};
48361
+ __export(base16_exports, {
48362
+ base16: () => base16,
48363
+ base16upper: () => base16upper
48364
+ });
48365
+ var base16 = rfc4648({
48366
+ prefix: "f",
48367
+ name: "base16",
48368
+ alphabet: "0123456789abcdef",
48369
+ bitsPerChar: 4
48370
+ });
48371
+ var base16upper = rfc4648({
48372
+ prefix: "F",
48373
+ name: "base16upper",
48374
+ alphabet: "0123456789ABCDEF",
48375
+ bitsPerChar: 4
48376
+ });
48377
+
48378
+ // ../../node_modules/multiformats/dist/src/bases/base2.js
48379
+ var base2_exports = {};
48380
+ __export(base2_exports, {
48381
+ base2: () => base22
48382
+ });
48383
+ var base22 = rfc4648({
48384
+ prefix: "0",
48385
+ name: "base2",
48386
+ alphabet: "01",
48387
+ bitsPerChar: 1
48388
+ });
48389
+
48390
+ // ../../node_modules/multiformats/dist/src/bases/base256emoji.js
48391
+ var base256emoji_exports = {};
48392
+ __export(base256emoji_exports, {
48393
+ base256emoji: () => base256emoji
48394
+ });
48395
+ var alphabet = Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}");
48396
+ var alphabetBytesToChars = alphabet.reduce((p, c, i) => {
48397
+ p[i] = c;
48398
+ return p;
48399
+ }, []);
48400
+ var alphabetCharsToBytes = alphabet.reduce((p, c, i) => {
48401
+ const codePoint = c.codePointAt(0);
48402
+ if (codePoint == null) {
48403
+ throw new Error(`Invalid character: ${c}`);
48404
+ }
48405
+ p[codePoint] = i;
48406
+ return p;
48407
+ }, []);
48408
+ function encode6(data) {
48409
+ return data.reduce((p, c) => {
48410
+ p += alphabetBytesToChars[c];
48411
+ return p;
48412
+ }, "");
48413
+ }
48414
+ function decode7(str) {
48415
+ const byts = [];
48416
+ for (const char of str) {
48417
+ const codePoint = char.codePointAt(0);
48418
+ if (codePoint == null) {
48419
+ throw new Error(`Invalid character: ${char}`);
48420
+ }
48421
+ const byt = alphabetCharsToBytes[codePoint];
48422
+ if (byt == null) {
48423
+ throw new Error(`Non-base256emoji character: ${char}`);
48424
+ }
48425
+ byts.push(byt);
48426
+ }
48427
+ return new Uint8Array(byts);
48428
+ }
48429
+ var base256emoji = from({
48430
+ prefix: "\u{1F680}",
48431
+ name: "base256emoji",
48432
+ encode: encode6,
48433
+ decode: decode7
48434
+ });
48435
+
48436
+ // ../../node_modules/multiformats/dist/src/bases/base64.js
48437
+ var base64_exports = {};
48438
+ __export(base64_exports, {
48439
+ base64: () => base64,
48440
+ base64pad: () => base64pad,
48441
+ base64url: () => base64url,
48442
+ base64urlpad: () => base64urlpad
48443
+ });
48444
+ var base64 = rfc4648({
48445
+ prefix: "m",
48446
+ name: "base64",
48447
+ alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
48448
+ bitsPerChar: 6
48449
+ });
48450
+ var base64pad = rfc4648({
48451
+ prefix: "M",
48452
+ name: "base64pad",
48453
+ alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
48454
+ bitsPerChar: 6
48455
+ });
48456
+ var base64url = rfc4648({
48457
+ prefix: "u",
48458
+ name: "base64url",
48459
+ alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",
48460
+ bitsPerChar: 6
48461
+ });
48462
+ var base64urlpad = rfc4648({
48463
+ prefix: "U",
48464
+ name: "base64urlpad",
48465
+ alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",
48466
+ bitsPerChar: 6
48467
+ });
48468
+
48469
+ // ../../node_modules/multiformats/dist/src/bases/base8.js
48470
+ var base8_exports = {};
48471
+ __export(base8_exports, {
48472
+ base8: () => base8
48473
+ });
48474
+ var base8 = rfc4648({
48475
+ prefix: "7",
48476
+ name: "base8",
48477
+ alphabet: "01234567",
48478
+ bitsPerChar: 3
48479
+ });
48480
+
48481
+ // ../../node_modules/multiformats/dist/src/bases/identity.js
48482
+ var identity_exports = {};
48483
+ __export(identity_exports, {
48484
+ identity: () => identity
48485
+ });
48486
+ var identity = from({
48487
+ prefix: "\0",
48488
+ name: "identity",
48489
+ encode: (buf) => toString(buf),
48490
+ decode: (str) => fromString(str)
48491
+ });
48492
+
48493
+ // ../../node_modules/multiformats/dist/src/codecs/json.js
48494
+ var textEncoder = new TextEncoder();
48495
+ var textDecoder = new TextDecoder();
48496
+
48497
+ // ../../node_modules/multiformats/dist/src/hashes/identity.js
48498
+ var identity_exports2 = {};
48499
+ __export(identity_exports2, {
48500
+ identity: () => identity2
48501
+ });
48502
+ var code = 0;
48503
+ var name = "identity";
48504
+ var encode7 = coerce2;
48505
+ function digest(input, options) {
48506
+ if (options?.truncate != null && options.truncate !== input.byteLength) {
48507
+ if (options.truncate < 0 || options.truncate > input.byteLength) {
48508
+ throw new Error(`Invalid truncate option, must be less than or equal to ${input.byteLength}`);
48509
+ }
48510
+ input = input.subarray(0, options.truncate);
48511
+ }
48512
+ return create(code, encode7(input));
48513
+ }
48514
+ var identity2 = { code, name, encode: encode7, digest };
48515
+
48516
+ // ../../node_modules/multiformats/dist/src/hashes/sha2.js
48517
+ var sha2_exports = {};
48518
+ __export(sha2_exports, {
48519
+ sha256: () => sha2563,
48520
+ sha512: () => sha5122
48521
+ });
48522
+ import crypto3 from "crypto";
48523
+
48524
+ // ../../node_modules/multiformats/dist/src/hashes/hasher.js
48525
+ var DEFAULT_MIN_DIGEST_LENGTH = 20;
48526
+ function from2({ name: name2, code: code2, encode: encode8, minDigestLength, maxDigestLength }) {
48527
+ return new Hasher(name2, code2, encode8, minDigestLength, maxDigestLength);
48528
+ }
48529
+ var Hasher = class {
48530
+ name;
48531
+ code;
48532
+ encode;
48533
+ minDigestLength;
48534
+ maxDigestLength;
48535
+ constructor(name2, code2, encode8, minDigestLength, maxDigestLength) {
48536
+ this.name = name2;
48537
+ this.code = code2;
48538
+ this.encode = encode8;
48539
+ this.minDigestLength = minDigestLength ?? DEFAULT_MIN_DIGEST_LENGTH;
48540
+ this.maxDigestLength = maxDigestLength;
48541
+ }
48542
+ digest(input, options) {
48543
+ if (options?.truncate != null) {
48544
+ if (options.truncate < this.minDigestLength) {
48545
+ throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);
48546
+ }
48547
+ if (this.maxDigestLength != null && options.truncate > this.maxDigestLength) {
48548
+ throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`);
48549
+ }
48550
+ }
48551
+ if (input instanceof Uint8Array) {
48552
+ const result = this.encode(input);
48553
+ if (result instanceof Uint8Array) {
48554
+ return createDigest(result, this.code, options?.truncate);
48555
+ }
48556
+ return result.then((digest2) => createDigest(digest2, this.code, options?.truncate));
48557
+ } else {
48558
+ throw Error("Unknown type, must be binary type");
48559
+ }
48560
+ }
48561
+ };
48562
+ function createDigest(digest2, code2, truncate) {
48563
+ if (truncate != null && truncate !== digest2.byteLength) {
48564
+ if (truncate > digest2.byteLength) {
48565
+ throw new Error(`Invalid truncate option, must be less than or equal to ${digest2.byteLength}`);
48566
+ }
48567
+ digest2 = digest2.subarray(0, truncate);
48568
+ }
48569
+ return create(code2, digest2);
48570
+ }
48571
+
48572
+ // ../../node_modules/multiformats/dist/src/hashes/sha2.js
48573
+ var sha2563 = from2({
48574
+ name: "sha2-256",
48575
+ code: 18,
48576
+ encode: (input) => coerce2(crypto3.createHash("sha256").update(input).digest())
48577
+ });
48578
+ var sha5122 = from2({
48579
+ name: "sha2-512",
48580
+ code: 19,
48581
+ encode: (input) => coerce2(crypto3.createHash("sha512").update(input).digest())
48582
+ });
48583
+
48584
+ // ../../node_modules/multiformats/dist/src/basics.js
48585
+ var bases = { ...identity_exports, ...base2_exports, ...base8_exports, ...base10_exports, ...base16_exports, ...base32_exports, ...base36_exports, ...base58_exports, ...base64_exports, ...base256emoji_exports };
48586
+ var hashes = { ...sha2_exports, ...identity_exports2 };
48587
+
48588
+ // ../sdk-core/dist/index.js
48589
+ var import_ms2 = __toESM(require_ms(), 1);
48590
+
48591
+ // ../../node_modules/uint8arrays/dist/src/equals.js
48592
+ function equals3(a, b) {
48593
+ if (a === b) {
48594
+ return true;
48595
+ }
48596
+ if (a.byteLength !== b.byteLength) {
48597
+ return false;
48598
+ }
48599
+ for (let i = 0; i < a.byteLength; i++) {
48600
+ if (a[i] !== b[i]) {
48601
+ return false;
48602
+ }
48603
+ }
48604
+ return true;
48605
+ }
48606
+
48607
+ // ../../node_modules/uint8arrays/dist/src/alloc.node.js
48608
+ import { Buffer as Buffer2 } from "buffer";
48609
+
48610
+ // ../../node_modules/uint8arrays/dist/src/util/as-uint8array.node.js
48611
+ function asUint8Array(buf) {
48612
+ return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
48613
+ }
48614
+
48615
+ // ../../node_modules/uint8arrays/dist/src/alloc.node.js
48616
+ function allocUnsafe(size = 0) {
48617
+ return asUint8Array(Buffer2.allocUnsafe(size));
48618
+ }
48619
+
48620
+ // ../../node_modules/uint8-varint/dist/src/index.js
48621
+ var N12 = Math.pow(2, 7);
48622
+ var N22 = Math.pow(2, 14);
48623
+ var N32 = Math.pow(2, 21);
48624
+ var N42 = Math.pow(2, 28);
48625
+ var N52 = Math.pow(2, 35);
48626
+ var N62 = Math.pow(2, 42);
48627
+ var N72 = Math.pow(2, 49);
48628
+ var MSB2 = 128;
48629
+ var REST2 = 127;
48630
+ function encodingLength2(value) {
48631
+ if (value < N12) {
48632
+ return 1;
48633
+ }
48634
+ if (value < N22) {
48635
+ return 2;
48636
+ }
48637
+ if (value < N32) {
48638
+ return 3;
48639
+ }
48640
+ if (value < N42) {
48641
+ return 4;
48642
+ }
48643
+ if (value < N52) {
48644
+ return 5;
48642
48645
  }
48643
- /**
48644
- * Decoded a CID from its binary representation at the beginning of a byte
48645
- * array.
48646
- *
48647
- * Returns an array with the first element containing the CID and the second
48648
- * element containing the remainder of the original byte array. The remainder
48649
- * will be a zero-length byte array if the provided bytes only contained a
48650
- * binary CID representation.
48651
- */
48652
- static decodeFirst(bytes) {
48653
- const specs = _CID.inspectBytes(bytes);
48654
- const prefixSize = specs.size - specs.multihashSize;
48655
- const multihashBytes = coerce2(bytes.subarray(prefixSize, prefixSize + specs.multihashSize));
48656
- if (multihashBytes.byteLength !== specs.multihashSize) {
48657
- throw new Error("Incorrect length");
48658
- }
48659
- const digestBytes = multihashBytes.subarray(specs.multihashSize - specs.digestSize);
48660
- const digest2 = new Digest(specs.multihashCode, specs.digestSize, digestBytes, multihashBytes);
48661
- const cid = specs.version === 0 ? _CID.createV0(digest2) : _CID.createV1(specs.codec, digest2);
48662
- return [cid, bytes.subarray(specs.size)];
48646
+ if (value < N62) {
48647
+ return 6;
48663
48648
  }
48664
- /**
48665
- * Inspect the initial bytes of a CID to determine its properties.
48666
- *
48667
- * Involves decoding up to 4 varints. Typically this will require only 4 to 6
48668
- * bytes but for larger multicodec code values and larger multihash digest
48669
- * lengths these varints can be quite large. It is recommended that at least
48670
- * 10 bytes be made available in the `initialBytes` argument for a complete
48671
- * inspection.
48672
- */
48673
- static inspectBytes(initialBytes) {
48674
- let offset = 0;
48675
- const next = () => {
48676
- const [i, length2] = decode7(initialBytes.subarray(offset));
48677
- offset += length2;
48678
- return i;
48679
- };
48680
- let version28 = next();
48681
- let codec = DAG_PB_CODE;
48682
- if (version28 === 18) {
48683
- version28 = 0;
48684
- offset = 0;
48685
- } else {
48686
- codec = next();
48649
+ if (value < N72) {
48650
+ return 7;
48651
+ }
48652
+ if (Number.MAX_SAFE_INTEGER != null && value > Number.MAX_SAFE_INTEGER) {
48653
+ throw new RangeError("Could not encode varint");
48654
+ }
48655
+ return 8;
48656
+ }
48657
+ function encodeUint8Array(value, buf, offset = 0) {
48658
+ switch (encodingLength2(value)) {
48659
+ case 8: {
48660
+ buf[offset++] = value & 255 | MSB2;
48661
+ value /= 128;
48687
48662
  }
48688
- if (version28 !== 0 && version28 !== 1) {
48689
- throw new RangeError(`Invalid CID version ${version28}`);
48663
+ case 7: {
48664
+ buf[offset++] = value & 255 | MSB2;
48665
+ value /= 128;
48690
48666
  }
48691
- const prefixSize = offset;
48692
- const multihashCode = next();
48693
- const digestSize = next();
48694
- const size = offset + digestSize;
48695
- const multihashSize = size - prefixSize;
48696
- return { version: version28, codec, multihashCode, digestSize, multihashSize, size };
48697
- }
48698
- /**
48699
- * Takes cid in a string representation and creates an instance. If `base`
48700
- * decoder is not provided will use a default from the configuration. It will
48701
- * throw an error if encoding of the CID is not compatible with supplied (or
48702
- * a default decoder).
48703
- */
48704
- static parse(source, base3) {
48705
- const [prefix, bytes] = parseCIDtoBytes(source, base3);
48706
- const cid = _CID.decode(bytes);
48707
- if (cid.version === 0 && source[0] !== "Q") {
48708
- throw Error("Version 0 CID string must not include multibase prefix");
48667
+ case 6: {
48668
+ buf[offset++] = value & 255 | MSB2;
48669
+ value /= 128;
48709
48670
  }
48710
- baseCache(cid).set(prefix, source);
48711
- return cid;
48712
- }
48713
- };
48714
- function parseCIDtoBytes(source, base3) {
48715
- switch (source[0]) {
48716
- // CIDv0 is parsed differently
48717
- case "Q": {
48718
- const decoder = base3 ?? base58btc;
48719
- return [
48720
- base58btc.prefix,
48721
- decoder.decode(`${base58btc.prefix}${source}`)
48722
- ];
48671
+ case 5: {
48672
+ buf[offset++] = value & 255 | MSB2;
48673
+ value /= 128;
48723
48674
  }
48724
- case base58btc.prefix: {
48725
- const decoder = base3 ?? base58btc;
48726
- return [base58btc.prefix, decoder.decode(source)];
48675
+ case 4: {
48676
+ buf[offset++] = value & 255 | MSB2;
48677
+ value >>>= 7;
48727
48678
  }
48728
- case base32.prefix: {
48729
- const decoder = base3 ?? base32;
48730
- return [base32.prefix, decoder.decode(source)];
48679
+ case 3: {
48680
+ buf[offset++] = value & 255 | MSB2;
48681
+ value >>>= 7;
48731
48682
  }
48732
- case base36.prefix: {
48733
- const decoder = base3 ?? base36;
48734
- return [base36.prefix, decoder.decode(source)];
48683
+ case 2: {
48684
+ buf[offset++] = value & 255 | MSB2;
48685
+ value >>>= 7;
48735
48686
  }
48736
- default: {
48737
- if (base3 == null) {
48738
- throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");
48739
- }
48740
- return [source[0], base3.decode(source)];
48687
+ case 1: {
48688
+ buf[offset++] = value & 255;
48689
+ value >>>= 7;
48690
+ break;
48741
48691
  }
48692
+ default:
48693
+ throw new Error("unreachable");
48742
48694
  }
48695
+ return buf;
48743
48696
  }
48744
- function toStringV0(bytes, cache2, base3) {
48745
- const { prefix } = base3;
48746
- if (prefix !== base58btc.prefix) {
48747
- throw Error(`Cannot string encode V0 in ${base3.name} encoding`);
48697
+ function decodeUint8Array(buf, offset) {
48698
+ let b = buf[offset];
48699
+ let res = 0;
48700
+ res += b & REST2;
48701
+ if (b < MSB2) {
48702
+ return res;
48748
48703
  }
48749
- const cid = cache2.get(prefix);
48750
- if (cid == null) {
48751
- const cid2 = base3.encode(bytes).slice(1);
48752
- cache2.set(prefix, cid2);
48753
- return cid2;
48754
- } else {
48755
- return cid;
48704
+ b = buf[offset + 1];
48705
+ res += (b & REST2) << 7;
48706
+ if (b < MSB2) {
48707
+ return res;
48708
+ }
48709
+ b = buf[offset + 2];
48710
+ res += (b & REST2) << 14;
48711
+ if (b < MSB2) {
48712
+ return res;
48713
+ }
48714
+ b = buf[offset + 3];
48715
+ res += (b & REST2) << 21;
48716
+ if (b < MSB2) {
48717
+ return res;
48718
+ }
48719
+ b = buf[offset + 4];
48720
+ res += (b & REST2) * N42;
48721
+ if (b < MSB2) {
48722
+ return res;
48723
+ }
48724
+ b = buf[offset + 5];
48725
+ res += (b & REST2) * N52;
48726
+ if (b < MSB2) {
48727
+ return res;
48728
+ }
48729
+ b = buf[offset + 6];
48730
+ res += (b & REST2) * N62;
48731
+ if (b < MSB2) {
48732
+ return res;
48733
+ }
48734
+ b = buf[offset + 7];
48735
+ res += (b & REST2) * N72;
48736
+ if (b < MSB2) {
48737
+ return res;
48756
48738
  }
48739
+ throw new RangeError("Could not decode varint");
48757
48740
  }
48758
- function toStringV1(bytes, cache2, base3) {
48759
- const { prefix } = base3;
48760
- const cid = cache2.get(prefix);
48761
- if (cid == null) {
48762
- const cid2 = base3.encode(bytes);
48763
- cache2.set(prefix, cid2);
48764
- return cid2;
48741
+ function decodeUint8ArrayList(buf, offset) {
48742
+ let b = buf.get(offset);
48743
+ let res = 0;
48744
+ res += b & REST2;
48745
+ if (b < MSB2) {
48746
+ return res;
48747
+ }
48748
+ b = buf.get(offset + 1);
48749
+ res += (b & REST2) << 7;
48750
+ if (b < MSB2) {
48751
+ return res;
48752
+ }
48753
+ b = buf.get(offset + 2);
48754
+ res += (b & REST2) << 14;
48755
+ if (b < MSB2) {
48756
+ return res;
48757
+ }
48758
+ b = buf.get(offset + 3);
48759
+ res += (b & REST2) << 21;
48760
+ if (b < MSB2) {
48761
+ return res;
48762
+ }
48763
+ b = buf.get(offset + 4);
48764
+ res += (b & REST2) * N42;
48765
+ if (b < MSB2) {
48766
+ return res;
48767
+ }
48768
+ b = buf.get(offset + 5);
48769
+ res += (b & REST2) * N52;
48770
+ if (b < MSB2) {
48771
+ return res;
48772
+ }
48773
+ b = buf.get(offset + 6);
48774
+ res += (b & REST2) * N62;
48775
+ if (b < MSB2) {
48776
+ return res;
48777
+ }
48778
+ b = buf.get(offset + 7);
48779
+ res += (b & REST2) * N72;
48780
+ if (b < MSB2) {
48781
+ return res;
48782
+ }
48783
+ throw new RangeError("Could not decode varint");
48784
+ }
48785
+ function decode8(buf, offset = 0) {
48786
+ if (buf instanceof Uint8Array) {
48787
+ return decodeUint8Array(buf, offset);
48765
48788
  } else {
48766
- return cid;
48789
+ return decodeUint8ArrayList(buf, offset);
48767
48790
  }
48768
48791
  }
48769
- var DAG_PB_CODE = 112;
48770
- var SHA_256_CODE = 18;
48771
- function encodeCID(version28, code2, multihash) {
48772
- const codeOffset = encodingLength2(version28);
48773
- const hashOffset = codeOffset + encodingLength2(code2);
48774
- const bytes = new Uint8Array(hashOffset + multihash.byteLength);
48775
- encodeTo(version28, bytes, 0);
48776
- encodeTo(code2, bytes, codeOffset);
48777
- bytes.set(multihash, hashOffset);
48778
- return bytes;
48792
+
48793
+ // ../../node_modules/uint8arrays/dist/src/concat.node.js
48794
+ import { Buffer as Buffer3 } from "buffer";
48795
+ function concat2(arrays, length2) {
48796
+ return asUint8Array(Buffer3.concat(arrays, length2));
48779
48797
  }
48780
- var cidSymbol = /* @__PURE__ */ Symbol.for("@ipld/js-cid/CID");
48781
48798
 
48782
- // ../../node_modules/multiformats/dist/src/basics.js
48783
- var bases = { ...identity_exports, ...base2_exports, ...base8_exports, ...base10_exports, ...base16_exports, ...base32_exports, ...base36_exports, ...base58_exports, ...base64_exports, ...base256emoji_exports };
48784
- var hashes = { ...sha2_exports, ...identity_exports2 };
48799
+ // ../../node_modules/uint8arrays/dist/src/from-string.node.js
48800
+ import { Buffer as Buffer4 } from "buffer";
48785
48801
 
48786
48802
  // ../../node_modules/uint8arrays/dist/src/util/bases.js
48787
48803
  function createCodec(name2, prefix, encode8, decode9) {
@@ -49353,13 +49369,13 @@ function bytesToComponents(bytes) {
49353
49369
  const components = [];
49354
49370
  let i = 0;
49355
49371
  while (i < bytes.length) {
49356
- const code2 = decode3(bytes, i);
49372
+ const code2 = decode8(bytes, i);
49357
49373
  const codec = registry.getProtocol(code2);
49358
- const codeLength = encodingLength(code2);
49374
+ const codeLength = encodingLength2(code2);
49359
49375
  const size = sizeForAddr(codec, bytes, i + codeLength);
49360
49376
  let sizeLength = 0;
49361
49377
  if (size > 0 && codec.size === V) {
49362
- sizeLength = encodingLength(size);
49378
+ sizeLength = encodingLength2(size);
49363
49379
  }
49364
49380
  const componentLength = codeLength + sizeLength + size;
49365
49381
  const component = {
@@ -49383,7 +49399,7 @@ function componentsToBytes(components) {
49383
49399
  for (const component of components) {
49384
49400
  if (component.bytes == null) {
49385
49401
  const codec = registry.getProtocol(component.code);
49386
- const codecLength = encodingLength(component.code);
49402
+ const codecLength = encodingLength2(component.code);
49387
49403
  let valueBytes;
49388
49404
  let valueLength = 0;
49389
49405
  let valueLengthLength = 0;
@@ -49391,7 +49407,7 @@ function componentsToBytes(components) {
49391
49407
  valueBytes = codec.valueToBytes?.(component.value) ?? fromString2(component.value);
49392
49408
  valueLength = valueBytes.byteLength;
49393
49409
  if (codec.size === V) {
49394
- valueLengthLength = encodingLength(valueLength);
49410
+ valueLengthLength = encodingLength2(valueLength);
49395
49411
  }
49396
49412
  }
49397
49413
  const bytes3 = new Uint8Array(codecLength + valueLengthLength + valueLength);
@@ -49491,7 +49507,7 @@ function sizeForAddr(codec, bytes, offset) {
49491
49507
  if (codec.size > 0) {
49492
49508
  return codec.size / 8;
49493
49509
  }
49494
- return decode3(bytes, offset);
49510
+ return decode8(bytes, offset);
49495
49511
  }
49496
49512
 
49497
49513
  // ../../node_modules/@multiformats/multiaddr/dist/src/multiaddr.js
@@ -49585,7 +49601,7 @@ var Multiaddr = class _Multiaddr {
49585
49601
  });
49586
49602
  }
49587
49603
  equals(addr) {
49588
- return equals(this.bytes, addr.bytes);
49604
+ return equals3(this.bytes, addr.bytes);
49589
49605
  }
49590
49606
  /**
49591
49607
  * Returns Multiaddr as a human-readable string
@@ -49673,6 +49689,232 @@ var ClientSessionSchema = external_exports.object({
49673
49689
  signature: external_exports.string(),
49674
49690
  ens: EnsDataSchema.optional()
49675
49691
  });
49692
+ var objectHasOwn = Object.hasOwn ?? Object.prototype.hasOwnProperty.call.bind(
49693
+ Object.prototype.hasOwnProperty
49694
+ );
49695
+ var textEncoder2 = new TextEncoder();
49696
+ var objectHasOwn2 = Object.hasOwn ?? Object.prototype.hasOwnProperty.call.bind(
49697
+ Object.prototype.hasOwnProperty
49698
+ );
49699
+ var CEILING_SERVICES = /* @__PURE__ */ new Set(["tinycloud.kv", "tinycloud.sql", "tinycloud.vfs"]);
49700
+ var GRANTABLE_ACTIONS = /* @__PURE__ */ new Map();
49701
+ for (const entry of CAPABILITY_REGISTRY) {
49702
+ if (!CEILING_SERVICES.has(entry.service)) {
49703
+ continue;
49704
+ }
49705
+ if (entry.aliasOf !== void 0 || entry.implies !== void 0 || entry.urn.endsWith("/*")) {
49706
+ continue;
49707
+ }
49708
+ const existing = GRANTABLE_ACTIONS.get(entry.service);
49709
+ if (existing === void 0) {
49710
+ GRANTABLE_ACTIONS.set(entry.service, /* @__PURE__ */ new Set([entry.urn]));
49711
+ continue;
49712
+ }
49713
+ existing.add(entry.urn);
49714
+ }
49715
+ var textEncoder22 = new TextEncoder();
49716
+ var objectHasOwn3 = Object.hasOwn ?? Object.prototype.hasOwnProperty.call.bind(
49717
+ Object.prototype.hasOwnProperty
49718
+ );
49719
+ var TRANSCRIPT_SHARE_BOOTSTRAP_SCHEMA = "xyz.tinycloud.exchange/transcript-bootstrap/v0";
49720
+ var OWNER_NODE_ENDPOINT_SCHEMA = "xyz.tinycloud.exchange/owner-node-endpoint/v1";
49721
+ var W3C_VC_CREDENTIAL_VERIFIER = "w3c.vc/credential/v1";
49722
+ var objectHasOwn4 = Object.hasOwn ?? Object.prototype.hasOwnProperty.call.bind(
49723
+ Object.prototype.hasOwnProperty
49724
+ );
49725
+ var POLICY_ENGINE_CHALLENGE_RESPONSE_SCHEMA = "xyz.tinycloud.policy/challenge/v0";
49726
+ var POLICY_ENGINE_DENIAL_SCHEMA = "xyz.tinycloud.policy-engine/denial/v0";
49727
+ var POLICY_ENGINE_GRANT_PRESENTATION_DENIAL_CODES = [
49728
+ "schema-invalid",
49729
+ "challenge-not-found",
49730
+ "challenge-expired",
49731
+ "challenge-nonce-consumed",
49732
+ "presentation-expired",
49733
+ "presentation-audience-mismatch",
49734
+ "presentation-evidence-missing",
49735
+ "digest-mismatch",
49736
+ "evidence-requirement-unknown",
49737
+ "evidence-requirement-duplicate",
49738
+ "holder-signature-invalid",
49739
+ "holder-signature-signer-mismatch",
49740
+ "id-mismatch",
49741
+ "requested-capabilities-exceeded",
49742
+ "requested-capabilities-hash-mismatch",
49743
+ "evidence-authority-missing",
49744
+ "evidence-credential-invalid",
49745
+ "evidence-domain-invalid",
49746
+ "evidence-domain-missing",
49747
+ "evidence-freshness-expired",
49748
+ "evidence-freshness-unestablishable",
49749
+ "evidence-issuer-missing",
49750
+ "evidence-issuer-untrusted",
49751
+ "evidence-presentation-invalid",
49752
+ "evidence-requirements-invalid",
49753
+ "evidence-verifier-unsupported",
49754
+ "enrollment-binding-mismatch",
49755
+ "enrollment-expired",
49756
+ "enrollment-not-yet-valid",
49757
+ "enrollment-out-of-scope",
49758
+ "enrollment-revoked",
49759
+ "enrollment-revoked-irreversible",
49760
+ "enrollment-status-rollback",
49761
+ "signature-invalid",
49762
+ "signer-not-authorized",
49763
+ "audience-mismatch",
49764
+ "capability-not-contained",
49765
+ "evidence-invalid",
49766
+ "evidence-missing",
49767
+ "evidence-stale",
49768
+ "evidence-subject-mismatch",
49769
+ "evidence-untrusted",
49770
+ "grant-ttl-exceeds-policy",
49771
+ "holder-did-mismatch",
49772
+ "holder-key-not-permitted",
49773
+ "holder-signature-invalid",
49774
+ "owner-mismatch",
49775
+ "policy-expired",
49776
+ "policy-inactive",
49777
+ "policy-not-found",
49778
+ "policy-not-satisfied",
49779
+ "policy-revoked",
49780
+ "policy-status-rollback",
49781
+ "rate-limited"
49782
+ ];
49783
+ var JsonValueSchema = external_exports.lazy(
49784
+ () => external_exports.union([
49785
+ external_exports.string(),
49786
+ external_exports.number().finite(),
49787
+ external_exports.boolean(),
49788
+ external_exports.null(),
49789
+ external_exports.array(JsonValueSchema),
49790
+ external_exports.record(JsonValueSchema)
49791
+ ])
49792
+ );
49793
+ var Rfc3339Schema = external_exports.string().refine((value) => parseStrictRfc33392(value) !== void 0, {
49794
+ message: "must be strict RFC 3339 date-time with timezone"
49795
+ });
49796
+ var SignedRecordSchema = external_exports.object({
49797
+ schema: external_exports.string(),
49798
+ engineRecordId: external_exports.string(),
49799
+ ownerDid: external_exports.string(),
49800
+ endpoint: external_exports.string(),
49801
+ audience: external_exports.string(),
49802
+ supportedPolicyVersions: external_exports.array(external_exports.string()),
49803
+ supportedEvidenceVerifiers: external_exports.array(external_exports.string()),
49804
+ grantIssuerDid: external_exports.string(),
49805
+ expiresAt: Rfc3339Schema,
49806
+ signature: external_exports.object({
49807
+ suite: external_exports.string(),
49808
+ signerDid: external_exports.string(),
49809
+ value: external_exports.string()
49810
+ }).strict()
49811
+ }).strict();
49812
+ var PolicyEngineSchema = external_exports.object({
49813
+ endpoint: external_exports.string().url(),
49814
+ audience: external_exports.string(),
49815
+ supportedEvidenceVerifiers: external_exports.tuple([
49816
+ external_exports.literal(W3C_VC_CREDENTIAL_VERIFIER)
49817
+ ]),
49818
+ signedRecord: SignedRecordSchema
49819
+ }).strict();
49820
+ var OwnerNodeSchema = external_exports.object({
49821
+ schema: external_exports.literal(OWNER_NODE_ENDPOINT_SCHEMA),
49822
+ endpoint: external_exports.string().url(),
49823
+ spaceId: external_exports.string().min(1)
49824
+ }).strict();
49825
+ var ResourceHintSchema = external_exports.object({
49826
+ resourceType: external_exports.string(),
49827
+ resourceId: external_exports.string(),
49828
+ requestedCapabilities: external_exports.array(JsonValueSchema).min(1)
49829
+ }).strict();
49830
+ var BootstrapSchema = external_exports.object({
49831
+ schema: external_exports.literal(TRANSCRIPT_SHARE_BOOTSTRAP_SCHEMA),
49832
+ policyId: external_exports.string(),
49833
+ policyEngine: PolicyEngineSchema,
49834
+ ownerNode: OwnerNodeSchema,
49835
+ resourceHint: ResourceHintSchema
49836
+ }).strict();
49837
+ var SignatureSchema = external_exports.object({
49838
+ suite: external_exports.string(),
49839
+ signerDid: external_exports.string(),
49840
+ value: external_exports.string()
49841
+ }).strict();
49842
+ var ChallengeSchema = external_exports.object({
49843
+ schema: external_exports.literal(POLICY_ENGINE_CHALLENGE_RESPONSE_SCHEMA),
49844
+ challengeId: external_exports.string(),
49845
+ policyId: external_exports.string(),
49846
+ audience: external_exports.string(),
49847
+ nonce: external_exports.string().min(16),
49848
+ challengeExpiresAt: Rfc3339Schema,
49849
+ acceptedSuites: external_exports.array(external_exports.string()).min(1),
49850
+ requestedCapabilitiesTemplate: external_exports.array(JsonValueSchema).optional(),
49851
+ signature: SignatureSchema
49852
+ }).strict();
49853
+ var ChallengeResponseSchema = external_exports.object({ challenge: ChallengeSchema }).strict();
49854
+ var DenialSchema = external_exports.object({
49855
+ schema: external_exports.literal(POLICY_ENGINE_DENIAL_SCHEMA),
49856
+ code: external_exports.enum(POLICY_ENGINE_GRANT_PRESENTATION_DENIAL_CODES),
49857
+ message: external_exports.string().optional()
49858
+ }).strict();
49859
+ var ErrorEnvelopeDenialSchema = external_exports.object({
49860
+ error: external_exports.object({
49861
+ code: external_exports.enum(POLICY_ENGINE_GRANT_PRESENTATION_DENIAL_CODES),
49862
+ message: external_exports.string().optional()
49863
+ }).strict()
49864
+ }).strict();
49865
+ var WireDelegationSchema = external_exports.object({
49866
+ delegationId: external_exports.string(),
49867
+ issuanceId: external_exports.string().min(1),
49868
+ issuerDid: external_exports.string(),
49869
+ holderDid: external_exports.string(),
49870
+ policyId: external_exports.string(),
49871
+ capabilityHashHex: external_exports.string().regex(/^[0-9a-f]{64}$/),
49872
+ revocationMode: external_exports.literal("refresh_only"),
49873
+ issuedAt: Rfc3339Schema,
49874
+ expiresAt: Rfc3339Schema,
49875
+ terminal: external_exports.boolean(),
49876
+ encoded: external_exports.string()
49877
+ }).strict();
49878
+ var ResolveResponseSchema = external_exports.object({ delegation: WireDelegationSchema }).strict();
49879
+ var DelegateReceiptSchema = external_exports.object({
49880
+ cid: external_exports.string().min(1),
49881
+ activated: external_exports.array(external_exports.string()),
49882
+ skipped: external_exports.array(external_exports.string())
49883
+ }).strict();
49884
+ var SqlReadResponseSchema = external_exports.object({ rows: external_exports.array(JsonValueSchema) }).strict();
49885
+ var KvReadResponseSchema = external_exports.object({ value: JsonValueSchema }).strict();
49886
+ var LISTEN_SQL_STATEMENT_CATALOG = [
49887
+ {
49888
+ name: "listen.getConversation",
49889
+ sql: "SELECT id, title, source, source_id, source_url, started_at, ended_at, duration_secs, summary, metadata, transcript_json, transcript_text, created_at, updated_at FROM conversation WHERE id = ?",
49890
+ fixedParams: [{ index: 0, value: "{conversationId}" }]
49891
+ },
49892
+ {
49893
+ name: "listen.listParticipants",
49894
+ sql: "SELECT id, name, email, speaker_label FROM participant WHERE conversation_id = ? ORDER BY COALESCE(speaker_label, name), id",
49895
+ fixedParams: [{ index: 0, value: "{conversationId}" }]
49896
+ }
49897
+ ];
49898
+ var LISTEN_SQL_STATEMENT_BY_NAME = new Map(
49899
+ LISTEN_SQL_STATEMENT_CATALOG.map((statement) => [
49900
+ statement.name,
49901
+ statement
49902
+ ])
49903
+ );
49904
+ function parseStrictRfc33392(value) {
49905
+ if (!/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(\.\d+)?(Z|[+-]\d{2}:\d{2})$/.test(
49906
+ value
49907
+ )) {
49908
+ return void 0;
49909
+ }
49910
+ const parsed = Date.parse(value);
49911
+ if (Number.isNaN(parsed)) {
49912
+ return void 0;
49913
+ }
49914
+ const canonical = new Date(parsed).toISOString().replace(".000Z", "Z");
49915
+ const reparsed = Date.parse(value);
49916
+ return Date.parse(canonical) === reparsed ? parsed : void 0;
49917
+ }
49676
49918
  var ethereumAddressPattern = /^0x[a-fA-F0-9]{40}$/;
49677
49919
  var EnsDataSchema2 = external_exports.object({
49678
49920
  /** ENS name/domain. */
@@ -49825,6 +50067,22 @@ var DelegationSchema = external_exports.object({
49825
50067
  /** Authorization header (UCAN bearer token) */
49826
50068
  authHeader: external_exports.string().optional()
49827
50069
  });
50070
+ var DelegationStatusSchema = external_exports.object({
50071
+ cid: external_exports.string().min(1),
50072
+ status: external_exports.enum(["active", "revoked", "expired", "unavailable", "not_found"]),
50073
+ exists: external_exports.boolean(),
50074
+ active: external_exports.boolean(),
50075
+ revoked: external_exports.boolean(),
50076
+ expired: external_exports.boolean()
50077
+ }).strict().superRefine((value, context) => {
50078
+ const valid = value.status === "active" ? value.exists && value.active && !value.revoked && !value.expired : value.status === "revoked" ? value.exists && !value.active && value.revoked && !value.expired : value.status === "expired" ? value.exists && !value.active && !value.revoked && value.expired : value.status === "unavailable" ? value.exists && !value.active && !value.revoked && !value.expired : !value.exists && !value.active && !value.revoked && !value.expired;
50079
+ if (!valid) {
50080
+ context.addIssue({
50081
+ code: external_exports.ZodIssueCode.custom,
50082
+ message: "delegation status flags do not match status"
50083
+ });
50084
+ }
50085
+ });
49828
50086
  var CapabilityEntrySchema = external_exports.object({
49829
50087
  /** Resource URI this capability applies to */
49830
50088
  resource: external_exports.string(),
@@ -49989,6 +50247,11 @@ var DelegationManagerConfigSchema = external_exports.object({
49989
50247
  (val) => typeof val === "function",
49990
50248
  { message: "Expected an invoke function" }
49991
50249
  ),
50250
+ /** Platform-specific invoke function for raw resource URIs */
50251
+ invokeAny: external_exports.unknown().refine(
50252
+ (val) => val === void 0 || typeof val === "function",
50253
+ { message: "Expected an invokeAny function or undefined" }
50254
+ ).optional(),
49992
50255
  /** Optional custom fetch implementation */
49993
50256
  fetch: external_exports.unknown().refine(
49994
50257
  (val) => val === void 0 || typeof val === "function",
@@ -50213,7 +50476,8 @@ var SERVICE_SHORT_TO_LONG2 = Object.freeze({
50213
50476
  duckdb: "tinycloud.duckdb",
50214
50477
  capabilities: "tinycloud.capabilities",
50215
50478
  hooks: "tinycloud.hooks",
50216
- encryption: "tinycloud.encryption"
50479
+ encryption: "tinycloud.encryption",
50480
+ delegation: "tinycloud.delegation"
50217
50481
  });
50218
50482
  var SERVICE_LONG_TO_SHORT2 = Object.freeze(
50219
50483
  Object.fromEntries(
@@ -50328,6 +50592,10 @@ var SharingServiceConfigSchema = external_exports.object({
50328
50592
  createDelegationWasm: external_exports.unknown().refine((val) => val === void 0 || typeof val === "function", {
50329
50593
  message: "Expected a createDelegationWasm function or undefined"
50330
50594
  }).optional(),
50595
+ /** CID computation used to verify transportable child delegations. */
50596
+ computeCid: external_exports.unknown().refine((val) => val === void 0 || typeof val === "function", {
50597
+ message: "Expected a computeCid function or undefined"
50598
+ }).optional(),
50331
50599
  /**
50332
50600
  * Path prefix for KV operations.
50333
50601
  */