phirepass-widgets 0.0.110 → 0.0.112

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 (33) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/phirepass-rdp.cjs.entry.js +1 -1
  3. package/dist/cjs/phirepass-sftp-client.cjs.entry.js +46 -34
  4. package/dist/cjs/phirepass-terminal.cjs.entry.js +19 -7
  5. package/dist/cjs/phirepass-widgets.cjs.js +1 -1
  6. package/dist/cjs/{protocol-CCD7cbHu.js → protocol-COvteaUJ.js} +3 -3
  7. package/dist/collection/common/channel.js +1 -0
  8. package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.js +69 -33
  9. package/dist/collection/components/phirepass-terminal/phirepass-terminal.js +42 -6
  10. package/dist/collection/phirepass-channel_bg.wasm +0 -0
  11. package/dist/components/{p-D4JeTIHt.js → p-Dur4cBX7.js} +1 -1
  12. package/dist/components/phirepass-rdp.js +1 -1
  13. package/dist/components/phirepass-sftp-client.js +1 -1
  14. package/dist/components/phirepass-terminal.js +2 -2
  15. package/dist/esm/loader.js +1 -1
  16. package/dist/esm/phirepass-rdp.entry.js +1 -1
  17. package/dist/esm/phirepass-sftp-client.entry.js +46 -34
  18. package/dist/esm/phirepass-terminal.entry.js +19 -7
  19. package/dist/esm/phirepass-widgets.js +1 -1
  20. package/dist/esm/{protocol-D4JeTIHt.js → protocol-Dur4cBX7.js} +2 -2
  21. package/dist/phirepass-widgets/{p-ff3ec00c.entry.js → p-1fef5b5f.entry.js} +2 -2
  22. package/dist/phirepass-widgets/p-8eb3ec24.entry.js +1 -0
  23. package/dist/phirepass-widgets/{p-401631af.entry.js → p-9a1f9b9f.entry.js} +1 -1
  24. package/dist/phirepass-widgets/{p-D4JeTIHt.js → p-Dur4cBX7.js} +1 -1
  25. package/dist/phirepass-widgets/phirepass-channel_bg.wasm +0 -0
  26. package/dist/phirepass-widgets/phirepass-widgets.esm.js +1 -1
  27. package/dist/types/common/channel.d.ts +19 -0
  28. package/dist/types/components/phirepass-sftp-client/phirepass-sftp-client.d.ts +7 -0
  29. package/dist/types/components/phirepass-terminal/phirepass-terminal.d.ts +7 -0
  30. package/dist/types/components.d.ts +18 -0
  31. package/dist/types/index.d.ts +2 -0
  32. package/package.json +2 -1
  33. package/dist/phirepass-widgets/p-1472a609.entry.js +0 -1
@@ -59,6 +59,12 @@ export class PhirepassSftpClient {
59
59
  }
60
60
  }
61
61
  serverId;
62
+ /**
63
+ * Supplies the channel instead of a WebSocket to the server — for demos,
64
+ * screenshots and tests. A property only (a function cannot be an
65
+ * attribute); read once, when the widget connects. See `ChannelFactory`.
66
+ */
67
+ channelFactory;
62
68
  onServerIdChange(_newValue, _oldValue) {
63
69
  this.onNodeIdChange(this.nodeId, this.nodeId);
64
70
  }
@@ -128,7 +134,9 @@ export class PhirepassSftpClient {
128
134
  this.maximizeEvent?.emit(!this.max);
129
135
  }
