Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/e2e-encryption.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@workflow/core": patch
---

Wire AES-GCM encryption into serialization layer with stream support
4 changes: 2 additions & 2 deletions packages/core/src/runtime/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,11 @@ export class Run<TResult> {
if (run.status === 'completed') {
const rawKey = await this.world.getEncryptionKeyForRun?.(run);
const encryptionKey = rawKey ? await importKey(rawKey) : undefined;
return await hydrateWorkflowReturnValue(
return (await hydrateWorkflowReturnValue(
run.output,
this.runId,
encryptionKey
);
)) as TResult;
}

if (run.status === 'cancelled') {
Expand Down
9 changes: 6 additions & 3 deletions packages/core/src/runtime/step-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,10 @@ const stepHandler = getWorldHandlers().createQueueHandler(
const ops: Promise<void>[] = [];
const rawKey = await world.getEncryptionKeyForRun?.(workflowRunId);
const encryptionKey = rawKey ? await importKey(rawKey) : undefined;
const hydratedInput = await trace(
// The hydrated input is { args, thisVal, closureVars } but
// hydrateStepArguments returns `unknown` since the serialization
// layer can't know the shape at compile time.
const hydratedInput = (await trace(
'step.hydrate',
{},
async (hydrateSpan) => {
Expand All @@ -325,12 +328,12 @@ const stepHandler = getWorldHandlers().createQueueHandler(
);
const durationMs = Date.now() - startTime;
hydrateSpan?.setAttributes({
...Attribute.StepArgumentsCount(result.args.length),
...Attribute.StepArgumentsCount((result as any).args.length),
...Attribute.QueueDeserializeTimeMs(durationMs),
});
return result;
}
);
)) as { args: unknown[]; thisVal?: unknown; closureVars?: unknown };

const args = hydratedInput.args;
const thisVal = hydratedInput.thisVal ?? null;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/runtime/suspension-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import {
type WorkflowRun,
type World,
} from '@workflow/world';
import { importKey } from '../encryption.js';
import type {
HookInvocationQueueItem,
StepInvocationQueueItem,
WaitInvocationQueueItem,
WorkflowSuspension,
} from '../global.js';
import { importKey } from '../encryption.js';
import { runtimeLogger } from '../logger.js';
import { dehydrateStepArguments } from '../serialization.js';
import * as Attribute from '../telemetry/semantic-conventions.js';
Expand Down
Loading