1 |
|
2 |
|
3 | import { EventEmitter } from "events";
|
4 | import { Agent as BaseHTTPAgent, AgentOptions as BaseHTTPAgentOptions } from "http";
|
5 | import { Agent as BaseHTTPSAgent, AgentOptions as BaseHTTPSAgentOptions } from "https";
|
6 | import { Server as NetServer, Socket } from "net";
|
7 | import { Duplex, Readable, ReadableOptions, Writable, WritableOptions } from "stream";
|
8 |
|
9 | export interface Prompt {
|
10 | prompt: string;
|
11 | echo?: boolean;
|
12 | }
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | export type KexAlgorithm =
|
18 | | "curve25519-sha256"
|
19 | | "curve25519-sha256@libssh.org"
|
20 | | "ecdh-sha2-nistp256"
|
21 | | "ecdh-sha2-nistp384"
|
22 | | "ecdh-sha2-nistp521"
|
23 | | "diffie-hellman-group-exchange-sha256"
|
24 | | "diffie-hellman-group14-sha256"
|
25 | | "diffie-hellman-group15-sha512"
|
26 | | "diffie-hellman-group16-sha512"
|
27 | | "diffie-hellman-group17-sha512"
|
28 | | "diffie-hellman-group18-sha512"
|
29 | | "diffie-hellman-group-exchange-sha1"
|
30 | | "diffie-hellman-group14-sha1"
|
31 | | "diffie-hellman-group1-sha1";
|
32 |
|
33 | export type ServerHostKeyAlgorithm =
|
34 | | "ssh-ed25519"
|
35 | | "ecdsa-sha2-nistp256"
|
36 | | "ecdsa-sha2-nistp384"
|
37 | | "ecdsa-sha2-nistp521"
|
38 | | "rsa-sha2-512"
|
39 | | "rsa-sha2-256"
|
40 | | "ssh-rsa"
|
41 | | "ssh-dss";
|
42 |
|
43 | export type CompressionAlgorithm = "none" | "zlib" | "zlib@openssh.com";
|
44 |
|
45 | export type CipherAlgorithm =
|
46 | | "chacha20-poly1305@openssh.com"
|
47 | | "aes128-gcm"
|
48 | | "aes128-gcm@openssh.com"
|
49 | | "aes256-gcm"
|
50 | | "aes256-gcm@openssh.com"
|
51 | | "aes128-ctr"
|
52 | | "aes192-ctr"
|
53 | | "aes256-ctr"
|
54 | | "aes256-cbc"
|
55 | | "aes192-cbc"
|
56 | | "aes128-cbc"
|
57 | | "blowfish-cbc"
|
58 | | "3des-cbc"
|
59 | | "arcfour256"
|
60 | | "arcfour128"
|
61 | | "cast128-cbc"
|
62 | | "arcfour";
|
63 |
|
64 | export type MacAlgorithm =
|
65 | | "hmac-sha2-256-etm@openssh.com"
|
66 | | "hmac-sha2-512-etm@openssh.com"
|
67 | | "hmac-sha1-etm@openssh.com"
|
68 | | "hmac-sha2-256"
|
69 | | "hmac-sha2-512"
|
70 | | "hmac-sha1"
|
71 | | "hmac-md5"
|
72 | | "hmac-sha2-256-96"
|
73 | | "hmac-sha2-512-96"
|
74 | | "hmac-ripemd160"
|
75 | | "hmac-sha1-96"
|
76 | | "hmac-md5-96";
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 | export type AlgorithmList<T> = T[] | Record<"append" | "prepend" | "remove", T | T[]>;
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 | export interface Algorithms {
|
90 | kex?: AlgorithmList<KexAlgorithm>;
|
91 | cipher?: AlgorithmList<CipherAlgorithm>;
|
92 | serverHostKey?: AlgorithmList<ServerHostKeyAlgorithm>;
|
93 | hmac?: AlgorithmList<MacAlgorithm>;
|
94 | compress?: AlgorithmList<CompressionAlgorithm>;
|
95 | }
|
96 |
|
97 | export type KeyType =
|
98 | | "ssh-rsa"
|
99 | | "ssh-dss"
|
100 | | "ssh-ed25519"
|
101 | | "ecdsa-sha2-nistp256"
|
102 | | "ecdsa-sha2-nistp384"
|
103 | | "ecdsa-sha2-nistp521";
|
104 |
|
105 | export interface ParsedKey {
|
106 | type: KeyType;
|
107 | comment: string;
|
108 | sign(data: Buffer | string, algo?: string): Buffer;
|
109 | verify(data: Buffer | string, signature: Buffer, algo?: string): boolean;
|
110 | isPrivateKey(): boolean;
|
111 | getPrivatePEM(): string;
|
112 | getPublicPEM(): string;
|
113 | getPublicSSH(): Buffer;
|
114 | equals(key: Buffer | string | ParsedKey): boolean;
|
115 | }
|
116 |
|
117 | export interface Versions {
|
118 | |
119 |
|
120 |
|
121 | protocol: string;
|
122 |
|
123 | |
124 |
|
125 |
|
126 | software: string;
|
127 | }
|
128 |
|
129 | export interface Header {
|
130 | |
131 |
|
132 |
|
133 | identRaw: string;
|
134 |
|
135 | |
136 |
|
137 |
|
138 | versions: Versions;
|
139 |
|
140 | |
141 |
|
142 |
|
143 | comments: string;
|
144 |
|
145 | |
146 |
|
147 |
|
148 | greeting?: string;
|
149 | }
|
150 |
|
151 | export type OpenMode = "r" | "r+" | "w" | "wx" | "xw" | "w+" | "xw+" | "a" | "ax" | "xa" | "a+" | "ax+" | "xa+";
|
152 |
|
153 | export namespace utils {
|
154 | interface KeySettings {
|
155 | rsa: {
|
156 | bits: number;
|
157 | };
|
158 | ecdsa: {
|
159 | bits: 256 | 384 | 521;
|
160 | };
|
161 | ed25519: {};
|
162 | }
|
163 |
|
164 | type KeyPairOptions =
|
165 | & {
|
166 | comment?: string;
|
167 | |
168 |
|
169 |
|
170 |
|
171 |
|
172 | format?: "new";
|
173 | }
|
174 | & ({
|
175 | passphrase: string | Buffer;
|
176 | cipher: string;
|
177 | rounds: number;
|
178 | } | {});
|
179 |
|
180 | type KeyType = keyof KeySettings;
|
181 |
|
182 |
|
183 | type OptionalKeyType = {
|
184 | [K in keyof KeySettings]: {} extends KeySettings[K] ? K : never;
|
185 | }[keyof KeySettings];
|
186 |
|
187 | interface KeyPairReturn {
|
188 | private: string;
|
189 | public: string;
|
190 | }
|
191 |
|
192 | function parseKey(data: Buffer | string | ParsedKey, passphrase?: Buffer | string): ParsedKey | Error;
|
193 |
|
194 | function generateKeyPair<K extends KeyType>(
|
195 | keyType: K,
|
196 | opts: KeySettings[K] & KeyPairOptions,
|
197 | cb?: (err: Error | null, keyPair: KeyPairReturn) => void,
|
198 | ): void;
|
199 | function generateKeyPair<K extends OptionalKeyType>(
|
200 | keyType: K,
|
201 | opts?: KeySettings[K] & KeyPairOptions,
|
202 | cb?: (err: Error | null, keyPair: KeyPairReturn) => void,
|
203 | ): void;
|
204 | function generateKeyPair(keyType: KeyType, cb: (err: Error | null, keyPair: KeyPairReturn) => void): void;
|
205 |
|
206 | function generateKeyPairSync<K extends KeyType>(keyType: K, opts: KeySettings[K] & KeyPairOptions): KeyPairReturn;
|
207 | function generateKeyPairSync<K extends OptionalKeyType>(
|
208 | keyType: K,
|
209 | opts?: KeySettings[K] & KeyPairOptions,
|
210 | ): KeyPairReturn;
|
211 | namespace sftp {
|
212 | enum OPEN_MODE {
|
213 | READ = 0x00000001,
|
214 | WRITE = 0x00000002,
|
215 | APPEND = 0x00000004,
|
216 | CREAT = 0x00000008,
|
217 | TRUNC = 0x00000010,
|
218 | EXCL = 0x00000020,
|
219 | }
|
220 |
|
221 | enum STATUS_CODE {
|
222 | OK = 0,
|
223 | EOF = 1,
|
224 | NO_SUCH_FILE = 2,
|
225 | PERMISSION_DENIED = 3,
|
226 | FAILURE = 4,
|
227 | BAD_MESSAGE = 5,
|
228 | NO_CONNECTION = 6,
|
229 | CONNECTION_LOST = 7,
|
230 | OP_UNSUPPORTED = 8,
|
231 | }
|
232 |
|
233 | function stringToFlags(str: OpenMode): number | null;
|
234 | function flagsToString(flags: number): OpenMode | null;
|
235 | }
|
236 | }
|
237 |
|
238 | export type ChannelType = "session" | "sftp" | "direct-tcpip" | "direct-streamlocal@openssh.com";
|
239 |
|
240 | export type ChannelSubType = "exec" | "shell";
|
241 |
|
242 | export interface Channel extends Duplex {
|
243 |
|
244 | stdin: this;
|
245 |
|
246 | stdout: this;
|
247 |
|
248 | stderr: Writable | Readable;
|
249 |
|
250 | server: boolean;
|
251 |
|
252 | type: ChannelType;
|
253 |
|
254 | subtype?: ChannelSubType;
|
255 | incoming: unknown;
|
256 | outgoing: unknown;
|
257 |
|
258 | |
259 |
|
260 |
|
261 | eof(): void;
|
262 |
|
263 | |
264 |
|
265 |
|
266 | close(...args: any[]): void;
|
267 |
|
268 | |
269 |
|
270 |
|
271 | destroy(): this;
|
272 |
|
273 | |
274 |
|
275 |
|
276 | setWindow(rows: number, cols: number, height: number, width: number): void;
|
277 | signal(signalName: string): void;
|
278 | exit(status: number): void;
|
279 | exit(signalName: string, coreDumped?: boolean, msg?: string): void;
|
280 |
|
281 | |
282 |
|
283 |
|
284 | on(event: "close", listener: () => void): this;
|
285 | on(event: "eof", listener: () => void): this;
|
286 | on(event: "end", listener: () => void): this;
|
287 | on(event: string | symbol, listener: Function): this;
|
288 | once(event: "close", listener: () => void): this;
|
289 | once(event: "eof", listener: () => void): this;
|
290 | once(event: "end", listener: () => void): this;
|
291 | once(event: string | symbol, listener: Function): this;
|
292 | }
|
293 |
|
294 | export interface ClientChannel extends Channel {
|
295 |
|
296 | stderr: Readable;
|
297 |
|
298 | server: false;
|
299 |
|
300 | |
301 |
|
302 |
|
303 |
|
304 |
|
305 | on(event: "exit", listener: (code: number) => void): this;
|
306 | on(event: "exit", listener: (code: null, signal: string, dump: string, desc: string) => void): this;
|
307 | on(event: string | symbol, listener: Function): this;
|
308 | once(event: "exit", listener: (code: number) => void): this;
|
309 | once(event: "exit", listener: (code: null, signal: string, dump: string, desc: string) => void): this;
|
310 | once(event: string | symbol, listener: Function): this;
|
311 | }
|
312 |
|
313 | export interface ServerChannel extends Channel {
|
314 |
|
315 | stderr: Writable;
|
316 |
|
317 | server: true;
|
318 | }
|
319 |
|
320 | export type AcceptConnection<T extends Channel = Channel> = () => T;
|
321 | export type AcceptSftpConnection = () => SFTPWrapper;
|
322 | export type RejectConnection = () => void;
|
323 |
|
324 | export class Client extends EventEmitter {
|
325 |
|
326 |
|
327 | |
328 |
|
329 |
|
330 | on(event: "banner", listener: (message: string) => void): this;
|
331 |
|
332 | |
333 |
|
334 |
|
335 | on(event: "ready", listener: () => void): this;
|
336 |
|
337 | |
338 |
|
339 |
|
340 |
|
341 |
|
342 |
|
343 | on(
|
344 | event: "tcp connection",
|
345 | listener: (
|
346 | details: TcpConnectionDetails,
|
347 | accept: AcceptConnection<ClientChannel>,
|
348 | reject: RejectConnection,
|
349 | ) => void,
|
350 | ): this;
|
351 |
|
352 | |
353 |
|
354 |
|
355 |
|
356 |
|
357 |
|
358 | on(
|
359 | event: "x11",
|
360 | listener: (details: X11Details, accept: AcceptConnection<ClientChannel>, reject: RejectConnection) => void,
|
361 | ): this;
|
362 |
|
363 | |
364 |
|
365 |
|
366 |
|
367 |
|
368 |
|
369 |
|
370 |
|
371 |
|
372 |
|
373 |
|
374 |
|
375 | on(
|
376 | event: "keyboard-interactive",
|
377 | listener: (
|
378 | name: string,
|
379 | instructions: string,
|
380 | lang: string,
|
381 | prompts: Prompt[],
|
382 | finish: KeyboardInteractiveCallback,
|
383 | ) => void,
|
384 | ): this;
|
385 |
|
386 | |
387 |
|
388 |
|
389 |
|
390 |
|
391 |
|
392 | on(event: "change password", listener: (message: string, done: ChangePasswordCallback) => void): this;
|
393 |
|
394 | |
395 |
|
396 |
|
397 | on(event: "error", listener: (err: Error & ClientErrorExtensions) => void): this;
|
398 |
|
399 | |
400 |
|
401 |
|
402 | on(event: "end", listener: () => void): this;
|
403 |
|
404 | |
405 |
|
406 |
|
407 | on(event: "close", listener: () => void): this;
|
408 |
|
409 | |
410 |
|
411 |
|
412 | on(event: "timeout", listener: () => void): this;
|
413 |
|
414 | |
415 |
|
416 |
|
417 | on(event: "connect", listener: () => void): this;
|
418 |
|
419 | |
420 |
|
421 |
|
422 | on(event: "greeting", listener: (greeting: string) => void): this;
|
423 |
|
424 | |
425 |
|
426 |
|
427 | on(event: "handshake", listener: (negotiated: NegotiatedAlgorithms) => void): this;
|
428 |
|
429 | |
430 |
|
431 |
|
432 | on(event: "hostkeys", listener: (keys: ParsedKey[]) => void): this;
|
433 |
|
434 | |
435 |
|
436 |
|
437 | on(
|
438 | event: "unix connection",
|
439 | listener: (info: UNIXConnectionDetails, accept: AcceptConnection, reject: RejectConnection) => void,
|
440 | ): this;
|
441 |
|
442 | |
443 |
|
444 |
|
445 | once(event: "banner", listener: (message: string) => void): this;
|
446 |
|
447 | |
448 |
|
449 |
|
450 | once(event: "ready", listener: () => void): this;
|
451 |
|
452 | |
453 |
|
454 |
|
455 |
|
456 |
|
457 |
|
458 | once(
|
459 | event: "tcp connection",
|
460 | listener: (
|
461 | details: TcpConnectionDetails,
|
462 | accept: AcceptConnection<ClientChannel>,
|
463 | reject: RejectConnection,
|
464 | ) => void,
|
465 | ): this;
|
466 |
|
467 | |
468 |
|
469 |
|
470 |
|
471 |
|
472 |
|
473 | once(
|
474 | event: "x11",
|
475 | listener: (details: X11Details, accept: AcceptConnection<ClientChannel>, reject: RejectConnection) => void,
|
476 | ): this;
|
477 |
|
478 | |
479 |
|
480 |
|
481 |
|
482 |
|
483 |
|
484 |
|
485 |
|
486 |
|
487 |
|
488 |
|
489 |
|
490 | once(
|
491 | event: "keyboard-interactive",
|
492 | listener: (
|
493 | name: string,
|
494 | instructions: string,
|
495 | lang: string,
|
496 | prompts: Prompt[],
|
497 | finish: KeyboardInteractiveCallback,
|
498 | ) => void,
|
499 | ): this;
|
500 |
|
501 | |
502 |
|
503 |
|
504 |
|
505 |
|
506 |
|
507 | once(event: "change password", listener: (message: string, done: ChangePasswordCallback) => void): this;
|
508 |
|
509 | |
510 |
|
511 |
|
512 | once(event: "error", listener: (err: Error & ClientErrorExtensions) => void): this;
|
513 |
|
514 | |
515 |
|
516 |
|
517 | once(event: "end", listener: () => void): this;
|
518 |
|
519 | |
520 |
|
521 |
|
522 | once(event: "close", listener: () => void): this;
|
523 |
|
524 | |
525 |
|
526 |
|
527 | once(event: "timeout", listener: () => void): this;
|
528 |
|
529 | |
530 |
|
531 |
|
532 | once(event: "connect", listener: () => void): this;
|
533 |
|
534 | |
535 |
|
536 |
|
537 | once(event: "greeting", listener: (greeting: string) => void): this;
|
538 |
|
539 | |
540 |
|
541 |
|
542 | once(event: "handshake", listener: (negotiated: NegotiatedAlgorithms) => void): this;
|
543 |
|
544 | |
545 |
|
546 |
|
547 | once(event: "hostkeys", listener: (keys: ParsedKey[]) => void): this;
|
548 |
|
549 | |
550 |
|
551 |
|
552 | once(
|
553 | event: "unix connection",
|
554 | listener: (info: UNIXConnectionDetails, accept: AcceptConnection, reject: RejectConnection) => void,
|
555 | ): this;
|
556 |
|
557 | |
558 |
|
559 |
|
560 | connect(config: ConnectConfig): this;
|
561 |
|
562 | |
563 |
|
564 |
|
565 |
|
566 |
|
567 |
|
568 |
|
569 | exec(command: string, options: ExecOptions, callback: ClientCallback): this;
|
570 |
|
571 | |
572 |
|
573 |
|
574 |
|
575 |
|
576 |
|
577 | exec(command: string, callback: ClientCallback): this;
|
578 |
|
579 | |
580 |
|
581 |
|
582 |
|
583 |
|
584 |
|
585 |
|
586 | shell(window: PseudoTtyOptions | false, options: ShellOptions, callback: ClientCallback): this;
|
587 |
|
588 | |
589 |
|
590 |
|
591 |
|
592 |
|
593 |
|
594 | shell(window: PseudoTtyOptions | false, callback: ClientCallback): this;
|
595 |
|
596 | |
597 |
|
598 |
|
599 |
|
600 |
|
601 |
|
602 | shell(options: ShellOptions, callback: ClientCallback): this;
|
603 |
|
604 | |
605 |
|
606 |
|
607 |
|
608 |
|
609 | shell(callback: ClientCallback): this;
|
610 |
|
611 | |
612 |
|
613 |
|
614 |
|
615 |
|
616 |
|
617 |
|
618 |
|
619 |
|
620 |
|
621 |
|
622 |
|
623 |
|
624 |
|
625 |
|
626 |
|
627 |
|
628 | forwardIn(remoteAddr: string, remotePort: number, callback?: ClientForwardCallback): this;
|
629 |
|
630 | |
631 |
|
632 |
|
633 |
|
634 |
|
635 |
|
636 |
|
637 |
|
638 | unforwardIn(remoteAddr: string, remotePort: number, callback?: Callback): this;
|
639 |
|
640 | |
641 |
|
642 |
|
643 |
|
644 |
|
645 |
|
646 |
|
647 |
|
648 |
|
649 |
|
650 | forwardOut(srcIP: string, srcPort: number, dstIP: string, dstPort: number, callback?: ClientCallback): this;
|
651 |
|
652 | |
653 |
|
654 |
|
655 |
|
656 |
|
657 | sftp(callback: ClientSFTPCallback): this;
|
658 |
|
659 | |
660 |
|
661 |
|
662 |
|
663 |
|
664 |
|
665 | subsys(subsystem: string, callback: ClientCallback): this;
|
666 |
|
667 | |
668 |
|
669 |
|
670 | end(): this;
|
671 |
|
672 | |
673 |
|
674 |
|
675 | destroy(): this;
|
676 |
|
677 | |
678 |
|
679 |
|
680 |
|
681 | openssh_noMoreSessions(cb: Callback): this;
|
682 |
|
683 | |
684 |
|
685 |
|
686 |
|
687 | openssh_forwardInStreamLocal(socketPath: string, cb: Callback): this;
|
688 |
|
689 | |
690 |
|
691 |
|
692 |
|
693 | openssh_unforwardInStreamLocal(socketPath: string, cb: Callback): this;
|
694 |
|
695 | |
696 |
|
697 |
|
698 |
|
699 | openssh_forwardOutStreamLocal(socketPath: string, cb: ClientCallback): this;
|
700 | }
|
701 |
|
702 | export type HostVerifier = (key: Buffer, verify: VerifyCallback) => void;
|
703 | export type SyncHostVerifier = (key: Buffer) => boolean;
|
704 | export type HostFingerprintVerifier = (fingerprint: string, verify: VerifyCallback) => boolean;
|
705 | export type SyncHostFingerprintVerifier = (fingerprint: string) => boolean;
|
706 | export type DebugFunction = (message: string) => void;
|
707 | export type AuthenticationType = "password" | "publickey" | "hostbased" | "agent" | "keyboard-interactive" | "none";
|
708 |
|
709 | export interface ConnectConfig {
|
710 |
|
711 | host?: string;
|
712 |
|
713 | port?: number;
|
714 |
|
715 | forceIPv4?: boolean;
|
716 |
|
717 | forceIPv6?: boolean;
|
718 |
|
719 | hostHash?: string;
|
720 |
|
721 | hostVerifier?: HostVerifier | SyncHostVerifier | HostFingerprintVerifier | SyncHostFingerprintVerifier;
|
722 |
|
723 | username?: string;
|
724 |
|
725 | password?: string;
|
726 |
|
727 | agent?: BaseAgent | string;
|
728 |
|
729 | privateKey?: Buffer | string;
|
730 |
|
731 | passphrase?: Buffer | string;
|
732 |
|
733 | localHostname?: string;
|
734 |
|
735 | localUsername?: string;
|
736 |
|
737 | tryKeyboard?: boolean;
|
738 |
|
739 | keepaliveInterval?: number;
|
740 |
|
741 | keepaliveCountMax?: number;
|
742 |
|
743 | readyTimeout?: number;
|
744 |
|
745 | strictVendor?: boolean;
|
746 |
|
747 | sock?: Readable;
|
748 |
|
749 | agentForward?: boolean;
|
750 |
|
751 | algorithms?: Algorithms;
|
752 |
|
753 | debug?: DebugFunction;
|
754 |
|
755 | authHandler?: AuthenticationType[] | AuthHandlerMiddleware | AuthMethod[];
|
756 |
|
757 | localAddress?: string;
|
758 |
|
759 | localPort?: number;
|
760 |
|
761 | timeout?: number;
|
762 |
|
763 | ident?: Buffer | string;
|
764 | }
|
765 |
|
766 | export interface AuthMethod {
|
767 | type: AuthenticationType;
|
768 | username: string;
|
769 | }
|
770 |
|
771 |
|
772 |
|
773 |
|
774 | export interface NoAuthMethod extends AuthMethod {
|
775 | type: "none";
|
776 | }
|
777 |
|
778 |
|
779 |
|
780 |
|
781 | export interface PasswordAuthMethod extends AuthMethod {
|
782 | type: "password";
|
783 | password: string;
|
784 | }
|
785 |
|
786 |
|
787 |
|
788 |
|
789 | export interface PublicKeyAuthMethod extends AuthMethod {
|
790 | type: "publickey";
|
791 | key: ParsedKey | Buffer | string;
|
792 | passphrase?: Buffer | string;
|
793 | }
|
794 |
|
795 |
|
796 |
|
797 |
|
798 | export interface HostBasedAuthMethod extends AuthMethod {
|
799 | type: "hostbased";
|
800 | localHostname: string;
|
801 | localUsername: string;
|
802 | |
803 |
|
804 |
|
805 | key: ParsedKey | Buffer | string;
|
806 | |
807 |
|
808 |
|
809 | passphrase?: Buffer | string;
|
810 | }
|
811 |
|
812 |
|
813 |
|
814 |
|
815 | export interface AgentAuthMethod extends AuthMethod {
|
816 | type: "agent";
|
817 | |
818 |
|
819 |
|
820 |
|
821 | agent: BaseAgent | string;
|
822 | }
|
823 |
|
824 |
|
825 |
|
826 |
|
827 | export interface KeyboardInteractiveAuthMethod extends AuthMethod {
|
828 | type: "keyboard-interactive";
|
829 | |
830 |
|
831 |
|
832 | prompt(
|
833 | name: string,
|
834 | instructions: string,
|
835 | lang: string,
|
836 | prompts: Prompt[],
|
837 | finish: KeyboardInteractiveCallback,
|
838 | ): void;
|
839 | }
|
840 |
|
841 | export type AnyAuthMethod =
|
842 | | NoAuthMethod
|
843 | | PasswordAuthMethod
|
844 | | HostBasedAuthMethod
|
845 | | PublicKeyAuthMethod
|
846 | | AgentAuthMethod
|
847 | | KeyboardInteractiveAuthMethod;
|
848 |
|
849 | export type NextAuthHandler = (authName: AuthenticationType | AnyAuthMethod) => void;
|
850 |
|
851 | export type AuthHandlerMiddleware = (
|
852 | authsLeft: AuthenticationType[],
|
853 | partialSuccess: boolean,
|
854 | next: NextAuthHandler,
|
855 | ) => void;
|
856 |
|
857 | export interface TcpConnectionDetails {
|
858 |
|
859 | srcIP: string;
|
860 |
|
861 | srcPort: number;
|
862 |
|
863 | destIP: string;
|
864 |
|
865 | destPort: number;
|
866 | }
|
867 |
|
868 | export interface X11Details {
|
869 |
|
870 | srcIP: string;
|
871 |
|
872 | srcPort: number;
|
873 | }
|
874 |
|
875 | export interface ClientErrorExtensions {
|
876 |
|
877 | level?: string;
|
878 |
|
879 | description?: string;
|
880 | }
|
881 |
|
882 | export interface ExecOptions {
|
883 |
|
884 | env?: NodeJS.ProcessEnv;
|
885 |
|
886 | pty?: PseudoTtyOptions | boolean;
|
887 |
|
888 | x11?: X11Options | number | boolean;
|
889 | allowHalfOpen?: boolean;
|
890 | }
|
891 |
|
892 | export interface ShellOptions {
|
893 |
|
894 | env?: NodeJS.ProcessEnv;
|
895 |
|
896 | x11?: X11Options | number | boolean;
|
897 | }
|
898 |
|
899 | export interface X11Options {
|
900 |
|
901 | single?: boolean;
|
902 |
|
903 | screen?: number;
|
904 |
|
905 | protocol?: string;
|
906 |
|
907 | cookie?: Buffer | string;
|
908 | }
|
909 |
|
910 | export interface PseudoTtyOptions {
|
911 |
|
912 | rows?: number;
|
913 |
|
914 | cols?: number;
|
915 |
|
916 | height?: number;
|
917 |
|
918 | width?: number;
|
919 |
|
920 | term?: string;
|
921 |
|
922 | modes?: TerminalModes;
|
923 | }
|
924 |
|
925 | export type ServerConnectionListener = (client: Connection, info: ClientInfo) => void;
|
926 |
|
927 | export class Server extends NetServer {
|
928 | static KEEPALIVE_CLIENT_INTERVAL: number;
|
929 | static KEEPALIVE_CLIENT_COUNT_MAX: number;
|
930 | constructor(cfg: ServerConfig, listener?: ServerConnectionListener);
|
931 | injectSocket(socket: Socket): void;
|
932 | on(event: "connection", listener: ServerConnectionListener): this;
|
933 | on(event: string | symbol, listener: Function): this;
|
934 | once(event: "connection", listener: ServerConnectionListener): this;
|
935 | once(event: string | symbol, listener: Function): this;
|
936 | }
|
937 |
|
938 | export interface ServerConfig {
|
939 |
|
940 | hostKeys: PrivateKeys;
|
941 |
|
942 | algorithms?: Algorithms;
|
943 |
|
944 | greeting?: string;
|
945 |
|
946 | banner?: string;
|
947 |
|
948 | ident?: string;
|
949 |
|
950 | highWaterMark?: number;
|
951 |
|
952 | keepaliveInterval?: number;
|
953 |
|
954 | keepaliveCountMax?: number;
|
955 |
|
956 | debug?: DebugFunction;
|
957 | }
|
958 |
|
959 | export interface EncryptedPrivateKey {
|
960 |
|
961 | key: ParsedKey | Buffer | string;
|
962 |
|
963 | passphrase?: Buffer | string;
|
964 | }
|
965 |
|
966 | export interface ClientInfo {
|
967 |
|
968 | ip: string;
|
969 |
|
970 | header: Header;
|
971 | family: string;
|
972 | port: number;
|
973 | }
|
974 |
|
975 | export interface Connection extends EventEmitter {
|
976 |
|
977 |
|
978 | |
979 |
|
980 |
|
981 | on(event: "authentication", listener: (context: AuthContext) => void): this;
|
982 |
|
983 | |
984 |
|
985 |
|
986 | on(event: "ready", listener: () => void): this;
|
987 |
|
988 | |
989 |
|
990 |
|
991 |
|
992 | on(event: "session", listener: (accept: AcceptConnection<Session>, reject: RejectConnection) => void): this;
|
993 |
|
994 | |
995 |
|
996 |
|
997 | on(
|
998 | event: "tcpip",
|
999 | listener: (accept: AcceptConnection<ServerChannel>, reject: RejectConnection, info: TcpipRequestInfo) => void,
|
1000 | ): this;
|
1001 |
|
1002 | |
1003 |
|
1004 |
|
1005 | on(
|
1006 | event: "openssh.streamlocal",
|
1007 | listener: (accept: AcceptConnection<ServerChannel>, reject: RejectConnection, info: SocketRequestInfo) => void,
|
1008 | ): this;
|
1009 |
|
1010 | |
1011 |
|
1012 |
|
1013 |
|
1014 | on(
|
1015 | event: "request",
|
1016 | listener: (
|
1017 | accept: ((chosenPort?: number) => void) | undefined,
|
1018 | reject: (() => void) | undefined,
|
1019 | name: "tcpip-forward" | "cancel-tcpip-forward",
|
1020 | info: TcpipBindInfo,
|
1021 | ) => void,
|
1022 | ): this;
|
1023 |
|
1024 | |
1025 |
|
1026 |
|
1027 | on(
|
1028 | event: "request",
|
1029 | listener: (
|
1030 | accept: (() => void) | undefined,
|
1031 | reject: () => void,
|
1032 | name: "streamlocal-forward@openssh.com" | "cancel-streamlocal-forward@openssh.com",
|
1033 | info: SocketBindInfo,
|
1034 | ) => void,
|
1035 | ): this;
|
1036 |
|
1037 | |
1038 |
|
1039 |
|
1040 | on(event: "rekey", listener: () => void): this;
|
1041 |
|
1042 | |
1043 |
|
1044 |
|
1045 | on(event: "error", listener: ErrorCallback): this;
|
1046 |
|
1047 | |
1048 |
|
1049 |
|
1050 | on(event: "end", listener: () => void): this;
|
1051 |
|
1052 | |
1053 |
|
1054 |
|
1055 | on(event: "close", listener: () => void): this;
|
1056 |
|
1057 | |
1058 |
|
1059 |
|
1060 | on(event: "handshake", listener: (negotiated: NegotiatedAlgorithms) => void): this;
|
1061 |
|
1062 | |
1063 |
|
1064 |
|
1065 | on(event: "greeting", listener: (greeting: string) => void): this;
|
1066 |
|
1067 | |
1068 |
|
1069 |
|
1070 | once(event: "authentication", listener: (context: AuthContext) => void): this;
|
1071 |
|
1072 | |
1073 |
|
1074 |
|
1075 | once(event: "ready", listener: () => void): this;
|
1076 |
|
1077 | |
1078 |
|
1079 |
|
1080 |
|
1081 | once(event: "session", listener: (accept: AcceptConnection<Session>, reject: RejectConnection) => void): this;
|
1082 |
|
1083 | |
1084 |
|
1085 |
|
1086 | once(
|
1087 | event: "tcpip",
|
1088 | listener: (accept: AcceptConnection<ServerChannel>, reject: RejectConnection, info: TcpipRequestInfo) => void,
|
1089 | ): this;
|
1090 |
|
1091 | |
1092 |
|
1093 |
|
1094 | once(
|
1095 | event: "openssh.streamlocal",
|
1096 | listener: (accept: AcceptConnection<ServerChannel>, reject: RejectConnection, info: SocketRequestInfo) => void,
|
1097 | ): this;
|
1098 |
|
1099 | |
1100 |
|
1101 |
|
1102 |
|
1103 | once(
|
1104 | event: "request",
|
1105 | listener: (
|
1106 | accept: ((chosenPort?: number) => void) | undefined,
|
1107 | reject: (() => void) | undefined,
|
1108 | name: "tcpip-forward" | "cancel-tcpip-forward",
|
1109 | info: TcpipBindInfo,
|
1110 | ) => void,
|
1111 | ): this;
|
1112 |
|
1113 | |
1114 |
|
1115 |
|
1116 | once(
|
1117 | event: "request",
|
1118 | listener: (
|
1119 | accept: (() => void) | undefined,
|
1120 | reject: () => void,
|
1121 | name: "streamlocal-forward@openssh.com" | "cancel-streamlocal-forward@openssh.com",
|
1122 | info: SocketBindInfo,
|
1123 | ) => void,
|
1124 | ): this;
|
1125 |
|
1126 | |
1127 |
|
1128 |
|
1129 | once(event: "rekey", listener: () => void): this;
|
1130 |
|
1131 | |
1132 |
|
1133 |
|
1134 | once(event: "error", listener: ErrorCallback): this;
|
1135 |
|
1136 | |
1137 |
|
1138 |
|
1139 | once(event: "end", listener: () => void): this;
|
1140 |
|
1141 | |
1142 |
|
1143 |
|
1144 | once(event: "close", listener: () => void): this;
|
1145 |
|
1146 | |
1147 |
|
1148 |
|
1149 | once(event: "handshake", listener: (negotiated: NegotiatedAlgorithms) => void): this;
|
1150 |
|
1151 | |
1152 |
|
1153 |
|
1154 | once(event: "greeting", listener: (greeting: string) => void): this;
|
1155 |
|
1156 | noMoreSessions: boolean;
|
1157 | authenticated: boolean;
|
1158 |
|
1159 |
|
1160 |
|
1161 | |
1162 |
|
1163 |
|
1164 | end(): this;
|
1165 |
|
1166 | |
1167 |
|
1168 |
|
1169 | x11(originAddr: string, originPort: number, channel: ServerCallback): this;
|
1170 |
|
1171 | |
1172 |
|
1173 |
|
1174 |
|
1175 | forwardOut(
|
1176 | boundAddr: string,
|
1177 | boundPort: number,
|
1178 | remoteAddr: string,
|
1179 | remotePort: number,
|
1180 | callback: ServerCallback,
|
1181 | ): this;
|
1182 |
|
1183 | |
1184 |
|
1185 |
|
1186 |
|
1187 |
|
1188 |
|
1189 |
|
1190 | rekey(callback?: () => void): void;
|
1191 |
|
1192 | |
1193 |
|
1194 |
|
1195 |
|
1196 |
|
1197 | openssh_forwardOutStreamLocal(socketPath: string, callback: ServerCallback): this;
|
1198 | }
|
1199 |
|
1200 | export interface AuthContextBase extends EventEmitter {
|
1201 |
|
1202 | username: string;
|
1203 |
|
1204 | service: string;
|
1205 |
|
1206 | method: AuthenticationType;
|
1207 |
|
1208 | |
1209 |
|
1210 |
|
1211 | accept(): void;
|
1212 |
|
1213 | |
1214 |
|
1215 |
|
1216 | reject(authMethodsLeft?: AuthenticationType[], isPartialSuccess?: boolean): void;
|
1217 |
|
1218 | |
1219 |
|
1220 |
|
1221 | on(event: "abort", listener: () => void): this;
|
1222 |
|
1223 | |
1224 |
|
1225 |
|
1226 | once(event: "abort", listener: () => void): this;
|
1227 | }
|
1228 |
|
1229 | export interface KeyboardAuthContext extends AuthContextBase {
|
1230 |
|
1231 | method: "keyboard-interactive";
|
1232 |
|
1233 |
|
1234 | submethods: string[];
|
1235 |
|
1236 | |
1237 |
|
1238 |
|
1239 |
|
1240 |
|
1241 | prompt(prompts: string | Prompt | Array<string | Prompt>, callback: KeyboardInteractiveCallback): void;
|
1242 |
|
1243 | |
1244 |
|
1245 |
|
1246 |
|
1247 |
|
1248 |
|
1249 | prompt(
|
1250 | prompts: string | Prompt | Array<string | Prompt>,
|
1251 | title: string,
|
1252 | callback: KeyboardInteractiveCallback,
|
1253 | ): void;
|
1254 |
|
1255 | |
1256 |
|
1257 |
|
1258 |
|
1259 |
|
1260 |
|
1261 |
|
1262 | prompt(
|
1263 | prompts: string | Prompt | Array<string | Prompt>,
|
1264 | title: string,
|
1265 | instructions: string,
|
1266 | callback: KeyboardInteractiveCallback,
|
1267 | ): void;
|
1268 | }
|
1269 |
|
1270 | export interface PublicKeyAuthContext extends AuthContextBase {
|
1271 |
|
1272 | method: "publickey";
|
1273 |
|
1274 | key: PublicKey;
|
1275 |
|
1276 | signature?: Buffer;
|
1277 |
|
1278 | blob?: Buffer;
|
1279 |
|
1280 | hashAlgo?: string;
|
1281 | }
|
1282 |
|
1283 | export interface PublicKey {
|
1284 |
|
1285 | algo: string;
|
1286 |
|
1287 | data: Buffer;
|
1288 | }
|
1289 |
|
1290 | export interface HostbasedAuthContext extends AuthContextBase {
|
1291 |
|
1292 | method: "hostbased";
|
1293 |
|
1294 | key: PublicKey;
|
1295 |
|
1296 | signature: Buffer;
|
1297 |
|
1298 | blob: Buffer;
|
1299 |
|
1300 | localHostname: string;
|
1301 |
|
1302 | localUsername: string;
|
1303 | }
|
1304 |
|
1305 | export interface PasswordAuthContext extends AuthContextBase {
|
1306 |
|
1307 | method: "password";
|
1308 |
|
1309 | password: string;
|
1310 | requestChange(prompt: string, cb: ChangePasswordCallback): void;
|
1311 | }
|
1312 |
|
1313 | export interface NoneAuthContext extends AuthContextBase {
|
1314 |
|
1315 | method: "none";
|
1316 | }
|
1317 |
|
1318 | export type AuthContext =
|
1319 | | KeyboardAuthContext
|
1320 | | PublicKeyAuthContext
|
1321 | | HostbasedAuthContext
|
1322 | | PasswordAuthContext
|
1323 | | NoneAuthContext;
|
1324 |
|
1325 | export interface TcpipRequestInfo {
|
1326 |
|
1327 | srcIP: string;
|
1328 |
|
1329 | srcPort: number;
|
1330 |
|
1331 | destIP: string;
|
1332 |
|
1333 | destPort: number;
|
1334 | }
|
1335 |
|
1336 | export interface SocketRequestInfo {
|
1337 |
|
1338 | socketPath: string;
|
1339 | }
|
1340 |
|
1341 | export interface TcpipBindInfo {
|
1342 |
|
1343 | bindAddr: string;
|
1344 |
|
1345 | bindPort: number;
|
1346 | }
|
1347 |
|
1348 | export interface SocketBindInfo {
|
1349 |
|
1350 | socketPath: string;
|
1351 | }
|
1352 |
|
1353 |
|
1354 | export type SessionAcceptReject = () => void;
|
1355 | export type SessionAccept = () => void;
|
1356 |
|
1357 |
|
1358 | export interface Session extends ServerChannel {
|
1359 |
|
1360 |
|
1361 | |
1362 |
|
1363 |
|
1364 | on(event: "pty", listener: (accept: SessionAccept, reject: RejectConnection, info: PseudoTtyInfo) => void): this;
|
1365 |
|
1366 | |
1367 |
|
1368 |
|
1369 | on(
|
1370 | event: "window-change",
|
1371 | listener: (accept: SessionAccept, reject: RejectConnection, info: WindowChangeInfo) => void,
|
1372 | ): this;
|
1373 |
|
1374 | |
1375 |
|
1376 |
|
1377 | on(event: "x11", listener: (accept: SessionAccept, reject: RejectConnection, info: X11Info) => void): this;
|
1378 |
|
1379 | |
1380 |
|
1381 |
|
1382 | on(event: "env", listener: (accept: SessionAccept, reject: RejectConnection, info: SetEnvInfo) => void): this;
|
1383 |
|
1384 | |
1385 |
|
1386 |
|
1387 | on(event: "signal", listener: (accept: SessionAccept, reject: RejectConnection, info: SignalInfo) => void): this;
|
1388 |
|
1389 | |
1390 |
|
1391 |
|
1392 | on(event: "auth-agent", listener: (accept: SessionAccept, reject: RejectConnection) => void): this;
|
1393 |
|
1394 | |
1395 |
|
1396 |
|
1397 | on(event: "shell", listener: (accept: AcceptConnection<ServerChannel>, reject: RejectConnection) => void): this;
|
1398 |
|
1399 | |
1400 |
|
1401 |
|
1402 | on(
|
1403 | event: "exec",
|
1404 | listener: (accept: AcceptConnection<ServerChannel>, reject: RejectConnection, info: ExecInfo) => void,
|
1405 | ): this;
|
1406 |
|
1407 | |
1408 |
|
1409 |
|
1410 | on(event: "sftp", listener: (accept: AcceptSftpConnection, reject: RejectConnection) => void): this;
|
1411 |
|
1412 | |
1413 |
|
1414 |
|
1415 | on(
|
1416 | event: "subsystem",
|
1417 | listener: (accept: AcceptConnection<ServerChannel>, reject: RejectConnection, info: SubsystemInfo) => void,
|
1418 | ): this;
|
1419 |
|
1420 | on(event: string | symbol, listener: Function): this;
|
1421 |
|
1422 | |
1423 |
|
1424 |
|
1425 | once(event: "pty", listener: (accept: SessionAccept, reject: RejectConnection, info: PseudoTtyInfo) => void): this;
|
1426 |
|
1427 | |
1428 |
|
1429 |
|
1430 | once(
|
1431 | event: "window-change",
|
1432 | listener: (accept: SessionAccept, reject: RejectConnection, info: WindowChangeInfo) => void,
|
1433 | ): this;
|
1434 |
|
1435 | |
1436 |
|
1437 |
|
1438 | once(event: "x11", listener: (accept: SessionAccept, reject: RejectConnection, info: X11Info) => void): this;
|
1439 |
|
1440 | |
1441 |
|
1442 |
|
1443 | once(event: "env", listener: (accept: SessionAccept, reject: RejectConnection, info: SetEnvInfo) => void): this;
|
1444 |
|
1445 | |
1446 |
|
1447 |
|
1448 | once(event: "signal", listener: (accept: SessionAccept, reject: RejectConnection, info: SignalInfo) => void): this;
|
1449 |
|
1450 | |
1451 |
|
1452 |
|
1453 | once(event: "auth-agent", listener: (accept: SessionAccept, reject: RejectConnection) => void): this;
|
1454 |
|
1455 | |
1456 |
|
1457 |
|
1458 | once(event: "shell", listener: (accept: AcceptConnection<ServerChannel>, reject: RejectConnection) => void): this;
|
1459 |
|
1460 | |
1461 |
|
1462 |
|
1463 | once(
|
1464 | event: "exec",
|
1465 | listener: (accept: AcceptConnection<ServerChannel>, reject: RejectConnection, info: ExecInfo) => void,
|
1466 | ): this;
|
1467 |
|
1468 | |
1469 |
|
1470 |
|
1471 | once(event: "sftp", listener: (accept: AcceptSftpConnection, reject: RejectConnection) => void): this;
|
1472 |
|
1473 | |
1474 |
|
1475 |
|
1476 | once(
|
1477 | event: "subsystem",
|
1478 | listener: (accept: AcceptConnection<ServerChannel>, reject: RejectConnection, info: SubsystemInfo) => void,
|
1479 | ): this;
|
1480 |
|
1481 | once(event: string | symbol, listener: Function): this;
|
1482 | }
|
1483 |
|
1484 | export interface PseudoTtyInfo {
|
1485 |
|
1486 | cols: number;
|
1487 |
|
1488 | rows: number;
|
1489 |
|
1490 | width: number;
|
1491 |
|
1492 | height: number;
|
1493 |
|
1494 | modes: TerminalModes;
|
1495 | }
|
1496 |
|
1497 | export interface TerminalModes {
|
1498 |
|
1499 | VINTR?: number | undefined;
|
1500 |
|
1501 | VQUIT?: number | undefined;
|
1502 |
|
1503 | VERASE?: number | undefined;
|
1504 |
|
1505 | VKILL?: number | undefined;
|
1506 |
|
1507 | VEOF?: number | undefined;
|
1508 |
|
1509 | VEOL?: number | undefined;
|
1510 |
|
1511 | VEOL2?: number | undefined;
|
1512 |
|
1513 | VSTART?: number | undefined;
|
1514 |
|
1515 | VSTOP?: number | undefined;
|
1516 |
|
1517 | VSUSP?: number | undefined;
|
1518 |
|
1519 | VDSUSP?: number | undefined;
|
1520 |
|
1521 | VREPRINT?: number | undefined;
|
1522 |
|
1523 | VWERASE?: number | undefined;
|
1524 |
|
1525 | VLNEXT?: number | undefined;
|
1526 |
|
1527 | VFLUSH?: number | undefined;
|
1528 |
|
1529 | VSWTCH?: number | undefined;
|
1530 |
|
1531 | VSTATUS?: number | undefined;
|
1532 |
|
1533 | VDISCARD?: number | undefined;
|
1534 |
|
1535 | IGNPAR?: 0 | 1 | undefined;
|
1536 |
|
1537 | PARMRK?: 0 | 1 | undefined;
|
1538 |
|
1539 | INPCK?: 0 | 1 | undefined;
|
1540 |
|
1541 | ISTRIP?: 0 | 1 | undefined;
|
1542 |
|
1543 | INLCR?: 0 | 1 | undefined;
|
1544 |
|
1545 | IGNCR?: 0 | 1 | undefined;
|
1546 |
|
1547 | ICRNL?: 0 | 1 | undefined;
|
1548 |
|
1549 | IUCLC?: 0 | 1 | undefined;
|
1550 |
|
1551 | IXON?: 0 | 1 | undefined;
|
1552 |
|
1553 | IXANY?: 0 | 1 | undefined;
|
1554 |
|
1555 | IXOFF?: 0 | 1 | undefined;
|
1556 |
|
1557 | IMAXBEL?: 0 | 1 | undefined;
|
1558 |
|
1559 | ISIG?: 0 | 1 | undefined;
|
1560 |
|
1561 | ICANON?: 0 | 1 | undefined;
|
1562 |
|
1563 | XCASE?: 0 | 1 | undefined;
|
1564 |
|
1565 | ECHO?: 0 | 1 | undefined;
|
1566 |
|
1567 | ECHOE?: 0 | 1 | undefined;
|
1568 |
|
1569 | ECHOK?: 0 | 1 | undefined;
|
1570 |
|
1571 | ECHONL?: 0 | 1 | undefined;
|
1572 |
|
1573 | NOFLSH?: 0 | 1 | undefined;
|
1574 |
|
1575 | TOSTOP?: 0 | 1 | undefined;
|
1576 |
|
1577 | IEXTEN?: 0 | 1 | undefined;
|
1578 |
|
1579 | ECHOCTL?: 0 | 1 | undefined;
|
1580 |
|
1581 | ECHOKE?: 0 | 1 | undefined;
|
1582 |
|
1583 | PENDIN?: 0 | 1 | undefined;
|
1584 |
|
1585 | OPOST?: 0 | 1 | undefined;
|
1586 |
|
1587 | OLCUC?: 0 | 1 | undefined;
|
1588 |
|
1589 | ONLCR?: 0 | 1 | undefined;
|
1590 |
|
1591 | OCRNL?: 0 | 1 | undefined;
|
1592 |
|
1593 | ONOCR?: 0 | 1 | undefined;
|
1594 |
|
1595 | ONLRET?: 0 | 1 | undefined;
|
1596 |
|
1597 | CS7?: 0 | 1 | undefined;
|
1598 |
|
1599 | CS8?: 0 | 1 | undefined;
|
1600 |
|
1601 | PARENB?: 0 | 1 | undefined;
|
1602 |
|
1603 | PARODD?: 0 | 1 | undefined;
|
1604 |
|
1605 | TTY_OP_ISPEED?: number | undefined;
|
1606 |
|
1607 | TTY_OP_OSPEED?: number | undefined;
|
1608 | }
|
1609 |
|
1610 | export interface WindowChangeInfo {
|
1611 |
|
1612 | cols: number;
|
1613 |
|
1614 | rows: number;
|
1615 |
|
1616 | width: number;
|
1617 |
|
1618 | height: number;
|
1619 | }
|
1620 |
|
1621 | export interface X11Info {
|
1622 |
|
1623 | single: boolean;
|
1624 |
|
1625 | protocol: string;
|
1626 |
|
1627 | cookie: string;
|
1628 |
|
1629 | screen: number;
|
1630 | }
|
1631 |
|
1632 | export interface SetEnvInfo {
|
1633 |
|
1634 | key: string;
|
1635 |
|
1636 | val: string;
|
1637 | }
|
1638 |
|
1639 | export interface SignalInfo {
|
1640 |
|
1641 | name: string;
|
1642 | }
|
1643 |
|
1644 | export interface ExecInfo {
|
1645 |
|
1646 | command: string;
|
1647 | }
|
1648 |
|
1649 | export interface SubsystemInfo {
|
1650 |
|
1651 | name: string;
|
1652 | }
|
1653 |
|
1654 | export interface TransferOptions {
|
1655 | concurrency?: number;
|
1656 | chunkSize?: number;
|
1657 | fileSize?: number;
|
1658 | step?: (total: number, nb: number, fsize: number) => void;
|
1659 | mode?: number | string;
|
1660 | }
|
1661 |
|
1662 | export interface ReadFileOptions {
|
1663 | encoding?: BufferEncoding;
|
1664 | flag?: string;
|
1665 | }
|
1666 |
|
1667 | export interface WriteFileOptions {
|
1668 | encoding?: BufferEncoding;
|
1669 | mode?: number;
|
1670 | flag?: string;
|
1671 | }
|
1672 |
|
1673 | export interface InputAttributes {
|
1674 | mode?: number | string;
|
1675 | uid?: number;
|
1676 | gid?: number;
|
1677 | size?: number;
|
1678 | atime?: number | Date;
|
1679 | mtime?: number | Date;
|
1680 | }
|
1681 |
|
1682 | export interface Attributes {
|
1683 | mode: number;
|
1684 | uid: number;
|
1685 | gid: number;
|
1686 | size: number;
|
1687 | atime: number;
|
1688 | mtime: number;
|
1689 | }
|
1690 |
|
1691 | export interface Stats extends Attributes {
|
1692 | isDirectory(): boolean;
|
1693 | isFile(): boolean;
|
1694 | isBlockDevice(): boolean;
|
1695 | isCharacterDevice(): boolean;
|
1696 | isSymbolicLink(): boolean;
|
1697 | isFIFO(): boolean;
|
1698 | isSocket(): boolean;
|
1699 | }
|
1700 |
|
1701 | export interface FileEntry {
|
1702 | filename: string;
|
1703 | longname: string;
|
1704 | attrs: Attributes;
|
1705 | }
|
1706 |
|
1707 | export interface FileEntryWithStats extends Omit<FileEntry, "attrs"> {
|
1708 | attrs: Stats;
|
1709 | }
|
1710 |
|
1711 | export interface SFTPWrapper extends EventEmitter {
|
1712 | |
1713 |
|
1714 |
|
1715 |
|
1716 | fastGet(remotePath: string, localPath: string, options: TransferOptions, callback: Callback): void;
|
1717 |
|
1718 | |
1719 |
|
1720 |
|
1721 |
|
1722 | fastGet(remotePath: string, localPath: string, callback: Callback): void;
|
1723 |
|
1724 | |
1725 |
|
1726 |
|
1727 |
|
1728 | fastPut(localPath: string, remotePath: string, options: TransferOptions, callback: Callback): void;
|
1729 |
|
1730 | |
1731 |
|
1732 |
|
1733 |
|
1734 | fastPut(localPath: string, remotePath: string, callback: Callback): void;
|
1735 |
|
1736 | |
1737 |
|
1738 |
|
1739 |
|
1740 | readFile(
|
1741 | remotePath: string,
|
1742 | options: ReadFileOptions,
|
1743 | callback: (err: Error | undefined, handle: Buffer) => void,
|
1744 | ): void;
|
1745 |
|
1746 | |
1747 |
|
1748 |
|
1749 |
|
1750 | readFile(
|
1751 | remotePath: string,
|
1752 | encoding: BufferEncoding,
|
1753 | callback: (err: Error | undefined, handle: Buffer) => void,
|
1754 | ): void;
|
1755 |
|
1756 | |
1757 |
|
1758 |
|
1759 |
|
1760 | readFile(remotePath: string, callback: (err: Error | undefined, handle: Buffer) => void): void;
|
1761 |
|
1762 | |
1763 |
|
1764 |
|
1765 |
|
1766 | createReadStream(path: string, options?: ReadStreamOptions): ReadStream;
|
1767 |
|
1768 | |
1769 |
|
1770 |
|
1771 |
|
1772 | writeFile(remotePath: string, data: string | Buffer, options: WriteFileOptions, callback?: Callback): void;
|
1773 |
|
1774 | |
1775 |
|
1776 |
|
1777 |
|
1778 | writeFile(remotePath: string, data: string | Buffer, encoding: string, callback?: Callback): void;
|
1779 |
|
1780 | |
1781 |
|
1782 |
|
1783 |
|
1784 | writeFile(remotePath: string, data: string | Buffer, callback?: Callback): void;
|
1785 |
|
1786 | |
1787 |
|
1788 |
|
1789 |
|
1790 | appendFile(remotePath: string, data: string | Buffer, options: WriteFileOptions, callback?: Callback): void;
|
1791 |
|
1792 | |
1793 |
|
1794 |
|
1795 |
|
1796 | appendFile(remotePath: string, data: string | Buffer, callback?: Callback): void;
|
1797 |
|
1798 | |
1799 |
|
1800 |
|
1801 |
|
1802 | createWriteStream(path: string, options?: WriteStreamOptions): WriteStream;
|
1803 |
|
1804 | |
1805 |
|
1806 |
|
1807 |
|
1808 | open(
|
1809 | filename: string,
|
1810 | mode: number | OpenMode,
|
1811 | attributes: InputAttributes,
|
1812 | callback: (err: Error | undefined, handle: Buffer) => void,
|
1813 | ): void;
|
1814 | open(
|
1815 | filename: string,
|
1816 | mode: number | OpenMode,
|
1817 | attributes: string | number,
|
1818 | callback: (err: Error | undefined, handle: Buffer) => void,
|
1819 | ): void;
|
1820 |
|
1821 | |
1822 |
|
1823 |
|
1824 |
|
1825 | open(filename: string, mode: number | OpenMode, callback: (err: Error | undefined, handle: Buffer) => void): void;
|
1826 |
|
1827 | |
1828 |
|
1829 |
|
1830 |
|
1831 | close(handle: Buffer, callback: Callback): void;
|
1832 |
|
1833 | |
1834 |
|
1835 |
|
1836 |
|
1837 |
|
1838 | read(
|
1839 | handle: Buffer,
|
1840 | buffer: Buffer,
|
1841 | offset: number,
|
1842 | length: number,
|
1843 | position: number,
|
1844 | callback: (err: Error | undefined, bytesRead: number, buffer: Buffer, position: number) => void,
|
1845 | ): void;
|
1846 |
|
1847 | |
1848 |
|
1849 |
|
1850 | write(handle: Buffer, buffer: Buffer, offset: number, length: number, position: number, callback: Callback): void;
|
1851 |
|
1852 | |
1853 |
|
1854 |
|
1855 |
|
1856 | fstat(handle: Buffer, callback: (err: Error | undefined, stats: Stats) => void): void;
|
1857 |
|
1858 | |
1859 |
|
1860 |
|
1861 |
|
1862 | fsetstat(handle: Buffer, attributes: InputAttributes, callback: Callback): void;
|
1863 |
|
1864 | |
1865 |
|
1866 |
|
1867 |
|
1868 | futimes(handle: Buffer, atime: number | Date, mtime: number | Date, callback: Callback): void;
|
1869 |
|
1870 | |
1871 |
|
1872 |
|
1873 |
|
1874 | fchown(handle: Buffer, uid: number, gid: number, callback: Callback): void;
|
1875 |
|
1876 | |
1877 |
|
1878 |
|
1879 |
|
1880 | fchmod(handle: Buffer, mode: number | string, callback: Callback): void;
|
1881 |
|
1882 | |
1883 |
|
1884 |
|
1885 |
|
1886 | opendir(path: string, callback: (err: Error | undefined, handle: Buffer) => void): void;
|
1887 |
|
1888 | |
1889 |
|
1890 |
|
1891 |
|
1892 | readdir(location: string | Buffer, callback: (err: Error | undefined, list: FileEntryWithStats[]) => void): void;
|
1893 |
|
1894 | |
1895 |
|
1896 |
|
1897 |
|
1898 | unlink(path: string, callback: Callback): void;
|
1899 |
|
1900 | |
1901 |
|
1902 |
|
1903 |
|
1904 | rename(srcPath: string, destPath: string, callback: Callback): void;
|
1905 |
|
1906 | |
1907 |
|
1908 |
|
1909 |
|
1910 | mkdir(path: string, attributes: InputAttributes, callback: Callback): void;
|
1911 |
|
1912 | |
1913 |
|
1914 |
|
1915 |
|
1916 | mkdir(path: string, callback: Callback): void;
|
1917 |
|
1918 | |
1919 |
|
1920 |
|
1921 |
|
1922 | rmdir(path: string, callback: Callback): void;
|
1923 |
|
1924 | |
1925 |
|
1926 |
|
1927 |
|
1928 | stat(path: string, callback: (err: Error | undefined, stats: Stats) => void): void;
|
1929 |
|
1930 | |
1931 |
|
1932 |
|
1933 |
|
1934 | exists(path: string, callback: (hasError: boolean) => void): void;
|
1935 |
|
1936 | |
1937 |
|
1938 |
|
1939 |
|
1940 |
|
1941 | lstat(path: string, callback: (err: Error | undefined, stats: Stats) => void): void;
|
1942 |
|
1943 | |
1944 |
|
1945 |
|
1946 |
|
1947 | setstat(path: string, attributes: InputAttributes, callback: Callback): void;
|
1948 |
|
1949 | |
1950 |
|
1951 |
|
1952 |
|
1953 | utimes(path: string, atime: number | Date, mtime: number | Date, callback: Callback): void;
|
1954 |
|
1955 | |
1956 |
|
1957 |
|
1958 |
|
1959 | chown(path: string, uid: number, gid: number, callback: Callback): void;
|
1960 |
|
1961 | |
1962 |
|
1963 |
|
1964 |
|
1965 | chmod(path: string, mode: number | string, callback: Callback): void;
|
1966 |
|
1967 | |
1968 |
|
1969 |
|
1970 |
|
1971 | readlink(path: string, callback: (err: Error | undefined, target: string) => void): void;
|
1972 |
|
1973 | |
1974 |
|
1975 |
|
1976 |
|
1977 | symlink(targetPath: string, linkPath: string, callback: Callback): void;
|
1978 |
|
1979 | |
1980 |
|
1981 |
|
1982 |
|
1983 | realpath(path: string, callback: (err: Error | undefined, absPath: string) => void): void;
|
1984 |
|
1985 | |
1986 |
|
1987 |
|
1988 |
|
1989 | ext_openssh_rename(srcPath: string, destPath: string, callback: Callback): void;
|
1990 |
|
1991 | |
1992 |
|
1993 |
|
1994 |
|
1995 | ext_openssh_statvfs(path: string, callback: (err: Error | undefined, fsInfo: any) => void): void;
|
1996 |
|
1997 | |
1998 |
|
1999 |
|
2000 |
|
2001 | ext_openssh_fstatvfs(handle: Buffer, callback: (err: Error | undefined, fsInfo: any) => void): void;
|
2002 |
|
2003 | |
2004 |
|
2005 |
|
2006 |
|
2007 | ext_openssh_hardlink(targetPath: string, linkPath: string, callback: Callback): void;
|
2008 |
|
2009 | |
2010 |
|
2011 |
|
2012 |
|
2013 | ext_openssh_fsync(handle: Buffer, callback: (err: Error | undefined, fsInfo: any) => void): void;
|
2014 |
|
2015 | |
2016 |
|
2017 |
|
2018 |
|
2019 | ext_openssh_lsetstat(path: string, attrs: InputAttributes, callback: Callback): void;
|
2020 | ext_openssh_lsetstat(path: string, callback: Callback): void;
|
2021 |
|
2022 | |
2023 |
|
2024 |
|
2025 |
|
2026 | ext_openssh_expandPath(path: string, callback: (err: Error | undefined, absPath: string) => void): void;
|
2027 |
|
2028 | |
2029 |
|
2030 |
|
2031 |
|
2032 | ext_copy_data(
|
2033 | handle: Buffer,
|
2034 | srcOffset: number,
|
2035 | len: number,
|
2036 | dstHandle: Buffer,
|
2037 | dstOffset: number,
|
2038 | callback: Callback,
|
2039 | ): void;
|
2040 |
|
2041 | |
2042 |
|
2043 |
|
2044 | on(event: "ready", listener: () => void): this;
|
2045 | on(event: "OPEN", listener: (reqId: number, filename: string, flags: number, attrs: Attributes) => void): this;
|
2046 | on(event: "READ", listener: (reqId: number, handle: Buffer, offset: number, len: number) => void): this;
|
2047 | on(event: "WRITE", listener: (reqId: number, handle: Buffer, offset: number, data: Buffer) => void): this;
|
2048 | on(event: "FSTAT", listener: (reqId: number, handle: Buffer) => void): this;
|
2049 | on(event: "FSETSTAT", listener: (reqId: number, handle: Buffer, attrs: Attributes) => void): this;
|
2050 | on(event: "CLOSE", listener: (reqId: number, handle: Buffer) => void): this;
|
2051 | on(event: "OPENDIR", listener: (reqId: number, path: string) => void): this;
|
2052 | on(event: "READDIR", listener: (reqId: number, handle: Buffer) => void): this;
|
2053 | on(event: "LSTAT", listener: (reqId: number, path: string) => void): this;
|
2054 | on(event: "STAT", listener: (reqId: number, path: string) => void): this;
|
2055 | on(event: "REMOVE", listener: (reqId: number, path: string) => void): this;
|
2056 | on(event: "RMDIR", listener: (reqId: number, path: string) => void): this;
|
2057 | on(event: "REALPATH", listener: (reqId: number, path: string) => void): this;
|
2058 | on(event: "READLINK", listener: (reqId: number, path: string) => void): this;
|
2059 | on(event: "SETSTAT", listener: (reqId: number, path: string, attrs: Attributes) => void): this;
|
2060 | on(event: "MKDIR", listener: (reqId: number, path: string, attrs: Attributes) => void): this;
|
2061 | on(event: "RENAME", listener: (reqId: number, oldPath: string, newPath: string) => void): this;
|
2062 | on(event: "SYMLINK", listener: (reqId: number, targetPath: string, linkPath: string) => void): this;
|
2063 | on(event: "EXTENDED", listener: (reqId: number, extName: string, extData: Buffer) => void): this;
|
2064 | on(event: string | symbol, listener: Function): this;
|
2065 |
|
2066 | |
2067 |
|
2068 |
|
2069 | once(event: "ready", listener: () => void): this;
|
2070 | once(event: "OPEN", listener: (reqId: number, filename: string, flags: number, attrs: Attributes) => void): this;
|
2071 | once(event: "READ", listener: (reqId: number, handle: Buffer, offset: number, len: number) => void): this;
|
2072 | once(event: "WRITE", listener: (reqId: number, handle: Buffer, offset: number, data: Buffer) => void): this;
|
2073 | once(event: "FSTAT", listener: (reqId: number, handle: Buffer) => void): this;
|
2074 | once(event: "FSETSTAT", listener: (reqId: number, handle: Buffer, attrs: Attributes) => void): this;
|
2075 | once(event: "CLOSE", listener: (reqId: number, handle: Buffer) => void): this;
|
2076 | once(event: "OPENDIR", listener: (reqId: number, path: string) => void): this;
|
2077 | once(event: "READDIR", listener: (reqId: number, handle: Buffer) => void): this;
|
2078 | once(event: "LSTAT", listener: (reqId: number, path: string) => void): this;
|
2079 | once(event: "STAT", listener: (reqId: number, path: string) => void): this;
|
2080 | once(event: "REMOVE", listener: (reqId: number, path: string) => void): this;
|
2081 | once(event: "RMDIR", listener: (reqId: number, path: string) => void): this;
|
2082 | once(event: "REALPATH", listener: (reqId: number, path: string) => void): this;
|
2083 | once(event: "READLINK", listener: (reqId: number, path: string) => void): this;
|
2084 | once(event: "SETSTAT", listener: (reqId: number, path: string, attrs: Attributes) => void): this;
|
2085 | once(event: "MKDIR", listener: (reqId: number, path: string, attrs: Attributes) => void): this;
|
2086 | once(event: "RENAME", listener: (reqId: number, oldPath: string, newPath: string) => void): this;
|
2087 | once(event: "SYMLINK", listener: (reqId: number, targetPath: string, linkPath: string) => void): this;
|
2088 | once(event: "EXTENDED", listener: (reqId: number, extName: string, extData: Buffer) => void): this;
|
2089 | once(event: string | symbol, listener: Function): this;
|
2090 |
|
2091 | |
2092 |
|
2093 |
|
2094 | status(reqId: number, code: number, message?: string): void;
|
2095 |
|
2096 | |
2097 |
|
2098 |
|
2099 |
|
2100 |
|
2101 | handle(reqId: number, handle: Buffer): void;
|
2102 |
|
2103 | |
2104 |
|
2105 |
|
2106 |
|
2107 | data(reqId: number, data: Buffer | string, encoding?: BufferEncoding): void;
|
2108 |
|
2109 | |
2110 |
|
2111 |
|
2112 | name(reqId: number, names: FileEntry[]): void;
|
2113 |
|
2114 | |
2115 |
|
2116 |
|
2117 | attrs(reqId: number, attrs: Attributes): void;
|
2118 |
|
2119 | |
2120 |
|
2121 |
|
2122 | end(): void;
|
2123 |
|
2124 | |
2125 |
|
2126 |
|
2127 | destroy(): void;
|
2128 | }
|
2129 |
|
2130 | export interface PublicKeyEntry {
|
2131 | pubKey:
|
2132 | | ParsedKey
|
2133 | | {
|
2134 | pubKey: ParsedKey | Buffer | string;
|
2135 | comment?: string;
|
2136 | };
|
2137 | }
|
2138 |
|
2139 | export type KnownPublicKeys<T extends string | Buffer | ParsedKey = string | Buffer | ParsedKey> = Array<
|
2140 | | T
|
2141 | | PublicKeyEntry
|
2142 | >;
|
2143 |
|
2144 | export type PrivateKeys = Array<Buffer | ParsedKey | EncryptedPrivateKey | string>;
|
2145 |
|
2146 | export type Callback = (err?: Error | null) => void;
|
2147 |
|
2148 | export type ErrorCallback = (err: Error) => void;
|
2149 |
|
2150 | export type IdentityCallback<T extends string | Buffer | ParsedKey = string | Buffer | ParsedKey> = (
|
2151 | err?: Error | null,
|
2152 | keys?: KnownPublicKeys<T>,
|
2153 | ) => void;
|
2154 |
|
2155 | export type SignCallback = (err?: Error | null, signature?: Buffer) => void;
|
2156 |
|
2157 | export type GetStreamCallback = (err?: Error | null, stream?: Duplex) => void;
|
2158 |
|
2159 |
|
2160 |
|
2161 |
|
2162 |
|
2163 |
|
2164 | export interface AgentInboundRequest {
|
2165 | __opaque_type: never;
|
2166 | }
|
2167 |
|
2168 | export interface SigningRequestOptions {
|
2169 | hash?: "sha1" | "sha256" | "sha512";
|
2170 | }
|
2171 |
|
2172 | export class AgentProtocol extends Duplex {
|
2173 | |
2174 |
|
2175 |
|
2176 |
|
2177 | constructor(isClient: boolean);
|
2178 |
|
2179 | /**
|
2180 | * (Server mode only)
|
2181 | * Replies to the given `request` with a failure response.
|
2182 | */
|
2183 | failureReply(request: AgentInboundRequest): void;
|
2184 |
|
2185 | /**
|
2186 | * (Client mode only)
|
2187 | * Requests a list of public keys from the agent. `callback` is passed
|
2188 | * `(err, keys)` where `keys` is a possible array of public keys for
|
2189 | * authentication.
|
2190 | */
|
2191 | getIdentities(callback: (err: Error | undefined, publicKeys?: ParsedKey[]) => void): void;
|
2192 |
|
2193 | /**
|
2194 | * (Server mode only)
|
2195 | * Responds to a identities list `request` with the given array of keys in `keys`.
|
2196 | */
|
2197 | getIdentitiesReply(request: AgentInboundRequest, keys: ParsedKey[]): void;
|
2198 |
|
2199 | /**
|
2200 | * (Client mode only)
|
2201 | * Signs the datawith the given public key, and calls back with its signature.
|
2202 | */
|
2203 | sign(
|
2204 | pubKey: ParsedKey | Buffer | string,
|
2205 | data: Buffer,
|
2206 | options?: SigningRequestOptions,
|
2207 | callback?: SignCallback,
|
2208 | ): boolean;
|
2209 | sign(pubKey: ParsedKey | Buffer | string, data: Buffer, callback?: SignCallback): boolean;
|
2210 |
|
2211 | /**
|
2212 | * (Server mode only)
|
2213 | * Responds to a sign `request` with the given signature in `signature`.
|
2214 | */
|
2215 | signReply(request: AgentInboundRequest, signature: Buffer): void;
|
2216 |
|
2217 | /**
|
2218 | * (Server mode only)
|
2219 | * The client has requested a list of public keys stored in the agent.
|
2220 | * Use `failureReply()` or `getIdentitiesReply()` to reply appropriately.
|
2221 | */
|
2222 | on(event: "identities", listener: (req: AgentInboundRequest) => void): this;
|
2223 |
|
2224 | /**
|
2225 | * (Server mode only)
|
2226 | * The client has requested `data` to be signed using the key identified
|
2227 | * by `pubKey`. Use `failureReply()` or `signReply()` to reply appropriately.
|
2228 | */
|
2229 | on(
|
2230 | event: "sign",
|
2231 | listener: (req: AgentInboundRequest, pubKey: ParsedKey, data: Buffer, options: SigningRequestOptions) => void,
|
2232 | ): this;
|
2233 |
|
2234 | on(event: string | symbol, listener: Function): this;
|
2235 |
|
2236 | /**
|
2237 | * (Server mode only)
|
2238 | * The client has requested a list of public keys stored in the agent.
|
2239 | * Use `failureReply()` or `getIdentitiesReply()` to reply appropriately.
|
2240 | */
|
2241 | once(event: "identities", listener: (req: AgentInboundRequest) => void): this;
|
2242 |
|
2243 | /**
|
2244 | * (Server mode only)
|
2245 | * The client has requested `data` to be signed using the key identified
|
2246 | * by `pubKey`. Use `failureReply()` or `signReply()` to reply appropriately.
|
2247 | */
|
2248 | once(
|
2249 | event: "sign",
|
2250 | listener: (req: AgentInboundRequest, pubKey: ParsedKey, data: Buffer, options: SigningRequestOptions) => void,
|
2251 | ): this;
|
2252 |
|
2253 | once(event: string | symbol, listener: Function): this;
|
2254 | }
|
2255 |
|
2256 | /**
|
2257 | * Creates and returns a new agent instance using the same logic as the
|
2258 | * `Client`'s `agent` configuration option: if the platform is Windows and
|
2259 | * it's the value "pageant", it creates a `PageantAgent`, otherwise if it's not
|
2260 | * a path to a Windows pipe it creates a `CygwinAgent`. In all other cases,
|
2261 | * it creates an `OpenSSHAgent`.
|
2262 | */
|
2263 | export function createAgent(socketPath: string | "pageant"): BaseAgent;
|
2264 |
|
2265 | export abstract class BaseAgent<TPublicKey extends string | Buffer | ParsedKey = string | Buffer | ParsedKey> {
|
2266 | |
2267 |
|
2268 |
|
2269 |
|
2270 | abstract getIdentities(cb: IdentityCallback<TPublicKey>): void;
|
2271 |
|
2272 | |
2273 |
|
2274 |
|
2275 |
|
2276 | abstract sign(pubKey: TPublicKey, data: Buffer, options: SigningRequestOptions, cb?: SignCallback): void;
|
2277 | abstract sign(pubKey: TPublicKey, data: Buffer, cb: SignCallback): void;
|
2278 |
|
2279 | |
2280 |
|
2281 |
|
2282 |
|
2283 |
|
2284 |
|
2285 |
|
2286 | getStream?(cb: GetStreamCallback): void;
|
2287 | }
|
2288 |
|
2289 |
|
2290 |
|
2291 |
|
2292 | export class OpenSSHAgent extends BaseAgent<ParsedKey> {
|
2293 | constructor(socketPath: string);
|
2294 |
|
2295 | /** @inheritdoc */
|
2296 | getIdentities(cb: IdentityCallback<ParsedKey>): void;
|
2297 |
|
2298 | /** @inheritdoc */
|
2299 | sign(
|
2300 | pubKey: ParsedKey | Buffer | string,
|
2301 | data: Buffer,
|
2302 | options?: SigningRequestOptions,
|
2303 | cb?: SignCallback,
|
2304 | ): boolean;
|
2305 | sign(pubKey: ParsedKey | Buffer | string, data: Buffer, cb?: SignCallback): boolean;
|
2306 |
|
2307 | /** @inheritdoc */
|
2308 | getStream(cb: GetStreamCallback): void;
|
2309 | }
|
2310 |
|
2311 | /**
|
2312 | * Communicates with an agent listening at `socketPath` in a Cygwin environment.
|
2313 | */
|
2314 | export class CygwinAgent extends OpenSSHAgent {}
|
2315 |
|
2316 |
|
2317 |
|
2318 |
|
2319 | export class PageantAgent extends OpenSSHAgent {}
|
2320 |
|
2321 | export interface NegotiatedAlgorithms {
|
2322 | kex: KexAlgorithm;
|
2323 | serverHostKey: ServerHostKeyAlgorithm;
|
2324 | cs: {
|
2325 | cipher: CipherAlgorithm;
|
2326 | mac: MacAlgorithm | "";
|
2327 | compress: CompressionAlgorithm;
|
2328 | lang: string;
|
2329 | };
|
2330 | sc: {
|
2331 | cipher: CipherAlgorithm;
|
2332 | mac: MacAlgorithm | "";
|
2333 | compress: CompressionAlgorithm;
|
2334 | lang: string;
|
2335 | };
|
2336 | }
|
2337 |
|
2338 | export type VerifyCallback = (valid: boolean) => void;
|
2339 |
|
2340 | export interface ReadStreamOptions extends ReadableOptions {
|
2341 | flags?: OpenMode;
|
2342 | mode?: number;
|
2343 | start?: number;
|
2344 | end?: number;
|
2345 | autoClose?: boolean;
|
2346 | handle?: Buffer;
|
2347 | }
|
2348 |
|
2349 | export interface WriteStreamOptions extends WritableOptions {
|
2350 | flags?: OpenMode;
|
2351 | mode?: number;
|
2352 | start?: number;
|
2353 | autoClose?: boolean;
|
2354 | handle?: Buffer;
|
2355 | encoding?: BufferEncoding;
|
2356 | }
|
2357 |
|
2358 | export interface ReadStream extends Readable {
|
2359 | pending: boolean;
|
2360 | open(): void;
|
2361 | close(cb: Callback): void;
|
2362 | on(eventName: "ready", listener: () => void): this;
|
2363 | on(eventName: "open", listener: (handle: Buffer) => void): this;
|
2364 | on(event: string | symbol, listener: Function): this;
|
2365 | once(eventName: "ready", listener: () => void): this;
|
2366 | once(eventName: "open", listener: (handle: Buffer) => void): this;
|
2367 | once(event: string | symbol, listener: Function): this;
|
2368 | }
|
2369 |
|
2370 | export interface WriteStream extends Writable {
|
2371 | pending: boolean;
|
2372 | open(): void;
|
2373 | destroy(): this;
|
2374 | close(cb: Callback): void;
|
2375 | on(eventName: "ready", listener: () => void): this;
|
2376 | on(eventName: "open", listener: (handle: Buffer) => void): this;
|
2377 | on(event: string | symbol, listener: Function): this;
|
2378 | once(eventName: "ready", listener: () => void): this;
|
2379 | once(eventName: "open", listener: (handle: Buffer) => void): this;
|
2380 | once(event: string | symbol, listener: Function): this;
|
2381 | }
|
2382 |
|
2383 | export type ClientCallback = (err: Error | undefined, channel: ClientChannel) => void;
|
2384 |
|
2385 | export type ServerCallback = (err: Error | undefined, channel: ServerChannel) => void;
|
2386 |
|
2387 | export type ClientForwardCallback = (err: Error | undefined, port: number) => void;
|
2388 |
|
2389 | export type ClientSFTPCallback = (err: Error | undefined, sftp: SFTPWrapper) => void;
|
2390 |
|
2391 | export type ChangePasswordCallback = (newPassword: string) => void;
|
2392 |
|
2393 | export type KeyboardInteractiveCallback = (answers: string[]) => void;
|
2394 |
|
2395 | export interface UNIXConnectionDetails {
|
2396 | socketPath: string;
|
2397 | }
|
2398 |
|
2399 | export interface HTTPAgentOptions extends BaseHTTPAgentOptions {
|
2400 | srcIP?: string;
|
2401 | }
|
2402 |
|
2403 | export class HTTPAgent extends BaseHTTPAgent {
|
2404 | constructor(connectCfg: ConnectConfig, agentOptions: HTTPAgentOptions);
|
2405 | }
|
2406 |
|
2407 | export interface HTTPSAgentOptions extends BaseHTTPSAgentOptions {
|
2408 | srcIP?: string;
|
2409 | }
|
2410 |
|
2411 | export class HTTPSAgent extends BaseHTTPSAgent {
|
2412 | constructor(connectCfg: ConnectConfig, agentOptions: HTTPSAgentOptions);
|
2413 | }
|