@ghostlytools/cli 1.10.1 → 1.10.2

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.
Files changed (94) hide show
  1. package/README.md +10 -8
  2. package/SKILL.md +3 -2
  3. package/dist/assets/{api-BOWLZYXM.js → api-DcE4KylM.js} +2 -2
  4. package/dist/assets/{api-Bi6hCcwG.js → api-EUGHGnRz.js} +95 -43
  5. package/dist/assets/api-EUGHGnRz.js.map +1 -0
  6. package/dist/assets/{apiKit-DzXHZojD.js → apiKit-CJVp_crp.js} +68 -22
  7. package/dist/assets/apiKit-CJVp_crp.js.map +1 -0
  8. package/dist/assets/{apps-0Ks6KjqS.js → apps-C-KbyLCa.js} +1 -1
  9. package/dist/assets/{apps-DIQbzG08.js → apps-C54T_MOT.js} +5 -5
  10. package/dist/assets/{apps-DIQbzG08.js.map → apps-C54T_MOT.js.map} +1 -1
  11. package/dist/assets/{arkade-zozCldAE.js → arkade-BmxJTa65.js} +2 -2
  12. package/dist/assets/{arkade-zozCldAE.js.map → arkade-BmxJTa65.js.map} +1 -1
  13. package/dist/assets/{backup-BL49Kt-T.js → backup-BxSH5BZG.js} +7 -7
  14. package/dist/assets/{backup-BL49Kt-T.js.map → backup-BxSH5BZG.js.map} +1 -1
  15. package/dist/assets/{backup-BvIFcZM7.js → backup-C0Plp-DF.js} +1 -1
  16. package/dist/assets/{buttons-CAW5v5EE.js → buttons-B-ZJYdo0.js} +6 -6
  17. package/dist/assets/{buttons-CAW5v5EE.js.map → buttons-B-ZJYdo0.js.map} +1 -1
  18. package/dist/assets/buttons-DA3wZfG0.js +2 -0
  19. package/dist/assets/{client-CyApKBEw.js → client-CDa87uYD.js} +3 -3
  20. package/dist/assets/{client-CyApKBEw.js.map → client-CDa87uYD.js.map} +1 -1
  21. package/dist/assets/{codec-DqFxxB_q.js → codec-D45W1L8n.js} +2 -2
  22. package/dist/assets/{codec-DqFxxB_q.js.map → codec-D45W1L8n.js.map} +1 -1
  23. package/dist/assets/{envelope-CMUgz31I.js → envelope-C3yFCQa-.js} +2 -2
  24. package/dist/assets/{envelope-CMUgz31I.js.map → envelope-C3yFCQa-.js.map} +1 -1
  25. package/dist/assets/{errors-R4S2SAEM.js → errors-Dt-ZnyOX.js} +3 -1
  26. package/dist/assets/errors-Dt-ZnyOX.js.map +1 -0
  27. package/dist/assets/{fixedHosts-C2hdCfzK.js → fixedHosts-C6nCHjOa.js} +4 -4
  28. package/dist/assets/{fixedHosts-C2hdCfzK.js.map → fixedHosts-C6nCHjOa.js.map} +1 -1
  29. package/dist/assets/{groupFiles-BAQIt_bJ.js → groupFiles-DYopNE57.js} +156 -41
  30. package/dist/assets/groupFiles-DYopNE57.js.map +1 -0
  31. package/dist/assets/{host-CaRlDMTd.js → host-G5seUwaI.js} +108 -55
  32. package/dist/assets/host-G5seUwaI.js.map +1 -0
  33. package/dist/assets/{hyperdhtRelay-BxADl3SG.js → hyperdhtRelay-B_uHjg_r.js} +28 -20
  34. package/dist/assets/hyperdhtRelay-B_uHjg_r.js.map +1 -0
  35. package/dist/assets/{irohWeb-D2sh6EWp.js → irohWeb-C-2oslSU.js} +112 -34
  36. package/dist/assets/{irohWeb-D2sh6EWp.js.map → irohWeb-C-2oslSU.js.map} +1 -1
  37. package/dist/assets/{main-Bc4Ow56Z.js → main-Dk--nD7X.js} +69 -41
  38. package/dist/assets/main-Dk--nD7X.js.map +1 -0
  39. package/dist/assets/{mainline-DWh4Ccri.js → mainline-HPlVrl8R.js} +5 -5
  40. package/dist/assets/mainline-HPlVrl8R.js.map +1 -0
  41. package/dist/assets/{networkReason-DT_D_Wpc.js → networkReason-CfpO9ayz.js} +3 -3
  42. package/dist/assets/{networkReason-DT_D_Wpc.js.map → networkReason-CfpO9ayz.js.map} +1 -1
  43. package/dist/assets/{nwc-DoSEhUKb.js → nwc-BY7BPttn.js} +3 -3
  44. package/dist/assets/{nwc-DoSEhUKb.js.map → nwc-BY7BPttn.js.map} +1 -1
  45. package/dist/assets/{nwcProvider-CGWqUjpB.js → nwcProvider-CfpbNUf7.js} +2 -2
  46. package/dist/assets/{nwcProvider-CGWqUjpB.js.map → nwcProvider-CfpbNUf7.js.map} +1 -1
  47. package/dist/assets/{ownDid-CbGjRLBn.js → ownDid-DJFZM2cV.js} +2 -2
  48. package/dist/assets/{ownDid-CbGjRLBn.js.map → ownDid-DJFZM2cV.js.map} +1 -1
  49. package/dist/assets/{profiles-DgIfvBeN.js → profiles-DKmZGXp6.js} +13 -6
  50. package/dist/assets/profiles-DKmZGXp6.js.map +1 -0
  51. package/dist/assets/{registry-BSyxGjN6.js → registry-BUm4cAzV.js} +54 -15
  52. package/dist/assets/registry-BUm4cAzV.js.map +1 -0
  53. package/dist/assets/{registry-C5cn80Rw.js → registry-CAzrtV0_.js} +1 -1
  54. package/dist/assets/{resolve-D-9YRFhl.js → resolve-CDD4X68j.js} +5 -3
  55. package/dist/assets/resolve-CDD4X68j.js.map +1 -0
  56. package/dist/assets/{restoredRows-CRYwIx3g.js → restoredRows-YhlbokEE.js} +4 -2
  57. package/dist/assets/restoredRows-YhlbokEE.js.map +1 -0
  58. package/dist/assets/{secretGuard-CSVNxXVW.js → secretGuard-B7Hj0Kvz.js} +2 -2
  59. package/dist/assets/{secretGuard-CSVNxXVW.js.map → secretGuard-B7Hj0Kvz.js.map} +1 -1
  60. package/dist/assets/secretGuard-DUr6bgKc.js +2 -0
  61. package/dist/assets/{server-BufntkX8.js → server-DcOsgYDU.js} +821 -299
  62. package/dist/assets/server-DcOsgYDU.js.map +1 -0
  63. package/dist/assets/{src-CCt5s4DK.js → src-D31D1_oY.js} +417 -67
  64. package/dist/assets/src-D31D1_oY.js.map +1 -0
  65. package/dist/assets/{sshForges-D8CPaIbR.js → sshForges-DerRwMf3.js} +2 -2
  66. package/dist/assets/{sshForges-D8CPaIbR.js.map → sshForges-DerRwMf3.js.map} +1 -1
  67. package/dist/assets/{translate-Cb-6hMhD.js → translate-C-sj0VJe.js} +3 -3
  68. package/dist/assets/{translate-Cb-6hMhD.js.map → translate-C-sj0VJe.js.map} +1 -1
  69. package/dist/assets/{usdt-ds461mzA.js → usdt-DwHqp625.js} +3 -3
  70. package/dist/assets/{usdt-ds461mzA.js.map → usdt-DwHqp625.js.map} +1 -1
  71. package/dist/assets/{waitNotice-B8D8WhbE.js → waitNotice-D52RWbV4.js} +38 -4
  72. package/dist/assets/waitNotice-D52RWbV4.js.map +1 -0
  73. package/dist/assets/{words-B1ylON2h.js → words-Db9WgatT.js} +3 -3
  74. package/dist/assets/words-Db9WgatT.js.map +1 -0
  75. package/dist/ghostly.mjs +1 -1
  76. package/package.json +1 -1
  77. package/dist/assets/api-Bi6hCcwG.js.map +0 -1
  78. package/dist/assets/apiKit-DzXHZojD.js.map +0 -1
  79. package/dist/assets/buttons-oJI5mHSL.js +0 -2
  80. package/dist/assets/errors-R4S2SAEM.js.map +0 -1
  81. package/dist/assets/groupFiles-BAQIt_bJ.js.map +0 -1
  82. package/dist/assets/host-CaRlDMTd.js.map +0 -1
  83. package/dist/assets/hyperdhtRelay-BxADl3SG.js.map +0 -1
  84. package/dist/assets/main-Bc4Ow56Z.js.map +0 -1
  85. package/dist/assets/mainline-DWh4Ccri.js.map +0 -1
  86. package/dist/assets/profiles-DgIfvBeN.js.map +0 -1
  87. package/dist/assets/registry-BSyxGjN6.js.map +0 -1
  88. package/dist/assets/resolve-D-9YRFhl.js.map +0 -1
  89. package/dist/assets/restoredRows-CRYwIx3g.js.map +0 -1
  90. package/dist/assets/secretGuard-Q2BKq0q0.js +0 -2
  91. package/dist/assets/server-BufntkX8.js.map +0 -1
  92. package/dist/assets/src-CCt5s4DK.js.map +0 -1
  93. package/dist/assets/waitNotice-B8D8WhbE.js.map +0 -1
  94. package/dist/assets/words-B1ylON2h.js.map +0 -1
