networkwm-js 0.2.2 → 0.2.4
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/dist/bytemanip.js +11 -12
- package/dist/cli/decrypt-mp3.js +2 -3
- package/dist/cli/decrypt-oma.js +1 -2
- package/dist/cli/encrypt-oma.js +1 -2
- package/dist/cli/sign-device.js +4 -5
- package/dist/cli/table-file-info.js +1 -2
- package/dist/cli/tagged-oma-info.js +1 -2
- package/dist/codecs.d.ts +1 -1
- package/dist/codecs.d.ts.map +1 -1
- package/dist/codecs.js +5 -5
- package/dist/database-abstraction.d.ts +3 -3
- package/dist/database-abstraction.d.ts.map +1 -1
- package/dist/database-abstraction.js +13 -10
- package/dist/databases.d.ts.map +1 -1
- package/dist/derive-mp3-key.d.ts +1 -1
- package/dist/derive-mp3-key.d.ts.map +1 -1
- package/dist/derive-mp3-key.js +3 -4
- package/dist/devices.js +2 -2
- package/dist/encryption.d.ts +8 -8
- package/dist/encryption.d.ts.map +1 -1
- package/dist/encryption.js +12 -12
- package/dist/filesystem/usb-mass-storage-webusb-filesystem.d.ts +18 -16
- package/dist/filesystem/usb-mass-storage-webusb-filesystem.d.ts.map +1 -1
- package/dist/filesystem/usb-mass-storage-webusb-filesystem.js +6 -6
- package/dist/id3.d.ts +4 -4
- package/dist/id3.d.ts.map +1 -1
- package/dist/id3.js +7 -8
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/init-data.d.ts +16 -16
- package/dist/init-data.d.ts.map +1 -1
- package/dist/initialization.js +2 -3
- package/dist/mp3.js +3 -4
- package/dist/{helpers.d.ts → node-helpers.d.ts} +1 -2
- package/dist/node-helpers.d.ts.map +1 -0
- package/dist/{helpers.js → node-helpers.js} +2 -8
- package/dist/sort.d.ts +2 -2
- package/dist/sort.d.ts.map +1 -1
- package/dist/sort.js +2 -3
- package/dist/tables.js +2 -3
- package/dist/tagged-oma.d.ts +4 -2
- package/dist/tagged-oma.d.ts.map +1 -1
- package/dist/tagged-oma.js +7 -8
- package/dist/utils.d.ts +5 -4
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +13 -9
- package/package.json +3 -3
- package/dist/helpers.d.ts.map +0 -1
package/dist/bytemanip.js
CHANGED
|
@@ -1,59 +1,60 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.readUint8 = readUint8;
|
|
4
|
+
exports.readUint16 = readUint16;
|
|
5
|
+
exports.readUint32 = readUint32;
|
|
6
|
+
exports.getUint32 = getUint32;
|
|
7
|
+
exports.getUint16 = getUint16;
|
|
8
|
+
exports.readBytes = readBytes;
|
|
9
|
+
exports.readString = readString;
|
|
10
|
+
exports.align = align;
|
|
11
|
+
exports.writeUint8 = writeUint8;
|
|
12
|
+
exports.writeUint16 = writeUint16;
|
|
13
|
+
exports.writeUint32 = writeUint32;
|
|
4
14
|
const textDecoder = new TextDecoder();
|
|
5
15
|
const textEncoder = new TextEncoder();
|
|
6
16
|
function readUint8(data, offset) {
|
|
7
17
|
const value = data.getUint8(offset);
|
|
8
18
|
return [value, offset + 1];
|
|
9
19
|
}
|
|
10
|
-
exports.readUint8 = readUint8;
|
|
11
20
|
;
|
|
12
21
|
function readUint16(data, offset) {
|
|
13
22
|
const value = data.getUint16(offset);
|
|
14
23
|
return [value, offset + 2];
|
|
15
24
|
}
|
|
16
|
-
exports.readUint16 = readUint16;
|
|
17
25
|
;
|
|
18
26
|
function readUint32(data, offset) {
|
|
19
27
|
const value = data.getUint32(offset);
|
|
20
28
|
return [value, offset + 4];
|
|
21
29
|
}
|
|
22
|
-
exports.readUint32 = readUint32;
|
|
23
30
|
;
|
|
24
31
|
function getUint32(data, offset = 0) {
|
|
25
32
|
if (offset < 0)
|
|
26
33
|
offset += data.length;
|
|
27
34
|
return (data[offset + 0] << 24) | (data[offset + 1] << 16) | (data[offset + 2] << 8) | data[offset + 3];
|
|
28
35
|
}
|
|
29
|
-
exports.getUint32 = getUint32;
|
|
30
36
|
function getUint16(data, offset = 0) {
|
|
31
37
|
if (offset < 0)
|
|
32
38
|
offset += data.length;
|
|
33
39
|
return (data[offset + 0] << 8) | data[offset + 1];
|
|
34
40
|
}
|
|
35
|
-
exports.getUint16 = getUint16;
|
|
36
41
|
function readBytes(data, offset, length) {
|
|
37
42
|
const value = new Uint8Array(data.buffer.slice(offset, offset + length));
|
|
38
43
|
return [value, offset + length];
|
|
39
44
|
}
|
|
40
|
-
exports.readBytes = readBytes;
|
|
41
45
|
;
|
|
42
46
|
function readString(data, offset, length) {
|
|
43
47
|
const bytes = readBytes(data, offset, length);
|
|
44
48
|
return [textDecoder.decode(bytes[0]), bytes[1]];
|
|
45
49
|
}
|
|
46
|
-
exports.readString = readString;
|
|
47
50
|
function align(offset, to) {
|
|
48
51
|
if (offset % to === 0)
|
|
49
52
|
return offset;
|
|
50
53
|
return (Math.floor(offset / to) + 1) * to;
|
|
51
54
|
}
|
|
52
|
-
exports.align = align;
|
|
53
55
|
function writeUint8(value) {
|
|
54
56
|
return new Uint8Array([value]);
|
|
55
57
|
}
|
|
56
|
-
exports.writeUint8 = writeUint8;
|
|
57
58
|
;
|
|
58
59
|
function writeUint16(value) {
|
|
59
60
|
const array = new Uint8Array(2);
|
|
@@ -61,7 +62,6 @@ function writeUint16(value) {
|
|
|
61
62
|
array[1] = value & 0xff;
|
|
62
63
|
return array;
|
|
63
64
|
}
|
|
64
|
-
exports.writeUint16 = writeUint16;
|
|
65
65
|
;
|
|
66
66
|
function writeUint32(value) {
|
|
67
67
|
const array = new Uint8Array(4);
|
|
@@ -71,5 +71,4 @@ function writeUint32(value) {
|
|
|
71
71
|
array[3] = value & 0xff;
|
|
72
72
|
return array;
|
|
73
73
|
}
|
|
74
|
-
exports.writeUint32 = writeUint32;
|
|
75
74
|
;
|
package/dist/cli/decrypt-mp3.js
CHANGED
|
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.mainDeriveKey = mainDeriveKey;
|
|
7
|
+
exports.main = main;
|
|
7
8
|
const fs_1 = __importDefault(require("fs"));
|
|
8
9
|
const path_1 = __importDefault(require("path"));
|
|
9
10
|
const derive_mp3_key_1 = require("../derive-mp3-key");
|
|
@@ -37,7 +38,6 @@ function mainDeriveKey(invocation, args) {
|
|
|
37
38
|
const leafId = (0, encryption_1.getMP3EncryptionKey)(trackKey, id);
|
|
38
39
|
console.log(`Device MP3 key: ${leafId.toString(16).padStart(8, '0')}`);
|
|
39
40
|
}
|
|
40
|
-
exports.mainDeriveKey = mainDeriveKey;
|
|
41
41
|
function main(invocation, args) {
|
|
42
42
|
if (args.length < 3) {
|
|
43
43
|
console.log(`Usage: ${invocation} <device key> <OMA-encapsulated-MP3> <output MP3>`);
|
|
@@ -56,4 +56,3 @@ function main(invocation, args) {
|
|
|
56
56
|
}
|
|
57
57
|
fs_1.default.writeFileSync(dest, (0, derive_mp3_key_1.decryptMP3)(new Uint8Array(fs_1.default.readFileSync(source)), fileId, deviceKey));
|
|
58
58
|
}
|
|
59
|
-
exports.main = main;
|
package/dist/cli/decrypt-oma.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.main =
|
|
6
|
+
exports.main = main;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const tagged_oma_1 = require("../tagged-oma");
|
|
9
9
|
function main(invocation, args) {
|
|
@@ -22,4 +22,3 @@ function main(invocation, args) {
|
|
|
22
22
|
}
|
|
23
23
|
fs_1.default.writeFileSync(dest, (0, tagged_oma_1.decryptOMA)(new Uint8Array(fs_1.default.readFileSync(source))));
|
|
24
24
|
}
|
|
25
|
-
exports.main = main;
|
package/dist/cli/encrypt-oma.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.main =
|
|
6
|
+
exports.main = main;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const tagged_oma_1 = require("../tagged-oma");
|
|
9
9
|
const himd_js_1 = require("himd-js");
|
|
@@ -80,4 +80,3 @@ async function main(invocation, args) {
|
|
|
80
80
|
console.log("Duration is: ", encrypted.duration, " seconds");
|
|
81
81
|
fs_1.default.writeFileSync(dest, encrypted.data);
|
|
82
82
|
}
|
|
83
|
-
exports.main = main;
|
package/dist/cli/sign-device.js
CHANGED
|
@@ -3,21 +3,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.main =
|
|
6
|
+
exports.main = main;
|
|
7
7
|
const encryption_1 = require("../encryption");
|
|
8
8
|
const filesystem_1 = require("../filesystem");
|
|
9
|
-
const
|
|
9
|
+
const node_helpers_1 = require("../node-helpers");
|
|
10
10
|
const path_1 = require("path");
|
|
11
11
|
const fs_1 = __importDefault(require("fs"));
|
|
12
12
|
async function main() {
|
|
13
13
|
await (0, encryption_1.initCrypto)();
|
|
14
14
|
(0, encryption_1.importKeys)(new Uint8Array(fs_1.default.readFileSync((0, path_1.join)(__dirname, "..", "..", "EKBROOTS.DES"))));
|
|
15
|
-
const device = await (0,
|
|
15
|
+
const device = await (0, node_helpers_1.openNewDeviceNode)();
|
|
16
16
|
if (!device) {
|
|
17
17
|
console.log("No device found!");
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
|
-
const fs = await (0,
|
|
20
|
+
const fs = await (0, node_helpers_1.createNWJSFS)(device);
|
|
21
21
|
console.log(`Connected to ${device.definition.name}`);
|
|
22
22
|
console.log("Opening session...");
|
|
23
23
|
const session = new filesystem_1.UMSCNWJSSession(fs.driver, fs);
|
|
@@ -27,4 +27,3 @@ async function main() {
|
|
|
27
27
|
await session.finalizeSession();
|
|
28
28
|
console.log("Done.");
|
|
29
29
|
}
|
|
30
|
-
exports.main = main;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.main =
|
|
6
|
+
exports.main = main;
|
|
7
7
|
const tables_1 = require("../tables");
|
|
8
8
|
const utils_1 = require("../utils");
|
|
9
9
|
const fs_1 = __importDefault(require("fs"));
|
|
@@ -43,4 +43,3 @@ function main(invocation, args) {
|
|
|
43
43
|
}
|
|
44
44
|
bumpIndent(-1);
|
|
45
45
|
}
|
|
46
|
-
exports.main = main;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.main =
|
|
6
|
+
exports.main = main;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const utils_1 = require("../utils");
|
|
9
9
|
const id3_1 = require("../id3");
|
|
@@ -189,4 +189,3 @@ function main(invocation, args) {
|
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
-
exports.main = main;
|
package/dist/codecs.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export interface NWCodecInfo {
|
|
|
7
7
|
codecInfo: Uint8Array;
|
|
8
8
|
complete?: boolean;
|
|
9
9
|
}
|
|
10
|
-
export declare function createEA3Header({ codecId, codecInfo, complete }: NWCodecInfo, encrypted?: number, version?: number): Uint8Array
|
|
10
|
+
export declare function createEA3Header({ codecId, codecInfo, complete }: NWCodecInfo, encrypted?: number, version?: number): Uint8Array<ArrayBuffer>;
|
|
11
11
|
export declare function getCodecName(codecInfo: NWCodecInfo): import("himd-js").HiMDCodecName;
|
|
12
12
|
export declare function getKBPS(codecInfo: NWCodecInfo): number;
|
|
13
13
|
//# sourceMappingURL=codecs.d.ts.map
|
package/dist/codecs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codecs.d.ts","sourceRoot":"","sources":["../src/codecs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,SAAS,EAAsD,MAAM,SAAS,CAAC;AAGnG,oBAAY,OAAO;IACf,GAAG,IAAO;CACb;AAED,MAAM,WAAW,WAAW;IACxB,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC;IAC7B,SAAS,EAAE,UAAU,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,eAAe,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,WAAW,EAAE,SAAS,SAAS,EAAE,OAAO,SAAI,
|
|
1
|
+
{"version":3,"file":"codecs.d.ts","sourceRoot":"","sources":["../src/codecs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,SAAS,EAAsD,MAAM,SAAS,CAAC;AAGnG,oBAAY,OAAO;IACf,GAAG,IAAO;CACb;AAED,MAAM,WAAW,WAAW;IACxB,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC;IAC7B,SAAS,EAAE,UAAU,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,eAAe,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,WAAW,EAAE,SAAS,SAAS,EAAE,OAAO,SAAI,2BAO7G;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,WAAW,mCAMlD;AAED,wBAAgB,OAAO,CAAC,SAAS,EAAE,WAAW,UAa7C"}
|
package/dist/codecs.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.NWCodec = void 0;
|
|
4
|
+
exports.createEA3Header = createEA3Header;
|
|
5
|
+
exports.getCodecName = getCodecName;
|
|
6
|
+
exports.getKBPS = getKBPS;
|
|
4
7
|
const himd_js_1 = require("himd-js");
|
|
5
8
|
const bytemanip_1 = require("./bytemanip");
|
|
6
9
|
var NWCodec;
|
|
7
10
|
(function (NWCodec) {
|
|
8
11
|
NWCodec[NWCodec["MP3"] = 3] = "MP3";
|
|
9
|
-
})(NWCodec
|
|
12
|
+
})(NWCodec || (exports.NWCodec = NWCodec = {}));
|
|
10
13
|
function createEA3Header({ codecId, codecInfo, complete }, encrypted = 0xFFFF, version = 1) {
|
|
11
14
|
const headerSize = 96;
|
|
12
15
|
const header = new Uint8Array(headerSize);
|
|
@@ -15,14 +18,12 @@ function createEA3Header({ codecId, codecInfo, complete }, encrypted = 0xFFFF, v
|
|
|
15
18
|
header.set(complete ? codecInfo : codecInfo.slice(0, 3), 33);
|
|
16
19
|
return header;
|
|
17
20
|
}
|
|
18
|
-
exports.createEA3Header = createEA3Header;
|
|
19
21
|
function getCodecName(codecInfo) {
|
|
20
22
|
if (codecInfo.codecId === NWCodec.MP3) {
|
|
21
23
|
return "MP3";
|
|
22
24
|
}
|
|
23
25
|
return (0, himd_js_1.getCodecName)(codecInfo);
|
|
24
26
|
}
|
|
25
|
-
exports.getCodecName = getCodecName;
|
|
26
27
|
function getKBPS(codecInfo) {
|
|
27
28
|
if (codecInfo.codecId === NWCodec.MP3) {
|
|
28
29
|
// Make it compatible with HiMD codec definitions
|
|
@@ -37,4 +38,3 @@ function getKBPS(codecInfo) {
|
|
|
37
38
|
}
|
|
38
39
|
return (0, himd_js_1.getKBPS)(codecInfo);
|
|
39
40
|
}
|
|
40
|
-
exports.getKBPS = getKBPS;
|
|
@@ -3,7 +3,7 @@ import { DatabaseManager, InboundTrackMetadata, TrackMetadata } from "./database
|
|
|
3
3
|
import { UMSCNWJSSession } from "./filesystem";
|
|
4
4
|
import { DeviceDefinition } from "./devices";
|
|
5
5
|
import { NWCodecInfo } from "./codecs";
|
|
6
|
-
export
|
|
6
|
+
export type AbstractedTrack = TrackMetadata & {
|
|
7
7
|
encryptionState: Uint8Array;
|
|
8
8
|
codecInfo: Uint8Array;
|
|
9
9
|
oneElementLength: number;
|
|
@@ -26,8 +26,8 @@ export declare class DatabaseAbstraction {
|
|
|
26
26
|
addNewTrack(trackInfo: TrackMetadata, codecInfo: NWCodecInfo, encryptionState: number): number;
|
|
27
27
|
private reassignTrackNumber;
|
|
28
28
|
private copyToFilesystem;
|
|
29
|
-
uploadMP3Track(trackInfo: InboundTrackMetadata, rawData: Uint8Array, callback?: (done: number, outOf: number) => void): Promise<void>;
|
|
30
|
-
uploadTrack(trackInfo: InboundTrackMetadata, codec: CodecInfo, rawData: Uint8Array
|
|
29
|
+
uploadMP3Track(trackInfo: InboundTrackMetadata, rawData: Uint8Array, callback?: (done: number, outOf: number) => void, chunkSize?: number): Promise<void>;
|
|
30
|
+
uploadTrack(trackInfo: InboundTrackMetadata, codec: CodecInfo, rawData: Uint8Array<ArrayBuffer>, session?: UMSCNWJSSession, callback?: (done: number, outOf: number) => void, chunkSize?: number): Promise<void>;
|
|
31
31
|
flushUpdates(): Promise<void>;
|
|
32
32
|
deleteTrack(systemIndex: number): Promise<void>;
|
|
33
33
|
reserializeDatabase(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database-abstraction.d.ts","sourceRoot":"","sources":["../src/database-abstraction.ts"],"names":[],"mappings":"AA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AM,CAAC,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,gBAAgB;IAiCnF,OAAO,CAAC,OAAO;IAkCR,WAAW,CAAC,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM;IAyB5F,OAAO,CAAC,mBAAmB;YAWb,gBAAgB;IAsBxB,cAAc,CAChB,SAAS,EAAE,oBAAoB,EAC/B,OAAO,EAAE,UAAU,EACnB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,EAChD,SAAS,CAAC,EAAE,MAAM;IAehB,WAAW,CACb,SAAS,EAAE,oBAAoB,EAC/B,KAAK,EAAE,SAAS,EAChB,OAAO,EAAE,UAAU,CAAC,WAAW,CAAC,EAChC,OAAO,CAAC,EAAE,eAAe,EACzB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,EAChD,SAAS,CAAC,EAAE,MAAM;IAmBhB,YAAY;IAMZ,WAAW,CAAC,WAAW,EAAE,MAAM;IAgBrC,mBAAmB;IA6EnB,0BAA0B,IAAK;QAC3B,0BAA0B,EAAE,CAAC,CAAC;QAC9B,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE;YACN,0BAA0B,EAAE,CAAC,CAAC;YAC9B,IAAI,EAAE,MAAM,CAAC;YACb,QAAQ,EAAE,eAAe,EAAE,CAAA;SAC9B,EAAE,CAAA;KACN,EAAE;IAIG,QAAQ;IA6BR,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa;CAoBjE"}
|
|
@@ -6,7 +6,7 @@ const sort_1 = require("./sort");
|
|
|
6
6
|
const initialization_1 = require("./initialization");
|
|
7
7
|
const filesystem_1 = require("./filesystem");
|
|
8
8
|
const tagged_oma_1 = require("./tagged-oma");
|
|
9
|
-
const
|
|
9
|
+
const utils_1 = require("./utils");
|
|
10
10
|
const mp3_1 = require("./mp3");
|
|
11
11
|
const codecs_1 = require("./codecs");
|
|
12
12
|
const bytemanip_1 = require("./bytemanip");
|
|
@@ -118,19 +118,19 @@ class DatabaseAbstraction {
|
|
|
118
118
|
}
|
|
119
119
|
return trackNumber;
|
|
120
120
|
}
|
|
121
|
-
async copyToFilesystem(data, globalTrackIndex, callback) {
|
|
121
|
+
async copyToFilesystem(data, globalTrackIndex, callback, chunkSize = 2048) {
|
|
122
122
|
// Make sure the audio store directory appropriate for this file exists
|
|
123
123
|
const audioStore = `/OMGAUDIO/10F${(globalTrackIndex >> 8).toString(16).padStart(2, '0')}`;
|
|
124
124
|
if (!(await this.filesystem.list("/OMGAUDIO")).some(e => e.name === audioStore)) {
|
|
125
125
|
// The audio store for this file doesn't yet exist - create it.
|
|
126
126
|
await this.filesystem.mkdir(audioStore);
|
|
127
127
|
}
|
|
128
|
-
const fh = await this.database.filesystem.open((0,
|
|
128
|
+
const fh = await this.database.filesystem.open((0, utils_1.resolvePathFromGlobalIndex)(globalTrackIndex), 'rw');
|
|
129
129
|
let remaining = data.length;
|
|
130
130
|
let i = 0;
|
|
131
131
|
callback === null || callback === void 0 ? void 0 : callback(i, data.length);
|
|
132
132
|
while (remaining) {
|
|
133
|
-
const toWrite = Math.min(
|
|
133
|
+
const toWrite = Math.min(chunkSize, remaining);
|
|
134
134
|
await fh.write(data.slice(i, i + toWrite));
|
|
135
135
|
i += toWrite;
|
|
136
136
|
remaining -= toWrite;
|
|
@@ -138,7 +138,7 @@ class DatabaseAbstraction {
|
|
|
138
138
|
}
|
|
139
139
|
await fh.close();
|
|
140
140
|
}
|
|
141
|
-
async uploadMP3Track(trackInfo, rawData, callback) {
|
|
141
|
+
async uploadMP3Track(trackInfo, rawData, callback, chunkSize) {
|
|
142
142
|
if (this.mp3DeviceKey === undefined && !this.deviceInfo.disableDRM)
|
|
143
143
|
throw new Error("Please load the device key first!");
|
|
144
144
|
const { codec, duration } = (0, mp3_1.generateMP3CodecField)(rawData);
|
|
@@ -149,9 +149,9 @@ class DatabaseAbstraction {
|
|
|
149
149
|
trackNumber,
|
|
150
150
|
}, codec, this.deviceInfo.disableDRM ? 0xFFFF : 0xFFFE);
|
|
151
151
|
const mp3Data = (0, mp3_1.createMP3OMAFile)(globalTrackIndex, trackInfo, rawData, this.deviceInfo.disableDRM ? null : this.mp3DeviceKey, codec);
|
|
152
|
-
await this.copyToFilesystem(mp3Data, globalTrackIndex, callback);
|
|
152
|
+
await this.copyToFilesystem(mp3Data, globalTrackIndex, callback, chunkSize);
|
|
153
153
|
}
|
|
154
|
-
async uploadTrack(trackInfo, codec, rawData, session, callback) {
|
|
154
|
+
async uploadTrack(trackInfo, codec, rawData, session, callback, chunkSize) {
|
|
155
155
|
const trackNumber = this.reassignTrackNumber(trackInfo);
|
|
156
156
|
// Step 1 - Create the encrypted OMA which will later be written to the device's storage
|
|
157
157
|
const omaFile = (this.deviceInfo.disableDRM ? tagged_oma_1.createTaggedOMA : tagged_oma_1.createTaggedEncryptedOMA)(rawData, trackInfo, codec);
|
|
@@ -162,7 +162,7 @@ class DatabaseAbstraction {
|
|
|
162
162
|
trackNumber,
|
|
163
163
|
}, codec, this.deviceInfo.disableDRM ? 0xFFFF : 0x0001);
|
|
164
164
|
// Step 3 - write track to the filesystem
|
|
165
|
-
await this.copyToFilesystem(omaFile.data, globalTrackIndex, callback);
|
|
165
|
+
await this.copyToFilesystem(omaFile.data, globalTrackIndex, callback, chunkSize);
|
|
166
166
|
// Step 4 - write MAC
|
|
167
167
|
if (!this.deviceInfo.disableDRM)
|
|
168
168
|
session === null || session === void 0 ? void 0 : session.writeTrackMac(globalTrackIndex - 1, omaFile.maclistValue);
|
|
@@ -183,7 +183,10 @@ class DatabaseAbstraction {
|
|
|
183
183
|
// Sort
|
|
184
184
|
this.deletedTracks.sort((a, b) => a - b);
|
|
185
185
|
// Delete the file.
|
|
186
|
-
|
|
186
|
+
try {
|
|
187
|
+
await this.filesystem.delete((0, utils_1.resolvePathFromGlobalIndex)(systemIndex));
|
|
188
|
+
}
|
|
189
|
+
catch (ex) { } // Might fail.
|
|
187
190
|
}
|
|
188
191
|
reserializeDatabase() {
|
|
189
192
|
const instrs = [
|
|
@@ -286,7 +289,7 @@ class DatabaseAbstraction {
|
|
|
286
289
|
}
|
|
287
290
|
async renameTrack(systemIndex, metadata) {
|
|
288
291
|
// Update the metadata within the OMA file
|
|
289
|
-
const handle = await this.database.filesystem.open((0,
|
|
292
|
+
const handle = await this.database.filesystem.open((0, utils_1.resolvePathFromGlobalIndex)(systemIndex), 'rw');
|
|
290
293
|
if (handle) {
|
|
291
294
|
try {
|
|
292
295
|
if (this.allTracks[systemIndex - 1].codecName === "MP3") {
|
package/dist/databases.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"databases.d.ts","sourceRoot":"","sources":["../src/databases.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAyB,aAAa,EAAE,MAAM,SAAS,CAAC;AAI/E,OAAO,EAAc,SAAS,EAAkB,MAAM,UAAU,CAAC;AAEjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AA2D/C,MAAM,WAAW,QAAQ;IAAE,cAAc,EAAE;QAAE,0BAA0B,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAC;AAC3I,MAAM,WAAW,YAAY;IAAG,eAAe,EAAE,UAAU,CAAC;IAAC,SAAS,EAAE,UAAU,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAC,CAAA;CAAC;AACvK,MAAM,WAAW,UAAU;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,MAAM,CA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;IAC9D,qBAAqB,EAAE,YAAY,EAAE,CAAM;gBAExB,UAAU,EAAE,cAAc,EAAU,kBAAkB,CAAC,EAAE,kBAAkB,YAAA;IAExF,IAAI;IAoFH,iBAAiB;IAsEX,aAAa;IAU1B,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,MAAM;;;;;;;;;IAkB/B,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAYvD,iBAAiB,IAAI;QAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,QAAQ,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,aAAa,CAAC;YAAC,SAAS,EAAE,MAAM,CAAA;SAAE,EAAE,CAAA;KAAC,EAAE;IAkC9L,kBAAkB,IAAI;QAAC,CAAC,MAAM,EAAE,MAAM,GAAG;YAAC,CAAC,KAAK,EAAE,MAAM,GAAG;gBAAC,KAAK,EAAE,MAAM,CAAC;gBAAC,KAAK,EAAE,CAAC,CAAC,CAAC;gBAAC,QAAQ,EAAE,MAAM,CAAC;gBAAC,SAAS,EAAE,aAAa,CAAC;gBAAC,SAAS,EAAE,MAAM,CAAA;aAAE,EAAE,CAAA;SAAC,CAAA;KAAC;CAwBnK"}
|
package/dist/derive-mp3-key.d.ts
CHANGED
|
@@ -8,5 +8,5 @@ export declare function deriveMP3ParametersFromOMA(mp3CodecInfo: Uint8Array): {
|
|
|
8
8
|
flags: number;
|
|
9
9
|
};
|
|
10
10
|
export declare function deriveMP3TrackKey(rawFile: Uint8Array, callback?: (state: 'genFrames' | 'genKeys' | 'commonness', progress: number, outOf: number) => void): number;
|
|
11
|
-
export declare function decryptMP3(fullFile: Uint8Array
|
|
11
|
+
export declare function decryptMP3(fullFile: Uint8Array<ArrayBuffer>, fileId: number, deviceKey?: number, callback?: (state: 'genFrames' | 'genKeys' | 'commonness' | 'decrypt', progress: number, of: number) => void): Uint8Array<ArrayBuffer>;
|
|
12
12
|
//# sourceMappingURL=derive-mp3-key.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"derive-mp3-key.d.ts","sourceRoot":"","sources":["../src/derive-mp3-key.ts"],"names":[],"mappings":"AAUA,wBAAgB,0BAA0B,CAAC,YAAY,EAAE,UAAU;;;;;;;;EAclE;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,GAAG,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,CA6DlK;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,IAAI,
|
|
1
|
+
{"version":3,"file":"derive-mp3-key.d.ts","sourceRoot":"","sources":["../src/derive-mp3-key.ts"],"names":[],"mappings":"AAUA,wBAAgB,0BAA0B,CAAC,YAAY,EAAE,UAAU;;;;;;;;EAclE;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,GAAG,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,CA6DlK;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,UAAU,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,IAAI,GAAG,UAAU,CAAC,WAAW,CAAC,CAyBvO"}
|
package/dist/derive-mp3-key.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.deriveMP3ParametersFromOMA = deriveMP3ParametersFromOMA;
|
|
4
|
+
exports.deriveMP3TrackKey = deriveMP3TrackKey;
|
|
5
|
+
exports.decryptMP3 = decryptMP3;
|
|
4
6
|
const bytemanip_1 = require("./bytemanip");
|
|
5
7
|
const encryption_1 = require("./encryption");
|
|
6
8
|
const id3_1 = require("./id3");
|
|
@@ -22,7 +24,6 @@ function deriveMP3ParametersFromOMA(mp3CodecInfo) {
|
|
|
22
24
|
const preemp = (cmb1 >> 2) & 3;
|
|
23
25
|
return { version, layer, bitrate, sample, chmod, preemp, flags };
|
|
24
26
|
}
|
|
25
|
-
exports.deriveMP3ParametersFromOMA = deriveMP3ParametersFromOMA;
|
|
26
27
|
function deriveMP3TrackKey(rawFile, callback) {
|
|
27
28
|
// Make sure we're dealing with an MP3 OMA file
|
|
28
29
|
let offset = 0;
|
|
@@ -82,7 +83,6 @@ function deriveMP3TrackKey(rawFile, callback) {
|
|
|
82
83
|
const matchedKey = allKeys[commonness.indexOf(Math.max(...commonness))];
|
|
83
84
|
return matchedKey;
|
|
84
85
|
}
|
|
85
|
-
exports.deriveMP3TrackKey = deriveMP3TrackKey;
|
|
86
86
|
function decryptMP3(fullFile, fileId, deviceKey, callback) {
|
|
87
87
|
const trackKey = (deviceKey ? (0, encryption_1.getMP3EncryptionKey)(deviceKey, fileId) : deriveMP3TrackKey(fullFile, callback ? (s, p) => callback(s, p, 127) : undefined)) >>> 0;
|
|
88
88
|
// Make sure we're dealing with an MP3 OMA file
|
|
@@ -106,4 +106,3 @@ function decryptMP3(fullFile, fileId, deviceKey, callback) {
|
|
|
106
106
|
}
|
|
107
107
|
return data;
|
|
108
108
|
}
|
|
109
|
-
exports.decryptMP3 = decryptMP3;
|
package/dist/devices.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.DeviceIds = void 0;
|
|
4
|
+
exports.findDevice = findDevice;
|
|
4
5
|
exports.DeviceIds = [
|
|
5
6
|
{ vendorId: 0x054c, productId: 0x01ad, name: 'Sony NW-HD1 / NW-HD2' },
|
|
6
7
|
{ vendorId: 0x054c, productId: 0x0210, name: 'Sony NW-HD3' },
|
|
@@ -118,4 +119,3 @@ function findDevice(vid, pid) {
|
|
|
118
119
|
var _a;
|
|
119
120
|
return (_a = exports.DeviceIds.find(e => e.vendorId === vid && e.productId === pid)) !== null && _a !== void 0 ? _a : null;
|
|
120
121
|
}
|
|
121
|
-
exports.findDevice = findDevice;
|
package/dist/encryption.d.ts
CHANGED
|
@@ -5,12 +5,12 @@ export declare const EKBROOTS: {
|
|
|
5
5
|
};
|
|
6
6
|
export declare function importKeys(rawKeysContents: Uint8Array): void;
|
|
7
7
|
export declare function getMP3EncryptionKey(discId: number, trackNumber: number): number;
|
|
8
|
-
export declare function createTrackKeyForKeyring(ekbNum: number, verificationKey: Uint8Array, trackKey: Uint8Array): Uint8Array
|
|
9
|
-
export declare function createTrackKeyFromKeyring(ekbNum: number, encryptedVerificationKey: Uint8Array, encryptedTrackKey: Uint8Array): Uint8Array
|
|
10
|
-
export declare function createMaclistValue(ekbNum: number, verificationKey: Uint8Array, contents: Uint8Array): Uint8Array
|
|
11
|
-
export declare function retailMac(message: Uint8Array, key: Uint8Array): Uint8Array
|
|
12
|
-
export declare function createIcvMac(icvAndHeader: Uint8Array, sessionKey: Uint8Array): Uint8Array
|
|
13
|
-
export declare function createTrackMac2(trackKeyWa: Crypto.lib.WordArray, trackEntry: Uint8Array): Uint8Array
|
|
14
|
-
export declare function createTrackMac(trackKey: Uint8Array, trackEntry: Uint8Array): Uint8Array
|
|
15
|
-
export declare function desDecrypt(data: Uint8Array, key: Uint8Array): Uint8Array
|
|
8
|
+
export declare function createTrackKeyForKeyring(ekbNum: number, verificationKey: Uint8Array, trackKey: Uint8Array): Uint8Array<ArrayBuffer>;
|
|
9
|
+
export declare function createTrackKeyFromKeyring(ekbNum: number, encryptedVerificationKey: Uint8Array, encryptedTrackKey: Uint8Array): Uint8Array<ArrayBuffer>;
|
|
10
|
+
export declare function createMaclistValue(ekbNum: number, verificationKey: Uint8Array, contents: Uint8Array): Uint8Array<ArrayBuffer>;
|
|
11
|
+
export declare function retailMac(message: Uint8Array, key: Uint8Array): Uint8Array<ArrayBuffer>;
|
|
12
|
+
export declare function createIcvMac(icvAndHeader: Uint8Array, sessionKey: Uint8Array): Uint8Array<ArrayBuffer>;
|
|
13
|
+
export declare function createTrackMac2(trackKeyWa: Crypto.lib.WordArray, trackEntry: Uint8Array): Uint8Array<ArrayBuffer>;
|
|
14
|
+
export declare function createTrackMac(trackKey: Uint8Array, trackEntry: Uint8Array): Uint8Array<ArrayBuffer>;
|
|
15
|
+
export declare function desDecrypt(data: Uint8Array, key: Uint8Array): Uint8Array<ArrayBuffer>;
|
|
16
16
|
//# sourceMappingURL=encryption.d.ts.map
|
package/dist/encryption.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encryption.d.ts","sourceRoot":"","sources":["../src/encryption.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,0BAA0B,CAAC;AAK9C,wBAAsB,UAAU,kBAG/B;AAGD,eAAO,MAAM,QAAQ,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAA;CAExC,CAAC;AAEX,wBAAgB,UAAU,CAAC,eAAe,EAAE,UAA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AAU,EAAE,GAAG,EAAE,UAAU,2BAE3D"}
|
package/dist/encryption.js
CHANGED
|
@@ -3,7 +3,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.EKBROOTS = void 0;
|
|
7
|
+
exports.initCrypto = initCrypto;
|
|
8
|
+
exports.importKeys = importKeys;
|
|
9
|
+
exports.getMP3EncryptionKey = getMP3EncryptionKey;
|
|
10
|
+
exports.createTrackKeyForKeyring = createTrackKeyForKeyring;
|
|
11
|
+
exports.createTrackKeyFromKeyring = createTrackKeyFromKeyring;
|
|
12
|
+
exports.createMaclistValue = createMaclistValue;
|
|
13
|
+
exports.retailMac = retailMac;
|
|
14
|
+
exports.createIcvMac = createIcvMac;
|
|
15
|
+
exports.createTrackMac2 = createTrackMac2;
|
|
16
|
+
exports.createTrackMac = createTrackMac;
|
|
17
|
+
exports.desDecrypt = desDecrypt;
|
|
7
18
|
const crypto_js_wasm_1 = __importDefault(require("@originjs/crypto-js-wasm"));
|
|
8
19
|
const bytemanip_1 = require("./bytemanip");
|
|
9
20
|
const errors_1 = require("./errors");
|
|
@@ -12,7 +23,6 @@ async function initCrypto() {
|
|
|
12
23
|
await crypto_js_wasm_1.default.TripleDES.loadWasm();
|
|
13
24
|
await crypto_js_wasm_1.default.DES.loadWasm();
|
|
14
25
|
}
|
|
15
|
-
exports.initCrypto = initCrypto;
|
|
16
26
|
// prettier-ignore
|
|
17
27
|
exports.EKBROOTS = {
|
|
18
28
|
// <Redacted>
|
|
@@ -26,11 +36,9 @@ function importKeys(rawKeysContents) {
|
|
|
26
36
|
exports.EKBROOTS[ekbid] = rawKeysContents.slice(offset, offset += 3 * 8);
|
|
27
37
|
}
|
|
28
38
|
}
|
|
29
|
-
exports.importKeys = importKeys;
|
|
30
39
|
function getMP3EncryptionKey(discId, trackNumber) {
|
|
31
40
|
return ((trackNumber * 0x5296E435 + 0x2465) ^ discId) >>> 0;
|
|
32
41
|
}
|
|
33
|
-
exports.getMP3EncryptionKey = getMP3EncryptionKey;
|
|
34
42
|
function createTrackKeyForKeyring(ekbNum, verificationKey, trackKey) {
|
|
35
43
|
if (!(ekbNum in exports.EKBROOTS)) {
|
|
36
44
|
throw new errors_1.NWJSError('Requested decryption with an unknown EKB');
|
|
@@ -52,7 +60,6 @@ function createTrackKeyForKeyring(ekbNum, verificationKey, trackKey) {
|
|
|
52
60
|
});
|
|
53
61
|
return (0, utils_1.wordArrayToByteArray)(decryptedTrackKey, 8);
|
|
54
62
|
}
|
|
55
|
-
exports.createTrackKeyForKeyring = createTrackKeyForKeyring;
|
|
56
63
|
function createTrackKeyFromKeyring(ekbNum, encryptedVerificationKey, encryptedTrackKey) {
|
|
57
64
|
if (!(ekbNum in exports.EKBROOTS)) {
|
|
58
65
|
throw new errors_1.NWJSError('Requested decryption with an unknown EKB');
|
|
@@ -73,7 +80,6 @@ function createTrackKeyFromKeyring(ekbNum, encryptedVerificationKey, encryptedTr
|
|
|
73
80
|
}).ciphertext;
|
|
74
81
|
return (0, utils_1.wordArrayToByteArray)(decryptedTrackKey, 8);
|
|
75
82
|
}
|
|
76
|
-
exports.createTrackKeyFromKeyring = createTrackKeyFromKeyring;
|
|
77
83
|
function createMaclistValue(ekbNum, verificationKey, contents) {
|
|
78
84
|
if (!(ekbNum in exports.EKBROOTS)) {
|
|
79
85
|
throw new errors_1.NWJSError('Requested decryption with an unknown EKB');
|
|
@@ -88,7 +94,6 @@ function createMaclistValue(ekbNum, verificationKey, contents) {
|
|
|
88
94
|
});
|
|
89
95
|
return createTrackMac2(decryptedVerificationKey, contents);
|
|
90
96
|
}
|
|
91
|
-
exports.createMaclistValue = createMaclistValue;
|
|
92
97
|
const NO_PADDING = { pad: (a) => a, unpad: (a) => a };
|
|
93
98
|
function retailMac(message, key) {
|
|
94
99
|
const keyA = key.subarray(0, 8);
|
|
@@ -107,7 +112,6 @@ function retailMac(message, key) {
|
|
|
107
112
|
const final = crypto_js_wasm_1.default.DES.encrypt(encB, keyAWa, { padding: NO_PADDING, mode: crypto_js_wasm_1.default.mode.ECB }).ciphertext;
|
|
108
113
|
return (0, utils_1.wordArrayToByteArray)(final);
|
|
109
114
|
}
|
|
110
|
-
exports.retailMac = retailMac;
|
|
111
115
|
function createIcvMac(icvAndHeader, sessionKey) {
|
|
112
116
|
const icvWa = crypto_js_wasm_1.default.lib.WordArray.create(icvAndHeader);
|
|
113
117
|
const sessionKeyWa = crypto_js_wasm_1.default.lib.WordArray.create(sessionKey);
|
|
@@ -115,7 +119,6 @@ function createIcvMac(icvAndHeader, sessionKey) {
|
|
|
115
119
|
const result = crypto_js_wasm_1.default.DES.encrypt(icvWa, sessionKeyWa, { mode: crypto_js_wasm_1.default.mode.CBC, iv: zeroWa, padding: NO_PADDING });
|
|
116
120
|
return (0, utils_1.wordArrayToByteArray)(result.ciphertext).subarray(-8);
|
|
117
121
|
}
|
|
118
|
-
exports.createIcvMac = createIcvMac;
|
|
119
122
|
function createTrackMac2(trackKeyWa, trackEntry) {
|
|
120
123
|
const trackEntryWa = crypto_js_wasm_1.default.lib.WordArray.create(trackEntry);
|
|
121
124
|
const macKeySourceWa = crypto_js_wasm_1.default.lib.WordArray.create(new Uint8Array(8).fill(0));
|
|
@@ -124,13 +127,10 @@ function createTrackMac2(trackKeyWa, trackEntry) {
|
|
|
124
127
|
const mac = crypto_js_wasm_1.default.DES.encrypt(trackEntryWa, macKey, { mode: crypto_js_wasm_1.default.mode.CBC, iv: zeroWa, padding: NO_PADDING });
|
|
125
128
|
return (0, utils_1.wordArrayToByteArray)(mac.ciphertext).subarray(-8);
|
|
126
129
|
}
|
|
127
|
-
exports.createTrackMac2 = createTrackMac2;
|
|
128
130
|
function createTrackMac(trackKey, trackEntry) {
|
|
129
131
|
const trackKeyWa = crypto_js_wasm_1.default.lib.WordArray.create(trackKey);
|
|
130
132
|
return createTrackMac2(trackKeyWa, trackEntry);
|
|
131
133
|
}
|
|
132
|
-
exports.createTrackMac = createTrackMac;
|
|
133
134
|
function desDecrypt(data, key) {
|
|
134
135
|
return (0, utils_1.wordArrayToByteArray)(crypto_js_wasm_1.default.TripleDES.decrypt(crypto_js_wasm_1.default.lib.CipherParams.create({ ciphertext: crypto_js_wasm_1.default.lib.WordArray.create(data) }), crypto_js_wasm_1.default.lib.WordArray.create(key), { mode: crypto_js_wasm_1.default.mode.ECB, iv: crypto_js_wasm_1.default.lib.WordArray.create(new Uint8Array(8).fill(0)) }), data.length);
|
|
135
136
|
}
|
|
136
|
-
exports.desDecrypt = desDecrypt;
|
|
@@ -2,37 +2,38 @@ import { HiMDFile, HiMDFilesystem, SonyVendorUSMCDriver, UMSCHiMDFilesystem } fr
|
|
|
2
2
|
import { WebUSBDevice } from 'usb';
|
|
3
3
|
export declare class SonyVendorNWJSUSMCDriver extends SonyVendorUSMCDriver {
|
|
4
4
|
constructor(webUSB: WebUSBDevice);
|
|
5
|
-
protected drmRead(param: number, length: number): Promise<Uint8Array
|
|
5
|
+
protected drmRead(param: number, length: number): Promise<Uint8Array<ArrayBuffer>>;
|
|
6
6
|
protected drmWrite(param: number, data: Uint8Array): Promise<void>;
|
|
7
7
|
getDiscID(): Promise<Uint8Array>;
|
|
8
8
|
writeHostLeafID(leafID: Uint8Array, hostNonce: Uint8Array): Promise<void>;
|
|
9
9
|
getAuthenticationStage2Info(): Promise<{
|
|
10
|
-
discId: Uint8Array
|
|
11
|
-
mac: Uint8Array
|
|
12
|
-
deviceLeafId: Uint8Array
|
|
13
|
-
deviceNonce: Uint8Array
|
|
10
|
+
discId: Uint8Array<ArrayBuffer>;
|
|
11
|
+
mac: Uint8Array<ArrayBuffer>;
|
|
12
|
+
deviceLeafId: Uint8Array<ArrayBuffer>;
|
|
13
|
+
deviceNonce: Uint8Array<ArrayBuffer>;
|
|
14
14
|
}>;
|
|
15
15
|
writeAuthenticationStage3Info(hostMac: Uint8Array): Promise<void>;
|
|
16
16
|
readMasterKey(): Promise<{
|
|
17
|
-
header: Uint8Array
|
|
18
|
-
masterKey: Uint8Array
|
|
17
|
+
header: Uint8Array<ArrayBuffer>;
|
|
18
|
+
masterKey: Uint8Array<ArrayBuffer>;
|
|
19
19
|
}>;
|
|
20
20
|
writeMasterKeyAndMac(generation: number, masterKey: Uint8Array, mac: Uint8Array, sessionKey: Uint8Array): Promise<void>;
|
|
21
21
|
}
|
|
22
|
+
type _Uint8Array = Uint8Array<ArrayBuffer>;
|
|
22
23
|
export declare class UMSCNWJSSession {
|
|
23
24
|
protected driver: SonyVendorNWJSUSMCDriver;
|
|
24
25
|
protected fs: HiMDFilesystem;
|
|
25
|
-
hostNonce: Uint8Array
|
|
26
|
-
hostLeafId: Uint8Array
|
|
27
|
-
deviceNonce?:
|
|
28
|
-
discId?:
|
|
29
|
-
deviceLeafId?:
|
|
30
|
-
currentIcv?:
|
|
31
|
-
currentIcvHeader?:
|
|
32
|
-
sessionKey?:
|
|
26
|
+
hostNonce: Uint8Array<ArrayBuffer>;
|
|
27
|
+
hostLeafId: Uint8Array<ArrayBuffer>;
|
|
28
|
+
deviceNonce?: _Uint8Array;
|
|
29
|
+
discId?: _Uint8Array;
|
|
30
|
+
deviceLeafId?: _Uint8Array;
|
|
31
|
+
currentIcv?: _Uint8Array;
|
|
32
|
+
currentIcvHeader?: _Uint8Array;
|
|
33
|
+
sessionKey?: _Uint8Array;
|
|
33
34
|
mclistHandle?: HiMDFile;
|
|
34
35
|
currentGeneration?: number;
|
|
35
|
-
allMacs?:
|
|
36
|
+
allMacs?: _Uint8Array;
|
|
36
37
|
constructor(driver: SonyVendorNWJSUSMCDriver, fs: HiMDFilesystem);
|
|
37
38
|
performAuthorization(): Promise<void>;
|
|
38
39
|
finalizeSession(): Promise<void>;
|
|
@@ -44,4 +45,5 @@ export declare class UMSCNWJSFilesystem extends UMSCHiMDFilesystem {
|
|
|
44
45
|
constructor(webUSB: WebUSBDevice, partition?: number | null);
|
|
45
46
|
protected initFS(bypassCoherencyChecks?: boolean | undefined): Promise<void>;
|
|
46
47
|
}
|
|
48
|
+
export {};
|
|
47
49
|
//# sourceMappingURL=usb-mass-storage-webusb-filesystem.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usb-mass-storage-webusb-filesystem.d.ts","sourceRoot":"","sources":["../../src/filesystem/usb-mass-storage-webusb-filesystem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAI7F,OAAO,EAAE,YAAY,EAAE,MAAM,KAAK,CAAC;AAKnC,qBAAa,wBAAyB,SAAQ,oBAAoB;gBAClD,MAAM,EAAE,YAAY;cAIhB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"usb-mass-storage-webusb-filesystem.d.ts","sourceRoot":"","sources":["../../src/filesystem/usb-mass-storage-webusb-filesystem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAI7F,OAAO,EAAE,YAAY,EAAE,MAAM,KAAK,CAAC;AAKnC,qBAAa,wBAAyB,SAAQ,oBAAoB;gBAClD,MAAM,EAAE,YAAY;cAIhB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;cAuBxE,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU;IA2BlD,SAAS,IAAI,OAAO,CAAC,UAAU,CAAC;IAIhC,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU;IASzD,2BAA2B;;;;;;IAoB3B,6BAA6B,CAAC,OAAO,EAAE,UAAU;IAyBjD,aA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