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
|
@@ -18,10 +18,13 @@
|
|
|
18
18
|
|
|
19
19
|
declare namespace web3n.files {
|
|
20
20
|
|
|
21
|
-
interface FileException extends RuntimeException {
|
|
21
|
+
interface FileException extends RuntimeException, FileExceptionFlag {
|
|
22
22
|
type: 'file';
|
|
23
23
|
code: string|undefined;
|
|
24
24
|
path: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface FileExceptionFlag {
|
|
25
28
|
notFound?: true;
|
|
26
29
|
alreadyExists?: true;
|
|
27
30
|
notDirectory?: true;
|
|
@@ -48,18 +51,30 @@ declare namespace web3n.files {
|
|
|
48
51
|
alreadyExists: 'EEXIST';
|
|
49
52
|
notDirectory: 'ENOTDIR';
|
|
50
53
|
notFile: 'ENOTFILE';
|
|
51
|
-
notLink: 'not-link';
|
|
52
54
|
isDirectory: 'EISDIR';
|
|
53
55
|
notEmpty: 'ENOTEMPTY';
|
|
54
56
|
endOfFile: 'EEOF';
|
|
55
57
|
opNotPermitted: 'EPERM';
|
|
56
58
|
busy: 'EBUSY';
|
|
57
59
|
ioError: 'EIO';
|
|
58
|
-
concurrentUpdate: 'concurrent-update';
|
|
59
|
-
parsingError: 'parsing-error';
|
|
60
60
|
notImplemented: 'ENOSYS';
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
interface FSSyncException extends RuntimeException {
|
|
64
|
+
type: 'fs-sync';
|
|
65
|
+
path: string;
|
|
66
|
+
localVersion?: number;
|
|
67
|
+
remoteVersion?: number;
|
|
68
|
+
alreadyUploading?: true;
|
|
69
|
+
versionNotFound?: true;
|
|
70
|
+
childNeverUploaded?: true;
|
|
71
|
+
childName?: string;
|
|
72
|
+
removedOnServer?: true;
|
|
73
|
+
versionMismatch?: true;
|
|
74
|
+
conflict?: true;
|
|
75
|
+
notSynced?: true;
|
|
76
|
+
remoteIsArchived?: true;
|
|
77
|
+
remoteFolderItemNotFound?: true;
|
|
63
78
|
}
|
|
64
79
|
|
|
65
80
|
/**
|
|
@@ -126,18 +141,39 @@ declare namespace web3n.files {
|
|
|
126
141
|
*/
|
|
127
142
|
version?: number;
|
|
128
143
|
|
|
129
|
-
|
|
130
|
-
* This tells object's latest sync state.
|
|
131
|
-
* If such information cannot be provided, this field will be absent.
|
|
132
|
-
*/
|
|
133
|
-
sync?: {
|
|
134
|
-
state: SyncState;
|
|
135
|
-
latest?: number;
|
|
136
|
-
conflictingRemote?: number[];
|
|
137
|
-
remote?: number;
|
|
138
|
-
deletedOnRemote?: true;
|
|
139
|
-
};
|
|
144
|
+
}
|
|
140
145
|
|
|
146
|
+
/**
|
|
147
|
+
* Sync status contains info about possible version branches with possible
|
|
148
|
+
* states:
|
|
149
|
+
* 1. unsynced - have local branch, and possibly synced one.
|
|
150
|
+
* Local version(s) should be uploaded to get into synced state.
|
|
151
|
+
* 2. synced - have only synced branch.
|
|
152
|
+
* 3. behind - have both synced and remote branches.
|
|
153
|
+
* Should explicitly advance to newer version to get into synced state.
|
|
154
|
+
* 4. conflicting - have conflicting local and remote branches, with possible
|
|
155
|
+
* common synced history branch.
|
|
156
|
+
* Conflict gets fixed by uploading some local version with value greater
|
|
157
|
+
* than remote's latest. Making this version is a custom magic of
|
|
158
|
+
* conflict resolution that you do for your app.
|
|
159
|
+
*/
|
|
160
|
+
interface SyncStatus {
|
|
161
|
+
state: SyncState;
|
|
162
|
+
synced?: SyncVersionsBranch;
|
|
163
|
+
local?: LocalVersion;
|
|
164
|
+
remote?: SyncVersionsBranch;
|
|
165
|
+
existsInSyncedParent?: boolean;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
interface LocalVersion {
|
|
169
|
+
latest?: number;
|
|
170
|
+
isArchived?: boolean;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
interface SyncVersionsBranch {
|
|
174
|
+
latest?: number;
|
|
175
|
+
archived?: number[];
|
|
176
|
+
isArchived?: boolean;
|
|
141
177
|
}
|
|
142
178
|
|
|
143
179
|
type SyncState = 'synced' | 'behind' | 'unsynced' | 'conflicting';
|
|
@@ -328,7 +364,7 @@ declare namespace web3n.files {
|
|
|
328
364
|
*/
|
|
329
365
|
getByteSource(): Promise<FileByteSource>;
|
|
330
366
|
|
|
331
|
-
watch(observer: Observer<FileEvent>): () => void;
|
|
367
|
+
watch(observer: Observer<FileEvent|RemoteEvent>): () => void;
|
|
332
368
|
|
|
333
369
|
}
|
|
334
370
|
|
|
@@ -398,8 +434,9 @@ declare namespace web3n.files {
|
|
|
398
434
|
* greater than file length, all available bytes are read. If parameter
|
|
399
435
|
* is missing, read will be done to file's end.
|
|
400
436
|
*/
|
|
401
|
-
readBytes(
|
|
402
|
-
|
|
437
|
+
readBytes(
|
|
438
|
+
start?: number, end?: number
|
|
439
|
+
): Promise<{ bytes: Uint8Array|undefined; version: number; }>;
|
|
403
440
|
|
|
404
441
|
/**
|
|
405
442
|
* This returns a promise, resolvable to text, read from file, assuming
|
|
@@ -418,6 +455,10 @@ declare namespace web3n.files {
|
|
|
418
455
|
*/
|
|
419
456
|
getByteSource(): Promise<{ src: FileByteSource; version: number; }>;
|
|
420
457
|
|
|
458
|
+
listVersions(): Promise<{ current?: number; archived?: number[]; }>;
|
|
459
|
+
|
|
460
|
+
sync?: ReadonlyFileSyncAPI;
|
|
461
|
+
|
|
421
462
|
}
|
|
422
463
|
|
|
423
464
|
interface WritableFileVersionedAPI extends ReadonlyFileVersionedAPI {
|
|
@@ -460,8 +501,9 @@ declare namespace web3n.files {
|
|
|
460
501
|
* When current version is given, an error is thrown, if file version at
|
|
461
502
|
* the moment of writing is different.
|
|
462
503
|
*/
|
|
463
|
-
getByteSink(
|
|
464
|
-
|
|
504
|
+
getByteSink(
|
|
505
|
+
truncateFile?: boolean, currentVersion?: number
|
|
506
|
+
): Promise<{ sink: FileByteSink; version: number; }>;
|
|
465
507
|
|
|
466
508
|
/**
|
|
467
509
|
* This returns a promise, resolvable to new file's version when copying
|
|
@@ -469,7 +511,48 @@ declare namespace web3n.files {
|
|
|
469
511
|
* @param file which content will be copied into this file
|
|
470
512
|
*/
|
|
471
513
|
copy(file: File): Promise<number>;
|
|
472
|
-
|
|
514
|
+
|
|
515
|
+
archiveCurrent(version?: number): Promise<number>;
|
|
516
|
+
|
|
517
|
+
sync?: WritableFileSyncAPI;
|
|
518
|
+
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
interface ReadonlyFileSyncAPI {
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Returns synchronization status of this object, as is currently known
|
|
525
|
+
* here without checking remote server.
|
|
526
|
+
*/
|
|
527
|
+
status(): Promise<SyncStatus>;
|
|
528
|
+
|
|
529
|
+
updateStatusInfo(): Promise<SyncStatus>;
|
|
530
|
+
|
|
531
|
+
isRemoteVersionOnDisk(
|
|
532
|
+
version: number
|
|
533
|
+
): Promise<'partial'|'complete'|'none'>;
|
|
534
|
+
|
|
535
|
+
download(version: number): Promise<void>;
|
|
536
|
+
|
|
537
|
+
adoptRemote(opts?: OptionsToAdopteRemote): Promise<void>;
|
|
538
|
+
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
interface OptionsToAdopteRemote {
|
|
542
|
+
dropLocalVer?: boolean;
|
|
543
|
+
remoteVersion?: number;
|
|
544
|
+
download?: boolean;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
interface WritableFileSyncAPI extends ReadonlyFileSyncAPI {
|
|
548
|
+
|
|
549
|
+
upload(opts?: OptionsToUploadLocal): Promise<void>;
|
|
550
|
+
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
interface OptionsToUploadLocal {
|
|
554
|
+
localVersion?: number;
|
|
555
|
+
uploadVersion?: number;
|
|
473
556
|
}
|
|
474
557
|
|
|
475
558
|
type FSType = 'device' | 'synced' | 'local' | 'share' | 'asmail-msg';
|
|
@@ -498,8 +581,9 @@ declare namespace web3n.files {
|
|
|
498
581
|
* throwing of an exception, when folder does not exist. Default value is
|
|
499
582
|
* false.
|
|
500
583
|
*/
|
|
501
|
-
checkFolderPresence(
|
|
502
|
-
|
|
584
|
+
checkFolderPresence(
|
|
585
|
+
path: string, throwIfMissing?: boolean
|
|
586
|
+
): Promise<boolean>;
|
|
503
587
|
|
|
504
588
|
/**
|
|
505
589
|
* This returns a promise, resolvable to true, if file exists, and to
|
|
@@ -509,8 +593,9 @@ declare namespace web3n.files {
|
|
|
509
593
|
* throwing of an exception, when file does not exist. Default value is
|
|
510
594
|
* false.
|
|
511
595
|
*/
|
|
512
|
-
checkFilePresence(
|
|
513
|
-
|
|
596
|
+
checkFilePresence(
|
|
597
|
+
path: string, throwIfMissing?: boolean
|
|
598
|
+
): Promise<boolean>;
|
|
514
599
|
|
|
515
600
|
/**
|
|
516
601
|
* This returns a promise, resolvable to true, if link exists, and to
|
|
@@ -520,8 +605,9 @@ declare namespace web3n.files {
|
|
|
520
605
|
* throwing of an exception, when link does not exist. Default value is
|
|
521
606
|
* false.
|
|
522
607
|
*/
|
|
523
|
-
checkLinkPresence(
|
|
524
|
-
|
|
608
|
+
checkLinkPresence(
|
|
609
|
+
path: string, throwIfMissing?: boolean
|
|
610
|
+
): Promise<boolean>;
|
|
525
611
|
|
|
526
612
|
/**
|
|
527
613
|
* This returns a promise, resolvable to stats of an entity at a given
|
|
@@ -546,12 +632,18 @@ declare namespace web3n.files {
|
|
|
546
632
|
|
|
547
633
|
readLink(path: string): Promise<SymLink>;
|
|
548
634
|
|
|
549
|
-
watchFolder(
|
|
635
|
+
watchFolder(
|
|
636
|
+
path: string, observer: Observer<FolderEvent|RemoteEvent>
|
|
637
|
+
): () => void;
|
|
550
638
|
|
|
551
|
-
watchFile(
|
|
639
|
+
watchFile(
|
|
640
|
+
path: string, observer: Observer<FileEvent|RemoteEvent>
|
|
641
|
+
): () => void;
|
|
552
642
|
|
|
553
|
-
watchTree(
|
|
554
|
-
|
|
643
|
+
watchTree(
|
|
644
|
+
path: string, depth: number|undefined,
|
|
645
|
+
observer: Observer<FolderEvent|FileEvent|RemoteEvent>
|
|
646
|
+
): () => void;
|
|
555
647
|
|
|
556
648
|
close(): Promise<void>;
|
|
557
649
|
|
|
@@ -593,8 +685,9 @@ declare namespace web3n.files {
|
|
|
593
685
|
* greater than file length, all available bytes are read. If parameter
|
|
594
686
|
* is missing, read will be done to file's end.
|
|
595
687
|
*/
|
|
596
|
-
readBytes(
|
|
597
|
-
|
|
688
|
+
readBytes(
|
|
689
|
+
path: string, start?: number, end?: number
|
|
690
|
+
): Promise<Uint8Array|undefined>;
|
|
598
691
|
|
|
599
692
|
/**
|
|
600
693
|
* This returns a promise, resolvable to bytes source with seek, which
|
|
@@ -619,8 +712,9 @@ declare namespace web3n.files {
|
|
|
619
712
|
* @param path
|
|
620
713
|
* @param criteria
|
|
621
714
|
*/
|
|
622
|
-
select(
|
|
623
|
-
|
|
715
|
+
select(
|
|
716
|
+
path: string, criteria: SelectCriteria
|
|
717
|
+
): Promise<{ items: FSCollection; completion: Promise<void>; }>;
|
|
624
718
|
|
|
625
719
|
}
|
|
626
720
|
|
|
@@ -752,8 +846,9 @@ declare namespace web3n.files {
|
|
|
752
846
|
* @param overwrite is a flag that with a true value allows
|
|
753
847
|
* overwrite of existing dst file. Default value is false.
|
|
754
848
|
*/
|
|
755
|
-
copyFile(
|
|
756
|
-
|
|
849
|
+
copyFile(
|
|
850
|
+
src: string, dst: string, overwrite?: boolean
|
|
851
|
+
): Promise<void>;
|
|
757
852
|
|
|
758
853
|
/**
|
|
759
854
|
* This returns a promise, resolvable when folder has been recursively
|
|
@@ -764,8 +859,9 @@ declare namespace web3n.files {
|
|
|
764
859
|
* merge into existing folder and files overwriting inside. Default
|
|
765
860
|
* value is false.
|
|
766
861
|
*/
|
|
767
|
-
copyFolder(
|
|
768
|
-
|
|
862
|
+
copyFolder(
|
|
863
|
+
src: string, dst: string, mergeAndOverwrite?: boolean
|
|
864
|
+
): Promise<void>;
|
|
769
865
|
|
|
770
866
|
/**
|
|
771
867
|
* This returns a promise, resolvable when file has been saved.
|
|
@@ -785,8 +881,9 @@ declare namespace web3n.files {
|
|
|
785
881
|
* merge into existing folder and files overwriting inside. Default
|
|
786
882
|
* value is false.
|
|
787
883
|
*/
|
|
788
|
-
saveFolder(
|
|
789
|
-
|
|
884
|
+
saveFolder(
|
|
885
|
+
folder: FS, dst: string, mergeAndOverwrite?: boolean
|
|
886
|
+
): Promise<void>;
|
|
790
887
|
|
|
791
888
|
/**
|
|
792
889
|
* This returns a promise, resolvable when file has been removed
|
|
@@ -830,8 +927,9 @@ declare namespace web3n.files {
|
|
|
830
927
|
* @param flags are optional flags. Default flags are create=true,
|
|
831
928
|
* exclusive=false.
|
|
832
929
|
*/
|
|
833
|
-
writeBytes(
|
|
834
|
-
|
|
930
|
+
writeBytes(
|
|
931
|
+
path: string, bytes: Uint8Array, flags?: FileFlags
|
|
932
|
+
): Promise<void>;
|
|
835
933
|
|
|
836
934
|
/**
|
|
837
935
|
* This returns a promise, resolvable to byte sink with seek
|
|
@@ -887,8 +985,9 @@ declare namespace web3n.files {
|
|
|
887
985
|
|
|
888
986
|
interface ReadonlyFSVersionedAPI {
|
|
889
987
|
|
|
890
|
-
getXAttr(
|
|
891
|
-
|
|
988
|
+
getXAttr(
|
|
989
|
+
path: string, xaName: string
|
|
990
|
+
): Promise<{ attr: any; version: number; }>;
|
|
892
991
|
|
|
893
992
|
listXAttrs(path: string): Promise<{ lst: string[]; version: number; }>;
|
|
894
993
|
|
|
@@ -897,8 +996,9 @@ declare namespace web3n.files {
|
|
|
897
996
|
* for entries in the folder, and a folder's version.
|
|
898
997
|
* @param path of a folder that should be listed
|
|
899
998
|
*/
|
|
900
|
-
listFolder(
|
|
901
|
-
|
|
999
|
+
listFolder(
|
|
1000
|
+
path: string
|
|
1001
|
+
): Promise<{ lst: ListingEntry[]; version: number; }>;
|
|
902
1002
|
|
|
903
1003
|
/**
|
|
904
1004
|
* This returns a promise, resolvable to json, read from file, and a
|
|
@@ -925,16 +1025,24 @@ declare namespace web3n.files {
|
|
|
925
1025
|
* greater than file length, all available bytes are read. If parameter
|
|
926
1026
|
* is missing, read will be done to file's end.
|
|
927
1027
|
*/
|
|
928
|
-
readBytes(
|
|
929
|
-
|
|
1028
|
+
readBytes(
|
|
1029
|
+
path: string, start?: number, end?: number
|
|
1030
|
+
): Promise<{ bytes: Uint8Array|undefined; version: number; }>;
|
|
930
1031
|
|
|
931
1032
|
/**
|
|
932
1033
|
* This returns a promise, resolvable to bytes source with seek, which
|
|
933
1034
|
* allows random reads, and a file version
|
|
934
1035
|
* @param path of a file from which to read bytes
|
|
935
1036
|
*/
|
|
936
|
-
getByteSource(
|
|
937
|
-
|
|
1037
|
+
getByteSource(
|
|
1038
|
+
path: string
|
|
1039
|
+
): Promise<{ src: FileByteSource; version: number; }>;
|
|
1040
|
+
|
|
1041
|
+
listVersions(
|
|
1042
|
+
path: string
|
|
1043
|
+
): Promise<{ current?: number; archived?: number[]; }>;
|
|
1044
|
+
|
|
1045
|
+
sync?: ReadonlyFSSyncAPI;
|
|
938
1046
|
|
|
939
1047
|
}
|
|
940
1048
|
|
|
@@ -956,8 +1064,9 @@ declare namespace web3n.files {
|
|
|
956
1064
|
* @param flags are optional flags. Default flags are create=true,
|
|
957
1065
|
* exclusive=false.
|
|
958
1066
|
*/
|
|
959
|
-
writeJSONFile(
|
|
960
|
-
|
|
1067
|
+
writeJSONFile(
|
|
1068
|
+
path: string, json: any, flags?: VersionedFileFlags
|
|
1069
|
+
): Promise<number>;
|
|
961
1070
|
|
|
962
1071
|
/**
|
|
963
1072
|
* This returns a promise, resolvable to new file's version when file is
|
|
@@ -967,8 +1076,9 @@ declare namespace web3n.files {
|
|
|
967
1076
|
* @param flags are optional flags. Default flags are create=true,
|
|
968
1077
|
* exclusive=false.
|
|
969
1078
|
*/
|
|
970
|
-
writeTxtFile(
|
|
971
|
-
|
|
1079
|
+
writeTxtFile(
|
|
1080
|
+
path: string, txt: string, flags?: VersionedFileFlags
|
|
1081
|
+
): Promise<number>;
|
|
972
1082
|
|
|
973
1083
|
/**
|
|
974
1084
|
* This returns a promise, resolvable to new file's version when file is
|
|
@@ -978,8 +1088,9 @@ declare namespace web3n.files {
|
|
|
978
1088
|
* @param flags are optional flags. Default flags are create=true,
|
|
979
1089
|
* exclusive=false.
|
|
980
1090
|
*/
|
|
981
|
-
writeBytes(
|
|
982
|
-
|
|
1091
|
+
writeBytes(
|
|
1092
|
+
path: string, bytes: Uint8Array, flags?: VersionedFileFlags
|
|
1093
|
+
): Promise<number>;
|
|
983
1094
|
|
|
984
1095
|
/**
|
|
985
1096
|
* This returns a promise, resolvable to byte sink with seek, and a file
|
|
@@ -988,53 +1099,148 @@ declare namespace web3n.files {
|
|
|
988
1099
|
* @param flags are optional flags. Default flags are create=true,
|
|
989
1100
|
* exclusive=false, truncate=true.
|
|
990
1101
|
*/
|
|
991
|
-
getByteSink(
|
|
992
|
-
|
|
1102
|
+
getByteSink(
|
|
1103
|
+
path: string, flags?: VersionedFileFlags
|
|
1104
|
+
): Promise<{ sink: FileByteSink; version: number; }>;
|
|
993
1105
|
|
|
1106
|
+
archiveCurrent(path: string, version?: number): Promise<number>;
|
|
1107
|
+
|
|
1108
|
+
sync?: WritableFSSyncAPI;
|
|
1109
|
+
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
interface ReadonlyFSSyncAPI {
|
|
1113
|
+
|
|
1114
|
+
/**
|
|
1115
|
+
* Returns synchronization status of this object, as is currently known
|
|
1116
|
+
* here without checking remote server.
|
|
1117
|
+
*/
|
|
1118
|
+
status(path: string): Promise<SyncStatus>;
|
|
1119
|
+
|
|
1120
|
+
updateStatusInfo(path: string): Promise<SyncStatus>;
|
|
1121
|
+
|
|
1122
|
+
isRemoteVersionOnDisk(
|
|
1123
|
+
path: string, version: number
|
|
1124
|
+
): Promise<'partial'|'complete'|'none'>;
|
|
1125
|
+
|
|
1126
|
+
download(path: string, version: number): Promise<void>;
|
|
1127
|
+
|
|
1128
|
+
adoptRemote(path: string, opts?: OptionsToAdopteRemote): Promise<void>;
|
|
1129
|
+
|
|
1130
|
+
diffCurrentAndRemoteFolderVersions(
|
|
1131
|
+
path: string, remoteVersion?: number
|
|
1132
|
+
): Promise<FolderDiff|undefined>;
|
|
1133
|
+
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
interface FolderDiff {
|
|
1137
|
+
currentVersion: number;
|
|
1138
|
+
isCurrentLocal: boolean;
|
|
1139
|
+
remoteVersion?: number;
|
|
1140
|
+
isRemoteArchived: boolean;
|
|
1141
|
+
inCurrent?: ListingEntry[];
|
|
1142
|
+
inRemote?: ListingEntry[];
|
|
1143
|
+
nameOverlaps?: string[];
|
|
1144
|
+
ctime: {
|
|
1145
|
+
remote?: Date;
|
|
1146
|
+
current: Date;
|
|
1147
|
+
};
|
|
1148
|
+
mtime: {
|
|
1149
|
+
remote?: Date;
|
|
1150
|
+
current: Date;
|
|
1151
|
+
};
|
|
1152
|
+
xattrs?: {
|
|
1153
|
+
inCurrent?: { name: string; value: any; }[];
|
|
1154
|
+
inRemote?: { name: string; value: any; }[];
|
|
1155
|
+
nameOverlaps?: string[];
|
|
1156
|
+
};
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
interface WritableFSSyncAPI extends ReadonlyFSSyncAPI {
|
|
1160
|
+
|
|
1161
|
+
upload(path: string, opts?: OptionsToUploadLocal): Promise<void>;
|
|
1162
|
+
|
|
1163
|
+
adoptRemoteFolderItem(
|
|
1164
|
+
path: string, itemName: string, opts?: OptionsToAdoptRemoteItem
|
|
1165
|
+
): Promise<number>;
|
|
1166
|
+
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
interface OptionsToAdoptRemoteItem {
|
|
1170
|
+
localVersion?: number;
|
|
1171
|
+
remoteVersion?: number;
|
|
994
1172
|
}
|
|
995
1173
|
|
|
996
1174
|
interface FSEvent {
|
|
997
|
-
type: string;
|
|
998
1175
|
path: string;
|
|
999
|
-
isRemote?: boolean;
|
|
1000
|
-
newVersion?: number;
|
|
1001
1176
|
}
|
|
1002
1177
|
|
|
1003
|
-
interface
|
|
1178
|
+
interface FSChangeEvent {
|
|
1179
|
+
path: string;
|
|
1180
|
+
src: 'local'|'sync';
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
interface RemovedEvent extends FSChangeEvent {
|
|
1004
1184
|
type: 'removed';
|
|
1005
1185
|
}
|
|
1006
1186
|
|
|
1007
|
-
interface
|
|
1008
|
-
type: '
|
|
1009
|
-
|
|
1010
|
-
|
|
1187
|
+
interface VersionChangeOnUpload extends FSChangeEvent {
|
|
1188
|
+
type: 'version-change-on-upload';
|
|
1189
|
+
src: 'sync';
|
|
1190
|
+
newVersion: number;
|
|
1011
1191
|
}
|
|
1012
1192
|
|
|
1013
1193
|
type FolderEvent = EntryRemovalEvent | EntryAdditionEvent |
|
|
1014
|
-
EntryRenamingEvent | RemovedEvent |
|
|
1194
|
+
EntryRenamingEvent | RemovedEvent | VersionChangeOnUpload;
|
|
1015
1195
|
|
|
1016
|
-
interface EntryRemovalEvent extends
|
|
1196
|
+
interface EntryRemovalEvent extends FSChangeEvent {
|
|
1017
1197
|
type: 'entry-removal';
|
|
1018
1198
|
name: string;
|
|
1019
1199
|
moveLabel?: number;
|
|
1200
|
+
newVersion?: number;
|
|
1020
1201
|
}
|
|
1021
1202
|
|
|
1022
|
-
interface EntryAdditionEvent extends
|
|
1203
|
+
interface EntryAdditionEvent extends FSChangeEvent {
|
|
1023
1204
|
type: 'entry-addition';
|
|
1024
1205
|
entry: ListingEntry;
|
|
1025
1206
|
moveLabel?: number;
|
|
1207
|
+
newVersion?: number;
|
|
1026
1208
|
}
|
|
1027
1209
|
|
|
1028
|
-
interface EntryRenamingEvent extends
|
|
1210
|
+
interface EntryRenamingEvent extends FSChangeEvent {
|
|
1029
1211
|
type: 'entry-renaming';
|
|
1030
1212
|
oldName: string;
|
|
1031
1213
|
newName: string;
|
|
1214
|
+
newVersion?: number;
|
|
1032
1215
|
}
|
|
1033
1216
|
|
|
1034
|
-
type FileEvent = FileChangeEvent | RemovedEvent |
|
|
1217
|
+
type FileEvent = FileChangeEvent | RemovedEvent | VersionChangeOnUpload;
|
|
1035
1218
|
|
|
1036
|
-
interface FileChangeEvent extends
|
|
1219
|
+
interface FileChangeEvent extends FSChangeEvent {
|
|
1037
1220
|
type: 'file-change';
|
|
1221
|
+
newVersion?: number;
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
type RemoteEvent = RemoteVersionArchivalEvent | RemoteArchVerRemovalEvent |
|
|
1225
|
+
RemoteRemovalEvent | RemoteChangeEvent;
|
|
1226
|
+
|
|
1227
|
+
interface RemoteVersionArchivalEvent extends FSEvent {
|
|
1228
|
+
type: 'remote-version-archival';
|
|
1229
|
+
archivedVersion: number;
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
interface RemoteArchVerRemovalEvent extends FSEvent {
|
|
1233
|
+
type: 'remote-arch-ver-removal';
|
|
1234
|
+
removedArchVer: number;
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
interface RemoteRemovalEvent extends FSEvent {
|
|
1238
|
+
type: 'remote-removal';
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
interface RemoteChangeEvent extends FSEvent {
|
|
1242
|
+
type: 'remote-change';
|
|
1243
|
+
newVersion: number;
|
|
1038
1244
|
}
|
|
1039
1245
|
|
|
1040
1246
|
}
|
package/build/core/app-files.js
CHANGED
|
@@ -33,32 +33,32 @@ const INBOX_DIR = 'inbox';
|
|
|
33
33
|
const STORAGE_DIR = 'storage';
|
|
34
34
|
function appDirs(appDir) {
|
|
35
35
|
function userDataPath(user) {
|
|
36
|
-
return path_1.join(appDir, userIdToFolderName(user));
|
|
36
|
+
return (0, path_1.join)(appDir, userIdToFolderName(user));
|
|
37
37
|
}
|
|
38
38
|
;
|
|
39
39
|
async function appFS() {
|
|
40
|
-
await async_fs_node_1.stat(appDir).catch(async (e) => {
|
|
40
|
+
await (0, async_fs_node_1.stat)(appDir).catch(async (e) => {
|
|
41
41
|
if (!e.notFound) {
|
|
42
42
|
throw e;
|
|
43
43
|
}
|
|
44
|
-
await async_fs_node_1.mkdir(appDir).catch((e) => {
|
|
44
|
+
await (0, async_fs_node_1.mkdir)(appDir).catch((e) => {
|
|
45
45
|
if (e.alreadyExists) {
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
|
-
throw error_1.errWithCause(e, `Cannot create app folder on the disk`);
|
|
48
|
+
throw (0, error_1.errWithCause)(e, `Cannot create app folder on the disk`);
|
|
49
49
|
});
|
|
50
50
|
});
|
|
51
51
|
return device_fs_1.DeviceFS.makeWritable(appDir);
|
|
52
52
|
}
|
|
53
53
|
return Object.freeze({
|
|
54
54
|
getUtilFS() {
|
|
55
|
-
return path_1.join(appDir, exports.UTIL_DIR);
|
|
55
|
+
return (0, path_1.join)(appDir, exports.UTIL_DIR);
|
|
56
56
|
},
|
|
57
57
|
storagePathFor(user) {
|
|
58
|
-
return path_1.join(userDataPath(user), STORAGE_DIR);
|
|
58
|
+
return (0, path_1.join)(userDataPath(user), STORAGE_DIR);
|
|
59
59
|
},
|
|
60
60
|
inboxPathFor(user) {
|
|
61
|
-
return path_1.join(userDataPath(user), INBOX_DIR);
|
|
61
|
+
return (0, path_1.join)(userDataPath(user), INBOX_DIR);
|
|
62
62
|
},
|
|
63
63
|
async getUsersOnDisk() {
|
|
64
64
|
const rootFS = await appFS();
|
|
@@ -55,12 +55,12 @@ class ParamOnFileAndServer extends file_based_json_1.JsonFileProc {
|
|
|
55
55
|
throw exc;
|
|
56
56
|
});
|
|
57
57
|
const currentVal = this.toServiceJSON();
|
|
58
|
-
if (!json_utils_1.deepEqual(infoOnServer, currentVal)) {
|
|
58
|
+
if (!(0, json_utils_1.deepEqual)(infoOnServer, currentVal)) {
|
|
59
59
|
await this.serviceConf.setParam(this.paramPath, currentVal);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
async onFileEvent(ev) {
|
|
63
|
-
if (
|
|
63
|
+
if (ev.src === 'local') {
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
66
66
|
if (ev.type === 'removed') {
|
|
@@ -47,7 +47,7 @@ class ConfigOfASMailServer {
|
|
|
47
47
|
}
|
|
48
48
|
static async makeAndStart(address, getSigner, resolver, net, fs) {
|
|
49
49
|
try {
|
|
50
|
-
file_1.ensureCorrectFS(fs, 'synced', true);
|
|
50
|
+
(0, file_1.ensureCorrectFS)(fs, 'synced', true);
|
|
51
51
|
const conf = new ConfigOfASMailServer(address, getSigner, resolver, net);
|
|
52
52
|
await Promise.all([
|
|
53
53
|
fs.writableFile(ANON_SENDER_INVITES_FILE)
|
|
@@ -59,7 +59,7 @@ class ConfigOfASMailServer {
|
|
|
59
59
|
return conf;
|
|
60
60
|
}
|
|
61
61
|
catch (err) {
|
|
62
|
-
throw error_1.errWithCause(err, 'Failed to initialize ConfigOfASMailServer');
|
|
62
|
+
throw (0, error_1.errWithCause)(err, 'Failed to initialize ConfigOfASMailServer');
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -80,7 +80,7 @@ class PublishedIntroKey extends common_2.ParamOnFileAndServer {
|
|
|
80
80
|
}
|
|
81
81
|
async makeNewIntroKey() {
|
|
82
82
|
const signer = await this.getSigner();
|
|
83
|
-
const pair = await common_1.generateKeyPair();
|
|
83
|
+
const pair = await (0, common_1.generateKeyPair)();
|
|
84
84
|
const certs = {
|
|
85
85
|
pkeyCert: signer.certifyPublicKey(pair.pkey, INTRO_KEY_VALIDITY),
|
|
86
86
|
userCert: signer.userCert,
|