phirepass-widgets 0.0.114 → 0.0.116

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.
Files changed (45) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/phirepass-downloader_3.cjs.entry.js +134 -39
  3. package/dist/cjs/phirepass-rdp.cjs.entry.js +2 -2
  4. package/dist/cjs/phirepass-terminal.cjs.entry.js +3 -3
  5. package/dist/cjs/phirepass-widgets.cjs.js +1 -1
  6. package/dist/cjs/{protocol-CYh109n2.js → protocol-BjOgJZ9-.js} +34 -9
  7. package/dist/collection/components/phirepass-downloader/jobs.js +22 -2
  8. package/dist/collection/components/phirepass-downloader/views/icons.js +1 -0
  9. package/dist/collection/components/phirepass-media-player/phirepass-media-player.css +9 -0
  10. package/dist/collection/components/phirepass-media-player/phirepass-media-player.js +79 -3
  11. package/dist/collection/components/phirepass-media-player/player.js +24 -0
  12. package/dist/collection/components/phirepass-rdp/phirepass-rdp.js +1 -1
  13. package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.js +33 -33
  14. package/dist/collection/components/phirepass-terminal/phirepass-terminal.js +2 -2
  15. package/dist/collection/phirepass-channel_bg.wasm +0 -0
  16. package/dist/components/p-5QoAejYG.js +1 -0
  17. package/dist/components/p-BekUePpu.js +1 -0
  18. package/dist/components/p-DIf-Ru26.js +1 -0
  19. package/dist/components/phirepass-downloader.js +1 -1
  20. package/dist/components/phirepass-media-player.js +1 -1
  21. package/dist/components/phirepass-rdp.js +1 -1
  22. package/dist/components/phirepass-sftp-client.js +1 -1
  23. package/dist/components/phirepass-terminal.js +5 -5
  24. package/dist/esm/loader.js +1 -1
  25. package/dist/esm/phirepass-downloader_3.entry.js +134 -39
  26. package/dist/esm/phirepass-rdp.entry.js +2 -2
  27. package/dist/esm/phirepass-terminal.entry.js +3 -3
  28. package/dist/esm/phirepass-widgets.js +1 -1
  29. package/dist/esm/{protocol-BtMWUitf.js → protocol-BekUePpu.js} +33 -8
  30. package/dist/phirepass-widgets/{p-a4a5e5f5.entry.js → p-70a67e4d.entry.js} +1 -1
  31. package/dist/phirepass-widgets/p-BekUePpu.js +1 -0
  32. package/dist/phirepass-widgets/p-ab33f71f.entry.js +1 -0
  33. package/dist/phirepass-widgets/{p-a5ce104d.entry.js → p-c28a9257.entry.js} +2 -2
  34. package/dist/phirepass-widgets/phirepass-channel_bg.wasm +0 -0
  35. package/dist/phirepass-widgets/phirepass-widgets.esm.js +1 -1
  36. package/dist/types/components/phirepass-downloader/jobs.d.ts +7 -0
  37. package/dist/types/components/phirepass-media-player/phirepass-media-player.d.ts +16 -1
  38. package/dist/types/components/phirepass-media-player/player.d.ts +10 -0
  39. package/dist/types/components.d.ts +10 -2
  40. package/package.json +5 -5
  41. package/dist/components/p-BtMWUitf.js +0 -1
  42. package/dist/components/p-C4cmk3bS.js +0 -1
  43. package/dist/components/p-CKnb-oeB.js +0 -1
  44. package/dist/phirepass-widgets/p-97d84225.entry.js +0 -1
  45. package/dist/phirepass-widgets/p-BtMWUitf.js +0 -1
@@ -536,6 +536,31 @@ class Channel {
536
536
  }
537
537
  wasm.channel_send_sftp_mkdir(this.__wbg_ptr, ptr0, len0, val3, ptr1, len1, val4);
538
538
  }
