core-3nweb-client-lib 0.27.0 → 0.27.4

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.
Files changed (81) hide show
  1. package/build/api-defs/files.d.ts +56 -26
  2. package/build/core/asmail/config/index.d.ts +2 -2
  3. package/build/core/asmail/config/index.js +2 -2
  4. package/build/core/asmail/config/invitations-anon.d.ts +10 -24
  5. package/build/core/asmail/config/invitations-anon.js +43 -31
  6. package/build/core/asmail/config/published-intro-key.d.ts +11 -22
  7. package/build/core/asmail/config/published-intro-key.js +47 -38
  8. package/build/core/asmail/inbox/attachments/fs.d.ts +2 -1
  9. package/build/core/asmail/inbox/attachments/fs.js +4 -3
  10. package/build/core/asmail/inbox/index.js +2 -2
  11. package/build/core/asmail/index.d.ts +1 -1
  12. package/build/core/asmail/index.js +2 -2
  13. package/build/core/asmail/keyring/correspondent-keys.d.ts +2 -2
  14. package/build/core/asmail/keyring/correspondent-keys.js +1 -1
  15. package/build/core/asmail/keyring/index.d.ts +9 -29
  16. package/build/core/asmail/keyring/index.js +82 -69
  17. package/build/core/id-manager/index.d.ts +43 -0
  18. package/build/core/{id-manager.js → id-manager/index.js} +33 -114
  19. package/build/core/id-manager/key-storage.d.ts +21 -0
  20. package/build/core/id-manager/key-storage.js +96 -0
  21. package/build/core/index.js +22 -25
  22. package/build/core/sign-in.d.ts +1 -2
  23. package/build/core/sign-in.js +5 -14
  24. package/build/core/sign-up.d.ts +2 -0
  25. package/build/core/sign-up.js +2 -1
  26. package/build/core/storage/index.d.ts +4 -2
  27. package/build/core/storage/index.js +36 -57
  28. package/build/core/storage/local/storage.d.ts +1 -1
  29. package/build/core/storage/synced/obj-files-gc.d.ts +1 -4
  30. package/build/core/storage/synced/obj-files-gc.js +1 -18
  31. package/build/core/storage/synced/obj-files.d.ts +11 -1
  32. package/build/core/storage/synced/obj-files.js +59 -34
  33. package/build/core/storage/synced/obj-status.d.ts +19 -7
  34. package/build/core/storage/synced/obj-status.js +158 -83
  35. package/build/core/storage/synced/storage.d.ts +7 -2
  36. package/build/core/storage/synced/storage.js +38 -15
  37. package/build/core/storage/synced/upsyncer.d.ts +4 -4
  38. package/build/core/storage/synced/upsyncer.js +14 -9
  39. package/build/ipc-via-protobuf/file.d.ts +7 -0
  40. package/build/ipc-via-protobuf/file.js +60 -27
  41. package/build/ipc-via-protobuf/fs.js +55 -38
  42. package/build/lib-client/3nstorage/exceptions.d.ts +13 -1
  43. package/build/lib-client/3nstorage/exceptions.js +9 -3
  44. package/build/lib-client/3nstorage/service.d.ts +6 -2
  45. package/build/lib-client/3nstorage/service.js +33 -17
  46. package/build/lib-client/3nstorage/util/file-based-json.js +2 -1
  47. package/build/lib-client/3nstorage/util/for-arrays.d.ts +1 -0
  48. package/build/lib-client/3nstorage/util/for-arrays.js +32 -0
  49. package/build/lib-client/3nstorage/xsp-fs/common.d.ts +5 -4
  50. package/build/lib-client/3nstorage/xsp-fs/common.js +1 -0
  51. package/build/lib-client/3nstorage/xsp-fs/file-node.d.ts +5 -10
  52. package/build/lib-client/3nstorage/xsp-fs/file-node.js +43 -45
  53. package/build/lib-client/3nstorage/xsp-fs/file.d.ts +7 -6
  54. package/build/lib-client/3nstorage/xsp-fs/file.js +14 -20
  55. package/build/lib-client/3nstorage/xsp-fs/folder-node.d.ts +16 -5
  56. package/build/lib-client/3nstorage/xsp-fs/folder-node.js +238 -68
  57. package/build/lib-client/3nstorage/xsp-fs/fs.d.ts +18 -17
  58. package/build/lib-client/3nstorage/xsp-fs/fs.js +32 -37
  59. package/build/lib-client/3nstorage/xsp-fs/node-in-fs.d.ts +15 -11
  60. package/build/lib-client/3nstorage/xsp-fs/node-in-fs.js +72 -22
  61. package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v1.js +1 -1
  62. package/build/lib-client/local-files/device-fs.js +11 -11
  63. package/build/lib-client/objs-on-disk/obj-on-disk.d.ts +5 -2
  64. package/build/lib-client/objs-on-disk/obj-on-disk.js +16 -1
  65. package/build/lib-client/user-with-mid-session.d.ts +2 -1
  66. package/build/lib-client/user-with-mid-session.js +7 -1
  67. package/build/lib-common/async-fs-node.js +8 -8
  68. package/build/lib-common/exceptions/file.d.ts +4 -2
  69. package/build/lib-common/exceptions/file.js +24 -58
  70. package/build/lib-common/ipc/generic-ipc.js +5 -4
  71. package/build/lib-common/objs-on-disk/file-layout.js +1 -1
  72. package/build/lib-common/objs-on-disk/utils.js +1 -1
  73. package/build/lib-common/service-api/3nstorage/owner.d.ts +8 -9
  74. package/build/lib-common/service-api/3nstorage/owner.js +2 -1
  75. package/build/protos/asmail.proto.js +5943 -4348
  76. package/build/protos/file.proto.js +874 -0
  77. package/build/protos/fs.proto.js +7014 -5419
  78. package/package.json +3 -2
  79. package/protos/file.proto +23 -7
  80. package/protos/fs.proto +27 -13
  81. package/build/core/id-manager.d.ts +0 -46
