@atxp/client 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.
Files changed (38) hide show
  1. package/package.json +2 -2
  2. package/dist/src/atxpClient.d.ts +0 -14
  3. package/dist/src/atxpClient.d.ts.map +0 -1
  4. package/dist/src/atxpClient.js +0 -62
  5. package/dist/src/atxpClient.js.map +0 -1
  6. package/dist/src/atxpFetcher.d.ts +0 -71
  7. package/dist/src/atxpFetcher.d.ts.map +0 -1
  8. package/dist/src/atxpFetcher.js +0 -347
  9. package/dist/src/atxpFetcher.js.map +0 -1
  10. package/dist/src/clientTestHelpers.d.ts +0 -6
  11. package/dist/src/clientTestHelpers.d.ts.map +0 -1
  12. package/dist/src/clientTestHelpers.js +0 -94
  13. package/dist/src/clientTestHelpers.js.map +0 -1
  14. package/dist/src/index.d.ts +0 -7
  15. package/dist/src/index.d.ts.map +0 -1
  16. package/dist/src/index.js +0 -7
  17. package/dist/src/index.js.map +0 -1
  18. package/dist/src/oAuth.d.ts +0 -44
  19. package/dist/src/oAuth.d.ts.map +0 -1
  20. package/dist/src/oAuth.js +0 -274
  21. package/dist/src/oAuth.js.map +0 -1
  22. package/dist/src/setup.expo.d.ts +0 -2
  23. package/dist/src/setup.expo.d.ts.map +0 -1
  24. package/dist/src/setup.expo.js +0 -42
  25. package/dist/src/setup.expo.js.map +0 -1
  26. package/dist/src/solanaAccount.d.ts +0 -9
  27. package/dist/src/solanaAccount.d.ts.map +0 -1
  28. package/dist/src/solanaAccount.js +0 -19
  29. package/dist/src/solanaAccount.js.map +0 -1
  30. package/dist/src/solanaPaymentMaker.d.ts +0 -17
  31. package/dist/src/solanaPaymentMaker.d.ts.map +0 -1
  32. package/dist/src/solanaPaymentMaker.js +0 -62
  33. package/dist/src/solanaPaymentMaker.js.map +0 -1
  34. package/dist/src/types.d.ts +0 -58
  35. package/dist/src/types.d.ts.map +0 -1
  36. package/dist/src/types.js +0 -2
  37. package/dist/src/types.js.map +0 -1
  38. package/dist/tsconfig.tsbuildinfo +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atxp/client",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "ATXP Client - MCP client with OAuth authentication and payment processing",
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.5",
25
+ "@atxp/common": "0.2.6",
26
26
  "@modelcontextprotocol/sdk": "^1.15.0",
27
27
  "@solana/pay": "^0.2.5",
28
28
  "@solana/web3.js": "^1.98.1",
@@ -1,14 +0,0 @@
1
- import { ClientConfig } from "./types.js";
2
- import { Client } from "@modelcontextprotocol/sdk/client/index.js";
3
- import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
4
- type RequiredClientConfigFields = 'mcpServer' | 'account';
5
- type RequiredClientConfig = Pick<ClientConfig, RequiredClientConfigFields>;
6
- type OptionalClientConfig = Omit<ClientConfig, RequiredClientConfigFields>;
7
- export type ClientArgs = RequiredClientConfig & Partial<OptionalClientConfig>;
8
- type BuildableClientConfigFields = 'oAuthDb' | 'logger';
9
- export declare const DEFAULT_CLIENT_CONFIG: Required<Omit<OptionalClientConfig, BuildableClientConfigFields>>;
10
- export declare function buildClientConfig(args: ClientArgs): ClientConfig;
11
- export declare function buildStreamableTransport(args: ClientArgs): StreamableHTTPClientTransport;
12
- export declare function atxpClient(args: ClientArgs): Promise<Client>;
13
- export {};
14
- //# sourceMappingURL=atxpClient.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"atxpClient.d.ts","sourceRoot":"","sources":["../../src/atxpClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG1C,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AAEnG,KAAK,0BAA0B,GAAG,WAAW,GAAG,SAAS,CAAC;AAC1D,KAAK,oBAAoB,GAAG,IAAI,CAAC,YAAY,EAAE,0BAA0B,CAAC,CAAC;AAC3E,KAAK,oBAAoB,GAAG,IAAI,CAAC,YAAY,EAAE,0BAA0B,CAAC,CAAC;AAC3E,MAAM,MAAM,UAAU,GAAG,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAC9E,KAAK,2BAA2B,GAAG,SAAS,GAAG,QAAQ,CAAC;AAExD,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,IAAI,CAAC,oBAAoB,EAAE,2BAA2B,CAAC,CAiBnG,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,UAAU,GAAG,YAAY,CAUhE;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,UAAU,GAAG,6BAA6B,CAoBxF;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAQlE"}
@@ -1,62 +0,0 @@
1
- import { SqliteOAuthDb, ConsoleLogger, DEFAULT_AUTHORIZATION_SERVER } from "@longrun/atxp-common";
2
- import { ATXPFetcher } from "./atxpFetcher.js";
3
- import { Client } from "@modelcontextprotocol/sdk/client/index.js";
4
- import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
5
- export const DEFAULT_CLIENT_CONFIG = {
6
- allowedAuthorizationServers: [DEFAULT_AUTHORIZATION_SERVER],
7
- approvePayment: async (_p) => true,
8
- fetchFn: fetch,
9
- oAuthChannelFetch: fetch,
10
- allowHttp: process.env.NODE_ENV === 'development',
11
- clientInfo: {
12
- name: 'ATXPClient',
13
- version: '0.0.1'
14
- },
15
- clientOptions: {
16
- capabilities: {}
17
- },
18
- onAuthorize: async () => { },
19
- onAuthorizeFailure: async () => { },
20
- onPayment: async () => { },
21
- onPaymentFailure: async () => { }
22
- };
23
- export function buildClientConfig(args) {
24
- // Use fetchFn for oAuthChannelFetch if the latter isn't explicitly set
25
- if (args.fetchFn && !args.oAuthChannelFetch) {
26
- args.oAuthChannelFetch = args.fetchFn;
27
- }
28
- const withDefaults = { ...DEFAULT_CLIENT_CONFIG, ...args };
29
- const oAuthDb = withDefaults.oAuthDb ?? new SqliteOAuthDb({ db: ':memory:' });
30
- const logger = withDefaults.logger ?? new ConsoleLogger();
31
- const built = { oAuthDb, logger };
32
- return Object.freeze({ ...withDefaults, ...built });
33
- }
34
- ;
35
- export function buildStreamableTransport(args) {
36
- const config = buildClientConfig(args);
37
- const fetcher = new ATXPFetcher({
38
- accountId: args.account.accountId,
39
- db: config.oAuthDb,
40
- paymentMakers: args.account.paymentMakers,
41
- fetchFn: config.fetchFn,
42
- sideChannelFetch: config.oAuthChannelFetch,
43
- allowInsecureRequests: config.allowHttp,
44
- allowedAuthorizationServers: config.allowedAuthorizationServers,
45
- approvePayment: config.approvePayment,
46
- logger: config.logger,
47
- onAuthorize: config.onAuthorize,
48
- onAuthorizeFailure: config.onAuthorizeFailure,
49
- onPayment: config.onPayment,
50
- onPaymentFailure: config.onPaymentFailure
51
- });
52
- const transport = new StreamableHTTPClientTransport(new URL(args.mcpServer), { fetch: fetcher.fetch });
53
- return transport;
54
- }
55
- export async function atxpClient(args) {
56
- const config = buildClientConfig(args);
57
- const transport = buildStreamableTransport(config);
58
- const client = new Client(config.clientInfo, config.clientOptions);
59
- await client.connect(transport);
60
- return client;
61
- }
62
- //# sourceMappingURL=atxpClient.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"atxpClient.js","sourceRoot":"","sources":["../../src/atxpClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AAClG,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;A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AAChB,CAAC"}
@@ -1,71 +0,0 @@
1
- import { OAuthAuthenticationRequiredError, OAuthClient } from './oAuth.js';
2
- import { AccessToken, AuthorizationServerUrl, FetchLike, OAuthDb, PaymentRequestData, Logger } from '@longrun/atxp-common';
3
- import type { PaymentMaker, ProspectivePayment } from './types.js';
4
- import { McpError } from '@modelcontextprotocol/sdk/types.js';
5
- export interface ATXPFetcherConfig {
6
- accountId: string;
7
- db: OAuthDb;
8
- paymentMakers: {
9
- [key: string]: PaymentMaker;
10
- };
11
- fetchFn?: FetchLike;
12
- sideChannelFetch?: FetchLike;
13
- strict?: boolean;
14
- allowInsecureRequests?: boolean;
15
- allowedAuthorizationServers?: AuthorizationServerUrl[];
16
- approvePayment?: (payment: ProspectivePayment) => Promise<boolean>;
17
- logger?: Logger;
18
- onAuthorize?: (args: {
19
- authorizationServer: AuthorizationServerUrl;
20
- userId: string;
21
- }) => Promise<void>;
22
- onAuthorizeFailure?: (args: {
23
- authorizationServer: AuthorizationServerUrl;
24
- userId: string;
25
- error: Error;
26
- }) => Promise<void>;
27
- onPayment?: (args: {
28
- payment: ProspectivePayment;
29
- }) => Promise<void>;
30
- onPaymentFailure?: (args: {
31
- payment: ProspectivePayment;
32
- error: Error;
33
- }) => Promise<void>;
34
- }
35
- export declare function atxpFetch(config: ATXPFetcherConfig): FetchLike;
36
- export declare class ATXPFetcher {
37
- protected oauthClient: OAuthClient;
38
- protected paymentMakers: Map<string, PaymentMaker>;
39
- protected sideChannelFetch: FetchLike;
40
- protected db: OAuthDb;
41
- protected accountId: string;
42
- protected allowedAuthorizationServers: AuthorizationServerUrl[];
43
- protected approvePayment: (payment: ProspectivePayment) => Promise<boolean>;
44
- protected logger: Logger;
45
- protected onAuthorize: (args: {
46
- authorizationServer: AuthorizationServerUrl;
47
- userId: string;
48
- }) => Promise<void>;
49
- protected onAuthorizeFailure: (args: {
50
- authorizationServer: AuthorizationServerUrl;
51
- userId: string;
52
- error: Error;
53
- }) => Promise<void>;
54
- protected onPayment: (args: {
55
- payment: ProspectivePayment;
56
- }) => Promise<void>;
57
- protected onPaymentFailure: (args: {
58
- payment: ProspectivePayment;
59
- error: Error;
60
- }) => Promise<void>;
61
- constructor({ accountId, db, paymentMakers, fetchFn, sideChannelFetch, strict, allowInsecureRequests, allowedAuthorizationServers, approvePayment, logger, onAuthorize, onAuthorizeFailure, onPayment, onPaymentFailure }: ATXPFetcherConfig);
62
- protected handlePaymentRequestError: (paymentRequestError: McpError) => Promise<boolean>;
63
- protected getPaymentRequestData: (paymentRequestUrl: string) => Promise<PaymentRequestData | null>;
64
- protected isAllowedAuthServer: (url: string | URL) => boolean;
65
- protected makeAuthRequestWithPaymentMaker: (authorizationUrl: URL, paymentMaker: PaymentMaker) => Promise<string>;
66
- protected authToService: (error: OAuthAuthenticationRequiredError) => Promise<void>;
67
- protected exchangeToken: (myToken: AccessToken, newResourceUrl: string) => Promise<AccessToken>;
68
- protected checkForATXPResponse: (response: Response) => Promise<void>;
69
- fetch: FetchLike;
70
- }
71
- //# sourceMappingURL=atxpFetcher.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"atxpFetcher.d.ts","sourceRoot":"","sources":["../../src/atxpFetcher.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gCAAgC,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC3E,OAAO,EAAqD,WAAW,EAAE,sBAAsB,EAAE,SAAS,EAAE,OAAO,EAAE,kBAAkB,EAAgC,MAAM,EAAwE,MAAM,sBAAsB,CAAC;AAClR,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEnE,OAAO,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAE9D,MAAM,WAAW,iBAAiB;IAEhC,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,EAAE,OAAO,CAAC;IACZ,aAAa,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAAA;KAAC,CAAC;IAC7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SAAS,CAAC,mBAAmB,GAAI,KAAK,MAAM,GAAG,GAAG,KAAG,OAAO,CAI3D;IAED,SAAS,CAAC,+BAA+B,GAAU,kBAAkB,GAAG,EAAE,cAAc,YAAY,KAAG,OAAO,CAAC,MAAM,CAAC,CAkDrH;IAED,SAAS,CAAC,aAAa,GAAU,OAAO,gCAAgC,KAAG,OAAO,CAAC,IAAI,CAAC,CAmDvF;IAED,SAAS,CAAC,aAAa,GAAU,SAAS,WAAW,EAAE,gBAAgB,MAAM,KAAG,OAAO,CAAC,WAAW,CAAC,CAKnG;IAED,SAAS,CAAC,oBAAoB,GAAU,UAAU,QAAQ,KAAG,OAAO,CAAC,IAAI,CAAC,CAgCzE;IAED,KAAK,EAAE,SAAS,CA+Cf;CACF"}
@@ -1,347 +0,0 @@
1
- import { BigNumber } from 'bignumber.js';
2
- import { OAuthAuthenticationRequiredError, OAuthClient } from './oAuth.js';
3
- import { PAYMENT_REQUIRED_ERROR_CODE, paymentRequiredError, DEFAULT_AUTHORIZATION_SERVER, parsePaymentRequests, parseMcpMessages, ConsoleLogger, isSSEResponse } from '@longrun/atxp-common';
4
- import { getIsReactNative, createReactNativeSafeFetch } from '@longrun/atxp-common';
5
- import { McpError } from '@modelcontextprotocol/sdk/types.js';
6
- export function atxpFetch(config) {
7
- const fetcher = new ATXPFetcher(config);
8
- return fetcher.fetch;
9
- }
10
- export class ATXPFetcher {
11
- constructor({ accountId, db, paymentMakers, fetchFn = fetch, sideChannelFetch = fetchFn, strict = true, allowInsecureRequests = process.env.NODE_ENV === 'development', allowedAuthorizationServers = [DEFAULT_AUTHORIZATION_SERVER], approvePayment = async () => true, logger = new ConsoleLogger(), onAuthorize = async () => { }, onAuthorizeFailure = async () => { }, onPayment = async () => { }, onPaymentFailure = async () => { } }) {
12
- this.handlePaymentRequestError = async (paymentRequestError) => {
13
- if (paymentRequestError.code !== PAYMENT_REQUIRED_ERROR_CODE) {
14
- throw new Error(`ATXP: expected payment required error (code ${PAYMENT_REQUIRED_ERROR_CODE}); got code ${paymentRequestError.code}`);
15
- }
16
- const paymentRequestUrl = paymentRequestError.data?.paymentRequestUrl;
17
- if (!paymentRequestUrl) {
18
- throw new Error(`ATXP: payment requirement error does not contain a payment requirement URL`);
19
- }
20
- const paymentRequestId = paymentRequestError.data?.paymentRequestId;
21
- if (!paymentRequestId) {
22
- throw new Error(`ATXP: payment requirement error does not contain a payment request ID`);
23
- }
24
- if (!this.isAllowedAuthServer(paymentRequestUrl)) {
25
- this.logger.info(`ATXP: payment requirement is not allowed on this server`);
26
- return false;
27
- }
28
- const paymentRequestData = await this.getPaymentRequestData(paymentRequestUrl);
29
- if (!paymentRequestData) {
30
- throw new Error(`ATXP: payment request ${paymentRequestId} not found on server ${paymentRequestUrl}`);
31
- }
32
- const requestedNetwork = paymentRequestData.network;
33
- if (!requestedNetwork) {
34
- throw new Error(`Payment network not provided`);
35
- }
36
- const destination = paymentRequestData.destination;
37
- if (!destination) {
38
- throw new Error(`destination not provided`);
39
- }
40
- let amount = new BigNumber(0);
41
- if (!paymentRequestData.amount) {
42
- throw new Error(`amount not provided`);
43
- }
44
- try {
45
- amount = new BigNumber(paymentRequestData.amount);
46
- }
47
- catch {
48
- throw new Error(`Invalid amount ${paymentRequestData.amount}`);
49
- }
50
- if (amount.lte(0)) {
51
- throw new Error(`Invalid amount ${paymentRequestData.amount}`);
52
- }
53
- const currency = paymentRequestData.currency;
54
- if (!currency) {
55
- throw new Error(`Currency not provided`);
56
- }
57
- const paymentMaker = this.paymentMakers.get(requestedNetwork);
58
- if (!paymentMaker) {
59
- this.logger.info(`ATXP: payment network ${requestedNetwork} not set up for this server (available networks: ${Array.from(this.paymentMakers.keys()).join(', ')})`);
60
- return false;
61
- }
62
- const prospectivePayment = {
63
- accountId: this.accountId,
64
- resourceUrl: paymentRequestData.resource?.toString() ?? '',
65
- resourceName: paymentRequestData.resourceName ?? '',
66
- network: requestedNetwork,
67
- currency,
68
- amount,
69
- iss: paymentRequestData.iss ?? '',
70
- };
71
- if (!await this.approvePayment(prospectivePayment)) {
72
- this.logger.info(`ATXP: payment request denied by callback function`);
73
- return false;
74
- }
75
- let paymentId;
76
- try {
77
- paymentId = await paymentMaker.makePayment(amount, currency, destination, paymentRequestData.iss);
78
- this.logger.info(`ATXP: made payment of ${amount} ${currency} on ${requestedNetwork}: ${paymentId}`);
79
- // Call onPayment callback after successful payment
80
- await this.onPayment({ payment: prospectivePayment });
81
- }
82
- catch (paymentError) {
83
- // Call onPaymentFailure callback if payment fails
84
- await this.onPaymentFailure({
85
- payment: prospectivePayment,
86
- error: paymentError
87
- });
88
- throw paymentError;
89
- }
90
- const jwt = await paymentMaker.generateJWT({ paymentRequestId, codeChallenge: '' });
91
- // Make a fetch call to the authorization URL with the payment ID
92
- // redirect=false is a hack
93
- // The OAuth spec calls for the authorization url to return with a redirect, but fetch
94
- // on mobile will automatically follow the redirect (it doesn't support the redirect=manual option)
95
- // We want the redirect URL so we can extract the code from it, not the contents of the
96
- // redirect URL (which might not even exist for agentic ATXP clients)
97
- // So ATXP servers are set up to instead return a 200 with the redirect URL in the body
98
- // if we pass redirect=false.
99
- // TODO: Remove the redirect=false hack once we have a way to handle the redirect on mobile
100
- const response = await this.sideChannelFetch(paymentRequestUrl.toString(), {
101
- method: 'PUT',
102
- headers: {
103
- 'Authorization': `Bearer ${jwt}`,
104
- 'Content-Type': 'application/json'
105
- },
106
- body: JSON.stringify({
107
- transactionId: paymentId,
108
- network: requestedNetwork
109
- })
110
- });
111
- this.logger.debug(`ATXP: payment was ${response.ok ? 'successfully' : 'not successfully'} PUT to ${paymentRequestUrl} : status ${response.status} ${response.statusText}`);
112
- if (!response.ok) {
113
- const msg = `ATXP: payment to ${paymentRequestUrl} failed: HTTP ${response.status} ${await response.text()}`;
114
- this.logger.info(msg);
115
- throw new Error(msg);
116
- }
117
- return true;
118
- };
119
- this.getPaymentRequestData = async (paymentRequestUrl) => {
120
- const prRequest = await this.sideChannelFetch(paymentRequestUrl);
121
- if (!prRequest.ok) {
122
- throw new Error(`ATXP: GET ${paymentRequestUrl} failed: ${prRequest.status} ${prRequest.statusText}`);
123
- }
124
- const paymentRequest = await prRequest.json();
125
- return paymentRequest;
126
- };
127
- this.isAllowedAuthServer = (url) => {
128
- const urlObj = typeof url === 'string' ? new URL(url) : url;
129
- const baseUrl = urlObj.origin;
130
- return this.allowedAuthorizationServers.includes(baseUrl);
131
- };
132
- this.makeAuthRequestWithPaymentMaker = async (authorizationUrl, paymentMaker) => {
133
- const codeChallenge = authorizationUrl.searchParams.get('code_challenge');
134
- if (!codeChallenge) {
135
- throw new Error(`Code challenge not provided`);
136
- }
137
- const authToken = await paymentMaker.generateJWT({ paymentRequestId: '', codeChallenge: codeChallenge });
138
- // Make a fetch call to the authorization URL with the payment ID
139
- // redirect=false is a hack
140
- // The OAuth spec calls for the authorization url to return with a redirect, but fetch
141
- // on mobile will automatically follow the redirect (it doesn't support the redirect=manual option)
142
- // We want the redirect URL so we can extract the code from it, not the contents of the
143
- // redirect URL (which might not even exist for agentic ATXP clients)
144
- // So ATXP servers are set up to instead return a 200 with the redirect URL in the body
145
- // if we pass redirect=false.
146
- // TODO: Remove the redirect=false hack once we have a way to handle the redirect on mobile
147
- const response = await this.sideChannelFetch(authorizationUrl.toString() + '&redirect=false', {
148
- method: 'GET',
149
- redirect: 'manual',
150
- headers: {
151
- 'Authorization': `Bearer ${authToken}`
152
- }
153
- });
154
- // Check if we got a redirect response (301, 302, etc.) in case the server follows
155
- // the OAuth spec
156
- if (response.status >= 300 && response.status < 400) {
157
- const location = response.headers.get('Location');
158
- if (location) {
159
- this.logger.info(`ATXP: got redirect authorization code response - redirect to ${location}`);
160
- return location;
161
- }
162
- else {
163
- this.logger.info(`ATXP: got redirect authorization code response, but no redirect URL in Location header`);
164
- }
165
- }
166
- // Handle the non-standard ATXP redirect=false hack
167
- if (response.ok) {
168
- // Handle the redirect manually
169
- const body = await response.json();
170
- const redirectUrl = body.redirect;
171
- if (redirectUrl) {
172
- this.logger.info(`ATXP: got response.ok authorization code response - redirect to ${redirectUrl}`);
173
- return redirectUrl;
174
- }
175
- else {
176
- this.logger.info(`ATXP: got authorization code response with response.ok, but no redirect URL in body`);
177
- }
178
- }
179
- // If we didn't get a redirect, throw an error
180
- throw new Error(`Expected redirect response from authorization URL, got ${response.status}`);
181
- };
182
- this.authToService = async (error) => {
183
- // TODO: We need to generalize this - we can't assume that there's a single paymentMaker for the auth flow.
184
- if (this.paymentMakers.size > 1) {
185
- throw new Error(`ATXP: multiple payment makers found - cannot determine which one to use for auth`);
186
- }
187
- const paymentMaker = Array.from(this.paymentMakers.values())[0];
188
- if (paymentMaker) {
189
- // We can do the full OAuth flow - we'll generate a signed JWT and call /authorize on the
190
- // AS to get a code, then exchange the code for an access token
191
- const authorizationUrl = await this.oauthClient.makeAuthorizationUrl(error.url, error.resourceServerUrl);
192
- if (!this.isAllowedAuthServer(authorizationUrl)) {
193
- throw new Error(`ATXP: resource server ${error.url} is requesting to use ${authorizationUrl} which is not in the allowed list of authorization servers ${this.allowedAuthorizationServers.join(', ')}`);
194
- }
195
- try {
196
- const redirectUrl = await this.makeAuthRequestWithPaymentMaker(authorizationUrl, paymentMaker);
197
- // Handle the OAuth callback
198
- await this.oauthClient.handleCallback(redirectUrl);
199
- // Call onAuthorize callback after successful authorization
200
- await this.onAuthorize({
201
- authorizationServer: authorizationUrl.origin,
202
- userId: this.accountId
203
- });
204
- }
205
- catch (authError) {
206
- // Call onAuthorizeFailure callback if authorization fails
207
- await this.onAuthorizeFailure({
208
- authorizationServer: authorizationUrl.origin,
209
- userId: this.accountId,
210
- error: authError
211
- });
212
- throw authError;
213
- }
214
- }
215
- else {
216
- // Else, we'll see if we've already got an OAuth token from OUR caller (if any).
217
- // If we do, we'll use it to auth to the downstream resource
218
- // (In pass-through scenarios, the atxpServer() middleware stores the incoming
219
- // token in the DB under the '' resource URL).
220
- const existingToken = await this.db.getAccessToken(this.accountId, '');
221
- if (!existingToken) {
222
- this.logger.info(`ATXP: no token found for the current server - we can't exchange a token if we don't have one`);
223
- throw error;
224
- }
225
- const newToken = await this.exchangeToken(existingToken, error.resourceServerUrl);
226
- this.db.saveAccessToken(this.accountId, error.resourceServerUrl, newToken);
227
- }
228
- };
229
- this.exchangeToken = async (myToken, newResourceUrl) => {
230
- // TODO: Do token-exchange rather than passing through our own token
231
- const token = Object.assign({}, myToken);
232
- token.resourceUrl = newResourceUrl;
233
- return token;
234
- };
235
- this.checkForATXPResponse = async (response) => {
236
- const clonedResponse = response.clone();
237
- const body = await clonedResponse.text();
238
- if (body.length === 0) {
239
- return;
240
- }
241
- let paymentRequests = [];
242
- try {
243
- // Check if the response is SSE formatted
244
- if (isSSEResponse(body)) {
245
- this.logger.debug('Detected SSE-formatted response, parsing SSE messages for payment requirements');
246
- const messages = await parseMcpMessages(body);
247
- paymentRequests = messages.flatMap(message => parsePaymentRequests(message)).filter(pr => pr !== null);
248
- }
249
- else {
250
- // Handle regular JSON responses
251
- const json = JSON.parse(body);
252
- const messages = await parseMcpMessages(json);
253
- paymentRequests = messages.flatMap(message => parsePaymentRequests(message)).filter(pr => pr !== null);
254
- }
255
- }
256
- catch (error) {
257
- this.logger.error(`ATXP: error checking for payment requirements in MCP response: ${error}`);
258
- this.logger.debug(body);
259
- }
260
- if (paymentRequests.length > 1) {
261
- throw new Error(`ATXP: multiple payment requirements found in MCP response. The client does not support multiple payment requirements. ${paymentRequests.map(pr => pr.url).join(', ')}`);
262
- }
263
- for (const { url, id } of paymentRequests) {
264
- this.logger.info(`ATXP: payment requirement found in MCP response - ${url} - throwing payment required error`);
265
- throw paymentRequiredError(url, id);
266
- }
267
- };
268
- this.fetch = async (url, init) => {
269
- let response = null;
270
- let fetchError = null;
271
- try {
272
- // Try to fetch the resource
273
- response = await this.oauthClient.fetch(url, init);
274
- await this.checkForATXPResponse(response);
275
- return response;
276
- }
277
- catch (error) {
278
- fetchError = error;
279
- // If we get an OAuth authentication required error, handle it
280
- if (error instanceof OAuthAuthenticationRequiredError) {
281
- this.logger.info(`OAuth authentication required - ATXP client starting oauth flow for resource metadata ${error.resourceServerUrl}`);
282
- await this.authToService(error);
283
- try {
284
- // Retry the request once - we should be auth'd now
285
- response = await this.oauthClient.fetch(url, init);
286
- await this.checkForATXPResponse(response);
287
- return response;
288
- }
289
- catch (eTwo) {
290
- // If we throw an error again, it could be a payment error - don't just fail, see
291
- // if we can handle it in the payment flow below
292
- fetchError = eTwo;
293
- }
294
- }
295
- const mcpError = error instanceof McpError ? fetchError : null;
296
- if (mcpError && mcpError.code === PAYMENT_REQUIRED_ERROR_CODE) {
297
- this.logger.info(`Payment required - ATXP client starting payment flow ${mcpError?.data?.paymentRequestUrl}`);
298
- if (await this.handlePaymentRequestError(mcpError)) {
299
- // Retry the request once - we should be auth'd now
300
- response = await this.oauthClient.fetch(url, init);
301
- await this.checkForATXPResponse(response);
302
- }
303
- else {
304
- this.logger.info(`ATXP: payment request was not completed successfully`);
305
- }
306
- if (response) {
307
- return response;
308
- }
309
- else {
310
- throw new Error(`ATXP: no response was generated by the fetch`);
311
- }
312
- }
313
- // If it's not an authentication or payment error, rethrow
314
- throw error;
315
- }
316
- };
317
- // Use React Native safe fetch if in React Native environment
318
- const safeFetchFn = getIsReactNative() ? createReactNativeSafeFetch(fetchFn) : fetchFn;
319
- const safeSideChannelFetch = getIsReactNative() ? createReactNativeSafeFetch(sideChannelFetch) : sideChannelFetch;
320
- // ATXPClient should never actually use the callback url - instead of redirecting the user to
321
- // an authorization url which redirects back to the callback url, ATXPClient posts the payment
322
- // directly to the authorization server, then does the token exchange itself
323
- this.oauthClient = new OAuthClient({
324
- userId: accountId,
325
- db,
326
- callbackUrl: 'http://localhost:3000/unused-dummy-atxp-callback',
327
- isPublic: false,
328
- fetchFn: safeFetchFn,
329
- sideChannelFetch: safeSideChannelFetch,
330
- strict,
331
- allowInsecureRequests,
332
- logger: logger
333
- });
334
- this.paymentMakers = new Map(Object.entries(paymentMakers));
335
- this.sideChannelFetch = safeSideChannelFetch;
336
- this.db = db;
337
- this.accountId = accountId;
338
- this.allowedAuthorizationServers = allowedAuthorizationServers;
339
- this.approvePayment = approvePayment;
340
- this.logger = logger;
341
- this.onAuthorize = onAuthorize;
342
- this.onAuthorizeFailure = onAuthorizeFailure;
343
- this.onPayment = onPayment;
344
- this.onPaymentFailure = onPaymentFailure;
345
- }
346
- }
347
- //# sourceMappingURL=atxpFetcher.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"atxpFetcher.js","sourceRoot":"","sources":["../../src/atxpFetcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,gCAAgC,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC3E,OAAO,EAAE,2BAA2B,EAAE,oBAAoB,EAA+E,4BAA4B,EAAU,oBAAoB,EAAE,gBAAgB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAElR,OAAO,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAoB9D,MAAM,UAAU,SAAS,CAAC,MAAyB;IACjD,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;IACxC,OAAO,OAAO,CAAC,KAAK,CAAC;AACvB,CAAC;AAED,MAAM,OAAO,WAAW;IAatB,YAAY,EACV,SAAS,EACT,EAAE,EACF,aAAa,EACb,OAAO,GAAG,KAAK,EACf,gBAAgB,GAAG,OAAO,EAC1B,MAAM,GAAG,IAAI,EACb,qBAAqB,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EAC9D,2BAA2B,GAAG,CAAC,4BAA4B,CAAC,EAC5D,cAAc,GAAG,KAAK,IAAsB,EAAE,CAAC,IAAI,EACnD,MAAM,GAAG,IAAI,aAAa,EAAE,EAC5B,WAAW,GAAG,KAAK,IAAI,EAAE,GAAE,CAAC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AAG,2BAA2B,CAAC;QAC/D,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;QAC7C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC3C,CAAC;CA2UF"}
@@ -1,6 +0,0 @@
1
- import { FetchMock } from 'fetch-mock';
2
- export declare function mockResourceServer(mock: FetchMock, baseUrl?: string, resourcePath?: string, authServerUrl?: string): FetchMock;
3
- export declare function mockAuthorizationServer(mock: FetchMock, baseUrl?: string, paymentRequests?: {
4
- [key: string]: BigNumber;
5
- }): FetchMock;
6
- //# sourceMappingURL=clientTestHelpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"clientTestHelpers.d.ts","sourceRoot":"","sources":["../../src/clientTestHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,GAAE,MAA8B,EAAE,YAAY,GAAE,MAAe,EAAE,aAAa,GAAE,MAAqC,aAqB/K;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,GAAE,MAAqC,EAAE,eAAe,GAAE;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAM,aAqExJ"}