Centralize username logic in UsernameRepository.

This commit is contained in:
Greyson Parrelli
2023-11-08 14:56:33 -05:00
committed by Cody Henthorne
parent 0f4f87067e
commit e5ab5241d5
9 changed files with 105 additions and 158 deletions

View File

@@ -84,7 +84,6 @@ import org.whispersystems.signalservice.internal.websocket.DefaultResponseMapper
import org.signal.core.util.Base64;
import java.io.IOException;
import java.security.KeyStore;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
@@ -761,8 +760,8 @@ public class SignalServiceAccountManager {
}
}
public ACI getAciByUsernameHash(String usernameHash) throws IOException {
return this.pushServiceSocket.getAciByUsernameHash(usernameHash);
public ACI getAciByUsername(Username username) throws IOException {
return this.pushServiceSocket.getAciByUsernameHash(Base64.encodeUrlSafeWithoutPadding(username.getHash()));
}
public ReserveUsernameResponse reserveUsername(List<String> usernameHashes) throws IOException {

View File

@@ -1068,7 +1068,7 @@ public class PushServiceSocket {
byte[] randomness = new byte[32];
random.nextBytes(randomness);
byte[] proof = Username.generateProof(username, randomness);
byte[] proof = new Username(username).generateProofWithRandomness(randomness);
ConfirmUsernameRequest confirmUsernameRequest = new ConfirmUsernameRequest(reserveUsernameResponse.getUsernameHash(),
Base64.encodeUrlSafeWithoutPadding(proof));