@@ -16,7 +16,7 @@
16
16
  this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.vListVersions = exports.remoteAdoptionOptsFromMsg = exports.remoteAdoptionOptsToMsg = exports.optionsToUploadLocalFromMsg = exports.optionsToUploadLocalToMsg = exports.vGetByteSink = exports.updateXAttrs = exports.xattrFromMsg = exports.xattrToMsg = exports.vGetByteSource = exports.vReadJSON = exports.vReadTxt = exports.vReadBytes = exports.vListXAttrs = exports.vGetXAttr = exports.unpackFileEvent = exports.packFileEvent = exports.unpackJSON = exports.packJSON = exports.readBytes = exports.unpackXAttrValue = exports.packXAttrValue = exports.unpackSyncStatus = exports.packSyncStatus = exports.unpackStats = exports.packStats = exports.fileMsgType = exports.exposeFileService = exports.makeFileCaller = void 0;
19
+ exports.vListVersions = exports.remoteAdoptionOptsFromMsg = exports.remoteAdoptionOptsToMsg = exports.optionsToUploadLocalFromMsg = exports.optionsToUploadLocalToMsg = exports.vGetByteSink = exports.updateXAttrs = exports.xattrFromMsg = exports.xattrToMsg = exports.vGetByteSource = exports.vReadJSON = exports.vReadTxt = exports.vReadBytes = exports.vListXAttrs = exports.vGetXAttr = exports.versionedReadFlagsToMsg = exports.versionedReadFlagsFromMsg = exports.unpackFileEvent = exports.packFileEvent = exports.unpackJSON = exports.packJSON = exports.readBytes = exports.unpackXAttrValue = exports.packXAttrValue = exports.unpackSyncStatus = exports.packSyncStatus = exports.unpackStats = exports.packStats = exports.fileMsgType = exports.exposeFileService = exports.makeFileCaller = void 0;
20
20
  const protobuf_msg_1 = require("./protobuf-msg");
21
21
  const protobuf_type_1 = require("../lib-client/protobuf-type");
22
22
  const file_proto_1 = require("../protos/file.proto");
@@ -533,9 +533,29 @@ var watch;
533
533
  watch.makeCaller = makeCaller;
534
534
  })(watch || (watch = {}));
535
535
  Object.freeze(watch);
536
+ function versionedReadFlagsFromMsg(msg) {
537
+ if (!msg) {
538
+ return;
539
+ }
540
+ return {
541
+ archivedVersion: (0, protobuf_msg_1.valOfOptInt)(msg.archivedVersion),
542
+ remoteVersion: (0, protobuf_msg_1.valOfOptInt)(msg.remoteVersion)
543
+ };
544
+ }
545
+ exports.versionedReadFlagsFromMsg = versionedReadFlagsFromMsg;
546
+ function versionedReadFlagsToMsg(flags) {
547
+ if (!flags) {
548
+ return;
549
+ }
550
+ return {
551
+ archivedVersion: (0, protobuf_msg_1.toOptVal)(flags.archivedVersion),
552
+ remoteVersion: (0, protobuf_msg_1.toOptVal)(flags.remoteVersion)
553
+ };
554
+ }
555
+ exports.versionedReadFlagsToMsg = versionedReadFlagsToMsg;
536
556
  var vGetXAttr;
