moeralib 0.18.1 → 0.18.3
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/lib/naming/index.js +4 -1
- package/lib/naming/naming.js +13 -1
- package/lib/node/cartes.js +2 -1
- package/lib/node/node.js +34 -2
- package/lib/node/validators.js +15498 -11724
- package/package.json +3 -3
- package/typings/naming/index.d.ts +1 -1
- package/typings/naming/index.d.ts.map +1 -1
- package/typings/naming/naming.d.ts +12 -0
- package/typings/naming/naming.d.ts.map +1 -1
- package/typings/node/cartes.d.ts +2 -2
- package/typings/node/cartes.d.ts.map +1 -1
- package/typings/node/node.d.ts +19 -1
- package/typings/node/node.d.ts.map +1 -1
- package/typings/node/types.d.ts +124 -6
- package/typings/node/types.d.ts.map +1 -1
- package/typings/node/validators.d.ts.map +1 -1
package/lib/naming/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateNamingSchema = exports.shorten = exports.resolve = exports.expand = exports.parseNodeName = exports.DEV_NAMING_SERVER = exports.MAIN_NAMING_SERVER = exports.MoeraNamingConnectionError = exports.MoeraNamingApiError = exports.MoeraNamingError = exports.MoeraNaming = void 0;
|
|
3
|
+
exports.validateNamingSchema = exports.shorten = exports.resolve = exports.expand = exports.parseNodeName = exports.ANONYMOUS_NODE_PRIVATE_KEY = exports.ANONYMOUS_NODE_PUBLIC_KEY = exports.ANONYMOUS_NODE_NAME = exports.DEV_NAMING_SERVER = exports.MAIN_NAMING_SERVER = exports.MoeraNamingConnectionError = exports.MoeraNamingApiError = exports.MoeraNamingError = exports.MoeraNaming = void 0;
|
|
4
4
|
var naming_1 = require("./naming");
|
|
5
5
|
Object.defineProperty(exports, "MoeraNaming", { enumerable: true, get: function () { return naming_1.MoeraNaming; } });
|
|
6
6
|
Object.defineProperty(exports, "MoeraNamingError", { enumerable: true, get: function () { return naming_1.MoeraNamingError; } });
|
|
@@ -8,6 +8,9 @@ Object.defineProperty(exports, "MoeraNamingApiError", { enumerable: true, get: f
|
|
|
8
8
|
Object.defineProperty(exports, "MoeraNamingConnectionError", { enumerable: true, get: function () { return naming_1.MoeraNamingConnectionError; } });
|
|
9
9
|
Object.defineProperty(exports, "MAIN_NAMING_SERVER", { enumerable: true, get: function () { return naming_1.MAIN_NAMING_SERVER; } });
|
|
10
10
|
Object.defineProperty(exports, "DEV_NAMING_SERVER", { enumerable: true, get: function () { return naming_1.DEV_NAMING_SERVER; } });
|
|
11
|
+
Object.defineProperty(exports, "ANONYMOUS_NODE_NAME", { enumerable: true, get: function () { return naming_1.ANONYMOUS_NODE_NAME; } });
|
|
12
|
+
Object.defineProperty(exports, "ANONYMOUS_NODE_PUBLIC_KEY", { enumerable: true, get: function () { return naming_1.ANONYMOUS_NODE_PUBLIC_KEY; } });
|
|
13
|
+
Object.defineProperty(exports, "ANONYMOUS_NODE_PRIVATE_KEY", { enumerable: true, get: function () { return naming_1.ANONYMOUS_NODE_PRIVATE_KEY; } });
|
|
11
14
|
Object.defineProperty(exports, "parseNodeName", { enumerable: true, get: function () { return naming_1.parseNodeName; } });
|
|
12
15
|
Object.defineProperty(exports, "expand", { enumerable: true, get: function () { return naming_1.expand; } });
|
|
13
16
|
Object.defineProperty(exports, "resolve", { enumerable: true, get: function () { return naming_1.resolve; } });
|
package/lib/naming/naming.js
CHANGED
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.MoeraNaming = exports.MoeraNamingConnectionError = exports.MoeraNamingApiError = exports.MoeraNamingError = exports.DEV_NAMING_SERVER = exports.MAIN_NAMING_SERVER = void 0;
|
|
12
|
+
exports.MoeraNaming = exports.MoeraNamingConnectionError = exports.MoeraNamingApiError = exports.MoeraNamingError = exports.ANONYMOUS_NODE_PRIVATE_KEY = exports.ANONYMOUS_NODE_PUBLIC_KEY = exports.ANONYMOUS_NODE_NAME = exports.DEV_NAMING_SERVER = exports.MAIN_NAMING_SERVER = void 0;
|
|
13
13
|
exports.parseNodeName = parseNodeName;
|
|
14
14
|
exports.shorten = shorten;
|
|
15
15
|
exports.expand = expand;
|
|
@@ -25,6 +25,18 @@ exports.MAIN_NAMING_SERVER = "https://naming.moera.org/moera-naming";
|
|
|
25
25
|
* Moera developers' naming server.
|
|
26
26
|
*/
|
|
27
27
|
exports.DEV_NAMING_SERVER = "https://naming-dev.moera.org/moera-naming";
|
|
28
|
+
/**
|
|
29
|
+
* Node name used to represent anonymous content author.
|
|
30
|
+
*/
|
|
31
|
+
exports.ANONYMOUS_NODE_NAME = "unk_0";
|
|
32
|
+
/**
|
|
33
|
+
* Public key used to verify signatures of anonymous content.
|
|
34
|
+
*/
|
|
35
|
+
exports.ANONYMOUS_NODE_PUBLIC_KEY = Buffer.from("VNKYmrV8b1XR7phWvrTUbkfnxsPTKvHIcvJLGrBZQr0Z8eKVdTooBkIWS0CECPjLxPGaQkcKkMcZ6M6wEsJm9A==", "base64");
|
|
36
|
+
/**
|
|
37
|
+
* Private key used to sign anonymous content.
|
|
38
|
+
*/
|
|
39
|
+
exports.ANONYMOUS_NODE_PRIVATE_KEY = Buffer.from("tCb+02pUSC6FLdQLPvrUhSBjD0xiV5Q+fQmZY3PKybo=", "base64");
|
|
28
40
|
/**
|
|
29
41
|
* Generic naming server error.
|
|
30
42
|
*/
|
package/lib/node/cartes.js
CHANGED
|
@@ -116,8 +116,9 @@ function generateCarte(ownerName_1, signingKey_1, beginning_1) {
|
|
|
116
116
|
if (Array.isArray(adminScope)) {
|
|
117
117
|
adminScope = toScopeMask(adminScope);
|
|
118
118
|
}
|
|
119
|
+
const addresses = address == null ? null : Array.isArray(address) ? address : [address];
|
|
119
120
|
const salt = yield (0, util_1.promisify)(crypto_1.default.randomBytes)(8);
|
|
120
|
-
const fingerprint = (0, fingerprints_1.
|
|
121
|
+
const fingerprint = (0, fingerprints_1.createCarteFingerprint3)(ownerName, addresses, beginning, beginning + ttl, nodeName, clientScope, adminScope, salt);
|
|
121
122
|
const signature = (0, crypto_2.signFingerprint)(fingerprint, signingKey);
|
|
122
123
|
return Buffer.concat([fingerprint, signature]).toString("base64url");
|
|
123
124
|
});
|
package/lib/node/node.js
CHANGED
|
@@ -1398,12 +1398,14 @@ class MoeraNode extends caller_1.Caller {
|
|
|
1398
1398
|
* the smallest in size, but the best in quality variant of the media, according to the width provided
|
|
1399
1399
|
* @param {boolean | null} download - if ``true``, the node will add ``Content-Disposition: attachment`` header to
|
|
1400
1400
|
* the output
|
|
1401
|
+
* @param {boolean | null} ignoremalware - if ``true``, the node will ignore malware detection and return the media
|
|
1402
|
+
* file; only admin may use this option
|
|
1401
1403
|
* @return {Promise<Blob>}
|
|
1402
1404
|
*/
|
|
1403
1405
|
getPrivateMedia(id_1) {
|
|
1404
|
-
return __awaiter(this, arguments, void 0, function* (id, width = null, download = null) {
|
|
1406
|
+
return __awaiter(this, arguments, void 0, function* (id, width = null, download = null, ignoremalware = null) {
|
|
1405
1407
|
const location = (0, util_1.ut) `/media/private/${id}/data`;
|
|
1406
|
-
const params = { width, download };
|
|
1408
|
+
const params = { width, download, ignoremalware };
|
|
1407
1409
|
return yield this.call("getPrivateMedia", location, {
|
|
1408
1410
|
method: "GET", params, schema: "blob"
|
|
1409
1411
|
});
|
|
@@ -1423,6 +1425,21 @@ class MoeraNode extends caller_1.Caller {
|
|
|
1423
1425
|
});
|
|
1424
1426
|
});
|
|
1425
1427
|
}
|
|
1428
|
+
/**
|
|
1429
|
+
* Update media file details.
|
|
1430
|
+
*
|
|
1431
|
+
* @param {string} id - media file ID
|
|
1432
|
+
* @param {API.PrivateMediaFileAttributes} attributes
|
|
1433
|
+
* @return {Promise<API.PrivateMediaFileInfo>}
|
|
1434
|
+
*/
|
|
1435
|
+
updatePrivateMediaInfo(id, attributes) {
|
|
1436
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1437
|
+
const location = (0, util_1.ut) `/media/private/${id}/info`;
|
|
1438
|
+
return yield this.call("updatePrivateMediaInfo", location, {
|
|
1439
|
+
method: "PUT", body: attributes, schema: "PrivateMediaFileInfo"
|
|
1440
|
+
});
|
|
1441
|
+
});
|
|
1442
|
+
}
|
|
1426
1443
|
/**
|
|
1427
1444
|
* Get the list of all postings and comments the media file is attached to.
|
|
1428
1445
|
*
|
|
@@ -2355,6 +2372,21 @@ class MoeraNode extends caller_1.Caller {
|
|
|
2355
2372
|
});
|
|
2356
2373
|
});
|
|
2357
2374
|
}
|
|
2375
|
+
/**
|
|
2376
|
+
* Download the private media file from the remote node and store it at the home node.
|
|
2377
|
+
*
|
|
2378
|
+
* @param {string} remoteNodeName - name of the remote node
|
|
2379
|
+
* @param {string} id - id of the media file
|
|
2380
|
+
* @return {Promise<API.PrivateMediaFileInfo>}
|
|
2381
|
+
*/
|
|
2382
|
+
downloadRemoteMedia(remoteNodeName, id) {
|
|
2383
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2384
|
+
const location = (0, util_1.ut) `/nodes/${remoteNodeName}/media/private/${id}/download`;
|
|
2385
|
+
return yield this.call("downloadRemoteMedia", location, {
|
|
2386
|
+
method: "POST", schema: "PrivateMediaFileInfo"
|
|
2387
|
+
});
|
|
2388
|
+
});
|
|
2389
|
+
}
|
|
2358
2390
|
/**
|
|
2359
2391
|
* Add a posting to the remote node and register it in the registry at the local node.
|
|
2360
2392
|
*
|