@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.
@@ -9992,7 +9992,7 @@ var AbracadabraWebRTC = class AbracadabraWebRTC extends EventEmitter {
9992
9992
  channel = pc.router.createChannel(channelName, { ordered: true });
9993
9993
  channel.onopen = () => {
9994
9994
  const data = new TextEncoder().encode(payload);
9995
- pc.router.send(channelName, data);
9995
+ pc.router.send(channelName, data).catch(() => {});
9996
9996
  };
9997
9997
  return;
9998
9998
  }
@@ -10078,9 +10078,14 @@ var AbracadabraWebRTC = class AbracadabraWebRTC extends EventEmitter {
10078
10078
  this.e2eeChannels.set(peerId, e2ee);
10079
10079
  pc.router.setEncryptor(e2ee);
10080
10080
  pc.router.on("channelMessage", async ({ name, data }) => {
10081
- if (name === KEY_EXCHANGE_CHANNEL) {
10081
+ if (name === KEY_EXCHANGE_CHANNEL) try {
10082
10082
  const buf = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
10083
10083
  await e2ee.handleKeyExchange(buf);
10084
+ } catch (err) {
10085
+ this.emit("e2eeFailed", {
10086
+ peerId,
10087
+ error: err
10088
+ });
10084
10089
  }
10085
10090
  });
10086
10091
  pc.router.on("channelOpen", ({ name, channel }) => {
@@ -10151,7 +10156,12 @@ var AbracadabraWebRTC = class AbracadabraWebRTC extends EventEmitter {
10151
10156
  try {
10152
10157
  const sdp = await pc.createOffer();
10153
10158
  this.signaling?.sendOffer(peerId, sdp);
10154
- } catch {
10159
+ } catch (err) {
10160
+ this.emit("error", {
10161
+ type: "offer-failed",
10162
+ peerId,
10163
+ error: err
10164
+ });
10155
10165
  this.removePeer(peerId);
10156
10166
  }
10157
10167
  }
@@ -10169,7 +10179,12 @@ var AbracadabraWebRTC = class AbracadabraWebRTC extends EventEmitter {
10169
10179
  try {
10170
10180
  const answerSdp = await pc.setRemoteOffer(sdp);
10171
10181
  this.signaling?.sendAnswer(from, answerSdp);
10172
- } catch {
10182
+ } catch (err) {
10183
+ this.emit("error", {
10184
+ type: "answer-failed",
10185
+ peerId: from,
10186
+ error: err
10187
+ });
10173
10188
  this.removePeer(from);
10174
10189
  }
10175
10190
  }
@@ -10587,6 +10602,12 @@ var DevicePairingChannel = class DevicePairingChannel extends EventEmitter {
10587
10602
  this.webrtc.on("customMessage", ({ peerId, payload }) => {
10588
10603
  this.handleMessage(peerId, payload);
10589
10604
  });
10605
+ this.webrtc.on("e2eeFailed", ({ peerId, error }) => {
10606
+ if (!this._destroyed) this.emit("error", /* @__PURE__ */ new Error(`E2EE failed: ${error?.message ?? error}`));
10607
+ });
10608
+ this.webrtc.on("error", (err) => {
10609
+ if (!this._destroyed) this.emit("error", /* @__PURE__ */ new Error(`WebRTC: ${err?.type ?? err?.message ?? "unknown"}`));
10610
+ });
10590
10611
  this.webrtc.on("peerLeft", () => {
10591
10612
  if (!this._destroyed) this.emit("error", /* @__PURE__ */ new Error("Peer disconnected"));
10592
10613
  });