dsh-msg9-kit 0.2.0 → 0.2.1
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/README.md +17 -3
- package/README.zh-CN.md +10 -2
- package/lib/client.js +79 -79
- package/lib/index.js +192 -45
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -137,10 +137,16 @@ The panel resolves the same workspace from the current session's `cwd` (the
|
|
|
137
137
|
|
|
138
138
|
## Install
|
|
139
139
|
|
|
140
|
+
```bash
|
|
141
|
+
dsh plugin --profile web add dsh-msg9-kit
|
|
142
|
+
# then restart dsh web and refresh the browser
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
From source (for development):
|
|
146
|
+
|
|
140
147
|
```bash
|
|
141
148
|
npm install && npm run build # builds lib/index.js + lib/client.js
|
|
142
149
|
bash scripts/install-personal.sh # dsh plugin --profile web add <this dir>
|
|
143
|
-
# then restart dsh web and refresh the browser
|
|
144
150
|
```
|
|
145
151
|
|
|
146
152
|
The plugin is one Loader entry; its `dsh.client` manifest makes the browser load
|
|
@@ -200,6 +206,12 @@ State (`~/.dsh/msg9-kit/state.json`, 0600, written atomically):
|
|
|
200
206
|
A state file that fails to parse is never silently discarded: it is copied to
|
|
201
207
|
`state.json.corrupt-*` and reported, because it holds irreplaceable inbox keys.
|
|
202
208
|
|
|
209
|
+
One `DSH_HOME` supports **one dsh instance**: writes are serialized with a
|
|
210
|
+
`state.json.lock` file lock, so a second instance sharing the same state file
|
|
211
|
+
fails loudly (`state file is locked by another process`) instead of silently
|
|
212
|
+
overwriting irreplaceable inbox keys. Run each instance with its own
|
|
213
|
+
`DSH_HOME` / `MSG9_STATE_FILE`.
|
|
214
|
+
|
|
203
215
|
## Typical use
|
|
204
216
|
|
|
205
217
|
```
|
|
@@ -219,8 +231,10 @@ what it sent, and the address book it messages most.
|
|
|
219
231
|
|
|
220
232
|
## HTTP bridge
|
|
221
233
|
|
|
222
|
-
The panel talks to these same-origin routes (
|
|
223
|
-
|
|
234
|
+
The panel talks to these same-origin routes (never a key in the response).
|
|
235
|
+
Requests are accepted only when the connection itself comes from loopback
|
|
236
|
+
(`remoteAddress`), plus a same-origin `Origin` check for browsers — a forged
|
|
237
|
+
`Host` header from another local process does not pass:
|
|
224
238
|
|
|
225
239
|
| Route | Purpose |
|
|
226
240
|
|---|---|
|
package/README.zh-CN.md
CHANGED
|
@@ -102,10 +102,16 @@ dsh-<slug>-<hash4>@msg9.io
|
|
|
102
102
|
|
|
103
103
|
## 安装
|
|
104
104
|
|
|
105
|
+
```bash
|
|
106
|
+
dsh plugin --profile web add dsh-msg9-kit
|
|
107
|
+
# 然后重启 dsh web 并刷新浏览器
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
从源码改装(开发时):
|
|
111
|
+
|
|
105
112
|
```bash
|
|
106
113
|
npm install && npm run build # 产出 lib/index.js + lib/client.js
|
|
107
114
|
bash scripts/install-personal.sh # 等价于 dsh plugin --profile web add <本目录>
|
|
108
|
-
# 然后重启 dsh web 并刷新浏览器
|
|
109
115
|
```
|
|
110
116
|
|
|
111
117
|
插件只有一个 Loader entry,包内的 `dsh.client` 声明让浏览器从同一个包加载 `./client` 面,因此图标和面板无需额外配置。
|
|
@@ -155,6 +161,8 @@ bash scripts/install-personal.sh # 等价于 dsh plugin --profile web add <
|
|
|
155
161
|
|
|
156
162
|
状态文件解析失败时**不会**被静默清空:它会先被复制为 `state.json.corrupt-*` 再报错——因为里面存着不可再生的收件箱 key。
|
|
157
163
|
|
|
164
|
+
一个 `DSH_HOME` 只支持**一个 dsh 实例**:写入前会对 `state.json.lock` 加文件锁,第二个共享同一状态文件的实例会响亮报错(`state file is locked by another process`),而不是互相覆盖不可再生的收件箱 key。多实例请各用各的 `DSH_HOME` / `MSG9_STATE_FILE`。
|
|
165
|
+
|
|
158
166
|
## 典型用法
|
|
159
167
|
|
|
160
168
|
```
|
|
@@ -173,7 +181,7 @@ msg9_send({ to: "dsh-alpha-a1b2@msg9.io", text: "schema 已更新", correlation_
|
|
|
173
181
|
|
|
174
182
|
## HTTP 桥
|
|
175
183
|
|
|
176
|
-
|
|
184
|
+
面板调用的同源接口(响应里永不含 key)。只接受连接来源本身是本机 loopback(`remoteAddress`)的请求,浏览器另有 `Origin` 同源校验——本机其他进程伪造 `Host` 头不再放行:
|
|
177
185
|
|
|
178
186
|
| 路由 | 用途 |
|
|
179
187
|
|---|---|
|