spec-3nweb-server 1.3.8 → 1.5.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/build/3nstorage/3nstorage-app.js +4 -4
- package/build/3nstorage/owner.js +28 -28
- package/build/3nstorage/resources/store.d.ts +2 -9
- package/build/3nstorage/resources/store.js +76 -73
- package/build/3nstorage/resources/users.d.ts +4 -2
- package/build/3nstorage/resources/users.js +8 -4
- package/build/3nstorage/routes/owner/archive-obj-version.d.ts +2 -2
- package/build/3nstorage/routes/owner/archive-obj-version.js +36 -31
- package/build/3nstorage/routes/owner/cancel-trans.js +1 -1
- package/build/3nstorage/routes/owner/delete-obj.d.ts +3 -2
- package/build/3nstorage/routes/owner/delete-obj.js +42 -7
- package/build/3nstorage/routes/owner/get-archived-obj-ver.js +10 -6
- package/build/3nstorage/routes/owner/get-current-obj.js +2 -2
- package/build/3nstorage/routes/owner/list-obj-archive.js +28 -31
- package/build/3nstorage/routes/owner/param-getter.js +3 -2
- package/build/3nstorage/routes/owner/param-setter.js +3 -2
- package/build/3nstorage/routes/owner/put-current-obj.js +12 -10
- package/build/3nstorage/routes/owner/session-params.js +4 -3
- package/build/admin/admin-app.js +5 -5
- package/build/admin/resources/users.js +42 -42
- package/build/admin/routes/add.js +3 -3
- package/build/admin/signup-tokens.js +8 -8
- package/build/asmail/asmail-app.js +7 -7
- package/build/asmail/config.js +9 -8
- package/build/asmail/delivery.js +10 -9
- package/build/asmail/resources/delivery-sessions.js +4 -3
- package/build/asmail/resources/inbox.d.ts +1 -1
- package/build/asmail/resources/inbox.js +22 -22
- package/build/asmail/resources/recipients.d.ts +2 -1
- package/build/asmail/resources/recipients.js +4 -4
- package/build/asmail/resources/sessions.js +2 -1
- package/build/asmail/retrieval.js +13 -8
- package/build/asmail/routes/config/param-getter.js +3 -2
- package/build/asmail/routes/config/param-setter.js +3 -2
- package/build/asmail/routes/delivery/finalize-delivery.js +3 -2
- package/build/asmail/routes/delivery/pre-flight.js +5 -4
- package/build/asmail/routes/delivery/provide-recipient-pubkey.js +3 -2
- package/build/asmail/routes/delivery/put-metadata.js +3 -2
- package/build/asmail/routes/delivery/put-obj.js +4 -4
- package/build/asmail/routes/delivery/restart-session.js +4 -3
- package/build/asmail/routes/delivery/sender-authorization.d.ts +1 -3
- package/build/asmail/routes/delivery/sender-authorization.js +3 -2
- package/build/asmail/routes/delivery/start-session.js +5 -4
- package/build/asmail/routes/retrieval/get-message-meta.js +3 -2
- package/build/asmail/routes/retrieval/get-message-obj.js +4 -3
- package/build/asmail/routes/retrieval/list-messages.js +3 -2
- package/build/asmail/routes/retrieval/remove-message.js +3 -2
- package/build/lib-common/async-fs-node.d.ts +2 -0
- package/build/lib-common/async-fs-node.js +13 -13
- package/build/lib-common/byte-streaming/common.js +9 -9
- package/build/lib-common/canonical-address.js +1 -1
- package/build/lib-common/ipc/generic-ipc.js +12 -12
- package/build/lib-common/ipc/ws-ipc.js +2 -2
- package/build/lib-common/mid-sigs-NaCl-Ed.js +14 -14
- package/build/lib-common/objs-on-disk/file-layout.js +10 -10
- package/build/lib-common/objs-on-disk/obj-file.js +11 -11
- package/build/lib-common/objs-on-disk/utils.d.ts +1 -0
- package/build/lib-common/objs-on-disk/utils.js +3 -3
- package/build/lib-common/processes.js +1 -1
- package/build/lib-common/random-node.js +7 -7
- package/build/lib-common/service-api/3nstorage/owner.d.ts +24 -18
- package/build/lib-common/service-api/3nstorage/owner.js +31 -26
- package/build/lib-common/service-api/asmail/delivery.js +2 -2
- package/build/lib-common/service-api/asmail/retrieval.js +1 -1
- package/build/lib-server/conf-util.js +2 -1
- package/build/lib-server/middleware/body-parsers.js +16 -16
- package/build/lib-server/middleware/error-handler.js +1 -1
- package/build/lib-server/resources/mailerid-authorizer.js +3 -3
- package/build/lib-server/resources/mem-backed-sessions-factory.js +3 -3
- package/build/lib-server/resources/server-data-folders.js +23 -23
- package/build/lib-server/resources/sessions.js +5 -5
- package/build/lib-server/resources/user-files.js +8 -8
- package/build/lib-server/routes/pub-key-login/complete-exchange.js +4 -3
- package/build/lib-server/routes/pub-key-login/start-exchange.js +7 -6
- package/build/lib-server/routes/sessions/mid-auth.js +6 -5
- package/build/lib-server/routes/sessions/start.js +4 -3
- package/build/lib-server/web-sockets/app.d.ts +1 -0
- package/build/lib-server/web-sockets/app.js +6 -5
- package/build/lib-server/web-sockets/server-events.js +5 -4
- package/build/mailerId/mailerId-app.js +7 -7
- package/build/mailerId/resources/certifier.d.ts +4 -6
- package/build/mailerId/resources/certifier.js +8 -7
- package/build/mailerId/resources/compute-login-dhshared-key.js +2 -1
- package/build/mailerId/resources/sessions.js +2 -1
- package/build/mailerId/resources/users.js +4 -4
- package/build/mailerId/routes/certify.js +1 -1
- package/build/main.js +10 -10
- package/build/mock/dns.js +1 -1
- package/build/mock/mock-as-child-proc.js +10 -10
- package/build/mock/node-child-ipc.js +2 -2
- package/build/mock/run-in-proc.js +7 -7
- package/build/run-config.js +10 -10
- package/build/run.js +4 -4
- package/build/services.js +5 -5
- package/package.json +13 -10
|
@@ -78,7 +78,7 @@ class ObjVersionFile {
|
|
|
78
78
|
return this.writeProc.startOrChain(async () => {
|
|
79
79
|
const fd = await fs.open(this.path, 'r+')
|
|
80
80
|
.catch(exc => {
|
|
81
|
-
throw error_1.errWithCause(exc, `Can't open obj version file ${this.path}`);
|
|
81
|
+
throw (0, error_1.errWithCause)(exc, `Can't open obj version file ${this.path}`);
|
|
82
82
|
});
|
|
83
83
|
try {
|
|
84
84
|
return await action(fd);
|
|
@@ -97,7 +97,7 @@ class ObjVersionFile {
|
|
|
97
97
|
saveHeader(header, saveLayout) {
|
|
98
98
|
return this.withRWFile(async (fd) => {
|
|
99
99
|
const ofs = this.layout.getLayoutOfs();
|
|
100
|
-
await fs.writeFromBuf(fd, ofs, buffer_utils_1.toBuffer(header));
|
|
100
|
+
await fs.writeFromBuf(fd, ofs, (0, buffer_utils_1.toBuffer)(header));
|
|
101
101
|
this.layout.addHeader(header.length, ofs);
|
|
102
102
|
if (saveLayout) {
|
|
103
103
|
await this.recordLayout(fd);
|
|
@@ -107,7 +107,7 @@ class ObjVersionFile {
|
|
|
107
107
|
saveSegs(segsChunks, thisVerOfs, baseVerOfs, saveLayout) {
|
|
108
108
|
return this.withRWFile(async (fd) => {
|
|
109
109
|
const ofs = this.layout.getLayoutOfs();
|
|
110
|
-
await fs.writeFromBuf(fd, ofs, buffer_utils_1.toBuffer(segsChunks));
|
|
110
|
+
await fs.writeFromBuf(fd, ofs, (0, buffer_utils_1.toBuffer)(segsChunks));
|
|
111
111
|
if (baseVerOfs === undefined) {
|
|
112
112
|
this.layout.addSegsOnFile(thisVerOfs, segsChunks.length, ofs);
|
|
113
113
|
}
|
|
@@ -125,7 +125,7 @@ class ObjVersionFile {
|
|
|
125
125
|
async withROFile(action) {
|
|
126
126
|
const fd = await fs.open(this.path, 'r')
|
|
127
127
|
.catch(exc => {
|
|
128
|
-
throw error_1.errWithCause(exc, `Can't open obj version file ${this.path}`);
|
|
128
|
+
throw (0, error_1.errWithCause)(exc, `Can't open obj version file ${this.path}`);
|
|
129
129
|
});
|
|
130
130
|
try {
|
|
131
131
|
return await action(fd);
|
|
@@ -158,7 +158,7 @@ class ObjVersionFile {
|
|
|
158
158
|
return;
|
|
159
159
|
}
|
|
160
160
|
await this.withROFile(async (fd) => {
|
|
161
|
-
const src = fs_1.createReadStream('', {
|
|
161
|
+
const src = (0, fs_1.createReadStream)('', {
|
|
162
162
|
fd,
|
|
163
163
|
autoClose: false,
|
|
164
164
|
start: chunkInfo.fileOfs,
|
|
@@ -191,7 +191,7 @@ class ObjVersionFile {
|
|
|
191
191
|
for (const chunk of chunks) {
|
|
192
192
|
if ((chunk.type === 'new-on-disk')
|
|
193
193
|
|| (chunk.type === 'base-on-disk')) {
|
|
194
|
-
const src = fs_1.createReadStream('', {
|
|
194
|
+
const src = (0, fs_1.createReadStream)('', {
|
|
195
195
|
fd,
|
|
196
196
|
autoClose: false,
|
|
197
197
|
start: chunk.fileOfs,
|
|
@@ -227,7 +227,7 @@ exports.ObjVersionFile = ObjVersionFile;
|
|
|
227
227
|
Object.freeze(ObjVersionFile.prototype);
|
|
228
228
|
Object.freeze(ObjVersionFile);
|
|
229
229
|
async function pipeBytes(src, sink) {
|
|
230
|
-
const deferred = processes_1.defer();
|
|
230
|
+
const deferred = (0, processes_1.defer)();
|
|
231
231
|
src.pipe(sink, { end: false });
|
|
232
232
|
src.on('error', (err) => {
|
|
233
233
|
deferred.reject(err);
|
|
@@ -260,8 +260,8 @@ async function parseObjVersionBytesLayout(fd) {
|
|
|
260
260
|
throw exc;
|
|
261
261
|
});
|
|
262
262
|
const fileStart = fstBytes.slice(0, 4);
|
|
263
|
-
if (bytes_equal_1.bytesEqual(fileStart, v1_obj_file_format_1.V1_FILE_START)) {
|
|
264
|
-
const layoutOfs = v1_obj_file_format_1.uintFrom8Bytes(fstBytes, 4);
|
|
263
|
+
if ((0, bytes_equal_1.bytesEqual)(fileStart, v1_obj_file_format_1.V1_FILE_START)) {
|
|
264
|
+
const layoutOfs = (0, v1_obj_file_format_1.uintFrom8Bytes)(fstBytes, 4);
|
|
265
265
|
if (layoutOfs === 0) {
|
|
266
266
|
throw parsingException(`Obj version file is in incomplete state`);
|
|
267
267
|
}
|
|
@@ -287,10 +287,10 @@ async function createNewV1File(path) {
|
|
|
287
287
|
await fs.writeFile(path, initContent, { flag: 'wx' });
|
|
288
288
|
}
|
|
289
289
|
async function recordLayoutOffsetInV1(fd, ofs) {
|
|
290
|
-
const ofsInBytes = v1_obj_file_format_1.uintTo8Bytes(ofs);
|
|
290
|
+
const ofsInBytes = (0, v1_obj_file_format_1.uintTo8Bytes)(ofs);
|
|
291
291
|
await fs.writeFromBuf(fd, v1_obj_file_format_1.V1_FILE_START.length, ofsInBytes)
|
|
292
292
|
.catch(exc => {
|
|
293
|
-
throw error_1.errWithCause(exc, `Can't record layout offset in obj file`);
|
|
293
|
+
throw (0, error_1.errWithCause)(exc, `Can't record layout offset in obj file`);
|
|
294
294
|
});
|
|
295
295
|
}
|
|
296
296
|
Object.freeze(exports);
|
|
@@ -42,7 +42,7 @@ function diffToLayout(diff) {
|
|
|
42
42
|
}
|
|
43
43
|
exports.diffToLayout = diffToLayout;
|
|
44
44
|
async function streamToObjFile(file, content, src, maxBufferLen) {
|
|
45
|
-
let deferred = processes_1.defer();
|
|
45
|
+
let deferred = (0, processes_1.defer)();
|
|
46
46
|
const contentIter = content.values();
|
|
47
47
|
let chunk = undefined;
|
|
48
48
|
let buf = new common_1.BytesFIFOBuffer();
|
|
@@ -111,7 +111,7 @@ async function streamToObjFile(file, content, src, maxBufferLen) {
|
|
|
111
111
|
});
|
|
112
112
|
src.on('end', () => {
|
|
113
113
|
if (chunk) {
|
|
114
|
-
complete(file_1.makeFileException(file_1.Code.endOfFile, '<input stream>'));
|
|
114
|
+
complete((0, file_1.makeFileException)(file_1.Code.endOfFile, '<input stream>'));
|
|
115
115
|
}
|
|
116
116
|
else {
|
|
117
117
|
complete();
|
|
@@ -125,7 +125,7 @@ exports.streamToObjFile = streamToObjFile;
|
|
|
125
125
|
function chunksInOrderedStream(len, headerLen, segsOfs) {
|
|
126
126
|
const chunks = [];
|
|
127
127
|
if (typeof headerLen === 'number') {
|
|
128
|
-
assert_1.assert(len >= headerLen);
|
|
128
|
+
(0, assert_1.assert)(len >= headerLen);
|
|
129
129
|
chunks.push({ type: 'header', len: headerLen });
|
|
130
130
|
len -= headerLen;
|
|
131
131
|
}
|
|
@@ -439,7 +439,7 @@ class PressureValve {
|
|
|
439
439
|
}
|
|
440
440
|
pressWithError(err) {
|
|
441
441
|
this.toggle(true);
|
|
442
|
-
this.stopper.reject(error_1.errWithCause(err, `Backpressure error`));
|
|
442
|
+
this.stopper.reject((0, error_1.errWithCause)(err, `Backpressure error`));
|
|
443
443
|
}
|
|
444
444
|
}
|
|
445
445
|
exports.PressureValve = PressureValve;
|
|
@@ -19,11 +19,11 @@ exports.stringOfB64Chars = exports.stringOfB64UrlSafeChars = exports.stringOfB64
|
|
|
19
19
|
const buffer_utils_1 = require("./buffer-utils");
|
|
20
20
|
const crypto_1 = require("crypto");
|
|
21
21
|
function bytesSync(numOfBytes) {
|
|
22
|
-
return crypto_1.randomBytes(numOfBytes);
|
|
22
|
+
return (0, crypto_1.randomBytes)(numOfBytes);
|
|
23
23
|
}
|
|
24
24
|
exports.bytesSync = bytesSync;
|
|
25
25
|
function bytes(numOfBytes) {
|
|
26
|
-
return new Promise((res, rej) => crypto_1.randomBytes(numOfBytes, (err, buf) => {
|
|
26
|
+
return new Promise((res, rej) => (0, crypto_1.randomBytes)(numOfBytes, (err, buf) => {
|
|
27
27
|
if (err) {
|
|
28
28
|
rej(err);
|
|
29
29
|
}
|
|
@@ -34,15 +34,15 @@ function bytes(numOfBytes) {
|
|
|
34
34
|
}
|
|
35
35
|
exports.bytes = bytes;
|
|
36
36
|
function uint8Sync() {
|
|
37
|
-
return crypto_1.randomBytes(1)[0];
|
|
37
|
+
return (0, crypto_1.randomBytes)(1)[0];
|
|
38
38
|
}
|
|
39
39
|
exports.uint8Sync = uint8Sync;
|
|
40
40
|
async function uint8() {
|
|
41
|
-
return (await crypto_1.randomBytes(1))[0];
|
|
41
|
+
return (await (0, crypto_1.randomBytes)(1))[0];
|
|
42
42
|
}
|
|
43
43
|
exports.uint8 = uint8;
|
|
44
44
|
function uint48Sync() {
|
|
45
|
-
const b = crypto_1.randomBytes(6);
|
|
45
|
+
const b = (0, crypto_1.randomBytes)(6);
|
|
46
46
|
const l = b[0] + (b[1] << 8) + (b[2] << 16) + (b[3] << 24);
|
|
47
47
|
const h = b[4] + (b[5] << 8);
|
|
48
48
|
return h * 0x100000000 + l;
|
|
@@ -57,13 +57,13 @@ async function uint48() {
|
|
|
57
57
|
exports.uint48 = uint48;
|
|
58
58
|
function stringOfB64UrlSafeCharsSync(numOfChars) {
|
|
59
59
|
const numOfbytes = 3 * (1 + Math.floor(numOfChars / 4));
|
|
60
|
-
const byteArr = crypto_1.randomBytes(numOfbytes);
|
|
60
|
+
const byteArr = (0, crypto_1.randomBytes)(numOfbytes);
|
|
61
61
|
return buffer_utils_1.base64urlSafe.pack(byteArr).substring(0, numOfChars);
|
|
62
62
|
}
|
|
63
63
|
exports.stringOfB64UrlSafeCharsSync = stringOfB64UrlSafeCharsSync;
|
|
64
64
|
function stringOfB64CharsSync(numOfChars) {
|
|
65
65
|
const numOfbytes = 3 * (1 + Math.floor(numOfChars / 4));
|
|
66
|
-
return crypto_1.randomBytes(numOfbytes).toString('base64').substring(0, numOfChars);
|
|
66
|
+
return (0, crypto_1.randomBytes)(numOfbytes).toString('base64').substring(0, numOfChars);
|
|
67
67
|
}
|
|
68
68
|
exports.stringOfB64CharsSync = stringOfB64CharsSync;
|
|
69
69
|
async function stringOfB64UrlSafeChars(numOfChars) {
|
|
@@ -67,10 +67,11 @@ export interface GetObjQueryOpts {
|
|
|
67
67
|
}
|
|
68
68
|
export interface PutObjFirstQueryOpts {
|
|
69
69
|
/**
|
|
70
|
-
* This is a
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
* This is a flag to indicate that new object should be created.
|
|
71
|
+
*/
|
|
72
|
+
create?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* This parameter is object's new version.
|
|
74
75
|
*/
|
|
75
76
|
ver: number;
|
|
76
77
|
/**
|
|
@@ -156,24 +157,20 @@ export declare namespace currentRootObj {
|
|
|
156
157
|
}
|
|
157
158
|
export declare namespace archivedObjVersion {
|
|
158
159
|
const EXPRESS_URL_END = "/obj/:objId/archived";
|
|
159
|
-
function getReqUrlEnd(objId: string,
|
|
160
|
+
function getReqUrlEnd(objId: string, opts: GetObjQueryOpts): string;
|
|
160
161
|
const SC: {
|
|
161
162
|
okGet: number;
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
concurrentTransaction: number;
|
|
165
|
-
incompatibleObjState: number;
|
|
163
|
+
unknownObj: number;
|
|
164
|
+
unknownObjVer: number;
|
|
166
165
|
};
|
|
167
166
|
}
|
|
168
167
|
export declare namespace archivedRootVersion {
|
|
169
168
|
const EXPRESS_URL_END = "root/archived";
|
|
170
|
-
function getReqUrlEnd(
|
|
169
|
+
function getReqUrlEnd(opts: GetObjQueryOpts): string;
|
|
171
170
|
const SC: {
|
|
172
171
|
okGet: number;
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
concurrentTransaction: number;
|
|
176
|
-
incompatibleObjState: number;
|
|
172
|
+
unknownObj: number;
|
|
173
|
+
unknownObjVer: number;
|
|
177
174
|
};
|
|
178
175
|
}
|
|
179
176
|
export interface DiffInfo {
|
|
@@ -220,18 +217,27 @@ export declare namespace cancelRootTransaction {
|
|
|
220
217
|
export declare namespace archiveObj {
|
|
221
218
|
const EXPRESS_URL_END = "obj/:objId/archive";
|
|
222
219
|
function getReqUrlEnd(objId: string): string;
|
|
220
|
+
function postAndDelReqUrlEnd(objId: string, version: number): string;
|
|
221
|
+
type VersionsList = number[];
|
|
223
222
|
const SC: {
|
|
224
223
|
okGet: number;
|
|
225
|
-
|
|
226
|
-
|
|
224
|
+
okPost: number;
|
|
225
|
+
okDelete: number;
|
|
226
|
+
unknownObj: number;
|
|
227
|
+
unknownObjVer: number;
|
|
227
228
|
};
|
|
228
229
|
}
|
|
229
230
|
export declare namespace archiveRoot {
|
|
230
231
|
const URL_END = "root/archive";
|
|
232
|
+
function getReqUrlEnd(): string;
|
|
233
|
+
function postAndDelReqUrlEnd(version: number): string;
|
|
234
|
+
type VersionsList = archiveObj.VersionsList;
|
|
231
235
|
const SC: {
|
|
232
236
|
okGet: number;
|
|
233
|
-
|
|
234
|
-
|
|
237
|
+
okPost: number;
|
|
238
|
+
okDelete: number;
|
|
239
|
+
unknownObj: number;
|
|
240
|
+
unknownObjVer: number;
|
|
235
241
|
};
|
|
236
242
|
}
|
|
237
243
|
export interface ErrorReply {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2015 - 2017, 2019 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2015 - 2017, 2019, 2022 3NSoft Inc.
|
|
4
4
|
|
|
5
5
|
This program is free software: you can redistribute it and/or modify it under
|
|
6
6
|
the terms of the GNU General Public License as published by the Free Software
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
See the GNU General Public License for more details.
|
|
14
14
|
|
|
15
15
|
You should have received a copy of the GNU General Public License along with
|
|
16
|
-
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
17
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
19
|
exports.objRemoved = exports.objChanged = exports.wsEventChannel = exports.archiveRoot = exports.archiveObj = exports.cancelRootTransaction = exports.cancelTransaction = exports.addDiffSectionTo = exports.sanitizedDiff = exports.archivedRootVersion = exports.archivedObjVersion = exports.currentRootObj = exports.currentObj = exports.keyDerivParams = exports.PARAM_SC = exports.sessionParams = exports.closeSession = exports.midLogin = exports.BIN_TYPE = exports.HTTP_HEADER = exports.ERR_SC = void 0;
|
|
19
20
|
/**
|
|
@@ -75,15 +76,15 @@ var currentObj;
|
|
|
75
76
|
(function (currentObj) {
|
|
76
77
|
currentObj.EXPRESS_URL_END = 'obj/:objId/current';
|
|
77
78
|
function getReqUrlEnd(objId, opts) {
|
|
78
|
-
return `obj/${objId}/current${opts ? `?${querystring_1.stringify(opts)}` : ''}`;
|
|
79
|
+
return `obj/${objId}/current${opts ? `?${(0, querystring_1.stringify)(opts)}` : ''}`;
|
|
79
80
|
}
|
|
80
81
|
currentObj.getReqUrlEnd = getReqUrlEnd;
|
|
81
82
|
function firstPutReqUrlEnd(objId, opts) {
|
|
82
|
-
return `obj/${objId}/current?${querystring_1.stringify(opts)}`;
|
|
83
|
+
return `obj/${objId}/current?${(0, querystring_1.stringify)(opts)}`;
|
|
83
84
|
}
|
|
84
85
|
currentObj.firstPutReqUrlEnd = firstPutReqUrlEnd;
|
|
85
86
|
function secondPutReqUrlEnd(objId, opts) {
|
|
86
|
-
return `obj/${objId}/current?${querystring_1.stringify(opts)}`;
|
|
87
|
+
return `obj/${objId}/current?${(0, querystring_1.stringify)(opts)}`;
|
|
87
88
|
}
|
|
88
89
|
currentObj.secondPutReqUrlEnd = secondPutReqUrlEnd;
|
|
89
90
|
currentObj.SC = {
|
|
@@ -105,15 +106,15 @@ var currentRootObj;
|
|
|
105
106
|
(function (currentRootObj) {
|
|
106
107
|
currentRootObj.EXPRESS_URL_END = 'root/current';
|
|
107
108
|
function getReqUrlEnd(opts) {
|
|
108
|
-
return `root/current${opts ? `?${querystring_1.stringify(opts)}` : ''}`;
|
|
109
|
+
return `root/current${opts ? `?${(0, querystring_1.stringify)(opts)}` : ''}`;
|
|
109
110
|
}
|
|
110
111
|
currentRootObj.getReqUrlEnd = getReqUrlEnd;
|
|
111
112
|
function firstPutReqUrlEnd(opts) {
|
|
112
|
-
return `root/current?${querystring_1.stringify(opts)}`;
|
|
113
|
+
return `root/current?${(0, querystring_1.stringify)(opts)}`;
|
|
113
114
|
}
|
|
114
115
|
currentRootObj.firstPutReqUrlEnd = firstPutReqUrlEnd;
|
|
115
116
|
function secondPutReqUrlEnd(opts) {
|
|
116
|
-
return `root/current?${querystring_1.stringify(opts)}`;
|
|
117
|
+
return `root/current?${(0, querystring_1.stringify)(opts)}`;
|
|
117
118
|
}
|
|
118
119
|
currentRootObj.secondPutReqUrlEnd = secondPutReqUrlEnd;
|
|
119
120
|
currentRootObj.SC = currentObj.SC;
|
|
@@ -122,32 +123,22 @@ Object.freeze(currentRootObj);
|
|
|
122
123
|
var archivedObjVersion;
|
|
123
124
|
(function (archivedObjVersion) {
|
|
124
125
|
archivedObjVersion.EXPRESS_URL_END = '/obj/:objId/archived';
|
|
125
|
-
function getReqUrlEnd(objId,
|
|
126
|
-
|
|
127
|
-
opts.ver = version;
|
|
128
|
-
}
|
|
129
|
-
const query = (opts ? `?${querystring_1.stringify(opts)}` : '');
|
|
130
|
-
return `/obj/${objId}/archived${query}`;
|
|
126
|
+
function getReqUrlEnd(objId, opts) {
|
|
127
|
+
return `/obj/${objId}/archived?${(0, querystring_1.stringify)(opts)}`;
|
|
131
128
|
}
|
|
132
129
|
archivedObjVersion.getReqUrlEnd = getReqUrlEnd;
|
|
133
130
|
archivedObjVersion.SC = {
|
|
134
131
|
okGet: 200,
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
concurrentTransaction: 483,
|
|
138
|
-
incompatibleObjState: 484
|
|
132
|
+
unknownObj: 474,
|
|
133
|
+
unknownObjVer: 494
|
|
139
134
|
};
|
|
140
135
|
})(archivedObjVersion = exports.archivedObjVersion || (exports.archivedObjVersion = {}));
|
|
141
136
|
Object.freeze(archivedObjVersion);
|
|
142
137
|
var archivedRootVersion;
|
|
143
138
|
(function (archivedRootVersion) {
|
|
144
139
|
archivedRootVersion.EXPRESS_URL_END = 'root/archived';
|
|
145
|
-
function getReqUrlEnd(
|
|
146
|
-
|
|
147
|
-
opts.ver = version;
|
|
148
|
-
}
|
|
149
|
-
const query = (opts ? `?${querystring_1.stringify(opts)}` : '');
|
|
150
|
-
return `root/archived${query}`;
|
|
140
|
+
function getReqUrlEnd(opts) {
|
|
141
|
+
return `root/archived?${(0, querystring_1.stringify)(opts)}`;
|
|
151
142
|
}
|
|
152
143
|
archivedRootVersion.getReqUrlEnd = getReqUrlEnd;
|
|
153
144
|
archivedRootVersion.SC = archivedObjVersion.SC;
|
|
@@ -236,16 +227,30 @@ var archiveObj;
|
|
|
236
227
|
return `obj/${objId}/archive`;
|
|
237
228
|
}
|
|
238
229
|
archiveObj.getReqUrlEnd = getReqUrlEnd;
|
|
230
|
+
function postAndDelReqUrlEnd(objId, version) {
|
|
231
|
+
return `obj/${objId}/archive?ver=${version}`;
|
|
232
|
+
}
|
|
233
|
+
archiveObj.postAndDelReqUrlEnd = postAndDelReqUrlEnd;
|
|
239
234
|
archiveObj.SC = {
|
|
240
235
|
okGet: 200,
|
|
241
|
-
|
|
242
|
-
|
|
236
|
+
okPost: 200,
|
|
237
|
+
okDelete: 200,
|
|
238
|
+
unknownObj: 474,
|
|
239
|
+
unknownObjVer: 494
|
|
243
240
|
};
|
|
244
241
|
})(archiveObj = exports.archiveObj || (exports.archiveObj = {}));
|
|
245
242
|
Object.freeze(archiveObj);
|
|
246
243
|
var archiveRoot;
|
|
247
244
|
(function (archiveRoot) {
|
|
248
245
|
archiveRoot.URL_END = 'root/archive';
|
|
246
|
+
function getReqUrlEnd() {
|
|
247
|
+
return `root/archive`;
|
|
248
|
+
}
|
|
249
|
+
archiveRoot.getReqUrlEnd = getReqUrlEnd;
|
|
250
|
+
function postAndDelReqUrlEnd(version) {
|
|
251
|
+
return `root/archive?ver=${version}`;
|
|
252
|
+
}
|
|
253
|
+
archiveRoot.postAndDelReqUrlEnd = postAndDelReqUrlEnd;
|
|
249
254
|
archiveRoot.SC = archiveObj.SC;
|
|
250
255
|
})(archiveRoot = exports.archiveRoot || (exports.archiveRoot = {}));
|
|
251
256
|
Object.freeze(archiveRoot);
|
|
@@ -97,11 +97,11 @@ var msgObj;
|
|
|
97
97
|
(function (msgObj) {
|
|
98
98
|
msgObj.EXPRESS_URL_END = 'msg/obj/:objId';
|
|
99
99
|
function firstPutReqUrlEnd(objId, opts) {
|
|
100
|
-
return `msg/obj/${objId}?${querystring_1.stringify(opts)}`;
|
|
100
|
+
return `msg/obj/${objId}?${(0, querystring_1.stringify)(opts)}`;
|
|
101
101
|
}
|
|
102
102
|
msgObj.firstPutReqUrlEnd = firstPutReqUrlEnd;
|
|
103
103
|
function secondPutReqUrlEnd(objId, opts) {
|
|
104
|
-
return `msg/obj/${objId}?${querystring_1.stringify(opts)}`;
|
|
104
|
+
return `msg/obj/${objId}?${(0, querystring_1.stringify)(opts)}`;
|
|
105
105
|
}
|
|
106
106
|
msgObj.secondPutReqUrlEnd = secondPutReqUrlEnd;
|
|
107
107
|
msgObj.SC = {
|
|
@@ -114,7 +114,7 @@ var msgObj;
|
|
|
114
114
|
(function (msgObj) {
|
|
115
115
|
msgObj.EXPRESS_URL_END = 'msg/:msgId/obj/:objId';
|
|
116
116
|
function genUrlEnd(msgId, objId, opts) {
|
|
117
|
-
let optStr = (opts ? '?' + querystring_1.stringify(opts) : '');
|
|
117
|
+
let optStr = (opts ? '?' + (0, querystring_1.stringify)(opts) : '');
|
|
118
118
|
return `msg/${msgId}/obj/${objId}${optStr}`;
|
|
119
119
|
}
|
|
120
120
|
msgObj.genUrlEnd = genUrlEnd;
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
See the GNU General Public License for more details.
|
|
14
14
|
|
|
15
15
|
You should have received a copy of the GNU General Public License along with
|
|
16
|
-
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
17
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
19
|
exports.stringToNumOfBytes = void 0;
|
|
19
20
|
const mapAmountEndings = {
|
|
@@ -50,10 +50,10 @@ function emptyBody() {
|
|
|
50
50
|
// get and check Content-Length
|
|
51
51
|
const contentLength = parseInt(req.get(HTTP_HEADER.contentLength), 10);
|
|
52
52
|
if (isNaN(contentLength)) {
|
|
53
|
-
return next(error_handler_1.makeErr(411, "Content-Length header is required with proper number."));
|
|
53
|
+
return next((0, error_handler_1.makeErr)(411, "Content-Length header is required with proper number."));
|
|
54
54
|
}
|
|
55
55
|
if (contentLength !== 0) {
|
|
56
|
-
return next(error_handler_1.makeErr(413, "Request body is too long."));
|
|
56
|
+
return next((0, error_handler_1.makeErr)(413, "Request body is too long."));
|
|
57
57
|
}
|
|
58
58
|
next();
|
|
59
59
|
};
|
|
@@ -73,22 +73,22 @@ async function parseBinaryBodyWithExpectedSize(req, expectedLen) {
|
|
|
73
73
|
}
|
|
74
74
|
// check type
|
|
75
75
|
if (!req.is(TYPES.bin)) {
|
|
76
|
-
throw error_handler_1.makeErr(415, `Content-Type must be ${TYPES.bin} for this call.`);
|
|
76
|
+
throw (0, error_handler_1.makeErr)(415, `Content-Type must be ${TYPES.bin} for this call.`);
|
|
77
77
|
}
|
|
78
78
|
// check length declared in header
|
|
79
79
|
const contentLength = parseInt(req.get(HTTP_HEADER.contentLength), 10);
|
|
80
80
|
if (isNaN(contentLength)) {
|
|
81
|
-
throw error_handler_1.makeErr(411, "Content-Length header is required with proper number.");
|
|
81
|
+
throw (0, error_handler_1.makeErr)(411, "Content-Length header is required with proper number.");
|
|
82
82
|
}
|
|
83
83
|
if (contentLength !== expectedLen) {
|
|
84
|
-
throw error_handler_1.makeErr(400, "Unexpected number of bytes.");
|
|
84
|
+
throw (0, error_handler_1.makeErr)(400, "Unexpected number of bytes.");
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
catch (err) {
|
|
88
88
|
attachByteDrainToRequest(req);
|
|
89
89
|
throw err;
|
|
90
90
|
}
|
|
91
|
-
const deffered = processes_1.defer();
|
|
91
|
+
const deffered = (0, processes_1.defer)();
|
|
92
92
|
const bytes = new common_1.BytesFIFOBuffer();
|
|
93
93
|
// collect body bytes
|
|
94
94
|
let erred = false;
|
|
@@ -101,7 +101,7 @@ async function parseBinaryBodyWithExpectedSize(req, expectedLen) {
|
|
|
101
101
|
}
|
|
102
102
|
else {
|
|
103
103
|
erred = true;
|
|
104
|
-
deffered.reject(error_handler_1.makeErr(400, "Request body is longer than expected."));
|
|
104
|
+
deffered.reject((0, error_handler_1.makeErr)(400, "Request body is longer than expected."));
|
|
105
105
|
}
|
|
106
106
|
});
|
|
107
107
|
req.on('end', () => {
|
|
@@ -112,14 +112,14 @@ async function parseBinaryBodyWithExpectedSize(req, expectedLen) {
|
|
|
112
112
|
deffered.resolve(bytes.getBytes(undefined));
|
|
113
113
|
}
|
|
114
114
|
else {
|
|
115
|
-
deffered.reject(error_handler_1.makeErr(400, "Request body is shorter than expected."));
|
|
115
|
+
deffered.reject((0, error_handler_1.makeErr)(400, "Request body is shorter than expected."));
|
|
116
116
|
}
|
|
117
117
|
});
|
|
118
118
|
return deffered.promise;
|
|
119
119
|
}
|
|
120
120
|
exports.parseBinaryBodyWithExpectedSize = parseBinaryBodyWithExpectedSize;
|
|
121
121
|
function byteCollector(maxSize, contentType, parser) {
|
|
122
|
-
const maxSizeNum = conf_util_1.stringToNumOfBytes(maxSize);
|
|
122
|
+
const maxSizeNum = (0, conf_util_1.stringToNumOfBytes)(maxSize);
|
|
123
123
|
if ('string' !== typeof contentType) {
|
|
124
124
|
throw new Error("Given 'contentType' argument must be a string.");
|
|
125
125
|
}
|
|
@@ -127,19 +127,19 @@ function byteCollector(maxSize, contentType, parser) {
|
|
|
127
127
|
// check Content-Type
|
|
128
128
|
if (!req.is(contentType)) {
|
|
129
129
|
attachByteDrainToRequest(req);
|
|
130
|
-
return next(error_handler_1.makeErr(415, "Content-Type must be " +
|
|
130
|
+
return next((0, error_handler_1.makeErr)(415, "Content-Type must be " +
|
|
131
131
|
contentType + " for this call."));
|
|
132
132
|
}
|
|
133
133
|
// get and check Content-Length
|
|
134
134
|
const contentLength = parseInt(req.get(HTTP_HEADER.contentLength), 10);
|
|
135
135
|
if (isNaN(contentLength)) {
|
|
136
136
|
attachByteDrainToRequest(req);
|
|
137
|
-
return next(error_handler_1.makeErr(411, "Content-Length header is required with proper number."));
|
|
137
|
+
return next((0, error_handler_1.makeErr)(411, "Content-Length header is required with proper number."));
|
|
138
138
|
}
|
|
139
139
|
// enforce agreed limit on request size
|
|
140
140
|
if (contentLength > maxSizeNum) {
|
|
141
141
|
attachByteDrainToRequest(req);
|
|
142
|
-
return next(error_handler_1.makeErr(413, "Request body is too long."));
|
|
142
|
+
return next((0, error_handler_1.makeErr)(413, "Request body is too long."));
|
|
143
143
|
}
|
|
144
144
|
// XXX we may use fifo here, postponing byte copying till moment, when
|
|
145
145
|
// everything is downloaded
|
|
@@ -160,7 +160,7 @@ function byteCollector(maxSize, contentType, parser) {
|
|
|
160
160
|
else {
|
|
161
161
|
erred = true;
|
|
162
162
|
req.body = null;
|
|
163
|
-
next(error_handler_1.makeErr(413, "Request body is too long."));
|
|
163
|
+
next((0, error_handler_1.makeErr)(413, "Request body is too long."));
|
|
164
164
|
}
|
|
165
165
|
});
|
|
166
166
|
req.on('end', () => {
|
|
@@ -201,11 +201,11 @@ function json(maxSize, allowNonObject) {
|
|
|
201
201
|
req.body = JSON.parse(bodyAsStr);
|
|
202
202
|
}
|
|
203
203
|
catch (err) {
|
|
204
|
-
return next(error_handler_1.makeErr(400, "Request body cannot be interpreted as JSON."));
|
|
204
|
+
return next((0, error_handler_1.makeErr)(400, "Request body cannot be interpreted as JSON."));
|
|
205
205
|
}
|
|
206
206
|
if (!allowNonObject &&
|
|
207
207
|
(!req.body || (typeof req.body !== 'object'))) {
|
|
208
|
-
return next(error_handler_1.makeErr(400, "Request body is not a JSON object."));
|
|
208
|
+
return next((0, error_handler_1.makeErr)(400, "Request body is not a JSON object."));
|
|
209
209
|
}
|
|
210
210
|
next();
|
|
211
211
|
});
|
|
@@ -223,7 +223,7 @@ function textPlain(maxSize) {
|
|
|
223
223
|
req.body = req.body.toString('utf8');
|
|
224
224
|
}
|
|
225
225
|
catch (err) {
|
|
226
|
-
return next(error_handler_1.makeErr(400, "Request body cannot be interpreted as plain utf8 text."));
|
|
226
|
+
return next((0, error_handler_1.makeErr)(400, "Request body cannot be interpreted as plain utf8 text."));
|
|
227
227
|
}
|
|
228
228
|
next();
|
|
229
229
|
});
|
|
@@ -27,7 +27,7 @@ const error_1 = require("../../lib-common/exceptions/error");
|
|
|
27
27
|
* @param cause
|
|
28
28
|
*/
|
|
29
29
|
function makeErr(code, msg, cause) {
|
|
30
|
-
const err = error_1.errWithCause(cause, msg);
|
|
30
|
+
const err = (0, error_1.errWithCause)(cause, msg);
|
|
31
31
|
err.status = code;
|
|
32
32
|
return err;
|
|
33
33
|
}
|
|
@@ -71,14 +71,14 @@ async function validate(rpDomain, sessionId, userId, assertion, userCert, provCe
|
|
|
71
71
|
const validAt = Date.now() / 1000;
|
|
72
72
|
try {
|
|
73
73
|
// check that certificate is for the user
|
|
74
|
-
const addressInCert = jwkeys_1.getPrincipalAddress(userCert);
|
|
74
|
+
const addressInCert = (0, jwkeys_1.getPrincipalAddress)(userCert);
|
|
75
75
|
if (userId !== addressInCert) {
|
|
76
76
|
return false;
|
|
77
77
|
}
|
|
78
78
|
// check that issuer is the one that provides MailerId service for
|
|
79
79
|
// user's domain
|
|
80
|
-
const issuer = jwkeys_1.getKeyCert(provCert).issuer;
|
|
81
|
-
const serviceURL = await dns_1.get3NWebRecords(addressInCert, 'mailerid');
|
|
80
|
+
const issuer = (0, jwkeys_1.getKeyCert)(provCert).issuer;
|
|
81
|
+
const serviceURL = await (0, dns_1.get3NWebRecords)(addressInCert, 'mailerid');
|
|
82
82
|
const domainInRecord = serviceURL.split('/')[0].split(':')[0];
|
|
83
83
|
if (issuer !== domainInRecord) {
|
|
84
84
|
return false;
|
|
@@ -51,7 +51,7 @@ class InMemorySessions extends sessions_1.BaseSessionFactory {
|
|
|
51
51
|
async generate() {
|
|
52
52
|
let newSessionId;
|
|
53
53
|
do {
|
|
54
|
-
newSessionId = buffer_utils_1.base64urlSafe.pack(await random_node_1.bytes(ID_BYTES_LEN));
|
|
54
|
+
newSessionId = buffer_utils_1.base64urlSafe.pack(await (0, random_node_1.bytes)(ID_BYTES_LEN));
|
|
55
55
|
} while (this.sessions.has(strChunk(newSessionId)));
|
|
56
56
|
const params = this.makeDefaultSessionParams(newSessionId);
|
|
57
57
|
const session = this.makeSession(newSessionId, params);
|
|
@@ -87,7 +87,7 @@ class InMemorySessions extends sessions_1.BaseSessionFactory {
|
|
|
87
87
|
static factory(timeout, makeDefaultSessionParams) {
|
|
88
88
|
const factory = new InMemorySessions(timeout, makeDefaultSessionParams);
|
|
89
89
|
Object.seal(factory);
|
|
90
|
-
return Object.freeze(sessions_1.wrapFactory(factory));
|
|
90
|
+
return Object.freeze((0, sessions_1.wrapFactory)(factory));
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
exports.InMemorySessions = InMemorySessions;
|
|
@@ -96,7 +96,7 @@ Object.freeze(InMemorySessions);
|
|
|
96
96
|
function sameIdBytes(idStr, idBytes) {
|
|
97
97
|
try {
|
|
98
98
|
const bytes = buffer_utils_1.base64urlSafe.open(idStr);
|
|
99
|
-
return ecma_nacl_1.compareVectors(bytes, idBytes);
|
|
99
|
+
return (0, ecma_nacl_1.compareVectors)(bytes, idBytes);
|
|
100
100
|
}
|
|
101
101
|
catch (err) {
|
|
102
102
|
return false;
|