@wisdoverse/dsh-inline-media-viewer 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -18
- package/LICENSE +21 -21
- package/README.md +3 -0
- package/README.zh-CN.md +2 -0
- package/SECURITY.md +67 -67
- package/client/client.js +555 -554
- package/index.js +185 -185
- package/lib.js +178 -178
- package/package.json +43 -43
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.2
|
|
4
|
+
|
|
5
|
+
- Make the settings navigation and all setting copy react live to DSH's
|
|
6
|
+
English/Chinese UI language through the standard locale slot contract.
|
|
7
|
+
- Add a dependency-free client registration test for both locale dictionaries
|
|
8
|
+
and the settings locale namespace.
|
|
9
|
+
|
|
3
10
|
## 1.0.1
|
|
4
11
|
|
|
5
12
|
- Publish the plugin as `@wisdoverse/dsh-inline-media-viewer` for one-command
|
|
@@ -8,22 +15,22 @@
|
|
|
8
15
|
documentation with the scoped package name.
|
|
9
16
|
|
|
10
17
|
## 1.0.0
|
|
11
|
-
|
|
12
|
-
- **Initial public release.** Inline image/video/audio previews in the
|
|
13
|
-
conversation tail (`conversation.chat.turnTail` projection): any media
|
|
14
|
-
path or media URL mentioned in a chat turn renders inline under that
|
|
15
|
-
turn.
|
|
16
|
-
- **Workspace-confined local reads** — a path renders only when it
|
|
17
|
-
resolves inside the calling session's workspace root (`realpath` +
|
|
18
|
-
containment; no symlink escapes).
|
|
19
|
-
- **Configurable ComfyUI proxy** — media URLs on the local aliases
|
|
20
|
-
(`127.0.0.1`/`localhost` on port 8188) or on the configured server
|
|
21
|
-
address are fetched server-side from the configured origin, with
|
|
22
|
-
redirects refused, a 20 s timeout, and a 48 MiB cap.
|
|
23
|
-
- **Settings page** (媒体预览 / Media preview): auto-render toggle,
|
|
24
|
-
per-turn cap (1–30), max media height (160–1200 px), ComfyUI server
|
|
25
|
-
address — persisted through the DSH settings document (loopback
|
|
26
|
-
writes).
|
|
27
|
-
- **Pure helpers** in a dependency-free `lib.js` with a zero-dependency
|
|
28
|
-
unit test runner (`node test.mjs`), plus README, SECURITY, and MIT
|
|
18
|
+
|
|
19
|
+
- **Initial public release.** Inline image/video/audio previews in the
|
|
20
|
+
conversation tail (`conversation.chat.turnTail` projection): any media
|
|
21
|
+
path or media URL mentioned in a chat turn renders inline under that
|
|
22
|
+
turn.
|
|
23
|
+
- **Workspace-confined local reads** — a path renders only when it
|
|
24
|
+
resolves inside the calling session's workspace root (`realpath` +
|
|
25
|
+
containment; no symlink escapes).
|
|
26
|
+
- **Configurable ComfyUI proxy** — media URLs on the local aliases
|
|
27
|
+
(`127.0.0.1`/`localhost` on port 8188) or on the configured server
|
|
28
|
+
address are fetched server-side from the configured origin, with
|
|
29
|
+
redirects refused, a 20 s timeout, and a 48 MiB cap.
|
|
30
|
+
- **Settings page** (媒体预览 / Media preview): auto-render toggle,
|
|
31
|
+
per-turn cap (1–30), max media height (160–1200 px), ComfyUI server
|
|
32
|
+
address — persisted through the DSH settings document (loopback
|
|
33
|
+
writes).
|
|
34
|
+
- **Pure helpers** in a dependency-free `lib.js` with a zero-dependency
|
|
35
|
+
unit test runner (`node test.mjs`), plus README, SECURITY, and MIT
|
|
29
36
|
LICENSE.
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Wisdoverse
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Wisdoverse
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -97,6 +97,9 @@ through [`cordis.patch.yml`](cordis.patch.yml).
|
|
|
97
97
|
|
|
98
98
|
Open **Settings → 媒体预览 / Media preview**.
|
|
99
99
|
|
|
100
|
+
The navigation label and all setting copy follow DSH's active UI language and
|
|
101
|
+
switch live between English and Chinese.
|
|
102
|
+
|
|
100
103
|
| Setting | Default | Allowed values |
|
|
101
104
|
| --- | --- | --- |
|
|
102
105
|
| Auto-render detected media | On | On / off |
|
package/README.zh-CN.md
CHANGED
package/SECURITY.md
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
# Security
|
|
2
|
-
|
|
3
|
-
This plugin renders media in a user's chat. It is a **local trust helper**, not
|
|
4
|
-
a security boundary: the conversation content it renders is produced by the
|
|
5
|
-
same session that views it. What shipping standards demand here is that the
|
|
6
|
-
plugin *cannot be turned into a wider primitive* — no arbitrary local file
|
|
7
|
-
exfiltration, no arbitrary SSRF, no unbounded memory use.
|
|
8
|
-
|
|
9
|
-
## Local file reads
|
|
10
|
-
|
|
11
|
-
- Only the session's workspace root is readable: `realpath(cwd)` + containment
|
|
12
|
-
check (`isInside`) against the resolved target. Symlink escapes, `..`
|
|
13
|
-
traversal, and out-of-workspace paths are rejected.
|
|
14
|
-
- Only known media extensions are accepted (MIME map in `lib.js`).
|
|
15
|
-
- Size cap: 48 MiB per file.
|
|
16
|
-
- The client must supply a valid session id; the workspace root is taken from
|
|
17
|
-
that session's header, never from client input.
|
|
18
|
-
|
|
19
|
-
## Remote (ComfyUI) proxy
|
|
20
|
-
|
|
21
|
-
- The fetch target is always the **configured ComfyUI origin** (default
|
|
22
|
-
`http://127.0.0.1:8188`, `comfyUrl` in the `inline-media` settings
|
|
23
|
-
namespace) — never the source host. Chat content can therefore only
|
|
24
|
-
select a path/query on a server the user configured, not an arbitrary
|
|
25
|
-
host.
|
|
26
|
-
- A source URL is accepted only when its host:port is a local alias
|
|
27
|
-
(`127.0.0.1` / `localhost` on port 8188) **or** matches the configured
|
|
28
|
-
origin; everything else is rejected before any network I/O.
|
|
29
|
-
- The configured address is validated to a bare `http(s)://host[:port]`
|
|
30
|
-
origin: credentials, paths, queries, hashes, and odd hostnames are
|
|
31
|
-
rejected. A non-empty invalid value fails remote reads with an explicit
|
|
32
|
-
error instead of silently retargeting; an empty value uses the built-in
|
|
33
|
-
default.
|
|
34
|
-
- Settings writes are loopback-only (see below), so only the local user
|
|
35
|
-
can point the proxy at another host — a remote viewer cannot retarget it.
|
|
36
|
-
- `redirect: "error"` — redirects are refused.
|
|
37
|
-
- 20 s timeout, 48 MiB response cap, and the response MIME must be
|
|
38
|
-
image/video/audio.
|
|
39
|
-
|
|
40
|
-
## Transport
|
|
41
|
-
|
|
42
|
-
- The media channel `/inline-media/read` is registered with the DSH
|
|
43
|
-
connection service (`authority: "trusted-host"`), so it runs under the same
|
|
44
|
-
browser-trust fence and session gating as DSH's own RPC surface.
|
|
45
|
-
- The client renderer never receives file system paths back — only `data:`
|
|
46
|
-
URLs — so a hostile session cannot use the channel as a file oracle for
|
|
47
|
-
paths the UI already knows.
|
|
48
|
-
|
|
49
|
-
## Settings
|
|
50
|
-
|
|
51
|
-
- Values are normalized client-side and validated server-side against the
|
|
52
|
-
schema (autoRender boolean; displayCap 1–30; imageMaxPx 160–1200;
|
|
53
|
-
comfyUrl string ≤ 512 chars, parsed to a bare origin at use time).
|
|
54
|
-
- The settings service only writes back for **loopback** connections; remote
|
|
55
|
-
browsers are read-only, so a remote viewer cannot persist state.
|
|
56
|
-
|
|
57
|
-
## Known limitations
|
|
58
|
-
|
|
59
|
-
- Remote (non-loopback) browsers cannot persist settings by design (DSH
|
|
60
|
-
settings writes are loopback-only).
|
|
61
|
-
- ComfyUI on a non-standard host/port: set the server address in the settings
|
|
62
|
-
page. The proxy fetches only from that configured origin, so it must be
|
|
63
|
-
reachable from the DSH host process — plain `http://` for a local install,
|
|
64
|
-
`https://` behind a TLS-terminating proxy. The loopback aliases
|
|
65
|
-
(`127.0.0.1`/`localhost` on port 8188) are always accepted as source
|
|
66
|
-
origins; editing `COMFY_HOSTS`/`COMFY_PORTS` is deliberate code surgery,
|
|
67
|
-
not a configuration surface.
|
|
1
|
+
# Security
|
|
2
|
+
|
|
3
|
+
This plugin renders media in a user's chat. It is a **local trust helper**, not
|
|
4
|
+
a security boundary: the conversation content it renders is produced by the
|
|
5
|
+
same session that views it. What shipping standards demand here is that the
|
|
6
|
+
plugin *cannot be turned into a wider primitive* — no arbitrary local file
|
|
7
|
+
exfiltration, no arbitrary SSRF, no unbounded memory use.
|
|
8
|
+
|
|
9
|
+
## Local file reads
|
|
10
|
+
|
|
11
|
+
- Only the session's workspace root is readable: `realpath(cwd)` + containment
|
|
12
|
+
check (`isInside`) against the resolved target. Symlink escapes, `..`
|
|
13
|
+
traversal, and out-of-workspace paths are rejected.
|
|
14
|
+
- Only known media extensions are accepted (MIME map in `lib.js`).
|
|
15
|
+
- Size cap: 48 MiB per file.
|
|
16
|
+
- The client must supply a valid session id; the workspace root is taken from
|
|
17
|
+
that session's header, never from client input.
|
|
18
|
+
|
|
19
|
+
## Remote (ComfyUI) proxy
|
|
20
|
+
|
|
21
|
+
- The fetch target is always the **configured ComfyUI origin** (default
|
|
22
|
+
`http://127.0.0.1:8188`, `comfyUrl` in the `inline-media` settings
|
|
23
|
+
namespace) — never the source host. Chat content can therefore only
|
|
24
|
+
select a path/query on a server the user configured, not an arbitrary
|
|
25
|
+
host.
|
|
26
|
+
- A source URL is accepted only when its host:port is a local alias
|
|
27
|
+
(`127.0.0.1` / `localhost` on port 8188) **or** matches the configured
|
|
28
|
+
origin; everything else is rejected before any network I/O.
|
|
29
|
+
- The configured address is validated to a bare `http(s)://host[:port]`
|
|
30
|
+
origin: credentials, paths, queries, hashes, and odd hostnames are
|
|
31
|
+
rejected. A non-empty invalid value fails remote reads with an explicit
|
|
32
|
+
error instead of silently retargeting; an empty value uses the built-in
|
|
33
|
+
default.
|
|
34
|
+
- Settings writes are loopback-only (see below), so only the local user
|
|
35
|
+
can point the proxy at another host — a remote viewer cannot retarget it.
|
|
36
|
+
- `redirect: "error"` — redirects are refused.
|
|
37
|
+
- 20 s timeout, 48 MiB response cap, and the response MIME must be
|
|
38
|
+
image/video/audio.
|
|
39
|
+
|
|
40
|
+
## Transport
|
|
41
|
+
|
|
42
|
+
- The media channel `/inline-media/read` is registered with the DSH
|
|
43
|
+
connection service (`authority: "trusted-host"`), so it runs under the same
|
|
44
|
+
browser-trust fence and session gating as DSH's own RPC surface.
|
|
45
|
+
- The client renderer never receives file system paths back — only `data:`
|
|
46
|
+
URLs — so a hostile session cannot use the channel as a file oracle for
|
|
47
|
+
paths the UI already knows.
|
|
48
|
+
|
|
49
|
+
## Settings
|
|
50
|
+
|
|
51
|
+
- Values are normalized client-side and validated server-side against the
|
|
52
|
+
schema (autoRender boolean; displayCap 1–30; imageMaxPx 160–1200;
|
|
53
|
+
comfyUrl string ≤ 512 chars, parsed to a bare origin at use time).
|
|
54
|
+
- The settings service only writes back for **loopback** connections; remote
|
|
55
|
+
browsers are read-only, so a remote viewer cannot persist state.
|
|
56
|
+
|
|
57
|
+
## Known limitations
|
|
58
|
+
|
|
59
|
+
- Remote (non-loopback) browsers cannot persist settings by design (DSH
|
|
60
|
+
settings writes are loopback-only).
|
|
61
|
+
- ComfyUI on a non-standard host/port: set the server address in the settings
|
|
62
|
+
page. The proxy fetches only from that configured origin, so it must be
|
|
63
|
+
reachable from the DSH host process — plain `http://` for a local install,
|
|
64
|
+
`https://` behind a TLS-terminating proxy. The loopback aliases
|
|
65
|
+
(`127.0.0.1`/`localhost` on port 8188) are always accepted as source
|
|
66
|
+
origins; editing `COMFY_HOSTS`/`COMFY_PORTS` is deliberate code surgery,
|
|
67
|
+
not a configuration surface.
|