@bcts/frost-hubert 1.0.0-alpha.23 → 1.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/dist/bin/frost.cjs +345 -71
  2. package/dist/bin/frost.cjs.map +1 -1
  3. package/dist/bin/frost.mjs +345 -71
  4. package/dist/bin/frost.mjs.map +1 -1
  5. package/dist/busy-DkM2jAIZ.mjs +27 -0
  6. package/dist/busy-DkM2jAIZ.mjs.map +1 -0
  7. package/dist/busy-EZU7EKr6.cjs +38 -0
  8. package/dist/busy-EZU7EKr6.cjs.map +1 -0
  9. package/dist/cmd/index.cjs +28 -22
  10. package/dist/cmd/index.d.cts +2 -2
  11. package/dist/cmd/index.d.mts +2 -2
  12. package/dist/cmd/index.mjs +7 -3
  13. package/dist/cmd-Bw9_i2_f.cjs +130 -0
  14. package/dist/cmd-Bw9_i2_f.cjs.map +1 -0
  15. package/dist/cmd-CS1uJtuD.mjs +113 -0
  16. package/dist/cmd-CS1uJtuD.mjs.map +1 -0
  17. package/dist/common-CvH6dFvQ.mjs +282 -0
  18. package/dist/common-CvH6dFvQ.mjs.map +1 -0
  19. package/dist/common-DUWvtc08.mjs +96 -0
  20. package/dist/common-DUWvtc08.mjs.map +1 -0
  21. package/dist/common-lKP5EzHy.cjs +372 -0
  22. package/dist/common-lKP5EzHy.cjs.map +1 -0
  23. package/dist/common-lThIvJmZ.cjs +114 -0
  24. package/dist/common-lThIvJmZ.cjs.map +1 -0
  25. package/dist/dkg/index.cjs +6 -102
  26. package/dist/dkg/index.cjs.map +1 -1
  27. package/dist/dkg/index.d.cts +2 -2
  28. package/dist/dkg/index.d.mts +2 -2
  29. package/dist/dkg/index.mjs +4 -101
  30. package/dist/dkg/index.mjs.map +1 -1
  31. package/dist/finalize-BRgJK-Xv.cjs +402 -0
  32. package/dist/finalize-BRgJK-Xv.cjs.map +1 -0
  33. package/dist/finalize-BfLgzn8f.cjs +303 -0
  34. package/dist/finalize-BfLgzn8f.cjs.map +1 -0
  35. package/dist/finalize-CNTDj6aS.mjs +389 -0
  36. package/dist/finalize-CNTDj6aS.mjs.map +1 -0
  37. package/dist/finalize-EC3ikHQq.mjs +252 -0
  38. package/dist/finalize-EC3ikHQq.mjs.map +1 -0
  39. package/dist/finalize-IA01t_Qq.mjs +290 -0
  40. package/dist/finalize-IA01t_Qq.mjs.map +1 -0
  41. package/dist/finalize-UPyI1yb1.cjs +265 -0
  42. package/dist/finalize-UPyI1yb1.cjs.map +1 -0
  43. package/dist/{index-BkqLimZT.d.mts → index-B3c-80VS.d.cts} +26 -3
  44. package/dist/index-B3c-80VS.d.cts.map +1 -0
  45. package/dist/{index-BJlwbPYu.d.cts → index-BgbSGpxn.d.mts} +102 -80
  46. package/dist/index-BgbSGpxn.d.mts.map +1 -0
  47. package/dist/{index-BMbPgH0W.d.cts → index-C8QeHNwa.d.cts} +46 -2
  48. package/dist/{index-BMbPgH0W.d.cts.map → index-C8QeHNwa.d.cts.map} +1 -1
  49. package/dist/{index-DmxfT59Y.d.cts → index-D3QTWkEm.d.mts} +26 -3
  50. package/dist/index-D3QTWkEm.d.mts.map +1 -0
  51. package/dist/{index-DoV5HFvV.d.mts → index-DVbWyOs7.d.mts} +46 -2
  52. package/dist/{index-DoV5HFvV.d.mts.map → index-DVbWyOs7.d.mts.map} +1 -1
  53. package/dist/{index-Dzm1v4_4.d.mts → index-F1iNEAJR.d.cts} +102 -80
  54. package/dist/index-F1iNEAJR.d.cts.map +1 -0
  55. package/dist/index.cjs +31 -23
  56. package/dist/index.cjs.map +1 -1
  57. package/dist/index.d.cts +4 -4
  58. package/dist/index.d.mts +4 -4
  59. package/dist/index.mjs +9 -4
  60. package/dist/index.mjs.map +1 -1
  61. package/dist/invite-5277FQVT.cjs +274 -0
  62. package/dist/invite-5277FQVT.cjs.map +1 -0
  63. package/dist/invite-DUTcfTgX.cjs +109 -0
  64. package/dist/invite-DUTcfTgX.cjs.map +1 -0
  65. package/dist/invite-IU4n0dq2.mjs +96 -0
  66. package/dist/invite-IU4n0dq2.mjs.map +1 -0
  67. package/dist/invite-RU-OXTNS.mjs +219 -0
  68. package/dist/invite-RU-OXTNS.mjs.map +1 -0
  69. package/dist/parallel-D1R6ZGlY.cjs +318 -0
  70. package/dist/parallel-D1R6ZGlY.cjs.map +1 -0
  71. package/dist/parallel-D6zc6VW4.mjs +235 -0
  72. package/dist/parallel-D6zc6VW4.mjs.map +1 -0
  73. package/dist/proposed-participant-Dm1Eq6mX.cjs +141 -0
  74. package/dist/proposed-participant-Dm1Eq6mX.cjs.map +1 -0
  75. package/dist/proposed-participant-cWM7iUrO.mjs +129 -0
  76. package/dist/proposed-participant-cWM7iUrO.mjs.map +1 -0
  77. package/dist/receive-CAI-x4II.cjs +213 -0
  78. package/dist/receive-CAI-x4II.cjs.map +1 -0
  79. package/dist/receive-D2Nn68L7.mjs +188 -0
  80. package/dist/receive-D2Nn68L7.mjs.map +1 -0
  81. package/dist/receive-DA_KQEgk.mjs +177 -0
  82. package/dist/receive-DA_KQEgk.mjs.map +1 -0
  83. package/dist/receive-kZMsXhbK.cjs +190 -0
  84. package/dist/receive-kZMsXhbK.cjs.map +1 -0
  85. package/dist/registry/index.cjs +85 -10
  86. package/dist/registry/index.cjs.map +1 -1
  87. package/dist/registry/index.d.cts +1 -1
  88. package/dist/registry/index.d.mts +1 -1
  89. package/dist/registry/index.mjs +85 -10
  90. package/dist/registry/index.mjs.map +1 -1
  91. package/dist/{registry-loI1_Mh1.cjs → registry-9puTaRrD.cjs} +1 -1
  92. package/dist/{registry-loI1_Mh1.cjs.map → registry-9puTaRrD.cjs.map} +1 -1
  93. package/dist/{registry-CgrCZ4En.mjs → registry-BpCwtrRt.mjs} +1 -1
  94. package/dist/{registry-CgrCZ4En.mjs.map → registry-BpCwtrRt.mjs.map} +1 -1
  95. package/dist/round1-4Hyx8w0x.cjs +422 -0
  96. package/dist/round1-4Hyx8w0x.cjs.map +1 -0
  97. package/dist/round1-7v9LlE11.mjs +373 -0
  98. package/dist/round1-7v9LlE11.mjs.map +1 -0
  99. package/dist/round1-BHBjru1m.cjs +465 -0
  100. package/dist/round1-BHBjru1m.cjs.map +1 -0
  101. package/dist/round1-CMLKN2RR.mjs +195 -0
  102. package/dist/round1-CMLKN2RR.mjs.map +1 -0
  103. package/dist/round1-CWSXZx5R.cjs +208 -0
  104. package/dist/round1-CWSXZx5R.cjs.map +1 -0
  105. package/dist/round1-CcQCGlIT.mjs +208 -0
  106. package/dist/round1-CcQCGlIT.mjs.map +1 -0
  107. package/dist/round1-Cgm7j1kI.mjs +452 -0
  108. package/dist/round1-Cgm7j1kI.mjs.map +1 -0
  109. package/dist/round1-DQ0fnc1H.cjs +221 -0
  110. package/dist/round1-DQ0fnc1H.cjs.map +1 -0
  111. package/dist/round2-BWz9SQIi.cjs +305 -0
  112. package/dist/round2-BWz9SQIi.cjs.map +1 -0
  113. package/dist/round2-BkNRCXgS.mjs +292 -0
  114. package/dist/round2-BkNRCXgS.mjs.map +1 -0
  115. package/dist/round2-Bl2uK93U.mjs +450 -0
  116. package/dist/round2-Bl2uK93U.mjs.map +1 -0
  117. package/dist/round2-CdUT-AhH.cjs +499 -0
  118. package/dist/round2-CdUT-AhH.cjs.map +1 -0
  119. package/dist/round2-DOA3rnV-.mjs +280 -0
  120. package/dist/round2-DOA3rnV-.mjs.map +1 -0
  121. package/dist/round2-Dg24w-TU.mjs +397 -0
  122. package/dist/round2-Dg24w-TU.mjs.map +1 -0
  123. package/dist/round2-LylCa84n.cjs +293 -0
  124. package/dist/round2-LylCa84n.cjs.map +1 -0
  125. package/dist/round2-o2Q-GMbX.cjs +410 -0
  126. package/dist/round2-o2Q-GMbX.cjs.map +1 -0
  127. package/dist/storage-B-Gu68-O.cjs +79 -0
  128. package/dist/storage-B-Gu68-O.cjs.map +1 -0
  129. package/dist/storage-Bkkliz0K.mjs +74 -0
  130. package/dist/storage-Bkkliz0K.mjs.map +1 -0
  131. package/package.json +10 -10
  132. package/src/bin/frost.ts +849 -128
  133. package/src/cmd/common.ts +19 -1
  134. package/src/cmd/dkg/common.ts +97 -10
  135. package/src/cmd/dkg/coordinator/invite.ts +5 -2
  136. package/src/cmd/dkg/participant/finalize.ts +51 -17
  137. package/src/cmd/dkg/participant/round1.ts +39 -38
  138. package/src/cmd/dkg/participant/round2.ts +60 -26
  139. package/src/cmd/sign/coordinator/round2.ts +5 -1
  140. package/src/cmd/sign/participant/finalize.ts +6 -2
  141. package/src/cmd/sign/participant/receive.ts +5 -2
  142. package/src/dkg/group-invite.ts +12 -2
  143. package/src/dkg/proposed-participant.ts +32 -3
  144. package/src/registry/owner-record.ts +12 -0
  145. package/src/registry/participant-record.ts +35 -2
  146. package/src/registry/registry-impl.ts +74 -18
  147. package/dist/cmd-5yLeC_QL.mjs +0 -4708
  148. package/dist/cmd-5yLeC_QL.mjs.map +0 -1
  149. package/dist/cmd-BfZjC3Uh.cjs +0 -4847
  150. package/dist/cmd-BfZjC3Uh.cjs.map +0 -1
  151. package/dist/index-BJlwbPYu.d.cts.map +0 -1
  152. package/dist/index-BkqLimZT.d.mts.map +0 -1
  153. package/dist/index-DmxfT59Y.d.cts.map +0 -1
  154. package/dist/index-Dzm1v4_4.d.mts.map +0 -1
@@ -1,20 +1,56 @@
1
1
  #!/usr/bin/env node
2
2
  require("../chunk-CZWwpsFl.cjs");
3
- const require_registry = require("../registry-loI1_Mh1.cjs");
3
+ const require_storage = require("../storage-B-Gu68-O.cjs");
4
+ const require_registry = require("../registry-9puTaRrD.cjs");
4
5
  let commander = require("commander");
5
6
  //#region src/bin/frost.ts
6
7
  /**
7
8
  * Copyright © 2023-2026 Blockchain Commons, LLC
8
9
  * Copyright © 2025-2026 Parity Technologies
9
10
  *
10
- */
11
- /**
11
+ *
12
12
  * FROST CLI binary entry point.
13
13
  *
14
- * Port of main.rs and lib.rs CLI from frost-hubert-rust.
14
+ * Port of `frost-hubert-rust/src/main.rs` and the per-subcommand
15
+ * `clap::Parser` definitions in
16
+ * `frost-hubert-rust/src/cmd/{registry,dkg,sign}/...`.
17
+ *
18
+ * Each subcommand is a thin wrapper that:
19
+ * 1. parses CLI args into the matching `*Options` interface,
20
+ * 2. constructs a `StorageClient` if a backend is requested,
21
+ * 3. delegates to the library function in `src/cmd/...`,
22
+ * 4. prints the same single-line output Rust prints.
15
23
  *
16
24
  * @module
17
25
  */
