nip07.ts raw
1 export type UnsignedNostrEvent = {
2 kind: number;
3 created_at: number;
4 tags: string[][];
5 content: string;
6 };
7
8 export type SignedNostrEvent = UnsignedNostrEvent & {
9 id: string;
10 pubkey: string;
11 sig: string;
12 };
13
14 export type Nip07Provider = {
15 getPublicKey(): Promise<string>;
16 signEvent(event: UnsignedNostrEvent): Promise<SignedNostrEvent>;
17 };
18
19 declare global {
20 interface Window {
21 nostr?: Nip07Provider;
22 }
23 }
24
25 export function hasNip07Signer(): boolean {
26 return typeof window !== "undefined" && !!window.nostr;
27 }
28