@byoky/openclaw-plugin 0.3.0 → 0.4.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/index.js +16 -15
- package/package.json +6 -6
- package/LICENSE +0 -21
package/dist/index.js
CHANGED
|
@@ -293,17 +293,7 @@ async function startCallbackServer(ctx, requestProviderId) {
|
|
|
293
293
|
return new Promise((resolve) => {
|
|
294
294
|
let resolved = false;
|
|
295
295
|
const server = createServer((req, res) => {
|
|
296
|
-
|
|
297
|
-
let isLocalhost = false;
|
|
298
|
-
try {
|
|
299
|
-
const parsed = new URL(reqOrigin);
|
|
300
|
-
isLocalhost = parsed.hostname === "127.0.0.1" || parsed.hostname === "localhost";
|
|
301
|
-
} catch {
|
|
302
|
-
}
|
|
303
|
-
res.setHeader(
|
|
304
|
-
"Access-Control-Allow-Origin",
|
|
305
|
-
isLocalhost ? reqOrigin : "http://127.0.0.1"
|
|
306
|
-
);
|
|
296
|
+
res.setHeader("Access-Control-Allow-Origin", "http://127.0.0.1");
|
|
307
297
|
res.setHeader("Access-Control-Allow-Methods", "POST, OPTIONS");
|
|
308
298
|
res.setHeader("Access-Control-Allow-Headers", "Content-Type");
|
|
309
299
|
if (req.method === "OPTIONS") {
|
|
@@ -312,11 +302,22 @@ async function startCallbackServer(ctx, requestProviderId) {
|
|
|
312
302
|
return;
|
|
313
303
|
}
|
|
314
304
|
if (req.method === "POST" && req.url === "/callback") {
|
|
305
|
+
const MAX_BODY_SIZE = 1048576;
|
|
315
306
|
let body = "";
|
|
307
|
+
let oversized = false;
|
|
316
308
|
req.on("data", (chunk) => {
|
|
317
309
|
body += chunk.toString();
|
|
310
|
+
if (body.length > MAX_BODY_SIZE) {
|
|
311
|
+
oversized = true;
|
|
312
|
+
req.destroy();
|
|
313
|
+
}
|
|
318
314
|
});
|
|
319
315
|
req.on("end", () => {
|
|
316
|
+
if (oversized) {
|
|
317
|
+
res.writeHead(413);
|
|
318
|
+
res.end("Request body too large");
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
320
321
|
try {
|
|
321
322
|
const data = JSON.parse(body);
|
|
322
323
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
@@ -324,8 +325,8 @@ async function startCallbackServer(ctx, requestProviderId) {
|
|
|
324
325
|
if (!resolved) {
|
|
325
326
|
resolved = true;
|
|
326
327
|
resolve({
|
|
327
|
-
providers: data.providers
|
|
328
|
-
port: data.bridgePort
|
|
328
|
+
providers: Array.isArray(data.providers) ? data.providers : [],
|
|
329
|
+
port: typeof data.bridgePort === "number" ? data.bridgePort : DEFAULT_BRIDGE_PORT,
|
|
329
330
|
server
|
|
330
331
|
});
|
|
331
332
|
}
|
|
@@ -429,7 +430,7 @@ function buildAuthPage(requestProviderId) {
|
|
|
429
430
|
id: requestId,
|
|
430
431
|
requestId,
|
|
431
432
|
payload: { providers: ${providerFilter} },
|
|
432
|
-
},
|
|
433
|
+
}, window.location.origin);
|
|
433
434
|
|
|
434
435
|
const response = await new Promise((resolve, reject) => {
|
|
435
436
|
function handler(event) {
|
|
@@ -461,7 +462,7 @@ function buildAuthPage(requestProviderId) {
|
|
|
461
462
|
requestId: bridgeRequestId,
|
|
462
463
|
action: 'startBridgeProxy',
|
|
463
464
|
payload: { sessionKey: response.sessionKey, port: ${DEFAULT_BRIDGE_PORT} },
|
|
464
|
-
},
|
|
465
|
+
}, window.location.origin);
|
|
465
466
|
|
|
466
467
|
const bridgeResult = await new Promise((resolve, reject) => {
|
|
467
468
|
function handler(event) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@byoky/openclaw-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Byoky wallet provider plugin for OpenClaw — manage AI API keys from your browser wallet",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
"openclaw.plugin.json",
|
|
11
11
|
"auth-page"
|
|
12
12
|
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsup",
|
|
15
|
+
"dev": "tsup --watch"
|
|
16
|
+
},
|
|
13
17
|
"openclaw": {
|
|
14
18
|
"extensions": [
|
|
15
19
|
"./dist/index.js"
|
|
@@ -34,9 +38,5 @@
|
|
|
34
38
|
"openclaw": "^2026.3.13",
|
|
35
39
|
"tsup": "^8.0.0",
|
|
36
40
|
"typescript": "^5.5.0"
|
|
37
|
-
},
|
|
38
|
-
"scripts": {
|
|
39
|
-
"build": "tsup",
|
|
40
|
-
"dev": "tsup --watch"
|
|
41
41
|
}
|
|
42
|
-
}
|
|
42
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 byoky contributors
|
|
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.
|