api

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectRelayHandler added in v0.4.1

func ConnectRelayHandler(w http.ResponseWriter, r *http.Request)

ConnectRelayHandler handles requests to connect to a new relay

func ConvertNpubHandler added in v0.4.1

func ConvertNpubHandler(w http.ResponseWriter, r *http.Request)

ConvertNpubHandler converts npub to hex pubkey format

func ConvertPubkeyHandler added in v0.4.1

func ConvertPubkeyHandler(w http.ResponseWriter, r *http.Request)

ConvertPubkeyHandler converts hex pubkey to npub format

func DisconnectRelayHandler added in v0.4.1

func DisconnectRelayHandler(w http.ResponseWriter, r *http.Request)

DisconnectRelayHandler handles requests to disconnect from a relay

func GenerateKeypairHandler added in v0.4.1

func GenerateKeypairHandler(w http.ResponseWriter, r *http.Request)

GenerateKeypairHandler generates a new random Nostr key pair

func GetCacheHandler added in v0.4.1

func GetCacheHandler(w http.ResponseWriter, r *http.Request)

GetCacheHandler returns the cached user data as JSON Automatically refreshes cache if expired or missing

func GetRelayStatusHandler added in v0.4.1

func GetRelayStatusHandler(w http.ResponseWriter, r *http.Request)

GetRelayStatusHandler returns the status of all relay connections

func GetSessionHandler added in v0.4.1

func GetSessionHandler(w http.ResponseWriter, r *http.Request)

GetSessionHandler returns the current user's session data as JSON

func GetUserProfileHandler added in v0.4.1

func GetUserProfileHandler(w http.ResponseWriter, r *http.Request)

GetUserProfileHandler fetches user profile using core client

func GetUserRelaysHandler added in v0.4.1

func GetUserRelaysHandler(w http.ResponseWriter, r *http.Request)

GetUserRelaysHandler fetches user relay list using core client

func HandleAmberCallback added in v0.4.1

func HandleAmberCallback(w http.ResponseWriter, r *http.Request)

HandleAmberCallback processes callbacks from Amber app

func LoginHandler added in v0.4.1

func LoginHandler(w http.ResponseWriter, r *http.Request)

LoginHandler handles user login requests via API Initializes user by fetching mailboxes, setting app relays, getting metadata from outboxes, caching the data, and creating session with appropriate signing capabilities

func LogoutHandler added in v0.4.1

func LogoutHandler(w http.ResponseWriter, r *http.Request)

LogoutHandler handles user logout requests via API

func PublishEventHandler added in v0.4.1

func PublishEventHandler(w http.ResponseWriter, r *http.Request)

PublishEventHandler handles event publishing requests

func QueryEventsHandler added in v0.4.1

func QueryEventsHandler(w http.ResponseWriter, r *http.Request)

QueryEventsHandler handles event querying using core client

func RefreshCacheHandler added in v0.4.1

func RefreshCacheHandler(w http.ResponseWriter, r *http.Request)

RefreshCacheHandler manually refreshes cache for the current user

func RelayPingHandler added in v0.4.1

func RelayPingHandler(w http.ResponseWriter, r *http.Request)

RelayPingHandler pings a relay and returns response time and connection status

func ValidateNpubHandler added in v0.4.1

func ValidateNpubHandler(w http.ResponseWriter, r *http.Request)

ValidateNpubHandler validates npub format and provides pubkey conversion

func ValidatePubkeyHandler added in v0.4.1

func ValidatePubkeyHandler(w http.ResponseWriter, r *http.Request)

ValidatePubkeyHandler validates hex pubkey format and provides npub conversion

Types

type AmberCallbackData added in v0.4.1

type AmberCallbackData struct {
	Event     string `json:"event"`
	PublicKey string `json:"public_key"`
	Error     string `json:"error,omitempty"`
}

AmberCallbackData represents the callback data from Amber

type ConnectRelayRequest added in v0.4.1

type ConnectRelayRequest struct {
	RelayURL string `json:"relayUrl"`
}

