@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.
@@ -9940,7 +9940,7 @@ var AbracadabraWebRTC = class AbracadabraWebRTC extends EventEmitter {
9940
9940
  channel = pc.router.createChannel(channelName, { ordered: true });
9941
9941
  channel.onopen = () => {
9942
9942
  const data = new TextEncoder().encode(payload);
9943
- pc.router.send(channelName, data);
9943
+ pc.router.send(channelName, data).catch(() => {});
9944
9944
  };
9945
9945
  return;
9946
9946
  }
@@ -10026,9 +10026,14 @@ var AbracadabraWebRTC = class AbracadabraWebRTC extends EventEmitter {
10026
10026
  this.e2eeChannels.set(peerId, e2ee);
10027
10027
  pc.router.setEncryptor(e2ee);
10028
10028
  pc.router.on("channelMessage", async ({ name, data }) => {
10029
- if (name === KEY_EXCHANGE_CHANNEL) {
10029
+ if (name === KEY_EXCHANGE_CHANNEL) try {
10030
10030
  const buf = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
10031
10031
  await e2ee.handleKeyExchange(buf);
10032
+ } catch (err) {
10033
+ this.emit("e2eeFailed", {
10034
+ peerId,
10035
+ error: err
10036
+ });
10032
10037
  }
10033
10038
  });
10034
10039
  pc.router.on("channelOpen", ({ name, channel }) => {
@@ -10099,7 +10104,12 @@ var AbracadabraWebRTC = class AbracadabraWebRTC extends EventEmitter {
10099
10104
  try {
10100
10105
  const sdp = await pc.createOffer();
10101
10106
  this.signaling?.sendOffer(peerId, sdp);
10102
- } catch {
10107
+ } catch (err) {
10108
+ this.emit("error", {
10109
+ type: "offer-failed",
10110
+ peerId,
10111
+ error: err
10112
+ });
10103
10113
  this.removePeer(peerId);
10104
10114
  }
10105
10115
  }
@@ -10117,7 +10127,12 @@ var AbracadabraWebRTC = class AbracadabraWebRTC extends EventEmitter {
10117
10127
  try {
10118
10128
  const answerSdp = await pc.setRemoteOffer(sdp);
10119
10129
  this.signaling?.sendAnswer(from, answerSdp);
10120
- } catch {
10130
+ } catch (err) {
10131
+ this.emit("error", {
10132
+ type: "answer-failed",
10133
+ peerId: from,
10134
+ error: err
10135
+ });
10121
10136
  this.removePeer(from);
10122
10137
  }
10123
10138
  }
@@ -10535,6 +10550,12 @@ var DevicePairingChannel = class DevicePairingChannel extends EventEmitter {
10535
10550
  this.webrtc.on("customMessage", ({ peerId, payload }) => {
10536
10551
  this.handleMessage(peerId, payload);
10537
10552
  });
10553
+ this.webrtc.on("e2eeFailed", ({ peerId, error }) => {
10554
+ if (!this._destroyed) this.emit("error", /* @__PURE__ */ new Error(`E2EE failed: ${error?.message ?? error}`));
10555
+ });
10556
+ this.webrtc.on("error", (err) => {
10557
+ if (!this._destroyed) this.emit("error", /* @__PURE__ */ new Error(`WebRTC: ${err?.type ?? err?.message ?? "unknown"}`));
10558
+ });
10538
10559
  this.webrtc.on("peerLeft", () => {
10539
10560
  if (!this._destroyed) this.emit("error", /* @__PURE__ */ new Error("Peer disconnected"));
10540
10561
  });