mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Update dependencies
This commit is contained in:
parent
3d5c440aa2
commit
aad4b53524
7 changed files with 72 additions and 11 deletions
|
@ -28,6 +28,7 @@ import org.whispersystems.signalservice.api.push.exceptions.AlreadyVerifiedExcep
|
|||
import org.whispersystems.signalservice.api.push.exceptions.AuthorizationFailedException;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.DeprecatedVersionException;
|
||||
import org.whispersystems.signalservice.api.util.DeviceNameUtil;
|
||||
import org.whispersystems.signalservice.internal.push.KyberPreKeyEntity;
|
||||
import org.whispersystems.signalservice.internal.push.OutgoingPushMessage;
|
||||
import org.whispersystems.util.Base64UrlSafe;
|
||||
|
||||
|
@ -153,6 +154,7 @@ public class AccountHelper {
|
|||
// TODO create new PNI identity key
|
||||
final List<OutgoingPushMessage> deviceMessages = null;
|
||||
final Map<String, SignedPreKeyEntity> devicePniSignedPreKeys = null;
|
||||
final Map<String, KyberPreKeyEntity> devicePniLastResortKyberPrekeys = null;
|
||||
final Map<String, Integer> pniRegistrationIds = null;
|
||||
var sessionId = account.getSessionId(account.getNumber());
|
||||
final var result = NumberVerificationUtils.verifyNumber(sessionId,
|
||||
|
@ -174,6 +176,7 @@ public class AccountHelper {
|
|||
account.getPniIdentityKeyPair().getPublicKey(),
|
||||
deviceMessages,
|
||||
devicePniSignedPreKeys,
|
||||
devicePniLastResortKyberPrekeys,
|
||||
pniRegistrationIds)));
|
||||
});
|
||||
// TODO handle response
|
||||
|
@ -193,10 +196,10 @@ public class AccountHelper {
|
|||
}
|
||||
}
|
||||
|
||||
final var candidates = Username.generateCandidates(nickname, USERNAME_MIN_LENGTH, USERNAME_MAX_LENGTH);
|
||||
final var candidates = Username.candidatesFrom(nickname, USERNAME_MIN_LENGTH, USERNAME_MAX_LENGTH);
|
||||
final var candidateHashes = new ArrayList<String>();
|
||||
for (final var candidate : candidates) {
|
||||
candidateHashes.add(Base64UrlSafe.encodeBytesWithoutPadding(Username.hash(candidate)));
|
||||
candidateHashes.add(Base64UrlSafe.encodeBytesWithoutPadding(candidate.getHash()));
|
||||
}
|
||||
|
||||
final var response = dependencies.getAccountManager().reserveUsername(candidateHashes);
|
||||
|
@ -207,7 +210,7 @@ public class AccountHelper {
|
|||
}
|
||||
|
||||
logger.debug("[reserveUsername] Successfully reserved username.");
|
||||
final var username = candidates.get(hashIndex);
|
||||
final var username = candidates.get(hashIndex).getUsername();
|
||||
|
||||
dependencies.getAccountManager().confirmUsername(username, response);
|
||||
account.setUsername(username);
|
||||
|
@ -226,7 +229,7 @@ public class AccountHelper {
|
|||
final var whoAmIResponse = dependencies.getAccountManager().getWhoAmI();
|
||||
final var serverUsernameHash = whoAmIResponse.getUsernameHash();
|
||||
final var hasServerUsername = !isEmpty(serverUsernameHash);
|
||||
final var localUsernameHash = Base64UrlSafe.encodeBytesWithoutPadding(Username.hash(localUsername));
|
||||
final var localUsernameHash = Base64UrlSafe.encodeBytesWithoutPadding(new Username(localUsername).getHash());
|
||||
|
||||
if (!hasServerUsername) {
|
||||
logger.debug("No remote username is set.");
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.signal.libsignal.protocol.state.PreKeyRecord;
|
|||
import org.signal.libsignal.protocol.state.SignedPreKeyRecord;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.whispersystems.signalservice.api.account.PreKeyUpload;
|
||||
import org.whispersystems.signalservice.api.push.ServiceIdType;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -34,9 +35,11 @@ public class PreKeyHelper {
|
|||
}
|
||||
|
||||
public void refreshPreKeysIfNecessary(ServiceIdType serviceIdType) throws IOException {
|
||||
if (dependencies.getAccountManager().getPreKeysCount(serviceIdType) < ServiceConfig.PREKEY_MINIMUM_COUNT) {
|
||||
final var preKeyCounts = dependencies.getAccountManager().getPreKeyCounts(serviceIdType);
|
||||
if (preKeyCounts.getEcCount() < ServiceConfig.PREKEY_MINIMUM_COUNT) {
|
||||
refreshPreKeys(serviceIdType);
|
||||
}
|
||||
// TODO kyber pre keys
|
||||
}
|
||||
|
||||
public void refreshPreKeys() throws IOException {
|
||||
|
@ -68,8 +71,13 @@ public class PreKeyHelper {
|
|||
final var oneTimePreKeys = generatePreKeys(serviceIdType);
|
||||
final var signedPreKeyRecord = generateSignedPreKey(serviceIdType, identityKeyPair);
|
||||
|
||||
dependencies.getAccountManager()
|
||||
.setPreKeys(serviceIdType, identityKeyPair.getPublicKey(), signedPreKeyRecord, oneTimePreKeys);
|
||||
final var preKeyUpload = new PreKeyUpload(serviceIdType,
|
||||
identityKeyPair.getPublicKey(),
|
||||
signedPreKeyRecord,
|
||||
oneTimePreKeys,
|
||||
null,
|
||||
null);
|
||||
dependencies.getAccountManager().setPreKeys(preKeyUpload);
|
||||
}
|
||||
|
||||
private List<PreKeyRecord> generatePreKeys(ServiceIdType serviceIdType) {
|
||||
|
|
|
@ -152,8 +152,12 @@ public class ReceiveHelper {
|
|||
logger.trace("Storing new message from {}", recipientId);
|
||||
// store message on disk, before acknowledging receipt to the server
|
||||
cachedMessage[0] = account.getMessageCache().cacheMessage(envelope1, recipientId);
|
||||
try {
|
||||
signalWebSocket.sendAck(it);
|
||||
} catch (IOException e) {
|
||||
logger.warn("Failed to ack envelope to server after storing it: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
isWaitingForMessage = false;
|
||||
backOffCounter = 0;
|
||||
|
|
|
@ -180,7 +180,7 @@ public class RecipientHelper {
|
|||
|
||||
private ACI getRegisteredUserByUsername(String username) throws IOException, BaseUsernameException {
|
||||
return dependencies.getAccountManager()
|
||||
.getAciByUsernameHash(Base64UrlSafe.encodeBytesWithoutPadding(Username.hash(username)));
|
||||
.getAciByUsernameHash(Base64UrlSafe.encodeBytesWithoutPadding(new Username(username).getHash()));
|
||||
}
|
||||
|
||||
public record RegisteredUser(Optional<ACI> aci, Optional<PNI> pni) {
|
||||
|
|
|
@ -226,4 +226,20 @@ public class SignalProtocolStore implements SignalServiceAccountDataStore {
|
|||
public void markKyberPreKeyUsed(final int kyberPreKeyId) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<KyberPreKeyRecord> loadLastResortKyberPreKeys() {
|
||||
// TODO
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeKyberPreKey(final int i) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public void storeLastResortKyberPreKey(final int i, final KyberPreKeyRecord kyberPreKeyRecord) {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue