Documentation ¶
Index ¶
- Variables
- func DecodeUserLocalpart(str string) (string, error)
- func EncodeUserLocalpart(str string) string
- type Algorithm
- type ContentURI
- func (uri *ContentURI) CUString() ContentURIString
- func (uri *ContentURI) IsEmpty() bool
- func (uri *ContentURI) MarshalJSON() ([]byte, error)
- func (uri ContentURI) MarshalText() ([]byte, error)
- func (uri *ContentURI) String() string
- func (uri *ContentURI) UnmarshalJSON(raw []byte) (err error)
- func (uri *ContentURI) UnmarshalText(raw []byte) (err error)
- type ContentURIString
- type Curve25519
- type DeviceID
- type DeviceKeyID
- type Ed25519
- type EventID
- type IdentityKey
- type KeyAlgorithm
- type KeyID
- type OlmMsgType
- type RoomAlias
- type RoomID
- type SenderKey
- type SessionID
- type SigningKey
- type UserID
Constants ¶
This section is empty.
Variables ¶
var ( InvalidContentURI = errors.New("invalid Matrix content URI") InputNotJSONString = errors.New("input doesn't look like a JSON string") )
Functions ¶
func DecodeUserLocalpart ¶
DecodeUserLocalpart decodes the given string back into the original input string. Returns an error if the given string is not a valid user ID localpart encoding. See http://matrix.org/docs/spec/intro.html#mapping-from-other-character-sets
This decodes quoted-printable bytes back into UTF8, and unescapes casing. For example:
_alph=40_bet=5f50up => Alph@Bet_50up
Returns an error if the input string contains characters outside the range "a-z0-9._=-", has an invalid quote-printable byte (e.g. not hex), or has an invalid _ escaped byte (e.g. "_5").
func EncodeUserLocalpart ¶
EncodeUserLocalpart encodes the given string into Matrix-compliant user ID localpart form. See http://matrix.org/docs/spec/intro.html#mapping-from-other-character-sets
This returns a string with only the characters "a-z0-9._=-". The uppercase range A-Z are encoded using leading underscores ("_"). Characters outside the aforementioned ranges (including literal underscores ("_") and equals ("=")) are encoded as UTF8 code points (NOT NCRs) and converted to lower-case hex with a leading "=". For example:
Alph@Bet_50up => _alph=40_bet=5f50up
Types ¶
type Algorithm ¶
type Algorithm string
Algorithm is a Matrix message encryption algorithm. https://matrix.org/docs/spec/client_server/r0.6.0#messaging-algorithm-names
type ContentURI ¶
ContentURI represents a Matrix content URI. https://matrix.org/docs/spec/client_server/r0.6.0#matrix-content-mxc-uris
func MustParseContentURI ¶
func MustParseContentURI(uri string) ContentURI
func ParseContentURI ¶
func ParseContentURI(uri string) (parsed ContentURI, err error)
ParseContentURI parses a Matrix content URI.
func ParseContentURIBytes ¶
func ParseContentURIBytes(uri []byte) (parsed ContentURI, err error)
func (*ContentURI) CUString ¶
func (uri *ContentURI) CUString() ContentURIString
func (*ContentURI) IsEmpty ¶
func (uri *ContentURI) IsEmpty() bool
func (*ContentURI) MarshalJSON ¶
func (uri *ContentURI) MarshalJSON() ([]byte, error)
func (ContentURI) MarshalText ¶ added in v0.3.6
func (uri ContentURI) MarshalText() ([]byte, error)
func (*ContentURI) String ¶
func (uri *ContentURI) String() string
func (*ContentURI) UnmarshalJSON ¶
func (uri *ContentURI) UnmarshalJSON(raw []byte) (err error)
func (*ContentURI) UnmarshalText ¶ added in v0.3.6
func (uri *ContentURI) UnmarshalText(raw []byte) (err error)
type ContentURIString ¶
type ContentURIString string
ContentURIString is a string that's expected to be a Matrix content URI. It's useful for delaying the parsing of the content URI to move errors from the event content JSON parsing step to a later step where more appropriate errors can be produced.
func (ContentURIString) Parse ¶
func (uriString ContentURIString) Parse() (ContentURI, error)
func (ContentURIString) ParseOrIgnore ¶
func (uriString ContentURIString) ParseOrIgnore() ContentURI
type Curve25519 ¶
type Curve25519 string
Curve25519 is the base64 representation of an Curve25519 public key
func (Curve25519) String ¶
func (curve25519 Curve25519) String() string
type DeviceID ¶
type DeviceID string
A DeviceID is an arbitrary string that references a specific device.
type DeviceKeyID ¶
type DeviceKeyID string
A DeviceKeyID is a string formatted as <algorithm>:<device_id> that is used as the key in deviceid-key mappings.
func NewDeviceKeyID ¶
func NewDeviceKeyID(algorithm KeyAlgorithm, deviceID DeviceID) DeviceKeyID
func (DeviceKeyID) Parse ¶
func (deviceKeyID DeviceKeyID) Parse() (Algorithm, DeviceID)
func (DeviceKeyID) String ¶
func (deviceKeyID DeviceKeyID) String() string
type EventID ¶
type EventID string
An EventID is a string starting with $ that references a specific event.
https://matrix.org/docs/spec/appendices#room-ids-and-event-ids https://matrix.org/docs/spec/rooms/v4#event-ids
type IdentityKey ¶ added in v0.5.5
type IdentityKey = Curve25519
type KeyAlgorithm ¶
type KeyAlgorithm string
const ( KeyAlgorithmCurve25519 KeyAlgorithm = "curve25519" KeyAlgorithmEd25519 KeyAlgorithm = "ed25519" KeyAlgorithmSignedCurve25519 KeyAlgorithm = "signed_curve25519" )
type KeyID ¶
type KeyID string
A KeyID a string formatted as <keyalgorithm>:<key_id> that is used as the key in one-time-key mappings.
func NewKeyID ¶
func NewKeyID(algorithm KeyAlgorithm, keyID string) KeyID
func (KeyID) Parse ¶
func (keyID KeyID) Parse() (KeyAlgorithm, string)
type OlmMsgType ¶
type OlmMsgType int
OlmMsgType is an Olm message type
const ( OlmMsgTypePreKey OlmMsgType = 0 OlmMsgTypeMsg OlmMsgType = 1 )
type RoomAlias ¶
type RoomAlias string
A RoomAlias is a string starting with # that can be resolved into. https://matrix.org/docs/spec/appendices#room-aliases
func NewRoomAlias ¶
type RoomID ¶
type RoomID string
A RoomID is a string starting with ! that references a specific room. https://matrix.org/docs/spec/appendices#room-ids-and-event-ids
type SenderKey ¶
type SenderKey = Curve25519
type SessionID ¶
type SessionID string
A SessionID is an arbitrary string that identifies an Olm or Megolm session.
type SigningKey ¶ added in v0.5.5
type SigningKey = Ed25519
type UserID ¶
type UserID string
UserID represents a Matrix user ID. https://matrix.org/docs/spec/appendices#user-identifiers
func NewEncodedUserID ¶
func (UserID) Parse ¶
Parse parses the user ID into the localpart and server name. See http://matrix.org/docs/spec/intro.html#user-identifiers