Add support for restoring usernames post-registration.

This commit is contained in:
Greyson Parrelli
2024-01-09 13:01:33 -05:00
parent c16bf65a80
commit 61a4a3b322
11 changed files with 171 additions and 56 deletions

View File

@@ -794,6 +794,17 @@ public class SignalServiceAccountManager {
}
}
public UsernameLinkComponents reclaimUsernameAndLink(Username username, UsernameLinkComponents linkComponents) throws IOException {
try {
UsernameLink link = username.generateLink(linkComponents.getEntropy());
UUID serverId = this.pushServiceSocket.confirmUsernameAndCreateNewLink(username, link);
return new UsernameLinkComponents(link.getEntropy(), serverId);
} catch (BaseUsernameException e) {
throw new AssertionError(e);
}
}
public UsernameLinkComponents updateUsernameLink(UsernameLink newUsernameLink) throws IOException {
UUID serverId = this.pushServiceSocket.createUsernameLink(Base64.encodeUrlSafeWithoutPadding(newUsernameLink.getEncryptedUsername()), true);