opencode-next 1.0.4 → 1.0.5

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 CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  All notable changes to `opencode-next` (`OpenCode-Next-for-DSH`) are documented in this file.
4
4
 
5
+ ## [1.0.5] - 2026-11-26
6
+
7
+ ### Added
8
+ - Added root `icon.svg` (`./icon`) and localized plugin metadata (`locale/en.json`, `locale/zh.json`, `locale/zh-Hant.json`) so DSH's Installed Plugins list displays the OpenCode-Next logo, title, and localized description.
9
+ - Integrated DSH host HTTP route admission via `connection.requestRejection` (`401`/`403` empty-body rejections with `cache-control: no-store` and fail-closed error handling) in `lib/web-api.js`, while retaining explicit `sec-fetch-site` and local loopback fallback checks for older DSH releases (`>=0.1.5-rc.1 <0.3.0`).
10
+
11
+ ### Changed
12
+ - Recorded DSH `0.2.1-rc.5` in `dsh.compatibility.dshReleases` in `package.json`.
13
+
5
14
  ## [1.0.4] - 2026-11-26
6
15
 
7
16
  ### Fixed
package/README.md CHANGED
@@ -237,7 +237,7 @@ Alternative sources:
237
237
 
238
238
  ```bash
239
239
  # Install from GitHub Release tarball
240
- dsh plugin --profile desktop add https://github.com/kizaki-R/OpenCode-Next-for-DSH/releases/download/v1.0.4/opencode-next-1.0.4.tgz
240
+ dsh plugin --profile desktop add https://github.com/kizaki-R/OpenCode-Next-for-DSH/releases/download/v1.0.5/opencode-next-1.0.5.tgz
241
241
 
242
242
  # Or directly from GitHub
243
243
  dsh plugin --profile desktop add github:kizaki-R/OpenCode-Next-for-DSH
@@ -249,7 +249,7 @@ dsh plugin --profile desktop add github:kizaki-R/OpenCode-Next-for-DSH
249
249
 
250
250
  ```bash
251
251
  npm pack
252
- dsh plugin --profile desktop add ./opencode-next-1.0.4.tgz
252
+ dsh plugin --profile desktop add ./opencode-next-1.0.5.tgz
253
253
  ```
254
254
 
255
255
  > **Re-pack after changing the source.** `npm pack` only includes files matched
package/README.zh-TW.md CHANGED
@@ -139,7 +139,7 @@ dsh plugin --profile desktop add opencode-next
139
139
 
140
140
  ```bash
141
141
  # 從 GitHub Release 下載安裝
142
- dsh plugin --profile desktop add https://github.com/kizaki-R/OpenCode-Next-for-DSH/releases/download/v1.0.4/opencode-next-1.0.4.tgz
142
+ dsh plugin --profile desktop add https://github.com/kizaki-R/OpenCode-Next-for-DSH/releases/download/v1.0.5/opencode-next-1.0.5.tgz
143
143
 
144
144
  # 或直接從 GitHub 倉庫安裝
145
145
  dsh plugin --profile desktop add github:kizaki-R/OpenCode-Next-for-DSH
@@ -168,7 +168,7 @@ dsh plugin --profile desktop add github:kizaki-R/OpenCode-Next-for-DSH
168
168
  ### 方式 4:使用打包後的 tgz 安裝(離線分發)
169
169
 
170
170
  ```bash
171
- dsh plugin --profile desktop add ./opencode-next-1.0.4.tgz
171
+ dsh plugin --profile desktop add ./opencode-next-1.0.5.tgz
172
172
  ```
173
173
 
174
174
  > **改完程式碼要重新打包。** `npm pack` 只會裝進 `package.json` 的 `files` 白名單
