libsignal

package module
v0.0.0-...-45d6d20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2023 License: Apache-2.0 Imports: 28 Imported by: 0

README

golibsignal

build status

golibsignal is a library for accessing signal servers. Written cause I wasn't happy with the state of the textsecure library.



Install

go get -u github.com/jckimble/golibsignal

Roadmap

list of features I intend to add over time. volunteers appreciated.

  • TypingMessage - Allow receiving and sending of the TypingMessage
  • CallMessage - Allow receiving calls along with starting them.
  • Device Provisioning - Allow connecting to an existing account.
  • Rewrite axolotl - Get rid of un-needed stores.
  • Profiles - Allow setting profile information from library.

License

Copyright 2019 James Kimble

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MIMETypeFromReader

func MIMETypeFromReader(r io.Reader) (mime string, reader io.Reader)

MIMETypeFromReader guesses MIME Type From Reader

Types

type Attachment

type Attachment struct {
	R    io.Reader
	Type string
}

Attachment represents an attachment received from server

func (Attachment) MimeType

func (a Attachment) MimeType() string

MimeType returns Attachment MIME Type

func (Attachment) Reader

func (a Attachment) Reader() io.Reader

Reader returns io.Reader for attachment

type Config

type Config interface {
	GetTel() (string, error)
	GetServer() (string, error)

	GetHTTPSignalingKey() ([]byte, error)
	SetHTTPSignalingKey([]byte) error

	GetHTTPPassword() (string, error)
	SetHTTPPassword(string) error
}

Config is an interface for libsignal configuration

type Contact

type Contact struct {
	Tel        string
	Devices    []uint32
	Name       string
	Avatar     string
	ProfileKey []byte
}

Contact holds contact information

func (Contact) String

func (c Contact) String() string

String returns human readable name for contact, returns phone number if name is empty

type ContactStore

type ContactStore interface {
	Get(string) (*Contact, error)
	Save(*Contact) error
}

ContactStore is an interface for storing contact information

type Group

type Group struct {
	ID      []byte
	Hexid   string
	Flags   uint32
	Name    string
	Members []string
	Avatar  *Attachment
}

Group holds signal group information for sending group messages

type GroupStore

type GroupStore interface {
	Get(string) (*Group, error)
	GetAll() ([]*Group, error)
	Save(*Group) error
}

GroupStore is an interface for storing Signal Groups

type Message

type Message struct {
	// contains filtered or unexported fields
}

Message holds incoming message information

func (Message) Attachments

func (m Message) Attachments() []*Attachment

Attachments returns Message Attachments

func (Message) Contact

func (m Message) Contact() *Contact

Contact returns Contact from incoming Message

func (Message) Flags

func (m Message) Flags() uint32

Flags returns Message Flags

func (Message) Group

func (m Message) Group() *Group

Group returns Group message was sent to, nil if direct

func (Message) Message

func (m Message) Message() string

Source returns Message Text

func (Message) Source

func (m Message) Source() string

Source returns Message Source Phone Number

func (Message) Timestamp

func (m Message) Timestamp() uint64

Timestamp returns Message Timestamp

type MessageHandler

type MessageHandler interface {
	Message(*Message)
}

MessageHandler is an interface for recieving signal messages

func MessageHandlerFunc

func MessageHandlerFunc(f func(*Message)) MessageHandler

type Profile

type Profile struct {
	Name   string
	Avatar string
	Key    []byte
}

Profile returns Signal Profile Information

type Signal

type Signal struct {
	Config            Config
	IdentityStore     axolotl.IdentityStore
	PreKeyStore       axolotl.PreKeyStore
	SignedPreKeyStore axolotl.SignedPreKeyStore
	SessionStore      axolotl.SessionStore
	GroupStore        GroupStore
	ContactStore      ContactStore
	HTTPClient        *http.Client

	Handler interface{}
	// contains filtered or unexported fields
}

Signal is golibsignal's Main Struct Config, HTTPClient, and All Stores required

func (*Signal) GetProfile

func (s *Signal) GetProfile(tel string, key []byte) (*Profile, error)

GetProfile Gets and Decrypts Signal Profile for number

func (*Signal) ListenAndServe

func (s *Signal) ListenAndServe() error

ListenAndServe connects to the server and handles incoming messages

func (*Signal) NeedsRegistration

func (s *Signal) NeedsRegistration() bool

NeedsRegistration checks if libsignal is initalized

func (*Signal) RegisterKeys

func (s *Signal) RegisterKeys() error

RegisterKeys creates and uploads keys to signal server, must be ran after verification

func (*Signal) RequestCode

func (s *Signal) RequestCode(method string) error

RequestCode sends code to phone for verification, allowed methods are sms and voice

func (*Signal) SendAttachment

func (s *Signal) SendAttachment(tel, msg string, r io.Reader) (uint64, error)

SendAttachment sends the contents of a reader, along with an optional message to a given number.

func (*Signal) SendGroupAttachment

func (s *Signal) SendGroupAttachment(hexid, msg string, r io.Reader) (uint64, error)

SendGroupAttachment sends the contents of a reader, along with an optional message to a given group.

func (*Signal) SendGroupMessage

func (s *Signal) SendGroupMessage(hexid string, msg string) (uint64, error)

SendGroupMessage sends a text message to a given group

func (*Signal) SendMessage

func (s *Signal) SendMessage(tel, msg string) (uint64, error)

SendMessage sends the given text message to the given number

func (*Signal) Shutdown

func (s *Signal) Shutdown() error

Shutdown closes Websocket to stop receiving messages

func (*Signal) VerifyCode

func (s *Signal) VerifyCode(code string) error

VerifyCode verifies code sent to phone

type SyncReadHandler

type SyncReadHandler interface {
	SyncRead(string, uint64)
}

SyncReadHandler is required to recieve SyncRead Messages

type SyncSentHandler

type SyncSentHandler interface {
	SyncSent(*Message, uint64)
}

SyncSentHandler is required to recieve SyncSent Messages

Directories

Path Synopsis
Package axolotl implements the Axolotl ratchet as used by TextSecure protocol version 3.
Package axolotl implements the Axolotl ratchet as used by TextSecure protocol version 3.
protobuf
Package textsecure is a generated protocol buffer package.
Package textsecure is a generated protocol buffer package.
examples
sql
store
sql

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL