@yume-chan/adb 0.0.12 → 0.0.13

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.
Files changed (130) hide show
  1. package/CHANGELOG.json +18 -0
  2. package/CHANGELOG.md +10 -1
  3. package/README.md +24 -17
  4. package/esm/adb.d.ts +6 -6
  5. package/esm/adb.d.ts.map +1 -1
  6. package/esm/adb.js +77 -59
  7. package/esm/adb.js.map +1 -1
  8. package/esm/auth.d.ts +6 -6
  9. package/esm/auth.d.ts.map +1 -1
  10. package/esm/auth.js +8 -6
  11. package/esm/auth.js.map +1 -1
  12. package/esm/backend.d.ts +2 -2
  13. package/esm/commands/install.d.ts.map +1 -1
  14. package/esm/commands/install.js +5 -7
  15. package/esm/commands/install.js.map +1 -1
  16. package/esm/commands/reverse.d.ts +2 -2
  17. package/esm/commands/subprocess/index.d.ts +19 -20
  18. package/esm/commands/subprocess/index.d.ts.map +1 -1
  19. package/esm/commands/subprocess/index.js +36 -31
  20. package/esm/commands/subprocess/index.js.map +1 -1
  21. package/esm/commands/subprocess/legacy.d.ts +14 -7
  22. package/esm/commands/subprocess/legacy.d.ts.map +1 -1
  23. package/esm/commands/subprocess/legacy.js +14 -5
  24. package/esm/commands/subprocess/legacy.js.map +1 -1
  25. package/esm/commands/subprocess/protocol.d.ts +3 -2
  26. package/esm/commands/subprocess/protocol.d.ts.map +1 -1
  27. package/esm/commands/subprocess/protocol.js +6 -4
  28. package/esm/commands/subprocess/protocol.js.map +1 -1
  29. package/esm/commands/subprocess/protocols/index.d.ts +4 -0
  30. package/esm/commands/subprocess/protocols/index.d.ts.map +1 -0
  31. package/esm/commands/subprocess/protocols/index.js +4 -0
  32. package/esm/commands/subprocess/protocols/index.js.map +1 -0
  33. package/esm/commands/subprocess/protocols/none.d.ts +35 -0
  34. package/esm/commands/subprocess/protocols/none.d.ts.map +1 -0
  35. package/esm/commands/subprocess/protocols/none.js +53 -0
  36. package/esm/commands/subprocess/protocols/none.js.map +1 -0
  37. package/esm/commands/subprocess/protocols/shell.d.ts +39 -0
  38. package/esm/commands/subprocess/protocols/shell.d.ts.map +1 -0
  39. package/esm/commands/subprocess/protocols/shell.js +155 -0
  40. package/esm/commands/subprocess/protocols/shell.js.map +1 -0
  41. package/esm/commands/subprocess/protocols/types.d.ts +50 -0
  42. package/esm/commands/subprocess/protocols/types.d.ts.map +1 -0
  43. package/esm/commands/subprocess/protocols/types.js +2 -0
  44. package/esm/commands/subprocess/protocols/types.js.map +1 -0
  45. package/esm/commands/subprocess/types.d.ts +9 -6
  46. package/esm/commands/subprocess/types.d.ts.map +1 -1
  47. package/esm/commands/sync/list.d.ts +25 -1
  48. package/esm/commands/sync/list.d.ts.map +1 -1
  49. package/esm/commands/sync/list.js +40 -5
  50. package/esm/commands/sync/list.js.map +1 -1
  51. package/esm/commands/sync/request.d.ts +1 -0
  52. package/esm/commands/sync/request.d.ts.map +1 -1
  53. package/esm/commands/sync/request.js +1 -0
  54. package/esm/commands/sync/request.js.map +1 -1
  55. package/esm/commands/sync/response.d.ts +2 -1
  56. package/esm/commands/sync/response.d.ts.map +1 -1
  57. package/esm/commands/sync/response.js +2 -1
  58. package/esm/commands/sync/response.js.map +1 -1
  59. package/esm/commands/sync/stat.d.ts +13 -1
  60. package/esm/commands/sync/stat.d.ts.map +1 -1
  61. package/esm/commands/sync/stat.js +20 -7
  62. package/esm/commands/sync/stat.js.map +1 -1
  63. package/esm/commands/sync/sync.d.ts +13 -35
  64. package/esm/commands/sync/sync.d.ts.map +1 -1
  65. package/esm/commands/sync/sync.js +39 -9
  66. package/esm/commands/sync/sync.js.map +1 -1
  67. package/esm/crypto.d.ts +23 -10
  68. package/esm/crypto.d.ts.map +1 -1
  69. package/esm/crypto.js +64 -46
  70. package/esm/crypto.js.map +1 -1
  71. package/esm/features.d.ts +4 -2
  72. package/esm/features.d.ts.map +1 -1
  73. package/esm/features.js +6 -2
  74. package/esm/features.js.map +1 -1
  75. package/esm/packet.d.ts +21 -2
  76. package/esm/packet.d.ts.map +1 -1
  77. package/esm/packet.js +2 -2
  78. package/esm/packet.js.map +1 -1
  79. package/esm/socket/dispatcher.d.ts +15 -11
  80. package/esm/socket/dispatcher.d.ts.map +1 -1
  81. package/esm/socket/dispatcher.js +16 -19
  82. package/esm/socket/dispatcher.js.map +1 -1
  83. package/esm/socket/socket.d.ts +19 -7
  84. package/esm/socket/socket.d.ts.map +1 -1
  85. package/esm/socket/socket.js +20 -11
  86. package/esm/socket/socket.js.map +1 -1
  87. package/esm/stream/detect.d.ts +1 -17
  88. package/esm/stream/detect.d.ts.map +1 -1
  89. package/esm/stream/detect.js +4 -5
  90. package/esm/stream/detect.js.map +1 -1
  91. package/esm/stream/detect.polyfill.d.ts.map +1 -1
  92. package/esm/stream/detect.polyfill.js +4 -1
  93. package/esm/stream/detect.polyfill.js.map +1 -1
  94. package/esm/stream/transform.d.ts +23 -23
  95. package/esm/stream/transform.d.ts.map +1 -1
  96. package/esm/stream/transform.js +74 -24
  97. package/esm/stream/transform.js.map +1 -1
  98. package/esm/utils/encoding.d.ts.map +1 -1
  99. package/esm/utils/encoding.js.map +1 -1
  100. package/esm/utils/index.d.ts +1 -1
  101. package/esm/utils/index.d.ts.map +1 -1
  102. package/esm/utils/index.js +1 -1
  103. package/esm/utils/index.js.map +1 -1
  104. package/package.json +6 -6
  105. package/src/adb.ts +93 -70
  106. package/src/auth.ts +21 -18
  107. package/src/backend.ts +2 -2
  108. package/src/commands/install.ts +7 -9
  109. package/src/commands/reverse.ts +2 -2
  110. package/src/commands/subprocess/index.ts +57 -42
  111. package/src/commands/subprocess/protocols/index.ts +3 -0
  112. package/src/commands/subprocess/{legacy.ts → protocols/none.ts} +18 -8
  113. package/src/commands/subprocess/{protocol.ts → protocols/shell.ts} +22 -17
  114. package/src/commands/subprocess/{types.ts → protocols/types.ts} +13 -9
  115. package/src/commands/sync/list.ts +51 -5
  116. package/src/commands/sync/request.ts +1 -0
  117. package/src/commands/sync/response.ts +8 -2
  118. package/src/commands/sync/stat.ts +36 -9
  119. package/src/commands/sync/sync.ts +55 -19
  120. package/src/crypto.ts +72 -56
  121. package/src/features.ts +6 -2
  122. package/src/packet.ts +17 -6
  123. package/src/socket/dispatcher.ts +43 -29
  124. package/src/socket/socket.ts +29 -22
  125. package/src/stream/detect.polyfill.ts +4 -1
  126. package/src/stream/detect.ts +4 -24
  127. package/src/stream/transform.ts +96 -40
  128. package/src/utils/index.ts +1 -1
  129. package/tsconfig.build.tsbuildinfo +1 -1
  130. package/src/utils/encoding.ts +0 -13
