core-3nweb-client-lib 0.41.8 → 0.41.10
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/api-defs/keys.d.ts +1 -1
- package/build/api-defs/mailerid.d.ts +1 -1
- package/build/lib-client/cryptor/worker-js.js +0 -10
- package/build/lib-client/mailer-id/provisioner.js +15 -7
- package/build/lib-client/service-locator.d.ts +7 -15
- package/build/lib-client/service-locator.js +6 -6
- package/build/lib-common/buffer-utils.d.ts +1 -1
- package/build/lib-common/objs-on-disk/v1-obj-file-format.d.ts +1 -1
- package/build/lib-common/service-api/3nstorage/root-route.d.ts +5 -0
- package/build/lib-common/service-api/3nstorage/root-route.js +18 -0
- package/build/lib-common/service-api/asmail/root-route.d.ts +5 -0
- package/build/lib-common/service-api/asmail/root-route.js +18 -0
- package/build/lib-common/service-api/mailer-id/root-route.d.ts +7 -0
- package/build/lib-common/service-api/mailer-id/root-route.js +18 -0
- package/build/protos/asmail.proto.js +387 -129
- package/build/protos/bytes.proto.js +54 -18
- package/build/protos/common.proto.js +27 -9
- package/build/protos/cryptor.proto.js +21 -7
- package/build/protos/file.proto.js +144 -48
- package/build/protos/fs.proto.js +321 -107
- package/build/protos/ipc.proto.js +33 -11
- package/build/protos/json-ipc.proto.js +39 -13
- package/build/protos/storage.proto.js +39 -13
- package/package.json +2 -2
package/build/api-defs/keys.d.ts
CHANGED
|
@@ -19,16 +19,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
19
19
|
const worker_threads_1 = require("worker_threads");
|
|
20
20
|
const ecma_nacl_1 = require("ecma-nacl");
|
|
21
21
|
const error_1 = require("../../lib-common/exceptions/error");
|
|
22
|
-
function transfer(...arrs) {
|
|
23
|
-
const transferLst = [];
|
|
24
|
-
for (const arr of arrs) {
|
|
25
|
-
const buffer = arr.buffer;
|
|
26
|
-
if (!transferLst.includes(buffer)) {
|
|
27
|
-
transferLst.push(buffer);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return transferLst;
|
|
31
|
-
}
|
|
32
22
|
if (!worker_threads_1.parentPort) {
|
|
33
23
|
throw new Error(`Missing expected parentPort. Is this called within WebWorker process?`);
|
|
34
24
|
}
|
|
@@ -58,10 +58,10 @@ class MailerIdProvisioner extends user_with_pkl_session_1.ServiceUser {
|
|
|
58
58
|
Object.seal(this);
|
|
59
59
|
}
|
|
60
60
|
async setUrlAndDomain() {
|
|
61
|
-
const
|
|
61
|
+
const { currentCert, provisioning } = await (0, service_locator_1.mailerIdInfoAt)(this.net, this.entryURI);
|
|
62
62
|
this.midDomain = (0, url_1.parse)(this.serviceURI).hostname;
|
|
63
|
-
this.serviceURI =
|
|
64
|
-
this.rootCert =
|
|
63
|
+
this.serviceURI = provisioning;
|
|
64
|
+
this.rootCert = currentCert;
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
67
|
* @param pkey is a public key, that needs to be certified.
|
|
@@ -73,10 +73,7 @@ class MailerIdProvisioner extends user_with_pkl_session_1.ServiceUser {
|
|
|
73
73
|
*/
|
|
74
74
|
async getCertificates(pkey, duration) {
|
|
75
75
|
(0, assert_1.assert)(!!this.encryptor);
|
|
76
|
-
const plainReqData = {
|
|
77
|
-
pkey: pkey,
|
|
78
|
-
duration: duration
|
|
79
|
-
};
|
|
76
|
+
const plainReqData = { pkey, duration };
|
|
80
77
|
const rep = await this.net.doBinaryRequest({
|
|
81
78
|
url: this.serviceURI + api.certify.URL_END,
|
|
82
79
|
method: api.certify.method,
|
|
@@ -95,6 +92,17 @@ class MailerIdProvisioner extends user_with_pkl_session_1.ServiceUser {
|
|
|
95
92
|
if (!certs.userCert || !certs.provCert) {
|
|
96
93
|
throw (0, request_utils_1.makeException)(rep, 'Malformed reply: Certificates are missing.');
|
|
97
94
|
}
|
|
95
|
+
if (certs.provCert.kid !== this.rootCert.kid) {
|
|
96
|
+
const { currentCert, previousCerts } = await (0, service_locator_1.mailerIdInfoAt)(this.net, this.entryURI);
|
|
97
|
+
const rootCert = ((currentCert.kid === certs.provCert.kid) ?
|
|
98
|
+
currentCert : previousCerts.find(cert => (cert.kid === certs.provCert.kid)));
|
|
99
|
+
if (rootCert) {
|
|
100
|
+
this.rootCert = rootCert;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
throw (0, request_utils_1.makeException)(rep, 'Malformed reply: referenced root MailerId certificate id is unknown.');
|
|
104
|
+
}
|
|
105
|
+
}
|
|
98
106
|
const pkeyAndId = (0, relying_party_1.verifyChainAndGetUserKey)({ user: certs.userCert, prov: certs.provCert, root: this.rootCert }, this.midDomain, (0, jwkeys_1.getKeyCert)(certs.userCert).issuedAt + 1);
|
|
99
107
|
if (pkeyAndId.address !== (0, canonical_address_1.toCanonicalAddress)(this.userId)) {
|
|
100
108
|
throw (0, request_utils_1.makeException)(rep, 'Malformed reply: Certificate is for a wrong address.');
|
|
@@ -1,39 +1,31 @@
|
|
|
1
1
|
import { NetClient } from './request-utils';
|
|
2
2
|
import { promises as dnsPromises } from 'dns';
|
|
3
|
+
import { StorageRootRoute } from '../lib-common/service-api/3nstorage/root-route';
|
|
4
|
+
import { ASMailRootRoute } from '../lib-common/service-api/asmail/root-route';
|
|
3
5
|
type SignedLoad = web3n.keys.SignedLoad;
|
|
4
|
-
export interface ASMailRoutes {
|
|
5
|
-
delivery?: string;
|
|
6
|
-
retrieval?: string;
|
|
7
|
-
config?: string;
|
|
8
|
-
}
|
|
9
6
|
/**
|
|
10
|
-
* This returns a promise, resolvable to
|
|
7
|
+
* This returns a promise, resolvable to ASMailRootRoute object.
|
|
11
8
|
* @param client
|
|
12
9
|
* @param url
|
|
13
10
|
*/
|
|
14
|
-
export declare function asmailInfoAt(client: NetClient, url: string): Promise<
|
|
11
|
+
export declare function asmailInfoAt(client: NetClient, url: string): Promise<ASMailRootRoute>;
|
|
15
12
|
export interface MailerIdServiceInfo {
|
|
16
13
|
provisioning: string;
|
|
17
14
|
currentCert: SignedLoad;
|
|
18
15
|
previousCerts: SignedLoad[];
|
|
19
16
|
}
|
|
20
17
|
/**
|
|
21
|
-
* This returns a promise, resolvable to
|
|
18
|
+
* This returns a promise, resolvable to MailerIdRootRoute object.
|
|
22
19
|
* @param client
|
|
23
20
|
* @param url
|
|
24
21
|
*/
|
|
25
22
|
export declare function mailerIdInfoAt(client: NetClient, url: string): Promise<MailerIdServiceInfo>;
|
|
26
|
-
export interface StorageRoutes {
|
|
27
|
-
owner?: string;
|
|
28
|
-
shared?: string;
|
|
29
|
-
config?: string;
|
|
30
|
-
}
|
|
31
23
|
/**
|
|
32
|
-
* This returns a promise, resolvable to
|
|
24
|
+
* This returns a promise, resolvable to StorageRootRoute object.
|
|
33
25
|
* @param client
|
|
34
26
|
* @param url
|
|
35
27
|
*/
|
|
36
|
-
export declare function storageInfoAt(client: NetClient, url: string): Promise<
|
|
28
|
+
export declare function storageInfoAt(client: NetClient, url: string): Promise<StorageRootRoute>;
|
|
37
29
|
export type ServiceTypeDNSLabel = 'mailerid' | 'asmail' | '3nstorage';
|
|
38
30
|
export type ServiceLocatorMaker = (serviceLabel: ServiceTypeDNSLabel) => ServiceLocator;
|
|
39
31
|
export type ServiceLocator = (address: string) => Promise<string>;
|
|
@@ -59,7 +59,7 @@ function transformPathToCompleteUri(url, path, rep) {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
62
|
-
* This returns a promise, resolvable to
|
|
62
|
+
* This returns a promise, resolvable to ASMailRootRoute object.
|
|
63
63
|
* @param client
|
|
64
64
|
* @param url
|
|
65
65
|
*/
|
|
@@ -80,7 +80,7 @@ async function asmailInfoAt(client, url) {
|
|
|
80
80
|
return transform;
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
|
-
* This returns a promise, resolvable to
|
|
83
|
+
* This returns a promise, resolvable to MailerIdRootRoute object.
|
|
84
84
|
* @param client
|
|
85
85
|
* @param url
|
|
86
86
|
*/
|
|
@@ -94,10 +94,10 @@ async function mailerIdInfoAt(client, url) {
|
|
|
94
94
|
else {
|
|
95
95
|
throw (0, request_utils_1.makeException)(rep, 'Malformed reply');
|
|
96
96
|
}
|
|
97
|
-
if ((
|
|
98
|
-
(0, jwkeys_1.isLikeSignedKeyCert)(json["current-cert"])) {
|
|
97
|
+
if ((0, jwkeys_1.isLikeSignedKeyCert)(json["current-cert"])) {
|
|
99
98
|
transform.currentCert = json["current-cert"];
|
|
100
|
-
transform.previousCerts = json["previous-certs"]
|
|
99
|
+
transform.previousCerts = (Array.isArray(json["previous-certs"]) ?
|
|
100
|
+
json["previous-certs"].filter(jwkeys_1.isLikeSignedKeyCert) : []);
|
|
101
101
|
}
|
|
102
102
|
else {
|
|
103
103
|
throw (0, request_utils_1.makeException)(rep, 'Malformed reply');
|
|
@@ -106,7 +106,7 @@ async function mailerIdInfoAt(client, url) {
|
|
|
106
106
|
return transform;
|
|
107
107
|
}
|
|
108
108
|
/**
|
|
109
|
-
* This returns a promise, resolvable to
|
|
109
|
+
* This returns a promise, resolvable to StorageRootRoute object.
|
|
110
110
|
* @param client
|
|
111
111
|
* @param url
|
|
112
112
|
*/
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2025 3NSoft Inc.
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
6
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
See the GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License along with
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2025 3NSoft Inc.
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
6
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
See the GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License along with
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2025 3NSoft Inc.
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
6
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
See the GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License along with
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|