@armory-sh/middleware-bun 0.3.21 → 0.3.22-alpha.14.46
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 +76 -51
- package/package.json +21 -2
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# @armory-sh/middleware-bun
|
|
2
2
|
|
|
3
|
-
x402
|
|
3
|
+
Armory x402 SDK — Payment middleware for Bun servers. Accept x402 payments from any client in your Bun app. 100% compatible with Coinbase x402 SDKs.
|
|
4
|
+
|
|
5
|
+
[Documentation](https://armory.sh) | [License](LICENSE)
|
|
4
6
|
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
@@ -8,89 +10,112 @@ x402 payment middleware for Bun runtime applications.
|
|
|
8
10
|
bun add @armory-sh/middleware-bun
|
|
9
11
|
```
|
|
10
12
|
|
|
11
|
-
##
|
|
13
|
+
## Why Armory?
|
|
14
|
+
|
|
15
|
+
Armory enables HTTP API payments via EIP-3009 `transferWithAuthorization`. Accept payments from any x402-compatible client—Coinbase SDK, Armory SDK, or your own implementation.
|
|
16
|
+
|
|
17
|
+
## Key Exports
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import {
|
|
21
|
+
// Middleware
|
|
22
|
+
createBunMiddleware,
|
|
23
|
+
createRouteAwareBunMiddleware,
|
|
24
|
+
|
|
25
|
+
// Types
|
|
26
|
+
type BunMiddlewareConfig,
|
|
27
|
+
type RouteAwareBunMiddlewareConfig,
|
|
28
|
+
type BunPaymentContext,
|
|
29
|
+
} from '@armory-sh/middleware-bun';
|
|
30
|
+
```
|
|
12
31
|
|
|
13
|
-
|
|
14
|
-
- Route-aware payment configuration
|
|
15
|
-
- Multi-network, multi-token support
|
|
16
|
-
- Facilitator integration
|
|
17
|
-
- Full TypeScript support
|
|
32
|
+
## Quick Start
|
|
18
33
|
|
|
19
|
-
|
|
34
|
+
### Basic Middleware
|
|
20
35
|
|
|
21
36
|
```typescript
|
|
22
|
-
import { createBunMiddleware } from
|
|
37
|
+
import { createBunMiddleware } from '@armory-sh/middleware-bun'
|
|
23
38
|
|
|
24
39
|
const middleware = createBunMiddleware({
|
|
25
|
-
payTo:
|
|
26
|
-
network:
|
|
27
|
-
|
|
28
|
-
|
|
40
|
+
payTo: '0xYourAddress...',
|
|
41
|
+
network: 'base',
|
|
42
|
+
token: 'usdc',
|
|
43
|
+
amount: '1.0'
|
|
44
|
+
})
|
|
29
45
|
|
|
30
|
-
|
|
46
|
+
Bun.serve({
|
|
31
47
|
port: 3000,
|
|
32
48
|
async fetch(req) {
|
|
33
|
-
const response = await middleware(req)
|
|
34
|
-
if (response) return response
|
|
49
|
+
const response = await middleware(req)
|
|
50
|
+
if (response) return response
|
|
35
51
|
|
|
36
|
-
return new Response(
|
|
37
|
-
}
|
|
38
|
-
})
|
|
52
|
+
return new Response('Hello!')
|
|
53
|
+
}
|
|
54
|
+
})
|
|
39
55
|
```
|
|
40
56
|
|
|
41
|
-
|
|
57
|
+
### Route-Aware Middleware
|
|
42
58
|
|
|
43
59
|
```typescript
|
|
44
|
-
import { createRouteAwareBunMiddleware } from
|
|
60
|
+
import { createRouteAwareBunMiddleware } from '@armory-sh/middleware-bun'
|
|
45
61
|
|
|
46
62
|
const middleware = createRouteAwareBunMiddleware({
|
|
47
|
-
routes: [
|
|
48
|
-
payTo:
|
|
49
|
-
amount:
|
|
50
|
-
network:
|
|
63
|
+
routes: ['/api/premium', '/api/vip/*'],
|
|
64
|
+
payTo: '0xYourAddress...',
|
|
65
|
+
amount: '$5.00',
|
|
66
|
+
network: 'base',
|
|
51
67
|
perRoute: {
|
|
52
|
-
|
|
53
|
-
amount:
|
|
68
|
+
'/api/vip/*': {
|
|
69
|
+
amount: '$10.00'
|
|
54
70
|
}
|
|
55
71
|
}
|
|
56
|
-
})
|
|
72
|
+
})
|
|
57
73
|
|
|
58
|
-
|
|
74
|
+
Bun.serve({
|
|
59
75
|
port: 3000,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
},
|
|
63
|
-
});
|
|
76
|
+
fetch: (req) => middleware(req)
|
|
77
|
+
})
|
|
64
78
|
```
|
|
65
79
|
|
|
66
|
-
## Configuration
|
|
67
|
-
|
|
68
|
-
### BunMiddlewareConfig
|
|
80
|
+
## Configuration Options
|
|
69
81
|
|
|
70
82
|
```typescript
|
|
71
83
|
interface BunMiddlewareConfig {
|
|
72
|
-
payTo: string | number
|
|
73
|
-
network: string | number
|
|
74
|
-
amount: string
|
|
75
|
-
facilitator?: FacilitatorConfig
|
|
76
|
-
settlementMode?:
|
|
77
|
-
defaultVersion?: 1 | 2
|
|
78
|
-
waitForSettlement?: boolean
|
|
84
|
+
payTo: string | number // Payment recipient
|
|
85
|
+
network: string | number // Network (name or chain ID)
|
|
86
|
+
amount: string // Amount to charge
|
|
87
|
+
facilitator?: FacilitatorConfig
|
|
88
|
+
settlementMode?: 'verify' | 'settle' | 'async'
|
|
89
|
+
defaultVersion?: 1 | 2
|
|
90
|
+
waitForSettlement?: boolean
|
|
79
91
|
}
|
|
80
92
|
|
|
81
93
|
interface RouteAwareBunMiddlewareConfig extends BunMiddlewareConfig {
|
|
82
|
-
route?: string
|
|
83
|
-
routes?: string[]
|
|
84
|
-
perRoute?: Record<string, Partial<BunMiddlewareConfig
|
|
94
|
+
route?: string
|
|
95
|
+
routes?: string[]
|
|
96
|
+
perRoute?: Record<string, Partial<BunMiddlewareConfig>>
|
|
85
97
|
}
|
|
86
98
|
```
|
|
87
99
|
|
|
88
|
-
##
|
|
100
|
+
## Features
|
|
101
|
+
|
|
102
|
+
- **x402 Compatible**: Accept payments from any x402 client
|
|
103
|
+
- **Route-Aware**: Different pricing for different routes
|
|
104
|
+
- **Multi-Network**: Ethereum, Base, SKALE support
|
|
105
|
+
- **Multi-Token**: USDC, EURC, USDT, WBTC, WETH, SKL
|
|
106
|
+
- **Facilitator Integration**: Optional facilitator support
|
|
107
|
+
- **Settlement Modes**: Verify, settle, or async settlement
|
|
89
108
|
|
|
90
|
-
|
|
109
|
+
## Supported Networks
|
|
91
110
|
|
|
92
|
-
|
|
111
|
+
| Network | Chain ID |
|
|
112
|
+
|---------|----------|
|
|
113
|
+
| Ethereum | 1 |
|
|
114
|
+
| Base | 8453 |
|
|
115
|
+
| Base Sepolia | 84532 |
|
|
116
|
+
| SKALE Base | 1187947933 |
|
|
117
|
+
| SKALE Base Sepolia | 324705682 |
|
|
93
118
|
|
|
94
|
-
|
|
119
|
+
## License
|
|
95
120
|
|
|
96
|
-
|
|
121
|
+
MIT © [Sawyer Cutler](https://github.com/TheGreatAxios/armory)
|
package/package.json
CHANGED
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@armory-sh/middleware-bun",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.22-alpha.14.46",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Sawyer Cutler <sawyer@dirtroad.dev>",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"x402",
|
|
8
|
+
"ai",
|
|
9
|
+
"agentic commerce",
|
|
10
|
+
"ai agent",
|
|
11
|
+
"stablecoins",
|
|
12
|
+
"eip-3009",
|
|
13
|
+
"skale",
|
|
14
|
+
"base",
|
|
15
|
+
"machine economy",
|
|
16
|
+
"payment",
|
|
17
|
+
"crypto",
|
|
18
|
+
"web3",
|
|
19
|
+
"ethereum",
|
|
20
|
+
"usdc",
|
|
21
|
+
"bun",
|
|
22
|
+
"middleware",
|
|
23
|
+
"server"
|
|
24
|
+
],
|
|
6
25
|
"type": "module",
|
|
7
26
|
"main": "./dist/index.js",
|
|
8
27
|
"types": "./dist/index.d.ts",
|
|
@@ -24,7 +43,7 @@
|
|
|
24
43
|
"directory": "packages/middleware-bun"
|
|
25
44
|
},
|
|
26
45
|
"dependencies": {
|
|
27
|
-
"@armory-sh/base": "0.2.
|
|
46
|
+
"@armory-sh/base": "0.2.24-alpha.14.46"
|
|
28
47
|
},
|
|
29
48
|
"devDependencies": {
|
|
30
49
|
"bun-types": "latest",
|