Signal

expect class Signal : SignaldClient
actual class Signal : SignaldClient

An asynchronous signald client, for use with V1 of the signald protocol. Use the create function to create an instance.

actual class Signal constructor(accountId: String, socketPath: String?) : SignaldClient

A synchronous signald client, for use with V1 of the signald protocol. Note that the functions and the constructor can block the thread that called the function / constructor due to reads and writes responses from a UNIX socket via blocking method calls.

Parameters

accountId
socketPath

An optional path to the signald socket.

accountId
socketPath

An optional path to the signald socket.

Throws

if unable to get list of accounts to cache current account data if already registered.

if unable to get list of accounts to cache current account data if already registered.

Constructors

Link copied to clipboard
fun Signal(accountId: String, socketPath: String? = null)

Creates a Signal instance for a particular account. A connection with the signald socket with be attempted, throwing an exception if unable to connect to the socket.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
suspend fun acceptInvitation(groupID: String): JsonGroupV2Info

Accept a group V2 invitation. Note that you must have a profile name set to join groups.

fun acceptInvitation(groupID: String): JsonGroupV2Info

Accept a group V2 invitation. Note that you must have a profile name set to join groups.

Link copied to clipboard
suspend fun addDevice(uri: String)

Adds a linked device to the current account.

fun addDevice(uri: String)

Adds a linked device to the current account.

Link copied to clipboard
suspend fun addServer(server: Server): String

Adds a new server to connect to and returns the new server's UUID.

fun addServer(server: Server): String

Adds a new server to connect to and returns the new server's UUID.

Link copied to clipboard
suspend fun approveMembership(groupID: String, members: Collection<JsonAddress>): JsonGroupV2Info

Approves the members requests to join a V2 group with the given groupID. Returns the new group information.

fun approveMembership(groupID: String, members: Collection<JsonAddress>): JsonGroupV2Info

Approves the members requests to join a V2 group with the given groupID. Returns the new group information.

Link copied to clipboard
suspend fun banUser(groupId: String, users: Collection<JsonAddress>): JsonGroupV2Info
fun banUser(groupId: String, users: Collection<JsonAddress>): JsonGroupV2Info
Link copied to clipboard
suspend fun createGroup(members: Collection<JsonAddress>, title: String, avatar: String? = null, timer: Int? = null, memberRole: String? = null): JsonGroupV2Info

Creates a new group and returns the information of the newly created group.

fun createGroup(members: Collection<JsonAddress>, title: String, avatar: String? = null, timer: Int? = null, memberRole: String? = null): JsonGroupV2Info

Creates a new group and returns the information of the newly created group.

Link copied to clipboard
suspend fun deleteAccount(alsoDeleteAccountOnServer: Boolean)

Deletes all account data signald has on disk, and optionally delete the account from the server as well. Note that this is not "unlink" and will delete the entire account, even from a linked device.

fun deleteAccount(alsoDeleteAccountOnServer: Boolean)

Deletes all account data signald has on disk, and optionally delete the account from the server as well. Note that this is not "unlink" and will delete the entire account, even from a linked device.

Link copied to clipboard
suspend fun deleteServer(serverUuid: String)

Deletes a previously added server from addServer.

fun deleteServer(serverUuid: String)

Deletes a previously added server from addServer.

Link copied to clipboard
suspend fun finishLink(deviceName: String, sessionId: String): Account

After a linking URI has been requested, finish_link must be called with the session_id provided with the URI.

fun finishLink(deviceName: String, sessionId: String): Account

After a linking URI has been requested, finish_link must be called with the session_id provided with the URI.

Link copied to clipboard
suspend fun generateLinkingUri(serverUuid: String? = null): LinkingURI

Generate a linking URI. Typically, this is QR encoded and scanned by the primary device. Submit the returned LinkingURI.sessionId with a finishLink request.

fun generateLinkingUri(serverUuid: String? = null): LinkingURI

Generate a linking URI. Typically, this is QR encoded and scanned by the primary device. Submit the returned LinkingURI.sessionId with a finishLink request.

Link copied to clipboard
suspend fun getAccountInfo(forceUpdate: Boolean = false): Account?
Link copied to clipboard
suspend fun getAllIdentities(): AllIdentityKeyList

