@astrale-os/adapter-cloudflare 0.3.0 → 0.3.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrale-os/adapter-cloudflare",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Deploy an Astrale domain as a standalone Cloudflare Worker",
5
5
  "keywords": [
6
6
  "adapter",
@@ -97,11 +97,12 @@ adapter-owned keys `name`, `main`, `assets`, `routes` are rejected (use
97
97
 
98
98
  - **Edit a handler** (`core/` logic or `runtime/` wiring) → hot-reloads at the same URL. Nothing to reinstall.
99
99
  - **Edit the schema** (`schema/`) → rebuilds the graph; reinstall with `astrale domain install <url> --direct`.
100
- - **`postInstall`** (the static `Monitor.seed` method) runs once after install, as
101
- the system identity, so the domain can seed `/monitoring/monitors` and
102
- `/monitoring/pages/status` and set its own grants. It
103
- must be a class-hosted static addressed by a typed colon-path
104
- (`/:origin:class.X:seed`)the kernel refuses tree paths here.
100
+ - **`postInstall`** (the standalone `seed` function in `functions/`) runs once
101
+ after install, as the system identity, so the domain can seed
102
+ `/monitoring/monitors` and `/monitoring/pages/status` and set its own grants.
103
+ `domain.ts` references it directly (`postInstall: functions.seed`) and the SDK
104
+ derives its path functions are first-class domain members, addressable at
105
+ `/:origin:function.seed`.
105
106
 
106
107
  ## Identity
107
108
 
@@ -10,11 +10,13 @@
10
10
  * A standalone function's `execute` receives the same request context as a
11
11
  * method MINUS `self` (it is not node-bound): `{ params, kernel, deps, auth, … }`.
12
12
  */
13
- import { defineRemoteFunction } from '@astrale-os/sdk'
13
+ import { __SYSTEM__ } from '@astrale-os/kernel-core'
14
+ import { assertPerm, defineRemoteFunction, EDIT } from '@astrale-os/sdk'
14
15
  import { z } from 'zod'
15
16
 
16
17
  import type { Deps } from '../deps'
17
18
 
19
+ import { MONITORS_PARENT } from '../core/monitor'
18
20
  import { monitor } from '../runtime/monitoring'
19
21
 
20
22
  export const functions = {
@@ -23,11 +25,21 @@ export const functions = {
23
25
  // function's own identity), so the domain comes up demonstrable. Must stay
24
26
  // idempotent — a re-install runs it again. `auth: 'required'` (the default)
25
27
  // makes `ctx.kernel` non-null; the body delegates to the per-operation seed
26
- // logic in `runtime/monitor/seed.ts`.
28
+ // logic in `runtime/monitoring/monitor/seed.ts`.
27
29
  seed: defineRemoteFunction<Record<string, never>, { seeded: number }, Deps>({
28
30
  inputSchema: z.object({}),
29
31
  outputSchema: z.object({ seeded: z.number().int() }),
30
- authorize: async () => undefined,
32
+ // Additive throw-to-deny pre-check (the kernel ALSO enforces `has_perm` on the
33
+ // create downstream — this just fails fast with the exact target). Two cases:
34
+ // • postInstall runs as __SYSTEM__ (full authority) and on the FIRST install
35
+ // `/monitoring/monitors` doesn't exist yet — seed creates it — so the
36
+ // short-circuit MUST skip the check, or first install would wrongly deny.
37
+ // • A later DIRECT call carries a real principal (and by then the folder
38
+ // exists), so require EDIT — the bit a child-create under it needs.
39
+ authorize: async ({ kernel, auth }) => {
40
+ if (auth.principal === __SYSTEM__) return
41
+ await assertPerm(kernel, MONITORS_PARENT, auth.principal, EDIT)
42
+ },
31
43
  execute: ({ kernel, deps }) => monitor.seed(kernel, deps.prober()),
32
44
  }),
33
45
  }
@@ -14,8 +14,8 @@
14
14
  "typecheck": "tsgo --noEmit"
15
15
  },
16
16
  "dependencies": {
17
- "@astrale-os/adapter-cloudflare": ">=0.3.0 <1.0.0",
18
- "@astrale-os/kernel-core": ">=0.4.3 <1.0.0",
17
+ "@astrale-os/adapter-cloudflare": ">=0.3.1 <1.0.0",
18
+ "@astrale-os/kernel-core": ">=0.5.0 <1.0.0",
19
19
  "@astrale-os/kernel-dsl": ">=0.1.2 <1.0.0",
20
20
  "@astrale-os/sdk": ">=0.2.0 <1.0.0",
21
21
  "@hono/node-server": "^1.19.0",