mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-28 18:10:38 +00:00
Update libsignal-service
This commit is contained in:
parent
5693d871f7
commit
985af6e445
5 changed files with 14 additions and 54 deletions
|
@ -10,7 +10,7 @@ slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" }
|
|||
slf4j-jul = { module = "org.slf4j:jul-to-slf4j", version.ref = "slf4j" }
|
||||
logback = "ch.qos.logback:logback-classic:1.5.17"
|
||||
|
||||
signalservice = "com.github.turasa:signal-service-java:2.15.3_unofficial_117"
|
||||
signalservice = "com.github.turasa:signal-service-java:2.15.3_unofficial_118"
|
||||
sqlite = "org.xerial:sqlite-jdbc:3.49.1.0"
|
||||
hikari = "com.zaxxer:HikariCP:6.2.1"
|
||||
junit-jupiter = "org.junit.jupiter:junit-jupiter:5.12.0"
|
||||
|
|
|
@ -102,7 +102,7 @@ public class AccountHelper {
|
|||
checkWhoAmiI();
|
||||
}
|
||||
if (!account.isPrimaryDevice() && account.getPniIdentityKeyPair() == null) {
|
||||
context.getSyncHelper().requestSyncPniIdentity();
|
||||
throw new IOException("Missing PNI identity key, relinking required");
|
||||
}
|
||||
if (account.getPreviousStorageVersion() < 4
|
||||
&& account.isPrimaryDevice()
|
||||
|
|
|
@ -70,17 +70,12 @@ public class SyncHelper {
|
|||
requestSyncData(SyncMessage.Request.Type.BLOCKED);
|
||||
requestSyncData(SyncMessage.Request.Type.CONFIGURATION);
|
||||
requestSyncKeys();
|
||||
requestSyncPniIdentity();
|
||||
}
|
||||
|
||||
public void requestSyncKeys() {
|
||||
requestSyncData(SyncMessage.Request.Type.KEYS);
|
||||
}
|
||||
|
||||
public void requestSyncPniIdentity() {
|
||||
requestSyncData(SyncMessage.Request.Type.PNI_IDENTITY);
|
||||
}
|
||||
|
||||
public SendMessageResult sendSyncFetchProfileMessage() {
|
||||
return context.getSendHelper()
|
||||
.sendSyncMessage(SignalServiceSyncMessage.forFetchLatest(SignalServiceSyncMessage.FetchType.LOCAL_PROFILE));
|
||||
|
@ -165,7 +160,7 @@ public class SyncHelper {
|
|||
final var contact = contactPair.second();
|
||||
final var address = account.getRecipientAddressResolver().resolveRecipientAddress(recipientId);
|
||||
|
||||
final var deviceContact = getDeviceContact(address, recipientId, contact);
|
||||
final var deviceContact = getDeviceContact(address, contact);
|
||||
out.write(deviceContact);
|
||||
deviceContact.getAvatar().ifPresent(a -> {
|
||||
try {
|
||||
|
@ -180,7 +175,7 @@ public class SyncHelper {
|
|||
final var address = account.getSelfRecipientAddress();
|
||||
final var recipientId = account.getSelfRecipientId();
|
||||
final var contact = account.getContactStore().getContact(recipientId);
|
||||
final var deviceContact = getDeviceContact(address, recipientId, contact);
|
||||
final var deviceContact = getDeviceContact(address, contact);
|
||||
out.write(deviceContact);
|
||||
deviceContact.getAvatar().ifPresent(a -> {
|
||||
try {
|
||||
|
@ -216,34 +211,14 @@ public class SyncHelper {
|
|||
}
|
||||
|
||||
@NotNull
|
||||
private DeviceContact getDeviceContact(
|
||||
final RecipientAddress address,
|
||||
final RecipientId recipientId,
|
||||
final Contact contact
|
||||
) throws IOException {
|
||||
var currentIdentity = address.serviceId().isEmpty()
|
||||
? null
|
||||
: account.getIdentityKeyStore().getIdentityInfo(address.serviceId().get());
|
||||
VerifiedMessage verifiedMessage = null;
|
||||
if (currentIdentity != null) {
|
||||
verifiedMessage = new VerifiedMessage(address.toSignalServiceAddress(),
|
||||
currentIdentity.getIdentityKey(),
|
||||
currentIdentity.getTrustLevel().toVerifiedState(),
|
||||
currentIdentity.getDateAddedTimestamp());
|
||||
}
|
||||
|
||||
var profileKey = account.getProfileStore().getProfileKey(recipientId);
|
||||
private DeviceContact getDeviceContact(final RecipientAddress address, final Contact contact) throws IOException {
|
||||
return new DeviceContact(address.aci(),
|
||||
address.number(),
|
||||
Optional.ofNullable(contact == null ? null : contact.getName()),
|
||||
createContactAvatarAttachment(address),
|
||||
Optional.ofNullable(contact == null ? null : contact.color()),
|
||||
Optional.ofNullable(verifiedMessage),
|
||||
Optional.ofNullable(profileKey),
|
||||
Optional.ofNullable(contact == null ? null : contact.messageExpirationTime()),
|
||||
Optional.ofNullable(contact == null ? null : contact.messageExpirationTimeVersion()),
|
||||
Optional.empty(),
|
||||
contact != null && contact.isArchived());
|
||||
Optional.empty());
|
||||
}
|
||||
|
||||
public SendMessageResult sendBlockedList() {
|
||||
|
@ -376,9 +351,6 @@ public class SyncHelper {
|
|||
break;
|
||||
}
|
||||
final var address = new RecipientAddress(c.getAci(), Optional.empty(), c.getE164(), Optional.empty());
|
||||
if (address.matches(account.getSelfRecipientAddress()) && c.getProfileKey().isPresent()) {
|
||||
account.setProfileKey(c.getProfileKey().get());
|
||||
}
|
||||
final var recipientId = account.getRecipientTrustedResolver().resolveRecipientTrusted(address);
|
||||
var contact = account.getContactStore().getContact(recipientId);
|
||||
final var builder = contact == null ? Contact.newBuilder() : Contact.newBuilder(contact);
|
||||
|
@ -390,19 +362,6 @@ public class SyncHelper {
|
|||
builder.withGivenName(c.getName().get());
|
||||
builder.withFamilyName(null);
|
||||
}
|
||||
if (c.getColor().isPresent()) {
|
||||
builder.withColor(c.getColor().get());
|
||||
}
|
||||
if (c.getProfileKey().isPresent()) {
|
||||
account.getProfileStore().storeProfileKey(recipientId, c.getProfileKey().get());
|
||||
}
|
||||
if (c.getVerified().isPresent()) {
|
||||
final var verifiedMessage = c.getVerified().get();
|
||||
account.getIdentityKeyStore()
|
||||
.setIdentityTrustLevel(verifiedMessage.getDestination().getServiceId(),
|
||||
verifiedMessage.getIdentityKey(),
|
||||
TrustLevel.fromVerifiedState(verifiedMessage.getVerified()));
|
||||
}
|
||||
if (c.getExpirationTimer().isPresent()) {
|
||||
if (c.getExpirationTimerVersion().isPresent() && (
|
||||
contact == null || c.getExpirationTimerVersion().get() > contact.messageExpirationTimeVersion()
|
||||
|
@ -417,7 +376,6 @@ public class SyncHelper {
|
|||
contact == null ? 1 : contact.messageExpirationTimeVersion());
|
||||
}
|
||||
}
|
||||
builder.withIsArchived(c.isArchived());
|
||||
account.getContactStore().storeContact(recipientId, builder.build());
|
||||
|
||||
if (c.getAvatar().isPresent()) {
|
||||
|
|
|
@ -23,8 +23,8 @@ public class PaymentUtils {
|
|||
public static PaymentAddress signPaymentsAddress(byte[] publicAddressBytes, ECPrivateKey privateKey) {
|
||||
byte[] signature = privateKey.calculateSignature(publicAddressBytes);
|
||||
|
||||
return new PaymentAddress.Builder().mobileCoinAddress(new PaymentAddress.MobileCoinAddress.Builder().address(
|
||||
ByteString.of(publicAddressBytes)).signature(ByteString.of(signature)).build()).build();
|
||||
return new PaymentAddress.Builder().mobileCoin(new PaymentAddress.MobileCoin.Builder().publicAddress(ByteString.of(
|
||||
publicAddressBytes)).signature(ByteString.of(signature)).build()).build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,13 +33,15 @@ public class PaymentUtils {
|
|||
* Returns the validated bytes if so, otherwise returns null.
|
||||
*/
|
||||
public static byte[] verifyPaymentsAddress(PaymentAddress paymentAddress, ECPublicKey publicKey) {
|
||||
final var mobileCoinAddress = paymentAddress.mobileCoinAddress;
|
||||
if (mobileCoinAddress == null || mobileCoinAddress.address == null || mobileCoinAddress.signature == null) {
|
||||
final var mobileCoinAddress = paymentAddress.mobileCoin;
|
||||
if (mobileCoinAddress == null
|
||||
|| mobileCoinAddress.publicAddress == null
|
||||
|| mobileCoinAddress.signature == null) {
|
||||
logger.debug("Got payment address without mobile coin address, ignoring.");
|
||||
return null;
|
||||
}
|
||||
|
||||
byte[] bytes = mobileCoinAddress.address.toByteArray();
|
||||
byte[] bytes = mobileCoinAddress.publicAddress.toByteArray();
|
||||
byte[] signature = mobileCoinAddress.signature.toByteArray();
|
||||
|
||||
if (signature.length != 64 || !publicKey.verifySignature(bytes, signature)) {
|
||||
|
|
|
@ -8,7 +8,7 @@ public class BaseConfig {
|
|||
public static final String PROJECT_VERSION = BaseConfig.class.getPackage().getImplementationVersion();
|
||||
|
||||
static final String USER_AGENT_SIGNAL_ANDROID = Optional.ofNullable(System.getenv("SIGNAL_CLI_USER_AGENT"))
|
||||
.orElse("Signal-Android/7.30.1");
|
||||
.orElse("Signal-Android/7.35.0");
|
||||
static final String USER_AGENT_SIGNAL_CLI = PROJECT_NAME == null
|
||||
? "signal-cli"
|
||||
: PROJECT_NAME + "/" + PROJECT_VERSION;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue