@wireapp/core 45.0.3 → 45.0.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.
@@ -26,8 +26,8 @@ export declare class E2EIServiceExternal extends TypedEventEmitter<Events> {
26
26
  clearAllProgress(): Promise<void>;
27
27
  getConversationState(conversationId: Uint8Array): Promise<E2eiConversationState>;
28
28
  isE2EIEnabled(): Promise<boolean>;
29
- getAllGroupUsersIdentities(groupId: string): Promise<Map<string, DeviceIdentity[]>>;
30
- getUsersIdentities(groupId: string, userIds: QualifiedId[]): Promise<Map<string, DeviceIdentity[]>>;
29
+ getAllGroupUsersIdentities(groupId: string): Promise<Map<string, DeviceIdentity[]> | undefined>;
30
+ getUsersIdentities(groupId: string, userIds: QualifiedId[]): Promise<Map<string, DeviceIdentity[]> | undefined>;
31
31
  getDevicesIdentities(groupId: string, userClientsMap: Record<string, QualifiedId>): Promise<DeviceIdentity[]>;
32
32
  isFreshMLSSelfClient(): Promise<boolean>;
33
33
  private registerLocalCertificateRoot;
@@ -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,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAC,UAAU,EAAE,qBAAqB,EAAE,YAAY,EAAE,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAMnG,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,YAAY,EAAC,MAAM,yBAAyB,CAAC;AAKrD,OAAO,EAAC,sBAAsB,EAAC,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAEzC,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,YAAY,EA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YAStB,+BAA+B;YAQ/B,uBAAuB;YAKvB,0BAA0B;YAI1B,eAAe;YAQf,4BAA4B;YAS5B,WAAW;YAkBX,8BAA8B;CAK7C"}
@@ -56,6 +56,10 @@ class E2EIServiceExternal extends commons_1.TypedEventEmitter {
56
56
  return this.coreCryptoClient.e2eiIsEnabled(this.mlsService.config.cipherSuite);
57
57
  }
58
58
  async getAllGroupUsersIdentities(groupId) {
59
+ const conversationExists = await this.mlsService.conversationExists(groupId);
60
+ if (!conversationExists) {
61
+ return undefined;
62
+ }
59
63
  const allGroupClients = await this.mlsService.getClientIds(groupId);
60
64
  const userIdsMap = allGroupClients.reduce((acc, { userId, domain }) => {
61
65
  const qualifiedId = { id: userId, domain };
@@ -66,6 +70,10 @@ class E2EIServiceExternal extends commons_1.TypedEventEmitter {
66
70
  return this.getUsersIdentities(groupId, userIds);
67
71
  }
68
72
  async getUsersIdentities(groupId, userIds) {
73
+ const conversationExists = await this.mlsService.conversationExists(groupId);
74
+ if (!conversationExists) {
75
+ return undefined;
76
+ }
69
77
  const groupIdBytes = bazinga64_1.Decoder.fromBase64(groupId).asBytes;
70
78
  const textDecoder = new TextDecoder();
71
79
  // we get all the devices that have an identity (either valid, expired or revoked)
@@ -32,6 +32,7 @@ async function buildE2EIService() {
32
32
  const mockedMLSService = {
33
33
  on: jest.fn(),
34
34
  getClientIds: jest.fn(),
35
+ conversationExists: jest.fn(),
35
36
  };
36
37
  const recurringTaskScheduler = new RecurringTaskScheduler_1.RecurringTaskScheduler({
37
38
  delete: key => mockedDb.delete('recurringTasks', key),
@@ -59,8 +60,18 @@ function generateCoreCryptoIdentity({ userId, status = 'Valid', deviceId = (0, P
59
60
  const groupId = 'AAEAAhJrE+8TbFFUqiagedTYDUMAZWxuYS53aXJlLmxpbms=';
60
61
  describe('E2EIServiceExternal', () => {
61
62
  describe('getUsersIdentities', () => {
63
+ it('returns undefined if conversation does not exist', async () => {
64
+ const [service, { mlsService }] = await buildE2EIService();
65
+ const user1 = { domain: 'elna.wire.link', id: '48a1c3b0-4b0e-4bcd-93ad-64c7344b1534' };
66
+ const user2 = { domain: 'elna.wire.link', id: 'b7d287e4-7bbd-40e0-a550-6b18dcaf5f31' };
67
+ const userIds = [user1, user2];
68
+ jest.spyOn(mlsService, 'conversationExists').mockResolvedValue(false);
69
+ const userIdentities = await service.getUsersIdentities(groupId, userIds);
70
+ expect(userIdentities === null || userIdentities === void 0 ? void 0 : userIdentities.get(user1.id)).toEqual(undefined);
71
+ expect(userIdentities === null || userIdentities === void 0 ? void 0 : userIdentities.get(user2.id)).toEqual(undefined);
72
+ });
62
73
  it('returns the user identities', async () => {
63
- const [service, { coreCrypto }] = await buildE2EIService();
74
+ const [service, { coreCrypto, mlsService }] = await buildE2EIService();
64
75
  const user1 = { domain: 'elna.wire.link', id: '48a1c3b0-4b0e-4bcd-93ad-64c7344b1534' };
65
76
  const user2 = { domain: 'elna.wire.link', id: 'b7d287e4-7bbd-40e0-a550-6b18dcaf5f31' };
66
77
  const userIds = [user1, user2];
@@ -68,12 +79,13 @@ describe('E2EIServiceExternal', () => {
68
79
  [user1.id, [generateCoreCryptoIdentity({ userId: user1.id }), generateCoreCryptoIdentity({ userId: user1.id })]],
69
80
  [user2.id, [generateCoreCryptoIdentity({ userId: user2.id })]],
70
81
  ]));
82
+ jest.spyOn(mlsService, 'conversationExists').mockResolvedValue(true);
71
83
  const userIdentities = await service.getUsersIdentities(groupId, userIds);
72
- expect(userIdentities.get(user1.id)).toHaveLength(2);
73
- expect(userIdentities.get(user2.id)).toHaveLength(1);
84
+ expect(userIdentities === null || userIdentities === void 0 ? void 0 : userIdentities.get(user1.id)).toHaveLength(2);
85
+ expect(userIdentities === null || userIdentities === void 0 ? void 0 : userIdentities.get(user2.id)).toHaveLength(1);
74
86
  });
75
87
  it('returns MLS basic devices with empty identity', async () => {
76
- const [service, { coreCrypto }] = await buildE2EIService();
88
+ const [service, { coreCrypto, mlsService }] = await buildE2EIService();
77
89
  const user1 = { domain: 'elna.wire.link', id: '48a1c3b0-4b0e-4bcd-93ad-64c7344b1534' };
78
90
  const user2 = { domain: 'elna.wire.link', id: 'b7d287e4-7bbd-40e0-a550-6b18dcaf5f31' };
79
91
  const userIds = [user1, user2];
@@ -89,12 +101,32 @@ describe('E2EIServiceExternal', () => {
89
101
  `${user2.id}:452cb4c65f0369a8@elna.wire.link`,
90
102
  ];
91
103
  coreCrypto.getClientIds.mockResolvedValue(allClients.map(clientId => encoder.encode(clientId)));
104
+ jest.spyOn(mlsService, 'conversationExists').mockResolvedValue(true);
92
105
  const userIdentities = await service.getUsersIdentities(groupId, userIds);
93
- expect(userIdentities.get(user1.id)).toHaveLength(3);
94
- expect(userIdentities.get(user2.id)).toHaveLength(1);
106
+ expect(userIdentities === null || userIdentities === void 0 ? void 0 : userIdentities.get(user1.id)).toHaveLength(3);
107
+ expect(userIdentities === null || userIdentities === void 0 ? void 0 : userIdentities.get(user2.id)).toHaveLength(1);
95
108
  });
96
109
  });
97
110
  describe('getAllGroupUsersIdentities', () => {
111
+ it('returns undefined if mls group does not exist', async () => {
112
+ const [service, { mlsService }] = await buildE2EIService();
113
+ const user1 = {
114
+ domain: 'elna.wire.link',
115
+ userId: '48a1c3b0-4b0e-4bcd-93ad-64c7344b1534',
116
+ clientId: '74a50c1f4352b41f',
117
+ };
118
+ const user2 = {
119
+ domain: 'elna.wire.link',
120
+ userId: 'b7d287e4-7bbd-40e0-a550-6b18dcaf5f31',
121
+ clientId: '452cb4c65f0369a8',
122
+ };
123
+ const clientIds = [user1, user2];
124
+ jest.spyOn(mlsService, 'getClientIds').mockResolvedValue(clientIds);
125
+ jest.spyOn(mlsService, 'conversationExists').mockResolvedValue(false);
126
+ const userIdentities = await service.getAllGroupUsersIdentities(groupId);
127
+ expect(userIdentities === null || userIdentities === void 0 ? void 0 : userIdentities.get(user1.userId)).toEqual(undefined);
128
+ expect(userIdentities === null || userIdentities === void 0 ? void 0 : userIdentities.get(user2.userId)).toEqual(undefined);
129
+ });
98
130
  it('returns all the user identities of a mls group', async () => {
99
131
  const [service, { coreCrypto, mlsService }] = await buildE2EIService();
100
132
  const user1 = {
@@ -109,6 +141,7 @@ describe('E2EIServiceExternal', () => {
109
141
  };
110
142
  const clientIds = [user1, user2];
111
143
  jest.spyOn(mlsService, 'getClientIds').mockResolvedValue(clientIds);
144
+ jest.spyOn(mlsService, 'conversationExists').mockResolvedValue(true);
112
145
  coreCrypto.getUserIdentities.mockResolvedValue(new Map([
113
146
  [
114
147
  user1.userId,
@@ -117,8 +150,8 @@ describe('E2EIServiceExternal', () => {
117
150
  [user2.userId, [generateCoreCryptoIdentity({ userId: user2.userId })]],
118
151
  ]));
119
152
  const userIdentities = await service.getAllGroupUsersIdentities(groupId);
120
- expect(userIdentities.get(user1.userId)).toHaveLength(2);
121
- expect(userIdentities.get(user2.userId)).toHaveLength(1);
153
+ expect(userIdentities === null || userIdentities === void 0 ? void 0 : userIdentities.get(user1.userId)).toHaveLength(2);
154
+ expect(userIdentities === null || userIdentities === void 0 ? void 0 : userIdentities.get(user2.userId)).toHaveLength(1);
122
155
  });
123
156
  });
124
157
  });
package/package.json CHANGED
@@ -60,6 +60,6 @@
60
60
  "test:coverage": "jest --coverage",
61
61
  "watch": "tsc --watch"
62
62
  },
63
- "version": "45.0.3",
64
- "gitHead": "6e9cc711b1997b28444f95a2c05a66d4437d1e3a"
63
+ "version": "45.0.4",
64
+ "gitHead": "64f68ecca609cf4650bf3cf88f9f88af42d8bcb5"
65
65
  }