ids

package
v0.0.0-...-3bed8bd Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: AGPL-3.0 Imports: 57 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinResultRefreshInterval         = 1 * day
	MinNegativeResultRefreshInterval = 1 * time.Hour
	ResultExpiry                     = 7 * day
)
View Source
const ChunkChecksumLength = 21
View Source
const MaxChunkSize = 5 * 1024 * 1024
View Source
const ProtocolVersion = "1640"

Variables

View Source
var AppleEpoch = time.Date(2001, 1, 1, 0, 0, 0, 0, time.UTC)
View Source
var DeviceName = "beeper-imessage"
View Source
var NoLookupParams = LookupParams{}

Functions

func CreateSMSRegisterRequest

func CreateSMSRegisterRequest(pushToken []byte) string

func GetCarrierInfo

func GetCarrierInfo(ctx context.Context, url string) (map[string]any, error)

func GetGatewayByMCCMNC

func GetGatewayByMCCMNC(ctx context.Context, mccmnc string) (string, error)

func ParseSMSRegisterResponse

func ParseSMSRegisterResponse(resp string) (phoneNumber string, sig []byte, err error)

func ValidatePreKey

func ValidatePreKey(key *idsproto.PublicDevicePrekey, deviceKey *ecdsa.PublicKey) bool

func VerifyKeyValidator

func VerifyKeyValidator(keyValidator []byte, senderDeviceKey, receiverSigningKey, receiverPreKey *ec.CompactPublicKey) bool

func VerifySignedPairECPayload

func VerifySignedPairECPayload(sharedSecret []byte, myPreKey, myDeviceKey *ec.CompactPublicKey, outer *idsproto.OuterMessage, pub *ec.CompactPublicKey) bool

func VerifySignedPairPayload

func VerifySignedPairPayload(senderKey *UserIdentity, body ParsedBody) bool

Types

type AttachmentDownloader

type AttachmentDownloader struct {
	URL           string
	OwnerID       string
	Signature     []byte
	DecryptionKey []byte

	MD      *MMCSDownloader
	RawData []byte
}

func NewAttachmentDownloader

func NewAttachmentDownloader(url, ownerID string, signature, decryptionKey []byte) *AttachmentDownloader

func (*AttachmentDownloader) DownloadFile

func (ad *AttachmentDownloader) DownloadFile(ctx context.Context, u *User, path string, progressFunc func(progress *DownloadProgress, save bool)) error

func (*AttachmentDownloader) DownloadMemory

func (ad *AttachmentDownloader) DownloadMemory(ctx context.Context, u *User) ([]byte, error)

func (*AttachmentDownloader) GetFileSize

func (ad *AttachmentDownloader) GetFileSize() int

func (*AttachmentDownloader) Prepare

func (ad *AttachmentDownloader) Prepare(ctx context.Context, u *User) error

type AuthIDCertPair

type AuthIDCertPair struct {
	Added    time.Time
	AuthCert *x509.Certificate
	IDCert   *x509.Certificate

	RefreshNeeded bool
}

type AuthResponse

type AuthResponse struct {
	Status    types.IDSStatus `plist:"status"`
	AuthToken string          `plist:"auth-token"`
	ProfileID string          `plist:"profile-id"`
}

type ChunkChecksum

type ChunkChecksum [ChunkChecksumLength]byte

type Config

type Config struct {
	ProfileID      string
	AuthPrivateKey *rsa.PrivateKey

	AuthIDCertPairs map[string]*AuthIDCertPair
	IDRegisteredAt  time.Time

	PushKey   *rsa.PrivateKey
	PushCert  *x509.Certificate
	PushToken []byte

	PushGenVersion int
	PushGenRetried bool

	IDSEncryptionKey *rsa.PrivateKey
	IDSSigningKey    *ecdsa.PrivateKey

	NGMDeviceKey *ec.CompactPrivateKey
	NGMPreKey    *ec.CompactPrivateKey

	Handles         []uri.ParsedURI
	DefaultHandle   uri.ParsedURI
	PreferredHandle uri.ParsedURI

	SMSForwarding *SMSForwarding

	Versions

	DeviceUUID uuid.UUID

	// WARNING: This is being used to determine if the user logged in at a time
	// when pair-ec registration was enabled. If this is zero, then we know
	// that the user might have been registered before pair-ec was enabled.
	LoggedInAt      time.Time
	LastLoginTestAt time.Time
}

