api

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ConflictUpdate will update matching records returning no error
	ConflictUpdate Conflict = 1
	// ConflictAbort will reject the request with ErrorConflict
	ConflictAbort Conflict = 2

	// AccountTypeUser indicates this is a user account
	AccountTypeUser AccountType = 1
	// AccountTypeGuest indicates this is a guest account
	AccountTypeGuest AccountType = 2
	// AccountTypeAdmin indicates this is an admin account
	AccountTypeAdmin AccountType = 3
	// AccountTypeAppService indicates this is an appservice account
	AccountTypeAppService AccountType = 4
)
View Source
const DefaultLoginTokenLifetime = 2 * time.Minute

DefaultLoginTokenLifetime determines how old a valid token may be.

NOTSPEC: The current spec says "SHOULD be limited to around five seconds". Since TCP retries are on the order of 3 s, 5 s sounds very low. Synapse uses 2 min (https://github.com/matrix-org/synapse/blob/78d5f91de1a9baf4dbb0a794cb49a799f29f7a38/synapse/handlers/auth.py#L1323-L1325).

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	UserID       string
	Localpart    string
	ServerName   spec.ServerName
	AppServiceID string
	AccountType  AccountType
}

Account represents a Matrix account on this home server.

type AccountType

type AccountType int

AccountType is an enum representing the kind of account

type AppserviceUserAPI

type AppserviceUserAPI interface {
	PerformAccountCreation(ctx context.Context, req *PerformAccountCreationRequest, res *PerformAccountCreationResponse) error
	PerformDeviceCreation(ctx context.Context, req *PerformDeviceCreationRequest, res *PerformDeviceCreationResponse) error
}

api functions required by the appservice api

type ClientKeyAPI

type ClientKeyAPI interface {
	UploadDeviceKeysAPI
	QueryKeys(ctx context.Context, req *QueryKeysRequest, res *QueryKeysResponse)
	PerformUploadKeys(ctx context.Context, req *PerformUploadKeysRequest, res *PerformUploadKeysResponse) error

	PerformUploadDeviceSignatures(ctx context.Context, req *PerformUploadDeviceSignaturesRequest, res *PerformUploadDeviceSignaturesResponse)
	// PerformClaimKeys claims one-time keys for use in pre-key messages
	PerformClaimKeys(ctx context.Context, req *PerformClaimKeysRequest, res *PerformClaimKeysResponse)
	PerformMarkAsStaleIfNeeded(ctx context.Context, req *PerformMarkAsStaleRequest, res *struct{}) error
}

API functions required by the clientapi

type ClientUserAPI

type ClientUserAPI interface {
	QueryAcccessTokenAPI
	LoginTokenInternalAPI
	LoginJWTInternalAPI
	UserLoginAPI
	ClientKeyAPI
	ProfileAPI
	KeyBackupAPI
	QueryNumericLocalpart(ctx context.Context, req *QueryNumericLocalpartRequest, res *QueryNumericLocalpartResponse) error
	QueryDevices(ctx context.Context, req *QueryDevicesRequest, res *QueryDevicesResponse) error
	QueryAccountData(ctx context.Context, req *QueryAccountDataRequest, res *QueryAccountDataResponse) error
	QueryPushers(ctx context.Context, req *QueryPushersRequest, res *QueryPushersResponse) error
	QueryPushRules(ctx context.Context, userID string) (*pushrules.AccountRuleSets, error)
	QueryAccountAvailability(ctx context.Context, req *QueryAccountAvailabilityRequest, res *QueryAccountAvailabilityResponse) error
	PerformAdminCreateRegistrationToken(ctx context.Context, registrationToken *clientapi.RegistrationToken) (bool, error)
	PerformAdminListRegistrationTokens(ctx context.Context, returnAll bool, valid bool) ([]clientapi.RegistrationToken, error)
	PerformAdminGetRegistrationToken(ctx context.Context, tokenString string) (*clientapi.RegistrationToken, error)
	PerformAdminDeleteRegistrationToken(ctx context.Context, tokenString string) error
	PerformAdminUpdateRegistrationToken(ctx context.Context, tokenString string, newAttributes map[string]interface{}) (*clientapi.RegistrationToken, error)
	PerformAccountCreation(ctx context.Context, req *PerformAccountCreationRequest, res *PerformAccountCreationResponse) error
	PerformDeviceCreation(ctx context.Context, req *PerformDeviceCreationRequest, res *PerformDeviceCreationResponse) error
	PerformDeviceUpdate(ctx context.Context, req *PerformDeviceUpdateRequest, res *PerformDeviceUpdateResponse) error
	PerformDeviceDeletion(ctx context.Context, req *PerformDeviceDeletionRequest, res *PerformDeviceDeletionResponse) error
	PerformPasswordUpdate(ctx context.Context, req *PerformPasswordUpdateRequest, res *PerformPasswordUpdateResponse) error
	PerformPusherDeletion(ctx context.Context, req *PerformPusherDeletionRequest, res *struct{}) error
	PerformPusherSet(ctx context.Context, req *PerformPusherSetRequest, res *struct{}) error
	PerformPushRulesPut(ctx context.Context, userID string, ruleSets *pushrules.AccountRuleSets) error
	PerformAccountDeactivation(ctx context.Context, req *PerformAccountDeactivationRequest, res *PerformAccountDeactivationResponse) error
	PerformOpenIDTokenCreation(ctx context.Context, req *PerformOpenIDTokenCreationRequest, res *PerformOpenIDTokenCreationResponse) error
	QueryNotifications(ctx context.Context, req *QueryNotificationsRequest, res *QueryNotificationsResponse) error
	InputAccountData(ctx context.Context, req *InputAccountDataRequest, res *InputAccountDataResponse) error

	QueryThreePIDsForLocalpart(ctx context.Context, req *QueryThreePIDsForLocalpartRequest, res *QueryThreePIDsForLocalpartResponse) error
	QueryLocalpartForThreePID(ctx context.Context, req *QueryLocalpartForThreePIDRequest, res *QueryLocalpartForThreePIDResponse) error
	PerformForgetThreePID(ctx context.Context, req *PerformForgetThreePIDRequest, res *struct{}) error
	PerformSaveThreePIDAssociation(ctx context.Context, req *PerformSaveThreePIDAssociationRequest, res *struct{}) error
}

