mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +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" }
|
slf4j-jul = { module = "org.slf4j:jul-to-slf4j", version.ref = "slf4j" }
|
||||||
logback = "ch.qos.logback:logback-classic:1.5.17"
|
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"
|
sqlite = "org.xerial:sqlite-jdbc:3.49.1.0"
|
||||||
hikari = "com.zaxxer:HikariCP:6.2.1"
|
hikari = "com.zaxxer:HikariCP:6.2.1"
|
||||||
junit-jupiter = "org.junit.jupiter:junit-jupiter:5.12.0"
|
junit-jupiter = "org.junit.jupiter:junit-jupiter:5.12.0"
|
||||||
|
|
|
@ -102,7 +102,7 @@ public class AccountHelper {
|
||||||
checkWhoAmiI();
|
checkWhoAmiI();
|
||||||
}
|
}
|
||||||
if (!account.isPrimaryDevice() && account.getPniIdentityKeyPair() == null) {
|
if (!account.isPrimaryDevice() && account.getPniIdentityKeyPair() == null) {
|
||||||
context.getSyncHelper().requestSyncPniIdentity();
|
throw new IOException("Missing PNI identity key, relinking required");
|
||||||
}
|
}
|
||||||
if (account.getPreviousStorageVersion() < 4
|
if (account.getPreviousStorageVersion() < 4
|
||||||
&& account.isPrimaryDevice()
|
&& account.isPrimaryDevice()
|
||||||
|
|
|
@ -70,17 +70,12 @@ public class SyncHelper {
|
||||||
requestSyncData(SyncMessage.Request.Type.BLOCKED);
|
requestSyncData(SyncMessage.Request.Type.BLOCKED);
|
||||||
requestSyncData(SyncMessage.Request.Type.CONFIGURATION);
|
requestSyncData(SyncMessage.Request.Type.CONFIGURATION);
|
||||||
requestSyncKeys();
|
requestSyncKeys();
|
||||||
requestSyncPniIdentity();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void requestSyncKeys() {
|
public void requestSyncKeys() {
|
||||||
requestSyncData(SyncMessage.Request.Type.KEYS);
|
requestSyncData(SyncMessage.Request.Type.KEYS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void requestSyncPniIdentity() {
|
|
||||||
requestSyncData(SyncMessage.Request.Type.PNI_IDENTITY);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SendMessageResult sendSyncFetchProfileMessage() {
|
public SendMessageResult sendSyncFetchProfileMessage() {
|
||||||
return context.getSendHelper()
|
return context.getSendHelper()
|
||||||
.sendSyncMessage(SignalServiceSyncMessage.forFetchLatest(SignalServiceSyncMessage.FetchType.LOCAL_PROFILE));
|
.sendSyncMessage(SignalServiceSyncMessage.forFetchLatest(SignalServiceSyncMessage.FetchType.LOCAL_PROFILE));
|
||||||
|
@ -165,7 +160,7 @@ public class SyncHelper {
|
||||||
final var contact = contactPair.second();
|
final var contact = contactPair.second();
|
||||||
final var address = account.getRecipientAddressResolver().resolveRecipientAddress(recipientId);
|
final var address = account.getRecipientAddressResolver().resolveRecipientAddress(recipientId);
|
||||||
|
|
||||||
final var deviceContact = getDeviceContact(address, recipientId, contact);
|
final var deviceContact = getDeviceContact(address, contact);
|
||||||
out.write(deviceContact);
|
out.write(deviceContact);
|
||||||
deviceContact.getAvatar().ifPresent(a -> {
|
deviceContact.getAvatar().ifPresent(a -> {
|
||||||
try {
|
try {
|
||||||
|
@ -180,7 +175,7 @@ public class SyncHelper {
|
||||||
final var address = account.getSelfRecipientAddress();
|
final var address = account.getSelfRecipientAddress();
|
||||||
final var recipientId = account.getSelfRecipientId();
|
final var recipientId = account.getSelfRecipientId();
|
||||||
final var contact = account.getContactStore().getContact(recipientId);
|
final var contact = account.getContactStore().getContact(recipientId);
|
||||||
final var deviceContact = getDeviceContact(address, recipientId, contact);
|
final var deviceContact = getDeviceContact(address, contact);
|
||||||
out.write(deviceContact);
|
out.write(deviceContact);
|
||||||
deviceContact.getAvatar().ifPresent(a -> {
|
deviceContact.getAvatar().ifPresent(a -> {
|
||||||
try {
|
try {
|
||||||
|
@ -216,34 +211,14 @@ public class SyncHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private DeviceContact getDeviceContact(
|
private DeviceContact getDeviceContact(final RecipientAddress address, final Contact contact) throws IOException {
|
||||||
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);
|
|
||||||
return new DeviceContact(address.aci(),
|
return new DeviceContact(address.aci(),
|
||||||
address.number(),
|
address.number(),
|
||||||
Optional.ofNullable(contact == null ? null : contact.getName()),
|
Optional.ofNullable(contact == null ? null : contact.getName()),
|
||||||
createContactAvatarAttachment(address),
|
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.messageExpirationTime()),
|
||||||
Optional.ofNullable(contact == null ? null : contact.messageExpirationTimeVersion()),
|
Optional.ofNullable(contact == null ? null : contact.messageExpirationTimeVersion()),
|
||||||
Optional.empty(),
|
Optional.empty());
|
||||||
contact != null && contact.isArchived());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SendMessageResult sendBlockedList() {
|
public SendMessageResult sendBlockedList() {
|
||||||
|
@ -376,9 +351,6 @@ public class SyncHelper {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
final var address = new RecipientAddress(c.getAci(), Optional.empty(), c.getE164(), Optional.empty());
|
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);
|
final var recipientId = account.getRecipientTrustedResolver().resolveRecipientTrusted(address);
|
||||||
var contact = account.getContactStore().getContact(recipientId);
|
var contact = account.getContactStore().getContact(recipientId);
|
||||||
final var builder = contact == null ? Contact.newBuilder() : Contact.newBuilder(contact);
|
final var builder = contact == null ? Contact.newBuilder() : Contact.newBuilder(contact);
|
||||||
|
@ -390,19 +362,6 @@ public class SyncHelper {
|
||||||
builder.withGivenName(c.getName().get());
|
builder.withGivenName(c.getName().get());
|
||||||
builder.withFamilyName(null);
|
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.getExpirationTimer().isPresent()) {
|
||||||
if (c.getExpirationTimerVersion().isPresent() && (
|
if (c.getExpirationTimerVersion().isPresent() && (
|
||||||
contact == null || c.getExpirationTimerVersion().get() > contact.messageExpirationTimeVersion()
|
contact == null || c.getExpirationTimerVersion().get() > contact.messageExpirationTimeVersion()
|
||||||
|
@ -417,7 +376,6 @@ public class SyncHelper {
|
||||||
contact == null ? 1 : contact.messageExpirationTimeVersion());
|
contact == null ? 1 : contact.messageExpirationTimeVersion());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
builder.withIsArchived(c.isArchived());
|
|
||||||
account.getContactStore().storeContact(recipientId, builder.build());
|
account.getContactStore().storeContact(recipientId, builder.build());
|
||||||
|
|
||||||
if (c.getAvatar().isPresent()) {
|
if (c.getAvatar().isPresent()) {
|
||||||
|
|
|
@ -23,8 +23,8 @@ public class PaymentUtils {
|
||||||
public static PaymentAddress signPaymentsAddress(byte[] publicAddressBytes, ECPrivateKey privateKey) {
|
public static PaymentAddress signPaymentsAddress(byte[] publicAddressBytes, ECPrivateKey privateKey) {
|
||||||
byte[] signature = privateKey.calculateSignature(publicAddressBytes);
|
byte[] signature = privateKey.calculateSignature(publicAddressBytes);
|
||||||
|
|
||||||
return new PaymentAddress.Builder().mobileCoinAddress(new PaymentAddress.MobileCoinAddress.Builder().address(
|
return new PaymentAddress.Builder().mobileCoin(new PaymentAddress.MobileCoin.Builder().publicAddress(ByteString.of(
|
||||||
ByteString.of(publicAddressBytes)).signature(ByteString.of(signature)).build()).build();
|
publicAddressBytes)).signature(ByteString.of(signature)).build()).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,13 +33,15 @@ public class PaymentUtils {
|
||||||
* Returns the validated bytes if so, otherwise returns null.
|
* Returns the validated bytes if so, otherwise returns null.
|
||||||
*/
|
*/
|
||||||
public static byte[] verifyPaymentsAddress(PaymentAddress paymentAddress, ECPublicKey publicKey) {
|
public static byte[] verifyPaymentsAddress(PaymentAddress paymentAddress, ECPublicKey publicKey) {
|
||||||
final var mobileCoinAddress = paymentAddress.mobileCoinAddress;
|
final var mobileCoinAddress = paymentAddress.mobileCoin;
|
||||||
if (mobileCoinAddress == null || mobileCoinAddress.address == null || mobileCoinAddress.signature == null) {
|
if (mobileCoinAddress == null
|
||||||
|
|| mobileCoinAddress.publicAddress == null
|
||||||
|
|| mobileCoinAddress.signature == null) {
|
||||||
logger.debug("Got payment address without mobile coin address, ignoring.");
|
logger.debug("Got payment address without mobile coin address, ignoring.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] bytes = mobileCoinAddress.address.toByteArray();
|
byte[] bytes = mobileCoinAddress.publicAddress.toByteArray();
|
||||||
byte[] signature = mobileCoinAddress.signature.toByteArray();
|
byte[] signature = mobileCoinAddress.signature.toByteArray();
|
||||||
|
|
||||||
if (signature.length != 64 || !publicKey.verifySignature(bytes, signature)) {
|
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();
|
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"))
|
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
|
static final String USER_AGENT_SIGNAL_CLI = PROJECT_NAME == null
|
||||||
? "signal-cli"
|
? "signal-cli"
|
||||||
: PROJECT_NAME + "/" + PROJECT_VERSION;
|
: PROJECT_NAME + "/" + PROJECT_VERSION;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue