@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.
Files changed (124) hide show
  1. package/README.md +499 -0
  2. package/dist/client-C9_zh3Qg.d.mts +11 -0
  3. package/dist/client-C9_zh3Qg.d.ts +11 -0
  4. package/dist/facilitator/index.d.mts +18 -0
  5. package/dist/facilitator/index.d.ts +18 -0
  6. package/dist/facilitator/index.js +180 -0
  7. package/dist/facilitator/index.js.map +1 -0
  8. package/dist/facilitator/index.mjs +149 -0
  9. package/dist/facilitator/index.mjs.map +1 -0
  10. package/dist/facilitator/middleware/index.d.mts +539 -0
  11. package/dist/facilitator/middleware/index.d.ts +539 -0
  12. package/dist/facilitator/middleware/index.js +1522 -0
  13. package/dist/facilitator/middleware/index.js.map +1 -0
  14. package/dist/facilitator/middleware/index.mjs +1493 -0
  15. package/dist/facilitator/middleware/index.mjs.map +1 -0
  16. package/dist/index.d.mts +5667 -0
  17. package/dist/index.d.ts +5667 -0
  18. package/dist/index.js +5555 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/index.mjs +5553 -0
  21. package/dist/index.mjs.map +1 -0
  22. package/dist/server.d.mts +8 -0
  23. package/dist/server.d.ts +8 -0
  24. package/dist/server.js +1587 -0
  25. package/dist/server.js.map +1 -0
  26. package/dist/server.mjs +1574 -0
  27. package/dist/server.mjs.map +1 -0
  28. package/docs/APIKeysApi.md +219 -0
  29. package/docs/AccountApi.md +72 -0
  30. package/docs/AccountBootstrapApproval.md +36 -0
  31. package/docs/AccountBootstrapCreated.md +44 -0
  32. package/docs/AccountBootstrapCreatedApproval.md +38 -0
  33. package/docs/AccountBootstrapCreatedResponse.md +32 -0
  34. package/docs/AccountBootstrapRequest.md +42 -0
  35. package/docs/AccountBootstrapStatus.md +40 -0
  36. package/docs/AccountBootstrapStatusResponse.md +32 -0
  37. package/docs/AccountDetails.md +43 -0
  38. package/docs/AgentBootstrapApi.md +223 -0
  39. package/docs/ApiKey.md +42 -0
  40. package/docs/ApiKeyCreated.md +40 -0
  41. package/docs/ApiKeyCreatedResponse.md +32 -0
  42. package/docs/ApiKeyListResponse.md +34 -0
  43. package/docs/AuthApi.md +408 -0
  44. package/docs/AuthResponse.md +32 -0
  45. package/docs/AuthResponseData.md +36 -0
  46. package/docs/BalanceApi.md +73 -0
  47. package/docs/BalanceResponse.md +45 -0
  48. package/docs/ConfirmRequest.md +32 -0
  49. package/docs/CreateApiKeyRequest.md +32 -0
  50. package/docs/DocumentationApi.md +65 -0
  51. package/docs/EnrolledResource.md +59 -0
  52. package/docs/ErrorResponse.md +33 -0
  53. package/docs/Fetch403Response.md +44 -0
  54. package/docs/FetchApi.md +91 -0
  55. package/docs/FetchBalanceSnapshot.md +41 -0
  56. package/docs/FetchErrorResponse.md +41 -0
  57. package/docs/FetchRequest.md +46 -0
  58. package/docs/FetchRequestBody.md +31 -0
  59. package/docs/FetchResponse.md +49 -0
  60. package/docs/InsufficientScopeResponse.md +37 -0
  61. package/docs/MeApiKey.md +40 -0
  62. package/docs/MeApiKeyCreator.md +37 -0
  63. package/docs/MeResponse.md +32 -0
  64. package/docs/MeResponseData.md +56 -0
  65. package/docs/MessageResponse.md +32 -0
  66. package/docs/MessageResponseData.md +32 -0
  67. package/docs/ModelError.md +39 -0
  68. package/docs/Pagination.md +38 -0
  69. package/docs/PasswordResetRequest.md +32 -0
  70. package/docs/PasswordUpdateRequest.md +36 -0
  71. package/docs/Payment.md +56 -0
  72. package/docs/PaymentListResponse.md +34 -0
  73. package/docs/PaymentResponse.md +32 -0
  74. package/docs/PaymentsApi.md +154 -0
  75. package/docs/PrincipalWallet.md +34 -0
  76. package/docs/PromoBalance.md +37 -0
  77. package/docs/Purchase.md +58 -0
  78. package/docs/PurchaseArtifact.md +38 -0
  79. package/docs/PurchaseListResponse.md +34 -0
  80. package/docs/PurchaseResponse.md +32 -0
  81. package/docs/PurchasesApi.md +157 -0
  82. package/docs/RateLimitResponse.md +34 -0
  83. package/docs/ResendConfirmationRequest.md +32 -0
  84. package/docs/ResourceEnrollmentRequest.md +39 -0
  85. package/docs/ResourceEnrollmentResponse.md +32 -0
  86. package/docs/ResourceStats.md +45 -0
  87. package/docs/ResourcesApi.md +77 -0
  88. package/docs/SearchAccessMethod.md +52 -0
  89. package/docs/SearchApi.md +86 -0
  90. package/docs/SearchCapabilityRef.md +34 -0
  91. package/docs/SearchCuratedCallability.md +34 -0
  92. package/docs/SearchCuratedExecution.md +32 -0
  93. package/docs/SearchCuratedOperation.md +36 -0
  94. package/docs/SearchCuratedService.md +34 -0
  95. package/docs/SearchCuratedSource.md +36 -0
  96. package/docs/SearchEndpointCall.md +39 -0
  97. package/docs/SearchEndpointHit.md +74 -0
  98. package/docs/SearchEndpointPrice.md +41 -0
  99. package/docs/SearchErrorResponse.md +35 -0
  100. package/docs/SearchExecutionModeFilter.md +34 -0
  101. package/docs/SearchFilterSpec.md +49 -0
  102. package/docs/SearchMethodFilter.md +34 -0
  103. package/docs/SearchPaymentOffer.md +47 -0
  104. package/docs/SearchPriceAtomicFilter.md +41 -0
  105. package/docs/SearchPriceUsdFilter.md +41 -0
  106. package/docs/SearchProtocolFilter.md +35 -0
  107. package/docs/SearchProviderRef.md +36 -0
  108. package/docs/SearchRequest.md +36 -0
  109. package/docs/SearchResourceTypeFilter.md +35 -0
  110. package/docs/SearchResponse.md +67 -0
  111. package/docs/SearchResponseWarningsInner.md +38 -0
  112. package/docs/SearchResult.md +38 -0
  113. package/docs/SearchStringSetFilter.md +34 -0
  114. package/docs/SearchWeftFetchCompatibility.md +36 -0
  115. package/docs/SignInRequest.md +34 -0
  116. package/docs/SignUpRequest.md +36 -0
  117. package/docs/SpendingPolicy.md +36 -0
  118. package/docs/User.md +36 -0
  119. package/docs/UserPrincipal.md +49 -0
  120. package/docs/Wallet.md +42 -0
  121. package/examples/charge-api-hono.mjs +40 -0
  122. package/examples/charge-api.mjs +43 -0
  123. package/examples/quickstart.mjs +16 -0
  124. 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
+ }