pure-js-sftp
Version:
A pure JavaScript SFTP client with revolutionary RSA-SHA2 compatibility fixes. Zero native dependencies, built on ssh2-streams with 100% SSH key support.
40 lines • 1.98 kB
TypeScript
/**
* Pure JavaScript RSA-SHA2 Signature Wrapper using sshpk only
* Eliminates all Node.js crypto dependencies for maximum VSCode/webpack compatibility
*/
export interface WrappedRSAKey {
type: string;
getPublicSSH(): Buffer;
sign(data: Buffer): Buffer;
verify(data: Buffer, signature: Buffer): boolean;
}
/**
* Wraps an ssh2-streams RSA key to use RSA-SHA2 signatures via sshpk
* @param originalKey - The original ssh2-streams key object
* @param privateKeyPEM - The raw private key in PEM format
* @param algorithm - RSA signature algorithm ('sha256' or 'sha512')
* @returns Wrapped key object with RSA-SHA2 signatures
*/
export declare function wrapRSAKeyWithSHA2(originalKey: any, privateKeyPEM: string, algorithm?: 'sha256' | 'sha512'): WrappedRSAKey;
/**
* Creates an RSA-SHA2 signature callback for ssh2-streams authentication using sshpk only
* @param originalKey - The original ssh2-streams key object
* @param privateKeyPEM - The raw private key in PEM format
* @param passphrase - Optional passphrase for encrypted keys
* @param algorithm - RSA signature algorithm ('sha256' or 'sha512')
* @returns Signature callback function for ssh2-streams authPK
*/
export declare function createRSASHA2SignatureCallback(originalKey: any, privateKeyPEM: string, passphrase?: string, algorithm?: 'sha256' | 'sha512'): (buf: Buffer, cb: (signature: Buffer) => void) => void;
/**
* Determines if a key should use the RSA-SHA2 wrapper
* @param keyType - The SSH key type (e.g., 'ssh-rsa', 'ssh-ed25519')
* @returns True if the key should be wrapped for RSA-SHA2
*/
export declare function shouldUseRSASHA2Wrapper(keyType: string): boolean;
/**
* Gets the appropriate RSA-SHA2 algorithm based on key size
* @param keySize - RSA key size in bits
* @returns Recommended algorithm ('sha256' or 'sha512')
*/
export declare function getRecommendedRSASHA2Algorithm(keySize: number): 'sha256' | 'sha512';
//# sourceMappingURL=rsa-sha2-wrapper.d.ts.map