scp-next 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -39,6 +39,12 @@ function redactSensitiveValues(value) {
39
39
  }
40
40
  return value;
41
41
  }
42
+ function formatErrorMessage(error) {
43
+ if (error instanceof Error) {
44
+ return String(redactSensitiveValues(error.message));
45
+ }
46
+ return String(redactSensitiveValues(error));
47
+ }
42
48
 
43
49
  // src/errors/index.ts
44
50
  var ScpNextError = class extends Error {
@@ -95,7 +101,7 @@ function toScpNextError(error) {
95
101
  if (lowerMessage.includes("authentication") || lowerMessage.includes("permission denied")) {
96
102
  return new AuthenticationError("SSH authentication failed.", { cause: error });
97
103
  }
98
- if (lowerMessage.includes("host verification") || lowerMessage.includes("host key")) {
104
+ if (lowerMessage.includes("host verification") || lowerMessage.includes("host key") || lowerMessage.includes("fingerprint") || lowerMessage.includes("host") && lowerMessage.includes("denied")) {
99
105
  return new HostVerificationError("SSH host verification failed.", { cause: error });
100
106
  }
101
107
  if (lowerMessage.includes("timed out") || lowerMessage.includes("connection") || lowerMessage.includes("econn")) {
@@ -169,8 +175,39 @@ async function getLocalPathKind(inputPath) {
169
175
  function normalizeFingerprint(fingerprint) {
170
176
  return fingerprint.trim().replace(/^SHA256:/i, "").replace(/^sha256:/i, "").replace(/=+$/g, "");
171
177
  }
178
+ function isHexFingerprint(fingerprint) {
179
+ return /^[0-9a-f]+$/i.test(fingerprint);
180
+ }
181
+ function fingerprintCandidates(fingerprint) {
182
+ const normalized = normalizeFingerprint(fingerprint);
183
+ const candidates = /* @__PURE__ */ new Set([normalized]);
184
+ if (isHexFingerprint(normalized)) {
185
+ candidates.add(normalized.toLowerCase());
186
+ } else {
187
+ try {
188
+ candidates.add(Buffer.from(normalized, "base64").toString("hex"));
189
+ } catch {
190
+ }
191
+ }
192
+ return [...candidates];
193
+ }
172
194
  function isFingerprintMatch(actual, expected) {
173
- return normalizeFingerprint(actual) === normalizeFingerprint(expected);
195
+ const normalizedActual = normalizeFingerprint(actual);
196
+ const normalizedExpected = normalizeFingerprint(expected);
197
+ if (normalizedActual === normalizedExpected) {
198
+ return true;
199
+ }
200
+ return isHexFingerprint(normalizedActual) && isHexFingerprint(normalizedExpected) && normalizedActual.toLowerCase() === normalizedExpected.toLowerCase();
201
+ }
202
+ function hostVerificationHint(host) {
203
+ return [
204
+ "",
205
+ "Typical fix:",
206
+ ` ssh ${host}`,
207
+ "",
208
+ "If you trust the host key, accept it and retry the scp-next command.",
209
+ "Alternatively configure hostFingerprint or knownHostsFile explicitly."
210
+ ].join("\n");
174
211
  }
175
212
  async function resolveAllowedFingerprints(options) {
176
213
  const fingerprints = /* @__PURE__ */ new Set();
@@ -179,7 +216,9 @@ async function resolveAllowedFingerprints(options) {
179
216
  throw new HostVerificationError("A host is required for SSH host verification.");
180
217
  }
181
218
  if (options.hostFingerprint) {
182
- fingerprints.add(normalizeFingerprint(options.hostFingerprint));
219
+ for (const fingerprint of fingerprintCandidates(options.hostFingerprint)) {
220
+ fingerprints.add(fingerprint);
221
+ }
183
222
  }
184
223
  try {
185
224
  await access2(expandHome(knownHostsFile));
@@ -190,11 +229,15 @@ async function resolveAllowedFingerprints(options) {
190
229
  continue;
191
230
  }
192
231
  const [hosts, algorithm, key] = trimmed.split(/\s+/);
193
- if (!hosts || !algorithm || !key || !hosts.split(",").includes(options.host)) {
232
+ const hostPatterns = hosts?.split(",") ?? [];
233
+ const portHost = options.port ? `[${options.host}]:${options.port}` : void 0;
234
+ const matchesHost = hostPatterns.includes(options.host) || Boolean(portHost && hostPatterns.includes(portHost));
235
+ if (!hosts || !algorithm || !key || !matchesHost) {
194
236
  continue;
195
237
  }
196
- const fingerprint = createHash("sha256").update(Buffer.from(key, "base64")).digest("base64").replace(/=+$/g, "");
197
- fingerprints.add(fingerprint);
238
+ const keyBuffer = Buffer.from(key, "base64");
239
+ fingerprints.add(createHash("sha256").update(keyBuffer).digest("base64").replace(/=+$/g, ""));
240
+ fingerprints.add(createHash("sha256").update(keyBuffer).digest("hex"));
198
241
  }
199
242
  } catch (error) {
200
243
  if (options.knownHostsFile || !options.hostFingerprint) {
@@ -206,7 +249,9 @@ async function resolveAllowedFingerprints(options) {
206
249
  }
207
250
  if (fingerprints.size === 0) {
208
251
  throw new HostVerificationError(
209
- "SSH host verification failed before connecting: no matching host fingerprint was configured."
252
+ `SSH host verification failed before connecting: no matching host fingerprint was configured.${hostVerificationHint(
253
+ options.host
254
+ )}`
210
255
  );
211
256
  }
212
257
  return fingerprints;
@@ -233,7 +278,11 @@ function toRemoteFileInfo(info) {
233
278
  var Ssh2SftpTransport = class {
234
279
  client;
235
280
  constructor(name = "scp-next") {
236
- this.client = new SftpClient(name);
281
+ this.client = new SftpClient(name, {
282
+ error: () => void 0,
283
+ end: () => void 0,
284
+ close: () => void 0
285
+ });
237
286
  }
238
287
  async connect(options) {
239
288
  const allowedFingerprints = await resolveAllowedFingerprints(options);
@@ -263,15 +312,24 @@ var Ssh2SftpTransport = class {
263
312
  } catch (error) {
264
313
  const converted = toScpNextError(error);
265
314
  if (converted instanceof HostVerificationError) {
266
- throw converted;
315
+ throw new HostVerificationError(
316
+ `SSH host verification failed during connection: ${formatErrorMessage(
317
+ error
318
+ )}.${hostVerificationTroubleshooting(options.host)}`,
319
+ { cause: error, context: connectionContext(options) }
320
+ );
267
321
  }
268
- throw new ConnectionError("Unable to connect to SSH server.", {
322
+ if (isLikelyHostVerificationFailure(error)) {
323
+ throw new HostVerificationError(
324
+ `SSH host verification failed during connection.${hostVerificationTroubleshooting(
325
+ options.host
326
+ )}`,
327
+ { cause: error, context: connectionContext(options) }
328
+ );
329
+ }
330
+ throw new ConnectionError(`Unable to connect to SSH server: ${formatErrorMessage(error)}`, {
269
331
  cause: error,
270
- context: {
271
- host: options.host,
272
- port: options.port,
273
- username: options.username
274
- }
332
+ context: connectionContext(options)
275
333
  });
276
334
  }
277
335
  }
@@ -292,7 +350,7 @@ var Ssh2SftpTransport = class {
292
350
  try {
293
351
  await this.client.fastPut(localPath, remotePath, this.transferOptions(onStep));
294
352
  } catch (error) {
295
- throw new TransferError(`Upload failed for ${localPath}.`, {
353
+ throw new TransferError(`Upload failed for ${localPath}: ${formatErrorMessage(error)}`, {
296
354
  cause: error,
297
355
  context: { localPath, remotePath }
298
356
  });
@@ -302,7 +360,7 @@ var Ssh2SftpTransport = class {
302
360
  try {
303
361
  await this.client.fastGet(remotePath, localPath, this.transferOptions(onStep));
304
362
  } catch (error) {
305
- throw new TransferError(`Download failed for ${remotePath}.`, {
363
+ throw new TransferError(`Download failed for ${remotePath}: ${formatErrorMessage(error)}`, {
306
364
  cause: error,
307
365
  context: { remotePath, localPath }
308
366
  });
@@ -319,6 +377,31 @@ var Ssh2SftpTransport = class {
319
377
  };
320
378
  }
321
379
  };
380
+ function connectionContext(options) {
381
+ return {
382
+ host: options.host,
383
+ port: options.port,
384
+ username: options.username
385
+ };
386
+ }
387
+ function isLikelyHostVerificationFailure(error) {
388
+ const message = error instanceof Error ? error.message.toLowerCase() : String(error).toLowerCase();
389
+ return message.includes("host") && (message.includes("verif") || message.includes("fingerprint") || message.includes("host key") || message.includes("key mismatch") || message.includes("denied"));
390
+ }
391
+ function hostVerificationTroubleshooting(host) {
392
+ const displayHost = host ?? "<host>";
393
+ return [
394
+ "",
395
+ "",
396
+ "Typical fix:",
397
+ ` ssh ${displayHost}`,
398
+ "",
399
+ "If plain ssh works but scp-next fails, check that the host entry is available in",
400
+ "`~/.ssh/known_hosts` for the same host and port used by scp-next. For non-default ports,",
401
+ "OpenSSH usually stores entries as `[host]:port`.",
402
+ "You can also configure hostFingerprint or knownHostsFile explicitly."
403
+ ].join("\n");
404
+ }
322
405
 
323
406
  // src/client/walk.ts
324
407
  import { readdir, stat as stat2 } from "fs/promises";
@@ -546,10 +629,9 @@ var ScpNextClientImpl = class {
546
629
  throw new ValidationError("Uploading a directory requires recursive mode.");
547
630
  }
548
631
  if (localKind === "file") {
549
- await this.ensureRemoteParent(remotePath, options.createDirectories);
550
- await this.assertRemoteOverwrite(remotePath, options.overwrite);
632
+ const destinationFile = await this.resolveRemoteDestinationForLocalFile(options, remotePath);
551
633
  const totalBytes2 = void 0;
552
- await this.transport.uploadFile(resolveLocalPath(options.localPath), remotePath, (step) => {
634
+ await this.transport.uploadFile(resolveLocalPath(options.localPath), destinationFile, (step) => {
553
635
  options.onProgress?.({
554
636
  operation: "upload",
555
637
  source: options.localPath,
@@ -602,6 +684,35 @@ var ScpNextClientImpl = class {
602
684
  completedFiles += 1;
603
685
  }
604
686
  }
687
+ async resolveRemoteDestinationForLocalFile(options, remotePath) {
688
+ const remoteKind = await this.transport.exists(remotePath);
689
+ const isDirectoryLikeDestination = remoteKind === "d" || remotePath.endsWith("/");
690
+ if (!isDirectoryLikeDestination) {
691
+ await this.ensureRemoteParent(remotePath, options.createDirectories);
692
+ await this.assertRemoteOverwrite(remotePath, options.overwrite);
693
+ return remotePath;
694
+ }
695
+ if (remoteKind && remoteKind !== "d") {
696
+ throw new TransferError(`Remote destination already exists and is not a directory: ${remotePath}`, {
697
+ context: { remotePath }
698
+ });
699
+ }
700
+ const remoteDirectory = remotePath.replace(/\/+$/g, "") || "/";
701
+ if (!remoteKind) {
702
+ if (!options.createDirectories) {
703
+ throw new TransferError(`Remote destination directory does not exist: ${remoteDirectory}`, {
704
+ context: { remotePath }
705
+ });
706
+ }
707
+ await this.transport.mkdir(remoteDirectory, true);
708
+ }
709
+ const destinationFile = remoteJoin(
710
+ remoteDirectory,
711
+ path4.basename(resolveLocalPath(options.localPath))
712
+ );
713
+ await this.assertRemoteOverwrite(destinationFile, options.overwrite);
714
+ return destinationFile;
715
+ }
605
716
  async downloadWithTransport(options) {
606
717
  const remotePath = normalizeRemotePath(options.remotePath);
607
718
  const remoteKind = await this.transport.exists(remotePath);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../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/upload.ts","../src/client/download.ts","../src/client/copy.ts"],"sourcesContent":["import { access, mkdir } 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\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 await this.ensureRemoteParent(remotePath, options.createDirectories);\n await this.assertRemoteOverwrite(remotePath, options.overwrite);\n const totalBytes = undefined;\n await this.transport.uploadFile(resolveLocalPath(options.localPath), remotePath, (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\n const destinationExists = await this.transport.exists(remotePath);\n if (destinationExists && destinationExists !== \"d\") {\n throw new TransferError(`Remote destination already exists and is not a directory: ${remotePath}`, {\n context: { remotePath }\n });\n }\n if (!destinationExists) {\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 for (const file of files) {\n const destinationFile = remoteJoin(remotePath, file.relativePath.split(path.sep).join(\"/\"));\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 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 = resolveLocalPath(options.localPath);\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 = resolveLocalPath(options.localPath);\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 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 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 { ConnectionError, HostVerificationError, TransferError, toScpNextError } from \"../errors/index.js\";\nimport { createHostVerifier, resolveAllowedFingerprints } from \"../security/host-verification.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 }\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 converted;\n }\n throw new ConnectionError(\"Unable to connect to SSH server.\", {\n cause: error,\n context: {\n host: options.host,\n port: options.port,\n username: options.username\n }\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}.`, {\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}.`, {\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","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 (lowerMessage.includes(\"host verification\") || lowerMessage.includes(\"host key\")) {\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\nexport function isFingerprintMatch(actual: string, expected: string): boolean {\n return normalizeFingerprint(actual) === normalizeFingerprint(expected);\n}\n\nexport interface HostVerifierConfig {\n host?: string | undefined;\n hostFingerprint?: string | undefined;\n knownHostsFile?: string | undefined;\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 fingerprints.add(normalizeFingerprint(options.hostFingerprint));\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 if (!hosts || !algorithm || !key || !hosts.split(\",\").includes(options.host)) {\n continue;\n }\n\n const fingerprint = createHash(\"sha256\")\n .update(Buffer.from(key, \"base64\"))\n .digest(\"base64\")\n .replace(/=+$/g, \"\");\n fingerprints.add(fingerprint);\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.\"\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 { 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 { 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 { download } from \"./download.js\";\nimport { upload } from \"./upload.js\";\nimport { ValidationError } from \"../errors/index.js\";\nimport type { CopyOptions } from \"../types/index.js\";\n\nexport async function copy(options: CopyOptions): Promise<void> {\n if (options.source.type === \"local\" && options.destination.type === \"remote\") {\n await upload({\n ...options,\n localPath: options.source.path,\n remotePath: options.destination.path\n });\n return;\n }\n\n if (options.source.type === \"remote\" && options.destination.type === \"local\") {\n await download({\n ...options,\n remotePath: options.source.path,\n localPath: options.destination.path\n });\n return;\n }\n\n throw new ValidationError(\"copy() supports only local-to-remote or remote-to-local transfers.\", {\n context: {\n sourceType: options.source.type,\n destinationType: options.destination.type\n }\n });\n}\n"],"mappings":";AAAA,SAAS,UAAAA,SAAQ,SAAAC,cAAa;AAC9B,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,UAAU,UAAU;AAC7B,WAAO,MAAM,QAAQ,qBAAqB,YAAY;AAAA,EACxD;AAEA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,UAAM,WAAsB,MAAM,IAAI,CAAC,SAAkB,sBAAsB,IAAI,CAAC;AACpF,WAAO;AAAA,EACT;AAEA,MAAI,SAAS,OAAO,UAAU,UAAU;AACtC,UAAM,WAAoC,CAAC;AAC3C,eAAW,CAAC,KAAK,WAAW,KAAK,OAAO,QAAQ,KAAK,GAAG;AACtD,eAAS,GAAG,IAAI,e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,OAAO;AAAA,MAC1B,YAAY,QAAQ,YAAY;AAAA,IAClC,CAAC;AACD;AAAA,EACF;AAEA,MAAI,QAAQ,OAAO,SAAS,YAAY,QAAQ,YAAY,SAAS,SAAS;AAC5E,UAAM,SAAS;AAAA,MACb,GAAG;AAAA,MACH,YAAY,QAAQ,OAAO;AAAA,MAC3B,WAAW,QAAQ,YAAY;AAAA,IACjC,CAAC;AACD;AAAA,EACF;AAEA,QAAM,IAAI,gBAAgB,sEAAsE;AAAA,IAC9F,SAAS;AAAA,MACP,YAAY,QAAQ,OAAO;AAAA,MAC3B,iBAAiB,QAAQ,YAAY;AAAA,IACvC;AAAA,EACF,CAAC;AACH;","names":["access","mkdir","path","readFile","access","access","readFile","stat","path","path","path","stat","path","access","access","totalBytes","path","mkdir","access"]}
1
+ {"version":3,"sources":["../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/upload.ts","../src/client/download.ts","../src/client/copy.ts"],"sourcesContent":["import { access, mkdir } 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\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\n const destinationExists = await this.transport.exists(remotePath);\n if (destinationExists && destinationExists !== \"d\") {\n throw new TransferError(`Remote destination already exists and is not a directory: ${remotePath}`, {\n context: { remotePath }\n });\n }\n if (!destinationExists) {\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 for (const file of files) {\n const destinationFile = remoteJoin(remotePath, file.relativePath.split(path.sep).join(\"/\"));\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 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 = resolveLocalPath(options.localPath);\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 = resolveLocalPath(options.localPath);\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 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 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 { 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 { 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 { download } from \"./download.js\";\nimport { upload } from \"./upload.js\";\nimport { ValidationError } from \"../errors/index.js\";\nimport type { CopyOptions } from \"../types/index.js\";\n\nexport async function copy(options: CopyOptions): Promise<void> {\n if (options.source.type === \"local\" && options.destination.type === \"remote\") {\n await upload({\n ...options,\n localPath: options.source.path,\n remotePath: options.destination.path\n });\n return;\n }\n\n if (options.source.type === \"remote\" && options.destination.type === \"local\") {\n await download({\n ...options,\n remotePath: options.source.path,\n localPath: options.destination.path\n });\n return;\n }\n\n throw new ValidationError(\"copy() supports only local-to-remote or remote-to-local transfers.\", {\n context: {\n sourceType: options.source.type,\n destinationType: options.destination.type\n }\n });\n}\n"],"mappings":";AAAA,SAAS,UAAAA,SAAQ,SAAAC,cAAa;AAC9B,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,sB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AQ,OAAO;AAAA,MAC1B,YAAY,QAAQ,YAAY;AAAA,IAClC,CAAC;AACD;AAAA,EACF;AAEA,MAAI,QAAQ,OAAO,SAAS,YAAY,QAAQ,YAAY,SAAS,SAAS;AAC5E,UAAM,SAAS;AAAA,MACb,GAAG;AAAA,MACH,YAAY,QAAQ,OAAO;AAAA,MAC3B,WAAW,QAAQ,YAAY;AAAA,IACjC,CAAC;AACD;AAAA,EACF;AAEA,QAAM,IAAI,gBAAgB,sEAAsE;AAAA,IAC9F,SAAS;AAAA,MACP,YAAY,QAAQ,OAAO;AAAA,MAC3B,iBAAiB,QAAQ,YAAY;AAAA,IACvC;AAAA,EACF,CAAC;AACH;","names":["access","mkdir","path","readFile","access","access","readFile","stat","path","path","path","stat","path","access","access","totalBytes","path","mkdir","access"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scp-next",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "A SCP CLI and library for secure SSH file transfers using SFTP.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",