@bcts/frost-hubert 1.0.0-alpha.21 → 1.0.0-alpha.23

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 (75) hide show
  1. package/dist/bin/frost.cjs +3 -5
  2. package/dist/bin/frost.cjs.map +1 -1
  3. package/dist/bin/frost.mjs +3 -5
  4. package/dist/bin/frost.mjs.map +1 -1
  5. package/dist/{chunk-uaV2rQ02.cjs → chunk-CZWwpsFl.cjs} +22 -32
  6. package/dist/{chunk-ClPoSABd.mjs → chunk-CjcI7cDX.mjs} +6 -12
  7. package/dist/cmd/index.cjs +40 -43
  8. package/dist/cmd/index.d.cts +1 -3
  9. package/dist/cmd/index.d.mts +1 -3
  10. package/dist/cmd/index.mjs +3 -6
  11. package/dist/{sign-D8C3HJ4B.mjs → cmd-5yLeC_QL.mjs} +16 -44
  12. package/dist/cmd-5yLeC_QL.mjs.map +1 -0
  13. package/dist/{sign-2bOp18Fs.cjs → cmd-BfZjC3Uh.cjs} +182 -210
  14. package/dist/cmd-BfZjC3Uh.cjs.map +1 -0
  15. package/dist/dkg/index.cjs +341 -7
  16. package/dist/dkg/index.cjs.map +1 -0
  17. package/dist/dkg/index.d.cts +1 -1
  18. package/dist/dkg/index.d.mts +1 -1
  19. package/dist/dkg/index.mjs +335 -2
  20. package/dist/dkg/index.mjs.map +1 -0
  21. package/dist/frost/index.cjs +8 -9
  22. package/dist/frost/index.cjs.map +1 -1
  23. package/dist/frost/index.mjs +2 -3
  24. package/dist/frost/index.mjs.map +1 -1
  25. package/dist/{index-CcvTi5EA.d.cts → index-BJlwbPYu.d.cts} +3 -3
  26. package/dist/{index-CcvTi5EA.d.cts.map → index-BJlwbPYu.d.cts.map} +1 -1
  27. package/dist/{registry-impl-CE76sTXQ.d.cts → index-BMbPgH0W.d.cts} +1 -1
  28. package/dist/index-BMbPgH0W.d.cts.map +1 -0
  29. package/dist/{group-invite-Dz1Jmiky.d.cts → index-BkqLimZT.d.mts} +2 -2
  30. package/dist/index-BkqLimZT.d.mts.map +1 -0
  31. package/dist/{group-invite-Wk9CIbHL.d.mts → index-DmxfT59Y.d.cts} +2 -2
  32. package/dist/index-DmxfT59Y.d.cts.map +1 -0
  33. package/dist/{registry-impl-BETn_lEO.d.mts → index-DoV5HFvV.d.mts} +1 -1
  34. package/dist/index-DoV5HFvV.d.mts.map +1 -0
  35. package/dist/{index-DNCPeLNM.d.mts → index-Dzm1v4_4.d.mts} +3 -3
  36. package/dist/{index-DNCPeLNM.d.mts.map → index-Dzm1v4_4.d.mts.map} +1 -1
  37. package/dist/index.cjs +64 -68
  38. package/dist/index.cjs.map +1 -1
  39. package/dist/index.d.cts +3 -6
  40. package/dist/index.d.cts.map +1 -1
  41. package/dist/index.d.mts +3 -6
  42. package/dist/index.d.mts.map +1 -1
  43. package/dist/index.mjs +5 -9
  44. package/dist/index.mjs.map +1 -1
  45. package/dist/registry/index.cjs +806 -13
  46. package/dist/registry/index.cjs.map +1 -0
  47. package/dist/registry/index.d.cts +1 -1
  48. package/dist/registry/index.d.mts +1 -1
  49. package/dist/registry/index.mjs +792 -2
  50. package/dist/registry/index.mjs.map +1 -0
  51. package/dist/{registry-BDnNV1Rk.mjs → registry-CgrCZ4En.mjs} +7 -10
  52. package/dist/{registry-BDnNV1Rk.mjs.map → registry-CgrCZ4En.mjs.map} +1 -1
  53. package/dist/{registry-FMU-ec5K.cjs → registry-loI1_Mh1.cjs} +28 -31
  54. package/dist/registry-loI1_Mh1.cjs.map +1 -0
  55. package/package.json +17 -17
  56. package/src/cmd/dkg/participant/finalize.ts +1 -1
  57. package/src/dkg/proposed-participant.ts +1 -2
  58. package/src/frost/index.ts +1 -1
  59. package/src/registry/owner-record.ts +1 -2
  60. package/src/registry/participant-record.ts +1 -2
  61. package/dist/group-invite-CrbOabFL.cjs +0 -368
  62. package/dist/group-invite-CrbOabFL.cjs.map +0 -1
  63. package/dist/group-invite-Dz1Jmiky.d.cts.map +0 -1
  64. package/dist/group-invite-RPElq-fm.mjs +0 -338
  65. package/dist/group-invite-RPElq-fm.mjs.map +0 -1
  66. package/dist/group-invite-Wk9CIbHL.d.mts.map +0 -1
  67. package/dist/registry-FMU-ec5K.cjs.map +0 -1
  68. package/dist/registry-impl-BETn_lEO.d.mts.map +0 -1
  69. package/dist/registry-impl-C7w4awTv.cjs +0 -865
  70. package/dist/registry-impl-C7w4awTv.cjs.map +0 -1
  71. package/dist/registry-impl-CE76sTXQ.d.cts.map +0 -1
  72. package/dist/registry-impl-eYXVSPwM.mjs +0 -797
  73. package/dist/registry-impl-eYXVSPwM.mjs.map +0 -1
  74. package/dist/sign-2bOp18Fs.cjs.map +0 -1
  75. package/dist/sign-D8C3HJ4B.mjs.map +0 -1
