dsh-mobile-plugin 0.5.106 → 0.5.108
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/lib/index.js +9 -1
- package/lib/panel/index.html +11 -11
- package/lib/relay/pairing-payload.cjs +16 -6
- package/lib/shell/updater.js +52 -0
- package/lib/zeronews/wiring.cjs +16 -3
- package/package.json +15 -15
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// 2026-11-24:出码把内置公用中转地址并进中转两格,给扫不上服务商线路(routes)的 iOS 兜底;宿主配置与停用逻辑不动。
|
|
1
2
|
// 2026-11-24:出码前的「有没有可用地址」收成 `pairingHasAddress`,服务商线路也算数——两个出码入口同用一处判据。
|
|
2
3
|
// 2026-11-23:第三方服务商线路随二维码一起下发(通用 `routes` 一栏):以后加服务商不用再改二维码。
|
|
3
4
|
// 配对二维码的 IPv6 候选为手填那条预留一席,避免被条数上限切掉。
|
|
@@ -17,7 +18,7 @@
|
|
|
17
18
|
|
|
18
19
|
const os = require('node:os');
|
|
19
20
|
// 中转地址两格的收敛:二维码里 `relayUrls[0]` 必须与 `relayUrl` 是同一个字符串。
|
|
20
|
-
const { relayAddressesOf } = require('./core.js');
|
|
21
|
+
const { relayAddressesOf, PUBLIC_RELAY_URLS } = require('./core.js');
|
|
21
22
|
const { providerLinesOf } = require('./provider-lines.cjs');
|
|
22
23
|
const {
|
|
23
24
|
advertisedCandidates,
|
|
@@ -93,12 +94,21 @@ function pairingPayload(state, lanPort) {
|
|
|
93
94
|
const tcpLanUrl = tcpTarget ? `http://${tcpTarget}` : '';
|
|
94
95
|
if (tcpLanUrl && !urls.includes(tcpLanUrl)) urls.push(tcpLanUrl);
|
|
95
96
|
// 老手机只读 `relayUrl`(语义一个字没变),新手机优先读数组、没有就退化到单条。
|
|
96
|
-
// `relayUrls[0]` 恒等于 `relayUrl
|
|
97
|
+
// `relayUrls[0]` 恒等于 `relayUrl` 这条不变式,在发进码的这一份里由下面的 codeRelays 保证。
|
|
97
98
|
//
|
|
98
|
-
//
|
|
99
|
-
//
|
|
99
|
+
// 2026-11-24 用户要求:出码时把内置公用中转地址并进这两格。引导页现在按地区配服务商,
|
|
100
|
+
// 但 iOS 扫不上 routes 里的服务商地址,给一条公用地址它就能拨。只改发进二维码的这一份,
|
|
101
|
+
// 不写回 state、不动停用逻辑:宿主配了自建的仍排在前、公用做兜底;没配中转的(新装 /
|
|
102
|
+
// 只接服务商)码里就只有这一条公用地址,手机扫到即可连。
|
|
100
103
|
const relay = relayAddressesOf(state);
|
|
101
|
-
const
|
|
104
|
+
const codeRelays = [...relay.relayUrls];
|
|
105
|
+
for (const url of PUBLIC_RELAY_URLS) {
|
|
106
|
+
if (!codeRelays.includes(url)) codeRelays.push(url);
|
|
107
|
+
}
|
|
108
|
+
const codeRelayUrl = codeRelays[0] || '';
|
|
109
|
+
// **只有一条时不写数组**:那个数组恒等于单值,写进去是同一串地址在码里出现两遍,
|
|
110
|
+
// 白占七八个模块。追加公用后通常仍只有一条,省下来的这几格最划算。
|
|
111
|
+
const relayList = codeRelays.length > 1 ? codeRelays : undefined;
|
|
102
112
|
// 服务商线路:与心跳 / 总控同源,另补 Cloudflare;同址已进 lanUrls 的不重复写。
|
|
103
113
|
const routes = pairingRoutes(state, new Set(urls));
|
|
104
114
|
const payload = {
|
|
@@ -116,7 +126,7 @@ function pairingPayload(state, lanPort) {
|
|
|
116
126
|
// 老 App 只取自己认识的那几个字段,多出来的两个会被忽略 —— 一张二维码同时服务新旧两种。
|
|
117
127
|
proto: 2,
|
|
118
128
|
ticket: state.pairingTicket || '',
|
|
119
|
-
relayUrl:
|
|
129
|
+
relayUrl: codeRelayUrl,
|
|
120
130
|
lanUrls: urls,
|
|
121
131
|
// 用户手填的直连地址(穿透域名 / 公网 IP)单独一格:手机据此把它落到「直连」栏,
|
|
122
132
|
// 不从 `lanUrls` 里猜。`lanUrls` 里仍带着它只为老手机兼容,新手机读到这一格会剔掉。
|
package/lib/shell/updater.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** 2026-11-24:判新版改为与装包同源(优先问 npm,市场兜底),修 106 卡住不放。 */
|
|
1
2
|
/** 更新账本保留安装恢复结果,外壳(含启动时加载的常驻模块)变化提示重新载入外壳。 */
|
|
2
3
|
/**
|
|
3
4
|
* 更新编排:查与装都归实现自己,装完就地换代(不重启 DSH)。
|
|
@@ -183,6 +184,57 @@ export async function checkUpdate(base, name = PACKAGE_NAME, { force = false } =
|
|
|
183
184
|
}
|
|
184
185
|
}
|
|
185
186
|
|
|
187
|
+
/**
|
|
188
|
+
* 外壳的进程启动时就把插件树定死了:盘上那一代换过之后,这里再 require 会拿到旧模块。
|
|
189
|
+
* 所以「判有没有新版」也跟装包一样,从盘上那一代**动态**取查询模块(带时间戳绕开缓存)。
|
|
190
|
+
*/
|
|
191
|
+
async function generationModule(dir, rel) {
|
|
192
|
+
const file = path.join(dir, 'lib', rel)
|
|
193
|
+
if (!fs.existsSync(file)) return null
|
|
194
|
+
try {
|
|
195
|
+
return await import(`${pathToFileURL(file).href}?v=${Date.now()}`)
|
|
196
|
+
} catch {
|
|
197
|
+
return null
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* 用盘上那一代自己的查询模块问 npm 注册表——与真正装包同一个源。
|
|
203
|
+
*
|
|
204
|
+
* 装包走 `update-install.cjs`(问 npm 注册表),而自动更新以前拿去判「有没有新版」的
|
|
205
|
+
* `check()` 问的是 DSH 市场:市场没装 / 太老 / 还没同步到新版本时,那一头说「没新版」,
|
|
206
|
+
* 自动更新就地停摆,可 App 和手动更新走 npm 却看得到新版。两处判据必须同源。
|
|
207
|
+
*
|
|
208
|
+
* 盘上那一代没有查询模块(老版本 / 无头源码部署)就拿到 null,调用方退回市场,不让
|
|
209
|
+
* 自动更新整个坏掉。拿不到注册表地址也照查——查询模块自己会退回官方源。
|
|
210
|
+
*/
|
|
211
|
+
export async function checkFromGeneration({ packageManager = null } = {}) {
|
|
212
|
+
const dir = installedPackageDirSafe()
|
|
213
|
+
if (!dir) return null
|
|
214
|
+
const reg = await generationModule(dir, 'update-registry.cjs')
|
|
215
|
+
const inst = await generationModule(dir, 'update-install.cjs')
|
|
216
|
+
const checkForUpdate = reg?.checkForUpdate ?? reg?.default?.checkForUpdate
|
|
217
|
+
const profileRegistry = inst?.profileRegistry ?? inst?.default?.profileRegistry
|
|
218
|
+
const declaredSource = inst?.declaredSource ?? inst?.default?.declaredSource
|
|
219
|
+
if (typeof checkForUpdate !== 'function' || typeof profileRegistry !== 'function') return null
|
|
220
|
+
try {
|
|
221
|
+
const base = await profileRegistry({ profileNodeModules: profileNodeModules(), packageManager })
|
|
222
|
+
const source = typeof declaredSource === 'function'
|
|
223
|
+
? declaredSource(path.dirname(profileNodeModules()))
|
|
224
|
+
: null
|
|
225
|
+
const update = await checkForUpdate({ installedVersion: installedVersion(), source, base: base ?? undefined })
|
|
226
|
+
return {
|
|
227
|
+
installedVersion: typeof update.installedVersion === 'string' ? update.installedVersion : null,
|
|
228
|
+
latestVersion: typeof update.latestVersion === 'string' ? update.latestVersion : null,
|
|
229
|
+
updateAvailable: update.updateAvailable === true,
|
|
230
|
+
source: typeof update.source === 'string' ? update.source : null,
|
|
231
|
+
channelSwitch: false,
|
|
232
|
+
}
|
|
233
|
+
} catch {
|
|
234
|
+
return null
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
186
238
|
/**
|
|
187
239
|
* 这条链能不能自动更新。
|
|
188
240
|
*
|
package/lib/zeronews/wiring.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// 2026-11-24
|
|
1
|
+
// 2026-11-24:首次接入先开代理商邀请链接埋归属 cookie,让新注册用户无感归到代理商名下。
|
|
2
2
|
// ZeroNews 线路挂载:把运行器接进装配层,隧道地址写回独立字段,随 effect 启停。
|
|
3
3
|
// 第一次接入的登录:`zeronews login` 要一直活着轮询设备授权码,浏览器确认后才把 token 落盘,
|
|
4
4
|
// 所以这里保留它继续跑、不设 NO_TTY、也不在拿到确认地址后就杀掉(见 defaultLogin)。
|
|
@@ -19,6 +19,15 @@
|
|
|
19
19
|
const { execFile, spawn } = require('node:child_process');
|
|
20
20
|
const path = require('node:path');
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* 代理商邀请链接:新用户从插件首次接入 ZeroNews 时,得先让浏览器落一次这个地址,ZeroNews 才会
|
|
24
|
+
* 把 agent 写进 zn_agent_ref cookie(域名 user.zeronews.cc、Path=/、30 天)。之后即使真正绑机
|
|
25
|
+
* 走的是官方 CLI 确认页 /cli/login,它发出的登录请求也会带上这个 cookie,新账号就归到代理商名下。
|
|
26
|
+
* 用户不用手动点邀请链接、也不用复制什么,只看到照常的浏览器确认页——这就是「无感」的来源。
|
|
27
|
+
* 归属只对新注册生效(厂商规则:注册/邀请链接仅能绑定新用户),老的 ZeroNews 账号不受影响。
|
|
28
|
+
*/
|
|
29
|
+
const AGENT_INVITE_URL = 'https://user.zeronews.cc/login?agent=14ad108deb4142228c8607acd2f2aac2';
|
|
30
|
+
|
|
22
31
|
const { createZeroNewsRunner } = require('./runner.cjs');
|
|
23
32
|
const { ensureZeroNews } = require('./provision.cjs');
|
|
24
33
|
const { createZeroNewsAccountReader } = require('./account.cjs');
|
|
@@ -219,7 +228,11 @@ function mountZeroNews(options) {
|
|
|
219
228
|
}
|
|
220
229
|
// 交给后台继续轮询:用户在浏览器确认后它自己把 token 写进本机配置,面板轮询 status 就会看到登录成功。
|
|
221
230
|
if (started.child) loginChild = started.child;
|
|
222
|
-
const
|
|
231
|
+
const open = (url) => (typeof options.openUrl === 'function' ? options.openUrl(url) : openInBrowser(url, exec));
|
|
232
|
+
// 先开邀请链接埋归属 cookie,再开官方确认页。顺序要紧:必须在确认页登录之前让浏览器带上 agent
|
|
233
|
+
// cookie,新账号才会归到代理商名下。邀请链接打不开不影响绑机(cookie 没埋上而已),故忽略结果。
|
|
234
|
+
await open(AGENT_INVITE_URL);
|
|
235
|
+
const opened = await open(started.url);
|
|
223
236
|
return { ok: true, downloaded: got.source === 'downloaded', opened: opened === true, url: started.url, loginPending: true };
|
|
224
237
|
};
|
|
225
238
|
|
|
@@ -272,4 +285,4 @@ function mountZeroNews(options) {
|
|
|
272
285
|
return facade;
|
|
273
286
|
}
|
|
274
287
|
|
|
275
|
-
module.exports = { mountZeroNews };
|
|
288
|
+
module.exports = { mountZeroNews, AGENT_INVITE_URL };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-mobile-plugin",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.108",
|
|
4
4
|
"description": "Mobile API (/api/mobile/v1) and relay client for the DSH mobile app — desktop profile build (dsh 0.2.x, peers resolved by the host)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"icon": "./icon.png",
|
|
@@ -117,23 +117,23 @@
|
|
|
117
117
|
"yaml": "2.9.1"
|
|
118
118
|
},
|
|
119
119
|
"dshMobileReleaseNotes": {
|
|
120
|
-
"version": "0.5.
|
|
120
|
+
"version": "0.5.108",
|
|
121
121
|
"kinds": [
|
|
122
|
-
"
|
|
123
|
-
"
|
|
122
|
+
"fix",
|
|
123
|
+
"feature"
|
|
124
124
|
],
|
|
125
125
|
"notes": {
|
|
126
|
-
"zh-Hans": "-
|
|
127
|
-
"zh-Hant": "-
|
|
128
|
-
"en": "-
|
|
129
|
-
"ja": "-
|
|
130
|
-
"ko": "-
|
|
131
|
-
"de": "-
|
|
132
|
-
"es": "-
|
|
133
|
-
"fr": "-
|
|
134
|
-
"pt": "-
|
|
135
|
-
"ru": "-
|
|
136
|
-
"tr": "-
|
|
126
|
+
"zh-Hans": "- 修复插件卡在旧版不自动更新的问题:电脑判断有没有新版现在和真正安装走同一个来源,不会再出现「手机上有提示、电脑上却一直不动」。\n- App 现在每隔半小时检查一次插件新版,一直开着也能收到更新提示,不用再切到后台再回来。\n- 插件更新完成后会自动清掉页面上残留的「更新 / 稍后再说」;设备多的时候,更新页可以一次把所有设备一起更新。",
|
|
127
|
+
"zh-Hant": "- 修復外掛卡在舊版不自動更新的問題:電腦判斷有沒有新版現在和真正安裝走同一個來源,不會再出現「手機上有提示、電腦上卻一直不動」。\n- App 現在每隔半小時檢查一次外掛新版,一直開著也能收到更新提示,不用再切到背景再回來。\n- 外掛更新完成後會自動清掉頁面上殘留的「更新 / 稍後再說」;裝置多的時候,更新頁可以一次把所有裝置一起更新。",
|
|
128
|
+
"en": "- Fixed a bug where the plugin could get stuck on an old version and never auto-update: the computer now checks for new versions from the same source it installs from, so the phone can show an update while the computer stays put no longer happens.\n- The app now checks for plugin updates every 30 minutes, so you'll get the notification even if you leave it open — no need to send it to the background and come back.\n- After an update finishes, the leftover \"Update / Later\" buttons are cleared automatically; with many devices, the update page can update them all at once.",
|
|
129
|
+
"ja": "- プラグインが古いバージョンで固まって自動更新されない問題を修正しました。新しいバージョンがあるかの確認を、実際のインストールと同じ情報源から行うようになり、「スマホには通知が出るのにパソコンが動かない」という状態が起きなくなりました。\n- アプリが30分ごとにプラグインの更新を確認するようになり、開いたままでも通知が届きます。バックグラウンドにして戻る必要はありません。\n- 更新完了後にページに残る「更新 / 後で」ボタンが自動で消えます。デバイスが多い場合、更新ページですべてをまとめて更新できます。",
|
|
130
|
+
"ko": "- 플러그인이 오래된 버전에 멈춰 자동 업데이트되지 않던 문제를 수정했습니다. 새 버전이 있는지 확인할 때 실제 설치와 같은 출처를 사용하므로, \"휴대전화에는 알림이 뜨는데 컴퓨터는 그대로인\" 상황이 더 이상 발생하지 않습니다.\n- 앱이 30분마다 플러그인 업데이트를 확인하므로 계속 열어 두어도 알림을 받을 수 있습니다. 백그라운드로 보냈다가 돌아올 필요가 없습니다.\n- 업데이트가 끝나면 화면에 남아 있던 \"업데이트 / 나중에\" 버튼이 자동으로 사라집니다. 기기가 많으면 업데이트 페이지에서 모두 한 번에 업데이트할 수 있습니다.",
|
|
131
|
+
"de": "- Behoben: Das Plugin blieb manchmal auf einer alten Version hängen und aktualisierte sich nicht automatisch. Der Computer prüft jetzt auf dieselbe Weise auf neue Versionen, wie er auch installiert — „das Handy zeigt eine Update-Meldung, der Computer bleibt stehen“ passiert nicht mehr.\n- Die App prüft jetzt alle 30 Minuten auf Plugin-Updates, sodass du auch bei dauerhaft geöffneter App eine Benachrichtigung bekommst — ohne in den Hintergrund und zurück zu wechseln.\n- Nach Abschluss eines Updates verschwinden die übrig gebliebenen Buttons „Aktualisieren / Später“ automatisch; bei vielen Geräten kann die Update-Seite alle auf einmal aktualisieren.",
|
|
132
|
+
"es": "- Corregido: el plugin podía quedarse atascado en una versión antigua y no actualizarse solo. Ahora el ordenador comprueba si hay versiones nuevas desde la misma fuente que usa para instalar, así que ya no ocurre que «el móvil muestra un aviso pero el ordenador no se mueve».\n- La app ahora comprueba las actualizaciones del plugin cada 30 minutos, así que recibirás el aviso aunque la dejes abierta, sin necesidad de pasar a segundo plano y volver.\n- Al terminar una actualización, los botones sobrantes de «Actualizar / Más tarde» desaparecen automáticamente; con muchos dispositivos, la página de actualizaciones puede actualizarlos todos a la vez.",
|
|
133
|
+
"fr": "- Corrigé : le plugin pouvait rester bloqué sur une ancienne version et ne pas se mettre à jour automatiquement. L'ordinateur vérifie désormais l'existence de nouvelles versions depuis la même source que celle utilisée pour l'installation : le cas « le téléphone affiche une notification mais l'ordinateur ne bouge pas » ne se produit plus.\n- L'application vérifie maintenant les mises à jour du plugin toutes les 30 minutes : vous recevrez la notification même si elle reste ouverte, sans passer en arrière-plan et revenir.\n- Une fois la mise à jour terminée, les boutons restants « Mettre à jour / Plus tard » disparaissent automatiquement ; avec de nombreux appareils, la page de mise à jour peut tous les mettre à jour en une seule fois.",
|
|
134
|
+
"pt": "- Corrigido: o plugin podia ficar preso numa versão antiga e não atualizar sozinho. Agora o computador verifica se há versões novas na mesma fonte usada para instalar, então não acontece mais de «o celular mostrar um aviso e o computador ficar parado».\n- O app agora verifica atualizações do plugin a cada 30 minutos, então você recebe o aviso mesmo deixando-o aberto, sem precisar ir para o segundo plano e voltar.\n- Após a conclusão da atualização, os botões restantes de «Atualizar / Depois» desaparecem automaticamente; com muitos dispositivos, a página de atualizações pode atualizar todos de uma vez.",
|
|
135
|
+
"ru": "- Исправлено: плагин мог застрять на старой версии и не обновляться автоматически. Теперь компьютер проверяет наличие новых версий из того же источника, из которого выполняет установку, поэтому ситуация «телефон показывает уведомление, а компьютер не реагирует» больше не возникает.\n- Теперь приложение проверяет обновления плагина каждые 30 минут, поэтому уведомление придёт даже если оно всё время открыто — не нужно сворачивать его и возвращаться.\n- После завершения обновления оставшиеся кнопки «Обновить / Позже» исчезают автоматически; при большом количестве устройств страница обновлений может обновить их все сразу.",
|
|
136
|
+
"tr": "- Düzeltildi: eklenti eski bir sürüme takılıp kendiliğinden güncellenmeyebiliyordu. Artık bilgisayar yeni sürüm olup olmadığını, kurulumu yaptığı kaynaktan kontrol ediyor; böylece \"telefonda bildirim çıkıyor ama bilgisayar kıpırdamıyor\" durumu artık oluşmuyor.\n- Uygulama artık eklenti güncellemelerini 30 dakikada bir kontrol ediyor; açık bıraksanız da bildirim gelir, arka plana alıp geri dönmeniz gerekmez.\n- Bir güncelleme tamamlandığında geride kalan \"Güncelle / Daha sonra\" düğmeleri otomatik kaybolur; cihaz sayısı fazlaysa güncelleme sayfası tümünü aynı anda güncelleyebilir."
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
}
|