@yume-chan/adb 0.0.18 → 0.0.20
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.json +54 -0
- package/CHANGELOG.md +25 -1
- package/README.md +220 -103
- package/esm/adb.d.ts +43 -60
- package/esm/adb.d.ts.map +1 -1
- package/esm/adb.js +68 -249
- package/esm/adb.js.map +1 -1
- package/esm/banner.d.ts +17 -0
- package/esm/banner.d.ts.map +1 -0
- package/esm/banner.js +67 -0
- package/esm/banner.js.map +1 -0
- package/esm/commands/base.d.ts +6 -6
- package/esm/commands/base.d.ts.map +1 -1
- package/esm/commands/base.js +8 -8
- package/esm/commands/framebuffer.d.ts +53 -53
- package/esm/commands/framebuffer.d.ts.map +1 -1
- package/esm/commands/framebuffer.js +46 -46
- package/esm/commands/framebuffer.js.map +1 -1
- package/esm/commands/index.d.ts +7 -8
- package/esm/commands/index.d.ts.map +1 -1
- package/esm/commands/index.js +7 -8
- package/esm/commands/index.js.map +1 -1
- package/esm/commands/power.d.ts +22 -22
- package/esm/commands/power.js +48 -48
- package/esm/commands/reverse.d.ts +40 -28
- package/esm/commands/reverse.d.ts.map +1 -1
- package/esm/commands/reverse.js +130 -100
- package/esm/commands/reverse.js.map +1 -1
- package/esm/commands/subprocess/command.d.ts +57 -51
- package/esm/commands/subprocess/command.d.ts.map +1 -1
- package/esm/commands/subprocess/command.js +86 -80
- package/esm/commands/subprocess/command.js.map +1 -1
- package/esm/commands/subprocess/index.d.ts +3 -3
- package/esm/commands/subprocess/index.js +3 -3
- package/esm/commands/subprocess/protocols/index.d.ts +3 -3
- package/esm/commands/subprocess/protocols/index.js +3 -3
- package/esm/commands/subprocess/protocols/none.d.ts +30 -35
- package/esm/commands/subprocess/protocols/none.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/none.js +65 -55
- package/esm/commands/subprocess/protocols/none.js.map +1 -1
- package/esm/commands/subprocess/protocols/shell.d.ts +33 -38
- package/esm/commands/subprocess/protocols/shell.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/shell.js +172 -162
- package/esm/commands/subprocess/protocols/shell.js.map +1 -1
- package/esm/commands/subprocess/protocols/types.d.ts +48 -49
- package/esm/commands/subprocess/protocols/types.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/types.js +1 -1
- package/esm/commands/subprocess/utils.d.ts +1 -1
- package/esm/commands/subprocess/utils.js +18 -18
- package/esm/commands/sync/index.d.ts +8 -7
- package/esm/commands/sync/index.d.ts.map +1 -1
- package/esm/commands/sync/index.js +8 -7
- package/esm/commands/sync/index.js.map +1 -1
- package/esm/commands/sync/list.d.ts +42 -40
- package/esm/commands/sync/list.d.ts.map +1 -1
- package/esm/commands/sync/list.js +67 -47
- package/esm/commands/sync/list.js.map +1 -1
- package/esm/commands/sync/pull.d.ts +13 -11
- package/esm/commands/sync/pull.d.ts.map +1 -1
- package/esm/commands/sync/pull.js +35 -37
- package/esm/commands/sync/pull.js.map +1 -1
- package/esm/commands/sync/push.d.ts +57 -7
- package/esm/commands/sync/push.d.ts.map +1 -1
- package/esm/commands/sync/push.js +89 -22
- package/esm/commands/sync/push.js.map +1 -1
- package/esm/commands/sync/request.d.ts +26 -23
- package/esm/commands/sync/request.d.ts.map +1 -1
- package/esm/commands/sync/request.js +40 -42
- package/esm/commands/sync/request.js.map +1 -1
- package/esm/commands/sync/response.d.ts +19 -19
- package/esm/commands/sync/response.d.ts.map +1 -1
- package/esm/commands/sync/response.js +54 -54
- package/esm/commands/sync/response.js.map +1 -1
- package/esm/commands/sync/socket.d.ts +22 -0
- package/esm/commands/sync/socket.d.ts.map +1 -0
- package/esm/commands/sync/socket.js +69 -0
- package/esm/commands/sync/socket.js.map +1 -0
- package/esm/commands/sync/stat.d.ts +72 -72
- package/esm/commands/sync/stat.d.ts.map +1 -1
- package/esm/commands/sync/stat.js +116 -104
- package/esm/commands/sync/stat.js.map +1 -1
- package/esm/commands/sync/sync.d.ts +65 -60
- package/esm/commands/sync/sync.d.ts.map +1 -1
- package/esm/commands/sync/sync.js +123 -149
- package/esm/commands/sync/sync.js.map +1 -1
- package/esm/commands/tcpip.d.ts +5 -5
- package/esm/commands/tcpip.d.ts.map +1 -1
- package/esm/commands/tcpip.js +20 -18
- package/esm/commands/tcpip.js.map +1 -1
- package/esm/{auth.d.ts → daemon/auth.d.ts} +50 -51
- package/esm/daemon/auth.d.ts.map +1 -0
- package/esm/{auth.js → daemon/auth.js} +95 -96
- package/esm/daemon/auth.js.map +1 -0
- package/esm/daemon/connection.d.ts +11 -0
- package/esm/daemon/connection.d.ts.map +1 -0
- package/esm/daemon/connection.js +2 -0
- package/esm/daemon/connection.js.map +1 -0
- package/esm/{crypto.d.ts → daemon/crypto.d.ts} +36 -36
- package/esm/daemon/crypto.d.ts.map +1 -0
- package/esm/{crypto.js → daemon/crypto.js} +244 -248
- package/esm/daemon/crypto.js.map +1 -0
- package/esm/daemon/device.d.ts +9 -0
- package/esm/daemon/device.d.ts.map +1 -0
- package/esm/daemon/device.js +2 -0
- package/esm/daemon/device.js.map +1 -0
- package/esm/daemon/dispatcher.d.ts +42 -0
- package/esm/daemon/dispatcher.d.ts.map +1 -0
- package/esm/{socket → daemon}/dispatcher.js +225 -234
- package/esm/daemon/dispatcher.js.map +1 -0
- package/esm/daemon/index.d.ts +8 -0
- package/esm/daemon/index.d.ts.map +1 -0
- package/esm/daemon/index.js +8 -0
- package/esm/daemon/index.js.map +1 -0
- package/esm/{packet.d.ts → daemon/packet.d.ts} +45 -46
- package/esm/daemon/packet.d.ts.map +1 -0
- package/esm/{packet.js → daemon/packet.js} +43 -48
- package/esm/daemon/packet.js.map +1 -0
- package/esm/daemon/socket.d.ts +58 -0
- package/esm/daemon/socket.d.ts.map +1 -0
- package/esm/{socket → daemon}/socket.js +121 -118
- package/esm/daemon/socket.js.map +1 -0
- package/esm/daemon/transport.d.ts +45 -0
- package/esm/daemon/transport.d.ts.map +1 -0
- package/esm/daemon/transport.js +184 -0
- package/esm/daemon/transport.js.map +1 -0
- package/esm/features.d.ts +10 -7
- package/esm/features.d.ts.map +1 -1
- package/esm/features.js +13 -10
- package/esm/features.js.map +1 -1
- package/esm/index.d.ts +7 -9
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +7 -9
- package/esm/index.js.map +1 -1
- package/esm/server/client.d.ts +78 -0
- package/esm/server/client.d.ts.map +1 -0
- package/esm/server/client.js +329 -0
- package/esm/server/client.js.map +1 -0
- package/esm/server/index.d.ts +3 -0
- package/esm/server/index.d.ts.map +1 -0
- package/esm/server/index.js +3 -0
- package/esm/server/index.js.map +1 -0
- package/esm/server/transport.d.ts +19 -0
- package/esm/server/transport.d.ts.map +1 -0
- package/esm/server/transport.js +44 -0
- package/esm/server/transport.js.map +1 -0
- package/esm/utils/auto-reset-event.d.ts +8 -9
- package/esm/utils/auto-reset-event.d.ts.map +1 -1
- package/esm/utils/auto-reset-event.js +33 -33
- package/esm/utils/auto-reset-event.js.map +1 -1
- package/esm/utils/base64.d.ts +27 -27
- package/esm/utils/base64.js +246 -246
- package/esm/utils/base64.js.map +1 -1
- package/esm/utils/conditional-variable.d.ts +8 -0
- package/esm/utils/conditional-variable.d.ts.map +1 -0
- package/esm/utils/conditional-variable.js +34 -0
- package/esm/utils/conditional-variable.js.map +1 -0
- package/esm/utils/hex.d.ts +3 -0
- package/esm/utils/hex.d.ts.map +1 -0
- package/esm/utils/hex.js +55 -0
- package/esm/utils/hex.js.map +1 -0
- package/esm/utils/index.d.ts +6 -3
- package/esm/utils/index.d.ts.map +1 -1
- package/esm/utils/index.js +6 -3
- package/esm/utils/index.js.map +1 -1
- package/esm/utils/no-op.d.ts +7 -0
- package/esm/utils/no-op.d.ts.map +1 -0
- package/esm/utils/no-op.js +12 -0
- package/esm/utils/no-op.js.map +1 -0
- package/package.json +14 -12
- package/src/adb.ts +47 -248
- package/src/banner.ts +82 -0
- package/src/commands/base.ts +1 -1
- package/src/commands/framebuffer.ts +4 -4
- package/src/commands/index.ts +7 -8
- package/src/commands/power.ts +2 -2
- package/src/commands/reverse.ts +90 -70
- package/src/commands/subprocess/command.ts +12 -4
- package/src/commands/subprocess/index.ts +3 -3
- package/src/commands/subprocess/protocols/index.ts +3 -3
- package/src/commands/subprocess/protocols/none.ts +36 -23
- package/src/commands/subprocess/protocols/shell.ts +94 -74
- package/src/commands/subprocess/protocols/types.ts +7 -7
- package/src/commands/subprocess/utils.ts +1 -1
- package/src/commands/sync/index.ts +8 -7
- package/src/commands/sync/list.ts +44 -25
- package/src/commands/sync/pull.ts +40 -45
- package/src/commands/sync/push.ts +158 -39
- package/src/commands/sync/request.ts +21 -16
- package/src/commands/sync/response.ts +10 -9
- package/src/commands/sync/socket.ts +99 -0
- package/src/commands/sync/stat.ts +47 -42
- package/src/commands/sync/sync.ts +73 -116
- package/src/commands/tcpip.ts +9 -7
- package/src/{auth.ts → daemon/auth.ts} +24 -23
- package/src/{crypto.ts → daemon/crypto.ts} +25 -33
- package/src/daemon/device.ts +14 -0
- package/src/{socket → daemon}/dispatcher.ts +95 -117
- package/src/daemon/index.ts +7 -0
- package/src/daemon/packet.ts +75 -0
- package/src/{socket → daemon}/socket.ts +71 -56
- package/src/daemon/transport.ts +269 -0
- package/src/features.ts +9 -6
- package/src/index.ts +3 -5
- package/src/server/client.ts +476 -0
- package/src/server/index.ts +2 -0
- package/src/server/transport.ts +77 -0
- package/src/utils/auto-reset-event.ts +14 -15
- package/src/utils/conditional-variable.ts +45 -0
- package/src/utils/hex.ts +58 -0
- package/src/utils/index.ts +6 -3
- package/src/utils/no-op.ts +12 -0
- package/tsconfig.build.json +12 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/esm/auth.d.ts.map +0 -1
- package/esm/auth.js.map +0 -1
- package/esm/backend.d.ts +0 -9
- package/esm/backend.d.ts.map +0 -1
- package/esm/backend.js +0 -2
- package/esm/backend.js.map +0 -1
- package/esm/commands/install.d.ts +0 -4
- package/esm/commands/install.d.ts.map +0 -1
- package/esm/commands/install.js +0 -29
- package/esm/commands/install.js.map +0 -1
- package/esm/crypto.d.ts.map +0 -1
- package/esm/crypto.js.map +0 -1
- package/esm/packet.d.ts.map +0 -1
- package/esm/packet.js.map +0 -1
- package/esm/socket/dispatcher.d.ts +0 -60
- package/esm/socket/dispatcher.d.ts.map +0 -1
- package/esm/socket/dispatcher.js.map +0 -1
- package/esm/socket/index.d.ts +0 -3
- package/esm/socket/index.d.ts.map +0 -1
- package/esm/socket/index.js +0 -3
- package/esm/socket/index.js.map +0 -1
- package/esm/socket/socket.d.ts +0 -60
- package/esm/socket/socket.d.ts.map +0 -1
- package/esm/socket/socket.js.map +0 -1
- package/src/backend.ts +0 -14
- package/src/commands/install.ts +0 -40
- package/src/packet.ts +0 -90
- package/src/socket/index.ts +0 -2
|
@@ -1,97 +1,96 @@
|
|
|
1
|
-
import { PromiseResolver } from "@yume-chan/async";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
export var AdbAuthType;
|
|
6
|
-
(function (AdbAuthType) {
|
|
7
|
-
AdbAuthType[AdbAuthType["Token"] = 1] = "Token";
|
|
8
|
-
AdbAuthType[AdbAuthType["Signature"] = 2] = "Signature";
|
|
9
|
-
AdbAuthType[AdbAuthType["PublicKey"] = 3] = "PublicKey";
|
|
10
|
-
})(AdbAuthType = AdbAuthType || (AdbAuthType = {}));
|
|
11
|
-
export const AdbSignatureAuthenticator = async function* (credentialStore, getNextRequest) {
|
|
12
|
-
for await (const key of credentialStore.iterateKeys()) {
|
|
13
|
-
const packet = await getNextRequest();
|
|
14
|
-
if (packet.arg0 !== AdbAuthType.Token) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const signature =
|
|
18
|
-
yield {
|
|
19
|
-
command: AdbCommand.Auth,
|
|
20
|
-
arg0: AdbAuthType.Signature,
|
|
21
|
-
arg1: 0,
|
|
22
|
-
payload: new Uint8Array(signature),
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
export const AdbPublicKeyAuthenticator = async function* (credentialStore, getNextRequest) {
|
|
27
|
-
const packet = await getNextRequest();
|
|
28
|
-
if (packet.arg0 !== AdbAuthType.Token) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
let privateKey;
|
|
32
|
-
for await (const key of credentialStore.iterateKeys()) {
|
|
33
|
-
privateKey = key;
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
if (!privateKey) {
|
|
37
|
-
privateKey = await credentialStore.generateKey();
|
|
38
|
-
}
|
|
39
|
-
const publicKeyLength =
|
|
40
|
-
const [publicKeyBase64Length] = calculateBase64EncodedLength(publicKeyLength);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
this.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
//
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
//
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
this.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
1
|
+
import { PromiseResolver } from "@yume-chan/async";
|
|
2
|
+
import { calculateBase64EncodedLength, encodeBase64 } from "../utils/index.js";
|
|
3
|
+
import { adbGeneratePublicKey, adbGetPublicKeySize, rsaSign, } from "./crypto.js";
|
|
4
|
+
import { AdbCommand } from "./packet.js";
|
|
5
|
+
export var AdbAuthType;
|
|
6
|
+
(function (AdbAuthType) {
|
|
7
|
+
AdbAuthType[AdbAuthType["Token"] = 1] = "Token";
|
|
8
|
+
AdbAuthType[AdbAuthType["Signature"] = 2] = "Signature";
|
|
9
|
+
AdbAuthType[AdbAuthType["PublicKey"] = 3] = "PublicKey";
|
|
10
|
+
})(AdbAuthType = AdbAuthType || (AdbAuthType = {}));
|
|
11
|
+
export const AdbSignatureAuthenticator = async function* (credentialStore, getNextRequest) {
|
|
12
|
+
for await (const key of credentialStore.iterateKeys()) {
|
|
13
|
+
const packet = await getNextRequest();
|
|
14
|
+
if (packet.arg0 !== AdbAuthType.Token) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const signature = rsaSign(key, packet.payload);
|
|
18
|
+
yield {
|
|
19
|
+
command: AdbCommand.Auth,
|
|
20
|
+
arg0: AdbAuthType.Signature,
|
|
21
|
+
arg1: 0,
|
|
22
|
+
payload: new Uint8Array(signature),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
export const AdbPublicKeyAuthenticator = async function* (credentialStore, getNextRequest) {
|
|
27
|
+
const packet = await getNextRequest();
|
|
28
|
+
if (packet.arg0 !== AdbAuthType.Token) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
let privateKey;
|
|
32
|
+
for await (const key of credentialStore.iterateKeys()) {
|
|
33
|
+
privateKey = key;
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
if (!privateKey) {
|
|
37
|
+
privateKey = await credentialStore.generateKey();
|
|
38
|
+
}
|
|
39
|
+
const publicKeyLength = adbGetPublicKeySize();
|
|
40
|
+
const [publicKeyBase64Length] = calculateBase64EncodedLength(publicKeyLength);
|
|
41
|
+
const publicKeyBuffer = new Uint8Array(publicKeyBase64Length + 1 // Null character
|
|
42
|
+
);
|
|
43
|
+
adbGeneratePublicKey(privateKey, publicKeyBuffer);
|
|
44
|
+
encodeBase64(publicKeyBuffer.subarray(0, publicKeyLength), publicKeyBuffer);
|
|
45
|
+
yield {
|
|
46
|
+
command: AdbCommand.Auth,
|
|
47
|
+
arg0: AdbAuthType.PublicKey,
|
|
48
|
+
arg1: 0,
|
|
49
|
+
payload: publicKeyBuffer,
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
export const ADB_DEFAULT_AUTHENTICATORS = [
|
|
53
|
+
AdbSignatureAuthenticator,
|
|
54
|
+
AdbPublicKeyAuthenticator,
|
|
55
|
+
];
|
|
56
|
+
export class AdbAuthenticationProcessor {
|
|
57
|
+
authenticators;
|
|
58
|
+
credentialStore;
|
|
59
|
+
#pendingRequest = new PromiseResolver();
|
|
60
|
+
#iterator;
|
|
61
|
+
constructor(authenticators, credentialStore) {
|
|
62
|
+
this.authenticators = authenticators;
|
|
63
|
+
this.credentialStore = credentialStore;
|
|
64
|
+
}
|
|
65
|
+
getNextRequest = () => {
|
|
66
|
+
return this.#pendingRequest.promise;
|
|
67
|
+
};
|
|
68
|
+
async *invokeAuthenticator() {
|
|
69
|
+
for (const authenticator of this.authenticators) {
|
|
70
|
+
for await (const packet of authenticator(this.credentialStore, this.getNextRequest)) {
|
|
71
|
+
// If the authenticator yielded a response
|
|
72
|
+
// Prepare `nextRequest` for next authentication request
|
|
73
|
+
this.#pendingRequest = new PromiseResolver();
|
|
74
|
+
// Yield the response to outer layer
|
|
75
|
+
yield packet;
|
|
76
|
+
}
|
|
77
|
+
// If the authenticator returned,
|
|
78
|
+
// Next authenticator will be given the same `pendingRequest`
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async process(packet) {
|
|
82
|
+
if (!this.#iterator) {
|
|
83
|
+
this.#iterator = this.invokeAuthenticator();
|
|
84
|
+
}
|
|
85
|
+
this.#pendingRequest.resolve(packet);
|
|
86
|
+
const result = await this.#iterator.next();
|
|
87
|
+
if (result.done) {
|
|
88
|
+
throw new Error("No authenticator can handle the request");
|
|
89
|
+
}
|
|
90
|
+
return result.value;
|
|
91
|
+
}
|
|
92
|
+
dispose() {
|
|
93
|
+
void this.#iterator?.return?.();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
97
96
|
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/daemon/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAInD,OAAO,EAAE,4BAA4B,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE/E,OAAO,EACH,oBAAoB,EACpB,mBAAmB,EACnB,OAAO,GACV,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAoBzC,MAAM,CAAN,IAAY,WAIX;AAJD,WAAY,WAAW;IACnB,+CAAS,CAAA;IACT,uDAAa,CAAA;IACb,uDAAa,CAAA;AACjB,CAAC,EAJW,WAAW,GAAX,WAAW,KAAX,WAAW,QAItB;AAoBD,MAAM,CAAC,MAAM,yBAAyB,GAAqB,KAAK,SAAS,CAAC,EACtE,eAAmC,EACnC,cAA4C;IAE5C,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,eAAe,CAAC,WAAW,EAAE,EAAE;QACnD,MAAM,MAAM,GAAG,MAAM,cAAc,EAAE,CAAC;QAEtC,IAAI,MAAM,CAAC,IAAI,KAAK,WAAW,CAAC,KAAK,EAAE;YACnC,OAAO;SACV;QAED,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;QAC/C,MAAM;YACF,OAAO,EAAE,UAAU,CAAC,IAAI;YACxB,IAAI,EAAE,WAAW,CAAC,SAAS;YAC3B,IAAI,EAAE,CAAC;YACP,OAAO,EAAE,IAAI,UAAU,CAAC,SAAS,CAAC;SACrC,CAAC;KACL;AACL,CAAC,CAAC;AAEF,MAA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QACrC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IAC3C,CAAC;IAEO,cAAc,GAAG,GAA2B,EAAE;QAClD,OAAO,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC;IACxC,CAAC,CAAC;IAEM,KAAK,CAAC,CAAC,mBAAmB;QAK9B,KAAK,MAAM,aAAa,IAAI,IAAI,CAAC,cAAc,EAAE;YAC7C,IAAI,KAAK,EAAE,MAAM,MAAM,IAAI,aAAa,CACpC,IAAI,CAAC,eAAe,EACpB,IAAI,CAAC,cAAc,CACtB,EAAE;gBACC,0CAA0C;gBAC1C,wDAAwD;gBACxD,IAAI,CAAC,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;gBAE7C,oCAAoC;gBACpC,MAAM,MAAM,CAAC;aAChB;YAED,iCAAiC;YACjC,6DAA6D;SAChE;IACL,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,MAAqB;QACtC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACjB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;SAC/C;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;YACb,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;SAC9D;QAED,OAAO,MAAM,CAAC,KAAK,CAAC;IACxB,CAAC;IAEM,OAAO;QACV,KAAK,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC;IACpC,CAAC;CACJ"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Consumable, ReadableWritablePair } from "@yume-chan/stream-extra";
|
|
2
|
+
import type { ValueOrPromise } from "@yume-chan/struct";
|
|
3
|
+
import type { AdbPacketData, AdbPacketInit } from "../../src/daemon/packet.js";
|
|
4
|
+
export interface AdbDaemonDevice {
|
|
5
|
+
readonly serial: string;
|
|
6
|
+
readonly name: string | undefined;
|
|
7
|
+
connect(): ValueOrPromise<
|
|
8
|
+
ReadableWritablePair<AdbPacketData, Consumable<AdbPacketInit>>
|
|
9
|
+
>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=connection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/daemon/connection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,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,cAAc,CACrB,oBAAoB,CAAC,aAAa,EAAE,UAAU,CAAC,aAAa,CAAC,CAAC,CACjE,CAAC;CACL"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/daemon/connection.ts"],"names":[],"mappings":""}
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Gets the `BigInt` value at the specified byte offset and length from the start of the view. There is
|
|
3
|
-
* no alignment constraint; multi-byte values may be fetched from any offset.
|
|
4
|
-
*
|
|
5
|
-
* Only supports Big-Endian, because that's what ADB uses.
|
|
6
|
-
* @param byteOffset The place in the buffer at which the value should be retrieved.
|
|
7
|
-
*/
|
|
8
|
-
export declare function getBigUint(dataView: DataView, byteOffset: number, length: number): bigint;
|
|
9
|
-
/**
|
|
10
|
-
* Stores an arbitrary-precision positive `BigInt` value at the specified byte offset from the start of the view.
|
|
11
|
-
* @param byteOffset The place in the buffer at which the value should be set.
|
|
12
|
-
* @param value The value to set.
|
|
13
|
-
* @param littleEndian If `false` or `undefined`, a big-endian value should be written,
|
|
14
|
-
* otherwise a little-endian value should be written.
|
|
15
|
-
*/
|
|
16
|
-
export declare function setBigUint(dataView: DataView, byteOffset: number, value: bigint, littleEndian?: boolean): number;
|
|
17
|
-
export declare function
|
|
18
|
-
export declare function modInverse(a: number, m: number): number;
|
|
19
|
-
export declare function
|
|
20
|
-
export declare function
|
|
21
|
-
export declare function
|
|
22
|
-
/**
|
|
23
|
-
* Modular exponentiation.
|
|
24
|
-
*
|
|
25
|
-
* Calculate `(base ** exponent) % modulus` without actually calculating `(base ** exponent)`.
|
|
26
|
-
*
|
|
27
|
-
* See https://en.wikipedia.org/wiki/Modular_exponentiation#Implementation_in_Lua
|
|
28
|
-
*/
|
|
29
|
-
export declare function powMod(base: bigint, exponent: bigint, modulus: bigint): bigint;
|
|
30
|
-
export declare const SHA1_DIGEST_LENGTH = 20;
|
|
31
|
-
export declare const ASN1_SEQUENCE = 48;
|
|
32
|
-
export declare const ASN1_OCTET_STRING = 4;
|
|
33
|
-
export declare const ASN1_NULL = 5;
|
|
34
|
-
export declare const ASN1_OID = 6;
|
|
35
|
-
export declare const SHA1_DIGEST_INFO: Uint8Array;
|
|
36
|
-
export declare function
|
|
1
|
+
/**
|
|
2
|
+
* Gets the `BigInt` value at the specified byte offset and length from the start of the view. There is
|
|
3
|
+
* no alignment constraint; multi-byte values may be fetched from any offset.
|
|
4
|
+
*
|
|
5
|
+
* Only supports Big-Endian, because that's what ADB uses.
|
|
6
|
+
* @param byteOffset The place in the buffer at which the value should be retrieved.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getBigUint(dataView: DataView, byteOffset: number, length: number): bigint;
|
|
9
|
+
/**
|
|
10
|
+
* Stores an arbitrary-precision positive `BigInt` value at the specified byte offset from the start of the view.
|
|
11
|
+
* @param byteOffset The place in the buffer at which the value should be set.
|
|
12
|
+
* @param value The value to set.
|
|
13
|
+
* @param littleEndian If `false` or `undefined`, a big-endian value should be written,
|
|
14
|
+
* otherwise a little-endian value should be written.
|
|
15
|
+
*/
|
|
16
|
+
export declare function setBigUint(dataView: DataView, byteOffset: number, value: bigint, littleEndian?: boolean): number;
|
|
17
|
+
export declare function rsaParsePrivateKey(key: Uint8Array): [n: bigint, d: bigint];
|
|
18
|
+
export declare function modInverse(a: number, m: number): number;
|
|
19
|
+
export declare function adbGetPublicKeySize(): number;
|
|
20
|
+
export declare function adbGeneratePublicKey(privateKey: Uint8Array): Uint8Array;
|
|
21
|
+
export declare function adbGeneratePublicKey(privateKey: Uint8Array, output: Uint8Array): number;
|
|
22
|
+
/**
|
|
23
|
+
* Modular exponentiation.
|
|
24
|
+
*
|
|
25
|
+
* Calculate `(base ** exponent) % modulus` without actually calculating `(base ** exponent)`.
|
|
26
|
+
*
|
|
27
|
+
* See https://en.wikipedia.org/wiki/Modular_exponentiation#Implementation_in_Lua
|
|
28
|
+
*/
|
|
29
|
+
export declare function powMod(base: bigint, exponent: bigint, modulus: bigint): bigint;
|
|
30
|
+
export declare const SHA1_DIGEST_LENGTH = 20;
|
|
31
|
+
export declare const ASN1_SEQUENCE = 48;
|
|
32
|
+
export declare const ASN1_OCTET_STRING = 4;
|
|
33
|
+
export declare const ASN1_NULL = 5;
|
|
34
|
+
export declare const ASN1_OID = 6;
|
|
35
|
+
export declare const SHA1_DIGEST_INFO: Uint8Array;
|
|
36
|
+
export declare function rsaSign(privateKey: Uint8Array, data: Uint8Array): Uint8Array;
|
|
37
37
|
//# sourceMappingURL=crypto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../src/daemon/crypto.ts"],"names":[],"mappings":"AAKA;;;;;;GAMG;AACH,wBAAgB,UAAU,CACtB,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GACf,MAAM,C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