@wireapp/core 30.5.1 → 30.5.2
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 +8 -0
- package/package.json +3 -3
- package/src/main/Account.d.ts +0 -204
- package/src/main/Account.js +0 -439
- package/src/main/CoreError.d.ts +0 -9
- package/src/main/CoreError.js +0 -26
- package/src/main/account/AccountService.d.ts +0 -7
- package/src/main/account/AccountService.js +0 -33
- package/src/main/account/AccountService.js.map +0 -1
- package/src/main/account/index.d.ts +0 -1
- package/src/main/account/index.js +0 -32
- package/src/main/account/index.js.map +0 -1
- package/src/main/auth/LoginSanitizer.d.ts +0 -5
- package/src/main/auth/LoginSanitizer.js +0 -41
- package/src/main/auth/index.d.ts +0 -1
- package/src/main/auth/index.js +0 -32
- package/src/main/broadcast/AvailabilityType.d.ts +0 -2
- package/src/main/broadcast/AvailabilityType.js +0 -21
- package/src/main/broadcast/BroadcastService.d.ts +0 -24
- package/src/main/broadcast/BroadcastService.js +0 -74
- package/src/main/broadcast/index.d.ts +0 -2
- package/src/main/broadcast/index.js +0 -33
- package/src/main/client/ClientBackendRepository.d.ts +0 -11
- package/src/main/client/ClientBackendRepository.js +0 -43
- package/src/main/client/ClientDatabaseRepository.d.ts +0 -27
- package/src/main/client/ClientDatabaseRepository.js +0 -85
- package/src/main/client/ClientInfo.d.ts +0 -8
- package/src/main/client/ClientInfo.js +0 -21
- package/src/main/client/ClientService.d.ts +0 -48
- package/src/main/client/ClientService.js +0 -118
- package/src/main/client/index.d.ts +0 -4
- package/src/main/client/index.js +0 -35
- package/src/main/connection/ConnectionService.d.ts +0 -11
- package/src/main/connection/ConnectionService.js +0 -45
- package/src/main/connection/index.d.ts +0 -1
- package/src/main/connection/index.js +0 -32
- package/src/main/conversation/AbortReason.d.ts +0 -2
- package/src/main/conversation/AbortReason.js +0 -21
- package/src/main/conversation/AssetService/AssetService.d.ts +0 -62
- package/src/main/conversation/AssetService/AssetService.js +0 -88
- package/src/main/conversation/AssetService/index.d.ts +0 -1
- package/src/main/conversation/AssetService/index.js +0 -32
- package/src/main/conversation/AssetTransferState.d.ts +0 -4
- package/src/main/conversation/AssetTransferState.js +0 -27
- package/src/main/conversation/ClientActionType.d.ts +0 -1
- package/src/main/conversation/ClientActionType.js +0 -24
- package/src/main/conversation/ConversationMapper/ConversationMapper.d.ts +0 -6
- package/src/main/conversation/ConversationMapper/ConversationMapper.js +0 -57
- package/src/main/conversation/ConversationMapper/index.d.ts +0 -1
- package/src/main/conversation/ConversationMapper/index.js +0 -32
- package/src/main/conversation/ConversationService/ConversationService.d.ts +0 -162
- package/src/main/conversation/ConversationService/ConversationService.js +0 -900
- package/src/main/conversation/ConversationService/ConversationService.types.d.ts +0 -108
- package/src/main/conversation/ConversationService/ConversationService.types.js +0 -28
- package/src/main/conversation/ConversationService/index.d.ts +0 -2
- package/src/main/conversation/ConversationService/index.js +0 -33
- package/src/main/conversation/GenericMessageType.d.ts +0 -25
- package/src/main/conversation/GenericMessageType.js +0 -49
- package/src/main/conversation/MessageTimer/MessageTimer.d.ts +0 -10
- package/src/main/conversation/MessageTimer/MessageTimer.js +0 -54
- package/src/main/conversation/MessageTimer/index.d.ts +0 -1
- package/src/main/conversation/MessageTimer/index.js +0 -32
- package/src/main/conversation/ReactionType.d.ts +0 -4
- package/src/main/conversation/ReactionType.js +0 -27
- package/src/main/conversation/content/AssetContent.d.ts +0 -42
- package/src/main/conversation/content/AssetContent.js +0 -21
- package/src/main/conversation/content/ButtonActionConfirmationContent.d.ts +0 -2
- package/src/main/conversation/content/ButtonActionConfirmationContent.js +0 -21
- package/src/main/conversation/content/ButtonActionContent.d.ts +0 -2
- package/src/main/conversation/content/ButtonActionContent.js +0 -21
- package/src/main/conversation/content/CallingContent.d.ts +0 -1
- package/src/main/conversation/content/CallingContent.js +0 -21
- package/src/main/conversation/content/ClearedContent.d.ts +0 -2
- package/src/main/conversation/content/ClearedContent.js +0 -21
- package/src/main/conversation/content/ClientActionContent.d.ts +0 -2
- package/src/main/conversation/content/ClientActionContent.js +0 -21
- package/src/main/conversation/content/ClientAddContent.d.ts +0 -4
- package/src/main/conversation/content/ClientAddContent.js +0 -21
- package/src/main/conversation/content/ClientRemoveContent.d.ts +0 -6
- package/src/main/conversation/content/ClientRemoveContent.js +0 -21
- package/src/main/conversation/content/CompositeContent.d.ts +0 -2
- package/src/main/conversation/content/CompositeContent.js +0 -21
- package/src/main/conversation/content/ConfirmationContent.d.ts +0 -2
- package/src/main/conversation/content/ConfirmationContent.js +0 -21
- package/src/main/conversation/content/ContentType.d.ts +0 -21
- package/src/main/conversation/content/ContentType.js +0 -94
- package/src/main/conversation/content/ConversationContent.d.ts +0 -3
- package/src/main/conversation/content/ConversationContent.js +0 -21
- package/src/main/conversation/content/DeletedContent.d.ts +0 -2
- package/src/main/conversation/content/DeletedContent.js +0 -21
- package/src/main/conversation/content/EditedTextContent.d.ts +0 -11
- package/src/main/conversation/content/EditedTextContent.js +0 -21
- package/src/main/conversation/content/FileContent.d.ts +0 -13
- package/src/main/conversation/content/FileContent.js +0 -21
- package/src/main/conversation/content/HiddenContent.d.ts +0 -2
- package/src/main/conversation/content/HiddenContent.js +0 -21
- package/src/main/conversation/content/ImageContent.d.ts +0 -7
- package/src/main/conversation/content/ImageContent.js +0 -21
- package/src/main/conversation/content/KnockContent.d.ts +0 -2
- package/src/main/conversation/content/KnockContent.js +0 -21
- package/src/main/conversation/content/LinkPreviewContent.d.ts +0 -10
- package/src/main/conversation/content/LinkPreviewContent.js +0 -21
- package/src/main/conversation/content/LocationContent.d.ts +0 -9
- package/src/main/conversation/content/LocationContent.js +0 -21
- package/src/main/conversation/content/MentionContent.d.ts +0 -2
- package/src/main/conversation/content/MentionContent.js +0 -21
- package/src/main/conversation/content/QuoteContent.d.ts +0 -7
- package/src/main/conversation/content/QuoteContent.js +0 -21
- package/src/main/conversation/content/ReactionContent.d.ts +0 -7
- package/src/main/conversation/content/ReactionContent.js +0 -21
- package/src/main/conversation/content/TextContent.d.ts +0 -9
- package/src/main/conversation/content/TextContent.js +0 -21
- package/src/main/conversation/content/TweetContent.d.ts +0 -2
- package/src/main/conversation/content/TweetContent.js +0 -21
- package/src/main/conversation/content/index.d.ts +0 -28
- package/src/main/conversation/content/index.js +0 -72
- package/src/main/conversation/index.d.ts +0 -9
- package/src/main/conversation/index.js +0 -40
- package/src/main/conversation/message/CompositeContentBuilder.d.ts +0 -14
- package/src/main/conversation/message/CompositeContentBuilder.js +0 -54
- package/src/main/conversation/message/Message.d.ts +0 -4
- package/src/main/conversation/message/Message.js +0 -21
- package/src/main/conversation/message/MessageBuilder.d.ts +0 -87
- package/src/main/conversation/message/MessageBuilder.js +0 -119
- package/src/main/conversation/message/MessageService.d.ts +0 -67
- package/src/main/conversation/message/MessageService.js +0 -293
- package/src/main/conversation/message/MessageToProtoMapper.d.ts +0 -7
- package/src/main/conversation/message/MessageToProtoMapper.js +0 -99
- package/src/main/conversation/message/OtrMessage.d.ts +0 -80
- package/src/main/conversation/message/OtrMessage.js +0 -21
- package/src/main/conversation/message/PayloadBundle.d.ts +0 -76
- package/src/main/conversation/message/PayloadBundle.js +0 -81
- package/src/main/conversation/message/TeamMessage.d.ts +0 -31
- package/src/main/conversation/message/TeamMessage.js +0 -21
- package/src/main/conversation/message/TextContentBuilder.d.ts +0 -13
- package/src/main/conversation/message/TextContentBuilder.js +0 -75
- package/src/main/conversation/message/UserClientsUtil.d.ts +0 -22
- package/src/main/conversation/message/UserClientsUtil.js +0 -38
- package/src/main/conversation/message/UserMessage.d.ts +0 -43
- package/src/main/conversation/message/UserMessage.js +0 -21
- package/src/main/cryptography/AssetCryptography/EncryptedAsset.d.ts +0 -11
- package/src/main/cryptography/AssetCryptography/EncryptedAsset.js +0 -21
- package/src/main/cryptography/AssetCryptography/crypto.browser.d.ts +0 -2
- package/src/main/cryptography/AssetCryptography/crypto.browser.js +0 -46
- package/src/main/cryptography/AssetCryptography/crypto.node.d.ts +0 -2
- package/src/main/cryptography/AssetCryptography/crypto.node.js +0 -68
- package/src/main/cryptography/AssetCryptography/index.d.ts +0 -8
- package/src/main/cryptography/AssetCryptography/index.js +0 -53
- package/src/main/cryptography/AssetCryptography/interfaces.d.ts +0 -9
- package/src/main/cryptography/AssetCryptography/interfaces.js +0 -21
- package/src/main/cryptography/CryptographyDatabaseRepository.d.ts +0 -17
- package/src/main/cryptography/CryptographyDatabaseRepository.js +0 -45
- package/src/main/cryptography/CryptographyService.d.ts +0 -52
- package/src/main/cryptography/CryptographyService.js +0 -205
- package/src/main/cryptography/GenericMessageMapper.d.ts +0 -6
- package/src/main/cryptography/GenericMessageMapper.js +0 -160
- package/src/main/cryptography/MessageHashService.d.ts +0 -16
- package/src/main/cryptography/MessageHashService.js +0 -114
- package/src/main/cryptography/SessionPayloadBundle.d.ts +0 -4
- package/src/main/cryptography/SessionPayloadBundle.js +0 -21
- package/src/main/cryptography/index.d.ts +0 -4
- package/src/main/cryptography/index.js +0 -35
- package/src/main/giphy/GiphyService.d.ts +0 -9
- package/src/main/giphy/GiphyService.js +0 -37
- package/src/main/giphy/index.d.ts +0 -1
- package/src/main/giphy/index.js +0 -32
- package/src/main/index.d.ts +0 -17
- package/src/main/index.js +0 -55
- package/src/main/linkPreview/LinkPreviewService.d.ts +0 -7
- package/src/main/linkPreview/LinkPreviewService.js +0 -52
- package/src/main/linkPreview/index.d.ts +0 -1
- package/src/main/linkPreview/index.js +0 -32
- package/src/main/mls/MLSService/MLSService.d.ts +0 -26
- package/src/main/mls/MLSService/MLSService.js +0 -131
- package/src/main/mls/index.d.ts +0 -1
- package/src/main/mls/index.js +0 -32
- package/src/main/mls/types.d.ts +0 -22
- package/src/main/mls/types.js +0 -21
- package/src/main/notification/NotificationBackendRepository.d.ts +0 -11
- package/src/main/notification/NotificationBackendRepository.js +0 -34
- package/src/main/notification/NotificationDatabaseRepository.d.ts +0 -66
- package/src/main/notification/NotificationDatabaseRepository.js +0 -136
- package/src/main/notification/NotificationService.d.ts +0 -131
- package/src/main/notification/NotificationService.js +0 -468
- package/src/main/notification/index.d.ts +0 -1
- package/src/main/notification/index.js +0 -32
- package/src/main/notification/types.d.ts +0 -20
- package/src/main/notification/types.js +0 -21
- package/src/main/self/SelfService.d.ts +0 -13
- package/src/main/self/SelfService.js +0 -55
- package/src/main/self/index.d.ts +0 -1
- package/src/main/self/index.js +0 -32
- package/src/main/team/TeamService.d.ts +0 -15
- package/src/main/team/TeamService.js +0 -55
- package/src/main/team/index.d.ts +0 -1
- package/src/main/team/index.js +0 -32
- package/src/main/test/CryptographyHelper.d.ts +0 -4
- package/src/main/test/CryptographyHelper.js +0 -65
- package/src/main/test/PayloadHelper.d.ts +0 -3
- package/src/main/test/PayloadHelper.js +0 -66
- package/src/main/user/UserMapper.d.ts +0 -5
- package/src/main/user/UserMapper.js +0 -88
- package/src/main/user/UserService.d.ts +0 -25
- package/src/main/user/UserService.js +0 -81
- package/src/main/user/index.d.ts +0 -1
- package/src/main/user/index.js +0 -32
- package/src/main/util/LowPrecisionTaskScheduler/LowPrecisionTaskScheduler.d.ts +0 -21
- package/src/main/util/LowPrecisionTaskScheduler/LowPrecisionTaskScheduler.js +0 -62
- package/src/main/util/TaskScheduler/TaskScheduler.d.ts +0 -10
- package/src/main/util/TaskScheduler/TaskScheduler.js +0 -70
- package/src/main/util/TypePredicateUtil.d.ts +0 -7
- package/src/main/util/TypePredicateUtil.js +0 -55
- package/src/main/util/encryptedStore.d.ts +0 -45
- package/src/main/util/encryptedStore.js +0 -116
- package/src/main/util/index.d.ts +0 -1
- package/src/main/util/index.js +0 -32
- package/src/main/util/mapQualifiedUserClientIdsToFullyQualifiedClientIds.d.ts +0 -8
- package/src/main/util/mapQualifiedUserClientIdsToFullyQualifiedClientIds.js +0 -32
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import type { APIClient } from '@wireapp/api-client';
|
|
3
|
-
import * as Events from '@wireapp/api-client/src/event';
|
|
4
|
-
import type { Notification } from '@wireapp/api-client/src/notification/';
|
|
5
|
-
import { CRUDEngine } from '@wireapp/store-engine';
|
|
6
|
-
import { EventEmitter } from 'events';
|
|
7
|
-
import { PayloadBundle, PayloadBundleSource } from '../conversation';
|
|
8
|
-
import { NotificationError } from '../CoreError';
|
|
9
|
-
import type { CryptographyService } from '../cryptography';
|
|
10
|
-
import { GenericMessage } from '@wireapp/protocol-messaging';
|
|
11
|
-
import { AbortHandler } from '@wireapp/api-client/src/tcp';
|
|
12
|
-
import { QualifiedId } from '@wireapp/api-client/src/user';
|
|
13
|
-
import { Conversation } from '@wireapp/api-client/src/conversation';
|
|
14
|
-
import { CommitPendingProposalsParams, LastKeyMaterialUpdateParams } from './types';
|
|
15
|
-
import type { MLSService } from '../mls';
|
|
16
|
-
export declare type HandledEventPayload = {
|
|
17
|
-
event: Events.BackendEvent;
|
|
18
|
-
mappedEvent?: PayloadBundle;
|
|
19
|
-
decryptedData?: GenericMessage;
|
|
20
|
-
decryptionError?: {
|
|
21
|
-
code: number;
|
|
22
|
-
message: string;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
declare enum TOPIC {
|
|
26
|
-
NOTIFICATION_ERROR = "NotificationService.TOPIC.NOTIFICATION_ERROR"
|
|
27
|
-
}
|
|
28
|
-
export declare type NotificationHandler = (notification: Notification, source: PayloadBundleSource, progress: {
|
|
29
|
-
done: number;
|
|
30
|
-
total: number;
|
|
31
|
-
}) => Promise<void>;
|
|
32
|
-
export interface NotificationService {
|
|
33
|
-
on(event: TOPIC.NOTIFICATION_ERROR, listener: (payload: NotificationError) => void): this;
|
|
34
|
-
}
|
|
35
|
-
export declare class NotificationService extends EventEmitter {
|
|
36
|
-
private readonly mlsService;
|
|
37
|
-
private readonly apiClient;
|
|
38
|
-
private readonly backend;
|
|
39
|
-
private readonly cryptographyService;
|
|
40
|
-
private readonly database;
|
|
41
|
-
private readonly logger;
|
|
42
|
-
static readonly TOPIC: typeof TOPIC;
|
|
43
|
-
constructor(apiClient: APIClient, cryptographyService: CryptographyService, mlsService: MLSService, storeEngine: CRUDEngine);
|
|
44
|
-
private getAllNotifications;
|
|
45
|
-
/** Should only be called with a completely new client. */
|
|
46
|
-
initializeNotificationStream(): Promise<string>;
|
|
47
|
-
hasHistory(): Promise<boolean>;
|
|
48
|
-
getNotificationEventList(): Promise<Events.BackendEvent[]>;
|
|
49
|
-
setLastEventDate(eventDate: Date): Promise<Date>;
|
|
50
|
-
setLastNotificationId(lastNotification: Notification): Promise<string>;
|
|
51
|
-
handleNotificationStream(notificationHandler: NotificationHandler, onMissedNotifications: (notificationId: string) => void, abortHandler: AbortHandler): Promise<void>;
|
|
52
|
-
/**
|
|
53
|
-
* Checks if an event should be ignored.
|
|
54
|
-
* An event that has a date prior to that last event that we have parsed should be ignored
|
|
55
|
-
*
|
|
56
|
-
* @param event
|
|
57
|
-
* @param source
|
|
58
|
-
* @param lastEventDate?
|
|
59
|
-
*/
|
|
60
|
-
private isOutdatedEvent;
|
|
61
|
-
handleNotification(notification: Notification, source: PayloadBundleSource, dryRun?: boolean): AsyncGenerator<HandledEventPayload>;
|
|
62
|
-
private cleanupPayloadBundle;
|
|
63
|
-
private handleEvent;
|
|
64
|
-
/**
|
|
65
|
-
* ## MLS only ##
|
|
66
|
-
* If there is a groupId in the conversation, we need to store the conversationId => groupId pair
|
|
67
|
-
* in order to find the groupId when decrypting messages
|
|
68
|
-
* This is a bit hacky but since mls messages do not embed the groupId we need to keep a mapping of those
|
|
69
|
-
*
|
|
70
|
-
* @param conversation conversation with group_id
|
|
71
|
-
*/
|
|
72
|
-
saveConversationGroupId(conversation: Conversation): Promise<void>;
|
|
73
|
-
/**
|
|
74
|
-
* ## MLS only ##
|
|
75
|
-
* If there is a matching conversationId => groupId pair in the database,
|
|
76
|
-
* we can find the groupId and return it as a Uint8Array
|
|
77
|
-
*
|
|
78
|
-
* @param conversationQualifiedId
|
|
79
|
-
*/
|
|
80
|
-
getUint8ArrayFromConversationGroupId(conversationQualifiedId: QualifiedId): Promise<Uint8Array>;
|
|
81
|
-
/**
|
|
82
|
-
* ## MLS only ##
|
|
83
|
-
* If there are pending proposals, we need to either process them,
|
|
84
|
-
* or save them in the database for later processing
|
|
85
|
-
*
|
|
86
|
-
* @param groupId groupId of the mls conversation
|
|
87
|
-
* @param delayInMs delay in ms before processing proposals
|
|
88
|
-
* @param eventTime time of the event that had the proposals
|
|
89
|
-
*/
|
|
90
|
-
private handlePendingProposals;
|
|
91
|
-
/**
|
|
92
|
-
* ## MLS only ##
|
|
93
|
-
* Commit all pending proposals for a given groupId
|
|
94
|
-
*
|
|
95
|
-
* @param groupId groupId of the conversation
|
|
96
|
-
* @param skipDelete if true, do not delete the pending proposals from the database
|
|
97
|
-
*/
|
|
98
|
-
commitPendingProposals({ groupId, skipDelete }: CommitPendingProposalsParams): Promise<void>;
|
|
99
|
-
/**
|
|
100
|
-
* ## MLS only ##
|
|
101
|
-
* Get all pending proposals from the database and schedule them
|
|
102
|
-
* Function must only be called once, after application start
|
|
103
|
-
*
|
|
104
|
-
*/
|
|
105
|
-
checkExistingPendingProposals(): Promise<void>;
|
|
106
|
-
/**
|
|
107
|
-
* ## MLS only ##
|
|
108
|
-
* Store groupIds with last key material update dates.
|
|
109
|
-
*
|
|
110
|
-
* @param {groupId} params.groupId - groupId of the mls conversation
|
|
111
|
-
* @param {previousUpdateDate} params.previousUpdateDate - date of the previous key material update
|
|
112
|
-
*/
|
|
113
|
-
storeLastKeyMaterialUpdateDate(params: LastKeyMaterialUpdateParams): Promise<void>;
|
|
114
|
-
/**
|
|
115
|
-
* ## MLS only ##
|
|
116
|
-
* Renew key material for a given groupId
|
|
117
|
-
*
|
|
118
|
-
* @param groupId groupId of the conversation
|
|
119
|
-
*/
|
|
120
|
-
private renewKeyMaterial;
|
|
121
|
-
private createKeyMaterialUpdateTaskSchedulerId;
|
|
122
|
-
private scheduleTaskToRenewKeyMaterial;
|
|
123
|
-
/**
|
|
124
|
-
* ## MLS only ##
|
|
125
|
-
* Get all pending proposals from the database and schedule them
|
|
126
|
-
* Function must only be called once, after application start
|
|
127
|
-
*
|
|
128
|
-
*/
|
|
129
|
-
checkForKeyMaterialsUpdate(): Promise<void>;
|
|
130
|
-
}
|
|
131
|
-
export {};
|
|
@@ -1,468 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Wire
|
|
4
|
-
* Copyright (C) 2018 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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
28
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
29
|
-
}) : function(o, v) {
|
|
30
|
-
o["default"] = v;
|
|
31
|
-
});
|
|
32
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
33
|
-
if (mod && mod.__esModule) return mod;
|
|
34
|
-
var result = {};
|
|
35
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
36
|
-
__setModuleDefault(result, mod);
|
|
37
|
-
return result;
|
|
38
|
-
};
|
|
39
|
-
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
40
|
-
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
41
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
42
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
43
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
44
|
-
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
45
|
-
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
46
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
47
|
-
function fulfill(value) { resume("next", value); }
|
|
48
|
-
function reject(value) { resume("throw", value); }
|
|
49
|
-
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
50
|
-
};
|
|
51
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
52
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
53
|
-
};
|
|
54
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
55
|
-
exports.NotificationService = void 0;
|
|
56
|
-
const commons_1 = require("@wireapp/commons");
|
|
57
|
-
const Events = __importStar(require("@wireapp/api-client/src/event"));
|
|
58
|
-
const store_engine_1 = require("@wireapp/store-engine");
|
|
59
|
-
const events_1 = require("events");
|
|
60
|
-
const logdown_1 = __importDefault(require("logdown"));
|
|
61
|
-
const conversation_1 = require("../conversation");
|
|
62
|
-
const ConversationMapper_1 = require("../conversation/ConversationMapper");
|
|
63
|
-
const CoreError_1 = require("../CoreError");
|
|
64
|
-
const UserMapper_1 = require("../user/UserMapper");
|
|
65
|
-
const NotificationBackendRepository_1 = require("./NotificationBackendRepository");
|
|
66
|
-
const NotificationDatabaseRepository_1 = require("./NotificationDatabaseRepository");
|
|
67
|
-
const protocol_messaging_1 = require("@wireapp/protocol-messaging");
|
|
68
|
-
const bazinga64_1 = require("bazinga64");
|
|
69
|
-
const TaskScheduler_1 = require("../util/TaskScheduler/TaskScheduler");
|
|
70
|
-
const LowPrecisionTaskScheduler_1 = require("../util/LowPrecisionTaskScheduler/LowPrecisionTaskScheduler");
|
|
71
|
-
var TOPIC;
|
|
72
|
-
(function (TOPIC) {
|
|
73
|
-
TOPIC["NOTIFICATION_ERROR"] = "NotificationService.TOPIC.NOTIFICATION_ERROR";
|
|
74
|
-
})(TOPIC || (TOPIC = {}));
|
|
75
|
-
const DEFAULT_KEYING_MATERIAL_UPDATE_THRESHOLD = 1000 * 60 * 60 * 24 * 30; //30 days
|
|
76
|
-
class NotificationService extends events_1.EventEmitter {
|
|
77
|
-
constructor(apiClient, cryptographyService, mlsService, storeEngine) {
|
|
78
|
-
super();
|
|
79
|
-
this.mlsService = mlsService;
|
|
80
|
-
this.logger = (0, logdown_1.default)('@wireapp/core/notification/NotificationService', {
|
|
81
|
-
logger: console,
|
|
82
|
-
markdown: false,
|
|
83
|
-
});
|
|
84
|
-
this.apiClient = apiClient;
|
|
85
|
-
this.cryptographyService = cryptographyService;
|
|
86
|
-
this.backend = new NotificationBackendRepository_1.NotificationBackendRepository(this.apiClient);
|
|
87
|
-
this.database = new NotificationDatabaseRepository_1.NotificationDatabaseRepository(storeEngine);
|
|
88
|
-
}
|
|
89
|
-
async getAllNotifications() {
|
|
90
|
-
const clientId = this.apiClient.clientId;
|
|
91
|
-
const lastNotificationId = await this.database.getLastNotificationId();
|
|
92
|
-
return this.backend.getAllNotifications(clientId, lastNotificationId);
|
|
93
|
-
}
|
|
94
|
-
/** Should only be called with a completely new client. */
|
|
95
|
-
async initializeNotificationStream() {
|
|
96
|
-
const clientId = this.apiClient.clientId;
|
|
97
|
-
await this.setLastEventDate(new Date(0));
|
|
98
|
-
const latestNotification = await this.backend.getLastNotification(clientId);
|
|
99
|
-
return this.setLastNotificationId(latestNotification);
|
|
100
|
-
}
|
|
101
|
-
async hasHistory() {
|
|
102
|
-
const notificationEvents = await this.getNotificationEventList();
|
|
103
|
-
return !!notificationEvents.length;
|
|
104
|
-
}
|
|
105
|
-
getNotificationEventList() {
|
|
106
|
-
return this.database.getNotificationEventList();
|
|
107
|
-
}
|
|
108
|
-
async setLastEventDate(eventDate) {
|
|
109
|
-
let databaseLastEventDate;
|
|
110
|
-
try {
|
|
111
|
-
databaseLastEventDate = await this.database.getLastEventDate();
|
|
112
|
-
}
|
|
113
|
-
catch (error) {
|
|
114
|
-
if (error instanceof store_engine_1.error.RecordNotFoundError ||
|
|
115
|
-
error.constructor.name === store_engine_1.error.RecordNotFoundError.name) {
|
|
116
|
-
return this.database.createLastEventDate(eventDate);
|
|
117
|
-
}
|
|
118
|
-
throw error;
|
|
119
|
-
}
|
|
120
|
-
if (databaseLastEventDate && eventDate > databaseLastEventDate) {
|
|
121
|
-
return this.database.updateLastEventDate(eventDate);
|
|
122
|
-
}
|
|
123
|
-
return databaseLastEventDate;
|
|
124
|
-
}
|
|
125
|
-
async setLastNotificationId(lastNotification) {
|
|
126
|
-
return this.database.updateLastNotificationId(lastNotification);
|
|
127
|
-
}
|
|
128
|
-
async handleNotificationStream(notificationHandler, onMissedNotifications, abortHandler) {
|
|
129
|
-
const { notifications, missedNotification } = await this.getAllNotifications();
|
|
130
|
-
if (missedNotification) {
|
|
131
|
-
onMissedNotifications(missedNotification);
|
|
132
|
-
}
|
|
133
|
-
for (const [index, notification] of notifications.entries()) {
|
|
134
|
-
if (abortHandler.isAborted()) {
|
|
135
|
-
/* Stop handling notifications if the websocket has been disconnected.
|
|
136
|
-
* Upon reconnecting we are going to restart handling the notification stream for where we left of
|
|
137
|
-
*/
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
await notificationHandler(notification, conversation_1.PayloadBundleSource.NOTIFICATION_STREAM, {
|
|
141
|
-
done: index + 1,
|
|
142
|
-
total: notifications.length,
|
|
143
|
-
}).catch(error => this.logger.error(error));
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Checks if an event should be ignored.
|
|
148
|
-
* An event that has a date prior to that last event that we have parsed should be ignored
|
|
149
|
-
*
|
|
150
|
-
* @param event
|
|
151
|
-
* @param source
|
|
152
|
-
* @param lastEventDate?
|
|
153
|
-
*/
|
|
154
|
-
isOutdatedEvent(event, source, lastEventDate) {
|
|
155
|
-
const isFromNotificationStream = source === conversation_1.PayloadBundleSource.NOTIFICATION_STREAM;
|
|
156
|
-
const shouldCheckEventDate = !!event.time && isFromNotificationStream && lastEventDate;
|
|
157
|
-
if (shouldCheckEventDate) {
|
|
158
|
-
/** This check prevents duplicated "You joined" system messages. */
|
|
159
|
-
const isOutdated = lastEventDate.getTime() >= new Date(event.time).getTime();
|
|
160
|
-
return isOutdated;
|
|
161
|
-
}
|
|
162
|
-
return false;
|
|
163
|
-
}
|
|
164
|
-
handleNotification(notification, source, dryRun = false) {
|
|
165
|
-
return __asyncGenerator(this, arguments, function* handleNotification_1() {
|
|
166
|
-
for (const event of notification.payload) {
|
|
167
|
-
this.logger.log(`Handling event of type "${event.type}" for notification with ID "${notification.id}"`, event);
|
|
168
|
-
let lastEventDate = undefined;
|
|
169
|
-
try {
|
|
170
|
-
lastEventDate = yield __await(this.database.getLastEventDate());
|
|
171
|
-
}
|
|
172
|
-
catch (_a) { }
|
|
173
|
-
if ('time' in event && this.isOutdatedEvent(event, source, lastEventDate)) {
|
|
174
|
-
this.logger.info(`Ignored outdated event type: '${event.type}'`);
|
|
175
|
-
continue;
|
|
176
|
-
}
|
|
177
|
-
try {
|
|
178
|
-
const data = yield __await(this.handleEvent(event, source, dryRun));
|
|
179
|
-
yield yield __await(Object.assign(Object.assign({}, data), { mappedEvent: data.mappedEvent ? this.cleanupPayloadBundle(data.mappedEvent) : undefined }));
|
|
180
|
-
}
|
|
181
|
-
catch (error) {
|
|
182
|
-
this.logger.error(`There was an error with notification ID "${notification.id}": ${error.message}`, error);
|
|
183
|
-
const notificationError = {
|
|
184
|
-
error: error,
|
|
185
|
-
notification,
|
|
186
|
-
type: CoreError_1.CoreError.NOTIFICATION_ERROR,
|
|
187
|
-
};
|
|
188
|
-
this.emit(NotificationService.TOPIC.NOTIFICATION_ERROR, notificationError);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
if (!dryRun && !notification.transient) {
|
|
192
|
-
// keep track of the last handled notification for next time we fetch the notification stream
|
|
193
|
-
yield __await(this.setLastNotificationId(notification));
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
cleanupPayloadBundle(payload) {
|
|
198
|
-
switch (payload.type) {
|
|
199
|
-
case conversation_1.PayloadBundleType.ASSET: {
|
|
200
|
-
const assetContent = payload.content;
|
|
201
|
-
const isMetaData = !!(assetContent === null || assetContent === void 0 ? void 0 : assetContent.original) && !(assetContent === null || assetContent === void 0 ? void 0 : assetContent.uploaded);
|
|
202
|
-
const isAbort = !!assetContent.abortReason || (!assetContent.original && !assetContent.uploaded);
|
|
203
|
-
if (isMetaData) {
|
|
204
|
-
payload.type = conversation_1.PayloadBundleType.ASSET_META;
|
|
205
|
-
}
|
|
206
|
-
else if (isAbort) {
|
|
207
|
-
payload.type = conversation_1.PayloadBundleType.ASSET_ABORT;
|
|
208
|
-
}
|
|
209
|
-
return payload;
|
|
210
|
-
}
|
|
211
|
-
default:
|
|
212
|
-
return payload;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
async handleEvent(event, source, dryRun = false) {
|
|
216
|
-
var _a, _b;
|
|
217
|
-
switch (event.type) {
|
|
218
|
-
case Events.CONVERSATION_EVENT.MLS_WELCOME_MESSAGE:
|
|
219
|
-
const data = bazinga64_1.Decoder.fromBase64(event.data).asBytes;
|
|
220
|
-
// We extract the groupId from the welcome message and let coreCrypto store this group
|
|
221
|
-
const newGroupId = await this.mlsService.processWelcomeMessage(data);
|
|
222
|
-
const groupIdStr = bazinga64_1.Encoder.toBase64(newGroupId).asString;
|
|
223
|
-
// The groupId can then be sent back to the consumer
|
|
224
|
-
return {
|
|
225
|
-
event,
|
|
226
|
-
mappedEvent: ConversationMapper_1.ConversationMapper.mapConversationEvent(Object.assign(Object.assign({}, event), { data: groupIdStr }), source),
|
|
227
|
-
};
|
|
228
|
-
case Events.CONVERSATION_EVENT.MLS_MESSAGE_ADD:
|
|
229
|
-
const encryptedData = bazinga64_1.Decoder.fromBase64(event.data).asBytes;
|
|
230
|
-
const groupId = await this.getUint8ArrayFromConversationGroupId((_a = event.qualified_conversation) !== null && _a !== void 0 ? _a : { id: event.conversation, domain: '' });
|
|
231
|
-
// Check if the message includes proposals
|
|
232
|
-
const { proposals, commitDelay, message } = await this.mlsService.decryptMessage(groupId, encryptedData);
|
|
233
|
-
if (proposals.length > 0) {
|
|
234
|
-
await this.handlePendingProposals({
|
|
235
|
-
groupId: groupId.toString(),
|
|
236
|
-
delayInMs: commitDelay !== null && commitDelay !== void 0 ? commitDelay : 0,
|
|
237
|
-
eventTime: event.time,
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
if (!message) {
|
|
241
|
-
throw new Error(`MLS message received from ${source} was empty`);
|
|
242
|
-
}
|
|
243
|
-
const decryptedData = protocol_messaging_1.GenericMessage.decode(message);
|
|
244
|
-
/**
|
|
245
|
-
* @todo Find a proper solution to add mappedEvent to this return
|
|
246
|
-
* otherwise event.data will be base64 raw data of the received event
|
|
247
|
-
*/
|
|
248
|
-
return { event, decryptedData };
|
|
249
|
-
// Encrypted Proteus events
|
|
250
|
-
case Events.CONVERSATION_EVENT.OTR_MESSAGE_ADD: {
|
|
251
|
-
if (dryRun) {
|
|
252
|
-
// In case of a dry run, we do not want to decrypt messages
|
|
253
|
-
// We just return the raw event to the caller
|
|
254
|
-
return { event };
|
|
255
|
-
}
|
|
256
|
-
try {
|
|
257
|
-
const decryptedData = await this.cryptographyService.decryptMessage(event);
|
|
258
|
-
return {
|
|
259
|
-
mappedEvent: this.cryptographyService.mapGenericMessage(event, decryptedData, source),
|
|
260
|
-
event,
|
|
261
|
-
decryptedData,
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
catch (error) {
|
|
265
|
-
return { event, decryptionError: error };
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
// Meta events
|
|
269
|
-
case Events.CONVERSATION_EVENT.MEMBER_JOIN:
|
|
270
|
-
// As of today (07/07/2022) the backend sends `WELCOME` message to the user's own conversation (not the actual conversation that the welcome should be part of)
|
|
271
|
-
// So in order to map conversation Ids and groupId together, we need to first fetch the conversation and get the groupId linked to it.
|
|
272
|
-
const conversation = await this.apiClient.api.conversation.getConversation((_b = event.qualified_conversation) !== null && _b !== void 0 ? _b : { id: event.conversation, domain: '' });
|
|
273
|
-
if (!conversation) {
|
|
274
|
-
throw new Error('no conv');
|
|
275
|
-
}
|
|
276
|
-
await this.saveConversationGroupId(conversation);
|
|
277
|
-
case Events.CONVERSATION_EVENT.MESSAGE_TIMER_UPDATE:
|
|
278
|
-
case Events.CONVERSATION_EVENT.RENAME:
|
|
279
|
-
case Events.CONVERSATION_EVENT.TYPING: {
|
|
280
|
-
const { conversation, from } = event;
|
|
281
|
-
const metaEvent = Object.assign(Object.assign({}, event), { conversation, from });
|
|
282
|
-
return { mappedEvent: ConversationMapper_1.ConversationMapper.mapConversationEvent(metaEvent, source), event };
|
|
283
|
-
}
|
|
284
|
-
// User events
|
|
285
|
-
case Events.USER_EVENT.CONNECTION:
|
|
286
|
-
case Events.USER_EVENT.CLIENT_ADD:
|
|
287
|
-
case Events.USER_EVENT.UPDATE:
|
|
288
|
-
case Events.USER_EVENT.CLIENT_REMOVE: {
|
|
289
|
-
return { mappedEvent: UserMapper_1.UserMapper.mapUserEvent(event, this.apiClient.context.userId, source), event };
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
return { event };
|
|
293
|
-
}
|
|
294
|
-
/**
|
|
295
|
-
* ## MLS only ##
|
|
296
|
-
* If there is a groupId in the conversation, we need to store the conversationId => groupId pair
|
|
297
|
-
* in order to find the groupId when decrypting messages
|
|
298
|
-
* This is a bit hacky but since mls messages do not embed the groupId we need to keep a mapping of those
|
|
299
|
-
*
|
|
300
|
-
* @param conversation conversation with group_id
|
|
301
|
-
*/
|
|
302
|
-
async saveConversationGroupId(conversation) {
|
|
303
|
-
if (conversation.group_id) {
|
|
304
|
-
const { group_id: groupId, qualified_id: { id: conversationId, domain: conversationDomain }, } = conversation;
|
|
305
|
-
await this.database.addCompoundGroupId({ conversationDomain, conversationId, groupId });
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* ## MLS only ##
|
|
310
|
-
* If there is a matching conversationId => groupId pair in the database,
|
|
311
|
-
* we can find the groupId and return it as a Uint8Array
|
|
312
|
-
*
|
|
313
|
-
* @param conversationQualifiedId
|
|
314
|
-
*/
|
|
315
|
-
async getUint8ArrayFromConversationGroupId(conversationQualifiedId) {
|
|
316
|
-
const { id: conversationId, domain: conversationDomain } = conversationQualifiedId;
|
|
317
|
-
const groupId = await this.database.getCompoundGroupId({
|
|
318
|
-
conversationId,
|
|
319
|
-
conversationDomain,
|
|
320
|
-
});
|
|
321
|
-
if (!groupId) {
|
|
322
|
-
throw new Error(`Could not find a group_id for conversation ${conversationId}@${conversationDomain}`);
|
|
323
|
-
}
|
|
324
|
-
return bazinga64_1.Decoder.fromBase64(groupId).asBytes;
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* ## MLS only ##
|
|
328
|
-
* If there are pending proposals, we need to either process them,
|
|
329
|
-
* or save them in the database for later processing
|
|
330
|
-
*
|
|
331
|
-
* @param groupId groupId of the mls conversation
|
|
332
|
-
* @param delayInMs delay in ms before processing proposals
|
|
333
|
-
* @param eventTime time of the event that had the proposals
|
|
334
|
-
*/
|
|
335
|
-
async handlePendingProposals({ delayInMs, groupId, eventTime }) {
|
|
336
|
-
if (delayInMs > 0) {
|
|
337
|
-
const eventDate = new Date(eventTime);
|
|
338
|
-
const firingDate = eventDate.setTime(eventDate.getTime() + delayInMs);
|
|
339
|
-
try {
|
|
340
|
-
await this.database.storePendingProposal({
|
|
341
|
-
groupId,
|
|
342
|
-
firingDate,
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
catch (error) {
|
|
346
|
-
this.logger.error('Could not store pending proposal', error);
|
|
347
|
-
}
|
|
348
|
-
finally {
|
|
349
|
-
TaskScheduler_1.TaskScheduler.addTask({
|
|
350
|
-
task: () => this.commitPendingProposals({ groupId }),
|
|
351
|
-
firingDate,
|
|
352
|
-
key: groupId,
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
else {
|
|
357
|
-
await this.commitPendingProposals({ groupId, skipDelete: true });
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
/**
|
|
361
|
-
* ## MLS only ##
|
|
362
|
-
* Commit all pending proposals for a given groupId
|
|
363
|
-
*
|
|
364
|
-
* @param groupId groupId of the conversation
|
|
365
|
-
* @param skipDelete if true, do not delete the pending proposals from the database
|
|
366
|
-
*/
|
|
367
|
-
async commitPendingProposals({ groupId, skipDelete = false }) {
|
|
368
|
-
try {
|
|
369
|
-
await this.mlsService.commitPendingProposals(bazinga64_1.Decoder.fromBase64(groupId).asBytes);
|
|
370
|
-
if (!skipDelete) {
|
|
371
|
-
TaskScheduler_1.TaskScheduler.cancelTask(groupId);
|
|
372
|
-
await this.database.deletePendingProposal({ groupId });
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
catch (error) {
|
|
376
|
-
this.logger.error(`Error while committing pending proposals for groupId ${groupId}`, error);
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
/**
|
|
380
|
-
* ## MLS only ##
|
|
381
|
-
* Get all pending proposals from the database and schedule them
|
|
382
|
-
* Function must only be called once, after application start
|
|
383
|
-
*
|
|
384
|
-
*/
|
|
385
|
-
async checkExistingPendingProposals() {
|
|
386
|
-
try {
|
|
387
|
-
const pendingProposals = await this.database.getStoredPendingProposals();
|
|
388
|
-
if (pendingProposals.length > 0) {
|
|
389
|
-
pendingProposals.forEach(({ groupId, firingDate }) => TaskScheduler_1.TaskScheduler.addTask({
|
|
390
|
-
task: () => this.commitPendingProposals({ groupId }),
|
|
391
|
-
firingDate,
|
|
392
|
-
key: groupId,
|
|
393
|
-
}));
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
catch (error) {
|
|
397
|
-
this.logger.error('Could not get pending proposals', error);
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
/**
|
|
401
|
-
* ## MLS only ##
|
|
402
|
-
* Store groupIds with last key material update dates.
|
|
403
|
-
*
|
|
404
|
-
* @param {groupId} params.groupId - groupId of the mls conversation
|
|
405
|
-
* @param {previousUpdateDate} params.previousUpdateDate - date of the previous key material update
|
|
406
|
-
*/
|
|
407
|
-
async storeLastKeyMaterialUpdateDate(params) {
|
|
408
|
-
await this.database.storeLastKeyMaterialUpdateDate(params);
|
|
409
|
-
await this.scheduleTaskToRenewKeyMaterial(params);
|
|
410
|
-
}
|
|
411
|
-
/**
|
|
412
|
-
* ## MLS only ##
|
|
413
|
-
* Renew key material for a given groupId
|
|
414
|
-
*
|
|
415
|
-
* @param groupId groupId of the conversation
|
|
416
|
-
*/
|
|
417
|
-
async renewKeyMaterial({ groupId }) {
|
|
418
|
-
try {
|
|
419
|
-
const groupConversationExists = await this.mlsService.conversationExists(bazinga64_1.Decoder.fromBase64(groupId).asBytes);
|
|
420
|
-
if (!groupConversationExists) {
|
|
421
|
-
await this.database.deleteLastKeyMaterialUpdateDate({ groupId });
|
|
422
|
-
return;
|
|
423
|
-
}
|
|
424
|
-
const groupIdDecodedFromBase64 = bazinga64_1.Decoder.fromBase64(groupId).asBytes;
|
|
425
|
-
await this.mlsService.updateKeyingMaterial(groupIdDecodedFromBase64);
|
|
426
|
-
const keyRenewalTime = new Date().getTime();
|
|
427
|
-
const keyMaterialUpdateDate = { groupId, previousUpdateDate: keyRenewalTime };
|
|
428
|
-
await this.storeLastKeyMaterialUpdateDate(keyMaterialUpdateDate);
|
|
429
|
-
}
|
|
430
|
-
catch (error) {
|
|
431
|
-
this.logger.error(`Error while renewing key material for groupId ${groupId}`, error);
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
createKeyMaterialUpdateTaskSchedulerId(groupId) {
|
|
435
|
-
return `renew-key-material-update-${groupId}`;
|
|
436
|
-
}
|
|
437
|
-
async scheduleTaskToRenewKeyMaterial({ groupId, previousUpdateDate }) {
|
|
438
|
-
var _a;
|
|
439
|
-
//given period of time (30 days by default) after last update date renew key material
|
|
440
|
-
const keyingMaterialUpdateThreshold = ((_a = this.mlsService.config) === null || _a === void 0 ? void 0 : _a.keyingMaterialUpdateThreshold) || DEFAULT_KEYING_MATERIAL_UPDATE_THRESHOLD;
|
|
441
|
-
const firingDate = previousUpdateDate + keyingMaterialUpdateThreshold;
|
|
442
|
-
const key = this.createKeyMaterialUpdateTaskSchedulerId(groupId);
|
|
443
|
-
LowPrecisionTaskScheduler_1.LowPrecisionTaskScheduler.addTask({
|
|
444
|
-
task: () => this.renewKeyMaterial({ groupId }),
|
|
445
|
-
intervalDelay: commons_1.TimeUtil.TimeInMillis.MINUTE,
|
|
446
|
-
firingDate,
|
|
447
|
-
key,
|
|
448
|
-
});
|
|
449
|
-
}
|
|
450
|
-
/**
|
|
451
|
-
* ## MLS only ##
|
|
452
|
-
* Get all pending proposals from the database and schedule them
|
|
453
|
-
* Function must only be called once, after application start
|
|
454
|
-
*
|
|
455
|
-
*/
|
|
456
|
-
async checkForKeyMaterialsUpdate() {
|
|
457
|
-
try {
|
|
458
|
-
const keyMaterialUpdateDates = await this.database.getStoredLastKeyMaterialUpdateDates();
|
|
459
|
-
keyMaterialUpdateDates.forEach(date => this.scheduleTaskToRenewKeyMaterial(date));
|
|
460
|
-
}
|
|
461
|
-
catch (error) {
|
|
462
|
-
this.logger.error('Could not get last key material update dates', error);
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
exports.NotificationService = NotificationService;
|
|
467
|
-
NotificationService.TOPIC = TOPIC;
|
|
468
|
-
//# sourceMappingURL=NotificationService.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './NotificationService';
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Wire
|
|
4
|
-
* Copyright (C) 2018 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("./NotificationService"), exports);
|
|
32
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export declare type CommonMLS = {
|
|
2
|
-
groupId: string;
|
|
3
|
-
};
|
|
4
|
-
export declare type CompoundGroupIdParams = {
|
|
5
|
-
conversationId: string;
|
|
6
|
-
conversationDomain: string;
|
|
7
|
-
} & CommonMLS;
|
|
8
|
-
export declare type HandlePendingProposalsParams = {
|
|
9
|
-
delayInMs: number;
|
|
10
|
-
eventTime: string;
|
|
11
|
-
} & CommonMLS;
|
|
12
|
-
export declare type CommitPendingProposalsParams = {
|
|
13
|
-
skipDelete?: boolean;
|
|
14
|
-
} & CommonMLS;
|
|
15
|
-
export declare type StorePendingProposalsParams = {
|
|
16
|
-
firingDate: number;
|
|
17
|
-
} & CommonMLS;
|
|
18
|
-
export declare type LastKeyMaterialUpdateParams = {
|
|
19
|
-
previousUpdateDate: number;
|
|
20
|
-
} & CommonMLS;
|
|
@@ -1,21 +0,0 @@
|
|
|
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
|
-
//# sourceMappingURL=types.js.map
|