6
1
mirror of https://git.mills.io/saltyim/saltyim.git synced 2024-06-28 09:41:02 +00:00
prologic-saltyim/addr.go
James Mills 14857206cb Add client e2e integration tests (#180)
Co-authored-by: James Mills <1290234+prologic@users.noreply.github.com>
Reviewed-on: https://git.mills.io/saltyim/saltyim/pulls/180
2023-01-26 22:30:16 +00:00

63 lines
1.7 KiB
Go

package saltyim
import (
"encoding/json"
"fmt"
"net/url"
"github.com/keys-pub/keys"
)
// Addr is a Salty Address in the form of user@domain and is used to discover
// a user's endpoint, domain, avatar service so we can send messages to.
type Addr interface {
fmt.Stringer
json.Marshaler
// IsZero returns true if the address is empty
IsZero() bool
// User returns the user part of the address user@domain
User() string
// Domain returns the domain part of the address user@domain
Domain() string
// Hash returns the Hex(SHA256Sum()) of the Address
Hash() string
// Formatted returns a formatted user used in the Salty Message Format
// <timestamp\t(<user>) <message>\n
Formatted() string
// Key returns the Publib Kcy of this User (Salty Addr) as discovered
Key() *keys.EdX25519PublicKey
// Endpoint returns the discovered Endpoint
Endpoint() *url.URL
// Cap returns the discovered Capabilities
Cap() Capabilities
// DiscoveredDomain returns the discovered domain (if any) of fallbacks to the Domain
DiscoveredDomain() string
// URI returns the Well-Known URI for this Addr
URI() string
// HashURI returns the Well-Known HashURI for this Addr
HashURI() string
// Refresh forces a lookup and configuration fetch for a Salty Address
Refresh() error
// Avatar returns the cached avatar service for a Salty Address or performs a DNS lookup
// for the avatar service to use and cached it (if found) and returns that. If there is no
// avatar service found, then a default avatar is used for peers.
Avatar() string
// WithEndpoint returns a clonse of this address with a different endpoint
// which is mostly useful for sending messages to ourselves or an outbox
WithEndpoint(endpoint *url.URL) Addr
}