@atxp/server 0.2.22 → 0.3.0
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/_virtual/_commonjsHelpers.js +8 -0
- package/dist/_virtual/_commonjsHelpers.js.map +1 -0
- package/dist/_virtual/bom-handling.js +4 -0
- package/dist/_virtual/bom-handling.js.map +1 -0
- package/dist/_virtual/dbcs-codec.js +4 -0
- package/dist/_virtual/dbcs-codec.js.map +1 -0
- package/dist/_virtual/index.js +8 -0
- package/dist/_virtual/index.js.map +1 -0
- package/dist/_virtual/index2.js +4 -0
- package/dist/_virtual/index2.js.map +1 -0
- package/dist/_virtual/index3.js +4 -0
- package/dist/_virtual/index3.js.map +1 -0
- package/dist/_virtual/index4.js +4 -0
- package/dist/_virtual/index4.js.map +1 -0
- package/dist/_virtual/index5.js +4 -0
- package/dist/_virtual/index5.js.map +1 -0
- package/dist/_virtual/inherits.js +4 -0
- package/dist/_virtual/inherits.js.map +1 -0
- package/dist/_virtual/inherits_browser.js +4 -0
- package/dist/_virtual/inherits_browser.js.map +1 -0
- package/dist/_virtual/sbcs-codec.js +4 -0
- package/dist/_virtual/sbcs-codec.js.map +1 -0
- package/dist/_virtual/utf16.js +4 -0
- package/dist/_virtual/utf16.js.map +1 -0
- package/dist/_virtual/utf32.js +4 -0
- package/dist/_virtual/utf32.js.map +1 -0
- package/dist/_virtual/utf7.js +4 -0
- package/dist/_virtual/utf7.js.map +1 -0
- package/dist/atxpContext.js +9 -6
- package/dist/atxpContext.js.map +1 -1
- package/dist/atxpServer.js +19 -27
- package/dist/atxpServer.js.map +1 -1
- package/dist/core/mcp.js +39 -0
- package/dist/core/mcp.js.map +1 -0
- package/dist/{oAuthChallenge.js → core/oauth.js} +21 -12
- package/dist/core/oauth.js.map +1 -0
- package/dist/{token.js → core/token.js} +13 -7
- package/dist/core/token.js.map +1 -0
- package/dist/getResource.js +5 -3
- package/dist/getResource.js.map +1 -1
- package/dist/index.cjs +13727 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +141 -5
- package/dist/index.js +13708 -5
- package/dist/index.js.map +1 -1
- package/dist/{http.js → node/http.js} +21 -20
- package/dist/node/http.js.map +1 -0
- package/dist/node/oauth.js +23 -0
- package/dist/node/oauth.js.map +1 -0
- package/dist/node/token.js +15 -0
- package/dist/node/token.js.map +1 -0
- package/dist/node_modules/bytes/index.js +181 -0
- package/dist/node_modules/bytes/index.js.map +1 -0
- package/dist/node_modules/depd/index.js +551 -0
- package/dist/node_modules/depd/index.js.map +1 -0
- package/dist/node_modules/http-errors/index.js +307 -0
- package/dist/node_modules/http-errors/index.js.map +1 -0
- package/dist/node_modules/iconv-lite/encodings/dbcs-codec.js +599 -0
- package/dist/node_modules/iconv-lite/encodings/dbcs-codec.js.map +1 -0
- package/dist/node_modules/iconv-lite/encodings/dbcs-data.js +207 -0
- package/dist/node_modules/iconv-lite/encodings/dbcs-data.js.map +1 -0
- package/dist/node_modules/iconv-lite/encodings/index.js +45 -0
- package/dist/node_modules/iconv-lite/encodings/index.js.map +1 -0
- package/dist/node_modules/iconv-lite/encodings/internal.js +211 -0
- package/dist/node_modules/iconv-lite/encodings/internal.js.map +1 -0
- package/dist/node_modules/iconv-lite/encodings/sbcs-codec.js +84 -0
- package/dist/node_modules/iconv-lite/encodings/sbcs-codec.js.map +1 -0
- package/dist/node_modules/iconv-lite/encodings/sbcs-data-generated.js +461 -0
- package/dist/node_modules/iconv-lite/encodings/sbcs-data-generated.js.map +1 -0
- package/dist/node_modules/iconv-lite/encodings/sbcs-data.js +188 -0
- package/dist/node_modules/iconv-lite/encodings/sbcs-data.js.map +1 -0
- package/dist/node_modules/iconv-lite/encodings/tables/big5-added.json.js +507 -0
- package/dist/node_modules/iconv-lite/encodings/tables/big5-added.json.js.map +1 -0
- package/dist/node_modules/iconv-lite/encodings/tables/cp936.json.js +2622 -0
- package/dist/node_modules/iconv-lite/encodings/tables/cp936.json.js.map +1 -0
- package/dist/node_modules/iconv-lite/encodings/tables/cp949.json.js +2381 -0
- package/dist/node_modules/iconv-lite/encodings/tables/cp949.json.js.map +1 -0
- package/dist/node_modules/iconv-lite/encodings/tables/cp950.json.js +730 -0
- package/dist/node_modules/iconv-lite/encodings/tables/cp950.json.js.map +1 -0
- package/dist/node_modules/iconv-lite/encodings/tables/eucjp.json.js +823 -0
- package/dist/node_modules/iconv-lite/encodings/tables/eucjp.json.js.map +1 -0
- package/dist/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json.js +425 -0
- package/dist/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json.js.map +1 -0
- package/dist/node_modules/iconv-lite/encodings/tables/gbk-added.json.js +265 -0
- package/dist/node_modules/iconv-lite/encodings/tables/gbk-added.json.js.map +1 -0
- package/dist/node_modules/iconv-lite/encodings/tables/shiftjis.json.js +549 -0
- package/dist/node_modules/iconv-lite/encodings/tables/shiftjis.json.js.map +1 -0
- package/dist/node_modules/iconv-lite/encodings/utf16.js +207 -0
- package/dist/node_modules/iconv-lite/encodings/utf16.js.map +1 -0
- package/dist/node_modules/iconv-lite/encodings/utf32.js +330 -0
- package/dist/node_modules/iconv-lite/encodings/utf32.js.map +1 -0
- package/dist/node_modules/iconv-lite/encodings/utf7.js +298 -0
- package/dist/node_modules/iconv-lite/encodings/utf7.js.map +1 -0
- package/dist/node_modules/iconv-lite/lib/bom-handling.js +62 -0
- package/dist/node_modules/iconv-lite/lib/bom-handling.js.map +1 -0
- package/dist/node_modules/iconv-lite/lib/index.js +193 -0
- package/dist/node_modules/iconv-lite/lib/index.js.map +1 -0
- package/dist/node_modules/iconv-lite/lib/streams.js +121 -0
- package/dist/node_modules/iconv-lite/lib/streams.js.map +1 -0
- package/dist/node_modules/inherits/inherits.js +22 -0
- package/dist/node_modules/inherits/inherits.js.map +1 -0
- package/dist/node_modules/inherits/inherits_browser.js +39 -0
- package/dist/node_modules/inherits/inherits_browser.js.map +1 -0
- package/dist/node_modules/raw-body/index.js +352 -0
- package/dist/node_modules/raw-body/index.js.map +1 -0
- package/dist/node_modules/safer-buffer/safer.js +89 -0
- package/dist/node_modules/safer-buffer/safer.js.map +1 -0
- package/dist/node_modules/setprototypeof/index.js +27 -0
- package/dist/node_modules/setprototypeof/index.js.map +1 -0
- package/dist/node_modules/statuses/codes.json.js +68 -0
- package/dist/node_modules/statuses/codes.json.js.map +1 -0
- package/dist/node_modules/statuses/index.js +158 -0
- package/dist/node_modules/statuses/index.js.map +1 -0
- package/dist/node_modules/toidentifier/index.js +42 -0
- package/dist/node_modules/toidentifier/index.js.map +1 -0
- package/dist/node_modules/unpipe/index.js +79 -0
- package/dist/node_modules/unpipe/index.js.map +1 -0
- package/dist/oAuthMetadata.js +7 -4
- package/dist/oAuthMetadata.js.map +1 -1
- package/dist/paymentServer.js +5 -20
- package/dist/paymentServer.js.map +1 -1
- package/dist/protectedResourceMetadata.js +7 -4
- package/dist/protectedResourceMetadata.js.map +1 -1
- package/dist/requirePayment.js +7 -4
- package/dist/requirePayment.js.map +1 -1
- package/dist/types.js +4 -2
- package/dist/types.js.map +1 -1
- package/dist/webapi/mcp.js +25 -0
- package/dist/webapi/mcp.js.map +1 -0
- package/dist/webapi/oauth.js +21 -0
- package/dist/webapi/oauth.js.map +1 -0
- package/dist/webapi/token.js +15 -0
- package/dist/webapi/token.js.map +1 -0
- package/package.json +21 -7
- package/dist/atxpContext.d.ts +0 -6
- package/dist/atxpContext.d.ts.map +0 -1
- package/dist/atxpServer.d.ts +0 -12
- package/dist/atxpServer.d.ts.map +0 -1
- package/dist/getResource.d.ts +0 -4
- package/dist/getResource.d.ts.map +0 -1
- package/dist/http.d.ts +0 -7
- package/dist/http.d.ts.map +0 -1
- package/dist/http.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/oAuthChallenge.d.ts +0 -4
- package/dist/oAuthChallenge.d.ts.map +0 -1
- package/dist/oAuthChallenge.js.map +0 -1
- package/dist/oAuthMetadata.d.ts +0 -6
- package/dist/oAuthMetadata.d.ts.map +0 -1
- package/dist/paymentServer.d.ts +0 -62
- package/dist/paymentServer.d.ts.map +0 -1
- package/dist/protectedResourceMetadata.d.ts +0 -5
- package/dist/protectedResourceMetadata.d.ts.map +0 -1
- package/dist/requirePayment.d.ts +0 -3
- package/dist/requirePayment.d.ts.map +0 -1
- package/dist/serverTestHelpers.d.ts +0 -55
- package/dist/serverTestHelpers.d.ts.map +0 -1
- package/dist/serverTestHelpers.js +0 -88
- package/dist/serverTestHelpers.js.map +0 -1
- package/dist/token.d.ts +0 -4
- package/dist/token.d.ts.map +0 -1
- package/dist/token.js.map +0 -1
- package/dist/types.d.ts +0 -60
- package/dist/types.d.ts.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,141 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { Currency, Network, AuthorizationServerUrl, UrlString, Logger, OAuthDb, OAuthResourceClient, PaymentRequestData, TokenData, RequirePaymentConfig } from '@atxp/common';
|
|
2
|
+
import { Router } from 'express';
|
|
3
|
+
import { IncomingMessage, ServerResponse } from 'http';
|
|
4
|
+
import { IncomingMessage as IncomingMessage$1 } from 'node:http';
|
|
5
|
+
import { JSONRPCRequest } from '@modelcontextprotocol/sdk/types.js';
|
|
6
|
+
|
|
7
|
+
type McpMethod = 'notifications/cancelled' | 'initialize' | 'ping' | 'notifications/progress' | 'resources/list' | 'resources/templates/list' | 'resources/read' | 'notifications/resources/list_changed' | 'resources/subscribe' | 'resources/unsubscribe' | 'notifications/resources/updated' | 'prompts/list' | 'prompts/get' | 'notifications/prompts/list_changed' | 'tools/list' | 'tools/call' | 'notifications/tools/list_changed' | 'logging/setLevel' | 'notifications/message' | 'sampling/createMessage' | 'elicitation/create' | 'completion/complete' | 'roots/list' | 'notifications/roots/list_changed';
|
|
8
|
+
type McpName = string;
|
|
9
|
+
type McpNamePattern = McpName | '*';
|
|
10
|
+
type McpOperation = `${McpMethod}` | `${McpMethod}:${McpName}`;
|
|
11
|
+
type McpOperationPattern = McpOperation | '*' | `${McpMethod}:*`;
|
|
12
|
+
type RefundErrors = boolean | 'nonMcpOnly';
|
|
13
|
+
type Charge = Omit<PaymentRequestData, 'resource' | 'resourceName' | 'iss'>;
|
|
14
|
+
type ChargeResponse = {
|
|
15
|
+
success: boolean;
|
|
16
|
+
requiredPayment: PaymentRequestData | null;
|
|
17
|
+
};
|
|
18
|
+
type PaymentServer = {
|
|
19
|
+
charge: (args: Charge) => Promise<ChargeResponse>;
|
|
20
|
+
createPaymentRequest: (args: Charge) => Promise<string>;
|
|
21
|
+
};
|
|
22
|
+
type ATXPConfig = {
|
|
23
|
+
destination: string;
|
|
24
|
+
mountPath: string;
|
|
25
|
+
currency: Currency;
|
|
26
|
+
network: Network;
|
|
27
|
+
server: AuthorizationServerUrl;
|
|
28
|
+
payeeName: string;
|
|
29
|
+
resource: UrlString | null;
|
|
30
|
+
allowHttp: boolean;
|
|
31
|
+
logger: Logger;
|
|
32
|
+
oAuthDb: OAuthDb;
|
|
33
|
+
oAuthClient: OAuthResourceClient;
|
|
34
|
+
paymentServer: PaymentServer;
|
|
35
|
+
};
|
|
36
|
+
declare enum TokenProblem {
|
|
37
|
+
NO_TOKEN = "NO-TOKEN",
|
|
38
|
+
NON_BEARER_AUTH_HEADER = "NON-BEARER-AUTH-HEADER",
|
|
39
|
+
INVALID_TOKEN = "INVALID-TOKEN",
|
|
40
|
+
INVALID_AUDIENCE = "INVALID-AUDIENCE",
|
|
41
|
+
NON_SUFFICIENT_FUNDS = "NON-SUFFICIENT-FUNDS",
|
|
42
|
+
INTROSPECT_ERROR = "INTROSPECT-ERROR"
|
|
43
|
+
}
|
|
44
|
+
type TokenCheckPass = {
|
|
45
|
+
passes: true;
|
|
46
|
+
token: string;
|
|
47
|
+
data: TokenData;
|
|
48
|
+
};
|
|
49
|
+
type TokenCheckFail = {
|
|
50
|
+
passes: false;
|
|
51
|
+
problem: TokenProblem;
|
|
52
|
+
token: string | null;
|
|
53
|
+
data: TokenData | null;
|
|
54
|
+
resourceMetadataUrl: string | null;
|
|
55
|
+
};
|
|
56
|
+
type TokenCheck = TokenCheckPass | TokenCheckFail;
|
|
57
|
+
type ProtectedResourceMetadata = {
|
|
58
|
+
resource: URL;
|
|
59
|
+
resource_name: string;
|
|
60
|
+
authorization_servers: string[];
|
|
61
|
+
bearer_methods_supported: string[];
|
|
62
|
+
scopes_supported: string[];
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
type RequiredATXPConfigFields = 'destination';
|
|
66
|
+
type RequiredATXPConfig = Pick<ATXPConfig, RequiredATXPConfigFields>;
|
|
67
|
+
type OptionalATXPConfig = Omit<ATXPConfig, RequiredATXPConfigFields>;
|
|
68
|
+
type ATXPArgs = RequiredATXPConfig & Partial<OptionalATXPConfig>;
|
|
69
|
+
type BuildableATXPConfigFields = 'oAuthDb' | 'oAuthClient' | 'paymentServer' | 'logger';
|
|
70
|
+
declare const DEFAULT_CONFIG: Required<Omit<OptionalATXPConfig, BuildableATXPConfigFields>>;
|
|
71
|
+
declare function buildServerConfig(args: ATXPArgs): ATXPConfig;
|
|
72
|
+
declare function atxpServer(args: ATXPArgs): Router;
|
|
73
|
+
|
|
74
|
+
declare function getATXPConfig(): ATXPConfig | null;
|
|
75
|
+
declare function getATXPResource(): URL | null;
|
|
76
|
+
declare function atxpAccountId(): string | null;
|
|
77
|
+
declare function withATXPContext(config: ATXPConfig, resource: URL, tokenInfo: Pick<TokenCheck, 'token' | 'data'> | null, next: () => void): Promise<void>;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Core platform-agnostic token checking logic
|
|
81
|
+
* Takes an authorization header string instead of platform-specific request objects
|
|
82
|
+
*/
|
|
83
|
+
declare function checkTokenCore(config: ATXPConfig, resourceURL: URL, authorizationHeader: string | null): Promise<TokenCheck>;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Core platform-agnostic OAuth challenge response creation
|
|
87
|
+
* Returns the response data instead of writing to platform-specific response objects
|
|
88
|
+
*/
|
|
89
|
+
declare function createOAuthChallengeResponseCore(tokenCheck: TokenCheck): {
|
|
90
|
+
status: number;
|
|
91
|
+
headers: Record<string, string>;
|
|
92
|
+
body: string;
|
|
93
|
+
} | null;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Core platform-agnostic MCP request parsing logic
|
|
97
|
+
* Takes parsed JSON and request metadata instead of platform-specific request objects
|
|
98
|
+
*/
|
|
99
|
+
declare function parseMcpRequestsCore(config: ATXPConfig, requestUrl: URL, method: string, parsedBody: unknown): any[];
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Node.js HTTP implementation of token checking
|
|
103
|
+
* Extracts data from Node.js IncomingMessage and delegates to core logic
|
|
104
|
+
*/
|
|
105
|
+
declare function checkToken(config: ATXPConfig, resourceURL: URL, req: IncomingMessage): Promise<TokenCheck>;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Node.js HTTP implementation of OAuth challenge sending
|
|
109
|
+
* Uses Node.js ServerResponse and delegates to core logic
|
|
110
|
+
*/
|
|
111
|
+
declare function sendOAuthChallenge(res: ServerResponse, tokenCheck: TokenCheck): boolean;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Node.js HTTP implementation of MCP request parsing
|
|
115
|
+
* Handles Node.js IncomingMessage parsing and delegates to core logic
|
|
116
|
+
*/
|
|
117
|
+
declare function parseMcpRequests(config: ATXPConfig, requestUrl: URL, req: IncomingMessage$1, parsedBody?: unknown): Promise<JSONRPCRequest[]>;
|
|
118
|
+
declare function parseBody(req: IncomingMessage$1, logger: Logger): Promise<unknown>;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Web API implementation of token checking for Cloudflare Workers, Deno, etc.
|
|
122
|
+
* Extracts data from Web API Request and delegates to core logic
|
|
123
|
+
*/
|
|
124
|
+
declare function checkTokenWebApi(config: ATXPConfig, resourceURL: URL, request: Request): Promise<TokenCheck>;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Web API implementation of OAuth challenge sending for Cloudflare Workers, Deno, etc.
|
|
128
|
+
* Uses Web API Response and delegates to core logic
|
|
129
|
+
*/
|
|
130
|
+
declare function sendOAuthChallengeWebApi(tokenCheck: TokenCheck): Response | null;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Web API implementation of MCP request parsing for Cloudflare Workers, Deno, etc.
|
|
134
|
+
* Handles Web API Request parsing and delegates to core logic
|
|
135
|
+
*/
|
|
136
|
+
declare function parseMcpRequestsWebApi(config: ATXPConfig, request: Request): Promise<any[]>;
|
|
137
|
+
|
|
138
|
+
declare function requirePayment(paymentConfig: RequirePaymentConfig): Promise<void>;
|
|
139
|
+
|
|
140
|
+
export { DEFAULT_CONFIG, TokenProblem, atxpAccountId, atxpServer, buildServerConfig, checkToken, checkTokenCore, checkTokenWebApi, createOAuthChallengeResponseCore, getATXPConfig, getATXPResource, parseBody, parseMcpRequests, parseMcpRequestsCore, parseMcpRequestsWebApi, requirePayment, sendOAuthChallenge, sendOAuthChallengeWebApi, withATXPContext };
|
|
141
|
+
export type { ATXPArgs, ATXPConfig, Charge, ChargeResponse, McpMethod, McpName, McpNamePattern, McpOperation, McpOperationPattern, PaymentServer, ProtectedResourceMetadata, RefundErrors, TokenCheck, TokenCheckFail, TokenCheckPass };
|