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
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import { r as registerInstance, c as createEvent, g as getElement, h, H as Host } from './index-DovZQ7sb.js';
|
|
2
|
+
import { _ as __wbg_init, C as Channel, a as ConnectionState, P as ProtocolMessageType } from './protocol-BR2c80mW.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Presents a phirepass tunnel as the "raw channel" noVNC expects in place of a
|
|
6
|
+
* WebSocket.
|
|
7
|
+
*
|
|
8
|
+
* noVNC's `Websock.attach()` validates the object it is handed against a fixed
|
|
9
|
+
* property list — `send`, `close`, `binaryType`, `onerror`, `onmessage`,
|
|
10
|
+
* `onopen`, `protocol`, `readyState` — collected from `Object.keys(channel)`
|
|
11
|
+
* plus the own property names of its prototype. Methods and getters satisfy
|
|
12
|
+
* that from the prototype; the event handlers only satisfy it if they are
|
|
13
|
+
* *assigned* in the constructor, so every one of them is initialised to `null`
|
|
14
|
+
* below even though TypeScript would not otherwise require it. Leaving one
|
|
15
|
+
* merely declared makes `attach()` throw "Raw channel missing property".
|
|
16
|
+
*/
|
|
17
|
+
/** Matches the numeric `WebSocket.readyState` constants noVNC compares against. */
|
|
18
|
+
var ChannelSocketState;
|
|
19
|
+
(function (ChannelSocketState) {
|
|
20
|
+
ChannelSocketState[ChannelSocketState["Connecting"] = 0] = "Connecting";
|
|
21
|
+
ChannelSocketState[ChannelSocketState["Open"] = 1] = "Open";
|
|
22
|
+
ChannelSocketState[ChannelSocketState["Closing"] = 2] = "Closing";
|
|
23
|
+
ChannelSocketState[ChannelSocketState["Closed"] = 3] = "Closed";
|
|
24
|
+
})(ChannelSocketState || (ChannelSocketState = {}));
|
|
25
|
+
class ChannelSocket {
|
|
26
|
+
/** noVNC overwrites this with "arraybuffer" during attach. */
|
|
27
|
+
binaryType = 'arraybuffer';
|
|
28
|
+
/** Always empty: there is no WebSocket sub-protocol negotiation here. */
|
|
29
|
+
protocol = '';
|
|
30
|
+
readyState = ChannelSocketState.Connecting;
|
|
31
|
+
onopen = null;
|
|
32
|
+
onmessage = null;
|
|
33
|
+
onclose = null;
|
|
34
|
+
onerror = null;
|
|
35
|
+
sendData;
|
|
36
|
+
closeTunnel;
|
|
37
|
+
constructor(sendData, closeTunnel) {
|
|
38
|
+
this.sendData = sendData;
|
|
39
|
+
this.closeTunnel = closeTunnel;
|
|
40
|
+
}
|
|
41
|
+
/** Marks the tunnel as usable and lets noVNC start the RFB handshake. */
|
|
42
|
+
open() {
|
|
43
|
+
if (this.readyState !== ChannelSocketState.Connecting) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
this.readyState = ChannelSocketState.Open;
|
|
47
|
+
this.onopen?.();
|
|
48
|
+
}
|
|
49
|
+
/** Hands bytes arriving from the node up to noVNC. */
|
|
50
|
+
receive(data) {
|
|
51
|
+
if (this.readyState !== ChannelSocketState.Open) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
// Copy into a standalone buffer: the incoming view may be backed by
|
|
55
|
+
// wasm memory that is reused or detached after this call returns.
|
|
56
|
+
const buffer = new ArrayBuffer(data.byteLength);
|
|
57
|
+
new Uint8Array(buffer).set(data);
|
|
58
|
+
this.onmessage?.({ data: buffer });
|
|
59
|
+
}
|
|
60
|
+
/** Ends the socket from the phirepass side (tunnel closed, disconnect). */
|
|
61
|
+
closed() {
|
|
62
|
+
if (this.readyState === ChannelSocketState.Closed) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
this.readyState = ChannelSocketState.Closed;
|
|
66
|
+
this.onclose?.();
|
|
67
|
+
}
|
|
68
|
+
failed(error) {
|
|
69
|
+
this.onerror?.(error);
|
|
70
|
+
this.closed();
|
|
71
|
+
}
|
|
72
|
+
// ── the surface noVNC calls ───────────────────────────────────────────────
|
|
73
|
+
send(data) {
|
|
74
|
+
if (this.readyState !== ChannelSocketState.Open) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const bytes = data instanceof ArrayBuffer
|
|
78
|
+
? new Uint8Array(data)
|
|
79
|
+
: new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
80
|
+
// Copy before handing off: noVNC sends views into its own reusable
|
|
81
|
+
// send queue, which it overwrites immediately afterwards.
|
|
82
|
+
this.sendData(new Uint8Array(bytes));
|
|
83
|
+
}
|
|
84
|
+
close() {
|
|
85
|
+
if (this.readyState === ChannelSocketState.Closed) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
this.readyState = ChannelSocketState.Closing;
|
|
89
|
+
this.closeTunnel();
|
|
90
|
+
this.closed();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
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}`;
|
|
95
|
+
|
|
96
|
+
const PhirepassVnc = class {
|
|
97
|
+
constructor(hostRef) {
|
|
98
|
+
registerInstance(this, hostRef);
|
|
99
|
+
this.connectionStateChanged = createEvent(this, "connectionStateChanged");
|
|
100
|
+
}
|
|
101
|
+
channel;
|
|
102
|
+
containerEl;
|
|
103
|
+
socket;
|
|
104
|
+
rfb;
|
|
105
|
+
domReady = false;
|
|
106
|
+
runtimeReady = false;
|
|
107
|
+
connected = false;
|
|
108
|
+
session_id;
|
|
109
|
+
passwordPrompt = false;
|
|
110
|
+
statusMessage;
|
|
111
|
+
passwordBuffer = '';
|
|
112
|
+
get el() { return getElement(this); }
|
|
113
|
+
serverHost = "phirepass.com";
|
|
114
|
+
serverPort = 443;
|
|
115
|
+
allowInsecure = false;
|
|
116
|
+
heartbeatInterval = 30_000;
|
|
117
|
+
nodeId;
|
|
118
|
+
serviceId;
|
|
119
|
+
token;
|
|
120
|
+
/** Scales the remote desktop to fit the widget instead of showing scrollbars. */
|
|
121
|
+
scaleViewport = true;
|
|
122
|
+
/** Asks the VNC server to match its resolution to the widget size. */
|
|
123
|
+
resizeSession = true;
|
|
124
|
+
onNodeIdChange(newValue, _oldValue) {
|
|
125
|
+
this.reset_session_state();
|
|
126
|
+
if (this.channel && this.channel.is_connected()) {
|
|
127
|
+
this.close_comms();
|
|
128
|
+
}
|
|
129
|
+
if (newValue) {
|
|
130
|
+
this.open_comms();
|
|
131
|
+
this.channel.connect();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
serverId;
|
|
135
|
+
onServerIdChange(_newValue, _oldValue) {
|
|
136
|
+
this.onNodeIdChange(this.nodeId, this.nodeId);
|
|
137
|
+
}
|
|
138
|
+
connectionStateChanged;
|
|
139
|
+
create_web_socket_endpoint() {
|
|
140
|
+
const protocol = this.allowInsecure ? 'ws' : 'wss';
|
|
141
|
+
if (!this.allowInsecure && this.serverPort === 443) {
|
|
142
|
+
return `${protocol}://${this.serverHost}`;
|
|
143
|
+
}
|
|
144
|
+
if (this.allowInsecure && this.serverPort === 80) {
|
|
145
|
+
return `${protocol}://${this.serverHost}`;
|
|
146
|
+
}
|
|
147
|
+
return `${protocol}://${this.serverHost}:${this.serverPort}`;
|
|
148
|
+
}
|
|
149
|
+
async connectedCallback() {
|
|
150
|
+
await __wbg_init();
|
|
151
|
+
this.open_comms();
|
|
152
|
+
this.runtimeReady = true;
|
|
153
|
+
if (!this.nodeId) {
|
|
154
|
+
console.warn('Prop node_id is not set. Cannot connect to VNC.');
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
this.try_connect();
|
|
158
|
+
}
|
|
159
|
+
componentDidLoad() {
|
|
160
|
+
this.domReady = true;
|
|
161
|
+
this.try_connect();
|
|
162
|
+
}
|
|
163
|
+
async disconnectedCallback() {
|
|
164
|
+
this.connected = false;
|
|
165
|
+
this.domReady = false;
|
|
166
|
+
this.runtimeReady = false;
|
|
167
|
+
this.close_comms();
|
|
168
|
+
}
|
|
169
|
+
try_connect() {
|
|
170
|
+
if (this.connected || !this.domReady || !this.runtimeReady) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (!this.containerEl || !this.channel) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
this.connect();
|
|
177
|
+
}
|
|
178
|
+
connect() {
|
|
179
|
+
this.connected = true;
|
|
180
|
+
this.channel.connect();
|
|
181
|
+
}
|
|
182
|
+
open_comms() {
|
|
183
|
+
if (this.serverId) {
|
|
184
|
+
this.channel = new Channel(`${this.create_web_socket_endpoint()}/api/web/ws`, this.nodeId, this.serverId);
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
this.channel = new Channel(`${this.create_web_socket_endpoint()}/api/web/ws`, this.nodeId);
|
|
188
|
+
}
|
|
189
|
+
this.channel.on_connection_open(() => {
|
|
190
|
+
this.connectionStateChanged.emit([ConnectionState.Connected]);
|
|
191
|
+
this.channel.authenticate(this.token, this.nodeId);
|
|
192
|
+
});
|
|
193
|
+
this.channel.on_connection_close(() => {
|
|
194
|
+
this.connectionStateChanged.emit([ConnectionState.Disconnected]);
|
|
195
|
+
this.teardown_rfb();
|
|
196
|
+
});
|
|
197
|
+
this.channel.on_connection_error((err) => {
|
|
198
|
+
this.connectionStateChanged.emit([ConnectionState.Error, err]);
|
|
199
|
+
this.socket?.failed(err);
|
|
200
|
+
});
|
|
201
|
+
this.channel.on_connection_message((_raw_) => {
|
|
202
|
+
// raw frames are handled by on_protocol_message below
|
|
203
|
+
});
|
|
204
|
+
this.channel.on_protocol_message((msg) => {
|
|
205
|
+
const { web } = msg.data;
|
|
206
|
+
switch (web.type) {
|
|
207
|
+
case ProtocolMessageType.Error:
|
|
208
|
+
this.handle_error(web);
|
|
209
|
+
break;
|
|
210
|
+
case ProtocolMessageType.AuthSuccess:
|
|
211
|
+
this.handle_auth_success(web);
|
|
212
|
+
break;
|
|
213
|
+
case ProtocolMessageType.TunnelOpened:
|
|
214
|
+
this.handle_tunnel_opened(web);
|
|
215
|
+
break;
|
|
216
|
+
case ProtocolMessageType.TunnelClosed:
|
|
217
|
+
this.handle_tunnel_closed(web);
|
|
218
|
+
break;
|
|
219
|
+
case ProtocolMessageType.TunnelData:
|
|
220
|
+
this.handle_tunnel_data(web);
|
|
221
|
+
break;
|
|
222
|
+
default:
|
|
223
|
+
console.warn('Unknown protocol message type:', web);
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
close_comms() {
|
|
228
|
+
this.teardown_rfb();
|
|
229
|
+
if (this.channel) {
|
|
230
|
+
this.channel.stop_heartbeat();
|
|
231
|
+
this.channel.disconnect();
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
reset_session_state() {
|
|
235
|
+
this.session_id = undefined;
|
|
236
|
+
this.passwordPrompt = false;
|
|
237
|
+
this.passwordBuffer = '';
|
|
238
|
+
this.statusMessage = undefined;
|
|
239
|
+
}
|
|
240
|
+
handle_auth_success(_auth_) {
|
|
241
|
+
this.channel.start_heartbeat(this.heartbeatInterval <= 15_000 ? 30_000 : this.heartbeatInterval);
|
|
242
|
+
this.channel.open_vnc_tunnel(this.nodeId, this.serviceId);
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* The tunnel is a byte pipe from here on: noVNC drives the RFB handshake,
|
|
246
|
+
* including authentication, over the socket adapter.
|
|
247
|
+
*/
|
|
248
|
+
async handle_tunnel_opened(web) {
|
|
249
|
+
this.session_id = web.sid;
|
|
250
|
+
this.statusMessage = undefined;
|
|
251
|
+
const socket = new ChannelSocket((data) => {
|
|
252
|
+
if (this.session_id === undefined) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
this.channel.send_vnc_tunnel_data(this.nodeId, this.session_id, data);
|
|
256
|
+
}, () => this.close_comms());
|
|
257
|
+
this.socket = socket;
|
|
258
|
+
// Loaded on demand so consumers embedding only the terminal or the SFTP
|
|
259
|
+
// client never download the RFB client.
|
|
260
|
+
const { default: RFBClient } = await import('@novnc/novnc');
|
|
261
|
+
// The element may have gone away while the module was loading.
|
|
262
|
+
if (!this.containerEl || this.socket !== socket) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
const rfb = new RFBClient(this.containerEl, socket);
|
|
266
|
+
rfb.scaleViewport = this.scaleViewport;
|
|
267
|
+
rfb.resizeSession = this.resizeSession;
|
|
268
|
+
rfb.addEventListener('credentialsrequired', () => {
|
|
269
|
+
this.passwordPrompt = true;
|
|
270
|
+
});
|
|
271
|
+
rfb.addEventListener('securityfailure', (event) => {
|
|
272
|
+
const detail = event.detail;
|
|
273
|
+
this.statusMessage = detail?.reason ?? 'Authentication failed.';
|
|
274
|
+
this.connectionStateChanged.emit([ConnectionState.Error, detail]);
|
|
275
|
+
});
|
|
276
|
+
rfb.addEventListener('disconnect', () => {
|
|
277
|
+
this.statusMessage = this.statusMessage ?? 'Connection closed.';
|
|
278
|
+
});
|
|
279
|
+
this.rfb = rfb;
|
|
280
|
+
// Only now can noVNC start reading: it attaches on construction.
|
|
281
|
+
socket.open();
|
|
282
|
+
}
|
|
283
|
+
handle_tunnel_data(web) {
|
|
284
|
+
this.socket?.receive(new Uint8Array(web.data));
|
|
285
|
+
}
|
|
286
|
+
handle_tunnel_closed(_web_) {
|
|
287
|
+
this.session_id = undefined;
|
|
288
|
+
this.statusMessage = 'Connection closed.';
|
|
289
|
+
this.teardown_rfb();
|
|
290
|
+
this.close_comms();
|
|
291
|
+
}
|
|
292
|
+
handle_error(error) {
|
|
293
|
+
this.statusMessage = error.message;
|
|
294
|
+
this.connectionStateChanged.emit([ConnectionState.Error, error]);
|
|
295
|
+
this.socket?.failed(error);
|
|
296
|
+
}
|
|
297
|
+
teardown_rfb() {
|
|
298
|
+
if (this.rfb) {
|
|
299
|
+
try {
|
|
300
|
+
this.rfb.disconnect();
|
|
301
|
+
}
|
|
302
|
+
catch (err) {
|
|
303
|
+
console.warn('Failed to disconnect RFB cleanly:', err);
|
|
304
|
+
}
|
|
305
|
+
this.rfb = undefined;
|
|
306
|
+
}
|
|
307
|
+
if (this.socket) {
|
|
308
|
+
this.socket.closed();
|
|
309
|
+
this.socket = undefined;
|
|
310
|
+
}
|
|
311
|
+
this.passwordPrompt = false;
|
|
312
|
+
this.passwordBuffer = '';
|
|
313
|
+
}
|
|
314
|
+
submit_password(event) {
|
|
315
|
+
event.preventDefault();
|
|
316
|
+
this.passwordPrompt = false;
|
|
317
|
+
this.rfb?.sendCredentials({ password: this.passwordBuffer });
|
|
318
|
+
this.passwordBuffer = '';
|
|
319
|
+
}
|
|
320
|
+
render() {
|
|
321
|
+
return (h(Host, { key: '5daf583edea28d1592827dd7b96aff27bf3fd857' }, h("div", { key: '4a5f3d8b64084c3929fc16fdda7eba0de300c188', class: "screen", ref: (el) => (this.containerEl = el) }), this.passwordPrompt && (h("form", { key: 'cadd7db5b5985f332156a93eae953fadd377af54', class: "prompt", onSubmit: (event) => this.submit_password(event) }, h("label", { key: '2c1702e048c5d932e3384bacf65c4a5393aecc79', htmlFor: "vnc-password" }, "VNC password"), h("input", { key: '0e2c947e15bdbf0cd76b6414bc0d22896914af0d', id: "vnc-password", type: "password", autofocus: true, onInput: (event) => (this.passwordBuffer = event.target.value) }), h("button", { key: 'eb5b346b830f449454bb2476d12f08e5fb61a4a5', type: "submit" }, "Connect"))), this.statusMessage && !this.passwordPrompt && (h("div", { key: '28f55f457ae33e774c6914b7f6f9761bdb95b804', class: "status" }, this.statusMessage))));
|
|
322
|
+
}
|
|
323
|
+
static get watchers() { return {
|
|
324
|
+
"nodeId": [{
|
|
325
|
+
"onNodeIdChange": 0
|
|
326
|
+
}],
|
|
327
|
+
"serverId": [{
|
|
328
|
+
"onServerIdChange": 0
|
|
329
|
+
}]
|
|
330
|
+
}; }
|
|
331
|
+
};
|
|
332
|
+
PhirepassVnc.style = phirepassVncCss();
|
|
333
|
+
|
|
334
|
+
export { PhirepassVnc as phirepass_vnc };
|
|
@@ -17,5 +17,5 @@ var patchBrowser = () => {
|
|
|
17
17
|
|
|
18
18
|
patchBrowser().then(async (options) => {
|
|
19
19
|
await globalScripts();
|
|
20
|
-
return bootstrapLazy([["phirepass-sftp-client",[[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",[[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);
|
|
20
|
+
return bootstrapLazy([["phirepass-sftp-client",[[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",[[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",[[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);
|
|
21
21
|
});
|
|
@@ -178,6 +178,20 @@ class Channel {
|
|
|
178
178
|
var len3 = WASM_VECTOR_LEN;
|
|
179
179
|
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);
|
|
180
180
|
}
|
|
181
|
+
/**
|
|
182
|
+
* VNC takes no credentials: the RFB password challenge is answered by the
|
|
183
|
+
* browser's VNC client inside the tunnel itself.
|
|
184
|
+
* @param {string} node_id
|
|
185
|
+
* @param {string} service_id
|
|
186
|
+
* @param {number | null} [msg_id]
|
|
187
|
+
*/
|
|
188
|
+
open_vnc_tunnel(node_id, service_id, msg_id) {
|
|
189
|
+
const ptr0 = passStringToWasm0(node_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
190
|
+
const len0 = WASM_VECTOR_LEN;
|
|
191
|
+
const ptr1 = passStringToWasm0(service_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
192
|
+
const len1 = WASM_VECTOR_LEN;
|
|
193
|
+
wasm.channel_open_vnc_tunnel(this.__wbg_ptr, ptr0, len0, ptr1, len1, isLikeNone(msg_id) ? Number.MAX_SAFE_INTEGER : (msg_id) >>> 0);
|
|
194
|
+
}
|
|
181
195
|
/**
|
|
182
196
|
* @param {string} node_id
|
|
183
197
|
* @param {number} sid
|
|
@@ -308,6 +322,21 @@ class Channel {
|
|
|
308
322
|
const len1 = WASM_VECTOR_LEN;
|
|
309
323
|
wasm.channel_send_ssh_tunnel_data(this.__wbg_ptr, ptr0, len0, sid, ptr1, len1);
|
|
310
324
|
}
|
|
325
|
+
/**
|
|
326
|
+
* Takes bytes rather than a string (unlike [`Channel::send_ssh_tunnel_data`]):
|
|
327
|
+
* RFB client messages are binary and would not survive a UTF-8 round trip.
|
|
328
|
+
* `Vec<u8>` arrives from JS as a `Uint8Array` with no re-encoding.
|
|
329
|
+
* @param {string} node_id
|
|
330
|
+
* @param {number} sid
|
|
331
|
+
* @param {Uint8Array} data
|
|
332
|
+
*/
|
|
333
|
+
send_vnc_tunnel_data(node_id, sid, data) {
|
|
334
|
+
const ptr0 = passStringToWasm0(node_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
335
|
+
const len0 = WASM_VECTOR_LEN;
|
|
336
|
+
const ptr1 = passArray8ToWasm0(data, wasm.__wbindgen_export);
|
|
337
|
+
const len1 = WASM_VECTOR_LEN;
|
|
338
|
+
wasm.channel_send_vnc_tunnel_data(this.__wbg_ptr, ptr0, len0, sid, ptr1, len1);
|
|
339
|
+
}
|
|
311
340
|
/**
|
|
312
341
|
* @param {number} interval_as_millis
|
|
313
342
|
*/
|
|
@@ -433,7 +462,7 @@ function __wbg_get_imports() {
|
|
|
433
462
|
const ret = Reflect.get(getObject(arg0), getObject(arg1));
|
|
434
463
|
return addHeapObject(ret);
|
|
435
464
|
}, arguments); },
|
|
436
|
-
|
|
465
|
+
__wbg_info_126a81f879b26b73: function(arg0, arg1) {
|
|
437
466
|
console.info(getStringFromWasm0(arg0, arg1));
|
|
438
467
|
},
|
|
439
468
|
__wbg_instanceof_ArrayBuffer_4480b9e0068a8adb: function(arg0) {
|
|
@@ -505,7 +534,7 @@ function __wbg_get_imports() {
|
|
|
505
534
|
__wbg_set_onopen_4f65470ae522a61a: function(arg0, arg1) {
|
|
506
535
|
getObject(arg0).onopen = getObject(arg1);
|
|
507
536
|
},
|
|
508
|
-
|
|
537
|
+
__wbg_warn_a34cc328d5dc529a: function(arg0, arg1) {
|
|
509
538
|
console.warn(getStringFromWasm0(arg0, arg1));
|
|
510
539
|
},
|
|
511
540
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as t,c as i,g as s,h as e,H as h}from"./p-DovZQ7sb.js";import{I as r,_ as n,C as o,a as l,P as a,E as u}from"./p-
|
|
1
|
+
import{r as t,c as i,g as s,h as e,H as h}from"./p-DovZQ7sb.js";import{I as r,_ as n,C as o,a as l,P as a,E as u}from"./p-BR2c80mW.js";
|
|
2
2
|
/**
|
|
3
3
|
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
4
4
|
* @license MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as t,c as s,g as e,h as i,H as n}from"./p-DovZQ7sb.js";import{_ as o,C as h,a as r,P as a}from"./p-BR2c80mW.js";var c;!function(t){t[t.Connecting=0]="Connecting",t[t.Open=1]="Open",t[t.Closing=2]="Closing",t[t.Closed=3]="Closed"}(c||(c={}));class d{binaryType="arraybuffer";protocol="";readyState=c.Connecting;onopen=null;onmessage=null;onclose=null;onerror=null;sendData;closeTunnel;constructor(t,s){this.sendData=t,this.closeTunnel=s}open(){this.readyState===c.Connecting&&(this.readyState=c.Open,this.onopen?.())}receive(t){if(this.readyState!==c.Open)return;const s=new ArrayBuffer(t.byteLength);new Uint8Array(s).set(t),this.onmessage?.({data:s})}closed(){this.readyState!==c.Closed&&(this.readyState=c.Closed,this.onclose?.())}failed(t){this.onerror?.(t),this.closed()}send(t){if(this.readyState!==c.Open)return;const s=t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength);this.sendData(new Uint8Array(s))}close(){this.readyState!==c.Closed&&(this.readyState=c.Closing,this.closeTunnel(),this.closed())}}const l=class{constructor(e){t(this,e),this.connectionStateChanged=s(this,"connectionStateChanged")}channel;containerEl;socket;rfb;domReady=!1;runtimeReady=!1;connected=!1;session_id;passwordPrompt=!1;statusMessage;passwordBuffer="";get el(){return e(this)}serverHost="phirepass.com";serverPort=443;allowInsecure=!1;heartbeatInterval=3e4;nodeId;serviceId;token;scaleViewport=!0;resizeSession=!0;onNodeIdChange(t,s){this.reset_session_state(),this.channel&&this.channel.is_connected()&&this.close_comms(),t&&(this.open_comms(),this.channel.connect())}serverId;onServerIdChange(t,s){this.onNodeIdChange(this.nodeId,this.nodeId)}connectionStateChanged;create_web_socket_endpoint(){const t=this.allowInsecure?"ws":"wss";return this.allowInsecure||443!==this.serverPort?this.allowInsecure&&80===this.serverPort?`${t}://${this.serverHost}`:`${t}://${this.serverHost}:${this.serverPort}`:`${t}://${this.serverHost}`}async connectedCallback(){await o(),this.open_comms(),this.runtimeReady=!0,this.nodeId?this.try_connect():console.warn("Prop node_id is not set. Cannot connect to VNC.")}componentDidLoad(){this.domReady=!0,this.try_connect()}async disconnectedCallback(){this.connected=!1,this.domReady=!1,this.runtimeReady=!1,this.close_comms()}try_connect(){!this.connected&&this.domReady&&this.runtimeReady&&this.containerEl&&this.channel&&this.connect()}connect(){this.connected=!0,this.channel.connect()}open_comms(){this.channel=this.serverId?new h(`${this.create_web_socket_endpoint()}/api/web/ws`,this.nodeId,this.serverId):new h(`${this.create_web_socket_endpoint()}/api/web/ws`,this.nodeId),this.channel.on_connection_open((()=>{this.connectionStateChanged.emit([r.Connected]),this.channel.authenticate(this.token,this.nodeId)})),this.channel.on_connection_close((()=>{this.connectionStateChanged.emit([r.Disconnected]),this.teardown_rfb()})),this.channel.on_connection_error((t=>{this.connectionStateChanged.emit([r.Error,t]),this.socket?.failed(t)})),this.channel.on_connection_message((()=>{})),this.channel.on_protocol_message((t=>{const{web:s}=t.data;switch(s.type){case a.Error:this.handle_error(s);break;case a.AuthSuccess:this.handle_auth_success(s);break;case a.TunnelOpened:this.handle_tunnel_opened(s);break;case a.TunnelClosed:this.handle_tunnel_closed(s);break;case a.TunnelData:this.handle_tunnel_data(s);break;default:console.warn("Unknown protocol message type:",s)}}))}close_comms(){this.teardown_rfb(),this.channel&&(this.channel.stop_heartbeat(),this.channel.disconnect())}reset_session_state(){this.session_id=void 0,this.passwordPrompt=!1,this.passwordBuffer="",this.statusMessage=void 0}handle_auth_success(t){this.channel.start_heartbeat(this.heartbeatInterval<=15e3?3e4:this.heartbeatInterval),this.channel.open_vnc_tunnel(this.nodeId,this.serviceId)}async handle_tunnel_opened(t){this.session_id=t.sid,this.statusMessage=void 0;const s=new d((t=>{void 0!==this.session_id&&this.channel.send_vnc_tunnel_data(this.nodeId,this.session_id,t)}),(()=>this.close_comms()));this.socket=s;const{default:e}=await import("@novnc/novnc");if(!this.containerEl||this.socket!==s)return;const i=new e(this.containerEl,s);i.scaleViewport=this.scaleViewport,i.resizeSession=this.resizeSession,i.addEventListener("credentialsrequired",(()=>{this.passwordPrompt=!0})),i.addEventListener("securityfailure",(t=>{const s=t.detail;this.statusMessage=s?.reason??"Authentication failed.",this.connectionStateChanged.emit([r.Error,s])})),i.addEventListener("disconnect",(()=>{this.statusMessage=this.statusMessage??"Connection closed."})),this.rfb=i,s.open()}handle_tunnel_data(t){this.socket?.receive(new Uint8Array(t.data))}handle_tunnel_closed(t){this.session_id=void 0,this.statusMessage="Connection closed.",this.teardown_rfb(),this.close_comms()}handle_error(t){this.statusMessage=t.message,this.connectionStateChanged.emit([r.Error,t]),this.socket?.failed(t)}teardown_rfb(){if(this.rfb){try{this.rfb.disconnect()}catch(t){console.warn("Failed to disconnect RFB cleanly:",t)}this.rfb=void 0}this.socket&&(this.socket.closed(),this.socket=void 0),this.passwordPrompt=!1,this.passwordBuffer=""}submit_password(t){t.preventDefault(),this.passwordPrompt=!1,this.rfb?.sendCredentials({password:this.passwordBuffer}),this.passwordBuffer=""}render(){return i(n,{key:"5daf583edea28d1592827dd7b96aff27bf3fd857"},i("div",{key:"4a5f3d8b64084c3929fc16fdda7eba0de300c188",class:"screen",ref:t=>this.containerEl=t}),this.passwordPrompt&&i("form",{key:"cadd7db5b5985f332156a93eae953fadd377af54",class:"prompt",onSubmit:t=>this.submit_password(t)},i("label",{key:"2c1702e048c5d932e3384bacf65c4a5393aecc79",htmlFor:"vnc-password"},"VNC password"),i("input",{key:"0e2c947e15bdbf0cd76b6414bc0d22896914af0d",id:"vnc-password",type:"password",autofocus:!0,onInput:t=>this.passwordBuffer=t.target.value}),i("button",{key:"eb5b346b830f449454bb2476d12f08e5fb61a4a5",type:"submit"},"Connect")),this.statusMessage&&!this.passwordPrompt&&i("div",{key:"28f55f457ae33e774c6914b7f6f9761bdb95b804",class:"status"},this.statusMessage))}static get watchers(){return{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}}};l.style=':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}';export{l as phirepass_vnc}
|