@wireapp/core 26.0.0 → 26.1.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,17 @@
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
+ # [26.1.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@26.0.0...@wireapp/core@26.1.0) (2022-05-16)
7
+
8
+
9
+ ### Features
10
+
11
+ * Allow consumer to set number of prekeys generated ([#4263](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4263)) ([648ecda](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/648ecdad260488e1d07965a84a28c346d6f015c3))
12
+
13
+
14
+
15
+
16
+
6
17
  # [26.0.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@25.3.1...@wireapp/core@26.0.0) (2022-05-16)
7
18
 
8
19
 
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": "26.0.0",
73
- "gitHead": "730379c5b3701879632789ca73c1a9d55a9505ad"
72
+ "version": "26.1.0",
73
+ "gitHead": "3b458a889a4e5ebebf2c66429c8fac7f39119891"
74
74
  }
@@ -53,11 +53,26 @@ export interface Account {
53
53
  on(event: TOPIC.ERROR, listener: (payload: CoreError) => void): this;
54
54
  }
55
55
  export declare type CreateStoreFn = (storeName: string, context: Context) => undefined | Promise<CRUDEngine | undefined>;
56
+ interface AccountOptions {
57
+ /** Used to store info in the database (will create a inMemory engine if returns undefined) */
58
+ createStore?: CreateStoreFn;
59
+ /** Number of prekeys to generate when creating a new device (defaults to 2)
60
+ * Prekeys are Diffie-Hellmann public keys which allow offline initiation of a secure Proteus session between two devices.
61
+ * Having a high value will:
62
+ * - make creating a new device consuming more CPU resources
63
+ * - make it less likely that all prekeys get consumed while the device is offline and the last resort prekey will not be used to create new session
64
+ * Having a low value will:
65
+ * - make creating a new device fast
66
+ * - make it likely that all prekeys get consumed while the device is offline and the last resort prekey will be used to create new session
67
+ */
68
+ nbPrekeys?: number;
69
+ }
56
70
  export declare class Account extends EventEmitter {
57
71
  private readonly apiClient;
58
72
  private readonly logger;
59
73
  private readonly createStore;
60
74
  private storeEngine?;
75
+ private readonly nbPrekeys;
61
76
  static readonly TOPIC: typeof TOPIC;
62
77
  service?: {
63
78
  account: AccountService;
@@ -77,11 +92,9 @@ export declare class Account extends EventEmitter {
77
92
  backendFeatures: BackendFeatures;
78
93
  /**
79
94
  * @param apiClient The apiClient instance to use in the core (will create a new new one if undefined)
80
- * @param storeEngineProvider Used to store info in the database (will create a inMemory engine if returns undefined)
95
+ * @param storeEngineProvider
81
96
  */
82
- constructor(apiClient?: APIClient, { createStore }?: {
83
- createStore?: CreateStoreFn;
84
- });
97
+ constructor(apiClient?: APIClient, { createStore, nbPrekeys }?: AccountOptions);
85
98
  private persistCookie;
86
99
  get clientId(): string;
87
100
  get userId(): string;
@@ -70,9 +70,9 @@ var TOPIC;
70
70
  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
- * @param storeEngineProvider Used to store info in the database (will create a inMemory engine if returns undefined)
73
+ * @param storeEngineProvider
74
74
  */
75
- constructor(apiClient = new api_client_1.APIClient(), { createStore = () => undefined } = {}) {
75
+ constructor(apiClient = new api_client_1.APIClient(), { createStore = () => undefined, nbPrekeys = 2 } = {}) {
76
76
  super();
77
77
  this.handlePayload = async (payload) => {
78
78
  switch (payload.type) {
@@ -90,6 +90,7 @@ class Account extends events_1.EventEmitter {
90
90
  };
91
91
  this.apiClient = apiClient;
92
92
  this.backendFeatures = this.apiClient.backendFeatures;
93
+ this.nbPrekeys = nbPrekeys;
93
94
  this.createStore = createStore;
94
95
  apiClient.on(api_client_1.APIClient.TOPIC.COOKIE_REFRESH, async (cookie) => {
95
96
  if (cookie && this.storeEngine) {
@@ -136,6 +137,7 @@ class Account extends events_1.EventEmitter {
136
137
  const cryptographyService = new cryptography_1.CryptographyService(this.apiClient, this.storeEngine, {
137
138
  // We want to encrypt with fully qualified session ids, only if the backend is federated with other backends
138
139
  useQualifiedIds: this.backendFeatures.isFederated,
140
+ nbPrekeys: this.nbPrekeys,
139
141
  });
140
142
  const clientService = new client_2.ClientService(this.apiClient, this.storeEngine, cryptographyService);
141
143
  const connectionService = new connection_1.ConnectionService(this.apiClient);
@@ -20,8 +20,9 @@ export declare class CryptographyService {
20
20
  private readonly logger;
21
21
  cryptobox: Cryptobox;
22
22
  private readonly database;
23
- constructor(apiClient: APIClient, storeEngine: CRUDEngine, config?: {
24
- useQualifiedIds?: boolean;
23
+ constructor(apiClient: APIClient, storeEngine: CRUDEngine, config: {
24
+ useQualifiedIds: boolean;
25
+ nbPrekeys: number;
25
26
  });
26
27
  constructSessionId(userId: string | QualifiedId, clientId: string, domain?: string): string;
27
28
  static convertArrayRecipientsToBase64(recipients: OTRRecipients<Uint8Array>): OTRRecipients<string>;
@@ -32,11 +32,11 @@ 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, config = {}) {
35
+ constructor(apiClient, storeEngine, config) {
36
36
  this.apiClient = apiClient;
37
37
  this.storeEngine = storeEngine;
38
38
  this.config = config;
39
- this.cryptobox = new cryptobox_1.Cryptobox(this.storeEngine);
39
+ this.cryptobox = new cryptobox_1.Cryptobox(this.storeEngine, config.nbPrekeys);
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,