Browser (WASM)
本頁內容尚未翻譯。
Functions
Section titled “Functions”Function
decodeLqip
Section titled “decodeLqip”export function decodeLqip(format_version: number, chromahash: Uint8Array | number[], dominant_color: Uint8Array | number[], max_width: number, max_height: number): WasmLqipImage;Types: WasmLqipImage
Render a sidecar lqip record to a paintable placeholder, band-limited to the box being
painted.
format_version— the record’slqip.format_version.chromahash— the record’slqip.chromahashpayload (32 bytes at the committed tier).dominant_color— the record’slqip.dominant_color, exactly 3 bytes (opaque RGB).max_width/max_height— the box the caller is about to paint. Decoding to the box rather than to a fixed size is the point ofdecode_capped: a grid cell never scales down a larger decode.
Infallible. An unrecognised format_version, a payload the parser rejects, and a
dominant_color that is not three bytes all yield a solid fallback fill rather than a throw.
A placeholder is cosmetic: it never damages a library and its absence never loses data, so
failing a viewer over one trades a blurry square for a broken gallery. The earlier version
threw on a malformed dominant_color while the native FFI painted black for the same input —
one record, two behaviours, decided by which client opened it. That is exactly the
client-dependent divergence capsule-core::lqip exists to prevent, so both surfaces now
paint the same fallback fill (black, the conventional empty cell) and say so.
Parameters
format_version:numberchromahash:Uint8Array | number[]dominant_color:Uint8Array | number[]max_width:numbermax_height:number
Returns
WasmLqipImage
Defined in wasm-surface.d.ts
Function
dropPassphraseProof
Section titled “dropPassphraseProof”export function dropPassphraseProof(passphrase: string, salt_hex: string, mem_kib: number, t_cost: number, p_cost: number): string;Derive the Argon2id proof a passphrase-gated upload link requires at drop-session creation.
The link’s salt + Argon2id parameters travel in the URL fragment beside the Drop Key; the
passphrase is entered by the guest and never leaves the browser. The returned lowercase-hex
proof equals the server’s stored verifier byte-for-byte (both are
Argon2id(passphrase, salt, params)), so submitting it proves possession without transmitting
the passphrase (SSoT: Web Upload — the optional-passphrase abuse gate). Throws malformed
on a bad salt hex, seal_failed if the KDF parameters are invalid.
Parameters
passphrase:stringsalt_hex:stringmem_kib:numbert_cost:numberp_cost:number
Returns
string
Defined in wasm-surface.d.ts
Function
openShare
Section titled “openShare”export function openShare(wrapped_scope_b64: string, opaque_id_hex: string, fragment_hex: string, passphrase?: string | null): ShareScope;Types: ShareScope
Open a share link’s encapsulated scope material entirely in the browser.
wrapped_scope_b64— the opaqueWrappedScope(base64 canonical CBOR) fetched from/s/{opaque-id}/wrapped-secret.opaque_id_hex— the{opaque-id}URL path component (lowercase hex; the HKDF salt).fragment_hex— the#{secret}URL fragment (lowercase hex; never sent to the server).passphrase— supplied only when the link is passphrase-protected; unwrapped here via Argon2id and never transmitted.
Throws (as Error.message): passphrase_required, wrong_secret (wrong passphrase or
wrong fragment/opaque — indistinguishable), or malformed.
Parameters
wrapped_scope_b64:stringopaque_id_hex:stringfragment_hex:stringpassphrase?:string | null
Returns
ShareScope
Defined in wasm-surface.d.ts
Function
openShareMetadata
Section titled “openShareMetadata”export function openShareMetadata(blob: Uint8Array | number[], opaque_id_hex: string, fragment_hex: string): ShareMetadataView;Types: ShareMetadataView
Open the sealed share metadata record entirely in the browser.
blob— the octets of/s/{opaque-id}/blob/{metadata_hash}.opaque_id_hex/fragment_hex— the URL’s path id and#{secret}, as foropen_share.
Throws (as Error.message): wrong_secret (the blob does not open under this URL — a wrong
fragment, a wrong opaque id, or a tampered blob, indistinguishable) or malformed (bad hex,
or a record this reader does not understand).
Parameters
blob:Uint8Array | number[]opaque_id_hex:stringfragment_hex:string
Returns
ShareMetadataView
Defined in wasm-surface.d.ts
Function
sealDrop
Section titled “sealDrop”export function sealDrop(plaintext: Uint8Array | number[], drop_pubkey: Uint8Array | number[], content_type: string): WasmSealedDrop;Types: WasmSealedDrop
Seal one selected asset for a guest drop, entirely in the browser.
plaintext— the asset bytes read from the file picker.drop_pubkey— the link’s Drop Key public half, decoded from the URL#{drop_pubkey}fragment (which never reaches the server).content_type— the asset’s media type (validated server-side against the link’s closed enum; here it is carried verbatim into the descriptor).
Draws a fresh K, STREAM-encrypts under it, and KEM-encapsulates K to the Drop Key. Throws
seal_failed (as Error.message) if the Drop Key is malformed.
Parameters
plaintext:Uint8Array | number[]drop_pubkey:Uint8Array | number[]content_type:string
Returns
WasmSealedDrop
Defined in wasm-surface.d.ts
Function
sealDropDerand
Section titled “sealDropDerand”export function sealDropDerand(plaintext: Uint8Array | number[], drop_pubkey: Uint8Array | number[], content_type: string, k_hex: string, nonce_prefix_hex: string, eseed_hex: string, blob_nonce_hex: string): WasmSealedDrop;Types: WasmSealedDrop
Derandomized seal_drop_wasm — exposed for the cross-language known-answer test only.
Every value the production seal draws from the CSPRNG is supplied explicitly (k,
nonce_prefix, eseed, blob_nonce, all lowercase hex) so the browser seal is byte-for-byte
reproducible and can be proven identical to capsule_core::drop::seal_drop_derand — the Rust
adopter then consumes those exact bytes (the cross-language KAT). Web app code uses
seal_drop_wasm, never this. Throws malformed on a bad-length hex field, seal_failed on a malformed Drop Key.
Parameters
plaintext:Uint8Array | number[]drop_pubkey:Uint8Array | number[]content_type:stringk_hex:stringnonce_prefix_hex:stringeseed_hex:stringblob_nonce_hex:string
Returns
WasmSealedDrop
Defined in wasm-surface.d.ts
Function
shareIsPassphraseProtected
Section titled “shareIsPassphraseProtected”export function shareIsPassphraseProtected(wrapped_scope_b64: string): boolean;Whether the fetched wrapped material is protected by an Argon2id passphrase layer.
The viewer calls this on the material from /s/{opaque-id}/wrapped-secret (or the
passphrase_protected flag on the metadata response) to decide whether to prompt for a
passphrase before calling open_share. The server holds only the opaque bytes and so cannot
answer this — it is a pure client-side inspection.
Parameters
wrapped_scope_b64:string
Returns
boolean
Defined in wasm-surface.d.ts
Classes
Section titled “Classes”Class
ShareMetadataView
Section titled “ShareMetadataView”export class ShareMetadataViewThe opened share metadata record — what the viewer starts from, recovered client-side from the
blob at the link’s metadata_hash with the URL’s opaque id and fragment.
Methods
free(): void;Returns
void
[Symbol.dispose]
Section titled “[Symbol.dispose]”[Symbol.dispose](): void;Returns
void
assets
Section titled “assets”assets(): SharedAssetView[];Types: SharedAssetView
Every covered asset, in the issuer’s order.
Returns
SharedAssetView[]
expiresAt
Section titled “expiresAt”expiresAt(): string | undefined;The issuer’s RFC 3339 expiry, for display; undefined when the link does not expire.
Returns
string | undefined
linkScopeB64
Section titled “linkScopeB64”linkScopeB64(): string | undefined;The link-only scope, base64 canonical CBOR — exactly what open_share takes. Present iff
the link has no passphrase; a passphrase link’s scope is fetched from
/s/{opaque-id}/wrapped-secret instead.
Returns
string | undefined
Defined in wasm-surface.d.ts
Class
ShareScope
Section titled “ShareScope”export class ShareScopeThe opened scope of a share link — the decryption material recovered client-side from the
URL fragment secret (and passphrase, if any). Hold it to decrypt_blob
the covered ciphertext blobs the serve path returns.
Methods
free(): void;Returns
void
[Symbol.dispose]
Section titled “[Symbol.dispose]”[Symbol.dispose](): void;Returns
void
decryptBlob
Section titled “decryptBlob”decryptBlob(file_id: string, amk_version: number, nonce_prefix_hex: string, ciphertext: Uint8Array | number[], wrapped_file_key_hex?: string | null): Uint8Array;Derive the covered asset’s per-file key and STREAM-decrypt ciphertext to plaintext.
file_id— the asset/file UUID (the servedasset_id).amk_version/nonce_prefix_hex— the asset’s crypto-manifest parameters. For an asset-scoped grant the file key is carried directly and both are unused; for an album-scoped grant the key is derived from the epoch AMK with the nonce prefix folded in.ciphertext— the octets from/s/{opaque-id}/blob/{hash}.wrapped_file_key_hex— lowercase hex of the asset’s AMK-sealedwrapped_file_key, passed only when itskey_modeiswrapped(an adopted web-upload drop, whose key a guest chose and no AMK derives). Omitted (ornull) meanskey_mode = derived. A trailing optional argument, so an existing three-plus-ciphertext call is unchanged.
Throws: scope_unavailable (the scope does not cover this asset/epoch), tampered (the
AEAD tag failed — tamper/truncation/wrong key — or the wrapped key did not open), or
malformed (bad file_id/prefix/wrapped-key hex or length).
Parameters
file_id:stringamk_version:numbernonce_prefix_hex:stringciphertext:Uint8Array | number[]wrapped_file_key_hex?:string | null
Returns
Uint8Array
scopeKind
Section titled “scopeKind”scopeKind(): string;"asset" or "album" — what the opened scope grants, for the viewer’s read-only header.
Returns
string
Defined in wasm-surface.d.ts
Class
SharedAssetView
Section titled “SharedAssetView”export class SharedAssetViewOne covered asset of an opened ShareMetadataView, in the shapes
ShareScope::decrypt_blob and /s/{opaque-id}/blob/{hash} take.
Properties
-
The AMK epoch —
decryptBlob’samk_version. -
The asset’s file UUID —
decryptBlob’sfile_id. -
The ciphertext’s content address, lowercase hex — the
{hash}to fetch. -
The plaintext media type.
-
"derived"or"wrapped". -
readonly noncePrefixHex: string;The STREAM nonce prefix, lowercase hex —
decryptBlob’snonce_prefix_hex. -
The plaintext byte length, as a JS number.
-
readonly wrappedFileKeyHex: string | undefined;The AMK-sealed file key, lowercase hex; present iff the key mode is
wrapped.
Methods
free(): void;Returns
void
[Symbol.dispose]
Section titled “[Symbol.dispose]”[Symbol.dispose](): void;Returns
void
Defined in wasm-surface.d.ts
Class
WasmLqipImage
Section titled “WasmLqipImage”export class WasmLqipImageA decoded LQIP placeholder: packed RGBA8, ready for putImageData.
A struct rather than a bare Vec<u8> because the caller cannot know the dimensions in
advance: decode_capped returns the largest frame that fits inside the requested box while
preserving the source aspect ratio, so the answer is (width, height, rgba) or nothing.
Properties
-
Frame height in pixels — at most the
maxHeightthat was requested. -
Packed RGBA8 samples,
width * height * 4bytes — the exact layoutnew ImageData(rgba, width, height)takes. -
Frame width in pixels — at most the
maxWidththat was requested.
Methods
free(): void;Returns
void
[Symbol.dispose]
Section titled “[Symbol.dispose]”[Symbol.dispose](): void;Returns
void
Defined in wasm-surface.d.ts
Class
WasmSealedDrop
Section titled “WasmSealedDrop”export class WasmSealedDropA sealed guest drop, ready for the uploader to open a drop session and stream its chunks.
Holds the STREAM ciphertext plus the unsigned descriptor’s fields, projected across the JS
boundary in exactly the wire shapes the drop endpoints expect (hex nonce prefix / ciphertext
hash, base64 kem_ct) so the TypeScript uploader builds the request body without re-encoding
crypto. Contribute-only: it exposes no way to recover K or decrypt — only a native adopter,
holding the Drop Key private half, can do that.
Methods
free(): void;Returns
void
[Symbol.dispose]
Section titled “[Symbol.dispose]”[Symbol.dispose](): void;Returns
void
chunkSize
Section titled “chunkSize”chunkSize(): number;The STREAM plaintext chunk size.
Returns
number
ciphertextHashHex
Section titled “ciphertextHashHex”ciphertextHashHex(): string;The ciphertext content-address digest, lowercase hex (64 chars) — the descriptor wire field and the per-chunk / finalization checksum the uploader sends.
Returns
string
ciphertextLen
Section titled “ciphertextLen”ciphertextLen(): number;Total ciphertext byte length — the drop session’s declared size and the cumulative
upload target, as a JS number.
Returns
number
ciphertext
Section titled “ciphertext”ciphertext(): Uint8Array;The STREAM ciphertext octets the uploader streams to the drop endpoint (a copy).
Returns
Uint8Array
contentType
Section titled “contentType”contentType(): string;The declared content type (the closed-enum value passed into seal_drop_wasm).
Returns
string
kemCtB64
Section titled “kemCtB64”kemCtB64(): string;K encapsulated to the Drop Key (KEM-DEM), base64 — the descriptor wire field. Opaque to
the server; only the Drop Key private half opens it.
Returns
string
noncePrefixHex
Section titled “noncePrefixHex”noncePrefixHex(): string;The 7-byte STREAM nonce prefix, lowercase hex (14 chars) — the descriptor wire field.
Returns
string
plaintextSize
Section titled “plaintextSize”plaintextSize(): number;Total plaintext byte length (plaintext_size), as a JS number — the drop descriptor wire
field. A guest asset never approaches the 2^53 exact-integer ceiling.
Returns
number
Defined in wasm-surface.d.ts