Skip to content

AttachmentReader

Defined in: zaun/js/index.d.ts:710

An attachment read while it downloads. Every byte a read gives is plaintext of a chunk whose SHA-256 the file’s description (sent by the host over the post-quantum connection) named. The attachment’s own SHA3-256, and XFTP’s whole-file digest and tag, are checked once every chunk was read in order: verified().

new AttachmentReader(): AttachmentReader

AttachmentReader

readonly attachment: Attachment

Defined in: zaun/js/index.d.ts:711


readonly raw: RawAttachmentReader

Defined in: zaun/js/index.d.ts:712


readonly size: number

Defined in: zaun/js/index.d.ts:714

The attachment’s size in bytes.

close(): void

Defined in: zaun/js/index.d.ts:726

Stops the download; waiting and later reads reject with closed.

void


progress(): object

Defined in: zaun/js/index.d.ts:724

Encrypted bytes fetched so far (again after an eviction) and of the whole file.

object

fetched: number

total: number


read(offset, length, signal?): Promise<Uint8Array<ArrayBufferLike>>

Defined in: zaun/js/index.d.ts:718

Up to length bytes from offset: fewer when the range runs past what is downloaded, none at the end. Waits for the first chunk the range needs. signal gives it up (aborted); a failed check rejects with mismatch, a closed reader with closed.

number

number

AbortSignal

Promise<Uint8Array<ArrayBufferLike>>


verified(): Promise<void>

Defined in: zaun/js/index.d.ts:722

Resolves once every chunk went through the whole-file checks and the file’s size and SHA3-256 are the attachment’s; rejects with mismatch (and fails every read after) when not, or with why the download stopped.

Promise<void>