@pikku/redis 0.12.13 → 0.12.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,372 @@
1
+ ## 0.12.15
2
+
3
+ ### Patch Changes
4
+
5
+ - 78b29f0: `SecretService` now returns a `SecretValue<T>` rather than the bare value, so a
6
+ vault secret cannot reach a sink by accident.
7
+
8
+ `SecretValue` is nominally typed, which means it is not assignable to `string`
9
+ (or to any other concretely-typed field). Every sink with a real type — a
10
+ database column, an email body, a session payload — rejects it with no lint
11
+ rule involved. The sinks typed `any`, `unknown`, or a free generic — the logger,
12
+ queue payloads, webhook and email inputs, and a function's own output — are
13
+ guarded with `Safe<T>`, which collapses a `SecretValue` found anywhere inside
14
+ `T`, however deeply nested, to `never`.
15
+
16
+ Unwrap deliberately at the point the secret reaches the wire:
17
+
18
+ ```ts
19
+ const secret = await secrets.getSecret('BETTER_AUTH_SECRET')
20
+ betterAuth({ secret: secret.reveal() })
21
+ ```
22
+
23
+ Two behaviours cover what types cannot see. Structured serialization redacts —
24
+ `JSON.stringify` and node's inspect both yield `[secret]`, so an audit or log
25
+ write stays honest without crashing the request. String coercion throws
26
+ `SecretCoercionError`, because a template literal is always a leak.
27
+
28
+ `AuditLog.write` is guarded the same way as the logger, since an audit event
29
+ carries `input` and `metadata` as `unknown` and nominality alone cannot stop a
30
+ secret landing in one.
31
+
32
+ `.reveal()` is the deliberate escape hatch, and what it hands back is an
33
+ ordinary string as far as every sink signature is concerned. **PKU953** closes
34
+ that gap: under `pikku all --security` the inspector reports a revealed secret
35
+ that flows into a logger, an audit, a queue, an email or a webhook — `console` included.
36
+
37
+ This also fixed a real one: `remote-addon-auth.ts` called `String(token)` on an
38
+ `unknown` and wrote the result straight into an `Authorization` header.
39
+
40
+ - Updated dependencies [62ea4cc]
41
+ - Updated dependencies [9dddff8]
42
+ - Updated dependencies [78b29f0]
43
+ - @pikku/core@0.12.76
44
+
45
+ ## 0.12.14
46
+
47
+ ### Patch Changes
48
+
49
+ - 6a307f0: Fix four latent correctness bugs in the function, RPC and error runtimes, and
50
+ remove dead code from the workflow service surface.
51
+
52
+ `WorkflowService.getNodesWithoutSteps` is gone. It was declared on the abstract
53
+ service and implemented by all five storage backends, and nothing ever called
54
+ it — hence the non-core packages in this changeset, which only lose that method.
55
+
56
+ **An RPC could execute twice.** `RPCService.invoke`, its addon path, and
57
+ `rpcWithWire` each wrapped the _execution_ of a resolved function in a `try`
58
+ whose `catch` treated `RPCNotFoundError` as "not found locally" and re-dispatched
59
+ the call through `deploymentService`. A nested `rpc.invoke` to a missing name,
60
+ raised from inside an already-running function, therefore re-ran that function on
61
+ a remote instance after its local side effects had already committed. Resolution
62
+ is now separated from execution on all three paths, so only a genuinely
63
+ unresolvable name reaches the fallback. What escapes to callers is unchanged.
64
+
65
+ **`addonNamespace` leaked between sibling calls.** The function runner's
66
+ middleware path restored `rpc`, `functionId`, `audit` and `addonNamespace` after
67
+ an invocation; the non-middleware path restored the first three but not the
68
+ fourth. A call into an addon function with no middleware left the addon's
69
+ namespace on the wire, so subsequent sibling calls resolved the wrong
70
+ per-instance singletons and `credentialOverrides`.
71
+
72
+ **Errors registered on a subclass never resolved.** `misc.errors` was typed
73
+ `Map<PikkuError, ErrorDetails>` — instances — while `addError` stores
74
+ constructors, a mismatch hidden by its `error: any` parameter. The instance
75
+ lookup in `getErrorResponse` was consequently dead, and lookup fell through to a
76
+ scan comparing `constructor.name`, so a subclass of a registered error got no
77
+ status mapping at all. The map is now typed `Map<PikkuErrorConstructor, …>` and
78
+ lookup walks the prototype chain first. Name matching is retained, deliberately,
79
+ as the fallback that keeps error mapping working when two copies of
80
+ `@pikku/core` are installed.
81
+
82
+ **`createWeakUID` collided across instances.** The prefix was
83
+ `Date.now().toString(36)` evaluated at module load, so any two instances loading
84
+ the module in the same millisecond emitted identical `channelId` and `requestId`
85
+ sequences — reproducibly, not just in principle. It is now seeded lazily from
86
+ `crypto.randomUUID()`.
87
+
88
+ Also: `pikkuState` keys its global map with `Symbol.for` rather than `Symbol`, so
89
+ two copies of the package share registrations instead of silently getting
90
+ disjoint state; and the local channel upgrade path no longer keys its middleware
91
+ cache on the raw request path, which grew the cache without bound while the
92
+ cached value never varied by path.
93
+
94
+ - afef587: Close eleven security weaknesses found in a review of `@pikku/core`. Most are
95
+ breaking, and two invalidate data or credentials already in the wild — read the
96
+ migration notes before upgrading.
97
+
98
+ **Breaking: AI agent thread ownership now fails closed.** Reading, listing,
99
+ resuming or approving an existing thread or run requires a resolved session
100
+ principal (`userId`, or `orgId` for `sessionScope: 'org'`), regardless of the
101
+ agent's `auth` setting. Previously a request without a session had no ownership
102
+ model at all: the caller-supplied `resourceId` was accepted as the ownership
103
+ key, so any caller could read or resume another party's thread by naming its
104
+ `resourceId`. Worse, `threadOwnerConstraint` returned `undefined` for a
105
+ sessionless caller, and `undefined` means _no filter_ rather than _no rows_ —
106
+ so `getAgentThreads` returned every thread in the deployment. It now returns
107
+ `string[]`, empty for a sessionless caller, which every storage backend already
108
+ treats as matching nothing. Sessionless agents still run one-shot conversations,
109
+ each with a fresh unguessable owner; what they lose is cross-request continuity.
110
+ Wire a session to restore it.
111
+
112
+ **Breaking: stored secrets and credentials must be re-entered.** `deriveKey` ran
113
+ a single unsalted round of SHA-256 over the passphrase and used the digest
114
+ directly as the AES-GCM key — roughly one hash per brute-force guess, with one
115
+ rainbow table working against every deployment. It is now PBKDF2-HMAC-SHA256 at
116
+ 600,000 iterations over a random salt. There is no compatibility path: every
117
+ value held by the kysely, mongodb and redis secret services and the kysely
118
+ credential service becomes undecryptable. They fail loud, naming the key and
119
+ `key_version`, so the app hard-fails on first secret read until each is re-set.
120
+
121
+ The KEK salt is scoped to the key version and stored alongside it, rather than
122
+ per secret, so a bulk read costs one derivation instead of N — `getSecrets` over
123
+ 50 secrets went from ~2.3s to ~48ms, and rotation from ~4.6s to ~94ms. This adds
124
+ a salt table (kysely), hash field (redis) or collection (mongodb), created
125
+ automatically on first use.
126
+
127
+ **Breaking: `PIKKU_REMOTE_SECRET` must be at least 32 characters.** The
128
+ remote-RPC session envelope moved from PBKDF2 to HKDF, which expands
129
+ high-entropy key material rather than stretching a low-entropy passphrase. That
130
+ took a remote hop from ~269ms to ~0.4ms — PBKDF2 was running twice per request —
131
+ but HKDF supplies no brute-force resistance, so the secret must carry the
132
+ entropy itself. A shorter secret now throws `WeakKeyMaterialError` at both ends.
133
+ Generate one with `openssl rand -base64 32` and roll it out to every service in
134
+ the mesh together: existing bearer tokens are format-incompatible, so a partial
135
+ rollout produces 401s until every instance is updated. The Cloudflare, Lambda
136
+ and Azure deployment services each hand-rolled a copy of `buildRemoteHeaders`
137
+ and now call the shared one, which is what keeps the two sides in step.
138
+
139
+ **Breaking: previously signed content URLs stop verifying.** `LocalContent`
140
+ signed only `{signedAt, expiresAt, notBefore}`, so a signature proved when a URL
141
+ was issued but never what it was issued for — any valid token was a skeleton
142
+ key, and swapping the pathname from a public thumbnail to a private document
143
+ still verified. The signature now binds the request path. Separately, the
144
+ verifier returned "valid" when no JWT service was wired, which is how
145
+ `pikku serve` ran: a forged `?signedAt=0&expiresAt=99999999999999` was accepted.
146
+ It now rejects with 403, `LocalContent` requires a `JWTService`, and
147
+ `pikku serve`/`pikku dev` mint an ephemeral per-process signing key so local
148
+ development works without shipping a fail-open path. In-flight signed URLs must
149
+ be re-issued.
150
+
151
+ **Request body size limits now apply to every adapter.** The `maxBodySize` cap
152
+ existed only in `PikkuFetchHTTPRequest`. The real hole was uWebSockets, which
153
+ drove `res.onData` itself and concatenated every chunk with no bound and nothing
154
+ downstream able to intervene; it now drops chunks past the limit and replies 413
155
+ before routing. Fastify delegates to its native `bodyLimit` (set only when
156
+ `maxBodySize` is configured, so fastify's stricter 1 MB default is never
157
+ loosened), and `PikkuExpressServer` feeds the limit into its body parsers. Two
158
+ paths can only reject rather than prevent, and are documented as such:
159
+ `express-middleware` mounted on your own app receives an already-parsed body, so
160
+ that deployment must bound its own parser; Next server actions bottom out at
161
+ `experimental.serverActions.bodySizeLimit`.
162
+
163
+ **Breaking: the console addon's privileged functions are gated by default.**
164
+ `wireAddon` gains a `scopes` option that applies to every function in the
165
+ addon's namespace, and the console scaffold now generates
166
+ `wireAddon({ name: 'console', package: '@pikku/addon-console', scopes: ['admin'] })`.
167
+ Previously the console's entire privileged surface — around 54 functions
168
+ including `credentialGet`, which returns a resolved OAuth token for an arbitrary
169
+ `userId`, `updateFunctionBody`, and `installAddon`, which shells out to a
170
+ package install — was protected only by an optional host-registered
171
+ `addGlobalPermission`. `resolveGlobalPermissions` returns `[]` when none is
172
+ registered and permission checking then no-ops, so an app that never registered
173
+ one served those functions to anyone, and with the template's default
174
+ `scaffold.rpc: "no-auth"` that meant unauthenticated. All of them now return 403
175
+ `MissingScopeError` without an `admin`, `admin:*` or `*` scope. **Regenerating
176
+ is required** — an app holding an old `console.gen.ts` stays open.
177
+ `installAddon` and `installOpenapiAddon` additionally declare their own
178
+ `auth: true, scopes: ['admin']`, and `getAgentThreads` now scopes its listing to
179
+ the session's own threads unless the caller holds admin.
180
+
181
+ Addon scopes are enforced in `runPikkuFunc` rather than at the RPC boundary,
182
+ because a wiring can reference an addon function directly — the inspector
183
+ records the addon's `packageName` on HTTP, channel, schedule, queue, CLI,
184
+ trigger, gateway and MCP wirings — and those paths never call `resolveNamespace`.
185
+ Enforcing at the RPC seam would have covered only the `namespace:function` form
186
+ while reading as complete.
187
+
188
+ **Breaking: `wireAddon`'s `auth` and `tags` now apply on direct wirings too.**
189
+ Both were read only by `resolveAddonFunction`, so they had exactly the hole
190
+ scopes had: `wireAddon({ name: 'console', package: '@pikku/addon-console', auth:
191
+ true, tags: ['admin'] })` gated `rpc('console:credentialGet')` and gated nothing
192
+ at all on an HTTP route wired straight to `credentialGet`. A consumer who
193
+ reached for the documented way to lock an addon down got a control that was
194
+ silently inert on every wiring except one. Both now resolve in `runPikkuFunc`.
195
+ `auth` merges as an OR — `auth: false` from an addon is ignored on a direct
196
+ wiring, because an addon may require a session the wiring did not but must never
197
+ waive one it did. Addon tags resolve to concrete middleware against the **root**
198
+ tag groups before the call rather than being folded into the function's
199
+ inherited middleware: `addTagMiddleware('admin', …)` is written by the consuming
200
+ app and registers under the root package, whereas `combineMiddleware` would look
201
+ the tag up under the addon's own `packageName`, where it does not exist.
202
+
203
+ One consequence worth naming: an addon that wires `auth: true` and also runs its
204
+ own sessionless internal work — a scheduled task or queue worker inside the
205
+ addon calling a sibling function — is now gated where it previously was not,
206
+ because a bare `rpc('fn')` from inside the addon reaches `runPikkuFunc` with the
207
+ addon's `packageName` like any other call. This reverses a decision that
208
+ deliberately scoped the gate to the namespaced boundary; that reasoning held
209
+ only while the boundary was real, and a direct wiring can enter an addon without
210
+ crossing it, so "already inside" is not something the runtime can infer. Such an
211
+ addon should carry authorization on the function via
212
+ `pikkuFunc({ permissions })`, which has always been enforced on every path. A
213
+ follow-up will add execution provenance so an intra-addon call can be
214
+ distinguished from an external one and skip the addon-level check; that needs a
215
+ marker no caller outside the process can set, which is its own design problem
216
+ and does not belong in a security fix.
217
+
218
+ **Codegen now warns when an exposed function has no gate (PKU574).** The
219
+ generated `POST /rpc/:rpcName` dispatcher forwards to `rpc.exposed`, which
220
+ refuses anything without `expose: true` — but nothing checked whether the
221
+ target was gated, because a dispatcher cannot know what it dispatches to. The
222
+ console shipped ~54 privileged functions through that gap and the toolchain was
223
+ silent. The inspector now reports every function that is exposed, sessionless,
224
+ and carries no `auth`, `scopes` or `permissions` of its own and none from a
225
+ governing `wireAddon`. It is a `warn`, not a critical: `expose: true` on an
226
+ ungated sessionless function is correct for a genuinely public endpoint, so it
227
+ blocks a build only under `--fail-on-warn`.
228
+
229
+ Two pieces of metadata were missing for this to be answerable statically, and
230
+ both are now recorded. A `pikkuSessionlessFunc`'s own `auth: true` was read at
231
+ runtime but never written to function meta, so a self-gated function was
232
+ indistinguishable from an ungated one — `sessionless` carries the baseline, and
233
+ `auth` now carries the tightening. And `wireAddon`'s `scopes`, `auth` and `tags`
234
+ were not parsed at all: the inspector recorded the addon's `rpcEndpoint` and its
235
+ secret, variable and credential overrides, and dropped every one of its gates.
236
+ An addon whose gates are not statically knowable is treated as gated, because a
237
+ false positive on a correctly-secured addon costs more than the one case it
238
+ would catch.
239
+
240
+ **Breaking: an application's global permissions now apply inside addons.**
241
+ `resolveGlobalPermissions` read only the bucket matching the function's own
242
+ package, but the generated `addGlobalPermission` wrapper takes no package
243
+ argument and always registers under the root. An app-wide rule like "every
244
+ request needs a signed-in user" therefore stopped at the addon boundary, and the
245
+ bucket an addon's functions did read was one no host could write to — which is
246
+ why the console addon's recommended `addGlobalPermission([isAdmin],
247
+ '@pikku/addon-console')` was never a gate anybody could actually install. A
248
+ function now resolves the root bucket and its own package's, root first.
249
+ Unioning is safe in a way nothing else here would be: globals AND, so adding the
250
+ root ones can only tighten. Package buckets stay one-way — a package's globals
251
+ never reach root functions, or an installed addon could gate the whole
252
+ application. Apps with both a root global and addon-provided functions will see
253
+ those functions gated where they previously were not.
254
+
255
+ **Codegen now records whether each HTTP route requires a session, and warns
256
+ about inert addon tags (PKU575).** Four separate things can demand a session —
257
+ the function's `sessionless`, its own `auth`, the route's (or its group's)
258
+ `auth`, and the addon it belongs to — and answering "which routes are open?"
259
+ meant joining all four by hand and knowing which wins. Each route's meta now
260
+ carries the resolved `requiresSession` alongside the route's own `auth`. Scopes
261
+ count as requiring one, since they are matched against the session's and fail
262
+ closed. Anything not statically knowable resolves to `true`, matching PKU574:
263
+ a route that looks stricter than it is costs less than one that looks open and
264
+ isn't. Separately, `wireAddon({ tags: ['admin'] })` reads like a gate and is
265
+ applied like one right up until no `addTagMiddleware('admin', …)` exists, at
266
+ which point it resolves to an empty list and gates nothing; that now warns.
267
+ Only addon tags are reported — a tag on a function is as likely to be
268
+ organizational, and warning about those would bury the case that matters.
269
+
270
+ **Object-shorthand permissions were missing from meta.** The inspector visited
271
+ `ts.PropertyAssignment` but not `ts.ShorthandPropertyAssignment`, so
272
+ `permissions: { canAdminOrg }` — enforced identically to the longhand form at
273
+ runtime, since `verifyPermissions` has a non-array branch — was recorded as _no
274
+ permissions at all_. That is the most dangerous direction for meta to be wrong
275
+ in: an audit reading it sees an open door where one is shut. It cost this review
276
+ a false IDOR report across ~35 billing and org functions before the source
277
+ contradicted the metadata.
278
+
279
+ **Functions that authorize in their own body can say so.** A webhook receiver
280
+ verifying a signature, or a handler redeeming a signed invite, is genuinely
281
+ closed while carrying no session, scope or permission — indistinguishable in
282
+ meta from one nobody remembered to gate, and so warned about forever by PKU574.
283
+ `selfAuthenticated: true` on the function config records the claim and silences
284
+ the warning for that function. It is declarative only: nothing at runtime reads
285
+ it and it grants nothing. Detection was rejected deliberately — inferring it
286
+ from the body means a function that _looks_ like it checks something silences
287
+ the warning while checking nothing, and a warning that is usually wrong stops
288
+ being read.
289
+
290
+ **Breaking: `scaffold.<feature>` is now `boolean | { auth?, path? }`, and `true`
291
+ means authenticated.** The old `'auth' | 'no-auth' | false` read like a
292
+ starter-file preference while being a live authorization decision, set three
293
+ directories from the functions it governed — the shape the console incident
294
+ took. A surface now becomes public only by writing `{ auth: false }`, so
295
+ omitting a field can never open anything: the failure mode of a forgotten flag
296
+ is a locked door. `{ path }` additionally overrides where the file is
297
+ generated, which previously could only be set for all features at once via
298
+ `pikkuDir`.
299
+
300
+ The legacy strings are **refused, not coerced**. `resolveScaffoldFeature` throws
301
+ naming the key and its replacement (`"rpc": "no-auth"` → `"rpc": { "auth":
302
+ false }`), and it does so at config load, not downstream. An earlier design used
303
+ a bare `string` for the output path, under which `"no-auth"` would have parsed
304
+ as a file named `no-auth` and every unmigrated config would have silently
305
+ produced nonsense; the object form makes any string invalid, so the failure is
306
+ loud.
307
+
308
+ The collapse is deliberately not uniform in effect. For `rpc` the flag was a
309
+ blanket "no anonymous RPC in this app" set on a dispatcher that cannot know what
310
+ it dispatches to; for `userAdmin` it was redundant, since the generated
311
+ functions are already `pikkuFunc` with `scopes: ['admin:users:list']`. But for
312
+ `agent`, `workflow`, `events` and `scenarios` it is the only gate — those
313
+ generate real endpoints the app never authors — so `true` keeps them
314
+ authenticated rather than opening them as a side effect of a config cleanup.
315
+ `webhook` and `remoteRpc` have no auth dimension at all (`serialize-remote-rpc.ts`
316
+ hardcodes `auth: false`), so an `{ auth }` on them is ignored. The three
317
+ configs in this repo are migrated preserving their current behaviour exactly.
318
+
319
+ **Queue job identities are signed.** A job carried the producer's `pikkuUserId`
320
+ as a plain string and the worker resolved a session from it with no
321
+ verification, so write access to the queue backend was act-as-any-user. The
322
+ identity is now `pq1.<claim>.<hmac>`, HMAC-SHA256 over the claim and the
323
+ canonicalized job payload, keyed by HKDF expansion of a new
324
+ `PIKKU_QUEUE_IDENTITY_SECRET`. Producers opt in by wrapping their queue service
325
+ with `SignedQueueService`. This fails safe rather than closed: with no secret
326
+ configured the identity is dropped and jobs still process, warning once per
327
+ process, so no existing deployment breaks on upgrade — it simply loses queue
328
+ identity until the secret is set. The payload rather than the job id is bound
329
+ because SQS, Cloudflare Queues, Azure and the in-memory service all mint ids
330
+ after `add` returns.
331
+
332
+ **Workflow inline state is read from the run record.** `isInline` consulted a
333
+ process-local `Map`, while `WorkflowRun.inline` is durable. Any instance that
334
+ did not start a run disagreed with the record, so one instance could dispatch a
335
+ queued job for a workflow another was already executing in-process. It is now
336
+ async and resolves through the durable identity, cached only when a context
337
+ already exists so a passive reader allocates nothing. The same `Map` also leaked:
338
+ `nextStepKey` fabricated replay state on every step, and `releaseContext`
339
+ refused to free anything carrying it, so runs whose steps executed outside a
340
+ `beginReplay` bracket — the step-worker queue path — stranded their context and
341
+ step state for the process lifetime. Contexts are now released by an explicit
342
+ execution counter. Step ordinals reset per execution rather than accumulating
343
+ across step-worker invocations in one process, which makes step naming
344
+ independent of how work was distributed.
345
+
346
+ **Secret reads fail loud in every store.** `MongoDBSecretService.getSecrets`
347
+ skipped rows that failed to decrypt, and the redis equivalent dropped every
348
+ rejection via `Promise.allSettled`, including the "No KEK available for
349
+ key_version N" configuration error. Both now throw, naming the key and its key
350
+ version, matching the kysely behaviour. This matters most alongside the KEK
351
+ change above: without it, an upgrade surfaces as a partial secrets map and an
352
+ opaque downstream failure instead of an error naming the secret to re-enter.
353
+
354
+ **A second middleware registration for a pattern no longer erases the first.**
355
+ `addHTTPMiddleware`, `addTagMiddleware` and `addChannelMiddleware` groups are
356
+ keyed by pattern or tag and held one source file each, so a second file's call
357
+ overwrote the first's. Codegen emits its imports from what is stored, so the
358
+ losing file was never imported and its middleware never registered — the
359
+ runtime composes repeated registrations for a pattern happily, and only codegen
360
+ dropped one. Adding an unrelated `addHTTPMiddleware('*', …)` to an app was
361
+ enough to silently unregister the generated better-auth session bridge, which
362
+ fails open and gives no sign until a request arrives without a session. A group
363
+ now carries every registration made for it, and all of them are imported.
364
+
365
+ - Updated dependencies [6a307f0]
366
+ - Updated dependencies [afef587]
367
+ - Updated dependencies [8075f6a]
368
+ - @pikku/core@0.12.74
369
+
1
370
  ## 0.12.13
2
371
 
3
372
  ### Patch Changes
@@ -1,4 +1,5 @@
1
- import type { SecretService } from '@pikku/core/services';
1
+ import { type SecretValue } from '@pikku/core';
2
+ import type { SecretService, SecretValues } from '@pikku/core/services';
2
3
  import { Redis, type RedisOptions } from 'ioredis';
3
4
  export interface RedisSecretServiceConfig {
4
5
  key: string;
@@ -13,14 +14,18 @@ export declare class RedisSecretService implements SecretService {
13
14
  private keyVersion;
14
15
  private previousKey?;
15
16
  private keyPrefix;
17
+ private kekSalts;
18
+ private keks;
16
19
  constructor(connectionOrConfig: Redis | RedisOptions | string, config: RedisSecretServiceConfig);
17
20
  private secretKey;
21
+ private saltKey;
22
+ private getKEKSalt;
18
23
  private getKEK;
19
- getSecret<T = string>(key: string): Promise<T>;
24
+ getSecret<T = string>(key: string): Promise<SecretValue<T>>;
20
25
  hasSecret(key: string): Promise<boolean>;
21
26
  setSecret(key: string, value: unknown): Promise<void>;
22
27
  deleteSecret(key: string): Promise<void>;
23
- getSecrets<T extends Record<string, unknown> = Record<string, unknown>>(keys: (keyof T & string)[]): Promise<T>;
28
+ getSecrets<T extends Record<string, unknown> = Record<string, unknown>>(keys: (keyof T & string)[]): Promise<Partial<SecretValues<T>>>;
24
29
  rotateKEK(): Promise<number>;
25
30
  close(): Promise<void>;
26
31
  }
@@ -1,5 +1,6 @@
1
+ import { createSecretValue, isSecretValue } from '@pikku/core';
1
2
  import { Redis } from 'ioredis';
2
- import { envelopeEncrypt, envelopeDecrypt, envelopeRewrap, } from '@pikku/core/crypto-utils';
3
+ import { deriveKEK, generateKEKSalt, envelopeEncrypt, envelopeDecrypt, envelopeRewrap, } from '@pikku/core/crypto-utils';
3
4
  export class RedisSecretService {
4
5
  redis;
5
6
  ownsConnection;
@@ -7,6 +8,8 @@ export class RedisSecretService {
7
8
  keyVersion;
8
9
  previousKey;
9
10
  keyPrefix;
11
+ kekSalts = new Map();
12
+ keks = new Map();
10
13
  constructor(connectionOrConfig, config) {
11
14
  if (typeof connectionOrConfig === 'object' &&
12
15
  'hgetall' in connectionOrConfig &&
@@ -30,26 +33,50 @@ export class RedisSecretService {
30
33
  secretKey(key) {
31
34
  return `${this.keyPrefix}:secret:${key}`;
32
35
  }
33
- getKEK(version) {
34
- if (version === this.keyVersion)
35
- return this.key;
36
- if (this.previousKey)
37
- return this.previousKey;
38
- throw new Error(`No KEK available for key_version ${version}`);
36
+ saltKey() {
37
+ return `${this.keyPrefix}:kek-salt`;
38
+ }
39
+ async getKEKSalt(version) {
40
+ const cached = this.kekSalts.get(version);
41
+ if (cached)
42
+ return cached;
43
+ const field = String(version);
44
+ let salt = await this.redis.hget(this.saltKey(), field);
45
+ if (!salt) {
46
+ await this.redis.hsetnx(this.saltKey(), field, generateKEKSalt());
47
+ salt = await this.redis.hget(this.saltKey(), field);
48
+ if (!salt) {
49
+ throw new Error(`Failed to persist a KEK salt for key_version ${version}`);
50
+ }
51
+ }
52
+ this.kekSalts.set(version, salt);
53
+ return salt;
54
+ }
55
+ async getKEK(version) {
56
+ const cached = this.keks.get(version);
57
+ if (cached)
58
+ return cached;
59
+ const passphrase = version === this.keyVersion ? this.key : this.previousKey;
60
+ if (!passphrase) {
61
+ throw new Error(`No KEK available for key_version ${version}`);
62
+ }
63
+ const kek = await deriveKEK(passphrase, await this.getKEKSalt(version));
64
+ this.keks.set(version, kek);
65
+ return kek;
39
66
  }
40
67
  async getSecret(key) {
41
68
  const data = await this.redis.hgetall(this.secretKey(key));
42
69
  if (!data.ciphertext)
43
70
  throw new Error('Requested secret not found');
44
- const kek = this.getKEK(Number(data.key_version));
45
- return envelopeDecrypt(kek, data.ciphertext, data.wrapped_dek);
71
+ const kek = await this.getKEK(Number(data.key_version));
72
+ return createSecretValue(await envelopeDecrypt(kek, data.ciphertext, data.wrapped_dek));
46
73
  }
47
74
  async hasSecret(key) {
48
75
  const exists = await this.redis.exists(this.secretKey(key));
49
76
  return exists === 1;
50
77
  }
51
78
  async setSecret(key, value) {
52
- const { ciphertext, wrappedDEK } = await envelopeEncrypt(this.key, value);
79
+ const { ciphertext, wrappedDEK } = await envelopeEncrypt(await this.getKEK(this.keyVersion), isSecretValue(value) ? value.reveal() : value);
53
80
  await this.redis.hset(this.secretKey(key), {
54
81
  ciphertext,
55
82
  wrapped_dek: wrappedDEK,
@@ -60,19 +87,32 @@ export class RedisSecretService {
60
87
  await this.redis.del(this.secretKey(key));
61
88
  }
62
89
  async getSecrets(keys) {
63
- const results = await Promise.allSettled(keys.map((k) => this.getSecret(k)));
90
+ const rows = await Promise.all(keys.map(async (key) => ({
91
+ key,
92
+ data: await this.redis.hgetall(this.secretKey(key)),
93
+ })));
64
94
  const out = {};
65
- keys.forEach((key, i) => {
66
- const result = results[i];
67
- if (result?.status === 'fulfilled')
68
- out[key] = result.value;
69
- });
95
+ for (const { key, data } of rows) {
96
+ if (!data.ciphertext)
97
+ continue;
98
+ const keyVersion = Number(data.key_version);
99
+ try {
100
+ const kek = await this.getKEK(keyVersion);
101
+ out[key] = createSecretValue(await envelopeDecrypt(kek, data.ciphertext, data.wrapped_dek));
102
+ }
103
+ catch (cause) {
104
+ throw new Error(`Failed to decrypt secret "${key}" (key_version ${keyVersion}): ` +
105
+ `the configured KEK does not match the key it was wrapped under`, { cause });
106
+ }
107
+ }
70
108
  return out;
71
109
  }
72
110
  async rotateKEK() {
73
111
  if (!this.previousKey) {
74
112
  throw new Error('No previousKey configured — nothing to rotate from');
75
113
  }
114
+ const oldKEK = await this.getKEK(this.keyVersion - 1);
115
+ const newKEK = await this.getKEK(this.keyVersion);
76
116
  const pattern = `${this.keyPrefix}:secret:*`;
77
117
  let cursor = '0';
78
118
  let count = 0;
@@ -84,7 +124,7 @@ export class RedisSecretService {
84
124
  const version = Number(data.key_version);
85
125
  if (version >= this.keyVersion)
86
126
  continue;
87
- const newWrappedDEK = await envelopeRewrap(this.previousKey, this.key, data.wrapped_dek);
127
+ const newWrappedDEK = await envelopeRewrap(oldKEK, newKEK, data.wrapped_dek);
88
128
  await this.redis.hset(redisKey, {
89
129
  wrapped_dek: newWrappedDEK,
90
130
  key_version: this.keyVersion.toString(),
@@ -1 +1 @@
1
- {"version":3,"file":"redis-secret-service.js","sourceRoot":"","sources":["../../src/redis-secret-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAqB,MAAM,SAAS,CAAA;AAClD,OAAO,EACL,eAAe,EACf,eAAe,EACf,cAAc,GACf,MAAM,0BAA0B,CAAA;AASjC,MAAM,OAAO,kBAAkB;IACrB,KAAK,CAAO;IACZ,cAAc,CAAS;IACvB,GAAG,CAAQ;IACX,UAAU,CAAQ;IAClB,WAAW,CAAS;IACpB,SAAS,CAAQ;IAEzB,YACE,kBAAiD,EACjD,MAAgC;QAEhC,IACE,OAAO,kBAAkB,KAAK,QAAQ;YACtC,SAAS,IAAI,kBAAkB;YAC/B,MAAM,IAAI,kBAAkB,EAC5B,CAAC;YACD,IAAI,CAAC,KAAK,GAAG,kBAA2B,CAAA;YACxC,IAAI,CAAC,cAAc,GAAG,KAAK,CAAA;QA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O,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;gBACxC,IAAI,OAAO,IAAI,IAAI,CAAC,UAAU;oBAAE,SAAQ;gBAExC,MAAM,aAAa,GAAG,MAAM,cAAc,CACxC,MAAM,EACN,MAAM,EACN,IAAI,CAAC,WAAY,CAClB,CAAA;gBACD,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE;oBAC9B,WAAW,EAAE,aAAa;oBAC1B,WAAW,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE;iBACxC,CAAC,CAAA;gBACF,KAAK,EAAE,CAAA;YACT,CAAC;QACH,CAAC,QAAQ,MAAM,KAAK,GAAG,EAAC;QAExB,OAAO,KAAK,CAAA;IACd,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACxB,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAA;QACzB,CAAC;IACH,CAAC;CACF"}
@@ -43,7 +43,6 @@ export declare class RedisWorkflowService extends PikkuWorkflowService {
43
43
  failedNodeIds: string[];
44
44
  branchKeys: Record<string, string>;
45
45
  }>;
46
- getNodesWithoutSteps(runId: string, nodeIds: string[]): Promise<string[]>;
47
46
  getStepInstances(runId: string): Promise<Array<{
48
47
  stepName: string;
49
48
  status: StepStatus;
@@ -400,19 +400,6 @@ export class RedisWorkflowService extends PikkuWorkflowService {
400
400
  } while (cursor !== '0');
401
401
  return { completedNodeIds, failedNodeIds, branchKeys };
402
402
  }
403
- async getNodesWithoutSteps(runId, nodeIds) {
404
- if (nodeIds.length === 0)
405
- return [];
406
- const result = [];
407
- for (const nodeId of nodeIds) {
408
- const key = this.stepKey(runId, nodeId);
409
- const exists = await this.redis.exists(key);
410
- if (!exists) {
411
- result.push(nodeId);
412
- }
413
- }
414
- return result;
415
- }
416
403
  async getStepInstances(runId) {
417
404
  const instances = [];
418
405
  const pattern = `${this.keyPrefix}:step:${runId}:*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,CAC7C,IAAY,EACZ,SAAiB,EACjB,MAA6B;QAE7B,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;QAC5C,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;IAC9C,CAAC;IAED,KAAK,CAAC,kBAAkB,CACtB,IAAY,EACZ,SAAiB;QAEjB,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;QAC5C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QAC1C,IAAI,CAAC,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAA;QAC5B,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;YAC7B,MAAM,EAAE,IAAI,CAAC,MAAO;SACrB,CAAA;IACH,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACxB,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAA;QACzB,CAAC;IACH,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pikku/redis",
