Overview
Some integrations need a backend or serverless worker to execute Lit actions long after a user has left the client. Instead of cachingpkpSessionSigs (which expire quickly and can become invalid when nodes join or leave the network), you can delegate the PKP to a session key and send the session keypair plus delegation auth signature to the server. The server then recreates the auth context and generates short-lived session signatures immediately before each request.
This pattern keeps the delegation scoped (resources and expiration are enforced by the delegation) while avoiding the flakiness that comes from reusing stale session signatures.
Workflow
- Client generates a session keypair with
generateSessionKeyPair(). - Client creates a delegation auth signature with
authManager.generatePkpDelegationAuthSig, scoping the allowed Lit resources and expiration. - Client sends the bundle ` to the server over a secure channel.
- Server restores an auth context using
authManager.createPkpAuthContextFromPreGenerated. - Server issues fresh session signatures on demand (e.g.,
authManager.createPkpSessionSigs) immediately before calling SDK helpers such as the wrapped-keys API orpkpSign.
Client hand-off example
Server restore example
Only call
createPkpSessionSigs when the downstream API explicitly requires the session sigs (for example, the wrapped-keys service).Security considerations
- Treat the session keypair like a secret. Whoever holds the private key can mint new session signatures until the delegation expires.
- Scope the delegation. Restrict resources to the minimal Lit resources needed and set conservative expirations.
- Rotate on failure. If a node joins or leaves the network the server can simply regenerate session signatures with the current handshake; if that fails, request a fresh delegation from the client.
When to use this pattern
- Long-running workflows where session signatures might expire before all steps finish (e.g., Bitcoin transactions that need multiple confirmations).
- Server-driven orchestration that must run without a browser tab staying open.
- Integrations that want to avoid caching
pkpSessionSigs, but still need durable delegated access.