@@ -1 +1 @@
1
- {"version":3,"file":"transform.js","sourceRoot":"","sources":["../../src/stream/transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGnD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,eAAe,EAAe,cAAc,EAA+B,eAAe,EAAE,cAAc,EAAkK,MAAM,aAAa,CAAC;AAQzS,MAAM,OAAO,mBAAmB;IACpB,mBAAmB,GAAyC,EAAE,CAAC;IAC/D,uBAAuB,GAAsC,EAAE,CAAC;IAEhE,OAAO,GAAG,IAAI,eAAe,EAAQ,CAAC;IAC9C,IAAW,MAAM,KAAK,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAE5C,OAAO,CAA6B;IAEpC,yBAAyB,GAAG,KAAK,CAAC;IAClC,eAAe,GAAG,KAAK,CAAC;IAEhC,YAAmB,OAAoC;QACnD,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;IACjC,CAAC;IAEM,kBAAkB,CAAC,MAAmC,EAAE,QAA6B;QACxF,OAAO,IAAI,kBAAkB,CAAI,UAAU,CAAC,EAAE;YAC1C,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAE9C,UA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AAC,UAAU,CAAC,WAAW,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE;4BACpC,YAAY,GAAG,IAAI,eAAe,EAAQ,CAAC;4BAC3C,MAAM,YAAY,CAAC,OAAO,CAAC;yBAC9B;wBAED,+CAA+C;wBAC/C,oCAAoC;wBACpC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;oBAC9B,CAAC;oBACD,KAAK;wBACD,UAAU,CAAC,KAAK,EAAE,CAAC;oBACvB,CAAC;oBACD,KAAK,CAAC,CAAC;wBACH,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;oBACxB,CAAC;iBACJ,CAAC,CAAC;YACP,CAAC;YACD,IAAI,EAAE,GAAG,EAAE;gBACP,YAAY,EAAE,OAAO,EAAE,CAAC;YAC5B,CAAC;YACD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;gBACrB,QAAQ,CAAC,KAAK,EAAE,CAAC;gBACjB,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;YACjC,CAAC;SACJ,EAAE,QAAQ,CAAC,CAAC;IACjB,CAAC;CACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../../src/utils/encoding.ts"],"names":[],"mappings":"AAMA,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAEpD;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,eAAe,GAAG,WAAW,GAAG,MAAM,CAExE"}
1
+ {"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../../src/utils/encoding.ts"],"names":[],"mappings":"AAKA,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAEpD;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,eAAe,GAAG,WAAW,GAAG,MAAM,CAExE"}
@@ -1 +1 @@
1
- {"version":3,"file":"encoding.js","sourceRoot":"","sources":["../../src/utils/encoding.ts"],"names":[],"mappings":"AACA,qDAAqD;AACrD,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AACtC,qDAAqD;AACrD,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AAEtC,MAAM,UAAU,UAAU,CAAC,KAAa;IACpC,OAAO,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,MAAqC;IAC5D,OAAO,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC"}
1
+ {"version":3,"file":"encoding.js","sourceRoot":"","sources":["../../src/utils/encoding.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AACtC,qDAAqD;AACrD,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AAEtC,MAAM,UAAU,UAAU,CAAC,KAAa;IACpC,OAAO,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,MAAqC;IAC5D,OAAO,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC"}
@@ -1,4 +1,4 @@
1
+ export { decodeUtf8, encodeUtf8 } from '@yume-chan/struct';
1
2
  export * from './auto-reset-event.js';
2
3
  export * from './base64.js';
3
- export * from './encoding.js';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC3D,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC"}
@@ -1,4 +1,4 @@
1
+ export { decodeUtf8, encodeUtf8 } from '@yume-chan/struct';
1
2
  export * from './auto-reset-event.js';
2
3
  export * from './base64.js';
3
- export * from './encoding.js';
4
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC3D,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yume-chan/adb",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "description": "TypeScript implementation of Android Debug Bridge (ADB) protocol.",
5
5
  "keywords": [
6
6
  "adb",
@@ -26,9 +26,9 @@
26
26
  "types": "esm/index.d.ts",
27
27
  "dependencies": {
28
28
  "@yume-chan/async": "^2.1.4",
29
- "@yume-chan/dataview-bigint-polyfill": "^0.0.12",
30
- "@yume-chan/event": "^0.0.12",
31
- "@yume-chan/struct": "^0.0.12",
29
+ "@yume-chan/dataview-bigint-polyfill": "^0.0.13",
30
+ "@yume-chan/event": "^0.0.13",
31
+ "@yume-chan/struct": "^0.0.13",
32
32
  "tslib": "^2.3.1",
33
33
  "web-streams-polyfill": "^3.2.0"
34
34
  },
@@ -39,12 +39,12 @@
39
39
  "cross-env": "^7.0.3",
40
40
  "jest": "^27.5.1",
41
41
  "ts-jest": "^27.1.3",
42
- "typescript": "next"
42
+ "typescript": "4.7.0-beta"
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
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 - [Backend](#backend-1)\r\n- [Commands](#commands)\r\n - [childProcess](#childprocess)\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| [Streams][MDN_Streams] | 67 | 79 | No | No | 14.1 | 16.5 |\r\n| *Overall* | 67 | 79 | No | No | 14.1 | 16.5 |\r\n\r\n<sup>1</sup> `uint64` and `string` 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[MDN_Streams]: https://developer.mozilla.org/en-US/docs/Web/API/Streams_API\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 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\nIt's possible to call `authenticate` multiple times on a single connection, every time the device receives a `CNXN` packet, it resets its 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\nThe `Backend` is responsible for reading and writing data from underlying source.\r\n\r\n### Backend\r\n\r\n## Commands\r\n\r\n### childProcess\r\n\r\nSpawns child process on server. ADB has two shell modes:\r\n\r\n| | Legacy mode | 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| Resizing window | No | Yes |\r\n\r\nThe `Adb#childProcess#shell` and `Adb#childProcess#spawn` methods accepts a list of implementations, and will use the first supported one.\r\n\r\nFor simple command invocation, usually the `AdbNoneSubprocessProtocol` is enough.\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"
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"
50
50
  }
package/src/adb.ts CHANGED
@@ -1,9 +1,11 @@
1
+ // cspell: ignore libusb
2
+
1
3
  import { PromiseResolver } from '@yume-chan/async';
2
- import { AdbAuthenticationHandler, AdbDefaultAuthenticators, type AdbCredentialStore } from './auth.js';
4
+ import { AdbAuthenticationProcessor, ADB_DEFAULT_AUTHENTICATORS, type AdbCredentialStore } from './auth.js';
3
5
  import { AdbPower, AdbReverseCommand, AdbSubprocess, AdbSync, AdbTcpIpCommand, escapeArg, framebuffer, install, type AdbFrameBuffer } from './commands/index.js';
4
6
  import { AdbFeatures } from './features.js';
5
- import { AdbCommand, AdbPacket, calculateChecksum, type AdbPacketCore, type AdbPacketInit } from './packet.js';
6
- import { AdbPacketDispatcher, AdbSocket } from './socket/index.js';
7
+ import { AdbCommand, calculateChecksum, type AdbPacketData, type AdbPacketInit } from './packet.js';
8
+ import { AdbPacketDispatcher, type AdbSocket } from './socket/index.js';
7
9
  import { AbortController, DecodeUtf8Stream, GatherStringStream, WritableStream, type ReadableWritablePair } from "./stream/index.js";
8
10
  import { decodeUtf8, encodeUtf8 } from "./utils/index.js";
9
11
 
@@ -23,39 +25,23 @@ export class Adb {
23
25
  * and starts a new authentication process.
24
26
  */
25
27
  public static async authenticate(
26
- connection: ReadableWritablePair<AdbPacketCore, AdbPacketCore>,
28
+ connection: ReadableWritablePair<AdbPacketData, AdbPacketInit>,
27
29
  credentialStore: AdbCredentialStore,
28
- authenticators = AdbDefaultAuthenticators,
30
+ authenticators = ADB_DEFAULT_AUTHENTICATORS,
29
31
  ): Promise<Adb> {
32
+ // Initially, set to highest-supported version and payload size.
30
33
  let version = 0x01000001;
31
34
  let maxPayloadSize = 0x100000;
32
35
 
33
- const features = [
34
- 'shell_v2',
35
- 'cmd',
36
- AdbFeatures.StatV2,
37
- 'ls_v2',
38
- 'fixed_push_mkdir',
39
- 'apex',
40
- 'abb',
41
- 'fixed_push_symlink_timestamp',
42
- 'abb_exec',
43
- 'remount_shell',
44
- 'track_app',
45
- 'sendrecv_v2',
46
- 'sendrecv_v2_brotli',
47
- 'sendrecv_v2_lz4',
48
- 'sendrecv_v2_zstd',
49
- 'sendrecv_v2_dry_run_send',
50
- ].join(',');
51
-
52
36
  const resolver = new PromiseResolver<string>();
53
- const authHandler = new AdbAuthenticationHandler(authenticators, credentialStore);
37
+ const authProcessor = new AdbAuthenticationProcessor(authenticators, credentialStore);
54
38
 
39
+ // Here is similar to `AdbPacketDispatcher`,
40
+ // But the received packet types and send packet processing are different.
55
41
  const abortController = new AbortController();
56
42
  const pipe = connection.readable
57
43
  .pipeTo(new WritableStream({
58
- async write(packet: AdbPacket) {
44
+ async write(packet) {
59
45
  switch (packet.command) {
60
46
  case AdbCommand.Connect:
61
47
  version = Math.min(version, packet.arg0);
@@ -63,58 +49,84 @@ export class Adb {
63
49
  resolver.resolve(decodeUtf8(packet.payload));
64
50
  break;
65
51
  case AdbCommand.Auth:
66
- const response = await authHandler.handle(packet);
52
+ const response = await authProcessor.process(packet);
67
53
  await sendPacket(response);
68
54
  break;
69
- case AdbCommand.Close:
70
- // Last connection was interrupted
71
- // Ignore this packet, device will recover
72
- break;
73
55
  default:
74
- throw new Error('Device not in correct state. Reconnect your device and try again');
56
+ // Maybe the previous ADB session exited without reading all packets,
57
+ // so they are still waiting in OS internal buffer.
58
+ // Just ignore them.
59
+ // Because a `Connect` packet will reset the device,
60
+ // Eventually there will be `Connect` and `Auth` response packets.
61
+ break;
75
62
  }
76
63
  }
77
64
  }), {
78
65
  preventCancel: true,
79
66
  signal: abortController.signal,
80
67
  })
81
- .catch((e) => { resolver.reject(e); });
68
+ .catch((e) => {
69
+ resolver.reject(e);
70
+ });
82
71
 
83
72
  const writer = connection.writable.getWriter();
84
- async function sendPacket(init: AdbPacketCore) {
73
+ async function sendPacket(init: AdbPacketData) {
85
74
  // Always send checksum in auth steps
86
- // Because we don't know if the device will ignore it yet.
75
+ // Because we don't know if the device needs it or not.
87
76
  await writer.write(calculateChecksum(init));
88
77
  }
89
78
 
90
- await sendPacket({
91
- command: AdbCommand.Connect,
92
- arg0: version,
93
- arg1: maxPayloadSize,
94
- // The terminating `;` is required in formal definition
95
- // But ADB daemon (all versions) can still work without it
96
- payload: encodeUtf8(`host::features=${features};`),
97
- });
98
-
99
79
  try {
80
+ // https://android.googlesource.com/platform/packages/modules/adb/+/79010dc6d5ca7490c493df800d4421730f5466ca/transport.cpp#1252
81
+ // There are some other feature constants, but some of them are only used by ADB server, not devices.
82
+ const features = [
83
+ AdbFeatures.ShellV2,
84
+ AdbFeatures.Cmd,
85
+ AdbFeatures.StatV2,
86
+ AdbFeatures.ListV2,
87
+ 'fixed_push_mkdir',
88
+ 'apex',
89
+ 'abb',
90
+ 'fixed_push_symlink_timestamp',
91
+ 'abb_exec',
92
+ 'remount_shell',
93
+ 'track_app',
94
+ 'sendrecv_v2',
95
+ 'sendrecv_v2_brotli',
96
+ 'sendrecv_v2_lz4',
97
+ 'sendrecv_v2_zstd',
98
+ 'sendrecv_v2_dry_run_send',
99
+ ].join(',');
100
+
101
+ await sendPacket({
102
+ command: AdbCommand.Connect,
103
+ arg0: version,
104
+ arg1: maxPayloadSize,
105
+ // The terminating `;` is required in formal definition
106
+ // But ADB daemon (all versions) can still work without it
107
+ payload: encodeUtf8(`host::features=${features};`),
108
+ });
109
+
100
110
  const banner = await resolver.promise;
101
111
 
102
- // Stop piping before creating Adb object
103
- // Because AdbPacketDispatcher will try to lock the streams when initializing
112
+ // Stop piping before creating `Adb` object
113
+ // Because `AdbPacketDispatcher` will lock the streams when initializing
104
114
  abortController.abort();
105
- await pipe;
106
-
107
115
  writer.releaseLock();
108
116
 
117
+ // Wait until pipe stops (`ReadableStream` lock released)
118
+ await pipe;
119
+
109
120
  return new Adb(
110
121
  connection,
111
122
  version,
112
123
  maxPayloadSize,
113
124
  banner,
114
125
  );
115
- } finally {
126
+ } catch (e) {
116
127
  abortController.abort();
117
128
  writer.releaseLock();
129
+ throw e;
118
130
  }
119
131
  }
120
132
 
@@ -143,22 +155,33 @@ export class Adb {
143
155
  public readonly tcpip: AdbTcpIpCommand;
144
156
 
145
157
  public constructor(
146
- connection: ReadableWritablePair<AdbPacketCore, AdbPacketInit>,
158
+ connection: ReadableWritablePair<AdbPacketData, AdbPacketInit>,
147
159
  version: number,
148
160
  maxPayloadSize: number,
149
161
  banner: string,
150
162
  ) {
151
163
  this.parseBanner(banner);
152
- this.packetDispatcher = new AdbPacketDispatcher(connection);
153
164
 
154
- this._protocolVersion = version;
165
+ let calculateChecksum: boolean;
166
+ let appendNullToServiceString: boolean;
155
167
  if (version >= VERSION_OMIT_CHECKSUM) {
156
- this.packetDispatcher.calculateChecksum = false;
157
- // Android prior to 9.0.0 uses char* to parse service string
158
- // thus requires an extra null character
159
- this.packetDispatcher.appendNullToServiceString = false;
168
+ calculateChecksum = false;
169
+ appendNullToServiceString = false;
170
+ } else {
171
+ calculateChecksum = true;
172
+ appendNullToServiceString = true;
160
173
  }
161
- this.packetDispatcher.maxPayloadSize = maxPayloadSize;
174
+
175
+ this.packetDispatcher = new AdbPacketDispatcher(
176
+ connection,
177
+ {
178
+ calculateChecksum,
179
+ appendNullToServiceString,
180
+ maxPayloadSize,
181
+ }
182
+ );
183
+
184
+ this._protocolVersion = version;
162
185
 
163
186
  this.subprocess = new AdbSubprocess(this);
164
187
  this.power = new AdbPower(this);
@@ -201,6 +224,19 @@ export class Adb {
201
224
  }
202
225
  }
203
226
 
227
+ public async createSocket(service: string): Promise<AdbSocket> {
228
+ return this.packetDispatcher.createSocket(service);
229
+ }
230
+
231
+ public async createSocketAndWait(service: string): Promise<string> {
232
+ const socket = await this.createSocket(service);
233
+ const gatherStream = new GatherStringStream();
234
+ await socket.readable
235
+ .pipeThrough(new DecodeUtf8Stream())
236
+ .pipeTo(gatherStream);
237
+ return gatherStream.result;
238
+ }
239
+
204
240
  public async getProp(key: string): Promise<string> {
205
241
  const stdout = await this.subprocess.spawnAndWaitLegacy(
206
242
  ['getprop', key]
@@ -228,19 +264,6 @@ export class Adb {
228
264
  return framebuffer(this);
229
265
  }
230
266
 
231
- public async createSocket(service: string): Promise<AdbSocket> {
232
- return this.packetDispatcher.createSocket(service);
233
- }
234
-
235
- public async createSocketAndWait(service: string): Promise<string> {
236
- const socket = await this.createSocket(service);
237
- const gatherStream = new GatherStringStream();
238
- await socket.readable
239
- .pipeThrough(new DecodeUtf8Stream())
240
- .pipeTo(gatherStream.writable);
241
- return gatherStream.result;
242
- }
243
-
244
267
  public async dispose(): Promise<void> {
245
268
  this.packetDispatcher.dispose();
246
269
  }
package/src/auth.ts CHANGED
@@ -2,7 +2,7 @@ import { PromiseResolver } from '@yume-chan/async';
2
2
  import type { Disposable } from '@yume-chan/event';
3
3
  import type { ValueOrPromise } from '@yume-chan/struct';
4
4
  import { calculatePublicKey, calculatePublicKeyLength, sign } from './crypto.js';
5
- import { AdbCommand, AdbPacket, type AdbPacketCore } from './packet.js';
5
+ import { AdbCommand, type AdbPacketData } from './packet.js';
6
6
  import { calculateBase64EncodedLength, encodeBase64 } from './utils/index.js';
7
7
 
8
8
  export type AdbKeyIterable = Iterable<Uint8Array> | AsyncIterable<Uint8Array>;
@@ -43,14 +43,14 @@ export interface AdbAuthenticator {
43
43
  */
44
44
  (
45
45
  credentialStore: AdbCredentialStore,
46
- getNextRequest: () => Promise<AdbPacket>
47
- ): AsyncIterable<AdbPacketCore>;
46
+ getNextRequest: () => Promise<AdbPacketData>
47
+ ): AsyncIterable<AdbPacketData>;
48
48
  }
49
49
 
50
50
  export const AdbSignatureAuthenticator: AdbAuthenticator = async function* (
51
51
  credentialStore: AdbCredentialStore,
52
- getNextRequest: () => Promise<AdbPacket>,
53
- ): AsyncIterable<AdbPacketCore> {
52
+ getNextRequest: () => Promise<AdbPacketData>,
53
+ ): AsyncIterable<AdbPacketData> {
54
54
  for await (const key of credentialStore.iterateKeys()) {
55
55
  const packet = await getNextRequest();
56
56
 
@@ -70,8 +70,8 @@ export const AdbSignatureAuthenticator: AdbAuthenticator = async function* (
70
70
 
71
71
  export const AdbPublicKeyAuthenticator: AdbAuthenticator = async function* (
72
72
  credentialStore: AdbCredentialStore,
73
- getNextRequest: () => Promise<AdbPacket>,
74
- ): AsyncIterable<AdbPacketCore> {
73
+ getNextRequest: () => Promise<AdbPacketData>,
74
+ ): AsyncIterable<AdbPacketData> {
75
75
  const packet = await getNextRequest();
76
76
 
77
77
  if (packet.arg0 !== AdbAuthType.Token) {
@@ -110,19 +110,19 @@ export const AdbPublicKeyAuthenticator: AdbAuthenticator = async function* (
110
110
  };
111
111
  };
112
112
 
113
- export const AdbDefaultAuthenticators: AdbAuthenticator[] = [
113
+ export const ADB_DEFAULT_AUTHENTICATORS: AdbAuthenticator[] = [
114
114
  AdbSignatureAuthenticator,
115
115
  AdbPublicKeyAuthenticator,
116
116
  ];
117
117
 
118
- export class AdbAuthenticationHandler implements Disposable {
118
+ export class AdbAuthenticationProcessor implements Disposable {
119
119
  public readonly authenticators: readonly AdbAuthenticator[];
120
120
 
121
121
  private readonly credentialStore: AdbCredentialStore;
122
122
 
123
- private pendingRequest = new PromiseResolver<AdbPacket>();
123
+ private pendingRequest = new PromiseResolver<AdbPacketData>();
124
124
 
125
- private iterator: AsyncIterator<AdbPacketCore> | undefined;
125
+ private iterator: AsyncIterator<AdbPacketData, void, void> | undefined;
126
126
 
127
127
  public constructor(
128
128
  authenticators: readonly AdbAuthenticator[],
@@ -132,16 +132,16 @@ export class AdbAuthenticationHandler implements Disposable {
132
132
  this.credentialStore = credentialStore;
133
133
  }
134
134
 
135
- private getNextRequest = (): Promise<AdbPacket> => {
135
+ private getNextRequest = (): Promise<AdbPacketData> => {
136
136
  return this.pendingRequest.promise;
137
137
  };
138
138
 
139
- private async* runAuthenticator(): AsyncGenerator<AdbPacketCore> {
139
+ private async* invokeAuthenticator(): AsyncGenerator<AdbPacketData, void, void> {
140
140
  for (const authenticator of this.authenticators) {
141
141
  for await (const packet of authenticator(this.credentialStore, this.getNextRequest)) {
142
142
  // If the authenticator yielded a response
143
143
  // Prepare `nextRequest` for next authentication request
144
- this.pendingRequest = new PromiseResolver<AdbPacket>();
144
+ this.pendingRequest = new PromiseResolver();
145
145
 
146
146
  // Yield the response to outer layer
147
147
  yield packet;
@@ -150,17 +150,20 @@ export class AdbAuthenticationHandler implements Disposable {
150
150
  // If the authenticator returned,
151
151
  // Next authenticator will be given the same `pendingRequest`
152
152
  }
153
-
154
- throw new Error('Cannot authenticate with device');
155
153
  }
156
154
 
157
- public async handle(packet: AdbPacket): Promise<AdbPacketCore> {
155
+ public async process(packet: AdbPacketData): Promise<AdbPacketData> {
158
156
  if (!this.iterator) {
159
- this.iterator = this.runAuthenticator();
157
+ this.iterator = this.invokeAuthenticator();
160
158
  }
161
159
 
162
160
  this.pendingRequest.resolve(packet);
161
+
163
162
  const result = await this.iterator.next();
163
+ if (result.done) {
164
+ throw new Error('No authenticator can handle the request');
165
+ }
166
+
164
167
  return result.value;
165
168
  }
166
169
 
package/src/backend.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { ValueOrPromise } from '@yume-chan/struct';
2
- import type { AdbPacketCore, AdbPacketInit } from "./packet.js";
2
+ import type { AdbPacketData, AdbPacketInit } from "./packet.js";
3
3
  import type { ReadableWritablePair } from "./stream/index.js";
4
4
 
5
5
  export interface AdbBackend {
@@ -7,5 +7,5 @@ export interface AdbBackend {
7
7
 
8
8
  readonly name: string | undefined;
9
9
 
10
- connect(): ValueOrPromise<ReadableWritablePair<AdbPacketCore, AdbPacketInit>>;
10
+ connect(): ValueOrPromise<ReadableWritablePair<AdbPacketData, AdbPacketInit>>;
11
11
  }
@@ -8,18 +8,16 @@ export function install(
8
8
  ): WritableStream<Uint8Array> {
9
9
  const filename = `/data/local/tmp/${Math.random().toString().substring(2)}.apk`;
10
10
 
11
- return new WrapWritableStream<Uint8Array, WritableStream<Uint8Array>, AdbSync>({
11
+ let sync!: AdbSync;
12
+ return new WrapWritableStream<Uint8Array>({
12
13
  async start() {
13
- // Upload apk file to tmp folder
14
- const sync = await adb.sync();
15
- const writable = sync.write(filename, undefined, undefined);
14
+ // TODO: install: support other install apk methods (streaming, etc.)
16
15
 
17
- return {
18
- writable,
19
- state: sync,
20
- };
16
+ // Upload apk file to tmp folder
17
+ sync = await adb.sync();
18
+ return sync.write(filename, undefined, undefined);
21
19
  },
22
- async close(sync) {
20
+ async close() {
23
21
  sync.dispose();
24
22
 
25
23
  // Invoke `pm install` to install it
@@ -2,13 +2,13 @@
2
2
 
3
3
  import { AutoDisposable } from '@yume-chan/event';
4
4
  import Struct from '@yume-chan/struct';
5
- import type { AdbPacketCore } from '../packet.js';
5
+ import type { AdbPacketData } from '../packet.js';
6
6
  import type { AdbIncomingSocketEventArgs, AdbPacketDispatcher, AdbSocket } from '../socket/index.js';
7
7
  import { AdbBufferedStream } from '../stream/index.js';
8
8
  import { decodeUtf8 } from "../utils/index.js";
9
9
 
10
10
  export interface AdbReverseHandler {
11
- onSocket(packet: AdbPacketCore, socket: AdbSocket): void;
11
+ onSocket(packet: AdbPacketData, socket: AdbSocket): void;
12
12
  }
13
13
 
14
14
  export interface AdbForwardListener {