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
|
@@ -28,7 +28,7 @@ exports.msgKeyPackSizeFor = msgKeyPackSizeFor;
|
|
|
28
28
|
*/
|
|
29
29
|
const ecma_nacl_1 = require("ecma-nacl");
|
|
30
30
|
const buffer_utils_1 = require("../../lib-common/buffer-utils");
|
|
31
|
-
const
|
|
31
|
+
const rng_def_1 = require("../../lib-common/rng-def");
|
|
32
32
|
exports.KID_LENGTH = 16;
|
|
33
33
|
exports.PID_LENGTH = 2;
|
|
34
34
|
exports.KEY_USE = {
|
|
@@ -43,10 +43,10 @@ Object.freeze(exports.KEY_USE);
|
|
|
43
43
|
* These are to be used with NaCl's box (Curve+XSalsa+Poly encryption).
|
|
44
44
|
* Key ids are the same in this intimate pair.
|
|
45
45
|
*/
|
|
46
|
-
async function generateKeyPair() {
|
|
47
|
-
const skeyBytes = await (
|
|
46
|
+
async function generateKeyPair(random) {
|
|
47
|
+
const skeyBytes = await random(ecma_nacl_1.box.KEY_LENGTH);
|
|
48
48
|
const pkeyBytes = ecma_nacl_1.box.generate_pubkey(skeyBytes);
|
|
49
|
-
const kid = await (0,
|
|
49
|
+
const kid = await (0, rng_def_1.stringOfB64Chars)(exports.KID_LENGTH, random);
|
|
50
50
|
const skey = {
|
|
51
51
|
use: exports.KEY_USE.SECRET,
|
|
52
52
|
alg: ecma_nacl_1.box.JWK_ALG_NAME,
|
|
@@ -69,12 +69,12 @@ async function generateKeyPair() {
|
|
|
69
69
|
* This returns a JWK form of a key for NaCl's secret box (XSalsa+Poly
|
|
70
70
|
* encryption).
|
|
71
71
|
*/
|
|
72
|
-
async function generateSymmetricKey() {
|
|
72
|
+
async function generateSymmetricKey(random) {
|
|
73
73
|
return {
|
|
74
74
|
use: exports.KEY_USE.SYMMETRIC,
|
|
75
|
-
k: buffer_utils_1.base64.pack(await (
|
|
75
|
+
k: buffer_utils_1.base64.pack(await random(ecma_nacl_1.secret_box.KEY_LENGTH)),
|
|
76
76
|
alg: ecma_nacl_1.secret_box.JWK_ALG_NAME,
|
|
77
|
-
kid: await (0,
|
|
77
|
+
kid: await (0, rng_def_1.stringOfB64Chars)(exports.KID_LENGTH, random)
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
80
|
;
|
|
@@ -6,6 +6,7 @@ import { SuggestedNextKeyPair } from '../asmail/msg/opener';
|
|
|
6
6
|
import { KeyPairsStorage } from './index';
|
|
7
7
|
import { Decryptor } from '../../lib-common/async-cryptor-wrap';
|
|
8
8
|
import { AsyncSBoxCryptor } from 'xsp-files';
|
|
9
|
+
import { AsyncRNG } from '../../lib-common/rng-def';
|
|
9
10
|
type JsonKey = web3n.keys.JsonKey;
|
|
10
11
|
type JsonKeyShort = web3n.keys.JsonKeyShort;
|
|
11
12
|
type CorrespondentKeysInfo = web3n.keys.CorrespondentKeysInfo;
|
|
@@ -80,7 +81,8 @@ export interface RatchetedSendingPair {
|
|
|
80
81
|
export type SendingPair = IntroductorySendingPair | RatchetedSendingPair;
|
|
81
82
|
export declare function msgMasterDecryptor(cryptor: AsyncSBoxCryptor, skey: JsonKey, pkey: JsonKeyShort): Decryptor;
|
|
82
83
|
export declare class CorrespondentKeys {
|
|
83
|
-
private keyring;
|
|
84
|
+
private readonly keyring;
|
|
85
|
+
private readonly random;
|
|
84
86
|
private keys;
|
|
85
87
|
get correspondent(): string;
|
|
86
88
|
/**
|
|
@@ -90,7 +92,7 @@ export declare class CorrespondentKeys {
|
|
|
90
92
|
* @param serialData from which this object should be reconstructed.
|
|
91
93
|
* Either serialData, or an address should be defined, not both.
|
|
92
94
|
*/
|
|
93
|
-
constructor(keyring: KeyPairsStorage, address: string | undefined, serialData?: string);
|
|
95
|
+
constructor(keyring: KeyPairsStorage, random: AsyncRNG, address: string | undefined, serialData?: string);
|
|
94
96
|
/**
|
|
95
97
|
* This attaches all keys into ring's maps.
|
|
96
98
|
* Theis method should be called only once, and only on a deserialized
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2015 - 2018, 2022 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2015 - 2018, 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
|
|
@@ -22,16 +22,16 @@ exports.msgMasterDecryptor = msgMasterDecryptor;
|
|
|
22
22
|
* This file contains functionality, used inside keyring.
|
|
23
23
|
*/
|
|
24
24
|
const common_1 = require("./common");
|
|
25
|
-
const random = require("../../lib-common/random-node");
|
|
26
25
|
const ecma_nacl_1 = require("ecma-nacl");
|
|
27
26
|
const buffer_utils_1 = require("../../lib-common/buffer-utils");
|
|
28
27
|
const error_1 = require("../../lib-common/exceptions/error");
|
|
29
28
|
const async_cryptor_wrap_1 = require("../../lib-common/async-cryptor-wrap");
|
|
30
29
|
const cryptor_work_labels_1 = require("../../lib-client/cryptor-work-labels");
|
|
31
|
-
|
|
30
|
+
const rng_def_1 = require("../../lib-common/rng-def");
|
|
31
|
+
async function generatePids(random) {
|
|
32
32
|
const pids = [];
|
|
33
33
|
for (let i = 0; i < 5; i += 1) {
|
|
34
|
-
pids[i] =
|
|
34
|
+
pids[i] = await (0, rng_def_1.stringOfB64UrlSafeChars)(common_1.PID_LENGTH, random);
|
|
35
35
|
}
|
|
36
36
|
return pids;
|
|
37
37
|
}
|
|
@@ -68,8 +68,9 @@ class CorrespondentKeys {
|
|
|
68
68
|
* @param serialData from which this object should be reconstructed.
|
|
69
69
|
* Either serialData, or an address should be defined, not both.
|
|
70
70
|
*/
|
|
71
|
-
constructor(keyring, address, serialData) {
|
|
71
|
+
constructor(keyring, random, address, serialData) {
|
|
72
72
|
this.keyring = keyring;
|
|
73
|
+
this.random = random;
|
|
73
74
|
this.keys = undefined;
|
|
74
75
|
if (address) {
|
|
75
76
|
this.keys = {
|
|
@@ -131,10 +132,10 @@ class CorrespondentKeys {
|
|
|
131
132
|
// generate new suggested pair
|
|
132
133
|
const corrPKey = this.keys.sendingPair.recipientPKey;
|
|
133
134
|
const isSenderIntroKey = (this.keys.sendingPair.type === 'intro');
|
|
134
|
-
const recipientKey = await (0, common_1.generateKeyPair)();
|
|
135
|
+
const recipientKey = await (0, common_1.generateKeyPair)(this.random);
|
|
135
136
|
const msgMasterKey = calcMsgMasterKeyB64(recipientKey.skey, corrPKey);
|
|
136
137
|
const pair = {
|
|
137
|
-
pids: generatePids(),
|
|
138
|
+
pids: await generatePids(this.random),
|
|
138
139
|
recipientKey,
|
|
139
140
|
senderPKey: corrPKey,
|
|
140
141
|
isSenderIntroKey,
|
|
@@ -300,7 +301,7 @@ class CorrespondentKeys {
|
|
|
300
301
|
let msgMasterKey;
|
|
301
302
|
let msgCount;
|
|
302
303
|
if (p.type === 'intro') {
|
|
303
|
-
const senderKey = await (0, common_1.generateKeyPair)();
|
|
304
|
+
const senderKey = await (0, common_1.generateKeyPair)(this.random);
|
|
304
305
|
msgMasterKey = calcMsgMasterKey(senderKey.skey, p.recipientPKey);
|
|
305
306
|
currentPair = {
|
|
306
307
|
senderPKey: senderKey.pkey,
|
|
@@ -344,7 +345,7 @@ function selectPid(pair) {
|
|
|
344
345
|
if (pair.pids.length < 1) {
|
|
345
346
|
throw new Error("There are no pair ids in array.");
|
|
346
347
|
}
|
|
347
|
-
const i = Math.round((pair.pids.length - 1) * random
|
|
348
|
+
const i = Math.round((pair.pids.length - 1) * Math.random());
|
|
348
349
|
return pair.pids[i];
|
|
349
350
|
}
|
|
350
351
|
/**
|
|
@@ -6,6 +6,7 @@ import { ResourcesForReceiving } from '../asmail/inbox';
|
|
|
6
6
|
import { GetSigner } from '../id-manager';
|
|
7
7
|
import { ParamOnServer } from '../../lib-client/asmail/service-config';
|
|
8
8
|
import { Logger } from '../../lib-client/logging/log-to-file';
|
|
9
|
+
import { AsyncRNG } from '../../lib-common/rng-def';
|
|
9
10
|
export { KEY_USE, MsgKeyRole } from './common';
|
|
10
11
|
export interface MsgKeyInfo {
|
|
11
12
|
correspondent: string;
|
|
@@ -38,6 +39,7 @@ export interface KeyPairsStorage {
|
|
|
38
39
|
}
|
|
39
40
|
export declare class Keyrings {
|
|
40
41
|
private readonly cryptor;
|
|
42
|
+
private readonly random;
|
|
41
43
|
private readonly logger;
|
|
42
44
|
/**
|
|
43
45
|
* This is a map from correspondents' canonical addresses to key objects.
|
|
@@ -47,7 +49,7 @@ export declare class Keyrings {
|
|
|
47
49
|
private readonly workLabel;
|
|
48
50
|
private storage;
|
|
49
51
|
private publishedKeys;
|
|
50
|
-
constructor(cryptor: AsyncSBoxCryptor, logger: Logger);
|
|
52
|
+
constructor(cryptor: AsyncSBoxCryptor, random: AsyncRNG, logger: Logger);
|
|
51
53
|
private readonly asKeyPairsStorage;
|
|
52
54
|
private addCorrespondent;
|
|
53
55
|
init(fs: WritableFS, getSigner: GetSigner, pkeyOnServer: ParamOnServer<'init-pub-key'>): Promise<void>;
|
|
@@ -22,7 +22,7 @@ const id_to_email_map_1 = require("./id-to-email-map");
|
|
|
22
22
|
const common_1 = require("./common");
|
|
23
23
|
const async_cryptor_wrap_1 = require("../../lib-common/async-cryptor-wrap");
|
|
24
24
|
const xsp_files_1 = require("xsp-files");
|
|
25
|
-
const random = require("../../lib-common/random-node");
|
|
25
|
+
const random = require("../../lib-common-on-node/random-node");
|
|
26
26
|
const buffer_utils_1 = require("../../lib-common/buffer-utils");
|
|
27
27
|
const canonical_address_1 = require("../../lib-common/canonical-address");
|
|
28
28
|
const common_2 = require("../asmail/delivery/common");
|
|
@@ -34,8 +34,9 @@ Object.defineProperty(exports, "KEY_USE", { enumerable: true, get: function () {
|
|
|
34
34
|
const FILE_FOR_INTRO_KEY_ON_SERVER = 'introductory-keys/published-on-server.json';
|
|
35
35
|
// XXX Keyring is just a storage and crypto functionality around keys
|
|
36
36
|
class Keyrings {
|
|
37
|
-
constructor(cryptor, logger) {
|
|
37
|
+
constructor(cryptor, random, logger) {
|
|
38
38
|
this.cryptor = cryptor;
|
|
39
|
+
this.random = random;
|
|
39
40
|
this.logger = logger;
|
|
40
41
|
/**
|
|
41
42
|
* This is a map from correspondents' canonical addresses to key objects.
|
|
@@ -53,8 +54,8 @@ class Keyrings {
|
|
|
53
54
|
}
|
|
54
55
|
addCorrespondent(address, serialForm) {
|
|
55
56
|
const ck = (serialForm ?
|
|
56
|
-
new correspondent_keys_1.CorrespondentKeys(this.asKeyPairsStorage, undefined, serialForm) :
|
|
57
|
-
new correspondent_keys_1.CorrespondentKeys(this.asKeyPairsStorage, address));
|
|
57
|
+
new correspondent_keys_1.CorrespondentKeys(this.asKeyPairsStorage, this.random, undefined, serialForm) :
|
|
58
|
+
new correspondent_keys_1.CorrespondentKeys(this.asKeyPairsStorage, this.random, address));
|
|
58
59
|
if (this.corrKeys.has(ck.correspondent)) {
|
|
59
60
|
throw new Error(`Correspondent with address ${ck.correspondent} is already present.`);
|
|
60
61
|
}
|
|
@@ -65,7 +66,7 @@ class Keyrings {
|
|
|
65
66
|
return ck;
|
|
66
67
|
}
|
|
67
68
|
async init(fs, getSigner, pkeyOnServer) {
|
|
68
|
-
this.publishedKeys = await published_intro_key_1.PublishedIntroKey.makeAndInit(await fs.writableFile(FILE_FOR_INTRO_KEY_ON_SERVER), getSigner, pkeyOnServer);
|
|
69
|
+
this.publishedKeys = await published_intro_key_1.PublishedIntroKey.makeAndInit(await fs.writableFile(FILE_FOR_INTRO_KEY_ON_SERVER), getSigner, this.random, pkeyOnServer);
|
|
69
70
|
this.storage = (0, keyring_storage_1.makeKeyringStorage)(fs);
|
|
70
71
|
await this.storage.start();
|
|
71
72
|
const serialForm = await this.storage.load();
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { ParamOnServer } from '../../lib-client/asmail/service-config';
|
|
2
|
+
import { AsyncRNG } from '../../lib-common/rng-def';
|
|
2
3
|
import { GetSigner } from '../id-manager';
|
|
3
4
|
import { JWKeyPair, MsgKeyRole } from './common';
|
|
4
5
|
type WritableFile = web3n.files.WritableFile;
|
|
5
6
|
type IntroKeyCAP = web3n.keys.Keyrings['introKeyOnASMailServer'];
|
|
6
7
|
export declare class PublishedIntroKey {
|
|
7
8
|
private readonly getSigner;
|
|
9
|
+
private readonly random;
|
|
8
10
|
private pkeyOnServer;
|
|
9
11
|
private published;
|
|
10
12
|
private readonly fileProc;
|
|
11
13
|
private periodicExpiryCheck;
|
|
12
14
|
private constructor();
|
|
13
|
-
static makeAndInit(file: WritableFile, getSigner: GetSigner, pkeyOnServer: ParamOnServer<'init-pub-key'>): Promise<PublishedIntroKey>;
|
|
15
|
+
static makeAndInit(file: WritableFile, getSigner: GetSigner, random: AsyncRNG, pkeyOnServer: ParamOnServer<'init-pub-key'>): Promise<PublishedIntroKey>;
|
|
14
16
|
private startExpiryCheckProcess;
|
|
15
17
|
close(): Promise<void>;
|
|
16
18
|
private onFileEvent;
|
|
@@ -23,8 +23,9 @@ const common_1 = require("./common");
|
|
|
23
23
|
const INTRO_KEY_VALIDITY = 31 * 24 * 60 * 60;
|
|
24
24
|
const UPDATE_BEFORE_EXPIRY = 7 * 24 * 60 * 60;
|
|
25
25
|
class PublishedIntroKey {
|
|
26
|
-
constructor(getSigner, pkeyOnServer) {
|
|
26
|
+
constructor(getSigner, random, pkeyOnServer) {
|
|
27
27
|
this.getSigner = getSigner;
|
|
28
|
+
this.random = random;
|
|
28
29
|
this.pkeyOnServer = pkeyOnServer;
|
|
29
30
|
this.published = {
|
|
30
31
|
previous: []
|
|
@@ -33,8 +34,8 @@ class PublishedIntroKey {
|
|
|
33
34
|
this.fileProc = new file_based_json_1.JsonFileProc(this.onFileEvent.bind(this));
|
|
34
35
|
Object.seal(this);
|
|
35
36
|
}
|
|
36
|
-
static async makeAndInit(file, getSigner, pkeyOnServer) {
|
|
37
|
-
const pk = new PublishedIntroKey(getSigner, pkeyOnServer);
|
|
37
|
+
static async makeAndInit(file, getSigner, random, pkeyOnServer) {
|
|
38
|
+
const pk = new PublishedIntroKey(getSigner, random, pkeyOnServer);
|
|
38
39
|
if (file.isNew) {
|
|
39
40
|
await pk.fileProc.start(file, () => pk.toFileJSON());
|
|
40
41
|
await pk.update();
|
|
@@ -107,7 +108,7 @@ class PublishedIntroKey {
|
|
|
107
108
|
}
|
|
108
109
|
async makeNewIntroKey() {
|
|
109
110
|
const signer = await this.getSigner();
|
|
110
|
-
const pair = await (0, common_1.generateKeyPair)();
|
|
111
|
+
const pair = await (0, common_1.generateKeyPair)(this.random);
|
|
111
112
|
const certs = {
|
|
112
113
|
pkeyCert: signer.certifyPublicKey(pair.pkey, INTRO_KEY_VALIDITY),
|
|
113
114
|
userCert: signer.userCert,
|
|
@@ -3,6 +3,7 @@ import * as keyDeriv from '../../lib-client/key-derivation';
|
|
|
3
3
|
import type { GetUsersOnDisk } from '../app-files';
|
|
4
4
|
import { LogError } from '../../lib-client/logging/log-to-file';
|
|
5
5
|
import type { Cryptor } from 'ecma-nacl-cryptors';
|
|
6
|
+
import { AsyncRNG } from '../../lib-common/rng-def';
|
|
6
7
|
type JsonKey = web3n.keys.JsonKey;
|
|
7
8
|
export interface ScryptGenParams {
|
|
8
9
|
logN: number;
|
|
@@ -12,10 +13,11 @@ export interface ScryptGenParams {
|
|
|
12
13
|
}
|
|
13
14
|
type SignUpService = web3n.startup.SignUpService;
|
|
14
15
|
export declare class SignUp {
|
|
15
|
-
private cryptor;
|
|
16
|
-
private
|
|
17
|
-
private
|
|
18
|
-
private
|
|
16
|
+
private readonly cryptor;
|
|
17
|
+
private readonly random;
|
|
18
|
+
private readonly makeNet;
|
|
19
|
+
private readonly getUsersOnDisk;
|
|
20
|
+
private readonly initForNewUser;
|
|
19
21
|
private readonly watchBoot;
|
|
20
22
|
private readonly logError;
|
|
21
23
|
private mid;
|
|
@@ -23,7 +25,7 @@ export declare class SignUp {
|
|
|
23
25
|
private serviceURL;
|
|
24
26
|
private netLazyInit;
|
|
25
27
|
private get net();
|
|
26
|
-
constructor(serviceURL: string, cryptor: Cryptor, makeNet: () => NetClient, getUsersOnDisk: GetUsersOnDisk, initForNewUser: (u: CreatedUser) => Promise<void>, watchBoot: SignUpService['watchBoot'], logError: LogError);
|
|
28
|
+
constructor(serviceURL: string, cryptor: Cryptor, random: AsyncRNG, makeNet: () => NetClient, getUsersOnDisk: GetUsersOnDisk, initForNewUser: (u: CreatedUser) => Promise<void>, watchBoot: SignUpService['watchBoot'], logError: LogError);
|
|
27
29
|
private setServiceURL;
|
|
28
30
|
private getAvailableDomains;
|
|
29
31
|
private getAvailableAddresses;
|
|
@@ -22,10 +22,10 @@ const jwkeys_1 = require("../../lib-common/jwkeys");
|
|
|
22
22
|
const buffer_utils_1 = require("../../lib-common/buffer-utils");
|
|
23
23
|
const canonical_address_1 = require("../../lib-common/canonical-address");
|
|
24
24
|
const keyDeriv = require("../../lib-client/key-derivation");
|
|
25
|
-
const random = require("../../lib-common/random-node");
|
|
26
25
|
const ecma_nacl_1 = require("ecma-nacl");
|
|
27
26
|
const sign_in_1 = require("./sign-in");
|
|
28
27
|
const error_1 = require("../../lib-common/exceptions/error");
|
|
28
|
+
const rng_def_1 = require("../../lib-common/rng-def");
|
|
29
29
|
/**
|
|
30
30
|
* With these parameters scrypt shall use memory around:
|
|
31
31
|
* (2^7)*r*N === (2^7)*(2^3)*(2^17) === 2^27 === (2^7)*(2^20) === 128MB
|
|
@@ -38,13 +38,13 @@ const defaultDerivParams = {
|
|
|
38
38
|
Object.freeze(defaultDerivParams);
|
|
39
39
|
const SALT_LEN = 32;
|
|
40
40
|
const KEY_ID_LEN = 10;
|
|
41
|
-
async function makeLabeledMidLoginKey(cryptor) {
|
|
42
|
-
const sk = await random
|
|
41
|
+
async function makeLabeledMidLoginKey(cryptor, random) {
|
|
42
|
+
const sk = await random(ecma_nacl_1.box.KEY_LENGTH);
|
|
43
43
|
const skey = (0, jwkeys_1.keyToJson)({
|
|
44
44
|
k: sk,
|
|
45
45
|
alg: ecma_nacl_1.box.JWK_ALG_NAME,
|
|
46
46
|
use: jwkeys_1.use.MID_PKLOGIN,
|
|
47
|
-
kid: await
|
|
47
|
+
kid: await (0, rng_def_1.stringOfB64Chars)(KEY_ID_LEN, random)
|
|
48
48
|
});
|
|
49
49
|
const pkey = (0, jwkeys_1.keyToJson)({
|
|
50
50
|
k: await cryptor.box.generate_pubkey(sk),
|
|
@@ -61,8 +61,9 @@ class SignUp {
|
|
|
61
61
|
}
|
|
62
62
|
return this.netLazyInit;
|
|
63
63
|
}
|
|
64
|
-
constructor(serviceURL, cryptor, makeNet, getUsersOnDisk, initForNewUser, watchBoot, logError) {
|
|
64
|
+
constructor(serviceURL, cryptor, random, makeNet, getUsersOnDisk, initForNewUser, watchBoot, logError) {
|
|
65
65
|
this.cryptor = cryptor;
|
|
66
|
+
this.random = random;
|
|
66
67
|
this.makeNet = makeNet;
|
|
67
68
|
this.getUsersOnDisk = getUsersOnDisk;
|
|
68
69
|
this.initForNewUser = initForNewUser;
|
|
@@ -112,7 +113,7 @@ class SignUp {
|
|
|
112
113
|
logN: defaultDerivParams.logN,
|
|
113
114
|
r: defaultDerivParams.r,
|
|
114
115
|
p: defaultDerivParams.p,
|
|
115
|
-
salt: buffer_utils_1.base64.pack(await random
|
|
116
|
+
salt: buffer_utils_1.base64.pack(await this.random(SALT_LEN))
|
|
116
117
|
};
|
|
117
118
|
const progressCB = (0, sign_in_1.makeKeyGenProgressCB)(progressStart, progressEnd, originalProgressCB);
|
|
118
119
|
const skey = await keyDeriv.deriveStorageSKey(this.cryptor, pass, derivParams, progressCB);
|
|
@@ -128,11 +129,11 @@ class SignUp {
|
|
|
128
129
|
logN: defaultDerivParams.logN,
|
|
129
130
|
r: defaultDerivParams.r,
|
|
130
131
|
p: defaultDerivParams.p,
|
|
131
|
-
salt: buffer_utils_1.base64.pack(await random
|
|
132
|
+
salt: buffer_utils_1.base64.pack(await this.random(SALT_LEN))
|
|
132
133
|
};
|
|
133
134
|
const progressCB = (0, sign_in_1.makeKeyGenProgressCB)(progressStart, progressEnd, originalProgressCB);
|
|
134
135
|
const defaultPair = await keyDeriv.deriveMidKeyPair(this.cryptor, pass, derivParams, progressCB, jwkeys_1.use.MID_PKLOGIN, '_');
|
|
135
|
-
const labeledKey = await makeLabeledMidLoginKey(this.cryptor);
|
|
136
|
+
const labeledKey = await makeLabeledMidLoginKey(this.cryptor, this.random);
|
|
136
137
|
this.mid = {
|
|
137
138
|
defaultSKey: defaultPair.skey,
|
|
138
139
|
labeledSKey: labeledKey.skey,
|
|
@@ -8,17 +8,19 @@ import { StoragePathForUser } from '../app-files';
|
|
|
8
8
|
import { LogError } from '../../lib-client/logging/log-to-file';
|
|
9
9
|
import { MakeNet } from '..';
|
|
10
10
|
import type { Cryptor } from 'ecma-nacl-cryptors';
|
|
11
|
+
import { AsyncRNG } from '../../lib-common/rng-def';
|
|
11
12
|
type WritableFS = web3n.files.WritableFS;
|
|
12
13
|
type StorageType = web3n.storage.StorageType;
|
|
13
14
|
type FSItem = web3n.files.FSItem;
|
|
14
15
|
type ProgressCB = web3n.startup.ProgressCB;
|
|
15
16
|
export declare class Storages implements FactoryOfFSs {
|
|
16
|
-
private cryptor;
|
|
17
|
-
private
|
|
17
|
+
private readonly cryptor;
|
|
18
|
+
private readonly random;
|
|
19
|
+
private readonly storageDirForUser;
|
|
18
20
|
private synced;
|
|
19
21
|
private local;
|
|
20
22
|
private preCloseWaits;
|
|
21
|
-
constructor(cryptor: AsyncSBoxCryptor, storageDirForUser: StoragePathForUser);
|
|
23
|
+
constructor(cryptor: AsyncSBoxCryptor, random: AsyncRNG, storageDirForUser: StoragePathForUser);
|
|
22
24
|
makeStorageCAP(appDomain: string, policy: StoragePolicy): {
|
|
23
25
|
cap: Service;
|
|
24
26
|
close: () => void;
|
|
@@ -216,8 +216,9 @@ class StorageAndFS {
|
|
|
216
216
|
Object.freeze(StorageAndFS.prototype);
|
|
217
217
|
Object.freeze(StorageAndFS);
|
|
218
218
|
class Storages {
|
|
219
|
-
constructor(cryptor, storageDirForUser) {
|
|
219
|
+
constructor(cryptor, random, storageDirForUser) {
|
|
220
220
|
this.cryptor = cryptor;
|
|
221
|
+
this.random = random;
|
|
221
222
|
this.storageDirForUser = storageDirForUser;
|
|
222
223
|
this.synced = undefined;
|
|
223
224
|
this.local = undefined;
|
|
@@ -286,7 +287,7 @@ class Storages {
|
|
|
286
287
|
return;
|
|
287
288
|
}
|
|
288
289
|
const key = await (0, key_derivation_1.deriveStorageSKey)(cryptor, pass, params, storeKeyProgressCB);
|
|
289
|
-
const indicatorStore = await StorageAndFS.existing(await storage_2.LocalStorage.makeAndStart((0, path_1.join)(storageDir, LOCAL_STORAGE_DIR), this.storageGetterForLocalStorage, this.cryptor, async () => { }), key);
|
|
290
|
+
const indicatorStore = await StorageAndFS.existing(await storage_2.LocalStorage.makeAndStart((0, path_1.join)(storageDir, LOCAL_STORAGE_DIR), this.storageGetterForLocalStorage, this.cryptor, this.random, async () => { }), key);
|
|
290
291
|
return (indicatorStore ? key : undefined);
|
|
291
292
|
}
|
|
292
293
|
async startInitFromCache(user, keyGen, makeNet, resolver, logError) {
|
|
@@ -296,11 +297,11 @@ class Storages {
|
|
|
296
297
|
return;
|
|
297
298
|
}
|
|
298
299
|
const key = await keyGen(params);
|
|
299
|
-
this.local = await StorageAndFS.existing(await storage_2.LocalStorage.makeAndStart((0, path_1.join)(storageDir, LOCAL_STORAGE_DIR), this.storageGetterForLocalStorage, this.cryptor, logError), key);
|
|
300
|
+
this.local = await StorageAndFS.existing(await storage_2.LocalStorage.makeAndStart((0, path_1.join)(storageDir, LOCAL_STORAGE_DIR), this.storageGetterForLocalStorage, this.cryptor, this.random, logError), key);
|
|
300
301
|
if (!this.local) {
|
|
301
302
|
return;
|
|
302
303
|
}
|
|
303
|
-
const { syncedStore, setupRemoteAndStartObjProcs } = await storage_1.SyncedStore.makeAndStartWithoutRemote((0, path_1.join)(storageDir, SYNCED_STORAGE_DIR), user, this.storageGetterForSyncedStorage, this.cryptor, () => resolver(user), makeNet(), logError);
|
|
304
|
+
const { syncedStore, setupRemoteAndStartObjProcs } = await storage_1.SyncedStore.makeAndStartWithoutRemote((0, path_1.join)(storageDir, SYNCED_STORAGE_DIR), user, this.storageGetterForSyncedStorage, this.cryptor, this.random, () => resolver(user), makeNet(), logError);
|
|
304
305
|
this.synced = await StorageAndFS.existing(syncedStore, key);
|
|
305
306
|
key.fill(0);
|
|
306
307
|
if (!this.synced) {
|
|
@@ -310,20 +311,20 @@ class Storages {
|
|
|
310
311
|
}
|
|
311
312
|
async initFromRemote(user, getSigner, generateKey, makeNet, resolver, logError) {
|
|
312
313
|
const storageDir = this.storageDirForUser(user);
|
|
313
|
-
const { startObjProcs, syncedStore } = await storage_1.SyncedStore.makeAndStart((0, path_1.join)(storageDir, SYNCED_STORAGE_DIR), user, getSigner, this.storageGetterForSyncedStorage, this.cryptor, () => resolver(user), makeNet(), logError);
|
|
314
|
+
const { startObjProcs, syncedStore } = await storage_1.SyncedStore.makeAndStart((0, path_1.join)(storageDir, SYNCED_STORAGE_DIR), user, getSigner, this.storageGetterForSyncedStorage, this.cryptor, this.random, () => resolver(user), makeNet(), logError);
|
|
314
315
|
const params = await getAndCacheRootKeyDerivParamsFromServer(storageDir, syncedStore.getRootKeyDerivParamsFromServer);
|
|
315
316
|
const key = await generateKey(params);
|
|
316
317
|
this.synced = await StorageAndFS.existing(syncedStore, key);
|
|
317
|
-
this.local = await StorageAndFS.makeNew(await storage_2.LocalStorage.makeAndStart((0, path_1.join)(storageDir, LOCAL_STORAGE_DIR), this.storageGetterForLocalStorage, this.cryptor, logError), key);
|
|
318
|
+
this.local = await StorageAndFS.makeNew(await storage_2.LocalStorage.makeAndStart((0, path_1.join)(storageDir, LOCAL_STORAGE_DIR), this.storageGetterForLocalStorage, this.cryptor, this.random, logError), key);
|
|
318
319
|
key.fill(0);
|
|
319
320
|
startObjProcs();
|
|
320
321
|
return (!!this.synced && !!this.local);
|
|
321
322
|
}
|
|
322
323
|
async initFreshForNewUser(user, getSigner, params, key, makeNet, resolver, logError) {
|
|
323
324
|
const storageDir = this.storageDirForUser(user);
|
|
324
|
-
const { startObjProcs, syncedStore } = await storage_1.SyncedStore.makeAndStart((0, path_1.join)(storageDir, SYNCED_STORAGE_DIR), user, getSigner, this.storageGetterForSyncedStorage, this.cryptor, () => resolver(user), makeNet(), logError);
|
|
325
|
+
const { startObjProcs, syncedStore } = await storage_1.SyncedStore.makeAndStart((0, path_1.join)(storageDir, SYNCED_STORAGE_DIR), user, getSigner, this.storageGetterForSyncedStorage, this.cryptor, this.random, () => resolver(user), makeNet(), logError);
|
|
325
326
|
this.synced = await StorageAndFS.makeNew(syncedStore, key);
|
|
326
|
-
this.local = await StorageAndFS.makeNew(await storage_2.LocalStorage.makeAndStart((0, path_1.join)(storageDir, LOCAL_STORAGE_DIR), this.storageGetterForLocalStorage, this.cryptor, logError), key);
|
|
327
|
+
this.local = await StorageAndFS.makeNew(await storage_2.LocalStorage.makeAndStart((0, path_1.join)(storageDir, LOCAL_STORAGE_DIR), this.storageGetterForLocalStorage, this.cryptor, this.random, logError), key);
|
|
327
328
|
key.fill(0);
|
|
328
329
|
await saveRootKeyDerivParamsToDisk(storageDir, params);
|
|
329
330
|
startObjProcs();
|
|
@@ -2,6 +2,7 @@ import { Storage, NodesContainer, StorageGetter, ObjId, NodeEvent, LocalObjStatu
|
|
|
2
2
|
import { LogError } from '../../../lib-client/logging/log-to-file';
|
|
3
3
|
import { AsyncSBoxCryptor, Subscribe, ObjSource } from 'xsp-files';
|
|
4
4
|
import { Observable } from 'rxjs';
|
|
5
|
+
import { AsyncRNG } from '../../../lib-common/rng-def';
|
|
5
6
|
type FolderEvent = web3n.files.FolderEvent;
|
|
6
7
|
type FileEvent = web3n.files.FileEvent;
|
|
7
8
|
type FSType = web3n.files.FSType;
|
|
@@ -9,6 +10,7 @@ export declare class LocalStorage implements Storage {
|
|
|
9
10
|
private readonly files;
|
|
10
11
|
private readonly getStorages;
|
|
11
12
|
readonly cryptor: AsyncSBoxCryptor;
|
|
13
|
+
readonly random: AsyncRNG;
|
|
12
14
|
readonly logError: LogError;
|
|
13
15
|
readonly type = "local";
|
|
14
16
|
readonly versioned = true;
|
|
@@ -16,7 +18,7 @@ export declare class LocalStorage implements Storage {
|
|
|
16
18
|
readonly connect: undefined;
|
|
17
19
|
private readonly events;
|
|
18
20
|
private constructor();
|
|
19
|
-
static makeAndStart(path: string, getStorages: StorageGetter, cryptor: AsyncSBoxCryptor, logError: LogError): Promise<Storage>;
|
|
21
|
+
static makeAndStart(path: string, getStorages: StorageGetter, cryptor: AsyncSBoxCryptor, random: AsyncRNG, logError: LogError): Promise<Storage>;
|
|
20
22
|
getNodeEvents(): Observable<NodeEvent>;
|
|
21
23
|
broadcastNodeEvent(objId: ObjId, parentObjId: ObjId | undefined, childObjId: ObjId | undefined, event: FolderEvent | FileEvent): void;
|
|
22
24
|
storageForLinking(type: FSType, location?: string): Storage;
|
|
@@ -19,16 +19,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
19
19
|
exports.LocalStorage = void 0;
|
|
20
20
|
const common_1 = require("../../../lib-client/xsp-fs/common");
|
|
21
21
|
const exceptions_1 = require("../../../lib-client/xsp-fs/exceptions");
|
|
22
|
-
const random_node_1 = require("../../../lib-common/random-node");
|
|
22
|
+
const random_node_1 = require("../../../lib-common-on-node/random-node");
|
|
23
23
|
const ecma_nacl_1 = require("ecma-nacl");
|
|
24
24
|
const buffer_utils_1 = require("../../../lib-common/buffer-utils");
|
|
25
25
|
const obj_files_1 = require("./obj-files");
|
|
26
26
|
const utils_for_observables_1 = require("../../../lib-common/utils-for-observables");
|
|
27
27
|
class LocalStorage {
|
|
28
|
-
constructor(files, getStorages, cryptor, logError) {
|
|
28
|
+
constructor(files, getStorages, cryptor, random, logError) {
|
|
29
29
|
this.files = files;
|
|
30
30
|
this.getStorages = getStorages;
|
|
31
31
|
this.cryptor = cryptor;
|
|
32
|
+
this.random = random;
|
|
32
33
|
this.logError = logError;
|
|
33
34
|
this.type = 'local';
|
|
34
35
|
this.versioned = true;
|
|
@@ -37,9 +38,9 @@ class LocalStorage {
|
|
|
37
38
|
this.events = new utils_for_observables_1.Broadcast();
|
|
38
39
|
Object.seal(this);
|
|
39
40
|
}
|
|
40
|
-
static async makeAndStart(path, getStorages, cryptor, logError) {
|
|
41
|
+
static async makeAndStart(path, getStorages, cryptor, random, logError) {
|
|
41
42
|
const files = await obj_files_1.ObjFiles.makeFor(path, logError);
|
|
42
|
-
const s = new LocalStorage(files, getStorages, cryptor, logError);
|
|
43
|
+
const s = new LocalStorage(files, getStorages, cryptor, random, logError);
|
|
43
44
|
return (0, common_1.wrapStorageImplementation)(s);
|
|
44
45
|
}
|
|
45
46
|
getNodeEvents() {
|
|
@@ -6,6 +6,7 @@ import { AsyncSBoxCryptor, Subscribe, ObjSource } from 'xsp-files';
|
|
|
6
6
|
import { NetClient } from '../../../lib-client/request-utils';
|
|
7
7
|
import { Observable } from 'rxjs';
|
|
8
8
|
import { UploadHeaderChange } from '../../../lib-client/xsp-fs/common';
|
|
9
|
+
import { AsyncRNG } from '../../../lib-common/rng-def';
|
|
9
10
|
type FolderEvent = web3n.files.FolderEvent;
|
|
10
11
|
type FileEvent = web3n.files.FileEvent;
|
|
11
12
|
type SyncStatus = web3n.files.SyncStatus;
|
|
@@ -16,6 +17,7 @@ export declare class SyncedStore implements ISyncedStorage {
|
|
|
16
17
|
private readonly remoteStorage;
|
|
17
18
|
private readonly getStorages;
|
|
18
19
|
readonly cryptor: AsyncSBoxCryptor;
|
|
20
|
+
readonly random: AsyncRNG;
|
|
19
21
|
readonly logError: LogError;
|
|
20
22
|
readonly type: web3n.files.FSType;
|
|
21
23
|
readonly versioned = true;
|
|
@@ -24,11 +26,11 @@ export declare class SyncedStore implements ISyncedStorage {
|
|
|
24
26
|
private readonly uploader;
|
|
25
27
|
private readonly events;
|
|
26
28
|
private constructor();
|
|
27
|
-
static makeAndStart(path: string, user: string, getSigner: IGetMailerIdSigner, getStorages: StorageGetter, cryptor: AsyncSBoxCryptor, remoteServiceUrl: () => Promise<string>, net: NetClient, logError: LogError): Promise<{
|
|
29
|
+
static makeAndStart(path: string, user: string, getSigner: IGetMailerIdSigner, getStorages: StorageGetter, cryptor: AsyncSBoxCryptor, random: AsyncRNG, remoteServiceUrl: () => Promise<string>, net: NetClient, logError: LogError): Promise<{
|
|
28
30
|
syncedStore: ISyncedStorage;
|
|
29
31
|
startObjProcs: () => void;
|
|
30
32
|
}>;
|
|
31
|
-
static makeAndStartWithoutRemote(path: string, user: string, getStorages: StorageGetter, cryptor: AsyncSBoxCryptor, remoteServiceUrl: () => Promise<string>, net: NetClient, logError: LogError): Promise<{
|
|
33
|
+
static makeAndStartWithoutRemote(path: string, user: string, getStorages: StorageGetter, cryptor: AsyncSBoxCryptor, random: AsyncRNG, remoteServiceUrl: () => Promise<string>, net: NetClient, logError: LogError): Promise<{
|
|
32
34
|
syncedStore: ISyncedStorage;
|
|
33
35
|
setupRemoteAndStartObjProcs: (getSigner: IGetMailerIdSigner) => void;
|
|
34
36
|
}>;
|
|
@@ -21,7 +21,7 @@ const common_1 = require("../../../lib-client/xsp-fs/common");
|
|
|
21
21
|
const exceptions_1 = require("../../../lib-client/xsp-fs/exceptions");
|
|
22
22
|
const storage_owner_1 = require("../../../lib-client/3nstorage/storage-owner");
|
|
23
23
|
const obj_files_1 = require("./obj-files");
|
|
24
|
-
const random_node_1 = require("../../../lib-common/random-node");
|
|
24
|
+
const random_node_1 = require("../../../lib-common-on-node/random-node");
|
|
25
25
|
const buffer_utils_1 = require("../../../lib-common/buffer-utils");
|
|
26
26
|
const xsp_files_1 = require("xsp-files");
|
|
27
27
|
const remote_events_1 = require("./remote-events");
|
|
@@ -29,11 +29,12 @@ const upsyncer_1 = require("./upsyncer");
|
|
|
29
29
|
const rxjs_1 = require("rxjs");
|
|
30
30
|
const utils_for_observables_1 = require("../../../lib-common/utils-for-observables");
|
|
31
31
|
class SyncedStore {
|
|
32
|
-
constructor(files, remoteStorage, getStorages, cryptor, logError) {
|
|
32
|
+
constructor(files, remoteStorage, getStorages, cryptor, random, logError) {
|
|
33
33
|
this.files = files;
|
|
34
34
|
this.remoteStorage = remoteStorage;
|
|
35
35
|
this.getStorages = getStorages;
|
|
36
36
|
this.cryptor = cryptor;
|
|
37
|
+
this.random = random;
|
|
37
38
|
this.logError = logError;
|
|
38
39
|
this.type = 'synced';
|
|
39
40
|
this.versioned = true;
|
|
@@ -43,10 +44,10 @@ class SyncedStore {
|
|
|
43
44
|
this.uploader = new upsyncer_1.UpSyncer(this.remoteStorage, this.logError);
|
|
44
45
|
Object.seal(this);
|
|
45
46
|
}
|
|
46
|
-
static async makeAndStart(path, user, getSigner, getStorages, cryptor, remoteServiceUrl, net, logError) {
|
|
47
|
+
static async makeAndStart(path, user, getSigner, getStorages, cryptor, random, remoteServiceUrl, net, logError) {
|
|
47
48
|
const remote = storage_owner_1.StorageOwner.make(user, getSigner, remoteServiceUrl, net);
|
|
48
49
|
const objFiles = await obj_files_1.ObjFiles.makeFor(path, remote, () => s.whenConnected(), logError);
|
|
49
|
-
const s = new SyncedStore(objFiles, remote, getStorages, cryptor, logError);
|
|
50
|
+
const s = new SyncedStore(objFiles, remote, getStorages, cryptor, random, logError);
|
|
50
51
|
s.uploader.start();
|
|
51
52
|
return {
|
|
52
53
|
syncedStore: (0, common_1.wrapSyncStorageImplementation)(s),
|
|
@@ -55,10 +56,10 @@ class SyncedStore {
|
|
|
55
56
|
}
|
|
56
57
|
};
|
|
57
58
|
}
|
|
58
|
-
static async makeAndStartWithoutRemote(path, user, getStorages, cryptor, remoteServiceUrl, net, logError) {
|
|
59
|
+
static async makeAndStartWithoutRemote(path, user, getStorages, cryptor, random, remoteServiceUrl, net, logError) {
|
|
59
60
|
const { remote, setMid } = storage_owner_1.StorageOwner.makeBeforeMidSetup(user, remoteServiceUrl, net);
|
|
60
61
|
const objFiles = await obj_files_1.ObjFiles.makeFor(path, remote, () => s.whenConnected(), logError);
|
|
61
|
-
const s = new SyncedStore(objFiles, remote, getStorages, cryptor, logError);
|
|
62
|
+
const s = new SyncedStore(objFiles, remote, getStorages, cryptor, random, logError);
|
|
62
63
|
return {
|
|
63
64
|
syncedStore: (0, common_1.wrapSyncStorageImplementation)(s),
|
|
64
65
|
setupRemoteAndStartObjProcs: getSigner => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Abortable } from 'events';
|
|
1
|
+
import type { Abortable } from 'events';
|
|
2
2
|
import type { BufferEncodingOption, promises as fsFns, Mode, ObjectEncodingOptions, OpenMode, RmDirOptions, StatOptions, Stats } from 'fs';
|
|
3
3
|
import { FlagAndOpenMode } from 'fs/promises';
|
|
4
4
|
import type Stream = require('stream');
|
|
@@ -61,9 +61,7 @@ declare function readlink(path: string, options: BufferEncodingOption): Promise<
|
|
|
61
61
|
declare function readlink(path: string, options?: ObjectEncodingOptions | string | null): Promise<string | Buffer>;
|
|
62
62
|
declare function lstat(path: string, opts?: StatOptions): Promise<Stats>;
|
|
63
63
|
declare function stat(path: string, opts?: StatOptions): Promise<Stats>;
|
|
64
|
-
declare function readdir(path: string
|
|
65
|
-
recursive?: boolean;
|
|
66
|
-
}): Promise<string[]>;
|
|
64
|
+
declare function readdir(path: string): Promise<string[]>;
|
|
67
65
|
declare function rmdir(path: string, options?: RmDirOptions): Promise<void>;
|
|
68
66
|
declare function unlink(path: string): Promise<void>;
|
|
69
67
|
declare function rename(oldPath: string, newPath: string): Promise<void>;
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
19
|
exports.ExposedObjs = exports.ServicesSideImpl = void 0;
|
|
20
20
|
const protobuf_msg_1 = require("./protobuf-msg");
|
|
21
|
-
const random_node_1 = require("../lib-common/random-node");
|
|
22
21
|
const connector_1 = require("./connector");
|
|
23
22
|
class ServicesSideImpl {
|
|
24
23
|
constructor(sendMsg) {
|
|
@@ -161,7 +160,7 @@ class ExposedObjs {
|
|
|
161
160
|
newRef(objType) {
|
|
162
161
|
let id;
|
|
163
162
|
do {
|
|
164
|
-
id = (
|
|
163
|
+
id = `${Math.floor(Math.random() * Number.MAX_SAFE_INTEGER)}`;
|
|
165
164
|
} while (this.objs.has(id));
|
|
166
165
|
return {
|
|
167
166
|
objType, path: [id]
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NetClient } from '../request-utils';
|
|
2
2
|
import { ServiceUser, ICalcDHSharedKey, LoginCompletion } from '../user-with-pkl-session';
|
|
3
3
|
import { MailerIdSigner } from '../../lib-common/mailerid-sigs/user';
|
|
4
|
+
import { AsyncRNG } from '../../lib-common/rng-def';
|
|
4
5
|
export interface ProvisioningCompletion {
|
|
5
6
|
keyParams: any;
|
|
6
7
|
serverPKey: Uint8Array;
|
|
@@ -13,6 +14,7 @@ export interface ProvisioningCompletion {
|
|
|
13
14
|
* identified by a given uri.
|
|
14
15
|
*/
|
|
15
16
|
export declare class MailerIdProvisioner extends ServiceUser {
|
|
17
|
+
private readonly random;
|
|
16
18
|
private userCert;
|
|
17
19
|
private provCert;
|
|
18
20
|
private midDomain;
|
|
@@ -22,7 +24,7 @@ export declare class MailerIdProvisioner extends ServiceUser {
|
|
|
22
24
|
* @param userId
|
|
23
25
|
* @param uri identifies place of MailerId service.
|
|
24
26
|
*/
|
|
25
|
-
constructor(userId: string, serviceUri: string, net: NetClient);
|
|
27
|
+
constructor(userId: string, serviceUri: string, net: NetClient, random: AsyncRNG);
|
|
26
28
|
private setUrlAndDomain;
|
|
27
29
|
/**
|
|
28
30
|
* @param pkey is a public key, that needs to be certified.
|