@wireapp/core 34.0.2 → 34.1.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/package.json
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
"./src/main/cryptography/AssetCryptography/crypto.node": "./src/main/cryptography/AssetCryptography/crypto.browser.js"
|
|
4
4
|
},
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@wireapp/api-client": "^21.0.
|
|
6
|
+
"@wireapp/api-client": "^21.0.3",
|
|
7
7
|
"@wireapp/commons": "^4.4.10",
|
|
8
8
|
"@wireapp/core-crypto": "0.5.2",
|
|
9
9
|
"@wireapp/cryptobox": "12.8.0",
|
|
10
10
|
"@wireapp/promise-queue": "^1.3.4",
|
|
11
11
|
"@wireapp/protocol-messaging": "1.39.0",
|
|
12
|
-
"@wireapp/store-engine-dexie": "^1.7.
|
|
13
|
-
"axios": "^
|
|
12
|
+
"@wireapp/store-engine-dexie": "^1.7.11",
|
|
13
|
+
"axios": "^1.1.3",
|
|
14
14
|
"bazinga64": "5.11.10",
|
|
15
15
|
"hash.js": "1.1.7",
|
|
16
16
|
"http-status-codes": "2.2.0",
|
|
@@ -64,6 +64,6 @@
|
|
|
64
64
|
"test": "jest",
|
|
65
65
|
"watch": "tsc ---watch"
|
|
66
66
|
},
|
|
67
|
-
"version": "34.
|
|
68
|
-
"gitHead": "
|
|
67
|
+
"version": "34.1.1",
|
|
68
|
+
"gitHead": "097af2ac03f7edafca8c09724286cd6722f0a452"
|
|
69
69
|
}
|
package/src/main/Account.js
CHANGED
|
@@ -80,6 +80,7 @@ const encryptedStore_1 = require("./util/encryptedStore");
|
|
|
80
80
|
const bazinga64_1 = require("bazinga64");
|
|
81
81
|
const mls_1 = require("./mls");
|
|
82
82
|
const messageSender_1 = require("./conversation/message/messageSender");
|
|
83
|
+
const axios_1 = __importDefault(require("axios"));
|
|
83
84
|
var TOPIC;
|
|
84
85
|
(function (TOPIC) {
|
|
85
86
|
TOPIC["ERROR"] = "Account.TOPIC.ERROR";
|
|
@@ -233,7 +234,7 @@ class Account extends events_1.EventEmitter {
|
|
|
233
234
|
error.constructor.name === 'CryptoboxError' ||
|
|
234
235
|
error instanceof store_engine_1.error.RecordNotFoundError ||
|
|
235
236
|
error.constructor.name === store_engine_1.error.RecordNotFoundError.name;
|
|
236
|
-
const notFoundOnBackend = ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === http_status_codes_1.StatusCodes.NOT_FOUND;
|
|
237
|
+
const notFoundOnBackend = axios_1.default.isAxiosError(error) ? ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === http_status_codes_1.StatusCodes.NOT_FOUND : false;
|
|
237
238
|
if (notFoundInDatabase) {
|
|
238
239
|
this.logger.log(`Could not find valid client in database "${(_b = this.storeEngine) === null || _b === void 0 ? void 0 : _b.storeName}".`);
|
|
239
240
|
return this.registerClient(loginData, clientInfo, entropyData);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { APIClient } from '@wireapp/api-client';
|
|
2
|
-
import { PreKey
|
|
2
|
+
import { PreKey } from '@wireapp/api-client/src/auth/';
|
|
3
3
|
import { RegisteredClient } from '@wireapp/api-client/src/client/';
|
|
4
4
|
import { OTRRecipients, QualifiedOTRRecipients, QualifiedUserClients, UserClients } from '@wireapp/api-client/src/conversation/';
|
|
5
5
|
import { ConversationOtrMessageAddEvent } from '@wireapp/api-client/src/event';
|
|
@@ -49,7 +49,7 @@ export declare class CryptographyService {
|
|
|
49
49
|
onNewSession?: (sessionId: SessionId) => void;
|
|
50
50
|
}): void;
|
|
51
51
|
static convertBase64RecipientsToArray(recipients: OTRRecipients<string>): OTRRecipients<Uint8Array>;
|
|
52
|
-
createCryptobox(entropyData?: Uint8Array): Promise<
|
|
52
|
+
createCryptobox(entropyData?: Uint8Array): Promise<PreKey[]>;
|
|
53
53
|
decrypt(sessionId: string, encodedCiphertext: string): Promise<Uint8Array>;
|
|
54
54
|
encryptQualified(plainText: Uint8Array, preKeyBundles: QualifiedUserPreKeyBundleMap | QualifiedUserClients): Promise<{
|
|
55
55
|
missing: QualifiedUserClients;
|
|
@@ -61,6 +61,20 @@ export declare class CryptographyService {
|
|
|
61
61
|
}>;
|
|
62
62
|
private encryptPayloadForSession;
|
|
63
63
|
initCryptobox(): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Get the fingerprint of the local client.
|
|
66
|
+
*/
|
|
67
|
+
getLocalFingerprint(): string;
|
|
68
|
+
/**
|
|
69
|
+
* Get the fingerprint of a remote client
|
|
70
|
+
* @param userId ID of user
|
|
71
|
+
* @param clientId ID of client
|
|
72
|
+
* @param prekey A prekey can be given to create a session if it doesn't already exist.
|
|
73
|
+
* If not provided and the session doesn't exists it will fetch a new prekey from the backend
|
|
74
|
+
*/
|
|
75
|
+
getRemoteFingerprint(userId: QualifiedId, clientId: string, prekey?: PreKey): Promise<string>;
|
|
76
|
+
private getOrCreateSession;
|
|
77
|
+
private getUserPrekey;
|
|
64
78
|
deleteCryptographyStores(): Promise<boolean[]>;
|
|
65
79
|
resetSession(sessionId: string): Promise<void>;
|
|
66
80
|
decryptMessage(otrMessage: ConversationOtrMessageAddEvent): Promise<GenericMessage>;
|
|
@@ -170,6 +170,37 @@ class CryptographyService {
|
|
|
170
170
|
async initCryptobox() {
|
|
171
171
|
await this.cryptobox.load();
|
|
172
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* Get the fingerprint of the local client.
|
|
175
|
+
*/
|
|
176
|
+
getLocalFingerprint() {
|
|
177
|
+
return this.cryptobox.getIdentity().public_key.fingerprint();
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Get the fingerprint of a remote client
|
|
181
|
+
* @param userId ID of user
|
|
182
|
+
* @param clientId ID of client
|
|
183
|
+
* @param prekey A prekey can be given to create a session if it doesn't already exist.
|
|
184
|
+
* If not provided and the session doesn't exists it will fetch a new prekey from the backend
|
|
185
|
+
*/
|
|
186
|
+
async getRemoteFingerprint(userId, clientId, prekey) {
|
|
187
|
+
const session = await this.getOrCreateSession(userId, clientId, prekey);
|
|
188
|
+
return session.fingerprint_remote();
|
|
189
|
+
}
|
|
190
|
+
async getOrCreateSession(userId, clientId, initialPrekey) {
|
|
191
|
+
const sessionId = this.constructSessionId(userId, clientId);
|
|
192
|
+
try {
|
|
193
|
+
return await this.cryptobox.session_load(sessionId);
|
|
194
|
+
}
|
|
195
|
+
catch (error) {
|
|
196
|
+
const prekey = initialPrekey !== null && initialPrekey !== void 0 ? initialPrekey : (await this.getUserPrekey(userId, clientId)).prekey;
|
|
197
|
+
const prekeyBuffer = bazinga64_1.Decoder.fromBase64(prekey.key).asBytes;
|
|
198
|
+
return this.cryptobox.session_from_prekey(sessionId, prekeyBuffer.buffer);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
getUserPrekey(userId, clientId) {
|
|
202
|
+
return this.apiClient.api.user.getClientPreKey(userId, clientId);
|
|
203
|
+
}
|
|
173
204
|
deleteCryptographyStores() {
|
|
174
205
|
return this.database.deleteStores();
|
|
175
206
|
}
|