api functions required by the client api

type Conflict

type Conflict int

Conflict is an enum representing what to do when encountering conflicting when creating profiles/devices

type CrossSigningKeyUpdate

type CrossSigningKeyUpdate struct {
	MasterKey      *fclient.CrossSigningKey `json:"master_key,omitempty"`
	SelfSigningKey *fclient.CrossSigningKey `json:"self_signing_key,omitempty"`
	UserID         string                   `json:"user_id"`
}

type Device

type Device struct {
	ID     string
	UserID string
	// The access_token granted to this device.
	// This uniquely identifies the device from all other devices and clients.
	AccessToken string
	// The unique ID of the session identified by the access token.
	// Can be used as a secure substitution in places where data needs to be
	// associated with access tokens.
	SessionID   int64
	DisplayName string
	LastSeenTS  int64
	LastSeenIP  string
	UserAgent   string
	// If the device is for an appservice user,
	// this is the appservice ID.
	AppserviceID string
	AccountType  AccountType
}

Device represents a client's device (mobile, web, etc)

func (*Device) UserDomain

func (d *Device) UserDomain() spec.ServerName

type DeviceKeys

type DeviceKeys struct {
	// The user who owns this device
	UserID string
	// The device ID of this device
	DeviceID string
	// The device display name
	DisplayName string
	// The raw device key JSON
	KeyJSON []byte
}

DeviceKeys represents a set of device keys for a single device https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-keys-upload

func (*DeviceKeys) WithStreamID

func (k *DeviceKeys) WithStreamID(streamID int64) DeviceMessage

WithStreamID returns a copy of this device message with the given stream ID

type DeviceMessage

type DeviceMessage struct {
	Type                         DeviceMessageType `json:"Type,omitempty"`
	*DeviceKeys                  `json:"DeviceKeys,omitempty"`
	*OutputCrossSigningKeyUpdate `json:"CrossSigningKeyUpdate,omitempty"`
	// A monotonically increasing number which represents device changes for this user.
	StreamID       int64
	DeviceChangeID int64
}

DeviceMessage represents the message produced into Kafka by the key server.

func (*DeviceMessage) DeviceKeysEqual

func (m1 *DeviceMessage) DeviceKeysEqual(m2 *DeviceMessage) bool

DeviceKeysEqual returns true if the device keys updates contain the same display name and key JSON. This will return false if either of the updates is not a device keys update, or if the user ID/device ID differ between the two.

type DeviceMessageType

type DeviceMessageType int
const (
	TypeDeviceKeyUpdate DeviceMessageType = iota
	TypeCrossSigningUpdate
)

type ErrorConflict

type ErrorConflict struct {
	Message string
}

ErrorConflict is an error indicating that there was a conflict which resulted in the request being aborted.

func (*ErrorConflict) Error

func (e *ErrorConflict) Error() string

type ErrorForbidden

type ErrorForbidden struct {
	Message string
}

ErrorForbidden is an error indicating that the supplied access token is forbidden

func (*ErrorForbidden) Error

func (e *ErrorForbidden) Error() string

type FederationKeyAPI

type FederationKeyAPI interface {
	UploadDeviceKeysAPI
	QueryKeys(ctx context.Context, req *QueryKeysRequest, res *QueryKeysResponse)
	QuerySignatures(ctx context.Context, req *QuerySignaturesRequest, res *QuerySignaturesResponse)
	QueryDeviceMessages(ctx context.Context, req *QueryDeviceMessagesRequest, res *QueryDeviceMessagesResponse) error
	PerformClaimKeys(ctx context.Context, req *PerformClaimKeysRequest, res *PerformClaimKeysResponse)
}

type FederationUserAPI

