core-3nweb-client-lib 0.47.3 → 0.48.0
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/common.d.ts +2 -0
- package/build/core/asmail/delivery/msg.js +2 -2
- package/build/core/asmail/inbox/attachments/fs.d.ts +2 -1
- package/build/core/asmail/inbox/attachments/fs.js +4 -3
- package/build/core/asmail/inbox/index.d.ts +3 -0
- package/build/core/asmail/inbox/index.js +4 -3
- package/build/core/asmail/index.d.ts +3 -1
- package/build/core/asmail/index.js +5 -2
- package/build/core/asmail/msg/packer.d.ts +4 -2
- package/build/core/asmail/msg/packer.js +28 -22
- package/build/core/asmail/sending-params/index.d.ts +2 -1
- package/build/core/asmail/sending-params/index.js +2 -2
- package/build/core/asmail/sending-params/invitations-anon.d.ts +3 -1
- package/build/core/asmail/sending-params/invitations-anon.js +6 -5
- package/build/core/id-manager/index.d.ts +4 -2
- package/build/core/id-manager/index.js +8 -7
- package/build/core/index.d.ts +3 -1
- package/build/core/index.js +11 -10
- package/build/core/keyring/common.d.ts +3 -2
- package/build/core/keyring/common.js +7 -7
- package/build/core/keyring/correspondent-keys.d.ts +4 -2
- package/build/core/keyring/correspondent-keys.js +10 -9
- package/build/core/keyring/index.d.ts +3 -1
- package/build/core/keyring/index.js +6 -5
- package/build/core/keyring/published-intro-key.d.ts +3 -1
- package/build/core/keyring/published-intro-key.js +5 -4
- package/build/core/startup/sign-up.d.ts +7 -5
- package/build/core/startup/sign-up.js +9 -8
- package/build/core/storage/index.d.ts +5 -3
- package/build/core/storage/index.js +9 -8
- package/build/core/storage/local/storage.d.ts +3 -1
- package/build/core/storage/local/storage.js +5 -4
- package/build/core/storage/synced/storage.d.ts +4 -2
- package/build/core/storage/synced/storage.js +7 -6
- package/build/injected-globals/platform-devfs.d.ts +2 -4
- package/build/ipc-via-protobuf/connector-services-side.js +1 -2
- package/build/lib-client/mailer-id/provisioner.d.ts +3 -1
- package/build/lib-client/mailer-id/provisioner.js +3 -3
- package/build/lib-client/request-utils.d.ts +2 -2
- package/build/lib-client/request-utils.js +3 -3
- package/build/lib-client/xsp-fs/common.d.ts +2 -0
- package/build/lib-client/xsp-fs/common.js +2 -1
- package/build/lib-client/xsp-fs/file-node.d.ts +2 -1
- package/build/lib-client/xsp-fs/file-node.js +3 -3
- package/build/lib-client/xsp-fs/folder-node.d.ts +3 -2
- package/build/lib-client/xsp-fs/folder-node.js +10 -11
- package/build/lib-client/xsp-fs/link-node.d.ts +2 -1
- package/build/lib-client/xsp-fs/link-node.js +3 -3
- package/build/lib-client/xsp-fs/node-persistence.d.ts +4 -2
- package/build/lib-client/xsp-fs/node-persistence.js +4 -4
- package/build/lib-common/async-fs-node.d.ts +1 -3
- package/build/lib-common/mailerid-sigs/id-provider.d.ts +6 -5
- package/build/lib-common/mailerid-sigs/id-provider.js +7 -7
- package/build/lib-common/mailerid-sigs/user.d.ts +3 -2
- package/build/lib-common/mailerid-sigs/user.js +1 -1
- package/build/lib-common/mailerid-sigs/utils-NaCl-Ed.d.ts +3 -2
- package/build/lib-common/mailerid-sigs/utils-NaCl-Ed.js +4 -4
- package/build/lib-common/rng-def.d.ts +3 -0
- package/build/lib-common/rng-def.js +32 -0
- package/build/{lib-common → lib-common-on-node}/random-node.js +2 -2
- package/build/lib-common-on-node/request-from-node.js +2 -2
- package/build/tests/caps-api/asmail/specs/send-with-attacment-from-storage.js +2 -2
- package/build/tests/caps-api/file-sink-checks/different-cases.js +1 -1
- package/build/tests/caps-api/file-sink-checks/splice.js +5 -5
- package/build/tests/caps-api/file-sink-checks/truncate.js +2 -2
- package/build/tests/caps-api/fs-checks/not-versioned/getByteSink.js +3 -3
- package/build/tests/caps-api/fs-checks/not-versioned/getByteSource.js +2 -2
- package/build/tests/caps-api/fs-checks/not-versioned/readBytes.js +3 -3
- package/build/tests/caps-api/fs-checks/not-versioned/writeBytes.js +10 -10
- package/build/tests/caps-api/fs-checks/sync-on-one-dev/startUpload.js +1 -1
- package/build/tests/caps-api/fs-checks/sync-on-one-dev/stat.js +1 -1
- package/build/tests/caps-api/fs-checks/sync-on-one-dev/status.js +1 -1
- package/build/tests/caps-api/fs-checks/sync-on-one-dev/upload.js +1 -1
- package/build/tests/caps-api/fs-checks/sync-with-two-devs/conflicts.js +1 -1
- package/build/tests/caps-api/fs-checks/sync-with-two-devs/update-propagation.js +1 -1
- package/build/tests/caps-api/fs-checks/versioned/archiveCurrent.js +1 -1
- package/build/tests/caps-api/fs-checks/versioned/getByteSink.js +4 -4
- package/build/tests/caps-api/fs-checks/versioned/getByteSource.js +2 -2
- package/build/tests/caps-api/fs-checks/versioned/readBytes.js +3 -3
- package/build/tests/caps-api/fs-checks/versioned/writeBytes.js +9 -9
- package/build/tests/caps-api/fs-checks/with-core-restarts/xattrs.js +1 -1
- package/build/tests/caps-api/startup/signin-empty-cache.js +1 -1
- package/build/tests/computer.3nweb.core/id-manager.js +1 -1
- package/build/tests/libs-for-tests/core-runner.js +2 -2
- package/build/tests/units/folder-node-serialization.js +1 -1
- package/build/tests/units/mid-sigs-NaCl-Ed.js +10 -9
- package/build/tests/units/obj-folders.js +1 -1
- package/package.json +1 -1
- /package/build/{lib-common → lib-common-on-node}/random-node.d.ts +0 -0
|
@@ -6,6 +6,7 @@ import { ASMailKeyPair } from '../../keyring/common';
|
|
|
6
6
|
import { NetClient } from '../../../lib-client/request-utils';
|
|
7
7
|
import { LogWarning, LogError } from '../../../lib-client/logging/log-to-file';
|
|
8
8
|
import { ServiceLocator } from '../../../lib-client/service-locator';
|
|
9
|
+
import { AsyncRNG } from '../../../lib-common/rng-def';
|
|
9
10
|
type OutgoingMessage = web3n.asmail.OutgoingMessage;
|
|
10
11
|
type DeliveryProgress = web3n.asmail.DeliveryProgress;
|
|
11
12
|
type DeliveryOptions = web3n.asmail.DeliveryOptions;
|
|
@@ -77,6 +78,7 @@ export interface ResourcesForSending {
|
|
|
77
78
|
newParamsForSendingReplies: (address: string) => Promise<SendingParams | undefined>;
|
|
78
79
|
};
|
|
79
80
|
cryptor: AsyncSBoxCryptor;
|
|
81
|
+
random: AsyncRNG;
|
|
80
82
|
notifyMsgProgress: (id: string, progress: DeliveryProgress) => void;
|
|
81
83
|
logError: LogError;
|
|
82
84
|
logWarning: LogWarning;
|
|
@@ -171,9 +171,9 @@ class Msg {
|
|
|
171
171
|
}
|
|
172
172
|
async msgPacker(pack) {
|
|
173
173
|
if (pack) {
|
|
174
|
-
return packer_1.MsgPacker.fromPack(pack, common_1.SEG_SIZE_IN_K_QUATS, this.attachments);
|
|
174
|
+
return packer_1.MsgPacker.fromPack(pack, common_1.SEG_SIZE_IN_K_QUATS, this.attachments, this.r.random);
|
|
175
175
|
}
|
|
176
|
-
const msg = packer_1.MsgPacker.empty(common_1.SEG_SIZE_IN_K_QUATS);
|
|
176
|
+
const msg = await packer_1.MsgPacker.empty(common_1.SEG_SIZE_IN_K_QUATS, this.r.random);
|
|
177
177
|
msg.setSection('From', this.sender);
|
|
178
178
|
if (typeof this.msgToSend.plainTxtBody === 'string') {
|
|
179
179
|
msg.setPlainTextBody(this.msgToSend.plainTxtBody);
|
|
@@ -2,6 +2,7 @@ import { StorageGetter, FolderInJSON } from '../../../../lib-client/xsp-fs/commo
|
|
|
2
2
|
import { AsyncSBoxCryptor } from 'xsp-files';
|
|
3
3
|
import { MsgOnDisk } from '../msg-on-disk';
|
|
4
4
|
import { LogError } from '../../../../lib-client/logging/log-to-file';
|
|
5
|
+
import { AsyncRNG } from '../../../../lib-common/rng-def';
|
|
5
6
|
type ReadonlyFS = web3n.files.ReadonlyFS;
|
|
6
|
-
export declare function fsForAttachments(msg: MsgOnDisk, rootJson: FolderInJSON, storages: StorageGetter, cryptor: AsyncSBoxCryptor, logError: LogError): ReadonlyFS;
|
|
7
|
+
export declare function fsForAttachments(msg: MsgOnDisk, rootJson: FolderInJSON, storages: StorageGetter, cryptor: AsyncSBoxCryptor, random: AsyncRNG, logError: LogError): ReadonlyFS;
|
|
7
8
|
export {};
|
|
@@ -20,10 +20,11 @@ exports.fsForAttachments = fsForAttachments;
|
|
|
20
20
|
const common_1 = require("../../../../lib-client/xsp-fs/common");
|
|
21
21
|
const fs_1 = require("../../../../lib-client/xsp-fs/fs");
|
|
22
22
|
class AttachmentStore {
|
|
23
|
-
constructor(msg, getStorages, cryptor, logError) {
|
|
23
|
+
constructor(msg, getStorages, cryptor, random, logError) {
|
|
24
24
|
this.msg = msg;
|
|
25
25
|
this.getStorages = getStorages;
|
|
26
26
|
this.cryptor = cryptor;
|
|
27
|
+
this.random = random;
|
|
27
28
|
this.logError = logError;
|
|
28
29
|
this.type = 'asmail-msg';
|
|
29
30
|
this.versioned = false;
|
|
@@ -67,8 +68,8 @@ class AttachmentStore {
|
|
|
67
68
|
}
|
|
68
69
|
Object.freeze(AttachmentStore.prototype);
|
|
69
70
|
Object.freeze(AttachmentStore);
|
|
70
|
-
function fsForAttachments(msg, rootJson, storages, cryptor, logError) {
|
|
71
|
-
const storage = new AttachmentStore(msg, storages, cryptor, logError);
|
|
71
|
+
function fsForAttachments(msg, rootJson, storages, cryptor, random, logError) {
|
|
72
|
+
const storage = new AttachmentStore(msg, storages, cryptor, random, logError);
|
|
72
73
|
const fs = fs_1.XspFS.fromASMailMsgRootFromJSON(storage, rootJson, 'attachments');
|
|
73
74
|
return fs;
|
|
74
75
|
}
|
|
@@ -8,6 +8,7 @@ import { LogError } from '../../../lib-client/logging/log-to-file';
|
|
|
8
8
|
import { AsyncSBoxCryptor } from 'xsp-files';
|
|
9
9
|
import { SendingParams } from '../msg/common';
|
|
10
10
|
import { NetClient } from '../../../lib-client/request-utils';
|
|
11
|
+
import { AsyncRNG } from '../../../lib-common/rng-def';
|
|
11
12
|
type WritableFS = web3n.files.WritableFS;
|
|
12
13
|
type InboxService = web3n.asmail.InboxService;
|
|
13
14
|
type JsonKey = web3n.keys.JsonKey;
|
|
@@ -17,6 +18,7 @@ export interface ResourcesForReceiving {
|
|
|
17
18
|
getSigner: GetSigner;
|
|
18
19
|
getStorages: StorageGetter;
|
|
19
20
|
cryptor: AsyncSBoxCryptor;
|
|
21
|
+
random: AsyncRNG;
|
|
20
22
|
makeNet: () => NetClient;
|
|
21
23
|
asmailResolver: ServiceLocator;
|
|
22
24
|
correspondents: {
|
|
@@ -75,6 +77,7 @@ export declare class InboxOnServer {
|
|
|
75
77
|
private readonly msgReceiver;
|
|
76
78
|
private readonly storages;
|
|
77
79
|
private readonly cryptor;
|
|
80
|
+
private readonly random;
|
|
78
81
|
private readonly downloader;
|
|
79
82
|
private readonly cache;
|
|
80
83
|
private readonly index;
|
|
@@ -40,11 +40,12 @@ const MSG_INDEX_FOLDER = 'msg-index';
|
|
|
40
40
|
* This object is also responsible for expiring messages on the server.
|
|
41
41
|
*/
|
|
42
42
|
class InboxOnServer {
|
|
43
|
-
constructor(r, msgReceiver, storages, cryptor, downloader, cache, index, logError) {
|
|
43
|
+
constructor(r, msgReceiver, storages, cryptor, random, downloader, cache, index, logError) {
|
|
44
44
|
this.r = r;
|
|
45
45
|
this.msgReceiver = msgReceiver;
|
|
46
46
|
this.storages = storages;
|
|
47
47
|
this.cryptor = cryptor;
|
|
48
|
+
this.random = random;
|
|
48
49
|
this.downloader = downloader;
|
|
49
50
|
this.cache = cache;
|
|
50
51
|
this.index = index;
|
|
@@ -63,7 +64,7 @@ class InboxOnServer {
|
|
|
63
64
|
const indexSyncedFS = await (0, fs_sync_utils_1.getOrMakeAndUploadFolderIn)(syncedFS, MSG_INDEX_FOLDER);
|
|
64
65
|
const index = await msg_indexing_1.MsgIndex.make(indexSyncedFS);
|
|
65
66
|
await (0, fs_sync_utils_1.uploadFolderChangesIfAny)(syncedFS);
|
|
66
|
-
const inbox = new InboxOnServer(r.correspondents, msgReceiver, r.getStorages, r.cryptor, downloader, cache, index, r.logError);
|
|
67
|
+
const inbox = new InboxOnServer(r.correspondents, msgReceiver, r.getStorages, r.cryptor, r.random, downloader, cache, index, r.logError);
|
|
67
68
|
return inbox;
|
|
68
69
|
}
|
|
69
70
|
catch (err) {
|
|
@@ -324,7 +325,7 @@ class InboxOnServer {
|
|
|
324
325
|
}
|
|
325
326
|
const attachments = msg.attachmentsJSON;
|
|
326
327
|
if (attachments) {
|
|
327
|
-
m.attachments = (0, fs_1.fsForAttachments)(msgOnDisk, attachments, this.storages, this.cryptor, this.logError);
|
|
328
|
+
m.attachments = (0, fs_1.fsForAttachments)(msgOnDisk, attachments, this.storages, this.cryptor, this.random, this.logError);
|
|
328
329
|
}
|
|
329
330
|
return m;
|
|
330
331
|
}
|
|
@@ -7,11 +7,13 @@ import { AsyncSBoxCryptor } from 'xsp-files';
|
|
|
7
7
|
import { Logger } from '../../lib-client/logging/log-to-file';
|
|
8
8
|
import { ServiceLocatorMaker } from '../../lib-client/service-locator';
|
|
9
9
|
import { MakeNet } from '..';
|
|
10
|
+
import { AsyncRNG } from '../../lib-common/rng-def';
|
|
10
11
|
type WritableFS = web3n.files.WritableFS;
|
|
11
12
|
type Service = web3n.asmail.Service;
|
|
12
13
|
export type MailCAPMaker = () => Service;
|
|
13
14
|
export declare class ASMail {
|
|
14
15
|
private readonly cryptor;
|
|
16
|
+
private readonly random;
|
|
15
17
|
private readonly makeNet;
|
|
16
18
|
private readonly inboxPathForUser;
|
|
17
19
|
private readonly logger;
|
|
@@ -21,7 +23,7 @@ export declare class ASMail {
|
|
|
21
23
|
private delivery;
|
|
22
24
|
private config;
|
|
23
25
|
private sendingParams;
|
|
24
|
-
constructor(cryptor: AsyncSBoxCryptor, makeNet: MakeNet, inboxPathForUser: InboxPathForUser, logger: Logger);
|
|
26
|
+
constructor(cryptor: AsyncSBoxCryptor, random: AsyncRNG, makeNet: MakeNet, inboxPathForUser: InboxPathForUser, logger: Logger);
|
|
25
27
|
init(address: string, getSigner: GetSigner, syncedFS: WritableFS, localFS: WritableFS, getStorages: StorageGetter, makeResolver: ServiceLocatorMaker, config: ConfigOfASMailServer, keyring: KeyringForASMail): Promise<void>;
|
|
26
28
|
private setupSendingParams;
|
|
27
29
|
private setupDelivery;
|
|
@@ -26,8 +26,9 @@ const INBOX_DATA_FOLDER = 'inbox';
|
|
|
26
26
|
const DELIVERY_DATA_FOLDER = 'delivery';
|
|
27
27
|
const SEND_PARAMS_DATA_FOLDER = 'sending-params';
|
|
28
28
|
class ASMail {
|
|
29
|
-
constructor(cryptor, makeNet, inboxPathForUser, logger) {
|
|
29
|
+
constructor(cryptor, random, makeNet, inboxPathForUser, logger) {
|
|
30
30
|
this.cryptor = cryptor;
|
|
31
|
+
this.random = random;
|
|
31
32
|
this.makeNet = makeNet;
|
|
32
33
|
this.inboxPathForUser = inboxPathForUser;
|
|
33
34
|
this.logger = logger;
|
|
@@ -61,13 +62,14 @@ class ASMail {
|
|
|
61
62
|
}
|
|
62
63
|
async setupSendingParams(syncedFS) {
|
|
63
64
|
const fs = await (0, fs_sync_utils_1.getOrMakeAndUploadFolderIn)(syncedFS, SEND_PARAMS_DATA_FOLDER);
|
|
64
|
-
this.sendingParams = await sending_params_1.SendingParamsHolder.makeAndInit(fs, this.config.makeParamSetterAndGetter('anon-sender/invites'));
|
|
65
|
+
this.sendingParams = await sending_params_1.SendingParamsHolder.makeAndInit(fs, this.config.makeParamSetterAndGetter('anon-sender/invites'), this.random);
|
|
65
66
|
}
|
|
66
67
|
async setupDelivery(localFS, getSigner, makeResolver) {
|
|
67
68
|
const fs = await localFS.writableSubRoot(DELIVERY_DATA_FOLDER);
|
|
68
69
|
this.delivery = await delivery_1.Delivery.makeAndStart(fs, {
|
|
69
70
|
address: this.address,
|
|
70
71
|
cryptor: this.cryptor,
|
|
72
|
+
random: this.random,
|
|
71
73
|
getSigner,
|
|
72
74
|
asmailResolver: makeResolver('asmail', this.logger.logError),
|
|
73
75
|
midResolver: makeResolver('mailerid', this.logger.logError),
|
|
@@ -90,6 +92,7 @@ class ASMail {
|
|
|
90
92
|
this.inbox = await inbox_1.InboxOnServer.makeAndStart(cachePath, inboxSyncedFS, {
|
|
91
93
|
address: this.address,
|
|
92
94
|
cryptor: this.cryptor,
|
|
95
|
+
random: this.random,
|
|
93
96
|
getSigner,
|
|
94
97
|
getStorages,
|
|
95
98
|
asmailResolver: makeResolver('asmail', this.logger.logError),
|
|
@@ -3,6 +3,7 @@ import * as delivApi from '../../../lib-common/service-api/asmail/delivery';
|
|
|
3
3
|
import { FolderInJSON } from '../../../lib-client/xsp-fs/common';
|
|
4
4
|
import { MsgEnvelope, SuggestedNextKeyPair, SendingParams } from './common';
|
|
5
5
|
import { Encryptor } from '../../../lib-common/async-cryptor-wrap';
|
|
6
|
+
import { AsyncRNG } from '../../../lib-common/rng-def';
|
|
6
7
|
type FS = web3n.files.FS;
|
|
7
8
|
type AttachmentsContainer = web3n.asmail.AttachmentsContainer;
|
|
8
9
|
type PKeyCertChain = web3n.keys.PKeyCertChain;
|
|
@@ -44,6 +45,7 @@ interface PathInMsg {
|
|
|
44
45
|
*/
|
|
45
46
|
export declare class MsgPacker {
|
|
46
47
|
private segSizeIn256bs;
|
|
48
|
+
private readonly random;
|
|
47
49
|
private meta;
|
|
48
50
|
private main;
|
|
49
51
|
private mainObjId;
|
|
@@ -54,11 +56,11 @@ export declare class MsgPacker {
|
|
|
54
56
|
private attachmentsCont;
|
|
55
57
|
private workLabel;
|
|
56
58
|
private constructor();
|
|
57
|
-
static empty(segSizeIn256bs: number): MsgPacker
|
|
59
|
+
static empty(segSizeIn256bs: number, random: AsyncRNG): Promise<MsgPacker>;
|
|
58
60
|
static fromPack(p: PackJSON, segSizeIn256bs: number, att: undefined | {
|
|
59
61
|
fs: FS | undefined;
|
|
60
62
|
container: AttachmentsContainer | undefined;
|
|
61
|
-
}): MsgPacker;
|
|
63
|
+
}, random: AsyncRNG): MsgPacker;
|
|
62
64
|
private generateObjId;
|
|
63
65
|
private addJsonObj;
|
|
64
66
|
private addFileInto;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2015 - 2018, 2020, 2022 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2015 - 2018, 2020, 2022, 2026 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
|
|
@@ -19,7 +19,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
19
19
|
exports.MsgPacker = void 0;
|
|
20
20
|
const ecma_nacl_1 = require("ecma-nacl");
|
|
21
21
|
const xsp_files_1 = require("xsp-files");
|
|
22
|
-
const random = require("../../../lib-common/random-node");
|
|
23
22
|
const buffer_utils_1 = require("../../../lib-common/buffer-utils");
|
|
24
23
|
const folder_node_serialization_1 = require("../../../lib-client/xsp-fs/folder-node-serialization");
|
|
25
24
|
const json_utils_1 = require("../../../lib-common/json-utils");
|
|
@@ -71,14 +70,17 @@ function isManagedField(name) {
|
|
|
71
70
|
* different for each recipient.
|
|
72
71
|
*/
|
|
73
72
|
class MsgPacker {
|
|
74
|
-
constructor(segSizeIn256bs) {
|
|
73
|
+
constructor(segSizeIn256bs, random) {
|
|
75
74
|
this.segSizeIn256bs = segSizeIn256bs;
|
|
75
|
+
this.random = random;
|
|
76
76
|
this.meta = undefined;
|
|
77
|
+
this.mainObjId = undefined;
|
|
77
78
|
this.allObjs = new Map();
|
|
78
79
|
this.readyPack = undefined;
|
|
79
80
|
this.hasAttachments = false;
|
|
80
81
|
this.attachmentsFS = undefined;
|
|
81
82
|
this.attachmentsCont = undefined;
|
|
83
|
+
this.workLabel = undefined;
|
|
82
84
|
this.wasBodySet = false;
|
|
83
85
|
this.main = {
|
|
84
86
|
'Flow Params': {
|
|
@@ -88,15 +90,16 @@ class MsgPacker {
|
|
|
88
90
|
'Body': {},
|
|
89
91
|
'From': undefined
|
|
90
92
|
};
|
|
91
|
-
this.mainObjId = this.addJsonObj(this.main);
|
|
92
|
-
this.workLabel = cryptor_work_labels_1.cryptoWorkLabels.makeFor('asmail', this.mainObjId);
|
|
93
93
|
Object.seal(this);
|
|
94
94
|
}
|
|
95
|
-
static empty(segSizeIn256bs) {
|
|
96
|
-
|
|
95
|
+
static async empty(segSizeIn256bs, random) {
|
|
96
|
+
const pkr = new MsgPacker(segSizeIn256bs, random);
|
|
97
|
+
pkr.mainObjId = await pkr.addJsonObj(pkr.main);
|
|
98
|
+
pkr.workLabel = cryptor_work_labels_1.cryptoWorkLabels.makeFor('asmail', pkr.mainObjId);
|
|
99
|
+
return pkr;
|
|
97
100
|
}
|
|
98
|
-
static fromPack(p, segSizeIn256bs, att) {
|
|
99
|
-
const packer = new MsgPacker(segSizeIn256bs);
|
|
101
|
+
static fromPack(p, segSizeIn256bs, att, random) {
|
|
102
|
+
const packer = new MsgPacker(segSizeIn256bs, random);
|
|
100
103
|
packer.readyPack = p;
|
|
101
104
|
packer.mainObjId = p.meta.objIds[0];
|
|
102
105
|
packer.workLabel = cryptor_work_labels_1.cryptoWorkLabels.makeFor('asmail', packer.mainObjId);
|
|
@@ -118,22 +121,22 @@ class MsgPacker {
|
|
|
118
121
|
}
|
|
119
122
|
return packer;
|
|
120
123
|
}
|
|
121
|
-
generateObjId() {
|
|
124
|
+
async generateObjId() {
|
|
122
125
|
let id;
|
|
123
126
|
do {
|
|
124
|
-
id =
|
|
127
|
+
id = await generateObjId(this.random);
|
|
125
128
|
} while (this.allObjs.has(id));
|
|
126
129
|
return id;
|
|
127
130
|
}
|
|
128
|
-
addJsonObj(json) {
|
|
129
|
-
const id = this.generateObjId();
|
|
130
|
-
const key = random
|
|
131
|
+
async addJsonObj(json) {
|
|
132
|
+
const id = await this.generateObjId();
|
|
133
|
+
const key = await this.random(xsp_files_1.KEY_LENGTH);
|
|
131
134
|
this.allObjs.set(id, { id, json, key });
|
|
132
135
|
return id;
|
|
133
136
|
}
|
|
134
|
-
addFileInto(folderInfo, fName, file) {
|
|
135
|
-
const id = this.generateObjId();
|
|
136
|
-
const key = random
|
|
137
|
+
async addFileInto(folderInfo, fName, file) {
|
|
138
|
+
const id = await this.generateObjId();
|
|
139
|
+
const key = await this.random(xsp_files_1.KEY_LENGTH);
|
|
137
140
|
this.allObjs.set(id, { id, file, key });
|
|
138
141
|
folderInfo.nodes[fName] = {
|
|
139
142
|
objId: id,
|
|
@@ -159,8 +162,8 @@ class MsgPacker {
|
|
|
159
162
|
// note that links are ignored.
|
|
160
163
|
}
|
|
161
164
|
// attach folder to the rest of the message
|
|
162
|
-
const id = this.generateObjId();
|
|
163
|
-
const key = await random
|
|
165
|
+
const id = await this.generateObjId();
|
|
166
|
+
const key = await this.random(xsp_files_1.KEY_LENGTH);
|
|
164
167
|
this.allObjs.set(id, { id, folder, key });
|
|
165
168
|
outerFolder.nodes[fName] = {
|
|
166
169
|
objId: id,
|
|
@@ -350,7 +353,7 @@ class MsgPacker {
|
|
|
350
353
|
}
|
|
351
354
|
const msgKeyPack = await msgKeyEnc.pack(obj.key);
|
|
352
355
|
const bytes = buffer_utils_1.utf8.pack(JSON.stringify(obj.json));
|
|
353
|
-
const segWriter = await (0, xsp_files_1.makeSegmentsWriter)(obj.key, (0, xsp_files_1.idToHeaderNonce)(obj.id), 0, { type: 'new', segSize: this.segSizeIn256bs, payloadFormat: 1 }, random
|
|
356
|
+
const segWriter = await (0, xsp_files_1.makeSegmentsWriter)(obj.key, (0, xsp_files_1.idToHeaderNonce)(obj.id), 0, { type: 'new', segSize: this.segSizeIn256bs, payloadFormat: 1 }, this.random, cryptor, this.workLabel);
|
|
354
357
|
// make source that inserts message key pack into header
|
|
355
358
|
return makeMainObjSrc(msgKeyPack, bytes, segWriter);
|
|
356
359
|
}
|
|
@@ -413,10 +416,10 @@ class MsgPacker {
|
|
|
413
416
|
// make object segments writer
|
|
414
417
|
let segWriter;
|
|
415
418
|
if (header) {
|
|
416
|
-
segWriter = await (0, xsp_files_1.makeSegmentsWriter)(obj.key, (0, xsp_files_1.idToHeaderNonce)(obj.id), 0, { type: 'restart', header }, random
|
|
419
|
+
segWriter = await (0, xsp_files_1.makeSegmentsWriter)(obj.key, (0, xsp_files_1.idToHeaderNonce)(obj.id), 0, { type: 'restart', header }, this.random, cryptor, this.workLabel);
|
|
417
420
|
}
|
|
418
421
|
else {
|
|
419
|
-
segWriter = await (0, xsp_files_1.makeSegmentsWriter)(obj.key, (0, xsp_files_1.idToHeaderNonce)(obj.id), 0, { type: 'new', segSize: this.segSizeIn256bs, payloadFormat: 1 }, random
|
|
422
|
+
segWriter = await (0, xsp_files_1.makeSegmentsWriter)(obj.key, (0, xsp_files_1.idToHeaderNonce)(obj.id), 0, { type: 'new', segSize: this.segSizeIn256bs, payloadFormat: 1 }, this.random, cryptor, this.workLabel);
|
|
420
423
|
}
|
|
421
424
|
// make object source
|
|
422
425
|
let src;
|
|
@@ -500,4 +503,7 @@ function fileSrcToByteSrc(fileSrc) {
|
|
|
500
503
|
seek: fileSrc.seek
|
|
501
504
|
};
|
|
502
505
|
}
|
|
506
|
+
async function generateObjId(random) {
|
|
507
|
+
return buffer_utils_1.base64urlSafe.pack(await random(ecma_nacl_1.secret_box.NONCE_LENGTH));
|
|
508
|
+
}
|
|
503
509
|
Object.freeze(exports);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ResourcesForSending } from '../delivery/common';
|
|
2
2
|
import { ResourcesForReceiving } from '../inbox';
|
|
3
3
|
import { ParamOnServer } from '../../../lib-client/asmail/service-config';
|
|
4
|
+
import { AsyncRNG } from '../../../lib-common/rng-def';
|
|
4
5
|
export { SendingParams } from './params-from-others';
|
|
5
6
|
type WritableFS = web3n.files.WritableFS;
|
|
6
7
|
type SendingResources = ResourcesForSending['correspondents'];
|
|
@@ -17,6 +18,6 @@ export declare class SendingParamsHolder {
|
|
|
17
18
|
set: ReceptionResources['saveParamsForSendingTo'];
|
|
18
19
|
};
|
|
19
20
|
private constructor();
|
|
20
|
-
static makeAndInit(fs: WritableFS, anonInvitesOnServer: ParamOnServer<'anon-sender/invites'
|
|
21
|
+
static makeAndInit(fs: WritableFS, anonInvitesOnServer: ParamOnServer<'anon-sender/invites'>, random: AsyncRNG): Promise<SendingParamsHolder>;
|
|
21
22
|
close(): Promise<void>;
|
|
22
23
|
}
|
|
@@ -37,13 +37,13 @@ class SendingParamsHolder {
|
|
|
37
37
|
};
|
|
38
38
|
Object.freeze(this);
|
|
39
39
|
}
|
|
40
|
-
static async makeAndInit(fs, anonInvitesOnServer) {
|
|
40
|
+
static async makeAndInit(fs, anonInvitesOnServer, random) {
|
|
41
41
|
const [paramsFromOthers, ownParams] = await Promise.all([
|
|
42
42
|
fs.writableFile(PARAMS_FROM_OTHERS_FILE)
|
|
43
43
|
.then(f => params_from_others_1.ParamsFromOthers.makeAndInit(f)),
|
|
44
44
|
fs.writableFile(ANONYM_INVITES_FILE)
|
|
45
45
|
.then(async (anonInvitesFile) => {
|
|
46
|
-
const anonInvites = await invitations_anon_1.AnonymousInvites.makeAndInit(anonInvitesFile, anonInvitesOnServer);
|
|
46
|
+
const anonInvites = await invitations_anon_1.AnonymousInvites.makeAndInit(anonInvitesFile, anonInvitesOnServer, random);
|
|
47
47
|
return await own_params_1.OwnSendingParams.makeAndInit(await fs.writableFile(OWN_PARAMS_FILE), anonInvites);
|
|
48
48
|
})
|
|
49
49
|
]);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ParamOnServer } from '../../../lib-client/asmail/service-config';
|
|
2
|
+
import { AsyncRNG } from '../../../lib-common/rng-def';
|
|
2
3
|
type WritableFile = web3n.files.WritableFile;
|
|
3
4
|
interface InvitesJSON {
|
|
4
5
|
invites: {
|
|
@@ -10,10 +11,11 @@ interface InvitesJSON {
|
|
|
10
11
|
}
|
|
11
12
|
export declare class AnonymousInvites {
|
|
12
13
|
private readonly anonInvitesOnServer;
|
|
14
|
+
private readonly random;
|
|
13
15
|
private invites;
|
|
14
16
|
private readonly fileProc;
|
|
15
17
|
private constructor();
|
|
16
|
-
static makeAndInit(file: WritableFile, anonInvitesOnServer: ParamOnServer<'anon-sender/invites'
|
|
18
|
+
static makeAndInit(file: WritableFile, anonInvitesOnServer: ParamOnServer<'anon-sender/invites'>, random: AsyncRNG): Promise<AnonymousInvites>;
|
|
17
19
|
private onFileEvent;
|
|
18
20
|
protected setFromJSON(json: InvitesJSON): void;
|
|
19
21
|
private toFileJSON;
|
|
@@ -17,19 +17,20 @@
|
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
19
|
exports.AnonymousInvites = void 0;
|
|
20
|
-
const random = require("../../../lib-common/random-node");
|
|
21
20
|
const file_based_json_1 = require("../../../lib-client/xsp-fs/util/file-based-json");
|
|
22
21
|
const json_utils_1 = require("../../../lib-common/json-utils");
|
|
22
|
+
const rng_def_1 = require("../../../lib-common/rng-def");
|
|
23
23
|
const INVITE_TOKEN_LEN = 40;
|
|
24
24
|
class AnonymousInvites {
|
|
25
|
-
constructor(anonInvitesOnServer) {
|
|
25
|
+
constructor(anonInvitesOnServer, random) {
|
|
26
26
|
this.anonInvitesOnServer = anonInvitesOnServer;
|
|
27
|
+
this.random = random;
|
|
27
28
|
this.invites = {};
|
|
28
29
|
this.fileProc = new file_based_json_1.JsonFileProc(this.onFileEvent.bind(this));
|
|
29
30
|
Object.seal(this);
|
|
30
31
|
}
|
|
31
|
-
static async makeAndInit(file, anonInvitesOnServer) {
|
|
32
|
-
const anonInvites = new AnonymousInvites(anonInvitesOnServer);
|
|
32
|
+
static async makeAndInit(file, anonInvitesOnServer, random) {
|
|
33
|
+
const anonInvites = new AnonymousInvites(anonInvitesOnServer, random);
|
|
33
34
|
await anonInvites.fileProc.start(file, () => anonInvites.toFileJSON());
|
|
34
35
|
// XXX these are part of proper syncing logic
|
|
35
36
|
// await anonInvites.absorbRemoteChanges();
|
|
@@ -146,7 +147,7 @@ class AnonymousInvites {
|
|
|
146
147
|
async generateNewRandomInvite() {
|
|
147
148
|
let invite;
|
|
148
149
|
do {
|
|
149
|
-
invite = await
|
|
150
|
+
invite = await (0, rng_def_1.stringOfB64Chars)(INVITE_TOKEN_LEN, this.random);
|
|
150
151
|
} while (this.invites[invite]);
|
|
151
152
|
return invite;
|
|
152
153
|
}
|
|
@@ -3,6 +3,7 @@ import { LogError, LogWarning } from '../../lib-client/logging/log-to-file';
|
|
|
3
3
|
import { NetClient } from '../../lib-client/request-utils';
|
|
4
4
|
import { ServiceLocator } from '../../lib-client/service-locator';
|
|
5
5
|
import { MailerIdSigner } from '../../lib-common/mailerid-sigs/user';
|
|
6
|
+
import { AsyncRNG } from '../../lib-common/rng-def';
|
|
6
7
|
type JsonKey = web3n.keys.JsonKey;
|
|
7
8
|
type WritableFS = web3n.files.WritableFS;
|
|
8
9
|
/**
|
|
@@ -24,14 +25,15 @@ export declare class IdManager {
|
|
|
24
25
|
private readonly makeNet;
|
|
25
26
|
private readonly midServiceFor;
|
|
26
27
|
private address;
|
|
28
|
+
private readonly random;
|
|
27
29
|
private signer;
|
|
28
30
|
private provisioningProc;
|
|
29
31
|
private constructor();
|
|
30
|
-
static initWithoutStore(address: string, resolver: ServiceLocator, makeNet: () => NetClient, logError: LogError, logWarning: LogWarning): Promise<((midLoginKey: GenerateKey | Uint8Array) => Promise<{
|
|
32
|
+
static initWithoutStore(address: string, resolver: ServiceLocator, makeNet: () => NetClient, random: AsyncRNG, logError: LogError, logWarning: LogWarning): Promise<((midLoginKey: GenerateKey | Uint8Array) => Promise<{
|
|
31
33
|
idManager: IdManager;
|
|
32
34
|
setupManagerStorage: SetupManagerStorage;
|
|
33
35
|
} | undefined>) | undefined>;
|
|
34
|
-
static initFromCachedStore(address: string, fs: WritableFS, resolver: ServiceLocator, makeNet: () => NetClient, logError: LogError, logWarning: LogWarning): Promise<IdManager | undefined>;
|
|
36
|
+
static initFromCachedStore(address: string, fs: WritableFS, resolver: ServiceLocator, makeNet: () => NetClient, random: AsyncRNG, logError: LogError, logWarning: LogWarning): Promise<IdManager | undefined>;
|
|
35
37
|
private startProvisionWithoutSavedKey;
|
|
36
38
|
private provisionUsingSavedKey;
|
|
37
39
|
getId(): string;
|
|
@@ -30,11 +30,12 @@ const CERTIFICATE_DURATION_SECONDS = 16 * 60 * 60;
|
|
|
30
30
|
const ASSERTION_VALIDITY = 15 * 60;
|
|
31
31
|
const MIN_SECS_LEFT_ASSUMED_OK = 10 * 60;
|
|
32
32
|
class IdManager {
|
|
33
|
-
constructor(store, makeNet, midServiceFor, address) {
|
|
33
|
+
constructor(store, makeNet, midServiceFor, address, random) {
|
|
34
34
|
this.store = store;
|
|
35
35
|
this.makeNet = makeNet;
|
|
36
36
|
this.midServiceFor = midServiceFor;
|
|
37
37
|
this.address = address;
|
|
38
|
+
this.random = random;
|
|
38
39
|
this.signer = undefined;
|
|
39
40
|
this.provisioningProc = new synced_1.SingleProc();
|
|
40
41
|
this.getSigner = async () => {
|
|
@@ -48,9 +49,9 @@ class IdManager {
|
|
|
48
49
|
};
|
|
49
50
|
Object.seal(this);
|
|
50
51
|
}
|
|
51
|
-
static async initWithoutStore(address, resolver, makeNet, logError, logWarning) {
|
|
52
|
+
static async initWithoutStore(address, resolver, makeNet, random, logError, logWarning) {
|
|
52
53
|
const { store, setupManagerStorage } = key_storage_1.IdKeysStorage.makeWithoutStorage(logError, logWarning);
|
|
53
|
-
const idManager = new IdManager(store, makeNet, resolver, address);
|
|
54
|
+
const idManager = new IdManager(store, makeNet, resolver, address, random);
|
|
54
55
|
const provisioning = await idManager.startProvisionWithoutSavedKey(address);
|
|
55
56
|
if (!provisioning) {
|
|
56
57
|
return;
|
|
@@ -70,13 +71,13 @@ class IdManager {
|
|
|
70
71
|
};
|
|
71
72
|
};
|
|
72
73
|
}
|
|
73
|
-
static async initFromCachedStore(address, fs, resolver, makeNet, logError, logWarning) {
|
|
74
|
+
static async initFromCachedStore(address, fs, resolver, makeNet, random, logError, logWarning) {
|
|
74
75
|
const store = key_storage_1.IdKeysStorage.makeWithStorage(fs, logError, logWarning);
|
|
75
|
-
return new IdManager(store, makeNet, resolver, address);
|
|
76
|
+
return new IdManager(store, makeNet, resolver, address, random);
|
|
76
77
|
}
|
|
77
78
|
async startProvisionWithoutSavedKey(address) {
|
|
78
79
|
const midUrl = await this.midServiceFor(address);
|
|
79
|
-
const provisioner = new provisioner_1.MailerIdProvisioner(address, midUrl, this.makeNet());
|
|
80
|
+
const provisioner = new provisioner_1.MailerIdProvisioner(address, midUrl, this.makeNet(), this.random);
|
|
80
81
|
try {
|
|
81
82
|
const provisioning = await provisioner.provisionSigner(undefined);
|
|
82
83
|
const completion = async (defaultSKey) => {
|
|
@@ -119,7 +120,7 @@ class IdManager {
|
|
|
119
120
|
}
|
|
120
121
|
proc = this.provisioningProc.start(async () => {
|
|
121
122
|
const midUrl = await this.midServiceFor(this.address);
|
|
122
|
-
const provisioner = new provisioner_1.MailerIdProvisioner(this.address, midUrl, this.makeNet());
|
|
123
|
+
const provisioner = new provisioner_1.MailerIdProvisioner(this.address, midUrl, this.makeNet(), this.random);
|
|
123
124
|
const key = await this.store.getSavedKey();
|
|
124
125
|
if (!key) {
|
|
125
126
|
throw new Error(`No saved MailerId login key can be found`);
|
package/build/core/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { FactoryOfFSs } from './storage';
|
|
|
2
2
|
import { NetClient } from '../lib-client/request-utils';
|
|
3
3
|
import { ServiceLocatorMaker } from '../lib-client/service-locator';
|
|
4
4
|
import type { makeCryptor } from 'ecma-nacl-cryptors';
|
|
5
|
+
import { AsyncRNG } from '../lib-common/rng-def';
|
|
5
6
|
export type { makeCryptor } from 'ecma-nacl-cryptors';
|
|
6
7
|
type RequestedCAPs = web3n.caps.common.RequestedCAPs;
|
|
7
8
|
type W3N = web3n.caps.common.W3N;
|
|
@@ -14,6 +15,7 @@ export type MakeNet = () => NetClient;
|
|
|
14
15
|
export declare class Core {
|
|
15
16
|
private readonly makeNet;
|
|
16
17
|
private readonly makeResolver;
|
|
18
|
+
private readonly random;
|
|
17
19
|
private readonly appDirs;
|
|
18
20
|
private readonly logger;
|
|
19
21
|
private readonly signUpUrl;
|
|
@@ -25,7 +27,7 @@ export declare class Core {
|
|
|
25
27
|
private closingProc;
|
|
26
28
|
private isInitialized;
|
|
27
29
|
private constructor();
|
|
28
|
-
static make(conf: CoreConf, makeNet: MakeNet, makeResolver: ServiceLocatorMaker, makeCryptor: makeCryptor): Core;
|
|
30
|
+
static make(conf: CoreConf, makeNet: MakeNet, makeResolver: ServiceLocatorMaker, makeCryptor: makeCryptor, random: AsyncRNG): Core;
|
|
29
31
|
start(): {
|
|
30
32
|
capsForStartup: web3n.startup.W3N;
|
|
31
33
|
coreInit: Promise<string>;
|
package/build/core/index.js
CHANGED
|
@@ -31,9 +31,10 @@ const constants_1 = require("./storage/common/constants");
|
|
|
31
31
|
const config_1 = require("./asmail/config");
|
|
32
32
|
const deferred_1 = require("../lib-common/processes/deferred");
|
|
33
33
|
class Core {
|
|
34
|
-
constructor(makeNet, makeResolver, makeCryptor, appDirs, logger, signUpUrl) {
|
|
34
|
+
constructor(makeNet, makeResolver, makeCryptor, random, appDirs, logger, signUpUrl) {
|
|
35
35
|
this.makeNet = makeNet;
|
|
36
36
|
this.makeResolver = makeResolver;
|
|
37
|
+
this.random = random;
|
|
37
38
|
this.appDirs = appDirs;
|
|
38
39
|
this.logger = logger;
|
|
39
40
|
this.signUpUrl = signUpUrl;
|
|
@@ -41,21 +42,21 @@ class Core {
|
|
|
41
42
|
this.closingProc = undefined;
|
|
42
43
|
this.isInitialized = false;
|
|
43
44
|
this.cryptor = makeCryptor(this.logger.logError, this.logger.logWarning);
|
|
44
|
-
this.storages = new storage_1.Storages(this.cryptor.cryptor.sbox, this.appDirs.storagePathFor);
|
|
45
|
-
this.keyrings = new keyring_1.Keyrings(this.cryptor.cryptor.sbox, this.logger);
|
|
46
|
-
this.asmail = new asmail_1.ASMail(this.cryptor.cryptor.sbox, this.makeNet, this.appDirs.inboxPathFor, this.logger);
|
|
45
|
+
this.storages = new storage_1.Storages(this.cryptor.cryptor.sbox, this.random, this.appDirs.storagePathFor);
|
|
46
|
+
this.keyrings = new keyring_1.Keyrings(this.cryptor.cryptor.sbox, this.random, this.logger);
|
|
47
|
+
this.asmail = new asmail_1.ASMail(this.cryptor.cryptor.sbox, this.random, this.makeNet, this.appDirs.inboxPathFor, this.logger);
|
|
47
48
|
Object.seal(this);
|
|
48
49
|
}
|
|
49
|
-
static make(conf, makeNet, makeResolver, makeCryptor) {
|
|
50
|
+
static make(conf, makeNet, makeResolver, makeCryptor, random) {
|
|
50
51
|
const dirs = (0, app_files_1.appDirs)(conf.dataDir);
|
|
51
52
|
const logger = (0, log_to_file_1.makeLogger)(dirs.getUtilFS());
|
|
52
|
-
const core = new Core(makeNet, makeResolver, makeCryptor, dirs, logger, conf.signUpUrl);
|
|
53
|
+
const core = new Core(makeNet, makeResolver, makeCryptor, random, dirs, logger, conf.signUpUrl);
|
|
53
54
|
return core;
|
|
54
55
|
}
|
|
55
56
|
start() {
|
|
56
57
|
const { promise: midPromise, resolve: midDone } = (0, deferred_1.defer)();
|
|
57
58
|
const { watchBoot, emitBootEvent } = makeForBootEvents();
|
|
58
|
-
const signUp = new sign_up_1.SignUp(this.signUpUrl, this.cryptor.cryptor, this.makeNet, this.appDirs.getUsersOnDisk, user => this.initForNewUser(user, midDone, emitBootEvent), watchBoot, this.logger.logError);
|
|
59
|
+
const signUp = new sign_up_1.SignUp(this.signUpUrl, this.cryptor.cryptor, this.random, this.makeNet, this.appDirs.getUsersOnDisk, user => this.initForNewUser(user, midDone, emitBootEvent), watchBoot, this.logger.logError);
|
|
59
60
|
const signIn = new sign_in_1.SignIn(this.cryptor.cryptor, addr => this.initForExistingUserWithoutCache(addr, midDone, emitBootEvent), (addr, storageKey) => this.initForExistingUserWithCache(addr, storageKey, midDone, emitBootEvent), this.appDirs.getUsersOnDisk, watchBoot, this.logger.logError);
|
|
60
61
|
const capsForStartup = {
|
|
61
62
|
signUp: signUp.exposedService(),
|
|
@@ -93,7 +94,7 @@ class Core {
|
|
|
93
94
|
});
|
|
94
95
|
try {
|
|
95
96
|
// 1) init of id manager without setting fs
|
|
96
|
-
const stepTwo = await id_manager_1.IdManager.initWithoutStore(u.address, this.makeResolver('mailerid', this.logger.logError), this.makeNet, this.logger.logError, this.logger.logWarning);
|
|
97
|
+
const stepTwo = await id_manager_1.IdManager.initWithoutStore(u.address, this.makeResolver('mailerid', this.logger.logError), this.makeNet, this.random, this.logger.logError, this.logger.logWarning);
|
|
97
98
|
if (!stepTwo) {
|
|
98
99
|
const message = `MailerId server doesn't recognize identity ${u.address}`;
|
|
99
100
|
emitBootEvent({ message, isError: true });
|
|
@@ -141,7 +142,7 @@ class Core {
|
|
|
141
142
|
});
|
|
142
143
|
try {
|
|
143
144
|
// 1) init of id manager without setting fs
|
|
144
|
-
const stepTwo = await id_manager_1.IdManager.initWithoutStore(address, this.makeResolver('mailerid', this.logger.logError), this.makeNet, this.logger.logError, this.logger.logWarning);
|
|
145
|
+
const stepTwo = await id_manager_1.IdManager.initWithoutStore(address, this.makeResolver('mailerid', this.logger.logError), this.makeNet, this.random, this.logger.logError, this.logger.logWarning);
|
|
145
146
|
if (!stepTwo) {
|
|
146
147
|
emitBootEvent({
|
|
147
148
|
isError: true, message: `MailerId server doesn't recognize identity ${address}`
|
|
@@ -212,7 +213,7 @@ class Core {
|
|
|
212
213
|
return false;
|
|
213
214
|
}
|
|
214
215
|
emitBootEvent({ message: `✔️ main storage is opened` });
|
|
215
|
-
const idManager = await id_manager_1.IdManager.initFromCachedStore(address, await this.storages.makeSyncedFSForApp(constants_1.MAILERID_APP_NAME), this.makeResolver('mailerid', this.logger.logError), this.makeNet, this.logger.logError, this.logger.logWarning);
|
|
216
|
+
const idManager = await id_manager_1.IdManager.initFromCachedStore(address, await this.storages.makeSyncedFSForApp(constants_1.MAILERID_APP_NAME), this.makeResolver('mailerid', this.logger.logError), this.makeNet, this.random, this.logger.logError, this.logger.logWarning);
|
|
216
217
|
if (!idManager) {
|
|
217
218
|
return false;
|
|
218
219
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AsyncRNG } from '../../lib-common/rng-def';
|
|
1
2
|
type JsonKey = web3n.keys.JsonKey;
|
|
2
3
|
type JsonKeyShort = web3n.keys.JsonKeyShort;
|
|
3
4
|
export type MsgKeyRole = 'suggested' | 'in_use' | 'old' | 'published_intro' | 'prev_published_intro' | 'introductory';
|
|
@@ -30,7 +31,7 @@ export declare const KEY_USE: {
|
|
|
30
31
|
* These are to be used with NaCl's box (Curve+XSalsa+Poly encryption).
|
|
31
32
|
* Key ids are the same in this intimate pair.
|
|
32
33
|
*/
|
|
33
|
-
export declare function generateKeyPair(): Promise<JWKeyPair>;
|
|
34
|
+
export declare function generateKeyPair(random: AsyncRNG): Promise<JWKeyPair>;
|
|
34
35
|
/**
|
|
35
36
|
* We have this function for future use by a keyring, that takes symmetric key.
|
|
36
37
|
* This keyring, is specifically tailored to handle short-lived public keys.
|
|
@@ -38,7 +39,7 @@ export declare function generateKeyPair(): Promise<JWKeyPair>;
|
|
|
38
39
|
* This returns a JWK form of a key for NaCl's secret box (XSalsa+Poly
|
|
39
40
|
* encryption).
|
|
40
41
|
*/
|
|
41
|
-
export declare function generateSymmetricKey(): Promise<JsonKey>;
|
|
42
|
+
export declare function generateSymmetricKey(random: AsyncRNG): Promise<JsonKey>;
|
|
42
43
|
/**
|
|
43
44
|
* This returns bytes of from a given secret key's JWK form
|
|
44
45
|
* @param key is a JWK form of a key
|