mirror of
https://github.com/EthanShoeDev/fressh.git
synced 2026-01-12 23:02:49 +00:00
Good changes
This commit is contained in:
@@ -153,7 +153,7 @@ type RusshApi = {
|
||||
// keySize?: number;
|
||||
// comment?: string;
|
||||
) => Promise<string>;
|
||||
validatePrivateKey: (key: string) => boolean;
|
||||
validatePrivateKey: (key: string) => { valid: true; error?: never } | { valid: false; error: GeneratedRussh.SshError };
|
||||
};
|
||||
|
||||
// #endregion
|
||||
@@ -196,6 +196,8 @@ const streamEnumToLiteral = {
|
||||
[GeneratedRussh.StreamKind.Stderr]: 'stderr',
|
||||
} as const satisfies Record<GeneratedRussh.StreamKind, StreamKind>;
|
||||
|
||||
|
||||
|
||||
function generatedConnDetailsToIdeal(
|
||||
details: GeneratedRussh.ConnectionDetails
|
||||
): ConnectionDetails {
|
||||
@@ -379,17 +381,19 @@ async function generateKeyPair(type: 'rsa' | 'ecdsa' | 'ed25519') {
|
||||
return GeneratedRussh.generateKeyPair(map[type]);
|
||||
}
|
||||
|
||||
function validatePrivateKey(key: string) {
|
||||
function validatePrivateKey(key: string): { valid: true; error?: never } | { valid: false; error: GeneratedRussh.SshError } {
|
||||
try {
|
||||
GeneratedRussh.validatePrivateKey(key);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
return { valid: true };
|
||||
} catch (e) {
|
||||
return { valid: false, error: e as GeneratedRussh.SshError };
|
||||
}
|
||||
}
|
||||
|
||||
// #endregion
|
||||
|
||||
export { SshError, SshError_Tags } from './generated/uniffi_russh';
|
||||
|
||||
export const RnRussh = {
|
||||
uniffiInitAsync: GeneratedRussh.uniffiInitAsync,
|
||||
connect,
|
||||
|
||||
Reference in New Issue
Block a user