func (*Config) MarshalJSON

func (c *Config) MarshalJSON() ([]byte, error)

func (*Config) ToJSONConfig

func (c *Config) ToJSONConfig() *JSONConfig

func (*Config) UnmarshalJSON

func (c *Config) UnmarshalJSON(data []byte) error

type DependentRegistration

type DependentRegistration struct {
	ClientData         LookupIdentityClientData `plist:"client-data"`
	DeviceName         string                   `plist:"device-name"`
	HardwareVersion    string                   `plist:"hardware-version"`
	Identities         []Handle                 `plist:"identities"`
	IsHSATrustedDevice bool                     `plist:"is-hsa-trusted-device"`
	PrivateDeviceData  PrivateDeviceData        `plist:"private-device-data"`
	PushToken          []byte                   `plist:"push-token"`
	SelfHandle         string                   `plist:"self-handle"`
	Service            apns.Topic               `plist:"service"`
	SubServices        []apns.Topic             `plist:"sub-services"`
	// This contains phone number URIs for iPhones that have registered a phone number
	LinkedUserURI []uri.ParsedURI `plist:"linked-user-uri"`
}

type DownloadChunk

type DownloadChunk struct {
	Downloaded bool

	Checksum ChunkChecksum
	// Size is the number of bytes in this chunk.
	Size int
	// Offset is the byte offset from the start of the container containing this chunk.
	Offset int
	// OffsetInFile is the byte offset of this chunk from the start of the entire file.
	OffsetInFile int64
}

type DownloadContainer

type DownloadContainer struct {
	Downloaded bool
	Chunks     []DownloadChunk
	Request    *mmcsproto.HTTPRequest
	CLAuthP1   string
	CLAuthP2   string
}

func (*DownloadContainer) Download

func (*DownloadContainer) DownloadAndWriteChunk

func (dc *DownloadContainer) DownloadAndWriteChunk(ctx context.Context, prog *DownloadProgress, ua Versions, chunk *DownloadChunk, into io.WriterAt) (*mmcsproto.ConfirmResponse_Request, error)

func (*DownloadContainer) Write

func (dc *DownloadContainer) Write(ctx context.Context, data []byte, into io.WriterAt) error

type DownloadProgress

type DownloadProgress struct {
	Prepared        bool `json:"prepared"`
	Allocated       bool `json:"allocated"`
	GetCompleted    bool `json:"get_completed"`
	DownloadedBytes int  `json:"downloaded_bytes"`
	DecryptedBytes  int  `json:"decrypted_bytes"`
	Size            int  `json:"total_bytes"`
	// contains filtered or unexported fields
}

func (*DownloadProgress) Percent

func (dp *DownloadProgress) Percent() float64

type Handle

type Handle struct {
	URI uri.ParsedURI `plist:"uri"`
}

type InMemoryLookupCache

type InMemoryLookupCache map[uriTuple]*LookupResult

func (InMemoryLookupCache) Clear

func (InMemoryLookupCache) Delete

func (i InMemoryLookupCache) Delete(_ context.Context, ourURI, theirURI uri.ParsedURI) error

func (InMemoryLookupCache) Get

func (i InMemoryLookupCache) Get(_ context.Context, ourURI, theirURI uri.ParsedURI) (*LookupResult, error)

func (InMemoryLookupCache) GetMany

func (i InMemoryLookupCache) GetMany(_ context.Context, ourURI uri.ParsedURI, theirURIs []uri.ParsedURI) (map[uri.ParsedURI]*LookupResult, error)

func (InMemoryLookupCache) Invalidate

func (i InMemoryLookupCache) Invalidate(_ context.Context, ourURI, theirURI uri.ParsedURI) error

