ebay-mcp 1.13.2 → 1.14.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/README.de.md +3 -3
- package/README.es.md +3 -3
- package/README.fr.md +3 -3
- package/README.ja.md +3 -3
- package/README.ko.md +3 -3
- package/README.md +163 -41
- package/README.pt-BR.md +3 -3
- package/README.ru.md +3 -3
- package/README.zh-CN.md +3 -3
- package/build/api/account-management/account.js +633 -297
- package/build/api/analytics-and-report/analytics.js +111 -65
- package/build/api/client.js +199 -140
- package/build/api/clientRequestError.js +23 -0
- package/build/api/clientTrading.js +213 -0
- package/build/api/clientTradingError.js +4 -0
- package/build/api/communication/feedback.js +147 -59
- package/build/api/communication/message.js +134 -81
- package/build/api/communication/negotiation.js +65 -53
- package/build/api/communication/notification.js +458 -164
- package/build/api/developer/developer.js +99 -45
- package/build/api/index.js +23 -8
- package/build/api/listing-management/inventory.js +884 -338
- package/build/api/listing-metadata/metadata.js +416 -170
- package/build/api/listing-metadata/taxonomy.js +187 -42
- package/build/api/marketing-and-promotions/marketing.js +1392 -598
- package/build/api/marketing-and-promotions/recommendation.js +49 -24
- package/build/api/order-management/dispute.js +226 -45
- package/build/api/order-management/fulfillment.js +144 -71
- package/build/api/order-management/orderIssueHelpers.js +61 -0
- package/build/api/other/compliance.js +50 -38
- package/build/api/other/edelivery.js +603 -159
- package/build/api/other/finding.js +280 -0
- package/build/api/other/identity.js +30 -15
- package/build/api/other/translation.js +29 -14
- package/build/api/other/vero.js +113 -27
- package/build/api/rateLimitTracker.js +55 -0
- package/build/api/shared/request.js +189 -98
- package/build/api/trading/trading.js +154 -87
- package/build/auth/credentialSession.js +250 -0
- package/build/auth/oauth.js +298 -171
- package/build/auth/{oauth-metadata.js → oauthMetadata.js} +22 -6
- package/build/auth/oauthMiddleware.js +104 -0
- package/build/auth/{scope-utils.js → scopeUtils.js} +101 -28
- package/build/auth/tokenVerifier.js +243 -0
- package/build/auth/tokenVerifierError.js +21 -0
- package/build/config/environment.js +148 -113
- package/build/config/{tool-families.js → toolFamilies.js} +30 -14
- package/build/index.js +25 -19
- package/build/mcp/{http-transport.js → httpTransport.js} +102 -52
- package/build/mcp/readOnlyFilter.js +67 -0
- package/build/mcp/runtime.js +31 -13
- package/build/mcp/{tool-gating.js → toolGating.js} +77 -49
- package/build/mcp/{ui-bridge.js → uiBridge.js} +80 -23
- package/build/schemas/account-management/account.js +144 -6
- package/build/schemas/analytics/analytics.js +33 -19
- package/build/schemas/communication/messages.js +12 -42
- package/build/schemas/developer/developer.js +135 -0
- package/build/schemas/fulfillment/orders.js +183 -21
- package/build/schemas/index.js +27 -19
- package/build/schemas/inventory-management/inventory.js +17 -9
- package/build/schemas/marketing/marketing.js +480 -25
- package/build/schemas/metadata/metadata.js +11 -6
- package/build/schemas/other/finding.js +27 -0
- package/build/schemas/other/otherApis.js +424 -0
- package/build/schemas/taxonomy/taxonomy.js +11 -5
- package/build/scripts/{auto-setup.js → autoSetup.js} +87 -74
- package/build/scripts/{build-ui.js → buildUi.js} +6 -1
- package/build/scripts/{dev-sync.js → devSync.js} +169 -110
- package/build/scripts/diagnostics.js +52 -44
- package/build/scripts/{download-specs.js → downloadSpecs.js} +29 -21
- package/build/scripts/{interactive-setup.js → interactiveSetup.js} +84 -78
- package/build/scripts/setup.js +241 -178
- package/build/scripts/{setup-shared.js → setupShared.js} +29 -7
- package/build/scripts/skills.js +35 -27
- package/build/scripts/updateApiStatusDoc.js +71 -0
- package/build/serverHttp.js +90 -0
- package/build/skills/content.js +124 -118
- package/build/skills/index.js +22 -10
- package/build/skills/install.js +21 -10
- package/build/skills/markers.js +50 -15
- package/build/skills/{registry-snapshot.js → registrySnapshot.js} +8 -2
- package/build/skills/render.js +41 -14
- package/build/skills/targets.js +49 -17
- package/build/tools/categories/account.js +166 -264
- package/build/tools/categories/analytics.js +11 -22
- package/build/tools/categories/browse.js +17 -0
- package/build/tools/categories/communication.js +124 -399
- package/build/tools/categories/connector.js +23 -20
- package/build/tools/categories/developer.js +46 -159
- package/build/tools/categories/fulfillment.js +84 -215
- package/build/tools/categories/index.js +6 -14
- package/build/tools/categories/inventory.js +238 -293
- package/build/tools/categories/marketing.js +677 -39
- package/build/tools/categories/metadata.js +190 -117
- package/build/tools/categories/other.js +81 -208
- package/build/tools/categories/taxonomy.js +29 -20
- package/build/tools/categories/{token-management.js → tokenManagement.js} +187 -192
- package/build/tools/categories/trading.js +16 -47
- package/build/tools/contracts.js +34 -24
- package/build/tools/{define-tool.js → defineTool.js} +44 -29
- package/build/tools/registry.js +87 -29
- package/build/tools/schemas.js +3 -57
- package/build/tools/ui/archetypes.js +1 -0
- package/build/tools/ui/{map-helpers.js → mapHelpers.js} +69 -19
- package/build/tools/ui/maps.js +294 -80
- package/build/types/index.js +1 -1
- package/build/ui/card.html +14 -14
- package/build/ui/chart.html +14 -14
- package/build/ui/stat.html +87 -0
- package/build/ui/table.html +14 -14
- package/build/utils/apiStatusFeed.js +95 -0
- package/build/utils/cliOutput.js +15 -0
- package/build/utils/cliUi.js +108 -0
- package/build/utils/communication/feedback.js +57 -77
- package/build/utils/communication/message.js +69 -98
- package/build/utils/communication/negotiation.js +30 -57
- package/build/utils/communication/notification.js +112 -252
- package/build/utils/{date-converter.js → dateConverter.js} +62 -30
- package/build/utils/effectSchema.js +203 -0
- package/build/utils/effectSchemaAdapter.js +121 -0
- package/build/utils/effectSchemaChainMethods.js +146 -0
- package/build/utils/effectSchemaRefinements.js +104 -0
- package/build/utils/effectSchemaStringMethods.js +63 -0
- package/build/utils/effectSchemaTypes.js +47 -0
- package/build/utils/{env-parser.js → envParser.js} +10 -2
- package/build/utils/errors.js +7 -3
- package/build/utils/http.js +148 -89
- package/build/utils/{llm-client-detector.js → llmClientDetector.js} +295 -274
- package/build/utils/logger.js +127 -51
- package/build/utils/{oauth-helper.js → oauthHelper.js} +127 -90
- package/build/utils/other/compliance.js +18 -38
- package/build/utils/other/identity.js +2 -2
- package/build/utils/other/translation.js +4 -4
- package/build/utils/other/vero.js +36 -20
- package/build/utils/schemaHelpers.js +22 -0
- package/build/utils/scopeHelper.js +270 -0
- package/build/utils/securityChecker.js +316 -0
- package/build/utils/{setup-validator.js → setupValidator.js} +113 -94
- package/build/utils/{setup-wizard.js → setupWizard.js} +57 -46
- package/build/utils/{token-utils.js → tokenUtils.js} +2 -2
- package/build/utils/trading/trading.js +35 -0
- package/build/utils/typeGuards.js +12 -0
- package/build/utils/version.js +65 -29
- package/package.json +10 -8
- package/build/api/client-trading.js +0 -124
- package/build/api/communication/shared.js +0 -59
- package/build/api/shared/query-params.js +0 -16
- package/build/auth/credential-session.js +0 -166
- package/build/auth/oauth-middleware.js +0 -100
- package/build/auth/token-verifier.js +0 -186
- package/build/schemas/other/other-apis.js +0 -390
- package/build/scripts/update-api-status-doc.js +0 -44
- package/build/server-http.js +0 -85
- package/build/tools/definitions/marketing.js +0 -1381
- package/build/tools/tool-handlers/marketing.js +0 -312
- package/build/utils/account-management/account.js +0 -818
- package/build/utils/api-status-feed.js +0 -84
- package/build/utils/cli-ui.js +0 -47
- package/build/utils/order-management/dispute.js +0 -369
- package/build/utils/order-management/fulfillment.js +0 -205
- package/build/utils/other/edelivery.js +0 -235
- package/build/utils/schema-helpers.js +0 -13
- package/build/utils/scope-helper.js +0 -207
- package/build/utils/security-checker.js +0 -248
- package/build/utils/type-guards.js +0 -6
- /package/build/auth/{oauth-types.js → oauthTypes.js} +0 -0
- /package/build/{server-http.d.ts → serverHttp.d.ts} +0 -0
- /package/build/tools/ui/{view-models.js → viewModels.js} +0 -0
- /package/build/types/{ebay-enums.js → ebayEnums.js} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { z } from '
|
|
1
|
+
import { z } from '../../utils/effectSchema.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Effect-backed schemas for Identity API input validation
|
|
4
4
|
* Based on: src/api/other/identity.ts
|
|
5
5
|
* OpenAPI spec: docs/sell-apps/other-apis/commerce_identity_v1_oas3.json
|
|
6
6
|
* Types from: src/types/commerce_identity_v1_oas3.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { z } from '
|
|
1
|
+
import { z } from '../../utils/effectSchema.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Effect-backed schemas for Translation API input validation
|
|
4
4
|
* Based on: src/api/other/translation.ts
|
|
5
5
|
* OpenAPI spec: docs/sell-apps/other-apis/commerce_translation_v1_beta_oas3.json
|
|
6
6
|
* Types from: src/types/commerce_translation_v1_beta_oas3.ts
|
|
@@ -23,9 +23,9 @@ export const translateSchema = z.object({
|
|
|
23
23
|
description: 'The target language for translation (e.g., en_US, fr_FR, de_DE)',
|
|
24
24
|
})
|
|
25
25
|
.optional(),
|
|
26
|
-
|
|
26
|
+
translationContext: z
|
|
27
27
|
.string({
|
|
28
|
-
invalid_type_error: '
|
|
28
|
+
invalid_type_error: 'translationContext must be a string',
|
|
29
29
|
description: 'The listing entity to translate (ITEM_TITLE or ITEM_DESCRIPTION)',
|
|
30
30
|
})
|
|
31
31
|
.optional(),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { z } from '
|
|
1
|
+
import { z } from '../../utils/effectSchema.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Effect-backed schemas for VERO API input validation
|
|
4
4
|
* Based on: src/api/other/vero.ts
|
|
5
5
|
* OpenAPI spec: docs/sell-apps/other-apis/commerce_vero_v1_oas3.json
|
|
6
6
|
* Types from: src/types/commerce_vero_v1_oas3.ts
|
|
@@ -15,32 +15,48 @@ const filterSchema = z
|
|
|
15
15
|
description: 'Filter criteria for the query (e.g., date range)',
|
|
16
16
|
})
|
|
17
17
|
.optional();
|
|
18
|
-
// Reusable schema for limit parameter
|
|
18
|
+
// Reusable schema for limit parameter
|
|
19
19
|
const limitSchema = z
|
|
20
|
-
.
|
|
21
|
-
invalid_type_error: 'limit must be a
|
|
20
|
+
.number({
|
|
21
|
+
invalid_type_error: 'limit must be a number',
|
|
22
22
|
description: 'Maximum number of items to return',
|
|
23
23
|
})
|
|
24
|
+
.int()
|
|
25
|
+
.positive()
|
|
24
26
|
.optional();
|
|
25
|
-
// Reusable schema for offset parameter
|
|
27
|
+
// Reusable schema for offset parameter
|
|
26
28
|
const offsetSchema = z
|
|
27
|
-
.
|
|
28
|
-
invalid_type_error: 'offset must be a
|
|
29
|
+
.number({
|
|
30
|
+
invalid_type_error: 'offset must be a number',
|
|
29
31
|
description: 'Number of items to skip',
|
|
30
32
|
})
|
|
33
|
+
.int()
|
|
34
|
+
.nonnegative()
|
|
31
35
|
.optional();
|
|
36
|
+
const reportItemSchema = z
|
|
37
|
+
.object({
|
|
38
|
+
brand: z.string().optional(),
|
|
39
|
+
copyEmailToRightsOwner: z.boolean().optional(),
|
|
40
|
+
countries: z.array(z.string()).optional(),
|
|
41
|
+
detailedMessage: z.string().optional(),
|
|
42
|
+
itemId: z.string().optional(),
|
|
43
|
+
messageToSeller: z.string().optional(),
|
|
44
|
+
patent: z.string().optional(),
|
|
45
|
+
regions: z.array(z.string()).optional(),
|
|
46
|
+
veroReasonCodeId: z.string().optional(),
|
|
47
|
+
})
|
|
48
|
+
.passthrough();
|
|
32
49
|
/**
|
|
33
50
|
* Schema for createVeroReport method
|
|
34
51
|
* Endpoint: POST /vero_report
|
|
35
52
|
* Body: VeroReportItemsRequest - report data
|
|
36
53
|
*/
|
|
37
54
|
export const createVeroReportSchema = z.object({
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}),
|
|
55
|
+
reportData: z
|
|
56
|
+
.object({
|
|
57
|
+
reportItems: z.array(reportItemSchema).optional(),
|
|
58
|
+
})
|
|
59
|
+
.passthrough(),
|
|
44
60
|
});
|
|
45
61
|
/**
|
|
46
62
|
* Schema for getVeroReport method
|
|
@@ -48,11 +64,11 @@ export const createVeroReportSchema = z.object({
|
|
|
48
64
|
* Path: vero_report_id
|
|
49
65
|
*/
|
|
50
66
|
export const getVeroReportSchema = z.object({
|
|
51
|
-
|
|
67
|
+
veroReportId: z
|
|
52
68
|
.string({
|
|
53
69
|
message: 'VERO report ID is required',
|
|
54
|
-
required_error: '
|
|
55
|
-
invalid_type_error: '
|
|
70
|
+
required_error: 'veroReportId is required',
|
|
71
|
+
invalid_type_error: 'veroReportId must be a string',
|
|
56
72
|
description: 'The unique identifier of the VERO report',
|
|
57
73
|
})
|
|
58
74
|
.min(1, 'VERO report ID cannot be empty'),
|
|
@@ -73,11 +89,11 @@ export const getVeroReportItemsSchema = z.object({
|
|
|
73
89
|
* Path: vero_reason_code_id
|
|
74
90
|
*/
|
|
75
91
|
export const getVeroReasonCodeSchema = z.object({
|
|
76
|
-
|
|
92
|
+
veroReasonCodeId: z
|
|
77
93
|
.string({
|
|
78
94
|
message: 'VERO reason code ID is required',
|
|
79
|
-
required_error: '
|
|
80
|
-
invalid_type_error: '
|
|
95
|
+
required_error: 'veroReasonCodeId is required',
|
|
96
|
+
invalid_type_error: 'veroReasonCodeId must be a string',
|
|
81
97
|
description: 'The unique identifier of the VERO reason code',
|
|
82
98
|
})
|
|
83
99
|
.min(1, 'VERO reason code ID cannot be empty'),
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from '../utils/effectSchema.js';
|
|
2
|
+
/**
|
|
3
|
+
* Reusable schema builder for required string ID parameters.
|
|
4
|
+
*
|
|
5
|
+
* @param name - Human-readable parameter name used in validation messages.
|
|
6
|
+
* @param description - Schema description exposed to MCP clients.
|
|
7
|
+
* @returns Effect-backed string schema for a required ID parameter.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const listingId = idSchema('Listing ID', 'The eBay listing identifier');
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export const idSchema = (name, description) => {
|
|
15
|
+
const normalized = name.toLowerCase().replace(/\s+/g, '_');
|
|
16
|
+
return z.string({
|
|
17
|
+
message: `${name} is required`,
|
|
18
|
+
required_error: `${normalized} is required`,
|
|
19
|
+
invalid_type_error: `${normalized} must be a string`,
|
|
20
|
+
description,
|
|
21
|
+
});
|
|
22
|
+
};
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scope Helper - Manages eBay OAuth scopes
|
|
3
|
+
*/
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import { getDefaultScopes } from '../config/environment.js';
|
|
6
|
+
import { writeCliLine } from './cliOutput.js';
|
|
7
|
+
/**
|
|
8
|
+
* Get all available scope categories
|
|
9
|
+
*
|
|
10
|
+
* @returns Scope categories shown by setup guidance.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const categories = getScopeCategories();
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export const getScopeCategories = () => [
|
|
18
|
+
{
|
|
19
|
+
name: 'Inventory Management',
|
|
20
|
+
description: 'Create, read, update, and delete inventory items',
|
|
21
|
+
scopes: ['https://api.ebay.com/oauth/api_scope/sell.inventory'],
|
|
22
|
+
required: true,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'Order Fulfillment',
|
|
26
|
+
description: 'View and manage orders, shipping, and fulfillment',
|
|
27
|
+
scopes: [
|
|
28
|
+
'https://api.ebay.com/oauth/api_scope/sell.fulfillment',
|
|
29
|
+
'https://api.ebay.com/oauth/api_scope/sell.fulfillment.readonly',
|
|
30
|
+
],
|
|
31
|
+
required: true,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: 'Account Management',
|
|
35
|
+
description: 'Manage account settings, policies, and preferences',
|
|
36
|
+
scopes: [
|
|
37
|
+
'https://api.ebay.com/oauth/api_scope/sell.account',
|
|
38
|
+
'https://api.ebay.com/oauth/api_scope/sell.account.readonly',
|
|
39
|
+
],
|
|
40
|
+
required: true,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'Analytics & Reports',
|
|
44
|
+
description: 'Access sales analytics and performance reports',
|
|
45
|
+
scopes: [
|
|
46
|
+
'https://api.ebay.com/oauth/api_scope/sell.analytics.readonly',
|
|
47
|
+
'https://api.ebay.com/oauth/api_scope/sell.marketplace.insights.readonly',
|
|
48
|
+
],
|
|
49
|
+
required: false,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'Marketing & Promotions',
|
|
53
|
+
description: 'Create and manage marketing campaigns and promotions',
|
|
54
|
+
scopes: [
|
|
55
|
+
'https://api.ebay.com/oauth/api_scope/sell.marketing',
|
|
56
|
+
'https://api.ebay.com/oauth/api_scope/sell.marketing.readonly',
|
|
57
|
+
],
|
|
58
|
+
required: false,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'Finance & Payments',
|
|
62
|
+
description: 'Access financial data and payment information',
|
|
63
|
+
scopes: ['https://api.ebay.com/oauth/api_scope/sell.finances'],
|
|
64
|
+
required: false,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'Reputation & Feedback',
|
|
68
|
+
description: 'Manage seller reputation and customer feedback',
|
|
69
|
+
scopes: ['https://api.ebay.com/oauth/api_scope/sell.reputation'],
|
|
70
|
+
required: false,
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: 'Commerce Services',
|
|
74
|
+
description: 'Identity verification, notifications, and messaging',
|
|
75
|
+
scopes: [
|
|
76
|
+
'https://api.ebay.com/oauth/api_scope/commerce.identity.readonly',
|
|
77
|
+
'https://api.ebay.com/oauth/api_scope/commerce.notification.subscription',
|
|
78
|
+
'https://api.ebay.com/oauth/api_scope/sell.stores',
|
|
79
|
+
],
|
|
80
|
+
required: false,
|
|
81
|
+
},
|
|
82
|
+
];
|
|
83
|
+
/**
|
|
84
|
+
* Get recommended scopes for the environment
|
|
85
|
+
*
|
|
86
|
+
* @param environment - eBay environment whose recommended scopes should be returned.
|
|
87
|
+
* @returns Recommended OAuth scopes for that environment.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* const scopes = getRecommendedScopes('sandbox');
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export const getRecommendedScopes = (environment) => getDefaultScopes(environment);
|
|
95
|
+
/**
|
|
96
|
+
* Display scope selection interface
|
|
97
|
+
*
|
|
98
|
+
* @returns Nothing; writes scope category guidance to stdout.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```ts
|
|
102
|
+
* displayScopeCategories();
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
export const displayScopeCategories = () => {
|
|
106
|
+
writeCliLine(chalk.bold.cyan('\n📋 Available OAuth Scopes\n'));
|
|
107
|
+
const categories = getScopeCategories();
|
|
108
|
+
for (const category of categories) {
|
|
109
|
+
const badge = category.required ? chalk.green('[Required]') : chalk.gray('[Optional]');
|
|
110
|
+
writeCliLine(`${badge} ${chalk.bold.white(category.name)}`);
|
|
111
|
+
writeCliLine(` ${chalk.gray(category.description)}`);
|
|
112
|
+
writeCliLine(chalk.gray(` Scopes: ${category.scopes.length}`));
|
|
113
|
+
writeCliLine('');
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Verify if token has required scopes
|
|
118
|
+
*
|
|
119
|
+
* @param tokenScopes - OAuth scopes present on the token.
|
|
120
|
+
* @param requiredScopes - Scopes expected for the workflow or environment.
|
|
121
|
+
* @returns Scope coverage result with missing and extra scopes.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```ts
|
|
125
|
+
* const coverage = verifyScopesCoverage(tokenScopes, requiredScopes);
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
export const verifyScopesCoverage = (tokenScopes, requiredScopes) => {
|
|
129
|
+
const tokenScopeSet = new Set(tokenScopes);
|
|
130
|
+
const requiredScopeSet = new Set(requiredScopes);
|
|
131
|
+
const missingScopes = requiredScopes.filter((scope) => !tokenScopeSet.has(scope));
|
|
132
|
+
const extraScopes = tokenScopes.filter((scope) => !requiredScopeSet.has(scope));
|
|
133
|
+
return {
|
|
134
|
+
hasAllRequired: missingScopes.length === 0,
|
|
135
|
+
missingScopes,
|
|
136
|
+
extraScopes,
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Display scope verification results
|
|
141
|
+
*
|
|
142
|
+
* @param tokenScopes - OAuth scopes present on the token.
|
|
143
|
+
* @param environment - eBay environment whose recommended scopes should be checked.
|
|
144
|
+
* @returns Nothing; writes verification guidance to stdout.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```ts
|
|
148
|
+
* displayScopeVerification(tokenScopes, 'production');
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
export const displayScopeVerification = (tokenScopes, environment) => {
|
|
152
|
+
writeCliLine(chalk.bold.cyan('\n🔍 Scope Verification\n'));
|
|
153
|
+
const recommendedScopes = getRecommendedScopes(environment);
|
|
154
|
+
const verification = verifyScopesCoverage(tokenScopes, recommendedScopes);
|
|
155
|
+
writeCliLine(chalk.bold.white('Token Scopes:'));
|
|
156
|
+
writeCliLine(chalk.gray(` Total: ${tokenScopes.length}\n`));
|
|
157
|
+
if (verification.hasAllRequired) {
|
|
158
|
+
writeCliLine(chalk.green('✓ Token has all recommended scopes\n'));
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
writeCliLine(chalk.yellow('⚠️ Token is missing some recommended scopes\n'));
|
|
162
|
+
writeCliLine(chalk.bold.white('Missing Scopes:'));
|
|
163
|
+
for (const scope of verification.missingScopes) {
|
|
164
|
+
writeCliLine(chalk.yellow(` • ${scope}`));
|
|
165
|
+
}
|
|
166
|
+
writeCliLine('');
|
|
167
|
+
}
|
|
168
|
+
if (verification.extraScopes.length > 0) {
|
|
169
|
+
writeCliLine(chalk.gray('Additional Scopes (not in recommended list):'));
|
|
170
|
+
for (const scope of verification.extraScopes) {
|
|
171
|
+
writeCliLine(chalk.gray(` • ${scope}`));
|
|
172
|
+
}
|
|
173
|
+
writeCliLine('');
|
|
174
|
+
}
|
|
175
|
+
// Display scope categories and their status
|
|
176
|
+
const categories = getScopeCategories();
|
|
177
|
+
const tokenScopeSet = new Set(tokenScopes);
|
|
178
|
+
writeCliLine(chalk.bold.white('Coverage by Category:\n'));
|
|
179
|
+
for (const category of categories) {
|
|
180
|
+
const hasAllCategoryScopes = category.scopes.every((scope) => tokenScopeSet.has(scope));
|
|
181
|
+
const hasSomeCategoryScopes = category.scopes.some((scope) => tokenScopeSet.has(scope));
|
|
182
|
+
let status;
|
|
183
|
+
if (hasAllCategoryScopes) {
|
|
184
|
+
status = chalk.green('✓ Full');
|
|
185
|
+
}
|
|
186
|
+
else if (hasSomeCategoryScopes) {
|
|
187
|
+
status = chalk.yellow('◐ Partial');
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
status = chalk.red('✗ None');
|
|
191
|
+
}
|
|
192
|
+
const badge = category.required ? chalk.red('[Required]') : chalk.gray('[Optional]');
|
|
193
|
+
writeCliLine(`${status} ${badge} ${category.name}`);
|
|
194
|
+
}
|
|
195
|
+
writeCliLine('');
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* Get scope description for a full OAuth scope URL.
|
|
199
|
+
*
|
|
200
|
+
* @param scope - Full eBay OAuth scope URL.
|
|
201
|
+
* @returns Human-readable scope description, or a missing-description label.
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```ts
|
|
205
|
+
* const description = describeScopeFromOAuthUrl(scope);
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
export const describeScopeFromOAuthUrl = (scope) => {
|
|
209
|
+
const descriptions = {
|
|
210
|
+
'https://api.ebay.com/oauth/api_scope/sell.inventory': 'Manage inventory items and offers',
|
|
211
|
+
'https://api.ebay.com/oauth/api_scope/sell.fulfillment': 'Manage orders and shipping',
|
|
212
|
+
'https://api.ebay.com/oauth/api_scope/sell.fulfillment.readonly': 'View orders and shipping',
|
|
213
|
+
'https://api.ebay.com/oauth/api_scope/sell.account': 'Manage account settings',
|
|
214
|
+
'https://api.ebay.com/oauth/api_scope/sell.account.readonly': 'View account settings',
|
|
215
|
+
'https://api.ebay.com/oauth/api_scope/sell.analytics.readonly': 'View analytics and reports',
|
|
216
|
+
'https://api.ebay.com/oauth/api_scope/sell.marketing': 'Manage marketing campaigns',
|
|
217
|
+
'https://api.ebay.com/oauth/api_scope/sell.marketing.readonly': 'View marketing campaigns',
|
|
218
|
+
'https://api.ebay.com/oauth/api_scope/sell.finances': 'View financial data',
|
|
219
|
+
'https://api.ebay.com/oauth/api_scope/sell.reputation': 'Manage seller reputation',
|
|
220
|
+
'https://api.ebay.com/oauth/api_scope/commerce.identity.readonly': 'View user identity',
|
|
221
|
+
'https://api.ebay.com/oauth/api_scope/sell.stores': 'Manage eBay Stores',
|
|
222
|
+
'https://api.ebay.com/oauth/api_scope/commerce.notification.subscription': 'Manage notification subscriptions',
|
|
223
|
+
'https://api.ebay.com/oauth/api_scope/sell.marketplace.insights.readonly': 'View marketplace insights',
|
|
224
|
+
};
|
|
225
|
+
return descriptions[scope] || 'No description available';
|
|
226
|
+
};
|
|
227
|
+
/**
|
|
228
|
+
* Format scopes for display
|
|
229
|
+
*
|
|
230
|
+
* @param scopes - OAuth scopes to format.
|
|
231
|
+
* @returns Bulleted scope list for CLI display.
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```ts
|
|
235
|
+
* const text = formatScopesForDisplay(scopes);
|
|
236
|
+
* ```
|
|
237
|
+
*/
|
|
238
|
+
export const formatScopesForDisplay = (scopes) => scopes
|
|
239
|
+
.map((scope) => {
|
|
240
|
+
const shortName = scope.split('/').pop() || scope;
|
|
241
|
+
return ` • ${shortName}`;
|
|
242
|
+
})
|
|
243
|
+
.join('\n');
|
|
244
|
+
/**
|
|
245
|
+
* Get all scopes as a space-separated string
|
|
246
|
+
*
|
|
247
|
+
* @param environment - eBay environment whose scopes should be returned.
|
|
248
|
+
* @returns Recommended scopes joined for OAuth URL parameters.
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* ```ts
|
|
252
|
+
* const scopeParam = getAllScopesString('sandbox');
|
|
253
|
+
* ```
|
|
254
|
+
*/
|
|
255
|
+
export const getAllScopesString = (environment) => getRecommendedScopes(environment).join(' ');
|
|
256
|
+
/**
|
|
257
|
+
* Parse scope string to array
|
|
258
|
+
*
|
|
259
|
+
* @param scopeString - Space-delimited OAuth scope string.
|
|
260
|
+
* @returns Non-empty scope tokens.
|
|
261
|
+
*
|
|
262
|
+
* @example
|
|
263
|
+
* ```ts
|
|
264
|
+
* const scopes = parseScopeString(scopeParam);
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
export const parseScopeString = (scopeString) => scopeString
|
|
268
|
+
.split(/\s+/)
|
|
269
|
+
.map((s) => s.trim())
|
|
270
|
+
.filter((s) => s.length > 0);
|