@solvapay/server 1.0.8-preview.6 → 1.0.8-preview.7
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/dist/chunk-R5U7XKVJ.js +16 -0
- package/dist/dist-EPVKJAIP.js +94 -0
- package/dist/dist-JBJ4HMP7.js +94 -0
- package/dist/esm-5GYCIXIY.js +3475 -0
- package/dist/esm-UW7WCMEK.js +3475 -0
- package/dist/index.cjs +293 -12
- package/dist/index.d.cts +35 -3
- package/dist/index.d.ts +35 -3
- package/dist/index.js +289 -12
- package/dist/src/adapters/base.d.ts +57 -0
- package/dist/src/adapters/base.d.ts.map +1 -0
- package/dist/src/adapters/base.js +73 -0
- package/dist/src/adapters/base.js.map +1 -0
- package/dist/src/adapters/http.d.ts +25 -0
- package/dist/src/adapters/http.d.ts.map +1 -0
- package/dist/src/adapters/http.js +99 -0
- package/dist/src/adapters/http.js.map +1 -0
- package/dist/src/adapters/index.d.ts +11 -0
- package/dist/src/adapters/index.d.ts.map +1 -0
- package/dist/src/adapters/index.js +10 -0
- package/dist/src/adapters/index.js.map +1 -0
- package/dist/src/adapters/mcp.d.ts +24 -0
- package/dist/src/adapters/mcp.d.ts.map +1 -0
- package/dist/src/adapters/mcp.js +75 -0
- package/dist/src/adapters/mcp.js.map +1 -0
- package/dist/src/adapters/next.d.ts +24 -0
- package/dist/src/adapters/next.d.ts.map +1 -0
- package/dist/src/adapters/next.js +109 -0
- package/dist/src/adapters/next.js.map +1 -0
- package/dist/src/client.d.ts +58 -0
- package/dist/src/client.d.ts.map +1 -0
- package/dist/src/client.js +495 -0
- package/dist/src/client.js.map +1 -0
- package/dist/src/edge.d.ts +22 -0
- package/dist/src/edge.d.ts.map +1 -0
- package/dist/src/edge.js +91 -0
- package/dist/src/edge.js.map +1 -0
- package/dist/src/factory.d.ts +605 -0
- package/dist/src/factory.d.ts.map +1 -0
- package/dist/src/factory.js +215 -0
- package/dist/src/factory.js.map +1 -0
- package/dist/src/helpers/auth.d.ts +47 -0
- package/dist/src/helpers/auth.d.ts.map +1 -0
- package/dist/src/helpers/auth.js +73 -0
- package/dist/src/helpers/auth.js.map +1 -0
- package/dist/src/helpers/checkout.d.ts +45 -0
- package/dist/src/helpers/checkout.d.ts.map +1 -0
- package/dist/src/helpers/checkout.js +89 -0
- package/dist/src/helpers/checkout.js.map +1 -0
- package/dist/src/helpers/customer.d.ts +51 -0
- package/dist/src/helpers/customer.d.ts.map +1 -0
- package/dist/src/helpers/customer.js +77 -0
- package/dist/src/helpers/customer.js.map +1 -0
- package/dist/src/helpers/error.d.ts +15 -0
- package/dist/src/helpers/error.d.ts.map +1 -0
- package/dist/src/helpers/error.js +35 -0
- package/dist/src/helpers/error.js.map +1 -0
- package/dist/src/helpers/index.d.ts +17 -0
- package/dist/src/helpers/index.d.ts.map +1 -0
- package/dist/src/helpers/index.js +23 -0
- package/dist/src/helpers/index.js.map +1 -0
- package/dist/src/helpers/payment.d.ts +107 -0
- package/dist/src/helpers/payment.d.ts.map +1 -0
- package/dist/src/helpers/payment.js +150 -0
- package/dist/src/helpers/payment.js.map +1 -0
- package/dist/src/helpers/plans.d.ts +19 -0
- package/dist/src/helpers/plans.d.ts.map +1 -0
- package/dist/src/helpers/plans.js +53 -0
- package/dist/src/helpers/plans.js.map +1 -0
- package/dist/src/helpers/renewal.d.ts +23 -0
- package/dist/src/helpers/renewal.d.ts.map +1 -0
- package/dist/src/helpers/renewal.js +90 -0
- package/dist/src/helpers/renewal.js.map +1 -0
- package/dist/src/helpers/subscription.d.ts +23 -0
- package/dist/src/helpers/subscription.d.ts.map +1 -0
- package/dist/src/helpers/subscription.js +101 -0
- package/dist/src/helpers/subscription.js.map +1 -0
- package/dist/src/helpers/types.d.ts +22 -0
- package/dist/src/helpers/types.d.ts.map +1 -0
- package/dist/src/helpers/types.js +7 -0
- package/dist/src/helpers/types.js.map +1 -0
- package/dist/src/index.d.ts +73 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +106 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/mcp/auth-bridge.d.ts +9 -0
- package/dist/src/mcp/auth-bridge.d.ts.map +1 -0
- package/dist/src/mcp/auth-bridge.js +46 -0
- package/dist/src/mcp/auth-bridge.js.map +1 -0
- package/dist/src/mcp/oauth-bridge.d.ts +48 -0
- package/dist/src/mcp/oauth-bridge.d.ts.map +1 -0
- package/dist/src/mcp/oauth-bridge.js +110 -0
- package/dist/src/mcp/oauth-bridge.js.map +1 -0
- package/dist/src/mcp-auth.d.ts +17 -0
- package/dist/src/mcp-auth.d.ts.map +1 -0
- package/dist/src/mcp-auth.js +57 -0
- package/dist/src/mcp-auth.js.map +1 -0
- package/dist/src/paywall.d.ts +119 -0
- package/dist/src/paywall.d.ts.map +1 -0
- package/dist/src/paywall.js +700 -0
- package/dist/src/paywall.js.map +1 -0
- package/dist/src/register-virtual-tools-mcp.d.ts +23 -0
- package/dist/src/register-virtual-tools-mcp.d.ts.map +1 -0
- package/dist/src/register-virtual-tools-mcp.js +86 -0
- package/dist/src/register-virtual-tools-mcp.js.map +1 -0
- package/dist/src/types/client.d.ts +216 -0
- package/dist/src/types/client.d.ts.map +1 -0
- package/dist/src/types/client.js +7 -0
- package/dist/src/types/client.js.map +1 -0
- package/dist/src/types/generated.d.ts +2834 -0
- package/dist/src/types/generated.d.ts.map +1 -0
- package/dist/src/types/generated.js +6 -0
- package/dist/src/types/generated.js.map +1 -0
- package/dist/src/types/index.d.ts +13 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/types/index.js +8 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/types/options.d.ts +126 -0
- package/dist/src/types/options.d.ts.map +1 -0
- package/dist/src/types/options.js +8 -0
- package/dist/src/types/options.js.map +1 -0
- package/dist/src/types/paywall.d.ts +64 -0
- package/dist/src/types/paywall.d.ts.map +1 -0
- package/dist/src/types/paywall.js +7 -0
- package/dist/src/types/paywall.js.map +1 -0
- package/dist/src/types/webhook.d.ts +50 -0
- package/dist/src/types/webhook.d.ts.map +1 -0
- package/dist/src/types/webhook.js +2 -0
- package/dist/src/types/webhook.js.map +1 -0
- package/dist/src/utils.d.ts +110 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/utils.js +217 -0
- package/dist/src/utils.js.map +1 -0
- package/dist/src/virtual-tools.d.ts +44 -0
- package/dist/src/virtual-tools.d.ts.map +1 -0
- package/dist/src/virtual-tools.js +140 -0
- package/dist/src/virtual-tools.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +6 -6
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
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
|
+
};
|