func (InMemoryLookupCache) MarkBroadcasted

func (i InMemoryLookupCache) MarkBroadcasted(ctx context.Context, handle uri.ParsedURI, broadcasted ...uri.ParsedURI) error

func (InMemoryLookupCache) Put

func (i InMemoryLookupCache) Put(_ context.Context, ourURI, theirURI uri.ParsedURI, result *LookupResult) error

type InMemoryOutgoingCounter

type InMemoryOutgoingCounter struct {
	Counter uint32
}

func (*InMemoryOutgoingCounter) GetNext

func (c *InMemoryOutgoingCounter) GetNext(ctx context.Context) (uint32, error)

type InMemoryOutgoingCounterStore

type InMemoryOutgoingCounterStore map[uri.ParsedURI]OutgoingCounter

func (InMemoryOutgoingCounterStore) Get

type InMemoryRerouteHistory

type InMemoryRerouteHistory map[uri.ParsedURI]*time.Time

func (InMemoryRerouteHistory) Clear

func (InMemoryRerouteHistory) Delete

func (InMemoryRerouteHistory) Get

func (InMemoryRerouteHistory) Put

type JSONAuthIDCertPair

type JSONAuthIDCertPair struct {
	Added    time.Time       `json:"added"`
	AuthCert JSONCertificate `json:"auth"`
	IDCert   JSONCertificate `json:"id"`

	RefreshNeeded bool `json:"refresh_needed"`
}

type JSONCertificate

type JSONCertificate struct {
	*x509.Certificate
}

func (*JSONCertificate) MarshalJSON

func (c *JSONCertificate) MarshalJSON() ([]byte, error)

func (*JSONCertificate) Sha256Fingerprint

func (c *JSONCertificate) Sha256Fingerprint() []byte

func (*JSONCertificate) UnmarshalJSON

func (c *JSONCertificate) UnmarshalJSON(data []byte) error

func (*JSONCertificate) Unwrap

func (c *JSONCertificate) Unwrap() *x509.Certificate

type JSONConfig

type JSONConfig struct {
	Encryption struct {
		RSAKey       JSONRSAPrivateKey `json:"rsa_key"`
		ECKey        JSONECPrivateKey  `json:"ec_key"`
		NGMDeviceKey JSONECPrivateKey  `json:"ngm_device_key"`
		NGMPreKey    JSONECPrivateKey  `json:"ngm_pre_key"`
	} `json:"encryption"`

	DeviceUUID      uuid.UUID `json:"device_uuid"`
	Handles         []string  `json:"handles"`
	DefaultHandle   string    `json:"default_handle"`
	PreferredHandle string    `json:"preferred_handle"`

	AuthKey   JSONRSAPrivateKey `json:"auth_key"`
	ProfileID string            `json:"profile_id,omitempty"`

	AuthIDCertPairs map[string]*JSONAuthIDCertPair `json:"auth_id_cert_pairs"`
	RegisteredAt    time.Time                      `json:"registered_at"`

	Push struct {
		Token   []byte            `json:"token"`
		Key     JSONRSAPrivateKey `json:"key"`
		Cert    JSONCertificate   `json:"cert"`
		Version int               `json:"version"`
		Retried bool              `json:"retried,omitempty"`
	} `json:"push"`

	SMSForwarding *SMSForwarding `json:"sms_forwarding,omitempty"`
	Versions      Versions       `json:"versions"`

	LoggedInAt      time.Time `json:"logged_in_at"`
	LastLoginTestAt time.Time `json:"last_login_test_at"`
}

func (*JSONConfig) ToConfig

func (c *JSONConfig) ToConfig() *Config

type JSONECPrivateKey

type JSONECPrivateKey struct {
	*ecdsa.PrivateKey
}

func (*JSONECPrivateKey) MarshalJSON

func (k *JSONECPrivateKey) MarshalJSON() ([]byte, error)

func (*JSONECPrivateKey) UnmarshalJSON

func (k *JSONECPrivateKey) UnmarshalJSON(data []byte) error

func (*JSONECPrivateKey) Unwrap

