@yume-chan/adb 0.0.16 → 0.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +18 -0
- package/CHANGELOG.md +13 -1
- package/LICENSE +1 -1
- package/esm/adb.d.ts +13 -8
- package/esm/adb.d.ts.map +1 -1
- package/esm/adb.js +63 -38
- package/esm/adb.js.map +1 -1
- package/esm/auth.d.ts +4 -4
- package/esm/auth.d.ts.map +1 -1
- package/esm/auth.js +6 -6
- package/esm/auth.js.map +1 -1
- package/esm/backend.d.ts +3 -3
- package/esm/backend.d.ts.map +1 -1
- package/esm/commands/base.d.ts +2 -2
- package/esm/commands/base.d.ts.map +1 -1
- package/esm/commands/base.js +1 -1
- package/esm/commands/base.js.map +1 -1
- package/esm/commands/framebuffer.d.ts +22 -6
- package/esm/commands/framebuffer.d.ts.map +1 -1
- package/esm/commands/framebuffer.js +33 -45
- package/esm/commands/framebuffer.js.map +1 -1
- package/esm/commands/install.d.ts +2 -2
- package/esm/commands/install.d.ts.map +1 -1
- package/esm/commands/install.js +12 -5
- package/esm/commands/install.js.map +1 -1
- package/esm/commands/power.d.ts.map +1 -1
- package/esm/commands/power.js +13 -9
- package/esm/commands/power.js.map +1 -1
- package/esm/commands/reverse.d.ts +5 -5
- package/esm/commands/reverse.d.ts.map +1 -1
- package/esm/commands/reverse.js +20 -18
- package/esm/commands/reverse.js.map +1 -1
- package/esm/commands/subprocess/command.d.ts +52 -0
- package/esm/commands/subprocess/command.d.ts.map +1 -0
- package/esm/commands/subprocess/command.js +81 -0
- package/esm/commands/subprocess/command.js.map +1 -0
- package/esm/commands/subprocess/index.d.ts +1 -53
- package/esm/commands/subprocess/index.d.ts.map +1 -1
- package/esm/commands/subprocess/index.js +1 -85
- package/esm/commands/subprocess/index.js.map +1 -1
- package/esm/commands/subprocess/protocols/none.d.ts +5 -5
- package/esm/commands/subprocess/protocols/none.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/none.js +5 -3
- package/esm/commands/subprocess/protocols/none.js.map +1 -1
- package/esm/commands/subprocess/protocols/shell.d.ts +4 -4
- package/esm/commands/subprocess/protocols/shell.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/shell.js +28 -20
- package/esm/commands/subprocess/protocols/shell.js.map +1 -1
- package/esm/commands/subprocess/protocols/types.d.ts +7 -7
- package/esm/commands/subprocess/protocols/types.d.ts.map +1 -1
- package/esm/commands/sync/index.d.ts +1 -1
- package/esm/commands/sync/index.d.ts.map +1 -1
- package/esm/commands/sync/index.js +1 -1
- package/esm/commands/sync/index.js.map +1 -1
- package/esm/commands/sync/list.d.ts +7 -7
- package/esm/commands/sync/list.d.ts.map +1 -1
- package/esm/commands/sync/list.js +34 -50
- package/esm/commands/sync/list.js.map +1 -1
- package/esm/commands/sync/pull.d.ts +5 -4
- package/esm/commands/sync/pull.d.ts.map +1 -1
- package/esm/commands/sync/pull.js +21 -22
- package/esm/commands/sync/pull.js.map +1 -1
- package/esm/commands/sync/push.d.ts +4 -4
- package/esm/commands/sync/push.d.ts.map +1 -1
- package/esm/commands/sync/push.js +7 -11
- package/esm/commands/sync/push.js.map +1 -1
- package/esm/commands/sync/request.d.ts +4 -4
- package/esm/commands/sync/request.d.ts.map +1 -1
- package/esm/commands/sync/request.js +6 -6
- package/esm/commands/sync/request.js.map +1 -1
- package/esm/commands/sync/response.d.ts +5 -10
- package/esm/commands/sync/response.d.ts.map +1 -1
- package/esm/commands/sync/response.js +35 -26
- package/esm/commands/sync/response.js.map +1 -1
- package/esm/commands/sync/stat.d.ts +7 -7
- package/esm/commands/sync/stat.d.ts.map +1 -1
- package/esm/commands/sync/stat.js +48 -55
- package/esm/commands/sync/stat.js.map +1 -1
- package/esm/commands/sync/sync.d.ts +7 -7
- package/esm/commands/sync/sync.d.ts.map +1 -1
- package/esm/commands/sync/sync.js +25 -22
- package/esm/commands/sync/sync.js.map +1 -1
- package/esm/crypto.d.ts.map +1 -1
- package/esm/crypto.js +26 -16
- package/esm/crypto.js.map +1 -1
- package/esm/index.d.ts +9 -10
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +9 -10
- package/esm/index.js.map +1 -1
- package/esm/packet.d.ts +8 -8
- package/esm/packet.d.ts.map +1 -1
- package/esm/packet.js +14 -12
- package/esm/packet.js.map +1 -1
- package/esm/socket/dispatcher.d.ts +11 -6
- package/esm/socket/dispatcher.d.ts.map +1 -1
- package/esm/socket/dispatcher.js +28 -20
- package/esm/socket/dispatcher.js.map +1 -1
- package/esm/socket/index.d.ts +1 -1
- package/esm/socket/index.d.ts.map +1 -1
- package/esm/socket/index.js +1 -1
- package/esm/socket/index.js.map +1 -1
- package/esm/socket/socket.d.ts +5 -5
- package/esm/socket/socket.d.ts.map +1 -1
- package/esm/socket/socket.js +37 -17
- package/esm/socket/socket.js.map +1 -1
- package/esm/utils/auto-reset-event.d.ts +1 -1
- package/esm/utils/auto-reset-event.d.ts.map +1 -1
- package/esm/utils/auto-reset-event.js +2 -2
- package/esm/utils/base64.d.ts +23 -0
- package/esm/utils/base64.d.ts.map +1 -1
- package/esm/utils/base64.js +36 -29
- package/esm/utils/base64.js.map +1 -1
- package/package.json +19 -17
- package/src/adb.ts +140 -86
- package/src/auth.ts +27 -18
- package/src/backend.ts +7 -4
- package/src/commands/base.ts +3 -2
- package/src/commands/framebuffer.ts +48 -47
- package/src/commands/install.ts +20 -10
- package/src/commands/power.ts +14 -10
- package/src/commands/reverse.ts +53 -33
- package/src/commands/subprocess/command.ts +134 -0
- package/src/commands/subprocess/index.ts +1 -137
- package/src/commands/subprocess/protocols/none.ts +10 -6
- package/src/commands/subprocess/protocols/shell.ts +72 -39
- package/src/commands/subprocess/protocols/types.ts +12 -8
- package/src/commands/sync/index.ts +1 -1
- package/src/commands/sync/list.ts +63 -68
- package/src/commands/sync/pull.ts +53 -37
- package/src/commands/sync/push.ts +26 -15
- package/src/commands/sync/request.ts +20 -21
- package/src/commands/sync/response.ts +63 -53
- package/src/commands/sync/stat.ts +91 -90
- package/src/commands/sync/sync.ts +56 -34
- package/src/crypto.ts +61 -33
- package/src/features.ts +1 -1
- package/src/index.ts +9 -11
- package/src/packet.ts +40 -30
- package/src/socket/dispatcher.ts +119 -77
- package/src/socket/index.ts +1 -1
- package/src/socket/socket.ts +68 -26
- package/src/utils/auto-reset-event.ts +3 -3
- package/src/utils/base64.ts +75 -42
- package/tsconfig.build.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/esm/stream/buffered.d.ts +0 -39
- package/esm/stream/buffered.d.ts.map +0 -1
- package/esm/stream/buffered.js +0 -143
- package/esm/stream/buffered.js.map +0 -1
- package/esm/stream/detect.d.ts +0 -2
- package/esm/stream/detect.d.ts.map +0 -1
- package/esm/stream/detect.js +0 -6
- package/esm/stream/detect.js.map +0 -1
- package/esm/stream/detect.native.d.ts +0 -240
- package/esm/stream/detect.native.d.ts.map +0 -1
- package/esm/stream/detect.native.js +0 -60
- package/esm/stream/detect.native.js.map +0 -1
- package/esm/stream/detect.polyfill.d.ts +0 -18
- package/esm/stream/detect.polyfill.d.ts.map +0 -1
- package/esm/stream/detect.polyfill.js +0 -4
- package/esm/stream/detect.polyfill.js.map +0 -1
- package/esm/stream/index.d.ts +0 -4
- package/esm/stream/index.d.ts.map +0 -1
- package/esm/stream/index.js +0 -4
- package/esm/stream/index.js.map +0 -1
- package/esm/stream/transform.d.ts +0 -124
- package/esm/stream/transform.d.ts.map +0 -1
- package/esm/stream/transform.js +0 -379
- package/esm/stream/transform.js.map +0 -1
- package/src/stream/buffered.ts +0 -168
- package/src/stream/detect.native.ts +0 -362
- package/src/stream/detect.polyfill.ts +0 -22
- package/src/stream/detect.ts +0 -7
- package/src/stream/index.ts +0 -3
- package/src/stream/transform.ts +0 -474
- package/tsconfig.test.json +0 -9
- package/web-streams-polyfill-4.0.0-beta.2.tgz +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { type BufferedReadableStream } from "@yume-chan/stream-extra";
|
|
2
|
+
import Struct, { type StructLike, type StructValueType } from "@yume-chan/struct";
|
|
3
3
|
export declare enum AdbSyncResponseId {
|
|
4
4
|
Entry = "DENT",
|
|
5
5
|
Entry2 = "DNT2",
|
|
@@ -11,15 +11,10 @@ export declare enum AdbSyncResponseId {
|
|
|
11
11
|
Ok = "OKAY",
|
|
12
12
|
Fail = "FAIL"
|
|
13
13
|
}
|
|
14
|
-
export declare class AdbSyncDoneResponse implements StructLike<AdbSyncDoneResponse> {
|
|
15
|
-
private length;
|
|
16
|
-
readonly id = AdbSyncResponseId.Done;
|
|
17
|
-
constructor(length: number);
|
|
18
|
-
deserialize(stream: StructAsyncDeserializeStream): Promise<this>;
|
|
19
|
-
}
|
|
20
14
|
export declare const AdbSyncFailResponse: Struct<{
|
|
21
15
|
messageLength: number;
|
|
22
16
|
message: string;
|
|
23
|
-
}, "messageLength",
|
|
24
|
-
export declare function adbSyncReadResponse<T
|
|
17
|
+
}, "messageLength", Record<never, never>, never>;
|
|
18
|
+
export declare function adbSyncReadResponse<T>(stream: BufferedReadableStream, id: AdbSyncResponseId, type: StructLike<T>): Promise<T>;
|
|
19
|
+
export declare function adbSyncReadResponses<T extends Struct<object, PropertyKey, object, any>>(stream: BufferedReadableStream, id: AdbSyncResponseId, type: T): AsyncGenerator<StructValueType<T>, void, void>;
|
|
25
20
|
//# sourceMappingURL=response.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/response.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,MAAM,EAAE,EACX,KAAK,UAAU,EACf,KAAK,eAAe,EACvB,MAAM,mBAAmB,CAAC;AAI3B,oBAAY,iBAAiB;IACzB,KAAK,SAAS;IACd,MAAM,SAAS;IACf,KAAK,SAAS;IACd,IAAI,SAAS;IACb,MAAM,SAAS;IACf,IAAI,SAAS;IACb,IAAI,SAAS;IACb,EAAE,SAAS;IACX,IAAI,SAAS;CAChB;AAED,eAAO,MAAM,mBAAmB;;;gDAK1B,CAAC;AAEP,wBAAsB,mBAAmB,CAAC,CAAC,EACvC,MAAM,EAAE,sBAAsB,EAC9B,EAAE,EAAE,iBAAiB,EACrB,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,GACpB,OAAO,CAAC,CAAC,CAAC,CAWZ;AAED,wBAAuB,oBAAoB,CACvC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,CAAC,EAElD,MAAM,EAAE,sBAAsB,EAC9B,EAAE,EAAE,iBAAiB,EACrB,IAAI,EAAE,CAAC,GACR,cAAc,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAuBhD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Struct from
|
|
1
|
+
import Struct from "@yume-chan/struct";
|
|
2
2
|
import { decodeUtf8 } from "../../utils/index.js";
|
|
3
3
|
export var AdbSyncResponseId;
|
|
4
4
|
(function (AdbSyncResponseId) {
|
|
@@ -12,35 +12,44 @@ export var AdbSyncResponseId;
|
|
|
12
12
|
AdbSyncResponseId["Ok"] = "OKAY";
|
|
13
13
|
AdbSyncResponseId["Fail"] = "FAIL";
|
|
14
14
|
})(AdbSyncResponseId = AdbSyncResponseId || (AdbSyncResponseId = {}));
|
|
15
|
-
// DONE responses' size are always same as the request's normal response.
|
|
16
|
-
// For example DONE responses for LIST requests are 16 bytes (same as DENT responses),
|
|
17
|
-
// but DONE responses for STAT requests are 12 bytes (same as STAT responses)
|
|
18
|
-
// So we need to know responses' size in advance.
|
|
19
|
-
export class AdbSyncDoneResponse {
|
|
20
|
-
length;
|
|
21
|
-
id = AdbSyncResponseId.Done;
|
|
22
|
-
constructor(length) {
|
|
23
|
-
this.length = length;
|
|
24
|
-
}
|
|
25
|
-
async deserialize(stream) {
|
|
26
|
-
await stream.read(this.length);
|
|
27
|
-
return this;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
15
|
export const AdbSyncFailResponse = new Struct({ littleEndian: true })
|
|
31
|
-
.uint32(
|
|
32
|
-
.string(
|
|
33
|
-
.postDeserialize(object => {
|
|
16
|
+
.uint32("messageLength")
|
|
17
|
+
.string("message", { lengthField: "messageLength" })
|
|
18
|
+
.postDeserialize((object) => {
|
|
34
19
|
throw new Error(object.message);
|
|
35
20
|
});
|
|
36
|
-
export async function adbSyncReadResponse(stream,
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
21
|
+
export async function adbSyncReadResponse(stream, id, type) {
|
|
22
|
+
const actualId = decodeUtf8(await stream.read(4));
|
|
23
|
+
switch (actualId) {
|
|
24
|
+
case AdbSyncResponseId.Fail:
|
|
25
|
+
await AdbSyncFailResponse.deserialize(stream);
|
|
26
|
+
throw new Error("Unreachable");
|
|
27
|
+
case id:
|
|
28
|
+
return await type.deserialize(stream);
|
|
29
|
+
default:
|
|
30
|
+
throw new Error(`Expected '${id}', but got '${actualId}'`);
|
|
40
31
|
}
|
|
41
|
-
|
|
42
|
-
|
|
32
|
+
}
|
|
33
|
+
export async function* adbSyncReadResponses(stream, id, type) {
|
|
34
|
+
while (true) {
|
|
35
|
+
const actualId = decodeUtf8(await stream.read(4));
|
|
36
|
+
switch (actualId) {
|
|
37
|
+
case AdbSyncResponseId.Fail:
|
|
38
|
+
await AdbSyncFailResponse.deserialize(stream);
|
|
39
|
+
throw new Error("Unreachable");
|
|
40
|
+
case AdbSyncResponseId.Done:
|
|
41
|
+
// `DONE` responses' size are always same as the request's normal response.
|
|
42
|
+
//
|
|
43
|
+
// For example, `DONE` responses for `LIST` requests are 16 bytes (same as `DENT` responses),
|
|
44
|
+
// but `DONE` responses for `STAT` requests are 12 bytes (same as `STAT` responses).
|
|
45
|
+
await stream.read(type.size);
|
|
46
|
+
return;
|
|
47
|
+
case id:
|
|
48
|
+
yield await type.deserialize(stream);
|
|
49
|
+
break;
|
|
50
|
+
default:
|
|
51
|
+
throw new Error(`Expected '${id}' or '${AdbSyncResponseId.Done}', but got '${actualId}'`);
|
|
52
|
+
}
|
|
43
53
|
}
|
|
44
|
-
throw new Error(`Expected '${Object.keys(types).join(', ')}', but got '${id}'`);
|
|
45
54
|
}
|
|
46
55
|
//# sourceMappingURL=response.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../../src/commands/sync/response.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../../src/commands/sync/response.ts"],"names":[],"mappings":"AACA,OAAO,MAGN,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,MAAM,CAAN,IAAY,iBAUX;AAVD,WAAY,iBAAiB;IACzB,mCAAc,CAAA;IACd,oCAAe,CAAA;IACf,mCAAc,CAAA;IACd,kCAAa,CAAA;IACb,oCAAe,CAAA;IACf,kCAAa,CAAA;IACb,kCAAa,CAAA;IACb,gCAAW,CAAA;IACX,kCAAa,CAAA;AACjB,CAAC,EAVW,iBAAiB,GAAjB,iBAAiB,KAAjB,iBAAiB,QAU5B;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,MAAM,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;KAChE,MAAM,CAAC,eAAe,CAAC;KACvB,MAAM,CAAC,SAAS,EAAE,EAAE,WAAW,EAAE,eAAe,EAAE,CAAC;KACnD,eAAe,CAAC,CAAC,MAAM,EAAE,EAAE;IACxB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AACpC,CAAC,CAAC,CAAC;AAEP,MAAM,CAAC,KAAK,UAAU,mBAAmB,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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { AdbSyncResponseId } from
|
|
1
|
+
import { type BufferedReadableStream, type WritableStreamDefaultWriter } from "@yume-chan/stream-extra";
|
|
2
|
+
import Struct from "@yume-chan/struct";
|
|
3
|
+
import { AdbSyncResponseId } from "./response.js";
|
|
4
4
|
export declare enum LinuxFileType {
|
|
5
5
|
Directory = 4,
|
|
6
6
|
File = 8,
|
|
@@ -26,7 +26,7 @@ export declare const AdbSyncLstatResponse: Struct<{
|
|
|
26
26
|
readonly type: LinuxFileType;
|
|
27
27
|
readonly permission: number;
|
|
28
28
|
}, undefined>;
|
|
29
|
-
export
|
|
29
|
+
export type AdbSyncLstatResponse = typeof AdbSyncLstatResponse["TDeserializeResult"];
|
|
30
30
|
export declare enum AdbSyncStatErrorCode {
|
|
31
31
|
SUCCESS = 0,
|
|
32
32
|
EACCES = 13,
|
|
@@ -67,7 +67,7 @@ export declare const AdbSyncStatResponse: Struct<{
|
|
|
67
67
|
readonly type: LinuxFileType;
|
|
68
68
|
readonly permission: number;
|
|
69
69
|
}, undefined>;
|
|
70
|
-
export
|
|
71
|
-
export declare function adbSyncLstat(stream:
|
|
72
|
-
export declare function adbSyncStat(stream:
|
|
70
|
+
export type AdbSyncStatResponse = typeof AdbSyncStatResponse["TDeserializeResult"];
|
|
71
|
+
export declare function adbSyncLstat(stream: BufferedReadableStream, writer: WritableStreamDefaultWriter<Uint8Array>, path: string, v2: boolean): Promise<AdbSyncStat>;
|
|
72
|
+
export declare function adbSyncStat(stream: BufferedReadableStream, writer: WritableStreamDefaultWriter<Uint8Array>, path: string): Promise<AdbSyncStatResponse>;
|
|
73
73
|
//# sourceMappingURL=stat.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stat.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/stat.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"st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,GAC3B,OAAO,mBAAmB,CAAC,oBAAoB,CAAC,CAAC;AAErD,wBAAsB,YAAY,CAC9B,MAAM,EAAE,sBAAsB,EAC9B,MAAM,EAAE,2BAA2B,CAAC,UAAU,CAAC,EAC/C,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,OAAO,GACZ,OAAO,CAAC,WAAW,CAAC,CA4BtB;AAED,wBAAsB,WAAW,CAC7B,MAAM,EAAE,sBAAsB,EAC9B,MAAM,EAAE,2BAA2B,CAAC,UAAU,CAAC,EAC/C,IAAI,EAAE,MAAM,GACb,OAAO,CAAC,mBAAmB,CAAC,CAO9B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import Struct, { placeholder } from
|
|
2
|
-
import { AdbSyncRequestId, adbSyncWriteRequest } from
|
|
3
|
-
import {
|
|
1
|
+
import Struct, { placeholder } from "@yume-chan/struct";
|
|
2
|
+
import { AdbSyncRequestId, adbSyncWriteRequest } from "./request.js";
|
|
3
|
+
import { AdbSyncResponseId, adbSyncReadResponse } from "./response.js";
|
|
4
4
|
// https://github.com/python/cpython/blob/4e581d64b8aff3e2eda99b12f080c877bb78dfca/Lib/stat.py#L36
|
|
5
5
|
export var LinuxFileType;
|
|
6
6
|
(function (LinuxFileType) {
|
|
@@ -9,19 +9,21 @@ export var LinuxFileType;
|
|
|
9
9
|
LinuxFileType[LinuxFileType["Link"] = 10] = "Link";
|
|
10
10
|
})(LinuxFileType = LinuxFileType || (LinuxFileType = {}));
|
|
11
11
|
export const AdbSyncLstatResponse = new Struct({ littleEndian: true })
|
|
12
|
-
.int32(
|
|
13
|
-
.int32(
|
|
14
|
-
.int32(
|
|
12
|
+
.int32("mode")
|
|
13
|
+
.int32("size")
|
|
14
|
+
.int32("mtime")
|
|
15
15
|
.extra({
|
|
16
16
|
id: AdbSyncResponseId.Lstat,
|
|
17
|
-
get type() {
|
|
18
|
-
|
|
17
|
+
get type() {
|
|
18
|
+
return (this.mode >> 12);
|
|
19
|
+
},
|
|
20
|
+
get permission() {
|
|
21
|
+
return this.mode & 4095;
|
|
22
|
+
},
|
|
19
23
|
})
|
|
20
24
|
.postDeserialize((object) => {
|
|
21
|
-
if (object.mode === 0 &&
|
|
22
|
-
|
|
23
|
-
object.mtime === 0) {
|
|
24
|
-
throw new Error('lstat failed');
|
|
25
|
+
if (object.mode === 0 && object.size === 0 && object.mtime === 0) {
|
|
26
|
+
throw new Error("lstat error");
|
|
25
27
|
}
|
|
26
28
|
});
|
|
27
29
|
export var AdbSyncStatErrorCode;
|
|
@@ -49,64 +51,55 @@ export var AdbSyncStatErrorCode;
|
|
|
49
51
|
AdbSyncStatErrorCode[AdbSyncStatErrorCode["ETXTBSY"] = 26] = "ETXTBSY";
|
|
50
52
|
})(AdbSyncStatErrorCode = AdbSyncStatErrorCode || (AdbSyncStatErrorCode = {}));
|
|
51
53
|
export const AdbSyncStatResponse = new Struct({ littleEndian: true })
|
|
52
|
-
.uint32(
|
|
53
|
-
.uint64(
|
|
54
|
-
.uint64(
|
|
55
|
-
.uint32(
|
|
56
|
-
.uint32(
|
|
57
|
-
.uint32(
|
|
58
|
-
.uint32(
|
|
59
|
-
.uint64(
|
|
60
|
-
.uint64(
|
|
61
|
-
.uint64(
|
|
62
|
-
.uint64(
|
|
54
|
+
.uint32("error", placeholder())
|
|
55
|
+
.uint64("dev")
|
|
56
|
+
.uint64("ino")
|
|
57
|
+
.uint32("mode")
|
|
58
|
+
.uint32("nlink")
|
|
59
|
+
.uint32("uid")
|
|
60
|
+
.uint32("gid")
|
|
61
|
+
.uint64("size")
|
|
62
|
+
.uint64("atime")
|
|
63
|
+
.uint64("mtime")
|
|
64
|
+
.uint64("ctime")
|
|
63
65
|
.extra({
|
|
64
66
|
id: AdbSyncResponseId.Stat,
|
|
65
|
-
get type() {
|
|
66
|
-
|
|
67
|
+
get type() {
|
|
68
|
+
return (this.mode >> 12);
|
|
69
|
+
},
|
|
70
|
+
get permission() {
|
|
71
|
+
return this.mode & 4095;
|
|
72
|
+
},
|
|
67
73
|
})
|
|
68
74
|
.postDeserialize((object) => {
|
|
69
75
|
if (object.error) {
|
|
70
76
|
throw new Error(AdbSyncStatErrorCode[object.error]);
|
|
71
77
|
}
|
|
72
78
|
});
|
|
73
|
-
const STAT_RESPONSE_TYPES = {
|
|
74
|
-
[AdbSyncResponseId.Stat]: AdbSyncStatResponse,
|
|
75
|
-
};
|
|
76
|
-
const LSTAT_RESPONSE_TYPES = {
|
|
77
|
-
[AdbSyncResponseId.Lstat]: AdbSyncLstatResponse,
|
|
78
|
-
};
|
|
79
|
-
const LSTAT_V2_RESPONSE_TYPES = {
|
|
80
|
-
[AdbSyncResponseId.Lstat2]: AdbSyncStatResponse,
|
|
81
|
-
};
|
|
82
79
|
export async function adbSyncLstat(stream, writer, path, v2) {
|
|
83
|
-
let requestId;
|
|
84
|
-
let responseType;
|
|
85
80
|
if (v2) {
|
|
86
|
-
|
|
87
|
-
|
|
81
|
+
await adbSyncWriteRequest(writer, AdbSyncRequestId.Lstat2, path);
|
|
82
|
+
return await adbSyncReadResponse(stream, AdbSyncResponseId.Lstat2, AdbSyncStatResponse);
|
|
88
83
|
}
|
|
89
84
|
else {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
default:
|
|
105
|
-
return response;
|
|
85
|
+
await adbSyncWriteRequest(writer, AdbSyncRequestId.Lstat, path);
|
|
86
|
+
const response = await adbSyncReadResponse(stream, AdbSyncResponseId.Lstat, AdbSyncLstatResponse);
|
|
87
|
+
return {
|
|
88
|
+
mode: response.mode,
|
|
89
|
+
// Convert to `BigInt` to make it compatible with `AdbSyncStatResponse`
|
|
90
|
+
size: BigInt(response.size),
|
|
91
|
+
mtime: BigInt(response.mtime),
|
|
92
|
+
get type() {
|
|
93
|
+
return response.type;
|
|
94
|
+
},
|
|
95
|
+
get permission() {
|
|
96
|
+
return response.permission;
|
|
97
|
+
},
|
|
98
|
+
};
|
|
106
99
|
}
|
|
107
100
|
}
|
|
108
101
|
export async function adbSyncStat(stream, writer, path) {
|
|
109
102
|
await adbSyncWriteRequest(writer, AdbSyncRequestId.Stat, path);
|
|
110
|
-
return await adbSyncReadResponse(stream,
|
|
103
|
+
return await adbSyncReadResponse(stream, AdbSyncResponseId.Stat, AdbSyncStatResponse);
|
|
111
104
|
}
|
|
112
105
|
//# sourceMappingURL=stat.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stat.js","sourceRoot":"","sources":["../../../src/commands/sync/stat.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"stat.js","sourceRoot":"","sources":["../../../src/commands/sync/stat.ts"],"names":[],"mappings":"AAIA,OAAO,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEvE,kGAAkG;AAClG,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACrB,2DAAgB,CAAA;IAChB,iDAAW,CAAA;IACX,kDAAW,CAAA;AACf,CAAC,EAJW,aAAa,GAAb,aAAa,KAAb,aAAa,QAIxB;AAeD,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,MAAM,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;KACjE,KAAK,CAAC,MAAM,CAAC;KACb,KAAK,CAAC,MAAM,CAAC;KACb,KAAK,CAAC,OAAO,CAAC;KACd,KAAK,CAAC;IACH,EAAE,EAAE,iBAAiB,CAAC,KAAc;IACpC,IAAI,IAAI;QACJ,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAkB,CAAC;IAC9C,CAAC;IACD,IA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C/B,CAAC;SACJ,CAAC;KACL;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAC7B,MAA8B,EAC9B,MAA+C,EAC/C,IAAY;IAEZ,MAAM,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC/D,OAAO,MAAM,mBAAmB,CAC5B,MAAM,EACN,iBAAiB,CAAC,IAAI,EACtB,mBAAmB,CACtB,CAAC;AACN,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { AutoDisposable } from
|
|
2
|
-
import type
|
|
3
|
-
import type
|
|
4
|
-
import {
|
|
5
|
-
import { AutoResetEvent } from
|
|
6
|
-
import { type AdbSyncEntry } from
|
|
1
|
+
import { AutoDisposable } from "@yume-chan/event";
|
|
2
|
+
import { BufferedReadableStream, type ReadableStream, type WritableStream, type WritableStreamDefaultWriter } from "@yume-chan/stream-extra";
|
|
3
|
+
import { type Adb } from "../../adb.js";
|
|
4
|
+
import { type AdbSocket } from "../../socket/index.js";
|
|
5
|
+
import { AutoResetEvent } from "../../utils/index.js";
|
|
6
|
+
import { type AdbSyncEntry } from "./list.js";
|
|
7
7
|
/**
|
|
8
8
|
* A simplified `dirname` function that only handles absolute unix paths.
|
|
9
9
|
* @param path an absolute unix path
|
|
@@ -12,7 +12,7 @@ import { type AdbSyncEntry } from './list.js';
|
|
|
12
12
|
export declare function dirname(path: string): string;
|
|
13
13
|
export declare class AdbSync extends AutoDisposable {
|
|
14
14
|
protected adb: Adb;
|
|
15
|
-
protected stream:
|
|
15
|
+
protected stream: BufferedReadableStream;
|
|
16
16
|
protected writer: WritableStreamDefaultWriter<Uint8Array>;
|
|
17
17
|
protected sendLock: AutoResetEvent;
|
|
18
18
|
get supportsStat(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/sync.ts"],"names":[],"mappings":"AAAA,OAAO,EA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Y,EAAE,IAAI,EAAE,IAAI,CAAC;IAe9B,OAAO,CAAC,IAAI,EAAE,MAAM;IAQjC;;;;;OAKG;IACI,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,CAAC,UAAU,CAAC;IAYzD;;;;;;;OAOG;IACI,KAAK,CACR,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,MAAM,GACf,cAAc,CAAC,UAAU,CAAC;IA8BP,OAAO;CAIhC"}
|
|
@@ -1,30 +1,33 @@
|
|
|
1
|
-
import { AutoDisposable } from
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { AutoResetEvent } from
|
|
5
|
-
import { escapeArg } from "../index.js";
|
|
6
|
-
import { adbSyncOpenDir } from
|
|
7
|
-
import { adbSyncPull } from
|
|
8
|
-
import { adbSyncPush } from
|
|
9
|
-
import { adbSyncLstat, adbSyncStat } from
|
|
1
|
+
import { AutoDisposable } from "@yume-chan/event";
|
|
2
|
+
import { BufferedReadableStream, WrapReadableStream, WrapWritableStream, } from "@yume-chan/stream-extra";
|
|
3
|
+
import { AdbFeatures } from "../../features.js";
|
|
4
|
+
import { AutoResetEvent } from "../../utils/index.js";
|
|
5
|
+
import { escapeArg } from "../subprocess/index.js";
|
|
6
|
+
import { adbSyncOpenDir } from "./list.js";
|
|
7
|
+
import { adbSyncPull } from "./pull.js";
|
|
8
|
+
import { adbSyncPush } from "./push.js";
|
|
9
|
+
import { adbSyncLstat, adbSyncStat } from "./stat.js";
|
|
10
10
|
/**
|
|
11
11
|
* A simplified `dirname` function that only handles absolute unix paths.
|
|
12
12
|
* @param path an absolute unix path
|
|
13
13
|
* @returns the directory name of the input path
|
|
14
14
|
*/
|
|
15
15
|
export function dirname(path) {
|
|
16
|
-
const end = path.lastIndexOf(
|
|
16
|
+
const end = path.lastIndexOf("/");
|
|
17
17
|
if (end === -1) {
|
|
18
18
|
throw new Error(`Invalid path`);
|
|
19
19
|
}
|
|
20
20
|
if (end === 0) {
|
|
21
|
-
return
|
|
21
|
+
return "/";
|
|
22
22
|
}
|
|
23
23
|
return path.substring(0, end);
|
|
24
24
|
}
|
|
25
25
|
export class AdbSync extends AutoDisposable {
|
|
26
26
|
adb;
|
|
27
27
|
stream;
|
|
28
|
+
// Getting another writer on a locked WritableStream will throw.
|
|
29
|
+
// We don't want this behavior on higher-level APIs.
|
|
30
|
+
// So we acquire the writer early and use a blocking lock to guard it.
|
|
28
31
|
writer;
|
|
29
32
|
sendLock = this.addDisposable(new AutoResetEvent());
|
|
30
33
|
get supportsStat() {
|
|
@@ -38,12 +41,13 @@ export class AdbSync extends AutoDisposable {
|
|
|
38
41
|
}
|
|
39
42
|
get needPushMkdirWorkaround() {
|
|
40
43
|
// https://android.googlesource.com/platform/packages/modules/adb/+/91768a57b7138166e0a3d11f79cd55909dda7014/client/file_sync_client.cpp#1361
|
|
41
|
-
return this.adb.features.includes(AdbFeatures.ShellV2) &&
|
|
44
|
+
return (this.adb.features.includes(AdbFeatures.ShellV2) &&
|
|
45
|
+
!this.fixedPushMkdir);
|
|
42
46
|
}
|
|
43
47
|
constructor(adb, socket) {
|
|
44
48
|
super();
|
|
45
49
|
this.adb = adb;
|
|
46
|
-
this.stream = new
|
|
50
|
+
this.stream = new BufferedReadableStream(socket.readable);
|
|
47
51
|
this.writer = socket.writable.getWriter();
|
|
48
52
|
}
|
|
49
53
|
async lstat(path) {
|
|
@@ -57,7 +61,7 @@ export class AdbSync extends AutoDisposable {
|
|
|
57
61
|
}
|
|
58
62
|
async stat(path) {
|
|
59
63
|
if (!this.supportsStat) {
|
|
60
|
-
throw new Error(
|
|
64
|
+
throw new Error("Not supported");
|
|
61
65
|
}
|
|
62
66
|
await this.sendLock.wait();
|
|
63
67
|
try {
|
|
@@ -69,7 +73,7 @@ export class AdbSync extends AutoDisposable {
|
|
|
69
73
|
}
|
|
70
74
|
async isDirectory(path) {
|
|
71
75
|
try {
|
|
72
|
-
await this.lstat(path +
|
|
76
|
+
await this.lstat(path + "/");
|
|
73
77
|
return true;
|
|
74
78
|
}
|
|
75
79
|
catch (e) {
|
|
@@ -104,7 +108,7 @@ export class AdbSync extends AutoDisposable {
|
|
|
104
108
|
await this.sendLock.wait();
|
|
105
109
|
return adbSyncPull(this.stream, this.writer, filename);
|
|
106
110
|
},
|
|
107
|
-
close:
|
|
111
|
+
close: () => {
|
|
108
112
|
this.sendLock.notify();
|
|
109
113
|
},
|
|
110
114
|
});
|
|
@@ -124,23 +128,22 @@ export class AdbSync extends AutoDisposable {
|
|
|
124
128
|
if (this.needPushMkdirWorkaround) {
|
|
125
129
|
// It may fail if the path is already existed.
|
|
126
130
|
// Ignore the result.
|
|
127
|
-
// TODO: sync: test
|
|
131
|
+
// TODO: sync: test push mkdir workaround (need an Android 8 device)
|
|
128
132
|
await this.adb.subprocess.spawnAndWait([
|
|
129
|
-
|
|
130
|
-
|
|
133
|
+
"mkdir",
|
|
134
|
+
"-p",
|
|
131
135
|
escapeArg(dirname(filename)),
|
|
132
136
|
]);
|
|
133
137
|
}
|
|
134
138
|
return adbSyncPush(this.stream, this.writer, filename, mode, mtime);
|
|
135
139
|
},
|
|
136
|
-
close:
|
|
140
|
+
close: () => {
|
|
137
141
|
this.sendLock.notify();
|
|
138
|
-
}
|
|
142
|
+
},
|
|
139
143
|
});
|
|
140
144
|
}
|
|
141
145
|
async dispose() {
|
|
142
146
|
super.dispose();
|
|
143
|
-
await this.stream.close();
|
|
144
147
|
await this.writer.close();
|
|
145
148
|
}
|
|
146
149
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../../src/commands/sync/sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../../src/commands/sync/sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAk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AgB,EAChB,IAAa,EACb,KAAc;QAEd,OAAO,IAAI,kBAAkB,CAAC;YAC1B,KAAK,EAAE,KAAK,IAAI,EAAE;gBACd,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;gBAE3B,IAAI,IAAI,CAAC,uBAAuB,EAAE;oBAC9B,8CAA8C;oBAC9C,qBAAqB;oBACrB,oEAAoE;oBACpE,MAAM,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC;wBACnC,OAAO;wBACP,IAAI;wBACJ,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;qBAC/B,CAAC,CAAC;iBACN;gBAED,OAAO,WAAW,CACd,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,MAAM,EACX,QAAQ,EACR,IAAI,EACJ,KAAK,CACR,CAAC;YACN,CAAC;YACD,KAAK,EAAE,GAAG,EAAE;gBACR,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;YAC3B,CAAC;SACJ,CAAC,CAAC;IACP,CAAC;IAEe,KAAK,CAAC,OAAO;QACzB,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;CACJ"}
|
package/esm/crypto.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../src/crypto.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../src/crypto.ts"],"names":[],"mappings":"AAUA;;;;;;GAMG;AACH,wBAAgB,UAAU,CACtB,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GACf,MAAM,CAaR;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CACtB,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,OAAO,UA0BzB;AA4BD,wBAAgB,eAAe,CAAC,GAAG,EAAE,UAAU,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAKvE;AAKD,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,UAsB9C;AAED,wBAAgB,wBAAwB,WAEvC;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,CAAC;AACvE,wBAAgB,kBAAkB,CAC9B,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,UAAU,GACnB,MAAM,CAAC;AA8EV;;;;;;GAMG;AACH,wBAAgB,MAAM,CAClB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GAChB,MAAM,CAkBR;AAED,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC,eAAO,MAAM,aAAa,KAAO,CAAC;AAClC,eAAO,MAAM,iBAAiB,IAAO,CAAC;AACtC,eAAO,MAAM,SAAS,IAAO,CAAC;AAC9B,eAAO,MAAM,QAAQ,IAAO,CAAC;AAG7B,eAAO,MAAM,gBAAgB,YAiB3B,CAAC;AAQH,wBAAgB,IAAI,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,GAAG,UAAU,CAsCzE"}
|
package/esm/crypto.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getBigUint64, setBigUint64 } from
|
|
1
|
+
import { getBigUint64, setBigUint64, } from "@yume-chan/dataview-bigint-polyfill/esm/fallback.js";
|
|
2
2
|
const BigInt0 = BigInt(0);
|
|
3
3
|
const BigInt1 = BigInt(1);
|
|
4
4
|
const BigInt2 = BigInt(2);
|
|
@@ -82,9 +82,9 @@ export function parsePrivateKey(key) {
|
|
|
82
82
|
}
|
|
83
83
|
// Taken from https://stackoverflow.com/a/51562038
|
|
84
84
|
// I can't understand, but it does work
|
|
85
|
-
// Only used with numbers
|
|
85
|
+
// Only used with numbers smaller than 2^32 so doesn't need BigInt
|
|
86
86
|
export function modInverse(a, m) {
|
|
87
|
-
a = (a % m + m) % m;
|
|
87
|
+
a = ((a % m) + m) % m;
|
|
88
88
|
if (!a || m < 2) {
|
|
89
89
|
return NaN; // invalid input
|
|
90
90
|
}
|
|
@@ -101,10 +101,10 @@ export function modInverse(a, m) {
|
|
|
101
101
|
// find the inverse
|
|
102
102
|
let x = 1;
|
|
103
103
|
let y = 0;
|
|
104
|
-
for (let i = s.length - 2; i >= 0;
|
|
104
|
+
for (let i = s.length - 2; i >= 0; i -= 1) {
|
|
105
105
|
[x, y] = [y, x - y * Math.floor(s[i].a / s[i].b)];
|
|
106
106
|
}
|
|
107
|
-
return (y % m + m) % m;
|
|
107
|
+
return ((y % m) + m) % m;
|
|
108
108
|
}
|
|
109
109
|
export function calculatePublicKeyLength() {
|
|
110
110
|
return 4 + 4 + 2048 / 8 + 2048 / 8 + 4;
|
|
@@ -131,13 +131,13 @@ export function calculatePublicKey(privateKey, output) {
|
|
|
131
131
|
const outputLength = calculatePublicKeyLength();
|
|
132
132
|
if (!output) {
|
|
133
133
|
output = new Uint8Array(outputLength);
|
|
134
|
-
outputType =
|
|
134
|
+
outputType = "Uint8Array";
|
|
135
135
|
}
|
|
136
136
|
else {
|
|
137
137
|
if (output.byteLength < outputLength) {
|
|
138
|
-
throw new Error(
|
|
138
|
+
throw new Error("output buffer is too small");
|
|
139
139
|
}
|
|
140
|
-
outputType =
|
|
140
|
+
outputType = "number";
|
|
141
141
|
}
|
|
142
142
|
const outputView = new DataView(output.buffer, output.byteOffset, output.byteLength);
|
|
143
143
|
let outputOffset = 0;
|
|
@@ -154,12 +154,12 @@ export function calculatePublicKey(privateKey, output) {
|
|
|
154
154
|
setBigUint(outputView, outputOffset, n, true);
|
|
155
155
|
outputOffset += 256;
|
|
156
156
|
// Calculate rr = (2^(rsa_size)) ^ 2 mod n
|
|
157
|
-
|
|
157
|
+
const rr = BigInt(2) ** BigInt(4096) % n;
|
|
158
158
|
outputOffset += setBigUint(outputView, outputOffset, rr, true);
|
|
159
159
|
// exponent
|
|
160
160
|
outputView.setUint32(outputOffset, 65537, true);
|
|
161
161
|
outputOffset += 4;
|
|
162
|
-
if (outputType ===
|
|
162
|
+
if (outputType === "Uint8Array") {
|
|
163
163
|
return output;
|
|
164
164
|
}
|
|
165
165
|
else {
|
|
@@ -181,7 +181,7 @@ export function powMod(base, exponent, modulus) {
|
|
|
181
181
|
base = base % modulus;
|
|
182
182
|
while (exponent > BigInt0) {
|
|
183
183
|
if (BigInt.asUintN(1, exponent) === BigInt1) {
|
|
184
|
-
r = r * base % modulus;
|
|
184
|
+
r = (r * base) % modulus;
|
|
185
185
|
}
|
|
186
186
|
exponent >>= BigInt1;
|
|
187
187
|
base = base ** BigInt2 % modulus;
|
|
@@ -195,12 +195,22 @@ export const ASN1_NULL = 0x05;
|
|
|
195
195
|
export const ASN1_OID = 0x06;
|
|
196
196
|
// PKCS#1 SHA-1 hash digest info
|
|
197
197
|
export const SHA1_DIGEST_INFO = new Uint8Array([
|
|
198
|
-
ASN1_SEQUENCE,
|
|
199
|
-
|
|
198
|
+
ASN1_SEQUENCE,
|
|
199
|
+
0x0d + SHA1_DIGEST_LENGTH,
|
|
200
|
+
ASN1_SEQUENCE,
|
|
201
|
+
0x09,
|
|
200
202
|
// SHA-1 (1 3 14 3 2 26)
|
|
201
|
-
ASN1_OID,
|
|
202
|
-
|
|
203
|
-
|
|
203
|
+
ASN1_OID,
|
|
204
|
+
0x05,
|
|
205
|
+
1 * 40 + 3,
|
|
206
|
+
14,
|
|
207
|
+
3,
|
|
208
|
+
2,
|
|
209
|
+
26,
|
|
210
|
+
ASN1_NULL,
|
|
211
|
+
0x00,
|
|
212
|
+
ASN1_OCTET_STRING,
|
|
213
|
+
SHA1_DIGEST_LENGTH,
|
|
204
214
|
]);
|
|
205
215
|
// SubtleCrypto.sign() will hash the given data and sign the hash
|
|
206
216
|
// But we don't need the hashing step
|