@cloudhal/cloudflare 0.5.0 → 0.6.0
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/dist/src/admin-worker.js +4 -4
- package/dist/src/features.d.ts +8 -5
- package/dist/src/features.js +23 -12
- package/package.json +10 -10
package/dist/src/admin-worker.js
CHANGED
|
@@ -284,8 +284,8 @@ export function createAdminWorker(options = {}) {
|
|
|
284
284
|
let migrated = false;
|
|
285
285
|
/** The request backstop's isolate state (RFC-0008 §8.6); plain numbers. */
|
|
286
286
|
const backstop = { lastCheck: 0, lastRun: 0 };
|
|
287
|
-
/** The site Worker confirmed
|
|
288
|
-
let gatesConfirmed =
|
|
287
|
+
/** The gates version the site Worker confirmed (RFC-0008 §7.7, RFC-0042 §3.6); 0: none yet. */
|
|
288
|
+
let gatesConfirmed = 0;
|
|
289
289
|
const ensureMigrated = async (sql ) => {
|
|
290
290
|
if (migrated) return;
|
|
291
291
|
try {
|
|
@@ -387,8 +387,8 @@ export function createAdminWorker(options = {}) {
|
|
|
387
387
|
: undefined,
|
|
388
388
|
token: purgeToken,
|
|
389
389
|
confirmed: () => gatesConfirmed,
|
|
390
|
-
remember: () => {
|
|
391
|
-
gatesConfirmed =
|
|
390
|
+
remember: (version) => {
|
|
391
|
+
gatesConfirmed = version;
|
|
392
392
|
},
|
|
393
393
|
log,
|
|
394
394
|
}),
|
package/dist/src/features.d.ts
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* What the site Worker enforces, asked over the `SITE` binding (RFC-0008 §7.6–§7.7). An older site
|
|
3
3
|
* Worker ignores time gates and would show embargoed content, so the admin Worker lets nobody
|
|
4
4
|
* write `availability` (REST, MCP, bundle import) until the site Worker answers
|
|
5
|
-
* `GET /__cloudhal/features` with `{ "gates": 1 }` or more (invariant S15)
|
|
5
|
+
* `GET /__cloudhal/features` with `{ "gates": 1 }` or more (invariant S15), nor a collection's
|
|
6
|
+
* `expiry` until it answers `{ "gates": 2 }` (derived gates, RFC-0042 §3.6).
|
|
6
7
|
*/
|
|
7
8
|
import { type GateSupport } from "@cloudhal/core-ts/availability";
|
|
8
9
|
import type { SiteFetch } from "./purge.js";
|
|
@@ -12,13 +13,15 @@ export declare function siteFeatures(fetch: SiteFetch, token: string): Promise<{
|
|
|
12
13
|
} | undefined>;
|
|
13
14
|
/**
|
|
14
15
|
* The store's gate capability for one admin Worker isolate. A confirmation is remembered as a
|
|
15
|
-
* plain value (`remember`/`confirmed`, nothing awaited across requests, ADR-0012)
|
|
16
|
-
*
|
|
16
|
+
* plain value (`remember`/`confirmed`, nothing awaited across requests, ADR-0012): the gates
|
|
17
|
+
* version the site Worker reported (`true` reads as 1, what Workers before RFC-0042 answered). A
|
|
18
|
+
* refusal or an error is asked again on the next write that needs gates, so deploying the site
|
|
19
|
+
* Worker is enough.
|
|
17
20
|
*/
|
|
18
21
|
export declare function siteGateSupport(options: {
|
|
19
22
|
readonly fetch: SiteFetch | undefined;
|
|
20
23
|
readonly token: string | undefined;
|
|
21
|
-
readonly confirmed: () => boolean;
|
|
22
|
-
readonly remember: () => void;
|
|
24
|
+
readonly confirmed: () => boolean | number;
|
|
25
|
+
readonly remember: (version: number) => void;
|
|
23
26
|
readonly log?: (line: string) => void;
|
|
24
27
|
}): GateSupport;
|
package/dist/src/features.js
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
* What the site Worker enforces, asked over the `SITE` binding (RFC-0008 §7.6–§7.7). An older site
|
|
3
3
|
* Worker ignores time gates and would show embargoed content, so the admin Worker lets nobody
|
|
4
4
|
* write `availability` (REST, MCP, bundle import) until the site Worker answers
|
|
5
|
-
* `GET /__cloudhal/features` with `{ "gates": 1 }` or more (invariant S15)
|
|
5
|
+
* `GET /__cloudhal/features` with `{ "gates": 1 }` or more (invariant S15), nor a collection's
|
|
6
|
+
* `expiry` until it answers `{ "gates": 2 }` (derived gates, RFC-0042 §3.6).
|
|
6
7
|
*/
|
|
7
|
-
import {
|
|
8
|
+
import { AVAILABILITY_GATES_VERSION, } from "@cloudhal/core-ts/availability";
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
const FEATURES_URL = "https://site.internal/__cloudhal/features";
|
|
@@ -28,27 +29,37 @@ export async function siteFeatures(
|
|
|
28
29
|
|
|
29
30
|
/**
|
|
30
31
|
* The store's gate capability for one admin Worker isolate. A confirmation is remembered as a
|
|
31
|
-
* plain value (`remember`/`confirmed`, nothing awaited across requests, ADR-0012)
|
|
32
|
-
*
|
|
32
|
+
* plain value (`remember`/`confirmed`, nothing awaited across requests, ADR-0012): the gates
|
|
33
|
+
* version the site Worker reported (`true` reads as 1, what Workers before RFC-0042 answered). A
|
|
34
|
+
* refusal or an error is asked again on the next write that needs gates, so deploying the site
|
|
35
|
+
* Worker is enough.
|
|
33
36
|
*/
|
|
34
37
|
export function siteGateSupport(options
|
|
35
38
|
|
|
36
39
|
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
|
|
41
|
+
|
|
39
42
|
|
|
40
43
|
) {
|
|
44
|
+
const known = () => {
|
|
45
|
+
const c = options.confirmed();
|
|
46
|
+
return c === true ? AVAILABILITY_GATES_VERSION : c === false ? 0 : c;
|
|
47
|
+
};
|
|
41
48
|
return {
|
|
42
|
-
enforced: async () => {
|
|
43
|
-
if (
|
|
49
|
+
enforced: async (_siteId, version = AVAILABILITY_GATES_VERSION) => {
|
|
50
|
+
if (known() >= version) return true;
|
|
44
51
|
if (!options.fetch || !options.token) return false;
|
|
45
52
|
try {
|
|
46
|
-
const
|
|
47
|
-
if (
|
|
48
|
-
|
|
53
|
+
const gates = (await siteFeatures(options.fetch, options.token))?.gates ?? 0;
|
|
54
|
+
if (gates > known() && gates >= AVAILABILITY_GATES_VERSION) options.remember(gates);
|
|
55
|
+
if (gates < version) {
|
|
56
|
+
options.log?.(
|
|
57
|
+
version > AVAILABILITY_GATES_VERSION
|
|
58
|
+
? "site Worker does not enforce derived gates yet: collection expiry is refused"
|
|
59
|
+
: "site Worker does not enforce time gates yet: availability is refused",
|
|
60
|
+
);
|
|
49
61
|
return false;
|
|
50
62
|
}
|
|
51
|
-
options.remember();
|
|
52
63
|
return true;
|
|
53
64
|
} catch (e) {
|
|
54
65
|
options.log?.(`features check failed: ${e instanceof Error ? e.message : String(e)}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudhal/cloudflare",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Cloudhal on Cloudflare: the admin Worker (API, auth, MCP, Studio) over D1 + R2",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://cloudhal.dev",
|
|
@@ -48,19 +48,19 @@
|
|
|
48
48
|
"README.md"
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@cloudhal/agent-runtime": "0.
|
|
52
|
-
"@cloudhal/analytics": "0.
|
|
53
|
-
"@cloudhal/api": "0.
|
|
54
|
-
"@cloudhal/comments": "0.
|
|
55
|
-
"@cloudhal/core-ts": "0.
|
|
56
|
-
"@cloudhal/mcp-server": "0.
|
|
57
|
-
"@cloudhal/schedules": "0.
|
|
58
|
-
"@cloudhal/storage": "0.
|
|
51
|
+
"@cloudhal/agent-runtime": "0.6.0",
|
|
52
|
+
"@cloudhal/analytics": "0.6.0",
|
|
53
|
+
"@cloudhal/api": "0.6.0",
|
|
54
|
+
"@cloudhal/comments": "0.6.0",
|
|
55
|
+
"@cloudhal/core-ts": "0.6.0",
|
|
56
|
+
"@cloudhal/mcp-server": "0.6.0",
|
|
57
|
+
"@cloudhal/schedules": "0.6.0",
|
|
58
|
+
"@cloudhal/storage": "0.6.0",
|
|
59
59
|
"zod": "^4.6.5"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@cloudflare/workers-types": "^5.20261007.1",
|
|
63
|
-
"@cloudhal/astro-renderer": "0.
|
|
63
|
+
"@cloudhal/astro-renderer": "0.6.0",
|
|
64
64
|
"@types/node": "^26.6.5",
|
|
65
65
|
"typescript": "7.0.2",
|
|
66
66
|
"vitest": "5.0.3",
|