phirepass-widgets 0.0.111 → 0.0.113

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 (89) hide show
  1. package/README.md +33 -0
  2. package/dist/cjs/{index-B8w6l0VL.js → index-CurErEK7.js} +101 -30
  3. package/dist/cjs/loader.cjs.js +2 -2
  4. package/dist/cjs/phirepass-downloader_3.cjs.entry.js +3696 -0
  5. package/dist/cjs/phirepass-rdp.cjs.entry.js +18 -6
  6. package/dist/cjs/phirepass-terminal.cjs.entry.js +6 -5
  7. package/dist/cjs/phirepass-widgets.cjs.js +3 -3
  8. package/dist/cjs/{protocol-CCD7cbHu.js → protocol-DCBMfc2u.js} +557 -360
  9. package/dist/collection/collection-manifest.json +3 -1
  10. package/dist/collection/common/channel.js +21 -1
  11. package/dist/collection/common/fetch.js +40 -0
  12. package/dist/collection/components/phirepass-downloader/form.js +69 -0
  13. package/dist/collection/components/phirepass-downloader/format.js +105 -0
  14. package/dist/collection/components/phirepass-downloader/jobs.js +370 -0
  15. package/dist/collection/components/phirepass-downloader/phirepass-downloader.css +1109 -0
  16. package/dist/collection/components/phirepass-downloader/phirepass-downloader.js +1455 -0
  17. package/dist/collection/components/phirepass-downloader/source.js +106 -0
  18. package/dist/collection/components/phirepass-downloader/views/dialogs.js +34 -0
  19. package/dist/collection/components/phirepass-downloader/views/fetch-form.js +65 -0
  20. package/dist/collection/components/phirepass-downloader/views/icons.js +33 -0
  21. package/dist/collection/components/phirepass-downloader/views/job-row.js +91 -0
  22. package/dist/collection/components/phirepass-downloader/views/notices.js +15 -0
  23. package/dist/collection/components/phirepass-downloader/views/states.js +19 -0
  24. package/dist/collection/components/phirepass-media-player/phirepass-media-player.css +216 -0
  25. package/dist/collection/components/phirepass-media-player/phirepass-media-player.js +473 -0
  26. package/dist/collection/components/phirepass-media-player/player.js +94 -0
  27. package/dist/collection/components/phirepass-rdp/phirepass-rdp.js +36 -13
  28. package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.css +122 -0
  29. package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.fetch.js +35 -0
  30. package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.js +181 -31
  31. package/dist/collection/components/phirepass-terminal/phirepass-terminal.js +2 -2
  32. package/dist/collection/phirepass-channel_bg.wasm +0 -0
  33. package/dist/collection/testing/fixtures.js +219 -0
  34. package/dist/collection/testing/mock-channel.js +410 -0
  35. package/dist/components/index.js +1 -1
  36. package/dist/components/p-C4cmk3bS.js +1 -0
  37. package/dist/components/p-CsYQJXY2.js +1 -0
  38. package/dist/components/p-D6Geq8Rn.js +1 -0
  39. package/dist/components/phirepass-downloader.d.ts +11 -0
  40. package/dist/components/phirepass-downloader.js +1 -0
  41. package/dist/components/phirepass-media-player.d.ts +11 -0
  42. package/dist/components/phirepass-media-player.js +1 -0
  43. package/dist/components/phirepass-rdp.js +1 -1
  44. package/dist/components/phirepass-sftp-client.js +1 -1
  45. package/dist/components/phirepass-terminal.js +2 -2
  46. package/dist/esm/{index-DGq2b7rM.js → index-B9qUl6FW.js} +101 -30
  47. package/dist/esm/loader.js +3 -3
  48. package/dist/esm/phirepass-downloader_3.entry.js +3692 -0
  49. package/dist/esm/phirepass-rdp.entry.js +18 -6
  50. package/dist/esm/phirepass-terminal.entry.js +6 -5
  51. package/dist/esm/phirepass-widgets.js +4 -4
  52. package/dist/esm/{protocol-D4JeTIHt.js → protocol-CsYQJXY2.js} +556 -359
  53. package/dist/phirepass-widgets/p-1b84c526.entry.js +1 -0
  54. package/dist/phirepass-widgets/{p-9eebbf05.entry.js → p-41dd1ac9.entry.js} +2 -2
  55. package/dist/phirepass-widgets/p-614ab3de.entry.js +1 -0
  56. package/dist/phirepass-widgets/p-B9qUl6FW.js +3 -0
  57. package/dist/phirepass-widgets/p-CsYQJXY2.js +1 -0
  58. package/dist/phirepass-widgets/phirepass-channel_bg.wasm +0 -0
  59. package/dist/phirepass-widgets/phirepass-widgets.esm.js +1 -1
  60. package/dist/types/common/channel.d.ts +30 -0
  61. package/dist/types/common/fetch.d.ts +161 -0
  62. package/dist/types/components/phirepass-downloader/form.d.ts +54 -0
  63. package/dist/types/components/phirepass-downloader/format.d.ts +17 -0
  64. package/dist/types/components/phirepass-downloader/jobs.d.ts +115 -0
  65. package/dist/types/components/phirepass-downloader/phirepass-downloader.d.ts +231 -0
  66. package/dist/types/components/phirepass-downloader/source.d.ts +61 -0
  67. package/dist/types/components/phirepass-downloader/views/dialogs.d.ts +52 -0
  68. package/dist/types/components/phirepass-downloader/views/fetch-form.d.ts +31 -0
  69. package/dist/types/components/phirepass-downloader/views/icons.d.ts +5 -0
  70. package/dist/types/components/phirepass-downloader/views/job-row.d.ts +21 -0
  71. package/dist/types/components/phirepass-downloader/views/notices.d.ts +18 -0
  72. package/dist/types/components/phirepass-downloader/views/states.d.ts +38 -0
  73. package/dist/types/components/phirepass-media-player/phirepass-media-player.d.ts +67 -0
  74. package/dist/types/components/phirepass-media-player/player.d.ts +43 -0
  75. package/dist/types/components/phirepass-rdp/phirepass-rdp.d.ts +10 -0
  76. package/dist/types/components/phirepass-sftp-client/phirepass-sftp-client.d.ts +30 -0
  77. package/dist/types/components/phirepass-sftp-client/phirepass-sftp-client.fetch.d.ts +40 -0
  78. package/dist/types/components.d.ts +426 -34
  79. package/dist/types/stencil-public-runtime.d.ts +1 -1
  80. package/dist/types/testing/fixtures.d.ts +25 -0
  81. package/dist/types/testing/mock-channel.d.ts +132 -0
  82. package/package.json +26 -12
  83. package/dist/cjs/phirepass-sftp-client.cjs.entry.js +0 -1469
  84. package/dist/components/p-D4JeTIHt.js +0 -1
  85. package/dist/esm/phirepass-sftp-client.entry.js +0 -1467
  86. package/dist/phirepass-widgets/p-401631af.entry.js +0 -1
  87. package/dist/phirepass-widgets/p-5f27300b.entry.js +0 -1
  88. package/dist/phirepass-widgets/p-D4JeTIHt.js +0 -1
  89. package/dist/phirepass-widgets/p-DGq2b7rM.js +0 -3
