Wire encryption into serialization layer#957
Wire encryption into serialization layer#957TooTallNate wants to merge 2 commits intonate/vercel-encryptionfrom
Conversation
🦋 Changeset detectedLatest commit: 80714fd The changes in this PR will be included in the next version bump. This PR includes changesets to release 18 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
🧪 E2E Test Results❌ Some tests failed Summary
❌ Failed Tests🌍 Community Worlds (41 failed)turso (41 failed):
Details by Category✅ ▲ Vercel Production
✅ 💻 Local Development
✅ 📦 Local Production
✅ 🐘 Local Postgres
✅ 🪟 Windows
❌ 🌍 Community Worlds
✅ 📋 Other
|
There was a problem hiding this comment.
Pull request overview
This PR implements end-to-end encryption for workflow user data by wiring encryption functionality into the serialization layer. It builds on previous PRs that generated runId client-side (#954), made serialization functions async (#955), and added the Vercel encryption implementation (#956).
Changes:
- Adds encryption/decryption helper functions (
maybeEncrypt,maybeDecrypt,isEncrypted,peekFormatPrefix) and unused stream encryption utilities (getEncryptStream,getDecryptStream) - Adds
ENCRYPTED('encr') format prefix toSerializationFormatenum - Wires encryption into all 8 dehydrate/hydrate functions by calling
maybeEncryptafter serialization andmaybeDecryptbefore deserialization - Implements inline stream encryption in
WorkflowServerWritableStreamandWorkflowServerReadableStream - Passes
runIdtoWorkflowServerReadableStreamfor decryption context - Adds 8 comprehensive integration tests using a mock XOR encryptor
- Removes unused
_prefixes fromencryptorandrunIdparameters (now actively used) - Adds type casts (
as any[],as any,as TResult) to hydration call sites to preserve type information
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/core/src/serialization.ts | Core encryption implementation: adds format prefix, helper functions, encryption wiring in dehydrate/hydrate functions, and inline stream encryption/decryption |
| packages/core/src/workflow.ts | Adds type cast for hydrated workflow arguments |
| packages/core/src/runtime/step-handler.ts | Adds type cast for hydrated step arguments |
| packages/core/src/runtime/run.ts | Adds type cast for hydrated workflow return value |
| packages/core/src/serialization.test.ts | Adds 8 encryption integration tests with mock XOR encryptor |
| .changeset/e2e-encryption.md | Documents the end-to-end encryption feature addition |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
efd031c to
c1795c7
Compare
7e25694 to
e5b148e
Compare
c1795c7 to
60fac27
Compare
e5b148e to
c686cb4
Compare
92cb3ef to
edad633
Compare
1d457e7 to
80714fd
Compare

Summary
maybeEncrypt()/maybeDecrypt()helpers that conditionally encrypt/decrypt based on whether anEncryptoris providedpeekFormatPrefix(),isEncrypted()helper functionsENCRYPTED('encr') format prefix toSerializationFormatgetEncryptStream()/getDecryptStream()TransformStream factories for stream encryptionmaybeEncryptafter serialization, hydrate callsmaybeDecryptbefore deserializationWorkflowServerWritableStream(encrypts chunks before writing to storage)WorkflowServerReadableStream(decrypts chunks when reading from storage)runIdtoWorkflowServerReadableStreamfor decryption contextThis is the "light the fuse" PR that actually enables encryption. When a
Worldimplementation providesencrypt/decryptfunctions (e.g., viaVERCEL_DEPLOYMENT_KEYenv var), all workflow user data will be encrypted at rest.Stack
runIdclient-side instart()and simplify streaming types #954 (Generate runId client-side in start())Test plan
All 311 core tests pass (303 existing + 8 new encryption integration tests). Build succeeds.