inkish 0.0.1-beta.1
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/dist/components/SessionContext.d.ts +4 -0
- package/dist/components/SessionContext.d.ts.map +1 -0
- package/dist/components/SessionContext.js +4 -0
- package/dist/components/SessionContext.js.map +1 -0
- package/dist/components/SshApp.d.ts +8 -0
- package/dist/components/SshApp.d.ts.map +1 -0
- package/dist/components/SshApp.js +7 -0
- package/dist/components/SshApp.js.map +1 -0
- package/dist/hooks/useSession.d.ts +2 -0
- package/dist/hooks/useSession.d.ts.map +1 -0
- package/dist/hooks/useSession.js +6 -0
- package/dist/hooks/useSession.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/ink.d.ts +4 -0
- package/dist/ink.d.ts.map +1 -0
- package/dist/ink.js +43 -0
- package/dist/ink.js.map +1 -0
- package/dist/middleware.d.ts +4 -0
- package/dist/middleware.d.ts.map +1 -0
- package/dist/middleware.js +22 -0
- package/dist/middleware.js.map +1 -0
- package/dist/server.d.ts +4 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +108 -0
- package/dist/server.js.map +1 -0
- package/dist/types.d.ts +31 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +38 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SessionContext.d.ts","sourceRoot":"","sources":["../../src/components/SessionContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,QAAA,MAAM,cAAc,8CAAgD,CAAC;AAErE,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SessionContext.js","sourceRoot":"","sources":["../../src/components/SessionContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAGtC,MAAM,cAAc,GAAG,aAAa,CAAsB,SAAS,CAAC,CAAC;AAErE,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { Session } from "../types.js";
|
|
3
|
+
declare const SshApp: ({ children, session, }: {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
session: Session;
|
|
6
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export default SshApp;
|
|
8
|
+
//# sourceMappingURL=SshApp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SshApp.d.ts","sourceRoot":"","sources":["../../src/components/SshApp.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,QAAA,MAAM,MAAM,GAAI,wBAGb;IACD,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;CAClB,4CAMA,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import SessionContext from "./SessionContext.js";
|
|
3
|
+
const SshApp = ({ children, session, }) => {
|
|
4
|
+
return (_jsx(SessionContext.Provider, { value: session, children: children }));
|
|
5
|
+
};
|
|
6
|
+
export default SshApp;
|
|
7
|
+
//# sourceMappingURL=SshApp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SshApp.js","sourceRoot":"","sources":["../../src/components/SshApp.tsx"],"names":[],"mappings":";AAEA,OAAO,cAAc,MAAM,qBAAqB,CAAC;AAGjD,MAAM,MAAM,GAAG,CAAC,EACd,QAAQ,EACR,OAAO,GAIR,EAAE,EAAE;IACH,OAAO,CACL,KAAC,cAAc,CAAC,QAAQ,IAAC,KAAK,EAAE,OAAO,YACpC,QAAQ,GACe,CAC3B,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSession.d.ts","sourceRoot":"","sources":["../../src/hooks/useSession.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,UAAU,iDAEtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSession.js","sourceRoot":"","sources":["../../src/hooks/useSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,cAAc,MAAM,iCAAiC,CAAC;AAE7D,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,EAAE;IAC7B,OAAO,UAAU,CAAC,cAAc,CAAC,CAAC;AACpC,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,YAAY,EACV,OAAO,EACP,OAAO,EACP,UAAU,EACV,WAAW,EACX,GAAG,GACJ,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/ink.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ink.d.ts","sourceRoot":"","sources":["../src/ink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,KAAK,EAAW,WAAW,EAAE,UAAU,EAAW,MAAM,YAAY,CAAC;AAa5E,wBAAgB,aAAa,CAC3B,GAAG,EAAE,YAAY,EACjB,MAAM,EAAE,WAAW,GAClB,UAAU,CAyCZ"}
|
package/dist/ink.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import SshApp from "./components/SshApp.js";
|
|
2
|
+
export function inkMiddleware(app, render) {
|
|
3
|
+
return (next) => async (session) => {
|
|
4
|
+
const channel = session.channel;
|
|
5
|
+
channel.columns = session.pty.cols;
|
|
6
|
+
channel.rows = session.pty.rows;
|
|
7
|
+
channel.isTTY = true;
|
|
8
|
+
channel.setRawMode = () => { };
|
|
9
|
+
if (!channel.ref)
|
|
10
|
+
channel.ref = () => { };
|
|
11
|
+
if (!channel.unref)
|
|
12
|
+
channel.unref = () => { };
|
|
13
|
+
const write = channel.write.bind(channel);
|
|
14
|
+
channel.write = (...args) => {
|
|
15
|
+
if (typeof args[0] === "string") {
|
|
16
|
+
args[0] = args[0].replace(/\r?\n/g, "\r\n");
|
|
17
|
+
}
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
return write(...args);
|
|
20
|
+
};
|
|
21
|
+
session.onResize((pty) => {
|
|
22
|
+
channel.columns = pty.cols;
|
|
23
|
+
channel.rows = pty.rows;
|
|
24
|
+
channel.emit("resize");
|
|
25
|
+
});
|
|
26
|
+
const instance = render(SshApp({ children: app, session }), {
|
|
27
|
+
stdout: channel,
|
|
28
|
+
stdin: channel,
|
|
29
|
+
stderr: channel.stderr,
|
|
30
|
+
patchConsole: false,
|
|
31
|
+
});
|
|
32
|
+
channel.on("close", () => instance.unmount());
|
|
33
|
+
try {
|
|
34
|
+
await instance.waitUntilExit();
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
}
|
|
38
|
+
finally {
|
|
39
|
+
session.close();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|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AC,GAAG,EAAE,EAAE;YACvB,OAAO,CAAC,OAAO,GAAG,GAAG,CAAC,IAAI,CAAC;YAC3B,OAAO,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;YACxB,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;QAEH,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,EAAE;YAC1D,MAAM,EAAE,OAAc;YACtB,KAAK,EAAE,OAAc;YACrB,MAAM,EAAE,OAAO,CAAC,MAAa;YAC7B,YAAY,EAAE,KAAK;SACpB,CAAC,CAAC;QAEH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;QAE9C,IAAI,CAAC;YACH,MAAM,QAAQ,CAAC,aAAa,EAAE,CAAC;QACjC,CAAC;QAAC,MAAM,CAAC;QACT,CAAC;gBAAS,CAAC;YACT,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,CAAC;IACH,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,eAAO,MAAM,0BAA0B,QAAO,UAW7C,CAAC;AAEF,wBAAgB,wBAAwB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,UAAU,CAYrE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const blockAllCommandsMiddleware = () => {
|
|
2
|
+
const message = "access denied\r\n";
|
|
3
|
+
return (next) => (session) => {
|
|
4
|
+
if (session.command) {
|
|
5
|
+
session.channel.write(message);
|
|
6
|
+
session.close();
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
return next(session);
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export function activeTerminalMiddleware(message) {
|
|
13
|
+
return (next) => (session) => {
|
|
14
|
+
if (!session.hasPty) {
|
|
15
|
+
session.channel.write(message ?? "this server requires a PTY. Please use: ssh -t\r\n");
|
|
16
|
+
session.close();
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
return next(session);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAe,EAAE;IACzD,MAAM,OAAO,GAAG,mBAAmB,CAAC;IAEpC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE;QAC3B,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAC/B,OAAO,CAAC,KAAK,EAAE,CAAC;YAChB,OAAO;QACT,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,UAAU,wBAAwB,CAAC,OAAgB;IACvD,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE;QAC3B,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACpB,OAAO,CAAC,OAAO,CAAC,KAAK,CACnB,OAAO,IAAI,oDAAoD,CAChE,CAAC;YACF,OAAO,CAAC,KAAK,EAAE,CAAC;YAChB,OAAO;QACT,CAAC;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAIV,WAAW,EAEX,OAAO,EACR,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAqG1C,eAAO,MAAM,WAAW,GACtB,KAAK,YAAY,EACjB,QAAQ,WAAW,EACnB,SAAS,OAAO,SA2BjB,CAAC"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import ssh2 from "ssh2";
|
|
2
|
+
import { readFileSync, existsSync, writeFileSync, mkdirSync } from "node:fs";
|
|
3
|
+
import { generateKeyPairSync } from "node:crypto";
|
|
4
|
+
import { dirname } from "node:path";
|
|
5
|
+
import EventEmitter from "node:events";
|
|
6
|
+
import { activeTerminalMiddleware, blockAllCommandsMiddleware, } from "./middleware.js";
|
|
7
|
+
import { inkMiddleware } from "./ink.js";
|
|
8
|
+
const compose = (middleware, base) => {
|
|
9
|
+
return middleware.reduce((next, mw) => mw(next), base);
|
|
10
|
+
};
|
|
11
|
+
const DEFAULT_HOST_KEY_PATH = ".ssh/host_key";
|
|
12
|
+
const DEFAULT_HOSTNAME = "";
|
|
13
|
+
const DEFAULT_PORT = 2222;
|
|
14
|
+
const resolveHostKey = (options) => {
|
|
15
|
+
if (options.hostKey)
|
|
16
|
+
return options.hostKey;
|
|
17
|
+
const keyPath = options.hostKeyPath ?? DEFAULT_HOST_KEY_PATH;
|
|
18
|
+
if (existsSync(keyPath))
|
|
19
|
+
return readFileSync(keyPath);
|
|
20
|
+
const { privateKey } = generateKeyPairSync("rsa", {
|
|
21
|
+
modulusLength: 2048,
|
|
22
|
+
publicKeyEncoding: { type: "spki", format: "pem" },
|
|
23
|
+
privateKeyEncoding: { type: "pkcs1", format: "pem" },
|
|
24
|
+
});
|
|
25
|
+
try {
|
|
26
|
+
mkdirSync(dirname(keyPath), { recursive: true });
|
|
27
|
+
writeFileSync(keyPath, privateKey, { mode: 0o600 });
|
|
28
|
+
}
|
|
29
|
+
catch { }
|
|
30
|
+
return privateKey;
|
|
31
|
+
};
|
|
32
|
+
const onSession = (sshSession, app, render, remoteAddr, user) => {
|
|
33
|
+
const pty = {
|
|
34
|
+
cols: 80,
|
|
35
|
+
rows: 24,
|
|
36
|
+
width: 0,
|
|
37
|
+
height: 0,
|
|
38
|
+
term: "xterm-256color",
|
|
39
|
+
};
|
|
40
|
+
let hasPty = false;
|
|
41
|
+
const resizeEvents = new EventEmitter();
|
|
42
|
+
const onResize = (callback) => {
|
|
43
|
+
resizeEvents.on("resize", callback);
|
|
44
|
+
};
|
|
45
|
+
const middleware = getMiddleware(app, render);
|
|
46
|
+
sshSession.on("pty", (accept, _reject, info) => {
|
|
47
|
+
hasPty = true;
|
|
48
|
+
pty.cols = info.cols;
|
|
49
|
+
pty.rows = info.rows;
|
|
50
|
+
pty.width = info.width;
|
|
51
|
+
pty.height = info.height;
|
|
52
|
+
pty.term = info.term;
|
|
53
|
+
accept?.();
|
|
54
|
+
});
|
|
55
|
+
sshSession.on("window-change", (accept, _reject, info) => {
|
|
56
|
+
pty.cols = info.cols;
|
|
57
|
+
pty.rows = info.rows;
|
|
58
|
+
pty.width = info.width;
|
|
59
|
+
pty.height = info.height;
|
|
60
|
+
resizeEvents.emit("resize", pty);
|
|
61
|
+
accept?.();
|
|
62
|
+
});
|
|
63
|
+
const makeSession = (channel, command) => ({
|
|
64
|
+
channel,
|
|
65
|
+
pty,
|
|
66
|
+
hasPty,
|
|
67
|
+
user,
|
|
68
|
+
remoteAddr,
|
|
69
|
+
command,
|
|
70
|
+
onResize,
|
|
71
|
+
close: () => channel.close(),
|
|
72
|
+
});
|
|
73
|
+
sshSession.on("shell", (accept) => {
|
|
74
|
+
middleware(makeSession(accept()));
|
|
75
|
+
});
|
|
76
|
+
sshSession.on("exec", (accept, _reject, info) => {
|
|
77
|
+
middleware(makeSession(accept(), info.command));
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
const getMiddleware = (app, render) => {
|
|
81
|
+
return compose([
|
|
82
|
+
activeTerminalMiddleware(),
|
|
83
|
+
blockAllCommandsMiddleware(),
|
|
84
|
+
inkMiddleware(app, render),
|
|
85
|
+
], () => { });
|
|
86
|
+
};
|
|
87
|
+
export const startServer = (app, render, options) => {
|
|
88
|
+
const server = new ssh2.Server({ hostKeys: [resolveHostKey(options)] });
|
|
89
|
+
const hostname = options.hostname ?? DEFAULT_HOSTNAME;
|
|
90
|
+
const port = options.port ?? DEFAULT_PORT;
|
|
91
|
+
server.on("connection", (client, info) => {
|
|
92
|
+
let user = "";
|
|
93
|
+
client.on("error", () => { });
|
|
94
|
+
client.on("authentication", (ctx) => {
|
|
95
|
+
user = ctx.username;
|
|
96
|
+
ctx.accept();
|
|
97
|
+
});
|
|
98
|
+
client.on("ready", () => {
|
|
99
|
+
client.on("session", (accept) => {
|
|
100
|
+
const sshSession = accept();
|
|
101
|
+
onSession(sshSession, app, render, info.ip, user);
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
server.on("error", () => { });
|
|
106
|
+
server.listen(port, hostname, options.listenCallback);
|
|
107
|
+
};
|
|
108
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUpC,OAAO,YAAY,MAAM,aAAa,CAAC;AACvC,OAAO,EACL,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,OA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,YAAY,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;QACvC,IAAI,IAAI,GAAG,EAAE,CAAC;QAEd,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QAE7B,MAAM,CAAC,EAAE,CAAC,gBAAgB,EAAE,CAAC,GAAQ,EAAE,EAAE;YACvC,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC;YACpB,GAAG,CAAC,MAAM,EAAE,CAAC;QACf,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;YACtB,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,MAAW,EAAE,EAAE;gBACnC,MAAM,UAAU,GAAG,MAAM,EAAE,CAAC;gBAC5B,SAAS,CAAC,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;YACpD,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAE7B,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;AACxD,CAAC,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ServerChannel } from "ssh2";
|
|
2
|
+
import type { RenderOptions, Instance } from "ink";
|
|
3
|
+
import type { ReactNode } from "react";
|
|
4
|
+
export interface Options {
|
|
5
|
+
hostname?: string;
|
|
6
|
+
port?: number;
|
|
7
|
+
hostKeyPath?: string;
|
|
8
|
+
hostKey?: Buffer | string;
|
|
9
|
+
listenCallback?: () => void;
|
|
10
|
+
}
|
|
11
|
+
export interface Pty {
|
|
12
|
+
cols: number;
|
|
13
|
+
rows: number;
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
term: string;
|
|
17
|
+
}
|
|
18
|
+
export interface Session {
|
|
19
|
+
channel: ServerChannel;
|
|
20
|
+
pty: Pty;
|
|
21
|
+
hasPty: boolean;
|
|
22
|
+
user: string;
|
|
23
|
+
remoteAddr: string;
|
|
24
|
+
command?: string;
|
|
25
|
+
onResize(callback: (pty: Pty) => void): void;
|
|
26
|
+
close(): void;
|
|
27
|
+
}
|
|
28
|
+
export type Handler = (session: Session) => void | Promise<void>;
|
|
29
|
+
export type Middleware = (next: Handler) => Handler;
|
|
30
|
+
export type InkRenderer = (node: ReactNode, options?: NodeJS.WriteStream | RenderOptions) => Instance;
|
|
31
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,aAAa,CAAC;IACvB,GAAG,EAAE,GAAG,CAAC;IACT,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI,CAAC;IAC7C,KAAK,IAAI,IAAI,CAAC;CACf;AAED,MAAM,MAAM,OAAO,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAEjE,MAAM,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC;AAEpD,MAAM,MAAM,WAAW,GAAG,CACxB,IAAI,EAAE,SAAS,EACf,OAAO,CAAC,EAAE,MAAM,CAAC,WAAW,GAAG,aAAa,KACzC,QAAQ,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "inkish",
|
|
3
|
+
"version": "0.0.1-beta.1",
|
|
4
|
+
"description": "React for SSH apps",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"dev": "tsc --watch",
|
|
17
|
+
"example:counter": "tsx examples/counter.tsx",
|
|
18
|
+
"example:menu": "tsx examples/menu.tsx",
|
|
19
|
+
"example:chat": "tsx examples/chat.tsx"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"ssh2": "^1.17.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/node": "^22.19.10",
|
|
29
|
+
"@types/react": "^18.0.0",
|
|
30
|
+
"@types/ssh2": "^1.15.5",
|
|
31
|
+
"ink": "^6.7.0",
|
|
32
|
+
"react": "^19.2.4",
|
|
33
|
+
"tsx": "^4.0.0",
|
|
34
|
+
"typescript": "^5.0.0"
|
|
35
|
+
},
|
|
36
|
+
"author": "cpendery",
|
|
37
|
+
"license": "MIT"
|
|
38
|
+
}
|