core-3nweb-client-lib 0.20.7 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/build/api-defs/common-caps.d.ts +0 -1
  2. package/build/api-defs/files.d.ts +8 -7
  3. package/build/api-defs/startup.d.ts +0 -1
  4. package/build/core/asmail/inbox/attachments/fs.d.ts +2 -2
  5. package/build/core/asmail/inbox/attachments/fs.js +3 -2
  6. package/build/core/asmail/msg/common.d.ts +2 -2
  7. package/build/core/asmail/msg/common.js +3 -2
  8. package/build/core/asmail/msg/opener.d.ts +2 -2
  9. package/build/core/asmail/msg/opener.js +3 -2
  10. package/build/core/asmail/msg/packer.d.ts +2 -2
  11. package/build/core/asmail/msg/packer.js +7 -6
  12. package/build/core/index.d.ts +3 -3
  13. package/build/core/index.js +24 -31
  14. package/build/core/storage/index.js +2 -2
  15. package/build/core/storage/local/obj-files.js +8 -5
  16. package/build/core/storage/local/obj-status.js +4 -3
  17. package/build/core/storage/synced/obj-status.js +4 -3
  18. package/build/core-ipc/startup-caps.js +0 -3
  19. package/build/ipc-via-protobuf/bytes.js +1 -1
  20. package/build/lib-client/3nstorage/xsp-fs/attrs.d.ts +28 -0
  21. package/build/lib-client/3nstorage/xsp-fs/attrs.js +337 -0
  22. package/build/lib-client/3nstorage/xsp-fs/common.d.ts +1 -1
  23. package/build/lib-client/3nstorage/xsp-fs/common.js +3 -2
  24. package/build/lib-client/3nstorage/xsp-fs/file-node.d.ts +31 -18
  25. package/build/lib-client/3nstorage/xsp-fs/file-node.js +130 -118
  26. package/build/lib-client/3nstorage/xsp-fs/file.d.ts +0 -1
  27. package/build/lib-client/3nstorage/xsp-fs/file.js +14 -49
  28. package/build/lib-client/3nstorage/xsp-fs/folder-node-serialization.d.ts +1 -1
  29. package/build/lib-client/3nstorage/xsp-fs/folder-node-serialization.js +95 -91
  30. package/build/lib-client/3nstorage/xsp-fs/folder-node.d.ts +19 -24
  31. package/build/lib-client/3nstorage/xsp-fs/folder-node.js +133 -190
  32. package/build/lib-client/3nstorage/xsp-fs/fs.d.ts +3 -4
  33. package/build/lib-client/3nstorage/xsp-fs/fs.js +18 -21
  34. package/build/lib-client/3nstorage/xsp-fs/link-node.d.ts +13 -8
  35. package/build/lib-client/3nstorage/xsp-fs/link-node.js +46 -38
  36. package/build/lib-client/3nstorage/xsp-fs/node-in-fs.d.ts +17 -35
  37. package/build/lib-client/3nstorage/xsp-fs/node-in-fs.js +34 -127
  38. package/build/lib-client/3nstorage/xsp-fs/node-persistence.d.ts +57 -0
  39. package/build/lib-client/3nstorage/xsp-fs/node-persistence.js +182 -0
  40. package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v1.d.ts +3 -0
  41. package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v1.js +87 -0
  42. package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v2.d.ts +6 -0
  43. package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v2.js +1022 -0
  44. package/build/lib-client/cryptor/cryptor-wasm.js +1 -1
  45. package/build/lib-client/cryptor/cryptor.wasm +0 -0
  46. package/build/lib-client/local-files/device-fs.js +7 -3
  47. package/build/lib-client/objs-on-disk/file-writing-proc.js +3 -2
  48. package/build/lib-client/objs-on-disk/obj-on-disk.js +8 -7
  49. package/build/lib-common/big-endian.d.ts +0 -24
  50. package/build/lib-common/big-endian.js +16 -78
  51. package/build/lib-common/exceptions/file.js +5 -1
  52. package/build/lib-common/obj-streaming/sink-utils.d.ts +0 -4
  53. package/build/lib-common/obj-streaming/sink-utils.js +4 -70
  54. package/build/lib-common/objs-on-disk/file-layout.js +2 -1
  55. package/build/lib-common/objs-on-disk/obj-file.js +2 -2
  56. package/build/lib-common/objs-on-disk/utils.js +2 -1
  57. package/build/lib-common/objs-on-disk/v1-obj-file-format.js +2 -1
  58. package/build/lib-index.d.ts +1 -0
  59. package/build/lib-index.js +3 -0
  60. package/package.json +2 -2
  61. package/build/lib-client/files/file-attrs.d.ts +0 -76
  62. package/build/lib-client/files/file-attrs.js +0 -549
  63. package/build/lib-client/files/file-layout.d.ts +0 -56
  64. package/build/lib-client/files/file-layout.js +0 -456
  65. package/build/lib-client/files/file-sink.d.ts +0 -33
  66. package/build/lib-client/files/file-sink.js +0 -173
  67. package/build/lib-client/files/file-source.d.ts +0 -19
  68. package/build/lib-client/files/file-source.js +0 -115