@@ -1,5 +1,5 @@
1
- import { Gn as INVITE_TAKEN, qu as isZ32Key } from "./src-CCt5s4DK.js";
2
- import { t as CliError } from "./errors-R4S2SAEM.js";
1
+ import { $u as isZ32Key, Kn as INVITE_TAKEN, Yu as sanitizeDisplayText } from "./src-D31D1_oY.js";
2
+ import { t as CliError } from "./errors-Dt-ZnyOX.js";
3
3
  //#region src/apiKit.ts
4
4
  var node = (ctx) => ctx.runtime.server.node;
5
5
  var state = (ctx) => node(ctx).getState();
@@ -61,16 +61,53 @@ var CONTACT_KEY = { test(ref) {
61
61
  return false;
62
62
  } };
63
63
  /**
64
+ * A chat's label, its contact's name or a group's name as a ref is compared with it: cleaned as the engine cleans a name
65
+ * it stores (`renameLink`, `groupName`: any run of whitespace one space, invisible and direction-changing characters
66
+ * dropped, trimmed), in one Unicode form (NFC) and one case. The string given to `chat rename` or `group create` finds
67
+ * what it named, though what was stored is the cleaned one. Empty when nothing visible is left: that names nothing.
68
+ */
69
+ function nameKey(name) {
70
+ if (!name) return "";
71
+ return (sanitizeDisplayText(name.replace(/\s+/gu, " "), Infinity)?.replace(/ {2,}/g, " ") ?? "").normalize("NFC").toLowerCase();
72
+ }
73
+ /**
74
+ * A name this side writes (a chat's label, the profile's name, a group's name) cleaned as the engine stores a name
75
+ * (`renameLink`, `groupName`): any run of whitespace (a tab, a line break) one space, invisible and direction-changing
76
+ * characters dropped, trimmed, in NFC: `nameKey` without the case. Counted after that, in code points as the engine
77
+ * counts: undefined past `max`, "" when nothing visible is left. Every command that writes a name checks it here, so a
78
+ * tab is a space and not a second line, and a name is never refused at a length it does not have once stored.
79
+ */
80
+ function cleanName(name, max) {
81
+ const clean = (sanitizeDisplayText(name.replace(/\s+/gu, " "), Infinity)?.replace(/ {2,}/g, " ") ?? "").normalize("NFC");
82
+ return [...clean].length > max ? void 0 : clean;
83
+ }
84
+ /** Whether `name` is the one `key` (a ref's `nameKey`) names. */
85
+ var namedAs = (key, name) => key !== "" && nameKey(name) === key;
86
+ /**
64
87
  * A chat by its id; by its contact's key (only by the key: a name is never taken for one); by the label this side gave
65
88
  * it; and only when no label matches, by a unique prefix of its id or the name the contact gave itself. The contact
66
89
  * controls both of those (a joiner's chat id is made from the inviter's code), so neither wins over a label, and a ref
67
- * that fits one chat's prefix and another's name is refused.
90
+ * that fits one chat's prefix and another's name is refused. `group:<ref>` is taken for a chat only by a label. A ref
91
+ * that names no chat but one of `groups` says it is a group (see `noChat`).
68
92
  */
