` block in `htmlBody` carrying the full base64 ciphertext, and `attachment` was always a `File`. Both have changed. The armor block has been removed (it pushed bodies past Outlook's 1 M-character `setAsync` limit), and `attachment` is now `File | null` — null for tier 3.
+:::
+
+### Usage
The Thunderbird addon creates the envelope in one call:
@@ -101,6 +138,8 @@ const envelope = await pg.email.createEnvelope({
[Source: yivi-popup.ts#L90-L136](https://github.com/encryption4all/postguard-tb-addon/blob/57234eebd32d64bd011086fe89ecdd7ac40fc15d/src/pages/yivi-popup/yivi-popup.ts#L90-L136)
+Callers that handle the result must null-check `envelope.attachment` before reading it, since tier 3 envelopes carry no attachment.
+
### Parameters
| Parameter | Type | Required | Description |
@@ -109,24 +148,23 @@ const envelope = await pg.email.createEnvelope({
| `from` | `string` | Yes | Sender email address |
| `websiteUrl` | `string` | No | URL to link in the placeholder body (default: `https://postguard.eu`) |
| `unencryptedMessage` | `string` | No | Unencrypted message shown in the placeholder |
+| `senderAttributes` | `string[]` | No | Verified sender attributes to display below the sender name |
+| `uploadToCryptify` | `boolean` | No | Default `true`. Set `false` to keep tier 2 envelopes as a local attachment only and skip the Cryptify upload + body link. Has no effect on tier 1 (no upload happens) or tier 3 (upload is always attempted because there is no fallback). |
### Result
| Property | Type | Description |
|----------|------|-------------|
| `subject` | `string` | Always `"PostGuard Encrypted Email"` |
-| `htmlBody` | `string` | Placeholder HTML with decrypt button and armored payload |
+| `htmlBody` | `string` | Placeholder HTML with the decrypt button and the fallback link for the selected tier |
| `plainTextBody` | `string` | Plain text fallback |
-| `attachment` | `File` | The `postguard.encrypted` file |
+| `attachment` | `File \| null` | The `postguard.encrypted` file in tiers 1 and 2, `null` in tier 3 |
+| `tier` | `'tier1' \| 'tier2' \| 'tier3'` | Which tier was selected |
+| `uploadUuid` | `string \| null` | Cryptify UUID if the payload was uploaded, otherwise `null` |
## `extractCiphertext()`
-Extracts the encrypted ciphertext from a received email. It checks two locations in order:
-
-1. Attachments: looks for a file named `postguard.encrypted`
-2. HTML body: looks for an armored payload between `-----BEGIN POSTGUARD MESSAGE-----` and `-----END POSTGUARD MESSAGE-----` markers
-
-Returns a `Uint8Array` with the ciphertext, or `null` if nothing is found.
+Extracts the encrypted ciphertext from a received email by looking for an attachment named `postguard.encrypted`. Returns a `Uint8Array` with the ciphertext, or `null` if no such attachment is found.
```ts
const ciphertext = pg.email.extractCiphertext({
@@ -135,13 +173,29 @@ const ciphertext = pg.email.extractCiphertext({
});
```
+
[Source: extract.ts#L14-L28](https://github.com/encryption4all/postguard-js/blob/91c84855b4613e9c8c1fe65fc0f5a4dc4c6d11d6/src/email/extract.ts#L14-L28)
+
+Tier 3 envelopes carry no attachment, so `extractCiphertext` returns `null` on them. Pair it with `extractUploadUuid` to find a Cryptify UUID in the body and download the ciphertext from there.
+
+The `htmlBody` field is accepted for compatibility but is no longer consulted. The legacy in-body armor block (`
` and the `-----BEGIN POSTGUARD MESSAGE-----` markers) is no longer emitted, and consumer code that stripped or parsed it can be removed.
+
### Parameters
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
-| `htmlBody` | `string` | No | The HTML body of the received email |
+| `htmlBody` | `string` | No | Accepted for compatibility, no longer consulted |
| `attachments` | `Array<{ name, data }>` | No | Email attachments (data as ArrayBuffer) |
+## `extractUploadUuid()`
+
+Finds a Cryptify UUID in the HTML body of a received email. It matches either the `/decrypt?uuid=…` or `/download?uuid=…` link produced by tier 2 and tier 3 envelopes. Returns the UUID, or `null` if none is found.
+
+```ts
+const uuid = pg.email.extractUploadUuid(htmlBody);
+```
+
+[Source: extract.ts#L35-L43](https://github.com/encryption4all/postguard-js/blob/91c84855b4613e9c8c1fe65fc0f5a4dc4c6d11d6/src/email/extract.ts#L35-L43)
+
## `injectMimeHeaders()`
Adds or replaces headers in a raw MIME string. The function splits the MIME at the `\r\n\r\n` separator, processes the header section (including folded multi-line headers), and reassembles the result.