veriql-agentkit 0.1.0 → 0.1.1
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.
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
export declare const VERIQL_BASE_URL = "https://veriql.app";
|
|
2
|
+
/**
|
|
3
|
+
* Sent on every request so Veriql can tell which framework a call came
|
|
4
|
+
* through. Kept equal to package.json by a test.
|
|
5
|
+
*/
|
|
6
|
+
export declare const USER_AGENT = "veriql-agentkit/0.1.1";
|
|
2
7
|
/**
|
|
3
8
|
* Veriql charges $0.005 per call. The default cap leaves room for a price
|
|
4
9
|
* change without letting a misconfigured endpoint charge an agent real money:
|
package/dist/veriql/constants.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
export const VERIQL_BASE_URL = "https://veriql.app";
|
|
2
|
+
/**
|
|
3
|
+
* Sent on every request so Veriql can tell which framework a call came
|
|
4
|
+
* through. Kept equal to package.json by a test.
|
|
5
|
+
*/
|
|
6
|
+
export const USER_AGENT = "veriql-agentkit/0.1.1";
|
|
2
7
|
/**
|
|
3
8
|
* Veriql charges $0.005 per call. The default cap leaves room for a price
|
|
4
9
|
* change without letting a misconfigured endpoint charge an agent real money:
|
|
@@ -13,7 +13,27 @@ import { wrapFetchWithPayment, x402Client } from "@x402/fetch";
|
|
|
13
13
|
import { registerExactEvmScheme } from "@x402/evm/exact/client";
|
|
14
14
|
import { registerExactSvmScheme } from "@x402/svm/exact/client";
|
|
15
15
|
import { CheckDenylistSchema, CheckPayeeSchema, CheckSignatureSchema } from "./schemas.js";
|
|
16
|
-
import { DEFAULT_MAX_PAYMENT_USDC, DENYLIST_TTL_MS, USDC_DECIMALS, VERIQL_BASE_URL, } from "./constants.js";
|
|
16
|
+
import { DEFAULT_MAX_PAYMENT_USDC, DENYLIST_TTL_MS, USDC_DECIMALS, USER_AGENT, VERIQL_BASE_URL, } from "./constants.js";
|
|
17
|
+
/**
|
|
18
|
+
* The global fetch, with our user-agent added unless the caller set one.
|
|
19
|
+
* Resolved per call so a fetch swapped in later (tests, polyfills) is used.
|
|
20
|
+
*
|
|
21
|
+
* @param input - The URL or Request
|
|
22
|
+
* @param init - The request options
|
|
23
|
+
* @returns The response
|
|
24
|
+
*/
|
|
25
|
+
const veriqlFetch = (input, init) => {
|
|
26
|
+
if (input instanceof Request) {
|
|
27
|
+
const headers = new Headers(input.headers);
|
|
28
|
+
if (!headers.has("user-agent"))
|
|
29
|
+
headers.set("user-agent", USER_AGENT);
|
|
30
|
+
return fetch(new Request(input, { ...init, headers }));
|
|
31
|
+
}
|
|
32
|
+
const headers = new Headers(init?.headers);
|
|
33
|
+
if (!headers.has("user-agent"))
|
|
34
|
+
headers.set("user-agent", USER_AGENT);
|
|
35
|
+
return fetch(input, { ...init, headers });
|
|
36
|
+
};
|
|
17
37
|
/**
|
|
18
38
|
* Which denylist family an address belongs to, by shape alone. Tron is checked
|
|
19
39
|
* before Solana because a 34-character Tron address also passes a base58
|
|
@@ -182,7 +202,7 @@ export class VeriqlActionProvider extends ActionProvider {
|
|
|
182
202
|
const hit = this.denylist.get(family);
|
|
183
203
|
if (hit && Date.now() - hit.at < DENYLIST_TTL_MS)
|
|
184
204
|
return hit.values;
|
|
185
|
-
const res = await
|
|
205
|
+
const res = await veriqlFetch(`${this.baseUrl}/api/denylist?family=${family}`);
|
|
186
206
|
if (!res.ok) {
|
|
187
207
|
// The feed answers 503 rather than an empty list; keep a stale copy.
|
|
188
208
|
if (hit)
|
|
@@ -216,7 +236,7 @@ export class VeriqlActionProvider extends ActionProvider {
|
|
|
216
236
|
try {
|
|
217
237
|
let res;
|
|
218
238
|
if (this.apiKey) {
|
|
219
|
-
res = await
|
|
239
|
+
res = await veriqlFetch(url, { ...init, headers: { ...init.headers, "x-api-key": this.apiKey } });
|
|
220
240
|
}
|
|
221
241
|
else {
|
|
222
242
|
const client = await this.createX402Client(walletProvider);
|
|
@@ -226,7 +246,7 @@ export class VeriqlActionProvider extends ActionProvider {
|
|
|
226
246
|
message: "This wallet cannot pay over x402 (needs an EVM or Solana wallet holding USDC on Base or Solana). Set VERIQL_API_KEY instead: a free key is at https://veriql.app/api/checkout?pack=free",
|
|
227
247
|
});
|
|
228
248
|
}
|
|
229
|
-
res = await wrapFetchWithPayment(
|
|
249
|
+
res = await wrapFetchWithPayment(veriqlFetch, client)(url, init);
|
|
230
250
|
}
|
|
231
251
|
const text = await res.text();
|
|
232
252
|
let data = text;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "veriql-agentkit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Veriql for Coinbase AgentKit: check a recipient (OFAC, Drain Watch, Tether/Circle freeze) before an agent pays, decode a signing request before it signs, and load a free denylist for wallet policies.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentkit",
|