@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.
Files changed (148) hide show
  1. package/README.md +80 -2
  2. package/dist/edge.d.ts +495 -61
  3. package/dist/edge.js +648 -187
  4. package/dist/fetch/index.cjs +3071 -0
  5. package/dist/fetch/index.d.cts +112 -0
  6. package/dist/fetch/index.d.ts +112 -0
  7. package/dist/fetch/index.js +3017 -0
  8. package/dist/index.cjs +603 -5013
  9. package/dist/index.d.cts +490 -156
  10. package/dist/index.d.ts +490 -156
  11. package/dist/index.js +571 -695
  12. package/package.json +15 -12
  13. package/dist/chunk-MLKGABMK.js +0 -9
  14. package/dist/chunk-R5U7XKVJ.js +0 -16
  15. package/dist/dist-EPVKJAIP.js +0 -94
  16. package/dist/dist-JBJ4HMP7.js +0 -94
  17. package/dist/esm-5GYCIXIY.js +0 -3475
  18. package/dist/esm-UW7WCMEK.js +0 -3475
  19. package/dist/src/adapters/base.d.ts +0 -57
  20. package/dist/src/adapters/base.d.ts.map +0 -1
  21. package/dist/src/adapters/base.js +0 -73
  22. package/dist/src/adapters/base.js.map +0 -1
  23. package/dist/src/adapters/http.d.ts +0 -25
  24. package/dist/src/adapters/http.d.ts.map +0 -1
  25. package/dist/src/adapters/http.js +0 -99
  26. package/dist/src/adapters/http.js.map +0 -1
  27. package/dist/src/adapters/index.d.ts +0 -11
  28. package/dist/src/adapters/index.d.ts.map +0 -1
  29. package/dist/src/adapters/index.js +0 -10
  30. package/dist/src/adapters/index.js.map +0 -1
  31. package/dist/src/adapters/mcp.d.ts +0 -24
  32. package/dist/src/adapters/mcp.d.ts.map +0 -1
  33. package/dist/src/adapters/mcp.js +0 -75
  34. package/dist/src/adapters/mcp.js.map +0 -1
  35. package/dist/src/adapters/next.d.ts +0 -24
  36. package/dist/src/adapters/next.d.ts.map +0 -1
  37. package/dist/src/adapters/next.js +0 -109
  38. package/dist/src/adapters/next.js.map +0 -1
  39. package/dist/src/client.d.ts +0 -58
  40. package/dist/src/client.d.ts.map +0 -1
  41. package/dist/src/client.js +0 -495
  42. package/dist/src/client.js.map +0 -1
  43. package/dist/src/edge.d.ts +0 -22
  44. package/dist/src/edge.d.ts.map +0 -1
  45. package/dist/src/edge.js +0 -91
  46. package/dist/src/edge.js.map +0 -1
  47. package/dist/src/factory.d.ts +0 -605
  48. package/dist/src/factory.d.ts.map +0 -1
  49. package/dist/src/factory.js +0 -215
  50. package/dist/src/factory.js.map +0 -1
  51. package/dist/src/helpers/auth.d.ts +0 -47
  52. package/dist/src/helpers/auth.d.ts.map +0 -1
  53. package/dist/src/helpers/auth.js +0 -73
  54. package/dist/src/helpers/auth.js.map +0 -1
  55. package/dist/src/helpers/checkout.d.ts +0 -45
  56. package/dist/src/helpers/checkout.d.ts.map +0 -1
  57. package/dist/src/helpers/checkout.js +0 -89
  58. package/dist/src/helpers/checkout.js.map +0 -1
  59. package/dist/src/helpers/customer.d.ts +0 -51
  60. package/dist/src/helpers/customer.d.ts.map +0 -1
  61. package/dist/src/helpers/customer.js +0 -77
  62. package/dist/src/helpers/customer.js.map +0 -1
  63. package/dist/src/helpers/error.d.ts +0 -15
  64. package/dist/src/helpers/error.d.ts.map +0 -1
  65. package/dist/src/helpers/error.js +0 -35
  66. package/dist/src/helpers/error.js.map +0 -1
  67. package/dist/src/helpers/index.d.ts +0 -17
  68. package/dist/src/helpers/index.d.ts.map +0 -1
  69. package/dist/src/helpers/index.js +0 -23
  70. package/dist/src/helpers/index.js.map +0 -1
  71. package/dist/src/helpers/payment.d.ts +0 -107
  72. package/dist/src/helpers/payment.d.ts.map +0 -1
  73. package/dist/src/helpers/payment.js +0 -150
  74. package/dist/src/helpers/payment.js.map +0 -1
  75. package/dist/src/helpers/plans.d.ts +0 -19
  76. package/dist/src/helpers/plans.d.ts.map +0 -1
  77. package/dist/src/helpers/plans.js +0 -53
  78. package/dist/src/helpers/plans.js.map +0 -1
  79. package/dist/src/helpers/renewal.d.ts +0 -23
  80. package/dist/src/helpers/renewal.d.ts.map +0 -1
  81. package/dist/src/helpers/renewal.js +0 -90
  82. package/dist/src/helpers/renewal.js.map +0 -1
  83. package/dist/src/helpers/subscription.d.ts +0 -23
  84. package/dist/src/helpers/subscription.d.ts.map +0 -1
  85. package/dist/src/helpers/subscription.js +0 -101
  86. package/dist/src/helpers/subscription.js.map +0 -1
  87. package/dist/src/helpers/types.d.ts +0 -22
  88. package/dist/src/helpers/types.d.ts.map +0 -1
  89. package/dist/src/helpers/types.js +0 -7
  90. package/dist/src/helpers/types.js.map +0 -1
  91. package/dist/src/index.d.ts +0 -73
  92. package/dist/src/index.d.ts.map +0 -1
  93. package/dist/src/index.js +0 -106
  94. package/dist/src/index.js.map +0 -1
  95. package/dist/src/mcp/auth-bridge.d.ts +0 -9
  96. package/dist/src/mcp/auth-bridge.d.ts.map +0 -1
  97. package/dist/src/mcp/auth-bridge.js +0 -46
  98. package/dist/src/mcp/auth-bridge.js.map +0 -1
  99. package/dist/src/mcp/oauth-bridge.d.ts +0 -48
  100. package/dist/src/mcp/oauth-bridge.d.ts.map +0 -1
  101. package/dist/src/mcp/oauth-bridge.js +0 -110
  102. package/dist/src/mcp/oauth-bridge.js.map +0 -1
  103. package/dist/src/mcp-auth.d.ts +0 -17
  104. package/dist/src/mcp-auth.d.ts.map +0 -1
  105. package/dist/src/mcp-auth.js +0 -57
  106. package/dist/src/mcp-auth.js.map +0 -1
  107. package/dist/src/paywall.d.ts +0 -119
  108. package/dist/src/paywall.d.ts.map +0 -1
  109. package/dist/src/paywall.js +0 -700
  110. package/dist/src/paywall.js.map +0 -1
  111. package/dist/src/register-virtual-tools-mcp.d.ts +0 -23
  112. package/dist/src/register-virtual-tools-mcp.d.ts.map +0 -1
  113. package/dist/src/register-virtual-tools-mcp.js +0 -86
  114. package/dist/src/register-virtual-tools-mcp.js.map +0 -1
  115. package/dist/src/types/client.d.ts +0 -216
  116. package/dist/src/types/client.d.ts.map +0 -1
  117. package/dist/src/types/client.js +0 -7
  118. package/dist/src/types/client.js.map +0 -1
  119. package/dist/src/types/generated.d.ts +0 -2834
  120. package/dist/src/types/generated.d.ts.map +0 -1
  121. package/dist/src/types/generated.js +0 -6
  122. package/dist/src/types/generated.js.map +0 -1
  123. package/dist/src/types/index.d.ts +0 -13
  124. package/dist/src/types/index.d.ts.map +0 -1
  125. package/dist/src/types/index.js +0 -8
  126. package/dist/src/types/index.js.map +0 -1
  127. package/dist/src/types/options.d.ts +0 -126
  128. package/dist/src/types/options.d.ts.map +0 -1
  129. package/dist/src/types/options.js +0 -8
  130. package/dist/src/types/options.js.map +0 -1
  131. package/dist/src/types/paywall.d.ts +0 -64
  132. package/dist/src/types/paywall.d.ts.map +0 -1
  133. package/dist/src/types/paywall.js +0 -7
  134. package/dist/src/types/paywall.js.map +0 -1
  135. package/dist/src/types/webhook.d.ts +0 -50
  136. package/dist/src/types/webhook.d.ts.map +0 -1
  137. package/dist/src/types/webhook.js +0 -2
  138. package/dist/src/types/webhook.js.map +0 -1
  139. package/dist/src/utils.d.ts +0 -110
  140. package/dist/src/utils.d.ts.map +0 -1
  141. package/dist/src/utils.js +0 -217
  142. package/dist/src/utils.js.map +0 -1
  143. package/dist/src/virtual-tools.d.ts +0 -44
  144. package/dist/src/virtual-tools.d.ts.map +0 -1
  145. package/dist/src/virtual-tools.js +0 -140
  146. package/dist/src/virtual-tools.js.map +0 -1
  147. package/dist/tsconfig.tsbuildinfo +0 -1
  148. package/dist/webapi-K5XBCEO6.js +0 -3775
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solvapay/server",
3
- "version": "1.0.8-preview.8",
3
+ "version": "1.0.8",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -18,6 +18,11 @@
18
18
  "types": "./dist/edge.d.ts",
19
19
  "import": "./dist/edge.js",
20
20
  "default": "./dist/edge.js"
21
+ },
22
+ "./fetch": {
23
+ "types": "./dist/fetch/index.d.ts",
24
+ "import": "./dist/fetch/index.js",
25
+ "require": "./dist/fetch/index.cjs"
21
26
  }
22
27
  },
23
28
  "files": [
@@ -37,17 +42,13 @@
37
42
  },
38
43
  "sideEffects": false,
39
44
  "dependencies": {
40
- "@solvapay/core": "1.0.8-preview.8"
45
+ "@solvapay/core": "1.0.8-preview.10"
41
46
  },
42
47
  "peerDependencies": {
43
- "@modelcontextprotocol/sdk": "^1.28.0",
44
48
  "zod": "^3.25.0 || ^4.0.0",
45
- "@solvapay/auth": "1.0.8-preview.8"
49
+ "@solvapay/auth": "1.0.8-preview.10"
46
50
  },
47
51
  "peerDependenciesMeta": {
48
- "@modelcontextprotocol/sdk": {
49
- "optional": true
50
- },
51
52
  "zod": {
52
53
  "optional": true
53
54
  }
@@ -60,15 +61,17 @@
60
61
  "tsx": "^4.21.0",
61
62
  "typescript": "^5.9.3",
62
63
  "vitest": "^4.1.2",
64
+ "zod": "^4.3.6",
65
+ "@solvapay/auth": "1.0.8-preview.10",
63
66
  "@solvapay/demo-services": "0.0.0",
64
- "@solvapay/test-utils": "^0.0.0",
65
- "@solvapay/auth": "1.0.8-preview.8"
67
+ "@solvapay/test-utils": "^0.0.0"
66
68
  },
67
69
  "scripts": {
68
- "build": "tsup src/index.ts --format esm,cjs --dts --tsconfig tsconfig.build.json && tsup src/edge.ts --format esm --dts --tsconfig tsconfig.build.json",
70
+ "build": "tsup",
71
+ "dev": "tsup --watch",
69
72
  "generate:types": "tsx scripts/generate-types.ts",
70
- "test": "vitest run __tests__/paywall.unit.test.ts __tests__/mcp-auth.unit.test.ts __tests__/bootstrap-mcp.unit.test.ts __tests__/verify-webhook.unit.test.ts src/mcp/oauth-bridge.spec.ts",
71
- "test:unit": "vitest run __tests__/paywall.unit.test.ts __tests__/mcp-auth.unit.test.ts __tests__/bootstrap-mcp.unit.test.ts __tests__/verify-webhook.unit.test.ts src/mcp/oauth-bridge.spec.ts",
73
+ "test": "vitest run __tests__/paywall.unit.test.ts __tests__/paywall-state.unit.test.ts __tests__/bootstrap-mcp.unit.test.ts __tests__/verify-webhook.unit.test.ts __tests__/edge-exports.unit.test.ts src/__tests__/edge-exports.test.ts __tests__/auth-core.unit.test.ts __tests__/ensure-customer.unit.test.ts __tests__/create-customer.unit.test.ts __tests__/fetch/cors.test.ts __tests__/fetch/handlers.test.ts __tests__/fetch/utils.test.ts",
74
+ "test:unit": "vitest run __tests__/paywall.unit.test.ts __tests__/paywall-state.unit.test.ts __tests__/bootstrap-mcp.unit.test.ts __tests__/verify-webhook.unit.test.ts __tests__/edge-exports.unit.test.ts src/__tests__/edge-exports.test.ts __tests__/auth-core.unit.test.ts __tests__/ensure-customer.unit.test.ts __tests__/create-customer.unit.test.ts __tests__/fetch/cors.test.ts __tests__/fetch/handlers.test.ts __tests__/fetch/utils.test.ts",
72
75
  "test:integration": "vitest run __tests__/backend.integration.test.ts",
73
76
  "test:integration:payment": "vitest run __tests__/payment-stripe.integration.test.ts",
74
77
  "test:all": "vitest run",
@@ -1,9 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __export = (target, all) => {
3
- for (var name in all)
4
- __defProp(target, name, { get: all[name], enumerable: true });
5
- };
6
-
7
- export {
8
- __export
9
- };
@@ -1,16 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
3
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
4
- }) : x)(function(x) {
5
- if (typeof require !== "undefined") return require.apply(this, arguments);
6
- throw Error('Dynamic require of "' + x + '" is not supported');
7
- });
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
-
13
- export {
14
- __require,
15
- __export
16
- };
@@ -1,94 +0,0 @@
1
- import "./chunk-R5U7XKVJ.js";
2
-
3
- // ../auth/dist/chunk-OETEFHW6.js
4
- var MockAuthAdapter = class {
5
- async getUserIdFromRequest(req) {
6
- const headers = "headers" in req ? req.headers : req;
7
- const headerUserId = headers.get("x-mock-user-id");
8
- if (headerUserId) {
9
- return headerUserId;
10
- }
11
- if (typeof process !== "undefined" && process.env.MOCK_USER_ID) {
12
- return process.env.MOCK_USER_ID;
13
- }
14
- return null;
15
- }
16
- };
17
-
18
- // ../auth/dist/chunk-2P77RLPB.js
19
- function getUserIdFromRequest(request, options) {
20
- const headerName = options?.headerName || "x-user-id";
21
- return request.headers.get(headerName);
22
- }
23
- async function getUserEmailFromRequest(request, options) {
24
- const authHeader = request.headers.get("authorization");
25
- if (!authHeader || !authHeader.startsWith("Bearer ")) {
26
- return null;
27
- }
28
- const token = authHeader.slice(7);
29
- if (!token) {
30
- return null;
31
- }
32
- try {
33
- const { jwtVerify } = await import("./esm-5GYCIXIY.js");
34
- const jwtSecret = options?.jwtSecret || process.env.SUPABASE_JWT_SECRET;
35
- if (!jwtSecret) {
36
- return null;
37
- }
38
- const secret = new TextEncoder().encode(jwtSecret);
39
- const { payload } = await jwtVerify(token, secret, {
40
- algorithms: ["HS256"]
41
- });
42
- return payload.email ? String(payload.email) : null;
43
- } catch {
44
- return null;
45
- }
46
- }
47
- async function getUserNameFromRequest(request, options) {
48
- const authHeader = request.headers.get("authorization");
49
- if (!authHeader || !authHeader.startsWith("Bearer ")) {
50
- return null;
51
- }
52
- const token = authHeader.slice(7);
53
- if (!token) {
54
- return null;
55
- }
56
- try {
57
- const { jwtVerify } = await import("./esm-5GYCIXIY.js");
58
- const jwtSecret = options?.jwtSecret || process.env.SUPABASE_JWT_SECRET;
59
- if (!jwtSecret) {
60
- return null;
61
- }
62
- const secret = new TextEncoder().encode(jwtSecret);
63
- const { payload } = await jwtVerify(token, secret, {
64
- algorithms: ["HS256"]
65
- });
66
- const name = payload.user_metadata?.full_name || payload.user_metadata?.name || payload.name || null;
67
- return name ? String(name) : null;
68
- } catch {
69
- return null;
70
- }
71
- }
72
- function requireUserId(request, options) {
73
- const headerName = options?.headerName || "x-user-id";
74
- const errorMessage = options?.errorMessage || "Unauthorized";
75
- const errorDetails = options?.errorDetails || "User ID not found. Ensure middleware is configured.";
76
- const userId = request.headers.get(headerName);
77
- if (!userId) {
78
- return new Response(
79
- JSON.stringify({ error: errorMessage, details: errorDetails }),
80
- {
81
- status: 401,
82
- headers: { "Content-Type": "application/json" }
83
- }
84
- );
85
- }
86
- return userId;
87
- }
88
- export {
89
- MockAuthAdapter,
90
- getUserEmailFromRequest,
91
- getUserIdFromRequest,
92
- getUserNameFromRequest,
93
- requireUserId
94
- };
@@ -1,94 +0,0 @@
1
- import "./chunk-R5U7XKVJ.js";
2
-
3
- // ../auth/dist/chunk-OETEFHW6.js
4
- var MockAuthAdapter = class {
5
- async getUserIdFromRequest(req) {
6
- const headers = "headers" in req ? req.headers : req;
7
- const headerUserId = headers.get("x-mock-user-id");
8
- if (headerUserId) {
9
- return headerUserId;
10
- }
11
- if (typeof process !== "undefined" && process.env.MOCK_USER_ID) {
12
- return process.env.MOCK_USER_ID;
13
- }
14
- return null;
15
- }
16
- };
17
-
18
- // ../auth/dist/chunk-B4VVTQWS.js
19
- function getUserIdFromRequest(request, options) {
20
- const headerName = options?.headerName || "x-user-id";
21
- return request.headers.get(headerName);
22
- }
23
- async function getUserEmailFromRequest(request, options) {
24
- const authHeader = request.headers.get("authorization");
25
- if (!authHeader || !authHeader.startsWith("Bearer ")) {
26
- return null;
27
- }
28
- const token = authHeader.slice(7);
29
- if (!token) {
30
- return null;
31
- }
32
- try {
33
- const { jwtVerify } = await import("./esm-5GYCIXIY.js");
34
- const jwtSecret = options?.jwtSecret || process.env.SUPABASE_JWT_SECRET;
35
- if (!jwtSecret) {
36
- return null;
37
- }
38
- const secret = new TextEncoder().encode(jwtSecret);
39
- const { payload } = await jwtVerify(token, secret, {
40
- algorithms: ["HS256"]
41
- });
42
- return payload.email ? String(payload.email) : null;
43
- } catch {
44
- return null;
45
- }
46
- }
47
- async function getUserNameFromRequest(request, options) {
48
- const authHeader = request.headers.get("authorization");
49
- if (!authHeader || !authHeader.startsWith("Bearer ")) {
50
- return null;
51
- }
52
- const token = authHeader.slice(7);
53
- if (!token) {
54
- return null;
55
- }
56
- try {
57
- const { jwtVerify } = await import("./esm-5GYCIXIY.js");
58
- const jwtSecret = options?.jwtSecret || process.env.SUPABASE_JWT_SECRET;
59
- if (!jwtSecret) {
60
- return null;
61
- }
62
- const secret = new TextEncoder().encode(jwtSecret);
63
- const { payload } = await jwtVerify(token, secret, {
64
- algorithms: ["HS256"]
65
- });
66
- const name = payload.user_metadata?.name || payload.name || null;
67
- return name ? String(name) : null;
68
- } catch {
69
- return null;
70
- }
71
- }
72
- function requireUserId(request, options) {
73
- const headerName = options?.headerName || "x-user-id";
74
- const errorMessage = options?.errorMessage || "Unauthorized";
75
- const errorDetails = options?.errorDetails || "User ID not found. Ensure middleware is configured.";
76
- const userId = request.headers.get(headerName);
77
- if (!userId) {
78
- return new Response(
79
- JSON.stringify({ error: errorMessage, details: errorDetails }),
80
- {
81
- status: 401,
82
- headers: { "Content-Type": "application/json" }
83
- }
84
- );
85
- }
86
- return userId;
87
- }
88
- export {
89
- MockAuthAdapter,
90
- getUserEmailFromRequest,
91
- getUserIdFromRequest,
92
- getUserNameFromRequest,
93
- requireUserId
94
- };