nip46

package
v0.30.2 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 15 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BUNKER_REGEX = regexp.MustCompile(`^bunker:\/\/([0-9a-f]{64})\??([?\/\w:.=&%]*)$`)

Functions

func CheckNameAvailability added in v0.29.0

func CheckNameAvailability(ctx context.Context, name, domain string) bool

func IsValidBunkerURL added in v0.29.0

func IsValidBunkerURL(input string) bool

Types

type BunkerClient added in v0.28.4

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

func ConnectBunker added in v0.28.4

func ConnectBunker(
	ctx context.Context,
	clientSecretKey string,
	bunkerURLOrNIP05 string,
	pool *nostr.SimplePool,
	onAuth func(string),
) (*BunkerClient, error)

ConnectBunker establishes an RPC connection to a NIP-46 signer using the relays and secret provided in the bunkerURL. pool can be passed to reuse an existing pool, otherwise a new pool will be created.

func CreateAccount added in v0.29.0

func CreateAccount(
	ctx context.Context,
	clientSecretKey string,
	name string,
	domain string,
	pool *nostr.SimplePool,
	extraOpts *CreateAccountOptions,
	onAuth func(string),
) (*BunkerClient, error)

func NewBunker added in v0.29.0

func NewBunker(
	ctx context.Context,
	clientSecretKey string,
	targetPublicKey string,
	relays []string,
	pool *nostr.SimplePool,
	onAuth func(string),
) *BunkerClient

func (*BunkerClient) GetPublicKey added in v0.28.4

func (bunker *BunkerClient) GetPublicKey(ctx context.Context) (string, error)

func (*BunkerClient) Ping added in v0.28.4

func (bunker *BunkerClient) Ping(ctx context.Context) error

func (*BunkerClient) RPC added in v0.28.4

func (bunker *BunkerClient) RPC(ctx context.Context, method string, params []string) (string, error)

func (*BunkerClient) SignEvent added in v0.28.4

func (bunker *BunkerClient) SignEvent(ctx context.Context, evt *nostr.Event) error

type CreateAccountOptions added in v0.29.0

type CreateAccountOptions struct {
	Email string
}

type DynamicSigner added in v0.28.0

type DynamicSigner struct {
	sync.Mutex

	RelaysToAdvertise map[string]RelayReadWrite
	// contains filtered or unexported fields
}

func NewDynamicSigner added in v0.28.0

func NewDynamicSigner(
	getPrivateKey func(pubkey string) (string, error),
	authorizeSigning func(event nostr.Event) bool,
	onEventSigned func(event nostr.Event),
	authorizeNIP04 func() bool,
) DynamicSigner

func (*DynamicSigner) GetSession added in v0.28.0

func (p *DynamicSigner) GetSession(clientPubkey string) (Session, bool)

func (*DynamicSigner) HandleRequest added in v0.28.0

func (p *DynamicSigner) HandleRequest(event *nostr.Event) (
	req Request,
	resp Response,
	eventResponse nostr.Event,
	err error,
)

type RelayReadWrite added in v0.28.0

type RelayReadWrite struct {
	Read  bool `json:"read"`
	Write bool `json:"write"`
}

type Request

type Request struct {
	ID     string   `json:"id"`
	Method string   `json:"method"`
	Params []string `json:"params"`
}

type Response

type Response struct {
	ID     string `json:"id"`
	Error  string `json:"error,omitempty"`
	Result string `json:"result,omitempty"`
}

type Session

type Session struct {
	SharedKey []byte
}

func (Session) MakeResponse

func (s Session) MakeResponse(
	id string,
	requester string,
	result string,
	err error,
) (resp Response, evt nostr.Event, error error)

func (Session) ParseRequest

func (s Session) ParseRequest(event *nostr.Event) (Request, error)

type Signer

type Signer interface {
	GetSession(clientPubkey string) (Session, bool)
	HandleRequest(event *nostr.Event) (req Request, resp Response, eventResponse nostr.Event, err error)
}

type StaticKeySigner added in v0.28.0

type StaticKeySigner struct {
	sync.Mutex

	RelaysToAdvertise map[string]RelayReadWrite
	AuthorizeRequest  func(harmless bool, from string) bool
	// contains filtered or unexported fields
}

func NewStaticKeySigner added in v0.28.0

func NewStaticKeySigner(secretKey string) StaticKeySigner

func (*StaticKeySigner) GetSession added in v0.28.0

func (p *StaticKeySigner) GetSession(clientPubkey string) (Session, bool)

func (*StaticKeySigner) HandleRequest added in v0.28.0

func (p *StaticKeySigner) HandleRequest(event *nostr.Event) (
	req Request,
	resp Response,
	eventResponse nostr.Event,
	err error,
)

Jump to

Keyboard shortcuts

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