mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-28 18:10:38 +00:00
Update libsignal-service
This commit is contained in:
parent
8524037900
commit
19dc2d446b
8 changed files with 69 additions and 47 deletions
|
@ -180,6 +180,8 @@
|
|||
"pattern":"\\Qkotlin/ranges/ranges.kotlin_builtins\\E"
|
||||
}, {
|
||||
"pattern":"\\Qkotlin/reflect/reflect.kotlin_builtins\\E"
|
||||
}, {
|
||||
"pattern":"\\Qlibsignal_jni.so\\E"
|
||||
}, {
|
||||
"pattern":"\\Qlibsignal_jni_aarch64.dylib\\E"
|
||||
}, {
|
||||
|
@ -194,6 +196,8 @@
|
|||
"pattern":"\\Qorg/slf4j/impl/StaticLoggerBinder.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/sqlite/native/Linux/x86_64/libsqlitejdbc.so\\E"
|
||||
}, {
|
||||
"pattern":"\\Qsignal_jni.dll\\E"
|
||||
}, {
|
||||
"pattern":"\\Qsignal_jni_amd64.dll\\E"
|
||||
}, {
|
||||
|
|
|
@ -194,7 +194,7 @@ public final class IncomingMessageHandler {
|
|||
) throws ProtocolInvalidKeyException, ProtocolInvalidMessageException, UnsupportedDataMessageException, InvalidMessageStructureException {
|
||||
final var content = cipherResult.getContent();
|
||||
final var envelopeMetadata = cipherResult.getMetadata();
|
||||
final var validationResult = EnvelopeContentValidator.INSTANCE.validate(envelope, content);
|
||||
final var validationResult = EnvelopeContentValidator.INSTANCE.validate(envelope, content, account.getAci());
|
||||
|
||||
if (validationResult instanceof EnvelopeContentValidator.Result.Invalid v) {
|
||||
logger.warn("Invalid content! {}", v.getReason(), v.getThrowable());
|
||||
|
|
|
@ -39,7 +39,6 @@ import org.whispersystems.signalservice.api.messages.multidevice.ViewedMessage;
|
|||
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.internal.push.SyncMessage;
|
||||
import org.whispersystems.signalservice.internal.push.http.ResumableUploadSpec;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
|
@ -135,15 +134,12 @@ public class SyncHelper {
|
|||
|
||||
if (groupsFile.exists() && groupsFile.length() > 0) {
|
||||
try (var groupsFileStream = new FileInputStream(groupsFile)) {
|
||||
final var uploadSpec = context.getDependencies()
|
||||
.getMessageSender()
|
||||
.getResumableUploadSpec()
|
||||
.toProto();
|
||||
final var uploadSpec = context.getDependencies().getMessageSender().getResumableUploadSpec();
|
||||
var attachmentStream = SignalServiceAttachment.newStreamBuilder()
|
||||
.withStream(groupsFileStream)
|
||||
.withContentType(MimeUtils.OCTET_STREAM)
|
||||
.withLength(groupsFile.length())
|
||||
.withResumableUploadSpec(ResumableUploadSpec.from(uploadSpec))
|
||||
.withResumableUploadSpec(uploadSpec)
|
||||
.build();
|
||||
|
||||
context.getSendHelper().sendSyncMessage(SignalServiceSyncMessage.forGroups(attachmentStream));
|
||||
|
@ -197,15 +193,12 @@ public class SyncHelper {
|
|||
|
||||
if (contactsFile.exists() && contactsFile.length() > 0) {
|
||||
try (var contactsFileStream = new FileInputStream(contactsFile)) {
|
||||
final var uploadSpec = context.getDependencies()
|
||||
.getMessageSender()
|
||||
.getResumableUploadSpec()
|
||||
.toProto();
|
||||
final var uploadSpec = context.getDependencies().getMessageSender().getResumableUploadSpec();
|
||||
var attachmentStream = SignalServiceAttachment.newStreamBuilder()
|
||||
.withStream(contactsFileStream)
|
||||
.withContentType(MimeUtils.OCTET_STREAM)
|
||||
.withLength(contactsFile.length())
|
||||
.withResumableUploadSpec(ResumableUploadSpec.from(uploadSpec))
|
||||
.withResumableUploadSpec(uploadSpec)
|
||||
.build();
|
||||
|
||||
context.getSendHelper()
|
||||
|
|
|
@ -36,6 +36,8 @@ import org.whispersystems.signalservice.api.push.ServiceIdType;
|
|||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.AuthorizationFailedException;
|
||||
import org.whispersystems.signalservice.api.util.DeviceNameUtil;
|
||||
import org.whispersystems.signalservice.internal.push.ProvisioningSocket;
|
||||
import org.whispersystems.signalservice.internal.push.PushServiceSocket;
|
||||
import org.whispersystems.signalservice.internal.util.DynamicCredentialsProvider;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -75,13 +77,21 @@ public class ProvisioningManagerImpl implements ProvisioningManager {
|
|||
|
||||
tempIdentityKey = KeyUtils.generateIdentityKeyPair();
|
||||
password = KeyUtils.createPassword();
|
||||
GroupsV2Operations groupsV2Operations = new GroupsV2Operations(ClientZkOperations.create(
|
||||
serviceEnvironmentConfig.signalServiceConfiguration()), ServiceConfig.GROUP_MAX_SIZE);
|
||||
accountManager = new SignalServiceAccountManager(serviceEnvironmentConfig.signalServiceConfiguration(),
|
||||
new DynamicCredentialsProvider(null, null, null, password, SignalServiceAddress.DEFAULT_DEVICE_ID),
|
||||
final var clientZkOperations = ClientZkOperations.create(serviceEnvironmentConfig.signalServiceConfiguration());
|
||||
final var groupsV2Operations = new GroupsV2Operations(clientZkOperations, ServiceConfig.GROUP_MAX_SIZE);
|
||||
final var credentialsProvider = new DynamicCredentialsProvider(null,
|
||||
null,
|
||||
null,
|
||||
password,
|
||||
SignalServiceAddress.DEFAULT_DEVICE_ID);
|
||||
final var pushServiceSocket = new PushServiceSocket(serviceEnvironmentConfig.signalServiceConfiguration(),
|
||||
credentialsProvider,
|
||||
userAgent,
|
||||
groupsV2Operations,
|
||||
clientZkOperations.getProfileOperations(),
|
||||
ServiceConfig.AUTOMATIC_NETWORK_RETRY);
|
||||
accountManager = new SignalServiceAccountManager(pushServiceSocket,
|
||||
new ProvisioningSocket(serviceEnvironmentConfig.signalServiceConfiguration(), userAgent),
|
||||
groupsV2Operations);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -48,8 +48,8 @@ import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
|||
import org.whispersystems.signalservice.api.push.exceptions.AlreadyVerifiedException;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.DeprecatedVersionException;
|
||||
import org.whispersystems.signalservice.api.svr.SecureValueRecovery;
|
||||
import org.whispersystems.signalservice.internal.push.PushServiceSocket;
|
||||
import org.whispersystems.signalservice.internal.push.VerifyAccountResponse;
|
||||
import org.whispersystems.signalservice.internal.util.DynamicCredentialsProvider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.function.Consumer;
|
||||
|
@ -65,9 +65,8 @@ public class RegistrationManagerImpl implements RegistrationManager {
|
|||
private final ServiceEnvironmentConfig serviceEnvironmentConfig;
|
||||
private final String userAgent;
|
||||
private final Consumer<Manager> newManagerListener;
|
||||
private final GroupsV2Operations groupsV2Operations;
|
||||
|
||||
private final SignalServiceAccountManager accountManager;
|
||||
private final SignalServiceAccountManager unauthenticatedAccountManager;
|
||||
private final PinHelper pinHelper;
|
||||
private final AccountFileUpdater accountFileUpdater;
|
||||
|
||||
|
@ -86,15 +85,17 @@ public class RegistrationManagerImpl implements RegistrationManager {
|
|||
this.userAgent = userAgent;
|
||||
this.newManagerListener = newManagerListener;
|
||||
|
||||
groupsV2Operations = new GroupsV2Operations(ClientZkOperations.create(serviceEnvironmentConfig.signalServiceConfiguration()),
|
||||
ServiceConfig.GROUP_MAX_SIZE);
|
||||
this.accountManager = new SignalServiceAccountManager(serviceEnvironmentConfig.signalServiceConfiguration(),
|
||||
new DynamicCredentialsProvider(
|
||||
// Using empty UUID, because registering doesn't work otherwise
|
||||
null, null, account.getNumber(), account.getPassword(), SignalServiceAddress.DEFAULT_DEVICE_ID),
|
||||
this.unauthenticatedAccountManager = SignalServiceAccountManager.createWithStaticCredentials(
|
||||
serviceEnvironmentConfig.signalServiceConfiguration(),
|
||||
// Using empty UUID, because registering doesn't work otherwise
|
||||
null,
|
||||
null,
|
||||
account.getNumber(),
|
||||
SignalServiceAddress.DEFAULT_DEVICE_ID,
|
||||
account.getPassword(),
|
||||
userAgent,
|
||||
groupsV2Operations,
|
||||
ServiceConfig.AUTOMATIC_NETWORK_RETRY);
|
||||
ServiceConfig.AUTOMATIC_NETWORK_RETRY,
|
||||
ServiceConfig.GROUP_MAX_SIZE);
|
||||
final var secureValueRecoveryV2 = serviceEnvironmentConfig.svr2Mrenclaves()
|
||||
.stream()
|
||||
.map(mr -> (SecureValueRecovery) accountManager.getSecureValueRecoveryV2(mr))
|
||||
|
@ -128,12 +129,14 @@ public class RegistrationManagerImpl implements RegistrationManager {
|
|||
return;
|
||||
}
|
||||
|
||||
String sessionId = NumberVerificationUtils.handleVerificationSession(accountManager,
|
||||
String sessionId = NumberVerificationUtils.handleVerificationSession(unauthenticatedAccountManager,
|
||||
account.getSessionId(account.getNumber()),
|
||||
id -> account.setSessionId(account.getNumber(), id),
|
||||
voiceVerification,
|
||||
captcha);
|
||||
NumberVerificationUtils.requestVerificationCode(accountManager, sessionId, voiceVerification);
|
||||
NumberVerificationUtils.requestVerificationCode(unauthenticatedAccountManager,
|
||||
sessionId,
|
||||
voiceVerification);
|
||||
account.setRegistered(false);
|
||||
} catch (DeprecatedVersionException e) {
|
||||
logger.debug("Signal-Server returned deprecated version exception", e);
|
||||
|
@ -193,7 +196,7 @@ public class RegistrationManagerImpl implements RegistrationManager {
|
|||
|
||||
final var aciPreKeys = generatePreKeysForType(account.getAccountData(ServiceIdType.ACI));
|
||||
final var pniPreKeys = generatePreKeysForType(account.getAccountData(ServiceIdType.PNI));
|
||||
final var response = Utils.handleResponseException(accountManager.registerAccount(null,
|
||||
final var response = Utils.handleResponseException(unauthenticatedAccountManager.registerAccount(null,
|
||||
recoveryPassword,
|
||||
account.getAccountAttributes(null),
|
||||
aciPreKeys,
|
||||
|
@ -215,11 +218,7 @@ public class RegistrationManagerImpl implements RegistrationManager {
|
|||
|
||||
private boolean attemptReactivateAccount() {
|
||||
try {
|
||||
final var accountManager = new SignalServiceAccountManager(serviceEnvironmentConfig.signalServiceConfiguration(),
|
||||
account.getCredentialsProvider(),
|
||||
userAgent,
|
||||
groupsV2Operations,
|
||||
ServiceConfig.AUTOMATIC_NETWORK_RETRY);
|
||||
final var accountManager = createAuthenticatedSignalServiceAccountManager();
|
||||
accountManager.setAccountAttributes(account.getAccountAttributes(null));
|
||||
account.setRegistered(true);
|
||||
logger.info("Reactivated existing account, verify is not necessary.");
|
||||
|
@ -239,6 +238,17 @@ public class RegistrationManagerImpl implements RegistrationManager {
|
|||
return false;
|
||||
}
|
||||
|
||||
private SignalServiceAccountManager createAuthenticatedSignalServiceAccountManager() {
|
||||
final var clientZkOperations = ClientZkOperations.create(serviceEnvironmentConfig.signalServiceConfiguration());
|
||||
final var pushServiceSocket = new PushServiceSocket(serviceEnvironmentConfig.signalServiceConfiguration(),
|
||||
account.getCredentialsProvider(),
|
||||
userAgent,
|
||||
clientZkOperations.getProfileOperations(),
|
||||
ServiceConfig.AUTOMATIC_NETWORK_RETRY);
|
||||
final var groupsV2Operations = new GroupsV2Operations(clientZkOperations, ServiceConfig.GROUP_MAX_SIZE);
|
||||
return new SignalServiceAccountManager(pushServiceSocket, null, groupsV2Operations);
|
||||
}
|
||||
|
||||
private VerifyAccountResponse verifyAccountWithCode(
|
||||
final String sessionId,
|
||||
final String verificationCode,
|
||||
|
@ -247,11 +257,11 @@ public class RegistrationManagerImpl implements RegistrationManager {
|
|||
final PreKeyCollection pniPreKeys
|
||||
) throws IOException {
|
||||
try {
|
||||
Utils.handleResponseException(accountManager.verifyAccount(verificationCode, sessionId));
|
||||
Utils.handleResponseException(unauthenticatedAccountManager.verifyAccount(verificationCode, sessionId));
|
||||
} catch (AlreadyVerifiedException e) {
|
||||
// Already verified so can continue registering
|
||||
}
|
||||
return Utils.handleResponseException(accountManager.registerAccount(sessionId,
|
||||
return Utils.handleResponseException(unauthenticatedAccountManager.registerAccount(sessionId,
|
||||
null,
|
||||
account.getAccountAttributes(registrationLock),
|
||||
aciPreKeys,
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.whispersystems.signalservice.api.svr.SecureValueRecovery;
|
|||
import org.whispersystems.signalservice.api.util.CredentialsProvider;
|
||||
import org.whispersystems.signalservice.api.util.UptimeSleepTimer;
|
||||
import org.whispersystems.signalservice.api.websocket.WebSocketFactory;
|
||||
import org.whispersystems.signalservice.internal.push.ProvisioningSocket;
|
||||
import org.whispersystems.signalservice.internal.push.PushServiceSocket;
|
||||
import org.whispersystems.signalservice.internal.websocket.OkHttpWebSocketConnection;
|
||||
import org.whispersystems.signalservice.internal.websocket.WebSocketConnection;
|
||||
|
@ -50,6 +51,7 @@ public class SignalDependencies {
|
|||
private ClientZkOperations clientZkOperations;
|
||||
|
||||
private PushServiceSocket pushServiceSocket;
|
||||
private ProvisioningSocket provisioningSocket;
|
||||
private Network libSignalNetwork;
|
||||
private SignalWebSocket signalWebSocket;
|
||||
private SignalServiceMessageReceiver messageReceiver;
|
||||
|
@ -107,6 +109,12 @@ public class SignalDependencies {
|
|||
ServiceConfig.AUTOMATIC_NETWORK_RETRY));
|
||||
}
|
||||
|
||||
public ProvisioningSocket getProvisioningSocket() {
|
||||
return getOrCreate(() -> provisioningSocket,
|
||||
() -> provisioningSocket = new ProvisioningSocket(getServiceEnvironmentConfig().signalServiceConfiguration(),
|
||||
userAgent));
|
||||
}
|
||||
|
||||
public Network getLibSignalNetwork() {
|
||||
return getOrCreate(() -> libSignalNetwork,
|
||||
() -> libSignalNetwork = new Network(serviceEnvironmentConfig.netEnvironment(), userAgent));
|
||||
|
@ -115,14 +123,12 @@ public class SignalDependencies {
|
|||
public SignalServiceAccountManager getAccountManager() {
|
||||
return getOrCreate(() -> accountManager,
|
||||
() -> accountManager = new SignalServiceAccountManager(getPushServiceSocket(),
|
||||
null,
|
||||
serviceEnvironmentConfig.signalServiceConfiguration(),
|
||||
credentialsProvider,
|
||||
getProvisioningSocket(),
|
||||
getGroupsV2Operations()));
|
||||
}
|
||||
|
||||
public SignalServiceAccountManager createUnauthenticatedAccountManager(String number, String password) {
|
||||
return new SignalServiceAccountManager(getServiceEnvironmentConfig().signalServiceConfiguration(),
|
||||
return SignalServiceAccountManager.createWithStaticCredentials(getServiceEnvironmentConfig().signalServiceConfiguration(),
|
||||
null,
|
||||
null,
|
||||
number,
|
||||
|
@ -190,14 +196,13 @@ public class SignalDependencies {
|
|||
|
||||
public SignalServiceMessageSender getMessageSender() {
|
||||
return getOrCreate(() -> messageSender,
|
||||
() -> messageSender = new SignalServiceMessageSender(credentialsProvider,
|
||||
() -> messageSender = new SignalServiceMessageSender(getPushServiceSocket(),
|
||||
dataStore,
|
||||
sessionLock,
|
||||
getSignalWebSocket(),
|
||||
Optional.empty(),
|
||||
executor,
|
||||
ServiceConfig.MAX_ENVELOPE_SIZE,
|
||||
getPushServiceSocket()));
|
||||
ServiceConfig.MAX_ENVELOPE_SIZE));
|
||||
}
|
||||
|
||||
public List<SecureValueRecovery> getSecureValueRecoveryV2() {
|
||||
|
|
|
@ -15,7 +15,7 @@ dependencyResolutionManagement {
|
|||
library("slf4j.jul", "org.slf4j", "jul-to-slf4j").versionRef("slf4j")
|
||||
library("logback", "ch.qos.logback", "logback-classic").version("1.5.8")
|
||||
|
||||
library("signalservice", "com.github.turasa", "signal-service-java").version("2.15.3_unofficial_107")
|
||||
library("signalservice", "com.github.turasa", "signal-service-java").version("2.15.3_unofficial_108")
|
||||
library("sqlite", "org.xerial", "sqlite-jdbc").version("3.46.1.0")
|
||||
library("hikari", "com.zaxxer", "HikariCP").version("5.1.0")
|
||||
library("junit.jupiter", "org.junit.jupiter", "junit-jupiter").version("5.11.0")
|
||||
|
|
|
@ -8,7 +8,7 @@ public class BaseConfig {
|
|||
public static final String PROJECT_VERSION = BaseConfig.class.getPackage().getImplementationVersion();
|
||||
|
||||
static final String USER_AGENT_SIGNAL_ANDROID = Optional.ofNullable(System.getenv("SIGNAL_CLI_USER_AGENT"))
|
||||
.orElse("Signal-Android/7.16.2");
|
||||
.orElse("Signal-Android/7.18.2");
|
||||
static final String USER_AGENT_SIGNAL_CLI = PROJECT_NAME == null
|
||||
? "signal-cli"
|
||||
: PROJECT_NAME + "/" + PROJECT_VERSION;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue