phirepass-widgets 0.0.78 → 0.0.79
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-sftp-client.cjs.entry.js +1 -1
- package/dist/cjs/phirepass-terminal.cjs.entry.js +1 -1
- package/dist/cjs/phirepass-vnc.cjs.entry.js +336 -0
- package/dist/cjs/phirepass-widgets.cjs.js +1 -1
- package/dist/cjs/{protocol-D5iIwePe.js → protocol-DC4eLkqJ.js} +32 -3
- package/dist/collection/collection-manifest.json +2 -1
- package/dist/collection/common/channel-socket.js +89 -0
- package/dist/collection/components/phirepass-vnc/phirepass-vnc.css +73 -0
- package/dist/collection/components/phirepass-vnc/phirepass-vnc.js +481 -0
- package/dist/collection/phirepass-channel_bg.wasm +0 -0
- package/dist/components/p-BR2c80mW.js +1 -0
- package/dist/components/phirepass-sftp-client.js +1 -1
- package/dist/components/phirepass-terminal.js +1 -1
- package/dist/components/phirepass-vnc.d.ts +11 -0
- package/dist/components/phirepass-vnc.js +1 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/phirepass-sftp-client.entry.js +1 -1
- package/dist/esm/phirepass-terminal.entry.js +1 -1
- package/dist/esm/phirepass-vnc.entry.js +334 -0
- package/dist/esm/phirepass-widgets.js +1 -1
- package/dist/esm/{protocol-DV8elohf.js → protocol-BR2c80mW.js} +31 -2
- package/dist/phirepass-widgets/{p-e6c56b50.entry.js → p-14c7611f.entry.js} +1 -1
- package/dist/phirepass-widgets/p-19e2a30c.entry.js +1 -0
- package/dist/phirepass-widgets/{p-7227a0f6.entry.js → p-339cd54e.entry.js} +1 -1
- package/dist/phirepass-widgets/p-BR2c80mW.js +1 -0
- package/dist/phirepass-widgets/phirepass-channel_bg.wasm +0 -0
- package/dist/phirepass-widgets/phirepass-widgets.esm.js +1 -1
- package/dist/types/common/channel-socket.d.ts +47 -0
- package/dist/types/common/novnc.d.ts +53 -0
- package/dist/types/components/phirepass-vnc/phirepass-vnc.d.ts +52 -0
- package/dist/types/components.d.ts +101 -0
- package/package.json +3 -2
- package/dist/components/p-DV8elohf.js +0 -1
- package/dist/phirepass-widgets/p-DV8elohf.js +0 -1
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",[[513,"phirepass-sftp-client",{"name":[1],"description":[1],"hideHeader":[4,"hide-header"],"serverHost":[1,"server-host"],"serverPort":[2,"server-port"],"allowInsecure":[4,"allow-insecure"],"heartbeatInterval":[2,"heartbeat-interval"],"nodeId":[1,"node-id"],"serviceId":[1,"service-id"],"token":[1],"serverId":[1,"server-id"],"max":[32],"show_login_screen":[32],"show_login_screen_username":[32],"show_error":[32],"error_message":[32],"show_login_screen_password":[32],"show_navigation":[32],"breadcrumbs":[32],"current_dir":[32],"listing":[32],"show_content":[32],"show_loader":[32],"version":[32],"status":[32],"selected_item":[32],"show_upload_modal":[32],"upload_progress":[32],"upload_file_name":[32],"upload_speed":[32],"upload_finished":[32],"show_download_modal":[32],"download_progress":[32],"download_file_name":[32],"download_speed":[32],"download_finished":[32],"show_delete_modal":[32],"delete_file_name":[32],"delete_loading":[32],"maximize":[64],"minimize":[64]},null,{"nodeId":[{"onNodeIdChange":0}],"serverId":[{"onServerIdChange":0}]}]]],["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"],"serviceId":[1,"service-id"],"token":[1],"serverId":[1,"server-id"]},null,{"nodeId":[{"onNodeIdChange":0}],"serverId":[{"onServerIdChange":0}]}]]]], options);
|
|
9
|
+
return index.bootstrapLazy([["phirepass-sftp-client.cjs",[[513,"phirepass-sftp-client",{"name":[1],"description":[1],"hideHeader":[4,"hide-header"],"serverHost":[1,"server-host"],"serverPort":[2,"server-port"],"allowInsecure":[4,"allow-insecure"],"heartbeatInterval":[2,"heartbeat-interval"],"nodeId":[1,"node-id"],"serviceId":[1,"service-id"],"token":[1],"serverId":[1,"server-id"],"max":[32],"show_login_screen":[32],"show_login_screen_username":[32],"show_error":[32],"error_message":[32],"show_login_screen_password":[32],"show_navigation":[32],"breadcrumbs":[32],"current_dir":[32],"listing":[32],"show_content":[32],"show_loader":[32],"version":[32],"status":[32],"selected_item":[32],"show_upload_modal":[32],"upload_progress":[32],"upload_file_name":[32],"upload_speed":[32],"upload_finished":[32],"show_download_modal":[32],"download_progress":[32],"download_file_name":[32],"download_speed":[32],"download_finished":[32],"show_delete_modal":[32],"delete_file_name":[32],"delete_loading":[32],"maximize":[64],"minimize":[64]},null,{"nodeId":[{"onNodeIdChange":0}],"serverId":[{"onServerIdChange":0}]}]]],["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"],"serviceId":[1,"service-id"],"token":[1],"serverId":[1,"server-id"]},null,{"nodeId":[{"onNodeIdChange":0}],"serverId":[{"onServerIdChange":0}]}]]],["phirepass-vnc.cjs",[[513,"phirepass-vnc",{"serverHost":[1,"server-host"],"serverPort":[2,"server-port"],"allowInsecure":[4,"allow-insecure"],"heartbeatInterval":[2,"heartbeat-interval"],"nodeId":[1,"node-id"],"serviceId":[1,"service-id"],"token":[1],"scaleViewport":[4,"scale-viewport"],"resizeSession":[4,"resize-session"],"serverId":[1,"server-id"],"passwordPrompt":[32],"statusMessage":[32]},null,{"nodeId":[{"onNodeIdChange":0}],"serverId":[{"onServerIdChange":0}]}]]]], options);
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
exports.setNonce = index.setNonce;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var index = require('./index-D-l8xaCI.js');
|
|
4
|
-
var protocol = require('./protocol-
|
|
4
|
+
var protocol = require('./protocol-DC4eLkqJ.js');
|
|
5
5
|
|
|
6
6
|
const phirepassSftpClientLogoSvg = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoNDYsIDE4NCwgMTM4KSIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiCiAgICBjbGFzcz0ibHVjaWRlIGx1Y2lkZS10ZXJtaW5hbCB3LTMuNSBoLTMuNSB0ZXh0LXByaW1hcnkiPgogICAgPHBvbHlsaW5lIHBvaW50cz0iNCAxNyAxMCAxMSA0IDUiPjwvcG9seWxpbmU+CiAgICA8bGluZSB4MT0iMTIiIHgyPSIyMCIgeTE9IjE5IiB5Mj0iMTkiPjwvbGluZT4KPC9zdmc+Cg==';
|
|
7
7
|
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index-D-l8xaCI.js');
|
|
4
|
+
var protocol = require('./protocol-DC4eLkqJ.js');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Presents a phirepass tunnel as the "raw channel" noVNC expects in place of a
|
|
8
|
+
* WebSocket.
|
|
9
|
+
*
|
|
10
|
+
* noVNC's `Websock.attach()` validates the object it is handed against a fixed
|
|
11
|
+
* property list — `send`, `close`, `binaryType`, `onerror`, `onmessage`,
|
|
12
|
+
* `onopen`, `protocol`, `readyState` — collected from `Object.keys(channel)`
|
|
13
|
+
* plus the own property names of its prototype. Methods and getters satisfy
|
|
14
|
+
* that from the prototype; the event handlers only satisfy it if they are
|
|
15
|
+
* *assigned* in the constructor, so every one of them is initialised to `null`
|
|
16
|
+
* below even though TypeScript would not otherwise require it. Leaving one
|
|
17
|
+
* merely declared makes `attach()` throw "Raw channel missing property".
|
|
18
|
+
*/
|
|
19
|
+
/** Matches the numeric `WebSocket.readyState` constants noVNC compares against. */
|
|
20
|
+
var ChannelSocketState;
|
|
21
|
+
(function (ChannelSocketState) {
|
|
22
|
+
ChannelSocketState[ChannelSocketState["Connecting"] = 0] = "Connecting";
|
|
23
|
+
ChannelSocketState[ChannelSocketState["Open"] = 1] = "Open";
|
|
24
|
+
ChannelSocketState[ChannelSocketState["Closing"] = 2] = "Closing";
|
|
25
|
+
ChannelSocketState[ChannelSocketState["Closed"] = 3] = "Closed";
|
|
26
|
+
})(ChannelSocketState || (ChannelSocketState = {}));
|
|
27
|
+
class ChannelSocket {
|
|
28
|
+
/** noVNC overwrites this with "arraybuffer" during attach. */
|
|
29
|
+
binaryType = 'arraybuffer';
|
|
30
|
+
/** Always empty: there is no WebSocket sub-protocol negotiation here. */
|
|
31
|
+
protocol = '';
|
|
32
|
+
readyState = ChannelSocketState.Connecting;
|
|
33
|
+
onopen = null;
|
|
34
|
+
onmessage = null;
|
|
35
|
+
onclose = null;
|
|
36
|
+
onerror = null;
|
|
37
|
+
sendData;
|
|
38
|
+
closeTunnel;
|
|
39
|
+
constructor(sendData, closeTunnel) {
|
|
40
|
+
this.sendData = sendData;
|
|
41
|
+
this.closeTunnel = closeTunnel;
|
|
42
|
+
}
|
|
43
|
+
/** Marks the tunnel as usable and lets noVNC start the RFB handshake. */
|
|
44
|
+
open() {
|
|
45
|
+
if (this.readyState !== ChannelSocketState.Connecting) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
this.readyState = ChannelSocketState.Open;
|
|
49
|
+
this.onopen?.();
|
|
50
|
+
}
|
|
51
|
+
/** Hands bytes arriving from the node up to noVNC. */
|
|
52
|
+
receive(data) {
|
|
53
|
+
if (this.readyState !== ChannelSocketState.Open) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
// Copy into a standalone buffer: the incoming view may be backed by
|
|
57
|
+
// wasm memory that is reused or detached after this call returns.
|
|
58
|
+
const buffer = new ArrayBuffer(data.byteLength);
|
|
59
|
+
new Uint8Array(buffer).set(data);
|
|
60
|
+
this.onmessage?.({ data: buffer });
|
|
61
|
+
}
|
|
62
|
+
/** Ends the socket from the phirepass side (tunnel closed, disconnect). */
|
|
63
|
+
closed() {
|
|
64
|
+
if (this.readyState === ChannelSocketState.Closed) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
this.readyState = ChannelSocketState.Closed;
|
|
68
|
+
this.onclose?.();
|
|
69
|
+
}
|
|
70
|
+
failed(error) {
|
|
71
|
+
this.onerror?.(error);
|
|
72
|
+
this.closed();
|
|
73
|
+
}
|
|
74
|
+
// ── the surface noVNC calls ───────────────────────────────────────────────
|
|
75
|
+
send(data) {
|
|
76
|
+
if (this.readyState !== ChannelSocketState.Open) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const bytes = data instanceof ArrayBuffer
|
|
80
|
+
? new Uint8Array(data)
|
|
81
|
+
: new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
82
|
+
// Copy before handing off: noVNC sends views into its own reusable
|
|
83
|
+
// send queue, which it overwrites immediately afterwards.
|
|
84
|
+
this.sendData(new Uint8Array(bytes));
|
|
85
|
+
}
|
|
86
|
+
close() {
|
|
87
|
+
if (this.readyState === ChannelSocketState.Closed) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
this.readyState = ChannelSocketState.Closing;
|
|
91
|
+
this.closeTunnel();
|
|
92
|
+
this.closed();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const phirepassVncCss = () => `:host{display:block;width:100%;height:100%;min-width:0;min-height:0;overflow:hidden;position:relative;background:#0b1021}.screen{width:100%;height:100%}.screen canvas{max-width:100%;display:block}.prompt{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:0.75rem;background:rgba(11, 16, 33, 0.92);color:#e2e8f0;font-family:"Berkeley Mono", "Fira Code", "SFMono-Regular", Menlo, monospace;font-size:0.875rem}.prompt input{padding:0.5rem 0.75rem;border:1px solid #334155;border-radius:0.375rem;background:#0f172a;color:inherit;font:inherit;min-width:16rem}.prompt input:focus{outline:2px solid #67e8f9;outline-offset:1px}.prompt button{padding:0.5rem 1.25rem;border:0;border-radius:0.375rem;background:#67e8f9;color:#0b1021;font:inherit;font-weight:600;cursor:pointer}.status{position:absolute;inset-inline:0;bottom:0;padding:0.5rem 0.75rem;background:rgba(11, 16, 33, 0.92);color:#e2e8f0;font-family:"Berkeley Mono", "Fira Code", "SFMono-Regular", Menlo, monospace;font-size:0.8125rem;text-align:center}`;
|
|
97
|
+
|
|
98
|
+
const PhirepassVnc = class {
|
|
99
|
+
constructor(hostRef) {
|
|
100
|
+
index.registerInstance(this, hostRef);
|
|
101
|
+
this.connectionStateChanged = index.createEvent(this, "connectionStateChanged");
|
|
102
|
+
}
|
|
103
|
+
channel;
|
|
104
|
+
containerEl;
|
|
105
|
+
socket;
|
|
106
|
+
rfb;
|
|
107
|
+
domReady = false;
|
|
108
|
+
runtimeReady = false;
|
|
109
|
+
connected = false;
|
|
110
|
+
session_id;
|
|
111
|
+
passwordPrompt = false;
|
|
112
|
+
statusMessage;
|
|
113
|
+
passwordBuffer = '';
|
|
114
|
+
get el() { return index.getElement(this); }
|
|
115
|
+
serverHost = "phirepass.com";
|
|
116
|
+
serverPort = 443;
|
|
117
|
+
allowInsecure = false;
|
|
118
|
+
heartbeatInterval = 30_000;
|
|
119
|
+
nodeId;
|
|
120
|
+
serviceId;
|
|
121
|
+
token;
|
|
122
|
+
/** Scales the remote desktop to fit the widget instead of showing scrollbars. */
|
|
123
|
+
scaleViewport = true;
|
|
124
|
+
/** Asks the VNC server to match its resolution to the widget size. */
|
|
125
|
+
resizeSession = true;
|
|
126
|
+
onNodeIdChange(newValue, _oldValue) {
|
|
127
|
+
this.reset_session_state();
|
|
128
|
+
if (this.channel && this.channel.is_connected()) {
|
|
129
|
+
this.close_comms();
|
|
130
|
+
}
|
|
131
|
+
if (newValue) {
|
|
132
|
+
this.open_comms();
|
|
133
|
+
this.channel.connect();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
serverId;
|
|
137
|
+
onServerIdChange(_newValue, _oldValue) {
|
|
138
|
+
this.onNodeIdChange(this.nodeId, this.nodeId);
|
|
139
|
+
}
|
|
140
|
+
connectionStateChanged;
|
|
141
|
+
create_web_socket_endpoint() {
|
|
142
|
+
const protocol = this.allowInsecure ? 'ws' : 'wss';
|
|
143
|
+
if (!this.allowInsecure && this.serverPort === 443) {
|
|
144
|
+
return `${protocol}://${this.serverHost}`;
|
|
145
|
+
}
|
|
146
|
+
if (this.allowInsecure && this.serverPort === 80) {
|
|
147
|
+
return `${protocol}://${this.serverHost}`;
|
|
148
|
+
}
|
|
149
|
+
return `${protocol}://${this.serverHost}:${this.serverPort}`;
|
|
150
|
+
}
|
|
151
|
+
async connectedCallback() {
|
|
152
|
+
await protocol.__wbg_init();
|
|
153
|
+
this.open_comms();
|
|
154
|
+
this.runtimeReady = true;
|
|
155
|
+
if (!this.nodeId) {
|
|
156
|
+
console.warn('Prop node_id is not set. Cannot connect to VNC.');
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
this.try_connect();
|
|
160
|
+
}
|
|
161
|
+
componentDidLoad() {
|
|
162
|
+
this.domReady = true;
|
|
163
|
+
this.try_connect();
|
|
164
|
+
}
|
|
165
|
+
async disconnectedCallback() {
|
|
166
|
+
this.connected = false;
|
|
167
|
+
this.domReady = false;
|
|
168
|
+
this.runtimeReady = false;
|
|
169
|
+
this.close_comms();
|
|
170
|
+
}
|
|
171
|
+
try_connect() {
|
|
172
|
+
if (this.connected || !this.domReady || !this.runtimeReady) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (!this.containerEl || !this.channel) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
this.connect();
|
|
179
|
+
}
|
|
180
|
+
connect() {
|
|
181
|
+
this.connected = true;
|
|
182
|
+
this.channel.connect();
|
|
183
|
+
}
|
|
184
|
+
open_comms() {
|
|
185
|
+
if (this.serverId) {
|
|
186
|
+
this.channel = new protocol.Channel(`${this.create_web_socket_endpoint()}/api/web/ws`, this.nodeId, this.serverId);
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
this.channel = new protocol.Channel(`${this.create_web_socket_endpoint()}/api/web/ws`, this.nodeId);
|
|
190
|
+
}
|
|
191
|
+
this.channel.on_connection_open(() => {
|
|
192
|
+
this.connectionStateChanged.emit([protocol.ConnectionState.Connected]);
|
|
193
|
+
this.channel.authenticate(this.token, this.nodeId);
|
|
194
|
+
});
|
|
195
|
+
this.channel.on_connection_close(() => {
|
|
196
|
+
this.connectionStateChanged.emit([protocol.ConnectionState.Disconnected]);
|
|
197
|
+
this.teardown_rfb();
|
|
198
|
+
});
|
|
199
|
+
this.channel.on_connection_error((err) => {
|
|
200
|
+
this.connectionStateChanged.emit([protocol.ConnectionState.Error, err]);
|
|
201
|
+
this.socket?.failed(err);
|
|
202
|
+
});
|
|
203
|
+
this.channel.on_connection_message((_raw_) => {
|
|
204
|
+
// raw frames are handled by on_protocol_message below
|
|
205
|
+
});
|
|
206
|
+
this.channel.on_protocol_message((msg) => {
|
|
207
|
+
const { web } = msg.data;
|
|
208
|
+
switch (web.type) {
|
|
209
|
+
case protocol.ProtocolMessageType.Error:
|
|
210
|
+
this.handle_error(web);
|
|
211
|
+
break;
|
|
212
|
+
case protocol.ProtocolMessageType.AuthSuccess:
|
|
213
|
+
this.handle_auth_success(web);
|
|
214
|
+
break;
|
|
215
|
+
case protocol.ProtocolMessageType.TunnelOpened:
|
|
216
|
+
this.handle_tunnel_opened(web);
|
|
217
|
+
break;
|
|
218
|
+
case protocol.ProtocolMessageType.TunnelClosed:
|
|
219
|
+
this.handle_tunnel_closed(web);
|
|
220
|
+
break;
|
|
221
|
+
case protocol.ProtocolMessageType.TunnelData:
|
|
222
|
+
this.handle_tunnel_data(web);
|
|
223
|
+
break;
|
|
224
|
+
default:
|
|
225
|
+
console.warn('Unknown protocol message type:', web);
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
close_comms() {
|
|
230
|
+
this.teardown_rfb();
|
|
231
|
+
if (this.channel) {
|
|
232
|
+
this.channel.stop_heartbeat();
|
|
233
|
+
this.channel.disconnect();
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
reset_session_state() {
|
|
237
|
+
this.session_id = undefined;
|
|
238
|
+
this.passwordPrompt = false;
|
|
239
|
+
this.passwordBuffer = '';
|
|
240
|
+
this.statusMessage = undefined;
|
|
241
|
+
}
|
|
242
|
+
handle_auth_success(_auth_) {
|
|
243
|
+
this.channel.start_heartbeat(this.heartbeatInterval <= 15_000 ? 30_000 : this.heartbeatInterval);
|
|
244
|
+
this.channel.open_vnc_tunnel(this.nodeId, this.serviceId);
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* The tunnel is a byte pipe from here on: noVNC drives the RFB handshake,
|
|
248
|
+
* including authentication, over the socket adapter.
|
|
249
|
+
*/
|
|
250
|
+
async handle_tunnel_opened(web) {
|
|
251
|
+
this.session_id = web.sid;
|
|
252
|
+
this.statusMessage = undefined;
|
|
253
|
+
const socket = new ChannelSocket((data) => {
|
|
254
|
+
if (this.session_id === undefined) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
this.channel.send_vnc_tunnel_data(this.nodeId, this.session_id, data);
|
|
258
|
+
}, () => this.close_comms());
|
|
259
|
+
this.socket = socket;
|
|
260
|
+
// Loaded on demand so consumers embedding only the terminal or the SFTP
|
|
261
|
+
// client never download the RFB client.
|
|
262
|
+
const { default: RFBClient } = await import('@novnc/novnc');
|
|
263
|
+
// The element may have gone away while the module was loading.
|
|
264
|
+
if (!this.containerEl || this.socket !== socket) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
const rfb = new RFBClient(this.containerEl, socket);
|
|
268
|
+
rfb.scaleViewport = this.scaleViewport;
|
|
269
|
+
rfb.resizeSession = this.resizeSession;
|
|
270
|
+
rfb.addEventListener('credentialsrequired', () => {
|
|
271
|
+
this.passwordPrompt = true;
|
|
272
|
+
});
|
|
273
|
+
rfb.addEventListener('securityfailure', (event) => {
|
|
274
|
+
const detail = event.detail;
|
|
275
|
+
this.statusMessage = detail?.reason ?? 'Authentication failed.';
|
|
276
|
+
this.connectionStateChanged.emit([protocol.ConnectionState.Error, detail]);
|
|
277
|
+
});
|
|
278
|
+
rfb.addEventListener('disconnect', () => {
|
|
279
|
+
this.statusMessage = this.statusMessage ?? 'Connection closed.';
|
|
280
|
+
});
|
|
281
|
+
this.rfb = rfb;
|
|
282
|
+
// Only now can noVNC start reading: it attaches on construction.
|
|
283
|
+
socket.open();
|
|
284
|
+
}
|
|
285
|
+
handle_tunnel_data(web) {
|
|
286
|
+
this.socket?.receive(new Uint8Array(web.data));
|
|
287
|
+
}
|
|
288
|
+
handle_tunnel_closed(_web_) {
|
|
289
|
+
this.session_id = undefined;
|
|
290
|
+
this.statusMessage = 'Connection closed.';
|
|
291
|
+
this.teardown_rfb();
|
|
292
|
+
this.close_comms();
|
|
293
|
+
}
|
|
294
|
+
handle_error(error) {
|
|
295
|
+
this.statusMessage = error.message;
|
|
296
|
+
this.connectionStateChanged.emit([protocol.ConnectionState.Error, error]);
|
|
297
|
+
this.socket?.failed(error);
|
|
298
|
+
}
|
|
299
|
+
teardown_rfb() {
|
|
300
|
+
if (this.rfb) {
|
|
301
|
+
try {
|
|
302
|
+
this.rfb.disconnect();
|
|
303
|
+
}
|
|
304
|
+
catch (err) {
|
|
305
|
+
console.warn('Failed to disconnect RFB cleanly:', err);
|
|
306
|
+
}
|
|
307
|
+
this.rfb = undefined;
|
|
308
|
+
}
|
|
309
|
+
if (this.socket) {
|
|
310
|
+
this.socket.closed();
|
|
311
|
+
this.socket = undefined;
|
|
312
|
+
}
|
|
313
|
+
this.passwordPrompt = false;
|
|
314
|
+
this.passwordBuffer = '';
|
|
315
|
+
}
|
|
316
|
+
submit_password(event) {
|
|
317
|
+
event.preventDefault();
|
|
318
|
+
this.passwordPrompt = false;
|
|
319
|
+
this.rfb?.sendCredentials({ password: this.passwordBuffer });
|
|
320
|
+
this.passwordBuffer = '';
|
|
321
|
+
}
|
|
322
|
+
render() {
|
|
323
|
+
return (index.h(index.Host, { key: '5daf583edea28d1592827dd7b96aff27bf3fd857' }, index.h("div", { key: '4a5f3d8b64084c3929fc16fdda7eba0de300c188', class: "screen", ref: (el) => (this.containerEl = el) }), this.passwordPrompt && (index.h("form", { key: 'cadd7db5b5985f332156a93eae953fadd377af54', class: "prompt", onSubmit: (event) => this.submit_password(event) }, index.h("label", { key: '2c1702e048c5d932e3384bacf65c4a5393aecc79', htmlFor: "vnc-password" }, "VNC password"), index.h("input", { key: '0e2c947e15bdbf0cd76b6414bc0d22896914af0d', id: "vnc-password", type: "password", autofocus: true, onInput: (event) => (this.passwordBuffer = event.target.value) }), index.h("button", { key: 'eb5b346b830f449454bb2476d12f08e5fb61a4a5', type: "submit" }, "Connect"))), this.statusMessage && !this.passwordPrompt && (index.h("div", { key: '28f55f457ae33e774c6914b7f6f9761bdb95b804', class: "status" }, this.statusMessage))));
|
|
324
|
+
}
|
|
325
|
+
static get watchers() { return {
|
|
326
|
+
"nodeId": [{
|
|
327
|
+
"onNodeIdChange": 0
|
|
328
|
+
}],
|
|
329
|
+
"serverId": [{
|
|
330
|
+
"onServerIdChange": 0
|
|
331
|
+
}]
|
|
332
|
+
}; }
|
|
333
|
+
};
|
|
334
|
+
PhirepassVnc.style = phirepassVncCss();
|
|
335
|
+
|
|
336
|
+
exports.phirepass_vnc = PhirepassVnc;
|
|
@@ -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",[[513,"phirepass-sftp-client",{"name":[1],"description":[1],"hideHeader":[4,"hide-header"],"serverHost":[1,"server-host"],"serverPort":[2,"server-port"],"allowInsecure":[4,"allow-insecure"],"heartbeatInterval":[2,"heartbeat-interval"],"nodeId":[1,"node-id"],"serviceId":[1,"service-id"],"token":[1],"serverId":[1,"server-id"],"max":[32],"show_login_screen":[32],"show_login_screen_username":[32],"show_error":[32],"error_message":[32],"show_login_screen_password":[32],"show_navigation":[32],"breadcrumbs":[32],"current_dir":[32],"listing":[32],"show_content":[32],"show_loader":[32],"version":[32],"status":[32],"selected_item":[32],"show_upload_modal":[32],"upload_progress":[32],"upload_file_name":[32],"upload_speed":[32],"upload_finished":[32],"show_download_modal":[32],"download_progress":[32],"download_file_name":[32],"download_speed":[32],"download_finished":[32],"show_delete_modal":[32],"delete_file_name":[32],"delete_loading":[32],"maximize":[64],"minimize":[64]},null,{"nodeId":[{"onNodeIdChange":0}],"serverId":[{"onServerIdChange":0}]}]]],["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"],"serviceId":[1,"service-id"],"token":[1],"serverId":[1,"server-id"]},null,{"nodeId":[{"onNodeIdChange":0}],"serverId":[{"onServerIdChange":0}]}]]]], options);
|
|
22
|
+
return index.bootstrapLazy([["phirepass-sftp-client.cjs",[[513,"phirepass-sftp-client",{"name":[1],"description":[1],"hideHeader":[4,"hide-header"],"serverHost":[1,"server-host"],"serverPort":[2,"server-port"],"allowInsecure":[4,"allow-insecure"],"heartbeatInterval":[2,"heartbeat-interval"],"nodeId":[1,"node-id"],"serviceId":[1,"service-id"],"token":[1],"serverId":[1,"server-id"],"max":[32],"show_login_screen":[32],"show_login_screen_username":[32],"show_error":[32],"error_message":[32],"show_login_screen_password":[32],"show_navigation":[32],"breadcrumbs":[32],"current_dir":[32],"listing":[32],"show_content":[32],"show_loader":[32],"version":[32],"status":[32],"selected_item":[32],"show_upload_modal":[32],"upload_progress":[32],"upload_file_name":[32],"upload_speed":[32],"upload_finished":[32],"show_download_modal":[32],"download_progress":[32],"download_file_name":[32],"download_speed":[32],"download_finished":[32],"show_delete_modal":[32],"delete_file_name":[32],"delete_loading":[32],"maximize":[64],"minimize":[64]},null,{"nodeId":[{"onNodeIdChange":0}],"serverId":[{"onServerIdChange":0}]}]]],["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"],"serviceId":[1,"service-id"],"token":[1],"serverId":[1,"server-id"]},null,{"nodeId":[{"onNodeIdChange":0}],"serverId":[{"onServerIdChange":0}]}]]],["phirepass-vnc.cjs",[[513,"phirepass-vnc",{"serverHost":[1,"server-host"],"serverPort":[2,"server-port"],"allowInsecure":[4,"allow-insecure"],"heartbeatInterval":[2,"heartbeat-interval"],"nodeId":[1,"node-id"],"serviceId":[1,"service-id"],"token":[1],"scaleViewport":[4,"scale-viewport"],"resizeSession":[4,"resize-session"],"serverId":[1,"server-id"],"passwordPrompt":[32],"statusMessage":[32]},null,{"nodeId":[{"onNodeIdChange":0}],"serverId":[{"onServerIdChange":0}]}]]]], options);
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
exports.setNonce = index.setNonce;
|
|
@@ -181,6 +181,20 @@ class Channel {
|
|
|
181
181
|
var len3 = WASM_VECTOR_LEN;
|
|
182
182
|
wasm.channel_open_ssh_tunnel(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, isLikeNone(msg_id) ? Number.MAX_SAFE_INTEGER : (msg_id) >>> 0);
|
|
183
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* VNC takes no credentials: the RFB password challenge is answered by the
|
|
186
|
+
* browser's VNC client inside the tunnel itself.
|
|
187
|
+
* @param {string} node_id
|
|
188
|
+
* @param {string} service_id
|
|
189
|
+
* @param {number | null} [msg_id]
|
|
190
|
+
*/
|
|
191
|
+
open_vnc_tunnel(node_id, service_id, msg_id) {
|
|
192
|
+
const ptr0 = passStringToWasm0(node_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
193
|
+
const len0 = WASM_VECTOR_LEN;
|
|
194
|
+
const ptr1 = passStringToWasm0(service_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
195
|
+
const len1 = WASM_VECTOR_LEN;
|
|
196
|
+
wasm.channel_open_vnc_tunnel(this.__wbg_ptr, ptr0, len0, ptr1, len1, isLikeNone(msg_id) ? Number.MAX_SAFE_INTEGER : (msg_id) >>> 0);
|
|
197
|
+
}
|
|
184
198
|
/**
|
|
185
199
|
* @param {string} node_id
|
|
186
200
|
* @param {number} sid
|
|
@@ -311,6 +325,21 @@ class Channel {
|
|
|
311
325
|
const len1 = WASM_VECTOR_LEN;
|
|
312
326
|
wasm.channel_send_ssh_tunnel_data(this.__wbg_ptr, ptr0, len0, sid, ptr1, len1);
|
|
313
327
|
}
|
|
328
|
+
/**
|
|
329
|
+
* Takes bytes rather than a string (unlike [`Channel::send_ssh_tunnel_data`]):
|
|
330
|
+
* RFB client messages are binary and would not survive a UTF-8 round trip.
|
|
331
|
+
* `Vec<u8>` arrives from JS as a `Uint8Array` with no re-encoding.
|
|
332
|
+
* @param {string} node_id
|
|
333
|
+
* @param {number} sid
|
|
334
|
+
* @param {Uint8Array} data
|
|
335
|
+
*/
|
|
336
|
+
send_vnc_tunnel_data(node_id, sid, data) {
|
|
337
|
+
const ptr0 = passStringToWasm0(node_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
338
|
+
const len0 = WASM_VECTOR_LEN;
|
|
339
|
+
const ptr1 = passArray8ToWasm0(data, wasm.__wbindgen_export);
|
|
340
|
+
const len1 = WASM_VECTOR_LEN;
|
|
341
|
+
wasm.channel_send_vnc_tunnel_data(this.__wbg_ptr, ptr0, len0, sid, ptr1, len1);
|
|
342
|
+
}
|
|
314
343
|
/**
|
|
315
344
|
* @param {number} interval_as_millis
|
|
316
345
|
*/
|
|
@@ -436,7 +465,7 @@ function __wbg_get_imports() {
|
|
|
436
465
|
const ret = Reflect.get(getObject(arg0), getObject(arg1));
|
|
437
466
|
return addHeapObject(ret);
|
|
438
467
|
}, arguments); },
|
|
439
|
-
|
|
468
|
+
__wbg_info_126a81f879b26b73: function(arg0, arg1) {
|
|
440
469
|
console.info(getStringFromWasm0(arg0, arg1));
|
|
441
470
|
},
|
|
442
471
|
__wbg_instanceof_ArrayBuffer_4480b9e0068a8adb: function(arg0) {
|
|
@@ -508,7 +537,7 @@ function __wbg_get_imports() {
|
|
|
508
537
|
__wbg_set_onopen_4f65470ae522a61a: function(arg0, arg1) {
|
|
509
538
|
getObject(arg0).onopen = getObject(arg1);
|
|
510
539
|
},
|
|
511
|
-
|
|
540
|
+
__wbg_warn_a34cc328d5dc529a: function(arg0, arg1) {
|
|
512
541
|
console.warn(getStringFromWasm0(arg0, arg1));
|
|
513
542
|
},
|
|
514
543
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
@@ -878,7 +907,7 @@ async function __wbg_init(module_or_path) {
|
|
|
878
907
|
}
|
|
879
908
|
|
|
880
909
|
if (module_or_path === undefined) {
|
|
881
|
-
module_or_path = new URL('phirepass-channel_bg.wasm', (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('protocol-
|
|
910
|
+
module_or_path = new URL('phirepass-channel_bg.wasm', (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('protocol-DC4eLkqJ.js', document.baseURI).href)));
|
|
882
911
|
}
|
|
883
912
|
const imports = __wbg_get_imports();
|
|
884
913
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"entries": [
|
|
3
3
|
"components/phirepass-sftp-client/phirepass-sftp-client.js",
|
|
4
|
-
"components/phirepass-terminal/phirepass-terminal.js"
|
|
4
|
+
"components/phirepass-terminal/phirepass-terminal.js",
|
|
5
|
+
"components/phirepass-vnc/phirepass-vnc.js"
|
|
5
6
|
],
|
|
6
7
|
"mixins": [],
|
|
7
8
|
"compiler": {
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Presents a phirepass tunnel as the "raw channel" noVNC expects in place of a
|
|
3
|
+
* WebSocket.
|
|
4
|
+
*
|
|
5
|
+
* noVNC's `Websock.attach()` validates the object it is handed against a fixed
|
|
6
|
+
* property list — `send`, `close`, `binaryType`, `onerror`, `onmessage`,
|
|
7
|
+
* `onopen`, `protocol`, `readyState` — collected from `Object.keys(channel)`
|
|
8
|
+
* plus the own property names of its prototype. Methods and getters satisfy
|
|
9
|
+
* that from the prototype; the event handlers only satisfy it if they are
|
|
10
|
+
* *assigned* in the constructor, so every one of them is initialised to `null`
|
|
11
|
+
* below even though TypeScript would not otherwise require it. Leaving one
|
|
12
|
+
* merely declared makes `attach()` throw "Raw channel missing property".
|
|
13
|
+
*/
|
|
14
|
+
/** Matches the numeric `WebSocket.readyState` constants noVNC compares against. */
|
|
15
|
+
export var ChannelSocketState;
|
|
16
|
+
(function (ChannelSocketState) {
|
|
17
|
+
ChannelSocketState[ChannelSocketState["Connecting"] = 0] = "Connecting";
|
|
18
|
+
ChannelSocketState[ChannelSocketState["Open"] = 1] = "Open";
|
|
19
|
+
ChannelSocketState[ChannelSocketState["Closing"] = 2] = "Closing";
|
|
20
|
+
ChannelSocketState[ChannelSocketState["Closed"] = 3] = "Closed";
|
|
21
|
+
})(ChannelSocketState || (ChannelSocketState = {}));
|
|
22
|
+
export class ChannelSocket {
|
|
23
|
+
/** noVNC overwrites this with "arraybuffer" during attach. */
|
|
24
|
+
binaryType = 'arraybuffer';
|
|
25
|
+
/** Always empty: there is no WebSocket sub-protocol negotiation here. */
|
|
26
|
+
protocol = '';
|
|
27
|
+
readyState = ChannelSocketState.Connecting;
|
|
28
|
+
onopen = null;
|
|
29
|
+
onmessage = null;
|
|
30
|
+
onclose = null;
|
|
31
|
+
onerror = null;
|
|
32
|
+
sendData;
|
|
33
|
+
closeTunnel;
|
|
34
|
+
constructor(sendData, closeTunnel) {
|
|
35
|
+
this.sendData = sendData;
|
|
36
|
+
this.closeTunnel = closeTunnel;
|
|
37
|
+
}
|
|
38
|
+
/** Marks the tunnel as usable and lets noVNC start the RFB handshake. */
|
|
39
|
+
open() {
|
|
40
|
+
if (this.readyState !== ChannelSocketState.Connecting) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
this.readyState = ChannelSocketState.Open;
|
|
44
|
+
this.onopen?.();
|
|
45
|
+
}
|
|
46
|
+
/** Hands bytes arriving from the node up to noVNC. */
|
|
47
|
+
receive(data) {
|
|
48
|
+
if (this.readyState !== ChannelSocketState.Open) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
// Copy into a standalone buffer: the incoming view may be backed by
|
|
52
|
+
// wasm memory that is reused or detached after this call returns.
|
|
53
|
+
const buffer = new ArrayBuffer(data.byteLength);
|
|
54
|
+
new Uint8Array(buffer).set(data);
|
|
55
|
+
this.onmessage?.({ data: buffer });
|
|
56
|
+
}
|
|
57
|
+
/** Ends the socket from the phirepass side (tunnel closed, disconnect). */
|
|
58
|
+
closed() {
|
|
59
|
+
if (this.readyState === ChannelSocketState.Closed) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
this.readyState = ChannelSocketState.Closed;
|
|
63
|
+
this.onclose?.();
|
|
64
|
+
}
|
|
65
|
+
failed(error) {
|
|
66
|
+
this.onerror?.(error);
|
|
67
|
+
this.closed();
|
|
68
|
+
}
|
|
69
|
+
// ── the surface noVNC calls ───────────────────────────────────────────────
|
|
70
|
+
send(data) {
|
|
71
|
+
if (this.readyState !== ChannelSocketState.Open) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const bytes = data instanceof ArrayBuffer
|
|
75
|
+
? new Uint8Array(data)
|
|
76
|
+
: new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
77
|
+
// Copy before handing off: noVNC sends views into its own reusable
|
|
78
|
+
// send queue, which it overwrites immediately afterwards.
|
|
79
|
+
this.sendData(new Uint8Array(bytes));
|
|
80
|
+
}
|
|
81
|
+
close() {
|
|
82
|
+
if (this.readyState === ChannelSocketState.Closed) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
this.readyState = ChannelSocketState.Closing;
|
|
86
|
+
this.closeTunnel();
|
|
87
|
+
this.closed();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: block;
|
|
3
|
+
width: 100%;
|
|
4
|
+
height: 100%;
|
|
5
|
+
min-width: 0;
|
|
6
|
+
min-height: 0;
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
position: relative;
|
|
9
|
+
background: #0b1021;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.screen {
|
|
13
|
+
width: 100%;
|
|
14
|
+
height: 100%;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/* noVNC injects its own canvas; make sure it never forces the page to scroll. */
|
|
18
|
+
.screen canvas {
|
|
19
|
+
max-width: 100%;
|
|
20
|
+
display: block;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.prompt {
|
|
24
|
+
position: absolute;
|
|
25
|
+
inset: 0;
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
align-items: center;
|
|
29
|
+
justify-content: center;
|
|
30
|
+
gap: 0.75rem;
|
|
31
|
+
background: rgba(11, 16, 33, 0.92);
|
|
32
|
+
color: #e2e8f0;
|
|
33
|
+
font-family: "Berkeley Mono", "Fira Code", "SFMono-Regular", Menlo, monospace;
|
|
34
|
+
font-size: 0.875rem;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.prompt input {
|
|
38
|
+
padding: 0.5rem 0.75rem;
|
|
39
|
+
border: 1px solid #334155;
|
|
40
|
+
border-radius: 0.375rem;
|
|
41
|
+
background: #0f172a;
|
|
42
|
+
color: inherit;
|
|
43
|
+
font: inherit;
|
|
44
|
+
min-width: 16rem;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.prompt input:focus {
|
|
48
|
+
outline: 2px solid #67e8f9;
|
|
49
|
+
outline-offset: 1px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.prompt button {
|
|
53
|
+
padding: 0.5rem 1.25rem;
|
|
54
|
+
border: 0;
|
|
55
|
+
border-radius: 0.375rem;
|
|
56
|
+
background: #67e8f9;
|
|
57
|
+
color: #0b1021;
|
|
58
|
+
font: inherit;
|
|
59
|
+
font-weight: 600;
|
|
60
|
+
cursor: pointer;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.status {
|
|
64
|
+
position: absolute;
|
|
65
|
+
inset-inline: 0;
|
|
66
|
+
bottom: 0;
|
|
67
|
+
padding: 0.5rem 0.75rem;
|
|
68
|
+
background: rgba(11, 16, 33, 0.92);
|
|
69
|
+
color: #e2e8f0;
|
|
70
|
+
font-family: "Berkeley Mono", "Fira Code", "SFMono-Regular", Menlo, monospace;
|
|
71
|
+
font-size: 0.8125rem;
|
|
72
|
+
text-align: center;
|
|
73
|
+
}
|