Returns all known identity keys for the current account

fun getAllIdentities(): AllIdentityKeyList

Returns all known identity keys for the current account

Link copied to clipboard
suspend fun getGroup(groupID: String, revision: Int? = null): JsonGroupV2Info

Query the server for the latest state of a known group. If no account in signald is a member of the group (anymore), a RequestFailedException with RequestFailedException.errorType: 'UnknownGroupException' is returned.

fun getGroup(groupID: String, revision: Int? = null): JsonGroupV2Info

Query the server for the latest state of a known group. If no account in signald is a member of the group (anymore), a RequestFailedException with RequestFailedException.errorType: 'UnknownGroupException' is returned.

Link copied to clipboard
suspend fun getGroupLinkInfo(groupLink: String): JsonGroupJoinInfo

Get information about a group from a signal.groupgroupLink.

fun getGroupLinkInfo(groupLink: String): JsonGroupJoinInfo

Get information about a group from a signal.groupgroupLink.

Link copied to clipboard
suspend fun getGroupRevisionPages(groupId: String, fromRevision: Int, includeFirstRevision: Boolean = false): GroupHistoryPage

Query the server for group revision history. The history contains information about the changes between each revision and the user that made the change.

fun getGroupRevisionPages(groupId: String, fromRevision: Int, includeFirstRevision: Boolean = false): GroupHistoryPage

Query the server for group revision history. The history contains information about the changes between each revision and the user that made the change.

Link copied to clipboard
suspend fun getIdentities(address: JsonAddress): IdentityKeyList

Get information about known identity keys for a particular address.

fun getIdentities(address: JsonAddress): IdentityKeyList

Get information about known identity keys for a particular address.

Link copied to clipboard
suspend fun getLinkedDevices(): LinkedDevices

Gets a list of all linked devices for this account.

fun getLinkedDevices(): LinkedDevices

Gets a list of all linked devices for this account.

Link copied to clipboard
suspend fun getProfile(address: JsonAddress, async: Boolean = false): Profile

Gets all information available about a user

fun getProfile(address: JsonAddress, async: Boolean = false): Profile

Gets all information available about a user

Link copied to clipboard
suspend fun getServers(): ServerList

Gets a list of all signald servers

fun getServers(): ServerList

Gets a list of all signald servers

Link copied to clipboard
suspend fun isAddressRegistered(address: JsonAddress): Boolean

Takes an address and determines if the address is registered on Signal. If the address doesn't contain a UUID, it will attempt to resolve the address first

fun isAddressRegistered(address: JsonAddress): Boolean

Takes an address and determines if the address is registered on Signal. If the address doesn't contain a UUID, it will attempt to resolve the address first

Link copied to clipboard
suspend fun isIdentifierRegistered(identifierUuid: String): Boolean

Takes a UUID of an identifier to check if it is registered on Signal. This UUID is either a Phone Number Identity (PNI) or an Account Identity (ACI).

fun isIdentifierRegistered(identifierUuid: String): Boolean

Takes a UUID of an identifier to check if it is registered on Signal. This UUID is either a Phone Number Identity (PNI) or an Account Identity (ACI).

Link copied to clipboard
suspend fun isRegisteredWithSignald(): Boolean

Whether the accountId of this Signal instance is registered with signald. This will do a check with the socket to ensure that the account is present with signald.

Link copied to clipboard
suspend fun joinGroup(groupLink: String): JsonGroupJoinInfo

Joins a group using the given signal.groupgroupLink.

fun joinGroup(groupLink: String): JsonGroupJoinInfo

Joins a group using the given signal.groupgroupLink.

Link copied to clipboard
suspend fun leaveGroup(groupID: String, leaveGroupType: LeaveGroupType = LeaveGroupType.LEAVE_ONLY): GroupInfo

Leaves a group with the specified groupID.

fun leaveGroup(groupID: String, leaveGroupType: LeaveGroupType = LeaveGroupType.LEAVE_ONLY): GroupInfo

Leaves a group with the specified groupID

Link copied to clipboard
suspend fun listAccounts(): AccountList

Returns a list of Accounts logged-in to signald.

fun listAccounts(): AccountList

