scp-next 1.0.6 → 1.0.8

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/cli/index.ts","../../src/client/client.ts","../../src/client/transport.ts","../../src/security/redact.ts","../../src/errors/index.ts","../../src/security/host-verification.ts","../../src/paths/local-path.ts","../../src/client/walk.ts","../../src/paths/remote-path.ts","../../src/config/validation.ts","../../src/client/download.ts","../../src/client/upload.ts","../../src/cli/commands/download.ts","../../src/cli/operands.ts","../../src/cli/commands/shared.ts","../../src/config/environment.ts","../../src/config/load-config.ts","../../src/config/resolve-config.ts","../../src/config/jobs.ts","../../src/config/profiles.ts","../../src/cli/output.ts","../../src/cli/commands/run.ts","../../src/cli/commands/upload.ts"],"sourcesContent":["import { readFileSync, realpathSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { Command, CommanderError } from \"commander\";\n\nimport { download } from \"../client/download.js\";\nimport { upload } from \"../client/upload.js\";\nimport { ScpNextError } from \"../errors/index.js\";\nimport { formatErrorMessage } from \"../security/redact.js\";\nimport { createDownloadCommand } from \"./commands/download.js\";\nimport { createRunCommand } from \"./commands/run.js\";\nimport { createUploadCommand } from \"./commands/upload.js\";\nimport type { Output } from \"./output.js\";\nimport type { TransferHandlers } from \"./commands/shared.js\";\n\nexport interface RunCliOptions {\n argv?: string[];\n cwd?: string;\n output?: Output;\n handlers?: TransferHandlers;\n}\n\nfunction readPackageVersion(currentModuleUrl = import.meta.url): string {\n const currentFile = fileURLToPath(currentModuleUrl);\n const packageJsonPath = resolve(dirname(currentFile), \"..\", \"..\", \"package.json\");\n const packageJson = JSON.parse(readFileSync(packageJsonPath, \"utf8\")) as { version?: string };\n return packageJson.version ?? \"0.0.0\";\n}\n\nexport function isCliEntrypoint(\n currentModuleUrl = import.meta.url,\n argv: string[] = process.argv\n): boolean {\n const executedFile = argv[1];\n if (!executedFile) {\n return false;\n }\n\n try {\n return realpathSync(fileURLToPath(currentModuleUrl)) === realpathSync(executedFile);\n } catch {\n return false;\n }\n}\n\nexport async function runCli(options: RunCliOptions = {}): Promise<number> {\n const output = options.output ?? { stdout: process.stdout, stderr: process.stderr };\n const cwd = options.cwd ?? process.cwd();\n const handlers = options.handlers ?? { upload, download };\n const program = new Command();\n\n program\n .name(\"scp-next\")\n .description(\"Secure file transfers over SSH using SFTP\")\n .version(readPackageVersion())\n .configureOutput({\n writeOut: (message) => output.stdout.write(message),\n writeErr: (message) => output.stderr.write(message)\n })\n .showHelpAfterError()\n .exitOverride();\n\n program.addCommand(createUploadCommand(handlers, output, cwd));\n program.addCommand(createDownloadCommand(handlers, output, cwd));\n program.addCommand(createRunCommand(handlers, output, cwd));\n\n try {\n await program.parseAsync(options.argv ?? process.argv, { from: \"node\" });\n return 0;\n } catch (error) {\n if (error instanceof CommanderError) {\n if (error.code === \"commander.helpDisplayed\" || error.code === \"commander.version\") {\n return 0;\n }\n output.stderr.write(`${formatErrorMessage(error.message)}\\n`);\n return error.exitCode || 1;\n }\n\n const verbose = (options.argv ?? process.argv).includes(\"--verbose\");\n if (error instanceof ScpNextError) {\n output.stderr.write(`Error: ${formatErrorMessage(error.message)}\\n`);\n if (verbose && error.cause instanceof Error) {\n output.stderr.write(`${formatErrorMessage(error.cause.stack ?? error.cause.message)}\\n`);\n }\n return 1;\n }\n\n output.stderr.write(`Error: ${formatErrorMessage(error)}\\n`);\n if (verbose && error instanceof Error && error.stack) {\n output.stderr.write(`${formatErrorMessage(error.stack)}\\n`);\n }\n return 1;\n }\n}\n\nif (isCliEntrypoint()) {\n void runCli().then((exitCode) => {\n process.exitCode = exitCode;\n });\n}\n","import { access, mkdir, stat } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport { Ssh2SftpTransport } from \"./transport.js\";\nimport type { SftpTransport } from \"./transport.js\";\nimport { walkLocalFiles, walkRemoteFiles } from \"./walk.js\";\nimport { TransferError, ValidationError } from \"../errors/index.js\";\nimport { getLocalPathKind, resolveLocalPath } from \"../paths/local-path.js\";\nimport { normalizeRemotePath, remoteDirname, remoteJoin } from \"../paths/remote-path.js\";\nimport type {\n DownloadOptions,\n ScpNextClient,\n ScpServerOptions,\n TransferOptions,\n UploadOptions\n} from \"../types/index.js\";\nimport {\n validateDownloadOptions,\n validateServerOptions,\n validateUploadOptions\n} from \"../config/validation.js\";\n\nexport interface ScpNextClientDependencies {\n transport?: SftpTransport;\n}\n\nfunction percentage(transferredBytes: number, totalBytes?: number): number | undefined {\n if (!totalBytes || totalBytes <= 0) {\n return undefined;\n }\n return Math.min(100, Math.round((transferredBytes / totalBytes) * 100));\n}\n\nfunction mergeOptions<T extends TransferOptions>(\n serverOptions: ScpServerOptions,\n transferOptions: T | undefined\n): ScpServerOptions & T {\n return { ...serverOptions, ...(transferOptions ?? {}) } as ScpServerOptions & T;\n}\n\nfunction hasTrailingPathSeparator(inputPath: string): boolean {\n return /[\\\\/]$/.test(inputPath);\n}\n\nfunction trimmedRemoteDirectory(remotePath: string): string {\n return remotePath.replace(/\\/+$/g, \"\") || \"/\";\n}\n\nfunction remoteBasename(remotePath: string): string {\n return path.posix.basename(trimmedRemoteDirectory(remotePath));\n}\n\nasync function isExistingLocalDirectory(localPath: string): Promise<boolean> {\n try {\n return (await stat(localPath)).isDirectory();\n } catch {\n return false;\n }\n}\n\nexport class ScpNextClientImpl implements ScpNextClient {\n private readonly serverOptions: ScpServerOptions;\n private readonly transport: SftpTransport;\n private connected = false;\n\n constructor(serverOptions: ScpServerOptions, dependencies: ScpNextClientDependencies = {}) {\n this.serverOptions = serverOptions;\n this.transport = dependencies.transport ?? new Ssh2SftpTransport();\n }\n\n async connect(): Promise<void> {\n await validateServerOptions(this.serverOptions);\n await this.transport.connect(this.serverOptions);\n this.connected = true;\n }\n\n async upload(\n localPath: string,\n remotePath: string,\n options: TransferOptions = {}\n ): Promise<void> {\n const uploadOptions: UploadOptions = {\n ...mergeOptions(this.serverOptions, options),\n localPath,\n remotePath\n };\n await validateUploadOptions(uploadOptions);\n\n if (options.dryRun) {\n return;\n }\n\n await this.ensureConnected();\n await this.uploadWithTransport(uploadOptions);\n }\n\n async download(\n remotePath: string,\n localPath: string,\n options: TransferOptions = {}\n ): Promise<void> {\n const downloadOptions: DownloadOptions = {\n ...mergeOptions(this.serverOptions, options),\n remotePath,\n localPath\n };\n await validateDownloadOptions(downloadOptions);\n\n if (options.dryRun) {\n return;\n }\n\n await this.ensureConnected();\n await this.downloadWithTransport(downloadOptions);\n }\n\n async close(): Promise<void> {\n if (this.connected) {\n await this.transport.close();\n this.connected = false;\n }\n }\n\n private async ensureConnected(): Promise<void> {\n if (!this.connected) {\n await this.connect();\n }\n }\n\n private async uploadWithTransport(options: UploadOptions): Promise<void> {\n const localKind = await getLocalPathKind(options.localPath);\n const remotePath = normalizeRemotePath(options.remotePath);\n\n if (localKind === \"directory\" && !options.recursive) {\n throw new ValidationError(\"Uploading a directory requires recursive mode.\");\n }\n\n if (localKind === \"file\") {\n const destinationFile = await this.resolveRemoteDestinationForLocalFile(options, remotePath);\n const totalBytes = undefined;\n await this.transport.uploadFile(resolveLocalPath(options.localPath), destinationFile, (step) => {\n options.onProgress?.({\n operation: \"upload\",\n source: options.localPath,\n destination: options.remotePath,\n transferredBytes: step.transferredBytes,\n totalBytes: step.totalBytes || totalBytes,\n percentage: percentage(step.transferredBytes, step.totalBytes),\n currentFile: options.localPath\n });\n });\n return;\n }\n\n const files = await walkLocalFiles(options.localPath);\n const totalBytes = files.reduce((sum, file) => sum + file.size, 0);\n let completedBytes = 0;\n let completedFiles = 0;\n const destinationRoot = await this.resolveRemoteDestinationForLocalDirectory(\n options,\n remotePath\n );\n\n for (const file of files) {\n const destinationFile = remoteJoin(\n destinationRoot,\n file.relativePath.split(path.sep).join(\"/\")\n );\n await this.ensureRemoteParent(destinationFile, true);\n await this.assertRemoteOverwrite(destinationFile, options.overwrite);\n\n await this.transport.uploadFile(file.absolutePath, destinationFile, (step) => {\n const transferredBytes = completedBytes + step.transferredBytes;\n options.onProgress?.({\n operation: \"upload\",\n source: options.localPath,\n destination: options.remotePath,\n transferredBytes,\n totalBytes,\n percentage: percentage(transferredBytes, totalBytes),\n currentFile: file.relativePath,\n completedFiles,\n totalFiles: files.length\n });\n });\n\n completedBytes += file.size;\n completedFiles += 1;\n }\n }\n\n private async resolveRemoteDestinationForLocalFile(\n options: UploadOptions,\n remotePath: string\n ): Promise<string> {\n const remoteKind = await this.transport.exists(remotePath);\n const isDirectoryLikeDestination = remoteKind === \"d\" || remotePath.endsWith(\"/\");\n\n if (!isDirectoryLikeDestination) {\n await this.ensureRemoteParent(remotePath, options.createDirectories);\n await this.assertRemoteOverwrite(remotePath, options.overwrite);\n return remotePath;\n }\n\n if (remoteKind && remoteKind !== \"d\") {\n throw new TransferError(`Remote destination already exists and is not a directory: ${remotePath}`, {\n context: { remotePath }\n });\n }\n\n const remoteDirectory = remotePath.replace(/\\/+$/g, \"\") || \"/\";\n if (!remoteKind) {\n if (!options.createDirectories) {\n throw new TransferError(`Remote destination directory does not exist: ${remoteDirectory}`, {\n context: { remotePath }\n });\n }\n await this.transport.mkdir(remoteDirectory, true);\n }\n\n const destinationFile = remoteJoin(\n remoteDirectory,\n path.basename(resolveLocalPath(options.localPath))\n );\n await this.assertRemoteOverwrite(destinationFile, options.overwrite);\n return destinationFile;\n }\n\n private async resolveRemoteDestinationForLocalDirectory(\n options: UploadOptions,\n remotePath: string\n ): Promise<string> {\n const remoteKind = await this.transport.exists(remotePath);\n const isDirectoryLikeDestination = remoteKind === \"d\" || remotePath.endsWith(\"/\");\n const localDirectoryName = path.basename(resolveLocalPath(options.localPath));\n\n if (remoteKind && remoteKind !== \"d\") {\n throw new TransferError(`Remote destination already exists and is not a directory: ${remotePath}`, {\n context: { remotePath }\n });\n }\n\n if (isDirectoryLikeDestination) {\n const remoteDirectory = trimmedRemoteDirectory(remotePath);\n if (!remoteKind) {\n if (!options.createDirectories) {\n throw new TransferError(`Remote destination directory does not exist: ${remoteDirectory}`, {\n context: { remotePath }\n });\n }\n await this.transport.mkdir(remoteDirectory, true);\n }\n\n const destinationRoot = remoteJoin(remoteDirectory, localDirectoryName);\n await this.ensureRemoteDirectory(destinationRoot);\n return destinationRoot;\n }\n\n if (!remoteKind) {\n if (!options.createDirectories) {\n throw new TransferError(`Remote destination directory does not exist: ${remotePath}`, {\n context: { remotePath }\n });\n }\n await this.transport.mkdir(remotePath, true);\n }\n\n return remotePath;\n }\n\n private async downloadWithTransport(options: DownloadOptions): Promise<void> {\n const remotePath = normalizeRemotePath(options.remotePath);\n const remoteKind = await this.transport.exists(remotePath);\n\n if (!remoteKind) {\n throw new TransferError(`Remote path does not exist: ${options.remotePath}`, {\n context: { remotePath: options.remotePath }\n });\n }\n\n if (remoteKind === \"d\") {\n if (!options.recursive) {\n throw new ValidationError(\"Downloading a directory requires recursive mode.\");\n }\n await this.downloadDirectory(options);\n return;\n }\n\n await this.downloadSingleFile(options, remotePath);\n }\n\n private async downloadSingleFile(options: DownloadOptions, remotePath: string): Promise<void> {\n const localPath = await this.resolveLocalDestinationForRemoteFile(options, remotePath);\n await this.assertLocalOverwrite(localPath, options.overwrite);\n if (options.createDirectories) {\n await mkdir(path.dirname(localPath), { recursive: true });\n }\n await this.transport.downloadFile(remotePath, localPath, (step) => {\n options.onProgress?.({\n operation: \"download\",\n source: options.remotePath,\n destination: options.localPath,\n transferredBytes: step.transferredBytes,\n totalBytes: step.totalBytes,\n percentage: percentage(step.transferredBytes, step.totalBytes),\n currentFile: options.remotePath\n });\n });\n }\n\n private async downloadDirectory(options: DownloadOptions): Promise<void> {\n const remotePath = normalizeRemotePath(options.remotePath);\n const localRoot = await this.resolveLocalDestinationForRemoteDirectory(options, remotePath);\n const files = await walkRemoteFiles(this.transport, remotePath);\n const totalBytes = files.reduce((sum, file) => sum + file.size, 0);\n let completedBytes = 0;\n let completedFiles = 0;\n\n await mkdir(localRoot, { recursive: Boolean(options.createDirectories) });\n\n for (const file of files) {\n const localFile = path.join(localRoot, ...file.relativePath.split(\"/\"));\n await this.assertLocalOverwrite(localFile, options.overwrite);\n await mkdir(path.dirname(localFile), { recursive: true });\n await this.transport.downloadFile(file.remotePath, localFile, (step) => {\n const transferredBytes = completedBytes + step.transferredBytes;\n options.onProgress?.({\n operation: \"download\",\n source: options.remotePath,\n destination: options.localPath,\n transferredBytes,\n totalBytes,\n percentage: percentage(transferredBytes, totalBytes),\n currentFile: file.relativePath,\n completedFiles,\n totalFiles: files.length\n });\n });\n completedBytes += file.size;\n completedFiles += 1;\n }\n }\n\n private async resolveLocalDestinationForRemoteFile(\n options: DownloadOptions,\n remotePath: string\n ): Promise<string> {\n const localDestination = resolveLocalPath(options.localPath);\n const isDirectoryLikeDestination =\n hasTrailingPathSeparator(options.localPath) || (await isExistingLocalDirectory(localDestination));\n\n if (!isDirectoryLikeDestination) {\n return localDestination;\n }\n\n if (!(await isExistingLocalDirectory(localDestination))) {\n if (!options.createDirectories) {\n throw new TransferError(`Local destination directory does not exist: ${localDestination}`, {\n context: { localPath: options.localPath }\n });\n }\n await mkdir(localDestination, { recursive: true });\n }\n\n return path.join(localDestination, remoteBasename(remotePath));\n }\n\n private async resolveLocalDestinationForRemoteDirectory(\n options: DownloadOptions,\n remotePath: string\n ): Promise<string> {\n const localDestination = resolveLocalPath(options.localPath);\n const isDirectoryLikeDestination =\n hasTrailingPathSeparator(options.localPath) || (await isExistingLocalDirectory(localDestination));\n\n if (!isDirectoryLikeDestination) {\n return localDestination;\n }\n\n if (!(await isExistingLocalDirectory(localDestination))) {\n if (!options.createDirectories) {\n throw new TransferError(`Local destination directory does not exist: ${localDestination}`, {\n context: { localPath: options.localPath }\n });\n }\n await mkdir(localDestination, { recursive: true });\n }\n\n return path.join(localDestination, remoteBasename(remotePath));\n }\n\n private async ensureRemoteParent(remotePath: string, createDirectories = false): Promise<void> {\n const parent = remoteDirname(remotePath);\n if (parent === \".\" || parent === \"/\") {\n return;\n }\n\n if (createDirectories) {\n await this.transport.mkdir(parent, true);\n return;\n }\n\n const exists = await this.transport.exists(parent);\n if (exists !== \"d\") {\n throw new TransferError(`Remote destination parent does not exist: ${parent}`, {\n context: { remotePath }\n });\n }\n }\n\n private async ensureRemoteDirectory(remotePath: string): Promise<void> {\n const exists = await this.transport.exists(remotePath);\n if (exists && exists !== \"d\") {\n throw new TransferError(`Remote destination already exists and is not a directory: ${remotePath}`, {\n context: { remotePath }\n });\n }\n if (!exists) {\n await this.transport.mkdir(remotePath, true);\n }\n }\n\n private async assertRemoteOverwrite(remotePath: string, overwrite = false): Promise<void> {\n if (overwrite) {\n return;\n }\n const exists = await this.transport.exists(remotePath);\n if (exists) {\n throw new TransferError(`Remote destination already exists: ${remotePath}`, {\n context: { remotePath }\n });\n }\n }\n\n private async assertLocalOverwrite(localPath: string, overwrite = false): Promise<void> {\n if (overwrite) {\n return;\n }\n\n try {\n await access(localPath);\n throw new TransferError(`Local destination already exists: ${localPath}`, {\n context: { localPath }\n });\n } catch (error) {\n if (error instanceof TransferError) {\n throw error;\n }\n }\n }\n}\n\nexport function createClient(options: ScpServerOptions): ScpNextClient {\n return new ScpNextClientImpl(options);\n}\n","import { readFile } from \"node:fs/promises\";\n\nimport SftpClient from \"ssh2-sftp-client\";\nimport type {\n ConnectOptions as SftpConnectOptions,\n FileInfo,\n TransferOptions as SftpTransferOptions\n} from \"ssh2-sftp-client\";\n\nimport {\n ConnectionError,\n HostVerificationError,\n TransferError,\n toScpNextError\n} from \"../errors/index.js\";\nimport { createHostVerifier, resolveAllowedFingerprints } from \"../security/host-verification.js\";\nimport { formatErrorMessage } from \"../security/redact.js\";\nimport type { ScpServerOptions } from \"../types/index.js\";\nimport { expandHome } from \"../paths/local-path.js\";\n\nexport interface RemoteFileInfo {\n type: \"-\" | \"d\" | \"l\";\n name: string;\n size: number;\n}\n\nexport interface TransferStep {\n transferredBytes: number;\n chunkBytes: number;\n totalBytes: number;\n}\n\nexport interface SftpTransport {\n connect(options: ScpServerOptions): Promise<void>;\n close(): Promise<void>;\n exists(remotePath: string): Promise<false | \"-\" | \"d\" | \"l\">;\n mkdir(remotePath: string, recursive?: boolean): Promise<void>;\n list(remotePath: string): Promise<RemoteFileInfo[]>;\n uploadFile(\n localPath: string,\n remotePath: string,\n onStep?: (step: TransferStep) => void\n ): Promise<void>;\n downloadFile(\n remotePath: string,\n localPath: string,\n onStep?: (step: TransferStep) => void\n ): Promise<void>;\n}\n\nfunction toRemoteFileInfo(info: FileInfo): RemoteFileInfo {\n return {\n type: info.type,\n name: info.name,\n size: info.size\n };\n}\n\nexport class Ssh2SftpTransport implements SftpTransport {\n private readonly client: SftpClient;\n\n constructor(name = \"scp-next\") {\n this.client = new SftpClient(name, {\n error: () => undefined,\n end: () => undefined,\n close: () => undefined\n });\n }\n\n async connect(options: ScpServerOptions): Promise<void> {\n const allowedFingerprints = await resolveAllowedFingerprints(options);\n const hostVerifier = createHostVerifier(allowedFingerprints);\n\n const connectOptions: SftpConnectOptions = {};\n if (options.host !== undefined) connectOptions.host = options.host;\n if (options.port !== undefined) connectOptions.port = options.port;\n if (options.username !== undefined) connectOptions.username = options.username;\n if (options.password !== undefined) connectOptions.password = options.password;\n if (options.privateKey !== undefined) {\n connectOptions.privateKey = options.privateKey;\n } else if (options.privateKeyFile) {\n connectOptions.privateKey = await readFile(expandHome(options.privateKeyFile), \"utf8\");\n }\n if (options.passphrase !== undefined) connectOptions.passphrase = options.passphrase;\n const agent = options.agent ?? process.env.SSH_AUTH_SOCK;\n if (agent !== undefined) {\n connectOptions.agent = agent;\n }\n if (options.timeout !== undefined) connectOptions.readyTimeout = options.timeout;\n if (hostVerifier) {\n connectOptions.hostHash = \"sha256\";\n connectOptions.hostVerifier = hostVerifier;\n }\n\n try {\n await this.client.connect(connectOptions);\n } catch (error) {\n const converted = toScpNextError(error);\n if (converted instanceof HostVerificationError) {\n throw new HostVerificationError(\n `SSH host verification failed during connection: ${formatErrorMessage(\n error\n )}.${hostVerificationTroubleshooting(options.host)}`,\n { cause: error, context: connectionContext(options) }\n );\n }\n if (isLikelyHostVerificationFailure(error)) {\n throw new HostVerificationError(\n `SSH host verification failed during connection.${hostVerificationTroubleshooting(\n options.host\n )}`,\n { cause: error, context: connectionContext(options) }\n );\n }\n throw new ConnectionError(`Unable to connect to SSH server: ${formatErrorMessage(error)}`, {\n cause: error,\n context: connectionContext(options)\n });\n }\n }\n\n async close(): Promise<void> {\n await this.client.end();\n }\n\n async exists(remotePath: string): Promise<false | \"-\" | \"d\" | \"l\"> {\n return this.client.exists(remotePath);\n }\n\n async mkdir(remotePath: string, recursive = true): Promise<void> {\n await this.client.mkdir(remotePath, recursive);\n }\n\n async list(remotePath: string): Promise<RemoteFileInfo[]> {\n const files = await this.client.list(remotePath);\n return files.map(toRemoteFileInfo);\n }\n\n async uploadFile(\n localPath: string,\n remotePath: string,\n onStep?: (step: TransferStep) => void\n ): Promise<void> {\n try {\n await this.client.fastPut(localPath, remotePath, this.transferOptions(onStep));\n } catch (error) {\n throw new TransferError(`Upload failed for ${localPath}: ${formatErrorMessage(error)}`, {\n cause: error,\n context: { localPath, remotePath }\n });\n }\n }\n\n async downloadFile(\n remotePath: string,\n localPath: string,\n onStep?: (step: TransferStep) => void\n ): Promise<void> {\n try {\n await this.client.fastGet(remotePath, localPath, this.transferOptions(onStep));\n } catch (error) {\n throw new TransferError(`Download failed for ${remotePath}: ${formatErrorMessage(error)}`, {\n cause: error,\n context: { remotePath, localPath }\n });\n }\n }\n\n private transferOptions(onStep?: (step: TransferStep) => void): SftpTransferOptions | undefined {\n if (!onStep) {\n return undefined;\n }\n return {\n step(transferredBytes, chunkBytes, totalBytes) {\n onStep({ transferredBytes, chunkBytes, totalBytes });\n }\n };\n }\n}\n\nfunction connectionContext(options: ScpServerOptions): Record<string, unknown> {\n return {\n host: options.host,\n port: options.port,\n username: options.username\n };\n}\n\nfunction isLikelyHostVerificationFailure(error: unknown): boolean {\n const message = error instanceof Error ? error.message.toLowerCase() : String(error).toLowerCase();\n return (\n message.includes(\"host\") &&\n (message.includes(\"verif\") ||\n message.includes(\"fingerprint\") ||\n message.includes(\"host key\") ||\n message.includes(\"key mismatch\") ||\n message.includes(\"denied\"))\n );\n}\n\nfunction hostVerificationTroubleshooting(host: string | undefined): string {\n const displayHost = host ?? \"<host>\";\n return [\n \"\",\n \"\",\n \"Typical fix:\",\n ` ssh ${displayHost}`,\n \"\",\n \"If plain ssh works but scp-next fails, check that the host entry is available in\",\n \"`~/.ssh/known_hosts` for the same host and port used by scp-next. For non-default ports,\",\n \"OpenSSH usually stores entries as `[host]:port`.\",\n \"You can also configure hostFingerprint or knownHostsFile explicitly.\"\n ].join(\"\\n\");\n}\n","const SENSITIVE_KEYS = [\n \"password\",\n \"passphrase\",\n \"privatekey\",\n \"privatekeyfile\",\n \"token\",\n \"authorization\",\n \"credential\",\n \"secret\"\n];\n\nconst PRIVATE_KEY_PATTERN =\n /-----BEGIN [A-Z ]*PRIVATE KEY-----[\\s\\S]*?-----END [A-Z ]*PRIVATE KEY-----/g;\n\nfunction isSensitiveKey(key: string): boolean {\n const normalized = key.replace(/[-_\\s]/g, \"\").toLowerCase();\n return SENSITIVE_KEYS.some((sensitive) => normalized.includes(sensitive));\n}\n\nexport function redactSensitiveValues(value: unknown): unknown {\n if (typeof value === \"string\") {\n return value.replace(PRIVATE_KEY_PATTERN, \"[REDACTED]\");\n }\n\n if (Array.isArray(value)) {\n const redacted: unknown[] = value.map((item: unknown) => redactSensitiveValues(item));\n return redacted;\n }\n\n if (value && typeof value === \"object\") {\n const redacted: Record<string, unknown> = {};\n for (const [key, nestedValue] of Object.entries(value)) {\n redacted[key] = isSensitiveKey(key) ? \"[REDACTED]\" : redactSensitiveValues(nestedValue);\n }\n return redacted;\n }\n\n return value;\n}\n\nexport function formatErrorMessage(error: unknown): string {\n if (error instanceof Error) {\n return String(redactSensitiveValues(error.message));\n }\n return String(redactSensitiveValues(error));\n}\n","import { redactSensitiveValues } from \"../security/redact.js\";\n\nexport type ScpNextErrorCode =\n | \"SCP_NEXT_ERROR\"\n | \"SCP_NEXT_CONFIGURATION_ERROR\"\n | \"SCP_NEXT_VALIDATION_ERROR\"\n | \"SCP_NEXT_AUTHENTICATION_ERROR\"\n | \"SCP_NEXT_CONNECTION_ERROR\"\n | \"SCP_NEXT_TRANSFER_ERROR\"\n | \"SCP_NEXT_FILESYSTEM_ERROR\"\n | \"SCP_NEXT_HOST_VERIFICATION_ERROR\";\n\nexport interface ScpNextErrorOptions {\n code?: ScpNextErrorCode;\n cause?: unknown;\n context?: Record<string, unknown>;\n}\n\nexport class ScpNextError extends Error {\n readonly code: ScpNextErrorCode;\n readonly context: Record<string, unknown>;\n\n constructor(message: string, options: ScpNextErrorOptions = {}) {\n super(message, { cause: options.cause });\n this.name = new.target.name;\n this.code = options.code ?? \"SCP_NEXT_ERROR\";\n this.context = redactSensitiveValues(options.context ?? {}) as Record<string, unknown>;\n }\n}\n\nexport class ConfigurationError extends ScpNextError {\n constructor(message: string, options: Omit<ScpNextErrorOptions, \"code\"> = {}) {\n super(message, { ...options, code: \"SCP_NEXT_CONFIGURATION_ERROR\" });\n }\n}\n\nexport class ValidationError extends ScpNextError {\n constructor(message: string, options: Omit<ScpNextErrorOptions, \"code\"> = {}) {\n super(message, { ...options, code: \"SCP_NEXT_VALIDATION_ERROR\" });\n }\n}\n\nexport class AuthenticationError extends ScpNextError {\n constructor(message: string, options: Omit<ScpNextErrorOptions, \"code\"> = {}) {\n super(message, { ...options, code: \"SCP_NEXT_AUTHENTICATION_ERROR\" });\n }\n}\n\nexport class ConnectionError extends ScpNextError {\n constructor(message: string, options: Omit<ScpNextErrorOptions, \"code\"> = {}) {\n super(message, { ...options, code: \"SCP_NEXT_CONNECTION_ERROR\" });\n }\n}\n\nexport class TransferError extends ScpNextError {\n constructor(message: string, options: Omit<ScpNextErrorOptions, \"code\"> = {}) {\n super(message, { ...options, code: \"SCP_NEXT_TRANSFER_ERROR\" });\n }\n}\n\nexport class FileSystemError extends ScpNextError {\n constructor(message: string, options: Omit<ScpNextErrorOptions, \"code\"> = {}) {\n super(message, { ...options, code: \"SCP_NEXT_FILESYSTEM_ERROR\" });\n }\n}\n\nexport class HostVerificationError extends ScpNextError {\n constructor(message: string, options: Omit<ScpNextErrorOptions, \"code\"> = {}) {\n super(message, { ...options, code: \"SCP_NEXT_HOST_VERIFICATION_ERROR\" });\n }\n}\n\nexport function toScpNextError(error: unknown): ScpNextError {\n if (error instanceof ScpNextError) {\n return error;\n }\n\n const message = error instanceof Error ? error.message : \"Unexpected scp-next error.\";\n const lowerMessage = message.toLowerCase();\n\n if (lowerMessage.includes(\"authentication\") || lowerMessage.includes(\"permission denied\")) {\n return new AuthenticationError(\"SSH authentication failed.\", { cause: error });\n }\n\n if (\n lowerMessage.includes(\"host verification\") ||\n lowerMessage.includes(\"host key\") ||\n lowerMessage.includes(\"fingerprint\") ||\n (lowerMessage.includes(\"host\") && lowerMessage.includes(\"denied\"))\n ) {\n return new HostVerificationError(\"SSH host verification failed.\", { cause: error });\n }\n\n if (\n lowerMessage.includes(\"timed out\") ||\n lowerMessage.includes(\"connection\") ||\n lowerMessage.includes(\"econn\")\n ) {\n return new ConnectionError(\"SSH connection failed.\", { cause: error });\n }\n\n return new TransferError(String(redactSensitiveValues(message)), { cause: error });\n}\n","import { createHash } from \"node:crypto\";\nimport { access, readFile } from \"node:fs/promises\";\n\nimport { HostVerificationError } from \"../errors/index.js\";\nimport { expandHome } from \"../paths/local-path.js\";\n\nfunction normalizeFingerprint(fingerprint: string): string {\n return fingerprint\n .trim()\n .replace(/^SHA256:/i, \"\")\n .replace(/^sha256:/i, \"\")\n .replace(/=+$/g, \"\");\n}\n\nfunction isHexFingerprint(fingerprint: string): boolean {\n return /^[0-9a-f]+$/i.test(fingerprint);\n}\n\nfunction fingerprintCandidates(fingerprint: string): string[] {\n const normalized = normalizeFingerprint(fingerprint);\n const candidates = new Set([normalized]);\n\n if (isHexFingerprint(normalized)) {\n candidates.add(normalized.toLowerCase());\n } else {\n try {\n candidates.add(Buffer.from(normalized, \"base64\").toString(\"hex\"));\n } catch {\n // Keep the original normalized value when it is not valid base64.\n }\n }\n\n return [...candidates];\n}\n\nexport function isFingerprintMatch(actual: string, expected: string): boolean {\n const normalizedActual = normalizeFingerprint(actual);\n const normalizedExpected = normalizeFingerprint(expected);\n if (normalizedActual === normalizedExpected) {\n return true;\n }\n return (\n isHexFingerprint(normalizedActual) &&\n isHexFingerprint(normalizedExpected) &&\n normalizedActual.toLowerCase() === normalizedExpected.toLowerCase()\n );\n}\n\nexport interface HostVerifierConfig {\n host?: string | undefined;\n port?: number | undefined;\n hostFingerprint?: string | undefined;\n knownHostsFile?: string | undefined;\n}\n\nfunction hostVerificationHint(host: string): string {\n return [\n \"\",\n \"Typical fix:\",\n ` ssh ${host}`,\n \"\",\n \"If you trust the host key, accept it and retry the scp-next command.\",\n \"Alternatively configure hostFingerprint or knownHostsFile explicitly.\"\n ].join(\"\\n\");\n}\n\nexport async function resolveAllowedFingerprints(\n options: HostVerifierConfig\n): Promise<Set<string>> {\n const fingerprints = new Set<string>();\n const knownHostsFile = options.knownHostsFile ?? \"~/.ssh/known_hosts\";\n\n if (!options.host) {\n throw new HostVerificationError(\"A host is required for SSH host verification.\");\n }\n\n if (options.hostFingerprint) {\n for (const fingerprint of fingerprintCandidates(options.hostFingerprint)) {\n fingerprints.add(fingerprint);\n }\n }\n\n try {\n await access(expandHome(knownHostsFile));\n const content = await readFile(expandHome(knownHostsFile), \"utf8\");\n for (const line of content.split(/\\r?\\n/)) {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith(\"#\") || trimmed.startsWith(\"@\")) {\n continue;\n }\n\n const [hosts, algorithm, key] = trimmed.split(/\\s+/);\n const hostPatterns = hosts?.split(\",\") ?? [];\n const portHost = options.port ? `[${options.host}]:${options.port}` : undefined;\n const matchesHost =\n hostPatterns.includes(options.host) || Boolean(portHost && hostPatterns.includes(portHost));\n if (!hosts || !algorithm || !key || !matchesHost) {\n continue;\n }\n\n const keyBuffer = Buffer.from(key, \"base64\");\n fingerprints.add(createHash(\"sha256\").update(keyBuffer).digest(\"base64\").replace(/=+$/g, \"\"));\n fingerprints.add(createHash(\"sha256\").update(keyBuffer).digest(\"hex\"));\n }\n } catch (error) {\n if (options.knownHostsFile || !options.hostFingerprint) {\n throw new HostVerificationError(\n \"SSH host verification requires hostFingerprint or an accessible knownHostsFile.\",\n { cause: error, context: { knownHostsFile } }\n );\n }\n }\n\n if (fingerprints.size === 0) {\n throw new HostVerificationError(\n `SSH host verification failed before connecting: no matching host fingerprint was configured.${hostVerificationHint(\n options.host\n )}`\n );\n }\n\n return fingerprints;\n}\n\nexport function createHostVerifier(allowedFingerprints: Set<string>) {\n return (hashedKey: string): boolean => {\n for (const expected of allowedFingerprints) {\n if (isFingerprintMatch(hashedKey, expected)) {\n return true;\n }\n }\n return false;\n };\n}\n","import { constants } from \"node:fs\";\nimport { access, mkdir, stat } from \"node:fs/promises\";\nimport os from \"node:os\";\nimport path from \"node:path\";\n\nimport { FileSystemError, ValidationError } from \"../errors/index.js\";\n\nexport function expandHome(inputPath: string): string {\n if (inputPath === \"~\") {\n return os.homedir();\n }\n if (inputPath.startsWith(`~${path.sep}`) || inputPath.startsWith(\"~/\")) {\n return path.join(os.homedir(), inputPath.slice(2));\n }\n return inputPath;\n}\n\nexport function resolveLocalPath(inputPath: string, baseDir = process.cwd()): string {\n const expanded = expandHome(inputPath);\n return path.isAbsolute(expanded) ? path.normalize(expanded) : path.resolve(baseDir, expanded);\n}\n\nexport async function assertLocalPathExists(inputPath: string): Promise<void> {\n try {\n await access(resolveLocalPath(inputPath), constants.F_OK);\n } catch (error) {\n throw new FileSystemError(`Local path does not exist: ${inputPath}`, {\n cause: error,\n context: { path: inputPath }\n });\n }\n}\n\nexport async function assertLocalFileReadable(inputPath: string): Promise<void> {\n try {\n await access(resolveLocalPath(inputPath), constants.R_OK);\n } catch (error) {\n throw new FileSystemError(`Local file is not readable: ${inputPath}`, {\n cause: error,\n context: { path: inputPath }\n });\n }\n}\n\nexport async function assertDownloadDestination(inputPath: string, createDirectories = false) {\n const resolved = resolveLocalPath(inputPath);\n const parent = path.dirname(resolved);\n\n if (createDirectories) {\n await mkdir(parent, { recursive: true });\n return;\n }\n\n try {\n await access(parent, constants.W_OK);\n } catch (error) {\n throw new FileSystemError(`Local destination parent does not exist or is not writable: ${parent}`, {\n cause: error,\n context: { path: inputPath }\n });\n }\n}\n\nexport async function getLocalPathKind(inputPath: string): Promise<\"file\" | \"directory\"> {\n const stats = await stat(resolveLocalPath(inputPath));\n if (stats.isDirectory()) {\n return \"directory\";\n }\n if (stats.isFile()) {\n return \"file\";\n }\n throw new ValidationError(`Local path must be a file or directory: ${inputPath}`, {\n context: { path: inputPath }\n });\n}\n\nexport async function getLocalFileSize(inputPath: string): Promise<number> {\n const stats = await stat(resolveLocalPath(inputPath));\n return stats.size;\n}\n","import { readdir, stat } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport type { RemoteFileInfo, SftpTransport } from \"./transport.js\";\nimport { resolveLocalPath } from \"../paths/local-path.js\";\nimport { remoteJoin } from \"../paths/remote-path.js\";\n\nexport interface LocalFileEntry {\n absolutePath: string;\n relativePath: string;\n size: number;\n}\n\nexport async function walkLocalFiles(rootPath: string): Promise<LocalFileEntry[]> {\n const resolvedRoot = resolveLocalPath(rootPath);\n const stats = await stat(resolvedRoot);\n\n if (stats.isFile()) {\n return [\n {\n absolutePath: resolvedRoot,\n relativePath: path.basename(resolvedRoot),\n size: stats.size\n }\n ];\n }\n\n const files: LocalFileEntry[] = [];\n\n async function visit(directory: string): Promise<void> {\n const entries = await readdir(directory, { withFileTypes: true });\n for (const entry of entries) {\n const absolutePath = path.join(directory, entry.name);\n if (entry.isDirectory()) {\n await visit(absolutePath);\n } else if (entry.isFile()) {\n const entryStats = await stat(absolutePath);\n files.push({\n absolutePath,\n relativePath: path.relative(resolvedRoot, absolutePath),\n size: entryStats.size\n });\n }\n }\n }\n\n await visit(resolvedRoot);\n return files;\n}\n\nexport interface RemoteFileEntry {\n remotePath: string;\n relativePath: string;\n size: number;\n}\n\nexport async function walkRemoteFiles(\n transport: SftpTransport,\n rootPath: string\n): Promise<RemoteFileEntry[]> {\n const rootEntries = await transport.list(rootPath);\n const files: RemoteFileEntry[] = [];\n\n async function visit(directory: string, relativeBase: string, entries: RemoteFileInfo[]): Promise<void> {\n for (const entry of entries) {\n const fullPath = remoteJoin(directory, entry.name);\n const relativePath = relativeBase ? remoteJoin(relativeBase, entry.name) : entry.name;\n if (entry.type === \"d\") {\n await visit(fullPath, relativePath, await transport.list(fullPath));\n } else if (entry.type === \"-\") {\n files.push({\n remotePath: fullPath,\n relativePath,\n size: entry.size\n });\n }\n }\n }\n\n await visit(rootPath, \"\", rootEntries);\n return files;\n}\n","import path from \"node:path\";\n\nimport { ValidationError } from \"../errors/index.js\";\n\nexport function assertRemotePath(inputPath: string, label = \"remote path\"): void {\n if (!inputPath || inputPath.trim().length === 0) {\n throw new ValidationError(`Invalid ${label}: remote paths must not be empty.`, {\n context: { path: inputPath }\n });\n }\n}\n\nexport function normalizeRemotePath(inputPath: string): string {\n assertRemotePath(inputPath);\n return path.posix.normalize(inputPath.replace(/\\\\/g, \"/\"));\n}\n\nexport function remoteJoin(...parts: string[]): string {\n const joined = path.posix.join(...parts);\n assertRemotePath(joined);\n return joined;\n}\n\nexport function remoteDirname(inputPath: string): string {\n assertRemotePath(inputPath);\n return path.posix.dirname(inputPath);\n}\n","import { access } from \"node:fs/promises\";\n\nimport { ValidationError } from \"../errors/index.js\";\nimport { assertDownloadDestination, assertLocalPathExists, resolveLocalPath } from \"../paths/local-path.js\";\nimport { assertRemotePath } from \"../paths/remote-path.js\";\nimport type { DownloadOptions, ScpServerOptions, UploadOptions } from \"../types/index.js\";\n\nfunction validatePort(port: number | undefined): void {\n if (port === undefined) {\n return;\n }\n if (!Number.isInteger(port) || port < 1 || port > 65535) {\n throw new ValidationError(\"Port must be an integer between 1 and 65535.\", {\n context: { port }\n });\n }\n}\n\nfunction validateTimeout(timeout: number | undefined): void {\n if (timeout === undefined) {\n return;\n }\n if (!Number.isFinite(timeout) || timeout <= 0) {\n throw new ValidationError(\"Timeout must be a positive number.\", {\n context: { timeout }\n });\n }\n}\n\nexport async function validateServerOptions(options: ScpServerOptions): Promise<void> {\n if (!options.host) {\n throw new ValidationError(\"Host is required.\");\n }\n if (!options.username) {\n throw new ValidationError(\"Username is required.\");\n }\n\n validatePort(options.port);\n validateTimeout(options.timeout);\n\n if (options.privateKeyFile) {\n try {\n await access(resolveLocalPath(options.privateKeyFile));\n } catch (error) {\n throw new ValidationError(`Private key file does not exist: ${options.privateKeyFile}`, {\n cause: error,\n context: { privateKeyFile: options.privateKeyFile }\n });\n }\n }\n\n const hasAuthentication =\n Boolean(options.password) ||\n Boolean(options.privateKey) ||\n Boolean(options.privateKeyFile) ||\n Boolean(options.agent) ||\n Boolean(process.env.SSH_AUTH_SOCK);\n\n if (!hasAuthentication) {\n throw new ValidationError(\n \"Authentication is required. Provide a password, private key, private key file, or SSH agent.\"\n );\n }\n}\n\nexport async function validateUploadOptions(options: UploadOptions): Promise<void> {\n if (!options.localPath) {\n throw new ValidationError(\"Missing localPath.\");\n }\n if (!options.remotePath) {\n throw new ValidationError(\"Missing remotePath.\");\n }\n assertRemotePath(options.remotePath, \"remotePath\");\n validateTimeout(options.timeout);\n await assertLocalPathExists(options.localPath);\n\n if (!options.dryRun) {\n await validateServerOptions(options);\n }\n}\n\nexport async function validateDownloadOptions(options: DownloadOptions): Promise<void> {\n if (!options.remotePath) {\n throw new ValidationError(\"Missing remotePath.\");\n }\n if (!options.localPath) {\n throw new ValidationError(\"Missing localPath.\");\n }\n assertRemotePath(options.remotePath, \"remotePath\");\n validateTimeout(options.timeout);\n await assertDownloadDestination(options.localPath, options.createDirectories);\n\n if (!options.dryRun) {\n await validateServerOptions(options);\n }\n}\n","import { ScpNextClientImpl } from \"./client.js\";\nimport type { DownloadOptions } from \"../types/index.js\";\n\nexport async function download(options: DownloadOptions): Promise<void> {\n const client = new ScpNextClientImpl(options);\n try {\n await client.download(options.remotePath, options.localPath, options);\n } finally {\n await client.close();\n }\n}\n","import { ScpNextClientImpl } from \"./client.js\";\nimport type { UploadOptions } from \"../types/index.js\";\n\nexport async function upload(options: UploadOptions): Promise<void> {\n const client = new ScpNextClientImpl(options);\n try {\n await client.upload(options.localPath, options.remotePath, options);\n } finally {\n await client.close();\n }\n}\n","import { Command } from \"commander\";\n\nimport { assertSourceDestination } from \"../operands.js\";\nimport type { Output } from \"../output.js\";\nimport {\n addTransferOptions,\n executeResolvedTransfer,\n resolveForCli,\n type RawCommandOptions,\n type TransferHandlers\n} from \"./shared.js\";\n\nexport function createDownloadCommand(handlers: TransferHandlers, output: Output, cwd: string): Command {\n const command = new Command(\"download\")\n .description(\"Download a remote source path to a local destination path\")\n .usage(\"<source> <destination> [options]\")\n .argument(\"[source]\", \"Remote file or directory path\")\n .argument(\"[destination]\", \"Local file or directory\")\n .action(async (source: string | undefined, destination: string | undefined, options: RawCommandOptions) => {\n assertSourceDestination(\"download\", source, destination);\n const resolved = await resolveForCli({\n operation: \"download\",\n source,\n destination,\n options,\n cwd\n });\n await executeResolvedTransfer(resolved, handlers, output, options);\n });\n\n addTransferOptions(command);\n return command;\n}\n","import { ValidationError } from \"../errors/index.js\";\nimport type { TransferOperation } from \"../types/index.js\";\n\nexport function usageFor(operation: TransferOperation): string {\n return `scp-next ${operation} <source> <destination> [options]`;\n}\n\nexport function assertSourceDestination(\n operation: TransferOperation,\n source?: string,\n destination?: string\n): asserts source is string {\n if (!source) {\n throw new ValidationError(`Missing source path.\\n\\nUsage:\\n ${usageFor(operation)}`);\n }\n if (!destination) {\n throw new ValidationError(`Missing destination path.\\n\\nUsage:\\n ${usageFor(operation)}`);\n }\n}\n","import { Option } from \"commander\";\n\nimport { readEnvironment } from \"../../config/environment.js\";\nimport { loadConfig } from \"../../config/load-config.js\";\nimport {\n resolveTransferConfig,\n type CliTransferOptions\n} from \"../../config/resolve-config.js\";\nimport type { Output } from \"../output.js\";\nimport { createProgressReporter, verbosePlan, writeDryRun } from \"../output.js\";\nimport type {\n DownloadOptions,\n ResolvedTransferConfig,\n TransferOperation,\n UploadOptions\n} from \"../../types/index.js\";\n\nexport interface RawCommandOptions {\n host?: string;\n port?: number;\n username?: string;\n password?: string;\n privateKey?: string;\n privateKeyFile?: string;\n passphrase?: string;\n config?: string;\n profile?: string;\n recursive?: boolean;\n overwrite?: boolean;\n createDirectories?: boolean;\n dryRun?: boolean;\n timeout?: number;\n verbose?: boolean;\n quiet?: boolean;\n}\n\nexport interface TransferHandlers {\n upload(options: UploadOptions): Promise<void>;\n download(options: DownloadOptions): Promise<void>;\n}\n\nexport function addTransferOptions(command: { option: (flags: string, description: string) => unknown; addOption: (option: Option) => unknown }) {\n command.option(\"--host <host>\", \"SSH server host\");\n command.addOption(new Option(\"--port <port>\", \"SSH server port\").argParser(parseInteger));\n command.option(\"--username <username>\", \"SSH username\");\n command.option(\"--password <password>\", \"SSH password (prefer environment variables or key files)\");\n command.option(\"--private-key <privateKey>\", \"Private-key content\");\n command.option(\"--private-key-file <privateKeyFile>\", \"Private-key file path\");\n command.option(\"--passphrase <passphrase>\", \"Private-key passphrase\");\n command.option(\"--config <path>\", \"Configuration file path\");\n command.option(\"--profile <name>\", \"Named server profile\");\n command.option(\"--recursive\", \"Transfer directories recursively\");\n command.option(\"--overwrite\", \"Overwrite existing destination files\");\n command.option(\"--create-directories\", \"Create missing destination directories\");\n command.option(\"--dry-run\", \"Resolve and validate without connecting or transferring\");\n command.addOption(new Option(\"--timeout <milliseconds>\", \"Connection/operation timeout\").argParser(parseInteger));\n command.option(\"--verbose\", \"Print verbose diagnostic output\");\n command.option(\"--quiet\", \"Disable progress and non-error output\");\n return command;\n}\n\nfunction parseInteger(value: string): number {\n const parsed = Number.parseInt(value, 10);\n if (!Number.isFinite(parsed)) {\n throw new Error(\"Expected a number.\");\n }\n return parsed;\n}\n\nfunction toCliOptions(options: RawCommandOptions): CliTransferOptions {\n return {\n host: options.host,\n port: options.port,\n username: options.username,\n password: options.password,\n privateKey: options.privateKey,\n privateKeyFile: options.privateKeyFile,\n passphrase: options.passphrase,\n profile: options.profile,\n recursive: options.recursive,\n overwrite: options.overwrite,\n createDirectories: options.createDirectories,\n dryRun: options.dryRun,\n timeout: options.timeout\n };\n}\n\nexport async function resolveForCli(input: {\n operation?: TransferOperation | undefined;\n source?: string | undefined;\n destination?: string | undefined;\n jobName?: string | undefined;\n options: RawCommandOptions;\n cwd: string;\n}): Promise<ResolvedTransferConfig> {\n const loaded = await loadConfig(input.options.config, input.cwd);\n return resolveTransferConfig({\n operation: input.operation,\n source: input.source,\n destination: input.destination,\n jobName: input.jobName,\n cli: toCliOptions(input.options),\n env: readEnvironment(),\n config: loaded.config,\n configDirectory: loaded.directory,\n cwd: input.cwd\n });\n}\n\nexport async function executeResolvedTransfer(\n config: ResolvedTransferConfig,\n handlers: TransferHandlers,\n output: Output,\n commandOptions: RawCommandOptions\n): Promise<void> {\n if (commandOptions.verbose) {\n verbosePlan(output, config);\n }\n\n if (config.dryRun) {\n if (!commandOptions.quiet) {\n writeDryRun(output, config);\n }\n return;\n }\n\n const onProgress = createProgressReporter(output, commandOptions.quiet);\n\n if (config.operation === \"upload\") {\n const uploadOptions: UploadOptions = {\n ...config,\n localPath: config.source,\n remotePath: config.destination\n };\n if (onProgress) uploadOptions.onProgress = onProgress;\n await handlers.upload(uploadOptions);\n return;\n }\n\n const downloadOptions: DownloadOptions = {\n ...config,\n remotePath: config.source,\n localPath: config.destination\n };\n if (onProgress) downloadOptions.onProgress = onProgress;\n await handlers.download(downloadOptions);\n}\n","import type { ScpServerOptions } from \"../types/index.js\";\n\nexport interface EnvironmentConfig extends ScpServerOptions {\n profile?: string;\n}\n\nfunction parseInteger(value: string | undefined, name: string): number | undefined {\n if (!value) {\n return undefined;\n }\n\n const parsed = Number.parseInt(value, 10);\n if (!Number.isFinite(parsed)) {\n throw new Error(`${name} must be a number.`);\n }\n return parsed;\n}\n\nexport function readEnvironment(\n env: NodeJS.ProcessEnv = process.env\n): EnvironmentConfig {\n const result: EnvironmentConfig = {};\n\n if (env.SCP_NEXT_HOST) result.host = env.SCP_NEXT_HOST;\n if (env.SCP_NEXT_PORT) {\n const port = parseInteger(env.SCP_NEXT_PORT, \"SCP_NEXT_PORT\");\n if (port !== undefined) result.port = port;\n }\n if (env.SCP_NEXT_USERNAME) result.username = env.SCP_NEXT_USERNAME;\n if (env.SCP_NEXT_PASSWORD) result.password = env.SCP_NEXT_PASSWORD;\n if (env.SCP_NEXT_PRIVATE_KEY) result.privateKey = env.SCP_NEXT_PRIVATE_KEY;\n if (env.SCP_NEXT_PRIVATE_KEY_FILE) result.privateKeyFile = env.SCP_NEXT_PRIVATE_KEY_FILE;\n if (env.SCP_NEXT_PASSPHRASE) result.passphrase = env.SCP_NEXT_PASSPHRASE;\n if (env.SCP_NEXT_TIMEOUT) {\n const timeout = parseInteger(env.SCP_NEXT_TIMEOUT, \"SCP_NEXT_TIMEOUT\");\n if (timeout !== undefined) result.timeout = timeout;\n }\n if (env.SCP_NEXT_PROFILE) result.profile = env.SCP_NEXT_PROFILE;\n\n return result;\n}\n","import { access, readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport { z } from \"zod\";\n\nimport { ConfigurationError } from \"../errors/index.js\";\nimport type { ScpNextConfig } from \"../types/index.js\";\nimport { resolveLocalPath } from \"../paths/local-path.js\";\n\nexport const CONFIG_FILENAMES = [\"scp-next.config.json\", \".scp-nextrc\", \".scp-nextrc.json\"] as const;\n\nconst serverSchema = z.object({\n host: z.string().optional(),\n port: z.number().int().optional(),\n username: z.string().optional(),\n password: z.string().optional(),\n privateKey: z.string().optional(),\n privateKeyFile: z.string().optional(),\n passphrase: z.string().optional(),\n agent: z.string().optional(),\n timeout: z.number().int().optional(),\n hostFingerprint: z.string().optional(),\n knownHostsFile: z.string().optional()\n});\n\nconst transferSchema = z.object({\n recursive: z.boolean().optional(),\n overwrite: z.boolean().optional(),\n createDirectories: z.boolean().optional(),\n dryRun: z.boolean().optional(),\n timeout: z.number().int().optional()\n});\n\nconst jobSchema = transferSchema.extend({\n operation: z.enum([\"upload\", \"download\"]),\n profile: z.string().optional(),\n source: z.string(),\n destination: z.string()\n});\n\nconst configSchema = serverSchema\n .extend({\n defaultProfile: z.string().optional(),\n server: serverSchema.optional(),\n transfer: transferSchema.optional(),\n profiles: z.record(serverSchema).optional(),\n jobs: z.record(jobSchema).optional()\n })\n .passthrough();\n\nexport interface LoadedConfig {\n config: ScpNextConfig;\n path?: string;\n directory: string;\n}\n\nasync function fileExists(filePath: string): Promise<boolean> {\n try {\n await access(filePath);\n return true;\n } catch {\n return false;\n }\n}\n\nexport async function findConfigFile(cwd = process.cwd()): Promise<string | undefined> {\n for (const filename of CONFIG_FILENAMES) {\n const candidate = path.resolve(cwd, filename);\n if (await fileExists(candidate)) {\n return candidate;\n }\n }\n return undefined;\n}\n\nexport async function loadConfig(\n explicitPath?: string,\n cwd = process.cwd()\n): Promise<LoadedConfig> {\n const configPath = explicitPath ? resolveLocalPath(explicitPath, cwd) : await findConfigFile(cwd);\n\n if (!configPath) {\n return { config: {}, directory: cwd };\n }\n\n let raw: string;\n try {\n raw = await readFile(configPath, \"utf8\");\n } catch (error) {\n throw new ConfigurationError(`Unable to read configuration file: ${configPath}`, {\n cause: error,\n context: { path: configPath }\n });\n }\n\n try {\n const parsed = JSON.parse(raw) as unknown;\n const result = configSchema.safeParse(parsed);\n if (!result.success) {\n throw new ConfigurationError(`Invalid configuration file: ${result.error.message}`, {\n context: { path: configPath }\n });\n }\n\n return {\n config: result.data,\n path: configPath,\n directory: path.dirname(configPath)\n };\n } catch (error) {\n if (error instanceof ConfigurationError) {\n throw error;\n }\n throw new ConfigurationError(`Invalid JSON in configuration file: ${configPath}`, {\n cause: error,\n context: { path: configPath }\n });\n }\n}\n","import path from \"node:path\";\n\nimport { selectJob } from \"./jobs.js\";\nimport { selectProfile } from \"./profiles.js\";\nimport type { EnvironmentConfig } from \"./environment.js\";\nimport type {\n ResolvedTransferConfig,\n ScpNextConfig,\n ScpServerOptions,\n TransferJob,\n TransferOperation,\n TransferOptions\n} from \"../types/index.js\";\nimport { resolveLocalPath } from \"../paths/local-path.js\";\n\nexport interface CliTransferOptions extends ScpServerOptions, Omit<TransferOptions, \"onProgress\"> {\n profile?: string | undefined;\n}\n\nexport interface ResolveTransferInput {\n operation?: TransferOperation | undefined;\n source?: string | undefined;\n destination?: string | undefined;\n cli?: CliTransferOptions | undefined;\n env?: EnvironmentConfig | undefined;\n config?: ScpNextConfig | undefined;\n configDirectory?: string | undefined;\n cwd?: string | undefined;\n jobName?: string | undefined;\n}\n\nconst DEFAULT_TRANSFER: Omit<ResolvedTransferConfig, \"operation\" | \"source\" | \"destination\"> = {\n port: 22,\n recursive: false,\n overwrite: false,\n createDirectories: false,\n dryRun: false\n};\n\nfunction assignDefined<T extends object>(target: T, source: object | undefined): T {\n if (!source) {\n return target;\n }\n\n for (const [key, value] of Object.entries(source as Record<string, unknown>)) {\n if (value !== undefined) {\n Object.assign(target, { [key]: value });\n }\n }\n\n return target;\n}\n\nfunction rootServer(config: ScpNextConfig): ScpServerOptions {\n const result: ScpServerOptions = {};\n assignDefined(result, config.server);\n assignDefined(result, {\n host: config.host,\n port: config.port,\n username: config.username,\n password: config.password,\n privateKey: config.privateKey,\n privateKeyFile: config.privateKeyFile,\n passphrase: config.passphrase,\n agent: config.agent,\n timeout: config.timeout,\n hostFingerprint: config.hostFingerprint,\n knownHostsFile: config.knownHostsFile\n });\n return result;\n}\n\nfunction jobTransfer(job: TransferJob | undefined): Omit<TransferOptions, \"onProgress\"> {\n const result: Omit<TransferOptions, \"onProgress\"> = {};\n if (!job) {\n return result;\n }\n return assignDefined(result, {\n recursive: job.recursive,\n overwrite: job.overwrite,\n createDirectories: job.createDirectories,\n dryRun: job.dryRun,\n timeout: job.timeout\n });\n}\n\nfunction resolveConfigRelatedPaths(\n resolved: ResolvedTransferConfig,\n operation: TransferOperation,\n configDirectory: string\n): ResolvedTransferConfig {\n const next = { ...resolved };\n\n if (next.privateKeyFile && !next.privateKeyFile.startsWith(\"~\")) {\n next.privateKeyFile = path.isAbsolute(next.privateKeyFile)\n ? next.privateKeyFile\n : resolveLocalPath(next.privateKeyFile, configDirectory);\n }\n\n if (next.knownHostsFile && !next.knownHostsFile.startsWith(\"~\")) {\n next.knownHostsFile = path.isAbsolute(next.knownHostsFile)\n ? next.knownHostsFile\n : resolveLocalPath(next.knownHostsFile, configDirectory);\n }\n\n if (operation === \"upload\" && !next.source.startsWith(\"~\")) {\n next.source = path.isAbsolute(next.source)\n ? next.source\n : resolveLocalPath(next.source, configDirectory);\n }\n\n if (operation === \"download\" && !next.destination.startsWith(\"~\")) {\n next.destination = path.isAbsolute(next.destination)\n ? next.destination\n : resolveLocalPath(next.destination, configDirectory);\n }\n\n return next;\n}\n\nexport function resolveTransferConfig(input: ResolveTransferInput): ResolvedTransferConfig {\n const config = input.config ?? {};\n const env = input.env ?? {};\n const cli = input.cli ?? {};\n const configDirectory = input.configDirectory ?? process.cwd();\n const cwd = input.cwd ?? process.cwd();\n const job = input.jobName ? selectJob(config, input.jobName) : undefined;\n const operation = input.operation ?? job?.operation;\n\n if (!operation) {\n throw new Error(\"Transfer operation is required.\");\n }\n\n const selectedProfileName =\n cli.profile ?? env.profile ?? job?.profile ?? config.defaultProfile;\n const profile = selectProfile(config, selectedProfileName);\n\n const resolved: ResolvedTransferConfig = {\n ...DEFAULT_TRANSFER,\n operation,\n source: job?.source ?? \"\",\n destination: job?.destination ?? \"\"\n };\n\n assignDefined(resolved, jobTransfer(job));\n assignDefined(resolved, config.transfer);\n assignDefined(resolved, rootServer(config));\n assignDefined(resolved, profile);\n assignDefined(resolved, {\n host: env.host,\n port: env.port,\n username: env.username,\n password: env.password,\n privateKey: env.privateKey,\n privateKeyFile: env.privateKeyFile,\n passphrase: env.passphrase,\n timeout: env.timeout\n });\n assignDefined(resolved, {\n source: input.source,\n destination: input.destination\n });\n assignDefined(resolved, cli);\n\n if (selectedProfileName) {\n resolved.profile = selectedProfileName;\n }\n\n const pathResolved = resolveConfigRelatedPaths(resolved, operation, configDirectory);\n\n if (input.source && operation === \"upload\") {\n pathResolved.source = resolveLocalPath(input.source, cwd);\n }\n\n if (input.destination && operation === \"download\") {\n pathResolved.destination = resolveLocalPath(input.destination, cwd);\n }\n\n return pathResolved;\n}\n","import { ConfigurationError } from \"../errors/index.js\";\nimport type { ScpNextConfig, TransferJob } from \"../types/index.js\";\n\nexport function selectJob(config: ScpNextConfig, jobName: string): TransferJob {\n const job = config.jobs?.[jobName];\n if (!job) {\n throw new ConfigurationError(`Unknown job: ${jobName}`, {\n context: { job: jobName }\n });\n }\n return job;\n}\n","import { ConfigurationError } from \"../errors/index.js\";\nimport type { ScpNextConfig, ScpServerOptions } from \"../types/index.js\";\n\nexport function selectProfile(\n config: ScpNextConfig,\n profileName?: string\n): ScpServerOptions | undefined {\n if (!profileName) {\n return undefined;\n }\n\n const profile = config.profiles?.[profileName];\n if (!profile) {\n throw new ConfigurationError(`Unknown profile: ${profileName}`, {\n context: { profile: profileName }\n });\n }\n\n return profile;\n}\n","import type { ResolvedTransferConfig, TransferProgress } from \"../types/index.js\";\nimport { redactSensitiveValues } from \"../security/redact.js\";\n\nexport interface Output {\n stdout: NodeJS.WritableStream & { isTTY?: boolean };\n stderr: NodeJS.WritableStream & { isTTY?: boolean };\n}\n\nexport function writeDryRun(output: Output, config: ResolvedTransferConfig): void {\n const destination =\n config.operation === \"upload\"\n ? `${config.username ?? \"user\"}@${config.host ?? \"host\"}:${config.destination}`\n : config.destination;\n\n output.stdout.write(`Dry run: ${config.operation}\\n`);\n output.stdout.write(`Source: ${config.source}\\n`);\n output.stdout.write(`Destination: ${destination}\\n`);\n output.stdout.write(`Recursive: ${config.recursive ? \"yes\" : \"no\"}\\n`);\n output.stdout.write(`Overwrite: ${config.overwrite ? \"yes\" : \"no\"}\\n`);\n}\n\nexport function createProgressReporter(\n output: Output,\n quiet?: boolean\n): ((progress: TransferProgress) => void) | undefined {\n if (quiet || !output.stderr.isTTY) {\n return undefined;\n }\n\n return (progress) => {\n const total = progress.totalBytes ? formatBytes(progress.totalBytes) : \"?\";\n const transferred = formatBytes(progress.transferredBytes);\n const percentage = progress.percentage === undefined ? \"\" : ` (${progress.percentage}%)`;\n const currentFile = progress.currentFile ? `: ${progress.currentFile}` : \"\";\n output.stderr.write(`\\r${progress.operation === \"upload\" ? \"Uploading\" : \"Downloading\"}${currentFile}\\n`);\n output.stderr.write(`${transferred} / ${total}${percentage}\\n`);\n };\n}\n\nexport function verbosePlan(output: Output, config: ResolvedTransferConfig): void {\n output.stderr.write(\n `${JSON.stringify(\n redactSensitiveValues({\n operation: config.operation,\n host: config.host,\n port: config.port,\n username: config.username,\n source: config.source,\n destination: config.destination,\n recursive: config.recursive,\n overwrite: config.overwrite,\n createDirectories: config.createDirectories,\n dryRun: config.dryRun\n }),\n null,\n 2\n )}\\n`\n );\n}\n\nfunction formatBytes(bytes: number): string {\n if (bytes < 1024) {\n return `${bytes} B`;\n }\n const units = [\"KB\", \"MB\", \"GB\", \"TB\"];\n let value = bytes / 1024;\n let unitIndex = 0;\n while (value >= 1024 && unitIndex < units.length - 1) {\n value /= 1024;\n unitIndex += 1;\n }\n return `${value.toFixed(1)} ${units[unitIndex]}`;\n}\n","import { Command } from \"commander\";\n\nimport type { Output } from \"../output.js\";\nimport {\n addTransferOptions,\n executeResolvedTransfer,\n resolveForCli,\n type RawCommandOptions,\n type TransferHandlers\n} from \"./shared.js\";\n\nexport function createRunCommand(handlers: TransferHandlers, output: Output, cwd: string): Command {\n const command = new Command(\"run\")\n .description(\"Run a configured transfer job\")\n .usage(\"<job> [source] [destination] [options]\")\n .argument(\"<job>\", \"Configured job name\")\n .argument(\"[source]\", \"Optional source override\")\n .argument(\"[destination]\", \"Optional destination override\")\n .action(\n async (\n jobName: string,\n source: string | undefined,\n destination: string | undefined,\n options: RawCommandOptions\n ) => {\n const resolved = await resolveForCli({\n source,\n destination,\n jobName,\n options,\n cwd\n });\n await executeResolvedTransfer(resolved, handlers, output, options);\n }\n );\n\n addTransferOptions(command);\n return command;\n}\n","import { Command } from \"commander\";\n\nimport { assertSourceDestination } from \"../operands.js\";\nimport type { Output } from \"../output.js\";\nimport {\n addTransferOptions,\n executeResolvedTransfer,\n resolveForCli,\n type RawCommandOptions,\n type TransferHandlers\n} from \"./shared.js\";\n\nexport function createUploadCommand(handlers: TransferHandlers, output: Output, cwd: string): Command {\n const command = new Command(\"upload\")\n .description(\"Upload a local source path to a remote destination path\")\n .usage(\"<source> <destination> [options]\")\n .argument(\"[source]\", \"Local file or directory\")\n .argument(\"[destination]\", \"Remote file or directory path\")\n .action(async (source: string | undefined, destination: string | undefined, options: RawCommandOptions) => {\n assertSourceDestination(\"upload\", source, destination);\n const resolved = await resolveForCli({\n operation: \"upload\",\n source,\n destination,\n options,\n cwd\n });\n await executeResolvedTransfer(resolved, handlers, output, options);\n });\n\n addTransferOptions(command);\n return command;\n}\n"],"mappings":";;;AAAA,SAAS,cAAc,oBAAoB;AAC3C,SAAS,SAAS,eAAe;AACjC,SAAS,qBAAqB;AAE9B,SAAS,WAAAA,UAAS,sBAAsB;;;ACJxC,SAAS,UAAAC,SAAQ,SAAAC,QAAO,QAAAC,aAAY;AACpC,OAAOC,WAAU;;;ACDjB,SAAS,YAAAC,iBAAgB;AAEzB,OAAO,gBAAgB;;;ACFvB,IAAM,iBAAiB;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,IAAM,sBACJ;AAEF,SAAS,eAAe,KAAsB;AAC5C,QAAM,aAAa,IAAI,QAAQ,WAAW,EAAE,EAAE,YAAY;AAC1D,SAAO,eAAe,KAAK,CAAC,cAAc,WAAW,SAAS,SAAS,CAAC;AAC1E;AAEO,SAAS,sBAAsB,OAAyB;AAC7D,MAAI,OAAO,UA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G,CAAC;AAC7D,UAAQ,WAAW,sBAAsB,UAAU,QAAQ,GAAG,CAAC;AAC/D,UAAQ,WAAW,iBAAiB,UAAU,QAAQ,GAAG,CAAC;AAE1D,MAAI;AACF,UAAM,QAAQ,WAAW,QAAQ,QAAQ,QAAQ,MAAM,EAAE,MAAM,OAAO,CAAC;AACvE,WAAO;AAAA,EACT,SAAS,OAAO;AACd,QAAI,iBAAiB,gBAAgB;AACnC,UAAI,MAAM,SAAS,6BAA6B,MAAM,SAAS,qBAAqB;AAClF,eAAO;AAAA,MACT;AACA,aAAO,OAAO,MAAM,GAAG,mBAAmB,MAAM,OAAO,CAAC;AAAA,CAAI;AAC5D,aAAO,MAAM,YAAY;AAAA,IAC3B;AAEA,UAAM,WAAW,QAAQ,QAAQ,QAAQ,MAAM,SAAS,WAAW;AACnE,QAAI,iBAAiB,cAAc;AACjC,aAAO,OAAO,MAAM,UAAU,mBAAmB,MAAM,OAAO,CAAC;AAAA,CAAI;AACnE,UAAI,WAAW,MAAM,iBAAiB,OAAO;AAC3C,eAAO,OAAO,MAAM,GAAG,mBAAmB,MAAM,MAAM,SAAS,MAAM,MAAM,OAAO,CAAC;AAAA,CAAI;AAAA,MACzF;AACA,aAAO;AAAA,IACT;AAEA,WAAO,OAAO,MAAM,UAAU,mBAAmB,KAAK,CAAC;AAAA,CAAI;AAC3D,QAAI,WAAW,iBAAiB,SAAS,MAAM,OAAO;AACpD,aAAO,OAAO,MAAM,GAAG,mBAAmB,MAAM,KAAK,CAAC;AAAA,CAAI;AAAA,IAC5D;AACA,WAAO;AAAA,EACT;AACF;AAEA,IAAI,gBAAgB,GAAG;AACrB,OAAK,OAAO,EAAE,KAAK,CAAC,aAAa;AAC/B,YAAQ,WAAW;AAAA,EACrB,CAAC;AACH;","names":["Command","access","mkdir","stat","path","readFile","access","access","readFile","stat","path","path","path","stat","path","access","access","path","stat","totalBytes","mkdir","access","access","readFile","path","access","path","readFile","path","path","percentage","parseInteger","Command","Command","Command","Command","Command"]}
1
+ {"version":3,"sources":["../../src/cli/index.ts","../../src/client/client.ts","../../src/client/transport.ts","../../src/security/redact.ts","../../src/errors/index.ts","../../src/security/host-verification.ts","../../src/paths/local-path.ts","../../src/client/walk.ts","../../src/paths/remote-path.ts","../../src/config/validation.ts","../../src/client/download.ts","../../src/client/upload.ts","../../src/cli/commands/download.ts","../../src/cli/operands.ts","../../src/cli/commands/shared.ts","../../src/config/environment.ts","../../src/config/load-config.ts","../../src/config/resolve-config.ts","../../src/config/jobs.ts","../../src/config/profiles.ts","../../src/cli/output.ts","../../src/cli/commands/run.ts","../../src/cli/commands/upload.ts"],"sourcesContent":["import { readFileSync, realpathSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { Command, CommanderError } from \"commander\";\n\nimport { download } from \"../client/download.js\";\nimport { upload } from \"../client/upload.js\";\nimport { ScpNextError } from \"../errors/index.js\";\nimport { formatErrorMessage } from \"../security/redact.js\";\nimport { createDownloadCommand } from \"./commands/download.js\";\nimport { createRunCommand } from \"./commands/run.js\";\nimport { createUploadCommand } from \"./commands/upload.js\";\nimport type { Output } from \"./output.js\";\nimport type { TransferHandlers } from \"./commands/shared.js\";\n\nexport interface RunCliOptions {\n argv?: string[];\n cwd?: string;\n output?: Output;\n handlers?: TransferHandlers;\n}\n\nfunction readPackageVersion(currentModuleUrl = import.meta.url): string {\n const currentFile = fileURLToPath(currentModuleUrl);\n const packageJsonPath = resolve(dirname(currentFile), \"..\", \"..\", \"package.json\");\n const packageJson = JSON.parse(readFileSync(packageJsonPath, \"utf8\")) as { version?: string };\n return packageJson.version ?? \"0.0.0\";\n}\n\nexport function isCliEntrypoint(\n currentModuleUrl = import.meta.url,\n argv: string[] = process.argv\n): boolean {\n const executedFile = argv[1];\n if (!executedFile) {\n return false;\n }\n\n try {\n return realpathSync(fileURLToPath(currentModuleUrl)) === realpathSync(executedFile);\n } catch {\n return false;\n }\n}\n\nexport async function runCli(options: RunCliOptions = {}): Promise<number> {\n const output = options.output ?? { stdout: process.stdout, stderr: process.stderr };\n const cwd = options.cwd ?? process.cwd();\n const handlers = options.handlers ?? { upload, download };\n const program = new Command();\n\n program\n .name(\"scp-next\")\n .description(\"Secure file transfers over SSH using SFTP\")\n .version(readPackageVersion())\n .configureOutput({\n writeOut: (message) => output.stdout.write(message),\n writeErr: (message) => output.stderr.write(message)\n })\n .showHelpAfterError()\n .exitOverride();\n\n program.addCommand(createUploadCommand(handlers, output, cwd));\n program.addCommand(createDownloadCommand(handlers, output, cwd));\n program.addCommand(createRunCommand(handlers, output, cwd));\n\n try {\n await program.parseAsync(options.argv ?? process.argv, { from: \"node\" });\n return 0;\n } catch (error) {\n if (error instanceof CommanderError) {\n if (error.code === \"commander.helpDisplayed\" || error.code === \"commander.version\") {\n return 0;\n }\n output.stderr.write(`${formatErrorMessage(error.message)}\\n`);\n return error.exitCode || 1;\n }\n\n const verbose = (options.argv ?? process.argv).includes(\"--verbose\");\n if (error instanceof ScpNextError) {\n output.stderr.write(`Error: ${formatErrorMessage(error.message)}\\n`);\n if (verbose && error.cause instanceof Error) {\n output.stderr.write(`${formatErrorMessage(error.cause.stack ?? error.cause.message)}\\n`);\n }\n return 1;\n }\n\n output.stderr.write(`Error: ${formatErrorMessage(error)}\\n`);\n if (verbose && error instanceof Error && error.stack) {\n output.stderr.write(`${formatErrorMessage(error.stack)}\\n`);\n }\n return 1;\n }\n}\n\nif (isCliEntrypoint()) {\n void runCli().then((exitCode) => {\n process.exitCode = exitCode;\n });\n}\n","import { access, mkdir, stat } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport { Ssh2SftpTransport } from \"./transport.js\";\nimport type { SftpTransport } from \"./transport.js\";\nimport { walkLocalFiles, walkRemoteFiles } from \"./walk.js\";\nimport { TransferError, ValidationError } from \"../errors/index.js\";\nimport { getLocalPathKind, resolveLocalPath } from \"../paths/local-path.js\";\nimport { normalizeRemotePath, remoteDirname, remoteJoin } from \"../paths/remote-path.js\";\nimport type {\n DownloadOptions,\n ScpNextClient,\n ScpServerOptions,\n TransferOptions,\n UploadOptions\n} from \"../types/index.js\";\nimport {\n validateDownloadOptions,\n validateServerOptions,\n validateUploadOptions\n} from \"../config/validation.js\";\n\nexport interface ScpNextClientDependencies {\n transport?: SftpTransport;\n}\n\nfunction percentage(transferredBytes: number, totalBytes?: number): number | undefined {\n if (!totalBytes || totalBytes <= 0) {\n return undefined;\n }\n return Math.min(100, Math.round((transferredBytes / totalBytes) * 100));\n}\n\nfunction mergeOptions<T extends TransferOptions>(\n serverOptions: ScpServerOptions,\n transferOptions: T | undefined\n): ScpServerOptions & T {\n return { ...serverOptions, ...(transferOptions ?? {}) } as ScpServerOptions & T;\n}\n\nfunction shouldCreateDirectories(options: TransferOptions): boolean {\n return options.createDirectories ?? true;\n}\n\nfunction hasTrailingPathSeparator(inputPath: string): boolean {\n return /[\\\\/]$/.test(inputPath);\n}\n\nfunction trimmedRemoteDirectory(remotePath: string): string {\n return remotePath.replace(/\\/+$/g, \"\") || \"/\";\n}\n\nfunction remoteBasename(remotePath: string): string {\n return path.posix.basename(trimmedRemoteDirectory(remotePath));\n}\n\nasync function isExistingLocalDirectory(localPath: string): Promise<boolean> {\n try {\n return (await stat(localPath)).isDirectory();\n } catch {\n return false;\n }\n}\n\nasync function ensureLocalDirectory(localPath: string, createParents = false): Promise<void> {\n try {\n const stats = await stat(localPath);\n if (stats.isDirectory()) {\n return;\n }\n throw new TransferError(`Local destination already exists and is not a directory: ${localPath}`, {\n context: { localPath }\n });\n } catch (error) {\n if (error instanceof TransferError) {\n throw error;\n }\n await mkdir(localPath, { recursive: createParents });\n }\n}\n\nexport class ScpNextClientImpl implements ScpNextClient {\n private readonly serverOptions: ScpServerOptions;\n private readonly transport: SftpTransport;\n private connected = false;\n\n constructor(serverOptions: ScpServerOptions, dependencies: ScpNextClientDependencies = {}) {\n this.serverOptions = serverOptions;\n this.transport = dependencies.transport ?? new Ssh2SftpTransport();\n }\n\n async connect(): Promise<void> {\n await validateServerOptions(this.serverOptions);\n await this.transport.connect(this.serverOptions);\n this.connected = true;\n }\n\n async upload(\n localPath: string,\n remotePath: string,\n options: TransferOptions = {}\n ): Promise<void> {\n const uploadOptions: UploadOptions = {\n ...mergeOptions(this.serverOptions, options),\n localPath,\n remotePath\n };\n await validateUploadOptions(uploadOptions);\n\n if (options.dryRun) {\n return;\n }\n\n await this.ensureConnected();\n await this.uploadWithTransport(uploadOptions);\n }\n\n async download(\n remotePath: string,\n localPath: string,\n options: TransferOptions = {}\n ): Promise<void> {\n const downloadOptions: DownloadOptions = {\n ...mergeOptions(this.serverOptions, options),\n remotePath,\n localPath\n };\n await validateDownloadOptions(downloadOptions);\n\n if (options.dryRun) {\n return;\n }\n\n await this.ensureConnected();\n await this.downloadWithTransport(downloadOptions);\n }\n\n async close(): Promise<void> {\n if (this.connected) {\n await this.transport.close();\n this.connected = false;\n }\n }\n\n private async ensureConnected(): Promise<void> {\n if (!this.connected) {\n await this.connect();\n }\n }\n\n private async uploadWithTransport(options: UploadOptions): Promise<void> {\n const localKind = await getLocalPathKind(options.localPath);\n const remotePath = normalizeRemotePath(options.remotePath);\n\n if (localKind === \"directory\" && !options.recursive) {\n throw new ValidationError(\"Uploading a directory requires recursive mode.\");\n }\n\n if (localKind === \"file\") {\n const destinationFile = await this.resolveRemoteDestinationForLocalFile(options, remotePath);\n const totalBytes = undefined;\n await this.transport.uploadFile(resolveLocalPath(options.localPath), destinationFile, (step) => {\n options.onProgress?.({\n operation: \"upload\",\n source: options.localPath,\n destination: options.remotePath,\n transferredBytes: step.transferredBytes,\n totalBytes: step.totalBytes || totalBytes,\n percentage: percentage(step.transferredBytes, step.totalBytes),\n currentFile: options.localPath\n });\n });\n return;\n }\n\n const files = await walkLocalFiles(options.localPath);\n const totalBytes = files.reduce((sum, file) => sum + file.size, 0);\n let completedBytes = 0;\n let completedFiles = 0;\n const destinationRoot = await this.resolveRemoteDestinationForLocalDirectory(\n options,\n remotePath\n );\n\n for (const file of files) {\n const destinationFile = remoteJoin(\n destinationRoot,\n file.relativePath.split(path.sep).join(\"/\")\n );\n await this.ensureRemoteParent(destinationFile, true);\n await this.assertRemoteOverwrite(destinationFile, options.overwrite);\n\n await this.transport.uploadFile(file.absolutePath, destinationFile, (step) => {\n const transferredBytes = completedBytes + step.transferredBytes;\n options.onProgress?.({\n operation: \"upload\",\n source: options.localPath,\n destination: options.remotePath,\n transferredBytes,\n totalBytes,\n percentage: percentage(transferredBytes, totalBytes),\n currentFile: file.relativePath,\n completedFiles,\n totalFiles: files.length\n });\n });\n\n completedBytes += file.size;\n completedFiles += 1;\n }\n }\n\n private async resolveRemoteDestinationForLocalFile(\n options: UploadOptions,\n remotePath: string\n ): Promise<string> {\n const remoteKind = await this.transport.exists(remotePath);\n const isDirectoryLikeDestination = remoteKind === \"d\" || remotePath.endsWith(\"/\");\n\n if (!isDirectoryLikeDestination) {\n await this.ensureRemoteParent(remotePath, shouldCreateDirectories(options));\n await this.assertRemoteOverwrite(remotePath, options.overwrite);\n return remotePath;\n }\n\n if (remoteKind && remoteKind !== \"d\") {\n throw new TransferError(`Remote destination already exists and is not a directory: ${remotePath}`, {\n context: { remotePath }\n });\n }\n\n const remoteDirectory = remotePath.replace(/\\/+$/g, \"\") || \"/\";\n if (!remoteKind) {\n if (!shouldCreateDirectories(options)) {\n throw new TransferError(`Remote destination directory does not exist: ${remoteDirectory}`, {\n context: { remotePath }\n });\n }\n await this.transport.mkdir(remoteDirectory, true);\n }\n\n const destinationFile = remoteJoin(\n remoteDirectory,\n path.basename(resolveLocalPath(options.localPath))\n );\n await this.assertRemoteOverwrite(destinationFile, options.overwrite);\n return destinationFile;\n }\n\n private async resolveRemoteDestinationForLocalDirectory(\n options: UploadOptions,\n remotePath: string\n ): Promise<string> {\n const remoteKind = await this.transport.exists(remotePath);\n const isDirectoryLikeDestination = remoteKind === \"d\" || remotePath.endsWith(\"/\");\n const localDirectoryName = path.basename(resolveLocalPath(options.localPath));\n\n if (remoteKind && remoteKind !== \"d\") {\n throw new TransferError(`Remote destination already exists and is not a directory: ${remotePath}`, {\n context: { remotePath }\n });\n }\n\n if (isDirectoryLikeDestination) {\n const remoteDirectory = trimmedRemoteDirectory(remotePath);\n if (!remoteKind) {\n if (!shouldCreateDirectories(options)) {\n throw new TransferError(`Remote destination directory does not exist: ${remoteDirectory}`, {\n context: { remotePath }\n });\n }\n await this.transport.mkdir(remoteDirectory, true);\n }\n\n const destinationRoot = remoteJoin(remoteDirectory, localDirectoryName);\n await this.ensureRemoteDirectory(destinationRoot);\n return destinationRoot;\n }\n\n if (!remoteKind) {\n if (!shouldCreateDirectories(options)) {\n throw new TransferError(`Remote destination directory does not exist: ${remotePath}`, {\n context: { remotePath }\n });\n }\n await this.transport.mkdir(remotePath, true);\n }\n\n return remotePath;\n }\n\n private async downloadWithTransport(options: DownloadOptions): Promise<void> {\n const remotePath = normalizeRemotePath(options.remotePath);\n const remoteKind = await this.transport.exists(remotePath);\n\n if (!remoteKind) {\n throw new TransferError(`Remote path does not exist: ${options.remotePath}`, {\n context: { remotePath: options.remotePath }\n });\n }\n\n if (remoteKind === \"d\") {\n if (!options.recursive) {\n throw new ValidationError(\"Downloading a directory requires recursive mode.\");\n }\n await this.downloadDirectory(options);\n return;\n }\n\n await this.downloadSingleFile(options, remotePath);\n }\n\n private async downloadSingleFile(options: DownloadOptions, remotePath: string): Promise<void> {\n const localPath = await this.resolveLocalDestinationForRemoteFile(options, remotePath);\n await this.assertLocalOverwrite(localPath, options.overwrite);\n if (shouldCreateDirectories(options)) {\n await mkdir(path.dirname(localPath), { recursive: true });\n }\n await this.transport.downloadFile(remotePath, localPath, (step) => {\n options.onProgress?.({\n operation: \"download\",\n source: options.remotePath,\n destination: options.localPath,\n transferredBytes: step.transferredBytes,\n totalBytes: step.totalBytes,\n percentage: percentage(step.transferredBytes, step.totalBytes),\n currentFile: options.remotePath\n });\n });\n }\n\n private async downloadDirectory(options: DownloadOptions): Promise<void> {\n const remotePath = normalizeRemotePath(options.remotePath);\n const localRoot = await this.resolveLocalDestinationForRemoteDirectory(options, remotePath);\n const files = await walkRemoteFiles(this.transport, remotePath);\n const totalBytes = files.reduce((sum, file) => sum + file.size, 0);\n let completedBytes = 0;\n let completedFiles = 0;\n\n await ensureLocalDirectory(localRoot, shouldCreateDirectories(options));\n\n for (const file of files) {\n const localFile = path.join(localRoot, ...file.relativePath.split(\"/\"));\n await this.assertLocalOverwrite(localFile, options.overwrite);\n await mkdir(path.dirname(localFile), { recursive: true });\n await this.transport.downloadFile(file.remotePath, localFile, (step) => {\n const transferredBytes = completedBytes + step.transferredBytes;\n options.onProgress?.({\n operation: \"download\",\n source: options.remotePath,\n destination: options.localPath,\n transferredBytes,\n totalBytes,\n percentage: percentage(transferredBytes, totalBytes),\n currentFile: file.relativePath,\n completedFiles,\n totalFiles: files.length\n });\n });\n completedBytes += file.size;\n completedFiles += 1;\n }\n }\n\n private async resolveLocalDestinationForRemoteFile(\n options: DownloadOptions,\n remotePath: string\n ): Promise<string> {\n const localDestination = resolveLocalPath(options.localPath);\n const isDirectoryLikeDestination =\n hasTrailingPathSeparator(options.localPath) || (await isExistingLocalDirectory(localDestination));\n\n if (!isDirectoryLikeDestination) {\n return localDestination;\n }\n\n if (!(await isExistingLocalDirectory(localDestination))) {\n if (!shouldCreateDirectories(options)) {\n throw new TransferError(`Local destination directory does not exist: ${localDestination}`, {\n context: { localPath: options.localPath }\n });\n }\n await mkdir(localDestination, { recursive: true });\n }\n\n return path.join(localDestination, remoteBasename(remotePath));\n }\n\n private async resolveLocalDestinationForRemoteDirectory(\n options: DownloadOptions,\n remotePath: string\n ): Promise<string> {\n const localDestination = resolveLocalPath(options.localPath);\n const isDirectoryLikeDestination =\n hasTrailingPathSeparator(options.localPath) || (await isExistingLocalDirectory(localDestination));\n\n if (!isDirectoryLikeDestination) {\n return localDestination;\n }\n\n if (!(await isExistingLocalDirectory(localDestination))) {\n if (!shouldCreateDirectories(options)) {\n throw new TransferError(`Local destination directory does not exist: ${localDestination}`, {\n context: { localPath: options.localPath }\n });\n }\n await mkdir(localDestination, { recursive: true });\n }\n\n return path.join(localDestination, remoteBasename(remotePath));\n }\n\n private async ensureRemoteParent(remotePath: string, createDirectories = false): Promise<void> {\n const parent = remoteDirname(remotePath);\n if (parent === \".\" || parent === \"/\") {\n return;\n }\n\n if (createDirectories) {\n await this.transport.mkdir(parent, true);\n return;\n }\n\n const exists = await this.transport.exists(parent);\n if (exists !== \"d\") {\n throw new TransferError(`Remote destination parent does not exist: ${parent}`, {\n context: { remotePath }\n });\n }\n }\n\n private async ensureRemoteDirectory(remotePath: string): Promise<void> {\n const exists = await this.transport.exists(remotePath);\n if (exists && exists !== \"d\") {\n throw new TransferError(`Remote destination already exists and is not a directory: ${remotePath}`, {\n context: { remotePath }\n });\n }\n if (!exists) {\n await this.transport.mkdir(remotePath, true);\n }\n }\n\n private async assertRemoteOverwrite(remotePath: string, overwrite = false): Promise<void> {\n if (overwrite) {\n return;\n }\n const exists = await this.transport.exists(remotePath);\n if (exists) {\n throw new TransferError(`Remote destination already exists: ${remotePath}`, {\n context: { remotePath }\n });\n }\n }\n\n private async assertLocalOverwrite(localPath: string, overwrite = false): Promise<void> {\n if (overwrite) {\n return;\n }\n\n try {\n await access(localPath);\n throw new TransferError(`Local destination already exists: ${localPath}`, {\n context: { localPath }\n });\n } catch (error) {\n if (error instanceof TransferError) {\n throw error;\n }\n }\n }\n}\n\nexport function createClient(options: ScpServerOptions): ScpNextClient {\n return new ScpNextClientImpl(options);\n}\n","import { readFile } from \"node:fs/promises\";\n\nimport SftpClient from \"ssh2-sftp-client\";\nimport type {\n ConnectOptions as SftpConnectOptions,\n FileInfo,\n TransferOptions as SftpTransferOptions\n} from \"ssh2-sftp-client\";\n\nimport {\n ConnectionError,\n HostVerificationError,\n TransferError,\n toScpNextError\n} from \"../errors/index.js\";\nimport { createHostVerifier, resolveAllowedFingerprints } from \"../security/host-verification.js\";\nimport { formatErrorMessage } from \"../security/redact.js\";\nimport type { ScpServerOptions } from \"../types/index.js\";\nimport { expandHome } from \"../paths/local-path.js\";\n\nexport interface RemoteFileInfo {\n type: \"-\" | \"d\" | \"l\";\n name: string;\n size: number;\n}\n\nexport interface TransferStep {\n transferredBytes: number;\n chunkBytes: number;\n totalBytes: number;\n}\n\nexport interface SftpTransport {\n connect(options: ScpServerOptions): Promise<void>;\n close(): Promise<void>;\n exists(remotePath: string): Promise<false | \"-\" | \"d\" | \"l\">;\n mkdir(remotePath: string, recursive?: boolean): Promise<void>;\n list(remotePath: string): Promise<RemoteFileInfo[]>;\n uploadFile(\n localPath: string,\n remotePath: string,\n onStep?: (step: TransferStep) => void\n ): Promise<void>;\n downloadFile(\n remotePath: string,\n localPath: string,\n onStep?: (step: TransferStep) => void\n ): Promise<void>;\n}\n\nfunction toRemoteFileInfo(info: FileInfo): RemoteFileInfo {\n return {\n type: info.type,\n name: info.name,\n size: info.size\n };\n}\n\nexport class Ssh2SftpTransport implements SftpTransport {\n private readonly client: SftpClient;\n\n constructor(name = \"scp-next\") {\n this.client = new SftpClient(name, {\n error: () => undefined,\n end: () => undefined,\n close: () => undefined\n });\n }\n\n async connect(options: ScpServerOptions): Promise<void> {\n const allowedFingerprints = await resolveAllowedFingerprints(options);\n const hostVerifier = createHostVerifier(allowedFingerprints);\n\n const connectOptions: SftpConnectOptions = {};\n if (options.host !== undefined) connectOptions.host = options.host;\n if (options.port !== undefined) connectOptions.port = options.port;\n if (options.username !== undefined) connectOptions.username = options.username;\n if (options.password !== undefined) connectOptions.password = options.password;\n if (options.privateKey !== undefined) {\n connectOptions.privateKey = options.privateKey;\n } else if (options.privateKeyFile) {\n connectOptions.privateKey = await readFile(expandHome(options.privateKeyFile), \"utf8\");\n }\n if (options.passphrase !== undefined) connectOptions.passphrase = options.passphrase;\n const agent = options.agent ?? process.env.SSH_AUTH_SOCK;\n if (agent !== undefined) {\n connectOptions.agent = agent;\n }\n if (options.timeout !== undefined) connectOptions.readyTimeout = options.timeout;\n if (hostVerifier) {\n connectOptions.hostHash = \"sha256\";\n connectOptions.hostVerifier = hostVerifier;\n }\n\n try {\n await this.client.connect(connectOptions);\n } catch (error) {\n const converted = toScpNextError(error);\n if (converted instanceof HostVerificationError) {\n throw new HostVerificationError(\n `SSH host verification failed during connection: ${formatErrorMessage(\n error\n )}.${hostVerificationTroubleshooting(options.host)}`,\n { cause: error, context: connectionContext(options) }\n );\n }\n if (isLikelyHostVerificationFailure(error)) {\n throw new HostVerificationError(\n `SSH host verification failed during connection.${hostVerificationTroubleshooting(\n options.host\n )}`,\n { cause: error, context: connectionContext(options) }\n );\n }\n throw new ConnectionError(`Unable to connect to SSH server: ${formatErrorMessage(error)}`, {\n cause: error,\n context: connectionContext(options)\n });\n }\n }\n\n async close(): Promise<void> {\n await this.client.end();\n }\n\n async exists(remotePath: string): Promise<false | \"-\" | \"d\" | \"l\"> {\n return this.client.exists(remotePath);\n }\n\n async mkdir(remotePath: string, recursive = true): Promise<void> {\n await this.client.mkdir(remotePath, recursive);\n }\n\n async list(remotePath: string): Promise<RemoteFileInfo[]> {\n const files = await this.client.list(remotePath);\n return files.map(toRemoteFileInfo);\n }\n\n async uploadFile(\n localPath: string,\n remotePath: string,\n onStep?: (step: TransferStep) => void\n ): Promise<void> {\n try {\n await this.client.fastPut(localPath, remotePath, this.transferOptions(onStep));\n } catch (error) {\n throw new TransferError(`Upload failed for ${localPath}: ${formatErrorMessage(error)}`, {\n cause: error,\n context: { localPath, remotePath }\n });\n }\n }\n\n async downloadFile(\n remotePath: string,\n localPath: string,\n onStep?: (step: TransferStep) => void\n ): Promise<void> {\n try {\n await this.client.fastGet(remotePath, localPath, this.transferOptions(onStep));\n } catch (error) {\n throw new TransferError(`Download failed for ${remotePath}: ${formatErrorMessage(error)}`, {\n cause: error,\n context: { remotePath, localPath }\n });\n }\n }\n\n private transferOptions(onStep?: (step: TransferStep) => void): SftpTransferOptions | undefined {\n if (!onStep) {\n return undefined;\n }\n return {\n step(transferredBytes, chunkBytes, totalBytes) {\n onStep({ transferredBytes, chunkBytes, totalBytes });\n }\n };\n }\n}\n\nfunction connectionContext(options: ScpServerOptions): Record<string, unknown> {\n return {\n host: options.host,\n port: options.port,\n username: options.username\n };\n}\n\nfunction isLikelyHostVerificationFailure(error: unknown): boolean {\n const message = error instanceof Error ? error.message.toLowerCase() : String(error).toLowerCase();\n return (\n message.includes(\"host\") &&\n (message.includes(\"verif\") ||\n message.includes(\"fingerprint\") ||\n message.includes(\"host key\") ||\n message.includes(\"key mismatch\") ||\n message.includes(\"denied\"))\n );\n}\n\nfunction hostVerificationTroubleshooting(host: string | undefined): string {\n const displayHost = host ?? \"<host>\";\n return [\n \"\",\n \"\",\n \"Typical fix:\",\n ` ssh ${displayHost}`,\n \"\",\n \"If plain ssh works but scp-next fails, check that the host entry is available in\",\n \"`~/.ssh/known_hosts` for the same host and port used by scp-next. For non-default ports,\",\n \"OpenSSH usually stores entries as `[host]:port`.\",\n \"You can also configure hostFingerprint or knownHostsFile explicitly.\"\n ].join(\"\\n\");\n}\n","const SENSITIVE_KEYS = [\n \"password\",\n \"passphrase\",\n \"privatekey\",\n \"privatekeyfile\",\n \"token\",\n \"authorization\",\n \"credential\",\n \"secret\"\n];\n\nconst PRIVATE_KEY_PATTERN =\n /-----BEGIN [A-Z ]*PRIVATE KEY-----[\\s\\S]*?-----END [A-Z ]*PRIVATE KEY-----/g;\n\nfunction isSensitiveKey(key: string): boolean {\n const normalized = key.replace(/[-_\\s]/g, \"\").toLowerCase();\n return SENSITIVE_KEYS.some((sensitive) => normalized.includes(sensitive));\n}\n\nexport function redactSensitiveValues(value: unknown): unknown {\n if (typeof value === \"string\") {\n return value.replace(PRIVATE_KEY_PATTERN, \"[REDACTED]\");\n }\n\n if (Array.isArray(value)) {\n const redacted: unknown[] = value.map((item: unknown) => redactSensitiveValues(item));\n return redacted;\n }\n\n if (value && typeof value === \"object\") {\n const redacted: Record<string, unknown> = {};\n for (const [key, nestedValue] of Object.entries(value)) {\n redacted[key] = isSensitiveKey(key) ? \"[REDACTED]\" : redactSensitiveValues(nestedValue);\n }\n return redacted;\n }\n\n return value;\n}\n\nexport function formatErrorMessage(error: unknown): string {\n if (error instanceof Error) {\n return String(redactSensitiveValues(error.message));\n }\n return String(redactSensitiveValues(error));\n}\n","import { redactSensitiveValues } from \"../security/redact.js\";\n\nexport type ScpNextErrorCode =\n | \"SCP_NEXT_ERROR\"\n | \"SCP_NEXT_CONFIGURATION_ERROR\"\n | \"SCP_NEXT_VALIDATION_ERROR\"\n | \"SCP_NEXT_AUTHENTICATION_ERROR\"\n | \"SCP_NEXT_CONNECTION_ERROR\"\n | \"SCP_NEXT_TRANSFER_ERROR\"\n | \"SCP_NEXT_FILESYSTEM_ERROR\"\n | \"SCP_NEXT_HOST_VERIFICATION_ERROR\";\n\nexport interface ScpNextErrorOptions {\n code?: ScpNextErrorCode;\n cause?: unknown;\n context?: Record<string, unknown>;\n}\n\nexport class ScpNextError extends Error {\n readonly code: ScpNextErrorCode;\n readonly context: Record<string, unknown>;\n\n constructor(message: string, options: ScpNextErrorOptions = {}) {\n super(message, { cause: options.cause });\n this.name = new.target.name;\n this.code = options.code ?? \"SCP_NEXT_ERROR\";\n this.context = redactSensitiveValues(options.context ?? {}) as Record<string, unknown>;\n }\n}\n\nexport class ConfigurationError extends ScpNextError {\n constructor(message: string, options: Omit<ScpNextErrorOptions, \"code\"> = {}) {\n super(message, { ...options, code: \"SCP_NEXT_CONFIGURATION_ERROR\" });\n }\n}\n\nexport class ValidationError extends ScpNextError {\n constructor(message: string, options: Omit<ScpNextErrorOptions, \"code\"> = {}) {\n super(message, { ...options, code: \"SCP_NEXT_VALIDATION_ERROR\" });\n }\n}\n\nexport class AuthenticationError extends ScpNextError {\n constructor(message: string, options: Omit<ScpNextErrorOptions, \"code\"> = {}) {\n super(message, { ...options, code: \"SCP_NEXT_AUTHENTICATION_ERROR\" });\n }\n}\n\nexport class ConnectionError extends ScpNextError {\n constructor(message: string, options: Omit<ScpNextErrorOptions, \"code\"> = {}) {\n super(message, { ...options, code: \"SCP_NEXT_CONNECTION_ERROR\" });\n }\n}\n\nexport class TransferError extends ScpNextError {\n constructor(message: string, options: Omit<ScpNextErrorOptions, \"code\"> = {}) {\n super(message, { ...options, code: \"SCP_NEXT_TRANSFER_ERROR\" });\n }\n}\n\nexport class FileSystemError extends ScpNextError {\n constructor(message: string, options: Omit<ScpNextErrorOptions, \"code\"> = {}) {\n super(message, { ...options, code: \"SCP_NEXT_FILESYSTEM_ERROR\" });\n }\n}\n\nexport class HostVerificationError extends ScpNextError {\n constructor(message: string, options: Omit<ScpNextErrorOptions, \"code\"> = {}) {\n super(message, { ...options, code: \"SCP_NEXT_HOST_VERIFICATION_ERROR\" });\n }\n}\n\nexport function toScpNextError(error: unknown): ScpNextError {\n if (error instanceof ScpNextError) {\n return error;\n }\n\n const message = error instanceof Error ? error.message : \"Unexpected scp-next error.\";\n const lowerMessage = message.toLowerCase();\n\n if (lowerMessage.includes(\"authentication\") || lowerMessage.includes(\"permission denied\")) {\n return new AuthenticationError(\"SSH authentication failed.\", { cause: error });\n }\n\n if (\n lowerMessage.includes(\"host verification\") ||\n lowerMessage.includes(\"host key\") ||\n lowerMessage.includes(\"fingerprint\") ||\n (lowerMessage.includes(\"host\") && lowerMessage.includes(\"denied\"))\n ) {\n return new HostVerificationError(\"SSH host verification failed.\", { cause: error });\n }\n\n if (\n lowerMessage.includes(\"timed out\") ||\n lowerMessage.includes(\"connection\") ||\n lowerMessage.includes(\"econn\")\n ) {\n return new ConnectionError(\"SSH connection failed.\", { cause: error });\n }\n\n return new TransferError(String(redactSensitiveValues(message)), { cause: error });\n}\n","import { createHash } from \"node:crypto\";\nimport { access, readFile } from \"node:fs/promises\";\n\nimport { HostVerificationError } from \"../errors/index.js\";\nimport { expandHome } from \"../paths/local-path.js\";\n\nfunction normalizeFingerprint(fingerprint: string): string {\n return fingerprint\n .trim()\n .replace(/^SHA256:/i, \"\")\n .replace(/^sha256:/i, \"\")\n .replace(/=+$/g, \"\");\n}\n\nfunction isHexFingerprint(fingerprint: string): boolean {\n return /^[0-9a-f]+$/i.test(fingerprint);\n}\n\nfunction fingerprintCandidates(fingerprint: string): string[] {\n const normalized = normalizeFingerprint(fingerprint);\n const candidates = new Set([normalized]);\n\n if (isHexFingerprint(normalized)) {\n candidates.add(normalized.toLowerCase());\n } else {\n try {\n candidates.add(Buffer.from(normalized, \"base64\").toString(\"hex\"));\n } catch {\n // Keep the original normalized value when it is not valid base64.\n }\n }\n\n return [...candidates];\n}\n\nexport function isFingerprintMatch(actual: string, expected: string): boolean {\n const normalizedActual = normalizeFingerprint(actual);\n const normalizedExpected = normalizeFingerprint(expected);\n if (normalizedActual === normalizedExpected) {\n return true;\n }\n return (\n isHexFingerprint(normalizedActual) &&\n isHexFingerprint(normalizedExpected) &&\n normalizedActual.toLowerCase() === normalizedExpected.toLowerCase()\n );\n}\n\nexport interface HostVerifierConfig {\n host?: string | undefined;\n port?: number | undefined;\n hostFingerprint?: string | undefined;\n knownHostsFile?: string | undefined;\n}\n\nfunction hostVerificationHint(host: string): string {\n return [\n \"\",\n \"Typical fix:\",\n ` ssh ${host}`,\n \"\",\n \"If you trust the host key, accept it and retry the scp-next command.\",\n \"Alternatively configure hostFingerprint or knownHostsFile explicitly.\"\n ].join(\"\\n\");\n}\n\nexport async function resolveAllowedFingerprints(\n options: HostVerifierConfig\n): Promise<Set<string>> {\n const fingerprints = new Set<string>();\n const knownHostsFile = options.knownHostsFile ?? \"~/.ssh/known_hosts\";\n\n if (!options.host) {\n throw new HostVerificationError(\"A host is required for SSH host verification.\");\n }\n\n if (options.hostFingerprint) {\n for (const fingerprint of fingerprintCandidates(options.hostFingerprint)) {\n fingerprints.add(fingerprint);\n }\n }\n\n try {\n await access(expandHome(knownHostsFile));\n const content = await readFile(expandHome(knownHostsFile), \"utf8\");\n for (const line of content.split(/\\r?\\n/)) {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith(\"#\") || trimmed.startsWith(\"@\")) {\n continue;\n }\n\n const [hosts, algorithm, key] = trimmed.split(/\\s+/);\n const hostPatterns = hosts?.split(\",\") ?? [];\n const portHost = options.port ? `[${options.host}]:${options.port}` : undefined;\n const matchesHost =\n hostPatterns.includes(options.host) || Boolean(portHost && hostPatterns.includes(portHost));\n if (!hosts || !algorithm || !key || !matchesHost) {\n continue;\n }\n\n const keyBuffer = Buffer.from(key, \"base64\");\n fingerprints.add(createHash(\"sha256\").update(keyBuffer).digest(\"base64\").replace(/=+$/g, \"\"));\n fingerprints.add(createHash(\"sha256\").update(keyBuffer).digest(\"hex\"));\n }\n } catch (error) {\n if (options.knownHostsFile || !options.hostFingerprint) {\n throw new HostVerificationError(\n \"SSH host verification requires hostFingerprint or an accessible knownHostsFile.\",\n { cause: error, context: { knownHostsFile } }\n );\n }\n }\n\n if (fingerprints.size === 0) {\n throw new HostVerificationError(\n `SSH host verification failed before connecting: no matching host fingerprint was configured.${hostVerificationHint(\n options.host\n )}`\n );\n }\n\n return fingerprints;\n}\n\nexport function createHostVerifier(allowedFingerprints: Set<string>) {\n return (hashedKey: string): boolean => {\n for (const expected of allowedFingerprints) {\n if (isFingerprintMatch(hashedKey, expected)) {\n return true;\n }\n }\n return false;\n };\n}\n","import { constants } from \"node:fs\";\nimport { access, mkdir, stat } from \"node:fs/promises\";\nimport os from \"node:os\";\nimport path from \"node:path\";\n\nimport { FileSystemError, ValidationError } from \"../errors/index.js\";\n\nexport function expandHome(inputPath: string): string {\n if (inputPath === \"~\") {\n return os.homedir();\n }\n if (inputPath.startsWith(`~${path.sep}`) || inputPath.startsWith(\"~/\")) {\n return path.join(os.homedir(), inputPath.slice(2));\n }\n return inputPath;\n}\n\nexport function resolveLocalPath(inputPath: string, baseDir = process.cwd()): string {\n const expanded = expandHome(inputPath);\n return path.isAbsolute(expanded) ? path.normalize(expanded) : path.resolve(baseDir, expanded);\n}\n\nexport async function assertLocalPathExists(inputPath: string): Promise<void> {\n try {\n await access(resolveLocalPath(inputPath), constants.F_OK);\n } catch (error) {\n throw new FileSystemError(`Local path does not exist: ${inputPath}`, {\n cause: error,\n context: { path: inputPath }\n });\n }\n}\n\nexport async function assertLocalFileReadable(inputPath: string): Promise<void> {\n try {\n await access(resolveLocalPath(inputPath), constants.R_OK);\n } catch (error) {\n throw new FileSystemError(`Local file is not readable: ${inputPath}`, {\n cause: error,\n context: { path: inputPath }\n });\n }\n}\n\nexport async function assertDownloadDestination(inputPath: string, createDirectories = false) {\n const resolved = resolveLocalPath(inputPath);\n const parent = path.dirname(resolved);\n\n if (createDirectories) {\n await mkdir(parent, { recursive: true });\n return;\n }\n\n try {\n await access(parent, constants.W_OK);\n } catch (error) {\n throw new FileSystemError(`Local destination parent does not exist or is not writable: ${parent}`, {\n cause: error,\n context: { path: inputPath }\n });\n }\n}\n\nexport async function getLocalPathKind(inputPath: string): Promise<\"file\" | \"directory\"> {\n const stats = await stat(resolveLocalPath(inputPath));\n if (stats.isDirectory()) {\n return \"directory\";\n }\n if (stats.isFile()) {\n return \"file\";\n }\n throw new ValidationError(`Local path must be a file or directory: ${inputPath}`, {\n context: { path: inputPath }\n });\n}\n\nexport async function getLocalFileSize(inputPath: string): Promise<number> {\n const stats = await stat(resolveLocalPath(inputPath));\n return stats.size;\n}\n","import { readdir, stat } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport type { RemoteFileInfo, SftpTransport } from \"./transport.js\";\nimport { resolveLocalPath } from \"../paths/local-path.js\";\nimport { remoteJoin } from \"../paths/remote-path.js\";\n\nexport interface LocalFileEntry {\n absolutePath: string;\n relativePath: string;\n size: number;\n}\n\nexport async function walkLocalFiles(rootPath: string): Promise<LocalFileEntry[]> {\n const resolvedRoot = resolveLocalPath(rootPath);\n const stats = await stat(resolvedRoot);\n\n if (stats.isFile()) {\n return [\n {\n absolutePath: resolvedRoot,\n relativePath: path.basename(resolvedRoot),\n size: stats.size\n }\n ];\n }\n\n const files: LocalFileEntry[] = [];\n\n async function visit(directory: string): Promise<void> {\n const entries = await readdir(directory, { withFileTypes: true });\n for (const entry of entries) {\n const absolutePath = path.join(directory, entry.name);\n if (entry.isDirectory()) {\n await visit(absolutePath);\n } else if (entry.isFile()) {\n const entryStats = await stat(absolutePath);\n files.push({\n absolutePath,\n relativePath: path.relative(resolvedRoot, absolutePath),\n size: entryStats.size\n });\n }\n }\n }\n\n await visit(resolvedRoot);\n return files;\n}\n\nexport interface RemoteFileEntry {\n remotePath: string;\n relativePath: string;\n size: number;\n}\n\nexport async function walkRemoteFiles(\n transport: SftpTransport,\n rootPath: string\n): Promise<RemoteFileEntry[]> {\n const rootEntries = await transport.list(rootPath);\n const files: RemoteFileEntry[] = [];\n\n async function visit(directory: string, relativeBase: string, entries: RemoteFileInfo[]): Promise<void> {\n for (const entry of entries) {\n const fullPath = remoteJoin(directory, entry.name);\n const relativePath = relativeBase ? remoteJoin(relativeBase, entry.name) : entry.name;\n if (entry.type === \"d\") {\n await visit(fullPath, relativePath, await transport.list(fullPath));\n } else if (entry.type === \"-\") {\n files.push({\n remotePath: fullPath,\n relativePath,\n size: entry.size\n });\n }\n }\n }\n\n await visit(rootPath, \"\", rootEntries);\n return files;\n}\n","import path from \"node:path\";\n\nimport { ValidationError } from \"../errors/index.js\";\n\nexport function assertRemotePath(inputPath: string, label = \"remote path\"): void {\n if (!inputPath || inputPath.trim().length === 0) {\n throw new ValidationError(`Invalid ${label}: remote paths must not be empty.`, {\n context: { path: inputPath }\n });\n }\n}\n\nexport function normalizeRemotePath(inputPath: string): string {\n assertRemotePath(inputPath);\n return path.posix.normalize(inputPath.replace(/\\\\/g, \"/\"));\n}\n\nexport function remoteJoin(...parts: string[]): string {\n const joined = path.posix.join(...parts);\n assertRemotePath(joined);\n return joined;\n}\n\nexport function remoteDirname(inputPath: string): string {\n assertRemotePath(inputPath);\n return path.posix.dirname(inputPath);\n}\n","import { access } from \"node:fs/promises\";\n\nimport { ValidationError } from \"../errors/index.js\";\nimport { assertDownloadDestination, assertLocalPathExists, resolveLocalPath } from \"../paths/local-path.js\";\nimport { assertRemotePath } from \"../paths/remote-path.js\";\nimport type { DownloadOptions, ScpServerOptions, UploadOptions } from \"../types/index.js\";\n\nfunction validatePort(port: number | undefined): void {\n if (port === undefined) {\n return;\n }\n if (!Number.isInteger(port) || port < 1 || port > 65535) {\n throw new ValidationError(\"Port must be an integer between 1 and 65535.\", {\n context: { port }\n });\n }\n}\n\nfunction validateTimeout(timeout: number | undefined): void {\n if (timeout === undefined) {\n return;\n }\n if (!Number.isFinite(timeout) || timeout <= 0) {\n throw new ValidationError(\"Timeout must be a positive number.\", {\n context: { timeout }\n });\n }\n}\n\nexport async function validateServerOptions(options: ScpServerOptions): Promise<void> {\n if (!options.host) {\n throw new ValidationError(\"Host is required.\");\n }\n if (!options.username) {\n throw new ValidationError(\"Username is required.\");\n }\n\n validatePort(options.port);\n validateTimeout(options.timeout);\n\n if (options.privateKeyFile) {\n try {\n await access(resolveLocalPath(options.privateKeyFile));\n } catch (error) {\n throw new ValidationError(`Private key file does not exist: ${options.privateKeyFile}`, {\n cause: error,\n context: { privateKeyFile: options.privateKeyFile }\n });\n }\n }\n\n const hasAuthentication =\n Boolean(options.password) ||\n Boolean(options.privateKey) ||\n Boolean(options.privateKeyFile) ||\n Boolean(options.agent) ||\n Boolean(process.env.SSH_AUTH_SOCK);\n\n if (!hasAuthentication) {\n throw new ValidationError(\n \"Authentication is required. Provide a password, private key, private key file, or SSH agent.\"\n );\n }\n}\n\nexport async function validateUploadOptions(options: UploadOptions): Promise<void> {\n if (!options.localPath) {\n throw new ValidationError(\"Missing localPath.\");\n }\n if (!options.remotePath) {\n throw new ValidationError(\"Missing remotePath.\");\n }\n assertRemotePath(options.remotePath, \"remotePath\");\n validateTimeout(options.timeout);\n await assertLocalPathExists(options.localPath);\n\n if (!options.dryRun) {\n await validateServerOptions(options);\n }\n}\n\nexport async function validateDownloadOptions(options: DownloadOptions): Promise<void> {\n if (!options.remotePath) {\n throw new ValidationError(\"Missing remotePath.\");\n }\n if (!options.localPath) {\n throw new ValidationError(\"Missing localPath.\");\n }\n assertRemotePath(options.remotePath, \"remotePath\");\n validateTimeout(options.timeout);\n await assertDownloadDestination(options.localPath, options.createDirectories ?? true);\n\n if (!options.dryRun) {\n await validateServerOptions(options);\n }\n}\n","import { ScpNextClientImpl } from \"./client.js\";\nimport type { DownloadOptions } from \"../types/index.js\";\n\nexport async function download(options: DownloadOptions): Promise<void> {\n const client = new ScpNextClientImpl(options);\n try {\n await client.download(options.remotePath, options.localPath, options);\n } finally {\n await client.close();\n }\n}\n","import { ScpNextClientImpl } from \"./client.js\";\nimport type { UploadOptions } from \"../types/index.js\";\n\nexport async function upload(options: UploadOptions): Promise<void> {\n const client = new ScpNextClientImpl(options);\n try {\n await client.upload(options.localPath, options.remotePath, options);\n } finally {\n await client.close();\n }\n}\n","import { Command } from \"commander\";\n\nimport { assertSourceDestination } from \"../operands.js\";\nimport type { Output } from \"../output.js\";\nimport {\n addTransferOptions,\n executeResolvedTransfer,\n resolveForCli,\n type RawCommandOptions,\n type TransferHandlers\n} from \"./shared.js\";\n\nexport function createDownloadCommand(handlers: TransferHandlers, output: Output, cwd: string): Command {\n const command = new Command(\"download\")\n .description(\"Download a remote source path to a local destination path\")\n .usage(\"<source> <destination> [options]\")\n .argument(\"[source]\", \"Remote file or directory path\")\n .argument(\"[destination]\", \"Local file or directory\")\n .action(async (source: string | undefined, destination: string | undefined, options: RawCommandOptions) => {\n assertSourceDestination(\"download\", source, destination);\n const resolved = await resolveForCli({\n operation: \"download\",\n source,\n destination,\n options,\n cwd\n });\n await executeResolvedTransfer(resolved, handlers, output, options);\n });\n\n addTransferOptions(command);\n return command;\n}\n","import { ValidationError } from \"../errors/index.js\";\nimport type { TransferOperation } from \"../types/index.js\";\n\nexport function usageFor(operation: TransferOperation): string {\n return `scp-next ${operation} <source> <destination> [options]`;\n}\n\nexport function assertSourceDestination(\n operation: TransferOperation,\n source?: string,\n destination?: string\n): asserts source is string {\n if (!source) {\n throw new ValidationError(`Missing source path.\\n\\nUsage:\\n ${usageFor(operation)}`);\n }\n if (!destination) {\n throw new ValidationError(`Missing destination path.\\n\\nUsage:\\n ${usageFor(operation)}`);\n }\n}\n","import { Option } from \"commander\";\n\nimport { readEnvironment } from \"../../config/environment.js\";\nimport { loadConfig } from \"../../config/load-config.js\";\nimport {\n resolveTransferConfig,\n type CliTransferOptions\n} from \"../../config/resolve-config.js\";\nimport type { Output } from \"../output.js\";\nimport { createProgressReporter, verbosePlan, writeDryRun } from \"../output.js\";\nimport type {\n DownloadOptions,\n ResolvedTransferConfig,\n TransferOperation,\n UploadOptions\n} from \"../../types/index.js\";\n\nexport interface RawCommandOptions {\n host?: string;\n port?: number;\n username?: string;\n password?: string;\n privateKey?: string;\n privateKeyFile?: string;\n passphrase?: string;\n config?: string;\n profile?: string;\n recursive?: boolean;\n overwrite?: boolean;\n createDirectories?: boolean;\n dryRun?: boolean;\n timeout?: number;\n verbose?: boolean;\n quiet?: boolean;\n}\n\nexport interface TransferHandlers {\n upload(options: UploadOptions): Promise<void>;\n download(options: DownloadOptions): Promise<void>;\n}\n\nexport function addTransferOptions(command: { option: (flags: string, description: string) => unknown; addOption: (option: Option) => unknown }) {\n command.option(\"--host <host>\", \"SSH server host\");\n command.addOption(new Option(\"--port <port>\", \"SSH server port\").argParser(parseInteger));\n command.option(\"--username <username>\", \"SSH username\");\n command.option(\"--password <password>\", \"SSH password (prefer environment variables or key files)\");\n command.option(\"--private-key <privateKey>\", \"Private-key content\");\n command.option(\"--private-key-file <privateKeyFile>\", \"Private-key file path\");\n command.option(\"--passphrase <passphrase>\", \"Private-key passphrase\");\n command.option(\"--config <path>\", \"Configuration file path\");\n command.option(\"--profile <name>\", \"Named server profile\");\n command.option(\"--recursive\", \"Transfer directories recursively\");\n command.option(\"--overwrite\", \"Overwrite existing destination files\");\n command.option(\"--create-directories\", \"Create missing destination directories\");\n command.option(\"--no-create-directories\", \"Do not create missing destination directories\");\n command.option(\"--dry-run\", \"Resolve and validate without connecting or transferring\");\n command.addOption(new Option(\"--timeout <milliseconds>\", \"Connection/operation timeout\").argParser(parseInteger));\n command.option(\"--verbose\", \"Print verbose diagnostic output\");\n command.option(\"--quiet\", \"Disable progress and non-error output\");\n return command;\n}\n\nfunction parseInteger(value: string): number {\n const parsed = Number.parseInt(value, 10);\n if (!Number.isFinite(parsed)) {\n throw new Error(\"Expected a number.\");\n }\n return parsed;\n}\n\nfunction toCliOptions(options: RawCommandOptions): CliTransferOptions {\n return {\n host: options.host,\n port: options.port,\n username: options.username,\n password: options.password,\n privateKey: options.privateKey,\n privateKeyFile: options.privateKeyFile,\n passphrase: options.passphrase,\n profile: options.profile,\n recursive: options.recursive,\n overwrite: options.overwrite,\n createDirectories: options.createDirectories,\n dryRun: options.dryRun,\n timeout: options.timeout\n };\n}\n\nexport async function resolveForCli(input: {\n operation?: TransferOperation | undefined;\n source?: string | undefined;\n destination?: string | undefined;\n jobName?: string | undefined;\n options: RawCommandOptions;\n cwd: string;\n}): Promise<ResolvedTransferConfig> {\n const loaded = await loadConfig(input.options.config, input.cwd);\n return resolveTransferConfig({\n operation: input.operation,\n source: input.source,\n destination: input.destination,\n jobName: input.jobName,\n cli: toCliOptions(input.options),\n env: readEnvironment(),\n config: loaded.config,\n configDirectory: loaded.directory,\n cwd: input.cwd\n });\n}\n\nexport async function executeResolvedTransfer(\n config: ResolvedTransferConfig,\n handlers: TransferHandlers,\n output: Output,\n commandOptions: RawCommandOptions\n): Promise<void> {\n if (commandOptions.verbose) {\n verbosePlan(output, config);\n }\n\n if (config.dryRun) {\n if (!commandOptions.quiet) {\n writeDryRun(output, config);\n }\n return;\n }\n\n const onProgress = createProgressReporter(output, commandOptions.quiet);\n\n if (config.operation === \"upload\") {\n const uploadOptions: UploadOptions = {\n ...config,\n localPath: config.source,\n remotePath: config.destination\n };\n if (onProgress) uploadOptions.onProgress = onProgress;\n await handlers.upload(uploadOptions);\n return;\n }\n\n const downloadOptions: DownloadOptions = {\n ...config,\n remotePath: config.source,\n localPath: config.destination\n };\n if (onProgress) downloadOptions.onProgress = onProgress;\n await handlers.download(downloadOptions);\n}\n","import type { ScpServerOptions } from \"../types/index.js\";\n\nexport interface EnvironmentConfig extends ScpServerOptions {\n profile?: string;\n}\n\nfunction parseInteger(value: string | undefined, name: string): number | undefined {\n if (!value) {\n return undefined;\n }\n\n const parsed = Number.parseInt(value, 10);\n if (!Number.isFinite(parsed)) {\n throw new Error(`${name} must be a number.`);\n }\n return parsed;\n}\n\nexport function readEnvironment(\n env: NodeJS.ProcessEnv = process.env\n): EnvironmentConfig {\n const result: EnvironmentConfig = {};\n\n if (env.SCP_NEXT_HOST) result.host = env.SCP_NEXT_HOST;\n if (env.SCP_NEXT_PORT) {\n const port = parseInteger(env.SCP_NEXT_PORT, \"SCP_NEXT_PORT\");\n if (port !== undefined) result.port = port;\n }\n if (env.SCP_NEXT_USERNAME) result.username = env.SCP_NEXT_USERNAME;\n if (env.SCP_NEXT_PASSWORD) result.password = env.SCP_NEXT_PASSWORD;\n if (env.SCP_NEXT_PRIVATE_KEY) result.privateKey = env.SCP_NEXT_PRIVATE_KEY;\n if (env.SCP_NEXT_PRIVATE_KEY_FILE) result.privateKeyFile = env.SCP_NEXT_PRIVATE_KEY_FILE;\n if (env.SCP_NEXT_PASSPHRASE) result.passphrase = env.SCP_NEXT_PASSPHRASE;\n if (env.SCP_NEXT_TIMEOUT) {\n const timeout = parseInteger(env.SCP_NEXT_TIMEOUT, \"SCP_NEXT_TIMEOUT\");\n if (timeout !== undefined) result.timeout = timeout;\n }\n if (env.SCP_NEXT_PROFILE) result.profile = env.SCP_NEXT_PROFILE;\n\n return result;\n}\n","import { access, readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport { z } from \"zod\";\n\nimport { ConfigurationError } from \"../errors/index.js\";\nimport type { ScpNextConfig } from \"../types/index.js\";\nimport { resolveLocalPath } from \"../paths/local-path.js\";\n\nexport const CONFIG_FILENAMES = [\"scp-next.config.json\", \".scp-nextrc\", \".scp-nextrc.json\"] as const;\n\nconst serverSchema = z.object({\n host: z.string().optional(),\n port: z.number().int().optional(),\n username: z.string().optional(),\n password: z.string().optional(),\n privateKey: z.string().optional(),\n privateKeyFile: z.string().optional(),\n passphrase: z.string().optional(),\n agent: z.string().optional(),\n timeout: z.number().int().optional(),\n hostFingerprint: z.string().optional(),\n knownHostsFile: z.string().optional()\n});\n\nconst transferSchema = z.object({\n recursive: z.boolean().optional(),\n overwrite: z.boolean().optional(),\n createDirectories: z.boolean().optional(),\n dryRun: z.boolean().optional(),\n timeout: z.number().int().optional()\n});\n\nconst jobSchema = transferSchema.extend({\n operation: z.enum([\"upload\", \"download\"]),\n profile: z.string().optional(),\n source: z.string(),\n destination: z.string()\n});\n\nconst configSchema = serverSchema\n .extend({\n defaultProfile: z.string().optional(),\n server: serverSchema.optional(),\n transfer: transferSchema.optional(),\n profiles: z.record(serverSchema).optional(),\n jobs: z.record(jobSchema).optional()\n })\n .passthrough();\n\nexport interface LoadedConfig {\n config: ScpNextConfig;\n path?: string;\n directory: string;\n}\n\nasync function fileExists(filePath: string): Promise<boolean> {\n try {\n await access(filePath);\n return true;\n } catch {\n return false;\n }\n}\n\nexport async function findConfigFile(cwd = process.cwd()): Promise<string | undefined> {\n for (const filename of CONFIG_FILENAMES) {\n const candidate = path.resolve(cwd, filename);\n if (await fileExists(candidate)) {\n return candidate;\n }\n }\n return undefined;\n}\n\nexport async function loadConfig(\n explicitPath?: string,\n cwd = process.cwd()\n): Promise<LoadedConfig> {\n const configPath = explicitPath ? resolveLocalPath(explicitPath, cwd) : await findConfigFile(cwd);\n\n if (!configPath) {\n return { config: {}, directory: cwd };\n }\n\n let raw: string;\n try {\n raw = await readFile(configPath, \"utf8\");\n } catch (error) {\n throw new ConfigurationError(`Unable to read configuration file: ${configPath}`, {\n cause: error,\n context: { path: configPath }\n });\n }\n\n try {\n const parsed = JSON.parse(raw) as unknown;\n const result = configSchema.safeParse(parsed);\n if (!result.success) {\n throw new ConfigurationError(`Invalid configuration file: ${result.error.message}`, {\n context: { path: configPath }\n });\n }\n\n return {\n config: result.data,\n path: configPath,\n directory: path.dirname(configPath)\n };\n } catch (error) {\n if (error instanceof ConfigurationError) {\n throw error;\n }\n throw new ConfigurationError(`Invalid JSON in configuration file: ${configPath}`, {\n cause: error,\n context: { path: configPath }\n });\n }\n}\n","import path from \"node:path\";\n\nimport { selectJob } from \"./jobs.js\";\nimport { selectProfile } from \"./profiles.js\";\nimport type { EnvironmentConfig } from \"./environment.js\";\nimport type {\n ResolvedTransferConfig,\n ScpNextConfig,\n ScpServerOptions,\n TransferJob,\n TransferOperation,\n TransferOptions\n} from \"../types/index.js\";\nimport { resolveLocalPath } from \"../paths/local-path.js\";\n\nexport interface CliTransferOptions extends ScpServerOptions, Omit<TransferOptions, \"onProgress\"> {\n profile?: string | undefined;\n}\n\nexport interface ResolveTransferInput {\n operation?: TransferOperation | undefined;\n source?: string | undefined;\n destination?: string | undefined;\n cli?: CliTransferOptions | undefined;\n env?: EnvironmentConfig | undefined;\n config?: ScpNextConfig | undefined;\n configDirectory?: string | undefined;\n cwd?: string | undefined;\n jobName?: string | undefined;\n}\n\nconst DEFAULT_TRANSFER: Omit<ResolvedTransferConfig, \"operation\" | \"source\" | \"destination\"> = {\n port: 22,\n recursive: false,\n overwrite: false,\n createDirectories: true,\n dryRun: false\n};\n\nfunction assignDefined<T extends object>(target: T, source: object | undefined): T {\n if (!source) {\n return target;\n }\n\n for (const [key, value] of Object.entries(source as Record<string, unknown>)) {\n if (value !== undefined) {\n Object.assign(target, { [key]: value });\n }\n }\n\n return target;\n}\n\nfunction rootServer(config: ScpNextConfig): ScpServerOptions {\n const result: ScpServerOptions = {};\n assignDefined(result, config.server);\n assignDefined(result, {\n host: config.host,\n port: config.port,\n username: config.username,\n password: config.password,\n privateKey: config.privateKey,\n privateKeyFile: config.privateKeyFile,\n passphrase: config.passphrase,\n agent: config.agent,\n timeout: config.timeout,\n hostFingerprint: config.hostFingerprint,\n knownHostsFile: config.knownHostsFile\n });\n return result;\n}\n\nfunction jobTransfer(job: TransferJob | undefined): Omit<TransferOptions, \"onProgress\"> {\n const result: Omit<TransferOptions, \"onProgress\"> = {};\n if (!job) {\n return result;\n }\n return assignDefined(result, {\n recursive: job.recursive,\n overwrite: job.overwrite,\n createDirectories: job.createDirectories,\n dryRun: job.dryRun,\n timeout: job.timeout\n });\n}\n\nfunction resolveConfigRelatedPaths(\n resolved: ResolvedTransferConfig,\n operation: TransferOperation,\n configDirectory: string\n): ResolvedTransferConfig {\n const next = { ...resolved };\n\n if (next.privateKeyFile && !next.privateKeyFile.startsWith(\"~\")) {\n next.privateKeyFile = path.isAbsolute(next.privateKeyFile)\n ? next.privateKeyFile\n : resolveLocalPath(next.privateKeyFile, configDirectory);\n }\n\n if (next.knownHostsFile && !next.knownHostsFile.startsWith(\"~\")) {\n next.knownHostsFile = path.isAbsolute(next.knownHostsFile)\n ? next.knownHostsFile\n : resolveLocalPath(next.knownHostsFile, configDirectory);\n }\n\n if (operation === \"upload\" && !next.source.startsWith(\"~\")) {\n next.source = path.isAbsolute(next.source)\n ? next.source\n : resolveLocalPath(next.source, configDirectory);\n }\n\n if (operation === \"download\" && !next.destination.startsWith(\"~\")) {\n next.destination = path.isAbsolute(next.destination)\n ? next.destination\n : resolveLocalPath(next.destination, configDirectory);\n }\n\n return next;\n}\n\nexport function resolveTransferConfig(input: ResolveTransferInput): ResolvedTransferConfig {\n const config = input.config ?? {};\n const env = input.env ?? {};\n const cli = input.cli ?? {};\n const configDirectory = input.configDirectory ?? process.cwd();\n const cwd = input.cwd ?? process.cwd();\n const job = input.jobName ? selectJob(config, input.jobName) : undefined;\n const operation = input.operation ?? job?.operation;\n\n if (!operation) {\n throw new Error(\"Transfer operation is required.\");\n }\n\n const selectedProfileName =\n cli.profile ?? env.profile ?? job?.profile ?? config.defaultProfile;\n const profile = selectProfile(config, selectedProfileName);\n\n const resolved: ResolvedTransferConfig = {\n ...DEFAULT_TRANSFER,\n operation,\n source: job?.source ?? \"\",\n destination: job?.destination ?? \"\"\n };\n\n assignDefined(resolved, jobTransfer(job));\n assignDefined(resolved, config.transfer);\n assignDefined(resolved, rootServer(config));\n assignDefined(resolved, profile);\n assignDefined(resolved, {\n host: env.host,\n port: env.port,\n username: env.username,\n password: env.password,\n privateKey: env.privateKey,\n privateKeyFile: env.privateKeyFile,\n passphrase: env.passphrase,\n timeout: env.timeout\n });\n assignDefined(resolved, {\n source: input.source,\n destination: input.destination\n });\n assignDefined(resolved, cli);\n\n if (selectedProfileName) {\n resolved.profile = selectedProfileName;\n }\n\n const pathResolved = resolveConfigRelatedPaths(resolved, operation, configDirectory);\n\n if (input.source && operation === \"upload\") {\n pathResolved.source = resolveLocalPath(input.source, cwd);\n }\n\n if (input.destination && operation === \"download\") {\n pathResolved.destination = resolveLocalPath(input.destination, cwd);\n }\n\n return pathResolved;\n}\n","import { ConfigurationError } from \"../errors/index.js\";\nimport type { ScpNextConfig, TransferJob } from \"../types/index.js\";\n\nexport function selectJob(config: ScpNextConfig, jobName: string): TransferJob {\n const job = config.jobs?.[jobName];\n if (!job) {\n throw new ConfigurationError(`Unknown job: ${jobName}`, {\n context: { job: jobName }\n });\n }\n return job;\n}\n","import { ConfigurationError } from \"../errors/index.js\";\nimport type { ScpNextConfig, ScpServerOptions } from \"../types/index.js\";\n\nexport function selectProfile(\n config: ScpNextConfig,\n profileName?: string\n): ScpServerOptions | undefined {\n if (!profileName) {\n return undefined;\n }\n\n const profile = config.profiles?.[profileName];\n if (!profile) {\n throw new ConfigurationError(`Unknown profile: ${profileName}`, {\n context: { profile: profileName }\n });\n }\n\n return profile;\n}\n","import type { ResolvedTransferConfig, TransferProgress } from \"../types/index.js\";\nimport { redactSensitiveValues } from \"../security/redact.js\";\n\nexport interface Output {\n stdout: NodeJS.WritableStream & { isTTY?: boolean };\n stderr: NodeJS.WritableStream & { isTTY?: boolean };\n}\n\nexport function writeDryRun(output: Output, config: ResolvedTransferConfig): void {\n const destination =\n config.operation === \"upload\"\n ? `${config.username ?? \"user\"}@${config.host ?? \"host\"}:${config.destination}`\n : config.destination;\n\n output.stdout.write(`Dry run: ${config.operation}\\n`);\n output.stdout.write(`Source: ${config.source}\\n`);\n output.stdout.write(`Destination: ${destination}\\n`);\n output.stdout.write(`Recursive: ${config.recursive ? \"yes\" : \"no\"}\\n`);\n output.stdout.write(`Overwrite: ${config.overwrite ? \"yes\" : \"no\"}\\n`);\n}\n\nexport function createProgressReporter(\n output: Output,\n quiet?: boolean\n): ((progress: TransferProgress) => void) | undefined {\n if (quiet || !output.stderr.isTTY) {\n return undefined;\n }\n\n return (progress) => {\n const total = progress.totalBytes ? formatBytes(progress.totalBytes) : \"?\";\n const transferred = formatBytes(progress.transferredBytes);\n const percentage = progress.percentage === undefined ? \"\" : ` (${progress.percentage}%)`;\n const currentFile = progress.currentFile ? `: ${progress.currentFile}` : \"\";\n output.stderr.write(`\\r${progress.operation === \"upload\" ? \"Uploading\" : \"Downloading\"}${currentFile}\\n`);\n output.stderr.write(`${transferred} / ${total}${percentage}\\n`);\n };\n}\n\nexport function verbosePlan(output: Output, config: ResolvedTransferConfig): void {\n output.stderr.write(\n `${JSON.stringify(\n redactSensitiveValues({\n operation: config.operation,\n host: config.host,\n port: config.port,\n username: config.username,\n source: config.source,\n destination: config.destination,\n recursive: config.recursive,\n overwrite: config.overwrite,\n createDirectories: config.createDirectories,\n dryRun: config.dryRun\n }),\n null,\n 2\n )}\\n`\n );\n}\n\nfunction formatBytes(bytes: number): string {\n if (bytes < 1024) {\n return `${bytes} B`;\n }\n const units = [\"KB\", \"MB\", \"GB\", \"TB\"];\n let value = bytes / 1024;\n let unitIndex = 0;\n while (value >= 1024 && unitIndex < units.length - 1) {\n value /= 1024;\n unitIndex += 1;\n }\n return `${value.toFixed(1)} ${units[unitIndex]}`;\n}\n","import { Command } from \"commander\";\n\nimport type { Output } from \"../output.js\";\nimport {\n addTransferOptions,\n executeResolvedTransfer,\n resolveForCli,\n type RawCommandOptions,\n type TransferHandlers\n} from \"./shared.js\";\n\nexport function createRunCommand(handlers: TransferHandlers, output: Output, cwd: string): Command {\n const command = new Command(\"run\")\n .description(\"Run a configured transfer job\")\n .usage(\"<job> [source] [destination] [options]\")\n .argument(\"<job>\", \"Configured job name\")\n .argument(\"[source]\", \"Optional source override\")\n .argument(\"[destination]\", \"Optional destination override\")\n .action(\n async (\n jobName: string,\n source: string | undefined,\n destination: string | undefined,\n options: RawCommandOptions\n ) => {\n const resolved = await resolveForCli({\n source,\n destination,\n jobName,\n options,\n cwd\n });\n await executeResolvedTransfer(resolved, handlers, output, options);\n }\n );\n\n addTransferOptions(command);\n return command;\n}\n","import { Command } from \"commander\";\n\nimport { assertSourceDestination } from \"../operands.js\";\nimport type { Output } from \"../output.js\";\nimport {\n addTransferOptions,\n executeResolvedTransfer,\n resolveForCli,\n type RawCommandOptions,\n type TransferHandlers\n} from \"./shared.js\";\n\nexport function createUploadCommand(handlers: TransferHandlers, output: Output, cwd: string): Command {\n const command = new Command(\"upload\")\n .description(\"Upload a local source path to a remote destination path\")\n .usage(\"<source> <destination> [options]\")\n .argument(\"[source]\", \"Local file or directory\")\n .argument(\"[destination]\", \"Remote file or directory path\")\n .action(async (source: string | undefined, destination: string | undefined, options: RawCommandOptions) => {\n assertSourceDestination(\"upload\", source, destination);\n const resolved = await resolveForCli({\n operation: \"upload\",\n source,\n destination,\n options,\n cwd\n });\n await executeResolvedTransfer(resolved, handlers, output, options);\n });\n\n addTransferOptions(command);\n return command;\n}\n"],"mappings":";;;AAAA,SAAS,cAAc,oBAAoB;AAC3C,SAAS,SAAS,eAAe;AACjC,SAAS,qBAAqB;AAE9B,SAAS,WAAAA,UAAS,sBAAsB;;;ACJxC,SAAS,UAAAC,SAAQ,SAAAC,QAAO,QAAAC,aAAY;AACpC,OAAOC,WAAU;;;ACDjB,SAAS,YAAAC,iBAAgB;AAEzB,OAAO,gBAAgB;;;ACFvB,IAAM,iBAAiB;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;A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W;AACnE,QAAI,iBAAiB,cAAc;AACjC,aAAO,OAAO,MAAM,UAAU,mBAAmB,MAAM,OAAO,CAAC;AAAA,CAAI;AACnE,UAAI,WAAW,MAAM,iBAAiB,OAAO;AAC3C,eAAO,OAAO,MAAM,GAAG,mBAAmB,MAAM,MAAM,SAAS,MAAM,MAAM,OAAO,CAAC;AAAA,CAAI;AAAA,MACzF;AACA,aAAO;AAAA,IACT;AAEA,WAAO,OAAO,MAAM,UAAU,mBAAmB,KAAK,CAAC;AAAA,CAAI;AAC3D,QAAI,WAAW,iBAAiB,SAAS,MAAM,OAAO;AACpD,aAAO,OAAO,MAAM,GAAG,mBAAmB,MAAM,KAAK,CAAC;AAAA,CAAI;AAAA,IAC5D;AACA,WAAO;AAAA,EACT;AACF;AAEA,IAAI,gBAAgB,GAAG;AACrB,OAAK,OAAO,EAAE,KAAK,CAAC,aAAa;AAC/B,YAAQ,WAAW;AAAA,EACrB,CAAC;AACH;","names":["Command","access","mkdir","stat","path","readFile","access","access","readFile","stat","path","path","path","stat","path","access","access","path","stat","mkdir","totalBytes","access","access","readFile","path","access","path","readFile","path","path","percentage","parseInteger","Command","Command","Command","Command","Command"]}