537
557
  (function (vGetXAttr) {
538
- const requestType = protobuf_type_1.ProtoType.for(file_proto_1.file.GetXAttrRequestBody);
558
+ const requestType = protobuf_type_1.ProtoType.for(file_proto_1.file.VersionedGetXAttrRequestBody);
539
559
  vGetXAttr.replyType = protobuf_type_1.ProtoType.for(file_proto_1.file.VersionedGetXAttrReplyBody);
540
560
  function unpackReply(buf) {
541
561
  const { json, str, bytes, version: v } = vGetXAttr.replyType.unpack(buf);
@@ -553,8 +573,8 @@ var vGetXAttr;
553
573
  vGetXAttr.unpackReply = unpackReply;
554
574
  function wrapService(fn) {
555
575
  return buf => {
556
- const { xaName } = requestType.unpack(buf);
557
- const promise = fn(xaName)
576
+ const { xaName, flags } = requestType.unpack(buf);
577
+ const promise = fn(xaName, versionedReadFlagsFromMsg(flags))
558
578
  .then(({ attr, version }) => {
559
579
  if (Buffer.isBuffer(attr)) {
560
580
  return vGetXAttr.replyType.pack({ version, bytes: (0, protobuf_msg_1.toVal)(attr) });
@@ -572,19 +592,31 @@ var vGetXAttr;
572
592
  vGetXAttr.wrapService = wrapService;
573
593
  function makeCaller(caller, objPath) {
574
594
  const path = objPath.concat('getXAttr');
575
- return () => caller
576
- .startPromiseCall(path, undefined)
595
+ return (xaName, flags) => caller
596
+ .startPromiseCall(path, requestType.pack({
597
+ xaName, flags: versionedReadFlagsToMsg(flags)
598
+ }))
577
599
  .then(unpackReply);
578
600
  }
579
601
  vGetXAttr.makeCaller = makeCaller;
580
602
  })(vGetXAttr = exports.vGetXAttr || (exports.vGetXAttr = {}));
581
603
  Object.freeze(vGetXAttr);
604
+ const requestWithReadFlags = protobuf_type_1.ProtoType.for(file_proto_1.file.RequestWithVersionedReadFlags);
605
+ function packVersionedReadFlagsRequest(flags) {
606
+ return requestWithReadFlags.pack({
607
+ flags: versionedReadFlagsToMsg(flags)
608
+ });
609
+ }
610
+ function unpackVersionedReadFlagsRequest(buf) {
611
+ const { flags } = requestWithReadFlags.unpack(buf);
612
+ return versionedReadFlagsFromMsg(flags);
613
+ }
582
614
  var vListXAttrs;
583
615
  (function (vListXAttrs) {
584
616
  vListXAttrs.replyType = protobuf_type_1.ProtoType.for(file_proto_1.file.VersionedListXAttrsReplyBody);
585
617
  function wrapService(fn) {
586
- return () => {
587
- const promise = fn()
618
+ return buf => {
619
+ const promise = fn(unpackVersionedReadFlagsRequest(buf))
588
620
  .then(({ version, lst }) => vListXAttrs.replyType.pack({ version, xaNames: lst }));
589
621
  return { promise };
590
622
  };
@@ -592,8 +624,8 @@ var vListXAttrs;
592
624
  vListXAttrs.wrapService = wrapService;
593
625
  function makeCaller(caller, objPath) {
594
626
  const path = objPath.concat('listXAttrs');
595
- return () => caller
596
- .startPromiseCall(path, undefined)
627
+ return flags => caller
628
+ .startPromiseCall(path, packVersionedReadFlagsRequest(flags))
597
629
  .then(buf => {
598
630
  const { xaNames, version: v } = vListXAttrs.replyType.unpack(buf);
599
631
  return { version: (0, protobuf_msg_1.fixInt)(v), lst: (xaNames ? xaNames : []) };
@@ -604,7 +636,7 @@ var vListXAttrs;
604
636
  Object.freeze(vListXAttrs);
605
637
  var vReadBytes;
606
638
  (function (vReadBytes) {
607
- const requestType = protobuf_type_1.ProtoType.for(file_proto_1.file.ReadBytesRequestBody);
639
+ const requestType = protobuf_type_1.ProtoType.for(file_proto_1.file.VersionedReadBytesRequestBody);
608
640
  const replyType = protobuf_type_1.ProtoType.for(file_proto_1.file.VersionedReadBytesReplyBody);
609
641
  function packReply(r) {
610
642
  return replyType.pack({
@@ -619,8 +651,8 @@ var vReadBytes;
619
651
  vReadBytes.unpackReply = unpackReply;
620
652
  function wrapService(fn) {
621
653
  return buf => {
622
- const { start, end } = requestType.unpack(buf);
623
- const promise = fn((0, protobuf_msg_1.valOfOptInt)(start), (0, protobuf_msg_1.valOfOptInt)(end))
654
+ const { start, end, flags } = requestType.unpack(buf);
655
+ const promise = fn((0, protobuf_msg_1.valOfOptInt)(start), (0, protobuf_msg_1.valOfOptInt)(end), versionedReadFlagsFromMsg(flags))
624
656
  .then(packReply);
625
657
  return { promise };
626
658
  };
@@ -628,9 +660,10 @@ var vReadBytes;
628
660
  vReadBytes.wrapService = wrapService;
629
661
  function makeCaller(caller, objPath) {
630
662
  const path = objPath.concat('readBytes');
631
- return (start, end) => caller
663
+ return (start, end, flags) => caller
632
664
  .startPromiseCall(path, requestType.pack({
633
- start: (0, protobuf_msg_1.toOptVal)(start), end: (0, protobuf_msg_1.toOptVal)(end)
665
+ start: (0, protobuf_msg_1.toOptVal)(start), end: (0, protobuf_msg_1.toOptVal)(end),
666
+ flags: versionedReadFlagsToMsg(flags)
634
667
  }))
635
668
  .then(unpackReply);
636
669
  }
@@ -641,8 +674,8 @@ var vReadTxt;
641
674
  (function (vReadTxt) {
642
675
  vReadTxt.replyType = protobuf_type_1.ProtoType.for(file_proto_1.file.VersionedReadTxtReplyBody);
643
676
  function wrapService(fn) {
644
- return () => {
645
- const promise = fn()
677
+ return buf => {
678
+ const promise = fn(unpackVersionedReadFlagsRequest(buf))
646
679
  .then(verAndTxt => vReadTxt.replyType.pack(verAndTxt));
647
680
  return { promise };
648
681
  };
@@ -650,8 +683,8 @@ var vReadTxt;
650
683
  vReadTxt.wrapService = wrapService;
651
684
  function makeCaller(caller, objPath) {
652
685
  const path = objPath.concat('readTxt');
653
- return () => caller
654
- .startPromiseCall(path, undefined)
686
+ return flags => caller
687
+ .startPromiseCall(path, packVersionedReadFlagsRequest(flags))
655
688
  .then(buf => {
656
689
  const { version: v, txt } = vReadTxt.replyType.unpack(buf);
657
690
  return { version: (0, protobuf_msg_1.fixInt)(v), txt };
@@ -664,8 +697,8 @@ var vReadJSON;
664
697
  (function (vReadJSON) {
665
698
  vReadJSON.replyType = protobuf_type_1.ProtoType.for(file_proto_1.file.VersionedReadJsonReplyBody);
666
699
  function wrapService(fn) {
667
- return () => {
668
- const promise = fn()
700
+ return buf => {
701
+ const promise = fn(unpackVersionedReadFlagsRequest(buf))
669
702
  .then(({ version, json }) => {
670
703
  return vReadJSON.replyType.pack({ version, json: JSON.stringify(json) });
671
704
  });
@@ -675,8 +708,8 @@ var vReadJSON;
675
708
  vReadJSON.wrapService = wrapService;
676
709
  function makeCaller(caller, objPath) {
677
710
  const path = objPath.concat('readJSON');
678
- return () => caller
679
- .startPromiseCall(path, undefined)
711
+ return flags => caller
712
+ .startPromiseCall(path, packVersionedReadFlagsRequest(flags))
680
713
  .then(buf => {
681
714
  const { version: v, json } = vReadJSON.replyType.unpack(buf);
682
715
  try {
@@ -694,8 +727,8 @@ var vGetByteSource;
694
727
  (function (vGetByteSource) {
695
728
  vGetByteSource.replyType = protobuf_type_1.ProtoType.for(file_proto_1.file.VersionedGetByteSourceReplyBody);
696
729
  function wrapService(fn, expServices) {
697
- return () => {
698
- const promise = fn()
730
+ return buf => {
731
+ const promise = fn(unpackVersionedReadFlagsRequest(buf))
699
732
  .then(({ version, src }) => {
700
733
  const ref = (0, bytes_1.exposeSrcService)(src, expServices);
701
734
  return vGetByteSource.replyType.pack({ version, src: ref });
@@ -706,8 +739,8 @@ var vGetByteSource;
706
739
  vGetByteSource.wrapService = wrapService;
707
740
  function makeCaller(caller, objPath) {
708
741
  const path = objPath.concat('getByteSource');
709
- return () => caller
710
- .startPromiseCall(path, undefined)
742
+ return flags => caller
743
+ .startPromiseCall(path, packVersionedReadFlagsRequest(flags))
711
744
  .then(buf => {
712
745
  const { version: v, src: ref } = vGetByteSource.replyType.unpack(buf);
713
746
  return { version: (0, protobuf_msg_1.fixInt)(v), src: (0, bytes_1.makeSrcCaller)(caller, ref) };
@@ -261,10 +261,10 @@ var stat;
261
261
  Object.freeze(stat);
262
262
  var getXAttr;
263
263
  (function (getXAttr) {
264
- getXAttr.requestType = protobuf_type_1.ProtoType.for(fs_proto_1.fs.GetXAttrRequestBody);
264
+ const requestType = protobuf_type_1.ProtoType.for(fs_proto_1.fs.GetXAttrRequestBody);
265
265
  function wrapService(fn) {
266
266
  return buf => {
267
- const { path, xaName } = getXAttr.requestType.unpack(buf);
267
+ const { path, xaName } = requestType.unpack(buf);
268
268
  const promise = fn(path, xaName)
269
269
  .then(file_1.packXAttrValue);
270
270
  return { promise };
@@ -274,7 +274,7 @@ var getXAttr;
274
274
  function makeCaller(caller, objPath) {
275
275
  const ipcPath = objPath.concat('getXAttr');
276
276
  return (path, xaName) => caller
277
- .startPromiseCall(ipcPath, getXAttr.requestType.pack({ path, xaName }))
277
+ .startPromiseCall(ipcPath, requestType.pack({ path, xaName }))
278
278
  .then(file_1.unpackXAttrValue);
279
279
  }
280
280
  getXAttr.makeCaller = makeCaller;
@@ -695,10 +695,10 @@ var readTxtFile;
695
695
  Object.freeze(readTxtFile);
696
696
  var readBytes;
697
697
  (function (readBytes) {
698
- readBytes.requestType = protobuf_type_1.ProtoType.for(fs_proto_1.fs.ReadBytesRequestBody);
698
+ const requestType = protobuf_type_1.ProtoType.for(fs_proto_1.fs.ReadBytesRequestBody);
699
699
  function wrapService(fn) {
700
700
  return buf => {
701
- const { path, start, end } = readBytes.requestType.unpack(buf);
701
+ const { path, start, end } = requestType.unpack(buf);
702
702
  const promise = fn(path, (0, protobuf_msg_1.valOfOptInt)(start), (0, protobuf_msg_1.valOfOptInt)(end))
703
703
  .then(file.readBytes.packReply);
704
704
  return { promise };
@@ -708,7 +708,7 @@ var readBytes;
708
708
  function makeCaller(caller, objPath) {
709
709
  const ipcPath = objPath.concat('readBytes');
710
710
  return (path, start, end) => caller
711
- .startPromiseCall(ipcPath, readBytes.requestType.pack({
711
+ .startPromiseCall(ipcPath, requestType.pack({
712
712
  path, start: (0, protobuf_msg_1.toOptVal)(start), end: (0, protobuf_msg_1.toOptVal)(end)
713
713
  }))
714
714
  .then(file.readBytes.unpackReply);
@@ -1169,12 +1169,27 @@ var fsItem;
1169
1169
  fsItem.fsItemFromMsg = fsItemFromMsg;
1170
1170
  })(fsItem = exports.fsItem || (exports.fsItem = {}));
1171
1171
  Object.freeze(fsItem);
1172
+ const reqWithPathAndFlagsType = protobuf_type_1.ProtoType.for(fs_proto_1.fs.PathAndFlagsRequestBody);
1173
+ function packRequestWithPathAndFlags(path, flags) {
1174
+ return reqWithPathAndFlagsType.pack({
1175
+ path,
1176
+ flags: file.versionedReadFlagsToMsg(flags)
1177
+ });
1178
+ }
1179
+ function unpackRequestWithPathAndFlags(buf) {
1180
+ const { path, flags } = reqWithPathAndFlagsType.unpack(buf);
1181
+ return {
1182
+ path,
1183
+ flags: file.versionedReadFlagsFromMsg(flags)
1184
+ };
1185
+ }
1172
1186
  var vGetXAttr;
1173
1187
  (function (vGetXAttr) {
1188
+ const requestType = protobuf_type_1.ProtoType.for(fs_proto_1.fs.VersionedGetXAttrRequestBody);
1174
1189
  function wrapService(fn) {
1175
1190
  return buf => {
1176
- const { path, xaName } = getXAttr.requestType.unpack(buf);
1177
- const promise = fn(path, xaName)
1191
+ const { path, xaName, flags } = requestType.unpack(buf);
1192
+ const promise = fn(path, xaName, file.versionedReadFlagsFromMsg(flags))
1178
1193
  .then(attrAndVer => file.vGetXAttr.replyType.pack(attrAndVer));
1179
1194
  return { promise };
1180
1195
  };
@@ -1182,8 +1197,10 @@ var vGetXAttr;
1182
1197
  vGetXAttr.wrapService = wrapService;
1183
1198
  function makeCaller(caller, objPath) {
1184
1199
  const ipcPath = objPath.concat('getXAttr');
1185
- return (path, xaName) => caller
1186
- .startPromiseCall(ipcPath, getXAttr.requestType.pack({ path, xaName }))
1200
+ return (path, xaName, flags) => caller
1201
+ .startPromiseCall(ipcPath, requestType.pack({
1202
+ path, xaName, flags: file.versionedReadFlagsToMsg(flags)
1203
+ }))
1187
1204
  .then(file.vGetXAttr.unpackReply);
1188
1205
  }
1189
1206
  vGetXAttr.makeCaller = makeCaller;
@@ -1193,8 +1210,8 @@ var vListXAttrs;
1193
1210
  (function (vListXAttrs) {
1194
1211
  function wrapService(fn) {
1195
1212
  return buf => {
1196
- const { path } = reqWithPathType.unpack(buf);
1197
- const promise = fn(path)
1213
+ const { path, flags } = unpackRequestWithPathAndFlags(buf);
1214
+ const promise = fn(path, flags)
1198
1215
  .then(({ version, lst }) => file.vListXAttrs.replyType.pack({ version, xaNames: lst }));
1199
1216
  return { promise };
1200
1217
  };
@@ -1202,8 +1219,8 @@ var vListXAttrs;
1202
1219
  vListXAttrs.wrapService = wrapService;
1203
1220
  function makeCaller(caller, objPath) {
1204
1221
  const ipcPath = objPath.concat('listXAttrs');
1205
- return path => caller
1206
- .startPromiseCall(ipcPath, reqWithPathType.pack({ path }))
1222
+ return (path, flags) => caller
1223
+ .startPromiseCall(ipcPath, packRequestWithPathAndFlags(path, flags))
1207
1224
  .then(buf => {
1208
1225
  const { version: v, xaNames } = file.vListXAttrs.replyType.unpack(buf);
1209
1226
  return { version: (0, protobuf_msg_1.fixInt)(v), lst: (xaNames ? xaNames : []) };
@@ -1217,8 +1234,8 @@ var vListFolder;
1217
1234
  const replyType = protobuf_type_1.ProtoType.for(fs_proto_1.fs.VersionedListFolderReplyBody);
1218
1235
  function wrapService(fn) {
1219
1236
  return buf => {
1220
- const { path } = reqWithPathType.unpack(buf);
1221
- const promise = fn(path)
1237
+ const { path, flags } = unpackRequestWithPathAndFlags(buf);
1238
+ const promise = fn(path, flags)
1222
1239
  .then(({ version, lst }) => replyType.pack({
1223
1240
  version, entries: lst.map(lsEntryToMsg)
1224
1241
  }));
@@ -1228,8 +1245,8 @@ var vListFolder;
1228
1245
  vListFolder.wrapService = wrapService;
1229
1246
  function makeCaller(caller, objPath) {
1230
1247
  const ipcPath = objPath.concat('listFolder');
1231
- return path => caller
1232
- .startPromiseCall(ipcPath, reqWithPathType.pack({ path }))
1248
+ return (path, flags) => caller
1249
+ .startPromiseCall(ipcPath, packRequestWithPathAndFlags(path, flags))
1233
1250
  .then(buf => {
1234
1251
  const { version: v, entries } = replyType.unpack(buf);
1235
1252
  return {
@@ -1244,8 +1261,8 @@ var vReadJSONFile;
1244
1261
  (function (vReadJSONFile) {
1245
1262
  function wrapService(fn) {
1246
1263
  return buf => {
1247
- const { path } = reqWithPathType.unpack(buf);
1248
- const promise = fn(path)
1264
+ const { path, flags } = unpackRequestWithPathAndFlags(buf);
1265
+ const promise = fn(path, flags)
1249
1266
  .then(({ version, json }) => {
1250
1267
  return file.vReadJSON.replyType.pack({ version, json: JSON.stringify(json) });
1251
1268
  });
@@ -1255,8 +1272,8 @@ var vReadJSONFile;
1255
1272
  vReadJSONFile.wrapService = wrapService;
1256
1273
  function makeCaller(caller, objPath) {
1257
1274
  const ipcPath = objPath.concat('readJSONFile');
1258
- return path => caller
1259
- .startPromiseCall(ipcPath, reqWithPathType.pack({ path }))
1275
+ return (path, flags) => caller
1276
+ .startPromiseCall(ipcPath, packRequestWithPathAndFlags(path, flags))
1260
1277
  .then(buf => {
1261
1278
  const { version: v, json } = file.vReadJSON.replyType.unpack(buf);
1262
1279
  return { version: (0, protobuf_msg_1.fixInt)(v), json: JSON.parse(json) };
@@ -1269,8 +1286,8 @@ var vReadTxtFile;
1269
1286
  (function (vReadTxtFile) {
1270
1287
  function wrapService(fn) {
1271
1288
  return buf => {
1272
- const { path } = reqWithPathType.unpack(buf);
1273
- const promise = fn(path)
1289
+ const { path, flags } = unpackRequestWithPathAndFlags(buf);
1290
+ const promise = fn(path, flags)
1274
1291
  .then(verAndTxt => file.vReadTxt.replyType.pack(verAndTxt));
1275
1292
  return { promise };
1276
1293
  };
@@ -1278,8 +1295,8 @@ var vReadTxtFile;
1278
1295
  vReadTxtFile.wrapService = wrapService;
1279
1296
  function makeCaller(caller, objPath) {
1280
1297
  const ipcPath = objPath.concat('readTxtFile');
1281
- return path => caller
1282
- .startPromiseCall(ipcPath, reqWithPathType.pack({ path }))
1298
+ return (path, flags) => caller
1299
+ .startPromiseCall(ipcPath, packRequestWithPathAndFlags(path, flags))
1283
1300
  .then(buf => {
1284
1301
  const { version: v, txt } = file.vReadTxt.replyType.unpack(buf);
1285
1302
  return { version: (0, protobuf_msg_1.fixInt)(v), txt };
@@ -1290,10 +1307,11 @@ var vReadTxtFile;
1290
1307
  Object.freeze(vReadTxtFile);
1291
1308
  var vReadBytes;
1292
1309
  (function (vReadBytes) {
1310
+ const requestType = protobuf_type_1.ProtoType.for(fs_proto_1.fs.VersionedReadBytesRequestBody);
1293
1311
  function wrapService(fn) {
1294
1312
  return buf => {
1295
- const { path, start, end } = readBytes.requestType.unpack(buf);
1296
- const promise = fn(path, (0, protobuf_msg_1.valOfOptInt)(start), (0, protobuf_msg_1.valOfOptInt)(end))
1313
+ const { path, start, end, flags } = requestType.unpack(buf);
1314
+ const promise = fn(path, (0, protobuf_msg_1.valOfOptInt)(start), (0, protobuf_msg_1.valOfOptInt)(end), file.versionedReadFlagsFromMsg(flags))
1297
1315
  .then(file.vReadBytes.packReply);
1298
1316
  return { promise };
1299
1317
  };
@@ -1301,13 +1319,12 @@ var vReadBytes;
1301
1319
  vReadBytes.wrapService = wrapService;
1302
1320
  function makeCaller(caller, objPath) {
1303
1321
  const ipcPath = objPath.concat('readBytes');
1304
- return (path, start, end) => {
1305
- return caller
1306
- .startPromiseCall(ipcPath, readBytes.requestType.pack({
1307
- path, start: (0, protobuf_msg_1.toOptVal)(start), end: (0, protobuf_msg_1.toOptVal)(end)
1308
- }))
1309
- .then(file.vReadBytes.unpackReply);
1310
- };
1322
+ return (path, start, end, flags) => caller
1323
+ .startPromiseCall(ipcPath, requestType.pack({
1324
+ path, start: (0, protobuf_msg_1.toOptVal)(start), end: (0, protobuf_msg_1.toOptVal)(end),
1325
+ flags: file.versionedReadFlagsToMsg(flags)
1326
+ }))
1327
+ .then(file.vReadBytes.unpackReply);
1311
1328
  }
1312
1329
  vReadBytes.makeCaller = makeCaller;
1313
1330
  })(vReadBytes || (vReadBytes = {}));
@@ -1316,7 +1333,7 @@ var vGetByteSource;
1316
1333
  (function (vGetByteSource) {
1317
1334
  function wrapService(fn, expServices) {
1318
1335
  return buf => {
1319
- const { path } = reqWithPathType.unpack(buf);
1336
+ const { path, flags } = unpackRequestWithPathAndFlags(buf);
1320
1337
  const promise = fn(path)
1321
1338
  .then(({ version, src }) => {
1322
1339
  const ref = (0, bytes_1.exposeSrcService)(src, expServices);
@@ -1328,8 +1345,8 @@ var vGetByteSource;
1328
1345
  vGetByteSource.wrapService = wrapService;
1329
1346
  function makeCaller(caller, objPath) {
1330
1347
  const ipcPath = objPath.concat('getByteSource');
1331
- return path => caller
1332
- .startPromiseCall(ipcPath, reqWithPathType.pack({ path }))
1348
+ return (path, flags) => caller
1349
+ .startPromiseCall(ipcPath, packRequestWithPathAndFlags(path, flags))
1333
1350
  .then(buf => {
1334
1351
  const { version: v, src } = file.vGetByteSource.replyType.unpack(buf);
1335
1352
  return { version: (0, protobuf_msg_1.fixInt)(v), src: (0, bytes_1.makeSrcCaller)(caller, src) };
@@ -6,6 +6,7 @@ export interface StorageException extends web3n.RuntimeException {
6
6
  objId?: ObjId;
7
7
  version?: number;
8
8
  objNotFound?: true;
9
+ objVersionNotFound?: true;
9
10
  objExists?: true;
10
11
  concurrentTransaction?: true;
11
12
  unknownTransaction?: true;
@@ -13,8 +14,19 @@ export interface StorageException extends web3n.RuntimeException {
13
14
  currentVersion?: number;
14
15
  storageIsClosed?: true;
15
16
  }
17
+ export interface StorageExceptionFlags {
18
+ remoteStorage?: true;
19
+ objNotFound?: true;
20
+ objVersionNotFound?: true;
21
+ objExists?: true;
22
+ concurrentTransaction?: true;
23
+ unknownTransaction?: true;
24
+ versionMismatch?: true;
25
+ storageIsClosed?: true;
26
+ }
16
27
  export declare function makeStorageException(fields: Partial<StorageException>): StorageException;
17
- export declare function makeObjNotFoundExc(objId: ObjId, version?: number, remoteStorage?: true): StorageException;
28
+ export declare function makeObjNotFoundExc(objId: ObjId, remoteStorage?: true): StorageException;
29
+ export declare function makeObjVersionNotFoundExc(objId: ObjId, version: number, remoteStorage?: true): StorageException;
18
30
  export declare function makeObjExistsExc(objId: ObjId, version?: number, remoteStorage?: true): StorageException;
19
31
  export declare function makeConcurrentTransExc(objId: ObjId): StorageException;
20
32
  export declare function makeUnknownTransactionExc(objId: ObjId): StorageException;
@@ -16,7 +16,7 @@
16
16
  this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.makeFSSyncException = exports.makeStorageIsClosedExc = exports.makeVersionMismatchExc = exports.makeUnknownTransactionExc = exports.makeConcurrentTransExc = exports.makeObjExistsExc = exports.makeObjNotFoundExc = exports.makeStorageException = void 0;
19
+ exports.makeFSSyncException = exports.makeStorageIsClosedExc = exports.makeVersionMismatchExc = exports.makeUnknownTransactionExc = exports.makeConcurrentTransExc = exports.makeObjExistsExc = exports.makeObjVersionNotFoundExc = exports.makeObjNotFoundExc = exports.makeStorageException = void 0;
20
20
  function makeStorageException(fields) {
21
21
  const exc = {
22
22
  runtimeException: true,
@@ -28,12 +28,18 @@ function makeStorageException(fields) {
28
28
  return exc;
29
29
  }
30
30
  exports.makeStorageException = makeStorageException;
31
- function makeObjNotFoundExc(objId, version, remoteStorage) {
31
+ function makeObjNotFoundExc(objId, remoteStorage) {
32
32
  return makeStorageException({
33
- objId, version, objNotFound: true, remoteStorage
33
+ objId, objNotFound: true, remoteStorage
34
34
  });
35
35
  }
36
36
  exports.makeObjNotFoundExc = makeObjNotFoundExc;
37
+ function makeObjVersionNotFoundExc(objId, version, remoteStorage) {
38
+ return makeStorageException({
39
+ objId, version, objVersionNotFound: true, remoteStorage
40
+ });
41
+ }
42
+ exports.makeObjVersionNotFoundExc = makeObjVersionNotFoundExc;
37
43
  function makeObjExistsExc(objId, version, remoteStorage) {
38
44
  return makeStorageException({
39
45
  objId, version, objExists: true, remoteStorage
@@ -11,7 +11,12 @@ export declare type FirstSaveReqOpts = api.PutObjFirstQueryOpts;
11
11
  export declare type FollowingSaveReqOpts = api.PutObjSecondQueryOpts;
12
12
  export declare class StorageOwner extends ServiceUser {
13
13
  maxChunkSize: number | undefined;
14
- constructor(user: string, getSigner: IGetMailerIdSigner, mainUrlGetter: () => Promise<string>, net: NetClient);
14
+ private constructor();
15
+ static make(user: string, getSigner: IGetMailerIdSigner, mainUrlGetter: () => Promise<string>, net: NetClient): StorageOwner;
16
+ static makeBeforeMidSetup(user: string, mainUrlGetter: () => Promise<string>, net: NetClient): {
17
+ remote: StorageOwner;
18
+ setMid: (getSigner: IGetMailerIdSigner) => void;
19
+ };
15
20
  getKeyDerivParams(): Promise<keyGen.ScryptGenParams>;
16
21
  private setSessionParams;
17
22
  /**
@@ -63,7 +68,6 @@ export declare class StorageOwner extends ServiceUser {
63
68
  * @param bytes is an object with header, diff and segs bytes to upload
64
69
  */
65
70
  saveNewObjVersion(objId: ObjId, fstReq: {
66
- create?: true;
67
71
  ver: number;
68
72
  last?: true;
69
73
  } | undefined, followReq: {
@@ -28,23 +28,39 @@ const keyGen = require("../key-derivation");
28
28
  const exceptions_1 = require("./exceptions");
29
29
  const ws_ipc_1 = require("../../lib-common/ipc/ws-ipc");
30
30
  const assert_1 = require("../../lib-common/assert");
31
+ function toInitServiceUriGetter(net, mainUrlGetter) {
32
+ return async () => {
33
+ const serviceUrl = await mainUrlGetter();
34
+ const info = await (0, service_locator_1.storageInfoAt)(net, serviceUrl);
35
+ if (!info.owner) {
36
+ throw new Error(`Missing owner service url in 3NStorage information at ${serviceUrl}`);
37
+ }
38
+ return info.owner;
39
+ };
40
+ }
31
41
  class StorageOwner extends user_with_mid_session_1.ServiceUser {
32
- constructor(user, getSigner, mainUrlGetter, net) {
42
+ constructor(user, getSigner, getInitServiceURI, net) {
33
43
  super(user, {
34
44
  login: api.midLogin.MID_URL_PART,
35
45
  logout: api.closeSession.URL_END,
36
46
  canBeRedirected: true
37
- }, getSigner, async () => {
38
- const serviceUrl = await mainUrlGetter();
39
- const info = await (0, service_locator_1.storageInfoAt)(this.net, serviceUrl);
40
- if (!info.owner) {
41
- throw new Error(`Missing owner service url in 3NStorage information at ${serviceUrl}`);
42
- }
43
- return info.owner;
44
- }, net);
47
+ }, getSigner, getInitServiceURI, net);
45
48
  this.maxChunkSize = undefined;
46
49
  Object.seal(this);
47
50
  }
51
+ static make(user, getSigner, mainUrlGetter, net) {
52
+ const srvUriGetter = toInitServiceUriGetter(net, mainUrlGetter);
53
+ const remote = new StorageOwner(user, getSigner, srvUriGetter, net);
54
+ return remote;
55
+ }
56
+ static makeBeforeMidSetup(user, mainUrlGetter, net) {
57
+ const srvUriGetter = toInitServiceUriGetter(net, mainUrlGetter);
58
+ const remote = new StorageOwner(user, undefined, srvUriGetter, net);
59
+ return {
60
+ remote,
61
+ setMid: getSigner => remote.setGetterOfSigner(getSigner)
62
+ };
63
+ }
48
64
  async getKeyDerivParams() {
49
65
  const rep = await this.doBodylessSessionRequest({
50
66
  appPath: api.keyDerivParams.URL_END,
@@ -144,7 +160,7 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
144
160
  };
145
161
  }
146
162
  else if (rep.status === api.currentObj.SC.unknownObj) {
147
- throw (0, exceptions_1.makeObjNotFoundExc)(objId, undefined, true);
163
+ throw (0, exceptions_1.makeObjNotFoundExc)(objId, true);
148
164
  }
149
165
  else {
150
166
  throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
@@ -179,7 +195,7 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
179
195
  return rep.data;
180
196
  }
181
197
  else if (rep.status === api.currentObj.SC.unknownObj) {
182
- throw (0, exceptions_1.makeObjNotFoundExc)(objId, undefined, true);
198
+ throw (0, exceptions_1.makeObjNotFoundExc)(objId, true);
183
199
  }
184
200
  else {
185
201
  throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
@@ -199,9 +215,9 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
199
215
  let appPath;
200
216
  if (fstReq) {
201
217
  (0, assert_1.assert)(!!header);
202
- const { create, ver, last } = fstReq;
218
+ const { ver, last } = fstReq;
203
219
  const reqOpts = {
204
- create, ver, last,
220
+ ver, last,
205
221
  header: header.length,
206
222
  diff: (diff ? diff.length : undefined)
207
223
  };
@@ -246,7 +262,7 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
246
262
  throw (0, exceptions_1.makeObjExistsExc)(objId, undefined, true);
247
263
  }
248
264
  else if (rep.status === api.currentObj.SC.unknownObj) {
249
- throw (0, exceptions_1.makeObjNotFoundExc)(objId, undefined, true);
265
+ throw (0, exceptions_1.makeObjNotFoundExc)(objId, true);
250
266
  }
251
267
  else if (rep.status === api.currentObj.SC.concurrentTransaction) {
252
268
  throw (0, exceptions_1.makeConcurrentTransExc)(objId);
@@ -276,10 +292,10 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
276
292
  return;
277
293
  }
278
294
  else if (rep.status === api.currentObj.SC.unknownObj) {
279
- throw (0, exceptions_1.makeObjNotFoundExc)(objId, undefined, true);
295
+ throw (0, exceptions_1.makeObjNotFoundExc)(objId, true);
280
296
  }
281
297
  else if (rep.status === api.currentObj.SC.unknownObjVer) {
282
- throw (0, exceptions_1.makeObjNotFoundExc)(objId, currentVer, true);
298
+ throw (0, exceptions_1.makeObjVersionNotFoundExc)(objId, currentVer, true);
283
299
  }
284
300
  else {
285
301
  throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
@@ -298,7 +314,7 @@ class StorageOwner extends user_with_mid_session_1.ServiceUser {
298
314
  return rep.data;
299
315
  }
300
316
  else if (rep.status === api.objStatus.SC.unknownObj) {
301
- throw (0, exceptions_1.makeObjNotFoundExc)(objId, undefined, true);
317
+ throw (0, exceptions_1.makeObjNotFoundExc)(objId, true);
302
318
  }
303
319
  else {
304
320
  throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
@@ -13,7 +13,8 @@
13
13
  See the GNU General Public License for more details.
14
14
 
15
15
  You should have received a copy of the GNU General Public License along with
16
- this program. If not, see <http://www.gnu.org/licenses/>. */
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
17
18
  Object.defineProperty(exports, "__esModule", { value: true });
18
19
  exports.JsonFileProc = void 0;
19
20
  const rxjs_1 = require("rxjs");
@@ -0,0 +1 @@
1
+ export declare function appendArray<T>(arr: T[], elems: T[] | T | undefined): T[];
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (C) 2022 3NSoft Inc.
4
+
5
+ This program is free software: you can redistribute it and/or modify it under
6
+ the terms of the GNU General Public License as published by the Free Software
7
+ Foundation, either version 3 of the License, or (at your option) any later
8
+ version.
9
+
10
+ This program is distributed in the hope that it will be useful, but
11
+ WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
+ See the GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License along with
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.appendArray = void 0;
20
+ function appendArray(arr, elems) {
21
+ if (elems !== undefined) {
22
+ if (Array.isArray(elems)) {
23
+ arr.push(...elems);
24
+ }
25
+ else {
26
+ arr.push(elems);
27
+ }
28
+ }
29
+ return arr;
30
+ }
31
+ exports.appendArray = appendArray;
32
+ Object.freeze(exports);