@wireapp/core 43.1.3 → 43.1.4
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/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.d.ts +3 -2
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.js +17 -3
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.test.js +29 -6
- package/lib/util/fullyQualifiedClientIdUtils.d.ts +3 -2
- package/lib/util/fullyQualifiedClientIdUtils.d.ts.map +1 -1
- package/package.json +6 -6
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { QualifiedId } from '@wireapp/api-client/lib/user';
|
|
2
|
-
import { Ciphersuite, CoreCrypto, E2eiConversationState, WireIdentity } from '@wireapp/core-crypto';
|
|
2
|
+
import { Ciphersuite, CoreCrypto, E2eiConversationState, WireIdentity, DeviceStatus } from '@wireapp/core-crypto';
|
|
3
3
|
import { ClientService } from '../../../client';
|
|
4
|
-
export type DeviceIdentity = Omit<WireIdentity, 'free'> & {
|
|
4
|
+
export type DeviceIdentity = Omit<WireIdentity, 'free' | 'status'> & {
|
|
5
|
+
status?: DeviceStatus;
|
|
5
6
|
deviceId: string;
|
|
6
7
|
};
|
|
7
8
|
export declare class E2EIServiceExternal {
|
|
@@ -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/mess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class E2EIServiceExternal {
|
|
|
62
62
|
return this.coreCryptoClient.e2eiIsEnabled(ciphersuite);
|
|
63
63
|
}
|
|
64
64
|
async getUsersIdentities(groupId, userIds) {
|
|
65
|
-
const
|
|
65
|
+
const groupIdBytes = bazinga64_1.Decoder.fromBase64(groupId).asBytes;
|
|
66
|
+
const textDecoder = new TextDecoder();
|
|
67
|
+
// we get all the devices that have an identity (either valid, expired or revoked)
|
|
68
|
+
const userIdentities = await this.coreCryptoClient.getUserIdentities(groupIdBytes, userIds.map(userId => userId.id));
|
|
69
|
+
// We get all the devices in the conversation (in order to get devices that have no identity)
|
|
70
|
+
const allUsersMLSDevices = (await this.coreCryptoClient.getClientIds(groupIdBytes))
|
|
71
|
+
.map(id => textDecoder.decode(id))
|
|
72
|
+
.map(fullyQualifiedId => (0, fullyQualifiedClientIdUtils_1.parseFullQualifiedClientId)(fullyQualifiedId));
|
|
66
73
|
const mappedUserIdentities = new Map();
|
|
67
|
-
for (const
|
|
68
|
-
|
|
74
|
+
for (const userId of userIds) {
|
|
75
|
+
const identities = (userIdentities.get(userId.id) || []).map(identity => (Object.assign(Object.assign({}, identity), { deviceId: (0, fullyQualifiedClientIdUtils_1.parseFullQualifiedClientId)(identity.client_id).client })));
|
|
76
|
+
const basicMLSDevices = allUsersMLSDevices
|
|
77
|
+
.filter(({ user }) => user === userId.id)
|
|
78
|
+
// filtering devices that have a valid identity
|
|
79
|
+
.filter(({ client }) => !identities.map(identity => identity.deviceId).includes(client))
|
|
80
|
+
// map basic MLS devices to "fake" identity object
|
|
81
|
+
.map(id => (Object.assign(Object.assign({}, id), { deviceId: id.client, thumbprint: '', user: '', certificate: '', displayName: '', handle: '', clientId: id.client })));
|
|
82
|
+
mappedUserIdentities.set(userId.id, [...identities, ...basicMLSDevices]);
|
|
69
83
|
}
|
|
70
84
|
return mappedUserIdentities;
|
|
71
85
|
}
|
|
@@ -19,16 +19,18 @@
|
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
const E2EIServiceExternal_1 = require("./E2EIServiceExternal");
|
|
22
|
+
const PayloadHelper_1 = require("../../../test/PayloadHelper");
|
|
22
23
|
function buildE2EIService() {
|
|
23
24
|
const coreCrypto = {
|
|
24
25
|
getUserIdentities: jest.fn(),
|
|
26
|
+
getClientIds: jest.fn().mockResolvedValue([]),
|
|
25
27
|
};
|
|
26
28
|
const clientService = {};
|
|
27
29
|
return [new E2EIServiceExternal_1.E2EIServiceExternal(coreCrypto, clientService), { coreCrypto }];
|
|
28
30
|
}
|
|
29
|
-
function generateCoreCryptoIdentity({ status = 'Valid', deviceId =
|
|
31
|
+
function generateCoreCryptoIdentity({ userId, status = 'Valid', deviceId = (0, PayloadHelper_1.getUUID)(), }) {
|
|
30
32
|
return {
|
|
31
|
-
client_id:
|
|
33
|
+
client_id: `${userId}:${deviceId}@elna.wire.link`,
|
|
32
34
|
handle: 'adrian_wire2@elna.wire.link',
|
|
33
35
|
display_name: 'Adrian Weiss 2',
|
|
34
36
|
domain: 'elna.wire.link',
|
|
@@ -46,12 +48,33 @@ describe('E2EIServiceExternal', () => {
|
|
|
46
48
|
const user2 = { domain: 'elna.wire.link', id: 'b7d287e4-7bbd-40e0-a550-6b18dcaf5f31' };
|
|
47
49
|
const userIds = [user1, user2];
|
|
48
50
|
coreCrypto.getUserIdentities.mockResolvedValue(new Map([
|
|
49
|
-
[
|
|
50
|
-
[
|
|
51
|
+
[user1.id, [generateCoreCryptoIdentity({ userId: user1.id }), generateCoreCryptoIdentity({ userId: user1.id })]],
|
|
52
|
+
[user2.id, [generateCoreCryptoIdentity({ userId: user2.id })]],
|
|
51
53
|
]));
|
|
52
54
|
const userIdentities = await service.getUsersIdentities(groupId, userIds);
|
|
53
|
-
expect(userIdentities.get(user1.id)).
|
|
54
|
-
expect(userIdentities.get(user2.id)).
|
|
55
|
+
expect(userIdentities.get(user1.id)).toHaveLength(2);
|
|
56
|
+
expect(userIdentities.get(user2.id)).toHaveLength(1);
|
|
57
|
+
});
|
|
58
|
+
it('returns MLS basic devices with empty identity', async () => {
|
|
59
|
+
const [service, { coreCrypto }] = buildE2EIService();
|
|
60
|
+
const user1 = { domain: 'elna.wire.link', id: '48a1c3b0-4b0e-4bcd-93ad-64c7344b1534' };
|
|
61
|
+
const user2 = { domain: 'elna.wire.link', id: 'b7d287e4-7bbd-40e0-a550-6b18dcaf5f31' };
|
|
62
|
+
const userIds = [user1, user2];
|
|
63
|
+
const user1Identities = [
|
|
64
|
+
generateCoreCryptoIdentity({ userId: user1.id }),
|
|
65
|
+
generateCoreCryptoIdentity({ userId: user1.id }),
|
|
66
|
+
];
|
|
67
|
+
const encoder = new TextEncoder();
|
|
68
|
+
coreCrypto.getUserIdentities.mockResolvedValue(new Map([[user1.id, user1Identities]]));
|
|
69
|
+
const allClients = [
|
|
70
|
+
...user1Identities.map(identity => identity.client_id),
|
|
71
|
+
`${user1.id}:74a50c1f4352b41f@elna.wire.link`,
|
|
72
|
+
`${user2.id}:452cb4c65f0369a8@elna.wire.link`,
|
|
73
|
+
];
|
|
74
|
+
coreCrypto.getClientIds.mockResolvedValue(allClients.map(clientId => encoder.encode(clientId)));
|
|
75
|
+
const userIdentities = await service.getUsersIdentities(groupId, userIds);
|
|
76
|
+
expect(userIdentities.get(user1.id)).toHaveLength(3);
|
|
77
|
+
expect(userIdentities.get(user2.id)).toHaveLength(1);
|
|
55
78
|
});
|
|
56
79
|
});
|
|
57
80
|
});
|
|
@@ -3,12 +3,13 @@ type UserId = string;
|
|
|
3
3
|
type ClientId = string;
|
|
4
4
|
type Domain = string;
|
|
5
5
|
export type ClientIdStringType = `${UserId}:${ClientId}@${Domain}`;
|
|
6
|
-
export
|
|
7
|
-
export declare const parseFullQualifiedClientId: (qualifiedId: string) => {
|
|
6
|
+
export type ParsedFullyQualifiedId = {
|
|
8
7
|
user: UserId;
|
|
9
8
|
client: ClientId;
|
|
10
9
|
domain: Domain;
|
|
11
10
|
};
|
|
11
|
+
export declare const constructFullyQualifiedClientId: (userId: UserId, clientId: ClientId, domain: Domain) => ClientIdStringType;
|
|
12
|
+
export declare const parseFullQualifiedClientId: (qualifiedId: string) => ParsedFullyQualifiedId;
|
|
12
13
|
export declare const mapQualifiedUserClientIdsToFullyQualifiedClientIds: (qualifiedUserMap: QualifiedUserClientMap) => `${string}:${string}@${string}`[];
|
|
13
14
|
export {};
|
|
14
15
|
//# sourceMappingURL=fullyQualifiedClientIdUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fullyQualifiedClientIdUtils.d.ts","sourceRoot":"","sources":["../../src/util/fullyQualifiedClientIdUtils.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,sBAAsB,EAAC,MAAM,gCAAgC,CAAC;AAEtE,KAAK,MAAM,GAAG,MAAM,CAAC;AACrB,KAAK,QAAQ,GAAG,MAAM,CAAC;AACvB,KAAK,MAAM,GAAG,MAAM,CAAC;AACrB,MAAM,MAAM,kBAAkB,GAAG,GAAG,MAAM,IAAI,QAAQ,IAAI,MAAM,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"fullyQualifiedClientIdUtils.d.ts","sourceRoot":"","sources":["../../src/util/fullyQualifiedClientIdUtils.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,sBAAsB,EAAC,MAAM,gCAAgC,CAAC;AAEtE,KAAK,MAAM,GAAG,MAAM,CAAC;AACrB,KAAK,QAAQ,GAAG,MAAM,CAAC;AACvB,KAAK,MAAM,GAAG,MAAM,CAAC;AACrB,MAAM,MAAM,kBAAkB,GAAG,GAAG,MAAM,IAAI,QAAQ,IAAI,MAAM,EAAE,CAAC;AACnE,MAAM,MAAM,sBAAsB,GAAG;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAC,CAAC;AAEtF,eAAO,MAAM,+BAA+B,WAClC,MAAM,YACJ,QAAQ,UACV,MAAM,KACb,kBAAuD,CAAC;AAE3D,eAAO,MAAM,0BAA0B,gBAAiB,MAAM,KAAG,sBAOhE,CAAC;AAEF,eAAO,MAAM,kDAAkD,qBAAsB,sBAAsB,sCAO1G,CAAC"}
|
package/package.json
CHANGED
|
@@ -11,16 +11,16 @@
|
|
|
11
11
|
"./lib/cryptography/AssetCryptography/crypto.node": "./lib/cryptography/AssetCryptography/crypto.browser.js"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@wireapp/api-client": "^26.7.
|
|
14
|
+
"@wireapp/api-client": "^26.7.2",
|
|
15
15
|
"@wireapp/commons": "^5.2.3",
|
|
16
16
|
"@wireapp/core-crypto": "1.0.0-rc.21",
|
|
17
17
|
"@wireapp/cryptobox": "12.8.0",
|
|
18
18
|
"@wireapp/promise-queue": "^2.2.8",
|
|
19
19
|
"@wireapp/protocol-messaging": "1.44.0",
|
|
20
|
-
"@wireapp/store-engine": "5.1.
|
|
21
|
-
"@wireapp/store-engine-dexie": "^2.1.
|
|
20
|
+
"@wireapp/store-engine": "5.1.5",
|
|
21
|
+
"@wireapp/store-engine-dexie": "^2.1.7",
|
|
22
22
|
"axios": "1.6.2",
|
|
23
|
-
"bazinga64": "^6.3.
|
|
23
|
+
"bazinga64": "^6.3.4",
|
|
24
24
|
"deepmerge-ts": "5.1.0",
|
|
25
25
|
"hash.js": "1.1.7",
|
|
26
26
|
"http-status-codes": "2.3.0",
|
|
@@ -61,6 +61,6 @@
|
|
|
61
61
|
"test:coverage": "jest --coverage",
|
|
62
62
|
"watch": "tsc --watch"
|
|
63
63
|
},
|
|
64
|
-
"version": "43.1.
|
|
65
|
-
"gitHead": "
|
|
64
|
+
"version": "43.1.4",
|
|
65
|
+
"gitHead": "0008113a715828f838fbb8f0eeb1844be78747ab"
|
|
66
66
|
}
|