@abraca/dabra 1.5.0 → 1.8.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.
@@ -77,11 +77,15 @@ interface PairRequestMsg {
77
77
 
78
78
  interface PairApprovedMsg {
79
79
  type: "pair-approved";
80
+ /** Approver's account-level Ed25519 public key (base64url). */
81
+ masterPublicKey?: string;
80
82
  }
81
83
 
82
84
  interface PairInviteCodeMsg {
83
85
  type: "pair-invite-code";
84
86
  code: string;
87
+ /** Approver's account-level Ed25519 public key (base64url). */
88
+ masterPublicKey?: string;
85
89
  }
86
90
 
87
91
  interface PairRejectedMsg {
@@ -171,8 +175,12 @@ export class DevicePairingChannel extends EventEmitter {
171
175
  /**
172
176
  * Approve the pending pairing request. Calls `client.addKey()` to
173
177
  * register Device B's public key, then notifies Device B.
178
+ *
179
+ * @param client Authenticated REST client.
180
+ * @param masterPublicKey Approver's account-level Ed25519 public key (base64url).
181
+ * Sent to Device B so it can adopt the master's identity doc.
174
182
  */
175
- async approve(client: AbracadabraClient): Promise<PairingResult> {
183
+ async approve(client: AbracadabraClient, masterPublicKey?: string): Promise<PairingResult> {
176
184
  if (this.role !== "approver") {
177
185
  return { success: false, error: "Only the approver can approve" };
178
186
  }
@@ -192,7 +200,7 @@ export class DevicePairingChannel extends EventEmitter {
192
200
  x25519Key: req.x25519Key,
193
201
  });
194
202
 
195
- this.sendMessage({ type: "pair-approved" });
203
+ this.sendMessage({ type: "pair-approved", masterPublicKey });
196
204
  this._pendingRequest = null;
197
205
  this.emit("pairingComplete", { success: true } as PairingResult);
198
206
  return { success: true };
@@ -210,8 +218,12 @@ export class DevicePairingChannel extends EventEmitter {
210
218
  * Approve via server-side device invite. Creates a single-use invite code
211
219
  * and sends it to Device B over the E2EE channel. Device B redeems it
212
220
  * independently via HTTP — Device A can go offline after this.
221
+ *
222
+ * @param client Authenticated REST client.
223
+ * @param masterPublicKey Approver's account-level Ed25519 public key (base64url).
224
+ * Sent to Device B so it can adopt the master's identity doc.
213
225
  */
214
- async approveWithInvite(client: AbracadabraClient): Promise<PairingResult> {
226
+ async approveWithInvite(client: AbracadabraClient, masterPublicKey?: string): Promise<PairingResult> {
215
227
  if (this.role !== "approver") {
216
228
  return { success: false, error: "Only the approver can approve" };
217
229
  }
@@ -224,7 +236,7 @@ export class DevicePairingChannel extends EventEmitter {
224
236
 
225
237
  try {
226
238
  const { code } = await client.createDeviceInvite();
227
- this.sendMessage({ type: "pair-invite-code", code });
239
+ this.sendMessage({ type: "pair-invite-code", code, masterPublicKey });
228
240
  this._pendingRequest = null;
229
241
  this.emit("pairingComplete", { success: true } as PairingResult);
230
242
  return { success: true };
@@ -462,7 +474,7 @@ export class DevicePairingChannel extends EventEmitter {
462
474
 
463
475
  case "pair-approved":
464
476
  if (this.role !== "requester") return;
465
- this.emit("approved");
477
+ this.emit("approved", { masterPublicKey: msg.masterPublicKey });
466
478
  this.emit("pairingComplete", { success: true } as PairingResult);
467
479
  break;
468
480
 
@@ -477,7 +489,7 @@ export class DevicePairingChannel extends EventEmitter {
477
489
 
478
490
  case "pair-invite-code":
479
491
  if (this.role !== "requester") return;
480
- this.emit("inviteCode", msg.code);
492
+ this.emit("inviteCode", msg.code, msg.masterPublicKey);
481
493
  break;
482
494
  }
483
495
  }