@yume-chan/adb 0.0.15 → 0.0.17
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 +33 -0
- package/CHANGELOG.md +18 -1
- package/LICENSE +21 -21
- package/README.md +247 -247
- package/esm/adb.d.ts +15 -3
- package/esm/adb.d.ts.map +1 -1
- package/esm/adb.js +18 -6
- package/esm/adb.js.map +1 -1
- package/esm/auth.d.ts.map +1 -1
- package/esm/auth.js.map +1 -1
- package/esm/backend.d.ts +2 -2
- package/esm/backend.d.ts.map +1 -1
- package/esm/commands/base.d.ts.map +1 -1
- package/esm/commands/base.js.map +1 -1
- package/esm/commands/framebuffer.d.ts +17 -1
- package/esm/commands/framebuffer.d.ts.map +1 -1
- package/esm/commands/framebuffer.js +4 -15
- package/esm/commands/framebuffer.js.map +1 -1
- package/esm/commands/install.d.ts +2 -2
- package/esm/commands/install.d.ts.map +1 -1
- package/esm/commands/install.js +3 -2
- package/esm/commands/install.js.map +1 -1
- package/esm/commands/power.d.ts +1 -1
- package/esm/commands/power.js +1 -1
- package/esm/commands/reverse.d.ts +3 -3
- package/esm/commands/reverse.d.ts.map +1 -1
- package/esm/commands/reverse.js +9 -9
- package/esm/commands/reverse.js.map +1 -1
- package/esm/commands/subprocess/command.d.ts +52 -0
- package/esm/commands/subprocess/command.d.ts.map +1 -0
- package/esm/commands/subprocess/command.js +83 -0
- package/esm/commands/subprocess/command.js.map +1 -0
- package/esm/commands/subprocess/index.d.ts +1 -53
- package/esm/commands/subprocess/index.d.ts.map +1 -1
- package/esm/commands/subprocess/index.js +1 -85
- package/esm/commands/subprocess/index.js.map +1 -1
- package/esm/commands/subprocess/protocols/none.d.ts +5 -4
- package/esm/commands/subprocess/protocols/none.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/none.js +11 -8
- package/esm/commands/subprocess/protocols/none.js.map +1 -1
- package/esm/commands/subprocess/protocols/shell.d.ts +4 -4
- package/esm/commands/subprocess/protocols/shell.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/shell.js +6 -6
- package/esm/commands/subprocess/protocols/shell.js.map +1 -1
- package/esm/commands/subprocess/protocols/types.d.ts +7 -7
- package/esm/commands/subprocess/protocols/types.d.ts.map +1 -1
- package/esm/commands/sync/index.d.ts +1 -1
- package/esm/commands/sync/index.d.ts.map +1 -1
- package/esm/commands/sync/index.js +1 -1
- package/esm/commands/sync/index.js.map +1 -1
- package/esm/commands/sync/list.d.ts +2 -2
- package/esm/commands/sync/list.d.ts.map +1 -1
- package/esm/commands/sync/list.js +15 -43
- package/esm/commands/sync/list.js.map +1 -1
- package/esm/commands/sync/pull.d.ts +3 -2
- package/esm/commands/sync/pull.d.ts.map +1 -1
- package/esm/commands/sync/pull.js +15 -17
- package/esm/commands/sync/pull.js.map +1 -1
- package/esm/commands/sync/push.d.ts +2 -2
- package/esm/commands/sync/push.d.ts.map +1 -1
- package/esm/commands/sync/push.js +2 -5
- package/esm/commands/sync/push.js.map +1 -1
- package/esm/commands/sync/request.d.ts +1 -1
- package/esm/commands/sync/request.d.ts.map +1 -1
- package/esm/commands/sync/request.js +1 -1
- package/esm/commands/sync/request.js.map +1 -1
- package/esm/commands/sync/response.d.ts +4 -9
- package/esm/commands/sync/response.d.ts.map +1 -1
- package/esm/commands/sync/response.js +32 -23
- package/esm/commands/sync/response.js.map +1 -1
- package/esm/commands/sync/stat.d.ts +3 -3
- package/esm/commands/sync/stat.d.ts.map +1 -1
- package/esm/commands/sync/stat.js +13 -30
- package/esm/commands/sync/stat.js.map +1 -1
- package/esm/commands/sync/sync.d.ts +2 -2
- package/esm/commands/sync/sync.d.ts.map +1 -1
- package/esm/commands/sync/sync.js +7 -5
- package/esm/commands/sync/sync.js.map +1 -1
- package/esm/crypto.js +1 -1
- package/esm/crypto.js.map +1 -1
- package/esm/index.d.ts +0 -1
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +0 -1
- package/esm/index.js.map +1 -1
- package/esm/packet.d.ts +1 -1
- package/esm/packet.d.ts.map +1 -1
- package/esm/packet.js +1 -1
- package/esm/packet.js.map +1 -1
- package/esm/socket/dispatcher.d.ts +11 -3
- package/esm/socket/dispatcher.d.ts.map +1 -1
- package/esm/socket/dispatcher.js +19 -11
- package/esm/socket/dispatcher.js.map +1 -1
- package/esm/socket/index.d.ts +1 -1
- package/esm/socket/index.d.ts.map +1 -1
- package/esm/socket/index.js +1 -1
- package/esm/socket/index.js.map +1 -1
- package/esm/socket/socket.d.ts +9 -4
- package/esm/socket/socket.d.ts.map +1 -1
- package/esm/socket/socket.js +20 -10
- package/esm/socket/socket.js.map +1 -1
- package/esm/utils/base64.d.ts +23 -0
- package/esm/utils/base64.d.ts.map +1 -1
- package/esm/utils/base64.js +6 -0
- package/esm/utils/base64.js.map +1 -1
- package/package.json +13 -14
- package/src/adb.ts +285 -273
- package/src/auth.ts +174 -173
- package/src/backend.ts +12 -11
- package/src/commands/base.ts +12 -11
- package/src/commands/framebuffer.ts +78 -73
- package/src/commands/index.ts +8 -8
- package/src/commands/install.ts +32 -30
- package/src/commands/power.ts +54 -54
- package/src/commands/reverse.ts +141 -140
- package/src/commands/subprocess/command.ts +131 -0
- package/src/commands/subprocess/index.ts +3 -139
- package/src/commands/subprocess/protocols/none.ts +73 -68
- package/src/commands/subprocess/protocols/shell.ts +191 -190
- package/src/commands/subprocess/protocols/types.ts +60 -59
- package/src/commands/subprocess/utils.ts +20 -20
- package/src/commands/sync/index.ts +7 -7
- package/src/commands/sync/list.ts +54 -86
- package/src/commands/sync/pull.ts +45 -46
- package/src/commands/sync/push.ts +38 -41
- package/src/commands/sync/request.ts +51 -50
- package/src/commands/sync/response.ts +68 -64
- package/src/commands/sync/stat.ts +129 -150
- package/src/commands/sync/sync.ts +182 -181
- package/src/commands/tcpip.ts +21 -21
- package/src/crypto.ts +296 -296
- package/src/features.ts +9 -9
- package/src/index.ts +10 -11
- package/src/packet.ts +80 -80
- package/src/socket/dispatcher.ts +310 -304
- package/src/socket/index.ts +2 -2
- package/src/socket/socket.ts +156 -144
- package/src/utils/auto-reset-event.ts +41 -41
- package/src/utils/base64.ts +329 -306
- package/src/utils/index.ts +3 -3
- package/tsconfig.build.json +3 -3
- package/tsconfig.build.tsbuildinfo +1 -1
- package/esm/commands/subprocess/legacy.d.ts +0 -35
- package/esm/commands/subprocess/legacy.d.ts.map +0 -1
- package/esm/commands/subprocess/legacy.js +0 -53
- package/esm/commands/subprocess/legacy.js.map +0 -1
- package/esm/commands/subprocess/protocol.d.ts +0 -39
- package/esm/commands/subprocess/protocol.d.ts.map +0 -1
- package/esm/commands/subprocess/protocol.js +0 -157
- package/esm/commands/subprocess/protocol.js.map +0 -1
- package/esm/commands/subprocess/types.d.ts +0 -50
- package/esm/commands/subprocess/types.d.ts.map +0 -1
- package/esm/commands/subprocess/types.js +0 -2
- package/esm/commands/subprocess/types.js.map +0 -1
- package/esm/socket/controller.d.ts +0 -37
- package/esm/socket/controller.d.ts.map +0 -1
- package/esm/socket/controller.js +0 -66
- package/esm/socket/controller.js.map +0 -1
- package/esm/stream/buffered.d.ts +0 -35
- package/esm/stream/buffered.d.ts.map +0 -1
- package/esm/stream/buffered.js +0 -123
- package/esm/stream/buffered.js.map +0 -1
- package/esm/stream/detect.bak.d.ts +0 -240
- package/esm/stream/detect.bak.d.ts.map +0 -1
- package/esm/stream/detect.bak.js +0 -60
- package/esm/stream/detect.bak.js.map +0 -1
- package/esm/stream/detect.d.ts +0 -2
- package/esm/stream/detect.d.ts.map +0 -1
- package/esm/stream/detect.js +0 -5
- package/esm/stream/detect.js.map +0 -1
- package/esm/stream/detect.native.d.ts +0 -240
- package/esm/stream/detect.native.d.ts.map +0 -1
- package/esm/stream/detect.native.js +0 -60
- package/esm/stream/detect.native.js.map +0 -1
- package/esm/stream/detect.polyfill.d.ts +0 -18
- package/esm/stream/detect.polyfill.d.ts.map +0 -1
- package/esm/stream/detect.polyfill.js +0 -9
- package/esm/stream/detect.polyfill.js.map +0 -1
- package/esm/stream/index.d.ts +0 -4
- package/esm/stream/index.d.ts.map +0 -1
- package/esm/stream/index.js +0 -4
- package/esm/stream/index.js.map +0 -1
- package/esm/stream/transform.d.ts +0 -104
- package/esm/stream/transform.d.ts.map +0 -1
- package/esm/stream/transform.js +0 -373
- package/esm/stream/transform.js.map +0 -1
- package/esm/utils/encoding.d.ts +0 -3
- package/esm/utils/encoding.d.ts.map +0 -1
- package/esm/utils/encoding.js +0 -11
- package/esm/utils/encoding.js.map +0 -1
- package/src/stream/buffered.ts +0 -147
- package/src/stream/detect.native.ts +0 -362
- package/src/stream/detect.polyfill.ts +0 -28
- package/src/stream/detect.ts +0 -5
- package/src/stream/index.ts +0 -3
- package/src/stream/transform.ts +0 -447
- package/tsconfig.test.json +0 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/socket/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/socket/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC"}
|
package/esm/socket/index.js
CHANGED
package/esm/socket/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/socket/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/socket/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC"}
|
package/esm/socket/socket.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Disposable } from
|
|
2
|
-
import { WritableStream, type ReadableStream, type ReadableWritablePair } from '
|
|
1
|
+
import type { Disposable } from '@yume-chan/event';
|
|
2
|
+
import { WritableStream, type ReadableStream, type ReadableWritablePair } from '@yume-chan/stream-extra';
|
|
3
3
|
import type { AdbPacketDispatcher, Closeable } from './dispatcher.js';
|
|
4
4
|
export interface AdbSocketInfo {
|
|
5
5
|
localId: number;
|
|
@@ -17,13 +17,18 @@ export declare class AdbSocketController implements AdbSocketInfo, ReadableWrita
|
|
|
17
17
|
readonly remoteId: number;
|
|
18
18
|
readonly localCreated: boolean;
|
|
19
19
|
readonly serviceString: string;
|
|
20
|
-
private
|
|
20
|
+
private _duplex;
|
|
21
21
|
private _readable;
|
|
22
22
|
private _readableController;
|
|
23
23
|
get readable(): ReadableStream<Uint8Array>;
|
|
24
24
|
private _writePromise;
|
|
25
25
|
readonly writable: WritableStream<Uint8Array>;
|
|
26
26
|
private _closed;
|
|
27
|
+
/**
|
|
28
|
+
* Whether the socket is half-closed (i.e. the local side initiated the close).
|
|
29
|
+
*
|
|
30
|
+
* It's only used by dispatcher to avoid sending another `CLSE` packet to remote.
|
|
31
|
+
*/
|
|
27
32
|
get closed(): boolean;
|
|
28
33
|
private _socket;
|
|
29
34
|
get socket(): AdbSocket;
|
|
@@ -34,7 +39,7 @@ export declare class AdbSocketController implements AdbSocketInfo, ReadableWrita
|
|
|
34
39
|
dispose(): void;
|
|
35
40
|
}
|
|
36
41
|
/**
|
|
37
|
-
*
|
|
42
|
+
* A duplex stream representing a socket to ADB daemon.
|
|
38
43
|
*
|
|
39
44
|
* To close it, call either `socket.close()`,
|
|
40
45
|
* `socket.readable.cancel()`, `socket.readable.getReader().cancel()`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket.d.ts","sourceRoot":"","sources":["../../src/socket/socket.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"socket.d.ts","sourceRoot":"","sources":["../../src/socket/socket.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAkE,cAAc,EAAqC,KAAK,cAAc,EAAE,KAAK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AAoB,CAAC,UAAU,EAAE,UAAU,CAAC;IACzF,OAAO,CAAC,WAAW,CAAsB;IAEzC,IAAW,OAAO,IAAI,MAAM,CAAqC;IACjE,IAAW,QAAQ,IAAI,MAAM,CAAsC;IACnE,IAAW,YAAY,IAAI,OAAO,CAA0C;IAC5E,IAAW,aAAa,IAAI,MAAM,CAA2C;IAE7E,IAAW,QAAQ,IAAI,cAAc,CAAC,UAAU,CAAC,CAAsC;IACvF,IAAW,QAAQ,IAAI,cAAc,CAAC,UAAU,CAAC,CAAsC;gBAEpE,UAAU,EAAE,mBAAmB;IAI3C,KAAK;CAGf"}
|
package/esm/socket/socket.js
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
import { PromiseResolver } from
|
|
1
|
+
import { PromiseResolver } from '@yume-chan/async';
|
|
2
|
+
import { ChunkStream, DuplexStreamFactory, pipeFrom, PushReadableStream, WritableStream } from '@yume-chan/stream-extra';
|
|
2
3
|
import { AdbCommand } from '../packet.js';
|
|
3
|
-
import { ChunkStream, DuplexStreamFactory, pipeFrom, PushReadableStream, WritableStream } from '../stream/index.js';
|
|
4
4
|
export class AdbSocketController {
|
|
5
5
|
dispatcher;
|
|
6
6
|
localId;
|
|
7
7
|
remoteId;
|
|
8
8
|
localCreated;
|
|
9
9
|
serviceString;
|
|
10
|
-
|
|
10
|
+
_duplex;
|
|
11
11
|
_readable;
|
|
12
12
|
_readableController;
|
|
13
13
|
get readable() { return this._readable; }
|
|
14
14
|
_writePromise;
|
|
15
15
|
writable;
|
|
16
16
|
_closed = false;
|
|
17
|
+
/**
|
|
18
|
+
* Whether the socket is half-closed (i.e. the local side initiated the close).
|
|
19
|
+
*
|
|
20
|
+
* It's only used by dispatcher to avoid sending another `CLSE` packet to remote.
|
|
21
|
+
*/
|
|
17
22
|
get closed() { return this._closed; }
|
|
18
23
|
_socket;
|
|
19
24
|
get socket() { return this._socket; }
|
|
@@ -22,25 +27,25 @@ export class AdbSocketController {
|
|
|
22
27
|
// Check this image to help you understand the stream graph
|
|
23
28
|
// cspell: disable-next-line
|
|
24
29
|
// https://www.plantuml.com/plantuml/png/TL0zoeGm4ErpYc3l5JxyS0yWM6mX5j4C6p4cxcJ25ejttuGX88ZftizxUKmJI275pGhXl0PP_UkfK_CAz5Z2hcWsW9Ny2fdU4C1f5aSchFVxA8vJjlTPRhqZzDQMRB7AklwJ0xXtX0ZSKH1h24ghoKAdGY23FhxC4nS2pDvxzIvxb-8THU0XlEQJ-ZB7SnXTAvc_LhOckhMdLBnbtndpb-SB7a8q2SRD_W00
|
|
25
|
-
this.
|
|
30
|
+
this._duplex = new DuplexStreamFactory({
|
|
26
31
|
close: async () => {
|
|
32
|
+
this._closed = true;
|
|
27
33
|
await this.dispatcher.sendPacket(AdbCommand.Close, this.localId, this.remoteId);
|
|
28
34
|
// Don't `dispose` here, we need to wait for `CLSE` response packet.
|
|
29
35
|
return false;
|
|
30
36
|
},
|
|
31
37
|
dispose: () => {
|
|
32
|
-
this._closed = true;
|
|
33
38
|
// Error out the pending writes
|
|
34
39
|
this._writePromise?.reject(new Error('Socket closed'));
|
|
35
40
|
},
|
|
36
41
|
});
|
|
37
|
-
this._readable = this.
|
|
42
|
+
this._readable = this._duplex.wrapReadable(new PushReadableStream(controller => {
|
|
38
43
|
this._readableController = controller;
|
|
39
44
|
}, {
|
|
40
45
|
highWaterMark: options.highWaterMark ?? 16 * 1024,
|
|
41
46
|
size(chunk) { return chunk.byteLength; }
|
|
42
47
|
}));
|
|
43
|
-
this.writable = pipeFrom(this.
|
|
48
|
+
this.writable = pipeFrom(this._duplex.createWritable(new WritableStream({
|
|
44
49
|
write: async (chunk) => {
|
|
45
50
|
// Wait for an ack packet
|
|
46
51
|
this._writePromise = new PromiseResolver();
|
|
@@ -51,20 +56,25 @@ export class AdbSocketController {
|
|
|
51
56
|
this._socket = new AdbSocket(this);
|
|
52
57
|
}
|
|
53
58
|
async enqueue(packet) {
|
|
59
|
+
// Consumer may abort the `ReadableStream` to close the socket,
|
|
60
|
+
// it's OK to throw away further packets in this case.
|
|
61
|
+
if (this._readableController.abortSignal.aborted) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
54
64
|
await this._readableController.enqueue(packet);
|
|
55
65
|
}
|
|
56
66
|
ack() {
|
|
57
67
|
this._writePromise?.resolve();
|
|
58
68
|
}
|
|
59
69
|
async close() {
|
|
60
|
-
this.
|
|
70
|
+
await this._duplex.close();
|
|
61
71
|
}
|
|
62
72
|
dispose() {
|
|
63
|
-
this.
|
|
73
|
+
this._duplex.dispose();
|
|
64
74
|
}
|
|
65
75
|
}
|
|
66
76
|
/**
|
|
67
|
-
*
|
|
77
|
+
* A duplex stream representing a socket to ADB daemon.
|
|
68
78
|
*
|
|
69
79
|
* To close it, call either `socket.close()`,
|
|
70
80
|
* `socket.readable.cancel()`, `socket.readable.getReader().cancel()`,
|
package/esm/socket/socket.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket.js","sourceRoot":"","sources":["../../src/socket/socket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"socket.js","sourceRoot":"","sources":["../../src/socket/socket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,QAAQ,EAAE,kBAAkB,EAAE,cAAc,EAAqF,MAAM,yBAAyB,CAAC;AAE5M,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAiB1C,MAAM,OAAO,mBAAmB;IACX,UAAU,CAAuB;IAElC,OAAO,CAAU;IACjB,QAAQ,CAAU;IAClB,YAAY,CAAW;IACvB,aAAa,CAAU;IAE/B,OAAO,CAA8C;IAErD,SAAS,CAA6B;IACtC,mBAAmB,CAA4C;IACvE,IAAW,QAAQ,KAAK,OAAO,IAAI,CAAC,SAAS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C,CAAC;IACnE,IAAW,YAAY,KAAc,OAAO,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC;IAC5E,IAAW,aAAa,KAAa,OAAO,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC;IAE7E,IAAW,QAAQ,KAAiC,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC;IACvF,IAAW,QAAQ,KAAiC,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEvF,YAAmB,UAA+B;QAC9C,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAClC,CAAC;IAEM,KAAK;QACR,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IACpC,CAAC;CACJ"}
|
package/esm/utils/base64.d.ts
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculate the required length of the output buffer for the given input length.
|
|
3
|
+
*
|
|
4
|
+
* @param inputLength Length of the input in bytes
|
|
5
|
+
* @returns Length of the output in bytes
|
|
6
|
+
*/
|
|
1
7
|
export declare function calculateBase64EncodedLength(inputLength: number): [outputLength: number, paddingLength: number];
|
|
8
|
+
/**
|
|
9
|
+
* Encode the given input buffer into base64.
|
|
10
|
+
*
|
|
11
|
+
* @param input The input buffer
|
|
12
|
+
* @returns The encoded output buffer
|
|
13
|
+
*/
|
|
2
14
|
export declare function encodeBase64(input: Uint8Array): Uint8Array;
|
|
15
|
+
/**
|
|
16
|
+
* Encode the given input into base64 and write it to the output buffer.
|
|
17
|
+
*
|
|
18
|
+
* The output buffer must be at least as long as the value returned by `calculateBase64EncodedLength`.
|
|
19
|
+
* It can points to the same buffer as the input, as long as `output.offset <= input.offset - input.length / 3`,
|
|
20
|
+
* or `output.offset >= input.offset - 1`
|
|
21
|
+
*
|
|
22
|
+
* @param input The input buffer
|
|
23
|
+
* @param output The output buffer
|
|
24
|
+
* @returns The number of bytes written to the output buffer
|
|
25
|
+
*/
|
|
3
26
|
export declare function encodeBase64(input: Uint8Array, output: Uint8Array): number;
|
|
4
27
|
export declare function decodeBase64(input: string): Uint8Array;
|
|
5
28
|
//# sourceMappingURL=base64.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base64.d.ts","sourceRoot":"","sources":["../../src/utils/base64.ts"],"names":[],"mappings":"AAqBA,wBAAgB,4BAA4B,CAAC,WAAW,EAAE,MAAM,GAAG,CAAC,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC,CAI/G;AAED,wBAAgB,YAAY,CACxB,KAAK,EAAE,UAAU,GAClB,UAAU,CAAC;AACd,wBAAgB,YAAY,CACxB,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,UAAU,GACnB,MAAM,CAAC;AAoNV,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CA4DtD"}
|
|
1
|
+
{"version":3,"file":"base64.d.ts","sourceRoot":"","sources":["../../src/utils/base64.ts"],"names":[],"mappings":"AAqBA;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,WAAW,EAAE,MAAM,GAAG,CAAC,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC,CAI/G;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CACxB,KAAK,EAAE,UAAU,GAClB,UAAU,CAAC;AACd;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CACxB,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,UAAU,GACnB,MAAM,CAAC;AAoNV,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CA4DtD"}
|
package/esm/utils/base64.js
CHANGED
|
@@ -15,6 +15,12 @@ addRange('a', 'z');
|
|
|
15
15
|
addRange('0', '9');
|
|
16
16
|
addRange('+', '+');
|
|
17
17
|
addRange('/', '/');
|
|
18
|
+
/**
|
|
19
|
+
* Calculate the required length of the output buffer for the given input length.
|
|
20
|
+
*
|
|
21
|
+
* @param inputLength Length of the input in bytes
|
|
22
|
+
* @returns Length of the output in bytes
|
|
23
|
+
*/
|
|
18
24
|
export function calculateBase64EncodedLength(inputLength) {
|
|
19
25
|
const remainder = inputLength % 3;
|
|
20
26
|
const paddingLength = remainder !== 0 ? 3 - remainder : 0;
|
package/esm/utils/base64.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base64.js","sourceRoot":"","sources":["../../src/utils/base64.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,MAAM,WAAW,GAA2B,EAAE,CAAC;AAC/C,MAAM,WAAW,GAAa,EAAE,CAAC;AACjC,MAAM,WAAW,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AAEtC,SAAS,QAAQ,CAAC,KAAa,EAAE,GAAW;IACxC,MAAM,aAAa,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAC1C,MAAM,WAAW,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAEtC,KAAK,IAAI,QAAQ,GAAG,aAAa,EAAE,QAAQ,IAAI,WAAW,EAAE,QAAQ,IAAI,CAAC,EAAE;QACvE,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC;QAChE,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;KAC9B;AACL,CAAC;AAED,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACnB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACnB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACnB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACnB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAEnB,MAAM,UAAU,4BAA4B,CAAC,WAAmB;IAC5D,MAAM,SAAS,GAAG,WAAW,GA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C,IAAI,CAAC,CAAC,CAAC;QACnD,MAAM,IAAI,CAAC,CAAC;QAEZ,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAS,CAAC,IAAI,CAAC,CAAC,CAAC;KACjE;SAAM,IAAI,OAAO,KAAK,CAAC,EAAE;QACtB,MAAM,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,MAAM,CAAE,CAAE,CAAC;QACvC,MAAM,IAAI,CAAC,CAAC;QAEZ,MAAM,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,MAAM,CAAE,CAAE,CAAC;QAEvC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAS,CAAC,IAAI,CAAC,CAAC,CAAC;KACtD;IAED,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yume-chan/adb",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"description": "TypeScript implementation of Android Debug Bridge (ADB) protocol.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"adb",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"email": "cnsimonchan@live.com",
|
|
13
13
|
"url": "https://chensi.moe/blog"
|
|
14
14
|
},
|
|
15
|
-
"homepage": "https://github.com/yume-chan/ya-webadb/tree/
|
|
15
|
+
"homepage": "https://github.com/yume-chan/ya-webadb/tree/main/libraries/adb#readme",
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
18
18
|
"url": "git+https://github.com/yume-chan/ya-webadb.git",
|
|
@@ -25,26 +25,25 @@
|
|
|
25
25
|
"main": "esm/index.js",
|
|
26
26
|
"types": "esm/index.d.ts",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@yume-chan/async": "^2.
|
|
29
|
-
"@yume-chan/dataview-bigint-polyfill": "^0.0.
|
|
30
|
-
"@yume-chan/event": "^0.0.
|
|
31
|
-
"@yume-chan/
|
|
32
|
-
"
|
|
33
|
-
"
|
|
28
|
+
"@yume-chan/async": "^2.2.0",
|
|
29
|
+
"@yume-chan/dataview-bigint-polyfill": "^0.0.17",
|
|
30
|
+
"@yume-chan/event": "^0.0.17",
|
|
31
|
+
"@yume-chan/stream-extra": "^0.0.17",
|
|
32
|
+
"@yume-chan/struct": "^0.0.17",
|
|
33
|
+
"tslib": "^2.4.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
+
"@jest/globals": "^28.1.2",
|
|
36
37
|
"@types/node": "^17.0.17",
|
|
37
|
-
"@types/jest": "^27.4.1",
|
|
38
38
|
"@yume-chan/ts-package-builder": "^1.0.0",
|
|
39
39
|
"cross-env": "^7.0.3",
|
|
40
|
-
"jest": "^
|
|
41
|
-
"ts-jest": "^
|
|
42
|
-
"typescript": "4.7.
|
|
40
|
+
"jest": "^28.1.2",
|
|
41
|
+
"ts-jest": "^28.0.5",
|
|
42
|
+
"typescript": "^4.7.4"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "tsc -b tsconfig.build.json",
|
|
46
46
|
"build:watch": "tsc -b tsconfig.build.json",
|
|
47
47
|
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage"
|
|
48
|
-
}
|
|
49
|
-
"readme": "# @yume-chan/adb\r\n\r\nTypeScript implementation of Android Debug Bridge (ADB) protocol.\r\n\r\n**WARNING:** The public API is UNSTABLE. If you have any questions, please open an issue.\r\n\r\n- [Compatibility](#compatibility)\r\n - [Basic usage](#basic-usage)\r\n - [Use without bundlers](#use-without-bundlers)\r\n- [Connection](#connection)\r\n - [Backend](#backend)\r\n - [`connect`](#connect)\r\n- [Authentication](#authentication)\r\n - [AdbCredentialStore](#adbcredentialstore)\r\n - [`generateKey`](#generatekey)\r\n - [`iterateKeys`](#iteratekeys)\r\n - [Implementations](#implementations)\r\n - [AdbAuthenticator](#adbauthenticator)\r\n - [`authenticate`](#authenticate)\r\n- [Stream multiplex](#stream-multiplex)\r\n- [Commands](#commands)\r\n - [subprocess](#subprocess)\r\n - [raw mode](#raw-mode)\r\n - [pty mode](#pty-mode)\r\n - [usb](#usb)\r\n - [tcpip](#tcpip)\r\n - [sync](#sync)\r\n - [LIST](#list)\r\n - [LIS2](#lis2)\r\n - [STAT](#stat)\r\n - [LST2](#lst2)\r\n - [STA2](#sta2)\r\n - [RECV](#recv)\r\n - [RCV2](#rcv2)\r\n - [SEND](#send)\r\n - [SND2](#snd2)\r\n- [Useful links](#useful-links)\r\n\r\n## Compatibility\r\n\r\nHere is a list of features, their used APIs, and their compatibilities. If an optional feature is not actually used, its requirements can be ignored.\r\n\r\nSome features can be polyfilled to support older runtimes, but this library doesn't ship with any polyfills.\r\n\r\nEach backend may have different requirements.\r\n\r\n### Basic usage\r\n\r\n| | Chrome | Edge | Firefox | Internet Explorer | Safari | Node.js |\r\n| ------------------------------- | ------ | ---- | ------- | ----------------- | ------ | ------------------- |\r\n| `@yume-chan/struct`<sup>1</sup> | 67 | 79 | 68 | No | 14 | 8.3<sup>2</sup>, 11 |\r\n| *Overall* | 67 | 79 | No | No | 14.1 | 16.5 |\r\n\r\n<sup>1</sup> `uint64` and `string` are used.\r\n\r\n<sup>2</sup> `TextEncoder` and `TextDecoder` are only available in `util` module. Need to be assigned to `globalThis`.\r\n\r\n### Use without bundlers\r\n\r\n| | Chrome | Edge | Firefox | Internet Explorer | Safari | Node.js |\r\n| --------------- | ------ | ---- | ------- | ----------------- | ------ | ------- |\r\n| Top-level await | 89 | 89 | 89 | No | 15 | 14.8 |\r\n\r\n## Connection\r\n\r\nThis library doesn't tie to a specific transportation method.\r\n\r\nInstead, a `Backend` is responsible for transferring data in its own way (USB, WebSocket, TCP, etc).\r\n\r\n### Backend\r\n\r\n#### `connect`\r\n\r\n```ts\r\nconnect(): ValueOrPromise<ReadableWritablePair<AdbPacketCore, AdbPacketInit>>\r\n```\r\n\r\nConnect to a device and create a pair of `AdbPacket` streams.\r\n\r\nThe 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.\r\n\r\n## Authentication\r\n\r\nFor how does ADB authentication work, see https://chensi.moe/blog/2020/09/30/webadb-part2-connection/#auth.\r\n\r\nIn this library, authentication comes in two parts:\r\n\r\n#### AdbCredentialStore\r\n\r\nAn interface to generate, store and iterate ADB private keys on each runtime. (Because Node.js and Browsers have different APIs to do this)\r\n\r\n##### `generateKey`\r\n\r\n```ts\r\ngenerateKey(): ValueOrPromise<Uint8Array>\r\n```\r\n\r\nGenerate and store a RSA private key with modulus length `2048` and public exponent `65537`.\r\n\r\nThe returned `Uint8Array` is the private key in PKCS #8 format.\r\n\r\n##### `iterateKeys`\r\n\r\n```ts\r\niterateKeys(): Iterator<ArrayBuffer> | AsyncIterator<ArrayBuffer>\r\n```\r\n\r\nSynchronously or asynchronously iterate through all stored RSA private keys.\r\n\r\nEach call to `iterateKeys` must return a different iterator that iterate through all stored keys.\r\n\r\n##### Implementations\r\n\r\nThe `@yume-chan/adb-credential-web` package contains a `AdbWebCredentialStore` implementation using Web Crypto API for generating keys and Web Storage API for storing keys.\r\n\r\n#### AdbAuthenticator\r\n\r\nAn `AdbAuthenticator` generates `AUTH` responses for each `AUTH` request from server.\r\n\r\nThis package contains `AdbSignatureAuthenticator` and `AdbPublicKeyAuthenticator`, the two basic modes.\r\n\r\n#### `authenticate`\r\n\r\n```ts\r\nstatic async authenticate(\r\n connection: ReadableWritablePair<AdbPacketCore, AdbPacketCore>,\r\n credentialStore: AdbCredentialStore,\r\n authenticators = AdbDefaultAuthenticators,\r\n): Promise<Adb>\r\n```\r\n\r\nCall this method to authenticate the connection and create an `Adb` instance.\r\n\r\nIf 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.\r\n\r\n## Stream multiplex\r\n\r\nADB commands are all based on streams. Multiple streams can send and receive at the same time in one connection.\r\n\r\n1. Client sends an `OPEN` packet to create a stream.\r\n2. Server responds with `OKAY` or `FAIL`.\r\n3. Client and server read/write on the stream.\r\n4. Client/server sends a `CLSE` to close the stream.\r\n\r\n## Commands\r\n\r\n### subprocess\r\n\r\nADB has two subprocess invocation modes and two data protocols (4 combinations).\r\n\r\n#### raw mode\r\n\r\nIn raw mode, Shell protocol transfers `stdout` and `stderr` separately. It also supports returning exit code.\r\n\r\n| | Legacy protocol | Shell Protocol |\r\n| --------------------------- | --------------------------- | ---------------------------- |\r\n| Feature flag | - | `shell_v2` |\r\n| Implementation | `AdbNoneSubprocessProtocol` | `AdbShellSubprocessProtocol` |\r\n| Splitting stdout and stderr | No | Yes |\r\n| Returning exit code | No | Yes |\r\n\r\nUse `spawn` method to create a subprocess in raw mode.\r\n\r\n#### pty mode\r\n\r\nIn 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.\r\n\r\n| | Legacy protocol | Shell Protocol |\r\n| --------------------------- | --------------------------- | ---------------------------- |\r\n| Feature flag | - | `shell_v2` |\r\n| Implementation | `AdbNoneSubprocessProtocol` | `AdbShellSubprocessProtocol` |\r\n| Resizing window | No | Yes |\r\n\r\nUse `shell` method to create a subprocess in PTY mode.\r\n\r\n### usb\r\n\r\nDisable ADB over WiFi.\r\n\r\n### tcpip\r\n\r\nEnable ADB over WiFi.\r\n\r\n### sync\r\n\r\nClient and server will communicate with another protocol on the opened stream.\r\n\r\n#### LIST\r\n\r\nRequest server to list the content of a folder.\r\n\r\n#### LIS2\r\n\r\nVersion 2 of the LIST command, contains more information.\r\n\r\nSupported on devices with `ls_v2` feature.\r\n\r\n#### STAT\r\n\r\nRequest server to return the information of a file.\r\n\r\nIf path is a symbolic link, the returned information is about the link itself.\r\n\r\nSo it's actually the [`lstat`](https://linux.die.net/man/2/lstat) system call.\r\n\r\n#### LST2\r\n\r\nVersion 2 of the STAT command, contains more information.\r\n\r\nSupported on devices with `stat_v2` feature.\r\n\r\n#### STA2\r\n\r\nBasically identical to LST2, but if path is a symbolic link, the information is about the file it refers to.\r\n\r\nSupported on devices with `stat_v2` feature.\r\n\r\n#### RECV\r\n\r\nRequest server to send the content of a file.\r\n\r\n#### RCV2\r\n\r\n*(Not Implemented)*\r\n\r\nVersion 2 of the RECV command.\r\n\r\nSupported on devices with `sendrecv_v2` feature.\r\n\r\n#### SEND\r\n\r\n*(Not Implemented)*\r\n\r\nSend a file onto server's file system.\r\n\r\n#### SND2\r\n\r\n*(Not Implemented)*\r\n\r\nVersion 2 of the SEND command.\r\n\r\nSupported on devices with `sendrecv_v2` feature.\r\n\r\n## Useful links\r\n\r\n* [ADB protocol overview](https://android.googlesource.com/platform/packages/modules/adb/+/2fd69306184634c6d90db3ed3be5349e71dcc471/OVERVIEW.TXT)\r\n* [ADB commands](https://android.googlesource.com/platform/packages/modules/adb/+/2fd69306184634c6d90db3ed3be5349e71dcc471/SERVICES.TXT#145)\r\n"
|
|
48
|
+
}
|
|
50
49
|
}
|