phirepass-widgets 0.0.13 → 0.0.15
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/cjs/loader.cjs.js +1 -1
- package/dist/cjs/phirepass-terminal.cjs.entry.js +42 -19
- package/dist/cjs/phirepass-widgets.cjs.js +1 -1
- package/dist/collection/components/phirepass-terminal/phirepass-terminal.css +8 -0
- package/dist/collection/components/phirepass-terminal/phirepass-terminal.js +48 -18
- package/dist/collection/phirepass-channel_bg.wasm +0 -0
- package/dist/components/phirepass-terminal.js +4 -4
- package/dist/esm/loader.js +1 -1
- package/dist/esm/phirepass-terminal.entry.js +42 -19
- package/dist/esm/phirepass-widgets.js +1 -1
- package/dist/phirepass-widgets/{p-11be5283.entry.js → p-e7a1889e.entry.js} +4 -4
- package/dist/phirepass-widgets/phirepass-channel_bg.wasm +0 -0
- package/dist/phirepass-widgets/phirepass-widgets.esm.js +1 -1
- package/dist/types/common/protocol.d.ts +7 -1
- package/dist/types/components/phirepass-terminal/phirepass-terminal.d.ts +7 -4
- package/dist/types/components.d.ts +4 -1
- package/package.json +4 -4
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -6,7 +6,7 @@ var appGlobals = require('./app-globals-V2Kpy_OQ.js');
|
|
|
6
6
|
const defineCustomElements = async (win, options) => {
|
|
7
7
|
if (typeof window === 'undefined') return undefined;
|
|
8
8
|
await appGlobals.globalScripts();
|
|
9
|
-
return index.bootstrapLazy([["phirepass-sftp-client.cjs",[[257,"phirepass-sftp-client"]]],["phirepass-terminal.cjs",[[513,"phirepass-terminal",{"terminalOptions":[16],"serverHost":[1,"server-host"],"serverPort":[2,"server-port"],"allowInsecure":[4,"allow-insecure"],"heartbeatInterval":[2,"heartbeat-interval"],"nodeId":[1,"node-id"],"serverId":[1,"server-id"]},null,{"nodeId":[{"onNodeIdChange":0}],"serverId":[{"onServerIdChange":0}]}]]]], options);
|
|
9
|
+
return index.bootstrapLazy([["phirepass-sftp-client.cjs",[[257,"phirepass-sftp-client"]]],["phirepass-terminal.cjs",[[513,"phirepass-terminal",{"terminalOptions":[16],"serverHost":[1,"server-host"],"serverPort":[2,"server-port"],"allowInsecure":[4,"allow-insecure"],"heartbeatInterval":[2,"heartbeat-interval"],"nodeId":[1,"node-id"],"token":[1],"serverId":[1,"server-id"]},null,{"nodeId":[{"onNodeIdChange":0}],"serverId":[{"onServerIdChange":0}]}]]]], options);
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
exports.setNonce = index.setNonce;
|
|
@@ -227,6 +227,18 @@ class Channel {
|
|
|
227
227
|
const ptr = this.__destroy_into_raw();
|
|
228
228
|
wasm.__wbg_channel_free(ptr, 0);
|
|
229
229
|
}
|
|
230
|
+
/**
|
|
231
|
+
* @param {string} token
|
|
232
|
+
* @param {string} node_id
|
|
233
|
+
* @param {number | null} [msg_id]
|
|
234
|
+
*/
|
|
235
|
+
authenticate(token, node_id, msg_id) {
|
|
236
|
+
const ptr0 = passStringToWasm0(token, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
237
|
+
const len0 = WASM_VECTOR_LEN;
|
|
238
|
+
const ptr1 = passStringToWasm0(node_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
239
|
+
const len1 = WASM_VECTOR_LEN;
|
|
240
|
+
wasm.channel_authenticate(this.__wbg_ptr, ptr0, len0, ptr1, len1, isLikeNone(msg_id) ? 0x100000001 : (msg_id) >>> 0);
|
|
241
|
+
}
|
|
230
242
|
connect() {
|
|
231
243
|
wasm.channel_connect(this.__wbg_ptr);
|
|
232
244
|
}
|
|
@@ -582,7 +594,7 @@ function __wbg_get_imports() {
|
|
|
582
594
|
__wbg_set_onopen_34e3e24cf9337ddd: function(arg0, arg1) {
|
|
583
595
|
getObject(arg0).onopen = getObject(arg1);
|
|
584
596
|
},
|
|
585
|
-
|
|
597
|
+
__wbg_warn_3ba994e68c965ce3: function(arg0, arg1) {
|
|
586
598
|
console.warn(getStringFromWasm0(arg0, arg1));
|
|
587
599
|
},
|
|
588
600
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
@@ -966,7 +978,7 @@ async function __wbg_init(module_or_path) {
|
|
|
966
978
|
return __wbg_finalize_init(instance);
|
|
967
979
|
}
|
|
968
980
|
|
|
969
|
-
const phirepassTerminalCss = () => `.xterm{cursor:text;position:relative;user-select:none;-ms-user-select:none;-webkit-user-select:none}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{position:absolute;top:0;z-index:5}.xterm .xterm-helper-textarea{padding:0;border:0;margin:0;position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-5;white-space:nowrap;overflow:hidden;resize:none}.xterm .composition-view{background:#000;color:#FFF;display:none;position:absolute;white-space:nowrap;z-index:1}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{background-color:#000;overflow-y:scroll;cursor:default;position:absolute;right:0;left:0;top:0;bottom:0}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;left:0;top:0}.xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;top:0;left:-9999em;line-height:normal}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility:not(.debug),.xterm .xterm-message{position:absolute;left:0;top:0;bottom:0;right:0;z-index:10;color:transparent;pointer-events:none}.xterm .xterm-accessibility-tree:not(.debug) *::selection{color:transparent}.xterm .xterm-accessibility-tree{font-family:monospace;user-select:text;white-space:pre}.xterm .xterm-accessibility-tree>div{transform-origin:left;width:fit-content}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}.xterm-dim{opacity:1 !important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{text-decoration:double underline}.xterm-underline-3{text-decoration:wavy underline}.xterm-underline-4{text-decoration:dotted underline}.xterm-underline-5{text-decoration:dashed underline}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:overline underline}.xterm-overline.xterm-underline-2{text-decoration:overline double underline}.xterm-overline.xterm-underline-3{text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;position:absolute;top:0;right:0;pointer-events:none}.xterm-decoration-top{z-index:2;position:relative}.xterm .xterm-scrollable-element>.scrollbar{cursor:default}.xterm .xterm-scrollable-element>.scrollbar>.scra{cursor:pointer;font-size:11px !important}.xterm .xterm-scrollable-element>.visible{opacity:1;background:rgba(0,0,0,0);transition:opacity 100ms linear;z-index:11}.xterm .xterm-scrollable-element>.invisible{opacity:0;pointer-events:none}.xterm .xterm-scrollable-element>.invisible.fade{transition:opacity 800ms linear}.xterm .xterm-scrollable-element>.shadow{position:absolute;display:none}.xterm .xterm-scrollable-element>.shadow.top{display:block;top:0;left:3px;height:3px;width:100%;box-shadow:var(--vscode-scrollbar-shadow, #000) 0 6px 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.left{display:block;top:3px;left:0;height:100%;width:3px;box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.top-left-corner{display:block;top:0;left:0;height:3px;width:3px}.xterm .xterm-scrollable-element>.shadow.top.left{box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}:host{display:block;width:100%;height:100%}:host #ccc{width:inherit;height:inherit}`;
|
|
981
|
+
const phirepassTerminalCss = () => `.xterm{cursor:text;position:relative;user-select:none;-ms-user-select:none;-webkit-user-select:none}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{position:absolute;top:0;z-index:5}.xterm .xterm-helper-textarea{padding:0;border:0;margin:0;position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-5;white-space:nowrap;overflow:hidden;resize:none}.xterm .composition-view{background:#000;color:#FFF;display:none;position:absolute;white-space:nowrap;z-index:1}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{background-color:#000;overflow-y:scroll;cursor:default;position:absolute;right:0;left:0;top:0;bottom:0}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;left:0;top:0}.xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;top:0;left:-9999em;line-height:normal}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility:not(.debug),.xterm .xterm-message{position:absolute;left:0;top:0;bottom:0;right:0;z-index:10;color:transparent;pointer-events:none}.xterm .xterm-accessibility-tree:not(.debug) *::selection{color:transparent}.xterm .xterm-accessibility-tree{font-family:monospace;user-select:text;white-space:pre}.xterm .xterm-accessibility-tree>div{transform-origin:left;width:fit-content}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}.xterm-dim{opacity:1 !important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{text-decoration:double underline}.xterm-underline-3{text-decoration:wavy underline}.xterm-underline-4{text-decoration:dotted underline}.xterm-underline-5{text-decoration:dashed underline}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:overline underline}.xterm-overline.xterm-underline-2{text-decoration:overline double underline}.xterm-overline.xterm-underline-3{text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;position:absolute;top:0;right:0;pointer-events:none}.xterm-decoration-top{z-index:2;position:relative}.xterm .xterm-scrollable-element>.scrollbar{cursor:default}.xterm .xterm-scrollable-element>.scrollbar>.scra{cursor:pointer;font-size:11px !important}.xterm .xterm-scrollable-element>.visible{opacity:1;background:rgba(0,0,0,0);transition:opacity 100ms linear;z-index:11}.xterm .xterm-scrollable-element>.invisible{opacity:0;pointer-events:none}.xterm .xterm-scrollable-element>.invisible.fade{transition:opacity 800ms linear}.xterm .xterm-scrollable-element>.shadow{position:absolute;display:none}.xterm .xterm-scrollable-element>.shadow.top{display:block;top:0;left:3px;height:3px;width:100%;box-shadow:var(--vscode-scrollbar-shadow, #000) 0 6px 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.left{display:block;top:3px;left:0;height:100%;width:3px;box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.top-left-corner{display:block;top:0;left:0;height:3px;width:3px}.xterm .xterm-scrollable-element>.shadow.top.left{box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}:host{display:block;width:100%;height:100%}:host #ccc{width:inherit;height:inherit}:host #ccc .terminal{height:inherit}:host #ccc .terminal .xterm-scrollable-element{height:inherit}`;
|
|
970
982
|
|
|
971
983
|
var InputMode;
|
|
972
984
|
(function (InputMode) {
|
|
@@ -1051,11 +1063,12 @@ const PhirepassTerminal = class {
|
|
|
1051
1063
|
allowInsecure = false;
|
|
1052
1064
|
heartbeatInterval = 30_000;
|
|
1053
1065
|
nodeId;
|
|
1066
|
+
token;
|
|
1054
1067
|
onNodeIdChange(newValue, _oldValue) {
|
|
1055
1068
|
// Handle the change in node_id here
|
|
1056
1069
|
// console.log(`node_id changed from ${oldValue} to ${newValue}`);
|
|
1057
1070
|
// Always clear local session state and reset terminal view
|
|
1058
|
-
this.
|
|
1071
|
+
this.reset_session_state();
|
|
1059
1072
|
this.terminal.reset();
|
|
1060
1073
|
// Close existing comms if connected
|
|
1061
1074
|
if (this.channel && this.channel.is_connected()) {
|
|
@@ -1082,9 +1095,13 @@ const PhirepassTerminal = class {
|
|
|
1082
1095
|
return `${protocol}://${this.serverHost}:${this.serverPort}`;
|
|
1083
1096
|
}
|
|
1084
1097
|
async connectedCallback() {
|
|
1098
|
+
console.log('PhirepassTerminal connected to DOM');
|
|
1085
1099
|
await __wbg_init();
|
|
1100
|
+
console.log('PhirepassChannel module initialized');
|
|
1086
1101
|
this.setup_terminal();
|
|
1102
|
+
console.log('Terminal setup complete');
|
|
1087
1103
|
this.open_comms();
|
|
1104
|
+
console.log('Comms opened');
|
|
1088
1105
|
if (!this.nodeId) {
|
|
1089
1106
|
console.warn('Prop node_id is not set. Cannot connect to terminal.');
|
|
1090
1107
|
return;
|
|
@@ -1135,8 +1152,7 @@ const PhirepassTerminal = class {
|
|
|
1135
1152
|
this.channel = new Channel(`${this.createWebSocketEndpoint()}/api/web/ws`, this.nodeId);
|
|
1136
1153
|
}
|
|
1137
1154
|
this.channel.on_connection_open(() => {
|
|
1138
|
-
this.channel.
|
|
1139
|
-
this.channel.open_ssh_tunnel(this.nodeId);
|
|
1155
|
+
this.channel.authenticate(this.token, this.nodeId);
|
|
1140
1156
|
});
|
|
1141
1157
|
this.channel.on_connection_close(() => {
|
|
1142
1158
|
this.terminal.reset();
|
|
@@ -1153,6 +1169,9 @@ const PhirepassTerminal = class {
|
|
|
1153
1169
|
case "Error":
|
|
1154
1170
|
this.handle_error(web);
|
|
1155
1171
|
break;
|
|
1172
|
+
case "AuthSuccess":
|
|
1173
|
+
this.handleAuthSuccess(web);
|
|
1174
|
+
break;
|
|
1156
1175
|
case "TunnelOpened":
|
|
1157
1176
|
this.session_id = web.sid;
|
|
1158
1177
|
this.terminal.reset();
|
|
@@ -1219,27 +1238,30 @@ const PhirepassTerminal = class {
|
|
|
1219
1238
|
this.channel.stop_heartbeat();
|
|
1220
1239
|
this.channel.disconnect();
|
|
1221
1240
|
}
|
|
1222
|
-
|
|
1241
|
+
cancel_credential_entry() {
|
|
1223
1242
|
this.inputMode = InputMode.Default;
|
|
1224
|
-
this.
|
|
1225
|
-
this.passwordBuffer = "";
|
|
1243
|
+
this.clear_creds_buffer();
|
|
1226
1244
|
this.terminal.writeln("Authentication cancelled.");
|
|
1227
1245
|
this.terminal.reset();
|
|
1228
1246
|
}
|
|
1229
|
-
|
|
1230
|
-
this.session_id = undefined;
|
|
1231
|
-
this.inputMode = InputMode.Default;
|
|
1247
|
+
clear_creds_buffer() {
|
|
1232
1248
|
this.usernameBuffer = "";
|
|
1233
1249
|
this.passwordBuffer = "";
|
|
1234
1250
|
}
|
|
1251
|
+
reset_session_state() {
|
|
1252
|
+
this.session_id = undefined;
|
|
1253
|
+
this.inputMode = InputMode.Default;
|
|
1254
|
+
this.clear_creds_buffer();
|
|
1255
|
+
}
|
|
1256
|
+
handleAuthSuccess(_auth_) {
|
|
1257
|
+
this.clear_creds_buffer();
|
|
1258
|
+
this.channel.start_heartbeat(this.heartbeatInterval <= 15_000 ? 30_000 : this.heartbeatInterval);
|
|
1259
|
+
this.channel.open_ssh_tunnel(this.nodeId);
|
|
1260
|
+
}
|
|
1235
1261
|
handleTunnelClosed() {
|
|
1236
|
-
// Clear session state
|
|
1237
1262
|
this.session_id = undefined;
|
|
1238
1263
|
this.inputMode = InputMode.Default;
|
|
1239
|
-
|
|
1240
|
-
this.usernameBuffer = "";
|
|
1241
|
-
this.passwordBuffer = "";
|
|
1242
|
-
// Reset terminal display
|
|
1264
|
+
this.clear_creds_buffer();
|
|
1243
1265
|
this.terminal.reset();
|
|
1244
1266
|
this.terminal.writeln("Connection closed.");
|
|
1245
1267
|
}
|
|
@@ -1252,6 +1274,7 @@ const PhirepassTerminal = class {
|
|
|
1252
1274
|
this.terminal.onData(this.handleTerminalData.bind(this));
|
|
1253
1275
|
this.channel.connect();
|
|
1254
1276
|
this.setupResizeObserver();
|
|
1277
|
+
console.log('Terminal connected and ready');
|
|
1255
1278
|
}
|
|
1256
1279
|
}
|
|
1257
1280
|
setupResizeObserver() {
|
|
@@ -1287,7 +1310,7 @@ const PhirepassTerminal = class {
|
|
|
1287
1310
|
}
|
|
1288
1311
|
if (data === "\u0003") {
|
|
1289
1312
|
this.terminal.write("^C\r\n");
|
|
1290
|
-
this.
|
|
1313
|
+
this.cancel_credential_entry();
|
|
1291
1314
|
return;
|
|
1292
1315
|
}
|
|
1293
1316
|
if (data === "\u007f") {
|
|
@@ -1324,7 +1347,7 @@ const PhirepassTerminal = class {
|
|
|
1324
1347
|
}
|
|
1325
1348
|
if (data === "\u0003") {
|
|
1326
1349
|
this.terminal.write("^C\r\n");
|
|
1327
|
-
this.
|
|
1350
|
+
this.cancel_credential_entry();
|
|
1328
1351
|
return;
|
|
1329
1352
|
}
|
|
1330
1353
|
if (data === "\u007f") {
|
|
@@ -1359,7 +1382,7 @@ const PhirepassTerminal = class {
|
|
|
1359
1382
|
this.usernameBuffer = "";
|
|
1360
1383
|
}
|
|
1361
1384
|
render() {
|
|
1362
|
-
return (index.h(index.Host, { key: '
|
|
1385
|
+
return (index.h(index.Host, { key: '3f923e0cc42c6a8eca61424a7e75960317a5d99c' }, index.h("div", { key: '4a3e2f6d4652b7049c9ec9f535ad32fd6401cc09', id: "ccc" })));
|
|
1363
1386
|
}
|
|
1364
1387
|
static get watchers() { return {
|
|
1365
1388
|
"nodeId": [{
|
|
@@ -19,7 +19,7 @@ var patchBrowser = () => {
|
|
|
19
19
|
|
|
20
20
|
patchBrowser().then(async (options) => {
|
|
21
21
|
await appGlobals.globalScripts();
|
|
22
|
-
return index.bootstrapLazy([["phirepass-sftp-client.cjs",[[257,"phirepass-sftp-client"]]],["phirepass-terminal.cjs",[[513,"phirepass-terminal",{"terminalOptions":[16],"serverHost":[1,"server-host"],"serverPort":[2,"server-port"],"allowInsecure":[4,"allow-insecure"],"heartbeatInterval":[2,"heartbeat-interval"],"nodeId":[1,"node-id"],"serverId":[1,"server-id"]},null,{"nodeId":[{"onNodeIdChange":0}],"serverId":[{"onServerIdChange":0}]}]]]], options);
|
|
22
|
+
return index.bootstrapLazy([["phirepass-sftp-client.cjs",[[257,"phirepass-sftp-client"]]],["phirepass-terminal.cjs",[[513,"phirepass-terminal",{"terminalOptions":[16],"serverHost":[1,"server-host"],"serverPort":[2,"server-port"],"allowInsecure":[4,"allow-insecure"],"heartbeatInterval":[2,"heartbeat-interval"],"nodeId":[1,"node-id"],"token":[1],"serverId":[1,"server-id"]},null,{"nodeId":[{"onNodeIdChange":0}],"serverId":[{"onServerIdChange":0}]}]]]], options);
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
exports.setNonce = index.setNonce;
|
|
@@ -88,11 +88,12 @@ export class PhirepassTerminal {
|
|
|
88
88
|
allowInsecure = false;
|
|
89
89
|
heartbeatInterval = 30_000;
|
|
90
90
|
nodeId;
|
|
91
|
+
token;
|
|
91
92
|
onNodeIdChange(newValue, _oldValue) {
|
|
92
93
|
// Handle the change in node_id here
|
|
93
94
|
// console.log(`node_id changed from ${oldValue} to ${newValue}`);
|
|
94
95
|
// Always clear local session state and reset terminal view
|
|
95
|
-
this.
|
|
96
|
+
this.reset_session_state();
|
|
96
97
|
this.terminal.reset();
|
|
97
98
|
// Close existing comms if connected
|
|
98
99
|
if (this.channel && this.channel.is_connected()) {
|
|
@@ -119,9 +120,13 @@ export class PhirepassTerminal {
|
|
|
119
120
|
return `${protocol}://${this.serverHost}:${this.serverPort}`;
|
|
120
121
|
}
|
|
121
122
|
async connectedCallback() {
|
|
123
|
+
console.log('PhirepassTerminal connected to DOM');
|
|
122
124
|
await init();
|
|
125
|
+
console.log('PhirepassChannel module initialized');
|
|
123
126
|
this.setup_terminal();
|
|
127
|
+
console.log('Terminal setup complete');
|
|
124
128
|
this.open_comms();
|
|
129
|
+
console.log('Comms opened');
|
|
125
130
|
if (!this.nodeId) {
|
|
126
131
|
console.warn('Prop node_id is not set. Cannot connect to terminal.');
|
|
127
132
|
return;
|
|
@@ -172,8 +177,7 @@ export class PhirepassTerminal {
|
|
|
172
177
|
this.channel = new PhirepassChannel(`${this.createWebSocketEndpoint()}/api/web/ws`, this.nodeId);
|
|
173
178
|
}
|
|
174
179
|
this.channel.on_connection_open(() => {
|
|
175
|
-
this.channel.
|
|
176
|
-
this.channel.open_ssh_tunnel(this.nodeId);
|
|
180
|
+
this.channel.authenticate(this.token, this.nodeId);
|
|
177
181
|
});
|
|
178
182
|
this.channel.on_connection_close(() => {
|
|
179
183
|
this.terminal.reset();
|
|
@@ -190,6 +194,9 @@ export class PhirepassTerminal {
|
|
|
190
194
|
case "Error":
|
|
191
195
|
this.handle_error(web);
|
|
192
196
|
break;
|
|
197
|
+
case "AuthSuccess":
|
|
198
|
+
this.handleAuthSuccess(web);
|
|
199
|
+
break;
|
|
193
200
|
case "TunnelOpened":
|
|
194
201
|
this.session_id = web.sid;
|
|
195
202
|
this.terminal.reset();
|
|
@@ -256,27 +263,30 @@ export class PhirepassTerminal {
|
|
|
256
263
|
this.channel.stop_heartbeat();
|
|
257
264
|
this.channel.disconnect();
|
|
258
265
|
}
|
|
259
|
-
|
|
266
|
+
cancel_credential_entry() {
|
|
260
267
|
this.inputMode = InputMode.Default;
|
|
261
|
-
this.
|
|
262
|
-
this.passwordBuffer = "";
|
|
268
|
+
this.clear_creds_buffer();
|
|
263
269
|
this.terminal.writeln("Authentication cancelled.");
|
|
264
270
|
this.terminal.reset();
|
|
265
271
|
}
|
|
266
|
-
|
|
267
|
-
this.session_id = undefined;
|
|
268
|
-
this.inputMode = InputMode.Default;
|
|
272
|
+
clear_creds_buffer() {
|
|
269
273
|
this.usernameBuffer = "";
|
|
270
274
|
this.passwordBuffer = "";
|
|
271
275
|
}
|
|
276
|
+
reset_session_state() {
|
|
277
|
+
this.session_id = undefined;
|
|
278
|
+
this.inputMode = InputMode.Default;
|
|
279
|
+
this.clear_creds_buffer();
|
|
280
|
+
}
|
|
281
|
+
handleAuthSuccess(_auth_) {
|
|
282
|
+
this.clear_creds_buffer();
|
|
283
|
+
this.channel.start_heartbeat(this.heartbeatInterval <= 15_000 ? 30_000 : this.heartbeatInterval);
|
|
284
|
+
this.channel.open_ssh_tunnel(this.nodeId);
|
|
285
|
+
}
|
|
272
286
|
handleTunnelClosed() {
|
|
273
|
-
// Clear session state
|
|
274
287
|
this.session_id = undefined;
|
|
275
288
|
this.inputMode = InputMode.Default;
|
|
276
|
-
|
|
277
|
-
this.usernameBuffer = "";
|
|
278
|
-
this.passwordBuffer = "";
|
|
279
|
-
// Reset terminal display
|
|
289
|
+
this.clear_creds_buffer();
|
|
280
290
|
this.terminal.reset();
|
|
281
291
|
this.terminal.writeln("Connection closed.");
|
|
282
292
|
}
|
|
@@ -289,6 +299,7 @@ export class PhirepassTerminal {
|
|
|
289
299
|
this.terminal.onData(this.handleTerminalData.bind(this));
|
|
290
300
|
this.channel.connect();
|
|
291
301
|
this.setupResizeObserver();
|
|
302
|
+
console.log('Terminal connected and ready');
|
|
292
303
|
}
|
|
293
304
|
}
|
|
294
305
|
setupResizeObserver() {
|
|
@@ -324,7 +335,7 @@ export class PhirepassTerminal {
|
|
|
324
335
|
}
|
|
325
336
|
if (data === "\u0003") {
|
|
326
337
|
this.terminal.write("^C\r\n");
|
|
327
|
-
this.
|
|
338
|
+
this.cancel_credential_entry();
|
|
328
339
|
return;
|
|
329
340
|
}
|
|
330
341
|
if (data === "\u007f") {
|
|
@@ -361,7 +372,7 @@ export class PhirepassTerminal {
|
|
|
361
372
|
}
|
|
362
373
|
if (data === "\u0003") {
|
|
363
374
|
this.terminal.write("^C\r\n");
|
|
364
|
-
this.
|
|
375
|
+
this.cancel_credential_entry();
|
|
365
376
|
return;
|
|
366
377
|
}
|
|
367
378
|
if (data === "\u007f") {
|
|
@@ -396,7 +407,7 @@ export class PhirepassTerminal {
|
|
|
396
407
|
this.usernameBuffer = "";
|
|
397
408
|
}
|
|
398
409
|
render() {
|
|
399
|
-
return (h(Host, { key: '
|
|
410
|
+
return (h(Host, { key: '3f923e0cc42c6a8eca61424a7e75960317a5d99c' }, h("div", { key: '4a3e2f6d4652b7049c9ec9f535ad32fd6401cc09', id: "ccc" })));
|
|
400
411
|
}
|
|
401
412
|
static get is() { return "phirepass-terminal"; }
|
|
402
413
|
static get encapsulation() { return "shadow"; }
|
|
@@ -519,7 +530,7 @@ export class PhirepassTerminal {
|
|
|
519
530
|
"references": {}
|
|
520
531
|
},
|
|
521
532
|
"required": false,
|
|
522
|
-
"optional":
|
|
533
|
+
"optional": false,
|
|
523
534
|
"docs": {
|
|
524
535
|
"tags": [],
|
|
525
536
|
"text": ""
|
|
@@ -529,6 +540,25 @@ export class PhirepassTerminal {
|
|
|
529
540
|
"reflect": false,
|
|
530
541
|
"attribute": "node-id"
|
|
531
542
|
},
|
|
543
|
+
"token": {
|
|
544
|
+
"type": "string",
|
|
545
|
+
"mutable": false,
|
|
546
|
+
"complexType": {
|
|
547
|
+
"original": "string",
|
|
548
|
+
"resolved": "string",
|
|
549
|
+
"references": {}
|
|
550
|
+
},
|
|
551
|
+
"required": false,
|
|
552
|
+
"optional": false,
|
|
553
|
+
"docs": {
|
|
554
|
+
"tags": [],
|
|
555
|
+
"text": ""
|
|
556
|
+
},
|
|
557
|
+
"getter": false,
|
|
558
|
+
"setter": false,
|
|
559
|
+
"reflect": false,
|
|
560
|
+
"attribute": "token"
|
|
561
|
+
},
|
|
532
562
|
"serverId": {
|
|
533
563
|
"type": "string",
|
|
534
564
|
"mutable": false,
|
|
Binary file
|