package/icon.svg ADDED
@@ -0,0 +1,16 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="512" height="512" role="img" aria-label="OpenCode Next">
2
+ <defs>
3
+ <linearGradient id="gRing" gradientUnits="userSpaceOnUse" x1="0" y1="158" x2="0" y2="354"><stop offset="0" stop-color="#A8B5C8"/><stop offset="1" stop-color="#5B6B82"/></linearGradient>
4
+ <linearGradient id="gChev" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#06B6D4"/><stop offset="1" stop-color="#2563EB"/></linearGradient>
5
+ <mask id="cut" maskUnits="userSpaceOnUse" x="0" y="0" width="512" height="512"><rect width="512" height="512" fill="#fff"/><path d="M377.15 200.85 A78 78 0 1 0 377.15 311.15" fill="none" stroke="#000" stroke-width="64" stroke-linecap="round"/></mask>
6
+
7
+ </defs>
8
+
9
+ <g transform="translate(256 256) scale(1.12) translate(-256 -256)">
10
+ <g transform="translate(11 0)">
11
+ <circle cx="190" cy="256" r="78" fill="none" stroke="url(#gRing)" stroke-width="40" mask="url(#cut)"/>
12
+ <path d="M377.15 200.85 A78 78 0 1 0 377.15 311.15" fill="none" stroke="url(#gRing)" stroke-width="40" stroke-linecap="round"/>
13
+ <path d="M334 234 L356 256 L334 278" fill="none" stroke="url(#gChev)" stroke-width="16" stroke-linecap="round" stroke-linejoin="round"/>
14
+ </g>
15
+ </g>
16
+ </svg>
package/lib/web-api.js CHANGED
@@ -218,11 +218,61 @@ function isAllowedLocalRequest(request) {
218
218
  return true;
219
219
  }
220
220
 
221
+ /**
222
+ * 透過 DSH 宿主 `connection.requestRejection` 執行官方准入檢查(DSH 0.2.0-rc.2+)。
223
+ *
224
+ * - 若宿主已提供 `connection.requestRejection`,以宿主 Host/Origin 政策與瀏覽器認證為準;
225
+ * 拒絕時回傳 401 或 403,且拋錯時採 Fail-Closed 回傳 403,絕不洩漏內部資料。
226
+ * - 若環境不提供 `connection` 服務(舊版 DSH 或無瀏覽器測試環境),則回報 `handled: false`,
227
+ * 交由第二道本機來源檢查 `isAllowedLocalRequest()` 把關。
228
+ */
229
+ function normalizeHeadersForAdmission(rawHeaders) {
230
+ if (!rawHeaders || typeof rawHeaders !== 'object') return {};
231
+ if (typeof rawHeaders.entries === 'function') {
232
+ return Object.fromEntries(rawHeaders.entries());
233
+ }
234
+ return rawHeaders;
235
+ }
236
+
237
+ function checkConnectionAdmission(ctx, webCtx, request) {
238
+ const connection = webCtx?.get?.('connection') ?? ctx?.get?.('connection');
239
+ const check = connection?.requestRejection;
240
+ if (typeof check !== 'function') {
241
+ return { handled: false, rejection: undefined };
242
+ }
243
+ try {
244
+ const rejection = check.call(connection, {
245
+ headers: normalizeHeadersForAdmission(request?.headers)
246
+ });
247
+ if (rejection === 401 || rejection === 403) {
248
+ return { handled: true, rejection };
249
+ }
250
+ return { handled: true, rejection: undefined };
251
+ } catch {
252
+ return { handled: true, rejection: 403 };
253
+ }
254
+ }
255
+
256
+ function isCrossSiteFetch(request) {
257
+ const headers = request?.headers;
258
+ if (!headers || typeof headers !== 'object') return false;
259
+ const secFetchSite = typeof headers.get === 'function'
260
+ ? headers.get('sec-fetch-site')
261
+ : (headers['sec-fetch-site'] ?? headers['Sec-Fetch-Site']);
262
+ return (
263
+ typeof secFetchSite === 'string' &&
264
+ secFetchSite !== '' &&
265
+ secFetchSite !== 'same-origin' &&
266
+ secFetchSite !== 'none'
267
+ );
268
+ }
269
+
221
270
  /**
222
271
  * 註冊路由。
223
272
  *
224
273
  * 以 `ctx.inject(['webServer'], ...)` 包住:沒有 web server 的 profile(例如純
225
274
  * headless 執行)仍然載得進本外掛,只是沒有狀態頁,而不是在啟動時直接爆掉。
275
+ * 請求進來時優先走宿主 `connection.requestRejection` 准入檢查,並保留本機來源防線。
226
276
  */
