@yume-chan/adb 0.0.19 → 0.0.21
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 +57 -0
- package/CHANGELOG.md +26 -1
- package/README.md +222 -103
- package/esm/adb.d.ts +28 -45
- package/esm/adb.d.ts.map +1 -1
- package/esm/adb.js +34 -213
- 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.map +1 -1
- package/esm/commands/base.js.map +1 -1
- package/esm/commands/framebuffer.d.ts +9 -0
- package/esm/commands/framebuffer.d.ts.map +1 -1
- package/esm/commands/framebuffer.js +27 -3
- package/esm/commands/framebuffer.js.map +1 -1
- package/esm/commands/power.d.ts +1 -1
- package/esm/commands/power.d.ts.map +1 -1
- package/esm/commands/power.js +2 -2
- package/esm/commands/power.js.map +1 -1
- package/esm/commands/reverse.d.ts +17 -18
- package/esm/commands/reverse.d.ts.map +1 -1
- package/esm/commands/reverse.js +53 -48
- package/esm/commands/reverse.js.map +1 -1
- package/esm/commands/subprocess/command.d.ts +1 -1
- package/esm/commands/subprocess/command.d.ts.map +1 -1
- package/esm/commands/subprocess/command.js +15 -13
- package/esm/commands/subprocess/command.js.map +1 -1
- package/esm/commands/subprocess/protocols/none.d.ts +3 -8
- package/esm/commands/subprocess/protocols/none.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/none.js +16 -16
- package/esm/commands/subprocess/protocols/none.js.map +1 -1
- package/esm/commands/subprocess/protocols/shell.d.ts +3 -9
- package/esm/commands/subprocess/protocols/shell.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/shell.js +63 -57
- package/esm/commands/subprocess/protocols/shell.js.map +1 -1
- package/esm/commands/subprocess/protocols/types.d.ts +1 -2
- package/esm/commands/subprocess/protocols/types.d.ts.map +1 -1
- package/esm/commands/sync/list.js +2 -2
- package/esm/commands/sync/push.d.ts +14 -3
- package/esm/commands/sync/push.d.ts.map +1 -1
- package/esm/commands/sync/push.js +9 -9
- package/esm/commands/sync/push.js.map +1 -1
- package/esm/commands/sync/request.js +2 -2
- package/esm/commands/sync/request.js.map +1 -1
- package/esm/commands/sync/response.d.ts +5 -3
- package/esm/commands/sync/response.d.ts.map +1 -1
- package/esm/commands/sync/response.js +7 -5
- package/esm/commands/sync/response.js.map +1 -1
- package/esm/commands/sync/socket.d.ts +8 -14
- package/esm/commands/sync/socket.d.ts.map +1 -1
- package/esm/commands/sync/socket.js +35 -32
- package/esm/commands/sync/socket.js.map +1 -1
- package/esm/commands/sync/stat.js +4 -4
- package/esm/commands/sync/stat.js.map +1 -1
- package/esm/commands/sync/sync.d.ts +26 -18
- package/esm/commands/sync/sync.d.ts.map +1 -1
- package/esm/commands/sync/sync.js +36 -25
- package/esm/commands/sync/sync.js.map +1 -1
- package/esm/commands/tcpip.d.ts +2 -2
- package/esm/commands/tcpip.d.ts.map +1 -1
- package/esm/commands/tcpip.js +4 -2
- package/esm/commands/tcpip.js.map +1 -1
- package/esm/{auth.d.ts → daemon/auth.d.ts} +12 -11
- package/esm/daemon/auth.d.ts.map +1 -0
- package/esm/{auth.js → daemon/auth.js} +31 -22
- package/esm/daemon/auth.js.map +1 -0
- package/esm/{crypto.d.ts → daemon/crypto.d.ts} +5 -5
- package/esm/daemon/crypto.d.ts.map +1 -0
- package/esm/{crypto.js → daemon/crypto.js} +24 -28
- package/esm/daemon/crypto.js.map +1 -0
- package/esm/{backend.d.ts → daemon/device.d.ts} +2 -2
- 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/{socket → daemon}/dispatcher.d.ts +12 -30
- package/esm/daemon/dispatcher.d.ts.map +1 -0
- package/esm/{socket → daemon}/dispatcher.js +80 -78
- 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} +4 -4
- package/esm/daemon/packet.d.ts.map +1 -0
- package/esm/{packet.js → daemon/packet.js} +2 -2
- package/esm/{packet.js.map → daemon/packet.js.map} +1 -1
- package/esm/{socket → daemon}/socket.d.ts +15 -19
- package/esm/daemon/socket.d.ts.map +1 -0
- package/esm/{socket → daemon}/socket.js +49 -42
- package/esm/daemon/socket.js.map +1 -0
- package/esm/daemon/transport.d.ts +53 -0
- package/esm/daemon/transport.d.ts.map +1 -0
- package/esm/daemon/transport.js +186 -0
- package/esm/daemon/transport.js.map +1 -0
- package/esm/features.js +1 -1
- package/esm/features.js.map +1 -1
- package/esm/index.d.ts +3 -5
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +3 -5
- 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 +328 -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 +1 -2
- package/esm/utils/auto-reset-event.d.ts.map +1 -1
- package/esm/utils/auto-reset-event.js +12 -12
- package/esm/utils/auto-reset-event.js.map +1 -1
- package/esm/utils/base64.js +5 -5
- package/esm/utils/base64.js.map +1 -1
- package/esm/utils/conditional-variable.d.ts +1 -2
- package/esm/utils/conditional-variable.d.ts.map +1 -1
- package/esm/utils/conditional-variable.js +10 -10
- package/esm/utils/conditional-variable.js.map +1 -1
- 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 +2 -0
- package/esm/utils/index.d.ts.map +1 -1
- package/esm/utils/index.js +2 -0
- 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 +12 -12
- package/src/adb.ts +75 -274
- package/src/banner.ts +82 -0
- package/src/commands/base.ts +1 -1
- package/src/commands/framebuffer.ts +31 -3
- package/src/commands/power.ts +10 -10
- package/src/commands/reverse.ts +77 -82
- package/src/commands/subprocess/command.ts +24 -25
- package/src/commands/subprocess/protocols/none.ts +29 -30
- package/src/commands/subprocess/protocols/shell.ts +87 -89
- package/src/commands/subprocess/protocols/types.ts +1 -2
- package/src/commands/sync/list.ts +7 -7
- package/src/commands/sync/pull.ts +4 -4
- package/src/commands/sync/push.ts +28 -16
- package/src/commands/sync/request.ts +4 -4
- package/src/commands/sync/response.ts +13 -11
- package/src/commands/sync/socket.ts +48 -46
- package/src/commands/sync/stat.ts +5 -5
- package/src/commands/sync/sync.ts +55 -43
- package/src/commands/tcpip.ts +6 -4
- package/src/{auth.ts → daemon/auth.ts} +62 -43
- package/src/{crypto.ts → daemon/crypto.ts} +33 -41
- package/src/{backend.ts → daemon/device.ts} +1 -1
- package/src/{socket → daemon}/dispatcher.ts +103 -109
- package/src/daemon/index.ts +7 -0
- package/src/{packet.ts → daemon/packet.ts} +6 -6
- package/src/{socket → daemon}/socket.ts +77 -67
- package/src/daemon/transport.ts +281 -0
- package/src/index.ts +3 -5
- package/src/server/client.ts +473 -0
- package/src/server/index.ts +2 -0
- package/src/server/transport.ts +77 -0
- package/src/utils/auto-reset-event.ts +16 -16
- package/src/utils/base64.ts +5 -5
- package/src/utils/conditional-variable.ts +14 -14
- package/src/utils/hex.ts +58 -0
- package/src/utils/index.ts +2 -0
- 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.map +0 -1
- package/esm/backend.js +0 -2
- package/esm/backend.js.map +0 -1
- package/esm/commands/install.d.ts +0 -10
- 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/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.map +0 -1
- package/esm/socket/socket.js.map +0 -1
- package/src/socket/index.ts +0 -2
|
@@ -1,66 +1,69 @@
|
|
|
1
1
|
import { BufferCombiner, BufferedReadableStream, ConsumableWritableStream, } from "@yume-chan/stream-extra";
|
|
2
|
-
import { AutoResetEvent } from "../../index.js";
|
|
2
|
+
import { AutoResetEvent } from "../../utils/index.js";
|
|
3
3
|
export class AdbSyncSocketLocked {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
#writer;
|
|
5
|
+
#readable;
|
|
6
|
+
#socketLock;
|
|
7
|
+
#writeLock = new AutoResetEvent();
|
|
8
|
+
#combiner;
|
|
9
|
+
get position() {
|
|
10
|
+
return this.#readable.position;
|
|
11
|
+
}
|
|
9
12
|
constructor(writer, readable, bufferSize, lock) {
|
|
10
|
-
this
|
|
11
|
-
this
|
|
12
|
-
this
|
|
13
|
-
this
|
|
13
|
+
this.#writer = writer;
|
|
14
|
+
this.#readable = readable;
|
|
15
|
+
this.#socketLock = lock;
|
|
16
|
+
this.#combiner = new BufferCombiner(bufferSize);
|
|
14
17
|
}
|
|
15
|
-
async writeInnerStream(buffer) {
|
|
16
|
-
await ConsumableWritableStream.write(this
|
|
18
|
+
async #writeInnerStream(buffer) {
|
|
19
|
+
await ConsumableWritableStream.write(this.#writer, buffer);
|
|
17
20
|
}
|
|
18
21
|
async flush() {
|
|
19
22
|
try {
|
|
20
|
-
await this.
|
|
21
|
-
const buffer = this.
|
|
23
|
+
await this.#writeLock.wait();
|
|
24
|
+
const buffer = this.#combiner.flush();
|
|
22
25
|
if (buffer) {
|
|
23
|
-
await this
|
|
26
|
+
await this.#writeInnerStream(buffer);
|
|
24
27
|
}
|
|
25
28
|
}
|
|
26
29
|
finally {
|
|
27
|
-
this.
|
|
30
|
+
this.#writeLock.notifyOne();
|
|
28
31
|
}
|
|
29
32
|
}
|
|
30
33
|
async write(data) {
|
|
31
34
|
try {
|
|
32
|
-
await this.
|
|
33
|
-
for (const buffer of this.
|
|
34
|
-
await this
|
|
35
|
+
await this.#writeLock.wait();
|
|
36
|
+
for (const buffer of this.#combiner.push(data)) {
|
|
37
|
+
await this.#writeInnerStream(buffer);
|
|
35
38
|
}
|
|
36
39
|
}
|
|
37
40
|
finally {
|
|
38
|
-
this.
|
|
41
|
+
this.#writeLock.notifyOne();
|
|
39
42
|
}
|
|
40
43
|
}
|
|
41
|
-
async
|
|
44
|
+
async readExactly(length) {
|
|
42
45
|
await this.flush();
|
|
43
|
-
return await this.
|
|
46
|
+
return await this.#readable.readExactly(length);
|
|
44
47
|
}
|
|
45
48
|
release() {
|
|
46
|
-
this.
|
|
47
|
-
this.
|
|
49
|
+
this.#combiner.flush();
|
|
50
|
+
this.#socketLock.notifyOne();
|
|
48
51
|
}
|
|
49
52
|
}
|
|
50
53
|
export class AdbSyncSocket {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
#lock = new AutoResetEvent();
|
|
55
|
+
#socket;
|
|
56
|
+
#locked;
|
|
54
57
|
constructor(socket, bufferSize) {
|
|
55
|
-
this
|
|
56
|
-
this
|
|
58
|
+
this.#socket = socket;
|
|
59
|
+
this.#locked = new AdbSyncSocketLocked(socket.writable.getWriter(), new BufferedReadableStream(socket.readable), bufferSize, this.#lock);
|
|
57
60
|
}
|
|
58
61
|
async lock() {
|
|
59
|
-
await this.
|
|
60
|
-
return this
|
|
62
|
+
await this.#lock.wait();
|
|
63
|
+
return this.#locked;
|
|
61
64
|
}
|
|
62
65
|
async close() {
|
|
63
|
-
await this.
|
|
66
|
+
await this.#socket.close();
|
|
64
67
|
}
|
|
65
68
|
}
|
|
66
69
|
//# sourceMappingURL=socket.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket.js","sourceRoot":"","sources":["../../../src/commands/sync/socket.ts"],"names":[],"mappings":"AAIA,OAAO,EACH,cAAc,EACd,sBAAsB,EACtB,wBAAwB,GAC3B,MAAM,yBAAyB,CAAC;AAIjC,OAAO,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"socket.js","sourceRoot":"","sources":["../../../src/commands/sync/socket.ts"],"names":[],"mappings":"AAIA,OAAO,EACH,cAAc,EACd,sBAAsB,EACtB,wBAAwB,GAC3B,MAAM,yBAAyB,CAAC;AAIjC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,OAAO,mBAAmB;IACnB,OAAO,CAAsD;IAC7D,SAAS,CAAyB;IAClC,WAAW,CAAiB;IAC5B,UAAU,GAAG,IAAI,cAAc,EAAE,CAAC;IAClC,SAAS,CAAiB;IAEnC,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;IACnC,CAAC;IAED,YACI,MAA2D,EAC3D,QAAgC,EAChC,UAAkB,EAClB,IAAoB;QAEpB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,SAAS,GAAG,IAAI,cAAc,CAAC,UAAU,CAAC,CAA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AAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,mBAAmB,CAClC,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE,EAC3B,IAAI,sBAAsB,CAAC,MAAM,CAAC,QAAQ,CAAC,EAC3C,UAAU,EACV,IAAI,CAAC,KAAK,CACb,CAAC;IACN,CAAC;IAED,KAAK,CAAC,IAAI;QACN,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,KAAK;QACP,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IAC/B,CAAC;CACJ"}
|
|
@@ -7,7 +7,7 @@ export var LinuxFileType;
|
|
|
7
7
|
LinuxFileType[LinuxFileType["Directory"] = 4] = "Directory";
|
|
8
8
|
LinuxFileType[LinuxFileType["File"] = 8] = "File";
|
|
9
9
|
LinuxFileType[LinuxFileType["Link"] = 10] = "Link";
|
|
10
|
-
})(LinuxFileType
|
|
10
|
+
})(LinuxFileType || (LinuxFileType = {}));
|
|
11
11
|
export const AdbSyncLstatResponse = new Struct({ littleEndian: true })
|
|
12
12
|
.int32("mode")
|
|
13
13
|
.int32("size")
|
|
@@ -18,7 +18,7 @@ export const AdbSyncLstatResponse = new Struct({ littleEndian: true })
|
|
|
18
18
|
return (this.mode >> 12);
|
|
19
19
|
},
|
|
20
20
|
get permission() {
|
|
21
|
-
return this.mode &
|
|
21
|
+
return this.mode & 0b00001111_11111111;
|
|
22
22
|
},
|
|
23
23
|
})
|
|
24
24
|
.postDeserialize((object) => {
|
|
@@ -49,7 +49,7 @@ export var AdbSyncStatErrorCode;
|
|
|
49
49
|
AdbSyncStatErrorCode[AdbSyncStatErrorCode["EPERM"] = 1] = "EPERM";
|
|
50
50
|
AdbSyncStatErrorCode[AdbSyncStatErrorCode["EROFS"] = 30] = "EROFS";
|
|
51
51
|
AdbSyncStatErrorCode[AdbSyncStatErrorCode["ETXTBSY"] = 26] = "ETXTBSY";
|
|
52
|
-
})(AdbSyncStatErrorCode
|
|
52
|
+
})(AdbSyncStatErrorCode || (AdbSyncStatErrorCode = {}));
|
|
53
53
|
export const AdbSyncStatResponse = new Struct({ littleEndian: true })
|
|
54
54
|
.uint32("error", placeholder())
|
|
55
55
|
.uint64("dev")
|
|
@@ -68,7 +68,7 @@ export const AdbSyncStatResponse = new Struct({ littleEndian: true })
|
|
|
68
68
|
return (this.mode >> 12);
|
|
69
69
|
},
|
|
70
70
|
get permission() {
|
|
71
|
-
return this.mode &
|
|
71
|
+
return this.mode & 0b00001111_11111111;
|
|
72
72
|
},
|
|
73
73
|
})
|
|
74
74
|
.postDeserialize((object) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stat.js","sourceRoot":"","sources":["../../../src/commands/sync/stat.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGvE,kGAAkG;AAClG,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACrB,2DAAgB,CAAA;IAChB,iDAAW,CAAA;IACX,kDAAW,CAAA;AACf,CAAC,EAJW,aAAa,
|
|
1
|
+
{"version":3,"file":"stat.js","sourceRoot":"","sources":["../../../src/commands/sync/stat.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGvE,kGAAkG;AAClG,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,a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H,MAAM,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YAChE,MAAM,QAAQ,GAAG,MAAM,mBAAmB,CACtC,MAAM,EACN,iBAAiB,CAAC,KAAK,EACvB,oBAAoB,CACvB,CAAC;YACF,OAAO;gBACH,IAAI,EAAE,QAAQ,CAAC,IAAI;gBACnB,uEAAuE;gBACvE,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;gBAC3B,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;gBAC7B,IAAI,IAAI;oBACJ,OAAO,QAAQ,CAAC,IAAI,CAAC;gBACzB,CAAC;gBACD,IAAI,UAAU;oBACV,OAAO,QAAQ,CAAC,UAAU,CAAC;gBAC/B,CAAC;aACJ,CAAC;SACL;KACJ;YAAS;QACN,MAAM,CAAC,OAAO,EAAE,CAAC;KACpB;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAC7B,MAAqB,EACrB,IAAY;IAEZ,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;IACnC,IAAI;QACA,MAAM,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC/D,OAAO,MAAM,mBAAmB,CAC5B,MAAM,EACN,iBAAiB,CAAC,IAAI,EACtB,mBAAmB,CACtB,CAAC;KACL;YAAS;QACN,MAAM,CAAC,OAAO,EAAE,CAAC;KACpB;AACL,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AutoDisposable } from "@yume-chan/event";
|
|
2
2
|
import type { Consumable, ReadableStream } from "@yume-chan/stream-extra";
|
|
3
|
-
import type { Adb } from "../../adb.js";
|
|
4
|
-
import type { AdbSocket } from "../../socket/index.js";
|
|
3
|
+
import type { Adb, AdbSocket } from "../../adb.js";
|
|
5
4
|
import type { AdbSyncEntry } from "./list.js";
|
|
6
5
|
import { AdbSyncSocket } from "./socket.js";
|
|
6
|
+
import type { AdbSyncStat, LinuxFileType } from "./stat.js";
|
|
7
7
|
/**
|
|
8
8
|
* A simplified `dirname` function that only handles absolute unix paths.
|
|
9
9
|
* @param path an absolute unix path
|
|
@@ -13,28 +13,35 @@ export declare function dirname(path: string): string;
|
|
|
13
13
|
export interface AdbSyncWriteOptions {
|
|
14
14
|
filename: string;
|
|
15
15
|
file: ReadableStream<Consumable<Uint8Array>>;
|
|
16
|
-
|
|
16
|
+
type?: LinuxFileType;
|
|
17
|
+
permission?: number;
|
|
17
18
|
mtime?: number;
|
|
18
19
|
dryRun?: boolean;
|
|
19
20
|
}
|
|
20
21
|
export declare class AdbSync extends AutoDisposable {
|
|
22
|
+
#private;
|
|
21
23
|
protected _adb: Adb;
|
|
22
24
|
protected _socket: AdbSyncSocket;
|
|
23
|
-
private _supportsStat;
|
|
24
|
-
private _supportsListV2;
|
|
25
|
-
private _fixedPushMkdir;
|
|
26
|
-
private _supportsSendReceiveV2;
|
|
27
|
-
private _needPushMkdirWorkaround;
|
|
28
25
|
get supportsStat(): boolean;
|
|
29
26
|
get supportsListV2(): boolean;
|
|
30
27
|
get fixedPushMkdir(): boolean;
|
|
31
28
|
get supportsSendReceiveV2(): boolean;
|
|
32
29
|
get needPushMkdirWorkaround(): boolean;
|
|
33
30
|
constructor(adb: Adb, socket: AdbSocket);
|
|
34
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Gets information of a file or folder.
|
|
33
|
+
*
|
|
34
|
+
* If `path` points to a symbolic link, the returned information is about the link itself (with `type` being `LinuxFileType.Link`).
|
|
35
|
+
*/
|
|
36
|
+
lstat(path: string): Promise<AdbSyncStat>;
|
|
37
|
+
/**
|
|
38
|
+
* Gets the information of a file or folder.
|
|
39
|
+
*
|
|
40
|
+
* If `path` points to a symbolic link, it will be resolved and the returned information is about the target (with `type` being `LinuxFileType.File` or `LinuxFileType.Directory`).
|
|
41
|
+
*/
|
|
35
42
|
stat(path: string): Promise<{
|
|
36
43
|
id: import("./response.js").AdbSyncResponseId.Stat;
|
|
37
|
-
readonly type:
|
|
44
|
+
readonly type: LinuxFileType;
|
|
38
45
|
readonly permission: number;
|
|
39
46
|
error: import("./stat.js").AdbSyncStatErrorCode;
|
|
40
47
|
dev: bigint;
|
|
@@ -48,24 +55,25 @@ export declare class AdbSync extends AutoDisposable {
|
|
|
48
55
|
mtime: bigint;
|
|
49
56
|
ctime: bigint;
|
|
50
57
|
}>;
|
|
58
|
+
/**
|
|
59
|
+
* Checks if `path` is a directory, or a symbolic link to a directory.
|
|
60
|
+
*
|
|
61
|
+
* This uses `lstat` internally, thus works on all Android versions.
|
|
62
|
+
*/
|
|
51
63
|
isDirectory(path: string): Promise<boolean>;
|
|
52
64
|
opendir(path: string): AsyncGenerator<AdbSyncEntry, void, void>;
|
|
53
65
|
readdir(path: string): Promise<AdbSyncEntry[]>;
|
|
54
66
|
/**
|
|
55
|
-
*
|
|
67
|
+
* Reads the content of a file on device.
|
|
56
68
|
*
|
|
57
69
|
* @param filename The full path of the file on device to read.
|
|
58
|
-
* @returns A `ReadableStream` that
|
|
70
|
+
* @returns A `ReadableStream` that contains the file content.
|
|
59
71
|
*/
|
|
60
72
|
read(filename: string): ReadableStream<Uint8Array>;
|
|
61
73
|
/**
|
|
62
|
-
*
|
|
74
|
+
* Writes a file on device. If the file name already exists, it will be overwritten.
|
|
63
75
|
*
|
|
64
|
-
* @param
|
|
65
|
-
* @param file The content to write.
|
|
66
|
-
* @param mode The unix permissions of the file.
|
|
67
|
-
* @param mtime The modified time of the file.
|
|
68
|
-
* @returns A `WritableStream` that writes to the file.
|
|
76
|
+
* @param options The content and options of the file to write.
|
|
69
77
|
*/
|
|
70
78
|
write(options: AdbSyncWriteOptions): Promise<void>;
|
|
71
79
|
dispose(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/sync.ts"],"names":[],"mappings":"A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nC;IAED,IAAI,uBAAuB,IAAI,OAAO,CAErC;gBAEW,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS;IAkBvC;;;;OAIG;IACG,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAI/C;;;;OAIG;IACG,IAAI,CAAC,IAAI,EAAE,MAAM;;;;;;;;;;;;;;;;IAQvB;;;;OAIG;IACG,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IASjD,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAAC,YAAY,EAAE,IAAI,EAAE,IAAI,CAAC;IAIzD,OAAO,CAAC,IAAI,EAAE,MAAM;IAQ1B;;;;;OAKG;IACH,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,CAAC,UAAU,CAAC;IAIlD;;;;OAIG;IACG,KAAK,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBzC,OAAO;CAIzB"}
|
|
@@ -24,48 +24,63 @@ export function dirname(path) {
|
|
|
24
24
|
export class AdbSync extends AutoDisposable {
|
|
25
25
|
_adb;
|
|
26
26
|
_socket;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
#supportsStat;
|
|
28
|
+
#supportsListV2;
|
|
29
|
+
#fixedPushMkdir;
|
|
30
|
+
#supportsSendReceiveV2;
|
|
31
|
+
#needPushMkdirWorkaround;
|
|
32
32
|
get supportsStat() {
|
|
33
|
-
return this
|
|
33
|
+
return this.#supportsStat;
|
|
34
34
|
}
|
|
35
35
|
get supportsListV2() {
|
|
36
|
-
return this
|
|
36
|
+
return this.#supportsListV2;
|
|
37
37
|
}
|
|
38
38
|
get fixedPushMkdir() {
|
|
39
|
-
return this
|
|
39
|
+
return this.#fixedPushMkdir;
|
|
40
40
|
}
|
|
41
41
|
get supportsSendReceiveV2() {
|
|
42
|
-
return this
|
|
42
|
+
return this.#supportsSendReceiveV2;
|
|
43
43
|
}
|
|
44
44
|
get needPushMkdirWorkaround() {
|
|
45
|
-
return this
|
|
45
|
+
return this.#needPushMkdirWorkaround;
|
|
46
46
|
}
|
|
47
47
|
constructor(adb, socket) {
|
|
48
48
|
super();
|
|
49
49
|
this._adb = adb;
|
|
50
50
|
this._socket = new AdbSyncSocket(socket, adb.maxPayloadSize);
|
|
51
|
-
this
|
|
52
|
-
this
|
|
53
|
-
this
|
|
54
|
-
this
|
|
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
55
|
// https://android.googlesource.com/platform/packages/modules/adb/+/91768a57b7138166e0a3d11f79cd55909dda7014/client/file_sync_client.cpp#1361
|
|
56
|
-
this
|
|
56
|
+
this.#needPushMkdirWorkaround =
|
|
57
57
|
this._adb.supportsFeature(AdbFeature.ShellV2) &&
|
|
58
58
|
!this.fixedPushMkdir;
|
|
59
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Gets information of a file or folder.
|
|
62
|
+
*
|
|
63
|
+
* If `path` points to a symbolic link, the returned information is about the link itself (with `type` being `LinuxFileType.Link`).
|
|
64
|
+
*/
|
|
60
65
|
async lstat(path) {
|
|
61
|
-
return await adbSyncLstat(this._socket, path, this
|
|
66
|
+
return await adbSyncLstat(this._socket, path, this.#supportsStat);
|
|
62
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Gets the information of a file or folder.
|
|
70
|
+
*
|
|
71
|
+
* If `path` points to a symbolic link, it will be resolved and the returned information is about the target (with `type` being `LinuxFileType.File` or `LinuxFileType.Directory`).
|
|
72
|
+
*/
|
|
63
73
|
async stat(path) {
|
|
64
|
-
if (!this
|
|
74
|
+
if (!this.#supportsStat) {
|
|
65
75
|
throw new Error("Not supported");
|
|
66
76
|
}
|
|
67
77
|
return await adbSyncStat(this._socket, path);
|
|
68
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Checks if `path` is a directory, or a symbolic link to a directory.
|
|
81
|
+
*
|
|
82
|
+
* This uses `lstat` internally, thus works on all Android versions.
|
|
83
|
+
*/
|
|
69
84
|
async isDirectory(path) {
|
|
70
85
|
try {
|
|
71
86
|
await this.lstat(path + "/");
|
|
@@ -86,22 +101,18 @@ export class AdbSync extends AutoDisposable {
|
|
|
86
101
|
return results;
|
|
87
102
|
}
|
|
88
103
|
/**
|
|
89
|
-
*
|
|
104
|
+
* Reads the content of a file on device.
|
|
90
105
|
*
|
|
91
106
|
* @param filename The full path of the file on device to read.
|
|
92
|
-
* @returns A `ReadableStream` that
|
|
107
|
+
* @returns A `ReadableStream` that contains the file content.
|
|
93
108
|
*/
|
|
94
109
|
read(filename) {
|
|
95
110
|
return adbSyncPull(this._socket, filename);
|
|
96
111
|
}
|
|
97
112
|
/**
|
|
98
|
-
*
|
|
113
|
+
* Writes a file on device. If the file name already exists, it will be overwritten.
|
|
99
114
|
*
|
|
100
|
-
* @param
|
|
101
|
-
* @param file The content to write.
|
|
102
|
-
* @param mode The unix permissions of the file.
|
|
103
|
-
* @param mtime The modified time of the file.
|
|
104
|
-
* @returns A `WritableStream` that writes to the file.
|
|
115
|
+
* @param options The content and options of the file to write.
|
|
105
116
|
*/
|
|
106
117
|
async write(options) {
|
|
107
118
|
if (this.needPushMkdirWorkaround) {
|
|
@@ -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;AAIlD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"sync.js","sourceRoot":"","sources":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cpip.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AdbCommandBase } from "./base.js";
|
|
2
2
|
export declare class AdbTcpIpCommand extends AdbCommandBase {
|
|
3
|
-
setPort(port: number): Promise<
|
|
4
|
-
disable(): Promise<
|
|
3
|
+
setPort(port: number): Promise<string>;
|
|
4
|
+
disable(): Promise<string>;
|
|
5
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;
|
|
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;IACzC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAYtC,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;CAOnC"}
|
package/esm/commands/tcpip.js
CHANGED
|
@@ -6,14 +6,16 @@ export class AdbTcpIpCommand extends AdbCommandBase {
|
|
|
6
6
|
}
|
|
7
7
|
const output = await this.adb.createSocketAndWait(`tcpip:${port}`);
|
|
8
8
|
if (output !== `restarting in TCP mode port: ${port}\n`) {
|
|
9
|
-
throw new Error(
|
|
9
|
+
throw new Error(output);
|
|
10
10
|
}
|
|
11
|
+
return output;
|
|
11
12
|
}
|
|
12
13
|
async disable() {
|
|
13
14
|
const output = await this.adb.createSocketAndWait("usb:");
|
|
14
15
|
if (output !== "restarting in USB mode\n") {
|
|
15
|
-
throw new Error(
|
|
16
|
+
throw new Error(output);
|
|
16
17
|
}
|
|
18
|
+
return output;
|
|
17
19
|
}
|
|
18
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;
|
|
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;IAC/C,KAAK,CAAC,OAAO,CAAC,IAAY;QACtB,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;IAED,KAAK,CAAC,OAAO;QACT,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,16 +1,21 @@
|
|
|
1
1
|
import type { Disposable } from "@yume-chan/event";
|
|
2
2
|
import type { ValueOrPromise } from "@yume-chan/struct";
|
|
3
3
|
import type { AdbPacketData } from "./packet.js";
|
|
4
|
-
export
|
|
4
|
+
export interface AdbPrivateKey {
|
|
5
|
+
/**
|
|
6
|
+
* The private key in PKCS #8 format.
|
|
7
|
+
*/
|
|
8
|
+
buffer: Uint8Array;
|
|
9
|
+
name?: string | undefined;
|
|
10
|
+
}
|
|
11
|
+
export type AdbKeyIterable = Iterable<AdbPrivateKey> | AsyncIterable<AdbPrivateKey>;
|
|
5
12
|
export interface AdbCredentialStore {
|
|
6
13
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* The returned `Uint8Array` is the private key in PKCS #8 format.
|
|
14
|
+
* Generates and stores a RSA private key with modulus length `2048` and public exponent `65537`.
|
|
10
15
|
*/
|
|
11
|
-
generateKey(): ValueOrPromise<
|
|
16
|
+
generateKey(): ValueOrPromise<AdbPrivateKey>;
|
|
12
17
|
/**
|
|
13
|
-
* Synchronously or asynchronously
|
|
18
|
+
* Synchronously or asynchronously iterates through all stored RSA private keys.
|
|
14
19
|
*
|
|
15
20
|
* Each call to `iterateKeys` must return a different iterator that iterate through all stored keys.
|
|
16
21
|
*/
|
|
@@ -39,13 +44,9 @@ export declare const AdbSignatureAuthenticator: AdbAuthenticator;
|
|
|
39
44
|
export declare const AdbPublicKeyAuthenticator: AdbAuthenticator;
|
|
40
45
|
export declare const ADB_DEFAULT_AUTHENTICATORS: AdbAuthenticator[];
|
|
41
46
|
export declare class AdbAuthenticationProcessor implements Disposable {
|
|
47
|
+
#private;
|
|
42
48
|
readonly authenticators: readonly AdbAuthenticator[];
|
|
43
|
-
private readonly credentialStore;
|
|
44
|
-
private pendingRequest;
|
|
45
|
-
private iterator;
|
|
46
49
|
constructor(authenticators: readonly AdbAuthenticator[], credentialStore: AdbCredentialStore);
|
|
47
|
-
private getNextRequest;
|
|
48
|
-
private invokeAuthenticator;
|
|
49
50
|
process(packet: AdbPacketData): Promise<AdbPacketData>;
|
|
50
51
|
dispose(): void;
|
|
51
52
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/daemon/auth.ts"],"names":[],"mappings":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async";
|
|
2
|
-
import {
|
|
2
|
+
import { EMPTY_UINT8_ARRAY } from "@yume-chan/struct";
|
|
3
|
+
import { calculateBase64EncodedLength, encodeBase64, encodeUtf8, } from "../utils/index.js";
|
|
4
|
+
import { adbGeneratePublicKey, adbGetPublicKeySize, rsaSign, } from "./crypto.js";
|
|
3
5
|
import { AdbCommand } from "./packet.js";
|
|
4
|
-
import { calculateBase64EncodedLength, encodeBase64 } from "./utils/index.js";
|
|
5
6
|
export var AdbAuthType;
|
|
6
7
|
(function (AdbAuthType) {
|
|
7
8
|
AdbAuthType[AdbAuthType["Token"] = 1] = "Token";
|
|
8
9
|
AdbAuthType[AdbAuthType["Signature"] = 2] = "Signature";
|
|
9
10
|
AdbAuthType[AdbAuthType["PublicKey"] = 3] = "PublicKey";
|
|
10
|
-
})(AdbAuthType
|
|
11
|
+
})(AdbAuthType || (AdbAuthType = {}));
|
|
11
12
|
export const AdbSignatureAuthenticator = async function* (credentialStore, getNextRequest) {
|
|
12
13
|
for await (const key of credentialStore.iterateKeys()) {
|
|
13
14
|
const packet = await getNextRequest();
|
|
14
15
|
if (packet.arg0 !== AdbAuthType.Token) {
|
|
15
16
|
return;
|
|
16
17
|
}
|
|
17
|
-
const signature =
|
|
18
|
+
const signature = rsaSign(key.buffer, packet.payload);
|
|
18
19
|
yield {
|
|
19
20
|
command: AdbCommand.Auth,
|
|
20
21
|
arg0: AdbAuthType.Signature,
|
|
@@ -36,12 +37,20 @@ export const AdbPublicKeyAuthenticator = async function* (credentialStore, getNe
|
|
|
36
37
|
if (!privateKey) {
|
|
37
38
|
privateKey = await credentialStore.generateKey();
|
|
38
39
|
}
|
|
39
|
-
const publicKeyLength =
|
|
40
|
+
const publicKeyLength = adbGetPublicKeySize();
|
|
40
41
|
const [publicKeyBase64Length] = calculateBase64EncodedLength(publicKeyLength);
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
const nameBuffer = privateKey.name?.length
|
|
43
|
+
? encodeUtf8(privateKey.name)
|
|
44
|
+
: EMPTY_UINT8_ARRAY;
|
|
45
|
+
const publicKeyBuffer = new Uint8Array(publicKeyBase64Length +
|
|
46
|
+
(nameBuffer.length ? nameBuffer.length + 1 : 0) + // Space character + name
|
|
47
|
+
1);
|
|
48
|
+
adbGeneratePublicKey(privateKey.buffer, publicKeyBuffer);
|
|
44
49
|
encodeBase64(publicKeyBuffer.subarray(0, publicKeyLength), publicKeyBuffer);
|
|
50
|
+
if (nameBuffer.length) {
|
|
51
|
+
publicKeyBuffer[publicKeyBase64Length] = 0x20;
|
|
52
|
+
publicKeyBuffer.set(nameBuffer, publicKeyBase64Length + 1);
|
|
53
|
+
}
|
|
45
54
|
yield {
|
|
46
55
|
command: AdbCommand.Auth,
|
|
47
56
|
arg0: AdbAuthType.PublicKey,
|
|
@@ -55,22 +64,22 @@ export const ADB_DEFAULT_AUTHENTICATORS = [
|
|
|
55
64
|
];
|
|
56
65
|
export class AdbAuthenticationProcessor {
|
|
57
66
|
authenticators;
|
|
58
|
-
credentialStore;
|
|
59
|
-
pendingRequest = new PromiseResolver();
|
|
60
|
-
iterator;
|
|
67
|
+
#credentialStore;
|
|
68
|
+
#pendingRequest = new PromiseResolver();
|
|
69
|
+
#iterator;
|
|
61
70
|
constructor(authenticators, credentialStore) {
|
|
62
71
|
this.authenticators = authenticators;
|
|
63
|
-
this
|
|
72
|
+
this.#credentialStore = credentialStore;
|
|
64
73
|
}
|
|
65
|
-
getNextRequest = () => {
|
|
66
|
-
return this
|
|
74
|
+
#getNextRequest = () => {
|
|
75
|
+
return this.#pendingRequest.promise;
|
|
67
76
|
};
|
|
68
|
-
async
|
|
77
|
+
async *#invokeAuthenticator() {
|
|
69
78
|
for (const authenticator of this.authenticators) {
|
|
70
|
-
for await (const packet of authenticator(this
|
|
79
|
+
for await (const packet of authenticator(this.#credentialStore, this.#getNextRequest)) {
|
|
71
80
|
// If the authenticator yielded a response
|
|
72
81
|
// Prepare `nextRequest` for next authentication request
|
|
73
|
-
this
|
|
82
|
+
this.#pendingRequest = new PromiseResolver();
|
|
74
83
|
// Yield the response to outer layer
|
|
75
84
|
yield packet;
|
|
76
85
|
}
|
|
@@ -79,18 +88,18 @@ export class AdbAuthenticationProcessor {
|
|
|
79
88
|
}
|
|
80
89
|
}
|
|
81
90
|
async process(packet) {
|
|
82
|
-
if (!this
|
|
83
|
-
this
|
|
91
|
+
if (!this.#iterator) {
|
|
92
|
+
this.#iterator = this.#invokeAuthenticator();
|
|
84
93
|
}
|
|
85
|
-
this
|
|
86
|
-
const result = await this
|
|
94
|
+
this.#pendingRequest.resolve(packet);
|
|
95
|
+
const result = await this.#iterator.next();
|
|
87
96
|
if (result.done) {
|
|
88
97
|
throw new Error("No authenticator can handle the request");
|
|
89
98
|
}
|
|
90
99
|
return result.value;
|
|
91
100
|
}
|
|
92
101
|
dispose() {
|
|
93
|
-
void this
|
|
102
|
+
void this.#iterator?.return?.();
|
|
94
103
|
}
|
|
95
104
|
}
|
|
96
105
|
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/daemon/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EACH,4BAA4B,EAC5B,YAAY,EACZ,UAAU,GACb,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACH,oBAAoB,EACpB,mBAAmB,EACnB,OAAO,GACV,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA4BzC,MAAM,CAAN,IAAY,WAIX;AAJD,WAAY,WAAW;IACnB,+CAAS,CAAA;IACT,uDAAa,CAAA;IACb,uDAAa,CAAA;AACjB,CAAC,EAJW,WAAW,KAAX,WAAW,QAItB;AAoBD,MAAM,CAAC,MAAM,yBAAyB,GAAqB,KAA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AAM,MAAM,IAAI,aAAa,CACpC,IAAI,CAAC,gBAAgB,EACrB,IAAI,CAAC,eAAe,CACvB,EAAE;gBACC,0CAA0C;gBAC1C,wDAAwD;gBACxD,IAAI,CAAC,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;gBAE7C,oCAAoC;gBACpC,MAAM,MAAM,CAAC;aAChB;YAED,iCAAiC;YACjC,6DAA6D;SAChE;IACL,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,MAAqB;QAC/B,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACjB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;SAChD;QAED,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAErC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;QAC3C,IAAI,MAAM,CAAC,IAAI,EAAE;YACb,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;SAC9D;QAED,OAAO,MAAM,CAAC,KAAK,CAAC;IACxB,CAAC;IAED,OAAO;QACH,KAAK,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC;IACpC,CAAC;CACJ"}
|
|
@@ -14,11 +14,11 @@ export declare function getBigUint(dataView: DataView, byteOffset: number, lengt
|
|
|
14
14
|
* otherwise a little-endian value should be written.
|
|
15
15
|
*/
|
|
16
16
|
export declare function setBigUint(dataView: DataView, byteOffset: number, value: bigint, littleEndian?: boolean): number;
|
|
17
|
-
export declare function
|
|
17
|
+
export declare function rsaParsePrivateKey(key: Uint8Array): [n: bigint, d: bigint];
|
|
18
18
|
export declare function modInverse(a: number, m: number): number;
|
|
19
|
-
export declare function
|
|
20
|
-
export declare function
|
|
21
|
-
export declare function
|
|
19
|
+
export declare function adbGetPublicKeySize(): number;
|
|
20
|
+
export declare function adbGeneratePublicKey(privateKey: Uint8Array): Uint8Array;
|
|
21
|
+
export declare function adbGeneratePublicKey(privateKey: Uint8Array, output: Uint8Array): number;
|
|
22
22
|
/**
|
|
23
23
|
* Modular exponentiation.
|
|
24
24
|
*
|
|
@@ -33,5 +33,5 @@ export declare const ASN1_OCTET_STRING = 4;
|
|
|
33
33
|
export declare const ASN1_NULL = 5;
|
|
34
34
|
export declare const ASN1_OID = 6;
|
|
35
35
|
export declare const SHA1_DIGEST_INFO: Uint8Array;
|
|
36
|
-
export declare function
|
|
36
|
+
export declare function rsaSign(privateKey: Uint8Array, data: Uint8Array): Uint8Array;
|
|
37
37
|
//# sourceMappingURL=crypto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../src/daemon/crypto.ts"],"names":[],"mappings":"AAKA;;;;;;GAMG;AACH,wBAAgB,UAAU,CACtB,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GACf,MAAM,CAaR;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CACtB,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,OAAO,UA0BzB;AA4BD,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,UAAU,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAK1E;AAKD,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,UAsB9C;AAED,wBAAgB,mBAAmB,WAElC;AAED,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,CAAC;AACzE,wBAAgB,oBAAoB,CAChC,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,UAAU,GACnB,MAAM,CAAC;AA2EV;;;;;;GAMG;AACH,wBAAgB,MAAM,CAClB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE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