Skip to content

Commit d627989

Browse files
committed
bot/modules/nostr: decode nostr sk from env. var
Decode nostr secret key from environment variable using hex encoding. Also replace requires with imports.
1 parent 992ca72 commit d627989

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

Diff for: bot/modules/nostr/config.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
const notsrPure = require('nostr-tools/pure');
2-
const { SimplePool } = require('nostr-tools/pool');
1+
import notsrPure from 'nostr-tools';
2+
import { SimplePool } from 'nostr-tools';
33

4-
const sk = process.env.NOSTR_SK || notsrPure.generateSecretKey();
4+
const nostrSkEnvVar = process.env.NOSTR_SK
5+
const sk = nostrSkEnvVar ? Buffer.from(nostrSkEnvVar, 'hex') : notsrPure.generateSecretKey();
56
const pk = notsrPure.getPublicKey(sk);
67

78
export const getPrivateKey = () => sk;

Diff for: bot/modules/nostr/events.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { finalizeEvent, verifyEvent } = require('nostr-tools/pure');
1+
import { finalizeEvent, verifyEvent } from 'nostr-tools';
22
import * as Config from './config';
33

44
import { Community } from '../../../models';

0 commit comments

Comments
 (0)