227
277
  export function registerWebApi(ctx, {
228
278
  tokenManager,
@@ -241,7 +291,16 @@ export function registerWebApi(ctx, {
241
291
  kind: 'prefix',
242
292
  path: PREFIX,
243
293
  handler: async (request, response) => {
244
- if (!isAllowedLocalRequest(request)) {
294
+ const admission = checkConnectionAdmission(ctx, webCtx, request);
295
+ if (admission.rejection) {
296
+ response.writeHead(admission.rejection, { 'cache-control': 'no-store' });
297
+ response.end();
298
+ return;
299
+ }
300
+ if (isCrossSiteFetch(request)) {
301
+ return sendJson(response, 403, { ok: false, error: 'forbidden_origin' });
302
+ }
303
+ if (!admission.handled && !isAllowedLocalRequest(request)) {
245
304
  return sendJson(response, 403, { ok: false, error: 'forbidden_origin' });
246
305
  }
247
306
 
package/locale/en.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "OpenCode-Next",
4
+ "description": "Native OpenCode OAuth & OpenCode Go provider for DeepSeek Harness: dual-track OAuth, Bun transport, model probing & curation, and Go subscription quota tracking."
5
+ }
6
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "OpenCode-Next",
4
+ "description": "DeepSeek Harness 的 OpenCode OAuth 與 OpenCode Go 模型供應商:支援雙軌 OAuth、Bun 原生傳輸、模型可用性探測、自訂清單與 Go 訂閱額度管理。"
5
+ }
6
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "OpenCode-Next",
4
+ "description": "DeepSeek Harness 的 OpenCode OAuth 与 OpenCode Go 模型供应商:支持双轨 OAuth、Bun 原生传输、模型可用性探测、自定义清单及 Go 订阅额度管理。"
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "opencode-next",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "OpenCode-Next: Native OpenCode OAuth & OpenCode Go provider for DeepSeek Harness (DSH)",
5
+ "icon": "./icon.svg",
5
6
  "repository": {
6
7
  "type": "git",
7
8
  "url": "git+https://github.com/kizaki-R/OpenCode-Next-for-DSH.git"
@@ -16,11 +17,17 @@
16
17
  ".": "./lib/index.js",
17
18
  "./client": "./lib/ui.js",
18
19
  "./config": "./lib/config.js",
20
+ "./icon": "./icon.svg",
21
+ "./locale/en.json": "./locale/en.json",
22
+ "./locale/zh.json": "./locale/zh.json",
23
+ "./locale/zh-Hant.json": "./locale/zh-Hant.json",
19
24
  "./package.json": "./package.json"
20
25
  },
21
26
  "files": [
22
27
  "lib",
23
28
  "bin",
29
+ "locale",
30
+ "icon.svg",
24
31
  "cordis.patch.yml",
25
32
  "CHANGELOG.md",
26
33
  "README.zh-TW.md"
@@ -61,7 +68,8 @@
61
68
  "dsh": ">=0.1.5-rc.1 <0.3.0",
62
69
  "dshReleases": {
63
70
  "0.1.5-rc.1": "compatible",
64
- "0.2.0-rc.2": "compatible"
71
+ "0.2.0-rc.2": "compatible",
72
+ "0.2.1-rc.5": "compatible"
65
73
  }
66
74
  }
67
75
  },