ebay-mcp 1.4.3
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/LICENSE +201 -0
- package/README.md +586 -0
- package/build/api/account-management/account.d.ts +216 -0
- package/build/api/account-management/account.js +305 -0
- package/build/api/analytics-and-report/analytics.d.ts +33 -0
- package/build/api/analytics-and-report/analytics.js +102 -0
- package/build/api/client.d.ts +89 -0
- package/build/api/client.js +343 -0
- package/build/api/communication/feedback.d.ts +45 -0
- package/build/api/communication/feedback.js +119 -0
- package/build/api/communication/message.d.ts +55 -0
- package/build/api/communication/message.js +131 -0
- package/build/api/communication/negotiation.d.ts +39 -0
- package/build/api/communication/negotiation.js +97 -0
- package/build/api/communication/notification.d.ts +128 -0
- package/build/api/communication/notification.js +373 -0
- package/build/api/index.d.ts +96 -0
- package/build/api/index.js +121 -0
- package/build/api/listing-management/inventory.d.ts +216 -0
- package/build/api/listing-management/inventory.js +633 -0
- package/build/api/listing-metadata/metadata.d.ts +154 -0
- package/build/api/listing-metadata/metadata.js +485 -0
- package/build/api/listing-metadata/taxonomy.d.ts +38 -0
- package/build/api/listing-metadata/taxonomy.js +58 -0
- package/build/api/marketing-and-promotions/marketing.d.ts +395 -0
- package/build/api/marketing-and-promotions/marketing.js +565 -0
- package/build/api/marketing-and-promotions/recommendation.d.ts +20 -0
- package/build/api/marketing-and-promotions/recommendation.js +32 -0
- package/build/api/order-management/dispute.d.ts +65 -0
- package/build/api/order-management/dispute.js +69 -0
- package/build/api/order-management/fulfillment.d.ts +80 -0
- package/build/api/order-management/fulfillment.js +89 -0
- package/build/api/other/compliance.d.ts +26 -0
- package/build/api/other/compliance.js +47 -0
- package/build/api/other/edelivery.d.ts +153 -0
- package/build/api/other/edelivery.js +219 -0
- package/build/api/other/identity.d.ts +17 -0
- package/build/api/other/identity.js +24 -0
- package/build/api/other/translation.d.ts +14 -0
- package/build/api/other/translation.js +22 -0
- package/build/api/other/vero.d.ts +30 -0
- package/build/api/other/vero.js +48 -0
- package/build/auth/oauth-metadata.d.ts +46 -0
- package/build/auth/oauth-metadata.js +59 -0
- package/build/auth/oauth-middleware.d.ts +35 -0
- package/build/auth/oauth-middleware.js +99 -0
- package/build/auth/oauth-types.d.ts +66 -0
- package/build/auth/oauth-types.js +4 -0
- package/build/auth/oauth.d.ts +93 -0
- package/build/auth/oauth.js +383 -0
- package/build/auth/scope-utils.d.ts +70 -0
- package/build/auth/scope-utils.js +304 -0
- package/build/auth/token-verifier.d.ts +57 -0
- package/build/auth/token-verifier.js +172 -0
- package/build/config/environment.d.ts +61 -0
- package/build/config/environment.js +260 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +98 -0
- package/build/schemas/account-management/account.d.ts +5324 -0
- package/build/schemas/account-management/account.js +366 -0
- package/build/schemas/analytics/analytics.d.ts +167 -0
- package/build/schemas/analytics/analytics.js +191 -0
- package/build/schemas/communication/messages.d.ts +1872 -0
- package/build/schemas/communication/messages.js +348 -0
- package/build/schemas/fulfillment/orders.d.ts +4655 -0
- package/build/schemas/fulfillment/orders.js +317 -0
- package/build/schemas/index.d.ts +2100 -0
- package/build/schemas/index.js +68 -0
- package/build/schemas/inventory-management/inventory.d.ts +6419 -0
- package/build/schemas/inventory-management/inventory.js +450 -0
- package/build/schemas/marketing/marketing.d.ts +14181 -0
- package/build/schemas/marketing/marketing.js +1088 -0
- package/build/schemas/metadata/metadata.d.ts +5259 -0
- package/build/schemas/metadata/metadata.js +614 -0
- package/build/schemas/other/other-apis.d.ts +257 -0
- package/build/schemas/other/other-apis.js +372 -0
- package/build/schemas/taxonomy/taxonomy.d.ts +215 -0
- package/build/schemas/taxonomy/taxonomy.js +571 -0
- package/build/scripts/auto-setup.d.ts +12 -0
- package/build/scripts/auto-setup.js +277 -0
- package/build/scripts/diagnostics.d.ts +8 -0
- package/build/scripts/diagnostics.js +299 -0
- package/build/scripts/download-specs.d.ts +1 -0
- package/build/scripts/download-specs.js +116 -0
- package/build/scripts/interactive-setup.d.ts +21 -0
- package/build/scripts/interactive-setup.js +723 -0
- package/build/server-http.d.ts +11 -0
- package/build/server-http.js +361 -0
- package/build/tools/definitions/account-with-schemas.d.ts +39 -0
- package/build/tools/definitions/account-with-schemas.js +170 -0
- package/build/tools/definitions/account.d.ts +12 -0
- package/build/tools/definitions/account.js +428 -0
- package/build/tools/definitions/analytics.d.ts +25 -0
- package/build/tools/definitions/analytics.js +66 -0
- package/build/tools/definitions/communication.d.ts +12 -0
- package/build/tools/definitions/communication.js +151 -0
- package/build/tools/definitions/fulfillment.d.ts +12 -0
- package/build/tools/definitions/fulfillment.js +326 -0
- package/build/tools/definitions/index.d.ts +25 -0
- package/build/tools/definitions/index.js +37 -0
- package/build/tools/definitions/inventory.d.ts +12 -0
- package/build/tools/definitions/inventory.js +429 -0
- package/build/tools/definitions/marketing.d.ts +12 -0
- package/build/tools/definitions/marketing.js +1095 -0
- package/build/tools/definitions/metadata.d.ts +12 -0
- package/build/tools/definitions/metadata.js +188 -0
- package/build/tools/definitions/other.d.ts +13 -0
- package/build/tools/definitions/other.js +309 -0
- package/build/tools/definitions/taxonomy.d.ts +25 -0
- package/build/tools/definitions/taxonomy.js +64 -0
- package/build/tools/definitions/token-management.d.ts +35 -0
- package/build/tools/definitions/token-management.js +103 -0
- package/build/tools/index.d.ts +11 -0
- package/build/tools/index.js +1003 -0
- package/build/tools/schemas.d.ts +14764 -0
- package/build/tools/schemas.js +667 -0
- package/build/tools/tool-definitions.d.ts +35 -0
- package/build/tools/tool-definitions.js +3534 -0
- package/build/types/application-settings/developerAnalyticsV1BetaOas3.d.ts +197 -0
- package/build/types/application-settings/developerAnalyticsV1BetaOas3.js +5 -0
- package/build/types/application-settings/developerClientRegistrationV1Oas3.d.ts +155 -0
- package/build/types/application-settings/developerClientRegistrationV1Oas3.js +5 -0
- package/build/types/application-settings/developerKeyManagementV1Oas3.d.ts +246 -0
- package/build/types/application-settings/developerKeyManagementV1Oas3.js +5 -0
- package/build/types/ebay-enums.d.ts +1204 -0
- package/build/types/ebay-enums.js +1330 -0
- package/build/types/ebay.d.ts +143 -0
- package/build/types/ebay.js +123 -0
- package/build/types/index.d.ts +6 -0
- package/build/types/index.js +10 -0
- package/build/types/sell-apps/account-management/sellAccountV1Oas3.d.ts +2579 -0
- package/build/types/sell-apps/account-management/sellAccountV1Oas3.js +5 -0
- package/build/types/sell-apps/analytics-and-report/sellAnalyticsV1Oas3.d.ts +446 -0
- package/build/types/sell-apps/analytics-and-report/sellAnalyticsV1Oas3.js +5 -0
- package/build/types/sell-apps/communication/commerceFeedbackV1BetaOas3.d.ts +705 -0
- package/build/types/sell-apps/communication/commerceFeedbackV1BetaOas3.js +5 -0
- package/build/types/sell-apps/communication/commerceMessageV1Oas3.d.ts +590 -0
- package/build/types/sell-apps/communication/commerceMessageV1Oas3.js +5 -0
- package/build/types/sell-apps/communication/commerceNotificationV1Oas3.d.ts +1276 -0
- package/build/types/sell-apps/communication/commerceNotificationV1Oas3.js +5 -0
- package/build/types/sell-apps/communication/sellNegotiationV1Oas3.d.ts +277 -0
- package/build/types/sell-apps/communication/sellNegotiationV1Oas3.js +5 -0
- package/build/types/sell-apps/listing-management/sellInventoryV1Oas3.d.ts +3133 -0
- package/build/types/sell-apps/listing-management/sellInventoryV1Oas3.js +5 -0
- package/build/types/sell-apps/listing-metadata/sellMetadataV1Oas3.d.ts +2289 -0
- package/build/types/sell-apps/listing-metadata/sellMetadataV1Oas3.js +5 -0
- package/build/types/sell-apps/markeitng-and-promotions/sellMarketingV1Oas3.d.ts +6650 -0
- package/build/types/sell-apps/markeitng-and-promotions/sellMarketingV1Oas3.js +5 -0
- package/build/types/sell-apps/markeitng-and-promotions/sellRecommendationV1Oas3.d.ts +172 -0
- package/build/types/sell-apps/markeitng-and-promotions/sellRecommendationV1Oas3.js +5 -0
- package/build/types/sell-apps/order-management/sellFulfillmentV1Oas3.d.ts +1869 -0
- package/build/types/sell-apps/order-management/sellFulfillmentV1Oas3.js +5 -0
- package/build/types/sell-apps/other-apis/commerceIdentityV1Oas3.d.ts +178 -0
- package/build/types/sell-apps/other-apis/commerceIdentityV1Oas3.js +5 -0
- package/build/types/sell-apps/other-apis/commerceTranslationV1BetaOas3.d.ts +128 -0
- package/build/types/sell-apps/other-apis/commerceTranslationV1BetaOas3.js +5 -0
- package/build/types/sell-apps/other-apis/commerceVeroV1Oas3.d.ts +417 -0
- package/build/types/sell-apps/other-apis/commerceVeroV1Oas3.js +5 -0
- package/build/types/sell-apps/other-apis/sellComplianceV1Oas3.d.ts +273 -0
- package/build/types/sell-apps/other-apis/sellComplianceV1Oas3.js +5 -0
- package/build/types/sell-apps/other-apis/sellEdeliveryInternationalShippingOas3.d.ts +2537 -0
- package/build/types/sell-apps/other-apis/sellEdeliveryInternationalShippingOas3.js +5 -0
- package/build/types/sell-apps/other-apis/sellMarketingV1Oas3.d.ts +6650 -0
- package/build/types/sell-apps/other-apis/sellMarketingV1Oas3.js +5 -0
- package/build/types/sell-apps/other-apis/sellRecommendationV1Oas3.d.ts +172 -0
- package/build/types/sell-apps/other-apis/sellRecommendationV1Oas3.js +5 -0
- package/build/utils/account-management/account.d.ts +1094 -0
- package/build/utils/account-management/account.js +831 -0
- package/build/utils/communication/feedback.d.ts +152 -0
- package/build/utils/communication/feedback.js +216 -0
- package/build/utils/communication/message.d.ts +174 -0
- package/build/utils/communication/message.js +242 -0
- package/build/utils/communication/negotiation.d.ts +123 -0
- package/build/utils/communication/negotiation.js +150 -0
- package/build/utils/communication/notification.d.ts +370 -0
- package/build/utils/communication/notification.js +369 -0
- package/build/utils/date-converter.d.ts +59 -0
- package/build/utils/date-converter.js +160 -0
- package/build/utils/llm-client-detector.d.ts +54 -0
- package/build/utils/llm-client-detector.js +318 -0
- package/build/utils/oauth-helper.d.ts +37 -0
- package/build/utils/oauth-helper.js +315 -0
- package/build/utils/order-management/dispute.d.ts +346 -0
- package/build/utils/order-management/dispute.js +369 -0
- package/build/utils/order-management/fulfillment.d.ts +200 -0
- package/build/utils/order-management/fulfillment.js +205 -0
- package/build/utils/other/compliance.d.ts +49 -0
- package/build/utils/other/compliance.js +76 -0
- package/build/utils/other/edelivery.d.ts +310 -0
- package/build/utils/other/edelivery.js +241 -0
- package/build/utils/other/identity.d.ts +13 -0
- package/build/utils/other/identity.js +13 -0
- package/build/utils/other/translation.d.ts +28 -0
- package/build/utils/other/translation.js +41 -0
- package/build/utils/other/vero.d.ts +61 -0
- package/build/utils/other/vero.js +90 -0
- package/build/utils/scope-helper.d.ts +49 -0
- package/build/utils/scope-helper.js +207 -0
- package/build/utils/security-checker.d.ts +46 -0
- package/build/utils/security-checker.js +248 -0
- package/build/utils/setup-validator.d.ts +25 -0
- package/build/utils/setup-validator.js +305 -0
- package/build/utils/token-utils.d.ts +40 -0
- package/build/utils/token-utils.js +40 -0
- package/package.json +115 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { EbayApiClient } from '../client.js';
|
|
2
|
+
/**
|
|
3
|
+
* Identity API - User identity verification
|
|
4
|
+
* Based on: docs/sell-apps/other-apis/commerce_identity_v1_oas3.json
|
|
5
|
+
*
|
|
6
|
+
* Note: Identity API uses apiz subdomain instead of api
|
|
7
|
+
*/
|
|
8
|
+
export declare class IdentityApi {
|
|
9
|
+
private client;
|
|
10
|
+
private readonly basePath;
|
|
11
|
+
constructor(client: EbayApiClient);
|
|
12
|
+
/**
|
|
13
|
+
* Get user information
|
|
14
|
+
* Uses apiz.ebay.com instead of api.ebay.com
|
|
15
|
+
*/
|
|
16
|
+
getUser(): Promise<unknown>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { getIdentityBaseUrl } from '../../config/environment.js';
|
|
2
|
+
/**
|
|
3
|
+
* Identity API - User identity verification
|
|
4
|
+
* Based on: docs/sell-apps/other-apis/commerce_identity_v1_oas3.json
|
|
5
|
+
*
|
|
6
|
+
* Note: Identity API uses apiz subdomain instead of api
|
|
7
|
+
*/
|
|
8
|
+
export class IdentityApi {
|
|
9
|
+
client;
|
|
10
|
+
basePath = '/commerce/identity/v1';
|
|
11
|
+
constructor(client) {
|
|
12
|
+
this.client = client;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Get user information
|
|
16
|
+
* Uses apiz.ebay.com instead of api.ebay.com
|
|
17
|
+
*/
|
|
18
|
+
async getUser() {
|
|
19
|
+
const config = this.client.getConfig();
|
|
20
|
+
const identityBaseUrl = getIdentityBaseUrl(config.environment);
|
|
21
|
+
const fullUrl = `${identityBaseUrl}${this.basePath}/user`;
|
|
22
|
+
return await this.client.getWithFullUrl(fullUrl);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { EbayApiClient } from '../../api/client.js';
|
|
2
|
+
/**
|
|
3
|
+
* Translation API - Translation services
|
|
4
|
+
* Based on: docs/sell-apps/other-apis/commerce_translation_v1_beta_oas3.json
|
|
5
|
+
*/
|
|
6
|
+
export declare class TranslationApi {
|
|
7
|
+
private client;
|
|
8
|
+
private readonly basePath;
|
|
9
|
+
constructor(client: EbayApiClient);
|
|
10
|
+
/**
|
|
11
|
+
* Translate listing text
|
|
12
|
+
*/
|
|
13
|
+
translate(from: string, to: string, translationContext: string, text: string[]): Promise<unknown>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Translation API - Translation services
|
|
3
|
+
* Based on: docs/sell-apps/other-apis/commerce_translation_v1_beta_oas3.json
|
|
4
|
+
*/
|
|
5
|
+
export class TranslationApi {
|
|
6
|
+
client;
|
|
7
|
+
basePath = '/commerce/translation/v1';
|
|
8
|
+
constructor(client) {
|
|
9
|
+
this.client = client;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Translate listing text
|
|
13
|
+
*/
|
|
14
|
+
async translate(from, to, translationContext, text) {
|
|
15
|
+
return await this.client.post(`${this.basePath}/translate`, {
|
|
16
|
+
from,
|
|
17
|
+
to,
|
|
18
|
+
translationContext,
|
|
19
|
+
text,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { EbayApiClient } from '../client.js';
|
|
2
|
+
/**
|
|
3
|
+
* VERO API - Verified Rights Owner program
|
|
4
|
+
* Based on: docs/sell-apps/other-apis/commerce_vero_v1_oas3.json
|
|
5
|
+
*/
|
|
6
|
+
export declare class VeroApi {
|
|
7
|
+
private client;
|
|
8
|
+
private readonly basePath;
|
|
9
|
+
constructor(client: EbayApiClient);
|
|
10
|
+
/**
|
|
11
|
+
* Create a VERO report to report intellectual property infringement
|
|
12
|
+
*/
|
|
13
|
+
createVeroReport(reportData: Record<string, unknown>): Promise<unknown>;
|
|
14
|
+
/**
|
|
15
|
+
* Get a specific VERO report by ID
|
|
16
|
+
*/
|
|
17
|
+
getVeroReport(veroReportId: string): Promise<unknown>;
|
|
18
|
+
/**
|
|
19
|
+
* Get VERO report items (listings reported for infringement)
|
|
20
|
+
*/
|
|
21
|
+
getVeroReportItems(filter?: string, limit?: number, offset?: number): Promise<unknown>;
|
|
22
|
+
/**
|
|
23
|
+
* Get a specific VERO reason code by ID
|
|
24
|
+
*/
|
|
25
|
+
getVeroReasonCode(veroReasonCodeId: string): Promise<unknown>;
|
|
26
|
+
/**
|
|
27
|
+
* Get all available VERO reason codes
|
|
28
|
+
*/
|
|
29
|
+
getVeroReasonCodes(): Promise<unknown>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VERO API - Verified Rights Owner program
|
|
3
|
+
* Based on: docs/sell-apps/other-apis/commerce_vero_v1_oas3.json
|
|
4
|
+
*/
|
|
5
|
+
export class VeroApi {
|
|
6
|
+
client;
|
|
7
|
+
basePath = '/commerce/vero/v1';
|
|
8
|
+
constructor(client) {
|
|
9
|
+
this.client = client;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Create a VERO report to report intellectual property infringement
|
|
13
|
+
*/
|
|
14
|
+
async createVeroReport(reportData) {
|
|
15
|
+
return await this.client.post(`${this.basePath}/vero_report`, reportData);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Get a specific VERO report by ID
|
|
19
|
+
*/
|
|
20
|
+
async getVeroReport(veroReportId) {
|
|
21
|
+
return await this.client.get(`${this.basePath}/vero_report/${veroReportId}`);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Get VERO report items (listings reported for infringement)
|
|
25
|
+
*/
|
|
26
|
+
async getVeroReportItems(filter, limit, offset) {
|
|
27
|
+
const params = {};
|
|
28
|
+
if (filter)
|
|
29
|
+
params.filter = filter;
|
|
30
|
+
if (limit)
|
|
31
|
+
params.limit = limit;
|
|
32
|
+
if (offset)
|
|
33
|
+
params.offset = offset;
|
|
34
|
+
return await this.client.get(`${this.basePath}/vero_report_items`, params);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Get a specific VERO reason code by ID
|
|
38
|
+
*/
|
|
39
|
+
async getVeroReasonCode(veroReasonCodeId) {
|
|
40
|
+
return await this.client.get(`${this.basePath}/vero_reason_code/${veroReasonCodeId}`);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get all available VERO reason codes
|
|
44
|
+
*/
|
|
45
|
+
async getVeroReasonCodes() {
|
|
46
|
+
return await this.client.get(`${this.basePath}/vero_reason_code`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth metadata endpoints for MCP server
|
|
3
|
+
* Implements RFC 9728 Protected Resource Metadata
|
|
4
|
+
*/
|
|
5
|
+
import type { Router } from 'express';
|
|
6
|
+
import type { OAuthServerMetadata } from './oauth-types.js';
|
|
7
|
+
export interface MetadataConfig {
|
|
8
|
+
/**
|
|
9
|
+
* Resource server URL (e.g., "http://localhost:3000")
|
|
10
|
+
*/
|
|
11
|
+
resourceServerUrl: string;
|
|
12
|
+
/**
|
|
13
|
+
* Authorization server URL or metadata
|
|
14
|
+
*/
|
|
15
|
+
authServerMetadata: string | OAuthServerMetadata;
|
|
16
|
+
/**
|
|
17
|
+
* Scopes supported by this resource server
|
|
18
|
+
*/
|
|
19
|
+
scopesSupported: string[];
|
|
20
|
+
/**
|
|
21
|
+
* Optional documentation URL for this resource server
|
|
22
|
+
*/
|
|
23
|
+
resourceDocumentation?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Resource name for display purposes
|
|
26
|
+
*/
|
|
27
|
+
resourceName?: string;
|
|
28
|
+
/**
|
|
29
|
+
* eBay environment (production or sandbox) - optional
|
|
30
|
+
* Used to indicate which eBay environment the server is configured for
|
|
31
|
+
*/
|
|
32
|
+
ebayEnvironment?: 'production' | 'sandbox';
|
|
33
|
+
/**
|
|
34
|
+
* eBay-specific OAuth scopes - optional
|
|
35
|
+
* Separate from MCP OAuth scopes, indicates what eBay API access is available
|
|
36
|
+
*/
|
|
37
|
+
ebayScopes?: string[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Create Express router with OAuth metadata endpoints
|
|
41
|
+
*/
|
|
42
|
+
export declare function createMetadataRouter(config: MetadataConfig): Router;
|
|
43
|
+
/**
|
|
44
|
+
* Helper to get Protected Resource Metadata URL from server URL
|
|
45
|
+
*/
|
|
46
|
+
export declare function getProtectedResourceMetadataUrl(serverUrl: string): string;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth metadata endpoints for MCP server
|
|
3
|
+
* Implements RFC 9728 Protected Resource Metadata
|
|
4
|
+
*/
|
|
5
|
+
import { Router as createRouter } from 'express';
|
|
6
|
+
/**
|
|
7
|
+
* Create Express router with OAuth metadata endpoints
|
|
8
|
+
*/
|
|
9
|
+
export function createMetadataRouter(config) {
|
|
10
|
+
const router = createRouter();
|
|
11
|
+
// RFC 9728: Protected Resource Metadata endpoint
|
|
12
|
+
// Path: /.well-known/oauth-protected-resource
|
|
13
|
+
router.get('/.well-known/oauth-protected-resource', (req, res) => {
|
|
14
|
+
const authServers = typeof config.authServerMetadata === 'string'
|
|
15
|
+
? [config.authServerMetadata]
|
|
16
|
+
: [config.authServerMetadata.issuer];
|
|
17
|
+
const metadata = {
|
|
18
|
+
resource: config.resourceServerUrl,
|
|
19
|
+
authorization_servers: authServers,
|
|
20
|
+
scopes_supported: config.scopesSupported,
|
|
21
|
+
};
|
|
22
|
+
if (config.resourceDocumentation) {
|
|
23
|
+
metadata.resource_documentation = config.resourceDocumentation;
|
|
24
|
+
}
|
|
25
|
+
res.json(metadata);
|
|
26
|
+
});
|
|
27
|
+
// Optional: Server info endpoint for debugging
|
|
28
|
+
router.get('/.well-known/mcp-server-info', (req, res) => {
|
|
29
|
+
const serverInfo = {
|
|
30
|
+
name: config.resourceName || 'MCP Resource Server',
|
|
31
|
+
version: '1.0.0',
|
|
32
|
+
resource_url: config.resourceServerUrl,
|
|
33
|
+
authorization_required: true,
|
|
34
|
+
scopes_supported: config.scopesSupported,
|
|
35
|
+
documentation: config.resourceDocumentation,
|
|
36
|
+
};
|
|
37
|
+
// Add eBay-specific information if provided
|
|
38
|
+
if (config.ebayEnvironment) {
|
|
39
|
+
serverInfo.ebay = {
|
|
40
|
+
environment: config.ebayEnvironment,
|
|
41
|
+
base_url: config.ebayEnvironment === 'production'
|
|
42
|
+
? 'https://api.ebay.com'
|
|
43
|
+
: 'https://api.sandbox.ebay.com',
|
|
44
|
+
scopes: config.ebayScopes || [],
|
|
45
|
+
note: 'MCP OAuth scopes (scopes_supported) are separate from eBay API OAuth scopes (ebay.scopes)',
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
res.json(serverInfo);
|
|
49
|
+
});
|
|
50
|
+
return router;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Helper to get Protected Resource Metadata URL from server URL
|
|
54
|
+
*/
|
|
55
|
+
export function getProtectedResourceMetadataUrl(serverUrl) {
|
|
56
|
+
const url = new URL(serverUrl);
|
|
57
|
+
url.pathname = '/.well-known/oauth-protected-resource';
|
|
58
|
+
return url.toString();
|
|
59
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth 2.1 middleware for Express
|
|
3
|
+
* Implements RFC 6750 Bearer Token authentication
|
|
4
|
+
*/
|
|
5
|
+
import type { Request, Response, NextFunction } from 'express';
|
|
6
|
+
import type { TokenVerifier } from './token-verifier.js';
|
|
7
|
+
import type { VerifiedToken } from './oauth-types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Extended Express Request with verified token
|
|
10
|
+
*/
|
|
11
|
+
export interface AuthenticatedRequest extends Request {
|
|
12
|
+
auth?: VerifiedToken;
|
|
13
|
+
}
|
|
14
|
+
export interface BearerAuthMiddlewareConfig {
|
|
15
|
+
/**
|
|
16
|
+
* Token verifier instance
|
|
17
|
+
*/
|
|
18
|
+
verifier: TokenVerifier;
|
|
19
|
+
/**
|
|
20
|
+
* Protected Resource Metadata URL for WWW-Authenticate header
|
|
21
|
+
*/
|
|
22
|
+
resourceMetadataUrl: string;
|
|
23
|
+
/**
|
|
24
|
+
* Realm for WWW-Authenticate header
|
|
25
|
+
*/
|
|
26
|
+
realm?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Create Bearer token authentication middleware
|
|
30
|
+
*/
|
|
31
|
+
export declare function createBearerAuthMiddleware(config: BearerAuthMiddlewareConfig): (req: AuthenticatedRequest, res: Response, next: NextFunction) => Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Optional middleware to check specific scopes
|
|
34
|
+
*/
|
|
35
|
+
export declare function requireScopes(requiredScopes: string[]): (req: AuthenticatedRequest, res: Response, next: NextFunction) => void;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth 2.1 middleware for Express
|
|
3
|
+
* Implements RFC 6750 Bearer Token authentication
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Create Bearer token authentication middleware
|
|
7
|
+
*/
|
|
8
|
+
export function createBearerAuthMiddleware(config) {
|
|
9
|
+
const realm = config.realm || 'mcp';
|
|
10
|
+
return async (req, res, next) => {
|
|
11
|
+
try {
|
|
12
|
+
// Extract token from Authorization header
|
|
13
|
+
const authHeader = req.headers.authorization;
|
|
14
|
+
if (!authHeader) {
|
|
15
|
+
sendUnauthorized(res, realm, config.resourceMetadataUrl, {
|
|
16
|
+
error: 'invalid_token',
|
|
17
|
+
error_description: 'No authorization header provided',
|
|
18
|
+
});
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
// Check Bearer scheme
|
|
22
|
+
const parts = authHeader.split(' ');
|
|
23
|
+
if (parts.length !== 2 || parts[0] !== 'Bearer') {
|
|
24
|
+
sendUnauthorized(res, realm, config.resourceMetadataUrl, {
|
|
25
|
+
error: 'invalid_token',
|
|
26
|
+
error_description: 'Invalid authorization header format. Expected: Bearer <token>',
|
|
27
|
+
});
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const token = parts[1];
|
|
31
|
+
// Verify token
|
|
32
|
+
try {
|
|
33
|
+
const verifiedToken = await config.verifier.verifyToken(token);
|
|
34
|
+
req.auth = verifiedToken;
|
|
35
|
+
next();
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
const errorMessage = error instanceof Error ? error.message : 'Token verification failed';
|
|
39
|
+
sendUnauthorized(res, realm, config.resourceMetadataUrl, {
|
|
40
|
+
error: 'invalid_token',
|
|
41
|
+
error_description: errorMessage,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
console.error('OAuth middleware error:', error);
|
|
47
|
+
res.status(500).json({
|
|
48
|
+
error: 'server_error',
|
|
49
|
+
error_description: 'Internal server error during authentication',
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Send 401 Unauthorized response with RFC 6750 compliant WWW-Authenticate header
|
|
56
|
+
*/
|
|
57
|
+
function sendUnauthorized(res, realm, resourceMetadataUrl, challenge) {
|
|
58
|
+
// Build WWW-Authenticate header per RFC 6750
|
|
59
|
+
let authenticateValue = `Bearer realm="${realm}", resource_metadata="${resourceMetadataUrl}"`;
|
|
60
|
+
if (challenge.error) {
|
|
61
|
+
authenticateValue += `, error="${challenge.error}"`;
|
|
62
|
+
}
|
|
63
|
+
if (challenge.error_description) {
|
|
64
|
+
authenticateValue += `, error_description="${challenge.error_description}"`;
|
|
65
|
+
}
|
|
66
|
+
if (challenge.scope) {
|
|
67
|
+
authenticateValue += `, scope="${challenge.scope}"`;
|
|
68
|
+
}
|
|
69
|
+
res.setHeader('WWW-Authenticate', authenticateValue);
|
|
70
|
+
res.status(401).json({
|
|
71
|
+
error: challenge.error || 'unauthorized',
|
|
72
|
+
error_description: challenge.error_description || 'Authorization required',
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Optional middleware to check specific scopes
|
|
77
|
+
*/
|
|
78
|
+
export function requireScopes(requiredScopes) {
|
|
79
|
+
return (req, res, next) => {
|
|
80
|
+
if (!req.auth) {
|
|
81
|
+
res.status(401).json({
|
|
82
|
+
error: 'unauthorized',
|
|
83
|
+
error_description: 'No authentication information found',
|
|
84
|
+
});
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const hasRequiredScopes = requiredScopes.every((scope) => req.auth.scopes.includes(scope));
|
|
88
|
+
if (!hasRequiredScopes) {
|
|
89
|
+
res.status(403).json({
|
|
90
|
+
error: 'insufficient_scope',
|
|
91
|
+
error_description: `Missing required scopes: ${requiredScopes.join(', ')}`,
|
|
92
|
+
required_scopes: requiredScopes,
|
|
93
|
+
provided_scopes: req.auth.scopes,
|
|
94
|
+
});
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
next();
|
|
98
|
+
};
|
|
99
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth 2.1 types for MCP server authorization
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* OAuth 2.0 Authorization Server Metadata (RFC 8414)
|
|
6
|
+
*/
|
|
7
|
+
export interface OAuthServerMetadata {
|
|
8
|
+
issuer: string;
|
|
9
|
+
authorization_endpoint: string;
|
|
10
|
+
token_endpoint: string;
|
|
11
|
+
registration_endpoint?: string;
|
|
12
|
+
jwks_uri?: string;
|
|
13
|
+
introspection_endpoint?: string;
|
|
14
|
+
response_types_supported: string[];
|
|
15
|
+
grant_types_supported?: string[];
|
|
16
|
+
token_endpoint_auth_methods_supported?: string[];
|
|
17
|
+
scopes_supported?: string[];
|
|
18
|
+
code_challenge_methods_supported?: string[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Protected Resource Metadata (RFC 9728)
|
|
22
|
+
*/
|
|
23
|
+
export interface ProtectedResourceMetadata {
|
|
24
|
+
resource: string;
|
|
25
|
+
authorization_servers: string[];
|
|
26
|
+
scopes_supported?: string[];
|
|
27
|
+
resource_documentation?: string;
|
|
28
|
+
resource_signing_alg_values_supported?: string[];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Verified access token payload
|
|
32
|
+
*/
|
|
33
|
+
export interface VerifiedToken {
|
|
34
|
+
token: string;
|
|
35
|
+
clientId: string;
|
|
36
|
+
scopes: string[];
|
|
37
|
+
expiresAt?: number;
|
|
38
|
+
audience?: string | string[];
|
|
39
|
+
subject?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Token introspection request (RFC 7662)
|
|
43
|
+
*/
|
|
44
|
+
export interface TokenIntrospectionRequest {
|
|
45
|
+
token: string;
|
|
46
|
+
token_type_hint?: 'access_token' | 'refresh_token';
|
|
47
|
+
client_id?: string;
|
|
48
|
+
client_secret?: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Token introspection response (RFC 7662)
|
|
52
|
+
*/
|
|
53
|
+
export interface TokenIntrospectionResponse {
|
|
54
|
+
active: boolean;
|
|
55
|
+
scope?: string;
|
|
56
|
+
client_id?: string;
|
|
57
|
+
username?: string;
|
|
58
|
+
token_type?: string;
|
|
59
|
+
exp?: number;
|
|
60
|
+
iat?: number;
|
|
61
|
+
nbf?: number;
|
|
62
|
+
sub?: string;
|
|
63
|
+
aud?: string | string[];
|
|
64
|
+
iss?: string;
|
|
65
|
+
jti?: string;
|
|
66
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { EbayConfig, EbayUserToken, StoredTokenData } from '../types/ebay.js';
|
|
2
|
+
/**
|
|
3
|
+
* Manages eBay OAuth 2.0 authentication
|
|
4
|
+
* Loads tokens exclusively from environment variables (.env file)
|
|
5
|
+
* Supports both client credentials (app tokens) and user access tokens with refresh
|
|
6
|
+
*/
|
|
7
|
+
export declare class EbayOAuthClient {
|
|
8
|
+
private config;
|
|
9
|
+
private appAccessToken;
|
|
10
|
+
private appAccessTokenExpiry;
|
|
11
|
+
private userTokens;
|
|
12
|
+
constructor(config: EbayConfig);
|
|
13
|
+
/**
|
|
14
|
+
* Initialize user tokens from environment variables only
|
|
15
|
+
* If EBAY_USER_REFRESH_TOKEN exists, automatically refresh to get a valid access token
|
|
16
|
+
*/
|
|
17
|
+
initialize(): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Check if user tokens are available
|
|
20
|
+
*/
|
|
21
|
+
hasUserTokens(): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Check if user access token is expired
|
|
24
|
+
*/
|
|
25
|
+
private isUserAccessTokenExpired;
|
|
26
|
+
/**
|
|
27
|
+
* Check if user refresh token is expired
|
|
28
|
+
*/
|
|
29
|
+
private isUserRefreshTokenExpired;
|
|
30
|
+
/**
|
|
31
|
+
* Get a valid access token, with priority order:
|
|
32
|
+
* 1. User access token (if available and valid, or refreshable)
|
|
33
|
+
* 2. App access token from client credentials (fallback)
|
|
34
|
+
*/
|
|
35
|
+
getAccessToken(): Promise<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Set user access token and refresh token
|
|
38
|
+
* Stores tokens in memory and updates .env file for persistence
|
|
39
|
+
*/
|
|
40
|
+
setUserTokens(accessToken: string, refreshToken: string, accessTokenExpiry?: number, refreshTokenExpiry?: number): void;
|
|
41
|
+
/**
|
|
42
|
+
* Get or refresh the app access token using the client credentials flow.
|
|
43
|
+
* This method ensures that a valid app access token is always available.
|
|
44
|
+
* Rate limit: 1,000 requests/day
|
|
45
|
+
*/
|
|
46
|
+
getOrRefreshAppAccessToken(): Promise<string>;
|
|
47
|
+
/**
|
|
48
|
+
* Exchange authorization code for user access token
|
|
49
|
+
* Note: After receiving tokens, manually add EBAY_USER_REFRESH_TOKEN to .env file
|
|
50
|
+
*/
|
|
51
|
+
exchangeCodeForToken(code: string): Promise<EbayUserToken>;
|
|
52
|
+
/**
|
|
53
|
+
* Refresh user access token using refresh token from .env
|
|
54
|
+
* This method is public and can be called by LLMs when encountering authentication errors
|
|
55
|
+
*/
|
|
56
|
+
refreshUserToken(): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Check if currently authenticated (either user or app credentials)
|
|
59
|
+
*/
|
|
60
|
+
isAuthenticated(): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Clear all authentication tokens from memory
|
|
63
|
+
* Note: To persist this change, remove EBAY_USER_REFRESH_TOKEN from .env
|
|
64
|
+
*/
|
|
65
|
+
clearAllTokens(): void;
|
|
66
|
+
/**
|
|
67
|
+
* Get current token info for debugging
|
|
68
|
+
*/
|
|
69
|
+
getTokenInfo(): {
|
|
70
|
+
hasUserToken: boolean;
|
|
71
|
+
hasAppAccessToken: boolean;
|
|
72
|
+
scopeInfo?: {
|
|
73
|
+
tokenScopes: string[];
|
|
74
|
+
environmentScopes: string[];
|
|
75
|
+
missingScopes: string[];
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Get internal user tokens (for debugging/status tools)
|
|
80
|
+
* @internal
|
|
81
|
+
*/
|
|
82
|
+
getUserTokens(): StoredTokenData | null;
|
|
83
|
+
/**
|
|
84
|
+
* Get internal app access token cached value (for debugging/status tools)
|
|
85
|
+
* @internal
|
|
86
|
+
*/
|
|
87
|
+
getCachedAppAccessToken(): string | null;
|
|
88
|
+
/**
|
|
89
|
+
* Get internal app access token expiry (for debugging/status tools)
|
|
90
|
+
* @internal
|
|
91
|
+
*/
|
|
92
|
+
getCachedAppAccessTokenExpiry(): number;
|
|
93
|
+
}
|