feat: NIP-24

This commit is contained in:
2023-08-17 19:54:14 +01:00
parent 8500dee24f
commit f6a46e3523
51 changed files with 792 additions and 319 deletions

View File

@ -19,6 +19,7 @@ export * from "./event-builder";
export * from "./nostr-link";
export * from "./profile-cache";
export * from "./zaps";
export * from "./signer";
export * from "./impl/nip4";
export * from "./impl/nip44";
@ -52,8 +53,19 @@ export interface SystemSnapshot {
}>;
}
export const enum MessageEncryptorVersion {
Nip4 = 0,
XChaCha20 = 1,
}
export interface MessageEncryptorPayload {
ciphertext: Uint8Array,
nonce: Uint8Array,
v: MessageEncryptorVersion
}
export interface MessageEncryptor {
getSharedSecret(privateKey: string, publicKey: string): Promise<Uint8Array> | Uint8Array;
encryptData(plaintext: string, sharedSecet: Uint8Array): Promise<string> | string;
decryptData(cyphertext: string, sharedSecet: Uint8Array): Promise<string> | string;
encryptData(plaintext: string, sharedSecet: Uint8Array): Promise<MessageEncryptorPayload> | MessageEncryptorPayload;
decryptData(payload: MessageEncryptorPayload, sharedSecet: Uint8Array): Promise<string> | string;
}