core-3nweb-client-lib 0.27.3 → 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 (45) hide show
  1. package/build/api-defs/files.d.ts +52 -19
  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/index.js +1 -1
  9. package/build/core/asmail/index.d.ts +1 -1
  10. package/build/core/asmail/index.js +2 -2
  11. package/build/core/asmail/keyring/correspondent-keys.d.ts +2 -2
  12. package/build/core/asmail/keyring/correspondent-keys.js +1 -1
  13. package/build/core/asmail/keyring/index.d.ts +9 -29
  14. package/build/core/asmail/keyring/index.js +82 -69
  15. package/build/core/index.js +1 -2
  16. package/build/core/sign-in.js +1 -1
  17. package/build/core/storage/synced/obj-files.d.ts +2 -0
  18. package/build/core/storage/synced/obj-files.js +18 -1
  19. package/build/core/storage/synced/obj-status.d.ts +1 -0
  20. package/build/core/storage/synced/obj-status.js +10 -0
  21. package/build/core/storage/synced/storage.js +4 -21
  22. package/build/ipc-via-protobuf/file.d.ts +7 -0
  23. package/build/ipc-via-protobuf/file.js +60 -27
  24. package/build/ipc-via-protobuf/fs.js +55 -38
  25. package/build/lib-client/3nstorage/xsp-fs/file-node.d.ts +5 -10
  26. package/build/lib-client/3nstorage/xsp-fs/file-node.js +43 -45
  27. package/build/lib-client/3nstorage/xsp-fs/file.d.ts +7 -6
  28. package/build/lib-client/3nstorage/xsp-fs/file.js +12 -18
  29. package/build/lib-client/3nstorage/xsp-fs/folder-node.d.ts +5 -0
  30. package/build/lib-client/3nstorage/xsp-fs/folder-node.js +7 -1
  31. package/build/lib-client/3nstorage/xsp-fs/fs.d.ts +18 -17
  32. package/build/lib-client/3nstorage/xsp-fs/fs.js +17 -18
  33. package/build/lib-client/3nstorage/xsp-fs/node-in-fs.d.ts +11 -2
  34. package/build/lib-client/3nstorage/xsp-fs/node-in-fs.js +56 -5
  35. package/build/lib-client/cryptor/cryptor-wasm.js +1 -1
  36. package/build/lib-client/cryptor/cryptor.wasm +0 -0
  37. package/build/lib-client/objs-on-disk/obj-on-disk.d.ts +5 -2
  38. package/build/lib-client/objs-on-disk/obj-on-disk.js +16 -1
  39. package/build/lib-common/objs-on-disk/file-layout.js +1 -1
  40. package/build/protos/asmail.proto.js +5943 -4348
  41. package/build/protos/file.proto.js +874 -0
  42. package/build/protos/fs.proto.js +7014 -5419
  43. package/package.json +1 -1
  44. package/protos/file.proto +23 -7
  45. package/protos/fs.proto +27 -13
@@ -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) };
@@ -11,6 +11,7 @@ import { NodePersistance } from './node-persistence';
11
11
  declare type FileByteSource = web3n.files.FileByteSource;
12
12
  declare type FileByteSink = web3n.files.FileByteSink;
13
13
  declare type XAttrsChanges = web3n.files.XAttrsChanges;