3
- "version": "0.12.13",
3
+ "version": "0.12.15",
4
4
  "description": "Redis services for Pikku — workflow state, agent runs, secrets, sessions and channel stores",
5
5
  "author": "yasser.fadl@gmail.com",
6
6
  "license": "MIT",
@@ -18,7 +18,7 @@
18
18
  "prepublishOnly": "yarn build"
19
19
  },
20
20
  "peerDependencies": {
21
- "@pikku/core": "^0.12.71"
21
+ "@pikku/core": "^0.12.76"
22
22
  },
23
23
  "dependencies": {
24
24
  "ioredis": "^5.10.0"
@@ -41,8 +41,82 @@ describe('RedisSecretService', () => {
41
41
  const r1 = await s1.getSecret<{ from: string }>('shared-name')
42
42
  const r2 = await s2.getSecret<{ from: string }>('shared-name')
43
43
 
44
- assert.deepEqual(r1, { from: 'app1' })
45
- assert.deepEqual(r2, { from: 'app2' })
44
+ assert.deepEqual(r1.reveal(), { from: 'app1' })
45
+ assert.deepEqual(r2.reveal(), { from: 'app2' })
46
46
  prefixRedis.disconnect()
47
47
  })
48
+
49
+ describe('decryption failures', () => {
50
+ const kek = 'test-key-encryption-key-32chars!'
51
+ const otherKek = 'a-totally-different-kek-32chars!'
52
+
53
+ test('getSecrets throws naming a secret it cannot decrypt', async () => {
54
+ const writer = new RedisSecretService(redis as any, { key: kek })
55
+ await writer.setSecret('undecryptable', { token: 'abc' })
56
+
57
+ const reader = new RedisSecretService(redis as any, { key: otherKek })
58
+
59
+ await assert.rejects(
60
+ () => reader.getSecrets(['undecryptable']),
61
+ (error: Error) => {
62
+ assert.equal(
63
+ error.message,
64
+ 'Failed to decrypt secret "undecryptable" (key_version 1): ' +
65
+ 'the configured KEK does not match the key it was wrapped under'
66
+ )
67
+ assert.ok(error.cause, 'the underlying crypto failure is preserved')
68
+ return true
69
+ }
70
+ )
71
+ })
72
+
73
+ test('getSecrets throws when no KEK is available for a stored key_version', async () => {
74
+ const writer = new RedisSecretService(redis as any, {
75
+ key: kek,
76
+ keyVersion: 7,
77
+ })
78
+ await writer.setSecret('old-version', 'value')
79
+
80
+ const reader = new RedisSecretService(redis as any, {
81
+ key: kek,
82
+ keyVersion: 8,
83
+ })
84
+
85
+ await assert.rejects(
86
+ () => reader.getSecrets(['old-version']),
87
+ (error: Error) => {
88
+ assert.equal(
89
+ error.message,
90
+ 'Failed to decrypt secret "old-version" (key_version 7): ' +
91
+ 'the configured KEK does not match the key it was wrapped under'
92
+ )
93
+ return true
94
+ }
95
+ )
96
+ })
97
+
98
+ test('getSecrets returns every secret when they all decrypt', async () => {
99
+ const service = new RedisSecretService(redis as any, { key: kek })
100
+ await service.setSecret('batch-a', { v: 1 })
101
+ await service.setSecret('batch-b', 'two')
102
+
103
+ const out = await service.getSecrets<{
104
+ 'batch-a': { v: number }
105
+ 'batch-b': string
106
+ }>(['batch-a', 'batch-b'])
107
+
108
+ assert.deepEqual(out['batch-a']!.reveal(), { v: 1 })
109
+ assert.equal(out['batch-b']!.reveal(), 'two')
110
+ })
111
+
112
+ test('getSecrets omits keys that were never stored', async () => {
113
+ const service = new RedisSecretService(redis as any, { key: kek })
114
+ await service.setSecret('present', 'here')
115
+
116
+ const out = await service.getSecrets(['present', 'never-stored'])
117
+
118
+ assert.deepEqual(Object.keys(out), ['present'])
119
+ assert.equal(out.present!.reveal(), 'here')
120
+ })
121
+ })
48
122
  })
