xeapi

package
v1.1.15 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPublicKeyMissing = errors.New("xeapi public key is missing")
	ErrSessionKeyLength = errors.New("xeapi session key length is invalid")
)

Functions

func DecryptResponse

func DecryptResponse(body []byte) ([]byte, error)

func Encrypt

func Encrypt(req EncryptRequest, publicKey PublicKeyState, session Session) (map[string]string, error)

func Sign

func Sign(timestamp, nonce string) string

Types

type EncryptRequest

type EncryptRequest struct {
	URI         string
	Data        interface{}
	Method      string
	ContentType string
	OS          string
	AppVersion  string
	DeviceID    string
	UserAgent   string
}

type HTTPDoer

type HTTPDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

type KeyClient

type KeyClient struct {
	HTTPClient HTTPDoer
	APIDomain  string
}

func (*KeyClient) PublicKey

func (c *KeyClient) PublicKey(ctx context.Context, req keyRefreshRequest) (PublicKeyState, error)

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager(opts ManagerOptions) *Manager

func (*Manager) Encrypt

func (m *Manager) Encrypt(ctx context.Context, req EncryptRequest) (map[string]string, error)

func (*Manager) SetSession

func (m *Manager) SetSession(id, key string)

type ManagerOptions

type ManagerOptions struct {
	HTTPClient HTTPDoer
	APIDomain  string
}

type PublicKeyState

type PublicKeyState struct {
	PublicKey      string `json:"publicKey"`
	Version        string `json:"version"`
	NextUpdateTime int64  `json:"nextUpdateTime"`
	SK             string `json:"sk"`
	DeviceID       string `json:"deviceId,omitempty"`
}

func DecryptPublicKey

func DecryptPublicKey(encryptedData string) (PublicKeyState, error)

type Session

type Session struct {
	ID  string
	Key string
}

Jump to

Keyboard shortcuts

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