mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-11-18 01:56:30 +01:00
docstrings for many functions.
This commit is contained in:
@@ -6,28 +6,40 @@ import (
|
||||
"github.com/nbd-wtf/go-nostr"
|
||||
)
|
||||
|
||||
// ManualSigner is a signer that doesn't really do anything, it just calls the functions given to it.
|
||||
// It can be used when an app for some reason wants to ask the user to manually provide a signed event
|
||||
// by copy-and-paste, for example.
|
||||
// ManualSigner is a signer that delegates all operations to user-provided functions.
|
||||
// It can be used when an app wants to ask the user or some custom server to manually provide a
|
||||
// signed event or an encrypted or decrypted payload by copy-and-paste, for example, or when the
|
||||
// app wants to implement custom signing logic.
|
||||
type ManualSigner struct {
|
||||
// ManualGetPublicKey is called when the public key is needed
|
||||
ManualGetPublicKey func(context.Context) (string, error)
|
||||
ManualSignEvent func(context.Context, *nostr.Event) error
|
||||
ManualEncrypt func(ctx context.Context, plaintext string, recipientPublicKey string) (base64ciphertext string, err error)
|
||||
ManualDecrypt func(ctx context.Context, base64ciphertext string, senderPublicKey string) (plaintext string, err error)
|
||||
|
||||
// ManualSignEvent is called when an event needs to be signed
|
||||
ManualSignEvent func(context.Context, *nostr.Event) error
|
||||
|
||||
// ManualEncrypt is called when a message needs to be encrypted
|
||||
ManualEncrypt func(ctx context.Context, plaintext string, recipientPublicKey string) (base64ciphertext string, err error)
|
||||
|
||||
// ManualDecrypt is called when a message needs to be decrypted
|
||||
ManualDecrypt func(ctx context.Context, base64ciphertext string, senderPublicKey string) (plaintext string, err error)
|
||||
}
|
||||
|
||||
// SignEvent delegates event signing to the ManualSignEvent function.
|
||||
func (ms ManualSigner) SignEvent(ctx context.Context, evt *nostr.Event) error {
|
||||
return ms.ManualSignEvent(ctx, evt)
|
||||
}
|
||||
|
||||
// GetPublicKey delegates public key retrieval to the ManualGetPublicKey function.
|
||||
func (ms ManualSigner) GetPublicKey(ctx context.Context) (string, error) {
|
||||
return ms.ManualGetPublicKey(ctx)
|
||||
}
|
||||
|
||||
// Encrypt delegates encryption to the ManualEncrypt function.
|
||||
func (ms ManualSigner) Encrypt(ctx context.Context, plaintext string, recipient string) (c64 string, err error) {
|
||||
return ms.ManualEncrypt(ctx, plaintext, recipient)
|
||||
}
|
||||
|
||||
// Decrypt delegates decryption to the ManualDecrypt function.
|
||||
func (ms ManualSigner) Decrypt(ctx context.Context, base64ciphertext string, sender string) (plaintext string, err error) {
|
||||
return ms.ManualDecrypt(ctx, base64ciphertext, sender)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user