@zackbart/connecta 0.37.0 → 0.38.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/CHANGELOG.md +80 -0
- package/README.md +2 -2
- package/bin/connecta.mjs +1 -39
- package/bin/version.mjs +1 -1
- package/dist/access-tokens.js +2 -4
- package/dist/agent-identity.js +1 -1
- package/dist/auth/clerk-sdk/generated.js +2 -1
- package/dist/auth/cloudflare-access.d.ts +3 -1
- package/dist/auth/cloudflare-access.js +22 -11
- package/dist/auth/downstream-oauth.js +195 -270
- package/dist/auth/downstream-revocation.js +1 -1
- package/dist/auth/oauth-grant.js +11 -0
- package/dist/auth/oauth-token-response.js +1 -1
- package/dist/auth/vercel-agent.js +2 -1
- package/dist/auth-elicitation.js +2 -2
- package/dist/branding.d.ts +1 -15
- package/dist/branding.js +2 -2
- package/dist/bytes.js +42 -0
- package/dist/call-admission-context.js +2 -5
- package/dist/call-admission.js +5 -0
- package/dist/call-recovery.js +0 -3
- package/dist/catalog-cache.js +26 -7
- package/dist/catalog-fingerprint.js +2 -18
- package/dist/catalog-revision.js +9 -0
- package/dist/catalog-service.js +51 -20
- package/dist/config-defaults.d.ts +1 -0
- package/dist/config-defaults.js +1 -0
- package/dist/config-schema.d.ts +1 -1
- package/dist/config-schema.js +6 -2
- package/dist/config.d.ts +41 -14
- package/dist/config.js +21 -71
- package/dist/connector-caller.js +1 -1
- package/dist/connectors/api-connector.js +4 -3
- package/dist/connectors/guarded-fetch.d.ts +0 -6
- package/dist/connectors/guarded-fetch.js +1 -11
- package/dist/connectors/remote-mcp.js +93 -69
- package/dist/connectors/resource-uri.js +0 -4
- package/dist/credentials.js +3 -0
- package/dist/d1.d.ts +0 -89
- package/dist/d1.js +0 -34
- package/dist/downstream-input.js +2 -2
- package/dist/execute.js +161 -116
- package/dist/executor-result.js +2 -1
- package/dist/executors/quickjs-runtime.js +2 -25
- package/dist/executors/quickjs.js +1 -1
- package/dist/guest-runtime.js +5 -3
- package/dist/guest-types.d.ts +5 -5
- package/dist/http/client.js +1 -1
- package/dist/http/errors.js +2 -2
- package/dist/http/json-schema.js +1 -1
- package/dist/http/node-transport.js +0 -1
- package/dist/http/oauth.js +1 -1
- package/dist/http/paging.js +6 -9
- package/dist/http/provider.js +1 -1
- package/dist/http/safety.js +1 -1
- package/dist/http/services.js +1 -8
- package/dist/http/tools.js +1 -7
- package/dist/http/vendor.js +7 -7
- package/dist/identity.js +2 -6
- package/dist/index.js +1 -2
- package/dist/invocation-auth.js +2 -1
- package/dist/invocation.js +8 -2
- package/dist/meta-tools.js +27 -27
- package/dist/native-tools.js +2 -1
- package/dist/oauth-handoff.js +2 -2
- package/dist/operation-vocabulary.js +1 -1
- package/dist/operator-record.d.ts +8 -2
- package/dist/operator-record.js +18 -50
- package/dist/operator-ui/contract.d.ts +4 -2
- package/dist/operator-ui/generated.js +3 -3
- package/dist/operator-ui/model.d.ts +7 -2
- package/dist/program-writes.js +3 -8
- package/dist/provider-call.js +0 -7
- package/dist/provider.d.ts +1 -1
- package/dist/providers/_shared/google/kit.js +1 -6
- package/dist/providers/_shared/google/service-account.js +1 -3
- package/dist/providers/_shared/google/workspace.d.ts +1 -1
- package/dist/providers/_shared/guide.js +3 -0
- package/dist/providers/_shared/json.js +12 -0
- package/dist/providers/_shared/rest/compact-index.js +1 -1
- package/dist/providers/_shared/rest/kit.js +1 -3
- package/dist/providers/_shared/rest/operation-index.js +1 -3
- package/dist/providers/_shared/rest/value-safety.js +26 -28
- package/dist/providers/breeze/api.js +2 -7
- package/dist/providers/breeze/index.js +4 -2
- package/dist/providers/breeze/tools.js +3 -4
- package/dist/providers/ccb/api.js +1 -6
- package/dist/providers/ccb/index.js +2 -1
- package/dist/providers/ccb/tools.js +1 -6
- package/dist/providers/cloudflare/api.js +2 -2
- package/dist/providers/cloudflare/index.js +2 -1
- package/dist/providers/cloudflare/safety.js +3 -3
- package/dist/providers/docs/tools.js +2 -10
- package/dist/providers/drive/tools.js +12 -25
- package/dist/providers/forms/tools.js +1 -9
- package/dist/providers/gmail/tools.js +5 -21
- package/dist/providers/overflow/api.js +1 -3
- package/dist/providers/overflow/index.js +2 -1
- package/dist/providers/overflow/tools.js +3 -7
- package/dist/providers/planning-center/api.js +2 -1
- package/dist/providers/planning-center/lib/constants.d.ts +1 -1
- package/dist/providers/planning-center/lib/json-api.js +1 -9
- package/dist/providers/planning-center/tools.js +2 -1
- package/dist/providers/sheets/tools.js +1 -9
- package/dist/providers/slides/tools.js +4 -13
- package/dist/providers/stripe/index.js +2 -1
- package/dist/providers/stripe/safety.js +2 -2
- package/dist/providers/tithely/api.js +2 -7
- package/dist/providers/tithely/index.js +3 -2
- package/dist/providers/tithely/tools.js +7 -5
- package/dist/providers/vercel/api.js +1 -6
- package/dist/providers/vercel/lib/pin.js +1 -1
- package/dist/providers/vercel/safety.js +1 -1
- package/dist/providers/vercel/tools.js +2 -1
- package/dist/redaction-marker.js +2 -2
- package/dist/registry.d.ts +4 -1
- package/dist/registry.js +35 -22
- package/dist/request-principal.js +15 -2
- package/dist/request-state.js +2 -2
- package/dist/routes/access-tokens.js +1 -1
- package/dist/routes/activity-disclosure.js +1 -1
- package/dist/routes/connect.js +2 -2
- package/dist/routes/credentials.js +1 -1
- package/dist/routes/dispatch.js +10 -0
- package/dist/routes/mcp.js +23 -21
- package/dist/routes/oauth-management.js +1 -1
- package/dist/routes/operator.js +53 -7
- package/dist/routes/shared.d.ts +8 -8
- package/dist/routes/shared.js +22 -15
- package/dist/routes/ui-config.js +6 -6
- package/dist/routes/ui-data.js +2 -2
- package/dist/routes/ui.js +9 -4
- package/dist/runtime/call-admission.js +1 -1
- package/dist/runtime/call.js +1 -1
- package/dist/runtime/settlement.js +1 -1
- package/dist/runtime/shared-read.js +2 -15
- package/dist/sent-secrets.d.ts +14 -6
- package/dist/sent-secrets.js +231 -85
- package/dist/server.js +4 -4
- package/dist/skills.js +8 -35
- package/dist/sqlite.d.ts +0 -19
- package/dist/sqlite.js +2 -83
- package/dist/storage/keys.js +29 -124
- package/dist/storage/sql-native.js +14 -111
- package/dist/storage/sql.d.ts +1 -24
- package/dist/storage/sql.js +1 -12
- package/dist/tool-error.js +4 -0
- package/dist/types.d.ts +4 -3
- package/dist/ui.js +3 -0
- package/dist/url-safety.js +0 -4
- package/dist/usage-guide.js +2 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worker.js +1 -1
- package/documentation/README.md +6 -42
- package/documentation/architecture.md +190 -507
- package/documentation/auth.md +172 -58
- package/documentation/code-mode.md +98 -66
- package/documentation/deploying.md +19 -40
- package/documentation/integrating.md +8 -19
- package/documentation/meta-tools.md +23 -6
- package/documentation/migration-0.33.md +5 -5
- package/documentation/migration-0.34.md +2 -4
- package/documentation/migration-retired-layouts.md +74 -0
- package/documentation/operator-tests.md +19 -119
- package/documentation/operator-ui.md +46 -8
- package/documentation/provider-auth-migration.md +4 -10
- package/documentation/provider-migration-0.29.md +4 -15
- package/examples/worker/AGENTS.md +4 -6
- package/examples/worker/README.md +20 -115
- package/guides/connecting-agents.md +7 -30
- package/guides/how-it-works.md +2 -2
- package/guides/safety-and-trust.md +4 -1
- package/package.json +19 -19
- package/templates/node/README.md +9 -26
- package/templates/node/package.json +1 -1
- package/dist/auth/oauth-v2-migration.js +0 -135
- package/dist/provider-call-facts.d.ts +0 -115
- package/dist/provider-call.d.ts +0 -112
- package/dist/storage/d1-copy.js +0 -255
- package/dist/storage/sql-schema.d.ts +0 -6
- package/examples/worker/kv-to-d1.wrangler.jsonc +0 -26
- package/examples/worker/scripts/copy-kv-to-d1.mjs +0 -162
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,86 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this package are documented here.
|
|
4
4
|
|
|
5
|
+
## 0.38.0 — 2026-10-28
|
|
6
|
+
|
|
7
|
+
0.38.0 is a minor release that retires the old storage and OAuth layout migrations, adds a configurable program return cap, makes in-program skill calls more forgiving, and moves the Eve helper to Eve 0.86.
|
|
8
|
+
|
|
9
|
+
Breaking: the pre-layout-3 OAuth grant converter, the Workers KV → D1 copy APIs and script, and the Node JSON-state import API and `connecta migrate-state` command are removed. A deployment still holding old state must first upgrade through 0.37.1, run `copyKvToD1` or `migrate-state` as needed, and open every OAuth grant once on that version before moving to 0.38.0; otherwise old OAuth grants need fresh consent and old KV or JSON state is not imported. Retired pause, identity, grant and trust options still fail construction, now as ordinary unknown options without migration hints. `documentation/migration-retired-layouts.md` covers verification and recovery. Deployments that already run on 0.37.x layouts need no change.
|
|
10
|
+
|
|
11
|
+
`execute.maxResultChars` sets how many serialized characters an `execute_code` program may return before Connecta pages it. The default stays 24,000, and paging notices now ask for pages sized to the configured cap. Programs can call `connecta.skill({ name })` and `connecta.skills(...)` as well as `connecta.skill(name)`, and the `execute_code` description states each host-call deadline truthfully when call and host-call timeouts differ.
|
|
12
|
+
|
|
13
|
+
Also breaking: `@zackbart/connecta-eve` now requires Eve `>=0.86.0 <0.87.0`, so Eve 0.84 apps upgrade Eve to 0.86.0 together with the helper. Eve 0.86.0 still pins undici 8.10.2, so pnpm apps rekey their override to `"eve@0.86.0>undici": "8.12.3"`; npm apps keep the same override. The rest of the release is contributor-facing: refreshed development dependencies, a slimmer test suite, consolidated internals and trimmed documentation, with no runtime behavior change.
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- Add `execute.maxResultChars`, the serialized characters an `execute_code` program may return before Connecta stashes the return behind a paging notice. The default stays 24,000; values from 4,000 to 1,000,000 are accepted, and anything else fails at construction. Emitted text shares the configured cap, and the paging notices that `execute_code` and direct calls return ask for pages sized to it instead of a fixed 3,829 bytes, never more than the stashed call's `maxResultBytes` or the 32 KiB bridge ceiling. A connector whose cap is below 3,829 bytes now gets a notice asking for the page size it actually serves. `describeConfig()` and the operator settings report it. Stash pages still obey each call's `maxResultBytes`. Connecta has no response-size limit, so keep the cap below what every client accepts: Claude Code passes at most 50,000 characters of text.
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- Accept the shapes models copy from the top-level `skills` tool into programs. `connecta.skill({ name })` now works like `connecta.skill(name)`, and `connecta.skills` is an undeclared alias of `connecta.skill` with the same host-call accounting, so neither costs a failed run. Any other argument fails `invalid_args` naming `connecta.skill("usage")`. The `execute_code` description, the server instructions, the usage guide and the program-error hint now show the in-program form `connecta.skill("usage")` and call the top-level one the skills tool, instead of giving `skills({ name: "usage" })` beside the guest API.
|
|
22
|
+
- Consolidate internal helpers and remove unused code without changing runtime behavior.
|
|
23
|
+
- Trim historical narration and duplicate procedures from documentation, correct contributor evidence references, and remove unreferenced eval baselines.
|
|
24
|
+
- Refresh development dependencies: TypeScript 6.0, Vitest 5 with Vite 8.3, `@cloudflare/vitest-plugin` 1.4 (renamed from `@cloudflare/vitest-pool-workers`) with Wrangler 4.151, Playwright 1.64, and current oxlint, oxfmt, knip, esbuild, tsx, React and Radix releases, in core and the Eve helper. Published dependency and peer ranges are unchanged, and deployments need no change.
|
|
25
|
+
- **Breaking:** `@zackbart/connecta-eve` now requires Eve 0.86 (`>=0.86.0 <0.87.0`) and is tested against Eve 0.86.0; Eve 0.84 apps must upgrade Eve to 0.86.0 together with the helper. Eve 0.86.0 still pins undici 8.10.2, so pnpm apps rekey their override to `"eve@0.86.0>undici": "8.12.3"`; npm apps keep the same override.
|
|
26
|
+
- Contributor test suite slimmed: about 100 regression, lifetime, parity and meta-guard suites are removed, and workerd now runs only the suites that need real Workers bindings or isolates. No runtime behavior changes.
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
|
|
30
|
+
- The `execute_code` description no longer overstates the deadline of `connecta.result`, `connecta.skill` and `connecta.read`. When `calls.defaultTimeoutMs` differs from `execute.hostCallTimeoutMs`, it states both, for example `Limits: 20 host calls, 10 writes, 25s/call (15s result/skill/read).`, instead of advertising the call default for every host call. Enforcement is unchanged; deployments without `calls.defaultTimeoutMs` see the same `15s/host call` text as before.
|
|
31
|
+
|
|
32
|
+
### Removed
|
|
33
|
+
|
|
34
|
+
- **Breaking:** Remove the pre-layout-3 OAuth grant converter and cleanup, Workers KV → D1 copy APIs/types/script, and Node JSON-state import API and `connecta migrate-state` command. Retired pause, identity, grant, and trust options still fail construction as ordinary unknown options, without migration hints. Before upgrading, deployments with old state must upgrade through 0.37.1, run `copyKvToD1` or `migrate-state` as needed, and open every OAuth grant once on that version. Old OAuth grants otherwise require fresh consent; old KV/JSON state is not imported. Follow `documentation/migration-retired-layouts.md` for verification and recovery.
|
|
35
|
+
|
|
36
|
+
## 0.37.1 — 2026-10-28
|
|
37
|
+
|
|
38
|
+
0.37.1 is a patch release of fixes and request-path performance work. It needs no configuration change, and deployments on 0.37.0 can upgrade in place. One type change is additive: connector status gains a `per_caller` state, so code that switches exhaustively over status states must handle it.
|
|
39
|
+
|
|
40
|
+
The headline fix is #1118: `execute_code` could return `hostCalls.failed` (and other numbers beside a redacted string) as `"[redacted]"`, which broke the tool's own output schema, so MCP clients that validate structured content rejected the whole result. Redaction now keeps a number unless it still holds part of a registered form after the strings around it are replaced, and Connecta's own counters are attached after redaction. Redaction also now rechecks a lane after every placeholder replacement until nothing changes, and typed arrays no longer hide a run split across them and their neighbours, so the documented guarantee holds in those corners too.
|
|
41
|
+
|
|
42
|
+
If a remote MCP connector forwards the admitted principal (`auth.principal`), its resolver's token is registered as a credential, and every eight-unit run of it is withheld from agent output for that request. Return an opaque reference, such as the principal id or a signed assertion, never an email or anything containing the deployment's own domain or names.
|
|
43
|
+
|
|
44
|
+
Security: a remote MCP OAuth challenge naming protected-resource metadata on a different origin from the connector URL, whether in the challenge or cached from an earlier grant, is now refused before any fetch.
|
|
45
|
+
|
|
46
|
+
Reliability: OAuth refresh commits are bounded when storage stalls; a connect that straddles an OAuth Restart can no longer act in the newer epoch; executor permits are released when result stashing stalls; timed-out listen candidates and expired connector waiters no longer hold or receive admission; SQLite and D1 reclaim expired rows written by compare-and-set; request-token resolver failures show as `auth_required` in status; the MCP body bound holds on Node 24 and later; and a search in the same request sees catalog changes Connecta itself made.
|
|
47
|
+
|
|
48
|
+
Operator pages: a principal-forwarding `remoteMcp` connector no longer shows "Authorization needed" when its calls work. The page checks it as the admitted operator, under the same `accept` policy as a call, and a check with no caller reports the neutral `per_caller` state. Cloudflare Access deployments no longer send an admitted browser a sign-in challenge when Access verification context is missing, as seen on fresh isolates; they answer a retryable 503 and log a classified reason for every operator 401. Startup no longer warns about missing OAuth state checks for connectors that never exchange a code, and operator status and config requests dispose workerd RPC results.
|
|
49
|
+
|
|
50
|
+
Performance: each `execute_code` response is scanned for secrets once instead of twice, repeated searches in a request reuse one lexical index, and responses with no registered secrets skip JSON re-serialization at the MCP route. The root bundle cap rises to 407,000 B gzip to cover these fixes.
|
|
51
|
+
|
|
52
|
+
### Changed
|
|
53
|
+
|
|
54
|
+
- Run one envelope redaction scan per execute_code response at the operation boundary, after write accounting and before attaching Connecta’s host-call counters.
|
|
55
|
+
- Reuse private lexical search snapshots within a request and safety view, cloning only selected definitions before returning discovery results.
|
|
56
|
+
- Return MCP response body text untouched when the request has no registered secrets or unregistered private values after the body is fully read, avoiding unnecessary JSON parsing and serialization.
|
|
57
|
+
- Raise the root bundle gzip cap from 404,500 to 407,000 B for the 0.37.1 fix set.
|
|
58
|
+
|
|
59
|
+
### Fixed
|
|
60
|
+
|
|
61
|
+
- Keep numbers when replacing an adjacent string breaks their credential match, while still withholding numeric credential runs. Recheck retained numbers after each whole-number replacement so new marker seams cannot expose credential fragments; an incomplete check withholds every originally touched number. Attach execute_code host-call counters after its final redaction so the counters remain integers. Document opaque principal-forwarding tokens and their request-wide redaction.
|
|
62
|
+
- Bound downstream OAuth refresh commit and cleanup so stalled storage settles the flight, releases the owner partition, and reports an unknown outcome while preserving spent-token fencing.
|
|
63
|
+
- Keep remote MCP authorization starts and status checks bound to the successful connection's OAuth epoch, so a concurrent Restart supersedes the older attempt instead of letting it read the replacement grant or publish consent there.
|
|
64
|
+
|
|
65
|
+
Explicit starts after a passive status check or call in the same request scope can still initiate consent without widening the cached connection's authorization permissions.
|
|
66
|
+
- Reclaim expired SQLite and D1 rows during mutating `compareAndSet()` calls with the same bounded sweep as `set()`, preserving atomic comparisons and their results.
|
|
67
|
+
- Report request-token and principal resolver authentication failures as `auth_required` in remote MCP status without exposing resolver error messages.
|
|
68
|
+
- Keep MCP listen-candidate body reads within their existing bound on Node 24 and later by avoiding an extra buffering pipe when attaching the request-local signal.
|
|
69
|
+
- Release executor permits when result-stash storage stalls. Bound reservation and result processing by their deadlines and request cancellation, including final program-return paging after executor release, while preserving successful write accounting and refusing to replay completed writes.
|
|
70
|
+
- Withdraw fallback admission waiters when a header-named subscriptions/listen candidate reaches its request deadline, preventing ended requests from being admitted later.
|
|
71
|
+
- Refuse expired connector call admission waiters before granting a permit, even when the event loop delays their timeout callback.
|
|
72
|
+
- Revalidate request-retained catalogs using in-process catalog invalidation and credential mutation fences, without storage reads on unchanged repeat searches, replacing derived search indexes when a fence changes.
|
|
73
|
+
- Keep typed-array, DataView, and ArrayBuffer numbers adjacent to neighbouring leaves during redaction, while checking their byte views separately and withholding binary whose bytes or numbers hold a match.
|
|
74
|
+
- Report principal-forwarding remote MCP connectors truthfully on the operator page: check as the admitted operator under the same caller policy as a call, and show actual downstream failures without a deployment-secret diagnosis or fix prompt. Checks without an admitted caller return the non-error `per_caller` state ("Authenticates as each caller; verified on use."). Adding `per_caller` to the public status union is an additive type change; exhaustive status consumers must handle it.
|
|
75
|
+
|
|
76
|
+
Operator observations are isolated by an opaque admitted viewer key, including same-role Cloudflare Access identity changes during pending probes.
|
|
77
|
+
- Return retryable 503s when Cloudflare Access verification context is unavailable for an assertion-bearing request or its trusted AUD is unusable, including on a fresh instance. Keep admission closed until Access supplies verified human identity, and log classified, non-secret facts for unavailable verification and every operator 401.
|
|
78
|
+
- Warn about missing OAuth state verification only for connectors that declare code-exchange support. Dispose remote MCP RPC responses at the request boundary, including operator configuration and status probes.
|
|
79
|
+
|
|
80
|
+
### Security
|
|
81
|
+
|
|
82
|
+
- Refuse remote MCP OAuth challenges whose protected-resource metadata URL is outside the configured resource origin before fetching metadata. Discard foreign cached resource metadata before SDK discovery, including callbacks and flows without challenges, and keep challenged hosts out of refusal messages. Same-origin paths, including Google's per-tool metadata, remain accepted.
|
|
83
|
+
- Recheck redaction lanes until replacements stop creating credential runs beside placeholders, withholding every unchecked seam participant when the shared work budget cannot finish. Include omitted error numbers, whole error names, whole JSON strings and walk-time scalar placeholders in the returned projection. Check typed arrays' returned byte numbers and original element numbers in separate projections with the same neighbours.
|
|
84
|
+
|
|
5
85
|
## 0.37.0 — 2026-10-27
|
|
6
86
|
|
|
7
87
|
Connecta 0.37.0 lets a `remoteMcp()` connection reach a trusted first-party downstream as the caller Connecta admitted, with no per-person OAuth. Request auth's new `principal` option gives the token resolver that caller's reference: people by default, and declared agents only with `accept: "human-or-agent"`. The new optional `fetch` carries all of the connector's MCP traffic, for example through a Workers service binding to a sibling Worker. The downstream must accept a forwarded identity only on its binding entrypoint or behind a verified signature. Operator status checks carry no caller, so a principal-forwarding connector reports `auth_required` on the operator pages even when calls succeed.
|
package/README.md
CHANGED
|
@@ -91,8 +91,8 @@ on Node, in Docker, or on Cloudflare Workers. The
|
|
|
91
91
|
| [Safety and trust](./guides/safety-and-trust.md) | Uncertain changes, secrets, read-only access, and your responsibilities. |
|
|
92
92
|
| [Operator documentation](./documentation/README.md) | Setup, feature availability, upgrades, and exact contracts. |
|
|
93
93
|
|
|
94
|
-
<a id="existing-client-tokens"></a>
|
|
95
|
-
|
|
96
94
|
Upgrading? Follow the [upgrade guide](./documentation/deploying.md#upgrade-an-existing-deployment).
|
|
95
|
+
Pre-0.29 storage and OAuth layouts must first migrate on 0.37.1; see the
|
|
96
|
+
[required bridge upgrade](./documentation/migration-retired-layouts.md).
|
|
97
97
|
Breaking changes are expected before 1.0. See the [changelog](./CHANGELOG.md)
|
|
98
98
|
and [security policy](./SECURITY.md).
|
package/bin/connecta.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { copyFile, cp, lstat, mkdtemp, readFile, rename, rm, symlink, writeFile
|
|
|
4
4
|
import { CONNECTA_VERSION } from "./version.mjs";
|
|
5
5
|
import { META_TOOL_NAMES } from "./meta-tool-names.mjs";
|
|
6
6
|
import { basename, dirname, join, resolve } from "node:path";
|
|
7
|
-
import { fileURLToPath
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
8
|
|
|
9
9
|
const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
10
10
|
const [command, ...args] = process.argv.slice(2);
|
|
@@ -19,7 +19,6 @@ function shellCd(path) {
|
|
|
19
19
|
function usage() {
|
|
20
20
|
console.log(`Usage:
|
|
21
21
|
connecta init [directory]
|
|
22
|
-
connecta migrate-state <state.json> <connecta.sqlite>
|
|
23
22
|
CONNECTA_TOKEN=<bearer> connecta doctor [--config] [--url http://localhost:8787] [--pool <name>]
|
|
24
23
|
CF_ACCESS_CLIENT_ID=<id> CF_ACCESS_CLIENT_SECRET=<secret> connecta doctor --url https://worker.example`);
|
|
25
24
|
}
|
|
@@ -307,46 +306,9 @@ async function doctor() {
|
|
|
307
306
|
);
|
|
308
307
|
}
|
|
309
308
|
|
|
310
|
-
/**
|
|
311
|
-
* One-shot copy of a 0.28 `fileStorage` JSON state file into the SQLite
|
|
312
|
-
* database 0.29 stores everything in. Stop the old deployment first; the file
|
|
313
|
-
* is read, never changed.
|
|
314
|
-
*/
|
|
315
|
-
async function migrateState() {
|
|
316
|
-
if (args.length !== 2 || args.some((arg) => arg.startsWith("--"))) {
|
|
317
|
-
usage();
|
|
318
|
-
process.exitCode = 1;
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
const [statePath, databasePath] = args.map((arg) => resolve(process.cwd(), arg));
|
|
322
|
-
const { importStateFile, openSqlite } = await import(pathToFileURL(join(packageRoot, "dist", "sqlite.js")).href);
|
|
323
|
-
let database;
|
|
324
|
-
try {
|
|
325
|
-
database = openSqlite(databasePath);
|
|
326
|
-
} catch {
|
|
327
|
-
throw new Error("State migration failed: could not open the SQLite database");
|
|
328
|
-
}
|
|
329
|
-
let closeFailed = false;
|
|
330
|
-
try {
|
|
331
|
-
const result = importStateFile(database, statePath);
|
|
332
|
-
console.log(
|
|
333
|
-
`Imported ${result.imported} entries from ${statePath} into ${databasePath}` +
|
|
334
|
-
` (${result.kept} already present, ${result.expired} expired).`,
|
|
335
|
-
);
|
|
336
|
-
} finally {
|
|
337
|
-
try {
|
|
338
|
-
database.close();
|
|
339
|
-
} catch {
|
|
340
|
-
closeFailed = true;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
if (closeFailed) throw new Error("State migration failed: could not close the SQLite database");
|
|
344
|
-
}
|
|
345
|
-
|
|
346
309
|
try {
|
|
347
310
|
if (command === "init") await init();
|
|
348
311
|
else if (command === "doctor") await doctor();
|
|
349
|
-
else if (command === "migrate-state") await migrateState();
|
|
350
312
|
else {
|
|
351
313
|
usage();
|
|
352
314
|
process.exitCode = command === "--help" || command === "-h" ? 0 : 1;
|
package/bin/version.mjs
CHANGED
package/dist/access-tokens.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { sha256Hex } from "./bytes.js";
|
|
1
2
|
import { withAuthenticationDeadline } from "./auth-admission.js";
|
|
2
3
|
import { authorizationCredential, isMachineCredential } from "./inbound-credential.js";
|
|
3
4
|
import { assertKnownOptions, ConfigError, optionsOf, readPlain } from "./config-schema.js";
|
|
@@ -137,11 +138,8 @@ function bytesToBase64Url(bytes) {
|
|
|
137
138
|
binary += String.fromCharCode(byte);
|
|
138
139
|
return btoa(binary).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/u, "");
|
|
139
140
|
}
|
|
140
|
-
function bytesToHex(bytes) {
|
|
141
|
-
return [...bytes].map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
142
|
-
}
|
|
143
141
|
async function hashToken(token) {
|
|
144
|
-
return
|
|
142
|
+
return sha256Hex(token);
|
|
145
143
|
}
|
|
146
144
|
const REVISION_RE = /^[A-Za-z0-9_-]{22}$/u;
|
|
147
145
|
/** Whether `value` has the shape of a slot revision. */
|
package/dist/agent-identity.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Code-declared agents
|
|
1
|
+
// Code-declared agents: the names deployment code lists in `agents`,
|
|
2
2
|
// the identity an admitted agent carries, and the built-in providers trusted
|
|
3
3
|
// to assert it. Pure, so core reads it without reaching credential modules.
|
|
4
4
|
import { ConfigError } from "./config-schema.js";
|
|
@@ -1833,4 +1833,5 @@ var Bc = new Set(["error", "warn", "info", "debug", "trace"]), Nt = { samplingRa
|
|
|
1833
1833
|
};
|
|
1834
1834
|
var ud = Mn(Z);
|
|
1835
1835
|
function jc(t) { let e = { ...t }, r = he(e), s = qn({ options: e, apiClient: r }), n = new Jt({ publishableKey: e.publishableKey, secretKey: e.secretKey, samplingRate: .1, ...e.sdkMetadata ? { sdk: e.sdkMetadata.name, sdkVersion: e.sdkMetadata.version } : {}, ...e.telemetry || {} }); return { ...r, ...s, telemetry: n }; }
|
|
1836
|
-
|
|
1836
|
+
const createClerkClient = jc;
|
|
1837
|
+
export { createClerkClient };
|
|
@@ -3,6 +3,8 @@ import type { InboundAuth } from "../types.js";
|
|
|
3
3
|
* Trust the identity Cloudflare Access attached to this direct Worker
|
|
4
4
|
* invocation. Access has already validated the browser session, Managed OAuth
|
|
5
5
|
* token, or service-token headers before the Worker runs; this adapter does
|
|
6
|
-
* not accept or parse a caller-supplied JWT.
|
|
6
|
+
* not accept or parse a caller-supplied JWT. An assertion header without
|
|
7
|
+
* trusted context is only a hint that verification infrastructure is missing,
|
|
8
|
+
* never evidence of an authenticated caller.
|
|
7
9
|
*/
|
|
8
10
|
export declare function cloudflareAccessAuth(): InboundAuth;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { withAuthenticationDeadline } from "../auth-admission.js";
|
|
2
2
|
import { validIdentityReference } from "../identity.js";
|
|
3
3
|
import { authorizationCredential } from "../inbound-credential.js";
|
|
4
|
+
import { attachFailureFacts } from "../operator-record.js";
|
|
4
5
|
import { authCall, authFlow, authInvoke, authMethod } from "./native.js";
|
|
5
6
|
function identityString(identity, field) {
|
|
6
7
|
const value = identity[field];
|
|
@@ -8,33 +9,46 @@ function identityString(identity, field) {
|
|
|
8
9
|
? value
|
|
9
10
|
: undefined;
|
|
10
11
|
}
|
|
11
|
-
function unauthorized() {
|
|
12
|
+
function unauthorized(reason) {
|
|
12
13
|
return {
|
|
13
14
|
ok: false,
|
|
14
|
-
response: Response.json({ error: "Cloudflare Access authentication required" }, { status: 401, headers: { "WWW-Authenticate": 'Bearer scope="openid email"', "Cache-Control": "no-store" } }),
|
|
15
|
+
response: attachFailureFacts(Response.json({ error: "Cloudflare Access authentication required" }, { status: 401, headers: { "WWW-Authenticate": 'Bearer scope="openid email"', "Cache-Control": "no-store" } }), { reason }),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function unavailable(problem) {
|
|
19
|
+
return {
|
|
20
|
+
ok: false,
|
|
21
|
+
response: attachFailureFacts(Response.json({ error: "Cloudflare Access identity unavailable", problem }, { status: 503, headers: { "Cache-Control": "no-store", "Retry-After": "1" } }), { reason: problem === "identity_unavailable" ? "access_identity_unavailable" : problem }),
|
|
15
22
|
};
|
|
16
23
|
}
|
|
17
24
|
/**
|
|
18
25
|
* Trust the identity Cloudflare Access attached to this direct Worker
|
|
19
26
|
* invocation. Access has already validated the browser session, Managed OAuth
|
|
20
27
|
* token, or service-token headers before the Worker runs; this adapter does
|
|
21
|
-
* not accept or parse a caller-supplied JWT.
|
|
28
|
+
* not accept or parse a caller-supplied JWT. An assertion header without
|
|
29
|
+
* trusted context is only a hint that verification infrastructure is missing,
|
|
30
|
+
* never evidence of an authenticated caller.
|
|
22
31
|
*/
|
|
23
32
|
export function cloudflareAccessAuth() {
|
|
24
33
|
return {
|
|
25
34
|
kind: "cloudflare-access",
|
|
26
35
|
interactiveOperator: true,
|
|
27
|
-
recognizesCredential: (request, context) => authorizationCredential(request).kind === "absent" &&
|
|
36
|
+
recognizesCredential: (request, context) => authorizationCredential(request).kind === "absent" &&
|
|
37
|
+
(Boolean(context?.access) || request.headers.has("Cf-Access-Jwt-Assertion")),
|
|
28
38
|
challenge: () => 'Bearer scope="openid email"',
|
|
29
39
|
activityActorNamespace: "cloudflare-access",
|
|
30
40
|
uiAuth: { kind: "cloudflare-access" },
|
|
31
41
|
authorize: authMethod(function (request, _baseUrl, runtimeContext) {
|
|
32
42
|
return authFlow(function* () {
|
|
33
43
|
if (authorizationCredential(request).kind !== "absent")
|
|
34
|
-
return unauthorized();
|
|
44
|
+
return unauthorized("access_authorization_header_rejected");
|
|
35
45
|
const access = runtimeContext?.access;
|
|
36
|
-
if (!access
|
|
37
|
-
return
|
|
46
|
+
if (!access)
|
|
47
|
+
return request.headers.has("Cf-Access-Jwt-Assertion")
|
|
48
|
+
? unavailable("access_context_unavailable")
|
|
49
|
+
: unauthorized("access_context_missing");
|
|
50
|
+
if (typeof access.aud !== "string" || !/^[\x21-\x7e]{1,256}$/.test(access.aud))
|
|
51
|
+
return unavailable("access_audience_invalid");
|
|
38
52
|
let identity;
|
|
39
53
|
try {
|
|
40
54
|
identity = (yield authCall(withAuthenticationDeadline, [
|
|
@@ -45,10 +59,7 @@ export function cloudflareAccessAuth() {
|
|
|
45
59
|
]));
|
|
46
60
|
}
|
|
47
61
|
catch {
|
|
48
|
-
return
|
|
49
|
-
ok: false,
|
|
50
|
-
response: Response.json({ error: "Cloudflare Access identity unavailable", problem: "identity_unavailable" }, { status: 503, headers: { "Cache-Control": "no-store", "Retry-After": "1" } }),
|
|
51
|
-
};
|
|
62
|
+
return unavailable("identity_unavailable");
|
|
52
63
|
}
|
|
53
64
|
// Access binds ctx.access.aud to its Worker application at the edge.
|
|
54
65
|
// Service credentials can pass that edge, but connecta machines must
|