@yume-chan/adb 0.0.12 → 0.0.15
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 +28 -1
- package/README.md +24 -17
- package/esm/adb.d.ts +10 -9
- package/esm/adb.d.ts.map +1 -1
- package/esm/adb.js +88 -67
- package/esm/adb.js.map +1 -1
- package/esm/auth.d.ts +6 -6
- package/esm/auth.d.ts.map +1 -1
- package/esm/auth.js +8 -6
- package/esm/auth.js.map +1 -1
- package/esm/backend.d.ts +2 -2
- package/esm/commands/install.d.ts.map +1 -1
- package/esm/commands/install.js +5 -7
- package/esm/commands/install.js.map +1 -1
- package/esm/commands/reverse.d.ts +9 -12
- package/esm/commands/reverse.d.ts.map +1 -1
- package/esm/commands/reverse.js +44 -36
- package/esm/commands/reverse.js.map +1 -1
- package/esm/commands/subprocess/index.d.ts +19 -20
- package/esm/commands/subprocess/index.d.ts.map +1 -1
- package/esm/commands/subprocess/index.js +36 -31
- package/esm/commands/subprocess/index.js.map +1 -1
- package/esm/commands/subprocess/legacy.d.ts +14 -7
- package/esm/commands/subprocess/legacy.d.ts.map +1 -1
- package/esm/commands/subprocess/legacy.js +14 -5
- package/esm/commands/subprocess/legacy.js.map +1 -1
- package/esm/commands/subprocess/protocol.d.ts +3 -2
- package/esm/commands/subprocess/protocol.d.ts.map +1 -1
- package/esm/commands/subprocess/protocol.js +6 -4
- package/esm/commands/subprocess/protocol.js.map +1 -1
- package/esm/commands/subprocess/protocols/index.d.ts +4 -0
- package/esm/commands/subprocess/protocols/index.d.ts.map +1 -0
- package/esm/commands/subprocess/protocols/index.js +4 -0
- package/esm/commands/subprocess/protocols/index.js.map +1 -0
- package/esm/commands/subprocess/protocols/none.d.ts +35 -0
- package/esm/commands/subprocess/protocols/none.d.ts.map +1 -0
- package/esm/commands/subprocess/protocols/none.js +53 -0
- package/esm/commands/subprocess/protocols/none.js.map +1 -0
- package/esm/commands/subprocess/protocols/shell.d.ts +39 -0
- package/esm/commands/subprocess/protocols/shell.d.ts.map +1 -0
- package/esm/commands/subprocess/protocols/shell.js +155 -0
- package/esm/commands/subprocess/protocols/shell.js.map +1 -0
- package/esm/commands/subprocess/protocols/types.d.ts +50 -0
- package/esm/commands/subprocess/protocols/types.d.ts.map +1 -0
- package/esm/commands/subprocess/protocols/types.js +2 -0
- package/esm/commands/subprocess/protocols/types.js.map +1 -0
- package/esm/commands/subprocess/types.d.ts +9 -6
- package/esm/commands/subprocess/types.d.ts.map +1 -1
- package/esm/commands/sync/list.d.ts +25 -1
- package/esm/commands/sync/list.d.ts.map +1 -1
- package/esm/commands/sync/list.js +40 -5
- package/esm/commands/sync/list.js.map +1 -1
- package/esm/commands/sync/pull.d.ts.map +1 -1
- package/esm/commands/sync/pull.js +6 -3
- package/esm/commands/sync/pull.js.map +1 -1
- package/esm/commands/sync/request.d.ts +1 -0
- package/esm/commands/sync/request.d.ts.map +1 -1
- package/esm/commands/sync/request.js +1 -0
- package/esm/commands/sync/request.js.map +1 -1
- package/esm/commands/sync/response.d.ts +2 -1
- package/esm/commands/sync/response.d.ts.map +1 -1
- package/esm/commands/sync/response.js +2 -1
- package/esm/commands/sync/response.js.map +1 -1
- package/esm/commands/sync/stat.d.ts +13 -1
- package/esm/commands/sync/stat.d.ts.map +1 -1
- package/esm/commands/sync/stat.js +22 -9
- package/esm/commands/sync/stat.js.map +1 -1
- package/esm/commands/sync/sync.d.ts +13 -35
- package/esm/commands/sync/sync.d.ts.map +1 -1
- package/esm/commands/sync/sync.js +40 -10
- package/esm/commands/sync/sync.js.map +1 -1
- package/esm/crypto.d.ts +23 -10
- package/esm/crypto.d.ts.map +1 -1
- package/esm/crypto.js +64 -46
- package/esm/crypto.js.map +1 -1
- package/esm/features.d.ts +4 -2
- package/esm/features.d.ts.map +1 -1
- package/esm/features.js +6 -2
- package/esm/features.js.map +1 -1
- package/esm/packet.d.ts +21 -2
- package/esm/packet.d.ts.map +1 -1
- package/esm/packet.js +2 -2
- package/esm/packet.js.map +1 -1
- package/esm/socket/dispatcher.d.ts +35 -23
- package/esm/socket/dispatcher.d.ts.map +1 -1
- package/esm/socket/dispatcher.js +97 -72
- package/esm/socket/dispatcher.js.map +1 -1
- package/esm/socket/socket.d.ts +29 -8
- package/esm/socket/socket.d.ts.map +1 -1
- package/esm/socket/socket.js +43 -29
- package/esm/socket/socket.js.map +1 -1
- package/esm/stream/buffered.d.ts +1 -1
- package/esm/stream/buffered.d.ts.map +1 -1
- package/esm/stream/buffered.js +2 -2
- package/esm/stream/buffered.js.map +1 -1
- package/esm/stream/detect.d.ts +1 -17
- package/esm/stream/detect.d.ts.map +1 -1
- package/esm/stream/detect.js +4 -5
- package/esm/stream/detect.js.map +1 -1
- package/esm/stream/detect.polyfill.d.ts +1 -1
- package/esm/stream/detect.polyfill.d.ts.map +1 -1
- package/esm/stream/detect.polyfill.js +4 -1
- package/esm/stream/detect.polyfill.js.map +1 -1
- package/esm/stream/transform.d.ts +39 -33
- package/esm/stream/transform.d.ts.map +1 -1
- package/esm/stream/transform.js +121 -100
- package/esm/stream/transform.js.map +1 -1
- package/esm/utils/base64.js +5 -5
- package/esm/utils/base64.js.map +1 -1
- package/esm/utils/encoding.d.ts.map +1 -1
- package/esm/utils/encoding.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/package.json +7 -7
- package/src/adb.ts +112 -86
- package/src/auth.ts +21 -18
- package/src/backend.ts +2 -2
- package/src/commands/install.ts +7 -9
- package/src/commands/reverse.ts +48 -44
- package/src/commands/subprocess/index.ts +57 -42
- package/src/commands/subprocess/protocols/index.ts +3 -0
- package/src/commands/subprocess/{legacy.ts → protocols/none.ts} +20 -10
- package/src/commands/subprocess/{protocol.ts → protocols/shell.ts} +22 -17
- package/src/commands/subprocess/{types.ts → protocols/types.ts} +13 -9
- package/src/commands/sync/list.ts +51 -5
- package/src/commands/sync/pull.ts +6 -3
- package/src/commands/sync/request.ts +1 -0
- package/src/commands/sync/response.ts +8 -2
- package/src/commands/sync/stat.ts +36 -9
- package/src/commands/sync/sync.ts +56 -20
- package/src/crypto.ts +72 -56
- package/src/features.ts +6 -2
- package/src/packet.ts +17 -6
- package/src/socket/dispatcher.ts +139 -91
- package/src/socket/socket.ts +76 -61
- package/src/stream/buffered.ts +2 -2
- package/src/stream/detect.polyfill.ts +5 -2
- package/src/stream/detect.ts +4 -24
- package/src/stream/transform.ts +144 -124
- package/src/utils/index.ts +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/src/utils/encoding.ts +0 -13
package/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yume-chan/adb",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.0.15",
|
|
6
|
+
"tag": "@yume-chan/adb_v0.0.15",
|
|
7
|
+
"date": "Mon, 02 May 2022 04:18:01 GMT",
|
|
8
|
+
"comments": {
|
|
9
|
+
"none": [
|
|
10
|
+
{
|
|
11
|
+
"comment": "Add support for old protocol of `reverse:forward` command before Android 8"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"comment": "Improve connection lifecycle handling"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"comment": "Update `reverse.add` to accept any string local address"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"comment": "Fix an issue where `reverse` commands doesn't parse error message correctly"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"version": "0.0.14",
|
|
27
|
+
"tag": "@yume-chan/adb_v0.0.14",
|
|
28
|
+
"date": "Sat, 30 Apr 2022 14:05:48 GMT",
|
|
29
|
+
"comments": {
|
|
30
|
+
"none": [
|
|
31
|
+
{
|
|
32
|
+
"comment": "Fix an issue where `subprocess.spawn` doesn't work on Android 6"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"comment": "Add an `Adb#close()` method to gracefully shutdown a connection"
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"version": "0.0.13",
|
|
42
|
+
"tag": "@yume-chan/adb_v0.0.13",
|
|
43
|
+
"date": "Thu, 28 Apr 2022 01:23:53 GMT",
|
|
44
|
+
"comments": {
|
|
45
|
+
"none": [
|
|
46
|
+
{
|
|
47
|
+
"comment": "Add support for raw shell mode"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"comment": "Add support for LIS2 command in Sync protocol"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"comment": "Add workaround for the push_mkdir issue in Android 9"
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
},
|
|
4
58
|
{
|
|
5
59
|
"version": "0.0.12",
|
|
6
60
|
"tag": "@yume-chan/adb_v0.0.12",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
# Change Log - @yume-chan/adb
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Mon, 02 May 2022 04:18:01 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 0.0.15
|
|
6
|
+
Mon, 02 May 2022 04:18:01 GMT
|
|
7
|
+
|
|
8
|
+
### Updates
|
|
9
|
+
|
|
10
|
+
- Add support for old protocol of `reverse:forward` command before Android 8
|
|
11
|
+
- Improve connection lifecycle handling
|
|
12
|
+
- Update `reverse.add` to accept any string local address
|
|
13
|
+
- Fix an issue where `reverse` commands doesn't parse error message correctly
|
|
14
|
+
|
|
15
|
+
## 0.0.14
|
|
16
|
+
Sat, 30 Apr 2022 14:05:48 GMT
|
|
17
|
+
|
|
18
|
+
### Updates
|
|
19
|
+
|
|
20
|
+
- Fix an issue where `subprocess.spawn` doesn't work on Android 6
|
|
21
|
+
- Add an `Adb#close()` method to gracefully shutdown a connection
|
|
22
|
+
|
|
23
|
+
## 0.0.13
|
|
24
|
+
Thu, 28 Apr 2022 01:23:53 GMT
|
|
25
|
+
|
|
26
|
+
### Updates
|
|
27
|
+
|
|
28
|
+
- Add support for raw shell mode
|
|
29
|
+
- Add support for LIS2 command in Sync protocol
|
|
30
|
+
- Add workaround for the push_mkdir issue in Android 9
|
|
4
31
|
|
|
5
32
|
## 0.0.12
|
|
6
33
|
Sun, 03 Apr 2022 11:18:47 GMT
|
package/README.md
CHANGED
|
@@ -18,9 +18,10 @@ TypeScript implementation of Android Debug Bridge (ADB) protocol.
|
|
|
18
18
|
- [AdbAuthenticator](#adbauthenticator)
|
|
19
19
|
- [`authenticate`](#authenticate)
|
|
20
20
|
- [Stream multiplex](#stream-multiplex)
|
|
21
|
-
- [Backend](#backend-1)
|
|
22
21
|
- [Commands](#commands)
|
|
23
|
-
- [
|
|
22
|
+
- [subprocess](#subprocess)
|
|
23
|
+
- [raw mode](#raw-mode)
|
|
24
|
+
- [pty mode](#pty-mode)
|
|
24
25
|
- [usb](#usb)
|
|
25
26
|
- [tcpip](#tcpip)
|
|
26
27
|
- [sync](#sync)
|
|
@@ -48,10 +49,9 @@ Each backend may have different requirements.
|
|
|
48
49
|
| | Chrome | Edge | Firefox | Internet Explorer | Safari | Node.js |
|
|
49
50
|
| ------------------------------- | ------ | ---- | ------- | ----------------- | ------ | ------------------- |
|
|
50
51
|
| `@yume-chan/struct`<sup>1</sup> | 67 | 79 | 68 | No | 14 | 8.3<sup>2</sup>, 11 |
|
|
51
|
-
| [Streams][MDN_Streams] | 67 | 79 | No | No | 14.1 | 16.5 |
|
|
52
52
|
| *Overall* | 67 | 79 | No | No | 14.1 | 16.5 |
|
|
53
53
|
|
|
54
|
-
<sup>1</sup> `uint64` and `string` used.
|
|
54
|
+
<sup>1</sup> `uint64` and `string` are used.
|
|
55
55
|
|
|
56
56
|
<sup>2</sup> `TextEncoder` and `TextDecoder` are only available in `util` module. Need to be assigned to `globalThis`.
|
|
57
57
|
|
|
@@ -61,8 +61,6 @@ Each backend may have different requirements.
|
|
|
61
61
|
| --------------- | ------ | ---- | ------- | ----------------- | ------ | ------- |
|
|
62
62
|
| Top-level await | 89 | 89 | 89 | No | 15 | 14.8 |
|
|
63
63
|
|
|
64
|
-
[MDN_Streams]: https://developer.mozilla.org/en-US/docs/Web/API/Streams_API
|
|
65
|
-
|
|
66
64
|
## Connection
|
|
67
65
|
|
|
68
66
|
This library doesn't tie to a specific transportation method.
|
|
@@ -79,7 +77,7 @@ connect(): ValueOrPromise<ReadableWritablePair<AdbPacketCore, AdbPacketInit>>
|
|
|
79
77
|
|
|
80
78
|
Connect to a device and create a pair of `AdbPacket` streams.
|
|
81
79
|
|
|
82
|
-
The backend is responsible for serializing and deserializing the packets
|
|
80
|
+
The backend, instead of the core library, is responsible for serializing and deserializing the packets. Because it's extreme slow for WebUSB backend (`@yume-chan/adb-backend-webusb`) to read packets with unknown size.
|
|
83
81
|
|
|
84
82
|
## Authentication
|
|
85
83
|
|
|
@@ -133,7 +131,7 @@ static async authenticate(
|
|
|
133
131
|
|
|
134
132
|
Call this method to authenticate the connection and create an `Adb` instance.
|
|
135
133
|
|
|
136
|
-
|
|
134
|
+
If an authentication process failed, it's possible to call `authenticate` again on the same connection (`AdbPacket` stream pair). Every time the device receives a `CNXN` packet, it resets all internal state, and starts a new authentication process.
|
|
137
135
|
|
|
138
136
|
## Stream multiplex
|
|
139
137
|
|
|
@@ -144,27 +142,36 @@ ADB commands are all based on streams. Multiple streams can send and receive at
|
|
|
144
142
|
3. Client and server read/write on the stream.
|
|
145
143
|
4. Client/server sends a `CLSE` to close the stream.
|
|
146
144
|
|
|
147
|
-
|
|
145
|
+
## Commands
|
|
148
146
|
|
|
149
|
-
###
|
|
147
|
+
### subprocess
|
|
150
148
|
|
|
151
|
-
|
|
149
|
+
ADB has two subprocess invocation modes and two data protocols (4 combinations).
|
|
152
150
|
|
|
153
|
-
|
|
151
|
+
#### raw mode
|
|
154
152
|
|
|
155
|
-
|
|
153
|
+
In raw mode, Shell protocol transfers `stdout` and `stderr` separately. It also supports returning exit code.
|
|
156
154
|
|
|
157
|
-
| | Legacy
|
|
155
|
+
| | Legacy protocol | Shell Protocol |
|
|
158
156
|
| --------------------------- | --------------------------- | ---------------------------- |
|
|
159
157
|
| Feature flag | - | `shell_v2` |
|
|
160
158
|
| Implementation | `AdbNoneSubprocessProtocol` | `AdbShellSubprocessProtocol` |
|
|
161
159
|
| Splitting stdout and stderr | No | Yes |
|
|
162
160
|
| Returning exit code | No | Yes |
|
|
163
|
-
| Resizing window | No | Yes |
|
|
164
161
|
|
|
165
|
-
|
|
162
|
+
Use `spawn` method to create a subprocess in raw mode.
|
|
163
|
+
|
|
164
|
+
#### pty mode
|
|
165
|
+
|
|
166
|
+
In PTY mode, the subprocess has a pseudo-terminal, so it can send special control sequences like clear screen and set cursor position. The two protocols both send data in `stdout`, but Shell Protocol also supports resizing the terminal from client.
|
|
167
|
+
|
|
168
|
+
| | Legacy protocol | Shell Protocol |
|
|
169
|
+
| --------------------------- | --------------------------- | ---------------------------- |
|
|
170
|
+
| Feature flag | - | `shell_v2` |
|
|
171
|
+
| Implementation | `AdbNoneSubprocessProtocol` | `AdbShellSubprocessProtocol` |
|
|
172
|
+
| Resizing window | No | Yes |
|
|
166
173
|
|
|
167
|
-
|
|
174
|
+
Use `shell` method to create a subprocess in PTY mode.
|
|
168
175
|
|
|
169
176
|
### usb
|
|
170
177
|
|
package/esm/adb.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type AdbCredentialStore } from './auth.js';
|
|
2
2
|
import { AdbPower, AdbReverseCommand, AdbSubprocess, AdbSync, AdbTcpIpCommand, type AdbFrameBuffer } from './commands/index.js';
|
|
3
3
|
import { AdbFeatures } from './features.js';
|
|
4
|
-
import { type
|
|
5
|
-
import { AdbSocket } from './socket/index.js';
|
|
4
|
+
import { type AdbPacketData, type AdbPacketInit } from './packet.js';
|
|
5
|
+
import { AdbIncomingSocketHandler, type AdbSocket, type Closeable } from './socket/index.js';
|
|
6
6
|
import { WritableStream, type ReadableWritablePair } from "./stream/index.js";
|
|
7
7
|
export declare enum AdbPropKey {
|
|
8
8
|
Product = "ro.product.name",
|
|
@@ -11,14 +11,14 @@ export declare enum AdbPropKey {
|
|
|
11
11
|
Features = "features"
|
|
12
12
|
}
|
|
13
13
|
export declare const VERSION_OMIT_CHECKSUM = 16777217;
|
|
14
|
-
export declare class Adb {
|
|
14
|
+
export declare class Adb implements Closeable {
|
|
15
15
|
/**
|
|
16
16
|
* It's possible to call `authenticate` multiple times on a single connection,
|
|
17
17
|
* every time the device receives a `CNXN` packet, it resets its internal state,
|
|
18
18
|
* and starts a new authentication process.
|
|
19
19
|
*/
|
|
20
|
-
static authenticate(connection: ReadableWritablePair<
|
|
21
|
-
private readonly
|
|
20
|
+
static authenticate(connection: ReadableWritablePair<AdbPacketData, AdbPacketInit>, credentialStore: AdbCredentialStore, authenticators?: import("./auth.js").AdbAuthenticator[]): Promise<Adb>;
|
|
21
|
+
private readonly dispatcher;
|
|
22
22
|
get disconnected(): Promise<void>;
|
|
23
23
|
private _protocolVersion;
|
|
24
24
|
get protocolVersion(): number | undefined;
|
|
@@ -34,15 +34,16 @@ export declare class Adb {
|
|
|
34
34
|
readonly power: AdbPower;
|
|
35
35
|
readonly reverse: AdbReverseCommand;
|
|
36
36
|
readonly tcpip: AdbTcpIpCommand;
|
|
37
|
-
constructor(connection: ReadableWritablePair<
|
|
37
|
+
constructor(connection: ReadableWritablePair<AdbPacketData, AdbPacketInit>, version: number, maxPayloadSize: number, banner: string);
|
|
38
38
|
private parseBanner;
|
|
39
|
+
addIncomingSocketHandler(handler: AdbIncomingSocketHandler): import("@yume-chan/event").RemoveEventListener;
|
|
40
|
+
createSocket(service: string): Promise<AdbSocket>;
|
|
41
|
+
createSocketAndWait(service: string): Promise<string>;
|
|
39
42
|
getProp(key: string): Promise<string>;
|
|
40
43
|
rm(...filenames: string[]): Promise<string>;
|
|
41
44
|
install(): WritableStream<Uint8Array>;
|
|
42
45
|
sync(): Promise<AdbSync>;
|
|
43
46
|
framebuffer(): Promise<AdbFrameBuffer>;
|
|
44
|
-
|
|
45
|
-
createSocketAndWait(service: string): Promise<string>;
|
|
46
|
-
dispose(): Promise<void>;
|
|
47
|
+
close(): Promise<void>;
|
|
47
48
|
}
|
|
48
49
|
//# sourceMappingURL=adb.d.ts.map
|
package/esm/adb.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adb.d.ts","sourceRoot":"","sources":["../src/adb.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"adb.d.ts","sourceRoot":"","sources":["../src/adb.ts"],"names":[],"mappings":"AAGA,OAAO,EAA0D,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC5G,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,EAAmC,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACjK,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAiC,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AACpG,OAAO,EAAE,wBAAwB,EAAuB,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAClH,OAAO,EAAyD,cAAc,EAAE,KAAK,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAGrI,oBAAY,UAAU;IAClB,OAAO,oBAAoB;IAC3B,KAAK,qBAAqB;IAC1B,MAAM,sBAAsB;IAC5B,QAAQ,aAAa;CACxB;AAED,eAAO,MAAM,qBAAqB,WAAa,CAAC;AAEhD,qBAAa,GAAI,YAAW,SAAS;IACjC;;;;OAIG;WACiB,YAAY,CAC5B,UAAU,EAAE,oBAAoB,CAAC,aAAa,EAAE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C,IAAI,CAAC;CAGtC"}
|
package/esm/adb.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
// cspell: ignore libusb
|
|
1
2
|
import { PromiseResolver } from '@yume-chan/async';
|
|
2
|
-
import {
|
|
3
|
+
import { AdbAuthenticationProcessor, ADB_DEFAULT_AUTHENTICATORS } from './auth.js';
|
|
3
4
|
import { AdbPower, AdbReverseCommand, AdbSubprocess, AdbSync, AdbTcpIpCommand, escapeArg, framebuffer, install } from './commands/index.js';
|
|
4
5
|
import { AdbFeatures } from './features.js';
|
|
5
6
|
import { AdbCommand, calculateChecksum } from './packet.js';
|
|
@@ -20,29 +21,14 @@ export class Adb {
|
|
|
20
21
|
* every time the device receives a `CNXN` packet, it resets its internal state,
|
|
21
22
|
* and starts a new authentication process.
|
|
22
23
|
*/
|
|
23
|
-
static async authenticate(connection, credentialStore, authenticators =
|
|
24
|
+
static async authenticate(connection, credentialStore, authenticators = ADB_DEFAULT_AUTHENTICATORS) {
|
|
25
|
+
// Initially, set to highest-supported version and payload size.
|
|
24
26
|
let version = 0x01000001;
|
|
25
27
|
let maxPayloadSize = 0x100000;
|
|
26
|
-
const features = [
|
|
27
|
-
'shell_v2',
|
|
28
|
-
'cmd',
|
|
29
|
-
AdbFeatures.StatV2,
|
|
30
|
-
'ls_v2',
|
|
31
|
-
'fixed_push_mkdir',
|
|
32
|
-
'apex',
|
|
33
|
-
'abb',
|
|
34
|
-
'fixed_push_symlink_timestamp',
|
|
35
|
-
'abb_exec',
|
|
36
|
-
'remount_shell',
|
|
37
|
-
'track_app',
|
|
38
|
-
'sendrecv_v2',
|
|
39
|
-
'sendrecv_v2_brotli',
|
|
40
|
-
'sendrecv_v2_lz4',
|
|
41
|
-
'sendrecv_v2_zstd',
|
|
42
|
-
'sendrecv_v2_dry_run_send',
|
|
43
|
-
].join(',');
|
|
44
28
|
const resolver = new PromiseResolver();
|
|
45
|
-
const
|
|
29
|
+
const authProcessor = new AdbAuthenticationProcessor(authenticators, credentialStore);
|
|
30
|
+
// Here is similar to `AdbPacketDispatcher`,
|
|
31
|
+
// But the received packet types and send packet processing are different.
|
|
46
32
|
const abortController = new AbortController();
|
|
47
33
|
const pipe = connection.readable
|
|
48
34
|
.pipeTo(new WritableStream({
|
|
@@ -54,52 +40,77 @@ export class Adb {
|
|
|
54
40
|
resolver.resolve(decodeUtf8(packet.payload));
|
|
55
41
|
break;
|
|
56
42
|
case AdbCommand.Auth:
|
|
57
|
-
const response = await
|
|
43
|
+
const response = await authProcessor.process(packet);
|
|
58
44
|
await sendPacket(response);
|
|
59
45
|
break;
|
|
60
|
-
case AdbCommand.Close:
|
|
61
|
-
// Last connection was interrupted
|
|
62
|
-
// Ignore this packet, device will recover
|
|
63
|
-
break;
|
|
64
46
|
default:
|
|
65
|
-
|
|
47
|
+
// Maybe the previous ADB client exited without reading all packets,
|
|
48
|
+
// so they are still waiting in OS internal buffer.
|
|
49
|
+
// Just ignore them.
|
|
50
|
+
// Because a `Connect` packet will reset the device,
|
|
51
|
+
// Eventually there will be `Connect` and `Auth` response packets.
|
|
52
|
+
break;
|
|
66
53
|
}
|
|
67
54
|
}
|
|
68
55
|
}), {
|
|
69
56
|
preventCancel: true,
|
|
70
57
|
signal: abortController.signal,
|
|
71
58
|
})
|
|
72
|
-
.catch((e) => {
|
|
59
|
+
.catch((e) => {
|
|
60
|
+
resolver.reject(e);
|
|
61
|
+
});
|
|
73
62
|
const writer = connection.writable.getWriter();
|
|
74
63
|
async function sendPacket(init) {
|
|
75
64
|
// Always send checksum in auth steps
|
|
76
|
-
// Because we don't know if the device
|
|
65
|
+
// Because we don't know if the device needs it or not.
|
|
77
66
|
await writer.write(calculateChecksum(init));
|
|
78
67
|
}
|
|
79
|
-
|
|
80
|
-
command: AdbCommand.Connect,
|
|
81
|
-
arg0: version,
|
|
82
|
-
arg1: maxPayloadSize,
|
|
83
|
-
// The terminating `;` is required in formal definition
|
|
84
|
-
// But ADB daemon (all versions) can still work without it
|
|
85
|
-
payload: encodeUtf8(`host::features=${features};`),
|
|
86
|
-
});
|
|
68
|
+
let banner;
|
|
87
69
|
try {
|
|
88
|
-
|
|
89
|
-
//
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
70
|
+
// https://android.googlesource.com/platform/packages/modules/adb/+/79010dc6d5ca7490c493df800d4421730f5466ca/transport.cpp#1252
|
|
71
|
+
// There are some other feature constants, but some of them are only used by ADB server, not devices (daemons).
|
|
72
|
+
const features = [
|
|
73
|
+
AdbFeatures.ShellV2,
|
|
74
|
+
AdbFeatures.Cmd,
|
|
75
|
+
AdbFeatures.StatV2,
|
|
76
|
+
AdbFeatures.ListV2,
|
|
77
|
+
AdbFeatures.FixedPushMkdir,
|
|
78
|
+
'apex',
|
|
79
|
+
'abb',
|
|
80
|
+
// only tells the client the symlink timestamp issue in `adb push --sync` has been fixed.
|
|
81
|
+
// No special handling required.
|
|
82
|
+
'fixed_push_symlink_timestamp',
|
|
83
|
+
'abb_exec',
|
|
84
|
+
'remount_shell',
|
|
85
|
+
'track_app',
|
|
86
|
+
'sendrecv_v2',
|
|
87
|
+
'sendrecv_v2_brotli',
|
|
88
|
+
'sendrecv_v2_lz4',
|
|
89
|
+
'sendrecv_v2_zstd',
|
|
90
|
+
'sendrecv_v2_dry_run_send',
|
|
91
|
+
].join(',');
|
|
92
|
+
await sendPacket({
|
|
93
|
+
command: AdbCommand.Connect,
|
|
94
|
+
arg0: version,
|
|
95
|
+
arg1: maxPayloadSize,
|
|
96
|
+
// The terminating `;` is required in formal definition
|
|
97
|
+
// But ADB daemon (all versions) can still work without it
|
|
98
|
+
payload: encodeUtf8(`host::features=${features};`),
|
|
99
|
+
});
|
|
100
|
+
banner = await resolver.promise;
|
|
95
101
|
}
|
|
96
102
|
finally {
|
|
103
|
+
// When failed, release locks on `connection` so the caller can try again.
|
|
104
|
+
// When success, also release locks so `AdbPacketDispatcher` can use them.
|
|
97
105
|
abortController.abort();
|
|
98
106
|
writer.releaseLock();
|
|
107
|
+
// Wait until pipe stops (`ReadableStream` lock released)
|
|
108
|
+
await pipe;
|
|
99
109
|
}
|
|
110
|
+
return new Adb(connection, version, maxPayloadSize, banner);
|
|
100
111
|
}
|
|
101
|
-
|
|
102
|
-
get disconnected() { return this.
|
|
112
|
+
dispatcher;
|
|
113
|
+
get disconnected() { return this.dispatcher.disconnected; }
|
|
103
114
|
_protocolVersion;
|
|
104
115
|
get protocolVersion() { return this._protocolVersion; }
|
|
105
116
|
_product;
|
|
@@ -116,18 +127,25 @@ export class Adb {
|
|
|
116
127
|
tcpip;
|
|
117
128
|
constructor(connection, version, maxPayloadSize, banner) {
|
|
118
129
|
this.parseBanner(banner);
|
|
119
|
-
|
|
120
|
-
|
|
130
|
+
let calculateChecksum;
|
|
131
|
+
let appendNullToServiceString;
|
|
121
132
|
if (version >= VERSION_OMIT_CHECKSUM) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
133
|
+
calculateChecksum = false;
|
|
134
|
+
appendNullToServiceString = false;
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
calculateChecksum = true;
|
|
138
|
+
appendNullToServiceString = true;
|
|
126
139
|
}
|
|
127
|
-
this.
|
|
140
|
+
this.dispatcher = new AdbPacketDispatcher(connection, {
|
|
141
|
+
calculateChecksum,
|
|
142
|
+
appendNullToServiceString,
|
|
143
|
+
maxPayloadSize,
|
|
144
|
+
});
|
|
145
|
+
this._protocolVersion = version;
|
|
128
146
|
this.subprocess = new AdbSubprocess(this);
|
|
129
147
|
this.power = new AdbPower(this);
|
|
130
|
-
this.reverse = new AdbReverseCommand(this
|
|
148
|
+
this.reverse = new AdbReverseCommand(this);
|
|
131
149
|
this.tcpip = new AdbTcpIpCommand(this);
|
|
132
150
|
}
|
|
133
151
|
parseBanner(banner) {
|
|
@@ -161,6 +179,20 @@ export class Adb {
|
|
|
161
179
|
}
|
|
162
180
|
}
|
|
163
181
|
}
|
|
182
|
+
addIncomingSocketHandler(handler) {
|
|
183
|
+
return this.dispatcher.addIncomingSocketHandler(handler);
|
|
184
|
+
}
|
|
185
|
+
async createSocket(service) {
|
|
186
|
+
return this.dispatcher.createSocket(service);
|
|
187
|
+
}
|
|
188
|
+
async createSocketAndWait(service) {
|
|
189
|
+
const socket = await this.createSocket(service);
|
|
190
|
+
const gatherStream = new GatherStringStream();
|
|
191
|
+
await socket.readable
|
|
192
|
+
.pipeThrough(new DecodeUtf8Stream())
|
|
193
|
+
.pipeTo(gatherStream);
|
|
194
|
+
return gatherStream.result;
|
|
195
|
+
}
|
|
164
196
|
async getProp(key) {
|
|
165
197
|
const stdout = await this.subprocess.spawnAndWaitLegacy(['getprop', key]);
|
|
166
198
|
return stdout.trim();
|
|
@@ -179,19 +211,8 @@ export class Adb {
|
|
|
179
211
|
async framebuffer() {
|
|
180
212
|
return framebuffer(this);
|
|
181
213
|
}
|
|
182
|
-
async
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
async createSocketAndWait(service) {
|
|
186
|
-
const socket = await this.createSocket(service);
|
|
187
|
-
const gatherStream = new GatherStringStream();
|
|
188
|
-
await socket.readable
|
|
189
|
-
.pipeThrough(new DecodeUtf8Stream())
|
|
190
|
-
.pipeTo(gatherStream.writable);
|
|
191
|
-
return gatherStream.result;
|
|
192
|
-
}
|
|
193
|
-
async dispose() {
|
|
194
|
-
this.packetDispatcher.dispose();
|
|
214
|
+
async close() {
|
|
215
|
+
await this.dispatcher.close();
|
|
195
216
|
}
|
|
196
217
|
}
|
|
197
218
|
//# sourceMappingURL=adb.js.map
|
package/esm/adb.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adb.js","sourceRoot":"","sources":["../src/adb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"adb.js","sourceRoot":"","sources":["../src/adb.ts"],"names":[],"mappings":"AA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E,CAAC;QAC9C,MAAM,MAAM,CAAC,QAAQ;aAChB,WAAW,CAAC,IAAI,gBAAgB,EAAE,CAAC;aACnC,MAAM,CAAC,YAAY,CAAC,CAAC;QAC1B,OAAO,YAAY,CAAC,MAAM,CAAC;IAC/B,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,GAAW;QAC5B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,kBAAkB,CACnD,CAAC,SAAS,EAAE,GAAG,CAAC,CACnB,CAAC;QACF,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC;IAEM,KAAK,CAAC,EAAE,CAAC,GAAG,SAAmB;QAClC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,kBAAkB,CACnD,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CACzD,CAAC;QACF,OAAO,MAAM,CAAC;IAClB,CAAC;IAEM,OAAO;QACV,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAEM,KAAK,CAAC,IAAI;QACb,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAChD,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACrC,CAAC;IAEM,KAAK,CAAC,WAAW;QACpB,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAEM,KAAK,CAAC,KAAK;QACd,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IAClC,CAAC;CACJ"}
|
package/esm/auth.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Disposable } from '@yume-chan/event';
|
|
2
2
|
import type { ValueOrPromise } from '@yume-chan/struct';
|
|
3
|
-
import {
|
|
3
|
+
import { type AdbPacketData } from './packet.js';
|
|
4
4
|
export declare type AdbKeyIterable = Iterable<Uint8Array> | AsyncIterable<Uint8Array>;
|
|
5
5
|
export interface AdbCredentialStore {
|
|
6
6
|
/**
|
|
@@ -33,20 +33,20 @@ export interface AdbAuthenticator {
|
|
|
33
33
|
*
|
|
34
34
|
* Calling `getNextRequest` multiple times without `yield` or `return` will always return the same request.
|
|
35
35
|
*/
|
|
36
|
-
(credentialStore: AdbCredentialStore, getNextRequest: () => Promise<
|
|
36
|
+
(credentialStore: AdbCredentialStore, getNextRequest: () => Promise<AdbPacketData>): AsyncIterable<AdbPacketData>;
|
|
37
37
|
}
|
|
38
38
|
export declare const AdbSignatureAuthenticator: AdbAuthenticator;
|
|
39
39
|
export declare const AdbPublicKeyAuthenticator: AdbAuthenticator;
|
|
40
|
-
export declare const
|
|
41
|
-
export declare class
|
|
40
|
+
export declare const ADB_DEFAULT_AUTHENTICATORS: AdbAuthenticator[];
|
|
41
|
+
export declare class AdbAuthenticationProcessor implements Disposable {
|
|
42
42
|
readonly authenticators: readonly AdbAuthenticator[];
|
|
43
43
|
private readonly credentialStore;
|
|
44
44
|
private pendingRequest;
|
|
45
45
|
private iterator;
|
|
46
46
|
constructor(authenticators: readonly AdbAuthenticator[], credentialStore: AdbCredentialStore);
|
|
47
47
|
private getNextRequest;
|
|
48
|
-
private
|
|
49
|
-
|
|
48
|
+
private invokeAuthenticator;
|
|
49
|
+
process(packet: AdbPacketData): Promise<AdbPacketData>;
|
|
50
50
|
dispose(): void;
|
|
51
51
|
}
|
|
52
52
|
//# sourceMappingURL=auth.d.ts.map
|
package/esm/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAc,
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AC,aAAa,CAAC;IAe5D,OAAO;CAGjB"}
|
package/esm/auth.js
CHANGED
|
@@ -50,11 +50,11 @@ export const AdbPublicKeyAuthenticator = async function* (credentialStore, getNe
|
|
|
50
50
|
payload: publicKeyBuffer,
|
|
51
51
|
};
|
|
52
52
|
};
|
|
53
|
-
export const
|
|
53
|
+
export const ADB_DEFAULT_AUTHENTICATORS = [
|
|
54
54
|
AdbSignatureAuthenticator,
|
|
55
55
|
AdbPublicKeyAuthenticator,
|
|
56
56
|
];
|
|
57
|
-
export class
|
|
57
|
+
export class AdbAuthenticationProcessor {
|
|
58
58
|
authenticators;
|
|
59
59
|
credentialStore;
|
|
60
60
|
pendingRequest = new PromiseResolver();
|
|
@@ -66,7 +66,7 @@ export class AdbAuthenticationHandler {
|
|
|
66
66
|
getNextRequest = () => {
|
|
67
67
|
return this.pendingRequest.promise;
|
|
68
68
|
};
|
|
69
|
-
async *
|
|
69
|
+
async *invokeAuthenticator() {
|
|
70
70
|
for (const authenticator of this.authenticators) {
|
|
71
71
|
for await (const packet of authenticator(this.credentialStore, this.getNextRequest)) {
|
|
72
72
|
// If the authenticator yielded a response
|
|
@@ -78,14 +78,16 @@ export class AdbAuthenticationHandler {
|
|
|
78
78
|
// If the authenticator returned,
|
|
79
79
|
// Next authenticator will be given the same `pendingRequest`
|
|
80
80
|
}
|
|
81
|
-
throw new Error('Cannot authenticate with device');
|
|
82
81
|
}
|
|
83
|
-
async
|
|
82
|
+
async process(packet) {
|
|
84
83
|
if (!this.iterator) {
|
|
85
|
-
this.iterator = this.
|
|
84
|
+
this.iterator = this.invokeAuthenticator();
|
|
86
85
|
}
|
|
87
86
|
this.pendingRequest.resolve(packet);
|
|
88
87
|
const result = await this.iterator.next();
|
|
88
|
+
if (result.done) {
|
|
89
|
+
throw new Error('No authenticator can handle the request');
|
|
90
|
+
}
|
|
89
91
|
return result.value;
|
|
90
92
|
}
|
|
91
93
|
dispose() {
|
package/esm/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGnD,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGnD,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,UAAU,EAAsB,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,4BAA4B,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAoB9E,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,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;QAC5C,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,CA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bPacketInit } from "./packet.js";
|
|
3
3
|
import type { ReadableWritablePair } from "./stream/index.js";
|
|
4
4
|
export interface AdbBackend {
|
|
5
5
|
readonly serial: string;
|
|
6
6
|
readonly name: string | undefined;
|
|
7
|
-
connect(): ValueOrPromise<ReadableWritablePair<
|
|
7
|
+
connect(): ValueOrPromise<ReadableWritablePair<AdbPacketData, AdbPacketInit>>;
|
|
8
8
|
}
|
|
9
9
|
//# sourceMappingURL=backend.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/commands/install.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAsB,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAIxE,wBAAgB,OAAO,CACnB,GAAG,EAAE,GAAG,GACT,cAAc,CAAC,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/commands/install.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAsB,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAIxE,wBAAgB,OAAO,CACnB,GAAG,EAAE,GAAG,GACT,cAAc,CAAC,UAAU,CAAC,CAsB5B"}
|