Documentation
¶
Overview ¶
Package signal provides a high-level client for the Signal messenger protocol.
Index ¶
- type AccountSettings
- type Client
- func (c *Client) ACI() string
- func (c *Client) Close() error
- func (c *Client) DeviceID() int
- func (c *Client) Devices(ctx context.Context) ([]DeviceInfo, error)
- func (c *Client) FetchGroupDetails(ctx context.Context) (int, error)
- func (c *Client) GetGroup(groupID string) (*Group, error)
- func (c *Client) GetIdentityKey(theirUUID string) ([]byte, error)
- func (c *Client) GetServerProfile(ctx context.Context) (*ServerProfile, error)
- func (c *Client) Groups() ([]*Group, error)
- func (c *Client) IdentityKey() ([]byte, error)
- func (c *Client) Link(ctx context.Context, onQR func(uri string)) error
- func (c *Client) Load() error
- func (c *Client) LookupACI(number string) string
- func (c *Client) LookupNumber(aci string) string
- func (c *Client) Number() string
- func (c *Client) ProfileInfo() (*ProfileInfo, error)
- func (c *Client) Receive(ctx context.Context) iter.Seq2[Message, error]
- func (c *Client) RefreshPreKeys(ctx context.Context) error
- func (c *Client) Register(ctx context.Context, number string, transport string, ...) error
- func (c *Client) Send(ctx context.Context, recipient string, text string) error
- func (c *Client) SendGroup(ctx context.Context, groupID string, text string) error
- func (c *Client) SetProfile(ctx context.Context, name string, numberSharing *bool) error
- func (c *Client) SetProfileName(ctx context.Context, name string) error
- func (c *Client) SyncContacts(ctx context.Context) error
- func (c *Client) SyncGroups(ctx context.Context) (int, error)
- func (c *Client) UpdateAccountSettings(ctx context.Context, settings *AccountSettings) error
- func (c *Client) UpdateAttributes(ctx context.Context) error
- type DeviceInfo
- type Group
- type Message
- type Option
- type ProfileInfo
- type ServerProfile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountSettings ¶
type AccountSettings struct {
// DiscoverableByPhoneNumber controls whether your number can be found via Contact Discovery.
DiscoverableByPhoneNumber *bool
// UnrestrictedUnidentifiedAccess allows anyone to send you sealed sender messages.
UnrestrictedUnidentifiedAccess *bool
}
AccountSettings contains configurable account settings.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the main entry point for interacting with Signal.
func Open ¶
Open opens an existing account by phone number (e.g. "+31647272794"). It finds the database in the default data directory, opens it, and loads credentials.
func (*Client) Devices ¶
func (c *Client) Devices(ctx context.Context) ([]DeviceInfo, error)
Devices returns the list of registered devices for this account.
func (*Client) FetchGroupDetails ¶
FetchGroupDetails fetches details (name, members) for all groups that don't have names yet. This uses the Groups V2 API which requires zkgroup auth credentials. Returns the number of groups updated.
func (*Client) GetGroup ¶
GetGroup returns group details by group ID (hex-encoded GroupIdentifier). Returns nil if the group is not found.
func (*Client) GetIdentityKey ¶
GetIdentityKey returns the stored identity key for a remote party.
func (*Client) GetServerProfile ¶
func (c *Client) GetServerProfile(ctx context.Context) (*ServerProfile, error)
GetServerProfile fetches and decrypts the user's profile from the server.
func (*Client) Groups ¶
Groups returns all groups this device knows about. Groups are discovered incrementally from received group messages.
func (*Client) IdentityKey ¶
IdentityKey returns our public identity key bytes.
func (*Client) Link ¶
Link connects as a secondary device. It blocks until the primary device scans the QR code and completes provisioning, then registers the device with the Signal server. The onQR callback is called with the device link URI for display as a QR code.
func (*Client) Load ¶
Load opens an existing database and loads credentials without re-linking. If no explicit DB path is set, it discovers the most recent account database in the default data directory.
func (*Client) LookupACI ¶
LookupACI returns the ACI UUID for the given E.164 phone number from the local contact store. Returns empty string if not found.
func (*Client) LookupNumber ¶
LookupNumber returns the phone number for the given ACI UUID from the local contact store. Returns empty string if not found.
func (*Client) ProfileInfo ¶
func (c *Client) ProfileInfo() (*ProfileInfo, error)
ProfileInfo returns the current account's profile information.
func (*Client) Receive ¶
Receive returns an iterator that yields incoming text messages. It connects to the authenticated WebSocket and decrypts messages. The iterator stops when the context is cancelled or the caller breaks.
func (*Client) RefreshPreKeys ¶
RefreshPreKeys re-uploads local pre-keys to the server. Use this if pre-keys on the server are out of sync with local storage.
func (*Client) Register ¶
func (c *Client) Register( ctx context.Context, number string, transport string, getCode func() (string, error), getCaptcha func() (string, error), ) error
Register registers a new Signal account as a primary device. The getCode callback is called to prompt the user for the SMS/voice verification code. The getCaptcha callback is called if a CAPTCHA challenge is required.
func (*Client) Send ¶
Send sends a text message to the given recipient. Recipient can be an ACI UUID (e.g., "550e8400-e29b-41d4-a716-446655440000"), an E.164 phone number (e.g., "+31612345678"), or a group ID (64 hex chars). For phone numbers, the local contact store is checked first; if not found, CDSI (Contact Discovery Service) is used to resolve the number. Automatically attempts sealed sender first with fallback to unsealed.
func (*Client) SendGroup ¶
SendGroup sends a text message to a group. The groupID should be the hex-encoded GroupIdentifier (obtained from Groups()). Uses sender key encryption for efficient group messaging.
func (*Client) SetProfile ¶
SetProfile updates profile settings on the Signal server. If name is empty and numberSharing is nil, this is a no-op. If the account doesn't have a profile key, one is generated and saved.
func (*Client) SetProfileName ¶
SetProfileName sets the profile name on the Signal server. If the account doesn't have a profile key, one is generated and saved.
func (*Client) SyncContacts ¶
SyncContacts requests a contact sync from the primary device. The primary device will respond with a SyncMessage.Contacts that is automatically handled by the receive loop, populating the local contact store.
func (*Client) SyncGroups ¶
SyncGroups fetches group master keys from the Storage Service and stores them locally. This requires the account's master key to be available (set during device linking). Returns the number of groups synced.
func (*Client) UpdateAccountSettings ¶
func (c *Client) UpdateAccountSettings(ctx context.Context, settings *AccountSettings) error
UpdateAccountSettings updates account attributes and/or profile settings on the server. Only non-nil fields in settings are updated.
type DeviceInfo ¶
type DeviceInfo = signalservice.DeviceInfo
DeviceInfo is the public type for device information.
type Option ¶
type Option func(*Client)
Option configures a Client.
func WithDBPath ¶
WithDBPath overrides the database path for persistent storage. If not set, defaults to $XDG_DATA_HOME/signal-go/<aci>.db after linking.
func WithDebugDir ¶
WithDebugDir sets a directory for dumping raw envelope bytes before decryption. When set, every received envelope is written as a .bin file for offline inspection.
func WithLogger ¶
WithLogger sets the logger for verbose output. If not set, logging is disabled.
func WithProvisioningURL ¶
WithProvisioningURL overrides the default provisioning WebSocket URL.
func WithTLSConfig ¶
WithTLSConfig overrides the TLS configuration used for connections. If nil (the default), Signal's pinned CA certificate is used.
type ProfileInfo ¶
ProfileInfo contains basic profile information for display.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
sgnl
command
Command sgnl is a CLI for Signal messenger.
|
Command sgnl is a CLI for Signal messenger. |
|
internal
|
|
|
proto
Package proto contains generated protobuf types for Signal's provisioning and WebSocket protocols.
|
Package proto contains generated protobuf types for Signal's provisioning and WebSocket protocols. |
|
provisioncrypto
Package provisioncrypto implements the Signal provisioning envelope crypto: HKDF key derivation, HMAC-SHA256, AES-256-CBC, and PKCS#7 padding.
|
Package provisioncrypto implements the Signal provisioning envelope crypto: HKDF key derivation, HMAC-SHA256, AES-256-CBC, and PKCS#7 padding. |
|
signalservice
Package signalservice orchestrates Signal protocol operations: device provisioning, message sending, and message receiving.
|
Package signalservice orchestrates Signal protocol operations: device provisioning, message sending, and message receiving. |
|
signalws
Package signalws provides protobuf-framed WebSocket communication for the Signal provisioning protocol.
|
Package signalws provides protobuf-framed WebSocket communication for the Signal provisioning protocol. |