Skip to content

Commit

Permalink
runfix: identify mls capable client (#15841)
Browse files Browse the repository at this point in the history
* feat: bump core with correct mls public key type

* runfix: identify client as mls capable

* refactor: simplify return statement
  • Loading branch information
PatrykBuniX authored Sep 18, 2023
1 parent 2914fe6 commit 1fda360
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"@datadog/browser-rum": "^4.49.0",
"@emotion/react": "11.11.1",
"@wireapp/avs": "9.3.7",
"@wireapp/core": "42.3.3",
"@wireapp/core": "42.3.4",
"@wireapp/lru-cache": "3.8.1",
"@wireapp/react-ui-kit": "9.9.5",
"@wireapp/store-engine-dexie": "2.1.6",
Expand Down
4 changes: 2 additions & 2 deletions src/script/client/ClientRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import {constructClientId, parseClientId} from './ClientIdUtil';
import {ClientMapper} from './ClientMapper';
import type {ClientService} from './ClientService';
import {ClientState} from './ClientState';
import {wasClientActiveWithinLast4Weeks} from './ClientUtils';
import {isClientMLSCapable, wasClientActiveWithinLast4Weeks} from './ClientUtils';

import {SIGN_OUT_REASON} from '../auth/SignOutReason';
import {PrimaryModal} from '../components/Modals/PrimaryModal';
Expand Down Expand Up @@ -589,6 +589,6 @@ export class ClientRepository {
const selfClients = await this.getAllSelfClients();
//we consider client active if it was active within last 4 weeks
const activeClients = selfClients.filter(wasClientActiveWithinLast4Weeks);
return activeClients.every(client => !!client.mls_public_keys);
return activeClients.every(isClientMLSCapable);
}
}
10 changes: 10 additions & 0 deletions src/script/client/ClientUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,13 @@ export const wasClientActiveWithinLast4Weeks = ({last_active: lastActiveISODate}
const passedWeeksSinceLastActive = weeksPassedSinceDate(new Date(lastActiveISODate));
return passedWeeksSinceLastActive <= 4;
};

/**
* Check if client is MLS-capable device.
* Client is considered MLS capable if it was registered and has uploaded MLS public keys.
* @param client - client to check
* @returns {boolean}
*/
export const isClientMLSCapable = ({mls_public_keys: mlsPublicKeys}: RegisteredClient): boolean => {
return Object.values(mlsPublicKeys).length > 0;
};
2 changes: 1 addition & 1 deletion src/script/self/SelfRepository.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const generateMLSFeaturesConfig = (migrationStatus: MLSMigrationStatus, supporte

const createMockClientResponse = (doesSupportMLS = false, wasActiveWithinLast4Weeks = false) => {
return {
mls_public_keys: doesSupportMLS ? {ed25519: 'key'} : undefined,
mls_public_keys: doesSupportMLS ? {ed25519: 'key'} : {},
last_active: wasActiveWithinLast4Weeks
? new Date().toISOString()
: new Date(Date.now() - 5 * 7 * 24 * 60 * 60 * 1000).toISOString(),
Expand Down
30 changes: 15 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5364,9 +5364,9 @@ __metadata:
languageName: node
linkType: hard

"@wireapp/api-client@npm:^26.1.0":
version: 26.1.0
resolution: "@wireapp/api-client@npm:26.1.0"
"@wireapp/api-client@npm:^26.1.1":
version: 26.1.1
resolution: "@wireapp/api-client@npm:26.1.1"
dependencies:
"@wireapp/commons": ^5.1.3
"@wireapp/priority-queue": ^2.1.4
Expand All @@ -5380,7 +5380,7 @@ __metadata:
spark-md5: 3.0.2
tough-cookie: 4.1.3
ws: 8.14.1
checksum: a0008aa096641b5aaf224bb191e6bc25099875f3f13731dc8de6d747fb8cfe4c362b764c5a4f8f8757a53f95f5328dc74ed68ddec43f881fb8d648e25ba2ce18
checksum: 788935f49f52c7b9c932f853a125f2ed4760eb62216f44c3ff12926b566502591f35bb3d163ed726acab48c8d6b3bb512ae3d2963440de28271d16e9648c9fcf
languageName: node
linkType: hard

Expand Down Expand Up @@ -5433,11 +5433,11 @@ __metadata:
languageName: node
linkType: hard

"@wireapp/core@npm:42.3.3":
version: 42.3.3
resolution: "@wireapp/core@npm:42.3.3"
"@wireapp/core@npm:42.3.4":
version: 42.3.4
resolution: "@wireapp/core@npm:42.3.4"
dependencies:
"@wireapp/api-client": ^26.1.0
"@wireapp/api-client": ^26.1.1
"@wireapp/commons": ^5.1.3
"@wireapp/core-crypto": 1.0.0-rc.12
"@wireapp/cryptobox": 12.8.0
Expand All @@ -5446,15 +5446,15 @@ __metadata:
"@wireapp/store-engine": 5.1.4
"@wireapp/store-engine-dexie": ^2.1.6
axios: 1.5.0
bazinga64: ^6.3.0
bazinga64: ^6.3.1
deepmerge-ts: 5.1.0
hash.js: 1.1.7
http-status-codes: 2.2.0
idb: 7.1.1
logdown: 3.3.1
long: ^5.2.0
uuidjs: 4.2.13
checksum: e7e4f9205bb5d68f589e46d9a2b57e4ecd374896923e0e6b2f3fa96b6579413076a0c9e03284d62818daa4db587573c5281120287fc78fa8e6ab7ea681446922
checksum: 89fd8d273f140dc69e08691f07dcebabd8c271f0afbebf35e5431618fb2e3e62bfd4ae6f79aae69b3949f0142c20b3525188d63f449df05b7b2fda759b9ef064
languageName: node
linkType: hard

Expand Down Expand Up @@ -6526,10 +6526,10 @@ __metadata:
languageName: node
linkType: hard

"bazinga64@npm:^6.3.0":
version: 6.3.0
resolution: "bazinga64@npm:6.3.0"
checksum: 8221f157a5d4bf53c2da03deaa4770da0a756b9f2829c2da5662519f211497e726b4994c5802179eb98d85d340e024c03522c69c9bbe6b21039b785aa20cd3a1
"bazinga64@npm:^6.3.1":
version: 6.3.1
resolution: "bazinga64@npm:6.3.1"
checksum: f720936b3919f8df3b903675a9557f36b5a959ec458d7536756b805a9a1e3c81d5d6a367adb0245b80e1ef870cd5f94491ac9566738016b5613b5e5e3bccce6e
languageName: node
linkType: hard

Expand Down Expand Up @@ -18556,7 +18556,7 @@ __metadata:
"@types/webpack-env": 1.18.1
"@wireapp/avs": 9.3.7
"@wireapp/copy-config": 2.1.7
"@wireapp/core": 42.3.3
"@wireapp/core": 42.3.4
"@wireapp/eslint-config": 3.0.4
"@wireapp/lru-cache": 3.8.1
"@wireapp/prettier-config": 0.6.3
Expand Down

0 comments on commit 1fda360

Please sign in to comment.