@wireapp/core 38.0.0-beta.0 → 38.0.0-beta.1
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/lib/Account.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Account.d.ts","sourceRoot":"","sources":["../src/Account.ts"],"names":[],"mappings":";AAmBA,OAAO,EACL,YAAY,EAGZ,OAAO,EACP,MAAM,EAEN,SAAS,EACV,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAuB,UAAU,EAAE,gBAAgB,EAAC,MAAM,iCAAiC,CAAC;AAWnG,OAAO,EAAC,YAAY,EAAC,MAAM,QAAQ,CAAC;AAEpC,OAAO,EAAC,SAAS,EAAE,eAAe,EAAC,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EAAC,UAAU,EAA0C,MAAM,uBAAuB,CAAC;AAE1F,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAC,UAAU,EAAE,aAAa,EAAC,MAAM,WAAW,CAAC;AACpD,OAAO,EAAC,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAChD,OAAO,EAAC,YAAY,EAAE,mBAAmB,EAAC,MAAM,iBAAiB,CAAC;AAElE,OAAO,EAAC,YAAY,EAAC,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"Account.d.ts","sourceRoot":"","sources":["../src/Account.ts"],"names":[],"mappings":";AAmBA,OAAO,EACL,YAAY,EAGZ,OAAO,EACP,MAAM,EAEN,SAAS,EACV,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAuB,UAAU,EAAE,gBAAgB,EAAC,MAAM,iCAAiC,CAAC;AAWnG,OAAO,EAAC,YAAY,EAAC,MAAM,QAAQ,CAAC;AAEpC,OAAO,EAAC,SAAS,EAAE,eAAe,EAAC,MAAM,qBAAqB,CAAC;AAE/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AAO,GAAG,OAAO,CAAC,IAAI,CAAC;IA+D7C,0BAA0B,IAAI,OAAO,CAAC,gBAAgB,CAAC;YAOtD,cAAc;IA8B5B,OAAO,CAAC,YAAY;IAKpB;;;OAGG;IACU,MAAM,CAAC,SAAS,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC;YAUhD,IAAI;IAUlB;;;;;;OAMG;IACI,MAAM,CAAC,EACZ,OAAkB,EAClB,wBAAmC,EACnC,4BAAuC,EACvC,qBAAgC,EAChC,MAAc,GACf,GAAE;QACD;;;;WAIG;QACH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,mBAAmB,EAAE,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAC;QAE7E;;WAEG;QACH,4BAA4B,CAAC,EAAE,CAAC,EAAC,IAAI,EAAE,KAAK,EAAC,EAAE;YAAC,IAAI,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAC,KAAK,IAAI,CAAC;QAEtF;;WAEG;QACH,wBAAwB,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;QAE5D;;;;;;WAMG;QACH,qBAAqB,CAAC,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,CAAC;QAEzD;;WAEG;QACH,MAAM,CAAC,EAAE,OAAO,CAAC;KACb,GAAG,MAAM,IAAI;IA2FN,qBAAqB;IA0BlC,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,kBAAkB;YAIZ,UAAU;CAqBzB"}
|
package/lib/Account.js
CHANGED
|
@@ -50,6 +50,7 @@ const connection_1 = require("./connection/");
|
|
|
50
50
|
const conversation_1 = require("./conversation/");
|
|
51
51
|
const messageSender_1 = require("./conversation/message/messageSender");
|
|
52
52
|
const giphy_1 = require("./giphy/");
|
|
53
|
+
const identityClearer_1 = require("./identity/identityClearer");
|
|
53
54
|
const linkPreview_1 = require("./linkPreview");
|
|
54
55
|
const mls_1 = require("./messagingProtocols/mls");
|
|
55
56
|
const proteus_1 = require("./messagingProtocols/proteus");
|
|
@@ -187,22 +188,22 @@ class Account extends events_1.EventEmitter {
|
|
|
187
188
|
* @returns The local existing client or newly created client
|
|
188
189
|
*/
|
|
189
190
|
async initClient(loginData, clientInfo, entropyData) {
|
|
190
|
-
var _a, _b, _c
|
|
191
|
+
var _a, _b, _c;
|
|
191
192
|
if (!this.service || !this.apiClient.context || !this.coreCryptoClient) {
|
|
192
193
|
throw new Error('Services are not set.');
|
|
193
194
|
}
|
|
194
|
-
//call /access endpoint with client_id after client initialisation
|
|
195
|
-
await this.apiClient.transport.http.associateClientWithSession(this.apiClient.context.clientId);
|
|
196
|
-
if (((_a = this.cryptoProtocolConfig) === null || _a === void 0 ? void 0 : _a.mls) && this.backendFeatures.supportsMLS) {
|
|
197
|
-
// initialize schedulers for pending mls proposals once client is initialized
|
|
198
|
-
await ((_b = this.service) === null || _b === void 0 ? void 0 : _b.mls.checkExistingPendingProposals());
|
|
199
|
-
// initialize schedulers for renewing key materials
|
|
200
|
-
(_c = this.service) === null || _c === void 0 ? void 0 : _c.mls.checkForKeyMaterialsUpdate();
|
|
201
|
-
// initialize scheduler for syncing key packages with backend
|
|
202
|
-
(_d = this.service) === null || _d === void 0 ? void 0 : _d.mls.checkForKeyPackagesBackendSync();
|
|
203
|
-
}
|
|
204
195
|
try {
|
|
205
196
|
const localClient = await this.loadAndValidateLocalClient();
|
|
197
|
+
//call /access endpoint with client_id after client initialisation
|
|
198
|
+
await this.apiClient.transport.http.associateClientWithSession(localClient.id);
|
|
199
|
+
if (((_a = this.cryptoProtocolConfig) === null || _a === void 0 ? void 0 : _a.mls) && this.backendFeatures.supportsMLS) {
|
|
200
|
+
// initialize schedulers for pending mls proposals once client is initialized
|
|
201
|
+
await this.service.mls.checkExistingPendingProposals();
|
|
202
|
+
// initialize schedulers for renewing key materials
|
|
203
|
+
this.service.mls.checkForKeyMaterialsUpdate();
|
|
204
|
+
// initialize scheduler for syncing key packages with backend
|
|
205
|
+
this.service.mls.checkForKeyPackagesBackendSync();
|
|
206
|
+
}
|
|
206
207
|
await this.service.proteus.init();
|
|
207
208
|
if (this.backendFeatures.supportsMLS) {
|
|
208
209
|
await this.service.mls.initClient(localClient.id);
|
|
@@ -217,9 +218,9 @@ class Account extends events_1.EventEmitter {
|
|
|
217
218
|
// There was no client so we need to "create" and "register" a client
|
|
218
219
|
const notFoundInDatabase = error instanceof store_engine_1.error.RecordNotFoundError ||
|
|
219
220
|
error.constructor.name === store_engine_1.error.RecordNotFoundError.name;
|
|
220
|
-
const notFoundOnBackend = axios_1.default.isAxiosError(error) ? ((
|
|
221
|
+
const notFoundOnBackend = axios_1.default.isAxiosError(error) ? ((_b = error.response) === null || _b === void 0 ? void 0 : _b.status) === http_status_codes_1.StatusCodes.NOT_FOUND : false;
|
|
221
222
|
if (notFoundInDatabase) {
|
|
222
|
-
this.logger.log(`Could not find valid client in database "${(
|
|
223
|
+
this.logger.log(`Could not find valid client in database "${(_c = this.storeEngine) === null || _c === void 0 ? void 0 : _c.storeName}".`);
|
|
223
224
|
return this.registerClient(loginData, clientInfo, entropyData);
|
|
224
225
|
}
|
|
225
226
|
if (notFoundOnBackend) {
|
|
@@ -233,9 +234,11 @@ class Account extends events_1.EventEmitter {
|
|
|
233
234
|
}
|
|
234
235
|
const context = await this.apiClient.init(loginData.clientType);
|
|
235
236
|
await this.initEngine(context);
|
|
236
|
-
return this.registerClient(loginData, clientInfo, entropyData);
|
|
237
237
|
}
|
|
238
|
-
this.
|
|
238
|
+
else if (this.storeEngine) {
|
|
239
|
+
this.logger.log('Last client was permanent - Deleting previous identity');
|
|
240
|
+
(0, identityClearer_1.deleteIdentity)(this.storeEngine);
|
|
241
|
+
}
|
|
239
242
|
return this.registerClient(loginData, clientInfo, entropyData);
|
|
240
243
|
}
|
|
241
244
|
throw error;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CRUDEngine } from '@wireapp/store-engine';
|
|
2
|
+
/**
|
|
3
|
+
* Will remove any information relative to the client identity.
|
|
4
|
+
* @param storeEngine The engine that currently holds the identity information
|
|
5
|
+
*/
|
|
6
|
+
export declare function deleteIdentity(storeEngine: CRUDEngine): Promise<boolean[]>;
|
|
7
|
+
//# sourceMappingURL=identityClearer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identityClearer.d.ts","sourceRoot":"","sources":["../../src/identity/identityClearer.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAKjD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAK1E"}
|
|
@@ -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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.deleteIdentity = void 0;
|
|
22
|
+
/** all the tables in the database that stores information relative to the client identity */
|
|
23
|
+
const IDENTITY_STORES = ['amplify', 'clients', 'keys', 'prekeys', 'sessions', 'group_ids'];
|
|
24
|
+
/**
|
|
25
|
+
* Will remove any information relative to the client identity.
|
|
26
|
+
* @param storeEngine The engine that currently holds the identity information
|
|
27
|
+
*/
|
|
28
|
+
function deleteIdentity(storeEngine) {
|
|
29
|
+
return Promise.all(
|
|
30
|
+
//make sure we use enum's lowercase values, not uppercase keys
|
|
31
|
+
IDENTITY_STORES.map(store => storeEngine.deleteAll(store)));
|
|
32
|
+
}
|
|
33
|
+
exports.deleteIdentity = deleteIdentity;
|