openclaw-cloudflare 0.1.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.
@@ -0,0 +1,8 @@
1
+ # Changesets
2
+
3
+ Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4
+ with multi-package repos, or single-package repos to help you version and publish your code. You can
5
+ find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6
+
7
+ We have a quick list of common questions to get you started engaging with this project in
8
+ [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
@@ -0,0 +1,11 @@
1
+ {
2
+ "$schema": "https://unpkg.com/@changesets/config@3.1.2/schema.json",
3
+ "changelog": ["@changesets/changelog-github", { "repo": "G4brym/openclaw-plugin-cloudflare" }],
4
+ "commit": false,
5
+ "fixed": [],
6
+ "linked": [],
7
+ "access": "public",
8
+ "baseBranch": "main",
9
+ "updateInternalDependencies": "patch",
10
+ "ignore": []
11
+ }
@@ -0,0 +1,25 @@
1
+ name: Changeset Check
2
+
3
+ on:
4
+ pull_request:
5
+ branches: [main]
6
+
7
+ jobs:
8
+ check:
9
+ name: Check for changeset
10
+ runs-on: ubuntu-latest
11
+ # Skip on the "Version Packages" PR itself — it has no changeset by design
12
+ if: github.head_ref != 'changeset-release/main'
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ with:
16
+ fetch-depth: 0
17
+
18
+ - uses: actions/setup-node@v4
19
+ with:
20
+ node-version: 22
21
+ cache: npm
22
+
23
+ - run: npm ci
24
+
25
+ - run: npx changeset status --since=origin/main
@@ -0,0 +1,25 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ name: Test & Typecheck
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+
16
+ - uses: actions/setup-node@v4
17
+ with:
18
+ node-version: 22
19
+ cache: npm
20
+
21
+ - run: npm ci
22
+
23
+ - run: npm run typecheck
24
+
25
+ - run: npm test
@@ -0,0 +1,39 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+
7
+ concurrency: ${{ github.workflow }}-${{ github.ref }}
8
+
9
+ jobs:
10
+ release:
11
+ name: Release
12
+ runs-on: ubuntu-latest
13
+ permissions:
14
+ contents: write
15
+ pull-requests: write
16
+ id-token: write
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ with:
20
+ fetch-depth: 0
21
+
22
+ - uses: actions/setup-node@v4
23
+ with:
24
+ node-version: 24
25
+ cache: npm
26
+ registry-url: https://registry.npmjs.org
27
+
28
+ - run: npm ci
29
+
30
+ - name: Create Release PR or Publish to npm
31
+ uses: changesets/action@v1
32
+ with:
33
+ publish: npm run release
34
+ version: npm run version
35
+ commit: "chore: version packages"
36
+ title: "chore: version packages"
37
+ env:
38
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39
+ NPM_CONFIG_PROVENANCE: true
package/README.md ADDED
@@ -0,0 +1,142 @@
1
+ # openclaw-cloudflare
2
+
3
+ Cloudflare integration plugin for [OpenClaw](https://github.com/openclaw/openclaw). Provides Cloudflare Tunnel and Access support, with room for future Cloudflare features (Workers, R2, KV, etc.).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ openclaw plugins install openclaw-cloudflare
9
+ ```
10
+
11
+ ## Configuration
12
+
13
+ Add to your `openclaw.json`:
14
+
15
+ ```json
16
+ {
17
+ "plugins": {
18
+ "entries": {
19
+ "cloudflare": {
20
+ "config": {
21
+ "tunnel": {
22
+ "mode": "managed",
23
+ "tunnelToken": "your-tunnel-token",
24
+ "teamDomain": "myteam",
25
+ "audience": "optional-aud-tag"
26
+ }
27
+ }
28
+ }
29
+ }
30
+ }
31
+ }
32
+ ```
33
+
34
+ ## Modes
35
+
36
+ ### `off` (default)
37
+
38
+ Cloudflare integration is disabled.
39
+
40
+ ### `managed`
41
+
42
+ OpenClaw spawns and manages a `cloudflared` tunnel process automatically.
43
+
44
+ **Requirements:**
45
+ - `cloudflared` binary installed and in PATH (or at a known location)
46
+ - A pre-configured tunnel token from the Cloudflare Zero Trust dashboard
47
+
48
+ **Setup:**
49
+
50
+ 1. In the [Cloudflare Zero Trust dashboard](https://one.dash.cloudflare.com/), create a tunnel under **Networks > Tunnels**
51
+ 2. Add a public hostname pointing to your OpenClaw gateway (e.g., `openclaw.example.com` → `http://localhost:3000`)
52
+ 3. Create an Access Application under **Access > Applications** for the hostname
53
+ 4. Copy the tunnel token and configure it:
54
+
55
+ ```json
56
+ {
57
+ "plugins": {
58
+ "entries": {
59
+ "cloudflare": {
60
+ "config": {
61
+ "tunnel": {
62
+ "mode": "managed",
63
+ "tunnelToken": "eyJhIjoiYWNj...",
64
+ "teamDomain": "myteam"
65
+ }
66
+ }
67
+ }
68
+ }
69
+ }
70
+ }
71
+ ```
72
+
73
+ Or via environment variable:
74
+
75
+ ```bash
76
+ export OPENCLAW_CLOUDFLARE_TUNNEL_TOKEN="eyJhIjoiYWNj..."
77
+ ```
78
+
79
+ ### `access-only`
80
+
81
+ Use when `cloudflared` is managed externally (e.g., Docker sidecar, systemd service). The plugin only handles Cloudflare Access JWT verification.
82
+
83
+ ```json
84
+ {
85
+ "plugins": {
86
+ "entries": {
87
+ "cloudflare": {
88
+ "config": {
89
+ "tunnel": {
90
+ "mode": "access-only",
91
+ "teamDomain": "myteam",
92
+ "audience": "aud-tag-from-access-app"
93
+ }
94
+ }
95
+ }
96
+ }
97
+ }
98
+ }
99
+ ```
100
+
101
+ **Docker Compose example** (external cloudflared):
102
+
103
+ ```yaml
104
+ services:
105
+ openclaw:
106
+ image: openclaw:latest
107
+ # ...
108
+
109
+ cloudflared:
110
+ image: cloudflare/cloudflared:latest
111
+ command: tunnel run
112
+ environment:
113
+ TUNNEL_TOKEN: "eyJhIjoiYWNj..."
114
+ ```
115
+
116
+ ## Authentication
117
+
118
+ When a request arrives with a `Cf-Access-Jwt-Assertion` header, the plugin:
119
+
120
+ 1. Verifies the JWT signature against Cloudflare's JWKS endpoint (`https://<teamDomain>.cloudflareaccess.com/cdn-cgi/access/certs`)
121
+ 2. Validates issuer, expiry, and audience (if configured)
122
+ 3. Sets `x-openclaw-user-email` and `x-openclaw-auth-source` headers for downstream auth
123
+
124
+ Supported algorithms: RS256, ES256 (via Node.js WebCrypto).
125
+
126
+ JWKS keys are cached for 10 minutes with automatic refresh on key rotation.
127
+
128
+ ## Configuration Reference
129
+
130
+ | Key | Type | Default | Description |
131
+ |-----|------|---------|-------------|
132
+ | `tunnel.mode` | `"off" \| "managed" \| "access-only"` | `"off"` | Operation mode |
133
+ | `tunnel.tunnelToken` | `string` | — | Tunnel token (managed mode) |
134
+ | `tunnel.teamDomain` | `string` | — | Team domain for `<team>.cloudflareaccess.com` |
135
+ | `tunnel.audience` | `string` | — | Optional AUD tag for stricter JWT validation |
136
+
137
+ ## Environment Variables
138
+
139
+ | Variable | Description |
140
+ |----------|-------------|
141
+ | `OPENCLAW_CLOUDFLARE_TUNNEL_TOKEN` | Tunnel token (alternative to config) |
142
+ | `OPENCLAW_TEST_CLOUDFLARED_BINARY` | Override cloudflared binary path (testing) |
@@ -0,0 +1,40 @@
1
+ {
2
+ "id": "cloudflare",
3
+ "configSchema": {
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "properties": {
7
+ "tunnel": {
8
+ "type": "object",
9
+ "additionalProperties": false,
10
+ "properties": {
11
+ "mode": {
12
+ "type": "string",
13
+ "enum": ["off", "managed", "access-only"],
14
+ "default": "off"
15
+ },
16
+ "tunnelToken": { "type": "string" },
17
+ "teamDomain": { "type": "string" },
18
+ "audience": { "type": "string" }
19
+ }
20
+ }
21
+ }
22
+ },
23
+ "uiHints": {
24
+ "tunnel.tunnelToken": {
25
+ "label": "Tunnel Token",
26
+ "sensitive": true,
27
+ "help": "Token from Cloudflare Zero Trust dashboard (managed mode)"
28
+ },
29
+ "tunnel.teamDomain": {
30
+ "label": "Team Domain",
31
+ "placeholder": "myteam",
32
+ "help": "Team domain for myteam.cloudflareaccess.com"
33
+ },
34
+ "tunnel.audience": {
35
+ "label": "Application Audience (AUD)",
36
+ "help": "Optional AUD tag for stricter JWT validation",
37
+ "advanced": true
38
+ }
39
+ }
40
+ }
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "openclaw-cloudflare",
3
+ "version": "0.1.0",
4
+ "description": "Cloudflare integration plugin for OpenClaw (Tunnel, Access, and more)",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": "./src/index.ts"
8
+ },
9
+ "scripts": {
10
+ "test": "vitest run",
11
+ "typecheck": "tsc --noEmit",
12
+ "changeset": "changeset",
13
+ "version": "changeset version",
14
+ "release": "changeset publish"
15
+ },
16
+ "peerDependencies": {
17
+ "openclaw": "*"
18
+ },
19
+ "devDependencies": {
20
+ "@changesets/changelog-github": "^0.5.2",
21
+ "@changesets/cli": "^2.29.8",
22
+ "@types/node": "^22.0.0",
23
+ "typescript": "^5.7.0",
24
+ "vitest": "^3.0.0"
25
+ },
26
+ "openclaw": {
27
+ "extensions": ["./src/index.ts"],
28
+ "install": {
29
+ "npmSpec": "openclaw-cloudflare",
30
+ "defaultChoice": "npm"
31
+ }
32
+ },
33
+ "keywords": [
34
+ "openclaw",
35
+ "openclaw-plugin",
36
+ "cloudflare",
37
+ "cloudflare-tunnel",
38
+ "cloudflare-access",
39
+ "zero-trust"
40
+ ],
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "git+https://github.com/G4brym/openclaw-plugin-cloudflare.git"
44
+ },
45
+ "publishConfig": {
46
+ "provenance": true,
47
+ "access": "public"
48
+ },
49
+ "license": "MIT"
50
+ }