130
136
  async connectedCallback() {
131
- await init();
137
+ if (!this.channelFactory) {
138
+ await init();
139
+ }
132
140
  // this.setup_terminal();
133
141
  this.open_comms();
134
142
  this.runtimeReady = true;
@@ -683,11 +691,15 @@ export class PhirepassSftpClient {
683
691
  this.close_comms();
684
692
  }
685
693
  open_comms() {
686
- if (this.serverId) {
687
- this.channel = new PhirepassChannel(`${this.create_web_socket_endpoint()}/api/web/ws`, this.nodeId, this.serverId);
694
+ const endpoint = `${this.create_web_socket_endpoint()}/api/web/ws`;
695
+ if (this.channelFactory) {
696
+ this.channel = this.channelFactory(endpoint, this.nodeId, this.serverId || undefined);
697
+ }
698
+ else if (this.serverId) {
699
+ this.channel = new PhirepassChannel(endpoint, this.nodeId, this.serverId);
688
700
  }
689
701
  else {
690
- this.channel = new PhirepassChannel(`${this.create_web_socket_endpoint()}/api/web/ws`, this.nodeId);
702
+ this.channel = new PhirepassChannel(endpoint, this.nodeId);
691
703
  }
692
704
  this.channel.on_connection_open(() => {
693
705
  this.connectionStateChanged.emit([ConnectionState.Connected]);
@@ -1345,20 +1357,20 @@ export class PhirepassSftpClient {
1345
1357
  return `${typeChar}${chars.join('')}`;
1346
1358
  }
1347
1359
  render() {
1348
- return (h(Host, { key: '94f75760ff9d2f6e2852cdabd109f58bbdc21826', class: {
1360
+ return (h(Host, { key: '9e2edc1a72c3a74b26feea2faa08b9f0a2e37a0c', class: {
1349
1361
  'default': !this.max,
1350
1362
  'max': this.max,
1351
- } }, h("section", { key: '9d2b388a11fb9a4b1ccf8fac1d926c0451fcba3f', class: "listing" }, !this.hideHeader &&
1352
- h("header", { key: '24e3f95b1ff48553e5e8bb150ee7d7ef60f74d73' }, h("section", { key: '1023558093761f93f32f58083b56f8385e6eecff', class: "title" }, h("img", { key: 'dbac57cd459cb6ebca477e85eb9fdeae51b9b8b2', src: svg, alt: "SFTP Client" }), h("div", { key: 'bab01697a1a84f05fbad8b15b75ba39962408c95', class: "text" }, h("div", { key: 'e3a29b907e3eef0e7240c13ee50d8e77ffd9a29c', class: "name" }, this.name), h("div", { key: 'ccdb117f874649914e4bc6fab0257d888a396ff5', class: "description" }, this.description))), h("section", { key: 'eda0da6fdca162f3414ba0802dad3088b00d9ab1', class: "actions" }, h("div", { key: 'e0882533b6e2512c0f8c074b031e17b53000413d', class: "action", onClick: () => this.toggle_max() }, h("img", { key: '18d6009f7e272537863034141ed22a30d7adcdb1', src: max, alt: "Maximize" })))), h("main", { key: 'fb9496e11a2d61d73052a735793931c6c262956a' }, this.show_navigation && h("nav", { key: 'be8098657ee5bd6335f3e37bb45c19818b3ed354', class: "navigation" }, h("div", { key: 'c689b18ab1c5ff8c2e06b050d9eb55253f064496', class: "breadcrumbs" }, this.breadcrumbs.map((crumb, index, breadcrumbs) => (h("span", { key: index, class: "breadcrumb-container" }, h("span", { key: index, onClick: () => this.list_breadcrumb(crumb.path), class: "breadcrumb" }, crumb.label), index < breadcrumbs.length - 1 && h("img", { class: "arrow", src: chevron }))))), h("section", { key: '8533b0cc60a39d5e43df3646487192d75d28eb95', class: "actions", "aria-label": "SFTP actions" }, h("input", { key: 'a7b98422554ee133af228b18297f03c805f138e5', class: "filter", type: "search", autocorrect: "off", autocapitalize: "none", autoComplete: "off", placeholder: "Filter", "aria-label": "Filter this directory", value: this.filter, onInput: (event) => this.filter = event.target.value }), h("button", { key: '4ded4cb62772c4d00153c73df40f2d77946f392d', type: "button", class: "action", onClick: () => this.go_to_parent_directory(), title: "Go to parent directory", "aria-label": "Go to parent directory" }, h("img", { key: '7c56e8a47b0bd650525dce7d1b14440e7fa5dd05', src: go_up, alt: "Go up" })), h("button", { key: '5f3dbe6e7bd6dbcdd9f5d08e179b96de25ddfbe4', type: "button", class: "action", onClick: () => this.refresh_directory(), title: "Refresh", "aria-label": "Refresh" }, h("img", { key: 'fad82f885c47e8fff98fdc987888bdf28533a28d', src: refresh, alt: "Refresh" })), h("button", { key: '5d55e71fa8eb1f2ea1f75859eef44b5a87ece401', type: "button", class: "action", onClick: () => this.open_mkdir(), title: "New folder", "aria-label": "New folder" }, h("svg", { key: '58a5611574a4a862767416437d6488c3ba87a566', xmlns: "http://www.w3.org/2000/svg", width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", "aria-hidden": "true" }, h("path", { key: 'b2bedcd737a0709e0f8af29cbe955acc15477081', d: "M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z" }), h("line", { key: 'ef531e0af9df3b308d91590b15d6dfb57acbeee2', x1: "12", x2: "12", y1: "10", y2: "16" }), h("line", { key: '4b3fb7124f97bacf0e723e728a7ddeec3b534879', x1: "9", x2: "15", y1: "13", y2: "13" }))), h("button", { key: '824e0362e5a256c3848392280ea46a7f798be1c0', type: "button", class: "action", onClick: () => this.open_upload_picker(), title: "Upload", "aria-label": "Upload" }, h("img", { key: '9566d040fa2856e1a39db5d16f7c9ac93af319f7', src: upload, alt: "Upload" })), h("button", { key: '8f3cb1ca3f128af76d7bc33d162ead4d25df7459', type: "button", class: "action disconnect", onClick: () => this.disconnect_session(), title: "Disconnect", "aria-label": "Disconnect" }, "DISCONNECT"))), h("input", { key: '916c345c3163ccea404fe85da708d1e5a522c8ec', type: "file", ref: (el) => this.uploadInputEl = el, onChange: (event) => this.on_upload_selected(event), style: { display: 'none' } }), this.show_content && h("div", { key: 'c894bda7c9f05538e099335bae720c6ac032dc70', class: "content", tabindex: 0, onKeyDown: (event) => this.on_listing_keydown(event) }, h("table", { key: 'e6d162543c57e0805875d52f5de8060473023113' }, h("thead", { key: 'b32d8edc1cc63834dada7cd4a8a9fc0aa4e641ab' }, h("tr", { key: '7ef2d28ba557ab36689066b830534aa644cd100a' }, h("th", { key: '9ec3dc58c85915562618f6dfedb466e4d32d8627', class: "sortable", onClick: () => this.toggle_sort('name'), title: "Sort by name" }, "Name", this.sort_indicator('name')), h("th", { key: '75164784bfde44c0844b5ba1e790fd53476ac0e0', class: "sortable", onClick: () => this.toggle_sort('size'), title: "Sort by size" }, "Size", this.sort_indicator('size')), h("th", { key: 'f4dc607bb845ee940030cd631bfb07aefda9316e' }, "Permissions"), h("th", { key: '2bcbe63f98b2ec812ae0ba82e184cdc0fa1fdfe4' }, "Owner"), h("th", { key: '7f3933b4191b303b99cac3a999392ea700072735', class: "sortable", onClick: () => this.toggle_sort('modified'), title: "Sort by modified date" }, "Modified", this.sort_indicator('modified')), h("th", { key: '6fc772fcb7eb31cc2684e5f50c7e0b25fc3cb11a', class: "action-col", "aria-label": "Actions" }))), h("tbody", { key: '6a506bd214a34a2f4ae0e138b43226502e2cd283' }, this.visible_listing().map((item, index) => (h("tr", { key: index, class: {
1363
+ } }, h("section", { key: '72fae8227792615a5452f9b01ec8230c2c10e2a9', class: "listing" }, !this.hideHeader &&
1364
+ h("header", { key: '14632fcb4575678418132892308cfea1903fadab' }, h("section", { key: '3ea3fb2cab9d4cdf36af3876235579562a7acbef', class: "title" }, h("img", { key: 'fd0badaae9b0d7b426ddece5faf7ea3515e9bbf0', src: svg, alt: "SFTP Client" }), h("div", { key: '4eece24a618c119861f5435eb3f1ae8a5bae4966', class: "text" }, h("div", { key: '84b45196e1a1609451413cf8ea369b60cd7f5ec6', class: "name" }, this.name), h("div", { key: '45da97e659ecbaa69e74d1789a1b7961b760a753', class: "description" }, this.description))), h("section", { key: '9177dcc02b911e95870c5f55fc48f741895a0b75', class: "actions" }, h("div", { key: '468f341eebf7569c2a1c4aeea09d56644e5b6161', class: "action", onClick: () => this.toggle_max() }, h("img", { key: '203b54e42cddc50bf068a49fa7f88c846ecaa2c9', src: max, alt: "Maximize" })))), h("main", { key: 'c0f757aaa07734199228e3dc520c98694bc6548d' }, this.show_navigation && h("nav", { key: '295440219080af5fa33566300fb1036998da399c', class: "navigation" }, h("div", { key: 'c9b63f04de675559d2e2bbb876115c63e00bfbd2', class: "breadcrumbs" }, this.breadcrumbs.map((crumb, index, breadcrumbs) => (h("span", { key: index, class: "breadcrumb-container" }, h("span", { key: index, onClick: () => this.list_breadcrumb(crumb.path), class: "breadcrumb" }, crumb.label), index < breadcrumbs.length - 1 && h("img", { class: "arrow", src: chevron }))))), h("section", { key: '325ccd4be07d61df1e16956b5818683feb70c52f', class: "actions", "aria-label": "SFTP actions" }, h("input", { key: 'f75b4191b0718bd2234497b7168af9dc13a070d6', class: "filter", type: "search", autocorrect: "off", autocapitalize: "none", autoComplete: "off", placeholder: "Filter", "aria-label": "Filter this directory", value: this.filter, onInput: (event) => this.filter = event.target.value }), h("button", { key: 'da64c4a88332d3efab6a6e03e8c16a8a1db96b43', type: "button", class: "action", onClick: () => this.go_to_parent_directory(), title: "Go to parent directory", "aria-label": "Go to parent directory" }, h("img", { key: '309e0fdb89aa4d119a5193f1803ebdc117e55105', src: go_up, alt: "Go up" })), h("button", { key: '5f451e50801f10b88a3436515d792b1015bf48bb', type: "button", class: "action", onClick: () => this.refresh_directory(), title: "Refresh", "aria-label": "Refresh" }, h("img", { key: 'aa673b81504e65e78043c328f94d3a9dd02f696a', src: refresh, alt: "Refresh" })), h("button", { key: '963f5abf044c207f9e42babe9e029ac052521f36', type: "button", class: "action", onClick: () => this.open_mkdir(), title: "New folder", "aria-label": "New folder" }, h("svg", { key: 'd441f67a8b5d2944f95e934d60d680dc22ec7c6c', xmlns: "http://www.w3.org/2000/svg", width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", "aria-hidden": "true" }, h("path", { key: '9eec6695289a71b135dee4751217cd4b4810a276', d: "M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z" }), h("line", { key: '9a759bd7ac97c4e8ebf75c4d54e8f207999634c2', x1: "12", x2: "12", y1: "10", y2: "16" }), h("line", { key: '4591434cdbb6a7d3a1a0212409fe38e21e02a52e', x1: "9", x2: "15", y1: "13", y2: "13" }))), h("button", { key: '301d406858c2d9a4656a342b49e663e76a7f1970', type: "button", class: "action", onClick: () => this.open_upload_picker(), title: "Upload", "aria-label": "Upload" }, h("img", { key: '36ff8480d3acf65282d6ef648349327eb3432237', src: upload, alt: "Upload" })), h("button", { key: '3fa19d5e17ef2e2a8fc926c8ba6994a4a30a1825', type: "button", class: "action disconnect", onClick: () => this.disconnect_session(), title: "Disconnect", "aria-label": "Disconnect" }, "DISCONNECT"))), h("input", { key: 'f5cf6cc13d4b760b538d630467972c8add2df490', type: "file", ref: (el) => this.uploadInputEl = el, onChange: (event) => this.on_upload_selected(event), style: { display: 'none' } }), this.show_content && h("div", { key: 'd69a7009192adc292cf3ccf4de6a4f059b46fa0e', class: "content", tabindex: 0, onKeyDown: (event) => this.on_listing_keydown(event) }, h("table", { key: '2f00d85024b3e4642925f488a34d228dd056a2ce' }, h("thead", { key: '611091a29f97e218f5282e11c7c1accdc1be5732' }, h("tr", { key: '5f0d04ff8a5009852af02472f4261b9a95733a3c' }, h("th", { key: '6df9558b86b3d3161920d5f94e8df0cf47ee9c80', class: "sortable", onClick: () => this.toggle_sort('name'), title: "Sort by name" }, "Name", this.sort_indicator('name')), h("th", { key: '83384582ac59c07f65526cfc5fd1359b5a0cd912', class: "sortable", onClick: () => this.toggle_sort('size'), title: "Sort by size" }, "Size", this.sort_indicator('size')), h("th", { key: 'cbc16eafd7fb17c9d79b5612502140bc9a16a3cb' }, "Permissions"), h("th", { key: '25d802dd84a6cc3eda222d5a732e05010c405f31' }, "Owner"), h("th", { key: 'cf5f9df11baae69f664724c6a79df0a95a5189a8', class: "sortable", onClick: () => this.toggle_sort('modified'), title: "Sort by modified date" }, "Modified", this.sort_indicator('modified')), h("th", { key: '9c8b9515c81245656d89ea65ee091a70606c1a93', class: "action-col", "aria-label": "Actions" }))), h("tbody", { key: '40f8ec5d38a0601af3520891c4a9d35b2da2c32f' }, this.visible_listing().map((item, index) => (h("tr", { key: index, class: {
1353
1365
  'selected': this.is_selected(item),
1354
1366
  }, onClick: () => this.list_directory(item) }, h("td", null, item.kind === 'Folder' ? h("img", { class: "kind", src: folder, alt: "Folder" }) : h("img", { class: "kind", src: file, alt: "File" }), h("span", { class: `name ${item.kind.toLowerCase()}` }, item.name)), h("td", null, item.kind === 'Folder' ? '-' : this.format_size(item.attributes.size)), h("td", null, this.format_permissions(item.attributes.permissions, item.kind)), h("td", null, item.attributes.user ?? '-'), h("td", null, new Date(item.attributes.modified * 1000).toLocaleString()), h("td", { class: "action-col" }, h("div", { class: "file-actions" }, item.kind === 'File' &&
1355
1367
  h("button", { type: "button", class: "file-action", onClick: (event) => this.on_edit_action(item, event), title: "Edit", "aria-label": `Edit ${item.name}` }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", "aria-hidden": "true" }, h("path", { d: "M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" }), h("path", { d: "M18.5 2.5a2.12 2.12 0 0 1 3 3L12 15l-4 1 1-4Z" }))), item.kind === 'File' &&
1356
1368
  h("button", { type: "button", class: "file-action", onClick: (event) => this.on_file_row_action(item, event), title: "Download", "aria-label": `Download ${item.name}` }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", "aria-hidden": "true" }, h("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }), h("polyline", { points: "7 10 12 15 17 10" }), h("line", { x1: "12", x2: "12", y1: "15", y2: "3" }))), h("button", { type: "button", class: "file-action", onClick: (event) => this.on_rename_action(item, event), title: "Rename", "aria-label": `Rename ${item.name}` }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", "aria-hidden": "true" }, h("path", { d: "M12 20h9" }), h("path", { d: "M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z" }))), h("button", { type: "button", class: "file-action", onClick: (event) => this.on_chmod_action(item, event), title: "Permissions", "aria-label": `Change permissions on ${item.name}` }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", "aria-hidden": "true" }, h("rect", { width: "18", height: "11", x: "3", y: "11", rx: "2", ry: "2" }), h("path", { d: "M7 11V7a5 5 0 0 1 10 0v4" }))), h("button", { type: "button", class: "file-action delete", onClick: (event) => this.on_file_delete_action(item, event), title: "Delete", "aria-label": `Delete ${item.name}` }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", "aria-hidden": "true" }, h("polyline", { points: "3 6 5 6 21 6" }), h("path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" }), h("path", { d: "M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6" }), h("line", { x1: "10", x2: "10", y1: "11", y2: "17" }), h("line", { x1: "14", x2: "14", y1: "11", y2: "17" })))))))), this.visible_listing().length === 0 &&
1357
- h("tr", { key: 'b056d99b4df7c0217c0eeb925d7ab8b519456a5f', class: "empty" }, h("td", { key: '34a0f9f9e70827e64ea9843bd0263f258fc0c20a', colSpan: 6 }, this.filter ? `Nothing here matches "${this.filter}".` : 'This directory is empty.'))))), this.show_loader && h("div", { key: '980fd45f6af488bf86dbbf1211abe0ccb3422b81', class: "loader" }, "Loading..."), this.show_error && h("div", { key: '0c368db0fd65b63f64e40119ac474d74e7832b61', class: "error" }, this.error_message)), h("footer", { key: '71d8b999bca0fd0a9b3a224fa370f2953abf3b5f' }, h("section", { key: '911030d32f3e1fab2f0df0ab43b093626124395c', class: "status" }, this.status, this.selected_item && h("span", { key: '19d2607ce0761647eeda4b01fbea9f4a3ccc5885', class: "selected-item" }, this.selected_item.name)), h("section", { key: 'e6f3f2a1b3f8adf04eff1b77f2947e210302876f', class: "version" }, this.version ? `Version: ${this.version}` : ''))), this.show_login_screen &&
1358
- h("section", { key: 'f08ce7f1182fffe42e7eb470e52d046095441234', class: {
1369
+ h("tr", { key: '46a173ad6542c9ab315da2792ea9830f0086b683', class: "empty" }, h("td", { key: '986924de123f9be62f89f869fca02cd195134080', colSpan: 6 }, this.filter ? `Nothing here matches "${this.filter}".` : 'This directory is empty.'))))), this.show_loader && h("div", { key: '588f4ff57df18c993f8566711a2627bd69b03881', class: "loader" }, "Loading..."), this.show_error && h("div", { key: '816c8ca05f68291d784d4c86509c9478204f3449', class: "error" }, this.error_message)), h("footer", { key: '6add74a0d5beb8de15a600d287d96dd69f87a646' }, h("section", { key: '39b31ae22b9f6298b8991be47d5641c1de618ab7', class: "status" }, this.status, this.selected_item && h("span", { key: '6e3942b5471e240719dfaf66cb01763f162ff3f0', class: "selected-item" }, this.selected_item.name)), h("section", { key: 'cc7ab5a9a632da8fae266f9ae73f967083e3589f', class: "version" }, this.version ? `Version: ${this.version}` : ''))), this.show_login_screen &&
1370
+ h("section", { key: '3e13e8c942f690d2e26c231c2403032af620f735', class: {
1359
1371
  'creds': true,
1360
1372
  'blurred': this.show_login_screen,
1361
- } }, h("form", { key: '0fbcaaf222d20a0c5a8769d7d9614135db0971bd', class: "auth", onSubmit: (event) => {
1373
+ } }, h("form", { key: '7ddb982159a3470bfad44aea75973a2eb37bebcd', class: "auth", onSubmit: (event) => {
1362
1374
  const formData = new FormData(event.target);
1363
1375
  let username = undefined;
1364
1376
  if (this.show_login_screen_username) {
@@ -1375,57 +1387,57 @@ export class PhirepassSftpClient {
1375
1387
  this.show_loader = true;
1376
1388
  event.stopPropagation();
1377
1389
  event.preventDefault();
1378
- } }, h("div", { key: '25af70a09ffe30493a8416f30b367402017b7ed0', class: "title" }, "SFTP Connection"), this.show_login_screen_username &&
1379
- h("div", { key: '3f1064e4acfc3f599e22e9314a455db72fcfd6f2' }, h("label", { key: 'a353afd35a192e7b8f7f66d0168974a42921a17d', htmlFor: "username" }, "Username"), h("input", { key: 'bc36e4f51537a4070443f9a5a82910e48842cfec', autocorrect: "off", autocapitalize: "none", autoComplete: "off", id: "username", name: "username", type: "text", placeholder: "" })), this.show_login_screen_password &&
1380
- h("div", { key: 'e7181272416bfc7928d8e714d9c3227b5d0c1f66' }, h("label", { key: 'd090c64f8179378cdef09bd6b9180f5707a1e43e', htmlFor: "password" }, "Password"), h("input", { key: '6359b22a3a2ba9c68c1d54ea07dae8b1c388d17a', autocorrect: "off", autocapitalize: "none", autoComplete: "off", id: "password", name: "password", type: "password", placeholder: "" })), h("div", { key: '778c3e57e389329fc12ad6bc90921d86aedd4e80' }, h("button", { key: 'ad7881537626c5242f4ff5f0ae267e4526589d0f', type: "submit" }, "Connect")))), this.show_upload_modal &&
1381
- h("section", { key: '75ee6bf70138d1df39eae7559e1d5358af127858', class: {
1390
+ } }, h("div", { key: '036877a02034000a79836c0a0979def9163f8a1a', class: "title" }, "SFTP Connection"), this.show_login_screen_username &&
1391
+ h("div", { key: '37830ddb769fe0491831700a90f3fc8bf71cf050' }, h("label", { key: '0f6e3d70e34baae3342a57fceed657e59c8c05a4', htmlFor: "username" }, "Username"), h("input", { key: '3ecb202b3ee015e8719c330edb06889f4f48a433', autocorrect: "off", autocapitalize: "none", autoComplete: "off", id: "username", name: "username", type: "text", placeholder: "" })), this.show_login_screen_password &&
1392
+ h("div", { key: '092a40a9da1205ec6342069844135aea92b85c5a' }, h("label", { key: '19e465136660c9d2c1ecd0bb02bd7f8a559e3e0b', htmlFor: "password" }, "Password"), h("input", { key: 'ab9a74273abc594fa9fd51a780c2586fb275b4b4', autocorrect: "off", autocapitalize: "none", autoComplete: "off", id: "password", name: "password", type: "password", placeholder: "" })), h("div", { key: 'c1596787c7fea135d203f831cb7432a6e803d488' }, h("button", { key: '89314be80add42ba55f96ec01bf22848742ec179', type: "submit" }, "Connect")))), this.show_upload_modal &&
1393
+ h("section", { key: 'c8b08cf050947d1936c97caf46eacca93175db9f', class: {
1382
1394
  'upload-modal': true,
1383
1395
  'visible': this.show_upload_modal,
1384
- } }, h("div", { key: '87ea253eb2044c1748c9feaf1daa9c684df429f8', class: "upload-dialog", role: "dialog", "aria-modal": "true", "aria-label": "Upload progress" }, h("div", { key: '83c64dcfc0a59c0cc76b6d0223c8fd17346849fc', class: "title" }, "Uploading File"), h("div", { key: 'a71a0dec4cb9d75e0a4edc5612c41238d9729f1a', class: "file-name", title: this.upload_file_name }, this.upload_file_name), h("div", { key: '057c9ca8bdf18fbedd75dba33d35ef7336a1c097', class: "progress-track", role: "progressbar", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": this.upload_progress }, h("div", { key: '7a503b29c32cc03f0491be389bd9a21b340838aa', class: "progress-fill", style: { width: `${this.upload_progress}%` } })), h("div", { key: 'a9b831b1548eecfcf21ad9d3d56a22cc6e3dae84', class: "progress-meta" }, h("div", { key: 'f5de7e9567ed5633bb81634add297faf24d55123', class: "progress-speed" }, this.upload_speed), h("div", { key: '0241bcc3c54afd1cd6e5bb802b8518bb45458659', class: "progress-value" }, this.format_percent(this.upload_progress))), h("button", { key: '354fb6fa81acf2e48eaa3ef897fb0d48d9435494', type: "button", class: {
1396
+ } }, h("div", { key: 'ccc745354525565cda06b6b6eb8253c557c59009', class: "upload-dialog", role: "dialog", "aria-modal": "true", "aria-label": "Upload progress" }, h("div", { key: 'd478b113fa655386998d93862fc53bf516eaf90b', class: "title" }, "Uploading File"), h("div", { key: '35c85475b00efcf05097e1feae1313afde0d04af', class: "file-name", title: this.upload_file_name }, this.upload_file_name), h("div", { key: 'd5cb7df154d77dacdca48673b2f01e03729846b0', class: "progress-track", role: "progressbar", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": this.upload_progress }, h("div", { key: '4a7c10979b37d06acdda30c0b8d04a2af3cf0e5a', class: "progress-fill", style: { width: `${this.upload_progress}%` } })), h("div", { key: 'c69da13c3bc15a9a36867cbb1a8d041780ffecca', class: "progress-meta" }, h("div", { key: '000b027205a828e1257263e29b5a595ead0fe54a', class: "progress-speed" }, this.upload_speed), h("div", { key: '8eda5c230e39343ffb10aa1bc64f70999d428c57', class: "progress-value" }, this.format_percent(this.upload_progress))), h("button", { key: 'b047fe324179b9f77f97f7bcf541c32e0903bad9', type: "button", class: {
1385
1397
  'cancel': true,
1386
1398
  'finished': this.upload_finished,
1387
1399
  }, onClick: () => this.cancel_upload() }, this.upload_finished ? 'Close' : 'Cancel'))), this.show_download_modal &&
1388
- h("section", { key: 'c5ae39a268ae33b4a623b576101fb524fb651a61', class: {
1400
+ h("section", { key: 'fff5c3228be15048397b86a1457f63d4562c98f8', class: {
1389
1401
  'download-modal': true,
1390
1402
  'visible': this.show_download_modal,
1391
- } }, h("div", { key: '38817aa1411005058ae56a9ab3acd66e7e031221', class: "download-dialog", role: "dialog", "aria-modal": "true", "aria-label": "Download progress" }, h("div", { key: '96bebe6045d616d34b8aeef8876032fed887affc', class: "title" }, "Downloading File"), h("div", { key: '9669662ca9a60bbee2764ba1b92c7d43a20106af', class: "file-name", title: this.download_file_name }, this.download_file_name), h("div", { key: '66b7759dbec989dbd093a3635d312ffd78059356', class: "progress-track", role: "progressbar", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": this.download_progress }, h("div", { key: '6ef0146a885aadfdf90de134ab8c4ad34b6a0a34', class: "progress-fill", style: { width: `${this.download_progress}%` } })), h("div", { key: '073bb8a2452515e0ea3678ed5da5e85a09df61ba', class: "progress-meta" }, h("div", { key: 'a401199826a0b028e26dc17155e056fa5b18b049', class: "progress-speed" }, this.download_speed), h("div", { key: 'a0c6170323d18d62107ea9c93405218773ef8f74', class: "progress-value" }, this.format_percent(this.download_progress))), h("button", { key: '9b8beb35c26a57b42c2e1b8b96eadb875e893668', type: "button", class: {
1403
+ } }, h("div", { key: '8bbf7465cdb2b514b16c4982b3480b04aa5e1a6c', class: "download-dialog", role: "dialog", "aria-modal": "true", "aria-label": "Download progress" }, h("div", { key: 'dea4371acce3010cefdb14bbc3873d6cca1e308c', class: "title" }, "Downloading File"), h("div", { key: 'cffc4ad6e269108252db2bbb3b3f9678e88aed4b', class: "file-name", title: this.download_file_name }, this.download_file_name), h("div", { key: 'ec0fd7bbd72c2c1dcb55dffb39a8e550af9c54a6', class: "progress-track", role: "progressbar", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": this.download_progress }, h("div", { key: 'c899bcf67b523e9de0db76bc9163d192120fd61b', class: "progress-fill", style: { width: `${this.download_progress}%` } })), h("div", { key: '14c343bb055ca7300f3b500bb9da06450f9338c8', class: "progress-meta" }, h("div", { key: '6b030a95eb9b11d88a070dd8a8dc9f4a2d10302a', class: "progress-speed" }, this.download_speed), h("div", { key: '0d8eb9884506e9bb7a31ea1ceedc0f3e3e74f9b8', class: "progress-value" }, this.format_percent(this.download_progress))), h("button", { key: '4416377601c6655ba0e9385e6149dd461702439a', type: "button", class: {
1392
1404
  'cancel': true,
1393
1405
  'finished': this.download_finished,
1394
1406
  }, onClick: () => this.cancel_download() }, this.download_finished ? 'Close' : 'Cancel'))), this.show_delete_modal &&
1395
- h("section", { key: 'acb147f3b2474a12948153992db4b105ec46c2e3', class: {
1407
+ h("section", { key: '803d5f9fc2096c44335380132eee7d6ee1c70c1f', class: {
1396
1408
  'delete-modal': true,
1397
1409
  'visible': this.show_delete_modal,
1398
- } }, h("div", { key: '1adb2b1ed0183ec136bfdaf63b4dfe880f919811', class: "delete-dialog", role: "dialog", "aria-modal": "true", "aria-label": "Delete confirmation", tabindex: -1, onKeyDown: (event) => this.on_modal_keydown(event, () => this.cancel_delete()) }, h("div", { key: '2481008ad54e92f4abd82c8e2c36a52e34db0c7c', class: "title" }, this.delete_is_dir ? 'Delete Folder' : 'Delete File'), h("div", { key: 'a91a942f3b35b7886033146597bb1ff7b9998dc1', class: "message" }, this.delete_loading
1410
+ } }, h("div", { key: '0f23cb5f9ed35b97accc994277c86eff46de74bd', class: "delete-dialog", role: "dialog", "aria-modal": "true", "aria-label": "Delete confirmation", tabindex: -1, onKeyDown: (event) => this.on_modal_keydown(event, () => this.cancel_delete()) }, h("div", { key: '6b64cac5732de2d5c091fea7ef1cd1b903b86c61', class: "title" }, this.delete_is_dir ? 'Delete Folder' : 'Delete File'), h("div", { key: 'f1b6592449d9697208c704dcaaeec83d4d40d852', class: "message" }, this.delete_loading
1399
1411
  ? (this.delete_recursive ? 'Deleting the folder and everything in it...' : 'Deleting...')
1400
- : `Are you sure you want to delete this ${this.delete_is_dir ? 'folder' : 'file'}?`), h("div", { key: 'f218cfc2faa0843b7dc8715f96aff55986aeab15', class: "file-name", title: this.delete_file_name }, this.delete_file_name), this.delete_is_dir &&
1401
- h("label", { key: '9477429e9d929c95f8173160ea3983034a3e3849', class: "checkline" }, h("input", { key: '6573ea9e9b7af1d6233ddf8328b152226b6957bb', type: "checkbox", checked: this.delete_recursive, disabled: this.delete_loading, onChange: (event) => this.delete_recursive = event.target.checked }), h("span", { key: '0e2f1fed38cd99272af527a4aebeb56afaaa1c0d' }, "Delete everything inside it too")), !this.delete_is_dir || this.delete_recursive ? null :
1402
- h("div", { class: "hint" }, "Without this, the remote refuses a folder that is not empty."), this.delete_error && h("div", { key: '837a597c00932e82be2e713badba936dcefb8b40', class: "dialog-error" }, this.delete_error), this.delete_loading &&
1403
- h("div", { key: '1e350abb9e5d93fff3a496797d5c53c3c2de1827', class: "delete-loader", "aria-hidden": "true" }, h("span", { key: '89ea233eba5a799e702944afb1c989e707497c77', class: "spinner" })), h("div", { key: '679d16bc9641e98c993bce468cf09a6cd06a345d', class: "modal-actions" }, h("button", { key: '2fbcf1783b8a6aeb6f9c7d3f20a8abf3ae68d816', type: "button", class: "btn secondary", onClick: () => this.cancel_delete(), disabled: this.delete_loading }, "Cancel"), h("button", { key: '00cb2afd0df514a36c7977e800007746e8c8e73d', type: "button", class: "btn destructive", onClick: () => this.confirm_delete(), disabled: this.delete_loading }, this.delete_loading ? 'Deleting...' : 'Delete')))), this.prompt_kind &&
1404
- h("section", { key: '7ac274aaa8c19e6d77c3a0be9feb68630fccb84f', class: "prompt-modal visible" }, h("div", { key: 'b9f9099ae61a0b518491c32e3f6aef79c28a812f', class: "prompt-dialog", role: "dialog", "aria-modal": "true", "aria-label": this.prompt_kind === 'mkdir' ? 'New folder' : 'Rename', tabindex: -1, onKeyDown: (event) => this.on_modal_keydown(event, () => this.close_prompt()) }, h("div", { key: 'e837df12158553b576282957ba368caf977f4d2a', class: "title" }, this.prompt_kind === 'mkdir' ? 'New Folder' : 'Rename'), h("div", { key: '25b71e67724d98f50cb3d21722822bddf8bc2c4c', class: "message" }, this.prompt_kind === 'mkdir'
1412
+ : `Are you sure you want to delete this ${this.delete_is_dir ? 'folder' : 'file'}?`), h("div", { key: 'a67f8bd35875e0477fcf3bbf9f075b10f9066f07', class: "file-name", title: this.delete_file_name }, this.delete_file_name), this.delete_is_dir &&
1413
+ h("label", { key: '5e660c03c1df789bcdc4dba7a2adfe4887dd71ca', class: "checkline" }, h("input", { key: 'c28122496182d007ae2f99d9de79451c23dadef5', type: "checkbox", checked: this.delete_recursive, disabled: this.delete_loading, onChange: (event) => this.delete_recursive = event.target.checked }), h("span", { key: '53539d4803c5358d26e181dc53fcc7f36ad62d6a' }, "Delete everything inside it too")), !this.delete_is_dir || this.delete_recursive ? null :
1414
+ h("div", { class: "hint" }, "Without this, the remote refuses a folder that is not empty."), this.delete_error && h("div", { key: '0773a1e6a26fa8dde7dba0d0ed00107d01782e2f', class: "dialog-error" }, this.delete_error), this.delete_loading &&
1415
+ h("div", { key: 'b1580f0825ec4f4b37f894fbd714f143a9515fd6', class: "delete-loader", "aria-hidden": "true" }, h("span", { key: 'db549d437007182afdaddab37d8caec7b1c4a2c7', class: "spinner" })), h("div", { key: '040a4c6730ce5149737211fae9d67a3a290bdc5c', class: "modal-actions" }, h("button", { key: 'b742ccd04a3e119c446a2186081835fd6f67022d', type: "button", class: "btn secondary", onClick: () => this.cancel_delete(), disabled: this.delete_loading }, "Cancel"), h("button", { key: '4ce414e250ace86f93d24e399ca56014e56c7757', type: "button", class: "btn destructive", onClick: () => this.confirm_delete(), disabled: this.delete_loading }, this.delete_loading ? 'Deleting...' : 'Delete')))), this.prompt_kind &&
1416
+ h("section", { key: 'd533b9ecb021dbb69766ba92e87d0b4279b047d4', class: "prompt-modal visible" }, h("div", { key: 'f7fbe0ee2323439da2c991046d90b1b6397ebee8', class: "prompt-dialog", role: "dialog", "aria-modal": "true", "aria-label": this.prompt_kind === 'mkdir' ? 'New folder' : 'Rename', tabindex: -1, onKeyDown: (event) => this.on_modal_keydown(event, () => this.close_prompt()) }, h("div", { key: '36b154bda604336f8bbb7c46d7bb35b6afd6cec2', class: "title" }, this.prompt_kind === 'mkdir' ? 'New Folder' : 'Rename'), h("div", { key: '76b8027be289fcdba2867e1b06f05cab8481564d', class: "message" }, this.prompt_kind === 'mkdir'
1405
1417
  ? `Create a folder in ${this.current_dir}`
1406
- : 'Give it a new name. Existing names are not overwritten.'), h("form", { key: '390328d2b0f27a1a315a2bc55ae520e907813068', onSubmit: (event) => { event.preventDefault(); event.stopPropagation(); void this.submit_prompt(); } }, h("input", { key: 'dc958cd778250116043d82f191c0f4fb2fcf1c91', class: "dialog-input", type: "text", autocorrect: "off", autocapitalize: "none", autoComplete: "off", spellcheck: false, "aria-label": "Name", disabled: this.prompt_busy, value: this.prompt_value, onInput: (event) => this.prompt_value = event.target.value, ref: (el) => this.focus_once(el, this.promptInputEl, (kept) => this.promptInputEl = kept) }), this.prompt_error && h("div", { key: '588e3aa9ec1759e24404784164a83001f1da8bb8', class: "dialog-error" }, this.prompt_error), h("div", { key: '15850d8a366a2a5f87e9b10c0351d684c3c30f78', class: "modal-actions" }, h("button", { key: 'dbfb5831fd896fc711efe53cbfe8ed57af19a2e3', type: "button", class: "btn secondary", onClick: () => this.close_prompt(), disabled: this.prompt_busy }, "Cancel"), h("button", { key: '95c872e35e3f65f4a7f0893b45c4d258b082b020', type: "submit", class: "btn primary", disabled: this.prompt_busy }, this.prompt_busy ? 'Working...' : (this.prompt_kind === 'mkdir' ? 'Create' : 'Rename')))))), this.chmod_target &&
1407
- h("section", { key: '52373d1f66e3db9da1d8bb3018788efbf19fc762', class: "prompt-modal visible" }, h("div", { key: '887b863eb1d41d99acebbe7abe19273b202bbed2', class: "prompt-dialog", role: "dialog", "aria-modal": "true", "aria-label": "Change permissions", tabindex: -1, onKeyDown: (event) => this.on_modal_keydown(event, () => this.close_chmod()) }, h("div", { key: '8c686b15eb982779633720236d3e00559ed37edd', class: "title" }, "Permissions"), h("div", { key: 'af9b7c128bc8bf0072c9c52de052435b3f8a6574', class: "file-name", title: this.chmod_target.name }, this.chmod_target.name), h("table", { key: '996e04c071fb8bbde39a0c811d8beef052f311c5', class: "perm-grid" }, h("thead", { key: '767477a3d4aacfe75fa4fa0bdc762c6d3448cebb' }, h("tr", { key: '5198f4e64fa9903cfd0c5221cb9ab86d690253e3' }, h("th", { key: 'd6fb60c8407b19a61e0d215ca8a9a1daa228e98e', "aria-label": "Class" }), h("th", { key: '9c1d18a98cd7471f6bae9f1009a2425287f60ef7' }, "Read"), h("th", { key: '529584b9be0ac95104818e22b7cd515b9e0f79f8' }, "Write"), h("th", { key: '9402ec30094930c53822722c17dd126949c8705e' }, "Execute"))), h("tbody", { key: '6aae29e72101eab4f5191696d64d65db35361b95' }, [
1418
+ : 'Give it a new name. Existing names are not overwritten.'), h("form", { key: '8ec6e410dc6572de35ff6b2c81734fa48d74a4a8', onSubmit: (event) => { event.preventDefault(); event.stopPropagation(); void this.submit_prompt(); } }, h("input", { key: '0511fa8205057fe088be93781c23e283bc07739e', class: "dialog-input", type: "text", autocorrect: "off", autocapitalize: "none", autoComplete: "off", spellcheck: false, "aria-label": "Name", disabled: this.prompt_busy, value: this.prompt_value, onInput: (event) => this.prompt_value = event.target.value, ref: (el) => this.focus_once(el, this.promptInputEl, (kept) => this.promptInputEl = kept) }), this.prompt_error && h("div", { key: '2644600b1e015e02209309e1163e991acabad2e9', class: "dialog-error" }, this.prompt_error), h("div", { key: '520937e554f3ff7839aad18fd0ed3c56f8a21680', class: "modal-actions" }, h("button", { key: 'e5a037f006c3f97e6227e672cff6cf3dc7282abb', type: "button", class: "btn secondary", onClick: () => this.close_prompt(), disabled: this.prompt_busy }, "Cancel"), h("button", { key: 'b7883cc44b152c2c648f133eb5ffd7f5942d0aa4', type: "submit", class: "btn primary", disabled: this.prompt_busy }, this.prompt_busy ? 'Working...' : (this.prompt_kind === 'mkdir' ? 'Create' : 'Rename')))))), this.chmod_target &&
1419
+ h("section", { key: 'e99ef709477024789821b76e1bbaa6497dcbc474', class: "prompt-modal visible" }, h("div", { key: '1cec5818b817d089a9b4cda3b4ee514e7e9201a7', class: "prompt-dialog", role: "dialog", "aria-modal": "true", "aria-label": "Change permissions", tabindex: -1, onKeyDown: (event) => this.on_modal_keydown(event, () => this.close_chmod()) }, h("div", { key: '49c35a7228bbc6e9898c499904feb5fb525b2b5c', class: "title" }, "Permissions"), h("div", { key: '814edc9c438d956bef13b14bc22733502168c340', class: "file-name", title: this.chmod_target.name }, this.chmod_target.name), h("table", { key: 'a4c1b45c1ee830599e7c08a9a44c69df1ac2b201', class: "perm-grid" }, h("thead", { key: '99b953b4cf5f3a6aeff766d39b15222e74235a3c' }, h("tr", { key: '49d3ae286989915aaca71ba43cb19db357064158' }, h("th", { key: '3f3b7fcbeb1b713d29a874a111552f6ff95a811e', "aria-label": "Class" }), h("th", { key: '6d18882102b71cb61be8ae93a946f62da7b555bc' }, "Read"), h("th", { key: '44aed1177108307db4618680b5e7d28e248cdab6' }, "Write"), h("th", { key: 'd6056bed3aab4164768a010c369365c70e67bbbc' }, "Execute"))), h("tbody", { key: 'd54ecfe06cade301263977cf1f0a0ba9e3721b5c' }, [
1408
1420
  { label: 'Owner', read: 0o400, write: 0o200, exec: 0o100 },
1409
1421
  { label: 'Group', read: 0o040, write: 0o020, exec: 0o010 },
1410
1422
  { label: 'Other', read: 0o004, write: 0o002, exec: 0o001 },
1411
- ].map((row) => (h("tr", { key: row.label }, h("th", { scope: "row" }, row.label), [row.read, row.write, row.exec].map((bit) => (h("td", { key: bit }, h("input", { type: "checkbox", "aria-label": `${row.label} ${bit}`, disabled: this.chmod_busy, checked: (this.chmod_mode & bit) !== 0, onChange: () => this.toggle_chmod_bit(bit) }))))))))), h("div", { key: 'c429b0d2bff193da9b48a2802719b774899125f4', class: "perm-special" }, [
1423
+ ].map((row) => (h("tr", { key: row.label }, h("th", { scope: "row" }, row.label), [row.read, row.write, row.exec].map((bit) => (h("td", { key: bit }, h("input", { type: "checkbox", "aria-label": `${row.label} ${bit}`, disabled: this.chmod_busy, checked: (this.chmod_mode & bit) !== 0, onChange: () => this.toggle_chmod_bit(bit) }))))))))), h("div", { key: 'a124e9599de6b406d84ba9ffa3a56b3b993179ef', class: "perm-special" }, [
1412
1424
  { label: 'setuid', bit: 0o4000 },
1413
1425
  { label: 'setgid', bit: 0o2000 },
1414
1426
  { label: 'sticky', bit: 0o1000 },
1415
- ].map((special) => (h("label", { key: special.label, class: "checkline" }, h("input", { type: "checkbox", disabled: this.chmod_busy, checked: (this.chmod_mode & special.bit) !== 0, onChange: () => this.toggle_chmod_bit(special.bit) }), h("span", null, special.label))))), h("div", { key: '8927030347b5a78bbc2d0c68963cfa4b50aafc7b', class: "perm-octal" }, h("label", { key: '23cab841c245e4efabbf2348d0b932e70084f15d', htmlFor: "chmod-octal" }, "Octal"), h("input", { key: '1db5c92a844e4458bd6b3be663d9d1c87d523cb1', id: "chmod-octal", class: "dialog-input", type: "text", autocorrect: "off", autocapitalize: "none", autoComplete: "off", spellcheck: false, maxlength: 4, disabled: this.chmod_busy, value: this.chmod_mode.toString(8).padStart(4, '0'), onInput: (event) => this.on_chmod_octal_input(event.target.value) }), h("span", { key: '636db9e85c1e551e3f09882acddca4b5e00ddb3a', class: "perm-preview" }, this.format_permissions(this.chmod_mode, this.chmod_target.kind))), this.chmod_error && h("div", { key: '295b4b35efbabede3481ba87df67dd6c49d96cc4', class: "dialog-error" }, this.chmod_error), h("div", { key: 'c226a4e3bed1a0388ceed76813667012d1022a4b', class: "modal-actions" }, h("button", { key: '716e0e6c46cbdb72872200a3ce5041212b41c63a', type: "button", class: "btn secondary", onClick: () => this.close_chmod(), disabled: this.chmod_busy }, "Cancel"), h("button", { key: '3b579eccd182089b65047280a0a8523aa62e3c74', type: "button", class: "btn primary", onClick: () => void this.submit_chmod(), disabled: this.chmod_busy }, this.chmod_busy ? 'Applying...' : 'Apply')))), this.show_editor &&
1416
- h("section", { key: 'c965bc02d104440f0e171a7ebbc3b63bf11b1ca7', class: "editor-modal visible" }, h("div", { key: '4796d6b8b79a6a1f486109005bac2f9f76c424d2', class: "editor-dialog", role: "dialog", "aria-modal": "true", "aria-label": `Editing ${this.editor_name}`, tabindex: -1, onKeyDown: (event) => {
1427
+ ].map((special) => (h("label", { key: special.label, class: "checkline" }, h("input", { type: "checkbox", disabled: this.chmod_busy, checked: (this.chmod_mode & special.bit) !== 0, onChange: () => this.toggle_chmod_bit(special.bit) }), h("span", null, special.label))))), h("div", { key: '05ab3c8451084b6acdf7ea0e45f71da0f913b08d', class: "perm-octal" }, h("label", { key: '5cb748e079c869720361e56c4973eaea82a85bc0', htmlFor: "chmod-octal" }, "Octal"), h("input", { key: '652571af51a36c975d8b7432923ef2ab80743480', id: "chmod-octal", class: "dialog-input", type: "text", autocorrect: "off", autocapitalize: "none", autoComplete: "off", spellcheck: false, maxlength: 4, disabled: this.chmod_busy, value: this.chmod_mode.toString(8).padStart(4, '0'), onInput: (event) => this.on_chmod_octal_input(event.target.value) }), h("span", { key: '4a789c75be9a941d2adf8de68cfda043c19864cc', class: "perm-preview" }, this.format_permissions(this.chmod_mode, this.chmod_target.kind))), this.chmod_error && h("div", { key: 'acb09c9d16146cc0466df1ea6394ff492604c397', class: "dialog-error" }, this.chmod_error), h("div", { key: '46c5c4fc154529060b24e335dcd192ed6dc6f75d', class: "modal-actions" }, h("button", { key: '2ad9fad876497e4d629c1911fbe29616853a2e59', type: "button", class: "btn secondary", onClick: () => this.close_chmod(), disabled: this.chmod_busy }, "Cancel"), h("button", { key: 'c14f7edb08da6d2db078722438e8e06455a076c7', type: "button", class: "btn primary", onClick: () => void this.submit_chmod(), disabled: this.chmod_busy }, this.chmod_busy ? 'Applying...' : 'Apply')))), this.show_editor &&
1428
+ h("section", { key: 'f040aeca04a6b02af3247c024271fbdc2564a0c4', class: "editor-modal visible" }, h("div", { key: '6874ae8a526168be8c2c09ca3f8a1faa52b78027', class: "editor-dialog", role: "dialog", "aria-modal": "true", "aria-label": `Editing ${this.editor_name}`, tabindex: -1, onKeyDown: (event) => {
1417
1429
  if ((event.ctrlKey || event.metaKey) && event.key === 's') {
1418
1430
  event.preventDefault();
1419
1431
  void this.save_editor();
1420
1432
  return;
1421
1433
  }
1422
1434
  this.on_modal_keydown(event, () => this.close_editor());
1423
- } }, h("div", { key: '9f5a55b46763e68b7a127b1b341a6a54e46628f4', class: "editor-head" }, h("div", { key: '59b7d4105a5a31e66c520ff0f809bdc59e700330', class: "title" }, this.editor_name, this.editor_is_dirty() ? ' *' : ''), h("button", { key: 'ee74ac43364b05393e3ddbffb40f291bd855a4f8', type: "button", class: "editor-close", onClick: () => this.close_editor(), "aria-label": "Close editor", disabled: this.editor_busy === 'saving' }, "x")), this.editor_busy === 'loading'
1435
+ } }, h("div", { key: '421cbd1bfbde035049ed028c4d05083cc7d8f66f', class: "editor-head" }, h("div", { key: '889adcf6e0187963964920b9750531c3fa06cd37', class: "title" }, this.editor_name, this.editor_is_dirty() ? ' *' : ''), h("button", { key: 'b14d28ca6a80c9a08277ff20bc0b38fc30ea3869', type: "button", class: "editor-close", onClick: () => this.close_editor(), "aria-label": "Close editor", disabled: this.editor_busy === 'saving' }, "x")), this.editor_busy === 'loading'
1424
1436
  ? h("div", { class: "editor-loading" }, "Loading...")
1425
- : h("textarea", { class: "editor-text", spellcheck: false, autocorrect: "off", autocapitalize: "none", autoComplete: "off", "aria-label": "File contents", disabled: this.editor_busy === 'saving' || !this.editor_loaded, value: this.editor_text, onInput: (event) => this.editor_text = event.target.value, ref: (el) => this.focus_once(el, this.editorTextEl, (kept) => this.editorTextEl = kept) }), this.editor_error && h("div", { key: '9a6c47f21cdce7cc76ce3cb9c5ca12af7215004e', class: "dialog-error" }, this.editor_error), this.editor_confirm_discard &&
1426
- h("div", { key: 'd445399441b1411d5f2607c1bed36551e8421b39', class: "dialog-error" }, "Unsaved changes. Close anyway?"), h("div", { key: '9a98131525346b0b818dc55f7f02d0be579a75c9', class: "modal-actions" }, this.editor_confirm_discard
1437
+ : h("textarea", { class: "editor-text", spellcheck: false, autocorrect: "off", autocapitalize: "none", autoComplete: "off", "aria-label": "File contents", disabled: this.editor_busy === 'saving' || !this.editor_loaded, value: this.editor_text, onInput: (event) => this.editor_text = event.target.value, ref: (el) => this.focus_once(el, this.editorTextEl, (kept) => this.editorTextEl = kept) }), this.editor_error && h("div", { key: 'e7c1db037e749fec8970ac2b2be2cb85cfcd85be', class: "dialog-error" }, this.editor_error), this.editor_confirm_discard &&
1438
+ h("div", { key: '84ca6080e18c4334e87374126b82b816f318cb0d', class: "dialog-error" }, "Unsaved changes. Close anyway?"), h("div", { key: '4515e164a418815eccfd9d54d8f96a076616f326', class: "modal-actions" }, this.editor_confirm_discard
1427
1439
  ? h("button", { type: "button", class: "btn destructive", onClick: () => this.close_editor(true) }, "Discard")
1428
- : h("button", { type: "button", class: "btn secondary", onClick: () => this.close_editor(), disabled: this.editor_busy === 'saving' }, "Close"), h("button", { key: '23cbe88de46ef76de09c02e54074606aec5aa3e8', type: "button", class: "btn primary", onClick: () => void this.save_editor(), disabled: !!this.editor_busy || !this.editor_is_dirty() }, this.editor_busy === 'saving' ? 'Saving...' : 'Save'))))));
1440
+ : h("button", { type: "button", class: "btn secondary", onClick: () => this.close_editor(), disabled: this.editor_busy === 'saving' }, "Close"), h("button", { key: 'b1e758ae6fd5de192135d617126c8c6939c62bde', type: "button", class: "btn primary", onClick: () => void this.save_editor(), disabled: !!this.editor_busy || !this.editor_is_dirty() }, this.editor_busy === 'saving' ? 'Saving...' : 'Save'))))));
1429
1441
  }
1430
1442
  static get is() { return "phirepass-sftp-client"; }
1431
1443
  static get encapsulation() { return "shadow"; }
@@ -1656,6 +1668,30 @@ export class PhirepassSftpClient {
1656
1668
  "setter": false,
1657
1669
  "reflect": false,
1658
1670
  "attribute": "server-id"
1671
+ },
1672
+ "channelFactory": {
1673
+ "type": "unknown",
1674
+ "mutable": false,
1675
+ "complexType": {
1676
+ "original": "ChannelFactory",
1677
+ "resolved": "(endpoint: string, nodeId: string, serverId?: string) => ChannelLike",
1678
+ "references": {
1679
+ "ChannelFactory": {
1680
+ "location": "import",
1681
+ "path": "../../common/channel",
1682
+ "id": "src/common/channel.ts::ChannelFactory",
1683
+ "referenceLocation": "ChannelFactory"
1684
+ }
1685
+ }
1686
+ },
1687
+ "required": false,
1688
+ "optional": true,
1689
+ "docs": {
1690
+ "tags": [],
1691
+ "text": "Supplies the channel instead of a WebSocket to the server \u2014 for demos,\nscreenshots and tests. A property only (a function cannot be an\nattribute); read once, when the widget connects. See `ChannelFactory`."
1692
+ },
1693
+ "getter": false,
1694
+ "setter": false
1659
1695
  }
1660
1696
  };
1661
1697
  }
@@ -176,6 +176,12 @@ export class PhirepassTerminal {
176
176
  }
177
177
  }
178
178
  serverId;
179
+ /**
180
+ * Supplies the channel instead of a WebSocket to the server — for demos,
181
+ * screenshots and tests. A property only (a function cannot be an
182
+ * attribute); read once, when the widget connects. See `ChannelFactory`.
183
+ */
184
+ channelFactory;
179
185
  onServerIdChange(_newValue, _oldValue) {
180
186
  this.onNodeIdChange(this.nodeId, this.nodeId);
181
187
  }
@@ -191,7 +197,9 @@ export class PhirepassTerminal {
191
197
  return `${protocol}://${this.serverHost}:${this.serverPort}`;
192
198
  }
193
199
  async connectedCallback() {
194
- await init();
200
+ if (!this.channelFactory) {
201
+ await init();
202
+ }
195
203
  this.setup_terminal();
196
204
  this.open_comms();
197
205
  this.runtimeReady = true;
@@ -340,11 +348,15 @@ export class PhirepassTerminal {
340
348
  }
341
349
  }
342
350
  open_comms() {
343
- if (this.serverId) {
344
- this.channel = new PhirepassChannel(`${this.create_web_socket_endpoint()}/api/web/ws`, this.nodeId, this.serverId);
351
+ const endpoint = `${this.create_web_socket_endpoint()}/api/web/ws`;
352
+ if (this.channelFactory) {
353
+ this.channel = this.channelFactory(endpoint, this.nodeId, this.serverId || undefined);
354
+ }
355
+ else if (this.serverId) {
356
+ this.channel = new PhirepassChannel(endpoint, this.nodeId, this.serverId);
345
357
  }
346
358
  else {
347
- this.channel = new PhirepassChannel(`${this.create_web_socket_endpoint()}/api/web/ws`, this.nodeId);
359
+ this.channel = new PhirepassChannel(endpoint, this.nodeId);
348
360
  }
349
361
  this.channel.on_connection_open(() => {
350
362
  this.connectionStateChanged.emit([ConnectionState.Connected]);
@@ -730,13 +742,13 @@ export class PhirepassTerminal {
730
742
  return (h("button", { key: id, type: "button", class: { key: true, armed: !!armed }, "aria-label": hint, "aria-pressed": armed === undefined ? undefined : String(armed), onPointerDown: (event) => event.preventDefault(), onMouseDown: (event) => event.preventDefault(), onClick: onPress }, label));
731
743
  }
732
744
  render() {
733
- return (h(Host, { key: 'a4e7018d85dc6ac27abfb46e199c1d2d947e57c6', class: { 'keys-on': this.keyBar === 'on', 'keys-off': this.keyBar === 'off' } }, h("div", { key: '0603c1fd65d7c70c0d48d45c4b85a7ad14c913bf', id: "ccc", ref: el => (this.containerEl = el) }), h("div", { key: '30bc8d4e31816e3c83d422133bbe9c1ced323141', class: "keys", role: "toolbar", "aria-label": "Terminal keys" }, this.key_button('ctrl', 'ctrl', 'Control', () => {
745
+ return (h(Host, { key: '4f00fba03285e6410d0248df32247f3231199cf8', class: { 'keys-on': this.keyBar === 'on', 'keys-off': this.keyBar === 'off' } }, h("div", { key: 'f43351419da2ca6ef1232afd96ea30be5feae138', id: "ccc", ref: el => (this.containerEl = el) }), h("div", { key: '56f7929c2045ae17053777b818f3317844ec6467', class: "keys", role: "toolbar", "aria-label": "Terminal keys" }, this.key_button('ctrl', 'ctrl', 'Control', () => {
734
746
  this.ctrlArmed = !this.ctrlArmed;
735
747
  this.terminal?.focus();
736
748
  }, this.ctrlArmed), this.key_button('alt', 'alt', 'Alt', () => {
737
749
  this.altArmed = !this.altArmed;
738
750
  this.terminal?.focus();
739
- }, this.altArmed), KEY_BAR_KEYS.map(entry => this.key_button(entry.id, entry.label, entry.hint, () => this.press(entry.data))), h("span", { key: '117e1718e8f4bc7451dd95222733ef3f841600db', class: "spacer" }), this.key_button('left', '←', 'Left arrow', () => this.press(this.arrow('D'))), this.key_button('down', '↓', 'Down arrow', () => this.press(this.arrow('B'))), this.key_button('up', '↑', 'Up arrow', () => this.press(this.arrow('A'))), this.key_button('right', '→', 'Right arrow', () => this.press(this.arrow('C'))))));
751
+ }, this.altArmed), KEY_BAR_KEYS.map(entry => this.key_button(entry.id, entry.label, entry.hint, () => this.press(entry.data))), h("span", { key: '6573fdb8605d4a3555589412591d921738c98abb', class: "spacer" }), this.key_button('left', '←', 'Left arrow', () => this.press(this.arrow('D'))), this.key_button('down', '↓', 'Down arrow', () => this.press(this.arrow('B'))), this.key_button('up', '↑', 'Up arrow', () => this.press(this.arrow('A'))), this.key_button('right', '→', 'Right arrow', () => this.press(this.arrow('C'))))));
740
752
  }
741
753
  static get is() { return "phirepass-terminal"; }
742
754
  static get encapsulation() { return "shadow"; }
@@ -945,6 +957,30 @@ export class PhirepassTerminal {
945
957
  "setter": false,
946
958
  "reflect": false,
947
959
  "attribute": "server-id"
960
+ },
961
+ "channelFactory": {
962
+ "type": "unknown",
963
+ "mutable": false,
964
+ "complexType": {
965
+ "original": "ChannelFactory",
966
+ "resolved": "(endpoint: string, nodeId: string, serverId?: string) => ChannelLike",
967
+ "references": {
968
+ "ChannelFactory": {
969
+ "location": "import",
970
+ "path": "../../common/channel",
971
+ "id": "src/common/channel.ts::ChannelFactory",
972
+ "referenceLocation": "ChannelFactory"
973
+ }
974
+ }
975
+ },
976
+ "required": false,
977
+ "optional": true,
978
+ "docs": {
979
+ "tags": [],
980
+ "text": "Supplies the channel instead of a WebSocket to the server \u2014 for demos,\nscreenshots and tests. A property only (a function cannot be an\nattribute); read once, when the widget connects. See `ChannelFactory`."
981
+ },
982
+ "getter": false,
983
+ "setter": false
948
984
  }
949
985
  };
950
986
  }
@@ -1 +1 @@
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();j.__wbg_channel_free(n,0)}authenticate(n,t,e){const r=N(n,j.__wbindgen_export,j.__wbindgen_export2),o=k,i=N(t,j.__wbindgen_export,j.__wbindgen_export2);j.channel_authenticate(this.__wbg_ptr,r,o,i,k,R(e)?Number.MAX_SAFE_INTEGER:e>>>0)}connect(){j.channel_connect(this.__wbg_ptr)}create_service(n,t,e,r,o,i,c,s,_){const u=N(n,j.__wbindgen_export,j.__wbindgen_export2),a=k,f=N(t,j.__wbindgen_export,j.__wbindgen_export2),b=k;var d=R(e)?0:N(e,j.__wbindgen_export,j.__wbindgen_export2),l=k;const w=N(r,j.__wbindgen_export,j.__wbindgen_export2),g=k;var h=R(i)?0:N(i,j.__wbindgen_export,j.__wbindgen_export2),p=k,m=R(c)?0:N(c,j.__wbindgen_export,j.__wbindgen_export2),y=k,v=R(s)?0:N(s,j.__wbindgen_export,j.__wbindgen_export2);j.channel_create_service(this.__wbg_ptr,u,a,f,b,d,l,w,g,o,h,p,m,y,v,k,R(_)?Number.MAX_SAFE_INTEGER:_>>>0)}delete_service(n,t,e){const r=N(n,j.__wbindgen_export,j.__wbindgen_export2),o=k,i=N(t,j.__wbindgen_export,j.__wbindgen_export2);j.channel_delete_service(this.__wbg_ptr,r,o,i,k,R(e)?Number.MAX_SAFE_INTEGER:e>>>0)}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){const r=N(n,j.__wbindgen_export,j.__wbindgen_export2),o=k,i=N(t,j.__wbindgen_export,j.__wbindgen_export2),c=k;var s=R(e)?0:N(e,j.__wbindgen_export,j.__wbindgen_export2);const u=j.channel_new(r,o,i,c,s,k);return this.__wbg_ptr=u,_.register(this,this.__wbg_ptr,this),this}on_connection_close(n){j.channel_on_connection_close(this.__wbg_ptr,R(n)?0:u(n))}on_connection_error(n){j.channel_on_connection_error(this.__wbg_ptr,R(n)?0:u(n))}on_connection_message(n){j.channel_on_connection_message(this.__wbg_ptr,R(n)?0:u(n))}on_connection_open(n){j.channel_on_connection_open(this.__wbg_ptr,R(n)?0:u(n))}on_protocol_message(n){j.channel_on_protocol_message(this.__wbg_ptr,R(n)?0:u(n))}on_protocol_message_type(n,t){const e=N(n,j.__wbindgen_export,j.__wbindgen_export2);j.channel_on_protocol_message_type(this.__wbg_ptr,e,k,R(t)?0:u(t))}open_rdp_tunnel(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(t,j.__wbindgen_export,j.__wbindgen_export2),_=k;var u=R(e)?0:N(e,j.__wbindgen_export,j.__wbindgen_export2),a=k,f=R(r)?0:N(r,j.__wbindgen_export,j.__wbindgen_export2);j.channel_open_rdp_tunnel(this.__wbg_ptr,i,c,s,_,u,a,f,k,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}open_sftp_tunnel(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(t,j.__wbindgen_export,j.__wbindgen_export2),_=k;var u=R(e)?0:N(e,j.__wbindgen_export,j.__wbindgen_export2),a=k,f=R(r)?0:N(r,j.__wbindgen_export,j.__wbindgen_export2);j.channel_open_sftp_tunnel(this.__wbg_ptr,i,c,s,_,u,a,f,k,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}open_ssh_tunnel(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(t,j.__wbindgen_export,j.__wbindgen_export2),_=k;var u=R(e)?0:N(e,j.__wbindgen_export,j.__wbindgen_export2),a=k,f=R(r)?0:N(r,j.__wbindgen_export,j.__wbindgen_export2);j.channel_open_ssh_tunnel(this.__wbg_ptr,i,c,s,_,u,a,f,k,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_sftp_chmod(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(e,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_chmod(this.__wbg_ptr,i,c,t,s,k,r,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_sftp_delete(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(e,j.__wbindgen_export,j.__wbindgen_export2),_=k,u=N(r,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_delete(this.__wbg_ptr,i,c,t,s,_,u,k,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_sftp_download_ack(n,t,e,r){const o=N(n,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_download_ack(this.__wbg_ptr,o,k,t,e,r)}send_sftp_download_chunk(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_download_chunk(this.__wbg_ptr,i,k,t,e,r,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_sftp_download_start(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(e,j.__wbindgen_export,j.__wbindgen_export2),_=k,u=N(r,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_download_start(this.__wbg_ptr,i,c,t,s,_,u,k,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_sftp_list_data(n,t,e,r){const o=N(n,j.__wbindgen_export,j.__wbindgen_export2),i=k,c=N(e,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_list_data(this.__wbg_ptr,o,i,t,c,k,R(r)?Number.MAX_SAFE_INTEGER:r>>>0)}send_sftp_mkdir(n,t,e,r){const o=N(n,j.__wbindgen_export,j.__wbindgen_export2),i=k,c=N(e,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_mkdir(this.__wbg_ptr,o,i,t,c,k,R(r)?Number.MAX_SAFE_INTEGER:r>>>0)}send_sftp_read_file(n,t,e,r){const o=N(n,j.__wbindgen_export,j.__wbindgen_export2),i=k,c=N(e,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_read_file(this.__wbg_ptr,o,i,t,c,k,R(r)?Number.MAX_SAFE_INTEGER:r>>>0)}send_sftp_remove(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(e,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_remove(this.__wbg_ptr,i,c,t,s,k,r,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_sftp_rename(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(e,j.__wbindgen_export,j.__wbindgen_export2),_=k,u=N(r,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_rename(this.__wbg_ptr,i,c,t,s,_,u,k,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_sftp_upload_chunk(n,t,e,r,o,i,c){const s=N(n,j.__wbindgen_export,j.__wbindgen_export2),_=k,u=S(i,j.__wbindgen_export);j.channel_send_sftp_upload_chunk(this.__wbg_ptr,s,_,t,e,r,o,u,k,R(c)?Number.MAX_SAFE_INTEGER:c>>>0)}send_sftp_upload_start(n,t,e,r,o,i,c){const s=N(n,j.__wbindgen_export,j.__wbindgen_export2),_=k,u=N(e,j.__wbindgen_export,j.__wbindgen_export2),a=k,f=N(r,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_upload_start(this.__wbg_ptr,s,_,t,u,a,f,k,o,i,R(c)?Number.MAX_SAFE_INTEGER:c>>>0)}send_sftp_write_file(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(e,j.__wbindgen_export,j.__wbindgen_export2),_=k,u=S(r,j.__wbindgen_export);j.channel_send_sftp_write_file(this.__wbg_ptr,i,c,t,s,_,u,k,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_ssh_terminal_resize(n,t,e,r,o,i){const c=N(n,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_ssh_terminal_resize(this.__wbg_ptr,c,k,t,e,r,o,i)}send_ssh_tunnel_data(n,t,e){const r=N(n,j.__wbindgen_export,j.__wbindgen_export2),o=k,i=N(e,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_ssh_tunnel_data(this.__wbg_ptr,r,o,t,i,k)}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,i,c,s,_,u){const a=N(n,j.__wbindgen_export,j.__wbindgen_export2),f=k,b=N(t,j.__wbindgen_export,j.__wbindgen_export2),d=k,l=N(e,j.__wbindgen_export,j.__wbindgen_export2),w=k;var g=R(r)?0:N(r,j.__wbindgen_export,j.__wbindgen_export2),h=k;const p=N(o,j.__wbindgen_export,j.__wbindgen_export2),m=k;var y=R(c)?0:N(c,j.__wbindgen_export,j.__wbindgen_export2),v=k,A=R(s)?0:N(s,j.__wbindgen_export,j.__wbindgen_export2),S=k,T=R(_)?0:N(_,j.__wbindgen_export,j.__wbindgen_export2);j.channel_update_service(this.__wbg_ptr,a,f,b,d,l,w,g,h,p,m,i,y,v,A,S,T,k,R(u)?Number.MAX_SAFE_INTEGER:u>>>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_30c8987f7c2ed4e2:function(n,t){return u(Error(w(n,t)))},__wbg_String_8564e559799eccda:function(n,t){const e=N(String(p(t)),j.__wbindgen_export,j.__wbindgen_export2),r=k;l().setInt32(n+4,r,!0),l().setInt32(n+0,e,!0)},__wbg___wbindgen_debug_string_4687d8d8c2017d52:function(n,t){const e=N(f(p(t)),j.__wbindgen_export,j.__wbindgen_export2),r=k;l().setInt32(n+4,r,!0),l().setInt32(n+0,e,!0)},__wbg___wbindgen_string_get_0380ccaa2f57f0d9:function(n,t){const e=p(t),r="string"==typeof e?e:void 0;var o=R(r)?0:N(r,j.__wbindgen_export,j.__wbindgen_export2),i=k;l().setInt32(n+4,i,!0),l().setInt32(n+0,o,!0)},__wbg___wbindgen_throw_41e9ee4f547fc59a:function(n,t){throw new Error(w(n,t))},__wbg__wbg_cb_unref_dcc1a90847f04c41:function(n){p(n)._wbg_cb_unref()},__wbg_call_1875a20c43a36133:function(){return m((function(n,t,e,r){return u(p(n).call(p(t),p(e),p(r)))}),arguments)},__wbg_call_187d372bd5fdd4aa:function(){return m((function(n,t,e){return u(p(n).call(p(t),p(e)))}),arguments)},__wbg_call_6137034ef55c9d0f:function(){return m((function(n,t){return u(p(n).call(p(t)))}),arguments)},__wbg_clearInterval_26ba580547547579:function(n){return u(clearInterval(T(n)))},__wbg_close_d3ed56b5763be5ae:function(){return m((function(n){p(n).close()}),arguments)},__wbg_data_522f7abc70721269:function(n){return u(p(n).data)},__wbg_from_296ca31f8d0f1c52:function(n){return u(Array.from(p(n)))},__wbg_getRandomValues_a608c4436c19407a:function(){return m((function(n,t){globalThis.crypto.getRandomValues(b(n,t))}),arguments)},__wbg_get_31af05bd4842a84f:function(){return m((function(n,t){return u(Reflect.get(p(n),p(t)))}),arguments)},__wbg_info_c2e816d395f9b883:function(n,t){console.info(w(n,t))},__wbg_instanceof_ArrayBuffer_a99f175873e5d9b8:function(n){let t;try{t=p(n)instanceof ArrayBuffer}catch(n){t=!1}return t},__wbg_length_7f3c00c40364105e:function(n){return p(n).length},__wbg_new_1dbf7428bba60a42:function(n){return u(new Uint8Array(p(n)))},__wbg_new_617a8cdb8bb1130e:function(){return u(new Object)},__wbg_new_ee2291f50781bf1d:function(){return u(new Array)},__wbg_new_with_str_sequence_f79e461d58fdeacc:function(){return m((function(n,t,e){return u(new WebSocket(w(n,t),p(e)))}),arguments)},__wbg_prototypesetcall_bc27214492979395:function(n,t,e){Uint8Array.prototype.set.call(b(n,t),p(e))},__wbg_push_2baf45db356cf468:function(n,t){return p(n).push(p(t))},__wbg_readyState_d8514376867e415b:function(n){return p(n).readyState},__wbg_send_c1dad0ec2e52defb:function(){return m((function(n,t,e){p(n).send(b(t,e))}),arguments)},__wbg_setInterval_cbf1c35c6a692d37:function(){return m((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_bea140a88be9b277:function(n,t,e){p(n)[t>>>0]=T(e)},__wbg_set_binaryType_21835bf0df8f70aa:function(n,t){p(n).binaryType=s[t]},__wbg_set_onclose_a84370531f3d2948:function(n,t){p(n).onclose=p(t)},__wbg_set_onerror_94ee307653399172:function(n,t){p(n).onerror=p(t)},__wbg_set_onmessage_cb6f77d2d8e0402a:function(n,t){p(n).onmessage=p(t)},__wbg_set_onopen_c914147e8a2db4b0:function(n,t){p(n).onopen=p(t)},__wbg_warn_ce1d5c8a41cfe303:function(n,t){console.warn(w(n,t))},__wbindgen_generic_0000000000000001:function(n,t){return u(A(n,t,o))},__wbindgen_generic_0000000000000002:function(n,t){return u(A(n,t,i))},__wbindgen_generic_0000000000000003:function(n,t){return u(A(n,t,c))},__wbindgen_generic_0000000000000004:function(n,t){return u(A(n,t,r))},__wbindgen_generic_0000000000000005:function(n){return u(n)},__wbindgen_generic_0000000000000006:function(n,t){return u(b(n,t))},__wbindgen_generic_0000000000000007:function(n,t){return u(w(n,t))},__wbindgen_generic_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){j.__wasm_bindgen_func_elem_64(n,t)}function o(n,t,e){j.__wasm_bindgen_func_elem_60(n,t,u(e))}function i(n,t,e){j.__wasm_bindgen_func_elem_60_37(n,t,u(e))}function c(n,t,e){j.__wasm_bindgen_func_elem_60_38(n,t,u(e))}const s=["blob","arraybuffer"],_="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((n=>j.__wbg_channel_free(n,1)));function u(n){v===y.length&&y.push(y.length+1);const t=v;return v=y[t],y[t]=n,t}const a="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((n=>j.__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 d=null;function l(){return(null===d||!0===d.buffer.detached||void 0===d.buffer.detached&&d.buffer!==j.memory.buffer)&&(d=new DataView(j.memory.buffer)),d}function w(n,t){return function(n,t){return P+=t,P>=O&&(F=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),F.decode(),P=t),F.decode(h().subarray(n,n+t))}(n>>>0,t)}let g=null;function h(){return null!==g&&0!==g.byteLength||(g=new Uint8Array(j.memory.buffer)),g}function p(n){return y[n]}function m(n,t){try{return n.apply(this,t)}catch(n){j.__wbindgen_export3(u(n))}}let y=new Array(1024).fill(void 0);y.push(void 0,null,!0,!1);let v=y.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&&(j.__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=U.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 i=h();let c=0;for(;c<r;c++){const t=n.charCodeAt(c);if(t>127)break;i[o+c]=t}if(c!==r){0!==c&&(n=n.slice(c)),o=e(o,r,r=c+3*n.length,1)>>>0;const t=h().subarray(o+c,o+r);c+=U.encodeInto(n,t).written,o=e(o,r,c,1)>>>0}return k=c,o}function T(n){const t=p(n);return function(n){n<1028||(y[n]=v,v=n)}(n),t}let F=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});F.decode();const O=2146435072;let P=0;const U=new TextEncoder;"encodeInto"in U||(U.encodeInto=function(n,t){const e=U.encode(n);return t.set(e),{read:n.length,written:e.length}});let j,k=0;async function W(n){if(void 0!==j)return j;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(!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,d=null,g=null,j}(r)}var $,q,E;!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"}($||($={})),function(n){n[n.Username=0]="Username",n[n.Password=1]="Password",n[n.Default=2]="Default"}(q||(q={})),function(n){n.Disconnected="disconnected",n.Connected="connected",n.Error="error"}(E||(E={}));export{n as C,t as E,q as I,$ as P,W as _,E as a}
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();j.__wbg_channel_free(n,0)}authenticate(n,t,e){const r=N(n,j.__wbindgen_export,j.__wbindgen_export2),o=k,i=N(t,j.__wbindgen_export,j.__wbindgen_export2);j.channel_authenticate(this.__wbg_ptr,r,o,i,k,R(e)?Number.MAX_SAFE_INTEGER:e>>>0)}connect(){j.channel_connect(this.__wbg_ptr)}create_service(n,t,e,r,o,i,c,s,_){const u=N(n,j.__wbindgen_export,j.__wbindgen_export2),a=k,f=N(t,j.__wbindgen_export,j.__wbindgen_export2),b=k;var d=R(e)?0:N(e,j.__wbindgen_export,j.__wbindgen_export2),l=k;const w=N(r,j.__wbindgen_export,j.__wbindgen_export2),g=k;var h=R(i)?0:N(i,j.__wbindgen_export,j.__wbindgen_export2),p=k,m=R(c)?0:N(c,j.__wbindgen_export,j.__wbindgen_export2),y=k,v=R(s)?0:N(s,j.__wbindgen_export,j.__wbindgen_export2);j.channel_create_service(this.__wbg_ptr,u,a,f,b,d,l,w,g,o,h,p,m,y,v,k,R(_)?Number.MAX_SAFE_INTEGER:_>>>0)}delete_service(n,t,e){const r=N(n,j.__wbindgen_export,j.__wbindgen_export2),o=k,i=N(t,j.__wbindgen_export,j.__wbindgen_export2);j.channel_delete_service(this.__wbg_ptr,r,o,i,k,R(e)?Number.MAX_SAFE_INTEGER:e>>>0)}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){const r=N(n,j.__wbindgen_export,j.__wbindgen_export2),o=k,i=N(t,j.__wbindgen_export,j.__wbindgen_export2),c=k;var s=R(e)?0:N(e,j.__wbindgen_export,j.__wbindgen_export2);const u=j.channel_new(r,o,i,c,s,k);return this.__wbg_ptr=u,_.register(this,this.__wbg_ptr,this),this}on_connection_close(n){j.channel_on_connection_close(this.__wbg_ptr,R(n)?0:u(n))}on_connection_error(n){j.channel_on_connection_error(this.__wbg_ptr,R(n)?0:u(n))}on_connection_message(n){j.channel_on_connection_message(this.__wbg_ptr,R(n)?0:u(n))}on_connection_open(n){j.channel_on_connection_open(this.__wbg_ptr,R(n)?0:u(n))}on_protocol_message(n){j.channel_on_protocol_message(this.__wbg_ptr,R(n)?0:u(n))}on_protocol_message_type(n,t){const e=N(n,j.__wbindgen_export,j.__wbindgen_export2);j.channel_on_protocol_message_type(this.__wbg_ptr,e,k,R(t)?0:u(t))}open_rdp_tunnel(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(t,j.__wbindgen_export,j.__wbindgen_export2),_=k;var u=R(e)?0:N(e,j.__wbindgen_export,j.__wbindgen_export2),a=k,f=R(r)?0:N(r,j.__wbindgen_export,j.__wbindgen_export2);j.channel_open_rdp_tunnel(this.__wbg_ptr,i,c,s,_,u,a,f,k,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}open_sftp_tunnel(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(t,j.__wbindgen_export,j.__wbindgen_export2),_=k;var u=R(e)?0:N(e,j.__wbindgen_export,j.__wbindgen_export2),a=k,f=R(r)?0:N(r,j.__wbindgen_export,j.__wbindgen_export2);j.channel_open_sftp_tunnel(this.__wbg_ptr,i,c,s,_,u,a,f,k,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}open_ssh_tunnel(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(t,j.__wbindgen_export,j.__wbindgen_export2),_=k;var u=R(e)?0:N(e,j.__wbindgen_export,j.__wbindgen_export2),a=k,f=R(r)?0:N(r,j.__wbindgen_export,j.__wbindgen_export2);j.channel_open_ssh_tunnel(this.__wbg_ptr,i,c,s,_,u,a,f,k,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_sftp_chmod(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(e,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_chmod(this.__wbg_ptr,i,c,t,s,k,r,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_sftp_delete(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(e,j.__wbindgen_export,j.__wbindgen_export2),_=k,u=N(r,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_delete(this.__wbg_ptr,i,c,t,s,_,u,k,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_sftp_download_ack(n,t,e,r){const o=N(n,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_download_ack(this.__wbg_ptr,o,k,t,e,r)}send_sftp_download_chunk(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_download_chunk(this.__wbg_ptr,i,k,t,e,r,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_sftp_download_start(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(e,j.__wbindgen_export,j.__wbindgen_export2),_=k,u=N(r,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_download_start(this.__wbg_ptr,i,c,t,s,_,u,k,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_sftp_list_data(n,t,e,r){const o=N(n,j.__wbindgen_export,j.__wbindgen_export2),i=k,c=N(e,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_list_data(this.__wbg_ptr,o,i,t,c,k,R(r)?Number.MAX_SAFE_INTEGER:r>>>0)}send_sftp_mkdir(n,t,e,r){const o=N(n,j.__wbindgen_export,j.__wbindgen_export2),i=k,c=N(e,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_mkdir(this.__wbg_ptr,o,i,t,c,k,R(r)?Number.MAX_SAFE_INTEGER:r>>>0)}send_sftp_read_file(n,t,e,r){const o=N(n,j.__wbindgen_export,j.__wbindgen_export2),i=k,c=N(e,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_read_file(this.__wbg_ptr,o,i,t,c,k,R(r)?Number.MAX_SAFE_INTEGER:r>>>0)}send_sftp_remove(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(e,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_remove(this.__wbg_ptr,i,c,t,s,k,r,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_sftp_rename(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(e,j.__wbindgen_export,j.__wbindgen_export2),_=k,u=N(r,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_rename(this.__wbg_ptr,i,c,t,s,_,u,k,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_sftp_upload_chunk(n,t,e,r,o,i,c){const s=N(n,j.__wbindgen_export,j.__wbindgen_export2),_=k,u=S(i,j.__wbindgen_export);j.channel_send_sftp_upload_chunk(this.__wbg_ptr,s,_,t,e,r,o,u,k,R(c)?Number.MAX_SAFE_INTEGER:c>>>0)}send_sftp_upload_start(n,t,e,r,o,i,c){const s=N(n,j.__wbindgen_export,j.__wbindgen_export2),_=k,u=N(e,j.__wbindgen_export,j.__wbindgen_export2),a=k,f=N(r,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_sftp_upload_start(this.__wbg_ptr,s,_,t,u,a,f,k,o,i,R(c)?Number.MAX_SAFE_INTEGER:c>>>0)}send_sftp_write_file(n,t,e,r,o){const i=N(n,j.__wbindgen_export,j.__wbindgen_export2),c=k,s=N(e,j.__wbindgen_export,j.__wbindgen_export2),_=k,u=S(r,j.__wbindgen_export);j.channel_send_sftp_write_file(this.__wbg_ptr,i,c,t,s,_,u,k,R(o)?Number.MAX_SAFE_INTEGER:o>>>0)}send_ssh_terminal_resize(n,t,e,r,o,i){const c=N(n,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_ssh_terminal_resize(this.__wbg_ptr,c,k,t,e,r,o,i)}send_ssh_tunnel_data(n,t,e){const r=N(n,j.__wbindgen_export,j.__wbindgen_export2),o=k,i=N(e,j.__wbindgen_export,j.__wbindgen_export2);j.channel_send_ssh_tunnel_data(this.__wbg_ptr,r,o,t,i,k)}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,i,c,s,_,u){const a=N(n,j.__wbindgen_export,j.__wbindgen_export2),f=k,b=N(t,j.__wbindgen_export,j.__wbindgen_export2),d=k,l=N(e,j.__wbindgen_export,j.__wbindgen_export2),w=k;var g=R(r)?0:N(r,j.__wbindgen_export,j.__wbindgen_export2),h=k;const p=N(o,j.__wbindgen_export,j.__wbindgen_export2),m=k;var y=R(c)?0:N(c,j.__wbindgen_export,j.__wbindgen_export2),v=k,A=R(s)?0:N(s,j.__wbindgen_export,j.__wbindgen_export2),S=k,T=R(_)?0:N(_,j.__wbindgen_export,j.__wbindgen_export2);j.channel_update_service(this.__wbg_ptr,a,f,b,d,l,w,g,h,p,m,i,y,v,A,S,T,k,R(u)?Number.MAX_SAFE_INTEGER:u>>>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_30c8987f7c2ed4e2:function(n,t){return u(Error(w(n,t)))},__wbg_String_8564e559799eccda:function(n,t){const e=N(String(p(t)),j.__wbindgen_export,j.__wbindgen_export2),r=k;l().setInt32(n+4,r,!0),l().setInt32(n+0,e,!0)},__wbg___wbindgen_debug_string_4687d8d8c2017d52:function(n,t){const e=N(f(p(t)),j.__wbindgen_export,j.__wbindgen_export2),r=k;l().setInt32(n+4,r,!0),l().setInt32(n+0,e,!0)},__wbg___wbindgen_string_get_0380ccaa2f57f0d9:function(n,t){const e=p(t),r="string"==typeof e?e:void 0;var o=R(r)?0:N(r,j.__wbindgen_export,j.__wbindgen_export2),i=k;l().setInt32(n+4,i,!0),l().setInt32(n+0,o,!0)},__wbg___wbindgen_throw_41e9ee4f547fc59a:function(n,t){throw new Error(w(n,t))},__wbg__wbg_cb_unref_dcc1a90847f04c41:function(n){p(n)._wbg_cb_unref()},__wbg_call_1875a20c43a36133:function(){return m((function(n,t,e,r){return u(p(n).call(p(t),p(e),p(r)))}),arguments)},__wbg_call_187d372bd5fdd4aa:function(){return m((function(n,t,e){return u(p(n).call(p(t),p(e)))}),arguments)},__wbg_call_6137034ef55c9d0f:function(){return m((function(n,t){return u(p(n).call(p(t)))}),arguments)},__wbg_clearInterval_26ba580547547579:function(n){return u(clearInterval(T(n)))},__wbg_close_d3ed56b5763be5ae:function(){return m((function(n){p(n).close()}),arguments)},__wbg_data_522f7abc70721269:function(n){return u(p(n).data)},__wbg_from_296ca31f8d0f1c52:function(n){return u(Array.from(p(n)))},__wbg_getRandomValues_a608c4436c19407a:function(){return m((function(n,t){globalThis.crypto.getRandomValues(b(n,t))}),arguments)},__wbg_get_31af05bd4842a84f:function(){return m((function(n,t){return u(Reflect.get(p(n),p(t)))}),arguments)},__wbg_info_930469ca0112784b:function(n,t){console.info(w(n,t))},__wbg_instanceof_ArrayBuffer_a99f175873e5d9b8:function(n){let t;try{t=p(n)instanceof ArrayBuffer}catch(n){t=!1}return t},__wbg_length_7f3c00c40364105e:function(n){return p(n).length},__wbg_new_1dbf7428bba60a42:function(n){return u(new Uint8Array(p(n)))},__wbg_new_617a8cdb8bb1130e:function(){return u(new Object)},__wbg_new_ee2291f50781bf1d:function(){return u(new Array)},__wbg_new_with_str_sequence_f79e461d58fdeacc:function(){return m((function(n,t,e){return u(new WebSocket(w(n,t),p(e)))}),arguments)},__wbg_prototypesetcall_bc27214492979395:function(n,t,e){Uint8Array.prototype.set.call(b(n,t),p(e))},__wbg_push_2baf45db356cf468:function(n,t){return p(n).push(p(t))},__wbg_readyState_d8514376867e415b:function(n){return p(n).readyState},__wbg_send_c1dad0ec2e52defb:function(){return m((function(n,t,e){p(n).send(b(t,e))}),arguments)},__wbg_setInterval_cbf1c35c6a692d37:function(){return m((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_bea140a88be9b277:function(n,t,e){p(n)[t>>>0]=T(e)},__wbg_set_binaryType_21835bf0df8f70aa:function(n,t){p(n).binaryType=s[t]},__wbg_set_onclose_a84370531f3d2948:function(n,t){p(n).onclose=p(t)},__wbg_set_onerror_94ee307653399172:function(n,t){p(n).onerror=p(t)},__wbg_set_onmessage_cb6f77d2d8e0402a:function(n,t){p(n).onmessage=p(t)},__wbg_set_onopen_c914147e8a2db4b0:function(n,t){p(n).onopen=p(t)},__wbg_warn_018ad7405d6ad231:function(n,t){console.warn(w(n,t))},__wbindgen_generic_0000000000000001:function(n,t){return u(A(n,t,o))},__wbindgen_generic_0000000000000002:function(n,t){return u(A(n,t,i))},__wbindgen_generic_0000000000000003:function(n,t){return u(A(n,t,c))},__wbindgen_generic_0000000000000004:function(n,t){return u(A(n,t,r))},__wbindgen_generic_0000000000000005:function(n){return u(n)},__wbindgen_generic_0000000000000006:function(n,t){return u(b(n,t))},__wbindgen_generic_0000000000000007:function(n,t){return u(w(n,t))},__wbindgen_generic_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){j.__wasm_bindgen_func_elem_64(n,t)}function o(n,t,e){j.__wasm_bindgen_func_elem_60(n,t,u(e))}function i(n,t,e){j.__wasm_bindgen_func_elem_60_37(n,t,u(e))}function c(n,t,e){j.__wasm_bindgen_func_elem_60_38(n,t,u(e))}const s=["blob","arraybuffer"],_="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((n=>j.__wbg_channel_free(n,1)));function u(n){v===y.length&&y.push(y.length+1);const t=v;return v=y[t],y[t]=n,t}const a="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((n=>j.__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 d=null;function l(){return(null===d||!0===d.buffer.detached||void 0===d.buffer.detached&&d.buffer!==j.memory.buffer)&&(d=new DataView(j.memory.buffer)),d}function w(n,t){return function(n,t){return P+=t,P>=O&&(F=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),F.decode(),P=t),F.decode(h().subarray(n,n+t))}(n>>>0,t)}let g=null;function h(){return null!==g&&0!==g.byteLength||(g=new Uint8Array(j.memory.buffer)),g}function p(n){return y[n]}function m(n,t){try{return n.apply(this,t)}catch(n){j.__wbindgen_export3(u(n))}}let y=new Array(1024).fill(void 0);y.push(void 0,null,!0,!1);let v=y.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&&(j.__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=U.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 i=h();let c=0;for(;c<r;c++){const t=n.charCodeAt(c);if(t>127)break;i[o+c]=t}if(c!==r){0!==c&&(n=n.slice(c)),o=e(o,r,r=c+3*n.length,1)>>>0;const t=h().subarray(o+c,o+r);c+=U.encodeInto(n,t).written,o=e(o,r,c,1)>>>0}return k=c,o}function T(n){const t=p(n);return function(n){n<1028||(y[n]=v,v=n)}(n),t}let F=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});F.decode();const O=2146435072;let P=0;const U=new TextEncoder;"encodeInto"in U||(U.encodeInto=function(n,t){const e=U.encode(n);return t.set(e),{read:n.length,written:e.length}});let j,k=0;async function W(n){if(void 0!==j)return j;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(!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,d=null,g=null,j}(r)}var $,q,E;!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"}($||($={})),function(n){n[n.Username=0]="Username",n[n.Password=1]="Password",n[n.Default=2]="Default"}(q||(q={})),function(n){n.Disconnected="disconnected",n.Connected="connected",n.Error="error"}(E||(E={}));export{n as C,t as E,q as I,$ as P,W as _,E as a}
@@ -1 +1 @@
1
- import{t,p as e,H as s,c as i,h as o,a as n}from"./index.js";import{_ as r,C as h,a,P as c}from"./p-D4JeTIHt.js";const d=200;function u(t){return!Number.isFinite(t)||t<=0?d:Math.min(8192,Math.max(d,Math.floor(t)))}function l(t){return t-t%2}function p(t){const e=t.getBoundingClientRect();return function(t,e){return{width:l(u(t)),height:l(u(e))}}(e.width,e.height)}class m{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(p(t)),"undefined"!=typeof ResizeObserver&&(this.observer=new ResizeObserver((()=>{clearTimeout(this.handle),this.handle=setTimeout((()=>this.report(p(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){(function(t,e){return!!t&&!!e&&t.width===e.width&&t.height===e.height})(t,this.reported)||(this.reported=t,this.onResize(t))}}function f(){return navigator.keyboard}function b(){return"function"==typeof f()?.lock}function y(t){return document.fullscreenElement===t}function w(t){return document.fullscreenElement?.contains(t)??!1}function g(){if(b())try{f().unlock()}catch(t){console.warn("Failed to release the keyboard lock:",t)}}const v=e(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.connectionStateChanged=i(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 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;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,await r(),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 y(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),y(t)}}(this.el);return this.focus_desktop(),t}async keyboardLockSupported(){return b()}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.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_client()})),this.channel.on_connection_error((t=>{this.connectionStateChanged.emit([a.Error,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.RDPAuthorized:this.handle_rdp_authorized(e);break;case c.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<d||e.height<d))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([a.Error,t])}}start_viewport_sync(t){this.dynamicResize&&(this.viewport=new m((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(){!function(t){t?.focus({preventScroll:!0})}(this.ironEl)}async sync_keyboard_lock(){this.captureKeyboard&&w(this.el)?(await async function(t){if(b()&&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()):g()}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([a.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(),g(),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 o(n,{key:"56354df7bd0d3f01fcd5ff65ca5618ceb6af1b91"},o("div",{key:"446dc83e41a29c3bc2c341a26092ed3581565967",class:"screen",ref:t=>this.containerEl=t},o("slot",{key:"2beafc92d81662dfac5c7b41356f6c6c802643b9"})),this.credentialsPrompt&&o("form",{key:"dcc29b21fba03bb97526ec3d1cf5a1fb51b483e9",class:"prompt",onSubmit:t=>this.submit_credentials(t)},o("label",{key:"b5a3e302089b2282aedbdbefd4fb5eaca7c34455",htmlFor:"rdp-username"},"Username"),o("input",{key:"3bd1c902a6bc41bc7e69c16258cac78035a949bd",id:"rdp-username",type:"text",autocomplete:"off",autofocus:!0,onInput:t=>this.usernameBuffer=t.target.value}),o("label",{key:"2defe12d73b609cbad27c06447c3c3221ff3e5aa",htmlFor:"rdp-password"},"Password"),o("input",{key:"55935891f24f0c1db71a14c42b2fc7a96c0c0ba6",id:"rdp-password",type:"password",autocomplete:"off",onInput:t=>this.passwordBuffer=t.target.value}),o("button",{key:"83439c0e8756001c7042fc3b6754889d62a8eada",type:"submit"},"Connect")),this.statusMessage&&!this.credentialsPrompt&&o("div",{key:"294262625f44a3f45d54bcd492875a9b6fd03219",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;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))}}'}},[769,"phirepass-rdp",{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],username:[1],password:[1],destination:[1],scale:[1],dynamicResize:[4,"dynamic-resize"],captureKeyboard:[4,"capture-keyboard"],clipboard:[4],serverId:[1,"server-id"],credentialsPrompt:[32],statusMessage:[32],toggleFullscreen:[64],keyboardLockSupported:[64],focusDesktop:[64],sendCtrlAltDel:[64],sendMetaKey:[64]},void 0,{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}]);function k(){"undefined"!=typeof customElements&&["phirepass-rdp"].forEach((e=>{"phirepass-rdp"===e&&(customElements.get(t(e))||customElements.define(t(e),v))}))}k();const _=v,I=k;export{_ as PhirepassRdp,I as defineCustomElement}
1
+ import{t,p as e,H as s,c as i,h as o,a as n}from"./index.js";import{_ as r,C as h,a,P as c}from"./p-Dur4cBX7.js";const d=200;function u(t){return!Number.isFinite(t)||t<=0?d:Math.min(8192,Math.max(d,Math.floor(t)))}function l(t){return t-t%2}function p(t){const e=t.getBoundingClientRect();return function(t,e){return{width:l(u(t)),height:l(u(e))}}(e.width,e.height)}class m{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(p(t)),"undefined"!=typeof ResizeObserver&&(this.observer=new ResizeObserver((()=>{clearTimeout(this.handle),this.handle=setTimeout((()=>this.report(p(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){(function(t,e){return!!t&&!!e&&t.width===e.width&&t.height===e.height})(t,this.reported)||(this.reported=t,this.onResize(t))}}function f(){return navigator.keyboard}function b(){return"function"==typeof f()?.lock}function y(t){return document.fullscreenElement===t}function w(t){return document.fullscreenElement?.contains(t)??!1}function g(){if(b())try{f().unlock()}catch(t){console.warn("Failed to release the keyboard lock:",t)}}const v=e(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.connectionStateChanged=i(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 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;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,await r(),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 y(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),y(t)}}(this.el);return this.focus_desktop(),t}async keyboardLockSupported(){return b()}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.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_client()})),this.channel.on_connection_error((t=>{this.connectionStateChanged.emit([a.Error,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.RDPAuthorized:this.handle_rdp_authorized(e);break;case c.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<d||e.height<d))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([a.Error,t])}}start_viewport_sync(t){this.dynamicResize&&(this.viewport=new m((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(){!function(t){t?.focus({preventScroll:!0})}(this.ironEl)}async sync_keyboard_lock(){this.captureKeyboard&&w(this.el)?(await async function(t){if(b()&&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()):g()}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([a.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(),g(),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 o(n,{key:"56354df7bd0d3f01fcd5ff65ca5618ceb6af1b91"},o("div",{key:"446dc83e41a29c3bc2c341a26092ed3581565967",class:"screen",ref:t=>this.containerEl=t},o("slot",{key:"2beafc92d81662dfac5c7b41356f6c6c802643b9"})),this.credentialsPrompt&&o("form",{key:"dcc29b21fba03bb97526ec3d1cf5a1fb51b483e9",class:"prompt",onSubmit:t=>this.submit_credentials(t)},o("label",{key:"b5a3e302089b2282aedbdbefd4fb5eaca7c34455",htmlFor:"rdp-username"},"Username"),o("input",{key:"3bd1c902a6bc41bc7e69c16258cac78035a949bd",id:"rdp-username",type:"text",autocomplete:"off",autofocus:!0,onInput:t=>this.usernameBuffer=t.target.value}),o("label",{key:"2defe12d73b609cbad27c06447c3c3221ff3e5aa",htmlFor:"rdp-password"},"Password"),o("input",{key:"55935891f24f0c1db71a14c42b2fc7a96c0c0ba6",id:"rdp-password",type:"password",autocomplete:"off",onInput:t=>this.passwordBuffer=t.target.value}),o("button",{key:"83439c0e8756001c7042fc3b6754889d62a8eada",type:"submit"},"Connect")),this.statusMessage&&!this.credentialsPrompt&&o("div",{key:"294262625f44a3f45d54bcd492875a9b6fd03219",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;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))}}'}},[769,"phirepass-rdp",{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],username:[1],password:[1],destination:[1],scale:[1],dynamicResize:[4,"dynamic-resize"],captureKeyboard:[4,"capture-keyboard"],clipboard:[4],serverId:[1,"server-id"],credentialsPrompt:[32],statusMessage:[32],toggleFullscreen:[64],keyboardLockSupported:[64],focusDesktop:[64],sendCtrlAltDel:[64],sendMetaKey:[64]},void 0,{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}]);function k(){"undefined"!=typeof customElements&&["phirepass-rdp"].forEach((e=>{"phirepass-rdp"===e&&(customElements.get(t(e))||customElements.define(t(e),v))}))}k();const _=v,I=k;export{_ as PhirepassRdp,I as defineCustomElement}