openclaw-cloudflare 0.1.0 → 0.3.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/LICENSE +21 -0
- package/README.md +106 -83
- package/openclaw.plugin.json +3 -14
- package/package.json +10 -3
- package/src/index.ts +14 -68
- package/.changeset/README.md +0 -8
- package/.changeset/config.json +0 -11
- package/.github/workflows/changeset-check.yml +0 -25
- package/.github/workflows/ci.yml +0 -25
- package/.github/workflows/release.yml +0 -39
- package/src/index.test.ts +0 -395
- package/src/tunnel/access.test.ts +0 -280
- package/src/tunnel/cloudflared.test.ts +0 -176
- package/src/tunnel/cloudflared.ts +0 -209
- package/src/tunnel/exposure.test.ts +0 -112
- package/src/tunnel/exposure.ts +0 -44
- package/tsconfig.json +0 -16
- package/vitest.config.ts +0 -7
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Gabriel Massadas
|
|
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
|
@@ -1,28 +1,37 @@
|
|
|
1
1
|
# openclaw-cloudflare
|
|
2
2
|
|
|
3
|
-
Cloudflare
|
|
3
|
+
Cloudflare Access JWT verification plugin for [OpenClaw](https://github.com/openclaw/openclaw). Verifies `Cf-Access-Jwt-Assertion` headers and sets identity headers for authenticated requests.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Assumes `cloudflared` is already running externally (Docker sidecar, systemd, Cloudflare's own connector, etc.).
|
|
6
|
+
|
|
7
|
+
## Setup Guide
|
|
8
|
+
|
|
9
|
+
### Step 1 — Install the plugin
|
|
6
10
|
|
|
7
11
|
```bash
|
|
8
12
|
openclaw plugins install openclaw-cloudflare
|
|
9
13
|
```
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
### Step 2 — Set up Cloudflare Access
|
|
16
|
+
|
|
17
|
+
1. In the [Cloudflare Zero Trust dashboard](https://one.dash.cloudflare.com/) → **Access > Applications** → **Add an application**
|
|
18
|
+
2. Choose **Self-hosted**
|
|
19
|
+
3. Set the **Application domain** to the hostname pointing at your OpenClaw gateway (e.g. `openclaw.example.com`)
|
|
20
|
+
4. Configure the identity providers and policies (who is allowed to access)
|
|
21
|
+
5. Note your **Team domain** — visible at **Settings > Custom Pages** or in the URL: `https://<team>.cloudflareaccess.com`
|
|
22
|
+
|
|
23
|
+
### Step 3 — Configure the plugin
|
|
12
24
|
|
|
13
|
-
Add to your
|
|
25
|
+
Add to your `~/.openclaw/openclaw.json`:
|
|
14
26
|
|
|
15
27
|
```json
|
|
16
28
|
{
|
|
17
29
|
"plugins": {
|
|
18
30
|
"entries": {
|
|
19
|
-
"cloudflare": {
|
|
31
|
+
"openclaw-cloudflare": {
|
|
20
32
|
"config": {
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"tunnelToken": "your-tunnel-token",
|
|
24
|
-
"teamDomain": "myteam",
|
|
25
|
-
"audience": "optional-aud-tag"
|
|
33
|
+
"access": {
|
|
34
|
+
"teamDomain": "myteam"
|
|
26
35
|
}
|
|
27
36
|
}
|
|
28
37
|
}
|
|
@@ -31,112 +40,126 @@ Add to your `openclaw.json`:
|
|
|
31
40
|
}
|
|
32
41
|
```
|
|
33
42
|
|
|
34
|
-
## Modes
|
|
35
43
|
|
|
36
|
-
###
|
|
44
|
+
### Step 4 — Start OpenClaw
|
|
37
45
|
|
|
38
|
-
|
|
46
|
+
```bash
|
|
47
|
+
openclaw gateway --force
|
|
48
|
+
```
|
|
39
49
|
|
|
40
|
-
|
|
50
|
+
The plugin will verify Cloudflare Access JWTs on every incoming request and set `x-openclaw-user-email` for authenticated users.
|
|
41
51
|
|
|
42
|
-
|
|
52
|
+
---
|
|
43
53
|
|
|
44
|
-
|
|
45
|
-
- `cloudflared` binary installed and in PATH (or at a known location)
|
|
46
|
-
- A pre-configured tunnel token from the Cloudflare Zero Trust dashboard
|
|
54
|
+
## Running cloudflared on your VM
|
|
47
55
|
|
|
48
|
-
|
|
56
|
+
This plugin only handles JWT verification — you need `cloudflared` running on the VM to route traffic through Cloudflare. Here's how to set it up as a persistent system service so it starts automatically.
|
|
49
57
|
|
|
50
|
-
1
|
|
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:
|
|
58
|
+
### 1 — Create a tunnel in the Cloudflare dashboard
|
|
54
59
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
60
|
+
1. Go to [Cloudflare Zero Trust](https://one.dash.cloudflare.com/) → **Networks > Tunnels** → **Create a tunnel**
|
|
61
|
+
2. Choose **Cloudflared**, name it (e.g. `my-openclaw`), click **Save tunnel**
|
|
62
|
+
3. Under **Public Hostnames**, add a hostname pointing to your OpenClaw gateway:
|
|
63
|
+
- Subdomain + domain: e.g. `openclaw.example.com`
|
|
64
|
+
- Service: `HTTP` → `localhost:18789` (OpenClaw's default port)
|
|
65
|
+
4. Copy the **tunnel token** shown on the connector install page
|
|
66
|
+
|
|
67
|
+
### 2 — Install cloudflared
|
|
68
|
+
|
|
69
|
+
**Debian/Ubuntu:**
|
|
70
|
+
```bash
|
|
71
|
+
curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb -o cloudflared.deb
|
|
72
|
+
sudo dpkg -i cloudflared.deb
|
|
71
73
|
```
|
|
72
74
|
|
|
73
|
-
|
|
75
|
+
**RHEL/Fedora:**
|
|
76
|
+
```bash
|
|
77
|
+
curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-x86_64.rpm -o cloudflared.rpm
|
|
78
|
+
sudo rpm -i cloudflared.rpm
|
|
79
|
+
```
|
|
74
80
|
|
|
81
|
+
**ARM64:**
|
|
75
82
|
```bash
|
|
76
|
-
|
|
83
|
+
curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-arm64 -o cloudflared
|
|
84
|
+
sudo install -m 755 cloudflared /usr/local/bin/cloudflared
|
|
77
85
|
```
|
|
78
86
|
|
|
79
|
-
|
|
87
|
+
**macOS:**
|
|
88
|
+
```bash
|
|
89
|
+
brew install cloudflare/cloudflare/cloudflared
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### 3 — Install as a system service
|
|
93
|
+
|
|
94
|
+
**Linux:**
|
|
95
|
+
```bash
|
|
96
|
+
sudo cloudflared service install <your-tunnel-token>
|
|
97
|
+
sudo systemctl enable cloudflared
|
|
98
|
+
sudo systemctl start cloudflared
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Verify it's running:
|
|
102
|
+
```bash
|
|
103
|
+
sudo systemctl status cloudflared
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**macOS:**
|
|
107
|
+
```bash
|
|
108
|
+
sudo cloudflared service install <your-tunnel-token>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
This registers a launchd plist that starts cloudflared automatically on boot.
|
|
80
112
|
|
|
81
|
-
|
|
113
|
+
Once the tunnel is active, all traffic arriving at your public hostname passes through Cloudflare Access — and this plugin verifies the resulting JWTs on each request.
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## OpenClaw gateway configuration
|
|
118
|
+
|
|
119
|
+
With `cloudflared` running on the same machine, the gateway only needs to be reachable on loopback. Configure `~/.openclaw/openclaw.json` to bind locally, trust the local proxy, and delegate authentication to the identity headers this plugin sets:
|
|
82
120
|
|
|
83
121
|
```json
|
|
84
122
|
{
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
"audience": "aud-tag-from-access-app"
|
|
93
|
-
}
|
|
94
|
-
}
|
|
123
|
+
"gateway": {
|
|
124
|
+
"bind": "loopback",
|
|
125
|
+
"trustedProxies": ["127.0.0.1"],
|
|
126
|
+
"auth": {
|
|
127
|
+
"mode": "trusted-proxy",
|
|
128
|
+
"trustedProxy": {
|
|
129
|
+
"userHeader": "x-openclaw-user-email"
|
|
95
130
|
}
|
|
96
131
|
}
|
|
97
132
|
}
|
|
98
133
|
}
|
|
99
134
|
```
|
|
100
135
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
# ...
|
|
136
|
+
| Field | Value | Why |
|
|
137
|
+
|-------|-------|-----|
|
|
138
|
+
| `gateway.bind` | `"loopback"` | cloudflared connects to OpenClaw locally — no need to expose to LAN |
|
|
139
|
+
| `gateway.trustedProxies` | `["127.0.0.1"]` | Only trust identity headers from cloudflared running on the same host |
|
|
140
|
+
| `gateway.auth.mode` | `"trusted-proxy"` | Delegate authentication to this plugin instead of using a password/token |
|
|
141
|
+
| `gateway.auth.trustedProxy.userHeader` | `"x-openclaw-user-email"` | This plugin sets this header after verifying the Cloudflare Access JWT |
|
|
108
142
|
|
|
109
|
-
|
|
110
|
-
image: cloudflare/cloudflared:latest
|
|
111
|
-
command: tunnel run
|
|
112
|
-
environment:
|
|
113
|
-
TUNNEL_TOKEN: "eyJhIjoiYWNj..."
|
|
114
|
-
```
|
|
143
|
+
---
|
|
115
144
|
|
|
116
|
-
##
|
|
145
|
+
## How it works
|
|
117
146
|
|
|
118
147
|
When a request arrives with a `Cf-Access-Jwt-Assertion` header, the plugin:
|
|
119
148
|
|
|
120
149
|
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
|
|
150
|
+
2. Validates issuer, expiry, and audience (if `audience` is configured)
|
|
151
|
+
3. Sets `x-openclaw-user-email` and `x-openclaw-auth-source: cloudflare-access` headers for downstream use
|
|
123
152
|
|
|
124
|
-
|
|
153
|
+
Identity headers are always stripped from incoming requests before verification to prevent spoofing.
|
|
125
154
|
|
|
126
|
-
JWKS keys are cached for 10 minutes with automatic refresh on key rotation.
|
|
155
|
+
Supported algorithms: RS256, ES256 (via Node.js WebCrypto, no external deps). JWKS keys are cached for 10 minutes with automatic refresh on key rotation.
|
|
127
156
|
|
|
128
|
-
|
|
157
|
+
---
|
|
129
158
|
|
|
130
|
-
|
|
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 |
|
|
159
|
+
## Configuration Reference
|
|
136
160
|
|
|
137
|
-
|
|
161
|
+
| Key | Type | Description |
|
|
162
|
+
|-----|------|-------------|
|
|
163
|
+
| `access.teamDomain` | `string` | Team domain for `<team>.cloudflareaccess.com` (required to enable) |
|
|
164
|
+
| `access.audience` | `string` | Optional AUD tag for stricter JWT validation |
|
|
138
165
|
|
|
139
|
-
| Variable | Description |
|
|
140
|
-
|----------|-------------|
|
|
141
|
-
| `OPENCLAW_CLOUDFLARE_TUNNEL_TOKEN` | Tunnel token (alternative to config) |
|
|
142
|
-
| `OPENCLAW_TEST_CLOUDFLARED_BINARY` | Override cloudflared binary path (testing) |
|
package/openclaw.plugin.json
CHANGED
|
@@ -4,16 +4,10 @@
|
|
|
4
4
|
"type": "object",
|
|
5
5
|
"additionalProperties": false,
|
|
6
6
|
"properties": {
|
|
7
|
-
"
|
|
7
|
+
"access": {
|
|
8
8
|
"type": "object",
|
|
9
9
|
"additionalProperties": false,
|
|
10
10
|
"properties": {
|
|
11
|
-
"mode": {
|
|
12
|
-
"type": "string",
|
|
13
|
-
"enum": ["off", "managed", "access-only"],
|
|
14
|
-
"default": "off"
|
|
15
|
-
},
|
|
16
|
-
"tunnelToken": { "type": "string" },
|
|
17
11
|
"teamDomain": { "type": "string" },
|
|
18
12
|
"audience": { "type": "string" }
|
|
19
13
|
}
|
|
@@ -21,17 +15,12 @@
|
|
|
21
15
|
}
|
|
22
16
|
},
|
|
23
17
|
"uiHints": {
|
|
24
|
-
"
|
|
25
|
-
"label": "Tunnel Token",
|
|
26
|
-
"sensitive": true,
|
|
27
|
-
"help": "Token from Cloudflare Zero Trust dashboard (managed mode)"
|
|
28
|
-
},
|
|
29
|
-
"tunnel.teamDomain": {
|
|
18
|
+
"access.teamDomain": {
|
|
30
19
|
"label": "Team Domain",
|
|
31
20
|
"placeholder": "myteam",
|
|
32
21
|
"help": "Team domain for myteam.cloudflareaccess.com"
|
|
33
22
|
},
|
|
34
|
-
"
|
|
23
|
+
"access.audience": {
|
|
35
24
|
"label": "Application Audience (AUD)",
|
|
36
25
|
"help": "Optional AUD tag for stricter JWT validation",
|
|
37
26
|
"advanced": true
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openclaw-cloudflare",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Cloudflare integration plugin for OpenClaw (Tunnel, Access, and more)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -24,7 +24,9 @@
|
|
|
24
24
|
"vitest": "^3.0.0"
|
|
25
25
|
},
|
|
26
26
|
"openclaw": {
|
|
27
|
-
"extensions": [
|
|
27
|
+
"extensions": [
|
|
28
|
+
"./src/index.ts"
|
|
29
|
+
],
|
|
28
30
|
"install": {
|
|
29
31
|
"npmSpec": "openclaw-cloudflare",
|
|
30
32
|
"defaultChoice": "npm"
|
|
@@ -40,8 +42,13 @@
|
|
|
40
42
|
],
|
|
41
43
|
"repository": {
|
|
42
44
|
"type": "git",
|
|
43
|
-
"url": "git+https://github.com/G4brym/openclaw-
|
|
45
|
+
"url": "git+https://github.com/G4brym/openclaw-cloudflare.git"
|
|
44
46
|
},
|
|
47
|
+
"files": [
|
|
48
|
+
"src",
|
|
49
|
+
"!src/**/*.test.ts",
|
|
50
|
+
"openclaw.plugin.json"
|
|
51
|
+
],
|
|
45
52
|
"publishConfig": {
|
|
46
53
|
"provenance": true,
|
|
47
54
|
"access": "public"
|
package/src/index.ts
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
-
import { createCloudflareAccessVerifier
|
|
3
|
-
import { startGatewayCloudflareExposure } from "./tunnel/exposure.js";
|
|
4
|
-
|
|
5
|
-
type TunnelConfig = {
|
|
6
|
-
mode?: "off" | "managed" | "access-only";
|
|
7
|
-
tunnelToken?: string;
|
|
8
|
-
teamDomain?: string;
|
|
9
|
-
audience?: string;
|
|
10
|
-
};
|
|
2
|
+
import { createCloudflareAccessVerifier } from "./tunnel/access.js";
|
|
11
3
|
|
|
12
4
|
type PluginConfig = {
|
|
13
|
-
|
|
5
|
+
access?: {
|
|
6
|
+
teamDomain?: string;
|
|
7
|
+
audience?: string;
|
|
8
|
+
};
|
|
14
9
|
};
|
|
15
10
|
|
|
16
11
|
export default {
|
|
@@ -20,88 +15,39 @@ export default {
|
|
|
20
15
|
register(api: {
|
|
21
16
|
pluginConfig?: PluginConfig;
|
|
22
17
|
logger: { info: (msg: string) => void; warn: (msg: string) => void; error: (msg: string) => void };
|
|
23
|
-
registerService(service: { id: string; start: () => Promise<void>; stop: () => Promise<void> }): void;
|
|
24
18
|
registerHttpHandler(handler: (req: IncomingMessage, res: ServerResponse) => Promise<boolean> | boolean): void;
|
|
25
19
|
}) {
|
|
26
|
-
const config = api.pluginConfig?.
|
|
27
|
-
const mode = config?.mode ?? "off";
|
|
28
|
-
if (mode === "off") return;
|
|
29
|
-
|
|
30
|
-
const tunnelToken =
|
|
31
|
-
config?.tunnelToken ?? process.env.OPENCLAW_CLOUDFLARE_TUNNEL_TOKEN;
|
|
20
|
+
const config = api.pluginConfig?.access;
|
|
32
21
|
const teamDomain = config?.teamDomain;
|
|
33
22
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
api.logger.error(
|
|
37
|
-
"[cloudflare] managed mode requires tunnelToken config or OPENCLAW_CLOUDFLARE_TUNNEL_TOKEN env var",
|
|
38
|
-
);
|
|
23
|
+
if (!teamDomain) {
|
|
24
|
+
api.logger.warn("[cloudflare] no teamDomain configured — plugin disabled");
|
|
39
25
|
return;
|
|
40
26
|
}
|
|
41
|
-
if (teamDomain === undefined) {
|
|
42
|
-
api.logger.warn(
|
|
43
|
-
"[cloudflare] no teamDomain configured — JWT verification will be skipped",
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
27
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
// Register background service for tunnel lifecycle
|
|
51
|
-
api.registerService({
|
|
52
|
-
id: "cloudflare-tunnel",
|
|
53
|
-
async start() {
|
|
54
|
-
// Create JWT verifier if teamDomain is set
|
|
55
|
-
if (teamDomain) {
|
|
56
|
-
verifier = createCloudflareAccessVerifier({
|
|
57
|
-
teamDomain,
|
|
58
|
-
audience: config?.audience,
|
|
59
|
-
});
|
|
60
|
-
api.logger.info(
|
|
61
|
-
`[cloudflare] Access JWT verifier active for ${teamDomain}.cloudflareaccess.com`,
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Start tunnel exposure (managed mode)
|
|
66
|
-
stopTunnel = await startGatewayCloudflareExposure({
|
|
67
|
-
cloudflareMode: mode,
|
|
68
|
-
tunnelToken,
|
|
69
|
-
logCloudflare: {
|
|
70
|
-
info: (msg) => api.logger.info(`[cloudflare] ${msg}`),
|
|
71
|
-
warn: (msg) => api.logger.warn(`[cloudflare] ${msg}`),
|
|
72
|
-
error: (msg) => api.logger.error(`[cloudflare] ${msg}`),
|
|
73
|
-
},
|
|
74
|
-
});
|
|
75
|
-
},
|
|
76
|
-
async stop() {
|
|
77
|
-
if (stopTunnel) {
|
|
78
|
-
await stopTunnel();
|
|
79
|
-
stopTunnel = null;
|
|
80
|
-
}
|
|
81
|
-
verifier = null;
|
|
82
|
-
},
|
|
28
|
+
const verifier = createCloudflareAccessVerifier({
|
|
29
|
+
teamDomain,
|
|
30
|
+
audience: config.audience,
|
|
83
31
|
});
|
|
84
32
|
|
|
85
|
-
|
|
33
|
+
api.logger.info(`[cloudflare] Access JWT verifier active for ${teamDomain}.cloudflareaccess.com`);
|
|
34
|
+
|
|
86
35
|
api.registerHttpHandler(async (req: IncomingMessage, _res: ServerResponse) => {
|
|
87
36
|
// Always strip identity headers to prevent spoofing from untrusted clients
|
|
88
37
|
delete req.headers["x-openclaw-user-email"];
|
|
89
38
|
delete req.headers["x-openclaw-auth-source"];
|
|
90
39
|
|
|
91
|
-
if (!verifier) return false;
|
|
92
|
-
|
|
93
40
|
const jwtHeader = req.headers["cf-access-jwt-assertion"];
|
|
94
41
|
const token = Array.isArray(jwtHeader) ? jwtHeader[0] : jwtHeader;
|
|
95
42
|
if (!token) return false;
|
|
96
43
|
|
|
97
44
|
const user = await verifier.verify(token);
|
|
98
45
|
if (user) {
|
|
99
|
-
// Set identity headers for gateway auth flow
|
|
100
46
|
req.headers["x-openclaw-user-email"] = user.email;
|
|
101
47
|
req.headers["x-openclaw-auth-source"] = "cloudflare-access";
|
|
102
48
|
}
|
|
103
49
|
|
|
104
|
-
return false;
|
|
50
|
+
return false;
|
|
105
51
|
});
|
|
106
52
|
},
|
|
107
53
|
};
|
package/.changeset/README.md
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
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)
|
package/.changeset/config.json
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
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
|
package/.github/workflows/ci.yml
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
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
|
|
@@ -1,39 +0,0 @@
|
|
|
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
|