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
64f6a1f072
commit
6843643aad
8 changed files with 52 additions and 10 deletions
|
@ -2995,6 +2995,7 @@
|
|||
{"name":"messageRequestResponse_"},
|
||||
{"name":"outgoingPayment_"},
|
||||
{"name":"padding_"},
|
||||
{"name":"pniChangeNumber_"},
|
||||
{"name":"pniIdentity_"},
|
||||
{"name":"read_"},
|
||||
{"name":"request_"},
|
||||
|
|
|
@ -14,7 +14,7 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation("com.github.turasa", "signal-service-java", "2.15.3_unofficial_54")
|
||||
implementation("com.github.turasa", "signal-service-java", "2.15.3_unofficial_55")
|
||||
implementation("com.fasterxml.jackson.core", "jackson-databind", "2.13.3")
|
||||
implementation("com.google.protobuf", "protobuf-javalite", "3.11.4")
|
||||
implementation("org.bouncycastle", "bcprov-jdk15on", "1.70")
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.whispersystems.signalservice.api.groupsv2.GroupsV2Operations;
|
|||
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.ConfirmCodeMessage;
|
||||
import org.whispersystems.signalservice.internal.util.DynamicCredentialsProvider;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -54,6 +55,7 @@ class ProvisioningManagerImpl implements ProvisioningManager {
|
|||
private final SignalServiceAccountManager accountManager;
|
||||
private final IdentityKeyPair tempIdentityKey;
|
||||
private final int registrationId;
|
||||
private final int pniRegistrationId;
|
||||
private final String password;
|
||||
|
||||
ProvisioningManagerImpl(
|
||||
|
@ -71,6 +73,7 @@ class ProvisioningManagerImpl implements ProvisioningManager {
|
|||
|
||||
tempIdentityKey = KeyUtils.generateIdentityKeyPair();
|
||||
registrationId = KeyHelper.generateRegistrationId(false);
|
||||
pniRegistrationId = KeyHelper.generateRegistrationId(false);
|
||||
password = KeyUtils.createPassword();
|
||||
GroupsV2Operations groupsV2Operations;
|
||||
try {
|
||||
|
@ -123,10 +126,7 @@ class ProvisioningManagerImpl implements ProvisioningManager {
|
|||
|
||||
logger.debug("Finishing new device registration");
|
||||
var deviceId = accountManager.finishNewDeviceRegistration(ret.getProvisioningCode(),
|
||||
false,
|
||||
true,
|
||||
registrationId,
|
||||
encryptedDeviceName);
|
||||
new ConfirmCodeMessage(false, true, registrationId, pniRegistrationId, encryptedDeviceName, null));
|
||||
|
||||
// Create new account with the synced identity
|
||||
var profileKey = ret.getProfileKey() == null ? KeyUtils.createProfileKey() : ret.getProfileKey();
|
||||
|
@ -145,6 +145,7 @@ class ProvisioningManagerImpl implements ProvisioningManager {
|
|||
ret.getAciIdentity(),
|
||||
ret.getPniIdentity(),
|
||||
registrationId,
|
||||
pniRegistrationId,
|
||||
profileKey,
|
||||
TrustNewIdentity.ON_FIRST_USE);
|
||||
|
||||
|
|
|
@ -187,7 +187,8 @@ class RegistrationManagerImpl implements RegistrationManager {
|
|||
account.isUnrestrictedUnidentifiedAccess(),
|
||||
capabilities,
|
||||
account.isDiscoverableByPhoneNumber(),
|
||||
account.getEncryptedDeviceName());
|
||||
account.getEncryptedDeviceName(),
|
||||
account.getLocalPniRegistrationId());
|
||||
account.setRegistered(true);
|
||||
logger.info("Reactivated existing account, verify is not necessary.");
|
||||
if (newManagerListener != null) {
|
||||
|
@ -216,7 +217,8 @@ class RegistrationManagerImpl implements RegistrationManager {
|
|||
account.getSelfUnidentifiedAccessKey(),
|
||||
account.isUnrestrictedUnidentifiedAccess(),
|
||||
ServiceConfig.capabilities,
|
||||
account.isDiscoverableByPhoneNumber());
|
||||
account.isDiscoverableByPhoneNumber(),
|
||||
account.getLocalPniRegistrationId());
|
||||
} else {
|
||||
return accountManager.verifyAccountWithRegistrationLockPin(verificationCode,
|
||||
account.getLocalRegistrationId(),
|
||||
|
@ -225,7 +227,8 @@ class RegistrationManagerImpl implements RegistrationManager {
|
|||
account.getSelfUnidentifiedAccessKey(),
|
||||
account.isUnrestrictedUnidentifiedAccess(),
|
||||
ServiceConfig.capabilities,
|
||||
account.isDiscoverableByPhoneNumber());
|
||||
account.isDiscoverableByPhoneNumber(),
|
||||
account.getLocalPniRegistrationId());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -149,6 +149,7 @@ public class SignalAccountFiles {
|
|||
var aciIdentityKey = KeyUtils.generateIdentityKeyPair();
|
||||
var pniIdentityKey = KeyUtils.generateIdentityKeyPair();
|
||||
var registrationId = KeyHelper.generateRegistrationId(false);
|
||||
var pniRegistrationId = KeyHelper.generateRegistrationId(false);
|
||||
|
||||
var profileKey = KeyUtils.createProfileKey();
|
||||
var account = SignalAccount.create(pathConfig.dataPath(),
|
||||
|
@ -158,6 +159,7 @@ public class SignalAccountFiles {
|
|||
aciIdentityKey,
|
||||
pniIdentityKey,
|
||||
registrationId,
|
||||
pniRegistrationId,
|
||||
profileKey,
|
||||
trustNewIdentity);
|
||||
|
||||
|
|
|
@ -13,12 +13,17 @@ import org.asamk.signal.manager.util.NumberVerificationUtils;
|
|||
import org.signal.libsignal.protocol.InvalidKeyException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.whispersystems.signalservice.api.account.ChangePhoneNumberRequest;
|
||||
import org.whispersystems.signalservice.api.push.ACI;
|
||||
import org.whispersystems.signalservice.api.push.PNI;
|
||||
import org.whispersystems.signalservice.api.push.SignedPreKeyEntity;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.AuthorizationFailedException;
|
||||
import org.whispersystems.signalservice.api.util.DeviceNameUtil;
|
||||
import org.whispersystems.signalservice.internal.push.OutgoingPushMessage;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -103,11 +108,21 @@ public class AccountHelper {
|
|||
public void finishChangeNumber(
|
||||
String newNumber, String verificationCode, String pin
|
||||
) throws IncorrectPinException, PinLockedException, IOException {
|
||||
// TODO create new PNI identity key
|
||||
final List<OutgoingPushMessage> deviceMessages = null;
|
||||
final Map<String, SignedPreKeyEntity> devicePniSignedPreKeys = null;
|
||||
final Map<String, Integer> pniRegistrationIds = null;
|
||||
final var result = NumberVerificationUtils.verifyNumber(verificationCode,
|
||||
pin,
|
||||
context.getPinHelper(),
|
||||
(verificationCode1, registrationLock) -> dependencies.getAccountManager()
|
||||
.changeNumber(verificationCode1, newNumber, registrationLock));
|
||||
.changeNumber(new ChangePhoneNumberRequest(newNumber,
|
||||
verificationCode1,
|
||||
registrationLock,
|
||||
account.getPniIdentityKeyPair().getPublicKey(),
|
||||
deviceMessages,
|
||||
devicePniSignedPreKeys,
|
||||
pniRegistrationIds)));
|
||||
// TODO handle response
|
||||
updateSelfIdentifiers(newNumber, account.getAci(), PNI.parseOrThrow(result.first().getPni()));
|
||||
}
|
||||
|
@ -129,7 +144,8 @@ public class AccountHelper {
|
|||
account.isUnrestrictedUnidentifiedAccess(),
|
||||
ServiceConfig.capabilities,
|
||||
account.isDiscoverableByPhoneNumber(),
|
||||
account.getEncryptedDeviceName());
|
||||
account.getEncryptedDeviceName(),
|
||||
account.getLocalPniRegistrationId());
|
||||
}
|
||||
|
||||
public void addDevice(DeviceLinkInfo deviceLinkInfo) throws IOException, InvalidDeviceLinkException {
|
||||
|
|
|
@ -492,6 +492,7 @@ public final class IncomingMessageHandler {
|
|||
pniIdentity.getPrivateKey().toByteArray()));
|
||||
actions.add(RefreshPreKeysAction.create());
|
||||
}
|
||||
// TODO handle PniChangeNumber
|
||||
return actions;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ import org.signal.libsignal.protocol.SignalProtocolAddress;
|
|||
import org.signal.libsignal.protocol.state.PreKeyRecord;
|
||||
import org.signal.libsignal.protocol.state.SessionRecord;
|
||||
import org.signal.libsignal.protocol.state.SignedPreKeyRecord;
|
||||
import org.signal.libsignal.protocol.util.KeyHelper;
|
||||
import org.signal.libsignal.protocol.util.Medium;
|
||||
import org.signal.libsignal.zkgroup.InvalidInputException;
|
||||
import org.signal.libsignal.zkgroup.profiles.ProfileKey;
|
||||
|
@ -125,6 +126,7 @@ public class SignalAccount implements Closeable {
|
|||
private IdentityKeyPair aciIdentityKeyPair;
|
||||
private IdentityKeyPair pniIdentityKeyPair;
|
||||
private int localRegistrationId;
|
||||
private int localPniRegistrationId;
|
||||
private TrustNewIdentity trustNewIdentity;
|
||||
private long lastReceiveTimestamp = 0;
|
||||
|
||||
|
@ -186,6 +188,7 @@ public class SignalAccount implements Closeable {
|
|||
IdentityKeyPair aciIdentityKey,
|
||||
IdentityKeyPair pniIdentityKey,
|
||||
int registrationId,
|
||||
int pniRegistrationId,
|
||||
ProfileKey profileKey,
|
||||
final TrustNewIdentity trustNewIdentity
|
||||
) throws IOException {
|
||||
|
@ -207,6 +210,7 @@ public class SignalAccount implements Closeable {
|
|||
signalAccount.aciIdentityKeyPair = aciIdentityKey;
|
||||
signalAccount.pniIdentityKeyPair = pniIdentityKey;
|
||||
signalAccount.localRegistrationId = registrationId;
|
||||
signalAccount.localPniRegistrationId = pniRegistrationId;
|
||||
signalAccount.trustNewIdentity = trustNewIdentity;
|
||||
signalAccount.groupStore = new GroupStore(getGroupCachePath(dataPath, accountPath),
|
||||
signalAccount.getRecipientResolver(),
|
||||
|
@ -236,6 +240,7 @@ public class SignalAccount implements Closeable {
|
|||
IdentityKeyPair aciIdentityKey,
|
||||
IdentityKeyPair pniIdentityKey,
|
||||
int registrationId,
|
||||
int pniRegistrationId,
|
||||
ProfileKey profileKey,
|
||||
final TrustNewIdentity trustNewIdentity
|
||||
) throws IOException {
|
||||
|
@ -254,6 +259,7 @@ public class SignalAccount implements Closeable {
|
|||
aciIdentityKey,
|
||||
pniIdentityKey,
|
||||
registrationId,
|
||||
pniRegistrationId,
|
||||
profileKey,
|
||||
trustNewIdentity);
|
||||
}
|
||||
|
@ -305,6 +311,7 @@ public class SignalAccount implements Closeable {
|
|||
IdentityKeyPair aciIdentityKey,
|
||||
IdentityKeyPair pniIdentityKey,
|
||||
int registrationId,
|
||||
int pniRegistrationId,
|
||||
ProfileKey profileKey,
|
||||
final TrustNewIdentity trustNewIdentity
|
||||
) throws IOException {
|
||||
|
@ -318,6 +325,7 @@ public class SignalAccount implements Closeable {
|
|||
signalAccount.accountPath = accountPath;
|
||||
signalAccount.serviceEnvironment = serviceEnvironment;
|
||||
signalAccount.localRegistrationId = registrationId;
|
||||
signalAccount.localPniRegistrationId = pniRegistrationId;
|
||||
signalAccount.trustNewIdentity = trustNewIdentity;
|
||||
signalAccount.setProvisioningData(number,
|
||||
aci,
|
||||
|
@ -549,6 +557,11 @@ public class SignalAccount implements Closeable {
|
|||
if (rootNode.hasNonNull("registrationId")) {
|
||||
registrationId = rootNode.get("registrationId").asInt();
|
||||
}
|
||||
if (rootNode.hasNonNull("pniRegistrationId")) {
|
||||
localPniRegistrationId = rootNode.get("pniRegistrationId").asInt();
|
||||
} else {
|
||||
localPniRegistrationId = KeyHelper.generateRegistrationId(false);
|
||||
}
|
||||
IdentityKeyPair aciIdentityKeyPair = null;
|
||||
if (rootNode.hasNonNull("identityPrivateKey") && rootNode.hasNonNull("identityKey")) {
|
||||
final var publicKeyBytes = Base64.getDecoder().decode(rootNode.get("identityKey").asText());
|
||||
|
@ -855,6 +868,7 @@ public class SignalAccount implements Closeable {
|
|||
.put("lastReceiveTimestamp", lastReceiveTimestamp)
|
||||
.put("password", password)
|
||||
.put("registrationId", localRegistrationId)
|
||||
.put("pniRegistrationId", localPniRegistrationId)
|
||||
.put("identityPrivateKey",
|
||||
Base64.getEncoder().encodeToString(aciIdentityKeyPair.getPrivateKey().serialize()))
|
||||
.put("identityKey",
|
||||
|
@ -1245,6 +1259,10 @@ public class SignalAccount implements Closeable {
|
|||
return localRegistrationId;
|
||||
}
|
||||
|
||||
public int getLocalPniRegistrationId() {
|
||||
return localPniRegistrationId;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue