@memetic-block/ao-encrypted-messages
Version:
Send encrypted messages on AO. Like an encrypted voicemail.
87 lines (86 loc) • 2.57 kB
TypeScript
import { createDataItemSigner } from '@permaweb/aoconnect';
import Arweave from 'arweave';
import { WalletLike } from '../util/wallet-like';
export type SpawnEncryptedMessagesOptions = {
module?: string;
scheduler?: string;
tags?: {
name: string;
value: string;
}[];
arweave?: {
host: string;
port: number;
protocol: string;
};
appName?: string;
luaSourceTxId?: string;
};
export type SendAosMessageOptions = {
processId: string;
data?: string;
tags?: {
name: string;
value: string;
}[];
signer: ReturnType<typeof createDataItemSigner>;
};
export type SendEncryptedMessageOptions = {
nonce?: string | Uint8Array;
secretKey?: string | Uint8Array;
};
export type EncryptedMessage = {
message: string;
nonce: string;
publicKey: string;
recipientPublicKey: string;
};
export declare class EncryptedMessages {
readonly processId: string;
private wallet?;
static SCHEDULER_ID: string;
static AOS_MODULE_ID: string;
static PUBLISHED_LUA_TX_ID: string;
static spawn(wallet: WalletLike, opts?: SpawnEncryptedMessagesOptions): Promise<EncryptedMessages>;
static sendAosMessage({ processId, data, tags, signer }: SendAosMessageOptions, retries?: number): Promise<{
messageId: string;
result: import("@permaweb/aoconnect/dist/lib/result").MessageResult;
}>;
lastSeenEncryptionPublicKey?: string;
private arweave;
constructor(processId: string, wallet?: WalletLike, arweave?: Arweave);
setWallet(wallet: WalletLike): void;
getEncryptionPublicKey(tags?: {
name: string;
value: string;
}[]): Promise<{
messageId: string;
result: import("@permaweb/aoconnect/dist/lib/result").MessageResult;
publicKey: any;
}>;
setEncryptionPublicKey(encryptionPublicKey?: string, tags?: {
name: string;
value: string;
}[]): Promise<{
publicKey: string;
secretKey?: string;
messageId: string;
}>;
sendEncryptedMessage(message: string, opts?: SendEncryptedMessageOptions, tags?: {
name: string;
value: string;
}[]): Promise<{
messageId: string;
nonce: string;
}>;
listEncryptedMessages(tags?: {
name: string;
value: string;
}[]): Promise<{
messageId: string;
messages: {
[nonce: string]: string;
};
}>;
getEncryptedMessage(messageId: string, secretKey?: string): Promise<EncryptedMessage>;
}