func (k *JSONECPrivateKey) Unwrap() *ecdsa.PrivateKey

type JSONRSAPrivateKey

type JSONRSAPrivateKey struct {
	*rsa.PrivateKey
}

func (*JSONRSAPrivateKey) MarshalJSON

func (k *JSONRSAPrivateKey) MarshalJSON() ([]byte, error)

func (*JSONRSAPrivateKey) Sha256Fingerprint

func (k *JSONRSAPrivateKey) Sha256Fingerprint() []byte

func (*JSONRSAPrivateKey) UnmarshalJSON

func (k *JSONRSAPrivateKey) UnmarshalJSON(data []byte) error

func (*JSONRSAPrivateKey) Unwrap

func (k *JSONRSAPrivateKey) Unwrap() *rsa.PrivateKey

type LookupCache

type LookupCache interface {
	Get(ctx context.Context, ourURI, theirURI uri.ParsedURI) (*LookupResult, error)
	GetMany(ctx context.Context, ourURI uri.ParsedURI, theirURIs []uri.ParsedURI) (map[uri.ParsedURI]*LookupResult, error)
	Put(ctx context.Context, ourURI, theirURI uri.ParsedURI, result *LookupResult) error
	Delete(ctx context.Context, ourURI, theirURI uri.ParsedURI) error
	Invalidate(ctx context.Context, ourURI, theirURI uri.ParsedURI) error
	Clear(ctx context.Context) error
	MarkBroadcasted(ctx context.Context, handle uri.ParsedURI, broadcasted ...uri.ParsedURI) error
}

type LookupIdentity

type LookupIdentity struct {
	ClientData LookupIdentityClientData `plist:"client-data" json:"client_data"`

	KTLoggableData             *idsproto.KeyTransparencyLoggableData `plist:"kt-loggable-data" json:"kt_loggable_data"`
	PushToken                  []byte                                `plist:"push-token" json:"push_token"`
	SessionToken               []byte                                `plist:"session-token" json:"session_token"`
	SessionTokenExpiresSeconds int                                   `plist:"session-token-expires-seconds" json:"session_token_expires_seconds"`
	SessionTokenRefreshSeconds int                                   `plist:"session-token-refresh-seconds" json:"session_token_refresh_seconds"`
}

type LookupIdentityClientData

type LookupIdentityClientData struct {
	PublicMessageIdentityKey *UserIdentity `json:"public_message_identity_key"`

	PublicDevicePrekey *idsproto.PublicDevicePrekey `json:"public_device_prekey"`
	NGMPublicIdentity  *idsproto.NgmPublicIdentity  `json:"ngm_public_identity"`

	Extra map[string]any `json:"extra"`
}

func (*LookupIdentityClientData) MarshalPlist

func (l *LookupIdentityClientData) MarshalPlist() (any, error)

func (*LookupIdentityClientData) UnmarshalPlist

func (l *LookupIdentityClientData) UnmarshalPlist(unmarshal func(any) error) error

type LookupParams

type LookupParams struct {
	Force          bool
	Ratelimiter    *rate.Limiter
	AlwaysUseCache bool
}

type LookupQuery

type LookupQuery struct {
	URIs []uri.ParsedURI `plist:"uris"`
}

type LookupResult

type LookupResult struct {
	Identities                  []LookupIdentity `plist:"identities" json:"identities"`
	KTAccountKey                []byte           `plist:"kt-account-key" json:"kt_account_key"`
	SenderCorrelationIdentifier string           `plist:"sender-correlation-identifier" json:"sender_correlation_identifier"`
	Status                      int              `plist:"status" json:"status"`

	Time        time.Time `plist:"-" json:"-"`
	Broadcasted bool      `plist:"-" json:"-"`
}

func (*LookupResult) FindIdentity

func (lr *LookupResult) FindIdentity(pushToken []byte, requireNGMKey bool) *LookupIdentity

type LookupResults

type LookupResults struct {
	// TODO plist doesn't like decoding into a map[uri.ParsedURI]LookupResult
	Results map[uri.PlainURI]*LookupResult `plist:"results"`
	Status  int                            `plist:"status"`
}

