@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,150 +1,124 @@
|
|
|
1
|
-
import { AutoDisposable } from "@yume-chan/event";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*
|
|
12
|
-
* @
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
constructor(adb, socket) {
|
|
48
|
-
super();
|
|
49
|
-
this.
|
|
50
|
-
this.
|
|
51
|
-
this
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
this.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
*
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
write(filename, mode, mtime) {
|
|
125
|
-
return new WrapWritableStream({
|
|
126
|
-
start: async () => {
|
|
127
|
-
await this.sendLock.wait();
|
|
128
|
-
if (this.needPushMkdirWorkaround) {
|
|
129
|
-
// It may fail if the path is already existed.
|
|
130
|
-
// Ignore the result.
|
|
131
|
-
// TODO: sync: test push mkdir workaround (need an Android 8 device)
|
|
132
|
-
await this.adb.subprocess.spawnAndWait([
|
|
133
|
-
"mkdir",
|
|
134
|
-
"-p",
|
|
135
|
-
escapeArg(dirname(filename)),
|
|
136
|
-
]);
|
|
137
|
-
}
|
|
138
|
-
return adbSyncPush(this.stream, this.writer, filename, mode, mtime);
|
|
139
|
-
},
|
|
140
|
-
close: () => {
|
|
141
|
-
this.sendLock.notify();
|
|
142
|
-
},
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
async dispose() {
|
|
146
|
-
super.dispose();
|
|
147
|
-
await this.writer.close();
|
|
148
|
-
}
|
|
149
|
-
}
|
|
1
|
+
import { AutoDisposable } from "@yume-chan/event";
|
|
2
|
+
import { AdbFeature } from "../../features.js";
|
|
3
|
+
import { escapeArg } from "../subprocess/index.js";
|
|
4
|
+
import { adbSyncOpenDir } from "./list.js";
|
|
5
|
+
import { adbSyncPull } from "./pull.js";
|
|
6
|
+
import { adbSyncPush } from "./push.js";
|
|
7
|
+
import { AdbSyncSocket } from "./socket.js";
|
|
8
|
+
import { adbSyncLstat, adbSyncStat } from "./stat.js";
|
|
9
|
+
/**
|
|
10
|
+
* A simplified `dirname` function that only handles absolute unix paths.
|
|
11
|
+
* @param path an absolute unix path
|
|
12
|
+
* @returns the directory name of the input path
|
|
13
|
+
*/
|
|
14
|
+
export function dirname(path) {
|
|
15
|
+
const end = path.lastIndexOf("/");
|
|
16
|
+
if (end === -1) {
|
|
17
|
+
throw new Error(`Invalid path`);
|
|
18
|
+
}
|
|
19
|
+
if (end === 0) {
|
|
20
|
+
return "/";
|
|
21
|
+
}
|
|
22
|
+
return path.substring(0, end);
|
|
23
|
+
}
|
|
24
|
+
export class AdbSync extends AutoDisposable {
|
|
25
|
+
_adb;
|
|
26
|
+
_socket;
|
|
27
|
+
#supportsStat;
|
|
28
|
+
#supportsListV2;
|
|
29
|
+
#fixedPushMkdir;
|
|
30
|
+
#supportsSendReceiveV2;
|
|
31
|
+
#needPushMkdirWorkaround;
|
|
32
|
+
get supportsStat() {
|
|
33
|
+
return this.#supportsStat;
|
|
34
|
+
}
|
|
35
|
+
get supportsListV2() {
|
|
36
|
+
return this.#supportsListV2;
|
|
37
|
+
}
|
|
38
|
+
get fixedPushMkdir() {
|
|
39
|
+
return this.#fixedPushMkdir;
|
|
40
|
+
}
|
|
41
|
+
get supportsSendReceiveV2() {
|
|
42
|
+
return this.#supportsSendReceiveV2;
|
|
43
|
+
}
|
|
44
|
+
get needPushMkdirWorkaround() {
|
|
45
|
+
return this.#needPushMkdirWorkaround;
|
|
46
|
+
}
|
|
47
|
+
constructor(adb, socket) {
|
|
48
|
+
super();
|
|
49
|
+
this._adb = adb;
|
|
50
|
+
this._socket = new AdbSyncSocket(socket, adb.maxPayloadSize);
|
|
51
|
+
this.#supportsStat = adb.supportsFeature(AdbFeature.StatV2);
|
|
52
|
+
this.#supportsListV2 = adb.supportsFeature(AdbFeature.ListV2);
|
|
53
|
+
this.#fixedPushMkdir = adb.supportsFeature(AdbFeature.FixedPushMkdir);
|
|
54
|
+
this.#supportsSendReceiveV2 = adb.supportsFeature(AdbFeature.SendReceiveV2);
|
|
55
|
+
// https://android.googlesource.com/platform/packages/modules/adb/+/91768a57b7138166e0a3d11f79cd55909dda7014/client/file_sync_client.cpp#1361
|
|
56
|
+
this.#needPushMkdirWorkaround =
|
|
57
|
+
this._adb.supportsFeature(AdbFeature.ShellV2) &&
|
|
58
|
+
!this.fixedPushMkdir;
|
|
59
|
+
}
|
|
60
|
+
async lstat(path) {
|
|
61
|
+
return await adbSyncLstat(this._socket, path, this.supportsStat);
|
|
62
|
+
}
|
|
63
|
+
async stat(path) {
|
|
64
|
+
if (!this.supportsStat) {
|
|
65
|
+
throw new Error("Not supported");
|
|
66
|
+
}
|
|
67
|
+
return await adbSyncStat(this._socket, path);
|
|
68
|
+
}
|
|
69
|
+
async isDirectory(path) {
|
|
70
|
+
try {
|
|
71
|
+
await this.lstat(path + "/");
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
opendir(path) {
|
|
79
|
+
return adbSyncOpenDir(this._socket, path, this.supportsListV2);
|
|
80
|
+
}
|
|
81
|
+
async readdir(path) {
|
|
82
|
+
const results = [];
|
|
83
|
+
for await (const entry of this.opendir(path)) {
|
|
84
|
+
results.push(entry);
|
|
85
|
+
}
|
|
86
|
+
return results;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Reads the content of a file on device.
|
|
90
|
+
*
|
|
91
|
+
* @param filename The full path of the file on device to read.
|
|
92
|
+
* @returns A `ReadableStream` that contains the file content.
|
|
93
|
+
*/
|
|
94
|
+
read(filename) {
|
|
95
|
+
return adbSyncPull(this._socket, filename);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Writes a file on device. If the file name already exists, it will be overwritten.
|
|
99
|
+
*
|
|
100
|
+
* @param options The content and options of the file to write.
|
|
101
|
+
*/
|
|
102
|
+
async write(options) {
|
|
103
|
+
if (this.needPushMkdirWorkaround) {
|
|
104
|
+
// It may fail if the path is already existed.
|
|
105
|
+
// Ignore the result.
|
|
106
|
+
// TODO: sync: test push mkdir workaround (need an Android 8 device)
|
|
107
|
+
await this._adb.subprocess.spawnAndWait([
|
|
108
|
+
"mkdir",
|
|
109
|
+
"-p",
|
|
110
|
+
escapeArg(dirname(options.filename)),
|
|
111
|
+
]);
|
|
112
|
+
}
|
|
113
|
+
await adbSyncPush({
|
|
114
|
+
v2: this.supportsSendReceiveV2,
|
|
115
|
+
socket: this._socket,
|
|
116
|
+
...options,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
async dispose() {
|
|
120
|
+
super.dispose();
|
|
121
|
+
await this._socket.close();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
150
124
|
//# sourceMappingURL=sync.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../../src/commands/sync/sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../../src/commands/sync/sync.ts"],"names":[],"mappings":"AAA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from
|
|
2
|
-
export declare class AdbTcpIpCommand extends AdbCommandBase {
|
|
3
|
-
setPort(port: number): Promise<
|
|
4
|
-
disable(): Promise<
|
|
5
|
-
}
|
|
1
|
+
import { AdbCommandBase } from "./base.js";
|
|
2
|
+
export declare class AdbTcpIpCommand extends AdbCommandBase {
|
|
3
|
+
setPort(port: number): Promise<string>;
|
|
4
|
+
disable(): Promise<string>;
|
|
5
|
+
}
|
|
6
6
|
//# sourceMappingURL=tcpip.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tcpip.d.ts","sourceRoot":"","sources":["../../src/commands/tcpip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,qBAAa,eAAgB,SAAQ,cAAc;IAClC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"tcpip.d.ts","sourceRoot":"","sources":["../../src/commands/tcpip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,qBAAa,eAAgB,SAAQ,cAAc;IAClC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAYtC,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;CAO1C"}
|
package/esm/commands/tcpip.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import { AdbCommandBase } from
|
|
2
|
-
export class AdbTcpIpCommand extends AdbCommandBase {
|
|
3
|
-
async setPort(port) {
|
|
4
|
-
if (port <= 0) {
|
|
5
|
-
throw new Error(`Invalid port ${port}`);
|
|
6
|
-
}
|
|
7
|
-
const output = await this.adb.createSocketAndWait(`tcpip:${port}`);
|
|
8
|
-
if (output !== `restarting in TCP mode port: ${port}\n`) {
|
|
9
|
-
throw new Error(
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import { AdbCommandBase } from "./base.js";
|
|
2
|
+
export class AdbTcpIpCommand extends AdbCommandBase {
|
|
3
|
+
async setPort(port) {
|
|
4
|
+
if (port <= 0) {
|
|
5
|
+
throw new Error(`Invalid port ${port}`);
|
|
6
|
+
}
|
|
7
|
+
const output = await this.adb.createSocketAndWait(`tcpip:${port}`);
|
|
8
|
+
if (output !== `restarting in TCP mode port: ${port}\n`) {
|
|
9
|
+
throw new Error(output);
|
|
10
|
+
}
|
|
11
|
+
return output;
|
|
12
|
+
}
|
|
13
|
+
async disable() {
|
|
14
|
+
const output = await this.adb.createSocketAndWait("usb:");
|
|
15
|
+
if (output !== "restarting in USB mode\n") {
|
|
16
|
+
throw new Error(output);
|
|
17
|
+
}
|
|
18
|
+
return output;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
19
21
|
//# sourceMappingURL=tcpip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tcpip.js","sourceRoot":"","sources":["../../src/commands/tcpip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,OAAO,eAAgB,SAAQ,cAAc;IACxC,KAAK,CAAC,OAAO,CAAC,IAAY;QAC7B,IAAI,IAAI,IAAI,CAAC,EAAE;YACX,MAAM,IAAI,KAAK,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC;SAC3C;QAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;QACnE,IAAI,MAAM,KAAK,gCAAgC,IAAI,IAAI,EAAE;YACrD,MAAM,IAAI,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"tcpip.js","sourceRoot":"","sources":["../../src/commands/tcpip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,OAAO,eAAgB,SAAQ,cAAc;IACxC,KAAK,CAAC,OAAO,CAAC,IAAY;QAC7B,IAAI,IAAI,IAAI,CAAC,EAAE;YACX,MAAM,IAAI,KAAK,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC;SAC3C;QAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;QACnE,IAAI,MAAM,KAAK,gCAAgC,IAAI,IAAI,EAAE;YACrD,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;SAC3B;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IAEM,KAAK,CAAC,OAAO;QAChB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;QAC1D,IAAI,MAAM,KAAK,0BAA0B,EAAE;YACvC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;SAC3B;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ"}
|
|
@@ -1,52 +1,51 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export type AdbKeyIterable = Iterable<Uint8Array> | AsyncIterable<Uint8Array>;
|
|
5
|
-
export interface AdbCredentialStore {
|
|
6
|
-
/**
|
|
7
|
-
* Generate and store a RSA private key with modulus length `2048` and public exponent `65537`.
|
|
8
|
-
*
|
|
9
|
-
* The returned `Uint8Array` is the private key in PKCS #8 format.
|
|
10
|
-
*/
|
|
11
|
-
generateKey(): ValueOrPromise<Uint8Array>;
|
|
12
|
-
/**
|
|
13
|
-
* Synchronously or asynchronously iterate through all stored RSA private keys.
|
|
14
|
-
*
|
|
15
|
-
* Each call to `iterateKeys` must return a different iterator that iterate through all stored keys.
|
|
16
|
-
*/
|
|
17
|
-
iterateKeys(): AdbKeyIterable;
|
|
18
|
-
}
|
|
19
|
-
export declare enum AdbAuthType {
|
|
20
|
-
Token = 1,
|
|
21
|
-
Signature = 2,
|
|
22
|
-
PublicKey = 3
|
|
23
|
-
}
|
|
24
|
-
export interface AdbAuthenticator {
|
|
25
|
-
/**
|
|
26
|
-
* @param getNextRequest
|
|
27
|
-
*
|
|
28
|
-
* Call this function to get the next authentication request packet from device.
|
|
29
|
-
*
|
|
30
|
-
* After calling `getNextRequest`, authenticator can `yield` a packet as response, or `return` to indicate its incapability of handling the request.
|
|
31
|
-
*
|
|
32
|
-
* After `return`, the `AdbAuthenticatorHandler` will move on to next authenticator and never go back.
|
|
33
|
-
*
|
|
34
|
-
* Calling `getNextRequest` multiple times without `yield` or `return` will always return the same request.
|
|
35
|
-
*/
|
|
36
|
-
(credentialStore: AdbCredentialStore, getNextRequest: () => Promise<AdbPacketData>): AsyncIterable<AdbPacketData>;
|
|
37
|
-
}
|
|
38
|
-
export declare const AdbSignatureAuthenticator: AdbAuthenticator;
|
|
39
|
-
export declare const AdbPublicKeyAuthenticator: AdbAuthenticator;
|
|
40
|
-
export declare const ADB_DEFAULT_AUTHENTICATORS: AdbAuthenticator[];
|
|
41
|
-
export declare class AdbAuthenticationProcessor implements Disposable {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
private
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
private
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
1
|
+
import type { Disposable } from "@yume-chan/event";
|
|
2
|
+
import type { ValueOrPromise } from "@yume-chan/struct";
|
|
3
|
+
import type { AdbPacketData } from "./packet.js";
|
|
4
|
+
export type AdbKeyIterable = Iterable<Uint8Array> | AsyncIterable<Uint8Array>;
|
|
5
|
+
export interface AdbCredentialStore {
|
|
6
|
+
/**
|
|
7
|
+
* Generate and store a RSA private key with modulus length `2048` and public exponent `65537`.
|
|
8
|
+
*
|
|
9
|
+
* The returned `Uint8Array` is the private key in PKCS #8 format.
|
|
10
|
+
*/
|
|
11
|
+
generateKey(): ValueOrPromise<Uint8Array>;
|
|
12
|
+
/**
|
|
13
|
+
* Synchronously or asynchronously iterate through all stored RSA private keys.
|
|
14
|
+
*
|
|
15
|
+
* Each call to `iterateKeys` must return a different iterator that iterate through all stored keys.
|
|
16
|
+
*/
|
|
17
|
+
iterateKeys(): AdbKeyIterable;
|
|
18
|
+
}
|
|
19
|
+
export declare enum AdbAuthType {
|
|
20
|
+
Token = 1,
|
|
21
|
+
Signature = 2,
|
|
22
|
+
PublicKey = 3
|
|
23
|
+
}
|
|
24
|
+
export interface AdbAuthenticator {
|
|
25
|
+
/**
|
|
26
|
+
* @param getNextRequest
|
|
27
|
+
*
|
|
28
|
+
* Call this function to get the next authentication request packet from device.
|
|
29
|
+
*
|
|
30
|
+
* After calling `getNextRequest`, authenticator can `yield` a packet as response, or `return` to indicate its incapability of handling the request.
|
|
31
|
+
*
|
|
32
|
+
* After `return`, the `AdbAuthenticatorHandler` will move on to next authenticator and never go back.
|
|
33
|
+
*
|
|
34
|
+
* Calling `getNextRequest` multiple times without `yield` or `return` will always return the same request.
|
|
35
|
+
*/
|
|
36
|
+
(credentialStore: AdbCredentialStore, getNextRequest: () => Promise<AdbPacketData>): AsyncIterable<AdbPacketData>;
|
|
37
|
+
}
|
|
38
|
+
export declare const AdbSignatureAuthenticator: AdbAuthenticator;
|
|
39
|
+
export declare const AdbPublicKeyAuthenticator: AdbAuthenticator;
|
|
40
|
+
export declare const ADB_DEFAULT_AUTHENTICATORS: AdbAuthenticator[];
|
|
41
|
+
export declare class AdbAuthenticationProcessor implements Disposable {
|
|
42
|
+
#private;
|
|
43
|
+
readonly authenticators: readonly AdbAuthenticator[];
|
|
44
|
+
private readonly credentialStore;
|
|
45
|
+
constructor(authenticators: readonly AdbAuthenticator[], credentialStore: AdbCredentialStore);
|
|
46
|
+
private getNextRequest;
|
|
47
|
+
private invokeAuthenticator;
|
|
48
|
+
process(packet: AdbPacketData): Promise<AdbPacketData>;
|
|
49
|
+
dispose(): void;
|
|
50
|
+
}
|
|
52
51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