@wireapp/core 30.0.5 → 30.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
+ # [30.1.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@30.0.5...@wireapp/core@30.1.0) (2022-09-07)
7
+
8
+
9
+ ### Features
10
+
11
+ * Ability to clear database when logging out ([#4377](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4377)) ([e5f7a9c](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/e5f7a9c4f36a018d2bd13eca8a0d751cf7f9805c))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [30.0.5](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@30.0.4...@wireapp/core@30.0.5) (2022-09-02)
7
18
 
8
19
  **Note:** Version bump only for package @wireapp/core
package/package.json CHANGED
@@ -77,6 +77,6 @@
77
77
  "test:node": "nyc jasmine --config=jasmine.json",
78
78
  "watch": "tsc ---watch"
79
79
  },
80
- "version": "30.0.5",
81
- "gitHead": "a6993ee7b942cf5c4fe85dbb8cf742c546765a36"
80
+ "version": "30.1.0",
81
+ "gitHead": "1d1db30fe5778628cd7b550a0d94891c18792236"
82
82
  }
@@ -166,7 +166,11 @@ export declare class Account<T = any> extends EventEmitter {
166
166
  private createMLSClient;
167
167
  private registerClient;
168
168
  private resetContext;
169
- logout(): Promise<void>;
169
+ /**
170
+ * Will logout the current user
171
+ * @param clearData if set to `true` will completely wipe any database that was created by the Account
172
+ */
173
+ logout(clearData?: boolean): Promise<void>;
170
174
  /**
171
175
  * Will download and handle the notification stream since last stored notification id.
172
176
  * Once the notification stream has been handled from backend, will then connect to the websocket and start listening to incoming events
@@ -210,6 +214,7 @@ export declare class Account<T = any> extends EventEmitter {
210
214
  dryRun?: boolean;
211
215
  }): Promise<() => void>;
212
216
  private generateDbName;
217
+ private generateSecretsDbName;
213
218
  private initEngine;
214
219
  }
215
220
  export {};
@@ -271,7 +271,7 @@ class Account extends events_1.EventEmitter {
271
271
  async createMLSClient(client, context, mlsConfig, entropyData) {
272
272
  const coreCryptoKeyId = 'corecrypto-key';
273
273
  const { CoreCrypto } = await Promise.resolve().then(() => __importStar(require('@otak/core-crypto')));
274
- const dbName = `secrets-${this.generateDbName(context)}`;
274
+ const dbName = this.generateSecretsDbName(context);
275
275
  const secretStore = mlsConfig.secretsCrypto
276
276
  ? await (0, encryptedStore_1.createCustomEncryptedStore)(dbName, mlsConfig.secretsCrypto)
277
277
  : await (0, encryptedStore_1.createEncryptedStore)(dbName);
@@ -311,7 +311,15 @@ class Account extends events_1.EventEmitter {
311
311
  delete this.apiClient.context;
312
312
  delete this.service;
313
313
  }
314
- async logout() {
314
+ /**
315
+ * Will logout the current user
316
+ * @param clearData if set to `true` will completely wipe any database that was created by the Account
317
+ */
318
+ async logout(clearData = false) {
319
+ if (clearData && this.coreCryptoClient) {
320
+ await this.coreCryptoClient.wipe();
321
+ await (0, encryptedStore_1.deleteEncryptedStore)(this.generateSecretsDbName(this.apiClient.context));
322
+ }
315
323
  await this.apiClient.logout();
316
324
  this.resetContext();
317
325
  }
@@ -387,6 +395,9 @@ class Account extends events_1.EventEmitter {
387
395
  const clientType = context.clientType === client_1.ClientType.NONE ? '' : `@${context.clientType}`;
388
396
  return `wire@${this.apiClient.config.urls.name}@${context.userId}${clientType}`;
389
397
  }
398
+ generateSecretsDbName(context) {
399
+ return `secrets-${this.generateDbName(context)}`;
400
+ }
390
401
  async initEngine(context) {
391
402
  const dbName = this.generateDbName(context);
392
403
  this.logger.log(`Initialising store with name "${dbName}"...`);
@@ -41,4 +41,5 @@ export declare function createEncryptedStore(dbName: string): Promise<EncryptedS
41
41
  * @param config contains the encrypt and decrypt methods
42
42
  */
43
43
  export declare function createCustomEncryptedStore<EncryptedPayload>(dbName: string, config: EncryptedStoreConfig<EncryptedPayload>): Promise<EncryptedStore<EncryptedPayload>>;
44
+ export declare function deleteEncryptedStore(dbName: string): Promise<void>;
44
45
  export {};
@@ -30,7 +30,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
30
30
  };
31
31
  var _EncryptedStore_decrypt, _EncryptedStore_encrypt;
32
32
  Object.defineProperty(exports, "__esModule", { value: true });
33
- exports.createCustomEncryptedStore = exports.createEncryptedStore = void 0;
33
+ exports.deleteEncryptedStore = exports.createCustomEncryptedStore = exports.createEncryptedStore = void 0;
34
34
  const idb_1 = require("idb");
35
35
  class EncryptedStore {
36
36
  constructor(db, { encrypt, decrypt }) {
@@ -109,4 +109,8 @@ async function createCustomEncryptedStore(dbName, config) {
109
109
  return new EncryptedStore(db, config);
110
110
  }
111
111
  exports.createCustomEncryptedStore = createCustomEncryptedStore;
112
+ async function deleteEncryptedStore(dbName) {
113
+ return (0, idb_1.deleteDB)(dbName);
114
+ }
115
+ exports.deleteEncryptedStore = deleteEncryptedStore;
112
116
  //# sourceMappingURL=encryptedStore.js.map