|
|
|
@ -5,8 +5,6 @@ |
|
|
|
import type { NostrEvent } from '../../types/nostr.js'; |
|
|
|
import type { NostrEvent } from '../../types/nostr.js'; |
|
|
|
import { getAnonymousKey } from '../cache/anonymous-key-store.js'; |
|
|
|
import { getAnonymousKey } from '../cache/anonymous-key-store.js'; |
|
|
|
import { signEventWithAnonymous } from './anonymous-signer.js'; |
|
|
|
import { signEventWithAnonymous } from './anonymous-signer.js'; |
|
|
|
import { hasNsecKey, getNcryptsec } from '../cache/nsec-key-store.js'; |
|
|
|
|
|
|
|
import { signEventWithNsec } from './nsec-signer.js'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export type AuthMethod = 'nip07' | 'nsec' | 'anonymous'; |
|
|
|
export type AuthMethod = 'nip07' | 'nsec' | 'anonymous'; |
|
|
|
|
|
|
|
|
|
|
|
@ -335,6 +333,7 @@ class SessionManager { |
|
|
|
// The encrypted key is stored in IndexedDB, and password is in sessionStorage
|
|
|
|
// The encrypted key is stored in IndexedDB, and password is in sessionStorage
|
|
|
|
if (pubkey) { |
|
|
|
if (pubkey) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
const { hasNsecKey } = await import('../cache/nsec-key-store.js'); |
|
|
|
const keyExists = await hasNsecKey(pubkey); |
|
|
|
const keyExists = await hasNsecKey(pubkey); |
|
|
|
if (keyExists) { |
|
|
|
if (keyExists) { |
|
|
|
// Try to get password from sessionStorage
|
|
|
|
// Try to get password from sessionStorage
|
|
|
|
@ -360,6 +359,8 @@ class SessionManager { |
|
|
|
if (!session || !session.password) { |
|
|
|
if (!session || !session.password) { |
|
|
|
throw new Error('Session password not available'); |
|
|
|
throw new Error('Session password not available'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
const { getNcryptsec } = await import('../cache/nsec-key-store.js'); |
|
|
|
|
|
|
|
const { signEventWithNsec } = await import('./nsec-signer.js'); |
|
|
|
const ncryptsec = await getNcryptsec(pubkey); |
|
|
|
const ncryptsec = await getNcryptsec(pubkey); |
|
|
|
if (!ncryptsec) { |
|
|
|
if (!ncryptsec) { |
|
|
|
throw new Error('Stored nsec key not found'); |
|
|
|
throw new Error('Stored nsec key not found'); |
|
|
|
|