@wireapp/core 30.8.0 → 30.9.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/CHANGELOG.md +11 -0
- package/package.json +2 -2
- package/src/main/cryptography/CryptographyDatabaseRepository.d.ts +1 -2
- package/src/main/cryptography/CryptographyDatabaseRepository.js +0 -1
- package/src/main/mls/keyMaterialUpdatesStore/index.d.ts +1 -0
- package/src/main/mls/keyMaterialUpdatesStore/index.js +32 -0
- package/src/main/mls/keyMaterialUpdatesStore/keyMaterialUpdatesStore.d.ts +9 -0
- package/src/main/mls/keyMaterialUpdatesStore/keyMaterialUpdatesStore.js +51 -0
- package/src/main/notification/NotificationDatabaseRepository.d.ts +1 -22
- package/src/main/notification/NotificationDatabaseRepository.js +0 -29
- package/src/main/notification/NotificationService.js +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [30.9.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@30.8.0...@wireapp/core@30.9.0) (2022-09-15)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* use localstorage for keys update date ([#4396](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4396)) ([cce74a3](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/cce74a3a8f403be8d658618a8684c397ab060df3))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [30.8.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@30.7.2...@wireapp/core@30.8.0) (2022-09-14)
|
|
7
18
|
|
|
8
19
|
|
package/package.json
CHANGED
|
@@ -6,8 +6,7 @@ export declare enum DatabaseStores {
|
|
|
6
6
|
PRE_KEYS = "prekeys",
|
|
7
7
|
SESSIONS = "sessions",
|
|
8
8
|
GROUP_IDS = "group_ids",
|
|
9
|
-
PENDING_PROPOSALS = "pending_proposals"
|
|
10
|
-
LAST_KEY_MATERIAL_UPDATE_DATES = "last_key_material_update_dates"
|
|
9
|
+
PENDING_PROPOSALS = "pending_proposals"
|
|
11
10
|
}
|
|
12
11
|
export declare class CryptographyDatabaseRepository {
|
|
13
12
|
private readonly storeEngine;
|
|
@@ -28,7 +28,6 @@ var DatabaseStores;
|
|
|
28
28
|
DatabaseStores["SESSIONS"] = "sessions";
|
|
29
29
|
DatabaseStores["GROUP_IDS"] = "group_ids";
|
|
30
30
|
DatabaseStores["PENDING_PROPOSALS"] = "pending_proposals";
|
|
31
|
-
DatabaseStores["LAST_KEY_MATERIAL_UPDATE_DATES"] = "last_key_material_update_dates";
|
|
32
31
|
})(DatabaseStores = exports.DatabaseStores || (exports.DatabaseStores = {}));
|
|
33
32
|
class CryptographyDatabaseRepository {
|
|
34
33
|
constructor(storeEngine) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './keyMaterialUpdatesStore';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Wire
|
|
4
|
+
* Copyright (C) 2022 Wire Swiss GmbH
|
|
5
|
+
*
|
|
6
|
+
* This program is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
* (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* This program is distributed in the hope that it will be useful,
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
* GNU General Public License for more details.
|
|
15
|
+
*
|
|
16
|
+
* You should have received a copy of the GNU General Public License
|
|
17
|
+
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
23
|
+
}) : (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
o[k2] = m[k];
|
|
26
|
+
}));
|
|
27
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
28
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
29
|
+
};
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
__exportStar(require("./keyMaterialUpdatesStore"), exports);
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CommonMLS, LastKeyMaterialUpdateParams } from '../../notification/types';
|
|
2
|
+
export interface KeyMaterialUpdatesStore {
|
|
3
|
+
[groupId: string]: LastKeyMaterialUpdateParams;
|
|
4
|
+
}
|
|
5
|
+
export declare const keyMaterialUpdatesStore: {
|
|
6
|
+
getAllUpdateDates: () => LastKeyMaterialUpdateParams[];
|
|
7
|
+
storeLastKeyMaterialUpdateDate: ({ groupId, previousUpdateDate }: LastKeyMaterialUpdateParams) => void;
|
|
8
|
+
deleteLastKeyMaterialUpdateDate: ({ groupId }: CommonMLS) => void;
|
|
9
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Wire
|
|
4
|
+
* Copyright (C) 2022 Wire Swiss GmbH
|
|
5
|
+
*
|
|
6
|
+
* This program is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
* (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* This program is distributed in the hope that it will be useful,
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
* GNU General Public License for more details.
|
|
15
|
+
*
|
|
16
|
+
* You should have received a copy of the GNU General Public License
|
|
17
|
+
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.keyMaterialUpdatesStore = void 0;
|
|
22
|
+
const storageKey = 'keyMaterialUpdates';
|
|
23
|
+
const getUpdateDatesMap = () => {
|
|
24
|
+
const storedState = localStorage.getItem(storageKey);
|
|
25
|
+
if (!storedState) {
|
|
26
|
+
return {};
|
|
27
|
+
}
|
|
28
|
+
return JSON.parse(storedState);
|
|
29
|
+
};
|
|
30
|
+
const getAllUpdateDates = () => {
|
|
31
|
+
const storedStateMap = getUpdateDatesMap();
|
|
32
|
+
return Object.values(storedStateMap);
|
|
33
|
+
};
|
|
34
|
+
const storeLastKeyMaterialUpdateDate = ({ groupId, previousUpdateDate }) => {
|
|
35
|
+
const storedState = getUpdateDatesMap();
|
|
36
|
+
const newStoredState = Object.assign(Object.assign({}, storedState), { [groupId]: { groupId, previousUpdateDate } });
|
|
37
|
+
localStorage.setItem(storageKey, JSON.stringify(newStoredState));
|
|
38
|
+
};
|
|
39
|
+
const deleteLastKeyMaterialUpdateDate = ({ groupId }) => {
|
|
40
|
+
const storedState = getUpdateDatesMap();
|
|
41
|
+
if (storedState[groupId]) {
|
|
42
|
+
delete storedState[groupId];
|
|
43
|
+
}
|
|
44
|
+
localStorage.setItem(storageKey, JSON.stringify(storedState));
|
|
45
|
+
};
|
|
46
|
+
exports.keyMaterialUpdatesStore = {
|
|
47
|
+
getAllUpdateDates,
|
|
48
|
+
storeLastKeyMaterialUpdateDate,
|
|
49
|
+
deleteLastKeyMaterialUpdateDate,
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=keyMaterialUpdatesStore.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BackendEvent } from '@wireapp/api-client/src/event';
|
|
2
2
|
import type { Notification } from '@wireapp/api-client/src/notification/';
|
|
3
3
|
import type { CRUDEngine } from '@wireapp/store-engine';
|
|
4
|
-
import { CommonMLS, CompoundGroupIdParams,
|
|
4
|
+
import { CommonMLS, CompoundGroupIdParams, StorePendingProposalsParams } from './types';
|
|
5
5
|
export declare enum DatabaseStores {
|
|
6
6
|
EVENTS = "events"
|
|
7
7
|
}
|
|
@@ -42,25 +42,4 @@ export declare class NotificationDatabaseRepository {
|
|
|
42
42
|
*
|
|
43
43
|
*/
|
|
44
44
|
getStoredPendingProposals(): Promise<StorePendingProposalsParams[]>;
|
|
45
|
-
/**
|
|
46
|
-
* ## MLS only ##
|
|
47
|
-
* Store groupIds with last key material update dates.
|
|
48
|
-
*
|
|
49
|
-
* @param {groupId} params.groupId - groupId of the mls conversation
|
|
50
|
-
* @param {previousUpdateDate} params.previousUpdateDate - date of the previous key material update
|
|
51
|
-
*/
|
|
52
|
-
storeLastKeyMaterialUpdateDate(params: LastKeyMaterialUpdateParams): Promise<boolean>;
|
|
53
|
-
/**
|
|
54
|
-
* ## MLS only ##
|
|
55
|
-
* Delete stored entries for last key materials update dates.
|
|
56
|
-
*
|
|
57
|
-
* @param {groupId} groupId - of the mls conversation
|
|
58
|
-
*/
|
|
59
|
-
deleteLastKeyMaterialUpdateDate({ groupId }: CommonMLS): Promise<boolean>;
|
|
60
|
-
/**
|
|
61
|
-
* ## MLS only ##
|
|
62
|
-
* Get all stored entries for last key materials update dates.
|
|
63
|
-
*
|
|
64
|
-
*/
|
|
65
|
-
getStoredLastKeyMaterialUpdateDates(): Promise<LastKeyMaterialUpdateParams[]>;
|
|
66
45
|
}
|
|
@@ -102,35 +102,6 @@ class NotificationDatabaseRepository {
|
|
|
102
102
|
async getStoredPendingProposals() {
|
|
103
103
|
return this.storeEngine.readAll(STORES.PENDING_PROPOSALS);
|
|
104
104
|
}
|
|
105
|
-
/**
|
|
106
|
-
* ## MLS only ##
|
|
107
|
-
* Store groupIds with last key material update dates.
|
|
108
|
-
*
|
|
109
|
-
* @param {groupId} params.groupId - groupId of the mls conversation
|
|
110
|
-
* @param {previousUpdateDate} params.previousUpdateDate - date of the previous key material update
|
|
111
|
-
*/
|
|
112
|
-
async storeLastKeyMaterialUpdateDate(params) {
|
|
113
|
-
await this.storeEngine.updateOrCreate(STORES.LAST_KEY_MATERIAL_UPDATE_DATES, `${params.groupId}`, params);
|
|
114
|
-
return true;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* ## MLS only ##
|
|
118
|
-
* Delete stored entries for last key materials update dates.
|
|
119
|
-
*
|
|
120
|
-
* @param {groupId} groupId - of the mls conversation
|
|
121
|
-
*/
|
|
122
|
-
async deleteLastKeyMaterialUpdateDate({ groupId }) {
|
|
123
|
-
await this.storeEngine.delete(STORES.LAST_KEY_MATERIAL_UPDATE_DATES, `${groupId}`);
|
|
124
|
-
return true;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* ## MLS only ##
|
|
128
|
-
* Get all stored entries for last key materials update dates.
|
|
129
|
-
*
|
|
130
|
-
*/
|
|
131
|
-
async getStoredLastKeyMaterialUpdateDates() {
|
|
132
|
-
return this.storeEngine.readAll(STORES.LAST_KEY_MATERIAL_UPDATE_DATES);
|
|
133
|
-
}
|
|
134
105
|
}
|
|
135
106
|
exports.NotificationDatabaseRepository = NotificationDatabaseRepository;
|
|
136
107
|
//# sourceMappingURL=NotificationDatabaseRepository.js.map
|
|
@@ -69,6 +69,7 @@ const bazinga64_1 = require("bazinga64");
|
|
|
69
69
|
const TaskScheduler_1 = require("../util/TaskScheduler/TaskScheduler");
|
|
70
70
|
const LowPrecisionTaskScheduler_1 = require("../util/LowPrecisionTaskScheduler/LowPrecisionTaskScheduler");
|
|
71
71
|
const keyPackagesStatusStore_1 = require("../mls/keyPackagesStatusStore/keyPackagesStatusStore");
|
|
72
|
+
const keyMaterialUpdatesStore_1 = require("../mls/keyMaterialUpdatesStore");
|
|
72
73
|
var TOPIC;
|
|
73
74
|
(function (TOPIC) {
|
|
74
75
|
TOPIC["NOTIFICATION_ERROR"] = "NotificationService.TOPIC.NOTIFICATION_ERROR";
|
|
@@ -407,7 +408,7 @@ class NotificationService extends events_1.EventEmitter {
|
|
|
407
408
|
* @param {previousUpdateDate} params.previousUpdateDate - date of the previous key material update
|
|
408
409
|
*/
|
|
409
410
|
async storeLastKeyMaterialUpdateDate(params) {
|
|
410
|
-
|
|
411
|
+
keyMaterialUpdatesStore_1.keyMaterialUpdatesStore.storeLastKeyMaterialUpdateDate(params);
|
|
411
412
|
await this.scheduleTaskToRenewKeyMaterial(params);
|
|
412
413
|
}
|
|
413
414
|
/**
|
|
@@ -420,7 +421,7 @@ class NotificationService extends events_1.EventEmitter {
|
|
|
420
421
|
try {
|
|
421
422
|
const groupConversationExists = await this.mlsService.conversationExists(bazinga64_1.Decoder.fromBase64(groupId).asBytes);
|
|
422
423
|
if (!groupConversationExists) {
|
|
423
|
-
|
|
424
|
+
keyMaterialUpdatesStore_1.keyMaterialUpdatesStore.deleteLastKeyMaterialUpdateDate({ groupId });
|
|
424
425
|
return;
|
|
425
426
|
}
|
|
426
427
|
const groupIdDecodedFromBase64 = bazinga64_1.Decoder.fromBase64(groupId).asBytes;
|
|
@@ -457,7 +458,7 @@ class NotificationService extends events_1.EventEmitter {
|
|
|
457
458
|
*/
|
|
458
459
|
async checkForKeyMaterialsUpdate() {
|
|
459
460
|
try {
|
|
460
|
-
const keyMaterialUpdateDates =
|
|
461
|
+
const keyMaterialUpdateDates = keyMaterialUpdatesStore_1.keyMaterialUpdatesStore.getAllUpdateDates();
|
|
461
462
|
keyMaterialUpdateDates.forEach(date => this.scheduleTaskToRenewKeyMaterial(date));
|
|
462
463
|
}
|
|
463
464
|
catch (error) {
|