type MMCSDownloader

type MMCSDownloader struct {
	AuthID string

	Signature     []byte
	DecryptionKey []byte

	TotalSize     int
	Containers    []*DownloadContainer
	Confirmations []*mmcsproto.ConfirmResponse_Request
	Expiry        time.Time
}

func ParseMMCSAuthorizeGetResponse

func ParseMMCSAuthorizeGetResponse(auth *mmcsproto.AuthorizeGetResponse, authID string, signature, decryptionKey []byte) (*MMCSDownloader, error)

func (*MMCSDownloader) Decrypt

func (md *MMCSDownloader) Decrypt(ctx context.Context, prog *DownloadProgress, file ReadWriterAt) error

func (*MMCSDownloader) Download

func (md *MMCSDownloader) Download(ctx context.Context, prog *DownloadProgress, ua Versions, into io.WriterAt) error

func (*MMCSDownloader) DownloadAndDecrypt

func (md *MMCSDownloader) DownloadAndDecrypt(ctx context.Context, prog *DownloadProgress, ua Versions, into ReadWriterAt, authURL string) error

func (*MMCSDownloader) SendGetComplete

func (md *MMCSDownloader) SendGetComplete(ctx context.Context, ua Versions, attachmentURL string) (*http.Response, error)

type OutgoingCounter

type OutgoingCounter interface {
	GetNext(ctx context.Context) (uint32, error)
}

type OutgoingCounterStore

type OutgoingCounterStore interface {
	Get(ctx context.Context, theirURI uri.ParsedURI) (OutgoingCounter, error)
}

type ParsedBody

type ParsedBody struct {
	Tag       byte
	Body      []byte
	Signature []byte
}

func ParseBody

func ParseBody(payload []byte) (out ParsedBody, err error)

func (ParsedBody) Bytes

func (pb ParsedBody) Bytes() []byte

type PreparedUpload

type PreparedUpload struct {
	DecryptionKey []byte
	Signature     []byte
	TotalSize     int
	AuthRequest   *mmcsproto.AuthorizePut
	Chunks        map[[21]byte][]byte
}

type PrivateDeviceData

type PrivateDeviceData struct {
	AP string `plist:"ap,omitempty"` // "0" on mac, "1" on iphone/ipad

	C string `plist:"c,omitempty"` // "1", not on Macs, only iPhones/iPads?

	D  string `plist:"d,omitempty"`  // Seconds (with floating point microseconds) since Apple epoch (2001-01-01 00:00 UTC)
	DT int    `plist:"dt,omitempty"` // 1 on macs, 2 on iphones, 4 on ipads? perhaps device type?
	EC string `plist:"ec,omitempty"` // "1", not on Macs, only iPhones/iPads?
	GT string `plist:"gt,omitempty"` // "0"
	H  string `plist:"h,omitempty"`  // "1"

	KTF string `plist:"ktf,omitempty"` // "0" or "1"
	KTV int    `plist:"ktv,omitempty"` // observed values: "70", 75, 81, 87

	M string `plist:"m,omitempty"` // "0" on mac/ipad, "1" on iphone
	P string `plist:"p,omitempty"` // "0" on mac/ipad, "1" on iphone

	SoftwareBuild   string `plist:"pb,omitempty"` // 22F82
	SoftwareName    string `plist:"pn,omitempty"` // "macOS" (or "iPhone OS" for ios)
	SoftwareVersion string `plist:"pv,omitempty"` // 13.4.1

	S    string         `plist:"s,omitempty"` // "0"
	T    string         `plist:"t,omitempty"` // "0"
	UUID plistuuid.UUID `plist:"u,omitempty"`
	V    string         `plist:"v,omitempty"` // "1", version?
}

type ReadWriterAt

type ReadWriterAt interface {
	io.Reader
	io.WriterAt
}

type RegisterError

type RegisterError struct {
	Alert  *RegisterRespAlert
	Status types.IDSStatus
	UserID string
}

func (RegisterError) Error

func (re RegisterError) Error() string

