NKeys -> keyring

This commit is contained in:
Alex Gleason 2024-10-30 11:42:10 -05:00
parent ce5a4b9a03
commit 36427f52d7
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
5 changed files with 9 additions and 9 deletions

View File

@ -1,6 +1,6 @@
import { NKeyring } from './NKeyring'; import { NKeyring } from './NKeyring';
export const NKeys = new NKeyring( export const keyring = new NKeyring(
localStorage, localStorage,
'soapbox:nostr:keys', 'soapbox:nostr:keys',
); );

View File

@ -6,7 +6,7 @@ import { logInNostr } from 'soapbox/actions/nostr';
import EmojiGraphic from 'soapbox/components/emoji-graphic'; import EmojiGraphic from 'soapbox/components/emoji-graphic';
import { Button, Stack, Modal, Input, FormGroup, Form, Divider } from 'soapbox/components/ui'; import { Button, Stack, Modal, Input, FormGroup, Form, Divider } from 'soapbox/components/ui';
import { useNostr } from 'soapbox/contexts/nostr-context'; import { useNostr } from 'soapbox/contexts/nostr-context';
import { NKeys } from 'soapbox/features/nostr/keys'; import { keyring } from 'soapbox/features/nostr/keyring';
import { useAppDispatch } from 'soapbox/hooks'; import { useAppDispatch } from 'soapbox/hooks';
import NostrExtensionIndicator from '../components/nostr-extension-indicator'; import NostrExtensionIndicator from '../components/nostr-extension-indicator';
@ -33,7 +33,7 @@ const KeyAddStep: React.FC<IKeyAddStep> = ({ onClose }) => {
const result = nip19.decode(nsec); const result = nip19.decode(nsec);
if (result.type === 'nsec') { if (result.type === 'nsec') {
const seckey = result.data; const seckey = result.data;
const signer = NKeys.add(seckey); const signer = keyring.add(seckey);
dispatch(logInNostr(signer, relay)); dispatch(logInNostr(signer, relay));
onClose(); onClose();
return; return;

View File

@ -8,7 +8,7 @@ import { closeSidebar } from 'soapbox/actions/sidebar';
import EmojiGraphic from 'soapbox/components/emoji-graphic'; import EmojiGraphic from 'soapbox/components/emoji-graphic';
import { Button, Stack, Modal, FormGroup, Text, Tooltip, HStack, Input } from 'soapbox/components/ui'; import { Button, Stack, Modal, FormGroup, Text, Tooltip, HStack, Input } from 'soapbox/components/ui';
import { useNostr } from 'soapbox/contexts/nostr-context'; import { useNostr } from 'soapbox/contexts/nostr-context';
import { NKeys } from 'soapbox/features/nostr/keys'; import { keyring } from 'soapbox/features/nostr/keyring';
import { useAppDispatch, useInstance } from 'soapbox/hooks'; import { useAppDispatch, useInstance } from 'soapbox/hooks';
import { useIsMobile } from 'soapbox/hooks/useIsMobile'; import { useIsMobile } from 'soapbox/hooks/useIsMobile';
import { download } from 'soapbox/utils/download'; import { download } from 'soapbox/utils/download';
@ -45,7 +45,7 @@ const KeygenStep: React.FC<IKeygenStep> = ({ onClose }) => {
const handleNext = async () => { const handleNext = async () => {
if (!relay) return; if (!relay) return;
const signer = NKeys.add(secretKey); const signer = keyring.add(secretKey);
const now = Math.floor(Date.now() / 1000); const now = Math.floor(Date.now() / 1000);
const [kind0, ...events] = await Promise.all([ const [kind0, ...events] = await Promise.all([

View File

@ -2,7 +2,7 @@ import { NSecSigner } from '@nostrify/nostrify';
import { useQuery } from '@tanstack/react-query'; import { useQuery } from '@tanstack/react-query';
import { useMemo } from 'react'; import { useMemo } from 'react';
import { NKeys } from 'soapbox/features/nostr/keys'; import { keyring } from 'soapbox/features/nostr/keyring';
import { useAppSelector } from 'soapbox/hooks'; import { useAppSelector } from 'soapbox/hooks';
import { useBunkerStore } from 'soapbox/hooks/nostr/useBunkerStore'; import { useBunkerStore } from 'soapbox/hooks/nostr/useBunkerStore';
@ -23,7 +23,7 @@ export function useSigner() {
queryFn: async () => { queryFn: async () => {
if (!pubkey) return null; if (!pubkey) return null;
const signer = NKeys.get(pubkey); const signer = keyring.get(pubkey);
if (signer) return signer; if (signer) return signer;
if (window.nostr && await window.nostr.getPublicKey() === pubkey) { if (window.nostr && await window.nostr.getPublicKey() === pubkey) {

View File

@ -2,7 +2,7 @@ import { AxiosError } from 'axios';
import { produce } from 'immer'; import { produce } from 'immer';
import { z } from 'zod'; import { z } from 'zod';
import { NKeys } from 'soapbox/features/nostr/keys'; import { keyring } from 'soapbox/features/nostr/keyring';
import { useBunkerStore } from 'soapbox/hooks/nostr/useBunkerStore'; import { useBunkerStore } from 'soapbox/hooks/nostr/useBunkerStore';
import { Account, accountSchema } from 'soapbox/schemas'; import { Account, accountSchema } from 'soapbox/schemas';
import { Application, applicationSchema } from 'soapbox/schemas/application'; import { Application, applicationSchema } from 'soapbox/schemas/application';
@ -131,7 +131,7 @@ function revokeNostr(accessToken: string): void {
// Revoke the private key, if it exists. // Revoke the private key, if it exists.
if (pubkey) { if (pubkey) {
NKeys.delete(pubkey); keyring.delete(pubkey);
} }
} }