@@ -1,338 +0,0 @@
1
- import { ARID } from "@bcts/components";
2
- import { CborDate } from "@bcts/dcbor";
3
- import { Envelope, Function } from "@bcts/envelope";
4
- import { SealedRequest, SealedResponse } from "@bcts/gstp";
5
- import { XIDDocument, XIDVerifySignature } from "@bcts/xid";
6
- import { UR } from "@bcts/uniform-resources";
7
-
8
- //#region src/dkg/proposed-participant.ts
9
- /**
10
- * A proposed participant in a DKG session.
11
- *
12
- * Port of `struct DkgProposedParticipant` from proposed_participant.rs lines 8-13.
13
- */
14
- var DkgProposedParticipant = class DkgProposedParticipant {
15
- _urString;
16
- _envelope;
17
- _document;
18
- _responseArid;
19
- constructor(urString, envelope, document, responseArid) {
20
- this._urString = urString;
21
- this._envelope = envelope;
22
- this._document = document;
23
- this._responseArid = responseArid;
24
- }
25
- /**
26
- * Create a new DkgProposedParticipant from a UR string and response ARID.
27
- *
28
- * Port of `DkgProposedParticipant::new()` from proposed_participant.rs lines 22-26.
29
- */
30
- static create(urString, responseArid) {
31
- const [envelope, document] = parseXidEnvelope(urString);
32
- return new DkgProposedParticipant(urString, envelope, document, responseArid);
33
- }
34
- /**
35
- * Get the XID of this participant.
36
- *
37
- * Port of `DkgProposedParticipant::xid()` from proposed_participant.rs line 28.
38
- */
39
- xid() {
40
- return this._document.xid();
41
- }
42
- /**
43
- * Get the XID document of this participant.
44
- *
45
- * Port of `DkgProposedParticipant::xid_document()` from proposed_participant.rs line 30.
46
- */
47
- xidDocument() {
48
- return this._document;
49
- }
50
- /**
51
- * Get the UR string of the XID document.
52
- *
53
- * Port of `DkgProposedParticipant::xid_document_ur()` from proposed_participant.rs line 32.
54
- */
55
- xidDocumentUr() {
56
- return this._urString;
57
- }
58
- /**
59
- * Get the envelope containing the XID document.
60
- *
61
- * Port of `DkgProposedParticipant::xid_document_envelope()` from proposed_participant.rs line 34.
62
- */
63
- xidDocumentEnvelope() {
64
- return this._envelope;
65
- }
66
- /**
67
- * Get the response ARID for this participant.
68
- *
69
- * Port of `DkgProposedParticipant::response_arid()` from proposed_participant.rs line 36.
70
- */
71
- responseArid() {
72
- return this._responseArid;
73
- }
74
- /**
75
- * Compare participants by XID for sorting.
76
- */
77
- compareTo(other) {
78
- const thisXid = this.xid().toString();
79
- const otherXid = other.xid().toString();
80
- return thisXid.localeCompare(otherXid);
81
- }
82
- };
83
- /**
84
- * Parse a XID envelope from a UR string.
85
- *
86
- * Port of `parse_xid_envelope()` from proposed_participant.rs lines 39-60.
87
- */
88
- function parseXidEnvelope(input) {
89
- const trimmed = input.trim();
90
- if (trimmed.length === 0) throw new Error("XID document is required");
91
- const ur = UR.fromURString(trimmed);
92
- const urType = ur.urTypeStr();
93
- if (urType !== "xid" && urType !== "envelope") throw new Error(`Expected a ur:xid document, found ur:${urType}`);
94
- const envelopeCbor = ur.cbor();
95
- let envelope;
96
- try {
97
- envelope = Envelope.fromTaggedCbor(envelopeCbor);
98
- } catch {
99
- envelope = Envelope.fromUntaggedCbor(envelopeCbor);
100
- }
101
- const document = XIDDocument.fromEnvelope(envelope, void 0, XIDVerifySignature.Inception);
102
- return [envelope, document];
103
- }
104
-
105
- //#endregion
106
- //#region src/dkg/group-invite.ts
107
- /**
108
- * Copyright © 2023-2026 Blockchain Commons, LLC
109
- * Copyright © 2025-2026 Parity Technologies
110
- *
111
- *
112
- * DKG Group Invite structures.
113
- *
114
- * Port of dkg/group_invite.rs from frost-hubert-rust.
115
- *
116
- * @module
117
- */
118
- /**
119
- * Helper to create an accepted result.
120
- */
121
- function accepted() {
122
- return { type: "accepted" };
123
- }
124
- /**
125
- * Helper to create a declined result.
126
- */
127
- function declined(reason) {
128
- return {
129
- type: "declined",
130
- reason
131
- };
132
- }
133
- /**
134
- * DKG Invite - represents an invitation to participate in a DKG session.
135
- *
136
- * Port of `struct DkgInvite` from group_invite.rs lines 11-27.
137
- */
138
- var DkgInvite = class DkgInvite {
139
- _requestId;
140
- _sender;
141
- _groupId;
142
- _date;
143
- _validUntil;
144
- _minSigners;
145
- _charter;
146
- _orderedParticipants;
147
- constructor(requestId, sender, groupId, date, validUntil, minSigners, charter, orderedParticipants) {
148
- this._requestId = requestId;
149
- this._sender = sender;
150
- this._groupId = groupId;
151
- this._date = date;
152
- this._validUntil = validUntil;
153
- this._minSigners = minSigners;
154
- this._charter = charter;
155
- this._orderedParticipants = orderedParticipants;
156
- }
157
- /**
158
- * Create a new DKG invite.
159
- *
160
- * Port of `DkgInvite::new()` from group_invite.rs lines 30-67.
161
- */
162
- static create(requestId, sender, groupId, date, validUntil, minSigners, charter, participants, responseArids) {
163
- if (participants.length !== responseArids.length) throw new Error(`Number of participants (${participants.length}) does not match number of response ARIDs (${responseArids.length})`);
164
- if (minSigners < 2) throw new Error("min_signers must be at least 2");
165
- const orderedParticipants = participants.map((urString, i) => DkgProposedParticipant.create(urString, responseArids[i]));
166
- if (minSigners > orderedParticipants.length) throw new Error("min_signers cannot exceed number of participants");
167
- orderedParticipants.sort((a, b) => a.compareTo(b));
168
- return new DkgInvite(requestId, sender, groupId, date, validUntil, minSigners, charter, orderedParticipants);
169
- }
170
- requestId() {
171
- return this._requestId;
172
- }
173
- sender() {
174
- return this._sender;
175
- }
176
- groupId() {
177
- return this._groupId;
178
- }
179
- date() {
180
- return this._date;
181
- }
182
- validUntil() {
183
- return this._validUntil;
184
- }
185
- minSigners() {
186
- return this._minSigners;
187
- }
188
- charter() {
189
- return this._charter;
190
- }
191
- participants() {
192
- return this._orderedParticipants;
193
- }
194
- /**
195
- * Create a GSTP sealed request from this invite.
196
- *
197
- * Port of `DkgInvite::to_request()` from group_invite.rs lines 87-121.
198
- */
199
- toRequest() {
200
- let request = SealedRequest.new("dkgInvite", this.requestId(), this.sender()).withParameter("group", this.groupId()).withParameter("minSigners", BigInt(this.minSigners())).withParameter("charter", this.charter()).withDate(this.date()).withParameter("validUntil", CborDate.fromDatetime(this.validUntil()));
201
- for (const participant of this.participants()) {
202
- const xidDocumentEnvelope = participant.xidDocumentEnvelope();
203
- const responseArid = participant.responseArid();
204
- const encryptionKey = participant.xidDocument().encryptionKey();
205
- if (encryptionKey === void 0) throw new Error("Participant XID document has no encryption key");
206
- const encryptedResponseArid = Envelope.new(responseArid).encryptToRecipients([encryptionKey]);
207
- const participantEnvelope = xidDocumentEnvelope.wrap().addAssertion("response_arid", encryptedResponseArid);
208
- request = request.withParameter("participant", participantEnvelope);
209
- }
210
- return request;
211
- }
212
- /**
213
- * Creates a signed but unencrypted envelope for auditing/preview.
214
- *
215
- * Port of `DkgInvite::to_unsealed_envelope()` from group_invite.rs lines 124-139.
216
- */
217
- toUnsealedEnvelope() {
218
- const request = this.toRequest();
219
- const signerPrivateKeys = this.sender().inceptionPrivateKeys();
220
- if (signerPrivateKeys === void 0) throw new Error("Sender XID document has no inception signing key");
221
- return request.toEnvelope(this.validUntil(), signerPrivateKeys, void 0);
222
- }
223
- /**
224
- * Creates a sealed envelope encrypted to all participants.
225
- *
226
- * Port of `DkgInvite::to_envelope()` from group_invite.rs lines 142-166.
227
- */
228
- toEnvelope() {
229
- const request = this.toRequest();
230
- const signerPrivateKeys = this.sender().inceptionPrivateKeys();
231
- if (signerPrivateKeys === void 0) throw new Error("Sender XID document has no inception signing key");
232
- const recipients = this.participants().map((p) => p.xidDocument());
233
- return request.toEnvelopeForRecipients(this.validUntil(), signerPrivateKeys, recipients);
234
- }
235
- };
236
- /**
237
- * DKG Invitation - represents a received invitation from a participant's perspective.
238
- *
239
- * Port of `struct DkgInvitation` from group_invite.rs lines 175-186.
240
- */
241
- var DkgInvitation = class DkgInvitation {
242
- _responseArid;
243
- _validUntil;
244
- _sender;
245
- _requestId;
246
- _peerContinuation;
247
- _minSigners;
248
- _charter;
249
- _groupId;
250
- constructor(responseArid, validUntil, sender, requestId, peerContinuation, minSigners, charter, groupId) {
251
- this._responseArid = responseArid;
252
- this._validUntil = validUntil;
253
- this._sender = sender;
254
- this._requestId = requestId;
255
- this._peerContinuation = peerContinuation;
256
- this._minSigners = minSigners;
257
- this._charter = charter;
258
- this._groupId = groupId;
259
- }
260
- responseArid() {
261
- return this._responseArid;
262
- }
263
- validUntil() {
264
- return this._validUntil;
265
- }
266
- sender() {
267
- return this._sender;
268
- }
269
- requestId() {
270
- return this._requestId;
271
- }
272
- peerContinuation() {
273
- return this._peerContinuation;
274
- }
275
- minSigners() {
276
- return this._minSigners;
277
- }
278
- charter() {
279
- return this._charter;
280
- }
281
- groupId() {
282
- return this._groupId;
283
- }
284
- /**
285
- * Build a GSTP response for this invitation result.
286
- *
287
- * Port of `DkgInvitation::to_response()` from group_invite.rs lines 207-224.
288
- */
289
- toResponse(response, recipient) {
290
- let base;
291
- if (response.type === "accepted") base = SealedResponse.newSuccess(this.requestId(), recipient);
292
- else base = SealedResponse.newFailure(this.requestId(), recipient).withError(response.reason);
293
- return base.withPeerContinuation(this.peerContinuation());
294
- }
295
- /**
296
- * Create a signed/encrypted GSTP envelope containing the response for the coordinator.
297
- *
298
- * Port of `DkgInvitation::to_envelope()` from group_invite.rs lines 228-244.
299
- */
300
- toEnvelope(response, recipient) {
301
- const responseObj = this.toResponse(response, recipient);
302
- const signerPrivateKeys = recipient.inceptionPrivateKeys();
303
- if (signerPrivateKeys === void 0) throw new Error("Recipient XID document has no signing keys");
304
- const recipients = [this.sender()];
305
- return responseObj.toEnvelopeForRecipients(this.validUntil(), signerPrivateKeys, recipients);
306
- }
307
- /**
308
- * Parse a DKG invitation from an invite envelope.
309
- *
310
- * Port of `DkgInvitation::from_invite()` from group_invite.rs lines 255-344.
311
- */
312
- static fromInvite(invite, now, expectedSender, recipient) {
313
- const recipientPrivateKeys = recipient.inceptionPrivateKeys();
314
- if (recipientPrivateKeys === void 0) throw new Error("Recipient XID document has no inception private keys");
315
- const sealedRequest = SealedRequest.tryFromEnvelope(invite, void 0, now, recipientPrivateKeys);
316
- if (expectedSender !== void 0 && sealedRequest.sender().xid() !== expectedSender.xid()) throw new Error("Invite sender does not match expected sender");
317
- if (!sealedRequest.request().function().equals(Function.fromString("dkgInvite"))) throw new Error("Unexpected invite function");
318
- const validUntil = sealedRequest.extractObjectForParameter("validUntil");
319
- if (validUntil <= now) throw new Error("Invitation expired");
320
- const recipientXid = recipient.xid();
321
- const minSigners = sealedRequest.extractObjectForParameter("minSigners");
322
- const charter = sealedRequest.extractObjectForParameter("charter");
323
- const groupId = sealedRequest.extractObjectForParameter("group");
324
- const participantObjects = sealedRequest.objectsForParameter("participant");
325
- if (minSigners < 2) throw new Error("min_signers must be at least 2");
326
- if (minSigners > participantObjects.length) throw new Error("min_signers exceeds participant count");
327
- for (const participant of participantObjects) {
328
- const xidDocumentEnvelope = participant.tryUnwrap();
329
- if (XIDDocument.fromEnvelope(xidDocumentEnvelope, void 0, XIDVerifySignature.Inception).xid() !== recipientXid) continue;
330
- return new DkgInvitation(participant.objectForPredicate("response_arid").decryptToRecipient(recipientPrivateKeys).extractSubject((cbor) => ARID.fromTaggedCbor(cbor)), validUntil, sealedRequest.sender(), sealedRequest.request().id(), sealedRequest.peerContinuation(), minSigners, charter, groupId);
331
- }
332
- throw new Error("Recipient not found in invite");
333
- }
334
- };
335
-
336
- //#endregion
337
- export { DkgProposedParticipant as a, declined as i, DkgInvite as n, accepted as r, DkgInvitation as t };
338
- //# sourceMappingURL=group-invite-RPElq-fm.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"group-invite-RPElq-fm.mjs","names":["EnvelopeFunction"],"sources":["../src/dkg/proposed-participant.ts","../src/dkg/group-invite.ts"],"sourcesContent":["/**\n * Copyright © 2023-2026 Blockchain Commons, LLC\n * Copyright © 2025-2026 Parity Technologies\n *\n *\n * DKG Proposed Participant.\n *\n * Port of dkg/proposed_participant.rs from frost-hubert-rust.\n *\n * @module\n */\n\nimport { type ARID, type XID } from \"@bcts/components\";\nimport { type Cbor } from \"@bcts/dcbor\";\nimport { Envelope } from \"@bcts/envelope\";\nimport { UR } from \"@bcts/uniform-resources\";\nimport { XIDDocument, XIDVerifySignature } from \"@bcts/xid\";\n\n/**\n * A proposed participant in a DKG session.\n *\n * Port of `struct DkgProposedParticipant` from proposed_participant.rs lines 8-13.\n */\nexport class DkgProposedParticipant {\n private readonly _urString: string;\n private readonly _envelope: Envelope;\n private readonly _document: XIDDocument;\n private readonly _responseArid: ARID;\n\n private constructor(\n urString: string,\n envelope: Envelope,\n document: XIDDocument,\n responseArid: ARID,\n ) {\n this._urString = urString;\n this._envelope = envelope;\n this._document = document;\n this._responseArid = responseArid;\n }\n\n /**\n * Create a new DkgProposedParticipant from a UR string and response ARID.\n *\n * Port of `DkgProposedParticipant::new()` from proposed_participant.rs lines 22-26.\n */\n static create(urString: string, responseArid: ARID): DkgProposedParticipant {\n const [envelope, document] = parseXidEnvelope(urString);\n return new DkgProposedParticipant(urString, envelope, document, responseArid);\n }\n\n /**\n * Get the XID of this participant.\n *\n * Port of `DkgProposedParticipant::xid()` from proposed_participant.rs line 28.\n */\n xid(): XID {\n return this._document.xid();\n }\n\n /**\n * Get the XID document of this participant.\n *\n * Port of `DkgProposedParticipant::xid_document()` from proposed_participant.rs line 30.\n */\n xidDocument(): XIDDocument {\n return this._document;\n }\n\n /**\n * Get the UR string of the XID document.\n *\n * Port of `DkgProposedParticipant::xid_document_ur()` from proposed_participant.rs line 32.\n */\n xidDocumentUr(): string {\n return this._urString;\n }\n\n /**\n * Get the envelope containing the XID document.\n *\n * Port of `DkgProposedParticipant::xid_document_envelope()` from proposed_participant.rs line 34.\n */\n xidDocumentEnvelope(): Envelope {\n return this._envelope;\n }\n\n /**\n * Get the response ARID for this participant.\n *\n * Port of `DkgProposedParticipant::response_arid()` from proposed_participant.rs line 36.\n */\n responseArid(): ARID {\n return this._responseArid;\n }\n\n /**\n * Compare participants by XID for sorting.\n */\n compareTo(other: DkgProposedParticipant): number {\n const thisXid = this.xid().toString();\n const otherXid = other.xid().toString();\n return thisXid.localeCompare(otherXid);\n }\n}\n\n/**\n * Parse a XID envelope from a UR string.\n *\n * Port of `parse_xid_envelope()` from proposed_participant.rs lines 39-60.\n */\nfunction parseXidEnvelope(input: string): [Envelope, XIDDocument] {\n const trimmed = input.trim();\n if (trimmed.length === 0) {\n throw new Error(\"XID document is required\");\n }\n\n const ur = UR.fromURString(trimmed);\n const urType = ur.urTypeStr();\n if (urType !== \"xid\" && urType !== \"envelope\") {\n throw new Error(`Expected a ur:xid document, found ur:${urType}`);\n }\n\n const envelopeCbor = ur.cbor() as unknown as Cbor;\n // Try tagged CBOR first, then untagged\n let envelope: Envelope;\n try {\n envelope = Envelope.fromTaggedCbor(envelopeCbor);\n } catch {\n envelope = Envelope.fromUntaggedCbor(envelopeCbor);\n }\n\n const document = XIDDocument.fromEnvelope(envelope, undefined, XIDVerifySignature.Inception);\n\n return [envelope, document];\n}\n","/**\n * Copyright © 2023-2026 Blockchain Commons, LLC\n * Copyright © 2025-2026 Parity Technologies\n *\n *\n * DKG Group Invite structures.\n *\n * Port of dkg/group_invite.rs from frost-hubert-rust.\n *\n * @module\n */\n\nimport { ARID } from \"@bcts/components\";\nimport { CborDate } from \"@bcts/dcbor\";\nimport { Envelope, Function as EnvelopeFunction } from \"@bcts/envelope\";\nimport { SealedRequest, SealedResponse } from \"@bcts/gstp\";\nimport { XIDDocument, XIDVerifySignature } from \"@bcts/xid\";\n\nimport { DkgProposedParticipant } from \"./proposed-participant.js\";\n\n/**\n * Result of a DKG invitation.\n *\n * Port of `enum DkgInvitationResult` from group_invite.rs lines 170-173.\n */\nexport type DkgInvitationResult = { type: \"accepted\" } | { type: \"declined\"; reason: string };\n\n/**\n * Helper to create an accepted result.\n */\nexport function accepted(): DkgInvitationResult {\n return { type: \"accepted\" };\n}\n\n/**\n * Helper to create a declined result.\n */\nexport function declined(reason: string): DkgInvitationResult {\n return { type: \"declined\", reason };\n}\n\n/**\n * DKG Invite - represents an invitation to participate in a DKG session.\n *\n * Port of `struct DkgInvite` from group_invite.rs lines 11-27.\n */\nexport class DkgInvite {\n private readonly _requestId: ARID;\n private readonly _sender: XIDDocument;\n private readonly _groupId: ARID;\n private readonly _date: Date;\n private readonly _validUntil: Date;\n private readonly _minSigners: number;\n private readonly _charter: string;\n private readonly _orderedParticipants: DkgProposedParticipant[];\n\n private constructor(\n requestId: ARID,\n sender: XIDDocument,\n groupId: ARID,\n date: Date,\n validUntil: Date,\n minSigners: number,\n charter: string,\n orderedParticipants: DkgProposedParticipant[],\n ) {\n this._requestId = requestId;\n this._sender = sender;\n this._groupId = groupId;\n this._date = date;\n this._validUntil = validUntil;\n this._minSigners = minSigners;\n this._charter = charter;\n this._orderedParticipants = orderedParticipants;\n }\n\n /**\n * Create a new DKG invite.\n *\n * Port of `DkgInvite::new()` from group_invite.rs lines 30-67.\n */\n static create(\n requestId: ARID,\n sender: XIDDocument,\n groupId: ARID,\n date: Date,\n validUntil: Date,\n minSigners: number,\n charter: string,\n participants: string[],\n responseArids: ARID[],\n ): DkgInvite {\n if (participants.length !== responseArids.length) {\n throw new Error(\n `Number of participants (${participants.length}) does not match number of response ARIDs (${responseArids.length})`,\n );\n }\n\n if (minSigners < 2) {\n throw new Error(\"min_signers must be at least 2\");\n }\n\n const orderedParticipants = participants.map((urString, i) =>\n DkgProposedParticipant.create(urString, responseArids[i]),\n );\n\n if (minSigners > orderedParticipants.length) {\n throw new Error(\"min_signers cannot exceed number of participants\");\n }\n\n // Sort by XID\n orderedParticipants.sort((a, b) => a.compareTo(b));\n\n return new DkgInvite(\n requestId,\n sender,\n groupId,\n date,\n validUntil,\n minSigners,\n charter,\n orderedParticipants,\n );\n }\n\n requestId(): ARID {\n return this._requestId;\n }\n\n sender(): XIDDocument {\n return this._sender;\n }\n\n groupId(): ARID {\n return this._groupId;\n }\n\n date(): Date {\n return this._date;\n }\n\n validUntil(): Date {\n return this._validUntil;\n }\n\n minSigners(): number {\n return this._minSigners;\n }\n\n charter(): string {\n return this._charter;\n }\n\n participants(): DkgProposedParticipant[] {\n return this._orderedParticipants;\n }\n\n /**\n * Create a GSTP sealed request from this invite.\n *\n * Port of `DkgInvite::to_request()` from group_invite.rs lines 87-121.\n */\n toRequest(): SealedRequest {\n let request = SealedRequest.new(\"dkgInvite\", this.requestId(), this.sender())\n .withParameter(\"group\", this.groupId())\n .withParameter(\"minSigners\", BigInt(this.minSigners()))\n .withParameter(\"charter\", this.charter())\n .withDate(this.date())\n .withParameter(\"validUntil\", CborDate.fromDatetime(this.validUntil()));\n\n for (const participant of this.participants()) {\n const xidDocumentEnvelope = participant.xidDocumentEnvelope();\n const responseArid = participant.responseArid();\n const encryptionKey = participant.xidDocument().encryptionKey();\n\n if (encryptionKey === undefined) {\n throw new Error(\"Participant XID document has no encryption key\");\n }\n\n const encryptedResponseArid = Envelope.new(responseArid).encryptToRecipients([encryptionKey]);\n\n const participantEnvelope = xidDocumentEnvelope\n .wrap()\n .addAssertion(\"response_arid\", encryptedResponseArid);\n\n request = request.withParameter(\"participant\", participantEnvelope);\n }\n\n return request;\n }\n\n /**\n * Creates a signed but unencrypted envelope for auditing/preview.\n *\n * Port of `DkgInvite::to_unsealed_envelope()` from group_invite.rs lines 124-139.\n */\n toUnsealedEnvelope(): Envelope {\n const request = this.toRequest();\n const sender = this.sender();\n const signerPrivateKeys = sender.inceptionPrivateKeys();\n\n if (signerPrivateKeys === undefined) {\n throw new Error(\"Sender XID document has no inception signing key\");\n }\n\n return request.toEnvelope(\n this.validUntil(),\n signerPrivateKeys,\n undefined, // No recipient = signed but not encrypted\n );\n }\n\n /**\n * Creates a sealed envelope encrypted to all participants.\n *\n * Port of `DkgInvite::to_envelope()` from group_invite.rs lines 142-166.\n */\n toEnvelope(): Envelope {\n const request = this.toRequest();\n const sender = this.sender();\n const signerPrivateKeys = sender.inceptionPrivateKeys();\n\n if (signerPrivateKeys === undefined) {\n throw new Error(\"Sender XID document has no inception signing key\");\n }\n\n const recipients = this.participants().map((p) => p.xidDocument());\n\n return request.toEnvelopeForRecipients(this.validUntil(), signerPrivateKeys, recipients);\n }\n}\n\n/**\n * DKG Invitation - represents a received invitation from a participant's perspective.\n *\n * Port of `struct DkgInvitation` from group_invite.rs lines 175-186.\n */\nexport class DkgInvitation {\n private readonly _responseArid: ARID;\n private readonly _validUntil: Date;\n private readonly _sender: XIDDocument;\n private readonly _requestId: ARID;\n private readonly _peerContinuation: Envelope | undefined;\n private readonly _minSigners: number;\n private readonly _charter: string;\n private readonly _groupId: ARID;\n\n private constructor(\n responseArid: ARID,\n validUntil: Date,\n sender: XIDDocument,\n requestId: ARID,\n peerContinuation: Envelope | undefined,\n minSigners: number,\n charter: string,\n groupId: ARID,\n ) {\n this._responseArid = responseArid;\n this._validUntil = validUntil;\n this._sender = sender;\n this._requestId = requestId;\n this._peerContinuation = peerContinuation;\n this._minSigners = minSigners;\n this._charter = charter;\n this._groupId = groupId;\n }\n\n responseArid(): ARID {\n return this._responseArid;\n }\n\n validUntil(): Date {\n return this._validUntil;\n }\n\n sender(): XIDDocument {\n return this._sender;\n }\n\n requestId(): ARID {\n return this._requestId;\n }\n\n peerContinuation(): Envelope | undefined {\n return this._peerContinuation;\n }\n\n minSigners(): number {\n return this._minSigners;\n }\n\n charter(): string {\n return this._charter;\n }\n\n groupId(): ARID {\n return this._groupId;\n }\n\n /**\n * Build a GSTP response for this invitation result.\n *\n * Port of `DkgInvitation::to_response()` from group_invite.rs lines 207-224.\n */\n toResponse(response: DkgInvitationResult, recipient: XIDDocument): SealedResponse {\n let base: SealedResponse;\n if (response.type === \"accepted\") {\n base = SealedResponse.newSuccess(this.requestId(), recipient);\n } else {\n base = SealedResponse.newFailure(this.requestId(), recipient).withError(response.reason);\n }\n\n return base.withPeerContinuation(this.peerContinuation());\n }\n\n /**\n * Create a signed/encrypted GSTP envelope containing the response for the coordinator.\n *\n * Port of `DkgInvitation::to_envelope()` from group_invite.rs lines 228-244.\n */\n toEnvelope(response: DkgInvitationResult, recipient: XIDDocument): Envelope {\n const responseObj = this.toResponse(response, recipient);\n const signerPrivateKeys = recipient.inceptionPrivateKeys();\n\n if (signerPrivateKeys === undefined) {\n throw new Error(\"Recipient XID document has no signing keys\");\n }\n\n const recipients = [this.sender()];\n\n return responseObj.toEnvelopeForRecipients(this.validUntil(), signerPrivateKeys, recipients);\n }\n\n /**\n * Parse a DKG invitation from an invite envelope.\n *\n * Port of `DkgInvitation::from_invite()` from group_invite.rs lines 255-344.\n */\n static fromInvite(\n invite: Envelope,\n now: Date,\n expectedSender: XIDDocument | undefined,\n recipient: XIDDocument,\n ): DkgInvitation {\n const recipientPrivateKeys = recipient.inceptionPrivateKeys();\n\n if (recipientPrivateKeys === undefined) {\n throw new Error(\"Recipient XID document has no inception private keys\");\n }\n\n const sealedRequest = SealedRequest.tryFromEnvelope(\n invite,\n undefined,\n now,\n recipientPrivateKeys,\n );\n\n if (expectedSender !== undefined && sealedRequest.sender().xid() !== expectedSender.xid()) {\n throw new Error(\"Invite sender does not match expected sender\");\n }\n\n if (!sealedRequest.request().function().equals(EnvelopeFunction.fromString(\"dkgInvite\"))) {\n throw new Error(\"Unexpected invite function\");\n }\n\n const validUntil = sealedRequest.extractObjectForParameter<Date>(\"validUntil\");\n\n if (validUntil <= now) {\n throw new Error(\"Invitation expired\");\n }\n\n const recipientXid = recipient.xid();\n const minSigners = sealedRequest.extractObjectForParameter<number>(\"minSigners\");\n const charter = sealedRequest.extractObjectForParameter<string>(\"charter\");\n const groupId = sealedRequest.extractObjectForParameter<ARID>(\"group\");\n const participantObjects = sealedRequest.objectsForParameter(\"participant\");\n\n if (minSigners < 2) {\n throw new Error(\"min_signers must be at least 2\");\n }\n\n if (minSigners > participantObjects.length) {\n throw new Error(\"min_signers exceeds participant count\");\n }\n\n for (const participant of participantObjects) {\n const xidDocumentEnvelope = participant.tryUnwrap();\n const xidDocument = XIDDocument.fromEnvelope(\n xidDocumentEnvelope,\n undefined,\n XIDVerifySignature.Inception,\n );\n\n if (xidDocument.xid() !== recipientXid) {\n continue;\n }\n\n const encryptedResponseArid = participant.objectForPredicate(\"response_arid\");\n const responseAridEnvelope = encryptedResponseArid.decryptToRecipient(recipientPrivateKeys);\n const responseArid: ARID = responseAridEnvelope.extractSubject((cbor) =>\n ARID.fromTaggedCbor(cbor),\n );\n\n return new DkgInvitation(\n responseArid,\n validUntil,\n sealedRequest.sender(),\n sealedRequest.request().id(),\n sealedRequest.peerContinuation(),\n minSigners,\n charter,\n groupId,\n );\n }\n\n throw new Error(\"Recipient not found in invite\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAuBA,IAAa,yBAAb,MAAa,uBAAuB;CAClC,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CAEjB,AAAQ,YACN,UACA,UACA,UACA,cACA;AACA,OAAK,YAAY;AACjB,OAAK,YAAY;AACjB,OAAK,YAAY;AACjB,OAAK,gBAAgB;;;;;;;CAQvB,OAAO,OAAO,UAAkB,cAA4C;EAC1E,MAAM,CAAC,UAAU,YAAY,iBAAiB,SAAS;AACvD,SAAO,IAAI,uBAAuB,UAAU,UAAU,UAAU,aAAa;;;;;;;CAQ/E,MAAW;AACT,SAAO,KAAK,UAAU,KAAK;;;;;;;CAQ7B,cAA2B;AACzB,SAAO,KAAK;;;;;;;CAQd,gBAAwB;AACtB,SAAO,KAAK;;;;;;;CAQd,sBAAgC;AAC9B,SAAO,KAAK;;;;;;;CAQd,eAAqB;AACnB,SAAO,KAAK;;;;;CAMd,UAAU,OAAuC;EAC/C,MAAM,UA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AW,WAAA,GAAc,QAAA;EAvL3D;;;;;EAAA,OAyMD,UAAA,CACL,MAAA,EAAQ,QAAA,EACR,GAAA,EAAK,IAAA,EACL,cAAA,EAAgB,WAAA,cAChB,SAAA,EAAW,WAAA,GACV,aAAA;AAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"registry-FMU-ec5K.cjs","names":["normalizePetName","OwnerRecord","Registry","OwnerOutcome","ParticipantRecord","Registry","AddOutcome","path","fs"],"sources":["../src/cmd/registry/owner/set.ts","../src/cmd/registry/participant/add.ts","../src/cmd/registry/index.ts"],"sourcesContent":["/**\n * Copyright © 2023-2026 Blockchain Commons, LLC\n * Copyright © 2025-2026 Parity Technologies\n *\n *\n * Registry owner set command.\n *\n * Port of cmd/registry/owner/set.rs from frost-hubert-rust.\n *\n * @module\n */\n\nimport { Registry, OwnerRecord, OwnerOutcome } from \"../../../registry/index.js\";\nimport { participantsFilePath } from \"../index.js\";\n\n/**\n * Options for the owner set command.\n */\nexport interface OwnerSetOptions {\n /** Signed ur:xid document containing the owner's XID document (must include private keys) */\n xidDocument: string;\n /** Optional human readable alias for the owner */\n petName?: string | undefined;\n /** Optional registry path or filename override */\n registryPath?: string | undefined;\n}\n\n/**\n * Result of the owner set command.\n */\nexport interface OwnerSetResult {\n outcome: OwnerOutcome;\n}\n\n/**\n * Normalize pet name, trimming whitespace and validating non-empty.\n */\nfunction normalizePetName(petName?: string): string | undefined {\n if (petName === undefined) {\n return undefined;\n }\n\n const trimmed = petName.trim();\n if (trimmed.length === 0) {\n throw new Error(\"Pet name cannot be empty\");\n }\n\n return trimmed;\n}\n\n/**\n * Execute the owner set command.\n *\n * Sets the registry owner using an ur:xid document that includes private keys.\n *\n * Port of `CommandArgs.exec()` from cmd/registry/owner/set.rs.\n */\nexport function ownerSet(options: OwnerSetOptions, cwd: string): OwnerSetResult {\n const petName = normalizePetName(options.petName);\n const owner = OwnerRecord.fromSignedXidUr(options.xidDocument, petName);\n const path = participantsFilePath(options.registryPath, cwd);\n const registry = Registry.load(path);\n\n const outcome = registry.setOwner(owner);\n\n if (outcome === OwnerOutcome.AlreadyPresent) {\n console.log(\"Owner already recorded\");\n }\n\n // Always save to persist pet name updates on existing owner records.\n registry.save(path);\n\n return { outcome };\n}\n","/**\n * Copyright © 2023-2026 Blockchain Commons, LLC\n * Copyright © 2025-2026 Parity Technologies\n *\n *\n * Registry participant add command.\n *\n * Port of cmd/registry/participant/add.rs from frost-hubert-rust.\n *\n * @module\n */\n\nimport { Registry, ParticipantRecord, AddOutcome } from \"../../../registry/index.js\";\nimport { participantsFilePath } from \"../index.js\";\n\n/**\n * Options for the participant add command.\n */\nexport interface ParticipantAddOptions {\n /** Signed ur:xid document containing the participant's XID document */\n xidDocument: string;\n /** Optional human readable alias */\n petName?: string | undefined;\n /** Optional registry path or filename override */\n registryPath?: string | undefined;\n}\n\n/**\n * Result of the participant add command.\n */\nexport interface ParticipantAddResult {\n outcome: AddOutcome;\n}\n\n/**\n * Normalize pet name, trimming whitespace and validating non-empty.\n */\nfunction normalizePetName(petName?: string): string | undefined {\n if (petName === undefined) {\n return undefined;\n }\n\n const trimmed = petName.trim();\n if (trimmed.length === 0) {\n throw new Error(\"Pet name cannot be empty\");\n }\n\n return trimmed;\n}\n\n/**\n * Execute the participant add command.\n *\n * Adds a participant using an ur:xid document.\n *\n * Port of `CommandArgs.exec()` from cmd/registry/participant/add.rs.\n */\nexport function participantAdd(options: ParticipantAddOptions, cwd: string): ParticipantAddResult {\n const petName = normalizePetName(options.petName);\n const participant = ParticipantRecord.fromSignedXidUr(options.xidDocument, petName);\n const xid = participant.xid();\n const path = participantsFilePath(options.registryPath, cwd);\n const registry = Registry.load(path);\n\n const outcome = registry.addParticipant(xid, participant);\n\n if (outcome === AddOutcome.AlreadyPresent) {\n console.log(\"Participant already recorded\");\n } else if (outcome === AddOutcome.Inserted) {\n registry.save(path);\n }\n\n return { outcome };\n}\n","/**\n * Copyright © 2023-2026 Blockchain Commons, LLC\n * Copyright © 2025-2026 Parity Technologies\n *\n *\n * Registry commands.\n *\n * Port of cmd/registry/mod.rs from frost-hubert-rust.\n *\n * @module\n */\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\nexport * from \"./owner/index.js\";\nexport * from \"./participant/index.js\";\n\nconst DEFAULT_FILENAME = \"registry.json\";\n\n/**\n * Resolve the participants registry path, defaulting to `registry.json` in the\n * current working directory.\n *\n * Port of `participants_file_path()` from cmd/registry/mod.rs.\n */\nexport function participantsFilePath(registry: string | undefined, cwd: string): string {\n if (registry === undefined) {\n return path.join(cwd, DEFAULT_FILENAME);\n }\n\n return resolveRegistryPath(cwd, DEFAULT_FILENAME, registry);\n}\n\n/**\n * Resolve registry path with smart directory detection.\n *\n * Port of `resolve_registry_path()` from cmd/registry/mod.rs.\n */\nfunction resolveRegistryPath(cwd: string, defaultFilename: string, raw: string): string {\n const trimmed = raw.trim();\n if (trimmed.length === 0) {\n throw new Error(\"Registry path cannot be empty\");\n }\n\n const provided = trimmed;\n const treatAsDirectory = isDirectoryHint(trimmed, provided);\n\n let resolved: string;\n if (path.isAbsolute(provided)) {\n resolved = provided;\n } else {\n resolved = path.join(cwd, provided);\n }\n\n if (treatAsDirectory) {\n // Ensure the directory exists\n if (!fs.existsSync(resolved)) {\n fs.mkdirSync(resolved, { recursive: true });\n }\n resolved = path.join(resolved, defaultFilename);\n }\n\n return resolved;\n}\n\n/**\n * Check if the input should be treated as a directory path.\n *\n * Port of `is_directory_hint()` from cmd/registry/mod.rs.\n */\nfunction isDirectoryHint(input: string, pathStr: string): boolean {\n if (endsWithSeparator(input)) {\n return true;\n }\n\n const basename = path.basename(pathStr);\n if (basename === \"\" || basename === \".\" || basename === \"..\") {\n return true;\n }\n\n return false;\n}\n\n/**\n * Check if input ends with a path separator.\n *\n * Port of `ends_with_separator()` from cmd/registry/mod.rs.\n */\nfunction endsWithSeparator(input: string): boolean {\n return input.endsWith(\"/\") || input.endsWith(\"\\\\\");\n}\n"],"mappings":";;;;;;;;;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KAAqB;AACtF,KAAI,aAAa,OACf,QAAOC,UAAK,KAAK,KAAK,iBAAiB;AAGzC,QAAO,oBAAoB,KAAK,kBAAkB,SAAS;;;;;;;AAQ7D,SAAS,oBAAoB,KAAa,iBAAyB,KAAqB;CACtF,MAAM,UAAU,IAAI,MAAM;AAC1B,KAAI,QAAQ,WAAW,EACrB,OAAM,IAAI,MAAM,gCAAgC;CAGlD,MAAM,WAAW;CACjB,MAAM,mBAAmB,gBAAgB,SAAS,SAAS;CAE3D,IAAI;AACJ,KAAIA,UAAK,WAAW,SAAS,CAC3B,YAAW;KAEX,YAAWA,UAAK,KAAK,KAAK,SAAS;AAGrC,KAAI,kBAAkB;AAEpB,MAAI,CAACC,QAAG,WAAW,SAAS,CAC1B,SAAG,UAAU,UAAU,EAAE,WAAW,MAAM,CAAC;AAE7C,aAAWD,UAAK,KAAK,UAAU,gBAAgB;;AAGjD,QAAO;;;;;;;AAQT,SAAS,gBAAgB,OAAe,SAA0B;AAChE,KAAI,kBAAkB,MAAM,CAC1B,QAAO;CAGT,MAAM,WAAWA,UAAK,SAAS,QAAQ;AACvC,KAAI,aAAa,MAAM,aAAa,OAAO,aAAa,KACtD,QAAO;AAGT,QAAO;;;;;;;AAQT,SAAS,kBAAkB,OAAwB;AACjD,QAAO,MAAM,SAAS,IAAI,IAAI,MAAM,SAAS,KAAK"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"registry-impl-BETn_lEO.d.mts","names":[],"sources":["../src/registry/group-record.ts","../src/registry/owner-record.ts","../src/registry/participant-record.ts","../src/registry/registry-impl.ts"],"mappings":";;;;;;;;;cAmBa,gBAAA;EAAA,iBACM,IAAA;cAEL,GAAA,EAAK,GAAA;EAIjB,GAAA,CAAA,GAAO,GAAA;EAIP,MAAA,CAAA;EAAA,OAIO,QAAA,CAAS,KAAA,WAAgB,gBAAA;AAAA;AAWlC;;;;;AAAA,cAAa,iBAAA;EACX,YAAA;EACA,aAAA;EACA,YAAA;EACA,UAAA;cAEY,I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