scp-next 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -26
- package/dist/cli/index.js +120 -19
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +119 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +120 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -621,6 +621,38 @@ function percentage(transferredBytes, totalBytes) {
|
|
|
621
621
|
function mergeOptions(serverOptions, transferOptions) {
|
|
622
622
|
return { ...serverOptions, ...transferOptions ?? {} };
|
|
623
623
|
}
|
|
624
|
+
function hasTrailingPathSeparator(inputPath) {
|
|
625
|
+
return /[\\/]$/.test(inputPath);
|
|
626
|
+
}
|
|
627
|
+
function trimmedRemoteDirectory(remotePath) {
|
|
628
|
+
return remotePath.replace(/\/+$/g, "") || "/";
|
|
629
|
+
}
|
|
630
|
+
function remoteBasename(remotePath) {
|
|
631
|
+
return import_node_path4.default.posix.basename(trimmedRemoteDirectory(remotePath));
|
|
632
|
+
}
|
|
633
|
+
async function isExistingLocalDirectory(localPath) {
|
|
634
|
+
try {
|
|
635
|
+
return (await (0, import_promises6.stat)(localPath)).isDirectory();
|
|
636
|
+
} catch {
|
|
637
|
+
return false;
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
async function ensureLocalDirectory(localPath, createParents = false) {
|
|
641
|
+
try {
|
|
642
|
+
const stats = await (0, import_promises6.stat)(localPath);
|
|
643
|
+
if (stats.isDirectory()) {
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
throw new TransferError(`Local destination already exists and is not a directory: ${localPath}`, {
|
|
647
|
+
context: { localPath }
|
|
648
|
+
});
|
|
649
|
+
} catch (error) {
|
|
650
|
+
if (error instanceof TransferError) {
|
|
651
|
+
throw error;
|
|
652
|
+
}
|
|
653
|
+
await (0, import_promises6.mkdir)(localPath, { recursive: createParents });
|
|
654
|
+
}
|
|
655
|
+
}
|
|
624
656
|
var ScpNextClientImpl = class {
|
|
625
657
|
serverOptions;
|
|
626
658
|
transport;
|
|
@@ -697,22 +729,15 @@ var ScpNextClientImpl = class {
|
|
|
697
729
|
const totalBytes = files.reduce((sum, file) => sum + file.size, 0);
|
|
698
730
|
let completedBytes = 0;
|
|
699
731
|
let completedFiles = 0;
|
|
700
|
-
const
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
});
|
|
705
|
-
}
|
|
706
|
-
if (!destinationExists) {
|
|
707
|
-
if (!options.createDirectories) {
|
|
708
|
-
throw new TransferError(`Remote destination directory does not exist: ${remotePath}`, {
|
|
709
|
-
context: { remotePath }
|
|
710
|
-
});
|
|
711
|
-
}
|
|
712
|
-
await this.transport.mkdir(remotePath, true);
|
|
713
|
-
}
|
|
732
|
+
const destinationRoot = await this.resolveRemoteDestinationForLocalDirectory(
|
|
733
|
+
options,
|
|
734
|
+
remotePath
|
|
735
|
+
);
|
|
714
736
|
for (const file of files) {
|
|
715
|
-
const destinationFile = remoteJoin(
|
|
737
|
+
const destinationFile = remoteJoin(
|
|
738
|
+
destinationRoot,
|
|
739
|
+
file.relativePath.split(import_node_path4.default.sep).join("/")
|
|
740
|
+
);
|
|
716
741
|
await this.ensureRemoteParent(destinationFile, true);
|
|
717
742
|
await this.assertRemoteOverwrite(destinationFile, options.overwrite);
|
|
718
743
|
await this.transport.uploadFile(file.absolutePath, destinationFile, (step) => {
|
|
@@ -762,6 +787,39 @@ var ScpNextClientImpl = class {
|
|
|
762
787
|
await this.assertRemoteOverwrite(destinationFile, options.overwrite);
|
|
763
788
|
return destinationFile;
|
|
764
789
|
}
|
|
790
|
+
async resolveRemoteDestinationForLocalDirectory(options, remotePath) {
|
|
791
|
+
const remoteKind = await this.transport.exists(remotePath);
|
|
792
|
+
const isDirectoryLikeDestination = remoteKind === "d" || remotePath.endsWith("/");
|
|
793
|
+
const localDirectoryName = import_node_path4.default.basename(resolveLocalPath(options.localPath));
|
|
794
|
+
if (remoteKind && remoteKind !== "d") {
|
|
795
|
+
throw new TransferError(`Remote destination already exists and is not a directory: ${remotePath}`, {
|
|
796
|
+
context: { remotePath }
|
|
797
|
+
});
|
|
798
|
+
}
|
|
799
|
+
if (isDirectoryLikeDestination) {
|
|
800
|
+
const remoteDirectory = trimmedRemoteDirectory(remotePath);
|
|
801
|
+
if (!remoteKind) {
|
|
802
|
+
if (!options.createDirectories) {
|
|
803
|
+
throw new TransferError(`Remote destination directory does not exist: ${remoteDirectory}`, {
|
|
804
|
+
context: { remotePath }
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
await this.transport.mkdir(remoteDirectory, true);
|
|
808
|
+
}
|
|
809
|
+
const destinationRoot = remoteJoin(remoteDirectory, localDirectoryName);
|
|
810
|
+
await this.ensureRemoteDirectory(destinationRoot);
|
|
811
|
+
return destinationRoot;
|
|
812
|
+
}
|
|
813
|
+
if (!remoteKind) {
|
|
814
|
+
if (!options.createDirectories) {
|
|
815
|
+
throw new TransferError(`Remote destination directory does not exist: ${remotePath}`, {
|
|
816
|
+
context: { remotePath }
|
|
817
|
+
});
|
|
818
|
+
}
|
|
819
|
+
await this.transport.mkdir(remotePath, true);
|
|
820
|
+
}
|
|
821
|
+
return remotePath;
|
|
822
|
+
}
|
|
765
823
|
async downloadWithTransport(options) {
|
|
766
824
|
const remotePath = normalizeRemotePath(options.remotePath);
|
|
767
825
|
const remoteKind = await this.transport.exists(remotePath);
|
|
@@ -780,7 +838,7 @@ var ScpNextClientImpl = class {
|
|
|
780
838
|
await this.downloadSingleFile(options, remotePath);
|
|
781
839
|
}
|
|
782
840
|
async downloadSingleFile(options, remotePath) {
|
|
783
|
-
const localPath =
|
|
841
|
+
const localPath = await this.resolveLocalDestinationForRemoteFile(options, remotePath);
|
|
784
842
|
await this.assertLocalOverwrite(localPath, options.overwrite);
|
|
785
843
|
if (options.createDirectories) {
|
|
786
844
|
await (0, import_promises6.mkdir)(import_node_path4.default.dirname(localPath), { recursive: true });
|
|
@@ -799,12 +857,12 @@ var ScpNextClientImpl = class {
|
|
|
799
857
|
}
|
|
800
858
|
async downloadDirectory(options) {
|
|
801
859
|
const remotePath = normalizeRemotePath(options.remotePath);
|
|
802
|
-
const localRoot =
|
|
860
|
+
const localRoot = await this.resolveLocalDestinationForRemoteDirectory(options, remotePath);
|
|
803
861
|
const files = await walkRemoteFiles(this.transport, remotePath);
|
|
804
862
|
const totalBytes = files.reduce((sum, file) => sum + file.size, 0);
|
|
805
863
|
let completedBytes = 0;
|
|
806
864
|
let completedFiles = 0;
|
|
807
|
-
await (
|
|
865
|
+
await ensureLocalDirectory(localRoot, Boolean(options.createDirectories));
|
|
808
866
|
for (const file of files) {
|
|
809
867
|
const localFile = import_node_path4.default.join(localRoot, ...file.relativePath.split("/"));
|
|
810
868
|
await this.assertLocalOverwrite(localFile, options.overwrite);
|
|
@@ -827,6 +885,38 @@ var ScpNextClientImpl = class {
|
|
|
827
885
|
completedFiles += 1;
|
|
828
886
|
}
|
|
829
887
|
}
|
|
888
|
+
async resolveLocalDestinationForRemoteFile(options, remotePath) {
|
|
889
|
+
const localDestination = resolveLocalPath(options.localPath);
|
|
890
|
+
const isDirectoryLikeDestination = hasTrailingPathSeparator(options.localPath) || await isExistingLocalDirectory(localDestination);
|
|
891
|
+
if (!isDirectoryLikeDestination) {
|
|
892
|
+
return localDestination;
|
|
893
|
+
}
|
|
894
|
+
if (!await isExistingLocalDirectory(localDestination)) {
|
|
895
|
+
if (!options.createDirectories) {
|
|
896
|
+
throw new TransferError(`Local destination directory does not exist: ${localDestination}`, {
|
|
897
|
+
context: { localPath: options.localPath }
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
await (0, import_promises6.mkdir)(localDestination, { recursive: true });
|
|
901
|
+
}
|
|
902
|
+
return import_node_path4.default.join(localDestination, remoteBasename(remotePath));
|
|
903
|
+
}
|
|
904
|
+
async resolveLocalDestinationForRemoteDirectory(options, remotePath) {
|
|
905
|
+
const localDestination = resolveLocalPath(options.localPath);
|
|
906
|
+
const isDirectoryLikeDestination = hasTrailingPathSeparator(options.localPath) || await isExistingLocalDirectory(localDestination);
|
|
907
|
+
if (!isDirectoryLikeDestination) {
|
|
908
|
+
return localDestination;
|
|
909
|
+
}
|
|
910
|
+
if (!await isExistingLocalDirectory(localDestination)) {
|
|
911
|
+
if (!options.createDirectories) {
|
|
912
|
+
throw new TransferError(`Local destination directory does not exist: ${localDestination}`, {
|
|
913
|
+
context: { localPath: options.localPath }
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
await (0, import_promises6.mkdir)(localDestination, { recursive: true });
|
|
917
|
+
}
|
|
918
|
+
return import_node_path4.default.join(localDestination, remoteBasename(remotePath));
|
|
919
|
+
}
|
|
830
920
|
async ensureRemoteParent(remotePath, createDirectories = false) {
|
|
831
921
|
const parent = remoteDirname(remotePath);
|
|
832
922
|
if (parent === "." || parent === "/") {
|
|
@@ -843,6 +933,17 @@ var ScpNextClientImpl = class {
|
|
|
843
933
|
});
|
|
844
934
|
}
|
|
845
935
|
}
|
|
936
|
+
async ensureRemoteDirectory(remotePath) {
|
|
937
|
+
const exists = await this.transport.exists(remotePath);
|
|
938
|
+
if (exists && exists !== "d") {
|
|
939
|
+
throw new TransferError(`Remote destination already exists and is not a directory: ${remotePath}`, {
|
|
940
|
+
context: { remotePath }
|
|
941
|
+
});
|
|
942
|
+
}
|
|
943
|
+
if (!exists) {
|
|
944
|
+
await this.transport.mkdir(remotePath, true);
|
|
945
|
+
}
|
|
946
|
+
}
|
|
846
947
|
async assertRemoteOverwrite(remotePath, overwrite = false) {
|
|
847
948
|
if (overwrite) {
|
|
848
949
|
return;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/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/upload.ts","../src/client/download.ts","../src/client/copy.ts"],"sourcesContent":["export { createClient, ScpNextClientImpl } from \"./client/client.js\";\nexport { upload } from \"./client/upload.js\";\nexport { download } from \"./client/download.js\";\nexport { copy } from \"./client/copy.js\";\nexport * from \"./types/index.js\";\nexport * from \"./errors/index.js\";\n","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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,mBAA8B;AAC9B,IAAAC,oBAAiB;;;ACDjB,IAAAC,mBAAyB;AAEzB,8BAAuB;;;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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,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":["import_promises","import_node_path","import_promises","import_promises","os","path","path","SftpClient","import_promises","import_node_path","import_node_path","path","path","import_promises","totalBytes","path"]}
|
|
1
|
+
{"version":3,"sources":["../src/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/upload.ts","../src/client/download.ts","../src/client/copy.ts"],"sourcesContent":["export { createClient, ScpNextClientImpl } from \"./client/client.js\";\nexport { upload } from \"./client/upload.js\";\nexport { download } from \"./client/download.js\";\nexport { copy } from \"./client/copy.js\";\nexport * from \"./types/index.js\";\nexport * from \"./errors/index.js\";\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\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, 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 ensureLocalDirectory(localRoot, 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 { 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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,mBAAoC;AACpC,IAAAC,oBAAiB;;;ACDjB,IAAAC,mBAAyB;AAEzB,8BAAuB;;;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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E,UAAM,OAAO;AAAA,MACX,GAAG;AAAA,MACH,WAAW,QAAQ,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":["import_promises","import_node_path","import_promises","import_promises","os","path","path","SftpClient","import_promises","import_node_path","import_node_path","path","path","import_promises","path","totalBytes"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -129,10 +129,14 @@ declare class ScpNextClientImpl implements ScpNextClient {
|
|
|
129
129
|
private ensureConnected;
|
|
130
130
|
private uploadWithTransport;
|
|
131
131
|
private resolveRemoteDestinationForLocalFile;
|
|
132
|
+
private resolveRemoteDestinationForLocalDirectory;
|
|
132
133
|
private downloadWithTransport;
|
|
133
134
|
private downloadSingleFile;
|
|
134
135
|
private downloadDirectory;
|
|
136
|
+
private resolveLocalDestinationForRemoteFile;
|
|
137
|
+
private resolveLocalDestinationForRemoteDirectory;
|
|
135
138
|
private ensureRemoteParent;
|
|
139
|
+
private ensureRemoteDirectory;
|
|
136
140
|
private assertRemoteOverwrite;
|
|
137
141
|
private assertLocalOverwrite;
|
|
138
142
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -129,10 +129,14 @@ declare class ScpNextClientImpl implements ScpNextClient {
|
|
|
129
129
|
private ensureConnected;
|
|
130
130
|
private uploadWithTransport;
|
|
131
131
|
private resolveRemoteDestinationForLocalFile;
|
|
132
|
+
private resolveRemoteDestinationForLocalDirectory;
|
|
132
133
|
private downloadWithTransport;
|
|
133
134
|
private downloadSingleFile;
|
|
134
135
|
private downloadDirectory;
|
|
136
|
+
private resolveLocalDestinationForRemoteFile;
|
|
137
|
+
private resolveLocalDestinationForRemoteDirectory;
|
|
135
138
|
private ensureRemoteParent;
|
|
139
|
+
private ensureRemoteDirectory;
|
|
136
140
|
private assertRemoteOverwrite;
|
|
137
141
|
private assertLocalOverwrite;
|
|
138
142
|
}
|