mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
Update libsignal-service-java
This commit is contained in:
parent
e83bfb9e03
commit
b903102407
5 changed files with 66 additions and 27 deletions
|
@ -2272,7 +2272,6 @@
|
||||||
"fields":[
|
"fields":[
|
||||||
{"name":"bitField0_"},
|
{"name":"bitField0_"},
|
||||||
{"name":"e164_"},
|
{"name":"e164_"},
|
||||||
{"name":"relay_"},
|
|
||||||
{"name":"uuid_"}
|
{"name":"uuid_"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -14,7 +14,7 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
api("com.github.turasa:signal-service-java:2.15.3_unofficial_26")
|
api("com.github.turasa:signal-service-java:2.15.3_unofficial_27")
|
||||||
implementation("com.google.protobuf:protobuf-javalite:3.10.0")
|
implementation("com.google.protobuf:protobuf-javalite:3.10.0")
|
||||||
implementation("org.bouncycastle:bcprov-jdk15on:1.69")
|
implementation("org.bouncycastle:bcprov-jdk15on:1.69")
|
||||||
implementation("org.slf4j:slf4j-api:1.7.30")
|
implementation("org.slf4j:slf4j-api:1.7.30")
|
||||||
|
|
|
@ -35,7 +35,9 @@ import org.whispersystems.signalservice.api.groupsv2.GroupsV2Operations;
|
||||||
import org.whispersystems.signalservice.api.kbs.MasterKey;
|
import org.whispersystems.signalservice.api.kbs.MasterKey;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
import org.whispersystems.signalservice.api.util.UuidUtil;
|
import org.whispersystems.signalservice.api.util.UuidUtil;
|
||||||
|
import org.whispersystems.signalservice.internal.ServiceResponse;
|
||||||
import org.whispersystems.signalservice.internal.push.LockedException;
|
import org.whispersystems.signalservice.internal.push.LockedException;
|
||||||
|
import org.whispersystems.signalservice.internal.push.RequestVerificationCodeResponse;
|
||||||
import org.whispersystems.signalservice.internal.push.VerifyAccountResponse;
|
import org.whispersystems.signalservice.internal.push.VerifyAccountResponse;
|
||||||
import org.whispersystems.signalservice.internal.util.DynamicCredentialsProvider;
|
import org.whispersystems.signalservice.internal.util.DynamicCredentialsProvider;
|
||||||
|
|
||||||
|
@ -115,13 +117,19 @@ public class RegistrationManager implements Closeable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void register(boolean voiceVerification, String captcha) throws IOException {
|
public void register(boolean voiceVerification, String captcha) throws IOException {
|
||||||
|
final ServiceResponse<RequestVerificationCodeResponse> response;
|
||||||
if (voiceVerification) {
|
if (voiceVerification) {
|
||||||
accountManager.requestVoiceVerificationCode(getDefaultLocale(),
|
response = accountManager.requestVoiceVerificationCode(getDefaultLocale(),
|
||||||
Optional.fromNullable(captcha),
|
Optional.fromNullable(captcha),
|
||||||
|
Optional.absent(),
|
||||||
Optional.absent());
|
Optional.absent());
|
||||||
} else {
|
} else {
|
||||||
accountManager.requestSmsVerificationCode(false, Optional.fromNullable(captcha), Optional.absent());
|
response = accountManager.requestSmsVerificationCode(false,
|
||||||
|
Optional.fromNullable(captcha),
|
||||||
|
Optional.absent(),
|
||||||
|
Optional.absent());
|
||||||
}
|
}
|
||||||
|
handleResponseException(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Locale getDefaultLocale() {
|
private Locale getDefaultLocale() {
|
||||||
|
@ -143,7 +151,7 @@ public class RegistrationManager implements Closeable {
|
||||||
VerifyAccountResponse response;
|
VerifyAccountResponse response;
|
||||||
MasterKey masterKey;
|
MasterKey masterKey;
|
||||||
try {
|
try {
|
||||||
response = verifyAccountWithCode(verificationCode, null, null);
|
response = verifyAccountWithCode(verificationCode, null);
|
||||||
|
|
||||||
masterKey = null;
|
masterKey = null;
|
||||||
pin = null;
|
pin = null;
|
||||||
|
@ -154,17 +162,16 @@ public class RegistrationManager implements Closeable {
|
||||||
|
|
||||||
var registrationLockData = pinHelper.getRegistrationLockData(pin, e);
|
var registrationLockData = pinHelper.getRegistrationLockData(pin, e);
|
||||||
if (registrationLockData == null) {
|
if (registrationLockData == null) {
|
||||||
response = verifyAccountWithCode(verificationCode, pin, null);
|
throw e;
|
||||||
masterKey = null;
|
|
||||||
} else {
|
|
||||||
var registrationLock = registrationLockData.getMasterKey().deriveRegistrationLock();
|
|
||||||
try {
|
|
||||||
response = verifyAccountWithCode(verificationCode, null, registrationLock);
|
|
||||||
} catch (LockedException _e) {
|
|
||||||
throw new AssertionError("KBS Pin appeared to matched but reg lock still failed!");
|
|
||||||
}
|
|
||||||
masterKey = registrationLockData.getMasterKey();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var registrationLock = registrationLockData.getMasterKey().deriveRegistrationLock();
|
||||||
|
try {
|
||||||
|
response = verifyAccountWithCode(verificationCode, registrationLock);
|
||||||
|
} catch (LockedException _e) {
|
||||||
|
throw new AssertionError("KBS Pin appeared to matched but reg lock still failed!");
|
||||||
|
}
|
||||||
|
masterKey = registrationLockData.getMasterKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO response.isStorageCapable()
|
// TODO response.isStorageCapable()
|
||||||
|
@ -192,18 +199,29 @@ public class RegistrationManager implements Closeable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private VerifyAccountResponse verifyAccountWithCode(
|
private VerifyAccountResponse verifyAccountWithCode(
|
||||||
final String verificationCode, final String legacyPin, final String registrationLock
|
final String verificationCode, final String registrationLock
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
return accountManager.verifyAccountWithCode(verificationCode,
|
final ServiceResponse<VerifyAccountResponse> response;
|
||||||
null,
|
if (registrationLock == null) {
|
||||||
account.getLocalRegistrationId(),
|
response = accountManager.verifyAccount(verificationCode,
|
||||||
true,
|
account.getLocalRegistrationId(),
|
||||||
legacyPin,
|
true,
|
||||||
registrationLock,
|
account.getSelfUnidentifiedAccessKey(),
|
||||||
account.getSelfUnidentifiedAccessKey(),
|
account.isUnrestrictedUnidentifiedAccess(),
|
||||||
account.isUnrestrictedUnidentifiedAccess(),
|
ServiceConfig.capabilities,
|
||||||
ServiceConfig.capabilities,
|
account.isDiscoverableByPhoneNumber());
|
||||||
account.isDiscoverableByPhoneNumber());
|
} else {
|
||||||
|
response = accountManager.verifyAccountWithRegistrationLockPin(verificationCode,
|
||||||
|
account.getLocalRegistrationId(),
|
||||||
|
true,
|
||||||
|
registrationLock,
|
||||||
|
account.getSelfUnidentifiedAccessKey(),
|
||||||
|
account.isUnrestrictedUnidentifiedAccess(),
|
||||||
|
ServiceConfig.capabilities,
|
||||||
|
account.isDiscoverableByPhoneNumber());
|
||||||
|
}
|
||||||
|
handleResponseException(response);
|
||||||
|
return response.getResult().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -213,4 +231,15 @@ public class RegistrationManager implements Closeable {
|
||||||
account = null;
|
account = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleResponseException(final ServiceResponse<?> response) throws IOException {
|
||||||
|
final var throwableOptional = response.getExecutionError().or(response.getApplicationError());
|
||||||
|
if (throwableOptional.isPresent()) {
|
||||||
|
if (throwableOptional.get() instanceof IOException) {
|
||||||
|
throw (IOException) throwableOptional.get();
|
||||||
|
} else {
|
||||||
|
throw new IOException(throwableOptional.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ class SandboxConfig {
|
||||||
|
|
||||||
private final static String KEY_BACKUP_ENCLAVE_NAME = "823a3b2c037ff0cbe305cc48928cfcc97c9ed4a8ca6d49af6f7d6981fb60a4e9";
|
private final static String KEY_BACKUP_ENCLAVE_NAME = "823a3b2c037ff0cbe305cc48928cfcc97c9ed4a8ca6d49af6f7d6981fb60a4e9";
|
||||||
private final static byte[] KEY_BACKUP_SERVICE_ID = Hex.decode(
|
private final static byte[] KEY_BACKUP_SERVICE_ID = Hex.decode(
|
||||||
"51a56084c0b21c6b8f62b1bc792ec9bedac4c7c3964bb08ddcab868158c09982");
|
"16b94ac6d2b7f7b9d72928f36d798dbb35ed32e7bb14c42b4301ad0344b46f29");
|
||||||
private final static String KEY_BACKUP_MRENCLAVE = "a3baab19ef6ce6f34ab9ebb25ba722725ae44a8872dc0ff08ad6d83a9489de87";
|
private final static String KEY_BACKUP_MRENCLAVE = "a3baab19ef6ce6f34ab9ebb25ba722725ae44a8872dc0ff08ad6d83a9489de87";
|
||||||
|
|
||||||
private final static String URL = "https://chat.staging.signal.org";
|
private final static String URL = "https://chat.staging.signal.org";
|
||||||
|
|
|
@ -58,6 +58,16 @@ public class SendHelper {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private final SignalServiceMessageSender.LegacyGroupEvents legacyGroupEvents = new SignalServiceMessageSender.LegacyGroupEvents() {
|
||||||
|
@Override
|
||||||
|
public void onMessageSent() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSyncMessageSent() {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public SendHelper(
|
public SendHelper(
|
||||||
final SignalAccount account,
|
final SignalAccount account,
|
||||||
final SignalDependencies dependencies,
|
final SignalDependencies dependencies,
|
||||||
|
@ -267,6 +277,7 @@ public class SendHelper {
|
||||||
isRecipientUpdate,
|
isRecipientUpdate,
|
||||||
ContentHint.DEFAULT,
|
ContentHint.DEFAULT,
|
||||||
message,
|
message,
|
||||||
|
legacyGroupEvents,
|
||||||
sendResult -> logger.trace("Partial message send result: {}", sendResult.isSuccess()),
|
sendResult -> logger.trace("Partial message send result: {}", sendResult.isSuccess()),
|
||||||
() -> false);
|
() -> false);
|
||||||
} catch (org.whispersystems.signalservice.api.crypto.UntrustedIdentityException e) {
|
} catch (org.whispersystems.signalservice.api.crypto.UntrustedIdentityException e) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue