@ctrl/torrent-file 1.3.0 → 2.0.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/dist/{bencode → src/bencode}/decode.d.ts +0 -0
- package/dist/{bencode → src/bencode}/decode.js +8 -10
- package/dist/{bencode → src/bencode}/encode.d.ts +1 -1
- package/dist/{bencode → src/bencode}/encode.js +5 -18
- package/dist/{bencode → src/bencode}/index.d.ts +0 -0
- package/dist/src/bencode/index.js +2 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/isArrayBuffer.d.ts +11 -0
- package/dist/src/isArrayBuffer.js +16 -0
- package/dist/{torrentFile.d.ts → src/torrentFile.d.ts} +0 -0
- package/dist/{torrentFile.js → src/torrentFile.js} +16 -25
- package/package.json +33 -28
- package/dist/bencode/decode.js.map +0 -1
- package/dist/bencode/encode.js.map +0 -1
- package/dist/bencode/index.js +0 -15
- package/dist/bencode/index.js.map +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -15
- package/dist/index.js.map +0 -1
- package/dist/torrentFile.js.map +0 -1
File without changes
|
@@ -1,6 +1,3 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.decode = void 0;
|
4
1
|
const INTEGER_START = 0x69; // 'i'
|
5
2
|
const STRING_DELIM = 0x3a; // ':'
|
6
3
|
const DICTIONARY_START = 0x64; // 'd'
|
@@ -15,8 +12,11 @@ function getIntFromBuffer(buffer, start, end) {
|
|
15
12
|
let sign = 1;
|
16
13
|
for (let i = start; i < end; i++) {
|
17
14
|
const num = buffer[i];
|
15
|
+
if (typeof num === 'undefined') {
|
16
|
+
continue;
|
17
|
+
}
|
18
18
|
if (num < 58 && num >= 48) {
|
19
|
-
sum =
|
19
|
+
sum = sum * 10 + (num - 48);
|
20
20
|
continue;
|
21
21
|
}
|
22
22
|
if (i === start && num === 43) {
|
@@ -40,7 +40,7 @@ function getIntFromBuffer(buffer, start, end) {
|
|
40
40
|
/**
|
41
41
|
* Decodes bencoded data
|
42
42
|
*/
|
43
|
-
function decode(data, encoding = null) {
|
43
|
+
export function decode(data, encoding = null) {
|
44
44
|
const state = {
|
45
45
|
bytes: 0,
|
46
46
|
position: 0,
|
@@ -54,7 +54,6 @@ function decode(data, encoding = null) {
|
|
54
54
|
state.bytes = state.data.length;
|
55
55
|
return next(state);
|
56
56
|
}
|
57
|
-
exports.decode = decode;
|
58
57
|
function next(state) {
|
59
58
|
switch (state.data[state.position]) {
|
60
59
|
case DICTIONARY_START:
|
@@ -112,8 +111,7 @@ function buffer(state) {
|
|
112
111
|
const length = getIntFromBuffer(state.data, state.position, sep);
|
113
112
|
const end = ++sep + length;
|
114
113
|
state.position = end;
|
115
|
-
return state.encoding
|
116
|
-
state.data.toString(state.encoding, sep, end)
|
117
|
-
state.data.slice(sep, end);
|
114
|
+
return state.encoding
|
115
|
+
? state.data.toString(state.encoding, sep, end)
|
116
|
+
: state.data.slice(sep, end);
|
118
117
|
}
|
119
|
-
//# sourceMappingURL=decode.js.map
|
@@ -2,4 +2,4 @@
|
|
2
2
|
/**
|
3
3
|
* Encodes data in bencode.
|
4
4
|
*/
|
5
|
-
export declare function encode(data: Buffer | string | any[] | ArrayBuffer | number | boolean | Record<string, unknown> | object, buffer?:
|
5
|
+
export declare function encode(data: Buffer | string | any[] | ArrayBuffer | number | boolean | Record<string, unknown> | object, buffer?: unknown, offset?: number, disableFloatConversionWarning?: boolean): Buffer;
|
@@ -1,15 +1,9 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.encode = void 0;
|
7
1
|
/* eslint-disable @typescript-eslint/ban-types */
|
8
|
-
|
2
|
+
import { isArrayBuffer } from '../isArrayBuffer.js';
|
9
3
|
/**
|
10
4
|
* Encodes data in bencode.
|
11
5
|
*/
|
12
|
-
function encode(data, buffer, offset, disableFloatConversionWarning = false) {
|
6
|
+
export function encode(data, buffer, offset, disableFloatConversionWarning = false) {
|
13
7
|
const buffers = [];
|
14
8
|
const state = {
|
15
9
|
bytes: -1,
|
@@ -24,7 +18,6 @@ function encode(data, buffer, offset, disableFloatConversionWarning = false) {
|
|
24
18
|
}
|
25
19
|
return result;
|
26
20
|
}
|
27
|
-
exports.encode = encode;
|
28
21
|
function getType(value) {
|
29
22
|
if (Buffer.isBuffer(value)) {
|
30
23
|
return 'buffer';
|
@@ -41,7 +34,7 @@ function getType(value) {
|
|
41
34
|
if (value instanceof Boolean) {
|
42
35
|
return 'boolean';
|
43
36
|
}
|
44
|
-
if (
|
37
|
+
if (isArrayBuffer(value)) {
|
45
38
|
return 'arraybuffer';
|
46
39
|
}
|
47
40
|
return typeof value;
|
@@ -92,7 +85,7 @@ function number(state, buffers, data) {
|
|
92
85
|
const maxLo = 0x80000000;
|
93
86
|
const hi = (data / maxLo) << 0;
|
94
87
|
const lo = data % maxLo << 0;
|
95
|
-
const val =
|
88
|
+
const val = hi * maxLo + lo;
|
96
89
|
buffers.push(Buffer.from(`i${val}e`));
|
97
90
|
if (val !== data && !state.disableFloatConversionWarning) {
|
98
91
|
state.disableFloatConversionWarning = true;
|
@@ -102,14 +95,9 @@ function number(state, buffers, data) {
|
|
102
95
|
}
|
103
96
|
function dict(state, buffers, data) {
|
104
97
|
buffers.push(buffD);
|
105
|
-
let j = 0;
|
106
|
-
let k;
|
107
98
|
// sorted dicts
|
108
|
-
// eslint-disable-next-line @typescript-eslint/require-array-sort-compare
|
109
99
|
const keys = Object.keys(data).sort();
|
110
|
-
const
|
111
|
-
for (; j < kl; j++) {
|
112
|
-
k = keys[j];
|
100
|
+
for (const k of keys) {
|
113
101
|
// filter out null / undefined elements
|
114
102
|
if (data[k] === null || data[k] === undefined) {
|
115
103
|
continue;
|
@@ -131,4 +119,3 @@ function list(state, buffers, data) {
|
|
131
119
|
}
|
132
120
|
buffers.push(buffE);
|
133
121
|
}
|
134
|
-
//# sourceMappingURL=encode.js.map
|
File without changes
|
@@ -0,0 +1,11 @@
|
|
1
|
+
/**
|
2
|
+
* Check if the given value is an ArrayBuffer.
|
3
|
+
* @param value - The value to check.
|
4
|
+
* @returns `true` if the given value is an ArrayBuffer, else `false`.
|
5
|
+
* @example
|
6
|
+
* isArrayBuffer(new ArrayBuffer())
|
7
|
+
* // => true
|
8
|
+
* isArrayBuffer([])
|
9
|
+
* // => false
|
10
|
+
*/
|
11
|
+
export declare function isArrayBuffer(value: unknown): boolean;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
const hasArrayBuffer = typeof ArrayBuffer === 'function';
|
2
|
+
const { toString } = Object.prototype;
|
3
|
+
/**
|
4
|
+
* Check if the given value is an ArrayBuffer.
|
5
|
+
* @param value - The value to check.
|
6
|
+
* @returns `true` if the given value is an ArrayBuffer, else `false`.
|
7
|
+
* @example
|
8
|
+
* isArrayBuffer(new ArrayBuffer())
|
9
|
+
* // => true
|
10
|
+
* isArrayBuffer([])
|
11
|
+
* // => false
|
12
|
+
*/
|
13
|
+
export function isArrayBuffer(value) {
|
14
|
+
return (hasArrayBuffer &&
|
15
|
+
(value instanceof ArrayBuffer || toString.call(value) === '[object ArrayBuffer]'));
|
16
|
+
}
|
File without changes
|
@@ -1,22 +1,18 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
const crypto_hash_1 = require("crypto-hash");
|
5
|
-
const path_1 = require("path");
|
6
|
-
const bencode_1 = require("./bencode");
|
1
|
+
import { join, sep } from 'node:path';
|
2
|
+
import { sha1 } from 'crypto-hash';
|
3
|
+
import { decode, encode } from './bencode/index.js';
|
7
4
|
/**
|
8
5
|
* sha1 of torrent file info. This hash is commenly used by torrent clients as the ID of the torrent.
|
9
6
|
*/
|
10
|
-
async function hash(file) {
|
11
|
-
const torrent =
|
12
|
-
return
|
7
|
+
export async function hash(file) {
|
8
|
+
const torrent = decode(file);
|
9
|
+
return sha1(encode(torrent.info));
|
13
10
|
}
|
14
|
-
exports.hash = hash;
|
15
11
|
/**
|
16
12
|
* data about the files the torrent contains
|
17
13
|
*/
|
18
|
-
function files(file) {
|
19
|
-
const torrent =
|
14
|
+
export function files(file) {
|
15
|
+
const torrent = decode(file);
|
20
16
|
const result = {
|
21
17
|
files: [],
|
22
18
|
length: 0,
|
@@ -27,11 +23,9 @@ function files(file) {
|
|
27
23
|
const files = torrent.info.files || [torrent.info];
|
28
24
|
const name = (torrent.info['name.utf-8'] || torrent.info.name).toString();
|
29
25
|
result.files = files.map((file, i) => {
|
30
|
-
const parts = []
|
31
|
-
.concat(name, file['path.utf-8'] || file.path || [])
|
32
|
-
.map(p => p.toString());
|
26
|
+
const parts = [name, ...(file['path.utf-8'] || file.path || [])].map(p => p.toString());
|
33
27
|
return {
|
34
|
-
path:
|
28
|
+
path: join(sep, ...parts).slice(1),
|
35
29
|
name: parts[parts.length - 1],
|
36
30
|
length: file.length,
|
37
31
|
offset: files.slice(0, i).reduce(sumLength, 0),
|
@@ -40,11 +34,10 @@ function files(file) {
|
|
40
34
|
result.length = files.reduce(sumLength, 0);
|
41
35
|
const lastFile = result.files[result.files.length - 1];
|
42
36
|
result.lastPieceLength =
|
43
|
-
(lastFile.offset + lastFile.length) % result.pieceLength || result.pieceLength;
|
37
|
+
(lastFile && (lastFile.offset + lastFile.length) % result.pieceLength) || result.pieceLength;
|
44
38
|
result.pieces = splitPieces(torrent.info.pieces);
|
45
39
|
return result;
|
46
40
|
}
|
47
|
-
exports.files = files;
|
48
41
|
function sumLength(sum, file) {
|
49
42
|
return sum + file.length;
|
50
43
|
}
|
@@ -58,8 +51,8 @@ function splitPieces(buf) {
|
|
58
51
|
/**
|
59
52
|
* torrent file info
|
60
53
|
*/
|
61
|
-
function info(file) {
|
62
|
-
const torrent =
|
54
|
+
export function info(file) {
|
55
|
+
const torrent = decode(file);
|
63
56
|
const result = {
|
64
57
|
name: (torrent.info['name.utf-8'] || torrent.info.name).toString(),
|
65
58
|
announce: [],
|
@@ -81,8 +74,8 @@ function info(file) {
|
|
81
74
|
if (Array.isArray(torrent['announce-list']) &&
|
82
75
|
torrent['announce-list'] &&
|
83
76
|
torrent['announce-list'].length > 0) {
|
84
|
-
torrent['announce-list'].forEach(urls => {
|
85
|
-
urls.forEach(url => {
|
77
|
+
torrent['announce-list'].forEach((urls) => {
|
78
|
+
urls.forEach((url) => {
|
86
79
|
result.announce.push(url.toString());
|
87
80
|
});
|
88
81
|
});
|
@@ -98,11 +91,9 @@ function info(file) {
|
|
98
91
|
// some clients set url-list to empty string
|
99
92
|
torrent['url-list'] = torrent['url-list'].length > 0 ? [torrent['url-list']] : [];
|
100
93
|
}
|
101
|
-
result.urlList = (torrent['url-list'] || []).map(url => url.toString());
|
94
|
+
result.urlList = (torrent['url-list'] || []).map((url) => url.toString());
|
102
95
|
if (result.urlList.length) {
|
103
96
|
result.urlList = Array.from(new Set(result.urlList));
|
104
97
|
}
|
105
98
|
return result;
|
106
99
|
}
|
107
|
-
exports.info = info;
|
108
|
-
//# sourceMappingURL=torrentFile.js.map
|
package/package.json
CHANGED
@@ -1,46 +1,51 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ctrl/torrent-file",
|
3
|
-
"version": "
|
3
|
+
"version": "2.0.0",
|
4
4
|
"description": "Parse a torrent file (name, hash, files, pieces)",
|
5
5
|
"author": "Scott Cooper <scttcper@gmail.com>",
|
6
6
|
"license": "MIT",
|
7
7
|
"repository": "scttcper/torrent-file",
|
8
|
-
"
|
9
|
-
"
|
8
|
+
"type": "module",
|
9
|
+
"exports": "./dist/src/index.js",
|
10
|
+
"types": "./dist/src/index.d.ts",
|
10
11
|
"files": [
|
11
|
-
"dist"
|
12
|
+
"dist/src"
|
12
13
|
],
|
13
14
|
"sideEffects": false,
|
14
|
-
"keywords": [
|
15
|
-
"typescript"
|
16
|
-
],
|
15
|
+
"keywords": [],
|
17
16
|
"scripts": {
|
18
|
-
"lint": "eslint --ext .
|
19
|
-
"lint:fix": "eslint --fix --ext .
|
17
|
+
"lint": "eslint --ext .ts .",
|
18
|
+
"lint:fix": "eslint --fix --ext .ts .",
|
20
19
|
"prepare": "npm run build",
|
21
|
-
"build": "tsc
|
22
|
-
"test": "
|
23
|
-
"test:watch": "
|
24
|
-
"test:ci": "
|
20
|
+
"build": "tsc",
|
21
|
+
"test": "ava",
|
22
|
+
"test:watch": "ava --watch",
|
23
|
+
"test:ci": "c8 --reporter=text --reporter=lcov ava"
|
25
24
|
},
|
26
25
|
"dependencies": {
|
27
|
-
"crypto-hash": "^
|
28
|
-
"lodash.isarraybuffer": "^4.4.1"
|
26
|
+
"crypto-hash": "^2.0.1"
|
29
27
|
},
|
30
28
|
"devDependencies": {
|
31
|
-
"@
|
32
|
-
"@
|
33
|
-
"@types/
|
34
|
-
"@types/
|
35
|
-
"
|
36
|
-
"
|
37
|
-
"
|
38
|
-
"
|
39
|
-
"typescript": "
|
29
|
+
"@sindresorhus/tsconfig": "2.0.0",
|
30
|
+
"@ctrl/eslint-config": "3.1.4",
|
31
|
+
"@types/node": "17.0.0",
|
32
|
+
"@types/parse-torrent": "5.8.4",
|
33
|
+
"ava": "4.0.0-rc.1",
|
34
|
+
"c8": "7.10.0",
|
35
|
+
"tsm": "2.2.1",
|
36
|
+
"parse-torrent": "9.1.4",
|
37
|
+
"typescript": "4.5.4"
|
40
38
|
},
|
41
|
-
"
|
42
|
-
"
|
43
|
-
|
39
|
+
"ava": {
|
40
|
+
"files": [
|
41
|
+
"test/**/*.spec.ts"
|
42
|
+
],
|
43
|
+
"extensions": {
|
44
|
+
"ts": "module"
|
45
|
+
},
|
46
|
+
"nodeArguments": [
|
47
|
+
"--loader=tsm"
|
48
|
+
]
|
44
49
|
},
|
45
50
|
"publishConfig": {
|
46
51
|
"access": "public"
|
@@ -49,6 +54,6 @@
|
|
49
54
|
"branch": "master"
|
50
55
|
},
|
51
56
|
"engines": {
|
52
|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,CAAC;IAEpB,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QACjB,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE;YACpB,SAAS;SACV;QAED,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;KAClC;IAED,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC"}
|
package/dist/bencode/index.js
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
-
if (k2 === undefined) k2 = k;
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
5
|
-
}) : (function(o, m, k, k2) {
|
6
|
-
if (k2 === undefined) k2 = k;
|
7
|
-
o[k2] = m[k];
|
8
|
-
}));
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
10
|
-
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
11
|
-
};
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
13
|
-
__exportStar(require("./decode"), exports);
|
14
|
-
__exportStar(require("./encode"), exports);
|
15
|
-
//# sourceMappingURL=index.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bencode/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAyB;AACzB,2CAAyB"}
|
package/dist/index.d.ts
DELETED
package/dist/index.js
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
-
if (k2 === undefined) k2 = k;
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
5
|
-
}) : (function(o, m, k, k2) {
|
6
|
-
if (k2 === undefined) k2 = k;
|
7
|
-
o[k2] = m[k];
|
8
|
-
}));
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
10
|
-
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
11
|
-
};
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
13
|
-
__exportStar(require("./bencode"), exports);
|
14
|
-
__exportStar(require("./torrentFile"), exports);
|
15
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAA0B;AAC1B,gDAA8B"}
|
package/dist/torrentFile.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"torrentFile.js","sourceRoot":"","sources":["../src/torrentFile.ts"],"names":[],"mappings":";;;AAAA,6CAAmC;AACnC,+BAAiC;AAEjC,uCAA2C;AAE3C;;GAEG;AACI,KAAK,UAAU,IAAI,CAAC,IAAY;IACrC,MAAM,OAAO,GAAQ,gBAAM,CAAC,IAAI,CAAC,CAAC;IAClC,OAAO,kBAAI,CAAC,gBAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AACpC,CAAC;AAHD,oBAGC;AAwBD;;GAEG;AACH,SAAgB,KAAK,CAAC,IAAY;IAChC,MAAM,OAAO,GAAQ,gBAAM,CAAC,IAAI,CAAC,CAAC;IAClC,MAAM,MAAM,GAAoB;QAC9B,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,CAAC;QACT,eAAe,EAAE,CAAC;QAClB,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC;QACzC,MAAM,EAAE,EAAE;KACX,CAAC;IAEF,MAAM,KAAK,GAAa,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7D,MAAM,IAAI,G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