@thecryptodonkey/toll-booth 1.0.0 → 1.0.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/README.md +24 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -160,6 +160,30 @@ import { createWebStandardMiddleware } from '@thecryptodonkey/toll-booth/adapter
|
|
|
160
160
|
|
|
161
161
|
## Payment flow
|
|
162
162
|
|
|
163
|
+
```mermaid
|
|
164
|
+
sequenceDiagram
|
|
165
|
+
participant C as Client
|
|
166
|
+
participant T as toll-booth
|
|
167
|
+
participant U as Upstream API
|
|
168
|
+
|
|
169
|
+
C->>T: GET /api/resource
|
|
170
|
+
T->>T: Check free tier
|
|
171
|
+
alt Free tier available
|
|
172
|
+
T->>U: Proxy request
|
|
173
|
+
U-->>T: Response
|
|
174
|
+
T-->>C: 200 + X-Free-Remaining header
|
|
175
|
+
else Free tier exhausted
|
|
176
|
+
T-->>C: 402 + Invoice + Macaroon
|
|
177
|
+
C->>C: Pay via Lightning / Cashu / NWC
|
|
178
|
+
C->>T: GET /api/resource<br/>Authorization: L402 macaroon:preimage
|
|
179
|
+
T->>T: Verify macaroon + preimage
|
|
180
|
+
T->>T: Settle credit + debit cost
|
|
181
|
+
T->>U: Proxy request
|
|
182
|
+
U-->>T: Response
|
|
183
|
+
T-->>C: 200 + X-Credit-Balance header
|
|
184
|
+
end
|
|
185
|
+
```
|
|
186
|
+
|
|
163
187
|
1. Client requests a priced endpoint without credentials
|
|
164
188
|
2. Free tier checked — if allowance remains, request passes through
|
|
165
189
|
3. If exhausted → **402** response with BOLT-11 invoice + macaroon
|