mirror of https://github.com/fiatjaf/nak.git
accept bunker URIs in $NOSTR_SECRET_KEY, simplify.
fixes https://github.com/fiatjaf/nak/issues/66
This commit is contained in:
parent
4387595437
commit
aa89093d57
|
@ -20,10 +20,12 @@ import (
|
||||||
var defaultKeyFlags = []cli.Flag{
|
var defaultKeyFlags = []cli.Flag{
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "sec",
|
Name: "sec",
|
||||||
Usage: "secret key to sign the event, as nsec, ncryptsec or hex, or a bunker URL, it is more secure to use the environment variable NOSTR_SECRET_KEY than this flag",
|
Usage: "secret key to sign the event, as nsec, ncryptsec or hex, or a bunker URL",
|
||||||
DefaultText: "the key '1'",
|
DefaultText: "the key '1'",
|
||||||
Aliases: []string{"connect"},
|
|
||||||
Category: CATEGORY_SIGNER,
|
Category: CATEGORY_SIGNER,
|
||||||
|
Sources: cli.EnvVars("NOSTR_SECRET_KEY"),
|
||||||
|
Value: nostr.KeyOne.Hex(),
|
||||||
|
HideDefault: true,
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "prompt-sec",
|
Name: "prompt-sec",
|
||||||
|
@ -80,15 +82,6 @@ func gatherSecretKeyOrBunkerFromArguments(ctx context.Context, c *cli.Command) (
|
||||||
return nostr.SecretKey{}, bunker, err
|
return nostr.SecretKey{}, bunker, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// take private from flags, environment variable or default to 1
|
|
||||||
if sec == "" {
|
|
||||||
if key, ok := os.LookupEnv("NOSTR_SECRET_KEY"); ok {
|
|
||||||
sec = key
|
|
||||||
} else {
|
|
||||||
sec = "0000000000000000000000000000000000000000000000000000000000000001"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if c.Bool("prompt-sec") {
|
if c.Bool("prompt-sec") {
|
||||||
var err error
|
var err error
|
||||||
sec, err = askPassword("type your secret key as ncryptsec, nsec or hex: ", nil)
|
sec, err = askPassword("type your secret key as ncryptsec, nsec or hex: ", nil)
|
||||||
|
|
10
mcp.go
10
mcp.go
|
@ -3,7 +3,6 @@ package main
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"fiatjaf.com/nostr"
|
"fiatjaf.com/nostr"
|
||||||
|
@ -28,13 +27,10 @@ var mcpServer = &cli.Command{
|
||||||
version,
|
version,
|
||||||
)
|
)
|
||||||
|
|
||||||
keyer, sk, err := gatherKeyerFromArguments(ctx, c)
|
keyer, _, err := gatherKeyerFromArguments(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if sk == nostr.KeyOne && !c.IsSet("sec") {
|
|
||||||
keyer = nil
|
|
||||||
}
|
|
||||||
|
|
||||||
s.AddTool(mcp.NewTool("publish_note",
|
s.AddTool(mcp.NewTool("publish_note",
|
||||||
mcp.WithDescription("Publish a short note event to Nostr with the given text content"),
|
mcp.WithDescription("Publish a short note event to Nostr with the given text content"),
|
||||||
|
@ -46,10 +42,6 @@ var mcpServer = &cli.Command{
|
||||||
mention, _ := optional[string](r, "mention")
|
mention, _ := optional[string](r, "mention")
|
||||||
relay, _ := optional[string](r, "relay")
|
relay, _ := optional[string](r, "relay")
|
||||||
|
|
||||||
sk := os.Getenv("NOSTR_SECRET_KEY")
|
|
||||||
if sk == "" {
|
|
||||||
sk = "0000000000000000000000000000000000000000000000000000000000000001"
|
|
||||||
}
|
|
||||||
var relays []string
|
var relays []string
|
||||||
|
|
||||||
evt := nostr.Event{
|
evt := nostr.Event{
|
||||||
|
|
Loading…
Reference in New Issue