@wireapp/core 31.1.3 → 31.2.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/package.json +10 -9
- package/src/main/Account.d.ts +214 -0
- package/src/main/Account.js +463 -0
- package/src/main/CoreError.d.ts +9 -0
- package/src/main/CoreError.js +26 -0
- package/src/main/account/AccountService.d.ts +7 -0
- package/src/main/account/AccountService.js +33 -0
- package/src/main/account/AccountService.js.map +1 -0
- package/src/main/account/index.d.ts +1 -0
- package/src/main/account/index.js +36 -0
- package/src/main/account/index.js.map +1 -0
- package/src/main/auth/LoginSanitizer.d.ts +5 -0
- package/src/main/auth/LoginSanitizer.js +41 -0
- package/src/main/auth/index.d.ts +1 -0
- package/src/main/auth/index.js +36 -0
- package/src/main/broadcast/AvailabilityType.d.ts +2 -0
- package/src/main/broadcast/AvailabilityType.js +21 -0
- package/src/main/broadcast/BroadcastService.d.ts +24 -0
- package/src/main/broadcast/BroadcastService.js +74 -0
- package/src/main/broadcast/index.d.ts +2 -0
- package/src/main/broadcast/index.js +37 -0
- package/src/main/client/ClientBackendRepository.d.ts +11 -0
- package/src/main/client/ClientBackendRepository.js +43 -0
- package/src/main/client/ClientDatabaseRepository.d.ts +27 -0
- package/src/main/client/ClientDatabaseRepository.js +85 -0
- package/src/main/client/ClientInfo.d.ts +8 -0
- package/src/main/client/ClientInfo.js +21 -0
- package/src/main/client/ClientService.d.ts +40 -0
- package/src/main/client/ClientService.js +103 -0
- package/src/main/client/index.d.ts +4 -0
- package/src/main/client/index.js +39 -0
- package/src/main/connection/ConnectionService.d.ts +11 -0
- package/src/main/connection/ConnectionService.js +45 -0
- package/src/main/connection/index.d.ts +1 -0
- package/src/main/connection/index.js +36 -0
- package/src/main/conversation/AbortReason.d.ts +2 -0
- package/src/main/conversation/AbortReason.js +21 -0
- package/src/main/conversation/AssetService/AssetService.d.ts +62 -0
- package/src/main/conversation/AssetService/AssetService.js +88 -0
- package/src/main/conversation/AssetService/index.d.ts +1 -0
- package/src/main/conversation/AssetService/index.js +36 -0
- package/src/main/conversation/AssetTransferState.d.ts +4 -0
- package/src/main/conversation/AssetTransferState.js +27 -0
- package/src/main/conversation/ClientActionType.d.ts +1 -0
- package/src/main/conversation/ClientActionType.js +24 -0
- package/src/main/conversation/ConversationMapper/ConversationMapper.d.ts +6 -0
- package/src/main/conversation/ConversationMapper/ConversationMapper.js +57 -0
- package/src/main/conversation/ConversationMapper/index.d.ts +1 -0
- package/src/main/conversation/ConversationMapper/index.js +36 -0
- package/src/main/conversation/ConversationService/ConversationService.d.ts +149 -0
- package/src/main/conversation/ConversationService/ConversationService.js +584 -0
- package/src/main/conversation/ConversationService/ConversationService.types.d.ts +110 -0
- package/src/main/conversation/ConversationService/ConversationService.types.js +28 -0
- package/src/main/conversation/ConversationService/index.d.ts +2 -0
- package/src/main/conversation/ConversationService/index.js +37 -0
- package/src/main/conversation/ConversationService/messageGenerator.d.ts +9 -0
- package/src/main/conversation/ConversationService/messageGenerator.js +313 -0
- package/src/main/conversation/GenericMessageType.d.ts +25 -0
- package/src/main/conversation/GenericMessageType.js +49 -0
- package/src/main/conversation/MessageTimer/MessageTimer.d.ts +10 -0
- package/src/main/conversation/MessageTimer/MessageTimer.js +54 -0
- package/src/main/conversation/MessageTimer/index.d.ts +1 -0
- package/src/main/conversation/MessageTimer/index.js +36 -0
- package/src/main/conversation/ReactionType.d.ts +4 -0
- package/src/main/conversation/ReactionType.js +27 -0
- package/src/main/conversation/content/AssetContent.d.ts +42 -0
- package/src/main/conversation/content/AssetContent.js +21 -0
- package/src/main/conversation/content/ButtonActionConfirmationContent.d.ts +2 -0
- package/src/main/conversation/content/ButtonActionConfirmationContent.js +21 -0
- package/src/main/conversation/content/ButtonActionContent.d.ts +2 -0
- package/src/main/conversation/content/ButtonActionContent.js +21 -0
- package/src/main/conversation/content/CallingContent.d.ts +1 -0
- package/src/main/conversation/content/CallingContent.js +21 -0
- package/src/main/conversation/content/ClearedContent.d.ts +2 -0
- package/src/main/conversation/content/ClearedContent.js +21 -0
- package/src/main/conversation/content/ClientActionContent.d.ts +2 -0
- package/src/main/conversation/content/ClientActionContent.js +21 -0
- package/src/main/conversation/content/ClientAddContent.d.ts +4 -0
- package/src/main/conversation/content/ClientAddContent.js +21 -0
- package/src/main/conversation/content/ClientRemoveContent.d.ts +6 -0
- package/src/main/conversation/content/ClientRemoveContent.js +21 -0
- package/src/main/conversation/content/CompositeContent.d.ts +2 -0
- package/src/main/conversation/content/CompositeContent.js +21 -0
- package/src/main/conversation/content/ConfirmationContent.d.ts +2 -0
- package/src/main/conversation/content/ConfirmationContent.js +21 -0
- package/src/main/conversation/content/ContentType.d.ts +21 -0
- package/src/main/conversation/content/ContentType.js +94 -0
- package/src/main/conversation/content/ConversationContent.d.ts +3 -0
- package/src/main/conversation/content/ConversationContent.js +21 -0
- package/src/main/conversation/content/DeletedContent.d.ts +2 -0
- package/src/main/conversation/content/DeletedContent.js +21 -0
- package/src/main/conversation/content/EditedTextContent.d.ts +11 -0
- package/src/main/conversation/content/EditedTextContent.js +21 -0
- package/src/main/conversation/content/FileContent.d.ts +13 -0
- package/src/main/conversation/content/FileContent.js +21 -0
- package/src/main/conversation/content/HiddenContent.d.ts +2 -0
- package/src/main/conversation/content/HiddenContent.js +21 -0
- package/src/main/conversation/content/ImageContent.d.ts +7 -0
- package/src/main/conversation/content/ImageContent.js +21 -0
- package/src/main/conversation/content/KnockContent.d.ts +2 -0
- package/src/main/conversation/content/KnockContent.js +21 -0
- package/src/main/conversation/content/LinkPreviewContent.d.ts +10 -0
- package/src/main/conversation/content/LinkPreviewContent.js +21 -0
- package/src/main/conversation/content/LocationContent.d.ts +9 -0
- package/src/main/conversation/content/LocationContent.js +21 -0
- package/src/main/conversation/content/MentionContent.d.ts +2 -0
- package/src/main/conversation/content/MentionContent.js +21 -0
- package/src/main/conversation/content/QuoteContent.d.ts +7 -0
- package/src/main/conversation/content/QuoteContent.js +21 -0
- package/src/main/conversation/content/ReactionContent.d.ts +7 -0
- package/src/main/conversation/content/ReactionContent.js +21 -0
- package/src/main/conversation/content/TextContent.d.ts +9 -0
- package/src/main/conversation/content/TextContent.js +21 -0
- package/src/main/conversation/content/TweetContent.d.ts +2 -0
- package/src/main/conversation/content/TweetContent.js +21 -0
- package/src/main/conversation/content/index.d.ts +28 -0
- package/src/main/conversation/content/index.js +76 -0
- package/src/main/conversation/index.d.ts +9 -0
- package/src/main/conversation/index.js +44 -0
- package/src/main/conversation/message/CompositeContentBuilder.d.ts +14 -0
- package/src/main/conversation/message/CompositeContentBuilder.js +54 -0
- package/src/main/conversation/message/Message.d.ts +4 -0
- package/src/main/conversation/message/Message.js +21 -0
- package/src/main/conversation/message/MessageBuilder.d.ts +96 -0
- package/src/main/conversation/message/MessageBuilder.js +125 -0
- package/src/main/conversation/message/MessageService.d.ts +67 -0
- package/src/main/conversation/message/MessageService.js +293 -0
- package/src/main/conversation/message/MessageToProtoMapper.d.ts +7 -0
- package/src/main/conversation/message/MessageToProtoMapper.js +99 -0
- package/src/main/conversation/message/OtrMessage.d.ts +80 -0
- package/src/main/conversation/message/OtrMessage.js +21 -0
- package/src/main/conversation/message/PayloadBundle.d.ts +76 -0
- package/src/main/conversation/message/PayloadBundle.js +81 -0
- package/src/main/conversation/message/TeamMessage.d.ts +31 -0
- package/src/main/conversation/message/TeamMessage.js +21 -0
- package/src/main/conversation/message/TextContentBuilder.d.ts +13 -0
- package/src/main/conversation/message/TextContentBuilder.js +75 -0
- package/src/main/conversation/message/UserClientsUtil.d.ts +22 -0
- package/src/main/conversation/message/UserClientsUtil.js +38 -0
- package/src/main/conversation/message/UserMessage.d.ts +43 -0
- package/src/main/conversation/message/UserMessage.js +21 -0
- package/src/main/conversation/message/messageSender.d.ts +4 -0
- package/src/main/conversation/message/messageSender.js +36 -0
- package/src/main/cryptography/AssetCryptography/EncryptedAsset.d.ts +11 -0
- package/src/main/cryptography/AssetCryptography/EncryptedAsset.js +21 -0
- package/src/main/cryptography/AssetCryptography/crypto.browser.d.ts +2 -0
- package/src/main/cryptography/AssetCryptography/crypto.browser.js +46 -0
- package/src/main/cryptography/AssetCryptography/crypto.node.d.ts +2 -0
- package/src/main/cryptography/AssetCryptography/crypto.node.js +72 -0
- package/src/main/cryptography/AssetCryptography/index.d.ts +8 -0
- package/src/main/cryptography/AssetCryptography/index.js +53 -0
- package/src/main/cryptography/AssetCryptography/interfaces.d.ts +9 -0
- package/src/main/cryptography/AssetCryptography/interfaces.js +21 -0
- package/src/main/cryptography/CryptographyDatabaseRepository.d.ts +16 -0
- package/src/main/cryptography/CryptographyDatabaseRepository.js +44 -0
- package/src/main/cryptography/CryptographyService.d.ts +52 -0
- package/src/main/cryptography/CryptographyService.js +205 -0
- package/src/main/cryptography/GenericMessageMapper.d.ts +6 -0
- package/src/main/cryptography/GenericMessageMapper.js +160 -0
- package/src/main/cryptography/MessageHashService.d.ts +16 -0
- package/src/main/cryptography/MessageHashService.js +118 -0
- package/src/main/cryptography/SessionPayloadBundle.d.ts +4 -0
- package/src/main/cryptography/SessionPayloadBundle.js +21 -0
- package/src/main/cryptography/index.d.ts +4 -0
- package/src/main/cryptography/index.js +39 -0
- package/src/main/giphy/GiphyService.d.ts +9 -0
- package/src/main/giphy/GiphyService.js +37 -0
- package/src/main/giphy/index.d.ts +1 -0
- package/src/main/giphy/index.js +36 -0
- package/src/main/index.d.ts +17 -0
- package/src/main/index.js +59 -0
- package/src/main/linkPreview/LinkPreviewService.d.ts +7 -0
- package/src/main/linkPreview/LinkPreviewService.js +52 -0
- package/src/main/linkPreview/index.d.ts +1 -0
- package/src/main/linkPreview/index.js +36 -0
- package/src/main/mls/MLSService/MLSService.d.ts +39 -0
- package/src/main/mls/MLSService/MLSService.js +181 -0
- package/src/main/mls/index.d.ts +1 -0
- package/src/main/mls/index.js +36 -0
- package/src/main/mls/keyMaterialUpdatesStore/index.d.ts +1 -0
- package/src/main/mls/keyMaterialUpdatesStore/index.js +36 -0
- package/src/main/mls/keyMaterialUpdatesStore/keyMaterialUpdatesStore.d.ts +9 -0
- package/src/main/mls/keyMaterialUpdatesStore/keyMaterialUpdatesStore.js +51 -0
- package/src/main/mls/keyPackagesStatusStore/keyPackagesStatusStore.d.ts +7 -0
- package/src/main/mls/keyPackagesStatusStore/keyPackagesStatusStore.js +42 -0
- package/src/main/mls/types.d.ts +33 -0
- package/src/main/mls/types.js +21 -0
- package/src/main/notification/NotificationBackendRepository.d.ts +11 -0
- package/src/main/notification/NotificationBackendRepository.js +34 -0
- package/src/main/notification/NotificationDatabaseRepository.d.ts +42 -0
- package/src/main/notification/NotificationDatabaseRepository.js +97 -0
- package/src/main/notification/NotificationService.d.ts +129 -0
- package/src/main/notification/NotificationService.js +501 -0
- package/src/main/notification/index.d.ts +1 -0
- package/src/main/notification/index.js +36 -0
- package/src/main/notification/types.d.ts +16 -0
- package/src/main/notification/types.js +21 -0
- package/src/main/self/SelfService.d.ts +13 -0
- package/src/main/self/SelfService.js +55 -0
- package/src/main/self/index.d.ts +1 -0
- package/src/main/self/index.js +36 -0
- package/src/main/team/TeamService.d.ts +15 -0
- package/src/main/team/TeamService.js +55 -0
- package/src/main/team/index.d.ts +1 -0
- package/src/main/team/index.js +36 -0
- package/src/main/test/CryptographyHelper.d.ts +4 -0
- package/src/main/test/CryptographyHelper.js +69 -0
- package/src/main/test/PayloadHelper.d.ts +3 -0
- package/src/main/test/PayloadHelper.js +66 -0
- package/src/main/user/UserMapper.d.ts +5 -0
- package/src/main/user/UserMapper.js +88 -0
- package/src/main/user/UserService.d.ts +25 -0
- package/src/main/user/UserService.js +81 -0
- package/src/main/user/index.d.ts +1 -0
- package/src/main/user/index.js +36 -0
- package/src/main/util/LowPrecisionTaskScheduler/LowPrecisionTaskScheduler.d.ts +21 -0
- package/src/main/util/LowPrecisionTaskScheduler/LowPrecisionTaskScheduler.js +62 -0
- package/src/main/util/TaskScheduler/TaskScheduler.d.ts +10 -0
- package/src/main/util/TaskScheduler/TaskScheduler.js +70 -0
- package/src/main/util/TypePredicateUtil.d.ts +7 -0
- package/src/main/util/TypePredicateUtil.js +55 -0
- package/src/main/util/encryptedStore.d.ts +45 -0
- package/src/main/util/encryptedStore.js +116 -0
- package/src/main/util/fullyQualifiedClientIdUtils.d.ts +13 -0
- package/src/main/util/fullyQualifiedClientIdUtils.js +42 -0
- package/src/main/util/index.d.ts +1 -0
- package/src/main/util/index.js +36 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
interface IntervalTask {
|
|
2
|
+
key: string;
|
|
3
|
+
firingDate: number;
|
|
4
|
+
task: () => Promise<any>;
|
|
5
|
+
}
|
|
6
|
+
interface ScheduleLowPrecisionTaskParams extends IntervalTask {
|
|
7
|
+
intervalDelay: number;
|
|
8
|
+
}
|
|
9
|
+
interface CancelLowPrecisionTaskParams {
|
|
10
|
+
key: string;
|
|
11
|
+
intervalDelay: number;
|
|
12
|
+
}
|
|
13
|
+
interface CancelLowPrecisionTaskParams {
|
|
14
|
+
key: string;
|
|
15
|
+
intervalDelay: number;
|
|
16
|
+
}
|
|
17
|
+
export declare const LowPrecisionTaskScheduler: {
|
|
18
|
+
addTask: ({ key, firingDate, task, intervalDelay }: ScheduleLowPrecisionTaskParams) => void;
|
|
19
|
+
cancelTask: ({ intervalDelay, key }: CancelLowPrecisionTaskParams) => void;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
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.LowPrecisionTaskScheduler = void 0;
|
|
22
|
+
const intervals = {};
|
|
23
|
+
const addTask = ({ key, firingDate, task, intervalDelay }) => {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
const existingIntervalId = (_a = intervals[intervalDelay]) === null || _a === void 0 ? void 0 : _a.timeoutId;
|
|
26
|
+
if (existingIntervalId) {
|
|
27
|
+
clearInterval(existingIntervalId);
|
|
28
|
+
}
|
|
29
|
+
const tasks = ((_b = intervals[intervalDelay]) === null || _b === void 0 ? void 0 : _b.tasks) || [];
|
|
30
|
+
tasks.push({ key, firingDate, task });
|
|
31
|
+
const timeoutId = setInterval(async () => {
|
|
32
|
+
var _a;
|
|
33
|
+
const nowTime = new Date().getTime();
|
|
34
|
+
const tasks = (_a = intervals[intervalDelay]) === null || _a === void 0 ? void 0 : _a.tasks;
|
|
35
|
+
if ((tasks === null || tasks === void 0 ? void 0 : tasks.length) !== 0) {
|
|
36
|
+
const tasksToExecute = await tasks.reduce(async (accPromise, { firingDate, task }) => {
|
|
37
|
+
const acc = await accPromise;
|
|
38
|
+
if (nowTime >= firingDate) {
|
|
39
|
+
const taskPromise = task();
|
|
40
|
+
acc.push(taskPromise);
|
|
41
|
+
cancelTask({ intervalDelay, key });
|
|
42
|
+
}
|
|
43
|
+
return acc;
|
|
44
|
+
}, Promise.resolve([]));
|
|
45
|
+
await Promise.all(tasksToExecute);
|
|
46
|
+
}
|
|
47
|
+
}, intervalDelay);
|
|
48
|
+
intervals[intervalDelay] = { timeoutId, tasks };
|
|
49
|
+
};
|
|
50
|
+
const cancelTask = ({ intervalDelay, key }) => {
|
|
51
|
+
if (intervals[intervalDelay]) {
|
|
52
|
+
const tasks = intervals[intervalDelay].tasks || [];
|
|
53
|
+
const newTasks = tasks.filter(task => task.key !== key);
|
|
54
|
+
intervals[intervalDelay].tasks = newTasks;
|
|
55
|
+
if (newTasks.length === 0) {
|
|
56
|
+
clearInterval(intervals[intervalDelay].timeoutId);
|
|
57
|
+
delete intervals[intervalDelay];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
exports.LowPrecisionTaskScheduler = { addTask, cancelTask };
|
|
62
|
+
//# sourceMappingURL=LowPrecisionTaskScheduler.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare type ScheduleTaskParams = {
|
|
2
|
+
task: () => Promise<void>;
|
|
3
|
+
firingDate: number;
|
|
4
|
+
key: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const TaskScheduler: {
|
|
7
|
+
addTask: ({ task, firingDate, key }: ScheduleTaskParams) => void;
|
|
8
|
+
cancelTask: (key: string) => void;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
21
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.TaskScheduler = void 0;
|
|
25
|
+
const logdown_1 = __importDefault(require("logdown"));
|
|
26
|
+
const logger = (0, logdown_1.default)('@wireapp/core/util/TaskScheduler/TaskScheduler', {
|
|
27
|
+
logger: console,
|
|
28
|
+
markdown: false,
|
|
29
|
+
});
|
|
30
|
+
const activeTimeouts = {};
|
|
31
|
+
/**
|
|
32
|
+
* Execute a task at a given time.
|
|
33
|
+
*
|
|
34
|
+
* @param task function to be executed
|
|
35
|
+
* @param firingDate execution date
|
|
36
|
+
* @param key unique key for the task
|
|
37
|
+
*/
|
|
38
|
+
const addTask = ({ task, firingDate, key }) => {
|
|
39
|
+
const now = new Date();
|
|
40
|
+
const execute = new Date(firingDate);
|
|
41
|
+
const delay = execute.getTime() - now.getTime();
|
|
42
|
+
if (activeTimeouts[key]) {
|
|
43
|
+
cancelTask(key);
|
|
44
|
+
}
|
|
45
|
+
const timeout = setTimeout(async () => {
|
|
46
|
+
await task();
|
|
47
|
+
delete activeTimeouts[key];
|
|
48
|
+
}, delay > 0 ? delay : 0);
|
|
49
|
+
// add the task to the list of active tasks
|
|
50
|
+
activeTimeouts[key] = timeout;
|
|
51
|
+
logger.info(`New scheduled task to be executed at "${execute}" with key "${key}"`);
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Cancel a scheduled task early
|
|
55
|
+
*
|
|
56
|
+
* @param key unique key for the task
|
|
57
|
+
*/
|
|
58
|
+
const cancelTask = (key) => {
|
|
59
|
+
const timeout = activeTimeouts[key];
|
|
60
|
+
if (timeout) {
|
|
61
|
+
clearTimeout(timeout);
|
|
62
|
+
delete activeTimeouts[key];
|
|
63
|
+
logger.info(`Scheduled task with key "${key}" prematurely cleared`);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
exports.TaskScheduler = {
|
|
67
|
+
addTask,
|
|
68
|
+
cancelTask,
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=TaskScheduler.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { QualifiedUserClients, UserClients } from '@wireapp/api-client/src/conversation/';
|
|
2
|
+
import { QualifiedId } from '@wireapp/api-client/src/user/';
|
|
3
|
+
export declare function isStringArray(obj: any): obj is string[];
|
|
4
|
+
export declare function isQualifiedId(obj: any): obj is QualifiedId;
|
|
5
|
+
export declare function isQualifiedIdArray(obj: any): obj is QualifiedId[];
|
|
6
|
+
export declare function isQualifiedUserClients(obj: any): obj is QualifiedUserClients;
|
|
7
|
+
export declare function isUserClients(obj: any): obj is UserClients;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Wire
|
|
4
|
+
* Copyright (C) 2021 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.isUserClients = exports.isQualifiedUserClients = exports.isQualifiedIdArray = exports.isQualifiedId = exports.isStringArray = void 0;
|
|
22
|
+
function isStringArray(obj) {
|
|
23
|
+
return Array.isArray(obj) && (obj.length === 0 || typeof obj[0] === 'string');
|
|
24
|
+
}
|
|
25
|
+
exports.isStringArray = isStringArray;
|
|
26
|
+
function isQualifiedId(obj) {
|
|
27
|
+
return typeof obj === 'object' && typeof obj['domain'] === 'string';
|
|
28
|
+
}
|
|
29
|
+
exports.isQualifiedId = isQualifiedId;
|
|
30
|
+
function isQualifiedIdArray(obj) {
|
|
31
|
+
return Array.isArray(obj) && isQualifiedId(obj[0]);
|
|
32
|
+
}
|
|
33
|
+
exports.isQualifiedIdArray = isQualifiedIdArray;
|
|
34
|
+
function isQualifiedUserClients(obj) {
|
|
35
|
+
var _a;
|
|
36
|
+
if (typeof obj === 'object') {
|
|
37
|
+
const firstUserClientObject = (_a = Object.values(obj)) === null || _a === void 0 ? void 0 : _a[0];
|
|
38
|
+
if (typeof firstUserClientObject === 'object') {
|
|
39
|
+
const firstClientIdArray = Object.values(firstUserClientObject)[0];
|
|
40
|
+
return isStringArray(firstClientIdArray);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
exports.isQualifiedUserClients = isQualifiedUserClients;
|
|
46
|
+
function isUserClients(obj) {
|
|
47
|
+
var _a;
|
|
48
|
+
if (typeof obj === 'object') {
|
|
49
|
+
const firstUserClientArray = (_a = Object.values(obj)) === null || _a === void 0 ? void 0 : _a[0];
|
|
50
|
+
return isStringArray(firstUserClientArray);
|
|
51
|
+
}
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
exports.isUserClients = isUserClients;
|
|
55
|
+
//# sourceMappingURL=TypePredicateUtil.js.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { DBSchema, IDBPDatabase } from 'idb';
|
|
2
|
+
interface DefaultEncryptedPayload {
|
|
3
|
+
iv: Uint8Array | ArrayBuffer;
|
|
4
|
+
value: Uint8Array | ArrayBuffer;
|
|
5
|
+
}
|
|
6
|
+
interface EncryptedDB<EncryptedPayload> extends DBSchema {
|
|
7
|
+
key: {
|
|
8
|
+
key: string;
|
|
9
|
+
value: CryptoKey;
|
|
10
|
+
};
|
|
11
|
+
secrets: {
|
|
12
|
+
key: string;
|
|
13
|
+
value: EncryptedPayload;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
declare type DecryptFn<EncryptedPayload> = (payload: EncryptedPayload) => Promise<Uint8Array>;
|
|
17
|
+
declare type EncryptFn<EncryptedPayload> = (value: Uint8Array) => Promise<EncryptedPayload>;
|
|
18
|
+
declare type EncryptedStoreConfig<EncryptedPayload> = {
|
|
19
|
+
encrypt: EncryptFn<EncryptedPayload>;
|
|
20
|
+
decrypt: DecryptFn<EncryptedPayload>;
|
|
21
|
+
};
|
|
22
|
+
declare class EncryptedStore<EncryptedPayload> {
|
|
23
|
+
#private;
|
|
24
|
+
private readonly db;
|
|
25
|
+
constructor(db: IDBPDatabase<EncryptedDB<EncryptedPayload>>, { encrypt, decrypt }: EncryptedStoreConfig<EncryptedPayload>);
|
|
26
|
+
saveSecretValue(primaryKey: string, value: Uint8Array): Promise<void>;
|
|
27
|
+
getsecretValue(primaryKey: string): Promise<Uint8Array | undefined>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Will create a database that uses the built in encryption/decryption functions.
|
|
31
|
+
* The master key will be created and stored inside the database
|
|
32
|
+
*
|
|
33
|
+
* @param dbName the name of the database to create
|
|
34
|
+
*/
|
|
35
|
+
export declare function createEncryptedStore(dbName: string): Promise<EncryptedStore<DefaultEncryptedPayload>>;
|
|
36
|
+
/**
|
|
37
|
+
* Will create a database that uses a custom encryption method. It needs the encrypt and decrypt function to be able to process the values stored.
|
|
38
|
+
* It's the responsability of the consumer to store the encryption key
|
|
39
|
+
*
|
|
40
|
+
* @param dbName the name of the database to create
|
|
41
|
+
* @param config contains the encrypt and decrypt methods
|
|
42
|
+
*/
|
|
43
|
+
export declare function createCustomEncryptedStore<EncryptedPayload>(dbName: string, config: EncryptedStoreConfig<EncryptedPayload>): Promise<EncryptedStore<EncryptedPayload>>;
|
|
44
|
+
export declare function deleteEncryptedStore(dbName: string): Promise<void>;
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,116 @@
|
|
|
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 __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
21
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
22
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
23
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
24
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
25
|
+
};
|
|
26
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
27
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
28
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
29
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
30
|
+
};
|
|
31
|
+
var _EncryptedStore_decrypt, _EncryptedStore_encrypt;
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.deleteEncryptedStore = exports.createCustomEncryptedStore = exports.createEncryptedStore = void 0;
|
|
34
|
+
const idb_1 = require("idb");
|
|
35
|
+
class EncryptedStore {
|
|
36
|
+
constructor(db, { encrypt, decrypt }) {
|
|
37
|
+
this.db = db;
|
|
38
|
+
_EncryptedStore_decrypt.set(this, void 0);
|
|
39
|
+
_EncryptedStore_encrypt.set(this, void 0);
|
|
40
|
+
__classPrivateFieldSet(this, _EncryptedStore_encrypt, encrypt, "f");
|
|
41
|
+
__classPrivateFieldSet(this, _EncryptedStore_decrypt, decrypt, "f");
|
|
42
|
+
}
|
|
43
|
+
async saveSecretValue(primaryKey, value) {
|
|
44
|
+
const encrypted = await __classPrivateFieldGet(this, _EncryptedStore_encrypt, "f").call(this, value);
|
|
45
|
+
await this.db.put('secrets', encrypted, primaryKey);
|
|
46
|
+
}
|
|
47
|
+
async getsecretValue(primaryKey) {
|
|
48
|
+
const result = await this.db.get('secrets', primaryKey);
|
|
49
|
+
if (!result) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
return __classPrivateFieldGet(this, _EncryptedStore_decrypt, "f").call(this, result);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
_EncryptedStore_decrypt = new WeakMap(), _EncryptedStore_encrypt = new WeakMap();
|
|
56
|
+
async function generateKey() {
|
|
57
|
+
return crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, //whether the key is extractable (i.e. can be used in exportKey)
|
|
58
|
+
['encrypt', 'decrypt']);
|
|
59
|
+
}
|
|
60
|
+
async function defaultDecrypt({ value, iv }, key) {
|
|
61
|
+
const decrypted = await crypto.subtle.decrypt({ name: 'AES-GCM', iv }, key, value);
|
|
62
|
+
return new Uint8Array(decrypted);
|
|
63
|
+
}
|
|
64
|
+
async function defaultEncrypt(data, key) {
|
|
65
|
+
const iv = await crypto.getRandomValues(new Uint8Array(12));
|
|
66
|
+
return {
|
|
67
|
+
iv,
|
|
68
|
+
value: await crypto.subtle.encrypt({ name: 'AES-GCM', iv }, key, data),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Will create a database that uses the built in encryption/decryption functions.
|
|
73
|
+
* The master key will be created and stored inside the database
|
|
74
|
+
*
|
|
75
|
+
* @param dbName the name of the database to create
|
|
76
|
+
*/
|
|
77
|
+
async function createEncryptedStore(dbName) {
|
|
78
|
+
const db = await (0, idb_1.openDB)(dbName, 1, {
|
|
79
|
+
upgrade: async (database) => {
|
|
80
|
+
database.createObjectStore('key');
|
|
81
|
+
database.createObjectStore('secrets');
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
const keyPrimaryKey = 'dbKey';
|
|
85
|
+
let key = await db.get('key', keyPrimaryKey);
|
|
86
|
+
if (!key) {
|
|
87
|
+
key = await generateKey();
|
|
88
|
+
await db.put('key', key, keyPrimaryKey);
|
|
89
|
+
}
|
|
90
|
+
return new EncryptedStore(db, {
|
|
91
|
+
encrypt: value => defaultEncrypt(value, key),
|
|
92
|
+
decrypt: payload => defaultDecrypt(payload, key),
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
exports.createEncryptedStore = createEncryptedStore;
|
|
96
|
+
/**
|
|
97
|
+
* Will create a database that uses a custom encryption method. It needs the encrypt and decrypt function to be able to process the values stored.
|
|
98
|
+
* It's the responsability of the consumer to store the encryption key
|
|
99
|
+
*
|
|
100
|
+
* @param dbName the name of the database to create
|
|
101
|
+
* @param config contains the encrypt and decrypt methods
|
|
102
|
+
*/
|
|
103
|
+
async function createCustomEncryptedStore(dbName, config) {
|
|
104
|
+
const db = await (0, idb_1.openDB)(dbName, 1, {
|
|
105
|
+
upgrade: async (database) => {
|
|
106
|
+
database.createObjectStore('secrets');
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
return new EncryptedStore(db, config);
|
|
110
|
+
}
|
|
111
|
+
exports.createCustomEncryptedStore = createCustomEncryptedStore;
|
|
112
|
+
async function deleteEncryptedStore(dbName) {
|
|
113
|
+
return (0, idb_1.deleteDB)(dbName);
|
|
114
|
+
}
|
|
115
|
+
exports.deleteEncryptedStore = deleteEncryptedStore;
|
|
116
|
+
//# sourceMappingURL=encryptedStore.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { QualifiedUserClientMap } from '@wireapp/api-client/src/client';
|
|
2
|
+
declare type UserId = string;
|
|
3
|
+
declare type ClientId = string;
|
|
4
|
+
declare type Domain = string;
|
|
5
|
+
export declare type ClientIdStringType = `${UserId}:${ClientId}@${Domain}`;
|
|
6
|
+
export declare const constructFullyQualifiedClientId: (userId: UserId, clientId: ClientId, domain: Domain) => ClientIdStringType;
|
|
7
|
+
export declare const parseFullQualifiedClientId: (qualifiedId: string) => {
|
|
8
|
+
user: UserId;
|
|
9
|
+
client: ClientId;
|
|
10
|
+
domain: Domain;
|
|
11
|
+
};
|
|
12
|
+
export declare const mapQualifiedUserClientIdsToFullyQualifiedClientIds: (qualifiedUserMap: QualifiedUserClientMap) => Uint8Array[];
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
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.mapQualifiedUserClientIdsToFullyQualifiedClientIds = exports.parseFullQualifiedClientId = exports.constructFullyQualifiedClientId = void 0;
|
|
22
|
+
const constructFullyQualifiedClientId = (userId, clientId, domain) => `${userId}:${clientId}@${domain}`;
|
|
23
|
+
exports.constructFullyQualifiedClientId = constructFullyQualifiedClientId;
|
|
24
|
+
const parseFullQualifiedClientId = (qualifiedId) => {
|
|
25
|
+
var _a;
|
|
26
|
+
const regexp = /([a-zA-Z0-9\-]+):([a-zA-Z0-9\-]+)@([a-zA-Z0-9\-.]+)/;
|
|
27
|
+
const [, user, client, domain] = (_a = qualifiedId.match(regexp)) !== null && _a !== void 0 ? _a : [];
|
|
28
|
+
if (!user || !client || !domain) {
|
|
29
|
+
throw new Error(`given client fully qualified ID is corrupted (${qualifiedId})`);
|
|
30
|
+
}
|
|
31
|
+
return { user, client, domain };
|
|
32
|
+
};
|
|
33
|
+
exports.parseFullQualifiedClientId = parseFullQualifiedClientId;
|
|
34
|
+
const mapQualifiedUserClientIdsToFullyQualifiedClientIds = (qualifiedUserMap) => {
|
|
35
|
+
const encoder = new TextEncoder();
|
|
36
|
+
return Object.entries(qualifiedUserMap).flatMap(([domain, users]) => {
|
|
37
|
+
const clients = Object.entries(users);
|
|
38
|
+
return clients.flatMap(([userId, clients]) => clients.map(client => encoder.encode((0, exports.constructFullyQualifiedClientId)(userId, client.id, domain))));
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
exports.mapQualifiedUserClientIdsToFullyQualifiedClientIds = mapQualifiedUserClientIdsToFullyQualifiedClientIds;
|
|
42
|
+
//# sourceMappingURL=fullyQualifiedClientIdUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './TypePredicateUtil';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Wire
|
|
4
|
+
* Copyright (C) 2021 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
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
23
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
24
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
25
|
+
}
|
|
26
|
+
Object.defineProperty(o, k2, desc);
|
|
27
|
+
}) : (function(o, m, k, k2) {
|
|
28
|
+
if (k2 === undefined) k2 = k;
|
|
29
|
+
o[k2] = m[k];
|
|
30
|
+
}));
|
|
31
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
32
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
__exportStar(require("./TypePredicateUtil"), exports);
|
|
36
|
+
//# sourceMappingURL=index.js.map
|