Returns a list of Accounts logged-in to signald.

Link copied to clipboard
suspend fun listContacts(async: Boolean? = null): ProfileList

Returns a list of contacts for this account.

fun listContacts(async: Boolean? = null): ProfileList

Returns a list of contacts for this account.

Link copied to clipboard
suspend fun listGroups(): GroupList

Returns a list of groups for this account.

fun listGroups(): GroupList

Returns a list of groups for this account.

Link copied to clipboard
suspend fun markRead(to: JsonAddress, timestamps: Collection<Long>, when: Long = Clock.System.now().toEpochMilliseconds())

Marks the given messages (represented as timestamps) as read. Note that messages are identified using their timestamps.

fun markRead(to: JsonAddress, timestamps: Collection<Long>, when: Long = Clock.System.now().toEpochMilliseconds())

Marks the given messages (represented as timestamps) as read. Note that messages are identified using their timestamps.

Link copied to clipboard
suspend fun react(recipient: Recipient, reaction: JsonReaction, timestamp: Long = Clock.System.now().toEpochMilliseconds()): SendResponse

Reacts to a previous message.

fun react(recipient: Recipient, reaction: JsonReaction, timestamp: Long = Clock.System.now().toEpochMilliseconds()): SendResponse

Reacts to a previous message.

Link copied to clipboard
suspend fun refuseMembership(groupID: String, members: Collection<JsonAddress>): JsonGroupV2Info

Deny requests from users from joining a group.

fun refuseMembership(groupID: String, members: Collection<JsonAddress>, alsoBan: Boolean = false): JsonGroupV2Info

Deny requests from users from joining a group.

Link copied to clipboard
suspend fun register(voice: Boolean = false, captcha: String? = null)

Begin the account registration process by requesting a phone number verification code. When the code is received, submit it with a verify request.

fun register(voice: Boolean = false, captcha: String? = null)

Begin the account registration process by requesting a phone number verification code. When the code is received, submit it with a verify request.

Link copied to clipboard
suspend fun remoteConfig(): RemoteConfigList

Gets the remote config (feature flags) from the server.

fun remoteConfig(): RemoteConfigList

Gets the remote config (feature flags) from the server

Link copied to clipboard
suspend fun remoteDelete(recipient: Recipient, timestampOfTarget: Long): SendResponse

Sends a remote delete message to delete a message that was previously sent to the given recipient (group or individual address).

fun remoteDelete(recipient: Recipient, timestampOfTarget: Long): SendResponse

Sends a remote delete message to delete a message that was previously sent to the given recipient (group or individual address).

Link copied to clipboard
suspend fun removeLinkedDevice(deviceId: Long)

Remove a linked device from the Signal account. Only allowed when the local device id is 1

fun removeLinkedDevice(deviceId: Long)

Remove a linked device from the Signal account. Only allowed when the local device id is 1

Link copied to clipboard
suspend fun requestSync(groups: Boolean = true, configuration: Boolean = true, contacts: Boolean = true, blocked: Boolean = true)

Request other devices on the account send us their group list, syncable config, contact list, and block list.

fun requestSync(groups: Boolean = true, configuration: Boolean = true, contacts: Boolean = true, blocked: Boolean = true)

Request other devices on the account send us their group list, syncable config, contact list, and block list.

Link copied to clipboard
suspend fun resetSession(address: JsonAddress, timestamp: Long = Clock.System.now().toEpochMilliseconds()): SendResponse

Resets a secure session with a particular user identified by the given address.

fun resetSession(address: JsonAddress, timestamp: Long = Clock.System.now().toEpochMilliseconds()): SendResponse

Resets a secure session with a particular user identified by the given address.

Link copied to clipboard
suspend fun resolveAddress(partial: JsonAddress): JsonAddress

Resolve a partial JsonAddress with only a number or UUID to one with both. Anywhere that signald accepts a JsonAddress will accept a partial; this is a convenience function for client authors, mostly because signald doesn't resolve all the partials it returns.

fun resolveAddress(partial: JsonAddress): JsonAddress

Resolve a partial JsonAddress with only a number or UUID to one with both. Anywhere that signald accepts a JsonAddress will accept a partial; this is a convenience function for client authors, mostly because signald doesn't resolve all the partials it returns.

