core-3nweb-client-lib 0.35.4 → 0.37.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.
@@ -82,7 +82,7 @@ declare namespace web3n.asmail {
82
82
  }
83
83
 
84
84
  interface DeliveryService {
85
-
85
+
86
86
  /**
87
87
  * This returns a promise, resolvable to an allowable total size of a
88
88
  * message
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright (C) 2017 - 2018, 2020 - 2022 3NSoft Inc.
2
+ Copyright (C) 2017 - 2018, 2020 - 2022, 2025 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
@@ -62,6 +62,7 @@ declare namespace web3n.caps.common {
62
62
  }
63
63
 
64
64
  interface MailCAPSetting {
65
+ preflightsTo?: 'all' | { whitelist: string[]; };
65
66
  sendingTo?: 'all' | { whitelist: string[]; };
66
67
  receivingFrom?: 'all' | { whitelist: string[]; };
67
68
  config?: 'all';
@@ -27,6 +27,7 @@ export declare class ASMail {
27
27
  private setupDelivery;
28
28
  private setupInbox;
29
29
  makeASMailCAP(): Service;
30
+ makePreflightOnlyASMailCAP(): Service;
30
31
  close(): Promise<void>;
31
32
  }
32
33
  export {};
@@ -112,6 +112,17 @@ class ASMail {
112
112
  return Object.freeze(w);
113
113
  }
114
114
  ;
115
+ makePreflightOnlyASMailCAP() {
116
+ const { preFlight } = this.delivery.makeCAP();
117
+ const w = {
118
+ getUserId: async () => this.address,
119
+ delivery: {
120
+ preFlight
121
+ }
122
+ };
123
+ return Object.freeze(w);
124
+ }
125
+ ;
115
126
  async close() {
116
127
  await this.inbox.close();
117
128
  await this.delivery.close();
@@ -150,11 +150,16 @@ class Core {
150
150
  }
151
151
  }
152
152
  makeMailCAP(requestedCAPs) {
153
- if (requestedCAPs.mail
154
- && (requestedCAPs.mail.receivingFrom === 'all')
155
- && (requestedCAPs.mail.sendingTo === 'all')) {
153
+ if (!requestedCAPs.mail) {
154
+ return;
155
+ }
156
+ const { sendingTo, receivingFrom, preflightsTo } = requestedCAPs.mail;
157
+ if ((receivingFrom === 'all') && (sendingTo === 'all')) {
156
158
  return this.asmail.makeASMailCAP();
157
159
  }
160
+ else if (preflightsTo === 'all') {
161
+ return this.asmail.makePreflightOnlyASMailCAP();
162
+ }
158
163
  else {
159
164
  return undefined;
160
165
  }
@@ -219,15 +219,14 @@ var extAttrs;
219
219
  }
220
220
  function packNamedStrAttr(name, value) {
221
221
  (0, assert_1.assert)((typeof name === 'string') && (name.length > 0) &&
222
- (typeof value === 'string') && (value.length > 0));
222
+ (typeof value === 'string'));
223
223
  const nameBin = Buffer.from(name, 'utf8');
224
224
  const valueBin = Buffer.from(value, 'utf8');
225
225
  return packNamedAttr(NAMED_UTF8_STR, nameBin, valueBin);
226
226
  }
227
227
  extAttrs.packNamedStrAttr = packNamedStrAttr;
228
228
  function packNamedBinaryAttr(name, value) {
229
- (0, assert_1.assert)((typeof name === 'string') && (name.length > 0) &&
230
- (value.length > 0));
229
+ (0, assert_1.assert)((typeof name === 'string') && (name.length > 0));
231
230
  const nameBin = Buffer.from(name, 'utf8');
232
231
  return packNamedAttr(NAMED_BINARY, nameBin, value);
233
232
  }
@@ -304,27 +303,6 @@ var extAttrs;
304
303
  (0, assert_1.assert)(false);
305
304
  }
306
305
  }
307
- // export function pack(xattrs: XAttrs): Buffer {
308
- // const ext: Buffer[] = [];
309
- // for (const xattr of Object.values(xattrs)) {
310
- // if (xattr.type === 'named-utf8str') {
311
- // ext.push(packNamedStrAttr(xattr.name, xattr.value));
312
- // } else if (xattr.type === 'named-json') {
313
- // ext.push(packNamedJsonAttr(xattr.name, xattr.value));
314
- // } else if (xattr.type === 'named-binary') {
315
- // ext.push(packNamedBinaryAttr(xattr.name, xattr.value));
316
- // } else {
317
- // throw new Error(`Unknown type of named attribute`);
318
- // }
319
- // }
320
- // const bytes = Buffer.allocUnsafe(ext.reduce((len, b) => len+b.length, 0));
321
- // let ofs = 0;
322
- // for (const buf of ext) {
323
- // bytes.set(buf, ofs);
324
- // ofs += buf.length;
325
- // }
326
- // return bytes;
327
- // }
328
306
  })(extAttrs || (extAttrs = {}));
329
307
  Object.freeze(extAttrs);
330
308
  function parsingException(msg, cause) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "core-3nweb-client-lib",
3
- "version": "0.35.4",
3
+ "version": "0.37.0",
4
4
  "description": "3NWeb client core library, embeddable into different environments",
5
5
  "main": "build/lib-index.js",
6
6
  "types": "build/lib-index.d.ts",