api

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2022 License: Apache-2.0 Imports: 6 Imported by: 144

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
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	UserID       string
	Localpart    string
	ServerName   gomatrixserverlib.ServerName
	AppServiceID string
}

Account represents a Matrix account on this home server.

type AccountType

type AccountType int

AccountType is an enum representing the kind of account

type Conflict

type Conflict int

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

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
}

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

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 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 added in v0.5.0

type InternalKeyBackupSession struct {
	KeyBackupSession
	RoomID    string
	SessionID string
}

Internal KeyBackupData for passing to/from the storage layer

type KeyBackupSession added in v0.5.0

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 added in v0.5.0

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

type OpenIDToken added in v0.4.0

type OpenIDToken struct {
	Token       string
	UserID      string
	ExpiresAtMS int64
}

OpenIDToken represents an OpenID token

type OpenIDTokenAttributes added in v0.4.0

type OpenIDTokenAttributes struct {
	UserID      string
	ExpiresAtMS int64
}

OpenIDTokenInfo represents the attributes associated with an issued OpenID token

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.

	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
}

PerformAccountDeactivationRequest is the request for PerformAccountDeactivation

type PerformAccountDeactivationResponse

type PerformAccountDeactivationResponse struct {
	AccountDeactivated bool
}

PerformAccountDeactivationResponse is the response for PerformAccountDeactivation

type PerformDeviceCreationRequest

type PerformDeviceCreationRequest struct {
	Localpart   string
	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
}

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
	Forbidden    bool
}

type PerformKeyBackupRequest added in v0.5.0

