@solvapay/server 1.0.8-preview.8 → 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 +80 -2
- package/dist/edge.d.ts +495 -61
- package/dist/edge.js +648 -187
- package/dist/fetch/index.cjs +3071 -0
- package/dist/fetch/index.d.cts +112 -0
- package/dist/fetch/index.d.ts +112 -0
- package/dist/fetch/index.js +3017 -0
- package/dist/index.cjs +603 -5013
- package/dist/index.d.cts +490 -156
- package/dist/index.d.ts +490 -156
- package/dist/index.js +571 -695
- package/package.json +15 -12
- package/dist/chunk-MLKGABMK.js +0 -9
- package/dist/chunk-R5U7XKVJ.js +0 -16
- package/dist/dist-EPVKJAIP.js +0 -94
- package/dist/dist-JBJ4HMP7.js +0 -94
- package/dist/esm-5GYCIXIY.js +0 -3475
- package/dist/esm-UW7WCMEK.js +0 -3475
- package/dist/src/adapters/base.d.ts +0 -57
- package/dist/src/adapters/base.d.ts.map +0 -1
- package/dist/src/adapters/base.js +0 -73
- package/dist/src/adapters/base.js.map +0 -1
- package/dist/src/adapters/http.d.ts +0 -25
- package/dist/src/adapters/http.d.ts.map +0 -1
- package/dist/src/adapters/http.js +0 -99
- package/dist/src/adapters/http.js.map +0 -1
- package/dist/src/adapters/index.d.ts +0 -11
- package/dist/src/adapters/index.d.ts.map +0 -1
- package/dist/src/adapters/index.js +0 -10
- package/dist/src/adapters/index.js.map +0 -1
- package/dist/src/adapters/mcp.d.ts +0 -24
- package/dist/src/adapters/mcp.d.ts.map +0 -1
- package/dist/src/adapters/mcp.js +0 -75
- package/dist/src/adapters/mcp.js.map +0 -1
- package/dist/src/adapters/next.d.ts +0 -24
- package/dist/src/adapters/next.d.ts.map +0 -1
- package/dist/src/adapters/next.js +0 -109
- package/dist/src/adapters/next.js.map +0 -1
- package/dist/src/client.d.ts +0 -58
- package/dist/src/client.d.ts.map +0 -1
- package/dist/src/client.js +0 -495
- package/dist/src/client.js.map +0 -1
- package/dist/src/edge.d.ts +0 -22
- package/dist/src/edge.d.ts.map +0 -1
- package/dist/src/edge.js +0 -91
- package/dist/src/edge.js.map +0 -1
- package/dist/src/factory.d.ts +0 -605
- package/dist/src/factory.d.ts.map +0 -1
- package/dist/src/factory.js +0 -215
- package/dist/src/factory.js.map +0 -1
- package/dist/src/helpers/auth.d.ts +0 -47
- package/dist/src/helpers/auth.d.ts.map +0 -1
- package/dist/src/helpers/auth.js +0 -73
- package/dist/src/helpers/auth.js.map +0 -1
- package/dist/src/helpers/checkout.d.ts +0 -45
- package/dist/src/helpers/checkout.d.ts.map +0 -1
- package/dist/src/helpers/checkout.js +0 -89
- package/dist/src/helpers/checkout.js.map +0 -1
- package/dist/src/helpers/customer.d.ts +0 -51
- package/dist/src/helpers/customer.d.ts.map +0 -1
- package/dist/src/helpers/customer.js +0 -77
- package/dist/src/helpers/customer.js.map +0 -1
- package/dist/src/helpers/error.d.ts +0 -15
- package/dist/src/helpers/error.d.ts.map +0 -1
- package/dist/src/helpers/error.js +0 -35
- package/dist/src/helpers/error.js.map +0 -1
- package/dist/src/helpers/index.d.ts +0 -17
- package/dist/src/helpers/index.d.ts.map +0 -1
- package/dist/src/helpers/index.js +0 -23
- package/dist/src/helpers/index.js.map +0 -1
- package/dist/src/helpers/payment.d.ts +0 -107
- package/dist/src/helpers/payment.d.ts.map +0 -1
- package/dist/src/helpers/payment.js +0 -150
- package/dist/src/helpers/payment.js.map +0 -1
- package/dist/src/helpers/plans.d.ts +0 -19
- package/dist/src/helpers/plans.d.ts.map +0 -1
- package/dist/src/helpers/plans.js +0 -53
- package/dist/src/helpers/plans.js.map +0 -1
- package/dist/src/helpers/renewal.d.ts +0 -23
- package/dist/src/helpers/renewal.d.ts.map +0 -1
- package/dist/src/helpers/renewal.js +0 -90
- package/dist/src/helpers/renewal.js.map +0 -1
- package/dist/src/helpers/subscription.d.ts +0 -23
- package/dist/src/helpers/subscription.d.ts.map +0 -1
- package/dist/src/helpers/subscription.js +0 -101
- package/dist/src/helpers/subscription.js.map +0 -1
- package/dist/src/helpers/types.d.ts +0 -22
- package/dist/src/helpers/types.d.ts.map +0 -1
- package/dist/src/helpers/types.js +0 -7
- package/dist/src/helpers/types.js.map +0 -1
- package/dist/src/index.d.ts +0 -73
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -106
- package/dist/src/index.js.map +0 -1
- package/dist/src/mcp/auth-bridge.d.ts +0 -9
- package/dist/src/mcp/auth-bridge.d.ts.map +0 -1
- package/dist/src/mcp/auth-bridge.js +0 -46
- package/dist/src/mcp/auth-bridge.js.map +0 -1
- package/dist/src/mcp/oauth-bridge.d.ts +0 -48
- package/dist/src/mcp/oauth-bridge.d.ts.map +0 -1
- package/dist/src/mcp/oauth-bridge.js +0 -110
- package/dist/src/mcp/oauth-bridge.js.map +0 -1
- package/dist/src/mcp-auth.d.ts +0 -17
- package/dist/src/mcp-auth.d.ts.map +0 -1
- package/dist/src/mcp-auth.js +0 -57
- package/dist/src/mcp-auth.js.map +0 -1
- package/dist/src/paywall.d.ts +0 -119
- package/dist/src/paywall.d.ts.map +0 -1
- package/dist/src/paywall.js +0 -700
- package/dist/src/paywall.js.map +0 -1
- package/dist/src/register-virtual-tools-mcp.d.ts +0 -23
- package/dist/src/register-virtual-tools-mcp.d.ts.map +0 -1
- package/dist/src/register-virtual-tools-mcp.js +0 -86
- package/dist/src/register-virtual-tools-mcp.js.map +0 -1
- package/dist/src/types/client.d.ts +0 -216
- package/dist/src/types/client.d.ts.map +0 -1
- package/dist/src/types/client.js +0 -7
- package/dist/src/types/client.js.map +0 -1
- package/dist/src/types/generated.d.ts +0 -2834
- package/dist/src/types/generated.d.ts.map +0 -1
- package/dist/src/types/generated.js +0 -6
- package/dist/src/types/generated.js.map +0 -1
- package/dist/src/types/index.d.ts +0 -13
- package/dist/src/types/index.d.ts.map +0 -1
- package/dist/src/types/index.js +0 -8
- package/dist/src/types/index.js.map +0 -1
- package/dist/src/types/options.d.ts +0 -126
- package/dist/src/types/options.d.ts.map +0 -1
- package/dist/src/types/options.js +0 -8
- package/dist/src/types/options.js.map +0 -1
- package/dist/src/types/paywall.d.ts +0 -64
- package/dist/src/types/paywall.d.ts.map +0 -1
- package/dist/src/types/paywall.js +0 -7
- package/dist/src/types/paywall.js.map +0 -1
- package/dist/src/types/webhook.d.ts +0 -50
- package/dist/src/types/webhook.d.ts.map +0 -1
- package/dist/src/types/webhook.js +0 -2
- package/dist/src/types/webhook.js.map +0 -1
- package/dist/src/utils.d.ts +0 -110
- package/dist/src/utils.d.ts.map +0 -1
- package/dist/src/utils.js +0 -217
- package/dist/src/utils.js.map +0 -1
- package/dist/src/virtual-tools.d.ts +0 -44
- package/dist/src/virtual-tools.d.ts.map +0 -1
- package/dist/src/virtual-tools.js +0 -140
- package/dist/src/virtual-tools.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/webapi-K5XBCEO6.js +0 -3775
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
|
-
|
|
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/
|
|
215
|
+
} from '@solvapay/mcp-core'
|
|
138
216
|
|
|
139
217
|
const handler = solvaPay.payable({ product: 'my-api' }).mcp(
|
|
140
218
|
async args => ({ ok: true }),
|