@yume-chan/adb 2.6.2 → 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/banner.js.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 -72
- 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 -10
- 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 +9 -9
- package/src/adb.ts +44 -35
- package/src/banner.ts +2 -1
- 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 -101
- 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 +94 -93
- 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 -10
- 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 -257
- 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 -203
- 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
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { getUint32LittleEndian } from "@yume-chan/no-data-view";
|
|
2
|
+
import type {
|
|
3
|
+
MaybeConsumable,
|
|
4
|
+
WritableStreamDefaultWriter,
|
|
5
|
+
} from "@yume-chan/stream-extra";
|
|
6
|
+
import {
|
|
7
|
+
BufferCombiner,
|
|
8
|
+
BufferedReadableStream,
|
|
9
|
+
clearTimeout,
|
|
10
|
+
Consumable,
|
|
11
|
+
setTimeout,
|
|
12
|
+
tryCancel,
|
|
13
|
+
} from "@yume-chan/stream-extra";
|
|
14
|
+
import type { AsyncExactReadable, StructDeserializer } from "@yume-chan/struct";
|
|
15
|
+
import { decodeUtf8, string, struct, u32 } from "@yume-chan/struct";
|
|
16
|
+
|
|
17
|
+
import type { Adb } from "../../adb.js";
|
|
18
|
+
import { AutoResetEvent, encodeUtf8, unreachable } from "../../utils/index.js";
|
|
19
|
+
|
|
20
|
+
import { ResponseId } from "./id/index.js";
|
|
21
|
+
|
|
22
|
+
const NumberRequest = struct({ id: u32, arg: u32 }, { littleEndian: true });
|
|
23
|
+
|
|
24
|
+
class AdbSyncError extends Error {}
|
|
25
|
+
export { AdbSyncError as Error };
|
|
26
|
+
|
|
27
|
+
const FailResponse = struct(
|
|
28
|
+
{ message: string(u32) },
|
|
29
|
+
{
|
|
30
|
+
littleEndian: true,
|
|
31
|
+
postDeserialize(value) {
|
|
32
|
+
throw new AdbSyncError(value.message);
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
function i32ToHex(i: number) {
|
|
38
|
+
return "0x" + i.toString(16).padStart(8, "0");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export class Socket implements AsyncExactReadable {
|
|
42
|
+
static readonly NumberRequest = NumberRequest;
|
|
43
|
+
static readonly FailResponse = FailResponse;
|
|
44
|
+
|
|
45
|
+
readonly #socket: Adb.Socket;
|
|
46
|
+
readonly #writer: WritableStreamDefaultWriter<MaybeConsumable<Uint8Array>>;
|
|
47
|
+
readonly #readable: BufferedReadableStream;
|
|
48
|
+
readonly #writeLock = new AutoResetEvent();
|
|
49
|
+
readonly #combiner: BufferCombiner;
|
|
50
|
+
#idleTimeoutId: ReturnType<typeof setTimeout> | null = null;
|
|
51
|
+
|
|
52
|
+
get position() {
|
|
53
|
+
return this.#readable.position;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
get closed(): Promise<undefined> {
|
|
57
|
+
return this.#socket.closed;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
constructor(socket: Adb.Socket, bufferSize: number) {
|
|
61
|
+
this.#socket = socket;
|
|
62
|
+
this.#writer = socket.writable.getWriter();
|
|
63
|
+
this.#readable = new BufferedReadableStream(socket.readable);
|
|
64
|
+
this.#combiner = new BufferCombiner(bufferSize);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Start an idle timer that will close the socket after the specified duration.
|
|
69
|
+
* The timer is automatically cancelled when the socket is used.
|
|
70
|
+
* @param timeout The timeout in milliseconds
|
|
71
|
+
* @param callback The callback to invoke when the timeout expires
|
|
72
|
+
*/
|
|
73
|
+
startIdleTimer(timeout: number, callback: () => void) {
|
|
74
|
+
this.clearIdleTimer();
|
|
75
|
+
this.#idleTimeoutId = setTimeout(callback, timeout);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Clear the idle timer.
|
|
80
|
+
*/
|
|
81
|
+
clearIdleTimer() {
|
|
82
|
+
if (this.#idleTimeoutId !== null) {
|
|
83
|
+
clearTimeout(this.#idleTimeoutId);
|
|
84
|
+
this.#idleTimeoutId = null;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Write a packet to the socket.
|
|
90
|
+
* @param packet The packet to write. Must be smaller than the buffer size.
|
|
91
|
+
*/
|
|
92
|
+
#writeOne(packet: Uint8Array) {
|
|
93
|
+
// `#combiner` will reuse the buffer, so we need to use the Consumable pattern
|
|
94
|
+
return Consumable.WritableStream.write(this.#writer, packet);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async #withWriteLock(callback: () => Promise<void>) {
|
|
98
|
+
try {
|
|
99
|
+
await this.#writeLock.wait();
|
|
100
|
+
await callback();
|
|
101
|
+
} finally {
|
|
102
|
+
this.#writeLock.notifyOne();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async flush() {
|
|
107
|
+
const buffer = this.#combiner.flush();
|
|
108
|
+
if (buffer) {
|
|
109
|
+
await this.#withWriteLock(() => this.#writeOne(buffer));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
async #write(data: Uint8Array) {
|
|
114
|
+
for (const buffer of this.#combiner.push(data)) {
|
|
115
|
+
await this.#writeOne(buffer);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
write(data: Uint8Array) {
|
|
120
|
+
return this.#withWriteLock(() => this.#write(data));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async writeRequest(id: number, value: number | string | Uint8Array) {
|
|
124
|
+
return this.#withWriteLock(async () => {
|
|
125
|
+
if (typeof value === "number") {
|
|
126
|
+
await this.#write(NumberRequest.serialize({ id, arg: value }));
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (typeof value === "string") {
|
|
131
|
+
value = encodeUtf8(value);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
await this.#write(
|
|
135
|
+
NumberRequest.serialize({ id, arg: value.length }),
|
|
136
|
+
);
|
|
137
|
+
await this.#write(value);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
async readExactly(length: number) {
|
|
142
|
+
// The request may still be in the internal buffer.
|
|
143
|
+
// Call `flush` to send it before starting reading
|
|
144
|
+
await this.flush();
|
|
145
|
+
return await this.#readable.readExactly(length);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async readResponse<T>(id: number, type: StructDeserializer<T>) {
|
|
149
|
+
const buffer = await this.readExactly(4);
|
|
150
|
+
switch (getUint32LittleEndian(buffer, 0)) {
|
|
151
|
+
case ResponseId.Fail:
|
|
152
|
+
await FailResponse.deserialize(this.#readable);
|
|
153
|
+
unreachable();
|
|
154
|
+
case id:
|
|
155
|
+
return await type.deserialize(this.#readable);
|
|
156
|
+
default:
|
|
157
|
+
// non-recoverable
|
|
158
|
+
throw new Error(
|
|
159
|
+
`Expected '${id}', but got '${decodeUtf8(buffer)}'`,
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
async *readResponses<T>(
|
|
165
|
+
expectedId: number,
|
|
166
|
+
type: StructDeserializer<T>,
|
|
167
|
+
): AsyncGenerator<T, void, void> {
|
|
168
|
+
await this.flush();
|
|
169
|
+
|
|
170
|
+
while (true) {
|
|
171
|
+
const buffer = await this.#readable.readExactly(4);
|
|
172
|
+
const actualId = getUint32LittleEndian(buffer, 0);
|
|
173
|
+
switch (actualId) {
|
|
174
|
+
case ResponseId.Fail:
|
|
175
|
+
await FailResponse.deserialize(this.#readable);
|
|
176
|
+
unreachable();
|
|
177
|
+
case ResponseId.Done:
|
|
178
|
+
// `DONE` responses' size are always same as the request's normal response.
|
|
179
|
+
//
|
|
180
|
+
// For example, `DONE` responses for `LIST` requests are 16 bytes (same as `DENT` responses),
|
|
181
|
+
// but `DONE` responses for `STAT` requests are 12 bytes (same as `STAT` responses).
|
|
182
|
+
await this.#readable.readExactly(type.size);
|
|
183
|
+
return;
|
|
184
|
+
case expectedId:
|
|
185
|
+
yield await type.deserialize(this.#readable);
|
|
186
|
+
break;
|
|
187
|
+
default:
|
|
188
|
+
// non-recoverable
|
|
189
|
+
throw new Error(
|
|
190
|
+
`Expected ${i32ToHex(expectedId)} or ${i32ToHex(ResponseId.Done)}, but got ${i32ToHex(actualId)}`,
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
async close() {
|
|
197
|
+
this.clearIdleTimer();
|
|
198
|
+
await tryCancel(this.#readable);
|
|
199
|
+
await this.#socket.close();
|
|
200
|
+
}
|
|
201
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Adb } from "../adb.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* ADB daemon checks for the following properties in the order of
|
|
@@ -27,13 +27,19 @@ function parsePort(value: string): number | undefined {
|
|
|
27
27
|
return Number.parseInt(value, 10);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export class AdbTcpIpService
|
|
30
|
+
export class AdbTcpIpService {
|
|
31
|
+
readonly #adb: Adb;
|
|
32
|
+
|
|
33
|
+
constructor(adb: Adb) {
|
|
34
|
+
this.#adb = adb;
|
|
35
|
+
}
|
|
36
|
+
|
|
31
37
|
async getListenAddresses(): Promise<AdbTcpIpListenAddresses> {
|
|
32
|
-
const serviceListenAddresses = await this
|
|
38
|
+
const serviceListenAddresses = await this.#adb.getProp(
|
|
33
39
|
"service.adb.listen_addrs",
|
|
34
40
|
);
|
|
35
|
-
const servicePort = await this
|
|
36
|
-
const persistPort = await this
|
|
41
|
+
const servicePort = await this.#adb.getProp("service.adb.tcp.port");
|
|
42
|
+
const persistPort = await this.#adb.getProp("persist.adb.tcp.port");
|
|
37
43
|
|
|
38
44
|
return {
|
|
39
45
|
serviceListenAddresses:
|
|
@@ -50,7 +56,7 @@ export class AdbTcpIpService extends AdbServiceBase {
|
|
|
50
56
|
throw new TypeError(`Invalid port ${port}`);
|
|
51
57
|
}
|
|
52
58
|
|
|
53
|
-
const output = await this
|
|
59
|
+
const output = await this.#adb.createSocketAndWait(`tcpip:${port}`);
|
|
54
60
|
if (output !== `restarting in TCP mode port: ${port}\n`) {
|
|
55
61
|
throw new Error(output);
|
|
56
62
|
}
|
|
@@ -58,7 +64,7 @@ export class AdbTcpIpService extends AdbServiceBase {
|
|
|
58
64
|
}
|
|
59
65
|
|
|
60
66
|
async disable(): Promise<string> {
|
|
61
|
-
const output = await this
|
|
67
|
+
const output = await this.#adb.createSocketAndWait("usb:");
|
|
62
68
|
if (output !== "restarting in USB mode\n") {
|
|
63
69
|
throw new Error(output);
|
|
64
70
|
}
|
|
@@ -3,7 +3,6 @@ export function toLocalUint8Array(value: Uint8Array): Uint8Array<ArrayBuffer> {
|
|
|
3
3
|
return value as Uint8Array<ArrayBuffer>;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return copy;
|
|
6
|
+
// This invokes the `constructor(Iterable<number>)` overload and copies the data
|
|
7
|
+
return new Uint8Array(value);
|
|
9
8
|
}
|
package/src/utils/base64.ts
CHANGED
|
@@ -293,7 +293,20 @@ function encodeBackward(
|
|
|
293
293
|
}
|
|
294
294
|
}
|
|
295
295
|
|
|
296
|
+
function getCharIndex(input: string, offset: number) {
|
|
297
|
+
const charCode = input.charCodeAt(offset);
|
|
298
|
+
const index = charToIndex[charCode];
|
|
299
|
+
if (index === undefined) {
|
|
300
|
+
throw new Error("Invalid Base64 character: " + input[offset]);
|
|
301
|
+
}
|
|
302
|
+
return index;
|
|
303
|
+
}
|
|
304
|
+
|
|
296
305
|
export function decodeBase64(input: string): Uint8Array<ArrayBuffer> {
|
|
306
|
+
if (input.length % 4 !== 0) {
|
|
307
|
+
throw new Error("Invalid Base64 length: " + input.length);
|
|
308
|
+
}
|
|
309
|
+
|
|
297
310
|
let padding: number;
|
|
298
311
|
if (input[input.length - 2] === "=") {
|
|
299
312
|
padding = 2;
|
|
@@ -307,17 +320,18 @@ export function decodeBase64(input: string): Uint8Array<ArrayBuffer> {
|
|
|
307
320
|
let sIndex = 0;
|
|
308
321
|
let dIndex = 0;
|
|
309
322
|
|
|
310
|
-
|
|
311
|
-
|
|
323
|
+
const loopEnd = input.length - (padding !== 0 ? 4 : 0);
|
|
324
|
+
while (sIndex < loopEnd) {
|
|
325
|
+
const a = getCharIndex(input, sIndex);
|
|
312
326
|
sIndex += 1;
|
|
313
327
|
|
|
314
|
-
const b =
|
|
328
|
+
const b = getCharIndex(input, sIndex);
|
|
315
329
|
sIndex += 1;
|
|
316
330
|
|
|
317
|
-
const c =
|
|
331
|
+
const c = getCharIndex(input, sIndex);
|
|
318
332
|
sIndex += 1;
|
|
319
333
|
|
|
320
|
-
const d =
|
|
334
|
+
const d = getCharIndex(input, sIndex);
|
|
321
335
|
sIndex += 1;
|
|
322
336
|
|
|
323
337
|
result[dIndex] = (a << 2) | ((b & 0b11_0000) >> 4);
|
|
@@ -331,23 +345,23 @@ export function decodeBase64(input: string): Uint8Array<ArrayBuffer> {
|
|
|
331
345
|
}
|
|
332
346
|
|
|
333
347
|
if (padding === 1) {
|
|
334
|
-
const a =
|
|
348
|
+
const a = getCharIndex(input, sIndex);
|
|
335
349
|
sIndex += 1;
|
|
336
350
|
|
|
337
|
-
const b =
|
|
351
|
+
const b = getCharIndex(input, sIndex);
|
|
338
352
|
sIndex += 1;
|
|
339
353
|
|
|
340
|
-
const c =
|
|
354
|
+
const c = getCharIndex(input, sIndex);
|
|
341
355
|
|
|
342
356
|
result[dIndex] = (a << 2) | ((b & 0b11_0000) >> 4);
|
|
343
357
|
dIndex += 1;
|
|
344
358
|
|
|
345
359
|
result[dIndex] = ((b & 0b1111) << 4) | ((c & 0b11_1100) >> 2);
|
|
346
360
|
} else if (padding === 2) {
|
|
347
|
-
const a =
|
|
361
|
+
const a = getCharIndex(input, sIndex);
|
|
348
362
|
sIndex += 1;
|
|
349
363
|
|
|
350
|
-
const b =
|
|
364
|
+
const b = getCharIndex(input, sIndex);
|
|
351
365
|
|
|
352
366
|
result[dIndex] = (a << 2) | ((b & 0b11_0000) >> 4);
|
|
353
367
|
}
|
package/src/utils/index.ts
CHANGED
package/src/utils/md5.ts
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getUint32LittleEndian,
|
|
3
|
+
setUint32LittleEndian,
|
|
4
|
+
setUint64LittleEndian,
|
|
5
|
+
} from "@yume-chan/no-data-view";
|
|
6
|
+
|
|
7
|
+
// Taken from https://github.com/digitalbazaar/forge/blob/e3c68e9695607702587583cda291d74e5369f21c/tests/unit/md5.js#L103
|
|
8
|
+
// LICENSE: https://github.com/digitalbazaar/forge/blob/2c37d0bd2864199409edbb520f674d1c93652b23/LICENSE
|
|
9
|
+
|
|
10
|
+
// g values
|
|
11
|
+
// prettier-ignore
|
|
12
|
+
const gs = [
|
|
13
|
+
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
|
14
|
+
1, 6, 11, 0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12,
|
|
15
|
+
5, 8, 11, 14, 1, 4, 7, 10, 13, 0, 3, 6, 9, 12, 15, 2,
|
|
16
|
+
0, 7, 14, 5, 12, 3, 10, 1, 8, 15, 6, 13, 4, 11, 2, 9];
|
|
17
|
+
|
|
18
|
+
// rounds table
|
|
19
|
+
// prettier-ignore
|
|
20
|
+
const rs = [
|
|
21
|
+
7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,
|
|
22
|
+
5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
|
|
23
|
+
4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,
|
|
24
|
+
6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21];
|
|
25
|
+
|
|
26
|
+
const k = /* @__PURE__ */ (() => {
|
|
27
|
+
const k = new Uint32Array(64);
|
|
28
|
+
for (let i = 0; i < 64; i += 1) {
|
|
29
|
+
// get the result of abs(sin(i + 1)) as a 32-bit integer
|
|
30
|
+
k[i] = Math.floor(Math.abs(Math.sin(i + 1)) * 0x100000000);
|
|
31
|
+
}
|
|
32
|
+
return k;
|
|
33
|
+
})();
|
|
34
|
+
|
|
35
|
+
export class Md5 {
|
|
36
|
+
#state = new Uint32Array([0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476]);
|
|
37
|
+
#length = 0n;
|
|
38
|
+
|
|
39
|
+
#buffer = new Uint8Array(64);
|
|
40
|
+
#bufferLength = 0;
|
|
41
|
+
|
|
42
|
+
#w = new Uint32Array(16);
|
|
43
|
+
|
|
44
|
+
update(input: Uint8Array) {
|
|
45
|
+
this.#length += BigInt(input.length);
|
|
46
|
+
|
|
47
|
+
let offset = 0;
|
|
48
|
+
|
|
49
|
+
if (this.#bufferLength) {
|
|
50
|
+
const remaining = 64 - this.#bufferLength;
|
|
51
|
+
this.#buffer.set(input.subarray(0, remaining), this.#bufferLength);
|
|
52
|
+
|
|
53
|
+
if (input.length < remaining) {
|
|
54
|
+
this.#bufferLength += input.length;
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
this.#update(this.#buffer);
|
|
59
|
+
this.#bufferLength = 0;
|
|
60
|
+
offset = remaining;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const end = input.length - 64;
|
|
64
|
+
for (; offset <= end; offset += 64) {
|
|
65
|
+
this.#update(input, offset);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (offset < input.length) {
|
|
69
|
+
this.#buffer.set(input.subarray(offset));
|
|
70
|
+
this.#bufferLength = input.length - offset;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
#update(input: Uint8Array, offset = 0) {
|
|
77
|
+
let a = this.#state[0]!;
|
|
78
|
+
let b = this.#state[1]!;
|
|
79
|
+
let c = this.#state[2]!;
|
|
80
|
+
let d = this.#state[3]!;
|
|
81
|
+
|
|
82
|
+
let t: number;
|
|
83
|
+
let f: number;
|
|
84
|
+
let r: number;
|
|
85
|
+
let i = 0;
|
|
86
|
+
|
|
87
|
+
// round 1
|
|
88
|
+
for (; i < 16; i += 1) {
|
|
89
|
+
this.#w[i] = getUint32LittleEndian(input, offset + i * 4);
|
|
90
|
+
f = d ^ (b & (c ^ d));
|
|
91
|
+
t = a + f + k[i]! + this.#w[i]!;
|
|
92
|
+
r = rs[i]!;
|
|
93
|
+
a = d;
|
|
94
|
+
d = c;
|
|
95
|
+
c = b;
|
|
96
|
+
b += (t << r) | (t >>> (32 - r));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// round 2
|
|
100
|
+
for (; i < 32; i += 1) {
|
|
101
|
+
f = c ^ (d & (b ^ c));
|
|
102
|
+
t = a + f + k[i]! + this.#w[gs[i]!]!;
|
|
103
|
+
r = rs[i]!;
|
|
104
|
+
a = d;
|
|
105
|
+
d = c;
|
|
106
|
+
c = b;
|
|
107
|
+
b += (t << r) | (t >>> (32 - r));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// round 3
|
|
111
|
+
for (; i < 48; i += 1) {
|
|
112
|
+
f = b ^ c ^ d;
|
|
113
|
+
t = a + f + k[i]! + this.#w[gs[i]!]!;
|
|
114
|
+
r = rs[i]!;
|
|
115
|
+
a = d;
|
|
116
|
+
d = c;
|
|
117
|
+
c = b;
|
|
118
|
+
b += (t << r) | (t >>> (32 - r));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// round 4
|
|
122
|
+
for (; i < 64; i += 1) {
|
|
123
|
+
f = c ^ (b | ~d);
|
|
124
|
+
t = a + f + k[i]! + this.#w[gs[i]!]!;
|
|
125
|
+
r = rs[i]!;
|
|
126
|
+
a = d;
|
|
127
|
+
d = c;
|
|
128
|
+
c = b;
|
|
129
|
+
b += (t << r) | (t >>> (32 - r));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
this.#state[0]! += a;
|
|
133
|
+
this.#state[1]! += b;
|
|
134
|
+
this.#state[2]! += c;
|
|
135
|
+
this.#state[3]! += d;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
digest() {
|
|
139
|
+
this.#buffer[this.#bufferLength] = 0x80;
|
|
140
|
+
this.#buffer.subarray(this.#bufferLength + 1).fill(0);
|
|
141
|
+
|
|
142
|
+
if (64 - this.#bufferLength < 8) {
|
|
143
|
+
this.#update(this.#buffer);
|
|
144
|
+
|
|
145
|
+
this.#buffer.fill(0);
|
|
146
|
+
this.#bufferLength = 0;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
setUint64LittleEndian(
|
|
150
|
+
this.#buffer,
|
|
151
|
+
this.#buffer.length - 8,
|
|
152
|
+
this.#length << 3n,
|
|
153
|
+
);
|
|
154
|
+
this.#update(this.#buffer);
|
|
155
|
+
|
|
156
|
+
const result = new Uint8Array(16);
|
|
157
|
+
setUint32LittleEndian(result, 0, this.#state[0]!);
|
|
158
|
+
setUint32LittleEndian(result, 4, this.#state[1]!);
|
|
159
|
+
setUint32LittleEndian(result, 8, this.#state[2]!);
|
|
160
|
+
setUint32LittleEndian(result, 12, this.#state[3]!);
|
|
161
|
+
return result;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
reset() {
|
|
165
|
+
this.#state[0] = 0x67452301;
|
|
166
|
+
this.#state[1] = 0xefcdab89;
|
|
167
|
+
this.#state[2] = 0x98badcfe;
|
|
168
|
+
this.#state[3] = 0x10325476;
|
|
169
|
+
this.#bufferLength = 0;
|
|
170
|
+
this.#length = 0n;
|
|
171
|
+
return this;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
let instance: Md5 | undefined;
|
|
176
|
+
|
|
177
|
+
export function md5Digest(input: Uint8Array) {
|
|
178
|
+
if (!instance) {
|
|
179
|
+
instance = new Md5();
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const result = instance.update(input).digest();
|
|
183
|
+
instance.reset();
|
|
184
|
+
return result;
|
|
185
|
+
}
|
|
Binary file
|