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
|
@@ -0,0 +1,316 @@
|
|
|
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
|
+
import { Effect, Either } from 'effect';
|
|
9
|
+
import process from 'node:process';
|
|
10
|
+
import { writeCliLine } from './cliOutput.js';
|
|
11
|
+
/**
|
|
12
|
+
* Checks that the current Node.js major version meets the minimum runtime.
|
|
13
|
+
*
|
|
14
|
+
* @returns A security check result for the active Node.js process.
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const result = checkNodeVersion();
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export const checkNodeVersion = () => {
|
|
21
|
+
const requiredVersion = 18;
|
|
22
|
+
const currentVersion = Number.parseInt(process.version.slice(1).split('.')[0], 10);
|
|
23
|
+
if (currentVersion >= requiredVersion) {
|
|
24
|
+
return {
|
|
25
|
+
check: 'Node.js Version',
|
|
26
|
+
passed: true,
|
|
27
|
+
message: `Node.js ${process.version} meets requirements (>= ${requiredVersion})`,
|
|
28
|
+
severity: 'info',
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
check: 'Node.js Version',
|
|
33
|
+
passed: false,
|
|
34
|
+
message: `Node.js ${process.version} is below required version ${requiredVersion}`,
|
|
35
|
+
severity: 'critical',
|
|
36
|
+
fix: `Install Node.js ${requiredVersion} or higher from https://nodejs.org/`,
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Checks whether `.env` files are ignored by git.
|
|
41
|
+
*
|
|
42
|
+
* @param projectRoot Absolute project root containing `.gitignore`.
|
|
43
|
+
* @returns A security check result for credential file ignore coverage.
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* const result = checkGitignore(process.cwd());
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export const checkGitignore = (projectRoot) => {
|
|
50
|
+
const gitignorePath = join(projectRoot, '.gitignore');
|
|
51
|
+
if (!existsSync(gitignorePath)) {
|
|
52
|
+
return {
|
|
53
|
+
check: '.gitignore Security',
|
|
54
|
+
passed: false,
|
|
55
|
+
message: 'No .gitignore file found',
|
|
56
|
+
severity: 'warning',
|
|
57
|
+
fix: 'Create a .gitignore file and add .env to it',
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const gitignoreContent = readFileSync(gitignorePath, 'utf-8');
|
|
61
|
+
const hasEnv = gitignoreContent.split('\n').some((line) => {
|
|
62
|
+
const trimmed = line.trim();
|
|
63
|
+
return trimmed === '.env' || trimmed === '*.env' || trimmed.startsWith('.env');
|
|
64
|
+
});
|
|
65
|
+
if (hasEnv) {
|
|
66
|
+
return {
|
|
67
|
+
check: '.gitignore Security',
|
|
68
|
+
passed: true,
|
|
69
|
+
message: '.env files are properly ignored by git',
|
|
70
|
+
severity: 'info',
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
check: '.gitignore Security',
|
|
75
|
+
passed: false,
|
|
76
|
+
message: '.env is not in .gitignore - credentials could be committed!',
|
|
77
|
+
severity: 'critical',
|
|
78
|
+
fix: 'Add ".env" to your .gitignore file immediately',
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Checks network connectivity to eBay API hosts.
|
|
83
|
+
*
|
|
84
|
+
* @returns A security check result for the eBay API reachability probe.
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* const result = await checkNetworkConnectivity();
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export const checkNetworkConnectivity = async () => {
|
|
91
|
+
const controller = new AbortController();
|
|
92
|
+
const timeout = setTimeout(() => controller.abort(), 5000);
|
|
93
|
+
const reached = await Effect.runPromise(Effect.either(Effect.tryPromise({
|
|
94
|
+
try: () => fetch('https://api.ebay.com/health', {
|
|
95
|
+
signal: controller.signal,
|
|
96
|
+
}),
|
|
97
|
+
catch: (error) => error,
|
|
98
|
+
}).pipe(Effect.ensuring(Effect.sync(() => {
|
|
99
|
+
clearTimeout(timeout);
|
|
100
|
+
})))));
|
|
101
|
+
if (Either.isLeft(reached)) {
|
|
102
|
+
return {
|
|
103
|
+
check: 'Network Connectivity',
|
|
104
|
+
passed: false,
|
|
105
|
+
message: 'Cannot reach eBay API servers',
|
|
106
|
+
severity: 'critical',
|
|
107
|
+
fix: 'Check your internet connection, proxy settings, and firewall',
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
const response = reached.right;
|
|
111
|
+
if (response.ok || response.status === 404) {
|
|
112
|
+
// 404 is fine, means we can reach eBay servers
|
|
113
|
+
return {
|
|
114
|
+
check: 'Network Connectivity',
|
|
115
|
+
passed: true,
|
|
116
|
+
message: 'Successfully connected to eBay API servers',
|
|
117
|
+
severity: 'info',
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
check: 'Network Connectivity',
|
|
122
|
+
passed: false,
|
|
123
|
+
message: `Unexpected response from eBay API: ${response.status}`,
|
|
124
|
+
severity: 'warning',
|
|
125
|
+
fix: 'Check your internet connection and firewall settings',
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Checks whether the compiled server entrypoint exists.
|
|
130
|
+
*
|
|
131
|
+
* @param projectRoot Absolute project root containing the `build` directory.
|
|
132
|
+
* @returns A security check result for build output presence.
|
|
133
|
+
* @example
|
|
134
|
+
* ```ts
|
|
135
|
+
* const result = checkProjectBuild(process.cwd());
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
export const checkProjectBuild = (projectRoot) => {
|
|
139
|
+
const buildPath = join(projectRoot, 'build', 'index.js');
|
|
140
|
+
if (existsSync(buildPath)) {
|
|
141
|
+
return {
|
|
142
|
+
check: 'Project Build',
|
|
143
|
+
passed: true,
|
|
144
|
+
message: 'Project is built and ready',
|
|
145
|
+
severity: 'info',
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
check: 'Project Build',
|
|
150
|
+
passed: false,
|
|
151
|
+
message: 'Project has not been built yet',
|
|
152
|
+
severity: 'warning',
|
|
153
|
+
fix: 'Run "npm run build" to build the project',
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* Checks whether project dependencies are installed.
|
|
158
|
+
*
|
|
159
|
+
* @param projectRoot Absolute project root containing `node_modules`.
|
|
160
|
+
* @returns A security check result for dependency installation state.
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* const result = checkDependencies(process.cwd());
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
export const checkDependencies = (projectRoot) => {
|
|
167
|
+
const nodeModulesPath = join(projectRoot, 'node_modules');
|
|
168
|
+
if (existsSync(nodeModulesPath)) {
|
|
169
|
+
return {
|
|
170
|
+
check: 'Dependencies',
|
|
171
|
+
passed: true,
|
|
172
|
+
message: 'Dependencies are installed',
|
|
173
|
+
severity: 'info',
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
return {
|
|
177
|
+
check: 'Project Dependencies',
|
|
178
|
+
passed: false,
|
|
179
|
+
message: 'Dependencies not installed',
|
|
180
|
+
severity: 'critical',
|
|
181
|
+
fix: 'Run "npm install" to install dependencies',
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
/**
|
|
185
|
+
* Checks whether `.env` is tracked by git.
|
|
186
|
+
*
|
|
187
|
+
* @param projectRoot Absolute project root containing `.git`.
|
|
188
|
+
* @returns A security check result for credential tracking risk.
|
|
189
|
+
* @example
|
|
190
|
+
* ```ts
|
|
191
|
+
* const result = checkGitTracking(process.cwd());
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
export const checkGitTracking = (projectRoot) => {
|
|
195
|
+
const gitPath = join(projectRoot, '.git');
|
|
196
|
+
const envPath = join(projectRoot, '.env');
|
|
197
|
+
if (!existsSync(gitPath)) {
|
|
198
|
+
return {
|
|
199
|
+
check: 'Git Repository',
|
|
200
|
+
passed: true,
|
|
201
|
+
message: 'Not a git repository (no tracking risk)',
|
|
202
|
+
severity: 'info',
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
if (!existsSync(envPath)) {
|
|
206
|
+
return {
|
|
207
|
+
check: 'Git Tracking',
|
|
208
|
+
passed: true,
|
|
209
|
+
message: '.env file does not exist yet',
|
|
210
|
+
severity: 'info',
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
const tracked = Effect.runSync(Effect.either(Effect.try({
|
|
214
|
+
try: () => execSync('git ls-files .env', {
|
|
215
|
+
cwd: projectRoot,
|
|
216
|
+
encoding: 'utf-8',
|
|
217
|
+
}).trim(),
|
|
218
|
+
catch: (error) => error,
|
|
219
|
+
})));
|
|
220
|
+
if (Either.isLeft(tracked)) {
|
|
221
|
+
return {
|
|
222
|
+
check: 'Git Tracking',
|
|
223
|
+
passed: true,
|
|
224
|
+
message: 'Unable to check git tracking (likely not tracked)',
|
|
225
|
+
severity: 'info',
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
if (tracked.right === '') {
|
|
229
|
+
return {
|
|
230
|
+
check: 'Git Tracking',
|
|
231
|
+
passed: true,
|
|
232
|
+
message: '.env is not tracked by git',
|
|
233
|
+
severity: 'info',
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
return {
|
|
237
|
+
check: 'Git Tracking',
|
|
238
|
+
passed: false,
|
|
239
|
+
message: '.env is tracked by git - SECURITY RISK!',
|
|
240
|
+
severity: 'critical',
|
|
241
|
+
fix: 'Run: git rm --cached .env && git commit -m "Remove .env from tracking"',
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
/**
|
|
245
|
+
* Runs all security checks used by setup and diagnostics commands.
|
|
246
|
+
*
|
|
247
|
+
* @param projectRoot Absolute project root to inspect.
|
|
248
|
+
* @returns Ordered security check results for CLI display and gating.
|
|
249
|
+
* @example
|
|
250
|
+
* ```ts
|
|
251
|
+
* const results = await runSecurityChecks(process.cwd());
|
|
252
|
+
* ```
|
|
253
|
+
*/
|
|
254
|
+
export const runSecurityChecks = async (projectRoot) => {
|
|
255
|
+
const results = [];
|
|
256
|
+
// Synchronous checks
|
|
257
|
+
results.push(checkNodeVersion());
|
|
258
|
+
results.push(checkGitignore(projectRoot));
|
|
259
|
+
results.push(checkProjectBuild(projectRoot));
|
|
260
|
+
results.push(checkDependencies(projectRoot));
|
|
261
|
+
results.push(checkGitTracking(projectRoot));
|
|
262
|
+
// Asynchronous checks
|
|
263
|
+
results.push(await checkNetworkConnectivity());
|
|
264
|
+
return results;
|
|
265
|
+
};
|
|
266
|
+
/**
|
|
267
|
+
* Displays security check results in the setup/diagnostics CLI.
|
|
268
|
+
*
|
|
269
|
+
* @param results Security check results returned by `runSecurityChecks`.
|
|
270
|
+
* @returns Nothing; results are written to stdout.
|
|
271
|
+
* @example
|
|
272
|
+
* ```ts
|
|
273
|
+
* displaySecurityResults(results);
|
|
274
|
+
* ```
|
|
275
|
+
*/
|
|
276
|
+
export const displaySecurityResults = (results) => {
|
|
277
|
+
writeCliLine(chalk.bold.cyan('\n🔒 Security & Environment Checks\n'));
|
|
278
|
+
for (const result of results) {
|
|
279
|
+
const icon = result.passed ? chalk.green('✓') : chalk.red('✗');
|
|
280
|
+
let severity = chalk.gray('[INFO]');
|
|
281
|
+
if (result.severity === 'critical') {
|
|
282
|
+
severity = chalk.red('[CRITICAL]');
|
|
283
|
+
}
|
|
284
|
+
else if (result.severity === 'warning') {
|
|
285
|
+
severity = chalk.yellow('[WARNING]');
|
|
286
|
+
}
|
|
287
|
+
writeCliLine(`${icon} ${chalk.bold(result.check)}: ${severity}`);
|
|
288
|
+
writeCliLine(` ${chalk.gray(result.message)}`);
|
|
289
|
+
if (result.fix) {
|
|
290
|
+
writeCliLine(` ${chalk.yellow('→ Fix:')} ${result.fix}`);
|
|
291
|
+
}
|
|
292
|
+
writeCliLine('');
|
|
293
|
+
}
|
|
294
|
+
const critical = results.filter((r) => !r.passed && r.severity === 'critical');
|
|
295
|
+
const warnings = results.filter((r) => !r.passed && r.severity === 'warning');
|
|
296
|
+
if (critical.length > 0) {
|
|
297
|
+
writeCliLine(chalk.red.bold(`⚠️ ${critical.length} critical issue(s) found. Please fix before continuing.\n`));
|
|
298
|
+
}
|
|
299
|
+
else if (warnings.length > 0) {
|
|
300
|
+
writeCliLine(chalk.yellow.bold(`⚠️ ${warnings.length} warning(s) found. Recommended to fix.\n`));
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
writeCliLine(chalk.green.bold('✅ All security checks passed!\n'));
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
/**
|
|
307
|
+
* Checks whether any security result should block setup.
|
|
308
|
+
*
|
|
309
|
+
* @param results Security check results to inspect.
|
|
310
|
+
* @returns `true` when at least one critical check failed.
|
|
311
|
+
* @example
|
|
312
|
+
* ```ts
|
|
313
|
+
* if (hasCriticalFailures(results)) process.exit(1);
|
|
314
|
+
* ```
|
|
315
|
+
*/
|
|
316
|
+
export const hasCriticalFailures = (results) => results.some((r) => !r.passed && r.severity === 'critical');
|
|
@@ -8,12 +8,14 @@ import { join } from 'path';
|
|
|
8
8
|
import chalk from 'chalk';
|
|
9
9
|
import { EbayOAuthClient } from '../auth/oauth.js';
|
|
10
10
|
import { getOAuthAuthorizationUrl } from '../config/environment.js';
|
|
11
|
-
import { parseEnvFile } from './
|
|
11
|
+
import { parseEnvFile } from './envParser.js';
|
|
12
12
|
import { getErrorMessage } from '../utils/errors.js';
|
|
13
|
+
import { Effect, Either } from 'effect';
|
|
14
|
+
import { writeCliLine } from './cliOutput.js';
|
|
13
15
|
/**
|
|
14
|
-
*
|
|
16
|
+
* Validates that the .env file exists and is readable.
|
|
15
17
|
*/
|
|
16
|
-
|
|
18
|
+
const validateEnvFile = (projectRoot) => {
|
|
17
19
|
const envPath = join(projectRoot, '.env');
|
|
18
20
|
if (!existsSync(envPath)) {
|
|
19
21
|
return {
|
|
@@ -23,27 +25,28 @@ function validateEnvFile(projectRoot) {
|
|
|
23
25
|
error: `.env file does not exist at ${envPath}`,
|
|
24
26
|
};
|
|
25
27
|
}
|
|
26
|
-
try
|
|
27
|
-
readFileSync(envPath, 'utf-8')
|
|
28
|
+
const readable = Effect.runSync(Effect.either(Effect.try({
|
|
29
|
+
try: () => readFileSync(envPath, 'utf-8'),
|
|
30
|
+
catch: (error) => error,
|
|
31
|
+
})));
|
|
32
|
+
if (Either.isRight(readable)) {
|
|
28
33
|
return {
|
|
29
34
|
test: '.env File Existence',
|
|
30
35
|
passed: true,
|
|
31
36
|
message: 'Configuration file exists and is readable',
|
|
32
37
|
};
|
|
33
38
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
}
|
|
39
|
+
return {
|
|
40
|
+
test: '.env File Existence',
|
|
41
|
+
passed: false,
|
|
42
|
+
message: 'Configuration file cannot be read',
|
|
43
|
+
error: getErrorMessage(readable.left),
|
|
44
|
+
};
|
|
45
|
+
};
|
|
43
46
|
/**
|
|
44
|
-
*
|
|
47
|
+
* Validates that required app credentials are present.
|
|
45
48
|
*/
|
|
46
|
-
|
|
49
|
+
const validateAppCredentials = (envVars) => {
|
|
47
50
|
const required = ['EBAY_CLIENT_ID', 'EBAY_CLIENT_SECRET', 'EBAY_REDIRECT_URI'];
|
|
48
51
|
const missing = [];
|
|
49
52
|
for (const key of required) {
|
|
@@ -64,11 +67,11 @@ function validateAppCredentials(envVars) {
|
|
|
64
67
|
passed: true,
|
|
65
68
|
message: 'All required app credentials are present',
|
|
66
69
|
};
|
|
67
|
-
}
|
|
70
|
+
};
|
|
68
71
|
/**
|
|
69
|
-
*
|
|
72
|
+
* Validates the configured eBay environment value.
|
|
70
73
|
*/
|
|
71
|
-
|
|
74
|
+
const validateEnvironment = (envVars) => {
|
|
72
75
|
const env = envVars.EBAY_ENVIRONMENT || 'sandbox';
|
|
73
76
|
if (env !== 'sandbox' && env !== 'production') {
|
|
74
77
|
return {
|
|
@@ -83,11 +86,11 @@ function validateEnvironment(envVars) {
|
|
|
83
86
|
passed: true,
|
|
84
87
|
message: `Environment set to "${env}"`,
|
|
85
88
|
};
|
|
86
|
-
}
|
|
89
|
+
};
|
|
87
90
|
/**
|
|
88
|
-
*
|
|
91
|
+
* Checks whether optional user tokens are configured.
|
|
89
92
|
*/
|
|
90
|
-
|
|
93
|
+
const validateUserTokens = (envVars) => {
|
|
91
94
|
const hasRefreshToken = envVars.EBAY_USER_REFRESH_TOKEN && envVars.EBAY_USER_REFRESH_TOKEN.trim() !== '';
|
|
92
95
|
if (!hasRefreshToken) {
|
|
93
96
|
return {
|
|
@@ -102,72 +105,81 @@ function validateUserTokens(envVars) {
|
|
|
102
105
|
passed: true,
|
|
103
106
|
message: 'User refresh token is configured',
|
|
104
107
|
};
|
|
105
|
-
}
|
|
108
|
+
};
|
|
106
109
|
/**
|
|
107
|
-
*
|
|
110
|
+
* Tests OAuth client initialization.
|
|
108
111
|
*/
|
|
109
|
-
async
|
|
110
|
-
|
|
112
|
+
const validateOAuthInitialization = async (config) => {
|
|
113
|
+
const initialized = await Effect.runPromise(Effect.either(Effect.gen(function* () {
|
|
111
114
|
const oauthClient = new EbayOAuthClient(config);
|
|
112
|
-
|
|
115
|
+
yield* oauthClient.initialize();
|
|
116
|
+
})));
|
|
117
|
+
if (Either.isRight(initialized)) {
|
|
113
118
|
return {
|
|
114
119
|
test: 'OAuth Client Initialization',
|
|
115
120
|
passed: true,
|
|
116
121
|
message: 'OAuth client initialized successfully',
|
|
117
122
|
};
|
|
118
123
|
}
|
|
119
|
-
|
|
124
|
+
return {
|
|
125
|
+
test: 'OAuth Client Initialization',
|
|
126
|
+
passed: false,
|
|
127
|
+
message: 'Failed to initialize OAuth client',
|
|
128
|
+
error: getErrorMessage(initialized.left),
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Tests OAuth URL generation.
|
|
133
|
+
*/
|
|
134
|
+
const validateOAuthURL = (config) => {
|
|
135
|
+
const redirectUri = config.redirectUri;
|
|
136
|
+
if (!redirectUri) {
|
|
120
137
|
return {
|
|
121
|
-
test: 'OAuth
|
|
138
|
+
test: 'OAuth URL Generation',
|
|
122
139
|
passed: false,
|
|
123
|
-
message: '
|
|
124
|
-
error:
|
|
140
|
+
message: 'Redirect URI is required for OAuth URL generation',
|
|
141
|
+
error: 'EBAY_REDIRECT_URI is not configured',
|
|
125
142
|
};
|
|
126
143
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
try {
|
|
133
|
-
if (!config.redirectUri) {
|
|
134
|
-
return {
|
|
135
|
-
test: 'OAuth URL Generation',
|
|
136
|
-
passed: false,
|
|
137
|
-
message: 'Redirect URI is required for OAuth URL generation',
|
|
138
|
-
error: 'EBAY_REDIRECT_URI is not configured',
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
const url = getOAuthAuthorizationUrl(config.clientId, config.redirectUri, config.environment);
|
|
142
|
-
if (!url.startsWith('http')) {
|
|
143
|
-
return {
|
|
144
|
-
test: 'OAuth URL Generation',
|
|
145
|
-
passed: false,
|
|
146
|
-
message: 'Invalid OAuth URL generated',
|
|
147
|
-
error: 'Generated URL is not valid',
|
|
148
|
-
};
|
|
149
|
-
}
|
|
144
|
+
const generated = Effect.runSync(Effect.either(Effect.try({
|
|
145
|
+
try: () => getOAuthAuthorizationUrl(config.clientId, redirectUri, config.environment),
|
|
146
|
+
catch: (error) => error,
|
|
147
|
+
})));
|
|
148
|
+
if (Either.isLeft(generated)) {
|
|
150
149
|
return {
|
|
151
150
|
test: 'OAuth URL Generation',
|
|
152
|
-
passed:
|
|
153
|
-
message: '
|
|
151
|
+
passed: false,
|
|
152
|
+
message: 'Failed to generate OAuth URL',
|
|
153
|
+
error: getErrorMessage(generated.left),
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
|
-
|
|
156
|
+
if (!generated.right.startsWith('http')) {
|
|
157
157
|
return {
|
|
158
158
|
test: 'OAuth URL Generation',
|
|
159
159
|
passed: false,
|
|
160
|
-
message: '
|
|
161
|
-
error:
|
|
160
|
+
message: 'Invalid OAuth URL generated',
|
|
161
|
+
error: 'Generated URL is not valid',
|
|
162
162
|
};
|
|
163
163
|
}
|
|
164
|
-
|
|
164
|
+
return {
|
|
165
|
+
test: 'OAuth URL Generation',
|
|
166
|
+
passed: true,
|
|
167
|
+
message: 'OAuth URL can be generated',
|
|
168
|
+
};
|
|
169
|
+
};
|
|
165
170
|
/**
|
|
166
|
-
*
|
|
171
|
+
* Runs all setup validation tests and prints their CLI summary.
|
|
172
|
+
*
|
|
173
|
+
* @param projectRoot Absolute project root containing the `.env` file to validate.
|
|
174
|
+
* @returns A summary containing individual validation results and pass/fail counts.
|
|
175
|
+
* @example
|
|
176
|
+
* ```ts
|
|
177
|
+
* const summary = await validateSetup(process.cwd());
|
|
178
|
+
* ```
|
|
167
179
|
*/
|
|
168
|
-
export async
|
|
180
|
+
export const validateSetup = async (projectRoot) => {
|
|
169
181
|
const results = [];
|
|
170
|
-
|
|
182
|
+
writeCliLine(chalk.bold.cyan('\n🧪 Running Configuration Tests...\n'));
|
|
171
183
|
// Test 1: .env file exists
|
|
172
184
|
const envFileResult = validateEnvFile(projectRoot);
|
|
173
185
|
results.push(envFileResult);
|
|
@@ -218,16 +230,16 @@ export async function validateSetup(projectRoot) {
|
|
|
218
230
|
const passed = results.filter((r) => r.passed).length;
|
|
219
231
|
const failed = results.length - passed;
|
|
220
232
|
// Print summary
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
233
|
+
writeCliLine(chalk.gray('\n' + '─'.repeat(60)));
|
|
234
|
+
writeCliLine(chalk.bold.white('\n📊 Validation Summary\n'));
|
|
235
|
+
writeCliLine(` Total Tests: ${results.length}`);
|
|
236
|
+
writeCliLine(` ${chalk.green('✓ Passed:')} ${passed}`);
|
|
237
|
+
writeCliLine(` ${chalk.red('✗ Failed:')} ${failed}`);
|
|
226
238
|
if (failed === 0) {
|
|
227
|
-
|
|
239
|
+
writeCliLine(chalk.green.bold('\n✨ All tests passed! Configuration is valid.\n'));
|
|
228
240
|
}
|
|
229
241
|
else {
|
|
230
|
-
|
|
242
|
+
writeCliLine(chalk.yellow.bold('\n⚠️ Some tests failed. Please review the errors above.\n'));
|
|
231
243
|
}
|
|
232
244
|
return {
|
|
233
245
|
totalTests: results.length,
|
|
@@ -235,42 +247,49 @@ export async function validateSetup(projectRoot) {
|
|
|
235
247
|
failed,
|
|
236
248
|
results,
|
|
237
249
|
};
|
|
238
|
-
}
|
|
250
|
+
};
|
|
239
251
|
/**
|
|
240
|
-
*
|
|
252
|
+
* Prints a single validation result.
|
|
241
253
|
*/
|
|
242
|
-
|
|
254
|
+
const printResult = (result) => {
|
|
243
255
|
const icon = result.passed ? chalk.green('✓') : chalk.red('✗');
|
|
244
256
|
const status = result.passed ? chalk.green('PASS') : chalk.red('FAIL');
|
|
245
|
-
|
|
246
|
-
|
|
257
|
+
writeCliLine(`${icon} ${chalk.bold(result.test)}: ${status}`);
|
|
258
|
+
writeCliLine(` ${chalk.gray(result.message)}`);
|
|
247
259
|
if (result.error) {
|
|
248
|
-
|
|
260
|
+
writeCliLine(` ${chalk.yellow('→')} ${chalk.yellow(result.error)}`);
|
|
249
261
|
}
|
|
250
|
-
|
|
251
|
-
}
|
|
262
|
+
writeCliLine('');
|
|
263
|
+
};
|
|
252
264
|
/**
|
|
253
|
-
*
|
|
265
|
+
* Displays setup recommendations based on validation results.
|
|
266
|
+
*
|
|
267
|
+
* @param summary Setup validation summary returned by `validateSetup`.
|
|
268
|
+
* @returns Nothing; recommendations are written to stdout.
|
|
269
|
+
* @example
|
|
270
|
+
* ```ts
|
|
271
|
+
* displayRecommendations(summary);
|
|
272
|
+
* ```
|
|
254
273
|
*/
|
|
255
|
-
export
|
|
274
|
+
export const displayRecommendations = (summary) => {
|
|
256
275
|
const hasUserTokens = summary.results.some((r) => r.test === 'User Tokens' && r.passed && !r.error);
|
|
257
|
-
|
|
276
|
+
writeCliLine(chalk.bold.cyan('💡 Recommendations:\n'));
|
|
258
277
|
if (!hasUserTokens) {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
278
|
+
writeCliLine(chalk.yellow(' ⚠️ User tokens not configured'));
|
|
279
|
+
writeCliLine(chalk.gray(' • You can only use app token for limited API access'));
|
|
280
|
+
writeCliLine(chalk.gray(' • To enable full API access, use the ebay_get_oauth_url tool'));
|
|
281
|
+
writeCliLine(chalk.gray(' • Then save your refresh token to EBAY_USER_REFRESH_TOKEN in .env\n'));
|
|
263
282
|
}
|
|
264
283
|
if (summary.failed > 0) {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
284
|
+
writeCliLine(chalk.red(' ❌ Configuration has errors'));
|
|
285
|
+
writeCliLine(chalk.gray(' • Review the failed tests above'));
|
|
286
|
+
writeCliLine(chalk.gray(' • Update your .env file with correct values'));
|
|
287
|
+
writeCliLine(chalk.gray(' • Run the setup wizard again: npm run setup\n'));
|
|
269
288
|
}
|
|
270
289
|
else {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
290
|
+
writeCliLine(chalk.green(' ✅ Configuration is complete and valid'));
|
|
291
|
+
writeCliLine(chalk.gray(' • Restart your MCP client (Claude Desktop, Cline, etc.)'));
|
|
292
|
+
writeCliLine(chalk.gray(' • The eBay MCP server should now be available'));
|
|
293
|
+
writeCliLine(chalk.gray(' • Try using tools like: ebay_get_user, ebay_get_oauth_url\n'));
|
|
275
294
|
}
|
|
276
|
-
}
|
|
295
|
+
};
|