type FederationUserAPI interface {
	UploadDeviceKeysAPI
	QueryOpenIDToken(ctx context.Context, req *QueryOpenIDTokenRequest, res *QueryOpenIDTokenResponse) error
	QueryProfile(ctx context.Context, userID string) (*authtypes.Profile, error)
	QueryDevices(ctx context.Context, req *QueryDevicesRequest, res *QueryDevicesResponse) error
	QueryKeys(ctx context.Context, req *QueryKeysRequest, res *QueryKeysResponse)
	QuerySignatures(ctx context.Context, req *QuerySignaturesRequest, res *QuerySignaturesResponse)
	QueryDeviceMessages(ctx context.Context, req *QueryDeviceMessagesRequest, res *QueryDeviceMessagesResponse) error
	PerformClaimKeys(ctx context.Context, req *PerformClaimKeysRequest, res *PerformClaimKeysResponse)
}

api functions required by the federation api

type InputAccountDataRequest

type InputAccountDataRequest struct {
	UserID      string          // required: the user to set account data for
	RoomID      string          // optional: the room to associate the account data with
	DataType    string          // required: the data type of the data
	AccountData json.RawMessage // required: the message content
}

InputAccountDataRequest is the request for InputAccountData

type InputAccountDataResponse

type InputAccountDataResponse struct {
}

InputAccountDataResponse is the response for InputAccountData

type InternalKeyBackupSession

type InternalKeyBackupSession struct {
	KeyBackupSession
	RoomID    string
	SessionID string
}

Internal KeyBackupData for passing to/from the storage layer

type JWTClaims added in v0.1.3

type JWTClaims struct {
	Ext         map[string]any `json:"ext,omitempty"`
	TenantID    string         `json:"tenant_id,omitempty"`
	PartitionID string         `json:"partition_id,omitempty"`
	AccessID    string         `json:"access_id,omitempty"`
	ContactID   string         `json:"contact_id,omitempty"`
	Roles       []string       `json:"roles,omitempty"`
	jwt.RegisteredClaims
}

JWTClaims Create a struct that will be encoded to a JWT. We add jwt.StandardClaims as an embedded type, to provide fields like expiry time

func (*JWTClaims) AsMetadata added in v0.1.3

func (a *JWTClaims) AsMetadata() map[string]string

AsMetadata Creates a string map to be used as metadata in queue data

func (*JWTClaims) GetAccessId added in v0.1.3

func (a *JWTClaims) GetAccessId() string

func (*JWTClaims) GetContactId added in v0.1.3

func (a *JWTClaims) GetContactId() string

func (*JWTClaims) GetPartitionId added in v0.1.3

func (a *JWTClaims) GetPartitionId() string

func (*JWTClaims) GetRoles added in v0.1.3

func (a *JWTClaims) GetRoles() []string

func (*JWTClaims) GetTenantId added in v0.1.3

func (a *JWTClaims) GetTenantId() string

func (*JWTClaims) ServiceName added in v0.1.3

func (a *JWTClaims) ServiceName() string

type KeyBackupAPI

type KeyBackupAPI interface {
	DeleteKeyBackup(ctx context.Context, userID, version string) (bool, error)
	PerformKeyBackup(ctx context.Context, req *PerformKeyBackupRequest) (string, error)
	QueryKeyBackup(ctx context.Context, req *QueryKeyBackupRequest) (*QueryKeyBackupResponse, error)
	UpdateBackupKeyAuthData(ctx context.Context, req *PerformKeyBackupRequest) (*PerformKeyBackupResponse, error)
}

type KeyBackupSession

type KeyBackupSession struct {
	FirstMessageIndex int             `json:"first_message_index"`
	ForwardedCount    int             `json:"forwarded_count"`
	IsVerified        bool            `json:"is_verified"`
	SessionData       json.RawMessage `json:"session_data"`
}

KeyBackupData in https://spec.matrix.org/unstable/client-server-api/#get_matrixclientr0room_keyskeysroomidsessionid

func (*KeyBackupSession) ShouldReplaceRoomKey

func (a *KeyBackupSession) ShouldReplaceRoomKey(newKey *KeyBackupSession) bool

type KeyError

type KeyError struct {
	Err                string `json:"error"`
	IsInvalidSignature bool   `json:"is_invalid_signature,omitempty"` // M_INVALID_SIGNATURE
	IsMissingParam     bool   `json:"is_missing_param,omitempty"`     // M_MISSING_PARAM
	IsInvalidParam     bool   `json:"is_invalid_param,omitempty"`     // M_INVALID_PARAM
}

KeyError is returned if there was a problem performing/querying the server

func (*KeyError) Error

func (k *KeyError) Error() string

type LoginJWTInternalAPI added in v0.1.3

type LoginJWTInternalAPI interface {

	// QueryLoginJWT returns the data associated with a login token
	QueryLoginJWT(ctx context.Context, req *QueryLoginJWTRequest, res *QueryLoginJWTResponse) error
}

type LoginTokenData

type LoginTokenData struct {
	// UserID is the full mxid of the user.
	UserID string
}

LoginTokenData is the data that can be retrieved given a login token. This is provided by the calling code.

type LoginTokenInternalAPI

