vibelet 1.2.210 → 1.2.211
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/index.cjs +1 -1
- package/dist/inventory-scan-worker.cjs +1 -1
- package/dist/runtime-version.cjs +1 -1
- package/dist/vibelet.mjs +315 -255
- package/package.json +1 -1
package/dist/runtime-version.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var c=require("node:fs"),n=require("node:path"),p="@vibelet/cli";function i(r){try{let e=JSON.parse((0,c.readFileSync)(r,"utf8"));if(e.name===p&&typeof e.version=="string"&&e.version.length>0)return e.version}catch{}return null}function l(){return"1.2.
|
|
1
|
+
var c=require("node:fs"),n=require("node:path"),p="@vibelet/cli";function i(r){try{let e=JSON.parse((0,c.readFileSync)(r,"utf8"));if(e.name===p&&typeof e.version=="string"&&e.version.length>0)return e.version}catch{}return null}function l(){return"1.2.211"}var a=l();process.stdout.write(`${a}
|
|
2
2
|
`);
|
package/dist/vibelet.mjs
CHANGED
|
@@ -11340,7 +11340,7 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("zlib");
|
|
|
11340
11340
|
|
|
11341
11341
|
/***/ }),
|
|
11342
11342
|
|
|
11343
|
-
/***/
|
|
11343
|
+
/***/ 1484:
|
|
11344
11344
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __nccwpck_require__) => {
|
|
11345
11345
|
|
|
11346
11346
|
|
|
@@ -11362,218 +11362,16 @@ var external_node_fs_ = __nccwpck_require__(3024);
|
|
|
11362
11362
|
var external_node_module_ = __nccwpck_require__(8995);
|
|
11363
11363
|
// EXTERNAL MODULE: external "node:path"
|
|
11364
11364
|
var external_node_path_ = __nccwpck_require__(6760);
|
|
11365
|
-
|
|
11366
|
-
var promises_ = __nccwpck_require__(1455);
|
|
11367
|
-
// EXTERNAL MODULE: external "node:util"
|
|
11368
|
-
var external_node_util_ = __nccwpck_require__(7975);
|
|
11369
|
-
;// CONCATENATED MODULE: ../../packages/cloudflared-tunnel/managed-binary.mjs
|
|
11370
|
-
|
|
11371
|
-
|
|
11372
|
-
|
|
11373
|
-
|
|
11374
|
-
|
|
11375
|
-
|
|
11376
|
-
const execFileAsync = (0,external_node_util_.promisify)(external_node_child_process_.execFile);
|
|
11377
|
-
const DEFAULT_UPDATE_INTERVAL_MS = 24 * 60 * 60 * 1000;
|
|
11378
|
-
const DEFAULT_UPDATE_TIMEOUT_MS = 30_000;
|
|
11379
|
-
|
|
11380
|
-
function parseCloudflaredVersion(output) {
|
|
11381
|
-
return String(output || '').match(/cloudflared version\s+([0-9]+(?:\.[0-9]+){1,2})/i)?.[1] ?? null;
|
|
11382
|
-
}
|
|
11383
|
-
|
|
11384
|
-
async function readUpdateState(updateStatePath) {
|
|
11385
|
-
try {
|
|
11386
|
-
const state = JSON.parse(await (0,promises_.readFile)(updateStatePath, 'utf8'));
|
|
11387
|
-
return state && typeof state === 'object' ? state : null;
|
|
11388
|
-
} catch {
|
|
11389
|
-
return null;
|
|
11390
|
-
}
|
|
11391
|
-
}
|
|
11392
|
-
|
|
11393
|
-
async function writeUpdateState(updateStatePath, state) {
|
|
11394
|
-
await (0,promises_.mkdir)((0,external_node_path_.dirname)(updateStatePath), { recursive: true });
|
|
11395
|
-
const temporaryPath = `${updateStatePath}.tmp-${process.pid}-${Date.now()}`;
|
|
11396
|
-
await (0,promises_.writeFile)(temporaryPath, `${JSON.stringify(state, null, 2)}\n`, 'utf8');
|
|
11397
|
-
await (0,promises_.rename)(temporaryPath, updateStatePath);
|
|
11398
|
-
}
|
|
11399
|
-
|
|
11400
|
-
async function runVersion(binaryPath, timeoutMs, runCommand) {
|
|
11401
|
-
if (!binaryPath || !(0,external_node_fs_.existsSync)(binaryPath)) return null;
|
|
11402
|
-
try {
|
|
11403
|
-
const { stdout, stderr } = await runCommand(binaryPath, ['--version'], {
|
|
11404
|
-
encoding: 'utf8',
|
|
11405
|
-
timeout: timeoutMs,
|
|
11406
|
-
maxBuffer: 1024 * 1024,
|
|
11407
|
-
});
|
|
11408
|
-
return parseCloudflaredVersion(`${stdout || ''}\n${stderr || ''}`);
|
|
11409
|
-
} catch {
|
|
11410
|
-
return null;
|
|
11411
|
-
}
|
|
11412
|
-
}
|
|
11413
|
-
|
|
11414
|
-
async function probeCloudflaredLaunchSpecVersion(
|
|
11415
|
-
launchSpec,
|
|
11416
|
-
{ timeoutMs = 5_000, runCommand = execFileAsync } = {},
|
|
11417
|
-
) {
|
|
11418
|
-
try {
|
|
11419
|
-
const { stdout, stderr } = await runCommand(launchSpec.command, [...launchSpec.args, '--version'], {
|
|
11420
|
-
encoding: 'utf8',
|
|
11421
|
-
timeout: timeoutMs,
|
|
11422
|
-
maxBuffer: 1024 * 1024,
|
|
11423
|
-
...(launchSpec.shell ? { shell: true } : {}),
|
|
11424
|
-
});
|
|
11425
|
-
return parseCloudflaredVersion(`${stdout || ''}\n${stderr || ''}`);
|
|
11426
|
-
} catch {
|
|
11427
|
-
return null;
|
|
11428
|
-
}
|
|
11429
|
-
}
|
|
11430
|
-
|
|
11431
|
-
async function installLatestToTemporaryPath({ launchSpec, binaryPath, timeoutMs, platform, runCommand }) {
|
|
11432
|
-
const temporaryDir = (0,external_node_path_.join)((0,external_node_path_.dirname)(binaryPath), `.cloudflared-update-${process.pid}-${Date.now()}`);
|
|
11433
|
-
const temporaryBinaryPath = (0,external_node_path_.join)(temporaryDir, (0,external_node_path_.basename)(binaryPath));
|
|
11434
|
-
await (0,promises_.mkdir)(temporaryDir, { recursive: true });
|
|
11435
|
-
try {
|
|
11436
|
-
await runCommand(launchSpec.command, [...launchSpec.args, 'bin', 'install', 'latest'], {
|
|
11437
|
-
encoding: 'utf8',
|
|
11438
|
-
timeout: timeoutMs,
|
|
11439
|
-
maxBuffer: 4 * 1024 * 1024,
|
|
11440
|
-
env: { ...process.env, CLOUDFLARED_BIN: temporaryBinaryPath },
|
|
11441
|
-
...(launchSpec.shell ? { shell: true } : {}),
|
|
11442
|
-
});
|
|
11443
|
-
const version = await runVersion(temporaryBinaryPath, timeoutMs, runCommand);
|
|
11444
|
-
if (!version) throw new Error('downloaded cloudflared did not report a valid version');
|
|
11445
|
-
|
|
11446
|
-
if (platform === 'win32' && (0,external_node_fs_.existsSync)(binaryPath)) {
|
|
11447
|
-
const backupPath = `${binaryPath}.previous-${process.pid}`;
|
|
11448
|
-
await (0,promises_.rename)(binaryPath, backupPath);
|
|
11449
|
-
try {
|
|
11450
|
-
await (0,promises_.rename)(temporaryBinaryPath, binaryPath);
|
|
11451
|
-
await (0,promises_.rm)(backupPath, { force: true });
|
|
11452
|
-
} catch (error) {
|
|
11453
|
-
await (0,promises_.rename)(backupPath, binaryPath).catch(() => undefined);
|
|
11454
|
-
throw error;
|
|
11455
|
-
}
|
|
11456
|
-
} else {
|
|
11457
|
-
await (0,promises_.rename)(temporaryBinaryPath, binaryPath);
|
|
11458
|
-
}
|
|
11459
|
-
return version;
|
|
11460
|
-
} finally {
|
|
11461
|
-
await (0,promises_.rm)(temporaryDir, { recursive: true, force: true });
|
|
11462
|
-
}
|
|
11463
|
-
}
|
|
11464
|
-
|
|
11465
|
-
async function resolveManagedCloudflared({
|
|
11466
|
-
launchSpec,
|
|
11467
|
-
updateStatePath,
|
|
11468
|
-
now = Date.now(),
|
|
11469
|
-
updateIntervalMs = DEFAULT_UPDATE_INTERVAL_MS,
|
|
11470
|
-
timeoutMs = DEFAULT_UPDATE_TIMEOUT_MS,
|
|
11471
|
-
platform = process.platform,
|
|
11472
|
-
runCommand = execFileAsync,
|
|
11473
|
-
}) {
|
|
11474
|
-
const state = await readUpdateState(updateStatePath);
|
|
11475
|
-
const lastAttemptAt = Date.parse(state?.lastAttemptAt || '');
|
|
11476
|
-
const recentlyAttempted = Number.isFinite(lastAttemptAt) && now - lastAttemptAt < updateIntervalMs;
|
|
11477
|
-
if (recentlyAttempted) {
|
|
11478
|
-
return {
|
|
11479
|
-
launchSpec,
|
|
11480
|
-
version: state?.installedVersion ?? null,
|
|
11481
|
-
update: 'skipped',
|
|
11482
|
-
};
|
|
11483
|
-
}
|
|
11484
|
-
|
|
11485
|
-
const attemptedAt = new Date(now).toISOString();
|
|
11486
|
-
const binaryPath = launchSpec.managedBinaryPath;
|
|
11487
|
-
if (launchSpec.source !== 'dependency' || !binaryPath) {
|
|
11488
|
-
const version = state?.installedVersion ?? null;
|
|
11489
|
-
let stateWarning = '';
|
|
11490
|
-
try {
|
|
11491
|
-
await writeUpdateState(updateStatePath, {
|
|
11492
|
-
...state,
|
|
11493
|
-
lastAttemptAt: attemptedAt,
|
|
11494
|
-
installedVersion: version,
|
|
11495
|
-
});
|
|
11496
|
-
} catch (error) {
|
|
11497
|
-
stateWarning = ` Update state could not be saved: ${error instanceof Error ? error.message : String(error)}`;
|
|
11498
|
-
}
|
|
11499
|
-
return {
|
|
11500
|
-
launchSpec,
|
|
11501
|
-
version,
|
|
11502
|
-
update: 'skipped',
|
|
11503
|
-
warning: `Skipping cloudflared self-update for unmanaged ${launchSpec.source} executable: ${launchSpec.description}.${stateWarning}`,
|
|
11504
|
-
};
|
|
11505
|
-
}
|
|
11506
|
-
|
|
11507
|
-
const previousVersion = await runVersion(binaryPath, timeoutMs, runCommand);
|
|
11508
|
-
try {
|
|
11509
|
-
const installedVersion = await installLatestToTemporaryPath({
|
|
11510
|
-
launchSpec,
|
|
11511
|
-
binaryPath,
|
|
11512
|
-
timeoutMs,
|
|
11513
|
-
platform,
|
|
11514
|
-
runCommand,
|
|
11515
|
-
});
|
|
11516
|
-
await writeUpdateState(updateStatePath, {
|
|
11517
|
-
lastAttemptAt: attemptedAt,
|
|
11518
|
-
lastSuccessAt: attemptedAt,
|
|
11519
|
-
installedVersion,
|
|
11520
|
-
});
|
|
11521
|
-
return {
|
|
11522
|
-
launchSpec,
|
|
11523
|
-
version: installedVersion,
|
|
11524
|
-
update: previousVersion ? 'updated' : 'fresh',
|
|
11525
|
-
};
|
|
11526
|
-
} catch (error) {
|
|
11527
|
-
const fallbackVersion = previousVersion || (await runVersion(binaryPath, timeoutMs, runCommand));
|
|
11528
|
-
await writeUpdateState(updateStatePath, {
|
|
11529
|
-
...state,
|
|
11530
|
-
lastAttemptAt: attemptedAt,
|
|
11531
|
-
installedVersion: fallbackVersion,
|
|
11532
|
-
}).catch(() => undefined);
|
|
11533
|
-
return {
|
|
11534
|
-
launchSpec,
|
|
11535
|
-
version: fallbackVersion,
|
|
11536
|
-
update: 'failed',
|
|
11537
|
-
warning: `cloudflared update failed; continuing with ${fallbackVersion || 'the existing launcher'}: ${error instanceof Error ? error.message : String(error)}`,
|
|
11538
|
-
};
|
|
11539
|
-
}
|
|
11540
|
-
}
|
|
11541
|
-
|
|
11542
|
-
;// CONCATENATED MODULE: ../../packages/cloudflared-tunnel/index.mjs
|
|
11543
|
-
|
|
11544
|
-
|
|
11545
|
-
|
|
11365
|
+
;// CONCATENATED MODULE: ../../packages/cloudflared-tunnel/launch-spec.mjs
|
|
11546
11366
|
|
|
11547
11367
|
|
|
11548
11368
|
|
|
11549
11369
|
|
|
11550
11370
|
|
|
11551
|
-
const QUICK_TUNNEL_URL_PATTERN = /https:\/\/[a-z0-9-]+\.trycloudflare\.com(?=$|[\s"',)\]])/g;
|
|
11552
11371
|
const npmFallbackArgs = ['--yes', '--package=cloudflared', 'cloudflared'];
|
|
11553
11372
|
const npmFallbackDescription = `npx ${npmFallbackArgs.join(' ')}`;
|
|
11554
11373
|
const defaultUrlTimeoutMs = 90_000;
|
|
11555
11374
|
|
|
11556
|
-
function supportsFastAutoProtocolFallback(version) {
|
|
11557
|
-
if (!version) return false;
|
|
11558
|
-
const parts = version.split('.').map(Number);
|
|
11559
|
-
const threshold = [2026, 5, 2];
|
|
11560
|
-
for (let index = 0; index < threshold.length; index += 1) {
|
|
11561
|
-
const value = parts[index] || 0;
|
|
11562
|
-
if (value !== threshold[index]) return value > threshold[index];
|
|
11563
|
-
}
|
|
11564
|
-
return true;
|
|
11565
|
-
}
|
|
11566
|
-
|
|
11567
|
-
function extractQuickTunnelUrl(logContent) {
|
|
11568
|
-
if (typeof logContent !== 'string' || logContent.length === 0) {
|
|
11569
|
-
return null;
|
|
11570
|
-
}
|
|
11571
|
-
|
|
11572
|
-
const match = QUICK_TUNNEL_URL_PATTERN.exec(logContent);
|
|
11573
|
-
QUICK_TUNNEL_URL_PATTERN.lastIndex = 0;
|
|
11574
|
-
return match?.[0] ?? null;
|
|
11575
|
-
}
|
|
11576
|
-
|
|
11577
11375
|
function isQuickTunnelUrl(url) {
|
|
11578
11376
|
if (typeof url !== 'string' || !url.trim()) return false;
|
|
11579
11377
|
try {
|
|
@@ -11657,55 +11455,6 @@ function readProcessCommandLine(pid, { platform = process.platform, spawnSyncImp
|
|
|
11657
11455
|
return result.status === 0 ? String(result.stdout || '').trim() : '';
|
|
11658
11456
|
}
|
|
11659
11457
|
|
|
11660
|
-
function extractCloudflaredMetricsBaseUrl(logContent) {
|
|
11661
|
-
if (typeof logContent !== 'string' || logContent.length === 0) {
|
|
11662
|
-
return null;
|
|
11663
|
-
}
|
|
11664
|
-
const match = logContent.match(
|
|
11665
|
-
/Starting metrics server on (?:https?:\/\/)?(127\.0\.0\.1|localhost|\[::1\]):(\d+)\/metrics\b/iu,
|
|
11666
|
-
);
|
|
11667
|
-
if (!match) return null;
|
|
11668
|
-
return `http://${match[1]}:${match[2]}`;
|
|
11669
|
-
}
|
|
11670
|
-
|
|
11671
|
-
async function probeCloudflaredReadiness(logContent, { fetchFn = globalThis.fetch, timeoutMs = 1000 } = {}) {
|
|
11672
|
-
const metricsBaseUrl = extractCloudflaredMetricsBaseUrl(logContent);
|
|
11673
|
-
if (!metricsBaseUrl || typeof fetchFn !== 'function') return false;
|
|
11674
|
-
|
|
11675
|
-
const controller = new AbortController();
|
|
11676
|
-
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
11677
|
-
try {
|
|
11678
|
-
const response = await fetchFn(`${metricsBaseUrl}/ready`, { signal: controller.signal });
|
|
11679
|
-
return response.ok;
|
|
11680
|
-
} catch {
|
|
11681
|
-
return false;
|
|
11682
|
-
} finally {
|
|
11683
|
-
clearTimeout(timeout);
|
|
11684
|
-
}
|
|
11685
|
-
}
|
|
11686
|
-
|
|
11687
|
-
async function probeQuickTunnelPublicHealth(state, { fetchFn = globalThis.fetch, timeoutMs = 1_500 } = {}) {
|
|
11688
|
-
if (!isQuickTunnelUrl(state?.url) || typeof fetchFn !== 'function') return false;
|
|
11689
|
-
|
|
11690
|
-
const controller = new AbortController();
|
|
11691
|
-
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
11692
|
-
try {
|
|
11693
|
-
const healthUrl = new URL('/health', state.url);
|
|
11694
|
-
healthUrl.searchParams.set('_vibelet_reuse_probe', String(Date.now()));
|
|
11695
|
-
const response = await fetchFn(healthUrl, {
|
|
11696
|
-
headers: { 'cache-control': 'no-cache' },
|
|
11697
|
-
signal: controller.signal,
|
|
11698
|
-
});
|
|
11699
|
-
if (!response.ok) return false;
|
|
11700
|
-
const payload = await response.json().catch(() => null);
|
|
11701
|
-
return payload?.status === 'ok';
|
|
11702
|
-
} catch {
|
|
11703
|
-
return false;
|
|
11704
|
-
} finally {
|
|
11705
|
-
clearTimeout(timeout);
|
|
11706
|
-
}
|
|
11707
|
-
}
|
|
11708
|
-
|
|
11709
11458
|
function getNpmFallbackCommand(platform = process.platform) {
|
|
11710
11459
|
return platform === 'win32' ? 'npx.cmd' : 'npx';
|
|
11711
11460
|
}
|
|
@@ -11878,6 +11627,316 @@ function resolvePreferredCloudflaredLaunchSpec() {
|
|
|
11878
11627
|
return dependencyCliPath ? createDependencyLaunchSpec(dependencyCliPath) : resolveCloudflaredLaunchSpec();
|
|
11879
11628
|
}
|
|
11880
11629
|
|
|
11630
|
+
function cloudflaredChildEnv(launchSpec, env = process.env, versions = process.versions) {
|
|
11631
|
+
// Electron must run the npm CLI as Node; app mode can exit while its child
|
|
11632
|
+
// tunnel is still starting, losing ownership of the process.
|
|
11633
|
+
return launchSpec.source === 'dependency' && versions.electron ? { ...env, ELECTRON_RUN_AS_NODE: '1' } : env;
|
|
11634
|
+
}
|
|
11635
|
+
|
|
11636
|
+
;// CONCATENATED MODULE: external "node:http"
|
|
11637
|
+
const external_node_http_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:http");
|
|
11638
|
+
;// CONCATENATED MODULE: external "node:https"
|
|
11639
|
+
const external_node_https_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:https");
|
|
11640
|
+
;// CONCATENATED MODULE: ../../packages/cloudflared-tunnel/health-fetch.mjs
|
|
11641
|
+
|
|
11642
|
+
|
|
11643
|
+
|
|
11644
|
+
// This package runs in Node and Electron plugin hosts. Renderer fetch applies
|
|
11645
|
+
// browser CORS to cloudflared's local metrics endpoint, which has no CORS headers.
|
|
11646
|
+
function fetchTunnelHealth(input, { signal, headers } = {}) {
|
|
11647
|
+
const url = new URL(input);
|
|
11648
|
+
const request = url.protocol === 'https:' ? external_node_https_namespaceObject.request : url.protocol === 'http:' ? external_node_http_namespaceObject.request : null;
|
|
11649
|
+
if (!request) return Promise.reject(new Error('Unsupported tunnel health protocol'));
|
|
11650
|
+
return new Promise((resolve, reject) => {
|
|
11651
|
+
const req = request(url, { signal, headers, method: 'GET' }, (res) => {
|
|
11652
|
+
const chunks = [];
|
|
11653
|
+
let size = 0;
|
|
11654
|
+
res.on('data', (chunk) => {
|
|
11655
|
+
size += chunk.length;
|
|
11656
|
+
if (size > 64 * 1024) {
|
|
11657
|
+
res.destroy(new Error('Tunnel health response is too large'));
|
|
11658
|
+
return;
|
|
11659
|
+
}
|
|
11660
|
+
chunks.push(chunk);
|
|
11661
|
+
});
|
|
11662
|
+
res.on('error', reject);
|
|
11663
|
+
res.on('end', () => {
|
|
11664
|
+
const body = Buffer.concat(chunks).toString('utf8');
|
|
11665
|
+
resolve({
|
|
11666
|
+
ok: res.statusCode >= 200 && res.statusCode < 300,
|
|
11667
|
+
json: async () => JSON.parse(body),
|
|
11668
|
+
});
|
|
11669
|
+
});
|
|
11670
|
+
});
|
|
11671
|
+
req.on('error', reject);
|
|
11672
|
+
req.end();
|
|
11673
|
+
});
|
|
11674
|
+
}
|
|
11675
|
+
|
|
11676
|
+
// EXTERNAL MODULE: external "node:fs/promises"
|
|
11677
|
+
var promises_ = __nccwpck_require__(1455);
|
|
11678
|
+
// EXTERNAL MODULE: external "node:util"
|
|
11679
|
+
var external_node_util_ = __nccwpck_require__(7975);
|
|
11680
|
+
;// CONCATENATED MODULE: ../../packages/cloudflared-tunnel/managed-binary.mjs
|
|
11681
|
+
|
|
11682
|
+
|
|
11683
|
+
|
|
11684
|
+
|
|
11685
|
+
|
|
11686
|
+
|
|
11687
|
+
|
|
11688
|
+
const execFileAsync = (0,external_node_util_.promisify)(external_node_child_process_.execFile);
|
|
11689
|
+
const DEFAULT_UPDATE_INTERVAL_MS = 24 * 60 * 60 * 1000;
|
|
11690
|
+
const DEFAULT_UPDATE_TIMEOUT_MS = 30_000;
|
|
11691
|
+
|
|
11692
|
+
function parseCloudflaredVersion(output) {
|
|
11693
|
+
return String(output || '').match(/cloudflared version\s+([0-9]+(?:\.[0-9]+){1,2})/i)?.[1] ?? null;
|
|
11694
|
+
}
|
|
11695
|
+
|
|
11696
|
+
async function readUpdateState(updateStatePath) {
|
|
11697
|
+
try {
|
|
11698
|
+
const state = JSON.parse(await (0,promises_.readFile)(updateStatePath, 'utf8'));
|
|
11699
|
+
return state && typeof state === 'object' ? state : null;
|
|
11700
|
+
} catch {
|
|
11701
|
+
return null;
|
|
11702
|
+
}
|
|
11703
|
+
}
|
|
11704
|
+
|
|
11705
|
+
async function writeUpdateState(updateStatePath, state) {
|
|
11706
|
+
await (0,promises_.mkdir)((0,external_node_path_.dirname)(updateStatePath), { recursive: true });
|
|
11707
|
+
const temporaryPath = `${updateStatePath}.tmp-${process.pid}-${Date.now()}`;
|
|
11708
|
+
await (0,promises_.writeFile)(temporaryPath, `${JSON.stringify(state, null, 2)}\n`, 'utf8');
|
|
11709
|
+
await (0,promises_.rename)(temporaryPath, updateStatePath);
|
|
11710
|
+
}
|
|
11711
|
+
|
|
11712
|
+
async function runVersion(binaryPath, timeoutMs, runCommand) {
|
|
11713
|
+
if (!binaryPath || !(0,external_node_fs_.existsSync)(binaryPath)) return null;
|
|
11714
|
+
try {
|
|
11715
|
+
const { stdout, stderr } = await runCommand(binaryPath, ['--version'], {
|
|
11716
|
+
encoding: 'utf8',
|
|
11717
|
+
timeout: timeoutMs,
|
|
11718
|
+
maxBuffer: 1024 * 1024,
|
|
11719
|
+
});
|
|
11720
|
+
return parseCloudflaredVersion(`${stdout || ''}\n${stderr || ''}`);
|
|
11721
|
+
} catch {
|
|
11722
|
+
return null;
|
|
11723
|
+
}
|
|
11724
|
+
}
|
|
11725
|
+
|
|
11726
|
+
async function probeCloudflaredLaunchSpecVersion(
|
|
11727
|
+
launchSpec,
|
|
11728
|
+
{ timeoutMs = 5_000, runCommand = execFileAsync } = {},
|
|
11729
|
+
) {
|
|
11730
|
+
try {
|
|
11731
|
+
const { stdout, stderr } = await runCommand(launchSpec.command, [...launchSpec.args, '--version'], {
|
|
11732
|
+
encoding: 'utf8',
|
|
11733
|
+
timeout: timeoutMs,
|
|
11734
|
+
maxBuffer: 1024 * 1024,
|
|
11735
|
+
env: cloudflaredChildEnv(launchSpec),
|
|
11736
|
+
...(launchSpec.shell ? { shell: true } : {}),
|
|
11737
|
+
});
|
|
11738
|
+
return parseCloudflaredVersion(`${stdout || ''}\n${stderr || ''}`);
|
|
11739
|
+
} catch {
|
|
11740
|
+
return null;
|
|
11741
|
+
}
|
|
11742
|
+
}
|
|
11743
|
+
|
|
11744
|
+
async function installLatestToTemporaryPath({ launchSpec, binaryPath, timeoutMs, platform, runCommand }) {
|
|
11745
|
+
const temporaryDir = (0,external_node_path_.join)((0,external_node_path_.dirname)(binaryPath), `.cloudflared-update-${process.pid}-${Date.now()}`);
|
|
11746
|
+
const temporaryBinaryPath = (0,external_node_path_.join)(temporaryDir, (0,external_node_path_.basename)(binaryPath));
|
|
11747
|
+
await (0,promises_.mkdir)(temporaryDir, { recursive: true });
|
|
11748
|
+
try {
|
|
11749
|
+
await runCommand(launchSpec.command, [...launchSpec.args, 'bin', 'install', 'latest'], {
|
|
11750
|
+
encoding: 'utf8',
|
|
11751
|
+
timeout: timeoutMs,
|
|
11752
|
+
maxBuffer: 4 * 1024 * 1024,
|
|
11753
|
+
env: cloudflaredChildEnv(launchSpec, { ...process.env, CLOUDFLARED_BIN: temporaryBinaryPath }),
|
|
11754
|
+
...(launchSpec.shell ? { shell: true } : {}),
|
|
11755
|
+
});
|
|
11756
|
+
const version = await runVersion(temporaryBinaryPath, timeoutMs, runCommand);
|
|
11757
|
+
if (!version) throw new Error('downloaded cloudflared did not report a valid version');
|
|
11758
|
+
|
|
11759
|
+
if (platform === 'win32' && (0,external_node_fs_.existsSync)(binaryPath)) {
|
|
11760
|
+
const backupPath = `${binaryPath}.previous-${process.pid}`;
|
|
11761
|
+
await (0,promises_.rename)(binaryPath, backupPath);
|
|
11762
|
+
try {
|
|
11763
|
+
await (0,promises_.rename)(temporaryBinaryPath, binaryPath);
|
|
11764
|
+
await (0,promises_.rm)(backupPath, { force: true });
|
|
11765
|
+
} catch (error) {
|
|
11766
|
+
await (0,promises_.rename)(backupPath, binaryPath).catch(() => undefined);
|
|
11767
|
+
throw error;
|
|
11768
|
+
}
|
|
11769
|
+
} else {
|
|
11770
|
+
await (0,promises_.rename)(temporaryBinaryPath, binaryPath);
|
|
11771
|
+
}
|
|
11772
|
+
return version;
|
|
11773
|
+
} finally {
|
|
11774
|
+
await (0,promises_.rm)(temporaryDir, { recursive: true, force: true });
|
|
11775
|
+
}
|
|
11776
|
+
}
|
|
11777
|
+
|
|
11778
|
+
async function resolveManagedCloudflared({
|
|
11779
|
+
launchSpec,
|
|
11780
|
+
updateStatePath,
|
|
11781
|
+
now = Date.now(),
|
|
11782
|
+
updateIntervalMs = DEFAULT_UPDATE_INTERVAL_MS,
|
|
11783
|
+
timeoutMs = DEFAULT_UPDATE_TIMEOUT_MS,
|
|
11784
|
+
platform = process.platform,
|
|
11785
|
+
runCommand = execFileAsync,
|
|
11786
|
+
}) {
|
|
11787
|
+
const state = await readUpdateState(updateStatePath);
|
|
11788
|
+
const lastAttemptAt = Date.parse(state?.lastAttemptAt || '');
|
|
11789
|
+
const recentlyAttempted = Number.isFinite(lastAttemptAt) && now - lastAttemptAt < updateIntervalMs;
|
|
11790
|
+
if (recentlyAttempted) {
|
|
11791
|
+
return {
|
|
11792
|
+
launchSpec,
|
|
11793
|
+
version: state?.installedVersion ?? null,
|
|
11794
|
+
update: 'skipped',
|
|
11795
|
+
};
|
|
11796
|
+
}
|
|
11797
|
+
|
|
11798
|
+
const attemptedAt = new Date(now).toISOString();
|
|
11799
|
+
const binaryPath = launchSpec.managedBinaryPath;
|
|
11800
|
+
if (launchSpec.source !== 'dependency' || !binaryPath) {
|
|
11801
|
+
const version = state?.installedVersion ?? null;
|
|
11802
|
+
let stateWarning = '';
|
|
11803
|
+
try {
|
|
11804
|
+
await writeUpdateState(updateStatePath, {
|
|
11805
|
+
...state,
|
|
11806
|
+
lastAttemptAt: attemptedAt,
|
|
11807
|
+
installedVersion: version,
|
|
11808
|
+
});
|
|
11809
|
+
} catch (error) {
|
|
11810
|
+
stateWarning = ` Update state could not be saved: ${error instanceof Error ? error.message : String(error)}`;
|
|
11811
|
+
}
|
|
11812
|
+
return {
|
|
11813
|
+
launchSpec,
|
|
11814
|
+
version,
|
|
11815
|
+
update: 'skipped',
|
|
11816
|
+
warning: `Skipping cloudflared self-update for unmanaged ${launchSpec.source} executable: ${launchSpec.description}.${stateWarning}`,
|
|
11817
|
+
};
|
|
11818
|
+
}
|
|
11819
|
+
|
|
11820
|
+
const previousVersion = await runVersion(binaryPath, timeoutMs, runCommand);
|
|
11821
|
+
try {
|
|
11822
|
+
const installedVersion = await installLatestToTemporaryPath({
|
|
11823
|
+
launchSpec,
|
|
11824
|
+
binaryPath,
|
|
11825
|
+
timeoutMs,
|
|
11826
|
+
platform,
|
|
11827
|
+
runCommand,
|
|
11828
|
+
});
|
|
11829
|
+
await writeUpdateState(updateStatePath, {
|
|
11830
|
+
lastAttemptAt: attemptedAt,
|
|
11831
|
+
lastSuccessAt: attemptedAt,
|
|
11832
|
+
installedVersion,
|
|
11833
|
+
});
|
|
11834
|
+
return {
|
|
11835
|
+
launchSpec,
|
|
11836
|
+
version: installedVersion,
|
|
11837
|
+
update: previousVersion ? 'updated' : 'fresh',
|
|
11838
|
+
};
|
|
11839
|
+
} catch (error) {
|
|
11840
|
+
const fallbackVersion = previousVersion || (await runVersion(binaryPath, timeoutMs, runCommand));
|
|
11841
|
+
await writeUpdateState(updateStatePath, {
|
|
11842
|
+
...state,
|
|
11843
|
+
lastAttemptAt: attemptedAt,
|
|
11844
|
+
installedVersion: fallbackVersion,
|
|
11845
|
+
}).catch(() => undefined);
|
|
11846
|
+
return {
|
|
11847
|
+
launchSpec,
|
|
11848
|
+
version: fallbackVersion,
|
|
11849
|
+
update: 'failed',
|
|
11850
|
+
warning: `cloudflared update failed; continuing with ${fallbackVersion || 'the existing launcher'}: ${error instanceof Error ? error.message : String(error)}`,
|
|
11851
|
+
};
|
|
11852
|
+
}
|
|
11853
|
+
}
|
|
11854
|
+
|
|
11855
|
+
;// CONCATENATED MODULE: ../../packages/cloudflared-tunnel/index.mjs
|
|
11856
|
+
|
|
11857
|
+
|
|
11858
|
+
|
|
11859
|
+
|
|
11860
|
+
|
|
11861
|
+
|
|
11862
|
+
|
|
11863
|
+
|
|
11864
|
+
|
|
11865
|
+
|
|
11866
|
+
|
|
11867
|
+
|
|
11868
|
+
const QUICK_TUNNEL_URL_PATTERN = /https:\/\/[a-z0-9-]+\.trycloudflare\.com(?=$|[\s"',)\]])/g;
|
|
11869
|
+
|
|
11870
|
+
function supportsFastAutoProtocolFallback(version) {
|
|
11871
|
+
if (!version) return false;
|
|
11872
|
+
const parts = version.split('.').map(Number);
|
|
11873
|
+
const threshold = [2026, 5, 2];
|
|
11874
|
+
for (let index = 0; index < threshold.length; index += 1) {
|
|
11875
|
+
const value = parts[index] || 0;
|
|
11876
|
+
if (value !== threshold[index]) return value > threshold[index];
|
|
11877
|
+
}
|
|
11878
|
+
return true;
|
|
11879
|
+
}
|
|
11880
|
+
|
|
11881
|
+
function extractQuickTunnelUrl(logContent) {
|
|
11882
|
+
if (typeof logContent !== 'string' || logContent.length === 0) {
|
|
11883
|
+
return null;
|
|
11884
|
+
}
|
|
11885
|
+
|
|
11886
|
+
const match = QUICK_TUNNEL_URL_PATTERN.exec(logContent);
|
|
11887
|
+
QUICK_TUNNEL_URL_PATTERN.lastIndex = 0;
|
|
11888
|
+
return match?.[0] ?? null;
|
|
11889
|
+
}
|
|
11890
|
+
|
|
11891
|
+
function extractCloudflaredMetricsBaseUrl(logContent) {
|
|
11892
|
+
if (typeof logContent !== 'string' || logContent.length === 0) {
|
|
11893
|
+
return null;
|
|
11894
|
+
}
|
|
11895
|
+
const match = logContent.match(
|
|
11896
|
+
/Starting metrics server on (?:https?:\/\/)?(127\.0\.0\.1|localhost|\[::1\]):(\d+)\/metrics\b/iu,
|
|
11897
|
+
);
|
|
11898
|
+
if (!match) return null;
|
|
11899
|
+
return `http://${match[1]}:${match[2]}`;
|
|
11900
|
+
}
|
|
11901
|
+
|
|
11902
|
+
async function probeCloudflaredReadiness(logContent, { fetchFn = fetchTunnelHealth, timeoutMs = 1000 } = {}) {
|
|
11903
|
+
const metricsBaseUrl = extractCloudflaredMetricsBaseUrl(logContent);
|
|
11904
|
+
if (!metricsBaseUrl || typeof fetchFn !== 'function') return false;
|
|
11905
|
+
|
|
11906
|
+
const controller = new AbortController();
|
|
11907
|
+
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
11908
|
+
try {
|
|
11909
|
+
const response = await fetchFn(`${metricsBaseUrl}/ready`, { signal: controller.signal });
|
|
11910
|
+
return response.ok;
|
|
11911
|
+
} catch {
|
|
11912
|
+
return false;
|
|
11913
|
+
} finally {
|
|
11914
|
+
clearTimeout(timeout);
|
|
11915
|
+
}
|
|
11916
|
+
}
|
|
11917
|
+
|
|
11918
|
+
async function probeQuickTunnelPublicHealth(state, { fetchFn = fetchTunnelHealth, timeoutMs = 1_500 } = {}) {
|
|
11919
|
+
if (!isQuickTunnelUrl(state?.url) || typeof fetchFn !== 'function') return false;
|
|
11920
|
+
|
|
11921
|
+
const controller = new AbortController();
|
|
11922
|
+
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
11923
|
+
try {
|
|
11924
|
+
const healthUrl = new URL('/health', state.url);
|
|
11925
|
+
healthUrl.searchParams.set('_vibelet_reuse_probe', String(Date.now()));
|
|
11926
|
+
const response = await fetchFn(healthUrl, {
|
|
11927
|
+
headers: { 'cache-control': 'no-cache' },
|
|
11928
|
+
signal: controller.signal,
|
|
11929
|
+
});
|
|
11930
|
+
if (!response.ok) return false;
|
|
11931
|
+
const payload = await response.json().catch(() => null);
|
|
11932
|
+
return payload?.status === 'ok';
|
|
11933
|
+
} catch {
|
|
11934
|
+
return false;
|
|
11935
|
+
} finally {
|
|
11936
|
+
clearTimeout(timeout);
|
|
11937
|
+
}
|
|
11938
|
+
}
|
|
11939
|
+
|
|
11881
11940
|
function summarizeCloudflaredLog(logContent, { maxLines = 8, maxChars = 1200 } = {}) {
|
|
11882
11941
|
const lines = logContent
|
|
11883
11942
|
.split(/\r?\n/u)
|
|
@@ -12187,6 +12246,7 @@ async function startTunnel({
|
|
|
12187
12246
|
[...launchSpec.args, 'tunnel', '--no-autoupdate', '--protocol', effectiveProtocol, '--url', originUrl],
|
|
12188
12247
|
{
|
|
12189
12248
|
detached: true,
|
|
12249
|
+
env: cloudflaredChildEnv(launchSpec),
|
|
12190
12250
|
stdio: ['ignore', stdoutLogFd, stderrLogFd],
|
|
12191
12251
|
windowsHide: true,
|
|
12192
12252
|
...(launchSpec.shell ? { shell: true } : {}),
|
|
@@ -14040,7 +14100,7 @@ function parseAccessTargetArg(argv, fail, env = process.env) {
|
|
|
14040
14100
|
/* harmony export */ });
|
|
14041
14101
|
/* harmony import */ var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(3024);
|
|
14042
14102
|
/* harmony import */ var node_path__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(6760);
|
|
14043
|
-
/* harmony import */ var _cloudflared_tunnel_manager_mjs__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(
|
|
14103
|
+
/* harmony import */ var _cloudflared_tunnel_manager_mjs__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(1484);
|
|
14044
14104
|
|
|
14045
14105
|
|
|
14046
14106
|
|
|
@@ -15975,7 +16035,7 @@ __nccwpck_require__.a(__webpack_module__, async (__webpack_handle_async_dependen
|
|
|
15975
16035
|
/* harmony import */ var node_path__WEBPACK_IMPORTED_MODULE_4__ = __nccwpck_require__(6760);
|
|
15976
16036
|
/* harmony import */ var node_url__WEBPACK_IMPORTED_MODULE_5__ = __nccwpck_require__(3136);
|
|
15977
16037
|
/* harmony import */ var _vibelet_cli_args_mjs__WEBPACK_IMPORTED_MODULE_17__ = __nccwpck_require__(6927);
|
|
15978
|
-
/* harmony import */ var _cloudflared_tunnel_manager_mjs__WEBPACK_IMPORTED_MODULE_6__ = __nccwpck_require__(
|
|
16038
|
+
/* harmony import */ var _cloudflared_tunnel_manager_mjs__WEBPACK_IMPORTED_MODULE_6__ = __nccwpck_require__(1484);
|
|
15979
16039
|
/* harmony import */ var _vibelet_cloudflare_runtime_mjs__WEBPACK_IMPORTED_MODULE_7__ = __nccwpck_require__(3869);
|
|
15980
16040
|
/* harmony import */ var _vibelet_launchd_mjs__WEBPACK_IMPORTED_MODULE_13__ = __nccwpck_require__(1010);
|
|
15981
16041
|
/* harmony import */ var _linux_systemd_mjs__WEBPACK_IMPORTED_MODULE_8__ = __nccwpck_require__(4217);
|