UNPKG

fs-tunnel

Version:

Modern SSH/SFTP file system client for Node.js - provides seamless remote file operations with a clean Promise-based API. Supports secure file transfers, directory management, and streaming for large files.

45 lines (44 loc) 1.29 kB
import { OpenMode } from 'ssh2'; import { Readable, Writable } from 'stream'; export interface SSHConfiguration { host: string; port: number; username?: string; password?: string; } export interface FileInfo { name: string; isDirectory: boolean; size: number; mtime: Date; mode: number; } export interface StatInfo { isDirectory: boolean; size: number; mtime: Date; mode: number; } export declare class SSHFileSystem { private connection; private sftp; private connected; private credentials; constructor(credentials: SSHConfiguration); connect(): Promise<void>; connectWithCredentials(username: string, password: string): Promise<void>; private connectInternal; ensureConnection(): Promise<void>; readdir(remotePath: string): Promise<FileInfo[]>; stat(remotePath: string): Promise<StatInfo>; mkdir(remotePath: string): Promise<void>; rmdir(remotePath: string): Promise<void>; unlink(remotePath: string): Promise<void>; createReadStream(remotePath: string): Readable; createWriteStream(remotePath: string, options?: { flags?: OpenMode; start?: number; }): Writable; rename(oldPath: string, newPath: string): Promise<void>; disconnect(): void; }