@basmilius/apple-airplay 0.0.87 → 0.0.89
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/dist/index.js +12 -9
- package/dist/stream.d.ts +1 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1660,8 +1660,7 @@ class AirPlayStream extends EncryptionAwareConnection {
|
|
|
1660
1660
|
const aad = data.subarray(offset, offset + 2);
|
|
1661
1661
|
const ciphertext = data.subarray(offset + 2, offset + 2 + length);
|
|
1662
1662
|
const authTag = data.subarray(offset + 2 + length, offset + 2 + length + 16);
|
|
1663
|
-
const nonce =
|
|
1664
|
-
nonce.writeBigUInt64LE(BigInt(this.#encryption.readCount++), 4);
|
|
1663
|
+
const nonce = this.nonce(this.#encryption.readCount++);
|
|
1665
1664
|
const plaintext = Chacha20.decrypt(this.#encryption.readKey, nonce, aad, ciphertext, authTag);
|
|
1666
1665
|
result = Buffer.concat([result, plaintext]);
|
|
1667
1666
|
offset += totalChunkLength;
|
|
@@ -1675,14 +1674,19 @@ class AirPlayStream extends EncryptionAwareConnection {
|
|
|
1675
1674
|
const length = Math.min(total - offset, 1024);
|
|
1676
1675
|
const leLength = Buffer.alloc(2);
|
|
1677
1676
|
leLength.writeUInt16LE(length, 0);
|
|
1678
|
-
const nonce =
|
|
1679
|
-
nonce.writeBigUInt64LE(BigInt(this.#encryption.writeCount++), 4);
|
|
1677
|
+
const nonce = this.nonce(this.#encryption.writeCount++);
|
|
1680
1678
|
const encrypted = Chacha20.encrypt(this.#encryption.writeKey, nonce, leLength, data.subarray(offset, offset + length));
|
|
1681
1679
|
offset += length;
|
|
1682
1680
|
result = Buffer.concat([result, leLength, encrypted.ciphertext, encrypted.authTag]);
|
|
1683
1681
|
}
|
|
1684
1682
|
return result;
|
|
1685
1683
|
}
|
|
1684
|
+
nonce(counter) {
|
|
1685
|
+
const nonceArray = new Uint8Array(12);
|
|
1686
|
+
const view = new DataView(nonceArray.buffer);
|
|
1687
|
+
view.setBigUint64(4, BigInt(counter), true);
|
|
1688
|
+
return Buffer.from(nonceArray);
|
|
1689
|
+
}
|
|
1686
1690
|
}
|
|
1687
1691
|
|
|
1688
1692
|
// src/dataStream.ts
|
|
@@ -1862,7 +1866,8 @@ class AirPlayDataStream extends AirPlayStream {
|
|
|
1862
1866
|
}
|
|
1863
1867
|
}
|
|
1864
1868
|
} catch (err) {
|
|
1865
|
-
reporter.error("Error in onData", err);
|
|
1869
|
+
reporter.error("Error in data stream onData()", err);
|
|
1870
|
+
this.emit("error", err);
|
|
1866
1871
|
}
|
|
1867
1872
|
}
|
|
1868
1873
|
async#decrypt(data) {
|
|
@@ -1876,8 +1881,7 @@ class AirPlayDataStream extends AirPlayStream {
|
|
|
1876
1881
|
}
|
|
1877
1882
|
const frameLength = data.readUInt16LE(offset);
|
|
1878
1883
|
offset += 2;
|
|
1879
|
-
const nonce =
|
|
1880
|
-
nonce.writeBigUInt64LE(BigInt(readCount++), 4);
|
|
1884
|
+
const nonce = this.nonce(readCount++);
|
|
1881
1885
|
const end = offset + frameLength + 16;
|
|
1882
1886
|
if (end > data.length) {
|
|
1883
1887
|
reporter.warn(`Truncated frame end=${end} length=${data.length}`);
|
|
@@ -1900,8 +1904,7 @@ class AirPlayDataStream extends AirPlayStream {
|
|
|
1900
1904
|
offset += frame.length;
|
|
1901
1905
|
const leLength = Buffer.alloc(2);
|
|
1902
1906
|
leLength.writeUInt16LE(frame.length, 0);
|
|
1903
|
-
const nonce =
|
|
1904
|
-
nonce.writeBigUInt64LE(BigInt(this.#encryption.writeCount++), 4);
|
|
1907
|
+
const nonce = this.nonce(this.#encryption.writeCount++);
|
|
1905
1908
|
const encrypted = Chacha202.encrypt(this.#encryption.writeKey, nonce, leLength, frame);
|
|
1906
1909
|
result.push(leLength, encrypted.ciphertext, encrypted.authTag);
|
|
1907
1910
|
}
|
package/dist/stream.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basmilius/apple-airplay",
|
|
3
3
|
"description": "Implementation of Apple's AirPlay2 in Node.js.",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.89",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": {
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@basmilius/apple-common": "0.0.
|
|
45
|
-
"@basmilius/apple-encoding": "0.0.
|
|
44
|
+
"@basmilius/apple-common": "0.0.89",
|
|
45
|
+
"@basmilius/apple-encoding": "0.0.89",
|
|
46
46
|
"@bufbuild/protobuf": "^2.10.2"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|