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.
package/build/core/index.d.ts
CHANGED
|
@@ -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
|
|
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,
|
|
32
|
+
makeCAPsForApp(appDomain: string, requestedCAPs: RequestedCAPs): {
|
|
33
33
|
caps: W3N;
|
|
34
34
|
close: () => void;
|
|
35
35
|
};
|
package/build/core/index.js
CHANGED
|
@@ -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,
|
|
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
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
const
|
|
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(
|
|
148
|
-
if (
|
|
149
|
-
const { cap: storage, close } = this.storages.makeStorageCAP(
|
|
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(
|
|
157
|
-
if (
|
|
158
|
-
&& (
|
|
159
|
-
&& (
|
|
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(
|
|
167
|
-
if (
|
|
168
|
-
return (type, msg, e) => this.logger.appLog(type,
|
|
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(
|
|
175
|
-
if (
|
|
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(
|
|
219
|
-
if (!
|
|
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 =
|
|
218
|
+
const capReq = requestedCAPs.storage;
|
|
223
219
|
let policy;
|
|
224
220
|
if (capReq.appFS === 'default') {
|
|
225
221
|
policy = {
|
|
226
222
|
canOpenAppFS: singleDomainAppFSChecker({
|
|
227
|
-
domain:
|
|
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 ===
|
|
235
|
-
fsInfo.domain.endsWith('.' +
|
|
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)
|