@wireapp/core 31.3.4 → 31.3.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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "./src/main/cryptography/AssetCryptography/crypto.node": "./src/main/cryptography/AssetCryptography/crypto.browser.js"
4
4
  },
5
5
  "dependencies": {
6
- "@wireapp/api-client": "^20.6.3",
6
+ "@wireapp/api-client": "^20.6.4",
7
7
  "@wireapp/commons": "^4.4.6",
8
8
  "@wireapp/core-crypto": "0.5.2",
9
9
  "@wireapp/cryptobox": "12.8.0",
@@ -81,6 +81,6 @@
81
81
  "test": "jest",
82
82
  "watch": "tsc ---watch"
83
83
  },
84
- "version": "31.3.4",
85
- "gitHead": "65fc4d287cf2bb6239bba6835b641cb49f22c826"
84
+ "version": "31.3.6",
85
+ "gitHead": "4578099d3d63d9e9e28e43911c72168fb885e2b8"
86
86
  }
@@ -2,7 +2,6 @@ import { AddProposalArgs, ConversationConfiguration, ConversationId, CoreCrypto,
2
2
  import { APIClient } from '@wireapp/api-client';
3
3
  import { QualifiedUsers } from '../../conversation';
4
4
  import { MLSCallbacks, MLSConfig } from '../types';
5
- import { PostMlsMessageResponse } from '@wireapp/api-client/src/conversation';
6
5
  export declare const optionalToUint8Array: (array: Uint8Array | []) => Uint8Array;
7
6
  export declare class MLSService {
8
7
  readonly config: MLSConfig | undefined;
@@ -12,7 +11,7 @@ export declare class MLSService {
12
11
  constructor(config: MLSConfig | undefined, apiClient: APIClient, coreCryptoClientProvider: () => CoreCrypto | undefined);
13
12
  private getCoreCryptoClient;
14
13
  private uploadCommitBundle;
15
- addUsersToExistingConversation(groupId: Uint8Array, invitee: Invitee[]): Promise<PostMlsMessageResponse | null>;
14
+ addUsersToExistingConversation(groupId: Uint8Array, invitee: Invitee[]): Promise<import("@wireapp/api-client/src/conversation").PostMlsMessageResponse | null>;
16
15
  configureMLSCallbacks({ groupIdFromConversationId, ...coreCryptoCallbacks }: MLSCallbacks): void;
17
16
  getKeyPackagesPayload(qualifiedUsers: QualifiedUsers[]): Promise<Invitee[]>;
18
17
  newProposal(proposalType: ProposalType, args: ProposalArgs | AddProposalArgs | RemoveProposalArgs): Promise<import("@wireapp/core-crypto").ProposalBundle>;
@@ -20,9 +19,20 @@ export declare class MLSService {
20
19
  processWelcomeMessage(welcomeMessage: Uint8Array): Promise<ConversationId>;
21
20
  decryptMessage(conversationId: ConversationId, payload: Uint8Array): Promise<DecryptedMessage>;
22
21
  encryptMessage(conversationId: ConversationId, message: Uint8Array): Promise<Uint8Array>;
23
- updateKeyingMaterial(conversationId: ConversationId): Promise<PostMlsMessageResponse | null>;
22
+ /**
23
+ * Will wrap a coreCrypto call that generates a CommitBundle and do all the necessary work so that commitbundle is handled the right way.
24
+ * It does:
25
+ * - commit the pending proposal
26
+ * - then generates the commitBundle with the given function
27
+ * - uploads the commitBundle to backend
28
+ * - warns coreCrypto that the commit was successfully processed
29
+ * @param groupId
30
+ * @param generateCommit The function that will generate a coreCrypto CommitBundle
31
+ */
32
+ private processCommitAction;
33
+ updateKeyingMaterial(conversationId: ConversationId): Promise<import("@wireapp/api-client/src/conversation").PostMlsMessageResponse | null>;
24
34
  createConversation(conversationId: ConversationId, configuration?: ConversationConfiguration): Promise<any>;
25
- removeClientsFromConversation(conversationId: ConversationId, clientIds: Uint8Array[]): Promise<PostMlsMessageResponse | null>;
35
+ removeClientsFromConversation(conversationId: ConversationId, clientIds: Uint8Array[]): Promise<import("@wireapp/api-client/src/conversation").PostMlsMessageResponse | null>;
26
36
  commitPendingProposals(groupId: ConversationId): Promise<void>;
27
37
  conversationExists(conversationId: ConversationId): Promise<boolean>;
28
38
  clientValidKeypackagesCount(): Promise<number>;
@@ -74,11 +74,7 @@ class MLSService {
74
74
  return null;
75
75
  }
76
76
  addUsersToExistingConversation(groupId, invitee) {
77
- return (0, messageSender_1.sendMessage)(async () => {
78
- const coreCryptoClient = this.getCoreCryptoClient();
79
- const memberAddedMessages = await coreCryptoClient.addClientsToConversation(groupId, invitee);
80
- return this.uploadCommitBundle(groupId, memberAddedMessages);
81
- });
77
+ return this.processCommitAction(groupId, () => this.getCoreCryptoClient().addClientsToConversation(groupId, invitee));
82
78
  }
83
79
  configureMLSCallbacks(_a) {
84
80
  var { groupIdFromConversationId } = _a, coreCryptoCallbacks = __rest(_a, ["groupIdFromConversationId"]);
@@ -131,24 +127,35 @@ class MLSService {
131
127
  async encryptMessage(conversationId, message) {
132
128
  return this.getCoreCryptoClient().encryptMessage(conversationId, message);
133
129
  }
134
- updateKeyingMaterial(conversationId) {
130
+ /**
131
+ * Will wrap a coreCrypto call that generates a CommitBundle and do all the necessary work so that commitbundle is handled the right way.
132
+ * It does:
133
+ * - commit the pending proposal
134
+ * - then generates the commitBundle with the given function
135
+ * - uploads the commitBundle to backend
136
+ * - warns coreCrypto that the commit was successfully processed
137
+ * @param groupId
138
+ * @param generateCommit The function that will generate a coreCrypto CommitBundle
139
+ */
140
+ async processCommitAction(groupId, generateCommit) {
135
141
  return (0, messageSender_1.sendMessage)(async () => {
136
- const commitBundle = await this.getCoreCryptoClient().updateKeyingMaterial(conversationId);
137
- return this.uploadCommitBundle(conversationId, commitBundle);
142
+ await this.commitPendingProposals(groupId);
143
+ const commitBundle = await generateCommit();
144
+ return this.uploadCommitBundle(groupId, commitBundle);
138
145
  });
139
146
  }
147
+ updateKeyingMaterial(conversationId) {
148
+ return this.processCommitAction(conversationId, () => this.getCoreCryptoClient().updateKeyingMaterial(conversationId));
149
+ }
140
150
  async createConversation(conversationId, configuration) {
141
151
  return this.getCoreCryptoClient().createConversation(conversationId, configuration);
142
152
  }
143
153
  removeClientsFromConversation(conversationId, clientIds) {
144
- return (0, messageSender_1.sendMessage)(async () => {
145
- const commitBundle = await this.getCoreCryptoClient().removeClientsFromConversation(conversationId, clientIds);
146
- return this.uploadCommitBundle(conversationId, commitBundle);
147
- });
154
+ return this.processCommitAction(conversationId, () => this.getCoreCryptoClient().removeClientsFromConversation(conversationId, clientIds));
148
155
  }
149
156
  async commitPendingProposals(groupId) {
150
157
  const commitBundle = await this.getCoreCryptoClient().commitPendingProposals(groupId);
151
- return commitBundle ? void this.uploadCommitBundle(groupId, commitBundle) : undefined;
158
+ return commitBundle ? void (await this.uploadCommitBundle(groupId, commitBundle)) : undefined;
152
159
  }
153
160
  async conversationExists(conversationId) {
154
161
  return this.getCoreCryptoClient().conversationExists(conversationId);