@basmilius/apple-airplay 0.5.2 → 0.5.4

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024-2025 Bas Milius
3
+ Copyright (c) 2024-present Bas Milius
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,4 +1,4 @@
1
- import { type Context } from "@basmilius/apple-common";
1
+ import type { Context } from "@basmilius/apple-common";
2
2
  import BaseStream from "./baseStream";
3
3
  export default class EventStream extends BaseStream {
4
4
  #private;
package/dist/index.js CHANGED
@@ -10,9 +10,11 @@ var __export = (target, all) => {
10
10
  };
11
11
 
12
12
  // src/baseStream.ts
13
- import { Chacha20, ENCRYPTION, EncryptionAwareConnection } from "@basmilius/apple-common";
13
+ import { ENCRYPTION, EncryptionAwareConnection } from "@basmilius/apple-common";
14
+ import { Chacha20 } from "@basmilius/apple-encryption";
14
15
 
15
16
  // src/utils.ts
17
+ import { uuid } from "@basmilius/apple-common";
16
18
  import { Plist } from "@basmilius/apple-encoding";
17
19
  import { fromBinary } from "@bufbuild/protobuf";
18
20
 
@@ -1488,7 +1490,7 @@ function generateDacpId() {
1488
1490
  return Math.floor(Math.random() * 2 ** 64).toString(16).toUpperCase();
1489
1491
  }
1490
1492
  function generateSessionId() {
1491
- return Math.floor(Math.random() * 2 ** 32).toString(10);
1493
+ return uuid().toUpperCase();
1492
1494
  }
1493
1495
  function nonce(counter) {
1494
1496
  const nonceArray = new Uint8Array(12);
@@ -1676,25 +1678,22 @@ class ControlStream extends BaseStream {
1676
1678
  this.#resolve = undefined;
1677
1679
  this.#requesting = false;
1678
1680
  }
1679
- async#request(method, path, body, headers, timeout = HTTP_TIMEOUT) {
1681
+ #request(method, path, body, headers, timeout = HTTP_TIMEOUT) {
1680
1682
  if (this.#requesting) {
1681
1683
  return Promise.reject(new Error("Another request is currently being made."));
1682
1684
  }
1683
1685
  this.#requesting = true;
1684
- headers["Active-Remote"] = this.activeRemoteId;
1685
- headers["Client-Instance"] = this.dacpId;
1686
- headers["DACP-ID"] = this.dacpId;
1687
1686
  const cseq = this.#cseq++;
1688
1687
  let data;
1689
1688
  if (body) {
1690
1689
  headers["Content-Length"] = Buffer.byteLength(body);
1691
1690
  data = Buffer.concat([
1692
- Buffer.from(RTSP.makeHeader(method, path, headers, cseq)),
1691
+ Buffer.from(RTSP.makeHeader(method, path, headers, cseq, this.#activeRemoteId, this.#dacpId, this.#sessionId)),
1693
1692
  Buffer.from(body)
1694
1693
  ]);
1695
1694
  } else {
1696
1695
  headers["Content-Length"] = 0;
1697
- data = Buffer.from(RTSP.makeHeader(method, path, headers, cseq));
1696
+ data = Buffer.from(RTSP.makeHeader(method, path, headers, cseq, this.#activeRemoteId, this.#dacpId, this.#sessionId));
1698
1697
  }
1699
1698
  this.context.logger.net("[control]", method, path, `cseq = ${cseq}`);
1700
1699
  if (this.isEncrypted) {
@@ -1745,8 +1744,9 @@ class ControlStream extends BaseStream {
1745
1744
  }
1746
1745
  }
1747
1746
  // src/dataStream.ts
1748
- import { hkdf, randomInt32 } from "@basmilius/apple-common";
1747
+ import { randomInt32 } from "@basmilius/apple-common";
1749
1748
  import { Plist as Plist2 } from "@basmilius/apple-encoding";
1749
+ import { hkdf } from "@basmilius/apple-encryption";
1750
1750
  import { getExtension, toBinary } from "@bufbuild/protobuf";
1751
1751
  var DATA_HEADER_LENGTH = 32;
1752
1752
 
@@ -1968,8 +1968,8 @@ class DataStream extends BaseStream {
1968
1968
  }
1969
1969
  }
1970
1970
  // src/eventStream.ts
1971
- import { hkdf as hkdf2 } from "@basmilius/apple-common";
1972
1971
  import { Plist as Plist3, RTSP as RTSP2 } from "@basmilius/apple-encoding";
1972
+ import { hkdf as hkdf2 } from "@basmilius/apple-encryption";
1973
1973
  class EventStream extends BaseStream {
1974
1974
  #buffer = Buffer.alloc(0);
1975
1975
  constructor(context, address, port) {
@@ -2069,11 +2069,12 @@ class EventStream extends BaseStream {
2069
2069
  }
2070
2070
  }
2071
2071
  // src/protocol.ts
2072
- import { Context, getMacAddress, randomInt64, uuid } from "@basmilius/apple-common";
2072
+ import { Context, getMacAddress, randomInt64, uuid as uuid2 } from "@basmilius/apple-common";
2073
2073
  import { Plist as Plist4 } from "@basmilius/apple-encoding";
2074
2074
 
2075
2075
  // src/pairing.ts
2076
- import { AccessoryPair, AccessoryVerify, hkdf as hkdf3 } from "@basmilius/apple-common";
2076
+ import { AccessoryPair, AccessoryVerify } from "@basmilius/apple-common";
2077
+ import { hkdf as hkdf3 } from "@basmilius/apple-encryption";
2077
2078
 
2078
2079
  class Pairing {
2079
2080
  get controlStream() {
@@ -2207,7 +2208,7 @@ class Protocol {
2207
2208
  constructor(discoveryResult) {
2208
2209
  this.#context = new Context(discoveryResult.id);
2209
2210
  this.#discoveryResult = discoveryResult;
2210
- this.#sessionUUID = uuid();
2211
+ this.#sessionUUID = uuid2();
2211
2212
  this.#controlStream = new ControlStream(this.#context, discoveryResult.address, discoveryResult.service.port);
2212
2213
  this.#pairing = new Pairing(this);
2213
2214
  this.#verify = new Verify(this);
@@ -2233,9 +2234,9 @@ class Protocol {
2233
2234
  const request = Plist4.serialize({
2234
2235
  streams: [{
2235
2236
  controlType: 2,
2236
- channelID: uuid().toUpperCase(),
2237
+ channelID: uuid2().toUpperCase(),
2237
2238
  seed,
2238
- clientUUID: uuid().toUpperCase(),
2239
+ clientUUID: uuid2().toUpperCase(),
2239
2240
  type: 130,
2240
2241
  wantsDedicatedSocket: true,
2241
2242
  clientTypeUUID: "1910A70F-DBC0-4242-AF95-115DB30604E1"
@@ -2265,7 +2266,7 @@ class Protocol {
2265
2266
  osBuildVersion: "18C66",
2266
2267
  osName: "iPhone OS",
2267
2268
  osVersion: "14.3",
2268
- sourceVersion: "550.10",
2269
+ sourceVersion: "320.20",
2269
2270
  sessionUUID: this.#sessionUUID,
2270
2271
  timingProtocol: "None",
2271
2272
  isRemoteControlOnly: true
@@ -2316,14 +2317,14 @@ __export(exports_dataStreamMessages, {
2316
2317
  configureConnection: () => configureConnection,
2317
2318
  clientUpdatesConfig: () => clientUpdatesConfig
2318
2319
  });
2319
- import { uint16ToBE, uuid as uuid2 } from "@basmilius/apple-common";
2320
+ import { uint16ToBE, uuid as uuid3 } from "@basmilius/apple-common";
2320
2321
  import { create, getExtension as _getExtension, setExtension } from "@bufbuild/protobuf";
2321
2322
  function protocol(type, errorCode = 0 /* NoError */) {
2322
2323
  return create(ProtocolMessageSchema, {
2323
2324
  type,
2324
2325
  errorCode,
2325
- identifier: uuid2().toUpperCase(),
2326
- uniqueIdentifier: uuid2().toUpperCase()
2326
+ identifier: uuid3().toUpperCase(),
2327
+ uniqueIdentifier: uuid3().toUpperCase()
2327
2328
  });
2328
2329
  }
2329
2330
  function clientUpdatesConfig(artworkUpdates = true, nowPlayingUpdates = true, volumeUpdates = true, keyboardUpdates = false, outputDeviceUpdates = true, systemEndpointUpdates = true) {
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.5.2",
4
+ "version": "0.5.4",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": {
@@ -41,13 +41,14 @@
41
41
  }
42
42
  },
43
43
  "dependencies": {
44
- "@basmilius/apple-common": "0.5.2",
45
- "@basmilius/apple-encoding": "0.5.2",
44
+ "@basmilius/apple-common": "0.5.4",
45
+ "@basmilius/apple-encoding": "0.5.4",
46
+ "@basmilius/apple-encryption": "0.5.4",
46
47
  "@bufbuild/protobuf": "^2.11.0"
47
48
  },
48
49
  "devDependencies": {
49
50
  "@basmilius/tools": "^2.23.0",
50
- "@bufbuild/buf": "^1.64.0",
51
+ "@bufbuild/buf": "^1.65.0",
51
52
  "@bufbuild/protoc-gen-es": "^2.11.0",
52
53
  "@types/bun": "^1.3.8"
53
54
  }