539
+ /**
540
+ * Ask the node to let a player read `path` through this SFTP session.
541
+ * Answered with `SFTPOpResult::Stream { token, size, mime }`; the player
542
+ * then reads `/api/web/stream/{node_id}/t/{token}`.
543
+ * @param {string} node_id
544
+ * @param {number} sid
545
+ * @param {string} path
546
+ * @param {number | null} [msg_id]
547
+ */
548
+ send_sftp_open_stream(node_id, sid, path, msg_id) {
549
+ const val3 = +sid;
550
+ const val4 = +(isLikeNone(msg_id) ? Number.MAX_SAFE_INTEGER : (msg_id) >>> 0);
551
+ let ptr0, len0, ptr1, len1;
552
+ try {
553
+ ptr0 = passStringToWasm0(node_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
554
+ len0 = WASM_VECTOR_LEN;
555
+ ptr1 = passStringToWasm0(path, wasm.__wbindgen_export, wasm.__wbindgen_export2);
556
+ len1 = WASM_VECTOR_LEN;
557
+ } catch (e) {
558
+ if (ptr1) { wasm.__wbindgen_export3(ptr1, len1 * 1, 1); }
559
+ if (ptr0) { wasm.__wbindgen_export3(ptr0, len0 * 1, 1); }
560
+ throw e;
561
+ }
562
+ wasm.channel_send_sftp_open_stream(this.__wbg_ptr, ptr0, len0, val3, ptr1, len1, val4);
563
+ }
539
564
  /**
540
565
  * Read a whole file for the in-page editor. Answered with an
541
566
  * `SFTPOpResult` carrying `FileContents`, or an `Error` if the file is
@@ -956,7 +981,7 @@ function __wbg_get_imports() {
956
981
  const ret = arg0[arg1];
957
982
  return ret;
958
983
  },
959
- __wbg_info_b0bac022aae81d46: function(arg0, arg1) {
984
+ __wbg_info_386f00b314475db5: function(arg0, arg1) {
960
985
  console.info(getStringFromWasm0(arg0, arg1));
961
986
  },
962
987
  __wbg_instanceof_ArrayBuffer_12cdaa4161423e6b: function(arg0) {
@@ -1066,7 +1091,7 @@ function __wbg_get_imports() {
1066
1091
  const ret = arg0.value;
1067
1092
  return ret;
1068
1093
  },
1069
- __wbg_warn_95c497419b251cd5: function(arg0, arg1) {
1094
+ __wbg_warn_4f0851b2fd19b28b: function(arg0, arg1) {
1070
1095
  console.warn(getStringFromWasm0(arg0, arg1));
1071
1096
  },
1072
1097
  __wbindgen_generic_0000000000000001: function(arg0, arg1) {
@@ -1076,12 +1101,12 @@ function __wbg_get_imports() {
1076
1101
  },
1077
1102
  __wbindgen_generic_0000000000000002: function(arg0, arg1) {
1078
1103
  // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("ErrorEvent")], shim_idx: 3, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1079
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_96_46);
1104
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_96_47);
1080
1105
  return ret;
1081
1106
  },
1082
1107
  __wbindgen_generic_0000000000000003: function(arg0, arg1) {
1083
1108
  // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 3, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1084
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_96_47);
1109
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_96_48);
1085
1110
  return ret;
1086
1111
  },
1087
1112
  __wbindgen_generic_0000000000000004: function(arg0, arg1) {
@@ -1132,14 +1157,14 @@ function __wasm_bindgen_func_elem_96(arg0, arg1, arg2) {
1132
1157
  wasm.__wasm_bindgen_func_elem_96(arg0, arg1, arg2);
1133
1158
  }
1134
1159
 
1135
- function __wasm_bindgen_func_elem_96_46(arg0, arg1, arg2) {
1136
- wasm.__wasm_bindgen_func_elem_96_46(arg0, arg1, arg2);
1137
- }
1138
-
1139
1160
  function __wasm_bindgen_func_elem_96_47(arg0, arg1, arg2) {
1140
1161
  wasm.__wasm_bindgen_func_elem_96_47(arg0, arg1, arg2);
1141
1162
  }
1142
1163
 
1164
+ function __wasm_bindgen_func_elem_96_48(arg0, arg1, arg2) {
1165
+ wasm.__wasm_bindgen_func_elem_96_48(arg0, arg1, arg2);
1166
+ }
1167
+
1143
1168
 
1144
1169
  const __wbindgen_enum_BinaryType = ["blob", "arraybuffer"];
1145
1170
  const ChannelFinalization = (typeof FinalizationRegistry === 'undefined')
@@ -1 +1 @@
1
- import{r as t,c as e,g as s,h as i,H as o}from"./p-Dd9o0CbU.js";import{_ as n,C as h,a as r,P as a}from"./p-BtMWUitf.js";const c=200;function d(t){return!Number.isFinite(t)||t<=0?c:Math.min(8192,Math.max(c,Math.floor(t)))}function l(t){return t-t%2}function u(t){const e=t.getBoundingClientRect();return s=e.height,{width:l(d(e.width)),height:l(d(s))};var s}class p{onResize;debounceMs;observer;handle;reported;constructor(t,e=250){this.onResize=t,this.debounceMs=e}observe(t,e){this.disconnect(),this.reported=e,this.report(u(t)),"undefined"!=typeof ResizeObserver&&(this.observer=new ResizeObserver((()=>{clearTimeout(this.handle),this.handle=setTimeout((()=>this.report(u(t))),this.debounceMs)})),this.observer.observe(t))}disconnect(){clearTimeout(this.handle),this.handle=void 0,this.observer?.disconnect(),this.observer=void 0,this.reported=void 0}report(t){var e,s;s=this.reported,(e=t)&&s&&e.width===s.width&&e.height===s.height||(this.reported=t,this.onResize(t))}}function m(){return navigator.keyboard}function f(){return"function"==typeof m()?.lock}function b(t){return document.fullscreenElement===t}function w(t){return document.fullscreenElement?.contains(t)??!1}function y(){if(f())try{m().unlock()}catch(t){console.warn("Failed to release the keyboard lock:",t)}}const g=class{constructor(s){new.target===g&&t(this,s),this.connectionStateChanged=e(this,"connectionStateChanged")}channel;containerEl;ironEl;userInteraction;viewport;domReady=!1;runtimeReady=!1;connected=!1;disposed=!1;session_id;onFullscreenChange=()=>this.sync_keyboard_lock();credentials;credentialsPrompt=!1;statusMessage;usernameBuffer="";passwordBuffer="";get el(){return s(this)}serverHost="phirepass.com";serverPort=443;allowInsecure=!1;heartbeatInterval=3e4;nodeId;serviceId;token;username;password;destination;scale="fit";dynamicResize=!0;captureKeyboard=!0;clipboard=!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;channelFactory;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(){document.addEventListener("fullscreenchange",this.onFullscreenChange),this.disposed=!1,this.channelFactory||await n(),this.open_comms(),this.runtimeReady=!0,this.nodeId?this.try_connect():console.warn("Prop node_id is not set. Cannot connect to RDP.")}componentDidLoad(){this.domReady=!0,this.try_connect()}async disconnectedCallback(){document.removeEventListener("fullscreenchange",this.onFullscreenChange),this.disposed=!0,this.session_id=void 0,this.connected=!1,this.domReady=!1,this.runtimeReady=!1,this.close_comms()}async toggleFullscreen(){const t=await async function(t){try{return b(t)?(await document.exitFullscreen(),!1):(await t.requestFullscreen({navigationUI:"hide"}),!0)}catch(e){return console.warn("Failed to change the fullscreen state of the RDP session:",e),b(t)}}(this.el);return this.focus_desktop(),t}async keyboardLockSupported(){return f()}async focusDesktop(){this.focus_desktop()}async sendCtrlAltDel(){return!!this.userInteraction&&(this.userInteraction.ctrlAltDel(),this.focus_desktop(),!0)}async sendMetaKey(){return!!this.userInteraction&&(this.userInteraction.metaKey(),this.focus_desktop(),!0)}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.channelFactory?this.channelFactory(`${this.create_web_socket_endpoint()}/api/web/ws`,this.nodeId,this.serverId||void 0):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_client()})),this.channel.on_connection_error((t=>{this.connectionStateChanged.emit([r.Error,t])})),this.channel.on_connection_message((()=>{})),this.channel.on_protocol_message((t=>{const{web:e}=t.data;switch(e.type){case a.Error:this.handle_error(e);break;case a.AuthSuccess:this.handle_auth_success(e);break;case a.RDPAuthorized:this.handle_rdp_authorized(e);break;case a.TunnelClosed:this.handle_tunnel_closed(e);break;default:console.warn("Unknown protocol message type:",e)}}))}close_comms(){this.teardown_client(),this.channel&&(this.channel.stop_heartbeat(),this.channel.disconnect())}reset_session_state(){this.session_id=void 0,this.credentials=void 0,this.credentialsPrompt=!1,this.usernameBuffer="",this.passwordBuffer="",this.statusMessage=void 0}handle_auth_success(t){if(this.channel.start_heartbeat(this.heartbeatInterval<=15e3?3e4:this.heartbeatInterval),this.username&&this.password)return this.credentials={username:this.username,password:this.password},void this.request_tunnel();this.credentialsPrompt=!0}request_tunnel(){this.credentials&&(this.statusMessage=void 0,this.channel.open_rdp_tunnel(this.nodeId,this.serviceId,this.credentials.username,this.credentials.password))}async handle_rdp_authorized(t){this.session_id=t.sid,this.statusMessage="Connecting…";const[e]=await Promise.all([import("@devolutions/iron-remote-desktop-rdp"),import("@devolutions/iron-remote-desktop")]);if(this.disposed||!this.containerEl||this.session_id!==t.sid)return;if(await e.init("info"),this.disposed||!this.containerEl||this.session_id!==t.sid)return;const s=document.createElement("iron-remote-desktop");s.module=e.Backend,s.scale=this.scale,s.flexcenter=!0,s.verbose=!1;const i=[e.enableCredssp(!0)];this.dynamicResize&&i.push(e.displayControl(!0)),s.addEventListener("ready",(e=>{this.start_session(e.detail.irgUserInteraction,t.ticket,i)})),this.ironEl=s,this.mount_client(s)}mount_client(t){this.el.appendChild(t)}async start_session(t,e,s){this.userInteraction=t,this.clipboard||t.setEnableClipboard(!1),t.onWarningCallback((t=>{console.warn("The remote desktop client reported a problem:",t)}));const i=t.configBuilder().withUsername(this.credentials?.username??"").withPassword(this.credentials?.password??"").withDestination(this.destination??this.nodeId).withProxyAddress(`${this.create_web_socket_endpoint()}/api/web/rdp/${this.nodeId}`).withAuthToken(e);for(const t of s)i.withExtension(t);let o;this.dynamicResize&&(o=function(t){const e=t.getBoundingClientRect();if(Number.isFinite(e.width)&&Number.isFinite(e.height)&&!(e.width<c||e.height<c))return{width:l(Math.min(Math.floor(e.width),4096)),height:l(Math.min(Math.floor(e.height),4096))}}(this.el),o&&i.withDesktopSize(o));try{const e=await t.connect(i.build());if(this.disposed)return this.shutdown_session(t),void await e.run();t.setVisibility(!0),this.statusMessage=void 0,this.focus_desktop(),this.sync_keyboard_lock();const s=e.run();this.start_viewport_sync(o);const n=await s;this.statusMessage=n.reason()}catch(t){const e=this.describe_error(t);this.statusMessage=e,this.connectionStateChanged.emit([r.Error,t])}}start_viewport_sync(t){this.dynamicResize&&(this.viewport=new p((t=>this.resize_desktop(t))),this.viewport.observe(this.el,t))}stop_viewport_sync(){this.viewport?.disconnect(),this.viewport=void 0}resize_desktop(t){try{this.userInteraction?.resize(t.width,t.height)}catch(t){console.warn("The remote host would not resize its desktop:",t)}}focus_desktop(){var t;t=this.ironEl,t?.focus({preventScroll:!0})}async sync_keyboard_lock(){this.captureKeyboard&&w(this.el)?(await async function(t){if(f()&&w(t))try{await m().lock()}catch(t){console.warn("Failed to lock the keyboard for the RDP session:",t)}}(this.el),this.focus_desktop()):y()}describe_error(t){return t&&"function"==typeof t.backtrace?t.backtrace():t instanceof Error?t.message:"Connection failed."}handle_tunnel_closed(t){this.session_id=void 0,this.statusMessage=this.statusMessage??"Connection closed.",this.teardown_client(),this.close_comms()}handle_error(t){this.statusMessage=t.message,this.connectionStateChanged.emit([r.Error,t])}shutdown_session(t){try{t.shutdown()}catch(t){console.warn("Failed to shut the RDP session down cleanly:",t)}}teardown_client(){this.stop_viewport_sync(),y(),this.userInteraction&&(this.shutdown_session(this.userInteraction),this.userInteraction=void 0),this.ironEl?.remove(),this.ironEl=void 0,this.credentialsPrompt=!1,this.usernameBuffer="",this.passwordBuffer=""}submit_credentials(t){t.preventDefault(),this.credentialsPrompt=!1,this.credentials={username:this.usernameBuffer,password:this.passwordBuffer},this.usernameBuffer="",this.passwordBuffer="",this.request_tunnel()}render(){return i(o,{key:"04896084a5e914a9e2a184ee7b560f4978da9bfd"},i("div",{key:"db5d3d0d4351aeb868ffe6956b86f22b62775e4b",class:"screen",ref:t=>this.containerEl=t},i("slot",{key:"efafd5d8b1437687713aff0425c050413593d162"})),this.credentialsPrompt&&i("form",{key:"ad6079b6db1d71e8eb60bef71cd808be22b7387c",class:"prompt",onSubmit:t=>this.submit_credentials(t)},i("label",{key:"b976c7a3c01e4983fac39e1ef027e4307a6654c7",htmlFor:"rdp-username"},"Username"),i("input",{key:"3a90a73a446015d708eaebec6a7d9bc1703ae5d0",id:"rdp-username",type:"text",autocomplete:"off",autofocus:!0,onInput:t=>this.usernameBuffer=t.target.value}),i("label",{key:"eaf13aa5fe39e4576de052b15c85e6b60be466cb",htmlFor:"rdp-password"},"Password"),i("input",{key:"d53ec8c48b7826b011a07bcb57b7ae1fbe30160f",id:"rdp-password",type:"password",autocomplete:"off",onInput:t=>this.passwordBuffer=t.target.value}),i("button",{key:"d1616e75c1f37a853ec793a25ffc8919544c16d2",type:"submit"},"Connect")),this.statusMessage&&!this.credentialsPrompt&&i("div",{key:"8e6deb9e32f0c416bf85666847f10e095f40e210",class:"status"},this.statusMessage))}static get watchers(){return{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}}};g.style=':host{display:block;width:100%;height:100%;min-width:0;min-height:0;overflow:hidden;position:relative;background:#0b1021;container-type:inline-size}.screen{width:100%;height:100%;display:flex}::slotted(iron-remote-desktop){display:block;flex:1 1 auto;min-width:0;min-height:0;width:100%;height:100%}:host(:fullscreen){width:100vw;height:100vh;background:#000}.prompt{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:0.5rem;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{margin-top:0.5rem;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}@container (max-width: 640px){.prompt{padding:1rem;gap:0.4rem}.prompt input{min-width:0;width:100%;max-width:22rem;font-size:16px;padding:0.625rem 0.75rem}.prompt button{width:100%;max-width:22rem;padding:0.75rem 1.25rem}.status{font-size:0.75rem;padding:0.5rem;padding-bottom:calc(0.5rem + env(safe-area-inset-bottom))}}';export{g as phirepass_rdp}
1
+ import{r as t,c as e,g as s,h as i,H as o}from"./p-Dd9o0CbU.js";import{_ as n,C as h,a as r,P as a}from"./p-BekUePpu.js";const c=200;function d(t){return!Number.isFinite(t)||t<=0?c:Math.min(8192,Math.max(c,Math.floor(t)))}function l(t){return t-t%2}function u(t){const e=t.getBoundingClientRect();return s=e.height,{width:l(d(e.width)),height:l(d(s))};var s}class p{onResize;debounceMs;observer;handle;reported;constructor(t,e=250){this.onResize=t,this.debounceMs=e}observe(t,e){this.disconnect(),this.reported=e,this.report(u(t)),"undefined"!=typeof ResizeObserver&&(this.observer=new ResizeObserver((()=>{clearTimeout(this.handle),this.handle=setTimeout((()=>this.report(u(t))),this.debounceMs)})),this.observer.observe(t))}disconnect(){clearTimeout(this.handle),this.handle=void 0,this.observer?.disconnect(),this.observer=void 0,this.reported=void 0}report(t){var e,s;s=this.reported,(e=t)&&s&&e.width===s.width&&e.height===s.height||(this.reported=t,this.onResize(t))}}function f(){return navigator.keyboard}function m(){return"function"==typeof f()?.lock}function b(t){return document.fullscreenElement===t}function w(t){return document.fullscreenElement?.contains(t)??!1}function y(){if(m())try{f().unlock()}catch(t){console.warn("Failed to release the keyboard lock:",t)}}const g=class{constructor(s){new.target===g&&t(this,s),this.connectionStateChanged=e(this,"connectionStateChanged")}channel;containerEl;ironEl;userInteraction;viewport;domReady=!1;runtimeReady=!1;connected=!1;disposed=!1;session_id;onFullscreenChange=()=>this.sync_keyboard_lock();credentials;credentialsPrompt=!1;statusMessage;usernameBuffer="";passwordBuffer="";get el(){return s(this)}serverHost="phirepass.com";serverPort=443;allowInsecure=!1;heartbeatInterval=3e4;nodeId;serviceId;token;username;password;destination;scale="fit";dynamicResize=!0;captureKeyboard=!0;clipboard=!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;channelFactory;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(){document.addEventListener("fullscreenchange",this.onFullscreenChange),this.disposed=!1,this.channelFactory||await n(),this.open_comms(),this.runtimeReady=!0,this.nodeId?this.try_connect():console.warn("Prop node_id is not set. Cannot connect to RDP.")}componentDidLoad(){this.domReady=!0,this.try_connect()}async disconnectedCallback(){document.removeEventListener("fullscreenchange",this.onFullscreenChange),this.disposed=!0,this.session_id=void 0,this.connected=!1,this.domReady=!1,this.runtimeReady=!1,this.close_comms()}async toggleFullscreen(){const t=await async function(t){try{return b(t)?(await document.exitFullscreen(),!1):(await t.requestFullscreen({navigationUI:"hide"}),!0)}catch(e){return console.warn("Failed to change the fullscreen state of the RDP session:",e),b(t)}}(this.el);return this.focus_desktop(),t}async keyboardLockSupported(){return m()}async focusDesktop(){this.focus_desktop()}async sendCtrlAltDel(){return!!this.userInteraction&&(this.userInteraction.ctrlAltDel(),this.focus_desktop(),!0)}async sendMetaKey(){return!!this.userInteraction&&(this.userInteraction.metaKey(),this.focus_desktop(),!0)}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.channelFactory?this.channelFactory(`${this.create_web_socket_endpoint()}/api/web/ws`,this.nodeId,this.serverId||void 0):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_client()})),this.channel.on_connection_error((t=>{this.connectionStateChanged.emit([r.Error,t])})),this.channel.on_connection_message((()=>{})),this.channel.on_protocol_message((t=>{const{web:e}=t.data;switch(e.type){case a.Error:this.handle_error(e);break;case a.AuthSuccess:this.handle_auth_success(e);break;case a.RDPAuthorized:this.handle_rdp_authorized(e);break;case a.TunnelClosed:this.handle_tunnel_closed(e);break;default:console.warn("Unknown protocol message type:",e)}}))}close_comms(){this.teardown_client(),this.channel&&(this.channel.stop_heartbeat(),this.channel.disconnect())}reset_session_state(){this.session_id=void 0,this.credentials=void 0,this.credentialsPrompt=!1,this.usernameBuffer="",this.passwordBuffer="",this.statusMessage=void 0}handle_auth_success(t){if(this.channel.start_heartbeat(this.heartbeatInterval<=15e3?3e4:this.heartbeatInterval),this.username&&this.password)return this.credentials={username:this.username,password:this.password},void this.request_tunnel();this.credentialsPrompt=!0}request_tunnel(){this.credentials&&(this.statusMessage=void 0,this.channel.open_rdp_tunnel(this.nodeId,this.serviceId,this.credentials.username,this.credentials.password))}async handle_rdp_authorized(t){this.session_id=t.sid,this.statusMessage="Connecting…";const[e]=await Promise.all([import("@devolutions/iron-remote-desktop-rdp"),import("@devolutions/iron-remote-desktop")]);if(this.disposed||!this.containerEl||this.session_id!==t.sid)return;if(await e.init("info"),this.disposed||!this.containerEl||this.session_id!==t.sid)return;const s=document.createElement("iron-remote-desktop");s.module=e.Backend,s.scale=this.scale,s.flexcenter=!0,s.verbose=!1;const i=[e.enableCredssp(!0)];this.dynamicResize&&i.push(e.displayControl(!0)),s.addEventListener("ready",(e=>{this.start_session(e.detail.irgUserInteraction,t.ticket,i)})),this.ironEl=s,this.mount_client(s)}mount_client(t){this.el.appendChild(t)}async start_session(t,e,s){this.userInteraction=t,this.clipboard||t.setEnableClipboard(!1),t.onWarningCallback((t=>{console.warn("The remote desktop client reported a problem:",t)}));const i=t.configBuilder().withUsername(this.credentials?.username??"").withPassword(this.credentials?.password??"").withDestination(this.destination??this.nodeId).withProxyAddress(`${this.create_web_socket_endpoint()}/api/web/rdp/${this.nodeId}`).withAuthToken(e);for(const t of s)i.withExtension(t);let o;this.dynamicResize&&(o=function(t){const e=t.getBoundingClientRect();if(Number.isFinite(e.width)&&Number.isFinite(e.height)&&!(e.width<c||e.height<c))return{width:l(Math.min(Math.floor(e.width),4096)),height:l(Math.min(Math.floor(e.height),4096))}}(this.el),o&&i.withDesktopSize(o));try{const e=await t.connect(i.build());if(this.disposed)return this.shutdown_session(t),void await e.run();t.setVisibility(!0),this.statusMessage=void 0,this.focus_desktop(),this.sync_keyboard_lock();const s=e.run();this.start_viewport_sync(o);const n=await s;this.statusMessage=n.reason()}catch(t){const e=this.describe_error(t);this.statusMessage=e,this.connectionStateChanged.emit([r.Error,t])}}start_viewport_sync(t){this.dynamicResize&&(this.viewport=new p((t=>this.resize_desktop(t))),this.viewport.observe(this.el,t))}stop_viewport_sync(){this.viewport?.disconnect(),this.viewport=void 0}resize_desktop(t){try{this.userInteraction?.resize(t.width,t.height)}catch(t){console.warn("The remote host would not resize its desktop:",t)}}focus_desktop(){var t;t=this.ironEl,t?.focus({preventScroll:!0})}async sync_keyboard_lock(){this.captureKeyboard&&w(this.el)?(await async function(t){if(m()&&w(t))try{await f().lock()}catch(t){console.warn("Failed to lock the keyboard for the RDP session:",t)}}(this.el),this.focus_desktop()):y()}describe_error(t){return t&&"function"==typeof t.backtrace?t.backtrace():t instanceof Error?t.message:"Connection failed."}handle_tunnel_closed(t){this.session_id=void 0,this.statusMessage=this.statusMessage??"Connection closed.",this.teardown_client(),this.close_comms()}handle_error(t){this.statusMessage=t.message,this.connectionStateChanged.emit([r.Error,t])}shutdown_session(t){try{t.shutdown()}catch(t){console.warn("Failed to shut the RDP session down cleanly:",t)}}teardown_client(){this.stop_viewport_sync(),y(),this.userInteraction&&(this.shutdown_session(this.userInteraction),this.userInteraction=void 0),this.ironEl?.remove(),this.ironEl=void 0,this.credentialsPrompt=!1,this.usernameBuffer="",this.passwordBuffer=""}submit_credentials(t){t.preventDefault(),this.credentialsPrompt=!1,this.credentials={username:this.usernameBuffer,password:this.passwordBuffer},this.usernameBuffer="",this.passwordBuffer="",this.request_tunnel()}render(){return i(o,{key:"9db127da5dbe168ef5f7a021767e5cedeb8305e6"},i("div",{key:"06d2de6763ec479198389032ab65033eefab21d6",class:"screen",ref:t=>this.containerEl=t},i("slot",{key:"7842ca9fd64795794e1b90e15319ddaa599f85b8"})),this.credentialsPrompt&&i("form",{key:"ce53830ced182740f139a318f099918c31013d9f",class:"prompt",onSubmit:t=>this.submit_credentials(t)},i("label",{key:"2b55341b9cfc2e08a847e26985000f5e1bc86eca",htmlFor:"rdp-username"},"Username"),i("input",{key:"243500ff59de6f16cc67acc5ddf9e15e3c0de0f6",id:"rdp-username",type:"text",autocomplete:"off",autofocus:!0,onInput:t=>this.usernameBuffer=t.target.value}),i("label",{key:"5a346aa6a730c4cb0dd550eab9a65db9f2e74bc6",htmlFor:"rdp-password"},"Password"),i("input",{key:"0f1081b05f94e15a7f04df4de390a33a021ffe53",id:"rdp-password",type:"password",autocomplete:"off",onInput:t=>this.passwordBuffer=t.target.value}),i("button",{key:"e9657c9df124176210508f5125fc526e3c78c5f1",type:"submit"},"Connect")),this.statusMessage&&!this.credentialsPrompt&&i("div",{key:"3c59dbae63b7c5c5ef80344abad4b1a2b4c0b79d",class:"status"},this.statusMessage))}static get watchers(){return{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}}};g.style=':host{display:block;width:100%;height:100%;min-width:0;min-height:0;overflow:hidden;position:relative;background:#0b1021;container-type:inline-size}.screen{width:100%;height:100%;display:flex}::slotted(iron-remote-desktop){display:block;flex:1 1 auto;min-width:0;min-height:0;width:100%;height:100%}:host(:fullscreen){width:100vw;height:100vh;background:#000}.prompt{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:0.5rem;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{margin-top:0.5rem;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}@container (max-width: 640px){.prompt{padding:1rem;gap:0.4rem}.prompt input{min-width:0;width:100%;max-width:22rem;font-size:16px;padding:0.625rem 0.75rem}.prompt button{width:100%;max-width:22rem;padding:0.75rem 1.25rem}.status{font-size:0.75rem;padding:0.5rem;padding-bottom:calc(0.5rem + env(safe-area-inset-bottom))}}';export{g as phirepass_rdp}
@@ -0,0 +1 @@
1
+ class n{__destroy_into_raw(){const n=this.__wbg_ptr;return this.__wbg_ptr=0,i.unregister(this),n}free(){const n=this.__destroy_into_raw();j.__wbg_channel_free(n,0)}authenticate(n,t,e){const r=+(y(e)?Number.MAX_SAFE_INTEGER:e>>>0);let _,o,c,i;try{_=v(n,j.__wbindgen_export,j.__wbindgen_export2),o=T,c=v(t,j.__wbindgen_export,j.__wbindgen_export2),i=T}catch(n){throw c&&j.__wbindgen_export3(c,1*i,1),_&&j.__wbindgen_export3(_,1*o,1),n}j.channel_authenticate(this.__wbg_ptr,_,o,c,i,r)}connect(){j.channel_connect(this.__wbg_ptr)}create_service(n,t,e,r,_,o,c,i,s){const u=+_,a=+(y(s)?Number.MAX_SAFE_INTEGER:s>>>0);let f,b,d,w,l,g,h,m,p,N,A,R,S,O;try{f=v(n,j.__wbindgen_export,j.__wbindgen_export2),b=T,d=v(t,j.__wbindgen_export,j.__wbindgen_export2),w=T,l=y(e)?0:v(e,j.__wbindgen_export,j.__wbindgen_export2),g=T,h=v(r,j.__wbindgen_export,j.__wbindgen_export2),m=T,p=y(o)?0:v(o,j.__wbindgen_export,j.__wbindgen_export2),N=T,A=y(c)?0:v(c,j.__wbindgen_export,j.__wbindgen_export2),R=T,S=y(i)?0:v(i,j.__wbindgen_export,j.__wbindgen_export2),O=T}catch(n){throw S&&j.__wbindgen_export3(S,1*O,1),A&&j.__wbindgen_export3(A,1*R,1),p&&j.__wbindgen_export3(p,1*N,1),h&&j.__wbindgen_export3(h,1*m,1),l&&j.__wbindgen_export3(l,1*g,1),d&&j.__wbindgen_export3(d,1*w,1),f&&j.__wbindgen_export3(f,1*b,1),n}j.channel_create_service(this.__wbg_ptr,f,b,d,w,l,g,h,m,u,p,N,A,R,S,O,a)}delete_service(n,t,e){const r=+(y(e)?Number.MAX_SAFE_INTEGER:e>>>0);let _,o,c,i;try{_=v(n,j.__wbindgen_export,j.__wbindgen_export2),o=T,c=v(t,j.__wbindgen_export,j.__wbindgen_export2),i=T}catch(n){throw c&&j.__wbindgen_export3(c,1*i,1),_&&j.__wbindgen_export3(_,1*o,1),n}j.channel_delete_service(this.__wbg_ptr,_,o,c,i,r)}disconnect(){j.channel_disconnect(this.__wbg_ptr)}is_connected(){return 0!==j.channel_is_connected(this.__wbg_ptr)}is_disconnected(){return 0!==j.channel_is_disconnected(this.__wbg_ptr)}constructor(n,t,e){let r,_,o,c,s,u;try{r=v(n,j.__wbindgen_export,j.__wbindgen_export2),_=T,o=v(t,j.__wbindgen_export,j.__wbindgen_export2),c=T,s=y(e)?0:v(e,j.__wbindgen_export,j.__wbindgen_export2),u=T}catch(n){throw s&&j.__wbindgen_export3(s,1*u,1),o&&j.__wbindgen_export3(o,1*c,1),r&&j.__wbindgen_export3(r,1*_,1),n}const a=j.channel_new(r,_,o,c,s,u);return this.__wbg_ptr=a,i.register(this,this.__wbg_ptr,this),this}on_connection_close(n){j.channel_on_connection_close(this.__wbg_ptr,y(n)?0:s(n))}on_connection_error(n){j.channel_on_connection_error(this.__wbg_ptr,y(n)?0:s(n))}on_connection_message(n){j.channel_on_connection_message(this.__wbg_ptr,y(n)?0:s(n))}on_connection_open(n){j.channel_on_connection_open(this.__wbg_ptr,y(n)?0:s(n))}on_protocol_message(n){j.channel_on_protocol_message(this.__wbg_ptr,y(n)?0:s(n))}on_protocol_message_type(n,t){const e=v(n,j.__wbindgen_export,j.__wbindgen_export2);j.channel_on_protocol_message_type(this.__wbg_ptr,e,T,y(t)?0:s(t))}open_rdp_tunnel(n,t,e,r,_){const o=+(y(_)?Number.MAX_SAFE_INTEGER:_>>>0);let c,i,s,u,a,f,b,d;try{c=v(n,j.__wbindgen_export,j.__wbindgen_export2),i=T,s=v(t,j.__wbindgen_export,j.__wbindgen_export2),u=T,a=y(e)?0:v(e,j.__wbindgen_export,j.__wbindgen_export2),f=T,b=y(r)?0:v(r,j.__wbindgen_export,j.__wbindgen_export2),d=T}catch(n){throw b&&j.__wbindgen_export3(b,1*d,1),a&&j.__wbindgen_export3(a,1*f,1),s&&j.__wbindgen_export3(s,1*u,1),c&&j.__wbindgen_export3(c,1*i,1),n}j.channel_open_rdp_tunnel(this.__wbg_ptr,c,i,s,u,a,f,b,d,o)}open_sftp_tunnel(n,t,e,r,_){const o=+(y(_)?Number.MAX_SAFE_INTEGER:_>>>0);let c,i,s,u,a,f,b,d;try{c=v(n,j.__wbindgen_export,j.__wbindgen_export2),i=T,s=v(t,j.__wbindgen_export,j.__wbindgen_export2),u=T,a=y(e)?0:v(e,j.__wbindgen_export,j.__wbindgen_export2),f=T,b=y(r)?0:v(r,j.__wbindgen_export,j.__wbindgen_export2),d=T}catch(n){throw b&&j.__wbindgen_export3(b,1*d,1),a&&j.__wbindgen_export3(a,1*f,1),s&&j.__wbindgen_export3(s,1*u,1),c&&j.__wbindgen_export3(c,1*i,1),n}j.channel_open_sftp_tunnel(this.__wbg_ptr,c,i,s,u,a,f,b,d,o)}open_ssh_tunnel(n,t,e,r,_){const o=+(y(_)?Number.MAX_SAFE_INTEGER:_>>>0);let c,i,s,u,a,f,b,d;try{c=v(n,j.__wbindgen_export,j.__wbindgen_export2),i=T,s=v(t,j.__wbindgen_export,j.__wbindgen_export2),u=T,a=y(e)?0:v(e,j.__wbindgen_export,j.__wbindgen_export2),f=T,b=y(r)?0:v(r,j.__wbindgen_export,j.__wbindgen_export2),d=T}catch(n){throw b&&j.__wbindgen_export3(b,1*d,1),a&&j.__wbindgen_export3(a,1*f,1),s&&j.__wbindgen_export3(s,1*u,1),c&&j.__wbindgen_export3(c,1*i,1),n}j.channel_open_ssh_tunnel(this.__wbg_ptr,c,i,s,u,a,f,b,d,o)}send_download_delete(n,t,e){const r=+t,_=+(y(e)?Number.MAX_SAFE_INTEGER:e>>>0),o=v(n,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_download_delete(this.__wbg_ptr,o,T,r,_)}send_download_resume(n,t,e){const r=+t,_=+(y(e)?Number.MAX_SAFE_INTEGER:e>>>0),o=v(n,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_download_resume(this.__wbg_ptr,o,T,r,_)}send_download_set_order(n,t,e){const r=+t,_=+(y(e)?Number.MAX_SAFE_INTEGER:e>>>0),o=v(n,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_download_set_order(this.__wbg_ptr,o,T,r,_)}send_download_settings_get(n,t){const e=+(y(t)?Number.MAX_SAFE_INTEGER:t>>>0),r=v(n,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_download_settings_get(this.__wbg_ptr,r,T,e)}send_download_settings_save(n,t,e){const r=+(y(e)?Number.MAX_SAFE_INTEGER:e>>>0),_=v(n,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_download_settings_save(this.__wbg_ptr,_,T,t,r)}send_download_start(n,t,e,r,_,o,c){const i=+(y(c)?Number.MAX_SAFE_INTEGER:c>>>0);let s,u,a,f;try{s=v(n,j.__wbindgen_export,j.__wbindgen_export2),u=T,a=y(e)?0:v(e,j.__wbindgen_export,j.__wbindgen_export2),f=T}catch(n){throw a&&j.__wbindgen_export3(a,1*f,1),s&&j.__wbindgen_export3(s,1*u,1),n}j.channel_send_download_start(this.__wbg_ptr,s,u,t,a,f,r,y(_)?16777215:_?1:0,o,i)}send_download_stop(n,t,e){const r=+t,_=+(y(e)?Number.MAX_SAFE_INTEGER:e>>>0),o=v(n,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_download_stop(this.__wbg_ptr,o,T,r,_)}send_download_subscribe(n){j.channel_send_download_subscribe(this.__wbg_ptr,n)}send_download_where(n,t,e){const r=+(y(e)?Number.MAX_SAFE_INTEGER:e>>>0),_=v(n,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_download_where(this.__wbg_ptr,_,T,t,r)}send_sftp_chmod(n,t,e,r,_){const o=+t,c=+r,i=+(y(_)?Number.MAX_SAFE_INTEGER:_>>>0);let s,u,a,f;try{s=v(n,j.__wbindgen_export,j.__wbindgen_export2),u=T,a=v(e,j.__wbindgen_export,j.__wbindgen_export2),f=T}catch(n){throw a&&j.__wbindgen_export3(a,1*f,1),s&&j.__wbindgen_export3(s,1*u,1),n}j.channel_send_sftp_chmod(this.__wbg_ptr,s,u,o,a,f,c,i)}send_sftp_delete(n,t,e,r,_){const o=+t,c=+(y(_)?Number.MAX_SAFE_INTEGER:_>>>0);let i,s,u,a,f,b;try{i=v(n,j.__wbindgen_export,j.__wbindgen_export2),s=T,u=v(e,j.__wbindgen_export,j.__wbindgen_export2),a=T,f=v(r,j.__wbindgen_export,j.__wbindgen_export2),b=T}catch(n){throw f&&j.__wbindgen_export3(f,1*b,1),u&&j.__wbindgen_export3(u,1*a,1),i&&j.__wbindgen_export3(i,1*s,1),n}j.channel_send_sftp_delete(this.__wbg_ptr,i,s,o,u,a,f,b,c)}send_sftp_download_ack(n,t,e,r){const _=+t,o=+e,c=+r,i=v(n,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_download_ack(this.__wbg_ptr,i,T,_,o,c)}send_sftp_download_chunk(n,t,e,r,_){const o=+t,c=+e,i=+r,s=+(y(_)?Number.MAX_SAFE_INTEGER:_>>>0),u=v(n,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_download_chunk(this.__wbg_ptr,u,T,o,c,i,s)}send_sftp_download_start(n,t,e,r,_){const o=+t,c=+(y(_)?Number.MAX_SAFE_INTEGER:_>>>0);let i,s,u,a,f,b;try{i=v(n,j.__wbindgen_export,j.__wbindgen_export2),s=T,u=v(e,j.__wbindgen_export,j.__wbindgen_export2),a=T,f=v(r,j.__wbindgen_export,j.__wbindgen_export2),b=T}catch(n){throw f&&j.__wbindgen_export3(f,1*b,1),u&&j.__wbindgen_export3(u,1*a,1),i&&j.__wbindgen_export3(i,1*s,1),n}j.channel_send_sftp_download_start(this.__wbg_ptr,i,s,o,u,a,f,b,c)}send_sftp_list_data(n,t,e,r){const _=+t,o=+(y(r)?Number.MAX_SAFE_INTEGER:r>>>0);let c,i,s,u;try{c=v(n,j.__wbindgen_export,j.__wbindgen_export2),i=T,s=v(e,j.__wbindgen_export,j.__wbindgen_export2),u=T}catch(n){throw s&&j.__wbindgen_export3(s,1*u,1),c&&j.__wbindgen_export3(c,1*i,1),n}j.channel_send_sftp_list_data(this.__wbg_ptr,c,i,_,s,u,o)}send_sftp_mkdir(n,t,e,r){const _=+t,o=+(y(r)?Number.MAX_SAFE_INTEGER:r>>>0);let c,i,s,u;try{c=v(n,j.__wbindgen_export,j.__wbindgen_export2),i=T,s=v(e,j.__wbindgen_export,j.__wbindgen_export2),u=T}catch(n){throw s&&j.__wbindgen_export3(s,1*u,1),c&&j.__wbindgen_export3(c,1*i,1),n}j.channel_send_sftp_mkdir(this.__wbg_ptr,c,i,_,s,u,o)}send_sftp_open_stream(n,t,e,r){const _=+t,o=+(y(r)?Number.MAX_SAFE_INTEGER:r>>>0);let c,i,s,u;try{c=v(n,j.__wbindgen_export,j.__wbindgen_export2),i=T,s=v(e,j.__wbindgen_export,j.__wbindgen_export2),u=T}catch(n){throw s&&j.__wbindgen_export3(s,1*u,1),c&&j.__wbindgen_export3(c,1*i,1),n}j.channel_send_sftp_open_stream(this.__wbg_ptr,c,i,_,s,u,o)}send_sftp_read_file(n,t,e,r){const _=+t,o=+(y(r)?Number.MAX_SAFE_INTEGER:r>>>0);let c,i,s,u;try{c=v(n,j.__wbindgen_export,j.__wbindgen_export2),i=T,s=v(e,j.__wbindgen_export,j.__wbindgen_export2),u=T}catch(n){throw s&&j.__wbindgen_export3(s,1*u,1),c&&j.__wbindgen_export3(c,1*i,1),n}j.channel_send_sftp_read_file(this.__wbg_ptr,c,i,_,s,u,o)}send_sftp_remove(n,t,e,r,_){const o=+t,c=+r,i=+(y(_)?Number.MAX_SAFE_INTEGER:_>>>0);let s,u,a,f;try{s=v(n,j.__wbindgen_export,j.__wbindgen_export2),u=T,a=v(e,j.__wbindgen_export,j.__wbindgen_export2),f=T}catch(n){throw a&&j.__wbindgen_export3(a,1*f,1),s&&j.__wbindgen_export3(s,1*u,1),n}j.channel_send_sftp_remove(this.__wbg_ptr,s,u,o,a,f,c,i)}send_sftp_rename(n,t,e,r,_){const o=+t,c=+(y(_)?Number.MAX_SAFE_INTEGER:_>>>0);let i,s,u,a,f,b;try{i=v(n,j.__wbindgen_export,j.__wbindgen_export2),s=T,u=v(e,j.__wbindgen_export,j.__wbindgen_export2),a=T,f=v(r,j.__wbindgen_export,j.__wbindgen_export2),b=T}catch(n){throw f&&j.__wbindgen_export3(f,1*b,1),u&&j.__wbindgen_export3(u,1*a,1),i&&j.__wbindgen_export3(i,1*s,1),n}j.channel_send_sftp_rename(this.__wbg_ptr,i,s,o,u,a,f,b,c)}send_sftp_upload_chunk(n,t,e,r,_,o,c){const i=+t,s=+e,u=+r,a=+_,f=+(y(c)?Number.MAX_SAFE_INTEGER:c>>>0);let b,d,w,l;try{b=v(n,j.__wbindgen_export,j.__wbindgen_export2),d=T,w=p(o,j.__wbindgen_export),l=T}catch(n){throw w&&j.__wbindgen_export3(w,1*l,1),b&&j.__wbindgen_export3(b,1*d,1),n}j.channel_send_sftp_upload_chunk(this.__wbg_ptr,b,d,i,s,u,a,w,l,f)}send_sftp_upload_start(n,t,e,r,_,o,c){const i=+t,s=+_,u=BigInt.asIntN(64,o),a=+(y(c)?Number.MAX_SAFE_INTEGER:c>>>0);let f,b,d,w,l,g;try{f=v(n,j.__wbindgen_export,j.__wbindgen_export2),b=T,d=v(e,j.__wbindgen_export,j.__wbindgen_export2),w=T,l=v(r,j.__wbindgen_export,j.__wbindgen_export2),g=T}catch(n){throw l&&j.__wbindgen_export3(l,1*g,1),d&&j.__wbindgen_export3(d,1*w,1),f&&j.__wbindgen_export3(f,1*b,1),n}j.channel_send_sftp_upload_start(this.__wbg_ptr,f,b,i,d,w,l,g,s,u,a)}send_sftp_write_file(n,t,e,r,_){const o=+t,c=+(y(_)?Number.MAX_SAFE_INTEGER:_>>>0);let i,s,u,a,f,b;try{i=v(n,j.__wbindgen_export,j.__wbindgen_export2),s=T,u=v(e,j.__wbindgen_export,j.__wbindgen_export2),a=T,f=p(r,j.__wbindgen_export),b=T}catch(n){throw f&&j.__wbindgen_export3(f,1*b,1),u&&j.__wbindgen_export3(u,1*a,1),i&&j.__wbindgen_export3(i,1*s,1),n}j.channel_send_sftp_write_file(this.__wbg_ptr,i,s,o,u,a,f,b,c)}send_ssh_terminal_resize(n,t,e,r,_,o){const c=+t,i=+e,s=+r,u=+_,a=+o,f=v(n,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_ssh_terminal_resize(this.__wbg_ptr,f,T,c,i,s,u,a)}send_ssh_tunnel_data(n,t,e){const r=+t;let _,o,c,i;try{_=v(n,j.__wbindgen_export,j.__wbindgen_export2),o=T,c=v(e,j.__wbindgen_export,j.__wbindgen_export2),i=T}catch(n){throw c&&j.__wbindgen_export3(c,1*i,1),_&&j.__wbindgen_export3(_,1*o,1),n}j.channel_send_ssh_tunnel_data(this.__wbg_ptr,_,o,r,c,i)}start_heartbeat(n){j.channel_start_heartbeat(this.__wbg_ptr,n)}stop_heartbeat(){j.channel_stop_heartbeat(this.__wbg_ptr)}update_service(n,t,e,r,_,o,c,i,s,u){const a=+o,f=+(y(u)?Number.MAX_SAFE_INTEGER:u>>>0);let b,d,w,l,g,h,m,p,N,A,R,S,O,U,F,P;try{b=v(n,j.__wbindgen_export,j.__wbindgen_export2),d=T,w=v(t,j.__wbindgen_export,j.__wbindgen_export2),l=T,g=v(e,j.__wbindgen_export,j.__wbindgen_export2),h=T,m=y(r)?0:v(r,j.__wbindgen_export,j.__wbindgen_export2),p=T,N=v(_,j.__wbindgen_export,j.__wbindgen_export2),A=T,R=y(c)?0:v(c,j.__wbindgen_export,j.__wbindgen_export2),S=T,O=y(i)?0:v(i,j.__wbindgen_export,j.__wbindgen_export2),U=T,F=y(s)?0:v(s,j.__wbindgen_export,j.__wbindgen_export2),P=T}catch(n){throw F&&j.__wbindgen_export3(F,1*P,1),O&&j.__wbindgen_export3(O,1*U,1),R&&j.__wbindgen_export3(R,1*S,1),N&&j.__wbindgen_export3(N,1*A,1),m&&j.__wbindgen_export3(m,1*p,1),g&&j.__wbindgen_export3(g,1*h,1),w&&j.__wbindgen_export3(w,1*l,1),b&&j.__wbindgen_export3(b,1*d,1),n}j.channel_update_service(this.__wbg_ptr,b,d,w,l,g,h,m,p,N,A,a,R,S,O,U,F,P,f)}}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(n,t){j.__wasm_bindgen_func_elem_100(n,t)}function r(n,t,e){j.__wasm_bindgen_func_elem_96(n,t,e)}function _(n,t,e){j.__wasm_bindgen_func_elem_96_47(n,t,e)}function o(n,t,e){j.__wasm_bindgen_func_elem_96_48(n,t,e)}const c=["blob","arraybuffer"],i="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((n=>j.__wbg_channel_free(n,1)));function s(n){const t=j.__wbindgen_export5();return j.__wbindgen_externrefs.set(t,n),t}const u="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((n=>j.__wbindgen_export6(n.a,n.b)));function a(n){switch(typeof n){case"number":case"boolean":case"undefined":return`${n}`;case"string":return JSON.stringify(n);case"bigint":return`${n}n`;case"symbol":return void 0!==n.description?`Symbol(${n.description})`:"Symbol";case"function":return"string"==typeof n.name&&""!==n.name?`Function(${n.name})`:"Function";case"object":{if(null===n)return"null";if(Array.isArray(n))return"["+Array.from(n,a).join(", ")+"]";if(n instanceof Error)return`${n.name}: ${n.message}\n${n.stack}`;const t=toString.call(n),e=/\[object ([^\]]+)\]/.exec(t)?.[1];if(void 0===e)return t;if("Object"===e)try{return"Object("+JSON.stringify(n)+")"}catch(n){return"Object"}return e}}}function f(n,t){return n>>>=0,g().subarray(n/1,n/1+t)}let b=null;function d(){return(null===b||!0===b.buffer.detached||void 0===b.buffer.detached&&b.buffer!==j.memory.buffer)&&(b=new DataView(j.memory.buffer)),b}function w(n,t){return n>>>=0,e=g().subarray(n,n+t),R+=e.length,R>=A&&(N=new TextDecoder("utf-8",{ignoreBOM:!0}),N.decode(),R=e.length),N.decode(e);var e}let l=null;function g(){return null!==l&&0!==l.byteLength||(l=new Uint8Array(j.memory.buffer)),l}function h(n,t){try{return n.apply(this,t)}catch(n){const t=s(n);j.__wbindgen_export4(t)}}function y(n){return null==n}function m(n,t,e){const r={a:n,b:t,cnt:1},_=(...n)=>{r.cnt++;const t=r.a;r.a=0;try{return e(t,r.b,...n)}finally{r.a=t,_._wbg_cb_unref()}};return _._wbg_cb_unref=()=>{0==--r.cnt&&(j.__wbindgen_export6(r.a,r.b),r.a=0,u.unregister(r))},u.register(_,r,r),_}function p(n,t){const e=t(1*n.length,1)>>>0;return g().set(n,e/1),T=n.length,e}function v(n,t,e){if(void 0===e){const e=S.encode(n),r=t(e.length,1)>>>0;return g().subarray(r,r+e.length).set(e),T=e.length,r}let r=n.length,_=t(r,1)>>>0;const o=g();let c=0;for(;c<r;c++){const t=n.charCodeAt(c);if(t>127)break;o[_+c]=t}if(c!==r){0!==c&&(n=n.slice(c)),_=e(_,r,r=c+3*n.length,1)>>>0;const t=g().subarray(_+c,_+r);c+=S.encodeInto(n,t).written,_=e(_,r,c,1)>>>0}return T=c,_}let N=new TextDecoder("utf-8",{ignoreBOM:!0});N.decode();const A=2146435072;let R=0;const S=new TextEncoder;"encodeInto"in S||(S.encodeInto=function(n,t){const e=S.encode(n);return t.set(e),{read:n.length,written:e.length}});let j,O,T=0;async function U(n){return void 0!==j?j:(void 0===O&&(O=async function(n){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=function(){const n={__proto__:null,__wbg_Error_208446807d0d1e30:function(n,t){return Error(w(n,t))},__wbg_Number_ff192a72a0dcdf6d:function(n){return Number(n)},__wbg_String_8564e559799eccda:function(n,t){const e=v(String(t),j.__wbindgen_export,j.__wbindgen_export2),r=T;d().setInt32(4+(n>>>0),r,!0),d().setInt32(0+(n>>>0),e,!0)},__wbg___wbindgen_bigint_get_as_i64_11da4b52cd0aedef:function(n,t){const e="bigint"==typeof t?t:void 0;d().setBigInt64(8+(n>>>0),y(e)?BigInt(0):e,!0),d().setInt32(0+(n>>>0),!y(e),!0)},__wbg___wbindgen_boolean_get_4f1baf9a00be3c74:function(n){const t="boolean"==typeof n?n:void 0;return y(t)?16777215:t?1:0},__wbg___wbindgen_debug_string_f249a2a76caa9a55:function(n,t){const e=v(a(t),j.__wbindgen_export,j.__wbindgen_export2),r=T;d().setInt32(4+(n>>>0),r,!0),d().setInt32(0+(n>>>0),e,!0)},__wbg___wbindgen_in_3f58a9d3b3a7eed2:function(n,t){return n in t},__wbg___wbindgen_is_bigint_5fa10641e039d3ef:function(n){return"bigint"==typeof n},__wbg___wbindgen_is_function_741ff2bb612836f5:function(n){return"function"==typeof n},__wbg___wbindgen_is_null_c22311b1cc228e3a:function(n){return null===n},__wbg___wbindgen_is_object_8b968c3ab8e96595:function(n){return"object"==typeof n&&null!==n},__wbg___wbindgen_is_string_fc456fee5d3317de:function(n){return"string"==typeof n},__wbg___wbindgen_is_undefined_be5b34249ff1fc15:function(n){return void 0===n},__wbg___wbindgen_jsval_eq_38d7bfbe4cc84039:function(n,t){return n===t},__wbg___wbindgen_jsval_loose_eq_b2f214e2e4b30e36:function(n,t){return n==t},__wbg___wbindgen_number_get_934b640d0889af78:function(n,t){const e="number"==typeof t?t:void 0;d().setFloat64(8+(n>>>0),y(e)?0:e,!0),d().setInt32(0+(n>>>0),!y(e),!0)},__wbg___wbindgen_string_get_7ce8eee7fd327545:function(n,t){const e="string"==typeof t?t:void 0;var r=y(e)?0:v(e,j.__wbindgen_export,j.__wbindgen_export2),_=T;d().setInt32(4+(n>>>0),_,!0),d().setInt32(0+(n>>>0),r,!0)},__wbg___wbindgen_throw_4c88d8bf264fd984:function(n,t){throw new Error(w(n,t))},__wbg__wbg_cb_unref_09736879a3f67559:function(n){n._wbg_cb_unref()},__wbg_call_40b008ba32f73991:function(){return h((function(n,t){return n.call(t)}),arguments)},__wbg_call_a410eb4b59ed5965:function(){return h((function(n,t,e){return n.call(t,e)}),arguments)},__wbg_call_fc92fee6137d452d:function(){return h((function(n,t,e,r){return n.call(t,e,r)}),arguments)},__wbg_clearInterval_2ed00e80b9bdc143:function(n){return clearInterval(n)},__wbg_close_5ee9c5fe4e8754a4:function(){return h((function(n){n.close()}),arguments)},__wbg_data_c7e5e8500f1bca2f:function(n){return n.data},__wbg_done_57e08d0be6e30c02:function(n){return n.done},__wbg_entries_7bb1459bd9b5c2b9:function(n){return Object.entries(n)},__wbg_from_eac91875c8a5ffa4:function(n){return Array.from(n)},__wbg_getRandomValues_5d8c030b527203a6:function(){return h((function(n,t){globalThis.crypto.getRandomValues(f(n,t))}),arguments)},__wbg_get_2080c49015e35254:function(){return h((function(n,t){return Reflect.get(n,t)}),arguments)},__wbg_get_635eea311fa1a291:function(){return h((function(n,t){return Reflect.get(n,t)}),arguments)},__wbg_get_d7176cfb76d71114:function(n,t){return n[t>>>0]},__wbg_get_unchecked_e6325ad374eff861:function(n,t){return n[t>>>0]},__wbg_get_with_ref_key_fc601247060b7204:function(n,t){return n[t]},__wbg_info_386f00b314475db5:function(n,t){console.info(w(n,t))},__wbg_instanceof_ArrayBuffer_12cdaa4161423e6b:function(n){let t;try{t=n instanceof ArrayBuffer}catch(n){t=!1}return t},__wbg_instanceof_Uint8Array_d7aeb0dcb3108fea:function(n){let t;try{t=n instanceof Uint8Array}catch(n){t=!1}return t},__wbg_isArray_bcf1376d0d732d08:function(n){return Array.isArray(n)},__wbg_isSafeInteger_1a35ba4d31e71d38:function(n){return Number.isSafeInteger(n)},__wbg_iterator_e4c5e8f68ada7b58:function(){return Symbol.iterator},__wbg_length_186163212ffe79c3:function(n){return n.length},__wbg_length_b03a0fabb109b1e9:function(n){return n.length},__wbg_new_13de428334042d26:function(n){return new Uint8Array(n)},__wbg_new_37eb45aaf5eeb820:function(){return new Array},__wbg_new_cd4348290afae586:function(){return new Object},__wbg_new_with_str_sequence_75b26d88172889d0:function(){return h((function(n,t,e){return new WebSocket(w(n,t),e)}),arguments)},__wbg_next_178c1651c11432b3:function(n){return n.next},__wbg_next_af5ac6a08bb0a717:function(){return h((function(n){return n.next()}),arguments)},__wbg_prototypesetcall_13162965d1fe7aa3:function(n,t,e){Uint8Array.prototype.set.call(f(n,t),e)},__wbg_push_c9f4893fc209f768:function(n,t){return n.push(t)},__wbg_readyState_039bc047141a5f6d:function(n){return n.readyState},__wbg_send_d83d0891cf698779:function(){return h((function(n,t,e){n.send(f(t,e))}),arguments)},__wbg_setInterval_ef738bbfe8cc0974:function(){return h((function(n,t){return setInterval(n,t)}),arguments)},__wbg_set_binaryType_d5b4dafd0f127fb2:function(n,t){n.binaryType=c[t]},__wbg_set_d2d33b52458e984a:function(n,t,e){n[t>>>0]=e},__wbg_set_e4b9a833d288759a:function(n,t,e){n[t]=e},__wbg_set_onclose_078935cf8d0fb024:function(n,t){n.onclose=t},__wbg_set_onerror_f7f089f7f059501c:function(n,t){n.onerror=t},__wbg_set_onmessage_26abc49cfa5f9ffc:function(n,t){n.onmessage=t},__wbg_set_onopen_757be120cc7b1ea6:function(n,t){n.onopen=t},__wbg_value_e0f328965e184931:function(n){return n.value},__wbg_warn_4f0851b2fd19b28b:function(n,t){console.warn(w(n,t))},__wbindgen_generic_0000000000000001:function(n,t){return m(n,t,r)},__wbindgen_generic_0000000000000002:function(n,t){return m(n,t,_)},__wbindgen_generic_0000000000000003:function(n,t){return m(n,t,o)},__wbindgen_generic_0000000000000004:function(n,t){return m(n,t,e)},__wbindgen_generic_0000000000000005:function(n){return n},__wbindgen_generic_0000000000000006:function(n,t){return f(n,t)},__wbindgen_generic_0000000000000007:function(n,t){return w(n,t)},__wbindgen_generic_0000000000000008:function(n){return BigInt.asUintN(64,n)},__wbindgen_init_externref_table:function(){const n=j.__wbindgen_externrefs;n.set(0,void 0),n.set(1024,void 0),n.set(1025,null),n.set(1026,!0),n.set(1027,!1)}};return{__proto__:null,"./phirepass-channel_bg.js":n}}();("string"==typeof n||"function"==typeof Request&&n instanceof Request||"function"==typeof URL&&n instanceof URL)&&(n=fetch(n));const{instance:i}=await async function(n,t){if("function"==typeof Response&&n instanceof Response){if(!n.ok)throw new Error(`failed to fetch Wasm: ${n.status} ${n.statusText} fetching '${n.url}'`);if("function"==typeof WebAssembly.instantiateStreaming)try{return await WebAssembly.instantiateStreaming(n,t)}catch(t){if(!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 j=n.exports,b=null,l=null,j.__wbindgen_start(),j}(i)}(n),O.catch((()=>{O=void 0}))),O)}var F,P,k;!function(n){n.Error="Error",n.AuthSuccess="AuthSuccess",n.TunnelOpened="TunnelOpened",n.TunnelClosed="TunnelClosed",n.TunnelData="TunnelData",n.RDPAuthorized="RDPAuthorized",n.SFTPListItems="SFTPListItems",n.SFTPDownloadStartResponse="SFTPDownloadStartResponse",n.SFTPDownloadChunk="SFTPDownloadChunk",n.SFTPUploadStartResponse="SFTPUploadStartResponse",n.SFTPUploadChunkAck="SFTPUploadChunkAck",n.SFTPOpResult="SFTPOpResult"}(F||(F={})),function(n){n[n.Username=0]="Username",n[n.Password=1]="Password",n[n.Default=2]="Default"}(P||(P={})),function(n){n.Disconnected="disconnected",n.Connected="connected",n.Error="error"}(k||(k={}));export{n as C,t as E,P as I,F as P,U as _,k as a}