func (RegisterError) Is

func (re RegisterError) Is(other error) bool

func (RegisterError) Unwrap

func (re RegisterError) Unwrap() error

type RegisterReq

type RegisterReq struct {
	DeviceName        string            `plist:"device-name"`
	HardwareVersion   string            `plist:"hardware-version"`
	Language          string            `plist:"language"`
	OSVersion         string            `plist:"os-version"`
	SoftwareVersion   string            `plist:"software-version"`
	PrivateDeviceData PrivateDeviceData `plist:"private-device-data"`
	Services          []RegisterService `plist:"services"`
	ValidationData    []byte            `plist:"validation-data"`
}

type RegisterResp

type RegisterResp struct {
	Message  string                `plist:"message"`
	Status   types.IDSStatus       `plist:"status"`
	Services []RegisterRespService `plist:"services"`

	RetryInterval int `plist:"retry-interval"`
}

type RegisterRespAlert

type RegisterRespAlert struct {
	Body   string `plist:"body"`
	Button string `plist:"button"`
	Title  string `plist:"title"`

	Action RegisterRespAlertAction `plist:"action"`
}

type RegisterRespAlertAction

type RegisterRespAlertAction struct {
	Button string `plist:"button"`
	Type   int    `plist:"type"`
	URL    string `plist:"url"`
}

type RegisterRespService

type RegisterRespService struct {
	Service string                    `plist:"service"`
	Users   []RegisterRespServiceUser `plist:"users"`
	Status  types.IDSStatus           `plist:"status"`
}

type RegisterRespServiceUser

type RegisterRespServiceUser struct {
	URIs   []RespHandle       `plist:"uris"`
	UserID string             `plist:"user-id"`
	Cert   []byte             `plist:"cert"`
	Status types.IDSStatus    `plist:"status"`
	Alert  *RegisterRespAlert `plist:"alert"`
}

type RegisterService

type RegisterService struct {
	Capabilities []RegisterServiceCapabilities `plist:"capabilities"`
	Service      apns.Topic                    `plist:"service"`
	SubServices  []apns.Topic                  `plist:"sub-services"`
	Users        []RegisterServiceUser         `plist:"users"`
}

type RegisterServiceCapabilities

type RegisterServiceCapabilities struct {
	Flags   int    `plist:"flags"`
	Name    string `plist:"name"`
	Version int    `plist:"version"`
}

type RegisterServiceUser

type RegisterServiceUser struct {
	ClientData     map[string]any                        `plist:"client-data"`
	Tag            string                                `plist:"tag,omitempty"`
	URIs           []Handle                              `plist:"uris"`
	UserID         string                                `plist:"user-id"`
	KTLoggableData *idsproto.KeyTransparencyLoggableData `plist:"kt-loggable-data"`
}

type RerouteHistory

type RerouteHistory interface {
	Get(ctx context.Context, handle uri.ParsedURI) (*time.Time, error)
	Put(ctx context.Context, handle uri.ParsedURI) error
	Delete(ctx context.Context, handle uri.ParsedURI) error
	Clear(ctx context.Context) error
}

type RespDependentRegistrations

type RespDependentRegistrations struct {
	ExpiryEpochMillis int64                   `plist:"expiry-epoch-milli-sec"`
	Status            types.IDSStatus         `plist:"status"`
	Registrations     []DependentRegistration `plist:"registrations"`
}

type RespHandle

type RespHandle struct {
	URI    string          `plist:"uri"`
	Status types.IDSStatus `plist:"status"`
}

type SMSForwarding

type SMSForwarding struct {
	Token  []byte        `json:"token"`
	Handle uri.ParsedURI `json:"handle"`
}

func (*SMSForwarding) GetHandle

func (sf *SMSForwarding) GetHandle() uri.ParsedURI

func (*SMSForwarding) GetToken

func (sf *SMSForwarding) GetToken() []byte

type SigningPayload

type SigningPayload []byte

type UploadChunk

type UploadChunk struct {
	OffsetInFile int64
	Size         int
}

type UploadedAttachment