ConnectRelayRequest represents a request to connect to a relay

type ConnectRelayResponse added in v0.4.1

type ConnectRelayResponse struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
	Error   string `json:"error,omitempty"`
}

ConnectRelayResponse represents the response from connecting to a relay

type GenerateKeypairResponse added in v0.4.1

type GenerateKeypairResponse struct {
	Success bool           `json:"success"`
	KeyPair *tools.KeyPair `json:"keypair,omitempty"`
	Error   string         `json:"error,omitempty"`
}

GenerateKeypairResponse represents the response structure for key generation

type NpubToPubkeyRequest added in v0.4.1

type NpubToPubkeyRequest struct {
	Npub string `json:"npub"`
}

NpubToPubkeyRequest represents the request structure for npub to pubkey conversion

type NpubToPubkeyResponse added in v0.4.1

type NpubToPubkeyResponse struct {
	Success bool   `json:"success"`
	Npub    string `json:"npub"`
	Pubkey  string `json:"pubkey,omitempty"`
	Error   string `json:"error,omitempty"`
}

NpubToPubkeyResponse represents the response structure for npub to pubkey conversion

type PubkeyToNpubRequest added in v0.4.1

type PubkeyToNpubRequest struct {
	Pubkey string `json:"pubkey"`
}

PubkeyToNpubRequest represents the request structure for pubkey to npub conversion

type PubkeyToNpubResponse added in v0.4.1

type PubkeyToNpubResponse struct {
	Success bool   `json:"success"`
	Pubkey  string `json:"pubkey"`
	Npub    string `json:"npub,omitempty"`
	Error   string `json:"error,omitempty"`
}

PubkeyToNpubResponse represents the response structure for pubkey to npub conversion

type PublishEventRequest added in v0.4.1

type PublishEventRequest struct {
	Kind       int        `json:"kind"`
	Content    string     `json:"content"`
	Tags       [][]string `json:"tags,omitempty"`
	PrivateKey string     `json:"privateKey,omitempty"`
	Relays     []string   `json:"relays,omitempty"`
}

PublishEventRequest represents the request structure for publishing events

type PublishEventResponse added in v0.4.1

type PublishEventResponse struct {
	Success bool                   `json:"success"`
	EventID string                 `json:"eventId,omitempty"`
	Event   *nostr.Event           `json:"event,omitempty"`
	Results []core.BroadcastResult `json:"results"`
	Summary core.BroadcastSummary  `json:"summary"`
	Error   string                 `json:"error,omitempty"`
}

PublishEventResponse represents the response structure for publishing events

type RelayStatusResponse added in v0.4.1

type RelayStatusResponse struct {
	ConnectedRelays []string `json:"connectedRelays"`
	TotalConnected  int      `json:"totalConnected"`
}

RelayStatusResponse represents the status of relay connections

type ValidateNpubRequest added in v0.4.1

type ValidateNpubRequest struct {
	Npub string `json:"npub"`
}

ValidateNpubRequest represents the request structure for npub validation

type ValidateNpubResponse added in v0.4.1

type ValidateNpubResponse struct {
	Success bool   `json:"success"`
	Npub    string `json:"npub"`
	Valid   bool   `json:"valid"`
	Pubkey  string `json:"pubkey,omitempty"`
	Error   string `json:"error,omitempty"`
}

ValidateNpubResponse represents the response structure for npub validation

type ValidatePubkeyRequest added in v0.4.1

type ValidatePubkeyRequest struct {
	Pubkey string `json:"pubkey"`
}

ValidatePubkeyRequest represents the request structure for pubkey validation

type ValidatePubkeyResponse added in v0.4.1

type ValidatePubkeyResponse struct {
	Success bool   `json:"success"`
	Pubkey  string `json:"pubkey"`
	Valid   bool   `json:"valid"`
	Npub    string `json:"npub,omitempty"`
	Error   string `json:"error,omitempty"`
}

ValidatePubkeyResponse represents the response structure for pubkey validation

Jump to

Keyboard shortcuts

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