type LoginTokenInternalAPI interface {
	// PerformLoginTokenCreation creates a new login token and associates it with the provided data.
	PerformLoginTokenCreation(ctx context.Context, req *PerformLoginTokenCreationRequest, res *PerformLoginTokenCreationResponse) error

	// PerformLoginTokenDeletion ensures the token doesn't exist. Success
	// is returned even if the token didn't exist, or was already deleted.
	PerformLoginTokenDeletion(ctx context.Context, req *PerformLoginTokenDeletionRequest, res *PerformLoginTokenDeletionResponse) error

	// QueryLoginToken returns the data associated with a login token. If
	// the token is not valid, success is returned, but res.Data == nil.
	QueryLoginToken(ctx context.Context, req *QueryLoginTokenRequest, res *QueryLoginTokenResponse) error
}

type LoginTokenMetadata

type LoginTokenMetadata struct {
	Token      string
	Expiration time.Time
}

LoginTokenMetadata contains metadata created and maintained by the User API.

type MediaUserAPI

type MediaUserAPI interface {
	QueryAcccessTokenAPI
}

api functions required by the media api

type Notification

type Notification struct {
	Actions    []*pushrules.Action   `json:"actions"`     // Required.
	Event      synctypes.ClientEvent `json:"event"`       // Required.
	ProfileTag string                `json:"profile_tag"` // Required by Sytest, but actually optional.
	Read       bool                  `json:"read"`        // Required.
	RoomID     string                `json:"room_id"`     // Required.
	TS         spec.Timestamp        `json:"ts"`          // Required.
}

type OneTimeKeys

type OneTimeKeys struct {
	// The user who owns this device
	UserID string
	// The device ID of this device
	DeviceID string
	// A map of algorithm:key_id => key JSON
	KeyJSON map[string]json.RawMessage
}

OneTimeKeys represents a set of one-time keys for a single device https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-keys-upload

func (*OneTimeKeys) Split

func (k *OneTimeKeys) Split(keyIDWithAlgo string) (algo string, keyID string)

Split a key in KeyJSON into algorithm and key ID

type OneTimeKeysCount

type OneTimeKeysCount struct {
	// The user who owns this device
	UserID string
	// The device ID of this device
	DeviceID string
	// algorithm to count e.g:
	// {
	//   "curve25519": 10,
	//   "signed_curve25519": 20
	// }
	KeyCount map[string]int
}

OneTimeKeysCount represents the counts of one-time keys for a single device

type OpenIDToken

type OpenIDToken struct {
	Token       string
	UserID      string
	ExpiresAtMS int64
}

OpenIDToken represents an OpenID token

type OpenIDTokenAttributes

type OpenIDTokenAttributes struct {
	UserID      string
	ExpiresAtMS int64
}

OpenIDTokenInfo represents the attributes associated with an issued OpenID token

type OutputCrossSigningKeyUpdate

type OutputCrossSigningKeyUpdate struct {
	CrossSigningKeyUpdate `json:"signing_keys"`
}

OutputCrossSigningKeyUpdate is an entry in the signing key update output kafka log

type PerformAccountCreationRequest

type PerformAccountCreationRequest struct {
	AccountType AccountType     // Required: whether this is a guest or user account
	Localpart   string          // Required: The localpart for this account. Ignored if account type is guest.
	ServerName  spec.ServerName // optional: if not specified, default server name used instead

	AppServiceID string // optional: the application service ID (not user ID) creating this account, if any.
	Password     string // optional: if missing then this account will be a passwordless account
	OnConflict   Conflict
}

PerformAccountCreationRequest is the request for PerformAccountCreation

type PerformAccountCreationResponse

type PerformAccountCreationResponse struct {
	AccountCreated bool
	Account        *Account
}

PerformAccountCreationResponse is the response for PerformAccountCreation

type PerformAccountDeactivationRequest

type PerformAccountDeactivationRequest struct {
	Localpart  string
	ServerName spec.ServerName // optional: if blank, default server name used
}

PerformAccountDeactivationRequest is the request for PerformAccountDeactivation

type PerformAccountDeactivationResponse

type PerformAccountDeactivationResponse struct {
	AccountDeactivated bool
}

PerformAccountDeactivationResponse is the response for PerformAccountDeactivation

type PerformClaimKeysRequest

type PerformClaimKeysRequest struct {
	// Map of user_id to device_id to algorithm name
	OneTimeKeys map[string]map[string]string
	Timeout     time.Duration
}

type PerformClaimKeysResponse

type PerformClaimKeysResponse struct {
	// Map of user_id to device_id to algorithm:key_id to key JSON
	OneTimeKeys map[string]map[string]map[string]json.RawMessage
	// Map of remote server domain to error JSON
	Failures map[string]interface{}
	// Set if there was a fatal error processing this action
	Error *KeyError
}

type PerformDeleteKeysRequest

type PerformDeleteKeysRequest struct {
	UserID string
	KeyIDs []gomatrixserverlib.KeyID
}

PerformDeleteKeysRequest asks the keyserver to forget about certain keys, and signatures related to those keys.

type PerformDeleteKeysResponse

type PerformDeleteKeysResponse struct {
	Error *KeyError
}

PerformDeleteKeysResponse is the response to PerformDeleteKeysRequest.

type PerformDeviceCreationRequest

