secure privkey

This commit is contained in:
Ren Amamiya
2023-07-09 16:55:25 +07:00
parent a5c2ec080a
commit cba94ab99e
20 changed files with 1011 additions and 499 deletions

View File

@@ -3,10 +3,12 @@ import { NDKEvent, NDKKind, NDKPrivateKeySigner } from '@nostr-dev-kit/ndk';
import { useNDK } from '@libs/ndk/provider';
import { useAccount } from '@utils/hooks/useAccount';
import { useSecureStorage } from '@utils/hooks/useSecureStorage';
export function usePublish() {
const { ndk } = useNDK();
const { account } = useAccount();
const { load } = useSecureStorage();
const publish = async ({
content,
@@ -17,8 +19,10 @@ export function usePublish() {
kind: NDKKind;
tags: string[][];
}): Promise<NDKEvent> => {
const privkey = await load(account.pubkey);
const event = new NDKEvent(ndk);
const signer = new NDKPrivateKeySigner(account.privkey);
const signer = new NDKPrivateKeySigner(privkey);
event.content = content;
event.kind = kind;