@wireapp/core 21.0.2 → 22.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
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
+ # [22.0.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@21.0.2...@wireapp/core@22.0.0) (2022-01-31)
7
+
8
+
9
+ ### Features
10
+
11
+ * **core:** Remove the need to give a domain to use qualified Ids ([#4217](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4217)) ([8ce58ea](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/8ce58eae8dcf86f66baccab3acfca7e3ba472e3c))
12
+
13
+
14
+ ### BREAKING CHANGES
15
+
16
+ * **core:** If you were using the Account with a federationDomain, you need to replace federationDomain: 'the.domain' to useQualifiedIds: true. The domain will be found automatically by the core
17
+
18
+
19
+
20
+
21
+
6
22
  ## [21.0.2](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@21.0.1...@wireapp/core@21.0.2) (2022-01-19)
7
23
 
8
24
 
package/package.json CHANGED
@@ -69,6 +69,6 @@
69
69
  "test:project": "yarn dist && yarn test",
70
70
  "test:node": "nyc jasmine --config=jasmine.json"
71
71
  },
72
- "version": "21.0.2",
73
- "gitHead": "9838da9b1a1dcb702154c73c28a15e53fc35af9f"
72
+ "version": "22.0.0",
73
+ "gitHead": "6f85fe1a8bc2dfe0ef0db6dfe094916aa00dc1f7"
74
74
  }
@@ -54,10 +54,11 @@ export interface Account {
54
54
  }
55
55
  export declare type StoreEngineProvider = (storeName: string) => Promise<CRUDEngine>;
56
56
  declare type AccountConfig = {
57
- federationDomain?: string;
57
+ /** If set to true, will use fully qualified ids and federated endpoints */
58
+ useQualifiedIds?: boolean;
58
59
  };
