Skip to content

Commit

Permalink
Merge pull request #21 from wireapp/WPB-12153-v2
Browse files Browse the repository at this point in the history
fix(add client_id param to token refresh) #WPB-12153
  • Loading branch information
spoonman01 authored Dec 6, 2024
2 parents 8496d84 + 6349752 commit 034361c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.wire</groupId>
<artifactId>helium</artifactId>
<version>1.5.2</version>
<version>1.6.0</version>

<name>Helium</name>
<description>User mode for Wire Bots</description>
Expand Down Expand Up @@ -65,7 +65,7 @@
<dependency>
<groupId>com.wire</groupId>
<artifactId>xenon</artifactId>
<version>1.7.2</version>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>jakarta.ws.rs</groupId>
Expand Down
14 changes: 6 additions & 8 deletions src/main/java/com/wire/helium/API.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.protobuf.ByteString;
import com.wire.helium.models.Connection;
import com.wire.helium.models.model.response.FeatureConfig;
import com.wire.helium.models.NotificationList;
import com.wire.helium.models.model.response.PublicKeysResponse;
import com.wire.helium.models.model.request.ConversationListPaginationConfig;
import com.wire.helium.models.model.request.ConversationListRequest;
import com.wire.helium.models.model.response.ConversationListIdsResponse;
import com.wire.helium.models.model.response.ConversationListResponse;
import com.wire.helium.models.model.response.FeatureConfig;
import com.wire.helium.models.model.response.PublicKeysResponse;
import com.wire.messages.Otr;
import com.wire.xenon.WireAPI;
import com.wire.xenon.assets.IAsset;
Expand Down Expand Up @@ -93,14 +93,13 @@ public API(Client client, QualifiedId convId, String token) {

/**
* Sends E2E encrypted messages to all clients already known, with opened cryptobox sessions.
*
* After sending those, the backend will return the list of clients that the service has no connection yet,
* so prekeys for those specific clients can be downloaded a new cryptobox sessions initiated.
* @param msg the message with the already encrypted clients
* @param ignoreMissing when true, missing clients won't be blocking and just be returned,
* when false, any missing recipient will block the message to be sent to anyone
* @return devices that had issues or still need the message
* @throws HttpException
* @throws HttpException on any error response from the backend
*/
@Override
public Devices sendMessage(OtrMessage msg, boolean ignoreMissing) throws HttpException {
Expand Down Expand Up @@ -137,13 +136,12 @@ public Devices sendMessage(OtrMessage msg, boolean ignoreMissing) throws HttpExc

/**
* Sends E2E encrypted messages to all clients already known, with opened cryptobox sessions.
*
* After sending those, the backend will return the list of clients that the service has no connection yet,
* so prekeys for those specific clients can be downloaded a new cryptobox sessions initiated.
* @param msg the message with the already encrypted clients
* @param userId If this users' client is missing, the message is not sent
* @return devices that had issues or still need the message
* @throws HttpException
* @throws HttpException on any error response from the backend
*/
@Override
public Devices sendPartialMessage(OtrMessage msg, QualifiedId userId) throws HttpException {
Expand Down Expand Up @@ -669,7 +667,7 @@ public boolean isMlsEnabled() {
}

try {
PublicKeysResponse publicKeysResponse = mlsPublicKeysResponse.readEntity(PublicKeysResponse.class);
mlsPublicKeysResponse.readEntity(PublicKeysResponse.class);
} catch (Exception e) {
Logger.error("isMlsEnabled - Public Keys Deserialization error: %s", e.getMessage());
return false;
Expand Down Expand Up @@ -761,7 +759,7 @@ public byte[] getConversationGroupInfo(QualifiedId conversationId) throws Runtim
.path(conversationId.domain)
.path(conversationId.id.toString())
.path("groupinfo")
.request(MediaType.APPLICATION_JSON)
.request()
.header(HttpHeaders.AUTHORIZATION, bearer(token))
.accept("message/mls")
.get();
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/com/wire/helium/LoginClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,11 @@ public String registerClient(String token, String password, ArrayList<PreKey> pr
return response.readEntity(_Client.class).id;
}

public Access renewAccessToken(Cookie cookie) throws HttpException {
public Access renewAccessToken(String clientId, Cookie cookie) throws HttpException {
Invocation.Builder builder = accessPath
.request(MediaType.APPLICATION_JSON)
.cookie(cookie);
.queryParam("client_id", clientId)
.request(MediaType.APPLICATION_JSON)
.cookie(cookie);

Response response = builder.
post(Entity.entity(null, MediaType.APPLICATION_JSON));
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/com/wire/helium/End2EndTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void testAliceToAlice() throws Exception {

CryptoDatabase aliceCrypto = new CryptoDatabase(aliceId, storage, rootFolder + "/testAliceToAlice/1");
CryptoDatabase aliceCrypto1 = new CryptoDatabase(aliceId, storage, rootFolder + "/testAliceToAlice/2");
CryptoMlsClient cryptoMlsClient = new CryptoMlsClient(client1, client1 + "_db_key");
CryptoMlsClient cryptoMlsClient = new CryptoMlsClient(client1, aliceId, client1 + "_db_key");

DummyAPI api = new DummyAPI();
api.addDevice(aliceId, client1, aliceCrypto1.box().newLastPreKey());
Expand Down Expand Up @@ -81,7 +81,7 @@ public void testAliceToBob() throws Exception {

CryptoDatabase aliceCrypto = new CryptoDatabase(aliceId, storage, rootFolder + "/testAliceToBob");
CryptoDatabase bobCrypto = new CryptoDatabase(bobId, storage, rootFolder + "/testAliceToBob");
CryptoMlsClient cryptoMlsClient = new CryptoMlsClient(client1, client1 + "_db_key");
CryptoMlsClient cryptoMlsClient = new CryptoMlsClient(client1, bobId, client1 + "_db_key");

DummyAPI api = new DummyAPI();
api.addDevice(bobId, client1, bobCrypto.box().newLastPreKey());
Expand Down Expand Up @@ -116,7 +116,7 @@ public void testMultiDevicePostgres() throws Exception {
CryptoDatabase aliceCrypto1 = new CryptoDatabase(aliceId, storage, rootFolder + "/testMultiDevicePostgres/alice/1");
CryptoDatabase bobCrypto1 = new CryptoDatabase(bobId, storage, rootFolder + "/testMultiDevicePostgres/bob/1");
CryptoDatabase bobCrypto2 = new CryptoDatabase(bobId, storage, rootFolder + "/testMultiDevicePostgres/bob/2");
CryptoMlsClient cryptoMlsClient = new CryptoMlsClient(client1, client1 + "_db_key");
CryptoMlsClient cryptoMlsClient = new CryptoMlsClient(client1, bobId, client1 + "_db_key");

DummyAPI api = new DummyAPI();
api.addDevice(bobId, client1, bobCrypto1.box().newLastPreKey());
Expand Down

0 comments on commit 034361c

Please sign in to comment.