core-3nweb-client-lib 0.26.1 → 0.27.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/api-defs/asmail.d.ts +1 -1
- package/build/api-defs/files.d.ts +281 -75
- package/build/core/app-files.js +7 -7
- package/build/core/asmail/config/common.js +2 -2
- package/build/core/asmail/config/index.js +2 -2
- package/build/core/asmail/config/published-intro-key.js +1 -1
- package/build/core/asmail/delivery/common.js +7 -7
- package/build/core/asmail/delivery/index.js +5 -5
- package/build/core/asmail/delivery/msg.js +4 -4
- package/build/core/asmail/delivery/per-recipient-wip.js +1 -1
- package/build/core/asmail/inbox/attachments/fs.d.ts +2 -1
- package/build/core/asmail/inbox/attachments/fs.js +9 -4
- package/build/core/asmail/inbox/cached-msgs.js +1 -1
- package/build/core/asmail/inbox/inbox-events.js +4 -4
- package/build/core/asmail/inbox/index.js +10 -10
- package/build/core/asmail/inbox/msg-downloader.js +1 -1
- package/build/core/asmail/inbox/msg-indexing.js +1 -1
- package/build/core/asmail/inbox/msg-on-disk.js +5 -5
- package/build/core/asmail/index.d.ts +3 -3
- package/build/core/asmail/index.js +13 -8
- package/build/core/asmail/key-verification.js +5 -5
- package/build/core/asmail/keyring/common.js +7 -6
- package/build/core/asmail/keyring/correspondent-keys.js +8 -7
- package/build/core/asmail/keyring/id-to-email-map.js +2 -1
- package/build/core/asmail/keyring/index.d.ts +7 -8
- package/build/core/asmail/keyring/index.js +15 -14
- package/build/core/asmail/keyring/keyring-storage.js +2 -1
- package/build/core/asmail/msg/opener.js +3 -3
- package/build/core/asmail/msg/packer.js +13 -13
- package/build/core/asmail/sending-params/own-params.js +2 -2
- package/build/core/asmail/sending-params/params-from-others.js +1 -1
- package/build/core/id-manager/index.d.ts +43 -0
- package/build/core/{id-manager.js → id-manager/index.js} +36 -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.d.ts +2 -1
- package/build/core/index.js +31 -33
- package/build/core/sign-in.d.ts +1 -2
- package/build/core/sign-in.js +8 -17
- package/build/core/sign-up.d.ts +2 -0
- package/build/core/sign-up.js +11 -10
- package/build/core/storage/common/json-saving.js +2 -2
- package/build/core/storage/common/obj-info-file.d.ts +12 -4
- package/build/core/storage/common/obj-info-file.js +66 -34
- package/build/core/storage/common/utils.d.ts +2 -0
- package/build/core/storage/common/utils.js +32 -0
- package/build/core/storage/index.d.ts +5 -17
- package/build/core/storage/index.js +78 -119
- package/build/core/storage/local/obj-files-gc.d.ts +2 -0
- package/build/core/storage/local/obj-files-gc.js +49 -37
- package/build/core/storage/local/obj-files.d.ts +4 -7
- package/build/core/storage/local/obj-files.js +7 -10
- package/build/core/storage/local/obj-status.d.ts +12 -6
- package/build/core/storage/local/obj-status.js +24 -9
- package/build/core/storage/local/storage.d.ts +10 -7
- package/build/core/storage/local/storage.js +29 -18
- package/build/core/storage/synced/downloader.js +1 -1
- package/build/core/storage/synced/obj-files-gc.d.ts +1 -0
- package/build/core/storage/synced/obj-files-gc.js +76 -39
- package/build/core/storage/synced/obj-files.d.ts +50 -36
- package/build/core/storage/synced/obj-files.js +201 -162
- package/build/core/storage/synced/obj-status.d.ts +99 -86
- package/build/core/storage/synced/obj-status.js +520 -251
- package/build/core/storage/synced/remote-events.d.ts +11 -12
- package/build/core/storage/synced/remote-events.js +73 -56
- package/build/core/storage/synced/storage.d.ts +24 -10
- package/build/core/storage/synced/storage.js +147 -47
- package/build/core/storage/synced/upload-header-file.d.ts +4 -0
- package/build/core/storage/synced/upload-header-file.js +64 -0
- package/build/core/storage/synced/upsyncer.d.ts +12 -7
- package/build/core/storage/synced/upsyncer.js +210 -280
- package/build/core/storage/system-folders/apps-data.d.ts +16 -0
- package/build/core/storage/system-folders/apps-data.js +110 -0
- package/build/core/storage/system-folders/index.d.ts +18 -0
- package/build/core/storage/system-folders/index.js +77 -0
- package/build/core-ipc/common-caps.js +3 -3
- package/build/core-ipc/generic.js +8 -8
- package/build/core-ipc/startup-caps.js +2 -2
- package/build/cryptors.js +6 -2
- package/build/ipc-via-protobuf/asmail-cap.js +58 -57
- package/build/ipc-via-protobuf/bytes.js +16 -17
- package/build/ipc-via-protobuf/connector-clients-side.d.ts +1 -0
- package/build/ipc-via-protobuf/connector-clients-side.js +14 -15
- package/build/ipc-via-protobuf/connector-services-side.js +10 -10
- package/build/ipc-via-protobuf/connector.js +4 -4
- package/build/ipc-via-protobuf/file.d.ts +48 -12
- package/build/ipc-via-protobuf/file.js +474 -126
- package/build/ipc-via-protobuf/fs.d.ts +8 -0
- package/build/ipc-via-protobuf/fs.js +577 -142
- package/build/ipc-via-protobuf/log-cap.js +2 -2
- package/build/ipc-via-protobuf/mailerid.js +3 -3
- package/build/ipc-via-protobuf/protobuf-msg.d.ts +1 -0
- package/build/ipc-via-protobuf/protobuf-msg.js +11 -7
- package/build/ipc-via-protobuf/startup-cap.js +21 -21
- package/build/ipc-via-protobuf/storage-cap.js +12 -12
- package/build/ipc.js +7 -2
- package/build/lib-client/3nstorage/exceptions.d.ts +16 -1
- package/build/lib-client/3nstorage/exceptions.js +21 -3
- package/build/lib-client/3nstorage/service.d.ts +21 -3
- package/build/lib-client/3nstorage/service.js +128 -46
- package/build/lib-client/3nstorage/util/file-based-json.d.ts +2 -1
- package/build/lib-client/3nstorage/util/file-based-json.js +3 -2
- 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/attrs.js +17 -17
- package/build/lib-client/3nstorage/xsp-fs/common.d.ts +44 -19
- package/build/lib-client/3nstorage/xsp-fs/common.js +30 -19
- package/build/lib-client/3nstorage/xsp-fs/file-node.d.ts +1 -0
- package/build/lib-client/3nstorage/xsp-fs/file-node.js +17 -13
- package/build/lib-client/3nstorage/xsp-fs/file.d.ts +31 -6
- package/build/lib-client/3nstorage/xsp-fs/file.js +73 -25
- package/build/lib-client/3nstorage/xsp-fs/folder-node-serialization.js +4 -4
- package/build/lib-client/3nstorage/xsp-fs/folder-node.d.ts +32 -13
- package/build/lib-client/3nstorage/xsp-fs/folder-node.js +752 -192
- package/build/lib-client/3nstorage/xsp-fs/fs.d.ts +35 -4
- package/build/lib-client/3nstorage/xsp-fs/fs.js +236 -119
- package/build/lib-client/3nstorage/xsp-fs/link-node.d.ts +1 -0
- package/build/lib-client/3nstorage/xsp-fs/link-node.js +7 -2
- package/build/lib-client/3nstorage/xsp-fs/node-in-fs.d.ts +30 -29
- package/build/lib-client/3nstorage/xsp-fs/node-in-fs.js +232 -127
- package/build/lib-client/3nstorage/xsp-fs/node-persistence.d.ts +1 -1
- package/build/lib-client/3nstorage/xsp-fs/node-persistence.js +17 -18
- package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v1.js +3 -3
- package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v2.js +53 -53
- package/build/lib-client/3nweb-signup.js +4 -4
- package/build/lib-client/asmail/recipient.js +15 -15
- package/build/lib-client/asmail/sender.js +22 -22
- package/build/lib-client/asmail/service-config.js +3 -3
- package/build/lib-client/cryptor/cryptor-in-worker.js +18 -16
- package/build/lib-client/cryptor/cryptor-wasm.js +1 -1
- package/build/lib-client/cryptor/cryptor.js +4 -2
- package/build/lib-client/cryptor/cryptor.wasm +0 -0
- package/build/lib-client/cryptor/in-proc-js.js +1 -1
- package/build/lib-client/cryptor/in-proc-wasm.js +6 -6
- package/build/lib-client/cryptor/worker-js.js +2 -2
- package/build/lib-client/cryptor/worker-wasm.js +2 -2
- package/build/lib-client/files-select.js +1 -1
- package/build/lib-client/files.d.ts +1 -1
- package/build/lib-client/files.js +71 -6
- package/build/lib-client/fs-collection.js +1 -1
- package/build/lib-client/fs-sync-utils.d.ts +5 -0
- package/build/lib-client/fs-sync-utils.js +61 -0
- package/build/lib-client/fs-view.d.ts +14 -0
- package/build/lib-client/fs-view.js +33 -0
- package/build/lib-client/key-derivation.js +1 -1
- package/build/lib-client/local-files/dev-file-sink.js +9 -9
- package/build/lib-client/local-files/dev-file-src.js +2 -2
- package/build/lib-client/local-files/device-fs.d.ts +1 -1
- package/build/lib-client/local-files/device-fs.js +56 -54
- package/build/lib-client/logging/log-to-file.d.ts +1 -1
- package/build/lib-client/logging/log-to-file.js +7 -7
- package/build/lib-client/mailer-id/login.js +7 -7
- package/build/lib-client/mailer-id/provisioner.js +12 -12
- package/build/lib-client/objs-on-disk/file-writing-proc.js +3 -3
- package/build/lib-client/objs-on-disk/obj-folders.js +31 -31
- package/build/lib-client/objs-on-disk/obj-on-disk.d.ts +13 -2
- package/build/lib-client/objs-on-disk/obj-on-disk.js +24 -9
- package/build/lib-client/request-utils.d.ts +1 -0
- package/build/lib-client/request-utils.js +13 -13
- package/build/lib-client/server-events.d.ts +3 -3
- package/build/lib-client/server-events.js +9 -8
- package/build/lib-client/service-locator.js +10 -10
- package/build/lib-client/user-with-mid-session.d.ts +2 -1
- package/build/lib-client/user-with-mid-session.js +14 -8
- package/build/lib-client/user-with-pkl-session.js +25 -25
- package/build/lib-client/ws-utils.js +2 -2
- package/build/lib-common/async-cryptor-wrap.js +4 -4
- package/build/lib-common/async-fs-node.d.ts +5 -3
- package/build/lib-common/async-fs-node.js +17 -17
- package/build/lib-common/byte-streaming/pipe.js +1 -1
- package/build/lib-common/byte-streaming/wrapping.js +13 -13
- package/build/lib-common/canonical-address.js +1 -1
- package/build/lib-common/exceptions/error.d.ts +1 -0
- package/build/lib-common/exceptions/error.js +7 -6
- package/build/lib-common/exceptions/file.d.ts +4 -2
- package/build/lib-common/exceptions/file.js +24 -54
- package/build/lib-common/ipc/generic-ipc.js +5 -4
- 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.d.ts +19 -0
- package/build/lib-common/objs-on-disk/file-layout.js +130 -12
- package/build/lib-common/objs-on-disk/obj-file.d.ts +13 -2
- package/build/lib-common/objs-on-disk/obj-file.js +96 -35
- 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/objs-on-disk/v1-obj-file-format.js +14 -14
- package/build/lib-common/processes/labelled-exec-pools.d.ts +1 -1
- package/build/lib-common/processes/labelled-exec-pools.js +1 -1
- package/build/lib-common/processes/pressure.js +2 -2
- package/build/lib-common/processes/synced.js +1 -1
- package/build/lib-common/processes/timeout.js +2 -2
- package/build/lib-common/random-node.js +7 -7
- package/build/lib-common/service-api/3nstorage/owner.d.ts +101 -42
- package/build/lib-common/service-api/3nstorage/owner.js +83 -40
- 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-common/timed-cache.d.ts +1 -0
- package/build/lib-common/timed-non-weak-cache.d.ts +1 -0
- package/build/lib-common/timed-non-weak-cache.js +11 -0
- package/build/lib-common/utils-for-observables.js +4 -4
- package/build/lib-common/weak-cache.d.ts +1 -0
- package/build/lib-common/weak-cache.js +12 -1
- package/build/lib-index.d.ts +2 -1
- package/build/lib-index.js +10 -7
- package/build/protos/asmail.proto.js +12955 -7496
- package/build/protos/file.proto.js +4867 -2744
- package/build/protos/fs.proto.js +9227 -3768
- package/package.json +7 -5
- package/protos/file.proto +91 -19
- package/protos/fs.proto +107 -8
- package/build/core/id-manager.d.ts +0 -46
package/build/core/index.js
CHANGED
|
@@ -42,38 +42,45 @@ class Core {
|
|
|
42
42
|
this.closingProc = undefined;
|
|
43
43
|
this.initForNewUser = async (u) => {
|
|
44
44
|
// 1) init of id manager without setting fs
|
|
45
|
-
const
|
|
46
|
-
if (!
|
|
45
|
+
const stepTwo = await id_manager_1.IdManager.initWithoutStore(u.address, this.makeResolver('mailerid'), () => this.makeNet(), this.logger.logError, this.logger.logWarning);
|
|
46
|
+
if (!stepTwo) {
|
|
47
|
+
throw new Error(`MailerId server doesn't recognize identity ${u.address}`);
|
|
48
|
+
}
|
|
49
|
+
// 2) complete id manager login, without use of fs
|
|
50
|
+
const idManagerInit = await stepTwo(u.midSKey.default);
|
|
51
|
+
if (!idManagerInit) {
|
|
47
52
|
throw new Error(`Failed to provision MailerId identity`);
|
|
48
53
|
}
|
|
49
|
-
|
|
50
|
-
|
|
54
|
+
const { idManager, setupManagerStorage } = idManagerInit;
|
|
55
|
+
// 3) initialize all storages
|
|
56
|
+
const storesUp = await this.storages.initFreshForNewUser(u.address, idManager.getSigner, u.storeParams, u.storeSKey, this.makeNet, this.makeResolver('3nstorage'), this.logger.logError);
|
|
51
57
|
if (!storesUp) {
|
|
52
58
|
throw new Error(`Stores failed to initialize`);
|
|
53
59
|
}
|
|
54
60
|
// 3) give id manager fs, in which it will record labeled key(s)
|
|
55
|
-
await
|
|
61
|
+
await setupManagerStorage(await this.storages.makeSyncedFSForApp(MAILERID_APP_NAME), [u.midSKey.labeled]);
|
|
56
62
|
return idManager;
|
|
57
63
|
};
|
|
58
64
|
this.initForExistingUserWithoutCache = async (address) => {
|
|
59
65
|
// 1) init of id manager without setting fs
|
|
60
|
-
const stepTwo = await id_manager_1.IdManager.initWithoutStore(address, this.makeResolver('mailerid'), this.makeNet, this.logger.logError, this.logger.logWarning);
|
|
66
|
+
const stepTwo = await id_manager_1.IdManager.initWithoutStore(address, this.makeResolver('mailerid'), () => this.makeNet(), this.logger.logError, this.logger.logWarning);
|
|
61
67
|
if (!stepTwo) {
|
|
62
68
|
return;
|
|
63
69
|
}
|
|
64
70
|
return async (midLoginKey, storageKey) => {
|
|
65
71
|
// 2) complete id manager login, without use of fs
|
|
66
|
-
const
|
|
67
|
-
if (!
|
|
72
|
+
const idManagerInit = await stepTwo(midLoginKey);
|
|
73
|
+
if (!idManagerInit) {
|
|
68
74
|
return;
|
|
69
75
|
}
|
|
76
|
+
const { idManager, setupManagerStorage } = idManagerInit;
|
|
70
77
|
// 3) initialize all storages
|
|
71
78
|
const storeDone = await this.storages.initFromRemote(address, idManager.getSigner, storageKey, this.makeNet, this.makeResolver('3nstorage'), this.logger.logError);
|
|
72
79
|
if (!storeDone) {
|
|
73
80
|
return;
|
|
74
81
|
}
|
|
75
82
|
// 4) complete initialization of id manager
|
|
76
|
-
await
|
|
83
|
+
await setupManagerStorage(await this.storages.makeSyncedFSForApp(MAILERID_APP_NAME));
|
|
77
84
|
return idManager;
|
|
78
85
|
};
|
|
79
86
|
};
|
|
@@ -82,21 +89,12 @@ class Core {
|
|
|
82
89
|
if (!completeStorageInit) {
|
|
83
90
|
return;
|
|
84
91
|
}
|
|
85
|
-
const idManager = await id_manager_1.IdManager.
|
|
86
|
-
if (idManager) {
|
|
87
|
-
|
|
88
|
-
await idManager.setStorages(undefined, await this.storages.makeSyncedFSForApp(MAILERID_APP_NAME));
|
|
89
|
-
return (res ? idManager : undefined);
|
|
92
|
+
const idManager = await id_manager_1.IdManager.initFromCachedStore(address, await this.storages.makeSyncedFSForApp(MAILERID_APP_NAME), this.makeResolver('mailerid'), () => this.makeNet(), this.logger.logError, this.logger.logWarning);
|
|
93
|
+
if (!idManager) {
|
|
94
|
+
return;
|
|
90
95
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (!idManager) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
const res = await completeStorageInit(idManager.getSigner);
|
|
97
|
-
await idManager.setStorages(await this.storages.makeLocalFSForApp(MAILERID_APP_NAME), await this.storages.makeSyncedFSForApp(MAILERID_APP_NAME));
|
|
98
|
-
return (res ? idManager : undefined);
|
|
99
|
-
};
|
|
96
|
+
completeStorageInit(idManager.getSigner);
|
|
97
|
+
return idManager;
|
|
100
98
|
};
|
|
101
99
|
this.closeBroadcast = new rxjs_1.Subject();
|
|
102
100
|
this.close$ = this.closeBroadcast.asObservable();
|
|
@@ -106,13 +104,13 @@ class Core {
|
|
|
106
104
|
Object.seal(this);
|
|
107
105
|
}
|
|
108
106
|
static make(conf, makeNet, makeResolver, makeCryptor) {
|
|
109
|
-
const dirs = app_files_1.appDirs(conf.dataDir);
|
|
110
|
-
const logger = log_to_file_1.makeLogger(dirs.getUtilFS());
|
|
107
|
+
const dirs = (0, app_files_1.appDirs)(conf.dataDir);
|
|
108
|
+
const logger = (0, log_to_file_1.makeLogger)(dirs.getUtilFS());
|
|
111
109
|
const core = new Core(makeNet, makeResolver, makeCryptor, dirs, logger, conf.signUpUrl);
|
|
112
110
|
return core;
|
|
113
111
|
}
|
|
114
112
|
start() {
|
|
115
|
-
const signUp = new sign_up_1.SignUp(this.signUpUrl, this.cryptor.cryptor, this.makeNet, this.appDirs.getUsersOnDisk, this.logger.logError);
|
|
113
|
+
const signUp = new sign_up_1.SignUp(this.signUpUrl, this.cryptor.cryptor, this.makeNet.bind(this), this.appDirs.getUsersOnDisk, this.logger.logError);
|
|
116
114
|
const signIn = new sign_in_1.SignIn(this.cryptor.cryptor, this.initForExistingUserWithoutCache, this.initForExistingUserWithCache, this.appDirs.getUsersOnDisk, this.logger.logError);
|
|
117
115
|
const capsForStartup = {
|
|
118
116
|
signUp: signUp.exposedService(),
|
|
@@ -120,10 +118,10 @@ class Core {
|
|
|
120
118
|
};
|
|
121
119
|
Object.freeze(capsForStartup);
|
|
122
120
|
const initFromSignUp$ = signUp.newUser$
|
|
123
|
-
.pipe(operators_1.mergeMap(this.initForNewUser, 1));
|
|
121
|
+
.pipe((0, operators_1.mergeMap)(this.initForNewUser, 1));
|
|
124
122
|
const initFromSignIn$ = signIn.existingUser$;
|
|
125
|
-
const coreInit = rxjs_1.merge(initFromSignIn$, initFromSignUp$)
|
|
126
|
-
.pipe(operators_1.take(1), operators_1.mergeMap(idManager => this.initCore(idManager), 1))
|
|
123
|
+
const coreInit = (0, rxjs_1.merge)(initFromSignIn$, initFromSignUp$)
|
|
124
|
+
.pipe((0, operators_1.take)(1), (0, operators_1.mergeMap)(idManager => this.initCore(idManager), 1))
|
|
127
125
|
.toPromise();
|
|
128
126
|
return { coreInit, capsForStartup };
|
|
129
127
|
}
|
|
@@ -201,7 +199,7 @@ class Core {
|
|
|
201
199
|
return this.idManager.getId();
|
|
202
200
|
}
|
|
203
201
|
catch (err) {
|
|
204
|
-
throw error_1.errWithCause(err, 'Failed to initialize core');
|
|
202
|
+
throw (0, error_1.errWithCause)(err, 'Failed to initialize core');
|
|
205
203
|
}
|
|
206
204
|
}
|
|
207
205
|
getStorages() {
|
|
@@ -229,7 +227,7 @@ function makeStoragePolicy(appDomain, requestedCAPs) {
|
|
|
229
227
|
const okDomains = capReq.appFS
|
|
230
228
|
.filter(fsInfo => (fsInfo.domain === appDomain) ||
|
|
231
229
|
fsInfo.domain.endsWith('.' + appDomain))
|
|
232
|
-
.map(fsInfo => json_utils_1.copy(fsInfo));
|
|
230
|
+
.map(fsInfo => (0, json_utils_1.copy)(fsInfo));
|
|
233
231
|
policy = {
|
|
234
232
|
canOpenAppFS: severalDomainsAppFSChecker(okDomains)
|
|
235
233
|
};
|
|
@@ -259,7 +257,7 @@ function makeStoragePolicy(appDomain, requestedCAPs) {
|
|
|
259
257
|
}
|
|
260
258
|
const noFS = () => false;
|
|
261
259
|
function singleDomainAppFSChecker(appFS) {
|
|
262
|
-
const revDomain = storage_1.reverseDomain(appFS.domain);
|
|
260
|
+
const revDomain = (0, storage_1.reverseDomain)(appFS.domain);
|
|
263
261
|
const allowedType = appFS.storage;
|
|
264
262
|
return (appFolder, type) => {
|
|
265
263
|
return (appFSTypeAllowed(allowedType, type) && (appFolder === revDomain));
|
|
@@ -286,7 +284,7 @@ function appFSTypeAllowed(allowed, type) {
|
|
|
286
284
|
}
|
|
287
285
|
function severalDomainsAppFSChecker(appFSs) {
|
|
288
286
|
const settings = appFSs.map(s => ({
|
|
289
|
-
revDomain: storage_1.reverseDomain(s.domain),
|
|
287
|
+
revDomain: (0, storage_1.reverseDomain)(s.domain),
|
|
290
288
|
storage: s.storage
|
|
291
289
|
}));
|
|
292
290
|
return (appFolder, type) => !!settings.find(s => ((s.revDomain === appFolder) && appFSTypeAllowed(s.storage, type)));
|
package/build/core/sign-in.d.ts
CHANGED
|
@@ -6,8 +6,7 @@ import { LogError } from '../lib-client/logging/log-to-file';
|
|
|
6
6
|
export declare type GenerateKey = (derivParams: ScryptGenParams) => Promise<Uint8Array>;
|
|
7
7
|
export declare type StartInitWithoutCache = (address: string) => Promise<CompleteInitWithoutCache | undefined>;
|
|
8
8
|
export declare type CompleteInitWithoutCache = (midLoginKey: GenerateKey, storageKey: GenerateKey) => Promise<IdManager | undefined>;
|
|
9
|
-
export declare type InitWithCache = (address: string, storageKey: GenerateKey) => Promise<IdManager | undefined
|
|
10
|
-
export declare type InitTwoWithCache = (midLoginKey: GenerateKey) => Promise<IdManager | undefined>;
|
|
9
|
+
export declare type InitWithCache = (address: string, storageKey: GenerateKey) => Promise<IdManager | undefined>;
|
|
11
10
|
declare type SignInService = web3n.startup.SignInService;
|
|
12
11
|
export declare class SignIn {
|
|
13
12
|
private cryptor;
|
package/build/core/sign-in.js
CHANGED
|
@@ -43,9 +43,9 @@ class SignIn {
|
|
|
43
43
|
}
|
|
44
44
|
try {
|
|
45
45
|
const midKeyProgressCB = makeKeyGenProgressCB(0, 50, progressCB);
|
|
46
|
-
const midKeyGen = async (params) => (await key_derivation_1.deriveMidKeyPair(this.cryptor, pass, params, midKeyProgressCB)).skey;
|
|
46
|
+
const midKeyGen = async (params) => (await (0, key_derivation_1.deriveMidKeyPair)(this.cryptor, pass, params, midKeyProgressCB)).skey;
|
|
47
47
|
const storeKeyProgressCB = makeKeyGenProgressCB(51, 100, progressCB);
|
|
48
|
-
const storeKeyGen = (params) => key_derivation_1.deriveStorageSKey(this.cryptor, pass, params, storeKeyProgressCB);
|
|
48
|
+
const storeKeyGen = (params) => (0, key_derivation_1.deriveStorageSKey)(this.cryptor, pass, params, storeKeyProgressCB);
|
|
49
49
|
const idManager = await this.completeInitWithoutCache(midKeyGen, storeKeyGen);
|
|
50
50
|
if (!idManager) {
|
|
51
51
|
return false;
|
|
@@ -62,24 +62,15 @@ class SignIn {
|
|
|
62
62
|
this.useExistingStorage = async (user, pass, progressCB) => {
|
|
63
63
|
try {
|
|
64
64
|
const storeKeyProgressCB = makeKeyGenProgressCB(0, 99, progressCB);
|
|
65
|
-
const storeKeyGen = params => key_derivation_1.deriveStorageSKey(this.cryptor, pass, params, storeKeyProgressCB);
|
|
66
|
-
const
|
|
67
|
-
if (
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
if (typeof res === 'object') {
|
|
71
|
-
this.doneBroadcast.next(res);
|
|
65
|
+
const storeKeyGen = params => (0, key_derivation_1.deriveStorageSKey)(this.cryptor, pass, params, storeKeyProgressCB);
|
|
66
|
+
const idManager = await this.initWithCache(user, storeKeyGen);
|
|
67
|
+
if (idManager) {
|
|
68
|
+
this.doneBroadcast.next(idManager);
|
|
72
69
|
return true;
|
|
73
70
|
}
|
|
74
|
-
|
|
75
|
-
const midKeyProgressCB = makeKeyGenProgressCB(50, 99, progressCB);
|
|
76
|
-
const midKeyGen = async (params) => (await key_derivation_1.deriveMidKeyPair(this.cryptor, pass, params, midKeyProgressCB)).skey;
|
|
77
|
-
const idManager = await res(midKeyGen);
|
|
78
|
-
if (!idManager) {
|
|
71
|
+
else {
|
|
79
72
|
return false;
|
|
80
73
|
}
|
|
81
|
-
this.doneBroadcast.next(idManager);
|
|
82
|
-
return true;
|
|
83
74
|
}
|
|
84
75
|
catch (err) {
|
|
85
76
|
throw await this.logAndWrap(err, 'Failing to start in a state with cache');
|
|
@@ -98,7 +89,7 @@ class SignIn {
|
|
|
98
89
|
}
|
|
99
90
|
async logAndWrap(err, msg) {
|
|
100
91
|
await this.logError(err, msg);
|
|
101
|
-
return error_1.errWithCause(err, msg);
|
|
92
|
+
return (0, error_1.errWithCause)(err, msg);
|
|
102
93
|
}
|
|
103
94
|
}
|
|
104
95
|
exports.SignIn = SignIn;
|
package/build/core/sign-up.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NetClient } from '../lib-client/request-utils';
|
|
2
2
|
import { JsonKey } from '../lib-common/jwkeys';
|
|
3
|
+
import * as keyDeriv from '../lib-client/key-derivation';
|
|
3
4
|
import { GetUsersOnDisk } from './app-files';
|
|
4
5
|
import { Cryptor } from '../lib-client/cryptor/cryptor';
|
|
5
6
|
import { LogError } from '../lib-client/logging/log-to-file';
|
|
@@ -40,5 +41,6 @@ export interface CreatedUser {
|
|
|
40
41
|
labeled: JsonKey;
|
|
41
42
|
};
|
|
42
43
|
storeSKey: Uint8Array;
|
|
44
|
+
storeParams: keyDeriv.ScryptGenParams;
|
|
43
45
|
}
|
|
44
46
|
export {};
|
package/build/core/sign-up.js
CHANGED
|
@@ -42,13 +42,13 @@ const SALT_LEN = 32;
|
|
|
42
42
|
const KEY_ID_LEN = 10;
|
|
43
43
|
async function makeLabeledMidLoginKey(cryptor) {
|
|
44
44
|
const sk = await random.bytes(ecma_nacl_1.box.KEY_LENGTH);
|
|
45
|
-
const skey = jwkeys_1.keyToJson({
|
|
45
|
+
const skey = (0, jwkeys_1.keyToJson)({
|
|
46
46
|
k: sk,
|
|
47
47
|
alg: ecma_nacl_1.box.JWK_ALG_NAME,
|
|
48
48
|
use: jwkeys_1.use.MID_PKLOGIN,
|
|
49
49
|
kid: await random.stringOfB64Chars(KEY_ID_LEN)
|
|
50
50
|
});
|
|
51
|
-
const pkey = jwkeys_1.keyToJson({
|
|
51
|
+
const pkey = (0, jwkeys_1.keyToJson)({
|
|
52
52
|
k: await cryptor.box.generate_pubkey(sk),
|
|
53
53
|
alg: skey.alg,
|
|
54
54
|
use: skey.use,
|
|
@@ -66,7 +66,7 @@ class SignUp {
|
|
|
66
66
|
this.store = undefined;
|
|
67
67
|
this.netLazyInit = undefined;
|
|
68
68
|
this.getAvailableAddresses = async (name, signupToken) => {
|
|
69
|
-
const addresses = await _3nweb_signup_1.checkAvailableAddressesForName(this.net, this.serviceURL, name, signupToken);
|
|
69
|
+
const addresses = await (0, _3nweb_signup_1.checkAvailableAddressesForName)(this.net, this.serviceURL, name, signupToken);
|
|
70
70
|
return addresses;
|
|
71
71
|
};
|
|
72
72
|
this.createUserParams = async (pass, progressCB) => {
|
|
@@ -75,11 +75,11 @@ class SignUp {
|
|
|
75
75
|
};
|
|
76
76
|
this.addUser = async (address, signupToken) => {
|
|
77
77
|
for (const user of await this.getUsersOnDisk()) {
|
|
78
|
-
if (canonical_address_1.areAddressesEqual(address, user)) {
|
|
78
|
+
if ((0, canonical_address_1.areAddressesEqual)(address, user)) {
|
|
79
79
|
throw new Error(`Account ${user} already exists on a disk.`);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
const accountCreated = await _3nweb_signup_1.addUser(this.net, this.serviceURL, {
|
|
82
|
+
const accountCreated = await (0, _3nweb_signup_1.addUser)(this.net, this.serviceURL, {
|
|
83
83
|
userId: address,
|
|
84
84
|
mailerId: this.mid.params,
|
|
85
85
|
storage: this.store.params,
|
|
@@ -96,7 +96,8 @@ class SignUp {
|
|
|
96
96
|
default: this.mid.defaultSKey,
|
|
97
97
|
labeled: this.mid.labeledSKey
|
|
98
98
|
},
|
|
99
|
-
storeSKey: this.store.skey
|
|
99
|
+
storeSKey: this.store.skey,
|
|
100
|
+
storeParams: this.store.params.kdParams
|
|
100
101
|
});
|
|
101
102
|
this.forgetKeys();
|
|
102
103
|
return true;
|
|
@@ -113,7 +114,7 @@ class SignUp {
|
|
|
113
114
|
return this.netLazyInit;
|
|
114
115
|
}
|
|
115
116
|
setServiceURL(serviceURL) {
|
|
116
|
-
const url = url_1.parse(serviceURL);
|
|
117
|
+
const url = (0, url_1.parse)(serviceURL);
|
|
117
118
|
if (url.protocol !== 'https:') {
|
|
118
119
|
throw new Error("Url protocol must be https.");
|
|
119
120
|
}
|
|
@@ -138,7 +139,7 @@ class SignUp {
|
|
|
138
139
|
p: defaultDerivParams.p,
|
|
139
140
|
salt: buffer_utils_1.base64.pack(await random.bytes(SALT_LEN))
|
|
140
141
|
};
|
|
141
|
-
const progressCB = sign_in_1.makeKeyGenProgressCB(progressStart, progressEnd, originalProgressCB);
|
|
142
|
+
const progressCB = (0, sign_in_1.makeKeyGenProgressCB)(progressStart, progressEnd, originalProgressCB);
|
|
142
143
|
const skey = await keyDeriv.deriveStorageSKey(this.cryptor, pass, derivParams, progressCB);
|
|
143
144
|
this.store = {
|
|
144
145
|
skey: skey,
|
|
@@ -154,7 +155,7 @@ class SignUp {
|
|
|
154
155
|
p: defaultDerivParams.p,
|
|
155
156
|
salt: buffer_utils_1.base64.pack(await random.bytes(SALT_LEN))
|
|
156
157
|
};
|
|
157
|
-
const progressCB = sign_in_1.makeKeyGenProgressCB(progressStart, progressEnd, originalProgressCB);
|
|
158
|
+
const progressCB = (0, sign_in_1.makeKeyGenProgressCB)(progressStart, progressEnd, originalProgressCB);
|
|
158
159
|
const defaultPair = await keyDeriv.deriveMidKeyPair(this.cryptor, pass, derivParams, progressCB, jwkeys_1.use.MID_PKLOGIN, '_');
|
|
159
160
|
const labeledKey = await makeLabeledMidLoginKey(this.cryptor);
|
|
160
161
|
this.mid = {
|
|
@@ -171,7 +172,7 @@ class SignUp {
|
|
|
171
172
|
}
|
|
172
173
|
async logAndWrap(err, msg) {
|
|
173
174
|
await this.logError(err, msg);
|
|
174
|
-
return error_1.errWithCause(err, msg);
|
|
175
|
+
return (0, error_1.errWithCause)(err, msg);
|
|
175
176
|
}
|
|
176
177
|
forgetKeys() {
|
|
177
178
|
this.store = undefined;
|
|
@@ -54,7 +54,7 @@ class JSONSavingProc {
|
|
|
54
54
|
this.jsonNeedsSaving = false;
|
|
55
55
|
const serialForm = this.getForSerialization();
|
|
56
56
|
if (serialForm === undefined) {
|
|
57
|
-
await async_fs_node_1.unlink(this.path)
|
|
57
|
+
await (0, async_fs_node_1.unlink)(this.path)
|
|
58
58
|
.catch((e) => {
|
|
59
59
|
if (!e.notFound) {
|
|
60
60
|
throw e;
|
|
@@ -63,7 +63,7 @@ class JSONSavingProc {
|
|
|
63
63
|
}
|
|
64
64
|
else {
|
|
65
65
|
const json = JSON.stringify(serialForm);
|
|
66
|
-
await async_fs_node_1.writeFile(this.path, json, { encoding: 'utf8' });
|
|
66
|
+
await (0, async_fs_node_1.writeFile)(this.path, json, { encoding: 'utf8' });
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
finally {
|
|
@@ -9,10 +9,10 @@ export interface VersionsInfo {
|
|
|
9
9
|
*/
|
|
10
10
|
archived?: number[];
|
|
11
11
|
/**
|
|
12
|
-
* This is a map from base version to diff-ed version
|
|
12
|
+
* This is a map from base version to diff-ed version, that uses base.
|
|
13
13
|
*/
|
|
14
14
|
baseToDiff: {
|
|
15
|
-
[baseVersion: number]: number
|
|
15
|
+
[baseVersion: number]: number;
|
|
16
16
|
};
|
|
17
17
|
/**
|
|
18
18
|
* This is a map from diff version to base version.
|
|
@@ -27,7 +27,8 @@ export interface VersionsInfo {
|
|
|
27
27
|
* @param diffVer
|
|
28
28
|
* @param baseVer
|
|
29
29
|
*/
|
|
30
|
-
export declare function
|
|
30
|
+
export declare function addBaseToDiffLinkInVersInfo(versions: VersionsInfo, diffVer: number, baseVer: number): void;
|
|
31
|
+
export declare function isVersionIn(version: number, vers: VersionsInfo): boolean;
|
|
31
32
|
/**
|
|
32
33
|
* This function removes given version from versions info, if it is neither
|
|
33
34
|
* archived, nor is a base for another version. If given version is itself
|
|
@@ -37,8 +38,15 @@ export declare function addBaseToDiffLinkInStatus(versions: VersionsInfo, diffVe
|
|
|
37
38
|
* @param ver
|
|
38
39
|
*/
|
|
39
40
|
export declare function rmNonArchVersionsIn(versions: VersionsInfo, ver: number): void;
|
|
40
|
-
export declare function
|
|
41
|
+
export declare function rmArchVersionFrom(versions: VersionsInfo, ver: number): boolean;
|
|
41
42
|
export declare function setCurrentVersionIn(versions: VersionsInfo, version: number, baseVer: number | undefined): void;
|
|
42
43
|
export declare function rmCurrentVersionIn(versions: VersionsInfo): number | undefined;
|
|
44
|
+
export declare function rmVersionIn(version: number, vers: VersionsInfo): void;
|
|
43
45
|
export declare function nonGarbageVersionsIn(versions: VersionsInfo): Set<number>;
|
|
46
|
+
export interface NonGarbageVersions {
|
|
47
|
+
gcMaxVer?: number;
|
|
48
|
+
nonGarbage: Set<number>;
|
|
49
|
+
}
|
|
44
50
|
export declare function addWithBasesTo(nonGarbage: Set<number>, ver: number | undefined, versions: VersionsInfo): void;
|
|
51
|
+
export declare function addArchived(versions: VersionsInfo, version: number): boolean;
|
|
52
|
+
export declare function isEmptyVersions(versions: VersionsInfo): boolean;
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.addWithBasesTo = exports.nonGarbageVersionsIn = exports.rmCurrentVersionIn = exports.setCurrentVersionIn = exports.
|
|
19
|
+
exports.isEmptyVersions = exports.addArchived = exports.addWithBasesTo = exports.nonGarbageVersionsIn = exports.rmVersionIn = exports.rmCurrentVersionIn = exports.setCurrentVersionIn = exports.rmArchVersionFrom = exports.rmNonArchVersionsIn = exports.isVersionIn = exports.addBaseToDiffLinkInVersInfo = exports.readJSONInfoFileIn = void 0;
|
|
20
20
|
const fs = require("../../../lib-common/async-fs-node");
|
|
21
21
|
const path_1 = require("path");
|
|
22
22
|
const exceptions_1 = require("../../../lib-client/3nstorage/exceptions");
|
|
23
23
|
async function readJSONInfoFileIn(objFolder, fileName) {
|
|
24
24
|
try {
|
|
25
|
-
const infoJSONStr = await fs.readFile(path_1.join(objFolder, fileName), { encoding: 'utf8' }).catch((exc) => {
|
|
25
|
+
const infoJSONStr = await fs.readFile((0, path_1.join)(objFolder, fileName), { encoding: 'utf8' }).catch((exc) => {
|
|
26
26
|
if (!exc.notFound) {
|
|
27
27
|
throw exc;
|
|
28
28
|
}
|
|
@@ -35,7 +35,7 @@ async function readJSONInfoFileIn(objFolder, fileName) {
|
|
|
35
35
|
return status;
|
|
36
36
|
}
|
|
37
37
|
catch (err) {
|
|
38
|
-
throw exceptions_1.makeStorageException({
|
|
38
|
+
throw (0, exceptions_1.makeStorageException)({
|
|
39
39
|
message: `Can't read and parse content of obj info file ${fileName} in obj folder ${objFolder}`,
|
|
40
40
|
cause: err
|
|
41
41
|
});
|
|
@@ -48,22 +48,24 @@ exports.readJSONInfoFileIn = readJSONInfoFileIn;
|
|
|
48
48
|
* @param diffVer
|
|
49
49
|
* @param baseVer
|
|
50
50
|
*/
|
|
51
|
-
function
|
|
51
|
+
function addBaseToDiffLinkInVersInfo(versions, diffVer, baseVer) {
|
|
52
52
|
if (diffVer <= baseVer) {
|
|
53
53
|
throw new Error(`Given diff version ${diffVer} is not greater than base version ${baseVer}`);
|
|
54
54
|
}
|
|
55
55
|
versions.diffToBase[diffVer] = baseVer;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
versions.baseToDiff[baseVer] = diffVer;
|
|
57
|
+
}
|
|
58
|
+
exports.addBaseToDiffLinkInVersInfo = addBaseToDiffLinkInVersInfo;
|
|
59
|
+
function isVersionIn(version, vers) {
|
|
60
|
+
if (vers.current === version) {
|
|
61
|
+
return true;
|
|
61
62
|
}
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
if (vers.archived && vers.archived.includes(version)) {
|
|
64
|
+
return true;
|
|
64
65
|
}
|
|
66
|
+
return false;
|
|
65
67
|
}
|
|
66
|
-
exports.
|
|
68
|
+
exports.isVersionIn = isVersionIn;
|
|
67
69
|
/**
|
|
68
70
|
* This function removes given version from versions info, if it is neither
|
|
69
71
|
* archived, nor is a base for another version. If given version is itself
|
|
@@ -73,49 +75,41 @@ exports.addBaseToDiffLinkInStatus = addBaseToDiffLinkInStatus;
|
|
|
73
75
|
* @param ver
|
|
74
76
|
*/
|
|
75
77
|
function rmNonArchVersionsIn(versions, ver) {
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
+
if (versions.archived
|
|
79
|
+
&& versions.archived.includes(ver)) {
|
|
78
80
|
return;
|
|
79
81
|
}
|
|
80
82
|
if (versions.baseToDiff[ver]) {
|
|
81
83
|
return;
|
|
82
84
|
}
|
|
83
85
|
const base = versions.diffToBase[ver];
|
|
84
|
-
if (
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
delete versions.diffToBase[ver];
|
|
88
|
-
const diffs = versions.baseToDiff[base];
|
|
89
|
-
if (!diffs) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
const diffInd = diffs.indexOf(ver);
|
|
93
|
-
if (diffInd < 0) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
diffs.splice(diffInd, 1);
|
|
97
|
-
if (diffs.length === 0) {
|
|
86
|
+
if (base) {
|
|
87
|
+
delete versions.diffToBase[ver];
|
|
98
88
|
delete versions.baseToDiff[base];
|
|
99
89
|
rmNonArchVersionsIn(versions, base);
|
|
100
90
|
}
|
|
101
91
|
}
|
|
102
92
|
exports.rmNonArchVersionsIn = rmNonArchVersionsIn;
|
|
103
|
-
function
|
|
93
|
+
function rmArchVersionFrom(versions, ver) {
|
|
104
94
|
if (!versions.archived) {
|
|
105
|
-
return;
|
|
95
|
+
return false;
|
|
106
96
|
}
|
|
107
97
|
const vInd = versions.archived.indexOf(ver);
|
|
108
98
|
if (vInd < 0) {
|
|
109
|
-
return;
|
|
99
|
+
return false;
|
|
110
100
|
}
|
|
111
101
|
versions.archived.splice(vInd, 1);
|
|
102
|
+
if (versions.archived.length === 0) {
|
|
103
|
+
versions.archived = undefined;
|
|
104
|
+
}
|
|
112
105
|
rmNonArchVersionsIn(versions, ver);
|
|
106
|
+
return true;
|
|
113
107
|
}
|
|
114
|
-
exports.
|
|
108
|
+
exports.rmArchVersionFrom = rmArchVersionFrom;
|
|
115
109
|
function setCurrentVersionIn(versions, version, baseVer) {
|
|
116
110
|
if (baseVer !== undefined) {
|
|
117
111
|
// base->diff links should be added before removals
|
|
118
|
-
|
|
112
|
+
addBaseToDiffLinkInVersInfo(versions, version, baseVer);
|
|
119
113
|
}
|
|
120
114
|
const initCurrent = versions.current;
|
|
121
115
|
if (typeof initCurrent === 'number') {
|
|
@@ -128,11 +122,21 @@ function rmCurrentVersionIn(versions) {
|
|
|
128
122
|
const current = versions.current;
|
|
129
123
|
if (typeof current === 'number') {
|
|
130
124
|
rmNonArchVersionsIn(versions, current);
|
|
131
|
-
|
|
125
|
+
versions.current = undefined;
|
|
132
126
|
}
|
|
133
127
|
return current;
|
|
134
128
|
}
|
|
135
129
|
exports.rmCurrentVersionIn = rmCurrentVersionIn;
|
|
130
|
+
function rmVersionIn(version, vers) {
|
|
131
|
+
if (vers.current === version) {
|
|
132
|
+
vers.current = undefined;
|
|
133
|
+
rmNonArchVersionsIn(vers, version);
|
|
134
|
+
}
|
|
135
|
+
if (isVersionIn(version, vers)) {
|
|
136
|
+
rmArchVersionFrom(vers, version);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.rmVersionIn = rmVersionIn;
|
|
136
140
|
function nonGarbageVersionsIn(versions) {
|
|
137
141
|
const nonGarbage = new Set();
|
|
138
142
|
addWithBasesTo(nonGarbage, versions.current, versions);
|
|
@@ -157,4 +161,32 @@ function addWithBasesTo(nonGarbage, ver, versions) {
|
|
|
157
161
|
}
|
|
158
162
|
}
|
|
159
163
|
exports.addWithBasesTo = addWithBasesTo;
|
|
164
|
+
function addArchived(versions, version) {
|
|
165
|
+
if (!versions.archived) {
|
|
166
|
+
versions.archived = [];
|
|
167
|
+
}
|
|
168
|
+
else if (versions.archived.includes(version)) {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
versions.archived.push(version);
|
|
172
|
+
versions.archived.sort();
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
exports.addArchived = addArchived;
|
|
176
|
+
function isEmptyVersions(versions) {
|
|
177
|
+
if (versions.current) {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
if (!versions.archived) {
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
else if (versions.archived.length > 0) {
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
versions.archived = undefined;
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
exports.isEmptyVersions = isEmptyVersions;
|
|
160
192
|
Object.freeze(exports);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2016 - 2020 3NSoft Inc.
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
6
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
See the GNU General Public License for more details.
|
|
14
|
+
|
|
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/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.noop = exports.getAndRemoveOneFrom = void 0;
|
|
20
|
+
function getAndRemoveOneFrom(set) {
|
|
21
|
+
const iter = set.values();
|
|
22
|
+
const { value, done } = iter.next();
|
|
23
|
+
if (done) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
set.delete(value);
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
exports.getAndRemoveOneFrom = getAndRemoveOneFrom;
|
|
30
|
+
function noop() { }
|
|
31
|
+
exports.noop = noop;
|
|
32
|
+
Object.freeze(exports);
|
|
@@ -2,25 +2,14 @@ import { GetSigner } from '../id-manager';
|
|
|
2
2
|
import { GenerateKey } from '../sign-in';
|
|
3
3
|
import { StorageGetter } from '../../lib-client/3nstorage/xsp-fs/common';
|
|
4
4
|
import { ServiceLocator } from '../../lib-client/service-locator';
|
|
5
|
+
import { ScryptGenParams } from '../../lib-client/key-derivation';
|
|
5
6
|
import { AsyncSBoxCryptor } from 'xsp-files';
|
|
6
|
-
import { NetClient } from '../../lib-client/request-utils';
|
|
7
7
|
import { StoragePathForUser } from '../app-files';
|
|
8
8
|
import { LogError } from '../../lib-client/logging/log-to-file';
|
|
9
|
+
import { MakeNet } from '..';
|
|
9
10
|
declare type WritableFS = web3n.files.WritableFS;
|
|
10
11
|
declare type StorageType = web3n.storage.StorageType;
|
|
11
12
|
declare type FSItem = web3n.files.FSItem;
|
|
12
|
-
export declare const sysFolders: {
|
|
13
|
-
appData: string;
|
|
14
|
-
apps: string;
|
|
15
|
-
packages: string;
|
|
16
|
-
sharedLibs: string;
|
|
17
|
-
userFiles: string;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* This function creates initial folder structure in a given root.
|
|
21
|
-
* @param root
|
|
22
|
-
*/
|
|
23
|
-
export declare function initSysFolders(root: WritableFS): Promise<void>;
|
|
24
13
|
export declare class Storages implements FactoryOfFSs {
|
|
25
14
|
private cryptor;
|
|
26
15
|
private storageDirForUser;
|
|
@@ -42,8 +31,9 @@ export declare class Storages implements FactoryOfFSs {
|
|
|
42
31
|
* This is a storage getter for links and linking in synced storage.
|
|
43
32
|
*/
|
|
44
33
|
private storageGetterForSyncedStorage;
|
|
45
|
-
startInitFromCache(user: string, keyGen: GenerateKey, makeNet:
|
|
46
|
-
initFromRemote(user: string, getSigner: GetSigner,
|
|
34
|
+
startInitFromCache(user: string, keyGen: GenerateKey, makeNet: MakeNet, resolver: ServiceLocator, logError: LogError): Promise<((getSigner: GetSigner) => void) | undefined>;
|
|
35
|
+
initFromRemote(user: string, getSigner: GetSigner, generateKey: GenerateKey, makeNet: MakeNet, resolver: ServiceLocator, logError: LogError): Promise<boolean>;
|
|
36
|
+
initFreshForNewUser(user: string, getSigner: GetSigner, params: ScryptGenParams, key: Uint8Array, makeNet: MakeNet, resolver: ServiceLocator, logError: LogError): Promise<boolean>;
|
|
47
37
|
makeSyncedFSForApp(appFolder: string): Promise<WritableFS>;
|
|
48
38
|
makeLocalFSForApp(appFolder: string): Promise<WritableFS>;
|
|
49
39
|
getUserFS(type: StorageType): Promise<FSItem>;
|
|
@@ -51,8 +41,6 @@ export declare class Storages implements FactoryOfFSs {
|
|
|
51
41
|
close(): Promise<void>;
|
|
52
42
|
wrap(): FactoryOfFSs;
|
|
53
43
|
}
|
|
54
|
-
export declare function userFilesOnDevice(): Promise<WritableFS>;
|
|
55
|
-
export declare function sysFilesOnDevice(): Promise<FSItem>;
|
|
56
44
|
export interface FactoryOfFSs {
|
|
57
45
|
makeSyncedFSForApp(appFolder: string): Promise<WritableFS>;
|
|
58
46
|
makeLocalFSForApp(appFolder: string): Promise<WritableFS>;
|