@@ -1,6 +1,9 @@
1
- import type { SecretService } from '@pikku/core/services'
1
+ import { createSecretValue, isSecretValue, type SecretValue } from '@pikku/core'
2
+ import type { SecretService, SecretValues } from '@pikku/core/services'
2
3
  import { Redis, type RedisOptions } from 'ioredis'
3
4
  import {
5
+ deriveKEK,
6
+ generateKEKSalt,
4
7
  envelopeEncrypt,
5
8
  envelopeDecrypt,
6
9
  envelopeRewrap,
@@ -20,6 +23,8 @@ export class RedisSecretService implements SecretService {
20
23
  private keyVersion: number
21
24
  private previousKey?: string
22
25
  private keyPrefix: string
26
+ private kekSalts = new Map<number, string>()
27
+ private keks = new Map<number, CryptoKey>()
23
28
 
24
29
  constructor(
25
30
  connectionOrConfig: Redis | RedisOptions | string,
@@ -50,18 +55,52 @@ export class RedisSecretService implements SecretService {
50
55
  return `${this.keyPrefix}:secret:${key}`
51
56
  }
52
57
 
53
- private getKEK(version: number): string {
54
- if (version === this.keyVersion) return this.key
55
- if (this.previousKey) return this.previousKey
56
- throw new Error(`No KEK available for key_version ${version}`)
58
+ private saltKey(): string {
59
+ return `${this.keyPrefix}:kek-salt`
57
60
  }
58
61
 
59
- async getSecret<T = string>(key: string): Promise<T> {
62
+ private async getKEKSalt(version: number): Promise<string> {
63
+ const cached = this.kekSalts.get(version)
64
+ if (cached) return cached
65
+
66
+ const field = String(version)
67
+ let salt = await this.redis.hget(this.saltKey(), field)
68
+ if (!salt) {
69
+ await this.redis.hsetnx(this.saltKey(), field, generateKEKSalt())
70
+ salt = await this.redis.hget(this.saltKey(), field)
71
+ if (!salt) {
72
+ throw new Error(
73
+ `Failed to persist a KEK salt for key_version ${version}`
74
+ )
75
+ }
76
+ }
77
+
78
+ this.kekSalts.set(version, salt)
79
+ return salt
80
+ }
81
+
82
+ private async getKEK(version: number): Promise<CryptoKey> {
83
+ const cached = this.keks.get(version)
84
+ if (cached) return cached
85
+
86
+ const passphrase = version === this.keyVersion ? this.key : this.previousKey
87
+ if (!passphrase) {
88
+ throw new Error(`No KEK available for key_version ${version}`)
89
+ }
90
+
91
+ const kek = await deriveKEK(passphrase, await this.getKEKSalt(version))
92
+ this.keks.set(version, kek)
93
+ return kek
94
+ }
95
+
96
+ async getSecret<T = string>(key: string): Promise<SecretValue<T>> {
60
97
  const data = await this.redis.hgetall(this.secretKey(key))
61
98
  if (!data.ciphertext) throw new Error('Requested secret not found')
62
99
 
63
- const kek = this.getKEK(Number(data.key_version))
64
- return envelopeDecrypt<T>(kek, data.ciphertext!, data.wrapped_dek!)
100
+ const kek = await this.getKEK(Number(data.key_version))
101
+ return createSecretValue(
102
+ await envelopeDecrypt<T>(kek, data.ciphertext!, data.wrapped_dek!)
103
+ )
65
104
  }
66
105
 
67
106
  async hasSecret(key: string): Promise<boolean> {
@@ -70,7 +109,12 @@ export class RedisSecretService implements SecretService {
70
109
  }
71
110
 
72
111
  async setSecret(key: string, value: unknown): Promise<void> {
73
- const { ciphertext, wrappedDEK } = await envelopeEncrypt(this.key, value)
112
+ // Encrypting the wrapper would store its redaction, not the secret —
113
+ // writing a secret back to the vault is exactly what this method is for.
114
+ const { ciphertext, wrappedDEK } = await envelopeEncrypt(
115
+ await this.getKEK(this.keyVersion),
116
+ isSecretValue(value) ? value.reveal() : value
117
+ )
74
118
 
75
119
  await this.redis.hset(this.secretKey(key), {
76
120
  ciphertext,
@@ -83,16 +127,35 @@ export class RedisSecretService implements SecretService {
83
127
  await this.redis.del(this.secretKey(key))
84
128
  }
85
129
 
86
- async getSecrets<
87
- T extends Record<string, unknown> = Record<string, unknown>,
88
- >(keys: (keyof T & string)[]): Promise<T> {
89
- const results = await Promise.allSettled(keys.map((k) => this.getSecret(k)))
130
+ async getSecrets<T extends Record<string, unknown> = Record<string, unknown>>(
131
+ keys: (keyof T & string)[]
132
+ ): Promise<Partial<SecretValues<T>>> {
133
+ const rows = await Promise.all(
134
+ keys.map(async (key) => ({
135
+ key,
136
+ data: await this.redis.hgetall(this.secretKey(key)),
137
+ }))
138
+ )
139
+
90
140
  const out: Record<string, unknown> = {}
91
- keys.forEach((key, i) => {
92
- const result = results[i]
93
- if (result?.status === 'fulfilled') out[key] = result.value
94
- })
95
- return out as T
141
+ for (const { key, data } of rows) {
142
+ if (!data.ciphertext) continue
143
+
144
+ const keyVersion = Number(data.key_version)
145
+ try {
146
+ const kek = await this.getKEK(keyVersion)
147
+ out[key] = createSecretValue(
148
+ await envelopeDecrypt(kek, data.ciphertext, data.wrapped_dek!)
149
+ )
150
+ } catch (cause) {
151
+ throw new Error(
152
+ `Failed to decrypt secret "${key}" (key_version ${keyVersion}): ` +
153
+ `the configured KEK does not match the key it was wrapped under`,
154
+ { cause }
155
+ )
156
+ }
157
+ }
158
+ return out as Partial<SecretValues<T>>
96
159
  }
97
160
 
98
161
  async rotateKEK(): Promise<number> {
@@ -100,6 +163,9 @@ export class RedisSecretService implements SecretService {
100
163
  throw new Error('No previousKey configured — nothing to rotate from')
101
164
  }
102
165
 
166
+ const oldKEK = await this.getKEK(this.keyVersion - 1)
167
+ const newKEK = await this.getKEK(this.keyVersion)
168
+
103
169
  const pattern = `${this.keyPrefix}:secret:*`
104
170
  let cursor = '0'
105
171
  let count = 0
@@ -120,8 +186,8 @@ export class RedisSecretService implements SecretService {
120
186
  if (version >= this.keyVersion) continue
121
187
 
122
188
  const newWrappedDEK = await envelopeRewrap(
123
- this.previousKey,
124
- this.key,
189
+ oldKEK,
190
+ newKEK,
125
191
  data.wrapped_dek!
126
192
  )
127
193
  await this.redis.hset(redisKey, {
@@ -829,25 +829,6 @@ export class RedisWorkflowService extends PikkuWorkflowService {
829
829
  return { completedNodeIds, failedNodeIds, branchKeys }
830
830
  }
831
831
 
832
- async getNodesWithoutSteps(
833
- runId: string,
834
- nodeIds: string[]
835
- ): Promise<string[]> {
836
- if (nodeIds.length === 0) return []
837
-
838
- const result: string[] = []
839
-
840
- for (const nodeId of nodeIds) {
841
- const key = this.stepKey(runId, nodeId)
842
- const exists = await this.redis.exists(key)
843
- if (!exists) {
844
- result.push(nodeId)
845
- }
846
- }
847
-
848
- return result
849
- }
850
-
851
832
  async getStepInstances(
852
833
  runId: string
853
834
  ): Promise<