@yume-chan/adb 2.6.0 → 3.0.0-beta.0
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/LICENSE +1 -1
- package/README.md +1 -1
- package/esm/adb.d.ts +18 -15
- package/esm/adb.d.ts.map +1 -1
- package/esm/adb.js +18 -11
- package/esm/adb.js.map +1 -1
- package/esm/banner.d.ts +1 -1
- package/esm/banner.d.ts.map +1 -1
- package/esm/daemon/auth/authenticator.d.ts +28 -0
- package/esm/daemon/auth/authenticator.d.ts.map +1 -0
- package/esm/daemon/auth/authenticator.js +108 -0
- package/esm/daemon/auth/authenticator.js.map +1 -0
- package/esm/daemon/auth/index.d.ts +5 -0
- package/esm/daemon/auth/index.d.ts.map +1 -0
- package/esm/daemon/auth/index.js +5 -0
- package/esm/daemon/auth/index.js.map +1 -0
- package/esm/daemon/auth/packet-processor.d.ts +42 -0
- package/esm/daemon/auth/packet-processor.d.ts.map +1 -0
- package/esm/daemon/auth/packet-processor.js +129 -0
- package/esm/daemon/auth/packet-processor.js.map +1 -0
- package/esm/daemon/auth/public-key.d.ts +8 -0
- package/esm/daemon/auth/public-key.d.ts.map +1 -0
- package/esm/daemon/auth/public-key.js +74 -0
- package/esm/daemon/auth/public-key.js.map +1 -0
- package/esm/daemon/auth/type.d.ts +5 -0
- package/esm/daemon/auth/type.d.ts.map +1 -0
- package/esm/daemon/auth/type.js +2 -0
- package/esm/daemon/auth/type.js.map +1 -0
- package/esm/daemon/crypto.d.ts +6 -5
- package/esm/daemon/crypto.d.ts.map +1 -1
- package/esm/daemon/crypto.js +23 -73
- package/esm/daemon/crypto.js.map +1 -1
- package/esm/daemon/dispatcher.d.ts +3 -3
- package/esm/daemon/dispatcher.d.ts.map +1 -1
- package/esm/daemon/dispatcher.js +11 -4
- package/esm/daemon/dispatcher.js.map +1 -1
- package/esm/daemon/index.d.ts +1 -1
- package/esm/daemon/index.d.ts.map +1 -1
- package/esm/daemon/index.js +1 -1
- package/esm/daemon/index.js.map +1 -1
- package/esm/daemon/socket.d.ts +3 -3
- package/esm/daemon/socket.d.ts.map +1 -1
- package/esm/daemon/transport.d.ts +13 -65
- package/esm/daemon/transport.d.ts.map +1 -1
- package/esm/daemon/transport.js +18 -140
- package/esm/daemon/transport.js.map +1 -1
- package/esm/device-observer.d.ts +2 -3
- package/esm/device-observer.d.ts.map +1 -1
- package/esm/features-value.d.ts +40 -0
- package/esm/features-value.d.ts.map +1 -0
- package/esm/features-value.js +46 -0
- package/esm/features-value.js.map +1 -0
- package/esm/features.d.ts +4 -12
- package/esm/features.d.ts.map +1 -1
- package/esm/features.js +27 -13
- package/esm/features.js.map +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/server/client.d.ts +7 -7
- package/esm/server/client.d.ts.map +1 -1
- package/esm/server/client.js +69 -86
- package/esm/server/client.js.map +1 -1
- package/esm/server/commands/wireless.js +1 -1
- package/esm/server/commands/wireless.js.map +1 -1
- package/esm/server/{stream.d.ts → data-connection.d.ts} +5 -5
- package/esm/server/data-connection.d.ts.map +1 -0
- package/esm/server/{stream.js → data-connection.js} +4 -4
- package/esm/server/data-connection.js.map +1 -0
- package/esm/server/index.d.ts +1 -1
- package/esm/server/index.d.ts.map +1 -1
- package/esm/server/index.js +1 -1
- package/esm/server/index.js.map +1 -1
- package/esm/server/observer.d.ts.map +1 -1
- package/esm/server/observer.js +14 -13
- package/esm/server/observer.js.map +1 -1
- package/esm/server/transport.d.ts +4 -6
- package/esm/server/transport.d.ts.map +1 -1
- package/esm/server/transport.js +9 -24
- package/esm/server/transport.js.map +1 -1
- package/esm/service/framebuffer.d.ts.map +1 -0
- package/esm/service/framebuffer.js.map +1 -0
- package/esm/{commands → service}/index.d.ts +1 -2
- package/esm/service/index.d.ts.map +1 -0
- package/esm/{commands → service}/index.js +1 -2
- package/esm/service/index.js.map +1 -0
- package/esm/{commands → service}/power.d.ts +4 -2
- package/esm/service/power.d.ts.map +1 -0
- package/esm/{commands → service}/power.js +11 -5
- package/esm/service/power.js.map +1 -0
- package/esm/service/reverse/error.d.ts +14 -0
- package/esm/service/reverse/error.d.ts.map +1 -0
- package/esm/service/reverse/error.js +21 -0
- package/esm/service/reverse/error.js.map +1 -0
- package/esm/service/reverse/index.d.ts +3 -0
- package/esm/service/reverse/index.d.ts.map +1 -0
- package/esm/service/reverse/index.js +4 -0
- package/esm/service/reverse/index.js.map +1 -0
- package/esm/service/reverse/response.d.ts +2 -0
- package/esm/service/reverse/response.d.ts.map +1 -0
- package/esm/service/reverse/response.js +30 -0
- package/esm/service/reverse/response.js.map +1 -0
- package/esm/service/reverse/service.d.ts +59 -0
- package/esm/service/reverse/service.d.ts.map +1 -0
- package/esm/{commands/reverse.js → service/reverse/service.js} +16 -45
- package/esm/service/reverse/service.js.map +1 -0
- package/esm/{commands → service}/subprocess/index.d.ts +1 -0
- package/esm/service/subprocess/index.d.ts.map +1 -0
- package/esm/{commands → service}/subprocess/index.js +1 -0
- package/esm/service/subprocess/index.js.map +1 -0
- package/esm/service/subprocess/none/index.d.ts.map +1 -0
- package/esm/service/subprocess/none/index.js.map +1 -0
- package/esm/{commands → service}/subprocess/none/process.d.ts +2 -2
- package/esm/service/subprocess/none/process.d.ts.map +1 -0
- package/esm/service/subprocess/none/process.js.map +1 -0
- package/esm/{commands → service}/subprocess/none/pty.d.ts +4 -4
- package/esm/service/subprocess/none/pty.d.ts.map +1 -0
- package/esm/{commands → service}/subprocess/none/pty.js +1 -1
- package/esm/service/subprocess/none/pty.js.map +1 -0
- package/esm/service/subprocess/none/service.d.ts +10 -0
- package/esm/service/subprocess/none/service.d.ts.map +1 -0
- package/esm/service/subprocess/none/service.js +44 -0
- package/esm/service/subprocess/none/service.js.map +1 -0
- package/esm/service/subprocess/none/spawner.d.ts +15 -0
- package/esm/service/subprocess/none/spawner.d.ts.map +1 -0
- package/esm/service/subprocess/none/spawner.js +31 -0
- package/esm/service/subprocess/none/spawner.js.map +1 -0
- package/esm/{commands → service}/subprocess/pty.d.ts +1 -1
- package/esm/service/subprocess/pty.d.ts.map +1 -0
- package/esm/{commands → service}/subprocess/pty.js.map +1 -1
- package/esm/service/subprocess/service.d.ts.map +1 -0
- package/esm/{commands → service}/subprocess/service.js +1 -1
- package/esm/service/subprocess/service.js.map +1 -0
- package/esm/service/subprocess/shell/index.d.ts +5 -0
- package/esm/{commands/subprocess/none → service/subprocess/shell}/index.d.ts.map +1 -1
- package/esm/service/subprocess/shell/index.js +6 -0
- package/esm/{commands/subprocess/none → service/subprocess/shell}/index.js.map +1 -1
- package/esm/{commands → service}/subprocess/shell/process.d.ts +2 -2
- package/esm/service/subprocess/shell/process.d.ts.map +1 -0
- package/esm/{commands → service}/subprocess/shell/process.js +4 -6
- package/esm/service/subprocess/shell/process.js.map +1 -0
- package/esm/{commands → service}/subprocess/shell/pty.d.ts +4 -4
- package/esm/service/subprocess/shell/pty.d.ts.map +1 -0
- package/esm/{commands → service}/subprocess/shell/pty.js +11 -9
- package/esm/service/subprocess/shell/pty.js.map +1 -0
- package/esm/service/subprocess/shell/service.d.ts +34 -0
- package/esm/service/subprocess/shell/service.d.ts.map +1 -0
- package/esm/service/subprocess/shell/service.js +52 -0
- package/esm/service/subprocess/shell/service.js.map +1 -0
- package/esm/service/subprocess/shell/shared.d.ts +2 -0
- package/esm/service/subprocess/shell/shared.d.ts.map +1 -0
- package/esm/{commands → service}/subprocess/shell/shared.js +2 -0
- package/esm/service/subprocess/shell/shared.js.map +1 -0
- package/esm/{commands → service}/subprocess/shell/spawner.d.ts +3 -7
- package/esm/service/subprocess/shell/spawner.d.ts.map +1 -0
- package/esm/service/subprocess/shell/spawner.js +45 -0
- package/esm/service/subprocess/shell/spawner.js.map +1 -0
- package/esm/service/subprocess/types.d.ts +14 -0
- package/esm/service/subprocess/types.d.ts.map +1 -0
- package/esm/service/subprocess/types.js +2 -0
- package/esm/service/subprocess/types.js.map +1 -0
- package/esm/service/subprocess/utils.d.ts +39 -0
- package/esm/service/subprocess/utils.d.ts.map +1 -0
- package/esm/service/subprocess/utils.js +142 -0
- package/esm/service/subprocess/utils.js.map +1 -0
- package/esm/service/sync/android.d.ts +34 -0
- package/esm/service/sync/android.d.ts.map +1 -0
- package/esm/service/sync/android.js +34 -0
- package/esm/service/sync/android.js.map +1 -0
- package/esm/service/sync/compression/compression.d.ts +17 -0
- package/esm/service/sync/compression/compression.d.ts.map +1 -0
- package/esm/service/sync/compression/compression.js +92 -0
- package/esm/service/sync/compression/compression.js.map +1 -0
- package/esm/service/sync/compression/format-ns.d.ts +5 -0
- package/esm/service/sync/compression/format-ns.d.ts.map +1 -0
- package/esm/service/sync/compression/format-ns.js +5 -0
- package/esm/service/sync/compression/format-ns.js.map +1 -0
- package/esm/service/sync/compression/format.d.ts +4 -0
- package/esm/service/sync/compression/format.d.ts.map +1 -0
- package/esm/service/sync/compression/format.js +3 -0
- package/esm/service/sync/compression/format.js.map +1 -0
- package/esm/service/sync/compression/index.d.ts +2 -0
- package/esm/service/sync/compression/index.d.ts.map +1 -0
- package/esm/service/sync/compression/index.js +2 -0
- package/esm/service/sync/compression/index.js.map +1 -0
- package/esm/service/sync/id/common.d.ts +17 -0
- package/esm/service/sync/id/common.d.ts.map +1 -0
- package/esm/service/sync/id/common.js +29 -0
- package/esm/service/sync/id/common.js.map +1 -0
- package/esm/service/sync/id/index.d.ts +4 -0
- package/esm/service/sync/id/index.d.ts.map +1 -0
- package/esm/service/sync/id/index.js +6 -0
- package/esm/service/sync/id/index.js.map +1 -0
- package/esm/service/sync/id/request.d.ts +7 -0
- package/esm/service/sync/id/request.d.ts.map +1 -0
- package/esm/service/sync/id/request.js +9 -0
- package/esm/service/sync/id/request.js.map +1 -0
- package/esm/service/sync/id/response.d.ts +6 -0
- package/esm/service/sync/id/response.d.ts.map +1 -0
- package/esm/service/sync/id/response.js +8 -0
- package/esm/service/sync/id/response.js.map +1 -0
- package/esm/service/sync/index-ns.d.ts +7 -0
- package/esm/service/sync/index-ns.d.ts.map +1 -0
- package/esm/service/sync/index-ns.js +7 -0
- package/esm/service/sync/index-ns.js.map +1 -0
- package/esm/service/sync/index.d.ts +3 -0
- package/esm/service/sync/index.d.ts.map +1 -0
- package/esm/service/sync/index.js +3 -0
- package/esm/service/sync/index.js.map +1 -0
- package/esm/service/sync/request/index.d.ts +5 -0
- package/esm/service/sync/request/index.d.ts.map +1 -0
- package/esm/service/sync/request/index.js +5 -0
- package/esm/service/sync/request/index.js.map +1 -0
- package/esm/{commands/sync → service/sync/request}/list.d.ts +21 -19
- package/esm/service/sync/request/list.d.ts.map +1 -0
- package/esm/service/sync/request/list.js +77 -0
- package/esm/service/sync/request/list.js.map +1 -0
- package/esm/service/sync/request/pull.d.ts +12 -0
- package/esm/service/sync/request/pull.d.ts.map +1 -0
- package/esm/service/sync/request/pull.js +28 -0
- package/esm/service/sync/request/pull.js.map +1 -0
- package/esm/service/sync/request/push.d.ts +54 -0
- package/esm/service/sync/request/push.d.ts.map +1 -0
- package/esm/service/sync/request/push.js +95 -0
- package/esm/service/sync/request/push.js.map +1 -0
- package/esm/{commands/sync → service/sync/request}/stat.d.ts +40 -50
- package/esm/service/sync/request/stat.d.ts.map +1 -0
- package/esm/service/sync/request/stat.js +89 -0
- package/esm/service/sync/request/stat.js.map +1 -0
- package/esm/service/sync/service.d.ts +123 -0
- package/esm/service/sync/service.d.ts.map +1 -0
- package/esm/service/sync/service.js +170 -0
- package/esm/service/sync/service.js.map +1 -0
- package/esm/service/sync/socket-pool.d.ts +11 -0
- package/esm/service/sync/socket-pool.d.ts.map +1 -0
- package/esm/service/sync/socket-pool.js +80 -0
- package/esm/service/sync/socket-pool.js.map +1 -0
- package/esm/service/sync/socket.d.ts +40 -0
- package/esm/service/sync/socket.d.ts.map +1 -0
- package/esm/service/sync/socket.js +153 -0
- package/esm/service/sync/socket.js.map +1 -0
- package/esm/{commands → service}/tcpip.d.ts +4 -2
- package/esm/service/tcpip.d.ts.map +1 -0
- package/esm/{commands → service}/tcpip.js +10 -7
- package/esm/service/tcpip.js.map +1 -0
- package/esm/utils/array-buffer.d.ts.map +1 -1
- package/esm/utils/array-buffer.js +2 -3
- package/esm/utils/array-buffer.js.map +1 -1
- package/esm/utils/base64.d.ts.map +1 -1
- package/esm/utils/base64.js +22 -12
- package/esm/utils/base64.js.map +1 -1
- package/esm/utils/index.d.ts +1 -0
- package/esm/utils/index.d.ts.map +1 -1
- package/esm/utils/index.js +1 -0
- package/esm/utils/index.js.map +1 -1
- package/esm/utils/md5.d.ts +8 -0
- package/esm/utils/md5.d.ts.map +1 -0
- package/esm/utils/md5.js +149 -0
- package/esm/utils/md5.js.map +1 -0
- package/package.json +10 -10
- package/src/adb.ts +44 -34
- package/src/daemon/auth/authenticator.ts +186 -0
- package/src/daemon/auth/index.ts +4 -0
- package/src/daemon/auth/packet-processor.ts +212 -0
- package/src/daemon/auth/public-key.ts +112 -0
- package/src/daemon/auth/type.ts +5 -0
- package/src/daemon/crypto.ts +36 -102
- package/src/daemon/dispatcher.ts +15 -8
- package/src/daemon/index.ts +1 -1
- package/src/daemon/socket.ts +3 -3
- package/src/daemon/transport.ts +35 -253
- package/src/device-observer.ts +3 -3
- package/src/features-value.ts +47 -0
- package/src/features.ts +31 -14
- package/src/index.ts +1 -1
- package/src/server/client.ts +96 -94
- package/src/server/commands/wireless.ts +1 -1
- package/src/server/{stream.ts → data-connection.ts} +4 -4
- package/src/server/index.ts +1 -1
- package/src/server/observer.ts +21 -19
- package/src/server/transport.ts +13 -34
- package/src/{commands → service}/index.ts +1 -2
- package/src/{commands → service}/power.ts +14 -5
- package/src/service/reverse/error.ts +35 -0
- package/src/service/reverse/index.ts +3 -0
- package/src/service/reverse/response.ts +38 -0
- package/src/{commands/reverse.ts → service/reverse/service.ts} +32 -72
- package/src/{commands → service}/subprocess/index.ts +1 -0
- package/src/{commands → service}/subprocess/none/process.ts +3 -3
- package/src/{commands → service}/subprocess/none/pty.ts +5 -5
- package/src/service/subprocess/none/service.ts +57 -0
- package/src/service/subprocess/none/spawner.ts +81 -0
- package/src/{commands → service}/subprocess/pty.ts +1 -1
- package/src/{commands → service}/subprocess/service.ts +1 -1
- package/src/{commands → service}/subprocess/shell/index.ts +1 -1
- package/src/{commands → service}/subprocess/shell/process.ts +6 -7
- package/src/{commands → service}/subprocess/shell/pty.ts +15 -13
- package/src/service/subprocess/shell/service.ts +75 -0
- package/src/{commands → service}/subprocess/shell/shared.ts +5 -0
- package/src/service/subprocess/shell/spawner.ts +109 -0
- package/src/service/subprocess/types.ts +19 -0
- package/src/service/subprocess/utils.ts +166 -0
- package/src/service/sync/android.ts +43 -0
- package/src/service/sync/compression/compression.ts +126 -0
- package/src/service/sync/compression/format-ns.ts +4 -0
- package/src/service/sync/compression/format.ts +5 -0
- package/src/service/sync/compression/index.ts +1 -0
- package/src/service/sync/id/common.ts +33 -0
- package/src/service/sync/id/index.ts +7 -0
- package/src/service/sync/id/request.ts +12 -0
- package/src/service/sync/id/response.ts +11 -0
- package/src/service/sync/index-ns.ts +6 -0
- package/src/service/sync/index.ts +2 -0
- package/src/service/sync/request/index.ts +4 -0
- package/src/service/sync/request/list.ts +110 -0
- package/src/service/sync/request/pull.ts +49 -0
- package/src/service/sync/request/push.ts +184 -0
- package/src/service/sync/request/stat.ts +127 -0
- package/src/service/sync/service.ts +255 -0
- package/src/service/sync/socket-pool.ts +97 -0
- package/src/service/sync/socket.ts +201 -0
- package/src/{commands → service}/tcpip.ts +13 -7
- package/src/utils/array-buffer.ts +2 -3
- package/src/utils/base64.ts +24 -12
- package/src/utils/index.ts +1 -0
- package/src/utils/md5.ts +185 -0
- package/yume-chan-adb-3.0.0-beta.0.tgz +0 -0
- package/CHANGELOG.md +0 -251
- package/esm/commands/base.d.ts +0 -8
- package/esm/commands/base.d.ts.map +0 -1
- package/esm/commands/base.js +0 -12
- package/esm/commands/base.js.map +0 -1
- package/esm/commands/framebuffer.d.ts.map +0 -1
- package/esm/commands/framebuffer.js.map +0 -1
- package/esm/commands/index.d.ts.map +0 -1
- package/esm/commands/index.js.map +0 -1
- package/esm/commands/power.d.ts.map +0 -1
- package/esm/commands/power.js.map +0 -1
- package/esm/commands/reverse.d.ts +0 -48
- package/esm/commands/reverse.d.ts.map +0 -1
- package/esm/commands/reverse.js.map +0 -1
- package/esm/commands/subprocess/index.d.ts.map +0 -1
- package/esm/commands/subprocess/index.js.map +0 -1
- package/esm/commands/subprocess/none/process.d.ts.map +0 -1
- package/esm/commands/subprocess/none/process.js.map +0 -1
- package/esm/commands/subprocess/none/pty.d.ts.map +0 -1
- package/esm/commands/subprocess/none/pty.js.map +0 -1
- package/esm/commands/subprocess/none/service.d.ts +0 -10
- package/esm/commands/subprocess/none/service.d.ts.map +0 -1
- package/esm/commands/subprocess/none/service.js +0 -34
- package/esm/commands/subprocess/none/service.js.map +0 -1
- package/esm/commands/subprocess/none/spawner.d.ts +0 -19
- package/esm/commands/subprocess/none/spawner.d.ts.map +0 -1
- package/esm/commands/subprocess/none/spawner.js +0 -26
- package/esm/commands/subprocess/none/spawner.js.map +0 -1
- package/esm/commands/subprocess/pty.d.ts.map +0 -1
- package/esm/commands/subprocess/service.d.ts.map +0 -1
- package/esm/commands/subprocess/service.js.map +0 -1
- package/esm/commands/subprocess/shell/index.d.ts +0 -6
- package/esm/commands/subprocess/shell/index.d.ts.map +0 -1
- package/esm/commands/subprocess/shell/index.js +0 -6
- package/esm/commands/subprocess/shell/index.js.map +0 -1
- package/esm/commands/subprocess/shell/process.d.ts.map +0 -1
- package/esm/commands/subprocess/shell/process.js.map +0 -1
- package/esm/commands/subprocess/shell/pty.d.ts.map +0 -1
- package/esm/commands/subprocess/shell/pty.js.map +0 -1
- package/esm/commands/subprocess/shell/service.d.ts +0 -14
- package/esm/commands/subprocess/shell/service.d.ts.map +0 -1
- package/esm/commands/subprocess/shell/service.js +0 -41
- package/esm/commands/subprocess/shell/service.js.map +0 -1
- package/esm/commands/subprocess/shell/shared.d.ts +0 -19
- package/esm/commands/subprocess/shell/shared.d.ts.map +0 -1
- package/esm/commands/subprocess/shell/shared.js.map +0 -1
- package/esm/commands/subprocess/shell/spawner.d.ts.map +0 -1
- package/esm/commands/subprocess/shell/spawner.js +0 -38
- package/esm/commands/subprocess/shell/spawner.js.map +0 -1
- package/esm/commands/subprocess/utils.d.ts +0 -3
- package/esm/commands/subprocess/utils.d.ts.map +0 -1
- package/esm/commands/subprocess/utils.js +0 -56
- package/esm/commands/subprocess/utils.js.map +0 -1
- package/esm/commands/sync/index.d.ts +0 -9
- package/esm/commands/sync/index.d.ts.map +0 -1
- package/esm/commands/sync/index.js +0 -9
- package/esm/commands/sync/index.js.map +0 -1
- package/esm/commands/sync/list.d.ts.map +0 -1
- package/esm/commands/sync/list.js +0 -64
- package/esm/commands/sync/list.js.map +0 -1
- package/esm/commands/sync/pull.d.ts +0 -12
- package/esm/commands/sync/pull.d.ts.map +0 -1
- package/esm/commands/sync/pull.js +0 -33
- package/esm/commands/sync/pull.js.map +0 -1
- package/esm/commands/sync/push.d.ts +0 -61
- package/esm/commands/sync/push.d.ts.map +0 -1
- package/esm/commands/sync/push.js +0 -83
- package/esm/commands/sync/push.js.map +0 -1
- package/esm/commands/sync/request.d.ts +0 -24
- package/esm/commands/sync/request.d.ts.map +0 -1
- package/esm/commands/sync/request.js +0 -32
- package/esm/commands/sync/request.js.map +0 -1
- package/esm/commands/sync/response.d.ts +0 -28
- package/esm/commands/sync/response.d.ts.map +0 -1
- package/esm/commands/sync/response.js +0 -81
- package/esm/commands/sync/response.js.map +0 -1
- package/esm/commands/sync/socket.d.ts +0 -22
- package/esm/commands/sync/socket.d.ts.map +0 -1
- package/esm/commands/sync/socket.js +0 -78
- package/esm/commands/sync/socket.js.map +0 -1
- package/esm/commands/sync/stat.d.ts.map +0 -1
- package/esm/commands/sync/stat.js +0 -121
- package/esm/commands/sync/stat.js.map +0 -1
- package/esm/commands/sync/sync.d.ts +0 -82
- package/esm/commands/sync/sync.d.ts.map +0 -1
- package/esm/commands/sync/sync.js +0 -138
- package/esm/commands/sync/sync.js.map +0 -1
- package/esm/commands/tcpip.d.ts.map +0 -1
- package/esm/commands/tcpip.js.map +0 -1
- package/esm/daemon/auth.d.ts +0 -54
- package/esm/daemon/auth.d.ts.map +0 -1
- package/esm/daemon/auth.js +0 -104
- package/esm/daemon/auth.js.map +0 -1
- package/esm/server/stream.d.ts.map +0 -1
- package/esm/server/stream.js.map +0 -1
- package/src/commands/base.ts +0 -15
- package/src/commands/subprocess/none/service.ts +0 -45
- package/src/commands/subprocess/none/spawner.ts +0 -68
- package/src/commands/subprocess/shell/service.ts +0 -58
- package/src/commands/subprocess/shell/spawner.ts +0 -90
- package/src/commands/subprocess/utils.ts +0 -61
- package/src/commands/sync/index.ts +0 -8
- package/src/commands/sync/list.ts +0 -99
- package/src/commands/sync/pull.ts +0 -55
- package/src/commands/sync/push.ts +0 -172
- package/src/commands/sync/request.ts +0 -53
- package/src/commands/sync/response.ts +0 -105
- package/src/commands/sync/socket.ts +0 -109
- package/src/commands/sync/stat.ts +0 -177
- package/src/commands/sync/sync.ts +0 -175
- package/src/daemon/auth.ts +0 -204
- package/tsconfig.build.tsbuildinfo +0 -1
- /package/esm/{commands → service}/framebuffer.d.ts +0 -0
- /package/esm/{commands → service}/framebuffer.js +0 -0
- /package/esm/{commands → service}/subprocess/none/index.d.ts +0 -0
- /package/esm/{commands → service}/subprocess/none/index.js +0 -0
- /package/esm/{commands → service}/subprocess/none/process.js +0 -0
- /package/esm/{commands → service}/subprocess/pty.js +0 -0
- /package/esm/{commands → service}/subprocess/service.d.ts +0 -0
- /package/src/{commands → service}/framebuffer.ts +0 -0
- /package/src/{commands → service}/subprocess/none/index.ts +0 -0
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ Check the latest documentation at https://tangoadb.dev/
|
|
|
37
37
|
|
|
38
38
|
## Sponsors
|
|
39
39
|
|
|
40
|
-
[Become a backer](https://opencollective.com/ya-webadb) and get your image on our README on
|
|
40
|
+
[Become a backer](https://opencollective.com/ya-webadb) and get your image on our README on GitHub with a link to your site.
|
|
41
41
|
|
|
42
42
|
<a href="https://opencollective.com/ya-webadb/backer/0/website?requireActive=false" target="_blank"><img src="https://opencollective.com/ya-webadb/backer/0/avatar.svg?requireActive=false"></a>
|
|
43
43
|
<a href="https://opencollective.com/ya-webadb/backer/1/website?requireActive=false" target="_blank"><img src="https://opencollective.com/ya-webadb/backer/1/avatar.svg?requireActive=false"></a>
|
package/esm/adb.d.ts
CHANGED
|
@@ -1,28 +1,20 @@
|
|
|
1
1
|
import type { MaybePromiseLike } from "@yume-chan/async";
|
|
2
2
|
import type { MaybeConsumable, ReadableWritablePair } from "@yume-chan/stream-extra";
|
|
3
3
|
import type { AdbBanner } from "./banner.js";
|
|
4
|
-
import type { AdbFrameBuffer } from "./commands/index.js";
|
|
5
|
-
import { AdbPower, AdbReverseService, AdbSubprocessService, AdbSync, AdbTcpIpService } from "./commands/index.js";
|
|
6
4
|
import type { AdbFeature } from "./features.js";
|
|
5
|
+
import type { AdbFrameBuffer } from "./service/index.js";
|
|
6
|
+
import { AdbPowerService, AdbReverseService, AdbSubprocessService, AdbSync, AdbTcpIpService } from "./service/index.js";
|
|
7
7
|
export interface Closeable {
|
|
8
8
|
close(): MaybePromiseLike<void>;
|
|
9
9
|
}
|
|
10
|
-
/**
|
|
11
|
-
* Represents an ADB socket.
|
|
12
|
-
*/
|
|
13
|
-
export interface AdbSocket extends ReadableWritablePair<Uint8Array, MaybeConsumable<Uint8Array>>, Closeable {
|
|
14
|
-
get service(): string;
|
|
15
|
-
get closed(): Promise<undefined>;
|
|
16
|
-
}
|
|
17
|
-
export type AdbIncomingSocketHandler = (socket: AdbSocket) => MaybePromiseLike<void>;
|
|
18
10
|
export interface AdbTransport extends Closeable {
|
|
19
11
|
readonly serial: string;
|
|
20
12
|
readonly maxPayloadSize: number;
|
|
21
13
|
readonly banner: AdbBanner;
|
|
22
14
|
readonly disconnected: Promise<void>;
|
|
23
15
|
readonly clientFeatures: readonly AdbFeature[];
|
|
24
|
-
connect(service: string): MaybePromiseLike<
|
|
25
|
-
addReverseTunnel(handler:
|
|
16
|
+
connect(service: string): MaybePromiseLike<Adb.Socket>;
|
|
17
|
+
addReverseTunnel(handler: Adb.IncomingSocketHandler, address?: string): MaybePromiseLike<string>;
|
|
26
18
|
removeReverseTunnel(address: string): MaybePromiseLike<void>;
|
|
27
19
|
clearReverseTunnels(): MaybePromiseLike<void>;
|
|
28
20
|
}
|
|
@@ -36,23 +28,34 @@ export declare class Adb implements Closeable {
|
|
|
36
28
|
get clientFeatures(): readonly AdbFeature[];
|
|
37
29
|
get deviceFeatures(): readonly AdbFeature[];
|
|
38
30
|
readonly subprocess: AdbSubprocessService;
|
|
39
|
-
readonly power:
|
|
31
|
+
readonly power: AdbPowerService;
|
|
40
32
|
readonly reverse: AdbReverseService;
|
|
41
33
|
readonly tcpip: AdbTcpIpService;
|
|
34
|
+
readonly sync: AdbSync.Service;
|
|
42
35
|
constructor(transport: AdbTransport);
|
|
43
36
|
canUseFeature(feature: AdbFeature): boolean;
|
|
44
37
|
/**
|
|
45
38
|
* Creates a new ADB Socket to the specified service or socket address.
|
|
46
39
|
*/
|
|
47
|
-
createSocket(service: string): Promise<
|
|
40
|
+
createSocket(service: string): Promise<Adb.Socket>;
|
|
48
41
|
createSocketAndWait(service: string): Promise<string>;
|
|
49
42
|
getProp(key: string): Promise<string>;
|
|
50
43
|
rm(filenames: string | readonly string[], options?: {
|
|
51
44
|
recursive?: boolean;
|
|
52
45
|
force?: boolean;
|
|
53
46
|
}): Promise<string>;
|
|
54
|
-
sync(): Promise<AdbSync>;
|
|
55
47
|
framebuffer(): Promise<AdbFrameBuffer>;
|
|
48
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
56
49
|
close(): Promise<void>;
|
|
57
50
|
}
|
|
51
|
+
export declare namespace Adb {
|
|
52
|
+
/**
|
|
53
|
+
* Represents an ADB socket.
|
|
54
|
+
*/
|
|
55
|
+
interface Socket extends ReadableWritablePair<Uint8Array, MaybeConsumable<Uint8Array>>, Closeable {
|
|
56
|
+
get service(): string;
|
|
57
|
+
get closed(): Promise<undefined>;
|
|
58
|
+
}
|
|
59
|
+
type IncomingSocketHandler = (socket: Socket) => MaybePromiseLike<void>;
|
|
60
|
+
}
|
|
58
61
|
//# sourceMappingURL=adb.d.ts.map
|
package/esm/adb.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adb.d.ts","sourceRoot":"","sources":["../src/adb.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EACR,eAAe,EACf,oBAAoB,EACvB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"adb.d.ts","sourceRoot":"","sources":["../src/adb.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EACR,eAAe,EACf,oBAAoB,EACvB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EACH,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,OAAO,EACP,eAAe,EAGlB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,WAAW,SAAS;IACtB,KAAK,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,YAAa,SAAQ,SAAS;IAC3C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,QAAQ,CAAC,cAAc,EAAE,M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,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAQ3C,EAAE,CACE,SAAS,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,EACrC,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GACnD,OAAO,CAAC,MAAM,CAAC;IA2BZ,WAAW,IAAI,OAAO,CAAC,cAAc,CAAC;IAI5C,CAAC,MAAM,CAAC,YAAY,CAAC;IAIf,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG/B;AAED,yBAAiB,GAAG,CAAC;IACjB;;OAEG;IACH,UAAiB,MACb,SACI,oBAAoB,CAAC,UAAU,EAAE,eAAe,CAAC,UAAU,CAAC,CAAC,EAC7D,SAAS;QACb,IAAI,OAAO,IAAI,MAAM,CAAC;QAEtB,IAAI,MAAM,IAAI,OAAO,CAAC,SAAS,CAAC,CAAC;KACpC;IAED,KAAY,qBAAqB,GAAG,CAChC,MAAM,EAAE,MAAM,KACb,gBAAgB,CAAC,IAAI,CAAC,CAAC;CAC/B"}
|
package/esm/adb.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ConcatStringStream, TextDecoderStream } from "@yume-chan/stream-extra";
|
|
2
|
-
import {
|
|
2
|
+
import { AdbPowerService, AdbReverseService, AdbSubprocessService, AdbSync, AdbTcpIpService, escapeArg, framebuffer, } from "./service/index.js";
|
|
3
3
|
export class Adb {
|
|
4
4
|
#transport;
|
|
5
5
|
get transport() {
|
|
@@ -27,12 +27,14 @@ export class Adb {
|
|
|
27
27
|
power;
|
|
28
28
|
reverse;
|
|
29
29
|
tcpip;
|
|
30
|
+
sync;
|
|
30
31
|
constructor(transport) {
|
|
31
32
|
this.#transport = transport;
|
|
32
33
|
this.subprocess = new AdbSubprocessService(this);
|
|
33
|
-
this.power = new
|
|
34
|
+
this.power = new AdbPowerService(this);
|
|
34
35
|
this.reverse = new AdbReverseService(this);
|
|
35
36
|
this.tcpip = new AdbTcpIpService(this);
|
|
37
|
+
this.sync = new AdbSync.Service(this);
|
|
36
38
|
}
|
|
37
39
|
canUseFeature(feature) {
|
|
38
40
|
return (this.clientFeatures.includes(feature) &&
|
|
@@ -50,10 +52,12 @@ export class Adb {
|
|
|
50
52
|
.pipeThrough(new TextDecoderStream())
|
|
51
53
|
.pipeThrough(new ConcatStringStream());
|
|
52
54
|
}
|
|
53
|
-
getProp(key) {
|
|
54
|
-
|
|
55
|
-
.
|
|
56
|
-
.
|
|
55
|
+
async getProp(key) {
|
|
56
|
+
const output = await this.subprocess.noneProtocol
|
|
57
|
+
.spawn(["getprop", key])
|
|
58
|
+
.wait()
|
|
59
|
+
.toString();
|
|
60
|
+
return output.trim();
|
|
57
61
|
}
|
|
58
62
|
rm(filenames, options) {
|
|
59
63
|
const args = ["rm"];
|
|
@@ -75,15 +79,18 @@ export class Adb {
|
|
|
75
79
|
}
|
|
76
80
|
// https://android.googlesource.com/platform/packages/modules/adb/+/1a0fb8846d4e6b671c8aa7f137a8c21d7b248716/client/adb_install.cpp#984
|
|
77
81
|
args.push("</dev/null");
|
|
78
|
-
return this.subprocess.noneProtocol
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
return this.subprocess.noneProtocol
|
|
83
|
+
.spawn(args)
|
|
84
|
+
.wait()
|
|
85
|
+
.toString()
|
|
86
|
+
.then((output) => output.trim());
|
|
83
87
|
}
|
|
84
88
|
async framebuffer() {
|
|
85
89
|
return framebuffer(this);
|
|
86
90
|
}
|
|
91
|
+
[Symbol.asyncDispose]() {
|
|
92
|
+
return this.close();
|
|
93
|
+
}
|
|
87
94
|
async close() {
|
|
88
95
|
await this.#transport.close();
|
|
89
96
|
}
|
package/esm/adb.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adb.js","sourceRoot":"","sources":["../src/adb.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,kBAAkB,EAAE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AAC;QACpB,CAAC;QACD,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;YAC3B,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;gBAC/B,uDAAuD;gBACvD,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,QAAkB,CAAC,CAAC,CAAC;YAC7C,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,uDAAuD;YACvD,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,SAAmB,CAAC,CAAC,CAAC;QAC9C,CAAC;QACD,uIAAuI;QACvI,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAExB,OAAO,IAAI,CAAC,UAAU,CAAC,YAAY;aAC9B,KAAK,CAAC,IAAI,CAAC;aACX,IAAI,EAAE;aACN,QAAQ,EAAE;aACV,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,WAAW;QACb,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED,CAAC,MAAM,CAAC,YAAY,CAAC;QACjB,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,KAAK;QACP,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IAClC,CAAC;CACJ"}
|
package/esm/banner.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type AdbBannerKey = (typeof AdbBannerKey)[keyof typeof AdbBannerKey];
|
|
|
10
10
|
export declare class AdbBanner {
|
|
11
11
|
#private;
|
|
12
12
|
static parse(banner: string): AdbBanner;
|
|
13
|
-
get state():
|
|
13
|
+
get state(): "offline" | "bootloader" | "device" | "host" | "recovery" | "rescue" | "sideload" | "unauthorized" | "authorizing" | "detached" | undefined;
|
|
14
14
|
get product(): string | undefined;
|
|
15
15
|
get model(): string | undefined;
|
|
16
16
|
get device(): string | undefined;
|
package/esm/banner.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"banner.d.ts","sourceRoot":"","sources":["../src/banner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,eAAO,MAAM,YAAY;;;;;CAKf,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAE5E,qBAAa,SAAS;;IAClB,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM;IA8C3B,IAAI,KAAK,
|
|
1
|
+
{"version":3,"file":"banner.d.ts","sourceRoot":"","sources":["../src/banner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,eAAO,MAAM,YAAY;;;;;CAKf,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAE5E,qBAAa,SAAS;;IAClB,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM;IA8C3B,IAAI,KAAK,gJAER;IAGD,IAAI,OAAO,uBAEV;IAGD,IAAI,KAAK,uBAER;IAGD,IAAI,MAAM,uBAET;IAGD,IAAI,QAAQ,0BAEX;gBAIG,KAAK,EAAE,eAAe,CAAC,eAAe,GAAG,SAAS,EAClD,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,QAAQ,EAAE,SAAS,UAAU,EAAE;CAQtC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { MaybePromiseLike } from "@yume-chan/async";
|
|
2
|
+
import type { AdbPacketData } from "../packet.js";
|
|
3
|
+
import type { AdbDaemonTransportInit } from "../transport.js";
|
|
4
|
+
import { AdbDaemonTransport } from "../transport.js";
|
|
5
|
+
import type { AdbDaemonDefaultAuthProcessorInit } from "./packet-processor.js";
|
|
6
|
+
export interface AdbDaemonAuthProcessor {
|
|
7
|
+
process(packet: AdbPacketData): Promise<AdbPacketData>;
|
|
8
|
+
close?(): MaybePromiseLike<undefined>;
|
|
9
|
+
}
|
|
10
|
+
export type AdbDaemonAuthenticateOptions = Pick<AdbDaemonTransportInit, "serial" | "connection" | "features" | "preserveConnection" | "readTimeLimit"> & {
|
|
11
|
+
/**
|
|
12
|
+
* The number of bytes the device can send before receiving an ack packet.
|
|
13
|
+
*
|
|
14
|
+
* Android 14 added the Delayed Acknowledgement feature to improve performance,
|
|
15
|
+
* especially for high-latency connections like ADB over Wi-Fi.
|
|
16
|
+
*
|
|
17
|
+
* Unlike {@linkcode AdbDaemonTransportInit.initialDelayedAckBytes},
|
|
18
|
+
* setting this parameter to 0 or a negative number will disable Delayed Ack.
|
|
19
|
+
*/
|
|
20
|
+
initialDelayedAckBytes?: number | undefined;
|
|
21
|
+
} & (AdbDaemonDefaultAuthProcessorInit | {
|
|
22
|
+
processor: AdbDaemonAuthProcessor;
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Authenticates an `AdbDaemonConnection` using an `AdbDaemonAuthProcessor`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function adbDaemonAuthenticate({ serial, connection, features, initialDelayedAckBytes, preserveConnection, readTimeLimit, ...processorInit }: AdbDaemonAuthenticateOptions): Promise<AdbDaemonTransport>;
|
|
28
|
+
//# sourceMappingURL=authenticator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authenticator.d.ts","sourceRoot":"","sources":["../../../src/daemon/auth/authenticator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAWzD,OAAO,KAAK,EAAE,aAAa,EAAiB,MAAM,cAAc,CAAC;AAEjE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAEH,kBAAkB,EACrB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,uBAAuB,CAAC;AAG/E,MAAM,WAAW,sBAAsB;IACnC,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAEvD,KAAK,CAAC,IAAI,gBAAgB,CAAC,SAAS,CAAC,CAAC;CACzC;AAED,MAAM,MAAM,4BAA4B,GAAG,IAAI,CAC3C,sBAAsB,EACpB,QAAQ,GACR,YAAY,GACZ,UAAU,GACV,oBAAoB,GACpB,eAAe,CACpB,GAAG;IACA;;;;;;;;OAQG;IACH,sBAAsB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/C,GAAG,CAAC,iCAAiC,GAAG;IAAE,SAAS,EAAE,sBAAsB,CAAA;CAAE,CAAC,CAAC;AAkBhF;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,EACxC,MAAM,EACN,UAAU,EACV,QAA4B,EAC5B,sBAAgE,EAChE,kBAAkB,EAClB,aAAa,EACb,GAAG,aAAa,EACnB,EAAE,4BAA4B,+BA8G9B"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { PromiseResolver } from "@yume-chan/async";
|
|
2
|
+
import { AbortController, Consumable, WritableStream, } from "@yume-chan/stream-extra";
|
|
3
|
+
import { decodeUtf8, encodeUtf8 } from "@yume-chan/struct";
|
|
4
|
+
import { AdbDeviceFeatures, AdbFeature } from "../../features.js";
|
|
5
|
+
import { AdbCommand, calculateChecksum } from "../packet.js";
|
|
6
|
+
import { ADB_DAEMON_DEFAULT_INITIAL_PAYLOAD_SIZE, AdbDaemonTransport, } from "../transport.js";
|
|
7
|
+
import { AdbDaemonDefaultAuthProcessor } from "./packet-processor.js";
|
|
8
|
+
/**
|
|
9
|
+
* Send a packet during authentication stage
|
|
10
|
+
* @param writer Writer to send packet to
|
|
11
|
+
* @param packet The packet to send. Note: this object will be modified.
|
|
12
|
+
*/
|
|
13
|
+
function sendPacket(writer, packet) {
|
|
14
|
+
// Always send checksum in auth steps
|
|
15
|
+
// Because we don't know if the device needs it or not.
|
|
16
|
+
packet.checksum = calculateChecksum(packet.payload);
|
|
17
|
+
packet.magic = packet.command ^ 0xffffffff;
|
|
18
|
+
return Consumable.WritableStream.write(writer, packet);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Authenticates an `AdbDaemonConnection` using an `AdbDaemonAuthProcessor`.
|
|
22
|
+
*/
|
|
23
|
+
export async function adbDaemonAuthenticate({ serial, connection, features = AdbDeviceFeatures, initialDelayedAckBytes = ADB_DAEMON_DEFAULT_INITIAL_PAYLOAD_SIZE, preserveConnection, readTimeLimit, ...processorInit }) {
|
|
24
|
+
const processor = "processor" in processorInit
|
|
25
|
+
? processorInit.processor
|
|
26
|
+
: new AdbDaemonDefaultAuthProcessor(processorInit);
|
|
27
|
+
// Initially, set to highest-supported version and payload size.
|
|
28
|
+
let version = 0x01000001;
|
|
29
|
+
// Android 4: 4K, Android 7: 256K, Android 9: 1M
|
|
30
|
+
let maxPayloadSize = 1024 * 1024;
|
|
31
|
+
const resolver = new PromiseResolver();
|
|
32
|
+
const abortController = new AbortController();
|
|
33
|
+
const writer = connection.writable.getWriter();
|
|
34
|
+
const pipe = connection.readable
|
|
35
|
+
.pipeTo(new WritableStream({
|
|
36
|
+
write: async (packet) => {
|
|
37
|
+
// Here is similar to `AdbPacketDispatcher`,
|
|
38
|
+
// But the received packet types and send packet processing are different.
|
|
39
|
+
switch (packet.command) {
|
|
40
|
+
case AdbCommand.Connect:
|
|
41
|
+
version = Math.min(version, packet.arg0);
|
|
42
|
+
maxPayloadSize = Math.min(maxPayloadSize, packet.arg1);
|
|
43
|
+
resolver.resolve(decodeUtf8(packet.payload));
|
|
44
|
+
break;
|
|
45
|
+
case AdbCommand.Auth: {
|
|
46
|
+
await sendPacket(writer, await processor.process(packet));
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
default:
|
|
50
|
+
// Maybe the previous ADB client exited without reading all packets,
|
|
51
|
+
// so they are still waiting in OS internal buffer.
|
|
52
|
+
// Just ignore them.
|
|
53
|
+
// Because a `Connect` packet will reset the device,
|
|
54
|
+
// Eventually there will be `Connect` and `Auth` response packets.
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
}), {
|
|
59
|
+
// Don't cancel the source ReadableStream on AbortSignal abort.
|
|
60
|
+
preventCancel: true,
|
|
61
|
+
signal: abortController.signal,
|
|
62
|
+
})
|
|
63
|
+
.then(async () => {
|
|
64
|
+
await processor.close?.();
|
|
65
|
+
// If `resolver` is already settled, call `reject` won't do anything.
|
|
66
|
+
resolver.reject(new Error("Connection closed unexpectedly"));
|
|
67
|
+
}, async (e) => {
|
|
68
|
+
await processor.close?.();
|
|
69
|
+
resolver.reject(e);
|
|
70
|
+
});
|
|
71
|
+
if (initialDelayedAckBytes <= 0) {
|
|
72
|
+
// Disable delayed ack by not sending this feature to the device
|
|
73
|
+
features = features.filter((feature) => feature !== AdbFeature.DelayedAck);
|
|
74
|
+
initialDelayedAckBytes = 0;
|
|
75
|
+
}
|
|
76
|
+
let banner;
|
|
77
|
+
try {
|
|
78
|
+
await sendPacket(writer, {
|
|
79
|
+
command: AdbCommand.Connect,
|
|
80
|
+
arg0: version,
|
|
81
|
+
arg1: maxPayloadSize,
|
|
82
|
+
// The terminating `;` is required in formal definition
|
|
83
|
+
// But ADB daemon (all versions) can still work without it
|
|
84
|
+
payload: encodeUtf8(`host::features=${features.join(",")}`),
|
|
85
|
+
});
|
|
86
|
+
banner = await resolver.promise;
|
|
87
|
+
}
|
|
88
|
+
finally {
|
|
89
|
+
// When failed, release locks on `connection` so the caller can try again.
|
|
90
|
+
// When success, also release locks so `AdbPacketDispatcher` can use them.
|
|
91
|
+
abortController.abort();
|
|
92
|
+
writer.releaseLock();
|
|
93
|
+
// Wait until pipe stops (`ReadableStream` lock released)
|
|
94
|
+
await pipe;
|
|
95
|
+
}
|
|
96
|
+
return new AdbDaemonTransport({
|
|
97
|
+
serial,
|
|
98
|
+
connection,
|
|
99
|
+
version,
|
|
100
|
+
maxPayloadSize,
|
|
101
|
+
banner,
|
|
102
|
+
features,
|
|
103
|
+
initialDelayedAckBytes,
|
|
104
|
+
preserveConnection,
|
|
105
|
+
readTimeLimit,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=authenticator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authenticator.js","sourceRoot":"","sources":["../../../src/daemon/auth/authenticator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EACH,eAAe,EACf,UAAU,EACV,cAAc,GACjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAElE,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAE7D,OAAO,EACH,uCAAuC,EACvC,kBAAkB,GACrB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AA4BtE;;;;GAIG;AACH,SAAS,UAAU,CACf,MAA8D,EAC9D,MAAqB;IAErB,qCAAqC;IACrC,uDAAuD;IACtD,MAAwB,CAAC,QAAQ,GAAG,iBAAiB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACtE,MAAwB,CAAC,KAAK,GAAG,MAAM,CAAC,OAAO,GAAG,UAAU,CAAC;IAC9D,OAAO,UAA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;IACpC,CAAC;YAAS,CAAC;QACP,0EAA0E;QAC1E,0EAA0E;QAC1E,eAAe,CAAC,KAAK,EAAE,CAAC;QACxB,MAAM,CAAC,WAAW,EAAE,CAAC;QAErB,yDAAyD;QACzD,MAAM,IAAI,CAAC;IACf,CAAC;IAED,OAAO,IAAI,kBAAkB,CAAC;QAC1B,MAAM;QACN,UAAU;QACV,OAAO;QACP,cAAc;QACd,MAAM;QACN,QAAQ;QACR,sBAAsB;QACtB,kBAAkB;QAClB,aAAa;KAChB,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/daemon/auth/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/daemon/auth/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { MaybePromiseLike } from "@yume-chan/async";
|
|
2
|
+
import type { AdbPacketData } from "../packet.js";
|
|
3
|
+
import type { AdbDaemonAuthProcessor } from "./authenticator.js";
|
|
4
|
+
import type { AdbPrivateKey } from "./type.js";
|
|
5
|
+
export type MaybeError<T> = T | Error;
|
|
6
|
+
export type AdbKeyIterable = Iterable<MaybeError<AdbPrivateKey>> | AsyncIterable<MaybeError<AdbPrivateKey>>;
|
|
7
|
+
export interface AdbCredentialManager {
|
|
8
|
+
/**
|
|
9
|
+
* Generates and stores a RSA private key with modulus length `2048` and public exponent `65537`.
|
|
10
|
+
*/
|
|
11
|
+
generateKey(): MaybePromiseLike<AdbPrivateKey>;
|
|
12
|
+
/**
|
|
13
|
+
* Synchronously or asynchronously iterates through all stored RSA private keys.
|
|
14
|
+
*
|
|
15
|
+
* Each call to `iterateKeys` must return a different iterator that iterate through all stored keys.
|
|
16
|
+
*/
|
|
17
|
+
iterateKeys(): AdbKeyIterable;
|
|
18
|
+
}
|
|
19
|
+
export interface AdbKeyInfo {
|
|
20
|
+
fingerprint: string;
|
|
21
|
+
name: string | undefined;
|
|
22
|
+
}
|
|
23
|
+
export declare const AdbDaemonAuthType: {
|
|
24
|
+
readonly Token: 1;
|
|
25
|
+
readonly Signature: 2;
|
|
26
|
+
readonly PublicKey: 3;
|
|
27
|
+
};
|
|
28
|
+
export type AdbDaemonAuthType = (typeof AdbDaemonAuthType)[keyof typeof AdbDaemonAuthType];
|
|
29
|
+
export interface AdbDaemonDefaultAuthProcessorInit {
|
|
30
|
+
credentialManager: AdbCredentialManager;
|
|
31
|
+
onKeyLoadError?: ((error: Error) => void) | undefined;
|
|
32
|
+
onSignatureAuthentication?: ((key: AdbKeyInfo) => void) | undefined;
|
|
33
|
+
onSignatureRejected?: ((key: AdbKeyInfo) => void) | undefined;
|
|
34
|
+
onPublicKeyAuthentication?: ((key: AdbKeyInfo) => void) | undefined;
|
|
35
|
+
}
|
|
36
|
+
export declare class AdbDaemonDefaultAuthProcessor implements AdbDaemonAuthProcessor {
|
|
37
|
+
#private;
|
|
38
|
+
constructor(init: AdbDaemonDefaultAuthProcessorInit);
|
|
39
|
+
process(packet: AdbPacketData): Promise<AdbPacketData>;
|
|
40
|
+
close(): Promise<undefined>;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=packet-processor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packet-processor.d.ts","sourceRoot":"","sources":["../../../src/daemon/auth/packet-processor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAQzD,OAAO,KAAK,EAAE,aAAa,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OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IAwDtD,KAAK,IAAI,OAAO,CAAC,SAAS,CAAC;CAMpC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { EmptyUint8Array, encodeUtf8 } from "@yume-chan/struct";
|
|
2
|
+
import { calculateBase64EncodedLength, encodeBase64, } from "../../utils/base64.js";
|
|
3
|
+
import { rsaSign } from "../crypto.js";
|
|
4
|
+
import { AdbCommand } from "../packet.js";
|
|
5
|
+
import { adbGeneratePublicKey, adbGetPublicKeyFingerprint, adbGetPublicKeySize, } from "./public-key.js";
|
|
6
|
+
export const AdbDaemonAuthType = {
|
|
7
|
+
Token: 1,
|
|
8
|
+
Signature: 2,
|
|
9
|
+
PublicKey: 3,
|
|
10
|
+
};
|
|
11
|
+
export class AdbDaemonDefaultAuthProcessor {
|
|
12
|
+
#credentialManager;
|
|
13
|
+
#onKeyLoadError;
|
|
14
|
+
#onSignatureAuthentication;
|
|
15
|
+
#onSignatureRejected;
|
|
16
|
+
#onPublicKeyAuthentication;
|
|
17
|
+
#iterator;
|
|
18
|
+
#prevKeyInfo;
|
|
19
|
+
#firstKey;
|
|
20
|
+
constructor(init) {
|
|
21
|
+
this.#credentialManager = init.credentialManager;
|
|
22
|
+
this.#onKeyLoadError = init.onKeyLoadError;
|
|
23
|
+
this.#onSignatureAuthentication = init.onSignatureAuthentication;
|
|
24
|
+
this.#onSignatureRejected = init.onSignatureRejected;
|
|
25
|
+
this.#onPublicKeyAuthentication = init.onPublicKeyAuthentication;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Gets the next available private key.
|
|
29
|
+
* @returns The next available private key, or `undefined` if no more key is available
|
|
30
|
+
*/
|
|
31
|
+
async #getNextKey() {
|
|
32
|
+
if (!this.#iterator) {
|
|
33
|
+
const iterable = this.#credentialManager.iterateKeys();
|
|
34
|
+
if (Symbol.iterator in iterable) {
|
|
35
|
+
this.#iterator = iterable[Symbol.iterator]();
|
|
36
|
+
}
|
|
37
|
+
else if (Symbol.asyncIterator in iterable) {
|
|
38
|
+
this.#iterator = iterable[Symbol.asyncIterator]();
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
throw new Error("`iterateKeys` doesn't return an iterator");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
while (true) {
|
|
45
|
+
const { done, value } = await this.#iterator.next();
|
|
46
|
+
if (done) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
if (value instanceof Error) {
|
|
50
|
+
// Report the error, then continue calling `next`
|
|
51
|
+
this.#onKeyLoadError?.(value);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
return value;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Tries to sign the challenge using the next private key.
|
|
59
|
+
*
|
|
60
|
+
* @param challenge The data to sign
|
|
61
|
+
* @returns An `AdbPacket` containing the response, or `undefined` if no key is available
|
|
62
|
+
*/
|
|
63
|
+
async #sign(challenge) {
|
|
64
|
+
const key = await this.#getNextKey();
|
|
65
|
+
if (!key) {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
if (!this.#firstKey) {
|
|
69
|
+
this.#firstKey = key;
|
|
70
|
+
}
|
|
71
|
+
// A new challenge implies the previous signature was rejected.
|
|
72
|
+
if (this.#prevKeyInfo) {
|
|
73
|
+
this.#onSignatureRejected?.(this.#prevKeyInfo);
|
|
74
|
+
}
|
|
75
|
+
const fingerprint = adbGetPublicKeyFingerprint(key);
|
|
76
|
+
this.#prevKeyInfo = { fingerprint, name: key.name };
|
|
77
|
+
this.#onSignatureAuthentication?.(this.#prevKeyInfo);
|
|
78
|
+
return {
|
|
79
|
+
command: AdbCommand.Auth,
|
|
80
|
+
arg0: AdbDaemonAuthType.Signature,
|
|
81
|
+
arg1: 0,
|
|
82
|
+
payload: rsaSign(key, challenge),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
async process(packet) {
|
|
86
|
+
if (packet.arg0 !== AdbDaemonAuthType.Token) {
|
|
87
|
+
throw new Error("Unsupported authentication packet");
|
|
88
|
+
}
|
|
89
|
+
const signature = await this.#sign(packet.payload);
|
|
90
|
+
if (signature) {
|
|
91
|
+
return signature;
|
|
92
|
+
}
|
|
93
|
+
let key = this.#firstKey;
|
|
94
|
+
if (!key) {
|
|
95
|
+
key = await this.#credentialManager.generateKey();
|
|
96
|
+
}
|
|
97
|
+
const publicKeyLength = adbGetPublicKeySize();
|
|
98
|
+
const [publicKeyBase64Length] = calculateBase64EncodedLength(publicKeyLength);
|
|
99
|
+
const nameBuffer = key.name?.length
|
|
100
|
+
? encodeUtf8(key.name)
|
|
101
|
+
: EmptyUint8Array;
|
|
102
|
+
const publicKeyBuffer = new Uint8Array(publicKeyBase64Length +
|
|
103
|
+
(nameBuffer.length ? nameBuffer.length + 1 : 0) + // Space character + name
|
|
104
|
+
1);
|
|
105
|
+
adbGeneratePublicKey(key, publicKeyBuffer);
|
|
106
|
+
const fingerprint = adbGetPublicKeyFingerprint(publicKeyBuffer.subarray(0, publicKeyLength));
|
|
107
|
+
encodeBase64(publicKeyBuffer.subarray(0, publicKeyLength), publicKeyBuffer);
|
|
108
|
+
if (nameBuffer.length) {
|
|
109
|
+
publicKeyBuffer[publicKeyBase64Length] = 0x20;
|
|
110
|
+
publicKeyBuffer.set(nameBuffer, publicKeyBase64Length + 1);
|
|
111
|
+
}
|
|
112
|
+
this.#onPublicKeyAuthentication?.({
|
|
113
|
+
fingerprint,
|
|
114
|
+
name: key.name,
|
|
115
|
+
});
|
|
116
|
+
return {
|
|
117
|
+
command: AdbCommand.Auth,
|
|
118
|
+
arg0: AdbDaemonAuthType.PublicKey,
|
|
119
|
+
arg1: 0,
|
|
120
|
+
payload: publicKeyBuffer,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
async close() {
|
|
124
|
+
await this.#iterator?.return?.();
|
|
125
|
+
this.#iterator = undefined;
|
|
126
|
+
this.#firstKey = undefined;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=packet-processor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packet-processor.js","sourceRoot":"","sources":["../../../src/daemon/auth/packet-processor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEhE,OAAO,EACH,4BAA4B,EAC5B,YAAY,GACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,OAAO,EACH,oBAAoB,EACpB,0BAA0B,EAC1B,mBAAmB,GACtB,MAAM,iBAAiB,CAAC;AA4BzB,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC7B,KAAK,EAAE,CAAC;IACR,SAAS,EAAE,CAAC;IACZ,SAAS,EAAE,CAAC;CACN,CAAC;AAaX,MAAM,OAAO,6BAA6B;IACtC,kBAAkB,CAAuB;IACzC,eAAe,CAAuC;IACtD,0BAA0B,CAA0C;IACpE,oBAAoB,CAA0C;IAC9D,0BAA0B,CAA0C;IAEpE,SAAS,CAGO;IAEhB,YAAY,CAAyB;IACrC,SAAS,CAA4B;IAErC,YAAY,IAAuC;QAC/C,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,iBAAiB,CAAC;QACjD,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,cAAc,CAAC;QAC3C,IAAI,CAAC,0BAA0B,GAAG,IAAI,CAAC,yBAAyB,CAAC;QACjE,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,mBAAmB,CAAC;QACrD,IAAI,CAAC,0BAA0B,GAAG,IAAI,CAAC,yBAAyB,CAAC;IACrE,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,WAAW;QACb,IAAI,CAAC,IAAI,CAAC,SAAS,EAA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AU,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,yBAAyB;YAC3E,CAAC,CACR,CAAC;QAEF,oBAAoB,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;QAC3C,MAAM,WAAW,GAAG,0BAA0B,CAC1C,eAAe,CAAC,QAAQ,CAAC,CAAC,EAAE,eAAe,CAAC,CAC/C,CAAC;QAEF,YAAY,CACR,eAAe,CAAC,QAAQ,CAAC,CAAC,EAAE,eAAe,CAAC,EAC5C,eAAe,CAClB,CAAC;QAEF,IAAI,UAAU,CAAC,MAAM,EAAE,CAAC;YACpB,eAAe,CAAC,qBAAqB,CAAC,GAAG,IAAI,CAAC;YAC9C,eAAe,CAAC,GAAG,CAAC,UAAU,EAAE,qBAAqB,GAAG,CAAC,CAAC,CAAC;QAC/D,CAAC;QAED,IAAI,CAAC,0BAA0B,EAAE,CAAC;YAC9B,WAAW;YACX,IAAI,EAAE,GAAG,CAAC,IAAI;SACjB,CAAC,CAAC;QAEH,OAAO;YACH,OAAO,EAAE,UAAU,CAAC,IAAI;YACxB,IAAI,EAAE,iBAAiB,CAAC,SAAS;YACjC,IAAI,EAAE,CAAC;YACP,OAAO,EAAE,eAAe;SAC3B,CAAC;IACN,CAAC;IAED,KAAK,CAAC,KAAK;QACP,MAAM,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC;QAEjC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;CACJ"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SimpleRsaPrivateKey } from "../crypto.js";
|
|
2
|
+
import type { AdbPrivateKey } from "./type.js";
|
|
3
|
+
export declare function adbGetPublicKeySize(): number;
|
|
4
|
+
export declare function adbGeneratePublicKey(privateKey: SimpleRsaPrivateKey): Uint8Array<ArrayBuffer>;
|
|
5
|
+
export declare function adbGeneratePublicKey(privateKey: SimpleRsaPrivateKey, output: Uint8Array): number;
|
|
6
|
+
export declare function adbGetPublicKeyFingerprint(privateKey: AdbPrivateKey): string;
|
|
7
|
+
export declare function adbGetPublicKeyFingerprint(publicKey: Uint8Array): string;
|
|
8
|
+
//# sourceMappingURL=public-key.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-key.d.ts","sourceRoot":"","sources":["../../../src/daemon/auth/public-key.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAK/C,wBAAgB,mBAAmB,WAElC;AAED,wBAAgB,oBAAoB,CAChC,UAAU,EAAE,mBAAmB,GAChC,UAAU,CAAC,WAAW,CAAC,CAAC;AAC3B,wBAAgB,oBAAoB,CAChC,UAAU,EAAE,mBAAmB,EAC/B,MAAM,EAAE,UAAU,GACnB,MAAM,CAAC;AA+EV,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,aAAa,GAAG,MAAM,CAAC;AAC9E,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,UAAU,GAAG,MAAM,CAAC"}
|