Browse Source

get rid of dynamic imports

master
Silberengel 1 month ago
parent
commit
e4e1e24b1c
  1. 4
      public/healthz.json
  2. 6
      src/lib/services/mentions.ts
  3. 8
      src/lib/services/nostr/auth-handler.ts

4
public/healthz.json

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
"status": "ok",
"service": "aitherboard",
"version": "0.2.0",
"buildTime": "2026-02-07T06:18:18.476Z",
"buildTime": "2026-02-07T06:20:23.861Z",
"gitCommit": "unknown",
"timestamp": 1770445098476
"timestamp": 1770445223861
}

6
src/lib/services/mentions.ts

@ -3,12 +3,12 @@ @@ -3,12 +3,12 @@
* Extracts @mentions from content and converts them to p tags
*/
import { getProfileByPubkey } from './profile-search.js';
import { getProfileByPubkey, searchProfiles } from './profile-search.js';
import { nip19 } from 'nostr-tools';
import { nostrClient } from './nostr/nostr-client.js';
import { relayManager } from './nostr/relay-manager.js';
import { cacheProfile } from './cache/profile-cache.js';
import { parseProfile } from './user-data.js';
import { parseProfile, fetchProfile } from './user-data.js';
import { KIND } from '../types/kind-lookup.js';
import type { NostrEvent } from '../types/nostr.js';
@ -94,8 +94,6 @@ export async function extractMentions(content: string): Promise<MentionInfo[]> { @@ -94,8 +94,6 @@ export async function extractMentions(content: string): Promise<MentionInfo[]> {
async function findProfileByHandle(handle: string): Promise<{ pubkey: string; handle?: string } | null> {
// Search through cached profiles for matching handle
try {
const { searchProfiles } = await import('./profile-search.js');
const { fetchProfile } = await import('./user-data.js');
const results = await searchProfiles(handle, 20); // Get more results to find exact matches
const searchHandle = handle.toLowerCase();

8
src/lib/services/nostr/auth-handler.ts

@ -6,9 +6,10 @@ import { getNIP07Signer, signEventWithNIP07, getPublicKeyWithNIP07 } from '../au @@ -6,9 +6,10 @@ import { getNIP07Signer, signEventWithNIP07, getPublicKeyWithNIP07 } from '../au
import { signEventWithNsec, getPublicKeyFromNsec } from '../auth/nsec-signer.js';
import {
signEventWithAnonymous,
generateAnonymousKey
generateAnonymousKey,
getStoredAnonymousKey
} from '../auth/anonymous-signer.js';
import { decryptPrivateKey } from '../security/key-management.js';
import { decryptPrivateKey, encryptPrivateKey } from '../security/key-management.js';
import { sessionManager, type AuthMethod } from '../auth/session-manager.js';
import { fetchRelayLists, fetchProfile } from '../user-data.js';
import { nostrClient } from './nostr-client.js';
@ -158,13 +159,11 @@ export async function authenticateWithNsec( @@ -158,13 +159,11 @@ export async function authenticateWithNsec(
throw new Error('Stored nsec key not found');
}
// Verify the decrypted nsec matches the expected pubkey
const { getPublicKeyFromNsec } = await import('../auth/nsec-signer.js');
const derivedPubkey = await getPublicKeyFromNsec(decryptedNsec);
if (derivedPubkey !== pubkey) {
throw new Error('Stored nsec key does not match the expected pubkey - key may be corrupted');
}
// Encrypt to ncryptsec format for signing
const { encryptPrivateKey } = await import('../security/key-management.js');
const ncryptsec = await encryptPrivateKey(decryptedNsec, session.password);
return signEventWithNsec(event, ncryptsec, session.password);
} catch (error) {
@ -201,7 +200,6 @@ export async function authenticateWithStoredAnonymous( @@ -201,7 +200,6 @@ export async function authenticateWithStoredAnonymous(
password: string
): Promise<string> {
// Verify the key exists and password is correct by trying to decrypt
const { getStoredAnonymousKey } = await import('../auth/anonymous-signer.js');
const decryptedNsec = await getStoredAnonymousKey(pubkey, password);
if (!decryptedNsec) {
throw new Error('Invalid password or key not found');

Loading…
Cancel
Save