@basmilius/apple-encoding 0.9.16 → 0.9.18

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.d.mts CHANGED
@@ -156,24 +156,6 @@ declare const serialize: (value: Value$1) => ArrayBufferLike;
156
156
  declare namespace plist_d_exports {
157
157
  export { parse, serialize };
158
158
  }
159
- declare namespace rtsp_d_exports {
160
- export { Method$1 as Method, makeHeader, makeRequest, makeResponse };
161
- }
162
- type Method$1 = "GET" | "OPTIONS" | "POST" | "PUT" | "GET_PARAMETER" | "SET_PARAMETER" | "ANNOUNCE" | "FLUSH" | "RECORD" | "SETUP" | "TEARDOWN";
163
- declare function makeHeader(method: Method$1, path: string, headers: HeadersInit, cseq: number, activeRemote: string, dacpId: string, sessionId: string): string;
164
- declare function makeRequest(buffer: Buffer): HttpRequest | null;
165
- declare function makeResponse(buffer: Buffer): HttpResponse | null;
166
- type HttpRequest = {
167
- readonly headers: Record<string, string>;
168
- readonly method: Method$1;
169
- readonly path: string;
170
- readonly body: Buffer;
171
- readonly requestLength: number;
172
- };
173
- type HttpResponse = {
174
- readonly response: Response;
175
- readonly responseLength: number;
176
- };
177
159
  declare namespace tlv8_d_exports {
178
160
  export { ErrorCode, Flags, Method, State, Value, bail, decode, encode };
179
161
  }
@@ -227,4 +209,4 @@ declare function bail(data: Map<number, Buffer>): never;
227
209
  declare function encode(entries: [number, number | Buffer | Uint8Array][]): Buffer;
228
210
  declare function decode(buf: Buffer): Map<number, Buffer>;
229
211
  //#endregion
230
- export { daap_d_exports as DAAP, ntp_d_exports as NTP, opack_d_exports as OPack, plist_d_exports as Plist, rtsp_d_exports as RTSP, tlv8_d_exports as TLV8 };
212
+ export { daap_d_exports as DAAP, ntp_d_exports as NTP, opack_d_exports as OPack, plist_d_exports as Plist, tlv8_d_exports as TLV8 };
package/dist/index.mjs CHANGED
@@ -1247,94 +1247,6 @@ var plist_exports = /* @__PURE__ */ __exportAll({
1247
1247
  serialize: () => serialize
1248
1248
  });
1249
1249
 
1250
- //#endregion
1251
- //#region src/rtsp.ts
1252
- var rtsp_exports = /* @__PURE__ */ __exportAll({
1253
- makeHeader: () => makeHeader,
1254
- makeRequest: () => makeRequest,
1255
- makeResponse: () => makeResponse
1256
- });
1257
- function makeHeader(method, path, headers, cseq, activeRemote, dacpId, sessionId) {
1258
- const lines = [];
1259
- lines.push(`${method} ${path} RTSP/1.0`);
1260
- lines.push(`CSeq: ${cseq}`);
1261
- lines.push(`Active-Remote: ${activeRemote}`);
1262
- lines.push(`Client-Instance: ${dacpId}`);
1263
- lines.push(`DACP-ID: ${dacpId}`);
1264
- lines.push("User-Agent: AirPlay/320.20");
1265
- lines.push("X-Apple-ProtocolVersion: 1");
1266
- lines.push(`X-Apple-Session-ID: ${sessionId}`);
1267
- lines.push("X-ProtocolVersion: 1");
1268
- for (const [name, value] of Object.entries(headers)) lines.push(`${name}: ${value}`);
1269
- lines.push("");
1270
- lines.push("");
1271
- return lines.join("\r\n");
1272
- }
1273
- function makeRequest(buffer) {
1274
- const headerLength = buffer.indexOf("\r\n\r\n");
1275
- const { headers, method, path } = parseRequestHeaders(buffer.subarray(0, headerLength));
1276
- let contentLength = headers["Content-Length"] ? Number(headers["Content-Length"]) : 0;
1277
- if (isNaN(contentLength)) contentLength = 0;
1278
- const requestLength = headerLength + 4 + contentLength;
1279
- if (buffer.byteLength < requestLength) return null;
1280
- return {
1281
- headers,
1282
- method,
1283
- path,
1284
- body: buffer.subarray(headerLength + 4, requestLength),
1285
- requestLength
1286
- };
1287
- }
1288
- function makeResponse(buffer) {
1289
- const headerLength = buffer.indexOf("\r\n\r\n");
1290
- const { headers, status, statusText } = parseResponseHeaders(buffer.subarray(0, headerLength));
1291
- let contentLength = headers["Content-Length"] ? Number(headers["Content-Length"]) : 0;
1292
- if (isNaN(contentLength)) contentLength = 0;
1293
- const responseLength = headerLength + 4 + contentLength;
1294
- if (buffer.byteLength < responseLength) return null;
1295
- const body = buffer.subarray(headerLength + 4, responseLength);
1296
- return {
1297
- response: new Response(body, {
1298
- status,
1299
- statusText,
1300
- headers
1301
- }),
1302
- responseLength
1303
- };
1304
- }
1305
- function parseHeaders(lines) {
1306
- const headers = {};
1307
- for (let i = 0; i < lines.length; i++) {
1308
- const colon = lines[i].indexOf(":");
1309
- if (colon <= 0) continue;
1310
- const name = lines[i].substring(0, colon).trim();
1311
- headers[name] = lines[i].substring(colon + 1).trim();
1312
- }
1313
- return headers;
1314
- }
1315
- function parseRequestHeaders(buffer) {
1316
- const lines = buffer.toString("utf8").split("\r\n");
1317
- const rawRequest = lines[0].match(/^(\S+)\s+(\S+)\s+RTSP\/1\.0$/);
1318
- const method = rawRequest[1];
1319
- const path = rawRequest[2];
1320
- return {
1321
- headers: parseHeaders(lines.slice(1)),
1322
- method,
1323
- path
1324
- };
1325
- }
1326
- function parseResponseHeaders(buffer) {
1327
- const lines = buffer.toString("utf8").split("\r\n");
1328
- const rawStatus = lines[0].match(/(HTTP|RTSP)\/[\d.]+\s+(\d+)\s+(.+)/);
1329
- const status = Number(rawStatus[2]);
1330
- const statusText = rawStatus[3];
1331
- return {
1332
- headers: parseHeaders(lines.slice(1)),
1333
- status,
1334
- statusText
1335
- };
1336
- }
1337
-
1338
1250
  //#endregion
1339
1251
  //#region src/tlv8.ts
1340
1252
  var tlv8_exports = /* @__PURE__ */ __exportAll({
@@ -1458,4 +1370,4 @@ function decode(buf) {
1458
1370
  }
1459
1371
 
1460
1372
  //#endregion
1461
- export { daap_exports as DAAP, ntp_exports as NTP, opack_exports as OPack, plist_exports as Plist, rtsp_exports as RTSP, tlv8_exports as TLV8 };
1373
+ export { daap_exports as DAAP, ntp_exports as NTP, opack_exports as OPack, plist_exports as Plist, tlv8_exports as TLV8 };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@basmilius/apple-encoding",
3
3
  "description": "Common encoding utilities for Apple Protocols.",
4
- "version": "0.9.16",
4
+ "version": "0.9.18",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": {