-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
global.d.ts
66 lines (57 loc) · 1.62 KB
/
global.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
interface Window {
nostr: Nostr;
webln: WebLN;
}
interface Nip04 {
encrypt(pubkey: string, plaintext: string): Promise<string>;
decrypt(pubkey, ciphertext): Promise<string>;
}
// https://github.com/nostr-protocol/nips/blob/master/07.md
interface Nostr {
getPublicKey(): Promise<string>;
signEvent(event: unknown): Promise<unknown>;
getRelays(): Promise<Record<string, { read: boolean; write: boolean }>>;
nip04: Nip04;
}
interface GetInfoResponse {
node: {
alias: string;
pubkey: string;
color?: string;
};
// Not supported by all connectors (see webln.request for more info)
methods: string[];
}
interface KeysendArgs {
destination: string;
amount: string | number;
customRecords?: Record<string, string>;
}
interface SendPaymentResponse {
preimage: string;
paymentHash: string;
}
interface RequestInvoiceArgs {
amount?: string | number;
defaultAmount?: string | number;
minimumAmount?: string | number;
maximumAmount?: string | number;
defaultMemo?: string;
}
interface SignMessageResponse {
message: string;
signature: string;
}
// https://www.webln.guide/introduction/readme
interface WebLN {
enable(): Promise<void>;
getInfo(): Promise<GetInfoResponse>;
keysend(args: KeysendArgs): Promise<SendPaymentResponse>;
makeInvoice(args: RequestInvoiceArgs): Promise<RequestInvoiceResponse>;
sendPayment(paymentRequest: string): Promise<SendPaymentResponse>;
signMessage(message: string): Promise<SignMessageResponse>;
// request(method: string, params: Object): RequestResponse;
// lnurl(lnurl: string): LNURLResponse;
}
declare const webln: WebLN;
declare const nostr: Nostr;