type PerformKeyBackupRequest struct {
	UserID       string
	Version      string // optional if modifying a key backup
	AuthData     json.RawMessage
	Algorithm    string
	DeleteBackup bool // if true will delete the backup based on 'Version'.

	// 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 added in v0.5.0

type PerformKeyBackupResponse struct {
	Error    string // set if there was a problem performing the request
	BadInput bool   // if set, the Error was due to bad input (HTTP 400)

	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 added in v0.3.1

type PerformLastSeenUpdateRequest struct {
	UserID     string
	DeviceID   string
	RemoteAddr string
}

PerformLastSeenUpdateRequest is the request for PerformLastSeenUpdate.

type PerformLastSeenUpdateResponse added in v0.3.1

type PerformLastSeenUpdateResponse struct {
}

PerformLastSeenUpdateResponse is the response for PerformLastSeenUpdate.

type PerformOpenIDTokenCreationRequest added in v0.4.0

type PerformOpenIDTokenCreationRequest struct {
	UserID string
}

PerformOpenIDTokenCreationRequest is the request for PerformOpenIDTokenCreation

type PerformOpenIDTokenCreationResponse added in v0.4.0

type PerformOpenIDTokenCreationResponse struct {
	Token OpenIDToken
}

PerformOpenIDTokenCreationResponse is the response for PerformOpenIDTokenCreation

type PerformPasswordUpdateRequest

type PerformPasswordUpdateRequest struct {
	Localpart string // Required: The localpart for this account.
	Password  string // Required: The new password to set.
}

PerformAccountCreationRequest is the request for PerformAccountCreation

type PerformPasswordUpdateResponse

type PerformPasswordUpdateResponse struct {
	PasswordUpdated bool
	Account         *Account
}

PerformAccountCreationResponse is the response for PerformAccountCreation

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 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 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 added in v0.5.0

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 added in v0.5.0

type QueryKeyBackupResponse struct {
	Error  string
	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 QueryOpenIDTokenRequest added in v0.4.0

type QueryOpenIDTokenRequest struct {
	Token string
}

QueryOpenIDTokenRequest is the request for QueryOpenIDToken

type QueryOpenIDTokenResponse added in v0.4.0

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

QueryOpenIDTokenResponse is the response for QueryOpenIDToken

type QueryProfileRequest

type QueryProfileRequest struct {
	// The user ID to query
	UserID string
}

QueryProfileRequest is the request for QueryProfile

type QueryProfileResponse

type QueryProfileResponse struct {
	// True if the user exists. Querying for a profile does not create them.
	UserExists bool
	// The current display name if set.
	DisplayName string
	// The current avatar URL if set.
	AvatarURL string
}

QueryProfileResponse is the response for QueryProfile

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 UserInfo added in v0.4.0

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 {
	InputAccountData(ctx context.Context, req *InputAccountDataRequest, res *InputAccountDataResponse) error
	PerformAccountCreation(ctx context.Context, req *PerformAccountCreationRequest, res *PerformAccountCreationResponse) error
	PerformPasswordUpdate(ctx context.Context, req *PerformPasswordUpdateRequest, res *PerformPasswordUpdateResponse) error
	PerformDeviceCreation(ctx context.Context, req *PerformDeviceCreationRequest, res *PerformDeviceCreationResponse) error
	PerformDeviceDeletion(ctx context.Context, req *PerformDeviceDeletionRequest, res *PerformDeviceDeletionResponse) error
	PerformLastSeenUpdate(ctx context.Context, req *PerformLastSeenUpdateRequest, res *PerformLastSeenUpdateResponse) error
	PerformDeviceUpdate(ctx context.Context, req *PerformDeviceUpdateRequest, res *PerformDeviceUpdateResponse) error
	PerformAccountDeactivation(ctx context.Context, req *PerformAccountDeactivationRequest, res *PerformAccountDeactivationResponse) error
	PerformOpenIDTokenCreation(ctx context.Context, req *PerformOpenIDTokenCreationRequest, res *PerformOpenIDTokenCreationResponse) error
	PerformKeyBackup(ctx context.Context, req *PerformKeyBackupRequest, res *PerformKeyBackupResponse) error
	QueryKeyBackup(ctx context.Context, req *QueryKeyBackupRequest, res *QueryKeyBackupResponse)
	QueryProfile(ctx context.Context, req *QueryProfileRequest, res *QueryProfileResponse) error
	QueryAccessToken(ctx context.Context, req *QueryAccessTokenRequest, res *QueryAccessTokenResponse) error
	QueryDevices(ctx context.Context, req *QueryDevicesRequest, res *QueryDevicesResponse) error
	QueryAccountData(ctx context.Context, req *QueryAccountDataRequest, res *QueryAccountDataResponse) error
	QueryDeviceInfos(ctx context.Context, req *QueryDeviceInfosRequest, res *QueryDeviceInfosResponse) error
	QuerySearchProfiles(ctx context.Context, req *QuerySearchProfilesRequest, res *QuerySearchProfilesResponse) error
	QueryOpenIDToken(ctx context.Context, req *QueryOpenIDTokenRequest, res *QueryOpenIDTokenResponse) error
}

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

type UserInternalAPITrace added in v0.5.0

type UserInternalAPITrace struct {
	Impl UserInternalAPI
}

UserInternalAPITrace wraps a RoomserverInternalAPI and logs the complete request/response/error

func (*UserInternalAPITrace) InputAccountData added in v0.5.0

func (*UserInternalAPITrace) PerformAccountCreation added in v0.5.0

func (*UserInternalAPITrace) PerformAccountDeactivation added in v0.5.0

func (*UserInternalAPITrace) PerformDeviceCreation added in v0.5.0

func (*UserInternalAPITrace) PerformDeviceDeletion added in v0.5.0

func (*UserInternalAPITrace) PerformDeviceUpdate added in v0.5.0

func (*UserInternalAPITrace) PerformKeyBackup added in v0.5.0

func (*UserInternalAPITrace) PerformLastSeenUpdate added in v0.5.0

func (*UserInternalAPITrace) PerformOpenIDTokenCreation added in v0.5.0

func (*UserInternalAPITrace) PerformPasswordUpdate added in v0.5.0

func (*UserInternalAPITrace) QueryAccessToken added in v0.5.0

func (*UserInternalAPITrace) QueryAccountData added in v0.5.0

func (*UserInternalAPITrace) QueryDeviceInfos added in v0.5.0

func (*UserInternalAPITrace) QueryDevices added in v0.5.0

func (*UserInternalAPITrace) QueryKeyBackup added in v0.5.0

func (*UserInternalAPITrace) QueryOpenIDToken added in v0.5.0

func (*UserInternalAPITrace) QueryProfile added in v0.5.0

func (*UserInternalAPITrace) QuerySearchProfiles added in v0.5.0

Jump to

Keyboard shortcuts

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