@tibame201020/queqiao-http 0.1.2 → 0.1.3
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/README.md +39 -85
- package/README.zh-TW.md +40 -86
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -8
- package/dist/index.js.map +1 -1
- package/package.json +5 -8
package/README.md
CHANGED
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
[English](https://github.com/tibame201020/queqiao-http/blob/main/README.md) | [繁體中文](https://github.com/tibame201020/queqiao-http/blob/main/README.zh-TW.md)
|
|
4
4
|
|
|
5
|
-
Official
|
|
5
|
+
Official curl-like HTTP extension for [Queqiao](https://github.com/tibame201020/Queqiao).
|
|
6
6
|
|
|
7
|
-
`@tibame201020/queqiao-http`
|
|
7
|
+
`@tibame201020/queqiao-http` gives an attached Queqiao Worker a convenient `http_request` capability for direct HTTP/HTTPS requests. The trust decision is the extension install/attach itself: the extension does **not** maintain an origin allowlist.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
The implementation uses the Worker's native `fetch` directly. It does not invoke `curl`, a shell, or `child_process`.
|
|
10
10
|
|
|
11
11
|
## Status
|
|
12
12
|
|
|
13
|
-
v0.1
|
|
13
|
+
v0.1.3 targets Queqiao 0.9.7. The canonical npm package is `@tibame201020/queqiao-http`.
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Starting with v0.1.1, npm publication is handled by the repository's GitHub Release workflow using npm Trusted Publishing with provenance.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
Current request path:
|
|
18
18
|
|
|
19
19
|
```text
|
|
20
20
|
MCP client / LLM
|
|
@@ -22,22 +22,20 @@ MCP client / LLM
|
|
|
22
22
|
→ Queqiao Worker
|
|
23
23
|
→ stable extension proxy
|
|
24
24
|
→ queqiao-http
|
|
25
|
-
→
|
|
26
|
-
→
|
|
25
|
+
→ direct HTTP/HTTPS request
|
|
26
|
+
→ target service
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
Verified behavior includes:
|
|
30
30
|
|
|
31
|
-
-
|
|
32
|
-
- automatic JSON response parsing;
|
|
31
|
+
- JSON GET/POST requests;
|
|
32
|
+
- automatic JSON request serialization and response parsing;
|
|
33
33
|
- backend HTTP 4xx responses preserved as normal HTTP responses;
|
|
34
|
-
-
|
|
34
|
+
- arbitrary HTTP/HTTPS origins, including localhost, WSL/private-network addresses, and internet origins;
|
|
35
35
|
- no public Queqiao connector manifest expansion when the extension is installed or updated.
|
|
36
36
|
|
|
37
37
|
## Install
|
|
38
38
|
|
|
39
|
-
Install from npm and attach to every Worker:
|
|
40
|
-
|
|
41
39
|
```bash
|
|
42
40
|
queqiao extension install npm:@tibame201020/queqiao-http --attach-all
|
|
43
41
|
```
|
|
@@ -49,35 +47,35 @@ queqiao extension install npm:@tibame201020/queqiao-http
|
|
|
49
47
|
queqiao extension attach dev.queqiao.http --worker windows
|
|
50
48
|
```
|
|
51
49
|
|
|
52
|
-
`attach` is activation.
|
|
50
|
+
`attach` is activation.
|
|
53
51
|
|
|
54
|
-
|
|
52
|
+
## Network authority
|
|
55
53
|
|
|
56
|
-
|
|
54
|
+
There is no per-origin grant list in `queqiao-http`.
|
|
57
55
|
|
|
58
|
-
|
|
56
|
+
Installing and attaching this extension is the explicit authorization for it to issue HTTP/HTTPS requests from the Worker. This is intentional: the extension is meant to be a convenient curl-like network capability, not a service-specific adapter.
|
|
59
57
|
|
|
60
|
-
|
|
61
|
-
http://127.0.0.1:9889
|
|
62
|
-
http://localhost:9889
|
|
63
|
-
```
|
|
58
|
+
The package manifest therefore declares no managed-runtime HTTP origins:
|
|
64
59
|
|
|
65
|
-
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"runtime": {
|
|
63
|
+
"processes": { "allow": [] },
|
|
64
|
+
"outboundHttp": { "allowOrigins": [] }
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
66
68
|
|
|
67
|
-
|
|
69
|
+
The empty `allowOrigins` list is intentional because v0.1.3 no longer routes requests through `context.runtime.http.request()`.
|
|
68
70
|
|
|
69
71
|
## Capability
|
|
70
72
|
|
|
71
|
-
`queqiao-http` registers one capability:
|
|
72
|
-
|
|
73
|
-
```text
|
|
74
|
-
http_request
|
|
75
|
-
```
|
|
73
|
+
`queqiao-http` registers one capability: `http_request`.
|
|
76
74
|
|
|
77
75
|
Input fields:
|
|
78
76
|
|
|
79
77
|
- `workspaceId` — selected Queqiao Workspace;
|
|
80
|
-
- `url` — full HTTP
|
|
78
|
+
- `url` — full HTTP or HTTPS URL;
|
|
81
79
|
- `method` — `GET | POST | PUT | PATCH | DELETE | HEAD`, default `GET`;
|
|
82
80
|
- `headers` — optional string header map;
|
|
83
81
|
- `body` — optional raw string body;
|
|
@@ -86,9 +84,7 @@ Input fields:
|
|
|
86
84
|
|
|
87
85
|
When `json` is supplied, the extension serializes it and adds `content-type: application/json` unless the caller already supplied a Content-Type header.
|
|
88
86
|
|
|
89
|
-
###
|
|
90
|
-
|
|
91
|
-
A client using Queqiao's stable public `extension` tool can invoke the capability like this:
|
|
87
|
+
### Example
|
|
92
88
|
|
|
93
89
|
```json
|
|
94
90
|
{
|
|
@@ -97,80 +93,42 @@ A client using Queqiao's stable public `extension` tool can invoke the capabilit
|
|
|
97
93
|
"extensionId": "dev.queqiao.http",
|
|
98
94
|
"capability": "http_request",
|
|
99
95
|
"arguments": {
|
|
100
|
-
"url": "http://
|
|
96
|
+
"url": "http://172.31.39.34:9889/api/meal/types",
|
|
101
97
|
"method": "GET"
|
|
102
98
|
}
|
|
103
99
|
}
|
|
104
100
|
```
|
|
105
101
|
|
|
106
|
-
### JSON POST
|
|
107
|
-
|
|
108
|
-
```json
|
|
109
|
-
{
|
|
110
|
-
"workspaceId": "codes",
|
|
111
|
-
"operation": "call",
|
|
112
|
-
"extensionId": "dev.queqiao.http",
|
|
113
|
-
"capability": "http_request",
|
|
114
|
-
"arguments": {
|
|
115
|
-
"url": "http://127.0.0.1:9889/api/trans/save",
|
|
116
|
-
"method": "POST",
|
|
117
|
-
"json": {
|
|
118
|
-
"type": "支出",
|
|
119
|
-
"category": "食",
|
|
120
|
-
"name": "牛肉麵",
|
|
121
|
-
"value": 180,
|
|
122
|
-
"transDate": "2026-09-07T00:00:00"
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
```
|
|
127
|
-
|
|
128
102
|
## Response contract
|
|
129
103
|
|
|
130
|
-
|
|
104
|
+
Non-2xx status codes remain ordinary downstream HTTP responses:
|
|
131
105
|
|
|
132
106
|
```json
|
|
133
107
|
{
|
|
134
108
|
"status": 200,
|
|
135
|
-
"headers": {
|
|
136
|
-
"content-type": "application/json"
|
|
137
|
-
},
|
|
109
|
+
"headers": { "content-type": "application/json" },
|
|
138
110
|
"body": "{\"ok\":true}",
|
|
139
|
-
"json": {
|
|
140
|
-
"ok": true
|
|
141
|
-
}
|
|
111
|
+
"json": { "ok": true }
|
|
142
112
|
}
|
|
143
113
|
```
|
|
144
114
|
|
|
145
|
-
`json` is included only when the response body
|
|
146
|
-
|
|
147
|
-
For example, an application-level `HTTP 400` validation response remains a response with `status: 400`. Runtime policy failures such as a denied origin remain Queqiao runtime errors instead.
|
|
115
|
+
`json` is included only when the response body is JSON. `body` preserves the response text.
|
|
148
116
|
|
|
149
117
|
## Trust boundary
|
|
150
118
|
|
|
151
|
-
Queqiao extensions are trusted plugin code. Installing and attaching `queqiao-http` grants this extension
|
|
152
|
-
|
|
153
|
-
Queqiao remains authoritative for:
|
|
154
|
-
|
|
155
|
-
- explicit package install/attach intent;
|
|
156
|
-
- Extension contract validation;
|
|
157
|
-
- exact-origin authorization;
|
|
158
|
-
- HTTP/HTTPS scheme validation;
|
|
159
|
-
- redirect denial;
|
|
160
|
-
- request/response bounds;
|
|
161
|
-
- timeout and cancellation handling;
|
|
162
|
-
- Gateway → Worker routing and ExtensionHost lifecycle.
|
|
119
|
+
Queqiao extensions are trusted plugin code. Installing and attaching `queqiao-http` grants this extension open-world HTTP/HTTPS network authority from that Worker.
|
|
163
120
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
The extension intentionally has:
|
|
121
|
+
Queqiao remains authoritative for package installation/attachment, Extension contract validation, Gateway → Worker routing, and ExtensionHost lifecycle. The extension validates request shape, restricts the URL scheme to HTTP/HTTPS, applies the caller timeout, performs direct `fetch`, and normalizes the response.
|
|
167
122
|
|
|
168
123
|
```text
|
|
169
124
|
process allowlist: empty
|
|
170
125
|
shell access: none
|
|
171
126
|
curl execution: none
|
|
172
127
|
child_process: none
|
|
173
|
-
|
|
128
|
+
origin allowlist: none
|
|
129
|
+
direct global fetch: yes
|
|
130
|
+
risk: execute
|
|
131
|
+
openWorldHint: true
|
|
174
132
|
```
|
|
175
133
|
|
|
176
134
|
## Development
|
|
@@ -181,12 +139,8 @@ npm run check
|
|
|
181
139
|
npm pack --ignore-scripts --dry-run
|
|
182
140
|
```
|
|
183
141
|
|
|
184
|
-
The test suite covers request mapping, JSON serialization/parsing, body/JSON exclusivity, non-2xx preservation, runtime error propagation, manifest/schema parity, bilingual package documentation, and release workflow invariants.
|
|
185
|
-
|
|
186
142
|
## Releasing
|
|
187
143
|
|
|
188
|
-
Releases are tag-driven after the initial npm bootstrap:
|
|
189
|
-
|
|
190
144
|
```text
|
|
191
145
|
main CI passes
|
|
192
146
|
→ tag v<package-version>
|
package/README.zh-TW.md
CHANGED
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
[English](https://github.com/tibame201020/queqiao-http/blob/main/README.md) | [繁體中文](https://github.com/tibame201020/queqiao-http/blob/main/README.zh-TW.md)
|
|
4
4
|
|
|
5
|
-
[Queqiao](https://github.com/tibame201020/Queqiao) 的官方
|
|
5
|
+
[Queqiao](https://github.com/tibame201020/Queqiao) 的官方 curl-like HTTP extension。
|
|
6
6
|
|
|
7
|
-
`@tibame201020/queqiao-http`
|
|
7
|
+
`@tibame201020/queqiao-http` 讓已 attach 的 Queqiao Worker 取得方便的 `http_request` 能力,可直接發送 HTTP/HTTPS request。**安裝/attach extension 本身就是信任決策**;extension 不再維護 origin allowlist。
|
|
8
8
|
|
|
9
|
-
底層直接使用 `
|
|
9
|
+
底層直接使用 Worker 執行環境的 native `fetch`,不執行 `curl`、shell 或 `child_process`。
|
|
10
10
|
|
|
11
11
|
## 狀態
|
|
12
12
|
|
|
13
|
-
v0.1
|
|
13
|
+
v0.1.3 對應 Queqiao 0.9.7。Canonical npm package 為 `@tibame201020/queqiao-http`。
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
自 v0.1.1 起,npm 發布由 GitHub Release workflow 透過 npm Trusted Publishing + provenance 自動處理。
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
目前 request path:
|
|
18
18
|
|
|
19
19
|
```text
|
|
20
20
|
MCP client / LLM
|
|
@@ -22,22 +22,20 @@ MCP client / LLM
|
|
|
22
22
|
→ Queqiao Worker
|
|
23
23
|
→ stable extension proxy
|
|
24
24
|
→ queqiao-http
|
|
25
|
-
→
|
|
26
|
-
→
|
|
25
|
+
→ direct HTTP/HTTPS request
|
|
26
|
+
→ target service
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
已驗證行為包括:
|
|
30
30
|
|
|
31
|
-
- JSON GET request
|
|
32
|
-
- JSON response
|
|
31
|
+
- JSON GET/POST request;
|
|
32
|
+
- JSON request 自動 serialize、JSON response 自動 parse;
|
|
33
33
|
- backend HTTP 4xx 保留為正常 HTTP response;
|
|
34
|
-
-
|
|
34
|
+
- 可呼叫任意 HTTP/HTTPS origin,包括 localhost、WSL/private-network IP 與網際網路 origin;
|
|
35
35
|
- 安裝或更新 extension 不會擴張 Queqiao 公開 connector manifest。
|
|
36
36
|
|
|
37
37
|
## 安裝
|
|
38
38
|
|
|
39
|
-
從 npm 安裝並 attach 到所有 Worker:
|
|
40
|
-
|
|
41
39
|
```bash
|
|
42
40
|
queqiao extension install npm:@tibame201020/queqiao-http --attach-all
|
|
43
41
|
```
|
|
@@ -49,46 +47,44 @@ queqiao extension install npm:@tibame201020/queqiao-http
|
|
|
49
47
|
queqiao extension attach dev.queqiao.http --worker windows
|
|
50
48
|
```
|
|
51
49
|
|
|
52
|
-
`attach`
|
|
50
|
+
`attach` 即 activation。
|
|
53
51
|
|
|
54
|
-
|
|
52
|
+
## Network authority
|
|
55
53
|
|
|
56
|
-
|
|
54
|
+
`queqiao-http` 不再有 per-origin grant list。
|
|
57
55
|
|
|
58
|
-
|
|
56
|
+
安裝並 attach 此 extension,即明確授權它從 Worker 發送 HTTP/HTTPS request。這是刻意設計:此 extension 的定位是方便的 curl-like network capability,而不是綁定某個服務的 adapter。
|
|
59
57
|
|
|
60
|
-
|
|
61
|
-
http://127.0.0.1:9889
|
|
62
|
-
http://localhost:9889
|
|
63
|
-
```
|
|
58
|
+
Package manifest 因此不宣告 managed-runtime HTTP origin:
|
|
64
59
|
|
|
65
|
-
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"runtime": {
|
|
63
|
+
"processes": { "allow": [] },
|
|
64
|
+
"outboundHttp": { "allowOrigins": [] }
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
66
68
|
|
|
67
|
-
|
|
69
|
+
`allowOrigins` 為空是刻意的,因為 v0.1.3 已不再透過 `context.runtime.http.request()` 發送 request。
|
|
68
70
|
|
|
69
71
|
## Capability
|
|
70
72
|
|
|
71
|
-
`queqiao-http` 只註冊一個 capability
|
|
72
|
-
|
|
73
|
-
```text
|
|
74
|
-
http_request
|
|
75
|
-
```
|
|
73
|
+
`queqiao-http` 只註冊一個 capability:`http_request`。
|
|
76
74
|
|
|
77
75
|
輸入欄位:
|
|
78
76
|
|
|
79
77
|
- `workspaceId` — 選定的 Queqiao Workspace;
|
|
80
|
-
- `url` —
|
|
78
|
+
- `url` — 完整 HTTP 或 HTTPS URL;
|
|
81
79
|
- `method` — `GET | POST | PUT | PATCH | DELETE | HEAD`,預設 `GET`;
|
|
82
80
|
- `headers` — optional string header map;
|
|
83
81
|
- `body` — optional raw string body;
|
|
84
82
|
- `json` — optional JSON value,與 `body` 互斥;
|
|
85
83
|
- `timeoutMs` — `100` 到 `120000`,預設 `30000`。
|
|
86
84
|
|
|
87
|
-
提供 `json` 時,extension 會自動 serialize
|
|
88
|
-
|
|
89
|
-
### 透過 Queqiao extension proxy 呼叫
|
|
85
|
+
提供 `json` 時,extension 會自動 serialize,且 caller 未提供 Content-Type 時會補上 `content-type: application/json`。
|
|
90
86
|
|
|
91
|
-
|
|
87
|
+
### 範例
|
|
92
88
|
|
|
93
89
|
```json
|
|
94
90
|
{
|
|
@@ -97,80 +93,42 @@ http_request
|
|
|
97
93
|
"extensionId": "dev.queqiao.http",
|
|
98
94
|
"capability": "http_request",
|
|
99
95
|
"arguments": {
|
|
100
|
-
"url": "http://
|
|
96
|
+
"url": "http://172.31.39.34:9889/api/meal/types",
|
|
101
97
|
"method": "GET"
|
|
102
98
|
}
|
|
103
99
|
}
|
|
104
100
|
```
|
|
105
101
|
|
|
106
|
-
### JSON POST
|
|
107
|
-
|
|
108
|
-
```json
|
|
109
|
-
{
|
|
110
|
-
"workspaceId": "codes",
|
|
111
|
-
"operation": "call",
|
|
112
|
-
"extensionId": "dev.queqiao.http",
|
|
113
|
-
"capability": "http_request",
|
|
114
|
-
"arguments": {
|
|
115
|
-
"url": "http://127.0.0.1:9889/api/trans/save",
|
|
116
|
-
"method": "POST",
|
|
117
|
-
"json": {
|
|
118
|
-
"type": "支出",
|
|
119
|
-
"category": "食",
|
|
120
|
-
"name": "牛肉麵",
|
|
121
|
-
"value": 180,
|
|
122
|
-
"transDate": "2026-09-07T00:00:00"
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
```
|
|
127
|
-
|
|
128
102
|
## Response contract
|
|
129
103
|
|
|
130
|
-
|
|
104
|
+
非 2xx status 會保留為普通 downstream HTTP response:
|
|
131
105
|
|
|
132
106
|
```json
|
|
133
107
|
{
|
|
134
108
|
"status": 200,
|
|
135
|
-
"headers": {
|
|
136
|
-
"content-type": "application/json"
|
|
137
|
-
},
|
|
109
|
+
"headers": { "content-type": "application/json" },
|
|
138
110
|
"body": "{\"ok\":true}",
|
|
139
|
-
"json": {
|
|
140
|
-
"ok": true
|
|
141
|
-
}
|
|
111
|
+
"json": { "ok": true }
|
|
142
112
|
}
|
|
143
113
|
```
|
|
144
114
|
|
|
145
|
-
只有 response body
|
|
146
|
-
|
|
147
|
-
例如 application validation 的 `HTTP 400` 仍會以 `status: 400` response 回傳。相對地,origin 未授權這類 runtime policy failure,會維持 Queqiao runtime error。
|
|
115
|
+
只有 response body 能成功 parse 為 JSON 時才提供 `json`;`body` 保留文字 response。
|
|
148
116
|
|
|
149
117
|
## 信任邊界
|
|
150
118
|
|
|
151
|
-
Queqiao extension 屬於 trusted plugin code。安裝並 attach `queqiao-http
|
|
152
|
-
|
|
153
|
-
Queqiao 仍負責:
|
|
154
|
-
|
|
155
|
-
- 明確的 package install/attach intent;
|
|
156
|
-
- Extension contract validation;
|
|
157
|
-
- exact-origin authorization;
|
|
158
|
-
- HTTP/HTTPS scheme validation;
|
|
159
|
-
- redirect denial;
|
|
160
|
-
- request/response bounds;
|
|
161
|
-
- timeout 與 cancellation;
|
|
162
|
-
- Gateway → Worker routing 與 ExtensionHost lifecycle。
|
|
119
|
+
Queqiao extension 屬於 trusted plugin code。安裝並 attach `queqiao-http`,代表授權此 extension 從該 Worker 對外發送 open-world HTTP/HTTPS request。
|
|
163
120
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
Extension 刻意不具備:
|
|
121
|
+
Queqiao 仍負責 package install/attach、Extension contract validation、Gateway → Worker routing 與 ExtensionHost lifecycle。Extension 本身負責 request schema、限制 URL scheme 為 HTTP/HTTPS、timeout、直接 `fetch` 與 response normalize。
|
|
167
122
|
|
|
168
123
|
```text
|
|
169
124
|
process allowlist: empty
|
|
170
125
|
shell access: none
|
|
171
126
|
curl execution: none
|
|
172
127
|
child_process: none
|
|
173
|
-
|
|
128
|
+
origin allowlist: none
|
|
129
|
+
direct global fetch: yes
|
|
130
|
+
risk: execute
|
|
131
|
+
openWorldHint: true
|
|
174
132
|
```
|
|
175
133
|
|
|
176
134
|
## 開發
|
|
@@ -181,12 +139,8 @@ npm run check
|
|
|
181
139
|
npm pack --ignore-scripts --dry-run
|
|
182
140
|
```
|
|
183
141
|
|
|
184
|
-
Test suite 會驗證 request mapping、JSON serialization/parsing、body/JSON 互斥、non-2xx preservation、runtime error propagation、manifest/schema parity、中英文 package documentation,以及 release workflow invariants。
|
|
185
|
-
|
|
186
142
|
## 發布
|
|
187
143
|
|
|
188
|
-
首次 npm bootstrap 完成後,release 採 tag-driven:
|
|
189
|
-
|
|
190
144
|
```text
|
|
191
145
|
main CI passes
|
|
192
146
|
→ tag v<package-version>
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAEV,cAAc,EACd,sBAAsB,EACvB,MAAM,iCAAiC,CAAC;AAQzC,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;iBAYpC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAEV,cAAc,EACd,sBAAsB,EACvB,MAAM,iCAAiC,CAAC;AAQzC,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;iBAYpC,CAAC;AAkCH,eAAO,MAAM,uBAAuB,EAAE,cAAc,CAAC,sBAAsB,CAmD1E,CAAC;AAEF,QAAA,MAAM,SAAS;;;;;;;;CAUqC,CAAC;eAEtC,SAAS"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
const EXTENSION_ID = "dev.queqiao.http";
|
|
3
|
-
const EXTENSION_VERSION = "0.1.
|
|
3
|
+
const EXTENSION_VERSION = "0.1.3";
|
|
4
4
|
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
5
5
|
const headersSchema = z.record(z.string().min(1).max(256), z.string().max(8192));
|
|
6
6
|
export const HTTP_REQUEST_INPUT_SCHEMA = z.object({
|
|
@@ -38,10 +38,17 @@ function maybeParseJson(body, headers) {
|
|
|
38
38
|
return undefined;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
+
function validateHttpUrl(value) {
|
|
42
|
+
const url = new URL(value);
|
|
43
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
44
|
+
throw new Error("url must use http or https");
|
|
45
|
+
}
|
|
46
|
+
return url;
|
|
47
|
+
}
|
|
41
48
|
export const HTTP_REQUEST_DEFINITION = {
|
|
42
49
|
name: "http_request",
|
|
43
50
|
title: "HTTP request",
|
|
44
|
-
description: "Send one
|
|
51
|
+
description: "Send one direct HTTP/HTTPS request from the trusted Worker extension without an origin allowlist.",
|
|
45
52
|
inputSchema: HTTP_REQUEST_INPUT_SCHEMA,
|
|
46
53
|
requiredCapabilities: [],
|
|
47
54
|
risk: "execute",
|
|
@@ -51,8 +58,9 @@ export const HTTP_REQUEST_DEFINITION = {
|
|
|
51
58
|
openWorldHint: true,
|
|
52
59
|
idempotentHint: false,
|
|
53
60
|
},
|
|
54
|
-
async execute(input
|
|
61
|
+
async execute(input) {
|
|
55
62
|
const parsed = HTTP_REQUEST_INPUT_SCHEMA.parse(input);
|
|
63
|
+
validateHttpUrl(parsed.url);
|
|
56
64
|
const headers = parsed.headers ? { ...parsed.headers } : undefined;
|
|
57
65
|
let body = parsed.body;
|
|
58
66
|
if (parsed.json !== undefined) {
|
|
@@ -66,17 +74,24 @@ export const HTTP_REQUEST_DEFINITION = {
|
|
|
66
74
|
? { "content-type": "application/json" }
|
|
67
75
|
: headers;
|
|
68
76
|
const request = {
|
|
69
|
-
url: parsed.url,
|
|
70
77
|
method: parsed.method,
|
|
71
|
-
|
|
78
|
+
signal: AbortSignal.timeout(parsed.timeoutMs),
|
|
79
|
+
redirect: "follow",
|
|
72
80
|
};
|
|
73
81
|
if (requestHeaders !== undefined)
|
|
74
82
|
request.headers = requestHeaders;
|
|
75
83
|
if (body !== undefined)
|
|
76
84
|
request.body = body;
|
|
77
|
-
const response = await
|
|
78
|
-
const
|
|
79
|
-
|
|
85
|
+
const response = await fetch(parsed.url, request);
|
|
86
|
+
const responseHeaders = Object.fromEntries(response.headers.entries());
|
|
87
|
+
const responseBody = parsed.method === "HEAD" ? "" : await response.text();
|
|
88
|
+
const json = maybeParseJson(responseBody, responseHeaders);
|
|
89
|
+
const normalized = {
|
|
90
|
+
status: response.status,
|
|
91
|
+
headers: responseHeaders,
|
|
92
|
+
body: responseBody,
|
|
93
|
+
};
|
|
94
|
+
return json === undefined ? normalized : { ...normalized, json };
|
|
80
95
|
},
|
|
81
96
|
};
|
|
82
97
|
const extension = {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,MAAM,YAAY,GAAG,kBAAkB,CAAC;AACxC,MAAM,iBAAiB,GAAG,OAAO,CAAC;AAClC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAElC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;AAEjF,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChD,WAAW,EAAE,CAAC,CA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C,CAAC;QAElD,MAAM,eAAe,GAAG,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;QACvE,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC3E,MAAM,IAAI,GAAG,cAAc,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;QAC3D,MAAM,UAAU,GAAG;YACjB,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,OAAO,EAAE,eAAe;YACxB,IAAI,EAAE,YAAY;SACnB,CAAC;QACF,OAAO,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,UAAU,EAAE,IAAI,EAAE,CAAC;IACnE,CAAC;CACF,CAAC;AAEF,MAAM,SAAS,GAAG;IAChB,QAAQ,EAAE;QACR,EAAE,EAAE,YAAY;QAChB,OAAO,EAAE,iBAAiB;QAC1B,WAAW,EAAE,cAAc;QAC3B,qBAAqB,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,CAAC;KACtD;IACD,QAAQ,CAAC,GAAG;QACV,GAAG,CAAC,YAAY,CAAC,uBAAuB,CAAC,CAAC;IAC5C,CAAC;CACiD,CAAC;AAErD,eAAe,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tibame201020/queqiao-http",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "Trusted curl-like HTTP extension for Queqiao",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"module": "./dist/index.js",
|
|
44
44
|
"manifest": {
|
|
45
45
|
"id": "dev.queqiao.http",
|
|
46
|
-
"version": "0.1.
|
|
46
|
+
"version": "0.1.3",
|
|
47
47
|
"displayName": "Queqiao HTTP",
|
|
48
48
|
"host": {
|
|
49
49
|
"kind": "worker"
|
|
@@ -58,10 +58,7 @@
|
|
|
58
58
|
"allow": []
|
|
59
59
|
},
|
|
60
60
|
"outboundHttp": {
|
|
61
|
-
"allowOrigins": [
|
|
62
|
-
"http://127.0.0.1:9889",
|
|
63
|
-
"http://localhost:9889"
|
|
64
|
-
]
|
|
61
|
+
"allowOrigins": []
|
|
65
62
|
}
|
|
66
63
|
},
|
|
67
64
|
"contributions": [
|
|
@@ -70,7 +67,7 @@
|
|
|
70
67
|
"tool": "http_request",
|
|
71
68
|
"visibility": "public",
|
|
72
69
|
"title": "HTTP request",
|
|
73
|
-
"description": "Send one
|
|
70
|
+
"description": "Send one direct HTTP/HTTPS request from the trusted Worker extension without an origin allowlist.",
|
|
74
71
|
"inputSchema": {
|
|
75
72
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
76
73
|
"type": "object",
|