squally-mcp 0.8.2 → 0.8.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/dist/api.d.ts +5 -0
- package/dist/api.js +11 -1
- package/dist/result.d.ts +8 -0
- package/dist/result.js +17 -0
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -16,6 +16,11 @@ export type ApiFailure = {
|
|
|
16
16
|
message: string | null;
|
|
17
17
|
/** The API's stable slug, when it sent a body. */
|
|
18
18
|
code: string | null;
|
|
19
|
+
/**
|
|
20
|
+
* `x-vercel-mitigated`, when Vercel's firewall in front of the API stopped
|
|
21
|
+
* the request itself (0.8.3): "challenge" or "deny", otherwise null.
|
|
22
|
+
*/
|
|
23
|
+
mitigated: "challenge" | "deny" | null;
|
|
19
24
|
};
|
|
20
25
|
/** The request never reached the API, or the answer was not JSON. */
|
|
21
26
|
export type ApiUnreachable = {
|
package/dist/api.js
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { errorCauses } from "./diagnostics.js";
|
|
2
2
|
/** Set by the API from 7 days before the key expires (OpenAPI components.headers). */
|
|
3
3
|
export const KEY_EXPIRY_HEADER = "Squally-Key-Expires-At";
|
|
4
|
+
/**
|
|
5
|
+
* Vercel's firewall answering instead of the API (0.8.3). Measured 30.10.2026:
|
|
6
|
+
* this server's Node fetch got 403 with `x-vercel-mitigated: challenge` and
|
|
7
|
+
* Vercel's own `{"error":{"code":"challenge"}}` while curl with the same key
|
|
8
|
+
* got 200 - a temporary mitigation for one machine, not a refusal of the key.
|
|
9
|
+
*/
|
|
10
|
+
function edgeMitigation(headers) {
|
|
11
|
+
const value = (headers.get("x-vercel-mitigated") ?? "").trim().toLowerCase();
|
|
12
|
+
return value === "challenge" || value === "deny" ? value : null;
|
|
13
|
+
}
|
|
4
14
|
/**
|
|
5
15
|
* Query parameters for which an EMPTY STRING is a value, not an absence.
|
|
6
16
|
*
|
|
@@ -113,5 +123,5 @@ export async function callOperation(config, operation, args, fetcher = fetch) {
|
|
|
113
123
|
catch {
|
|
114
124
|
// Left null; the caller has a sentence for every status either way.
|
|
115
125
|
}
|
|
116
|
-
return { kind: "failure", status: response.status, message, code };
|
|
126
|
+
return { kind: "failure", status: response.status, message, code, mitigated: edgeMitigation(response.headers) };
|
|
117
127
|
}
|
package/dist/result.d.ts
CHANGED
|
@@ -3,6 +3,14 @@ import type { ApiFailure, ApiResult, ApiUnreachable } from "./api.js";
|
|
|
3
3
|
import type { ErrorCode } from "./openapi.js";
|
|
4
4
|
/** The one message for a rate limit, which arrives without a body. */
|
|
5
5
|
export declare const RATE_LIMITED_TEXT = "Rate limited - wait 60 seconds, then retry.";
|
|
6
|
+
/**
|
|
7
|
+
* Vercel's firewall stopped the request (0.8.3): 403 with
|
|
8
|
+
* `x-vercel-mitigated`. Until 0.8.2 this read "The Squally API answered HTTP
|
|
9
|
+
* 403." and nothing else - which sends an agent and its user after the key.
|
|
10
|
+
* One retry after a wait, not a loop: retrying into the challenge is what
|
|
11
|
+
* keeps it going.
|
|
12
|
+
*/
|
|
13
|
+
export declare function edgeMitigatedText(mitigated: "challenge" | "deny"): string;
|
|
6
14
|
/**
|
|
7
15
|
* The line appended when the key is within 7 days of expiring.
|
|
8
16
|
*
|
package/dist/result.js
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { describeFailure } from "./diagnostics.js";
|
|
2
2
|
/** The one message for a rate limit, which arrives without a body. */
|
|
3
3
|
export const RATE_LIMITED_TEXT = "Rate limited - wait 60 seconds, then retry.";
|
|
4
|
+
/**
|
|
5
|
+
* Vercel's firewall stopped the request (0.8.3): 403 with
|
|
6
|
+
* `x-vercel-mitigated`. Until 0.8.2 this read "The Squally API answered HTTP
|
|
7
|
+
* 403." and nothing else - which sends an agent and its user after the key.
|
|
8
|
+
* One retry after a wait, not a loop: retrying into the challenge is what
|
|
9
|
+
* keeps it going.
|
|
10
|
+
*/
|
|
11
|
+
export function edgeMitigatedText(mitigated) {
|
|
12
|
+
return (`Vercel's firewall in front of Squally ${mitigated === "deny" ? "blocked" : "challenged"} this request ` +
|
|
13
|
+
`(HTTP 403, x-vercel-mitigated: ${mitigated}). This is not a key problem - the key was not checked. ` +
|
|
14
|
+
"Wait a few minutes, then retry once; do not retry in a loop. If it persists, tell the user.");
|
|
15
|
+
}
|
|
4
16
|
function text(value) {
|
|
5
17
|
return { type: "text", text: value };
|
|
6
18
|
}
|
|
@@ -55,6 +67,11 @@ export function failureResult(failure, errorCodes) {
|
|
|
55
67
|
if (failure.status === 429) {
|
|
56
68
|
return { content: [text(RATE_LIMITED_TEXT)], isError: true };
|
|
57
69
|
}
|
|
70
|
+
// Before the API's own 403s (organization_deleted, tier_too_low): those
|
|
71
|
+
// come without the header and keep their sentence and action.
|
|
72
|
+
if (failure.status === 403 && failure.mitigated !== null) {
|
|
73
|
+
return { content: [text(edgeMitigatedText(failure.mitigated))], isError: true };
|
|
74
|
+
}
|
|
58
75
|
const known = failure.code ? errorCodes.get(failure.code) : undefined;
|
|
59
76
|
const lines = [];
|
|
60
77
|
lines.push(failure.message ?? `The Squally API answered HTTP ${failure.status}.`);
|