type PerformDeviceCreationRequest struct {
	Localpart   string
	ServerName  spec.ServerName // optional: if blank, default server name used
	AccessToken string          // optional: if blank one will be made on your behalf
	// optional: if nil an ID is generated for you. If set, replaces any existing device session,
	// which will generate a new access token and invalidate the old one.
	DeviceID *string
	// optional: if nil no display name will be associated with this device.
	DeviceDisplayName *string
	// IP address of this device
	IPAddr string
	// Useragent for this device
	UserAgent string
	// NoDeviceListUpdate determines whether we should avoid sending a device list
	// update for this account. Generally the only reason to do this is if the account
	// is an appservice account.
	NoDeviceListUpdate bool

	// FromRegistration determines if this request comes from registering a new account
	// and is in most cases false.
	FromRegistration bool
}

PerformDeviceCreationRequest is the request for PerformDeviceCreation

type PerformDeviceCreationResponse

type PerformDeviceCreationResponse struct {
	DeviceCreated bool
	Device        *Device
}

PerformDeviceCreationResponse is the response for PerformDeviceCreation

type PerformDeviceDeletionRequest

type PerformDeviceDeletionRequest struct {
	UserID string
	// The devices to delete. An empty slice means delete all devices.
	DeviceIDs []string
	// The requesting device ID to exclude from deletion. This is needed
	// so that a password change doesn't cause that client to be logged
	// out. Only specify when DeviceIDs is empty.
	ExceptDeviceID string
}

type PerformDeviceDeletionResponse

type PerformDeviceDeletionResponse struct {
}

type PerformDeviceUpdateRequest

type PerformDeviceUpdateRequest struct {
	RequestingUserID string
	DeviceID         string
	DisplayName      *string
}

type PerformDeviceUpdateResponse

type PerformDeviceUpdateResponse struct {
	DeviceExists bool
}

type PerformForgetThreePIDRequest

type PerformForgetThreePIDRequest QueryLocalpartForThreePIDRequest

type PerformKeyBackupRequest

type PerformKeyBackupRequest struct {
	UserID    string
	Version   string // optional if modifying a key backup
	AuthData  json.RawMessage
	Algorithm string

	// The keys to upload, if any. If blank, creates/updates/deletes key version metadata only.
	Keys struct {
		Rooms map[string]struct {
			Sessions map[string]KeyBackupSession `json:"sessions"`
		} `json:"rooms"`
	}
}

type PerformKeyBackupResponse

type PerformKeyBackupResponse struct {
	Exists  bool   // set to true if the Version exists
	Version string // the newly created version

	KeyCount int64  // only set if Keys were given in the request
	KeyETag  string // only set if Keys were given in the request
}

type PerformLastSeenUpdateRequest

type PerformLastSeenUpdateRequest struct {
	UserID     string
	DeviceID   string
	RemoteAddr string
	UserAgent  string
}

PerformLastSeenUpdateRequest is the request for PerformLastSeenUpdate.

type PerformLastSeenUpdateResponse

type PerformLastSeenUpdateResponse struct {
}

PerformLastSeenUpdateResponse is the response for PerformLastSeenUpdate.

type PerformLoginTokenCreationRequest

type PerformLoginTokenCreationRequest struct {
	Data LoginTokenData
}

type PerformLoginTokenCreationResponse

type PerformLoginTokenCreationResponse struct {
	Metadata LoginTokenMetadata
}

type PerformLoginTokenDeletionRequest

type PerformLoginTokenDeletionRequest struct {
	Token string
}

type PerformLoginTokenDeletionResponse

type PerformLoginTokenDeletionResponse struct{}

type PerformMarkAsStaleRequest

type PerformMarkAsStaleRequest struct {
	UserID   string
	Domain   spec.ServerName
	DeviceID string
}

type PerformOpenIDTokenCreationRequest

type PerformOpenIDTokenCreationRequest struct {
	UserID string
}

PerformOpenIDTokenCreationRequest is the request for PerformOpenIDTokenCreation

type PerformOpenIDTokenCreationResponse

type PerformOpenIDTokenCreationResponse struct {
	Token OpenIDToken
}

PerformOpenIDTokenCreationResponse is the response for PerformOpenIDTokenCreation

type PerformPasswordUpdateRequest

type PerformPasswordUpdateRequest struct {
	Localpart     string          // Required: The localpart for this account.
	ServerName    spec.ServerName // Required: The domain for this account.
	Password      string          // Required: The new password to set.
	LogoutDevices bool            // Optional: Whether to log out all user devices.
}

PerformAccountCreationRequest is the request for PerformAccountCreation

type PerformPasswordUpdateResponse

type PerformPasswordUpdateResponse struct {
	PasswordUpdated bool
	Account         *Account
}

PerformAccountCreationResponse is the response for PerformAccountCreation

type PerformPusherDeletionRequest

type PerformPusherDeletionRequest struct {
	Localpart  string
	ServerName spec.ServerName
	SessionID  int64
}

type PerformPusherSetRequest

type PerformPusherSetRequest struct {
	Pusher     // Anonymous field because that's how clientapi unmarshals it.
	Localpart  string
	ServerName spec.ServerName
	Append     bool `json:"append"`
}

type PerformSaveThreePIDAssociationRequest

type PerformSaveThreePIDAssociationRequest struct {
	ThreePID   string
	Localpart  string
	ServerName spec.ServerName
	Medium     string
}

type PerformUploadDeviceKeysRequest

