Update libsignal-service-java

This commit is contained in:
AsamK 2022-02-11 20:33:12 +01:00
parent d690b35ed9
commit b0bb602eb5
7 changed files with 43 additions and 22 deletions

View file

@ -14,7 +14,7 @@ repositories {
}
dependencies {
implementation("com.github.turasa", "signal-service-java", "2.15.3_unofficial_39")
implementation("com.github.turasa", "signal-service-java", "2.15.3_unofficial_41")
implementation("com.fasterxml.jackson.core", "jackson-databind", "2.13.1")
implementation("com.google.protobuf", "protobuf-javalite", "3.11.4")
implementation("org.bouncycastle", "bcprov-jdk15on", "1.70")

View file

@ -133,7 +133,7 @@ class ManagerImpl implements Manager {
this.dependencies = new SignalDependencies(serviceEnvironmentConfig,
userAgent,
account.getCredentialsProvider(),
account.getSignalProtocolStore(),
account.getSignalServiceDataStore(),
executor,
sessionLock);
final var avatarStore = new AvatarStore(pathConfig.avatarsPath());

View file

@ -153,8 +153,7 @@ class RegistrationManagerImpl implements RegistrationManager {
userAgent,
null,
ServiceConfig.AUTOMATIC_NETWORK_RETRY);
accountManager.setAccountAttributes(account.getEncryptedDeviceName(),
null,
accountManager.setAccountAttributes(null,
account.getLocalRegistrationId(),
true,
null,
@ -162,7 +161,8 @@ class RegistrationManagerImpl implements RegistrationManager {
account.getSelfUnidentifiedAccessKey(),
account.isUnrestrictedUnidentifiedAccess(),
capabilities,
account.isDiscoverableByPhoneNumber());
account.isDiscoverableByPhoneNumber(),
account.getEncryptedDeviceName());
account.setRegistered(true);
logger.info("Reactivated existing account, verify is not necessary.");
if (newManagerListener != null) {

View file

@ -90,8 +90,8 @@ public class SignalDependencies {
return new SignalServiceAccountManager(getServiceEnvironmentConfig().getSignalServiceConfiguration(),
null,
number,
password,
SignalServiceAddress.DEFAULT_DEVICE_ID,
password,
userAgent,
ServiceConfig.AUTOMATIC_NETWORK_RETRY);
}
@ -191,7 +191,7 @@ public class SignalDependencies {
final var certificateValidator = new CertificateValidator(serviceEnvironmentConfig.getUnidentifiedSenderTrustRoot());
final var address = new SignalServiceAddress(credentialsProvider.getAci(), credentialsProvider.getE164());
final var deviceId = credentialsProvider.getDeviceId();
cipher = new SignalServiceCipher(address, deviceId, dataStore, sessionLock, certificateValidator);
cipher = new SignalServiceCipher(address, deviceId, dataStore.aci(), sessionLock, certificateValidator);
});
}

View file

@ -114,8 +114,7 @@ public class AccountHelper {
public void updateAccountAttributes() throws IOException {
dependencies.getAccountManager()
.setAccountAttributes(account.getEncryptedDeviceName(),
null,
.setAccountAttributes(null,
account.getLocalRegistrationId(),
true,
null,
@ -123,7 +122,8 @@ public class AccountHelper {
account.getSelfUnidentifiedAccessKey(),
account.isUnrestrictedUnidentifiedAccess(),
ServiceConfig.capabilities,
account.isDiscoverableByPhoneNumber());
account.isDiscoverableByPhoneNumber(),
account.getEncryptedDeviceName());
}
public void addDevice(DeviceLinkInfo deviceLinkInfo) throws IOException, InvalidDeviceLinkException {

View file

@ -44,9 +44,12 @@ import org.whispersystems.libsignal.state.PreKeyRecord;
import org.whispersystems.libsignal.state.SessionRecord;
import org.whispersystems.libsignal.state.SignedPreKeyRecord;
import org.whispersystems.libsignal.util.Medium;
import org.whispersystems.signalservice.api.SignalServiceAccountDataStore;
import org.whispersystems.signalservice.api.SignalServiceDataStore;
import org.whispersystems.signalservice.api.crypto.UnidentifiedAccess;
import org.whispersystems.signalservice.api.kbs.MasterKey;
import org.whispersystems.signalservice.api.push.ACI;
import org.whispersystems.signalservice.api.push.AccountIdentifier;
import org.whispersystems.signalservice.api.push.DistributionId;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import org.whispersystems.signalservice.api.storage.StorageKey;
@ -814,7 +817,31 @@ public class SignalAccount implements Closeable {
save();
}
public SignalProtocolStore getSignalProtocolStore() {
public SignalServiceDataStore getSignalServiceDataStore() {
return new SignalServiceDataStore() {
@Override
public SignalServiceAccountDataStore get(final AccountIdentifier accountIdentifier) {
return getSignalServiceAccountDataStore();
}
@Override
public SignalServiceAccountDataStore aci() {
return getSignalServiceAccountDataStore();
}
@Override
public SignalServiceAccountDataStore pni() {
return getSignalServiceAccountDataStore();
}
@Override
public boolean isMultiDevice() {
return SignalAccount.this.isMultiDevice();
}
};
}
public SignalServiceAccountDataStore getSignalServiceAccountDataStore() {
return getOrCreate(() -> signalProtocolStore,
() -> signalProtocolStore = new SignalProtocolStore(getPreKeyStore(),
getSignedPreKeyStore(),
@ -957,8 +984,8 @@ public class SignalAccount implements Closeable {
return getRecipientStore().resolveRecipient(getSelfRecipientAddress());
}
public String getEncryptedDeviceName() {
return encryptedDeviceName;
public byte[] getEncryptedDeviceName() {
return encryptedDeviceName == null ? null : Base64.getDecoder().decode(encryptedDeviceName);
}
public void setEncryptedDeviceName(final String encryptedDeviceName) {

View file

@ -12,7 +12,7 @@ import org.whispersystems.libsignal.state.PreKeyStore;
import org.whispersystems.libsignal.state.SessionRecord;
import org.whispersystems.libsignal.state.SignedPreKeyRecord;
import org.whispersystems.libsignal.state.SignedPreKeyStore;
import org.whispersystems.signalservice.api.SignalServiceDataStore;
import org.whispersystems.signalservice.api.SignalServiceAccountDataStore;
import org.whispersystems.signalservice.api.SignalServiceSenderKeyStore;
import org.whispersystems.signalservice.api.SignalServiceSessionStore;
import org.whispersystems.signalservice.api.push.DistributionId;
@ -23,7 +23,7 @@ import java.util.Set;
import java.util.UUID;
import java.util.function.Supplier;
public class SignalProtocolStore implements SignalServiceDataStore {
public class SignalProtocolStore implements SignalServiceAccountDataStore {
private final PreKeyStore preKeyStore;
private final SignedPreKeyStore signedPreKeyStore;
@ -131,6 +131,7 @@ public class SignalProtocolStore implements SignalServiceDataStore {
@Override
public void archiveSession(final SignalProtocolAddress address) {
sessionStore.archiveSession(address);
senderKeyStore.clearSenderKeySharedWith(List.of(address));
}
@Override
@ -196,11 +197,4 @@ public class SignalProtocolStore implements SignalServiceDataStore {
public boolean isMultiDevice() {
return isMultiDevice.get();
}
@Override
public Transaction beginTransaction() {
return () -> {
// No-op transaction should be safe, as it's only a performance improvement
};
}
}