Link copied to clipboard
suspend fun send(recipient: Recipient, messageBody: String, timestamp: Long = Clock.System.now().toEpochMilliseconds(), attachments: Collection<JsonAttachment> = emptyList(), quote: JsonQuote? = null, mentions: Collection<JsonMention> = emptyList(), previews: Collection<JsonPreview> = emptyList()): SendResponse

Sends a message to either a single user (Recipient.Individual) or a group (Recipient.Group).

fun send(recipient: Recipient, messageBody: String, timestamp: Long = Clock.System.now().toEpochMilliseconds(), attachments: Collection<JsonAttachment> = emptyList(), quote: JsonQuote? = null, mentions: Collection<JsonMention> = emptyList(), previews: Collection<JsonPreview> = emptyList()): SendResponse

Sends a message to either a single user (Recipient.Individual) or a group (Recipient.Group).

Link copied to clipboard
suspend fun sendPayment(recipientAddress: JsonAddress, payment: Payment, when: Long = Clock.System.now().toEpochMilliseconds()): SendResponse

Sends a MobileCoin payment to the user identified by the recipientAddress.

fun sendPayment(recipientAddress: JsonAddress, payment: Payment, when: Long = Clock.System.now().toEpochMilliseconds()): SendResponse

Sends a MobileCoin payment to the user identified by the recipientAddress.

Link copied to clipboard
suspend fun sendSyncRequest(syncRequest: SyncRequest): JsonSendMessageResult

Sends a sync message to the account's devices.

fun sendSyncRequest(syncRequest: SyncRequest): JsonSendMessageResult

Sends a sync message to the account's devices.

Link copied to clipboard
suspend fun setDeviceName(deviceName: String)

Set this device's name. This will show up on the mobile device on the same account under linked devices

fun setDeviceName(deviceName: String)

Set this device's name. This will show up on the mobile device on the same account under linked devices

Link copied to clipboard
suspend fun setExpiration(recipient: Recipient, expiration: Int): SendResponse

Set the message expiration timer for a thread.

fun setExpiration(recipient: Recipient, expiration: Int): SendResponse

Set the message expiration timer for a thread.

Link copied to clipboard
suspend fun setProfile(name: String, avatarFile: String?, about: String?, emoji: String?, mobileCoinAddress: String?, visibleBadgeIds: List<String>?)

Sets the profile of the current account. Note that all the parameters here will be used as the new profile fields; leaving one of the fields unset or null means it will be treated as clearing it.

fun setProfile(name: String, avatarFile: String?, about: String?, emoji: String?, mobileCoinAddress: String?, visibleBadgeIds: List<String>?)

Sets the profile of the current account. Note that all the parameters here will be used as the new profile fields; leaving one of the fields unset or null means it will be treated as clearing it.

Link copied to clipboard
suspend fun submitChallenge(challenge: RateLimitChallenge)

Submits a challenge that is requested by the server. Sometimes, when sending a message, the server may rate limit the sender (signald has ProofRequiredError), requiring the user to either submit a push challenge (on Android, this is via Firebase Cloud Message) or a reCAPTCHA. This is indicated by the property org.inthewaves.kotlinsignald.clientprotocol.v1.structures.JsonSendMessageResult.proofRequiredFailure, which corresponds to ProofRequiredException in the Signal-Android code.

fun submitChallenge(challenge: RateLimitChallenge)

Submits a challenge that is requested by the server. Sometimes, when sending a message, the server may rate limit the sender (signald has ProofRequiredError), requiring the user to either submit a push challenge (on Android, this is via Firebase Cloud Message) or a reCAPTCHA. This is indicated by the property org.inthewaves.kotlinsignald.clientprotocol.v1.structures.JsonSendMessageResult.proofRequiredFailure, which corresponds to ProofRequiredException in the Signal-Android code.

Link copied to clipboard
abstract fun subscribe(): IncomingMessageSubscription
open override fun subscribe(): IncomingMessageSubscription

Function not supported on JS, as this is a blocking call. Use subscribeSuspend instead.

open override fun subscribe(): Subscription

