@weftlabs/sdk 0.25.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/README.md +499 -0
- package/dist/client-C9_zh3Qg.d.mts +11 -0
- package/dist/client-C9_zh3Qg.d.ts +11 -0
- package/dist/facilitator/index.d.mts +18 -0
- package/dist/facilitator/index.d.ts +18 -0
- package/dist/facilitator/index.js +180 -0
- package/dist/facilitator/index.js.map +1 -0
- package/dist/facilitator/index.mjs +149 -0
- package/dist/facilitator/index.mjs.map +1 -0
- package/dist/facilitator/middleware/index.d.mts +539 -0
- package/dist/facilitator/middleware/index.d.ts +539 -0
- package/dist/facilitator/middleware/index.js +1522 -0
- package/dist/facilitator/middleware/index.js.map +1 -0
- package/dist/facilitator/middleware/index.mjs +1493 -0
- package/dist/facilitator/middleware/index.mjs.map +1 -0
- package/dist/index.d.mts +5667 -0
- package/dist/index.d.ts +5667 -0
- package/dist/index.js +5555 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +5553 -0
- package/dist/index.mjs.map +1 -0
- package/dist/server.d.mts +8 -0
- package/dist/server.d.ts +8 -0
- package/dist/server.js +1587 -0
- package/dist/server.js.map +1 -0
- package/dist/server.mjs +1574 -0
- package/dist/server.mjs.map +1 -0
- package/docs/APIKeysApi.md +219 -0
- package/docs/AccountApi.md +72 -0
- package/docs/AccountBootstrapApproval.md +36 -0
- package/docs/AccountBootstrapCreated.md +44 -0
- package/docs/AccountBootstrapCreatedApproval.md +38 -0
- package/docs/AccountBootstrapCreatedResponse.md +32 -0
- package/docs/AccountBootstrapRequest.md +42 -0
- package/docs/AccountBootstrapStatus.md +40 -0
- package/docs/AccountBootstrapStatusResponse.md +32 -0
- package/docs/AccountDetails.md +43 -0
- package/docs/AgentBootstrapApi.md +223 -0
- package/docs/ApiKey.md +42 -0
- package/docs/ApiKeyCreated.md +40 -0
- package/docs/ApiKeyCreatedResponse.md +32 -0
- package/docs/ApiKeyListResponse.md +34 -0
- package/docs/AuthApi.md +408 -0
- package/docs/AuthResponse.md +32 -0
- package/docs/AuthResponseData.md +36 -0
- package/docs/BalanceApi.md +73 -0
- package/docs/BalanceResponse.md +45 -0
- package/docs/ConfirmRequest.md +32 -0
- package/docs/CreateApiKeyRequest.md +32 -0
- package/docs/DocumentationApi.md +65 -0
- package/docs/EnrolledResource.md +59 -0
- package/docs/ErrorResponse.md +33 -0
- package/docs/Fetch403Response.md +44 -0
- package/docs/FetchApi.md +91 -0
- package/docs/FetchBalanceSnapshot.md +41 -0
- package/docs/FetchErrorResponse.md +41 -0
- package/docs/FetchRequest.md +46 -0
- package/docs/FetchRequestBody.md +31 -0
- package/docs/FetchResponse.md +49 -0
- package/docs/InsufficientScopeResponse.md +37 -0
- package/docs/MeApiKey.md +40 -0
- package/docs/MeApiKeyCreator.md +37 -0
- package/docs/MeResponse.md +32 -0
- package/docs/MeResponseData.md +56 -0
- package/docs/MessageResponse.md +32 -0
- package/docs/MessageResponseData.md +32 -0
- package/docs/ModelError.md +39 -0
- package/docs/Pagination.md +38 -0
- package/docs/PasswordResetRequest.md +32 -0
- package/docs/PasswordUpdateRequest.md +36 -0
- package/docs/Payment.md +56 -0
- package/docs/PaymentListResponse.md +34 -0
- package/docs/PaymentResponse.md +32 -0
- package/docs/PaymentsApi.md +154 -0
- package/docs/PrincipalWallet.md +34 -0
- package/docs/PromoBalance.md +37 -0
- package/docs/Purchase.md +58 -0
- package/docs/PurchaseArtifact.md +38 -0
- package/docs/PurchaseListResponse.md +34 -0
- package/docs/PurchaseResponse.md +32 -0
- package/docs/PurchasesApi.md +157 -0
- package/docs/RateLimitResponse.md +34 -0
- package/docs/ResendConfirmationRequest.md +32 -0
- package/docs/ResourceEnrollmentRequest.md +39 -0
- package/docs/ResourceEnrollmentResponse.md +32 -0
- package/docs/ResourceStats.md +45 -0
- package/docs/ResourcesApi.md +77 -0
- package/docs/SearchAccessMethod.md +52 -0
- package/docs/SearchApi.md +86 -0
- package/docs/SearchCapabilityRef.md +34 -0
- package/docs/SearchCuratedCallability.md +34 -0
- package/docs/SearchCuratedExecution.md +32 -0
- package/docs/SearchCuratedOperation.md +36 -0
- package/docs/SearchCuratedService.md +34 -0
- package/docs/SearchCuratedSource.md +36 -0
- package/docs/SearchEndpointCall.md +39 -0
- package/docs/SearchEndpointHit.md +74 -0
- package/docs/SearchEndpointPrice.md +41 -0
- package/docs/SearchErrorResponse.md +35 -0
- package/docs/SearchExecutionModeFilter.md +34 -0
- package/docs/SearchFilterSpec.md +49 -0
- package/docs/SearchMethodFilter.md +34 -0
- package/docs/SearchPaymentOffer.md +47 -0
- package/docs/SearchPriceAtomicFilter.md +41 -0
- package/docs/SearchPriceUsdFilter.md +41 -0
- package/docs/SearchProtocolFilter.md +35 -0
- package/docs/SearchProviderRef.md +36 -0
- package/docs/SearchRequest.md +36 -0
- package/docs/SearchResourceTypeFilter.md +35 -0
- package/docs/SearchResponse.md +67 -0
- package/docs/SearchResponseWarningsInner.md +38 -0
- package/docs/SearchResult.md +38 -0
- package/docs/SearchStringSetFilter.md +34 -0
- package/docs/SearchWeftFetchCompatibility.md +36 -0
- package/docs/SignInRequest.md +34 -0
- package/docs/SignUpRequest.md +36 -0
- package/docs/SpendingPolicy.md +36 -0
- package/docs/User.md +36 -0
- package/docs/UserPrincipal.md +49 -0
- package/docs/Wallet.md +42 -0
- package/examples/charge-api-hono.mjs +40 -0
- package/examples/charge-api.mjs +43 -0
- package/examples/quickstart.mjs +16 -0
- package/package.json +105 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Hono } from "hono";
|
|
2
|
+
import { ExactEvmScheme } from "@x402/evm/exact/server";
|
|
3
|
+
import { weftPaymentMiddlewareHono } from "@weftlabs/sdk/facilitator/middleware";
|
|
4
|
+
|
|
5
|
+
const apiKey = process.env.WEFT_SELLER_API_KEY;
|
|
6
|
+
if (!apiKey) {
|
|
7
|
+
throw new Error("Set WEFT_SELLER_API_KEY to a seller ax_live_* API key");
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const payTo = process.env.WEFT_PAY_TO;
|
|
11
|
+
if (!payTo) {
|
|
12
|
+
throw new Error("Set WEFT_PAY_TO to the wallet address that gets paid");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const network = process.env.WEFT_NETWORK ?? "eip155:8453";
|
|
16
|
+
|
|
17
|
+
const app = new Hono();
|
|
18
|
+
|
|
19
|
+
app.use(
|
|
20
|
+
weftPaymentMiddlewareHono(
|
|
21
|
+
{
|
|
22
|
+
"GET /v1/quote": {
|
|
23
|
+
accepts: { scheme: "exact", network, payTo, price: "$0.01" },
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
apiKey,
|
|
28
|
+
name: "Acme Pricing API",
|
|
29
|
+
type: "api",
|
|
30
|
+
tags: ["finance", "pricing"],
|
|
31
|
+
schemes: [{ network, server: new ExactEvmScheme() }],
|
|
32
|
+
},
|
|
33
|
+
),
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
app.get("/v1/quote", (c) =>
|
|
37
|
+
c.json({ symbol: "ACME", price: "12.34", currency: "USD" }),
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
export default app;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import express from "express";
|
|
2
|
+
import { ExactEvmScheme } from "@x402/evm/exact/server";
|
|
3
|
+
import { weftPaymentMiddleware } from "@weftlabs/sdk/facilitator/middleware";
|
|
4
|
+
|
|
5
|
+
const apiKey = process.env.WEFT_SELLER_API_KEY;
|
|
6
|
+
if (!apiKey) {
|
|
7
|
+
throw new Error("Set WEFT_SELLER_API_KEY to a seller ax_live_* API key");
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const payTo = process.env.WEFT_PAY_TO;
|
|
11
|
+
if (!payTo) {
|
|
12
|
+
throw new Error("Set WEFT_PAY_TO to the wallet address that gets paid");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const network = process.env.WEFT_NETWORK ?? "eip155:8453";
|
|
16
|
+
|
|
17
|
+
const app = express();
|
|
18
|
+
|
|
19
|
+
app.use(
|
|
20
|
+
weftPaymentMiddleware(
|
|
21
|
+
{
|
|
22
|
+
"GET /v1/quote": {
|
|
23
|
+
accepts: { scheme: "exact", network, payTo, price: "$0.01" },
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
apiKey,
|
|
28
|
+
name: "Acme Pricing API",
|
|
29
|
+
type: "api",
|
|
30
|
+
tags: ["finance", "pricing"],
|
|
31
|
+
schemes: [{ network, server: new ExactEvmScheme() }],
|
|
32
|
+
},
|
|
33
|
+
),
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
app.get("/v1/quote", (_req, res) => {
|
|
37
|
+
res.json({ symbol: "ACME", price: "12.34", currency: "USD" });
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const port = Number(process.env.PORT ?? 3000);
|
|
41
|
+
app.listen(port, () => {
|
|
42
|
+
console.log(JSON.stringify({ listening: port }));
|
|
43
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { WeftClient } from "@weftlabs/sdk";
|
|
2
|
+
|
|
3
|
+
const apiKey = process.env.WEFT_API_KEY;
|
|
4
|
+
if (!apiKey) {
|
|
5
|
+
throw new Error("Set WEFT_API_KEY to a buyer wk_* API key");
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const weft = new WeftClient({
|
|
9
|
+
apiKey,
|
|
10
|
+
...(process.env.WEFT_BASE_URL ? { baseUrl: process.env.WEFT_BASE_URL } : {}),
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const account = await weft.me();
|
|
14
|
+
const search = await weft.search({ query: "weather data API" });
|
|
15
|
+
|
|
16
|
+
console.log(JSON.stringify({ account: account.data, results: search.results }));
|
package/package.json
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@weftlabs/sdk",
|
|
3
|
+
"version": "0.25.0",
|
|
4
|
+
"description": "Unified Weft SDK for the Weft API and x402 Facilitator",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./dist/index.d.mts",
|
|
12
|
+
"default": "./dist/index.mjs"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"./facilitator": {
|
|
20
|
+
"import": {
|
|
21
|
+
"types": "./dist/facilitator/index.d.mts",
|
|
22
|
+
"default": "./dist/facilitator/index.mjs"
|
|
23
|
+
},
|
|
24
|
+
"require": {
|
|
25
|
+
"types": "./dist/facilitator/index.d.ts",
|
|
26
|
+
"default": "./dist/facilitator/index.js"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"./facilitator/middleware": {
|
|
30
|
+
"import": {
|
|
31
|
+
"types": "./dist/facilitator/middleware/index.d.mts",
|
|
32
|
+
"default": "./dist/facilitator/middleware/index.mjs"
|
|
33
|
+
},
|
|
34
|
+
"require": {
|
|
35
|
+
"types": "./dist/facilitator/middleware/index.d.ts",
|
|
36
|
+
"default": "./dist/facilitator/middleware/index.js"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"./server": {
|
|
40
|
+
"import": {
|
|
41
|
+
"types": "./dist/server.d.mts",
|
|
42
|
+
"default": "./dist/server.mjs"
|
|
43
|
+
},
|
|
44
|
+
"require": {
|
|
45
|
+
"types": "./dist/server.d.ts",
|
|
46
|
+
"default": "./dist/server.js"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"keywords": [
|
|
51
|
+
"weft",
|
|
52
|
+
"x402",
|
|
53
|
+
"payments",
|
|
54
|
+
"micropayments",
|
|
55
|
+
"coinbase",
|
|
56
|
+
"sdk"
|
|
57
|
+
],
|
|
58
|
+
"author": "Weft Labs",
|
|
59
|
+
"license": "Apache-2.0",
|
|
60
|
+
"repository": {
|
|
61
|
+
"type": "git",
|
|
62
|
+
"url": "https://github.com/weftlabs/weft-sdk"
|
|
63
|
+
},
|
|
64
|
+
"peerDependencies": {
|
|
65
|
+
"@x402/core": "^2.24.0"
|
|
66
|
+
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@types/node": "^26.1.2",
|
|
69
|
+
"@typescript-eslint/eslint-plugin": "^8.29.1",
|
|
70
|
+
"@typescript-eslint/parser": "^8.29.1",
|
|
71
|
+
"@x402/core": "2.24.0",
|
|
72
|
+
"eslint": "^10.4.1",
|
|
73
|
+
"express": "^5.2.1",
|
|
74
|
+
"fast-check": "^4.8.0",
|
|
75
|
+
"hono": "^4.13.5",
|
|
76
|
+
"prettier": "3.9.6",
|
|
77
|
+
"tsup": "^8.4.0",
|
|
78
|
+
"typescript": "^6.0.3",
|
|
79
|
+
"vitest": "^4.1.8"
|
|
80
|
+
},
|
|
81
|
+
"files": [
|
|
82
|
+
"dist",
|
|
83
|
+
"docs",
|
|
84
|
+
"examples",
|
|
85
|
+
"README.md"
|
|
86
|
+
],
|
|
87
|
+
"engines": {
|
|
88
|
+
"node": ">=18.0.0"
|
|
89
|
+
},
|
|
90
|
+
"overrides": {
|
|
91
|
+
"esbuild": "^0.28.1"
|
|
92
|
+
},
|
|
93
|
+
"scripts": {
|
|
94
|
+
"build": "tsup",
|
|
95
|
+
"test": "vitest run",
|
|
96
|
+
"test:unit": "vitest run",
|
|
97
|
+
"lint": "eslint --fix",
|
|
98
|
+
"lint:check": "eslint",
|
|
99
|
+
"format": "prettier --write \"src/**/*.ts\" \"!src/generated/**\" \"examples/*.mjs\" \"../scripts/test-typescript-quickstarts.mjs\" \"../scripts/test-seller-quickstarts.mjs\"",
|
|
100
|
+
"format:check": "prettier --check \"src/**/*.ts\" \"!src/generated/**\" \"examples/*.mjs\" \"../scripts/test-typescript-quickstarts.mjs\" \"../scripts/test-seller-quickstarts.mjs\"",
|
|
101
|
+
"hooks:pre-push": "pnpm run lint:check && pnpm run format:check && vitest run",
|
|
102
|
+
"generate": "../scripts/generate-typescript.sh",
|
|
103
|
+
"smoke": "pnpm run build && node ../scripts/weft-smoke.mjs"
|
|
104
|
+
}
|
|
105
|
+
}
|