Sealed sessions
Encrypt a small payload into a cookie value, or sign a session cookie, with a rotating secret, a purpose and an expiry.
On this page
Some state has to live in the browser between requests: the in-flight login transaction, or a small session. A value in a cookie can be read and edited by the person who holds it unless you protect it. The sealed module does that protection with two pairs of functions. It is imported from the SDK's sealed subpath.
| Pair | Protects | Format |
|---|---|---|
seal and unseal | Confidentiality and integrity: the person cannot read or change the payload. | A compact JWE using dir with A256GCM. |
signSession and verifySession | Integrity only: the person can read the payload, not change it. | A compact JWT signed with HS256. |
The relying-party routes use seal for the login transaction, so you rarely call it yourself for that. Use these functions for your own cookies.