core-3nweb-client-lib 0.34.0 → 0.34.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.
- package/build/core/asmail/key-verification.js +18 -9
- package/build/core-ipc/json-ipc-wrapping/service-side-wrap.js +9 -1
- package/build/lib-client/cryptor/cryptor-wasm.js +1 -1
- package/build/lib-client/cryptor/cryptor.wasm +0 -0
- package/build/lib-common/jwkeys.d.ts +2 -2
- package/build/lib-common/jwkeys.js +4 -6
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2016 - 2017 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2016 - 2017, 2025 3NSoft Inc.
|
|
4
4
|
|
|
5
5
|
This program is free software: you can redistribute it and/or modify it under
|
|
6
6
|
the terms of the GNU General Public License as published by the Free Software
|
|
@@ -34,13 +34,25 @@ async function checkAndExtractPKey(client, resolver, address, certs) {
|
|
|
34
34
|
address = (0, canonical_address_1.toCanonicalAddress)(address);
|
|
35
35
|
const validAt = Math.round(Date.now() / 1000);
|
|
36
36
|
// get MailerId provider's info with a root certificate(s)
|
|
37
|
-
const
|
|
38
|
-
// TODO choose proper root certificate, as it may not be current one
|
|
39
|
-
const rootAddr = data.domain;
|
|
40
|
-
const rootCert = data.info.currentCert;
|
|
37
|
+
const { domain: rootAddr, rootCert } = await getRootCertForKey(certs.provCert.kid, resolver, client, address);
|
|
41
38
|
const pkey = mid_sigs_NaCl_Ed_1.relyingParty.verifyPubKey(certs.pkeyCert, address, { user: certs.userCert, prov: certs.provCert, root: rootCert }, rootAddr, validAt);
|
|
42
39
|
return pkey;
|
|
43
40
|
}
|
|
41
|
+
async function getRootCertForKey(kid, resolver, client, address) {
|
|
42
|
+
const { domain, info: { currentCert, previousCerts } } = await (0, service_locator_1.getMailerIdInfoFor)(resolver, client, address);
|
|
43
|
+
let rootCert;
|
|
44
|
+
if (currentCert.kid === kid) {
|
|
45
|
+
rootCert = currentCert;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
const pastCert = previousCerts.find((cert) => (cert.kid === kid));
|
|
49
|
+
if (!pastCert) {
|
|
50
|
+
throw new Error(`Root cert for given key id is not found in server's reply.`);
|
|
51
|
+
}
|
|
52
|
+
rootCert = pastCert;
|
|
53
|
+
}
|
|
54
|
+
return { domain, rootCert };
|
|
55
|
+
}
|
|
44
56
|
/**
|
|
45
57
|
* This returns a promise, resolvable to public key and related address, when
|
|
46
58
|
* certificates' verification is successful, and rejectable in all other cases.
|
|
@@ -62,10 +74,7 @@ async function checkAndExtractPKeyWithAddress(client, resolver, certs, validAt)
|
|
|
62
74
|
throw (0, mid_sigs_NaCl_Ed_1.makeMalformedCertsException)(`Cannot read public key certificate`, err);
|
|
63
75
|
}
|
|
64
76
|
// get MailerId provider's info with a root certificate(s)
|
|
65
|
-
const
|
|
66
|
-
// TODO choose proper root certificate, as it may not be current one
|
|
67
|
-
const rootAddr = data.domain;
|
|
68
|
-
const rootCert = data.info.currentCert;
|
|
77
|
+
const { domain: rootAddr, rootCert } = await getRootCertForKey(certs.provCert.kid, resolver, client, address);
|
|
69
78
|
const pkey = mid_sigs_NaCl_Ed_1.relyingParty.verifyPubKey(certs.pkeyCert, address, { user: certs.userCert, prov: certs.provCert, root: rootCert }, rootAddr, validAt);
|
|
70
79
|
return { address, pkey };
|
|
71
80
|
}
|
|
@@ -41,7 +41,15 @@ function wrapReqReplyFunc(srvOrFn, funcOrTransforms, transforms) {
|
|
|
41
41
|
let promise = (args ?
|
|
42
42
|
func.call(srv, ...args) :
|
|
43
43
|
func.call(srv));
|
|
44
|
-
|
|
44
|
+
if (promise === undefined) {
|
|
45
|
+
promise = Promise.resolve();
|
|
46
|
+
}
|
|
47
|
+
else if ((promise === null) || !promise.then) {
|
|
48
|
+
promise = Promise.resolve(resultToBuffer(promise, transforms));
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
promise = promise.then(result => resultToBuffer(result, transforms));
|
|
52
|
+
}
|
|
45
53
|
return { promise };
|
|
46
54
|
};
|
|
47
55
|
}
|