Last active
December 10, 2023 07:28
-
-
Save syusui-s/cd5482ddfc83792b54a756759acbda55 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This code is Public domain (Creative Commons Zero CC0-1.0) | |
// https://creativecommons.org/publicdomain/zero/1.0/deed.ja | |
// from nostr-tools (Public domains) | |
export type NostrEvent = { | |
id?: string; | |
kind: number; | |
tags: string[][]; | |
pubkey: string; | |
content: string; | |
created_at: number; | |
}; | |
type NostrAPI = { | |
/** returns a public key as hex */ | |
getPublicKey(): Promise<string>; | |
/** takes an event object, adds `id`, `pubkey` and `sig` and returns it */ | |
signEvent(event: NostrEvent): Promise<NostrEvent>; | |
// Optional | |
/** returns a basic map of relay urls to relay policies */ | |
getRelays?(): Promise<{ [url: string]: { read: boolean; write: boolean } }>; | |
/** NIP-04: Encrypted Direct Messages */ | |
nip04?: { | |
/** returns ciphertext and iv as specified in nip-04 */ | |
encrypt(pubkey: string, plaintext: string): Promise<string>; | |
/** takes ciphertext and iv as specified in nip-04 */ | |
decrypt(pubkey: string, ciphertext: string): Promise<string>; | |
}; | |
}; | |
declare global { | |
interface Window { | |
nostr?: NostrAPI; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment