@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/dist/src/client.js
DELETED
|
@@ -1,495 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SolvaPay Server SDK - API Client
|
|
3
|
-
*
|
|
4
|
-
* This module provides the API client implementation for communicating with
|
|
5
|
-
* the SolvaPay backend. The client handles all HTTP requests for paywall
|
|
6
|
-
* protection, usage tracking, and resource management.
|
|
7
|
-
*/
|
|
8
|
-
import { SolvaPayError } from '@solvapay/core';
|
|
9
|
-
/**
|
|
10
|
-
* Creates a SolvaPay API client that implements the full SolvaPayClient interface.
|
|
11
|
-
*
|
|
12
|
-
* This function creates a low-level API client for direct communication with the
|
|
13
|
-
* SolvaPay backend. For most use cases, use `createSolvaPay()` instead, which
|
|
14
|
-
* provides a higher-level API with paywall protection.
|
|
15
|
-
*
|
|
16
|
-
* Use this function when you need:
|
|
17
|
-
* - Direct API access for custom operations
|
|
18
|
-
* - Testing with custom client implementations
|
|
19
|
-
* - Advanced use cases not covered by the main API
|
|
20
|
-
*
|
|
21
|
-
* @param opts - Configuration options
|
|
22
|
-
* @param opts.apiKey - Your SolvaPay API key (required)
|
|
23
|
-
* @param opts.apiBaseUrl - Optional API base URL override
|
|
24
|
-
* @returns A fully configured SolvaPayClient instance
|
|
25
|
-
* @throws {SolvaPayError} If API key is missing
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```typescript
|
|
29
|
-
* // Create API client directly
|
|
30
|
-
* const client = createSolvaPayClient({
|
|
31
|
-
* apiKey: process.env.SOLVAPAY_SECRET_KEY!,
|
|
32
|
-
* apiBaseUrl: 'https://api.solvapay.com' // optional
|
|
33
|
-
* });
|
|
34
|
-
*
|
|
35
|
-
* // Use client for custom operations
|
|
36
|
-
* const products = await client.listProducts();
|
|
37
|
-
* ```
|
|
38
|
-
*
|
|
39
|
-
* @see {@link createSolvaPay} for the recommended high-level API
|
|
40
|
-
* @see {@link ServerClientOptions} for configuration options
|
|
41
|
-
* @since 1.0.0
|
|
42
|
-
*/
|
|
43
|
-
export function createSolvaPayClient(opts) {
|
|
44
|
-
const base = opts.apiBaseUrl ?? 'https://api.solvapay.com';
|
|
45
|
-
if (!opts.apiKey)
|
|
46
|
-
throw new SolvaPayError('Missing apiKey');
|
|
47
|
-
const headers = {
|
|
48
|
-
'Content-Type': 'application/json',
|
|
49
|
-
Authorization: `Bearer ${opts.apiKey}`,
|
|
50
|
-
};
|
|
51
|
-
// Enable debug logging via environment variable (same pattern as paywall)
|
|
52
|
-
const debug = process.env.SOLVAPAY_DEBUG === 'true';
|
|
53
|
-
const log = (...args) => {
|
|
54
|
-
if (debug) {
|
|
55
|
-
// eslint-disable-next-line no-console
|
|
56
|
-
console.log(...args);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
return {
|
|
60
|
-
// POST: /v1/sdk/limits
|
|
61
|
-
async checkLimits(params) {
|
|
62
|
-
const url = `${base}/v1/sdk/limits`;
|
|
63
|
-
const res = await fetch(url, {
|
|
64
|
-
method: 'POST',
|
|
65
|
-
headers,
|
|
66
|
-
body: JSON.stringify(params),
|
|
67
|
-
});
|
|
68
|
-
if (!res.ok) {
|
|
69
|
-
const error = await res.text();
|
|
70
|
-
log(`❌ API Error: ${res.status} - ${error}`);
|
|
71
|
-
throw new SolvaPayError(`Check limits failed (${res.status}): ${error}`);
|
|
72
|
-
}
|
|
73
|
-
const result = await res.json();
|
|
74
|
-
return result;
|
|
75
|
-
},
|
|
76
|
-
// POST: /v1/sdk/usages
|
|
77
|
-
async trackUsage(params) {
|
|
78
|
-
const url = `${base}/v1/sdk/usages`;
|
|
79
|
-
const { customerRef, ...rest } = params;
|
|
80
|
-
const body = { ...rest, customerId: customerRef };
|
|
81
|
-
const res = await fetch(url, {
|
|
82
|
-
method: 'POST',
|
|
83
|
-
headers,
|
|
84
|
-
body: JSON.stringify(body),
|
|
85
|
-
});
|
|
86
|
-
if (!res.ok) {
|
|
87
|
-
const error = await res.text();
|
|
88
|
-
log(`❌ API Error: ${res.status} - ${error}`);
|
|
89
|
-
throw new SolvaPayError(`Track usage failed (${res.status}): ${error}`);
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
// POST: /v1/sdk/customers
|
|
93
|
-
async createCustomer(params) {
|
|
94
|
-
const url = `${base}/v1/sdk/customers`;
|
|
95
|
-
const res = await fetch(url, {
|
|
96
|
-
method: 'POST',
|
|
97
|
-
headers,
|
|
98
|
-
body: JSON.stringify(params),
|
|
99
|
-
});
|
|
100
|
-
if (!res.ok) {
|
|
101
|
-
const error = await res.text();
|
|
102
|
-
log(`❌ API Error: ${res.status} - ${error}`);
|
|
103
|
-
throw new SolvaPayError(`Create customer failed (${res.status}): ${error}`);
|
|
104
|
-
}
|
|
105
|
-
const result = await res.json();
|
|
106
|
-
return result;
|
|
107
|
-
},
|
|
108
|
-
// GET: /v1/sdk/customers/{reference} or /v1/sdk/customers?externalRef={externalRef}|email={email}
|
|
109
|
-
async getCustomer(params) {
|
|
110
|
-
let url;
|
|
111
|
-
let isByExternalRef = false;
|
|
112
|
-
let isByEmail = false;
|
|
113
|
-
if (params.externalRef) {
|
|
114
|
-
url = `${base}/v1/sdk/customers?externalRef=${encodeURIComponent(params.externalRef)}`;
|
|
115
|
-
isByExternalRef = true;
|
|
116
|
-
}
|
|
117
|
-
else if (params.email) {
|
|
118
|
-
url = `${base}/v1/sdk/customers?email=${encodeURIComponent(params.email)}`;
|
|
119
|
-
isByEmail = true;
|
|
120
|
-
}
|
|
121
|
-
else if (params.customerRef) {
|
|
122
|
-
url = `${base}/v1/sdk/customers/${params.customerRef}`;
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
throw new SolvaPayError('One of customerRef, externalRef, or email must be provided');
|
|
126
|
-
}
|
|
127
|
-
const res = await fetch(url, {
|
|
128
|
-
method: 'GET',
|
|
129
|
-
headers,
|
|
130
|
-
});
|
|
131
|
-
if (!res.ok) {
|
|
132
|
-
const error = await res.text();
|
|
133
|
-
log(`❌ API Error: ${res.status} - ${error}`);
|
|
134
|
-
throw new SolvaPayError(`Get customer failed (${res.status}): ${error}`);
|
|
135
|
-
}
|
|
136
|
-
const result = await res.json();
|
|
137
|
-
// If getting by externalRef, support all backend response shapes:
|
|
138
|
-
// - direct customer object
|
|
139
|
-
// - array of customers
|
|
140
|
-
// - wrapped object with `customers` or `customer`
|
|
141
|
-
let customer = result;
|
|
142
|
-
if (isByExternalRef || isByEmail) {
|
|
143
|
-
const directCustomer = result &&
|
|
144
|
-
typeof result === 'object' &&
|
|
145
|
-
(result.reference || result.customerRef || result.externalRef)
|
|
146
|
-
? result
|
|
147
|
-
: undefined;
|
|
148
|
-
const wrappedCustomer = result && typeof result === 'object' && result.customer ? result.customer : undefined;
|
|
149
|
-
const customers = Array.isArray(result)
|
|
150
|
-
? result
|
|
151
|
-
: result && typeof result === 'object' && Array.isArray(result.customers)
|
|
152
|
-
? result.customers
|
|
153
|
-
: [];
|
|
154
|
-
customer = directCustomer || wrappedCustomer || customers[0];
|
|
155
|
-
if (!customer) {
|
|
156
|
-
throw new SolvaPayError(`No customer found with externalRef: ${params.externalRef}`);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
// Map response fields to expected format
|
|
160
|
-
// Note: purchases may include additional fields like endDate, cancelledAt
|
|
161
|
-
// even though they're not in the PurchaseInfo type definition
|
|
162
|
-
return {
|
|
163
|
-
customerRef: customer.reference || customer.customerRef,
|
|
164
|
-
email: customer.email,
|
|
165
|
-
name: customer.name,
|
|
166
|
-
externalRef: customer.externalRef,
|
|
167
|
-
purchases: customer.purchases || [],
|
|
168
|
-
};
|
|
169
|
-
},
|
|
170
|
-
// Product management methods (primarily for integration tests)
|
|
171
|
-
// GET: /v1/sdk/products
|
|
172
|
-
async listProducts() {
|
|
173
|
-
const url = `${base}/v1/sdk/products`;
|
|
174
|
-
const res = await fetch(url, {
|
|
175
|
-
method: 'GET',
|
|
176
|
-
headers,
|
|
177
|
-
});
|
|
178
|
-
if (!res.ok) {
|
|
179
|
-
const error = await res.text();
|
|
180
|
-
log(`❌ API Error: ${res.status} - ${error}`);
|
|
181
|
-
throw new SolvaPayError(`List products failed (${res.status}): ${error}`);
|
|
182
|
-
}
|
|
183
|
-
const result = await res.json();
|
|
184
|
-
// Handle both direct array and wrapped object formats
|
|
185
|
-
const products = Array.isArray(result) ? result : result.products || [];
|
|
186
|
-
// Unwrap data field if present
|
|
187
|
-
return products.map((product) => ({
|
|
188
|
-
...product,
|
|
189
|
-
...(product.data || {}),
|
|
190
|
-
}));
|
|
191
|
-
},
|
|
192
|
-
// POST: /v1/sdk/products
|
|
193
|
-
async createProduct(params) {
|
|
194
|
-
const url = `${base}/v1/sdk/products`;
|
|
195
|
-
const res = await fetch(url, {
|
|
196
|
-
method: 'POST',
|
|
197
|
-
headers,
|
|
198
|
-
body: JSON.stringify(params),
|
|
199
|
-
});
|
|
200
|
-
if (!res.ok) {
|
|
201
|
-
const error = await res.text();
|
|
202
|
-
log(`❌ API Error: ${res.status} - ${error}`);
|
|
203
|
-
throw new SolvaPayError(`Create product failed (${res.status}): ${error}`);
|
|
204
|
-
}
|
|
205
|
-
const result = await res.json();
|
|
206
|
-
return result;
|
|
207
|
-
},
|
|
208
|
-
// POST: /v1/sdk/products/mcp/bootstrap
|
|
209
|
-
async bootstrapMcpProduct(params) {
|
|
210
|
-
const url = `${base}/v1/sdk/products/mcp/bootstrap`;
|
|
211
|
-
const res = await fetch(url, {
|
|
212
|
-
method: 'POST',
|
|
213
|
-
headers,
|
|
214
|
-
body: JSON.stringify(params),
|
|
215
|
-
});
|
|
216
|
-
if (!res.ok) {
|
|
217
|
-
const error = await res.text();
|
|
218
|
-
log(`❌ API Error: ${res.status} - ${error}`);
|
|
219
|
-
throw new SolvaPayError(`Bootstrap MCP product failed (${res.status}): ${error}`);
|
|
220
|
-
}
|
|
221
|
-
return await res.json();
|
|
222
|
-
},
|
|
223
|
-
// PUT: /v1/sdk/products/{productRef}/mcp/plans
|
|
224
|
-
async configureMcpPlans(productRef, params) {
|
|
225
|
-
const url = `${base}/v1/sdk/products/${productRef}/mcp/plans`;
|
|
226
|
-
const res = await fetch(url, {
|
|
227
|
-
method: 'PUT',
|
|
228
|
-
headers,
|
|
229
|
-
body: JSON.stringify(params),
|
|
230
|
-
});
|
|
231
|
-
if (!res.ok) {
|
|
232
|
-
const error = await res.text();
|
|
233
|
-
log(`❌ API Error: ${res.status} - ${error}`);
|
|
234
|
-
throw new SolvaPayError(`Configure MCP plans failed (${res.status}): ${error}`);
|
|
235
|
-
}
|
|
236
|
-
return await res.json();
|
|
237
|
-
},
|
|
238
|
-
// DELETE: /v1/sdk/products/{productRef}
|
|
239
|
-
async deleteProduct(productRef) {
|
|
240
|
-
const url = `${base}/v1/sdk/products/${productRef}`;
|
|
241
|
-
const res = await fetch(url, {
|
|
242
|
-
method: 'DELETE',
|
|
243
|
-
headers,
|
|
244
|
-
});
|
|
245
|
-
if (!res.ok && res.status !== 404) {
|
|
246
|
-
const error = await res.text();
|
|
247
|
-
log(`❌ API Error: ${res.status} - ${error}`);
|
|
248
|
-
throw new SolvaPayError(`Delete product failed (${res.status}): ${error}`);
|
|
249
|
-
}
|
|
250
|
-
},
|
|
251
|
-
// POST: /v1/sdk/products/{productRef}/clone
|
|
252
|
-
async cloneProduct(productRef, overrides) {
|
|
253
|
-
const url = `${base}/v1/sdk/products/${productRef}/clone`;
|
|
254
|
-
const res = await fetch(url, {
|
|
255
|
-
method: 'POST',
|
|
256
|
-
headers,
|
|
257
|
-
body: JSON.stringify(overrides || {}),
|
|
258
|
-
});
|
|
259
|
-
if (!res.ok) {
|
|
260
|
-
const error = await res.text();
|
|
261
|
-
log(`❌ API Error: ${res.status} - ${error}`);
|
|
262
|
-
throw new SolvaPayError(`Clone product failed (${res.status}): ${error}`);
|
|
263
|
-
}
|
|
264
|
-
return await res.json();
|
|
265
|
-
},
|
|
266
|
-
// GET: /v1/sdk/products/{productRef}/plans
|
|
267
|
-
async listPlans(productRef) {
|
|
268
|
-
const url = `${base}/v1/sdk/products/${productRef}/plans`;
|
|
269
|
-
const res = await fetch(url, {
|
|
270
|
-
method: 'GET',
|
|
271
|
-
headers,
|
|
272
|
-
});
|
|
273
|
-
if (!res.ok) {
|
|
274
|
-
const error = await res.text();
|
|
275
|
-
log(`❌ API Error: ${res.status} - ${error}`);
|
|
276
|
-
throw new SolvaPayError(`List plans failed (${res.status}): ${error}`);
|
|
277
|
-
}
|
|
278
|
-
const result = await res.json();
|
|
279
|
-
// Handle both direct array and wrapped object formats
|
|
280
|
-
const plans = Array.isArray(result) ? result : result.plans || [];
|
|
281
|
-
// Unwrap data field if present, preserving all plan properties
|
|
282
|
-
// Spread plan.data first, then plan, so plan properties take precedence
|
|
283
|
-
return plans.map((plan) => {
|
|
284
|
-
const data = plan.data || {};
|
|
285
|
-
const price = plan.price ?? data.price;
|
|
286
|
-
const unwrapped = {
|
|
287
|
-
...data,
|
|
288
|
-
...plan,
|
|
289
|
-
...(price !== undefined && { price }),
|
|
290
|
-
};
|
|
291
|
-
delete unwrapped.data;
|
|
292
|
-
return unwrapped;
|
|
293
|
-
});
|
|
294
|
-
},
|
|
295
|
-
// POST: /v1/sdk/products/{productRef}/plans
|
|
296
|
-
async createPlan(params) {
|
|
297
|
-
const url = `${base}/v1/sdk/products/${params.productRef}/plans`;
|
|
298
|
-
const res = await fetch(url, {
|
|
299
|
-
method: 'POST',
|
|
300
|
-
headers,
|
|
301
|
-
body: JSON.stringify(params),
|
|
302
|
-
});
|
|
303
|
-
if (!res.ok) {
|
|
304
|
-
const error = await res.text();
|
|
305
|
-
log(`❌ API Error: ${res.status} - ${error}`);
|
|
306
|
-
throw new SolvaPayError(`Create plan failed (${res.status}): ${error}`);
|
|
307
|
-
}
|
|
308
|
-
const result = await res.json();
|
|
309
|
-
return result;
|
|
310
|
-
},
|
|
311
|
-
// PUT: /v1/sdk/products/{productRef}/plans/{planRef}
|
|
312
|
-
async updatePlan(productRef, planRef, params) {
|
|
313
|
-
const url = `${base}/v1/sdk/products/${productRef}/plans/${planRef}`;
|
|
314
|
-
const res = await fetch(url, {
|
|
315
|
-
method: 'PUT',
|
|
316
|
-
headers,
|
|
317
|
-
body: JSON.stringify(params),
|
|
318
|
-
});
|
|
319
|
-
if (!res.ok) {
|
|
320
|
-
const error = await res.text();
|
|
321
|
-
log(`❌ API Error: ${res.status} - ${error}`);
|
|
322
|
-
throw new SolvaPayError(`Update plan failed (${res.status}): ${error}`);
|
|
323
|
-
}
|
|
324
|
-
return await res.json();
|
|
325
|
-
},
|
|
326
|
-
// DELETE: /v1/sdk/products/{productRef}/plans/{planRef}
|
|
327
|
-
async deletePlan(productRef, planRef) {
|
|
328
|
-
const url = `${base}/v1/sdk/products/${productRef}/plans/${planRef}`;
|
|
329
|
-
const res = await fetch(url, {
|
|
330
|
-
method: 'DELETE',
|
|
331
|
-
headers,
|
|
332
|
-
});
|
|
333
|
-
if (!res.ok && res.status !== 404) {
|
|
334
|
-
const error = await res.text();
|
|
335
|
-
log(`❌ API Error: ${res.status} - ${error}`);
|
|
336
|
-
throw new SolvaPayError(`Delete plan failed (${res.status}): ${error}`);
|
|
337
|
-
}
|
|
338
|
-
},
|
|
339
|
-
// POST: /payment-intents
|
|
340
|
-
async createPaymentIntent(params) {
|
|
341
|
-
const idempotencyKey = params.idempotencyKey ||
|
|
342
|
-
`payment-${params.planRef}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
343
|
-
const url = `${base}/v1/sdk/payment-intents`;
|
|
344
|
-
const res = await fetch(url, {
|
|
345
|
-
method: 'POST',
|
|
346
|
-
headers: {
|
|
347
|
-
...headers,
|
|
348
|
-
'Idempotency-Key': idempotencyKey,
|
|
349
|
-
},
|
|
350
|
-
body: JSON.stringify({
|
|
351
|
-
productRef: params.productRef,
|
|
352
|
-
planRef: params.planRef,
|
|
353
|
-
customerRef: params.customerRef,
|
|
354
|
-
}),
|
|
355
|
-
});
|
|
356
|
-
if (!res.ok) {
|
|
357
|
-
const error = await res.text();
|
|
358
|
-
log(`❌ API Error: ${res.status} - ${error}`);
|
|
359
|
-
throw new SolvaPayError(`Create payment intent failed (${res.status}): ${error}`);
|
|
360
|
-
}
|
|
361
|
-
const result = await res.json();
|
|
362
|
-
return result;
|
|
363
|
-
},
|
|
364
|
-
// POST: /v1/sdk/payment-intents/{paymentIntentId}/process
|
|
365
|
-
async processPaymentIntent(params) {
|
|
366
|
-
const url = `${base}/v1/sdk/payment-intents/${params.paymentIntentId}/process`;
|
|
367
|
-
const res = await fetch(url, {
|
|
368
|
-
method: 'POST',
|
|
369
|
-
headers: {
|
|
370
|
-
...headers,
|
|
371
|
-
'Content-Type': 'application/json',
|
|
372
|
-
},
|
|
373
|
-
body: JSON.stringify({
|
|
374
|
-
productRef: params.productRef,
|
|
375
|
-
customerRef: params.customerRef,
|
|
376
|
-
planRef: params.planRef,
|
|
377
|
-
}),
|
|
378
|
-
});
|
|
379
|
-
if (!res.ok) {
|
|
380
|
-
const error = await res.text();
|
|
381
|
-
log(`❌ API Error: ${res.status} - ${error}`);
|
|
382
|
-
throw new SolvaPayError(`Process payment failed (${res.status}): ${error}`);
|
|
383
|
-
}
|
|
384
|
-
const result = await res.json();
|
|
385
|
-
return result;
|
|
386
|
-
},
|
|
387
|
-
// POST: /v1/sdk/purchases/{purchaseRef}/cancel
|
|
388
|
-
async cancelPurchase(params) {
|
|
389
|
-
const url = `${base}/v1/sdk/purchases/${params.purchaseRef}/cancel`;
|
|
390
|
-
// Prepare request options
|
|
391
|
-
const requestOptions = {
|
|
392
|
-
method: 'POST',
|
|
393
|
-
headers,
|
|
394
|
-
};
|
|
395
|
-
// Only include body if reason is provided (backend body is optional)
|
|
396
|
-
if (params.reason) {
|
|
397
|
-
requestOptions.body = JSON.stringify({ reason: params.reason });
|
|
398
|
-
}
|
|
399
|
-
const res = await fetch(url, requestOptions);
|
|
400
|
-
if (!res.ok) {
|
|
401
|
-
const error = await res.text();
|
|
402
|
-
log(`❌ API Error: ${res.status} - ${error}`);
|
|
403
|
-
if (res.status === 404) {
|
|
404
|
-
throw new SolvaPayError(`Purchase not found: ${error}`);
|
|
405
|
-
}
|
|
406
|
-
if (res.status === 400) {
|
|
407
|
-
throw new SolvaPayError(`Purchase cannot be cancelled or does not belong to provider: ${error}`);
|
|
408
|
-
}
|
|
409
|
-
throw new SolvaPayError(`Cancel purchase failed (${res.status}): ${error}`);
|
|
410
|
-
}
|
|
411
|
-
// Get response text first to debug any parsing issues
|
|
412
|
-
const responseText = await res.text();
|
|
413
|
-
let responseData;
|
|
414
|
-
try {
|
|
415
|
-
responseData = JSON.parse(responseText);
|
|
416
|
-
}
|
|
417
|
-
catch (parseError) {
|
|
418
|
-
log(`❌ Failed to parse response as JSON: ${parseError}`);
|
|
419
|
-
throw new SolvaPayError(`Invalid JSON response from cancel purchase endpoint: ${responseText.substring(0, 200)}`);
|
|
420
|
-
}
|
|
421
|
-
// Validate response structure
|
|
422
|
-
if (!responseData || typeof responseData !== 'object') {
|
|
423
|
-
log(`❌ Invalid response structure: ${JSON.stringify(responseData)}`);
|
|
424
|
-
throw new SolvaPayError(`Invalid response structure from cancel purchase endpoint`);
|
|
425
|
-
}
|
|
426
|
-
// Backend returns nested structure: { purchase: {...}, message: "..." }
|
|
427
|
-
// Extract the purchase object from the response
|
|
428
|
-
let result;
|
|
429
|
-
if (responseData.purchase && typeof responseData.purchase === 'object') {
|
|
430
|
-
result = responseData.purchase;
|
|
431
|
-
}
|
|
432
|
-
else if (responseData.reference) {
|
|
433
|
-
result = responseData;
|
|
434
|
-
}
|
|
435
|
-
else {
|
|
436
|
-
// Try to extract anyway or use the whole response
|
|
437
|
-
result = responseData.purchase || responseData;
|
|
438
|
-
}
|
|
439
|
-
// Check if response has expected fields
|
|
440
|
-
if (!result || typeof result !== 'object') {
|
|
441
|
-
log(`❌ Invalid purchase data in response. Full response:`, responseData);
|
|
442
|
-
throw new SolvaPayError(`Invalid purchase data in cancel purchase response`);
|
|
443
|
-
}
|
|
444
|
-
return result;
|
|
445
|
-
},
|
|
446
|
-
// POST: /v1/sdk/user-info
|
|
447
|
-
async getUserInfo(params) {
|
|
448
|
-
const url = `${base}/v1/sdk/user-info`;
|
|
449
|
-
const res = await fetch(url, {
|
|
450
|
-
method: 'POST',
|
|
451
|
-
headers,
|
|
452
|
-
body: JSON.stringify(params),
|
|
453
|
-
});
|
|
454
|
-
if (!res.ok) {
|
|
455
|
-
const error = await res.text();
|
|
456
|
-
log(`❌ API Error: ${res.status} - ${error}`);
|
|
457
|
-
throw new SolvaPayError(`Get user info failed (${res.status}): ${error}`);
|
|
458
|
-
}
|
|
459
|
-
return await res.json();
|
|
460
|
-
},
|
|
461
|
-
// POST: /v1/sdk/checkout-sessions
|
|
462
|
-
async createCheckoutSession(params) {
|
|
463
|
-
const url = `${base}/v1/sdk/checkout-sessions`;
|
|
464
|
-
const res = await fetch(url, {
|
|
465
|
-
method: 'POST',
|
|
466
|
-
headers,
|
|
467
|
-
body: JSON.stringify(params),
|
|
468
|
-
});
|
|
469
|
-
if (!res.ok) {
|
|
470
|
-
const error = await res.text();
|
|
471
|
-
log(`❌ API Error: ${res.status} - ${error}`);
|
|
472
|
-
throw new SolvaPayError(`Create checkout session failed (${res.status}): ${error}`);
|
|
473
|
-
}
|
|
474
|
-
const result = await res.json();
|
|
475
|
-
return result;
|
|
476
|
-
},
|
|
477
|
-
// POST: /v1/sdk/customers/customer-sessions
|
|
478
|
-
async createCustomerSession(params) {
|
|
479
|
-
const url = `${base}/v1/sdk/customers/customer-sessions`;
|
|
480
|
-
const res = await fetch(url, {
|
|
481
|
-
method: 'POST',
|
|
482
|
-
headers,
|
|
483
|
-
body: JSON.stringify(params),
|
|
484
|
-
});
|
|
485
|
-
if (!res.ok) {
|
|
486
|
-
const error = await res.text();
|
|
487
|
-
log(`❌ API Error: ${res.status} - ${error}`);
|
|
488
|
-
throw new SolvaPayError(`Create customer session failed (${res.status}): ${error}`);
|
|
489
|
-
}
|
|
490
|
-
const result = await res.json();
|
|
491
|
-
return result;
|
|
492
|
-
},
|
|
493
|
-
};
|
|
494
|
-
}
|
|
495
|
-
//# sourceMappingURL=client.js.map
|
package/dist/src/client.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAmB9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAyB;IAC5D,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,IAAI,0BAA0B,CAAA;IAC1D,IAAI,CAAC,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,aAAa,CAAC,gBAAgB,CAAC,CAAA;IAE3D,MAAM,OAAO,GAAG;QACd,cAAc,EAAE,kBAAkB;QAClC,aAAa,EAAE,UAAU,IAAI,CAAC,MAAM,EAAE;KACvC,CAAA;IAED,0EAA0E;IAC1E,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,MAAM,CAAA;IACnD,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,MAAM;YAChC,MAAM,GAAG,GAAG,GAAG,IAAI,qCAAqC,CAAA;YAExD,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;gBAC3B,MAAM,EAAE,MAAM;gBACd,OAAO;gBACP,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;aAC7B,CAAC,CAAA;YAEF,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;gBACZ,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAA;gBAC9B,GAAG,CAAC,gBAAgB,GAAG,CAAC,MAAM,MAAM,KAAK,EAAE,CAAC,CAAA;gBAC5C,MAAM,IAAI,aAAa,CAAC,mCAAmC,GAAG,CAAC,MAAM,MAAM,KAAK,EAAE,CAAC,CAAA;YACrF,CAAC;YAED,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAA;YAC/B,OAAO,MAAM,CAAA;QACf,CAAC;KACF,CAAA;AACH,CAAC"}
|
package/dist/src/edge.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SolvaPay Server SDK - Edge Runtime Entry Point
|
|
3
|
-
*
|
|
4
|
-
* This module provides edge runtime-compatible exports using Web Crypto API.
|
|
5
|
-
* Automatically selected when running in edge runtimes (Vercel Edge, Cloudflare Workers, Deno, etc.)
|
|
6
|
-
*/
|
|
7
|
-
import type { WebhookEvent } from './types/webhook';
|
|
8
|
-
export { createSolvaPayClient } from './client';
|
|
9
|
-
export type { ServerClientOptions } from './client';
|
|
10
|
-
export { createSolvaPay } from './factory';
|
|
11
|
-
export type { CreateSolvaPayConfig, SolvaPay, PayableFunction } from './factory';
|
|
12
|
-
export { PaywallError, paywallErrorToClientPayload } from './paywall';
|
|
13
|
-
export type { LimitActivationBalance, LimitActivationProduct, LimitPlanSummary, SolvaPayClient, PayableOptions, HttpAdapterOptions, NextAdapterOptions, McpAdapterOptions, PaywallArgs, PaywallMetadata, PaywallStructuredContent, PaywallToolResult, RetryOptions, WebhookEvent, WebhookEventType, WebhookEventForType, WebhookEventObjectMap, CustomerWebhookObject, WebhookProduct, } from './types';
|
|
14
|
-
export { withRetry } from './utils';
|
|
15
|
-
export { getAuthenticatedUserCore, syncCustomerCore, createPaymentIntentCore, processPaymentIntentCore, createCheckoutSessionCore, createCustomerSessionCore, cancelPurchaseCore, listPlansCore, isErrorResult, handleRouteError, } from './helpers';
|
|
16
|
-
export type { ErrorResult, AuthenticatedUser } from './helpers';
|
|
17
|
-
export declare function verifyWebhook({ body, signature, secret, }: {
|
|
18
|
-
body: string;
|
|
19
|
-
signature: string;
|
|
20
|
-
secret: string;
|
|
21
|
-
}): Promise<WebhookEvent>;
|
|
22
|
-
//# sourceMappingURL=edge.d.ts.map
|
package/dist/src/edge.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"edge.d.ts","sourceRoot":"","sources":["../../src/edge.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAGnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAC/C,YAAY,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAGnD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,YAAY,EAAE,oBAAoB,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAGhF,OAAO,EAAE,YAAY,EAAE,2BAA2B,EAAE,MAAM,WAAW,CAAA;AAGrE,YAAY,EACV,sBAAsB,EACtB,sBAAsB,EACtB,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,WAAW,EACX,eAAe,EACf,wBAAwB,EACxB,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,GACf,MAAM,SAAS,CAAA;AAGhB,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAInC,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,EACxB,yBAAyB,EACzB,yBAAyB,EACzB,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,gBAAgB,GACjB,MAAM,WAAW,CAAA;AAClB,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAqC/D,wBAAsB,aAAa,CAAC,EAClC,IAAI,EACJ,SAAS,EACT,MAAM,GACP,EAAE;IACD,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;CACf,GAAG,OAAO,CAAC,YAAY,CAAC,CA8CxB"}
|
package/dist/src/edge.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SolvaPay Server SDK - Edge Runtime Entry Point
|
|
3
|
-
*
|
|
4
|
-
* This module provides edge runtime-compatible exports using Web Crypto API.
|
|
5
|
-
* Automatically selected when running in edge runtimes (Vercel Edge, Cloudflare Workers, Deno, etc.)
|
|
6
|
-
*/
|
|
7
|
-
import { SolvaPayError } from '@solvapay/core';
|
|
8
|
-
// Re-export the main client which is already edge-compatible (uses fetch)
|
|
9
|
-
export { createSolvaPayClient } from './client';
|
|
10
|
-
// Re-export factory for unified API
|
|
11
|
-
export { createSolvaPay } from './factory';
|
|
12
|
-
// Export PaywallError for error handling
|
|
13
|
-
export { PaywallError, paywallErrorToClientPayload } from './paywall';
|
|
14
|
-
// Export retry utility for general use
|
|
15
|
-
export { withRetry } from './utils';
|
|
16
|
-
// Export route helpers (generic, framework-agnostic)
|
|
17
|
-
// These work in edge runtimes as they use standard Web API Request
|
|
18
|
-
export { getAuthenticatedUserCore, syncCustomerCore, createPaymentIntentCore, processPaymentIntentCore, createCheckoutSessionCore, createCustomerSessionCore, cancelPurchaseCore, listPlansCore, isErrorResult, handleRouteError, } from './helpers';
|
|
19
|
-
/**
|
|
20
|
-
* Verify webhook signature using edge-compatible Web Crypto API.
|
|
21
|
-
*
|
|
22
|
-
* The backend sends an `SV-Signature` header in the format `t={timestamp},v1={hmac}`.
|
|
23
|
-
* The HMAC is SHA-256 over `"{timestamp}.{rawBody}"` keyed by the full webhook secret
|
|
24
|
-
* (including the `whsec_` prefix). Signatures older than 5 minutes are rejected to
|
|
25
|
-
* prevent replay attacks.
|
|
26
|
-
*
|
|
27
|
-
* Works in: Vercel Edge Functions, Cloudflare Workers, Deno, Supabase Edge Functions.
|
|
28
|
-
*
|
|
29
|
-
* @param params.body - Raw webhook request body (string)
|
|
30
|
-
* @param params.signature - Value of the `SV-Signature` header
|
|
31
|
-
* @param params.secret - Webhook signing secret (`whsec_…`)
|
|
32
|
-
* @returns Parsed and typed {@link WebhookEvent} object
|
|
33
|
-
* @throws {SolvaPayError} If signature is missing, malformed, expired, or invalid
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```typescript
|
|
37
|
-
* // Supabase Edge Function
|
|
38
|
-
* import { verifyWebhook } from '@solvapay/server/edge';
|
|
39
|
-
*
|
|
40
|
-
* const signature = req.headers.get('sv-signature')!;
|
|
41
|
-
* const body = await req.text();
|
|
42
|
-
* const event = await verifyWebhook({ body, signature, secret });
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
45
|
-
function timingSafeEqual(a, b) {
|
|
46
|
-
if (a.length !== b.length)
|
|
47
|
-
return false;
|
|
48
|
-
let mismatch = 0;
|
|
49
|
-
for (let i = 0; i < a.length; i++) {
|
|
50
|
-
mismatch |= a.charCodeAt(i) ^ b.charCodeAt(i);
|
|
51
|
-
}
|
|
52
|
-
return mismatch === 0;
|
|
53
|
-
}
|
|
54
|
-
export async function verifyWebhook({ body, signature, secret, }) {
|
|
55
|
-
const toleranceSec = 300;
|
|
56
|
-
if (!signature)
|
|
57
|
-
throw new SolvaPayError('Missing webhook signature');
|
|
58
|
-
const parts = signature.split(',');
|
|
59
|
-
const tPart = parts.find(p => p.startsWith('t='));
|
|
60
|
-
const v1Part = parts.find(p => p.startsWith('v1='));
|
|
61
|
-
if (!tPart || !v1Part) {
|
|
62
|
-
throw new SolvaPayError('Malformed webhook signature');
|
|
63
|
-
}
|
|
64
|
-
const timestamp = parseInt(tPart.slice(2), 10);
|
|
65
|
-
const receivedHmac = v1Part.slice(3);
|
|
66
|
-
if (Number.isNaN(timestamp) || !receivedHmac) {
|
|
67
|
-
throw new SolvaPayError('Malformed webhook signature');
|
|
68
|
-
}
|
|
69
|
-
if (toleranceSec > 0) {
|
|
70
|
-
const age = Math.abs(Math.floor(Date.now() / 1000) - timestamp);
|
|
71
|
-
if (age > toleranceSec) {
|
|
72
|
-
throw new SolvaPayError('Webhook signature timestamp too old');
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
const enc = new TextEncoder();
|
|
76
|
-
const key = await crypto.subtle.importKey('raw', enc.encode(secret), { name: 'HMAC', hash: 'SHA-256' }, false, ['sign']);
|
|
77
|
-
const sigBuf = await crypto.subtle.sign('HMAC', key, enc.encode(`${timestamp}.${body}`));
|
|
78
|
-
const expectedHmac = Array.from(new Uint8Array(sigBuf))
|
|
79
|
-
.map(b => b.toString(16).padStart(2, '0'))
|
|
80
|
-
.join('');
|
|
81
|
-
if (!timingSafeEqual(expectedHmac, receivedHmac)) {
|
|
82
|
-
throw new SolvaPayError('Invalid webhook signature');
|
|
83
|
-
}
|
|
84
|
-
try {
|
|
85
|
-
return JSON.parse(body);
|
|
86
|
-
}
|
|
87
|
-
catch {
|
|
88
|
-
throw new SolvaPayError('Invalid webhook payload: body is not valid JSON');
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
//# sourceMappingURL=edge.js.map
|
package/dist/src/edge.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"edge.js","sourceRoot":"","sources":["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