mirror of
https://github.com/Yonle/bostr.git
synced 2025-10-11 00:52:36 +02:00
introduce nip42 and public/personal usage
Signed-off-by: Yonle <yonle@lecturify.net>
This commit is contained in:
19
nip42.js
Normal file
19
nip42.js
Normal file
@@ -0,0 +1,19 @@
|
||||
const { getEventHash, getSignature } = require("nostr-tools");
|
||||
|
||||
module.exports = (relay, pubkey, privkey, challenge) => {
|
||||
if (!privkey) return;
|
||||
let signed_challenge = {
|
||||
pubkey,
|
||||
created_at: Math.floor(Date.now() / 1000),
|
||||
kind: 22242,
|
||||
tags: [
|
||||
["relay", relay.url],
|
||||
["challenge", challenge]
|
||||
],
|
||||
content: ""
|
||||
}
|
||||
|
||||
signed_challenge.id = getEventHash(signed_challenge);
|
||||
signed_challenge.sig = getSignature(signed_challenge, privkey);
|
||||
relay.send(JSON.stringify(["AUTH", signed_challenge]));
|
||||
}
|
Reference in New Issue
Block a user