26
+ const lazyDkgCoord = {
27
+ invite: () => Promise.resolve().then(() => require("../invite-DUTcfTgX.cjs")).then((n) => n.invite_exports).then((m) => m.invite),
28
+ round1: () => Promise.resolve().then(() => require("../round1-BHBjru1m.cjs")).then((n) => n.round1_exports).then((m) => m.round1),
29
+ round2: () => Promise.resolve().then(() => require("../round2-CdUT-AhH.cjs")).then((n) => n.round2_exports).then((m) => m.round2),
30
+ finalize: () => Promise.resolve().then(() => require("../finalize-BfLgzn8f.cjs")).then((n) => n.finalize_exports).then((m) => m.finalize)
31
+ };
32
+ const lazyDkgPart = {
33
+ receive: () => Promise.resolve().then(() => require("../receive-CAI-x4II.cjs")).then((n) => n.receive_exports).then((m) => m.receive),
34
+ round1: () => Promise.resolve().then(() => require("../round1-CWSXZx5R.cjs")).then((n) => n.round1_exports).then((m) => m.round1),
35
+ round2: () => Promise.resolve().then(() => require("../round2-LylCa84n.cjs")).then((n) => n.round2_exports).then((m) => m.round2),
36
+ finalize: () => Promise.resolve().then(() => require("../finalize-UPyI1yb1.cjs")).then((n) => n.finalize_exports).then((m) => m.finalize)
37
+ };
38
+ const lazySignCoord = {
39
+ invite: () => Promise.resolve().then(() => require("../invite-5277FQVT.cjs")).then((n) => n.invite_exports).then((m) => m.invite),
40
+ round1: () => Promise.resolve().then(() => require("../round1-4Hyx8w0x.cjs")).then((n) => n.round1_exports).then((m) => m.round1),
41
+ round2: () => Promise.resolve().then(() => require("../round2-o2Q-GMbX.cjs")).then((n) => n.round2_exports).then((m) => m.round2)
42
+ };
43
+ const lazySignPart = {
44
+ receive: () => Promise.resolve().then(() => require("../receive-kZMsXhbK.cjs")).then((n) => n.receive_exports).then((m) => m.receive),
45
+ round1: () => Promise.resolve().then(() => require("../round1-DQ0fnc1H.cjs")).then((n) => n.round1_exports).then((m) => m.round1),
46
+ round2: () => Promise.resolve().then(() => require("../round2-BWz9SQIi.cjs")).then((n) => n.round2_exports).then((m) => m.round2),
47
+ finalize: () => Promise.resolve().then(() => require("../finalize-BRgJK-Xv.cjs")).then((n) => n.finalize_exports).then((m) => m.finalize)
48
+ };
49
+ /**
50
+ * Initialize the global CBOR tag registry. Mirrors the
51
+ * Rust `lib.rs::run` initialization step (`bc_components::register_tags();`
52
+ * `bc_envelope::register_tags();` `provenance_mark::register_tags();`).
53
+ */
18
54
  async function registerTags() {
19
55
  try {
20
56
  const components = await import("@bcts/components");
@@ -25,86 +61,324 @@ async function registerTags() {
25
61
  if (typeof provenanceMark.registerTags === "function") provenanceMark.registerTags();
26
62
  } catch {}
27
63
  }
28
- async function main() {
29
- await registerTags();
30
- commander.program.name("frost").description("FROST threshold signing CLI").version("1.0.0");
31
- const registryCmd = commander.program.command("registry").description("Manage the registry");
32
- registryCmd.command("owner").description("Manage the registry owner").command("set <xid-document> [pet-name]").description("Set the registry owner using an ur:xid document that includes private keys").option("-r, --registry <path>", "Registry path or filename override").action((xidDocument, petName, options) => {
33
- try {
34
- require_registry.ownerSet({
35
- xidDocument,
36
- petName,
37
- registryPath: options.registry
38
- }, process.cwd());
39
- } catch (error) {
40
- console.error(error.message);
64
+ function isStorageSelection(value) {
65
+ return value === "server" || value === "mainline" || value === "ipfs" || value === "hybrid";
66
+ }
67
+ function parseStorageSelection(opts) {
68
+ const value = opts.storage;
69
+ if (value === void 0) return void 0;
70
+ if (!isStorageSelection(value)) throw new Error(`Unknown --storage value: ${String(value)}`);
71
+ return value;
72
+ }
73
+ async function buildClient(opts) {
74
+ const selection = parseStorageSelection(opts);
75
+ if (selection === void 0) return void 0;
76
+ return require_storage.createStorageClient(selection, opts.host !== void 0 && opts.port !== void 0 ? `http://${opts.host}:${opts.port}` : opts.host);
77
+ }
78
+ /** Convert a comma-separated, repeated-flag, or positional list. */
79
+ function asStringArray(value) {
80
+ if (Array.isArray(value)) return value;
81
+ if (typeof value === "string") return [value];
82
+ return [];
83
+ }
84
+ function asNumber(value) {
85
+ if (value === void 0 || value === null) return void 0;
86
+ if (typeof value !== "string" && typeof value !== "number") throw new Error(`Expected a number, got: ${typeof value}`);
87
+ const n = Number(value);
88
+ if (Number.isNaN(n)) throw new Error(`Expected a number, got: ${value}`);
89
+ return n;
90
+ }
91
+ function defined(obj) {
92
+ const out = {};
93
+ for (const [key, value] of Object.entries(obj)) if (value !== void 0) out[key] = value;
94
+ return out;
95
+ }
96
+ /**
97
+ * Wrap a CLI action handler so any thrown error prints to stderr and
98
+ * exits with code 1. Mirrors Rust's `anyhow::Result<()>` propagation.
99
+ */
100
+ function runAsync(handler) {
101
+ return (...args) => {
102
+ handler(...args).catch((err) => {
103
+ console.error(err instanceof Error ? err.message : String(err));
41
104
  process.exit(1);
42
- }
43
- });
44
- registryCmd.command("participant").description("Manage registry participants").command("add <xid-document> [pet-name]").description("Add a participant using an ur:xid document").option("-r, --registry <path>", "Registry path or filename override").action((xidDocument, petName, options) => {
105
+ });
106
+ };
107
+ }
108
+ function runSync(handler) {
109
+ return (...args) => {
45
110
  try {
46
- require_registry.participantAdd({
47
- xidDocument,
48
- petName,
49
- registryPath: options.registry
50
- }, process.cwd());
51
- } catch (error) {
52
- console.error(error.message);
111
+ handler(...args);
112
+ } catch (err) {
113
+ console.error(err instanceof Error ? err.message : String(err));
53
114
  process.exit(1);
54
115
  }
55
- });
116
+ };
117
+ }
118
+ const addStorageOpts = (cmd) => cmd.option("--storage <selection>", "Storage backend (server|mainline|ipfs|hybrid)").option("--host <host>", "Server host (server backend only)").option("--port <port>", "Server port (server backend only)");
119
+ const addRegistryOpt = (cmd) => cmd.option("-r, --registry <path>", "Registry path or filename override");
120
+ const addTimeoutOpt = (cmd) => cmd.option("--timeout <seconds>", "Wait up to this many seconds");
121
+ async function main() {
122
+ await registerTags();
123
+ commander.program.name("frost").description("FROST threshold signing CLI").version("1.0.0");
124
+ const registryCmd = commander.program.command("registry").description("Manage the registry");
125
+ registryCmd.command("owner").description("Manage the registry owner").command("set <xid-document> [pet-name]").description("Set the registry owner using an ur:xid document that includes private keys").option("-r, --registry <path>", "Registry path or filename override").action(runSync((xidDocument, petName, options) => {
126
+ require_registry.ownerSet({
127
+ xidDocument,
128
+ petName,
129
+ registryPath: options.registry
130
+ }, process.cwd());
131
+ }));
132
+ registryCmd.command("participant").description("Manage registry participants").command("add <xid-document> [pet-name]").description("Add a participant using an ur:xid document").option("-r, --registry <path>", "Registry path or filename override").action(runSync((xidDocument, petName, options) => {
133
+ require_registry.participantAdd({
134
+ xidDocument,
135
+ petName,
136
+ registryPath: options.registry
137
+ }, process.cwd());
138
+ }));
56
139
  const dkgCmd = commander.program.command("dkg").description("Distributed Key Generation commands");
57
140
  const dkgCoordinatorCmd = dkgCmd.command("coordinator").description("DKG coordinator commands");
58
- dkgCoordinatorCmd.command("invite").description("Send DKG invite to participants").action(() => {
59
- console.log("DKG coordinator invite command not yet implemented");
60
- });
61
- dkgCoordinatorCmd.command("round1").description("Collect round 1 responses").action(() => {
62
- console.log("DKG coordinator round1 command not yet implemented");
63
- });
64
- dkgCoordinatorCmd.command("round2").description("Collect round 2 responses").action(() => {
65
- console.log("DKG coordinator round2 command not yet implemented");
66
- });
141
+ addStorageOpts(addRegistryOpt(dkgCoordinatorCmd.command("invite <participants...>").description("Compose or send a DKG invite").option("--min-signers <n>", "Minimum signers required; defaults to participant count").option("--charter <string>", "Charter statement for the DKG group", "").option("--valid-days <days>", "Days the invite is valid for", "30").option("--preview", "Print the preview invite envelope UR instead of the sealed envelope"))).action(runAsync(async (participants, opts) => {
142
+ if (parseStorageSelection(opts) !== void 0 && opts.preview === true) throw new Error("--preview cannot be used with Hubert storage options");
143
+ const client = await buildClient(opts);
144
+ const result = await (await lazyDkgCoord.invite())(client ?? noOpClient(), {
145
+ charter: opts.charter ?? "",
146
+ validDays: asNumber(opts.validDays) ?? 30,
147
+ participantNames: asStringArray(participants),
148
+ ...defined({
149
+ registryPath: opts.registry,
150
+ minSigners: asNumber(opts.minSigners)
151
+ })
152
+ }, process.cwd());
153
+ console.log(result.envelopeUr);
154
+ }));
155
+ addStorageOpts(addTimeoutOpt(addRegistryOpt(dkgCoordinatorCmd.command("round1 <group-id>").description("Collect round 1 responses").option("--preview", "Preview one of the round 2 requests while sending").option("--parallel", "Use parallel fetch/send")))).action(runAsync(async (groupId, opts) => {
156
+ const client = await buildClient(opts);
157
+ if (client === void 0) throw new Error("dkg coordinator round1 requires --storage");
158
+ const result = await (await lazyDkgCoord.round1())(client, {
159
+ groupId,
160
+ ...defined({
161
+ registryPath: opts.registry,
162
+ timeoutSeconds: asNumber(opts.timeout),
163
+ preview: opts.preview,
164
+ parallel: opts.parallel
165
+ })
166
+ }, process.cwd());
167
+ console.log(JSON.stringify(result));
168
+ }));
169
+ addStorageOpts(addTimeoutOpt(addRegistryOpt(dkgCoordinatorCmd.command("round2 <group-id>").description("Collect round 2 responses").option("--preview", "Preview one of the finalize requests while sending").option("--parallel", "Use parallel fetch/send")))).action(runAsync(async (groupId, opts) => {
170
+ const client = await buildClient(opts);
171
+ if (client === void 0) throw new Error("dkg coordinator round2 requires --storage");
172
+ const result = await (await lazyDkgCoord.round2())(client, {
173
+ groupId,
174
+ ...defined({
175
+ registryPath: opts.registry,
176
+ timeoutSeconds: asNumber(opts.timeout),
177
+ preview: opts.preview,
178
+ parallel: opts.parallel
179
+ })
180
+ }, process.cwd());
181
+ console.log(JSON.stringify(result));
182
+ }));
183
+ addStorageOpts(addTimeoutOpt(addRegistryOpt(dkgCoordinatorCmd.command("finalize <group-id>").description("Collect finalize responses").option("--parallel", "Use parallel fetch")))).action(runAsync(async (groupId, opts) => {
184
+ const client = await buildClient(opts);
185
+ if (client === void 0) throw new Error("dkg coordinator finalize requires --storage");
186
+ const result = await (await lazyDkgCoord.finalize())(client, {
187
+ groupId,
188
+ ...defined({
189
+ registryPath: opts.registry,
190
+ timeoutSeconds: asNumber(opts.timeout),
191
+ parallel: opts.parallel
192
+ })
193
+ }, process.cwd());
194
+ console.log(result.verifyingKey);
195
+ }));
67
196
  const dkgParticipantCmd = dkgCmd.command("participant").description("DKG participant commands");
68
- dkgParticipantCmd.command("receive").description("Receive DKG invite").action(() => {
69
- console.log("DKG participant receive command not yet implemented");
70
- });
71
- dkgParticipantCmd.command("round1").description("Send round 1 response").action(() => {
72
- console.log("DKG participant round1 command not yet implemented");
73
- });
74
- dkgParticipantCmd.command("round2").description("Send round 2 response").action(() => {
75
- console.log("DKG participant round2 command not yet implemented");
76
- });
77
- dkgParticipantCmd.command("finalize").description("Receive finalize package").action(() => {
78
- console.log("DKG participant finalize command not yet implemented");
79
- });
197
+ addStorageOpts(addTimeoutOpt(addRegistryOpt(dkgParticipantCmd.command("receive <invite>").description("Receive a DKG invite (ur:arid or ur:envelope)").option("--no-envelope", "Suppress printing the invite envelope UR").option("--info", "Show invite details").option("--sender <sender>", "Require the invite to come from this sender")))).action(runAsync(async (invite, opts) => {
198
+ const selection = parseStorageSelection(opts);
199
+ const client = await buildClient(opts);
200
+ const result = await (await lazyDkgPart.receive())(client, {
201
+ invite,
202
+ noEnvelope: opts.envelope === false,
203
+ ...defined({
204
+ registryPath: opts.registry,
205
+ timeoutSeconds: asNumber(opts.timeout),
206
+ info: opts.info,
207
+ sender: opts.sender,
208
+ storageSelection: selection
209
+ })
210
+ }, process.cwd());
211
+ if (result.envelopeUr !== void 0) console.log(result.envelopeUr);
212
+ }));
213
+ addStorageOpts(addTimeoutOpt(addRegistryOpt(dkgParticipantCmd.command("round1 <invite>").description("Send round 1 response").option("--response-arid <ur>", "Optional ARID for the next response").option("--preview", "Print the preview response envelope UR instead").option("--reject <reason>", "Reject the invite with the provided reason").option("--sender <sender>", "Require the invite to come from this sender")))).action(runAsync(async (invite, opts) => {
214
+ const selection = parseStorageSelection(opts);
215
+ const client = await buildClient(opts);
216
+ const result = await (await lazyDkgPart.round1())(client, {
217
+ invite,
218
+ ...defined({
219
+ registryPath: opts.registry,
220
+ timeoutSeconds: asNumber(opts.timeout),
221
+ responseArid: opts.responseArid,
222
+ preview: opts.preview,
223
+ rejectReason: opts.reject,
224
+ sender: opts.sender,
225
+ storageSelection: selection
226
+ })
227
+ }, process.cwd());
228
+ if (result.envelopeUr !== void 0) console.log(result.envelopeUr);
229
+ else if (result.listeningArid !== void 0) console.log(result.listeningArid);
230
+ }));
231
+ addStorageOpts(addTimeoutOpt(addRegistryOpt(dkgParticipantCmd.command("round2 <group-id>").description("Send round 2 response").option("--preview", "Also print the preview response envelope")))).action(runAsync(async (groupId, opts) => {
232
+ const selection = parseStorageSelection(opts);
233
+ const client = await buildClient(opts);
234
+ const result = await (await lazyDkgPart.round2())(client, {
235
+ groupId,
236
+ ...defined({
237
+ registryPath: opts.registry,
238
+ timeoutSeconds: asNumber(opts.timeout),
239
+ preview: opts.preview,
240
+ storageSelection: selection
241
+ })
242
+ }, process.cwd());
243
+ if (result.envelopeUr !== void 0) console.log(result.envelopeUr);
244
+ else console.log(result.listeningArid);
245
+ }));
246
+ addStorageOpts(addTimeoutOpt(addRegistryOpt(dkgParticipantCmd.command("finalize <group-id>").description("Receive finalize package").option("--preview", "Also print the preview response envelope")))).action(runAsync(async (groupId, opts) => {
247
+ const selection = parseStorageSelection(opts);
248
+ const client = await buildClient(opts);
249
+ const result = await (await lazyDkgPart.finalize())(client, {
250
+ groupId,
251
+ ...defined({
252
+ registryPath: opts.registry,
253
+ timeoutSeconds: asNumber(opts.timeout),
254
+ preview: opts.preview,
255
+ storageSelection: selection
256
+ })
257
+ }, process.cwd());
258
+ console.log(result.verifyingKey);
259
+ }));
80
260
  const signCmd = commander.program.command("sign").description("Threshold signing commands");
81
261
  const signCoordinatorCmd = signCmd.command("coordinator").description("Sign coordinator commands");
82
- signCoordinatorCmd.command("invite").description("Send sign invite to participants").action(() => {
83
- console.log("Sign coordinator invite command not yet implemented");
84
- });
85
- signCoordinatorCmd.command("round1").description("Collect round 1 responses").action(() => {
86
- console.log("Sign coordinator round1 command not yet implemented");
87
- });
88
- signCoordinatorCmd.command("round2").description("Collect round 2 responses and finalize signature").action(() => {
89
- console.log("Sign coordinator round2 command not yet implemented");
90
- });
262
+ addStorageOpts(addRegistryOpt(signCoordinatorCmd.command("invite <group-id>").description("Send sign invite to participants").requiredOption("--target <path>", "Path to a file containing the target envelope UR").option("--preview", "Print the preview request envelope UR instead of sending"))).action(runAsync(async (groupId, opts) => {
263
+ const client = await buildClient(opts);
264
+ const result = await (await lazySignCoord.invite())(client, {
265
+ groupId,
266
+ targetFile: opts.target,
267
+ ...defined({
268
+ registryPath: opts.registry,
269
+ preview: opts.preview
270
+ })
271
+ }, process.cwd());
272
+ console.log(result.startArid);
273
+ }));
274
+ addStorageOpts(addTimeoutOpt(addRegistryOpt(signCoordinatorCmd.command("round1 <session-id>").description("Collect round 1 (commitment) responses").option("--group <ur:arid>", "Optional group ID hint").option("--preview-share", "Print a sample unsealed signRound2 request").option("--parallel", "Use parallel fetch/send")))).action(runAsync(async (sessionId, opts) => {
275
+ const client = await buildClient(opts);
276
+ if (client === void 0) throw new Error("sign coordinator round1 requires --storage");
277
+ const result = await (await lazySignCoord.round1())(client, {
278
+ sessionId,
279
+ ...defined({
280
+ registryPath: opts.registry,
281
+ groupId: opts.group,
282
+ timeoutSeconds: asNumber(opts.timeout),
283
+ previewShare: opts.previewShare,
284
+ parallel: opts.parallel
285
+ })
286
+ }, process.cwd());
287
+ console.log(JSON.stringify(result));
288
+ }));
289
+ addStorageOpts(addTimeoutOpt(addRegistryOpt(signCoordinatorCmd.command("round2 <session-id>").description("Collect round 2 responses and finalize signature").option("--group <ur:arid>", "Optional group ID hint").option("--preview-finalize", "Print a sample unsealed finalize package").option("--parallel", "Use parallel fetch/send")))).action(runAsync(async (sessionId, opts) => {
290
+ const client = await buildClient(opts);
291
+ if (client === void 0) throw new Error("sign coordinator round2 requires --storage");
292
+ const result = await (await lazySignCoord.round2())(client, {
293
+ sessionId,
294
+ ...defined({
295
+ registryPath: opts.registry,
296
+ groupId: opts.group,
297
+ timeoutSeconds: asNumber(opts.timeout),
298
+ previewFinalize: opts.previewFinalize,
299
+ parallel: opts.parallel
300
+ })
301
+ }, process.cwd());
302
+ console.log(result.signedEnvelope);
303
+ }));
91
304
  const signParticipantCmd = signCmd.command("participant").description("Sign participant commands");
92
- signParticipantCmd.command("receive").description("Receive sign invite").action(() => {
93
- console.log("Sign participant receive command not yet implemented");
94
- });
95
- signParticipantCmd.command("round1").description("Send commitment").action(() => {
96
- console.log("Sign participant round1 command not yet implemented");
97
- });
98
- signParticipantCmd.command("round2").description("Send signature share").action(() => {
99
- console.log("Sign participant round2 command not yet implemented");
100
- });
101
- signParticipantCmd.command("finalize").description("Receive finalize event").action(() => {
102
- console.log("Sign participant finalize command not yet implemented");
103
- });
305
+ addStorageOpts(addTimeoutOpt(addRegistryOpt(signParticipantCmd.command("receive <request>").description("Receive a signInvite request (ur:arid or ur:envelope)").option("--info", "Show request details").option("--sender <sender>", "Require the request to come from this sender")))).action(runAsync(async (request, opts) => {
306
+ const selection = parseStorageSelection(opts);
307
+ const client = await buildClient(opts);
308
+ const result = await (await lazySignPart.receive())(client, selection, {
309
+ request,
310
+ ...defined({
311
+ registryPath: opts.registry,
312
+ timeoutSeconds: asNumber(opts.timeout),
313
+ info: opts.info,
314
+ sender: opts.sender
315
+ })
316
+ }, process.cwd());
317
+ console.log(JSON.stringify(result));
318
+ }));
319
+ addStorageOpts(addRegistryOpt(signParticipantCmd.command("round1 <session-id>").description("Send commitment").option("--preview", "Print the preview response envelope UR instead of sending").option("--reject <reason>", "Reject the signInvite request with the provided reason").option("--group <ur:arid>", "Optional group ID hint"))).action(runAsync(async (sessionId, opts) => {
320
+ const selection = parseStorageSelection(opts);
321
+ const client = await buildClient(opts);
322
+ const result = await (await lazySignPart.round1())(client, {
323
+ sessionId,
324
+ ...defined({
325
+ registryPath: opts.registry,
326
+ groupId: opts.group,
327
+ preview: opts.preview,
328
+ rejectReason: opts.reject,
329
+ storageSelection: selection
330
+ })
331
+ }, process.cwd());
332
+ if (result.envelopeUr !== void 0) console.log(result.envelopeUr);
333
+ else if (result.listeningArid !== void 0) console.log(result.listeningArid);
334
+ }));
335
+ addStorageOpts(addTimeoutOpt(addRegistryOpt(signParticipantCmd.command("round2 <session-id>").description("Send signature share").option("--preview", "Print the unsealed response envelope UR instead of sending").option("--group <ur:arid>", "Optional group ID hint")))).action(runAsync(async (sessionId, opts) => {
336
+ const client = await buildClient(opts);
337
+ if (client === void 0) throw new Error("sign participant round2 requires --storage");
338
+ const result = await (await lazySignPart.round2())(client, {
339
+ sessionId,
340
+ ...defined({
341
+ registryPath: opts.registry,
342
+ groupId: opts.group,
343
+ timeoutSeconds: asNumber(opts.timeout),
344
+ preview: opts.preview
345
+ })
346
+ }, process.cwd());
347
+ console.log(result.listeningArid);
348
+ }));
349
+ addStorageOpts(addTimeoutOpt(addRegistryOpt(signParticipantCmd.command("finalize <session-id>").description("Receive finalize event").option("--group <ur:arid>", "Optional group ID hint")))).action(runAsync(async (sessionId, opts) => {
350
+ const client = await buildClient(opts);
351
+ if (client === void 0) throw new Error("sign participant finalize requires --storage");
352
+ const result = await (await lazySignPart.finalize())(client, {
353
+ sessionId,
354
+ ...defined({
355
+ registryPath: opts.registry,
356
+ groupId: opts.group,
357
+ timeoutSeconds: asNumber(opts.timeout)
358
+ })
359
+ }, process.cwd());
360
+ console.log(result.signature);
361
+ }));
104
362
  commander.program.parse();
105
363
  }
364
+ /**
365
+ * Build a no-op StorageClient for preview-only paths (the
366
+ * coordinator-invite library expects a defined client even when no
367
+ * envelope is sent, because it threads through some helpers).
368
+ *
369
+ * Mirrors Rust's behaviour: `--preview` skips the
370
+ * `StorageClient::from_selection` call entirely, but the underlying
371
+ * library still walks through the same code path with a stub.
372
+ */
373
+ function noOpClient() {
374
+ return {
375
+ put: () => Promise.reject(/* @__PURE__ */ new Error("no-op storage client used in preview mode")),
376
+ get: () => Promise.reject(/* @__PURE__ */ new Error("no-op storage client used in preview mode")),
377
+ exists: () => Promise.resolve(false)
378
+ };
379
+ }
106
380
  main().catch((error) => {
107
- console.error(error.message);
381
+ console.error(error instanceof Error ? error.message : String(error));
108
382
  process.exit(1);
109
383
  });
110
384
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"frost.cjs","names":["program"],"sources":["../../src/bin/frost.ts"],"sourcesContent":["#!/usr/bin/env node\n/**\n * Copyright © 2023-2026 Blockchain Commons, LLC\n * Copyright © 2025-2026 Parity Technologies\n *\n */\n\n/**\n * FROST CLI binary entry point.\n *\n * Port of main.rs and lib.rs CLI from frost-hubert-rust.\n *\n * @module\n */\n\nimport { program } from \"commander\";\n\nimport { ownerSet } from \"../cmd/registry/owner/set.js\";\nimport { participantAdd } from \"../cmd/registry/participant/add.js\";\n\n// Type for modules that may have registerTags\ninterface TagModule {\n registerTags?: () => void;\n}\n\n// Register CBOR tags using dynamic import\nasync function registerTags(): Promise<void> {\n try {\n const components = (await import(\"@bcts/components\")) as TagModule;\n const envelope = (await import(\"@bcts/envelope\")) as TagModule;\n const provenanceMark = (await import(\"@bcts/provenance-mark\")) as TagModule;\n\n if (typeof components.registerTags === \"function\") {\n components.registerTags();\n }\n if (typeof envelope.registerTags === \"function\") {\n envelope.registerTags();\n }\n if (typeof provenanceMark.registerTags === \"function\") {\n provenanceMark.registerTags();\n }\n } catch {\n // Tags may not need registration in this context\n }\n}\n\n// Main CLI function\nasync function main(): Promise<void> {\n // Initialize tags before CLI runs\n await registerTags();\n\n program.name(\"frost\").description(\"FROST threshold signing CLI\").version(\"1.0.0\");\n\n // Registry commands\n const registryCmd = program.command(\"registry\").description(\"Manage the registry\");\n\n // Registry owner commands\n const ownerCmd = registryCmd.command(\"owner\").description(\"Manage the registry owner\");\n\n ownerCmd\n .command(\"set <xid-document> [pet-name]\")\n .description(\"Set the registry owner using an ur:xid document that includes private keys\")\n .option(\"-r, --registry <path>\", \"Registry path or filename override\")\n .action((xidDocument: string, petName: string | undefined, options: { registry?: string }) => {\n try {\n ownerSet(\n {\n xidDocument,\n petName,\n registryPath: options.registry,\n },\n process.cwd(),\n );\n } catch (error) {\n console.error((error as Error).message);\n process.exit(1);\n }\n });\n\n // Registry participant commands\n const participantCmd = registryCmd\n .command(\"participant\")\n .description(\"Manage registry participants\");\n\n participantCmd\n .command(\"add <xid-document> [pet-name]\")\n .description(\"Add a participant using an ur:xid document\")\n .option(\"-r, --registry <path>\", \"Registry path or filename override\")\n .action((xidDocument: string, petName: string | undefined, options: { registry?: string }) => {\n try {\n participantAdd(\n {\n xidDocument,\n petName,\n registryPath: options.registry,\n },\n process.cwd(),\n );\n } catch (error) {\n console.error((error as Error).message);\n process.exit(1);\n }\n });\n\n // DKG commands (placeholder)\n const dkgCmd = program.command(\"dkg\").description(\"Distributed Key Generation commands\");\n\n const dkgCoordinatorCmd = dkgCmd.command(\"coordinator\").description(\"DKG coordinator commands\");\n dkgCoordinatorCmd\n .command(\"invite\")\n .description(\"Send DKG invite to participants\")\n .action(() => {\n console.log(\"DKG coordinator invite command not yet implemented\");\n });\n\n dkgCoordinatorCmd\n .command(\"round1\")\n .description(\"Collect round 1 responses\")\n .action(() => {\n console.log(\"DKG coordinator round1 command not yet implemented\");\n });\n\n dkgCoordinatorCmd\n .command(\"round2\")\n .description(\"Collect round 2 responses\")\n .action(() => {\n console.log(\"DKG coordinator round2 command not yet implemented\");\n });\n\n const dkgParticipantCmd = dkgCmd.command(\"participant\").description(\"DKG participant commands\");\n dkgParticipantCmd\n .command(\"receive\")\n .description(\"Receive DKG invite\")\n .action(() => {\n console.log(\"DKG participant receive command not yet implemented\");\n });\n\n dkgParticipantCmd\n .command(\"round1\")\n .description(\"Send round 1 response\")\n .action(() => {\n console.log(\"DKG participant round1 command not yet implemented\");\n });\n\n dkgParticipantCmd\n .command(\"round2\")\n .description(\"Send round 2 response\")\n .action(() => {\n console.log(\"DKG participant round2 command not yet implemented\");\n });\n\n dkgParticipantCmd\n .command(\"finalize\")\n .description(\"Receive finalize package\")\n .action(() => {\n console.log(\"DKG participant finalize command not yet implemented\");\n });\n\n // Sign commands (placeholder)\n const signCmd = program.command(\"sign\").description(\"Threshold signing commands\");\n\n const signCoordinatorCmd = signCmd\n .command(\"coordinator\")\n .description(\"Sign coordinator commands\");\n signCoordinatorCmd\n .command(\"invite\")\n .description(\"Send sign invite to participants\")\n .action(() => {\n console.log(\"Sign coordinator invite command not yet implemented\");\n });\n\n signCoordinatorCmd\n .command(\"round1\")\n .description(\"Collect round 1 responses\")\n .action(() => {\n console.log(\"Sign coordinator round1 command not yet implemented\");\n });\n\n signCoordinatorCmd\n .command(\"round2\")\n .description(\"Collect round 2 responses and finalize signature\")\n .action(() => {\n console.log(\"Sign coordinator round2 command not yet implemented\");\n });\n\n const signParticipantCmd = signCmd\n .command(\"participant\")\n .description(\"Sign participant commands\");\n signParticipantCmd\n .command(\"receive\")\n .description(\"Receive sign invite\")\n .action(() => {\n console.log(\"Sign participant receive command not yet implemented\");\n });\n\n signParticipantCmd\n .command(\"round1\")\n .description(\"Send commitment\")\n .action(() => {\n console.log(\"Sign participant round1 command not yet implemented\");\n });\n\n signParticipantCmd\n .command(\"round2\")\n .description(\"Send signature share\")\n .action(() => {\n console.log(\"Sign participant round2 command not yet implemented\");\n });\n\n signParticipantCmd\n .command(\"finalize\")\n .description(\"Receive finalize event\")\n .action(() => {\n console.log(\"Sign participant finalize command not yet implemented\");\n });\n\n program.parse();\n}\n\nmain().catch((error: unknown) => {\n console.error((error as Error).message);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;AA0BA,eAAe,eAA8B;AAC3C,KAAI;EACF,MAAM,aAAc,MAAM,OAAO;EACjC,MAAM,WAAY,MAAM,OAAO;EAC/B,MAAM,iBAAkB,MAAM,OAAO;AAErC,MAAI,OAAO,WAAW,iBAAiB,WACrC,YAAW,cAAc;AAE3B,M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aAAa;AACZ,UAAQ,IAAI,sDAAsD;GAClE;AAEJ,oBACG,QAAQ,WAAW,CACnB,YAAY,yBAAyB,CACrC,aAAa;AACZ,UAAQ,IAAI,wDAAwD;GACpE;AAEJ,WAAA,QAAQ,OAAO;;AAGjB,MAAM,CAAC,OAAO,UAAmB;AAC/B,SAAQ,MAAO,MAAgB,QAAQ;AACvC,SAAQ,KAAK,EAAE;EACf"}
1
+ {"version":3,"file":"frost.cjs","names":["createStorageClient","program"],"sources":["../../src/bin/frost.ts"],"sourcesContent":["#!/usr/bin/env node\n/**\n * Copyright © 2023-2026 Blockchain Commons, LLC\n * Copyright © 2025-2026 Parity Technologies\n *\n *\n * FROST CLI binary entry point.\n *\n * Port of `frost-hubert-rust/src/main.rs` and the per-subcommand\n * `clap::Parser` definitions in\n * `frost-hubert-rust/src/cmd/{registry,dkg,sign}/...`.\n *\n * Each subcommand is a thin wrapper that:\n * 1. parses CLI args into the matching `*Options` interface,\n * 2. constructs a `StorageClient` if a backend is requested,\n * 3. delegates to the library function in `src/cmd/...`,\n * 4. prints the same single-line output Rust prints.\n *\n * @module\n */\n\nimport { program } from \"commander\";\n\nimport { ownerSet } from \"../cmd/registry/owner/set.js\";\nimport { participantAdd } from \"../cmd/registry/participant/add.js\";\nimport { type StorageClient, type StorageSelection, createStorageClient } from \"../cmd/storage.js\";\n\n// DKG / sign command modules transitively load `@frosts/core`, whose\n// published dist auto-imports `vitest` as a side-effect (a known\n// upstream packaging bug). Importing them at module-load time would\n// crash the registry-only CLI, so we lazy-import them inside the\n// command handlers below. Once `@frosts/core` ships a clean dist this\n// can be flipped back to static imports.\nconst lazyDkgCoord = {\n invite: () => import(\"../cmd/dkg/coordinator/invite.js\").then((m) => m.invite),\n round1: () => import(\"../cmd/dkg/coordinator/round1.js\").then((m) => m.round1),\n round2: () => import(\"../cmd/dkg/coordinator/round2.js\").then((m) => m.round2),\n finalize: () => import(\"../cmd/dkg/coordinator/finalize.js\").then((m) => m.finalize),\n};\nconst lazyDkgPart = {\n receive: () => import(\"../cmd/dkg/participant/receive.js\").then((m) => m.receive),\n round1: () => import(\"../cmd/dkg/participant/round1.js\").then((m) => m.round1),\n round2: () => import(\"../cmd/dkg/participant/round2.js\").then((m) => m.round2),\n finalize: () => import(\"../cmd/dkg/participant/finalize.js\").then((m) => m.finalize),\n};\nconst lazySignCoord = {\n invite: () => import(\"../cmd/sign/coordinator/invite.js\").then((m) => m.invite),\n round1: () => import(\"../cmd/sign/coordinator/round1.js\").then((m) => m.round1),\n round2: () => import(\"../cmd/sign/coordinator/round2.js\").then((m) => m.round2),\n};\nconst lazySignPart = {\n receive: () => import(\"../cmd/sign/participant/receive.js\").then((m) => m.receive),\n round1: () => import(\"../cmd/sign/participant/round1.js\").then((m) => m.round1),\n round2: () => import(\"../cmd/sign/participant/round2.js\").then((m) => m.round2),\n finalize: () => import(\"../cmd/sign/participant/finalize.js\").then((m) => m.finalize),\n};\n\n// Type for modules that may have registerTags\ninterface TagModule {\n registerTags?: () => void;\n}\n\n/**\n * Initialize the global CBOR tag registry. Mirrors the\n * Rust `lib.rs::run` initialization step (`bc_components::register_tags();`\n * `bc_envelope::register_tags();` `provenance_mark::register_tags();`).\n */\nasync function registerTags(): Promise<void> {\n try {\n const components = (await import(\"@bcts/components\")) as TagModule;\n const envelope = (await import(\"@bcts/envelope\")) as TagModule;\n const provenanceMark = (await import(\"@bcts/provenance-mark\")) as TagModule;\n\n if (typeof components.registerTags === \"function\") {\n components.registerTags();\n }\n if (typeof envelope.registerTags === \"function\") {\n envelope.registerTags();\n }\n if (typeof provenanceMark.registerTags === \"function\") {\n provenanceMark.registerTags();\n }\n } catch {\n // Tags may not need registration in this context\n }\n}\n\n/**\n * Storage-related CLI options shared across most subcommands.\n *\n * Mirrors Rust `OptionalStorageSelector` (clap-flatten) — the user can\n * pass exactly one of `--storage server|mainline|ipfs|hybrid` to enable\n * a Hubert backend. When omitted, the subcommand runs in local-only\n * preview/state mode.\n */\ninterface StorageOpts {\n storage?: StorageSelection;\n host?: string;\n port?: string;\n}\n\nfunction isStorageSelection(value: string): value is StorageSelection {\n return value === \"server\" || value === \"mainline\" || value === \"ipfs\" || value === \"hybrid\";\n}\n\nfunction parseStorageSelection(opts: StorageOpts): StorageSelection | undefined {\n const value = opts.storage;\n if (value === undefined) return undefined;\n if (!isStorageSelection(value)) {\n throw new Error(`Unknown --storage value: ${String(value)}`);\n }\n return value;\n}\n\nasync function buildClient(opts: StorageOpts): Promise<StorageClient | undefined> {\n const selection = parseStorageSelection(opts);\n if (selection === undefined) return undefined;\n const serverUrl =\n opts.host !== undefined && opts.port !== undefined\n ? `http://${opts.host}:${opts.port}`\n : opts.host;\n return createStorageClient(selection, serverUrl);\n}\n\n/** Convert a comma-separated, repeated-flag, or positional list. */\nfunction asStringArray(value: unknown): string[] {\n if (Array.isArray(value)) return value as string[];\n if (typeof value === \"string\") return [value];\n return [];\n}\n\nfunction asNumber(value: unknown): number | undefined {\n if (value === undefined || value === null) return undefined;\n if (typeof value !== \"string\" && typeof value !== \"number\") {\n throw new Error(`Expected a number, got: ${typeof value}`);\n }\n const n = Number(value);\n if (Number.isNaN(n)) throw new Error(`Expected a number, got: ${value as string}`);\n return n;\n}\n\n/**\n * Build an object containing only the keys whose values are defined.\n *\n * The frost-hubert library types use `exactOptionalPropertyTypes: true`,\n * which means `{ foo?: string }` rejects `{ foo: undefined }` — only\n * `{ foo: \"x\" }` or `{}` is allowed. Spreading this helper's return\n * value into an options object preserves that contract: at runtime we\n * filter out the `undefined` keys, and we strip `undefined` from the\n * value type so the spread satisfies `exactOptionalPropertyTypes`.\n */\ntype DefinedValues<T> = { [K in keyof T]?: Exclude<T[K], undefined> };\nfunction defined<T extends Record<string, unknown>>(obj: T): DefinedValues<T> {\n const out: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj)) {\n if (value !== undefined) out[key] = value;\n }\n return out as DefinedValues<T>;\n}\n\n/**\n * Wrap a CLI action handler so any thrown error prints to stderr and\n * exits with code 1. Mirrors Rust's `anyhow::Result<()>` propagation.\n */\nfunction runAsync<TArgs extends unknown[]>(\n handler: (...args: TArgs) => Promise<void>,\n): (...args: TArgs) => void {\n return (...args: TArgs): void => {\n handler(...args).catch((err: unknown) => {\n console.error(err instanceof Error ? err.message : String(err));\n process.exit(1);\n });\n };\n}\n\nfunction runSync<TArgs extends unknown[]>(\n handler: (...args: TArgs) => void,\n): (...args: TArgs) => void {\n return (...args: TArgs): void => {\n try {\n handler(...args);\n } catch (err) {\n console.error(err instanceof Error ? err.message : String(err));\n process.exit(1);\n }\n };\n}\n\n// Common option attachers — keep the per-subcommand definitions short.\nconst addStorageOpts = (cmd: ReturnType<typeof program.command>): typeof cmd =>\n cmd\n .option(\"--storage <selection>\", \"Storage backend (server|mainline|ipfs|hybrid)\")\n .option(\"--host <host>\", \"Server host (server backend only)\")\n .option(\"--port <port>\", \"Server port (server backend only)\");\n\nconst addRegistryOpt = (cmd: ReturnType<typeof program.command>): typeof cmd =>\n cmd.option(\"-r, --registry <path>\", \"Registry path or filename override\");\n\nconst addTimeoutOpt = (cmd: ReturnType<typeof program.command>): typeof cmd =>\n cmd.option(\"--timeout <seconds>\", \"Wait up to this many seconds\");\n\n// ---------------------------------------------------------------------------\n// CLI definition\n// ---------------------------------------------------------------------------\n\nasync function main(): Promise<void> {\n await registerTags();\n\n program.name(\"frost\").description(\"FROST threshold signing CLI\").version(\"1.0.0\");\n\n // ─── Registry ──────────────────────────────────────────────────────────\n const registryCmd = program.command(\"registry\").description(\"Manage the registry\");\n const ownerCmd = registryCmd.command(\"owner\").description(\"Manage the registry owner\");\n\n ownerCmd\n .command(\"set <xid-document> [pet-name]\")\n .description(\"Set the registry owner using an ur:xid document that includes private keys\")\n .option(\"-r, --registry <path>\", \"Registry path or filename override\")\n .action(\n runSync(\n (xidDocument: string, petName: string | undefined, options: { registry?: string }) => {\n ownerSet({ xidDocument, petName, registryPath: options.registry }, process.cwd());\n },\n ),\n );\n\n const participantCmd = registryCmd\n .command(\"participant\")\n .description(\"Manage registry participants\");\n\n participantCmd\n .command(\"add <xid-document> [pet-name]\")\n .description(\"Add a participant using an ur:xid document\")\n .option(\"-r, --registry <path>\", \"Registry path or filename override\")\n .action(\n runSync(\n (xidDocument: string, petName: string | undefined, options: { registry?: string }) => {\n participantAdd({ xidDocument, petName, registryPath: options.registry }, process.cwd());\n },\n ),\n );\n\n // ─── DKG ──────────────────────────────────────────────────────────────\n const dkgCmd = program.command(\"dkg\").description(\"Distributed Key Generation commands\");\n const dkgCoordinatorCmd = dkgCmd.command(\"coordinator\").description(\"DKG coordinator commands\");\n\n // dkg coordinator invite\n addStorageOpts(\n addRegistryOpt(\n dkgCoordinatorCmd\n .command(\"invite <participants...>\")\n .description(\"Compose or send a DKG invite\")\n .option(\"--min-signers <n>\", \"Minimum signers required; defaults to participant count\")\n .option(\"--charter <string>\", \"Charter statement for the DKG group\", \"\")\n .option(\"--valid-days <days>\", \"Days the invite is valid for\", \"30\")\n .option(\"--preview\", \"Print the preview invite envelope UR instead of the sealed envelope\"),\n ),\n ).action(\n runAsync(\n async (\n participants: string[],\n opts: StorageOpts & {\n registry?: string;\n minSigners?: string;\n charter?: string;\n validDays?: string;\n preview?: boolean;\n },\n ) => {\n const selection = parseStorageSelection(opts);\n if (selection !== undefined && opts.preview === true) {\n throw new Error(\"--preview cannot be used with Hubert storage options\");\n }\n const client = await buildClient(opts);\n const fn = await lazyDkgCoord.invite();\n const result = await fn(\n // dkgCoordInvite requires a defined client; for preview the\n // invite is built but not posted, so we pass a no-op client.\n client ?? noOpClient(),\n {\n charter: opts.charter ?? \"\",\n validDays: asNumber(opts.validDays) ?? 30,\n participantNames: asStringArray(participants),\n ...defined({\n registryPath: opts.registry,\n minSigners: asNumber(opts.minSigners),\n }),\n },\n process.cwd(),\n );\n console.log(result.envelopeUr);\n },\n ),\n );\n\n // dkg coordinator round1\n addStorageOpts(\n addTimeoutOpt(\n addRegistryOpt(\n dkgCoordinatorCmd\n .command(\"round1 <group-id>\")\n .description(\"Collect round 1 responses\")\n .option(\"--preview\", \"Preview one of the round 2 requests while sending\")\n .option(\"--parallel\", \"Use parallel fetch/send\"),\n ),\n ),\n ).action(\n runAsync(\n async (\n groupId: string,\n opts: StorageOpts & {\n registry?: string;\n timeout?: string;\n preview?: boolean;\n parallel?: boolean;\n },\n ) => {\n const client = await buildClient(opts);\n if (client === undefined) {\n throw new Error(\"dkg coordinator round1 requires --storage\");\n }\n const fn = await lazyDkgCoord.round1();\n const result = await fn(\n client,\n {\n groupId,\n ...defined({\n registryPath: opts.registry,\n timeoutSeconds: asNumber(opts.timeout),\n preview: opts.preview,\n parallel: opts.parallel,\n }),\n },\n process.cwd(),\n );\n console.log(JSON.stringify(result));\n },\n ),\n );\n\n // dkg coordinator round2\n addStorageOpts(\n addTimeoutOpt(\n addRegistryOpt(\n dkgCoordinatorCmd\n .command(\"round2 <group-id>\")\n .description(\"Collect round 2 responses\")\n .option(\"--preview\", \"Preview one of the finalize requests while sending\")\n .option(\"--parallel\", \"Use parallel fetch/send\"),\n ),\n ),\n ).action(\n runAsync(\n async (\n groupId: string,\n opts: StorageOpts & {\n registry?: string;\n timeout?: string;\n preview?: boolean;\n parallel?: boolean;\n },\n ) => {\n const client = await buildClient(opts);\n if (client === undefined) {\n throw new Error(\"dkg coordinator round2 requires --storage\");\n }\n const fn = await lazyDkgCoord.round2();\n const result = await fn(\n client,\n {\n groupId,\n ...defined({\n registryPath: opts.registry,\n timeoutSeconds: asNumber(opts.timeout),\n preview: opts.preview,\n parallel: opts.parallel,\n }),\n },\n process.cwd(),\n );\n console.log(JSON.stringify(result));\n },\n ),\n );\n\n // dkg coordinator finalize\n addStorageOpts(\n addTimeoutOpt(\n addRegistryOpt(\n dkgCoordinatorCmd\n .command(\"finalize <group-id>\")\n .description(\"Collect finalize responses\")\n .option(\"--parallel\", \"Use parallel fetch\"),\n ),\n ),\n ).action(\n runAsync(\n async (\n groupId: string,\n opts: StorageOpts & {\n registry?: string;\n timeout?: string;\n parallel?: boolean;\n },\n ) => {\n const client = await buildClient(opts);\n if (client === undefined) {\n throw new Error(\"dkg coordinator finalize requires --storage\");\n }\n const fn = await lazyDkgCoord.finalize();\n const result = await fn(\n client,\n {\n groupId,\n ...defined({\n registryPath: opts.registry,\n timeoutSeconds: asNumber(opts.timeout),\n parallel: opts.parallel,\n }),\n },\n process.cwd(),\n );\n console.log(result.verifyingKey);\n },\n ),\n );\n\n // ─── DKG participant ───────────────────────────────────────────────────\n const dkgParticipantCmd = dkgCmd.command(\"participant\").description(\"DKG participant commands\");\n\n // dkg participant receive\n addStorageOpts(\n addTimeoutOpt(\n addRegistryOpt(\n dkgParticipantCmd\n .command(\"receive <invite>\")\n .description(\"Receive a DKG invite (ur:arid or ur:envelope)\")\n .option(\"--no-envelope\", \"Suppress printing the invite envelope UR\")\n .option(\"--info\", \"Show invite details\")\n .option(\"--sender <sender>\", \"Require the invite to come from this sender\"),\n ),\n ),\n ).action(\n runAsync(\n async (\n invite: string,\n opts: StorageOpts & {\n registry?: string;\n timeout?: string;\n envelope?: boolean;\n info?: boolean;\n sender?: string;\n },\n ) => {\n const selection = parseStorageSelection(opts);\n const client = await buildClient(opts);\n const fn = await lazyDkgPart.receive();\n const result = await fn(\n client,\n {\n invite,\n // commander auto-negates `--no-envelope` into `envelope: false`.\n noEnvelope: opts.envelope === false,\n ...defined({\n registryPath: opts.registry,\n timeoutSeconds: asNumber(opts.timeout),\n info: opts.info,\n sender: opts.sender,\n storageSelection: selection,\n }),\n },\n process.cwd(),\n );\n if (result.envelopeUr !== undefined) console.log(result.envelopeUr);\n },\n ),\n );\n\n // dkg participant round1\n addStorageOpts(\n addTimeoutOpt(\n addRegistryOpt(\n dkgParticipantCmd\n .command(\"round1 <invite>\")\n .description(\"Send round 1 response\")\n .option(\"--response-arid <ur>\", \"Optional ARID for the next response\")\n .option(\"--preview\", \"Print the preview response envelope UR instead\")\n .option(\"--reject <reason>\", \"Reject the invite with the provided reason\")\n .option(\"--sender <sender>\", \"Require the invite to come from this sender\"),\n ),\n ),\n ).action(\n runAsync(\n async (\n invite: string,\n opts: StorageOpts & {\n registry?: string;\n timeout?: string;\n responseArid?: string;\n preview?: boolean;\n reject?: string;\n sender?: string;\n },\n ) => {\n const selection = parseStorageSelection(opts);\n const client = await buildClient(opts);\n const fn = await lazyDkgPart.round1();\n const result = await fn(\n client,\n {\n invite,\n ...defined({\n registryPath: opts.registry,\n timeoutSeconds: asNumber(opts.timeout),\n responseArid: opts.responseArid,\n preview: opts.preview,\n rejectReason: opts.reject,\n sender: opts.sender,\n storageSelection: selection,\n }),\n },\n process.cwd(),\n );\n if (result.envelopeUr !== undefined) console.log(result.envelopeUr);\n else if (result.listeningArid !== undefined) console.log(result.listeningArid);\n },\n ),\n );\n\n // dkg participant round2\n addStorageOpts(\n addTimeoutOpt(\n addRegistryOpt(\n dkgParticipantCmd\n .command(\"round2 <group-id>\")\n .description(\"Send round 2 response\")\n .option(\"--preview\", \"Also print the preview response envelope\"),\n ),\n ),\n ).action(\n runAsync(\n async (\n groupId: string,\n opts: StorageOpts & { registry?: string; timeout?: string; preview?: boolean },\n ) => {\n const selection = parseStorageSelection(opts);\n const client = await buildClient(opts);\n const fn = await lazyDkgPart.round2();\n const result = await fn(\n client,\n {\n groupId,\n ...defined({\n registryPath: opts.registry,\n timeoutSeconds: asNumber(opts.timeout),\n preview: opts.preview,\n storageSelection: selection,\n }),\n },\n process.cwd(),\n );\n if (result.envelopeUr !== undefined) console.log(result.envelopeUr);\n else console.log(result.listeningArid);\n },\n ),\n );\n\n // dkg participant finalize\n addStorageOpts(\n addTimeoutOpt(\n addRegistryOpt(\n dkgParticipantCmd\n .command(\"finalize <group-id>\")\n .description(\"Receive finalize package\")\n .option(\"--preview\", \"Also print the preview response envelope\"),\n ),\n ),\n ).action(\n runAsync(\n async (\n groupId: string,\n opts: StorageOpts & { registry?: string; timeout?: string; preview?: boolean },\n ) => {\n const selection = parseStorageSelection(opts);\n const client = await buildClient(opts);\n const fn = await lazyDkgPart.finalize();\n const result = await fn(\n client,\n {\n groupId,\n ...defined({\n registryPath: opts.registry,\n timeoutSeconds: asNumber(opts.timeout),\n preview: opts.preview,\n storageSelection: selection,\n }),\n },\n process.cwd(),\n );\n console.log(result.verifyingKey);\n },\n ),\n );\n\n // ─── Sign ──────────────────────────────────────────────────────────────\n const signCmd = program.command(\"sign\").description(\"Threshold signing commands\");\n const signCoordinatorCmd = signCmd\n .command(\"coordinator\")\n .description(\"Sign coordinator commands\");\n\n // sign coordinator invite\n addStorageOpts(\n addRegistryOpt(\n signCoordinatorCmd\n .command(\"invite <group-id>\")\n .description(\"Send sign invite to participants\")\n .requiredOption(\"--target <path>\", \"Path to a file containing the target envelope UR\")\n .option(\"--preview\", \"Print the preview request envelope UR instead of sending\"),\n ),\n ).action(\n runAsync(\n async (\n groupId: string,\n opts: StorageOpts & { registry?: string; target: string; preview?: boolean },\n ) => {\n const client = await buildClient(opts);\n const fn = await lazySignCoord.invite();\n const result = await fn(\n client,\n {\n groupId,\n targetFile: opts.target,\n ...defined({\n registryPath: opts.registry,\n preview: opts.preview,\n }),\n },\n process.cwd(),\n );\n console.log(result.startArid);\n },\n ),\n );\n\n // sign coordinator round1\n addStorageOpts(\n addTimeoutOpt(\n addRegistryOpt(\n signCoordinatorCmd\n .command(\"round1 <session-id>\")\n .description(\"Collect round 1 (commitment) responses\")\n .option(\"--group <ur:arid>\", \"Optional group ID hint\")\n .option(\"--preview-share\", \"Print a sample unsealed signRound2 request\")\n .option(\"--parallel\", \"Use parallel fetch/send\"),\n ),\n ),\n ).action(\n runAsync(\n async (\n sessionId: string,\n opts: StorageOpts & {\n registry?: string;\n timeout?: string;\n group?: string;\n previewShare?: boolean;\n parallel?: boolean;\n },\n ) => {\n const client = await buildClient(opts);\n if (client === undefined) {\n throw new Error(\"sign coordinator round1 requires --storage\");\n }\n const fn = await lazySignCoord.round1();\n const result = await fn(\n client,\n {\n sessionId,\n ...defined({\n registryPath: opts.registry,\n groupId: opts.group,\n timeoutSeconds: asNumber(opts.timeout),\n previewShare: opts.previewShare,\n parallel: opts.parallel,\n }),\n },\n process.cwd(),\n );\n console.log(JSON.stringify(result));\n },\n ),\n );\n\n // sign coordinator round2\n addStorageOpts(\n addTimeoutOpt(\n addRegistryOpt(\n signCoordinatorCmd\n .command(\"round2 <session-id>\")\n .description(\"Collect round 2 responses and finalize signature\")\n .option(\"--group <ur:arid>\", \"Optional group ID hint\")\n .option(\"--preview-finalize\", \"Print a sample unsealed finalize package\")\n .option(\"--parallel\", \"Use parallel fetch/send\"),\n ),\n ),\n ).action(\n runAsync(\n async (\n sessionId: string,\n opts: StorageOpts & {\n registry?: string;\n timeout?: string;\n group?: string;\n previewFinalize?: boolean;\n parallel?: boolean;\n },\n ) => {\n const client = await buildClient(opts);\n if (client === undefined) {\n throw new Error(\"sign coordinator round2 requires --storage\");\n }\n const fn = await lazySignCoord.round2();\n const result = await fn(\n client,\n {\n sessionId,\n ...defined({\n registryPath: opts.registry,\n groupId: opts.group,\n timeoutSeconds: asNumber(opts.timeout),\n previewFinalize: opts.previewFinalize,\n parallel: opts.parallel,\n }),\n },\n process.cwd(),\n );\n console.log(result.signedEnvelope);\n },\n ),\n );\n\n // ─── Sign participant ──────────────────────────────────────────────────\n const signParticipantCmd = signCmd\n .command(\"participant\")\n .description(\"Sign participant commands\");\n\n // sign participant receive\n addStorageOpts(\n addTimeoutOpt(\n addRegistryOpt(\n signParticipantCmd\n .command(\"receive <request>\")\n .description(\"Receive a signInvite request (ur:arid or ur:envelope)\")\n .option(\"--info\", \"Show request details\")\n .option(\"--sender <sender>\", \"Require the request to come from this sender\"),\n ),\n ),\n ).action(\n runAsync(\n async (\n request: string,\n opts: StorageOpts & {\n registry?: string;\n timeout?: string;\n info?: boolean;\n sender?: string;\n },\n ) => {\n const selection = parseStorageSelection(opts);\n const client = await buildClient(opts);\n const fn = await lazySignPart.receive();\n const result = await fn(\n client,\n selection,\n {\n request,\n ...defined({\n registryPath: opts.registry,\n timeoutSeconds: asNumber(opts.timeout),\n info: opts.info,\n sender: opts.sender,\n }),\n },\n process.cwd(),\n );\n console.log(JSON.stringify(result));\n },\n ),\n );\n\n // sign participant round1\n addStorageOpts(\n addRegistryOpt(\n signParticipantCmd\n .command(\"round1 <session-id>\")\n .description(\"Send commitment\")\n .option(\"--preview\", \"Print the preview response envelope UR instead of sending\")\n .option(\"--reject <reason>\", \"Reject the signInvite request with the provided reason\")\n .option(\"--group <ur:arid>\", \"Optional group ID hint\"),\n ),\n ).action(\n runAsync(\n async (\n sessionId: string,\n opts: StorageOpts & {\n registry?: string;\n preview?: boolean;\n reject?: string;\n group?: string;\n },\n ) => {\n const selection = parseStorageSelection(opts);\n const client = await buildClient(opts);\n const fn = await lazySignPart.round1();\n const result = await fn(\n client,\n {\n sessionId,\n ...defined({\n registryPath: opts.registry,\n groupId: opts.group,\n preview: opts.preview,\n rejectReason: opts.reject,\n storageSelection: selection,\n }),\n },\n process.cwd(),\n );\n if (result.envelopeUr !== undefined) console.log(result.envelopeUr);\n else if (result.listeningArid !== undefined) console.log(result.listeningArid);\n },\n ),\n );\n\n // sign participant round2\n addStorageOpts(\n addTimeoutOpt(\n addRegistryOpt(\n signParticipantCmd\n .command(\"round2 <session-id>\")\n .description(\"Send signature share\")\n .option(\"--preview\", \"Print the unsealed response envelope UR instead of sending\")\n .option(\"--group <ur:arid>\", \"Optional group ID hint\"),\n ),\n ),\n ).action(\n runAsync(\n async (\n sessionId: string,\n opts: StorageOpts & {\n registry?: string;\n timeout?: string;\n preview?: boolean;\n group?: string;\n },\n ) => {\n const client = await buildClient(opts);\n if (client === undefined) {\n throw new Error(\"sign participant round2 requires --storage\");\n }\n const fn = await lazySignPart.round2();\n const result = await fn(\n client,\n {\n sessionId,\n ...defined({\n registryPath: opts.registry,\n groupId: opts.group,\n timeoutSeconds: asNumber(opts.timeout),\n preview: opts.preview,\n }),\n },\n process.cwd(),\n );\n console.log(result.listeningArid);\n },\n ),\n );\n\n // sign participant finalize\n addStorageOpts(\n addTimeoutOpt(\n addRegistryOpt(\n signParticipantCmd\n .command(\"finalize <session-id>\")\n .description(\"Receive finalize event\")\n .option(\"--group <ur:arid>\", \"Optional group ID hint\"),\n ),\n ),\n ).action(\n runAsync(\n async (\n sessionId: string,\n opts: StorageOpts & {\n registry?: string;\n timeout?: string;\n group?: string;\n },\n ) => {\n const client = await buildClient(opts);\n if (client === undefined) {\n throw new Error(\"sign participant finalize requires --storage\");\n }\n const fn = await lazySignPart.finalize();\n const result = await fn(\n client,\n {\n sessionId,\n ...defined({\n registryPath: opts.registry,\n groupId: opts.group,\n timeoutSeconds: asNumber(opts.timeout),\n }),\n },\n process.cwd(),\n );\n console.log(result.signature);\n },\n ),\n );\n\n program.parse();\n}\n\n/**\n * Build a no-op StorageClient for preview-only paths (the\n * coordinator-invite library expects a defined client even when no\n * envelope is sent, because it threads through some helpers).\n *\n * Mirrors Rust's behaviour: `--preview` skips the\n * `StorageClient::from_selection` call entirely, but the underlying\n * library still walks through the same code path with a stub.\n */\nfunction noOpClient(): StorageClient {\n return {\n put: () => Promise.reject(new Error(\"no-op storage client used in preview mode\")),\n get: () => Promise.reject(new Error(\"no-op storage client used in preview mode\")),\n exists: () => Promise.resolve(false),\n };\n}\n\nmain().catch((error: unknown) => {\n console.error(error instanceof Error ? error.message : String(error));\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAM,eAAe;CACnB,cAAA,QAAA,SAAA,CAAA,WAAA,QAAc,yBAAA,CAAA,CAAA,MAAA,MAAA,EAAA,eAAA,CAA2C,MAAM,MAAM,EAAE,OAAO;CAC9E,cAAA,QAAA,SAAA,CAAA,WAAA,QAAc,yBAAA,CAAA,CAAA,MAAA,MAAA,EAAA,eAAA,CAA2C,MAAM,MAAM,EAAE,OAAO;CAC9E,cAAA,QAAA,SAAA,CAAA,WAAA,QAAc,yBAAA,CAAA,CAAA,MAAA,MAAA,EAAA,eAAA,CAA2C,MAAM,MAAM,EAAE,OAAO;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