@patimweb/pi-ssh 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/types.ts CHANGED
@@ -25,6 +25,53 @@ export interface SshProfile {
25
25
  */
26
26
  readonly strictHostKey?: boolean;
27
27
  readonly connectTimeoutMs?: number;
28
+ /**
29
+ * Upgrade this profile to key authentication on first use, replacing the
30
+ * stored password. On by default; set to false to keep using the password.
31
+ */
32
+ readonly autoKey?: boolean;
33
+ /** Named port forwards that ssh_tunnel can start by name. */
34
+ readonly tunnels?: Record<string, TunnelDefinition>;
35
+ }
36
+
37
+ /** A tunnel that is currently running. */
38
+ export interface RunningTunnel {
39
+ readonly id: string;
40
+ readonly profile: string;
41
+ readonly name: string;
42
+ readonly definition: TunnelDefinition;
43
+ /** Where it actually listens, which matters when listenPort was 0. */
44
+ readonly listenAddress: string;
45
+ readonly startedAt: string;
46
+ readonly connections: number;
47
+ /** Set when the tunnel closes itself after a fixed time. */
48
+ readonly expiresAt?: string;
49
+ }
50
+
51
+ /**
52
+ * A port forward, stored by name in a profile.
53
+ *
54
+ * The same shape describes both directions, and `kind` decides whose machine
55
+ * each side refers to:
56
+ *
57
+ * local (ssh -L): this machine listens on bind:listenPort, and the server
58
+ * opens the connection to destHost:destPort.
59
+ * remote (ssh -R): the server listens on bind:listenPort, and this machine
60
+ * opens the connection to destHost:destPort.
61
+ */
62
+ export interface TunnelDefinition {
63
+ readonly kind: "local" | "remote";
64
+ /** Port the tunnel accepts connections on. */
65
+ readonly listenPort: number;
66
+ /**
67
+ * Interface to bind that port to. Defaults to 127.0.0.1: binding to
68
+ * 0.0.0.0 publishes the forwarded service to the whole network.
69
+ */
70
+ readonly bind?: string;
71
+ /** Where traffic is delivered. */
72
+ readonly destHost: string;
73
+ readonly destPort: number;
74
+ readonly description?: string;
28
75
  }
29
76
 
30
77
  export interface SshProfiles {
@@ -95,6 +142,7 @@ export interface SetupParams {
95
142
  readonly privateKeyPath?: string;
96
143
  readonly passphrase?: string;
97
144
  readonly strictHostKey?: boolean;
145
+ readonly autoKey?: boolean;
98
146
  }
99
147
 
100
148
  // Errors
@@ -133,6 +181,13 @@ export class SshAuthError extends Error {
133
181
  }
134
182
  }
135
183
 
184
+ export class TunnelError extends Error {
185
+ constructor(message: string) {
186
+ super(message);
187
+ this.name = "TunnelError";
188
+ }
189
+ }
190
+
136
191
  export class RemoteCommandError extends Error {
137
192
  readonly result: ExecResult;
138
193