59
60
  export declare class Account extends EventEmitter {
60
- private readonly config?;
61
+ private readonly config;
61
62
  private readonly apiClient;
62
63
  private readonly logger;
63
64
  private readonly storeEngineProvider;
@@ -81,9 +82,8 @@ export declare class Account extends EventEmitter {
81
82
  /**
82
83
  * @param apiClient The apiClient instance to use in the core (will create a new new one if undefined)
83
84
  * @param storeEngineProvider Used to store info in the database (will create a inMemory engine if undefined)
84
- * @param config.federationDomain If using a federated backend this will set the default domain for qualified ids. Do not set if using a regular backend
85
85
  */
86
- constructor(apiClient?: APIClient, storeEngineProvider?: StoreEngineProvider, config?: AccountConfig | undefined);
86
+ constructor(apiClient?: APIClient, storeEngineProvider?: StoreEngineProvider, config?: AccountConfig);
87
87
  private persistCookie;
88
88
  get clientId(): string;
89
89
  get userId(): string;
@@ -71,9 +71,8 @@ class Account extends events_1.EventEmitter {
71
71
  /**
72
72
  * @param apiClient The apiClient instance to use in the core (will create a new new one if undefined)
73
73
  * @param storeEngineProvider Used to store info in the database (will create a inMemory engine if undefined)
74
- * @param config.federationDomain If using a federated backend this will set the default domain for qualified ids. Do not set if using a regular backend
75
74
  */
76
- constructor(apiClient = new api_client_1.APIClient(), storeEngineProvider, config) {
75
+ constructor(apiClient = new api_client_1.APIClient(), storeEngineProvider, config = {}) {
77
76
  super();
78
77
  this.config = config;
79
78
  this.handlePayload = async (payload) => {
@@ -157,7 +156,7 @@ class Account extends events_1.EventEmitter {
157
156
  const connectionService = new connection_1.ConnectionService(this.apiClient);
158
157
  const giphyService = new giphy_1.GiphyService(this.apiClient);
159
158
  const linkPreviewService = new linkPreview_1.LinkPreviewService(assetService);
160
- const conversationService = new conversation_1.ConversationService(this.apiClient, cryptographyService);
159
+ const conversationService = new conversation_1.ConversationService(this.apiClient, cryptographyService, this.config);
161
160
  const notificationService = new notification_1.NotificationService(this.apiClient, cryptographyService, storeEngine);
162
161
  const selfService = new self_1.SelfService(this.apiClient);
163
162
  const teamService = new team_1.TeamService(this.apiClient);
@@ -60,10 +60,13 @@ export interface MessageSendingCallbacks {
60
60
  }
61
61
  export declare class ConversationService {
62
62
  private readonly apiClient;
63
+ private readonly config;
63
64
  readonly messageTimer: MessageTimer;
64
65
  private readonly messageService;
65
66
  private selfConversationId?;
66
- constructor(apiClient: APIClient, cryptographyService: CryptographyService);
67
+ constructor(apiClient: APIClient, cryptographyService: CryptographyService, config: {
68
+ useQualifiedIds?: boolean;
69
+ });
67
70
  private createEphemeral;
68
71
  private getConversationQualifiedMembers;
69
72
  /**
@@ -35,8 +35,9 @@ var MessageTargetMode;
35
35
  MessageTargetMode[MessageTargetMode["USERS_CLIENTS"] = 2] = "USERS_CLIENTS";
36
36
  })(MessageTargetMode = exports.MessageTargetMode || (exports.MessageTargetMode = {}));
37
37
  class ConversationService {
38
- constructor(apiClient, cryptographyService) {
38
+ constructor(apiClient, cryptographyService, config) {
39
39
  this.apiClient = apiClient;
40
+ this.config = config;
40
41
  this.messageTimer = new conversation_2.MessageTimer();
41
42
  this.messageService = new MessageService_1.MessageService(this.apiClient, cryptographyService);
42
43
  }
@@ -138,7 +139,8 @@ class ConversationService {
138
139
  if (!this.selfConversationId) {
139
140
  const { userId } = this.apiClient.context;
140
141
  const { qualified_id, id } = await this.apiClient.conversation.api.getConversation(userId);
141
- this.selfConversationId = qualified_id || { id, domain: '' };
142
+ const domain = this.config.useQualifiedIds ? qualified_id.domain : '';
143
+ this.selfConversationId = { id, domain };
142
144
  }
143
145
  return this.selfConversationId;
144
146
  }
@@ -13,17 +13,16 @@ export interface MetaClient extends RegisteredClient {
13
13
  primary_key: string;
14
14
  };
15
15
  }
16
- declare type CryptographyServiceOptions = {
17
- federationDomain?: string;
18
- };
19
16
  export declare class CryptographyService {
20
17
  readonly apiClient: APIClient;
21
18
  private readonly storeEngine;
22
- private readonly options?;
19
+ private readonly config;
23
20
  private readonly logger;
24
21
  cryptobox: Cryptobox;
25
22
  private readonly database;
26
- constructor(apiClient: APIClient, storeEngine: CRUDEngine, options?: CryptographyServiceOptions | undefined);
23
+ constructor(apiClient: APIClient, storeEngine: CRUDEngine, config?: {
24
+ useQualifiedIds?: boolean;
25
+ });
27
26
  static constructSessionId(userId: string, clientId: string, domain: string | null): string;
28
27
  static convertArrayRecipientsToBase64(recipients: OTRRecipients<Uint8Array>): OTRRecipients<string>;
29
28
  static convertBase64RecipientsToArray(recipients: OTRRecipients<string>): OTRRecipients<Uint8Array>;
@@ -43,4 +42,3 @@ export declare class CryptographyService {
43
42
  resetSession(sessionId: string): Promise<void>;
44
43
  decodeGenericMessage(otrMessage: ConversationOtrMessageAddEvent, source: PayloadBundleSource): Promise<PayloadBundle>;
45
44
  }
46
- export {};
@@ -32,17 +32,16 @@ const util_1 = require("../util");
32
32
  const CryptographyDatabaseRepository_1 = require("./CryptographyDatabaseRepository");
33
33
  const GenericMessageMapper_1 = require("./GenericMessageMapper");
34
34
  class CryptographyService {
35
- constructor(apiClient, storeEngine, options) {
35
+ constructor(apiClient, storeEngine, config = {}) {
36
36
  this.apiClient = apiClient;
37
37
  this.storeEngine = storeEngine;
38
- this.options = options;
38
+ this.config = config;
39
39
  this.cryptobox = new cryptobox_1.Cryptobox(this.storeEngine);
40
40
  this.database = new CryptographyDatabaseRepository_1.CryptographyDatabaseRepository(this.storeEngine);
41
41
  this.logger = (0, logdown_1.default)('@wireapp/core/cryptography/CryptographyService', {
42
42
  logger: console,
43
43
  markdown: false,
44
44
  });
45
- this.options = options;
46
45
  }
47
46
  static constructSessionId(userId, clientId, domain) {
48
47
  const baseId = `${userId}@${clientId}`;
@@ -147,9 +146,8 @@ class CryptographyService {
147
146
  this.logger.log(`Deleted session ID "${sessionId}".`);
148
147
  }
149
148
  async decodeGenericMessage(otrMessage, source) {
150
- var _a;
151
149
  const { from, qualified_from, data: { sender, text: cipherText }, } = otrMessage;
152
- const domain = ((_a = this.options) === null || _a === void 0 ? void 0 : _a.federationDomain) ? (qualified_from === null || qualified_from === void 0 ? void 0 : qualified_from.domain) || this.options.federationDomain : null;
150
+ const domain = this.config.useQualifiedIds ? qualified_from.domain : null;
153
151
  const sessionId = CryptographyService.constructSessionId(from, sender, domain);
154
152
  const decryptedMessage = await this.decrypt(sessionId, cipherText);
155
153
  const genericMessage = protocol_messaging_1.GenericMessage.decode(decryptedMessage);