core-3nweb-client-lib 0.25.6 → 0.27.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/README.md +2 -2
- package/build/api-defs/asmail.d.ts +1 -1
- package/build/api-defs/files.d.ts +282 -70
- package/build/core/app-files.js +7 -7
- package/build/core/asmail/config/common.js +4 -4
- 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 +7 -6
- package/build/core/asmail/delivery/msg.js +8 -7
- package/build/core/asmail/delivery/per-recipient-wip.js +3 -3
- package/build/core/asmail/inbox/attachments/fs.js +11 -1
- package/build/core/asmail/inbox/cached-msgs.js +3 -3
- package/build/core/asmail/inbox/inbox-events.js +5 -4
- package/build/core/asmail/inbox/index.js +12 -12
- package/build/core/asmail/inbox/msg-downloader.js +3 -3
- package/build/core/asmail/inbox/msg-indexing.js +4 -4
- package/build/core/asmail/inbox/msg-on-disk.js +7 -7
- 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 +4 -3
- 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 +4 -4
- package/build/core/asmail/sending-params/params-from-others.js +3 -3
- package/build/core/id-manager.js +8 -5
- package/build/core/index.d.ts +2 -1
- package/build/core/index.js +14 -14
- package/build/core/sign-in.d.ts +5 -4
- package/build/core/sign-in.js +12 -14
- package/build/core/sign-up.d.ts +1 -0
- package/build/core/sign-up.js +15 -11
- package/build/core/storage/common/json-saving.d.ts +21 -0
- package/build/core/storage/common/json-saving.js +82 -0
- package/build/core/storage/common/obj-info-file.d.ts +51 -0
- package/build/core/storage/common/obj-info-file.js +153 -5
- 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 +3 -17
- package/build/core/storage/index.js +57 -77
- package/build/core/storage/local/obj-files-gc.d.ts +2 -0
- package/build/core/storage/local/obj-files-gc.js +53 -39
- package/build/core/storage/local/obj-files.d.ts +6 -9
- package/build/core/storage/local/obj-files.js +16 -19
- package/build/core/storage/local/obj-status.d.ts +20 -30
- package/build/core/storage/local/obj-status.js +46 -113
- package/build/core/storage/local/storage.d.ts +15 -5
- package/build/core/storage/local/storage.js +37 -18
- package/build/core/storage/synced/downloader.js +7 -6
- package/build/core/storage/synced/obj-files-gc.d.ts +6 -1
- package/build/core/storage/synced/obj-files-gc.js +106 -13
- package/build/core/storage/synced/obj-files.d.ts +46 -47
- package/build/core/storage/synced/obj-files.js +207 -154
- package/build/core/storage/synced/obj-status.d.ts +103 -42
- package/build/core/storage/synced/obj-status.js +525 -137
- package/build/core/storage/synced/remote-events.d.ts +11 -12
- package/build/core/storage/synced/remote-events.js +80 -57
- package/build/core/storage/synced/storage.d.ts +24 -5
- package/build/core/storage/synced/storage.js +123 -38
- 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 +15 -9
- package/build/core/storage/synced/upsyncer.js +219 -246
- 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 +67 -83
- package/build/ipc-via-protobuf/bytes.js +16 -17
- package/build/ipc-via-protobuf/connector-clients-side.d.ts +3 -0
- package/build/ipc-via-protobuf/connector-clients-side.js +62 -25
- 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 +476 -120
- package/build/ipc-via-protobuf/fs.d.ts +8 -0
- package/build/ipc-via-protobuf/fs.js +592 -159
- 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 +23 -23
- package/build/ipc-via-protobuf/storage-cap.js +12 -12
- package/build/ipc.js +7 -2
- package/build/lib-client/3nstorage/exceptions.d.ts +12 -8
- package/build/lib-client/3nstorage/exceptions.js +31 -10
- package/build/lib-client/3nstorage/service.d.ts +16 -2
- package/build/lib-client/3nstorage/service.js +109 -39
- package/build/lib-client/3nstorage/util/file-based-json.d.ts +2 -1
- package/build/lib-client/3nstorage/util/file-based-json.js +1 -1
- package/build/lib-client/3nstorage/xsp-fs/attrs.js +17 -17
- package/build/lib-client/3nstorage/xsp-fs/common.d.ts +52 -14
- package/build/lib-client/3nstorage/xsp-fs/common.js +31 -16
- package/build/lib-client/3nstorage/xsp-fs/file-node.d.ts +1 -0
- package/build/lib-client/3nstorage/xsp-fs/file-node.js +18 -14
- package/build/lib-client/3nstorage/xsp-fs/file.d.ts +31 -6
- package/build/lib-client/3nstorage/xsp-fs/file.js +74 -23
- package/build/lib-client/3nstorage/xsp-fs/folder-node-serialization.js +4 -4
- package/build/lib-client/3nstorage/xsp-fs/folder-node.d.ts +24 -11
- package/build/lib-client/3nstorage/xsp-fs/folder-node.js +599 -189
- package/build/lib-client/3nstorage/xsp-fs/fs.d.ts +45 -9
- package/build/lib-client/3nstorage/xsp-fs/fs.js +326 -74
- 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 -20
- package/build/lib-client/3nstorage/xsp-fs/node-in-fs.js +239 -106
- package/build/lib-client/3nstorage/xsp-fs/node-persistence.d.ts +1 -1
- package/build/lib-client/3nstorage/xsp-fs/node-persistence.js +18 -19
- package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v1.js +5 -5
- package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v2.js +56 -56
- 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 +19 -17
- 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 +7 -7
- 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 -4
- package/build/lib-client/fs-collection.js +3 -2
- 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 +11 -11
- 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 +5 -5
- package/build/lib-client/objs-on-disk/obj-folders.js +33 -33
- 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 +14 -14
- package/build/lib-client/server-events.d.ts +3 -3
- package/build/lib-client/server-events.js +12 -10
- package/build/lib-client/service-locator.js +10 -10
- package/build/lib-client/user-with-mid-session.js +7 -7
- package/build/lib-client/user-with-pkl-session.js +25 -25
- package/build/lib-client/ws-utils.js +3 -3
- 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 +19 -18
- package/build/lib-common/byte-streaming/pipe.js +1 -1
- package/build/lib-common/byte-streaming/wrapping.js +17 -17
- 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.js +10 -1
- package/build/lib-common/ipc/generic-ipc.js +2 -2
- package/build/lib-common/ipc/ws-ipc.js +2 -2
- package/build/lib-common/json-utils.js +2 -1
- 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 +99 -37
- package/build/lib-common/objs-on-disk/utils.d.ts +1 -0
- package/build/lib-common/objs-on-disk/utils.js +4 -4
- package/build/lib-common/objs-on-disk/v1-obj-file-format.js +14 -14
- package/build/lib-common/processes/deferred.d.ts +6 -0
- package/build/lib-common/processes/deferred.js +30 -0
- package/build/lib-common/processes/labelled-exec-pools.d.ts +33 -0
- package/build/lib-common/processes/labelled-exec-pools.js +141 -0
- package/build/lib-common/processes/pressure.d.ts +7 -0
- package/build/lib-common/processes/pressure.js +56 -0
- package/build/lib-common/processes/sleep.d.ts +1 -0
- package/build/lib-common/processes/sleep.js +26 -0
- package/build/lib-common/{processes.d.ts → processes/synced.d.ts} +0 -40
- package/build/lib-common/{processes.js → processes/synced.js} +187 -204
- package/build/lib-common/processes/timeout.d.ts +1 -0
- package/build/lib-common/processes/timeout.js +51 -0
- package/build/lib-common/random-node.js +7 -7
- package/build/lib-common/service-api/3nstorage/owner.d.ts +100 -39
- package/build/lib-common/service-api/3nstorage/owner.js +85 -42
- 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.d.ts +15 -1
- package/build/lib-common/utils-for-observables.js +70 -19
- 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 +12912 -7127
- package/build/protos/file.proto.js +4848 -2399
- package/build/protos/fs.proto.js +9230 -3445
- package/package.json +8 -7
- package/protos/file.proto +91 -11
- package/protos/fs.proto +107 -8
- package/build/core/storage/synced/upsync-status.d.ts +0 -41
- package/build/core/storage/synced/upsync-status.js +0 -158
package/README.md
CHANGED
|
@@ -10,9 +10,9 @@ After repository clone, bring down all NodeJS modules, by running in project's f
|
|
|
10
10
|
npm ci
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Tests have some unit and integrated components. Integration test uses 3NWeb spec server.
|
|
13
|
+
Tests have some unit and integrated components. Integration test uses 3NWeb spec server. Integrated tests use server and dns mocking from `spec-3nweb-server`.
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Build is done with
|
|
16
16
|
```
|
|
17
17
|
npm run build
|
|
18
18
|
```
|
|
@@ -40,6 +40,7 @@ declare namespace web3n.files {
|
|
|
40
40
|
attrsNotEnabledInFS?: true;
|
|
41
41
|
versionMismatch?: true;
|
|
42
42
|
isEndless?: true;
|
|
43
|
+
storageClosed?: true;
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
interface exceptionCode {
|
|
@@ -58,6 +59,25 @@ declare namespace web3n.files {
|
|
|
58
59
|
parsingError: 'parsing-error';
|
|
59
60
|
notImplemented: 'ENOSYS';
|
|
60
61
|
isEndless: 'is-endless';
|
|
62
|
+
storageClosed: 'storage-closed';
|
|
63
|
+
versionMismatch: 'version-mismatch';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
interface FSSyncException extends RuntimeException {
|
|
67
|
+
type: 'fs-sync';
|
|
68
|
+
path: string;
|
|
69
|
+
localVersion?: number;
|
|
70
|
+
remoteVersion?: number;
|
|
71
|
+
alreadyUploading?: true;
|
|
72
|
+
versionNotFound?: true;
|
|
73
|
+
childNeverUploaded?: true;
|
|
74
|
+
childName?: string;
|
|
75
|
+
removedOnServer?: true;
|
|
76
|
+
versionMismatch?: true;
|
|
77
|
+
conflict?: true;
|
|
78
|
+
notSynced?: true;
|
|
79
|
+
remoteIsArchived?: true;
|
|
80
|
+
remoteFolderItemNotFound?: true;
|
|
61
81
|
}
|
|
62
82
|
|
|
63
83
|
/**
|
|
@@ -126,6 +146,41 @@ declare namespace web3n.files {
|
|
|
126
146
|
|
|
127
147
|
}
|
|
128
148
|
|
|
149
|
+
/**
|
|
150
|
+
* Sync status contains info about possible version branches with possible
|
|
151
|
+
* states:
|
|
152
|
+
* 1. unsynced - have local branch, and possibly synced one.
|
|
153
|
+
* Local version(s) should be uploaded to get into synced state.
|
|
154
|
+
* 2. synced - have only synced branch.
|
|
155
|
+
* 3. behind - have both synced and remote branches.
|
|
156
|
+
* Should explicitly advance to newer version to get into synced state.
|
|
157
|
+
* 4. conflicting - have conflicting local and remote branches, with possible
|
|
158
|
+
* common synced history branch.
|
|
159
|
+
* Conflict gets fixed by uploading some local version with value greater
|
|
160
|
+
* than remote's latest. Making this version is a custom magic of
|
|
161
|
+
* conflict resolution that you do for your app.
|
|
162
|
+
*/
|
|
163
|
+
interface SyncStatus {
|
|
164
|
+
state: SyncState;
|
|
165
|
+
synced?: SyncVersionsBranch;
|
|
166
|
+
local?: LocalVersion;
|
|
167
|
+
remote?: SyncVersionsBranch;
|
|
168
|
+
existsInSyncedParent?: boolean;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
interface LocalVersion {
|
|
172
|
+
latest?: number;
|
|
173
|
+
isArchived?: boolean;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
interface SyncVersionsBranch {
|
|
177
|
+
latest?: number;
|
|
178
|
+
archived?: number[];
|
|
179
|
+
isArchived?: boolean;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
type SyncState = 'synced' | 'behind' | 'unsynced' | 'conflicting';
|
|
183
|
+
|
|
129
184
|
interface FileByteSource {
|
|
130
185
|
|
|
131
186
|
/**
|
|
@@ -312,7 +367,7 @@ declare namespace web3n.files {
|
|
|
312
367
|
*/
|
|
313
368
|
getByteSource(): Promise<FileByteSource>;
|
|
314
369
|
|
|
315
|
-
watch(observer: Observer<FileEvent>): () => void;
|
|
370
|
+
watch(observer: Observer<FileEvent|RemoteEvent>): () => void;
|
|
316
371
|
|
|
317
372
|
}
|
|
318
373
|
|
|
@@ -382,8 +437,9 @@ declare namespace web3n.files {
|
|
|
382
437
|
* greater than file length, all available bytes are read. If parameter
|
|
383
438
|
* is missing, read will be done to file's end.
|
|
384
439
|
*/
|
|
385
|
-
readBytes(
|
|
386
|
-
|
|
440
|
+
readBytes(
|
|
441
|
+
start?: number, end?: number
|
|
442
|
+
): Promise<{ bytes: Uint8Array|undefined; version: number; }>;
|
|
387
443
|
|
|
388
444
|
/**
|
|
389
445
|
* This returns a promise, resolvable to text, read from file, assuming
|
|
@@ -402,6 +458,10 @@ declare namespace web3n.files {
|
|
|
402
458
|
*/
|
|
403
459
|
getByteSource(): Promise<{ src: FileByteSource; version: number; }>;
|
|
404
460
|
|
|
461
|
+
listVersions(): Promise<{ current?: number; archived?: number[]; }>;
|
|
462
|
+
|
|
463
|
+
sync?: ReadonlyFileSyncAPI;
|
|
464
|
+
|
|
405
465
|
}
|
|
406
466
|
|
|
407
467
|
interface WritableFileVersionedAPI extends ReadonlyFileVersionedAPI {
|
|
@@ -444,8 +504,9 @@ declare namespace web3n.files {
|
|
|
444
504
|
* When current version is given, an error is thrown, if file version at
|
|
445
505
|
* the moment of writing is different.
|
|
446
506
|
*/
|
|
447
|
-
getByteSink(
|
|
448
|
-
|
|
507
|
+
getByteSink(
|
|
508
|
+
truncateFile?: boolean, currentVersion?: number
|
|
509
|
+
): Promise<{ sink: FileByteSink; version: number; }>;
|
|
449
510
|
|
|
450
511
|
/**
|
|
451
512
|
* This returns a promise, resolvable to new file's version when copying
|
|
@@ -453,7 +514,48 @@ declare namespace web3n.files {
|
|
|
453
514
|
* @param file which content will be copied into this file
|
|
454
515
|
*/
|
|
455
516
|
copy(file: File): Promise<number>;
|
|
456
|
-
|
|
517
|
+
|
|
518
|
+
archiveCurrent(version?: number): Promise<number>;
|
|
519
|
+
|
|
520
|
+
sync?: WritableFileSyncAPI;
|
|
521
|
+
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
interface ReadonlyFileSyncAPI {
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Returns synchronization status of this object, as is currently known
|
|
528
|
+
* here without checking remote server.
|
|
529
|
+
*/
|
|
530
|
+
status(): Promise<SyncStatus>;
|
|
531
|
+
|
|
532
|
+
updateStatusInfo(): Promise<SyncStatus>;
|
|
533
|
+
|
|
534
|
+
isRemoteVersionOnDisk(
|
|
535
|
+
version: number
|
|
536
|
+
): Promise<'partial'|'complete'|'none'>;
|
|
537
|
+
|
|
538
|
+
download(version: number): Promise<void>;
|
|
539
|
+
|
|
540
|
+
adoptRemote(opts?: OptionsToAdopteRemote): Promise<void>;
|
|
541
|
+
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
interface OptionsToAdopteRemote {
|
|
545
|
+
dropLocalVer?: boolean;
|
|
546
|
+
remoteVersion?: number;
|
|
547
|
+
download?: boolean;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
interface WritableFileSyncAPI extends ReadonlyFileSyncAPI {
|
|
551
|
+
|
|
552
|
+
upload(opts?: OptionsToUploadLocal): Promise<void>;
|
|
553
|
+
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
interface OptionsToUploadLocal {
|
|
557
|
+
localVersion?: number;
|
|
558
|
+
uploadVersion?: number;
|
|
457
559
|
}
|
|
458
560
|
|
|
459
561
|
type FSType = 'device' | 'synced' | 'local' | 'share' | 'asmail-msg';
|
|
@@ -482,8 +584,9 @@ declare namespace web3n.files {
|
|
|
482
584
|
* throwing of an exception, when folder does not exist. Default value is
|
|
483
585
|
* false.
|
|
484
586
|
*/
|
|
485
|
-
checkFolderPresence(
|
|
486
|
-
|
|
587
|
+
checkFolderPresence(
|
|
588
|
+
path: string, throwIfMissing?: boolean
|
|
589
|
+
): Promise<boolean>;
|
|
487
590
|
|
|
488
591
|
/**
|
|
489
592
|
* This returns a promise, resolvable to true, if file exists, and to
|
|
@@ -493,8 +596,9 @@ declare namespace web3n.files {
|
|
|
493
596
|
* throwing of an exception, when file does not exist. Default value is
|
|
494
597
|
* false.
|
|
495
598
|
*/
|
|
496
|
-
checkFilePresence(
|
|
497
|
-
|
|
599
|
+
checkFilePresence(
|
|
600
|
+
path: string, throwIfMissing?: boolean
|
|
601
|
+
): Promise<boolean>;
|
|
498
602
|
|
|
499
603
|
/**
|
|
500
604
|
* This returns a promise, resolvable to true, if link exists, and to
|
|
@@ -504,8 +608,9 @@ declare namespace web3n.files {
|
|
|
504
608
|
* throwing of an exception, when link does not exist. Default value is
|
|
505
609
|
* false.
|
|
506
610
|
*/
|
|
507
|
-
checkLinkPresence(
|
|
508
|
-
|
|
611
|
+
checkLinkPresence(
|
|
612
|
+
path: string, throwIfMissing?: boolean
|
|
613
|
+
): Promise<boolean>;
|
|
509
614
|
|
|
510
615
|
/**
|
|
511
616
|
* This returns a promise, resolvable to stats of an entity at a given
|
|
@@ -530,12 +635,18 @@ declare namespace web3n.files {
|
|
|
530
635
|
|
|
531
636
|
readLink(path: string): Promise<SymLink>;
|
|
532
637
|
|
|
533
|
-
watchFolder(
|
|
638
|
+
watchFolder(
|
|
639
|
+
path: string, observer: Observer<FolderEvent|RemoteEvent>
|
|
640
|
+
): () => void;
|
|
534
641
|
|
|
535
|
-
watchFile(
|
|
642
|
+
watchFile(
|
|
643
|
+
path: string, observer: Observer<FileEvent|RemoteEvent>
|
|
644
|
+
): () => void;
|
|
536
645
|
|
|
537
|
-
watchTree(
|
|
538
|
-
|
|
646
|
+
watchTree(
|
|
647
|
+
path: string, depth: number|undefined,
|
|
648
|
+
observer: Observer<FolderEvent|FileEvent|RemoteEvent>
|
|
649
|
+
): () => void;
|
|
539
650
|
|
|
540
651
|
close(): Promise<void>;
|
|
541
652
|
|
|
@@ -577,8 +688,9 @@ declare namespace web3n.files {
|
|
|
577
688
|
* greater than file length, all available bytes are read. If parameter
|
|
578
689
|
* is missing, read will be done to file's end.
|
|
579
690
|
*/
|
|
580
|
-
readBytes(
|
|
581
|
-
|
|
691
|
+
readBytes(
|
|
692
|
+
path: string, start?: number, end?: number
|
|
693
|
+
): Promise<Uint8Array|undefined>;
|
|
582
694
|
|
|
583
695
|
/**
|
|
584
696
|
* This returns a promise, resolvable to bytes source with seek, which
|
|
@@ -603,8 +715,9 @@ declare namespace web3n.files {
|
|
|
603
715
|
* @param path
|
|
604
716
|
* @param criteria
|
|
605
717
|
*/
|
|
606
|
-
select(
|
|
607
|
-
|
|
718
|
+
select(
|
|
719
|
+
path: string, criteria: SelectCriteria
|
|
720
|
+
): Promise<{ items: FSCollection; completion: Promise<void>; }>;
|
|
608
721
|
|
|
609
722
|
}
|
|
610
723
|
|
|
@@ -736,8 +849,9 @@ declare namespace web3n.files {
|
|
|
736
849
|
* @param overwrite is a flag that with a true value allows
|
|
737
850
|
* overwrite of existing dst file. Default value is false.
|
|
738
851
|
*/
|
|
739
|
-
copyFile(
|
|
740
|
-
|
|
852
|
+
copyFile(
|
|
853
|
+
src: string, dst: string, overwrite?: boolean
|
|
854
|
+
): Promise<void>;
|
|
741
855
|
|
|
742
856
|
/**
|
|
743
857
|
* This returns a promise, resolvable when folder has been recursively
|
|
@@ -748,8 +862,9 @@ declare namespace web3n.files {
|
|
|
748
862
|
* merge into existing folder and files overwriting inside. Default
|
|
749
863
|
* value is false.
|
|
750
864
|
*/
|
|
751
|
-
copyFolder(
|
|
752
|
-
|
|
865
|
+
copyFolder(
|
|
866
|
+
src: string, dst: string, mergeAndOverwrite?: boolean
|
|
867
|
+
): Promise<void>;
|
|
753
868
|
|
|
754
869
|
/**
|
|
755
870
|
* This returns a promise, resolvable when file has been saved.
|
|
@@ -769,8 +884,9 @@ declare namespace web3n.files {
|
|
|
769
884
|
* merge into existing folder and files overwriting inside. Default
|
|
770
885
|
* value is false.
|
|
771
886
|
*/
|
|
772
|
-
saveFolder(
|
|
773
|
-
|
|
887
|
+
saveFolder(
|
|
888
|
+
folder: FS, dst: string, mergeAndOverwrite?: boolean
|
|
889
|
+
): Promise<void>;
|
|
774
890
|
|
|
775
891
|
/**
|
|
776
892
|
* This returns a promise, resolvable when file has been removed
|
|
@@ -814,8 +930,9 @@ declare namespace web3n.files {
|
|
|
814
930
|
* @param flags are optional flags. Default flags are create=true,
|
|
815
931
|
* exclusive=false.
|
|
816
932
|
*/
|
|
817
|
-
writeBytes(
|
|
818
|
-
|
|
933
|
+
writeBytes(
|
|
934
|
+
path: string, bytes: Uint8Array, flags?: FileFlags
|
|
935
|
+
): Promise<void>;
|
|
819
936
|
|
|
820
937
|
/**
|
|
821
938
|
* This returns a promise, resolvable to byte sink with seek
|
|
@@ -871,8 +988,9 @@ declare namespace web3n.files {
|
|
|
871
988
|
|
|
872
989
|
interface ReadonlyFSVersionedAPI {
|
|
873
990
|
|
|
874
|
-
getXAttr(
|
|
875
|
-
|
|
991
|
+
getXAttr(
|
|
992
|
+
path: string, xaName: string
|
|
993
|
+
): Promise<{ attr: any; version: number; }>;
|
|
876
994
|
|
|
877
995
|
listXAttrs(path: string): Promise<{ lst: string[]; version: number; }>;
|
|
878
996
|
|
|
@@ -881,8 +999,9 @@ declare namespace web3n.files {
|
|
|
881
999
|
* for entries in the folder, and a folder's version.
|
|
882
1000
|
* @param path of a folder that should be listed
|
|
883
1001
|
*/
|
|
884
|
-
listFolder(
|
|
885
|
-
|
|
1002
|
+
listFolder(
|
|
1003
|
+
path: string
|
|
1004
|
+
): Promise<{ lst: ListingEntry[]; version: number; }>;
|
|
886
1005
|
|
|
887
1006
|
/**
|
|
888
1007
|
* This returns a promise, resolvable to json, read from file, and a
|
|
@@ -909,16 +1028,24 @@ declare namespace web3n.files {
|
|
|
909
1028
|
* greater than file length, all available bytes are read. If parameter
|
|
910
1029
|
* is missing, read will be done to file's end.
|
|
911
1030
|
*/
|
|
912
|
-
readBytes(
|
|
913
|
-
|
|
1031
|
+
readBytes(
|
|
1032
|
+
path: string, start?: number, end?: number
|
|
1033
|
+
): Promise<{ bytes: Uint8Array|undefined; version: number; }>;
|
|
914
1034
|
|
|
915
1035
|
/**
|
|
916
1036
|
* This returns a promise, resolvable to bytes source with seek, which
|
|
917
1037
|
* allows random reads, and a file version
|
|
918
1038
|
* @param path of a file from which to read bytes
|
|
919
1039
|
*/
|
|
920
|
-
getByteSource(
|
|
921
|
-
|
|
1040
|
+
getByteSource(
|
|
1041
|
+
path: string
|
|
1042
|
+
): Promise<{ src: FileByteSource; version: number; }>;
|
|
1043
|
+
|
|
1044
|
+
listVersions(
|
|
1045
|
+
path: string
|
|
1046
|
+
): Promise<{ current?: number; archived?: number[]; }>;
|
|
1047
|
+
|
|
1048
|
+
sync?: ReadonlyFSSyncAPI;
|
|
922
1049
|
|
|
923
1050
|
}
|
|
924
1051
|
|
|
@@ -940,8 +1067,9 @@ declare namespace web3n.files {
|
|
|
940
1067
|
* @param flags are optional flags. Default flags are create=true,
|
|
941
1068
|
* exclusive=false.
|
|
942
1069
|
*/
|
|
943
|
-
writeJSONFile(
|
|
944
|
-
|
|
1070
|
+
writeJSONFile(
|
|
1071
|
+
path: string, json: any, flags?: VersionedFileFlags
|
|
1072
|
+
): Promise<number>;
|
|
945
1073
|
|
|
946
1074
|
/**
|
|
947
1075
|
* This returns a promise, resolvable to new file's version when file is
|
|
@@ -951,8 +1079,9 @@ declare namespace web3n.files {
|
|
|
951
1079
|
* @param flags are optional flags. Default flags are create=true,
|
|
952
1080
|
* exclusive=false.
|
|
953
1081
|
*/
|
|
954
|
-
writeTxtFile(
|
|
955
|
-
|
|
1082
|
+
writeTxtFile(
|
|
1083
|
+
path: string, txt: string, flags?: VersionedFileFlags
|
|
1084
|
+
): Promise<number>;
|
|
956
1085
|
|
|
957
1086
|
/**
|
|
958
1087
|
* This returns a promise, resolvable to new file's version when file is
|
|
@@ -962,8 +1091,9 @@ declare namespace web3n.files {
|
|
|
962
1091
|
* @param flags are optional flags. Default flags are create=true,
|
|
963
1092
|
* exclusive=false.
|
|
964
1093
|
*/
|
|
965
|
-
writeBytes(
|
|
966
|
-
|
|
1094
|
+
writeBytes(
|
|
1095
|
+
path: string, bytes: Uint8Array, flags?: VersionedFileFlags
|
|
1096
|
+
): Promise<number>;
|
|
967
1097
|
|
|
968
1098
|
/**
|
|
969
1099
|
* This returns a promise, resolvable to byte sink with seek, and a file
|
|
@@ -972,66 +1102,148 @@ declare namespace web3n.files {
|
|
|
972
1102
|
* @param flags are optional flags. Default flags are create=true,
|
|
973
1103
|
* exclusive=false, truncate=true.
|
|
974
1104
|
*/
|
|
975
|
-
getByteSink(
|
|
976
|
-
|
|
1105
|
+
getByteSink(
|
|
1106
|
+
path: string, flags?: VersionedFileFlags
|
|
1107
|
+
): Promise<{ sink: FileByteSink; version: number; }>;
|
|
1108
|
+
|
|
1109
|
+
archiveCurrent(path: string, version?: number): Promise<number>;
|
|
1110
|
+
|
|
1111
|
+
sync?: WritableFSSyncAPI;
|
|
977
1112
|
|
|
978
1113
|
}
|
|
979
1114
|
|
|
980
|
-
interface
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
1115
|
+
interface ReadonlyFSSyncAPI {
|
|
1116
|
+
|
|
1117
|
+
/**
|
|
1118
|
+
* Returns synchronization status of this object, as is currently known
|
|
1119
|
+
* here without checking remote server.
|
|
1120
|
+
*/
|
|
1121
|
+
status(path: string): Promise<SyncStatus>;
|
|
1122
|
+
|
|
1123
|
+
updateStatusInfo(path: string): Promise<SyncStatus>;
|
|
1124
|
+
|
|
1125
|
+
isRemoteVersionOnDisk(
|
|
1126
|
+
path: string, version: number
|
|
1127
|
+
): Promise<'partial'|'complete'|'none'>;
|
|
1128
|
+
|
|
1129
|
+
download(path: string, version: number): Promise<void>;
|
|
1130
|
+
|
|
1131
|
+
adoptRemote(path: string, opts?: OptionsToAdopteRemote): Promise<void>;
|
|
1132
|
+
|
|
1133
|
+
diffCurrentAndRemoteFolderVersions(
|
|
1134
|
+
path: string, remoteVersion?: number
|
|
1135
|
+
): Promise<FolderDiff|undefined>;
|
|
1136
|
+
|
|
985
1137
|
}
|
|
986
1138
|
|
|
987
|
-
interface
|
|
988
|
-
|
|
1139
|
+
interface FolderDiff {
|
|
1140
|
+
currentVersion: number;
|
|
1141
|
+
isCurrentLocal: boolean;
|
|
1142
|
+
remoteVersion?: number;
|
|
1143
|
+
isRemoteArchived: boolean;
|
|
1144
|
+
inCurrent?: ListingEntry[];
|
|
1145
|
+
inRemote?: ListingEntry[];
|
|
1146
|
+
nameOverlaps?: string[];
|
|
1147
|
+
ctime: {
|
|
1148
|
+
remote?: Date;
|
|
1149
|
+
current: Date;
|
|
1150
|
+
};
|
|
1151
|
+
mtime: {
|
|
1152
|
+
remote?: Date;
|
|
1153
|
+
current: Date;
|
|
1154
|
+
};
|
|
1155
|
+
xattrs?: {
|
|
1156
|
+
inCurrent?: { name: string; value: any; }[];
|
|
1157
|
+
inRemote?: { name: string; value: any; }[];
|
|
1158
|
+
nameOverlaps?: string[];
|
|
1159
|
+
};
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
interface WritableFSSyncAPI extends ReadonlyFSSyncAPI {
|
|
1163
|
+
|
|
1164
|
+
upload(path: string, opts?: OptionsToUploadLocal): Promise<void>;
|
|
1165
|
+
|
|
1166
|
+
adoptRemoteFolderItem(
|
|
1167
|
+
path: string, itemName: string, opts?: OptionsToAdoptRemoteItem
|
|
1168
|
+
): Promise<number>;
|
|
1169
|
+
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
interface OptionsToAdoptRemoteItem {
|
|
1173
|
+
localVersion?: number;
|
|
1174
|
+
remoteVersion?: number;
|
|
989
1175
|
}
|
|
990
1176
|
|
|
991
|
-
interface
|
|
992
|
-
|
|
1177
|
+
interface FSEvent {
|
|
1178
|
+
path: string;
|
|
993
1179
|
}
|
|
994
1180
|
|
|
995
|
-
interface
|
|
996
|
-
|
|
997
|
-
|
|
1181
|
+
interface FSChangeEvent {
|
|
1182
|
+
path: string;
|
|
1183
|
+
src: 'local'|'sync';
|
|
998
1184
|
}
|
|
999
1185
|
|
|
1000
|
-
interface
|
|
1001
|
-
type: '
|
|
1002
|
-
lastSynced: number;
|
|
1186
|
+
interface RemovedEvent extends FSChangeEvent {
|
|
1187
|
+
type: 'removed';
|
|
1003
1188
|
}
|
|
1004
1189
|
|
|
1005
|
-
interface
|
|
1006
|
-
type: '
|
|
1007
|
-
|
|
1190
|
+
interface VersionChangeOnUpload extends FSChangeEvent {
|
|
1191
|
+
type: 'version-change-on-upload';
|
|
1192
|
+
src: 'sync';
|
|
1193
|
+
newVersion: number;
|
|
1008
1194
|
}
|
|
1009
1195
|
|
|
1010
1196
|
type FolderEvent = EntryRemovalEvent | EntryAdditionEvent |
|
|
1011
|
-
EntryRenamingEvent | RemovedEvent |
|
|
1012
|
-
SyncedEvent | UnsyncedEvent | ConflictEvent;
|
|
1197
|
+
EntryRenamingEvent | RemovedEvent | VersionChangeOnUpload;
|
|
1013
1198
|
|
|
1014
|
-
interface EntryRemovalEvent extends
|
|
1199
|
+
interface EntryRemovalEvent extends FSChangeEvent {
|
|
1015
1200
|
type: 'entry-removal';
|
|
1016
1201
|
name: string;
|
|
1202
|
+
moveLabel?: number;
|
|
1203
|
+
newVersion?: number;
|
|
1017
1204
|
}
|
|
1018
1205
|
|
|
1019
|
-
interface EntryAdditionEvent extends
|
|
1206
|
+
interface EntryAdditionEvent extends FSChangeEvent {
|
|
1020
1207
|
type: 'entry-addition';
|
|
1021
1208
|
entry: ListingEntry;
|
|
1209
|
+
moveLabel?: number;
|
|
1210
|
+
newVersion?: number;
|
|
1022
1211
|
}
|
|
1023
1212
|
|
|
1024
|
-
interface EntryRenamingEvent extends
|
|
1213
|
+
interface EntryRenamingEvent extends FSChangeEvent {
|
|
1025
1214
|
type: 'entry-renaming';
|
|
1026
1215
|
oldName: string;
|
|
1027
1216
|
newName: string;
|
|
1217
|
+
newVersion?: number;
|
|
1028
1218
|
}
|
|
1029
1219
|
|
|
1030
|
-
type FileEvent = FileChangeEvent | RemovedEvent |
|
|
1031
|
-
SyncedEvent | UnsyncedEvent | ConflictEvent;
|
|
1220
|
+
type FileEvent = FileChangeEvent | RemovedEvent | VersionChangeOnUpload;
|
|
1032
1221
|
|
|
1033
|
-
interface FileChangeEvent extends
|
|
1222
|
+
interface FileChangeEvent extends FSChangeEvent {
|
|
1034
1223
|
type: 'file-change';
|
|
1224
|
+
newVersion?: number;
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
type RemoteEvent = RemoteVersionArchivalEvent | RemoteArchVerRemovalEvent |
|
|
1228
|
+
RemoteRemovalEvent | RemoteChangeEvent;
|
|
1229
|
+
|
|
1230
|
+
interface RemoteVersionArchivalEvent extends FSEvent {
|
|
1231
|
+
type: 'remote-version-archival';
|
|
1232
|
+
archivedVersion: number;
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
interface RemoteArchVerRemovalEvent extends FSEvent {
|
|
1236
|
+
type: 'remote-arch-ver-removal';
|
|
1237
|
+
removedArchVer: number;
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
interface RemoteRemovalEvent extends FSEvent {
|
|
1241
|
+
type: 'remote-removal';
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
interface RemoteChangeEvent extends FSEvent {
|
|
1245
|
+
type: 'remote-change';
|
|
1246
|
+
newVersion: number;
|
|
1035
1247
|
}
|
|
1036
1248
|
|
|
1037
1249
|
}
|
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();
|
|
@@ -18,7 +18,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
exports.ParamOnFileAndServer = void 0;
|
|
19
19
|
const json_utils_1 = require("../../../lib-common/json-utils");
|
|
20
20
|
const file_based_json_1 = require("../../../lib-client/3nstorage/util/file-based-json");
|
|
21
|
-
const
|
|
21
|
+
const synced_1 = require("../../../lib-common/processes/synced");
|
|
22
22
|
class ParamOnFileAndServer extends file_based_json_1.JsonFileProc {
|
|
23
23
|
constructor(paramPath, serviceConf) {
|
|
24
24
|
super();
|
|
@@ -27,7 +27,7 @@ class ParamOnFileAndServer extends file_based_json_1.JsonFileProc {
|
|
|
27
27
|
// XXX This should be done in a transactional style, with set on server
|
|
28
28
|
// first. FolderNode with its base class is an example of transactional
|
|
29
29
|
// mechanism implementation.
|
|
30
|
-
this.changesProc = new
|
|
30
|
+
this.changesProc = new synced_1.SingleProc();
|
|
31
31
|
}
|
|
32
32
|
async start(file) {
|
|
33
33
|
await super.start(file, async () => {
|
|
@@ -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,
|