69
- function findChat(links, ref) {
70
- return chatBy(links, ref).link;
93
+ function findChat(links, ref, groups = []) {
94
+ return chatBy(links, ref, groups).link;
95
+ }
96
+ /**
97
+ * No chat by `ref`. A group's id, prefix or name (or `group:<id>`) says it is a group, as `groupOf` says a chat is one:
98
+ * `chat connect`, `identity share`, `call start` and the other commands that take only a 1:1 chat read `No chat "Crew"`,
99
+ * as if nothing had that name.
100
+ */
101
+ function noChat(ref, groups) {
102
+ let group;
103
+ try {
104
+ group = findGroup(groups, ref);
105
+ } catch {}
106
+ if (group) return new CliError("not_found", `${JSON.stringify(ref)} is a group, not a chat (ghostly chat list)`, { group: group.id });
107
+ return new CliError("not_found", `No chat ${JSON.stringify(ref)} (ghostly chat list)`);
71
108
  }
72
109
  /** `findChat`, and whether only what the contact controls (`theirName`: a prefix of the id, its own name) found the chat. */
73
- function chatBy(links, ref) {
110
+ function chatBy(links, ref, groups = []) {
74
111
  if (!ref.trim()) throw new CliError("bad_request", `${JSON.stringify(ref)} names no chat`);
75
112
  const exact = links.find((link) => link.id === ref);
76
113
  if (exact) return {
@@ -86,24 +123,25 @@ function chatBy(links, ref) {
86
123
  if (byKey.length > 1) throw new CliError("bad_request", `${JSON.stringify(ref)} names more than one chat: use its id`, { matches: byKey.map((link) => link.id) });
87
124
  throw new CliError("not_found", `No chat with ${JSON.stringify(ref)} (ghostly chat list)`);
88
125
  }
89
- const lower = ref.toLowerCase();
90
- const named = (name) => name?.trim().toLowerCase() === lower;
126
+ const key = nameKey(ref);
127
+ const named = (name) => namedAs(key, name);
91
128
  const byLabel = links.filter((link) => named(link.label));
129
+ if (!byLabel.length && groupPrefixed(ref) !== null) throw noChat(ref, groups);
92
130
  const found = byLabel.length ? byLabel : [.../* @__PURE__ */ new Set([...links.filter((link) => link.id.startsWith(ref)), ...links.filter((link) => named(link.peerNick))])];
93
131
  if (found.length === 1) return {
94
132
  link: found[0],
95
133
  theirName: !byLabel.length
96
134
  };
97
135
  if (found.length > 1) throw new CliError("bad_request", `${JSON.stringify(ref)} names more than one chat: use its id`, { matches: found.map((link) => link.id) });
98
- throw new CliError("not_found", `No chat ${JSON.stringify(ref)} (ghostly chat list)`);
136
+ throw noChat(ref, groups);
99
137
  }
100
138
  /**
101
139
  * `findChat` for a grant the daemon keeps acting on (`call auto on --from`): only the chat's id, its contact's key or the
102
140
  * label this side gave it name the chat. A prefix of its id or the name its contact gave itself is refused, with the
103
141
  * chat it found: the contact chose those, so another contact could take the grant by calling itself that name.
104
142
  */
105
- function findOwnNamedChat(links, ref) {
106
- const chat = chatBy(links, ref);
143
+ function findOwnNamedChat(links, ref, groups = []) {
144
+ const chat = chatBy(links, ref, groups);
107
145
  if (chat.theirName) throw namedByThem(ref, {
108
146
  chat: chat.link.id,
109
147
  name: chat.link.peerNick ?? null,
@@ -115,6 +153,12 @@ function findOwnNamedChat(links, ref) {
115
153
  function namedByThem(ref, chat) {
116
154
  return new CliError("bad_request", `${JSON.stringify(ref)} names a chat only by what its contact chose (a prefix of its id, its own name): use the chat's id, its contact's key or a label given here (ghostly chat rename <chat> <name>)`, chat);
117
155
  }
156
+ /**
157
+ * `group:<ref>`, the form that names a group wherever a group is taken (docs/CLI.md § What it does): `<ref>`, read as any
158
+ * other ref (`findGroup`: an id, a prefix of it or a name). Null for a ref without it. `findGroup` and `findChatOrGroup`
159
+ * both read the prefix here, so a group command and a command that takes a chat or a group never read it apart.
160
+ */
161
+ var groupPrefixed = (ref) => ref.startsWith("group:") ? ref.slice(6) : null;
118
162
  /** Only an invitation so far: this profile is not in the group (yet), and whoever invited chose its name. */
119
163
  var invitedOnly = (group) => group.status === void 0 && !!group.invitation;
120
164
  /**
@@ -122,15 +166,17 @@ var invitedOnly = (group) => group.status === void 0 && !!group.invitation;
122
166
  * chooses its name, so neither wins over the other: a ref that is one group's name and another's prefix is refused,
123
167
  * with both ids, as `chatBy` does for chats. A group this profile is in wins over an invitation with the same name or
124
168
  * prefix (the one who invites chooses those); an invitation is still found by its id, and by name or prefix where no
125
- * group of this profile has it.
169
+ * group of this profile has it. `group:<ref>` is `<ref>` (`groupPrefixed`); before, only the commands that take a chat
170
+ * or a group read it, and every group command and `listen --group` answered it `No group`.
126
171
  */
127
- function findGroup(groups, ref) {
172
+ function findGroup(groups, given) {
173
+ const ref = groupPrefixed(given) ?? given;
128
174
  if (!ref.trim()) throw new CliError("bad_request", `${JSON.stringify(ref)} names no group`);
129
175
  const exact = groups.find((group) => group.id === ref);
130
176
  if (exact) return exact;
131
- const lower = ref.toLowerCase();
177
+ const key = nameKey(ref);
132
178
  for (const among of [groups.filter((group) => !invitedOnly(group)), groups.filter(invitedOnly)]) {
133
- const found = among.filter((group) => group.name.trim().toLowerCase() === lower || group.id.startsWith(ref));
179
+ const found = among.filter((group) => namedAs(key, group.name) || group.id.startsWith(ref));
134
180
  if (found.length === 1) return found[0];
135
181
  if (found.length > 1) throw new CliError("bad_request", `${JSON.stringify(ref)} names more than one group: use its id`, { matches: found.map((group) => group.id) });
136
182
  }
@@ -145,7 +191,7 @@ function findGroup(groups, ref) {
145
191
  * chat or group stays that error.
146
192
  */
147
193
  function findChatOrGroup(links, groups, ref) {
148
- if (ref.startsWith("group:")) return { group: findGroup(groups, ref.slice(6)) };
194
+ if (groupPrefixed(ref) !== null) return { group: findGroup(groups, ref) };
149
195
  let chat;
150
196
  try {
151
197
  chat = chatBy(links, ref);
@@ -162,8 +208,8 @@ function findChatOrGroup(links, groups, ref) {
162
208
  if (!chat.theirName) return { link: chat.link };
163
209
  const exact = groups.find((group) => group.id === ref);
164
210
  if (exact) return { group: exact };
165
- const lower = ref.toLowerCase();
166
- const also = groups.filter((group) => !invitedOnly(group) && (group.id.startsWith(ref) || group.name.trim().toLowerCase() === lower));
211
+ const key = nameKey(ref);
212
+ const also = groups.filter((group) => !invitedOnly(group) && (group.id.startsWith(ref) || namedAs(key, group.name)));
167
213
  if (also.length) throw new CliError("bad_request", `${JSON.stringify(ref)} names a chat (by what its contact chose) and a group: use the chat's id or group:<id>`, {
168
214
  chat: chat.link.id,
169
215
  groups: also.map((group) => group.id)
@@ -187,7 +233,7 @@ function startNamedChats(ctx, params) {
187
233
  if ("link" in found) node(ctx).startDeferredChat(found.link.id);
188
234
  }
189
235
  }
190
- var chatOf = (ctx, params) => findChat(state(ctx).links, str(params, "chat", true));
236
+ var chatOf = (ctx, params) => findChat(state(ctx).links, str(params, "chat", true), state(ctx).groups);
191
237
  /**
192
238
  * A chat whose invite nobody took yet: nobody is there to pay or to dial, and its stage says so. Before, `chat pay`
193
239
  * waited 15 s and `chat connect` 25 s for the contact, then answered `engine`. A chat whose invite someone else used
@@ -253,7 +299,7 @@ function groupOf(ctx, params, twin) {
253
299
  try {
254
300
  return findGroup(state(ctx).groups, ref);
255
301
  } catch (error) {
256
- if (!(error instanceof CliError) || error.code !== "not_found") throw error;
302
+ if (!(error instanceof CliError) || error.code !== "not_found" || groupPrefixed(ref) !== null) throw error;
257
303
  let chat;
258
304
  try {
259
305
  chat = findChat(state(ctx).links, ref);
@@ -305,6 +351,6 @@ function waitForState(ctx, check, ms, what) {
305
351
  });
306
352
  }
307
353
  //#endregion
308
- export { waitForState as C, transportOffered as S, oneOf as _, dhtOnly as a, state as b, findGroup as c, inviteTaken as d, list as f, num as g, node as h, chatOrGroup as i, findOwnNamedChat as l, namedByThem as m, bool as n, findChat as o, messageOf as p, chatOf as r, findChatOrGroup as s, CONTACT_KEY as t, groupOf as u, sentAt as v, str as x, startNamedChats as y };
354
+ export { str as C, state as S, waitForState as T, node as _, cleanName as a, sentAt as b, findChatOrGroup as c, groupOf as d, groupPrefixed as f, namedByThem as g, messageOf as h, chatOrGroup as i, findGroup as l, list as m, bool as n, dhtOnly as o, inviteTaken as p, chatOf as r, findChat as s, CONTACT_KEY as t, findOwnNamedChat as u, num as v, transportOffered as w, startNamedChats as x, oneOf as y };
309
355
 
310
- //# sourceMappingURL=apiKit-DzXHZojD.js.map
356
+ //# sourceMappingURL=apiKit-CJVp_crp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apiKit-CJVp_crp.js","names":[],"sources":["../../src/apiKit.ts"],"sourcesContent":["import { INVITE_TAKEN, isZ32Key, sanitizeDisplayText, type PairedTransport } from \"@ghostly/core\";\nimport type { GhostlyNode } from \"@ghostly/browser/engine/node\";\nimport type { EngineState, GroupView, LinkView, StoredMessage } from \"@ghostly/browser/shared/types\";\nimport { CliError } from \"./errors\";\nimport type { CallManager } from \"./calls/manager\";\nimport type { EventHub } from \"./events\";\nimport type { Runtime } from \"./runtime/engine\";\n\n/**\n * The methods of the local control API (WISP 1100): the daemon answers them over its socket, and a one-shot\n * command calls them in its own process. Parameters come from JSON: every one is checked here.\n */\nexport interface ApiContext {\n runtime: Runtime;\n hub: EventHub;\n /** Voice calls (WISP 1100 § Calls). */\n calls: CallManager;\n /** How the host runs: a daemon stays; a one-shot leaves when its command is done. */\n mode: \"daemon\" | \"one-shot\";\n version: string;\n /** The daemon asks to stop (answered first). */\n stop?: () => void;\n /** The daemon is a `listen` that found none and runs the profile itself: a stop ends that listen too. */\n listen?: true;\n}\n\nexport type Params = Record<string, unknown>;\nexport type Method = (ctx: ApiContext, params: Params) => Promise<unknown>;\n\nexport const node = (ctx: ApiContext): GhostlyNode => ctx.runtime.server.node;\nexport const state = (ctx: ApiContext): EngineState => node(ctx).getState();\n\n/**\n * The time of a send the engine names its row after (`me_<timestamp>`: a file, a payment, a request), its own even\n * within one millisecond (a bot paying or sending several times at once over the socket, `file send` run in\n * parallel), or the chat keeps only one. One clock for all of them: they share the row names. A file's resend after a\n * drop finds its row by it, as a forward does.\n */\nlet lastSentAt = 0;\nexport const sentAt = () => (lastSentAt = Math.max(Date.now(), lastSentAt + 1));\n\n// ---------- parameters ----------\n\nexport function str(params: Params, name: string, required: true): string;\nexport function str(params: Params, name: string, required?: false): string | undefined;\nexport function str(params: Params, name: string, required = false): string | undefined {\n const value = params[name];\n if (value === undefined || value === null || value === \"\") {\n if (required) throw new CliError(\"bad_request\", `${name} is required`);\n return undefined;\n }\n if (typeof value !== \"string\") throw new CliError(\"bad_request\", `${name} must be a string`);\n return value;\n}\n/** A number in `[min, max]`; `whole` takes only whole ones (a count of messages), as the engine needs them. */\nexport function num(params: Params, name: string, fallback: number, { min = 0, max = Number.MAX_SAFE_INTEGER, whole = false } = {}): number {\n const value = params[name];\n if (value === undefined || value === null) return fallback;\n if (typeof value !== \"number\" || !Number.isFinite(value) || value < min || value > max) throw new CliError(\"bad_request\", `${name} must be a ${whole ? \"whole \" : \"\"}number from ${min} to ${max}`);\n if (whole && !Number.isSafeInteger(value)) throw new CliError(\"bad_request\", `${name} must be a whole number from ${min} to ${max}`);\n return value;\n}\nexport function bool(params: Params, name: string): boolean {\n const value = params[name];\n if (value === undefined || value === null) return false;\n if (typeof value !== \"boolean\") throw new CliError(\"bad_request\", `${name} must be true or false`);\n return value;\n}\nexport function list(params: Params, name: string): string[] {\n const value = params[name];\n if (value === undefined || value === null) return [];\n if (!Array.isArray(value) || value.some((item) => typeof item !== \"string\")) throw new CliError(\"bad_request\", `${name} must be a list of strings`);\n return value as string[];\n}\n/**\n * One of `values`; `fallback` when it was left out. Given empty (an unset variable in a script: `wallet remove \"\"`), it\n * is refused like any other wrong choice, never read as left out: that acted on the default (the Cashu wallet).\n */\nexport function oneOf<T extends string>(params: Params, name: string, values: readonly T[], fallback: T): T {\n const value = params[name] === \"\" ? \"\" : str(params, name) ?? fallback;\n if (!values.includes(value as T)) throw new CliError(\"bad_request\", `${name} must be one of ${values.join(\", \")}`);\n return value as T;\n}\n\n// ---------- finding things ----------\n\nconst KEY_SHAPED = /^[ybndrfg8ejkmcpqxot1uwisza345h769]{52}$/;\n/**\n * A contact key as chats show it (`peer`): 52 characters of z-base-32, in its one canonical spelling. The same 52\n * characters with the last one respelled decode to the same bytes but are no key (WISP 02): refused here, so that\n * they never fall through to a chat's name, which its contact chooses.\n */\nexport const CONTACT_KEY = {\n test(ref: string): boolean {\n if (isZ32Key(ref)) return true;\n if (KEY_SHAPED.test(ref)) throw new CliError(\"bad_request\", `${JSON.stringify(ref)} is not a contact key: a key has one spelling, and its last character is not this one`);\n return false;\n },\n};\n\n/**\n * A chat's label, its contact's name or a group's name as a ref is compared with it: cleaned as the engine cleans a name\n * it stores (`renameLink`, `groupName`: any run of whitespace one space, invisible and direction-changing characters\n * dropped, trimmed), in one Unicode form (NFC) and one case. The string given to `chat rename` or `group create` finds\n * what it named, though what was stored is the cleaned one. Empty when nothing visible is left: that names nothing.\n */\nexport function nameKey(name: string | null | undefined): string {\n if (!name) return \"\";\n return (sanitizeDisplayText(name.replace(/\\s+/gu, \" \"), Infinity)?.replace(/ {2,}/g, \" \") ?? \"\").normalize(\"NFC\").toLowerCase();\n}\n\n/**\n * A name this side writes (a chat's label, the profile's name, a group's name) cleaned as the engine stores a name\n * (`renameLink`, `groupName`): any run of whitespace (a tab, a line break) one space, invisible and direction-changing\n * characters dropped, trimmed, in NFC: `nameKey` without the case. Counted after that, in code points as the engine\n * counts: undefined past `max`, \"\" when nothing visible is left. Every command that writes a name checks it here, so a\n * tab is a space and not a second line, and a name is never refused at a length it does not have once stored.\n */\nexport function cleanName(name: string, max: number): string | undefined {\n const clean = (sanitizeDisplayText(name.replace(/\\s+/gu, \" \"), Infinity)?.replace(/ {2,}/g, \" \") ?? \"\").normalize(\"NFC\");\n return [...clean].length > max ? undefined : clean;\n}\n\n/** Whether `name` is the one `key` (a ref's `nameKey`) names. */\nconst namedAs = (key: string, name: string | null | undefined) => key !== \"\" && nameKey(name) === key;\n\n/**\n * A chat by its id; by its contact's key (only by the key: a name is never taken for one); by the label this side gave\n * it; and only when no label matches, by a unique prefix of its id or the name the contact gave itself. The contact\n * controls both of those (a joiner's chat id is made from the inviter's code), so neither wins over a label, and a ref\n * that fits one chat's prefix and another's name is refused. `group:<ref>` is taken for a chat only by a label. A ref\n * that names no chat but one of `groups` says it is a group (see `noChat`).\n */\nexport function findChat(links: readonly LinkView[], ref: string, groups: readonly GroupView[] = []): LinkView {\n return chatBy(links, ref, groups).link;\n}\n\n/**\n * No chat by `ref`. A group's id, prefix or name (or `group:<id>`) says it is a group, as `groupOf` says a chat is one:\n * `chat connect`, `identity share`, `call start` and the other commands that take only a 1:1 chat read `No chat \"Crew\"`,\n * as if nothing had that name.\n */\nfunction noChat(ref: string, groups: readonly GroupView[]): CliError {\n let group: GroupView | undefined;\n try { group = findGroup(groups, ref); } catch { /* no group, or more than one */ }\n if (group) return new CliError(\"not_found\", `${JSON.stringify(ref)} is a group, not a chat (ghostly chat list)`, { group: group.id });\n return new CliError(\"not_found\", `No chat ${JSON.stringify(ref)} (ghostly chat list)`);\n}\n\n/** `findChat`, and whether only what the contact controls (`theirName`: a prefix of the id, its own name) found the chat. */\nfunction chatBy(links: readonly LinkView[], ref: string, groups: readonly GroupView[] = []): { link: LinkView; theirName: boolean } {\n // \"\" (an unset variable in a script) is a prefix of every id: it took the only chat.\n if (!ref.trim()) throw new CliError(\"bad_request\", `${JSON.stringify(ref)} names no chat`);\n const exact = links.find((link) => link.id === ref);\n if (exact) return { link: exact, theirName: false };\n if (CONTACT_KEY.test(ref)) {\n const byKey = links.filter((link) => link.peerPubKeyZ32 === ref);\n if (byKey.length === 1) return { link: byKey[0], theirName: false };\n if (byKey.length > 1) throw new CliError(\"bad_request\", `${JSON.stringify(ref)} names more than one chat: use its id`, { matches: byKey.map((link) => link.id) });\n throw new CliError(\"not_found\", `No chat with ${JSON.stringify(ref)} (ghostly chat list)`);\n }\n const key = nameKey(ref);\n const named = (name: string | null | undefined) => namedAs(key, name);\n const byLabel = links.filter((link) => named(link.label));\n // `group:<ref>` names a group (`groupPrefixed`): only a label given here takes it for a chat, never a name its contact\n // chose (a contact calling itself `group:Crew` took `send group:Crew` and every chat-only command meant for the group).\n if (!byLabel.length && groupPrefixed(ref) !== null) throw noChat(ref, groups);\n const found = byLabel.length ? byLabel : [...new Set([...links.filter((link) => link.id.startsWith(ref)), ...links.filter((link) => named(link.peerNick))])];\n if (found.length === 1) return { link: found[0], theirName: !byLabel.length };\n if (found.length > 1) throw new CliError(\"bad_request\", `${JSON.stringify(ref)} names more than one chat: use its id`, { matches: found.map((link) => link.id) });\n throw noChat(ref, groups);\n}\n\n/**\n * `findChat` for a grant the daemon keeps acting on (`call auto on --from`): only the chat's id, its contact's key or the\n * label this side gave it name the chat. A prefix of its id or the name its contact gave itself is refused, with the\n * chat it found: the contact chose those, so another contact could take the grant by calling itself that name.\n */\nexport function findOwnNamedChat(links: readonly LinkView[], ref: string, groups: readonly GroupView[] = []): LinkView {\n const chat = chatBy(links, ref, groups);\n if (chat.theirName) throw namedByThem(ref, { chat: chat.link.id, name: chat.link.peerNick ?? null, contact: chat.link.peerPubKeyZ32 });\n return chat.link;\n}\n\n/** `findOwnNamedChat`'s refusal: `ref` found `chat` only by what its contact chose. */\nexport function namedByThem(ref: string, chat: { chat: string; name: string | null; contact: string | undefined }): CliError {\n return new CliError(\"bad_request\", `${JSON.stringify(ref)} names a chat only by what its contact chose (a prefix of its id, its own name): use the chat's id, its contact's key or a label given here (ghostly chat rename <chat> <name>)`, chat);\n}\n\n/**\n * `group:<ref>`, the form that names a group wherever a group is taken (docs/CLI.md § What it does): `<ref>`, read as any\n * other ref (`findGroup`: an id, a prefix of it or a name). Null for a ref without it. `findGroup` and `findChatOrGroup`\n * both read the prefix here, so a group command and a command that takes a chat or a group never read it apart.\n */\nexport const groupPrefixed = (ref: string): string | null => (ref.startsWith(\"group:\") ? ref.slice(\"group:\".length) : null);\n\n/** Only an invitation so far: this profile is not in the group (yet), and whoever invited chose its name. */\nconst invitedOnly = (group: GroupView) => group.status === undefined && !!group.invitation;\n\n/**\n * A group by its id, by its name, or by a unique prefix of its id. Whoever created a group chose its id and its admin\n * chooses its name, so neither wins over the other: a ref that is one group's name and another's prefix is refused,\n * with both ids, as `chatBy` does for chats. A group this profile is in wins over an invitation with the same name or\n * prefix (the one who invites chooses those); an invitation is still found by its id, and by name or prefix where no\n * group of this profile has it. `group:<ref>` is `<ref>` (`groupPrefixed`); before, only the commands that take a chat\n * or a group read it, and every group command and `listen --group` answered it `No group`.\n */\nexport function findGroup(groups: readonly GroupView[], given: string): GroupView {\n const ref = groupPrefixed(given) ?? given;\n if (!ref.trim()) throw new CliError(\"bad_request\", `${JSON.stringify(ref)} names no group`);\n const exact = groups.find((group) => group.id === ref);\n if (exact) return exact;\n const key = nameKey(ref);\n for (const among of [groups.filter((group) => !invitedOnly(group)), groups.filter(invitedOnly)]) {\n const found = among.filter((group) => namedAs(key, group.name) || group.id.startsWith(ref));\n if (found.length === 1) return found[0];\n if (found.length > 1) throw new CliError(\"bad_request\", `${JSON.stringify(ref)} names more than one group: use its id`, { matches: found.map((group) => group.id) });\n }\n throw new CliError(\"not_found\", `No group ${JSON.stringify(ref)} (ghostly group list)`);\n}\n\n/**\n * A chat or a group, where a command takes either: `group:<id>` is a group; anything else a chat first (`findChat`),\n * then a group. A chat found only by what its contact chose (a prefix of its id, its own name) never takes what also\n * names a group: a group's\n * own id is that group, and a prefix or the name of a group this profile is in is refused, with both ids. With neither,\n * one `not_found` names both and where to look (a contact's key: no chat with it); a name that matches more than one\n * chat or group stays that error.\n */\nexport function findChatOrGroup(links: readonly LinkView[], groups: readonly GroupView[], ref: string): { link: LinkView } | { group: GroupView } {\n if (groupPrefixed(ref) !== null) return { group: findGroup(groups, ref) };\n let chat: ReturnType<typeof chatBy>;\n try {\n chat = chatBy(links, ref);\n } catch (error) {\n if (!(error instanceof CliError) || error.code !== \"not_found\") throw error;\n try { return { group: findGroup(groups, ref) }; } catch (inner) {\n if (!(inner instanceof CliError) || inner.code !== \"not_found\") throw inner;\n if (CONTACT_KEY.test(ref)) throw error;\n throw new CliError(\"not_found\", `No chat or group ${JSON.stringify(ref)} (ghostly chat list, ghostly group list)`);\n }\n }\n if (!chat.theirName) return { link: chat.link };\n const exact = groups.find((group) => group.id === ref);\n if (exact) return { group: exact };\n const key = nameKey(ref);\n const also = groups.filter((group) => !invitedOnly(group) && (group.id.startsWith(ref) || namedAs(key, group.name)));\n if (also.length) throw new CliError(\"bad_request\", `${JSON.stringify(ref)} names a chat (by what its contact chose) and a group: use the chat's id or group:<id>`, { chat: chat.link.id, groups: also.map((group) => group.id) });\n return { link: chat.link };\n}\n\n/**\n * Starts the chats a call names (its `chat`, a forward's `to`) in a runtime that left the saved chats unstarted\n * (`RuntimeOptions.deferChats`). A ref that names no chat, or names a group, starts nothing: the call says so itself.\n */\nexport function startNamedChats(ctx: ApiContext, params: Params): void {\n const { links, groups } = state(ctx);\n for (const ref of [params.chat, ...(Array.isArray(params.to) ? params.to : [])]) {\n if (typeof ref !== \"string\") continue;\n let found: ReturnType<typeof findChatOrGroup>;\n try { found = findChatOrGroup(links, groups, ref); } catch { continue; }\n if (\"link\" in found) node(ctx).startDeferredChat(found.link.id);\n }\n}\n\nexport const chatOf = (ctx: ApiContext, params: Params) => findChat(state(ctx).links, str(params, \"chat\", true), state(ctx).groups);\n\n/**\n * A chat whose invite nobody took yet: nobody is there to pay or to dial, and its stage says so. Before, `chat pay`\n * waited 15 s and `chat connect` 25 s for the contact, then answered `engine`. A chat whose invite someone else used\n * first is refused too, with the sentence `send` gives: its contact seals everything to them (`connect` waited 120 s,\n * then answered `timeout`, a code a bot retries).\n */\nexport function inviteTaken(link: LinkView): void {\n if (link.profile && link.inviteCode && !link.peerParticipationKey) throw new CliError(\"unavailable\", \"Nobody joined this chat yet: its invite is still waiting to be taken\");\n if (link.dhtDelivery?.inviteTaken && link.textDelivery !== \"stream\") throw new CliError(\"refused\", INVITE_TAKEN);\n}\n\n/**\n * A chat on DHT only opens no live session: the engine refused `chat connect` as `engine`, \"Both peers must choose a\n * live method first\", which read as if this side had to change something. Refused instead, naming whose choice it is\n * (`details.reason`): the contact's (`peer-dht-only`, nothing to do here but wait), or this side's (`dht-only`).\n */\nexport function dhtOnly(link: LinkView): void {\n if (link.deliveryMode === \"dht\") throw new CliError(\"refused\", \"This chat is on DHT only on this side: choose a live method first (chat transport auto)\", { reason: \"dht-only\" });\n if (link.dhtDelivery?.peerMode === \"dht\") throw new CliError(\"refused\", \"Your contact keeps this chat on DHT only: it goes live once they choose a live method. Short texts still go on the DHT\", { reason: \"peer-dht-only\" });\n}\n\nconst TRANSPORT_TITLES: Record<PairedTransport, string> = { \"webrtc/1\": \"WebRTC\", \"iroh/1\": \"Iroh\", \"hyperdht/1\": \"HyperDHT\" };\n\n/**\n * A transport the chat's Connection menu offers: one this app runs (on DHT only, one it can start), and the contact's\n * app too, by its last word. `chat transport` took any: toward a contact with no WebRTC (`GHOSTLY_WEBRTC=0`) the choice\n * was kept and the chat stayed where it was, saying nothing; for one this app lacks, the engine answered `engine`,\n * \"Transport unavailable\". Refused instead, saying whose app lacks it (`details.reason`, as a chat's wait says it).\n */\nexport function transportOffered(link: LinkView, transport: PairedTransport): void {\n const mine = (link.deliveryMode === \"dht\" ? link.runnableTransports : undefined) ?? link.availableTransports;\n const title = TRANSPORT_TITLES[transport], error = link.transportErrors?.[transport];\n if (mine && !mine.includes(transport)) throw new CliError(\"refused\", `This app has no ${title} running${error ? `: ${error}` : \"\"}`, { reason: \"app-lacks\", transport });\n if (link.peerTransports?.length && !link.peerTransports.includes(transport)) throw new CliError(\"refused\", `Your contact's app doesn't have ${title}: choose another, or auto`, { reason: \"contact-lacks\", transport });\n}\n\n/** A chat or a group as `findChatOrGroup` reads it. `linkId` is what the engine calls it. */\nexport function chatOrGroup(ctx: ApiContext, ref: string): { id: string; linkId: string; group: boolean } {\n const found = findChatOrGroup(state(ctx).links, state(ctx).groups, ref);\n return \"group\" in found ? { id: found.group.id, linkId: `group:${found.group.id}`, group: true } : { id: found.link.id, linkId: found.link.id, group: false };\n}\n\n/**\n * The group a group command names. A chat's id, key or name says it is a chat, with `twin`, the chat command that takes\n * it (`group send` on a chat, where `send` is meant; `<chat>` stands for the ref), else where the groups are listed.\n * It read \"No group\" before. A name nothing has stays that error.\n */\nexport function groupOf(ctx: ApiContext, params: Params, twin?: string): GroupView {\n const ref = str(params, \"group\", true);\n try { return findGroup(state(ctx).groups, ref); } catch (error) {\n // `group:<ref>` names a group only: never a chat, as in `findChatOrGroup`.\n if (!(error instanceof CliError) || error.code !== \"not_found\" || groupPrefixed(ref) !== null) throw error;\n let chat: LinkView;\n try { chat = findChat(state(ctx).links, ref); } catch { throw error; }\n const shown = /^[\\w.:-]+$/.test(ref) ? ref : JSON.stringify(ref);\n throw new CliError(\"not_found\", `${JSON.stringify(ref)} is a chat, not a group${twin ? `: ghostly ${twin.replace(\"<chat>\", shown)}` : \" (ghostly group list)\"}`, { chat: chat.id });\n }\n}\n\n/**\n * A message of a chat or a group (`group:<id>`) named by its id here, read as one row; only a name that is no such\n * row's key (the id both sides know, `wireId`) reads the whole history. `keep`: only a message it accepts (mine, or\n * someone else's). The history is synchronous work on the daemon's one thread, about 120 ms at 10,000 messages.\n */\nexport async function messageOf(ctx: ApiContext, linkId: string, ref: string, keep: (message: StoredMessage) => boolean = () => true): Promise<StoredMessage | undefined> {\n const found = await node(ctx).getMessage(linkId, ref);\n if (found && keep(found)) return found;\n const all = linkId.startsWith(\"group:\") ? await node(ctx).groupMessages({ groupId: linkId.slice(\"group:\".length) }) : await node(ctx).getMessages(linkId);\n return all.find((m) => keep(m) && m.wireId === ref);\n}\n\n// ---------- waiting ----------\n\n/**\n * Resolves with `check`'s first defined answer: now, or on a later state; `timeout` error after `ms`. A check that\n * throws on a later state (`chat wait`'s chat removed) ends the wait with its error: the hub swallows what its\n * listeners throw, and the wait went on to its timeout.\n */\nexport function waitForState<T>(ctx: ApiContext, check: (state: EngineState) => T | undefined, ms: number, what: string): Promise<T> {\n const now = check(state(ctx));\n if (now !== undefined) return Promise.resolve(now);\n return new Promise<T>((resolve, reject) => {\n const timer = setTimeout(() => { off(); reject(new CliError(\"timeout\", `Timed out after ${Math.round(ms / 1000)} s waiting for ${what}`)); }, ms);\n const off = ctx.hub.onState((next) => {\n let value: T | undefined;\n try { value = check(next); } catch (error) { clearTimeout(timer); off(); reject(error); return; }\n if (value === undefined) return;\n clearTimeout(timer);\n off();\n resolve(value);\n });\n });\n}\n\n"],"mappings":";;;AA6BA,IAAa,QAAQ,QAAiC,IAAI,QAAQ,OAAO;AACzE,IAAa,SAAS,QAAiC,KAAK,GAAG,CAAC,CAAC,SAAS;;;;;;;AAQ1E,IAAI,aAAa;AACjB,IAAa,eAAgB,aAAa,KAAK,IAAI,KAAK,IAAI,GAAG,aAAa,CAAC;AAM7E,SAAgB,IAAI,QAAgB,MAAc,WAAW,OAA2B;CACtF,MAAM,QAAQ,OAAO;CACrB,IAAI,UAAU,KAAA,KAAa,UAAU,QAAQ,UAAU,IAAI;EACzD,IAAI,UAAU,MAAM,IAAI,SAAS,eAAe,GAAG,KAAK,aAAa;EACrE;CACF;CACA,IAAI,OAAO,UAAU,UAAU,MAAM,IAAI,SAAS,eAAe,GAAG,KAAK,kBAAkB;CAC3F,OAAO;AACT;;AAEA,SAAgB,IAAI,QAAgB,MAAc,UAAkB,EAAE,MAAM,GAAG,MAAM,OAAO,kBAAkB,QAAQ,UAAU,CAAC,GAAW;CAC1I,MAAM,QAAQ,OAAO;CACrB,IAAI,UAAU,KAAA,KAAa,UAAU,MAAM,OAAO;CAClD,IAAI,OAAO,UAAU,YAAY,CAAC,OAAO,SAAS,KAAK,KAAK,QAAQ,OAAO,QAAQ,KAAK,MAAM,IAAI,SAAS,eAAe,GAAG,KAAK,aAAa,QAAQ,WAAW,GAAG,cAAc,IAAI,MAAM,KAAK;CAClM,IAAI,SAAS,CAAC,OAAO,cAAc,KAAK,GAAG,MAAM,IAAI,SAAS,eAAe,GAAG,KAAK,+BAA+B,IAAI,MAAM,KAAK;CACnI,OAAO;AACT;AACA,SAAgB,KAAK,QAAgB,MAAuB;CAC1D,MAAM,QAAQ,OAAO;CACrB,IAAI,UAAU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AG,EAAE;EAChJ,MAAM,MAAM,IAAI,IAAI,SAAS,SAAS;GACpC,IAAI;GACJ,IAAI;IAAE,QAAQ,MAAM,IAAI;GAAG,SAAS,OAAO;IAAE,aAAa,KAAK;IAAG,IAAI;IAAG,OAAO,KAAK;IAAG;GAAQ;GAChG,IAAI,UAAU,KAAA,GAAW;GACzB,aAAa,KAAK;GAClB,IAAI;GACJ,QAAQ,KAAK;EACf,CAAC;CACH,CAAC;AACH"}
@@ -1,2 +1,2 @@
1
- import { c as publishApp, d as verifyApp, l as revokeApp, s as initApp, u as signStore } from "./apps-DIQbzG08.js";
1
+ import { c as publishApp, d as verifyApp, l as revokeApp, s as initApp, u as signStore } from "./apps-C54T_MOT.js";
2
2
  export { initApp, publishApp, revokeApp, signStore, verifyApp };
@@ -1,7 +1,7 @@
1
- import { $l as seedSigner, Cl as setAppSignatureFastPath, Ku as fromBase64Url, Ol as canonicalJson, Qc as APP_BUNDLE_LIMITS, Sl as readAppRevocations, Tl as signAppRevocation, Xu as toZ32, Yu as toBase64Url, a as appRevocationFor, al as checkAppManifest, cl as readAppBundle, d as checkAppStoreIndex, dl as APP_PREFIXES, f as readAppStore, fl as APP_STATEMENT_LIMITS, gl as checkAppRevokeStatement, il as assembleAppBundle, kl as canonicalJsonBytes, m as signAppStore, ml as appRef, o as appStoreDecision, ol as isAppUrl, pl as appFingerprint, wl as signAppObject } from "./src-CCt5s4DK.js";
2
- import { t as guardText } from "./secretGuard-CSVNxXVW.js";
3
- import { i as localFileError, t as CliError } from "./errors-R4S2SAEM.js";
4
- import { _ as userPath } from "./profiles-DgIfvBeN.js";
1
+ import { Dl as signAppObject, El as setAppSignatureFastPath, Ml as canonicalJsonBytes, Ol as signAppRevocation, Qu as fromBase64Url, Tl as readAppRevocations, _l as appRef, a as appRevocationFor, cl as checkAppManifest, d as checkAppStoreIndex, dl as readAppBundle, f as readAppStore, gl as appFingerprint, hl as APP_STATEMENT_LIMITS, jl as canonicalJson, ll as isAppUrl, m as signAppStore, ml as APP_PREFIXES, nd as toZ32, nu as seedSigner, o as appStoreDecision, sl as assembleAppBundle, td as toBase64Url, tl as APP_BUNDLE_LIMITS, yl as checkAppRevokeStatement } from "./src-D31D1_oY.js";
2
+ import { t as guardText } from "./secretGuard-B7Hj0Kvz.js";
3
+ import { i as localFileError, t as CliError } from "./errors-Dt-ZnyOX.js";
4
+ import { _ as userPath } from "./profiles-DKmZGXp6.js";
5
5
  import { closeSync, existsSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync, writeSync } from "node:fs";
6
6
  import { basename, dirname, isAbsolute, join, relative, sep } from "node:path";
7
7
  import { createHash, createPrivateKey, createPublicKey, generateKeyPairSync, verify } from "node:crypto";
@@ -900,4 +900,4 @@ async function signStore(indexArg, keyArg, outArg, now = Math.floor(Date.now() /
900
900
  //#endregion
901
901
  export { STORE_SIG_FILE as a, publishApp as c, verifyApp as d, writeWhole as f, STORE_INDEX_FILE as i, revokeApp as l, APP_REVOKE_FILE as n, checkedBundle as o, APP_SOURCE as r, initApp as s, APP_BUNDLE_FILE as t, signStore as u };
902
902
 
903
- //# sourceMappingURL=apps-DIQbzG08.js.map
903
+ //# sourceMappingURL=apps-C54T_MOT.js.map