type PerformUploadDeviceKeysRequest struct {
	fclient.CrossSigningKeys
	// The user that uploaded the key, should be populated by the clientapi.
	UserID string
}

type PerformUploadDeviceKeysResponse

type PerformUploadDeviceKeysResponse struct {
	Error *KeyError
}

type PerformUploadDeviceSignaturesRequest

type PerformUploadDeviceSignaturesRequest struct {
	Signatures map[string]map[gomatrixserverlib.KeyID]fclient.CrossSigningForKeyOrDevice
	// The user that uploaded the sig, should be populated by the clientapi.
	UserID string
}

type PerformUploadDeviceSignaturesResponse

type PerformUploadDeviceSignaturesResponse struct {
	Error *KeyError
}

type PerformUploadKeysRequest

type PerformUploadKeysRequest struct {
	UserID      string // Required - User performing the request
	DeviceID    string // Optional - Device performing the request, for fetching OTK count
	DeviceKeys  []DeviceKeys
	OneTimeKeys []OneTimeKeys
	// OnlyDisplayNameUpdates should be `true` if ALL the DeviceKeys are present to update
	// the display name for their respective device, and NOT to modify the keys. The key
	// itself doesn't change but it's easier to pretend upload new keys and reuse the same code paths.
	// Without this flag, requests to modify device display names would delete device keys.
	OnlyDisplayNameUpdates bool

	// FromRegistration is set if this key upload comes right after creating an account
	// and determines if we need to inform downstream components.
	FromRegistration bool
}

PerformUploadKeysRequest is the request to PerformUploadKeys

type PerformUploadKeysResponse

type PerformUploadKeysResponse struct {
	// A fatal error when processing e.g database failures
	Error *KeyError
	// A map of user_id -> device_id -> Error for tracking failures.
	KeyErrors        map[string]map[string]*KeyError
	OneTimeKeyCounts []OneTimeKeysCount
}

PerformUploadKeysResponse is the response to PerformUploadKeys

func (*PerformUploadKeysResponse) KeyError

func (r *PerformUploadKeysResponse) KeyError(userID, deviceID string, err *KeyError)

KeyError sets a key error field on KeyErrors

type ProfileAPI

type ProfileAPI interface {
	QueryProfile(ctx context.Context, userID string) (*authtypes.Profile, error)
	SetAvatarURL(ctx context.Context, localpart string, serverName spec.ServerName, avatarURL string) (*authtypes.Profile, bool, error)
	SetDisplayName(ctx context.Context, localpart string, serverName spec.ServerName, displayName string) (*authtypes.Profile, bool, error)
}

type Pusher

type Pusher struct {
	SessionID         int64                  `json:"session_id,omitempty"`
	PushKey           string                 `json:"pushkey"`
	PushKeyTS         int64                  `json:"pushkey_ts,omitempty"`
	Kind              PusherKind             `json:"kind"`
	AppID             string                 `json:"app_id"`
	AppDisplayName    string                 `json:"app_display_name"`
	DeviceDisplayName string                 `json:"device_display_name"`
	ProfileTag        string                 `json:"profile_tag"`
	Language          string                 `json:"lang"`
	Data              map[string]interface{} `json:"data"`
}

Pusher represents a push notification subscriber

type PusherKind

type PusherKind string
const (
	EmailKind PusherKind = "email"
	HTTPKind  PusherKind = "http"
)

type QueryAcccessTokenAPI

type QueryAcccessTokenAPI interface {
	QueryAccessToken(ctx context.Context, req *QueryAccessTokenRequest, res *QueryAccessTokenResponse) error
}

common function for creating authenticated endpoints (used in client/media/sync api)

type QueryAccessTokenRequest

type QueryAccessTokenRequest struct {
	AccessToken string
	// optional user ID, valid only if the token is an appservice.
	// https://matrix.org/docs/spec/application_service/r0.1.2#using-sync-and-events
	AppServiceUserID string
}

QueryAccessTokenRequest is the request for QueryAccessToken

type QueryAccessTokenResponse

type QueryAccessTokenResponse struct {
	Device *Device
	Err    string // e.g ErrorForbidden
}

QueryAccessTokenResponse is the response for QueryAccessToken

type QueryAccountAvailabilityRequest

type QueryAccountAvailabilityRequest struct {
	Localpart  string
	ServerName spec.ServerName
}

type QueryAccountAvailabilityResponse

type QueryAccountAvailabilityResponse struct {
	Available bool
}

type QueryAccountByLocalpartRequest

type QueryAccountByLocalpartRequest struct {
	Localpart  string
	ServerName spec.ServerName
}

type QueryAccountByLocalpartResponse

type QueryAccountByLocalpartResponse struct {
	Account *Account
}

type QueryAccountByPasswordRequest

type QueryAccountByPasswordRequest struct {
	Localpart         string
	ServerName        spec.ServerName
	PlaintextPassword string
}

type QueryAccountByPasswordResponse

type QueryAccountByPasswordResponse struct {
	Account *Account
	Exists  bool
}

type QueryAccountDataRequest

type QueryAccountDataRequest struct {
	UserID   string // required: the user to get account data for.
	RoomID   string // optional: the room ID, or global account data if not specified.
	DataType string // optional: the data type, or all types if not specified.
}

