@basmilius/apple-common 0.0.80 → 0.0.81

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.js +813 -2
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,2 +1,813 @@
1
- var k=Object.defineProperty;var R=(e,r)=>{for(var o in r)k(e,o,{get:r[o],enumerable:!0,configurable:!0,set:(t)=>r[o]=()=>t})};import{v4 as ur}from"uuid";var l={};R(l,{padNonce:()=>w,encrypt:()=>z,decrypt:()=>W,CHACHA20_NONCE_LENGTH:()=>S,CHACHA20_AUTH_TAG_LENGTH:()=>G});import{createCipher as H,createDecipher as Y}from"chacha";var G=16,S=12;function W(e,r,o,t,n){r=w(r);let i=Y(e,r);o&&i.setAAD(o),i.setAuthTag(n);let a=i._update(t);return i._final(),a}function z(e,r,o,t){r=w(r);let n=H(e,r);o&&n.setAAD(o);let i=n._update(t);n._final();let a=n.getAuthTag();return{ciphertext:i,authTag:a}}function w(e){if(e.length>=S)return e;return Buffer.concat([Buffer.alloc(S-e.length,0),e])}var m={};R(m,{generateSharedSecKey:()=>Q,generateKeyPair:()=>J});import D from"tweetnacl";function J(){let e=D.box.keyPair();return{publicKey:e.publicKey,secretKey:e.secretKey}}function Q(e,r){return D.scalarMult(e,r)}import{hkdfSync as Z}from"node:crypto";function f(e){return Buffer.from(Z(e.hash,e.key,e.salt,e.info,e.length))}import oe from"node-dns-sd";import{createInterface as j}from"node:readline";var _=j({input:process.stdin,output:process.stdout});async function ee(e){return await new Promise((r)=>_.question(`${e}: `,r))}async function I(e){return new Promise((r)=>setTimeout(r,e))}class C{#e=[];all(){this.#e=["debug","error","info","net","raw","warn"]}disable(e){if(this.#e.includes(e))this.#e.splice(this.#e.indexOf(e),1)}enable(e){if(!this.#e.includes(e))this.#e.push(e)}isEnabled(e){return this.#e.includes(e)}debug(...e){this.isEnabled("debug")&&console.debug("\x1B[36m[debug]\x1B[39m",...e)}error(...e){this.isEnabled("error")&&console.error("\x1B[31m[error]\x1B[39m",...e)}info(...e){this.isEnabled("info")&&console.info("\x1B[32m[info]\x1B[39m",...e)}net(...e){this.isEnabled("net")&&console.info("\x1B[33m[net]\x1B[39m",...e)}raw(...e){this.isEnabled("raw")&&console.log("\x1B[34m[raw]\x1B[39m",...e)}warn(...e){this.isEnabled("warn")&&console.warn("\x1B[33m[warn]\x1B[39m",...e)}}var c=new C;var K="3939",re=6000,L=1e4,v="_airplay._tcp.local",V="_companion-link._tcp.local",M="_raop._tcp.local";class d{#e;constructor(e){this.#e=e}async find(){return await oe.discover({name:this.#e})}async findUntil(e,r=10,o=1000){while(r>0){let t=await this.find(),n=t.find((i)=>i.fqdn===e);if(n)return n;if(console.log(),console.log(`Device not found, retrying in ${o}ms...`),console.log(t.map((i)=>` ● ${i.fqdn}`).join(`
2
- `)),r--,r===0)throw Error("Device not found after serveral tries, aborting.");await I(o)}}static airplay(){return new d(v)}static companionLink(){return new d(V)}static raop(){return new d(M)}}import{networkInterfaces as te}from"node:os";function x(){let e=te();for(let r of Object.keys(e)){let o=e[r];if(!o)continue;for(let t of o){if(t.internal||t.family!=="IPv4")continue;if(t.address&&t.address!=="127.0.0.1")return t.address}}return null}import{networkInterfaces as se}from"node:os";function F(){let e=se();for(let r of Object.keys(e)){let o=e[r];if(!o)continue;for(let t of o){if(t.internal||t.family!=="IPv4")continue;if(t.mac&&t.mac!=="00:00:00:00:00:00")return t.mac.toUpperCase()}}return"00:00:00:00:00:00"}import{createSocket as ne}from"node:dgram";import{NTP as B}from"@basmilius/apple-encoding";class N{get port(){return this.#t}#e;#t=0;constructor(){this.#e=ne("udp4"),this.#e.on("error",(e)=>this.#s(e)),this.#e.on("message",(e,r)=>this.#n(e,r))}async close(){this.#e.close(),this.#t=0}async listen(){return new Promise((e)=>{this.#e.once("listening",()=>this.#a()),this.#e.bind(0,e)})}async#s(e){c.error("Timing server error",e)}async#a(){let{port:e}=this.#e.address();this.#t=e}async#n(e,r){let o=B.decode(e),t=B.now(),[n,i]=B.parts(t);c.info(`Timing server ntp=${t} receivedSeconds=${n} receivedFraction=${i}`);let a=B.encode({proto:o.proto,type:211,seqno:o.seqno,padding:0,reftime_sec:o.sendtime_sec,reftime_frac:o.sendtime_frac,recvtime_sec:n,recvtime_frac:i,sendtime_sec:n,sendtime_frac:i});this.#e.send(a,r.port,r.address)}}import{EventEmitter as ie}from"node:events";import{Socket as ae}from"node:net";var h=Symbol();class A extends ie{get address(){return this.#e}get port(){return this.#t}get isConnected(){return this.#o==="connected"}get state(){return this.#o}#e;#t;#s;#a=!1;#n=0;#i=3;#u=!0;#l=3000;#f;#r;#o;#c;constructor(e,r){super();this.#e=e,this.#t=r,this.#s={onClose:this.#p.bind(this),onConnect:this.#h.bind(this),onData:this.#g.bind(this),onEnd:this.#P.bind(this),onError:this.#B.bind(this),onTimeout:this.#b.bind(this)},this.#o="disconnected"}async connect(){if(this.#o==="connected")return;if(this.#o==="connecting")throw Error("A connection is already being established.");return this.#u=!0,this.#n=0,this.#d()}async disconnect(){if(this.#f)clearTimeout(this.#f),this.#f=void 0;if(this.#u=!1,!this.#r||this.#o==="disconnected")return;return new Promise((e)=>{this.#o="closing",this.#r.once("close",()=>{this.#m(),e()}),this.#r.end()})}debug(e){return this.#a=e,this}retry(e,r=3000){return this.#i=e,this.#l=r,this}async write(e){if(!this.#r||this.#o!=="connected")throw Error("Cannot write to a disconnected connection.");return new Promise((r,o)=>{this.#r.write(e,(t)=>t?o(t):r())})}async#d(){return new Promise((e,r)=>{this.#o="connecting",this.#c={resolve:e,reject:r},this.#r=new ae,this.#r.setTimeout(L),this.#r.on("close",this.#s.onClose),this.#r.on("connect",this.#s.onConnect),this.#r.on("data",this.#s.onData),this.#r.on("end",this.#s.onEnd),this.#r.on("error",this.#s.onError),this.#r.on("timeout",this.#s.onTimeout),c.net(`Connecting to ${this.#e}:${this.#t}...`),this.#r.connect({host:this.#e,port:this.#t,keepAlive:!0})})}#m(){if(this.#r)this.#r.removeAllListeners(),this.#r.destroy(),this.#r=void 0;this.#o="disconnected",this.#c=void 0}#y(e){if(!this.#u||this.#n>=this.#i){this.#o="failed",this.#c?.reject(e),this.#c=void 0;return}this.#n++,c.net(`Retry attempt ${this.#n} / ${this.#i} in ${this.#l}ms...`);let{resolve:r,reject:o}=this.#c;this.#m(),this.#f=setTimeout(async()=>{this.#f=void 0;try{this.#c={resolve:r,reject:o},await this.#d(),r()}catch(t){}},this.#l)}#p(e){let r=this.#o==="connected";if(this.#o!=="closing")this.#o="disconnected";if(this.emit("close",e),r&&this.#u&&e)this.#y(Error("Connection closed unexpectedly."))}#h(){this.#o="connected",this.#n=0,this.#r.setKeepAlive(!0,1e4),this.#r.setTimeout(0),this.emit("connect"),this.#c?.resolve(),this.#c=void 0}#g(e){if(this.#a){let r=Math.min(e.byteLength,64);c.debug(`Received ${e.byteLength} bytes of data.`),c.debug(`hex=${e.subarray(0,r).toString("hex")}`),c.debug(`ascii=${e.toString("ascii").replace(/[^\x20-\x7E]/g,".").substring(0,r)}`)}this.emit("data",e)}#P(){this.emit("end")}#B(e){if(c.error(`Connection error: ${e.message}`),this.emit("error",e),this.#o==="connecting")this.#y(e);else this.#o="failed"}#b(){c.error("Connection timed out.");let e=Error("Connection timed out.");if(this.emit("timeout"),this.emit("error",e),this.#o==="connecting")this.#y(e);else this.#o="failed",this.#r?.destroy()}}class U extends A{get isEncrypted(){return!!this[h]}[h];async enableEncryption(e,r){this[h]=new E(e,r)}}class E{readKey;readCount;writeKey;writeCount;constructor(e,r){this.readCount=0,this.readKey=e,this.writeCount=0,this.writeKey=r}}import{OPack as ce,TLV8 as s}from"@basmilius/apple-encoding";import{SRP as q,SrpClient as fe}from"fast-srp-hap";import{v4 as ue}from"uuid";import g from"tweetnacl";class O{#e;#t;#s;#a;#n;#i;constructor(e){this.#e="basmilius/apple-protocols",this.#t=Buffer.from(ue().toUpperCase()),this.#s=e}async start(){let e=g.sign.keyPair();this.#a=Buffer.from(e.publicKey),this.#n=Buffer.from(e.secretKey)}async pin(e){let r=await this.m1(),o=await this.m2(r,await e()),t=await this.m3(o),n=await this.m4(t),i=await this.m5(n),a=await this.m6(n,i);if(!a)throw Error("Pairing failed, could not get accessory keys.");return a}async transient(){let e=await this.m1([[s.Value.Flags,s.Flags.TransientPairing]]),r=await this.m2(e),o=await this.m3(r),t=await this.m4(o),n=f({hash:"sha512",key:t.sharedSecret,length:32,salt:Buffer.from("Control-Salt"),info:Buffer.from("Control-Read-Encryption-Key")}),i=f({hash:"sha512",key:t.sharedSecret,length:32,salt:Buffer.from("Control-Salt"),info:Buffer.from("Control-Write-Encryption-Key")});return{pairingId:this.#t,sharedSecret:t.sharedSecret,accessoryToControllerKey:n,controllerToAccessoryKey:i}}async m1(e=[]){let r=await this.#s("m1",s.encode([[s.Value.Method,s.Method.PairSetup],[s.Value.State,s.State.M1],...e])),o=b(r),t=o.get(s.Value.PublicKey),n=o.get(s.Value.Salt);return{publicKey:t,salt:n}}async m2(e,r=K){let o=await q.genKey(32);this.#i=new fe(q.params.hap,e.salt,Buffer.from("Pair-Setup"),Buffer.from(r),o,!0),this.#i.setB(e.publicKey);let t=this.#i.computeA(),n=this.#i.computeM1();return{publicKey:t,proof:n}}async m3(e){let r=await this.#s("m3",s.encode([[s.Value.State,s.State.M3],[s.Value.PublicKey,e.publicKey],[s.Value.Proof,e.proof]]));return{serverProof:b(r).get(s.Value.Proof)}}async m4(e){return this.#i.checkM2(e.serverProof),{sharedSecret:this.#i.computeK()}}async m5(e){let r=f({hash:"sha512",key:e.sharedSecret,length:32,salt:Buffer.from("Pair-Setup-Controller-Sign-Salt","utf8"),info:Buffer.from("Pair-Setup-Controller-Sign-Info","utf8")}),o=f({hash:"sha512",key:e.sharedSecret,length:32,salt:Buffer.from("Pair-Setup-Encrypt-Salt","utf8"),info:Buffer.from("Pair-Setup-Encrypt-Info","utf8")}),t=Buffer.concat([r,this.#t,this.#a]),n=g.sign.detached(t,this.#n),i=s.encode([[s.Value.Identifier,this.#t],[s.Value.PublicKey,this.#a],[s.Value.Signature,Buffer.from(n)],[s.Value.Name,Buffer.from(ce.encode({name:this.#e}))]]),{authTag:a,ciphertext:y}=l.encrypt(o,Buffer.from("PS-Msg05"),null,i),u=Buffer.concat([y,a]),p=await this.#s("m5",s.encode([[s.Value.State,s.State.M5],[s.Value.EncryptedData,u]])),P=b(p).get(s.Value.EncryptedData),X=P.subarray(0,-16);return{authTag:P.subarray(-16),data:X,sessionKey:o}}async m6(e,r){let o=l.decrypt(r.sessionKey,Buffer.from("PS-Msg06"),null,r.data,r.authTag),t=s.decode(o),n=t.get(s.Value.Identifier),i=t.get(s.Value.PublicKey),a=t.get(s.Value.Signature),y=f({hash:"sha512",key:e.sharedSecret,length:32,salt:Buffer.from("Pair-Setup-Accessory-Sign-Salt"),info:Buffer.from("Pair-Setup-Accessory-Sign-Info")}),u=Buffer.concat([y,n,i]);if(!g.sign.detached.verify(u,a,i))throw Error("Invalid accessory signature.");return{accessoryIdentifier:n.toString(),accessoryLongTermPublicKey:i,pairingId:this.#t,publicKey:this.#a,secretKey:this.#n}}}class ${#e;#t;constructor(e){this.#e=m.generateKeyPair(),this.#t=e}async start(e){let r=await this.#s(),o=await this.#a(e.accessoryIdentifier,e.accessoryLongTermPublicKey,r);return await this.#n(e.pairingId,e.secretKey,o),await this.#i(o,e.pairingId)}async#s(){let e=await this.#t("m1",s.encode([[s.Value.State,s.State.M1],[s.Value.PublicKey,Buffer.from(this.#e.publicKey)]])),r=b(e),o=r.get(s.Value.PublicKey);return{encryptedData:r.get(s.Value.EncryptedData),serverPublicKey:o}}async#a(e,r,o){let t=Buffer.from(m.generateSharedSecKey(this.#e.secretKey,o.serverPublicKey)),n=f({hash:"sha512",key:t,length:32,salt:Buffer.from("Pair-Verify-Encrypt-Salt"),info:Buffer.from("Pair-Verify-Encrypt-Info")}),i=o.encryptedData.subarray(0,-16),a=o.encryptedData.subarray(-16),y=l.decrypt(n,Buffer.from("PV-Msg02"),null,i,a),u=s.decode(y),p=u.get(s.Value.Identifier),T=u.get(s.Value.Signature);if(p.toString()!==e)throw Error(`Invalid accessory identifier. Expected ${p.toString()} to be ${e}.`);let P=Buffer.concat([o.serverPublicKey,p,this.#e.publicKey]);if(!g.sign.detached.verify(P,T,r))throw Error("Invalid accessory signature.");return{serverEphemeralPublicKey:o.serverPublicKey,sessionKey:n,sharedSecret:t}}async#n(e,r,o){let t=Buffer.concat([this.#e.publicKey,e,o.serverEphemeralPublicKey]),n=Buffer.from(g.sign.detached(t,r)),i=s.encode([[s.Value.Identifier,e],[s.Value.Signature,n]]),{authTag:a,ciphertext:y}=l.encrypt(o.sessionKey,Buffer.from("PV-Msg03"),null,i),u=Buffer.concat([y,a]);return await this.#t("m3",s.encode([[s.Value.State,s.State.M3],[s.Value.EncryptedData,u]])),{}}async#i(e,r){return{accessoryToControllerKey:Buffer.alloc(0),controllerToAccessoryKey:Buffer.alloc(0),pairingId:r,sharedSecret:e.sharedSecret}}}function b(e){let r=s.decode(e);if(r.has(s.Value.Error))s.bail(r);return c.raw("Decoded TLV",r),r}function le(e){let r=Buffer.alloc(2);return r.writeUInt16BE(e,0),r}function ye(e){let[r,o]=de(e),t=Buffer.alloc(8);return t.writeUInt32LE(o,0),t.writeUInt32LE(r,4),t}function de(e){if(e<=-1||e>9007199254740991)throw Error("Number out of range.");if(Math.floor(e)!==e)throw Error("Number is not an integer.");let t=0,n=e&4294967295,i=n<0?(e&2147483647)+2147483648:n;if(e>4294967295)t=(e-i)/4294967296;return[t,i]}export{I as waitFor,ur as uuid,ye as uint53ToLE,le as uint16ToBE,c as reporter,ee as prompt,f as hkdf,F as getMacAddress,x as getLocalIP,_ as cli,N as TimingServer,M as RAOP_SERVICE,re as HTTP_TIMEOUT,E as EncryptionState,U as EncryptionAwareConnection,h as ENCRYPTION,d as Discovery,m as Curve25519,A as Connection,l as Chacha20,V as COMPANION_LINK_SERVICE,$ as AccessoryVerify,O as AccessoryPair,K as AIRPLAY_TRANSIENT_PIN,v as AIRPLAY_SERVICE};
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, {
5
+ get: all[name],
6
+ enumerable: true,
7
+ configurable: true,
8
+ set: (newValue) => all[name] = () => newValue
9
+ });
10
+ };
11
+
12
+ // src/index.ts
13
+ import {
14
+ v4
15
+ } from "uuid";
16
+
17
+ // src/crypto/chacha20.ts
18
+ var exports_chacha20 = {};
19
+ __export(exports_chacha20, {
20
+ padNonce: () => padNonce,
21
+ encrypt: () => encrypt,
22
+ decrypt: () => decrypt,
23
+ CHACHA20_NONCE_LENGTH: () => CHACHA20_NONCE_LENGTH,
24
+ CHACHA20_AUTH_TAG_LENGTH: () => CHACHA20_AUTH_TAG_LENGTH
25
+ });
26
+ import { createCipher, createDecipher } from "chacha";
27
+ var CHACHA20_AUTH_TAG_LENGTH = 16;
28
+ var CHACHA20_NONCE_LENGTH = 12;
29
+ function decrypt(key, nonce, add, ciphertext, authTag) {
30
+ nonce = padNonce(nonce);
31
+ const decipher = createDecipher(key, nonce);
32
+ add && decipher.setAAD(add);
33
+ decipher.setAuthTag(authTag);
34
+ const plaintext = decipher._update(ciphertext);
35
+ decipher._final();
36
+ return plaintext;
37
+ }
38
+ function encrypt(key, nonce, aad, plaintext) {
39
+ nonce = padNonce(nonce);
40
+ const cipher = createCipher(key, nonce);
41
+ aad && cipher.setAAD(aad);
42
+ const ciphertext = cipher._update(plaintext);
43
+ cipher._final();
44
+ const authTag = cipher.getAuthTag();
45
+ return {
46
+ ciphertext,
47
+ authTag
48
+ };
49
+ }
50
+ function padNonce(nonce) {
51
+ if (nonce.length >= CHACHA20_NONCE_LENGTH) {
52
+ return nonce;
53
+ }
54
+ return Buffer.concat([
55
+ Buffer.alloc(CHACHA20_NONCE_LENGTH - nonce.length, 0),
56
+ nonce
57
+ ]);
58
+ }
59
+ // src/crypto/curve25519.ts
60
+ var exports_curve25519 = {};
61
+ __export(exports_curve25519, {
62
+ generateSharedSecKey: () => generateSharedSecKey,
63
+ generateKeyPair: () => generateKeyPair
64
+ });
65
+ import tweetnacl from "tweetnacl";
66
+ function generateKeyPair() {
67
+ const keyPair = tweetnacl.box.keyPair();
68
+ return {
69
+ publicKey: keyPair.publicKey,
70
+ secretKey: keyPair.secretKey
71
+ };
72
+ }
73
+ function generateSharedSecKey(priKey, pubKey) {
74
+ return tweetnacl.scalarMult(priKey, pubKey);
75
+ }
76
+ // src/crypto/hkdf.ts
77
+ import { hkdfSync } from "node:crypto";
78
+ function hkdf_default(options) {
79
+ return Buffer.from(hkdfSync(options.hash, options.key, options.salt, options.info, options.length));
80
+ }
81
+ // src/discovery/discovery.ts
82
+ import mdns from "node-dns-sd";
83
+
84
+ // src/cli.ts
85
+ import { createInterface } from "node:readline";
86
+ var cli = createInterface({
87
+ input: process.stdin,
88
+ output: process.stdout
89
+ });
90
+ async function prompt(message) {
91
+ return await new Promise((resolve) => cli.question(`${message}: `, resolve));
92
+ }
93
+ async function waitFor(ms) {
94
+ return new Promise((resolve) => setTimeout(resolve, ms));
95
+ }
96
+
97
+ class Reporter {
98
+ #enabled = [];
99
+ all() {
100
+ this.#enabled = ["debug", "error", "info", "net", "raw", "warn"];
101
+ }
102
+ disable(group) {
103
+ if (this.#enabled.includes(group)) {
104
+ this.#enabled.splice(this.#enabled.indexOf(group), 1);
105
+ }
106
+ }
107
+ enable(group) {
108
+ if (!this.#enabled.includes(group)) {
109
+ this.#enabled.push(group);
110
+ }
111
+ }
112
+ isEnabled(group) {
113
+ return this.#enabled.includes(group);
114
+ }
115
+ debug(...data) {
116
+ this.isEnabled("debug") && console.debug(`\x1B[36m[debug]\x1B[39m`, ...data);
117
+ }
118
+ error(...data) {
119
+ this.isEnabled("error") && console.error(`\x1B[31m[error]\x1B[39m`, ...data);
120
+ }
121
+ info(...data) {
122
+ this.isEnabled("info") && console.info(`\x1B[32m[info]\x1B[39m`, ...data);
123
+ }
124
+ net(...data) {
125
+ this.isEnabled("net") && console.info(`\x1B[33m[net]\x1B[39m`, ...data);
126
+ }
127
+ raw(...data) {
128
+ this.isEnabled("raw") && console.log(`\x1B[34m[raw]\x1B[39m`, ...data);
129
+ }
130
+ warn(...data) {
131
+ this.isEnabled("warn") && console.warn(`\x1B[33m[warn]\x1B[39m`, ...data);
132
+ }
133
+ }
134
+ var reporter = new Reporter;
135
+
136
+ // src/const.ts
137
+ var AIRPLAY_TRANSIENT_PIN = "3939";
138
+ var HTTP_TIMEOUT = 6000;
139
+ var SOCKET_TIMEOUT = 1e4;
140
+ var AIRPLAY_SERVICE = "_airplay._tcp.local";
141
+ var COMPANION_LINK_SERVICE = "_companion-link._tcp.local";
142
+ var RAOP_SERVICE = "_raop._tcp.local";
143
+
144
+ // src/discovery/discovery.ts
145
+ class Discovery {
146
+ #service;
147
+ constructor(service) {
148
+ this.#service = service;
149
+ }
150
+ async find() {
151
+ return await mdns.discover({
152
+ name: this.#service
153
+ });
154
+ }
155
+ async findUntil(fqdn, tries = 10, timeout = 1000) {
156
+ while (tries > 0) {
157
+ const devices = await this.find();
158
+ const device = devices.find((device2) => device2.fqdn === fqdn);
159
+ if (device) {
160
+ return device;
161
+ }
162
+ console.log();
163
+ console.log(`Device not found, retrying in ${timeout}ms...`);
164
+ console.log(devices.map((d) => ` ● ${d.fqdn}`).join(`
165
+ `));
166
+ tries--;
167
+ if (tries === 0) {
168
+ throw new Error("Device not found after serveral tries, aborting.");
169
+ }
170
+ await waitFor(timeout);
171
+ }
172
+ }
173
+ static airplay() {
174
+ return new Discovery(AIRPLAY_SERVICE);
175
+ }
176
+ static companionLink() {
177
+ return new Discovery(COMPANION_LINK_SERVICE);
178
+ }
179
+ static raop() {
180
+ return new Discovery(RAOP_SERVICE);
181
+ }
182
+ }
183
+ // src/net/getLocalIP.ts
184
+ import { networkInterfaces } from "node:os";
185
+ function getLocalIP_default() {
186
+ const interfaces = networkInterfaces();
187
+ for (const name of Object.keys(interfaces)) {
188
+ const iface = interfaces[name];
189
+ if (!iface) {
190
+ continue;
191
+ }
192
+ for (const net of iface) {
193
+ if (net.internal || net.family !== "IPv4") {
194
+ continue;
195
+ }
196
+ if (net.address && net.address !== "127.0.0.1") {
197
+ return net.address;
198
+ }
199
+ }
200
+ }
201
+ return null;
202
+ }
203
+ // src/net/getMacAddress.ts
204
+ import { networkInterfaces as networkInterfaces2 } from "node:os";
205
+ function getMacAddress_default() {
206
+ const interfaces = networkInterfaces2();
207
+ for (const name of Object.keys(interfaces)) {
208
+ const iface = interfaces[name];
209
+ if (!iface) {
210
+ continue;
211
+ }
212
+ for (const net of iface) {
213
+ if (net.internal || net.family !== "IPv4") {
214
+ continue;
215
+ }
216
+ if (net.mac && net.mac !== "00:00:00:00:00:00") {
217
+ return net.mac.toUpperCase();
218
+ }
219
+ }
220
+ }
221
+ return "00:00:00:00:00:00";
222
+ }
223
+ // src/net/timing.ts
224
+ import { createSocket } from "node:dgram";
225
+ import { NTP } from "@basmilius/apple-encoding";
226
+ class timing_default {
227
+ get port() {
228
+ return this.#port;
229
+ }
230
+ #socket;
231
+ #port = 0;
232
+ constructor() {
233
+ this.#socket = createSocket("udp4");
234
+ this.#socket.on("error", (err) => this.#onError(err));
235
+ this.#socket.on("message", (data, info) => this.#onMessage(data, info));
236
+ }
237
+ async close() {
238
+ this.#socket.close();
239
+ this.#port = 0;
240
+ }
241
+ async listen() {
242
+ return new Promise((resolve) => {
243
+ this.#socket.once("listening", () => this.#onListening());
244
+ this.#socket.bind(0, resolve);
245
+ });
246
+ }
247
+ async#onError(err) {
248
+ reporter.error("Timing server error", err);
249
+ }
250
+ async#onListening() {
251
+ const { port } = this.#socket.address();
252
+ this.#port = port;
253
+ }
254
+ async#onMessage(data, info) {
255
+ const request = NTP.decode(data);
256
+ const ntp = NTP.now();
257
+ const [receivedSeconds, receivedFraction] = NTP.parts(ntp);
258
+ reporter.info(`Timing server ntp=${ntp} receivedSeconds=${receivedSeconds} receivedFraction=${receivedFraction}`);
259
+ const response = NTP.encode({
260
+ proto: request.proto,
261
+ type: 83 | 128,
262
+ seqno: request.seqno,
263
+ padding: 0,
264
+ reftime_sec: request.sendtime_sec,
265
+ reftime_frac: request.sendtime_frac,
266
+ recvtime_sec: receivedSeconds,
267
+ recvtime_frac: receivedFraction,
268
+ sendtime_sec: receivedSeconds,
269
+ sendtime_frac: receivedFraction
270
+ });
271
+ this.#socket.send(response, info.port, info.address);
272
+ }
273
+ }
274
+ // src/connection.ts
275
+ import { EventEmitter } from "node:events";
276
+ import { Socket as Socket2 } from "node:net";
277
+
278
+ // src/symbols.ts
279
+ var ENCRYPTION = Symbol();
280
+
281
+ // src/connection.ts
282
+ class Connection extends EventEmitter {
283
+ get address() {
284
+ return this.#address;
285
+ }
286
+ get port() {
287
+ return this.#port;
288
+ }
289
+ get isConnected() {
290
+ return this.#state === "connected";
291
+ }
292
+ get state() {
293
+ return this.#state;
294
+ }
295
+ #address;
296
+ #port;
297
+ #bindings;
298
+ #debug = false;
299
+ #retryAttempt = 0;
300
+ #retryAttempts = 3;
301
+ #retryEnabled = true;
302
+ #retryInterval = 3000;
303
+ #retryTimeout;
304
+ #socket;
305
+ #state;
306
+ #connectPromise;
307
+ constructor(address, port) {
308
+ super();
309
+ this.#address = address;
310
+ this.#port = port;
311
+ this.#bindings = {
312
+ onClose: this.#onClose.bind(this),
313
+ onConnect: this.#onConnect.bind(this),
314
+ onData: this.#onData.bind(this),
315
+ onEnd: this.#onEnd.bind(this),
316
+ onError: this.#onError.bind(this),
317
+ onTimeout: this.#onTimeout.bind(this)
318
+ };
319
+ this.#state = "disconnected";
320
+ }
321
+ async connect() {
322
+ if (this.#state === "connected") {
323
+ return;
324
+ }
325
+ if (this.#state === "connecting") {
326
+ throw new Error("A connection is already being established.");
327
+ }
328
+ this.#retryEnabled = true;
329
+ this.#retryAttempt = 0;
330
+ return this.#attemptConnect();
331
+ }
332
+ async disconnect() {
333
+ if (this.#retryTimeout) {
334
+ clearTimeout(this.#retryTimeout);
335
+ this.#retryTimeout = undefined;
336
+ }
337
+ this.#retryEnabled = false;
338
+ if (!this.#socket || this.#state === "disconnected") {
339
+ return;
340
+ }
341
+ return new Promise((resolve) => {
342
+ this.#state = "closing";
343
+ this.#socket.once("close", () => {
344
+ this.#cleanup();
345
+ resolve();
346
+ });
347
+ this.#socket.end();
348
+ });
349
+ }
350
+ debug(enabled) {
351
+ this.#debug = enabled;
352
+ return this;
353
+ }
354
+ retry(attempts, interval = 3000) {
355
+ this.#retryAttempts = attempts;
356
+ this.#retryInterval = interval;
357
+ return this;
358
+ }
359
+ async write(data) {
360
+ if (!this.#socket || this.#state !== "connected") {
361
+ throw new Error("Cannot write to a disconnected connection.");
362
+ }
363
+ return new Promise((resolve, reject) => {
364
+ this.#socket.write(data, (err) => err ? reject(err) : resolve());
365
+ });
366
+ }
367
+ async#attemptConnect() {
368
+ return new Promise((resolve, reject) => {
369
+ this.#state = "connecting";
370
+ this.#connectPromise = { resolve, reject };
371
+ this.#socket = new Socket2;
372
+ this.#socket.setTimeout(SOCKET_TIMEOUT);
373
+ this.#socket.on("close", this.#bindings.onClose);
374
+ this.#socket.on("connect", this.#bindings.onConnect);
375
+ this.#socket.on("data", this.#bindings.onData);
376
+ this.#socket.on("end", this.#bindings.onEnd);
377
+ this.#socket.on("error", this.#bindings.onError);
378
+ this.#socket.on("timeout", this.#bindings.onTimeout);
379
+ reporter.net(`Connecting to ${this.#address}:${this.#port}...`);
380
+ this.#socket.connect({
381
+ host: this.#address,
382
+ port: this.#port,
383
+ keepAlive: true
384
+ });
385
+ });
386
+ }
387
+ #cleanup() {
388
+ if (this.#socket) {
389
+ this.#socket.removeAllListeners();
390
+ this.#socket.destroy();
391
+ this.#socket = undefined;
392
+ }
393
+ this.#state = "disconnected";
394
+ this.#connectPromise = undefined;
395
+ }
396
+ #scheduleRetry(err) {
397
+ if (!this.#retryEnabled || this.#retryAttempt >= this.#retryAttempts) {
398
+ this.#state = "failed";
399
+ this.#connectPromise?.reject(err);
400
+ this.#connectPromise = undefined;
401
+ return;
402
+ }
403
+ this.#retryAttempt++;
404
+ reporter.net(`Retry attempt ${this.#retryAttempt} / ${this.#retryAttempts} in ${this.#retryInterval}ms...`);
405
+ const { resolve, reject } = this.#connectPromise;
406
+ this.#cleanup();
407
+ this.#retryTimeout = setTimeout(async () => {
408
+ this.#retryTimeout = undefined;
409
+ try {
410
+ this.#connectPromise = { resolve, reject };
411
+ await this.#attemptConnect();
412
+ resolve();
413
+ } catch (retryErr) {}
414
+ }, this.#retryInterval);
415
+ }
416
+ #onClose(hadError) {
417
+ const wasConnected = this.#state === "connected";
418
+ if (this.#state !== "closing") {
419
+ this.#state = "disconnected";
420
+ }
421
+ this.emit("close", hadError);
422
+ if (wasConnected && this.#retryEnabled && hadError) {
423
+ this.#scheduleRetry(new Error("Connection closed unexpectedly."));
424
+ }
425
+ }
426
+ #onConnect() {
427
+ this.#state = "connected";
428
+ this.#retryAttempt = 0;
429
+ this.#socket.setKeepAlive(true, 1e4);
430
+ this.#socket.setTimeout(0);
431
+ this.emit("connect");
432
+ this.#connectPromise?.resolve();
433
+ this.#connectPromise = undefined;
434
+ }
435
+ #onData(data) {
436
+ if (this.#debug) {
437
+ const cutoff = Math.min(data.byteLength, 64);
438
+ reporter.debug(`Received ${data.byteLength} bytes of data.`);
439
+ reporter.debug(`hex=${data.subarray(0, cutoff).toString("hex")}`);
440
+ reporter.debug(`ascii=${data.toString("ascii").replace(/[^\x20-\x7E]/g, ".").substring(0, cutoff)}`);
441
+ }
442
+ this.emit("data", data);
443
+ }
444
+ #onEnd() {
445
+ this.emit("end");
446
+ }
447
+ #onError(err) {
448
+ reporter.error(`Connection error: ${err.message}`);
449
+ this.emit("error", err);
450
+ if (this.#state === "connecting") {
451
+ this.#scheduleRetry(err);
452
+ } else {
453
+ this.#state = "failed";
454
+ }
455
+ }
456
+ #onTimeout() {
457
+ reporter.error("Connection timed out.");
458
+ const err = new Error("Connection timed out.");
459
+ this.emit("timeout");
460
+ this.emit("error", err);
461
+ if (this.#state === "connecting") {
462
+ this.#scheduleRetry(err);
463
+ } else {
464
+ this.#state = "failed";
465
+ this.#socket?.destroy();
466
+ }
467
+ }
468
+ }
469
+
470
+ class EncryptionAwareConnection extends Connection {
471
+ get isEncrypted() {
472
+ return !!this[ENCRYPTION];
473
+ }
474
+ [ENCRYPTION];
475
+ async enableEncryption(readKey, writeKey) {
476
+ this[ENCRYPTION] = new EncryptionState(readKey, writeKey);
477
+ }
478
+ }
479
+
480
+ class EncryptionState {
481
+ readKey;
482
+ readCount;
483
+ writeKey;
484
+ writeCount;
485
+ constructor(readKey, writeKey) {
486
+ this.readCount = 0;
487
+ this.readKey = readKey;
488
+ this.writeCount = 0;
489
+ this.writeKey = writeKey;
490
+ }
491
+ }
492
+ // src/pairing.ts
493
+ import { OPack, TLV8 } from "@basmilius/apple-encoding";
494
+ import { SRP, SrpClient } from "fast-srp-hap";
495
+ import { v4 as uuid } from "uuid";
496
+ import tweetnacl2 from "tweetnacl";
497
+
498
+ class AccessoryPair {
499
+ #name;
500
+ #pairingId;
501
+ #requestHandler;
502
+ #publicKey;
503
+ #secretKey;
504
+ #srp;
505
+ constructor(requestHandler) {
506
+ this.#name = "basmilius/apple-protocols";
507
+ this.#pairingId = Buffer.from(uuid().toUpperCase());
508
+ this.#requestHandler = requestHandler;
509
+ }
510
+ async start() {
511
+ const keyPair = tweetnacl2.sign.keyPair();
512
+ this.#publicKey = Buffer.from(keyPair.publicKey);
513
+ this.#secretKey = Buffer.from(keyPair.secretKey);
514
+ }
515
+ async pin(askPin) {
516
+ const m1 = await this.m1();
517
+ const m2 = await this.m2(m1, await askPin());
518
+ const m3 = await this.m3(m2);
519
+ const m4 = await this.m4(m3);
520
+ const m5 = await this.m5(m4);
521
+ const m6 = await this.m6(m4, m5);
522
+ if (!m6) {
523
+ throw new Error("Pairing failed, could not get accessory keys.");
524
+ }
525
+ return m6;
526
+ }
527
+ async transient() {
528
+ const m1 = await this.m1([[TLV8.Value.Flags, TLV8.Flags.TransientPairing]]);
529
+ const m2 = await this.m2(m1);
530
+ const m3 = await this.m3(m2);
531
+ const m4 = await this.m4(m3);
532
+ const accessoryToControllerKey = hkdf_default({
533
+ hash: "sha512",
534
+ key: m4.sharedSecret,
535
+ length: 32,
536
+ salt: Buffer.from("Control-Salt"),
537
+ info: Buffer.from("Control-Read-Encryption-Key")
538
+ });
539
+ const controllerToAccessoryKey = hkdf_default({
540
+ hash: "sha512",
541
+ key: m4.sharedSecret,
542
+ length: 32,
543
+ salt: Buffer.from("Control-Salt"),
544
+ info: Buffer.from("Control-Write-Encryption-Key")
545
+ });
546
+ return {
547
+ pairingId: this.#pairingId,
548
+ sharedSecret: m4.sharedSecret,
549
+ accessoryToControllerKey,
550
+ controllerToAccessoryKey
551
+ };
552
+ }
553
+ async m1(additionalTlv = []) {
554
+ const response = await this.#requestHandler("m1", TLV8.encode([
555
+ [TLV8.Value.Method, TLV8.Method.PairSetup],
556
+ [TLV8.Value.State, TLV8.State.M1],
557
+ ...additionalTlv
558
+ ]));
559
+ const data = tlv(response);
560
+ const publicKey = data.get(TLV8.Value.PublicKey);
561
+ const salt = data.get(TLV8.Value.Salt);
562
+ return { publicKey, salt };
563
+ }
564
+ async m2(m1, pin = AIRPLAY_TRANSIENT_PIN) {
565
+ const srpKey = await SRP.genKey(32);
566
+ this.#srp = new SrpClient(SRP.params.hap, m1.salt, Buffer.from("Pair-Setup"), Buffer.from(pin), srpKey, true);
567
+ this.#srp.setB(m1.publicKey);
568
+ const publicKey = this.#srp.computeA();
569
+ const proof = this.#srp.computeM1();
570
+ return { publicKey, proof };
571
+ }
572
+ async m3(m2) {
573
+ const response = await this.#requestHandler("m3", TLV8.encode([
574
+ [TLV8.Value.State, TLV8.State.M3],
575
+ [TLV8.Value.PublicKey, m2.publicKey],
576
+ [TLV8.Value.Proof, m2.proof]
577
+ ]));
578
+ const data = tlv(response);
579
+ const serverProof = data.get(TLV8.Value.Proof);
580
+ return { serverProof };
581
+ }
582
+ async m4(m3) {
583
+ this.#srp.checkM2(m3.serverProof);
584
+ const sharedSecret = this.#srp.computeK();
585
+ return { sharedSecret };
586
+ }
587
+ async m5(m4) {
588
+ const iosDeviceX = hkdf_default({
589
+ hash: "sha512",
590
+ key: m4.sharedSecret,
591
+ length: 32,
592
+ salt: Buffer.from("Pair-Setup-Controller-Sign-Salt", "utf8"),
593
+ info: Buffer.from("Pair-Setup-Controller-Sign-Info", "utf8")
594
+ });
595
+ const sessionKey = hkdf_default({
596
+ hash: "sha512",
597
+ key: m4.sharedSecret,
598
+ length: 32,
599
+ salt: Buffer.from("Pair-Setup-Encrypt-Salt", "utf8"),
600
+ info: Buffer.from("Pair-Setup-Encrypt-Info", "utf8")
601
+ });
602
+ const deviceInfo = Buffer.concat([
603
+ iosDeviceX,
604
+ this.#pairingId,
605
+ this.#publicKey
606
+ ]);
607
+ const signature = tweetnacl2.sign.detached(deviceInfo, this.#secretKey);
608
+ const innerTlv = TLV8.encode([
609
+ [TLV8.Value.Identifier, this.#pairingId],
610
+ [TLV8.Value.PublicKey, this.#publicKey],
611
+ [TLV8.Value.Signature, Buffer.from(signature)],
612
+ [TLV8.Value.Name, Buffer.from(OPack.encode({
613
+ name: this.#name
614
+ }))]
615
+ ]);
616
+ const { authTag, ciphertext } = exports_chacha20.encrypt(sessionKey, Buffer.from("PS-Msg05"), null, innerTlv);
617
+ const encrypted = Buffer.concat([ciphertext, authTag]);
618
+ const response = await this.#requestHandler("m5", TLV8.encode([
619
+ [TLV8.Value.State, TLV8.State.M5],
620
+ [TLV8.Value.EncryptedData, encrypted]
621
+ ]));
622
+ const data = tlv(response);
623
+ const encryptedDataRaw = data.get(TLV8.Value.EncryptedData);
624
+ const encryptedData = encryptedDataRaw.subarray(0, -16);
625
+ const encryptedTag = encryptedDataRaw.subarray(-16);
626
+ return {
627
+ authTag: encryptedTag,
628
+ data: encryptedData,
629
+ sessionKey
630
+ };
631
+ }
632
+ async m6(m4, m5) {
633
+ const data = exports_chacha20.decrypt(m5.sessionKey, Buffer.from("PS-Msg06"), null, m5.data, m5.authTag);
634
+ const tlv = TLV8.decode(data);
635
+ const accessoryIdentifier = tlv.get(TLV8.Value.Identifier);
636
+ const accessoryLongTermPublicKey = tlv.get(TLV8.Value.PublicKey);
637
+ const accessorySignature = tlv.get(TLV8.Value.Signature);
638
+ const accessoryX = hkdf_default({
639
+ hash: "sha512",
640
+ key: m4.sharedSecret,
641
+ length: 32,
642
+ salt: Buffer.from("Pair-Setup-Accessory-Sign-Salt"),
643
+ info: Buffer.from("Pair-Setup-Accessory-Sign-Info")
644
+ });
645
+ const accessoryInfo = Buffer.concat([
646
+ accessoryX,
647
+ accessoryIdentifier,
648
+ accessoryLongTermPublicKey
649
+ ]);
650
+ if (!tweetnacl2.sign.detached.verify(accessoryInfo, accessorySignature, accessoryLongTermPublicKey)) {
651
+ throw new Error("Invalid accessory signature.");
652
+ }
653
+ return {
654
+ accessoryIdentifier: accessoryIdentifier.toString(),
655
+ accessoryLongTermPublicKey,
656
+ pairingId: this.#pairingId,
657
+ publicKey: this.#publicKey,
658
+ secretKey: this.#secretKey
659
+ };
660
+ }
661
+ }
662
+
663
+ class AccessoryVerify {
664
+ #ephemeralKeyPair;
665
+ #requestHandler;
666
+ constructor(requestHandler) {
667
+ this.#ephemeralKeyPair = exports_curve25519.generateKeyPair();
668
+ this.#requestHandler = requestHandler;
669
+ }
670
+ async start(credentials) {
671
+ const m1 = await this.#m1();
672
+ const m2 = await this.#m2(credentials.accessoryIdentifier, credentials.accessoryLongTermPublicKey, m1);
673
+ await this.#m3(credentials.pairingId, credentials.secretKey, m2);
674
+ return await this.#m4(m2, credentials.pairingId);
675
+ }
676
+ async#m1() {
677
+ const response = await this.#requestHandler("m1", TLV8.encode([
678
+ [TLV8.Value.State, TLV8.State.M1],
679
+ [TLV8.Value.PublicKey, Buffer.from(this.#ephemeralKeyPair.publicKey)]
680
+ ]));
681
+ const data = tlv(response);
682
+ const serverPublicKey = data.get(TLV8.Value.PublicKey);
683
+ const encryptedData = data.get(TLV8.Value.EncryptedData);
684
+ return {
685
+ encryptedData,
686
+ serverPublicKey
687
+ };
688
+ }
689
+ async#m2(localAccessoryIdentifier, longTermPublicKey, m1) {
690
+ const sharedSecret = Buffer.from(exports_curve25519.generateSharedSecKey(this.#ephemeralKeyPair.secretKey, m1.serverPublicKey));
691
+ const sessionKey = hkdf_default({
692
+ hash: "sha512",
693
+ key: sharedSecret,
694
+ length: 32,
695
+ salt: Buffer.from("Pair-Verify-Encrypt-Salt"),
696
+ info: Buffer.from("Pair-Verify-Encrypt-Info")
697
+ });
698
+ const encryptedData = m1.encryptedData.subarray(0, -16);
699
+ const encryptedTag = m1.encryptedData.subarray(-16);
700
+ const data = exports_chacha20.decrypt(sessionKey, Buffer.from("PV-Msg02"), null, encryptedData, encryptedTag);
701
+ const tlv = TLV8.decode(data);
702
+ const accessoryIdentifier = tlv.get(TLV8.Value.Identifier);
703
+ const accessorySignature = tlv.get(TLV8.Value.Signature);
704
+ if (accessoryIdentifier.toString() !== localAccessoryIdentifier) {
705
+ throw new Error(`Invalid accessory identifier. Expected ${accessoryIdentifier.toString()} to be ${localAccessoryIdentifier}.`);
706
+ }
707
+ const accessoryInfo = Buffer.concat([
708
+ m1.serverPublicKey,
709
+ accessoryIdentifier,
710
+ this.#ephemeralKeyPair.publicKey
711
+ ]);
712
+ if (!tweetnacl2.sign.detached.verify(accessoryInfo, accessorySignature, longTermPublicKey)) {
713
+ throw new Error("Invalid accessory signature.");
714
+ }
715
+ return {
716
+ serverEphemeralPublicKey: m1.serverPublicKey,
717
+ sessionKey,
718
+ sharedSecret
719
+ };
720
+ }
721
+ async#m3(pairingId, secretKey, m2) {
722
+ const iosDeviceInfo = Buffer.concat([
723
+ this.#ephemeralKeyPair.publicKey,
724
+ pairingId,
725
+ m2.serverEphemeralPublicKey
726
+ ]);
727
+ const iosDeviceSignature = Buffer.from(tweetnacl2.sign.detached(iosDeviceInfo, secretKey));
728
+ const innerTlv = TLV8.encode([
729
+ [TLV8.Value.Identifier, pairingId],
730
+ [TLV8.Value.Signature, iosDeviceSignature]
731
+ ]);
732
+ const { authTag, ciphertext } = exports_chacha20.encrypt(m2.sessionKey, Buffer.from("PV-Msg03"), null, innerTlv);
733
+ const encrypted = Buffer.concat([ciphertext, authTag]);
734
+ await this.#requestHandler("m3", TLV8.encode([
735
+ [TLV8.Value.State, TLV8.State.M3],
736
+ [TLV8.Value.EncryptedData, encrypted]
737
+ ]));
738
+ return {};
739
+ }
740
+ async#m4(m2, pairingId) {
741
+ return {
742
+ accessoryToControllerKey: Buffer.alloc(0),
743
+ controllerToAccessoryKey: Buffer.alloc(0),
744
+ pairingId,
745
+ sharedSecret: m2.sharedSecret
746
+ };
747
+ }
748
+ }
749
+ function tlv(buffer) {
750
+ const data = TLV8.decode(buffer);
751
+ if (data.has(TLV8.Value.Error)) {
752
+ TLV8.bail(data);
753
+ }
754
+ reporter.raw("Decoded TLV", data);
755
+ return data;
756
+ }
757
+ // src/utils.ts
758
+ function uint16ToBE(value) {
759
+ const buffer = Buffer.alloc(2);
760
+ buffer.writeUInt16BE(value, 0);
761
+ return buffer;
762
+ }
763
+ function uint53ToLE(value) {
764
+ const [upper, lower] = splitUInt53(value);
765
+ const buffer = Buffer.alloc(8);
766
+ buffer.writeUInt32LE(lower, 0);
767
+ buffer.writeUInt32LE(upper, 4);
768
+ return buffer;
769
+ }
770
+ function splitUInt53(number) {
771
+ const MAX_UINT32 = 4294967295;
772
+ const MAX_INT53 = 9007199254740991;
773
+ if (number <= -1 || number > MAX_INT53) {
774
+ throw new Error("Number out of range.");
775
+ }
776
+ if (Math.floor(number) !== number) {
777
+ throw new Error("Number is not an integer.");
778
+ }
779
+ let upper = 0;
780
+ const signbit = number & 4294967295;
781
+ const lower = signbit < 0 ? (number & 2147483647) + 2147483648 : signbit;
782
+ if (number > MAX_UINT32) {
783
+ upper = (number - lower) / (MAX_UINT32 + 1);
784
+ }
785
+ return [upper, lower];
786
+ }
787
+ export {
788
+ waitFor,
789
+ v4 as uuid,
790
+ uint53ToLE,
791
+ uint16ToBE,
792
+ reporter,
793
+ prompt,
794
+ hkdf_default as hkdf,
795
+ getMacAddress_default as getMacAddress,
796
+ getLocalIP_default as getLocalIP,
797
+ cli,
798
+ timing_default as TimingServer,
799
+ RAOP_SERVICE,
800
+ HTTP_TIMEOUT,
801
+ EncryptionState,
802
+ EncryptionAwareConnection,
803
+ ENCRYPTION,
804
+ Discovery,
805
+ exports_curve25519 as Curve25519,
806
+ Connection,
807
+ exports_chacha20 as Chacha20,
808
+ COMPANION_LINK_SERVICE,
809
+ AccessoryVerify,
810
+ AccessoryPair,
811
+ AIRPLAY_TRANSIENT_PIN,
812
+ AIRPLAY_SERVICE
813
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@basmilius/apple-common",
3
3
  "description": "Common features shared across various apple protocol packages.",
4
- "version": "0.0.80",
4
+ "version": "0.0.81",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": {
@@ -38,7 +38,7 @@
38
38
  }
39
39
  },
40
40
  "dependencies": {
41
- "@basmilius/apple-encoding": "0.0.80",
41
+ "@basmilius/apple-encoding": "0.0.81",
42
42
  "chacha": "^2.1.0",
43
43
  "fast-srp-hap": "^2.0.4",
44
44
  "node-dns-sd": "^1.0.1",