core-3nweb-client-lib 0.43.9 → 0.43.12
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/files.d.ts +32 -8
- package/build/api-defs/web3n.d.ts +2 -0
- package/build/core/asmail/inbox/index.js +1 -1
- package/build/core/asmail/inbox/msg-downloader.d.ts +2 -12
- package/build/core/asmail/inbox/msg-downloader.js +13 -46
- package/build/core/storage/synced/downloader.d.ts +6 -15
- package/build/core/storage/synced/downloader.js +25 -48
- package/build/core/storage/synced/obj-files.d.ts +4 -2
- package/build/core/storage/synced/obj-files.js +7 -7
- package/build/core/storage/synced/storage.d.ts +4 -2
- package/build/core/storage/synced/storage.js +2 -2
- package/build/core/storage/synced/upsyncer.d.ts +2 -4
- package/build/core/storage/synced/upsyncer.js +19 -13
- package/build/core-ipc/file.d.ts +10 -0
- package/build/core-ipc/file.js +23 -13
- package/build/core-ipc/fs.js +15 -8
- package/build/lib-client/3nstorage/storage-owner.js +36 -29
- package/build/lib-client/3nweb-signup.js +7 -7
- package/build/lib-client/asmail/recipient.js +14 -11
- package/build/lib-client/asmail/sender.js +24 -25
- package/build/lib-client/asmail/service-config.js +3 -6
- package/build/lib-client/cryptor/cryptor-wasm.js +1 -1
- package/build/lib-client/cryptor/cryptor.wasm +0 -0
- package/build/lib-client/fs-utils/files.js +4 -4
- package/build/lib-client/mailer-id/login.js +7 -7
- package/build/lib-client/mailer-id/provisioner.js +9 -7
- package/build/lib-client/objs-on-disk/file-writing-proc.d.ts +1 -1
- package/build/lib-client/objs-on-disk/obj-on-disk.d.ts +51 -3
- package/build/lib-client/objs-on-disk/obj-on-disk.js +414 -34
- package/build/lib-client/request-utils.d.ts +0 -7
- package/build/lib-client/request-utils.js +16 -11
- package/build/lib-client/service-locator.js +11 -8
- package/build/lib-client/user-with-mid-session.js +2 -6
- package/build/lib-client/user-with-pkl-session.js +25 -24
- package/build/lib-client/xsp-fs/common.d.ts +8 -3
- package/build/lib-client/xsp-fs/common.js +1 -1
- package/build/lib-client/xsp-fs/file.d.ts +3 -1
- package/build/lib-client/xsp-fs/file.js +4 -4
- package/build/lib-client/xsp-fs/folder-node.d.ts +1 -1
- package/build/lib-client/xsp-fs/folder-node.js +4 -4
- package/build/lib-client/xsp-fs/fs.d.ts +3 -1
- package/build/lib-client/xsp-fs/fs.js +4 -4
- package/build/lib-client/xsp-fs/node-in-fs.d.ts +6 -4
- package/build/lib-client/xsp-fs/node-in-fs.js +14 -9
- package/build/lib-common/buffer-utils.js +4 -1
- package/build/lib-common/exceptions/http.d.ts +11 -1
- package/build/lib-common/exceptions/http.js +10 -2
- package/build/lib-common/objs-on-disk/utils.d.ts +1 -1
- package/build/lib-common/processes/labelled-exec-pools.d.ts +1 -1
- package/build/lib-common/processes/labelled-exec-pools.js +8 -2
- package/build/protos/asmail.proto.js +545 -116
- package/build/protos/file.proto.js +485 -56
- package/build/protos/fs.proto.js +545 -116
- package/package.json +1 -1
- package/protos/file.proto +8 -2
- package/protos/fs.proto +3 -3
- /package/build/lib-common/objs-on-disk/{obj-file.d.ts → obj-version-file.d.ts} +0 -0
- /package/build/lib-common/objs-on-disk/{obj-file.js → obj-version-file.js} +0 -0
|
Binary file
|
|
@@ -87,7 +87,7 @@ function wrapWritableFileSyncAPI(sImpl) {
|
|
|
87
87
|
}
|
|
88
88
|
const w = {
|
|
89
89
|
status: sImpl.status.bind(sImpl),
|
|
90
|
-
|
|
90
|
+
startDownload: sImpl.startDownload.bind(sImpl),
|
|
91
91
|
isRemoteVersionOnDisk: sImpl.isRemoteVersionOnDisk.bind(sImpl),
|
|
92
92
|
startUpload: sImpl.startUpload.bind(sImpl),
|
|
93
93
|
upload: sImpl.upload.bind(sImpl),
|
|
@@ -140,7 +140,7 @@ function wrapReadonlyFileSyncAPI(sImpl) {
|
|
|
140
140
|
}
|
|
141
141
|
const w = {
|
|
142
142
|
status: sImpl.status.bind(sImpl),
|
|
143
|
-
|
|
143
|
+
startDownload: sImpl.startDownload.bind(sImpl),
|
|
144
144
|
isRemoteVersionOnDisk: sImpl.isRemoteVersionOnDisk.bind(sImpl),
|
|
145
145
|
adoptRemote: sImpl.adoptRemote.bind(sImpl),
|
|
146
146
|
};
|
|
@@ -234,7 +234,7 @@ function wrapWritableFSSyncAPI(sImpl) {
|
|
|
234
234
|
}
|
|
235
235
|
const w = {
|
|
236
236
|
status: sImpl.status.bind(sImpl),
|
|
237
|
-
|
|
237
|
+
startDownload: sImpl.startDownload.bind(sImpl),
|
|
238
238
|
isRemoteVersionOnDisk: sImpl.isRemoteVersionOnDisk.bind(sImpl),
|
|
239
239
|
adoptRemote: sImpl.adoptRemote.bind(sImpl),
|
|
240
240
|
diffCurrentAndRemoteFolderVersions: sImpl.diffCurrentAndRemoteFolderVersions.bind(sImpl),
|
|
@@ -296,7 +296,7 @@ function wrapReadonlyFSSyncAPI(sImpl) {
|
|
|
296
296
|
}
|
|
297
297
|
const w = {
|
|
298
298
|
status: sImpl.status.bind(sImpl),
|
|
299
|
-
|
|
299
|
+
startDownload: sImpl.startDownload.bind(sImpl),
|
|
300
300
|
isRemoteVersionOnDisk: sImpl.isRemoteVersionOnDisk.bind(sImpl),
|
|
301
301
|
adoptRemote: sImpl.adoptRemote.bind(sImpl),
|
|
302
302
|
diffCurrentAndRemoteFolderVersions: sImpl.diffCurrentAndRemoteFolderVersions.bind(sImpl),
|
|
@@ -19,7 +19,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
19
19
|
exports.startMidSession = startMidSession;
|
|
20
20
|
exports.authenticateMidSession = authenticateMidSession;
|
|
21
21
|
const api = require("../../lib-common/service-api/mailer-id/login");
|
|
22
|
-
const
|
|
22
|
+
const http_1 = require("../../lib-common/exceptions/http");
|
|
23
23
|
const url_1 = require("url");
|
|
24
24
|
async function startMidSession(userId, net, loginUrl) {
|
|
25
25
|
const reqData = { userId };
|
|
@@ -34,24 +34,24 @@ async function startMidSession(userId, net, loginUrl) {
|
|
|
34
34
|
if (rep.status === api.startSession.SC.ok) {
|
|
35
35
|
const r = rep.data;
|
|
36
36
|
if (!r || (typeof r.sessionId !== 'string') || !r.sessionId) {
|
|
37
|
-
throw (0,
|
|
37
|
+
throw (0, http_1.makeMalformedReplyHTTPException)(rep);
|
|
38
38
|
}
|
|
39
39
|
return { sessionId: r.sessionId };
|
|
40
40
|
}
|
|
41
41
|
else if (rep.status === api.startSession.SC.redirect) {
|
|
42
42
|
const rd = rep.data;
|
|
43
43
|
if (!rd || ('string' !== typeof rd.redirect) || !rd.redirect) {
|
|
44
|
-
throw (0,
|
|
44
|
+
throw (0, http_1.makeMalformedReplyHTTPException)(rep);
|
|
45
45
|
}
|
|
46
46
|
return { redirect: rd.redirect };
|
|
47
47
|
}
|
|
48
48
|
else if (rep.status === api.startSession.SC.unknownUser) {
|
|
49
|
-
const exc = (0,
|
|
49
|
+
const exc = (0, http_1.makeHTTPException)(rep.url, rep.method, rep.status, {});
|
|
50
50
|
exc.unknownUser = true;
|
|
51
51
|
throw exc;
|
|
52
52
|
}
|
|
53
53
|
else {
|
|
54
|
-
throw (0,
|
|
54
|
+
throw (0, http_1.makeUnexpectedStatusHTTPException)(rep);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
async function authenticateMidSession(sessionId, midSigner, net, loginUrl) {
|
|
@@ -73,12 +73,12 @@ async function authenticateMidSession(sessionId, midSigner, net, loginUrl) {
|
|
|
73
73
|
return;
|
|
74
74
|
}
|
|
75
75
|
else if (rep.status === api.authSession.SC.authFailed) {
|
|
76
|
-
const exc = (0,
|
|
76
|
+
const exc = (0, http_1.makeHTTPException)(rep.url, rep.method, rep.status, {});
|
|
77
77
|
exc.loginFailed = true;
|
|
78
78
|
throw exc;
|
|
79
79
|
}
|
|
80
80
|
else {
|
|
81
|
-
throw (0,
|
|
81
|
+
throw (0, http_1.makeUnexpectedStatusHTTPException)(rep);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
Object.freeze(exports);
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
19
|
exports.MailerIdProvisioner = void 0;
|
|
20
|
-
const request_utils_1 = require("../request-utils");
|
|
21
20
|
const service_locator_1 = require("../service-locator");
|
|
22
21
|
const user_with_pkl_session_1 = require("../user-with-pkl-session");
|
|
23
22
|
const jwkeys_1 = require("../../lib-common/jwkeys");
|
|
@@ -29,6 +28,7 @@ const url_1 = require("url");
|
|
|
29
28
|
const assert_1 = require("../../lib-common/assert");
|
|
30
29
|
const user_1 = require("../../lib-common/mailerid-sigs/user");
|
|
31
30
|
const relying_party_1 = require("../../lib-common/mailerid-sigs/relying-party");
|
|
31
|
+
const http_1 = require("../../lib-common/exceptions/http");
|
|
32
32
|
const DEFAULT_ASSERTION_VALIDITY = 20 * 60;
|
|
33
33
|
/**
|
|
34
34
|
* Certificate provisioner is an object that can do all MailerId's provisioning
|
|
@@ -87,10 +87,10 @@ class MailerIdProvisioner extends user_with_pkl_session_1.ServiceUser {
|
|
|
87
87
|
certs = this.encryptor.openJSON(rep.data);
|
|
88
88
|
}
|
|
89
89
|
catch (err) {
|
|
90
|
-
throw (0,
|
|
90
|
+
throw (0, http_1.makeMalformedReplyHTTPException)(rep, { message: err.message });
|
|
91
91
|
}
|
|
92
92
|
if (!certs.userCert || !certs.provCert) {
|
|
93
|
-
throw (0,
|
|
93
|
+
throw (0, http_1.makeMalformedReplyHTTPException)(rep, { message: 'Certificates are missing.' });
|
|
94
94
|
}
|
|
95
95
|
if (certs.provCert.kid !== this.rootCert.kid) {
|
|
96
96
|
const { currentCert, previousCerts } = await (0, service_locator_1.mailerIdInfoAt)(this.net, this.entryURI);
|
|
@@ -100,22 +100,24 @@ class MailerIdProvisioner extends user_with_pkl_session_1.ServiceUser {
|
|
|
100
100
|
this.rootCert = rootCert;
|
|
101
101
|
}
|
|
102
102
|
else {
|
|
103
|
-
throw (0,
|
|
103
|
+
throw (0, http_1.makeMalformedReplyHTTPException)(rep, {
|
|
104
|
+
message: 'referenced root MailerId certificate id is unknown.'
|
|
105
|
+
});
|
|
104
106
|
}
|
|
105
107
|
}
|
|
106
108
|
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);
|
|
107
109
|
if (pkeyAndId.address !== (0, canonical_address_1.toCanonicalAddress)(this.userId)) {
|
|
108
|
-
throw (0,
|
|
110
|
+
throw (0, http_1.makeMalformedReplyHTTPException)(rep, { message: 'Certificate is for a wrong address.' });
|
|
109
111
|
}
|
|
110
112
|
const keyInCert = (0, jwkeys_1.keyToJson)(pkeyAndId.pkey);
|
|
111
113
|
if (!(0, json_utils_1.deepEqual)(keyInCert, pkey)) {
|
|
112
|
-
throw (0,
|
|
114
|
+
throw (0, http_1.makeMalformedReplyHTTPException)(rep, { message: 'Certificate is for a wrong key.' });
|
|
113
115
|
}
|
|
114
116
|
this.userCert = certs.userCert;
|
|
115
117
|
this.provCert = certs.provCert;
|
|
116
118
|
}
|
|
117
119
|
else {
|
|
118
|
-
throw (0,
|
|
120
|
+
throw (0, http_1.makeUnexpectedStatusHTTPException)(rep);
|
|
119
121
|
}
|
|
120
122
|
}
|
|
121
123
|
finally {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Subscribe } from 'xsp-files';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
|
-
import { ObjVersionFile } from '../../lib-common/objs-on-disk/obj-file';
|
|
3
|
+
import { ObjVersionFile } from '../../lib-common/objs-on-disk/obj-version-file';
|
|
4
4
|
export declare class FileWritingProc {
|
|
5
5
|
private readonly objFile;
|
|
6
6
|
private readonly pValve;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { ObjId } from '../xsp-fs/common';
|
|
1
|
+
import { DownloadEventSink, ObjId } from '../xsp-fs/common';
|
|
2
2
|
import { ObjSource, Subscribe, Layout } from 'xsp-files';
|
|
3
3
|
import { FileWrite } from './file-writing-proc';
|
|
4
4
|
import { Observable } from 'rxjs';
|
|
5
|
+
import { ObjVersionFile } from '../../lib-common/objs-on-disk/obj-version-file';
|
|
5
6
|
import { NotOnDiskFiniteChunk, FiniteChunk } from '../../lib-common/objs-on-disk/file-layout';
|
|
6
7
|
import { DiffInfo } from '../../lib-common/service-api/3nstorage/owner';
|
|
7
8
|
export type GetBaseSegsOnDisk = (version: number, ofs: number, len: number) => Promise<(Uint8Array | NotOnDiskFiniteChunk)[]>;
|
|
@@ -12,6 +13,7 @@ export declare class ObjOnDisk {
|
|
|
12
13
|
private readonly downloader;
|
|
13
14
|
private readable;
|
|
14
15
|
private readonly getBaseSegsOnDisk;
|
|
16
|
+
private downloadsInProgress;
|
|
15
17
|
private proxiedHeader;
|
|
16
18
|
private constructor();
|
|
17
19
|
static forExistingFile(objId: ObjId, version: number, path: string, downloader?: ObjDownloader, getBase?: GetBaseSegsOnDisk): Promise<ObjOnDisk>;
|
|
@@ -28,9 +30,9 @@ export declare class ObjOnDisk {
|
|
|
28
30
|
removeFile(): Promise<void>;
|
|
29
31
|
private readHeader;
|
|
30
32
|
private readSegs;
|
|
33
|
+
private downloads;
|
|
31
34
|
readSegsOnlyFromDisk(offset: number, len: number): Promise<(Uint8Array | NotOnDiskFiniteChunk)[]>;
|
|
32
35
|
private readBaseBytesFromOtherFilesOnDisk;
|
|
33
|
-
private downloadAndSaveSegsChunk;
|
|
34
36
|
getSrc(): ObjSource;
|
|
35
37
|
getBaseVersion(): number | undefined;
|
|
36
38
|
absorbImmediateBaseVersion(baseVer: number, path: string): Promise<void>;
|
|
@@ -41,14 +43,60 @@ export declare class ObjOnDisk {
|
|
|
41
43
|
private segsThatNeedDownload;
|
|
42
44
|
doesFileNeedDownload(): boolean;
|
|
43
45
|
numOfBytesNeedingDownload(): number;
|
|
44
|
-
|
|
46
|
+
startDownloadInBackground(eventSink: DownloadEventSink): number | undefined;
|
|
47
|
+
}
|
|
48
|
+
export declare class Download {
|
|
49
|
+
readonly objId: ObjId;
|
|
50
|
+
readonly version: number;
|
|
51
|
+
private readonly downloader;
|
|
52
|
+
saveSegs?: ObjVersionFile["saveSegs"] | undefined;
|
|
53
|
+
segsThatNeedDownload?: ObjOnDisk["segsThatNeedDownload"] | undefined;
|
|
54
|
+
private readonly segsAsapRequest;
|
|
55
|
+
private initDataRequest;
|
|
56
|
+
private inBkgrnd;
|
|
57
|
+
constructor(objId: ObjId, version: number, downloader: ObjDownloader, saveSegs?: ObjVersionFile["saveSegs"] | undefined, segsThatNeedDownload?: ObjOnDisk["segsThatNeedDownload"] | undefined);
|
|
58
|
+
getInitParts(): Promise<InitDownloadParts>;
|
|
59
|
+
downloadAndSaveSegsChunk(chunk: NotOnDiskFiniteChunk): Promise<Uint8Array>;
|
|
60
|
+
downloadAllInBackground(eventSink: DownloadEventSink): number | undefined;
|
|
61
|
+
nextActionType(): {
|
|
62
|
+
runASAP: boolean;
|
|
63
|
+
} | undefined;
|
|
64
|
+
startNextAction(): Promise<void> | undefined;
|
|
65
|
+
private processInitDataRequest;
|
|
66
|
+
private processSomeAsapSegs;
|
|
67
|
+
private processBkgrnd;
|
|
68
|
+
private completeBkgrnd;
|
|
69
|
+
private emitDownloadEvent;
|
|
45
70
|
}
|
|
46
71
|
export interface ObjDownloader {
|
|
47
72
|
getLayoutWithHeaderAndFirstSegs: (objId: ObjId, version: number) => Promise<InitDownloadParts>;
|
|
48
73
|
getSegs: (objId: ObjId, version: number, start: number, end: number) => Promise<Uint8Array>;
|
|
74
|
+
splitSegsDownloads: (start: number, end: number) => Section[];
|
|
75
|
+
schedule: (download: Download) => void;
|
|
49
76
|
}
|
|
50
77
|
export interface InitDownloadParts {
|
|
51
78
|
layout: Layout;
|
|
52
79
|
header: Uint8Array;
|
|
53
80
|
segs?: Uint8Array;
|
|
54
81
|
}
|
|
82
|
+
export declare class DownloadsRunner {
|
|
83
|
+
private readonly downloads;
|
|
84
|
+
private readonly longRunsPool;
|
|
85
|
+
private readonly asapPool;
|
|
86
|
+
constructor(asapPoolMax?: number, longPoolMax?: number);
|
|
87
|
+
schedule(download: Download): void;
|
|
88
|
+
private removeDownload;
|
|
89
|
+
private triggerRuns;
|
|
90
|
+
private triggerRunsInPool;
|
|
91
|
+
}
|
|
92
|
+
export interface Section {
|
|
93
|
+
ofs: number;
|
|
94
|
+
len: number;
|
|
95
|
+
repeatCount?: number;
|
|
96
|
+
repeatLen?: number;
|
|
97
|
+
}
|
|
98
|
+
export declare function splitSegsDownloads(start: number, end: number, max: number): Section[];
|
|
99
|
+
export declare function generateSectionsFrom(sections: Section[]): Generator<{
|
|
100
|
+
ofs: number;
|
|
101
|
+
len: number;
|
|
102
|
+
}, void, unknown>;
|