type UploadedAttachment struct {
	Name             string `xml:"name,attr,omitempty"`
	Width            int    `xml:"width,attr"`
	Height           int    `xml:"height,attr"`
	Datasize         int    `xml:"datasize,attr,omitempty"`
	MimeType         string `xml:"mime-type,attr,omitempty"`
	UTIType          string `xml:"uti-type,attr,omitempty"`
	FileSize         int    `xml:"file-size,attr,omitempty"`
	MessagePart      int    `xml:"message-part,attr"` // don't omitempty, as we always require this, even if 0
	MMCSSignatureHex string `xml:"mmcs-signature-hex,attr,omitempty"`
	MMCSURL          string `xml:"mmcs-url,attr,omitempty"`
	MMCSOwner        string `xml:"mmcs-owner,attr,omitempty"`
	DecryptionKey    string `xml:"decryption-key,attr,omitempty"`
	InlineAttachment string `xml:"inline-attachment,attr,omitempty"`
}

type User

type User struct {
	*Config
	LookupCache    LookupCache
	RerouteHistory RerouteHistory
	Conn           *apns.Connection

	OutgoingCounterStore OutgoingCounterStore
	DontPublishKeys      bool
	// contains filtered or unexported fields
}

func NewUser

func NewUser(conn *apns.Connection, cfg *Config, lookupCache LookupCache, rerouteHistory RerouteHistory, enablePairECSending bool, outgoingCounterStore OutgoingCounterStore, parentRegisterIDS parentRegisterIDS) *User

func (*User) Authenticate

func (u *User) Authenticate(ctx context.Context, username, password, code string) (*AuthResponse, error)

func (*User) DecryptSignedPairECPayload

func (u *User) DecryptSignedPairECPayload(sharedSecret, payload []byte) ([]byte, error)

func (*User) DecryptSignedPairPayload

func (u *User) DecryptSignedPairPayload(body ParsedBody) ([]byte, error)

func (*User) DeriveExistingPairECSharedSecret

func (u *User) DeriveExistingPairECSharedSecret(ephemeralPubKeyRaw []byte) ([]byte, error)

func (*User) DownloadAttachment

func (u *User) DownloadAttachment(ctx context.Context, url, ownerID string, sig, decryptionKey []byte) ([]byte, error)

func (*User) EncryptSignPairECPayload

func (u *User) EncryptSignPairECPayload(ctx context.Context, theirURI uri.ParsedURI, theirPreKey, theirDeviceKey *ec.CompactPublicKey, payload []byte) ([]byte, error)

func (*User) EncryptSignPairPayload

func (u *User) EncryptSignPairPayload(ctx context.Context, key *UserIdentity, payload []byte) ([]byte, error)

func (*User) EncryptSignPayload

func (u *User) EncryptSignPayload(ctx context.Context, theirURI uri.ParsedURI, ident *LookupIdentity, payload []byte) ([]byte, apns.EncryptionType, error)

func (*User) GenerateLoggableData

func (u *User) GenerateLoggableData() *idsproto.KeyTransparencyLoggableData

func (*User) GeneratePreKeyData

func (u *User) GeneratePreKeyData() []byte

func (*User) GetAuthCert

func (u *User) GetAuthCert(ctx context.Context, authToken, profileID string) (*x509.Certificate, error)

func (*User) GetAuthCertSMS

func (u *User) GetAuthCertSMS(ctx context.Context, pushToken, signature []byte, phoneNumber string) (*x509.Certificate, error)

func (*User) GetDependentRegistrations

func (u *User) GetDependentRegistrations(ctx context.Context, profileID string) (map[string]any, error)

func (*User) GetPhoneRegistrationHandle

func (u *User) GetPhoneRegistrationHandle() *uri.ParsedURI

func (*User) HasAuthCerts

func (u *User) HasAuthCerts() bool

func (*User) HasIDSKeys

func (u *User) HasIDSKeys() bool

func (*User) HasValidIDCerts

func (u *User) HasValidIDCerts() bool

func (*User) Lookup

