core-3nweb-client-lib 0.20.9 → 0.23.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/api-defs/common-caps.d.ts +6 -10
- package/build/api-defs/files.d.ts +8 -7
- package/build/core/asmail/inbox/attachments/fs.d.ts +2 -2
- package/build/core/asmail/inbox/attachments/fs.js +3 -2
- package/build/core/asmail/msg/common.d.ts +2 -2
- package/build/core/asmail/msg/common.js +3 -2
- package/build/core/asmail/msg/opener.d.ts +2 -2
- package/build/core/asmail/msg/opener.js +3 -2
- package/build/core/asmail/msg/packer.d.ts +2 -2
- package/build/core/asmail/msg/packer.js +7 -6
- package/build/core/index.d.ts +2 -2
- package/build/core/index.js +24 -28
- package/build/core/storage/index.js +2 -2
- package/build/core/storage/local/obj-files.js +8 -5
- package/build/core/storage/local/obj-status.js +4 -3
- package/build/core/storage/synced/obj-status.js +4 -3
- package/build/ipc-via-protobuf/bytes.js +1 -1
- package/build/ipc-via-protobuf/file.d.ts +4 -0
- package/build/ipc-via-protobuf/file.js +17 -15
- package/build/ipc-via-protobuf/fs.js +1 -1
- package/build/lib-client/3nstorage/xsp-fs/attrs.d.ts +28 -0
- package/build/lib-client/3nstorage/xsp-fs/attrs.js +337 -0
- package/build/lib-client/3nstorage/xsp-fs/common.d.ts +1 -1
- package/build/lib-client/3nstorage/xsp-fs/common.js +3 -2
- package/build/lib-client/3nstorage/xsp-fs/file-node.d.ts +31 -18
- package/build/lib-client/3nstorage/xsp-fs/file-node.js +130 -118
- package/build/lib-client/3nstorage/xsp-fs/file.d.ts +0 -1
- package/build/lib-client/3nstorage/xsp-fs/file.js +14 -49
- package/build/lib-client/3nstorage/xsp-fs/folder-node-serialization.d.ts +1 -1
- package/build/lib-client/3nstorage/xsp-fs/folder-node-serialization.js +95 -91
- package/build/lib-client/3nstorage/xsp-fs/folder-node.d.ts +19 -24
- package/build/lib-client/3nstorage/xsp-fs/folder-node.js +133 -190
- package/build/lib-client/3nstorage/xsp-fs/fs.d.ts +3 -4
- package/build/lib-client/3nstorage/xsp-fs/fs.js +18 -21
- package/build/lib-client/3nstorage/xsp-fs/link-node.d.ts +13 -8
- package/build/lib-client/3nstorage/xsp-fs/link-node.js +46 -38
- package/build/lib-client/3nstorage/xsp-fs/node-in-fs.d.ts +17 -35
- package/build/lib-client/3nstorage/xsp-fs/node-in-fs.js +34 -127
- package/build/lib-client/3nstorage/xsp-fs/node-persistence.d.ts +57 -0
- package/build/lib-client/3nstorage/xsp-fs/node-persistence.js +182 -0
- package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v1.d.ts +3 -0
- package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v1.js +87 -0
- package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v2.d.ts +6 -0
- package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v2.js +1022 -0
- package/build/lib-client/cryptor/cryptor-wasm.js +1 -1
- package/build/lib-client/cryptor/cryptor.wasm +0 -0
- package/build/lib-client/local-files/device-fs.js +7 -3
- package/build/lib-client/objs-on-disk/file-writing-proc.js +3 -2
- package/build/lib-client/objs-on-disk/obj-on-disk.js +8 -7
- package/build/lib-common/big-endian.d.ts +0 -24
- package/build/lib-common/big-endian.js +16 -78
- package/build/lib-common/exceptions/file.js +6 -2
- package/build/lib-common/obj-streaming/sink-utils.d.ts +0 -4
- package/build/lib-common/obj-streaming/sink-utils.js +4 -70
- package/build/lib-common/objs-on-disk/file-layout.js +2 -1
- package/build/lib-common/objs-on-disk/obj-file.js +2 -2
- package/build/lib-common/objs-on-disk/utils.js +2 -1
- package/build/lib-common/objs-on-disk/v1-obj-file-format.js +2 -1
- package/package.json +2 -2
- package/build/lib-client/files/file-attrs.d.ts +0 -76
- package/build/lib-client/files/file-attrs.js +0 -549
- package/build/lib-client/files/file-layout.d.ts +0 -56
- package/build/lib-client/files/file-layout.js +0 -456
- package/build/lib-client/files/file-sink.d.ts +0 -33
- package/build/lib-client/files/file-sink.js +0 -173
- package/build/lib-client/files/file-source.d.ts +0 -19
- package/build/lib-client/files/file-source.js +0 -115
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright (C) 2017 - 2018, 2020 -
|
|
2
|
+
Copyright (C) 2017 - 2018, 2020 - 2022 3NSoft Inc.
|
|
3
3
|
|
|
4
4
|
This program is free software: you can redistribute it and/or modify it under
|
|
5
5
|
the terms of the GNU General Public License as published by the Free Software
|
|
@@ -28,15 +28,11 @@ declare namespace web3n.caps.common {
|
|
|
28
28
|
|
|
29
29
|
type DevPathChecker = (path: string) => 'w'|'r'|false;
|
|
30
30
|
|
|
31
|
-
interface
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
storage?: StorageCAPSetting;
|
|
37
|
-
mailerid?: true;
|
|
38
|
-
log?: LogCAPSetting;
|
|
39
|
-
};
|
|
31
|
+
interface RequestedCAPs {
|
|
32
|
+
mail?: MailCAPSetting;
|
|
33
|
+
storage?: StorageCAPSetting;
|
|
34
|
+
mailerid?: true;
|
|
35
|
+
log?: LogCAPSetting;
|
|
40
36
|
}
|
|
41
37
|
|
|
42
38
|
interface StorageCAPSetting {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright (C) 2016 - 2018, 2020 3NSoft Inc.
|
|
2
|
+
Copyright (C) 2016 - 2018, 2020, 2022 3NSoft Inc.
|
|
3
3
|
|
|
4
4
|
This program is free software: you can redistribute it and/or modify it under
|
|
5
5
|
the terms of the GNU General Public License as published by the Free Software
|
|
@@ -39,6 +39,7 @@ declare namespace web3n.files {
|
|
|
39
39
|
notImplemented?: true;
|
|
40
40
|
attrsNotEnabledInFS?: true;
|
|
41
41
|
versionMismatch?: true;
|
|
42
|
+
isEndless?: true;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
interface exceptionCode {
|
|
@@ -56,6 +57,7 @@ declare namespace web3n.files {
|
|
|
56
57
|
concurrentUpdate: 'concurrent-update';
|
|
57
58
|
parsingError: 'parsing-error';
|
|
58
59
|
notImplemented: 'ENOSYS';
|
|
60
|
+
isEndless: 'is-endless';
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
/**
|
|
@@ -99,6 +101,11 @@ declare namespace web3n.files {
|
|
|
99
101
|
*/
|
|
100
102
|
size?: number;
|
|
101
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Flag indicating if file is an endless (unknown place of end) stream.
|
|
106
|
+
*/
|
|
107
|
+
isEndless?: boolean;
|
|
108
|
+
|
|
102
109
|
/**
|
|
103
110
|
* Last content modification time stamp.
|
|
104
111
|
* If such information cannot be provided, this field will be absent.
|
|
@@ -152,12 +159,6 @@ declare namespace web3n.files {
|
|
|
152
159
|
getPosition(): Promise<number>;
|
|
153
160
|
}
|
|
154
161
|
|
|
155
|
-
interface FileSection {
|
|
156
|
-
hasContent: boolean;
|
|
157
|
-
ofs: number;
|
|
158
|
-
len: number;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
162
|
interface LayoutSection {
|
|
162
163
|
src: 'new' | 'base' | 'empty';
|
|
163
164
|
ofs: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { StorageGetter,
|
|
1
|
+
import { StorageGetter, FolderInJSON } from '../../../../lib-client/3nstorage/xsp-fs/common';
|
|
2
2
|
import { AsyncSBoxCryptor } from 'xsp-files';
|
|
3
3
|
import { MsgOnDisk } from '../msg-on-disk';
|
|
4
4
|
declare type ReadonlyFS = web3n.files.ReadonlyFS;
|
|
5
|
-
export declare function fsForAttachments(msg: MsgOnDisk, rootJson:
|
|
5
|
+
export declare function fsForAttachments(msg: MsgOnDisk, rootJson: FolderInJSON, storages: StorageGetter, cryptor: AsyncSBoxCryptor): ReadonlyFS;
|
|
6
6
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2016 - 2019 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2016 - 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.fsForAttachments = void 0;
|
|
19
20
|
const common_1 = require("../../../../lib-client/3nstorage/xsp-fs/common");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JsonKeyShort } from '../../../lib-common/jwkeys';
|
|
2
|
-
import {
|
|
2
|
+
import { FolderInJSON } from '../../../lib-client/3nstorage/xsp-fs/common';
|
|
3
3
|
import * as confApi from '../../../lib-common/service-api/asmail/config';
|
|
4
4
|
/**
|
|
5
5
|
* Metadata for message that uses established key pair.
|
|
@@ -24,7 +24,7 @@ export interface MsgEnvelope {
|
|
|
24
24
|
'Msg Type': string;
|
|
25
25
|
'Subject'?: string;
|
|
26
26
|
'Body': MainBody;
|
|
27
|
-
'Attachments'?:
|
|
27
|
+
'Attachments'?: FolderInJSON;
|
|
28
28
|
'Flow Params': FlowParams;
|
|
29
29
|
'From': string;
|
|
30
30
|
'To'?: string[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2015 - 2018, 2020 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2015 - 2018, 2020, 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,6 +13,7 @@
|
|
|
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
|
Object.freeze(exports);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as confApi from '../../../lib-common/service-api/asmail/config';
|
|
2
2
|
import { MsgEnvelope, MainBody, SuggestedNextKeyPair, SendingParams } from './common';
|
|
3
3
|
import { AsyncSBoxCryptor, ObjSource } from 'xsp-files';
|
|
4
|
-
import {
|
|
4
|
+
import { FolderInJSON } from '../../../lib-client/3nstorage/xsp-fs/common';
|
|
5
5
|
import { MsgKeyRole } from '../keyring';
|
|
6
6
|
export { SuggestedNextKeyPair } from './common';
|
|
7
7
|
export declare class OpenedMsg {
|
|
@@ -18,6 +18,6 @@ export declare class OpenedMsg {
|
|
|
18
18
|
get msgCount(): number;
|
|
19
19
|
get nextSendingParams(): SendingParams | undefined;
|
|
20
20
|
get introCryptoCerts(): confApi.p.initPubKey.Certs;
|
|
21
|
-
get attachmentsJSON():
|
|
21
|
+
get attachmentsJSON(): FolderInJSON | undefined;
|
|
22
22
|
}
|
|
23
23
|
export declare function openMsg(msgId: string, mainObjId: string, mainObj: ObjSource, headerOfs: number, fKey: Uint8Array, cryptor: AsyncSBoxCryptor): Promise<OpenedMsg>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2015 - 2020 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2015 - 2020, 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.openMsg = exports.OpenedMsg = void 0;
|
|
19
20
|
const buffer_utils_1 = require("../../../lib-common/buffer-utils");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AsyncSBoxCryptor, ObjSource } from 'xsp-files';
|
|
2
2
|
import * as delivApi from '../../../lib-common/service-api/asmail/delivery';
|
|
3
|
-
import {
|
|
3
|
+
import { FolderInJSON } from '../../../lib-client/3nstorage/xsp-fs/common';
|
|
4
4
|
import * as confApi from '../../../lib-common/service-api/asmail/config';
|
|
5
5
|
import { MsgEnvelope, SuggestedNextKeyPair, SendingParams } from './common';
|
|
6
6
|
import { Encryptor } from '../../../lib-common/async-cryptor-wrap';
|
|
@@ -24,7 +24,7 @@ export interface PackJSON {
|
|
|
24
24
|
}
|
|
25
25
|
export interface MsgObj {
|
|
26
26
|
json?: any;
|
|
27
|
-
folder?:
|
|
27
|
+
folder?: FolderInJSON;
|
|
28
28
|
file?: PathInMsg;
|
|
29
29
|
/**
|
|
30
30
|
* This is object's id in the message
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2015 - 2018, 2020 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2015 - 2018, 2020, 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.MsgPacker = void 0;
|
|
19
20
|
const ecma_nacl_1 = require("ecma-nacl");
|
|
@@ -139,7 +140,7 @@ class MsgPacker {
|
|
|
139
140
|
};
|
|
140
141
|
}
|
|
141
142
|
async addFolderInto(outerFolder, fName, fs, fsPath) {
|
|
142
|
-
const folder = { nodes: {} };
|
|
143
|
+
const folder = { nodes: {}, ctime: outerFolder.ctime };
|
|
143
144
|
const list = await fs.listFolder('.');
|
|
144
145
|
for (const entry of list) {
|
|
145
146
|
const fName = entry.name;
|
|
@@ -282,7 +283,7 @@ class MsgPacker {
|
|
|
282
283
|
throw new Error(`Attachments are already set.`);
|
|
283
284
|
}
|
|
284
285
|
// attachments folder json to insert into main
|
|
285
|
-
const attachments = { nodes: {} };
|
|
286
|
+
const attachments = { nodes: {}, ctime: Date.now() };
|
|
286
287
|
// populate attachments json
|
|
287
288
|
const path = { start: 'attachments', path: [] };
|
|
288
289
|
if (att.container && !attachments_container_1.isContainerEmpty(att.container)) {
|
|
@@ -346,7 +347,7 @@ class MsgPacker {
|
|
|
346
347
|
}
|
|
347
348
|
const msgKeyPack = await msgKeyEnc.pack(obj.key);
|
|
348
349
|
const bytes = buffer_utils_1.utf8.pack(JSON.stringify(obj.json));
|
|
349
|
-
const segWriter = await xsp_files_1.makeSegmentsWriter(obj.key, xsp_files_1.idToHeaderNonce(obj.id), 0, { type: 'new', segSize: this.segSizeIn256bs }, random.bytes, cryptor);
|
|
350
|
+
const segWriter = await xsp_files_1.makeSegmentsWriter(obj.key, xsp_files_1.idToHeaderNonce(obj.id), 0, { type: 'new', segSize: this.segSizeIn256bs, payloadFormat: 1 }, random.bytes, cryptor);
|
|
350
351
|
// make source that inserts message key pack into header
|
|
351
352
|
return makeMainObjSrc(msgKeyPack, bytes, segWriter);
|
|
352
353
|
}
|
|
@@ -412,7 +413,7 @@ class MsgPacker {
|
|
|
412
413
|
segWriter = await xsp_files_1.makeSegmentsWriter(obj.key, xsp_files_1.idToHeaderNonce(obj.id), 0, { type: 'restart', header }, random.bytes, cryptor);
|
|
413
414
|
}
|
|
414
415
|
else {
|
|
415
|
-
segWriter = await xsp_files_1.makeSegmentsWriter(obj.key, xsp_files_1.idToHeaderNonce(obj.id), 0, { type: 'new', segSize: this.segSizeIn256bs }, random.bytes, cryptor);
|
|
416
|
+
segWriter = await xsp_files_1.makeSegmentsWriter(obj.key, xsp_files_1.idToHeaderNonce(obj.id), 0, { type: 'new', segSize: this.segSizeIn256bs, payloadFormat: 1 }, random.bytes, cryptor);
|
|
416
417
|
}
|
|
417
418
|
// make object source
|
|
418
419
|
let src;
|
package/build/core/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { FactoryOfFSs } from './storage';
|
|
|
2
2
|
import { makeCryptor } from '../lib-client/cryptor/cryptor';
|
|
3
3
|
import { NetClient } from '../lib-client/request-utils';
|
|
4
4
|
import { ServiceLocatorMaker } from '../lib-client/service-locator';
|
|
5
|
-
declare type
|
|
5
|
+
declare type RequestedCAPs = web3n.caps.common.RequestedCAPs;
|
|
6
6
|
declare type W3N = web3n.caps.common.W3N;
|
|
7
7
|
export interface CoreConf {
|
|
8
8
|
dataDir: string;
|
|
@@ -29,7 +29,7 @@ export declare class Core {
|
|
|
29
29
|
private initForNewUser;
|
|
30
30
|
private initForExistingUserWithoutCache;
|
|
31
31
|
private initForExistingUserWithCache;
|
|
32
|
-
makeCAPsForApp(appDomain: string,
|
|
32
|
+
makeCAPsForApp(appDomain: string, requestedCAPs: RequestedCAPs): {
|
|
33
33
|
caps: W3N;
|
|
34
34
|
close: () => void;
|
|
35
35
|
};
|
package/build/core/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2015 -
|
|
3
|
+
Copyright (C) 2015 - 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
|
|
@@ -30,7 +30,6 @@ const operators_1 = require("rxjs/operators");
|
|
|
30
30
|
const app_files_1 = require("./app-files");
|
|
31
31
|
const ASMAIL_APP_NAME = 'computer.3nweb.core.asmail';
|
|
32
32
|
const MAILERID_APP_NAME = 'computer.3nweb.core.mailerid';
|
|
33
|
-
const STARTUP_APP_DOMAIN = 'startup.3nweb.computer';
|
|
34
33
|
class Core {
|
|
35
34
|
constructor(makeNet, makeResolver, makeCryptor, appDirs, logger, signUpUrl) {
|
|
36
35
|
this.makeNet = makeNet;
|
|
@@ -129,50 +128,47 @@ class Core {
|
|
|
129
128
|
return { coreInit, capsForStartup };
|
|
130
129
|
}
|
|
131
130
|
;
|
|
132
|
-
makeCAPsForApp(appDomain,
|
|
131
|
+
makeCAPsForApp(appDomain, requestedCAPs) {
|
|
133
132
|
if (!this.isInitialized || this.closingProc) {
|
|
134
133
|
throw new Error(`Core is either not yet initialized, or is already closed.`);
|
|
135
134
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
const mail = this.makeMailCAP(manifest);
|
|
141
|
-
const log = this.makeLogCAP(manifest);
|
|
142
|
-
const mailerid = this.makeMailerIdCAP(manifest);
|
|
135
|
+
const { storage, close } = this.makeStorageCAP(appDomain, requestedCAPs);
|
|
136
|
+
const mail = this.makeMailCAP(requestedCAPs);
|
|
137
|
+
const log = this.makeLogCAP(appDomain, requestedCAPs);
|
|
138
|
+
const mailerid = this.makeMailerIdCAP(requestedCAPs);
|
|
143
139
|
const caps = { mail, log, mailerid, storage };
|
|
144
140
|
return { caps, close };
|
|
145
141
|
}
|
|
146
142
|
;
|
|
147
|
-
makeStorageCAP(
|
|
148
|
-
if (
|
|
149
|
-
const { cap: storage, close } = this.storages.makeStorageCAP(
|
|
143
|
+
makeStorageCAP(appDomain, requestedCAPs) {
|
|
144
|
+
if (requestedCAPs.storage) {
|
|
145
|
+
const { cap: storage, close } = this.storages.makeStorageCAP(appDomain, makeStoragePolicy(appDomain, requestedCAPs));
|
|
150
146
|
return { storage, close };
|
|
151
147
|
}
|
|
152
148
|
else {
|
|
153
149
|
return { close: () => { } };
|
|
154
150
|
}
|
|
155
151
|
}
|
|
156
|
-
makeMailCAP(
|
|
157
|
-
if (
|
|
158
|
-
&& (
|
|
159
|
-
&& (
|
|
152
|
+
makeMailCAP(requestedCAPs) {
|
|
153
|
+
if (requestedCAPs.mail
|
|
154
|
+
&& (requestedCAPs.mail.receivingFrom === 'all')
|
|
155
|
+
&& (requestedCAPs.mail.sendingTo === 'all')) {
|
|
160
156
|
return this.asmail.makeASMailCAP();
|
|
161
157
|
}
|
|
162
158
|
else {
|
|
163
159
|
return undefined;
|
|
164
160
|
}
|
|
165
161
|
}
|
|
166
|
-
makeLogCAP(
|
|
167
|
-
if (
|
|
168
|
-
return (type, msg, e) => this.logger.appLog(type,
|
|
162
|
+
makeLogCAP(appDomain, requestedCAPs) {
|
|
163
|
+
if (requestedCAPs.log === 'all') {
|
|
164
|
+
return (type, msg, e) => this.logger.appLog(type, appDomain, msg, e);
|
|
169
165
|
}
|
|
170
166
|
else {
|
|
171
167
|
return undefined;
|
|
172
168
|
}
|
|
173
169
|
}
|
|
174
|
-
makeMailerIdCAP(
|
|
175
|
-
if (
|
|
170
|
+
makeMailerIdCAP(requestedCAPs) {
|
|
171
|
+
if (requestedCAPs.mailerid === true) {
|
|
176
172
|
return this.idManager.makeMailerIdCAP();
|
|
177
173
|
}
|
|
178
174
|
else {
|
|
@@ -215,24 +211,24 @@ class Core {
|
|
|
215
211
|
exports.Core = Core;
|
|
216
212
|
Object.freeze(Core.prototype);
|
|
217
213
|
Object.freeze(Core);
|
|
218
|
-
function makeStoragePolicy(
|
|
219
|
-
if (!
|
|
214
|
+
function makeStoragePolicy(appDomain, requestedCAPs) {
|
|
215
|
+
if (!requestedCAPs.storage) {
|
|
220
216
|
throw new Error(`Missing storage setting in app's manifest`);
|
|
221
217
|
}
|
|
222
|
-
const capReq =
|
|
218
|
+
const capReq = requestedCAPs.storage;
|
|
223
219
|
let policy;
|
|
224
220
|
if (capReq.appFS === 'default') {
|
|
225
221
|
policy = {
|
|
226
222
|
canOpenAppFS: singleDomainAppFSChecker({
|
|
227
|
-
domain:
|
|
223
|
+
domain: appDomain,
|
|
228
224
|
storage: 'synced-n-local'
|
|
229
225
|
})
|
|
230
226
|
};
|
|
231
227
|
}
|
|
232
228
|
else if (Array.isArray(capReq.appFS)) {
|
|
233
229
|
const okDomains = capReq.appFS
|
|
234
|
-
.filter(fsInfo => (fsInfo.domain ===
|
|
235
|
-
fsInfo.domain.endsWith('.' +
|
|
230
|
+
.filter(fsInfo => (fsInfo.domain === appDomain) ||
|
|
231
|
+
fsInfo.domain.endsWith('.' + appDomain))
|
|
236
232
|
.map(fsInfo => json_utils_1.copy(fsInfo));
|
|
237
233
|
policy = {
|
|
238
234
|
canOpenAppFS: severalDomainsAppFSChecker(okDomains)
|
|
@@ -36,13 +36,13 @@ function makeBadAppNameExc(appName) {
|
|
|
36
36
|
appName
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
-
function makeNotAllowedToOpenAppFSExc(
|
|
39
|
+
function makeNotAllowedToOpenAppFSExc(appFolder) {
|
|
40
40
|
return {
|
|
41
41
|
runtimeException: true,
|
|
42
42
|
type: 'storage',
|
|
43
43
|
storageSegment: 'app',
|
|
44
44
|
notAllowedToOpenFS: true,
|
|
45
|
-
appName
|
|
45
|
+
appName: reverseDomain(appFolder)
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
48
|
function makeNotAllowedToOpenUserFSExc(storageType) {
|
|
@@ -23,8 +23,6 @@ const processes_1 = require("../../../lib-common/processes");
|
|
|
23
23
|
const path_1 = require("path");
|
|
24
24
|
const obj_files_gc_1 = require("./obj-files-gc");
|
|
25
25
|
const obj_status_1 = require("./obj-status");
|
|
26
|
-
const operators_1 = require("rxjs/operators");
|
|
27
|
-
const utils_for_observables_1 = require("../../../lib-common/utils-for-observables");
|
|
28
26
|
const timed_cache_1 = require("../../../lib-common/timed-cache");
|
|
29
27
|
class ObjFiles {
|
|
30
28
|
constructor(folders, logError) {
|
|
@@ -141,12 +139,17 @@ class LocalObj {
|
|
|
141
139
|
}
|
|
142
140
|
const fPath = this.path(version);
|
|
143
141
|
const { obj, write$ } = await obj_on_disk_1.ObjOnDisk.createFileForWriteOfNewVersion(this.objId, version, fPath, encSub, undefined, this.objSegsGetterFromDisk);
|
|
144
|
-
|
|
145
|
-
|
|
142
|
+
try {
|
|
143
|
+
await write$.toPromise();
|
|
144
|
+
}
|
|
145
|
+
catch (err) {
|
|
146
146
|
if (this.verObjs.get(version) === obj) {
|
|
147
147
|
this.verObjs.delete(version);
|
|
148
148
|
}
|
|
149
|
-
|
|
149
|
+
throw err;
|
|
150
|
+
}
|
|
151
|
+
this.verObjs.set(version, obj);
|
|
152
|
+
await this.status.setNewCurrentVersion(version, obj.getBaseVersion());
|
|
150
153
|
this.scheduleGC(this);
|
|
151
154
|
}
|
|
152
155
|
isArchived() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2016 - 2020 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2016 - 2020, 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.ObjStatus = void 0;
|
|
19
20
|
const fs = require("../../../lib-common/async-fs-node");
|
|
@@ -63,7 +64,6 @@ class ObjStatus {
|
|
|
63
64
|
};
|
|
64
65
|
}
|
|
65
66
|
async setNewCurrentVersion(newVersion, baseVer) {
|
|
66
|
-
this.status.currentVersion = newVersion;
|
|
67
67
|
if (baseVer !== undefined) {
|
|
68
68
|
// base->diff links should be added before removals
|
|
69
69
|
addBaseToDiffLinkInStatus(this.status, newVersion, baseVer);
|
|
@@ -71,6 +71,7 @@ class ObjStatus {
|
|
|
71
71
|
if (typeof this.status.currentVersion === 'number') {
|
|
72
72
|
rmNonArchVersionsIn(this.status, this.status.currentVersion);
|
|
73
73
|
}
|
|
74
|
+
this.status.currentVersion = newVersion;
|
|
74
75
|
await this.saveProc.trigger();
|
|
75
76
|
}
|
|
76
77
|
async removeCurrentVersion(verObjs) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2016 - 2020 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2016 - 2020, 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.ObjStatus = void 0;
|
|
19
20
|
const processes_1 = require("../../../lib-common/processes");
|
|
@@ -184,7 +185,6 @@ function rmNonArchVersionsIn(status, ver) {
|
|
|
184
185
|
// status: ObjStatusInfo, newVersion: number, baseVer: number|undefined
|
|
185
186
|
// ): void {
|
|
186
187
|
// if (status.isArchived) { return; }
|
|
187
|
-
// status.versions.current = newVersion;
|
|
188
188
|
// if (status.syncState === 'synced') {
|
|
189
189
|
// status.syncState = 'unsynced';
|
|
190
190
|
// }
|
|
@@ -195,6 +195,7 @@ function rmNonArchVersionsIn(status, ver) {
|
|
|
195
195
|
// if (status.versions.current) {
|
|
196
196
|
// rmNonArchVersionsIn(status, status.versions.current);
|
|
197
197
|
// }
|
|
198
|
+
// status.versions.current = newVersion;
|
|
198
199
|
// }
|
|
199
200
|
// export function addConflictingRemoteVersionTo(
|
|
200
201
|
// status: ObjStatusInfo, conflictVersion: number
|
|
@@ -147,7 +147,7 @@ var sinkShowLayout;
|
|
|
147
147
|
}
|
|
148
148
|
function unpackLayout(msg) {
|
|
149
149
|
return {
|
|
150
|
-
base: protobuf_msg_1.
|
|
150
|
+
base: protobuf_msg_1.valOfOptInt(msg.base),
|
|
151
151
|
sections: protobuf_msg_1.fixArray(msg.sections).map(({ src, ofs, len }) => ({
|
|
152
152
|
src, ofs: protobuf_msg_1.fixInt(ofs), len: protobuf_msg_1.fixInt(len)
|
|
153
153
|
}))
|
|
@@ -42,6 +42,10 @@ export declare namespace vGetXAttr {
|
|
|
42
42
|
bytes?: Value<Buffer>;
|
|
43
43
|
}
|
|
44
44
|
const replyType: ProtoType<Reply>;
|
|
45
|
+
function unpackReply(buf: EnvelopeBody): {
|
|
46
|
+
attr: any;
|
|
47
|
+
version: number;
|
|
48
|
+
};
|
|
45
49
|
function wrapService(fn: ReadonlyFileVersionedAPI['getXAttr']): ExposedFn;
|
|
46
50
|
function makeCaller(caller: Caller, objPath: string[]): ReadonlyFileVersionedAPI['getXAttr'];
|
|
47
51
|
}
|
|
@@ -214,8 +214,8 @@ var getXAttr;
|
|
|
214
214
|
getXAttr.wrapService = wrapService;
|
|
215
215
|
function makeCaller(caller, objPath) {
|
|
216
216
|
const path = objPath.concat('getXAttr');
|
|
217
|
-
return
|
|
218
|
-
.startPromiseCall(path,
|
|
217
|
+
return xaName => caller
|
|
218
|
+
.startPromiseCall(path, requestType.pack({ xaName }))
|
|
219
219
|
.then(unpackXAttrValue);
|
|
220
220
|
}
|
|
221
221
|
getXAttr.makeCaller = makeCaller;
|
|
@@ -413,6 +413,20 @@ var vGetXAttr;
|
|
|
413
413
|
(function (vGetXAttr) {
|
|
414
414
|
const requestType = makeFileType('GetXAttrRequestBody');
|
|
415
415
|
vGetXAttr.replyType = makeFileType('VersionedGetXAttrReplyBody');
|
|
416
|
+
function unpackReply(buf) {
|
|
417
|
+
const { json, str, bytes, version: v } = vGetXAttr.replyType.unpack(buf);
|
|
418
|
+
const version = protobuf_msg_1.fixInt(v);
|
|
419
|
+
if (bytes) {
|
|
420
|
+
return { version, attr: protobuf_msg_1.valOf(bytes) };
|
|
421
|
+
}
|
|
422
|
+
else if (str) {
|
|
423
|
+
return { version, attr: protobuf_msg_1.valOf(str) };
|
|
424
|
+
}
|
|
425
|
+
else {
|
|
426
|
+
return { version, attr: protobuf_msg_1.valOfOptJson(json) };
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
vGetXAttr.unpackReply = unpackReply;
|
|
416
430
|
function wrapService(fn) {
|
|
417
431
|
return buf => {
|
|
418
432
|
const { xaName } = requestType.unpack(buf);
|
|
@@ -436,19 +450,7 @@ var vGetXAttr;
|
|
|
436
450
|
const path = objPath.concat('getXAttr');
|
|
437
451
|
return () => caller
|
|
438
452
|
.startPromiseCall(path, undefined)
|
|
439
|
-
.then(
|
|
440
|
-
const { json, str, bytes, version: v } = vGetXAttr.replyType.unpack(buf);
|
|
441
|
-
const version = protobuf_msg_1.fixInt(v);
|
|
442
|
-
if (bytes) {
|
|
443
|
-
return { version, attr: protobuf_msg_1.valOf(bytes) };
|
|
444
|
-
}
|
|
445
|
-
else if (str) {
|
|
446
|
-
return { version, attr: protobuf_msg_1.valOf(str) };
|
|
447
|
-
}
|
|
448
|
-
else {
|
|
449
|
-
return { version, attr: protobuf_msg_1.valOfOptJson(json) };
|
|
450
|
-
}
|
|
451
|
-
});
|
|
453
|
+
.then(unpackReply);
|
|
452
454
|
}
|
|
453
455
|
vGetXAttr.makeCaller = makeCaller;
|
|
454
456
|
})(vGetXAttr = exports.vGetXAttr || (exports.vGetXAttr = {}));
|
|
@@ -1043,7 +1043,7 @@ var vGetXAttr;
|
|
|
1043
1043
|
const ipcPath = objPath.concat('getXAttr');
|
|
1044
1044
|
return (path, xaName) => caller
|
|
1045
1045
|
.startPromiseCall(ipcPath, getXAttr.requestType.pack({ path, xaName }))
|
|
1046
|
-
.then(
|
|
1046
|
+
.then(file.vGetXAttr.unpackReply);
|
|
1047
1047
|
}
|
|
1048
1048
|
vGetXAttr.makeCaller = makeCaller;
|
|
1049
1049
|
})(vGetXAttr || (vGetXAttr = {}));
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Attrs } from "./node-persistence";
|
|
3
|
+
export declare class CommonAttrs {
|
|
4
|
+
ctime: number;
|
|
5
|
+
mtime: number;
|
|
6
|
+
constructor(ctime: number, mtime: number);
|
|
7
|
+
static makeForTimeNow(): CommonAttrs;
|
|
8
|
+
static fromAttrs(attrs: Attrs): CommonAttrs;
|
|
9
|
+
static readonly PACK_LEN: number;
|
|
10
|
+
static parse(bytes: Uint8Array): CommonAttrs;
|
|
11
|
+
pack(): Buffer;
|
|
12
|
+
copy(): CommonAttrs;
|
|
13
|
+
updateMTime(): void;
|
|
14
|
+
}
|
|
15
|
+
export declare class XAttrs {
|
|
16
|
+
private readonly attrs;
|
|
17
|
+
private constructor();
|
|
18
|
+
static makeEmpty(): XAttrs;
|
|
19
|
+
static parseFrom(sections: Uint8Array[]): XAttrs;
|
|
20
|
+
copy(): XAttrs;
|
|
21
|
+
makeUpdated(changes: XAttrsChanges): XAttrs;
|
|
22
|
+
get(xaName: string): any;
|
|
23
|
+
list(): string[];
|
|
24
|
+
get isEmpty(): boolean;
|
|
25
|
+
pack(): Uint8Array[] | undefined;
|
|
26
|
+
}
|
|
27
|
+
declare type XAttrsChanges = web3n.files.XAttrsChanges;
|
|
28
|
+
export {};
|