core-3nweb-client-lib 0.49.6 → 0.49.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/api-defs/files.d.ts +11 -5
- package/build/core/asmail/delivery/common.d.ts +8 -28
- package/build/core/asmail/delivery/common.js +1 -47
- package/build/core/asmail/delivery/index.js +3 -3
- package/build/core/asmail/delivery/per-recipient-wip.js +3 -2
- package/build/core/asmail/inbox/index.d.ts +1 -2
- package/build/core/asmail/inbox/index.js +14 -15
- package/build/core/asmail/inbox/msg-indexing/dataset/v0/sql-db-v-none.d.ts +11 -0
- package/build/core/asmail/inbox/msg-indexing/dataset/v0/sql-db-v-none.js +25 -0
- package/build/core/asmail/inbox/msg-indexing/dataset/v1/logs.d.ts +33 -0
- package/build/core/asmail/inbox/msg-indexing/dataset/v1/logs.js +72 -0
- package/build/core/asmail/inbox/msg-indexing/dataset/v1/sql-db.d.ts +28 -0
- package/build/core/asmail/inbox/msg-indexing/dataset/v1/sql-db.js +477 -0
- package/build/core/asmail/inbox/msg-indexing/index.d.ts +12 -26
- package/build/core/asmail/inbox/msg-indexing/index.js +47 -68
- package/build/core/asmail/inbox/msg-on-disk.js +1 -2
- package/build/core/asmail/index.js +8 -7
- package/build/core/asmail/msg/common.d.ts +0 -1
- package/build/core/asmail/msg/common.js +1 -1
- package/build/core/index.js +7 -4
- package/build/core/keyring/common.d.ts +1 -0
- package/build/core/keyring/common.js +2 -1
- package/build/core/keyring/index.d.ts +7 -44
- package/build/core/keyring/index.js +89 -222
- package/build/core/keyring/introductory-keys/published-intro-key.d.ts +17 -0
- package/build/core/keyring/introductory-keys/published-intro-key.js +190 -0
- package/build/core/keyring/peer-keys/dataset/v1/json-files.d.ts +105 -0
- package/build/core/keyring/peer-keys/dataset/v1/json-files.js +89 -0
- package/build/core/keyring/peer-keys/dataset/v2/logs.d.ts +43 -0
- package/build/core/keyring/peer-keys/dataset/v2/logs.js +116 -0
- package/build/core/keyring/peer-keys/dataset/v2/peer-keys-db.d.ts +73 -0
- package/build/core/keyring/peer-keys/dataset/v2/peer-keys-db.js +543 -0
- package/build/core/keyring/peer-keys/index.d.ts +24 -0
- package/build/core/keyring/peer-keys/index.js +208 -0
- package/build/core/storage/synced/obj-files.js +10 -3
- package/build/core/storage/synced/obj-status.d.ts +1 -1
- package/build/core/storage/synced/obj-status.js +8 -2
- package/build/core/storage/synced/storage.d.ts +4 -4
- package/build/core/storage/system-folders/apps-data.d.ts +0 -1
- package/build/core/storage/system-folders/apps-data.js +2 -6
- package/build/lib-client/fs-utils/fs-sync-utils.d.ts +1 -1
- package/build/lib-client/fs-utils/fs-sync-utils.js +70 -13
- package/build/lib-client/xsp-fs/fs.js +3 -1
- package/build/lib-client/xsp-fs/node-in-fs.d.ts +1 -0
- package/build/lib-client/xsp-fs/node-in-fs.js +7 -2
- package/build/lib-client/xsp-fs/node-persistence.js +1 -3
- package/build/lib-client/xsp-fs/xsp-payload-v2.js +1 -2
- package/build/lib-common/dataset-sync/per-device-json-array-logs.d.ts +58 -0
- package/build/lib-common/dataset-sync/per-device-json-array-logs.js +432 -0
- package/build/lib-common/number-line.d.ts +10 -0
- package/build/lib-common/number-line.js +66 -0
- package/build/lib-common/objs-on-disk/obj-version-file.d.ts +1 -1
- package/build/lib-common/objs-on-disk/obj-version-file.js +3 -3
- package/build/lib-common/rng-def.d.ts +1 -0
- package/build/lib-common/rng-def.js +8 -0
- package/build/lib-sqlite-on-3nstorage/for-sqlite.d.ts +38 -0
- package/build/lib-sqlite-on-3nstorage/for-sqlite.js +162 -0
- package/build/lib-sqlite-on-3nstorage/index.d.ts +18 -5
- package/build/lib-sqlite-on-3nstorage/index.js +49 -26
- package/build/tests/caps-api/file-sink-checks/splice.js +72 -1
- package/build/tests/caps-api/fs-checks/sync-on-one-dev/upload.js +27 -1
- package/build/tests/caps-api/fs-checks/sync-with-two-devs/update-propagation.js +12 -3
- package/build/tests/computer.3nweb.core/inbox/msg-indexing.js +16 -12
- package/build/tests/computer.3nweb.core/keyrings.js +113 -28
- package/build/tests/jasmine.js +2 -2
- package/build/tests/units/number-line.js +9 -9
- package/package.json +2 -1
- package/build/core/asmail/inbox/msg-indexing/logs-n-entries.d.ts +0 -52
- package/build/core/asmail/inbox/msg-indexing/logs-n-entries.js +0 -333
- package/build/core/asmail/inbox/msg-indexing/sql-indexing.d.ts +0 -4
- package/build/core/asmail/inbox/msg-indexing/sql-indexing.js +0 -319
- package/build/core/keyring/correspondent-keys.d.ts +0 -149
- package/build/core/keyring/correspondent-keys.js +0 -403
- package/build/core/keyring/id-to-email-map.d.ts +0 -38
- package/build/core/keyring/id-to-email-map.js +0 -105
- package/build/core/keyring/keyring-storage.d.ts +0 -9
- package/build/core/keyring/keyring-storage.js +0 -54
- package/build/core/keyring/published-intro-key.d.ts +0 -45
- package/build/core/keyring/published-intro-key.js +0 -200
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
Copyright (C) 2015 - 2018, 2025 3NSoft Inc.
|
|
4
|
-
|
|
5
|
-
This program is free software: you can redistribute it and/or modify it under
|
|
6
|
-
the terms of the GNU General Public License as published by the Free Software
|
|
7
|
-
Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
-
version.
|
|
9
|
-
|
|
10
|
-
This program is distributed in the hope that it will be useful, but
|
|
11
|
-
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
-
See the GNU General Public License for more details.
|
|
14
|
-
|
|
15
|
-
You should have received a copy of the GNU General Public License along with
|
|
16
|
-
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
-
*/
|
|
18
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.PublishedIntroKey = void 0;
|
|
20
|
-
const file_based_json_1 = require("../../lib-client/xsp-fs/util/file-based-json");
|
|
21
|
-
const jwkeys_1 = require("../../lib-common/jwkeys");
|
|
22
|
-
const common_1 = require("./common");
|
|
23
|
-
const INTRO_KEY_VALIDITY = 31 * 24 * 60 * 60;
|
|
24
|
-
const UPDATE_BEFORE_EXPIRY = 7 * 24 * 60 * 60;
|
|
25
|
-
class PublishedIntroKey {
|
|
26
|
-
constructor(getSigner, random, pkeyOnServer) {
|
|
27
|
-
this.getSigner = getSigner;
|
|
28
|
-
this.random = random;
|
|
29
|
-
this.pkeyOnServer = pkeyOnServer;
|
|
30
|
-
this.published = {
|
|
31
|
-
previous: []
|
|
32
|
-
};
|
|
33
|
-
this.periodicExpiryCheck = undefined;
|
|
34
|
-
this.fileProc = new file_based_json_1.JsonFileProc(this.onFileEvent.bind(this));
|
|
35
|
-
Object.seal(this);
|
|
36
|
-
}
|
|
37
|
-
static async makeAndInit(file, getSigner, random, pkeyOnServer) {
|
|
38
|
-
const pk = new PublishedIntroKey(getSigner, random, pkeyOnServer);
|
|
39
|
-
if (file.isNew) {
|
|
40
|
-
await pk.fileProc.start(file, () => pk.toFileJSON());
|
|
41
|
-
await pk.update();
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
await pk.fileProc.start(file, undefined);
|
|
45
|
-
pk.setFromJSON((await pk.fileProc.get()).json);
|
|
46
|
-
await pk.absorbRemoteChanges();
|
|
47
|
-
pk.startExpiryCheckProcess(true);
|
|
48
|
-
}
|
|
49
|
-
return pk;
|
|
50
|
-
}
|
|
51
|
-
startExpiryCheckProcess(calledInInit = false) {
|
|
52
|
-
var _a, _b;
|
|
53
|
-
if (!calledInInit && !this.periodicExpiryCheck) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
if (this.published.current) {
|
|
57
|
-
const { pkeyCert } = this.published.current.certs;
|
|
58
|
-
const expiryInSeconds = (0, jwkeys_1.getKeyCert)(pkeyCert).expiresAt;
|
|
59
|
-
const now = Math.floor(Date.now() / 1000);
|
|
60
|
-
if (expiryInSeconds < (now + UPDATE_BEFORE_EXPIRY)) {
|
|
61
|
-
this.update();
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
if (calledInInit) {
|
|
65
|
-
this.periodicExpiryCheck = setTimeout(() => this.startExpiryCheckProcess(), UPDATE_BEFORE_EXPIRY * 1000 / 20);
|
|
66
|
-
(_b = (_a = this.periodicExpiryCheck).unref) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
async close() {
|
|
70
|
-
if (this.periodicExpiryCheck) {
|
|
71
|
-
clearTimeout(this.periodicExpiryCheck);
|
|
72
|
-
this.periodicExpiryCheck = undefined;
|
|
73
|
-
}
|
|
74
|
-
await this.fileProc.close();
|
|
75
|
-
}
|
|
76
|
-
async onFileEvent(ev) {
|
|
77
|
-
if (ev.src === 'local') {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
switch (ev.type) {
|
|
81
|
-
case 'file-change':
|
|
82
|
-
await this.fileProc.order.startOrChain(() => this.absorbRemoteChanges());
|
|
83
|
-
break;
|
|
84
|
-
case 'removed':
|
|
85
|
-
throw new Error(`Unexpected removal of file with parameter "anon-sender/invites"`);
|
|
86
|
-
default:
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
setFromJSON(json) {
|
|
91
|
-
if (!Array.isArray(json.previous)) { // migration part
|
|
92
|
-
json.previous = (json.previous ? [json.previous] : []);
|
|
93
|
-
}
|
|
94
|
-
this.published = json;
|
|
95
|
-
}
|
|
96
|
-
toFileJSON() {
|
|
97
|
-
return this.published;
|
|
98
|
-
}
|
|
99
|
-
// private toServerParam(): PKeyCertChain|undefined {
|
|
100
|
-
// return this.published.current?.certs;
|
|
101
|
-
// }
|
|
102
|
-
async absorbRemoteChanges() {
|
|
103
|
-
// XXX
|
|
104
|
-
// - check for changes: what is needed here from fileProc, and what is
|
|
105
|
-
// generic in absorbing remote changes to refactor it into JsonFileProc
|
|
106
|
-
// - absorb and sync, if needed: what can be in JsonFileProc
|
|
107
|
-
// Code from pre-v.sync:
|
|
108
|
-
// const { json } = await this.fileProc.get();
|
|
109
|
-
// this.setFromJSON(json);
|
|
110
|
-
}
|
|
111
|
-
async makeNewIntroKey() {
|
|
112
|
-
const signer = await this.getSigner();
|
|
113
|
-
const pair = await (0, common_1.generateKeyPair)(this.random);
|
|
114
|
-
const certs = {
|
|
115
|
-
pkeyCert: signer.certifyPublicKey(pair.pkey, INTRO_KEY_VALIDITY),
|
|
116
|
-
userCert: signer.userCert,
|
|
117
|
-
provCert: signer.providerCert
|
|
118
|
-
};
|
|
119
|
-
pair.createdAt = Date.now();
|
|
120
|
-
return { pair, certs };
|
|
121
|
-
}
|
|
122
|
-
update() {
|
|
123
|
-
return this.fileProc.order.startOrChain(async () => {
|
|
124
|
-
const { certs, pair: keyPair } = await this.makeNewIntroKey();
|
|
125
|
-
await this.pkeyOnServer.setOnServer(certs);
|
|
126
|
-
this.retireCurrent(keyPair.createdAt);
|
|
127
|
-
this.published.current = { keyPair, certs };
|
|
128
|
-
await this.fileProc.save(this.toFileJSON(), false);
|
|
129
|
-
return certs;
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
;
|
|
133
|
-
retireCurrent(retiredAt) {
|
|
134
|
-
if (!this.published.current) {
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
const current = this.published.current;
|
|
138
|
-
current.keyPair.retiredAt = retiredAt;
|
|
139
|
-
this.published.previous.push(current.keyPair);
|
|
140
|
-
this.published.current = undefined;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* This looks for a published key with a given key id. If it is found, an
|
|
144
|
-
* object is returned with following fields:
|
|
145
|
-
* - pair is JWK key pair;
|
|
146
|
-
* - role of a found key pair;
|
|
147
|
-
* - replacedAt field is present for a previously published key pair,
|
|
148
|
-
* telling, in milliseconds, when this key was superseded a newer one.
|
|
149
|
-
* Undefined is returned, when a key is not found.
|
|
150
|
-
* @param kid
|
|
151
|
-
* @return if key is found, object with following fields is returned:
|
|
152
|
-
*/
|
|
153
|
-
find(kid) {
|
|
154
|
-
// check current key
|
|
155
|
-
if (this.published.current
|
|
156
|
-
&& (this.published.current.keyPair.skey.kid === kid)) {
|
|
157
|
-
return {
|
|
158
|
-
role: 'published_intro',
|
|
159
|
-
pair: this.published.current.keyPair
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
// check previous key
|
|
163
|
-
const pair = this.published.previous.find(({ skey }) => (skey.kid === kid));
|
|
164
|
-
if (pair) {
|
|
165
|
-
return {
|
|
166
|
-
role: 'prev_published_intro',
|
|
167
|
-
pair,
|
|
168
|
-
replacedAt: pair.retiredAt
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
// if nothing found, explicitly return undefined
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
makeIntroKeyCAP() {
|
|
175
|
-
const w = {
|
|
176
|
-
getCurrent: this.getCurrent.bind(this),
|
|
177
|
-
makeAndPublishNew: this.update.bind(this),
|
|
178
|
-
remove: this.removeCurrent.bind(this)
|
|
179
|
-
};
|
|
180
|
-
return Object.freeze(w);
|
|
181
|
-
}
|
|
182
|
-
async getCurrent() {
|
|
183
|
-
var _a;
|
|
184
|
-
const certs = (_a = this.published.current) === null || _a === void 0 ? void 0 : _a.certs;
|
|
185
|
-
return (certs ? certs : null);
|
|
186
|
-
}
|
|
187
|
-
async removeCurrent() {
|
|
188
|
-
if (!this.published.current) {
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
return this.fileProc.order.startOrChain(async () => {
|
|
192
|
-
await this.pkeyOnServer.setOnServer(null);
|
|
193
|
-
this.retireCurrent(Math.floor(Date.now() / 1000));
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
exports.PublishedIntroKey = PublishedIntroKey;
|
|
198
|
-
Object.freeze(PublishedIntroKey.prototype);
|
|
199
|
-
Object.freeze(PublishedIntroKey);
|
|
200
|
-
Object.freeze(exports);
|