core-3nweb-client-lib 0.50.6 → 0.51.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.
@@ -34,6 +34,8 @@ declare namespace web3n.asmail {
34
34
 
35
35
  config: ASMailConfigService;
36
36
 
37
+ getReportAddressForDomain(domain: string): Promise<string>;
38
+
37
39
  }
38
40
 
39
41
  interface PreFlightOnlyService {
@@ -58,7 +58,8 @@ function exposeASMailCAP(cap, expServices) {
58
58
  removeMsg: removeMsg.wrapService(box.removeMsg),
59
59
  subscribe: inboxSubscribe.wrapService(box.subscribe, expServices)
60
60
  },
61
- config: exposeConfigCAP(cap.config)
61
+ config: exposeConfigCAP(cap.config),
62
+ getReportAddressForDomain: (0, service_side_wrap_1.wrapReqReplyFunc)(cap, cap.getReportAddressForDomain)
62
63
  };
63
64
  }
64
65
  }
@@ -83,7 +84,8 @@ function makeASMailBasedOnListing(caller, objPath, capLists) {
83
84
  removeMsg: removeMsg.makeCaller(caller, inboxPath),
84
85
  subscribe: inboxSubscribe.makeCaller(caller, inboxPath)
85
86
  },
86
- config: makeConfigCaller(caller, objPath.concat('config'))
87
+ config: makeConfigCaller(caller, objPath.concat('config')),
88
+ getReportAddressForDomain: (0, caller_side_wrap_1.makeReqRepFuncCaller)(caller, objPath.concat('getReportAddressForDomain'))
87
89
  };
88
90
  }
89
91
  else if (capLists === 'preflight') {
@@ -23,6 +23,7 @@ export declare class ASMail {
23
23
  private delivery;
24
24
  private config;
25
25
  private sendingParams;
26
+ private getReportAddressForDomain;
26
27
  constructor(cryptor: AsyncSBoxCryptor, random: AsyncRNG, makeNet: MakeNet, inboxPathForUser: InboxPathForUser, logger: Logger);
27
28
  init(address: string, getSigner: GetSigner, syncedFS: WritableFS, localFS: WritableFS, getStorages: StorageGetter, makeResolver: ServiceLocatorMaker, config: ConfigOfASMailServer, keyring: KeyringForASMail): Promise<void>;
28
29
  private setupSendingParams;
@@ -38,11 +38,13 @@ class ASMail {
38
38
  this.delivery = undefined;
39
39
  this.config = undefined;
40
40
  this.sendingParams = undefined;
41
+ this.getReportAddressForDomain = undefined;
41
42
  Object.seal(this);
42
43
  }
43
44
  async init(address, getSigner, syncedFS, localFS, getStorages, makeResolver, config, keyring) {
44
45
  try {
45
46
  this.address = address;
47
+ this.getReportAddressForDomain = makeResolver('report', this.logger.logError);
46
48
  // XXX this should be part of proper syncing logic
47
49
  // await getRemoteFolderChanges(syncedFS);
48
50
  this.config = config;
@@ -112,7 +114,8 @@ class ASMail {
112
114
  getUserId: async () => this.address,
113
115
  delivery: this.delivery.makeCAP(),
114
116
  inbox: this.inbox.makeCAP(),
115
- config: this.config.makeCAP()
117
+ config: this.config.makeCAP(),
118
+ getReportAddressForDomain: this.getReportAddressForDomain
116
119
  };
117
120
  return Object.freeze(w);
118
121
  }
@@ -28,7 +28,7 @@ export declare function mailerIdInfoAt(client: NetClient, url: string): Promise<
28
28
  */
29
29
  export declare function storageInfoAt(client: NetClient, url: string): Promise<StorageRootRoute>;
30
30
  export type ServiceTypeDNSLabel = 'mailerid' | 'asmail' | '3nstorage';
31
- export type ServiceLocatorMaker = (serviceLabel: ServiceTypeDNSLabel, logError: LogError) => ServiceLocator;
31
+ export type ServiceLocatorMaker = (serviceLabel: ServiceTypeDNSLabel | 'report', logError: LogError) => ServiceLocator;
32
32
  export type ServiceLocator = (address: string) => Promise<string>;
33
33
  export interface DnsResolver {
34
34
  resolveTxt: (typeof dnsPromises)['resolveTxt'];
@@ -188,7 +188,8 @@ function extractPair(txtRecords, serviceLabel) {
188
188
  const recordsStarts = {
189
189
  "3nstorage": '3nstorage=',
190
190
  asmail: 'asmail=',
191
- mailerid: 'mailerid='
191
+ mailerid: 'mailerid=',
192
+ report: 'report='
192
193
  };
193
194
  function getRecordAtStartOf(txt) {
194
195
  let service = undefined;
@@ -276,7 +277,12 @@ function makeServiceLocator(...resolvers) {
276
277
  }
277
278
  const recValue = extractPair(txtRecords, serviceLabel);
278
279
  if (recValue) {
279
- return checkAndPrepareURL(recValue);
280
+ if (serviceLabel === 'report') {
281
+ return recValue;
282
+ }
283
+ else {
284
+ return checkAndPrepareURL(recValue);
285
+ }
280
286
  }
281
287
  else {
282
288
  exc !== null && exc !== void 0 ? exc : (exc = noServiceRecordExc(address));
@@ -21,6 +21,7 @@ const setups_1 = require("../libs-for-tests/setups");
21
21
  const spec_module_1 = require("../libs-for-tests/spec-module");
22
22
  const path_1 = require("path");
23
23
  const assert_1 = require("../../lib-common/assert");
24
+ const canonical_address_1 = require("../../lib-common/canonical-address");
24
25
  describe('ASMail', () => {
25
26
  const s = (0, setups_1.setupWithUsers)(true, ['Bob Perkins @company.inc', 'John Morrison @bank.com']);
26
27
  beforeAll(() => {
@@ -35,6 +36,7 @@ describe('ASMail', () => {
35
36
  expect(typeof w3n.mail.inbox).toBe('object');
36
37
  expect(typeof w3n.mail.config).toBe('object');
37
38
  expect(typeof w3n.mail.getUserId).toBe('function');
39
+ expect(typeof w3n.mail.getReportAddressForDomain).toBe('function');
38
40
  }
39
41
  }, undefined, s);
40
42
  (0, jasmine_utils_1.itCond)('gets current user id', async () => {
@@ -82,5 +84,14 @@ describe('ASMail', () => {
82
84
  expect(msgs.length).toBe(0);
83
85
  }
84
86
  }, undefined, s);
87
+ (0, jasmine_utils_1.itCond)('hosts report address getting', async () => {
88
+ (0, assert_1.assert)(s.users.length > 0);
89
+ for (const u of s.users) {
90
+ const w3n = s.testAppCapsByUser(u);
91
+ const address = await w3n.mail.getUserId();
92
+ expect(typeof address).toBe('string');
93
+ expect((0, canonical_address_1.checkAndTransformAddress)(address)).toBeTruthy();
94
+ }
95
+ }, undefined, s);
85
96
  (0, spec_module_1.loadSpecs)(s, (0, path_1.join)(__dirname, 'asmail', 'specs'));
86
97
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "core-3nweb-client-lib",
3
- "version": "0.50.6",
3
+ "version": "0.51.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",
@@ -51,7 +51,7 @@
51
51
  "lodash": "^4.18.1",
52
52
  "napi-nacl": "^1.2.1",
53
53
  "protobufjs-cli": "^1.0.2",
54
- "spec-3nweb-server": "^1.8.6",
54
+ "spec-3nweb-server": "^1.8.11",
55
55
  "tsuml2": "^0.17.1",
56
56
  "typescript": "^5.5.3"
57
57
  }