core-3nweb-client-lib 0.26.0 → 0.27.1
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 +278 -69
- 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.js +5 -1
- 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.js +6 -3
- package/build/core/index.d.ts +2 -1
- package/build/core/index.js +14 -14
- package/build/core/sign-in.js +5 -5
- package/build/core/sign-up.js +9 -9
- 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 +3 -17
- package/build/core/storage/index.js +56 -76
- 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 +9 -6
- 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 +5 -1
- package/build/core/storage/synced/obj-files-gc.js +91 -37
- package/build/core/storage/synced/obj-files.d.ts +42 -36
- package/build/core/storage/synced/obj-files.js +178 -147
- package/build/core/storage/synced/obj-status.d.ts +87 -85
- package/build/core/storage/synced/obj-status.js +463 -259
- 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 +18 -9
- package/build/core/storage/synced/storage.js +108 -48
- 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 +204 -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 +3 -0
- package/build/ipc-via-protobuf/connector-clients-side.js +61 -24
- 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 +3 -0
- package/build/lib-client/3nstorage/exceptions.js +13 -1
- package/build/lib-client/3nstorage/service.d.ts +15 -2
- package/build/lib-client/3nstorage/service.js +104 -38
- 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 +42 -18
- package/build/lib-client/3nstorage/xsp-fs/common.js +29 -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 +24 -11
- package/build/lib-client/3nstorage/xsp-fs/folder-node.js +575 -179
- package/build/lib-client/3nstorage/xsp-fs/fs.d.ts +35 -4
- package/build/lib-client/3nstorage/xsp-fs/fs.js +231 -110
- 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 -24
- package/build/lib-client/3nstorage/xsp-fs/node-in-fs.js +229 -123
- 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.js +7 -7
- 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 +16 -16
- 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.js +4 -0
- 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 +95 -39
- package/build/lib-common/service-api/3nstorage/owner.js +82 -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 +6 -5
- package/protos/file.proto +91 -19
- package/protos/fs.proto +107 -8
|
@@ -60,6 +60,24 @@ declare namespace web3n.files {
|
|
|
60
60
|
notImplemented: 'ENOSYS';
|
|
61
61
|
isEndless: 'is-endless';
|
|
62
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;
|
|
63
81
|
}
|
|
64
82
|
|
|
65
83
|
/**
|
|
@@ -126,18 +144,39 @@ declare namespace web3n.files {
|
|
|
126
144
|
*/
|
|
127
145
|
version?: number;
|
|
128
146
|
|
|
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
|
-
};
|
|
147
|
+
}
|
|
140
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;
|
|
141
180
|
}
|
|
142
181
|
|
|
143
182
|
type SyncState = 'synced' | 'behind' | 'unsynced' | 'conflicting';
|
|
@@ -328,7 +367,7 @@ declare namespace web3n.files {
|
|
|
328
367
|
*/
|
|
329
368
|
getByteSource(): Promise<FileByteSource>;
|
|
330
369
|
|
|
331
|
-
watch(observer: Observer<FileEvent>): () => void;
|
|
370
|
+
watch(observer: Observer<FileEvent|RemoteEvent>): () => void;
|
|
332
371
|
|
|
333
372
|
}
|
|
334
373
|
|
|
@@ -398,8 +437,9 @@ declare namespace web3n.files {
|
|
|
398
437
|
* greater than file length, all available bytes are read. If parameter
|
|
399
438
|
* is missing, read will be done to file's end.
|
|
400
439
|
*/
|
|
401
|
-
readBytes(
|
|
402
|
-
|
|
440
|
+
readBytes(
|
|
441
|
+
start?: number, end?: number
|
|
442
|
+
): Promise<{ bytes: Uint8Array|undefined; version: number; }>;
|
|
403
443
|
|
|
404
444
|
/**
|
|
405
445
|
* This returns a promise, resolvable to text, read from file, assuming
|
|
@@ -418,6 +458,10 @@ declare namespace web3n.files {
|
|
|
418
458
|
*/
|
|
419
459
|
getByteSource(): Promise<{ src: FileByteSource; version: number; }>;
|
|
420
460
|
|
|
461
|
+
listVersions(): Promise<{ current?: number; archived?: number[]; }>;
|
|
462
|
+
|
|
463
|
+
sync?: ReadonlyFileSyncAPI;
|
|
464
|
+
|
|
421
465
|
}
|
|
422
466
|
|
|
423
467
|
interface WritableFileVersionedAPI extends ReadonlyFileVersionedAPI {
|
|
@@ -460,8 +504,9 @@ declare namespace web3n.files {
|
|
|
460
504
|
* When current version is given, an error is thrown, if file version at
|
|
461
505
|
* the moment of writing is different.
|
|
462
506
|
*/
|
|
463
|
-
getByteSink(
|
|
464
|
-
|
|
507
|
+
getByteSink(
|
|
508
|
+
truncateFile?: boolean, currentVersion?: number
|
|
509
|
+
): Promise<{ sink: FileByteSink; version: number; }>;
|
|
465
510
|
|
|
466
511
|
/**
|
|
467
512
|
* This returns a promise, resolvable to new file's version when copying
|
|
@@ -469,7 +514,48 @@ declare namespace web3n.files {
|
|
|
469
514
|
* @param file which content will be copied into this file
|
|
470
515
|
*/
|
|
471
516
|
copy(file: File): Promise<number>;
|
|
472
|
-
|
|
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;
|
|
473
559
|
}
|
|
474
560
|
|
|
475
561
|
type FSType = 'device' | 'synced' | 'local' | 'share' | 'asmail-msg';
|
|
@@ -498,8 +584,9 @@ declare namespace web3n.files {
|
|
|
498
584
|
* throwing of an exception, when folder does not exist. Default value is
|
|
499
585
|
* false.
|
|
500
586
|
*/
|
|
501
|
-
checkFolderPresence(
|
|
502
|
-
|
|
587
|
+
checkFolderPresence(
|
|
588
|
+
path: string, throwIfMissing?: boolean
|
|
589
|
+
): Promise<boolean>;
|
|
503
590
|
|
|
504
591
|
/**
|
|
505
592
|
* This returns a promise, resolvable to true, if file exists, and to
|
|
@@ -509,8 +596,9 @@ declare namespace web3n.files {
|
|
|
509
596
|
* throwing of an exception, when file does not exist. Default value is
|
|
510
597
|
* false.
|
|
511
598
|
*/
|
|
512
|
-
checkFilePresence(
|
|
513
|
-
|
|
599
|
+
checkFilePresence(
|
|
600
|
+
path: string, throwIfMissing?: boolean
|
|
601
|
+
): Promise<boolean>;
|
|
514
602
|
|
|
515
603
|
/**
|
|
516
604
|
* This returns a promise, resolvable to true, if link exists, and to
|
|
@@ -520,8 +608,9 @@ declare namespace web3n.files {
|
|
|
520
608
|
* throwing of an exception, when link does not exist. Default value is
|
|
521
609
|
* false.
|
|
522
610
|
*/
|
|
523
|
-
checkLinkPresence(
|
|
524
|
-
|
|
611
|
+
checkLinkPresence(
|
|
612
|
+
path: string, throwIfMissing?: boolean
|
|
613
|
+
): Promise<boolean>;
|
|
525
614
|
|
|
526
615
|
/**
|
|
527
616
|
* This returns a promise, resolvable to stats of an entity at a given
|
|
@@ -546,12 +635,18 @@ declare namespace web3n.files {
|
|
|
546
635
|
|
|
547
636
|
readLink(path: string): Promise<SymLink>;
|
|
548
637
|
|
|
549
|
-
watchFolder(
|
|
638
|
+
watchFolder(
|
|
639
|
+
path: string, observer: Observer<FolderEvent|RemoteEvent>
|
|
640
|
+
): () => void;
|
|
550
641
|
|
|
551
|
-
watchFile(
|
|
642
|
+
watchFile(
|
|
643
|
+
path: string, observer: Observer<FileEvent|RemoteEvent>
|
|
644
|
+
): () => void;
|
|
552
645
|
|
|
553
|
-
watchTree(
|
|
554
|
-
|
|
646
|
+
watchTree(
|
|
647
|
+
path: string, depth: number|undefined,
|
|
648
|
+
observer: Observer<FolderEvent|FileEvent|RemoteEvent>
|
|
649
|
+
): () => void;
|
|
555
650
|
|
|
556
651
|
close(): Promise<void>;
|
|
557
652
|
|
|
@@ -593,8 +688,9 @@ declare namespace web3n.files {
|
|
|
593
688
|
* greater than file length, all available bytes are read. If parameter
|
|
594
689
|
* is missing, read will be done to file's end.
|
|
595
690
|
*/
|
|
596
|
-
readBytes(
|
|
597
|
-
|
|
691
|
+
readBytes(
|
|
692
|
+
path: string, start?: number, end?: number
|
|
693
|
+
): Promise<Uint8Array|undefined>;
|
|
598
694
|
|
|
599
695
|
/**
|
|
600
696
|
* This returns a promise, resolvable to bytes source with seek, which
|
|
@@ -619,8 +715,9 @@ declare namespace web3n.files {
|
|
|
619
715
|
* @param path
|
|
620
716
|
* @param criteria
|
|
621
717
|
*/
|
|
622
|
-
select(
|
|
623
|
-
|
|
718
|
+
select(
|
|
719
|
+
path: string, criteria: SelectCriteria
|
|
720
|
+
): Promise<{ items: FSCollection; completion: Promise<void>; }>;
|
|
624
721
|
|
|
625
722
|
}
|
|
626
723
|
|
|
@@ -752,8 +849,9 @@ declare namespace web3n.files {
|
|
|
752
849
|
* @param overwrite is a flag that with a true value allows
|
|
753
850
|
* overwrite of existing dst file. Default value is false.
|
|
754
851
|
*/
|
|
755
|
-
copyFile(
|
|
756
|
-
|
|
852
|
+
copyFile(
|
|
853
|
+
src: string, dst: string, overwrite?: boolean
|
|
854
|
+
): Promise<void>;
|
|
757
855
|
|
|
758
856
|
/**
|
|
759
857
|
* This returns a promise, resolvable when folder has been recursively
|
|
@@ -764,8 +862,9 @@ declare namespace web3n.files {
|
|
|
764
862
|
* merge into existing folder and files overwriting inside. Default
|
|
765
863
|
* value is false.
|
|
766
864
|
*/
|
|
767
|
-
copyFolder(
|
|
768
|
-
|
|
865
|
+
copyFolder(
|
|
866
|
+
src: string, dst: string, mergeAndOverwrite?: boolean
|
|
867
|
+
): Promise<void>;
|
|
769
868
|
|
|
770
869
|
/**
|
|
771
870
|
* This returns a promise, resolvable when file has been saved.
|
|
@@ -785,8 +884,9 @@ declare namespace web3n.files {
|
|
|
785
884
|
* merge into existing folder and files overwriting inside. Default
|
|
786
885
|
* value is false.
|
|
787
886
|
*/
|
|
788
|
-
saveFolder(
|
|
789
|
-
|
|
887
|
+
saveFolder(
|
|
888
|
+
folder: FS, dst: string, mergeAndOverwrite?: boolean
|
|
889
|
+
): Promise<void>;
|
|
790
890
|
|
|
791
891
|
/**
|
|
792
892
|
* This returns a promise, resolvable when file has been removed
|
|
@@ -830,8 +930,9 @@ declare namespace web3n.files {
|
|
|
830
930
|
* @param flags are optional flags. Default flags are create=true,
|
|
831
931
|
* exclusive=false.
|
|
832
932
|
*/
|
|
833
|
-
writeBytes(
|
|
834
|
-
|
|
933
|
+
writeBytes(
|
|
934
|
+
path: string, bytes: Uint8Array, flags?: FileFlags
|
|
935
|
+
): Promise<void>;
|
|
835
936
|
|
|
836
937
|
/**
|
|
837
938
|
* This returns a promise, resolvable to byte sink with seek
|
|
@@ -887,8 +988,9 @@ declare namespace web3n.files {
|
|
|
887
988
|
|
|
888
989
|
interface ReadonlyFSVersionedAPI {
|
|
889
990
|
|
|
890
|
-
getXAttr(
|
|
891
|
-
|
|
991
|
+
getXAttr(
|
|
992
|
+
path: string, xaName: string
|
|
993
|
+
): Promise<{ attr: any; version: number; }>;
|
|
892
994
|
|
|
893
995
|
listXAttrs(path: string): Promise<{ lst: string[]; version: number; }>;
|
|
894
996
|
|
|
@@ -897,8 +999,9 @@ declare namespace web3n.files {
|
|
|
897
999
|
* for entries in the folder, and a folder's version.
|
|
898
1000
|
* @param path of a folder that should be listed
|
|
899
1001
|
*/
|
|
900
|
-
listFolder(
|
|
901
|
-
|
|
1002
|
+
listFolder(
|
|
1003
|
+
path: string
|
|
1004
|
+
): Promise<{ lst: ListingEntry[]; version: number; }>;
|
|
902
1005
|
|
|
903
1006
|
/**
|
|
904
1007
|
* This returns a promise, resolvable to json, read from file, and a
|
|
@@ -925,16 +1028,24 @@ declare namespace web3n.files {
|
|
|
925
1028
|
* greater than file length, all available bytes are read. If parameter
|
|
926
1029
|
* is missing, read will be done to file's end.
|
|
927
1030
|
*/
|
|
928
|
-
readBytes(
|
|
929
|
-
|
|
1031
|
+
readBytes(
|
|
1032
|
+
path: string, start?: number, end?: number
|
|
1033
|
+
): Promise<{ bytes: Uint8Array|undefined; version: number; }>;
|
|
930
1034
|
|
|
931
1035
|
/**
|
|
932
1036
|
* This returns a promise, resolvable to bytes source with seek, which
|
|
933
1037
|
* allows random reads, and a file version
|
|
934
1038
|
* @param path of a file from which to read bytes
|
|
935
1039
|
*/
|
|
936
|
-
getByteSource(
|
|
937
|
-
|
|
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;
|
|
938
1049
|
|
|
939
1050
|
}
|
|
940
1051
|
|
|
@@ -956,8 +1067,9 @@ declare namespace web3n.files {
|
|
|
956
1067
|
* @param flags are optional flags. Default flags are create=true,
|
|
957
1068
|
* exclusive=false.
|
|
958
1069
|
*/
|
|
959
|
-
writeJSONFile(
|
|
960
|
-
|
|
1070
|
+
writeJSONFile(
|
|
1071
|
+
path: string, json: any, flags?: VersionedFileFlags
|
|
1072
|
+
): Promise<number>;
|
|
961
1073
|
|
|
962
1074
|
/**
|
|
963
1075
|
* This returns a promise, resolvable to new file's version when file is
|
|
@@ -967,8 +1079,9 @@ declare namespace web3n.files {
|
|
|
967
1079
|
* @param flags are optional flags. Default flags are create=true,
|
|
968
1080
|
* exclusive=false.
|
|
969
1081
|
*/
|
|
970
|
-
writeTxtFile(
|
|
971
|
-
|
|
1082
|
+
writeTxtFile(
|
|
1083
|
+
path: string, txt: string, flags?: VersionedFileFlags
|
|
1084
|
+
): Promise<number>;
|
|
972
1085
|
|
|
973
1086
|
/**
|
|
974
1087
|
* This returns a promise, resolvable to new file's version when file is
|
|
@@ -978,8 +1091,9 @@ declare namespace web3n.files {
|
|
|
978
1091
|
* @param flags are optional flags. Default flags are create=true,
|
|
979
1092
|
* exclusive=false.
|
|
980
1093
|
*/
|
|
981
|
-
writeBytes(
|
|
982
|
-
|
|
1094
|
+
writeBytes(
|
|
1095
|
+
path: string, bytes: Uint8Array, flags?: VersionedFileFlags
|
|
1096
|
+
): Promise<number>;
|
|
983
1097
|
|
|
984
1098
|
/**
|
|
985
1099
|
* This returns a promise, resolvable to byte sink with seek, and a file
|
|
@@ -988,53 +1102,148 @@ declare namespace web3n.files {
|
|
|
988
1102
|
* @param flags are optional flags. Default flags are create=true,
|
|
989
1103
|
* exclusive=false, truncate=true.
|
|
990
1104
|
*/
|
|
991
|
-
getByteSink(
|
|
992
|
-
|
|
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;
|
|
993
1112
|
|
|
994
1113
|
}
|
|
995
1114
|
|
|
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
|
+
|
|
1137
|
+
}
|
|
1138
|
+
|
|
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;
|
|
1175
|
+
}
|
|
1176
|
+
|
|
996
1177
|
interface FSEvent {
|
|
997
|
-
type: string;
|
|
998
1178
|
path: string;
|
|
999
|
-
isRemote?: boolean;
|
|
1000
|
-
newVersion?: number;
|
|
1001
1179
|
}
|
|
1002
1180
|
|
|
1003
|
-
interface
|
|
1181
|
+
interface FSChangeEvent {
|
|
1182
|
+
path: string;
|
|
1183
|
+
src: 'local'|'sync';
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
interface RemovedEvent extends FSChangeEvent {
|
|
1004
1187
|
type: 'removed';
|
|
1005
1188
|
}
|
|
1006
1189
|
|
|
1007
|
-
interface
|
|
1008
|
-
type: '
|
|
1009
|
-
|
|
1010
|
-
|
|
1190
|
+
interface VersionChangeOnUpload extends FSChangeEvent {
|
|
1191
|
+
type: 'version-change-on-upload';
|
|
1192
|
+
src: 'sync';
|
|
1193
|
+
newVersion: number;
|
|
1011
1194
|
}
|
|
1012
1195
|
|
|
1013
1196
|
type FolderEvent = EntryRemovalEvent | EntryAdditionEvent |
|
|
1014
|
-
EntryRenamingEvent | RemovedEvent |
|
|
1197
|
+
EntryRenamingEvent | RemovedEvent | VersionChangeOnUpload;
|
|
1015
1198
|
|
|
1016
|
-
interface EntryRemovalEvent extends
|
|
1199
|
+
interface EntryRemovalEvent extends FSChangeEvent {
|
|
1017
1200
|
type: 'entry-removal';
|
|
1018
1201
|
name: string;
|
|
1019
1202
|
moveLabel?: number;
|
|
1203
|
+
newVersion?: number;
|
|
1020
1204
|
}
|
|
1021
1205
|
|
|
1022
|
-
interface EntryAdditionEvent extends
|
|
1206
|
+
interface EntryAdditionEvent extends FSChangeEvent {
|
|
1023
1207
|
type: 'entry-addition';
|
|
1024
1208
|
entry: ListingEntry;
|
|
1025
1209
|
moveLabel?: number;
|
|
1210
|
+
newVersion?: number;
|
|
1026
1211
|
}
|
|
1027
1212
|
|
|
1028
|
-
interface EntryRenamingEvent extends
|
|
1213
|
+
interface EntryRenamingEvent extends FSChangeEvent {
|
|
1029
1214
|
type: 'entry-renaming';
|
|
1030
1215
|
oldName: string;
|
|
1031
1216
|
newName: string;
|
|
1217
|
+
newVersion?: number;
|
|
1032
1218
|
}
|
|
1033
1219
|
|
|
1034
|
-
type FileEvent = FileChangeEvent | RemovedEvent |
|
|
1220
|
+
type FileEvent = FileChangeEvent | RemovedEvent | VersionChangeOnUpload;
|
|
1035
1221
|
|
|
1036
|
-
interface FileChangeEvent extends
|
|
1222
|
+
interface FileChangeEvent extends FSChangeEvent {
|
|
1037
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;
|
|
1038
1247
|
}
|
|
1039
1248
|
|
|
1040
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();
|
|
@@ -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,
|
|
@@ -26,7 +26,7 @@ class Attachments {
|
|
|
26
26
|
Object.freeze(this);
|
|
27
27
|
}
|
|
28
28
|
static fromMsg(msg) {
|
|
29
|
-
if (!attachments_container_1.isContainerEmpty(msg.attachments)) {
|
|
29
|
+
if (!(0, attachments_container_1.isContainerEmpty)(msg.attachments)) {
|
|
30
30
|
return new Attachments(msg.attachments, undefined);
|
|
31
31
|
}
|
|
32
32
|
return;
|
|
@@ -42,11 +42,11 @@ class Attachments {
|
|
|
42
42
|
const link = await msgFS.readLink(`${ATTACHMENTS_NAME}/${f.name}`);
|
|
43
43
|
if (link.isFile) {
|
|
44
44
|
const file = (await link.target());
|
|
45
|
-
attachments_container_1.addFileTo(container, file, f.name);
|
|
45
|
+
(0, attachments_container_1.addFileTo)(container, file, f.name);
|
|
46
46
|
}
|
|
47
47
|
else if (link.isFolder) {
|
|
48
48
|
const fs = (await link.target());
|
|
49
|
-
attachments_container_1.addFolderTo(container, fs, f.name);
|
|
49
|
+
(0, attachments_container_1.addFolderTo)(container, fs, f.name);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
return new Attachments(container, undefined);
|
|
@@ -63,10 +63,10 @@ class Attachments {
|
|
|
63
63
|
async linkIn(msgFS) {
|
|
64
64
|
if (this.container) {
|
|
65
65
|
await msgFS.makeFolder(ATTACHMENTS_NAME);
|
|
66
|
-
for (const f of attachments_container_1.iterFilesIn(this.container)) {
|
|
66
|
+
for (const f of (0, attachments_container_1.iterFilesIn)(this.container)) {
|
|
67
67
|
msgFS.link(`${ATTACHMENTS_NAME}/${f.fileName}`, f.file);
|
|
68
68
|
}
|
|
69
|
-
for (const f of attachments_container_1.iterFoldersIn(this.container)) {
|
|
69
|
+
for (const f of (0, attachments_container_1.iterFoldersIn)(this.container)) {
|
|
70
70
|
msgFS.link(`${ATTACHMENTS_NAME}/${f.folderName}`, f.folder);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
@@ -85,13 +85,13 @@ class Attachments {
|
|
|
85
85
|
async estimatedPackedSize() {
|
|
86
86
|
if (this.container) {
|
|
87
87
|
let totalSize = 0;
|
|
88
|
-
for (const f of attachments_container_1.iterFilesIn(this.container)) {
|
|
88
|
+
for (const f of (0, attachments_container_1.iterFilesIn)(this.container)) {
|
|
89
89
|
const fileSize = (await f.file.stat()).size;
|
|
90
90
|
if (typeof fileSize === 'number') {
|
|
91
91
|
totalSize += await estimatePackedSizeOf(fileSize);
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
for (const f of attachments_container_1.iterFoldersIn(this.container)) {
|
|
94
|
+
for (const f of (0, attachments_container_1.iterFoldersIn)(this.container)) {
|
|
95
95
|
totalSize += await estimatePackedSizeOfFolder(f.folder);
|
|
96
96
|
}
|
|
97
97
|
return totalSize;
|