Documentation Index Fetch the complete documentation index at: https://dylankenneally-react-native-ssh-sftp-96.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Overview
This page documents all exported types and interfaces from the React Native SSH SFTP library. These types provide strong type safety for TypeScript users and define the data structures used throughout the library.
Enums
PtyType
Represents the types of PTY (pseudo-terminal) for SSH connections.
enum PtyType {
VANILLA = 'vanilla' ,
VT100 = 'vt100' ,
VT102 = 'vt102' ,
VT220 = 'vt220' ,
ANSI = 'ansi' ,
XTERM = 'xterm' ,
}
Values:
Value Description VANILLABasic vanilla terminal type VT100VT100 terminal emulation VT102VT102 terminal emulation VT220VT220 terminal emulation ANSIANSI terminal emulation XTERMXTerm terminal emulation
Usage:
import SSHClient , { PtyType } from '@dylankenneally/react-native-ssh-sftp' ;
// Start a shell with VT100 terminal type
await client . startShell ( PtyType . VT100 );
Interfaces
KeyPair
Represents a key pair used for SSH authentication.
interface KeyPair {
privateKey : string ;
publicKey ?: string ;
passphrase ?: string ;
}
Properties:
Property Type Required Description privateKeystringYes The private key in PEM format publicKeystringNo The public key (optional) passphrasestringNo The passphrase for the encrypted private key (optional)
Usage:
const keyPair : KeyPair = {
privateKey: '-----BEGIN RSA PRIVATE KEY----- \n ...' ,
passphrase: 'my-secret-passphrase'
};
await SSHClient . connectWithKey (
'example.com' ,
22 ,
'username' ,
keyPair . privateKey ,
keyPair . passphrase
);
LsResult
Represents the result of a directory listing operation.
interface LsResult {
filename : string ;
isDirectory : boolean ;
modificationDate : string ;
lastAccess : string ;
fileSize : number ;
ownerUserID : number ;
ownerGroupID : number ;
flags : number ;
}
Properties:
Property Type Description filenamestringThe name of the file or directory isDirectorybooleanWhether the item is a directory modificationDatestringThe last modification date lastAccessstringThe last access date fileSizenumberThe size of the file in bytes ownerUserIDnumberThe user ID of the owner ownerGroupIDnumberThe group ID of the owner flagsnumberFile permission flags
Usage:
const files : LsResult [] = await client . sftpLs ( '/home/user' );
files . forEach ( file => {
console . log ( ` ${ file . filename } - ${ file . isDirectory ? 'DIR' : 'FILE' } ` );
console . log ( `Size: ${ file . fileSize } bytes` );
console . log ( `Modified: ${ file . modificationDate } ` );
});
genKeyPair
Represents the result of a key pair generation operation.
interface genKeyPair {
privateKey : string ;
publicKey ?: string ;
}
Properties:
Property Type Required Description privateKeystringYes The generated private key in PEM format publicKeystringNo The generated public key (optional)
Usage:
const keys : genKeyPair = await SSHClient . generateKeyPair (
'rsa' ,
'passphrase' ,
2048 ,
'comment'
);
console . log ( 'Private Key:' , keys . privateKey );
console . log ( 'Public Key:' , keys . publicKey );
keyDetail
Represents the details of an SSH key.
interface keyDetail {
keyType : string ;
keySize ?: number ;
}
Properties:
Property Type Required Description keyTypestringYes The type of the key (e.g., ‘RSA’, ‘DSA’, ‘ECDSA’) keySizenumberNo The size of the key in bits (optional)
Usage:
const details : keyDetail = await SSHClient . getKeyDetails ( privateKey );
console . log ( `Key Type: ${ details . keyType } ` );
console . log ( `Key Size: ${ details . keySize } bits` );
Type Aliases
PasswordOrKey
Represents a password or key for authentication. Can be either a string (password) or a KeyPair object.
type PasswordOrKey = string | KeyPair ;
Usage:
This type is used internally by the SSHClient constructor to accept either password or key-based authentication:
// Using with password (string)
const password : PasswordOrKey = 'my-password' ;
// Using with key (KeyPair)
const key : PasswordOrKey = {
privateKey: '-----BEGIN RSA PRIVATE KEY----- \n ...' ,
passphrase: 'passphrase'
};
CallbackFunction
Represents a callback function with an optional response.
type CallbackFunction < T > = ( error : any , response ?: T ) => void ;
Type Parameters:
Parameter Description TThe type of the response object
Parameters:
Parameter Type Description erroranyThe error object, if any error occurred responseTThe response object, if the operation was successful (optional)
Usage:
// Callback with string response
const callback : CallbackFunction < string > = ( error , response ) => {
if ( error ) {
console . error ( 'Error:' , error );
return ;
}
console . log ( 'Response:' , response );
};
await client . execute ( 'ls -la' , callback );
// Callback with void response
const voidCallback : CallbackFunction < void > = ( error ) => {
if ( error ) {
console . error ( 'Error:' , error );
return ;
}
console . log ( 'Operation completed' );
};
await client . sftpMkdir ( '/home/user/newdir' , voidCallback );
EventHandler
Represents an event handler function for SSH events.
type EventHandler = ( value : any ) => void ;
Parameters:
Parameter Type Description valueanyThe value passed to the event handler
Usage:
// Register shell event handler
const shellHandler : EventHandler = ( data ) => {
console . log ( 'Shell output:' , data );
};
client . on ( 'Shell' , shellHandler );
// Register download progress handler
const downloadHandler : EventHandler = ( progress ) => {
console . log ( 'Download progress:' , progress );
};
client . on ( 'DownloadProgress' , downloadHandler );
// Register upload progress handler
const uploadHandler : EventHandler = ( progress ) => {
console . log ( 'Upload progress:' , progress );
};
client . on ( 'UploadProgress' , uploadHandler );
SSHClient Class Complete API reference for the SSHClient class
Static Methods Static methods for connecting and key generation