Receive incoming messages by creating a new, dedicated socket connection. After making a subscribe request, incoming messages will be sent to the client encoded as ClientMessageWrapper. When finished, to prevent leaks, send an unsubscribe request via Subscription.unsubscribe or disconnect from the socket via PersistentSocketWrapper.close to stop receiving messages.

Link copied to clipboard
fun subscribeAndConsumeBlocking(messageConsumer: (ClientMessageWrapper) -> Unit)

Subscribes to incoming messages and consumes them on the thread that called this function. This will open a dedicated, persistent socket connection for this function call. The current thread will be blocked when it waits for more messages. After this function executes, an unsubscribe request will be made and the persistent socket will be closed.

Link copied to clipboard
abstract suspend fun subscribeSuspend(): IncomingMessageSubscription
open suspend override fun subscribeSuspend(): Subscription

Receive incoming messages by creating a new, dedicated socket connection. After making a subscribe request, incoming messages will be sent to the client encoded as ClientMessageWrapper. Send an unsubscribe request via Subscription.unsubscribe or disconnect from the socket via NodePersistentSocketWrapper.close to stop receiving messages.

open suspend override fun subscribeSuspend(): IncomingMessageSubscription
Link copied to clipboard
suspend fun trust(address: JsonAddress, fingerprint: Fingerprint, trustLevel: TrustLevel = TrustLevel.TRUSTED_VERIFIED)

Trust another user's safety number using either the QR code data or the safety number text

fun trust(address: JsonAddress, fingerprint: Fingerprint, trustLevel: TrustLevel = TrustLevel.TRUSTED_VERIFIED)

Trust another user's safety number using either the QR code data or the safety number text

Link copied to clipboard
suspend fun typing(recipient: Recipient, isTyping: Boolean, when: Long = Clock.System.now().toEpochMilliseconds())

Send a typing started or stopped message

fun typing(recipient: Recipient, isTyping: Boolean, when: Long = Clock.System.now().toEpochMilliseconds())

Send a typing started or stopped message

Link copied to clipboard
suspend fun unbanUser(groupId: String, users: Collection<JsonAddress>): JsonGroupV2Info
fun unbanUser(groupId: String, users: Collection<JsonAddress>): JsonGroupV2Info
Link copied to clipboard
suspend fun updateContact(address: JsonAddress, name: String? = null, color: String? = null, inboxPosition: Int? = null)

Update information about a local contact. Null properties will be left alone.

fun updateContact(address: JsonAddress, name: String? = null, color: String? = null, inboxPosition: Int? = null)

Update information about a local contact. Null properties will be left alone.

Link copied to clipboard
suspend fun updateGroup(groupID: String, groupUpdate: GroupUpdate): GroupInfo

Update information about a group

fun updateGroup(groupID: String, groupUpdate: GroupUpdate): GroupInfo

Update information about a group

Link copied to clipboard
suspend fun verify(code: String)

Verify an account's phone number with a code after registering, completing the account creation process.

fun verify(code: String)

Verify an account's phone number with a code after registering, completing the account creation process.

Link copied to clipboard
suspend fun version(): JsonVersionMessage

Gets the version of signald

fun version(): JsonVersionMessage

Gets the version of signald

Link copied to clipboard
suspend fun waitForScan(sessionId: String)

An optional part of the linking process. Intended to be called after displaying the QR code, will return quickly after the user scans the QR code. finishLink must be called after waitForScan returns a non-error.

fun waitForScan(sessionId: String)

An optional part of the linking process. Intended to be called after displaying the QR code, will return quickly after the user scans the QR code. finishLink must be called after waitForScan returns a non-error.

Properties

Link copied to clipboard
expect val accountId: String
actual val accountId: String

The ID of account corresponding to the signald account to use. As of the current version, this is a phone number in E.164 format starting with a + character.

actual val accountId: String

The ID of account corresponding to the signald account to use. As of the current version, this is a phone number in E.164 format starting with a + character.

Link copied to clipboard
var accountInfo: Account?

The account info for the specified accountId. May be null if the account doesn't exist with signald. If this is null, getting the account info will attempt a request to the signald socket.

Link copied to clipboard
val isRegisteredWithSignald: Boolean

Whether the accountId of this Signal instance is registered with signald. This will do a check with the socket to ensure that the account is present with signald.