encrypt block is set, the viewer can decrypt text in-browser before rendering.
Detection
The loader callshasEncryptedContent(doc) on every load. If encrypted content is detected, one of two flows runs:
- Password in config — if
passwordwas passed in config, it’s used to decrypt in-memory. - Password modal — otherwise a
PasswordModalcomponent is rendered, prompting the user.
JavaScript
Svelte
Programmatic helpers
Imported from the library:| Helper | Signature | Purpose |
|---|---|---|
hasEncryptedContent(doc) | (doc: ScreenJSONDocument) => boolean | Detects encryption on any element in the document. |
decryptDocument(doc, key) | Mutates in place. | Decrypts every encrypted text run in the document tree. |
decryptText(cipher, key, encoding?) | Returns plain text. | Decrypts a single AES-256-CTR text run. |
Errors
When a wrong password is supplied, the viewer callsonError with a LoaderError carrying code: 'DECRYPT_FAILED'. The modal flow retries until the user cancels or succeeds.