mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-28 18:10:38 +00:00
Improve behavior when pin data doesn't exist on the server
This commit is contained in:
parent
6b60a6d5a5
commit
a0d5744c49
11 changed files with 31 additions and 9 deletions
|
@ -30,6 +30,7 @@ import org.asamk.signal.manager.api.NotAGroupMemberException;
|
|||
import org.asamk.signal.manager.api.NotPrimaryDeviceException;
|
||||
import org.asamk.signal.manager.api.Pair;
|
||||
import org.asamk.signal.manager.api.PendingAdminApprovalException;
|
||||
import org.asamk.signal.manager.api.PinLockMissingException;
|
||||
import org.asamk.signal.manager.api.PinLockedException;
|
||||
import org.asamk.signal.manager.api.RateLimitException;
|
||||
import org.asamk.signal.manager.api.ReceiveConfig;
|
||||
|
@ -140,7 +141,7 @@ public interface Manager extends Closeable {
|
|||
String newNumber,
|
||||
String verificationCode,
|
||||
String pin
|
||||
) throws IncorrectPinException, PinLockedException, IOException, NotPrimaryDeviceException;
|
||||
) throws IncorrectPinException, PinLockedException, IOException, NotPrimaryDeviceException, PinLockMissingException;
|
||||
|
||||
void unregister() throws IOException;
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.asamk.signal.manager;
|
|||
import org.asamk.signal.manager.api.CaptchaRequiredException;
|
||||
import org.asamk.signal.manager.api.IncorrectPinException;
|
||||
import org.asamk.signal.manager.api.NonNormalizedPhoneNumberException;
|
||||
import org.asamk.signal.manager.api.PinLockMissingException;
|
||||
import org.asamk.signal.manager.api.PinLockedException;
|
||||
import org.asamk.signal.manager.api.RateLimitException;
|
||||
import org.asamk.signal.manager.api.VerificationMethodNotAvailableException;
|
||||
|
@ -21,7 +22,7 @@ public interface RegistrationManager extends Closeable {
|
|||
void verifyAccount(
|
||||
String verificationCode,
|
||||
String pin
|
||||
) throws IOException, PinLockedException, IncorrectPinException;
|
||||
) throws IOException, PinLockedException, IncorrectPinException, PinLockMissingException;
|
||||
|
||||
void deleteLocalAccountData() throws IOException;
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
package org.asamk.signal.manager.api;
|
||||
|
||||
public class PinLockMissingException extends Exception {}
|
|
@ -4,6 +4,7 @@ import org.asamk.signal.manager.api.CaptchaRequiredException;
|
|||
import org.asamk.signal.manager.api.DeviceLinkUrl;
|
||||
import org.asamk.signal.manager.api.IncorrectPinException;
|
||||
import org.asamk.signal.manager.api.NonNormalizedPhoneNumberException;
|
||||
import org.asamk.signal.manager.api.PinLockMissingException;
|
||||
import org.asamk.signal.manager.api.PinLockedException;
|
||||
import org.asamk.signal.manager.api.RateLimitException;
|
||||
import org.asamk.signal.manager.api.VerificationMethodNotAvailableException;
|
||||
|
@ -185,7 +186,7 @@ public class AccountHelper {
|
|||
String newNumber,
|
||||
String verificationCode,
|
||||
String pin
|
||||
) throws IncorrectPinException, PinLockedException, IOException {
|
||||
) throws IncorrectPinException, PinLockedException, IOException, PinLockMissingException {
|
||||
for (var attempts = 0; attempts < 5; attempts++) {
|
||||
try {
|
||||
finishChangeNumberInternal(newNumber, verificationCode, pin);
|
||||
|
@ -205,7 +206,7 @@ public class AccountHelper {
|
|||
String newNumber,
|
||||
String verificationCode,
|
||||
String pin
|
||||
) throws IncorrectPinException, PinLockedException, IOException {
|
||||
) throws IncorrectPinException, PinLockedException, IOException, PinLockMissingException {
|
||||
final var pniIdentity = KeyUtils.generateIdentityKeyPair();
|
||||
final var encryptedDeviceMessages = new ArrayList<OutgoingPushMessage>();
|
||||
final var devicePniSignedPreKeys = new HashMap<Integer, SignedPreKeyEntity>();
|
||||
|
|
|
@ -88,7 +88,11 @@ public class PinHelper {
|
|||
IOException exception = null;
|
||||
for (final var secureValueRecovery : secureValueRecoveries) {
|
||||
try {
|
||||
return getRegistrationLockData(secureValueRecovery, svr2Credentials, pin);
|
||||
final var lockData = getRegistrationLockData(secureValueRecovery, svr2Credentials, pin);
|
||||
if (lockData == null) {
|
||||
continue;
|
||||
}
|
||||
return lockData;
|
||||
} catch (IOException e) {
|
||||
exception = e;
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ import org.asamk.signal.manager.api.NotPrimaryDeviceException;
|
|||
import org.asamk.signal.manager.api.Pair;
|
||||
import org.asamk.signal.manager.api.PendingAdminApprovalException;
|
||||
import org.asamk.signal.manager.api.PhoneNumberSharingMode;
|
||||
import org.asamk.signal.manager.api.PinLockMissingException;
|
||||
import org.asamk.signal.manager.api.PinLockedException;
|
||||
import org.asamk.signal.manager.api.Profile;
|
||||
import org.asamk.signal.manager.api.RateLimitException;
|
||||
|
@ -428,7 +429,7 @@ public class ManagerImpl implements Manager {
|
|||
String newNumber,
|
||||
String verificationCode,
|
||||
String pin
|
||||
) throws IncorrectPinException, PinLockedException, IOException, NotPrimaryDeviceException {
|
||||
) throws IncorrectPinException, PinLockedException, IOException, NotPrimaryDeviceException, PinLockMissingException {
|
||||
if (!account.isPrimaryDevice()) {
|
||||
throw new NotPrimaryDeviceException();
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.asamk.signal.manager.RegistrationManager;
|
|||
import org.asamk.signal.manager.api.CaptchaRequiredException;
|
||||
import org.asamk.signal.manager.api.IncorrectPinException;
|
||||
import org.asamk.signal.manager.api.NonNormalizedPhoneNumberException;
|
||||
import org.asamk.signal.manager.api.PinLockMissingException;
|
||||
import org.asamk.signal.manager.api.PinLockedException;
|
||||
import org.asamk.signal.manager.api.RateLimitException;
|
||||
import org.asamk.signal.manager.api.UpdateProfile;
|
||||
|
@ -149,7 +150,7 @@ public class RegistrationManagerImpl implements RegistrationManager {
|
|||
public void verifyAccount(
|
||||
String verificationCode,
|
||||
String pin
|
||||
) throws IOException, PinLockedException, IncorrectPinException {
|
||||
) throws IOException, PinLockedException, IncorrectPinException, PinLockMissingException {
|
||||
if (account.isRegistered()) {
|
||||
throw new IOException("Account is already registered");
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import org.asamk.signal.manager.api.CaptchaRequiredException;
|
|||
import org.asamk.signal.manager.api.IncorrectPinException;
|
||||
import org.asamk.signal.manager.api.NonNormalizedPhoneNumberException;
|
||||
import org.asamk.signal.manager.api.Pair;
|
||||
import org.asamk.signal.manager.api.PinLockMissingException;
|
||||
import org.asamk.signal.manager.api.PinLockedException;
|
||||
import org.asamk.signal.manager.api.RateLimitException;
|
||||
import org.asamk.signal.manager.api.VerificationMethodNotAvailableException;
|
||||
|
@ -114,7 +115,7 @@ public class NumberVerificationUtils {
|
|||
String pin,
|
||||
PinHelper pinHelper,
|
||||
Verifier verifier
|
||||
) throws IOException, PinLockedException, IncorrectPinException {
|
||||
) throws IOException, PinLockedException, IncorrectPinException, PinLockMissingException {
|
||||
verificationCode = verificationCode.replace("-", "");
|
||||
try {
|
||||
final var response = verifier.verify(sessionId, verificationCode, null);
|
||||
|
@ -127,7 +128,7 @@ public class NumberVerificationUtils {
|
|||
|
||||
final var registrationLockData = pinHelper.getRegistrationLockData(pin, e);
|
||||
if (registrationLockData == null) {
|
||||
throw e;
|
||||
throw new PinLockMissingException();
|
||||
}
|
||||
|
||||
var registrationLock = registrationLockData.getMasterKey().deriveRegistrationLock();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue