diff --git a/src/lib/utils/nostrUtils.ts b/src/lib/utils/nostrUtils.ts index e63f9b4..f702d24 100644 --- a/src/lib/utils/nostrUtils.ts +++ b/src/lib/utils/nostrUtils.ts @@ -1,14 +1,12 @@ import { get } from 'svelte/store'; import { nip19 } from 'nostr-tools'; import { ndkInstance } from '$lib/ndk'; +import { npubCache } from './npubCache'; // Regular expressions for Nostr identifiers - match the entire identifier including any prefix export const NOSTR_PROFILE_REGEX = /(?(); - /** * HTML escape a string */ diff --git a/src/lib/utils/npubCache.ts b/src/lib/utils/npubCache.ts new file mode 100644 index 0000000..55bf8cc --- /dev/null +++ b/src/lib/utils/npubCache.ts @@ -0,0 +1,23 @@ +export type NpubMetadata = { name?: string; displayName?: string }; + +class NpubCache { + private cache: Record = {}; + + get(key: string): NpubMetadata | undefined { + return this.cache[key]; + } + + set(key: string, value: NpubMetadata): void { + this.cache[key] = value; + } + + has(key: string): boolean { + return key in this.cache; + } + + getAll(): Record { + return { ...this.cache }; + } +} + +export const npubCache = new NpubCache(); \ No newline at end of file