@solvapay/server 1.0.8-preview.9 → 1.0.8

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 CHANGED
@@ -52,6 +52,64 @@ const solvapay = createSolvaPayClient({
52
52
  })
53
53
  ```
54
54
 
55
+ ### Web-standards runtimes — `@solvapay/server/fetch` subpath
56
+
57
+ For Deno / Supabase Edge / Cloudflare Workers / Bun / Next edge /
58
+ Vercel Functions deploys, use the `./fetch` subpath export. Every
59
+ SolvaPay route ships as a ready-made `(req: Request) => Promise<Response>`
60
+ handler with CORS + JSON serialisation baked in, so each Edge Function
61
+ is a one-liner:
62
+
63
+ ```ts
64
+ // supabase/functions/check-purchase/index.ts
65
+ import { checkPurchase } from '@solvapay/server/fetch'
66
+
67
+ Deno.serve(checkPurchase)
68
+ ```
69
+
70
+ Available handlers: `checkPurchase`, `trackUsage`, `createPaymentIntent`,
71
+ `processPayment`, `createTopupPaymentIntent`, `customerBalance`,
72
+ `cancelRenewal`, `reactivateRenewal`, `activatePlan`, `getPaymentMethod`,
73
+ `listPlans`, `syncCustomer`, `createCheckoutSession`,
74
+ `createCustomerSession`, `getMerchant`, `getProduct`, `solvapayWebhook`.
75
+
76
+ Configure CORS for production origins:
77
+
78
+ ```ts
79
+ import { checkPurchase, configureCors } from '@solvapay/server/fetch'
80
+
81
+ configureCors({ origins: ['https://myapp.com', 'http://localhost:5173'] })
82
+
83
+ Deno.serve(checkPurchase)
84
+ ```
85
+
86
+ Webhook handler (verifies the `SV-Signature` header via Web Crypto,
87
+ returns 401 on invalid signatures, 500 on handler failures):
88
+
89
+ ```ts
90
+ import { solvapayWebhook } from '@solvapay/server/fetch'
91
+
92
+ Deno.serve(
93
+ solvapayWebhook({
94
+ secret: Deno.env.get('SOLVAPAY_WEBHOOK_SECRET')!,
95
+ onEvent: async event => {
96
+ if (event.type === 'purchase.created') {
97
+ // handle new purchase
98
+ }
99
+ },
100
+ }),
101
+ )
102
+ ```
103
+
104
+ Full reference implementation in
105
+ [`examples/supabase-edge`](https://github.com/solvapay/solvapay-sdk/tree/main/examples/supabase-edge).
106
+
107
+ > **History**: the `./fetch` subpath was formerly shipped as the
108
+ > standalone package `@solvapay/fetch@1.0.0` (renamed from
109
+ > `@solvapay/supabase@1.0.1`). It was folded into `@solvapay/server`
110
+ > in `@solvapay/server@1.0.8` — see the CHANGELOG for the migration
111
+ > one-liner.
112
+
55
113
  ### Paywall Protection
56
114
 
57
115
  Use the unified payable API to protect your endpoints and functions with usage limits and metered billing:
@@ -128,13 +186,33 @@ export const POST = solvaPay.payable({ product: 'my-api' }).next(
128
186
  This automatically extracts the user ID from authentication tokens and uses it as the customer reference for paywall checks.
129
187
  Fail closed on missing/invalid auth. Do not fall back to shared identities like `anonymous`.
130
188
 
131
- For MCP bearer-token flows, the SDK also exports helper utilities:
189
+ ### MCP servers
190
+
191
+ `@solvapay/server` is framework-free. For a full SolvaPay MCP server
192
+ (transport tools + `open_*` bootstrap tools + UI resource) use
193
+ [`@solvapay/mcp`](https://github.com/solvapay/solvapay-sdk/tree/main/packages/mcp)'s
194
+ `createSolvaPayMcpServer` — the official `@modelcontextprotocol/sdk`
195
+ adapter. For framework-neutral descriptors (`fastmcp`, raw JSON-RPC),
196
+ use
197
+ [`@solvapay/mcp-core`](https://github.com/solvapay/solvapay-sdk/tree/main/packages/mcp-core)'s
198
+ `buildSolvaPayDescriptors`. OAuth-bridge middleware ships as runtime-
199
+ specific subpath exports of `@solvapay/mcp`:
200
+ [`@solvapay/mcp/express`](https://github.com/solvapay/solvapay-sdk/tree/main/packages/mcp/src/express)
201
+ (`createMcpOAuthBridge`) for Node, and
202
+ [`@solvapay/mcp/fetch`](https://github.com/solvapay/solvapay-sdk/tree/main/packages/mcp/src/fetch)
203
+ (`createSolvaPayMcpFetchHandler`, `createSolvaPayMcpFetch`) for
204
+ Web-standards runtimes (Deno / Supabase Edge / Cloudflare Workers /
205
+ Bun / Next edge / Vercel Functions). JWT bearer helpers
206
+ (`getCustomerRefFromBearerAuthHeader`, `McpBearerAuthError`) live
207
+ in `@solvapay/mcp-core`.
208
+
209
+ For MCP bearer-token flows, import the helpers from `@solvapay/mcp-core`:
132
210
 
133
211
  ```ts
134
212
  import {
135
213
  getCustomerRefFromBearerAuthHeader,
136
214
  McpBearerAuthError,
137
- } from '@solvapay/server'
215
+ } from '@solvapay/mcp-core'
138
216
 
139
217
  const handler = solvaPay.payable({ product: 'my-api' }).mcp(
140
218
  async args => ({ ok: true }),