@basmilius/apple-companion-link 0.9.15 → 0.9.17

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.
Files changed (2) hide show
  1. package/dist/index.mjs +7 -0
  2. package/package.json +4 -4
package/dist/index.mjs CHANGED
@@ -177,6 +177,7 @@ function convertAttentionState(state) {
177
177
  //#endregion
178
178
  //#region src/stream.ts
179
179
  const HEADER_SIZE = 4;
180
+ const MAX_BUFFER_SIZE = 1024 * 1024;
180
181
  const PAIRING_QUEUE_IDENTIFIER = -1;
181
182
  var Stream = class extends EncryptionAwareConnection {
182
183
  get #encryptionState() {
@@ -246,6 +247,12 @@ var Stream = class extends EncryptionAwareConnection {
246
247
  }
247
248
  async #onData(data) {
248
249
  this.#buffer = Buffer.concat([this.#buffer, data]);
250
+ if (this.#buffer.byteLength > MAX_BUFFER_SIZE) {
251
+ this.context.logger.error("[companion-link]", `Buffer exceeded max size (${this.#buffer.byteLength} bytes), resetting connection.`);
252
+ this.#buffer = Buffer.alloc(0);
253
+ this.emit("error", /* @__PURE__ */ new Error("Buffer overflow: exceeded maximum buffer size"));
254
+ return;
255
+ }
249
256
  try {
250
257
  while (this.#buffer.byteLength >= HEADER_SIZE) {
251
258
  const header = this.#buffer.subarray(0, HEADER_SIZE);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@basmilius/apple-companion-link",
3
3
  "description": "Implementation of Apple's Companion Link in Node.js.",
4
- "version": "0.9.15",
4
+ "version": "0.9.17",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": {
@@ -46,9 +46,9 @@
46
46
  }
47
47
  },
48
48
  "dependencies": {
49
- "@basmilius/apple-common": "0.9.15",
50
- "@basmilius/apple-encoding": "0.9.15",
51
- "@basmilius/apple-encryption": "0.9.15"
49
+ "@basmilius/apple-common": "0.9.17",
50
+ "@basmilius/apple-encoding": "0.9.17",
51
+ "@basmilius/apple-encryption": "0.9.17"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@types/bun": "^1.3.11",