QueryAccountDataRequest is the request for QueryAccountData

type QueryAccountDataResponse

type QueryAccountDataResponse struct {
	GlobalAccountData map[string]json.RawMessage            // type -> data
	RoomAccountData   map[string]map[string]json.RawMessage // room -> type -> data
}

QueryAccountDataResponse is the response for QueryAccountData

type QueryDeviceInfosRequest

type QueryDeviceInfosRequest struct {
	DeviceIDs []string
}

QueryDeviceInfosRequest is the request to QueryDeviceInfos

type QueryDeviceInfosResponse

type QueryDeviceInfosResponse struct {
	DeviceInfo map[string]struct {
		DisplayName string
		UserID      string
	}
}

QueryDeviceInfosResponse is the response to QueryDeviceInfos

type QueryDeviceMessagesRequest

type QueryDeviceMessagesRequest struct {
	UserID string
}

type QueryDeviceMessagesResponse

type QueryDeviceMessagesResponse struct {
	// The latest stream ID
	StreamID int64
	Devices  []DeviceMessage
	Error    *KeyError
}

type QueryDevicesRequest

type QueryDevicesRequest struct {
	UserID string
}

QueryDevicesRequest is the request for QueryDevices

type QueryDevicesResponse

type QueryDevicesResponse struct {
	UserExists bool
	Devices    []Device
}

QueryDevicesResponse is the response for QueryDevices

type QueryKeyBackupRequest

type QueryKeyBackupRequest struct {
	UserID  string
	Version string // the version to query, if blank it means the latest

	ReturnKeys       bool   // whether to return keys in the backup response or just the metadata
	KeysForRoomID    string // optional string to return keys which belong to this room
	KeysForSessionID string // optional string to return keys which belong to this (room, session)
}

type QueryKeyBackupResponse

type QueryKeyBackupResponse struct {
	Exists bool

	Algorithm string          `json:"algorithm"`
	AuthData  json.RawMessage `json:"auth_data"`
	Count     int64           `json:"count"`
	ETag      string          `json:"etag"`
	Version   string          `json:"version"`

	Keys map[string]map[string]KeyBackupSession // the keys if ReturnKeys=true
}

type QueryKeyChangesRequest

type QueryKeyChangesRequest struct {
	// The offset of the last received key event, or sarama.OffsetOldest if this is from the beginning
	Offset int64
	// The inclusive offset where to track key changes up to. Messages with this offset are included in the response.
	// Use types.OffsetNewest if the offset is unknown (then check the response Offset to avoid racing).
	ToOffset int64
}

type QueryKeyChangesResponse

type QueryKeyChangesResponse struct {
	// The set of users who have had their keys change.
	UserIDs []string
	// The latest offset represented in this response.
	Offset int64
	// Set if there was a problem handling the request.
	Error *KeyError
}

type QueryKeysRequest

type QueryKeysRequest struct {
	// The user ID asking for the keys, e.g. if from a client API request.
	// Will not be populated if the key request came from federation.
	UserID string
	// Maps user IDs to a list of devices
	UserToDevices map[string][]string
	Timeout       time.Duration
}

type QueryKeysResponse

type QueryKeysResponse struct {
	// Map of remote server domain to error JSON
	Failures map[string]interface{}
	// Map of user_id to device_id to device_key
	DeviceKeys map[string]map[string]json.RawMessage
	// Maps of user_id to cross signing key
	MasterKeys      map[string]fclient.CrossSigningKey
	SelfSigningKeys map[string]fclient.CrossSigningKey
	UserSigningKeys map[string]fclient.CrossSigningKey
	// Set if there was a fatal error processing this query
	Error *KeyError
}

type QueryLocalpartForThreePIDRequest

type QueryLocalpartForThreePIDRequest struct {
	ThreePID, Medium string
}

type QueryLocalpartForThreePIDResponse

type QueryLocalpartForThreePIDResponse struct {
	Localpart  string
	ServerName spec.ServerName
}

type QueryLoginJWTRequest added in v0.1.3

type QueryLoginJWTRequest struct {
	Token string
}

type QueryLoginJWTResponse added in v0.1.3

type QueryLoginJWTResponse struct {
	// Data is nil if the token was invalid.
	Data *LoginTokenData
}

type QueryLoginTokenRequest

type QueryLoginTokenRequest struct {
	Token string
}

type QueryLoginTokenResponse

type QueryLoginTokenResponse struct {
	// Data is nil if the token was invalid.
	Data *LoginTokenData
}

type QueryNotificationsRequest

type QueryNotificationsRequest struct {
	Localpart  string          `json:"localpart"`   // Required.
	ServerName spec.ServerName `json:"server_name"` // Required.
	From       string          `json:"from,omitempty"`
	Limit      int             `json:"limit,omitempty"`
	Only       string          `json:"only,omitempty"`
}

type QueryNotificationsResponse

type QueryNotificationsResponse struct {
	NextToken     string          `json:"next_token"`
	Notifications []*Notification `json:"notifications"` // Required.
}

type QueryNumericLocalpartRequest

type QueryNumericLocalpartRequest struct {
	ServerName spec.ServerName
}

