core-3nweb-client-lib 0.27.0 → 0.27.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/api-defs/files.d.ts +56 -26
- package/build/core/asmail/config/index.d.ts +2 -2
- package/build/core/asmail/config/index.js +2 -2
- package/build/core/asmail/config/invitations-anon.d.ts +10 -24
- package/build/core/asmail/config/invitations-anon.js +43 -31
- package/build/core/asmail/config/published-intro-key.d.ts +11 -22
- package/build/core/asmail/config/published-intro-key.js +47 -38
- package/build/core/asmail/inbox/attachments/fs.d.ts +2 -1
- package/build/core/asmail/inbox/attachments/fs.js +4 -3
- package/build/core/asmail/inbox/index.js +2 -2
- package/build/core/asmail/index.d.ts +1 -1
- package/build/core/asmail/index.js +2 -2
- package/build/core/asmail/keyring/correspondent-keys.d.ts +2 -2
- package/build/core/asmail/keyring/correspondent-keys.js +1 -1
- package/build/core/asmail/keyring/index.d.ts +9 -29
- package/build/core/asmail/keyring/index.js +82 -69
- package/build/core/id-manager/index.d.ts +43 -0
- package/build/core/{id-manager.js → id-manager/index.js} +33 -114
- package/build/core/id-manager/key-storage.d.ts +21 -0
- package/build/core/id-manager/key-storage.js +96 -0
- package/build/core/index.js +22 -25
- package/build/core/sign-in.d.ts +1 -2
- package/build/core/sign-in.js +5 -14
- package/build/core/sign-up.d.ts +2 -0
- package/build/core/sign-up.js +2 -1
- package/build/core/storage/index.d.ts +4 -2
- package/build/core/storage/index.js +36 -57
- package/build/core/storage/local/storage.d.ts +1 -1
- package/build/core/storage/synced/obj-files-gc.d.ts +1 -4
- package/build/core/storage/synced/obj-files-gc.js +1 -18
- package/build/core/storage/synced/obj-files.d.ts +11 -1
- package/build/core/storage/synced/obj-files.js +59 -34
- package/build/core/storage/synced/obj-status.d.ts +19 -7
- package/build/core/storage/synced/obj-status.js +158 -83
- package/build/core/storage/synced/storage.d.ts +7 -2
- package/build/core/storage/synced/storage.js +38 -15
- package/build/core/storage/synced/upsyncer.d.ts +4 -4
- package/build/core/storage/synced/upsyncer.js +14 -9
- package/build/ipc-via-protobuf/file.d.ts +7 -0
- package/build/ipc-via-protobuf/file.js +60 -27
- package/build/ipc-via-protobuf/fs.js +55 -38
- package/build/lib-client/3nstorage/exceptions.d.ts +13 -1
- package/build/lib-client/3nstorage/exceptions.js +9 -3
- package/build/lib-client/3nstorage/service.d.ts +6 -2
- package/build/lib-client/3nstorage/service.js +33 -17
- package/build/lib-client/3nstorage/util/file-based-json.js +2 -1
- package/build/lib-client/3nstorage/util/for-arrays.d.ts +1 -0
- package/build/lib-client/3nstorage/util/for-arrays.js +32 -0
- package/build/lib-client/3nstorage/xsp-fs/common.d.ts +5 -4
- package/build/lib-client/3nstorage/xsp-fs/common.js +1 -0
- package/build/lib-client/3nstorage/xsp-fs/file-node.d.ts +5 -10
- package/build/lib-client/3nstorage/xsp-fs/file-node.js +43 -45
- package/build/lib-client/3nstorage/xsp-fs/file.d.ts +7 -6
- package/build/lib-client/3nstorage/xsp-fs/file.js +14 -20
- package/build/lib-client/3nstorage/xsp-fs/folder-node.d.ts +16 -5
- package/build/lib-client/3nstorage/xsp-fs/folder-node.js +238 -68
- package/build/lib-client/3nstorage/xsp-fs/fs.d.ts +18 -17
- package/build/lib-client/3nstorage/xsp-fs/fs.js +32 -37
- package/build/lib-client/3nstorage/xsp-fs/node-in-fs.d.ts +15 -11
- package/build/lib-client/3nstorage/xsp-fs/node-in-fs.js +72 -22
- package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v1.js +1 -1
- package/build/lib-client/local-files/device-fs.js +11 -11
- package/build/lib-client/objs-on-disk/obj-on-disk.d.ts +5 -2
- package/build/lib-client/objs-on-disk/obj-on-disk.js +16 -1
- package/build/lib-client/user-with-mid-session.d.ts +2 -1
- package/build/lib-client/user-with-mid-session.js +7 -1
- package/build/lib-common/async-fs-node.js +8 -8
- package/build/lib-common/exceptions/file.d.ts +4 -2
- package/build/lib-common/exceptions/file.js +24 -58
- package/build/lib-common/ipc/generic-ipc.js +5 -4
- package/build/lib-common/objs-on-disk/file-layout.js +1 -1
- package/build/lib-common/objs-on-disk/utils.js +1 -1
- package/build/lib-common/service-api/3nstorage/owner.d.ts +8 -9
- package/build/lib-common/service-api/3nstorage/owner.js +2 -1
- package/build/protos/asmail.proto.js +5943 -4348
- package/build/protos/file.proto.js +874 -0
- package/build/protos/fs.proto.js +7014 -5419
- package/package.json +3 -2
- package/protos/file.proto +23 -7
- package/protos/fs.proto +27 -13
- package/build/core/id-manager.d.ts +0 -46
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2015 - 2019, 2021 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2015 - 2019, 2021 - 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
|
|
@@ -28,7 +28,7 @@ const path_1 = require("path");
|
|
|
28
28
|
var fs_2 = require("fs");
|
|
29
29
|
Object.defineProperty(exports, "Stats", { enumerable: true, get: function () { return fs_2.Stats; } });
|
|
30
30
|
function makeFileExceptionFromNodes(nodeExc) {
|
|
31
|
-
return (0, file_1.
|
|
31
|
+
return (0, file_1.makeFileExceptionFromCode)(nodeExc.code, nodeExc.path);
|
|
32
32
|
}
|
|
33
33
|
function readFile(path, options) {
|
|
34
34
|
return new Promise((resolve, reject) => {
|
|
@@ -307,7 +307,7 @@ async function readToBuf(fd, pos, buf) {
|
|
|
307
307
|
while (bytesRead < buf.length) {
|
|
308
308
|
const bNum = await readOrig(fd, buf, bytesRead, buf.length - bytesRead, pos);
|
|
309
309
|
if (bNum === 0) {
|
|
310
|
-
throw (0, file_1.makeFileException)(
|
|
310
|
+
throw (0, file_1.makeFileException)('endOfFile', '<file descriptor>');
|
|
311
311
|
}
|
|
312
312
|
bytesRead += bNum;
|
|
313
313
|
pos += bNum;
|
|
@@ -379,7 +379,7 @@ async function existsFolder(path) {
|
|
|
379
379
|
return true;
|
|
380
380
|
}
|
|
381
381
|
else {
|
|
382
|
-
throw (0, file_1.makeFileException)(
|
|
382
|
+
throw (0, file_1.makeFileException)('notDirectory', path);
|
|
383
383
|
}
|
|
384
384
|
}
|
|
385
385
|
catch (e) {
|
|
@@ -400,7 +400,7 @@ function existsFolderSync(path) {
|
|
|
400
400
|
return true;
|
|
401
401
|
}
|
|
402
402
|
else {
|
|
403
|
-
throw (0, file_1.makeFileException)(
|
|
403
|
+
throw (0, file_1.makeFileException)('notDirectory', path);
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
406
|
catch (e) {
|
|
@@ -421,7 +421,7 @@ function existsFileSync(path) {
|
|
|
421
421
|
return true;
|
|
422
422
|
}
|
|
423
423
|
else {
|
|
424
|
-
throw (0, file_1.makeFileException)(
|
|
424
|
+
throw (0, file_1.makeFileException)('notFile', path);
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
427
|
catch (e) {
|
|
@@ -586,7 +586,7 @@ async function streamToExistingFile(filePath, pos, len, src, bufSize) {
|
|
|
586
586
|
if (doneReading) {
|
|
587
587
|
return;
|
|
588
588
|
}
|
|
589
|
-
complete((0, file_1.makeFileException)(
|
|
589
|
+
complete((0, file_1.makeFileException)('endOfFile', '<input stream>'));
|
|
590
590
|
});
|
|
591
591
|
src.on('error', (err) => {
|
|
592
592
|
complete(err);
|
|
@@ -614,7 +614,7 @@ async function read(fd, pos, buf) {
|
|
|
614
614
|
while (bytesRead < buf.length) {
|
|
615
615
|
const bNum = await readOrig(fd, buf, bytesRead, buf.length - bytesRead, pos);
|
|
616
616
|
if (bNum === 0) {
|
|
617
|
-
throw (0, file_1.makeFileException)(
|
|
617
|
+
throw (0, file_1.makeFileException)('endOfFile', '<file descriptor>');
|
|
618
618
|
}
|
|
619
619
|
bytesRead += bNum;
|
|
620
620
|
pos += bNum;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
export declare const Code: web3n.files.exceptionCode;
|
|
2
1
|
export declare type FileException = web3n.files.FileException;
|
|
3
|
-
export declare
|
|
2
|
+
export declare type FileExceptionFlag = web3n.files.FileExceptionFlag;
|
|
3
|
+
export declare const Code: web3n.files.exceptionCode;
|
|
4
|
+
export declare function makeFileExceptionFromCode(code: string | undefined, path: string, cause?: any): FileException;
|
|
5
|
+
export declare function makeFileException(flag: keyof FileExceptionFlag, path: string, cause?: any): FileException;
|
|
4
6
|
export declare function maskPathInExc(pathPrefixMaskLen: number, exc: any): FileException;
|
|
5
7
|
export declare function ensureCorrectFS(fs: web3n.files.FS, type: web3n.files.FSType, writable: boolean): void;
|
|
6
8
|
export declare function makeNoAttrsExc(path: string): FileException;
|
|
@@ -16,28 +16,26 @@
|
|
|
16
16
|
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.makeVersionMismatchExc = exports.makeNoAttrsExc = exports.ensureCorrectFS = exports.maskPathInExc = exports.makeFileException = exports.Code = void 0;
|
|
19
|
+
exports.makeVersionMismatchExc = exports.makeNoAttrsExc = exports.ensureCorrectFS = exports.maskPathInExc = exports.makeFileException = exports.makeFileExceptionFromCode = exports.Code = void 0;
|
|
20
20
|
exports.Code = {
|
|
21
21
|
notFound: 'ENOENT',
|
|
22
22
|
alreadyExists: 'EEXIST',
|
|
23
23
|
notDirectory: 'ENOTDIR',
|
|
24
24
|
notFile: 'ENOTFILE',
|
|
25
|
-
notLink: 'not-link',
|
|
26
25
|
isDirectory: 'EISDIR',
|
|
27
26
|
notEmpty: 'ENOTEMPTY',
|
|
28
27
|
endOfFile: 'EEOF',
|
|
29
28
|
opNotPermitted: 'EPERM',
|
|
30
29
|
busy: 'EBUSY',
|
|
31
30
|
ioError: 'EIO',
|
|
32
|
-
concurrentUpdate: 'concurrent-update',
|
|
33
|
-
parsingError: 'parsing-error',
|
|
34
31
|
notImplemented: 'ENOSYS',
|
|
35
|
-
isEndless: 'is-endless',
|
|
36
|
-
storageClosed: 'storage-closed',
|
|
37
|
-
versionMismatch: 'version-mismatch',
|
|
38
32
|
};
|
|
39
33
|
Object.freeze(exports.Code);
|
|
40
|
-
|
|
34
|
+
const codeToFlag = {};
|
|
35
|
+
for (const [flag, code] of Object.entries(exports.Code)) {
|
|
36
|
+
codeToFlag[code] = flag;
|
|
37
|
+
}
|
|
38
|
+
function makeFileExceptionFromCode(code, path, cause) {
|
|
41
39
|
const err = {
|
|
42
40
|
runtimeException: true,
|
|
43
41
|
type: 'file',
|
|
@@ -45,59 +43,27 @@ function makeFileException(code, path, cause) {
|
|
|
45
43
|
path,
|
|
46
44
|
cause
|
|
47
45
|
};
|
|
48
|
-
if (code
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
else if (code === exports.Code.isDirectory) {
|
|
55
|
-
err.isDirectory = true;
|
|
56
|
-
}
|
|
57
|
-
else if (code === exports.Code.notDirectory) {
|
|
58
|
-
err.notDirectory = true;
|
|
59
|
-
}
|
|
60
|
-
else if (code === exports.Code.notFile) {
|
|
61
|
-
err.notFile = true;
|
|
62
|
-
}
|
|
63
|
-
else if (code === exports.Code.notLink) {
|
|
64
|
-
err.notLink = true;
|
|
65
|
-
}
|
|
66
|
-
else if (code === exports.Code.endOfFile) {
|
|
67
|
-
err.endOfFile = true;
|
|
68
|
-
}
|
|
69
|
-
else if (code === exports.Code.busy) {
|
|
70
|
-
err.busy = true;
|
|
71
|
-
}
|
|
72
|
-
else if (code === exports.Code.ioError) {
|
|
73
|
-
err.ioError = true;
|
|
74
|
-
}
|
|
75
|
-
else if (code === exports.Code.notEmpty) {
|
|
76
|
-
err.notEmpty = true;
|
|
77
|
-
}
|
|
78
|
-
else if (code === exports.Code.opNotPermitted) {
|
|
79
|
-
err.opNotPermitted = true;
|
|
80
|
-
}
|
|
81
|
-
else if (code === exports.Code.concurrentUpdate) {
|
|
82
|
-
err.concurrentUpdate = true;
|
|
83
|
-
}
|
|
84
|
-
else if (code === exports.Code.parsingError) {
|
|
85
|
-
err.parsingError = true;
|
|
86
|
-
}
|
|
87
|
-
else if (code === exports.Code.notImplemented) {
|
|
88
|
-
err.notImplemented = true;
|
|
89
|
-
}
|
|
90
|
-
else if (code === exports.Code.isEndless) {
|
|
91
|
-
err.isEndless = true;
|
|
92
|
-
}
|
|
93
|
-
else if (code === exports.Code.storageClosed) {
|
|
94
|
-
err.storageClosed = true;
|
|
95
|
-
}
|
|
96
|
-
else if (code === exports.Code.versionMismatch) {
|
|
97
|
-
err.versionMismatch = true;
|
|
46
|
+
if (code) {
|
|
47
|
+
const flag = codeToFlag[code];
|
|
48
|
+
if (flag) {
|
|
49
|
+
err[flag] = true;
|
|
50
|
+
}
|
|
98
51
|
}
|
|
99
52
|
return err;
|
|
100
53
|
}
|
|
54
|
+
exports.makeFileExceptionFromCode = makeFileExceptionFromCode;
|
|
55
|
+
function makeFileException(flag, path, cause) {
|
|
56
|
+
const code = exports.Code[flag];
|
|
57
|
+
const err = {
|
|
58
|
+
runtimeException: true,
|
|
59
|
+
type: 'file',
|
|
60
|
+
code,
|
|
61
|
+
path,
|
|
62
|
+
cause
|
|
63
|
+
};
|
|
64
|
+
err[flag] = true;
|
|
65
|
+
return err;
|
|
66
|
+
}
|
|
101
67
|
exports.makeFileException = makeFileException;
|
|
102
68
|
function maskPathInExc(pathPrefixMaskLen, exc) {
|
|
103
69
|
if (!exc.runtimeException || !exc.code) {
|
|
@@ -278,11 +278,12 @@ function makeRequestServer(channel, comm) {
|
|
|
278
278
|
return (new ReplyingSide(channel, comm)).wrap();
|
|
279
279
|
}
|
|
280
280
|
exports.makeRequestServer = makeRequestServer;
|
|
281
|
-
function makeUnknownEventException() {
|
|
281
|
+
function makeUnknownEventException(message) {
|
|
282
282
|
return {
|
|
283
283
|
runtimeException: true,
|
|
284
284
|
type: 'events',
|
|
285
|
-
unknownEvent: true
|
|
285
|
+
unknownEvent: true,
|
|
286
|
+
message
|
|
286
287
|
};
|
|
287
288
|
}
|
|
288
289
|
const SUBSCRIBE_REQ_NAME = 'subscribe';
|
|
@@ -307,7 +308,7 @@ class EventsSendingSide extends ReplyingSide {
|
|
|
307
308
|
const event = env.req;
|
|
308
309
|
const gr = this.findGroup(event);
|
|
309
310
|
if (!gr) {
|
|
310
|
-
throw makeUnknownEventException();
|
|
311
|
+
throw makeUnknownEventException(`Events' channel ${event} is not found in handling subscribe`);
|
|
311
312
|
}
|
|
312
313
|
this.subscribedEvents.add(event);
|
|
313
314
|
await gr.subscribe(event);
|
|
@@ -316,7 +317,7 @@ class EventsSendingSide extends ReplyingSide {
|
|
|
316
317
|
const event = env.req;
|
|
317
318
|
const gr = this.findGroup(event);
|
|
318
319
|
if (!gr) {
|
|
319
|
-
throw makeUnknownEventException();
|
|
320
|
+
throw makeUnknownEventException(`Events' channel ${event} is not found in handling unsubscribe`);
|
|
320
321
|
}
|
|
321
322
|
this.subscribedEvents.delete(event);
|
|
322
323
|
if (gr.unsubscribe) {
|
|
@@ -111,7 +111,7 @@ async function streamToObjFile(file, content, src, maxBufferLen) {
|
|
|
111
111
|
});
|
|
112
112
|
src.on('end', () => {
|
|
113
113
|
if (chunk) {
|
|
114
|
-
complete((0, file_1.makeFileException)(
|
|
114
|
+
complete((0, file_1.makeFileException)('endOfFile', '<input stream>'));
|
|
115
115
|
}
|
|
116
116
|
else {
|
|
117
117
|
complete();
|
|
@@ -66,10 +66,6 @@ export interface GetObjQueryOpts {
|
|
|
66
66
|
ver?: number;
|
|
67
67
|
}
|
|
68
68
|
export interface PutObjFirstQueryOpts {
|
|
69
|
-
/**
|
|
70
|
-
* This is a flag to indicate that new object should be created.
|
|
71
|
-
*/
|
|
72
|
-
create?: boolean;
|
|
73
69
|
/**
|
|
74
70
|
* This parameter is object's new version.
|
|
75
71
|
*/
|
|
@@ -132,9 +128,10 @@ export declare namespace currentObj {
|
|
|
132
128
|
mismatchedObjVer: number;
|
|
133
129
|
objIncomplete: number;
|
|
134
130
|
};
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
131
|
+
type MismatchedObjVerReply = MismatchedObjVerErrReply;
|
|
132
|
+
}
|
|
133
|
+
export interface MismatchedObjVerErrReply extends ErrorReply {
|
|
134
|
+
current_version: number;
|
|
138
135
|
}
|
|
139
136
|
export declare namespace currentRootObj {
|
|
140
137
|
const EXPRESS_URL_END = "root/current";
|
|
@@ -240,23 +237,25 @@ export declare namespace rootStatus {
|
|
|
240
237
|
export declare namespace archiveObj {
|
|
241
238
|
const EXPRESS_URL_END = "obj/:objId/archive";
|
|
242
239
|
function postAndDelReqUrlEnd(objId: string, version: number): string;
|
|
243
|
-
type
|
|
240
|
+
type MismatchedObjVerReply = MismatchedObjVerErrReply;
|
|
244
241
|
const SC: {
|
|
245
242
|
okPost: number;
|
|
246
243
|
okDelete: number;
|
|
247
244
|
unknownObj: number;
|
|
248
245
|
unknownObjVer: number;
|
|
246
|
+
mismatchedObjVer: number;
|
|
249
247
|
};
|
|
250
248
|
}
|
|
251
249
|
export declare namespace archiveRoot {
|
|
252
250
|
const EXPRESS_URL_END = "root/archive";
|
|
253
251
|
function postAndDelReqUrlEnd(version: number): string;
|
|
254
|
-
type
|
|
252
|
+
type MismatchedObjVerReply = archiveObj.MismatchedObjVerReply;
|
|
255
253
|
const SC: {
|
|
256
254
|
okPost: number;
|
|
257
255
|
okDelete: number;
|
|
258
256
|
unknownObj: number;
|
|
259
257
|
unknownObjVer: number;
|
|
258
|
+
mismatchedObjVer: number;
|
|
260
259
|
};
|
|
261
260
|
}
|
|
262
261
|
export interface ErrorReply {
|
|
@@ -258,7 +258,8 @@ var archiveObj;
|
|
|
258
258
|
okPost: 200,
|
|
259
259
|
okDelete: 200,
|
|
260
260
|
unknownObj: 474,
|
|
261
|
-
unknownObjVer: 494
|
|
261
|
+
unknownObjVer: 494,
|
|
262
|
+
mismatchedObjVer: 495
|
|
262
263
|
};
|
|
263
264
|
})(archiveObj = exports.archiveObj || (exports.archiveObj = {}));
|
|
264
265
|
Object.freeze(archiveObj);
|