14
+ declare type VersionedReadFlags = web3n.files.VersionedReadFlags;
14
15
  interface FileAttrs {
15
16
  attrs: CommonAttrs;
16
17
  size: number;
@@ -19,14 +20,8 @@ interface FileAttrs {
19
20
  declare class FilePersistance extends NodePersistance {
20
21
  constructor(zNonce: Uint8Array, key: Uint8Array, cryptor: AsyncSBoxCryptor);
21
22
  getAttrs(objSrc: ObjSource): Promise<FileAttrs>;
22
- getFileSource(objSrc: ObjSource, getAttrs?: boolean): Promise<{
23
- src: FileByteSource;
24
- fileAttrs?: FileAttrs;
25
- }>;
26
- readBytes(objSrc: ObjSource, start: number | undefined, end: number | undefined, getAttrs?: boolean): Promise<{
27
- bytes?: Uint8Array;
28
- fileAttrs?: FileAttrs;
29
- }>;
23
+ getFileSource(objSrc: ObjSource): Promise<FileByteSource>;
24
+ readBytes(objSrc: ObjSource, start: number | undefined, end: number | undefined): Promise<Uint8Array | undefined>;
30
25
  saveBytes(bytes: Uint8Array | Uint8Array[], version: number, attrs: CommonAttrs, xattrs: XAttrs | undefined): Promise<Subscribe>;
31
26
  getFileSink(version: number, attrs: CommonAttrs, xattrs: XAttrs | undefined, base: ObjSource | undefined): Promise<{
32
27
  sinkPromise: Promise<FileByteSink>;
@@ -48,11 +43,11 @@ export declare class FileNode extends NodeInFS<FilePersistance> {
48
43
  protected setCurrentStateFrom(src: ObjSource): Promise<void>;
49
44
  private setUpdatedState;
50
45
  get size(): number;
51
- readSrc(): Promise<{
46
+ readSrc(flags: VersionedReadFlags | undefined): Promise<{
52
47
  src: FileByteSource;
53
48
  version: number;
54
49
  }>;
55
- readBytes(start: number | undefined, end: number | undefined): Promise<{
50
+ readBytes(start: number | undefined, end: number | undefined, flags: VersionedReadFlags | undefined): Promise<{
56
51
  bytes: Uint8Array | undefined;
57
52
  version: number;
58
53
  }>;
@@ -43,14 +43,11 @@ class FilePersistance extends node_persistence_1.NodePersistance {
43
43
  const payload = await super.readonlyPayload(objSrc);
44
44
  return await fileAttrsFrom(payload);
45
45
  }
46
- async getFileSource(objSrc, getAttrs = false) {
46
+ async getFileSource(objSrc) {
47
47
  const payload = await this.readonlyPayload(objSrc);
48
- const src = payload.makeFileByteSource();
49
- return (getAttrs ?
50
- { src, fileAttrs: await fileAttrsFrom(payload) } :
51
- { src });
48
+ return payload.makeFileByteSource();
52
49
  }
53
- async readBytes(objSrc, start, end, getAttrs = false) {
50
+ async readBytes(objSrc, start, end) {
54
51
  if ((typeof start === 'number') && (start < 0)) {
55
52
  throw new Error(`Parameter start has bad value: ${start}`);
56
53
  }
@@ -64,22 +61,18 @@ class FilePersistance extends node_persistence_1.NodePersistance {
64
61
  end = size;
65
62
  }
66
63
  else if (start >= size) {
67
- return (getAttrs ? { fileAttrs: await fileAttrsFrom(payload) } : {});
64
+ return;
68
65
  }
69
66
  if (typeof end === 'number') {
70
67
  end = Math.min(size, end);
71
68
  if (end <= start) {
72
- return (getAttrs ?
73
- { fileAttrs: await fileAttrsFrom(payload) } : {});
69
+ return;
74
70
  }
75
71
  }
76
72
  else {
77
73
  end = size;
78
74
  }
79
- const bytes = await payload.readSomeContentBytes(start, end);
80
- return (getAttrs ?
81
- { bytes, fileAttrs: await fileAttrsFrom(payload) } :
82
- { bytes });
75
+ return await payload.readSomeContentBytes(start, end);
83
76
  }
84
77
  async saveBytes(bytes, version, attrs, xattrs) {
85
78
  return super.writeWhole(bytes, version, attrs, xattrs);
@@ -139,45 +132,50 @@ class FileNode extends node_in_fs_1.NodeInFS {
139
132
  get size() {
140
133
  return this.fileSize;
141
134
  }
142
- async readSrc() {
143
- const objSrc = await this.storage.getObjSrc(this.objId);
144
- if ((this.storage.type === 'synced') || (this.storage.type === 'local')) {
145
- const version = objSrc.version;
146
- if (this.version < version) {
147
- const { src, fileAttrs } = await this.crypto.getFileSource(objSrc, true);
148
- this.setUpdatedState(version, fileAttrs);
149
- return { src, version };
150
- }
151
- else {
152
- const { src } = await this.crypto.getFileSource(objSrc);
153
- return { src, version };
154
- }
135
+ async readSrc(flags) {
136
+ const objSrc = await this.getObjSrcOfVersion(flags);
137
+ let version;
138
+ if ((this.storage.type === 'synced')
139
+ || (this.storage.type === 'local')
140
+ || (this.storage.type === 'share')) {
141
+ version = objSrc.version;
155
142
  }
156
143
  else {
157
- const { src } = await this.crypto.getFileSource(objSrc);
158
- // unversioned storage passes undefined version
159
- return { src, version: undefined };
144
+ version = undefined;
160
145
  }
146
+ const src = await this.crypto.getFileSource(objSrc);
147
+ return { src, version };
161
148
  }
162
- async readBytes(start, end) {
163
- const objSrc = await this.storage.getObjSrc(this.objId);
164
- if ((this.storage.type === 'synced') || (this.storage.type === 'local')) {
165
- const version = objSrc.version;
166
- if (this.version < version) {
167
- const { bytes, fileAttrs } = await this.crypto.readBytes(objSrc, start, end, true);
168
- this.setUpdatedState(version, fileAttrs);
169
- return { bytes, version };
170
- }
171
- else {
172
- const { bytes } = await this.crypto.readBytes(objSrc, start, end);
173
- return { bytes, version };
174
- }
149
+ async readBytes(start, end, flags) {
150
+ const objSrc = await this.getObjSrcOfVersion(flags);
151
+ let version;
152
+ if ((this.storage.type === 'synced')
153
+ || (this.storage.type === 'local')
154
+ || (this.storage.type === 'share')) {
155
+ version = objSrc.version;
175
156
  }
176
157
  else {
177
- const { bytes } = await this.crypto.readBytes(objSrc, start, end);
178
- // unversioned storage passes undefined version
179
- return { bytes, version: undefined };
158
+ version = undefined;
180
159
  }
160
+ const bytes = await this.crypto.readBytes(objSrc, start, end);
161
+ return { bytes, version };
162
+ // if ((this.storage.type === 'synced') || (this.storage.type === 'local')) {
163
+ // const version = objSrc.version;
164
+ // if (this.version < version) {
165
+ // const {
166
+ // bytes, fileAttrs
167
+ // } = await this.crypto.readBytes(objSrc, start, end, true);
168
+ // // this.setUpdatedState(version, fileAttrs!);
169
+ // return { bytes, version };
170
+ // } else {
171
+ // const { bytes } = await this.crypto.readBytes(objSrc, start, end);
172
+ // return { bytes, version };
173
+ // }
174
+ // } else {
175
+ // const { bytes } = await this.crypto.readBytes(objSrc, start, end);
176
+ // // unversioned storage passes undefined version
177
+ // return { bytes, version: (undefined as any) };
178
+ // }
181
179
  }
182
180
  async writeSink(truncate, currentVersion, changes) {
183
181
  const deferredSink = (0, deferred_1.defer)();
@@ -15,6 +15,7 @@ declare type SyncStatus = web3n.files.SyncStatus;
15
15
  declare type WritableFileVersionedAPI = web3n.files.WritableFileVersionedAPI;
16
16
  declare type OptionsToAdopteRemote = web3n.files.OptionsToAdopteRemote;
17
17
  declare type OptionsToUploadLocal = web3n.files.OptionsToUploadLocal;
18
+ declare type VersionedReadFlags = web3n.files.VersionedReadFlags;
18
19
  export declare class FileObject implements WritableFile, Linkable {
19
20
  name: string;
20
21
  isNew: boolean;
@@ -54,11 +55,11 @@ declare class V implements WritableFileVersionedAPI, N {
54
55
  getNode(): Promise<FileNode>;
55
56
  ensureIsWritable(): void;
56
57
  updateXAttrs(changes: XAttrsChanges): Promise<number>;
57
- getXAttr(xaName: string): Promise<{
58
+ getXAttr(xaName: string, flags?: VersionedReadFlags): Promise<{
58
59
  attr: any;
59
60
  version: number;
60
61
  }>;
61
- listXAttrs(): Promise<{
62
+ listXAttrs(flags?: VersionedReadFlags): Promise<{
62
63
  lst: string[];
63
64
  version: number;
64
65
  }>;
@@ -67,23 +68,23 @@ declare class V implements WritableFileVersionedAPI, N {
67
68
  sink: FileByteSink;
68
69
  version: number;
69
70
  }>;
70
- getByteSource(): Promise<{
71
+ getByteSource(flags?: VersionedReadFlags): Promise<{
71
72
  src: FileByteSource;
72
73
  version: number;
73
74
  }>;
74
75
  writeBytes(bytes: Uint8Array): Promise<number>;
75
76
  writeTxt(txt: string): Promise<number>;
76
77
  writeJSON(json: any): Promise<number>;
77
- readBytes(start?: number, end?: number): Promise<{
78
+ readBytes(start?: number, end?: number, flags?: VersionedReadFlags): Promise<{
78
79
  bytes: Uint8Array | undefined;
79
80
  version: number;
80
81
  }>;
81
- readTxt(): Promise<{
82
+ readTxt(flags?: VersionedReadFlags): Promise<{
82
83
  txt: string;
83
84
  version: number;
84
85
  }>;
85
86
  copy(file: File): Promise<number>;
86
- readJSON<T>(): Promise<{
87
+ readJSON<T>(flags?: VersionedReadFlags): Promise<{
87
88
  json: T;
88
89
  version: number;
89
90
  }>;
@@ -148,19 +148,13 @@ class V {
148
148
  const node = await this.getNode();
149
149
  return node.updateXAttrs(changes);
150
150
  }
151
- async getXAttr(xaName) {
151
+ async getXAttr(xaName, flags) {
152
152
  const node = await this.getNode();
153
- return {
154
- attr: node.getXAttr(xaName),
155
- version: node.version
156
- };
153
+ return await node.getXAttr(xaName, flags);
157
154
  }
158
- async listXAttrs() {
155
+ async listXAttrs(flags) {
159
156
  const node = await this.getNode();
160
- return {
161
- lst: node.listXAttrs(),
162
- version: node.version
163
- };
157
+ return await node.listXAttrs(flags);
164
158
  }
165
159
  async getLinkParams() {
166
160
  if (!this.node) {
@@ -176,11 +170,11 @@ class V {
176
170
  const node = await this.getNode();
177
171
  return node.writeSink(truncate, currentVersion);
178
172
  }
179
- async getByteSource() {
173
+ async getByteSource(flags) {
180
174
  if (!this.node) {
181
175
  throw (0, file_1.makeFileException)('notFound', this.name);
182
176
  }
183
- return this.node.readSrc();
177
+ return this.node.readSrc(flags);
184
178
  }
185
179
  async writeBytes(bytes) {
186
180
  this.ensureIsWritable();
@@ -194,14 +188,14 @@ class V {
194
188
  writeJSON(json) {
195
189
  return this.writeTxt(JSON.stringify(json));
196
190
  }
197
- async readBytes(start, end) {
191
+ async readBytes(start, end, flags) {
198
192
  if (!this.node) {
199
193
  throw (0, file_1.makeFileException)('notFound', this.name);
200
194
  }
201
- return await this.node.readBytes(start, end);
195
+ return await this.node.readBytes(start, end, flags);
202
196
  }
203
- async readTxt() {
204
- const { bytes, version } = await this.readBytes();
197
+ async readTxt(flags) {
198
+ const { bytes, version } = await this.readBytes(undefined, undefined, flags);
205
199
  const txt = (bytes ? buffer_utils_1.utf8.open(bytes) : '');
206
200
  return { txt, version };
207
201
  }
@@ -212,8 +206,8 @@ class V {
212
206
  await (0, pipe_1.pipe)(src, sink);
213
207
  return version;
214
208
  }
215
- async readJSON() {
216
- const { txt, version } = await this.readTxt();
209
+ async readJSON(flags) {
210
+ const { txt, version } = await this.readTxt(flags);
217
211
  const json = JSON.parse(txt);
218
212
  return { json, version };
219
213
  }
@@ -12,6 +12,7 @@ declare type FolderDiff = web3n.files.FolderDiff;
12
12
  declare type OptionsToAdopteRemote = web3n.files.OptionsToAdopteRemote;
13
13
  declare type OptionsToAdoptRemoteItem = web3n.files.OptionsToAdoptRemoteItem;
14
14
  declare type OptionsToUploadLocal = web3n.files.OptionsToUploadLocal;
15
+ declare type VersionedReadFlags = web3n.files.VersionedReadFlags;
15
16
  export interface NodeInfo {
16
17
  /**
17
18
  * This is a usual file name.
@@ -80,6 +81,10 @@ export declare class FolderNode extends NodeInFS<FolderPersistance> {
80
81
  lst: ListingEntry[];
81
82
  version: number;
82
83
  };
84
+ listNonCurrent(flags: VersionedReadFlags): Promise<{
85
+ lst: ListingEntry[];
86
+ version: number;
87
+ }>;
83
88
  childExistsInSyncedVersion(childObjId: string): Promise<boolean>;
84
89
  getNodeInfo(name: string, undefOnMissing?: boolean): NodeInfo | undefined;
85
90
  hasChild(childName: string, throwIfMissing?: boolean): boolean;
@@ -224,6 +224,13 @@ class FolderNode extends node_in_fs_1.NodeInFS {
224
224
  .map(nodeInfoToListingEntry);
225
225
  return { lst, version: this.version };
226
226
  }
227
+ async listNonCurrent(flags) {
228
+ const src = await this.getObjSrcOfVersion(flags);
229
+ const { folderInfo } = await this.crypto.read(src);
230
+ const lst = Object.values(folderInfo)
231
+ .map(nodeInfoToListingEntry);
232
+ return { lst, version: src.version };
233
+ }
227
234
  async childExistsInSyncedVersion(childObjId) {
228
235
  const { state, synced } = await this.syncStatus();
229
236
  if (state === 'synced') {
@@ -783,7 +790,6 @@ class FolderNode extends node_in_fs_1.NodeInFS {
783
790
  }
784
791
  }
785
792
  async uploadRemovalOf(removedNodes) {
786
- const storage = this.syncedStorage();
787
793
  const rmObjs = [];
788
794
  for (const node of removedNodes) {
789
795
  (0, for_arrays_1.appendArray)(rmObjs, await this.listRemovedInTreeToUploadRm(node));
@@ -21,6 +21,7 @@ declare type FSCollection = web3n.files.FSCollection;
21
21
  declare type FileFlags = web3n.files.FileFlags;
22
22
  declare type FileByteSource = web3n.files.FileByteSource;
23
23
  declare type FileByteSink = web3n.files.FileByteSink;
24
+ declare type VersionedReadFlags = web3n.files.VersionedReadFlags;
24
25
  declare type XAttrsChanges = web3n.files.XAttrsChanges;
25
26
  declare type WritableFSSyncAPI = web3n.files.WritableFSSyncAPI;
26
27
  declare type SyncStatus = web3n.files.SyncStatus;
@@ -39,7 +40,7 @@ export declare class XspFS implements WritableFS {
39
40
  private constructor();
40
41
  private storage;
41
42
  readonlySubRoot(path: string): Promise<ReadonlyFS>;
42
- writableSubRoot(path: string, flags?: web3n.files.VersionedFileFlags): Promise<WritableFS>;
43
+ writableSubRoot(path: string, flags?: web3n.files.VersionedFileWriteFlags): Promise<WritableFS>;
43
44
  /**
44
45
  * This creates in a root object in a given storage, returning fs object
45
46
  * representing created root.
@@ -88,7 +89,7 @@ export declare class XspFS implements WritableFS {
88
89
  watchFile(path: string, observer: Observer<FileEvent>): () => void;
89
90
  watchTree(path: string, depth: number | undefined, observer: Observer<FolderEvent | FileEvent>): () => void;
90
91
  readonlyFile(path: string): Promise<ReadonlyFile>;
91
- writableFile(path: string, flags?: web3n.files.VersionedFileFlags): Promise<WritableFile>;
92
+ writableFile(path: string, flags?: web3n.files.VersionedFileWriteFlags): Promise<WritableFile>;
92
93
  copyFile(src: string, dst: string, overwrite?: boolean): Promise<void>;
93
94
  saveFile(file: File, dst: string, overwrite?: boolean): Promise<void>;
94
95
  listFolder(folder: string): Promise<ListingEntry[]>;
@@ -96,10 +97,10 @@ export declare class XspFS implements WritableFS {
96
97
  readTxtFile(path: string): Promise<string>;
97
98
  readBytes(path: string, start?: number, end?: number): Promise<Uint8Array | undefined>;
98
99
  getByteSource(path: string): Promise<FileByteSource>;
99
- writeJSONFile(path: string, json: any, flags?: web3n.files.VersionedFileFlags): Promise<void>;
100
- writeTxtFile(path: string, txt: string, flags?: web3n.files.VersionedFileFlags): Promise<void>;
101
- writeBytes(path: string, bytes: Uint8Array, flags?: web3n.files.VersionedFileFlags): Promise<void>;
102
- getByteSink(path: string, flags?: web3n.files.VersionedFileFlags): Promise<FileByteSink>;
100
+ writeJSONFile(path: string, json: any, flags?: web3n.files.VersionedFileWriteFlags): Promise<void>;
101
+ writeTxtFile(path: string, txt: string, flags?: web3n.files.VersionedFileWriteFlags): Promise<void>;
102
+ writeBytes(path: string, bytes: Uint8Array, flags?: web3n.files.VersionedFileWriteFlags): Promise<void>;
103
+ getByteSink(path: string, flags?: web3n.files.VersionedFileWriteFlags): Promise<FileByteSink>;
103
104
  }
104
105
  interface N {
105
106
  get(path: string): Promise<NodeInFS<any>>;
@@ -121,38 +122,38 @@ declare class V implements WritableFSVersionedAPI, N {
121
122
  get(path: string): Promise<NodeInFS<any>>;
122
123
  ensureIsWritable(): void;
123
124
  updateXAttrs(path: string, changes: XAttrsChanges): Promise<number>;
124
- getXAttr(path: string, xaName: string): Promise<{
125
+ getXAttr(path: string, xaName: string, flags?: VersionedReadFlags): Promise<{
125
126
  attr: any;
126
127
  version: number;
127
128
  }>;
128
- listXAttrs(path: string): Promise<{
129
+ listXAttrs(path: string, flags?: VersionedReadFlags): Promise<{
129
130
  lst: string[];
130
131
  version: number;
131
132
  }>;
132
- listFolder(path: string): Promise<{
133
+ listFolder(path: string, flags?: VersionedReadFlags): Promise<{
133
134
  lst: ListingEntry[];
134
135
  version: number;
135
136
  }>;
136
- writeBytes(path: string, bytes: Uint8Array, flags?: web3n.files.VersionedFileFlags): Promise<number>;
137
- readBytes(path: string, start?: number, end?: number): Promise<{
137
+ writeBytes(path: string, bytes: Uint8Array, flags?: web3n.files.VersionedFileWriteFlags): Promise<number>;
138
+ readBytes(path: string, start?: number, end?: number, flags?: VersionedReadFlags): Promise<{
138
139
  bytes: Uint8Array | undefined;
139
140
  version: number;
140
141
  }>;
141
- writeTxtFile(path: string, txt: string, flags?: web3n.files.VersionedFileFlags): Promise<number>;
142
- readTxtFile(path: string): Promise<{
142
+ writeTxtFile(path: string, txt: string, flags?: web3n.files.VersionedFileWriteFlags): Promise<number>;
143
+ readTxtFile(path: string, flags?: VersionedReadFlags): Promise<{
143
144
  txt: string;
144
145
  version: number;
145
146
  }>;
146
- writeJSONFile(path: string, json: any, flags?: web3n.files.VersionedFileFlags): Promise<number>;
147
- readJSONFile<T>(path: string): Promise<{
147
+ writeJSONFile(path: string, json: any, flags?: web3n.files.VersionedFileWriteFlags): Promise<number>;
148
+ readJSONFile<T>(path: string, flags?: VersionedReadFlags): Promise<{
148
149
  json: T;
149
150
  version: number;
150
151
  }>;
151
- getByteSink(path: string, flags?: web3n.files.VersionedFileFlags): Promise<{
152
+ getByteSink(path: string, flags?: web3n.files.VersionedFileWriteFlags): Promise<{
152
153
  sink: FileByteSink;
153
154
  version: number;
154
155
  }>;
155
- getByteSource(path: string): Promise<{
156
+ getByteSource(path: string, flags?: VersionedReadFlags): Promise<{
156
157
  src: FileByteSource;
157
158
  version: number;
158
159
  }>;