@@ -5,20 +5,167 @@
5
5
  * It contains typing information for all components that exist in this project.
6
6
  */
7
7
  import { HTMLStencilElement, JSXBase } from "./stencil-public-runtime";
8
- import { ConnectionState } from "./common/protocol";
9
- import { ChannelFactory } from "./common/channel";
10
- export { ConnectionState } from "./common/protocol";
11
- export { ChannelFactory } from "./common/channel";
8
+ import { ChannelFactory, DownloadChannelFactory, DownloadChannelLike } from "./common/channel";
9
+ import { ConnectionState, ProtocolMessage } from "./common/protocol";
10
+ import { PositionStore, RemotePlaybackLike } from "./components/phirepass-media-player/player";
11
+ export { ChannelFactory, DownloadChannelFactory, DownloadChannelLike } from "./common/channel";
12
+ export { ConnectionState, ProtocolMessage } from "./common/protocol";
13
+ export { PositionStore, RemotePlaybackLike } from "./components/phirepass-media-player/player";
12
14
  export namespace Components {
13
15
  /**
14
- * Remote desktop over RDP.
15
- * Unlike the terminal and SFTP widgets this one does not pipe protocol bytes
16
- * through the phirepass channel. The channel is used only to authorise the
17
- * session; the actual RDP stream runs on a second WebSocket opened by IronRDP's
18
- * own client, because that client speaks RDCleanPath and can set neither
19
- * headers nor a subprotocol on the socket it opens. See `RDP.md` in
20
- * `phirepass-rs` for why the session is split across two sockets.
16
+ * Remote Fetch: paste a link or a magnet, or drop a `.torrent`, and the node
17
+ * downloads it into its own download folder.
18
+ * Two forms, one component. **Embedded** in the SFTP browser (`compact`), it
19
+ * shares the host's channel, which forwards it the `Download*` frames through
20
+ * `receive()`, and saves into the folder on screen when the node can map it.
21
+ * **Standalone**, it builds its own channel, signs in with `token`, and saves
22
+ * into the download folder or a sub-folder of it. Either way it never asks for
23
+ * a login: the node writes its own files.
24
+ * The widget only sends events and shows progress. Downloads run on the node
25
+ * and carry on after the tab closes.
21
26
  */
27
+ interface PhirepassDownloader {
28
+ /**
29
+ * @default false
30
+ */
31
+ "allowInsecure": boolean;
32
+ /**
33
+ * The folder on screen in the host. Downloads land here when it lies inside the download folder.
34
+ */
35
+ "browsingPath"?: string;
36
+ /**
37
+ * The SFTP/SSH service the host is browsing, so the node can map `browsingPath`.
38
+ */
39
+ "browsingService"?: string;
40
+ /**
41
+ * Whether the viewer may configure this node, which only changes advice text (B9).
42
+ * @default false
43
+ */
44
+ "canConfigure": boolean;
45
+ /**
46
+ * A channel to share instead of opening one: the SFTP client passes its own. The host must forward `Download*` frames (and `Error`s whose `msg_id` is at or above `DOWNLOADER_MSG_ID_BASE`) to `receive()`, and set `connected` once the channel is authenticated.
47
+ */
48
+ "channel"?: DownloadChannelLike;
49
+ /**
50
+ * Builds the channel in place of a WebSocket, for demos and tests (see `ChannelFactory`).
51
+ */
52
+ "channelFactory"?: DownloadChannelFactory;
53
+ /**
54
+ * The drawer layout used inside the SFTP browser.
55
+ * @default false
56
+ */
57
+ "compact": boolean;
58
+ /**
59
+ * With an injected `channel`: whether it is authenticated and usable.
60
+ * @default false
61
+ */
62
+ "connected": boolean;
63
+ /**
64
+ * Deletes a download (an unfinished one always loses its part file).
65
+ */
66
+ "deleteDownload": (downloadId: string, deleteFile?: boolean) => Promise<void>;
67
+ /**
68
+ * @default 30_000
69
+ */
70
+ "heartbeatInterval": number;
71
+ /**
72
+ * Open the built-in player on Play, unless a `phirepassPlay` listener calls `preventDefault()`.
73
+ * @default true
74
+ */
75
+ "inlinePlayer": boolean;
76
+ /**
77
+ * The running download whose part file this is, so the SFTP client can offer K3 instead of a plain delete.
78
+ */
79
+ "jobForPath": (path: string) => Promise<{ download_id: string; name: string; } | null>;
80
+ "nodeId": string;
81
+ /**
82
+ * What to call the node in sentences; the id is a uuid nobody reads.
83
+ */
84
+ "nodeLabel"?: string;
85
+ /**
86
+ * Opens the Fetch dialog (and the drawer behind it). `path` updates the folder on screen.
87
+ */
88
+ "openFetch": (path?: string) => Promise<void>;
89
+ /**
90
+ * Hands this widget a frame from a shared channel: `Download*` frames, and `Error`s answering one of its `msg_id`s. Anything else is ignored.
91
+ */
92
+ "receive": (msg: ProtocolMessage | { data: { web: unknown; }; }) => Promise<void>;
93
+ /**
94
+ * @default 'phirepass.com'
95
+ */
96
+ "serverHost": string;
97
+ "serverId"?: string;
98
+ /**
99
+ * @default 443
100
+ */
101
+ "serverPort": number;
102
+ /**
103
+ * C: download the contents of a `.torrent` already on the node, into the folder it sits in.
104
+ */
105
+ "startTorrentPath": (path: string, inOrder?: boolean) => Promise<boolean>;
106
+ /**
107
+ * Base URL for `/api/web/stream/…`. Defaults to the server the channel talks to.
108
+ */
109
+ "streamBase"?: string;
110
+ /**
111
+ * Opens or closes the drawer (embedded).
112
+ */
113
+ "toggleDrawer": (open?: boolean) => Promise<void>;
114
+ /**
115
+ * Session token, for the standalone form. Not needed when `channel` is given.
116
+ */
117
+ "token"?: string;
118
+ /**
119
+ * The path of a `.torrent` on the node relative to the download folder, or null when it lies outside it (then C's menu item is not offered).
120
+ */
121
+ "torrentPathFor": (path: string) => Promise<string | null>;
122
+ }
123
+ /**
124
+ * Plays a file from the node with the browser's own `<video>` or `<audio>`.
125
+ * It knows nothing of channels or WASM: `src` is a stream URL the server turns
126
+ * into stream events towards the agent, and the browser's range requests do
127
+ * the rest. A download that is still arriving plays as far as `ready` bytes;
128
+ * past that the element waits, and so does the player, saying why.
129
+ */
130
+ interface PhirepassMediaPlayer {
131
+ /**
132
+ * Shown while casting, when the host knows the device's name.
133
+ */
134
+ "castDevice"?: string;
135
+ /**
136
+ * Closes the player, saving where it stopped. The download is not affected.
137
+ */
138
+ "close": () => Promise<void>;
139
+ /**
140
+ * Overrides the mime the extension implies.
141
+ */
142
+ "mime"?: string;
143
+ "name": string;
144
+ /**
145
+ * Key for the stored position: `dl:<download_id>:<file>` or `node:<node_id>:<path>`.
146
+ */
147
+ "positionKey"?: string;
148
+ /**
149
+ * “Continue watching”. Without one, positions stay in this browser.
150
+ */
151
+ "positionStore"?: PositionStore;
152
+ /**
153
+ * Bytes ready from the start of the file, while it is still downloading.
154
+ */
155
+ "ready"?: number;
156
+ /**
157
+ * Stands in for `video.remote`, for demos and tests (like `channelFactory`).
158
+ */
159
+ "remotePlayback"?: RemotePlaybackLike;
160
+ /**
161
+ * The stream URL: `/api/web/stream/{node}/{download}/{file}` or a listing token URL.
162
+ */
163
+ "src": string;
164
+ /**
165
+ * The status line above the picture, from the job: “Downloading · 23.4%”, “On the node”.
166
+ */
167
+ "status"?: string;
168
+ }
22
169
  interface PhirepassRdp {
23
170
  /**
24
171
  * @default false
@@ -29,6 +176,10 @@ export namespace Components {
29
176
  * @default true
30
177
  */
31
178
  "captureKeyboard": boolean;
179
+ /**
180
+ * Supplies the channel instead of a WebSocket to the server — for demos, screenshots and tests, as on the terminal and SFTP client. A property only; read once, when the widget connects.
181
+ */
182
+ "channelFactory"?: (endpoint: string, nodeId: string, serverId?: string) => RdpChannelLike;
32
183
  /**
33
184
  * Share the clipboard with the remote host in both directions. On is the client's own default and needs nothing from us, so this exists to turn it **off**: a deployment that treats copy-out as exfiltration can take the clipboard away without giving up the session. Clipboard access additionally needs a secure context — over plain HTTP the browser refuses it whatever this says, and the client's warning is logged.
34
185
  * @default true
@@ -166,6 +317,14 @@ export namespace Components {
166
317
  "token": string;
167
318
  }
168
319
  }
320
+ export interface PhirepassDownloaderCustomEvent<T> extends CustomEvent<T> {
321
+ detail: T;
322
+ target: HTMLPhirepassDownloaderElement;
323
+ }
324
+ export interface PhirepassMediaPlayerCustomEvent<T> extends CustomEvent<T> {
325
+ detail: T;
326
+ target: HTMLPhirepassMediaPlayerElement;
327
+ }
169
328
  export interface PhirepassRdpCustomEvent<T> extends CustomEvent<T> {
170
329
  detail: T;
171
330
  target: HTMLPhirepassRdpElement;
@@ -179,18 +338,67 @@ export interface PhirepassTerminalCustomEvent<T> extends CustomEvent<T> {
179
338
  target: HTMLPhirepassTerminalElement;
180
339
  }
181
340
  declare global {
182
- interface HTMLPhirepassRdpElementEventMap {
183
- "connectionStateChanged": [ConnectionState, unknown?];
341
+ interface HTMLPhirepassDownloaderElementEventMap {
342
+ "phirepassFetchCompleted": { download_id: string; dest_root: string; sub_dir: string | null; name: string };
343
+ "phirepassPlay": { src: string; name: string; downloadId: string };
344
+ "phirepassActiveCount": { n: number };
345
+ "phirepassShowInFolder": { path: string; name: string };
346
+ "phirepassOpenNodeSettings": { nodeId: string };
347
+ "phirepassSignIn": void;
184
348
  }
185
349
  /**
186
- * Remote desktop over RDP.
187
- * Unlike the terminal and SFTP widgets this one does not pipe protocol bytes
188
- * through the phirepass channel. The channel is used only to authorise the
189
- * session; the actual RDP stream runs on a second WebSocket opened by IronRDP's
190
- * own client, because that client speaks RDCleanPath and can set neither
191
- * headers nor a subprotocol on the socket it opens. See `RDP.md` in
192
- * `phirepass-rs` for why the session is split across two sockets.
350
+ * Remote Fetch: paste a link or a magnet, or drop a `.torrent`, and the node
351
+ * downloads it into its own download folder.
352
+ * Two forms, one component. **Embedded** in the SFTP browser (`compact`), it
353
+ * shares the host's channel, which forwards it the `Download*` frames through
354
+ * `receive()`, and saves into the folder on screen when the node can map it.
355
+ * **Standalone**, it builds its own channel, signs in with `token`, and saves
356
+ * into the download folder or a sub-folder of it. Either way it never asks for
357
+ * a login: the node writes its own files.
358
+ * The widget only sends events and shows progress. Downloads run on the node
359
+ * and carry on after the tab closes.
193
360
  */
361
+ interface HTMLPhirepassDownloaderElement extends Components.PhirepassDownloader, HTMLStencilElement {
362
+ addEventListener<K extends keyof HTMLPhirepassDownloaderElementEventMap>(type: K, listener: (this: HTMLPhirepassDownloaderElement, ev: PhirepassDownloaderCustomEvent<HTMLPhirepassDownloaderElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
363
+ addEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
364
+ addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
365
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
366
+ removeEventListener<K extends keyof HTMLPhirepassDownloaderElementEventMap>(type: K, listener: (this: HTMLPhirepassDownloaderElement, ev: PhirepassDownloaderCustomEvent<HTMLPhirepassDownloaderElementEventMap[K]>) => any, options?: boolean | EventListenerOptions): void;
367
+ removeEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
368
+ removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
369
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
370
+ }
371
+ var HTMLPhirepassDownloaderElement: {
372
+ prototype: HTMLPhirepassDownloaderElement;
373
+ new (): HTMLPhirepassDownloaderElement;
374
+ };
375
+ interface HTMLPhirepassMediaPlayerElementEventMap {
376
+ "phirepassPlayerClose": void;
377
+ }
378
+ /**
379
+ * Plays a file from the node with the browser's own `<video>` or `<audio>`.
380
+ * It knows nothing of channels or WASM: `src` is a stream URL the server turns
381
+ * into stream events towards the agent, and the browser's range requests do
382
+ * the rest. A download that is still arriving plays as far as `ready` bytes;
383
+ * past that the element waits, and so does the player, saying why.
384
+ */
385
+ interface HTMLPhirepassMediaPlayerElement extends Components.PhirepassMediaPlayer, HTMLStencilElement {
386
+ addEventListener<K extends keyof HTMLPhirepassMediaPlayerElementEventMap>(type: K, listener: (this: HTMLPhirepassMediaPlayerElement, ev: PhirepassMediaPlayerCustomEvent<HTMLPhirepassMediaPlayerElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
387
+ addEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
388
+ addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
389
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
390
+ removeEventListener<K extends keyof HTMLPhirepassMediaPlayerElementEventMap>(type: K, listener: (this: HTMLPhirepassMediaPlayerElement, ev: PhirepassMediaPlayerCustomEvent<HTMLPhirepassMediaPlayerElementEventMap[K]>) => any, options?: boolean | EventListenerOptions): void;
391
+ removeEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
392
+ removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
393
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
394
+ }
395
+ var HTMLPhirepassMediaPlayerElement: {
396
+ prototype: HTMLPhirepassMediaPlayerElement;
397
+ new (): HTMLPhirepassMediaPlayerElement;
398
+ };
399
+ interface HTMLPhirepassRdpElementEventMap {
400
+ "connectionStateChanged": [ConnectionState, unknown?];
401
+ }
194
402
  interface HTMLPhirepassRdpElement extends Components.PhirepassRdp, HTMLStencilElement {
195
403
  addEventListener<K extends keyof HTMLPhirepassRdpElementEventMap>(type: K, listener: (this: HTMLPhirepassRdpElement, ev: PhirepassRdpCustomEvent<HTMLPhirepassRdpElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
196
404
  addEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
@@ -241,6 +449,8 @@ declare global {
241
449
  new (): HTMLPhirepassTerminalElement;
242
450
  };
243
451
  interface HTMLElementTagNameMap {
452
+ "phirepass-downloader": HTMLPhirepassDownloaderElement;
453
+ "phirepass-media-player": HTMLPhirepassMediaPlayerElement;
244
454
  "phirepass-rdp": HTMLPhirepassRdpElement;
245
455
  "phirepass-sftp-client": HTMLPhirepassSftpClientElement;
246
456
  "phirepass-terminal": HTMLPhirepassTerminalElement;
@@ -250,14 +460,152 @@ declare namespace LocalJSX {
250
460
  type OneOf<K extends string, PropT, AttrT = PropT> = { [P in K]: PropT } & { [P in `attr:${K}`]?: never } | { [P in `attr:${K}`]: AttrT } & { [P in K]?: never };
251
461
 
252
462
  /**
253
- * Remote desktop over RDP.
254
- * Unlike the terminal and SFTP widgets this one does not pipe protocol bytes
255
- * through the phirepass channel. The channel is used only to authorise the
256
- * session; the actual RDP stream runs on a second WebSocket opened by IronRDP's
257
- * own client, because that client speaks RDCleanPath and can set neither
258
- * headers nor a subprotocol on the socket it opens. See `RDP.md` in
259
- * `phirepass-rs` for why the session is split across two sockets.
463
+ * Remote Fetch: paste a link or a magnet, or drop a `.torrent`, and the node
464
+ * downloads it into its own download folder.
465
+ * Two forms, one component. **Embedded** in the SFTP browser (`compact`), it
466
+ * shares the host's channel, which forwards it the `Download*` frames through
467
+ * `receive()`, and saves into the folder on screen when the node can map it.
468
+ * **Standalone**, it builds its own channel, signs in with `token`, and saves
469
+ * into the download folder or a sub-folder of it. Either way it never asks for
470
+ * a login: the node writes its own files.
471
+ * The widget only sends events and shows progress. Downloads run on the node
472
+ * and carry on after the tab closes.
473
+ */
474
+ interface PhirepassDownloader {
475
+ /**
476
+ * @default false
477
+ */
478
+ "allowInsecure"?: boolean;
479
+ /**
480
+ * The folder on screen in the host. Downloads land here when it lies inside the download folder.
481
+ */
482
+ "browsingPath"?: string;
483
+ /**
484
+ * The SFTP/SSH service the host is browsing, so the node can map `browsingPath`.
485
+ */
486
+ "browsingService"?: string;
487
+ /**
488
+ * Whether the viewer may configure this node, which only changes advice text (B9).
489
+ * @default false
490
+ */
491
+ "canConfigure"?: boolean;
492
+ /**
493
+ * A channel to share instead of opening one: the SFTP client passes its own. The host must forward `Download*` frames (and `Error`s whose `msg_id` is at or above `DOWNLOADER_MSG_ID_BASE`) to `receive()`, and set `connected` once the channel is authenticated.
494
+ */
495
+ "channel"?: DownloadChannelLike;
496
+ /**
497
+ * Builds the channel in place of a WebSocket, for demos and tests (see `ChannelFactory`).
498
+ */
499
+ "channelFactory"?: DownloadChannelFactory;
500
+ /**
501
+ * The drawer layout used inside the SFTP browser.
502
+ * @default false
503
+ */
504
+ "compact"?: boolean;
505
+ /**
506
+ * With an injected `channel`: whether it is authenticated and usable.
507
+ * @default false
508
+ */
509
+ "connected"?: boolean;
510
+ /**
511
+ * @default 30_000
512
+ */
513
+ "heartbeatInterval"?: number;
514
+ /**
515
+ * Open the built-in player on Play, unless a `phirepassPlay` listener calls `preventDefault()`.
516
+ * @default true
517
+ */
518
+ "inlinePlayer"?: boolean;
519
+ "nodeId": string;
520
+ /**
521
+ * What to call the node in sentences; the id is a uuid nobody reads.
522
+ */
523
+ "nodeLabel"?: string;
524
+ /**
525
+ * How many downloads are running, for a badge.
526
+ */
527
+ "onPhirepassActiveCount"?: (event: PhirepassDownloaderCustomEvent<{ n: number }>) => void;
528
+ /**
529
+ * A finished download, once per job. The SFTP client refreshes when it lands in the open folder.
530
+ */
531
+ "onPhirepassFetchCompleted"?: (event: PhirepassDownloaderCustomEvent<{ download_id: string; dest_root: string; sub_dir: string | null; name: string }>) => void;
532
+ /**
533
+ * “Open node settings” (B9, no folder).
534
+ */
535
+ "onPhirepassOpenNodeSettings"?: (event: PhirepassDownloaderCustomEvent<{ nodeId: string }>) => void;
536
+ /**
537
+ * Play was pressed. Cancelable: prevent it to open your own player instead.
538
+ */
539
+ "onPhirepassPlay"?: (event: PhirepassDownloaderCustomEvent<{ src: string; name: string; downloadId: string }>) => void;
540
+ /**
541
+ * “Show in folder” on a finished row.
542
+ */
543
+ "onPhirepassShowInFolder"?: (event: PhirepassDownloaderCustomEvent<{ path: string; name: string }>) => void;
544
+ /**
545
+ * “Sign in” (X3).
546
+ */
547
+ "onPhirepassSignIn"?: (event: PhirepassDownloaderCustomEvent<void>) => void;
548
+ /**
549
+ * @default 'phirepass.com'
550
+ */
551
+ "serverHost"?: string;
552
+ "serverId"?: string;
553
+ /**
554
+ * @default 443
555
+ */
556
+ "serverPort"?: number;
557
+ /**
558
+ * Base URL for `/api/web/stream/…`. Defaults to the server the channel talks to.
559
+ */
560
+ "streamBase"?: string;
561
+ /**
562
+ * Session token, for the standalone form. Not needed when `channel` is given.
563
+ */
564
+ "token"?: string;
565
+ }
566
+ /**
567
+ * Plays a file from the node with the browser's own `<video>` or `<audio>`.
568
+ * It knows nothing of channels or WASM: `src` is a stream URL the server turns
569
+ * into stream events towards the agent, and the browser's range requests do
570
+ * the rest. A download that is still arriving plays as far as `ready` bytes;
571
+ * past that the element waits, and so does the player, saying why.
260
572
  */
573
+ interface PhirepassMediaPlayer {
574
+ /**
575
+ * Shown while casting, when the host knows the device's name.
576
+ */
577
+ "castDevice"?: string;
578
+ /**
579
+ * Overrides the mime the extension implies.
580
+ */
581
+ "mime"?: string;
582
+ "name": string;
583
+ "onPhirepassPlayerClose"?: (event: PhirepassMediaPlayerCustomEvent<void>) => void;
584
+ /**
585
+ * Key for the stored position: `dl:<download_id>:<file>` or `node:<node_id>:<path>`.
586
+ */
587
+ "positionKey"?: string;
588
+ /**
589
+ * “Continue watching”. Without one, positions stay in this browser.
590
+ */
591
+ "positionStore"?: PositionStore;
592
+ /**
593
+ * Bytes ready from the start of the file, while it is still downloading.
594
+ */
595
+ "ready"?: number;
596
+ /**
597
+ * Stands in for `video.remote`, for demos and tests (like `channelFactory`).
598
+ */
599
+ "remotePlayback"?: RemotePlaybackLike;
600
+ /**
601
+ * The stream URL: `/api/web/stream/{node}/{download}/{file}` or a listing token URL.
602
+ */
603
+ "src": string;
604
+ /**
605
+ * The status line above the picture, from the job: “Downloading · 23.4%”, “On the node”.
606
+ */
607
+ "status"?: string;
608
+ }
261
609
  interface PhirepassRdp {
262
610
  /**
263
611
  * @default false
@@ -268,6 +616,10 @@ declare namespace LocalJSX {
268
616
  * @default true
269
617
  */
270
618
  "captureKeyboard"?: boolean;
619
+ /**
620
+ * Supplies the channel instead of a WebSocket to the server — for demos, screenshots and tests, as on the terminal and SFTP client. A property only; read once, when the widget connects.
621
+ */
622
+ "channelFactory"?: (endpoint: string, nodeId: string, serverId?: string) => RdpChannelLike;
271
623
  /**
272
624
  * Share the clipboard with the remote host in both directions. On is the client's own default and needs nothing from us, so this exists to turn it **off**: a deployment that treats copy-out as exfiltration can take the clipboard away without giving up the session. Clipboard access additionally needs a secure context — over plain HTTP the browser refuses it whatever this says, and the client's warning is logged.
273
625
  * @default true
@@ -387,6 +739,32 @@ declare namespace LocalJSX {
387
739
  "token": string;
388
740
  }
389
741
 
742
+ interface PhirepassDownloaderAttributes {
743
+ "nodeId": string;
744
+ "nodeLabel": string;
745
+ "token": string;
746
+ "connected": boolean;
747
+ "browsingService": string;
748
+ "browsingPath": string;
749
+ "compact": boolean;
750
+ "streamBase": string;
751
+ "canConfigure": boolean;
752
+ "inlinePlayer": boolean;
753
+ "serverHost": string;
754
+ "serverPort": number;
755
+ "serverId": string;
756
+ "allowInsecure": boolean;
757
+ "heartbeatInterval": number;
758
+ }
759
+ interface PhirepassMediaPlayerAttributes {
760
+ "src": string;
761
+ "name": string;
762
+ "mime": string;
763
+ "status": string;
764
+ "ready": number;
765
+ "positionKey": string;
766
+ "castDevice": string;
767
+ }
390
768
  interface PhirepassRdpAttributes {
391
769
  "serverHost": string;
392
770
  "serverPort": number;
@@ -430,6 +808,8 @@ declare namespace LocalJSX {
430
808
  }
431
809
 
432
810
  interface IntrinsicElements {
811
+ "phirepass-downloader": Omit<PhirepassDownloader, keyof PhirepassDownloaderAttributes> & { [K in keyof PhirepassDownloader & keyof PhirepassDownloaderAttributes]?: PhirepassDownloader[K] } & { [K in keyof PhirepassDownloader & keyof PhirepassDownloaderAttributes as `attr:${K}`]?: PhirepassDownloaderAttributes[K] } & { [K in keyof PhirepassDownloader & keyof PhirepassDownloaderAttributes as `prop:${K}`]?: PhirepassDownloader[K] } & OneOf<"nodeId", PhirepassDownloader["nodeId"], PhirepassDownloaderAttributes["nodeId"]>;
812
+ "phirepass-media-player": Omit<PhirepassMediaPlayer, keyof PhirepassMediaPlayerAttributes> & { [K in keyof PhirepassMediaPlayer & keyof PhirepassMediaPlayerAttributes]?: PhirepassMediaPlayer[K] } & { [K in keyof PhirepassMediaPlayer & keyof PhirepassMediaPlayerAttributes as `attr:${K}`]?: PhirepassMediaPlayerAttributes[K] } & { [K in keyof PhirepassMediaPlayer & keyof PhirepassMediaPlayerAttributes as `prop:${K}`]?: PhirepassMediaPlayer[K] } & OneOf<"src", PhirepassMediaPlayer["src"], PhirepassMediaPlayerAttributes["src"]> & OneOf<"name", PhirepassMediaPlayer["name"], PhirepassMediaPlayerAttributes["name"]>;
433
813
  "phirepass-rdp": Omit<PhirepassRdp, keyof PhirepassRdpAttributes> & { [K in keyof PhirepassRdp & keyof PhirepassRdpAttributes]?: PhirepassRdp[K] } & { [K in keyof PhirepassRdp & keyof PhirepassRdpAttributes as `attr:${K}`]?: PhirepassRdpAttributes[K] } & { [K in keyof PhirepassRdp & keyof PhirepassRdpAttributes as `prop:${K}`]?: PhirepassRdp[K] } & OneOf<"nodeId", PhirepassRdp["nodeId"], PhirepassRdpAttributes["nodeId"]> & OneOf<"serviceId", PhirepassRdp["serviceId"], PhirepassRdpAttributes["serviceId"]> & OneOf<"token", PhirepassRdp["token"], PhirepassRdpAttributes["token"]>;
434
814
  "phirepass-sftp-client": Omit<PhirepassSftpClient, keyof PhirepassSftpClientAttributes> & { [K in keyof PhirepassSftpClient & keyof PhirepassSftpClientAttributes]?: PhirepassSftpClient[K] } & { [K in keyof PhirepassSftpClient & keyof PhirepassSftpClientAttributes as `attr:${K}`]?: PhirepassSftpClientAttributes[K] } & { [K in keyof PhirepassSftpClient & keyof PhirepassSftpClientAttributes as `prop:${K}`]?: PhirepassSftpClient[K] } & OneOf<"nodeId", PhirepassSftpClient["nodeId"], PhirepassSftpClientAttributes["nodeId"]> & OneOf<"serviceId", PhirepassSftpClient["serviceId"], PhirepassSftpClientAttributes["serviceId"]> & OneOf<"token", PhirepassSftpClient["token"], PhirepassSftpClientAttributes["token"]>;
435
815
  "phirepass-terminal": Omit<PhirepassTerminal, keyof PhirepassTerminalAttributes> & { [K in keyof PhirepassTerminal & keyof PhirepassTerminalAttributes]?: PhirepassTerminal[K] } & { [K in keyof PhirepassTerminal & keyof PhirepassTerminalAttributes as `attr:${K}`]?: PhirepassTerminalAttributes[K] } & { [K in keyof PhirepassTerminal & keyof PhirepassTerminalAttributes as `prop:${K}`]?: PhirepassTerminal[K] } & OneOf<"nodeId", PhirepassTerminal["nodeId"], PhirepassTerminalAttributes["nodeId"]> & OneOf<"serviceId", PhirepassTerminal["serviceId"], PhirepassTerminalAttributes["serviceId"]> & OneOf<"token", PhirepassTerminal["token"], PhirepassTerminalAttributes["token"]>;
@@ -440,14 +820,26 @@ declare module "@stencil/core" {
440
820
  export namespace JSX {
441
821
  interface IntrinsicElements {
442
822
  /**
443
- * Remote desktop over RDP.
444
- * Unlike the terminal and SFTP widgets this one does not pipe protocol bytes
445
- * through the phirepass channel. The channel is used only to authorise the
446
- * session; the actual RDP stream runs on a second WebSocket opened by IronRDP's
447
- * own client, because that client speaks RDCleanPath and can set neither
448
- * headers nor a subprotocol on the socket it opens. See `RDP.md` in
449
- * `phirepass-rs` for why the session is split across two sockets.
823
+ * Remote Fetch: paste a link or a magnet, or drop a `.torrent`, and the node
824
+ * downloads it into its own download folder.
825
+ * Two forms, one component. **Embedded** in the SFTP browser (`compact`), it
826
+ * shares the host's channel, which forwards it the `Download*` frames through
827
+ * `receive()`, and saves into the folder on screen when the node can map it.
828
+ * **Standalone**, it builds its own channel, signs in with `token`, and saves
829
+ * into the download folder or a sub-folder of it. Either way it never asks for
830
+ * a login: the node writes its own files.
831
+ * The widget only sends events and shows progress. Downloads run on the node
832
+ * and carry on after the tab closes.
833
+ */
834
+ "phirepass-downloader": LocalJSX.IntrinsicElements["phirepass-downloader"] & JSXBase.HTMLAttributes<HTMLPhirepassDownloaderElement>;
835
+ /**
836
+ * Plays a file from the node with the browser's own `<video>` or `<audio>`.
837
+ * It knows nothing of channels or WASM: `src` is a stream URL the server turns
838
+ * into stream events towards the agent, and the browser's range requests do
839
+ * the rest. A download that is still arriving plays as far as `ready` bytes;
840
+ * past that the element waits, and so does the player, saying why.
450
841
  */
842
+ "phirepass-media-player": LocalJSX.IntrinsicElements["phirepass-media-player"] & JSXBase.HTMLAttributes<HTMLPhirepassMediaPlayerElement>;
451
843
  "phirepass-rdp": LocalJSX.IntrinsicElements["phirepass-rdp"] & JSXBase.HTMLAttributes<HTMLPhirepassRdpElement>;
452
844
  "phirepass-sftp-client": LocalJSX.IntrinsicElements["phirepass-sftp-client"] & JSXBase.HTMLAttributes<HTMLPhirepassSftpClientElement>;
453
845
  "phirepass-terminal": LocalJSX.IntrinsicElements["phirepass-terminal"] & JSXBase.HTMLAttributes<HTMLPhirepassTerminalElement>;
@@ -1402,7 +1402,7 @@ export declare namespace JSXBase {
1402
1402
  contextmenu?: string;
1403
1403
  dir?: string;
1404
1404
  draggable?: boolean;
1405
- hidden?: boolean;
1405
+ hidden?: boolean | 'until-found';
1406
1406
  id?: string;
1407
1407
  inert?: boolean;
1408
1408
  lang?: string;
@@ -0,0 +1,25 @@
1
+ import type { FetchCaps, FetchJob } from '../common/fetch';
2
+ import type { SFTPListItem } from '../common/protocol';
3
+ /**
4
+ * Data for stories and tests: the nodes, folders and downloads the Remote
5
+ * Fetch mockups draw, so every screen can be shown with the real widgets.
6
+ */
7
+ export declare const NODE_ID = "7b0c3c1e-6f0a-4f43-9d1e-0c5b8f1a2d10";
8
+ export declare const NODE_LABEL = "raspberrypi";
9
+ export declare const DOWNLOAD_FOLDER = "/home/pi/Downloads";
10
+ export declare const MEDIA_FOLDER = "/home/pi/media";
11
+ export declare function caps(over?: Partial<FetchCaps>): FetchCaps;
12
+ export declare function job(over?: Partial<FetchJob>): FetchJob;
13
+ /** Rows from mockup A: three active, one finished, one retrying. */
14
+ export declare function drawerJobs(): FetchJob[];
15
+ /** Mockup R: one row per state, top to bottom. */
16
+ export declare function everyState(): FetchJob[];
17
+ /** Mockup R2: torrent, schedule, disk and login states. */
18
+ export declare function moreStates(): FetchJob[];
19
+ /** H4: the Finished tab. */
20
+ export declare function finishedJobs(): FetchJob[];
21
+ /** H: the standalone desktop. */
22
+ export declare function standaloneJobs(): FetchJob[];
23
+ export declare function entry(name: string, kind: SFTPListItem['kind'], over?: Partial<SFTPListItem['attributes']>, path?: string): SFTPListItem;
24
+ /** The folders mockups A and C browse. */
25
+ export declare function mediaListing(): Record<string, SFTPListItem[]>;