Skip to Content

VaultAttachments

Defined in: src/lib/chatStore/vaultAttachments.ts:92 

Encrypted chat attachments in vault: upload, bind to a message, read back on any device, delete.

Methods

commit()

commit(attachmentId: string, owner: VaultAttachmentOwner, signal?: AbortSignal): Promise<ChatAttachment>

Defined in: src/lib/chatStore/vaultAttachments.ts:99 

Binds an uploaded attachment to a message or summary that vault already holds.

Parameters

ParameterType

attachmentId

string

owner

VaultAttachmentOwner

signal?

AbortSignal

Returns

Promise<ChatAttachment>


delete()

delete(attachmentId: string, signal?: AbortSignal): Promise<void>

Defined in: src/lib/chatStore/vaultAttachments.ts:114 

Parameters

ParameterType

attachmentId

string

signal?

AbortSignal

Returns

Promise<void>


read()

read(attachmentId: string, signal?: AbortSignal): Promise<Uint8Array<ArrayBufferLike> | null>

Defined in: src/lib/chatStore/vaultAttachments.ts:105 

The decrypted bytes, or null when the attachment is gone or not yet committed.

Parameters

ParameterType

attachmentId

string

signal?

AbortSignal

Returns

Promise<Uint8Array<ArrayBufferLike> | null>


readSealedTo()

readSealedTo(attachmentId: string, sink: VaultAttachmentSink, signal?: AbortSignal): Promise<boolean>

Defined in: src/lib/chatStore/vaultAttachments.ts:109 

Downloads the ciphertext into sink exactly as vault stores it, without decrypting; false when the attachment is gone or not yet committed.

Parameters

ParameterType

attachmentId

string

sink

VaultAttachmentSink

signal?

AbortSignal

Returns

Promise<boolean>


readTo()

readTo(attachmentId: string, sink: VaultAttachmentSink, signal?: AbortSignal): Promise<boolean>

Defined in: src/lib/chatStore/vaultAttachments.ts:107 

Downloads and decrypts into sink a few chunks at a time; false when the attachment is gone or not yet committed.

Parameters

ParameterType

attachmentId

string

sink

VaultAttachmentSink

signal?

AbortSignal

Returns

Promise<boolean>


upload()

upload(source: Blob | Uint8Array<ArrayBufferLike> | VaultAttachmentSource, options?: VaultAttachmentUploadOptions): Promise<string>

Defined in: src/lib/chatStore/vaultAttachments.ts:94 

Encrypts and uploads a file, in parts when it is over 50 MiB and vault takes parts; the attachment stays pending until commit, and vault drops it after 24h.

Parameters

ParameterType

source

Blob | Uint8Array<ArrayBufferLike> | VaultAttachmentSource

options?

VaultAttachmentUploadOptions

Returns

Promise<string>

Last updated on