@wireapp/core 42.22.1 → 42.23.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/lib/Account.js +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.d.ts +7 -6
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.js +18 -14
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.test.d.ts +2 -0
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.test.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.test.js +56 -0
- package/lib/messagingProtocols/mls/MLSService/MLSService.js +1 -1
- package/lib/notification/NotificationService.js +3 -2
- package/package.json +3 -3
package/lib/Account.js
CHANGED
|
@@ -321,7 +321,7 @@ class Account extends commons_1.TypedEventEmitter {
|
|
|
321
321
|
let mlsService;
|
|
322
322
|
let e2eIdentityService;
|
|
323
323
|
if (clientType === CryptoClient_1.CryptoClientType.CORE_CRYPTO && (await this.isMlsEnabled())) {
|
|
324
|
-
e2eIdentityService =
|
|
324
|
+
e2eIdentityService = new E2EIdentityService_1.E2EIServiceExternal(cryptoClient.getNativeClient());
|
|
325
325
|
mlsService = new mls_1.MLSService(this.apiClient, cryptoClient.getNativeClient(), this.db, this.recurringTaskScheduler, Object.assign({}, (_a = this.cryptoProtocolConfig) === null || _a === void 0 ? void 0 : _a.mls));
|
|
326
326
|
}
|
|
327
327
|
const proteusService = new proteus_1.ProteusService(this.apiClient, cryptoClient, {
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { QualifiedId } from '@wireapp/api-client/lib/user';
|
|
2
2
|
import { Ciphersuite, CoreCrypto, E2eiConversationState, WireIdentity } from '@wireapp/core-crypto';
|
|
3
|
+
export type DeviceIdentity = Omit<WireIdentity, 'free'> & {
|
|
4
|
+
deviceId: string;
|
|
5
|
+
};
|
|
3
6
|
export declare class E2EIServiceExternal {
|
|
4
|
-
private
|
|
7
|
+
private coreCryptoClient;
|
|
5
8
|
private readonly logger;
|
|
6
|
-
|
|
7
|
-
private constructor();
|
|
8
|
-
static getInstance(coreCryptoClient: CoreCrypto): Promise<E2EIServiceExternal>;
|
|
9
|
+
constructor(coreCryptoClient: CoreCrypto);
|
|
9
10
|
hasActiveCertificate(): boolean;
|
|
10
11
|
getCertificateData(): string | undefined;
|
|
11
12
|
isEnrollmentInProgress(): boolean;
|
|
12
13
|
clearAllProgress(): void;
|
|
13
14
|
getConversationState(conversationId: Uint8Array): Promise<E2eiConversationState>;
|
|
14
15
|
isE2EIEnabled(ciphersuite: Ciphersuite): Promise<boolean>;
|
|
15
|
-
getUsersIdentities(groupId: string, userIds: QualifiedId[]): Promise<Map<string,
|
|
16
|
-
|
|
16
|
+
getUsersIdentities(groupId: string, userIds: QualifiedId[]): Promise<Map<string, DeviceIdentity[]>>;
|
|
17
|
+
getDevicesIdentities(groupId: string, userClientsMap: Record<string, QualifiedId>): Promise<DeviceIdentity[]>;
|
|
17
18
|
}
|
|
18
19
|
//# sourceMappingURL=E2EIServiceExternal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"E2EIServiceExternal.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAIzD,OAAO,EAAC,WAAW,EAAE,UAAU,EAAE,qBAAqB,EAAE,YAAY,EAAC,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"E2EIServiceExternal.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAIzD,OAAO,EAAC,WAAW,EAAE,UAAU,EAAE,qBAAqB,EAAE,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAOlG,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,CAAC;AAG7E,qBAAa,mBAAmB;IAGX,OAAO,CAAC,gBAAgB;IAF3C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuD;gBAEnD,gBAAgB,EAAE,UAAU;IAGhD,oBAAoB,IAAI,OAAO;IAK/B,kBAAkB,IAAI,MAAM,GAAG,SAAS;IAUxC,sBAAsB,IAAI,OAAO;IAIjC,gBAAgB,IAAI,IAAI;IAIxB,oBAAoB,CAAC,cAAc,EAAE,UAAU,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAIhF,aAAa,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;IAInD,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC;IA4BnG,oBAAoB,CAC/B,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAC1C,OAAO,CAAC,cAAc,EAAE,CAAC;CAc7B"}
|
|
@@ -26,20 +26,12 @@ const bazinga64_1 = require("bazinga64");
|
|
|
26
26
|
const logdown_1 = __importDefault(require("logdown"));
|
|
27
27
|
const Helper_1 = require("./Helper");
|
|
28
28
|
const E2EIStorage_1 = require("./Storage/E2EIStorage");
|
|
29
|
+
const fullyQualifiedClientIdUtils_1 = require("../../../util/fullyQualifiedClientIdUtils");
|
|
29
30
|
// This export is meant to be accessible from the outside (e.g the Webapp / UI)
|
|
30
31
|
class E2EIServiceExternal {
|
|
31
|
-
constructor(
|
|
32
|
+
constructor(coreCryptoClient) {
|
|
33
|
+
this.coreCryptoClient = coreCryptoClient;
|
|
32
34
|
this.logger = (0, logdown_1.default)('@wireapp/core/E2EIdentityServiceExternal');
|
|
33
|
-
this.coreCryptoClient = coreCryptClient;
|
|
34
|
-
}
|
|
35
|
-
static async getInstance(coreCryptoClient) {
|
|
36
|
-
if (!E2EIServiceExternal.instance) {
|
|
37
|
-
if (!coreCryptoClient) {
|
|
38
|
-
throw new Error('E2EIServiceExternal is not initialized. Please call getInstance with params.');
|
|
39
|
-
}
|
|
40
|
-
E2EIServiceExternal.instance = new E2EIServiceExternal(coreCryptoClient);
|
|
41
|
-
}
|
|
42
|
-
return E2EIServiceExternal.instance;
|
|
43
35
|
}
|
|
44
36
|
// Checks if there is a certificate stored in the local storage
|
|
45
37
|
hasActiveCertificate() {
|
|
@@ -69,12 +61,24 @@ class E2EIServiceExternal {
|
|
|
69
61
|
return this.coreCryptoClient.e2eiIsEnabled(ciphersuite);
|
|
70
62
|
}
|
|
71
63
|
async getUsersIdentities(groupId, userIds) {
|
|
72
|
-
|
|
64
|
+
// We keep track of the ID we give to CoreCrypto in order to map it back to regular userIds afterwards
|
|
65
|
+
const hashedIdMap = new Map(userIds.map(userId => [(0, Helper_1.uuidTobase64url)(userId.id).asString, userId]));
|
|
66
|
+
const userIdentities = await this.coreCryptoClient.getUserIdentities(bazinga64_1.Decoder.fromBase64(groupId).asBytes, Array.from(hashedIdMap.keys()));
|
|
67
|
+
const mappedUserIdentities = new Map();
|
|
68
|
+
for (const [base64Id, identities] of userIdentities) {
|
|
69
|
+
// remapping coreCrypto user ids to regular userIds
|
|
70
|
+
const userId = hashedIdMap.get(base64Id);
|
|
71
|
+
if (userId) {
|
|
72
|
+
mappedUserIdentities.set(userId.id, identities.map(identity => (Object.assign(Object.assign({}, identity), { deviceId: (0, fullyQualifiedClientIdUtils_1.parseFullQualifiedClientId)(identity.client_id).client }))));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return mappedUserIdentities;
|
|
73
76
|
}
|
|
74
77
|
// Returns devices e2ei certificates
|
|
75
|
-
async
|
|
78
|
+
async getDevicesIdentities(groupId, userClientsMap) {
|
|
76
79
|
const clientIds = Object.entries(userClientsMap).map(([clientId, userId]) => (0, Helper_1.getE2EIClientId)(clientId, userId.id, userId.domain).asBytes);
|
|
77
|
-
|
|
80
|
+
const deviceIdentities = await this.coreCryptoClient.getDeviceIdentities(bazinga64_1.Decoder.fromBase64(groupId).asBytes, clientIds);
|
|
81
|
+
return deviceIdentities.map(identity => (Object.assign(Object.assign({}, identity), { deviceId: (0, fullyQualifiedClientIdUtils_1.parseFullQualifiedClientId)(identity.client_id).client })));
|
|
78
82
|
}
|
|
79
83
|
}
|
|
80
84
|
exports.E2EIServiceExternal = E2EIServiceExternal;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"E2EIServiceExternal.test.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Wire
|
|
4
|
+
* Copyright (C) 2023 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
|
+
const E2EIServiceExternal_1 = require("./E2EIServiceExternal");
|
|
22
|
+
function buildE2EIService() {
|
|
23
|
+
const coreCrypto = {
|
|
24
|
+
getUserIdentities: jest.fn(),
|
|
25
|
+
};
|
|
26
|
+
return [new E2EIServiceExternal_1.E2EIServiceExternal(coreCrypto), { coreCrypto }];
|
|
27
|
+
}
|
|
28
|
+
function generateCoreCryptoIdentity({ status = 'Valid', deviceId = 'aaaaa' } = {}) {
|
|
29
|
+
return {
|
|
30
|
+
client_id: `SKHDsEsOS82TrWTHNEsVNA:${deviceId}@elna.wire.link`,
|
|
31
|
+
handle: 'adrian_wire2@elna.wire.link',
|
|
32
|
+
display_name: 'Adrian Weiss 2',
|
|
33
|
+
domain: 'elna.wire.link',
|
|
34
|
+
certificate: '-----BEGIN CERTIFICATE-----\nMIICRTCCAeqgAwIBAgIQcpcbKbgHLM5qoB7xgxm6BTAKBggqhkjOPQQDAjAuMSww\nKgYDVQQDEyNlbG5hLndpcmUubGluayBFMkVJIEludGVybWVkaWF0ZSBDQTAeFw0y\nMzExMjIxMTIwMDVaFw0yMzExMjQxMTIwMDVaMDIxFzAVBgNVBAoTDmVsbmEud2ly\nZS5saW5rMRcwFQYDVQQDEw5BZHJpYW4gV2Vpc3MgMjAqMAUGAytlcAMhAMwP5B9X\nwanLL7JUmHEc1SJYAvHUvMnL1MS/D4CK3JaMo4IBEzCCAQ8wDgYDVR0PAQH/BAQD\nAgeAMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAdBgNVHQ4EFgQUrIPC\nem20zAl1ybZqXm2LkvD2U1swHwYDVR0jBBgwFoAU5bQTjX1Ps09suTYe4tzXUKgl\nN9YwdwYDVR0RBHAwboYpaW06d2lyZWFwcD0lNDBhZHJpYW5fd2lyZTJAZWxuYS53\naXJlLmxpbmuGQWltOndpcmVhcHA9U0tIRHNFc09TODJUcldUSE5Fc1ZOQS9lYjll\nMDM4NjE4MzllOWRhQGVsbmEud2lyZS5saW5rMCUGDCsGAQQBgqRkxihAAQQVMBMC\nAQYEDGRlZmF1bHR0ZWFtcwQAMAoGCCqGSM49BAMCA0kAMEYCIQCQQHVAd6wjp2A+\nVvKIXu4oVlCMZkAUATU5bXY4njvapwIhAO8rION7Mz5rSjixJsdEL8E+HHsNvCax\ndjrSL0FL9SM6\n-----END CERTIFICATE-----\n',
|
|
35
|
+
status,
|
|
36
|
+
thumbprint: 'mNyAo88vAF5s7v0UWBNxlQKxP3dfT91A-4PbuzEA5uQ',
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
const groupId = 'AAEAAhJrE+8TbFFUqiagedTYDUMAZWxuYS53aXJlLmxpbms=';
|
|
40
|
+
describe('E2EIServiceExternal', () => {
|
|
41
|
+
describe('getUsersIdentities', () => {
|
|
42
|
+
it('returns the user identities', async () => {
|
|
43
|
+
const [service, { coreCrypto }] = buildE2EIService();
|
|
44
|
+
const user1 = { domain: 'elna.wire.link', id: '48a1c3b0-4b0e-4bcd-93ad-64c7344b1534' };
|
|
45
|
+
const user2 = { domain: 'elna.wire.link', id: 'b7d287e4-7bbd-40e0-a550-6b18dcaf5f31' };
|
|
46
|
+
const userIds = [user1, user2];
|
|
47
|
+
coreCrypto.getUserIdentities.mockResolvedValue(new Map([
|
|
48
|
+
['SKHDsEsOS82TrWTHNEsVNA', [generateCoreCryptoIdentity(), generateCoreCryptoIdentity()]],
|
|
49
|
+
['t9KH5Hu9QOClUGsY3K9fMQ', [generateCoreCryptoIdentity()]],
|
|
50
|
+
]));
|
|
51
|
+
const userIdentities = await service.getUsersIdentities(groupId, userIds);
|
|
52
|
+
expect(userIdentities.get(user1.id)).toBeDefined();
|
|
53
|
+
expect(userIdentities.get(user2.id)).toBeDefined();
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
});
|
|
@@ -53,7 +53,7 @@ const optionalToUint8Array = (array) => {
|
|
|
53
53
|
};
|
|
54
54
|
exports.optionalToUint8Array = optionalToUint8Array;
|
|
55
55
|
const defaultConfig = {
|
|
56
|
-
keyingMaterialUpdateThreshold: 1000 * 60 * 60 * 24 * 30,
|
|
56
|
+
keyingMaterialUpdateThreshold: 1000 * 60 * 60 * 24 * 30, //30 days
|
|
57
57
|
nbKeyPackages: 100,
|
|
58
58
|
defaultCiphersuite: core_crypto_1.Ciphersuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519,
|
|
59
59
|
defaultCredentialType: core_crypto_1.CredentialType.Basic,
|
|
@@ -21,8 +21,9 @@ var __await = (this && this.__await) || function (v) { return this instanceof __
|
|
|
21
21
|
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
22
22
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
23
23
|
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
24
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
25
|
-
function
|
|
24
|
+
return i = {}, verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
25
|
+
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
26
|
+
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
26
27
|
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
27
28
|
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
28
29
|
function fulfill(value) { resume("next", value); }
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"./lib/cryptography/AssetCryptography/crypto.node": "./lib/cryptography/AssetCryptography/crypto.browser.js"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@wireapp/api-client": "^26.5.
|
|
14
|
+
"@wireapp/api-client": "^26.5.4",
|
|
15
15
|
"@wireapp/commons": "^5.2.3",
|
|
16
16
|
"@wireapp/core-crypto": "1.0.0-rc.19",
|
|
17
17
|
"@wireapp/cryptobox": "12.8.0",
|
|
@@ -61,6 +61,6 @@
|
|
|
61
61
|
"test:coverage": "jest --coverage",
|
|
62
62
|
"watch": "tsc --watch"
|
|
63
63
|
},
|
|
64
|
-
"version": "42.
|
|
65
|
-
"gitHead": "
|
|
64
|
+
"version": "42.23.0",
|
|
65
|
+
"gitHead": "51af8002058b19edf83bb7b306a35217114087f2"
|
|
66
66
|
}
|