@pikku/azure-functions 0.12.2 → 0.12.4

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,296 @@
1
+ ## 0.12.4
2
+
3
+ ### Patch Changes
4
+
5
+ - afef587: Close eleven security weaknesses found in a review of `@pikku/core`. Most are
6
+ breaking, and two invalidate data or credentials already in the wild — read the
7
+ migration notes before upgrading.
8
+
9
+ **Breaking: AI agent thread ownership now fails closed.** Reading, listing,
10
+ resuming or approving an existing thread or run requires a resolved session
11
+ principal (`userId`, or `orgId` for `sessionScope: 'org'`), regardless of the
12
+ agent's `auth` setting. Previously a request without a session had no ownership
13
+ model at all: the caller-supplied `resourceId` was accepted as the ownership
14
+ key, so any caller could read or resume another party's thread by naming its
15
+ `resourceId`. Worse, `threadOwnerConstraint` returned `undefined` for a
16
+ sessionless caller, and `undefined` means _no filter_ rather than _no rows_ —
17
+ so `getAgentThreads` returned every thread in the deployment. It now returns
18
+ `string[]`, empty for a sessionless caller, which every storage backend already
19
+ treats as matching nothing. Sessionless agents still run one-shot conversations,
20
+ each with a fresh unguessable owner; what they lose is cross-request continuity.
21
+ Wire a session to restore it.
22
+
23
+ **Breaking: stored secrets and credentials must be re-entered.** `deriveKey` ran
24
+ a single unsalted round of SHA-256 over the passphrase and used the digest
25
+ directly as the AES-GCM key — roughly one hash per brute-force guess, with one
26
+ rainbow table working against every deployment. It is now PBKDF2-HMAC-SHA256 at
27
+ 600,000 iterations over a random salt. There is no compatibility path: every
28
+ value held by the kysely, mongodb and redis secret services and the kysely
29
+ credential service becomes undecryptable. They fail loud, naming the key and
30
+ `key_version`, so the app hard-fails on first secret read until each is re-set.
31
+
32
+ The KEK salt is scoped to the key version and stored alongside it, rather than
33
+ per secret, so a bulk read costs one derivation instead of N — `getSecrets` over
34
+ 50 secrets went from ~2.3s to ~48ms, and rotation from ~4.6s to ~94ms. This adds
35
+ a salt table (kysely), hash field (redis) or collection (mongodb), created
36
+ automatically on first use.
37
+
38
+ **Breaking: `PIKKU_REMOTE_SECRET` must be at least 32 characters.** The
39
+ remote-RPC session envelope moved from PBKDF2 to HKDF, which expands
40
+ high-entropy key material rather than stretching a low-entropy passphrase. That
41
+ took a remote hop from ~269ms to ~0.4ms — PBKDF2 was running twice per request —
42
+ but HKDF supplies no brute-force resistance, so the secret must carry the
43
+ entropy itself. A shorter secret now throws `WeakKeyMaterialError` at both ends.
44
+ Generate one with `openssl rand -base64 32` and roll it out to every service in
45
+ the mesh together: existing bearer tokens are format-incompatible, so a partial
46
+ rollout produces 401s until every instance is updated. The Cloudflare, Lambda
47
+ and Azure deployment services each hand-rolled a copy of `buildRemoteHeaders`
48
+ and now call the shared one, which is what keeps the two sides in step.
49
+
50
+ **Breaking: previously signed content URLs stop verifying.** `LocalContent`
51
+ signed only `{signedAt, expiresAt, notBefore}`, so a signature proved when a URL
52
+ was issued but never what it was issued for — any valid token was a skeleton
53
+ key, and swapping the pathname from a public thumbnail to a private document
54
+ still verified. The signature now binds the request path. Separately, the
55
+ verifier returned "valid" when no JWT service was wired, which is how
56
+ `pikku serve` ran: a forged `?signedAt=0&expiresAt=99999999999999` was accepted.
57
+ It now rejects with 403, `LocalContent` requires a `JWTService`, and
58
+ `pikku serve`/`pikku dev` mint an ephemeral per-process signing key so local
59
+ development works without shipping a fail-open path. In-flight signed URLs must
60
+ be re-issued.
61
+
62
+ **Request body size limits now apply to every adapter.** The `maxBodySize` cap
63
+ existed only in `PikkuFetchHTTPRequest`. The real hole was uWebSockets, which
64
+ drove `res.onData` itself and concatenated every chunk with no bound and nothing
65
+ downstream able to intervene; it now drops chunks past the limit and replies 413
66
+ before routing. Fastify delegates to its native `bodyLimit` (set only when
67
+ `maxBodySize` is configured, so fastify's stricter 1 MB default is never
68
+ loosened), and `PikkuExpressServer` feeds the limit into its body parsers. Two
69
+ paths can only reject rather than prevent, and are documented as such:
70
+ `express-middleware` mounted on your own app receives an already-parsed body, so
71
+ that deployment must bound its own parser; Next server actions bottom out at
72
+ `experimental.serverActions.bodySizeLimit`.
73
+
74
+ **Breaking: the console addon's privileged functions are gated by default.**
75
+ `wireAddon` gains a `scopes` option that applies to every function in the
76
+ addon's namespace, and the console scaffold now generates
77
+ `wireAddon({ name: 'console', package: '@pikku/addon-console', scopes: ['admin'] })`.
78
+ Previously the console's entire privileged surface — around 54 functions
79
+ including `credentialGet`, which returns a resolved OAuth token for an arbitrary
80
+ `userId`, `updateFunctionBody`, and `installAddon`, which shells out to a
81
+ package install — was protected only by an optional host-registered
82
+ `addGlobalPermission`. `resolveGlobalPermissions` returns `[]` when none is
83
+ registered and permission checking then no-ops, so an app that never registered
84
+ one served those functions to anyone, and with the template's default
85
+ `scaffold.rpc: "no-auth"` that meant unauthenticated. All of them now return 403
86
+ `MissingScopeError` without an `admin`, `admin:*` or `*` scope. **Regenerating
87
+ is required** — an app holding an old `console.gen.ts` stays open.
88
+ `installAddon` and `installOpenapiAddon` additionally declare their own
89
+ `auth: true, scopes: ['admin']`, and `getAgentThreads` now scopes its listing to
90
+ the session's own threads unless the caller holds admin.
91
+
92
+ Addon scopes are enforced in `runPikkuFunc` rather than at the RPC boundary,
93
+ because a wiring can reference an addon function directly — the inspector
94
+ records the addon's `packageName` on HTTP, channel, schedule, queue, CLI,
95
+ trigger, gateway and MCP wirings — and those paths never call `resolveNamespace`.
96
+ Enforcing at the RPC seam would have covered only the `namespace:function` form
97
+ while reading as complete.
98
+
99
+ **Breaking: `wireAddon`'s `auth` and `tags` now apply on direct wirings too.**
100
+ Both were read only by `resolveAddonFunction`, so they had exactly the hole
101
+ scopes had: `wireAddon({ name: 'console', package: '@pikku/addon-console', auth:
102
+ true, tags: ['admin'] })` gated `rpc('console:credentialGet')` and gated nothing
103
+ at all on an HTTP route wired straight to `credentialGet`. A consumer who
104
+ reached for the documented way to lock an addon down got a control that was
105
+ silently inert on every wiring except one. Both now resolve in `runPikkuFunc`.
106
+ `auth` merges as an OR — `auth: false` from an addon is ignored on a direct
107
+ wiring, because an addon may require a session the wiring did not but must never
108
+ waive one it did. Addon tags resolve to concrete middleware against the **root**
109
+ tag groups before the call rather than being folded into the function's
110
+ inherited middleware: `addTagMiddleware('admin', …)` is written by the consuming
111
+ app and registers under the root package, whereas `combineMiddleware` would look
112
+ the tag up under the addon's own `packageName`, where it does not exist.
113
+
114
+ One consequence worth naming: an addon that wires `auth: true` and also runs its
115
+ own sessionless internal work — a scheduled task or queue worker inside the
116
+ addon calling a sibling function — is now gated where it previously was not,
117
+ because a bare `rpc('fn')` from inside the addon reaches `runPikkuFunc` with the
118
+ addon's `packageName` like any other call. This reverses a decision that
119
+ deliberately scoped the gate to the namespaced boundary; that reasoning held
120
+ only while the boundary was real, and a direct wiring can enter an addon without
121
+ crossing it, so "already inside" is not something the runtime can infer. Such an
122
+ addon should carry authorization on the function via
123
+ `pikkuFunc({ permissions })`, which has always been enforced on every path. A
124
+ follow-up will add execution provenance so an intra-addon call can be
125
+ distinguished from an external one and skip the addon-level check; that needs a
126
+ marker no caller outside the process can set, which is its own design problem
127
+ and does not belong in a security fix.
128
+
129
+ **Codegen now warns when an exposed function has no gate (PKU574).** The
130
+ generated `POST /rpc/:rpcName` dispatcher forwards to `rpc.exposed`, which
131
+ refuses anything without `expose: true` — but nothing checked whether the
132
+ target was gated, because a dispatcher cannot know what it dispatches to. The
133
+ console shipped ~54 privileged functions through that gap and the toolchain was
134
+ silent. The inspector now reports every function that is exposed, sessionless,
135
+ and carries no `auth`, `scopes` or `permissions` of its own and none from a
136
+ governing `wireAddon`. It is a `warn`, not a critical: `expose: true` on an
137
+ ungated sessionless function is correct for a genuinely public endpoint, so it
138
+ blocks a build only under `--fail-on-warn`.
139
+
140
+ Two pieces of metadata were missing for this to be answerable statically, and
141
+ both are now recorded. A `pikkuSessionlessFunc`'s own `auth: true` was read at
142
+ runtime but never written to function meta, so a self-gated function was
143
+ indistinguishable from an ungated one — `sessionless` carries the baseline, and
144
+ `auth` now carries the tightening. And `wireAddon`'s `scopes`, `auth` and `tags`
145
+ were not parsed at all: the inspector recorded the addon's `rpcEndpoint` and its
146
+ secret, variable and credential overrides, and dropped every one of its gates.
147
+ An addon whose gates are not statically knowable is treated as gated, because a
148
+ false positive on a correctly-secured addon costs more than the one case it
149
+ would catch.
150
+
151
+ **Breaking: an application's global permissions now apply inside addons.**
152
+ `resolveGlobalPermissions` read only the bucket matching the function's own
153
+ package, but the generated `addGlobalPermission` wrapper takes no package
154
+ argument and always registers under the root. An app-wide rule like "every
155
+ request needs a signed-in user" therefore stopped at the addon boundary, and the
156
+ bucket an addon's functions did read was one no host could write to — which is
157
+ why the console addon's recommended `addGlobalPermission([isAdmin],
158
+ '@pikku/addon-console')` was never a gate anybody could actually install. A
159
+ function now resolves the root bucket and its own package's, root first.
160
+ Unioning is safe in a way nothing else here would be: globals AND, so adding the
161
+ root ones can only tighten. Package buckets stay one-way — a package's globals
162
+ never reach root functions, or an installed addon could gate the whole
163
+ application. Apps with both a root global and addon-provided functions will see
164
+ those functions gated where they previously were not.
165
+
166
+ **Codegen now records whether each HTTP route requires a session, and warns
167
+ about inert addon tags (PKU575).** Four separate things can demand a session —
168
+ the function's `sessionless`, its own `auth`, the route's (or its group's)
169
+ `auth`, and the addon it belongs to — and answering "which routes are open?"
170
+ meant joining all four by hand and knowing which wins. Each route's meta now
171
+ carries the resolved `requiresSession` alongside the route's own `auth`. Scopes
172
+ count as requiring one, since they are matched against the session's and fail
173
+ closed. Anything not statically knowable resolves to `true`, matching PKU574:
174
+ a route that looks stricter than it is costs less than one that looks open and
175
+ isn't. Separately, `wireAddon({ tags: ['admin'] })` reads like a gate and is
176
+ applied like one right up until no `addTagMiddleware('admin', …)` exists, at
177
+ which point it resolves to an empty list and gates nothing; that now warns.
178
+ Only addon tags are reported — a tag on a function is as likely to be
179
+ organizational, and warning about those would bury the case that matters.
180
+
181
+ **Object-shorthand permissions were missing from meta.** The inspector visited
182
+ `ts.PropertyAssignment` but not `ts.ShorthandPropertyAssignment`, so
183
+ `permissions: { canAdminOrg }` — enforced identically to the longhand form at
184
+ runtime, since `verifyPermissions` has a non-array branch — was recorded as _no
185
+ permissions at all_. That is the most dangerous direction for meta to be wrong
186
+ in: an audit reading it sees an open door where one is shut. It cost this review
187
+ a false IDOR report across ~35 billing and org functions before the source
188
+ contradicted the metadata.
189
+
190
+ **Functions that authorize in their own body can say so.** A webhook receiver
191
+ verifying a signature, or a handler redeeming a signed invite, is genuinely
192
+ closed while carrying no session, scope or permission — indistinguishable in
193
+ meta from one nobody remembered to gate, and so warned about forever by PKU574.
194
+ `selfAuthenticated: true` on the function config records the claim and silences
195
+ the warning for that function. It is declarative only: nothing at runtime reads
196
+ it and it grants nothing. Detection was rejected deliberately — inferring it
197
+ from the body means a function that _looks_ like it checks something silences
198
+ the warning while checking nothing, and a warning that is usually wrong stops
199
+ being read.
200
+
201
+ **Breaking: `scaffold.<feature>` is now `boolean | { auth?, path? }`, and `true`
202
+ means authenticated.** The old `'auth' | 'no-auth' | false` read like a
203
+ starter-file preference while being a live authorization decision, set three
204
+ directories from the functions it governed — the shape the console incident
205
+ took. A surface now becomes public only by writing `{ auth: false }`, so
206
+ omitting a field can never open anything: the failure mode of a forgotten flag
207
+ is a locked door. `{ path }` additionally overrides where the file is
208
+ generated, which previously could only be set for all features at once via
209
+ `pikkuDir`.
210
+
211
+ The legacy strings are **refused, not coerced**. `resolveScaffoldFeature` throws
212
+ naming the key and its replacement (`"rpc": "no-auth"` → `"rpc": { "auth":
213
+ false }`), and it does so at config load, not downstream. An earlier design used
214
+ a bare `string` for the output path, under which `"no-auth"` would have parsed
215
+ as a file named `no-auth` and every unmigrated config would have silently
216
+ produced nonsense; the object form makes any string invalid, so the failure is
217
+ loud.
218
+
219
+ The collapse is deliberately not uniform in effect. For `rpc` the flag was a
220
+ blanket "no anonymous RPC in this app" set on a dispatcher that cannot know what
221
+ it dispatches to; for `userAdmin` it was redundant, since the generated
222
+ functions are already `pikkuFunc` with `scopes: ['admin:users:list']`. But for
223
+ `agent`, `workflow`, `events` and `scenarios` it is the only gate — those
224
+ generate real endpoints the app never authors — so `true` keeps them
225
+ authenticated rather than opening them as a side effect of a config cleanup.
226
+ `webhook` and `remoteRpc` have no auth dimension at all (`serialize-remote-rpc.ts`
227
+ hardcodes `auth: false`), so an `{ auth }` on them is ignored. The three
228
+ configs in this repo are migrated preserving their current behaviour exactly.
229
+
230
+ **Queue job identities are signed.** A job carried the producer's `pikkuUserId`
231
+ as a plain string and the worker resolved a session from it with no
232
+ verification, so write access to the queue backend was act-as-any-user. The
233
+ identity is now `pq1.<claim>.<hmac>`, HMAC-SHA256 over the claim and the
234
+ canonicalized job payload, keyed by HKDF expansion of a new
235
+ `PIKKU_QUEUE_IDENTITY_SECRET`. Producers opt in by wrapping their queue service
236
+ with `SignedQueueService`. This fails safe rather than closed: with no secret
237
+ configured the identity is dropped and jobs still process, warning once per
238
+ process, so no existing deployment breaks on upgrade — it simply loses queue
239
+ identity until the secret is set. The payload rather than the job id is bound
240
+ because SQS, Cloudflare Queues, Azure and the in-memory service all mint ids
241
+ after `add` returns.
242
+
243
+ **Workflow inline state is read from the run record.** `isInline` consulted a
244
+ process-local `Map`, while `WorkflowRun.inline` is durable. Any instance that
245
+ did not start a run disagreed with the record, so one instance could dispatch a
246
+ queued job for a workflow another was already executing in-process. It is now
247
+ async and resolves through the durable identity, cached only when a context
248
+ already exists so a passive reader allocates nothing. The same `Map` also leaked:
249
+ `nextStepKey` fabricated replay state on every step, and `releaseContext`
250
+ refused to free anything carrying it, so runs whose steps executed outside a
251
+ `beginReplay` bracket — the step-worker queue path — stranded their context and
252
+ step state for the process lifetime. Contexts are now released by an explicit
253
+ execution counter. Step ordinals reset per execution rather than accumulating
254
+ across step-worker invocations in one process, which makes step naming
255
+ independent of how work was distributed.
256
+
257
+ **Secret reads fail loud in every store.** `MongoDBSecretService.getSecrets`
258
+ skipped rows that failed to decrypt, and the redis equivalent dropped every
259
+ rejection via `Promise.allSettled`, including the "No KEK available for
260
+ key_version N" configuration error. Both now throw, naming the key and its key
261
+ version, matching the kysely behaviour. This matters most alongside the KEK
262
+ change above: without it, an upgrade surfaces as a partial secrets map and an
263
+ opaque downstream failure instead of an error naming the secret to re-enter.
264
+
265
+ **A second middleware registration for a pattern no longer erases the first.**
266
+ `addHTTPMiddleware`, `addTagMiddleware` and `addChannelMiddleware` groups are
267
+ keyed by pattern or tag and held one source file each, so a second file's call
268
+ overwrote the first's. Codegen emits its imports from what is stored, so the
269
+ losing file was never imported and its middleware never registered — the
270
+ runtime composes repeated registrations for a pattern happily, and only codegen
271
+ dropped one. Adding an unrelated `addHTTPMiddleware('*', …)` to an app was
272
+ enough to silently unregister the generated better-auth session bridge, which
273
+ fails open and gives no sign until a request arrives without a session. A group
274
+ now carries every registration made for it, and all of them are imported.
275
+
276
+ - Updated dependencies [6a307f0]
277
+ - Updated dependencies [afef587]
278
+ - Updated dependencies [8075f6a]
279
+ - @pikku/core@0.12.74
280
+
281
+ ## 0.12.3
282
+
283
+ ### Patch Changes
284
+
285
+ - daec082: Drop Node 22 support — the minimum supported runtime is now Node 24 (LTS).
286
+
287
+ 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.
288
+
289
+ - Updated dependencies [7b17b14]
290
+ - Updated dependencies [daec082]
291
+ - Updated dependencies [e0fd352]
292
+ - @pikku/core@0.12.58
293
+
1
294
  ## 0.12.2
2
295
 
3
296
  ### Patch Changes
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 - present Yasser Fadl and Pikku contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -0,0 +1,35 @@
1
+ # @pikku/azure-functions
2
+
3
+ Azure Functions runtime for Pikku — HTTP, timer and storage-queue handlers,
4
+ plus `AzureQueueService`.
5
+
6
+ ## Install
7
+
8
+ ```bash
9
+ npm install @pikku/azure-functions
10
+ ```
11
+
12
+ ## Usage
13
+
14
+ ```typescript
15
+ import { app } from '@azure/functions'
16
+ import { createAzureHandler } from '@pikku/azure-functions'
17
+
18
+ import './.pikku/pikku-bootstrap.gen.js'
19
+
20
+ const handlers = createAzureHandler(factories, ['fetch'])
21
+
22
+ app.http('pikku', {
23
+ route: '{*path}',
24
+ authLevel: 'anonymous',
25
+ handler: handlers.http,
26
+ })
27
+ ```
28
+
29
+ `createAzureWorkerHandler` and `createAzureWebSocketHandler` cover queue and
30
+ WebSocket units. Use `@pikku/deploy-azure` to generate `host.json` and the
31
+ infra manifest.
32
+
33
+ ## Docs
34
+
35
+ https://pikku.dev/docs
@@ -1,4 +1,4 @@
1
- import { encryptJSON } from '@pikku/core/crypto-utils';
1
+ import { buildRemoteHeaders } from '@pikku/core/remote';
2
2
  export class AzureDeploymentService {
3
3
  jwt;
4
4
  secrets;
@@ -17,27 +17,7 @@ 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 = {
21
- 'content-type': 'application/json',
22
- ...(traceId && { 'x-request-id': traceId }),
23
- };
24
- let secret;
25
- try {
26
- secret = await this.secrets.getSecret('PIKKU_REMOTE_SECRET');
27
- }
28
- catch { }
29
- if (secret && this.jwt) {
30
- const sessionEnc = session
31
- ? await encryptJSON(secret, { session })
32
- : undefined;
33
- const token = await this.jwt.encode({ value: 5, unit: 'minute' }, {
34
- aud: 'pikku-remote',
35
- fn: funcName,
36
- iat: Math.floor(Date.now() / 1000),
37
- session: sessionEnc,
38
- });
39
- headers.authorization = `Bearer ${token}`;
40
- }
20
+ const headers = await buildRemoteHeaders(this.jwt, this.secrets, funcName, session, traceId);
41
21
  const url = `${functionUrl}/remote/rpc/${encodeURIComponent(funcName)}`;
42
22
  const response = await fetch(url, {
43
23
  method: 'POST',
@@ -1 +1 @@
1
- {"version":3,"file":"azure-deployment-service.js","sourceRoot":"","sources":["../src/azure-deployment-service.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAEtD,MAAM,OAAO,sBAAsB;IAIvB;IACA;IAJF,QAAQ,CAAqB;IAErC,YACU,GAA2B,EAC3B,OAAsB,EAC9B,gBAAwC;QAFhC,QAAG,GAAH,GAAG,CAAwB;QAC3B,YAAO,GAAP,OAAO,CAAe;QAG9B,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAA;IAC3D,CAAC;IAED,KAAK,CAAC,IAAI,KAAmB,CAAC;IAC9B,KAAK,CAAC,KAAK,CAAC,OAAyB,IAAkB,CAAC;IACxD,KAAK,CAAC,IAAI,KAAmB,CAAC;IAE9B,KAAK,CAAC,MAAM,CACV,QAAgB,EA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.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@pikku/azure-functions",
3
- "version": "0.12.2",
3
+ "version": "0.12.4",
4
+ "description": "Azure Functions runtime for Pikku — HTTP, timer and storage-queue handlers",
4
5
  "license": "MIT",
5
6
  "author": "yasser.fadl@gmail.com",
6
7
  "module": "dist/index.js",
@@ -17,13 +18,13 @@
17
18
  "prepublishOnly": "yarn build"
18
19
  },
19
20
  "peerDependencies": {
20
- "@pikku/core": "^0.12.44"
21
+ "@pikku/core": "^0.12.74"
21
22
  },
22
23
  "devDependencies": {
23
24
  "typescript": "^6.0.3"
24
25
  },
25
26
  "engines": {
26
- "node": ">=22"
27
+ "node": ">=24"
27
28
  },
28
29
  "dependencies": {
29
30
  "@azure/functions": "4.11.2",
package/run-tests.sh CHANGED
@@ -38,16 +38,16 @@ if [ ${#files[@]} -eq 0 ]; then
38
38
  fi
39
39
 
40
40
  # Construct the node command
41
- node_cmd="node --import tsx --test"
41
+ node_cmd=(node --import tsx --test)
42
42
 
43
43
  # Append options based on flags
44
44
  if [ "$watch_mode" = true ]; then
45
- node_cmd="$node_cmd --watch"
45
+ node_cmd+=(--watch)
46
46
  fi
47
47
 
48
48
  if [ "$coverage_mode" = true ]; then
49
- node_cmd="$node_cmd --test-coverage-include=\"src/**/*.{ts,js}\" --test-coverage-exclude=\"**/dist/**\" --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=lcov.info"
49
+ node_cmd+=(--test-coverage-include="src/**/*.{ts,js}" --test-coverage-exclude="**/dist/**" --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=lcov.info)
50
50
  fi
51
51
 
52
52
  # Execute the node command with the expanded list of files
53
- $node_cmd "${files[@]}"
53
+ "${node_cmd[@]}" "${files[@]}"
@@ -12,7 +12,7 @@
12
12
  import type { DeploymentService, DeploymentConfig } from '@pikku/core/services'
13
13
  import type { JWTService } from '@pikku/core/services'
14
14
  import type { SecretService } from '@pikku/core/services'
15
- import { encryptJSON } from '@pikku/core/crypto-utils'
15
+ import { buildRemoteHeaders } from '@pikku/core/remote'
16
16
 
17
17
  export class AzureDeploymentService implements DeploymentService {
18
18
  private bindings: Map<string, string>
@@ -43,32 +43,13 @@ export class AzureDeploymentService implements DeploymentService {
43
43
  )
44
44
  }
45
45
 
46
- const headers: Record<string, string> = {
47
- 'content-type': 'application/json',
48
- ...(traceId && { 'x-request-id': traceId }),
49
- }
50
-
51
- // Sign session as JWT for pikkuRemoteAuthMiddleware
52
- let secret: string | undefined
53
- try {
54
- secret = await this.secrets.getSecret('PIKKU_REMOTE_SECRET')
55
- } catch {}
56
-
57
- if (secret && this.jwt) {
58
- const sessionEnc = session
59
- ? await encryptJSON(secret, { session })
60
- : undefined
61
- const token = await this.jwt.encode(
62
- { value: 5, unit: 'minute' },
63
- {
64
- aud: 'pikku-remote',
65
- fn: funcName,
66
- iat: Math.floor(Date.now() / 1000),
67
- session: sessionEnc,
68
- }
69
- )
70
- headers.authorization = `Bearer ${token}`
71
- }
46
+ const headers = await buildRemoteHeaders(
47
+ this.jwt,
48
+ this.secrets,
49
+ funcName,
50
+ session,
51
+ traceId
52
+ )
72
53
 
73
54
  const url = `${functionUrl}/remote/rpc/${encodeURIComponent(funcName)}`
74
55
  const response = await fetch(url, {