@corewire/core 0.0.0 → 1.0.0-next.2
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/README.md +28 -1
- package/dist/chunk-wE0WeVzl.mjs +22 -0
- package/dist/crypto-CXSIS6si.mjs +3093 -0
- package/dist/crypto.d.mts +111 -0
- package/dist/crypto.mjs +3 -0
- package/dist/discovery.d.mts +110 -0
- package/dist/discovery.mjs +763 -0
- package/dist/encoding-BaLbwFQ0.mjs +1663 -0
- package/dist/encoding.d.mts +411 -0
- package/dist/encoding.mjs +3 -0
- package/dist/errors-DVv1n4fL.mjs +125 -0
- package/dist/index-BJKNwUmq.d.mts +125 -0
- package/dist/index.d.mts +82 -0
- package/dist/index.mjs +5 -0
- package/dist/pairing.d.mts +169 -0
- package/dist/pairing.mjs +2487 -0
- package/dist/reporter-DfM6vPT0.mjs +223 -0
- package/dist/reporter-Dn7n2TXN.d.mts +112 -0
- package/dist/transport-C4BMdD2J.mjs +270 -0
- package/dist/transport.d.mts +2 -0
- package/dist/transport.mjs +3 -0
- package/dist/types-qzabRJJ9.d.mts +5 -0
- package/dist/utils-DY5OKUuy.mjs +8 -0
- package/package.json +84 -18
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
declare namespace daap_d_exports {
|
|
2
|
+
export { ContentCode, ContentCodeKey, DecodedTag, PlaybackStatus, TagType, TrackMetadata, decode$4 as decode, decodeTag, decodeToObject, decodeTrackMetadata, encodeContainer, encodePlaybackStatus, encodeTag, encodeTagWithSize, encodeTrackMetadata };
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Maps four-character DAAP tag codes to their DMAP/DAAP content code names.
|
|
6
|
+
*/
|
|
7
|
+
declare const ContentCode: {
|
|
8
|
+
readonly mlit: "dmap.listingitem";
|
|
9
|
+
readonly mlcl: "dmap.listing";
|
|
10
|
+
readonly msrv: "dmap.serverinforesponse";
|
|
11
|
+
readonly mcon: "dmap.container";
|
|
12
|
+
readonly miid: "dmap.itemid";
|
|
13
|
+
readonly minm: "dmap.itemname";
|
|
14
|
+
readonly mikd: "dmap.itemkind";
|
|
15
|
+
readonly mper: "dmap.persistentid";
|
|
16
|
+
readonly asal: "daap.songalbum";
|
|
17
|
+
readonly asar: "daap.songartist";
|
|
18
|
+
readonly asaa: "daap.songalbumartist";
|
|
19
|
+
readonly ascp: "daap.songcomposer";
|
|
20
|
+
readonly asgn: "daap.songgenre";
|
|
21
|
+
readonly astm: "daap.songtime";
|
|
22
|
+
readonly astn: "daap.songtracknumber";
|
|
23
|
+
readonly asdc: "daap.songdisccount";
|
|
24
|
+
readonly asdn: "daap.songdiscnumber";
|
|
25
|
+
readonly astc: "daap.songtrackcount";
|
|
26
|
+
readonly asyr: "daap.songyear";
|
|
27
|
+
readonly asbr: "daap.songbitrate";
|
|
28
|
+
readonly assr: "daap.songsamplerate";
|
|
29
|
+
readonly assz: "daap.songsize";
|
|
30
|
+
readonly caps: "daap.songplaystatus";
|
|
31
|
+
readonly cash: "daap.songshufflestate";
|
|
32
|
+
readonly carp: "daap.songrepeatstate";
|
|
33
|
+
readonly cavs: "daap.songvisiblestate";
|
|
34
|
+
readonly aePP: "com.apple.itunes.photo-properties";
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Maps four-character DAAP tag codes to the type the decoder reads their value as.
|
|
38
|
+
*
|
|
39
|
+
* Type values: 1=byte, 2=unsigned byte, 3=short, 4=unsigned short,
|
|
40
|
+
* 5=int, 6=unsigned int, 7=long, 8=unsigned long,
|
|
41
|
+
* 9=string, 10=date, 11=version, 12=container.
|
|
42
|
+
*/
|
|
43
|
+
declare const TagType: {
|
|
44
|
+
readonly mlit: 12;
|
|
45
|
+
readonly mlcl: 12;
|
|
46
|
+
readonly mcon: 12;
|
|
47
|
+
readonly msrv: 12;
|
|
48
|
+
readonly miid: 5;
|
|
49
|
+
readonly minm: 9;
|
|
50
|
+
readonly mikd: 1;
|
|
51
|
+
readonly mper: 7;
|
|
52
|
+
readonly asal: 9;
|
|
53
|
+
readonly asar: 9;
|
|
54
|
+
readonly asaa: 9;
|
|
55
|
+
readonly ascp: 9;
|
|
56
|
+
readonly asgn: 9;
|
|
57
|
+
readonly astm: 5;
|
|
58
|
+
readonly astn: 3;
|
|
59
|
+
readonly asdc: 3;
|
|
60
|
+
readonly asdn: 3;
|
|
61
|
+
readonly astc: 3;
|
|
62
|
+
readonly asyr: 3;
|
|
63
|
+
readonly asbr: 3;
|
|
64
|
+
readonly assr: 5;
|
|
65
|
+
readonly assz: 5;
|
|
66
|
+
readonly caps: 1;
|
|
67
|
+
readonly cash: 1;
|
|
68
|
+
readonly carp: 1;
|
|
69
|
+
readonly cavs: 1;
|
|
70
|
+
readonly aePP: 9;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Encodes a single DAAP tag. A number takes the smallest big-endian size that fits.
|
|
74
|
+
*
|
|
75
|
+
* @param tag - Four-character ASCII tag code, such as `minm`.
|
|
76
|
+
* @param value - A string is written as UTF-8, a bigint as 8 bytes and a Buffer as is.
|
|
77
|
+
* @throws Error if the tag is not exactly 4 characters.
|
|
78
|
+
*/
|
|
79
|
+
declare function encodeTag(tag: string, value: Buffer | string | number | bigint): Buffer;
|
|
80
|
+
/**
|
|
81
|
+
* Encodes a DAAP container tag around tags that are already encoded.
|
|
82
|
+
*
|
|
83
|
+
* @param tag - Four-character ASCII container tag code, such as `mlit`.
|
|
84
|
+
* @throws Error if the tag is not exactly 4 characters.
|
|
85
|
+
*/
|
|
86
|
+
declare function encodeContainer(tag: string, content: Buffer): Buffer;
|
|
87
|
+
/**
|
|
88
|
+
* Encodes the playback status into DAAP tags, one tag per defined field.
|
|
89
|
+
*/
|
|
90
|
+
declare function encodePlaybackStatus(status: PlaybackStatus): Buffer;
|
|
91
|
+
/**
|
|
92
|
+
* Encodes a numeric DAAP tag with a fixed value size, for tags whose size the protocol fixes.
|
|
93
|
+
*
|
|
94
|
+
* @param tag - Four-character ASCII tag code.
|
|
95
|
+
* @param byteSize - Size of the big-endian value in bytes.
|
|
96
|
+
* @throws Error if the tag is not exactly 4 characters.
|
|
97
|
+
*/
|
|
98
|
+
declare function encodeTagWithSize(tag: string, value: number, byteSize: 1 | 2 | 4 | 8): Buffer;
|
|
99
|
+
/**
|
|
100
|
+
* Encodes track metadata into a DAAP listing item (`mlit`), one tag per defined field.
|
|
101
|
+
* The duration goes from seconds to the milliseconds of `astm`.
|
|
102
|
+
*/
|
|
103
|
+
declare function encodeTrackMetadata(metadata: TrackMetadata): Buffer;
|
|
104
|
+
/**
|
|
105
|
+
* Decodes the DAAP tags in a buffer, up to its end or the first incomplete tag.
|
|
106
|
+
*/
|
|
107
|
+
declare function decode$4(buffer: Buffer): DecodedTag[];
|
|
108
|
+
/**
|
|
109
|
+
* Decodes the DAAP tag at the start of a buffer.
|
|
110
|
+
*
|
|
111
|
+
* @returns The tag and the rest of the buffer, or null when the buffer holds no complete tag.
|
|
112
|
+
*/
|
|
113
|
+
declare function decodeTag(buffer: Buffer): [DecodedTag, Buffer] | null;
|
|
114
|
+
/**
|
|
115
|
+
* Decodes a DAAP buffer into an object keyed by tag code, with values read as {@link TagType} says.
|
|
116
|
+
* Containers decode recursively; a tag of unknown type keeps its raw buffer.
|
|
117
|
+
*/
|
|
118
|
+
declare function decodeToObject(buffer: Buffer): Record<string, unknown>;
|
|
119
|
+
/**
|
|
120
|
+
* Decodes track metadata from a bare tag list or an `mlit` container.
|
|
121
|
+
* The duration goes from the milliseconds of `astm` back to seconds.
|
|
122
|
+
*/
|
|
123
|
+
declare function decodeTrackMetadata(buffer: Buffer): TrackMetadata;
|
|
124
|
+
/** A four-character DAAP content code from {@link ContentCode}. */
|
|
125
|
+
type ContentCodeKey = keyof typeof ContentCode;
|
|
126
|
+
/** A decoded DAAP tag with its raw value bytes. */
|
|
127
|
+
type DecodedTag = {
|
|
128
|
+
readonly tag: string; /** The length of the value in bytes. */
|
|
129
|
+
readonly length: number;
|
|
130
|
+
readonly value: Buffer;
|
|
131
|
+
};
|
|
132
|
+
/** The playback state that DAAP sends as `caps`, `cash` and `carp`. */
|
|
133
|
+
type PlaybackStatus = {
|
|
134
|
+
readonly playing?: boolean;
|
|
135
|
+
readonly shuffle?: boolean;
|
|
136
|
+
readonly repeat?: "off" | "one" | "all";
|
|
137
|
+
};
|
|
138
|
+
/** The metadata of a track, with the DAAP tag that carries each field. */
|
|
139
|
+
type TrackMetadata = {
|
|
140
|
+
/** The title, sent as `minm`. */readonly title?: string; /** The artist, sent as `asar`. */
|
|
141
|
+
readonly artist?: string; /** The album artist, sent as `asaa`. */
|
|
142
|
+
readonly albumArtist?: string; /** The album name, sent as `asal`. */
|
|
143
|
+
readonly album?: string; /** The composer, sent as `ascp`. */
|
|
144
|
+
readonly composer?: string; /** The genre, sent as `asgn`. */
|
|
145
|
+
readonly genre?: string; /** The duration in seconds, sent as milliseconds in `astm`. */
|
|
146
|
+
readonly duration?: number; /** The track number on the album, sent as `astn`. */
|
|
147
|
+
readonly trackNumber?: number; /** The number of tracks on the album, sent as `astc`. */
|
|
148
|
+
readonly trackCount?: number; /** The disc number in the set, sent as `asdn`. */
|
|
149
|
+
readonly discNumber?: number; /** The number of discs in the set, sent as `asdc`. */
|
|
150
|
+
readonly discCount?: number; /** The release year, sent as `asyr`. */
|
|
151
|
+
readonly year?: number; /** The bitrate in kbps, sent as `asbr`. */
|
|
152
|
+
readonly bitrate?: number; /** The sample rate in Hz, sent as `assr`. */
|
|
153
|
+
readonly sampleRate?: number; /** The file size in bytes, sent as `assz`. */
|
|
154
|
+
readonly size?: number;
|
|
155
|
+
};
|
|
156
|
+
declare namespace nskeyedarchiver_d_exports {
|
|
157
|
+
export { decode$3 as decode, decodeAsArray };
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Decodes an NSKeyedArchiver plist into plain objects. It resolves `CF$UID` references, turns
|
|
161
|
+
* NSArray and NSDictionary into arrays and objects, and drops the class metadata.
|
|
162
|
+
*
|
|
163
|
+
* @param archive - The parsed plist, with `$objects` and `$top`.
|
|
164
|
+
* @returns The root object, or null when the archive lacks `$objects` or `$top`.
|
|
165
|
+
*/
|
|
166
|
+
declare function decode$3(archive: any): unknown;
|
|
167
|
+
/** Like {@link decode}, but wraps a root that is not an array in a single-element array. */
|
|
168
|
+
declare function decodeAsArray(archive: any): unknown[];
|
|
169
|
+
declare namespace ntp_d_exports {
|
|
170
|
+
export { PacketFields, decode$2 as decode, encode$2 as encode, now, parts };
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Returns the wall-clock time as a 64-bit NTP timestamp: whole seconds since 1900 in the upper
|
|
174
|
+
* 32 bits, the fraction in the lower 32 bits.
|
|
175
|
+
*
|
|
176
|
+
* It reads `Date.now()` instead of a monotonic clock, because Apple devices expect NTP
|
|
177
|
+
* timestamps anchored to real time.
|
|
178
|
+
*/
|
|
179
|
+
declare function now(): bigint;
|
|
180
|
+
/** Splits a 64-bit NTP timestamp into `[seconds, fraction]`, both 32-bit unsigned integers. */
|
|
181
|
+
declare function parts(ntp: bigint): [number, number];
|
|
182
|
+
/**
|
|
183
|
+
* Decodes an NTP timing packet. The send timestamp (bytes 24 to 31) reads as 0 when the packet
|
|
184
|
+
* stops before it.
|
|
185
|
+
*
|
|
186
|
+
* @throws {RangeError} When the packet is shorter than 24 bytes.
|
|
187
|
+
*/
|
|
188
|
+
declare function decode$2(buffer: Buffer): PacketFields;
|
|
189
|
+
/** Encodes a 32-byte NTP timing packet. */
|
|
190
|
+
declare function encode$2(fields: PacketFields): Buffer;
|
|
191
|
+
/**
|
|
192
|
+
* The fields of an AirPlay NTP timing packet. Each timestamp is split into whole seconds since
|
|
193
|
+
* 1900 (`_sec`) and a 32-bit fraction (`_frac`).
|
|
194
|
+
*/
|
|
195
|
+
type PacketFields = {
|
|
196
|
+
readonly proto: number;
|
|
197
|
+
readonly type: number;
|
|
198
|
+
readonly seqno: number;
|
|
199
|
+
readonly padding: number;
|
|
200
|
+
readonly reftime_sec: number;
|
|
201
|
+
readonly reftime_frac: number;
|
|
202
|
+
readonly recvtime_sec: number;
|
|
203
|
+
readonly recvtime_frac: number;
|
|
204
|
+
readonly sendtime_sec: number;
|
|
205
|
+
readonly sendtime_frac: number;
|
|
206
|
+
};
|
|
207
|
+
declare namespace opack_d_exports {
|
|
208
|
+
export { decode$1 as decode, encode$1 as encode, float, int, sizedInteger };
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* A number that OPack encodes as FLOAT64. A plain number with an integer value
|
|
212
|
+
* would encode as an OPack integer.
|
|
213
|
+
*/
|
|
214
|
+
declare class Float {
|
|
215
|
+
#private;
|
|
216
|
+
get value(): number;
|
|
217
|
+
constructor(value: number);
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* A number that OPack encodes as an integer in the smallest width that holds it.
|
|
221
|
+
*/
|
|
222
|
+
declare class Integer {
|
|
223
|
+
#private;
|
|
224
|
+
get value(): number | bigint;
|
|
225
|
+
constructor(value: number | bigint);
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* A signed integer with a fixed width on the wire. The decoder returns one for every sized
|
|
229
|
+
* integer, so encoding it again writes the same width.
|
|
230
|
+
*/
|
|
231
|
+
declare class SizedInteger {
|
|
232
|
+
#private;
|
|
233
|
+
/** The width of the integer on the wire in bytes: 1, 2, 4, 8 or 16. */
|
|
234
|
+
get size(): number;
|
|
235
|
+
/** The value; a bigint when it lies outside the safe integer range of a number. */
|
|
236
|
+
get value(): number | bigint;
|
|
237
|
+
constructor(value: number | bigint, size: number);
|
|
238
|
+
/**
|
|
239
|
+
* Returns the value, so the integer works in arithmetic and comparisons.
|
|
240
|
+
*/
|
|
241
|
+
valueOf(): number | bigint;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Wraps a number so OPack encodes it as FLOAT64, also when it is a whole number.
|
|
245
|
+
*/
|
|
246
|
+
declare function float(value: number): Float;
|
|
247
|
+
/**
|
|
248
|
+
* Wraps an integer so OPack encodes it as an integer in the smallest width that holds it.
|
|
249
|
+
*
|
|
250
|
+
* @throws RangeError if the value is not an integer.
|
|
251
|
+
*/
|
|
252
|
+
declare function int(value: number | bigint): Integer;
|
|
253
|
+
/**
|
|
254
|
+
* Wraps an integer so OPack encodes it with a fixed width.
|
|
255
|
+
*
|
|
256
|
+
* @param size - The width in bytes: 1, 2, 4, 8 or 16. The value must fit as a signed integer.
|
|
257
|
+
* @throws RangeError if the width is not one of these or the value does not fit in it.
|
|
258
|
+
*/
|
|
259
|
+
declare function sizedInteger(value: number | bigint, size: number): SizedInteger;
|
|
260
|
+
/**
|
|
261
|
+
* Decodes OPack bytes into a value. Inline integers come back as numbers, sized integers as
|
|
262
|
+
* {@link sizedInteger} values, dates as `Date`, UUIDs and byte strings as `Uint8Array`.
|
|
263
|
+
*
|
|
264
|
+
* @throws TypeError if the buffer ends early, nests deeper than 32 containers, refers to a
|
|
265
|
+
* value that does not exist or holds a tag OPack does not define.
|
|
266
|
+
*/
|
|
267
|
+
declare function decode$1(data: Uint8Array): any;
|
|
268
|
+
/**
|
|
269
|
+
* Encodes a value as OPack. It takes null, booleans, numbers, bigints, strings, bytes, dates,
|
|
270
|
+
* arrays, plain objects and the wrappers {@link float}, {@link int} and {@link sizedInteger}.
|
|
271
|
+
* A repeated string, byte string of two bytes or more, number outside -1 to 39 or date becomes
|
|
272
|
+
* a reference to its first occurrence; arrays and objects are always written in full.
|
|
273
|
+
*
|
|
274
|
+
* @throws TypeError if the value has an unsupported type or nests deeper than 32 containers.
|
|
275
|
+
* @throws RangeError if an integer does not fit in 128 bits or a date is invalid.
|
|
276
|
+
*/
|
|
277
|
+
declare function encode$1(data: any): Uint8Array;
|
|
278
|
+
//#endregion
|
|
279
|
+
//#region ../../node_modules/.bun/@plist+common@1.1.0/node_modules/@plist/common/lib/cjs/types.d.ts
|
|
280
|
+
declare type Value$1 = null | string | number | bigint | boolean | ArrayBuffer | Date | Dictionary | Value$1[];
|
|
281
|
+
declare type Dictionary = {
|
|
282
|
+
[key: string]: Value$1;
|
|
283
|
+
};
|
|
284
|
+
//#endregion
|
|
285
|
+
//#region ../../node_modules/.bun/@plist+binary.serialize@1.1.0/node_modules/@plist/binary.serialize/lib/cjs/index.d.ts
|
|
286
|
+
declare const serialize: (value: Value$1) => ArrayBufferLike;
|
|
287
|
+
declare namespace plist_d_exports {
|
|
288
|
+
export { PlistDictionary, PlistValue, parse, serialize };
|
|
289
|
+
}
|
|
290
|
+
type PlistValue = null | string | number | bigint | boolean | ArrayBuffer | Date | PlistDictionary | PlistValue[];
|
|
291
|
+
type PlistDictionary = {
|
|
292
|
+
[key: string]: PlistValue;
|
|
293
|
+
};
|
|
294
|
+
/**
|
|
295
|
+
* Parses a binary plist.
|
|
296
|
+
*
|
|
297
|
+
* Integers of 1, 2 and 4 bytes are unsigned; only 8-byte integers carry a sign. A signed
|
|
298
|
+
* read turns 200 into -56 and 44100 into -21436. An 8-byte integer comes back as a `bigint`.
|
|
299
|
+
*
|
|
300
|
+
* @throws Error when the buffer is not a well-formed binary plist.
|
|
301
|
+
*/
|
|
302
|
+
declare function parse(buffer: ArrayBuffer): PlistValue;
|
|
303
|
+
declare namespace tlv8_d_exports {
|
|
304
|
+
export { ErrorCode, Flags, Method, State, Value, bail, decode, decodeEntries, encode };
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* TLV8 pairing flags used during HAP pair-setup and pair-verify.
|
|
308
|
+
* Sent as part of the TLV8 Flags (0x13) value.
|
|
309
|
+
*/
|
|
310
|
+
declare const Flags: {
|
|
311
|
+
readonly TransientPairing: 0x10;
|
|
312
|
+
};
|
|
313
|
+
/**
|
|
314
|
+
* TLV8 error codes returned by the accessory during pairing.
|
|
315
|
+
* Included in the Error (0x07) TLV value.
|
|
316
|
+
*/
|
|
317
|
+
declare const ErrorCode: {
|
|
318
|
+
readonly Unknown: 0x01;
|
|
319
|
+
readonly Authentication: 0x02;
|
|
320
|
+
readonly BackOff: 0x03;
|
|
321
|
+
readonly MaxPeers: 0x04;
|
|
322
|
+
readonly MaxTries: 0x05;
|
|
323
|
+
readonly Unavailable: 0x06;
|
|
324
|
+
readonly Busy: 0x07;
|
|
325
|
+
};
|
|
326
|
+
/**
|
|
327
|
+
* HAP pairing method identifiers. Sent in the Method (0x00) TLV value
|
|
328
|
+
* to indicate which pairing operation is being performed.
|
|
329
|
+
*/
|
|
330
|
+
declare const Method: {
|
|
331
|
+
readonly PairSetup: 0x00;
|
|
332
|
+
readonly PairSetupWithAuth: 0x01;
|
|
333
|
+
readonly PairVerify: 0x02;
|
|
334
|
+
readonly AddPairing: 0x03;
|
|
335
|
+
readonly RemovePairing: 0x04;
|
|
336
|
+
readonly ListPairing: 0x05;
|
|
337
|
+
};
|
|
338
|
+
/**
|
|
339
|
+
* HAP pairing state machine steps (M1 through M6).
|
|
340
|
+
* Each state corresponds to a message in the SRP pair-setup or pair-verify flow.
|
|
341
|
+
*/
|
|
342
|
+
declare const State: {
|
|
343
|
+
readonly M1: 0x01;
|
|
344
|
+
readonly M2: 0x02;
|
|
345
|
+
readonly M3: 0x03;
|
|
346
|
+
readonly M4: 0x04;
|
|
347
|
+
readonly M5: 0x05;
|
|
348
|
+
readonly M6: 0x06;
|
|
349
|
+
};
|
|
350
|
+
/**
|
|
351
|
+
* TLV8 type identifiers for the fields exchanged during HAP pairing.
|
|
352
|
+
* Each value is the type byte that precedes the length and data in a TLV8 entry.
|
|
353
|
+
*/
|
|
354
|
+
declare const Value: {
|
|
355
|
+
readonly Method: 0x00;
|
|
356
|
+
readonly Identifier: 0x01;
|
|
357
|
+
readonly Salt: 0x02;
|
|
358
|
+
readonly PublicKey: 0x03;
|
|
359
|
+
readonly Proof: 0x04;
|
|
360
|
+
readonly EncryptedData: 0x05;
|
|
361
|
+
readonly State: 0x06;
|
|
362
|
+
readonly Error: 0x07;
|
|
363
|
+
readonly BackOff: 0x08;
|
|
364
|
+
readonly Certificate: 0x09;
|
|
365
|
+
readonly Signature: 0x0A;
|
|
366
|
+
readonly Permissions: 0x0B;
|
|
367
|
+
readonly FragmentData: 0x0C;
|
|
368
|
+
readonly FragmentLast: 0x0D;
|
|
369
|
+
readonly Name: 0x11;
|
|
370
|
+
readonly Flags: 0x13;
|
|
371
|
+
};
|
|
372
|
+
/** Throws the {@link TLV8PairingError} for the error or back-off in a decoded pairing response. */
|
|
373
|
+
declare function bail(data: Map<number, Buffer>): never;
|
|
374
|
+
/**
|
|
375
|
+
* Encodes `[type, value]` entries; a number value is a single byte. A value longer than 255 bytes
|
|
376
|
+
* becomes consecutive fragments of the same type, as TLV8 requires.
|
|
377
|
+
*/
|
|
378
|
+
declare function encode(entries: [number, number | Buffer | Uint8Array][]): Buffer;
|
|
379
|
+
/**
|
|
380
|
+
* Decodes a TLV8 buffer into a map from type to value, for messages that hold each type once,
|
|
381
|
+
* such as pairing messages. Adjacent entries of the same type are concatenated, which reassembles
|
|
382
|
+
* fragmented values. When a type appears again after another type, the first value wins.
|
|
383
|
+
*
|
|
384
|
+
* @throws {RangeError} When an entry is truncated.
|
|
385
|
+
*/
|
|
386
|
+
declare function decode(buf: Buffer): Map<number, Buffer>;
|
|
387
|
+
/**
|
|
388
|
+
* Decodes a TLV8 buffer into its `[type, value]` entries in order, for lists in which a type
|
|
389
|
+
* repeats. Adjacent entries of the same type are concatenated into one value, which reassembles
|
|
390
|
+
* fragmented values; a separator entry between two items keeps them apart.
|
|
391
|
+
*
|
|
392
|
+
* @throws {RangeError} When an entry is truncated.
|
|
393
|
+
*/
|
|
394
|
+
declare function decodeEntries(buf: Buffer): [number, Buffer][];
|
|
395
|
+
declare namespace rti_d_exports {
|
|
396
|
+
export { TextInputSession, decodeSession, encodeOperation };
|
|
397
|
+
}
|
|
398
|
+
type TextInputSession = {
|
|
399
|
+
readonly uuid: Uint8Array;
|
|
400
|
+
readonly documentText: string;
|
|
401
|
+
readonly isSecure: boolean;
|
|
402
|
+
readonly keyboardType: number;
|
|
403
|
+
readonly autocorrection: boolean;
|
|
404
|
+
readonly autocapitalization: boolean;
|
|
405
|
+
};
|
|
406
|
+
/** Reads RTIKeyedArchiver roots without exposing bytes outside the supplied view. */
|
|
407
|
+
declare function decodeSession(data: Uint8Array | ArrayBuffer): TextInputSession;
|
|
408
|
+
/** Encodes an RTITextOperations archive that inserts `text`, or clears the field when `clear` is set. */
|
|
409
|
+
declare function encodeOperation(sessionUUID: Uint8Array, text: string, clear: boolean): ArrayBuffer;
|
|
410
|
+
//#endregion
|
|
411
|
+
export { daap_d_exports as DAAP, nskeyedarchiver_d_exports as NSKeyedArchiver, ntp_d_exports as NTP, opack_d_exports as OPack, plist_d_exports as Plist, rti_d_exports as RTI, tlv8_d_exports as TLV8 };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { f as opack_exports, h as daap_exports, l as tlv8_exports, m as nskeyedarchiver_exports, p as ntp_exports, t as rti_exports, u as plist_exports } from "./encoding-BaLbwFQ0.mjs";
|
|
2
|
+
|
|
3
|
+
export { daap_exports as DAAP, nskeyedarchiver_exports as NSKeyedArchiver, ntp_exports as NTP, opack_exports as OPack, plist_exports as Plist, rti_exports as RTI, tlv8_exports as TLV8 };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
//#region src/errors.ts
|
|
2
|
+
/** Base class of the CoreWire errors, so one `instanceof` check catches all of them. */
|
|
3
|
+
var AppleProtocolError = class extends Error {
|
|
4
|
+
constructor(message) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.name = "AppleProtocolError";
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
/** Thrown when a TCP connection fails to open or breaks. */
|
|
10
|
+
var ConnectionError = class extends AppleProtocolError {
|
|
11
|
+
constructor(message) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.name = "ConnectionError";
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
/** Thrown when a TCP connection attempt exceeds the configured socket timeout. */
|
|
17
|
+
var ConnectionTimeoutError = class extends ConnectionError {
|
|
18
|
+
constructor(message = "Connection timed out.") {
|
|
19
|
+
super(message);
|
|
20
|
+
this.name = "ConnectionTimeoutError";
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
/** Thrown when a connection or session closes before an operation finishes, or when an operation runs on a closed one. */
|
|
24
|
+
var ConnectionClosedError = class extends ConnectionError {
|
|
25
|
+
constructor(message = "Connection closed unexpectedly.") {
|
|
26
|
+
super(message);
|
|
27
|
+
this.name = "ConnectionClosedError";
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
/** Thrown when a HAP pair-setup or pair-verify fails. */
|
|
31
|
+
var PairingError = class extends AppleProtocolError {
|
|
32
|
+
constructor(message) {
|
|
33
|
+
super(message);
|
|
34
|
+
this.name = "PairingError";
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Thrown when the accessory's identity verification fails, such as an invalid
|
|
39
|
+
* Ed25519 signature or mismatched accessory identifier during pair-verify.
|
|
40
|
+
*/
|
|
41
|
+
var AuthenticationError = class extends PairingError {
|
|
42
|
+
constructor(message) {
|
|
43
|
+
super(message);
|
|
44
|
+
this.name = "AuthenticationError";
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Thrown when stored credentials are invalid, missing, or incompatible
|
|
49
|
+
* with the accessory (e.g. after a factory reset).
|
|
50
|
+
*/
|
|
51
|
+
var CredentialsError = class extends PairingError {
|
|
52
|
+
constructor(message) {
|
|
53
|
+
super(message);
|
|
54
|
+
this.name = "CredentialsError";
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
/** Thrown when a protocol command fails to execute on the target device. */
|
|
58
|
+
var CommandError = class extends AppleProtocolError {
|
|
59
|
+
constructor(message) {
|
|
60
|
+
super(message);
|
|
61
|
+
this.name = "CommandError";
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
/** Thrown when a protocol setup step fails (e.g. an RTSP SETUP). */
|
|
65
|
+
var SetupError = class extends AppleProtocolError {
|
|
66
|
+
constructor(message) {
|
|
67
|
+
super(message);
|
|
68
|
+
this.name = "SetupError";
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
/** Thrown when mDNS device discovery fails or a device cannot be found after retries. */
|
|
72
|
+
var DiscoveryError = class extends AppleProtocolError {
|
|
73
|
+
constructor(message) {
|
|
74
|
+
super(message);
|
|
75
|
+
this.name = "DiscoveryError";
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
/** Thrown when encrypting or decrypting a message fails. */
|
|
79
|
+
var EncryptionError = class extends AppleProtocolError {
|
|
80
|
+
constructor(message) {
|
|
81
|
+
super(message);
|
|
82
|
+
this.name = "EncryptionError";
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
/** Thrown when a response from the accessory is malformed or has an unexpected format. */
|
|
86
|
+
var InvalidResponseError = class extends AppleProtocolError {
|
|
87
|
+
constructor(message) {
|
|
88
|
+
super(message);
|
|
89
|
+
this.name = "InvalidResponseError";
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
/** Thrown when a protocol operation exceeds its expected time limit. */
|
|
93
|
+
var TimeoutError = class extends AppleProtocolError {
|
|
94
|
+
constructor(message) {
|
|
95
|
+
super(message);
|
|
96
|
+
this.name = "TimeoutError";
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
/** Thrown when a media playback operation fails on the target device. */
|
|
100
|
+
var PlaybackError = class extends AppleProtocolError {
|
|
101
|
+
constructor(message) {
|
|
102
|
+
super(message);
|
|
103
|
+
this.name = "PlaybackError";
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
/** Thrown when the authentication tag of a ChaCha20-Poly1305 message does not match, because the ciphertext changed or the key or nonce is wrong. */
|
|
107
|
+
var DecryptionError = class extends EncryptionError {
|
|
108
|
+
constructor(message = "Decryption failed: authentication tag mismatch") {
|
|
109
|
+
super(message);
|
|
110
|
+
this.name = "DecryptionError";
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
/** Thrown when the accessory answers a pairing message with a TLV8 error or back-off. */
|
|
114
|
+
var TLV8PairingError = class extends PairingError {
|
|
115
|
+
/** The TLV8 error code of the accessory; undefined when it sent none. */
|
|
116
|
+
code;
|
|
117
|
+
constructor(message, code) {
|
|
118
|
+
super(message);
|
|
119
|
+
this.name = "TLV8PairingError";
|
|
120
|
+
this.code = code;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
//#endregion
|
|
125
|
+
export { ConnectionError as a, DecryptionError as c, InvalidResponseError as d, PairingError as f, TimeoutError as g, TLV8PairingError as h, ConnectionClosedError as i, DiscoveryError as l, SetupError as m, AuthenticationError as n, ConnectionTimeoutError as o, PlaybackError as p, CommandError as r, CredentialsError as s, AppleProtocolError as t, EncryptionError as u };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { n as LogSink, r as Logger } from "./reporter-Dn7n2TXN.mjs";
|
|
2
|
+
import { t as EventMap } from "./types-qzabRJJ9.mjs";
|
|
3
|
+
import { EventEmitter } from "node:events";
|
|
4
|
+
|
|
5
|
+
//#region src/transport/context.d.ts
|
|
6
|
+
/** The name every protocol presents for this client when the identity has none. */
|
|
7
|
+
declare const DEFAULT_CLIENT_NAME = "CoreWire";
|
|
8
|
+
/**
|
|
9
|
+
* Overrides of the identity this client presents to Apple devices during pairing and protocol
|
|
10
|
+
* negotiation. Each protocol fills what is missing with its own defaults.
|
|
11
|
+
*/
|
|
12
|
+
type DeviceIdentity = {
|
|
13
|
+
/** The name the device shows for this client, such as in its list of paired devices; {@link DEFAULT_CLIENT_NAME} when omitted. */readonly name?: string;
|
|
14
|
+
readonly model?: string;
|
|
15
|
+
readonly osName?: string;
|
|
16
|
+
readonly osVersion?: string;
|
|
17
|
+
readonly osBuildVersion?: string;
|
|
18
|
+
readonly sourceVersion?: string;
|
|
19
|
+
readonly applicationBundleIdentifier?: string;
|
|
20
|
+
readonly applicationBundleVersion?: string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Travels through every protocol layer of one device connection, so all layers log under the
|
|
24
|
+
* same device id and present the same identity.
|
|
25
|
+
*/
|
|
26
|
+
declare class Context {
|
|
27
|
+
#private;
|
|
28
|
+
/** Identifies the target device, usually by its mDNS host name. */
|
|
29
|
+
get deviceId(): string;
|
|
30
|
+
/** The identity overrides this client presents; a protocol fills the rest with its defaults. */
|
|
31
|
+
get identity(): DeviceIdentity;
|
|
32
|
+
/** Prefixes its output with the device id. */
|
|
33
|
+
get logger(): Logger;
|
|
34
|
+
/**
|
|
35
|
+
* @param sink - Also receives every log record of this context.
|
|
36
|
+
*/
|
|
37
|
+
constructor(deviceId: string, identity?: DeviceIdentity, sink?: LogSink);
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/transport/types.d.ts
|
|
41
|
+
/** Lifecycle of a {@link Connection}. `failed` is where a connection ends after an error or a timeout. */
|
|
42
|
+
type ConnectionState = "closing" | "connected" | "connecting" | "disconnected" | "failed";
|
|
43
|
+
/**
|
|
44
|
+
* Why a connection ended: we closed it (`local`), the device did (`remote`), the socket did not
|
|
45
|
+
* open in time (`timeout`), or a socket or protocol error broke it (`error`).
|
|
46
|
+
*/
|
|
47
|
+
type CloseReason = "local" | "remote" | "timeout" | "error";
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/transport/connection.d.ts
|
|
50
|
+
type ConnectionEventMap = {
|
|
51
|
+
closed: [reason: CloseReason, error?: Error];
|
|
52
|
+
connect: [];
|
|
53
|
+
data: [data: Buffer];
|
|
54
|
+
error: [error: Error];
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* One TCP socket to a device, with keep-alive and no-delay. Subclasses extend the event map with
|
|
58
|
+
* protocol events.
|
|
59
|
+
*
|
|
60
|
+
* A connection connects once and ends once. Every way it ends, `disconnect()` and `destroy()`
|
|
61
|
+
* included, emits `closed` with the reason and aborts {@link signal}. Reconnecting takes a new
|
|
62
|
+
* connection, because a fresh socket carries no pairing and no encryption keys. `error` reports
|
|
63
|
+
* problems that do not end the connection by themselves, such as a write after the socket closed.
|
|
64
|
+
*/
|
|
65
|
+
declare class Connection<TEventMap extends EventMap = {}> extends EventEmitter<ConnectionEventMap & TEventMap> {
|
|
66
|
+
#private;
|
|
67
|
+
get address(): string;
|
|
68
|
+
get context(): Context;
|
|
69
|
+
get port(): number;
|
|
70
|
+
get isConnected(): boolean;
|
|
71
|
+
/** The local IP address of the socket, or `0.0.0.0` when it is not connected. */
|
|
72
|
+
get localAddress(): string;
|
|
73
|
+
get state(): ConnectionState;
|
|
74
|
+
/** Aborts with a {@link ConnectionClosedError} when the connection ends. */
|
|
75
|
+
get signal(): AbortSignal;
|
|
76
|
+
constructor(context: Context, address: string, port: number);
|
|
77
|
+
/**
|
|
78
|
+
* Opens the socket. Returns at once when already connected.
|
|
79
|
+
*
|
|
80
|
+
* @throws {ConnectionTimeoutError} If the socket does not open within the socket timeout.
|
|
81
|
+
* @throws {ConnectionError} If the socket cannot open, or the connection is busy or has ended.
|
|
82
|
+
*/
|
|
83
|
+
connect(): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Ends the connection right away without a graceful shutdown. Passing an error ends it with
|
|
86
|
+
* reason `error`, for a subclass that cannot continue after a broken frame.
|
|
87
|
+
*/
|
|
88
|
+
destroy(error?: Error): void;
|
|
89
|
+
/** Ends the socket gracefully and resolves once it is closed. */
|
|
90
|
+
disconnect(): Promise<void>;
|
|
91
|
+
/** Toggles hex and ASCII dumps of incoming data. */
|
|
92
|
+
debug(enabled: boolean): this;
|
|
93
|
+
/** Writes to the socket, or emits `error` when the socket is not writable. */
|
|
94
|
+
write(data: Buffer | Uint8Array): void;
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/transport/encryption.d.ts
|
|
98
|
+
/**
|
|
99
|
+
* Where the 64-bit little-endian message counter sits in the 12-byte ChaCha20 nonce. Companion
|
|
100
|
+
* Link puts it at offset 0, HAP and AirPlay put it at offset 4 behind four zero bytes.
|
|
101
|
+
*/
|
|
102
|
+
type NonceFormat = "counter-at-0" | "counter-at-4";
|
|
103
|
+
/** Builds the 12-byte ChaCha20-Poly1305 nonce for a message counter. */
|
|
104
|
+
declare function buildNonce(counter: number, format: NonceFormat): Buffer;
|
|
105
|
+
/**
|
|
106
|
+
* Connection that can switch to ChaCha20-Poly1305 once pairing yields keys. Subclasses frame and
|
|
107
|
+
* encrypt with the {@link EncryptionState}, because every protocol frames differently.
|
|
108
|
+
*/
|
|
109
|
+
declare class EncryptionAwareConnection<TEventMap extends EventMap> extends Connection<TEventMap> {
|
|
110
|
+
#private;
|
|
111
|
+
get isEncrypted(): boolean;
|
|
112
|
+
/** Keys and counters once {@link enableEncryption} ran; for the subclass that frames the messages. */
|
|
113
|
+
protected get encryption(): EncryptionState | undefined;
|
|
114
|
+
enableEncryption(readKey: Buffer, writeKey: Buffer): void;
|
|
115
|
+
}
|
|
116
|
+
/** Keys and per-direction message counters of one encrypted connection. */
|
|
117
|
+
declare class EncryptionState {
|
|
118
|
+
readKey: Buffer;
|
|
119
|
+
readCount: number;
|
|
120
|
+
writeKey: Buffer;
|
|
121
|
+
writeCount: number;
|
|
122
|
+
constructor(readKey: Buffer, writeKey: Buffer);
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
export { Connection as a, Context as c, buildNonce as i, DEFAULT_CLIENT_NAME as l, EncryptionState as n, CloseReason as o, NonceFormat as r, ConnectionState as s, EncryptionAwareConnection as t, DeviceIdentity as u };
|