mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Update libsignal-service-java
This commit is contained in:
parent
510dc89e92
commit
a20bbe1246
18 changed files with 106 additions and 99 deletions
|
@ -2459,6 +2459,10 @@
|
|||
{"name":"metadata_"}
|
||||
]}
|
||||
,
|
||||
{
|
||||
"name":"org.whispersystems.signalservice.internal.util.JsonUtil$AciDeserializer",
|
||||
"methods":[{"name":"<init>","parameterTypes":[] }]}
|
||||
,
|
||||
{
|
||||
"name":"org.whispersystems.signalservice.internal.util.JsonUtil$IdentityKeyDeserializer",
|
||||
"methods":[{"name":"<init>","parameterTypes":[] }]}
|
||||
|
|
|
@ -14,9 +14,9 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation("com.github.turasa:signal-service-java:2.15.3_unofficial_31")
|
||||
implementation("com.github.turasa:signal-service-java:2.15.3_unofficial_32")
|
||||
api("com.fasterxml.jackson.core", "jackson-databind", "2.13.0")
|
||||
implementation("com.google.protobuf:protobuf-javalite:3.10.0")
|
||||
implementation("com.google.protobuf:protobuf-javalite:3.11.4")
|
||||
implementation("org.bouncycastle:bcprov-jdk15on:1.69")
|
||||
implementation("org.slf4j:slf4j-api:1.7.32")
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ public class AvatarStore {
|
|||
}
|
||||
|
||||
private String getLegacyIdentifier(final SignalServiceAddress address) {
|
||||
return address.getNumber().or(() -> address.getUuid().toString());
|
||||
return address.getNumber().or(() -> address.getAci().toString());
|
||||
}
|
||||
|
||||
private File getProfileAvatarFile(SignalServiceAddress address) {
|
||||
|
|
|
@ -74,6 +74,7 @@ import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
|
|||
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceReceiptMessage;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceTypingMessage;
|
||||
import org.whispersystems.signalservice.api.push.ACI;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.api.util.DeviceNameUtil;
|
||||
import org.whispersystems.signalservice.api.util.InvalidNumberException;
|
||||
|
@ -149,7 +150,7 @@ public class ManagerImpl implements Manager {
|
|||
this.account = account;
|
||||
this.serviceEnvironmentConfig = serviceEnvironmentConfig;
|
||||
|
||||
final var credentialsProvider = new DynamicCredentialsProvider(account.getUuid(),
|
||||
final var credentialsProvider = new DynamicCredentialsProvider(account.getAci(),
|
||||
account.getUsername(),
|
||||
account.getPassword(),
|
||||
account.getDeviceId());
|
||||
|
@ -262,8 +263,8 @@ public class ManagerImpl implements Manager {
|
|||
}
|
||||
}
|
||||
preKeyHelper.refreshPreKeysIfNecessary();
|
||||
if (account.getUuid() == null) {
|
||||
account.setUuid(dependencies.getAccountManager().getOwnUuid());
|
||||
if (account.getAci() == null) {
|
||||
account.setAci(dependencies.getAccountManager().getOwnAci());
|
||||
}
|
||||
updateAccountAttributes(null);
|
||||
}
|
||||
|
@ -293,8 +294,8 @@ public class ManagerImpl implements Manager {
|
|||
|
||||
return numbers.stream().collect(Collectors.toMap(n -> n, n -> {
|
||||
final var number = canonicalizedNumbers.get(n);
|
||||
final var uuid = registeredUsers.get(number);
|
||||
return new Pair<>(number.isEmpty() ? null : number, uuid);
|
||||
final var aci = registeredUsers.get(number);
|
||||
return new Pair<>(number.isEmpty() ? null : number, aci == null ? null : aci.uuid());
|
||||
}));
|
||||
}
|
||||
|
||||
|
@ -817,22 +818,22 @@ public class ManagerImpl implements Manager {
|
|||
return resolveRecipientTrusted(new SignalServiceAddress(uuid, number));
|
||||
}
|
||||
|
||||
private UUID getRegisteredUser(final String number) throws IOException {
|
||||
final Map<String, UUID> uuidMap;
|
||||
private ACI getRegisteredUser(final String number) throws IOException {
|
||||
final Map<String, ACI> aciMap;
|
||||
try {
|
||||
uuidMap = getRegisteredUsers(Set.of(number));
|
||||
aciMap = getRegisteredUsers(Set.of(number));
|
||||
} catch (NumberFormatException e) {
|
||||
throw new IOException(number, e);
|
||||
}
|
||||
final var uuid = uuidMap.get(number);
|
||||
final var uuid = aciMap.get(number);
|
||||
if (uuid == null) {
|
||||
throw new IOException(number, null);
|
||||
}
|
||||
return uuid;
|
||||
}
|
||||
|
||||
private Map<String, UUID> getRegisteredUsers(final Set<String> numbers) throws IOException {
|
||||
final Map<String, UUID> registeredUsers;
|
||||
private Map<String, ACI> getRegisteredUsers(final Set<String> numbers) throws IOException {
|
||||
final Map<String, ACI> registeredUsers;
|
||||
try {
|
||||
registeredUsers = dependencies.getAccountManager()
|
||||
.getRegisteredUsers(ServiceConfig.getIasKeyStore(),
|
||||
|
@ -842,8 +843,8 @@ public class ManagerImpl implements Manager {
|
|||
throw new IOException(e);
|
||||
}
|
||||
|
||||
// Store numbers as recipients so we have the number/uuid association
|
||||
registeredUsers.forEach((number, uuid) -> resolveRecipientTrusted(new SignalServiceAddress(uuid, number)));
|
||||
// Store numbers as recipients, so we have the number/uuid association
|
||||
registeredUsers.forEach((number, aci) -> resolveRecipientTrusted(new SignalServiceAddress(aci, number)));
|
||||
|
||||
return registeredUsers;
|
||||
}
|
||||
|
@ -1313,15 +1314,15 @@ public class ManagerImpl implements Manager {
|
|||
// Address in recipient store doesn't have a uuid, this shouldn't happen
|
||||
// Try to retrieve the uuid from the server
|
||||
final var number = address.getNumber().get();
|
||||
final UUID uuid;
|
||||
final ACI aci;
|
||||
try {
|
||||
uuid = getRegisteredUser(number);
|
||||
aci = getRegisteredUser(number);
|
||||
} catch (IOException e) {
|
||||
logger.warn("Failed to get uuid for e164 number: {}", number, e);
|
||||
// Return SignalServiceAddress with unknown UUID
|
||||
return address.toSignalServiceAddress();
|
||||
}
|
||||
return resolveSignalServiceAddress(account.getRecipientStore().resolveRecipient(uuid));
|
||||
return resolveSignalServiceAddress(account.getRecipientStore().resolveRecipient(aci));
|
||||
}
|
||||
|
||||
private Set<RecipientId> resolveRecipients(Collection<RecipientIdentifier.Single> recipients) throws IOException {
|
||||
|
@ -1334,8 +1335,8 @@ public class ManagerImpl implements Manager {
|
|||
}
|
||||
|
||||
private RecipientId resolveRecipient(final RecipientIdentifier.Single recipient) throws IOException {
|
||||
if (recipient instanceof RecipientIdentifier.Uuid) {
|
||||
return account.getRecipientStore().resolveRecipient(((RecipientIdentifier.Uuid) recipient).uuid());
|
||||
if (recipient instanceof RecipientIdentifier.Uuid uuidRecipient) {
|
||||
return account.getRecipientStore().resolveRecipient(ACI.from(uuidRecipient.uuid()));
|
||||
} else {
|
||||
final var number = ((RecipientIdentifier.Number) recipient).number();
|
||||
return account.getRecipientStore().resolveRecipient(number, () -> {
|
||||
|
|
|
@ -117,7 +117,7 @@ public class ProvisioningManager {
|
|||
try {
|
||||
account = SignalAccount.createOrUpdateLinkedAccount(pathConfig.dataPath(),
|
||||
number,
|
||||
ret.getUuid(),
|
||||
ret.getAci(),
|
||||
password,
|
||||
encryptedDeviceName,
|
||||
deviceId,
|
||||
|
|
|
@ -37,8 +37,8 @@ import org.whispersystems.signalservice.api.SignalServiceAccountManager;
|
|||
import org.whispersystems.signalservice.api.groupsv2.ClientZkOperations;
|
||||
import org.whispersystems.signalservice.api.groupsv2.GroupsV2Operations;
|
||||
import org.whispersystems.signalservice.api.kbs.MasterKey;
|
||||
import org.whispersystems.signalservice.api.push.ACI;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
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.RequestVerificationCodeResponse;
|
||||
|
@ -190,7 +190,7 @@ public class RegistrationManager implements Closeable {
|
|||
}
|
||||
|
||||
//accountManager.setGcmId(Optional.of(GoogleCloudMessaging.getInstance(this).register(REGISTRATION_ID)));
|
||||
account.finishRegistration(UuidUtil.parseOrNull(response.getUuid()), masterKey, pin);
|
||||
account.finishRegistration(ACI.parseOrNull(response.getUuid()), masterKey, pin);
|
||||
|
||||
ManagerImpl m = null;
|
||||
try {
|
||||
|
|
|
@ -170,7 +170,7 @@ public class SignalDependencies {
|
|||
public SignalServiceCipher getCipher() {
|
||||
return getOrCreate(() -> cipher, () -> {
|
||||
final var certificateValidator = new CertificateValidator(serviceEnvironmentConfig.getUnidentifiedSenderTrustRoot());
|
||||
final var address = new SignalServiceAddress(credentialsProvider.getUuid(), credentialsProvider.getE164());
|
||||
final var address = new SignalServiceAddress(credentialsProvider.getAci(), credentialsProvider.getE164());
|
||||
cipher = new SignalServiceCipher(address, dataStore, sessionLock, certificateValidator);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -236,7 +236,7 @@ public record MessageEnvelope(
|
|||
RecipientResolver recipientResolver,
|
||||
RecipientAddressResolver addressResolver
|
||||
) {
|
||||
return new Mention(addressResolver.resolveRecipientAddress(recipientResolver.resolveRecipient(mention.getUuid())),
|
||||
return new Mention(addressResolver.resolveRecipientAddress(recipientResolver.resolveRecipient(mention.getAci())),
|
||||
mention.getStart(),
|
||||
mention.getLength());
|
||||
}
|
||||
|
|
|
@ -43,8 +43,8 @@ import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentStre
|
|||
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceGroup;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceGroupV2;
|
||||
import org.whispersystems.signalservice.api.push.ACI;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.ConflictException;
|
||||
import org.whispersystems.signalservice.api.util.UuidUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -410,8 +410,8 @@ public class GroupHelper {
|
|||
|
||||
private void storeProfileKeysFromMembers(final DecryptedGroup group) {
|
||||
for (var member : group.getMembersList()) {
|
||||
final var uuid = UuidUtil.parseOrThrow(member.getUuid().toByteArray());
|
||||
final var recipientId = account.getRecipientStore().resolveRecipient(uuid);
|
||||
final var aci = ACI.fromByteString(member.getUuid());
|
||||
final var recipientId = account.getRecipientStore().resolveRecipient(aci);
|
||||
try {
|
||||
account.getProfileStore()
|
||||
.storeProfileKey(recipientId, new ProfileKey(member.getProfileKey().toByteArray()));
|
||||
|
|
|
@ -35,9 +35,9 @@ import org.whispersystems.signalservice.api.groupsv2.GroupsV2AuthorizationString
|
|||
import org.whispersystems.signalservice.api.groupsv2.GroupsV2Operations;
|
||||
import org.whispersystems.signalservice.api.groupsv2.InvalidGroupStateException;
|
||||
import org.whispersystems.signalservice.api.groupsv2.NotAbleToApplyGroupV2ChangeException;
|
||||
import org.whispersystems.signalservice.api.push.ACI;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResponseCodeException;
|
||||
import org.whispersystems.signalservice.api.util.UuidUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
|
@ -158,9 +158,9 @@ public class GroupV2Helper {
|
|||
|
||||
if (!areMembersValid(members)) return null;
|
||||
|
||||
var self = new GroupCandidate(getSelfUuid(), Optional.fromNullable(profileKeyCredential));
|
||||
var self = new GroupCandidate(getSelfAci().uuid(), Optional.fromNullable(profileKeyCredential));
|
||||
var candidates = members.stream()
|
||||
.map(member -> new GroupCandidate(addressResolver.resolveSignalServiceAddress(member).getUuid(),
|
||||
.map(member -> new GroupCandidate(addressResolver.resolveSignalServiceAddress(member).getAci().uuid(),
|
||||
Optional.fromNullable(profileKeyCredentialProvider.getProfileKeyCredential(member))))
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
|
@ -208,8 +208,7 @@ public class GroupV2Helper {
|
|||
change.setModifyAvatar(GroupChange.Actions.ModifyAvatarAction.newBuilder().setAvatar(avatarCdnKey));
|
||||
}
|
||||
|
||||
final var uuid = getSelfUuid();
|
||||
change.setSourceUuid(UuidUtil.toByteString(uuid));
|
||||
change.setSourceUuid(getSelfAci().toByteString());
|
||||
|
||||
return commitChange(groupInfoV2, change);
|
||||
}
|
||||
|
@ -224,14 +223,14 @@ public class GroupV2Helper {
|
|||
}
|
||||
|
||||
var candidates = newMembers.stream()
|
||||
.map(member -> new GroupCandidate(addressResolver.resolveSignalServiceAddress(member).getUuid(),
|
||||
.map(member -> new GroupCandidate(addressResolver.resolveSignalServiceAddress(member).getAci().uuid(),
|
||||
Optional.fromNullable(profileKeyCredentialProvider.getProfileKeyCredential(member))))
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
final var uuid = getSelfUuid();
|
||||
final var change = groupOperations.createModifyGroupMembershipChange(candidates, uuid);
|
||||
final var aci = getSelfAci();
|
||||
final var change = groupOperations.createModifyGroupMembershipChange(candidates, aci.uuid());
|
||||
|
||||
change.setSourceUuid(UuidUtil.toByteString(uuid));
|
||||
change.setSourceUuid(getSelfAci().toByteString());
|
||||
|
||||
return commitChange(groupInfoV2, change);
|
||||
}
|
||||
|
@ -240,8 +239,8 @@ public class GroupV2Helper {
|
|||
GroupInfoV2 groupInfoV2, Set<RecipientId> membersToMakeAdmin
|
||||
) throws IOException {
|
||||
var pendingMembersList = groupInfoV2.getGroup().getPendingMembersList();
|
||||
final var selfUuid = getSelfUuid();
|
||||
var selfPendingMember = DecryptedGroupUtil.findPendingByUuid(pendingMembersList, selfUuid);
|
||||
final var selfAci = getSelfAci();
|
||||
var selfPendingMember = DecryptedGroupUtil.findPendingByUuid(pendingMembersList, selfAci.uuid());
|
||||
|
||||
if (selfPendingMember.isPresent()) {
|
||||
return revokeInvites(groupInfoV2, Set.of(selfPendingMember.get()));
|
||||
|
@ -249,10 +248,12 @@ public class GroupV2Helper {
|
|||
|
||||
final var adminUuids = membersToMakeAdmin.stream()
|
||||
.map(addressResolver::resolveSignalServiceAddress)
|
||||
.map(SignalServiceAddress::getUuid)
|
||||
.map(SignalServiceAddress::getAci)
|
||||
.map(ACI::uuid)
|
||||
.collect(Collectors.toList());
|
||||
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
||||
return commitChange(groupInfoV2, groupOperations.createLeaveAndPromoteMembersToAdmin(selfUuid, adminUuids));
|
||||
return commitChange(groupInfoV2,
|
||||
groupOperations.createLeaveAndPromoteMembersToAdmin(selfAci.uuid(), adminUuids));
|
||||
}
|
||||
|
||||
public Pair<DecryptedGroup, GroupChange> removeMembers(
|
||||
|
@ -260,7 +261,8 @@ public class GroupV2Helper {
|
|||
) throws IOException {
|
||||
final var memberUuids = members.stream()
|
||||
.map(addressResolver::resolveSignalServiceAddress)
|
||||
.map(SignalServiceAddress::getUuid)
|
||||
.map(SignalServiceAddress::getAci)
|
||||
.map(ACI::uuid)
|
||||
.collect(Collectors.toSet());
|
||||
return ejectMembers(groupInfoV2, memberUuids);
|
||||
}
|
||||
|
@ -271,7 +273,8 @@ public class GroupV2Helper {
|
|||
var pendingMembersList = groupInfoV2.getGroup().getPendingMembersList();
|
||||
final var memberUuids = members.stream()
|
||||
.map(addressResolver::resolveSignalServiceAddress)
|
||||
.map(SignalServiceAddress::getUuid)
|
||||
.map(SignalServiceAddress::getAci)
|
||||
.map(ACI::uuid)
|
||||
.map(uuid -> DecryptedGroupUtil.findPendingByUuid(pendingMembersList, uuid))
|
||||
.filter(Optional::isPresent)
|
||||
.map(Optional::get)
|
||||
|
@ -341,8 +344,7 @@ public class GroupV2Helper {
|
|||
? groupOperations.createGroupJoinRequest(profileKeyCredential)
|
||||
: groupOperations.createGroupJoinDirect(profileKeyCredential);
|
||||
|
||||
change.setSourceUuid(UuidUtil.toByteString(addressResolver.resolveSignalServiceAddress(selfRecipientId)
|
||||
.getUuid()));
|
||||
change.setSourceUuid(addressResolver.resolveSignalServiceAddress(selfRecipientId).getAci().toByteString());
|
||||
|
||||
return commitChange(groupSecretParams, decryptedGroupJoinInfo.getRevision(), change, groupLinkPassword);
|
||||
}
|
||||
|
@ -358,8 +360,8 @@ public class GroupV2Helper {
|
|||
|
||||
final var change = groupOperations.createAcceptInviteChange(profileKeyCredential);
|
||||
|
||||
final var uuid = addressResolver.resolveSignalServiceAddress(selfRecipientId).getUuid();
|
||||
change.setSourceUuid(UuidUtil.toByteString(uuid));
|
||||
final var aci = addressResolver.resolveSignalServiceAddress(selfRecipientId).getAci();
|
||||
change.setSourceUuid(aci.toByteString());
|
||||
|
||||
return commitChange(groupInfoV2, change);
|
||||
}
|
||||
|
@ -370,7 +372,7 @@ public class GroupV2Helper {
|
|||
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
||||
final var address = addressResolver.resolveSignalServiceAddress(recipientId);
|
||||
final var newRole = admin ? Member.Role.ADMINISTRATOR : Member.Role.DEFAULT;
|
||||
final var change = groupOperations.createChangeMemberRole(address.getUuid(), newRole);
|
||||
final var change = groupOperations.createChangeMemberRole(address.getAci().uuid(), newRole);
|
||||
return commitChange(groupInfoV2, change);
|
||||
}
|
||||
|
||||
|
@ -443,7 +445,7 @@ public class GroupV2Helper {
|
|||
final DecryptedGroup decryptedGroupState;
|
||||
|
||||
try {
|
||||
decryptedChange = groupOperations.decryptChange(changeActions, getSelfUuid());
|
||||
decryptedChange = groupOperations.decryptChange(changeActions, getSelfAci().uuid());
|
||||
decryptedGroupState = DecryptedGroupUtil.apply(previousGroupState, decryptedChange);
|
||||
} catch (VerificationFailedException | InvalidGroupStateException | NotAbleToApplyGroupV2ChangeException e) {
|
||||
throw new IOException(e);
|
||||
|
@ -510,15 +512,15 @@ public class GroupV2Helper {
|
|||
final var credentials = groupsV2Api.getCredentials(today);
|
||||
// TODO cache credentials until they expire
|
||||
var authCredentialResponse = credentials.get(today);
|
||||
final var uuid = getSelfUuid();
|
||||
final var aci = getSelfAci();
|
||||
try {
|
||||
return groupsV2Api.getGroupsV2AuthorizationString(uuid, today, groupSecretParams, authCredentialResponse);
|
||||
return groupsV2Api.getGroupsV2AuthorizationString(aci, today, groupSecretParams, authCredentialResponse);
|
||||
} catch (VerificationFailedException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private UUID getSelfUuid() {
|
||||
return addressResolver.resolveSignalServiceAddress(this.selfRecipientIdProvider.getSelfRecipientId()).getUuid();
|
||||
private ACI getSelfAci() {
|
||||
return addressResolver.resolveSignalServiceAddress(this.selfRecipientIdProvider.getSelfRecipientId()).getAci();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ public final class ProfileHelper {
|
|||
? avatarStore.retrieveProfileAvatar(account.getSelfAddress())
|
||||
: avatar.isPresent() ? Utils.createStreamDetailsFromFile(avatar.get()) : null) {
|
||||
final var avatarPath = dependencies.getAccountManager()
|
||||
.setVersionedProfile(account.getUuid(),
|
||||
.setVersionedProfile(account.getAci(),
|
||||
account.getProfileKey(),
|
||||
newProfile.getInternalServiceName(),
|
||||
newProfile.getAbout() == null ? "" : newProfile.getAbout(),
|
||||
|
|
|
@ -44,6 +44,7 @@ import org.whispersystems.libsignal.state.SignedPreKeyRecord;
|
|||
import org.whispersystems.libsignal.util.Medium;
|
||||
import org.whispersystems.signalservice.api.crypto.UnidentifiedAccess;
|
||||
import org.whispersystems.signalservice.api.kbs.MasterKey;
|
||||
import org.whispersystems.signalservice.api.push.ACI;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.api.storage.StorageKey;
|
||||
import org.whispersystems.signalservice.api.util.UuidUtil;
|
||||
|
@ -77,7 +78,7 @@ public class SignalAccount implements Closeable {
|
|||
private final FileLock lock;
|
||||
|
||||
private String username;
|
||||
private UUID uuid;
|
||||
private ACI aci;
|
||||
private String encryptedDeviceName;
|
||||
private int deviceId = SignalServiceAddress.DEFAULT_DEVICE_ID;
|
||||
private boolean isMultiDevice = false;
|
||||
|
@ -205,7 +206,7 @@ public class SignalAccount implements Closeable {
|
|||
public static SignalAccount createOrUpdateLinkedAccount(
|
||||
File dataPath,
|
||||
String username,
|
||||
UUID uuid,
|
||||
ACI aci,
|
||||
String password,
|
||||
String encryptedDeviceName,
|
||||
int deviceId,
|
||||
|
@ -219,7 +220,7 @@ public class SignalAccount implements Closeable {
|
|||
if (!fileName.exists()) {
|
||||
return createLinkedAccount(dataPath,
|
||||
username,
|
||||
uuid,
|
||||
aci,
|
||||
password,
|
||||
encryptedDeviceName,
|
||||
deviceId,
|
||||
|
@ -230,7 +231,7 @@ public class SignalAccount implements Closeable {
|
|||
}
|
||||
|
||||
final var account = load(dataPath, username, true, trustNewIdentity);
|
||||
account.setProvisioningData(username, uuid, password, encryptedDeviceName, deviceId, profileKey);
|
||||
account.setProvisioningData(username, aci, password, encryptedDeviceName, deviceId, profileKey);
|
||||
account.recipientStore.resolveRecipientTrusted(account.getSelfAddress());
|
||||
account.sessionStore.archiveAllSessions();
|
||||
account.senderKeyStore.deleteAll();
|
||||
|
@ -249,7 +250,7 @@ public class SignalAccount implements Closeable {
|
|||
private static SignalAccount createLinkedAccount(
|
||||
File dataPath,
|
||||
String username,
|
||||
UUID uuid,
|
||||
ACI aci,
|
||||
String password,
|
||||
String encryptedDeviceName,
|
||||
int deviceId,
|
||||
|
@ -264,7 +265,7 @@ public class SignalAccount implements Closeable {
|
|||
final var pair = openFileChannel(fileName, true);
|
||||
var account = new SignalAccount(pair.first(), pair.second());
|
||||
|
||||
account.setProvisioningData(username, uuid, password, encryptedDeviceName, deviceId, profileKey);
|
||||
account.setProvisioningData(username, aci, password, encryptedDeviceName, deviceId, profileKey);
|
||||
|
||||
account.initStores(dataPath, identityKey, registrationId, trustNewIdentity);
|
||||
account.groupStore = new GroupStore(getGroupCachePath(dataPath, username),
|
||||
|
@ -282,14 +283,14 @@ public class SignalAccount implements Closeable {
|
|||
|
||||
private void setProvisioningData(
|
||||
final String username,
|
||||
final UUID uuid,
|
||||
final ACI aci,
|
||||
final String password,
|
||||
final String encryptedDeviceName,
|
||||
final int deviceId,
|
||||
final ProfileKey profileKey
|
||||
) {
|
||||
this.username = username;
|
||||
this.uuid = uuid;
|
||||
this.aci = aci;
|
||||
this.password = password;
|
||||
this.profileKey = profileKey;
|
||||
this.encryptedDeviceName = encryptedDeviceName;
|
||||
|
@ -404,7 +405,7 @@ public class SignalAccount implements Closeable {
|
|||
registered = Utils.getNotNullNode(rootNode, "registered").asBoolean();
|
||||
if (rootNode.hasNonNull("uuid")) {
|
||||
try {
|
||||
uuid = UUID.fromString(rootNode.get("uuid").asText());
|
||||
aci = ACI.from(UUID.fromString(rootNode.get("uuid").asText()));
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new IOException("Config file contains an invalid uuid, needs to be a valid UUID", e);
|
||||
}
|
||||
|
@ -702,7 +703,7 @@ public class SignalAccount implements Closeable {
|
|||
var rootNode = jsonProcessor.createObjectNode();
|
||||
rootNode.put("version", CURRENT_STORAGE_VERSION)
|
||||
.put("username", username)
|
||||
.put("uuid", uuid == null ? null : uuid.toString())
|
||||
.put("uuid", aci == null ? null : aci.toString())
|
||||
.put("deviceName", encryptedDeviceName)
|
||||
.put("deviceId", deviceId)
|
||||
.put("isMultiDevice", isMultiDevice)
|
||||
|
@ -830,21 +831,21 @@ public class SignalAccount implements Closeable {
|
|||
return username;
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
public ACI getAci() {
|
||||
return aci;
|
||||
}
|
||||
|
||||
public void setUuid(final UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
public void setAci(final ACI aci) {
|
||||
this.aci = aci;
|
||||
save();
|
||||
}
|
||||
|
||||
public SignalServiceAddress getSelfAddress() {
|
||||
return new SignalServiceAddress(uuid, username);
|
||||
return new SignalServiceAddress(aci, username);
|
||||
}
|
||||
|
||||
public RecipientId getSelfRecipientId() {
|
||||
return recipientStore.resolveRecipientTrusted(new RecipientAddress(uuid, username));
|
||||
return recipientStore.resolveRecipientTrusted(new RecipientAddress(aci.uuid(), username));
|
||||
}
|
||||
|
||||
public String getEncryptedDeviceName() {
|
||||
|
@ -991,7 +992,7 @@ public class SignalAccount implements Closeable {
|
|||
return true;
|
||||
}
|
||||
|
||||
public void finishRegistration(final UUID uuid, final MasterKey masterKey, final String pin) {
|
||||
public void finishRegistration(final ACI aci, final MasterKey masterKey, final String pin) {
|
||||
this.pinMasterKey = masterKey;
|
||||
this.storageManifestVersion = -1;
|
||||
this.storageKey = null;
|
||||
|
@ -999,7 +1000,7 @@ public class SignalAccount implements Closeable {
|
|||
this.deviceId = SignalServiceAddress.DEFAULT_DEVICE_ID;
|
||||
this.isMultiDevice = false;
|
||||
this.registered = true;
|
||||
this.uuid = uuid;
|
||||
this.aci = aci;
|
||||
this.registrationLockPin = pin;
|
||||
this.lastReceiveTimestamp = 0;
|
||||
save();
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.signal.storageservice.protos.groups.Member;
|
|||
import org.signal.storageservice.protos.groups.local.DecryptedGroup;
|
||||
import org.signal.storageservice.protos.groups.local.EnabledState;
|
||||
import org.signal.zkgroup.groups.GroupMasterKey;
|
||||
import org.whispersystems.signalservice.api.util.UuidUtil;
|
||||
import org.whispersystems.signalservice.api.push.ACI;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -99,7 +99,7 @@ public final class GroupInfoV2 extends GroupInfo {
|
|||
}
|
||||
return group.getMembersList()
|
||||
.stream()
|
||||
.map(m -> UuidUtil.parseOrThrow(m.getUuid().toByteArray()))
|
||||
.map(m -> ACI.fromByteString(m.getUuid()))
|
||||
.map(recipientResolver::resolveRecipient)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ public final class GroupInfoV2 extends GroupInfo {
|
|||
}
|
||||
return group.getPendingMembersList()
|
||||
.stream()
|
||||
.map(m -> UuidUtil.parseOrThrow(m.getUuid().toByteArray()))
|
||||
.map(m -> ACI.fromByteString(m.getUuid()))
|
||||
.map(recipientResolver::resolveRecipient)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ public final class GroupInfoV2 extends GroupInfo {
|
|||
}
|
||||
return group.getRequestingMembersList()
|
||||
.stream()
|
||||
.map(m -> UuidUtil.parseOrThrow(m.getUuid().toByteArray()))
|
||||
.map(m -> ACI.fromByteString(m.getUuid()))
|
||||
.map(recipientResolver::resolveRecipient)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ public final class GroupInfoV2 extends GroupInfo {
|
|||
return group.getMembersList()
|
||||
.stream()
|
||||
.filter(m -> m.getRole() == Member.Role.ADMINISTRATOR)
|
||||
.map(m -> UuidUtil.parseOrThrow(m.getUuid().toByteArray()))
|
||||
.map(m -> ACI.fromByteString(m.getUuid()))
|
||||
.map(recipientResolver::resolveRecipient)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.asamk.signal.manager.storage.recipients;
|
||||
|
||||
import org.whispersystems.signalservice.api.push.ACI;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
|
||||
import java.util.Optional;
|
||||
|
@ -7,7 +8,7 @@ import java.util.UUID;
|
|||
|
||||
public class RecipientAddress {
|
||||
|
||||
public static final UUID UNKNOWN_UUID = new UUID(0, 0);
|
||||
public static final UUID UNKNOWN_UUID = ACI.UNKNOWN.uuid();
|
||||
|
||||
private final Optional<UUID> uuid;
|
||||
private final Optional<String> e164;
|
||||
|
@ -33,7 +34,7 @@ public class RecipientAddress {
|
|||
}
|
||||
|
||||
public RecipientAddress(SignalServiceAddress address) {
|
||||
this(Optional.of(address.getUuid()), Optional.ofNullable(address.getNumber().orNull()));
|
||||
this(Optional.of(address.getAci().uuid()), Optional.ofNullable(address.getNumber().orNull()));
|
||||
}
|
||||
|
||||
public RecipientAddress(UUID uuid) {
|
||||
|
@ -75,7 +76,7 @@ public class RecipientAddress {
|
|||
}
|
||||
|
||||
public SignalServiceAddress toSignalServiceAddress() {
|
||||
return new SignalServiceAddress(uuid.orElse(UNKNOWN_UUID),
|
||||
return new SignalServiceAddress(ACI.from(uuid.orElse(UNKNOWN_UUID)),
|
||||
org.whispersystems.libsignal.util.guava.Optional.fromNullable(e164.orElse(null)));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
package org.asamk.signal.manager.storage.recipients;
|
||||
|
||||
import org.whispersystems.signalservice.api.push.ACI;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface RecipientResolver {
|
||||
|
||||
RecipientId resolveRecipient(String identifier);
|
||||
|
@ -12,5 +11,5 @@ public interface RecipientResolver {
|
|||
|
||||
RecipientId resolveRecipient(SignalServiceAddress address);
|
||||
|
||||
RecipientId resolveRecipient(UUID uuid);
|
||||
RecipientId resolveRecipient(ACI aci);
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.signal.zkgroup.profiles.ProfileKey;
|
|||
import org.signal.zkgroup.profiles.ProfileKeyCredential;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.whispersystems.signalservice.api.push.ACI;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException;
|
||||
import org.whispersystems.signalservice.api.util.UuidUtil;
|
||||
|
@ -137,8 +138,8 @@ public class RecipientStore implements RecipientResolver, ContactsStore, Profile
|
|||
}
|
||||
|
||||
@Override
|
||||
public RecipientId resolveRecipient(UUID uuid) {
|
||||
return resolveRecipient(new RecipientAddress(uuid), false);
|
||||
public RecipientId resolveRecipient(ACI aci) {
|
||||
return resolveRecipient(new RecipientAddress(aci.uuid()), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -147,19 +148,19 @@ public class RecipientStore implements RecipientResolver, ContactsStore, Profile
|
|||
}
|
||||
|
||||
public RecipientId resolveRecipient(
|
||||
final String number, Supplier<UUID> uuidSupplier
|
||||
final String number, Supplier<ACI> aciSupplier
|
||||
) throws UnregisteredUserException {
|
||||
final Optional<Recipient> byNumber;
|
||||
synchronized (recipients) {
|
||||
byNumber = findByNumberLocked(number);
|
||||
}
|
||||
if (byNumber.isEmpty() || byNumber.get().getAddress().getUuid().isEmpty()) {
|
||||
final var uuid = uuidSupplier.get();
|
||||
if (uuid == null) {
|
||||
final var aci = aciSupplier.get();
|
||||
if (aci == null) {
|
||||
throw new UnregisteredUserException(number, null);
|
||||
}
|
||||
|
||||
return resolveRecipient(new RecipientAddress(uuid, number), false);
|
||||
return resolveRecipient(new RecipientAddress(aci.uuid(), number), false);
|
||||
}
|
||||
return byNumber.get().getRecipientId();
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@ package org.asamk.signal.manager.util;
|
|||
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
|
||||
import org.whispersystems.signalservice.api.push.ACI;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.api.util.UuidUtil;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
@ -11,7 +11,6 @@ import java.io.File;
|
|||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
public class MessageCacheUtils {
|
||||
|
||||
|
@ -24,9 +23,9 @@ public class MessageCacheUtils {
|
|||
}
|
||||
var type = in.readInt();
|
||||
var source = in.readUTF();
|
||||
UUID sourceUuid = null;
|
||||
ACI sourceAci = null;
|
||||
if (version >= 3) {
|
||||
sourceUuid = UuidUtil.parseOrNull(in.readUTF());
|
||||
sourceAci = ACI.parseOrNull(in.readUTF());
|
||||
}
|
||||
var sourceDevice = in.readInt();
|
||||
if (version == 1) {
|
||||
|
@ -59,9 +58,9 @@ public class MessageCacheUtils {
|
|||
if (version >= 4) {
|
||||
serverDeliveredTimestamp = in.readLong();
|
||||
}
|
||||
Optional<SignalServiceAddress> addressOptional = sourceUuid == null
|
||||
Optional<SignalServiceAddress> addressOptional = sourceAci == null
|
||||
? Optional.absent()
|
||||
: Optional.of(new SignalServiceAddress(sourceUuid, source));
|
||||
: Optional.of(new SignalServiceAddress(sourceAci, source));
|
||||
return new SignalServiceEnvelope(type,
|
||||
addressOptional,
|
||||
sourceDevice,
|
||||
|
|
|
@ -5,7 +5,6 @@ import org.whispersystems.libsignal.fingerprint.Fingerprint;
|
|||
import org.whispersystems.libsignal.fingerprint.NumericFingerprintGenerator;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.api.util.StreamDetails;
|
||||
import org.whispersystems.signalservice.api.util.UuidUtil;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
|
@ -51,8 +50,8 @@ public class Utils {
|
|||
if (isUuidCapable) {
|
||||
// Version 2: UUID user
|
||||
version = 2;
|
||||
ownId = UuidUtil.toByteArray(ownAddress.getUuid());
|
||||
theirId = UuidUtil.toByteArray(theirAddress.getUuid());
|
||||
ownId = ownAddress.getAci().toByteArray();
|
||||
theirId = theirAddress.getAci().toByteArray();
|
||||
} else {
|
||||
// Version 1: E164 user
|
||||
version = 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue