@wireapp/core 28.7.1 → 29.0.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 +32 -0
- package/package.json +5 -5
- package/src/main/conversation/{AssetService.d.ts → AssetService/AssetService.d.ts} +1 -1
- package/src/main/conversation/{AssetService.js → AssetService/AssetService.js} +1 -1
- package/src/main/conversation/AssetService/index.d.ts +1 -0
- package/src/main/conversation/AssetService/index.js +32 -0
- package/src/main/conversation/{ConversationMapper.d.ts → ConversationMapper/ConversationMapper.d.ts} +1 -1
- package/src/main/conversation/{ConversationMapper.js → ConversationMapper/ConversationMapper.js} +2 -2
- package/src/main/conversation/ConversationMapper/index.d.ts +1 -0
- package/src/main/conversation/ConversationMapper/index.js +32 -0
- package/src/main/conversation/{ConversationService.d.ts → ConversationService/ConversationService.d.ts} +10 -89
- package/src/main/conversation/{ConversationService.js → ConversationService/ConversationService.js} +28 -27
- package/src/main/conversation/ConversationService/ConversationService.types.d.ts +94 -0
- package/src/main/conversation/ConversationService/ConversationService.types.js +28 -0
- package/src/main/conversation/ConversationService/index.d.ts +2 -0
- package/src/main/conversation/ConversationService/index.js +33 -0
- package/src/main/conversation/{MessageTimer.d.ts → MessageTimer/MessageTimer.d.ts} +0 -0
- package/src/main/conversation/{MessageTimer.js → MessageTimer/MessageTimer.js} +0 -0
- package/src/main/conversation/MessageTimer/index.d.ts +1 -0
- package/src/main/conversation/MessageTimer/index.js +32 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,38 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [29.0.2](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@29.0.1...@wireapp/core@29.0.2) (2022-07-25)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @wireapp/core
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [29.0.1](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@29.0.0...@wireapp/core@29.0.1) (2022-07-25)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @wireapp/core
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# [29.0.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@28.7.1...@wireapp/core@29.0.0) (2022-07-22)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* **core:** prepare conversationService addUsers() for MLS and Proteus Versions, clean up code, fix scripts (FS-815) ([#4339](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4339)) ([8f1aeec](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/8f1aeecf3391052ca741419577e1e11a393eab39))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### BREAKING CHANGES
|
|
31
|
+
|
|
32
|
+
* **core:** * The addUser() function in ConversationService.ts has been renamed to addUsers(), and its API changed in preparation for the MLS and Proteus split.
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
6
38
|
## [28.7.1](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@28.7.0...@wireapp/core@28.7.1) (2022-07-20)
|
|
7
39
|
|
|
8
40
|
**Note:** Version bump only for package @wireapp/core
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"@otak/core-crypto": "0.3.0-beta-2",
|
|
8
8
|
"@types/long": "4.0.1",
|
|
9
9
|
"@types/node": "~14",
|
|
10
|
-
"@wireapp/api-client": "19.17.
|
|
10
|
+
"@wireapp/api-client": "19.17.2",
|
|
11
11
|
"@wireapp/commons": "4.3.0",
|
|
12
12
|
"@wireapp/cryptobox": "12.8.0",
|
|
13
13
|
"@wireapp/store-engine-dexie": "1.6.10",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"build": "yarn build:node && yarn build:browser",
|
|
64
64
|
"build:browser": "webpack --progress",
|
|
65
65
|
"build:node": "tsc",
|
|
66
|
-
"clean": "rimraf .tmp \"src/main/{!(*.test*).js,*.js.map,*.d.ts}\" \"src/main/test/{*.js.map,*.d.ts}\" \"src/main/!(test)/{!(*.test*).js,*.js.map,*.d.ts}\"",
|
|
66
|
+
"clean": "rimraf .tmp \"src/main/{!(*.test*).js,*.js.map,*.d.ts}\" \"src/main/test/{*.js.map,*.d.ts}\" \"src/main/!(test)/{!(*.test*).js,*.js.map,*.d.ts}\" \"src/main/**/{!(*.test*|AccountHelper|StoreHelper).js,*.js.map,*.d.ts}\" \"src/main/**/*.node.js\"",
|
|
67
67
|
"coverage": "cross-env JASMINE_CONFIG_PATH=src/test/node/support/jasmine.json istanbul cover --report html ../../node_modules/jasmine/bin/jasmine.js",
|
|
68
68
|
"demo:composite": "cross-env NODE_DEBUG=@wireapp* ts-node src/demo/composite.ts",
|
|
69
69
|
"demo:sendCounter": "cross-env NODE_DEBUG=@wireapp* ts-node src/demo/sendCounter.ts",
|
|
@@ -71,12 +71,12 @@
|
|
|
71
71
|
"start": "yarn dist && node index.js",
|
|
72
72
|
"start:echo": "cross-env NODE_DEBUG=@wireapp/core* node src/demo/echo.js",
|
|
73
73
|
"start:sender": "cross-env NODE_DEBUG=@wireapp/core* node src/demo/sender.js",
|
|
74
|
-
"test": "yarn test:node && yarn test:browser",
|
|
74
|
+
"test": "yarn clean && yarn build && yarn test:node && yarn test:browser",
|
|
75
75
|
"test:browser": "webpack --mode=development && karma start",
|
|
76
76
|
"test:project": "yarn dist && yarn test",
|
|
77
77
|
"test:node": "nyc jasmine --config=jasmine.json",
|
|
78
78
|
"watch": "tsc ---watch"
|
|
79
79
|
},
|
|
80
|
-
"version": "
|
|
81
|
-
"gitHead": "
|
|
80
|
+
"version": "29.0.2",
|
|
81
|
+
"gitHead": "1ced13e856df4efbf53ae4be955db98ab7a25899"
|
|
82
82
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { APIClient } from '@wireapp/api-client';
|
|
3
3
|
import type { AssetOptions } from '@wireapp/api-client/src/asset';
|
|
4
4
|
import type { ProgressCallback, RequestCancelable } from '@wireapp/api-client/src/http';
|
|
5
|
-
import type { EncryptedAssetUploaded } from '
|
|
5
|
+
import type { EncryptedAssetUploaded } from '../../cryptography';
|
|
6
6
|
export interface AssetDataV4 {
|
|
7
7
|
assetKey: string;
|
|
8
8
|
assetToken: string;
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.AssetService = void 0;
|
|
22
|
-
const AssetCryptography_1 = require("
|
|
22
|
+
const AssetCryptography_1 = require("../../cryptography/AssetCryptography");
|
|
23
23
|
class AssetService {
|
|
24
24
|
constructor(apiClient) {
|
|
25
25
|
this.apiClient = apiClient;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AssetService';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Wire
|
|
4
|
+
* Copyright (C) 2022 Wire Swiss GmbH
|
|
5
|
+
*
|
|
6
|
+
* This program is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
* (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* This program is distributed in the hope that it will be useful,
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
* GNU General Public License for more details.
|
|
15
|
+
*
|
|
16
|
+
* You should have received a copy of the GNU General Public License
|
|
17
|
+
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
23
|
+
}) : (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
o[k2] = m[k];
|
|
26
|
+
}));
|
|
27
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
28
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
29
|
+
};
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
__exportStar(require("./AssetService"), exports);
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
package/src/main/conversation/{ConversationMapper.d.ts → ConversationMapper/ConversationMapper.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ConversationEvent } from '@wireapp/api-client/src/event';
|
|
2
|
-
import { PayloadBundle, PayloadBundleSource } from '
|
|
2
|
+
import { PayloadBundle, PayloadBundleSource } from '../message/PayloadBundle';
|
|
3
3
|
export declare class ConversationMapper {
|
|
4
4
|
static mapConversationEvent(event: ConversationEvent, source: PayloadBundleSource): PayloadBundle;
|
|
5
5
|
private static mapConversationEventType;
|
package/src/main/conversation/{ConversationMapper.js → ConversationMapper/ConversationMapper.js}
RENAMED
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.ConversationMapper = void 0;
|
|
22
22
|
const event_1 = require("@wireapp/api-client/src/event");
|
|
23
|
-
const MessageBuilder_1 = require("
|
|
24
|
-
const PayloadBundle_1 = require("
|
|
23
|
+
const MessageBuilder_1 = require("../message/MessageBuilder");
|
|
24
|
+
const PayloadBundle_1 = require("../message/PayloadBundle");
|
|
25
25
|
class ConversationMapper {
|
|
26
26
|
static mapConversationEvent(event, source) {
|
|
27
27
|
return {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ConversationMapper';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Wire
|
|
4
|
+
* Copyright (C) 2022 Wire Swiss GmbH
|
|
5
|
+
*
|
|
6
|
+
* This program is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
* (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* This program is distributed in the hope that it will be useful,
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
* GNU General Public License for more details.
|
|
15
|
+
*
|
|
16
|
+
* You should have received a copy of the GNU General Public License
|
|
17
|
+
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
23
|
+
}) : (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
o[k2] = m[k];
|
|
26
|
+
}));
|
|
27
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
28
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
29
|
+
};
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
__exportStar(require("./ConversationMapper"), exports);
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,95 +1,15 @@
|
|
|
1
1
|
import type { CoreCrypto } from '@otak/core-crypto';
|
|
2
2
|
import type { APIClient } from '@wireapp/api-client';
|
|
3
|
-
import { MessageSendingStatus, Conversation, DefaultConversationRoleName, MutedStatus, NewConversation, QualifiedUserClients, UserClients, ClientMismatch
|
|
3
|
+
import { MessageSendingStatus, Conversation, DefaultConversationRoleName, MutedStatus, NewConversation, QualifiedUserClients, UserClients, ClientMismatch } from '@wireapp/api-client/src/conversation';
|
|
4
4
|
import type { ConversationMemberLeaveEvent } from '@wireapp/api-client/src/event';
|
|
5
5
|
import type { QualifiedId, UserPreKeyBundleMap } from '@wireapp/api-client/src/user';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import type {
|
|
9
|
-
import type {
|
|
10
|
-
import type { ClearConversationMessage, DeleteMessage, HideMessage, OtrMessage } from './message/OtrMessage';
|
|
6
|
+
import { MessageTimer } from '../../conversation/';
|
|
7
|
+
import type { RemoteData } from '../../conversation/content/';
|
|
8
|
+
import type { CryptographyService } from '../../cryptography/';
|
|
9
|
+
import type { ClearConversationMessage, DeleteMessage, HideMessage, OtrMessage } from '../message/OtrMessage';
|
|
11
10
|
import { XOR } from '@wireapp/commons/src/main/util/TypeUtil';
|
|
12
|
-
import type { NotificationService } from '
|
|
13
|
-
|
|
14
|
-
NONE = 0,
|
|
15
|
-
USERS = 1,
|
|
16
|
-
USERS_CLIENTS = 2
|
|
17
|
-
}
|
|
18
|
-
interface SendCommonParams<T> {
|
|
19
|
-
/**
|
|
20
|
-
* The protocol to use to send the message (MLS or Proteus)
|
|
21
|
-
*/
|
|
22
|
-
protocol: ConversationProtocol;
|
|
23
|
-
/**
|
|
24
|
-
* The message to send to the conversation
|
|
25
|
-
*/
|
|
26
|
-
payload: T;
|
|
27
|
-
onStart?: (message: GenericMessage) => void | boolean | Promise<boolean>;
|
|
28
|
-
onSuccess?: (message: GenericMessage, sentTime?: string) => void;
|
|
29
|
-
}
|
|
30
|
-
declare type SendProteusMessageParams<T> = SendCommonParams<T> & MessageSendingOptions & {
|
|
31
|
-
/**
|
|
32
|
-
* Can be either a QualifiedId[], string[], UserClients or QualfiedUserClients. The type has some effect on the behavior of the method. (Needed only for Proteus)
|
|
33
|
-
* When given a QualifiedId[] or string[] the method will fetch the freshest list of devices for those users (since they are not given by the consumer). As a consequence no ClientMismatch error will trigger and we will ignore missing clients when sending
|
|
34
|
-
* When given a QualifiedUserClients or UserClients the method will only send to the clients listed in the userIds. This could lead to ClientMismatch (since the given list of devices might not be the freshest one and new clients could have been created)
|
|
35
|
-
* When given a QualifiedId[] or QualifiedUserClients the method will send the message through the federated API endpoint
|
|
36
|
-
* When given a string[] or UserClients the method will send the message through the old API endpoint
|
|
37
|
-
*/
|
|
38
|
-
userIds?: string[] | QualifiedId[] | UserClients | QualifiedUserClients;
|
|
39
|
-
onClientMismatch?: (status: ClientMismatch | MessageSendingStatus, wasSent: boolean) => void | boolean | Promise<boolean>;
|
|
40
|
-
};
|
|
41
|
-
declare type SendMlsMessageParams<T> = SendCommonParams<T> & {
|
|
42
|
-
/**
|
|
43
|
-
* The groupId of the conversation to send the message to (Needed only for MLS)
|
|
44
|
-
*/
|
|
45
|
-
groupId: string;
|
|
46
|
-
};
|
|
47
|
-
interface MessageSendingOptions {
|
|
48
|
-
/**
|
|
49
|
-
* The federated domain the server runs on. Should only be set for federation enabled envs
|
|
50
|
-
*/
|
|
51
|
-
conversationDomain?: string;
|
|
52
|
-
/**
|
|
53
|
-
* can be either a QualifiedId[] or QualfiedUserClients or undefined. The type has some effect on the behavior of the method.
|
|
54
|
-
* When given undefined the method will fetch both the members of the conversations and their devices. No ClientMismatch can happen in that case
|
|
55
|
-
* When given a QualifiedId[] the method will fetch the freshest list of devices for those users (since they are not given by the consumer). As a consequence no ClientMismatch error will trigger and we will ignore missing clients when sending
|
|
56
|
-
* When given a QualifiedUserClients the method will only send to the clients listed in the userIds. This could lead to ClientMismatch (since the given list of devices might not be the freshest one and new clients could have been created)
|
|
57
|
-
*/
|
|
58
|
-
userIds?: string[] | QualifiedId[] | UserClients | QualifiedUserClients;
|
|
59
|
-
/**
|
|
60
|
-
* Will send the message as a protobuf payload
|
|
61
|
-
*/
|
|
62
|
-
sendAsProtobuf?: boolean;
|
|
63
|
-
nativePush?: boolean;
|
|
64
|
-
/**
|
|
65
|
-
* Will be called whenever there is a clientmismatch returned from the server. Needs to be combined with a userIds of type QualifiedUserClients
|
|
66
|
-
*/
|
|
67
|
-
onClientMismatch?: MessageSendingCallbacks['onClientMismatch'];
|
|
68
|
-
/**
|
|
69
|
-
* Defines the behavior to use when a mismatch happens on backend side:
|
|
70
|
-
* - NONE -> Not a targetted message, we want to send to all the users/clients in the conversation. Will report all missing users and clients (default mode)
|
|
71
|
-
* - USERS -> A message targetted to all the clients of the given users (according to params.userIds). Will ignore missing users and only report missing clients for the given params.userIds
|
|
72
|
-
* - USERS_CLIENTS -> A message targetted at some specific clients of specific users (according to params.userIds). Will force sending the message even if users or clients are missing
|
|
73
|
-
*/
|
|
74
|
-
targetMode?: MessageTargetMode;
|
|
75
|
-
}
|
|
76
|
-
export interface MessageSendingCallbacks {
|
|
77
|
-
/**
|
|
78
|
-
* Will be called before a message is actually sent. Returning 'false' will prevent the message from being sent
|
|
79
|
-
* @param message The message being sent
|
|
80
|
-
* @return true or undefined if the message should be sent, false if the message sending should be cancelled
|
|
81
|
-
*/
|
|
82
|
-
onStart?: (message: GenericMessage) => void | boolean | Promise<boolean>;
|
|
83
|
-
onSuccess?: (message: GenericMessage, sentTime?: string) => void;
|
|
84
|
-
/**
|
|
85
|
-
* Called whenever there is a clientmismatch returned from the server. Will also indicate the sending status of the message (if it was already sent or not)
|
|
86
|
-
*
|
|
87
|
-
* @param status The mismatch info
|
|
88
|
-
* @param wasSent Indicate whether the message was already sent or if it can still be canceled
|
|
89
|
-
* @return
|
|
90
|
-
*/
|
|
91
|
-
onClientMismatch?: (status: ClientMismatch | MessageSendingStatus, wasSent: boolean) => void | boolean | Promise<boolean>;
|
|
92
|
-
}
|
|
11
|
+
import type { NotificationService } from '../../notification';
|
|
12
|
+
import { AddUsersParams, MessageSendingCallbacks, MessageSendingOptions, SendMlsMessageParams, SendProteusMessageParams } from './ConversationService.types';
|
|
93
13
|
export declare class ConversationService {
|
|
94
14
|
private readonly apiClient;
|
|
95
15
|
private readonly config;
|
|
@@ -207,7 +127,9 @@ export declare class ConversationService {
|
|
|
207
127
|
getConversations(conversationIds?: string[]): Promise<Conversation[]>;
|
|
208
128
|
getAsset({ assetId, assetToken, otrKey, sha256 }: RemoteData): Promise<Uint8Array>;
|
|
209
129
|
getUnencryptedAsset(assetId: string, assetToken?: string): Promise<ArrayBuffer>;
|
|
210
|
-
|
|
130
|
+
private addUsersToProteusGroup;
|
|
131
|
+
private addUsersToMLSGroup;
|
|
132
|
+
addUsers({ conversationId, protocol, userIds }: AddUsersParams): Promise<void | import("@wireapp/api-client/src/event").ConversationMemberJoinEvent>;
|
|
211
133
|
removeUser(conversationId: string, userId: string): Promise<string>;
|
|
212
134
|
private sendMlsMessage;
|
|
213
135
|
private sendProteusMessage;
|
|
@@ -224,4 +146,3 @@ export declare class ConversationService {
|
|
|
224
146
|
private isClearFromMismatch;
|
|
225
147
|
private generateGenericMessage;
|
|
226
148
|
}
|
|
227
|
-
export {};
|
package/src/main/conversation/{ConversationService.js → ConversationService/ConversationService.js}
RENAMED
|
@@ -18,26 +18,18 @@
|
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.ConversationService =
|
|
21
|
+
exports.ConversationService = void 0;
|
|
22
22
|
const bazinga64_1 = require("bazinga64");
|
|
23
23
|
const conversation_1 = require("@wireapp/api-client/src/conversation");
|
|
24
24
|
const data_1 = require("@wireapp/api-client/src/conversation/data");
|
|
25
25
|
const protocol_messaging_1 = require("@wireapp/protocol-messaging");
|
|
26
|
-
const conversation_2 = require("
|
|
27
|
-
const AssetCryptography_1 = require("
|
|
28
|
-
const TypePredicateUtil_1 = require("
|
|
29
|
-
const MessageBuilder_1 = require("
|
|
30
|
-
const MessageService_1 = require("
|
|
31
|
-
const MessageToProtoMapper_1 = require("
|
|
32
|
-
|
|
33
|
-
(function (MessageTargetMode) {
|
|
34
|
-
MessageTargetMode[MessageTargetMode["NONE"] = 0] = "NONE";
|
|
35
|
-
MessageTargetMode[MessageTargetMode["USERS"] = 1] = "USERS";
|
|
36
|
-
MessageTargetMode[MessageTargetMode["USERS_CLIENTS"] = 2] = "USERS_CLIENTS";
|
|
37
|
-
})(MessageTargetMode = exports.MessageTargetMode || (exports.MessageTargetMode = {}));
|
|
38
|
-
function isMLS(params) {
|
|
39
|
-
return params.protocol === conversation_1.ConversationProtocol.MLS;
|
|
40
|
-
}
|
|
26
|
+
const conversation_2 = require("../../conversation/");
|
|
27
|
+
const AssetCryptography_1 = require("../../cryptography/AssetCryptography");
|
|
28
|
+
const TypePredicateUtil_1 = require("../../util/TypePredicateUtil");
|
|
29
|
+
const MessageBuilder_1 = require("../message/MessageBuilder");
|
|
30
|
+
const MessageService_1 = require("../message/MessageService");
|
|
31
|
+
const MessageToProtoMapper_1 = require("../message/MessageToProtoMapper");
|
|
32
|
+
const ConversationService_types_1 = require("./ConversationService.types");
|
|
41
33
|
class ConversationService {
|
|
42
34
|
constructor(apiClient, cryptographyService, config, coreCryptoClientProvider, notificationService) {
|
|
43
35
|
this.apiClient = apiClient;
|
|
@@ -171,9 +163,9 @@ class ConversationService {
|
|
|
171
163
|
* @param genericMessage The payload of the message to send
|
|
172
164
|
* @return Resolves with the message sending status from backend
|
|
173
165
|
*/
|
|
174
|
-
async sendGenericMessage(sendingClientId, conversationId, genericMessage, { conversationDomain, userIds, nativePush, sendAsProtobuf, onClientMismatch, targetMode = MessageTargetMode.NONE, } = {}) {
|
|
166
|
+
async sendGenericMessage(sendingClientId, conversationId, genericMessage, { conversationDomain, userIds, nativePush, sendAsProtobuf, onClientMismatch, targetMode = ConversationService_types_1.MessageTargetMode.NONE, } = {}) {
|
|
175
167
|
const plainText = protocol_messaging_1.GenericMessage.encode(genericMessage).finish();
|
|
176
|
-
if (targetMode !== MessageTargetMode.NONE && !userIds) {
|
|
168
|
+
if (targetMode !== ConversationService_types_1.MessageTargetMode.NONE && !userIds) {
|
|
177
169
|
throw new Error('Cannot send targetted message when no userIds are given');
|
|
178
170
|
}
|
|
179
171
|
if (conversationDomain && this.config.useQualifiedIds) {
|
|
@@ -182,10 +174,10 @@ class ConversationService {
|
|
|
182
174
|
}
|
|
183
175
|
const recipients = await this.getQualifiedRecipientsForConversation({ id: conversationId, domain: conversationDomain }, userIds);
|
|
184
176
|
let reportMissing;
|
|
185
|
-
if (targetMode === MessageTargetMode.NONE) {
|
|
177
|
+
if (targetMode === ConversationService_types_1.MessageTargetMode.NONE) {
|
|
186
178
|
reportMissing = (0, TypePredicateUtil_1.isQualifiedUserClients)(userIds); // we want to check mismatch in case the consumer gave an exact list of users/devices
|
|
187
179
|
}
|
|
188
|
-
else if (targetMode === MessageTargetMode.USERS) {
|
|
180
|
+
else if (targetMode === ConversationService_types_1.MessageTargetMode.USERS) {
|
|
189
181
|
reportMissing = this.extractQualifiedUserIds(userIds);
|
|
190
182
|
}
|
|
191
183
|
else {
|
|
@@ -204,10 +196,10 @@ class ConversationService {
|
|
|
204
196
|
}
|
|
205
197
|
const recipients = await this.getRecipientsForConversation(conversationId, userIds);
|
|
206
198
|
let reportMissing;
|
|
207
|
-
if (targetMode === MessageTargetMode.NONE) {
|
|
199
|
+
if (targetMode === ConversationService_types_1.MessageTargetMode.NONE) {
|
|
208
200
|
reportMissing = (0, TypePredicateUtil_1.isUserClients)(userIds); // we want to check mismatch in case the consumer gave an exact list of users/devices
|
|
209
201
|
}
|
|
210
|
-
else if (targetMode === MessageTargetMode.USERS) {
|
|
202
|
+
else if (targetMode === ConversationService_types_1.MessageTargetMode.USERS) {
|
|
211
203
|
reportMissing = this.extractUserIds(userIds);
|
|
212
204
|
}
|
|
213
205
|
else {
|
|
@@ -712,11 +704,17 @@ class ConversationService {
|
|
|
712
704
|
const request = await this.apiClient.api.asset.getAssetV3(assetId, assetToken);
|
|
713
705
|
return (await request.response).buffer;
|
|
714
706
|
}
|
|
715
|
-
async
|
|
716
|
-
const
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
707
|
+
async addUsersToProteusGroup({ conversationId, userIds }) {
|
|
708
|
+
const response = await this.apiClient.api.conversation.postMembers(conversationId, userIds);
|
|
709
|
+
return response;
|
|
710
|
+
}
|
|
711
|
+
async addUsersToMLSGroup({ conversationId, userIds }) {
|
|
712
|
+
return console.info('addUsersToMLSGroup', conversationId, userIds);
|
|
713
|
+
}
|
|
714
|
+
async addUsers({ conversationId, protocol, userIds }) {
|
|
715
|
+
return protocol === conversation_1.ConversationProtocol.MLS
|
|
716
|
+
? this.addUsersToMLSGroup({ conversationId, userIds })
|
|
717
|
+
: this.addUsersToProteusGroup({ conversationId, userIds });
|
|
720
718
|
}
|
|
721
719
|
async removeUser(conversationId, userId) {
|
|
722
720
|
await this.apiClient.api.conversation.deleteMember(conversationId, userId);
|
|
@@ -762,6 +760,9 @@ class ConversationService {
|
|
|
762
760
|
* @return resolves with the sent message
|
|
763
761
|
*/
|
|
764
762
|
async send(params) {
|
|
763
|
+
function isMLS(params) {
|
|
764
|
+
return params.protocol === conversation_1.ConversationProtocol.MLS;
|
|
765
|
+
}
|
|
765
766
|
const { payload, onStart } = params;
|
|
766
767
|
const { genericMessage, content } = this.generateGenericMessage(payload);
|
|
767
768
|
if ((await (onStart === null || onStart === void 0 ? void 0 : onStart(genericMessage))) === false) {
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { GenericMessage } from '@wireapp/protocol-messaging';
|
|
2
|
+
import { QualifiedUserClients, ClientMismatch, ConversationProtocol, MessageSendingStatus, UserClients } from '@wireapp/api-client/src/conversation';
|
|
3
|
+
import { QualifiedId } from '@wireapp/api-client/src/user';
|
|
4
|
+
export declare enum MessageTargetMode {
|
|
5
|
+
NONE = 0,
|
|
6
|
+
USERS = 1,
|
|
7
|
+
USERS_CLIENTS = 2
|
|
8
|
+
}
|
|
9
|
+
export interface MessageSendingOptions {
|
|
10
|
+
/**
|
|
11
|
+
* The federated domain the server runs on. Should only be set for federation enabled envs
|
|
12
|
+
*/
|
|
13
|
+
conversationDomain?: string;
|
|
14
|
+
/**
|
|
15
|
+
* can be either a QualifiedId[] or QualfiedUserClients or undefined. The type has some effect on the behavior of the method.
|
|
16
|
+
* When given undefined the method will fetch both the members of the conversations and their devices. No ClientMismatch can happen in that case
|
|
17
|
+
* When given a QualifiedId[] the method will fetch the freshest list of devices for those users (since they are not given by the consumer). As a consequence no ClientMismatch error will trigger and we will ignore missing clients when sending
|
|
18
|
+
* When given a QualifiedUserClients the method will only send to the clients listed in the userIds. This could lead to ClientMismatch (since the given list of devices might not be the freshest one and new clients could have been created)
|
|
19
|
+
*/
|
|
20
|
+
userIds?: string[] | QualifiedId[] | UserClients | QualifiedUserClients;
|
|
21
|
+
/**
|
|
22
|
+
* Will send the message as a protobuf payload
|
|
23
|
+
*/
|
|
24
|
+
sendAsProtobuf?: boolean;
|
|
25
|
+
nativePush?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Will be called whenever there is a clientmismatch returned from the server. Needs to be combined with a userIds of type QualifiedUserClients
|
|
28
|
+
*/
|
|
29
|
+
onClientMismatch?: MessageSendingCallbacks['onClientMismatch'];
|
|
30
|
+
/**
|
|
31
|
+
* Defines the behavior to use when a mismatch happens on backend side:
|
|
32
|
+
* - NONE -> Not a targetted message, we want to send to all the users/clients in the conversation. Will report all missing users and clients (default mode)
|
|
33
|
+
* - USERS -> A message targetted to all the clients of the given users (according to params.userIds). Will ignore missing users and only report missing clients for the given params.userIds
|
|
34
|
+
* - USERS_CLIENTS -> A message targetted at some specific clients of specific users (according to params.userIds). Will force sending the message even if users or clients are missing
|
|
35
|
+
*/
|
|
36
|
+
targetMode?: MessageTargetMode;
|
|
37
|
+
}
|
|
38
|
+
export interface MessageSendingCallbacks {
|
|
39
|
+
/**
|
|
40
|
+
* Will be called before a message is actually sent. Returning 'false' will prevent the message from being sent
|
|
41
|
+
* @param message The message being sent
|
|
42
|
+
* @return true or undefined if the message should be sent, false if the message sending should be cancelled
|
|
43
|
+
*/
|
|
44
|
+
onStart?: (message: GenericMessage) => void | boolean | Promise<boolean>;
|
|
45
|
+
onSuccess?: (message: GenericMessage, sentTime?: string) => void;
|
|
46
|
+
/**
|
|
47
|
+
* Called whenever there is a clientmismatch returned from the server. Will also indicate the sending status of the message (if it was already sent or not)
|
|
48
|
+
*
|
|
49
|
+
* @param status The mismatch info
|
|
50
|
+
* @param wasSent Indicate whether the message was already sent or if it can still be canceled
|
|
51
|
+
* @return
|
|
52
|
+
*/
|
|
53
|
+
onClientMismatch?: (status: ClientMismatch | MessageSendingStatus, wasSent: boolean) => void | boolean | Promise<boolean>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* ######################################################################
|
|
57
|
+
* ################ MLS and Proteus implementation types ################
|
|
58
|
+
* ######################################################################
|
|
59
|
+
*/
|
|
60
|
+
/**
|
|
61
|
+
* The protocol to use to send the message (MLS or Proteus)
|
|
62
|
+
*/
|
|
63
|
+
export declare type ProtocolParam = {
|
|
64
|
+
protocol: ConversationProtocol;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* The message to send to the conversation
|
|
68
|
+
*/
|
|
69
|
+
export declare type SendCommonParams<T> = ProtocolParam & {
|
|
70
|
+
payload: T;
|
|
71
|
+
onStart?: (message: GenericMessage) => void | boolean | Promise<boolean>;
|
|
72
|
+
onSuccess?: (message: GenericMessage, sentTime?: string) => void;
|
|
73
|
+
};
|
|
74
|
+
export declare type SendProteusMessageParams<T> = SendCommonParams<T> & MessageSendingOptions & {
|
|
75
|
+
/**
|
|
76
|
+
* Can be either a QualifiedId[], string[], UserClients or QualfiedUserClients. The type has some effect on the behavior of the method. (Needed only for Proteus)
|
|
77
|
+
* When given a QualifiedId[] or string[] the method will fetch the freshest list of devices for those users (since they are not given by the consumer). As a consequence no ClientMismatch error will trigger and we will ignore missing clients when sending
|
|
78
|
+
* When given a QualifiedUserClients or UserClients the method will only send to the clients listed in the userIds. This could lead to ClientMismatch (since the given list of devices might not be the freshest one and new clients could have been created)
|
|
79
|
+
* When given a QualifiedId[] or QualifiedUserClients the method will send the message through the federated API endpoint
|
|
80
|
+
* When given a string[] or UserClients the method will send the message through the old API endpoint
|
|
81
|
+
*/
|
|
82
|
+
userIds?: string[] | QualifiedId[] | UserClients | QualifiedUserClients;
|
|
83
|
+
onClientMismatch?: (status: ClientMismatch | MessageSendingStatus, wasSent: boolean) => void | boolean | Promise<boolean>;
|
|
84
|
+
};
|
|
85
|
+
export declare type SendMlsMessageParams<T> = SendCommonParams<T> & {
|
|
86
|
+
/**
|
|
87
|
+
* The groupId of the conversation to send the message to (Needed only for MLS)
|
|
88
|
+
*/
|
|
89
|
+
groupId: string;
|
|
90
|
+
};
|
|
91
|
+
export declare type AddUsersParams = ProtocolParam & {
|
|
92
|
+
conversationId: QualifiedId;
|
|
93
|
+
userIds: QualifiedId[];
|
|
94
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Wire
|
|
4
|
+
* Copyright (C) 2022 Wire Swiss GmbH
|
|
5
|
+
*
|
|
6
|
+
* This program is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
* (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* This program is distributed in the hope that it will be useful,
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
* GNU General Public License for more details.
|
|
15
|
+
*
|
|
16
|
+
* You should have received a copy of the GNU General Public License
|
|
17
|
+
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.MessageTargetMode = void 0;
|
|
22
|
+
var MessageTargetMode;
|
|
23
|
+
(function (MessageTargetMode) {
|
|
24
|
+
MessageTargetMode[MessageTargetMode["NONE"] = 0] = "NONE";
|
|
25
|
+
MessageTargetMode[MessageTargetMode["USERS"] = 1] = "USERS";
|
|
26
|
+
MessageTargetMode[MessageTargetMode["USERS_CLIENTS"] = 2] = "USERS_CLIENTS";
|
|
27
|
+
})(MessageTargetMode = exports.MessageTargetMode || (exports.MessageTargetMode = {}));
|
|
28
|
+
//# sourceMappingURL=ConversationService.types.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Wire
|
|
4
|
+
* Copyright (C) 2022 Wire Swiss GmbH
|
|
5
|
+
*
|
|
6
|
+
* This program is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
* (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* This program is distributed in the hope that it will be useful,
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
* GNU General Public License for more details.
|
|
15
|
+
*
|
|
16
|
+
* You should have received a copy of the GNU General Public License
|
|
17
|
+
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
23
|
+
}) : (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
o[k2] = m[k];
|
|
26
|
+
}));
|
|
27
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
28
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
29
|
+
};
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
__exportStar(require("./ConversationService.types"), exports);
|
|
32
|
+
__exportStar(require("./ConversationService"), exports);
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './MessageTimer';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Wire
|
|
4
|
+
* Copyright (C) 2022 Wire Swiss GmbH
|
|
5
|
+
*
|
|
6
|
+
* This program is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
* (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* This program is distributed in the hope that it will be useful,
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
* GNU General Public License for more details.
|
|
15
|
+
*
|
|
16
|
+
* You should have received a copy of the GNU General Public License
|
|
17
|
+
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
23
|
+
}) : (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
o[k2] = m[k];
|
|
26
|
+
}));
|
|
27
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
28
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
29
|
+
};
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
__exportStar(require("./MessageTimer"), exports);
|
|
32
|
+
//# sourceMappingURL=index.js.map
|