@abraca/dabra 1.0.23 → 1.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abraca/dabra",
3
- "version": "1.0.23",
3
+ "version": "1.0.24",
4
4
  "description": "abracadabra provider",
5
5
  "keywords": [
6
6
  "abracadabra",
@@ -349,7 +349,7 @@ export class AbracadabraWebRTC extends EventEmitter {
349
349
  // Wait for open before sending.
350
350
  channel.onopen = () => {
351
351
  const data = new TextEncoder().encode(payload);
352
- pc.router.send(channelName, data);
352
+ pc.router.send(channelName, data).catch(() => {});
353
353
  };
354
354
  return;
355
355
  }
@@ -475,8 +475,12 @@ export class AbracadabraWebRTC extends EventEmitter {
475
475
  // Listen for key-exchange messages on the router.
476
476
  pc.router.on("channelMessage", async ({ name, data }: { name: string; data: any }) => {
477
477
  if (name === KEY_EXCHANGE_CHANNEL) {
478
- const buf = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
479
- await e2ee.handleKeyExchange(buf);
478
+ try {
479
+ const buf = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
480
+ await e2ee.handleKeyExchange(buf);
481
+ } catch (err) {
482
+ this.emit("e2eeFailed", { peerId, error: err });
483
+ }
480
484
  }
481
485
  });
482
486
 
@@ -559,7 +563,8 @@ export class AbracadabraWebRTC extends EventEmitter {
559
563
  try {
560
564
  const sdp = await pc.createOffer();
561
565
  this.signaling?.sendOffer(peerId, sdp);
562
- } catch {
566
+ } catch (err) {
567
+ this.emit("error", { type: "offer-failed", peerId, error: err });
563
568
  this.removePeer(peerId);
564
569
  }
565
570
  }
@@ -581,7 +586,8 @@ export class AbracadabraWebRTC extends EventEmitter {
581
586
  try {
582
587
  const answerSdp = await pc.setRemoteOffer(sdp);
583
588
  this.signaling?.sendAnswer(from, answerSdp);
584
- } catch {
589
+ } catch (err) {
590
+ this.emit("error", { type: "answer-failed", peerId: from, error: err });
585
591
  this.removePeer(from);
586
592
  }
587
593
  }
@@ -378,6 +378,18 @@ export class DevicePairingChannel extends EventEmitter {
378
378
  },
379
379
  );
380
380
 
381
+ this.webrtc.on("e2eeFailed", ({ peerId, error }: { peerId: string; error: any }) => {
382
+ if (!this._destroyed) {
383
+ this.emit("error", new Error(`E2EE failed: ${error?.message ?? error}`));
384
+ }
385
+ });
386
+
387
+ this.webrtc.on("error", (err: any) => {
388
+ if (!this._destroyed) {
389
+ this.emit("error", new Error(`WebRTC: ${err?.type ?? err?.message ?? "unknown"}`));
390
+ }
391
+ });
392
+
381
393
  this.webrtc.on("peerLeft", () => {
382
394
  if (!this._destroyed) {
383
395
  this.emit("error", new Error("Peer disconnected"));