phirepass-widgets 0.0.116 → 0.0.118

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 (88) hide show
  1. package/README.md +10 -20
  2. package/dist/cjs/{index-BCgmMoIq.js → index-C3v5xmUo.js} +3 -75
  3. package/dist/cjs/loader.cjs.js +2 -2
  4. package/dist/cjs/phirepass-rdp.cjs.entry.js +5 -16
  5. package/dist/cjs/phirepass-sftp-client.cjs.entry.js +1470 -0
  6. package/dist/cjs/phirepass-terminal.cjs.entry.js +4 -4
  7. package/dist/cjs/phirepass-widgets.cjs.js +3 -3
  8. package/dist/cjs/{protocol-BjOgJZ9-.js → protocol-DCBMfc2u.js} +21 -277
  9. package/dist/collection/collection-manifest.json +1 -3
  10. package/dist/collection/common/channel.js +1 -21
  11. package/dist/collection/components/phirepass-rdp/phirepass-rdp.js +13 -36
  12. package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.css +0 -122
  13. package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.js +31 -181
  14. package/dist/collection/components/phirepass-terminal/phirepass-terminal.js +2 -2
  15. package/dist/collection/phirepass-channel_bg.wasm +0 -0
  16. package/dist/components/index.js +1 -1
  17. package/dist/components/p-CsYQJXY2.js +1 -0
  18. package/dist/components/phirepass-rdp.js +1 -1
  19. package/dist/components/phirepass-sftp-client.js +1 -1
  20. package/dist/components/phirepass-terminal.js +5 -5
  21. package/dist/esm/{index-Dd9o0CbU.js → index-BVOulYtW.js} +3 -75
  22. package/dist/esm/loader.js +3 -3
  23. package/dist/esm/phirepass-rdp.entry.js +5 -16
  24. package/dist/esm/phirepass-sftp-client.entry.js +1468 -0
  25. package/dist/esm/phirepass-terminal.entry.js +4 -4
  26. package/dist/esm/phirepass-widgets.js +4 -4
  27. package/dist/esm/{protocol-BekUePpu.js → protocol-CsYQJXY2.js} +20 -276
  28. package/dist/phirepass-widgets/{p-c28a9257.entry.js → p-7ea2fdbc.entry.js} +2 -2
  29. package/dist/phirepass-widgets/p-BVOulYtW.js +3 -0
  30. package/dist/phirepass-widgets/p-CsYQJXY2.js +1 -0
  31. package/dist/phirepass-widgets/p-c1c616ca.entry.js +1 -0
  32. package/dist/phirepass-widgets/p-f1bc04a8.entry.js +1 -0
  33. package/dist/phirepass-widgets/phirepass-channel_bg.wasm +0 -0
  34. package/dist/phirepass-widgets/phirepass-widgets.esm.js +1 -1
  35. package/dist/types/common/channel.d.ts +0 -30
  36. package/dist/types/components/phirepass-rdp/phirepass-rdp.d.ts +0 -10
  37. package/dist/types/components/phirepass-sftp-client/phirepass-sftp-client.d.ts +0 -30
  38. package/dist/types/components.d.ts +34 -434
  39. package/package.json +5 -19
  40. package/dist/cjs/phirepass-downloader_3.cjs.entry.js +0 -3812
  41. package/dist/collection/common/fetch.js +0 -44
  42. package/dist/collection/components/phirepass-downloader/form.js +0 -69
  43. package/dist/collection/components/phirepass-downloader/format.js +0 -105
  44. package/dist/collection/components/phirepass-downloader/jobs.js +0 -393
  45. package/dist/collection/components/phirepass-downloader/phirepass-downloader.css +0 -1109
  46. package/dist/collection/components/phirepass-downloader/phirepass-downloader.js +0 -1455
  47. package/dist/collection/components/phirepass-downloader/source.js +0 -120
  48. package/dist/collection/components/phirepass-downloader/views/dialogs.js +0 -34
  49. package/dist/collection/components/phirepass-downloader/views/fetch-form.js +0 -65
  50. package/dist/collection/components/phirepass-downloader/views/icons.js +0 -34
  51. package/dist/collection/components/phirepass-downloader/views/job-row.js +0 -91
  52. package/dist/collection/components/phirepass-downloader/views/notices.js +0 -15
  53. package/dist/collection/components/phirepass-downloader/views/states.js +0 -19
  54. package/dist/collection/components/phirepass-media-player/phirepass-media-player.css +0 -225
  55. package/dist/collection/components/phirepass-media-player/phirepass-media-player.js +0 -549
  56. package/dist/collection/components/phirepass-media-player/player.js +0 -118
  57. package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.fetch.js +0 -35
  58. package/dist/collection/testing/fixtures.js +0 -219
  59. package/dist/collection/testing/mock-channel.js +0 -410
  60. package/dist/components/p-5QoAejYG.js +0 -1
  61. package/dist/components/p-BekUePpu.js +0 -1
  62. package/dist/components/p-DIf-Ru26.js +0 -1
  63. package/dist/components/phirepass-downloader.d.ts +0 -11
  64. package/dist/components/phirepass-downloader.js +0 -1
  65. package/dist/components/phirepass-media-player.d.ts +0 -11
  66. package/dist/components/phirepass-media-player.js +0 -1
  67. package/dist/esm/phirepass-downloader_3.entry.js +0 -3808
  68. package/dist/phirepass-widgets/p-70a67e4d.entry.js +0 -1
  69. package/dist/phirepass-widgets/p-BekUePpu.js +0 -1
  70. package/dist/phirepass-widgets/p-Dd9o0CbU.js +0 -3
  71. package/dist/phirepass-widgets/p-ab33f71f.entry.js +0 -1
  72. package/dist/types/common/fetch.d.ts +0 -167
  73. package/dist/types/components/phirepass-downloader/form.d.ts +0 -54
  74. package/dist/types/components/phirepass-downloader/format.d.ts +0 -17
  75. package/dist/types/components/phirepass-downloader/jobs.d.ts +0 -123
  76. package/dist/types/components/phirepass-downloader/phirepass-downloader.d.ts +0 -231
  77. package/dist/types/components/phirepass-downloader/source.d.ts +0 -61
  78. package/dist/types/components/phirepass-downloader/views/dialogs.d.ts +0 -52
  79. package/dist/types/components/phirepass-downloader/views/fetch-form.d.ts +0 -31
  80. package/dist/types/components/phirepass-downloader/views/icons.d.ts +0 -5
  81. package/dist/types/components/phirepass-downloader/views/job-row.d.ts +0 -21
  82. package/dist/types/components/phirepass-downloader/views/notices.d.ts +0 -18
  83. package/dist/types/components/phirepass-downloader/views/states.d.ts +0 -38
  84. package/dist/types/components/phirepass-media-player/phirepass-media-player.d.ts +0 -82
  85. package/dist/types/components/phirepass-media-player/player.d.ts +0 -53
  86. package/dist/types/components/phirepass-sftp-client/phirepass-sftp-client.fetch.d.ts +0 -40
  87. package/dist/types/testing/fixtures.d.ts +0 -25
  88. package/dist/types/testing/mock-channel.d.ts +0 -132