type QueryNumericLocalpartResponse

type QueryNumericLocalpartResponse struct {
	ID int64
}

type QueryOneTimeKeysRequest

type QueryOneTimeKeysRequest struct {
	// The local user to query OTK counts for
	UserID string
	// The device to query OTK counts for
	DeviceID string
}

type QueryOneTimeKeysResponse

type QueryOneTimeKeysResponse struct {
	// OTK key counts, in the extended /sync form described by https://matrix.org/docs/spec/client_server/r0.6.1#id84
	Count OneTimeKeysCount
	Error *KeyError
}

type QueryOpenIDTokenRequest

type QueryOpenIDTokenRequest struct {
	Token string
}

QueryOpenIDTokenRequest is the request for QueryOpenIDToken

type QueryOpenIDTokenResponse

type QueryOpenIDTokenResponse struct {
	Sub         string // The Matrix User ID that generated the token
	ExpiresAtMS int64
}

QueryOpenIDTokenResponse is the response for QueryOpenIDToken

type QueryPushersRequest

type QueryPushersRequest struct {
	Localpart  string
	ServerName spec.ServerName
}

type QueryPushersResponse

type QueryPushersResponse struct {
	Pushers []Pusher `json:"pushers"`
}

type QuerySearchProfilesAPI

type QuerySearchProfilesAPI interface {
	QuerySearchProfiles(ctx context.Context, req *QuerySearchProfilesRequest, res *QuerySearchProfilesResponse) error
}

custom api functions required by pinecone / p2p demos

type QuerySearchProfilesRequest

type QuerySearchProfilesRequest struct {
	// The search string to match
	SearchString string
	// How many results to return
	Limit int
}

QuerySearchProfilesRequest is the request for QueryProfile

type QuerySearchProfilesResponse

type QuerySearchProfilesResponse struct {
	// Profiles matching the search
	Profiles []authtypes.Profile
}

QuerySearchProfilesResponse is the response for QuerySearchProfilesRequest

type QuerySignaturesRequest

type QuerySignaturesRequest struct {
	// A map of target user ID -> target key/device IDs to retrieve signatures for
	TargetIDs map[string][]gomatrixserverlib.KeyID `json:"target_ids"`
}

type QuerySignaturesResponse

type QuerySignaturesResponse struct {
	// A map of target user ID -> target key/device ID -> origin user ID -> origin key/device ID -> signatures
	Signatures map[string]map[gomatrixserverlib.KeyID]types.CrossSigningSigMap
	// A map of target user ID -> cross-signing master key
	MasterKeys map[string]fclient.CrossSigningKey
	// A map of target user ID -> cross-signing self-signing key
	SelfSigningKeys map[string]fclient.CrossSigningKey
	// A map of target user ID -> cross-signing user-signing key
	UserSigningKeys map[string]fclient.CrossSigningKey
	// The request error, if any
	Error *KeyError
}

type QueryThreePIDsForLocalpartRequest

type QueryThreePIDsForLocalpartRequest struct {
	Localpart  string
	ServerName spec.ServerName
}

type QueryThreePIDsForLocalpartResponse

type QueryThreePIDsForLocalpartResponse struct {
	ThreePIDs []authtypes.ThreePID
}

type RoomserverUserAPI

type RoomserverUserAPI interface {
	QueryAccountData(ctx context.Context, req *QueryAccountDataRequest, res *QueryAccountDataResponse) error
	QueryAccountByLocalpart(ctx context.Context, req *QueryAccountByLocalpartRequest, res *QueryAccountByLocalpartResponse) (err error)
}

type SyncKeyAPI

type SyncKeyAPI interface {
	QueryKeyChanges(ctx context.Context, req *QueryKeyChangesRequest, res *QueryKeyChangesResponse) error
	QueryOneTimeKeys(ctx context.Context, req *QueryOneTimeKeysRequest, res *QueryOneTimeKeysResponse) error
	PerformMarkAsStaleIfNeeded(ctx context.Context, req *PerformMarkAsStaleRequest, res *struct{}) error
}

API functions required by the syncapi

type SyncUserAPI

api functions required by the sync api

type UploadDeviceKeysAPI

type UploadDeviceKeysAPI interface {
	PerformUploadDeviceKeys(ctx context.Context, req *PerformUploadDeviceKeysRequest, res *PerformUploadDeviceKeysResponse)
}

type UserInfo

type UserInfo struct {
	Sub string // The Matrix user's ID who generated the token
}

UserInfo is for returning information about the user an OpenID token was issued for

type UserInternalAPI

type UserInternalAPI interface {
	SyncUserAPI
	ClientUserAPI
	FederationUserAPI

	QuerySearchProfilesAPI // used by p2p demos
	QueryAccountByLocalpart(ctx context.Context, req *QueryAccountByLocalpartRequest, res *QueryAccountByLocalpartResponse) (err error)
}

UserInternalAPI is the internal API for information about users and devices.

type UserLoginAPI

type UserLoginAPI interface {
	QueryAccountByPassword(ctx context.Context, req *QueryAccountByPasswordRequest, res *QueryAccountByPasswordResponse) error
}

Jump to

Keyboard shortcuts

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