mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-09-26 03:49:01 +02:00
keyer: move interfaces to toplevel "nostr" package.
This commit is contained in:
20
keyer.go
Normal file
20
keyer.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package nostr
|
||||
|
||||
import "context"
|
||||
|
||||
type Keyer interface {
|
||||
Signer
|
||||
Cipher
|
||||
}
|
||||
|
||||
// A Signer provides basic public key signing methods.
|
||||
type Signer interface {
|
||||
GetPublicKey(context.Context) (string, error)
|
||||
SignEvent(context.Context, *Event) error
|
||||
}
|
||||
|
||||
// A Cipher provides NIP-44 encryption and decryption methods.
|
||||
type Cipher interface {
|
||||
Encrypt(ctx context.Context, plaintext string, recipientPublicKey string) (base64ciphertext string, err error)
|
||||
Decrypt(ctx context.Context, base64ciphertext string, senderPublicKey string) (plaintext string, err error)
|
||||
}
|
25
keyer/deprecated.go
Normal file
25
keyer/deprecated.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package keyer
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/nbd-wtf/go-nostr"
|
||||
)
|
||||
|
||||
// Deprecated: use nostr.Keyer instead
|
||||
type Keyer interface {
|
||||
Signer
|
||||
Cipher
|
||||
}
|
||||
|
||||
// Deprecated: use nostr.Signer instead
|
||||
type Signer interface {
|
||||
GetPublicKey(context.Context) (string, error)
|
||||
SignEvent(context.Context, *nostr.Event) error
|
||||
}
|
||||
|
||||
// Deprecated: use nostr.Cipher instead
|
||||
type Cipher interface {
|
||||
Encrypt(ctx context.Context, plaintext string, recipientPublicKey string) (base64ciphertext string, err error)
|
||||
Decrypt(ctx context.Context, base64ciphertext string, senderPublicKey string) (plaintext string, err error)
|
||||
}
|
24
keyer/lib.go
24
keyer/lib.go
@@ -15,22 +15,12 @@ import (
|
||||
"github.com/puzpuzpuz/xsync/v3"
|
||||
)
|
||||
|
||||
type Keyer interface {
|
||||
Signer
|
||||
Cipher
|
||||
}
|
||||
|
||||
// A Signer provides basic public key signing methods.
|
||||
type Signer interface {
|
||||
GetPublicKey(context.Context) (string, error)
|
||||
SignEvent(context.Context, *nostr.Event) error
|
||||
}
|
||||
|
||||
// A Cipher provides NIP-44 encryption and decryption methods.
|
||||
type Cipher interface {
|
||||
Encrypt(ctx context.Context, plaintext string, recipientPublicKey string) (base64ciphertext string, err error)
|
||||
Decrypt(ctx context.Context, base64ciphertext string, senderPublicKey string) (plaintext string, err error)
|
||||
}
|
||||
var (
|
||||
_ nostr.Keyer = (*BunkerSigner)(nil)
|
||||
_ nostr.Keyer = (*EncryptedKeySigner)(nil)
|
||||
_ nostr.Keyer = (*KeySigner)(nil)
|
||||
_ nostr.Keyer = (*ManualSigner)(nil)
|
||||
)
|
||||
|
||||
type SignerOptions struct {
|
||||
BunkerClientSecretKey string
|
||||
@@ -45,7 +35,7 @@ type SignerOptions struct {
|
||||
Password string
|
||||
}
|
||||
|
||||
func New(ctx context.Context, pool *nostr.SimplePool, input string, opts *SignerOptions) (Keyer, error) {
|
||||
func New(ctx context.Context, pool *nostr.SimplePool, input string, opts *SignerOptions) (nostr.Keyer, error) {
|
||||
if opts == nil {
|
||||
opts = &SignerOptions{}
|
||||
}
|
||||
|
Reference in New Issue
Block a user