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.
@@ -96,7 +96,7 @@ declare namespace web3n.keys {
96
96
  */
97
97
  alg: string;
98
98
  /**
99
- * This is an id of a key that did the signature.
99
+ * This is an id of a key that created the signature.
100
100
  */
101
101
  kid: string;
102
102
  /**
@@ -71,7 +71,7 @@ declare namespace web3n.mailerid {
71
71
  'all-ok'
72
72
  | 'unknown-root-cert'
73
73
  | 'not-current-provider'
74
- |'dns-not-set'
74
+ | 'dns-not-set'
75
75
  | 'offline-no-check'
76
76
  | 'other-fail';
77
77
 
@@ -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 info = await (0, service_locator_1.mailerIdInfoAt)(this.net, this.entryURI);
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 = info.provisioning;
64
- this.rootCert = info.currentCert;
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 ASMailRoutes object.
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<ASMailRoutes>;
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 MailerIdRoutes object.
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 StorageRoutes object.
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<StorageRoutes>;
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 ASMailRoutes object.
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 MailerIdRoutes object.
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 (('object' === typeof json["current-cert"]) &&
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 StorageRoutes object.
109
+ * This returns a promise, resolvable to StorageRootRoute object.
110
110
  * @param client
111
111
  * @param url
112
112
  */
@@ -1,4 +1,4 @@
1
- export declare const EMPTY_BUFFER: Buffer;
1
+ export declare const EMPTY_BUFFER: Buffer<ArrayBuffer>;
2
2
  /**
3
3
  * Buffer and Uint8Array are intimately linked in Node, starting with some
4
4
  * version. As a result, Uint8Array can be efficiently turned into Buffer,
@@ -1,5 +1,5 @@
1
1
  import { HeaderChunkInfo, SegsChunk } from "./file-layout";
2
- export declare const V1_FILE_START: Buffer;
2
+ export declare const V1_FILE_START: Buffer<ArrayBuffer>;
3
3
  export declare namespace layoutV1 {
4
4
  interface Attrs {
5
5
  fileComplete: boolean;
@@ -0,0 +1,5 @@
1
+ export interface StorageRootRoute {
2
+ owner?: string;
3
+ shared?: string;
4
+ config?: string;
5
+ }
@@ -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,5 @@
1
+ export interface ASMailRootRoute {
2
+ delivery?: string;
3
+ retrieval?: string;
4
+ config?: string;
5
+ }
@@ -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,7 @@
1
+ type SignedLoad = web3n.keys.SignedLoad;
2
+ export interface MailerIdRootRoute {
3
+ "current-cert": SignedLoad;
4
+ "previous-certs": SignedLoad[];
5
+ provisioning: string;
6
+ }
7
+ export {};
@@ -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 });