@yume-chan/adb 0.0.23 → 1.0.0
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/CHANGELOG.md +51 -2
- package/LICENSE +1 -1
- package/README.md +4 -1
- package/esm/adb.d.ts +15 -9
- package/esm/adb.d.ts.map +1 -1
- package/esm/adb.js +5 -2
- package/esm/adb.js.map +1 -1
- package/esm/banner.d.ts +7 -6
- package/esm/banner.d.ts.map +1 -1
- package/esm/banner.js +6 -7
- package/esm/banner.js.map +1 -1
- package/esm/commands/framebuffer.d.ts +63 -34
- package/esm/commands/framebuffer.d.ts.map +1 -1
- package/esm/commands/framebuffer.js +35 -33
- package/esm/commands/framebuffer.js.map +1 -1
- package/esm/commands/power.d.ts.map +1 -1
- package/esm/commands/power.js +6 -5
- package/esm/commands/power.js.map +1 -1
- package/esm/commands/reverse.d.ts +12 -12
- package/esm/commands/reverse.d.ts.map +1 -1
- package/esm/commands/reverse.js +60 -39
- package/esm/commands/reverse.js.map +1 -1
- package/esm/commands/subprocess/command.js +3 -3
- package/esm/commands/subprocess/command.js.map +1 -1
- package/esm/commands/subprocess/protocols/none.d.ts +2 -2
- package/esm/commands/subprocess/protocols/none.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/none.js +3 -5
- package/esm/commands/subprocess/protocols/none.js.map +1 -1
- package/esm/commands/subprocess/protocols/shell.d.ts +22 -14
- package/esm/commands/subprocess/protocols/shell.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/shell.js +21 -27
- package/esm/commands/subprocess/protocols/shell.js.map +1 -1
- package/esm/commands/subprocess/protocols/types.d.ts +8 -8
- package/esm/commands/subprocess/protocols/types.d.ts.map +1 -1
- package/esm/commands/sync/list.d.ts +49 -30
- package/esm/commands/sync/list.d.ts.map +1 -1
- package/esm/commands/sync/list.js +9 -11
- package/esm/commands/sync/list.js.map +1 -1
- package/esm/commands/sync/pull.d.ts +7 -9
- package/esm/commands/sync/pull.d.ts.map +1 -1
- package/esm/commands/sync/pull.js +4 -6
- package/esm/commands/sync/pull.js.map +1 -1
- package/esm/commands/sync/push.d.ts +25 -22
- package/esm/commands/sync/push.d.ts.map +1 -1
- package/esm/commands/sync/push.js +14 -21
- package/esm/commands/sync/push.js.map +1 -1
- package/esm/commands/sync/request.d.ts +20 -23
- package/esm/commands/sync/request.d.ts.map +1 -1
- package/esm/commands/sync/request.js +26 -35
- package/esm/commands/sync/request.js.map +1 -1
- package/esm/commands/sync/response.d.ts +25 -19
- package/esm/commands/sync/response.d.ts.map +1 -1
- package/esm/commands/sync/response.js +49 -26
- package/esm/commands/sync/response.js.map +1 -1
- package/esm/commands/sync/socket.d.ts +3 -3
- package/esm/commands/sync/socket.d.ts.map +1 -1
- package/esm/commands/sync/socket.js +10 -5
- package/esm/commands/sync/socket.js.map +1 -1
- package/esm/commands/sync/stat.d.ts +75 -54
- package/esm/commands/sync/stat.d.ts.map +1 -1
- package/esm/commands/sync/stat.js +73 -69
- package/esm/commands/sync/stat.js.map +1 -1
- package/esm/commands/sync/sync.d.ts +18 -17
- package/esm/commands/sync/sync.d.ts.map +1 -1
- package/esm/commands/sync/sync.js +8 -8
- package/esm/commands/sync/sync.js.map +1 -1
- package/esm/commands/tcpip.d.ts +0 -1
- package/esm/commands/tcpip.d.ts.map +1 -1
- package/esm/commands/tcpip.js +9 -9
- package/esm/commands/tcpip.js.map +1 -1
- package/esm/daemon/auth.d.ts +8 -7
- package/esm/daemon/auth.d.ts.map +1 -1
- package/esm/daemon/auth.js +8 -9
- package/esm/daemon/auth.js.map +1 -1
- package/esm/daemon/crypto.d.ts +4 -3
- package/esm/daemon/crypto.d.ts.map +1 -1
- package/esm/daemon/crypto.js +57 -49
- package/esm/daemon/crypto.js.map +1 -1
- package/esm/daemon/device.d.ts +2 -2
- package/esm/daemon/device.d.ts.map +1 -1
- package/esm/daemon/dispatcher.d.ts +35 -10
- package/esm/daemon/dispatcher.d.ts.map +1 -1
- package/esm/daemon/dispatcher.js +46 -33
- package/esm/daemon/dispatcher.js.map +1 -1
- package/esm/daemon/packet.d.ts +48 -32
- package/esm/daemon/packet.d.ts.map +1 -1
- package/esm/daemon/packet.js +36 -32
- package/esm/daemon/packet.js.map +1 -1
- package/esm/daemon/socket.d.ts +11 -11
- package/esm/daemon/socket.d.ts.map +1 -1
- package/esm/daemon/socket.js +19 -40
- package/esm/daemon/socket.js.map +1 -1
- package/esm/daemon/transport.d.ts +60 -20
- package/esm/daemon/transport.d.ts.map +1 -1
- package/esm/daemon/transport.js +12 -15
- package/esm/daemon/transport.js.map +1 -1
- package/esm/device-observer.d.ts +10 -0
- package/esm/device-observer.d.ts.map +1 -0
- package/esm/device-observer.js +2 -0
- package/esm/device-observer.js.map +1 -0
- package/esm/features.d.ts +12 -11
- package/esm/features.d.ts.map +1 -1
- package/esm/features.js +11 -12
- package/esm/features.js.map +1 -1
- package/esm/index.d.ts +1 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/server/client.d.ts +140 -50
- package/esm/server/client.d.ts.map +1 -1
- package/esm/server/client.js +396 -180
- package/esm/server/client.js.map +1 -1
- package/esm/server/transport.d.ts +2 -2
- package/esm/server/transport.d.ts.map +1 -1
- package/esm/server/transport.js +4 -6
- package/esm/server/transport.js.map +1 -1
- package/esm/utils/base64.d.ts.map +1 -1
- package/esm/utils/base64.js +52 -38
- package/esm/utils/base64.js.map +1 -1
- package/esm/utils/hex.d.ts +1 -1
- package/esm/utils/hex.d.ts.map +1 -1
- package/esm/utils/hex.js +12 -14
- package/esm/utils/hex.js.map +1 -1
- package/esm/utils/index.d.ts +1 -1
- package/esm/utils/index.d.ts.map +1 -1
- package/esm/utils/index.js +1 -1
- package/esm/utils/index.js.map +1 -1
- package/esm/utils/no-op.d.ts.map +1 -1
- package/esm/utils/no-op.js +1 -0
- package/esm/utils/no-op.js.map +1 -1
- package/esm/utils/sequence-equal.d.ts +2 -0
- package/esm/utils/sequence-equal.d.ts.map +1 -0
- package/esm/utils/sequence-equal.js +12 -0
- package/esm/utils/sequence-equal.js.map +1 -0
- package/package.json +14 -19
- package/src/adb.ts +20 -11
- package/src/banner.ts +8 -6
- package/src/commands/framebuffer.ts +44 -35
- package/src/commands/power.ts +7 -5
- package/src/commands/reverse.ts +78 -47
- package/src/commands/subprocess/command.ts +3 -3
- package/src/commands/subprocess/protocols/none.ts +5 -7
- package/src/commands/subprocess/protocols/shell.ts +33 -35
- package/src/commands/subprocess/protocols/types.ts +8 -8
- package/src/commands/sync/list.ts +20 -15
- package/src/commands/sync/pull.ts +9 -8
- package/src/commands/sync/push.ts +25 -24
- package/src/commands/sync/request.ts +37 -38
- package/src/commands/sync/response.ts +63 -37
- package/src/commands/sync/socket.ts +13 -8
- package/src/commands/sync/stat.ts +93 -73
- package/src/commands/sync/sync.ts +12 -11
- package/src/commands/tcpip.ts +9 -9
- package/src/daemon/auth.ts +12 -10
- package/src/daemon/crypto.ts +66 -55
- package/src/daemon/device.ts +2 -2
- package/src/daemon/dispatcher.ts +106 -44
- package/src/daemon/packet.ts +57 -38
- package/src/daemon/socket.ts +30 -50
- package/src/daemon/transport.ts +98 -50
- package/src/device-observer.ts +10 -0
- package/src/features.ts +13 -11
- package/src/index.ts +1 -0
- package/src/server/client.ts +505 -268
- package/src/server/transport.ts +7 -9
- package/src/utils/base64.ts +59 -40
- package/src/utils/hex.ts +16 -14
- package/src/utils/index.ts +1 -1
- package/src/utils/no-op.ts +1 -0
- package/src/utils/sequence-equal.ts +13 -0
- package/tsconfig.build.json +1 -12
- package/tsconfig.build.tsbuildinfo +1 -1
- package/CHANGELOG.json +0 -265
- package/esm/utils/conditional-variable.d.ts +0 -8
- package/esm/utils/conditional-variable.d.ts.map +0 -1
- package/esm/utils/conditional-variable.js +0 -34
- package/esm/utils/conditional-variable.js.map +0 -1
- package/src/utils/conditional-variable.ts +0 -45
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tcpip.js","sourceRoot":"","sources":["../../src/commands/tcpip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAsB3C,
|
|
1
|
+
{"version":3,"file":"tcpip.js","sourceRoot":"","sources":["../../src/commands/tcpip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAsB3C,SAAS,SAAS,CAAC,KAAa;IAC5B,IAAI,CAAC,KAAK,IAAI,KAAK,KAAK,GAAG,EAAE,CAAC;QAC1B,OAAO,SAAS,CAAC;IACrB,CAAC;IACD,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,OAAO,eAAgB,SAAQ,cAAc;IAC/C,KAAK,CAAC,kBAAkB;QACpB,MAAM,sBAAsB,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CACjD,0BAA0B,CAC7B,CAAC;QACF,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;QACnE,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;QAEnE,OAAO;YACH,sBAAsB,EAClB,sBAAsB,IAAI,EAAE;gBACxB,CAAC,CAAC,sBAAsB,CAAC,KAAK,CAAC,GAAG,CAAC;gBACnC,CAAC,CAAC,EAAE;YACZ,WAAW,EAAE,SAAS,CAAC,WAAW,CAAC;YACnC,WAAW,EAAE,SAAS,CAAC,WAAW,CAAC;SACtC,CAAC;IACN,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,IAAY;QACtB,IAAI,IAAI,IAAI,CAAC,EAAE,CAAC;YACZ,MAAM,IAAI,SAAS,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC;QAChD,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;QACnE,IAAI,MAAM,KAAK,gCAAgC,IAAI,IAAI,EAAE,CAAC;YACtD,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;QAC5B,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,OAAO;QACT,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;QAC1D,IAAI,MAAM,KAAK,0BAA0B,EAAE,CAAC;YACxC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;QAC5B,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ"}
|
package/esm/daemon/auth.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { MaybePromiseLike } from "@yume-chan/async";
|
|
1
2
|
import type { Disposable } from "@yume-chan/event";
|
|
2
|
-
import type { ValueOrPromise } from "@yume-chan/struct";
|
|
3
3
|
import type { AdbPacketData } from "./packet.js";
|
|
4
4
|
export interface AdbPrivateKey {
|
|
5
5
|
/**
|
|
@@ -13,7 +13,7 @@ export interface AdbCredentialStore {
|
|
|
13
13
|
/**
|
|
14
14
|
* Generates and stores a RSA private key with modulus length `2048` and public exponent `65537`.
|
|
15
15
|
*/
|
|
16
|
-
generateKey():
|
|
16
|
+
generateKey(): MaybePromiseLike<AdbPrivateKey>;
|
|
17
17
|
/**
|
|
18
18
|
* Synchronously or asynchronously iterates through all stored RSA private keys.
|
|
19
19
|
*
|
|
@@ -21,11 +21,12 @@ export interface AdbCredentialStore {
|
|
|
21
21
|
*/
|
|
22
22
|
iterateKeys(): AdbKeyIterable;
|
|
23
23
|
}
|
|
24
|
-
export declare
|
|
25
|
-
Token
|
|
26
|
-
Signature
|
|
27
|
-
PublicKey
|
|
28
|
-
}
|
|
24
|
+
export declare const AdbAuthType: {
|
|
25
|
+
readonly Token: 1;
|
|
26
|
+
readonly Signature: 2;
|
|
27
|
+
readonly PublicKey: 3;
|
|
28
|
+
};
|
|
29
|
+
export type AdbAuthType = (typeof AdbAuthType)[keyof typeof AdbAuthType];
|
|
29
30
|
export interface AdbAuthenticator {
|
|
30
31
|
/**
|
|
31
32
|
* @param getNextRequest
|
package/esm/daemon/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/daemon/auth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/daemon/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAcnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,MAAM,WAAW,aAAa;IAC1B;;OAEG;IACH,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B;AAED,MAAM,MAAM,cAAc,GACpB,QAAQ,CAAC,aAAa,CAAC,GACvB,aAAa,CAAC,aAAa,CAAC,CAAC;AAEnC,MAAM,WAAW,kBAAkB;IAC/B;;OAEG;IACH,WAAW,IAAI,gBAAgB,CAAC,aAAa,CAAC,CAAC;IAE/C;;;;OAIG;IACH,WAAW,IAAI,cAAc,CAAC;CACjC;AAED,eAAO,MAAM,WAAW;;;;CAId,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;AAEzE,MAAM,WAAW,gBAAgB;IAC7B;;;;;;;;;;OAUG;IACH,CACI,eAAe,EAAE,kBAAkB,EACnC,cAAc,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC,GAC7C,aAAa,CAAC,aAAa,CAAC,CAAC;CACnC;AAED,eAAO,MAAM,yBAAyB,EAAE,gBAmBvC,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,gBA+CvC,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,gBAAgB,EAGxD,CAAC;AAEF,qBAAa,0BAA2B,YAAW,UAAU;;IACzD,QAAQ,CAAC,cAAc,EAAE,SAAS,gBAAgB,EAAE,CAAC;gBAQjD,cAAc,EAAE,SAAS,gBAAgB,EAAE,EAC3C,eAAe,EAAE,kBAAkB;IA6BjC,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IAe5D,OAAO;CAGV"}
|
package/esm/daemon/auth.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { PromiseResolver } from "@yume-chan/async";
|
|
2
|
-
import {
|
|
2
|
+
import { EmptyUint8Array } from "@yume-chan/struct";
|
|
3
3
|
import { calculateBase64EncodedLength, encodeBase64, encodeUtf8, } from "../utils/index.js";
|
|
4
4
|
import { adbGeneratePublicKey, adbGetPublicKeySize, rsaSign, } from "./crypto.js";
|
|
5
5
|
import { AdbCommand } from "./packet.js";
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
})(AdbAuthType || (AdbAuthType = {}));
|
|
6
|
+
export const AdbAuthType = {
|
|
7
|
+
Token: 1,
|
|
8
|
+
Signature: 2,
|
|
9
|
+
PublicKey: 3,
|
|
10
|
+
};
|
|
12
11
|
export const AdbSignatureAuthenticator = async function* (credentialStore, getNextRequest) {
|
|
13
12
|
for await (const key of credentialStore.iterateKeys()) {
|
|
14
13
|
const packet = await getNextRequest();
|
|
@@ -20,7 +19,7 @@ export const AdbSignatureAuthenticator = async function* (credentialStore, getNe
|
|
|
20
19
|
command: AdbCommand.Auth,
|
|
21
20
|
arg0: AdbAuthType.Signature,
|
|
22
21
|
arg1: 0,
|
|
23
|
-
payload:
|
|
22
|
+
payload: signature,
|
|
24
23
|
};
|
|
25
24
|
}
|
|
26
25
|
};
|
|
@@ -41,7 +40,7 @@ export const AdbPublicKeyAuthenticator = async function* (credentialStore, getNe
|
|
|
41
40
|
const [publicKeyBase64Length] = calculateBase64EncodedLength(publicKeyLength);
|
|
42
41
|
const nameBuffer = privateKey.name?.length
|
|
43
42
|
? encodeUtf8(privateKey.name)
|
|
44
|
-
:
|
|
43
|
+
: EmptyUint8Array;
|
|
45
44
|
const publicKeyBuffer = new Uint8Array(publicKeyBase64Length +
|
|
46
45
|
(nameBuffer.length ? nameBuffer.length + 1 : 0) + // Space character + name
|
|
47
46
|
1);
|
package/esm/daemon/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/daemon/auth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/daemon/auth.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EACH,4BAA4B,EAC5B,YAAY,EACZ,UAAU,GACb,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACH,oBAAoB,EACpB,mBAAmB,EACnB,OAAO,GACV,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA4BzC,MAAM,CAAC,MAAM,WAAW,GAAG;IACvB,KAAK,EAAE,CAAC;IACR,SAAS,EAAE,CAAC;IACZ,SAAS,EAAE,CAAC;CACN,CAAC;AAsBX,MAAM,CAAC,MAAM,yBAAyB,GAAqB,KAAK,SAAS,CAAC,EACtE,eAAmC,EACnC,cAA4C;IAE5C,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,eAAe,CAAC,WAAW,EAAE,EAAE,CAAC;QACpD,MAAM,MAAM,GAAG,MAAM,cAAc,EAAE,CAAC;QAEtC,IAAI,MAAM,CAAC,IAAI,KAAK,WAAW,C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AAe,EAAE,CAAC;gBAE7C,oCAAoC;gBACpC,MAAM,MAAM,CAAC;YACjB,CAAC;YAED,iCAAiC;YACjC,6DAA6D;QACjE,CAAC;IACL,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,MAAqB;QAC/B,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YAClB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;QACjD,CAAC;QAED,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAErC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;QAC3C,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;QAC/D,CAAC;QAED,OAAO,MAAM,CAAC,KAAK,CAAC;IACxB,CAAC;IAED,OAAO;QACH,KAAK,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC;IACpC,CAAC;CACJ"}
|
package/esm/daemon/crypto.d.ts
CHANGED
|
@@ -5,15 +5,16 @@
|
|
|
5
5
|
* Only supports Big-Endian, because that's what ADB uses.
|
|
6
6
|
* @param byteOffset The place in the buffer at which the value should be retrieved.
|
|
7
7
|
*/
|
|
8
|
-
export declare function getBigUint(
|
|
8
|
+
export declare function getBigUint(array: Uint8Array, byteOffset: number, length: number): bigint;
|
|
9
9
|
/**
|
|
10
10
|
* Stores an arbitrary-precision positive `BigInt` value at the specified byte offset from the start of the view.
|
|
11
11
|
* @param byteOffset The place in the buffer at which the value should be set.
|
|
12
|
+
* @param length The number of bytes to set.
|
|
12
13
|
* @param value The value to set.
|
|
13
14
|
* @param littleEndian If `false` or `undefined`, a big-endian value should be written,
|
|
14
15
|
* otherwise a little-endian value should be written.
|
|
15
16
|
*/
|
|
16
|
-
export declare function setBigUint(
|
|
17
|
+
export declare function setBigUint(array: Uint8Array, byteOffset: number, length: number, value: bigint, littleEndian?: boolean): void;
|
|
17
18
|
export declare function rsaParsePrivateKey(key: Uint8Array): [n: bigint, d: bigint];
|
|
18
19
|
export declare function modInverse(a: number, m: number): number;
|
|
19
20
|
export declare function adbGetPublicKeySize(): number;
|
|
@@ -32,6 +33,6 @@ export declare const ASN1_SEQUENCE = 48;
|
|
|
32
33
|
export declare const ASN1_OCTET_STRING = 4;
|
|
33
34
|
export declare const ASN1_NULL = 5;
|
|
34
35
|
export declare const ASN1_OID = 6;
|
|
35
|
-
export declare const SHA1_DIGEST_INFO: Uint8Array
|
|
36
|
+
export declare const SHA1_DIGEST_INFO: Uint8Array<ArrayBuffer>;
|
|
36
37
|
export declare function rsaSign(privateKey: Uint8Array, data: Uint8Array): Uint8Array;
|
|
37
38
|
//# sourceMappingURL=crypto.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../src/daemon/crypto.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../src/daemon/crypto.ts"],"names":[],"mappings":"AAMA;;;;;;GAMG;AACH,wBAAgB,UAAU,CACtB,KAAK,EAAE,UAAU,EACjB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GACf,MAAM,CAaR;AAED;;;;;;;GAOG;AAGH,wBAAgB,UAAU,CACtB,KAAK,EAAE,UAAU,EACjB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,OAAO,QAgBzB;AA4BD,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,UAAU,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAI1E;AAeD,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,UAuB9C;AAKD,wBAAgB,mBAAmB,WAElC;AAED,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,CAAC;AACzE,wBAAgB,oBAAoB,CAChC,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,UAAU,GACnB,MAAM,CAAC;AA+EV;;;;;;GAMG;AACH,wBAAgB,MAAM,CAClB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GAChB,MAAM,CAkBR;AAED,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC,eAAO,MAAM,aAAa,KAAO,CAAC;AAClC,eAAO,MAAM,iBAAiB,IAAO,CAAC;AACtC,eAAO,MAAM,SAAS,IAAO,CAAC;AAC9B,eAAO,MAAM,QAAQ,IAAO,CAAC;AAG7B,eAAO,MAAM,gBAAgB,yBAiB3B,CAAC;AAQH,wBAAgB,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,GAAG,UAAU,CAqC5E"}
|
package/esm/daemon/crypto.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getUint64BigEndian, setInt64BigEndian, setInt64LittleEndian, } from "@yume-chan/no-data-view";
|
|
2
2
|
/**
|
|
3
3
|
* Gets the `BigInt` value at the specified byte offset and length from the start of the view. There is
|
|
4
4
|
* no alignment constraint; multi-byte values may be fetched from any offset.
|
|
@@ -6,47 +6,42 @@ import { getBigUint64, setBigUint64, } from "@yume-chan/dataview-bigint-polyfill
|
|
|
6
6
|
* Only supports Big-Endian, because that's what ADB uses.
|
|
7
7
|
* @param byteOffset The place in the buffer at which the value should be retrieved.
|
|
8
8
|
*/
|
|
9
|
-
export function getBigUint(
|
|
9
|
+
export function getBigUint(array, byteOffset, length) {
|
|
10
10
|
let result = 0n;
|
|
11
11
|
// Currently `length` must be a multiplication of 8
|
|
12
12
|
// Support for arbitrary length can be easily added
|
|
13
13
|
for (let i = byteOffset; i < byteOffset + length; i += 8) {
|
|
14
14
|
result <<= 64n;
|
|
15
|
-
const value =
|
|
16
|
-
result
|
|
15
|
+
const value = getUint64BigEndian(array, i);
|
|
16
|
+
result |= value;
|
|
17
17
|
}
|
|
18
18
|
return result;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* Stores an arbitrary-precision positive `BigInt` value at the specified byte offset from the start of the view.
|
|
22
22
|
* @param byteOffset The place in the buffer at which the value should be set.
|
|
23
|
+
* @param length The number of bytes to set.
|
|
23
24
|
* @param value The value to set.
|
|
24
25
|
* @param littleEndian If `false` or `undefined`, a big-endian value should be written,
|
|
25
26
|
* otherwise a little-endian value should be written.
|
|
26
27
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
29
|
+
export function setBigUint(array, byteOffset, length, value, littleEndian) {
|
|
29
30
|
if (littleEndian) {
|
|
30
31
|
while (value > 0n) {
|
|
31
|
-
|
|
32
|
+
setInt64LittleEndian(array, byteOffset, value);
|
|
32
33
|
byteOffset += 8;
|
|
33
34
|
value >>= 64n;
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
else {
|
|
37
|
-
|
|
38
|
-
// Convert it to an array of `uint64` first.
|
|
39
|
-
const uint64Array = [];
|
|
38
|
+
let position = byteOffset + length - 8;
|
|
40
39
|
while (value > 0n) {
|
|
41
|
-
|
|
40
|
+
setInt64BigEndian(array, position, value);
|
|
41
|
+
position -= 8;
|
|
42
42
|
value >>= 64n;
|
|
43
43
|
}
|
|
44
|
-
for (let i = uint64Array.length - 1; i >= 0; i -= 1) {
|
|
45
|
-
setBigUint64(dataView, byteOffset, uint64Array[i], false);
|
|
46
|
-
byteOffset += 8;
|
|
47
|
-
}
|
|
48
44
|
}
|
|
49
|
-
return byteOffset - start;
|
|
50
45
|
}
|
|
51
46
|
// These values are correct only if
|
|
52
47
|
// modulus length is 2048 and
|
|
@@ -71,16 +66,24 @@ const RsaPrivateKeyNLength = 2048 / 8;
|
|
|
71
66
|
const RsaPrivateKeyDOffset = 303;
|
|
72
67
|
const RsaPrivateKeyDLength = 2048 / 8;
|
|
73
68
|
export function rsaParsePrivateKey(key) {
|
|
74
|
-
const
|
|
75
|
-
const
|
|
76
|
-
const d = getBigUint(view, RsaPrivateKeyDOffset, RsaPrivateKeyDLength);
|
|
69
|
+
const n = getBigUint(key, RsaPrivateKeyNOffset, RsaPrivateKeyNLength);
|
|
70
|
+
const d = getBigUint(key, RsaPrivateKeyDOffset, RsaPrivateKeyDLength);
|
|
77
71
|
return [n, d];
|
|
78
72
|
}
|
|
73
|
+
function nonNegativeMod(m, d) {
|
|
74
|
+
const r = m % d;
|
|
75
|
+
if (r > 0) {
|
|
76
|
+
return r;
|
|
77
|
+
}
|
|
78
|
+
return r + (d > 0 ? d : -d);
|
|
79
|
+
}
|
|
80
|
+
// https://en.wikipedia.org/wiki/Modular_multiplicative_inverse
|
|
81
|
+
// Solve for the smallest positive `x` in the equation `a * x ≡ 1 (mod m)`,
|
|
82
|
+
// or in other words, `a * x % m = 1`
|
|
79
83
|
// Taken from https://stackoverflow.com/a/51562038
|
|
80
|
-
// I can't understand, but it does work
|
|
81
84
|
// Only used with numbers smaller than 2^32 so doesn't need BigInt
|
|
82
85
|
export function modInverse(a, m) {
|
|
83
|
-
a = (
|
|
86
|
+
a = nonNegativeMod(a, m);
|
|
84
87
|
if (!a || m < 2) {
|
|
85
88
|
return NaN; // invalid input
|
|
86
89
|
}
|
|
@@ -91,6 +94,7 @@ export function modInverse(a, m) {
|
|
|
91
94
|
[a, b] = [b, a % b];
|
|
92
95
|
s.push({ a, b });
|
|
93
96
|
}
|
|
97
|
+
/* istanbul ignore next */
|
|
94
98
|
if (a !== 1) {
|
|
95
99
|
return NaN; // inverse does not exists
|
|
96
100
|
}
|
|
@@ -100,27 +104,33 @@ export function modInverse(a, m) {
|
|
|
100
104
|
for (let i = s.length - 2; i >= 0; i -= 1) {
|
|
101
105
|
[x, y] = [y, x - y * Math.floor(s[i].a / s[i].b)];
|
|
102
106
|
}
|
|
103
|
-
return (
|
|
107
|
+
return nonNegativeMod(y, m);
|
|
104
108
|
}
|
|
109
|
+
const ModulusLengthInBytes = 2048 / 8;
|
|
110
|
+
const ModulusLengthInWords = ModulusLengthInBytes / 4;
|
|
105
111
|
export function adbGetPublicKeySize() {
|
|
106
|
-
return 4 + 4 +
|
|
112
|
+
return 4 + 4 + ModulusLengthInBytes + ModulusLengthInBytes + 4;
|
|
107
113
|
}
|
|
108
114
|
export function adbGeneratePublicKey(privateKey, output) {
|
|
109
|
-
//
|
|
110
|
-
//
|
|
111
|
-
//
|
|
115
|
+
// cspell: ignore: mincrypt
|
|
116
|
+
// Android 6 and earlier has its own encryption library called mincrypt
|
|
117
|
+
// This is the RSA public key format used by mincrypt:
|
|
118
|
+
// https://android.googlesource.com/platform/system/core/+/bb0c180e62703c2068a1b2c9f8ba6d634bf1553c/include/mincrypt/rsa.h#46
|
|
119
|
+
// `n0inv` and `rr` are pre-calculated to speed up RSA operations
|
|
120
|
+
// Android 7 switched its encryption library to BoringSSL, but still keeps the key format:
|
|
121
|
+
// https://android.googlesource.com/platform/system/core.git/+/91784040db2b9273687f88d8b95f729d4a61ecc2/libcrypto_utils/android_pubkey.cpp#38
|
|
122
|
+
// Except when reading a key, `n0inv` and `rr` are ignored (they are still populated when generating a key):
|
|
123
|
+
// https://android.googlesource.com/platform/system/core.git/+/91784040db2b9273687f88d8b95f729d4a61ecc2/libcrypto_utils/android_pubkey.cpp#55
|
|
124
|
+
// The public key is a struct (in little endian) of:
|
|
112
125
|
//
|
|
113
126
|
// [
|
|
114
127
|
// modulusLengthInWords, // 32-bit integer, a "word" is 32-bit so it must be 2048 / 8 / 4
|
|
115
|
-
// //
|
|
116
|
-
// n0inv, // 32-bit integer, the modular inverse of (
|
|
117
|
-
// modulus, // n
|
|
128
|
+
// // (the comment in Android source code is incorrect saying "This must be ANDROID_PUBKEY_MODULUS_SIZE")
|
|
129
|
+
// n0inv, // 32-bit integer, the modular inverse of (lower 32 bits of `n`)
|
|
130
|
+
// modulus, // `n`
|
|
118
131
|
// rr, // Montgomery parameter R^2
|
|
119
|
-
// exponent, // 32-bit integer, must be 65537
|
|
132
|
+
// exponent, // 32-bit integer, must be 3 or 65537
|
|
120
133
|
// ]
|
|
121
|
-
//
|
|
122
|
-
// (All in little endian)
|
|
123
|
-
// See https://android.googlesource.com/platform/system/core.git/+/91784040db2b9273687f88d8b95f729d4a61ecc2/libcrypto_utils/android_pubkey.cpp#38
|
|
124
134
|
let outputType;
|
|
125
135
|
const outputLength = adbGetPublicKeySize();
|
|
126
136
|
if (!output) {
|
|
@@ -128,30 +138,29 @@ export function adbGeneratePublicKey(privateKey, output) {
|
|
|
128
138
|
outputType = "Uint8Array";
|
|
129
139
|
}
|
|
130
140
|
else {
|
|
131
|
-
if (output.
|
|
132
|
-
throw new
|
|
141
|
+
if (output.length < outputLength) {
|
|
142
|
+
throw new TypeError("output buffer is too small");
|
|
133
143
|
}
|
|
134
144
|
outputType = "number";
|
|
135
145
|
}
|
|
136
|
-
const outputView = new DataView(output.buffer, output.byteOffset, output.
|
|
146
|
+
const outputView = new DataView(output.buffer, output.byteOffset, output.length);
|
|
137
147
|
let outputOffset = 0;
|
|
138
148
|
// modulusLengthInWords
|
|
139
|
-
outputView.setUint32(outputOffset,
|
|
149
|
+
outputView.setUint32(outputOffset, ModulusLengthInWords, true);
|
|
140
150
|
outputOffset += 4;
|
|
141
151
|
// extract `n` from private key
|
|
142
152
|
const [n] = rsaParsePrivateKey(privateKey);
|
|
143
153
|
// Calculate `n0inv`
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
const n0inv = modInverse(-Number(BigInt.asUintN(32, n)), 2 ** 32);
|
|
147
|
-
outputView.setUint32(outputOffset, n0inv, true);
|
|
154
|
+
const n0inv = -modInverse(Number(n % 2n ** 32n), 2 ** 32);
|
|
155
|
+
outputView.setInt32(outputOffset, n0inv, true);
|
|
148
156
|
outputOffset += 4;
|
|
149
|
-
// Write n
|
|
150
|
-
setBigUint(
|
|
151
|
-
outputOffset +=
|
|
152
|
-
// Calculate rr = (2
|
|
157
|
+
// Write `n` (a.k.a. `modulus`)
|
|
158
|
+
setBigUint(output, outputOffset, ModulusLengthInBytes, n, true);
|
|
159
|
+
outputOffset += ModulusLengthInBytes;
|
|
160
|
+
// Calculate rr = (2 ** (rsa_size)) ** 2 % n
|
|
153
161
|
const rr = 2n ** 4096n % n;
|
|
154
|
-
|
|
162
|
+
setBigUint(output, outputOffset, ModulusLengthInBytes, rr, true);
|
|
163
|
+
outputOffset += ModulusLengthInBytes;
|
|
155
164
|
// exponent
|
|
156
165
|
outputView.setUint32(outputOffset, 65537, true);
|
|
157
166
|
outputOffset += 4;
|
|
@@ -235,11 +244,10 @@ export function rsaSign(privateKey, data) {
|
|
|
235
244
|
padded.set(data, index);
|
|
236
245
|
// Encryption
|
|
237
246
|
// signature = padded ** d % n
|
|
238
|
-
const
|
|
239
|
-
const signature = powMod(getBigUint(view, 0, view.byteLength), d, n);
|
|
247
|
+
const signature = powMod(getBigUint(padded, 0, padded.length), d, n);
|
|
240
248
|
// `padded` is not used anymore,
|
|
241
249
|
// re-use the buffer to store the result
|
|
242
|
-
setBigUint(
|
|
250
|
+
setBigUint(padded, 0, padded.length, signature, false);
|
|
243
251
|
return padded;
|
|
244
252
|
}
|
|
245
253
|
//# sourceMappingURL=crypto.js.map
|
package/esm/daemon/crypto.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../src/daemon/crypto.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,
|
|
1
|
+
{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../src/daemon/crypto.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,GACvB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CACtB,KAAiB,EACjB,UAAkB,EAClB,MAAc;IAEd,IAAI,MAAM,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GAAG,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAErE,gCAAgC;IAChC,wCAAwC;IACxC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;IAEvD,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
package/esm/daemon/device.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import type { MaybePromiseLike } from "@yume-chan/async";
|
|
1
2
|
import type { Consumable, ReadableWritablePair } from "@yume-chan/stream-extra";
|
|
2
|
-
import type { ValueOrPromise } from "@yume-chan/struct";
|
|
3
3
|
import type { AdbPacketData, AdbPacketInit } from "./packet.js";
|
|
4
4
|
export interface AdbDaemonDevice {
|
|
5
5
|
readonly serial: string;
|
|
6
6
|
readonly name: string | undefined;
|
|
7
|
-
connect():
|
|
7
|
+
connect(): MaybePromiseLike<ReadableWritablePair<AdbPacketData, Consumable<AdbPacketInit>>>;
|
|
8
8
|
}
|
|
9
9
|
//# sourceMappingURL=device.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../../src/daemon/device.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../../src/daemon/device.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAEhF,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEhE,MAAM,WAAW,eAAe;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAElC,OAAO,IAAI,gBAAgB,CACvB,oBAAoB,CAAC,aAAa,EAAE,UAAU,CAAC,aAAa,CAAC,CAAC,CACjE,CAAC;CACL"}
|
|
@@ -1,29 +1,54 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ReadableWritablePair } from "@yume-chan/stream-extra";
|
|
2
|
+
import { Consumable } from "@yume-chan/stream-extra";
|
|
2
3
|
import type { AdbIncomingSocketHandler, AdbSocket, Closeable } from "../adb.js";
|
|
3
4
|
import type { AdbPacketData, AdbPacketInit } from "./packet.js";
|
|
4
5
|
import { AdbCommand } from "./packet.js";
|
|
5
6
|
export interface AdbPacketDispatcherOptions {
|
|
7
|
+
/**
|
|
8
|
+
* From Android 9.0, ADB stopped checking the checksum in packet header to improve performance.
|
|
9
|
+
*
|
|
10
|
+
* The value should be inferred from the device's ADB protocol version.
|
|
11
|
+
*/
|
|
6
12
|
calculateChecksum: boolean;
|
|
7
13
|
/**
|
|
8
|
-
* Before Android 9.0, ADB uses `char*` to parse service
|
|
14
|
+
* Before Android 9.0, ADB uses `char*` to parse service strings,
|
|
9
15
|
* thus requires a null character to terminate.
|
|
10
16
|
*
|
|
11
|
-
*
|
|
17
|
+
* The value should be inferred from the device's ADB protocol version.
|
|
18
|
+
* Usually it should have the same value as `calculateChecksum`, since they both changed
|
|
19
|
+
* in Android 9.0.
|
|
12
20
|
*/
|
|
13
21
|
appendNullToServiceString: boolean;
|
|
14
22
|
maxPayloadSize: number;
|
|
23
|
+
/**
|
|
24
|
+
* Whether to keep the `connection` open (don't call `writable.close` and `readable.cancel`)
|
|
25
|
+
* when `AdbPacketDispatcher.close` is called.
|
|
26
|
+
*
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
preserveConnection?: boolean | undefined;
|
|
15
30
|
/**
|
|
16
31
|
* The number of bytes the device can send before receiving an ack packet.
|
|
17
|
-
|
|
18
|
-
*
|
|
19
|
-
*
|
|
32
|
+
* Using delayed ack can improve the throughput,
|
|
33
|
+
* especially when the device is connected over Wi-Fi (so the latency is higher).
|
|
34
|
+
*
|
|
35
|
+
* This must be the negotiated value between the client and device. If the device enabled
|
|
36
|
+
* delayed ack but the client didn't, the device will throw an error when the client sends
|
|
37
|
+
* the first `WRTE` packet. And vice versa.
|
|
20
38
|
*/
|
|
21
39
|
initialDelayedAckBytes: number;
|
|
22
40
|
/**
|
|
23
|
-
*
|
|
41
|
+
* When set, the dispatcher will throw an error when
|
|
42
|
+
* one of the socket readable stalls for this amount of milliseconds.
|
|
43
|
+
*
|
|
44
|
+
* Because ADB is a multiplexed protocol, blocking one socket will also block all other sockets.
|
|
45
|
+
* It's important to always read from all sockets to prevent stalling.
|
|
46
|
+
*
|
|
47
|
+
* This option is helpful to detect bugs in the client code.
|
|
48
|
+
*
|
|
49
|
+
* @default false
|
|
24
50
|
*/
|
|
25
|
-
|
|
26
|
-
debugSlowRead?: boolean | undefined;
|
|
51
|
+
readTimeLimit?: number | undefined;
|
|
27
52
|
}
|
|
28
53
|
/**
|
|
29
54
|
* The dispatcher is the "dumb" part of the connection handling logic.
|
|
@@ -44,7 +69,7 @@ export declare class AdbPacketDispatcher implements Closeable {
|
|
|
44
69
|
addReverseTunnel(service: string, handler: AdbIncomingSocketHandler): void;
|
|
45
70
|
removeReverseTunnel(address: string): void;
|
|
46
71
|
clearReverseTunnels(): void;
|
|
47
|
-
sendPacket(command: AdbCommand, arg0: number, arg1: number, payload
|
|
72
|
+
sendPacket(command: AdbCommand, arg0: number, arg1: number, payload: string | Uint8Array): Promise<void>;
|
|
48
73
|
close(): Promise<void>;
|
|
49
74
|
}
|
|
50
75
|
//# sourceMappingURL=dispatcher.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatcher.d.ts","sourceRoot":"","sources":["../../src/daemon/dispatcher.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dispatcher.d.ts","sourceRoot":"","sources":["../../src/daemon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