@abraca/dabra 1.9.1 → 2.0.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.
@@ -527,7 +527,7 @@ export class AbracadabraWebRTC extends EventEmitter {
527
527
  pendingKeyExchangeChannel = channel;
528
528
  return;
529
529
  }
530
- channel.send(e2ee.getKeyExchangeMessage());
530
+ channel.send(e2ee.getKeyExchangeMessage() as unknown as ArrayBuffer);
531
531
  });
532
532
 
533
533
  this.resolveE2ee().then(async (identity) => {
@@ -541,7 +541,7 @@ export class AbracadabraWebRTC extends EventEmitter {
541
541
 
542
542
  // Drain buffered key-exchange channel open
543
543
  if (pendingKeyExchangeChannel) {
544
- pendingKeyExchangeChannel.send(e2ee.getKeyExchangeMessage());
544
+ pendingKeyExchangeChannel.send(e2ee.getKeyExchangeMessage() as unknown as ArrayBuffer);
545
545
  }
546
546
  // Drain buffered messages
547
547
  for (const msg of pendingMessages) {
@@ -100,9 +100,9 @@ export class DataChannelRouter extends EventEmitter {
100
100
 
101
101
  if (this.encryptor?.isEstablished && !this.plaintextChannels.has(name)) {
102
102
  const encrypted = await this.encryptor.encrypt(data);
103
- channel.send(encrypted);
103
+ channel.send(encrypted as unknown as ArrayBuffer);
104
104
  } else {
105
- channel.send(data);
105
+ channel.send(data as unknown as ArrayBuffer);
106
106
  }
107
107
  return true;
108
108
  }
@@ -98,7 +98,7 @@ export class E2EEChannel extends EventEmitter {
98
98
 
99
99
  this.sessionKey = await crypto.subtle.importKey(
100
100
  "raw",
101
- keyBytes,
101
+ keyBytes as BufferSource,
102
102
  { name: "AES-GCM" },
103
103
  false,
104
104
  ["encrypt", "decrypt"],
@@ -130,9 +130,9 @@ export class E2EEChannel extends EventEmitter {
130
130
  const nonce = crypto.getRandomValues(new Uint8Array(NONCE_BYTES));
131
131
  const ciphertext = new Uint8Array(
132
132
  await crypto.subtle.encrypt(
133
- { name: "AES-GCM", iv: nonce },
133
+ { name: "AES-GCM", iv: nonce as BufferSource },
134
134
  this.sessionKey,
135
- plaintext,
135
+ plaintext as BufferSource,
136
136
  ),
137
137
  );
138
138
 
@@ -45,6 +45,13 @@ export class FileTransferHandle extends EventEmitter {
45
45
  _setStatus(s: FileTransferStatus): void {
46
46
  this.status = s;
47
47
  }
48
+
49
+ /** @internal — public alias for the protected emit so the parent
50
+ * `FileTransferChannel` (a different class instance) can dispatch events
51
+ * on this handle. Protected access is by-class, not by-hierarchy. */
52
+ _emit(event: string, ...args: unknown[]): void {
53
+ this.emit(event, ...args);
54
+ }
48
55
  }
49
56
 
50
57
  interface ReceiveState {
@@ -102,7 +109,7 @@ export class FileTransferChannel extends EventEmitter {
102
109
  const channel = this.router.getChannel(CHANNEL_NAMES.FILE_TRANSFER);
103
110
  if (!channel || channel.readyState !== "open") {
104
111
  handle._setStatus("error");
105
- handle.emit("error", new Error("File transfer channel not open"));
112
+ handle._emit("error", new Error("File transfer channel not open"));
106
113
  return handle;
107
114
  }
108
115
 
@@ -174,7 +181,7 @@ export class FileTransferChannel extends EventEmitter {
174
181
  channel.send(completeMsg);
175
182
 
176
183
  handle._setStatus("complete");
177
- handle.emit("complete");
184
+ handle._emit("complete");
178
185
 
179
186
  return handle;
180
187
  }