mirror of
https://github.com/signalapp/Signal-Server.git
synced 2026-11-30 01:16:50 +00:00
Add accountRecoveryPassword to accounts
This commit is contained in:
1 parent
f4f2ffff21
commit
8cbc8b0ce6
2 files changed
+27
No files matched your search
@@ -145,6 +145,14 @@ public class Account {
|
||||
@JsonProperty("holds")
|
||||
private List<UsernameHold> usernameHolds = Collections.emptyList();
|
||||
|
||||
@JsonProperty("arps")
|
||||
@Nullable
|
||||
private String accountRecoveryPasswordSalt;
|
||||
|
||||
@JsonProperty("arph")
|
||||
@Nullable
|
||||
private String accountRecoveryPasswordHash;
|
||||
|
||||
@JsonIgnore
|
||||
private boolean stale;
|
||||
|
||||
@@ -678,6 +686,24 @@ public class Account {
|
||||
this.zkCredentialKeyRotationId = zkCredentialKeyRotationId;
|
||||
}
|
||||
|
||||
public Optional<SaltedTokenHash> getAccountRecoveryPassword() {
|
||||
requireNotStale();
|
||||
|
||||
return accountRecoveryPasswordSalt != null && accountRecoveryPasswordHash != null
|
||||
? Optional.of(new SaltedTokenHash(accountRecoveryPasswordSalt, accountRecoveryPasswordHash))
|
||||
: Optional.empty();
|
||||
}
|
||||
|
||||
public void setAccountRecoveryPassword(final byte[] accountRecoveryPassword) {
|
||||
requireNotStale();
|
||||
|
||||
final SaltedTokenHash saltedTokenHash =
|
||||
SaltedTokenHash.generateFor(HexFormat.of().formatHex(accountRecoveryPassword));
|
||||
|
||||
this.accountRecoveryPasswordSalt = saltedTokenHash.salt();
|
||||
this.accountRecoveryPasswordHash = saltedTokenHash.hash();
|
||||
}
|
||||
|
||||
public void markStale() {
|
||||
stale = true;
|
||||
}
|
||||
|
||||
@@ -243,6 +243,7 @@ public class AccountsHelper {
|
||||
case "hasLockedCredentials" -> when(updatedAccount.hasLockedCredentials()).thenAnswer(stubbing);
|
||||
case "getCurrentProfileVersion" -> when(updatedAccount.getCurrentProfileVersion()).thenAnswer(stubbing);
|
||||
case "getUnidentifiedAccessKey" -> when(updatedAccount.getUnidentifiedAccessKey()).thenAnswer(stubbing);
|
||||
case "getRecoveryPassword" -> when(updatedAccount.getAccountRecoveryPassword()).thenAnswer(stubbing);
|
||||
default -> throw new IllegalArgumentException("unsupported method: Account#" + stubbing.getInvocation().getMethod().getName());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user