@teambit/api-server 1.0.995 → 1.0.997
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/dist/api-for-ide.d.ts
CHANGED
|
@@ -157,8 +157,8 @@ export declare class APIForIDE {
|
|
|
157
157
|
[relativePath: string]: string;
|
|
158
158
|
}>;
|
|
159
159
|
catObject(hash: string): Promise<string>;
|
|
160
|
-
logFile(filePath: string): Promise<import("@teambit/component-log/component-log.main.runtime").FileLog[]>;
|
|
161
|
-
blame(filePath: string): Promise<import("@teambit/component-log/component-log.main.runtime").BlameLineInfo[]>;
|
|
160
|
+
logFile(filePath: string): Promise<import("@teambit/component-log/dist/component-log.main.runtime").FileLog[]>;
|
|
161
|
+
blame(filePath: string): Promise<import("@teambit/component-log/dist/component-log.main.runtime").BlameLineInfo[]>;
|
|
162
162
|
changedFilesFromParent(id: string): Promise<FileHashDiffFromParent[]>;
|
|
163
163
|
getConfigForDiff(id: string): Promise<{
|
|
164
164
|
version?: string;
|
|
@@ -28,12 +28,36 @@ export declare class ApiServerMain {
|
|
|
28
28
|
private watcher;
|
|
29
29
|
private installer;
|
|
30
30
|
private importer;
|
|
31
|
+
private serverToken?;
|
|
31
32
|
constructor(workspace: Workspace, logger: Logger, express: ExpressMain, watcher: WatcherMain, installer: InstallMain, importer: ImporterMain);
|
|
32
33
|
runApiServer(options: {
|
|
33
34
|
port: number;
|
|
34
35
|
compile: boolean;
|
|
35
36
|
}): Promise<unknown>;
|
|
36
37
|
writeUsedPort(port: number): void;
|
|
38
|
+
/**
|
|
39
|
+
* Generate a fresh per-server bearer token and persist it to a 0600 file.
|
|
40
|
+
* Clients (e.g. the bit-vscode extension) read this file and send the token
|
|
41
|
+
* as `Authorization: Bearer <token>` on every request.
|
|
42
|
+
*
|
|
43
|
+
* Backwards compatibility: clients that don't yet know about this file (older
|
|
44
|
+
* extension versions) won't send the header and will receive 401 with a
|
|
45
|
+
* message pointing them at the upgrade. Old bit-server versions don't write
|
|
46
|
+
* this file, so a new client checking for it gracefully falls back to no
|
|
47
|
+
* auth header — meaning a NEW extension keeps working against an OLD
|
|
48
|
+
* bit-server.
|
|
49
|
+
*/
|
|
50
|
+
private writeServerToken;
|
|
51
|
+
private getServerTokenFilePath;
|
|
52
|
+
/**
|
|
53
|
+
* Authentication middleware: requires `Authorization: Bearer <serverToken>`
|
|
54
|
+
* on every request except OPTIONS preflight (handled by cors) and the
|
|
55
|
+
* unauthenticated `/api/_health` liveness probe.
|
|
56
|
+
*
|
|
57
|
+
* Runs before bodyParser so unauthenticated requests can't trigger
|
|
58
|
+
* large-body parsing.
|
|
59
|
+
*/
|
|
60
|
+
private createAuthMiddleware;
|
|
37
61
|
/**
|
|
38
62
|
* Monitor the parent process (typically VSCode) and shut down if it dies.
|
|
39
63
|
*
|
|
@@ -25,13 +25,27 @@ function _fsExtra() {
|
|
|
25
25
|
};
|
|
26
26
|
return data;
|
|
27
27
|
}
|
|
28
|
+
function _crypto() {
|
|
29
|
+
const data = _interopRequireDefault(require("crypto"));
|
|
30
|
+
_crypto = function () {
|
|
31
|
+
return data;
|
|
32
|
+
};
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
28
35
|
function _express() {
|
|
29
|
-
const data = require("
|
|
36
|
+
const data = _interopRequireDefault(require("express"));
|
|
30
37
|
_express = function () {
|
|
31
38
|
return data;
|
|
32
39
|
};
|
|
33
40
|
return data;
|
|
34
41
|
}
|
|
42
|
+
function _express2() {
|
|
43
|
+
const data = require("@teambit/express");
|
|
44
|
+
_express2 = function () {
|
|
45
|
+
return data;
|
|
46
|
+
};
|
|
47
|
+
return data;
|
|
48
|
+
}
|
|
35
49
|
function _logger() {
|
|
36
50
|
const data = require("@teambit/logger");
|
|
37
51
|
_logger = function () {
|
|
@@ -289,6 +303,7 @@ class ApiServerMain {
|
|
|
289
303
|
this.watcher = watcher;
|
|
290
304
|
this.installer = installer;
|
|
291
305
|
this.importer = importer;
|
|
306
|
+
_defineProperty(this, "serverToken", void 0);
|
|
292
307
|
}
|
|
293
308
|
async runApiServer(options) {
|
|
294
309
|
if (!this.workspace) {
|
|
@@ -325,13 +340,27 @@ class ApiServerMain {
|
|
|
325
340
|
compile: options.compile
|
|
326
341
|
});
|
|
327
342
|
const port = options.port || (await this.getRandomPort());
|
|
328
|
-
|
|
343
|
+
|
|
344
|
+
// Generate a per-server auth token and persist it to a 0600 file before
|
|
345
|
+
// any HTTP request can be handled. Clients (e.g. the bit-vscode extension)
|
|
346
|
+
// read it from <workspace.scope.path>/server-token.txt and send it as
|
|
347
|
+
// `Authorization: Bearer <token>`. See createAuthMiddleware below.
|
|
348
|
+
this.writeServerToken();
|
|
349
|
+
|
|
350
|
+
// Create the app *before* express.createApp registers routes, so the auth
|
|
351
|
+
// middleware runs before bodyParser — unauthenticated requests can't
|
|
352
|
+
// trigger large-body parsing. CORS is registered before auth so 401
|
|
353
|
+
// responses still carry CORS headers; otherwise browser-based clients
|
|
354
|
+
// (bit-vscode) see a misleading CORS failure instead of the JSON 401.
|
|
355
|
+
const app = (0, _express().default)();
|
|
329
356
|
app.use((0, _cors().default)({
|
|
330
357
|
origin(origin, callback) {
|
|
331
358
|
callback(null, true);
|
|
332
359
|
},
|
|
333
360
|
credentials: true
|
|
334
361
|
}));
|
|
362
|
+
app.use(this.createAuthMiddleware());
|
|
363
|
+
this.express.createApp(app);
|
|
335
364
|
const proxyHeaders = {
|
|
336
365
|
Authorization: `${_scope().DEFAULT_AUTH_TYPE} ${_scope().Http.getToken()}`,
|
|
337
366
|
origin: '',
|
|
@@ -414,6 +443,61 @@ class ApiServerMain {
|
|
|
414
443
|
_fsExtra().default.writeFileSync(filePath, port.toString());
|
|
415
444
|
}
|
|
416
445
|
|
|
446
|
+
/**
|
|
447
|
+
* Generate a fresh per-server bearer token and persist it to a 0600 file.
|
|
448
|
+
* Clients (e.g. the bit-vscode extension) read this file and send the token
|
|
449
|
+
* as `Authorization: Bearer <token>` on every request.
|
|
450
|
+
*
|
|
451
|
+
* Backwards compatibility: clients that don't yet know about this file (older
|
|
452
|
+
* extension versions) won't send the header and will receive 401 with a
|
|
453
|
+
* message pointing them at the upgrade. Old bit-server versions don't write
|
|
454
|
+
* this file, so a new client checking for it gracefully falls back to no
|
|
455
|
+
* auth header — meaning a NEW extension keeps working against an OLD
|
|
456
|
+
* bit-server.
|
|
457
|
+
*/
|
|
458
|
+
writeServerToken() {
|
|
459
|
+
const token = _crypto().default.randomBytes(32).toString('hex');
|
|
460
|
+
const filePath = this.getServerTokenFilePath();
|
|
461
|
+
_fsExtra().default.writeFileSync(filePath, token, {
|
|
462
|
+
mode: 0o600
|
|
463
|
+
});
|
|
464
|
+
// Node's `mode` write option is only honored when the file is created.
|
|
465
|
+
// chmod explicitly so a pre-existing file with broader permissions gets
|
|
466
|
+
// tightened to 0600.
|
|
467
|
+
_fsExtra().default.chmodSync(filePath, 0o600);
|
|
468
|
+
this.serverToken = token;
|
|
469
|
+
}
|
|
470
|
+
getServerTokenFilePath() {
|
|
471
|
+
return (0, _path().join)(this.workspace.scope.path, 'server-token.txt');
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Authentication middleware: requires `Authorization: Bearer <serverToken>`
|
|
476
|
+
* on every request except OPTIONS preflight (handled by cors) and the
|
|
477
|
+
* unauthenticated `/api/_health` liveness probe.
|
|
478
|
+
*
|
|
479
|
+
* Runs before bodyParser so unauthenticated requests can't trigger
|
|
480
|
+
* large-body parsing.
|
|
481
|
+
*/
|
|
482
|
+
createAuthMiddleware() {
|
|
483
|
+
return (req, res, next) => {
|
|
484
|
+
if (req.method === 'OPTIONS') return next();
|
|
485
|
+
// Use req.path (not req.url) so query strings don't bypass the
|
|
486
|
+
// health-check exemption — e.g. /api/_health?cache-buster=1.
|
|
487
|
+
if (req.path === '/api/_health') return next();
|
|
488
|
+
const provided = parseBearerToken(req.headers.authorization);
|
|
489
|
+
if (!this.serverToken || provided !== this.serverToken) {
|
|
490
|
+
this.logger.debug(`api-server: rejected unauthenticated request to ${req.path}`);
|
|
491
|
+
res.status(401).jsonp({
|
|
492
|
+
error: 'unauthorized',
|
|
493
|
+
message: 'This bit-server requires authentication. Please upgrade your bit VS Code extension to the latest version.'
|
|
494
|
+
});
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
return next();
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
|
|
417
501
|
/**
|
|
418
502
|
* Monitor the parent process (typically VSCode) and shut down if it dies.
|
|
419
503
|
*
|
|
@@ -515,9 +599,20 @@ class ApiServerMain {
|
|
|
515
599
|
}
|
|
516
600
|
}
|
|
517
601
|
exports.ApiServerMain = ApiServerMain;
|
|
518
|
-
_defineProperty(ApiServerMain, "dependencies", [_cli().CLIAspect, _workspace().WorkspaceAspect, _logger().LoggerAspect,
|
|
602
|
+
_defineProperty(ApiServerMain, "dependencies", [_cli().CLIAspect, _workspace().WorkspaceAspect, _logger().LoggerAspect, _express2().ExpressAspect, _watcher().WatcherAspect, _snapping().SnappingAspect, _lanes().LanesAspect, _install().InstallAspect, _export().ExportAspect, _checkout().CheckoutAspect, _componentLog().ComponentLogAspect, _importer().ImporterAspect, _componentCompare().ComponentCompareAspect, _generator().GeneratorAspect, _remove().RemoveAspect, _config().ConfigAspect, _application().ApplicationAspect, _deprecation().DeprecationAspect, _envs().EnvsAspect, _graph().GraphAspect, _scope2().ScopeAspect, _component().ComponentAspect, _schema().SchemaAspect]);
|
|
519
603
|
_defineProperty(ApiServerMain, "runtime", _cli().MainRuntime);
|
|
520
604
|
_apiServer().ApiServerAspect.addRuntime(ApiServerMain);
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* Extract the token from an `Authorization: Bearer <token>` header.
|
|
608
|
+
* Lenient on scheme casing and surrounding whitespace so a slightly
|
|
609
|
+
* non-canonical client header doesn't get rejected.
|
|
610
|
+
*/
|
|
611
|
+
function parseBearerToken(header) {
|
|
612
|
+
if (!header) return undefined;
|
|
613
|
+
const match = header.match(/^\s*Bearer\s+(\S+)\s*$/i);
|
|
614
|
+
return match?.[1];
|
|
615
|
+
}
|
|
521
616
|
var _default = exports.default = ApiServerMain;
|
|
522
617
|
|
|
523
618
|
//# sourceMappingURL=api-server.main.runtime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_cli","data","require","_toolboxNetwork","_fsExtra","_interopRequireDefault","_express","_logger","_lanes","_remove","_snapping","_generator","_componentCompare","_componentLog","_watcher","_config","_export","_checkout","_install","_importer","_component","_workspace","_harmonyModules","_cors","_httpProxyMiddleware","_apiServer","_cli2","_server","_ide","_apiForIde","_sseEvents","_path","_child_process","_cliRaw","_application","_deprecation","_envs","_scope","_legacy","_graph","_scope2","_schema","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","ApiServerMain","constructor","workspace","logger","express","watcher","installer","importer","runApiServer","options","Error","process","cwd","registerOnComponentChange","component","files","removedFiles","sendEventsToClients","id","toStringWithoutVersion","registerOnBitmapChange","lastModifiedTimestamp","bitMap","getLastModifiedBitmapThroughBit","secondsPassedSinceLastModified","Date","now","debug","importCurrentObjects","registerOnWorkspaceConfigChange","scope","registerOnPostExport","registerPostInstall","watch","preCompile","compile","port","getRandomPort","app","createApp","use","cors","origin","callback","credentials","proxyHeaders","Authorization","DEFAULT_AUTH_TYPE","Http","getToken","symphonyUrl","getSymphonyUrl","createProxyMiddleware","target","changeOrigin","headers","on","error","err","req","res","writeHead","end","proxyReq","fixRequestBody","proxyRes","proxyReqWs","entries","forEach","key","setHeader","pathFilter","ws","secure","server","listen","Promise","resolve","reject","consoleSuccess","writeUsedPort","startParentProcessMonitor","filePath","getServerPortFilePath","fs","writeFileSync","toString","originalPpid","ppid","parentInfo","getProcessInfo","pid","platform","checkInterval","intervalId","setInterval","currentPpid","clearInterval","exit","unref","psCommand","output","execSync","encoding","timeout","trim","startingPort","randomNumber","Math","floor","random","Port","getPort","getExistingUsedPort","fileContent","readFile","parseInt","code","undefined","join","path","provider","cli","loggerMain","snapping","lanes","exporter","checkout","componentLog","componentCompare","generator","remove","config","application","deprecation","envs","graph","schema","createLogger","ApiServerAspect","apiServer","register","ServerCmd","apiForIDE","APIForIDE","cliRoute","CLIRoute","cliRawRoute","CLIRawRoute","ideRoute","IDERoute","sseEventsRoute","SSEEventsRoute","exports","CLIAspect","WorkspaceAspect","LoggerAspect","ExpressAspect","WatcherAspect","SnappingAspect","LanesAspect","InstallAspect","ExportAspect","CheckoutAspect","ComponentLogAspect","ImporterAspect","ComponentCompareAspect","GeneratorAspect","RemoveAspect","ConfigAspect","ApplicationAspect","DeprecationAspect","EnvsAspect","GraphAspect","ScopeAspect","ComponentAspect","SchemaAspect","MainRuntime","addRuntime","_default"],"sources":["api-server.main.runtime.ts"],"sourcesContent":["import type { CLIMain } from '@teambit/cli';\nimport { CLIAspect, MainRuntime } from '@teambit/cli';\nimport { Port } from '@teambit/toolbox.network.get-port';\nimport fs from 'fs-extra';\nimport type { ExpressMain } from '@teambit/express';\nimport { ExpressAspect } from '@teambit/express';\nimport type { Logger, LoggerMain } from '@teambit/logger';\nimport { LoggerAspect } from '@teambit/logger';\nimport type { LanesMain } from '@teambit/lanes';\nimport { LanesAspect } from '@teambit/lanes';\nimport type { RemoveMain } from '@teambit/remove';\nimport { RemoveAspect } from '@teambit/remove';\nimport type { SnappingMain } from '@teambit/snapping';\nimport { SnappingAspect } from '@teambit/snapping';\nimport type { GeneratorMain } from '@teambit/generator';\nimport { GeneratorAspect } from '@teambit/generator';\nimport type { ComponentCompareMain } from '@teambit/component-compare';\nimport { ComponentCompareAspect } from '@teambit/component-compare';\nimport type { ComponentLogMain } from '@teambit/component-log';\nimport { ComponentLogAspect } from '@teambit/component-log';\nimport type { WatcherMain } from '@teambit/watcher';\nimport { WatcherAspect } from '@teambit/watcher';\nimport type { ConfigMain } from '@teambit/config';\nimport { ConfigAspect } from '@teambit/config';\nimport type { ExportMain } from '@teambit/export';\nimport { ExportAspect } from '@teambit/export';\nimport type { CheckoutMain } from '@teambit/checkout';\nimport { CheckoutAspect } from '@teambit/checkout';\nimport type { InstallMain } from '@teambit/install';\nimport { InstallAspect } from '@teambit/install';\nimport type { ImporterMain } from '@teambit/importer';\nimport { ImporterAspect } from '@teambit/importer';\nimport type { Component, ComponentMain } from '@teambit/component';\nimport { ComponentAspect } from '@teambit/component';\nimport type { Workspace } from '@teambit/workspace';\nimport { WorkspaceAspect } from '@teambit/workspace';\nimport { sendEventsToClients } from '@teambit/harmony.modules.send-server-sent-events';\nimport cors from 'cors';\nimport { createProxyMiddleware, fixRequestBody } from 'http-proxy-middleware';\nimport { ApiServerAspect } from './api-server.aspect';\nimport { CLIRoute } from './cli.route';\nimport { ServerCmd } from './server.cmd';\nimport { IDERoute } from './ide.route';\nimport { APIForIDE } from './api-for-ide';\nimport { SSEEventsRoute } from './sse-events.route';\nimport { join } from 'path';\nimport { execSync } from 'child_process';\nimport { CLIRawRoute } from './cli-raw.route';\nimport type { ApplicationMain } from '@teambit/application';\nimport { ApplicationAspect } from '@teambit/application';\nimport type { DeprecationMain } from '@teambit/deprecation';\nimport { DeprecationAspect } from '@teambit/deprecation';\nimport type { EnvsMain } from '@teambit/envs';\nimport { EnvsAspect } from '@teambit/envs';\nimport { DEFAULT_AUTH_TYPE, Http } from '@teambit/scope.network';\nimport { getSymphonyUrl } from '@teambit/legacy.constants';\nimport type { GraphMain } from '@teambit/graph';\nimport { GraphAspect } from '@teambit/graph';\nimport type { ScopeMain } from '@teambit/scope';\nimport { ScopeAspect } from '@teambit/scope';\nimport type { SchemaMain } from '@teambit/schema';\nimport { SchemaAspect } from '@teambit/schema';\n\nexport class ApiServerMain {\n constructor(\n private workspace: Workspace,\n private logger: Logger,\n private express: ExpressMain,\n private watcher: WatcherMain,\n private installer: InstallMain,\n private importer: ImporterMain\n ) {}\n\n async runApiServer(options: { port: number; compile: boolean }) {\n if (!this.workspace) {\n throw new Error(`unable to run bit-server, the current directory ${process.cwd()} is not a workspace`);\n }\n\n this.workspace.registerOnComponentChange(\n async (\n component: Component,\n files: string[], // os absolute paths\n removedFiles?: string[] // os absolute paths\n ) => {\n sendEventsToClients('onComponentChange', {\n id: component.id.toStringWithoutVersion(),\n files,\n removedFiles,\n });\n }\n );\n\n this.workspace.registerOnBitmapChange(async () => {\n const lastModifiedTimestamp = await this.workspace.bitMap.getLastModifiedBitmapThroughBit();\n const secondsPassedSinceLastModified = lastModifiedTimestamp && (Date.now() - lastModifiedTimestamp) / 1000;\n if (secondsPassedSinceLastModified && secondsPassedSinceLastModified > 1) {\n // changes by bit were done more than a second ago, so probably this .bitmap change was done by \"git pull\"\n this.logger.debug(\n `running import because we assume the .bitmap file has changed due to \"git pull\", last time it was modified by bit was ${secondsPassedSinceLastModified} seconds ago`\n );\n await this.importer.importCurrentObjects();\n }\n sendEventsToClients('onBitmapChange', {});\n });\n\n this.workspace.registerOnWorkspaceConfigChange(async () => {\n sendEventsToClients('onWorkspaceConfigChange', {});\n });\n\n this.workspace.scope.registerOnPostExport(async () => {\n sendEventsToClients('onPostExport', {});\n });\n\n this.installer.registerPostInstall(async () => {\n sendEventsToClients('onPostInstall', {});\n });\n\n await this.watcher.watch({\n preCompile: false,\n compile: options.compile,\n });\n\n const port = options.port || (await this.getRandomPort());\n\n const app = this.express.createApp();\n\n app.use(\n cors({\n origin(origin, callback) {\n callback(null, true);\n },\n credentials: true,\n })\n );\n const proxyHeaders = {\n Authorization: `${DEFAULT_AUTH_TYPE} ${Http.getToken()}`,\n origin: '',\n 'user-agent': 'bit-vscode-proxy',\n };\n const symphonyUrl = getSymphonyUrl();\n app.use(\n '/api/cloud-graphql',\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n createProxyMiddleware({\n target: `${symphonyUrl}/graphql`,\n changeOrigin: true,\n headers: proxyHeaders,\n on: {\n error: (err, req, res) => {\n this.logger.error('graphql cloud proxy error', err);\n // @ts-ignore\n res.writeHead(500, {\n 'Content-Type': 'text/plain',\n });\n res.end('Something went wrong with the proxy server of bit cloud graphql');\n },\n proxyReq: fixRequestBody,\n },\n })\n );\n\n app.use(\n '/api/cloud-rest',\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n createProxyMiddleware({\n target: `${symphonyUrl}`,\n changeOrigin: true,\n headers: proxyHeaders,\n on: {\n proxyRes: (proxyRes) => {\n proxyRes.headers['Access-Control-Allow-Credentials'] = 'true';\n },\n error: (err, req, res) => {\n this.logger.error('rest cloud proxy error', err);\n // @ts-ignore\n res.writeHead(500, {\n 'Content-Type': 'text/plain',\n });\n res.end('Something went wrong with the proxy server of bit cloud rest');\n },\n proxyReq: fixRequestBody,\n },\n })\n );\n\n app.use(\n '/websocket-server/subscriptions',\n createProxyMiddleware({\n on: {\n proxyReqWs: (proxyReq) => {\n Object.entries(proxyHeaders).forEach(([key, value]) => {\n proxyReq.setHeader(key, value);\n });\n },\n error: (err) => {\n this.logger.error('websocket cloud proxy error', err);\n },\n },\n pathFilter: '/',\n target: symphonyUrl,\n ws: true,\n secure: false, // Disable SSL verification for proxy to remote server\n changeOrigin: true,\n })\n );\n\n const server = await app.listen(port);\n\n return new Promise((resolve, reject) => {\n server.on('error', (err) => {\n reject(err);\n });\n server.on('listening', () => {\n // important! if you change the message here, change it also in server-forever.ts and also in the vscode extension.\n this.logger.consoleSuccess(`Bit Server is listening on port ${port}`);\n this.writeUsedPort(port);\n this.startParentProcessMonitor();\n resolve(port);\n });\n });\n }\n\n writeUsedPort(port: number) {\n const filePath = this.getServerPortFilePath();\n fs.writeFileSync(filePath, port.toString());\n }\n\n /**\n * Monitor the parent process (typically VSCode) and shut down if it dies.\n *\n * On Unix-like systems (macOS, Linux), when a parent process dies, orphaned children are\n * re-parented to PID 1 (init/launchd). By watching for `process.ppid` changing from\n * the original value to 1, we can detect that the parent exited and proactively\n * shut down the bit server to avoid leaving stale background processes running.\n *\n * Note: This orphan detection does not work on Windows, as Windows does not re-parent\n * processes to PID 1. On Windows, this method only logs the parent process info at startup.\n */\n private startParentProcessMonitor() {\n const originalPpid = process.ppid;\n\n // Log parent process info at startup\n const parentInfo = this.getProcessInfo(originalPpid);\n this.logger.debug(\n `bit server started. PID: ${process.pid}, Parent PID: ${originalPpid}, Parent command: ${parentInfo}`\n );\n\n // Skip orphan detection on Windows - PPID doesn't change to 1 when parent dies\n if (process.platform === 'win32') {\n return;\n }\n\n const checkInterval = 5000; // Check every 5 seconds\n const intervalId = setInterval(() => {\n const currentPpid = process.ppid;\n // If PPID changed to 1, our parent (e.g., VSCode) died and we were re-parented to init\n if (currentPpid === 1 && originalPpid !== 1) {\n this.logger.debug(\n `Parent process died (was PID ${originalPpid}: ${parentInfo}). Current PPID is now 1 (init/launchd). Shutting down bit server.`\n );\n clearInterval(intervalId);\n process.exit(0);\n }\n }, checkInterval);\n\n // Don't let this interval keep the process alive if everything else is done\n intervalId.unref();\n }\n\n /**\n * Get the command/path of a process by its PID.\n */\n private getProcessInfo(pid: number): string {\n try {\n if (process.platform === 'win32') {\n // Windows: use PowerShell Get-CimInstance (WMIC is deprecated/removed on modern Windows)\n const psCommand = `Get-CimInstance Win32_Process -Filter 'ProcessId = ${pid}' | Select-Object -ExpandProperty CommandLine`;\n const output = execSync(`powershell.exe -NoProfile -Command \"${psCommand}\"`, {\n encoding: 'utf8',\n timeout: 2000,\n });\n return output.trim() || 'unknown';\n } else {\n // macOS/Linux: use ps\n const output = execSync(`ps -o command= -p ${pid}`, { encoding: 'utf8', timeout: 2000 });\n return output.trim() || 'unknown';\n }\n } catch {\n return 'unknown (process may have exited)';\n }\n }\n\n async getRandomPort() {\n const startingPort = 4000; // we prefer to have the ports between 4000 and 4999.\n // get random number in the range of [startingPort, 4999].\n const randomNumber = Math.floor(Math.random() * (4999 - startingPort + 1) + startingPort);\n const port = await Port.getPort(randomNumber, 65500);\n return port;\n }\n\n async getExistingUsedPort(): Promise<number | undefined> {\n const filePath = this.getServerPortFilePath();\n try {\n const fileContent = await fs.readFile(filePath, 'utf8');\n return parseInt(fileContent, 10);\n } catch (err: any) {\n if (err.code === 'ENOENT') {\n return undefined;\n }\n throw err;\n }\n }\n\n private getServerPortFilePath() {\n return join(this.workspace.scope.path, 'server-port.txt');\n }\n\n static dependencies = [\n CLIAspect,\n WorkspaceAspect,\n LoggerAspect,\n ExpressAspect,\n WatcherAspect,\n SnappingAspect,\n LanesAspect,\n InstallAspect,\n ExportAspect,\n CheckoutAspect,\n ComponentLogAspect,\n ImporterAspect,\n ComponentCompareAspect,\n GeneratorAspect,\n RemoveAspect,\n ConfigAspect,\n ApplicationAspect,\n DeprecationAspect,\n EnvsAspect,\n GraphAspect,\n ScopeAspect,\n ComponentAspect,\n SchemaAspect,\n ];\n static runtime = MainRuntime;\n static async provider([\n cli,\n workspace,\n loggerMain,\n express,\n watcher,\n snapping,\n lanes,\n installer,\n exporter,\n checkout,\n componentLog,\n importer,\n componentCompare,\n generator,\n remove,\n config,\n application,\n deprecation,\n envs,\n graph,\n scope,\n component,\n schema,\n ]: [\n CLIMain,\n Workspace,\n LoggerMain,\n ExpressMain,\n WatcherMain,\n SnappingMain,\n LanesMain,\n InstallMain,\n ExportMain,\n CheckoutMain,\n ComponentLogMain,\n ImporterMain,\n ComponentCompareMain,\n GeneratorMain,\n RemoveMain,\n ConfigMain,\n ApplicationMain,\n DeprecationMain,\n EnvsMain,\n GraphMain,\n ScopeMain,\n ComponentMain,\n SchemaMain,\n ]) {\n const logger = loggerMain.createLogger(ApiServerAspect.id);\n const apiServer = new ApiServerMain(workspace, logger, express, watcher, installer, importer);\n cli.register(new ServerCmd(apiServer));\n\n const apiForIDE = new APIForIDE(\n workspace,\n snapping,\n lanes,\n installer,\n exporter,\n checkout,\n componentLog,\n componentCompare,\n generator,\n remove,\n config,\n application,\n deprecation,\n envs,\n graph,\n scope,\n component,\n schema,\n logger\n );\n const cliRoute = new CLIRoute(logger, cli, apiForIDE);\n const cliRawRoute = new CLIRawRoute(logger, cli, apiForIDE);\n const ideRoute = new IDERoute(logger, apiForIDE);\n const sseEventsRoute = new SSEEventsRoute(logger, cli);\n // register only when the workspace is available. don't register this on a remote-scope, for security reasons.\n if (workspace) {\n express.register([cliRoute, cliRawRoute, ideRoute, sseEventsRoute]);\n }\n\n return apiServer;\n }\n}\n\nApiServerAspect.addRuntime(ApiServerMain);\n\nexport default ApiServerMain;\n"],"mappings":";;;;;;AACA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,gBAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,eAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,SAAA;EAAA,MAAAH,IAAA,GAAAI,sBAAA,CAAAH,OAAA;EAAAE,QAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAK,SAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,QAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAM,QAAA;EAAA,MAAAN,IAAA,GAAAC,OAAA;EAAAK,OAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAO,OAAA;EAAA,MAAAP,IAAA,GAAAC,OAAA;EAAAM,MAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAQ,QAAA;EAAA,MAAAR,IAAA,GAAAC,OAAA;EAAAO,OAAA,YAAAA,CAAA;IAAA,OAAAR,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAS,UAAA;EAAA,MAAAT,IAAA,GAAAC,OAAA;EAAAQ,SAAA,YAAAA,CAAA;IAAA,OAAAT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A,OAAOX,SAAS;EAClB;AACF;AAACa,OAAA,CAAAzJ,aAAA,GAAAA,aAAA;AAAAlB,eAAA,CA7WYkB,aAAa,kBA8PF,CACpB0J,gBAAS,EACTC,4BAAe,EACfC,sBAAY,EACZC,wBAAa,EACbC,wBAAa,EACbC,0BAAc,EACdC,oBAAW,EACXC,wBAAa,EACbC,sBAAY,EACZC,0BAAc,EACdC,kCAAkB,EAClBC,0BAAc,EACdC,0CAAsB,EACtBC,4BAAe,EACfC,sBAAY,EACZC,sBAAY,EACZC,gCAAiB,EACjBC,gCAAiB,EACjBC,kBAAU,EACVC,oBAAW,EACXC,qBAAW,EACXC,4BAAe,EACfC,sBAAY,CACb;AAAAlM,eAAA,CAtRUkB,aAAa,aAuRPiL,kBAAW;AAwF9BtC,4BAAe,CAACuC,UAAU,CAAClL,aAAa,CAAC;AAAC,IAAAmL,QAAA,GAAA1B,OAAA,CAAA5K,OAAA,GAE3BmB,aAAa","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_cli","data","require","_toolboxNetwork","_fsExtra","_interopRequireDefault","_crypto","_express","_express2","_logger","_lanes","_remove","_snapping","_generator","_componentCompare","_componentLog","_watcher","_config","_export","_checkout","_install","_importer","_component","_workspace","_harmonyModules","_cors","_httpProxyMiddleware","_apiServer","_cli2","_server","_ide","_apiForIde","_sseEvents","_path","_child_process","_cliRaw","_application","_deprecation","_envs","_scope","_legacy","_graph","_scope2","_schema","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","ApiServerMain","constructor","workspace","logger","express","watcher","installer","importer","runApiServer","options","Error","process","cwd","registerOnComponentChange","component","files","removedFiles","sendEventsToClients","id","toStringWithoutVersion","registerOnBitmapChange","lastModifiedTimestamp","bitMap","getLastModifiedBitmapThroughBit","secondsPassedSinceLastModified","Date","now","debug","importCurrentObjects","registerOnWorkspaceConfigChange","scope","registerOnPostExport","registerPostInstall","watch","preCompile","compile","port","getRandomPort","writeServerToken","app","expressFactory","use","cors","origin","callback","credentials","createAuthMiddleware","createApp","proxyHeaders","Authorization","DEFAULT_AUTH_TYPE","Http","getToken","symphonyUrl","getSymphonyUrl","createProxyMiddleware","target","changeOrigin","headers","on","error","err","req","res","writeHead","end","proxyReq","fixRequestBody","proxyRes","proxyReqWs","entries","forEach","key","setHeader","pathFilter","ws","secure","server","listen","Promise","resolve","reject","consoleSuccess","writeUsedPort","startParentProcessMonitor","filePath","getServerPortFilePath","fs","writeFileSync","toString","token","crypto","randomBytes","getServerTokenFilePath","mode","chmodSync","serverToken","join","path","next","method","provided","parseBearerToken","authorization","status","jsonp","message","originalPpid","ppid","parentInfo","getProcessInfo","pid","platform","checkInterval","intervalId","setInterval","currentPpid","clearInterval","exit","unref","psCommand","output","execSync","encoding","timeout","trim","startingPort","randomNumber","Math","floor","random","Port","getPort","getExistingUsedPort","fileContent","readFile","parseInt","code","undefined","provider","cli","loggerMain","snapping","lanes","exporter","checkout","componentLog","componentCompare","generator","remove","config","application","deprecation","envs","graph","schema","createLogger","ApiServerAspect","apiServer","register","ServerCmd","apiForIDE","APIForIDE","cliRoute","CLIRoute","cliRawRoute","CLIRawRoute","ideRoute","IDERoute","sseEventsRoute","SSEEventsRoute","exports","CLIAspect","WorkspaceAspect","LoggerAspect","ExpressAspect","WatcherAspect","SnappingAspect","LanesAspect","InstallAspect","ExportAspect","CheckoutAspect","ComponentLogAspect","ImporterAspect","ComponentCompareAspect","GeneratorAspect","RemoveAspect","ConfigAspect","ApplicationAspect","DeprecationAspect","EnvsAspect","GraphAspect","ScopeAspect","ComponentAspect","SchemaAspect","MainRuntime","addRuntime","header","match","_default"],"sources":["api-server.main.runtime.ts"],"sourcesContent":["import type { CLIMain } from '@teambit/cli';\nimport { CLIAspect, MainRuntime } from '@teambit/cli';\nimport { Port } from '@teambit/toolbox.network.get-port';\nimport fs from 'fs-extra';\nimport crypto from 'crypto';\nimport expressFactory from 'express';\nimport type { ExpressMain, Middleware, Request, Response, NextFunction } from '@teambit/express';\nimport { ExpressAspect } from '@teambit/express';\nimport type { Logger, LoggerMain } from '@teambit/logger';\nimport { LoggerAspect } from '@teambit/logger';\nimport type { LanesMain } from '@teambit/lanes';\nimport { LanesAspect } from '@teambit/lanes';\nimport type { RemoveMain } from '@teambit/remove';\nimport { RemoveAspect } from '@teambit/remove';\nimport type { SnappingMain } from '@teambit/snapping';\nimport { SnappingAspect } from '@teambit/snapping';\nimport type { GeneratorMain } from '@teambit/generator';\nimport { GeneratorAspect } from '@teambit/generator';\nimport type { ComponentCompareMain } from '@teambit/component-compare';\nimport { ComponentCompareAspect } from '@teambit/component-compare';\nimport type { ComponentLogMain } from '@teambit/component-log';\nimport { ComponentLogAspect } from '@teambit/component-log';\nimport type { WatcherMain } from '@teambit/watcher';\nimport { WatcherAspect } from '@teambit/watcher';\nimport type { ConfigMain } from '@teambit/config';\nimport { ConfigAspect } from '@teambit/config';\nimport type { ExportMain } from '@teambit/export';\nimport { ExportAspect } from '@teambit/export';\nimport type { CheckoutMain } from '@teambit/checkout';\nimport { CheckoutAspect } from '@teambit/checkout';\nimport type { InstallMain } from '@teambit/install';\nimport { InstallAspect } from '@teambit/install';\nimport type { ImporterMain } from '@teambit/importer';\nimport { ImporterAspect } from '@teambit/importer';\nimport type { Component, ComponentMain } from '@teambit/component';\nimport { ComponentAspect } from '@teambit/component';\nimport type { Workspace } from '@teambit/workspace';\nimport { WorkspaceAspect } from '@teambit/workspace';\nimport { sendEventsToClients } from '@teambit/harmony.modules.send-server-sent-events';\nimport cors from 'cors';\nimport { createProxyMiddleware, fixRequestBody } from 'http-proxy-middleware';\nimport { ApiServerAspect } from './api-server.aspect';\nimport { CLIRoute } from './cli.route';\nimport { ServerCmd } from './server.cmd';\nimport { IDERoute } from './ide.route';\nimport { APIForIDE } from './api-for-ide';\nimport { SSEEventsRoute } from './sse-events.route';\nimport { join } from 'path';\nimport { execSync } from 'child_process';\nimport { CLIRawRoute } from './cli-raw.route';\nimport type { ApplicationMain } from '@teambit/application';\nimport { ApplicationAspect } from '@teambit/application';\nimport type { DeprecationMain } from '@teambit/deprecation';\nimport { DeprecationAspect } from '@teambit/deprecation';\nimport type { EnvsMain } from '@teambit/envs';\nimport { EnvsAspect } from '@teambit/envs';\nimport { DEFAULT_AUTH_TYPE, Http } from '@teambit/scope.network';\nimport { getSymphonyUrl } from '@teambit/legacy.constants';\nimport type { GraphMain } from '@teambit/graph';\nimport { GraphAspect } from '@teambit/graph';\nimport type { ScopeMain } from '@teambit/scope';\nimport { ScopeAspect } from '@teambit/scope';\nimport type { SchemaMain } from '@teambit/schema';\nimport { SchemaAspect } from '@teambit/schema';\n\nexport class ApiServerMain {\n private serverToken?: string;\n\n constructor(\n private workspace: Workspace,\n private logger: Logger,\n private express: ExpressMain,\n private watcher: WatcherMain,\n private installer: InstallMain,\n private importer: ImporterMain\n ) {}\n\n async runApiServer(options: { port: number; compile: boolean }) {\n if (!this.workspace) {\n throw new Error(`unable to run bit-server, the current directory ${process.cwd()} is not a workspace`);\n }\n\n this.workspace.registerOnComponentChange(\n async (\n component: Component,\n files: string[], // os absolute paths\n removedFiles?: string[] // os absolute paths\n ) => {\n sendEventsToClients('onComponentChange', {\n id: component.id.toStringWithoutVersion(),\n files,\n removedFiles,\n });\n }\n );\n\n this.workspace.registerOnBitmapChange(async () => {\n const lastModifiedTimestamp = await this.workspace.bitMap.getLastModifiedBitmapThroughBit();\n const secondsPassedSinceLastModified = lastModifiedTimestamp && (Date.now() - lastModifiedTimestamp) / 1000;\n if (secondsPassedSinceLastModified && secondsPassedSinceLastModified > 1) {\n // changes by bit were done more than a second ago, so probably this .bitmap change was done by \"git pull\"\n this.logger.debug(\n `running import because we assume the .bitmap file has changed due to \"git pull\", last time it was modified by bit was ${secondsPassedSinceLastModified} seconds ago`\n );\n await this.importer.importCurrentObjects();\n }\n sendEventsToClients('onBitmapChange', {});\n });\n\n this.workspace.registerOnWorkspaceConfigChange(async () => {\n sendEventsToClients('onWorkspaceConfigChange', {});\n });\n\n this.workspace.scope.registerOnPostExport(async () => {\n sendEventsToClients('onPostExport', {});\n });\n\n this.installer.registerPostInstall(async () => {\n sendEventsToClients('onPostInstall', {});\n });\n\n await this.watcher.watch({\n preCompile: false,\n compile: options.compile,\n });\n\n const port = options.port || (await this.getRandomPort());\n\n // Generate a per-server auth token and persist it to a 0600 file before\n // any HTTP request can be handled. Clients (e.g. the bit-vscode extension)\n // read it from <workspace.scope.path>/server-token.txt and send it as\n // `Authorization: Bearer <token>`. See createAuthMiddleware below.\n this.writeServerToken();\n\n // Create the app *before* express.createApp registers routes, so the auth\n // middleware runs before bodyParser — unauthenticated requests can't\n // trigger large-body parsing. CORS is registered before auth so 401\n // responses still carry CORS headers; otherwise browser-based clients\n // (bit-vscode) see a misleading CORS failure instead of the JSON 401.\n const app = expressFactory();\n app.use(\n cors({\n origin(origin, callback) {\n callback(null, true);\n },\n credentials: true,\n })\n );\n app.use(this.createAuthMiddleware());\n this.express.createApp(app);\n const proxyHeaders = {\n Authorization: `${DEFAULT_AUTH_TYPE} ${Http.getToken()}`,\n origin: '',\n 'user-agent': 'bit-vscode-proxy',\n };\n const symphonyUrl = getSymphonyUrl();\n app.use(\n '/api/cloud-graphql',\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n createProxyMiddleware({\n target: `${symphonyUrl}/graphql`,\n changeOrigin: true,\n headers: proxyHeaders,\n on: {\n error: (err, req, res) => {\n this.logger.error('graphql cloud proxy error', err);\n // @ts-ignore\n res.writeHead(500, {\n 'Content-Type': 'text/plain',\n });\n res.end('Something went wrong with the proxy server of bit cloud graphql');\n },\n proxyReq: fixRequestBody,\n },\n })\n );\n\n app.use(\n '/api/cloud-rest',\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n createProxyMiddleware({\n target: `${symphonyUrl}`,\n changeOrigin: true,\n headers: proxyHeaders,\n on: {\n proxyRes: (proxyRes) => {\n proxyRes.headers['Access-Control-Allow-Credentials'] = 'true';\n },\n error: (err, req, res) => {\n this.logger.error('rest cloud proxy error', err);\n // @ts-ignore\n res.writeHead(500, {\n 'Content-Type': 'text/plain',\n });\n res.end('Something went wrong with the proxy server of bit cloud rest');\n },\n proxyReq: fixRequestBody,\n },\n })\n );\n\n app.use(\n '/websocket-server/subscriptions',\n createProxyMiddleware({\n on: {\n proxyReqWs: (proxyReq) => {\n Object.entries(proxyHeaders).forEach(([key, value]) => {\n proxyReq.setHeader(key, value);\n });\n },\n error: (err) => {\n this.logger.error('websocket cloud proxy error', err);\n },\n },\n pathFilter: '/',\n target: symphonyUrl,\n ws: true,\n secure: false, // Disable SSL verification for proxy to remote server\n changeOrigin: true,\n })\n );\n\n const server = await app.listen(port);\n\n return new Promise((resolve, reject) => {\n server.on('error', (err) => {\n reject(err);\n });\n server.on('listening', () => {\n // important! if you change the message here, change it also in server-forever.ts and also in the vscode extension.\n this.logger.consoleSuccess(`Bit Server is listening on port ${port}`);\n this.writeUsedPort(port);\n this.startParentProcessMonitor();\n resolve(port);\n });\n });\n }\n\n writeUsedPort(port: number) {\n const filePath = this.getServerPortFilePath();\n fs.writeFileSync(filePath, port.toString());\n }\n\n /**\n * Generate a fresh per-server bearer token and persist it to a 0600 file.\n * Clients (e.g. the bit-vscode extension) read this file and send the token\n * as `Authorization: Bearer <token>` on every request.\n *\n * Backwards compatibility: clients that don't yet know about this file (older\n * extension versions) won't send the header and will receive 401 with a\n * message pointing them at the upgrade. Old bit-server versions don't write\n * this file, so a new client checking for it gracefully falls back to no\n * auth header — meaning a NEW extension keeps working against an OLD\n * bit-server.\n */\n private writeServerToken() {\n const token = crypto.randomBytes(32).toString('hex');\n const filePath = this.getServerTokenFilePath();\n fs.writeFileSync(filePath, token, { mode: 0o600 });\n // Node's `mode` write option is only honored when the file is created.\n // chmod explicitly so a pre-existing file with broader permissions gets\n // tightened to 0600.\n fs.chmodSync(filePath, 0o600);\n this.serverToken = token;\n }\n\n private getServerTokenFilePath() {\n return join(this.workspace.scope.path, 'server-token.txt');\n }\n\n /**\n * Authentication middleware: requires `Authorization: Bearer <serverToken>`\n * on every request except OPTIONS preflight (handled by cors) and the\n * unauthenticated `/api/_health` liveness probe.\n *\n * Runs before bodyParser so unauthenticated requests can't trigger\n * large-body parsing.\n */\n private createAuthMiddleware(): Middleware {\n return (req: Request, res: Response, next: NextFunction) => {\n if (req.method === 'OPTIONS') return next();\n // Use req.path (not req.url) so query strings don't bypass the\n // health-check exemption — e.g. /api/_health?cache-buster=1.\n if (req.path === '/api/_health') return next();\n\n const provided = parseBearerToken(req.headers.authorization);\n if (!this.serverToken || provided !== this.serverToken) {\n this.logger.debug(`api-server: rejected unauthenticated request to ${req.path}`);\n res.status(401).jsonp({\n error: 'unauthorized',\n message:\n 'This bit-server requires authentication. Please upgrade your bit VS Code extension to the latest version.',\n });\n return;\n }\n return next();\n };\n }\n\n /**\n * Monitor the parent process (typically VSCode) and shut down if it dies.\n *\n * On Unix-like systems (macOS, Linux), when a parent process dies, orphaned children are\n * re-parented to PID 1 (init/launchd). By watching for `process.ppid` changing from\n * the original value to 1, we can detect that the parent exited and proactively\n * shut down the bit server to avoid leaving stale background processes running.\n *\n * Note: This orphan detection does not work on Windows, as Windows does not re-parent\n * processes to PID 1. On Windows, this method only logs the parent process info at startup.\n */\n private startParentProcessMonitor() {\n const originalPpid = process.ppid;\n\n // Log parent process info at startup\n const parentInfo = this.getProcessInfo(originalPpid);\n this.logger.debug(\n `bit server started. PID: ${process.pid}, Parent PID: ${originalPpid}, Parent command: ${parentInfo}`\n );\n\n // Skip orphan detection on Windows - PPID doesn't change to 1 when parent dies\n if (process.platform === 'win32') {\n return;\n }\n\n const checkInterval = 5000; // Check every 5 seconds\n const intervalId = setInterval(() => {\n const currentPpid = process.ppid;\n // If PPID changed to 1, our parent (e.g., VSCode) died and we were re-parented to init\n if (currentPpid === 1 && originalPpid !== 1) {\n this.logger.debug(\n `Parent process died (was PID ${originalPpid}: ${parentInfo}). Current PPID is now 1 (init/launchd). Shutting down bit server.`\n );\n clearInterval(intervalId);\n process.exit(0);\n }\n }, checkInterval);\n\n // Don't let this interval keep the process alive if everything else is done\n intervalId.unref();\n }\n\n /**\n * Get the command/path of a process by its PID.\n */\n private getProcessInfo(pid: number): string {\n try {\n if (process.platform === 'win32') {\n // Windows: use PowerShell Get-CimInstance (WMIC is deprecated/removed on modern Windows)\n const psCommand = `Get-CimInstance Win32_Process -Filter 'ProcessId = ${pid}' | Select-Object -ExpandProperty CommandLine`;\n const output = execSync(`powershell.exe -NoProfile -Command \"${psCommand}\"`, {\n encoding: 'utf8',\n timeout: 2000,\n });\n return output.trim() || 'unknown';\n } else {\n // macOS/Linux: use ps\n const output = execSync(`ps -o command= -p ${pid}`, { encoding: 'utf8', timeout: 2000 });\n return output.trim() || 'unknown';\n }\n } catch {\n return 'unknown (process may have exited)';\n }\n }\n\n async getRandomPort() {\n const startingPort = 4000; // we prefer to have the ports between 4000 and 4999.\n // get random number in the range of [startingPort, 4999].\n const randomNumber = Math.floor(Math.random() * (4999 - startingPort + 1) + startingPort);\n const port = await Port.getPort(randomNumber, 65500);\n return port;\n }\n\n async getExistingUsedPort(): Promise<number | undefined> {\n const filePath = this.getServerPortFilePath();\n try {\n const fileContent = await fs.readFile(filePath, 'utf8');\n return parseInt(fileContent, 10);\n } catch (err: any) {\n if (err.code === 'ENOENT') {\n return undefined;\n }\n throw err;\n }\n }\n\n private getServerPortFilePath() {\n return join(this.workspace.scope.path, 'server-port.txt');\n }\n\n static dependencies = [\n CLIAspect,\n WorkspaceAspect,\n LoggerAspect,\n ExpressAspect,\n WatcherAspect,\n SnappingAspect,\n LanesAspect,\n InstallAspect,\n ExportAspect,\n CheckoutAspect,\n ComponentLogAspect,\n ImporterAspect,\n ComponentCompareAspect,\n GeneratorAspect,\n RemoveAspect,\n ConfigAspect,\n ApplicationAspect,\n DeprecationAspect,\n EnvsAspect,\n GraphAspect,\n ScopeAspect,\n ComponentAspect,\n SchemaAspect,\n ];\n static runtime = MainRuntime;\n static async provider([\n cli,\n workspace,\n loggerMain,\n express,\n watcher,\n snapping,\n lanes,\n installer,\n exporter,\n checkout,\n componentLog,\n importer,\n componentCompare,\n generator,\n remove,\n config,\n application,\n deprecation,\n envs,\n graph,\n scope,\n component,\n schema,\n ]: [\n CLIMain,\n Workspace,\n LoggerMain,\n ExpressMain,\n WatcherMain,\n SnappingMain,\n LanesMain,\n InstallMain,\n ExportMain,\n CheckoutMain,\n ComponentLogMain,\n ImporterMain,\n ComponentCompareMain,\n GeneratorMain,\n RemoveMain,\n ConfigMain,\n ApplicationMain,\n DeprecationMain,\n EnvsMain,\n GraphMain,\n ScopeMain,\n ComponentMain,\n SchemaMain,\n ]) {\n const logger = loggerMain.createLogger(ApiServerAspect.id);\n const apiServer = new ApiServerMain(workspace, logger, express, watcher, installer, importer);\n cli.register(new ServerCmd(apiServer));\n\n const apiForIDE = new APIForIDE(\n workspace,\n snapping,\n lanes,\n installer,\n exporter,\n checkout,\n componentLog,\n componentCompare,\n generator,\n remove,\n config,\n application,\n deprecation,\n envs,\n graph,\n scope,\n component,\n schema,\n logger\n );\n const cliRoute = new CLIRoute(logger, cli, apiForIDE);\n const cliRawRoute = new CLIRawRoute(logger, cli, apiForIDE);\n const ideRoute = new IDERoute(logger, apiForIDE);\n const sseEventsRoute = new SSEEventsRoute(logger, cli);\n // register only when the workspace is available. don't register this on a remote-scope, for security reasons.\n if (workspace) {\n express.register([cliRoute, cliRawRoute, ideRoute, sseEventsRoute]);\n }\n\n return apiServer;\n }\n}\n\nApiServerAspect.addRuntime(ApiServerMain);\n\n/**\n * Extract the token from an `Authorization: Bearer <token>` header.\n * Lenient on scheme casing and surrounding whitespace so a slightly\n * non-canonical client header doesn't get rejected.\n */\nfunction parseBearerToken(header: string | undefined): string | undefined {\n if (!header) return undefined;\n const match = header.match(/^\\s*Bearer\\s+(\\S+)\\s*$/i);\n return match?.[1];\n}\n\nexport default ApiServerMain;\n"],"mappings":";;;;;;AACA,SAAAA,KAAA;EAAA,MAA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
{
|
|
2
2
|
"name": "@teambit/api-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.997",
|
|
4
4
|
"homepage": "https://bit.cloud/teambit/harmony/api-server",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.harmony",
|
|
8
8
|
"name": "api-server",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.997"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"filenamify": "4.2.0",
|
|
@@ -15,54 +15,56 @@
|
|
|
15
15
|
"node-fetch": "2.6.7",
|
|
16
16
|
"p-map": "4.0.0",
|
|
17
17
|
"cors": "2.8.5",
|
|
18
|
+
"express": "4.21.2",
|
|
18
19
|
"http-proxy-middleware": "^3.0.3",
|
|
19
20
|
"chalk": "4.1.2",
|
|
20
21
|
"pretty-time": "1.1.0",
|
|
22
|
+
"@teambit/application": "1.0.972",
|
|
23
|
+
"@teambit/checkout": "1.0.973",
|
|
24
|
+
"@teambit/component-compare": "1.0.972",
|
|
25
|
+
"@teambit/component-log": "1.0.972",
|
|
21
26
|
"@teambit/component.modules.component-url": "0.0.187",
|
|
22
27
|
"@teambit/component.modules.merge-helper": "0.0.54",
|
|
28
|
+
"@teambit/component": "1.0.972",
|
|
23
29
|
"@teambit/config": "0.0.1495",
|
|
30
|
+
"@teambit/deprecation": "1.0.972",
|
|
31
|
+
"@teambit/envs": "1.0.972",
|
|
32
|
+
"@teambit/export": "1.0.972",
|
|
33
|
+
"@teambit/generator": "1.0.973",
|
|
34
|
+
"@teambit/graph": "1.0.972",
|
|
35
|
+
"@teambit/install": "1.0.972",
|
|
24
36
|
"@teambit/lane-id": "0.0.312",
|
|
25
37
|
"@teambit/lanes.modules.diff": "0.0.614",
|
|
38
|
+
"@teambit/lanes": "1.0.988",
|
|
26
39
|
"@teambit/legacy.consumer": "0.0.111",
|
|
27
40
|
"@teambit/legacy.scope": "0.0.111",
|
|
28
41
|
"@teambit/legacy.utils": "0.0.34",
|
|
29
42
|
"@teambit/logger": "0.0.1413",
|
|
43
|
+
"@teambit/objects": "0.0.479",
|
|
44
|
+
"@teambit/remove": "1.0.972",
|
|
45
|
+
"@teambit/schema": "1.0.972",
|
|
46
|
+
"@teambit/scope": "1.0.972",
|
|
47
|
+
"@teambit/snapping": "1.0.972",
|
|
48
|
+
"@teambit/workspace": "1.0.972",
|
|
30
49
|
"@teambit/harmony": "0.4.7",
|
|
31
50
|
"@teambit/cli": "0.0.1320",
|
|
32
51
|
"@teambit/express": "0.0.1419",
|
|
33
52
|
"@teambit/harmony.modules.send-server-sent-events": "0.0.17",
|
|
53
|
+
"@teambit/importer": "1.0.972",
|
|
34
54
|
"@teambit/legacy.constants": "0.0.26",
|
|
35
55
|
"@teambit/scope.network": "0.0.111",
|
|
36
56
|
"@teambit/toolbox.network.get-port": "1.0.20",
|
|
57
|
+
"@teambit/watcher": "1.0.972",
|
|
37
58
|
"@teambit/harmony.modules.feature-toggle": "0.0.36",
|
|
38
59
|
"@teambit/legacy.loader": "0.0.18",
|
|
39
|
-
"@teambit/legacy.logger": "0.0.38"
|
|
40
|
-
"@teambit/application": "1.0.971",
|
|
41
|
-
"@teambit/checkout": "1.0.972",
|
|
42
|
-
"@teambit/component-compare": "1.0.971",
|
|
43
|
-
"@teambit/component-log": "1.0.971",
|
|
44
|
-
"@teambit/component": "1.0.971",
|
|
45
|
-
"@teambit/deprecation": "1.0.971",
|
|
46
|
-
"@teambit/envs": "1.0.971",
|
|
47
|
-
"@teambit/export": "1.0.971",
|
|
48
|
-
"@teambit/generator": "1.0.972",
|
|
49
|
-
"@teambit/graph": "1.0.971",
|
|
50
|
-
"@teambit/install": "1.0.971",
|
|
51
|
-
"@teambit/lanes": "1.0.987",
|
|
52
|
-
"@teambit/objects": "0.0.478",
|
|
53
|
-
"@teambit/remove": "1.0.971",
|
|
54
|
-
"@teambit/schema": "1.0.971",
|
|
55
|
-
"@teambit/scope": "1.0.971",
|
|
56
|
-
"@teambit/snapping": "1.0.971",
|
|
57
|
-
"@teambit/workspace": "1.0.971",
|
|
58
|
-
"@teambit/importer": "1.0.971",
|
|
59
|
-
"@teambit/watcher": "1.0.971"
|
|
60
|
+
"@teambit/legacy.logger": "0.0.38"
|
|
60
61
|
},
|
|
61
62
|
"devDependencies": {
|
|
62
63
|
"@types/fs-extra": "9.0.7",
|
|
63
64
|
"@types/lodash": "4.14.165",
|
|
64
65
|
"@types/node-fetch": "2.5.12",
|
|
65
66
|
"@types/cors": "2.8.10",
|
|
67
|
+
"@types/express": "4.17.21",
|
|
66
68
|
"@types/pretty-time": "^1.1.5",
|
|
67
69
|
"@types/mocha": "9.1.0",
|
|
68
70
|
"@teambit/harmony.envs.core-aspect-env": "0.1.4"
|
|
File without changes
|