@@ -0,0 +1,1470 @@
1
+ 'use strict';
2
+
3
+ var index = require('./index-C3v5xmUo.js');
4
+ var protocol = require('./protocol-DCBMfc2u.js');
5
+
6
+ const phirepassSftpClientLogoSvg = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoNDYsIDE4NCwgMTM4KSIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiCiAgICBjbGFzcz0ibHVjaWRlIGx1Y2lkZS10ZXJtaW5hbCB3LTMuNSBoLTMuNSB0ZXh0LXByaW1hcnkiPgogICAgPHBvbHlsaW5lIHBvaW50cz0iNCAxNyAxMCAxMSA0IDUiPjwvcG9seWxpbmU+CiAgICA8bGluZSB4MT0iMTIiIHgyPSIyMCIgeTE9IjE5IiB5Mj0iMTkiPjwvbGluZT4KPC9zdmc+Cg==';
7
+
8
+ const phirepassSftpClientMaxSvg = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTE1LCAxMjMsIDE0MCkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtbWF4aW1pemUyIHctMyBoLTMiPgogICAgPHBvbHlsaW5lIHBvaW50cz0iMTUgMyAyMSAzIDIxIDkiPjwvcG9seWxpbmU+CiAgICA8cG9seWxpbmUgcG9pbnRzPSI5IDIxIDMgMjEgMyAxNSI+PC9wb2x5bGluZT4KICAgIDxsaW5lIHgxPSIyMSIgeDI9IjE0IiB5MT0iMyIgeTI9IjEwIj48L2xpbmU+CiAgICA8bGluZSB4MT0iMyIgeDI9IjEwIiB5MT0iMjEiIHkyPSIxNCI+PC9saW5lPgo8L3N2Zz4K';
9
+
10
+ const phirepassSftpClientChevronSvg = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTg5LCAyMTksIDIwOSkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIgogICAgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIKICAgIGNsYXNzPSJsdWNpZGUgbHVjaWRlLWNoZXZyb24tcmlnaHQgdy0zIGgtMyB0ZXh0LW11dGVkLWZvcmVncm91bmQvNTAgc2hyaW5rLTAiPgogICAgPHBhdGggZD0ibTkgMTggNi02LTYtNiI+PC9wYXRoPgo8L3N2Zz4K';
11
+
12
+ const phirepassSftpClientFolderSvg = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoNDYsIDE4NCwgMTM4KSIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiCiAgICBjbGFzcz0ibHVjaWRlIGx1Y2lkZS1mb2xkZXIgdy0zLjUgaC0zLjUgdGV4dC1wcmltYXJ5IHNocmluay0wIj4KICAgIDxwYXRoCiAgICAgICAgZD0iTTIwIDIwYTIgMiAwIDAgMCAyLTJWOGEyIDIgMCAwIDAtMi0yaC03LjlhMiAyIDAgMCAxLTEuNjktLjlMOS42IDMuOUEyIDIgMCAwIDAgNy45MyAzSDRhMiAyIDAgMCAwLTIgMnYxM2EyIDIgMCAwIDAgMiAyWiI+PC9wYXRoPgo8L3N2Zz4K';
13
+
14
+ const phirepassSftpClientFileSvg = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTE1LCAxMjMsIDE0MCkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtZmlsZSB3LTMuNSBoLTMuNSB0ZXh0LW11dGVkLWZvcmVncm91bmQgc2hyaW5rLTAiPgogICAgPHBhdGggZD0iTTE1IDJINmEyIDIgMCAwIDAtMiAydjE2YTIgMiAwIDAgMCAyIDJoMTJhMiAyIDAgMCAwIDItMlY3WiI+PC9wYXRoPgogICAgPHBhdGggZD0iTTE0IDJ2NGEyIDIgMCAwIDAgMiAyaDQiPjwvcGF0aD4KPC9zdmc+Cg==';
15
+
16
+ const phirepassSftpClientGoUpSvg = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTg5LCAyMTksIDIwOSkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtYXJyb3ctdXAgdy0zLjUgaC0zLjUiPgogICAgPHBhdGggZD0ibTUgMTIgNy03IDcgNyI+PC9wYXRoPgogICAgPHBhdGggZD0iTTEyIDE5VjUiPjwvcGF0aD4KPC9zdmc+Cg==';
17
+
18
+ const phirepassSftpClientRefreshSvg = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTg5LCAyMTksIDIwOSkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtcmVmcmVzaC1jdyB3LTMuNSBoLTMuNSI+CiAgICA8cGF0aCBkPSJNMyAxMmE5IDkgMCAwIDEgOS05IDkuNzUgOS43NSAwIDAgMSA2Ljc0IDIuNzRMMjEgOCI+PC9wYXRoPgogICAgPHBhdGggZD0iTTIxIDN2NWgtNSI+PC9wYXRoPgogICAgPHBhdGggZD0iTTIxIDEyYTkgOSAwIDAgMS05IDkgOS43NSA5Ljc1IDAgMCAxLTYuNzQtMi43NEwzIDE2Ij48L3BhdGg+CiAgICA8cGF0aCBkPSJNOCAxNkgzdjUiPjwvcGF0aD4KPC9zdmc+Cg==';
19
+
20
+ const phirepassSftpClientUploadSvg = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTg5LCAyMTksIDIwOSkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtdXBsb2FkIHctMy41IGgtMy41Ij4KICAgIDxwYXRoIGQ9Ik0yMSAxNXY0YTIgMiAwIDAgMS0yIDJINWEyIDIgMCAwIDEtMi0ydi00Ij48L3BhdGg+CiAgICA8cG9seWxpbmUgcG9pbnRzPSIxNyA4IDEyIDMgNyA4Ij48L3BvbHlsaW5lPgogICAgPGxpbmUgeDE9IjEyIiB4Mj0iMTIiIHkxPSIzIiB5Mj0iMTUiPjwvbGluZT4KPC9zdmc+Cg==';
21
+
22
+ const phirepassSftpClientCss = () => `:host{--radius:0.375rem;--card:220 18% 10%;--border:220 15% 18%;--primary:160 60% 45%;--radius:0.375rem;--destructive:0 70% 50%;--muted:220 15% 13%;--muted-foreground:220 10% 50%;--primary-foreground:220 20% 7%;--scroll-track:220 16% 12%;--scroll-thumb:220 12% 34%;--scroll-thumb-hover:160 45% 44%;font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace;height:100%;width:100%;border:1px solid hsl(var(--border));background-color:hsl(var(--card));border-radius:var(--radius);overflow:hidden;display:flex;flex-direction:column;position:relative;container-type:inline-size;.listing{height:100%;display:flex;flex-direction:column;justify-content:space-between;min-height:0;header{height:30px;background:rgba(28, 31, 38, 0.6);border-bottom:1px solid hsl(var(--border));display:flex;align-items:center;justify-content:space-between;.actions{display:flex;align-items:center;.action{cursor:pointer;padding:4px;display:flex;align-items:center;z-index:1;img{height:14px;padding:4px;border-radius:4px}&:hover{background-color:hsl(var(--border) / 0.6)}}}.title{color:hsl(var(--primary));height:14px;padding:0 12px;display:flex;align-items:center;font-size:0.75rem;line-height:1rem;img{height:14px;margin-right:5px}.text{display:flex;flex-direction:row;justify-content:center;margin-top:2px;.name{margin-right:10px}.description{color:hsl(var(--muted-foreground))}}}}main{flex:1;display:flex;flex-direction:column;position:relative;min-height:0;overflow:hidden;.loader{color:hsl(var(--muted-foreground));font-size:13px;animation:pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;text-align:center;display:flex;align-items:center;justify-content:center;position:absolute;height:100%;width:100%;background:rgba(28, 31, 38, 0);backdrop-filter:blur(4px)}.error{font-size:13px;text-align:center;color:hsl(var(--destructive));height:100%;display:flex;align-items:center;justify-content:center}.navigation{height:25px;padding:10px;font-size:0.75rem;line-height:1rem;background-color:hsl(var(--card));display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid hsl(var(--border));position:sticky;top:0;z-index:3;.breadcrumbs{display:flex;align-items:center;margin-right:10px;.breadcrumb-container{white-space:nowrap;.breadcrumb{color:hsl(var(--primary));margin-right:4px;cursor:pointer;&:after{margin-left:4px}&:hover{color:rgb(189, 219, 209)}&:last-child{margin-right:0;color:rgb(189, 219, 209);cursor:default}}}.arrow{height:12px;width:12px;opacity:0.6;top:2px;margin-right:4px;position:relative}}.actions{display:flex;align-items:center;gap:8px}.filter{height:1.5rem;width:110px;padding:0 6px;font:inherit;font-size:0.68rem;color:rgb(189, 219, 209);background-color:hsl(var(--muted));border:1px solid hsl(var(--border));border-radius:calc(var(--radius) - 2px);outline:none;&::placeholder{color:hsl(var(--muted-foreground))}&:focus{border-color:hsl(var(--primary))}}.action{border:none;background:transparent;color:rgb(189, 219, 209);font-size:1.1rem;line-height:1;padding:2px 4px;border-radius:4px;cursor:pointer;&:hover{background-color:hsl(var(--border) / 0.6)}img{height:14px;width:14px;display:block}}.action.disconnect{color:#ff4d5f;font-size:0.65rem;letter-spacing:0.08em;padding:4px 8px;&:hover{color:#ff6b7a;background-color:hsl(var(--destructive) / 0.12)}}}.content{flex:1;min-height:0;outline:none;overflow:auto;font-size:0.75rem;line-height:1rem;scrollbar-width:thin;scrollbar-color:hsl(var(--scroll-thumb)) hsl(var(--scroll-track));&:focus-visible{box-shadow:inset 0 0 0 1px hsl(var(--primary) / 0.5)}&::-webkit-scrollbar{width:10px;height:10px}&::-webkit-scrollbar-track{background:hsl(var(--scroll-track))}&::-webkit-scrollbar-thumb{background:hsl(var(--scroll-thumb));border-radius:999px;border:2px solid hsl(var(--scroll-track))}&::-webkit-scrollbar-thumb:hover{background:hsl(var(--scroll-thumb-hover))}table{width:100%;border-collapse:separate;border-spacing:0;table-layout:auto;thead{background-color:hsl(var(--muted));border-bottom:1px solid hsl(var(--border));th.sortable{cursor:pointer;user-select:none;&:hover{color:hsl(var(--primary))}}th{padding:8px 10px;text-align:left;color:hsl(var(--muted-foreground));position:sticky;top:0;z-index:2;background-color:hsl(var(--muted));border-bottom:1px solid hsl(var(--border));line-height:0.95rem;&.action-col{width:58px;min-width:58px;padding:0 10px}&:first-child{width:30%;min-width:180px;max-width:195px}&:nth-child(2),&:nth-child(3),&:nth-child(4),&:nth-child(5){white-space:nowrap;width:1%}}}tbody{padding:10px 10px;tr.empty{cursor:default;td{color:hsl(var(--muted-foreground));text-align:center;padding:18px 8px}&:hover{background:transparent}}tr{border-bottom:1px solid hsl(var(--border) / 0.4);td{padding:10px 10px 9px;color:hsl(var(--muted-foreground));&:first-child{min-width:180px;max-width:195px;white-space:nowrap;.name{display:inline-block;max-width:calc(100% - 26px);overflow:hidden;text-overflow:ellipsis;vertical-align:middle}}&:nth-child(2),&:nth-child(3),&:nth-child(4),&:nth-child(5){white-space:nowrap}&.action-col{width:58px;min-width:58px;text-align:center;padding-left:1px;padding-right:1px;.file-actions{display:flex;align-items:center;justify-content:center;gap:8px}.file-action{border:none;background:transparent;color:hsl(var(--muted-foreground));width:16px;height:16px;border-radius:3px;cursor:pointer;opacity:0;visibility:hidden;pointer-events:none;transition:opacity 120ms ease;padding:0;svg{width:12px;height:12px;display:block;margin:0 auto}&:hover{color:hsl(var(--primary))}&.delete:hover{color:hsl(var(--destructive))}}}.name{&.file{color:rgb(189, 219, 209)}&.folder{color:hsl(var(--primary))}}.kind{height:14px;width:14px;margin-right:5px;top:3px;position:relative}}&:hover{cursor:pointer;background-color:hsl(var(--muted) / 0.4);td.action-col .file-action{opacity:1;visibility:visible;pointer-events:auto;color:hsl(var(--primary))}}&.selected{background-color:hsl(var(--primary) / 0.3);td.action-col .file-action{opacity:1;visibility:visible;pointer-events:auto}&:hover{background-color:hsl(var(--primary) / 0.4)}}}}}}}footer{height:25px;background:rgba(28, 31, 38, 0.6);border-top:1px solid hsl(var(--border));font-size:0.75rem;line-height:1rem;display:flex;align-items:center;justify-content:space-between;padding:0 10px;.status{font-size:0.65rem;color:hsl(var(--muted-foreground));.selected-item{margin-left:10px;color:hsl(var(--primary))}}.version{font-size:0.65rem;color:hsl(var(--muted-foreground))}}}.creds{position:absolute;top:0;left:0;height:100%;width:100%;display:flex;justify-content:center;align-items:center;;&.blurred{background:rgba(28, 31, 38, 0);backdrop-filter:blur(4px)}.auth{display:flex;flex-direction:column;background:hsl(var(--card));position:relative;background-color:rgba(21, 24, 30, 0.95);border:1px solid hsl(var(--border));padding:30px;box-shadow:rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0.5) 0px 25px 50px -12px;border-radius:var(--radius);.title{margin-bottom:12px;color:hsl(var(--primary))}label{font-size:0.75rem;line-height:1rem;margin-bottom:1rem;color:hsl(var(--muted-foreground))}input{font-size:0.875rem;line-height:1.25rem;padding-top:0.5rem;padding-bottom:0.5rem;padding-left:0.75rem;padding-right:0.75rem;background-color:rgb(28, 31, 38);border-color:rgb(39, 44, 53);border-width:1px;border-radius:calc(var(--radius) - 2px);width:100%;margin-bottom:12px;color:rgb(189, 219, 209);box-sizing:border-box;&:focus{outline:none;border-color:hsl(var(--primary));box-shadow:0 0 0 1px hsl(var(--primary))}}button[type='submit']{margin-top:12px;width:100%;background-color:hsl(var(--primary));color:hsl(var(--primary-foreground));letter-spacing:0.05em;font-size:13px;font-weight:500;padding:0.5rem 1rem;border-radius:calc(var(--radius) - 2px);height:2rem;cursor:pointer;border:none;&:hover{background-color:hsl(var(--primary) / 0.9)}}}}.upload-modal,.download-modal,.delete-modal,.prompt-modal{position:absolute;inset:0;display:none;align-items:center;justify-content:center;background:rgba(28, 31, 38, 0);backdrop-filter:blur(4px);z-index:6;&.visible{display:flex}.upload-dialog,.download-dialog,.delete-dialog,.prompt-dialog{width:min(360px, calc(100% - 24px));background-color:rgba(21, 24, 30, 0.96);border:1px solid hsl(var(--border));border-radius:var(--radius);padding:16px;box-shadow:rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0.5) 0px 25px 50px -12px;.title{color:hsl(var(--primary));font-size:0.8rem;margin-bottom:8px}.file-name{color:rgb(189, 219, 209);font-size:0.72rem;line-height:1rem;margin-bottom:10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.progress-track{width:100%;height:10px;border-radius:999px;background-color:hsl(var(--muted));overflow:hidden;border:1px solid hsl(var(--border));.progress-fill{height:100%;width:0;background:linear-gradient(90deg, hsl(var(--primary) / 0.7), hsl(var(--primary)));transition:width 140ms ease}}.progress-meta{margin-top:8px;margin-bottom:12px;display:flex;align-items:center;justify-content:space-between;gap:10px}.progress-speed{color:hsl(var(--muted-foreground));font-size:0.75rem;font-variant-numeric:tabular-nums;line-height:1.4;text-align:left}.progress-value{color:hsl(var(--muted-foreground));font-size:0.75rem;font-variant-numeric:tabular-nums;line-height:1.4;text-align:right}.cancel{margin-top:14px;width:100%;height:2rem;border:1px solid hsl(var(--border));border-radius:calc(var(--radius) - 2px);background:hsl(var(--muted));color:rgb(189, 219, 209);font-size:0.75rem;letter-spacing:0.03em;cursor:pointer;&:hover{border-color:hsl(var(--primary));color:hsl(var(--primary))}&.finished{background-color:hsl(var(--primary));border-color:hsl(var(--primary));color:hsl(var(--primary-foreground));&:hover{background-color:hsl(var(--primary) / 0.9);border-color:hsl(var(--primary) / 0.9);color:hsl(var(--primary-foreground))}}}.message{color:rgb(189, 219, 209);font-size:0.74rem;line-height:1rem;margin-bottom:8px}.modal-actions{margin-top:14px;display:grid;grid-template-columns:1fr 1fr;gap:8px;.btn{height:2rem;border:1px solid hsl(var(--border));border-radius:calc(var(--radius) - 2px);font-size:0.75rem;letter-spacing:0.03em;cursor:pointer;&:disabled{opacity:0.65;cursor:not-allowed}}.btn.secondary{background:hsl(var(--muted));color:rgb(189, 219, 209);&:hover{border-color:hsl(var(--primary));color:hsl(var(--primary))}}.btn.destructive{background:hsl(var(--destructive));border-color:hsl(var(--destructive));color:white;&:hover{background:hsl(var(--destructive) / 0.9);border-color:hsl(var(--destructive) / 0.9)}}}.dialog-input{width:100%;box-sizing:border-box;height:2rem;padding:0 8px;font:inherit;font-size:0.75rem;color:rgb(189, 219, 209);background-color:hsl(var(--muted));border:1px solid hsl(var(--border));border-radius:calc(var(--radius) - 2px);outline:none;&:focus{border-color:hsl(var(--primary))}&:disabled{opacity:0.65}}.dialog-error{margin-top:8px;font-size:0.7rem;line-height:0.95rem;color:#ff6b7a}.hint{margin-top:4px;font-size:0.66rem;line-height:0.9rem;color:hsl(var(--muted-foreground))}.checkline{margin-top:8px;display:flex;align-items:center;gap:6px;font-size:0.72rem;color:rgb(189, 219, 209);cursor:pointer;input{accent-color:hsl(var(--primary));margin:0}}.perm-grid{margin-top:10px;width:100%;border-collapse:collapse;font-size:0.68rem;th{color:hsl(var(--muted-foreground));font-weight:normal;text-align:center;padding:2px 0}th[scope='row']{text-align:left;color:rgb(189, 219, 209)}td{text-align:center;padding:2px 0}input{accent-color:hsl(var(--primary));margin:0}}.perm-special{margin-top:4px;display:flex;gap:12px;.checkline{margin-top:4px;font-size:0.66rem}}.perm-octal{margin-top:10px;display:flex;align-items:center;gap:8px;label{font-size:0.68rem;color:hsl(var(--muted-foreground))}.dialog-input{width:4.5rem;text-align:center;letter-spacing:0.1em}.perm-preview{font-size:0.7rem;color:hsl(var(--primary))}}.modal-actions .btn.primary{background:hsl(var(--primary));border-color:hsl(var(--primary));color:hsl(var(--primary-foreground));&:hover:not(:disabled){background:hsl(var(--primary) / 0.9);border-color:hsl(var(--primary) / 0.9)}}.delete-loader{margin-top:4px;display:flex;justify-content:center;.spinner{width:16px;height:16px;border:2px solid hsl(var(--muted-foreground) / 0.35);border-top-color:hsl(var(--primary));border-radius:50%;animation:spin 0.7s linear infinite}}}}.editor-modal{position:absolute;inset:0;display:none;align-items:center;justify-content:center;background:rgba(28, 31, 38, 0);backdrop-filter:blur(4px);z-index:7;&.visible{display:flex}.editor-dialog{width:min(860px, calc(100% - 24px));height:min(620px, calc(100% - 24px));display:flex;flex-direction:column;background-color:rgba(21, 24, 30, 0.98);border:1px solid hsl(var(--border));border-radius:var(--radius);padding:16px;box-shadow:rgba(0, 0, 0, 0.5) 0px 25px 50px -12px;outline:none;.editor-head{display:flex;align-items:center;justify-content:space-between;gap:8px;.title{color:hsl(var(--primary));font-size:0.8rem;margin-bottom:8px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.editor-close{border:none;background:transparent;color:hsl(var(--muted-foreground));font-size:0.85rem;line-height:1;padding:2px 6px;border-radius:4px;cursor:pointer;&:hover:not(:disabled){color:hsl(var(--primary));background-color:hsl(var(--border) / 0.6)}&:disabled{opacity:0.5;cursor:not-allowed}}}.editor-loading{flex:1;display:flex;align-items:center;justify-content:center;font-size:0.75rem;color:hsl(var(--muted-foreground))}.editor-text{flex:1;min-height:0;width:100%;box-sizing:border-box;resize:none;padding:10px;font:inherit;font-size:0.75rem;line-height:1.15rem;tab-size:4;white-space:pre;overflow:auto;color:rgb(189, 219, 209);background-color:hsl(var(--muted));border:1px solid hsl(var(--border));border-radius:calc(var(--radius) - 2px);outline:none;&:focus{border-color:hsl(var(--primary) / 0.6)}&:disabled{opacity:0.65}}.dialog-error{margin-top:8px;font-size:0.7rem;line-height:0.95rem;color:#ff6b7a}.modal-actions{margin-top:14px;display:flex;justify-content:flex-end;gap:8px;.btn{height:2rem;min-width:6rem;border:1px solid hsl(var(--border));border-radius:calc(var(--radius) - 2px);font-size:0.75rem;letter-spacing:0.03em;cursor:pointer;&:disabled{opacity:0.65;cursor:not-allowed}}.btn.secondary{background:hsl(var(--muted));color:rgb(189, 219, 209);&:hover:not(:disabled){border-color:hsl(var(--primary));color:hsl(var(--primary))}}.btn.destructive{background:hsl(var(--destructive));border-color:hsl(var(--destructive));color:white}.btn.primary{background:hsl(var(--primary));border-color:hsl(var(--primary));color:hsl(var(--primary-foreground));&:hover:not(:disabled){background:hsl(var(--primary) / 0.9);border-color:hsl(var(--primary) / 0.9)}}}}}}@keyframes spin{to{transform:rotate(360deg)}}:host(.max){height:100vh;width:100vw;position:fixed;top:0;left:0;z-index:9999}@container (max-width: 699px){:host .listing main .content table thead th:nth-child(4),:host .listing main .content table tbody td:nth-child(4){display:none}}@container (max-width: 635px){:host .listing main .content table thead th:nth-child(3),:host .listing main .content table tbody td:nth-child(3){display:none}}@container (max-width: 530px){:host .listing main .content table thead th:nth-child(5),:host .listing main .content table tbody td:nth-child(5){display:none}:host .listing footer .status{display:none}}@container (max-width: 370px){:host .listing main .content table thead th:nth-child(2),:host .listing main .content table tbody td:nth-child(2){display:none}:host .listing main .content table thead th:first-child,:host .listing main .content table tbody td:first-child{width:100%;min-width:0;max-width:none}:host .listing main .content table tbody td:first-child .name{max-width:100%}}@container (max-width: 295px){:host .listing main .content table tbody td:first-child .name{max-width:120px}}@container (max-width: 635px){:host .listing main .content table tbody tr td.action-col .file-action{opacity:1;visibility:visible;pointer-events:auto;width:36px;height:36px;border-radius:8px}:host .listing main .content table tbody tr td.action-col .file-action svg{width:17px;height:17px}:host .listing main .content table thead th.action-col,:host .listing main .content table tbody td.action-col{width:92px;min-width:92px}:host .listing main .content table tbody td.action-col .file-actions{gap:4px}:host .listing main .content table tbody tr:hover{background-color:transparent}:host .listing main .content table tbody tr.selected:hover{background-color:hsl(var(--primary) / 0.3)}:host .listing main .content table tbody td{padding:13px 10px 12px}:host .listing main .content table thead th{padding:12px 10px}:host .listing main .navigation{height:auto;min-height:44px;padding:6px 8px}:host .listing main .navigation .action{padding:10px;border-radius:8px}:host .listing main .navigation .action img{height:17px;width:17px}:host .listing main .navigation .action.disconnect{padding:10px 12px}:host .listing main .navigation .filter{height:2.25rem;font-size:16px;width:8rem}:host .listing header .actions .action{padding:8px}:host .listing header .actions .action img{height:17px}:host .modal .upload-dialog .cancel,:host .modal .download-dialog .cancel,:host .modal .delete-dialog .cancel,:host .modal .prompt-dialog .cancel,:host .modal .upload-dialog .modal-actions .btn,:host .modal .download-dialog .modal-actions .btn,:host .modal .delete-dialog .modal-actions .btn,:host .modal .prompt-dialog .modal-actions .btn{height:2.75rem}:host .modal .prompt-dialog .dialog-input,:host .auth input{height:2.5rem;font-size:16px}:host .modal .prompt-dialog .perm-grid input,:host .modal .prompt-dialog .perm-special input{width:20px;height:20px}:host .modal .prompt-dialog .perm-grid td,:host .modal .prompt-dialog .perm-grid th{padding:7px 0}}`;
23
+
24
+ const PhirepassSftpClient = class {
25
+ constructor(hostRef) {
26
+ if (new.target === PhirepassSftpClient)
27
+ index.registerInstance(this, hostRef);
28
+ this.maximizeEvent = index.createEvent(this, "maximize");
29
+ this.connectionStateChanged = index.createEvent(this, "connectionStateChanged");
30
+ }
31
+ channel;
32
+ domReady = false;
33
+ runtimeReady = false;
34
+ connected = false;
35
+ uploadInputEl;
36
+ msgId = 1;
37
+ activeUploadToken = 0;
38
+ pendingUploadStarts = new Map();
39
+ pendingUploadAcks = new Map();
40
+ pendingDownloadStarts = new Map();
41
+ activeDownloads = new Map();
42
+ activeDownloadMsgId;
43
+ pendingOps = new Map();
44
+ promptInputEl;
45
+ editorPath = '';
46
+ editorTextEl;
47
+ // private inputMode: InputMode = InputMode.Default;
48
+ session_id;
49
+ // private usernameBuffer = "";
50
+ // private passwordBuffer = "";
51
+ name = 'SFTP';
52
+ description = 'Client';
53
+ hideHeader = false;
54
+ serverHost = "phirepass.com";
55
+ serverPort = 443;
56
+ allowInsecure = false;
57
+ heartbeatInterval = 30_000;
58
+ nodeId;
59
+ serviceId;
60
+ token;
61
+ onNodeIdChange(newValue, _oldValue) {
62
+ // Handle the change in node_id here
63
+ // console.log(`node_id changed from ${oldValue} to ${newValue}`);
64
+ // Always clear local session state and reset terminal view
65
+ this.reset_session_state();
66
+ // this.terminal.reset();
67
+ // Close existing comms if connected
68
+ if (this.channel && this.channel.is_connected()) {
69
+ this.close_comms();
70
+ }
71
+ // Open new comms for the updated node
72
+ if (newValue) {
73
+ this.open_comms();
74
+ this.channel.connect();
75
+ this.status = 'Connecting...';
76
+ }
77
+ }
78
+ serverId;
79
+ /**
80
+ * Supplies the channel instead of a WebSocket to the server — for demos,
81
+ * screenshots and tests. A property only (a function cannot be an
82
+ * attribute); read once, when the widget connects. See `ChannelFactory`.
83
+ */
84
+ channelFactory;
85
+ onServerIdChange(_newValue, _oldValue) {
86
+ this.onNodeIdChange(this.nodeId, this.nodeId);
87
+ }
88
+ maximizeEvent;
89
+ async maximize() {
90
+ this.max = !this.max;
91
+ }
92
+ async minimize() {
93
+ this.max = false;
94
+ }
95
+ connectionStateChanged;
96
+ max = false;
97
+ show_login_screen = false;
98
+ show_login_screen_username = false;
99
+ show_error = false;
100
+ error_message = '';
101
+ show_login_screen_password = false;
102
+ show_navigation = false;
103
+ breadcrumbs = [];
104
+ current_dir = '.';
105
+ listing = [];
106
+ show_content = false;
107
+ show_loader = false;
108
+ version = '';
109
+ status = 'Disconnected';
110
+ selected_item = null;
111
+ show_upload_modal = false;
112
+ upload_progress = 0;
113
+ upload_file_name = '';
114
+ upload_speed = '--';
115
+ upload_finished = false;
116
+ show_download_modal = false;
117
+ download_progress = 0;
118
+ download_file_name = '';
119
+ download_speed = '--';
120
+ download_finished = false;
121
+ show_delete_modal = false;
122
+ delete_file_name = '';
123
+ delete_loading = false;
124
+ delete_is_dir = false;
125
+ delete_recursive = false;
126
+ delete_error = '';
127
+ /** `mkdir` and `rename` share one dialog: both take a single name. */
128
+ prompt_kind = null;
129
+ prompt_value = '';
130
+ prompt_error = '';
131
+ prompt_busy = false;
132
+ chmod_target = null;
133
+ /** Permission bits under edit, masked to 0o7777. */
134
+ chmod_mode = 0;
135
+ chmod_error = '';
136
+ chmod_busy = false;
137
+ show_editor = false;
138
+ editor_name = '';
139
+ editor_text = '';
140
+ /** What is on the remote, so the dialog knows whether it has edits. */
141
+ editor_saved_text = '';
142
+ editor_busy = '';
143
+ editor_error = '';
144
+ editor_confirm_discard = false;
145
+ /** False until the file's contents are in hand, so a failed open is read-only. */
146
+ editor_loaded = false;
147
+ filter = '';
148
+ sort_key = 'name';
149
+ sort_asc = true;
150
+ toggle_max() {
151
+ this.maximizeEvent?.emit(!this.max);
152
+ }
153
+ async connectedCallback() {
154
+ if (!this.channelFactory) {
155
+ await protocol.__wbg_init();
156
+ }
157
+ // this.setup_terminal();
158
+ this.open_comms();
159
+ this.runtimeReady = true;
160
+ if (!this.nodeId) {
161
+ console.warn('Prop node_id is not set. Cannot connect to terminal.');
162
+ return;
163
+ }
164
+ this.try_connect();
165
+ }
166
+ componentDidLoad() {
167
+ this.domReady = true;
168
+ this.try_connect();
169
+ }
170
+ async disconnectedCallback() {
171
+ // if (this.resizeDebounceHandle) {
172
+ // clearTimeout(this.resizeDebounceHandle);
173
+ // this.resizeDebounceHandle = undefined;
174
+ // }
175
+ //
176
+ // if (this.resizeObserver) {
177
+ // this.resizeObserver.disconnect();
178
+ // }
179
+ this.connected = false;
180
+ this.domReady = false;
181
+ this.runtimeReady = false;
182
+ this.cancel_active_upload();
183
+ this.cancel_active_download();
184
+ this.clear_pending_operations();
185
+ this.close_comms();
186
+ // this.destroy_terminal();
187
+ }
188
+ next_msg_id() {
189
+ const id = this.msgId;
190
+ this.msgId += 1;
191
+ return id;
192
+ }
193
+ clear_pending_operations() {
194
+ this.pendingUploadStarts.forEach((pending) => {
195
+ window.clearTimeout(pending.timeout);
196
+ pending.reject(new Error('Upload start aborted'));
197
+ });
198
+ this.pendingUploadStarts.clear();
199
+ this.pendingUploadAcks.forEach((pending) => {
200
+ window.clearTimeout(pending.timeout);
201
+ pending.reject(new Error('Upload chunk aborted'));
202
+ });
203
+ this.pendingUploadAcks.clear();
204
+ this.pendingDownloadStarts.forEach((pending) => {
205
+ window.clearTimeout(pending.timeout);
206
+ pending.reject(new Error('Download start aborted'));
207
+ });
208
+ this.pendingDownloadStarts.clear();
209
+ this.pendingOps.forEach((pending) => {
210
+ window.clearTimeout(pending.timeout);
211
+ pending.reject(new Error(`Could not ${pending.verb}: the session ended.`));
212
+ });
213
+ this.pendingOps.clear();
214
+ this.activeDownloads.clear();
215
+ }
216
+ cancel_active_upload() {
217
+ this.activeUploadToken += 1;
218
+ this.upload_progress = 0;
219
+ this.upload_finished = false;
220
+ this.upload_speed = '--';
221
+ }
222
+ cancel_active_download() {
223
+ if (this.activeDownloadMsgId !== undefined) {
224
+ this.activeDownloads.delete(this.activeDownloadMsgId);
225
+ }
226
+ this.activeDownloadMsgId = undefined;
227
+ this.download_progress = 0;
228
+ this.download_finished = false;
229
+ this.download_speed = '--';
230
+ }
231
+ format_duration(seconds) {
232
+ if (!Number.isFinite(seconds) || seconds < 0) {
233
+ return '--';
234
+ }
235
+ if (seconds < 60) {
236
+ return `${seconds.toFixed(0)}s`;
237
+ }
238
+ const minutes = Math.floor(seconds / 60);
239
+ const remainderSeconds = Math.floor(seconds % 60);
240
+ if (minutes < 60) {
241
+ return `${minutes}m ${remainderSeconds}s`;
242
+ }
243
+ const hours = Math.floor(minutes / 60);
244
+ const remainderMinutes = minutes % 60;
245
+ return `${hours}h ${remainderMinutes}m`;
246
+ }
247
+ format_percent(value) {
248
+ const safe = Number.isFinite(value) ? value : 0;
249
+ return `${safe.toFixed(2)}%`;
250
+ }
251
+ format_transfer_rate(bytesPerSecond) {
252
+ if (!Number.isFinite(bytesPerSecond) || bytesPerSecond <= 0) {
253
+ return '--';
254
+ }
255
+ return `${this.format_size(bytesPerSecond)}/s`;
256
+ }
257
+ update_upload_progress(uploadedBytes, totalBytes, startTime) {
258
+ const progress = totalBytes > 0 ? (uploadedBytes / totalBytes) * 100 : 0;
259
+ this.upload_progress = Math.max(0, Math.min(100, progress));
260
+ if (uploadedBytes >= totalBytes) {
261
+ this.upload_finished = true;
262
+ this.upload_speed = '--';
263
+ return;
264
+ }
265
+ const elapsedSeconds = (performance.now() - startTime) / 1000;
266
+ const speed = elapsedSeconds > 0 ? uploadedBytes / elapsedSeconds : 0;
267
+ this.upload_speed = this.format_transfer_rate(speed);
268
+ const remaining = totalBytes - uploadedBytes;
269
+ const eta = speed > 0 ? remaining / speed : NaN;
270
+ this.status = `Uploading ${this.format_size(uploadedBytes)} / ${this.format_size(totalBytes)} (ETA ${this.format_duration(eta)})`;
271
+ }
272
+ update_download_progress(receivedBytes, totalBytes, startTime) {
273
+ const progress = totalBytes > 0 ? (receivedBytes / totalBytes) * 100 : 0;
274
+ this.download_progress = Math.max(0, Math.min(100, progress));
275
+ if (receivedBytes >= totalBytes) {
276
+ this.download_finished = true;
277
+ this.download_speed = '--';
278
+ return;
279
+ }
280
+ const elapsedSeconds = (Date.now() - startTime) / 1000;
281
+ const speed = elapsedSeconds > 0 ? receivedBytes / elapsedSeconds : 0;
282
+ this.download_speed = this.format_transfer_rate(speed);
283
+ const remaining = totalBytes - receivedBytes;
284
+ const eta = speed > 0 ? remaining / speed : NaN;
285
+ this.status = `Downloading ${this.format_size(receivedBytes)} / ${this.format_size(totalBytes)} (ETA ${this.format_duration(eta)})`;
286
+ }
287
+ connect() {
288
+ this.connected = true;
289
+ this.channel.connect();
290
+ this.status = 'Connecting...';
291
+ // const container = this.containerEl;
292
+ // console.log('Attempting to connect terminal to container:', container);
293
+ // if (container) {
294
+ // this.terminal.open(container);
295
+ // console.log('Terminal opened in container');
296
+ // this.connected = true;
297
+ // this.fit_terminal_safely();
298
+ // this.terminal.focus();
299
+ // this.terminal.onData(this.handle_terminal_data.bind(this));
300
+ // this.channel.connect();
301
+ // this.setup_resize_observer();
302
+ // console.log('Terminal connected and ready');
303
+ // }
304
+ }
305
+ try_connect() {
306
+ if (this.connected || !this.domReady || !this.runtimeReady) {
307
+ return;
308
+ }
309
+ if (!this.channel) {
310
+ return;
311
+ }
312
+ this.connect();
313
+ }
314
+ create_web_socket_endpoint() {
315
+ const protocol = this.allowInsecure ? 'ws' : 'wss';
316
+ if (!this.allowInsecure && this.serverPort === 443) {
317
+ return `${protocol}://${this.serverHost}`;
318
+ }
319
+ if (this.allowInsecure && this.serverPort === 80) {
320
+ return `${protocol}://${this.serverHost}`;
321
+ }
322
+ return `${protocol}://${this.serverHost}:${this.serverPort}`;
323
+ }
324
+ handle_error(error) {
325
+ if (error.msg_id !== undefined) {
326
+ const pendingUploadStart = this.pendingUploadStarts.get(error.msg_id);
327
+ if (pendingUploadStart) {
328
+ window.clearTimeout(pendingUploadStart.timeout);
329
+ pendingUploadStart.reject(new Error(error.message || 'Upload start failed'));
330
+ this.pendingUploadStarts.delete(error.msg_id);
331
+ }
332
+ const pendingDownloadStart = this.pendingDownloadStarts.get(error.msg_id);
333
+ if (pendingDownloadStart) {
334
+ window.clearTimeout(pendingDownloadStart.timeout);
335
+ pendingDownloadStart.reject(new Error(error.message || 'Download start failed'));
336
+ this.pendingDownloadStarts.delete(error.msg_id);
337
+ }
338
+ if (this.activeDownloads.has(error.msg_id)) {
339
+ this.activeDownloads.delete(error.msg_id);
340
+ if (this.activeDownloadMsgId === error.msg_id) {
341
+ this.activeDownloadMsgId = undefined;
342
+ }
343
+ this.download_finished = false;
344
+ }
345
+ const pendingOp = this.pendingOps.get(error.msg_id);
346
+ if (pendingOp) {
347
+ window.clearTimeout(pendingOp.timeout);
348
+ this.pendingOps.delete(error.msg_id);
349
+ pendingOp.reject(new Error(error.message || `Could not ${pendingOp.verb}.`));
350
+ // The caller puts this message in the dialog the user is
351
+ // looking at. Raising the page-level banner as well would say
352
+ // the same thing twice, in the place they are not looking.
353
+ this.show_loader = false;
354
+ return;
355
+ }
356
+ }
357
+ switch (error.kind) {
358
+ case protocol.ErrorType.Generic:
359
+ case protocol.ErrorType.Authentication:
360
+ this.error_message = error.message || 'An unknown error occurred.';
361
+ this.show_error = true;
362
+ break;
363
+ case protocol.ErrorType.RequiresUsername:
364
+ this.show_login_screen_username = true;
365
+ this.show_login_screen_password = false;
366
+ this.show_login_screen = true;
367
+ break;
368
+ case protocol.ErrorType.RequiresPassword:
369
+ this.show_login_screen_username = false;
370
+ this.show_login_screen_password = true;
371
+ this.show_login_screen = true;
372
+ break;
373
+ case protocol.ErrorType.RequiresUsernamePassword:
374
+ this.show_login_screen_username = true;
375
+ this.show_login_screen_password = true;
376
+ this.show_login_screen = true;
377
+ break;
378
+ }
379
+ setTimeout(() => {
380
+ this.show_loader = false;
381
+ }, 1_000);
382
+ }
383
+ handle_auth_success(auth) {
384
+ this.clear_creds_buffer();
385
+ this.version = auth.version;
386
+ this.channel.start_heartbeat(this.heartbeatInterval <= 15_000 ? 30_000 : this.heartbeatInterval);
387
+ this.channel.open_sftp_tunnel(this.nodeId, this.serviceId);
388
+ this.status = 'Connected';
389
+ }
390
+ handle_tunnel_opened(web) {
391
+ this.session_id = web.sid;
392
+ // this.terminal.reset();
393
+ // this.fit_terminal_safely();
394
+ // this.send_ssh_terminal_resize();
395
+ this.channel.send_sftp_list_data(this.nodeId, this.session_id, this.current_dir);
396
+ }
397
+ handle_sftp_list_items(web) {
398
+ setTimeout(() => {
399
+ this.show_loader = false;
400
+ }, 500);
401
+ // A filter is about the directory you typed it in; carrying it into
402
+ // the next one hides most of what you just navigated to.
403
+ if (web.path !== this.current_dir) {
404
+ this.filter = '';
405
+ }
406
+ this.listing = web.dir.items;
407
+ this.current_dir = web.path;
408
+ this.breadcrumbs = web.path.split('/').map((path, index, arr) => {
409
+ if (path === '' && index === 0) {
410
+ return { label: '/', path: '/' };
411
+ }
412
+ return { label: path, path: arr.slice(0, index + 1).join('/') };
413
+ });
414
+ this.show_content = true;
415
+ this.show_navigation = true;
416
+ console.log('Received SFTP list items:', web);
417
+ }
418
+ handle_upload_start_response(web) {
419
+ if (web.msg_id === undefined) {
420
+ return;
421
+ }
422
+ const pending = this.pendingUploadStarts.get(web.msg_id);
423
+ if (!pending) {
424
+ return;
425
+ }
426
+ window.clearTimeout(pending.timeout);
427
+ pending.resolve(web.response.upload_id);
428
+ this.pendingUploadStarts.delete(web.msg_id);
429
+ }
430
+ handle_upload_chunk_ack(web) {
431
+ const key = `${web.upload_id}_${web.chunk_index}`;
432
+ const pending = this.pendingUploadAcks.get(key);
433
+ if (!pending) {
434
+ return;
435
+ }
436
+ window.clearTimeout(pending.timeout);
437
+ pending.resolve();
438
+ this.pendingUploadAcks.delete(key);
439
+ }
440
+ handle_download_start_response(web) {
441
+ if (web.msg_id === undefined) {
442
+ return;
443
+ }
444
+ const pending = this.pendingDownloadStarts.get(web.msg_id);
445
+ if (!pending) {
446
+ return;
447
+ }
448
+ window.clearTimeout(pending.timeout);
449
+ pending.resolve({
450
+ download_id: web.response.download_id,
451
+ total_size: web.response.total_size,
452
+ total_chunks: web.response.total_chunks,
453
+ });
454
+ this.pendingDownloadStarts.delete(web.msg_id);
455
+ }
456
+ finalize_download(msgId) {
457
+ const download = this.activeDownloads.get(msgId);
458
+ if (!download) {
459
+ return;
460
+ }
461
+ const sortedChunks = Array.from(download.chunks.entries())
462
+ .sort((a, b) => a[0] - b[0])
463
+ .map(([, data]) => data);
464
+ // Normalize to fresh ArrayBuffer-backed views for BlobPart compatibility.
465
+ const blobParts = sortedChunks.map((chunk) => new Uint8Array(chunk));
466
+ const blob = new Blob(blobParts, { type: 'application/octet-stream' });
467
+ const objectUrl = URL.createObjectURL(blob);
468
+ const anchor = document.createElement('a');
469
+ anchor.href = objectUrl;
470
+ anchor.download = download.filename;
471
+ document.body.appendChild(anchor);
472
+ anchor.click();
473
+ document.body.removeChild(anchor);
474
+ URL.revokeObjectURL(objectUrl);
475
+ this.activeDownloads.delete(msgId);
476
+ if (this.activeDownloadMsgId === msgId) {
477
+ this.activeDownloadMsgId = undefined;
478
+ }
479
+ this.download_finished = true;
480
+ this.status = 'Connected';
481
+ }
482
+ handle_download_chunk(web) {
483
+ if (web.msg_id === undefined) {
484
+ return;
485
+ }
486
+ const download = this.activeDownloads.get(web.msg_id);
487
+ if (!download || !this.session_id) {
488
+ return;
489
+ }
490
+ const chunkData = new Uint8Array(web.chunk.data);
491
+ download.chunks.set(web.chunk.chunk_index, chunkData);
492
+ const receivedBytes = Array.from(download.chunks.values()).reduce((sum, data) => sum + data.length, 0);
493
+ this.update_download_progress(receivedBytes, download.total_size, download.startTime);
494
+ // Pipeline ACK: advance the agent's sliding window so it can push the next
495
+ // batch of chunks without waiting for an explicit per-chunk request.
496
+ this.channel.send_sftp_download_ack(this.nodeId, this.session_id, download.download_id, web.chunk.chunk_index);
497
+ if (download.chunks.size >= download.total_chunks) {
498
+ this.finalize_download(web.msg_id);
499
+ }
500
+ }
501
+ async start_download(item) {
502
+ if (!this.session_id) {
503
+ return;
504
+ }
505
+ this.selected_item = item;
506
+ this.download_file_name = item.name;
507
+ this.download_progress = 0;
508
+ this.download_finished = false;
509
+ this.download_speed = '--';
510
+ this.show_download_modal = true;
511
+ this.show_error = false;
512
+ const msgId = this.next_msg_id();
513
+ this.activeDownloadMsgId = msgId;
514
+ this.activeDownloads.set(msgId, {
515
+ filename: item.name,
516
+ chunks: new Map(),
517
+ total_chunks: 0,
518
+ total_size: 0,
519
+ download_id: 0,
520
+ startTime: Date.now(),
521
+ });
522
+ const downloadStart = new Promise((resolve, reject) => {
523
+ const timeout = window.setTimeout(() => {
524
+ this.pendingDownloadStarts.delete(msgId);
525
+ reject(new Error('Download start timeout'));
526
+ }, 10_000);
527
+ this.pendingDownloadStarts.set(msgId, {
528
+ timeout,
529
+ resolve,
530
+ reject,
531
+ });
532
+ });
533
+ try {
534
+ this.channel.send_sftp_download_start(this.nodeId, this.session_id, item.path, item.name, msgId);
535
+ const { download_id, total_chunks, total_size } = await downloadStart;
536
+ const download = this.activeDownloads.get(msgId);
537
+ if (!download) {
538
+ return;
539
+ }
540
+ download.download_id = download_id;
541
+ download.total_chunks = total_chunks;
542
+ download.total_size = total_size;
543
+ // Pipelined: agent pushes chunks immediately after SFTPDownloadStartResponse;
544
+ // no explicit per-chunk request is needed to start the flow.
545
+ }
546
+ catch (err) {
547
+ this.activeDownloads.delete(msgId);
548
+ if (this.activeDownloadMsgId === msgId) {
549
+ this.activeDownloadMsgId = undefined;
550
+ }
551
+ this.show_error = true;
552
+ this.error_message = err instanceof Error ? err.message : 'Failed to start download';
553
+ this.cancel_download();
554
+ }
555
+ }
556
+ async upload_file(fileToUpload) {
557
+ if (!this.session_id) {
558
+ return;
559
+ }
560
+ const uploadToken = this.activeUploadToken + 1;
561
+ this.activeUploadToken = uploadToken;
562
+ this.upload_file_name = fileToUpload.name;
563
+ this.upload_progress = 0;
564
+ this.upload_finished = false;
565
+ this.upload_speed = '--';
566
+ this.show_upload_modal = true;
567
+ this.show_error = false;
568
+ this.status = 'Uploading...';
569
+ const chunkSize = 64 * 1024;
570
+ const totalChunks = Math.max(1, Math.ceil(fileToUpload.size / chunkSize));
571
+ const msgId = this.next_msg_id();
572
+ const uploadStart = new Promise((resolve, reject) => {
573
+ const timeout = window.setTimeout(() => {
574
+ this.pendingUploadStarts.delete(msgId);
575
+ reject(new Error('Upload start timeout'));
576
+ }, 10_000);
577
+ this.pendingUploadStarts.set(msgId, {
578
+ timeout,
579
+ resolve,
580
+ reject,
581
+ });
582
+ });
583
+ try {
584
+ this.channel.send_sftp_upload_start(this.nodeId, this.session_id, fileToUpload.name, this.current_dir, totalChunks, BigInt(fileToUpload.size), msgId);
585
+ const uploadId = await uploadStart;
586
+ let uploadedBytes = 0;
587
+ const startedAt = performance.now();
588
+ for (let chunkIndex = 0; chunkIndex < totalChunks; chunkIndex += 1) {
589
+ if (uploadToken !== this.activeUploadToken) {
590
+ throw new Error('Upload cancelled');
591
+ }
592
+ const start = chunkIndex * chunkSize;
593
+ const end = Math.min(start + chunkSize, fileToUpload.size);
594
+ const chunkBuffer = new Uint8Array(await fileToUpload.slice(start, end).arrayBuffer());
595
+ await new Promise((resolve, reject) => {
596
+ const key = `${uploadId}_${chunkIndex}`;
597
+ const timeout = window.setTimeout(() => {
598
+ this.pendingUploadAcks.delete(key);
599
+ reject(new Error(`Upload chunk ${chunkIndex + 1} timed out`));
600
+ }, 30_000);
601
+ this.pendingUploadAcks.set(key, {
602
+ timeout,
603
+ resolve,
604
+ reject,
605
+ });
606
+ this.channel.send_sftp_upload_chunk(this.nodeId, this.session_id, uploadId, chunkIndex, chunkBuffer.length, chunkBuffer, null);
607
+ });
608
+ uploadedBytes += chunkBuffer.length;
609
+ this.update_upload_progress(uploadedBytes, fileToUpload.size, startedAt);
610
+ }
611
+ this.upload_progress = 100;
612
+ this.upload_finished = true;
613
+ this.status = 'Connected';
614
+ this.refresh_directory();
615
+ }
616
+ catch (err) {
617
+ if (err.message !== 'Upload cancelled') {
618
+ this.show_error = true;
619
+ this.error_message = err instanceof Error ? err.message : 'Upload failed';
620
+ }
621
+ this.upload_finished = false;
622
+ this.status = 'Connected';
623
+ }
624
+ }
625
+ handle_op_result(web) {
626
+ if (web.msg_id === undefined) {
627
+ return;
628
+ }
629
+ const pending = this.pendingOps.get(web.msg_id);
630
+ if (!pending) {
631
+ return;
632
+ }
633
+ window.clearTimeout(pending.timeout);
634
+ this.pendingOps.delete(web.msg_id);
635
+ pending.resolve(web.result);
636
+ }
637
+ /**
638
+ * Send one filesystem operation and wait for its single answer.
639
+ *
640
+ * There are three outcomes: an `SFTPOpResult` resolves it, an `Error` frame
641
+ * carrying the same `msg_id` rejects it, and the timeout covers the case
642
+ * worth naming — an agent built before these frames existed logs the
643
+ * unknown frame and drops it, so silence usually means "too old" rather
644
+ * than "slow", and the message says so.
645
+ */
646
+ run_op(verb, send, timeoutMs = 30_000) {
647
+ if (!this.session_id) {
648
+ return Promise.reject(new Error('No active SFTP session.'));
649
+ }
650
+ const msgId = this.next_msg_id();
651
+ return new Promise((resolve, reject) => {
652
+ const timeout = window.setTimeout(() => {
653
+ this.pendingOps.delete(msgId);
654
+ reject(new Error(`Timed out trying to ${verb}. This node's agent may be too old to support it.`));
655
+ }, timeoutMs);
656
+ this.pendingOps.set(msgId, { verb, timeout, resolve, reject });
657
+ try {
658
+ send(msgId);
659
+ }
660
+ catch (err) {
661
+ window.clearTimeout(timeout);
662
+ this.pendingOps.delete(msgId);
663
+ reject(err instanceof Error ? err : new Error(String(err)));
664
+ }
665
+ });
666
+ }
667
+ error_text(err) {
668
+ return err instanceof Error ? err.message : String(err);
669
+ }
670
+ /**
671
+ * A listing entry carries its *parent* directory in `path`, so a full path
672
+ * is always the join of the two.
673
+ */
674
+ item_path(item) {
675
+ return this.join_path(item.path, item.name);
676
+ }
677
+ join_path(dir, name) {
678
+ if (!dir || dir === '/') {
679
+ return `/${name}`;
680
+ }
681
+ return dir.endsWith('/') ? `${dir}${name}` : `${dir}/${name}`;
682
+ }
683
+ /** Names the remote would reject, or that would silently mean something else. */
684
+ invalid_name(name) {
685
+ if (!name) {
686
+ return 'Enter a name.';
687
+ }
688
+ if (name === '.' || name === '..') {
689
+ return 'That name is reserved.';
690
+ }
691
+ if (name.includes('/')) {
692
+ return 'A name cannot contain "/".';
693
+ }
694
+ if (name.includes('\u0000')) {
695
+ return 'A name cannot contain a null byte.';
696
+ }
697
+ return '';
698
+ }
699
+ handle_tunnel_data(web) {
700
+ console.log('received tunnel data:', web);
701
+ }
702
+ handle_tunnel_closed(_web_) {
703
+ // this.session_id = undefined;
704
+ // this.inputMode = InputMode.Default;
705
+ this.clear_creds_buffer();
706
+ // this.terminal.reset();
707
+ // this.terminal.writeln("Connection closed.");
708
+ this.close_comms();
709
+ }
710
+ open_comms() {
711
+ const endpoint = `${this.create_web_socket_endpoint()}/api/web/ws`;
712
+ if (this.channelFactory) {
713
+ this.channel = this.channelFactory(endpoint, this.nodeId, this.serverId || undefined);
714
+ }
715
+ else if (this.serverId) {
716
+ this.channel = new protocol.Channel(endpoint, this.nodeId, this.serverId);
717
+ }
718
+ else {
719
+ this.channel = new protocol.Channel(endpoint, this.nodeId);
720
+ }
721
+ this.channel.on_connection_open(() => {
722
+ this.connectionStateChanged.emit([protocol.ConnectionState.Connected]);
723
+ this.channel.authenticate(this.token, this.nodeId);
724
+ this.status = 'Authenticating...';
725
+ });
726
+ this.channel.on_connection_close(() => {
727
+ this.connectionStateChanged.emit([protocol.ConnectionState.Disconnected]);
728
+ this.status = 'Disconnected';
729
+ });
730
+ this.channel.on_connection_error((err) => {
731
+ this.connectionStateChanged.emit([protocol.ConnectionState.Error, err]);
732
+ this.status = 'Error ' + err.message;
733
+ });
734
+ this.channel.on_connection_message((_raw_) => {
735
+ //
736
+ });
737
+ this.channel.on_protocol_message((msg) => {
738
+ const { web } = msg.data;
739
+ switch (web.type) {
740
+ case protocol.ProtocolMessageType.Error:
741
+ this.handle_error(web);
742
+ break;
743
+ case protocol.ProtocolMessageType.AuthSuccess:
744
+ this.handle_auth_success(web);
745
+ break;
746
+ case protocol.ProtocolMessageType.TunnelOpened:
747
+ this.handle_tunnel_opened(web);
748
+ break;
749
+ case protocol.ProtocolMessageType.TunnelClosed:
750
+ this.handle_tunnel_closed(web);
751
+ break;
752
+ case protocol.ProtocolMessageType.TunnelData:
753
+ this.handle_tunnel_data(web);
754
+ break;
755
+ case protocol.ProtocolMessageType.SFTPListItems:
756
+ this.handle_sftp_list_items(web);
757
+ break;
758
+ case protocol.ProtocolMessageType.SFTPUploadStartResponse:
759
+ this.handle_upload_start_response(web);
760
+ break;
761
+ case protocol.ProtocolMessageType.SFTPUploadChunkAck:
762
+ this.handle_upload_chunk_ack(web);
763
+ break;
764
+ case protocol.ProtocolMessageType.SFTPDownloadStartResponse:
765
+ this.handle_download_start_response(web);
766
+ break;
767
+ case protocol.ProtocolMessageType.SFTPDownloadChunk:
768
+ this.handle_download_chunk(web);
769
+ break;
770
+ case protocol.ProtocolMessageType.SFTPOpResult:
771
+ this.handle_op_result(web);
772
+ break;
773
+ default:
774
+ console.warn('Unhandled protocol message type:', web);
775
+ }
776
+ });
777
+ }
778
+ close_comms() {
779
+ this.cancel_active_upload();
780
+ this.cancel_active_download();
781
+ this.clear_pending_operations();
782
+ if (!this.channel) {
783
+ return;
784
+ }
785
+ this.channel.stop_heartbeat();
786
+ this.channel.disconnect();
787
+ }
788
+ clear_creds_buffer() {
789
+ // this.usernameBuffer = "";
790
+ // this.passwordBuffer = "";
791
+ }
792
+ reset_session_state() {
793
+ // this.session_id = undefined;
794
+ // this.inputMode = InputMode.Default;
795
+ this.clear_creds_buffer();
796
+ }
797
+ list_breadcrumb(path) {
798
+ this.show_loader = true;
799
+ this.selected_item = null;
800
+ this.channel.send_sftp_list_data(this.nodeId, this.session_id, path);
801
+ }
802
+ go_to_parent_directory() {
803
+ if (!this.session_id) {
804
+ return;
805
+ }
806
+ if (this.current_dir === '/') {
807
+ return;
808
+ }
809
+ const parent = this.breadcrumbs[this.breadcrumbs.length - 2]?.path || '/';
810
+ this.list_breadcrumb(parent);
811
+ }
812
+ refresh_directory() {
813
+ if (!this.session_id) {
814
+ return;
815
+ }
816
+ this.list_breadcrumb(this.current_dir);
817
+ }
818
+ disconnect_session() {
819
+ this.close_comms();
820
+ this.session_id = undefined;
821
+ this.show_loader = false;
822
+ this.show_content = false;
823
+ this.breadcrumbs = [];
824
+ this.current_dir = '.';
825
+ this.listing = [];
826
+ this.show_navigation = false;
827
+ this.show_login_screen_username = false;
828
+ this.show_login_screen_password = false;
829
+ this.show_login_screen = false;
830
+ this.show_upload_modal = false;
831
+ this.show_download_modal = false;
832
+ this.show_delete_modal = false;
833
+ this.upload_progress = 0;
834
+ this.download_progress = 0;
835
+ this.upload_finished = false;
836
+ this.download_finished = false;
837
+ this.delete_loading = false;
838
+ this.delete_file_name = '';
839
+ this.delete_error = '';
840
+ this.delete_is_dir = false;
841
+ this.delete_recursive = false;
842
+ this.prompt_kind = null;
843
+ this.prompt_value = '';
844
+ this.prompt_error = '';
845
+ this.prompt_busy = false;
846
+ this.chmod_target = null;
847
+ this.chmod_error = '';
848
+ this.chmod_busy = false;
849
+ this.show_editor = false;
850
+ this.editor_busy = '';
851
+ this.editor_error = '';
852
+ this.editor_confirm_discard = false;
853
+ this.editor_loaded = false;
854
+ this.filter = '';
855
+ this.version = '';
856
+ this.status = 'Disconnected';
857
+ }
858
+ on_file_row_action(item, event) {
859
+ event.preventDefault();
860
+ event.stopPropagation();
861
+ if (item.kind !== 'File') {
862
+ return;
863
+ }
864
+ void this.start_download(item);
865
+ }
866
+ on_file_delete_action(item, event) {
867
+ event.preventDefault();
868
+ event.stopPropagation();
869
+ this.selected_item = item;
870
+ this.delete_file_name = item.name;
871
+ this.delete_is_dir = item.kind === 'Folder';
872
+ this.delete_recursive = false;
873
+ this.delete_error = '';
874
+ this.delete_loading = false;
875
+ this.show_delete_modal = true;
876
+ }
877
+ cancel_delete() {
878
+ if (this.delete_loading) {
879
+ return;
880
+ }
881
+ this.show_delete_modal = false;
882
+ this.delete_file_name = '';
883
+ this.delete_error = '';
884
+ this.delete_is_dir = false;
885
+ this.delete_recursive = false;
886
+ }
887
+ async confirm_delete() {
888
+ if (this.delete_loading) {
889
+ return;
890
+ }
891
+ const target = this.selected_item;
892
+ if (!this.session_id || !target) {
893
+ this.show_delete_modal = false;
894
+ return;
895
+ }
896
+ const path = this.item_path(target);
897
+ const recursive = this.delete_is_dir && this.delete_recursive;
898
+ this.delete_loading = true;
899
+ this.delete_error = '';
900
+ this.show_error = false;
901
+ this.status = `Deleting ${target.name}...`;
902
+ try {
903
+ // A recursive delete walks the tree one entry at a time over SSH,
904
+ // so it earns a far longer leash than the other operations.
905
+ await this.run_op('delete', (msgId) => this.channel.send_sftp_remove(this.nodeId, this.session_id, path, recursive, msgId), recursive ? 300_000 : 30_000);
906
+ this.delete_loading = false;
907
+ this.show_delete_modal = false;
908
+ this.delete_file_name = '';
909
+ this.delete_is_dir = false;
910
+ this.delete_recursive = false;
911
+ this.status = 'Connected';
912
+ this.refresh_directory();
913
+ }
914
+ catch (err) {
915
+ this.delete_loading = false;
916
+ this.delete_error = this.error_text(err);
917
+ this.status = 'Connected';
918
+ }
919
+ }
920
+ open_mkdir() {
921
+ if (!this.session_id) {
922
+ return;
923
+ }
924
+ this.prompt_kind = 'mkdir';
925
+ this.prompt_value = '';
926
+ this.prompt_error = '';
927
+ this.prompt_busy = false;
928
+ }
929
+ on_rename_action(item, event) {
930
+ event.preventDefault();
931
+ event.stopPropagation();
932
+ if (!this.session_id) {
933
+ return;
934
+ }
935
+ this.selected_item = item;
936
+ this.prompt_kind = 'rename';
937
+ this.prompt_value = item.name;
938
+ this.prompt_error = '';
939
+ this.prompt_busy = false;
940
+ }
941
+ close_prompt() {
942
+ if (this.prompt_busy) {
943
+ return;
944
+ }
945
+ this.prompt_kind = null;
946
+ this.prompt_value = '';
947
+ this.prompt_error = '';
948
+ this.promptInputEl = undefined;
949
+ }
950
+ async submit_prompt() {
951
+ if (this.prompt_busy || !this.session_id) {
952
+ return;
953
+ }
954
+ const kind = this.prompt_kind;
955
+ const name = this.prompt_value.trim();
956
+ const invalid = this.invalid_name(name);
957
+ if (invalid) {
958
+ this.prompt_error = invalid;
959
+ return;
960
+ }
961
+ const target = this.selected_item;
962
+ if (kind === 'rename' && target && name === target.name) {
963
+ this.close_prompt();
964
+ return;
965
+ }
966
+ this.prompt_busy = true;
967
+ this.prompt_error = '';
968
+ this.show_error = false;
969
+ try {
970
+ if (kind === 'mkdir') {
971
+ const path = this.join_path(this.current_dir, name);
972
+ this.status = `Creating ${name}...`;
973
+ await this.run_op('create the folder', (msgId) => this.channel.send_sftp_mkdir(this.nodeId, this.session_id, path, msgId));
974
+ }
975
+ else if (kind === 'rename' && target) {
976
+ // `to` is a full path, so the same call would move the entry if
977
+ // the dialog ever offered a destination directory.
978
+ const from = this.item_path(target);
979
+ const to = this.join_path(target.path, name);
980
+ this.status = `Renaming ${target.name}...`;
981
+ await this.run_op('rename', (msgId) => this.channel.send_sftp_rename(this.nodeId, this.session_id, from, to, msgId));
982
+ }
983
+ else {
984
+ this.prompt_busy = false;
985
+ this.close_prompt();
986
+ return;
987
+ }
988
+ this.prompt_busy = false;
989
+ this.prompt_kind = null;
990
+ this.prompt_value = '';
991
+ this.promptInputEl = undefined;
992
+ this.status = 'Connected';
993
+ this.refresh_directory();
994
+ }
995
+ catch (err) {
996
+ this.prompt_busy = false;
997
+ this.prompt_error = this.error_text(err);
998
+ this.status = 'Connected';
999
+ }
1000
+ }
1001
+ on_chmod_action(item, event) {
1002
+ event.preventDefault();
1003
+ event.stopPropagation();
1004
+ if (!this.session_id) {
1005
+ return;
1006
+ }
1007
+ this.selected_item = item;
1008
+ this.chmod_target = item;
1009
+ this.chmod_mode = (item.attributes.permissions ?? 0) & 0o7777;
1010
+ this.chmod_error = '';
1011
+ this.chmod_busy = false;
1012
+ }
1013
+ close_chmod() {
1014
+ if (this.chmod_busy) {
1015
+ return;
1016
+ }
1017
+ this.chmod_target = null;
1018
+ this.chmod_error = '';
1019
+ }
1020
+ toggle_chmod_bit(bit) {
1021
+ if (this.chmod_busy) {
1022
+ return;
1023
+ }
1024
+ this.chmod_mode = (this.chmod_mode ^ bit) & 0o7777;
1025
+ }
1026
+ on_chmod_octal_input(value) {
1027
+ const digits = value.trim();
1028
+ if (!/^[0-7]{1,4}$/.test(digits)) {
1029
+ this.chmod_error = 'Enter up to four octal digits, 0-7.';
1030
+ return;
1031
+ }
1032
+ this.chmod_error = '';
1033
+ this.chmod_mode = parseInt(digits, 8) & 0o7777;
1034
+ }
1035
+ async submit_chmod() {
1036
+ const target = this.chmod_target;
1037
+ if (this.chmod_busy || !this.session_id || !target) {
1038
+ return;
1039
+ }
1040
+ const path = this.item_path(target);
1041
+ const mode = this.chmod_mode & 0o7777;
1042
+ this.chmod_busy = true;
1043
+ this.chmod_error = '';
1044
+ this.show_error = false;
1045
+ this.status = `Setting permissions on ${target.name}...`;
1046
+ try {
1047
+ await this.run_op('change permissions', (msgId) => this.channel.send_sftp_chmod(this.nodeId, this.session_id, path, mode, msgId));
1048
+ this.chmod_busy = false;
1049
+ this.chmod_target = null;
1050
+ this.status = 'Connected';
1051
+ this.refresh_directory();
1052
+ }
1053
+ catch (err) {
1054
+ this.chmod_busy = false;
1055
+ this.chmod_error = this.error_text(err);
1056
+ this.status = 'Connected';
1057
+ }
1058
+ }
1059
+ async on_edit_action(item, event) {
1060
+ event.preventDefault();
1061
+ event.stopPropagation();
1062
+ if (!this.session_id || item.kind !== 'File') {
1063
+ return;
1064
+ }
1065
+ const path = this.item_path(item);
1066
+ this.selected_item = item;
1067
+ this.show_editor = true;
1068
+ this.editorPath = path;
1069
+ this.editor_name = item.name;
1070
+ this.editor_text = '';
1071
+ this.editor_saved_text = '';
1072
+ this.editor_error = '';
1073
+ this.editor_confirm_discard = false;
1074
+ this.editor_loaded = false;
1075
+ this.editor_busy = 'loading';
1076
+ this.status = `Opening ${item.name}...`;
1077
+ try {
1078
+ const answer = await this.run_op('open the file', (msgId) => this.channel.send_sftp_read_file(this.nodeId, this.session_id, path, msgId), 60_000);
1079
+ if (answer.result !== 'FileContents') {
1080
+ throw new Error('The agent answered without any file contents.');
1081
+ }
1082
+ const text = this.decode_text(answer.contents instanceof Uint8Array ? answer.contents : new Uint8Array(answer.contents));
1083
+ this.editor_text = text;
1084
+ this.editor_saved_text = text;
1085
+ this.editor_loaded = true;
1086
+ this.editor_busy = '';
1087
+ this.status = 'Connected';
1088
+ }
1089
+ catch (err) {
1090
+ this.editor_busy = '';
1091
+ this.editor_error = this.error_text(err);
1092
+ this.status = 'Connected';
1093
+ }
1094
+ }
1095
+ /**
1096
+ * Refuse binary rather than mangle it. A lossy decode looks fine on screen
1097
+ * and then writes replacement characters over the real bytes on save, so
1098
+ * anything that is not valid UTF-8 is sent to the download button instead.
1099
+ */
1100
+ decode_text(bytes) {
1101
+ if (bytes.includes(0)) {
1102
+ throw new Error('This looks like a binary file. Download it instead of editing it here.');
1103
+ }
1104
+ try {
1105
+ return new TextDecoder('utf-8', { fatal: true }).decode(bytes);
1106
+ }
1107
+ catch {
1108
+ throw new Error('This file is not valid UTF-8. Download it instead of editing it here.');
1109
+ }
1110
+ }
1111
+ editor_is_dirty() {
1112
+ return this.editor_loaded && this.editor_text !== this.editor_saved_text;
1113
+ }
1114
+ close_editor(force = false) {
1115
+ if (this.editor_busy === 'saving') {
1116
+ return;
1117
+ }
1118
+ if (!force && this.editor_is_dirty()) {
1119
+ this.editor_confirm_discard = true;
1120
+ return;
1121
+ }
1122
+ this.show_editor = false;
1123
+ this.editor_confirm_discard = false;
1124
+ this.editor_loaded = false;
1125
+ this.editorPath = '';
1126
+ this.editor_name = '';
1127
+ this.editor_text = '';
1128
+ this.editor_saved_text = '';
1129
+ this.editor_error = '';
1130
+ this.editor_busy = '';
1131
+ this.editorTextEl = undefined;
1132
+ }
1133
+ async save_editor() {
1134
+ if (this.editor_busy || !this.session_id || !this.editorPath) {
1135
+ return;
1136
+ }
1137
+ const path = this.editorPath;
1138
+ const text = this.editor_text;
1139
+ this.editor_busy = 'saving';
1140
+ this.editor_error = '';
1141
+ this.show_error = false;
1142
+ this.status = `Saving ${this.editor_name}...`;
1143
+ try {
1144
+ await this.run_op('save the file', (msgId) => this.channel.send_sftp_write_file(this.nodeId, this.session_id, path, new TextEncoder().encode(text), msgId), 60_000);
1145
+ this.editor_saved_text = text;
1146
+ this.editor_busy = '';
1147
+ this.status = 'Connected';
1148
+ this.refresh_directory();
1149
+ }
1150
+ catch (err) {
1151
+ this.editor_busy = '';
1152
+ this.editor_error = this.error_text(err);
1153
+ this.status = 'Connected';
1154
+ }
1155
+ }
1156
+ toggle_sort(key) {
1157
+ if (this.sort_key === key) {
1158
+ this.sort_asc = !this.sort_asc;
1159
+ return;
1160
+ }
1161
+ this.sort_key = key;
1162
+ this.sort_asc = true;
1163
+ }
1164
+ /**
1165
+ * Folders stay above files whichever way the sort runs: a listing that
1166
+ * scatters directories through the files is harder to scan, not more sorted.
1167
+ */
1168
+ visible_listing() {
1169
+ const needle = this.filter.trim().toLowerCase();
1170
+ const rows = needle
1171
+ ? this.listing.filter((item) => item.name.toLowerCase().includes(needle))
1172
+ : [...this.listing];
1173
+ const direction = this.sort_asc ? 1 : -1;
1174
+ return rows.sort((a, b) => {
1175
+ if (a.kind !== b.kind) {
1176
+ return a.kind === 'Folder' ? -1 : 1;
1177
+ }
1178
+ switch (this.sort_key) {
1179
+ case 'size':
1180
+ return direction * ((a.attributes.size ?? 0) - (b.attributes.size ?? 0));
1181
+ case 'modified':
1182
+ return direction * ((a.attributes.modified ?? 0) - (b.attributes.modified ?? 0));
1183
+ default:
1184
+ return direction * a.name.localeCompare(b.name, undefined, {
1185
+ numeric: true,
1186
+ sensitivity: 'base',
1187
+ });
1188
+ }
1189
+ });
1190
+ }
1191
+ sort_indicator(key) {
1192
+ if (this.sort_key !== key) {
1193
+ return '';
1194
+ }
1195
+ return this.sort_asc ? ' \u25b2' : ' \u25bc';
1196
+ }
1197
+ /** Keyboard shortcuts, scoped to the file table so the page keeps its own. */
1198
+ on_listing_keydown(event) {
1199
+ if (this.prompt_kind || this.chmod_target || this.show_editor || this.show_delete_modal) {
1200
+ return;
1201
+ }
1202
+ const item = this.selected_item;
1203
+ switch (event.key) {
1204
+ case 'Backspace':
1205
+ event.preventDefault();
1206
+ this.go_to_parent_directory();
1207
+ break;
1208
+ case 'F5':
1209
+ event.preventDefault();
1210
+ this.refresh_directory();
1211
+ break;
1212
+ case 'F2':
1213
+ if (item) {
1214
+ event.preventDefault();
1215
+ this.on_rename_action(item, event);
1216
+ }
1217
+ break;
1218
+ case 'Delete':
1219
+ if (item) {
1220
+ event.preventDefault();
1221
+ this.on_file_delete_action(item, event);
1222
+ }
1223
+ break;
1224
+ case 'Enter':
1225
+ if (item) {
1226
+ event.preventDefault();
1227
+ this.list_directory(item);
1228
+ }
1229
+ break;
1230
+ }
1231
+ }
1232
+ on_modal_keydown(event, close) {
1233
+ if (event.key === 'Escape') {
1234
+ event.preventDefault();
1235
+ event.stopPropagation();
1236
+ close();
1237
+ }
1238
+ }
1239
+ /** Focus a dialog's field as it appears, without re-focusing on every render. */
1240
+ focus_once(el, current, keep) {
1241
+ if (!el || el === current) {
1242
+ return;
1243
+ }
1244
+ keep(el);
1245
+ requestAnimationFrame(() => el.focus());
1246
+ }
1247
+ open_upload_picker() {
1248
+ this.uploadInputEl?.click();
1249
+ }
1250
+ on_upload_selected(event) {
1251
+ const input = event.target;
1252
+ const selectedFile = input.files?.[0];
1253
+ if (!selectedFile) {
1254
+ return;
1255
+ }
1256
+ void this.upload_file(selectedFile);
1257
+ input.value = '';
1258
+ }
1259
+ cancel_upload() {
1260
+ this.cancel_active_upload();
1261
+ this.show_upload_modal = false;
1262
+ this.upload_file_name = '';
1263
+ this.upload_speed = '--';
1264
+ this.status = 'Connected';
1265
+ this.refresh_directory();
1266
+ }
1267
+ cancel_download() {
1268
+ this.cancel_active_download();
1269
+ this.show_download_modal = false;
1270
+ this.download_file_name = '';
1271
+ this.download_speed = '--';
1272
+ this.status = 'Connected';
1273
+ this.refresh_directory();
1274
+ }
1275
+ is_selected(item) {
1276
+ if (!this.selected_item) {
1277
+ return false;
1278
+ }
1279
+ return this.selected_item.path === item.path &&
1280
+ this.selected_item.name === item.name;
1281
+ }
1282
+ list_directory(entry) {
1283
+ if (!this.session_id) {
1284
+ console.warn('No active session. Cannot list directory.');
1285
+ return;
1286
+ }
1287
+ if (entry.kind === 'File') {
1288
+ console.warn('Cannot list directory of a file. Ignoring click.');
1289
+ this.selected_item = entry;
1290
+ return;
1291
+ }
1292
+ const path = this.item_path(entry);
1293
+ if (path === this.current_dir) {
1294
+ console.warn('Already in this directory. Ignoring click.');
1295
+ return;
1296
+ }
1297
+ this.show_loader = true;
1298
+ this.selected_item = null;
1299
+ this.channel.send_sftp_list_data(this.nodeId, this.session_id, path);
1300
+ }
1301
+ format_size(size) {
1302
+ if (size === undefined || Number.isNaN(size)) {
1303
+ return '-';
1304
+ }
1305
+ if (size < 1024) {
1306
+ return `${size} B`;
1307
+ }
1308
+ const units = ['KB', 'MB', 'GB', 'TB', 'PB'];
1309
+ let value = size;
1310
+ let unitIndex = -1;
1311
+ while (value >= 1024 && unitIndex < units.length - 1) {
1312
+ value /= 1024;
1313
+ unitIndex += 1;
1314
+ }
1315
+ const rounded = value >= 10 ? value.toFixed(1) : value.toFixed(2);
1316
+ return `${rounded} ${units[unitIndex]}`;
1317
+ }
1318
+ mode_type_to_char(mode, kind) {
1319
+ const S_IFMT = 0o170000;
1320
+ const type = mode & S_IFMT;
1321
+ switch (type) {
1322
+ case 0o140000: return 's';
1323
+ case 0o120000: return 'l';
1324
+ case 0o100000: return '-';
1325
+ case 0o060000: return 'b';
1326
+ case 0o040000: return 'd';
1327
+ case 0o020000: return 'c';
1328
+ case 0o010000: return 'p';
1329
+ default:
1330
+ return kind === 'Folder' ? 'd' : '-';
1331
+ }
1332
+ }
1333
+ format_permissions(permissions, kind) {
1334
+ if (permissions === undefined || permissions === null) {
1335
+ return '-';
1336
+ }
1337
+ if (typeof permissions === 'string') {
1338
+ const value = permissions.trim();
1339
+ if (/^[bcdlps-][rwxStTs-]{9}$/.test(value)) {
1340
+ return value;
1341
+ }
1342
+ if (/^[0-7]{3,4}$/.test(value)) {
1343
+ const mode = parseInt(value, 8);
1344
+ return this.format_permissions(mode, kind);
1345
+ }
1346
+ if (/^\d+$/.test(value)) {
1347
+ const mode = parseInt(value, 10);
1348
+ return this.format_permissions(mode, kind);
1349
+ }
1350
+ return value || '-';
1351
+ }
1352
+ const mode = permissions;
1353
+ const typeChar = this.mode_type_to_char(mode, kind);
1354
+ const chars = [
1355
+ mode & 0o400 ? 'r' : '-',
1356
+ mode & 0o200 ? 'w' : '-',
1357
+ mode & 0o100 ? 'x' : '-',
1358
+ mode & 0o040 ? 'r' : '-',
1359
+ mode & 0o020 ? 'w' : '-',
1360
+ mode & 0o010 ? 'x' : '-',
1361
+ mode & 0o004 ? 'r' : '-',
1362
+ mode & 0o002 ? 'w' : '-',
1363
+ mode & 0o001 ? 'x' : '-',
1364
+ ];
1365
+ if (mode & 0o4000) {
1366
+ chars[2] = chars[2] === 'x' ? 's' : 'S';
1367
+ }
1368
+ if (mode & 0o2000) {
1369
+ chars[5] = chars[5] === 'x' ? 's' : 'S';
1370
+ }
1371
+ if (mode & 0o1000) {
1372
+ chars[8] = chars[8] === 'x' ? 't' : 'T';
1373
+ }
1374
+ return `${typeChar}${chars.join('')}`;
1375
+ }
1376
+ render() {
1377
+ return (index.h(index.Host, { key: '9e2edc1a72c3a74b26feea2faa08b9f0a2e37a0c', class: {
1378
+ 'default': !this.max,
1379
+ 'max': this.max,
1380
+ } }, index.h("section", { key: '72fae8227792615a5452f9b01ec8230c2c10e2a9', class: "listing" }, !this.hideHeader &&
1381
+ index.h("header", { key: '14632fcb4575678418132892308cfea1903fadab' }, index.h("section", { key: '3ea3fb2cab9d4cdf36af3876235579562a7acbef', class: "title" }, index.h("img", { key: 'fd0badaae9b0d7b426ddece5faf7ea3515e9bbf0', src: phirepassSftpClientLogoSvg, alt: "SFTP Client" }), index.h("div", { key: '4eece24a618c119861f5435eb3f1ae8a5bae4966', class: "text" }, index.h("div", { key: '84b45196e1a1609451413cf8ea369b60cd7f5ec6', class: "name" }, this.name), index.h("div", { key: '45da97e659ecbaa69e74d1789a1b7961b760a753', class: "description" }, this.description))), index.h("section", { key: '9177dcc02b911e95870c5f55fc48f741895a0b75', class: "actions" }, index.h("div", { key: '468f341eebf7569c2a1c4aeea09d56644e5b6161', class: "action", onClick: () => this.toggle_max() }, index.h("img", { key: '203b54e42cddc50bf068a49fa7f88c846ecaa2c9', src: phirepassSftpClientMaxSvg, alt: "Maximize" })))), index.h("main", { key: 'c0f757aaa07734199228e3dc520c98694bc6548d' }, this.show_navigation && index.h("nav", { key: '295440219080af5fa33566300fb1036998da399c', class: "navigation" }, index.h("div", { key: 'c9b63f04de675559d2e2bbb876115c63e00bfbd2', class: "breadcrumbs" }, this.breadcrumbs.map((crumb, index$1, breadcrumbs) => (index.h("span", { key: index$1, class: "breadcrumb-container" }, index.h("span", { key: index$1, onClick: () => this.list_breadcrumb(crumb.path), class: "breadcrumb" }, crumb.label), index$1 < breadcrumbs.length - 1 && index.h("img", { class: "arrow", src: phirepassSftpClientChevronSvg }))))), index.h("section", { key: '325ccd4be07d61df1e16956b5818683feb70c52f', class: "actions", "aria-label": "SFTP actions" }, index.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 }), index.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" }, index.h("img", { key: '309e0fdb89aa4d119a5193f1803ebdc117e55105', src: phirepassSftpClientGoUpSvg, alt: "Go up" })), index.h("button", { key: '5f451e50801f10b88a3436515d792b1015bf48bb', type: "button", class: "action", onClick: () => this.refresh_directory(), title: "Refresh", "aria-label": "Refresh" }, index.h("img", { key: 'aa673b81504e65e78043c328f94d3a9dd02f696a', src: phirepassSftpClientRefreshSvg, alt: "Refresh" })), index.h("button", { key: '963f5abf044c207f9e42babe9e029ac052521f36', type: "button", class: "action", onClick: () => this.open_mkdir(), title: "New folder", "aria-label": "New folder" }, index.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" }, index.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" }), index.h("line", { key: '9a759bd7ac97c4e8ebf75c4d54e8f207999634c2', x1: "12", x2: "12", y1: "10", y2: "16" }), index.h("line", { key: '4591434cdbb6a7d3a1a0212409fe38e21e02a52e', x1: "9", x2: "15", y1: "13", y2: "13" }))), index.h("button", { key: '301d406858c2d9a4656a342b49e663e76a7f1970', type: "button", class: "action", onClick: () => this.open_upload_picker(), title: "Upload", "aria-label": "Upload" }, index.h("img", { key: '36ff8480d3acf65282d6ef648349327eb3432237', src: phirepassSftpClientUploadSvg, alt: "Upload" })), index.h("button", { key: '3fa19d5e17ef2e2a8fc926c8ba6994a4a30a1825', type: "button", class: "action disconnect", onClick: () => this.disconnect_session(), title: "Disconnect", "aria-label": "Disconnect" }, "DISCONNECT"))), index.h("input", { key: 'f5cf6cc13d4b760b538d630467972c8add2df490', type: "file", ref: (el) => this.uploadInputEl = el, onChange: (event) => this.on_upload_selected(event), style: { display: 'none' } }), this.show_content && index.h("div", { key: 'd69a7009192adc292cf3ccf4de6a4f059b46fa0e', class: "content", tabindex: 0, onKeyDown: (event) => this.on_listing_keydown(event) }, index.h("table", { key: '2f00d85024b3e4642925f488a34d228dd056a2ce' }, index.h("thead", { key: '611091a29f97e218f5282e11c7c1accdc1be5732' }, index.h("tr", { key: '5f0d04ff8a5009852af02472f4261b9a95733a3c' }, index.h("th", { key: '6df9558b86b3d3161920d5f94e8df0cf47ee9c80', class: "sortable", onClick: () => this.toggle_sort('name'), title: "Sort by name" }, "Name", this.sort_indicator('name')), index.h("th", { key: '83384582ac59c07f65526cfc5fd1359b5a0cd912', class: "sortable", onClick: () => this.toggle_sort('size'), title: "Sort by size" }, "Size", this.sort_indicator('size')), index.h("th", { key: 'cbc16eafd7fb17c9d79b5612502140bc9a16a3cb' }, "Permissions"), index.h("th", { key: '25d802dd84a6cc3eda222d5a732e05010c405f31' }, "Owner"), index.h("th", { key: 'cf5f9df11baae69f664724c6a79df0a95a5189a8', class: "sortable", onClick: () => this.toggle_sort('modified'), title: "Sort by modified date" }, "Modified", this.sort_indicator('modified')), index.h("th", { key: '9c8b9515c81245656d89ea65ee091a70606c1a93', class: "action-col", "aria-label": "Actions" }))), index.h("tbody", { key: '40f8ec5d38a0601af3520891c4a9d35b2da2c32f' }, this.visible_listing().map((item, index$1) => (index.h("tr", { key: index$1, class: {
1382
+ 'selected': this.is_selected(item),
1383
+ }, onClick: () => this.list_directory(item) }, index.h("td", null, item.kind === 'Folder' ? index.h("img", { class: "kind", src: phirepassSftpClientFolderSvg, alt: "Folder" }) : index.h("img", { class: "kind", src: phirepassSftpClientFileSvg, alt: "File" }), index.h("span", { class: `name ${item.kind.toLowerCase()}` }, item.name)), index.h("td", null, item.kind === 'Folder' ? '-' : this.format_size(item.attributes.size)), index.h("td", null, this.format_permissions(item.attributes.permissions, item.kind)), index.h("td", null, item.attributes.user ?? '-'), index.h("td", null, new Date(item.attributes.modified * 1000).toLocaleString()), index.h("td", { class: "action-col" }, index.h("div", { class: "file-actions" }, item.kind === 'File' &&
1384
+ index.h("button", { type: "button", class: "file-action", onClick: (event) => this.on_edit_action(item, event), title: "Edit", "aria-label": `Edit ${item.name}` }, index.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" }, index.h("path", { d: "M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" }), index.h("path", { d: "M18.5 2.5a2.12 2.12 0 0 1 3 3L12 15l-4 1 1-4Z" }))), item.kind === 'File' &&
1385
+ index.h("button", { type: "button", class: "file-action", onClick: (event) => this.on_file_row_action(item, event), title: "Download", "aria-label": `Download ${item.name}` }, index.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" }, index.h("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }), index.h("polyline", { points: "7 10 12 15 17 10" }), index.h("line", { x1: "12", x2: "12", y1: "15", y2: "3" }))), index.h("button", { type: "button", class: "file-action", onClick: (event) => this.on_rename_action(item, event), title: "Rename", "aria-label": `Rename ${item.name}` }, index.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" }, index.h("path", { d: "M12 20h9" }), index.h("path", { d: "M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z" }))), index.h("button", { type: "button", class: "file-action", onClick: (event) => this.on_chmod_action(item, event), title: "Permissions", "aria-label": `Change permissions on ${item.name}` }, index.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" }, index.h("rect", { width: "18", height: "11", x: "3", y: "11", rx: "2", ry: "2" }), index.h("path", { d: "M7 11V7a5 5 0 0 1 10 0v4" }))), index.h("button", { type: "button", class: "file-action delete", onClick: (event) => this.on_file_delete_action(item, event), title: "Delete", "aria-label": `Delete ${item.name}` }, index.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" }, index.h("polyline", { points: "3 6 5 6 21 6" }), index.h("path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" }), index.h("path", { d: "M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6" }), index.h("line", { x1: "10", x2: "10", y1: "11", y2: "17" }), index.h("line", { x1: "14", x2: "14", y1: "11", y2: "17" })))))))), this.visible_listing().length === 0 &&
1386
+ index.h("tr", { key: '46a173ad6542c9ab315da2792ea9830f0086b683', class: "empty" }, index.h("td", { key: '986924de123f9be62f89f869fca02cd195134080', colSpan: 6 }, this.filter ? `Nothing here matches "${this.filter}".` : 'This directory is empty.'))))), this.show_loader && index.h("div", { key: '588f4ff57df18c993f8566711a2627bd69b03881', class: "loader" }, "Loading..."), this.show_error && index.h("div", { key: '816c8ca05f68291d784d4c86509c9478204f3449', class: "error" }, this.error_message)), index.h("footer", { key: '6add74a0d5beb8de15a600d287d96dd69f87a646' }, index.h("section", { key: '39b31ae22b9f6298b8991be47d5641c1de618ab7', class: "status" }, this.status, this.selected_item && index.h("span", { key: '6e3942b5471e240719dfaf66cb01763f162ff3f0', class: "selected-item" }, this.selected_item.name)), index.h("section", { key: 'cc7ab5a9a632da8fae266f9ae73f967083e3589f', class: "version" }, this.version ? `Version: ${this.version}` : ''))), this.show_login_screen &&
1387
+ index.h("section", { key: '3e13e8c942f690d2e26c231c2403032af620f735', class: {
1388
+ 'creds': true,
1389
+ 'blurred': this.show_login_screen,
1390
+ } }, index.h("form", { key: '7ddb982159a3470bfad44aea75973a2eb37bebcd', class: "auth", onSubmit: (event) => {
1391
+ const formData = new FormData(event.target);
1392
+ let username = undefined;
1393
+ if (this.show_login_screen_username) {
1394
+ username = formData.get('username');
1395
+ }
1396
+ let password = undefined;
1397
+ if (this.show_login_screen_password) {
1398
+ password = formData.get('password');
1399
+ }
1400
+ this.channel.open_sftp_tunnel(this.nodeId, this.serviceId, username, password);
1401
+ this.show_login_screen_username = false;
1402
+ this.show_login_screen_password = false;
1403
+ this.show_login_screen = false;
1404
+ this.show_loader = true;
1405
+ event.stopPropagation();
1406
+ event.preventDefault();
1407
+ } }, index.h("div", { key: '036877a02034000a79836c0a0979def9163f8a1a', class: "title" }, "SFTP Connection"), this.show_login_screen_username &&
1408
+ index.h("div", { key: '37830ddb769fe0491831700a90f3fc8bf71cf050' }, index.h("label", { key: '0f6e3d70e34baae3342a57fceed657e59c8c05a4', htmlFor: "username" }, "Username"), index.h("input", { key: '3ecb202b3ee015e8719c330edb06889f4f48a433', autocorrect: "off", autocapitalize: "none", autoComplete: "off", id: "username", name: "username", type: "text", placeholder: "" })), this.show_login_screen_password &&
1409
+ index.h("div", { key: '092a40a9da1205ec6342069844135aea92b85c5a' }, index.h("label", { key: '19e465136660c9d2c1ecd0bb02bd7f8a559e3e0b', htmlFor: "password" }, "Password"), index.h("input", { key: 'ab9a74273abc594fa9fd51a780c2586fb275b4b4', autocorrect: "off", autocapitalize: "none", autoComplete: "off", id: "password", name: "password", type: "password", placeholder: "" })), index.h("div", { key: 'c1596787c7fea135d203f831cb7432a6e803d488' }, index.h("button", { key: '89314be80add42ba55f96ec01bf22848742ec179', type: "submit" }, "Connect")))), this.show_upload_modal &&
1410
+ index.h("section", { key: 'c8b08cf050947d1936c97caf46eacca93175db9f', class: {
1411
+ 'upload-modal': true,
1412
+ 'visible': this.show_upload_modal,
1413
+ } }, index.h("div", { key: 'ccc745354525565cda06b6b6eb8253c557c59009', class: "upload-dialog", role: "dialog", "aria-modal": "true", "aria-label": "Upload progress" }, index.h("div", { key: 'd478b113fa655386998d93862fc53bf516eaf90b', class: "title" }, "Uploading File"), index.h("div", { key: '35c85475b00efcf05097e1feae1313afde0d04af', class: "file-name", title: this.upload_file_name }, this.upload_file_name), index.h("div", { key: 'd5cb7df154d77dacdca48673b2f01e03729846b0', class: "progress-track", role: "progressbar", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": this.upload_progress }, index.h("div", { key: '4a7c10979b37d06acdda30c0b8d04a2af3cf0e5a', class: "progress-fill", style: { width: `${this.upload_progress}%` } })), index.h("div", { key: 'c69da13c3bc15a9a36867cbb1a8d041780ffecca', class: "progress-meta" }, index.h("div", { key: '000b027205a828e1257263e29b5a595ead0fe54a', class: "progress-speed" }, this.upload_speed), index.h("div", { key: '8eda5c230e39343ffb10aa1bc64f70999d428c57', class: "progress-value" }, this.format_percent(this.upload_progress))), index.h("button", { key: 'b047fe324179b9f77f97f7bcf541c32e0903bad9', type: "button", class: {
1414
+ 'cancel': true,
1415
+ 'finished': this.upload_finished,
1416
+ }, onClick: () => this.cancel_upload() }, this.upload_finished ? 'Close' : 'Cancel'))), this.show_download_modal &&
1417
+ index.h("section", { key: 'fff5c3228be15048397b86a1457f63d4562c98f8', class: {
1418
+ 'download-modal': true,
1419
+ 'visible': this.show_download_modal,
1420
+ } }, index.h("div", { key: '8bbf7465cdb2b514b16c4982b3480b04aa5e1a6c', class: "download-dialog", role: "dialog", "aria-modal": "true", "aria-label": "Download progress" }, index.h("div", { key: 'dea4371acce3010cefdb14bbc3873d6cca1e308c', class: "title" }, "Downloading File"), index.h("div", { key: 'cffc4ad6e269108252db2bbb3b3f9678e88aed4b', class: "file-name", title: this.download_file_name }, this.download_file_name), index.h("div", { key: 'ec0fd7bbd72c2c1dcb55dffb39a8e550af9c54a6', class: "progress-track", role: "progressbar", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": this.download_progress }, index.h("div", { key: 'c899bcf67b523e9de0db76bc9163d192120fd61b', class: "progress-fill", style: { width: `${this.download_progress}%` } })), index.h("div", { key: '14c343bb055ca7300f3b500bb9da06450f9338c8', class: "progress-meta" }, index.h("div", { key: '6b030a95eb9b11d88a070dd8a8dc9f4a2d10302a', class: "progress-speed" }, this.download_speed), index.h("div", { key: '0d8eb9884506e9bb7a31ea1ceedc0f3e3e74f9b8', class: "progress-value" }, this.format_percent(this.download_progress))), index.h("button", { key: '4416377601c6655ba0e9385e6149dd461702439a', type: "button", class: {
1421
+ 'cancel': true,
1422
+ 'finished': this.download_finished,
1423
+ }, onClick: () => this.cancel_download() }, this.download_finished ? 'Close' : 'Cancel'))), this.show_delete_modal &&
1424
+ index.h("section", { key: '803d5f9fc2096c44335380132eee7d6ee1c70c1f', class: {
1425
+ 'delete-modal': true,
1426
+ 'visible': this.show_delete_modal,
1427
+ } }, index.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()) }, index.h("div", { key: '6b64cac5732de2d5c091fea7ef1cd1b903b86c61', class: "title" }, this.delete_is_dir ? 'Delete Folder' : 'Delete File'), index.h("div", { key: 'f1b6592449d9697208c704dcaaeec83d4d40d852', class: "message" }, this.delete_loading
1428
+ ? (this.delete_recursive ? 'Deleting the folder and everything in it...' : 'Deleting...')
1429
+ : `Are you sure you want to delete this ${this.delete_is_dir ? 'folder' : 'file'}?`), index.h("div", { key: 'a67f8bd35875e0477fcf3bbf9f075b10f9066f07', class: "file-name", title: this.delete_file_name }, this.delete_file_name), this.delete_is_dir &&
1430
+ index.h("label", { key: '5e660c03c1df789bcdc4dba7a2adfe4887dd71ca', class: "checkline" }, index.h("input", { key: 'c28122496182d007ae2f99d9de79451c23dadef5', type: "checkbox", checked: this.delete_recursive, disabled: this.delete_loading, onChange: (event) => this.delete_recursive = event.target.checked }), index.h("span", { key: '53539d4803c5358d26e181dc53fcc7f36ad62d6a' }, "Delete everything inside it too")), !this.delete_is_dir || this.delete_recursive ? null :
1431
+ index.h("div", { class: "hint" }, "Without this, the remote refuses a folder that is not empty."), this.delete_error && index.h("div", { key: '0773a1e6a26fa8dde7dba0d0ed00107d01782e2f', class: "dialog-error" }, this.delete_error), this.delete_loading &&
1432
+ index.h("div", { key: 'b1580f0825ec4f4b37f894fbd714f143a9515fd6', class: "delete-loader", "aria-hidden": "true" }, index.h("span", { key: 'db549d437007182afdaddab37d8caec7b1c4a2c7', class: "spinner" })), index.h("div", { key: '040a4c6730ce5149737211fae9d67a3a290bdc5c', class: "modal-actions" }, index.h("button", { key: 'b742ccd04a3e119c446a2186081835fd6f67022d', type: "button", class: "btn secondary", onClick: () => this.cancel_delete(), disabled: this.delete_loading }, "Cancel"), index.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 &&
1433
+ index.h("section", { key: 'd533b9ecb021dbb69766ba92e87d0b4279b047d4', class: "prompt-modal visible" }, index.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()) }, index.h("div", { key: '36b154bda604336f8bbb7c46d7bb35b6afd6cec2', class: "title" }, this.prompt_kind === 'mkdir' ? 'New Folder' : 'Rename'), index.h("div", { key: '76b8027be289fcdba2867e1b06f05cab8481564d', class: "message" }, this.prompt_kind === 'mkdir'
1434
+ ? `Create a folder in ${this.current_dir}`
1435
+ : 'Give it a new name. Existing names are not overwritten.'), index.h("form", { key: '8ec6e410dc6572de35ff6b2c81734fa48d74a4a8', onSubmit: (event) => { event.preventDefault(); event.stopPropagation(); void this.submit_prompt(); } }, index.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 && index.h("div", { key: '2644600b1e015e02209309e1163e991acabad2e9', class: "dialog-error" }, this.prompt_error), index.h("div", { key: '520937e554f3ff7839aad18fd0ed3c56f8a21680', class: "modal-actions" }, index.h("button", { key: 'e5a037f006c3f97e6227e672cff6cf3dc7282abb', type: "button", class: "btn secondary", onClick: () => this.close_prompt(), disabled: this.prompt_busy }, "Cancel"), index.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 &&
1436
+ index.h("section", { key: 'e99ef709477024789821b76e1bbaa6497dcbc474', class: "prompt-modal visible" }, index.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()) }, index.h("div", { key: '49c35a7228bbc6e9898c499904feb5fb525b2b5c', class: "title" }, "Permissions"), index.h("div", { key: '814edc9c438d956bef13b14bc22733502168c340', class: "file-name", title: this.chmod_target.name }, this.chmod_target.name), index.h("table", { key: 'a4c1b45c1ee830599e7c08a9a44c69df1ac2b201', class: "perm-grid" }, index.h("thead", { key: '99b953b4cf5f3a6aeff766d39b15222e74235a3c' }, index.h("tr", { key: '49d3ae286989915aaca71ba43cb19db357064158' }, index.h("th", { key: '3f3b7fcbeb1b713d29a874a111552f6ff95a811e', "aria-label": "Class" }), index.h("th", { key: '6d18882102b71cb61be8ae93a946f62da7b555bc' }, "Read"), index.h("th", { key: '44aed1177108307db4618680b5e7d28e248cdab6' }, "Write"), index.h("th", { key: 'd6056bed3aab4164768a010c369365c70e67bbbc' }, "Execute"))), index.h("tbody", { key: 'd54ecfe06cade301263977cf1f0a0ba9e3721b5c' }, [
1437
+ { label: 'Owner', read: 0o400, write: 0o200, exec: 0o100 },
1438
+ { label: 'Group', read: 0o040, write: 0o020, exec: 0o010 },
1439
+ { label: 'Other', read: 0o004, write: 0o002, exec: 0o001 },
1440
+ ].map((row) => (index.h("tr", { key: row.label }, index.h("th", { scope: "row" }, row.label), [row.read, row.write, row.exec].map((bit) => (index.h("td", { key: bit }, index.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) }))))))))), index.h("div", { key: 'a124e9599de6b406d84ba9ffa3a56b3b993179ef', class: "perm-special" }, [
1441
+ { label: 'setuid', bit: 0o4000 },
1442
+ { label: 'setgid', bit: 0o2000 },
1443
+ { label: 'sticky', bit: 0o1000 },
1444
+ ].map((special) => (index.h("label", { key: special.label, class: "checkline" }, index.h("input", { type: "checkbox", disabled: this.chmod_busy, checked: (this.chmod_mode & special.bit) !== 0, onChange: () => this.toggle_chmod_bit(special.bit) }), index.h("span", null, special.label))))), index.h("div", { key: '05ab3c8451084b6acdf7ea0e45f71da0f913b08d', class: "perm-octal" }, index.h("label", { key: '5cb748e079c869720361e56c4973eaea82a85bc0', htmlFor: "chmod-octal" }, "Octal"), index.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) }), index.h("span", { key: '4a789c75be9a941d2adf8de68cfda043c19864cc', class: "perm-preview" }, this.format_permissions(this.chmod_mode, this.chmod_target.kind))), this.chmod_error && index.h("div", { key: 'acb09c9d16146cc0466df1ea6394ff492604c397', class: "dialog-error" }, this.chmod_error), index.h("div", { key: '46c5c4fc154529060b24e335dcd192ed6dc6f75d', class: "modal-actions" }, index.h("button", { key: '2ad9fad876497e4d629c1911fbe29616853a2e59', type: "button", class: "btn secondary", onClick: () => this.close_chmod(), disabled: this.chmod_busy }, "Cancel"), index.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 &&
1445
+ index.h("section", { key: 'f040aeca04a6b02af3247c024271fbdc2564a0c4', class: "editor-modal visible" }, index.h("div", { key: '6874ae8a526168be8c2c09ca3f8a1faa52b78027', class: "editor-dialog", role: "dialog", "aria-modal": "true", "aria-label": `Editing ${this.editor_name}`, tabindex: -1, onKeyDown: (event) => {
1446
+ if ((event.ctrlKey || event.metaKey) && event.key === 's') {
1447
+ event.preventDefault();
1448
+ void this.save_editor();
1449
+ return;
1450
+ }
1451
+ this.on_modal_keydown(event, () => this.close_editor());
1452
+ } }, index.h("div", { key: '421cbd1bfbde035049ed028c4d05083cc7d8f66f', class: "editor-head" }, index.h("div", { key: '889adcf6e0187963964920b9750531c3fa06cd37', class: "title" }, this.editor_name, this.editor_is_dirty() ? ' *' : ''), index.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'
1453
+ ? index.h("div", { class: "editor-loading" }, "Loading...")
1454
+ : index.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 && index.h("div", { key: 'e7c1db037e749fec8970ac2b2be2cb85cfcd85be', class: "dialog-error" }, this.editor_error), this.editor_confirm_discard &&
1455
+ index.h("div", { key: '84ca6080e18c4334e87374126b82b816f318cb0d', class: "dialog-error" }, "Unsaved changes. Close anyway?"), index.h("div", { key: '4515e164a418815eccfd9d54d8f96a076616f326', class: "modal-actions" }, this.editor_confirm_discard
1456
+ ? index.h("button", { type: "button", class: "btn destructive", onClick: () => this.close_editor(true) }, "Discard")
1457
+ : index.h("button", { type: "button", class: "btn secondary", onClick: () => this.close_editor(), disabled: this.editor_busy === 'saving' }, "Close"), index.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'))))));
1458
+ }
1459
+ static get watchers() { return {
1460
+ "nodeId": [{
1461
+ "onNodeIdChange": 0
1462
+ }],
1463
+ "serverId": [{
1464
+ "onServerIdChange": 0
1465
+ }]
1466
+ }; }
1467
+ };
1468
+ PhirepassSftpClient.style = phirepassSftpClientCss();
1469
+
1470
+ exports.phirepass_sftp_client = PhirepassSftpClient;