Skip to content

Welshman Docs / @welshman/util / Encryptable

Class: Encryptable<T> ​

Defined in: packages/util/src/Encryptable.ts:17

Represents an encryptable event with optional updates.

Type Parameters ​

• T extends EventTemplate

Constructors ​

new Encryptable() ​

new Encryptable<T>(event, updates): Encryptable<T>

Defined in: packages/util/src/Encryptable.ts:30

Creates an instance of Encryptable.

Parameters ​

event ​

Partial<T>

An EventTemplate with optional tags and content.

updates ​

Partial

Plaintext updates to be applied to the event content.

Returns ​

Encryptable<T>

Example ​

Here's an example which enables updating a private mute list:

const event = {kind: 10000, content: "", tags: []} // An event, only kind is required
const encryptable = new Encryptable(event, {content: JSON.stringify([["e", "bad word"]])})
const eventTemplate = await encryptable.reconcile(myEncryptFunction)

Properties ​

event ​

readonly event: Partial<T>

Defined in: packages/util/src/Encryptable.ts:31

An EventTemplate with optional tags and content.


updates ​

readonly updates: Partial

Defined in: packages/util/src/Encryptable.ts:32

Plaintext updates to be applied to the event content.

Methods ​

reconcile() ​

reconcile(encrypt): Promise<T>

Defined in: packages/util/src/Encryptable.ts:40

Encrypts plaintext updates and merges them into the event template.

Parameters ​

encrypt ​

Encrypt

The encryption function to be used.

Returns ​

Promise<T>

A promise that resolves to the reconciled and encrypted event.