core-3nweb-client-lib 0.27.3 → 0.27.5
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/files.d.ts +92 -29
- package/build/core/asmail/config/index.d.ts +2 -2
- package/build/core/asmail/config/index.js +2 -2
- package/build/core/asmail/config/invitations-anon.d.ts +10 -24
- package/build/core/asmail/config/invitations-anon.js +43 -31
- package/build/core/asmail/config/published-intro-key.d.ts +11 -22
- package/build/core/asmail/config/published-intro-key.js +47 -38
- package/build/core/asmail/delivery/per-recipient-wip.js +2 -2
- package/build/core/asmail/inbox/inbox-events.js +10 -5
- package/build/core/asmail/inbox/index.d.ts +3 -2
- package/build/core/asmail/inbox/index.js +15 -11
- package/build/core/asmail/inbox/msg-indexing.d.ts +17 -64
- package/build/core/asmail/inbox/msg-indexing.js +440 -311
- package/build/core/asmail/inbox/msg-on-disk.js +2 -1
- package/build/core/asmail/index.d.ts +1 -1
- package/build/core/asmail/index.js +5 -4
- package/build/core/asmail/keyring/correspondent-keys.d.ts +2 -2
- package/build/core/asmail/keyring/correspondent-keys.js +4 -2
- package/build/core/asmail/keyring/index.d.ts +10 -33
- package/build/core/asmail/keyring/index.js +88 -75
- package/build/core/asmail/msg/opener.js +4 -3
- package/build/core/asmail/msg/packer.d.ts +1 -0
- package/build/core/asmail/msg/packer.js +8 -4
- package/build/core/index.js +3 -5
- package/build/core/sign-in.js +1 -1
- package/build/core/storage/local/obj-files.js +2 -1
- package/build/core/storage/synced/obj-files.d.ts +2 -0
- package/build/core/storage/synced/obj-files.js +18 -1
- package/build/core/storage/synced/obj-status.d.ts +1 -0
- package/build/core/storage/synced/obj-status.js +10 -0
- package/build/core/storage/synced/storage.js +7 -23
- package/build/core/storage/synced/upload-header-file.js +4 -2
- package/build/core/storage/synced/upsyncer.js +3 -5
- package/build/ipc-via-protobuf/asmail-cap.js +14 -15
- package/build/ipc-via-protobuf/bytes.js +42 -18
- package/build/ipc-via-protobuf/file.d.ts +7 -0
- package/build/ipc-via-protobuf/file.js +103 -66
- package/build/ipc-via-protobuf/fs.js +127 -105
- package/build/ipc-via-protobuf/mailerid.js +2 -2
- package/build/ipc-via-protobuf/protobuf-msg.d.ts +1 -0
- package/build/ipc-via-protobuf/protobuf-msg.js +5 -1
- package/build/ipc-via-protobuf/startup-cap.js +8 -8
- package/build/ipc-via-protobuf/storage-cap.js +4 -4
- package/build/lib-client/3nstorage/xsp-fs/common.js +2 -0
- package/build/lib-client/3nstorage/xsp-fs/file-node.d.ts +5 -10
- package/build/lib-client/3nstorage/xsp-fs/file-node.js +26 -45
- package/build/lib-client/3nstorage/xsp-fs/file.d.ts +8 -7
- package/build/lib-client/3nstorage/xsp-fs/file.js +12 -18
- package/build/lib-client/3nstorage/xsp-fs/folder-node.d.ts +6 -1
- package/build/lib-client/3nstorage/xsp-fs/folder-node.js +20 -8
- package/build/lib-client/3nstorage/xsp-fs/fs.d.ts +19 -18
- package/build/lib-client/3nstorage/xsp-fs/fs.js +18 -19
- package/build/lib-client/3nstorage/xsp-fs/node-in-fs.d.ts +13 -4
- package/build/lib-client/3nstorage/xsp-fs/node-in-fs.js +63 -8
- package/build/lib-client/3nstorage/xsp-fs/node-persistence.d.ts +1 -0
- package/build/lib-client/3nstorage/xsp-fs/node-persistence.js +7 -5
- package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v1.js +3 -4
- package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v2.js +20 -15
- package/build/lib-client/cryptor/cryptor-in-worker.js +37 -47
- package/build/lib-client/cryptor/cryptor-wasm.js +1 -1
- package/build/lib-client/cryptor/cryptor.wasm +0 -0
- package/build/lib-client/cryptor/in-proc-js.js +15 -12
- package/build/lib-client/cryptor/in-proc-wasm.js +11 -8
- package/build/lib-client/cryptor/serialization-for-wasm.d.ts +36 -0
- package/build/lib-client/cryptor/serialization-for-wasm.js +58 -0
- package/build/lib-client/cryptor-work-labels.d.ts +26 -0
- package/build/lib-client/cryptor-work-labels.js +152 -0
- package/build/lib-client/fs-sync-utils.d.ts +7 -1
- package/build/lib-client/fs-sync-utils.js +18 -7
- package/build/lib-client/local-files/dev-file-src.d.ts +2 -1
- package/build/lib-client/local-files/dev-file-src.js +5 -1
- package/build/lib-client/local-files/device-fs.js +2 -1
- package/build/lib-client/objs-on-disk/obj-on-disk.d.ts +5 -2
- package/build/lib-client/objs-on-disk/obj-on-disk.js +21 -2
- package/build/lib-client/request-utils.js +14 -14
- package/build/lib-common/async-cryptor-wrap.d.ts +9 -9
- package/build/lib-common/async-cryptor-wrap.js +13 -13
- package/build/lib-common/byte-streaming/pipe.d.ts +1 -1
- package/build/lib-common/byte-streaming/pipe.js +3 -3
- package/build/lib-common/byte-streaming/wrapping.js +4 -2
- package/build/lib-common/json-utils.js +0 -3
- package/build/lib-common/objs-on-disk/file-layout.js +1 -1
- package/build/lib-common/processes/synced.js +0 -184
- package/build/lib-sqlite-on-3nstorage/index.d.ts +32 -0
- package/build/lib-sqlite-on-3nstorage/index.js +117 -0
- package/build/lib-sqlite-on-3nstorage/sqljs.d.ts +279 -0
- package/build/lib-sqlite-on-3nstorage/sqljs.js +223 -0
- package/build/protos/asmail.proto.js +10145 -5923
- package/build/protos/bytes.proto.js +731 -204
- package/build/protos/common.proto.js +192 -44
- package/build/protos/cryptor.proto.js +184 -61
- package/build/protos/file.proto.js +2388 -502
- package/build/protos/fs.proto.js +9894 -6046
- package/build/protos/ipc.proto.js +244 -61
- package/build/protos/logger.proto.js +219 -53
- package/build/protos/mailerid.proto.js +230 -50
- package/build/protos/startup.proto.js +341 -77
- package/build/protos/storage.proto.js +276 -62
- package/package.json +8 -7
- package/protos/bytes.proto +13 -4
- package/protos/file.proto +27 -8
- package/protos/fs.proto +31 -14
|
@@ -44,6 +44,7 @@ declare namespace web3n.files {
|
|
|
44
44
|
versionMismatch?: true;
|
|
45
45
|
isEndless?: true;
|
|
46
46
|
storageClosed?: true;
|
|
47
|
+
remoteNotSet?: true;
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
interface exceptionCode {
|
|
@@ -192,7 +193,17 @@ declare namespace web3n.files {
|
|
|
192
193
|
* @param len maximum number of bytes to read from file. If undefine is
|
|
193
194
|
* given, all bytes are read from current postion to the end of file.
|
|
194
195
|
*/
|
|
195
|
-
|
|
196
|
+
readNext(len: number|undefined): Promise<Uint8Array|undefined>;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* This moves current position to a given value and read given number of
|
|
200
|
+
* bytes. It is equivalent to calling seek() and readNext() with
|
|
201
|
+
* respective arguments.
|
|
202
|
+
* @param pos is a position at which to start read.
|
|
203
|
+
* @param len maximum number of bytes to read from file. If undefine is
|
|
204
|
+
* given, all bytes are read from current postion to the end of file.
|
|
205
|
+
*/
|
|
206
|
+
readAt(pos: number, len: number|undefined): Promise<Uint8Array|undefined>;
|
|
196
207
|
|
|
197
208
|
/**
|
|
198
209
|
* This returns a promise, resolvable to the size of this file.
|
|
@@ -264,7 +275,8 @@ declare namespace web3n.files {
|
|
|
264
275
|
* sink with this error. When err is given, no errors will be thrown back
|
|
265
276
|
* to this call.
|
|
266
277
|
*/
|
|
267
|
-
done(err?: any): Promise<void>;
|
|
278
|
+
done(err?: any, xattrChanges?: XAttrsChanges): Promise<void>;
|
|
279
|
+
|
|
268
280
|
}
|
|
269
281
|
|
|
270
282
|
type Linkable = File | FS;
|
|
@@ -382,20 +394,28 @@ declare namespace web3n.files {
|
|
|
382
394
|
/**
|
|
383
395
|
* This returns a promise, resolvable when file is written
|
|
384
396
|
* @param bytes is a complete file content to write
|
|
397
|
+
* @param xattrChanges is optional changes to xattrs, to pack them in the
|
|
398
|
+
* same go
|
|
385
399
|
*/
|
|
386
|
-
writeBytes(
|
|
400
|
+
writeBytes(
|
|
401
|
+
bytes: Uint8Array, xattrChanges?: XAttrsChanges
|
|
402
|
+
): Promise<void>;
|
|
387
403
|
|
|
388
404
|
/**
|
|
389
405
|
* This returns a promise, resolvable when file is written
|
|
390
406
|
* @param txt to write to file, using utf8 encoding
|
|
407
|
+
* @param xattrChanges is optional changes to xattrs, to pack them in the
|
|
408
|
+
* same go
|
|
391
409
|
*/
|
|
392
|
-
writeTxt(txt: string): Promise<void>;
|
|
410
|
+
writeTxt(txt: string, xattrChanges?: XAttrsChanges): Promise<void>;
|
|
393
411
|
|
|
394
412
|
/**
|
|
395
413
|
* This returns a promise, resolvable when file is written
|
|
396
414
|
* @param json
|
|
415
|
+
* @param xattrChanges is optional changes to xattrs, to pack them in the
|
|
416
|
+
* same go
|
|
397
417
|
*/
|
|
398
|
-
writeJSON(json: any): Promise<void>;
|
|
418
|
+
writeJSON(json: any, xattrChanges?: XAttrsChanges): Promise<void>;
|
|
399
419
|
|
|
400
420
|
/**
|
|
401
421
|
* This returns a promise, resolvable to byte sink with seek
|
|
@@ -420,9 +440,13 @@ declare namespace web3n.files {
|
|
|
420
440
|
|
|
421
441
|
interface ReadonlyFileVersionedAPI {
|
|
422
442
|
|
|
423
|
-
getXAttr(
|
|
443
|
+
getXAttr(
|
|
444
|
+
xaName: string, flags?: VersionedReadFlags
|
|
445
|
+
): Promise<{ attr: any; version: number; }>;
|
|
424
446
|
|
|
425
|
-
listXAttrs(
|
|
447
|
+
listXAttrs(
|
|
448
|
+
flags?: VersionedReadFlags
|
|
449
|
+
): Promise<{ lst: string[]; version: number; }>;
|
|
426
450
|
|
|
427
451
|
/**
|
|
428
452
|
* This returns a promise, resolvable to either non-empty byte array, or
|
|
@@ -433,34 +457,51 @@ declare namespace web3n.files {
|
|
|
433
457
|
* @param end optional parameter, setting an end of read. If end is
|
|
434
458
|
* greater than file length, all available bytes are read. If parameter
|
|
435
459
|
* is missing, read will be done to file's end.
|
|
460
|
+
* @param flags are optional flags to read archived or remote versions.
|
|
436
461
|
*/
|
|
437
462
|
readBytes(
|
|
438
|
-
start?: number, end?: number
|
|
463
|
+
start?: number, end?: number, flags?: VersionedReadFlags
|
|
439
464
|
): Promise<{ bytes: Uint8Array|undefined; version: number; }>;
|
|
440
465
|
|
|
441
466
|
/**
|
|
442
467
|
* This returns a promise, resolvable to text, read from file, assuming
|
|
443
468
|
* utf8 encoding.
|
|
469
|
+
* @param flags are optional flags to read archived or remote versions.
|
|
444
470
|
*/
|
|
445
|
-
readTxt(
|
|
471
|
+
readTxt(
|
|
472
|
+
flags?: VersionedReadFlags
|
|
473
|
+
): Promise<{ txt: string; version: number; }>;
|
|
446
474
|
|
|
447
475
|
/**
|
|
448
476
|
* This returns a promise, resolvable to json, read from file
|
|
477
|
+
* @param flags are optional flags to read archived or remote versions.
|
|
449
478
|
*/
|
|
450
|
-
readJSON<T>(
|
|
479
|
+
readJSON<T>(
|
|
480
|
+
flags?: VersionedReadFlags
|
|
481
|
+
): Promise<{ json: T; version: number; }>;
|
|
451
482
|
|
|
452
483
|
/**
|
|
453
484
|
* This returns a promise, resolvable to bytes source with seek, which
|
|
454
485
|
* allows random reads, and a file version
|
|
486
|
+
* @param flags are optional flags to read archived or remote versions.
|
|
455
487
|
*/
|
|
456
|
-
getByteSource(
|
|
488
|
+
getByteSource(
|
|
489
|
+
flags?: VersionedReadFlags
|
|
490
|
+
): Promise<{ src: FileByteSource; version: number; }>;
|
|
457
491
|
|
|
458
|
-
listVersions(
|
|
492
|
+
listVersions(
|
|
493
|
+
flags?: VersionedReadFlags
|
|
494
|
+
): Promise<{ current?: number; archived?: number[]; }>;
|
|
459
495
|
|
|
460
496
|
sync?: ReadonlyFileSyncAPI;
|
|
461
497
|
|
|
462
498
|
}
|
|
463
499
|
|
|
500
|
+
interface VersionedReadFlags {
|
|
501
|
+
archivedVersion?: number;
|
|
502
|
+
remoteVersion?: number;
|
|
503
|
+
}
|
|
504
|
+
|
|
464
505
|
interface WritableFileVersionedAPI extends ReadonlyFileVersionedAPI {
|
|
465
506
|
|
|
466
507
|
/**
|
|
@@ -474,22 +515,30 @@ declare namespace web3n.files {
|
|
|
474
515
|
* This returns a promise, resolvable to new file's version when file is
|
|
475
516
|
* written
|
|
476
517
|
* @param bytes is a complete file content to write
|
|
518
|
+
* @param xattrChanges is optional changes to xattrs, to pack them into
|
|
519
|
+
* the same file version
|
|
477
520
|
*/
|
|
478
|
-
writeBytes(
|
|
521
|
+
writeBytes(
|
|
522
|
+
bytes: Uint8Array, xattrChanges?: XAttrsChanges
|
|
523
|
+
): Promise<number>;
|
|
479
524
|
|
|
480
525
|
/**
|
|
481
526
|
* This returns a promise, resolvable to new file's version when file is
|
|
482
527
|
* written
|
|
483
528
|
* @param txt to write to file, using utf8 encoding
|
|
529
|
+
* @param xattrChanges is optional changes to xattrs, to pack them into
|
|
530
|
+
* the same file version
|
|
484
531
|
*/
|
|
485
|
-
writeTxt(txt: string): Promise<number>;
|
|
532
|
+
writeTxt(txt: string, xattrChanges?: XAttrsChanges): Promise<number>;
|
|
486
533
|
|
|
487
534
|
/**
|
|
488
535
|
* This returns a promise, resolvable to new file's version when file is
|
|
489
536
|
* written
|
|
490
537
|
* @param json
|
|
538
|
+
* @param xattrChanges is optional changes to xattrs, to pack them into
|
|
539
|
+
* the same file version
|
|
491
540
|
*/
|
|
492
|
-
writeJSON(json: any): Promise<number>;
|
|
541
|
+
writeJSON(json: any, xattrChanges?: XAttrsChanges): Promise<number>;
|
|
493
542
|
|
|
494
543
|
/**
|
|
495
544
|
* This returns a promise, resolvable to byte sink with seek, and a file
|
|
@@ -546,7 +595,7 @@ declare namespace web3n.files {
|
|
|
546
595
|
|
|
547
596
|
interface WritableFileSyncAPI extends ReadonlyFileSyncAPI {
|
|
548
597
|
|
|
549
|
-
upload(opts?: OptionsToUploadLocal): Promise<
|
|
598
|
+
upload(opts?: OptionsToUploadLocal): Promise<number|undefined>;
|
|
550
599
|
|
|
551
600
|
}
|
|
552
601
|
|
|
@@ -972,7 +1021,7 @@ declare namespace web3n.files {
|
|
|
972
1021
|
|
|
973
1022
|
}
|
|
974
1023
|
|
|
975
|
-
interface
|
|
1024
|
+
interface VersionedFileWriteFlags extends FileFlags {
|
|
976
1025
|
|
|
977
1026
|
/**
|
|
978
1027
|
* currentVersion flag is optional. This flag is applicable to existing
|
|
@@ -986,33 +1035,42 @@ declare namespace web3n.files {
|
|
|
986
1035
|
interface ReadonlyFSVersionedAPI {
|
|
987
1036
|
|
|
988
1037
|
getXAttr(
|
|
989
|
-
path: string, xaName: string
|
|
1038
|
+
path: string, xaName: string, flags?: VersionedReadFlags
|
|
990
1039
|
): Promise<{ attr: any; version: number; }>;
|
|
991
1040
|
|
|
992
|
-
listXAttrs(
|
|
1041
|
+
listXAttrs(
|
|
1042
|
+
path: string, flags?: VersionedReadFlags
|
|
1043
|
+
): Promise<{ lst: string[]; version: number; }>;
|
|
993
1044
|
|
|
994
1045
|
/**
|
|
995
1046
|
* This returns a promise, resolvable to a list of informational objects
|
|
996
1047
|
* for entries in the folder, and a folder's version.
|
|
997
1048
|
* @param path of a folder that should be listed
|
|
1049
|
+
* @param flags are optional flags to read archived or remote versions.
|
|
998
1050
|
*/
|
|
999
1051
|
listFolder(
|
|
1000
|
-
path: string
|
|
1052
|
+
path: string, flags?: VersionedReadFlags
|
|
1001
1053
|
): Promise<{ lst: ListingEntry[]; version: number; }>;
|
|
1002
1054
|
|
|
1003
1055
|
/**
|
|
1004
1056
|
* This returns a promise, resolvable to json, read from file, and a
|
|
1005
1057
|
* version of file.
|
|
1006
1058
|
* @param path of a file from which to read json
|
|
1059
|
+
* @param flags are optional flags to read archived or remote versions.
|
|
1007
1060
|
*/
|
|
1008
|
-
readJSONFile<T>(
|
|
1061
|
+
readJSONFile<T>(
|
|
1062
|
+
path: string, flags?: VersionedReadFlags
|
|
1063
|
+
): Promise<{ json: T; version: number; }>;
|
|
1009
1064
|
|
|
1010
1065
|
/**
|
|
1011
1066
|
* This returns a promise, resolvable to text, read from file, assuming
|
|
1012
1067
|
* utf8 encoding, and version of file.
|
|
1013
1068
|
* @param path of a file from which to read text
|
|
1069
|
+
* @param flags are optional flags to read archived or remote versions.
|
|
1014
1070
|
*/
|
|
1015
|
-
readTxtFile(
|
|
1071
|
+
readTxtFile(
|
|
1072
|
+
path: string, flags?: VersionedReadFlags
|
|
1073
|
+
): Promise<{ txt: string; version: number; }>;
|
|
1016
1074
|
|
|
1017
1075
|
/**
|
|
1018
1076
|
* This returns a promise, resolvable to bytes, that is either non-empty
|
|
@@ -1024,18 +1082,21 @@ declare namespace web3n.files {
|
|
|
1024
1082
|
* @param end optional parameter, setting an end of read. If end is
|
|
1025
1083
|
* greater than file length, all available bytes are read. If parameter
|
|
1026
1084
|
* is missing, read will be done to file's end.
|
|
1085
|
+
* @param flags are optional flags to read archived or remote versions.
|
|
1027
1086
|
*/
|
|
1028
1087
|
readBytes(
|
|
1029
|
-
path: string, start?: number, end?: number
|
|
1088
|
+
path: string, start?: number, end?: number,
|
|
1089
|
+
flags?: VersionedReadFlags
|
|
1030
1090
|
): Promise<{ bytes: Uint8Array|undefined; version: number; }>;
|
|
1031
1091
|
|
|
1032
1092
|
/**
|
|
1033
1093
|
* This returns a promise, resolvable to bytes source with seek, which
|
|
1034
1094
|
* allows random reads, and a file version
|
|
1035
1095
|
* @param path of a file from which to read bytes
|
|
1096
|
+
* @param flags are optional flags to read archived or remote versions.
|
|
1036
1097
|
*/
|
|
1037
1098
|
getByteSource(
|
|
1038
|
-
path: string
|
|
1099
|
+
path: string, flags?: VersionedReadFlags
|
|
1039
1100
|
): Promise<{ src: FileByteSource; version: number; }>;
|
|
1040
1101
|
|
|
1041
1102
|
listVersions(
|
|
@@ -1065,7 +1126,7 @@ declare namespace web3n.files {
|
|
|
1065
1126
|
* exclusive=false.
|
|
1066
1127
|
*/
|
|
1067
1128
|
writeJSONFile(
|
|
1068
|
-
path: string, json: any, flags?:
|
|
1129
|
+
path: string, json: any, flags?: VersionedFileWriteFlags
|
|
1069
1130
|
): Promise<number>;
|
|
1070
1131
|
|
|
1071
1132
|
/**
|
|
@@ -1077,7 +1138,7 @@ declare namespace web3n.files {
|
|
|
1077
1138
|
* exclusive=false.
|
|
1078
1139
|
*/
|
|
1079
1140
|
writeTxtFile(
|
|
1080
|
-
path: string, txt: string, flags?:
|
|
1141
|
+
path: string, txt: string, flags?: VersionedFileWriteFlags
|
|
1081
1142
|
): Promise<number>;
|
|
1082
1143
|
|
|
1083
1144
|
/**
|
|
@@ -1089,7 +1150,7 @@ declare namespace web3n.files {
|
|
|
1089
1150
|
* exclusive=false.
|
|
1090
1151
|
*/
|
|
1091
1152
|
writeBytes(
|
|
1092
|
-
path: string, bytes: Uint8Array, flags?:
|
|
1153
|
+
path: string, bytes: Uint8Array, flags?: VersionedFileWriteFlags
|
|
1093
1154
|
): Promise<number>;
|
|
1094
1155
|
|
|
1095
1156
|
/**
|
|
@@ -1100,7 +1161,7 @@ declare namespace web3n.files {
|
|
|
1100
1161
|
* exclusive=false, truncate=true.
|
|
1101
1162
|
*/
|
|
1102
1163
|
getByteSink(
|
|
1103
|
-
path: string, flags?:
|
|
1164
|
+
path: string, flags?: VersionedFileWriteFlags
|
|
1104
1165
|
): Promise<{ sink: FileByteSink; version: number; }>;
|
|
1105
1166
|
|
|
1106
1167
|
archiveCurrent(path: string, version?: number): Promise<number>;
|
|
@@ -1158,7 +1219,9 @@ declare namespace web3n.files {
|
|
|
1158
1219
|
|
|
1159
1220
|
interface WritableFSSyncAPI extends ReadonlyFSSyncAPI {
|
|
1160
1221
|
|
|
1161
|
-
upload(
|
|
1222
|
+
upload(
|
|
1223
|
+
path: string, opts?: OptionsToUploadLocal
|
|
1224
|
+
): Promise<number|undefined>;
|
|
1162
1225
|
|
|
1163
1226
|
adoptRemoteFolderItem(
|
|
1164
1227
|
path: string, itemName: string, opts?: OptionsToAdoptRemoteItem
|
|
@@ -35,11 +35,11 @@ export declare class ConfigOfASMailServer {
|
|
|
35
35
|
* @param kid
|
|
36
36
|
* @return if key is found, object with following fields is returned:
|
|
37
37
|
*/
|
|
38
|
-
find: (kid: string) =>
|
|
38
|
+
find: (kid: string) => {
|
|
39
39
|
role: MsgKeyRole;
|
|
40
40
|
pair: JWKeyPair;
|
|
41
41
|
replacedAt?: number;
|
|
42
|
-
};
|
|
42
|
+
} | undefined;
|
|
43
43
|
};
|
|
44
44
|
private constructor();
|
|
45
45
|
static makeAndStart(address: string, getSigner: GetSigner, resolver: ServiceLocator, net: NetClient, fs: WritableFS): Promise<ConfigOfASMailServer>;
|
|
@@ -30,8 +30,8 @@ const INTRO_KEY_FILE = 'introductory-key.json';
|
|
|
30
30
|
class ConfigOfASMailServer {
|
|
31
31
|
constructor(address, getSigner, resolver, net) {
|
|
32
32
|
const serviceConf = new service_config_1.MailConfigurator(address, getSigner, () => resolver(serviceConf.userId), net);
|
|
33
|
-
this.anonInvites =
|
|
34
|
-
this.publishedIntroKeys =
|
|
33
|
+
this.anonInvites = (0, invitations_anon_1.makeInvites)(serviceConf);
|
|
34
|
+
this.publishedIntroKeys = (0, published_intro_key_1.makePublishedIntroKey)(getSigner, serviceConf);
|
|
35
35
|
this.anonSenderInvites = {
|
|
36
36
|
getAll: this.anonInvites.getAll,
|
|
37
37
|
create: this.anonInvites.create,
|
|
@@ -1,27 +1,13 @@
|
|
|
1
1
|
import { MailConfigurator } from '../../../lib-client/asmail/service-config';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
declare type ExposedFuncs = ConfigOfASMailServer['anonSenderInvites'];
|
|
14
|
-
export declare class Invites extends ParamOnFileAndServer<InvitesJSON, api.InvitesList> {
|
|
15
|
-
private invites;
|
|
16
|
-
constructor(serviceConf: MailConfigurator);
|
|
17
|
-
protected initStruct(): Promise<void>;
|
|
18
|
-
protected setFromJSON(json: InvitesJSON): void;
|
|
19
|
-
protected toFileJSON(): InvitesJSON;
|
|
20
|
-
protected toServiceJSON(): api.InvitesList;
|
|
21
|
-
getAll: ExposedFuncs['getAll'];
|
|
22
|
-
create: ExposedFuncs['create'];
|
|
23
|
-
private generateNewRandomInvite;
|
|
24
|
-
private findByLabel;
|
|
25
|
-
setMsgMaxSize: ExposedFuncs['setMsgMaxSize'];
|
|
2
|
+
declare type WritableFile = web3n.files.WritableFile;
|
|
3
|
+
export interface Invites {
|
|
4
|
+
getAll: () => Map<string, {
|
|
5
|
+
invite: string;
|
|
6
|
+
msgMaxSize: number;
|
|
7
|
+
}>;
|
|
8
|
+
create: (label: string, msgMaxSize: number) => Promise<string>;
|
|
9
|
+
setMsgMaxSize: (label: string, msgMaxSize: number) => Promise<void>;
|
|
10
|
+
start: (file: WritableFile) => Promise<void>;
|
|
26
11
|
}
|
|
12
|
+
export declare function makeInvites(serviceConf: MailConfigurator): Invites;
|
|
27
13
|
export {};
|
|
@@ -15,41 +15,25 @@
|
|
|
15
15
|
You should have received a copy of the GNU General Public License along with
|
|
16
16
|
this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.
|
|
18
|
+
exports.makeInvites = void 0;
|
|
19
19
|
const random = require("../../../lib-common/random-node");
|
|
20
20
|
const api = require("../../../lib-common/service-api/asmail/config");
|
|
21
21
|
const common_1 = require("./common");
|
|
22
22
|
const INVITE_TOKEN_LEN = 40;
|
|
23
|
-
|
|
23
|
+
function makeInvites(serviceConf) {
|
|
24
|
+
const invites = new InvitesData(serviceConf);
|
|
25
|
+
return {
|
|
26
|
+
create: invites.create.bind(invites),
|
|
27
|
+
getAll: invites.getAll.bind(invites),
|
|
28
|
+
setMsgMaxSize: invites.setMsgMaxSize.bind(invites),
|
|
29
|
+
start: invites.start.bind(invites)
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
exports.makeInvites = makeInvites;
|
|
33
|
+
class InvitesData extends common_1.ParamOnFileAndServer {
|
|
24
34
|
constructor(serviceConf) {
|
|
25
35
|
super(api.p.anonSenderInvites.URL_END, serviceConf);
|
|
26
36
|
this.invites = {};
|
|
27
|
-
this.getAll = () => {
|
|
28
|
-
const byLabel = new Map();
|
|
29
|
-
Object.entries(this.invites)
|
|
30
|
-
.forEach(([invite, params]) => {
|
|
31
|
-
byLabel.set(params.label, { invite, msgMaxSize: params.msgMaxSize });
|
|
32
|
-
});
|
|
33
|
-
return byLabel;
|
|
34
|
-
};
|
|
35
|
-
this.create = async (label, msgMaxSize) => {
|
|
36
|
-
const existingInvite = this.findByLabel(label);
|
|
37
|
-
if (existingInvite) {
|
|
38
|
-
throw new Error(`Anonymous sender invite already exists with label ${label}`);
|
|
39
|
-
}
|
|
40
|
-
const invite = await this.generateNewRandomInvite();
|
|
41
|
-
this.invites[invite] = { label, msgMaxSize };
|
|
42
|
-
await this.save();
|
|
43
|
-
return invite;
|
|
44
|
-
};
|
|
45
|
-
this.setMsgMaxSize = async (label, msgMaxSize) => {
|
|
46
|
-
const invite = this.findByLabel(label);
|
|
47
|
-
if (!invite) {
|
|
48
|
-
throw new Error(`There is no anonymous sender invite with label ${label}`);
|
|
49
|
-
}
|
|
50
|
-
this.invites[invite].msgMaxSize = msgMaxSize;
|
|
51
|
-
await this.save();
|
|
52
|
-
};
|
|
53
37
|
Object.seal(this);
|
|
54
38
|
}
|
|
55
39
|
async initStruct() { }
|
|
@@ -69,6 +53,26 @@ class Invites extends common_1.ParamOnFileAndServer {
|
|
|
69
53
|
});
|
|
70
54
|
return serverJSON;
|
|
71
55
|
}
|
|
56
|
+
getAll() {
|
|
57
|
+
const byLabel = new Map();
|
|
58
|
+
Object.entries(this.invites)
|
|
59
|
+
.forEach(([invite, params]) => {
|
|
60
|
+
byLabel.set(params.label, { invite, msgMaxSize: params.msgMaxSize });
|
|
61
|
+
});
|
|
62
|
+
return byLabel;
|
|
63
|
+
}
|
|
64
|
+
;
|
|
65
|
+
async create(label, msgMaxSize) {
|
|
66
|
+
const existingInvite = this.findByLabel(label);
|
|
67
|
+
if (existingInvite) {
|
|
68
|
+
throw new Error(`Anonymous sender invite already exists with label ${label}`);
|
|
69
|
+
}
|
|
70
|
+
const invite = await this.generateNewRandomInvite();
|
|
71
|
+
this.invites[invite] = { label, msgMaxSize };
|
|
72
|
+
await this.save();
|
|
73
|
+
return invite;
|
|
74
|
+
}
|
|
75
|
+
;
|
|
72
76
|
async generateNewRandomInvite() {
|
|
73
77
|
let invite;
|
|
74
78
|
do {
|
|
@@ -81,8 +85,16 @@ class Invites extends common_1.ParamOnFileAndServer {
|
|
|
81
85
|
.find(([_, params]) => (params.label === label));
|
|
82
86
|
return (found ? found[0] : undefined);
|
|
83
87
|
}
|
|
88
|
+
async setMsgMaxSize(label, msgMaxSize) {
|
|
89
|
+
const invite = this.findByLabel(label);
|
|
90
|
+
if (!invite) {
|
|
91
|
+
throw new Error(`There is no anonymous sender invite with label ${label}`);
|
|
92
|
+
}
|
|
93
|
+
this.invites[invite].msgMaxSize = msgMaxSize;
|
|
94
|
+
await this.save();
|
|
95
|
+
}
|
|
96
|
+
;
|
|
84
97
|
}
|
|
85
|
-
|
|
86
|
-
Object.freeze(
|
|
87
|
-
Object.freeze(Invites);
|
|
98
|
+
Object.freeze(InvitesData.prototype);
|
|
99
|
+
Object.freeze(InvitesData);
|
|
88
100
|
Object.freeze(exports);
|
|
@@ -1,28 +1,17 @@
|
|
|
1
1
|
import { MailConfigurator } from '../../../lib-client/asmail/service-config';
|
|
2
2
|
import * as api from '../../../lib-common/service-api/asmail/config';
|
|
3
3
|
import { GetSigner } from '../../id-manager';
|
|
4
|
-
import { JWKeyPair } from '../keyring/common';
|
|
5
|
-
|
|
6
|
-
import { ConfigOfASMailServer } from '../config';
|
|
4
|
+
import { JWKeyPair, MsgKeyRole } from '../keyring/common';
|
|
5
|
+
declare type WritableFile = web3n.files.WritableFile;
|
|
7
6
|
export declare type Certs = api.p.initPubKey.Certs;
|
|
8
|
-
interface
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export declare class PublishedIntroKey extends ParamOnFileAndServer<PublishedIntroKeysJSON, Certs> {
|
|
17
|
-
private getSigner;
|
|
18
|
-
private published;
|
|
19
|
-
constructor(getSigner: GetSigner, serviceConf: MailConfigurator);
|
|
20
|
-
protected initStruct(): Promise<void>;
|
|
21
|
-
protected setFromJSON(json: PublishedIntroKeysJSON): void;
|
|
22
|
-
protected toFileJSON(): PublishedIntroKeysJSON;
|
|
23
|
-
protected toServiceJSON(): Certs;
|
|
24
|
-
private makeNewIntroKey;
|
|
25
|
-
update: ExposedFuncs['update'];
|
|
26
|
-
find: ExposedFuncs['find'];
|
|
7
|
+
export interface PublishedIntroKey {
|
|
8
|
+
update: () => Promise<void>;
|
|
9
|
+
find: (kid: string) => {
|
|
10
|
+
role: MsgKeyRole;
|
|
11
|
+
pair: JWKeyPair;
|
|
12
|
+
replacedAt?: number;
|
|
13
|
+
} | undefined;
|
|
14
|
+
start: (file: WritableFile) => Promise<void>;
|
|
27
15
|
}
|
|
16
|
+
export declare function makePublishedIntroKey(getSigner: GetSigner, serviceConf: MailConfigurator): PublishedIntroKey;
|
|
28
17
|
export {};
|
|
@@ -15,49 +15,25 @@
|
|
|
15
15
|
You should have received a copy of the GNU General Public License along with
|
|
16
16
|
this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.
|
|
18
|
+
exports.makePublishedIntroKey = void 0;
|
|
19
19
|
const api = require("../../../lib-common/service-api/asmail/config");
|
|
20
20
|
const common_1 = require("../keyring/common");
|
|
21
21
|
const common_2 = require("./common");
|
|
22
22
|
const INTRO_KEY_VALIDITY = 31 * 24 * 60 * 60;
|
|
23
|
-
|
|
23
|
+
function makePublishedIntroKey(getSigner, serviceConf) {
|
|
24
|
+
const published = new PublishedKey(getSigner, serviceConf);
|
|
25
|
+
return {
|
|
26
|
+
find: published.find.bind(published),
|
|
27
|
+
update: published.update.bind(published),
|
|
28
|
+
start: published.start.bind(published)
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
exports.makePublishedIntroKey = makePublishedIntroKey;
|
|
32
|
+
class PublishedKey extends common_2.ParamOnFileAndServer {
|
|
24
33
|
constructor(getSigner, serviceConf) {
|
|
25
34
|
super(api.p.initPubKey.URL_END, serviceConf);
|
|
26
35
|
this.getSigner = getSigner;
|
|
27
36
|
this.published = undefined;
|
|
28
|
-
this.update = async () => {
|
|
29
|
-
const newKey = await this.makeNewIntroKey();
|
|
30
|
-
if (this.published.current) {
|
|
31
|
-
this.published.current.keyPair.retiredAt = newKey.pair.createdAt;
|
|
32
|
-
this.published.previous = this.published.current.keyPair;
|
|
33
|
-
}
|
|
34
|
-
this.published.current = {
|
|
35
|
-
keyPair: newKey.pair,
|
|
36
|
-
certs: newKey.certs
|
|
37
|
-
};
|
|
38
|
-
await this.save();
|
|
39
|
-
};
|
|
40
|
-
this.find = (kid) => {
|
|
41
|
-
// check current key
|
|
42
|
-
if (this.published.current
|
|
43
|
-
&& (this.published.current.keyPair.skey.kid === kid)) {
|
|
44
|
-
return {
|
|
45
|
-
role: 'published_intro',
|
|
46
|
-
pair: this.published.current.keyPair
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
// check previous key
|
|
50
|
-
if (this.published.previous
|
|
51
|
-
&& (this.published.previous.skey.kid === kid)) {
|
|
52
|
-
return {
|
|
53
|
-
role: 'prev_published_intro',
|
|
54
|
-
pair: this.published.previous,
|
|
55
|
-
replacedAt: this.published.previous.retiredAt
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
// if nothing found, explicitly return undefined
|
|
59
|
-
return;
|
|
60
|
-
};
|
|
61
37
|
Object.seal(this);
|
|
62
38
|
}
|
|
63
39
|
async initStruct() {
|
|
@@ -89,8 +65,41 @@ class PublishedIntroKey extends common_2.ParamOnFileAndServer {
|
|
|
89
65
|
pair.createdAt = Date.now();
|
|
90
66
|
return { pair, certs };
|
|
91
67
|
}
|
|
68
|
+
async update() {
|
|
69
|
+
const newKey = await this.makeNewIntroKey();
|
|
70
|
+
if (this.published.current) {
|
|
71
|
+
this.published.current.keyPair.retiredAt = newKey.pair.createdAt;
|
|
72
|
+
this.published.previous = this.published.current.keyPair;
|
|
73
|
+
}
|
|
74
|
+
this.published.current = {
|
|
75
|
+
keyPair: newKey.pair,
|
|
76
|
+
certs: newKey.certs
|
|
77
|
+
};
|
|
78
|
+
await this.save();
|
|
79
|
+
}
|
|
80
|
+
;
|
|
81
|
+
find(kid) {
|
|
82
|
+
// check current key
|
|
83
|
+
if (this.published.current
|
|
84
|
+
&& (this.published.current.keyPair.skey.kid === kid)) {
|
|
85
|
+
return {
|
|
86
|
+
role: 'published_intro',
|
|
87
|
+
pair: this.published.current.keyPair
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
// check previous key
|
|
91
|
+
if (this.published.previous
|
|
92
|
+
&& (this.published.previous.skey.kid === kid)) {
|
|
93
|
+
return {
|
|
94
|
+
role: 'prev_published_intro',
|
|
95
|
+
pair: this.published.previous,
|
|
96
|
+
replacedAt: this.published.previous.retiredAt
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
// if nothing found, explicitly return undefined
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
92
102
|
}
|
|
93
|
-
|
|
94
|
-
Object.freeze(
|
|
95
|
-
Object.freeze(PublishedIntroKey);
|
|
103
|
+
Object.freeze(PublishedKey.prototype);
|
|
104
|
+
Object.freeze(PublishedKey);
|
|
96
105
|
Object.freeze(exports);
|
|
@@ -370,7 +370,7 @@ class WIP {
|
|
|
370
370
|
if (!isEndless) {
|
|
371
371
|
obj.upload.expectedSegsSize = size;
|
|
372
372
|
}
|
|
373
|
-
let segsChunk = await obj.src.segSrc.
|
|
373
|
+
let segsChunk = await obj.src.segSrc.readNext(this.sender.maxChunkSize - header.length);
|
|
374
374
|
// check if we'll be done in this request
|
|
375
375
|
const segsSize = obj.upload.expectedSegsSize;
|
|
376
376
|
let isObjDone = false;
|
|
@@ -406,7 +406,7 @@ class WIP {
|
|
|
406
406
|
async followingObjSendingRequest(obj) {
|
|
407
407
|
// read from source
|
|
408
408
|
const segsSize = obj.upload.expectedSegsSize;
|
|
409
|
-
const chunk = await obj.src.segSrc.
|
|
409
|
+
const chunk = await obj.src.segSrc.readNext(this.sender.maxChunkSize);
|
|
410
410
|
// return early, when there are no bytes
|
|
411
411
|
if (!chunk) {
|
|
412
412
|
await this.sender.sendObj(obj.objId, EMPTY_BYTE_ARR, undefined, { ofs: obj.upload.segsOffset, last: true });
|
|
@@ -30,11 +30,16 @@ class InboxEvents {
|
|
|
30
30
|
constructor(msgReceiver, getMsg, logError) {
|
|
31
31
|
const serverEvents = new server_events_1.ServerEvents(() => msgReceiver.openEventSource(), SERVER_EVENTS_RESTART_WAIT_SECS);
|
|
32
32
|
this.newMsg$ = serverEvents.observe(retrieval_1.msgRecievedCompletely.EVENT_NAME)
|
|
33
|
-
.pipe((0, operators_1.mergeMap)(ev =>
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
.pipe((0, operators_1.mergeMap)(async (ev) => {
|
|
34
|
+
try {
|
|
35
|
+
const msg = await getMsg(ev.msgId);
|
|
36
|
+
return msg;
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
// TODO should more error handling logic be added here?
|
|
40
|
+
await logError(err, `Cannot get message ${ev.msgId}`);
|
|
41
|
+
}
|
|
42
|
+
}), (0, operators_1.filter)(msg => !!msg), (0, operators_1.share)());
|
|
38
43
|
Object.seal(this);
|
|
39
44
|
}
|
|
40
45
|
subscribe(event, observer) {
|