core-3nweb-client-lib 0.25.5 → 0.25.6
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/ipc-via-protobuf/asmail-cap.js +2 -2
- package/build/ipc-via-protobuf/file.js +4 -4
- package/build/ipc-via-protobuf/fs.js +2 -2
- package/build/ipc-via-protobuf/mailerid.js +3 -2
- package/build/ipc-via-protobuf/protobuf-msg.d.ts +2 -0
- package/build/ipc-via-protobuf/protobuf-msg.js +11 -1
- package/package.json +1 -1
|
@@ -75,7 +75,7 @@ var getUserId;
|
|
|
75
75
|
function wrapService(fn) {
|
|
76
76
|
return () => {
|
|
77
77
|
const promise = fn()
|
|
78
|
-
.then(userId =>
|
|
78
|
+
.then(userId => protobuf_msg_1.encodeToUtf8(userId));
|
|
79
79
|
return { promise };
|
|
80
80
|
};
|
|
81
81
|
}
|
|
@@ -87,7 +87,7 @@ var getUserId;
|
|
|
87
87
|
if (!buf) {
|
|
88
88
|
throw connector_1.makeIPCException({ missingBodyBytes: true });
|
|
89
89
|
}
|
|
90
|
-
return
|
|
90
|
+
return protobuf_msg_1.decodeFromUtf8(buf);
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
93
|
getUserId.makeCaller = makeCaller;
|
|
@@ -276,7 +276,7 @@ var readTxt;
|
|
|
276
276
|
function wrapService(fn) {
|
|
277
277
|
return () => {
|
|
278
278
|
const promise = fn()
|
|
279
|
-
.then(txt =>
|
|
279
|
+
.then(txt => protobuf_msg_1.encodeToUtf8(txt));
|
|
280
280
|
return { promise };
|
|
281
281
|
};
|
|
282
282
|
}
|
|
@@ -285,13 +285,13 @@ var readTxt;
|
|
|
285
285
|
const path = objPath.concat('readTxt');
|
|
286
286
|
return () => caller
|
|
287
287
|
.startPromiseCall(path, undefined)
|
|
288
|
-
.then(buf => (buf ?
|
|
288
|
+
.then(buf => (buf ? protobuf_msg_1.decodeFromUtf8(buf) : ''));
|
|
289
289
|
}
|
|
290
290
|
readTxt.makeCaller = makeCaller;
|
|
291
291
|
})(readTxt || (readTxt = {}));
|
|
292
292
|
Object.freeze(readTxt);
|
|
293
293
|
function packJSON(json) {
|
|
294
|
-
return
|
|
294
|
+
return protobuf_msg_1.encodeToUtf8(JSON.stringify(json));
|
|
295
295
|
}
|
|
296
296
|
exports.packJSON = packJSON;
|
|
297
297
|
function unpackJSON(buf) {
|
|
@@ -299,7 +299,7 @@ function unpackJSON(buf) {
|
|
|
299
299
|
throw connector_1.makeIPCException({ missingBodyBytes: true });
|
|
300
300
|
}
|
|
301
301
|
try {
|
|
302
|
-
return JSON.parse(
|
|
302
|
+
return JSON.parse(protobuf_msg_1.decodeFromUtf8(buf));
|
|
303
303
|
}
|
|
304
304
|
catch (err) {
|
|
305
305
|
throw error_1.errWithCause(err, `Can't parse ipc reply as json`);
|
|
@@ -531,7 +531,7 @@ var readTxtFile;
|
|
|
531
531
|
return buf => {
|
|
532
532
|
const { path } = reqWithPathType.unpack(buf);
|
|
533
533
|
const promise = fn(path)
|
|
534
|
-
.then(txt =>
|
|
534
|
+
.then(txt => protobuf_msg_1.encodeToUtf8(txt));
|
|
535
535
|
return { promise };
|
|
536
536
|
};
|
|
537
537
|
}
|
|
@@ -540,7 +540,7 @@ var readTxtFile;
|
|
|
540
540
|
const ipcPath = objPath.concat('readTxtFile');
|
|
541
541
|
return path => caller
|
|
542
542
|
.startPromiseCall(ipcPath, reqWithPathType.pack({ path }))
|
|
543
|
-
.then(buf => (buf ?
|
|
543
|
+
.then(buf => (buf ? protobuf_msg_1.decodeFromUtf8(buf) : ''));
|
|
544
544
|
}
|
|
545
545
|
readTxtFile.makeCaller = makeCaller;
|
|
546
546
|
})(readTxtFile || (readTxtFile = {}));
|
|
@@ -20,6 +20,7 @@ exports.makeMailerIdCaller = exports.exposeMailerIdCAP = void 0;
|
|
|
20
20
|
const connector_1 = require("./connector");
|
|
21
21
|
const protobuf_type_1 = require("../lib-client/protobuf-type");
|
|
22
22
|
const mailerid_proto_1 = require("../protos/mailerid.proto");
|
|
23
|
+
const protobuf_msg_1 = require("./protobuf-msg");
|
|
23
24
|
function exposeMailerIdCAP(cap) {
|
|
24
25
|
return {
|
|
25
26
|
getUserId: getUserId.wrapService(cap.getUserId),
|
|
@@ -39,7 +40,7 @@ var getUserId;
|
|
|
39
40
|
function wrapService(fn) {
|
|
40
41
|
return () => {
|
|
41
42
|
const promise = fn()
|
|
42
|
-
.then(userId =>
|
|
43
|
+
.then(userId => protobuf_msg_1.encodeToUtf8(userId));
|
|
43
44
|
return { promise };
|
|
44
45
|
};
|
|
45
46
|
}
|
|
@@ -51,7 +52,7 @@ var getUserId;
|
|
|
51
52
|
if (!buf) {
|
|
52
53
|
throw connector_1.makeIPCException({ missingBodyBytes: true });
|
|
53
54
|
}
|
|
54
|
-
return
|
|
55
|
+
return protobuf_msg_1.decodeFromUtf8(buf);
|
|
55
56
|
});
|
|
56
57
|
}
|
|
57
58
|
getUserId.makeCaller = makeCaller;
|
|
@@ -42,4 +42,6 @@ export interface AnyValue {
|
|
|
42
42
|
}
|
|
43
43
|
export declare function toOptAny(value: any | undefined): AnyValue | undefined;
|
|
44
44
|
export declare function valOfOptAny(valObj: AnyValue | undefined): any | undefined;
|
|
45
|
+
export declare function encodeToUtf8(str: string): Uint8Array;
|
|
46
|
+
export declare function decodeFromUtf8(bytes: Uint8Array): string;
|
|
45
47
|
export {};
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.valOfOptAny = exports.toOptAny = exports.toOptJson = exports.valOfOptJson = exports.valOfOpt = exports.valOf = exports.toOptVal = exports.toVal = exports.errFromMsg = exports.errToMsg = exports.errBodyType = exports.unpackInt = exports.packInt = exports.valOfOptInt = exports.fixInt = exports.fixArray = exports.strArrValType = exports.boolValType = exports.objRefType = void 0;
|
|
19
|
+
exports.decodeFromUtf8 = exports.encodeToUtf8 = exports.valOfOptAny = exports.toOptAny = exports.toOptJson = exports.valOfOptJson = exports.valOfOpt = exports.valOf = exports.toOptVal = exports.toVal = exports.errFromMsg = exports.errToMsg = exports.errBodyType = exports.unpackInt = exports.packInt = exports.valOfOptInt = exports.fixInt = exports.fixArray = exports.strArrValType = exports.boolValType = exports.objRefType = void 0;
|
|
20
20
|
const connector_1 = require("./connector");
|
|
21
21
|
const error_1 = require("../lib-common/exceptions/error");
|
|
22
22
|
const buffer_utils_1 = require("../lib-common/buffer-utils");
|
|
@@ -152,4 +152,14 @@ function valOfOptAny(valObj) {
|
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
exports.valOfOptAny = valOfOptAny;
|
|
155
|
+
function encodeToUtf8(str) {
|
|
156
|
+
const enc = new TextEncoder();
|
|
157
|
+
return enc.encode(str);
|
|
158
|
+
}
|
|
159
|
+
exports.encodeToUtf8 = encodeToUtf8;
|
|
160
|
+
function decodeFromUtf8(bytes) {
|
|
161
|
+
const dec = new TextDecoder();
|
|
162
|
+
return dec.decode(bytes);
|
|
163
|
+
}
|
|
164
|
+
exports.decodeFromUtf8 = decodeFromUtf8;
|
|
155
165
|
Object.freeze(exports);
|