@atxp/server 0.2.5 → 0.2.6
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/package.json +2 -2
- package/dist/src/atxpContext.d.ts +0 -6
- package/dist/src/atxpContext.d.ts.map +0 -1
- package/dist/src/atxpContext.js +0 -41
- package/dist/src/atxpContext.js.map +0 -1
- package/dist/src/atxpServer.d.ts +0 -12
- package/dist/src/atxpServer.d.ts.map +0 -1
- package/dist/src/atxpServer.js +0 -95
- package/dist/src/atxpServer.js.map +0 -1
- package/dist/src/getResource.d.ts +0 -4
- package/dist/src/getResource.d.ts.map +0 -1
- package/dist/src/getResource.js +0 -17
- package/dist/src/getResource.js.map +0 -1
- package/dist/src/http.d.ts +0 -7
- package/dist/src/http.d.ts.map +0 -1
- package/dist/src/http.js +0 -51
- package/dist/src/http.js.map +0 -1
- package/dist/src/index.d.ts +0 -5
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -5
- package/dist/src/index.js.map +0 -1
- package/dist/src/oAuthChallenge.d.ts +0 -4
- package/dist/src/oAuthChallenge.d.ts.map +0 -1
- package/dist/src/oAuthChallenge.js +0 -39
- package/dist/src/oAuthChallenge.js.map +0 -1
- package/dist/src/oAuthMetadata.d.ts +0 -6
- package/dist/src/oAuthMetadata.d.ts.map +0 -1
- package/dist/src/oAuthMetadata.js +0 -41
- package/dist/src/oAuthMetadata.js.map +0 -1
- package/dist/src/paymentServer.d.ts +0 -68
- package/dist/src/paymentServer.d.ts.map +0 -1
- package/dist/src/paymentServer.js +0 -97
- package/dist/src/paymentServer.js.map +0 -1
- package/dist/src/protectedResourceMetadata.d.ts +0 -5
- package/dist/src/protectedResourceMetadata.d.ts.map +0 -1
- package/dist/src/protectedResourceMetadata.js +0 -40
- package/dist/src/protectedResourceMetadata.js.map +0 -1
- package/dist/src/requirePayment.d.ts +0 -3
- package/dist/src/requirePayment.d.ts.map +0 -1
- package/dist/src/requirePayment.js +0 -35
- package/dist/src/requirePayment.js.map +0 -1
- package/dist/src/serverTestHelpers.d.ts +0 -55
- package/dist/src/serverTestHelpers.d.ts.map +0 -1
- package/dist/src/serverTestHelpers.js +0 -88
- package/dist/src/serverTestHelpers.js.map +0 -1
- package/dist/src/token.d.ts +0 -4
- package/dist/src/token.d.ts.map +0 -1
- package/dist/src/token.js +0 -36
- package/dist/src/token.js.map +0 -1
- package/dist/src/types.d.ts +0 -60
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js +0 -10
- package/dist/src/types.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atxp/server",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"description": "ATXP Server - MCP server implementation with payment processing capabilities",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"test": "vitest run"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@atxp/common": "0.2.
|
|
25
|
+
"@atxp/common": "0.2.6",
|
|
26
26
|
"@modelcontextprotocol/sdk": "^1.15.0",
|
|
27
27
|
"@types/express": "^5.0.0",
|
|
28
28
|
"bignumber.js": "^9.3.0",
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ATXPConfig, TokenCheck } from "./types.js";
|
|
2
|
-
export declare function getATXPConfig(): ATXPConfig | null;
|
|
3
|
-
export declare function getATXPResource(): URL | null;
|
|
4
|
-
export declare function atxpAccountId(): string | null;
|
|
5
|
-
export declare function withATXPContext(config: ATXPConfig, resource: URL, tokenInfo: Pick<TokenCheck, 'token' | 'data'> | null, next: () => void): Promise<void>;
|
|
6
|
-
//# sourceMappingURL=atxpContext.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"atxpContext.d.ts","sourceRoot":"","sources":["../../src/atxpContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAWpD,wBAAgB,aAAa,IAAI,UAAU,GAAG,IAAI,CAGjD;AAED,wBAAgB,eAAe,IAAI,GAAG,GAAG,IAAI,CAG5C;AAGD,wBAAgB,aAAa,IAAI,MAAM,GAAG,IAAI,CAG7C;AAGD,wBAAsB,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,GAAG,MAAM,CAAC,GAAG,IAAI,EAAE,IAAI,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAwB9J"}
|
package/dist/src/atxpContext.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { AsyncLocalStorage } from "async_hooks";
|
|
2
|
-
const contextStorage = new AsyncLocalStorage();
|
|
3
|
-
export function getATXPConfig() {
|
|
4
|
-
const context = contextStorage.getStore();
|
|
5
|
-
return context?.config ?? null;
|
|
6
|
-
}
|
|
7
|
-
export function getATXPResource() {
|
|
8
|
-
const context = contextStorage.getStore();
|
|
9
|
-
return context?.resource ?? null;
|
|
10
|
-
}
|
|
11
|
-
// Helper function to get the current request's user
|
|
12
|
-
export function atxpAccountId() {
|
|
13
|
-
const context = contextStorage.getStore();
|
|
14
|
-
return context?.tokenData?.sub ?? null;
|
|
15
|
-
}
|
|
16
|
-
// Helper function to run code within a user context
|
|
17
|
-
export async function withATXPContext(config, resource, tokenInfo, next) {
|
|
18
|
-
config.logger.debug(`Setting user context to ${tokenInfo?.data?.sub ?? 'null'}`);
|
|
19
|
-
if (tokenInfo && tokenInfo.data?.sub) {
|
|
20
|
-
if (tokenInfo.token) {
|
|
21
|
-
const dbData = {
|
|
22
|
-
accessToken: tokenInfo.token,
|
|
23
|
-
resourceUrl: ''
|
|
24
|
-
};
|
|
25
|
-
// Save the token to the oAuthDB so that other users of the DB can access it
|
|
26
|
-
// if needed (ie, for token-exchange for downstream services)
|
|
27
|
-
await config.oAuthDb.saveAccessToken(tokenInfo.data.sub, '', dbData);
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
config.logger.warn(`Setting user context with token data, but there was no token provided. This probably indicates a bug, since the data should be derived from the token`);
|
|
31
|
-
config.logger.debug(`Token data: ${JSON.stringify(tokenInfo.data)}`);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
const ctx = {
|
|
35
|
-
tokenData: tokenInfo?.data || null,
|
|
36
|
-
config,
|
|
37
|
-
resource
|
|
38
|
-
};
|
|
39
|
-
return contextStorage.run(ctx, next);
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=atxpContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"atxpContext.js","sourceRoot":"","sources":["../../src/atxpContext.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,cAAc,GAAG,IAAI,iBAAiB,EAAsB,CAAC;AAQnE,MAAM,UAAU,aAAa;IAC3B,MAAM,OAAO,GAAG,cAAc,CAAC,QAAQ,EAAE,CAAC;IAC1C,OAAO,OAAO,EAAE,MAAM,IAAI,IAAI,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,MAAM,OAAO,GAAG,cAAc,CAAC,QAAQ,EAAE,CAAC;IAC1C,OAAO,OAAO,EAAE,QAAQ,IAAI,IAAI,CAAC;AACnC,CAAC;AAED,oDAAoD;AACpD,MAAM,UAAU,aAAa;IAC3B,MAAM,OAAO,GAAG,cAAc,CAAC,QAAQ,EAAE,CAAC;IAC1C,OAAO,OAAO,EAAE,SAAS,EAAE,GAAG,IAAI,IAAI,CAAC;AACzC,CAAC;AAED,oDAAoD;AACpD,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,MAAkB,EAAE,QAAa,EAAE,SAAoD,EAAE,IAAgB;IAC7I,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,2BAA2B,SAAS,EAAE,IAAI,EAAE,GAAG,IAAI,MAAM,EAAE,CAAC,CAAC;IAEjF,IAAG,SAAS,IAAI,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC;QACpC,IAAG,SAAS,CAAC,KAAK,EAAE,CAAC;YACnB,MAAM,MAAM,GAAG;gBACb,WAAW,EAAE,SAAS,CAAC,KAAM;gBAC7B,WAAW,EAAE,EAAE;aAChB,CAAC;YACF,4EAA4E;YAC5E,6DAA6D;YAC7D,MAAM,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;QACvE,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,uJAAuJ,CAAC,CAAC;YAC5K,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;IAED,MAAM,GAAG,GAAG;QACV,SAAS,EAAE,SAAS,EAAE,IAAI,IAAI,IAAI;QAClC,MAAM;QACN,QAAQ;KACT,CAAC;IACF,OAAO,cAAc,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AACvC,CAAC"}
|
package/dist/src/atxpServer.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ATXPConfig } from "./types.js";
|
|
2
|
-
import { Router } from "express";
|
|
3
|
-
type RequiredATXPConfigFields = 'destination';
|
|
4
|
-
type RequiredATXPConfig = Pick<ATXPConfig, RequiredATXPConfigFields>;
|
|
5
|
-
type OptionalATXPConfig = Omit<ATXPConfig, RequiredATXPConfigFields>;
|
|
6
|
-
export type ATXPArgs = RequiredATXPConfig & Partial<OptionalATXPConfig>;
|
|
7
|
-
type BuildableATXPConfigFields = 'oAuthDb' | 'oAuthClient' | 'paymentServer' | 'logger';
|
|
8
|
-
export declare const DEFAULT_CONFIG: Required<Omit<OptionalATXPConfig, BuildableATXPConfigFields>>;
|
|
9
|
-
export declare function buildServerConfig(args: ATXPArgs): ATXPConfig;
|
|
10
|
-
export declare function atxpServer(args: ATXPArgs): Router;
|
|
11
|
-
export {};
|
|
12
|
-
//# sourceMappingURL=atxpServer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"atxpServer.d.ts","sourceRoot":"","sources":["../../src/atxpServer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAiB,MAAM,YAAY,CAAC;AAKvD,OAAO,EAAmC,MAAM,EAAE,MAAM,SAAS,CAAC;AAMlE,KAAK,wBAAwB,GAAG,aAAa,CAAC;AAC9C,KAAK,kBAAkB,GAAG,IAAI,CAAC,UAAU,EAAE,wBAAwB,CAAC,CAAC;AACrE,KAAK,kBAAkB,GAAG,IAAI,CAAC,UAAU,EAAE,wBAAwB,CAAC,CAAC;AACrE,MAAM,MAAM,QAAQ,GAAG,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AACxE,KAAK,yBAAyB,GAAG,SAAS,GAAG,aAAa,GAAG,eAAe,GAAG,QAAQ,CAAC;AAExF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,IAAI,CAAC,kBAAkB,EAAE,yBAAyB,CAAC,CASxF,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,QAAQ,GAAG,UAAU,CAwB5D;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAyDjD"}
|
package/dist/src/atxpServer.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { ConsoleLogger, OAuthResourceClient, DEFAULT_AUTHORIZATION_SERVER, MemoryOAuthDb } from "@longrun/atxp-common";
|
|
2
|
-
import { checkToken } from "./token.js";
|
|
3
|
-
import { sendOAuthChallenge } from "./oAuthChallenge.js";
|
|
4
|
-
import { withATXPContext } from "./atxpContext.js";
|
|
5
|
-
import { parseMcpRequests } from "./http.js";
|
|
6
|
-
import { Router } from "express";
|
|
7
|
-
import { getProtectedResourceMetadata as getPRMResponse, sendProtectedResourceMetadata } from "./protectedResourceMetadata.js";
|
|
8
|
-
import { getResource } from "./getResource.js";
|
|
9
|
-
import { ATXPPaymentServer } from "./paymentServer.js";
|
|
10
|
-
import { getOAuthMetadata, sendOAuthMetadata } from "./oAuthMetadata.js";
|
|
11
|
-
export const DEFAULT_CONFIG = {
|
|
12
|
-
mountPath: '/',
|
|
13
|
-
currency: 'USDC',
|
|
14
|
-
network: 'solana',
|
|
15
|
-
server: DEFAULT_AUTHORIZATION_SERVER,
|
|
16
|
-
atxpAuthClientToken: process.env.ATXP_AUTH_CLIENT_TOKEN,
|
|
17
|
-
payeeName: 'An ATXP Server',
|
|
18
|
-
allowHttp: process.env.NODE_ENV === 'development',
|
|
19
|
-
resource: null, // Set dynamically from the request URL
|
|
20
|
-
};
|
|
21
|
-
export function buildServerConfig(args) {
|
|
22
|
-
if (!args.destination) {
|
|
23
|
-
throw new Error('destination is required');
|
|
24
|
-
}
|
|
25
|
-
const withDefaults = { ...DEFAULT_CONFIG, ...args };
|
|
26
|
-
const oAuthDb = withDefaults.oAuthDb ?? new MemoryOAuthDb();
|
|
27
|
-
const oAuthClient = withDefaults.oAuthClient ?? new OAuthResourceClient({
|
|
28
|
-
db: oAuthDb,
|
|
29
|
-
allowInsecureRequests: withDefaults.allowHttp,
|
|
30
|
-
clientName: withDefaults.payeeName,
|
|
31
|
-
});
|
|
32
|
-
const logger = withDefaults.logger ?? new ConsoleLogger();
|
|
33
|
-
let paymentServer;
|
|
34
|
-
if (withDefaults.paymentServer) {
|
|
35
|
-
paymentServer = withDefaults.paymentServer;
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
if (!withDefaults.atxpAuthClientToken) {
|
|
39
|
-
throw new Error('ATXP_AUTH_CLIENT_TOKEN is not set. If no payment server is provided, you must set ATXP_AUTH_CLIENT_TOKEN.');
|
|
40
|
-
}
|
|
41
|
-
paymentServer = new ATXPPaymentServer(withDefaults.server, withDefaults.atxpAuthClientToken, logger);
|
|
42
|
-
}
|
|
43
|
-
const built = { oAuthDb, oAuthClient, paymentServer, logger };
|
|
44
|
-
return Object.freeze({ ...withDefaults, ...built });
|
|
45
|
-
}
|
|
46
|
-
;
|
|
47
|
-
export function atxpServer(args) {
|
|
48
|
-
const config = buildServerConfig(args);
|
|
49
|
-
const router = Router();
|
|
50
|
-
// Regular middleware
|
|
51
|
-
const atxpMiddleware = async (req, res, next) => {
|
|
52
|
-
try {
|
|
53
|
-
const logger = config.logger; // Capture logger in closure
|
|
54
|
-
const requestUrl = new URL(req.url, req.protocol + '://' + req.host);
|
|
55
|
-
logger.debug(`Handling ${req.method} ${requestUrl.toString()}`);
|
|
56
|
-
const resource = getResource(config, requestUrl);
|
|
57
|
-
const prmResponse = getPRMResponse(config, requestUrl);
|
|
58
|
-
if (sendProtectedResourceMetadata(res, prmResponse)) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
// Some older clients don't use PRM and assume the MCP server is an OAuth server
|
|
62
|
-
const oAuthMetadata = await getOAuthMetadata(config, requestUrl);
|
|
63
|
-
if (sendOAuthMetadata(res, oAuthMetadata)) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
const mcpRequests = await parseMcpRequests(config, requestUrl, req, req.body);
|
|
67
|
-
logger.debug(`${mcpRequests.length} MCP requests found in request`);
|
|
68
|
-
if (mcpRequests.length === 0) {
|
|
69
|
-
next();
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
logger.debug(`Request started - ${req.method} ${req.path}`);
|
|
73
|
-
const tokenCheck = await checkToken(config, resource, req);
|
|
74
|
-
const user = tokenCheck.data?.sub ?? null;
|
|
75
|
-
// Listen for when the response is finished
|
|
76
|
-
res.on('finish', async () => {
|
|
77
|
-
logger.debug(`Request finished ${user ? `for user ${user} ` : ''}- ${req.method} ${req.path}`);
|
|
78
|
-
});
|
|
79
|
-
// Send the oauth challenge, if needed. If we do, we're done
|
|
80
|
-
if (sendOAuthChallenge(res, tokenCheck)) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
return withATXPContext(config, resource, tokenCheck, next);
|
|
84
|
-
}
|
|
85
|
-
catch (error) {
|
|
86
|
-
config.logger.error(`Critical error in atxp middleware - returning HTTP 500. Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
87
|
-
config.logger.debug(JSON.stringify(error, null, 2));
|
|
88
|
-
res.status(500).json({ error: 'server_error', error_description: 'An internal server error occurred' });
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
// Add middleware to the router
|
|
92
|
-
router.use(atxpMiddleware);
|
|
93
|
-
return router;
|
|
94
|
-
}
|
|
95
|
-
//# sourceMappingURL=atxpServer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"atxpServer.js","sourceRoot":"","sources":["../../src/atxpServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,4BAA4B,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAEvH,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAmC,MAAM,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,4BAA4B,IAAI,cAAc,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAC/H,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,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AC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YACpD,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,mCAAmC,EAAE,CAAC,CAAC;QAC1G,CAAC;IACH,CAAC,CAAC;IAEF,+BAA+B;IAC/B,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAE3B,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getResource.d.ts","sourceRoot":"","sources":["../../src/getResource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,wBAAgB,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAGxC;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,GAAG,GAAG,CAapE"}
|
package/dist/src/getResource.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export function getPath(url) {
|
|
2
|
-
const fullPath = url.pathname.replace(/^\/$/, '');
|
|
3
|
-
return fullPath;
|
|
4
|
-
}
|
|
5
|
-
export function getResource(config, requestUrl) {
|
|
6
|
-
if (config.resource) {
|
|
7
|
-
return new URL(config.resource);
|
|
8
|
-
}
|
|
9
|
-
const protocol = process.env.NODE_ENV === 'development' ? requestUrl.protocol : 'https:';
|
|
10
|
-
const url = new URL(`${protocol}//${requestUrl.host}${requestUrl.pathname}`);
|
|
11
|
-
const fullPath = getPath(url);
|
|
12
|
-
// If this is a PRM path, convert it into the path for the resource this is the metadata for
|
|
13
|
-
const resourcePath = fullPath.replace('/.well-known/oauth-protected-resource', '').replace(/\/$/, '');
|
|
14
|
-
const resource = new URL(`${protocol}//${requestUrl.host}${resourcePath}`);
|
|
15
|
-
return resource;
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=getResource.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getResource.js","sourceRoot":"","sources":["../../src/getResource.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,OAAO,CAAC,GAAQ;IAC9B,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAClD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,MAAkB,EAAE,UAAe;IAC7D,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpB,OAAO,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAClC,CAAC;IACD,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC;IACzF,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,QAAQ,KAAK,UAAU,CAAC,IAAI,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC;IAE7E,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAC9B,4FAA4F;IAC5F,MAAM,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC,uCAAuC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAEtG,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,GAAG,QAAQ,KAAK,UAAU,CAAC,IAAI,GAAG,YAAY,EAAE,CAAC,CAAC;IAC3E,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/dist/src/http.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { IncomingMessage } from "node:http";
|
|
2
|
-
import { JSONRPCRequest } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
-
import { ATXPConfig } from "./types.js";
|
|
4
|
-
import { Logger } from "@longrun/atxp-common";
|
|
5
|
-
export declare function parseMcpRequests(config: ATXPConfig, requestUrl: URL, req: IncomingMessage, parsedBody?: unknown): Promise<JSONRPCRequest[]>;
|
|
6
|
-
export declare function parseBody(req: IncomingMessage, logger: Logger): Promise<unknown>;
|
|
7
|
-
//# sourceMappingURL=http.d.ts.map
|
package/dist/src/http.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAG5C,OAAO,EAAE,cAAc,EAAoB,MAAM,oCAAoC,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAoB,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAQhE,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,EAAE,eAAe,EAAE,UAAU,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CA0BjJ;AAED,wBAAsB,SAAS,CAAC,GAAG,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAmBtF"}
|
package/dist/src/http.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import getRawBody from "raw-body";
|
|
2
|
-
import contentType from "content-type";
|
|
3
|
-
import { isJSONRPCRequest } from "@modelcontextprotocol/sdk/types.js";
|
|
4
|
-
import { parseMcpMessages } from "@longrun/atxp-common";
|
|
5
|
-
// Useful reference for dealing with low-level http requests:
|
|
6
|
-
// https://github.com/modelcontextprotocol/typescript-sdk/blob/c6ac083b1b37b222b5bfba5563822daa5d03372e/src/server/streamableHttp.ts#L375
|
|
7
|
-
// Using the same value as MCP SDK
|
|
8
|
-
const MAXIMUM_MESSAGE_SIZE = "4mb";
|
|
9
|
-
export async function parseMcpRequests(config, requestUrl, req, parsedBody) {
|
|
10
|
-
if (!req.method) {
|
|
11
|
-
return [];
|
|
12
|
-
}
|
|
13
|
-
if (req.method.toLowerCase() !== 'post') {
|
|
14
|
-
return [];
|
|
15
|
-
}
|
|
16
|
-
// The middleware has to be mounted at the root to serve the protected resource metadata,
|
|
17
|
-
// but the actual MCP server it's controlling is specified by the mountPath.
|
|
18
|
-
const path = requestUrl.pathname.replace(/\/$/, '');
|
|
19
|
-
const mountPath = config.mountPath.replace(/\/$/, '');
|
|
20
|
-
if (path !== mountPath && path !== `${mountPath}/message`) {
|
|
21
|
-
config.logger.debug(`Request path (${path}) does not match the mountPath (${mountPath}), skipping MCP middleware`);
|
|
22
|
-
return [];
|
|
23
|
-
}
|
|
24
|
-
parsedBody = parsedBody ?? await parseBody(req, config.logger);
|
|
25
|
-
const messages = await parseMcpMessages(parsedBody, config.logger);
|
|
26
|
-
const requests = messages.filter(msg => isJSONRPCRequest(msg));
|
|
27
|
-
if (requests.length !== messages.length) {
|
|
28
|
-
config.logger.debug(`Dropped ${messages.length - requests.length} MCP messages that were not MCP requests`);
|
|
29
|
-
}
|
|
30
|
-
return requests;
|
|
31
|
-
}
|
|
32
|
-
export async function parseBody(req, logger) {
|
|
33
|
-
try {
|
|
34
|
-
const ct = req.headers["content-type"];
|
|
35
|
-
let encoding = "utf-8";
|
|
36
|
-
if (ct) {
|
|
37
|
-
const parsedCt = contentType.parse(ct);
|
|
38
|
-
encoding = parsedCt.parameters.charset ?? "utf-8";
|
|
39
|
-
}
|
|
40
|
-
const body = await getRawBody(req, {
|
|
41
|
-
limit: MAXIMUM_MESSAGE_SIZE,
|
|
42
|
-
encoding,
|
|
43
|
-
});
|
|
44
|
-
return JSON.parse(body.toString());
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
logger.error(error.message);
|
|
48
|
-
return undefined;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
//# sour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cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC"}
|
package/dist/src/index.js
DELETED
package/dist/src/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"oAuthChallenge.d.ts","sourceRoot":"","sources":["../../src/oAuthChallenge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,EAAE,UAAU,EAAgB,MAAM,YAAY,CAAC;AAGtD,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO,CAsCvF"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { TokenProblem } from "./types.js";
|
|
2
|
-
import { assertNever } from "@longrun/atxp-common";
|
|
3
|
-
export function sendOAuthChallenge(res, tokenCheck) {
|
|
4
|
-
if (tokenCheck.passes) {
|
|
5
|
-
return false;
|
|
6
|
-
}
|
|
7
|
-
let status = 401;
|
|
8
|
-
let body = {};
|
|
9
|
-
// https://datatracker.ietf.org/doc/html/rfc6750#section-3.1
|
|
10
|
-
switch (tokenCheck.problem) {
|
|
11
|
-
case TokenProblem.NO_TOKEN:
|
|
12
|
-
break;
|
|
13
|
-
case TokenProblem.NON_BEARER_AUTH_HEADER:
|
|
14
|
-
status = 400;
|
|
15
|
-
body = { error: 'invalid_request', error_description: 'Authorization header did not include a Bearer token' };
|
|
16
|
-
break;
|
|
17
|
-
case TokenProblem.INVALID_TOKEN:
|
|
18
|
-
body = { error: 'invalid_token', error_description: 'Token is not active' };
|
|
19
|
-
break;
|
|
20
|
-
case TokenProblem.INVALID_AUDIENCE:
|
|
21
|
-
body = { error: 'invalid_token', error_description: 'Token is does not match the expected audience' };
|
|
22
|
-
break;
|
|
23
|
-
case TokenProblem.NON_SUFFICIENT_FUNDS:
|
|
24
|
-
status = 403;
|
|
25
|
-
body = { error: 'insufficient_scope', error_description: 'Non sufficient funds' };
|
|
26
|
-
break;
|
|
27
|
-
case TokenProblem.INTROSPECT_ERROR:
|
|
28
|
-
status = 502;
|
|
29
|
-
body = { error: 'server_error', error_description: 'An internal server error occurred' };
|
|
30
|
-
break;
|
|
31
|
-
default:
|
|
32
|
-
assertNever(tokenCheck.problem);
|
|
33
|
-
}
|
|
34
|
-
res.setHeader('WWW-Authenticate', `Bearer resource_metadata="${tokenCheck.resourceMetadataUrl}"`);
|
|
35
|
-
res.writeHead(status);
|
|
36
|
-
res.end(JSON.stringify(body));
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=oAuthChallenge.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"oAuthChallenge.js","sourceRoot":"","sources":["../../src/oAuthChallenge.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,YAAY,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,MAAM,UAAU,kBAAkB,CAAC,GAAmB,EAAE,UAAsB;IAC5E,IAAI,UAAU,CAAC,MAAM,EAAE,CAAC;QACtB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,MAAM,GAAG,GAAG,CAAC;IACjB,IAAI,IAAI,GAAkE,EAAE,CAAC;IAC7E,4DAA4D;IAC5D,QAAQ,UAAU,CAAC,OAAO,EAAE,CAAC;QAC3B,KAAK,YAAY,CAAC,QAAQ;YACxB,MAAM;QACR,KAAK,YAAY,CAAC,sBAAsB;YACtC,MAAM,GAAG,GAAG,CAAC;YACb,IAAI,GAAG,EAAE,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,qDAAqD,EAAE,CAAC;YAC9G,MAAM;QACR,KAAK,YAAY,CAAC,aAAa;YAC7B,IAAI,GAAG,EAAE,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,CAAC;YAC5E,MAAM;QACR,KAAK,YAAY,CAAC,gBAAgB;YAChC,IAAI,GAAG,EAAE,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,+CAA+C,EAAE,CAAC;YACtG,MAAM;QACR,KAAK,YAAY,CAAC,oBAAoB;YACpC,MAAM,GAAG,GAAG,CAAC;YACb,IAAI,GAAG,EAAE,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,CAAC;YAClF,MAAM;QACR,KAAK,YAAY,CAAC,gBAAgB;YAChC,MAAM,GAAG,GAAG,CAAC;YACb,IAAI,GAAG,EAAE,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,mCAAmC,EAAE,CAAC;YACzF,MAAM;QACR;YACE,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED,GAAG,CAAC,SAAS,CAAC,kBAAkB,EAAE,6BAA6B,UAAU,CAAC,mBAAmB,GAAG,CAAC,CAAC;IAClG,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACtB,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IAE9B,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ATXPConfig } from "./types.js";
|
|
2
|
-
import * as oauth from 'oauth4webapi';
|
|
3
|
-
import { ServerResponse } from "http";
|
|
4
|
-
export declare function sendOAuthMetadata(res: ServerResponse, metadata: oauth.AuthorizationServer | null): boolean;
|
|
5
|
-
export declare function getOAuthMetadata(config: ATXPConfig, requestUrl: URL): Promise<oauth.AuthorizationServer | null>;
|
|
6
|
-
//# sourceMappingURL=oAuthMetadata.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"oAuthMetadata.d.ts","sourceRoot":"","sources":["../../src/oAuthMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAGtC,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,cAAc,EAAE,QAAQ,EAAE,KAAK,CAAC,mBAAmB,GAAG,IAAI,GAAG,OAAO,CAQ1G;AAED,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAyBrH"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { getPath } from "./getResource.js";
|
|
2
|
-
export function sendOAuthMetadata(res, metadata) {
|
|
3
|
-
if (!metadata) {
|
|
4
|
-
return false;
|
|
5
|
-
}
|
|
6
|
-
res.setHeader('Content-Type', 'application/json');
|
|
7
|
-
res.writeHead(200);
|
|
8
|
-
res.end(JSON.stringify(metadata));
|
|
9
|
-
return true;
|
|
10
|
-
}
|
|
11
|
-
export async function getOAuthMetadata(config, requestUrl) {
|
|
12
|
-
if (isOAuthMetadataRequest(config, requestUrl)) {
|
|
13
|
-
try {
|
|
14
|
-
const authServer = await config.oAuthClient.authorizationServerFromUrl(new URL(config.server));
|
|
15
|
-
return {
|
|
16
|
-
issuer: config.server,
|
|
17
|
-
authorization_endpoint: authServer.authorization_endpoint,
|
|
18
|
-
response_types_supported: authServer.response_types_supported,
|
|
19
|
-
grant_types_supported: authServer.grant_types_supported,
|
|
20
|
-
token_endpoint: authServer.token_endpoint,
|
|
21
|
-
token_endpoint_auth_methods_supported: authServer.token_endpoint_auth_methods_supported,
|
|
22
|
-
registration_endpoint: authServer.registration_endpoint,
|
|
23
|
-
revocation_endpoint: authServer.revocation_endpoint,
|
|
24
|
-
introspection_endpoint: authServer.introspection_endpoint,
|
|
25
|
-
introspection_endpoint_auth_methods_supported: authServer.introspection_endpoint_auth_methods_supported,
|
|
26
|
-
code_challenge_methods_supported: authServer.code_challenge_methods_supported,
|
|
27
|
-
scopes_supported: authServer.scopes_supported
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
catch (error) {
|
|
31
|
-
config.logger.error(`Error fetching authorization server configuration from ${config.server}: ${error}`);
|
|
32
|
-
throw error;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
function isOAuthMetadataRequest(config, requestUrl) {
|
|
38
|
-
const path = getPath(requestUrl).replace(/\/$/, '');
|
|
39
|
-
return path === '/.well-known/oauth-authorization-server';
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=oAuthMetadata.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"oAuthMetadata.js","sourceRoot":"","sources":["../../src/oAuthMetadata.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,MAAM,UAAU,iBAAiB,CAAC,GAAmB,EAAE,QAA0C;IAC/F,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,KAAK,CAAC;IACf,CAAC;IACD,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;IAClD,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IACnB,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;IAClC,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,MAAkB,EAAE,UAAe;IACxE,IAAI,sBAAsB,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,CAAC;QAC/C,IAAI,CAAC;YACH,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,0BAA0B,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;YAE/F,OAAO;gBACL,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,sBAAsB,EAAE,UAAU,CAAC,sBAAsB;gBACzD,wBAAwB,EAAE,UAAU,CAAC,wBAAwB;gBAC7D,qBAAqB,EAAE,UAAU,CAAC,qBAAqB;gBACvD,cAAc,EAAE,UAAU,CAAC,cAAc;gBACzC,qCAAqC,EAAE,UAAU,CAAC,qCAAqC;gBACvF,qBAAqB,EAAE,UAAU,CAAC,qBAAqB;gBACvD,mBAAmB,EAAE,UAAU,CAAC,mBAAmB;gBACnD,sBAAsB,EAAE,UAAU,CAAC,sBAAsB;gBACzD,6CAA6C,EAAE,UAAU,CAAC,6CAA6C;gBACvG,gCAAgC,EAAE,UAAU,CAAC,gCAAgC;gBAC7E,gBAAgB,EAAE,UAAU,CAAC,gBAAgB;aAC9C,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,0DAA0D,MAAM,CAAC,MAAM,KAAK,KAAK,EAAE,CAAC,CAAC;YACzG,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,sBAAsB,CAAC,MAAkB,EAAE,UAAe;IACjE,MAAM,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACpD,OAAO,IAAI,KAAK,yCAAyC,CAAC;AAC5D,CAAC"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { PaymentServer, ChargeResponse } from "./types.js";
|
|
2
|
-
import { Network, Currency, AuthorizationServerUrl, FetchLike, Logger } from "@longrun/atxp-common";
|
|
3
|
-
import BigNumber from "bignumber.js";
|
|
4
|
-
/**
|
|
5
|
-
* ATXP Payment Server implementation
|
|
6
|
-
*
|
|
7
|
-
* This class handles payment operations with the ATXP authorization server.
|
|
8
|
-
*
|
|
9
|
-
* **Required Environment Variable:**
|
|
10
|
-
* - `ATXP_AUTH_CLIENT_TOKEN`: Authentication token for the ATXP authorization server.
|
|
11
|
-
* This token is used to authenticate API calls to the ATXP server for payment operations.
|
|
12
|
-
* Must be set when using this class, otherwise an error will be thrown.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```typescript
|
|
16
|
-
* // Ensure ATXP_AUTH_CLIENT_TOKEN is set in your environment
|
|
17
|
-
* const paymentServer = new ATXPPaymentServer(
|
|
18
|
-
* 'https://auth.atxp.ai',
|
|
19
|
-
* oAuthDb,
|
|
20
|
-
* logger
|
|
21
|
-
* );
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
export declare class ATXPPaymentServer implements PaymentServer {
|
|
25
|
-
private readonly server;
|
|
26
|
-
private readonly authCredentials;
|
|
27
|
-
private readonly logger;
|
|
28
|
-
private readonly fetchFn;
|
|
29
|
-
constructor(server: AuthorizationServerUrl, authCredentials: string, logger: Logger, fetchFn?: FetchLike);
|
|
30
|
-
charge: ({ source, destination, network, currency, amount }: {
|
|
31
|
-
source: string;
|
|
32
|
-
destination: string;
|
|
33
|
-
network: Network;
|
|
34
|
-
currency: Currency;
|
|
35
|
-
amount: BigNumber;
|
|
36
|
-
}) => Promise<ChargeResponse>;
|
|
37
|
-
createPaymentRequest: ({ source, destination, network, currency, amount }: {
|
|
38
|
-
source: string;
|
|
39
|
-
destination: string;
|
|
40
|
-
network: Network;
|
|
41
|
-
currency: Currency;
|
|
42
|
-
amount: BigNumber;
|
|
43
|
-
}) => Promise<string>;
|
|
44
|
-
/**
|
|
45
|
-
* Makes authenticated requests to the ATXP authorization server
|
|
46
|
-
*
|
|
47
|
-
* This method automatically includes the `ATXP_AUTH_CLIENT_TOKEN` from environment variables
|
|
48
|
-
* in the Authorization header for all requests.
|
|
49
|
-
*
|
|
50
|
-
* @param method - HTTP method ('GET' or 'POST')
|
|
51
|
-
* @param path - API endpoint path
|
|
52
|
-
* @param body - Request body (for POST requests)
|
|
53
|
-
* @returns Promise<Response> - The HTTP response from the server
|
|
54
|
-
* @throws {Error} When `ATXP_AUTH_CLIENT_TOKEN` environment variable is not set
|
|
55
|
-
*
|
|
56
|
-
* @example
|
|
57
|
-
* ```typescript
|
|
58
|
-
* // Ensure ATXP_AUTH_CLIENT_TOKEN is set in your environment
|
|
59
|
-
* const response = await paymentServer.makeRequest('POST', '/charge', {
|
|
60
|
-
* source: 'user123',
|
|
61
|
-
* destination: 'merchant456',
|
|
62
|
-
* amount: new BigNumber('0.01')
|
|
63
|
-
* });
|
|
64
|
-
* ```
|
|
65
|
-
*/
|
|
66
|
-
protected makeRequest: (method: "GET" | "POST", path: string, body: unknown) => Promise<Response>;
|
|
67
|
-
}
|
|
68
|
-
//# sourceMappingURL=paymentServer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"paymentServer.d.ts","sourceRoot":"","sources":["../../src/paymentServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,sBAAsB,EAAE,SAAS,EAAE,MAAM,EAAsB,MAAM,sBAAsB,CAAC;AACxH,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,iBAAkB,YAAW,aAAa;IAEnD,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAHP,MAAM,EAAE,sBAAsB,EAC9B,eAAe,EAAE,MAAM,EACvB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,SAAiB;IAM7C,MAAM,GAAS,oDACb;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,QAAQ,CAAC;QAAC,MAAM,EAAE,SAAS,CAAA;KAAC,KAAG,OAAO,CAAC,cAAc,CAAC,CAczH;IAED,oBAAoB,GAAS,oDAC3B;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,QAAQ,CAAC;QAAC,MAAM,EAAE,SAAS,CAAA;KAAC,KAAG,OAAO,CAAC,MAAM,CAAC,CAajH;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,SAAS,CAAC,WAAW,GAAS,QAAQ,KAAK,GAAG,MAAM,EAAE,MAAM,MAAM,EAAE,MAAM,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC,CAWpG;CACF"}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ATXP Payment Server implementation
|
|
3
|
-
*
|
|
4
|
-
* This class handles payment operations with the ATXP authorization server.
|
|
5
|
-
*
|
|
6
|
-
* **Required Environment Variable:**
|
|
7
|
-
* - `ATXP_AUTH_CLIENT_TOKEN`: Authentication token for the ATXP authorization server.
|
|
8
|
-
* This token is used to authenticate API calls to the ATXP server for payment operations.
|
|
9
|
-
* Must be set when using this class, otherwise an error will be thrown.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* // Ensure ATXP_AUTH_CLIENT_TOKEN is set in your environment
|
|
14
|
-
* const paymentServer = new ATXPPaymentServer(
|
|
15
|
-
* 'https://auth.atxp.ai',
|
|
16
|
-
* oAuthDb,
|
|
17
|
-
* logger
|
|
18
|
-
* );
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
export class ATXPPaymentServer {
|
|
22
|
-
constructor(server, authCredentials, logger, fetchFn = fetch) {
|
|
23
|
-
this.server = server;
|
|
24
|
-
this.authCredentials = authCredentials;
|
|
25
|
-
this.logger = logger;
|
|
26
|
-
this.fetchFn = fetchFn;
|
|
27
|
-
this.charge = async ({ source, destination, network, currency, amount }) => {
|
|
28
|
-
const body = { source, destination, network, currency, amount };
|
|
29
|
-
const chargeResponse = await this.makeRequest('POST', '/charge', body);
|
|
30
|
-
const json = await chargeResponse.json();
|
|
31
|
-
if (chargeResponse.status === 200) {
|
|
32
|
-
return { success: true, requiredPayment: null };
|
|
33
|
-
}
|
|
34
|
-
else if (chargeResponse.status === 402) {
|
|
35
|
-
return { success: false, requiredPayment: json };
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
const msg = `Unexpected status code ${chargeResponse.status} from payment server POST /charge endpoint`;
|
|
39
|
-
this.logger.warn(msg);
|
|
40
|
-
this.logger.debug(`Response body: ${JSON.stringify(json)}`);
|
|
41
|
-
throw new Error(msg);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
this.createPaymentRequest = async ({ source, destination, network, currency, amount }) => {
|
|
45
|
-
const body = { source, destination, network, currency, amount };
|
|
46
|
-
const response = await this.makeRequest('POST', '/payment-request', body);
|
|
47
|
-
const json = await response.json();
|
|
48
|
-
if (response.status !== 200) {
|
|
49
|
-
this.logger.warn(`POST /payment-request responded with unexpected HTTP status ${response.status}`);
|
|
50
|
-
this.logger.debug(`Response body: ${JSON.stringify(json)}`);
|
|
51
|
-
throw new Error(`POST /payment-request responded with unexpected HTTP status ${response.status}`);
|
|
52
|
-
}
|
|
53
|
-
if (!json.id) {
|
|
54
|
-
throw new Error(`POST /payment-request response did not contain an id`);
|
|
55
|
-
}
|
|
56
|
-
return json.id;
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Makes authenticated requests to the ATXP authorization server
|
|
60
|
-
*
|
|
61
|
-
* This method automatically includes the `ATXP_AUTH_CLIENT_TOKEN` from environment variables
|
|
62
|
-
* in the Authorization header for all requests.
|
|
63
|
-
*
|
|
64
|
-
* @param method - HTTP method ('GET' or 'POST')
|
|
65
|
-
* @param path - API endpoint path
|
|
66
|
-
* @param body - Request body (for POST requests)
|
|
67
|
-
* @returns Promise<Response> - The HTTP response from the server
|
|
68
|
-
* @throws {Error} When `ATXP_AUTH_CLIENT_TOKEN` environment variable is not set
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* ```typescript
|
|
72
|
-
* // Ensure ATXP_AUTH_CLIENT_TOKEN is set in your environment
|
|
73
|
-
* const response = await paymentServer.makeRequest('POST', '/charge', {
|
|
74
|
-
* source: 'user123',
|
|
75
|
-
* destination: 'merchant456',
|
|
76
|
-
* amount: new BigNumber('0.01')
|
|
77
|
-
* });
|
|
78
|
-
* ```
|
|
79
|
-
*/
|
|
80
|
-
this.makeRequest = async (method, path, body) => {
|
|
81
|
-
const url = new URL(path, this.server);
|
|
82
|
-
const response = await this.fetchFn(url, {
|
|
83
|
-
method,
|
|
84
|
-
headers: {
|
|
85
|
-
'Authorization': `Bearer ${this.authCredentials}`,
|
|
86
|
-
'Content-Type': 'application/json'
|
|
87
|
-
},
|
|
88
|
-
body: JSON.stringify(body)
|
|
89
|
-
});
|
|
90
|
-
return response;
|
|
91
|
-
};
|
|
92
|
-
if (!authCredentials || authCredentials.trim() === '') {
|
|
93
|
-
throw new Error('Auth credentials are required');
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
//# sourceMappingURL=paymentServer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"paymentServer.js","sourceRoot":"","sources":["../../src/paymentServer.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO,iBAAiB;IAC5B,YACmB,MAA8B,EAC9B,eAAuB,EACvB,MAAc,EACd,UAAqB,KAAK;QAH1B,WAAM,GAAN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IAAI,CAAC,eAAe,IAAI,eAAe,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACtD,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;CAqEF"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { ATXPConfig, ProtectedResourceMetadata } from "./types.js";
|
|
2
|
-
import { ServerResponse } from "http";
|
|
3
|
-
export declare function sendProtectedResourceMetadata(res: ServerResponse, metadata: ProtectedResourceMetadata | null): boolean;
|
|
4
|
-
export declare function getProtectedResourceMetadata(config: ATXPConfig, requestUrl: URL): ProtectedResourceMetadata | null;
|
|
5
|
-
//# sourceMappingURL=protectedResourceMetadata.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"protectedResourceMetadata.d.ts","sourceRoot":"","sources":["../../src/protectedResourceMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAGtC,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,cAAc,EAAE,QAAQ,EAAE,yBAAyB,GAAG,IAAI,GAAG,OAAO,CAQtH;AAED,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,GAAG,yBAAyB,GAAG,IAAI,CAYlH"}
|