core-3nweb-client-lib 0.20.9 → 0.21.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.
@@ -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;
@@ -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;
@@ -29,7 +29,7 @@ export declare class Core {
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;
@@ -129,50 +128,47 @@ class Core {
129
128
  return { coreInit, capsForStartup };
130
129
  }
131
130
  ;
132
- makeCAPsForApp(appDomain, manifest) {
131
+ makeCAPsForApp(appDomain, requestedCAPs) {
133
132
  if (!this.isInitialized || this.closingProc) {
134
133
  throw new Error(`Core is either not yet initialized, or is already closed.`);
135
134
  }
136
- if (appDomain !== manifest.appDomain) {
137
- throw new Error(`App manifest is for domain ${manifest.appDomain}, while app's domain is ${appDomain}`);
138
- }
139
- const { storage, close } = this.makeStorageCAP(manifest);
140
- const mail = this.makeMailCAP(manifest);
141
- const log = this.makeLogCAP(manifest);
142
- 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);
143
139
  const caps = { mail, log, mailerid, storage };
144
140
  return { caps, close };
145
141
  }
146
142
  ;
147
- makeStorageCAP(m) {
148
- if (m.capsRequested.storage) {
149
- 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));
150
146
  return { storage, close };
151
147
  }
152
148
  else {
153
149
  return { close: () => { } };
154
150
  }
155
151
  }
156
- makeMailCAP(m) {
157
- if (m.capsRequested.mail
158
- && (m.capsRequested.mail.receivingFrom === 'all')
159
- && (m.capsRequested.mail.sendingTo === 'all')) {
152
+ makeMailCAP(requestedCAPs) {
153
+ if (requestedCAPs.mail
154
+ && (requestedCAPs.mail.receivingFrom === 'all')
155
+ && (requestedCAPs.mail.sendingTo === 'all')) {
160
156
  return this.asmail.makeASMailCAP();
161
157
  }
162
158
  else {
163
159
  return undefined;
164
160
  }
165
161
  }
166
- makeLogCAP(m) {
167
- if (m.capsRequested.log === 'all') {
168
- 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);
169
165
  }
170
166
  else {
171
167
  return undefined;
172
168
  }
173
169
  }
174
- makeMailerIdCAP(m) {
175
- if (m.capsRequested.mailerid === true) {
170
+ makeMailerIdCAP(requestedCAPs) {
171
+ if (requestedCAPs.mailerid === true) {
176
172
  return this.idManager.makeMailerIdCAP();
177
173
  }
178
174
  else {
@@ -215,24 +211,24 @@ class Core {
215
211
  exports.Core = Core;
216
212
  Object.freeze(Core.prototype);
217
213
  Object.freeze(Core);
218
- function makeStoragePolicy(manifest) {
219
- if (!manifest.capsRequested.storage) {
214
+ function makeStoragePolicy(appDomain, requestedCAPs) {
215
+ if (!requestedCAPs.storage) {
220
216
  throw new Error(`Missing storage setting in app's manifest`);
221
217
  }
222
- const capReq = manifest.capsRequested.storage;
218
+ const capReq = requestedCAPs.storage;
223
219
  let policy;
224
220
  if (capReq.appFS === 'default') {
225
221
  policy = {
226
222
  canOpenAppFS: singleDomainAppFSChecker({
227
- domain: manifest.appDomain,
223
+ domain: appDomain,
228
224
  storage: 'synced-n-local'
229
225
  })
230
226
  };
231
227
  }
232
228
  else if (Array.isArray(capReq.appFS)) {
233
229
  const okDomains = capReq.appFS
234
- .filter(fsInfo => (fsInfo.domain === manifest.appDomain) ||
235
- fsInfo.domain.endsWith('.' + manifest.appDomain))
230
+ .filter(fsInfo => (fsInfo.domain === appDomain) ||
231
+ fsInfo.domain.endsWith('.' + appDomain))
236
232
  .map(fsInfo => json_utils_1.copy(fsInfo));
237
233
  policy = {
238
234
  canOpenAppFS: severalDomainsAppFSChecker(okDomains)