dsh-mobile-plugin 0.5.100 → 0.5.101
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/routes/mobile-api.js
CHANGED
|
@@ -159,7 +159,18 @@ function profileNodeModulesOf(ctx) {
|
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
function registerMobileRoutes(deps) {
|
|
162
|
-
const { registerRoute, tailcat, p2p,
|
|
162
|
+
const { registerRoute: registerRouteRaw, registerUpgradeRoute: registerUpgradeRouteRaw, tailcat, p2p, guarded, state, getControl, hostMetadata, getSidecarSnapshot, safeLanCandidates, safeIpv6Candidates, lanPortInUse, mux = { handleUpgrade: () => {} }, preview, core, pairingApproval, rotatePairing, getHistoryKey, credentials, dropDeviceStreams } = deps;
|
|
163
|
+
/**
|
|
164
|
+
* 移动端路由对**宿主层**要匿名:安全由 `guarded` 里的设备凭据校验负责,不能指望桌面会话。
|
|
165
|
+
* 新版宿主把未声明 `auth` 的路由按 `required` 处理,手机没有桌面 peer,就会在网关层被判
|
|
166
|
+
* 403/401,根本进不到 token 守卫。这里统一给移动路由补 `auth: 'anonymous'`;控制面
|
|
167
|
+
* `/api/relay/*` 不经过本函数,仍保持要求桌面会话。
|
|
168
|
+
*/
|
|
169
|
+
const anonymousRoute = (route) => (route && route.auth === undefined ? { ...route, auth: 'anonymous' } : route)
|
|
170
|
+
const registerRoute = (route) => registerRouteRaw(anonymousRoute(route))
|
|
171
|
+
const registerUpgradeRoute = typeof registerUpgradeRouteRaw === 'function'
|
|
172
|
+
? (route) => registerUpgradeRouteRaw(anonymousRoute(route))
|
|
173
|
+
: registerUpgradeRouteRaw
|
|
163
174
|
const currentRelayUrl = () => {
|
|
164
175
|
const tunnel = getSidecarSnapshot?.()?.tunnel
|
|
165
176
|
return state.enabled && tunnel?.state === 'connected' ? tunnel.relayUrl || tunnel.route?.url || null : null
|
package/lib/shell/runtime.js
CHANGED
|
@@ -118,6 +118,9 @@ export function createRuntime() {
|
|
|
118
118
|
function ensureHttpDispatcher(path, sample) {
|
|
119
119
|
if (httpDispatchers.has(path) || !dispatchServer || !dispatchOuter) return
|
|
120
120
|
const dispatcher = {
|
|
121
|
+
// 原样带上样例路由的其余字段(尤其 `auth` 准入策略)——新版宿主按 `auth` 判准入,
|
|
122
|
+
// 漏掉它会被当成 "required",把本该由插件自己 token 守卫的移动端路由挡在网关外。
|
|
123
|
+
...(sample || {}),
|
|
121
124
|
kind: sample && sample.kind,
|
|
122
125
|
path,
|
|
123
126
|
handler: async (...args) => {
|
|
@@ -104,7 +104,7 @@ export function installTransportHosts(ctx) {
|
|
|
104
104
|
})
|
|
105
105
|
try {
|
|
106
106
|
if (typeof ctx.webServer.registerUpgrade === 'function') {
|
|
107
|
-
ctx.effect(() => ctx.webServer.registerUpgrade({ path: '/api/mobile/v1/mux', handler: muxService.handleUpgrade }), 'dsh-mobile-plugin: mux upgrade route')
|
|
107
|
+
ctx.effect(() => ctx.webServer.registerUpgrade({ path: '/api/mobile/v1/mux', handler: muxService.handleUpgrade, auth: 'anonymous' }), 'dsh-mobile-plugin: mux upgrade route')
|
|
108
108
|
}
|
|
109
109
|
} catch { /* 宿主没有升级路由能力时这条不挂,App 走 HTTP/SSE 兜底 */ }
|
|
110
110
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-mobile-plugin",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.101",
|
|
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",
|