@@ -30,7 +30,6 @@ declare namespace web3n.caps.common {
30
30
 
31
31
  interface AppManifest {
32
32
  appDomain: string;
33
- name: string;
34
33
  capsRequested: {
35
34
  mail?: MailCAPSetting;
36
35
  storage?: StorageCAPSetting;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright (C) 2016 - 2018, 2020 3NSoft Inc.
2
+ Copyright (C) 2016 - 2018, 2020, 2022 3NSoft Inc.
3
3
 
4
4
  This program is free software: you can redistribute it and/or modify it under
5
5
  the terms of the GNU General Public License as published by the Free Software
@@ -39,6 +39,7 @@ declare namespace web3n.files {
39
39
  notImplemented?: true;
40
40
  attrsNotEnabledInFS?: true;
41
41
  versionMismatch?: true;
42
+ isEndless?: true;
42
43
  }
43
44
 
44
45
  interface exceptionCode {
@@ -56,6 +57,7 @@ declare namespace web3n.files {
56
57
  concurrentUpdate: 'concurrent-update';
57
58
  parsingError: 'parsing-error';
58
59
  notImplemented: 'ENOSYS';
60
+ isEndless: 'is-endless';
59
61
  }
60
62
 
61
63
  /**
@@ -99,6 +101,11 @@ declare namespace web3n.files {
99
101
  */
100
102
  size?: number;
101
103
 
104
+ /**
105
+ * Flag indicating if file is an endless (unknown place of end) stream.
106
+ */
107
+ isEndless?: boolean;
108
+
102
109
  /**
103
110
  * Last content modification time stamp.
104
111
  * If such information cannot be provided, this field will be absent.
@@ -152,12 +159,6 @@ declare namespace web3n.files {
152
159
  getPosition(): Promise<number>;
153
160
  }
154
161
 
155
- interface FileSection {
156
- hasContent: boolean;
157
- ofs: number;
158
- len: number;
159
- }
160
-
161
162
  interface LayoutSection {
162
163
  src: 'new' | 'base' | 'empty';
163
164
  ofs: number;
@@ -116,7 +116,6 @@ declare namespace web3n.startup {
116
116
  interface W3N {
117
117
  signIn: startup.SignInService;
118
118
  signUp: startup.SignUpService;
119
- log?: caps.common.Logger;
120
119
  }
121
120
 
122
121
  }
@@ -1,6 +1,6 @@
1
- import { StorageGetter, FolderInfoWithAttrs } from '../../../../lib-client/3nstorage/xsp-fs/common';
1
+ import { StorageGetter, FolderInJSON } from '../../../../lib-client/3nstorage/xsp-fs/common';
2
2
  import { AsyncSBoxCryptor } from 'xsp-files';
3
3
  import { MsgOnDisk } from '../msg-on-disk';
4
4
  declare type ReadonlyFS = web3n.files.ReadonlyFS;
5
- export declare function fsForAttachments(msg: MsgOnDisk, rootJson: FolderInfoWithAttrs, storages: StorageGetter, cryptor: AsyncSBoxCryptor): ReadonlyFS;
5
+ export declare function fsForAttachments(msg: MsgOnDisk, rootJson: FolderInJSON, storages: StorageGetter, cryptor: AsyncSBoxCryptor): ReadonlyFS;
6
6
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2016 - 2019 3NSoft Inc.
3
+ Copyright (C) 2016 - 2019, 2022 3NSoft Inc.
4
4
 
5
5
  This program is free software: you can redistribute it and/or modify it under
6
6
  the terms of the GNU General Public License as published by the Free Software
@@ -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.fsForAttachments = void 0;
19
20
  const common_1 = require("../../../../lib-client/3nstorage/xsp-fs/common");
@@ -1,5 +1,5 @@
1
1
  import { JsonKeyShort } from '../../../lib-common/jwkeys';
2
- import { FolderInfoWithAttrs } from '../../../lib-client/3nstorage/xsp-fs/common';
2
+ import { FolderInJSON } from '../../../lib-client/3nstorage/xsp-fs/common';
3
3
  import * as confApi from '../../../lib-common/service-api/asmail/config';
4
4
  /**
5
5
  * Metadata for message that uses established key pair.
@@ -24,7 +24,7 @@ export interface MsgEnvelope {
24
24
  'Msg Type': string;
25
25
  'Subject'?: string;
26
26
  'Body': MainBody;
27
- 'Attachments'?: FolderInfoWithAttrs;
27
+ 'Attachments'?: FolderInJSON;
28
28
  'Flow Params': FlowParams;
29
29
  'From': string;
30
30
  'To'?: string[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2015 - 2018, 2020 3NSoft Inc.
3
+ Copyright (C) 2015 - 2018, 2020, 2022 3NSoft Inc.
4
4
 
5
5
  This program is free software: you can redistribute it and/or modify it under
6
6
  the terms of the GNU General Public License as published by the Free Software
@@ -13,6 +13,7 @@
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
  Object.freeze(exports);
@@ -1,7 +1,7 @@
1
1
  import * as confApi from '../../../lib-common/service-api/asmail/config';
2
2
  import { MsgEnvelope, MainBody, SuggestedNextKeyPair, SendingParams } from './common';
3
3
  import { AsyncSBoxCryptor, ObjSource } from 'xsp-files';
4
- import { FolderInfoWithAttrs } from '../../../lib-client/3nstorage/xsp-fs/common';
4
+ import { FolderInJSON } from '../../../lib-client/3nstorage/xsp-fs/common';
5
5
  import { MsgKeyRole } from '../keyring';
6
6
  export { SuggestedNextKeyPair } from './common';
7
7
  export declare class OpenedMsg {
@@ -18,6 +18,6 @@ export declare class OpenedMsg {
18
18
  get msgCount(): number;
19
19
  get nextSendingParams(): SendingParams | undefined;
20
20
  get introCryptoCerts(): confApi.p.initPubKey.Certs;
21
- get attachmentsJSON(): FolderInfoWithAttrs | undefined;
21
+ get attachmentsJSON(): FolderInJSON | undefined;
22
22
  }
23
23
  export declare function openMsg(msgId: string, mainObjId: string, mainObj: ObjSource, headerOfs: number, fKey: Uint8Array, cryptor: AsyncSBoxCryptor): Promise<OpenedMsg>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2015 - 2020 3NSoft Inc.
3
+ Copyright (C) 2015 - 2020, 2022 3NSoft Inc.
4
4
 
5
5
  This program is free software: you can redistribute it and/or modify it under
6
6
  the terms of the GNU General Public License as published by the Free Software
@@ -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.openMsg = exports.OpenedMsg = void 0;
19
20
  const buffer_utils_1 = require("../../../lib-common/buffer-utils");
@@ -1,6 +1,6 @@
1
1
  import { AsyncSBoxCryptor, ObjSource } from 'xsp-files';
2
2
  import * as delivApi from '../../../lib-common/service-api/asmail/delivery';
3
- import { FolderInfoWithAttrs } from '../../../lib-client/3nstorage/xsp-fs/common';
3
+ import { FolderInJSON } from '../../../lib-client/3nstorage/xsp-fs/common';
4
4
  import * as confApi from '../../../lib-common/service-api/asmail/config';
5
5
  import { MsgEnvelope, SuggestedNextKeyPair, SendingParams } from './common';
6
6
  import { Encryptor } from '../../../lib-common/async-cryptor-wrap';
@@ -24,7 +24,7 @@ export interface PackJSON {
24
24
  }
25
25
  export interface MsgObj {
26
26
  json?: any;
27
- folder?: FolderInfoWithAttrs;
27
+ folder?: FolderInJSON;
28
28
  file?: PathInMsg;
29
29
  /**
30
30
  * This is object's id in the message
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2015 - 2018, 2020 3NSoft Inc.
3
+ Copyright (C) 2015 - 2018, 2020, 2022 3NSoft Inc.
4
4
 
5
5
  This program is free software: you can redistribute it and/or modify it under
6
6
  the terms of the GNU General Public License as published by the Free Software
@@ -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.MsgPacker = void 0;
19
20
  const ecma_nacl_1 = require("ecma-nacl");
@@ -139,7 +140,7 @@ class MsgPacker {
139
140
  };
140
141
  }
141
142
  async addFolderInto(outerFolder, fName, fs, fsPath) {
142
- const folder = { nodes: {} };
143
+ const folder = { nodes: {}, ctime: outerFolder.ctime };
143
144
  const list = await fs.listFolder('.');
144
145
  for (const entry of list) {
145
146
  const fName = entry.name;
@@ -282,7 +283,7 @@ class MsgPacker {
282
283
  throw new Error(`Attachments are already set.`);
283
284
  }
284
285
  // attachments folder json to insert into main
285
- const attachments = { nodes: {} };
286
+ const attachments = { nodes: {}, ctime: Date.now() };
286
287
  // populate attachments json
287
288
  const path = { start: 'attachments', path: [] };
288
289
  if (att.container && !attachments_container_1.isContainerEmpty(att.container)) {
@@ -346,7 +347,7 @@ class MsgPacker {
346
347
  }
347
348
  const msgKeyPack = await msgKeyEnc.pack(obj.key);
348
349
  const bytes = buffer_utils_1.utf8.pack(JSON.stringify(obj.json));
349
- const segWriter = await xsp_files_1.makeSegmentsWriter(obj.key, xsp_files_1.idToHeaderNonce(obj.id), 0, { type: 'new', segSize: this.segSizeIn256bs }, random.bytes, cryptor);
350
+ const segWriter = await xsp_files_1.makeSegmentsWriter(obj.key, xsp_files_1.idToHeaderNonce(obj.id), 0, { type: 'new', segSize: this.segSizeIn256bs, payloadFormat: 1 }, random.bytes, cryptor);
350
351
  // make source that inserts message key pack into header
351
352
  return makeMainObjSrc(msgKeyPack, bytes, segWriter);
352
353
  }
@@ -412,7 +413,7 @@ class MsgPacker {
412
413
  segWriter = await xsp_files_1.makeSegmentsWriter(obj.key, xsp_files_1.idToHeaderNonce(obj.id), 0, { type: 'restart', header }, random.bytes, cryptor);
413
414
  }
414
415
  else {
415
- segWriter = await xsp_files_1.makeSegmentsWriter(obj.key, xsp_files_1.idToHeaderNonce(obj.id), 0, { type: 'new', segSize: this.segSizeIn256bs }, random.bytes, cryptor);
416
+ segWriter = await xsp_files_1.makeSegmentsWriter(obj.key, xsp_files_1.idToHeaderNonce(obj.id), 0, { type: 'new', segSize: this.segSizeIn256bs, payloadFormat: 1 }, random.bytes, cryptor);
416
417
  }
417
418
  // make object source
418
419
  let src;
@@ -2,7 +2,7 @@ import { FactoryOfFSs } from './storage';
2
2
  import { makeCryptor } from '../lib-client/cryptor/cryptor';
3
3
  import { NetClient } from '../lib-client/request-utils';
4
4
  import { ServiceLocatorMaker } from '../lib-client/service-locator';
5
- declare type AppManifest = web3n.caps.common.AppManifest;
5
+ declare type RequestedCAPs = web3n.caps.common.AppManifest['capsRequested'];
6
6
  declare type W3N = web3n.caps.common.W3N;
7
7
  export interface CoreConf {
8
8
  dataDir: string;
@@ -22,14 +22,14 @@ export declare class Core {
22
22
  private closingProc;
23
23
  private constructor();
24
24
  static make(conf: CoreConf, makeNet: () => NetClient, makeResolver: ServiceLocatorMaker, makeCryptor: makeCryptor): Core;
25
- start(logCAP?: boolean): {
25
+ start(): {
26
26
  capsForStartup: web3n.startup.W3N;
27
27
  coreInit: Promise<string>;
28
28
  };
29
29
  private initForNewUser;
30
30
  private initForExistingUserWithoutCache;
31
31
  private initForExistingUserWithCache;
32
- makeCAPsForApp(appDomain: string, manifest: AppManifest): {
32
+ makeCAPsForApp(appDomain: string, requestedCAPs: RequestedCAPs): {
33
33
  caps: W3N;
34
34
  close: () => void;
35
35
  };
@@ -30,7 +30,6 @@ const operators_1 = require("rxjs/operators");
30
30
  const app_files_1 = require("./app-files");
31
31
  const ASMAIL_APP_NAME = 'computer.3nweb.core.asmail';
32
32
  const MAILERID_APP_NAME = 'computer.3nweb.core.mailerid';
33
- const STARTUP_APP_DOMAIN = 'startup.3nweb.computer';
34
33
  class Core {
35
34
  constructor(makeNet, makeResolver, makeCryptor, appDirs, logger, signUpUrl) {
36
35
  this.makeNet = makeNet;
@@ -112,16 +111,13 @@ class Core {
112
111
  const core = new Core(makeNet, makeResolver, makeCryptor, dirs, logger, conf.signUpUrl);
113
112
  return core;
114
113
  }
115
- start(logCAP = false) {
114
+ start() {
116
115
  const signUp = new sign_up_1.SignUp(this.signUpUrl, this.cryptor.cryptor, this.makeNet, this.appDirs.getUsersOnDisk, this.logger.logError);
117
116
  const signIn = new sign_in_1.SignIn(this.cryptor.cryptor, this.initForExistingUserWithoutCache, this.initForExistingUserWithCache, this.appDirs.getUsersOnDisk, this.logger.logError);
118
117
  const capsForStartup = {
119
118
  signUp: signUp.exposedService(),
120
119
  signIn: signIn.exposedService()
121
120
  };
122
- if (logCAP) {
123
- capsForStartup.log = (type, msg, e) => this.logger.appLog(type, STARTUP_APP_DOMAIN, msg, e);
124
- }
125
121
  Object.freeze(capsForStartup);
126
122
  const initFromSignUp$ = signUp.newUser$
127
123
  .pipe(operators_1.mergeMap(this.initForNewUser, 1));
@@ -132,50 +128,47 @@ class Core {
132
128
  return { coreInit, capsForStartup };
133
129
  }
134
130
  ;
135
- makeCAPsForApp(appDomain, manifest) {
131
+ makeCAPsForApp(appDomain, requestedCAPs) {
136
132
  if (!this.isInitialized || this.closingProc) {
137
133
  throw new Error(`Core is either not yet initialized, or is already closed.`);
138
134
  }
139
- if (appDomain !== manifest.appDomain) {
140
- throw new Error(`App manifest is for domain ${manifest.appDomain}, while app's domain is ${appDomain}`);
141
- }
142
- const { storage, close } = this.makeStorageCAP(manifest);
143
- const mail = this.makeMailCAP(manifest);
144
- const log = this.makeLogCAP(manifest);
145
- const mailerid = this.makeMailerIdCAP(manifest);
135
+ const { storage, close } = this.makeStorageCAP(appDomain, requestedCAPs);
136
+ const mail = this.makeMailCAP(requestedCAPs);
137
+ const log = this.makeLogCAP(appDomain, requestedCAPs);
138
+ const mailerid = this.makeMailerIdCAP(requestedCAPs);
146
139
  const caps = { mail, log, mailerid, storage };
147
140
  return { caps, close };
148
141
  }
149
142
  ;
150
- makeStorageCAP(m) {
151
- if (m.capsRequested.storage) {
152
- const { cap: storage, close } = this.storages.makeStorageCAP(m.appDomain, makeStoragePolicy(m));
143
+ makeStorageCAP(appDomain, requestedCAPs) {
144
+ if (requestedCAPs.storage) {
145
+ const { cap: storage, close } = this.storages.makeStorageCAP(appDomain, makeStoragePolicy(appDomain, requestedCAPs));
153
146
  return { storage, close };
154
147
  }
155
148
  else {
156
149
  return { close: () => { } };
157
150
  }
158
151
  }
159
- makeMailCAP(m) {
160
- if (m.capsRequested.mail
161
- && (m.capsRequested.mail.receivingFrom === 'all')
162
- && (m.capsRequested.mail.sendingTo === 'all')) {
152
+ makeMailCAP(requestedCAPs) {
153
+ if (requestedCAPs.mail
154
+ && (requestedCAPs.mail.receivingFrom === 'all')
155
+ && (requestedCAPs.mail.sendingTo === 'all')) {
163
156
  return this.asmail.makeASMailCAP();
164
157
  }
165
158
  else {
166
159
  return undefined;
167
160
  }
168
161
  }
169
- makeLogCAP(m) {
170
- if (m.capsRequested.log === 'all') {
171
- return (type, msg, e) => this.logger.appLog(type, m.appDomain, msg, e);
162
+ makeLogCAP(appDomain, requestedCAPs) {
163
+ if (requestedCAPs.log === 'all') {
164
+ return (type, msg, e) => this.logger.appLog(type, appDomain, msg, e);
172
165
  }
173
166
  else {
174
167
  return undefined;
175
168
  }
176
169
  }
177
- makeMailerIdCAP(m) {
178
- if (m.capsRequested.mailerid === true) {
170
+ makeMailerIdCAP(requestedCAPs) {
171
+ if (requestedCAPs.mailerid === true) {
179
172
  return this.idManager.makeMailerIdCAP();
180
173
  }
181
174
  else {
@@ -218,24 +211,24 @@ class Core {
218
211
  exports.Core = Core;
219
212
  Object.freeze(Core.prototype);
220
213
  Object.freeze(Core);
221
- function makeStoragePolicy(manifest) {
222
- if (!manifest.capsRequested.storage) {
214
+ function makeStoragePolicy(appDomain, requestedCAPs) {
215
+ if (!requestedCAPs.storage) {
223
216
  throw new Error(`Missing storage setting in app's manifest`);
224
217
  }
225
- const capReq = manifest.capsRequested.storage;
218
+ const capReq = requestedCAPs.storage;
226
219
  let policy;
227
220
  if (capReq.appFS === 'default') {
228
221
  policy = {
229
222
  canOpenAppFS: singleDomainAppFSChecker({
230
- domain: manifest.appDomain,
223
+ domain: appDomain,
231
224
  storage: 'synced-n-local'
232
225
  })
233
226
  };
234
227
  }
235
228
  else if (Array.isArray(capReq.appFS)) {
236
229
  const okDomains = capReq.appFS
237
- .filter(fsInfo => (fsInfo.domain === manifest.appDomain) ||
238
- fsInfo.domain.endsWith('.' + manifest.appDomain))
230
+ .filter(fsInfo => (fsInfo.domain === appDomain) ||
231
+ fsInfo.domain.endsWith('.' + appDomain))
239
232
  .map(fsInfo => json_utils_1.copy(fsInfo));
240
233
  policy = {
241
234
  canOpenAppFS: severalDomainsAppFSChecker(okDomains)
@@ -36,13 +36,13 @@ function makeBadAppNameExc(appName) {
36
36
  appName
37
37
  };
38
38
  }
39
- function makeNotAllowedToOpenAppFSExc(appName) {
39
+ function makeNotAllowedToOpenAppFSExc(appFolder) {
40
40
  return {
41
41
  runtimeException: true,
42
42
  type: 'storage',
43
43
  storageSegment: 'app',
44
44
  notAllowedToOpenFS: true,
45
- appName
45
+ appName: reverseDomain(appFolder)
46
46
  };
47
47
  }
48
48
  function makeNotAllowedToOpenUserFSExc(storageType) {
@@ -23,8 +23,6 @@ const processes_1 = require("../../../lib-common/processes");
23
23
  const path_1 = require("path");
24
24
  const obj_files_gc_1 = require("./obj-files-gc");
25
25
  const obj_status_1 = require("./obj-status");
26
- const operators_1 = require("rxjs/operators");
27
- const utils_for_observables_1 = require("../../../lib-common/utils-for-observables");
28
26
  const timed_cache_1 = require("../../../lib-common/timed-cache");
29
27
  class ObjFiles {
30
28
  constructor(folders, logError) {
@@ -141,12 +139,17 @@ class LocalObj {
141
139
  }
142
140
  const fPath = this.path(version);
143
141
  const { obj, write$ } = await obj_on_disk_1.ObjOnDisk.createFileForWriteOfNewVersion(this.objId, version, fPath, encSub, undefined, this.objSegsGetterFromDisk);
144
- // this.verObjs.set(version, obj);
145
- await write$.pipe(operators_1.tap(undefined, err => {
142
+ try {
143
+ await write$.toPromise();
144
+ }
145
+ catch (err) {
146
146
  if (this.verObjs.get(version) === obj) {
147
147
  this.verObjs.delete(version);
148
148
  }
149
- }), utils_for_observables_1.flatTap(undefined, undefined, () => this.status.setNewCurrentVersion(version, obj.getBaseVersion()))).toPromise();
149
+ throw err;
150
+ }
151
+ this.verObjs.set(version, obj);
152
+ await this.status.setNewCurrentVersion(version, obj.getBaseVersion());
150
153
  this.scheduleGC(this);
151
154
  }
152
155
  isArchived() {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2016 - 2020 3NSoft Inc.
3
+ Copyright (C) 2016 - 2020, 2022 3NSoft Inc.
4
4
 
5
5
  This program is free software: you can redistribute it and/or modify it under
6
6
  the terms of the GNU General Public License as published by the Free Software
@@ -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.ObjStatus = void 0;
19
20
  const fs = require("../../../lib-common/async-fs-node");
@@ -63,7 +64,6 @@ class ObjStatus {
63
64
  };
64
65
  }
65
66
  async setNewCurrentVersion(newVersion, baseVer) {
66
- this.status.currentVersion = newVersion;
67
67
  if (baseVer !== undefined) {
68
68
  // base->diff links should be added before removals
69
69
  addBaseToDiffLinkInStatus(this.status, newVersion, baseVer);
@@ -71,6 +71,7 @@ class ObjStatus {
71
71
  if (typeof this.status.currentVersion === 'number') {
72
72
  rmNonArchVersionsIn(this.status, this.status.currentVersion);
73
73
  }
74
+ this.status.currentVersion = newVersion;
74
75
  await this.saveProc.trigger();
75
76
  }
76
77
  async removeCurrentVersion(verObjs) {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2016 - 2020 3NSoft Inc.
3
+ Copyright (C) 2016 - 2020, 2022 3NSoft Inc.
4
4
 
5
5
  This program is free software: you can redistribute it and/or modify it under
6
6
  the terms of the GNU General Public License as published by the Free Software
@@ -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.ObjStatus = void 0;
19
20
  const processes_1 = require("../../../lib-common/processes");
@@ -184,7 +185,6 @@ function rmNonArchVersionsIn(status, ver) {
184
185
  // status: ObjStatusInfo, newVersion: number, baseVer: number|undefined
185
186
  // ): void {
186
187
  // if (status.isArchived) { return; }
187
- // status.versions.current = newVersion;
188
188
  // if (status.syncState === 'synced') {
189
189
  // status.syncState = 'unsynced';
190
190
  // }
@@ -195,6 +195,7 @@ function rmNonArchVersionsIn(status, ver) {
195
195
  // if (status.versions.current) {
196
196
  // rmNonArchVersionsIn(status, status.versions.current);
197
197
  // }
198
+ // status.versions.current = newVersion;
198
199
  // }
199
200
  // export function addConflictingRemoteVersionTo(
200
201
  // status: ObjStatusInfo, conflictVersion: number
@@ -18,14 +18,12 @@
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.makeStartupW3Nclient = exports.exposeStartupW3N = void 0;
20
20
  const connector_1 = require("../ipc-via-protobuf/connector");
21
- const log_cap_1 = require("../ipc-via-protobuf/log-cap");
22
21
  const startup_cap_1 = require("../ipc-via-protobuf/startup-cap");
23
22
  const generic_1 = require("./generic");
24
23
  function exposeStartupW3N(coreSide, w3n, extraCAPs) {
25
24
  const startupCAPsExposures = {
26
25
  signIn: startup_cap_1.wrapSignInCAP,
27
26
  signUp: startup_cap_1.wrapSignUpCAP,
28
- log: log_cap_1.exposeLogger,
29
27
  };
30
28
  generic_1.exposeCAPs(coreSide, w3n, startupCAPsExposures, extraCAPs);
31
29
  }
@@ -35,7 +33,6 @@ exports.exposeStartupW3N = exposeStartupW3N;
35
33
  const unused = connector_1.W3N_NAME;
36
34
  function makeStartupW3Nclient(clientSide, extraCAPs) {
37
35
  const mainCAPs = {
38
- log: log_cap_1.makeLogCaller,
39
36
  signIn: startup_cap_1.makeSignInCaller,
40
37
  signUp: startup_cap_1.makeSignUpCaller,
41
38
  };
@@ -147,7 +147,7 @@ var sinkShowLayout;
147
147
  }
148
148
  function unpackLayout(msg) {
149
149
  return {
150
- base: protobuf_msg_1.valOfOpt(msg.base),
150
+ base: protobuf_msg_1.valOfOptInt(msg.base),
151
151
  sections: protobuf_msg_1.fixArray(msg.sections).map(({ src, ofs, len }) => ({
152
152
  src, ofs: protobuf_msg_1.fixInt(ofs), len: protobuf_msg_1.fixInt(len)
153
153
  }))
@@ -0,0 +1,28 @@
1
+ /// <reference types="node" />
2
+ import { Attrs } from "./node-persistence";
3
+ export declare class CommonAttrs {
4
+ ctime: number;
5
+ mtime: number;
6
+ constructor(ctime: number, mtime: number);
7
+ static makeForTimeNow(): CommonAttrs;
8
+ static fromAttrs(attrs: Attrs): CommonAttrs;
9
+ static readonly PACK_LEN: number;
10
+ static parse(bytes: Uint8Array): CommonAttrs;
11
+ pack(): Buffer;
12
+ copy(): CommonAttrs;
13
+ updateMTime(): void;
14
+ }
15
+ export declare class XAttrs {
16
+ private readonly attrs;
17
+ private constructor();
18
+ static makeEmpty(): XAttrs;
19
+ static parseFrom(sections: Uint8Array[]): XAttrs;
20
+ copy(): XAttrs;
21
+ makeUpdated(changes: XAttrsChanges): XAttrs;
22
+ get(xaName: string): any;
23
+ list(): string[];
24
+ get isEmpty(): boolean;
25
+ pack(): Uint8Array[] | undefined;
26
+ }
27
+ declare type XAttrsChanges = web3n.files.XAttrsChanges;
28
+ export {};