feat: script to generate an nsec
This fixes: https://gitlab.com/soapbox-pub/ditto/-/issues/85
This commit is contained in:
parent
2ff96d2403
commit
90e110b1fd
|
@ -7,7 +7,8 @@
|
|||
"debug": "deno run -A --unstable-ffi --inspect src/server.ts",
|
||||
"test": "DB_PATH=\":memory:\" deno test -A --unstable-ffi",
|
||||
"check": "deno check src/server.ts",
|
||||
"relays:sync": "deno run -A --unstable-ffi scripts/relays.ts sync"
|
||||
"relays:sync": "deno run -A --unstable-ffi scripts/relays.ts sync",
|
||||
"nsec": "deno run -A --unstable-ffi scripts/nsec.ts"
|
||||
},
|
||||
"exclude": ["./public"],
|
||||
"imports": { "@/": "./src/", "@soapbox/nspec": "jsr:@soapbox/nspec@^0.8.1", "~/fixtures/": "./fixtures/" },
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
import { generateSecretKey, nip19 } from '@/deps.ts';
|
||||
|
||||
switch (Deno.args[0]) {
|
||||
default: {
|
||||
const encodedNsec = generateEncodedPrivateKey();
|
||||
console.log(encodedNsec);
|
||||
Deno.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
function generateEncodedPrivateKey(): string {
|
||||
const sk = generateSecretKey();
|
||||
const nsec = nip19.nsecEncode(sk);
|
||||
|
||||
return nsec;
|
||||
}
|
|
@ -19,6 +19,7 @@ export {
|
|||
nip13,
|
||||
nip19,
|
||||
nip21,
|
||||
generateSecretKey,
|
||||
type UnsignedEvent,
|
||||
type VerifiedEvent,
|
||||
} from 'npm:nostr-tools@^2.3.1';
|
||||
|
|
Loading…
Reference in New Issue