core-3nweb-client-lib 0.37.0 → 0.37.2

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.
@@ -36,6 +36,13 @@ declare namespace web3n.asmail {
36
36
 
37
37
  }
38
38
 
39
+ interface PreFlightOnlyService {
40
+ getUserId: Service['getUserId'];
41
+ delivery: {
42
+ preFlight: DeliveryService['preFlight'];
43
+ }
44
+ }
45
+
39
46
  interface DeliveryProgress {
40
47
  notConnected?: true;
41
48
  allDone?: 'all-ok' | 'with-errors';
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright (C) 2016 - 2018, 2020 3NSoft Inc.
2
+ Copyright (C) 2016 - 2018, 2020, 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
@@ -33,6 +33,21 @@ declare namespace web3n {
33
33
  message?: string;
34
34
  }
35
35
 
36
+ interface HTTPErrorDetails extends web3n.RuntimeException {
37
+ url: string;
38
+ method: string;
39
+ message?: string;
40
+ }
41
+
42
+ interface ConnectException extends HTTPErrorDetails {
43
+ type: 'http-connect';
44
+ }
45
+
46
+ interface HTTPException extends HTTPErrorDetails {
47
+ type: 'http-request';
48
+ status: number;
49
+ }
50
+
36
51
  interface EncryptionException {
37
52
  failedCipherVerification?: true;
38
53
  failedSignatureVerification?: true;
@@ -1,5 +1,7 @@
1
1
  import { ExposedObj, Caller, CoreSideServices } from '../../ipc-via-protobuf/connector';
2
2
  type ASMailService = web3n.asmail.Service;
3
- export declare function exposeASMailCAP(cap: ASMailService, expServices: CoreSideServices): ExposedObj<ASMailService>;
4
- export declare function makeASMailCaller(caller: Caller, objPath: string[]): ASMailService;
3
+ type PreFlight = web3n.asmail.PreFlightOnlyService;
4
+ export declare function exposeASMailCAP(cap: ASMailService, expServices: CoreSideServices): ExposedObj<ASMailService> | ExposedObj<PreFlight>;
5
+ export declare function makeASMailCaller(caller: Caller, objPath: string[]): ASMailService | PreFlight;
6
+ export declare function promiseASMailCaller(caller: Caller, objPath: string[]): Promise<ASMailService | PreFlight>;
5
7
  export {};
@@ -18,6 +18,7 @@
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.exposeASMailCAP = exposeASMailCAP;
20
20
  exports.makeASMailCaller = makeASMailCaller;
21
+ exports.promiseASMailCaller = promiseASMailCaller;
21
22
  const protobuf_msg_1 = require("../../ipc-via-protobuf/protobuf-msg");
22
23
  const protobuf_type_1 = require("../../lib-client/protobuf-type");
23
24
  const asmail_proto_1 = require("../../protos/asmail.proto");
@@ -31,48 +32,87 @@ const service_side_wrap_1 = require("../../core-ipc/json-ipc-wrapping/service-si
31
32
  function exposeASMailCAP(cap, expServices) {
32
33
  const out = cap.delivery;
33
34
  const box = cap.inbox;
34
- return {
35
- getUserId: getUserId.wrapService(cap.getUserId),
36
- delivery: {
37
- addMsg: addMsg.wrapService(out.addMsg, expServices),
38
- currentState: currentState.wrapService(out.currentState),
39
- listMsgs: delivListMsgs.wrapService(out.listMsgs),
40
- observeAllDeliveries: observeAllDeliveries.wrapService(out.observeAllDeliveries),
41
- observeDelivery: observeDelivery.wrapService(out.observeDelivery),
42
- preFlight: preFlight.wrapService(out.preFlight),
43
- rmMsg: rmMsg.wrapService(out.rmMsg)
44
- },
45
- inbox: {
46
- getMsg: getMsg.wrapService(box.getMsg, expServices),
47
- listMsgs: inboxListMsgs.wrapService(box.listMsgs),
48
- removeMsg: removeMsg.wrapService(box.removeMsg),
49
- subscribe: inboxSubscribe.wrapService(box.subscribe, expServices)
50
- },
51
- config: exposeCofigCAP(cap.config)
52
- };
35
+ if (!box && !out.addMsg) {
36
+ return {
37
+ getUserId: getUserId.wrapService(cap.getUserId),
38
+ delivery: {
39
+ preFlight: preFlight.wrapService(out.preFlight),
40
+ }
41
+ };
42
+ }
43
+ else {
44
+ return {
45
+ getUserId: getUserId.wrapService(cap.getUserId),
46
+ delivery: {
47
+ addMsg: addMsg.wrapService(out.addMsg, expServices),
48
+ currentState: currentState.wrapService(out.currentState),
49
+ listMsgs: delivListMsgs.wrapService(out.listMsgs),
50
+ observeAllDeliveries: observeAllDeliveries.wrapService(out.observeAllDeliveries),
51
+ observeDelivery: observeDelivery.wrapService(out.observeDelivery),
52
+ preFlight: preFlight.wrapService(out.preFlight),
53
+ rmMsg: rmMsg.wrapService(out.rmMsg)
54
+ },
55
+ inbox: {
56
+ getMsg: getMsg.wrapService(box.getMsg, expServices),
57
+ listMsgs: inboxListMsgs.wrapService(box.listMsgs),
58
+ removeMsg: removeMsg.wrapService(box.removeMsg),
59
+ subscribe: inboxSubscribe.wrapService(box.subscribe, expServices)
60
+ },
61
+ config: exposeCofigCAP(cap.config)
62
+ };
63
+ }
53
64
  }
54
- function makeASMailCaller(caller, objPath) {
65
+ function makeASMailBasedOnListing(caller, objPath, capLists) {
55
66
  const delivPath = (0, protobuf_msg_1.methodPathFor)(objPath, 'delivery');
56
67
  const inboxPath = (0, protobuf_msg_1.methodPathFor)(objPath, 'inbox');
57
- return {
58
- getUserId: getUserId.makeCaller(caller, objPath),
59
- delivery: {
60
- addMsg: addMsg.makeCaller(caller, delivPath),
61
- currentState: currentState.makeCaller(caller, delivPath),
62
- listMsgs: delivListMsgs.makeCaller(caller, delivPath),
63
- observeAllDeliveries: observeAllDeliveries.makeCaller(caller, delivPath),
64
- observeDelivery: observeDelivery.makeCaller(caller, delivPath),
65
- preFlight: preFlight.makeCaller(caller, delivPath),
66
- rmMsg: rmMsg.makeCaller(caller, delivPath)
67
- },
68
- inbox: {
69
- getMsg: getMsg.makeCaller(caller, inboxPath),
70
- listMsgs: inboxListMsgs.makeCaller(caller, inboxPath),
71
- removeMsg: removeMsg.makeCaller(caller, inboxPath),
72
- subscribe: inboxSubscribe.makeCaller(caller, inboxPath)
73
- },
74
- config: makeConfigCaller(caller, objPath.concat('config'))
75
- };
68
+ if (capLists === 'asmail') {
69
+ return {
70
+ getUserId: getUserId.makeCaller(caller, objPath),
71
+ delivery: {
72
+ addMsg: addMsg.makeCaller(caller, delivPath),
73
+ currentState: currentState.makeCaller(caller, delivPath),
74
+ listMsgs: delivListMsgs.makeCaller(caller, delivPath),
75
+ observeAllDeliveries: observeAllDeliveries.makeCaller(caller, delivPath),
76
+ observeDelivery: observeDelivery.makeCaller(caller, delivPath),
77
+ preFlight: preFlight.makeCaller(caller, delivPath),
78
+ rmMsg: rmMsg.makeCaller(caller, delivPath)
79
+ },
80
+ inbox: {
81
+ getMsg: getMsg.makeCaller(caller, inboxPath),
82
+ listMsgs: inboxListMsgs.makeCaller(caller, inboxPath),
83
+ removeMsg: removeMsg.makeCaller(caller, inboxPath),
84
+ subscribe: inboxSubscribe.makeCaller(caller, inboxPath)
85
+ },
86
+ config: makeConfigCaller(caller, objPath.concat('config'))
87
+ };
88
+ }
89
+ else if (capLists === 'preflight') {
90
+ return {
91
+ getUserId: getUserId.makeCaller(caller, objPath),
92
+ delivery: {
93
+ preFlight: preFlight.makeCaller(caller, delivPath),
94
+ }
95
+ };
96
+ }
97
+ else {
98
+ throw new Error(`Unknown capLists value ${capLists}`);
99
+ }
100
+ }
101
+ function makeASMailCaller(caller, objPath) {
102
+ if (!caller.listObj) {
103
+ throw new Error(`Caller here expects to have method 'listObj'`);
104
+ }
105
+ const topLst = caller.listObj(objPath);
106
+ const capLists = (topLst.includes('inbox') ? 'asmail' : 'preflight');
107
+ return makeASMailBasedOnListing(caller, objPath, capLists);
108
+ }
109
+ async function promiseASMailCaller(caller, objPath) {
110
+ if (!caller.listObjAsync) {
111
+ throw new Error(`Caller here expects to have method 'listObjAsync'`);
112
+ }
113
+ const topLst = await caller.listObjAsync(objPath);
114
+ const capLists = (topLst.includes('inbox') ? 'asmail' : 'preflight');
115
+ return makeASMailBasedOnListing(caller, objPath, capLists);
76
116
  }
77
117
  var getUserId;
78
118
  (function (getUserId) {
@@ -174,7 +174,7 @@ class Msg {
174
174
  if (typeof this.msgToSend.plainTxtBody === 'string') {
175
175
  msg.setPlainTextBody(this.msgToSend.plainTxtBody);
176
176
  }
177
- else if (typeof this.msgToSend.htmlTxtBody === 'string') {
177
+ if (typeof this.msgToSend.htmlTxtBody === 'string') {
178
178
  msg.setHtmlTextBody(this.msgToSend.htmlTxtBody);
179
179
  }
180
180
  if (this.msgToSend.jsonBody !== undefined) {
@@ -33,9 +33,9 @@ class OpenedMsg {
33
33
  if (!this.msgKeyRole) {
34
34
  throw new Error(`Key role is not set in incoming message ${this.msgId}`);
35
35
  }
36
- return (this.msgKeyRole === 'suggested') ||
36
+ return ((this.msgKeyRole === 'suggested') ||
37
37
  (this.msgKeyRole === 'in_use') ||
38
- (this.msgKeyRole === 'old');
38
+ (this.msgKeyRole === 'old'));
39
39
  }
40
40
  setMsgKeyRole(msgKeyRole) {
41
41
  if (this.msgKeyRole) {
@@ -73,9 +73,9 @@ export declare class MsgPacker {
73
73
  setPlainTextBody(text: string): void;
74
74
  /**
75
75
  * This sets a plain html body.
76
- * @param html
76
+ * @param htmlTxt
77
77
  */
78
- setHtmlTextBody(html: string): void;
78
+ setHtmlTextBody(htmlTxt: string): void;
79
79
  /**
80
80
  * This sets a json body.
81
81
  * @param json
@@ -186,18 +186,18 @@ class MsgPacker {
186
186
  if (!this.mainBody.text) {
187
187
  this.mainBody.text = {};
188
188
  }
189
- this.mainBody.text = { plain: text };
189
+ this.mainBody.text.plain = text;
190
190
  this.wasBodySet = true;
191
191
  }
192
192
  /**
193
193
  * This sets a plain html body.
194
- * @param html
194
+ * @param htmlTxt
195
195
  */
196
- setHtmlTextBody(html) {
196
+ setHtmlTextBody(htmlTxt) {
197
197
  if (!this.mainBody.text) {
198
198
  this.mainBody.text = {};
199
199
  }
200
- this.mainBody.text = { html };
200
+ this.mainBody.text.html = htmlTxt;
201
201
  this.wasBodySet = true;
202
202
  }
203
203
  /**
@@ -54,7 +54,7 @@ function makeW3Nclient(clientSide, extraCAPs) {
54
54
  async function promiseW3Nclient(clientSide, extraCAPs) {
55
55
  const mainCAPs = {
56
56
  log: log_cap_1.makeLogCaller,
57
- mail: asmail_cap_ipc_1.makeASMailCaller,
57
+ mail: asmail_cap_ipc_1.promiseASMailCaller,
58
58
  mailerid: mailerid_cap_ipc_1.makeMailerIdCaller,
59
59
  storage: storage_cap_ipc_1.promiseStorageCaller,
60
60
  keyrings: keyrings_cap_ipc_1.makeKeyringsCaller,
@@ -1,19 +1,4 @@
1
- /**
2
- * This module contains some code and type declarations that are common for
3
- * both main and worker processes.
4
- */
5
- interface HTTPErrorDetails extends web3n.RuntimeException {
6
- url: string;
7
- method: string;
8
- message?: string;
9
- }
10
- export interface ConnectException extends HTTPErrorDetails {
11
- type: 'http-connect';
12
- }
13
- export interface HTTPException extends HTTPErrorDetails {
14
- type: 'http-request';
15
- status: number;
16
- }
1
+ export type ConnectException = web3n.ConnectException;
2
+ export type HTTPException = web3n.HTTPException;
17
3
  export declare function makeConnectionException(url: string | undefined, method: string | undefined, msg?: string, cause?: any): ConnectException;
18
4
  export declare function makeHTTPException(url: string, method: string, status: number, msg?: string, cause?: any): HTTPException;
19
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "core-3nweb-client-lib",
3
- "version": "0.37.0",
3
+ "version": "0.37.2",
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",