@pikku/azure-functions 0.12.9 → 0.12.11

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.
@@ -1,4 +1,4 @@
1
- import { buildRemoteHeaders } from '@pikku/core/remote';
1
+ import { buildMeshHeaders } from '@pikku/core/mesh';
2
2
  export class AzureDeploymentService {
3
3
  jwt;
4
4
  secrets;
@@ -17,8 +17,8 @@ export class AzureDeploymentService {
17
17
  throw new Error(`No Azure Function binding for function '${funcName}'. ` +
18
18
  `Available bindings: ${[...this.bindings.keys()].join(', ')}`);
19
19
  }
20
- const headers = await buildRemoteHeaders(this.jwt, this.secrets, funcName, session, traceId);
21
- const url = `${functionUrl}/remote/rpc/${encodeURIComponent(funcName)}`;
20
+ const headers = await buildMeshHeaders(this.jwt, this.secrets, funcName, session, traceId);
21
+ const url = `${functionUrl}/mesh/rpc/${encodeURIComponent(funcName)}`;
22
22
  const response = await fetch(url, {
23
23
  method: 'POST',
24
24
  headers,
@@ -32,7 +32,7 @@ export class AzureDeploymentService {
32
32
  catch {
33
33
  errorBody = await response.text();
34
34
  }
35
- throw new Error(`Remote RPC call to '${funcName}' failed: ${response.status} ${response.statusText}. ${errorBody}`);
35
+ throw new Error(`Mesh RPC call to '${funcName}' failed: ${response.status} ${response.statusText}. ${errorBody}`);
36
36
  }
37
37
  return response.json();
38
38
  }
@@ -1 +1 @@
1
- {"version":3,"file":"azure-deployment-service.js","sourceRoot":"","sources":["../src/azure-deployment-service.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAEvD,MAAM,OAAO,sBAAsB;IAIvB,GAAG;IACH,OAAO;IAJT,QAAQ,CAAqB;IAErC,YACU,GAA2B,EAC3B,OAAsB,EAC9B,gBAAwC;mBAFhC,GAAG;uBACH,OAAO;QAGf,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAA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,CAAC,EAAE,CAAA;QACrE,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;YAChC,MAAM,EAAE,MAAM;YACd,OAAO;YACP,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,CAAC;SAC/B,CAAC,CAAA;QAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,IAAI,SAAiB,CAAA;YACrB,IAAI,CAAC;gBACH,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;YACnD,CAAC;YAAC,MAAM,CAAC;gBACP,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;YACnC,CAAC;YACD,MAAM,IAAI,KAAK,CACb,qBAAqB,QAAQ,aAAa,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,KAAK,SAAS,EAAE,CACjG,CAAA;QACH,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAA;IACxB,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pikku/azure-functions",
3
- "version": "0.12.9",
3
+ "version": "0.12.11",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/pikkujs/pikku.git",
@@ -15,24 +15,30 @@
15
15
  "scripts": {
16
16
  "tsc": "tsc && tsc -p tsconfig.type-tests.json",
17
17
  "ncu": "npx npm-check-updates",
18
- "build": "tsc -b",
18
+ "build": "bun run clean && tsc -b",
19
19
  "release": "npm run build && npm test",
20
20
  "test": "bash run-tests.sh",
21
21
  "test:watch": "bash run-tests.sh --watch",
22
22
  "test:coverage": "bash run-tests.sh --coverage",
23
- "prepublishOnly": "bun run build"
23
+ "prepublishOnly": "bun run build",
24
+ "clean": "rm -rf dist tsconfig.tsbuildinfo"
24
25
  },
25
26
  "peerDependencies": {
26
- "@pikku/core": "^0.12.108"
27
+ "@pikku/core": "^0.12.146"
27
28
  },
28
29
  "engines": {
29
30
  "node": ">=24"
30
31
  },
31
32
  "dependencies": {
32
- "@azure/functions": "4.16.2",
33
- "@azure/storage-queue": "^12.31.0"
33
+ "@azure/functions": "4.16.5",
34
+ "@azure/storage-queue": "^12.32.0"
34
35
  },
35
36
  "exports": {
36
- ".": "./dist/index.js"
37
- }
37
+ ".": "./dist/index.js",
38
+ "./package.json": "./package.json"
39
+ },
40
+ "files": [
41
+ "dist",
42
+ "!dist/**/*.tsbuildinfo"
43
+ ]
38
44
  }
package/CHANGELOG.md DELETED
@@ -1,653 +0,0 @@
1
- ## 0.12.9
2
-
3
- ### Patch Changes
4
-
5
- - 4c7a1b5: Run the monorepo's own scripts through bun instead of yarn. What moves is the
6
- package manager each package's `prepublishOnly` and build scripts invoke, plus
7
- the two manifest fixes bun needs to resolve the tree: `uWebSockets.js` is
8
- declared with an explicit `github:` specifier, and `@pikku/uws-handler` marks
9
- its `uWebSockets.js` peer optional so a bun install of a consumer that brings
10
- its own uWS app does not try to fetch it from the registry.
11
-
12
- Three published behaviours change, all of them cases where an isolated
13
- `node_modules` or bun as the runtime had been papered over by yarn's hoisting:
14
-
15
- - `@pikku/migrator-sql` turns foreign keys on when it opens a sqlite database
16
- through bun. `node:sqlite` enforces them by default and `bun:sqlite` does not,
17
- which silently turned every `ON DELETE CASCADE` into a no-op under
18
- `bunx --bun pikku`.
19
- - `@pikku/cli` resolves a deploy provider against the project being deployed
20
- rather than against wherever the CLI itself is installed, which is what its
21
- own "is not installed" error asks the user to arrange.
22
- - `@pikku/cli` treats a specifier a runtime hands straight back — bun does this
23
- for the modules it implements itself — as not resolved from the project, so
24
- it falls back rather than loading the runtime's own copy.
25
-
26
- - Updated dependencies [4c7a1b5]
27
- - @pikku/core@0.12.108
28
-
29
- ## 0.12.8
30
-
31
- ### Patch Changes
32
-
33
- - 3a83f85: Stop re-exporting package internals through entry points
34
-
35
- 66 names reached consumers only because an `export *` in an entry point swept
36
- them up. Each one is referenced solely inside its own package, so the star is
37
- now an explicit named re-export listing what is genuinely public. The
38
- declarations themselves are untouched — this narrows the entry point, not the
39
- module.
40
-
41
- - Updated dependencies [9687ad1]
42
- - Updated dependencies [2d21628]
43
- - Updated dependencies [985b87b]
44
- - Updated dependencies [3a83f85]
45
- - @pikku/core@0.12.87
46
-
47
- ## 0.12.7
48
-
49
- ### Patch Changes
50
-
51
- - 266e3bc: One door per name: `@pikku/core/ecosystem/*` and the package root are gone
52
-
53
- `@pikku/core` published every module twice. `ecosystem/http` re-exported
54
- `./http`, `ecosystem/services` re-exported `./services`, and a name was
55
- reachable through either — so every addition had to be made in two places, and a
56
- consumer's import said nothing about what it actually used. The package root was
57
- the same problem at a larger scale: a single barrel of 206 names that no bundler
58
- could take apart, and the one specifier that revealed nothing at all.
59
-
60
- Both are deleted. Every name now lives on the subpath that owns it, and every
61
- import carries that subpath — `@pikku/core/http`, `@pikku/core/services`,
62
- `@pikku/core/errors`, `@pikku/core/types`.
63
-
64
- Deleting the facades meant the raw subpaths had to become a superset of them,
65
- which they were not: the facade tree had accumulated 25 names with no raw home
66
- and about 26 more filed under a different area than the module they came from.
67
- Those names moved to the area that owns them, and three areas were published as
68
- new entry points rather than left on a root that is going away — `./types` (the
69
- shared type surface, the largest single destination), `./state` and
70
- `./classification`.
71
-
72
- `./classification` is one door onto one subject: what a value is and how it must
73
- be handled. Its three halves would each have been an entry point — the brands
74
- and manifest types, the stored-form helpers (`hashToken`, `unsafeAsSealed` and
75
- friends), and `SecretValue` — split by whether a name happens to be a type or a
76
- value, which is the same defect as the facades. The duration and versioned-id
77
- helpers went to `./utils`, which already published, and `PikkuRequest` went to
78
- `./function`: it is the transport-agnostic request base, not an HTTP one — HTTP
79
- has `PikkuHTTPAbstractRequest`, and the only thing outside core that extends
80
- `PikkuRequest` is Azure's timer request.
81
-
82
- `./types` inherited the root barrel's habit before it inherited its contents, so
83
- the names with an owner elsewhere were moved off it. The middleware types and the
84
- five middleware factories — `pikkuMiddleware`, `pikkuMiddlewareFactory`,
85
- `pikkuChannelMiddleware`, `pikkuChannelMiddlewareFactory` and
86
- `pikkuAgentMiddleware`, runtime values on a types entry point — are now
87
- `@pikku/core/middleware`; the function meta types are `@pikku/core/function`;
88
- `SerializedError` is `@pikku/core/errors`; and the generic TypeScript helpers
89
- (`MakeRequired`, `PickRequired`, `PickOptional`, `RequireAtLeastOne`,
90
- `JSONPrimitive`, `JSONValue`) are `@pikku/core/utils`. What is left on `./types`
91
- is the vocabulary the wirings share, which no single module owns.
92
-
93
- `pikku` was itself a root barrel — `export * from '@pikku/core'` — and
94
- now exports only the services it bundles.
95
-
96
- One module survives at the old specifier, and only for the bootstrap:
97
- `packages/cli` is generated by the _published_ CLI pinned in its `build.sh`, and
98
- that CLI still writes a bare `@pikku/core` into the files it generates for the
99
- CLI itself. `bootstrap-compat/root.ts` carries the eight types it names, a test
100
- in core fails if that list grows, and it goes when the pin moves to a CLI
101
- released from this branch. The adapter names the pinned CLI reaches for —
102
- `pikkuState` and `CreateWireServices` — are rewritten to `@pikku/core/state` and
103
- `@pikku/core/types` by the same `build.sh` patch pass, so no second shim is
104
- needed for them.
105
-
106
- A guard test keeps the root shut: it parses imports and rejects a bare
107
- `@pikku/core` rather than grepping for it, because several tests hold a user's
108
- file as a template literal, where `import … from '@pikku/core'` is fixture text
109
- rather than an import this repo makes.
110
-
111
- An agent scaffold a project generated under an older CLI is refreshed rather
112
- than left to fail: `pikku all` already deleted one importing an entry point
113
- `@pikku/core` no longer publishes, and the `#pikku` hub joins that list.
114
- Without it a project that scaffolds the agent endpoint but
115
- declares no agents keeps the old file forever — the generator that would rewrite
116
- it only runs when agents exist, and the file being present is what stops it
117
- being regenerated as missing.
118
-
119
- `pikku new addon` also wrote a tsconfig `paths` map naming only the deleted hub.
120
- An addon's `imports` map points into `dist`, so `paths` is what resolves
121
- `#pikku/<leaf>` for the addon's own source build — it now names the two leaf
122
- patterns, in both the addon and its test harness.
123
-
124
- - 6eef0a0: Bump every dependency to its latest compatible minor/patch across the monorepo.
125
- - Updated dependencies [7722ceb]
126
- - Updated dependencies [375c1ff]
127
- - Updated dependencies [02a70cd]
128
- - Updated dependencies [aeef159]
129
- - Updated dependencies [a281de6]
130
- - Updated dependencies [266e3bc]
131
- - Updated dependencies [02a70cd]
132
- - Updated dependencies [786dae5]
133
- - Updated dependencies [6eef0a0]
134
- - Updated dependencies [3561d67]
135
- - Updated dependencies [a91c433]
136
- - Updated dependencies [02a70cd]
137
- - Updated dependencies [9537f74]
138
- - Updated dependencies [2b57ca8]
139
- - Updated dependencies [266e3bc]
140
- - Updated dependencies [9fce0f1]
141
- - Updated dependencies [83683a0]
142
- - Updated dependencies [456c88b]
143
- - Updated dependencies [456c88b]
144
- - Updated dependencies [c127273]
145
- - @pikku/core@0.12.85
146
-
147
- ## 0.12.6
148
-
149
- ### Patch Changes
150
-
151
- - 6794681: Publish the ecosystem surface as per-area sub-barrels under `@pikku/core/ecosystem/*`, and point generated code, the CLI, the inspector and the runtime adapters at them.
152
-
153
- 348 names that only generated code, the toolchain or a runtime adapter ever imports now have a second home on `@pikku/core/ecosystem/<area>` — one sub-barrel per area, matching how core already publishes its entrypoints, so no single barrel grows without bound and a consumer only pulls in the area it uses.
154
-
155
- This step is additive: every name is still exported from the entrypoint it was published from before, so nothing downstream breaks. Removing them from the app-facing barrels is a later change, and needs a release carrying `./ecosystem/*` first.
156
-
157
- - Updated dependencies [7406bfe]
158
- - Updated dependencies [6794681]
159
- - @pikku/core@0.12.84
160
-
161
- ## 0.12.5
162
-
163
- ### Patch Changes
164
-
165
- - 78b29f0: `SecretService` now returns a `SecretValue<T>` rather than the bare value, so a
166
- vault secret cannot reach a sink by accident.
167
-
168
- `SecretValue` is nominally typed, which means it is not assignable to `string`
169
- (or to any other concretely-typed field). Every sink with a real type — a
170
- database column, an email body, a session payload — rejects it with no lint
171
- rule involved. The sinks typed `any`, `unknown`, or a free generic — the logger,
172
- queue payloads, webhook and email inputs, and a function's own output — are
173
- guarded with `Safe<T>`, which collapses a `SecretValue` found anywhere inside
174
- `T`, however deeply nested, to `never`.
175
-
176
- Unwrap deliberately at the point the secret reaches the wire:
177
-
178
- ```ts
179
- const secret = await secrets.getSecret('BETTER_AUTH_SECRET')
180
- betterAuth({ secret: secret.reveal() })
181
- ```
182
-
183
- Two behaviours cover what types cannot see. Structured serialization redacts —
184
- `JSON.stringify` and node's inspect both yield `[secret]`, so an audit or log
185
- write stays honest without crashing the request. String coercion throws
186
- `SecretCoercionError`, because a template literal is always a leak.
187
-
188
- `AuditLog.write` is guarded the same way as the logger, since an audit event
189
- carries `input` and `metadata` as `unknown` and nominality alone cannot stop a
190
- secret landing in one.
191
-
192
- `.reveal()` is the deliberate escape hatch, and what it hands back is an
193
- ordinary string as far as every sink signature is concerned. **PKU953** closes
194
- that gap: under `pikku all --security` the inspector reports a revealed secret
195
- that flows into a logger, an audit, a queue, an email or a webhook — `console` included.
196
-
197
- This also fixed a real one: `remote-addon-auth.ts` called `String(token)` on an
198
- `unknown` and wrote the result straight into an `Authorization` header.
199
-
200
- - Updated dependencies [62ea4cc]
201
- - Updated dependencies [9dddff8]
202
- - Updated dependencies [78b29f0]
203
- - @pikku/core@0.12.76
204
-
205
- ## 0.12.4
206
-
207
- ### Patch Changes
208
-
209
- - afef587: Close eleven security weaknesses found in a review of `@pikku/core`. Most are
210
- breaking, and two invalidate data or credentials already in the wild — read the
211
- migration notes before upgrading.
212
-
213
- **Breaking: AI agent thread ownership now fails closed.** Reading, listing,
214
- resuming or approving an existing thread or run requires a resolved session
215
- principal (`userId`, or `orgId` for `sessionScope: 'org'`), regardless of the
216
- agent's `auth` setting. Previously a request without a session had no ownership
217
- model at all: the caller-supplied `resourceId` was accepted as the ownership
218
- key, so any caller could read or resume another party's thread by naming its
219
- `resourceId`. Worse, `threadOwnerConstraint` returned `undefined` for a
220
- sessionless caller, and `undefined` means _no filter_ rather than _no rows_ —
221
- so `getAgentThreads` returned every thread in the deployment. It now returns
222
- `string[]`, empty for a sessionless caller, which every storage backend already
223
- treats as matching nothing. Sessionless agents still run one-shot conversations,
224
- each with a fresh unguessable owner; what they lose is cross-request continuity.
225
- Wire a session to restore it.
226
-
227
- **Breaking: stored secrets and credentials must be re-entered.** `deriveKey` ran
228
- a single unsalted round of SHA-256 over the passphrase and used the digest
229
- directly as the AES-GCM key — roughly one hash per brute-force guess, with one
230
- rainbow table working against every deployment. It is now PBKDF2-HMAC-SHA256 at
231
- 600,000 iterations over a random salt. There is no compatibility path: every
232
- value held by the kysely, mongodb and redis secret services and the kysely
233
- credential service becomes undecryptable. They fail loud, naming the key and
234
- `key_version`, so the app hard-fails on first secret read until each is re-set.
235
-
236
- The KEK salt is scoped to the key version and stored alongside it, rather than
237
- per secret, so a bulk read costs one derivation instead of N — `getSecrets` over
238
- 50 secrets went from ~2.3s to ~48ms, and rotation from ~4.6s to ~94ms. This adds
239
- a salt table (kysely), hash field (redis) or collection (mongodb), created
240
- automatically on first use.
241
-
242
- **Breaking: `PIKKU_REMOTE_SECRET` must be at least 32 characters.** The
243
- remote-RPC session envelope moved from PBKDF2 to HKDF, which expands
244
- high-entropy key material rather than stretching a low-entropy passphrase. That
245
- took a remote hop from ~269ms to ~0.4ms — PBKDF2 was running twice per request —
246
- but HKDF supplies no brute-force resistance, so the secret must carry the
247
- entropy itself. A shorter secret now throws `WeakKeyMaterialError` at both ends.
248
- Generate one with `openssl rand -base64 32` and roll it out to every service in
249
- the mesh together: existing bearer tokens are format-incompatible, so a partial
250
- rollout produces 401s until every instance is updated. The Cloudflare, Lambda
251
- and Azure deployment services each hand-rolled a copy of `buildRemoteHeaders`
252
- and now call the shared one, which is what keeps the two sides in step.
253
-
254
- **Breaking: previously signed content URLs stop verifying.** `LocalContent`
255
- signed only `{signedAt, expiresAt, notBefore}`, so a signature proved when a URL
256
- was issued but never what it was issued for — any valid token was a skeleton
257
- key, and swapping the pathname from a public thumbnail to a private document
258
- still verified. The signature now binds the request path. Separately, the
259
- verifier returned "valid" when no JWT service was wired, which is how
260
- `pikku serve` ran: a forged `?signedAt=0&expiresAt=99999999999999` was accepted.
261
- It now rejects with 403, `LocalContent` requires a `JWTService`, and
262
- `pikku serve`/`pikku dev` mint an ephemeral per-process signing key so local
263
- development works without shipping a fail-open path. In-flight signed URLs must
264
- be re-issued.
265
-
266
- **Request body size limits now apply to every adapter.** The `maxBodySize` cap
267
- existed only in `PikkuFetchHTTPRequest`. The real hole was uWebSockets, which
268
- drove `res.onData` itself and concatenated every chunk with no bound and nothing
269
- downstream able to intervene; it now drops chunks past the limit and replies 413
270
- before routing. Fastify delegates to its native `bodyLimit` (set only when
271
- `maxBodySize` is configured, so fastify's stricter 1 MB default is never
272
- loosened), and `PikkuExpressServer` feeds the limit into its body parsers. Two
273
- paths can only reject rather than prevent, and are documented as such:
274
- `express-middleware` mounted on your own app receives an already-parsed body, so
275
- that deployment must bound its own parser; Next server actions bottom out at
276
- `experimental.serverActions.bodySizeLimit`.
277
-
278
- **Breaking: the console addon's privileged functions are gated by default.**
279
- `wireAddon` gains a `scopes` option that applies to every function in the
280
- addon's namespace, and the console scaffold now generates
281
- `wireAddon({ name: 'console', package: '@pikku/addon-console', scopes: ['admin'] })`.
282
- Previously the console's entire privileged surface — around 54 functions
283
- including `credentialGet`, which returns a resolved OAuth token for an arbitrary
284
- `userId`, `updateFunctionBody`, and `installAddon`, which shells out to a
285
- package install — was protected only by an optional host-registered
286
- `addGlobalPermission`. `resolveGlobalPermissions` returns `[]` when none is
287
- registered and permission checking then no-ops, so an app that never registered
288
- one served those functions to anyone, and with the template's default
289
- `scaffold.rpc: "no-auth"` that meant unauthenticated. All of them now return 403
290
- `MissingScopeError` without an `admin`, `admin:*` or `*` scope. **Regenerating
291
- is required** — an app holding an old `console.gen.ts` stays open.
292
- `installAddon` and `installOpenapiAddon` additionally declare their own
293
- `auth: true, scopes: ['admin']`, and `getAgentThreads` now scopes its listing to
294
- the session's own threads unless the caller holds admin.
295
-
296
- Addon scopes are enforced in `runPikkuFunc` rather than at the RPC boundary,
297
- because a wiring can reference an addon function directly — the inspector
298
- records the addon's `packageName` on HTTP, channel, schedule, queue, CLI,
299
- trigger, gateway and MCP wirings — and those paths never call `resolveNamespace`.
300
- Enforcing at the RPC seam would have covered only the `namespace:function` form
301
- while reading as complete.
302
-
303
- **Breaking: `wireAddon`'s `auth` and `tags` now apply on direct wirings too.**
304
- Both were read only by `resolveAddonFunction`, so they had exactly the hole
305
- scopes had: `wireAddon({ name: 'console', package: '@pikku/addon-console', auth:
306
- true, tags: ['admin'] })` gated `rpc('console:credentialGet')` and gated nothing
307
- at all on an HTTP route wired straight to `credentialGet`. A consumer who
308
- reached for the documented way to lock an addon down got a control that was
309
- silently inert on every wiring except one. Both now resolve in `runPikkuFunc`.
310
- `auth` merges as an OR — `auth: false` from an addon is ignored on a direct
311
- wiring, because an addon may require a session the wiring did not but must never
312
- waive one it did. Addon tags resolve to concrete middleware against the **root**
313
- tag groups before the call rather than being folded into the function's
314
- inherited middleware: `addTagMiddleware('admin', …)` is written by the consuming
315
- app and registers under the root package, whereas `combineMiddleware` would look
316
- the tag up under the addon's own `packageName`, where it does not exist.
317
-
318
- One consequence worth naming: an addon that wires `auth: true` and also runs its
319
- own sessionless internal work — a scheduled task or queue worker inside the
320
- addon calling a sibling function — is now gated where it previously was not,
321
- because a bare `rpc('fn')` from inside the addon reaches `runPikkuFunc` with the
322
- addon's `packageName` like any other call. This reverses a decision that
323
- deliberately scoped the gate to the namespaced boundary; that reasoning held
324
- only while the boundary was real, and a direct wiring can enter an addon without
325
- crossing it, so "already inside" is not something the runtime can infer. Such an
326
- addon should carry authorization on the function via
327
- `pikkuFunc({ permissions })`, which has always been enforced on every path. A
328
- follow-up will add execution provenance so an intra-addon call can be
329
- distinguished from an external one and skip the addon-level check; that needs a
330
- marker no caller outside the process can set, which is its own design problem
331
- and does not belong in a security fix.
332
-
333
- **Codegen now warns when an exposed function has no gate (PKU574).** The
334
- generated `POST /rpc/:rpcName` dispatcher forwards to `rpc.exposed`, which
335
- refuses anything without `expose: true` — but nothing checked whether the
336
- target was gated, because a dispatcher cannot know what it dispatches to. The
337
- console shipped ~54 privileged functions through that gap and the toolchain was
338
- silent. The inspector now reports every function that is exposed, sessionless,
339
- and carries no `auth`, `scopes` or `permissions` of its own and none from a
340
- governing `wireAddon`. It is a `warn`, not a critical: `expose: true` on an
341
- ungated sessionless function is correct for a genuinely public endpoint, so it
342
- blocks a build only under `--fail-on-warn`.
343
-
344
- Two pieces of metadata were missing for this to be answerable statically, and
345
- both are now recorded. A `pikkuSessionlessFunc`'s own `auth: true` was read at
346
- runtime but never written to function meta, so a self-gated function was
347
- indistinguishable from an ungated one — `sessionless` carries the baseline, and
348
- `auth` now carries the tightening. And `wireAddon`'s `scopes`, `auth` and `tags`
349
- were not parsed at all: the inspector recorded the addon's `rpcEndpoint` and its
350
- secret, variable and credential overrides, and dropped every one of its gates.
351
- An addon whose gates are not statically knowable is treated as gated, because a
352
- false positive on a correctly-secured addon costs more than the one case it
353
- would catch.
354
-
355
- **Breaking: an application's global permissions now apply inside addons.**
356
- `resolveGlobalPermissions` read only the bucket matching the function's own
357
- package, but the generated `addGlobalPermission` wrapper takes no package
358
- argument and always registers under the root. An app-wide rule like "every
359
- request needs a signed-in user" therefore stopped at the addon boundary, and the
360
- bucket an addon's functions did read was one no host could write to — which is
361
- why the console addon's recommended `addGlobalPermission([isAdmin],
362
- '@pikku/addon-console')` was never a gate anybody could actually install. A
363
- function now resolves the root bucket and its own package's, root first.
364
- Unioning is safe in a way nothing else here would be: globals AND, so adding the
365
- root ones can only tighten. Package buckets stay one-way — a package's globals
366
- never reach root functions, or an installed addon could gate the whole
367
- application. Apps with both a root global and addon-provided functions will see
368
- those functions gated where they previously were not.
369
-
370
- **Codegen now records whether each HTTP route requires a session, and warns
371
- about inert addon tags (PKU575).** Four separate things can demand a session —
372
- the function's `sessionless`, its own `auth`, the route's (or its group's)
373
- `auth`, and the addon it belongs to — and answering "which routes are open?"
374
- meant joining all four by hand and knowing which wins. Each route's meta now
375
- carries the resolved `requiresSession` alongside the route's own `auth`. Scopes
376
- count as requiring one, since they are matched against the session's and fail
377
- closed. Anything not statically knowable resolves to `true`, matching PKU574:
378
- a route that looks stricter than it is costs less than one that looks open and
379
- isn't. Separately, `wireAddon({ tags: ['admin'] })` reads like a gate and is
380
- applied like one right up until no `addTagMiddleware('admin', …)` exists, at
381
- which point it resolves to an empty list and gates nothing; that now warns.
382
- Only addon tags are reported — a tag on a function is as likely to be
383
- organizational, and warning about those would bury the case that matters.
384
-
385
- **Object-shorthand permissions were missing from meta.** The inspector visited
386
- `ts.PropertyAssignment` but not `ts.ShorthandPropertyAssignment`, so
387
- `permissions: { canAdminOrg }` — enforced identically to the longhand form at
388
- runtime, since `verifyPermissions` has a non-array branch — was recorded as _no
389
- permissions at all_. That is the most dangerous direction for meta to be wrong
390
- in: an audit reading it sees an open door where one is shut. It cost this review
391
- a false IDOR report across ~35 billing and org functions before the source
392
- contradicted the metadata.
393
-
394
- **Functions that authorize in their own body can say so.** A webhook receiver
395
- verifying a signature, or a handler redeeming a signed invite, is genuinely
396
- closed while carrying no session, scope or permission — indistinguishable in
397
- meta from one nobody remembered to gate, and so warned about forever by PKU574.
398
- `selfAuthenticated: true` on the function config records the claim and silences
399
- the warning for that function. It is declarative only: nothing at runtime reads
400
- it and it grants nothing. Detection was rejected deliberately — inferring it
401
- from the body means a function that _looks_ like it checks something silences
402
- the warning while checking nothing, and a warning that is usually wrong stops
403
- being read.
404
-
405
- **Breaking: `scaffold.<feature>` is now `boolean | { auth?, path? }`, and `true`
406
- means authenticated.** The old `'auth' | 'no-auth' | false` read like a
407
- starter-file preference while being a live authorization decision, set three
408
- directories from the functions it governed — the shape the console incident
409
- took. A surface now becomes public only by writing `{ auth: false }`, so
410
- omitting a field can never open anything: the failure mode of a forgotten flag
411
- is a locked door. `{ path }` additionally overrides where the file is
412
- generated, which previously could only be set for all features at once via
413
- `pikkuDir`.
414
-
415
- The legacy strings are **refused, not coerced**. `resolveScaffoldFeature` throws
416
- naming the key and its replacement (`"rpc": "no-auth"` → `"rpc": { "auth":
417
- false }`), and it does so at config load, not downstream. An earlier design used
418
- a bare `string` for the output path, under which `"no-auth"` would have parsed
419
- as a file named `no-auth` and every unmigrated config would have silently
420
- produced nonsense; the object form makes any string invalid, so the failure is
421
- loud.
422
-
423
- The collapse is deliberately not uniform in effect. For `rpc` the flag was a
424
- blanket "no anonymous RPC in this app" set on a dispatcher that cannot know what
425
- it dispatches to; for `userAdmin` it was redundant, since the generated
426
- functions are already `pikkuFunc` with `scopes: ['admin:users:list']`. But for
427
- `agent`, `workflow`, `events` and `scenarios` it is the only gate — those
428
- generate real endpoints the app never authors — so `true` keeps them
429
- authenticated rather than opening them as a side effect of a config cleanup.
430
- `webhook` and `remoteRpc` have no auth dimension at all (`serialize-remote-rpc.ts`
431
- hardcodes `auth: false`), so an `{ auth }` on them is ignored. The three
432
- configs in this repo are migrated preserving their current behaviour exactly.
433
-
434
- **Queue job identities are signed.** A job carried the producer's `pikkuUserId`
435
- as a plain string and the worker resolved a session from it with no
436
- verification, so write access to the queue backend was act-as-any-user. The
437
- identity is now `pq1.<claim>.<hmac>`, HMAC-SHA256 over the claim and the
438
- canonicalized job payload, keyed by HKDF expansion of a new
439
- `PIKKU_QUEUE_IDENTITY_SECRET`. Producers opt in by wrapping their queue service
440
- with `SignedQueueService`. This fails safe rather than closed: with no secret
441
- configured the identity is dropped and jobs still process, warning once per
442
- process, so no existing deployment breaks on upgrade — it simply loses queue
443
- identity until the secret is set. The payload rather than the job id is bound
444
- because SQS, Cloudflare Queues, Azure and the in-memory service all mint ids
445
- after `add` returns.
446
-
447
- **Workflow inline state is read from the run record.** `isInline` consulted a
448
- process-local `Map`, while `WorkflowRun.inline` is durable. Any instance that
449
- did not start a run disagreed with the record, so one instance could dispatch a
450
- queued job for a workflow another was already executing in-process. It is now
451
- async and resolves through the durable identity, cached only when a context
452
- already exists so a passive reader allocates nothing. The same `Map` also leaked:
453
- `nextStepKey` fabricated replay state on every step, and `releaseContext`
454
- refused to free anything carrying it, so runs whose steps executed outside a
455
- `beginReplay` bracket — the step-worker queue path — stranded their context and
456
- step state for the process lifetime. Contexts are now released by an explicit
457
- execution counter. Step ordinals reset per execution rather than accumulating
458
- across step-worker invocations in one process, which makes step naming
459
- independent of how work was distributed.
460
-
461
- **Secret reads fail loud in every store.** `MongoDBSecretService.getSecrets`
462
- skipped rows that failed to decrypt, and the redis equivalent dropped every
463
- rejection via `Promise.allSettled`, including the "No KEK available for
464
- key_version N" configuration error. Both now throw, naming the key and its key
465
- version, matching the kysely behaviour. This matters most alongside the KEK
466
- change above: without it, an upgrade surfaces as a partial secrets map and an
467
- opaque downstream failure instead of an error naming the secret to re-enter.
468
-
469
- **A second middleware registration for a pattern no longer erases the first.**
470
- `addHTTPMiddleware`, `addTagMiddleware` and `addChannelMiddleware` groups are
471
- keyed by pattern or tag and held one source file each, so a second file's call
472
- overwrote the first's. Codegen emits its imports from what is stored, so the
473
- losing file was never imported and its middleware never registered — the
474
- runtime composes repeated registrations for a pattern happily, and only codegen
475
- dropped one. Adding an unrelated `addHTTPMiddleware('*', …)` to an app was
476
- enough to silently unregister the generated better-auth session bridge, which
477
- fails open and gives no sign until a request arrives without a session. A group
478
- now carries every registration made for it, and all of them are imported.
479
-
480
- - Updated dependencies [6a307f0]
481
- - Updated dependencies [afef587]
482
- - Updated dependencies [8075f6a]
483
- - @pikku/core@0.12.74
484
-
485
- ## 0.12.3
486
-
487
- ### Patch Changes
488
-
489
- - daec082: Drop Node 22 support — the minimum supported runtime is now Node 24 (LTS).
490
-
491
- Node 22 deadlocks `pikku dev` at `loadUserBootstrap` (tsx `register()` + `require(esm)` cycle handling on node 22.12+), and Node 20 is already below our floor. The `engines.node` requirement is raised to `>=24` across all packages, matching `.nvmrc` and the CI test matrix. Closes #751.
492
-
493
- - Updated dependencies [7b17b14]
494
- - Updated dependencies [daec082]
495
- - Updated dependencies [e0fd352]
496
- - @pikku/core@0.12.58
497
-
498
- ## 0.12.2
499
-
500
- ### Patch Changes
501
-
502
- - 41ce2cb: Upgrade to TypeScript 6 and raise the minimum Node.js version to 22.
503
-
504
- All packages now build against `typescript@^6.0.3` and declare `engines.node >= 22`. Internal tooling (`ts-json-schema-generator`, `zod-to-ts`) was bumped to TypeScript 6-compatible releases.
505
-
506
- - Updated dependencies [41ce2cb]
507
- - @pikku/core@0.12.44
508
-
509
- ## 0.12.0
510
-
511
- ## 0.12.1
512
-
513
- ### Patch Changes
514
-
515
- - e04531f: Code quality improvements: resolve oxlint warnings and apply autofixes across the codebase (unused bindings, unnecessary constructors, prefer `const` over `let`, etc.). No behaviour changes.
516
- - Updated dependencies [62a8725]
517
- - Updated dependencies [a3bdb0d]
518
- - Updated dependencies [e0349ff]
519
- - Updated dependencies [62a8725]
520
- - Updated dependencies [e04531f]
521
- - Updated dependencies [62a8725]
522
- - Updated dependencies [a83efb8]
523
- - Updated dependencies [8eed717]
524
- - Updated dependencies [62a8725]
525
- - Updated dependencies [62a8725]
526
- - Updated dependencies [62a8725]
527
- - @pikku/core@0.12.1
528
-
529
- - Updated dependencies
530
-
531
- ## 0.11.0
532
-
533
- ## 0.11.1
534
-
535
- ### Patch Changes
536
-
537
- - 4b811db: chore: updating all dependencies
538
- - Updated dependencies [4b811db]
539
- - Updated dependencies [e12a00c]
540
- - Updated dependencies [4579434]
541
- - Updated dependencies [28aeb7f]
542
- - Updated dependencies [ce902b1]
543
- - Updated dependencies [06e1a31]
544
- - @pikku/core@0.11.1
545
-
546
- ### Minor Changes
547
-
548
- - Workflow support
549
-
550
- # @pikku/azure-functions
551
-
552
- ## 0.10.0
553
-
554
- This release includes significant improvements across the framework including tree-shaking support, middleware/permission factories, enhanced CLI functionality, improved TypeScript type safety, and comprehensive test strategies.
555
-
556
- For complete details, see https://pikku.dev/changelogs/0_10_0.md
557
-
558
- ## 0.9.3-next.0
559
-
560
- ### Patch Changes
561
-
562
- - Updated dependencies
563
- - @pikku/core@0.9.12-next.0
564
-
565
- ## 0.9.2
566
-
567
- ### Patch Changes
568
-
569
- - a5905a9: chore: updating all dependencies
570
- - Updated dependencies [1256238]
571
- - Updated dependencies [6cf8efd]
572
- - Updated dependencies [d3a9a09]
573
- - Updated dependencies [840e078]
574
- - Updated dependencies [667d23c]
575
- - Updated dependencies [a5905a9]
576
- - @pikku/core@0.9.2
577
-
578
- ## 0.9.1
579
-
580
- ### Patch Changes
581
-
582
- - fdb1593: core: bumping everything with a patch to sync up the major release inconsistencies in dependencies
583
- - Updated dependencies [fdb1593]
584
- - @pikku/core@0.9.1
585
-
586
- ## 0.9.0
587
-
588
- ### Breaking Changes
589
-
590
- - Normalized all transports to use "wirings" instead of events/routes/transports for consistency across the framework
591
-
592
- ## 0.8.0
593
-
594
- - Updating to match remaining packages
595
-
596
- ## 0.7.0
597
-
598
- - Updating to match remaining packages
599
-
600
- ## 0.6.1
601
-
602
- ### Patch Changes
603
-
604
- - 0a92fa7: refactor: pulling schema into seperate package since ajv doesnt work on cloudflare (also keeps bundle size small!)
605
- - Updated dependencies [0a92fa7]
606
- - @pikku/core@0.6.7
607
-
608
- ## 0.6
609
-
610
- Marking a major release to include channels and scheduled tasks
611
-
612
- ## 0.5.4
613
-
614
- ### Patch Changes
615
-
616
- - 886a2fb: refactor: moving singletons (like routes and channels) to global to avoid nodemodule overrides
617
- - Updated dependencies [a768bad]
618
- - Updated dependencies [886a2fb]
619
- - Updated dependencies [886a2fb]
620
- - @pikku/core@0.5.28
621
-
622
- ## 0.5.3
623
-
624
- ### Patch Changes
625
-
626
- - 0f96787: refactor: dropping cjs support
627
- - 64e4a1e: refactor: seperating core into cleaner sub-packages
628
- - c23524a: refactor: bump to versions to ensure correct package usage
629
- - Updated dependencies [0f96787]
630
- - Updated dependencies [64e4a1e]
631
- - Updated dependencies [c23524a]
632
- - @pikku/core@0.5.25
633
-
634
- ## 0.5.2
635
-
636
- ### Patch Changes
637
-
638
- - bba25cc: chore: updating all packages to reflect major changes
639
- - Updated dependencies [bba25cc]
640
- - Updated dependencies [9deb482]
641
- - Updated dependencies [ee0c6ea]
642
- - @pikku/core@0.5.24
643
-
644
- ## 0.5.1
645
-
646
- ### Patch Changes
647
-
648
- - d58c440: refactor: making http requests explicit to support other types
649
- - b01ecbf: fix: adding index file
650
- - Updated dependencies [cbcc75b]
651
- - Updated dependencies [d58c440]
652
- - Updated dependencies [11c50d4]
653
- - @pikku/core@0.5.19
package/run-tests.sh DELETED
@@ -1,68 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Enable nullglob to handle cases where no files match the pattern
4
- shopt -s nullglob
5
-
6
- # Initialize variables for options
7
- watch_mode=false
8
- coverage_mode=false
9
-
10
- # Parse command-line options
11
- while [[ $# -gt 0 ]]; do
12
- case $1 in
13
- --watch)
14
- watch_mode=true
15
- shift
16
- ;;
17
- --coverage)
18
- coverage_mode=true
19
- shift
20
- ;;
21
- *)
22
- echo "Unknown option: $1"
23
- exit 1
24
- ;;
25
- esac
26
- done
27
-
28
- # Define the pattern to match your test files
29
- pattern="src/*.test.ts"
30
-
31
- # Expand the pattern into an array of files
32
- files=($(find src -type f -name "*.test.ts"))
33
-
34
- # Check if any files matched the pattern
35
- if [ ${#files[@]} -eq 0 ]; then
36
- echo "No test files found matching pattern: $pattern"
37
- if [ "${STRICT_TEST_DISCOVERY}" = "1" ]; then
38
- exit 1
39
- fi
40
- exit 0
41
- fi
42
-
43
- # Construct the bun command
44
- #
45
- # --parallel gives every test file its own worker process, which is what node's
46
- # `--test` did. Several suites keep module-level caches (a TypeScript program, a
47
- # temp fixture directory) that a shared process would leak between files.
48
- #
49
- # --timeout because bun caps a test at 5s by default where node had no cap, and
50
- # the suites that build real TypeScript programs run well past that.
51
- bun_cmd=(bun test --parallel --timeout 120000)
52
-
53
- # Append options based on flags
54
- if [ "$watch_mode" = true ]; then
55
- # --watch reruns in one process; parallel workers have nothing to watch.
56
- bun_cmd=(bun test --watch --timeout 120000)
57
- fi
58
-
59
- if [ "$coverage_mode" = true ]; then
60
- # --coverage-dir=. keeps lcov.info at the package root: CI merges every
61
- # package's report by prefixing its SF paths with the file's own directory,
62
- # so a nested coverage/ directory would re-root them one level too deep.
63
- bun_cmd+=(--coverage --coverage-reporter=lcov --coverage-reporter=text --coverage-dir=.)
64
- export PIKKU_TEST_COVERAGE=1
65
- fi
66
-
67
- # Execute the bun command with the expanded list of files
68
- "${bun_cmd[@]}" "${files[@]}"