phirepass-widgets 0.0.79 → 0.0.81
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-rdp.cjs.entry.js +308 -0
- package/dist/cjs/phirepass-sftp-client.cjs.entry.js +17 -17
- package/dist/cjs/phirepass-terminal.cjs.entry.js +2 -2
- package/dist/cjs/phirepass-widgets.cjs.js +1 -1
- package/dist/cjs/{protocol-DC4eLkqJ.js → protocol-DS0qXomZ.js} +25 -26
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/common/protocol.js +1 -0
- package/dist/collection/components/{phirepass-vnc/phirepass-vnc.css → phirepass-rdp/phirepass-rdp.css} +9 -2
- package/dist/collection/components/{phirepass-vnc/phirepass-vnc.js → phirepass-rdp/phirepass-rdp.js} +198 -90
- package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.js +16 -16
- package/dist/collection/components/phirepass-terminal/phirepass-terminal.js +1 -1
- package/dist/collection/phirepass-channel_bg.wasm +0 -0
- package/dist/components/p-CWIhN33k.js +1 -0
- package/dist/components/{phirepass-vnc.d.ts → phirepass-rdp.d.ts} +4 -4
- package/dist/components/phirepass-rdp.js +1 -0
- package/dist/components/phirepass-sftp-client.js +1 -1
- package/dist/components/phirepass-terminal.js +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/phirepass-rdp.entry.js +306 -0
- package/dist/esm/phirepass-sftp-client.entry.js +17 -17
- package/dist/esm/phirepass-terminal.entry.js +2 -2
- package/dist/esm/phirepass-widgets.js +1 -1
- package/dist/esm/{protocol-BR2c80mW.js → protocol-CWIhN33k.js} +24 -25
- package/dist/phirepass-widgets/{p-339cd54e.entry.js → p-19789356.entry.js} +1 -1
- package/dist/phirepass-widgets/{p-14c7611f.entry.js → p-2478a6eb.entry.js} +2 -2
- package/dist/phirepass-widgets/p-CWIhN33k.js +1 -0
- package/dist/phirepass-widgets/p-a5528005.entry.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/protocol.d.ts +17 -1
- package/dist/types/components/phirepass-rdp/phirepass-rdp.d.ts +90 -0
- package/dist/types/components.d.ts +136 -90
- package/package.json +4 -3
- package/dist/cjs/phirepass-vnc.cjs.entry.js +0 -336
- package/dist/collection/common/channel-socket.js +0 -89
- package/dist/components/p-BR2c80mW.js +0 -1
- package/dist/components/phirepass-vnc.js +0 -1
- package/dist/esm/phirepass-vnc.entry.js +0 -334
- package/dist/phirepass-widgets/p-19e2a30c.entry.js +0 -1
- package/dist/phirepass-widgets/p-BR2c80mW.js +0 -1
- package/dist/types/common/channel-socket.d.ts +0 -47
- package/dist/types/common/novnc.d.ts +0 -53
- package/dist/types/components/phirepass-vnc/phirepass-vnc.d.ts +0 -52
|
@@ -1,336 +0,0 @@
|
|
|
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;
|
|
@@ -1,89 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
class n{__destroy_into_raw(){const n=this.__wbg_ptr;return this.__wbg_ptr=0,_.unregister(this),n}free(){const n=this.__destroy_into_raw();P.__wbg_channel_free(n,0)}authenticate(n,t,e){const r=N(n,P.__wbindgen_export,P.__wbindgen_export2),o=k,c=N(t,P.__wbindgen_export,P.__wbindgen_export2);P.channel_authenticate(this.__wbg_ptr,r,o,c,k,R(e)?Number.MAX_SAFE_INTEGER:e>>>0)}connect(){P.channel_connect(this.__wbg_ptr)}create_service(n,t,e,r,o,c,i,s,_,u){const a=N(n,P.__wbindgen_export,P.__wbindgen_export2),f=k,b=N(t,P.__wbindgen_export,P.__wbindgen_export2),l=k;var d=R(e)?0:N(e,P.__wbindgen_export,P.__wbindgen_export2),w=k;const g=N(r,P.__wbindgen_export,P.__wbindgen_export2),h=k;var p=R(c)?0:N(c,P.__wbindgen_export,P.__wbindgen_export2),y=k,m=R(i)?0:N(i,P.__wbindgen_export,P.__wbindgen_export2),v=k,A=R(s)?0:N(s,P.__wbindgen_export,P.__wbindgen_export2),S=k,T=R(_)?0:N(_,P.__wbindgen_export,P.__wbindgen_export2);P.channel_create_service(this.__wbg_ptr,a,f,b,l,d,w,g,h,o,p,y,m,v,A,S,T,k,R(u)?Number.MAX_SAFE_INTEGER:u>>>0)}delete_service(n,t,e){const r=N(n,P.__wbindgen_export,P.__wbindgen_export2),o=k,c=N(t,P.__wbindgen_export,P.__wbindgen_export2);P.channel_delete_service(this.__wbg_ptr,r,o,c,k,R(e)?Number.MAX_SAFE_INTEGER:e>>>0)}disconnect(){P.channel_disconnect(this.__wbg_ptr)}is_connected(){return 0!==P.channel_is_connected(this.__wbg_ptr)}is_disconnected(){return 0!==P.channel_is_disconnected(this.__wbg_ptr)}constructor(n,t,e){const r=N(n,P.__wbindgen_export,P.__wbindgen_export2),o=k,c=N(t,P.__wbindgen_export,P.__wbindgen_export2),i=k;var s=R(e)?0:N(e,P.__wbindgen_export,P.__wbindgen_export2);const u=P.channel_new(r,o,c,i,s,k);return this.__wbg_ptr=u,_.register(this,this.__wbg_ptr,this),this}on_connection_close(n){P.channel_on_connection_close(this.__wbg_ptr,R(n)?0:u(n))}on_connection_error(n){P.channel_on_connection_error(this.__wbg_ptr,R(n)?0:u(n))}on_connection_message(n){P.channel_on_connection_message(this.__wbg_ptr,R(n)?0:u(n))}on_connection_open(n){P.channel_on_connection_open(this.__wbg_ptr,R(n)?0:u(n))}on_protocol_message(n){P.channel_on_protocol_message(this.__wbg_ptr,R(n)?0:u(n))}on_protocol_message_type(n,t){const e=N(n,P.__wbindgen_export,P.__wbindgen_export2);P.channel_on_protocol_message_type(this.__wbg_ptr,e,k,R(t)?0:u(t))}open_sftp_tunnel(n,t,e,r,o){const c=N(n,P.__wbindgen_export,P.__wbindgen_export2),i=k,s=N(t,P.__wbindgen_export,P.__wbindgen_export2),_=k;var u=R(e)?0:N(e,P.__wbindgen_export,P.__wbindgen_export2),a=k,f=R(r)?0:N(r,P.__wbindgen_export,P.__wbindgen_export2);P.channel_open_sftp_tunnel(this.__wbg_ptr,c,i,s,_,u,a,f,k,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}open_ssh_tunnel(n,t,e,r,o){const c=N(n,P.__wbindgen_export,P.__wbindgen_export2),i=k,s=N(t,P.__wbindgen_export,P.__wbindgen_export2),_=k;var u=R(e)?0:N(e,P.__wbindgen_export,P.__wbindgen_export2),a=k,f=R(r)?0:N(r,P.__wbindgen_export,P.__wbindgen_export2);P.channel_open_ssh_tunnel(this.__wbg_ptr,c,i,s,_,u,a,f,k,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}open_vnc_tunnel(n,t,e){const r=N(n,P.__wbindgen_export,P.__wbindgen_export2),o=k,c=N(t,P.__wbindgen_export,P.__wbindgen_export2);P.channel_open_vnc_tunnel(this.__wbg_ptr,r,o,c,k,R(e)?Number.MAX_SAFE_INTEGER:e>>>0)}send_sftp_delete(n,t,e,r,o){const c=N(n,P.__wbindgen_export,P.__wbindgen_export2),i=k,s=N(e,P.__wbindgen_export,P.__wbindgen_export2),_=k,u=N(r,P.__wbindgen_export,P.__wbindgen_export2);P.channel_send_sftp_delete(this.__wbg_ptr,c,i,t,s,_,u,k,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_sftp_download_ack(n,t,e,r){const o=N(n,P.__wbindgen_export,P.__wbindgen_export2);P.channel_send_sftp_download_ack(this.__wbg_ptr,o,k,t,e,r)}send_sftp_download_chunk(n,t,e,r,o){const c=N(n,P.__wbindgen_export,P.__wbindgen_export2);P.channel_send_sftp_download_chunk(this.__wbg_ptr,c,k,t,e,r,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_sftp_download_start(n,t,e,r,o){const c=N(n,P.__wbindgen_export,P.__wbindgen_export2),i=k,s=N(e,P.__wbindgen_export,P.__wbindgen_export2),_=k,u=N(r,P.__wbindgen_export,P.__wbindgen_export2);P.channel_send_sftp_download_start(this.__wbg_ptr,c,i,t,s,_,u,k,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_sftp_list_data(n,t,e,r){const o=N(n,P.__wbindgen_export,P.__wbindgen_export2),c=k,i=N(e,P.__wbindgen_export,P.__wbindgen_export2);P.channel_send_sftp_list_data(this.__wbg_ptr,o,c,t,i,k,R(r)?Number.MAX_SAFE_INTEGER:r>>>0)}send_sftp_upload_chunk(n,t,e,r,o,c,i){const s=N(n,P.__wbindgen_export,P.__wbindgen_export2),_=k,u=S(c,P.__wbindgen_export);P.channel_send_sftp_upload_chunk(this.__wbg_ptr,s,_,t,e,r,o,u,k,R(i)?Number.MAX_SAFE_INTEGER:i>>>0)}send_sftp_upload_start(n,t,e,r,o,c,i){const s=N(n,P.__wbindgen_export,P.__wbindgen_export2),_=k,u=N(e,P.__wbindgen_export,P.__wbindgen_export2),a=k,f=N(r,P.__wbindgen_export,P.__wbindgen_export2);P.channel_send_sftp_upload_start(this.__wbg_ptr,s,_,t,u,a,f,k,o,c,R(i)?Number.MAX_SAFE_INTEGER:i>>>0)}send_ssh_terminal_resize(n,t,e,r,o,c){const i=N(n,P.__wbindgen_export,P.__wbindgen_export2);P.channel_send_ssh_terminal_resize(this.__wbg_ptr,i,k,t,e,r,o,c)}send_ssh_tunnel_data(n,t,e){const r=N(n,P.__wbindgen_export,P.__wbindgen_export2),o=k,c=N(e,P.__wbindgen_export,P.__wbindgen_export2);P.channel_send_ssh_tunnel_data(this.__wbg_ptr,r,o,t,c,k)}send_vnc_tunnel_data(n,t,e){const r=N(n,P.__wbindgen_export,P.__wbindgen_export2),o=k,c=S(e,P.__wbindgen_export);P.channel_send_vnc_tunnel_data(this.__wbg_ptr,r,o,t,c,k)}start_heartbeat(n){P.channel_start_heartbeat(this.__wbg_ptr,n)}stop_heartbeat(){P.channel_stop_heartbeat(this.__wbg_ptr)}update_service(n,t,e,r,o,c,i,s,_,u,a){const f=N(n,P.__wbindgen_export,P.__wbindgen_export2),b=k,l=N(t,P.__wbindgen_export,P.__wbindgen_export2),d=k,w=N(e,P.__wbindgen_export,P.__wbindgen_export2),g=k;var h=R(r)?0:N(r,P.__wbindgen_export,P.__wbindgen_export2),p=k;const y=N(o,P.__wbindgen_export,P.__wbindgen_export2),m=k;var v=R(i)?0:N(i,P.__wbindgen_export,P.__wbindgen_export2),A=k,S=R(s)?0:N(s,P.__wbindgen_export,P.__wbindgen_export2),T=k,U=R(_)?0:N(_,P.__wbindgen_export,P.__wbindgen_export2),j=k,F=R(u)?0:N(u,P.__wbindgen_export,P.__wbindgen_export2);P.channel_update_service(this.__wbg_ptr,f,b,l,d,w,g,h,p,y,m,c,v,A,S,T,U,j,F,k,R(a)?Number.MAX_SAFE_INTEGER:a>>>0)}}Symbol.dispose&&(n.prototype[Symbol.dispose]=n.prototype.free);const t=Object.freeze({Generic:0,0:"Generic",Authentication:10,10:"Authentication",RequiresUsername:100,100:"RequiresUsername",RequiresPassword:110,110:"RequiresPassword",RequiresUsernamePassword:120,120:"RequiresUsernamePassword"});function e(){const n={__proto__:null,__wbg_Error_92b29b0548f8b746:function(n,t){return u(Error(w(n,t)))},__wbg_String_8564e559799eccda:function(n,t){const e=N(String(p(t)),P.__wbindgen_export,P.__wbindgen_export2),r=k;d().setInt32(n+4,r,!0),d().setInt32(n+0,e,!0)},__wbg___wbindgen_debug_string_c25d447a39f5578f:function(n,t){const e=N(f(p(t)),P.__wbindgen_export,P.__wbindgen_export2),r=k;d().setInt32(n+4,r,!0),d().setInt32(n+0,e,!0)},__wbg___wbindgen_string_get_b0ca35b86a603356:function(n,t){const e=p(t),r="string"==typeof e?e:void 0;var o=R(r)?0:N(r,P.__wbindgen_export,P.__wbindgen_export2),c=k;d().setInt32(n+4,c,!0),d().setInt32(n+0,o,!0)},__wbg___wbindgen_throw_344f42d3211c4765:function(n,t){throw new Error(w(n,t))},__wbg__wbg_cb_unref_fffb441def202758:function(n){p(n)._wbg_cb_unref()},__wbg_call_8a2dd23819f8a60a:function(){return y((function(n,t){return u(p(n).call(p(t)))}),arguments)},__wbg_call_a6e5c5dce5018821:function(){return y((function(n,t,e){return u(p(n).call(p(t),p(e)))}),arguments)},__wbg_call_e3b662382210db98:function(){return y((function(n,t,e,r){return u(p(n).call(p(t),p(e),p(r)))}),arguments)},__wbg_clearInterval_26ba580547547579:function(n){return u(clearInterval(T(n)))},__wbg_close_c65ca0257e895318:function(){return y((function(n){p(n).close()}),arguments)},__wbg_data_328de4280640da92:function(n){return u(p(n).data)},__wbg_from_13e323c65fc8f464:function(n){return u(Array.from(p(n)))},__wbg_getRandomValues_3f44b700395062e5:function(){return y((function(n,t){globalThis.crypto.getRandomValues(b(n,t))}),arguments)},__wbg_get_78f252d074a84d0b:function(){return y((function(n,t){return u(Reflect.get(p(n),p(t)))}),arguments)},__wbg_info_126a81f879b26b73:function(n,t){console.info(w(n,t))},__wbg_instanceof_ArrayBuffer_4480b9e0068a8adb:function(n){let t;try{t=p(n)instanceof ArrayBuffer}catch(n){t=!1}return t},__wbg_length_1f0964f4a5e2c6d8:function(n){return p(n).length},__wbg_new_32b398fb48b6d94a:function(){return u(new Array)},__wbg_new_cd45aabdf6073e84:function(n){return u(new Uint8Array(p(n)))},__wbg_new_da52cf8fe3429cb2:function(){return u(new Object)},__wbg_new_with_str_sequence_2de2f569c29910ad:function(){return y((function(n,t,e){return u(new WebSocket(w(n,t),p(e)))}),arguments)},__wbg_prototypesetcall_4770620bbe4688a0:function(n,t,e){Uint8Array.prototype.set.call(b(n,t),p(e))},__wbg_push_d2ae3af0c1217ae6:function(n,t){return p(n).push(p(t))},__wbg_readyState_50bc38c2a9e83db6:function(n){return p(n).readyState},__wbg_send_a321b376d40ec867:function(){return y((function(n,t,e){p(n).send(b(t,e))}),arguments)},__wbg_setInterval_cbf1c35c6a692d37:function(){return y((function(n,t){return u(setInterval(p(n),t))}),arguments)},__wbg_set_6be42768c690e380:function(n,t,e){p(n)[T(t)]=T(e)},__wbg_set_8a16b38e4805b298:function(n,t,e){p(n)[t>>>0]=T(e)},__wbg_set_binaryType_a37b086c78ca7c29:function(n,t){p(n).binaryType=s[t]},__wbg_set_onclose_f706475385ecce07:function(n,t){p(n).onclose=p(t)},__wbg_set_onerror_9f5773fd31512333:function(n,t){p(n).onerror=p(t)},__wbg_set_onmessage_836d2f72130b4706:function(n,t){p(n).onmessage=p(t)},__wbg_set_onopen_4f65470ae522a61a:function(n,t){p(n).onopen=p(t)},__wbg_warn_a34cc328d5dc529a:function(n,t){console.warn(w(n,t))},__wbindgen_cast_0000000000000001:function(n,t){return u(A(n,t,o))},__wbindgen_cast_0000000000000002:function(n,t){return u(A(n,t,c))},__wbindgen_cast_0000000000000003:function(n,t){return u(A(n,t,i))},__wbindgen_cast_0000000000000004:function(n,t){return u(A(n,t,r))},__wbindgen_cast_0000000000000005:function(n){return u(n)},__wbindgen_cast_0000000000000006:function(n,t){return u(b(n,t))},__wbindgen_cast_0000000000000007:function(n,t){return u(w(n,t))},__wbindgen_cast_0000000000000008:function(n){return u(BigInt.asUintN(64,n))},__wbindgen_object_clone_ref:function(n){return u(p(n))},__wbindgen_object_drop_ref:function(n){T(n)}};return{__proto__:null,"./phirepass-channel_bg.js":n}}function r(n,t){P.__wasm_bindgen_func_elem_63(n,t)}function o(n,t,e){P.__wasm_bindgen_func_elem_59(n,t,u(e))}function c(n,t,e){P.__wasm_bindgen_func_elem_59_1(n,t,u(e))}function i(n,t,e){P.__wasm_bindgen_func_elem_59_2(n,t,u(e))}const s=["blob","arraybuffer"],_="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((n=>P.__wbg_channel_free(n,1)));function u(n){v===m.length&&m.push(m.length+1);const t=v;return v=m[t],m[t]=n,t}const a="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((n=>P.__wbindgen_export4(n.a,n.b)));function f(n){const t=typeof n;if("number"==t||"boolean"==t||null==n)return`${n}`;if("string"==t)return`"${n}"`;if("symbol"==t){const t=n.description;return null==t?"Symbol":`Symbol(${t})`}if("function"==t){const t=n.name;return"string"==typeof t&&t.length>0?`Function(${t})`:"Function"}if(Array.isArray(n)){const t=n.length;let e="[";t>0&&(e+=f(n[0]));for(let r=1;r<t;r++)e+=", "+f(n[r]);return e+="]",e}const e=/\[object ([^\]]+)\]/.exec(toString.call(n));let r;if(!(e&&e.length>1))return toString.call(n);if(r=e[1],"Object"==r)try{return"Object("+JSON.stringify(n)+")"}catch(n){return"Object"}return n instanceof Error?`${n.name}: ${n.message}\n${n.stack}`:r}function b(n,t){return n>>>=0,h().subarray(n/1,n/1+t)}let l=null;function d(){return(null===l||!0===l.buffer.detached||void 0===l.buffer.detached&&l.buffer!==P.memory.buffer)&&(l=new DataView(P.memory.buffer)),l}function w(n,t){return function(n,t){return F+=t,F>=j&&(U=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),U.decode(),F=t),U.decode(h().subarray(n,n+t))}(n>>>0,t)}let g=null;function h(){return null!==g&&0!==g.byteLength||(g=new Uint8Array(P.memory.buffer)),g}function p(n){return m[n]}function y(n,t){try{return n.apply(this,t)}catch(n){P.__wbindgen_export3(u(n))}}let m=new Array(1024).fill(void 0);m.push(void 0,null,!0,!1);let v=m.length;function R(n){return null==n}function A(n,t,e){const r={a:n,b:t,cnt:1},o=(...n)=>{r.cnt++;const t=r.a;r.a=0;try{return e(t,r.b,...n)}finally{r.a=t,o._wbg_cb_unref()}};return o._wbg_cb_unref=()=>{0==--r.cnt&&(P.__wbindgen_export4(r.a,r.b),r.a=0,a.unregister(r))},a.register(o,r,r),o}function S(n,t){const e=t(1*n.length,1)>>>0;return h().set(n,e/1),k=n.length,e}function N(n,t,e){if(void 0===e){const e=O.encode(n),r=t(e.length,1)>>>0;return h().subarray(r,r+e.length).set(e),k=e.length,r}let r=n.length,o=t(r,1)>>>0;const c=h();let i=0;for(;i<r;i++){const t=n.charCodeAt(i);if(t>127)break;c[o+i]=t}if(i!==r){0!==i&&(n=n.slice(i)),o=e(o,r,r=i+3*n.length,1)>>>0;const t=h().subarray(o+i,o+r);i+=O.encodeInto(n,t).written,o=e(o,r,i,1)>>>0}return k=i,o}function T(n){const t=p(n);return function(n){n<1028||(m[n]=v,v=n)}(n),t}let U=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});U.decode();const j=2146435072;let F=0;const O=new TextEncoder;"encodeInto"in O||(O.encodeInto=function(n,t){const e=O.encode(n);return t.set(e),{read:n.length,written:e.length}});let P,k=0;async function q(n){if(void 0!==P)return P;void 0!==n&&(Object.getPrototypeOf(n)===Object.prototype?({module_or_path:n}=n):console.warn("using deprecated parameters for the initialization function; pass a single object instead")),void 0===n&&(n=new URL("phirepass-channel_bg.wasm",import.meta.url));const t=e();("string"==typeof n||"function"==typeof Request&&n instanceof Request||"function"==typeof URL&&n instanceof URL)&&(n=fetch(n));const{instance:r}=await async function(n,t){if("function"==typeof Response&&n instanceof Response){if("function"==typeof WebAssembly.instantiateStreaming)try{return await WebAssembly.instantiateStreaming(n,t)}catch(t){if(!n.ok||!function(n){switch(n){case"basic":case"cors":case"default":return!0}return!1}(n.type)||"application/wasm"===n.headers.get("Content-Type"))throw t;console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",t)}const e=await n.arrayBuffer();return await WebAssembly.instantiate(e,t)}{const e=await WebAssembly.instantiate(n,t);return e instanceof WebAssembly.Instance?{instance:e,module:n}:e}}(await n,t);return function(n){return P=n.exports,l=null,g=null,P}(r)}var I,W,E;!function(n){n.Error="Error",n.AuthSuccess="AuthSuccess",n.TunnelOpened="TunnelOpened",n.TunnelClosed="TunnelClosed",n.TunnelData="TunnelData",n.SFTPListItems="SFTPListItems",n.SFTPDownloadStartResponse="SFTPDownloadStartResponse",n.SFTPDownloadChunk="SFTPDownloadChunk",n.SFTPUploadStartResponse="SFTPUploadStartResponse",n.SFTPUploadChunkAck="SFTPUploadChunkAck"}(I||(I={})),function(n){n[n.Username=0]="Username",n[n.Password=1]="Password",n[n.Default=2]="Default"}(W||(W={})),function(n){n.Disconnected="disconnected",n.Connected="connected",n.Error="error"}(E||(E={}));export{n as C,t as E,W as I,I as P,q as _,E as a}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t,p as e,H as s,c as i,h as n,a as o}from"./index.js";import{_ as r,C as h,a,P as c}from"./p-BR2c80mW.js";var d;!function(t){t[t.Connecting=0]="Connecting",t[t.Open=1]="Open",t[t.Closing=2]="Closing",t[t.Closed=3]="Closed"}(d||(d={}));class l{binaryType="arraybuffer";protocol="";readyState=d.Connecting;onopen=null;onmessage=null;onclose=null;onerror=null;sendData;closeTunnel;constructor(t,e){this.sendData=t,this.closeTunnel=e}open(){this.readyState===d.Connecting&&(this.readyState=d.Open,this.onopen?.())}receive(t){if(this.readyState!==d.Open)return;const e=new ArrayBuffer(t.byteLength);new Uint8Array(e).set(t),this.onmessage?.({data:e})}closed(){this.readyState!==d.Closed&&(this.readyState=d.Closed,this.onclose?.())}failed(t){this.onerror?.(t),this.closed()}send(t){if(this.readyState!==d.Open)return;const e=t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength);this.sendData(new Uint8Array(e))}close(){this.readyState!==d.Closed&&(this.readyState=d.Closing,this.closeTunnel(),this.closed())}}const p=e(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.connectionStateChanged=i(this,"connectionStateChanged")}channel;containerEl;socket;rfb;domReady=!1;runtimeReady=!1;connected=!1;session_id;passwordPrompt=!1;statusMessage;passwordBuffer="";get el(){return this}serverHost="phirepass.com";serverPort=443;allowInsecure=!1;heartbeatInterval=3e4;nodeId;serviceId;token;scaleViewport=!0;resizeSession=!0;onNodeIdChange(t,e){this.reset_session_state(),this.channel&&this.channel.is_connected()&&this.close_comms(),t&&(this.open_comms(),this.channel.connect())}serverId;onServerIdChange(t,e){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 r(),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([a.Connected]),this.channel.authenticate(this.token,this.nodeId)})),this.channel.on_connection_close((()=>{this.connectionStateChanged.emit([a.Disconnected]),this.teardown_rfb()})),this.channel.on_connection_error((t=>{this.connectionStateChanged.emit([a.Error,t]),this.socket?.failed(t)})),this.channel.on_connection_message((()=>{})),this.channel.on_protocol_message((t=>{const{web:e}=t.data;switch(e.type){case c.Error:this.handle_error(e);break;case c.AuthSuccess:this.handle_auth_success(e);break;case c.TunnelOpened:this.handle_tunnel_opened(e);break;case c.TunnelClosed:this.handle_tunnel_closed(e);break;case c.TunnelData:this.handle_tunnel_data(e);break;default:console.warn("Unknown protocol message type:",e)}}))}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 e=new l((t=>{void 0!==this.session_id&&this.channel.send_vnc_tunnel_data(this.nodeId,this.session_id,t)}),(()=>this.close_comms()));this.socket=e;const{default:s}=await import("@novnc/novnc");if(!this.containerEl||this.socket!==e)return;const i=new s(this.containerEl,e);i.scaleViewport=this.scaleViewport,i.resizeSession=this.resizeSession,i.addEventListener("credentialsrequired",(()=>{this.passwordPrompt=!0})),i.addEventListener("securityfailure",(t=>{const e=t.detail;this.statusMessage=e?.reason??"Authentication failed.",this.connectionStateChanged.emit([a.Error,e])})),i.addEventListener("disconnect",(()=>{this.statusMessage=this.statusMessage??"Connection closed."})),this.rfb=i,e.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([a.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 n(o,{key:"5daf583edea28d1592827dd7b96aff27bf3fd857"},n("div",{key:"4a5f3d8b64084c3929fc16fdda7eba0de300c188",class:"screen",ref:t=>this.containerEl=t}),this.passwordPrompt&&n("form",{key:"cadd7db5b5985f332156a93eae953fadd377af54",class:"prompt",onSubmit:t=>this.submit_password(t)},n("label",{key:"2c1702e048c5d932e3384bacf65c4a5393aecc79",htmlFor:"vnc-password"},"VNC password"),n("input",{key:"0e2c947e15bdbf0cd76b6414bc0d22896914af0d",id:"vnc-password",type:"password",autofocus:!0,onInput:t=>this.passwordBuffer=t.target.value}),n("button",{key:"eb5b346b830f449454bb2476d12f08e5fb61a4a5",type:"submit"},"Connect")),this.statusMessage&&!this.passwordPrompt&&n("div",{key:"28f55f457ae33e774c6914b7f6f9761bdb95b804",class:"status"},this.statusMessage))}static get watchers(){return{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}}static get style(){return':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}'}},[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]},void 0,{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}]);function u(){"undefined"!=typeof customElements&&["phirepass-vnc"].forEach((e=>{"phirepass-vnc"===e&&(customElements.get(t(e))||customElements.define(t(e),p))}))}u();const f=p,b=u;export{f as PhirepassVnc,b as defineCustomElement}
|