cryptpad-server 0.0.2 → 0.0.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/build/core.js +17 -18
- package/build/core.worker.js +7 -0
- package/build/eviction.js +7736 -0
- package/build/front.js +17 -9
- package/build/http.js +16 -5
- package/build/http.worker.js +46 -11
- package/build/storage.cluster.js +34 -9
- package/build/storage.js +61 -16
- package/build/storage.worker.js +89 -10
- package/index.js +35 -38
- package/package.json +8 -4
- package/readme.md +1 -5
- package/build/websocket.js +0 -35556
- package/build/ws.worker.js +0 -46222
package/build/front.js
CHANGED
|
@@ -22,8 +22,6 @@ var require$$1$2 = require("express");
|
|
|
22
22
|
|
|
23
23
|
var require$$4$1 = require("cookie-parser");
|
|
24
24
|
|
|
25
|
-
var require$$5 = require("body-parser");
|
|
26
|
-
|
|
27
25
|
var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
|
|
28
26
|
|
|
29
27
|
var commonUtil$2 = {
|
|
@@ -1360,6 +1358,9 @@ function requireWsConnector() {
|
|
|
1360
1358
|
cb(void 0, ctx.self);
|
|
1361
1359
|
};
|
|
1362
1360
|
const port = config.wsPort || config.port;
|
|
1361
|
+
httpServer.on("error", e => {
|
|
1362
|
+
cb(e);
|
|
1363
|
+
});
|
|
1363
1364
|
httpServer.listen(port, config.host, onServerReady);
|
|
1364
1365
|
},
|
|
1365
1366
|
initClient: (ctx, config, id, onConnected, cb) => {
|
|
@@ -1570,7 +1571,6 @@ function requireCore() {
|
|
|
1570
1571
|
const Util = requireCommonUtil$1();
|
|
1571
1572
|
const Constants = requireConstants();
|
|
1572
1573
|
const escapeKeyCharacters = Util.escapeKeyCharacters;
|
|
1573
|
-
__require();
|
|
1574
1574
|
const Crypto = __require$3();
|
|
1575
1575
|
const Keys = requireKeys();
|
|
1576
1576
|
Core.DEFAULT_LIMIT = 50 * 1024 * 1024;
|
|
@@ -1690,8 +1690,7 @@ function requireCore() {
|
|
|
1690
1690
|
cb();
|
|
1691
1691
|
};
|
|
1692
1692
|
Core.getPaths = (mainConfig, isEnv) => {
|
|
1693
|
-
const {
|
|
1694
|
-
Constants.paths;
|
|
1693
|
+
const {config} = mainConfig;
|
|
1695
1694
|
const all = {
|
|
1696
1695
|
basePath: config.basePath || config.base || "./data",
|
|
1697
1696
|
filePath: config.filePath || "./datastore",
|
|
@@ -2776,6 +2775,14 @@ function requireFile() {
|
|
|
2776
2775
|
writeLinkedFile(env, path, content, cb);
|
|
2777
2776
|
});
|
|
2778
2777
|
};
|
|
2778
|
+
const hasLinkedDocuments = (env, channelId) => {
|
|
2779
|
+
const path = mkLinkedPath(env, channelId);
|
|
2780
|
+
try {
|
|
2781
|
+
return Fs.existsSync(path);
|
|
2782
|
+
} catch (e) {
|
|
2783
|
+
return false;
|
|
2784
|
+
}
|
|
2785
|
+
};
|
|
2779
2786
|
const getLinkedDocuments = (env, channelId, cb) => {
|
|
2780
2787
|
const path = mkLinkedPath(env, channelId);
|
|
2781
2788
|
readLinkedFile(env, path, cb);
|
|
@@ -3848,6 +3855,7 @@ function requireFile() {
|
|
|
3848
3855
|
writeMetadata(env, channelName, data, Util.both(cb, next));
|
|
3849
3856
|
});
|
|
3850
3857
|
},
|
|
3858
|
+
hasLinkedDocuments: channelId => hasLinkedDocuments(env, channelId),
|
|
3851
3859
|
getLinkedDocuments: (channelId, cb) => {
|
|
3852
3860
|
if (!isValidChannelId(channelId)) {
|
|
3853
3861
|
return cb(new Error("EINVAL"));
|
|
@@ -4053,7 +4061,7 @@ function requireLogger() {
|
|
|
4053
4061
|
return logger;
|
|
4054
4062
|
}
|
|
4055
4063
|
|
|
4056
|
-
var version = "0.0.
|
|
4064
|
+
var version = "0.0.4";
|
|
4057
4065
|
|
|
4058
4066
|
var require$$2 = {
|
|
4059
4067
|
version
|
|
@@ -5010,7 +5018,6 @@ function requireNetwork() {
|
|
|
5010
5018
|
const {setHeaders} = requireHeaders();
|
|
5011
5019
|
const Crypto = require("crypto");
|
|
5012
5020
|
const cookieParser = require$$4$1;
|
|
5013
|
-
const bodyParser = require$$5;
|
|
5014
5021
|
const Network = {};
|
|
5015
5022
|
const app = Express();
|
|
5016
5023
|
const events = {
|
|
@@ -5028,7 +5035,7 @@ function requireNetwork() {
|
|
|
5028
5035
|
}
|
|
5029
5036
|
next();
|
|
5030
5037
|
});
|
|
5031
|
-
app.use(
|
|
5038
|
+
app.use(Express.urlencoded({
|
|
5032
5039
|
extended: true
|
|
5033
5040
|
}));
|
|
5034
5041
|
app.use(cookieParser());
|
|
@@ -5800,7 +5807,8 @@ function requireFront() {
|
|
|
5800
5807
|
process.send({
|
|
5801
5808
|
type: "front",
|
|
5802
5809
|
index,
|
|
5803
|
-
msg: "READY"
|
|
5810
|
+
msg: "READY",
|
|
5811
|
+
pid: process.pid
|
|
5804
5812
|
});
|
|
5805
5813
|
} else {
|
|
5806
5814
|
Env.Log.info("SINGLE_FRONT_STARTED", Env.myId);
|
package/build/http.js
CHANGED
|
@@ -996,7 +996,6 @@ function requireCore() {
|
|
|
996
996
|
const Util = requireCommonUtil$1();
|
|
997
997
|
const Constants = requireConstants();
|
|
998
998
|
const escapeKeyCharacters = Util.escapeKeyCharacters;
|
|
999
|
-
__require$5();
|
|
1000
999
|
const Crypto = __require$4();
|
|
1001
1000
|
const Keys = requireKeys();
|
|
1002
1001
|
Core.DEFAULT_LIMIT = 50 * 1024 * 1024;
|
|
@@ -1116,8 +1115,7 @@ function requireCore() {
|
|
|
1116
1115
|
cb();
|
|
1117
1116
|
};
|
|
1118
1117
|
Core.getPaths = (mainConfig, isEnv) => {
|
|
1119
|
-
const {
|
|
1120
|
-
Constants.paths;
|
|
1118
|
+
const {config} = mainConfig;
|
|
1121
1119
|
const all = {
|
|
1122
1120
|
basePath: config.basePath || config.base || "./data",
|
|
1123
1121
|
filePath: config.filePath || "./datastore",
|
|
@@ -2202,6 +2200,14 @@ function requireFile() {
|
|
|
2202
2200
|
writeLinkedFile(env, path, content, cb);
|
|
2203
2201
|
});
|
|
2204
2202
|
};
|
|
2203
|
+
const hasLinkedDocuments = (env, channelId) => {
|
|
2204
|
+
const path = mkLinkedPath(env, channelId);
|
|
2205
|
+
try {
|
|
2206
|
+
return Fs.existsSync(path);
|
|
2207
|
+
} catch (e) {
|
|
2208
|
+
return false;
|
|
2209
|
+
}
|
|
2210
|
+
};
|
|
2205
2211
|
const getLinkedDocuments = (env, channelId, cb) => {
|
|
2206
2212
|
const path = mkLinkedPath(env, channelId);
|
|
2207
2213
|
readLinkedFile(env, path, cb);
|
|
@@ -3274,6 +3280,7 @@ function requireFile() {
|
|
|
3274
3280
|
writeMetadata(env, channelName, data, Util.both(cb, next));
|
|
3275
3281
|
});
|
|
3276
3282
|
},
|
|
3283
|
+
hasLinkedDocuments: channelId => hasLinkedDocuments(env, channelId),
|
|
3277
3284
|
getLinkedDocuments: (channelId, cb) => {
|
|
3278
3285
|
if (!isValidChannelId(channelId)) {
|
|
3279
3286
|
return cb(new Error("EINVAL"));
|
|
@@ -3479,7 +3486,7 @@ function requireLogger() {
|
|
|
3479
3486
|
return logger;
|
|
3480
3487
|
}
|
|
3481
3488
|
|
|
3482
|
-
var version = "0.0.
|
|
3489
|
+
var version = "0.0.4";
|
|
3483
3490
|
|
|
3484
3491
|
var require$$2 = {
|
|
3485
3492
|
version
|
|
@@ -5174,6 +5181,9 @@ function requireWsConnector() {
|
|
|
5174
5181
|
cb(void 0, ctx.self);
|
|
5175
5182
|
};
|
|
5176
5183
|
const port = config.wsPort || config.port;
|
|
5184
|
+
httpServer.on("error", e => {
|
|
5185
|
+
cb(e);
|
|
5186
|
+
});
|
|
5177
5187
|
httpServer.listen(port, config.host, onServerReady);
|
|
5178
5188
|
},
|
|
5179
5189
|
initClient: (ctx, config, id, onConnected, cb) => {
|
|
@@ -5315,7 +5325,8 @@ function requireHttpServer() {
|
|
|
5315
5325
|
type: "http",
|
|
5316
5326
|
index: 0,
|
|
5317
5327
|
dev: Env.DEV_MODE,
|
|
5318
|
-
msg: "READY"
|
|
5328
|
+
msg: "READY",
|
|
5329
|
+
pid: process.pid
|
|
5319
5330
|
});
|
|
5320
5331
|
});
|
|
5321
5332
|
};
|
package/build/http.worker.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var require$$0$2 = require("express");
|
|
4
4
|
|
|
5
|
+
var require$$1$2 = require("mime-types");
|
|
6
|
+
|
|
5
7
|
var node_module = require("node:module");
|
|
6
8
|
|
|
7
9
|
var require$$1$1 = require("fs-extra");
|
|
@@ -16,9 +18,9 @@ var require$$0$1 = require("stream-to-pull-stream");
|
|
|
16
18
|
|
|
17
19
|
var require$$1 = require("pull-stream");
|
|
18
20
|
|
|
19
|
-
var require$$
|
|
21
|
+
var require$$6 = require("http-proxy-middleware");
|
|
20
22
|
|
|
21
|
-
var require$$
|
|
23
|
+
var require$$8 = require("connect-gzip-static");
|
|
22
24
|
|
|
23
25
|
var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
|
|
24
26
|
|
|
@@ -1004,7 +1006,6 @@ function requireCore() {
|
|
|
1004
1006
|
const Util = requireCommonUtil$1();
|
|
1005
1007
|
const Constants = requireConstants();
|
|
1006
1008
|
const escapeKeyCharacters = Util.escapeKeyCharacters;
|
|
1007
|
-
__require$2();
|
|
1008
1009
|
const Crypto = __require();
|
|
1009
1010
|
const Keys = requireKeys();
|
|
1010
1011
|
Core.DEFAULT_LIMIT = 50 * 1024 * 1024;
|
|
@@ -1124,8 +1125,7 @@ function requireCore() {
|
|
|
1124
1125
|
cb();
|
|
1125
1126
|
};
|
|
1126
1127
|
Core.getPaths = (mainConfig, isEnv) => {
|
|
1127
|
-
const {
|
|
1128
|
-
Constants.paths;
|
|
1128
|
+
const {config} = mainConfig;
|
|
1129
1129
|
const all = {
|
|
1130
1130
|
basePath: config.basePath || config.base || "./data",
|
|
1131
1131
|
filePath: config.filePath || "./datastore",
|
|
@@ -2210,6 +2210,14 @@ function requireFile() {
|
|
|
2210
2210
|
writeLinkedFile(env, path, content, cb);
|
|
2211
2211
|
});
|
|
2212
2212
|
};
|
|
2213
|
+
const hasLinkedDocuments = (env, channelId) => {
|
|
2214
|
+
const path = mkLinkedPath(env, channelId);
|
|
2215
|
+
try {
|
|
2216
|
+
return Fs.existsSync(path);
|
|
2217
|
+
} catch (e) {
|
|
2218
|
+
return false;
|
|
2219
|
+
}
|
|
2220
|
+
};
|
|
2213
2221
|
const getLinkedDocuments = (env, channelId, cb) => {
|
|
2214
2222
|
const path = mkLinkedPath(env, channelId);
|
|
2215
2223
|
readLinkedFile(env, path, cb);
|
|
@@ -3282,6 +3290,7 @@ function requireFile() {
|
|
|
3282
3290
|
writeMetadata(env, channelName, data, Util.both(cb, next));
|
|
3283
3291
|
});
|
|
3284
3292
|
},
|
|
3293
|
+
hasLinkedDocuments: channelId => hasLinkedDocuments(env, channelId),
|
|
3285
3294
|
getLinkedDocuments: (channelId, cb) => {
|
|
3286
3295
|
if (!isValidChannelId(channelId)) {
|
|
3287
3296
|
return cb(new Error("EINVAL"));
|
|
@@ -3529,7 +3538,7 @@ function requireDefaults() {
|
|
|
3529
3538
|
return defaults.exports;
|
|
3530
3539
|
}
|
|
3531
3540
|
|
|
3532
|
-
var version = "0.0.
|
|
3541
|
+
var version = "0.0.4";
|
|
3533
3542
|
|
|
3534
3543
|
var require$$2 = {
|
|
3535
3544
|
version
|
|
@@ -4330,14 +4339,16 @@ function requireWorker() {
|
|
|
4330
4339
|
if (hasRequiredWorker) return worker$1;
|
|
4331
4340
|
hasRequiredWorker = 1;
|
|
4332
4341
|
const Express = require$$0$2;
|
|
4342
|
+
const Mime = require$$1$2;
|
|
4333
4343
|
const Http = require("node:http");
|
|
4344
|
+
const Https = require("node:https");
|
|
4334
4345
|
const Path = __require$2();
|
|
4335
4346
|
const Fs = __require$1();
|
|
4336
4347
|
const Logger = requireLogger();
|
|
4337
4348
|
const Util = requireCommonUtil$1();
|
|
4338
|
-
const {createProxyMiddleware} = require$$
|
|
4349
|
+
const {createProxyMiddleware} = require$$6;
|
|
4339
4350
|
const Default = requireDefaults();
|
|
4340
|
-
const gzipStatic = require$$
|
|
4351
|
+
const gzipStatic = require$$8;
|
|
4341
4352
|
const Environment = requireEnv();
|
|
4342
4353
|
const {setHeaders} = requireHeaders();
|
|
4343
4354
|
const COMMANDS = {};
|
|
@@ -4350,9 +4361,7 @@ function requireWorker() {
|
|
|
4350
4361
|
warn: () => {},
|
|
4351
4362
|
info: () => {}
|
|
4352
4363
|
};
|
|
4353
|
-
|
|
4354
|
-
"application/wasm": [ "wasm" ]
|
|
4355
|
-
});
|
|
4364
|
+
Mime.lookup("wasm");
|
|
4356
4365
|
const initFeedback = (Env, app) => {
|
|
4357
4366
|
if (!Env.logFeedback) {
|
|
4358
4367
|
return;
|
|
@@ -4422,6 +4431,28 @@ function requireWorker() {
|
|
|
4422
4431
|
app.use("/cryptpad_websocket", wsProxy);
|
|
4423
4432
|
app.use("/extensions.js", httpProxy);
|
|
4424
4433
|
app.use("/api", httpProxy);
|
|
4434
|
+
const checkAllStores = (req, res) => {
|
|
4435
|
+
setHeaders(Env, req, res);
|
|
4436
|
+
const promiseResponses = storageList.map(baseUrl => new Promise((res, rej) => {
|
|
4437
|
+
const protocol = new URL(baseUrl).protocol;
|
|
4438
|
+
if (![ "http:", "https:" ].includes(protocol)) {
|
|
4439
|
+
return rej();
|
|
4440
|
+
}
|
|
4441
|
+
const H = protocol === "http:" ? Http : Https;
|
|
4442
|
+
H.get(new URL(req.url, baseUrl), {
|
|
4443
|
+
method: "HEAD"
|
|
4444
|
+
}, resp => {
|
|
4445
|
+
const {statusCode} = resp;
|
|
4446
|
+
if (statusCode !== 200) {
|
|
4447
|
+
return rej();
|
|
4448
|
+
}
|
|
4449
|
+
res();
|
|
4450
|
+
});
|
|
4451
|
+
}));
|
|
4452
|
+
Promise.all(promiseResponses).then(() => res.status(200).send("PLACEHOLDER")).catch(() => res.status(404).end());
|
|
4453
|
+
};
|
|
4454
|
+
app.get("/blob/placeholder.txt", checkAllStores);
|
|
4455
|
+
app.get("/block/placeholder.txt", checkAllStores);
|
|
4425
4456
|
const storeProxy = createProxyMiddleware({
|
|
4426
4457
|
router: req => {
|
|
4427
4458
|
const split = req.url.split("/");
|
|
@@ -4589,6 +4620,10 @@ function requireWorker() {
|
|
|
4589
4620
|
txid: obj.txid,
|
|
4590
4621
|
pid: obj.pid,
|
|
4591
4622
|
value
|
|
4623
|
+
}, e => {
|
|
4624
|
+
if (e) {
|
|
4625
|
+
console.error("E_RESPONSE", Util.serializeError(e));
|
|
4626
|
+
}
|
|
4592
4627
|
});
|
|
4593
4628
|
};
|
|
4594
4629
|
if (!ready) {
|
package/build/storage.cluster.js
CHANGED
|
@@ -18,8 +18,6 @@ var require$$1$1 = require("pull-stream");
|
|
|
18
18
|
|
|
19
19
|
var require$$0$2 = require("tweetnacl/nacl-fast");
|
|
20
20
|
|
|
21
|
-
var require$$11 = require("body-parser");
|
|
22
|
-
|
|
23
21
|
var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
|
|
24
22
|
|
|
25
23
|
function getDefaultExportFromCjs(x) {
|
|
@@ -981,7 +979,6 @@ function requireCore() {
|
|
|
981
979
|
const Util = requireCommonUtil$1();
|
|
982
980
|
const Constants = requireConstants();
|
|
983
981
|
const escapeKeyCharacters = Util.escapeKeyCharacters;
|
|
984
|
-
__require$2();
|
|
985
982
|
const Crypto = __require$1();
|
|
986
983
|
const Keys = requireKeys();
|
|
987
984
|
Core.DEFAULT_LIMIT = 50 * 1024 * 1024;
|
|
@@ -1101,8 +1098,7 @@ function requireCore() {
|
|
|
1101
1098
|
cb();
|
|
1102
1099
|
};
|
|
1103
1100
|
Core.getPaths = (mainConfig, isEnv) => {
|
|
1104
|
-
const {
|
|
1105
|
-
Constants.paths;
|
|
1101
|
+
const {config} = mainConfig;
|
|
1106
1102
|
const all = {
|
|
1107
1103
|
basePath: config.basePath || config.base || "./data",
|
|
1108
1104
|
filePath: config.filePath || "./datastore",
|
|
@@ -1425,6 +1421,27 @@ function requireBlock$1() {
|
|
|
1425
1421
|
}, cb);
|
|
1426
1422
|
});
|
|
1427
1423
|
};
|
|
1424
|
+
Block.rootPlaceholderCreate = (Env, _cb) => {
|
|
1425
|
+
const cb = Util.once(Util.mkAsync(_cb));
|
|
1426
|
+
nThen(w => {
|
|
1427
|
+
Fse.mkdirp(Env.paths.block, w(err => {
|
|
1428
|
+
if (err) {
|
|
1429
|
+
Env.Log.error("BLOCK_FOLDER_CREATE_FAILED", err);
|
|
1430
|
+
w.abort();
|
|
1431
|
+
return cb(err);
|
|
1432
|
+
}
|
|
1433
|
+
}));
|
|
1434
|
+
}).nThen(w => {
|
|
1435
|
+
const fullPath = Path.join(Env.paths.block, "placeholder.txt");
|
|
1436
|
+
Fs.writeFile(fullPath, "PLACEHOLDER\n", w(err => {
|
|
1437
|
+
if (err) {
|
|
1438
|
+
Env.Log.error("BLOCK_PLACEHOLDER_CREATE_FAILED", err);
|
|
1439
|
+
w.abort();
|
|
1440
|
+
return cb(err);
|
|
1441
|
+
}
|
|
1442
|
+
}));
|
|
1443
|
+
}).nThen(() => cb());
|
|
1444
|
+
};
|
|
1428
1445
|
})(block$1);
|
|
1429
1446
|
return block$1.exports;
|
|
1430
1447
|
}
|
|
@@ -2862,7 +2879,7 @@ function requireMfa() {
|
|
|
2862
2879
|
return mfa.exports;
|
|
2863
2880
|
}
|
|
2864
2881
|
|
|
2865
|
-
var version = "0.0.
|
|
2882
|
+
var version = "0.0.4";
|
|
2866
2883
|
|
|
2867
2884
|
var require$$2 = {
|
|
2868
2885
|
version
|
|
@@ -4456,6 +4473,14 @@ function requireFile() {
|
|
|
4456
4473
|
writeLinkedFile(env, path, content, cb);
|
|
4457
4474
|
});
|
|
4458
4475
|
};
|
|
4476
|
+
const hasLinkedDocuments = (env, channelId) => {
|
|
4477
|
+
const path = mkLinkedPath(env, channelId);
|
|
4478
|
+
try {
|
|
4479
|
+
return Fs.existsSync(path);
|
|
4480
|
+
} catch (e) {
|
|
4481
|
+
return false;
|
|
4482
|
+
}
|
|
4483
|
+
};
|
|
4459
4484
|
const getLinkedDocuments = (env, channelId, cb) => {
|
|
4460
4485
|
const path = mkLinkedPath(env, channelId);
|
|
4461
4486
|
readLinkedFile(env, path, cb);
|
|
@@ -5528,6 +5553,7 @@ function requireFile() {
|
|
|
5528
5553
|
writeMetadata(env, channelName, data, Util.both(cb, next));
|
|
5529
5554
|
});
|
|
5530
5555
|
},
|
|
5556
|
+
hasLinkedDocuments: channelId => hasLinkedDocuments(env, channelId),
|
|
5531
5557
|
getLinkedDocuments: (channelId, cb) => {
|
|
5532
5558
|
if (!isValidChannelId(channelId)) {
|
|
5533
5559
|
return cb(new Error("EINVAL"));
|
|
@@ -7982,7 +8008,6 @@ function requireCluster() {
|
|
|
7982
8008
|
const Util = requireCommonUtil$1();
|
|
7983
8009
|
const MFA = requireMfa();
|
|
7984
8010
|
const Sessions = requireSessions();
|
|
7985
|
-
const bodyParser = require$$11;
|
|
7986
8011
|
const Fs = __require();
|
|
7987
8012
|
const Environment = requireEnv();
|
|
7988
8013
|
const Logger = requireLogger();
|
|
@@ -8017,7 +8042,7 @@ function requireCluster() {
|
|
|
8017
8042
|
Env.Log.error("WORKER__" + errLabel, info);
|
|
8018
8043
|
});
|
|
8019
8044
|
const initServerHandlers = (Env, app) => {
|
|
8020
|
-
app.use(
|
|
8045
|
+
app.use(Express.urlencoded({
|
|
8021
8046
|
extended: true
|
|
8022
8047
|
}));
|
|
8023
8048
|
app.use("/blob", function(req, res, next) {
|
|
@@ -8244,7 +8269,7 @@ function requireCluster() {
|
|
|
8244
8269
|
res.statusCode = 204;
|
|
8245
8270
|
return void res.end();
|
|
8246
8271
|
}
|
|
8247
|
-
const {chunk, sig, edPublic} = req.body;
|
|
8272
|
+
const {chunk, sig, edPublic} = req.body || {};
|
|
8248
8273
|
const forbidden = reason => void res.status(403).send({
|
|
8249
8274
|
error: reason
|
|
8250
8275
|
});
|
package/build/storage.js
CHANGED
|
@@ -998,7 +998,6 @@ function requireCore() {
|
|
|
998
998
|
const Util = requireCommonUtil$1();
|
|
999
999
|
const Constants = requireConstants();
|
|
1000
1000
|
const escapeKeyCharacters = Util.escapeKeyCharacters;
|
|
1001
|
-
__require$5();
|
|
1002
1001
|
const Crypto = __require$6();
|
|
1003
1002
|
const Keys = requireKeys();
|
|
1004
1003
|
Core.DEFAULT_LIMIT = 50 * 1024 * 1024;
|
|
@@ -1118,8 +1117,7 @@ function requireCore() {
|
|
|
1118
1117
|
cb();
|
|
1119
1118
|
};
|
|
1120
1119
|
Core.getPaths = (mainConfig, isEnv) => {
|
|
1121
|
-
const {
|
|
1122
|
-
Constants.paths;
|
|
1120
|
+
const {config} = mainConfig;
|
|
1123
1121
|
const all = {
|
|
1124
1122
|
basePath: config.basePath || config.base || "./data",
|
|
1125
1123
|
filePath: config.filePath || "./datastore",
|
|
@@ -2204,6 +2202,14 @@ function requireFile() {
|
|
|
2204
2202
|
writeLinkedFile(env, path, content, cb);
|
|
2205
2203
|
});
|
|
2206
2204
|
};
|
|
2205
|
+
const hasLinkedDocuments = (env, channelId) => {
|
|
2206
|
+
const path = mkLinkedPath(env, channelId);
|
|
2207
|
+
try {
|
|
2208
|
+
return Fs.existsSync(path);
|
|
2209
|
+
} catch (e) {
|
|
2210
|
+
return false;
|
|
2211
|
+
}
|
|
2212
|
+
};
|
|
2207
2213
|
const getLinkedDocuments = (env, channelId, cb) => {
|
|
2208
2214
|
const path = mkLinkedPath(env, channelId);
|
|
2209
2215
|
readLinkedFile(env, path, cb);
|
|
@@ -3276,6 +3282,7 @@ function requireFile() {
|
|
|
3276
3282
|
writeMetadata(env, channelName, data, Util.both(cb, next));
|
|
3277
3283
|
});
|
|
3278
3284
|
},
|
|
3285
|
+
hasLinkedDocuments: channelId => hasLinkedDocuments(env, channelId),
|
|
3279
3286
|
getLinkedDocuments: (channelId, cb) => {
|
|
3280
3287
|
if (!isValidChannelId(channelId)) {
|
|
3281
3288
|
return cb(new Error("EINVAL"));
|
|
@@ -5027,10 +5034,17 @@ function requireChannelManager() {
|
|
|
5027
5034
|
}
|
|
5028
5035
|
}));
|
|
5029
5036
|
}).nThen(function(w) {
|
|
5037
|
+
if (!store.hasLinkedDocuments(channel)) {
|
|
5038
|
+
return;
|
|
5039
|
+
}
|
|
5030
5040
|
Linked.trimHistory(Env, {
|
|
5031
5041
|
channel
|
|
5032
5042
|
}, w());
|
|
5033
5043
|
}).nThen(function() {
|
|
5044
|
+
Env.Log.info("HK_TRIM_HISTORY_START", {
|
|
5045
|
+
unsafeKey,
|
|
5046
|
+
channel
|
|
5047
|
+
});
|
|
5034
5048
|
store.trimChannel(channel, hash, err => {
|
|
5035
5049
|
Env.Log.info("HK_TRIM_HISTORY", {
|
|
5036
5050
|
unsafeKey,
|
|
@@ -5475,6 +5489,27 @@ function requireBlock$1() {
|
|
|
5475
5489
|
}, cb);
|
|
5476
5490
|
});
|
|
5477
5491
|
};
|
|
5492
|
+
Block.rootPlaceholderCreate = (Env, _cb) => {
|
|
5493
|
+
const cb = Util.once(Util.mkAsync(_cb));
|
|
5494
|
+
nThen(w => {
|
|
5495
|
+
Fse.mkdirp(Env.paths.block, w(err => {
|
|
5496
|
+
if (err) {
|
|
5497
|
+
Env.Log.error("BLOCK_FOLDER_CREATE_FAILED", err);
|
|
5498
|
+
w.abort();
|
|
5499
|
+
return cb(err);
|
|
5500
|
+
}
|
|
5501
|
+
}));
|
|
5502
|
+
}).nThen(w => {
|
|
5503
|
+
const fullPath = Path.join(Env.paths.block, "placeholder.txt");
|
|
5504
|
+
Fs.writeFile(fullPath, "PLACEHOLDER\n", w(err => {
|
|
5505
|
+
if (err) {
|
|
5506
|
+
Env.Log.error("BLOCK_PLACEHOLDER_CREATE_FAILED", err);
|
|
5507
|
+
w.abort();
|
|
5508
|
+
return cb(err);
|
|
5509
|
+
}
|
|
5510
|
+
}));
|
|
5511
|
+
}).nThen(() => cb());
|
|
5512
|
+
};
|
|
5478
5513
|
})(block$1);
|
|
5479
5514
|
return block$1.exports;
|
|
5480
5515
|
}
|
|
@@ -6676,7 +6711,7 @@ function requireMfaManager() {
|
|
|
6676
6711
|
return mfaManager;
|
|
6677
6712
|
}
|
|
6678
6713
|
|
|
6679
|
-
var version = "0.0.
|
|
6714
|
+
var version = "0.0.4";
|
|
6680
6715
|
|
|
6681
6716
|
var require$$2 = {
|
|
6682
6717
|
version
|
|
@@ -7905,6 +7940,9 @@ function requireWsConnector() {
|
|
|
7905
7940
|
cb(void 0, ctx.self);
|
|
7906
7941
|
};
|
|
7907
7942
|
const port = config.wsPort || config.port;
|
|
7943
|
+
httpServer.on("error", e => {
|
|
7944
|
+
cb(e);
|
|
7945
|
+
});
|
|
7908
7946
|
httpServer.listen(port, config.host, onServerReady);
|
|
7909
7947
|
},
|
|
7910
7948
|
initClient: (ctx, config, id, onConnected, cb) => {
|
|
@@ -10624,6 +10662,17 @@ function requireAdmin() {
|
|
|
10624
10662
|
const {key} = data;
|
|
10625
10663
|
MFA.revoke(Env, key, cb);
|
|
10626
10664
|
};
|
|
10665
|
+
const onGetCachedChannelMetadata = (Env, id, cb) => {
|
|
10666
|
+
const index = Env.metadata_cache?.[id];
|
|
10667
|
+
if (!index) {
|
|
10668
|
+
return void cb("ENOENT");
|
|
10669
|
+
}
|
|
10670
|
+
cb(void 0, index);
|
|
10671
|
+
};
|
|
10672
|
+
const onClearCachedChannelMetadata = (Env, id, cb) => {
|
|
10673
|
+
delete Env.metadata_cache[id];
|
|
10674
|
+
cb();
|
|
10675
|
+
};
|
|
10627
10676
|
const onArchiveBlock = (Env, data, cb) => {
|
|
10628
10677
|
const {key, reason} = data;
|
|
10629
10678
|
const archiveReason = {
|
|
@@ -11013,17 +11062,6 @@ function requireAdmin() {
|
|
|
11013
11062
|
}
|
|
11014
11063
|
cb(void 0, index);
|
|
11015
11064
|
};
|
|
11016
|
-
const onGetCachedChannelMetadata = (Env, id, cb) => {
|
|
11017
|
-
const index = Env.metadata_cache?.[id];
|
|
11018
|
-
if (!index) {
|
|
11019
|
-
return void cb("ENOENT");
|
|
11020
|
-
}
|
|
11021
|
-
cb(void 0, index);
|
|
11022
|
-
};
|
|
11023
|
-
const onClearCachedChannelMetadata = (Env, id, cb) => {
|
|
11024
|
-
delete Env.metadata_cache[id];
|
|
11025
|
-
cb();
|
|
11026
|
-
};
|
|
11027
11065
|
const onGetActiveChannelCount = (Env, _id, cb) => {
|
|
11028
11066
|
if (!Env.channel_cache) {
|
|
11029
11067
|
return void cb("ENOENT");
|
|
@@ -12059,6 +12097,12 @@ function requireStorage() {
|
|
|
12059
12097
|
const bearerSecret = Util.encodeBase64(Crypto.randomBytes(32));
|
|
12060
12098
|
const decree = [ "SET_BEARER_SECRET", [ bearerSecret ], "INTERNAL", +new Date ];
|
|
12061
12099
|
Decrees.onNewDecree(Env, decree, "", waitFor());
|
|
12100
|
+
}).nThen(w => {
|
|
12101
|
+
BlockStore.rootPlaceholderCreate(Env, w(err => {
|
|
12102
|
+
if (err) {
|
|
12103
|
+
console.warn(`${myId}: Impossible to create block's placeholder. Please check the value of blockPath in your config.js file and if you have write access on it.`);
|
|
12104
|
+
}
|
|
12105
|
+
}));
|
|
12062
12106
|
}).nThen(() => {
|
|
12063
12107
|
if (index !== 0) {
|
|
12064
12108
|
return;
|
|
@@ -12088,7 +12132,8 @@ function requireStorage() {
|
|
|
12088
12132
|
process.send({
|
|
12089
12133
|
type: "storage",
|
|
12090
12134
|
index,
|
|
12091
|
-
msg: "READY"
|
|
12135
|
+
msg: "READY",
|
|
12136
|
+
pid: process.pid
|
|
12092
12137
|
});
|
|
12093
12138
|
} else {
|
|
12094
12139
|
console.log(myId, "started");
|