Skip to content

Commit

Permalink
[signal] musl support + update to signal-cli 0.13.3 + support for rea…
Browse files Browse the repository at this point in the history
…ction
  • Loading branch information
dalgwen committed Apr 27, 2024
1 parent e12a01c commit f4c3e8a
Show file tree
Hide file tree
Showing 55 changed files with 642 additions and 262 deletions.
12 changes: 6 additions & 6 deletions bundles/org.openhab.binding.signal/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
<dependency>
<artifactId>signal-service-java</artifactId>
<groupId>com.github.turasa</groupId>
<version>2.15.3_unofficial_96</version>
<version>2.15.3_unofficial_101</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.turasa</groupId>
<artifactId>core-util-jvm</artifactId>
<version>2.15.3_unofficial_96</version>
<version>2.15.3_unofficial_101</version>
</dependency>
<dependency>
<groupId>com.squareup.wire</groupId>
Expand All @@ -41,7 +41,7 @@
<dependency>
<groupId>org.signal</groupId>
<artifactId>libsignal-client</artifactId>
<version>0.39.2</version>
<version>0.44.0</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand All @@ -64,7 +64,7 @@
<dependency>
<artifactId>bcpkix-jdk18on</artifactId>
<groupId>org.bouncycastle</groupId>
<version>1.77</version>
<version>1.76</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand All @@ -82,7 +82,7 @@
<dependency>
<groupId>com.googlecode.libphonenumber</groupId>
<artifactId>libphonenumber</artifactId>
<version>8.13.19</version>
<version>8.13.23</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand All @@ -100,7 +100,7 @@
<dependency>
<groupId>com.squareup.okio</groupId>
<artifactId>okio</artifactId>
<version>3.0.0</version>
<version>3.6.0</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.asamk.signal.manager.api.AlreadyReceivingException;
import org.asamk.signal.manager.api.AttachmentInvalidException;
import org.asamk.signal.manager.api.CaptchaRejectedException;
import org.asamk.signal.manager.api.CaptchaRequiredException;
import org.asamk.signal.manager.api.Configuration;
import org.asamk.signal.manager.api.Device;
Expand Down Expand Up @@ -43,6 +44,8 @@
import org.asamk.signal.manager.api.UpdateProfile;
import org.asamk.signal.manager.api.UserStatus;
import org.asamk.signal.manager.api.UsernameLinkUrl;
import org.asamk.signal.manager.api.UsernameStatus;
import org.asamk.signal.manager.api.VerificationMethodNotAvailableException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.whispersystems.signalservice.api.util.PhoneNumberFormatter;
Expand Down Expand Up @@ -90,6 +93,8 @@ static boolean isSignalClientAvailable() {
*/
Map<String, UserStatus> getUserStatus(Set<String> numbers) throws IOException, RateLimitException;

Map<String, UsernameStatus> getUsernameStatus(Set<String> usernames);

void updateAccountAttributes(
String deviceName,
Boolean unrestrictedUnidentifiedSender,
Expand Down Expand Up @@ -125,7 +130,7 @@ void updateAccountAttributes(

void startChangeNumber(
String newNumber, boolean voiceVerification, String captcha
) throws RateLimitException, IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, NotPrimaryDeviceException;
) throws RateLimitException, IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, NotPrimaryDeviceException, VerificationMethodNotAvailableException;

void finishChangeNumber(
String newNumber, String verificationCode, String pin
Expand All @@ -135,11 +140,13 @@ void finishChangeNumber(

void deleteAccount() throws IOException;

void submitRateLimitRecaptchaChallenge(String challenge, String captcha) throws IOException;
void submitRateLimitRecaptchaChallenge(
String challenge, String captcha
) throws IOException, CaptchaRejectedException;

List<Device> getLinkedDevices() throws IOException;

void removeLinkedDevices(int deviceId) throws IOException;
void removeLinkedDevices(int deviceId) throws IOException, NotPrimaryDeviceException;

void addDeviceLink(DeviceLinkUrl linkUri) throws IOException, InvalidDeviceLinkException, NotPrimaryDeviceException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
import org.asamk.signal.manager.api.NonNormalizedPhoneNumberException;
import org.asamk.signal.manager.api.PinLockedException;
import org.asamk.signal.manager.api.RateLimitException;
import org.asamk.signal.manager.api.VerificationMethodNotAvailableException;

import java.io.Closeable;
import java.io.IOException;

public interface RegistrationManager extends Closeable {

void register(
boolean voiceVerification, String captcha
) throws IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, RateLimitException;
boolean voiceVerification, String captcha, final boolean forceRegister
) throws IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, RateLimitException, VerificationMethodNotAvailableException;

void verifyAccount(
String verificationCode, String pin
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.asamk.signal.manager.api;

public class CaptchaRejectedException extends Exception {

public CaptchaRejectedException() {
super("Captcha rejected");
}

public CaptchaRejectedException(final String message) {
super(message);
}

public CaptchaRejectedException(final String message, final Throwable cause) {
super(message, cause);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ public record Contact(
String givenName,
String familyName,
String nickName,
String nickNameGivenName,
String nickNameFamilyName,
String note,
String color,
int messageExpirationTime,
long muteUntil,
Expand All @@ -21,6 +24,9 @@ private Contact(final Builder builder) {
this(builder.givenName,
builder.familyName,
builder.nickName,
builder.nickNameGivenName,
builder.nickNameFamilyName,
builder.note,
builder.color,
builder.messageExpirationTime,
builder.muteUntil,
Expand Down Expand Up @@ -73,6 +79,9 @@ public static final class Builder {
private String givenName;
private String familyName;
private String nickName;
private String nickNameGivenName;
private String nickNameFamilyName;
private String note;
private String color;
private int messageExpirationTime;
private long muteUntil;
Expand Down Expand Up @@ -105,6 +114,21 @@ public Builder withNickName(final String val) {
return this;
}

public Builder withNickNameGivenName(final String val) {
nickNameGivenName = val;
return this;
}

public Builder withNickNameFamilyName(final String val) {
nickNameFamilyName = val;
return this;
}

public Builder withNote(final String val) {
note = val;
return this;
}

public Builder withColor(final String val) {
color = val;
return this;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
package org.asamk.signal.manager.api;

import org.signal.libsignal.protocol.IdentityKey;

public record Identity(
RecipientAddress recipient,
IdentityKey identityKey,
byte[] fingerprint,
String safetyNumber,
byte[] scannableSafetyNumber,
TrustLevel trustLevel,
long dateAddedTimestamp
) {

public byte[] getFingerprint() {
return identityKey.getPublicKey().serialize();
}
}
) {}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,16 @@
public enum PhoneNumberSharingMode {
EVERYBODY,
CONTACTS,
NOBODY,
NOBODY;

public static PhoneNumberSharingMode valueOfOrNull(String value) {
if (value == null) {
return null;
}
try {
return valueOf(value);
} catch (IllegalArgumentException ignored) {
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public class Profile {

private final Set<Capability> capabilities;

private final PhoneNumberSharingMode phoneNumberSharingMode;

public Profile(
final long lastUpdateTimestamp,
final String givenName,
Expand All @@ -35,7 +37,8 @@ public Profile(
final String avatarUrlPath,
final byte[] mobileCoinAddress,
final UnidentifiedAccessMode unidentifiedAccessMode,
final Set<Capability> capabilities
final Set<Capability> capabilities,
final PhoneNumberSharingMode phoneNumberSharingMode
) {
this.lastUpdateTimestamp = lastUpdateTimestamp;
this.givenName = givenName;
Expand All @@ -46,6 +49,7 @@ public Profile(
this.mobileCoinAddress = mobileCoinAddress;
this.unidentifiedAccessMode = unidentifiedAccessMode;
this.capabilities = capabilities;
this.phoneNumberSharingMode = phoneNumberSharingMode;
}

private Profile(final Builder builder) {
Expand All @@ -58,6 +62,7 @@ private Profile(final Builder builder) {
mobileCoinAddress = builder.mobileCoinAddress;
unidentifiedAccessMode = builder.unidentifiedAccessMode;
capabilities = builder.capabilities;
phoneNumberSharingMode = builder.phoneNumberSharingMode;
}

public static Builder newBuilder() {
Expand Down Expand Up @@ -136,6 +141,10 @@ public Set<Capability> getCapabilities() {
return capabilities;
}

public PhoneNumberSharingMode getPhoneNumberSharingMode() {
return phoneNumberSharingMode;
}

public enum UnidentifiedAccessMode {
UNKNOWN,
DISABLED,
Expand All @@ -152,10 +161,7 @@ public static UnidentifiedAccessMode valueOfOrUnknown(String value) {
}

public enum Capability {
storage,
gv1Migration,
senderKey,
announcementGroup;
storage;

public static Capability valueOfOrNull(String value) {
try {
Expand Down Expand Up @@ -203,6 +209,7 @@ public static final class Builder {
private byte[] mobileCoinAddress;
private UnidentifiedAccessMode unidentifiedAccessMode = UnidentifiedAccessMode.UNKNOWN;
private Set<Capability> capabilities = Collections.emptySet();
private PhoneNumberSharingMode phoneNumberSharingMode;
private long lastUpdateTimestamp = 0;

private Builder() {
Expand Down Expand Up @@ -243,6 +250,11 @@ public Builder withCapabilities(final Set<Capability> val) {
return this;
}

public Builder withPhoneNumberSharingMode(final PhoneNumberSharingMode val) {
phoneNumberSharingMode = val;
return this;
}

public Profile build() {
return new Profile(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ public long getRetryAfterSeconds() {
}

public enum Option {
RECAPTCHA,
CAPTCHA,
PUSH_CHALLENGE;

static Option from(org.whispersystems.signalservice.api.push.exceptions.ProofRequiredException.Option option) {
return switch (option) {
case RECAPTCHA -> RECAPTCHA;
case RECAPTCHA -> CAPTCHA;
case CAPTCHA -> CAPTCHA;
case PUSH_CHALLENGE -> PUSH_CHALLENGE;
};
}
Expand Down
Loading

0 comments on commit f4c3e8a

Please sign in to comment.