spec-3nweb-server 1.7.7 → 1.7.8

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.
@@ -37,22 +37,22 @@ function makeApp(domain, sessions, recipients, midAuthorizer) {
37
37
  .put((0, body_parsers_1.json)('4kb', true), (0, param_setter_1.setParam)(recipients.setPubKey));
38
38
  app.route('/' + api.p.anonSenderPolicy.URL_END)
39
39
  .get((0, param_getter_1.getParam)(recipients.getAnonSenderPolicy))
40
- .put((0, body_parsers_1.json)('40kb', true), (0, param_setter_1.setParam)(recipients.setAnonSenderPolicy));
40
+ .put((0, body_parsers_1.json)('40kb'), (0, param_setter_1.setParam)(recipients.setAnonSenderPolicy));
41
41
  app.route('/' + api.p.anonSenderInvites.URL_END)
42
42
  .get((0, param_getter_1.getParam)(recipients.getAnonSenderInvites))
43
- .put((0, body_parsers_1.json)('40kb', true), (0, param_setter_1.setParam)(recipients.setAnonSenderInvites));
43
+ .put((0, body_parsers_1.json)('40kb'), (0, param_setter_1.setParam)(recipients.setAnonSenderInvites));
44
44
  app.route('/' + api.p.authSenderPolicy.URL_END)
45
45
  .get((0, param_getter_1.getParam)(recipients.getAuthSenderPolicy))
46
- .put((0, body_parsers_1.json)('4kb', true), (0, param_setter_1.setParam)(recipients.setAuthSenderPolicy));
46
+ .put((0, body_parsers_1.json)('4kb'), (0, param_setter_1.setParam)(recipients.setAuthSenderPolicy));
47
47
  app.route('/' + api.p.authSenderInvites.URL_END)
48
48
  .get((0, param_getter_1.getParam)(recipients.getAuthSenderInvites))
49
- .put((0, body_parsers_1.json)('40kb', true), (0, param_setter_1.setParam)(recipients.setAuthSenderInvites));
49
+ .put((0, body_parsers_1.json)('40kb'), (0, param_setter_1.setParam)(recipients.setAuthSenderInvites));
50
50
  app.route('/' + api.p.authSenderWhitelist.URL_END)
51
51
  .get((0, param_getter_1.getParam)(recipients.getAuthSenderWhitelist))
52
- .put((0, body_parsers_1.json)('40kb', true), (0, param_setter_1.setParam)(recipients.setAuthSenderWhitelist));
52
+ .put((0, body_parsers_1.json)('40kb'), (0, param_setter_1.setParam)(recipients.setAuthSenderWhitelist));
53
53
  app.route('/' + api.p.authSenderBlacklist.URL_END)
54
54
  .get((0, param_getter_1.getParam)(recipients.getAuthSenderBlacklist))
55
- .put((0, body_parsers_1.json)('40kb', true), (0, param_setter_1.setParam)(recipients.setAuthSenderBlacklist));
55
+ .put((0, body_parsers_1.json)('40kb'), (0, param_setter_1.setParam)(recipients.setAuthSenderBlacklist));
56
56
  return app;
57
57
  }
58
58
  exports.makeApp = makeApp;
@@ -23,7 +23,7 @@ export declare const SC: {
23
23
  OBJ_FILE_INCOMPLETE: string;
24
24
  };
25
25
  export interface InboxParams {
26
- "pubkey": deliveryApi.initPubKey.Reply;
26
+ "pubkey": deliveryApi.initPubKey.Reply | null;
27
27
  "anonymous/policy": AnonSenderPolicy;
28
28
  "anonymous/invites": AnonSenderInvites;
29
29
  "authenticated/policy": AuthSenderPolicy;
@@ -107,16 +107,14 @@ export declare class Inbox extends UserFiles<InboxParams> {
107
107
  getObj(msgId: string, objId: string, header: boolean, segsOfs: number, segsLimit: number | undefined): Promise<ObjReader>;
108
108
  /**
109
109
  * @param initKeyCerts
110
- * @param setDefault when it is true, sets default values -- null --
111
- * in place of an object with certs.
112
110
  * @return a promise, resolvable to true, when certs are set, or
113
111
  * resolvable to false, when given certs do not pass sanitization.
114
112
  */
115
- setPubKey(initKeyCerts: deliveryApi.initPubKey.Reply, setDefault: boolean): Promise<boolean>;
116
- setAnonSenderPolicy(policy: AnonSenderPolicy, setDefault: boolean): Promise<boolean>;
117
- setAnonSenderInvites(invites: AnonSenderInvites, setDefault: boolean): Promise<boolean>;
118
- setAuthSenderPolicy(policy: AuthSenderPolicy, setDefault: boolean): Promise<boolean>;
119
- setAuthSenderBlacklist(list: Blacklist, setDefault: boolean): Promise<boolean>;
120
- setAuthSenderWhitelist(list: Whitelist, setDefault: boolean): Promise<boolean>;
121
- setAuthSenderInvites(invites: AuthSenderInvites, setDefault: boolean): Promise<boolean>;
113
+ setPubKey(initKeyCerts: deliveryApi.initPubKey.Reply | null): Promise<boolean>;
114
+ setAnonSenderPolicy(policy: AnonSenderPolicy): Promise<boolean>;
115
+ setAnonSenderInvites(invites: AnonSenderInvites): Promise<boolean>;
116
+ setAuthSenderPolicy(policy: AuthSenderPolicy): Promise<boolean>;
117
+ setAuthSenderBlacklist(list: Blacklist): Promise<boolean>;
118
+ setAuthSenderWhitelist(list: Whitelist): Promise<boolean>;
119
+ setAuthSenderInvites(invites: AuthSenderInvites): Promise<boolean>;
122
120
  }
@@ -330,140 +330,96 @@ class Inbox extends user_files_1.UserFiles {
330
330
  }
331
331
  /**
332
332
  * @param initKeyCerts
333
- * @param setDefault when it is true, sets default values -- null --
334
- * in place of an object with certs.
335
333
  * @return a promise, resolvable to true, when certs are set, or
336
334
  * resolvable to false, when given certs do not pass sanitization.
337
335
  */
338
- async setPubKey(initKeyCerts, setDefault) {
339
- if (setDefault) {
340
- initKeyCerts = null;
336
+ async setPubKey(initKeyCerts) {
337
+ let isOK;
338
+ if (initKeyCerts === null) {
339
+ isOK = true;
341
340
  }
342
341
  else {
343
- const isOK = (typeof initKeyCerts === 'object') && !!initKeyCerts &&
342
+ isOK = ((typeof initKeyCerts === 'object') &&
344
343
  (0, jwkeys_1.isLikeSignedKeyCert)(initKeyCerts.pkeyCert) &&
345
344
  (0, jwkeys_1.isLikeSignedKeyCert)(initKeyCerts.userCert) &&
346
- (0, jwkeys_1.isLikeSignedKeyCert)(initKeyCerts.provCert);
347
- if (!isOK) {
348
- return false;
349
- }
350
- }
351
- await this.setParam('pubkey', initKeyCerts);
352
- return true;
353
- }
354
- async setAnonSenderPolicy(policy, setDefault) {
355
- if (setDefault) {
356
- policy = {
357
- accept: true,
358
- acceptWithInvitesOnly: false,
359
- defaultMsgSize: 1024 * 1024
360
- };
345
+ (0, jwkeys_1.isLikeSignedKeyCert)(initKeyCerts.provCert));
361
346
  }
362
- else {
363
- const isOK = ('object' === typeof policy) && !!policy &&
364
- ('boolean' === typeof policy.accept) &&
365
- ('boolean' === typeof policy.acceptWithInvitesOnly) &&
366
- ('number' === typeof policy.defaultMsgSize) &&
367
- (policy.defaultMsgSize > 500);
368
- if (!isOK) {
369
- false;
370
- }
371
- }
372
- await this.setParam('anonymous/policy', policy);
373
- return true;
374
- }
375
- async setAnonSenderInvites(invites, setDefault) {
376
- if (setDefault) {
377
- invites = {};
378
- }
379
- else {
380
- const isOK = ('object' === typeof invites) && !!invites;
381
- if (!isOK) {
382
- return false;
383
- }
384
- for (var invite in invites) {
385
- const msgMaxSize = invites[invite];
386
- const isOK = ('number' === typeof msgMaxSize) && (msgMaxSize > 500);
387
- if (!isOK) {
388
- return false;
389
- }
390
- }
347
+ if (isOK) {
348
+ await this.setParam('pubkey', initKeyCerts);
391
349
  }
392
- await this.setParam('anonymous/invites', invites);
393
- return true;
350
+ return isOK;
394
351
  }
395
- async setAuthSenderPolicy(policy, setDefault) {
396
- if (setDefault) {
397
- policy = {
398
- acceptWithInvitesOnly: false,
399
- acceptFromWhiteListOnly: false,
400
- applyBlackList: true,
401
- defaultMsgSize: 100 * 1024 * 1024,
402
- };
403
- }
404
- else {
405
- const isOK = ('object' === typeof policy) && !!policy &&
406
- ('boolean' === typeof policy.applyBlackList) &&
407
- ('boolean' === typeof policy.acceptFromWhiteListOnly) &&
408
- ('boolean' === typeof policy.acceptWithInvitesOnly) &&
409
- ('number' === typeof policy.defaultMsgSize) &&
410
- (policy.defaultMsgSize > 500);
411
- if (!isOK) {
412
- return false;
413
- }
352
+ async setAnonSenderPolicy(policy) {
353
+ const isOK = (('object' === typeof policy) && !!policy &&
354
+ ('boolean' === typeof policy.accept) &&
355
+ ('boolean' === typeof policy.acceptWithInvitesOnly) &&
356
+ ('number' === typeof policy.defaultMsgSize) &&
357
+ (policy.defaultMsgSize > 500));
358
+ if (isOK) {
359
+ await this.setParam('anonymous/policy', policy);
414
360
  }
415
- await this.setParam('authenticated/policy', policy);
416
- return true;
361
+ return isOK;
417
362
  }
418
- async setAuthSenderBlacklist(list, setDefault) {
419
- if (setDefault) {
420
- list = {};
363
+ async setAnonSenderInvites(invites) {
364
+ const isOK = ('object' === typeof invites) && !!invites;
365
+ if (!isOK) {
366
+ return false;
421
367
  }
422
- else {
423
- const isOK = ('object' === typeof list) && !!list;
368
+ for (var invite in invites) {
369
+ const msgMaxSize = invites[invite];
370
+ const isOK = ('number' === typeof msgMaxSize) && (msgMaxSize > 500);
424
371
  if (!isOK) {
425
372
  return false;
426
373
  }
427
374
  }
428
- await this.setParam('authenticated/blacklist', list);
375
+ await this.setParam('anonymous/invites', invites);
429
376
  return true;
430
377
  }
431
- async setAuthSenderWhitelist(list, setDefault) {
432
- if (setDefault) {
433
- list = {};
434
- }
435
- else {
436
- const isOK = ('object' === typeof list) && !!list;
378
+ async setAuthSenderPolicy(policy) {
379
+ const isOK = (('object' === typeof policy) && !!policy &&
380
+ ('boolean' === typeof policy.applyBlackList) &&
381
+ ('boolean' === typeof policy.acceptFromWhiteListOnly) &&
382
+ ('boolean' === typeof policy.acceptWithInvitesOnly) &&
383
+ ('number' === typeof policy.defaultMsgSize) &&
384
+ (policy.defaultMsgSize > 500));
385
+ if (!isOK) {
386
+ await this.setParam('authenticated/policy', policy);
387
+ }
388
+ return isOK;
389
+ }
390
+ async setAuthSenderBlacklist(list) {
391
+ const isOK = ('object' === typeof list) && !!list;
392
+ if (isOK) {
393
+ await this.setParam('authenticated/blacklist', list);
394
+ }
395
+ return isOK;
396
+ }
397
+ async setAuthSenderWhitelist(list) {
398
+ const isOK = ('object' === typeof list) && !!list;
399
+ if (!isOK) {
400
+ return false;
401
+ }
402
+ for (var addr in list) {
403
+ const msgMaxSize = list[addr];
404
+ const isOK = ('number' === typeof msgMaxSize) && (msgMaxSize > 500);
437
405
  if (!isOK) {
438
406
  return false;
439
407
  }
440
- for (var addr in list) {
441
- const msgMaxSize = list[addr];
442
- const isOK = ('number' === typeof msgMaxSize) && (msgMaxSize > 500);
443
- if (!isOK) {
444
- return false;
445
- }
446
- }
447
408
  }
448
409
  await this.setParam('authenticated/whitelist', list);
449
410
  return true;
450
411
  }
451
- async setAuthSenderInvites(invites, setDefault) {
452
- if (setDefault) {
453
- invites = {};
412
+ async setAuthSenderInvites(invites) {
413
+ const isOK = ('object' === typeof invites) && !!invites;
414
+ if (!isOK) {
415
+ return false;
454
416
  }
455
- else {
456
- const isOK = ('object' === typeof invites) && !!invites;
417
+ for (var invite in invites) {
418
+ const msgMaxSize = invites[invite];
419
+ const isOK = ('number' === typeof msgMaxSize) && (msgMaxSize > 500);
457
420
  if (!isOK) {
458
421
  return false;
459
422
  }
460
- for (var invite in invites) {
461
- const msgMaxSize = invites[invite];
462
- const isOK = ('number' === typeof msgMaxSize) && (msgMaxSize > 500);
463
- if (!isOK) {
464
- return false;
465
- }
466
- }
467
423
  }
468
424
  await this.setParam('authenticated/invites', invites);
469
425
  return true;
@@ -188,7 +188,7 @@ function makeFactory(rootFolder, writeBufferSize, readBufferSize) {
188
188
  },
189
189
  setPubKey: async (userId, pkey) => {
190
190
  const inbox = await getInbox(userId);
191
- return inbox.setPubKey(pkey, false);
191
+ return inbox.setPubKey(pkey);
192
192
  },
193
193
  getAnonSenderPolicy: async (recipient) => {
194
194
  const inbox = await getInbox(recipient);
@@ -196,7 +196,7 @@ function makeFactory(rootFolder, writeBufferSize, readBufferSize) {
196
196
  },
197
197
  setAnonSenderPolicy: async (userId, policy) => {
198
198
  const inbox = await getInbox(userId);
199
- return inbox.setAnonSenderPolicy(policy, false);
199
+ return inbox.setAnonSenderPolicy(policy);
200
200
  },
201
201
  getAnonSenderInvites: async (recipient) => {
202
202
  const inbox = await getInbox(recipient);
@@ -204,7 +204,7 @@ function makeFactory(rootFolder, writeBufferSize, readBufferSize) {
204
204
  },
205
205
  setAnonSenderInvites: async (userId, invites) => {
206
206
  const inbox = await getInbox(userId);
207
- return inbox.setAnonSenderInvites(invites, false);
207
+ return inbox.setAnonSenderInvites(invites);
208
208
  },
209
209
  getAuthSenderPolicy: async (recipient) => {
210
210
  const inbox = await getInbox(recipient);
@@ -212,7 +212,7 @@ function makeFactory(rootFolder, writeBufferSize, readBufferSize) {
212
212
  },
213
213
  setAuthSenderPolicy: async (userId, policy) => {
214
214
  const inbox = await getInbox(userId);
215
- return inbox.setAuthSenderPolicy(policy, false);
215
+ return inbox.setAuthSenderPolicy(policy);
216
216
  },
217
217
  getAuthSenderInvites: async (recipient) => {
218
218
  const inbox = await getInbox(recipient);
@@ -220,7 +220,7 @@ function makeFactory(rootFolder, writeBufferSize, readBufferSize) {
220
220
  },
221
221
  setAuthSenderInvites: async (userId, invites) => {
222
222
  const inbox = await getInbox(userId);
223
- return inbox.setAnonSenderInvites(invites, false);
223
+ return inbox.setAnonSenderInvites(invites);
224
224
  },
225
225
  getAuthSenderBlacklist: async (recipient) => {
226
226
  const inbox = await getInbox(recipient);
@@ -228,7 +228,7 @@ function makeFactory(rootFolder, writeBufferSize, readBufferSize) {
228
228
  },
229
229
  setAuthSenderBlacklist: async (userId, list) => {
230
230
  const inbox = await getInbox(userId);
231
- return inbox.setAuthSenderBlacklist(list, false);
231
+ return inbox.setAuthSenderBlacklist(list);
232
232
  },
233
233
  getAuthSenderWhitelist: async (recipient) => {
234
234
  const inbox = await getInbox(recipient);
@@ -236,7 +236,7 @@ function makeFactory(rootFolder, writeBufferSize, readBufferSize) {
236
236
  },
237
237
  setAuthSenderWhitelist: async (userId, list) => {
238
238
  const inbox = await getInbox(userId);
239
- return inbox.setAuthSenderWhitelist(list, false);
239
+ return inbox.setAuthSenderWhitelist(list);
240
240
  },
241
241
  allowedMaxMsgSize: async (recipient, sender, invitation) => {
242
242
  const inbox = await getInbox(recipient);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spec-3nweb-server",
3
- "version": "1.7.7",
3
+ "version": "1.7.8",
4
4
  "description": "3NWeb spec server.",
5
5
  "main": "build/lib.js",
6
6
  "types": "build/lib.d.ts",