@wireapp/core 46.46.6-beta.14.f6fd03fe6 → 46.46.6
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/lib/Account.d.ts +156 -51
- package/lib/Account.d.ts.map +1 -1
- package/lib/Account.js +503 -127
- package/lib/Account.test.js +158 -147
- package/lib/broadcast/AvailabilityType.d.ts +1 -1
- package/lib/broadcast/AvailabilityType.d.ts.map +1 -1
- package/lib/broadcast/BroadcastService.d.ts +1 -1
- package/lib/broadcast/BroadcastService.d.ts.map +1 -1
- package/lib/broadcast/BroadcastService.js +1 -1
- package/lib/client/ClientService.d.ts +4 -3
- package/lib/client/ClientService.d.ts.map +1 -1
- package/lib/client/ClientService.js +19 -5
- package/lib/conversation/AbortReason.d.ts +1 -1
- package/lib/conversation/AbortReason.d.ts.map +1 -1
- package/lib/conversation/AssetService/AssetService.d.ts +12 -30
- package/lib/conversation/AssetService/AssetService.d.ts.map +1 -1
- package/lib/conversation/AssetService/AssetService.js +1 -10
- package/lib/conversation/AssetService/AssetService.test.js +8 -3
- package/lib/conversation/ClientActionType.d.ts +1 -1
- package/lib/conversation/ClientActionType.d.ts.map +1 -1
- package/lib/conversation/ClientActionType.js +1 -1
- package/lib/conversation/ConversationService/ConversationService.d.ts +98 -14
- package/lib/conversation/ConversationService/ConversationService.d.ts.map +1 -1
- package/lib/conversation/ConversationService/ConversationService.js +314 -101
- package/lib/conversation/ConversationService/ConversationService.test.js +441 -47
- package/lib/conversation/ConversationService/ConversationService.types.d.ts +5 -4
- package/lib/conversation/ConversationService/ConversationService.types.d.ts.map +1 -1
- package/lib/conversation/ConversationService/Utility/getConversationQualifiedMembers.d.ts.map +1 -1
- package/lib/conversation/ConversationService/Utility/getConversationQualifiedMembers.js +6 -3
- package/lib/conversation/SubconversationService/SubconversationService.d.ts.map +1 -1
- package/lib/conversation/SubconversationService/SubconversationService.js +158 -11
- package/lib/conversation/SubconversationService/SubconversationService.test.js +8 -2
- package/lib/conversation/content/AssetContent.d.ts +1 -1
- package/lib/conversation/content/AssetContent.d.ts.map +1 -1
- package/lib/conversation/content/ButtonActionConfirmationContent.d.ts +1 -1
- package/lib/conversation/content/ButtonActionConfirmationContent.d.ts.map +1 -1
- package/lib/conversation/content/ButtonActionContent.d.ts +1 -1
- package/lib/conversation/content/ButtonActionContent.d.ts.map +1 -1
- package/lib/conversation/content/ClearedContent.d.ts +1 -1
- package/lib/conversation/content/ClearedContent.d.ts.map +1 -1
- package/lib/conversation/content/ClientActionContent.d.ts +1 -1
- package/lib/conversation/content/ClientActionContent.d.ts.map +1 -1
- package/lib/conversation/content/CompositeContent.d.ts +1 -1
- package/lib/conversation/content/CompositeContent.d.ts.map +1 -1
- package/lib/conversation/content/ConfirmationContent.d.ts +1 -1
- package/lib/conversation/content/ConfirmationContent.d.ts.map +1 -1
- package/lib/conversation/content/DeletedContent.d.ts +1 -1
- package/lib/conversation/content/DeletedContent.d.ts.map +1 -1
- package/lib/conversation/content/HiddenContent.d.ts +1 -1
- package/lib/conversation/content/HiddenContent.d.ts.map +1 -1
- package/lib/conversation/content/KnockContent.d.ts +1 -1
- package/lib/conversation/content/KnockContent.d.ts.map +1 -1
- package/lib/conversation/content/LinkPreviewContent.d.ts +1 -1
- package/lib/conversation/content/LinkPreviewContent.d.ts.map +1 -1
- package/lib/conversation/content/MentionContent.d.ts +1 -1
- package/lib/conversation/content/MentionContent.d.ts.map +1 -1
- package/lib/conversation/content/MultipartContent.d.ts +1 -1
- package/lib/conversation/content/MultipartContent.d.ts.map +1 -1
- package/lib/conversation/content/QuoteContent.d.ts +1 -1
- package/lib/conversation/content/QuoteContent.d.ts.map +1 -1
- package/lib/conversation/content/TweetContent.d.ts +1 -1
- package/lib/conversation/content/TweetContent.d.ts.map +1 -1
- package/lib/conversation/content/index.d.ts +1 -1
- package/lib/conversation/content/index.d.ts.map +1 -1
- package/lib/conversation/content/index.js +1 -1
- package/lib/conversation/message/MessageBuilder.d.ts +1 -1
- package/lib/conversation/message/MessageBuilder.d.ts.map +1 -1
- package/lib/conversation/message/MessageBuilder.js +1 -1
- package/lib/conversation/message/MessageService.d.ts.map +1 -1
- package/lib/conversation/message/MessageService.js +1 -1
- package/lib/conversation/message/MessageService.test.js +7 -1
- package/lib/conversation/message/MessageToProtoMapper.d.ts +1 -1
- package/lib/conversation/message/MessageToProtoMapper.d.ts.map +1 -1
- package/lib/conversation/message/MessageToProtoMapper.js +1 -1
- package/lib/conversation/message/messageSender.js +2 -2
- package/lib/cryptography/AssetCryptography/EncryptedAsset.d.ts +2 -2
- package/lib/cryptography/AssetCryptography/EncryptedAsset.d.ts.map +1 -1
- package/lib/messagingProtocols/common.types.d.ts +9 -0
- package/lib/messagingProtocols/common.types.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIService.types.d.ts +2 -2
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIService.types.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIService.types.js +2 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.d.ts +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.js +13 -11
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.test.js +21 -16
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.d.ts +9 -3
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.js +31 -12
- package/lib/messagingProtocols/mls/E2EIdentityService/Helper/index.d.ts +6 -0
- package/lib/messagingProtocols/mls/E2EIdentityService/Helper/index.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/Helper/index.js +19 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingProposalsQueue/IncomingProposalsQueue.d.ts +7 -0
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingProposalsQueue/IncomingProposalsQueue.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingProposalsQueue/IncomingProposalsQueue.js +48 -0
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingProposalsQueue/index.d.ts +2 -0
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/{IncomingMessagesQueue → IncomingProposalsQueue}/index.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/{IncomingMessagesQueue → IncomingProposalsQueue}/index.js +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/index.d.ts +0 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/index.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/index.js +0 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.js +23 -14
- package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.js +5 -2
- package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.test.js +13 -3
- package/lib/messagingProtocols/mls/MLSService/CoreCryptoMLSError.d.ts +38 -2
- package/lib/messagingProtocols/mls/MLSService/CoreCryptoMLSError.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/MLSService/CoreCryptoMLSError.js +41 -6
- package/lib/messagingProtocols/mls/MLSService/CoreCryptoMLSError.test.d.ts +2 -0
- package/lib/messagingProtocols/mls/MLSService/CoreCryptoMLSError.test.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/MLSService/CoreCryptoMLSError.test.js +124 -0
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts +38 -34
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/MLSService/MLSService.js +267 -208
- package/lib/messagingProtocols/mls/MLSService/MLSService.test.js +157 -160
- package/lib/messagingProtocols/mls/MLSService/commitBundleUtil.js +3 -3
- package/lib/messagingProtocols/mls/MLSService/commitBundleUtil.test.js +5 -5
- package/lib/messagingProtocols/mls/conversationRejoinQueue.js +2 -2
- package/lib/messagingProtocols/mls/recovery/MlsErrorMapper.d.ts +78 -0
- package/lib/messagingProtocols/mls/recovery/MlsErrorMapper.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/recovery/MlsErrorMapper.js +173 -0
- package/lib/messagingProtocols/mls/recovery/MlsErrorMapper.test.d.ts +2 -0
- package/lib/messagingProtocols/mls/recovery/MlsErrorMapper.test.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/recovery/MlsErrorMapper.test.js +117 -0
- package/lib/messagingProtocols/mls/recovery/MlsRecoveryOrchestrator.d.ts +167 -0
- package/lib/messagingProtocols/mls/recovery/MlsRecoveryOrchestrator.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/recovery/MlsRecoveryOrchestrator.js +317 -0
- package/lib/messagingProtocols/mls/recovery/MlsRecoveryOrchestrator.test.d.ts +2 -0
- package/lib/messagingProtocols/mls/recovery/MlsRecoveryOrchestrator.test.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/recovery/MlsRecoveryOrchestrator.test.js +248 -0
- package/lib/messagingProtocols/mls/recovery/index.d.ts +5 -0
- package/lib/messagingProtocols/mls/recovery/index.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/recovery/index.js +28 -0
- package/lib/messagingProtocols/mls/types.d.ts +0 -8
- package/lib/messagingProtocols/mls/types.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/EventHandler/events/otrMessageAdd/otrMessageAdd.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/EventHandler/events/otrMessageAdd/otrMessageAdd.js +7 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.d.ts +8 -15
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.js +97 -62
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.types.d.ts +0 -6
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.types.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/DecryptionErrorGenerator/DecryptionErrorGenerator.d.ts +1 -6
- package/lib/messagingProtocols/proteus/ProteusService/DecryptionErrorGenerator/DecryptionErrorGenerator.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/DecryptionErrorGenerator/DecryptionErrorGenerator.js +19 -22
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.d.ts +5 -3
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.js +11 -24
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.d.ts +1 -0
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.js +11 -2
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.test.js +13 -9
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.types.d.ts +3 -2
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.types.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/WithMockedGenerics.test.js +11 -4
- package/lib/messagingProtocols/proteus/ProteusService/cryptoMigrationStateStore.d.ts +0 -4
- package/lib/messagingProtocols/proteus/ProteusService/cryptoMigrationStateStore.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/cryptoMigrationStateStore.js +0 -5
- package/lib/messagingProtocols/proteus/ProteusService/identityClearer.d.ts +2 -1
- package/lib/messagingProtocols/proteus/ProteusService/identityClearer.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/identityClearer.js +8 -2
- package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.test.js +4 -0
- package/lib/messagingProtocols/proteus/Utility/getGenericMessageParams.d.ts +1 -1
- package/lib/messagingProtocols/proteus/Utility/getGenericMessageParams.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/Utility/getGenericMessageParams.js +1 -1
- package/lib/notification/NotificationService.d.ts +20 -6
- package/lib/notification/NotificationService.d.ts.map +1 -1
- package/lib/notification/NotificationService.js +23 -14
- package/lib/notification/NotificationService.test.js +8 -0
- package/lib/secretStore/secretKeyGenerator.d.ts +1 -0
- package/lib/secretStore/secretKeyGenerator.d.ts.map +1 -1
- package/lib/secretStore/secretKeyGenerator.js +3 -1
- package/lib/self/SelfService.d.ts +2 -2
- package/lib/self/SelfService.d.ts.map +1 -1
- package/lib/self/SelfService.test.js +5 -2
- package/lib/team/TeamService.d.ts +5 -2
- package/lib/team/TeamService.d.ts.map +1 -1
- package/lib/team/TeamService.js +12 -2
- package/lib/test/StoreHelper.d.ts +2 -0
- package/lib/test/StoreHelper.d.ts.map +1 -0
- package/lib/test/StoreHelper.js +27 -0
- package/lib/user/UserService.d.ts +2 -2
- package/lib/user/UserService.d.ts.map +1 -1
- package/lib/user/UserService.js +3 -3
- package/lib/util/TypePredicateUtil.d.ts.map +1 -1
- package/lib/util/TypePredicateUtil.js +2 -2
- package/package.json +3 -3
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingMessagesQueue/IncomingMesssagesQueue.d.ts +0 -4
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingMessagesQueue/IncomingMesssagesQueue.d.ts.map +0 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingMessagesQueue/IncomingMesssagesQueue.js +0 -69
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingMessagesQueue/index.d.ts +0 -2
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.test.d.ts +0 -2
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.test.d.ts.map +0 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.test.js +0 -98
|
@@ -19,16 +19,21 @@
|
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.handleOtrMessageAdd = void 0;
|
|
22
|
-
const protocol_messaging_1 = require("@pydio/protocol-messaging");
|
|
23
22
|
const bazinga64_1 = require("bazinga64");
|
|
23
|
+
const commons_1 = require("@wireapp/commons");
|
|
24
|
+
const protocol_messaging_1 = require("@wireapp/protocol-messaging");
|
|
24
25
|
const conversation_1 = require("../../../../../conversation");
|
|
25
26
|
const DecryptionError_1 = require("../../../../../errors/DecryptionError");
|
|
27
|
+
const logger = commons_1.LogFactory.getLogger('@wireapp/core/otrMessageAdd');
|
|
26
28
|
const handleOtrMessageAdd = async ({ event, proteusService, }) => {
|
|
27
29
|
try {
|
|
28
30
|
const { from, qualified_from, data: { sender: clientId, text: encodedCiphertext }, } = event;
|
|
29
31
|
const userId = qualified_from || { id: from, domain: '' };
|
|
30
32
|
const messageBytes = bazinga64_1.Decoder.fromBase64(encodedCiphertext).asBytes;
|
|
33
|
+
const now = Date.now();
|
|
34
|
+
logger.info('Decrypting OTR message', { userId, clientId, event });
|
|
31
35
|
const decryptedData = await proteusService.decrypt(messageBytes, userId, clientId);
|
|
36
|
+
logger.info('OTR message decrypted successfully', { userId, clientId, event, duration: Date.now() - now });
|
|
32
37
|
const decodedData = protocol_messaging_1.GenericMessage.decode(decryptedData);
|
|
33
38
|
const isSessionReset = decodedData[conversation_1.GenericMessageType.CLIENT_ACTION] === protocol_messaging_1.ClientAction.RESET_SESSION;
|
|
34
39
|
if (isSessionReset) {
|
|
@@ -41,6 +46,7 @@ const handleOtrMessageAdd = async ({ event, proteusService, }) => {
|
|
|
41
46
|
};
|
|
42
47
|
}
|
|
43
48
|
catch (error) {
|
|
49
|
+
logger.warn('Failed to decrypt OTR message', { event, error });
|
|
44
50
|
if (error instanceof DecryptionError_1.DecryptionError) {
|
|
45
51
|
return { event, decryptionError: error };
|
|
46
52
|
}
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { PreKey } from '@wireapp/api-client/lib/auth';
|
|
2
|
-
import { CoreCrypto } from '@wireapp/core-crypto';
|
|
2
|
+
import { CoreCrypto, CoreCryptoLogLevel } from '@wireapp/core-crypto';
|
|
3
3
|
import type { CRUDEngine } from '@wireapp/store-engine';
|
|
4
4
|
import { GeneratedKey } from '../../../../../secretStore/secretKeyGenerator';
|
|
5
|
+
import { CoreCryptoConfig } from '../../../../common.types';
|
|
5
6
|
import { CryptoClient } from '../CryptoClient.types';
|
|
6
7
|
type Config = {
|
|
7
|
-
generateSecretKey: (keyId: string) => Promise<GeneratedKey>;
|
|
8
|
+
generateSecretKey: (keyId: string, keySize: 16 | 32) => Promise<GeneratedKey>;
|
|
8
9
|
nbPrekeys: number;
|
|
9
10
|
onNewPrekeys: (prekeys: PreKey[]) => void;
|
|
10
|
-
wasmFilePath: string;
|
|
11
11
|
};
|
|
12
|
-
type ClientConfig = Omit<Config, 'generateSecretKey'
|
|
12
|
+
type ClientConfig = Omit<Config, 'generateSecretKey'> & {
|
|
13
13
|
onWipe: () => Promise<void>;
|
|
14
14
|
};
|
|
15
|
-
export declare
|
|
15
|
+
export declare const getCoreCryptoDbName: (storeEngine: CRUDEngine) => string;
|
|
16
|
+
export declare const wipeCoreCryptoDb: (storeEngine: CRUDEngine) => Promise<void>;
|
|
17
|
+
export declare function buildClient(storeEngine: CRUDEngine, { generateSecretKey, nbPrekeys, onNewPrekeys }: Config, { wasmFilePath }: CoreCryptoConfig): Promise<CoreCryptoWrapper>;
|
|
16
18
|
export declare class CoreCryptoWrapper implements CryptoClient {
|
|
17
19
|
private readonly coreCrypto;
|
|
18
|
-
private readonly config;
|
|
19
20
|
private readonly prekeyTracker;
|
|
20
21
|
readonly version: string;
|
|
21
22
|
constructor(coreCrypto: CoreCrypto, config: ClientConfig);
|
|
@@ -30,6 +31,7 @@ export declare class CoreCryptoWrapper implements CryptoClient {
|
|
|
30
31
|
key: string;
|
|
31
32
|
};
|
|
32
33
|
}>;
|
|
34
|
+
setMaxLogLevel(level: CoreCryptoLogLevel): void;
|
|
33
35
|
getFingerprint(): Promise<string>;
|
|
34
36
|
getRemoteFingerprint(sessionId: string): Promise<string>;
|
|
35
37
|
sessionFromMessage(sessionId: string, message: Uint8Array): Promise<Uint8Array>;
|
|
@@ -43,15 +45,6 @@ export declare class CoreCryptoWrapper implements CryptoClient {
|
|
|
43
45
|
key: string;
|
|
44
46
|
}>;
|
|
45
47
|
debugBreakSession(sessionId: string): Promise<void>;
|
|
46
|
-
debugResetIdentity(): Promise<void>;
|
|
47
|
-
migrateFromCryptobox(dbName: string): Promise<void>;
|
|
48
|
-
/**
|
|
49
|
-
* Will call the callback once corecrypto is ready.
|
|
50
|
-
* @param callback - Function to be called once corecrypto is ready.
|
|
51
|
-
* @see https://github.com/wireapp/wire-web-packages/pull/4972
|
|
52
|
-
*/
|
|
53
|
-
private onReady;
|
|
54
|
-
wipe(): Promise<void>;
|
|
55
48
|
}
|
|
56
49
|
export {};
|
|
57
50
|
//# sourceMappingURL=CoreCryptoWrapper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoreCryptoWrapper.d.ts","sourceRoot":"","sources":["../../../../../../src/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,MAAM,EAAC,MAAM,8BAA8B,CAAC;AAKpD,OAAO,
|
|
1
|
+
{"version":3,"file":"CoreCryptoWrapper.d.ts","sourceRoot":"","sources":["../../../../../../src/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,MAAM,EAAC,MAAM,8BAA8B,CAAC;AAKpD,OAAO,EACL,UAAU,EACV,kBAAkB,EAOnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAItD,OAAO,EAAoB,YAAY,EAAC,MAAM,+CAA+C,CAAC;AAC9F,OAAO,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAC;AAEnD,KAAK,MAAM,GAAG;IACZ,iBAAiB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;IAC9E,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CAC3C,CAAC;AAEF,KAAK,YAAY,GAAG,IAAI,CAAC,MAAM,EAAE,mBAAmB,CAAC,GAAG;IACtD,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7B,CAAC;AAiEF,eAAO,MAAM,mBAAmB,gBAAiB,UAAU,KAAG,MAE7D,CAAC;AAEF,eAAO,MAAM,gBAAgB,gBAAuB,UAAU,KAAG,OAAO,CAAC,IAAI,CAS5E,CAAC;AAGF,wBAAsB,WAAW,CAC/B,WAAW,EAAE,UAAU,EACvB,EAAC,iBAAiB,EAAE,SAAS,EAAE,YAAY,EAAC,EAAE,MAAM,EACpD,EAAC,YAAY,EAAC,EAAE,gBAAgB,GAC/B,OAAO,CAAC,iBAAiB,CAAC,CA0C5B;AAED,qBAAa,iBAAkB,YAAW,YAAY;IAKlD,OAAO,CAAC,QAAQ,CAAC,UAAU;IAJ7B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;IAC9C,SAAgB,OAAO,EAAE,MAAM,CAAC;gBAGb,UAAU,EAAE,UAAU,EACvC,MAAM,EAAE,YAAY;IAMtB,eAAe;IAIf,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,UAAU;IAIjD,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU;IAI9C,IAAI,CAAC,gBAAgB,CAAC,EAAE,MAAM;IAOxB,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU;;;;;;;IAqB7C,cAAc,CAAC,KAAK,EAAE,kBAAkB;IAI/C,cAAc;IAId,oBAAoB,CAAC,SAAS,EAAE,MAAM;IAIhC,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU;IAK/D,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU;IAIvD,aAAa,CAAC,SAAS,EAAE,MAAM;IAI/B,WAAW,CAAC,SAAS,EAAE,MAAM;IAI7B,aAAa,CAAC,SAAS,EAAE,MAAM;IAI/B,aAAa;IAIP,SAAS;;;;IAKT,iBAAiB,CAAC,SAAS,EAAE,MAAM;CAS1C"}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.CoreCryptoWrapper = void 0;
|
|
21
|
+
exports.CoreCryptoWrapper = exports.wipeCoreCryptoDb = exports.getCoreCryptoDbName = void 0;
|
|
22
22
|
exports.buildClient = buildClient;
|
|
23
23
|
const bazinga64_1 = require("bazinga64");
|
|
24
24
|
const idb_1 = require("idb");
|
|
@@ -40,57 +40,118 @@ const coreCryptoLogger = {
|
|
|
40
40
|
logFunctions[level].call(logger, { message, context });
|
|
41
41
|
},
|
|
42
42
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
const getKey = async (generateSecretKey, keyName, keySize) => {
|
|
44
|
+
return await generateSecretKey(keyName, keySize);
|
|
45
|
+
};
|
|
46
|
+
const migrateOnceAndGetKey = async (generateSecretKey, coreCryptoDbName) => {
|
|
47
|
+
const coreCryptoNewKeyId = 'corecrypto-key-v2';
|
|
46
48
|
const coreCryptoKeyId = 'corecrypto-key';
|
|
49
|
+
// We retrieve the old key if it exists or generate a new one
|
|
50
|
+
const keyOld = await getKey(generateSecretKey, coreCryptoKeyId, 16);
|
|
51
|
+
// We retrieve the new key if it exists or generate a new one
|
|
52
|
+
const keyNew = await getKey(generateSecretKey, coreCryptoNewKeyId, 32);
|
|
53
|
+
if (!keyNew || !keyOld) {
|
|
54
|
+
// If we dont retreive any key, we throw an error
|
|
55
|
+
// This should not happen since we generate a new key if it does not exist
|
|
56
|
+
throw new Error('Key not found and could not be generated');
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Handles migration and cleanup of encryption keys.
|
|
60
|
+
*
|
|
61
|
+
* - If `keyNew` is freshly generated and `keyOld` is not freshly generated:
|
|
62
|
+
* - Migrate data from `keyOld` to `keyNew`
|
|
63
|
+
*/
|
|
64
|
+
if (keyNew.freshlyGenerated && !keyOld.freshlyGenerated) {
|
|
65
|
+
const databaseKey = new core_crypto_1.DatabaseKey(keyNew.key);
|
|
66
|
+
await (0, core_crypto_1.migrateDatabaseKeyTypeToBytes)(coreCryptoDbName, bazinga64_1.Encoder.toBase64(keyOld.key).asString, databaseKey);
|
|
67
|
+
}
|
|
68
|
+
// Always clean up the old key
|
|
69
|
+
await keyOld.deleteKey();
|
|
70
|
+
return {
|
|
71
|
+
key: new core_crypto_1.DatabaseKey(keyNew.key),
|
|
72
|
+
deleteKey: keyNew.deleteKey,
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
const getCoreCryptoDbName = (storeEngine) => {
|
|
76
|
+
return `corecrypto-${storeEngine.storeName}`;
|
|
77
|
+
};
|
|
78
|
+
exports.getCoreCryptoDbName = getCoreCryptoDbName;
|
|
79
|
+
const wipeCoreCryptoDb = async (storeEngine) => {
|
|
80
|
+
const coreCryptoDbName = (0, exports.getCoreCryptoDbName)(storeEngine);
|
|
47
81
|
try {
|
|
48
|
-
|
|
82
|
+
await coreCryptoInstance?.close();
|
|
83
|
+
await (0, idb_1.deleteDB)(coreCryptoDbName);
|
|
84
|
+
logger.log('info', 'CoreCrypto DB wiped successfully');
|
|
49
85
|
}
|
|
50
86
|
catch (error) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
87
|
+
logger.error('error', 'Failed to wipe CoreCrypto DB');
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
exports.wipeCoreCryptoDb = wipeCoreCryptoDb;
|
|
91
|
+
let coreCryptoInstance;
|
|
92
|
+
async function buildClient(storeEngine, { generateSecretKey, nbPrekeys, onNewPrekeys }, { wasmFilePath }) {
|
|
93
|
+
return (
|
|
94
|
+
// We need to initialize the coreCrypto package with the path to the wasm file
|
|
95
|
+
// before we can use it. This is a one time operation and should be done
|
|
96
|
+
// before we create the CoreCrypto instance.
|
|
97
|
+
(0, core_crypto_1.initWasmModule)(wasmFilePath)
|
|
98
|
+
.then(async (output) => {
|
|
99
|
+
logger.log('info', 'CoreCrypto initialized', { output });
|
|
100
|
+
const coreCryptoDbName = (0, exports.getCoreCryptoDbName)(storeEngine);
|
|
101
|
+
// New key format used by coreCrypto
|
|
102
|
+
let key;
|
|
103
|
+
try {
|
|
104
|
+
key = await migrateOnceAndGetKey(generateSecretKey, coreCryptoDbName);
|
|
55
105
|
}
|
|
56
|
-
|
|
57
|
-
|
|
106
|
+
catch (error) {
|
|
107
|
+
if (error instanceof secretKeyGenerator_1.CorruptedKeyError) {
|
|
108
|
+
// If we are dealing with a corrupted key, we wipe the key and the coreCrypto DB to start fresh
|
|
109
|
+
await (0, exports.wipeCoreCryptoDb)(storeEngine);
|
|
110
|
+
key = await migrateOnceAndGetKey(generateSecretKey, coreCryptoDbName);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
throw error;
|
|
114
|
+
}
|
|
58
115
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
116
|
+
coreCryptoInstance = await core_crypto_1.CoreCrypto.deferredInit({
|
|
117
|
+
databaseName: coreCryptoDbName,
|
|
118
|
+
key: key.key,
|
|
119
|
+
});
|
|
120
|
+
(0, core_crypto_1.setLogger)(coreCryptoLogger);
|
|
121
|
+
(0, core_crypto_1.setMaxLogLevel)(core_crypto_1.CoreCryptoLogLevel.Info);
|
|
122
|
+
return new CoreCryptoWrapper(coreCryptoInstance, { nbPrekeys, onNewPrekeys, onWipe: key.deleteKey });
|
|
123
|
+
})
|
|
124
|
+
// if the coreCrypto initialization fails, can not use the crypto client and throw an error
|
|
125
|
+
.catch(async (error) => {
|
|
126
|
+
logger.error('error', 'CoreCrypto initialization failed', { error });
|
|
127
|
+
// If the initialization fails, we wipe the coreCrypto DB to start fresh
|
|
128
|
+
await (0, exports.wipeCoreCryptoDb)(storeEngine);
|
|
129
|
+
throw error;
|
|
130
|
+
}));
|
|
68
131
|
}
|
|
69
132
|
class CoreCryptoWrapper {
|
|
70
133
|
coreCrypto;
|
|
71
|
-
config;
|
|
72
134
|
prekeyTracker;
|
|
73
135
|
version;
|
|
74
136
|
constructor(coreCrypto, config) {
|
|
75
137
|
this.coreCrypto = coreCrypto;
|
|
76
|
-
this.
|
|
77
|
-
this.version = core_crypto_1.CoreCrypto.version();
|
|
138
|
+
this.version = (0, core_crypto_1.version)();
|
|
78
139
|
this.prekeyTracker = new PrekeysTracker_1.PrekeyTracker(this, config);
|
|
79
140
|
}
|
|
80
141
|
getNativeClient() {
|
|
81
142
|
return this.coreCrypto;
|
|
82
143
|
}
|
|
83
144
|
encrypt(sessions, plainText) {
|
|
84
|
-
return this.coreCrypto.proteusEncryptBatched(sessions, plainText);
|
|
145
|
+
return this.coreCrypto.transaction(cx => cx.proteusEncryptBatched(sessions, plainText));
|
|
85
146
|
}
|
|
86
147
|
decrypt(sessionId, message) {
|
|
87
|
-
return this.coreCrypto.proteusDecrypt(sessionId, message);
|
|
148
|
+
return this.coreCrypto.transaction(cx => cx.proteusDecrypt(sessionId, message));
|
|
88
149
|
}
|
|
89
150
|
init(nbInitialPrekeys) {
|
|
90
151
|
if (nbInitialPrekeys) {
|
|
91
152
|
this.prekeyTracker.setInitialState(nbInitialPrekeys);
|
|
92
153
|
}
|
|
93
|
-
return this.coreCrypto.proteusInit();
|
|
154
|
+
return this.coreCrypto.transaction(cx => cx.proteusInit());
|
|
94
155
|
}
|
|
95
156
|
async create(nbPrekeys, entropy) {
|
|
96
157
|
if (entropy) {
|
|
@@ -101,7 +162,7 @@ class CoreCryptoWrapper {
|
|
|
101
162
|
for (let id = 0; id < nbPrekeys; id++) {
|
|
102
163
|
prekeys.push(await this.newPrekey());
|
|
103
164
|
}
|
|
104
|
-
const lastPrekeyBytes = await this.coreCrypto.proteusLastResortPrekey();
|
|
165
|
+
const lastPrekeyBytes = await this.coreCrypto.transaction(cx => cx.proteusLastResortPrekey());
|
|
105
166
|
const lastPrekey = bazinga64_1.Encoder.toBase64(lastPrekeyBytes).asString;
|
|
106
167
|
const lastPrekeyId = core_crypto_1.CoreCrypto.proteusLastResortPrekeyId();
|
|
107
168
|
return {
|
|
@@ -109,6 +170,9 @@ class CoreCryptoWrapper {
|
|
|
109
170
|
lastPrekey: { id: lastPrekeyId, key: lastPrekey },
|
|
110
171
|
};
|
|
111
172
|
}
|
|
173
|
+
setMaxLogLevel(level) {
|
|
174
|
+
(0, core_crypto_1.setMaxLogLevel)(level);
|
|
175
|
+
}
|
|
112
176
|
getFingerprint() {
|
|
113
177
|
return this.coreCrypto.proteusFingerprint();
|
|
114
178
|
}
|
|
@@ -117,25 +181,25 @@ class CoreCryptoWrapper {
|
|
|
117
181
|
}
|
|
118
182
|
async sessionFromMessage(sessionId, message) {
|
|
119
183
|
await this.consumePrekey(); // we need to mark a prekey as consumed since if we create a session from a message, it means the sender has consumed one of our prekeys
|
|
120
|
-
return this.coreCrypto.proteusSessionFromMessage(sessionId, message);
|
|
184
|
+
return this.coreCrypto.transaction(cx => cx.proteusSessionFromMessage(sessionId, message));
|
|
121
185
|
}
|
|
122
186
|
sessionFromPrekey(sessionId, prekey) {
|
|
123
|
-
return this.coreCrypto.proteusSessionFromPrekey(sessionId, prekey);
|
|
187
|
+
return this.coreCrypto.transaction(cx => cx.proteusSessionFromPrekey(sessionId, prekey));
|
|
124
188
|
}
|
|
125
189
|
sessionExists(sessionId) {
|
|
126
190
|
return this.coreCrypto.proteusSessionExists(sessionId);
|
|
127
191
|
}
|
|
128
192
|
saveSession(sessionId) {
|
|
129
|
-
return this.coreCrypto.proteusSessionSave(sessionId);
|
|
193
|
+
return this.coreCrypto.transaction(cx => cx.proteusSessionSave(sessionId));
|
|
130
194
|
}
|
|
131
195
|
deleteSession(sessionId) {
|
|
132
|
-
return this.coreCrypto.proteusSessionDelete(sessionId);
|
|
196
|
+
return this.coreCrypto.transaction(cx => cx.proteusSessionDelete(sessionId));
|
|
133
197
|
}
|
|
134
198
|
consumePrekey() {
|
|
135
199
|
return this.prekeyTracker.consumePrekey();
|
|
136
200
|
}
|
|
137
201
|
async newPrekey() {
|
|
138
|
-
const { id, pkb } = await this.coreCrypto.proteusNewPrekeyAuto();
|
|
202
|
+
const { id, pkb } = await this.coreCrypto.transaction(cx => cx.proteusNewPrekeyAuto());
|
|
139
203
|
return { id, key: bazinga64_1.Encoder.toBase64(pkb).asString };
|
|
140
204
|
}
|
|
141
205
|
async debugBreakSession(sessionId) {
|
|
@@ -145,36 +209,7 @@ class CoreCryptoWrapper {
|
|
|
145
209
|
200, 16, 166, 184, 70, 21, 81, 43, 80, 21, 231, 182, 142, 51, 220, 131, 162, 11, 255, 162, 74, 78, 162, 95, 156,
|
|
146
210
|
131, 48, 203, 5, 77, 122, 4, 246,
|
|
147
211
|
];
|
|
148
|
-
await this.coreCrypto.proteusSessionFromPrekey(sessionId, Uint8Array.from(fakePrekey));
|
|
149
|
-
}
|
|
150
|
-
async debugResetIdentity() {
|
|
151
|
-
await this.coreCrypto.wipe();
|
|
152
|
-
}
|
|
153
|
-
async migrateFromCryptobox(dbName) {
|
|
154
|
-
return this.coreCrypto.proteusCryptoboxMigrate(dbName);
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Will call the callback once corecrypto is ready.
|
|
158
|
-
* @param callback - Function to be called once corecrypto is ready.
|
|
159
|
-
* @see https://github.com/wireapp/wire-web-packages/pull/4972
|
|
160
|
-
*/
|
|
161
|
-
onReady(callback) {
|
|
162
|
-
if (!this.coreCrypto.isLocked()) {
|
|
163
|
-
return callback();
|
|
164
|
-
}
|
|
165
|
-
return new Promise(resolve => {
|
|
166
|
-
const intervalId = setInterval(async () => {
|
|
167
|
-
if (!this.coreCrypto.isLocked()) {
|
|
168
|
-
clearInterval(intervalId);
|
|
169
|
-
await callback();
|
|
170
|
-
return resolve();
|
|
171
|
-
}
|
|
172
|
-
}, 100);
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
async wipe() {
|
|
176
|
-
await this.config.onWipe();
|
|
177
|
-
await this.onReady(() => this.coreCrypto.wipe());
|
|
212
|
+
await this.coreCrypto.transaction(cx => cx.proteusSessionFromPrekey(sessionId, Uint8Array.from(fakePrekey)));
|
|
178
213
|
}
|
|
179
214
|
}
|
|
180
215
|
exports.CoreCryptoWrapper = CoreCryptoWrapper;
|
|
@@ -30,11 +30,5 @@ export interface CryptoClient<T = unknown> {
|
|
|
30
30
|
deleteSession(sessionId: string): Promise<void>;
|
|
31
31
|
newPrekey(): Promise<PreKey>;
|
|
32
32
|
debugBreakSession(sessionId: string): void;
|
|
33
|
-
debugResetIdentity(): Promise<void>;
|
|
34
|
-
/**
|
|
35
|
-
* Will migrate the database from a different client type
|
|
36
|
-
*/
|
|
37
|
-
migrateFromCryptobox?(dbName: string): Promise<void>;
|
|
38
|
-
wipe(): Promise<void>;
|
|
39
33
|
}
|
|
40
34
|
//# sourceMappingURL=CryptoClient.types.d.ts.map
|
package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CryptoClient.types.d.ts","sourceRoot":"","sources":["../../../../../src/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.types.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,MAAM,EAAC,MAAM,8BAA8B,CAAC;AAEpD,MAAM,MAAM,cAAc,GAAG;IAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAC,CAAC;AAErE,oBAAY,gBAAgB;IAC1B,WAAW,IAAA;IACX,SAAS,IAAA;CACV;AAED,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,OAAO;IACvC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,eAAe,IAAI,CAAC,CAAC;IACrB,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IACrF,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAErE;;OAEG;IACH,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvC;;OAEG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IACzE,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAClC,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACzD,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAChF,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxE,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACnD,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,aAAa,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7B,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"CryptoClient.types.d.ts","sourceRoot":"","sources":["../../../../../src/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.types.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,MAAM,EAAC,MAAM,8BAA8B,CAAC;AAEpD,MAAM,MAAM,cAAc,GAAG;IAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAC,CAAC;AAErE,oBAAY,gBAAgB;IAC1B,WAAW,IAAA;IACX,SAAS,IAAA;CACV;AAED,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,OAAO;IACvC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,eAAe,IAAI,CAAC,CAAC;IACrB,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IACrF,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAErE;;OAEG;IACH,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvC;;OAEG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IACzE,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAClC,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACzD,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAChF,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxE,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACnD,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,aAAa,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7B,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5C"}
|
|
@@ -8,15 +8,10 @@ export declare const ProteusErrors: {
|
|
|
8
8
|
readonly DuplicateMessage: 209;
|
|
9
9
|
readonly Unknown: 999;
|
|
10
10
|
};
|
|
11
|
-
export declare const CORE_CRYPTO_PROTEUS_ERROR_NAMES: {
|
|
12
|
-
ProteusErrorSessionNotFound: string;
|
|
13
|
-
ProteusErrorRemoteIdentityChanged: string;
|
|
14
|
-
ProteusErrorDuplicateMessage: string;
|
|
15
|
-
};
|
|
16
11
|
type SenderInfo = {
|
|
17
12
|
clientId: string;
|
|
18
13
|
userId: QualifiedId;
|
|
19
14
|
};
|
|
20
|
-
export declare const generateDecryptionError: (senderInfo: SenderInfo, error:
|
|
15
|
+
export declare const generateDecryptionError: (senderInfo: SenderInfo, error: unknown) => DecryptionError;
|
|
21
16
|
export {};
|
|
22
17
|
//# sourceMappingURL=DecryptionErrorGenerator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DecryptionErrorGenerator.d.ts","sourceRoot":"","sources":["../../../../../src/messagingProtocols/proteus/ProteusService/DecryptionErrorGenerator/DecryptionErrorGenerator.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"DecryptionErrorGenerator.d.ts","sourceRoot":"","sources":["../../../../../src/messagingProtocols/proteus/ProteusService/DecryptionErrorGenerator/DecryptionErrorGenerator.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAUzD,OAAO,EAAC,eAAe,EAAC,MAAM,oCAAoC,CAAC;AAEnE,eAAO,MAAM,aAAa;;;;;;;CAOhB,CAAC;AAUX,KAAK,UAAU,GAAG;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,WAAW,CAAA;CAAC,CAAC;AA8B1D,eAAO,MAAM,uBAAuB,eAAgB,UAAU,SAAS,OAAO,KAAG,eAWhF,CAAC"}
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.generateDecryptionError = exports.
|
|
21
|
+
exports.generateDecryptionError = exports.ProteusErrors = void 0;
|
|
22
|
+
const core_crypto_1 = require("@wireapp/core-crypto");
|
|
22
23
|
const DecryptionError_1 = require("../../../../errors/DecryptionError");
|
|
23
24
|
exports.ProteusErrors = {
|
|
24
25
|
SessionNotFound: 102,
|
|
@@ -28,40 +29,36 @@ exports.ProteusErrors = {
|
|
|
28
29
|
DuplicateMessage: 209,
|
|
29
30
|
Unknown: 999,
|
|
30
31
|
};
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
};
|
|
34
|
-
const isCryptoboxError = (error) => {
|
|
35
|
-
return 'code' in error;
|
|
36
|
-
};
|
|
37
|
-
exports.CORE_CRYPTO_PROTEUS_ERROR_NAMES = {
|
|
38
|
-
ProteusErrorSessionNotFound: 'ProteusErrorSessionNotFound',
|
|
39
|
-
ProteusErrorRemoteIdentityChanged: 'ProteusErrorRemoteIdentityChanged',
|
|
40
|
-
ProteusErrorDuplicateMessage: 'ProteusErrorDuplicateMessage',
|
|
41
|
-
};
|
|
32
|
+
const isCryptoboxError = (error) => typeof error?.code === 'number';
|
|
33
|
+
const hasProteusErrorCode = (error) => typeof error?.proteusErrorCode === 'number';
|
|
42
34
|
function getErrorCode(error) {
|
|
43
|
-
if (
|
|
44
|
-
return error.proteusErrorCode;
|
|
45
|
-
}
|
|
46
|
-
if (isCryptoboxError(error) && typeof error.code === 'number') {
|
|
47
|
-
return error.code;
|
|
48
|
-
}
|
|
49
|
-
if (error.name === exports.CORE_CRYPTO_PROTEUS_ERROR_NAMES.ProteusErrorSessionNotFound) {
|
|
35
|
+
if ((0, core_crypto_1.isProteusSessionNotFoundError)(error)) {
|
|
50
36
|
return exports.ProteusErrors.SessionNotFound;
|
|
51
37
|
}
|
|
52
|
-
if (
|
|
38
|
+
if ((0, core_crypto_1.isProteusRemoteIdentityChangedError)(error)) {
|
|
53
39
|
return exports.ProteusErrors.RemoteIdentityChanged;
|
|
54
40
|
}
|
|
55
|
-
if (
|
|
41
|
+
if ((0, core_crypto_1.isProteusDuplicateMessageError)(error)) {
|
|
56
42
|
return exports.ProteusErrors.DuplicateMessage;
|
|
57
43
|
}
|
|
44
|
+
if ((0, core_crypto_1.isProteusError)(error, core_crypto_1.ProteusErrorType.Other)) {
|
|
45
|
+
return exports.ProteusErrors.Unknown;
|
|
46
|
+
}
|
|
47
|
+
if (hasProteusErrorCode(error)) {
|
|
48
|
+
return error.proteusErrorCode;
|
|
49
|
+
}
|
|
50
|
+
if (isCryptoboxError(error)) {
|
|
51
|
+
return error.code;
|
|
52
|
+
}
|
|
58
53
|
return exports.ProteusErrors.Unknown;
|
|
59
54
|
}
|
|
60
55
|
const generateDecryptionError = (senderInfo, error) => {
|
|
61
56
|
const { clientId, userId } = senderInfo;
|
|
62
57
|
const sender = `${userId.id} (${clientId})`;
|
|
63
58
|
const code = getErrorCode(error);
|
|
64
|
-
const
|
|
59
|
+
const name = error?.name;
|
|
60
|
+
const text = error?.message ?? String(error);
|
|
61
|
+
const message = `Decryption error from ${sender} (name: ${name}) (message: ${text})`;
|
|
65
62
|
return new DecryptionError_1.DecryptionError(message, code);
|
|
66
63
|
};
|
|
67
64
|
exports.generateDecryptionError = generateDecryptionError;
|
|
@@ -20,11 +20,13 @@ export declare class ProteusService {
|
|
|
20
20
|
private readonly apiClient;
|
|
21
21
|
private readonly cryptoClient;
|
|
22
22
|
private readonly config;
|
|
23
|
+
private readonly storeEngine;
|
|
23
24
|
private readonly messageService;
|
|
24
25
|
private readonly logger;
|
|
25
|
-
|
|
26
|
+
private readonly dbName;
|
|
27
|
+
constructor(apiClient: APIClient, cryptoClient: CryptoClient, config: ProteusServiceConfig, storeEngine: CRUDEngine);
|
|
26
28
|
handleOtrMessageAddEvent(event: ConversationOtrMessageAddEvent): Promise<HandledEventPayload>;
|
|
27
|
-
initClient(
|
|
29
|
+
initClient(context: Context): Promise<void>;
|
|
28
30
|
createClient(entropy?: Uint8Array): Promise<import("./CryptoClient").InitialPrekeys>;
|
|
29
31
|
/**
|
|
30
32
|
* Get the fingerprint of the local client.
|
|
@@ -50,6 +52,6 @@ export declare class ProteusService {
|
|
|
50
52
|
consumePrekey(): Promise<void>;
|
|
51
53
|
deleteSession(userId: QualifiedId, clientId: string): Promise<void>;
|
|
52
54
|
encrypt(plainText: Uint8Array, recipients: QualifiedUserPreKeyBundleMap | QualifiedUserClients): Promise<EncryptionResult>;
|
|
53
|
-
wipe(
|
|
55
|
+
wipe(): Promise<void>;
|
|
54
56
|
}
|
|
55
57
|
//# sourceMappingURL=ProteusService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProteusService.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/ProteusService/ProteusService.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,mCAAmC,CAAC;AACjE,OAAO,KAAK,EAAC,MAAM,EAAE,OAAO,EAAC,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAGL,eAAe,EACf,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAC,8BAA8B,EAAC,MAAM,+BAA+B,CAAC;AAClF,OAAO,KAAK,EAAC,WAAW,EAAE,4BAA4B,EAAC,MAAM,8BAA8B,CAAC;AAG5F,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAI5C,OAAO,KAAK,EACV,mCAAmC,EACnC,oBAAoB,EACpB,wBAAwB,EACzB,MAAM,wBAAwB,CAAC;AAIhC,OAAO,EAEL,iCAAiC,EAEjC,UAAU,EACV,uBAAuB,EACxB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAY1D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,wEAAwE;IACxE,QAAQ,EAAE,sBAAsB,CAAC;IACjC,wEAAwE;IACxE,QAAQ,CAAC,EAAE,oBAAoB,CAAC;IAChC,sGAAsG;IACtG,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;CACxB,CAAC;AAEF,qBAAa,cAAc;
|
|
1
|
+
{"version":3,"file":"ProteusService.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/ProteusService/ProteusService.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,mCAAmC,CAAC;AACjE,OAAO,KAAK,EAAC,MAAM,EAAE,OAAO,EAAC,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAGL,eAAe,EACf,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAC,8BAA8B,EAAC,MAAM,+BAA+B,CAAC;AAClF,OAAO,KAAK,EAAC,WAAW,EAAE,4BAA4B,EAAC,MAAM,8BAA8B,CAAC;AAG5F,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAI5C,OAAO,KAAK,EACV,mCAAmC,EACnC,oBAAoB,EACpB,wBAAwB,EACzB,MAAM,wBAAwB,CAAC;AAIhC,OAAO,EAEL,iCAAiC,EAEjC,UAAU,EACV,uBAAuB,EACxB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAY1D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,wEAAwE;IACxE,QAAQ,EAAE,sBAAsB,CAAC;IACjC,wEAAwE;IACxE,QAAQ,CAAC,EAAE,oBAAoB,CAAC;IAChC,sGAAsG;IACtG,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;CACxB,CAAC;AAEF,qBAAa,cAAc;IAMvB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAR9B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;IAChD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwD;IAC/E,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBAGb,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,oBAAoB,EAC5B,WAAW,EAAE,UAAU;IAM7B,wBAAwB,CAAC,KAAK,EAAE,8BAA8B,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAO7F,UAAU,CAAC,OAAO,EAAE,OAAO;IAgBjC,YAAY,CAAC,OAAO,CAAC,EAAE,UAAU;IAIxC;;OAEG;IACI,mBAAmB;IAInB,kBAAkB,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;IAIxE;;;;;;OAMG;IACU,oBAAoB,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IAQ3E,kBAAkB,CAAC,gBAAgB,EAAE,eAAe,GAAG,OAAO,CAAC,iCAAiC,CAAC;IAwC9G;;;OAGG;IACU,sBAAsB,CAAC,EAClC,cAAc,EACd,cAAc,GACf,EAAE,mCAAmC,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAoD5D,WAAW,CAAC,EACvB,OAAO,EACP,cAAc,EACd,UAAU,EACV,UAAU,EACV,OAAO,EACP,gBAAgB,GACjB,EAAE,wBAAwB,GAAG,OAAO,CAAC,UAAU,CAAC;IA6CpC,OAAO,CAAC,aAAa,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM;IAuB9E,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM;IAQ7C,OAAO,CAClB,SAAS,EAAE,UAAU,EACrB,UAAU,EAAE,4BAA4B,GAAG,oBAAoB,GAC9D,OAAO,CAAC,gBAAgB,CAAC;IAiBtB,IAAI;CAGX"}
|
|
@@ -37,13 +37,17 @@ class ProteusService {
|
|
|
37
37
|
apiClient;
|
|
38
38
|
cryptoClient;
|
|
39
39
|
config;
|
|
40
|
+
storeEngine;
|
|
40
41
|
messageService;
|
|
41
42
|
logger = commons_1.LogFactory.getLogger('@wireapp/core/ProteusService');
|
|
42
|
-
|
|
43
|
+
dbName;
|
|
44
|
+
constructor(apiClient, cryptoClient, config, storeEngine) {
|
|
43
45
|
this.apiClient = apiClient;
|
|
44
46
|
this.cryptoClient = cryptoClient;
|
|
45
47
|
this.config = config;
|
|
48
|
+
this.storeEngine = storeEngine;
|
|
46
49
|
this.messageService = new MessageService_1.MessageService(this.apiClient, this);
|
|
50
|
+
this.dbName = storeEngine.storeName;
|
|
47
51
|
}
|
|
48
52
|
async handleOtrMessageAddEvent(event) {
|
|
49
53
|
return (0, events_1.handleOtrMessageAdd)({
|
|
@@ -51,30 +55,16 @@ class ProteusService {
|
|
|
51
55
|
proteusService: this,
|
|
52
56
|
});
|
|
53
57
|
}
|
|
54
|
-
async initClient(
|
|
55
|
-
const dbName = storeEngine.storeName;
|
|
58
|
+
async initClient(context) {
|
|
56
59
|
if (context.domain) {
|
|
57
60
|
// We want sessions to be fully qualified from now on
|
|
58
|
-
if (!cryptoMigrationStateStore_1.cryptoMigrationStore.qualifiedSessions.isReady(dbName)) {
|
|
61
|
+
if (!cryptoMigrationStateStore_1.cryptoMigrationStore.qualifiedSessions.isReady(this.dbName)) {
|
|
59
62
|
this.logger.info(`Migrating existing session ids to qualified ids.`);
|
|
60
|
-
await (0, sessionIdMigrator_1.migrateToQualifiedSessionIds)(storeEngine, context.domain);
|
|
61
|
-
cryptoMigrationStateStore_1.cryptoMigrationStore.qualifiedSessions.markAsReady(dbName);
|
|
63
|
+
await (0, sessionIdMigrator_1.migrateToQualifiedSessionIds)(this.storeEngine, context.domain);
|
|
64
|
+
cryptoMigrationStateStore_1.cryptoMigrationStore.qualifiedSessions.markAsReady(this.dbName);
|
|
62
65
|
this.logger.info(`Successfully migrated session ids to qualified ids.`);
|
|
63
66
|
}
|
|
64
67
|
}
|
|
65
|
-
if (!cryptoMigrationStateStore_1.cryptoMigrationStore.coreCrypto.isReady(dbName) && this.cryptoClient.migrateFromCryptobox) {
|
|
66
|
-
this.logger.info(`Migrating from cryptobox to corecrypto.`);
|
|
67
|
-
try {
|
|
68
|
-
const startTime = Date.now();
|
|
69
|
-
await this.cryptoClient.migrateFromCryptobox(dbName);
|
|
70
|
-
cryptoMigrationStateStore_1.cryptoMigrationStore.coreCrypto.markAsReady(dbName);
|
|
71
|
-
this.logger.info(`Successfully migrated from cryptobox to corecrypto (took ${Date.now() - startTime}ms).`);
|
|
72
|
-
}
|
|
73
|
-
catch (error) {
|
|
74
|
-
this.logger.error('Client was not able to perform DB migration: ', error);
|
|
75
|
-
throw error;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
68
|
const backendPrekeys = await this.apiClient.api.client.getClientPreKeys(context.clientId ?? '');
|
|
79
69
|
const totalUsableBackedPrekeys = backendPrekeys.length - 1; // we remove the last resort prekey from the total number of available prekeys
|
|
80
70
|
return this.cryptoClient.init(totalUsableBackedPrekeys);
|
|
@@ -271,11 +261,8 @@ class ProteusService {
|
|
|
271
261
|
failed,
|
|
272
262
|
};
|
|
273
263
|
}
|
|
274
|
-
async wipe(
|
|
275
|
-
|
|
276
|
-
await (0, identityClearer_1.deleteIdentity)(storeEngine);
|
|
277
|
-
}
|
|
278
|
-
return this.cryptoClient.wipe();
|
|
264
|
+
async wipe() {
|
|
265
|
+
await (0, identityClearer_1.deleteIdentity)(this.storeEngine);
|
|
279
266
|
}
|
|
280
267
|
}
|
|
281
268
|
exports.ProteusService = ProteusService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProteusService.mocks.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/ProteusService/ProteusService.mocks.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"ProteusService.mocks.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/ProteusService/ProteusService.mocks.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAOhD,eAAO,MAAM,mBAAmB,QAAa,OAAO,CAClD,CAAC,cAAc,EAAE;IAAC,SAAS,EAAE,SAAS,CAAC;IAAC,YAAY,EAAE,YAAY,CAAA;CAAC,CAAC,CAyBrE,CAAC;AAEF,eAAO,MAAM,0BAA0B,YAGtC,CAAC"}
|
|
@@ -18,23 +18,32 @@
|
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.buildProteusService = void 0;
|
|
21
|
+
exports.cleanupProteusServiceMocks = exports.buildProteusService = void 0;
|
|
22
22
|
const client_1 = require("@wireapp/api-client/lib/client");
|
|
23
23
|
const api_client_1 = require("@wireapp/api-client");
|
|
24
24
|
const CoreCryptoWrapper_1 = require("./CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper");
|
|
25
25
|
const ProteusService_1 = require("./ProteusService");
|
|
26
26
|
const PayloadHelper_1 = require("../../../test/PayloadHelper");
|
|
27
|
+
const StoreHelper_1 = require("../../../test/StoreHelper");
|
|
28
|
+
const createdApiClients = [];
|
|
27
29
|
const buildProteusService = async () => {
|
|
28
30
|
const apiClient = new api_client_1.APIClient({ urls: api_client_1.APIClient.BACKEND.STAGING });
|
|
31
|
+
createdApiClients.push(apiClient);
|
|
29
32
|
apiClient.context = {
|
|
30
33
|
clientType: client_1.ClientType.NONE,
|
|
31
34
|
userId: (0, PayloadHelper_1.getUUID)(),
|
|
32
35
|
clientId: (0, PayloadHelper_1.getUUID)(),
|
|
33
36
|
};
|
|
34
37
|
const cryptoClient = new CoreCryptoWrapper_1.CoreCryptoWrapper({}, {});
|
|
38
|
+
const storeEngine = await (0, StoreHelper_1.createMemoryEngine)('proteus-service-test');
|
|
35
39
|
const proteusService = new ProteusService_1.ProteusService(apiClient, cryptoClient, {
|
|
36
40
|
nbPrekeys: 0,
|
|
37
|
-
});
|
|
41
|
+
}, storeEngine);
|
|
38
42
|
return [proteusService, { apiClient, cryptoClient }];
|
|
39
43
|
};
|
|
40
44
|
exports.buildProteusService = buildProteusService;
|
|
45
|
+
const cleanupProteusServiceMocks = () => {
|
|
46
|
+
createdApiClients.forEach(client => client.disconnect());
|
|
47
|
+
createdApiClients.length = 0;
|
|
48
|
+
};
|
|
49
|
+
exports.cleanupProteusServiceMocks = cleanupProteusServiceMocks;
|