Signers of events with the listener's Nostr key: a key that the app holds, a browser extension of NIP-07, and a remote signer of NIP-46.
A signer is a map of two functions, each of which gives a value, or in ClojureScript a promise of one:
Sign with sign!, which checks that a signer signed what it was given. A secret key is a hidden text of dk.simongray.wary-fetch.secret, so it doesn't show in a log or at a REPL.
Signers of events with the listener's Nostr key: a key that the app holds, a browser extension of NIP-07, and a remote signer of NIP-46. A signer is a map of two functions, each of which gives a value, or in ClojureScript a promise of one: - :public-key-fn, of no arguments, which gives the public key in hexadecimal, or a map with a diagnostic under :error - :sign-fn, of an event of NIP-01 without its id, public key and signature, which gives the signed event, or a map with a diagnostic under :error Sign with sign!, which checks that a signer signed what it was given. A secret key is a hidden text of dk.simongray.wary-fetch.secret, so it doesn't show in a log or at a REPL.
(answer {:keys [remote-signer client-key] :as connection} event id)What the event of the remote signer of connection answers to the
request id: a map of the :result, which is a text, or a map with a
diagnostic under :error. It's nil for the answer to another request.
A signer that wants the listener to approve the request on a web page first answers with :nostr/signer-approval and the :url of the page.
What the `event` of the remote signer of `connection` answers to the request `id`: a map of the :result, which is a text, or a map with a diagnostic under :error. It's nil for the answer to another request. A signer that wants the listener to approve the request on a web page first answers with :nostr/signer-approval and the :url of the page.
(ask! connection method params)(ask! {:keys [remote-signer relays client-key] :as connection}
method
params
opts)Ask the remote signer of connection to do method with the texts
params, with opts, and give its answer, a map of the :result, or a
map with a diagnostic under :error. On the JVM it gives the answer, and
in ClojureScript a promise of it.
(ask! connection "get_public_key" [])
;; => {:result "3bf0…"}
The request goes to the first relay of the connection, and to the next
only when a relay didn't take it. The opts are these:
Ask the remote signer of `connection` to do `method` with the texts
`params`, with `opts`, and give its answer, a map of the :result, or a
map with a diagnostic under :error. On the JVM it gives the answer, and
in ClojureScript a promise of it.
(ask! connection "get_public_key" [])
;; => {:result "3bf0…"}
The request goes to the first relay of the connection, and to the next
only when a relay didn't take it. The `opts` are these:
- :timeout-seconds, in place of that of default-limits
- :send, a function that sends a request map to a relay, in place of
nostr/send!
- :allow-pred, a predicate of the URL of a relay, nostr/public? by
default
- :now-fn, a function that gives the instant of now, the clock by default
- :random-fn, a function that gives a number of random bytes, from a
secure source by default(connect! connection)(connect! {:keys [remote-signer] :as connection} {:keys [perms] :as opts})Connect to the remote signer of connection with opts, and give the
public key of the listener as :public-key, or a map with a diagnostic
under :error. On the JVM it gives the key, and in ClojureScript a
promise of it.
The request has the :secret of the connection, and the :perms of
opts, the permissions that the app asks for, e.g.
"sign_event:1111,sign_event:7". The other opts are those of ask!.
Connect to the remote signer of `connection` with `opts`, and give the public key of the listener as :public-key, or a map with a diagnostic under :error. On the JVM it gives the key, and in ClojureScript a promise of it. The request has the :secret of the connection, and the :perms of `opts`, the permissions that the app asks for, e.g. "sign_event:1111,sign_event:7". The other `opts` are those of ask!.
The limits of a request to a remote signer that its options don't set. A remote signer can ask the listener first, so it has :timeout-seconds to answer.
The limits of a request to a remote signer that its options don't set. A remote signer can ask the listener first, so it has :timeout-seconds to answer.
(generate-key!)Generate a new secret key, from the generator of the platform for keys, as a hidden text.
Generate a new secret key, from the generator of the platform for keys, as a hidden text.
The kind of the events of NIP-46, of the requests and of the answers.
The kind of the events of NIP-46, of the requests and of the answers.
(local secret-key)(local secret-key
{:keys [random-fn] :or {random-fn webcrypto/random-bytes} :as opts})A signer over the hidden secret-key, which signs on the device, with
the opts below. It throws for a text that isn't a secret key.
A signer over the hidden `secret-key`, which signs on the device, with the `opts` below. It throws for a text that isn't a secret key. - :random-fn, a function that gives a number of random bytes, for the aux of each signature of BIP-340, from a secure source by default
(nip07)(nip07 {:keys [provider] :as opts})A signer over the provider of NIP-07 that a browser extension gives
the page as window.nostr, or the :provider of opts, or nil when the
page has none. The extension asks the listener, and signs with a key
that the page never sees.
A signer over the provider of NIP-07 that a browser extension gives the page as window.nostr, or the :provider of `opts`, or nil when the page has none. The extension asks the listener, and signs with a key that the page never sees.
(nsec secret-key)The name nsec1… of NIP-19 of the hidden secret-key, as a hidden text,
for the listener to keep, or to take to another app.
The name nsec1… of NIP-19 of the hidden `secret-key`, as a hidden text, for the listener to keep, or to take to another app.
(parse uri)The connection that the bunker:// URI uri of NIP-46 names, or nil for
another text.
{:remote-signer "fa98…" ; the public key of the signer
:relays ["wss://relay.example"]
:secret #<secret>} ; for the first connect, if any
Add the hidden secret key of the app as :client-key, e.g. from generate-key!, and keep it, since the remote signer knows the app by its public key. The secret of the URI works for one connect only.
The connection that the bunker:// URI `uri` of NIP-46 names, or nil for
another text.
{:remote-signer "fa98…" ; the public key of the signer
:relays ["wss://relay.example"]
:secret #<secret>} ; for the first connect, if any
Add the hidden secret key of the app as :client-key, e.g. from
generate-key!, and keep it, since the remote signer knows the app by
its public key. The secret of the URI works for one connect only.(public-key secret-key)The public key of the hidden secret-key, in hexadecimal, or nil when
it isn't a secret key.
The public key of the hidden `secret-key`, in hexadecimal, or nil when it isn't a secret key.
(remote connection)(remote connection {:keys [public-key] :as opts})A signer over the remote signer of connection, with the opts of
ask!. The :public-key of opts is the listener's, as connect! gave it,
so that no request asks for it again.
A signer over the remote signer of `connection`, with the `opts` of ask!. The :public-key of `opts` is the listener's, as connect! gave it, so that no request asks for it again.
(request-event {:keys [remote-signer client-key] :as connection}
method
params
{:keys [id at nonce aux] :as opts})The event that asks the remote signer of connection to do method
with the texts params, made from opts, or nil for a request with
more bytes than a payload of NIP-44 holds.
It's a signed event of the kind 24133 from the :client-key, with the
request encrypted for the remote signer. The opts have what makes the
event, since nothing here reads a clock or makes random bytes:
The event that asks the remote signer of `connection` to do `method` with the texts `params`, made from `opts`, or nil for a request with more bytes than a payload of NIP-44 holds. It's a signed event of the kind 24133 from the :client-key, with the request encrypted for the remote signer. The `opts` have what makes the event, since nothing here reads a clock or makes random bytes: - :id, the id of the request, which its answer names - :at, the instant of the request - :nonce, hexadecimal text of 32 random bytes, for the encryption - :aux, the same for the signature
(secret-key s)The secret key that the text s names, as a hidden text, or nil for
another text. The text is nsec1… of NIP-19 or hexadecimal text of 32
bytes, and it can be hidden itself.
The secret key that the text `s` names, as a hidden text, or nil for another text. The text is nsec1… of NIP-19 or hexadecimal text of 32 bytes, and it can be hidden itself.
(sign! {:keys [sign-fn] :as signer} event)Sign event with signer, and give the signed event, or a map with a
diagnostic under :error. On the JVM it gives the event, and in
ClojureScript a promise of it.
The signed event must verify, and have the kind, the time, the tags and
the content of event, so that a signer can't sign another event in
its place.
Sign `event` with `signer`, and give the signed event, or a map with a diagnostic under :error. On the JVM it gives the event, and in ClojureScript a promise of it. The signed event must verify, and have the kind, the time, the tags and the content of `event`, so that a signer can't sign another event in its place.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |