63 lines
1.7 KiB
Go
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 Public Key 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 clone of this address with a different endpoint
|
|
// which is mostly useful for sending messages to ourselves or an outbox
|
|
WithEndpoint(endpoint *url.URL) Addr
|
|
}
|