core-3nweb-client-lib 0.49.0 → 0.49.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/delivery/index.js +2 -0
- package/build/core/asmail/delivery/per-recipient-wip.js +2 -4
- package/build/core/startup/sign-in.d.ts +1 -0
- package/build/core/startup/sign-in.js +21 -4
- package/build/core/startup/sign-up.js +2 -1
- package/build/lib-client/asmail/sender.js +9 -5
- package/package.json +1 -1
|
@@ -154,6 +154,8 @@ class Delivery {
|
|
|
154
154
|
}
|
|
155
155
|
const attachments = common_1.Attachments.fromMsg(msgToSend);
|
|
156
156
|
const localMeta = opts === null || opts === void 0 ? void 0 : opts.localMeta;
|
|
157
|
+
// DEBUG console to help capturing a bug
|
|
158
|
+
console.log(`Sending msg with delivery id ${id} ${attachments ? `with attachments` : `without attachments`}`);
|
|
157
159
|
// save msg, in case delivery should be restarted
|
|
158
160
|
const msgFS = await this.makeFSForNewMsg(id);
|
|
159
161
|
const msg = await msg_1.Msg.forNew(id, msgFS, msgToSend, sender, recipients, this.r, attachments, localMeta, opts === null || opts === void 0 ? void 0 : opts.retryRecipient);
|
|
@@ -65,8 +65,7 @@ class WIP {
|
|
|
65
65
|
const wip = new WIP(msg, state, cryptor);
|
|
66
66
|
wip.packer = await msg.msgPacker(state.pack);
|
|
67
67
|
if (state.bytesUploaded > 0) {
|
|
68
|
-
msg.progress.recipients[state.recipient].bytesSent =
|
|
69
|
-
state.bytesUploaded;
|
|
68
|
+
msg.progress.recipients[state.recipient].bytesSent = state.bytesUploaded;
|
|
70
69
|
}
|
|
71
70
|
return wip;
|
|
72
71
|
}
|
|
@@ -230,8 +229,7 @@ class WIP {
|
|
|
230
229
|
const recInfo = this.msg.progress.recipients[recipient];
|
|
231
230
|
if (complete) {
|
|
232
231
|
if (err) {
|
|
233
|
-
recInfo.err = (err.runtimeException ?
|
|
234
|
-
err : (err.stack ? err.stack : err));
|
|
232
|
+
recInfo.err = (err.runtimeException ? err : (err.stack ? err.stack : err));
|
|
235
233
|
}
|
|
236
234
|
else {
|
|
237
235
|
recInfo.bytesSent = this.msg.progress.msgSize;
|
|
@@ -20,6 +20,7 @@ export declare class SignIn {
|
|
|
20
20
|
constructor(cryptor: Cryptor, startInitWithoutCache: StartInitWithoutCache, initWithCache: InitWithCache, getUsersOnDisk: GetUsersOnDisk, saveStorageKeyForAutologin: ((storageKey: Uint8Array) => void) | undefined, watchBoot: SignInService['watchBoot'], logError: LogError);
|
|
21
21
|
exposedService(): SignInService;
|
|
22
22
|
private startLoginToRemoteStorage;
|
|
23
|
+
private getAddressFromDisk;
|
|
23
24
|
private completeLoginAndLocalSetup;
|
|
24
25
|
private useExistingStorage;
|
|
25
26
|
private logAndWrap;
|
|
@@ -20,6 +20,7 @@ exports.SignIn = void 0;
|
|
|
20
20
|
exports.makeKeyGenProgressCB = makeKeyGenProgressCB;
|
|
21
21
|
const key_derivation_1 = require("../../lib-client/key-derivation");
|
|
22
22
|
const error_1 = require("../../lib-common/exceptions/error");
|
|
23
|
+
const canonical_address_1 = require("../../lib-common/canonical-address");
|
|
23
24
|
class SignIn {
|
|
24
25
|
constructor(cryptor, startInitWithoutCache, initWithCache, getUsersOnDisk, saveStorageKeyForAutologin, watchBoot, logError) {
|
|
25
26
|
this.cryptor = cryptor;
|
|
@@ -44,6 +45,10 @@ class SignIn {
|
|
|
44
45
|
}
|
|
45
46
|
async startLoginToRemoteStorage(address) {
|
|
46
47
|
try {
|
|
48
|
+
const addrOnDisk = await this.getAddressFromDisk(address);
|
|
49
|
+
if (addrOnDisk) {
|
|
50
|
+
throw new Error(`${address} exists on disk as ${addrOnDisk}`);
|
|
51
|
+
}
|
|
47
52
|
this.completeInitWithoutCache = await this.startInitWithoutCache(address);
|
|
48
53
|
return !!this.completeInitWithoutCache;
|
|
49
54
|
}
|
|
@@ -51,6 +56,10 @@ class SignIn {
|
|
|
51
56
|
throw await this.logAndWrap(err, 'Fail to start login to remote storage');
|
|
52
57
|
}
|
|
53
58
|
}
|
|
59
|
+
async getAddressFromDisk(address) {
|
|
60
|
+
const usersOnDisk = await this.getUsersOnDisk();
|
|
61
|
+
return usersOnDisk.find(existing => (0, canonical_address_1.areAddressesEqual)(existing, address));
|
|
62
|
+
}
|
|
54
63
|
async completeLoginAndLocalSetup(pass, progressCB) {
|
|
55
64
|
var _a;
|
|
56
65
|
if (!this.completeInitWithoutCache) {
|
|
@@ -62,8 +71,10 @@ class SignIn {
|
|
|
62
71
|
const storeKeyProgressCB = makeKeyGenProgressCB(51, 100, progressCB);
|
|
63
72
|
let storeKey;
|
|
64
73
|
const storeKeyGen = async (params) => {
|
|
65
|
-
|
|
66
|
-
|
|
74
|
+
const key = await (0, key_derivation_1.deriveStorageSKey)(this.cryptor, pass, params, storeKeyProgressCB);
|
|
75
|
+
storeKey = new Uint8Array(key.length);
|
|
76
|
+
storeKey.set(key);
|
|
77
|
+
return key;
|
|
67
78
|
};
|
|
68
79
|
const ok = await this.completeInitWithoutCache(midKeyGen, storeKeyGen);
|
|
69
80
|
if (ok) {
|
|
@@ -77,12 +88,18 @@ class SignIn {
|
|
|
77
88
|
}
|
|
78
89
|
async useExistingStorage(user, pass, progressCB) {
|
|
79
90
|
var _a;
|
|
91
|
+
const addrOnDisk = await this.getAddressFromDisk(user);
|
|
92
|
+
if (addrOnDisk) {
|
|
93
|
+
user = addrOnDisk;
|
|
94
|
+
}
|
|
80
95
|
try {
|
|
81
96
|
let storeKey;
|
|
82
97
|
const storeKeyProgressCB = makeKeyGenProgressCB(0, 99, progressCB);
|
|
83
98
|
const storeKeyGen = async (params) => {
|
|
84
|
-
|
|
85
|
-
|
|
99
|
+
const key = await (0, key_derivation_1.deriveStorageSKey)(this.cryptor, pass, params, storeKeyProgressCB);
|
|
100
|
+
storeKey = new Uint8Array(key.length);
|
|
101
|
+
storeKey.set(key);
|
|
102
|
+
return key;
|
|
86
103
|
};
|
|
87
104
|
const ok = await this.initWithCache(user, storeKeyGen);
|
|
88
105
|
if (ok) {
|
|
@@ -164,7 +164,8 @@ class SignUp {
|
|
|
164
164
|
if (!accountCreated) {
|
|
165
165
|
return false;
|
|
166
166
|
}
|
|
167
|
-
const storeKey = this.store.skey;
|
|
167
|
+
const storeKey = new Uint8Array(this.store.skey.length);
|
|
168
|
+
storeKey.set(this.store.skey);
|
|
168
169
|
this.initForNewUser({
|
|
169
170
|
address,
|
|
170
171
|
midSKey: {
|
|
@@ -155,9 +155,9 @@ class MailSender {
|
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
prepareRedirectOrThrowUp(rep) {
|
|
158
|
-
if (("string" !== typeof rep.redirect)
|
|
159
|
-
(rep.redirect.length === 0)
|
|
160
|
-
((new URL(rep.redirect)).protocol !== 'https:')) {
|
|
158
|
+
if (("string" !== typeof rep.redirect)
|
|
159
|
+
|| (rep.redirect.length === 0)
|
|
160
|
+
|| ((new URL(rep.redirect)).protocol !== 'https:')) {
|
|
161
161
|
throw this.badRedirectExc();
|
|
162
162
|
}
|
|
163
163
|
// refuse second redirect
|
|
@@ -413,8 +413,8 @@ class MailSender {
|
|
|
413
413
|
async trySessionRestart() {
|
|
414
414
|
// check and set timestamp for session restarts
|
|
415
415
|
const now = Date.now();
|
|
416
|
-
if ((typeof this.sessionRestartTimeStamp === 'number')
|
|
417
|
-
(now <= (this.sessionRestartTimeStamp + TOO_EARLY_RESTART_PERIOD))) {
|
|
416
|
+
if ((typeof this.sessionRestartTimeStamp === 'number')
|
|
417
|
+
&& (now <= (this.sessionRestartTimeStamp + TOO_EARLY_RESTART_PERIOD))) {
|
|
418
418
|
return false;
|
|
419
419
|
}
|
|
420
420
|
this.sessionRestartTimeStamp = now;
|
|
@@ -451,6 +451,10 @@ class MailSender {
|
|
|
451
451
|
}
|
|
452
452
|
}
|
|
453
453
|
else if (rep.status === api.msgObj.SC.ok) {
|
|
454
|
+
// DEBUG console to help capturing a bug
|
|
455
|
+
if ((fstReq === null || fstReq === void 0 ? void 0 : fstReq.last) || (followReq === null || followReq === void 0 ? void 0 : followReq.last)) {
|
|
456
|
+
console.log(`sent obj ${objId} within msg ${this.msgId}`);
|
|
457
|
+
}
|
|
454
458
|
// normal return
|
|
455
459
|
return;
|
|
456
460
|
}
|