func (u *User) Lookup(ctx context.Context, ownHandle uri.ParsedURI, params LookupParams, uris []uri.ParsedURI) (map[uri.ParsedURI]*LookupResult, error)

func (*User) LookupDevice

func (u *User) LookupDevice(ctx context.Context, ownHandle, theirHandle uri.ParsedURI, wantedToken []byte, requireNGMKey bool) (*LookupIdentity, error)

func (*User) LookupServer

func (u *User) LookupServer(ctx context.Context, ownHandle uri.ParsedURI, uris ...uri.ParsedURI) (map[uri.ParsedURI]*LookupResult, error)

LookupServer asks IDS whether the list of provided uris exist on iMessage and returns a map of results If the request completes successfully but the user is not on iMessage, the LookupResult in the map will have an empty list for the Identities array

func (*User) NeedsRefresh

func (u *User) NeedsRefresh() bool

func (*User) PublicIdentity

func (u *User) PublicIdentity() *UserIdentity

func (*User) Register

func (u *User) Register(ctx context.Context, handles map[string][]Handle, validationData []byte) error

func (*User) RegisterSpecificAuthCerts

func (u *User) RegisterSpecificAuthCerts(ctx context.Context, handles map[string][]Handle, validationData []byte, certPairs map[string]*AuthIDCertPair) error

func (*User) TriggerReroute

func (u *User) TriggerReroute(ctx context.Context, url, token string) error

func (*User) UpdateHandles

func (u *User) UpdateHandles(ctx context.Context) (bool, map[string][]Handle, []string, error)

func (*User) UpdateHandlesIfChanged

func (u *User) UpdateHandlesIfChanged(ctx context.Context, handles []uri.ParsedURI) bool

func (*User) UploadAttachment

func (u *User) UploadAttachment(ctx context.Context, data []byte, filename, mimeType string) (*UploadedAttachment, error)

func (*User) VerifySignedPairECPayload

func (u *User) VerifySignedPairECPayload(ctx context.Context, ourURI, theirURI uri.ParsedURI, theirPushToken, sharedSecret []byte, outer *idsproto.OuterMessage) error

func (*User) VerifySignedPairPayload

func (u *User) VerifySignedPairPayload(ctx context.Context, ourURI, theirURI uri.ParsedURI, theirPushToken []byte, body ParsedBody) error

type UserIdentity

type UserIdentity struct {
	SigningKey    *ecdsa.PublicKey
	EncryptionKey *rsa.PublicKey
}

func (*UserIdentity) Hash

func (i *UserIdentity) Hash() []byte

func (*UserIdentity) MarshalBinary

func (i *UserIdentity) MarshalBinary() ([]byte, error)

func (*UserIdentity) MarshalJSON

func (i *UserIdentity) MarshalJSON() ([]byte, error)

func (*UserIdentity) ToBytes

func (i *UserIdentity) ToBytes() []byte

func (*UserIdentity) UnmarshalBinary

func (i *UserIdentity) UnmarshalBinary(data []byte) error

func (*UserIdentity) UnmarshalJSON

func (i *UserIdentity) UnmarshalJSON(data []byte) error

type Versions

type Versions struct {
	HardwareVersion string `json:"hardware_version"`
	SoftwareName    string `json:"software_name"`
	SoftwareVersion string `json:"software_version"`
	SoftwareBuildID string `json:"software_build_id"`
	SerialNumber    string `json:"serial_number,omitempty"`
	UniqueDeviceID  string `json:"unique_device_id,omitempty"`
}

func (*Versions) CombinedVersion

func (v *Versions) CombinedVersion() string

func (*Versions) DefaultIfEmpty

func (v *Versions) DefaultIfEmpty()

func (*Versions) IDSOSVersion

func (v *Versions) IDSOSVersion() string

func (*Versions) IMTransferUserAgent

func (v *Versions) IMTransferUserAgent() string

func (*Versions) MMEClientInfo

func (v *Versions) MMEClientInfo() string

func (*Versions) MarshalZerologObject

func (v *Versions) MarshalZerologObject(e *zerolog.Event)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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