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,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scope Helper - Manages eBay OAuth scopes
|
|
3
|
+
*/
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import { getDefaultScopes } from '../config/environment.js';
|
|
6
|
+
/**
|
|
7
|
+
* Get all available scope categories
|
|
8
|
+
*/
|
|
9
|
+
export function getScopeCategories() {
|
|
10
|
+
return [
|
|
11
|
+
{
|
|
12
|
+
name: 'Inventory Management',
|
|
13
|
+
description: 'Create, read, update, and delete inventory items',
|
|
14
|
+
scopes: ['https://api.ebay.com/oauth/api_scope/sell.inventory'],
|
|
15
|
+
required: true,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: 'Order Fulfillment',
|
|
19
|
+
description: 'View and manage orders, shipping, and fulfillment',
|
|
20
|
+
scopes: [
|
|
21
|
+
'https://api.ebay.com/oauth/api_scope/sell.fulfillment',
|
|
22
|
+
'https://api.ebay.com/oauth/api_scope/sell.fulfillment.readonly',
|
|
23
|
+
],
|
|
24
|
+
required: true,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'Account Management',
|
|
28
|
+
description: 'Manage account settings, policies, and preferences',
|
|
29
|
+
scopes: [
|
|
30
|
+
'https://api.ebay.com/oauth/api_scope/sell.account',
|
|
31
|
+
'https://api.ebay.com/oauth/api_scope/sell.account.readonly',
|
|
32
|
+
],
|
|
33
|
+
required: true,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'Analytics & Reports',
|
|
37
|
+
description: 'Access sales analytics and performance reports',
|
|
38
|
+
scopes: [
|
|
39
|
+
'https://api.ebay.com/oauth/api_scope/sell.analytics.readonly',
|
|
40
|
+
'https://api.ebay.com/oauth/api_scope/sell.marketplace.insights.readonly',
|
|
41
|
+
],
|
|
42
|
+
required: false,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: 'Marketing & Promotions',
|
|
46
|
+
description: 'Create and manage marketing campaigns and promotions',
|
|
47
|
+
scopes: [
|
|
48
|
+
'https://api.ebay.com/oauth/api_scope/sell.marketing',
|
|
49
|
+
'https://api.ebay.com/oauth/api_scope/sell.marketing.readonly',
|
|
50
|
+
],
|
|
51
|
+
required: false,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'Finance & Payments',
|
|
55
|
+
description: 'Access financial data and payment information',
|
|
56
|
+
scopes: ['https://api.ebay.com/oauth/api_scope/sell.finances'],
|
|
57
|
+
required: false,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: 'Reputation & Feedback',
|
|
61
|
+
description: 'Manage seller reputation and customer feedback',
|
|
62
|
+
scopes: ['https://api.ebay.com/oauth/api_scope/sell.reputation'],
|
|
63
|
+
required: false,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: 'Commerce Services',
|
|
67
|
+
description: 'Identity verification, notifications, and messaging',
|
|
68
|
+
scopes: [
|
|
69
|
+
'https://api.ebay.com/oauth/api_scope/commerce.identity.readonly',
|
|
70
|
+
'https://api.ebay.com/oauth/api_scope/commerce.notification.subscription',
|
|
71
|
+
'https://api.ebay.com/oauth/api_scope/sell.stores',
|
|
72
|
+
],
|
|
73
|
+
required: false,
|
|
74
|
+
},
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Get recommended scopes for the environment
|
|
79
|
+
*/
|
|
80
|
+
export function getRecommendedScopes(environment) {
|
|
81
|
+
return getDefaultScopes(environment);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Display scope selection interface
|
|
85
|
+
*/
|
|
86
|
+
export function displayScopeCategories() {
|
|
87
|
+
console.log(chalk.bold.cyan('\nš Available OAuth Scopes\n'));
|
|
88
|
+
const categories = getScopeCategories();
|
|
89
|
+
for (const category of categories) {
|
|
90
|
+
const badge = category.required ? chalk.green('[Required]') : chalk.gray('[Optional]');
|
|
91
|
+
console.log(`${badge} ${chalk.bold.white(category.name)}`);
|
|
92
|
+
console.log(` ${chalk.gray(category.description)}`);
|
|
93
|
+
console.log(chalk.gray(` Scopes: ${category.scopes.length}`));
|
|
94
|
+
console.log('');
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Verify if token has required scopes
|
|
99
|
+
*/
|
|
100
|
+
export function verifyScopesCoverage(tokenScopes, requiredScopes) {
|
|
101
|
+
const tokenScopeSet = new Set(tokenScopes);
|
|
102
|
+
const requiredScopeSet = new Set(requiredScopes);
|
|
103
|
+
const missingScopes = requiredScopes.filter((scope) => !tokenScopeSet.has(scope));
|
|
104
|
+
const extraScopes = tokenScopes.filter((scope) => !requiredScopeSet.has(scope));
|
|
105
|
+
return {
|
|
106
|
+
hasAllRequired: missingScopes.length === 0,
|
|
107
|
+
missingScopes,
|
|
108
|
+
extraScopes,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Display scope verification results
|
|
113
|
+
*/
|
|
114
|
+
export function displayScopeVerification(tokenScopes, environment) {
|
|
115
|
+
console.log(chalk.bold.cyan('\nš Scope Verification\n'));
|
|
116
|
+
const recommendedScopes = getRecommendedScopes(environment);
|
|
117
|
+
const verification = verifyScopesCoverage(tokenScopes, recommendedScopes);
|
|
118
|
+
console.log(chalk.bold.white('Token Scopes:'));
|
|
119
|
+
console.log(chalk.gray(` Total: ${tokenScopes.length}\n`));
|
|
120
|
+
if (verification.hasAllRequired) {
|
|
121
|
+
console.log(chalk.green('ā Token has all recommended scopes\n'));
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
console.log(chalk.yellow('ā ļø Token is missing some recommended scopes\n'));
|
|
125
|
+
console.log(chalk.bold.white('Missing Scopes:'));
|
|
126
|
+
for (const scope of verification.missingScopes) {
|
|
127
|
+
console.log(chalk.yellow(` ⢠${scope}`));
|
|
128
|
+
}
|
|
129
|
+
console.log('');
|
|
130
|
+
}
|
|
131
|
+
if (verification.extraScopes.length > 0) {
|
|
132
|
+
console.log(chalk.gray('Additional Scopes (not in recommended list):'));
|
|
133
|
+
for (const scope of verification.extraScopes) {
|
|
134
|
+
console.log(chalk.gray(` ⢠${scope}`));
|
|
135
|
+
}
|
|
136
|
+
console.log('');
|
|
137
|
+
}
|
|
138
|
+
// Display scope categories and their status
|
|
139
|
+
const categories = getScopeCategories();
|
|
140
|
+
const tokenScopeSet = new Set(tokenScopes);
|
|
141
|
+
console.log(chalk.bold.white('Coverage by Category:\n'));
|
|
142
|
+
for (const category of categories) {
|
|
143
|
+
const hasAllCategoryScopes = category.scopes.every((scope) => tokenScopeSet.has(scope));
|
|
144
|
+
const hasSomeCategoryScopes = category.scopes.some((scope) => tokenScopeSet.has(scope));
|
|
145
|
+
let status;
|
|
146
|
+
if (hasAllCategoryScopes) {
|
|
147
|
+
status = chalk.green('ā Full');
|
|
148
|
+
}
|
|
149
|
+
else if (hasSomeCategoryScopes) {
|
|
150
|
+
status = chalk.yellow('ā Partial');
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
status = chalk.red('ā None');
|
|
154
|
+
}
|
|
155
|
+
const badge = category.required ? chalk.red('[Required]') : chalk.gray('[Optional]');
|
|
156
|
+
console.log(`${status} ${badge} ${category.name}`);
|
|
157
|
+
}
|
|
158
|
+
console.log('');
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Get scope description
|
|
162
|
+
*/
|
|
163
|
+
export function getScopeDescription(scope) {
|
|
164
|
+
const descriptions = {
|
|
165
|
+
'https://api.ebay.com/oauth/api_scope/sell.inventory': 'Manage inventory items and offers',
|
|
166
|
+
'https://api.ebay.com/oauth/api_scope/sell.fulfillment': 'Manage orders and shipping',
|
|
167
|
+
'https://api.ebay.com/oauth/api_scope/sell.fulfillment.readonly': 'View orders and shipping',
|
|
168
|
+
'https://api.ebay.com/oauth/api_scope/sell.account': 'Manage account settings',
|
|
169
|
+
'https://api.ebay.com/oauth/api_scope/sell.account.readonly': 'View account settings',
|
|
170
|
+
'https://api.ebay.com/oauth/api_scope/sell.analytics.readonly': 'View analytics and reports',
|
|
171
|
+
'https://api.ebay.com/oauth/api_scope/sell.marketing': 'Manage marketing campaigns',
|
|
172
|
+
'https://api.ebay.com/oauth/api_scope/sell.marketing.readonly': 'View marketing campaigns',
|
|
173
|
+
'https://api.ebay.com/oauth/api_scope/sell.finances': 'View financial data',
|
|
174
|
+
'https://api.ebay.com/oauth/api_scope/sell.reputation': 'Manage seller reputation',
|
|
175
|
+
'https://api.ebay.com/oauth/api_scope/commerce.identity.readonly': 'View user identity',
|
|
176
|
+
'https://api.ebay.com/oauth/api_scope/sell.stores': 'Manage eBay Stores',
|
|
177
|
+
'https://api.ebay.com/oauth/api_scope/commerce.notification.subscription': 'Manage notification subscriptions',
|
|
178
|
+
'https://api.ebay.com/oauth/api_scope/sell.marketplace.insights.readonly': 'View marketplace insights',
|
|
179
|
+
};
|
|
180
|
+
return descriptions[scope] || 'No description available';
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Format scopes for display
|
|
184
|
+
*/
|
|
185
|
+
export function formatScopesForDisplay(scopes) {
|
|
186
|
+
return scopes
|
|
187
|
+
.map((scope) => {
|
|
188
|
+
const shortName = scope.split('/').pop() || scope;
|
|
189
|
+
return ` ⢠${shortName}`;
|
|
190
|
+
})
|
|
191
|
+
.join('\n');
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Get all scopes as a space-separated string
|
|
195
|
+
*/
|
|
196
|
+
export function getAllScopesString(environment) {
|
|
197
|
+
return getRecommendedScopes(environment).join(' ');
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Parse scope string to array
|
|
201
|
+
*/
|
|
202
|
+
export function parseScopeString(scopeString) {
|
|
203
|
+
return scopeString
|
|
204
|
+
.split(/\s+/)
|
|
205
|
+
.map((s) => s.trim())
|
|
206
|
+
.filter((s) => s.length > 0);
|
|
207
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security Checker - Pre-flight security and environment checks
|
|
3
|
+
*/
|
|
4
|
+
export interface SecurityCheckResult {
|
|
5
|
+
check: string;
|
|
6
|
+
passed: boolean;
|
|
7
|
+
message: string;
|
|
8
|
+
severity: 'critical' | 'warning' | 'info';
|
|
9
|
+
fix?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Check Node.js version meets requirements
|
|
13
|
+
*/
|
|
14
|
+
export declare function checkNodeVersion(): SecurityCheckResult;
|
|
15
|
+
/**
|
|
16
|
+
* Check if .env is in .gitignore
|
|
17
|
+
*/
|
|
18
|
+
export declare function checkGitignore(projectRoot: string): SecurityCheckResult;
|
|
19
|
+
/**
|
|
20
|
+
* Check network connectivity to eBay APIs
|
|
21
|
+
*/
|
|
22
|
+
export declare function checkNetworkConnectivity(): Promise<SecurityCheckResult>;
|
|
23
|
+
/**
|
|
24
|
+
* Check if project is built
|
|
25
|
+
*/
|
|
26
|
+
export declare function checkProjectBuild(projectRoot: string): SecurityCheckResult;
|
|
27
|
+
/**
|
|
28
|
+
* Check if dependencies are installed
|
|
29
|
+
*/
|
|
30
|
+
export declare function checkDependencies(projectRoot: string): SecurityCheckResult;
|
|
31
|
+
/**
|
|
32
|
+
* Check if git repo is initialized and .env is not tracked
|
|
33
|
+
*/
|
|
34
|
+
export declare function checkGitTracking(projectRoot: string): SecurityCheckResult;
|
|
35
|
+
/**
|
|
36
|
+
* Run all security checks
|
|
37
|
+
*/
|
|
38
|
+
export declare function runSecurityChecks(projectRoot: string): Promise<SecurityCheckResult[]>;
|
|
39
|
+
/**
|
|
40
|
+
* Display security check results
|
|
41
|
+
*/
|
|
42
|
+
export declare function displaySecurityResults(results: SecurityCheckResult[]): void;
|
|
43
|
+
/**
|
|
44
|
+
* Check if there are critical failures
|
|
45
|
+
*/
|
|
46
|
+
export declare function hasCriticalFailures(results: SecurityCheckResult[]): boolean;
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security Checker - Pre-flight security and environment checks
|
|
3
|
+
*/
|
|
4
|
+
import { existsSync, readFileSync } from 'fs';
|
|
5
|
+
import { join } from 'path';
|
|
6
|
+
import { execSync } from 'child_process';
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
/**
|
|
9
|
+
* Check Node.js version meets requirements
|
|
10
|
+
*/
|
|
11
|
+
export function checkNodeVersion() {
|
|
12
|
+
const requiredVersion = 18;
|
|
13
|
+
const currentVersion = parseInt(process.version.slice(1).split('.')[0], 10);
|
|
14
|
+
if (currentVersion >= requiredVersion) {
|
|
15
|
+
return {
|
|
16
|
+
check: 'Node.js Version',
|
|
17
|
+
passed: true,
|
|
18
|
+
message: `Node.js ${process.version} meets requirements (>= ${requiredVersion})`,
|
|
19
|
+
severity: 'info',
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
check: 'Node.js Version',
|
|
24
|
+
passed: false,
|
|
25
|
+
message: `Node.js ${process.version} is below required version ${requiredVersion}`,
|
|
26
|
+
severity: 'critical',
|
|
27
|
+
fix: `Install Node.js ${requiredVersion} or higher from https://nodejs.org/`,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Check if .env is in .gitignore
|
|
32
|
+
*/
|
|
33
|
+
export function checkGitignore(projectRoot) {
|
|
34
|
+
const gitignorePath = join(projectRoot, '.gitignore');
|
|
35
|
+
if (!existsSync(gitignorePath)) {
|
|
36
|
+
return {
|
|
37
|
+
check: '.gitignore Security',
|
|
38
|
+
passed: false,
|
|
39
|
+
message: 'No .gitignore file found',
|
|
40
|
+
severity: 'warning',
|
|
41
|
+
fix: 'Create a .gitignore file and add .env to it',
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
const gitignoreContent = readFileSync(gitignorePath, 'utf-8');
|
|
45
|
+
const hasEnv = gitignoreContent.split('\n').some((line) => {
|
|
46
|
+
const trimmed = line.trim();
|
|
47
|
+
return trimmed === '.env' || trimmed === '*.env' || trimmed.startsWith('.env');
|
|
48
|
+
});
|
|
49
|
+
if (hasEnv) {
|
|
50
|
+
return {
|
|
51
|
+
check: '.gitignore Security',
|
|
52
|
+
passed: true,
|
|
53
|
+
message: '.env files are properly ignored by git',
|
|
54
|
+
severity: 'info',
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
check: '.gitignore Security',
|
|
59
|
+
passed: false,
|
|
60
|
+
message: '.env is not in .gitignore - credentials could be committed!',
|
|
61
|
+
severity: 'critical',
|
|
62
|
+
fix: 'Add ".env" to your .gitignore file immediately',
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Check network connectivity to eBay APIs
|
|
67
|
+
*/
|
|
68
|
+
export async function checkNetworkConnectivity() {
|
|
69
|
+
try {
|
|
70
|
+
const controller = new AbortController();
|
|
71
|
+
const timeout = setTimeout(() => controller.abort(), 5000);
|
|
72
|
+
const response = await fetch('https://api.ebay.com/health', {
|
|
73
|
+
signal: controller.signal,
|
|
74
|
+
});
|
|
75
|
+
clearTimeout(timeout);
|
|
76
|
+
if (response.ok || response.status === 404) {
|
|
77
|
+
// 404 is fine, means we can reach eBay servers
|
|
78
|
+
return {
|
|
79
|
+
check: 'Network Connectivity',
|
|
80
|
+
passed: true,
|
|
81
|
+
message: 'Successfully connected to eBay API servers',
|
|
82
|
+
severity: 'info',
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
check: 'Network Connectivity',
|
|
87
|
+
passed: false,
|
|
88
|
+
message: `Unexpected response from eBay API: ${response.status}`,
|
|
89
|
+
severity: 'warning',
|
|
90
|
+
fix: 'Check your internet connection and firewall settings',
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
return {
|
|
95
|
+
check: 'Network Connectivity',
|
|
96
|
+
passed: false,
|
|
97
|
+
message: 'Cannot reach eBay API servers',
|
|
98
|
+
severity: 'critical',
|
|
99
|
+
fix: 'Check your internet connection, proxy settings, and firewall',
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Check if project is built
|
|
105
|
+
*/
|
|
106
|
+
export function checkProjectBuild(projectRoot) {
|
|
107
|
+
const buildPath = join(projectRoot, 'build', 'index.js');
|
|
108
|
+
if (existsSync(buildPath)) {
|
|
109
|
+
return {
|
|
110
|
+
check: 'Project Build',
|
|
111
|
+
passed: true,
|
|
112
|
+
message: 'Project is built and ready',
|
|
113
|
+
severity: 'info',
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
check: 'Project Build',
|
|
118
|
+
passed: false,
|
|
119
|
+
message: 'Project has not been built yet',
|
|
120
|
+
severity: 'warning',
|
|
121
|
+
fix: 'Run "npm run build" to build the project',
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Check if dependencies are installed
|
|
126
|
+
*/
|
|
127
|
+
export function checkDependencies(projectRoot) {
|
|
128
|
+
const nodeModulesPath = join(projectRoot, 'node_modules');
|
|
129
|
+
if (existsSync(nodeModulesPath)) {
|
|
130
|
+
return {
|
|
131
|
+
check: 'Dependencies',
|
|
132
|
+
passed: true,
|
|
133
|
+
message: 'Dependencies are installed',
|
|
134
|
+
severity: 'info',
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
check: 'Project Dependencies',
|
|
139
|
+
passed: false,
|
|
140
|
+
message: 'Dependencies not installed',
|
|
141
|
+
severity: 'critical',
|
|
142
|
+
fix: 'Run "npm install" to install dependencies',
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Check if git repo is initialized and .env is not tracked
|
|
147
|
+
*/
|
|
148
|
+
export function checkGitTracking(projectRoot) {
|
|
149
|
+
const gitPath = join(projectRoot, '.git');
|
|
150
|
+
const envPath = join(projectRoot, '.env');
|
|
151
|
+
if (!existsSync(gitPath)) {
|
|
152
|
+
return {
|
|
153
|
+
check: 'Git Repository',
|
|
154
|
+
passed: true,
|
|
155
|
+
message: 'Not a git repository (no tracking risk)',
|
|
156
|
+
severity: 'info',
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
if (!existsSync(envPath)) {
|
|
160
|
+
return {
|
|
161
|
+
check: 'Git Tracking',
|
|
162
|
+
passed: true,
|
|
163
|
+
message: '.env file does not exist yet',
|
|
164
|
+
severity: 'info',
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
try {
|
|
168
|
+
const result = execSync('git ls-files .env', {
|
|
169
|
+
cwd: projectRoot,
|
|
170
|
+
encoding: 'utf-8',
|
|
171
|
+
}).trim();
|
|
172
|
+
if (result === '') {
|
|
173
|
+
return {
|
|
174
|
+
check: 'Git Tracking',
|
|
175
|
+
passed: true,
|
|
176
|
+
message: '.env is not tracked by git',
|
|
177
|
+
severity: 'info',
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
check: 'Git Tracking',
|
|
182
|
+
passed: false,
|
|
183
|
+
message: '.env is tracked by git - SECURITY RISK!',
|
|
184
|
+
severity: 'critical',
|
|
185
|
+
fix: 'Run: git rm --cached .env && git commit -m "Remove .env from tracking"',
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
return {
|
|
190
|
+
check: 'Git Tracking',
|
|
191
|
+
passed: true,
|
|
192
|
+
message: 'Unable to check git tracking (likely not tracked)',
|
|
193
|
+
severity: 'info',
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Run all security checks
|
|
199
|
+
*/
|
|
200
|
+
export async function runSecurityChecks(projectRoot) {
|
|
201
|
+
const results = [];
|
|
202
|
+
// Synchronous checks
|
|
203
|
+
results.push(checkNodeVersion());
|
|
204
|
+
results.push(checkGitignore(projectRoot));
|
|
205
|
+
results.push(checkProjectBuild(projectRoot));
|
|
206
|
+
results.push(checkDependencies(projectRoot));
|
|
207
|
+
results.push(checkGitTracking(projectRoot));
|
|
208
|
+
// Asynchronous checks
|
|
209
|
+
results.push(await checkNetworkConnectivity());
|
|
210
|
+
return results;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Display security check results
|
|
214
|
+
*/
|
|
215
|
+
export function displaySecurityResults(results) {
|
|
216
|
+
console.log(chalk.bold.cyan('\nš Security & Environment Checks\n'));
|
|
217
|
+
for (const result of results) {
|
|
218
|
+
const icon = result.passed ? chalk.green('ā') : chalk.red('ā');
|
|
219
|
+
const severity = result.severity === 'critical'
|
|
220
|
+
? chalk.red('[CRITICAL]')
|
|
221
|
+
: result.severity === 'warning'
|
|
222
|
+
? chalk.yellow('[WARNING]')
|
|
223
|
+
: chalk.gray('[INFO]');
|
|
224
|
+
console.log(`${icon} ${chalk.bold(result.check)}: ${severity}`);
|
|
225
|
+
console.log(` ${chalk.gray(result.message)}`);
|
|
226
|
+
if (result.fix) {
|
|
227
|
+
console.log(` ${chalk.yellow('ā Fix:')} ${result.fix}`);
|
|
228
|
+
}
|
|
229
|
+
console.log('');
|
|
230
|
+
}
|
|
231
|
+
const critical = results.filter((r) => !r.passed && r.severity === 'critical');
|
|
232
|
+
const warnings = results.filter((r) => !r.passed && r.severity === 'warning');
|
|
233
|
+
if (critical.length > 0) {
|
|
234
|
+
console.log(chalk.red.bold(`ā ļø ${critical.length} critical issue(s) found. Please fix before continuing.\n`));
|
|
235
|
+
}
|
|
236
|
+
else if (warnings.length > 0) {
|
|
237
|
+
console.log(chalk.yellow.bold(`ā ļø ${warnings.length} warning(s) found. Recommended to fix.\n`));
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
console.log(chalk.green.bold('ā
All security checks passed!\n'));
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Check if there are critical failures
|
|
245
|
+
*/
|
|
246
|
+
export function hasCriticalFailures(results) {
|
|
247
|
+
return results.some((r) => !r.passed && r.severity === 'critical');
|
|
248
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Setup Validation Module
|
|
3
|
+
*
|
|
4
|
+
* Tests the configuration after setup to ensure everything is working properly.
|
|
5
|
+
*/
|
|
6
|
+
export interface ValidationResult {
|
|
7
|
+
test: string;
|
|
8
|
+
passed: boolean;
|
|
9
|
+
message: string;
|
|
10
|
+
error?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ValidationSummary {
|
|
13
|
+
totalTests: number;
|
|
14
|
+
passed: number;
|
|
15
|
+
failed: number;
|
|
16
|
+
results: ValidationResult[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Run all validation tests
|
|
20
|
+
*/
|
|
21
|
+
export declare function validateSetup(projectRoot: string): Promise<ValidationSummary>;
|
|
22
|
+
/**
|
|
23
|
+
* Display recommendations based on validation results
|
|
24
|
+
*/
|
|
25
|
+
export declare function displayRecommendations(summary: ValidationSummary): void;
|