Cache all the things

This commit is contained in:
2023-09-05 14:57:50 +01:00
parent 5521f685fc
commit b1459d0f49
49 changed files with 805 additions and 243 deletions

View File

@ -7,6 +7,8 @@ import { MessageEncryptorPayload, MessageEncryptorVersion } from "./index";
import { NostrEvent } from "./nostr";
import { base64 } from "@scure/base";
export type SignerSupports = "nip04" | "nip44" | string;
export interface EventSigner {
init(): Promise<void>;
getPubKey(): Promise<string> | string;
@ -15,6 +17,7 @@ export interface EventSigner {
nip44Encrypt(content: string, key: string): Promise<string>;
nip44Decrypt(content: string, otherKey: string): Promise<string>;
sign(ev: NostrEvent): Promise<NostrEvent>;
get supports(): Array<SignerSupports>;
}
export class PrivateKeySigner implements EventSigner {
@ -30,6 +33,10 @@ export class PrivateKeySigner implements EventSigner {
this.#publicKey = getPublicKey(this.#privateKey);
}
get supports(): string[] {
return ["nip04", "nip44"]
}
get privateKey() {
return this.#privateKey;
}