Skip to content

A full-featured download manager.

fix(server): allow terminal extension pairing without web url (#2400)

Dr_rOot4de1b3a6245e
diff --git a/.claude/rules/bridge.md b/.claude/rules/bridge.md
index d10191c9..ce415fc6 100644
--- a/.claude/rules/bridge.md
+++ b/.claude/rules/bridge.md
@@ -46,8 +46,11 @@ Import `ErrorCodes` and `makeMdxpError` from the package.
Approval is proven by typing the pairing code, never by clicking an Allow
button. The dialog shows an 8-symbol Crockford-alphabet code grouped
`XXXX-XXXX` (`mbp1/pairing-code.ts`), lives 120 seconds, and *is* the SPAKE2
-password: it never travels a network channel and MUST NOT be logged at any
-level (§7.1). A pairing session resolves to one of three identities —
+password: it never travels on the Extension connection and MUST NOT be logged
+at any level (§7.1). Server operator snapshots/events and an explicitly selected
+interactive `motrix-admin extension pair` view follow §4.4. The terminal uses
+fixed loopback RPC with the operator Bearer credential, rejects redirected streams
+and JSON, revalidates the exact session, and never renews the code lifetime. A pairing session resolves to one of three identities —
`official`, `attested-non-official`, `unverified` — and `official` is decided
by the immutable allowlist only, never the NM manifest set and never the
user-added trusted-extension registry (§5).
@@ -75,7 +78,11 @@ existing token + reverse-proxy model.
The Server's documented Docker path deliberately binds MDXP to `0.0.0.0`
inside the container so Docker can publish port 16801. Remote Extension routes
may use that non-loopback listener only behind a parser-issued, all-or-nothing
-remote configuration; `RemoteExtensionSurfacePolicy` then enforces the exact
+remote configuration; the WS/WSS public URL is required, while the operator URL
+is optional. Without an HTTPS operator URL or explicit HTTP consent, code-bearing
+operator snapshots/events are restricted to the authenticated local Bearer path.
+Both HTTP snapshots and event broadcasts must enforce the delivery policy from
+the same parser-issued configuration. `RemoteExtensionSurfacePolicy` enforces the exact
public Host and raw route prefix plus the admission limits before MBP1 runs.
Do not reintroduce a loopback-only bootstrap guard: container loopback is not
reachable through Docker's published-port path.
diff --git a/.claude/rules/i18n.md b/.claude/rules/i18n.md
index 83c78e51..b27e2658 100644
--- a/.claude/rules/i18n.md
+++ b/.claude/rules/i18n.md
@@ -24,6 +24,10 @@ locale changes transactional, including rollback on failure.
locale files. Only English and Simplified Chinese are eager; await resource loading before
committing a host or renderer language change. New languages also require a catalog entry in
`src/shared/constants/locales.ts` and a matching JSON resource.
+- The server operator CLI uses `src/server/operator-admin-locales.ts` to
+ import only the `operatorAdmin` namespace from every catalog. Keep its locale
+ map exhaustive; importing full application catalogs into the CLI duplicates
+ Web UI resources in the Server package and can exceed its size budget.
- Every translation leaf is a string. Keep readable locale files as UTF-8;
avoid unnecessary `\uXXXX` escapes.
- English user-visible prose, including matching test fixtures and assertions,
diff --git a/docs/bridge-pairing-protocol.md b/docs/bridge-pairing-protocol.md
index 61b5e63d..b3ac92da 100644
--- a/docs/bridge-pairing-protocol.md
+++ b/docs/bridge-pairing-protocol.md
@@ -260,9 +260,9 @@ MOTRIX_PUBLIC_URL=http(s)://operator-host[:port][/base-path]
MOTRIX_ALLOW_INSECURE_OPERATOR_HTTP=false
```
-When enabled, both public URLs are required. The WebSocket URL accepts only WS
-or WSS. The operator URL accepts HTTPS by default. An HTTP operator URL is
-accepted only when `MOTRIX_ALLOW_INSECURE_OPERATOR_HTTP=true` supplies a second,
+When enabled, the WebSocket public URL is required and accepts only WS or WSS.
+The operator URL is optional and is never inferred from the WebSocket address.
+If present, it accepts HTTPS by default. An HTTP operator URL is accepted only when `MOTRIX_ALLOW_INSECURE_OPERATOR_HTTP=true` supplies a second,
explicit opt-in; startup then warns that the operator token, pairing codes,
session cookies, and administrator traffic lack TLS protection. This exception
is for a trusted LAN only and is forbidden for Internet-facing or untrusted-LAN
@@ -303,11 +303,28 @@ public raw-route gate, raw MDXP is rejected, and CLI/operator bearers cannot
enter either Extension route.
The pairing code is released only through an authenticated operator snapshot or
-event channel. HTTP snapshot/mutation responses use `Cache-Control: no-store`;
+event channel. Web delivery additionally requires a valid configured HTTPS
+operator URL or explicit insecure-HTTP consent. Without either, operator
+snapshots exclude Extension requests and event sockets skip Extension
+`PairRequested` messages while retaining ordinary events and CLI requests.
+An authenticated operator Bearer request may read the snapshot over an observed
+loopback connection: its original headers MUST contain exactly one loopback Host
+with the actual listening port, and no Origin, Forwarded, or X-Forwarded-* header
+(even an empty one). Locality comes from the peer socket, never forwarded IPs.
+A privileged local proxy can emulate this connection; the operator token already
+grants machine-owner authority, so this is not physical isolation from an
+administrator who possesses that token. HTTP snapshot/mutation responses use `Cache-Control: no-store`;
cookie-authenticated operator WebSockets require an Origin exactly matching the
canonical `MOTRIX_PUBLIC_URL`, and mutation CSRF remains enforced. Codes do not
-enter URL, log, persistent browser storage, clipboard, CLI output, or
-notification text. The user reads the code and types it into the Extension.
+enter URL, log, persistent browser storage, clipboard, noninteractive CLI output,
+or notification text. `motrix-admin extension pair` may display one explicitly
+selected live code on an interactive terminal after authenticating over fixed
+loopback RPC. It MUST reject JSON and redirected streams, sanitize request
+metadata, revalidate the selected session and its original expiry, and clear the
+display on exit, cancellation, expiry, or failure. Reading never extends expiry;
+a disappeared request is not proof of successful pairing. A terminal viewer
+closing does not approve or deny the request. Terminal recording and privileged
+access remain within the administrator trust boundary. The user reads the code and types it into the Extension.
Origin/CSRF, HttpOnly, SameSite, no-store, and login-rate controls remain active
in explicitly authorized HTTP mode, but they do not provide confidentiality or
prevent an on-path attacker from reading or altering operator traffic.
@@ -799,8 +816,10 @@ retry. Implementations MUST test worker death both before and after approval.
the 40 bits big-endian into eight 5-bit groups; each group indexes the
alphabet.
- **Display**: uppercase, grouped `XXXX-XXXX`, shown **only** in the Motrix
- approval dialog. The code is the PAKE password: it MUST never travel over
- any network channel in any form, and MUST never be logged.
+ approval dialog, or the authenticated Server operator surfaces in §4.4
+ (including the explicitly selected interactive terminal view). The code is the
+ PAKE password: it MUST never travel on the Extension connection, and MUST never
+ be logged. Server operator delivery follows the separate §4.4 policy.
- **Input normalization** (extension side, before local validation): strip
ASCII hyphens and spaces; uppercase; map `O→0`, `I→1`, `L→1`; then require
exactly 8 alphabet symbols. A string failing local validation MUST be
diff --git a/docs/bridge-pairing-protocol.zh-CN.md b/docs/bridge-pairing-protocol.zh-CN.md
index 267c1709..856083e0 100644
--- a/docs/bridge-pairing-protocol.zh-CN.md
+++ b/docs/bridge-pairing-protocol.zh-CN.md
@@ -184,6 +184,46 @@ token + 反向代理模型,不在 MBP1 范围内。)
---
+### 4.4 远程 Motrix Server 配置与终端配对
+
+远程扩展功能必须显式启用,并在配置无效时保持关闭。配置项为:
+
+```text
+MOTRIX_REMOTE_EXTENSION_ENABLED=false
+MOTRIX_REMOTE_EXTENSION_PUBLIC_URL=ws(s)://host[:port][/base-path]
+MOTRIX_PUBLIC_URL=http(s)://operator-host[:port][/base-path]
+MOTRIX_ALLOW_INSECURE_OPERATOR_HTTP=false
+```
+
+启用后必须提供 WS/WSS 扩展地址。Web 管理地址可选,不得从扩展地址推测其主机、
+端口或路径。提供 Web 地址时必须严格校验;HTTPS 默认允许,HTTP 必须同时显式
+授权 `MOTRIX_ALLOW_INSECURE_OPERATOR_HTTP=true`。该例外仅适用于可信局域网。
+无效的 URL 或布尔值只关闭远程扩展入口,不改变 CLI/agent 与桌面行为。
+
+扩展入口继续按 WS/WSS 地址严格校验原始 Host、有效端口和路径前缀,保留 nonce、
+限流、凭据、撤销与 MBP1 验证。Web 和扩展地址可使用不同主机。没有配置 HTTPS
+管理地址、也没有 HTTP 显式授权时,Web 待配对快照必须过滤扩展请求,事件连接必须
+跳过扩展 `PairRequested` 消息;普通任务事件、CLI 请求和不含码的结束事件继续工作。
+
+经过 operator Bearer 鉴权的请求可以通过实际观察到的本机回环连接读取快照:
+必须恰有一个原始 Host 头,匹配回环地址和实际监听端口,并且不得携带 Origin、
+Forwarded 或任何 X-Forwarded-* 头,包括空值。连接来源取自 socket,不能使用
+转发 IP。拥有 operator token 的管理员仍可通过改写头部的本机代理模拟这种连接;
+该 token 本身授予机器所有者权限,这项检查不构成对管理员的物理本机隔离。
+
+`motrix-admin extension pair` 可以通过固定回环地址和 operator 凭据,在交互终端
+展示用户明确选中的一个有效配对码。必须拒绝 JSON、管道和重定向,过滤请求元数据
+中的终端控制字符,并重新验证所选会话及其原始到期时间。退出、取消、过期、失败
+或挂起请求都必须清除配对码视图。读取不延长有效期,请求消失不代表成功,关闭
+查看界面不批准或拒绝请求。用户仍须在扩展中输入配对码完成 MBP1 握手。
+
+配对码不得进入 URL、日志、持久化浏览器存储、剪贴板、非交互 CLI 输出或通知文本。
+终端录制和管理员权限属于可信管理员会话的边界,清屏不保证消除录制记录。
+Web 快照和操作响应继续使用 `Cache-Control: no-store`;Cookie 事件连接仍校验
+配置的 Web Origin,缺省时使用现有同源策略;CSRF、HttpOnly、SameSite 和登录限流
+保持生效。HTTPS 代理必须保留正确 Host、Origin、Upgrade 和路径,HTTP 授权不意味着
+流量具有加密保护。
+
## 5. 扩展身份三态
审批对话框 MUST 区分三种身份状态;证明*是哪一个*扩展在调用,不等于证明它是
@@ -523,8 +563,9 @@ WebSocket 会重置 worker 空闲计时器(见附录 B);即便 worker 仍
(32 个符号;排除 `I`、`L`、`O`、`U`)。
- **长度**:8 个符号 = 恰好 40 bit,取自 5 个 CSPRNG 字节:将 40 bit 按
大端切成 8 组、每组 5 bit,逐组索引字母表。
-- **展示**:大写、按 `XXXX-XXXX` 分组,**只**显示在 Motrix 审批对话框中。
- 配对码即 PAKE 口令:MUST 绝不以任何形式经任何网络信道传输,MUST 绝不
+- **展示**:大写、按 `XXXX-XXXX` 分组,显示在 Motrix 审批对话框或 §4.4 允许的已鉴权 Server 管理界面、交互终端中。
+ 配对码即 PAKE 口令:MUST 绝不通过扩展连接传输;Server 的已鉴权管理界面及
+ 用户明确选择的交互终端展示遵循 §4.4。MUST 绝不
写入日志。
- **输入规范化**(扩展侧,本地校验之前):去掉 ASCII 连字符与空格;转
大写;映射 `O→0`、`I→1`、`L→1`;然后要求恰好 8 个字母表符号。本地校验
diff --git a/docs/docker-server.md b/docs/docker-server.md
index 1042735d..d0ac441c 100644
--- a/docs/docker-server.md
+++ b/docs/docker-server.md
@@ -412,6 +412,39 @@ To reject a request instead:
docker compose exec server motrix-admin pairing deny ABCD-EFGH
```
+Browser Extensions use a separate code-entry handshake. To pair using only the
+container terminal, enable the remote Extension listener and configure its exact
+WS/WSS address; `MOTRIX_PUBLIC_URL` is optional:
+
+```bash
+export MOTRIX_REMOTE_EXTENSION_ENABLED=true
+export MOTRIX_REMOTE_EXTENSION_PUBLIC_URL='ws://nas.example.lan:16801'
+```
+
+Recreate the container with the updated environment, start pairing in the
+Extension, then run:
+
+```bash
+docker compose exec server motrix-admin extension pair
+```
+
+Select the request you initiated and type its displayed code into the Extension.
+The command requires an interactive terminal for input, output and errors; do not
+use `-T`, pipes, redirection or `--json`. Codes are never printed in service logs
+or the ordinary `pairing pending` list. The original 120-second deadline is not
+extended. Closing the terminal view does not approve or deny the request; if a
+request disappears, check the Extension for its outcome. Terminal recording can
+capture the code, so use a trusted administrator session.
+
+Without a configured HTTPS operator URL or explicit
+`MOTRIX_ALLOW_INSECURE_OPERATOR_HTTP=true`, the Web UI receives no Extension
+pairing codes; use the interactive command. To show codes in the Web UI, configure
+HTTPS or explicitly authorize trusted-LAN HTTP. When the public Web URL is
+omitted, existing same-origin Web checks use the request Host and protocol.
+The Web and Extension addresses may use different hosts and ports; if a Web URL
+is configured, access the Web UI at that URL for its event connection.
+
+
Start pairing on the client first, then enter the code shown by that client.
The command intentionally has no approve-latest, approve-all, remote endpoint,
or token argument. Web approval remains available and is the normal path; this
@@ -747,7 +780,7 @@ uses this ownership record and the already-bound Web listener as one proof.
| `MOTRIX_BIND_IP` | Compose: `0.0.0.0` | Backward-compatible shared host-publish fallback |
| `MOTRIX_MDXP_HOST` | runtime: `127.0.0.1`; Compose: `0.0.0.0` | MDXP listener inside the container, not the host publish address |
| `MOTRIX_MDXP_PORT` | `16801` | MDXP listen port; `0` disables a stable published port |
-| `MOTRIX_PUBLIC_URL` | unset | Explicit externally reachable Web approval URL, not the MDXP URL; never defaults to localhost |
+| `MOTRIX_PUBLIC_URL` | unset | Optional externally reachable Web approval URL, not the MDXP URL; omitted Extension pairing uses the local terminal unless operator HTTP is explicitly allowed |
| `MOTRIX_REMOTE_EXTENSION_ENABLED` | `false` | Opt in to the four remote browser-Extension MBP1 routes |
| `MOTRIX_REMOTE_EXTENSION_PUBLIC_URL` | unset | Exact WS/WSS Server address entered in Motrix Extension |
| `MOTRIX_ALLOW_INSECURE_OPERATOR_HTTP` | `false` | Explicitly accept exposed operator credentials and traffic on a trusted-LAN HTTP deployment; never use on an untrusted network |
diff --git a/docs/docker-server.zh-CN.md b/docs/docker-server.zh-CN.md
index 44ef7428..a193b7a1 100644
--- a/docs/docker-server.zh-CN.md
+++ b/docs/docker-server.zh-CN.md
@@ -366,6 +366,33 @@ docker compose exec server motrix-admin pairing approve ABCD-EFGH
docker compose exec server motrix-admin pairing deny ABCD-EFGH
```
+浏览器扩展使用独立的配对码握手。若通过容器终端完成配对,启用远程扩展监听并配置
+准确的 WS/WSS 地址即可,`MOTRIX_PUBLIC_URL` 为可选项:
+
+```bash
+export MOTRIX_REMOTE_EXTENSION_ENABLED=true
+export MOTRIX_REMOTE_EXTENSION_PUBLIC_URL='ws://nas.example.lan:16801'
+```
+
+使用新环境变量重新创建容器,在扩展中发起配对,然后运行:
+
+```bash
+docker compose exec server motrix-admin extension pair
+```
+
+选择你刚发起的请求,将终端显示的配对码输入扩展。该命令要求输入、输出及错误输出
+均连接交互终端,不要使用 `-T`、管道、重定向或 `--json`。配对码不会出现在服务日志
+或普通 `pairing pending` 列表中,原有的 120 秒期限也不会延长。关闭终端视图不会
+批准或拒绝请求;若请求消失,请在扩展中确认结果。终端录制可能记录配对码,请使用
+可信的管理员会话。
+
+未配置 HTTPS 管理地址、也未显式设置 `MOTRIX_ALLOW_INSECURE_OPERATOR_HTTP=true`
+时,WebUI 不会收到扩展配对码,请使用交互式命令。若要在 WebUI 显示配对码,需配置
+HTTPS 或明确授权可信局域网 HTTP。省略 Web 地址时,现有 Web 同源检查使用请求的
+Host 和协议。Web 与扩展地址可以使用不同主机和端口;若配置了 Web 地址,请从该
+地址访问 WebUI,以满足其事件连接的来源校验。
+
+
先在客户端发起 pairing,再输入该客户端显示的验证码。该命令刻意不提供
approve-latest、approve-all、远程 endpoint 或 token 参数。Web 审批仍是正常
路径;这个入口只用于 headless 或恢复场景下的本机 operator 操作。
@@ -643,7 +670,7 @@ bridge lock 的恢复会把该 ownership 记录与已绑定的 Web listener 共
| `MOTRIX_BIND_IP` | Compose:`0.0.0.0` | 向后兼容的共享宿主发布 fallback |
| `MOTRIX_MDXP_HOST` | runtime:`127.0.0.1`;Compose:`0.0.0.0` | 容器内 MDXP listener,不是宿主发布地址 |
| `MOTRIX_MDXP_PORT` | `16801` | MDXP 监听端口;`0` 表示不使用固定发布端口 |
-| `MOTRIX_PUBLIC_URL` | 未设置 | 显式设置的外部可访问 Web 审批 URL,不是 MDXP URL;不会默认为 localhost |
+| `MOTRIX_PUBLIC_URL` | 未设置 | 可选的外部可访问 Web 审批 URL,不是 MDXP URL;未设置时扩展配对使用本机终端,除非明确授权管理界面 HTTP |
| `MOTRIX_REMOTE_EXTENSION_ENABLED` | `false` | 显式开启浏览器扩展使用的四条远程 MBP1 路由 |
| `MOTRIX_REMOTE_EXTENSION_PUBLIC_URL` | 未设置 | Motrix Extension 中应填写的准确 WS/WSS Server 地址 |
| `MOTRIX_ALLOW_INSECURE_OPERATOR_HTTP` | `false` | 在可信局域网显式接受 operator 凭据和管理流量暴露风险;不可信网络绝不能开启 |
diff --git a/src/server/bridge/bootstrap.test.ts b/src/server/bridge/bootstrap.test.ts
index 62974cfc..a826e120 100644
--- a/src/server/bridge/bootstrap.test.ts
+++ b/src/server/bridge/bootstrap.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises'
import { request as httpRequest } from 'node:http'
import { tmpdir } from 'node:os'
@@ -35,11 +36,77 @@ import {
} from '@test-utils/bridge-receiver'
import { makeDownloadTask } from '@test-utils/task'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import { createApp } from '../http/app'
+import { OperatorAdminExitCode, runOperatorAdmin } from '../operator-admin'
import {
bootstrapBridgeForServer,
type ServerExtensionReceiver,
} from './bootstrap'
-import { parseRemoteExtensionConfig } from './remote-extension-config'
+import {
+ parseRemoteExtensionConfig,
+ type RemoteExtensionConfig,
+} from './remote-extension-config'
+
+async function pairThroughOperatorTerminal(
+ runtime: Awaited<ReturnType<typeof bootstrapBridgeForServer>>,
+ config: RemoteExtensionConfig,
+ handshake: Awaited<ReturnType<typeof startPair>>
+) {
+ const token = 't'.repeat(43)
+ const app = await createApp({
+ operatorAuth: { operatorToken: token },
+ remoteExtensionConfig: config,
+ bridgeQueryHandlers: runtime.bridgeQueryHandlers,
+ })
+ const controller = new AbortController()
+ let reveal!: (code: string) => void
+ const shown = new Promise<string>((resolve) => {
+ reveal = resolve
+ })
+ const stdout: string[] = []
+ const stderr: string[] = []
+ let command: Promise<OperatorAdminExitCode> | undefined
+ try {
+ const address = await app.listen({ host: '127.0.0.1', port: 0 })
+ command = runOperatorAdmin(['extension', 'pair'], {
+ env: { MOTRIX_OPERATOR_TOKEN: token, PORT: new URL(address).port },
+ writeStdout: (message) => stdout.push(message),
+ writeStderr: (message) => stderr.push(message),
+ terminal: {
+ interactive: true,
+ signal: controller.signal,
+ begin() {},
+ clear() {},
+ close() {},
+ select: async () => '1',
+ show(lines) {
+ const code = lines
+ .join('\n')
+ .match(/^Pairing code: ([0-9A-Z]{4}-[0-9A-Z]{4})$/m)?.[1]
+ if (code) reveal(code)
+ },
+ },
+ })
+ const code = await Promise.race([
+ shown,
+ command.then(() => {
+ throw new Error('terminal exited before revealing the selected code')
+ }),
+ ])
+ const { channel } = await runPake(handshake, code)
+ const credential = await exchangeCredential(handshake, channel)
+ expect(await command).toBe(OperatorAdminExitCode.Success)
+ expect(stdout.join('')).not.toContain(code)
+ expect(stdout.join('')).not.toContain(token)
+ expect(stderr).toEqual([])
+ expect(stdout.join('')).toContain('Check the Extension')
+ return { code, channel, credential }
+ } finally {
+ controller.abort()
+ await command
+ await app.close()
+ }
+}
function readDeps(): ReadHandlerDeps {
return {
@@ -392,172 +459,181 @@ describe('bootstrapBridgeForServer', () => {
}
})
- it('serves the direct-LAN Extension routes across a persistent restart', async () => {
- const remoteExtensionConfig = parseRemoteExtensionConfig({
- MOTRIX_REMOTE_EXTENSION_ENABLED: 'true',
- MOTRIX_REMOTE_EXTENSION_PUBLIC_URL: 'ws://motrix.example/bridge',
- MOTRIX_PUBLIC_URL: 'https://motrix.example',
- })
- const firstReceiver = extensionReceiver()
- runtime = await bootstrapBridgeForServer({
- userDataDir,
- host: '0.0.0.0',
- port: 0,
- motrixVersion: '2.0',
- eventBus: { on: vi.fn(), off: vi.fn(), emit: vi.fn() },
- readHandlerDeps: readDeps(),
- writeHandlerDeps: writeDeps(),
- remoteExtensionConfig,
- createExtensionReceiver: () => firstReceiver,
- })
- expect(firstReceiver.restoreInflight).toHaveBeenCalledOnce()
- expect(firstReceiver.start).toHaveBeenCalledOnce()
- const firstInstanceId = await readFile(
- join(userDataDir, 'bridge', 'server-instance-id'),
- 'utf8'
- )
- expect(firstInstanceId).toMatch(/^[0-9a-f-]{36}$/u)
- expect(
- (await fetch(`http://127.0.0.1:${runtime.port}/discovery`)).status
- ).toBe(404)
- expect(
- (
- await fetch(`http://127.0.0.1:${runtime.port}/nonce`, {
- method: 'POST',
- headers: { 'X-Motrix-Bridge': '1' },
+ it.each([true, false])(
+ 'serves direct-LAN Extension routes across restart with operator URL=%s',
+ async (withOperatorUrl) => {
+ const remoteExtensionConfig = parseRemoteExtensionConfig({
+ MOTRIX_REMOTE_EXTENSION_ENABLED: 'true',
+ MOTRIX_REMOTE_EXTENSION_PUBLIC_URL: 'ws://motrix.example/bridge',
+ ...(withOperatorUrl
+ ? { MOTRIX_PUBLIC_URL: 'https://motrix.example' }
+ : {}),
+ })
+ const firstReceiver = extensionReceiver()
+ runtime = await bootstrapBridgeForServer({
+ userDataDir,
+ host: '0.0.0.0',
+ port: 0,
+ motrixVersion: '2.0',
+ eventBus: { on: vi.fn(), off: vi.fn(), emit: vi.fn() },
+ readHandlerDeps: readDeps(),
+ writeHandlerDeps: writeDeps(),
+ remoteExtensionConfig,
+ createExtensionReceiver: () => firstReceiver,
+ })
+ expect(firstReceiver.restoreInflight).toHaveBeenCalledOnce()
+ expect(firstReceiver.start).toHaveBeenCalledOnce()
+ const firstInstanceId = await readFile(
+ join(userDataDir, 'bridge', 'server-instance-id'),
+ 'utf8'
+ )
+ expect(firstInstanceId).toMatch(/^[0-9a-f-]{36}$/u)
+ expect(
+ (await fetch(`http://127.0.0.1:${runtime.port}/discovery`)).status
+ ).toBe(404)
+ expect(
+ (
+ await fetch(`http://127.0.0.1:${runtime.port}/nonce`, {
+ method: 'POST',
+ headers: { 'X-Motrix-Bridge': '1' },
+ })
+ ).status
+ ).toBe(404)
+ await expect(
+ rawRequest(runtime.port, [
+ 'GET /bridge/discovery HTTP/1.1',
+ 'Host: motrix.example',
+ 'Connection: close',
+ ])
+ ).resolves.toMatchObject({ status: 200 })
+ await expect(
+ rawRequest(runtime.port, [
+ 'POST /bridge/nonce HTTP/1.1',
+ 'Host: motrix.example',
+ 'X-Motrix-Bridge: 1',
+ 'Content-Length: 0',
+ 'Connection: close',
+ ])
+ ).resolves.toMatchObject({ status: 200 })
+ await expect(
+ runtime.bridgeQueryHandlers['bridge:listPaired']()
+ ).resolves.toEqual([])
+
+ // The public bundle is not merely connectable: a real first-pair channel
+ // reaches the shell receiver's validated download/submit handler.
+ const extensionId = 'lggbokfckofcgjndaboioakcmincinpo'
+ const handshake = await startPair({
+ port: runtime.port,
+ origin: `chrome-extension://${extensionId}`,
+ browser: 'chromium',
+ claimedExtensionId: extensionId,
+ routePrefix: '/bridge',
+ hostHeader: 'motrix.example',
+ })
+ const pending = (await runtime.bridgeQueryHandlers[
+ 'bridge:listPendingPairRequests'
+ ]()) as Array<{
+ kind: string
+ code?: string
+ verifiedOrigin?: string
+ originHost?: string
+ claimedExtensionId?: string
+ attestationClass?: string
+ publicAuthority?: string
+ }>
+ expect(pending).toHaveLength(1)
+ expect(pending[0]).toMatchObject({
+ verifiedOrigin: `chrome-extension://${extensionId}`,
+ originHost: extensionId,
+ claimedExtensionId: extensionId,
+ attestationClass: 'official',
+ publicAuthority: 'motrix.example',
+ })
+ const { code, channel, credential } = await pairThroughOperatorTerminal(
+ runtime,
+ remoteExtensionConfig,
+ handshake
+ )
+ const connection = mdxpOverChannel(handshake.wire, channel)
+ await connection.sendRequest(
+ 'motrix/initialize',
+ initializeParams(extensionId)
+ )
+ await expect(
+ connection.sendRequest('download/submit', {
+ source: {
+ pageUrl: 'https://example.com/watch',
+ pageTitle: 'Remote submit',
+ detectedAt: Date.now(),
+ },
+ selection: {
+ kind: 'direct',
+ primary: {
+ url: 'https://cdn.example.com/video.mp4',
+ headers: {},
+ cookies: [],
+ refererPolicy: 'strict-origin-when-cross-origin',
+ },
+ },
+ meta: { suggestedFilename: 'video.mp4', qualityLabel: 'source' },
})
- ).status
- ).toBe(404)
- await expect(
- rawRequest(runtime.port, [
- 'GET /bridge/discovery HTTP/1.1',
- 'Host: motrix.example',
- 'Connection: close',
- ])
- ).resolves.toMatchObject({ status: 200 })
- await expect(
- rawRequest(runtime.port, [
- 'POST /bridge/nonce HTTP/1.1',
- 'Host: motrix.example',
- 'X-Motrix-Bridge: 1',
- 'Content-Length: 0',
- 'Connection: close',
+ ).resolves.toEqual({ taskId: 'submitted' })
+ expect(firstReceiver.handle).toHaveBeenCalledOnce()
+ await vi.waitFor(async () =>
+ expect(
+ (await runtime?.bridgeQueryHandlers['bridge:listPaired']()) ?? []
+ ).toHaveLength(1)
+ )
+ const durablePairingState = await Promise.all([
+ readFile(join(userDataDir, 'bridge', 'mbp1-credentials.json'), 'utf8'),
+ readFile(
+ join(userDataDir, 'bridge', 'extension-pairings.json'),
+ 'utf8'
+ ),
+ readFile(join(userDataDir, 'bridge', 'endpoint.json'), 'utf8'),
])
- ).resolves.toMatchObject({ status: 200 })
- await expect(
- runtime.bridgeQueryHandlers['bridge:listPaired']()
- ).resolves.toEqual([])
+ expect(durablePairingState.join('\n')).not.toContain(code)
+ connection.dispose()
- // The public bundle is not merely connectable: a real first-pair channel
- // reaches the shell receiver's validated download/submit handler.
- const extensionId = 'lggbokfckofcgjndaboioakcmincinpo'
- const handshake = await startPair({
- port: runtime.port,
- origin: `chrome-extension://${extensionId}`,
- browser: 'chromium',
- claimedExtensionId: extensionId,
- routePrefix: '/bridge',
- hostHeader: 'motrix.example',
- })
- const pending = (await runtime.bridgeQueryHandlers[
- 'bridge:listPendingPairRequests'
- ]()) as Array<{
- kind: string
- code?: string
- verifiedOrigin?: string
- originHost?: string
- claimedExtensionId?: string
- attestationClass?: string
- publicAuthority?: string
- }>
- expect(pending).toHaveLength(1)
- expect(pending[0]).toMatchObject({
- verifiedOrigin: `chrome-extension://${extensionId}`,
- originHost: extensionId,
- claimedExtensionId: extensionId,
- attestationClass: 'official',
- publicAuthority: 'motrix.example',
- })
- const code = pending[0]?.code
- if (code === undefined) throw new Error('extension pairing code missing')
- const { channel } = await runPake(handshake, code)
- const credential = await exchangeCredential(handshake, channel)
- const connection = mdxpOverChannel(handshake.wire, channel)
- await connection.sendRequest(
- 'motrix/initialize',
- initializeParams(extensionId)
- )
- await expect(
- connection.sendRequest('download/submit', {
- source: {
- pageUrl: 'https://example.com/watch',
- pageTitle: 'Remote submit',
- detectedAt: Date.now(),
- },
- selection: {
- kind: 'direct',
- primary: {
- url: 'https://cdn.example.com/video.mp4',
- headers: {},
- cookies: [],
- refererPolicy: 'strict-origin-when-cross-origin',
- },
- },
- meta: { suggestedFilename: 'video.mp4', qualityLabel: 'source' },
+ await runtime.shutdown()
+ expect(firstReceiver.stopAndDrain).toHaveBeenCalledOnce()
+ const secondReceiver = extensionReceiver()
+ runtime = await bootstrapBridgeForServer({
+ userDataDir,
+ host: '0.0.0.0',
+ port: 0,
+ motrixVersion: '2.0',
+ eventBus: { on: vi.fn(), off: vi.fn(), emit: vi.fn() },
+ readHandlerDeps: readDeps(),
+ writeHandlerDeps: writeDeps(),
+ remoteExtensionConfig,
+ createExtensionReceiver: () => secondReceiver,
})
- ).resolves.toEqual({ taskId: 'submitted' })
- expect(firstReceiver.handle).toHaveBeenCalledOnce()
- await vi.waitFor(async () =>
- expect(
- (await runtime?.bridgeQueryHandlers['bridge:listPaired']()) ?? []
- ).toHaveLength(1)
- )
- const durablePairingState = await Promise.all([
- readFile(join(userDataDir, 'bridge', 'mbp1-credentials.json'), 'utf8'),
- readFile(join(userDataDir, 'bridge', 'extension-pairings.json'), 'utf8'),
- readFile(join(userDataDir, 'bridge', 'endpoint.json'), 'utf8'),
- ])
- expect(durablePairingState.join('\n')).not.toContain(code)
- connection.dispose()
-
- await runtime.shutdown()
- expect(firstReceiver.stopAndDrain).toHaveBeenCalledOnce()
- const secondReceiver = extensionReceiver()
- runtime = await bootstrapBridgeForServer({
- userDataDir,
- host: '0.0.0.0',
- port: 0,
- motrixVersion: '2.0',
- eventBus: { on: vi.fn(), off: vi.fn(), emit: vi.fn() },
- readHandlerDeps: readDeps(),
- writeHandlerDeps: writeDeps(),
- remoteExtensionConfig,
- createExtensionReceiver: () => secondReceiver,
- })
- await expect(
- readFile(join(userDataDir, 'bridge', 'server-instance-id'), 'utf8')
- ).resolves.toBe(firstInstanceId)
+ await expect(
+ readFile(join(userDataDir, 'bridge', 'server-instance-id'), 'utf8')
+ ).resolves.toBe(firstInstanceId)
- const reconnected = await reconnect({
- port: runtime.port,
- origin: `chrome-extension://${extensionId}`,
- instanceId: firstInstanceId.trim(),
- credential,
- routePrefix: '/bridge',
- hostHeader: 'motrix.example',
- })
- const reconnectedMdxp = mdxpOverChannel(
- reconnected.wire,
- reconnected.channel
- )
- await expect(
- reconnectedMdxp.sendRequest(
- 'motrix/initialize',
- initializeParams(extensionId)
+ const reconnected = await reconnect({
+ port: runtime.port,
+ origin: `chrome-extension://${extensionId}`,
+ instanceId: firstInstanceId.trim(),
+ credential,
+ routePrefix: '/bridge',
+ hostHeader: 'motrix.example',
+ })
+ const reconnectedMdxp = mdxpOverChannel(
+ reconnected.wire,
+ reconnected.channel
)
- ).resolves.toMatchObject({ protocolVersion: '1.0' })
- reconnectedMdxp.dispose()
- })
+ await expect(
+ reconnectedMdxp.sendRequest(
+ 'motrix/initialize',
+ initializeParams(extensionId)
+ )
+ ).resolves.toMatchObject({ protocolVersion: '1.0' })
+ reconnectedMdxp.dispose()
+ }
+ )
it('quarantines a committed Extension when projection persistence fails and repairs it on restart', async () => {
const remoteExtensionConfig = parseRemoteExtensionConfig({
diff --git a/src/server/bridge/remote-extension-config.test.ts b/src/server/bridge/remote-extension-config.test.ts
index 0c95825b..6f2aa353 100644
--- a/src/server/bridge/remote-extension-config.test.ts
+++ b/src/server/bridge/remote-extension-config.test.ts
@@ -13,6 +13,15 @@ const enabledEnvironment = {
}
describe('parseRemoteExtensionConfig', () => {
+ it('enables remote pairing without a public operator URL', () => {
+ expect(
+ parseRemoteExtensionConfig({
+ MOTRIX_REMOTE_EXTENSION_ENABLED: 'true',
+ MOTRIX_REMOTE_EXTENSION_PUBLIC_URL: 'ws://192.168.1.2:16801',
+ }).status
+ ).toBe('enabled')
+ })
+
it('issues ephemeral capabilities and rejects structural copies', () => {
const parsed = parseRemoteExtensionConfig(enabledEnvironment)
@@ -68,9 +77,10 @@ describe('parseRemoteExtensionConfig', () => {
'MOTRIX_REMOTE_EXTENSION_PUBLIC_URL',
RemoteExtensionEnvironmentVariable.PublicWebSocketUrl,
],
- ['MOTRIX_PUBLIC_URL', RemoteExtensionEnvironmentVariable.PublicOperatorUrl],
] as const)('requires %s when enabled', (key, variable) => {
- const environment = { ...enabledEnvironment }
+ const environment: Partial<typeof enabledEnvironment> = {
+ ...enabledEnvironment,
+ }
delete environment[key]
expect(parseRemoteExtensionConfig(environment)).toEqual({
@@ -94,6 +104,7 @@ describe('parseRemoteExtensionConfig', () => {
publicWebSocketBaseUrl: 'wss://[2001:db8::1]/bridge',
publicWebSocketAuthority: '[2001:db8::1]',
publicWebSocketBasePath: '/bridge',
+ operatorDelivery: 'web',
publicOperatorBaseUrl: 'https://operator.example/ui',
publicOperatorAuthority: 'operator.example',
publicOperatorBasePath: '/ui',
@@ -112,6 +123,7 @@ describe('parseRemoteExtensionConfig', () => {
publicWebSocketBaseUrl: 'wss://motrix.example:9443',
publicWebSocketAuthority: 'motrix.example:9443',
publicWebSocketBasePath: '',
+ operatorDelivery: 'web',
publicOperatorBaseUrl: 'https://console.example:8443',
publicOperatorAuthority: 'console.example:8443',
publicOperatorBasePath: '',
@@ -130,6 +142,7 @@ describe('parseRemoteExtensionConfig', () => {
publicWebSocketBaseUrl: 'ws://nas.local/bridge',
publicWebSocketAuthority: 'nas.local',
publicWebSocketBasePath: '/bridge',
+ operatorDelivery: 'web',
publicOperatorBaseUrl: 'https://console.example/operator',
publicOperatorAuthority: 'console.example',
publicOperatorBasePath: '/operator',
@@ -151,6 +164,7 @@ describe('parseRemoteExtensionConfig', () => {
publicWebSocketBaseUrl: 'ws://nas.local:16801',
publicWebSocketAuthority: 'nas.local:16801',
publicWebSocketBasePath: '',
+ operatorDelivery: 'web',
publicOperatorBaseUrl: 'http://nas.local/admin',
publicOperatorAuthority: 'nas.local',
publicOperatorBasePath: '/admin',
diff --git a/src/server/bridge/remote-extension-config.ts b/src/server/bridge/remote-extension-config.ts
index 0e7e0eb6..a01ff25e 100644
--- a/src/server/bridge/remote-extension-config.ts
+++ b/src/server/bridge/remote-extension-config.ts
@@ -60,9 +60,11 @@ export interface EnabledRemoteExtensionConfig {
/** Reverse-proxy prefix, empty at the authority root. */
readonly publicWebSocketBasePath: string
/** Canonical HTTP/HTTPS operator UI base, without a trailing slash. */
- readonly publicOperatorBaseUrl: string
- readonly publicOperatorAuthority: string
- readonly publicOperatorBasePath: string
+ readonly publicOperatorBaseUrl?: string
+ readonly publicOperatorAuthority?: string
+ readonly publicOperatorBasePath?: string
+ /** Web code delivery requires an operator URL or explicit HTTP consent. */
+ readonly operatorDelivery: 'web' | 'local'
}
export type RemoteExtensionConfig =
@@ -374,14 +376,19 @@ export function parseRemoteExtensionConfig(
)
if (!webSocket.ok) return webSocket.value
- const operator = parsePublicUrl(
+ const operatorValue =
parsedEnvironment.data[
RemoteExtensionEnvironmentVariable.PublicOperatorUrl
- ],
- RemoteExtensionEnvironmentVariable.PublicOperatorUrl,
- ['http:', 'https:']
- )
- if (!operator.ok) return operator.value
+ ]
+ const operator =
+ operatorValue === undefined || operatorValue.trim() === ''
+ ? null
+ : parsePublicUrl(
+ operatorValue,
+ RemoteExtensionEnvironmentVariable.PublicOperatorUrl,
+ ['http:', 'https:']
+ )
+ if (operator !== null && !operator.ok) return operator.value
const allowInsecureOperatorHttp = parseBooleanFlag(
parsedEnvironment.data[
@@ -394,7 +401,7 @@ export function parseRemoteExtensionConfig(
return allowInsecureOperatorHttp
}
if (
- operator.value.baseUrl.startsWith('http://') &&
+ operator?.value.baseUrl.startsWith('http://') &&
!allowInsecureOperatorHttp
) {
return invalid(
@@ -409,9 +416,15 @@ export function parseRemoteExtensionConfig(
publicWebSocketBaseUrl: webSocket.value.baseUrl,
publicWebSocketAuthority: webSocket.value.authority,
publicWebSocketBasePath: webSocket.value.basePath,
- publicOperatorBaseUrl: operator.value.baseUrl,
- publicOperatorAuthority: operator.value.authority,
- publicOperatorBasePath: operator.value.basePath,
+ ...(operator === null
+ ? {}
+ : {
+ publicOperatorBaseUrl: operator.value.baseUrl,
+ publicOperatorAuthority: operator.value.authority,
+ publicOperatorBasePath: operator.value.basePath,
+ }),
+ operatorDelivery:
+ operator !== null || allowInsecureOperatorHttp ? 'web' : 'local',
})
)
} catch {
diff --git a/src/server/bridge/remote-extension-host-policy.test.ts b/src/server/bridge/remote-extension-host-policy.test.ts
index 07ad2c3a..fdef7dd4 100644
--- a/src/server/bridge/remote-extension-host-policy.test.ts
+++ b/src/server/bridge/remote-extension-host-policy.test.ts
@@ -161,6 +161,7 @@ describe('evaluateRemoteExtensionHost', () => {
publicWebSocketBaseUrl: 'wss://attacker.example/bridge',
publicWebSocketAuthority: 'motrix.example',
publicWebSocketBasePath: '/bridge',
+ operatorDelivery: 'web',
publicOperatorBaseUrl: 'https://motrix.example',
publicOperatorAuthority: 'motrix.example',
publicOperatorBasePath: '',
diff --git a/src/server/bridge/remote-extension-startup-log.ts b/src/server/bridge/remote-extension-startup-log.ts
index d32deef1..d529c388 100644
--- a/src/server/bridge/remote-extension-startup-log.ts
+++ b/src/server/bridge/remote-extension-startup-log.ts
@@ -25,7 +25,15 @@ export function logRemoteExtensionPairingReady(
}
const extensionServerAddress = config.publicWebSocketBaseUrl
- if (config.publicOperatorBaseUrl.startsWith('http://')) {
+ if (config.operatorDelivery === 'local') {
+ log.info(
+ 'Extension pairing codes are available through the local interactive command: motrix-admin extension pair. Configure an HTTPS MOTRIX_PUBLIC_URL or explicitly allow operator HTTP to display codes in the Web UI.'
+ )
+ }
+ if (
+ config.operatorDelivery === 'web' &&
+ !config.publicOperatorBaseUrl?.startsWith('https://')
+ ) {
log.warn({ operatorTransport: 'http' }, INSECURE_OPERATOR_WARNING)
}
log.info(
diff --git a/src/server/http/app.ts b/src/server/http/app.ts
index 4506b610..4351078c 100644
--- a/src/server/http/app.ts
+++ b/src/server/http/app.ts
@@ -2,6 +2,7 @@ import type { EventBus } from '@core/events/event-bus'
import type { CapabilityHost } from '@core/plugin/capabilities/interface'
import fastifyStatic from '@fastify/static'
import websocket from '@fastify/websocket'
+import { BridgeQueries } from '@shared/protocol/bridge'
import { Commands } from '@shared/protocol/commands'
import {
assertTaskInspectorActivityArguments,
@@ -29,8 +30,14 @@ import {
import { parseTaskInspectorActivitySnapshot } from '@shared/schemas/task-inspector-activity'
import { torrentRpcBodyLimitSchema } from '@shared/schemas/torrent-request-limits'
import Fastify, { type FastifyInstance, type FastifyReply } from 'fastify'
+import type { RemoteExtensionConfig } from '../bridge/remote-extension-config'
import { bindEventHeartbeat } from './event-heartbeat'
import { bindEventBroadcaster } from './events'
+import {
+ canDeliverExtensionPairingCode,
+ filterExtensionPairingSnapshot,
+ isExtensionPairingCodeEvent,
+} from './extension-pairing-delivery'
import { type OperatorAuthOptions, registerOperatorAuth } from './operator-auth'
import { ServiceUnavailableError } from './service-unavailable-error'
import {
@@ -108,6 +115,7 @@ export interface AppOptions {
*/
bridgeCommandHandlers?: Record<string, Handler>
bridgeQueryHandlers?: Record<string, Handler>
+ remoteExtensionConfig?: RemoteExtensionConfig
eventBus?: EventBus
pluginLogSource?: Pick<CapabilityHost, 'subscribeLog'>
rendererDir?: string
@@ -212,6 +220,20 @@ export async function createApp(
assertTaskInspectorActivityArguments(args)
}
const value = await handler(...(args ?? []))
+ if (
+ req.params.channel === BridgeQueries.ListPendingPairRequests &&
+ !(
+ operatorSessions?.principal(req) &&
+ canDeliverExtensionPairingCode(
+ opts.remoteExtensionConfig,
+ req,
+ operatorSessions?.principal(req)?.id.startsWith('bearer:') ===
+ true
+ )
+ )
+ ) {
+ return filterExtensionPairingSnapshot(value)
+ }
if (!usesSharedEnvelope) return value
const snapshot = parseTaskInspectorActivitySnapshot(value)
if (!snapshot) {
@@ -243,7 +265,20 @@ export async function createApp(
await app.register(websocket)
app.get('/rpc/events', { websocket: true }, (socket, request) => {
const session = operatorSessions?.bindSocket(request, socket)
- broadcaster.register(socket, session?.eligible)
+ const allowPairingCode =
+ operatorSessions?.principal(request) !== undefined &&
+ canDeliverExtensionPairingCode(
+ opts.remoteExtensionConfig,
+ request,
+ operatorSessions?.principal(request)?.id.startsWith('bearer:') ===
+ true
+ )
+ broadcaster.register(
+ socket,
+ session?.eligible,
+ (channel, args) =>
+ allowPairingCode || !isExtensionPairingCodeEvent(channel, args)
+ )
const stopHeartbeat = bindEventHeartbeat(socket)
const cleanup = () => {
stopHeartbeat()
diff --git a/src/server/http/events.ts b/src/server/http/events.ts
index 7062878d..e8edfc34 100644
--- a/src/server/http/events.ts
+++ b/src/server/http/events.ts
@@ -10,7 +10,13 @@ interface SocketLike {
}
export function bindEventBroadcaster(bus: EventBus) {
- const sockets = new Map<SocketLike, () => boolean>()
+ const sockets = new Map<
+ SocketLike,
+ {
+ eligible: () => boolean
+ accepts: (channel: string, args: unknown[]) => boolean
+ }
+ >()
subscribeForwardableEvents(bus, (channel, args) => {
broadcast(channel, args)
@@ -19,11 +25,12 @@ export function bindEventBroadcaster(bus: EventBus) {
function broadcast(channel: string, args: unknown[]): void {
if (sockets.size === 0) return
const frame = JSON.stringify({ channel, args })
- for (const [s, eligible] of sockets) {
+ for (const [s, { eligible, accepts }] of sockets) {
if (!eligible()) {
sockets.delete(s)
continue
}
+ if (!accepts(channel, args)) continue
const failed = (error: unknown) => {
if (!sockets.delete(s)) return
log.warn({ err: error }, 'event delivery failed; closing socket')
@@ -41,8 +48,11 @@ export function bindEventBroadcaster(bus: EventBus) {
return {
broadcast,
- register: (s: SocketLike, eligible: () => boolean = () => true) =>
- sockets.set(s, eligible),
+ register: (
+ s: SocketLike,
+ eligible: () => boolean = () => true,
+ accepts: (channel: string, args: unknown[]) => boolean = () => true
+ ) => sockets.set(s, { eligible, accepts }),
unregister: (s: SocketLike) => sockets.delete(s),
count: () => sockets.size,
}
diff --git a/src/server/http/extension-pairing-delivery.test.ts b/src/server/http/extension-pairing-delivery.test.ts
new file mode 100644
index 00000000..2ab63477
--- /dev/null
+++ b/src/server/http/extension-pairing-delivery.test.ts
@@ -0,0 +1,196 @@
+import { EventBus } from '@core/events/event-bus'
+import { BridgeEvents, BridgeQueries } from '@shared/protocol/bridge'
+import { Events } from '@shared/protocol/events'
+import type { FastifyRequest } from 'fastify'
+import { describe, expect, it } from 'vitest'
+import WebSocket from 'ws'
+import { parseRemoteExtensionConfig } from '../bridge/remote-extension-config'
+import { createApp } from './app'
+import { canDeliverExtensionPairingCode } from './extension-pairing-delivery'
+
+const config = parseRemoteExtensionConfig({
+ MOTRIX_REMOTE_EXTENSION_ENABLED: 'true',
+ MOTRIX_REMOTE_EXTENSION_PUBLIC_URL: 'ws://192.168.1.2:16801',
+})
+const request = (
+ headers = ['Host', '127.0.0.1:8080'],
+ remoteAddress = '127.0.0.1',
+ localPort: number | undefined = 8080
+) =>
+ ({
+ raw: { rawHeaders: headers, socket: { remoteAddress, localPort } },
+ }) as FastifyRequest
+
+describe('Extension pairing code delivery', () => {
+ it('admits only an authenticated direct loopback operator in local mode', () => {
+ expect(canDeliverExtensionPairingCode(config, request(), true)).toBe(true)
+ expect(canDeliverExtensionPairingCode(config, request(), false)).toBe(false)
+ expect(
+ canDeliverExtensionPairingCode(
+ config,
+ request(['Host', '[::1]:8080'], '::1'),
+ true
+ )
+ ).toBe(true)
+ expect(
+ canDeliverExtensionPairingCode(
+ config,
+ request(undefined, '::ffff:127.0.0.1'),
+ true
+ )
+ ).toBe(true)
+ })
+ it.each([
+ ['Origin', ''],
+ ['Origin', 'http://127.0.0.1:8080'],
+ ['Forwarded', ''],
+ ['X-Forwarded-For', '127.0.0.1'],
+ ['X-Forwarded-Host', ''],
+ ['X-Forwarded-Proto', 'https'],
+ ])('rejects the local exception when %s is present', (name, value) => {
+ expect(
+ canDeliverExtensionPairingCode(
+ config,
+ request(['Host', '127.0.0.1:8080', name, value]),
+ true
+ )
+ ).toBe(false)
+ })
+ it.each(
+ [
+ [],
+ ['Host', 'localhost:8081'],
+ ['Host', 'evil.example:8080'],
+ ['Host', '127.0.0.1:8080', 'host', '127.0.0.1:8080'],
+ ['Host', '127.0.0.1:8080 '],
+ ['Host', '127.0.0.1'],
+ ].map((headers) => ({ headers }))
+ )('rejects missing, duplicate or mismatched Host $headers', ({ headers }) => {
+ expect(canDeliverExtensionPairingCode(config, request(headers), true)).toBe(
+ false
+ )
+ })
+ it('ignores forwarded locality and requires a parser-issued enabled config', () => {
+ expect(
+ canDeliverExtensionPairingCode(
+ config,
+ request(undefined, '192.168.1.3'),
+ true
+ )
+ ).toBe(false)
+ expect(canDeliverExtensionPairingCode(undefined, request(), true)).toBe(
+ false
+ )
+ expect(canDeliverExtensionPairingCode({ ...config }, request(), true)).toBe(
+ false
+ )
+ expect(
+ canDeliverExtensionPairingCode(
+ parseRemoteExtensionConfig({}),
+ request(),
+ true
+ )
+ ).toBe(false)
+ })
+ it.each([
+ { MOTRIX_PUBLIC_URL: 'https://operator.example' },
+ { MOTRIX_ALLOW_INSECURE_OPERATOR_HTTP: 'true' },
+ {
+ MOTRIX_PUBLIC_URL: 'http://nas.local:8080',
+ MOTRIX_ALLOW_INSECURE_OPERATOR_HTTP: 'true',
+ },
+ ])('preserves explicit Web delivery for %j', (env) => {
+ const web = parseRemoteExtensionConfig({
+ MOTRIX_REMOTE_EXTENSION_ENABLED: 'true',
+ MOTRIX_REMOTE_EXTENSION_PUBLIC_URL: 'wss://bridge.example',
+ ...env,
+ })
+ expect(
+ canDeliverExtensionPairingCode(
+ web,
+ request(undefined, '192.168.1.3'),
+ false
+ )
+ ).toBe(true)
+ })
+
+ it('filters both authenticated Web snapshots and events while local Bearer can read', async () => {
+ const token = 'owner-token'
+ const extension = {
+ kind: 'extension',
+ pairingNonce: 'n'.repeat(43),
+ extensionId: 'a'.repeat(32),
+ browser: 'chromium',
+ identity: 'unverified',
+ code: '0123-4567',
+ createdAt: 1,
+ expiresAt: Date.now() + 120_000,
+ }
+ const cli = { kind: 'cli', requestId: 'cli-request', userCode: 'ABCD-EFGH' }
+ const bus = new EventBus()
+ const app = await createApp({
+ eventBus: bus,
+ remoteExtensionConfig: config,
+ operatorAuth: { operatorToken: token },
+ bridgeQueryHandlers: {
+ [BridgeQueries.ListPendingPairRequests]: async () => [extension, cli],
+ },
+ })
+ let ws: WebSocket | undefined
+ try {
+ const base = await app.listen({ host: '127.0.0.1', port: 0 })
+ const login = await fetch(`${base}/rpc/auth/login`, {
+ method: 'POST',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({ token }),
+ })
+ const cookie = login.headers.get('set-cookie')!.split(';')[0]
+ const url = `${base}/rpc/query/${encodeURIComponent(BridgeQueries.ListPendingPairRequests)}`
+ const read = (headers: Record<string, string>) =>
+ fetch(url, {
+ method: 'POST',
+ headers: { 'content-type': 'application/json', ...headers },
+ body: JSON.stringify({ args: [] }),
+ })
+ expect(
+ await (await read({ authorization: `Bearer ${token}` })).json()
+ ).toEqual([extension, cli])
+ expect(await (await read({ cookie, origin: base })).json()).toEqual([cli])
+ expect(
+ await (
+ await read({
+ authorization: `Bearer ${token}`,
+ 'x-forwarded-proto': 'https',
+ })
+ ).json()
+ ).toEqual([cli])
+ const unauthorized = await read({ authorization: 'Bearer agent-token' })
+ expect(unauthorized.status).toBe(401)
+ expect(await unauthorized.text()).not.toContain(extension.code)
+ ws = new WebSocket(`${base.replace('http:', 'ws:')}/rpc/events`, {
+ headers: { cookie, origin: base },
+ })
+ await new Promise<void>((resolve, reject) => {
+ ws!.once('open', resolve)
+ ws!.once('error', reject)
+ })
+ const messages: string[] = []
+ ws.on('message', (data) => messages.push(String(data)))
+ const end = new Promise<void>((resolve) => {
+ ws!.on('message', (data) => {
+ if (String(data).includes(Events.TaskUpdated)) resolve()
+ })
+ })
+ bus.emit(BridgeEvents.PairRequested as never, extension)
+ bus.emit(BridgeEvents.PairRequested as never, cli)
+ bus.emit(Events.TaskUpdated, { id: 'still-connected' })
+ await end
+ expect(messages).toHaveLength(2)
+ expect(messages.join('')).not.toContain(extension.code)
+ expect(messages.join('')).toContain(cli.userCode)
+ } finally {
+ ws?.terminate()
+ await app.close()
+ }
+ })
+})
diff --git a/src/server/http/extension-pairing-delivery.ts b/src/server/http/extension-pairing-delivery.ts
new file mode 100644
index 00000000..a329fb2d
--- /dev/null
+++ b/src/server/http/extension-pairing-delivery.ts
@@ -0,0 +1,76 @@
+import { BridgeEvents } from '@shared/protocol/bridge'
+import type { FastifyRequest } from 'fastify'
+import {
+ isIssuedRemoteExtensionConfig,
+ type RemoteExtensionConfig,
+} from '../bridge/remote-extension-config'
+
+/**
+ * Operator authentication is required separately. The local exception describes
+ * the observed HTTP connection, not proof that no privileged local proxy exists.
+ * The operator bearer already grants machine-owner authority.
+ */
+export function canDeliverExtensionPairingCode(
+ config: RemoteExtensionConfig | undefined,
+ request: FastifyRequest,
+ bearerAuthenticated: boolean
+): boolean {
+ if (!isIssuedRemoteExtensionConfig(config) || config.status !== 'enabled') {
+ return false
+ }
+ if (config.operatorDelivery === 'web') return true
+ if (!bearerAuthenticated) return false
+
+ const { remoteAddress, localPort } = request.raw.socket
+ if (
+ !['127.0.0.1', '::1', '::ffff:127.0.0.1'].includes(remoteAddress ?? '') ||
+ localPort === undefined
+ ) {
+ return false
+ }
+
+ const hosts: string[] = []
+ const headers = request.raw.rawHeaders
+ for (let index = 0; index < headers.length; index += 2) {
+ const name = headers[index]?.toLowerCase()
+ const value = headers[index + 1]
+ if (
+ name === 'origin' ||
+ name === 'forwarded' ||
+ name?.startsWith('x-forwarded-')
+ ) {
+ return false
+ }
+ if (name === 'host' && value !== undefined) hosts.push(value.toLowerCase())
+ }
+ return (
+ hosts.length === 1 &&
+ [
+ `127.0.0.1:${localPort}`,
+ `localhost:${localPort}`,
+ `[::1]:${localPort}`,
+ ].includes(hosts[0])
+ )
+}
+
+function isExtensionRequest(value: unknown): boolean {
+ return (
+ typeof value === 'object' &&
+ value !== null &&
+ 'kind' in value &&
+ value.kind === 'extension'
+ )
+}
+
+export function filterExtensionPairingSnapshot(value: unknown): unknown {
+ return Array.isArray(value)
+ ? value.filter((request) => !isExtensionRequest(request))
+ : value
+}
+
+export function isExtensionPairingCodeEvent(
+ channel: string,
+ args: unknown[]
+): boolean {
+ return channel === BridgeEvents.PairRequested && isExtensionRequest(args[0])
+}
diff --git a/src/server/http/operator-auth.test.ts b/src/server/http/operator-auth.test.ts
index 1a851e4a..161e81af 100644
--- a/src/server/http/operator-auth.test.ts
+++ b/src/server/http/operator-auth.test.ts
@@ -4,6 +4,7 @@ import { BridgeCommands, BridgeQueries } from '@shared/protocol/bridge'
import { Commands } from '@shared/protocol/commands'
import type { FastifyInstance } from 'fastify'
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
+import { parseRemoteExtensionConfig } from '../bridge/remote-extension-config'
import { createApp } from './app'
const TOKEN = 'machine-owner-token-xyz'
@@ -247,6 +248,11 @@ describe('device-code approval is gated by the operator (the Codex bypass)', ()
expiresAt: 2,
}
const app = await createApp({
+ remoteExtensionConfig: parseRemoteExtensionConfig({
+ MOTRIX_REMOTE_EXTENSION_ENABLED: 'true',
+ MOTRIX_REMOTE_EXTENSION_PUBLIC_URL: 'wss://motrix.example',
+ MOTRIX_PUBLIC_URL: 'https://motrix.example',
+ }),
commandHandlers: {},
queryHandlers: {},
bridgeQueryHandlers: {
diff --git a/src/server/index.ts b/src/server/index.ts
index 93ad9822..719bc04e 100644
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@ -1304,7 +1304,9 @@ async function main() {
'operator token provisioned'
)
+ const remoteExtensionConfig = parseRemoteExtensionConfig(process.env)
const app = await createApp({
+ remoteExtensionConfig,
torrentBodyLimitBytes,
commandHandlers,
queryHandlers,
@@ -1952,7 +1954,6 @@ async function main() {
? 16801
: fixedPort
const mdxpHost = process.env.MOTRIX_MDXP_HOST ?? '127.0.0.1'
- const remoteExtensionConfig = parseRemoteExtensionConfig(process.env)
if (remoteExtensionConfig.status === 'invalid') {
log.warn(
{
diff --git a/src/server/operator-admin-http.test.ts b/src/server/operator-admin-http.test.ts
new file mode 100644
index 00000000..c779e45e
--- /dev/null
+++ b/src/server/operator-admin-http.test.ts
@@ -0,0 +1,104 @@
+// @vitest-environment node
+import { createServer, type ServerResponse } from 'node:http'
+import type { AddressInfo } from 'node:net'
+import { getGlobalDispatcher, MockAgent, setGlobalDispatcher } from 'undici'
+import { afterEach, describe, expect, it, vi } from 'vitest'
+import { OperatorAdminExitCode, runOperatorAdmin } from './operator-admin'
+import type { PairingTerminal } from './operator-extension-pairing'
+
+const token = 't'.repeat(43)
+const cleanup: (() => Promise<void>)[] = []
+afterEach(async () => {
+ for (const close of cleanup.splice(0).reverse()) await close()
+})
+
+async function serve(reply: (response: ServerResponse) => void) {
+ const server = createServer((request, response) => {
+ expect(request.headers.authorization).toBe(`Bearer ${token}`)
+ reply(response)
+ })
+ await new Promise<void>((resolve) => server.listen(0, '127.0.0.1', resolve))
+ cleanup.push(async () => {
+ server.closeAllConnections()
+ await new Promise<void>((resolve, reject) =>
+ server.close((error) => (error ? reject(error) : resolve()))
+ )
+ })
+ return {
+ MOTRIX_OPERATOR_TOKEN: token,
+ PORT: String((server.address() as AddressInfo).port),
+ }
+}
+
+describe('operator CLI direct HTTP transport', () => {
+ it('uses a compatible direct fetch/Agent without the global dispatcher', async () => {
+ const env = await serve((response) => response.end('[]'))
+ const original = getGlobalDispatcher()
+ const blocked = new MockAgent()
+ blocked.disableNetConnect()
+ setGlobalDispatcher(blocked)
+ cleanup.push(async () => {
+ setGlobalDispatcher(original)
+ await blocked.close()
+ })
+ const stdout: string[] = []
+ const stderr: string[] = []
+ expect(
+ await runOperatorAdmin(['pairing', 'pending'], {
+ env,
+ writeStdout: (value) => stdout.push(value),
+ writeStderr: (value) => stderr.push(value),
+ })
+ ).toBe(OperatorAdminExitCode.Success)
+ expect(stdout).toEqual(['No pending pairing requests.'])
+ expect(stderr).toEqual([])
+ })
+
+ it('bounds response-body reading after successful headers', async () => {
+ const env = await serve((response) => {
+ response.writeHead(200, { 'content-type': 'application/json' })
+ response.write('[')
+ })
+ const stderr: string[] = []
+ const start = Date.now()
+ const result = await runOperatorAdmin(['pairing', 'pending'], {
+ env,
+ pendingRetryWindowMs: 80,
+ writeStdout: vi.fn(),
+ writeStderr: (message) => stderr.push(message),
+ })
+ expect(result).toBe(OperatorAdminExitCode.Server)
+ expect(Date.now() - start).toBeLessThan(2_000)
+ expect(stderr.join('')).not.toContain(token)
+ })
+
+ it('cancels an incomplete body and closes the interactive view', async () => {
+ const controller = new AbortController()
+ const env = await serve((response) => {
+ response.writeHead(200, { 'content-type': 'application/json' })
+ response.write('[')
+ setTimeout(() => controller.abort(), 30)
+ })
+ const terminal: PairingTerminal = {
+ interactive: true,
+ signal: controller.signal,
+ begin: vi.fn(),
+ show: vi.fn(),
+ clear: vi.fn(),
+ close: vi.fn(),
+ select: vi.fn(),
+ }
+ const stderr: string[] = []
+ expect(
+ await runOperatorAdmin(['extension', 'pair'], {
+ env,
+ terminal,
+ writeStdout: vi.fn(),
+ writeStderr: (message) => stderr.push(message),
+ })
+ ).toBe(OperatorAdminExitCode.Unavailable)
+ expect(terminal.close).toHaveBeenCalledOnce()
+ expect(terminal.show).not.toHaveBeenCalled()
+ expect(stderr.join('')).not.toContain(token)
+ })
+})
diff --git a/src/server/operator-admin-locales.ts b/src/server/operator-admin-locales.ts
new file mode 100644
index 00000000..e579cd22
--- /dev/null
+++ b/src/server/operator-admin-locales.ts
@@ -0,0 +1,117 @@
+import type { SupportedLocale } from '@shared/constants/locales'
+import { operatorAdmin as enUS } from '@shared/locales/en-US.json'
+import { operatorAdmin as zhCN } from '@shared/locales/zh-CN.json'
+
+// Keep the CLI namespace small while preserving the application contract:
+// English/Chinese are eager; every other bundled locale loads on demand.
+export const OPERATOR_ADMIN_RESOURCES = {
+ 'en-US': { translation: { operatorAdmin: enUS } },
+ 'zh-CN': { translation: { operatorAdmin: zhCN } },
+}
+
+const loaders = {
+ ar: () =>
+ import('@shared/locales/ar.json').then(
+ ({ operatorAdmin }) => operatorAdmin
+ ),
+ bg: () =>
+ import('@shared/locales/bg.json').then(
+ ({ operatorAdmin }) => operatorAdmin
+ ),
+ ca: () =>
+ import('@shared/locales/ca.json').then(
+ ({ operatorAdmin }) => operatorAdmin
+ ),
+ de: () =>
+ import('@shared/locales/de.json').then(
+ ({ operatorAdmin }) => operatorAdmin
+ ),
+ el: () =>
+ import('@shared/locales/el.json').then(
+ ({ operatorAdmin }) => operatorAdmin
+ ),
+ 'en-US': async () => enUS,
+ es: () =>
+ import('@shared/locales/es.json').then(
+ ({ operatorAdmin }) => operatorAdmin
+ ),
+ fa: () =>
+ import('@shared/locales/fa.json').then(
+ ({ operatorAdmin }) => operatorAdmin
+ ),
+ fr: () =>
+ import('@shared/locales/fr.json').then(
+ ({ operatorAdmin }) => operatorAdmin
+ ),
+ hu: () =>
+ import('@shared/locales/hu.json').then(
+ ({ operatorAdmin }) => operatorAdmin
+ ),
+ id: () =>
+ import('@shared/locales/id.json').then(
+ ({ operatorAdmin }) => operatorAdmin
+ ),
+ it: () =>
+ import('@shared/locales/it.json').then(
+ ({ operatorAdmin }) => operatorAdmin
+ ),
+ ja: () =>
+ import('@shared/locales/ja.json').then(
+ ({ operatorAdmin }) => operatorAdmin
+ ),
+ ko: () =>
+ import('@shared/locales/ko.json').then(
+ ({ operatorAdmin }) => operatorAdmin
+ ),
+ nb: () =>
+ import('@shared/locales/nb.json').then(
+ ({ operatorAdmin }) => operatorAdmin
+ ),
+ nl: () =>
+ import('@shared/locales/nl.json').then(
+ ({ operatorAdmin }) => operatorAdmin
+ ),
+ pl: () =>
+ import('@shared/locales/pl.json').then(
+ ({ operatorAdmin }) => operatorAdmin
+ ),
+ 'pt-BR': () =>
+ import('@shared/locales/pt-BR.json').then(
+ ({ operatorAdmin }) => operatorAdmin
+ ),
+ ro: () =>
+ import('@shared/locales/ro.json').then(
+ ({ operatorAdmin }) => operatorAdmin
+ ),
+ ru: () =>
+ import('@shared/locales/ru.json').then(
+ ({ operatorAdmin }) => operatorAdmin
+ ),
+ th: () =>
+ import('@shared/locales/th.json').then(
+ ({ operatorAdmin }) => operatorAdmin
+ ),
+ tr: () =>
+ import('@shared/locales/tr.json').then(
+ ({ operatorAdmin }) => operatorAdmin
+ ),
+ uk: () =>
+ import('@shared/locales/uk.json').then(
+ ({ operatorAdmin }) => operatorAdmin
+ ),
+ vi: () =>
+ import('@shared/locales/vi.json').then(
+ ({ operatorAdmin }) => operatorAdmin
+ ),
+ 'zh-CN': async () => zhCN,
+ 'zh-TW': () =>
+ import('@shared/locales/zh-TW.json').then(
+ ({ operatorAdmin }) => operatorAdmin
+ ),
+} satisfies Record<SupportedLocale, () => Promise<typeof enUS>>
+
+export function loadOperatorAdminLocale(
+ locale: SupportedLocale
+): Promise<typeof enUS> {
+ return loaders[locale]()
+}
diff --git a/src/server/operator-admin.test.ts b/src/server/operator-admin.test.ts
index ee06ea1e..3d06a745 100644
--- a/src/server/operator-admin.test.ts
+++ b/src/server/operator-admin.test.ts
@@ -60,7 +60,7 @@ function extensionRequest(
extensionId: 'a'.repeat(32),
browser: 'chromium' as const,
identity: 'official' as const,
- code: 'JKLM-NPQR',
+ code: 'JKMN-PQRS',
createdAt: NOW - 500,
expiresAt: NOW + 59_500,
...overrides,
@@ -111,6 +111,57 @@ function rpcCall(fetchMock: ReturnType<typeof vi.fn>, index: number) {
}
describe('runOperatorAdmin', () => {
+ it.each([
+ ['extension', 'pair', '--json'],
+ ['extension', 'pair', '--all'],
+ ])(
+ 'rejects noninteractive Extension options before any RPC: %j',
+ async (...argv) => {
+ const fetchMock = vi.fn()
+ const h = harness(fetchMock)
+ expect(await runOperatorAdmin(argv, h.options)).toBe(
+ OperatorAdminExitCode.Usage
+ )
+ expect(fetchMock).not.toHaveBeenCalled()
+ expect(h.stdout.join('')).not.toContain('0123-4567')
+ }
+ )
+ it('rejects redirected Extension pairing before loading credentials', async () => {
+ const fetchMock = vi.fn()
+ const lstatMock = vi.fn()
+ const h = harness(fetchMock, {
+ env: {},
+ lstat: lstatMock as unknown as AdminOptions['lstat'],
+ terminal: {
+ interactive: false,
+ signal: new AbortController().signal,
+ begin() {},
+ show() {},
+ clear() {},
+ close() {},
+ select: async () => '1',
+ },
+ })
+ expect(await runOperatorAdmin(['extension', 'pair'], h.options)).toBe(
+ OperatorAdminExitCode.Usage
+ )
+ expect(lstatMock).not.toHaveBeenCalled()
+ expect(fetchMock).not.toHaveBeenCalled()
+ })
+ it('accepts MBP1 Crockford codes containing zero and one without printing them', async () => {
+ const h = harness(
+ vi
+ .fn()
+ .mockResolvedValue(
+ jsonResponse([extensionRequest({ code: '0123-4567' }), request()])
+ )
+ )
+ expect(await runOperatorAdmin(['pairing', 'pending'], h.options)).toBe(
+ OperatorAdminExitCode.Success
+ )
+ expect(h.stdout.join('')).not.toContain('0123-4567')
+ })
+
it('shows help without reading credentials or contacting the server', async () => {
const fetchMock = vi.fn()
const lstatMock = vi.fn()
@@ -293,7 +344,7 @@ describe('runOperatorAdmin', () => {
const output = h.stdout.join('')
expect(JSON.parse(output).requests).toHaveLength(1)
expect(output).toContain('ABCD-EFGH')
- expect(output).not.toContain('JKLM-NPQR')
+ expect(output).not.toContain('JKMN-PQRS')
expect(output).not.toContain('extension')
})
@@ -307,7 +358,7 @@ describe('runOperatorAdmin', () => {
runOperatorAdmin(['pairing', 'pending'], h.options)
).resolves.toBe(OperatorAdminExitCode.Success)
expect(h.stdout).toEqual(['No pending pairing requests.'])
- expect(h.stdout.join('')).not.toContain('JKLM-NPQR')
+ expect(h.stdout.join('')).not.toContain('JKMN-PQRS')
})
it('fails closed on a malformed Extension row instead of silently dropping it', async () => {
@@ -324,7 +375,7 @@ describe('runOperatorAdmin', () => {
runOperatorAdmin(['pairing', 'pending'], h.options)
).resolves.toBe(OperatorAdminExitCode.Server)
expect(h.stdout).toEqual([])
- expect(h.stderr.join('')).not.toContain('JKLM-NPQR')
+ expect(h.stderr.join('')).not.toContain('JKMN-PQRS')
})
it('sanitizes and bounds untrusted client metadata in JSON output', async () => {
@@ -445,7 +496,7 @@ describe('runOperatorAdmin', () => {
const h = harness(fetchMock)
await expect(
- runOperatorAdmin(['pairing', 'approve', 'JKLM-NPQR'], h.options)
+ runOperatorAdmin(['pairing', 'approve', 'JKMN-PQRS'], h.options)
).resolves.toBe(OperatorAdminExitCode.Server)
expect(fetchMock).toHaveBeenCalledTimes(1)
})
diff --git a/src/server/operator-admin.ts b/src/server/operator-admin.ts
index 9cceec2d..670436aa 100644
--- a/src/server/operator-admin.ts
+++ b/src/server/operator-admin.ts
@@ -1,11 +1,11 @@
import { lstat, readFile } from 'node:fs/promises'
import { isAbsolute, join } from 'node:path'
+import { CROCKFORD_ALPHABET } from '@core/bridge/mbp1/pairing-code'
import {
FALLBACK_LOCALE,
resolveSupportedLocale,
SUPPORTED_LOCALE_CODES,
} from '@shared/constants/locales'
-import { I18N_RESOURCES, loadI18nLocale } from '@shared/i18n-resources'
import {
BridgeCommands,
BridgeQueries,
@@ -15,8 +15,23 @@ import {
type ResolvePairResult,
} from '@shared/protocol/bridge'
import { createInstance } from 'i18next'
+import {
+ Agent,
+ type RequestInit as DirectRequestInit,
+ fetch as directFetch,
+} from 'undici'
import { z } from 'zod'
import { parseServerPort } from './environment'
+import {
+ loadOperatorAdminLocale,
+ OPERATOR_ADMIN_RESOURCES,
+} from './operator-admin-locales'
+import {
+ createPairingTerminal,
+ ExtensionPairingTerminalError,
+ type PairingTerminal,
+ runExtensionPairingTerminal,
+} from './operator-extension-pairing'
const OPERATOR_TOKEN_PATTERN = /^[A-Za-z0-9_-]{43,128}$/
const USER_CODE_PATTERN = /^[A-HJ-NP-Z2-9]{8}$/
@@ -60,7 +75,11 @@ const pendingExtensionRequestSchema: z.ZodType<PendingExtensionRequest> = z
extensionId: z.string().min(1).max(256),
browser: BrowserSchema,
identity: z.enum(['official', 'attested-non-official', 'unverified']),
- code: z.string().regex(WIRE_USER_CODE_PATTERN),
+ code: z
+ .string()
+ .regex(
+ new RegExp(`^[${CROCKFORD_ALPHABET}]{4}-[${CROCKFORD_ALPHABET}]{4}$`)
+ ),
verifiedOrigin: z.string().min(1).max(512).optional(),
originHost: z.string().min(1).max(256).optional(),
claimedExtensionId: z.string().min(1).max(256).optional(),
@@ -165,6 +184,7 @@ interface OperatorAdminDependencies {
writeStderr: (message: string) => void
pendingRetryWindowMs: number
mutationTimeoutMs: number
+ terminal?: PairingTerminal
}
export interface OperatorAdminOptions
@@ -172,7 +192,7 @@ export interface OperatorAdminOptions
interface ParsedCommand {
json: boolean
- operation: 'pending' | 'approve' | 'deny'
+ operation: 'pending' | 'approve' | 'deny' | 'extension-pair'
userCode?: string
}
@@ -207,6 +227,7 @@ function defaultDependencies(
((message) => {
process.stderr.write(`${message}\n`)
}),
+ terminal: options.terminal,
pendingRetryWindowMs:
options.pendingRetryWindowMs ?? PENDING_RETRY_WINDOW_MS,
mutationTimeoutMs: options.mutationTimeoutMs ?? MUTATION_TIMEOUT_MS,
@@ -218,8 +239,10 @@ async function createTranslator(env: NodeJS.ProcessEnv): Promise<Translate> {
const instance = createInstance()
await instance.init({
resources: {
- ...I18N_RESOURCES,
- [locale]: { translation: await loadI18nLocale(locale) },
+ ...OPERATOR_ADMIN_RESOURCES,
+ [locale]: {
+ translation: { operatorAdmin: await loadOperatorAdminLocale(locale) },
+ },
},
supportedLngs: SUPPORTED_LOCALE_CODES,
lng: locale,
@@ -264,6 +287,9 @@ function parseCommand(argv: readonly string[]): ParsedCommand | 'help' {
return 'help'
}
+ if (argv.length === 2 && argv[0] === 'extension' && argv[1] === 'pair') {
+ return { json: false, operation: 'extension-pair' }
+ }
const args = argv.filter((arg) => arg !== '--json')
if (args.some((arg) => arg.startsWith('--'))) {
throw new OperatorAdminError(
@@ -496,8 +522,9 @@ async function waitBeforePendingRetry(
async function listPendingRequests(
deps: OperatorAdminDependencies,
baseUrl: string,
- token: string
-): Promise<PendingCliRequest[]> {
+ token: string,
+ signal?: AbortSignal
+): Promise<PendingPairRequestInfo[]> {
const startedAt = deps.now()
let attempts = 0
while (attempts < MAX_PENDING_ATTEMPTS) {
@@ -514,10 +541,14 @@ async function listPendingRequests(
)}`,
{
...requestInit(token, []),
- signal: controller.signal,
+ signal: signal
+ ? AbortSignal.any([signal, controller.signal])
+ : controller.signal,
}
)
} catch {
+ clearTimeout(timeout)
+ if (signal?.aborted) throw new ExtensionPairingTerminalError('cancelled')
if (retryWindowExpired(deps, startedAt, attempts)) {
throw new OperatorAdminError(
OperatorAdminErrorKind.Unavailable,
@@ -526,44 +557,39 @@ async function listPendingRequests(
}
await waitBeforePendingRetry(deps, startedAt)
continue
- } finally {
- clearTimeout(timeout)
}
- if (response.status === 404) {
- const isStartupResponse = await isUnknownChannelResponse(response)
- if (!isStartupResponse) classifyHttpStatus(response.status, false)
- if (retryWindowExpired(deps, startedAt, attempts)) {
- throw new OperatorAdminError(
- OperatorAdminErrorKind.Unavailable,
- OperatorAdminErrorCode.ApprovalNotReady
- )
+ try {
+ if (response.status === 404) {
+ const isStartupResponse = await isUnknownChannelResponse(response)
+ if (!isStartupResponse) classifyHttpStatus(response.status, false)
+ if (retryWindowExpired(deps, startedAt, attempts)) {
+ throw new OperatorAdminError(
+ OperatorAdminErrorKind.Unavailable,
+ OperatorAdminErrorCode.ApprovalNotReady
+ )
+ }
+ await waitBeforePendingRetry(deps, startedAt)
+ continue
+ }
+ if (!response.ok) {
+ await discardResponse(response)
+ classifyHttpStatus(response.status, false)
}
- await waitBeforePendingRetry(deps, startedAt)
- continue
- }
- if (!response.ok) {
- await discardResponse(response)
- classifyHttpStatus(response.status, false)
- }
- const parsed = pendingResponseSchema.safeParse(
- await parseJsonResponse(response)
- )
- if (!parsed.success) {
- throw new OperatorAdminError(
- OperatorAdminErrorKind.Server,
- OperatorAdminErrorCode.PendingResponseInvalid
+ const parsed = pendingResponseSchema.safeParse(
+ await parseJsonResponse(response)
)
+ if (!parsed.success) {
+ throw new OperatorAdminError(
+ OperatorAdminErrorKind.Server,
+ OperatorAdminErrorCode.PendingResponseInvalid
+ )
+ }
+ return parsed.data
+ } finally {
+ clearTimeout(timeout)
}
- // `motrix-admin` is intentionally CLI-only: Extension pairing approval is
- // code-entry in the browser, not an operator allow/deny action. Validate
- // the complete renderer-safe union first so a malformed Server response
- // still fails closed, then project only CLI rows. In particular, never
- // print or match an Extension's PAKE code.
- return parsed.data.filter(
- (request): request is PendingCliRequest => request.kind === 'cli'
- )
}
throw new OperatorAdminError(
@@ -758,7 +784,19 @@ export async function runOperatorAdmin(
argv: readonly string[],
options: OperatorAdminOptions = {}
): Promise<OperatorAdminExitCode> {
- const deps = defaultDependencies(options)
+ // An explicit direct dispatcher prevents NODE_USE_ENV_PROXY/global proxy
+ // settings from forwarding the machine-owner credential outside loopback.
+ const dispatcher = options.fetch === undefined ? new Agent() : undefined
+ const deps = defaultDependencies({
+ ...options,
+ fetch:
+ options.fetch ??
+ ((input, init) =>
+ directFetch(String(input), {
+ ...init,
+ dispatcher,
+ } as DirectRequestInit) as unknown as Promise<Response>),
+ })
const t = await createTranslator(deps.env)
let json = argv.includes('--json')
try {
@@ -769,14 +807,35 @@ export async function runOperatorAdmin(
}
json = command.json
+ const terminal =
+ command.operation === 'extension-pair'
+ ? (deps.terminal ?? createPairingTerminal())
+ : undefined
+ if (terminal && !terminal.interactive)
+ throw new ExtensionPairingTerminalError('ttyRequired')
const token = await readOperatorToken(deps)
const baseUrl = serverBaseUrl(deps.env)
- const pending = await listPendingRequests(deps, baseUrl, token)
+ if (terminal) {
+ const outcome = await runExtensionPairingTerminal({
+ terminal,
+ listPending: (signal) =>
+ listPendingRequests(deps, baseUrl, token, signal),
+ now: deps.now,
+ t,
+ })
+ deps.writeStdout(t(`operatorAdmin.extension.${outcome}`))
+ return OperatorAdminExitCode.Success
+ }
+ const pending = (await listPendingRequests(deps, baseUrl, token)).filter(
+ (request): request is PendingCliRequest => request.kind === 'cli'
+ )
if (command.operation === 'pending') {
printPending(deps, t, pending, command.json)
return OperatorAdminExitCode.Success
}
+ if (command.operation === 'extension-pair')
+ throw new ExtensionPairingTerminalError('unavailable')
const request = findUniqueRequest(pending, command.userCode as string)
const params: ResolvePairParams = {
kind: 'cli',
@@ -787,6 +846,13 @@ export async function runOperatorAdmin(
printDecision(deps, t, request, command.operation, command.json)
return OperatorAdminExitCode.Success
} catch (error) {
+ if (error instanceof ExtensionPairingTerminalError) {
+ deps.writeStderr(t(`operatorAdmin.extension.${error.reason}`))
+ return error.reason === 'ttyRequired' ||
+ error.reason === 'invalidSelection'
+ ? OperatorAdminExitCode.Usage
+ : OperatorAdminExitCode.Unavailable
+ }
const normalized =
error instanceof OperatorAdminError
? error
@@ -796,5 +862,7 @@ export async function runOperatorAdmin(
)
printError(deps, t, normalized, json)
return exitCodeFor(normalized)
+ } finally {
+ await dispatcher?.destroy().catch(() => {})
}
}
diff --git a/src/server/operator-extension-pairing.test.ts b/src/server/operator-extension-pairing.test.ts
new file mode 100644
index 00000000..23faf5e4
--- /dev/null
+++ b/src/server/operator-extension-pairing.test.ts
@@ -0,0 +1,152 @@
+import type { PendingPairRequestInfo } from '@shared/protocol/bridge'
+import { describe, expect, it, vi } from 'vitest'
+import {
+ type PairingTerminal,
+ runExtensionPairingTerminal,
+ terminalPairingText,
+} from './operator-extension-pairing'
+
+const code = '0123-4567'
+const entry = {
+ kind: 'extension' as const,
+ pairingNonce: 'n'.repeat(43),
+ extensionId: 'a'.repeat(32),
+ browser: 'chromium' as const,
+ identity: 'unverified' as const,
+ code,
+ verifiedOrigin: `chrome-extension://${'a'.repeat(32)}`,
+ claimedExtensionId: 'a'.repeat(32),
+ publicAuthority: 'nas.local:16801',
+ createdAt: 1_000,
+ expiresAt: 121_000,
+}
+
+function harness(
+ snapshots: PendingPairRequestInfo[][] = [[entry], [entry], []]
+) {
+ const controller = new AbortController()
+ let now = 2_000
+ const frames: string[][] = []
+ const terminal: PairingTerminal = {
+ interactive: true,
+ signal: controller.signal,
+ begin: vi.fn(),
+ show: vi.fn((lines) => frames.push(lines)),
+ select: vi.fn(async () => '1'),
+ clear: vi.fn(),
+ close: vi.fn(),
+ }
+ const options = {
+ terminal,
+ listPending: vi.fn(async () => snapshots.shift() ?? []),
+ now: () => now,
+ wait: vi.fn(async (ms: number) => {
+ now += ms
+ }),
+ t: (key: string, values?: Readonly<Record<string, string | number>>) =>
+ `${key} ${JSON.stringify(values ?? {})}`,
+ }
+ return {
+ terminal,
+ options,
+ frames,
+ controller,
+ advance: (ms: number) => {
+ now += ms
+ },
+ }
+}
+
+describe('interactive Extension pairing', () => {
+ it('shows one explicitly selected code after revalidation and treats disappearance as ended', async () => {
+ const h = harness()
+ await expect(runExtensionPairingTerminal(h.options)).resolves.toBe('ended')
+ expect(h.frames[0].join('')).not.toContain(code)
+ expect(h.frames[1].join('')).toContain(code)
+ expect(h.options.listPending).toHaveBeenCalledTimes(3)
+ expect(h.terminal.close).toHaveBeenCalledOnce()
+ })
+ it('rejects a non-TTY before reading any request', async () => {
+ const h = harness()
+ h.options.terminal = { ...h.terminal, interactive: false }
+ await expect(runExtensionPairingTerminal(h.options)).rejects.toMatchObject({
+ reason: 'ttyRequired',
+ })
+ expect(h.options.listPending).not.toHaveBeenCalled()
+ })
+ it.each(['0', '-1', '2', 'all', '', '1; echo secret'])(
+ 'rejects selection %j without showing a code',
+ async (value) => {
+ const h = harness()
+ h.terminal.select = async () => value
+ await expect(
+ runExtensionPairingTerminal(h.options)
+ ).rejects.toMatchObject({ reason: 'invalidSelection' })
+ expect(h.frames.flat().join('')).not.toContain(code)
+ expect(h.terminal.close).toHaveBeenCalledOnce()
+ }
+ )
+ it.each([
+ { pairingNonce: 'another-nonce' },
+ { code: '9999-9999' },
+ { expiresAt: entry.expiresAt + 1 },
+ { createdAt: entry.createdAt + 1 },
+ { verifiedOrigin: 'chrome-extension://other' },
+ { claimedExtensionId: 'other' },
+ { identity: 'official' as const },
+ { publicAuthority: 'other' },
+ ])('refuses session substitution or drift %j', async (change) => {
+ const h = harness([[entry], [{ ...entry, ...change }]])
+ await expect(runExtensionPairingTerminal(h.options)).rejects.toMatchObject({
+ reason: 'unavailable',
+ })
+ expect(h.frames.flat().join('')).not.toContain(code)
+ })
+ it('preserves the initial selection even if rows reorder', async () => {
+ const other = { ...entry, pairingNonce: 'other', code: '9999-9999' }
+ const h = harness([[entry, other], [other, entry], []])
+ await runExtensionPairingTerminal(h.options)
+ expect(h.frames[1].join('')).toContain(code)
+ expect(h.frames.flat().join('')).not.toContain(other.code)
+ })
+ it('does not show a code after its deadline passes while choosing', async () => {
+ const h = harness()
+ h.terminal.select = async () => {
+ h.advance(120_000)
+ return '1'
+ }
+ await expect(runExtensionPairingTerminal(h.options)).rejects.toMatchObject({
+ reason: 'unavailable',
+ })
+ expect(h.frames.flat().join('')).not.toContain(code)
+ })
+ it('cleans the display on network failure without copying the code into an error', async () => {
+ const h = harness()
+ h.options.listPending
+ .mockImplementationOnce(async () => [entry])
+ .mockImplementationOnce(async () => [entry])
+ .mockRejectedValueOnce(new Error('offline'))
+ await expect(runExtensionPairingTerminal(h.options)).rejects.toThrow(
+ 'offline'
+ )
+ expect(h.terminal.close).toHaveBeenCalledOnce()
+ })
+ it('cleans the display on cancellation', async () => {
+ const h = harness()
+ h.terminal.select = async () => {
+ h.controller.abort()
+ throw new Error('aborted')
+ }
+ await expect(runExtensionPairingTerminal(h.options)).rejects.toMatchObject({
+ reason: 'cancelled',
+ })
+ expect(h.terminal.close).toHaveBeenCalledOnce()
+ })
+ it('removes terminal controls and bidi marks and bounds metadata', () => {
+ const result = terminalPairingText(
+ `\x1b]52;secret\x07\n\r\u202eevil${'x'.repeat(200)}`
+ )
+ expect(result).not.toMatch(/[\p{Cc}\p{Cf}]/u)
+ expect(result.length).toBe(160)
+ })
+})
diff --git a/src/server/operator-extension-pairing.ts b/src/server/operator-extension-pairing.ts
new file mode 100644
index 00000000..36a328e6
--- /dev/null
+++ b/src/server/operator-extension-pairing.ts
@@ -0,0 +1,223 @@
+import { createInterface } from 'node:readline/promises'
+import { setTimeout as delay } from 'node:timers/promises'
+import {
+ type PendingPairRequestInfo,
+ pairRequestKey,
+} from '@shared/protocol/bridge'
+
+type ExtensionRequest = Extract<PendingPairRequestInfo, { kind: 'extension' }>
+type Translate = (
+ key: string,
+ values?: Readonly<Record<string, string | number>>
+) => string
+
+export class ExtensionPairingTerminalError extends Error {
+ constructor(
+ readonly reason:
+ | 'ttyRequired'
+ | 'cancelled'
+ | 'invalidSelection'
+ | 'unavailable'
+ ) {
+ super(reason)
+ }
+}
+
+export interface PairingTerminal {
+ readonly interactive: boolean
+ readonly signal: AbortSignal
+ begin(): void
+ show(lines: string[]): void
+ select(prompt: string, signal: AbortSignal): Promise<string>
+ clear(): void
+ close(): void
+}
+
+/** Removes terminal commands, multiline spoofing and invisible direction marks. */
+export function terminalPairingText(value: string): string {
+ return value.replace(/[\p{Cc}\p{Cf}\p{Zl}\p{Zp}]/gu, '').slice(0, 160)
+}
+
+export function createPairingTerminal(): PairingTerminal {
+ const controller = new AbortController()
+ let reader: ReturnType<typeof createInterface> | undefined
+ let opened = false
+ const cancel = () => controller.abort()
+ const clear = () => {
+ if (opened) process.stdout.write('\x1b[2J\x1b[H')
+ }
+ return {
+ interactive:
+ process.stdin.isTTY === true &&
+ process.stdout.isTTY === true &&
+ process.stderr.isTTY === true,
+ signal: controller.signal,
+ begin() {
+ process.stdout.write('\x1b[?1049h')
+ opened = true
+ reader = createInterface({
+ input: process.stdin,
+ output: process.stdout,
+ terminal: true,
+ })
+ reader.on('SIGINT', cancel)
+ reader.on('SIGTSTP', cancel)
+ reader.on('close', cancel)
+ for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP', 'SIGTSTP'] as const)
+ process.on(signal, cancel)
+ },
+ show(lines) {
+ clear()
+ process.stdout.write(`${lines.join('\n')}\n`)
+ },
+ async select(prompt, signal) {
+ if (!reader) throw new ExtensionPairingTerminalError('cancelled')
+ return reader.question(prompt, { signal })
+ },
+ clear,
+ close() {
+ try {
+ clear()
+ if (opened) process.stdout.write('\x1b[?1049l')
+ } finally {
+ opened = false
+ reader?.close()
+ for (const signal of [
+ 'SIGINT',
+ 'SIGTERM',
+ 'SIGHUP',
+ 'SIGTSTP',
+ ] as const)
+ process.off(signal, cancel)
+ }
+ },
+ }
+}
+
+function sameRequest(left: ExtensionRequest, right: ExtensionRequest): boolean {
+ return (
+ pairRequestKey(left) === pairRequestKey(right) &&
+ left.code === right.code &&
+ left.identity === right.identity &&
+ left.verifiedOrigin === right.verifiedOrigin &&
+ left.originHost === right.originHost &&
+ left.claimedExtensionId === right.claimedExtensionId &&
+ left.attestationClass === right.attestationClass &&
+ left.publicAuthority === right.publicAuthority &&
+ left.createdAt === right.createdAt &&
+ left.expiresAt === right.expiresAt
+ )
+}
+
+export async function runExtensionPairingTerminal(options: {
+ terminal: PairingTerminal
+ listPending(signal: AbortSignal): Promise<PendingPairRequestInfo[]>
+ now(): number
+ t: Translate
+ wait?: (ms: number, signal: AbortSignal) => Promise<void>
+}): Promise<'none' | 'ended'> {
+ const { terminal, listPending, now, t } = options
+ if (!terminal.interactive)
+ throw new ExtensionPairingTerminalError('ttyRequired')
+ const wait =
+ options.wait ?? ((ms, signal) => delay(ms, undefined, { signal }))
+ let expiryTimer: ReturnType<typeof setTimeout> | undefined
+ const expired = new AbortController()
+ const signal = AbortSignal.any([terminal.signal, expired.signal])
+ const armDeadline = (deadline: number) => {
+ clearTimeout(expiryTimer)
+ expiryTimer = setTimeout(
+ () => {
+ // Clear immediately, even while an HTTP response is still in flight.
+ try {
+ terminal.clear()
+ } finally {
+ expired.abort()
+ }
+ },
+ Math.max(0, deadline - now())
+ )
+ }
+ try {
+ terminal.begin()
+ const pending = (await listPending(signal)).filter(
+ (request): request is ExtensionRequest =>
+ request.kind === 'extension' && request.expiresAt > now()
+ )
+ if (pending.length === 0) return 'none'
+ armDeadline(
+ Math.min(
+ now() + 120_000,
+ Math.max(...pending.map((request) => request.expiresAt))
+ )
+ )
+ terminal.show([
+ t('operatorAdmin.extension.heading'),
+ t('operatorAdmin.extension.identityNotice'),
+ ...pending.map((request, index) =>
+ t('operatorAdmin.extension.row', {
+ index: index + 1,
+ browser: request.browser,
+ identity: request.identity,
+ origin: terminalPairingText(
+ request.verifiedOrigin ?? request.extensionId
+ ),
+ claimedId: terminalPairingText(
+ request.claimedExtensionId ?? request.extensionId
+ ),
+ authority: terminalPairingText(request.publicAuthority ?? ''),
+ seconds: Math.max(0, Math.ceil((request.expiresAt - now()) / 1_000)),
+ })
+ ),
+ ])
+ const selection = (
+ await terminal.select(t('operatorAdmin.extension.select'), signal)
+ ).trim()
+ if (!/^[1-9]\d{0,3}$/.test(selection))
+ throw new ExtensionPairingTerminalError('invalidSelection')
+ const selected = pending[Number(selection) - 1]
+ if (!selected) throw new ExtensionPairingTerminalError('invalidSelection')
+ if (selected.expiresAt <= now())
+ throw new ExtensionPairingTerminalError('unavailable')
+ armDeadline(selected.expiresAt)
+
+ const getSelected = async (): Promise<ExtensionRequest | undefined> => {
+ const requests = await listPending(signal)
+ return requests.find(
+ (request): request is ExtensionRequest =>
+ request.kind === 'extension' &&
+ pairRequestKey(request) === pairRequestKey(selected)
+ )
+ }
+ const confirmed = await getSelected()
+ if (
+ !confirmed ||
+ !sameRequest(selected, confirmed) ||
+ confirmed.expiresAt <= now() ||
+ signal.aborted
+ ) {
+ throw new ExtensionPairingTerminalError('unavailable')
+ }
+ terminal.show([
+ t('operatorAdmin.extension.code', { code: confirmed.code }),
+ t('operatorAdmin.extension.instructions'),
+ ])
+ while (!signal.aborted && now() < selected.expiresAt) {
+ await wait(Math.min(1_000, selected.expiresAt - now()), signal)
+ const current = await getSelected()
+ if (!current) return 'ended'
+ if (!sameRequest(selected, current))
+ throw new ExtensionPairingTerminalError('unavailable')
+ }
+ throw new ExtensionPairingTerminalError('unavailable')
+ } catch (error) {
+ if (terminal.signal.aborted)
+ throw new ExtensionPairingTerminalError('cancelled')
+ if (expired.signal.aborted)
+ throw new ExtensionPairingTerminalError('unavailable')
+ throw error
+ } finally {
+ clearTimeout(expiryTimer)
+ terminal.close()
+ }
+}
diff --git a/src/server/operator-pairing-terminal.test.ts b/src/server/operator-pairing-terminal.test.ts
new file mode 100644
index 00000000..6eb6e8f2
--- /dev/null
+++ b/src/server/operator-pairing-terminal.test.ts
@@ -0,0 +1,63 @@
+// @vitest-environment node
+import { EventEmitter } from 'node:events'
+import { afterEach, describe, expect, it, vi } from 'vitest'
+
+const reader = vi.hoisted(() => ({ current: null as EventEmitter | null }))
+vi.mock('node:readline/promises', () => ({
+ createInterface: () => {
+ const emitter = new EventEmitter()
+ reader.current = emitter
+ return Object.assign(emitter, { close: () => emitter.emit('close') })
+ },
+}))
+
+import { createPairingTerminal } from './operator-extension-pairing'
+
+afterEach(() => vi.restoreAllMocks())
+
+describe('default pairing terminal lifecycle', () => {
+ it.each(['SIGINT', 'SIGTSTP', 'close'])(
+ 'cancels on readline %s and clears the sensitive screen',
+ (event) => {
+ const write = vi
+ .spyOn(process.stdout, 'write')
+ .mockImplementation(() => true)
+ const before = process.listenerCount('SIGTSTP')
+ const terminal = createPairingTerminal()
+ try {
+ terminal.begin()
+ terminal.show(['fixture-secret'])
+ reader.current!.emit(event)
+ expect(terminal.signal.aborted).toBe(true)
+ } finally {
+ terminal.close()
+ }
+ expect(write.mock.calls.map(([text]) => text).slice(-2)).toEqual([
+ '\x1b[2J\x1b[H',
+ '\x1b[?1049l',
+ ])
+ expect(process.listenerCount('SIGTSTP')).toBe(before)
+ }
+ )
+ it.each(['SIGINT', 'SIGTERM', 'SIGHUP', 'SIGTSTP'] as const)(
+ 'cancels on process %s and removes its listener',
+ (signal) => {
+ vi.spyOn(process.stdout, 'write').mockImplementation(() => true)
+ const before = process.listeners(signal)
+ const terminal = createPairingTerminal()
+ try {
+ terminal.begin()
+ const cancel = process
+ .listeners(signal)
+ .find((listener) => !before.includes(listener)) as (
+ signal: NodeJS.Signals
+ ) => void
+ cancel(signal)
+ expect(terminal.signal.aborted).toBe(true)
+ } finally {
+ terminal.close()
+ }
+ expect(process.listeners(signal)).toEqual(before)
+ }
+ )
+})
diff --git a/src/shared/locales/ar.json b/src/shared/locales/ar.json
index e223320f..0577dabc 100644
--- a/src/shared/locales/ar.json
+++ b/src/shared/locales/ar.json
@@ -377,13 +377,27 @@
"unknownOption": "خيار سطر أوامر غير معروف."
}
},
- "help": "الاستخدام:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n\nيتصل الأمر بخادم Motrix الجاري فقط عبر واجهة الاسترجاع داخل الحاوية.",
+ "help": "الاستخدام:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n motrix-admin extension pair\n\nيتصل الأمر بخادم Motrix الجاري فقط عبر واجهة الاسترجاع داخل الحاوية.",
"pending": {
"none": "لا توجد طلبات اقتران معلّقة.",
"row": "{{userCode}} {{clientName}} {{clientVersion}} تنتهي الصلاحية خلال {{ttl}}",
"ttl": "{{minutes}} د {{seconds}} ث"
},
- "usageHint": "شغّل `motrix-admin --help` لعرض طريقة الاستخدام."
+ "usageHint": "شغّل `motrix-admin --help` لعرض طريقة الاستخدام.",
+ "extension": {
+ "heading": "Pending browser Extension pairing requests",
+ "identityNotice": "Verify that you initiated this request. Origin and claimed identity alone do not prove who is connecting. Terminal recording can capture the pairing code.",
+ "row": "{{index}}. {{browser}} [{{identity}}] Origin: {{origin}}; claimed ID: {{claimedId}}; Server: {{authority}}; {{seconds}} s remaining",
+ "select": "Enter the number of one request (Ctrl+C to exit): ",
+ "code": "Pairing code: {{code}}",
+ "instructions": "Type this code into the browser Extension. It expires at the original deadline. Ctrl+C closes this view without approving or denying the request.",
+ "none": "No pending Extension pairing requests. Start pairing in the Extension, then run this command again. If requests remain absent, check the remote Extension configuration.",
+ "ended": "The selected pairing request has ended. Check the Extension for its outcome.",
+ "ttyRequired": "Extension pairing requires interactive input, output and error terminals. Piping, redirection and JSON output are not supported.",
+ "cancelled": "Pairing code view closed. No approval or denial was sent.",
+ "invalidSelection": "Select exactly one listed request by its number.",
+ "unavailable": "The selected request expired, ended or changed. Start a new pairing attempt in the Extension."
+ }
},
"operatorUnlock": {
"error": "رمز المشغّل غير صالح. تحقق من MOTRIX_OPERATOR_TOKEN أو <dataDir>/operator-token على المضيف وحاول مجددًا.",
diff --git a/src/shared/locales/bg.json b/src/shared/locales/bg.json
index 716c0591..3746e78f 100644
--- a/src/shared/locales/bg.json
+++ b/src/shared/locales/bg.json
@@ -373,13 +373,27 @@
"unknownOption": "Непозната опция на командния ред."
}
},
- "help": "Употреба:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n\nКомандата се свързва само с работещия сървър Motrix през локалния интерфейс на контейнера.",
+ "help": "Употреба:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n motrix-admin extension pair\n\nКомандата се свързва само с работещия сървър Motrix през локалния интерфейс на контейнера.",
"pending": {
"none": "Няма чакащи заявки за сдвояване.",
"row": "{{userCode}} {{clientName}} {{clientVersion}} изтича след {{ttl}}",
"ttl": "{{minutes}} мин {{seconds}} сек"
},
- "usageHint": "Изпълнете `motrix-admin --help` за указания."
+ "usageHint": "Изпълнете `motrix-admin --help` за указания.",
+ "extension": {
+ "heading": "Pending browser Extension pairing requests",
+ "identityNotice": "Verify that you initiated this request. Origin and claimed identity alone do not prove who is connecting. Terminal recording can capture the pairing code.",
+ "row": "{{index}}. {{browser}} [{{identity}}] Origin: {{origin}}; claimed ID: {{claimedId}}; Server: {{authority}}; {{seconds}} s remaining",
+ "select": "Enter the number of one request (Ctrl+C to exit): ",
+ "code": "Pairing code: {{code}}",
+ "instructions": "Type this code into the browser Extension. It expires at the original deadline. Ctrl+C closes this view without approving or denying the request.",
+ "none": "No pending Extension pairing requests. Start pairing in the Extension, then run this command again. If requests remain absent, check the remote Extension configuration.",
+ "ended": "The selected pairing request has ended. Check the Extension for its outcome.",
+ "ttyRequired": "Extension pairing requires interactive input, output and error terminals. Piping, redirection and JSON output are not supported.",
+ "cancelled": "Pairing code view closed. No approval or denial was sent.",
+ "invalidSelection": "Select exactly one listed request by its number.",
+ "unavailable": "The selected request expired, ended or changed. Start a new pairing attempt in the Extension."
+ }
},
"operatorUnlock": {
"error": "Невалиден операторски токен. Проверете MOTRIX_OPERATOR_TOKEN или <dataDir>/operator-token на хоста и опитайте отново.",
diff --git a/src/shared/locales/ca.json b/src/shared/locales/ca.json
index 4b347a01..aa599058 100644
--- a/src/shared/locales/ca.json
+++ b/src/shared/locales/ca.json
@@ -374,13 +374,27 @@
"unknownOption": "Opció de línia d'ordres desconeguda."
}
},
- "help": "Ús:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n\nL'ordre només es comunica amb el servidor Motrix en execució mitjançant la interfície de bucle local del contenidor.",
+ "help": "Ús:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n motrix-admin extension pair\n\nL'ordre només es comunica amb el servidor Motrix en execució mitjançant la interfície de bucle local del contenidor.",
"pending": {
"none": "No hi ha peticions d'aparellament pendents.",
"row": "{{userCode}} {{clientName}} {{clientVersion}} caduca d'aquí a {{ttl}}",
"ttl": "{{minutes}} min {{seconds}} s"
},
- "usageHint": "Executeu `motrix-admin --help` per veure les instruccions d'ús."
+ "usageHint": "Executeu `motrix-admin --help` per veure les instruccions d'ús.",
+ "extension": {
+ "heading": "Pending browser Extension pairing requests",
+ "identityNotice": "Verify that you initiated this request. Origin and claimed identity alone do not prove who is connecting. Terminal recording can capture the pairing code.",
+ "row": "{{index}}. {{browser}} [{{identity}}] Origin: {{origin}}; claimed ID: {{claimedId}}; Server: {{authority}}; {{seconds}} s remaining",
+ "select": "Enter the number of one request (Ctrl+C to exit): ",
+ "code": "Pairing code: {{code}}",
+ "instructions": "Type this code into the browser Extension. It expires at the original deadline. Ctrl+C closes this view without approving or denying the request.",
+ "none": "No pending Extension pairing requests. Start pairing in the Extension, then run this command again. If requests remain absent, check the remote Extension configuration.",
+ "ended": "The selected pairing request has ended. Check the Extension for its outcome.",
+ "ttyRequired": "Extension pairing requires interactive input, output and error terminals. Piping, redirection and JSON output are not supported.",
+ "cancelled": "Pairing code view closed. No approval or denial was sent.",
+ "invalidSelection": "Select exactly one listed request by its number.",
+ "unavailable": "The selected request expired, ended or changed. Start a new pairing attempt in the Extension."
+ }
},
"operatorUnlock": {
"error": "El testimoni d'operador no és vàlid. Comproveu MOTRIX_OPERATOR_TOKEN o <dataDir>/operator-token a l'amfitrió i torneu-ho a provar.",
diff --git a/src/shared/locales/de.json b/src/shared/locales/de.json
index 82954697..02980ea7 100644
--- a/src/shared/locales/de.json
+++ b/src/shared/locales/de.json
@@ -7,7 +7,7 @@
"submit": "Entsperren"
},
"operatorAdmin": {
- "help": "Verwendung:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n\nDer Befehl kommuniziert ausschließlich über die Loopback-Schnittstelle des Containers mit dem laufenden Motrix-Server.",
+ "help": "Verwendung:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n motrix-admin extension pair\n\nDer Befehl kommuniziert ausschließlich über die Loopback-Schnittstelle des Containers mit dem laufenden Motrix-Server.",
"errorPrefix": "motrix-admin: {{message}}",
"usageHint": "Hinweise zur Verwendung erhalten Sie mit `motrix-admin --help`.",
"pending": {
@@ -55,6 +55,20 @@
"loopback": "Der laufende Motrix-Server ist über die Loopback-Schnittstelle des Containers nicht erreichbar.",
"approvalNotReady": "Die Kopplungsfreigabe ist auf dem laufenden Motrix-Server noch nicht bereit."
}
+ },
+ "extension": {
+ "heading": "Pending browser Extension pairing requests",
+ "identityNotice": "Verify that you initiated this request. Origin and claimed identity alone do not prove who is connecting. Terminal recording can capture the pairing code.",
+ "row": "{{index}}. {{browser}} [{{identity}}] Origin: {{origin}}; claimed ID: {{claimedId}}; Server: {{authority}}; {{seconds}} s remaining",
+ "select": "Enter the number of one request (Ctrl+C to exit): ",
+ "code": "Pairing code: {{code}}",
+ "instructions": "Type this code into the browser Extension. It expires at the original deadline. Ctrl+C closes this view without approving or denying the request.",
+ "none": "No pending Extension pairing requests. Start pairing in the Extension, then run this command again. If requests remain absent, check the remote Extension configuration.",
+ "ended": "The selected pairing request has ended. Check the Extension for its outcome.",
+ "ttyRequired": "Extension pairing requires interactive input, output and error terminals. Piping, redirection and JSON output are not supported.",
+ "cancelled": "Pairing code view closed. No approval or denial was sent.",
+ "invalidSelection": "Select exactly one listed request by its number.",
+ "unavailable": "The selected request expired, ended or changed. Start a new pairing attempt in the Extension."
}
},
"common": {
diff --git a/src/shared/locales/el.json b/src/shared/locales/el.json
index 7708d61f..77586548 100644
--- a/src/shared/locales/el.json
+++ b/src/shared/locales/el.json
@@ -373,13 +373,27 @@
"unknownOption": "Άγνωστη επιλογή γραμμής εντολών."
}
},
- "help": "Χρήση:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n\nΗ εντολή επικοινωνεί μόνο με τον εκτελούμενο διακομιστή Motrix μέσω της τοπικής διεπαφής loopback του περιέκτη.",
+ "help": "Χρήση:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n motrix-admin extension pair\n\nΗ εντολή επικοινωνεί μόνο με τον εκτελούμενο διακομιστή Motrix μέσω της τοπικής διεπαφής loopback του περιέκτη.",
"pending": {
"none": "Δεν υπάρχουν εκκρεμή αιτήματα σύζευξης.",
"row": "{{userCode}} {{clientName}} {{clientVersion}} λήγει σε {{ttl}}",
"ttl": "{{minutes}} λεπ. {{seconds}} δευτ."
},
- "usageHint": "Εκτελέστε `motrix-admin --help` για οδηγίες χρήσης."
+ "usageHint": "Εκτελέστε `motrix-admin --help` για οδηγίες χρήσης.",
+ "extension": {
+ "heading": "Pending browser Extension pairing requests",
+ "identityNotice": "Verify that you initiated this request. Origin and claimed identity alone do not prove who is connecting. Terminal recording can capture the pairing code.",
+ "row": "{{index}}. {{browser}} [{{identity}}] Origin: {{origin}}; claimed ID: {{claimedId}}; Server: {{authority}}; {{seconds}} s remaining",
+ "select": "Enter the number of one request (Ctrl+C to exit): ",
+ "code": "Pairing code: {{code}}",
+ "instructions": "Type this code into the browser Extension. It expires at the original deadline. Ctrl+C closes this view without approving or denying the request.",
+ "none": "No pending Extension pairing requests. Start pairing in the Extension, then run this command again. If requests remain absent, check the remote Extension configuration.",
+ "ended": "The selected pairing request has ended. Check the Extension for its outcome.",
+ "ttyRequired": "Extension pairing requires interactive input, output and error terminals. Piping, redirection and JSON output are not supported.",
+ "cancelled": "Pairing code view closed. No approval or denial was sent.",
+ "invalidSelection": "Select exactly one listed request by its number.",
+ "unavailable": "The selected request expired, ended or changed. Start a new pairing attempt in the Extension."
+ }
},
"operatorUnlock": {
"error": "Μη έγκυρο διακριτικό χειριστή. Ελέγξτε το MOTRIX_OPERATOR_TOKEN ή το <dataDir>/operator-token στον κεντρικό υπολογιστή και δοκιμάστε ξανά.",
diff --git a/src/shared/locales/en-US.json b/src/shared/locales/en-US.json
index 7c42c7da..49dd3cc4 100644
--- a/src/shared/locales/en-US.json
+++ b/src/shared/locales/en-US.json
@@ -7,7 +7,7 @@
"submit": "Unlock"
},
"operatorAdmin": {
- "help": "Usage:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n\nThe command talks only to the running Motrix server over container loopback.",
+ "help": "Usage:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n motrix-admin extension pair\n\nThe command talks only to the running Motrix server over container loopback.",
"errorPrefix": "motrix-admin: {{message}}",
"usageHint": "Run `motrix-admin --help` for usage.",
"pending": {
@@ -55,6 +55,20 @@
"loopback": "The running Motrix server is unavailable on container loopback.",
"approvalNotReady": "Pairing approval is not ready in the running Motrix server."
}
+ },
+ "extension": {
+ "heading": "Pending browser Extension pairing requests",
+ "identityNotice": "Verify that you initiated this request. Origin and claimed identity alone do not prove who is connecting. Terminal recording can capture the pairing code.",
+ "row": "{{index}}. {{browser}} [{{identity}}] Origin: {{origin}}; claimed ID: {{claimedId}}; Server: {{authority}}; {{seconds}} s remaining",
+ "select": "Enter the number of one request (Ctrl+C to exit): ",
+ "code": "Pairing code: {{code}}",
+ "instructions": "Type this code into the browser Extension. It expires at the original deadline. Ctrl+C closes this view without approving or denying the request.",
+ "none": "No pending Extension pairing requests. Start pairing in the Extension, then run this command again. If requests remain absent, check the remote Extension configuration.",
+ "ended": "The selected pairing request has ended. Check the Extension for its outcome.",
+ "ttyRequired": "Extension pairing requires interactive input, output and error terminals. Piping, redirection and JSON output are not supported.",
+ "cancelled": "Pairing code view closed. No approval or denial was sent.",
+ "invalidSelection": "Select exactly one listed request by its number.",
+ "unavailable": "The selected request expired, ended or changed. Start a new pairing attempt in the Extension."
}
},
"common": {
diff --git a/src/shared/locales/es.json b/src/shared/locales/es.json
index 65dfe06b..22203590 100644
--- a/src/shared/locales/es.json
+++ b/src/shared/locales/es.json
@@ -7,7 +7,7 @@
"submit": "Desbloquear"
},
"operatorAdmin": {
- "help": "Uso:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n\nEl comando solo se comunica con el servidor Motrix en ejecución a través de la interfaz de bucle local del contenedor.",
+ "help": "Uso:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n motrix-admin extension pair\n\nEl comando solo se comunica con el servidor Motrix en ejecución a través de la interfaz de bucle local del contenedor.",
"errorPrefix": "motrix-admin: {{message}}",
"usageHint": "Ejecuta `motrix-admin --help` para consultar el uso.",
"pending": {
@@ -55,6 +55,20 @@
"loopback": "El servidor Motrix en ejecución no está disponible en la interfaz de bucle local del contenedor.",
"approvalNotReady": "La aprobación de vinculaciones no está lista en el servidor Motrix en ejecución."
}
+ },
+ "extension": {
+ "heading": "Pending browser Extension pairing requests",
+ "identityNotice": "Verify that you initiated this request. Origin and claimed identity alone do not prove who is connecting. Terminal recording can capture the pairing code.",
+ "row": "{{index}}. {{browser}} [{{identity}}] Origin: {{origin}}; claimed ID: {{claimedId}}; Server: {{authority}}; {{seconds}} s remaining",
+ "select": "Enter the number of one request (Ctrl+C to exit): ",
+ "code": "Pairing code: {{code}}",
+ "instructions": "Type this code into the browser Extension. It expires at the original deadline. Ctrl+C closes this view without approving or denying the request.",
+ "none": "No pending Extension pairing requests. Start pairing in the Extension, then run this command again. If requests remain absent, check the remote Extension configuration.",
+ "ended": "The selected pairing request has ended. Check the Extension for its outcome.",
+ "ttyRequired": "Extension pairing requires interactive input, output and error terminals. Piping, redirection and JSON output are not supported.",
+ "cancelled": "Pairing code view closed. No approval or denial was sent.",
+ "invalidSelection": "Select exactly one listed request by its number.",
+ "unavailable": "The selected request expired, ended or changed. Start a new pairing attempt in the Extension."
}
},
"common": {
diff --git a/src/shared/locales/fa.json b/src/shared/locales/fa.json
index d2954b33..21ddffa1 100644
--- a/src/shared/locales/fa.json
+++ b/src/shared/locales/fa.json
@@ -373,13 +373,27 @@
"unknownOption": "گزینهٔ خط فرمان ناشناخته است."
}
},
- "help": "نحوهٔ استفاده:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n\nاین فرمان فقط از طریق رابط loopback کانتینر با سرور در حال اجرای Motrix ارتباط برقرار می‌کند.",
+ "help": "نحوهٔ استفاده:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n motrix-admin extension pair\n\nاین فرمان فقط از طریق رابط loopback کانتینر با سرور در حال اجرای Motrix ارتباط برقرار می‌کند.",
"pending": {
"none": "درخواست جفت‌سازی در انتظاری وجود ندارد.",
"row": "{{userCode}} {{clientName}} {{clientVersion}} انقضا در {{ttl}}",
"ttl": "{{minutes}} دقیقه {{seconds}} ثانیه"
},
- "usageHint": "برای راهنما، `motrix-admin --help` را اجرا کنید."
+ "usageHint": "برای راهنما، `motrix-admin --help` را اجرا کنید.",
+ "extension": {
+ "heading": "Pending browser Extension pairing requests",
+ "identityNotice": "Verify that you initiated this request. Origin and claimed identity alone do not prove who is connecting. Terminal recording can capture the pairing code.",
+ "row": "{{index}}. {{browser}} [{{identity}}] Origin: {{origin}}; claimed ID: {{claimedId}}; Server: {{authority}}; {{seconds}} s remaining",
+ "select": "Enter the number of one request (Ctrl+C to exit): ",
+ "code": "Pairing code: {{code}}",
+ "instructions": "Type this code into the browser Extension. It expires at the original deadline. Ctrl+C closes this view without approving or denying the request.",
+ "none": "No pending Extension pairing requests. Start pairing in the Extension, then run this command again. If requests remain absent, check the remote Extension configuration.",
+ "ended": "The selected pairing request has ended. Check the Extension for its outcome.",
+ "ttyRequired": "Extension pairing requires interactive input, output and error terminals. Piping, redirection and JSON output are not supported.",
+ "cancelled": "Pairing code view closed. No approval or denial was sent.",
+ "invalidSelection": "Select exactly one listed request by its number.",
+ "unavailable": "The selected request expired, ended or changed. Start a new pairing attempt in the Extension."
+ }
},
"operatorUnlock": {
"error": "توکن اپراتور نامعتبر است. MOTRIX_OPERATOR_TOKEN یا <dataDir>/operator-token را روی میزبان بررسی کنید و دوباره تلاش کنید.",
diff --git a/src/shared/locales/fr.json b/src/shared/locales/fr.json
index 8a335a92..b2cc3a08 100644
--- a/src/shared/locales/fr.json
+++ b/src/shared/locales/fr.json
@@ -374,13 +374,27 @@
"unknownOption": "Option de ligne de commande inconnue."
}
},
- "help": "Utilisation :\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n\nCette commande communique uniquement avec le serveur Motrix en cours d’exécution via l’interface de bouclage du conteneur.",
+ "help": "Utilisation :\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n motrix-admin extension pair\n\nCette commande communique uniquement avec le serveur Motrix en cours d’exécution via l’interface de bouclage du conteneur.",
"pending": {
"none": "Aucune demande d’association en attente.",
"row": "{{userCode}} {{clientName}} {{clientVersion}} expire dans {{ttl}}",
"ttl": "{{minutes}} min {{seconds}} s"
},
- "usageHint": "Exécutez `motrix-admin --help` pour consulter l’aide."
+ "usageHint": "Exécutez `motrix-admin --help` pour consulter l’aide.",
+ "extension": {
+ "heading": "Pending browser Extension pairing requests",
+ "identityNotice": "Verify that you initiated this request. Origin and claimed identity alone do not prove who is connecting. Terminal recording can capture the pairing code.",
+ "row": "{{index}}. {{browser}} [{{identity}}] Origin: {{origin}}; claimed ID: {{claimedId}}; Server: {{authority}}; {{seconds}} s remaining",
+ "select": "Enter the number of one request (Ctrl+C to exit): ",
+ "code": "Pairing code: {{code}}",
+ "instructions": "Type this code into the browser Extension. It expires at the original deadline. Ctrl+C closes this view without approving or denying the request.",
+ "none": "No pending Extension pairing requests. Start pairing in the Extension, then run this command again. If requests remain absent, check the remote Extension configuration.",
+ "ended": "The selected pairing request has ended. Check the Extension for its outcome.",
+ "ttyRequired": "Extension pairing requires interactive input, output and error terminals. Piping, redirection and JSON output are not supported.",
+ "cancelled": "Pairing code view closed. No approval or denial was sent.",
+ "invalidSelection": "Select exactly one listed request by its number.",
+ "unavailable": "The selected request expired, ended or changed. Start a new pairing attempt in the Extension."
+ }
},
"operatorUnlock": {
"error": "Jeton d’administration invalide. Vérifiez MOTRIX_OPERATOR_TOKEN ou <dataDir>/operator-token sur l’hôte, puis réessayez.",
diff --git a/src/shared/locales/hu.json b/src/shared/locales/hu.json
index d0007dca..bfc8a1d4 100644
--- a/src/shared/locales/hu.json
+++ b/src/shared/locales/hu.json
@@ -7,7 +7,7 @@
"submit": "Feloldás"
},
"operatorAdmin": {
- "help": "Használat:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n\nA parancs kizárólag a futó Motrix szerverrel kommunikál a konténer loopback kapcsolatán keresztül.",
+ "help": "Használat:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n motrix-admin extension pair\n\nA parancs kizárólag a futó Motrix szerverrel kommunikál a konténer loopback kapcsolatán keresztül.",
"errorPrefix": "motrix-admin: {{message}}",
"usageHint": "A használati útmutatóhoz futtasd a `motrix-admin --help` parancsot.",
"pending": {
@@ -55,6 +55,20 @@
"loopback": "A futó Motrix szerver nem érhető el a konténer loopback kapcsolatán keresztül.",
"approvalNotReady": "A párosítás jóváhagyása még nem áll készen a futó Motrix szerveren."
}
+ },
+ "extension": {
+ "heading": "Pending browser Extension pairing requests",
+ "identityNotice": "Verify that you initiated this request. Origin and claimed identity alone do not prove who is connecting. Terminal recording can capture the pairing code.",
+ "row": "{{index}}. {{browser}} [{{identity}}] Origin: {{origin}}; claimed ID: {{claimedId}}; Server: {{authority}}; {{seconds}} s remaining",
+ "select": "Enter the number of one request (Ctrl+C to exit): ",
+ "code": "Pairing code: {{code}}",
+ "instructions": "Type this code into the browser Extension. It expires at the original deadline. Ctrl+C closes this view without approving or denying the request.",
+ "none": "No pending Extension pairing requests. Start pairing in the Extension, then run this command again. If requests remain absent, check the remote Extension configuration.",
+ "ended": "The selected pairing request has ended. Check the Extension for its outcome.",
+ "ttyRequired": "Extension pairing requires interactive input, output and error terminals. Piping, redirection and JSON output are not supported.",
+ "cancelled": "Pairing code view closed. No approval or denial was sent.",
+ "invalidSelection": "Select exactly one listed request by its number.",
+ "unavailable": "The selected request expired, ended or changed. Start a new pairing attempt in the Extension."
}
},
"common": {
diff --git a/src/shared/locales/id.json b/src/shared/locales/id.json
index 450a191c..d23215c6 100644
--- a/src/shared/locales/id.json
+++ b/src/shared/locales/id.json
@@ -7,7 +7,7 @@
"submit": "Buka akses"
},
"operatorAdmin": {
- "help": "Penggunaan:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n\nPerintah ini hanya berkomunikasi dengan server Motrix yang berjalan melalui loopback kontainer.",
+ "help": "Penggunaan:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n motrix-admin extension pair\n\nPerintah ini hanya berkomunikasi dengan server Motrix yang berjalan melalui loopback kontainer.",
"errorPrefix": "motrix-admin: {{message}}",
"usageHint": "Jalankan `motrix-admin --help` untuk petunjuk penggunaan.",
"pending": {
@@ -55,6 +55,20 @@
"loopback": "Server Motrix yang berjalan tidak tersedia melalui loopback kontainer.",
"approvalNotReady": "Persetujuan pemasangan belum siap pada server Motrix yang berjalan."
}
+ },
+ "extension": {
+ "heading": "Pending browser Extension pairing requests",
+ "identityNotice": "Verify that you initiated this request. Origin and claimed identity alone do not prove who is connecting. Terminal recording can capture the pairing code.",
+ "row": "{{index}}. {{browser}} [{{identity}}] Origin: {{origin}}; claimed ID: {{claimedId}}; Server: {{authority}}; {{seconds}} s remaining",
+ "select": "Enter the number of one request (Ctrl+C to exit): ",
+ "code": "Pairing code: {{code}}",
+ "instructions": "Type this code into the browser Extension. It expires at the original deadline. Ctrl+C closes this view without approving or denying the request.",
+ "none": "No pending Extension pairing requests. Start pairing in the Extension, then run this command again. If requests remain absent, check the remote Extension configuration.",
+ "ended": "The selected pairing request has ended. Check the Extension for its outcome.",
+ "ttyRequired": "Extension pairing requires interactive input, output and error terminals. Piping, redirection and JSON output are not supported.",
+ "cancelled": "Pairing code view closed. No approval or denial was sent.",
+ "invalidSelection": "Select exactly one listed request by its number.",
+ "unavailable": "The selected request expired, ended or changed. Start a new pairing attempt in the Extension."
}
},
"common": {
diff --git a/src/shared/locales/it.json b/src/shared/locales/it.json
index a93242c5..f535b4cb 100644
--- a/src/shared/locales/it.json
+++ b/src/shared/locales/it.json
@@ -7,7 +7,7 @@
"submit": "Sblocca"
},
"operatorAdmin": {
- "help": "Utilizzo:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n\nIl comando comunica esclusivamente con il server Motrix in esecuzione tramite l’interfaccia di loopback del container.",
+ "help": "Utilizzo:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n motrix-admin extension pair\n\nIl comando comunica esclusivamente con il server Motrix in esecuzione tramite l’interfaccia di loopback del container.",
"errorPrefix": "motrix-admin: {{message}}",
"usageHint": "Esegui `motrix-admin --help` per le istruzioni d’uso.",
"pending": {
@@ -55,6 +55,20 @@
"loopback": "Il server Motrix in esecuzione non è disponibile sull’interfaccia di loopback del container.",
"approvalNotReady": "L’approvazione delle associazioni non è ancora pronta nel server Motrix in esecuzione."
}
+ },
+ "extension": {
+ "heading": "Pending browser Extension pairing requests",
+ "identityNotice": "Verify that you initiated this request. Origin and claimed identity alone do not prove who is connecting. Terminal recording can capture the pairing code.",
+ "row": "{{index}}. {{browser}} [{{identity}}] Origin: {{origin}}; claimed ID: {{claimedId}}; Server: {{authority}}; {{seconds}} s remaining",
+ "select": "Enter the number of one request (Ctrl+C to exit): ",
+ "code": "Pairing code: {{code}}",
+ "instructions": "Type this code into the browser Extension. It expires at the original deadline. Ctrl+C closes this view without approving or denying the request.",
+ "none": "No pending Extension pairing requests. Start pairing in the Extension, then run this command again. If requests remain absent, check the remote Extension configuration.",
+ "ended": "The selected pairing request has ended. Check the Extension for its outcome.",
+ "ttyRequired": "Extension pairing requires interactive input, output and error terminals. Piping, redirection and JSON output are not supported.",
+ "cancelled": "Pairing code view closed. No approval or denial was sent.",
+ "invalidSelection": "Select exactly one listed request by its number.",
+ "unavailable": "The selected request expired, ended or changed. Start a new pairing attempt in the Extension."
}
},
"common": {
diff --git a/src/shared/locales/ja.json b/src/shared/locales/ja.json
index 6683d45e..259b157b 100644
--- a/src/shared/locales/ja.json
+++ b/src/shared/locales/ja.json
@@ -7,7 +7,7 @@
"submit": "ロックを解除"
},
"operatorAdmin": {
- "help": "使い方:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n\nこのコマンドは、コンテナーのループバック経由で、実行中の Motrix サーバーとのみ通信します。",
+ "help": "使い方:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n motrix-admin extension pair\n\nこのコマンドは、コンテナーのループバック経由で、実行中の Motrix サーバーとのみ通信します。",
"errorPrefix": "motrix-admin: {{message}}",
"usageHint": "使い方を確認するには `motrix-admin --help` を実行してください。",
"pending": {
@@ -55,6 +55,20 @@
"loopback": "コンテナーのループバックから実行中の Motrix サーバーに接続できません。",
"approvalNotReady": "実行中の Motrix サーバーでペアリング承認の準備ができていません。"
}
+ },
+ "extension": {
+ "heading": "Pending browser Extension pairing requests",
+ "identityNotice": "Verify that you initiated this request. Origin and claimed identity alone do not prove who is connecting. Terminal recording can capture the pairing code.",
+ "row": "{{index}}. {{browser}} [{{identity}}] Origin: {{origin}}; claimed ID: {{claimedId}}; Server: {{authority}}; {{seconds}} s remaining",
+ "select": "Enter the number of one request (Ctrl+C to exit): ",
+ "code": "Pairing code: {{code}}",
+ "instructions": "Type this code into the browser Extension. It expires at the original deadline. Ctrl+C closes this view without approving or denying the request.",
+ "none": "No pending Extension pairing requests. Start pairing in the Extension, then run this command again. If requests remain absent, check the remote Extension configuration.",
+ "ended": "The selected pairing request has ended. Check the Extension for its outcome.",
+ "ttyRequired": "Extension pairing requires interactive input, output and error terminals. Piping, redirection and JSON output are not supported.",
+ "cancelled": "Pairing code view closed. No approval or denial was sent.",
+ "invalidSelection": "Select exactly one listed request by its number.",
+ "unavailable": "The selected request expired, ended or changed. Start a new pairing attempt in the Extension."
}
},
"common": {
diff --git a/src/shared/locales/ko.json b/src/shared/locales/ko.json
index bde048b8..678f72be 100644
--- a/src/shared/locales/ko.json
+++ b/src/shared/locales/ko.json
@@ -7,7 +7,7 @@
"submit": "잠금 해제"
},
"operatorAdmin": {
- "help": "사용법:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n\n이 명령은 컨테이너 루프백을 통해 실행 중인 Motrix 서버와만 통신합니다.",
+ "help": "사용법:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n motrix-admin extension pair\n\n이 명령은 컨테이너 루프백을 통해 실행 중인 Motrix 서버와만 통신합니다.",
"errorPrefix": "motrix-admin: {{message}}",
"usageHint": "사용법을 보려면 `motrix-admin --help`를 실행하세요.",
"pending": {
@@ -55,6 +55,20 @@
"loopback": "컨테이너 루프백에서 실행 중인 Motrix 서버에 연결할 수 없습니다.",
"approvalNotReady": "실행 중인 Motrix 서버의 페어링 승인이 아직 준비되지 않았습니다."
}
+ },
+ "extension": {
+ "heading": "Pending browser Extension pairing requests",
+ "identityNotice": "Verify that you initiated this request. Origin and claimed identity alone do not prove who is connecting. Terminal recording can capture the pairing code.",
+ "row": "{{index}}. {{browser}} [{{identity}}] Origin: {{origin}}; claimed ID: {{claimedId}}; Server: {{authority}}; {{seconds}} s remaining",
+ "select": "Enter the number of one request (Ctrl+C to exit): ",
+ "code": "Pairing code: {{code}}",
+ "instructions": "Type this code into the browser Extension. It expires at the original deadline. Ctrl+C closes this view without approving or denying the request.",
+ "none": "No pending Extension pairing requests. Start pairing in the Extension, then run this command again. If requests remain absent, check the remote Extension configuration.",
+ "ended": "The selected pairing request has ended. Check the Extension for its outcome.",
+ "ttyRequired": "Extension pairing requires interactive input, output and error terminals. Piping, redirection and JSON output are not supported.",
+ "cancelled": "Pairing code view closed. No approval or denial was sent.",
+ "invalidSelection": "Select exactly one listed request by its number.",
+ "unavailable": "The selected request expired, ended or changed. Start a new pairing attempt in the Extension."
}
},
"common": {
diff --git a/src/shared/locales/nb.json b/src/shared/locales/nb.json
index db6e447b..d7080879 100644
--- a/src/shared/locales/nb.json
+++ b/src/shared/locales/nb.json
@@ -373,13 +373,27 @@
"unknownOption": "Ukjent kommandolinjealternativ."
}
},
- "help": "Bruk:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n\nKommandoen kommuniserer bare med den kjørende Motrix-serveren via containerens loopback-grensesnitt.",
+ "help": "Bruk:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n motrix-admin extension pair\n\nKommandoen kommuniserer bare med den kjørende Motrix-serveren via containerens loopback-grensesnitt.",
"pending": {
"none": "Ingen ventende sammenkoblingsforespørsler.",
"row": "{{userCode}} {{clientName}} {{clientVersion}} utløper om {{ttl}}",
"ttl": "{{minutes}} min {{seconds}} s"
},
- "usageHint": "Kjør `motrix-admin --help` for bruksanvisning."
+ "usageHint": "Kjør `motrix-admin --help` for bruksanvisning.",
+ "extension": {
+ "heading": "Pending browser Extension pairing requests",
+ "identityNotice": "Verify that you initiated this request. Origin and claimed identity alone do not prove who is connecting. Terminal recording can capture the pairing code.",
+ "row": "{{index}}. {{browser}} [{{identity}}] Origin: {{origin}}; claimed ID: {{claimedId}}; Server: {{authority}}; {{seconds}} s remaining",
+ "select": "Enter the number of one request (Ctrl+C to exit): ",
+ "code": "Pairing code: {{code}}",
+ "instructions": "Type this code into the browser Extension. It expires at the original deadline. Ctrl+C closes this view without approving or denying the request.",
+ "none": "No pending Extension pairing requests. Start pairing in the Extension, then run this command again. If requests remain absent, check the remote Extension configuration.",
+ "ended": "The selected pairing request has ended. Check the Extension for its outcome.",
+ "ttyRequired": "Extension pairing requires interactive input, output and error terminals. Piping, redirection and JSON output are not supported.",
+ "cancelled": "Pairing code view closed. No approval or denial was sent.",
+ "invalidSelection": "Select exactly one listed request by its number.",
+ "unavailable": "The selected request expired, ended or changed. Start a new pairing attempt in the Extension."
+ }
},
"operatorUnlock": {
"error": "Ugyldig operatørtoken. Kontroller MOTRIX_OPERATOR_TOKEN eller <dataDir>/operator-token på vertsmaskinen og prøv igjen.",
diff --git a/src/shared/locales/nl.json b/src/shared/locales/nl.json
index 33d499c2..6528f612 100644
--- a/src/shared/locales/nl.json
+++ b/src/shared/locales/nl.json
@@ -373,13 +373,27 @@
"unknownOption": "Onbekende opdrachtregeloptie."
}
},
- "help": "Gebruik:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n\nDe opdracht communiceert alleen met de actieve Motrix-server via de loopbackinterface van de container.",
+ "help": "Gebruik:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n motrix-admin extension pair\n\nDe opdracht communiceert alleen met de actieve Motrix-server via de loopbackinterface van de container.",
"pending": {
"none": "Geen koppelingsverzoeken in behandeling.",
"row": "{{userCode}} {{clientName}} {{clientVersion}} verloopt over {{ttl}}",
"ttl": "{{minutes}}m {{seconds}}s"
},
- "usageHint": "Voer `motrix-admin --help` uit voor gebruiksinstructies."
+ "usageHint": "Voer `motrix-admin --help` uit voor gebruiksinstructies.",
+ "extension": {
+ "heading": "Pending browser Extension pairing requests",
+ "identityNotice": "Verify that you initiated this request. Origin and claimed identity alone do not prove who is connecting. Terminal recording can capture the pairing code.",
+ "row": "{{index}}. {{browser}} [{{identity}}] Origin: {{origin}}; claimed ID: {{claimedId}}; Server: {{authority}}; {{seconds}} s remaining",
+ "select": "Enter the number of one request (Ctrl+C to exit): ",
+ "code": "Pairing code: {{code}}",
+ "instructions": "Type this code into the browser Extension. It expires at the original deadline. Ctrl+C closes this view without approving or denying the request.",
+ "none": "No pending Extension pairing requests. Start pairing in the Extension, then run this command again. If requests remain absent, check the remote Extension configuration.",
+ "ended": "The selected pairing request has ended. Check the Extension for its outcome.",
+ "ttyRequired": "Extension pairing requires interactive input, output and error terminals. Piping, redirection and JSON output are not supported.",
+ "cancelled": "Pairing code view closed. No approval or denial was sent.",
+ "invalidSelection": "Select exactly one listed request by its number.",
+ "unavailable": "The selected request expired, ended or changed. Start a new pairing attempt in the Extension."
+ }
},
"operatorUnlock": {
"error": "Ongeldig operatortoken. Controleer MOTRIX_OPERATOR_TOKEN of <dataDir>/operator-token op de host en probeer het opnieuw.",
diff --git a/src/shared/locales/pl.json b/src/shared/locales/pl.json
index 3391769f..e3bb42f0 100644
--- a/src/shared/locales/pl.json
+++ b/src/shared/locales/pl.json
@@ -7,7 +7,7 @@
"submit": "Odblokuj"
},
"operatorAdmin": {
- "help": "Użycie:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n\nPolecenie łączy się wyłącznie z działającym serwerem Motrix przez interfejs pętli zwrotnej kontenera.",
+ "help": "Użycie:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n motrix-admin extension pair\n\nPolecenie łączy się wyłącznie z działającym serwerem Motrix przez interfejs pętli zwrotnej kontenera.",
"errorPrefix": "motrix-admin: {{message}}",
"usageHint": "Uruchom `motrix-admin --help`, aby wyświetlić sposób użycia.",
"pending": {
@@ -55,6 +55,20 @@
"loopback": "Działający serwer Motrix jest niedostępny przez interfejs pętli zwrotnej kontenera.",
"approvalNotReady": "Zatwierdzanie parowania nie jest gotowe w działającym serwerze Motrix."
}
+ },
+ "extension": {
+ "heading": "Pending browser Extension pairing requests",
+ "identityNotice": "Verify that you initiated this request. Origin and claimed identity alone do not prove who is connecting. Terminal recording can capture the pairing code.",
+ "row": "{{index}}. {{browser}} [{{identity}}] Origin: {{origin}}; claimed ID: {{claimedId}}; Server: {{authority}}; {{seconds}} s remaining",
+ "select": "Enter the number of one request (Ctrl+C to exit): ",
+ "code": "Pairing code: {{code}}",
+ "instructions": "Type this code into the browser Extension. It expires at the original deadline. Ctrl+C closes this view without approving or denying the request.",
+ "none": "No pending Extension pairing requests. Start pairing in the Extension, then run this command again. If requests remain absent, check the remote Extension configuration.",
+ "ended": "The selected pairing request has ended. Check the Extension for its outcome.",
+ "ttyRequired": "Extension pairing requires interactive input, output and error terminals. Piping, redirection and JSON output are not supported.",
+ "cancelled": "Pairing code view closed. No approval or denial was sent.",
+ "invalidSelection": "Select exactly one listed request by its number.",
+ "unavailable": "The selected request expired, ended or changed. Start a new pairing attempt in the Extension."
}
},
"common": {
diff --git a/src/shared/locales/pt-BR.json b/src/shared/locales/pt-BR.json
index 514155a6..40cf5e10 100644
--- a/src/shared/locales/pt-BR.json
+++ b/src/shared/locales/pt-BR.json
@@ -7,7 +7,7 @@
"submit": "Desbloquear"
},
"operatorAdmin": {
- "help": "Uso:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n\nO comando se comunica apenas com o servidor Motrix em execução, pela interface de loopback do contêiner.",
+ "help": "Uso:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n motrix-admin extension pair\n\nO comando se comunica apenas com o servidor Motrix em execução, pela interface de loopback do contêiner.",
"errorPrefix": "motrix-admin: {{message}}",
"usageHint": "Execute `motrix-admin --help` para ver as instruções de uso.",
"pending": {
@@ -55,6 +55,20 @@
"loopback": "O servidor Motrix em execução está indisponível na interface de loopback do contêiner.",
"approvalNotReady": "A aprovação de pareamento ainda não está pronta no servidor Motrix em execução."
}
+ },
+ "extension": {
+ "heading": "Pending browser Extension pairing requests",
+ "identityNotice": "Verify that you initiated this request. Origin and claimed identity alone do not prove who is connecting. Terminal recording can capture the pairing code.",
+ "row": "{{index}}. {{browser}} [{{identity}}] Origin: {{origin}}; claimed ID: {{claimedId}}; Server: {{authority}}; {{seconds}} s remaining",
+ "select": "Enter the number of one request (Ctrl+C to exit): ",
+ "code": "Pairing code: {{code}}",
+ "instructions": "Type this code into the browser Extension. It expires at the original deadline. Ctrl+C closes this view without approving or denying the request.",
+ "none": "No pending Extension pairing requests. Start pairing in the Extension, then run this command again. If requests remain absent, check the remote Extension configuration.",
+ "ended": "The selected pairing request has ended. Check the Extension for its outcome.",
+ "ttyRequired": "Extension pairing requires interactive input, output and error terminals. Piping, redirection and JSON output are not supported.",
+ "cancelled": "Pairing code view closed. No approval or denial was sent.",
+ "invalidSelection": "Select exactly one listed request by its number.",
+ "unavailable": "The selected request expired, ended or changed. Start a new pairing attempt in the Extension."
}
},
"common": {
diff --git a/src/shared/locales/ro.json b/src/shared/locales/ro.json
index ba075051..e2629584 100644
--- a/src/shared/locales/ro.json
+++ b/src/shared/locales/ro.json
@@ -374,13 +374,27 @@
"unknownOption": "Opțiune necunoscută a liniei de comandă."
}
},
- "help": "Utilizare:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n\nComanda comunică doar cu serverul Motrix activ, prin interfața loopback a containerului.",
+ "help": "Utilizare:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n motrix-admin extension pair\n\nComanda comunică doar cu serverul Motrix activ, prin interfața loopback a containerului.",
"pending": {
"none": "Nu există cereri de asociere în așteptare.",
"row": "{{userCode}} {{clientName}} {{clientVersion}} expiră în {{ttl}}",
"ttl": "{{minutes}}m {{seconds}}s"
},
- "usageHint": "Rulează `motrix-admin --help` pentru instrucțiuni de utilizare."
+ "usageHint": "Rulează `motrix-admin --help` pentru instrucțiuni de utilizare.",
+ "extension": {
+ "heading": "Pending browser Extension pairing requests",
+ "identityNotice": "Verify that you initiated this request. Origin and claimed identity alone do not prove who is connecting. Terminal recording can capture the pairing code.",
+ "row": "{{index}}. {{browser}} [{{identity}}] Origin: {{origin}}; claimed ID: {{claimedId}}; Server: {{authority}}; {{seconds}} s remaining",
+ "select": "Enter the number of one request (Ctrl+C to exit): ",
+ "code": "Pairing code: {{code}}",
+ "instructions": "Type this code into the browser Extension. It expires at the original deadline. Ctrl+C closes this view without approving or denying the request.",
+ "none": "No pending Extension pairing requests. Start pairing in the Extension, then run this command again. If requests remain absent, check the remote Extension configuration.",
+ "ended": "The selected pairing request has ended. Check the Extension for its outcome.",
+ "ttyRequired": "Extension pairing requires interactive input, output and error terminals. Piping, redirection and JSON output are not supported.",
+ "cancelled": "Pairing code view closed. No approval or denial was sent.",
+ "invalidSelection": "Select exactly one listed request by its number.",
+ "unavailable": "The selected request expired, ended or changed. Start a new pairing attempt in the Extension."
+ }
},
"operatorUnlock": {
"error": "Token de operator nevalid. Verifică MOTRIX_OPERATOR_TOKEN sau <dataDir>/operator-token pe gazdă și încearcă din nou.",
diff --git a/src/shared/locales/ru.json b/src/shared/locales/ru.json
index 89de36af..4003e65b 100644
--- a/src/shared/locales/ru.json
+++ b/src/shared/locales/ru.json
@@ -7,7 +7,7 @@
"submit": "Разблокировать"
},
"operatorAdmin": {
- "help": "Использование:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n\nКоманда взаимодействует только с запущенным сервером Motrix через интерфейс обратной петли контейнера.",
+ "help": "Использование:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n motrix-admin extension pair\n\nКоманда взаимодействует только с запущенным сервером Motrix через интерфейс обратной петли контейнера.",
"errorPrefix": "motrix-admin: {{message}}",
"usageHint": "Выполните `motrix-admin --help`, чтобы узнать, как использовать команду.",
"pending": {
@@ -55,6 +55,20 @@
"loopback": "Запущенный сервер Motrix недоступен через интерфейс обратной петли контейнера.",
"approvalNotReady": "Подтверждение сопряжения ещё не готово на запущенном сервере Motrix."
}
+ },
+ "extension": {
+ "heading": "Pending browser Extension pairing requests",
+ "identityNotice": "Verify that you initiated this request. Origin and claimed identity alone do not prove who is connecting. Terminal recording can capture the pairing code.",
+ "row": "{{index}}. {{browser}} [{{identity}}] Origin: {{origin}}; claimed ID: {{claimedId}}; Server: {{authority}}; {{seconds}} s remaining",
+ "select": "Enter the number of one request (Ctrl+C to exit): ",
+ "code": "Pairing code: {{code}}",
+ "instructions": "Type this code into the browser Extension. It expires at the original deadline. Ctrl+C closes this view without approving or denying the request.",
+ "none": "No pending Extension pairing requests. Start pairing in the Extension, then run this command again. If requests remain absent, check the remote Extension configuration.",
+ "ended": "The selected pairing request has ended. Check the Extension for its outcome.",
+ "ttyRequired": "Extension pairing requires interactive input, output and error terminals. Piping, redirection and JSON output are not supported.",
+ "cancelled": "Pairing code view closed. No approval or denial was sent.",
+ "invalidSelection": "Select exactly one listed request by its number.",
+ "unavailable": "The selected request expired, ended or changed. Start a new pairing attempt in the Extension."
}
},
"common": {
diff --git a/src/shared/locales/th.json b/src/shared/locales/th.json
index 07e29f5a..ef195989 100644
--- a/src/shared/locales/th.json
+++ b/src/shared/locales/th.json
@@ -372,13 +372,27 @@
"unknownOption": "ไม่รู้จักตัวเลือกบรรทัดคำสั่งนี้"
}
},
- "help": "วิธีใช้:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n\nคำสั่งนี้สื่อสารกับเซิร์ฟเวอร์ Motrix ที่กำลังทำงานอยู่ผ่านลูปแบ็กของคอนเทนเนอร์เท่านั้น",
+ "help": "วิธีใช้:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n motrix-admin extension pair\n\nคำสั่งนี้สื่อสารกับเซิร์ฟเวอร์ Motrix ที่กำลังทำงานอยู่ผ่านลูปแบ็กของคอนเทนเนอร์เท่านั้น",
"pending": {
"none": "ไม่มีคำขอจับคู่ที่รออยู่",
"row": "{{userCode}} {{clientName}} {{clientVersion}} หมดอายุใน {{ttl}}",
"ttl": "{{minutes}} นาที {{seconds}} วินาที"
},
- "usageHint": "เรียกใช้ `motrix-admin --help` เพื่อดูวิธีใช้"
+ "usageHint": "เรียกใช้ `motrix-admin --help` เพื่อดูวิธีใช้",
+ "extension": {
+ "heading": "Pending browser Extension pairing requests",
+ "identityNotice": "Verify that you initiated this request. Origin and claimed identity alone do not prove who is connecting. Terminal recording can capture the pairing code.",
+ "row": "{{index}}. {{browser}} [{{identity}}] Origin: {{origin}}; claimed ID: {{claimedId}}; Server: {{authority}}; {{seconds}} s remaining",
+ "select": "Enter the number of one request (Ctrl+C to exit): ",
+ "code": "Pairing code: {{code}}",
+ "instructions": "Type this code into the browser Extension. It expires at the original deadline. Ctrl+C closes this view without approving or denying the request.",
+ "none": "No pending Extension pairing requests. Start pairing in the Extension, then run this command again. If requests remain absent, check the remote Extension configuration.",
+ "ended": "The selected pairing request has ended. Check the Extension for its outcome.",
+ "ttyRequired": "Extension pairing requires interactive input, output and error terminals. Piping, redirection and JSON output are not supported.",
+ "cancelled": "Pairing code view closed. No approval or denial was sent.",
+ "invalidSelection": "Select exactly one listed request by its number.",
+ "unavailable": "The selected request expired, ended or changed. Start a new pairing attempt in the Extension."
+ }
},
"operatorUnlock": {
"error": "โทเค็นผู้ดูแลไม่ถูกต้อง ตรวจสอบ MOTRIX_OPERATOR_TOKEN หรือ <dataDir>/operator-token บนโฮสต์แล้วลองอีกครั้ง",
diff --git a/src/shared/locales/tr.json b/src/shared/locales/tr.json
index 6e4419b8..b2251683 100644
--- a/src/shared/locales/tr.json
+++ b/src/shared/locales/tr.json
@@ -7,7 +7,7 @@
"submit": "Kilidi aç"
},
"operatorAdmin": {
- "help": "Kullanım:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n\nKomut yalnızca çalışan Motrix sunucusuyla, kapsayıcının geri döngü bağlantısı üzerinden iletişim kurar.",
+ "help": "Kullanım:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n motrix-admin extension pair\n\nKomut yalnızca çalışan Motrix sunucusuyla, kapsayıcının geri döngü bağlantısı üzerinden iletişim kurar.",
"errorPrefix": "motrix-admin: {{message}}",
"usageHint": "Kullanım bilgisi için `motrix-admin --help` komutunu çalıştırın.",
"pending": {
@@ -55,6 +55,20 @@
"loopback": "Çalışan Motrix sunucusuna kapsayıcının geri döngü bağlantısından ulaşılamıyor.",
"approvalNotReady": "Çalışan Motrix sunucusunda eşleştirme onayı henüz hazır değil."
}
+ },
+ "extension": {
+ "heading": "Pending browser Extension pairing requests",
+ "identityNotice": "Verify that you initiated this request. Origin and claimed identity alone do not prove who is connecting. Terminal recording can capture the pairing code.",
+ "row": "{{index}}. {{browser}} [{{identity}}] Origin: {{origin}}; claimed ID: {{claimedId}}; Server: {{authority}}; {{seconds}} s remaining",
+ "select": "Enter the number of one request (Ctrl+C to exit): ",
+ "code": "Pairing code: {{code}}",
+ "instructions": "Type this code into the browser Extension. It expires at the original deadline. Ctrl+C closes this view without approving or denying the request.",
+ "none": "No pending Extension pairing requests. Start pairing in the Extension, then run this command again. If requests remain absent, check the remote Extension configuration.",
+ "ended": "The selected pairing request has ended. Check the Extension for its outcome.",
+ "ttyRequired": "Extension pairing requires interactive input, output and error terminals. Piping, redirection and JSON output are not supported.",
+ "cancelled": "Pairing code view closed. No approval or denial was sent.",
+ "invalidSelection": "Select exactly one listed request by its number.",
+ "unavailable": "The selected request expired, ended or changed. Start a new pairing attempt in the Extension."
}
},
"common": {
diff --git a/src/shared/locales/uk.json b/src/shared/locales/uk.json
index 9eb096cf..61d8ead5 100644
--- a/src/shared/locales/uk.json
+++ b/src/shared/locales/uk.json
@@ -375,13 +375,27 @@
"unknownOption": "Невідомий параметр командного рядка."
}
},
- "help": "Використання:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n\nКоманда звертається лише до запущеного сервера Motrix через петльовий інтерфейс контейнера.",
+ "help": "Використання:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n motrix-admin extension pair\n\nКоманда звертається лише до запущеного сервера Motrix через петльовий інтерфейс контейнера.",
"pending": {
"none": "Немає запитів на сполучення, що очікують рішення.",
"row": "{{userCode}} {{clientName}} {{clientVersion}} спливає через {{ttl}}",
"ttl": "{{minutes}} хв {{seconds}} с"
},
- "usageHint": "Виконайте `motrix-admin --help`, щоб переглянути довідку."
+ "usageHint": "Виконайте `motrix-admin --help`, щоб переглянути довідку.",
+ "extension": {
+ "heading": "Pending browser Extension pairing requests",
+ "identityNotice": "Verify that you initiated this request. Origin and claimed identity alone do not prove who is connecting. Terminal recording can capture the pairing code.",
+ "row": "{{index}}. {{browser}} [{{identity}}] Origin: {{origin}}; claimed ID: {{claimedId}}; Server: {{authority}}; {{seconds}} s remaining",
+ "select": "Enter the number of one request (Ctrl+C to exit): ",
+ "code": "Pairing code: {{code}}",
+ "instructions": "Type this code into the browser Extension. It expires at the original deadline. Ctrl+C closes this view without approving or denying the request.",
+ "none": "No pending Extension pairing requests. Start pairing in the Extension, then run this command again. If requests remain absent, check the remote Extension configuration.",
+ "ended": "The selected pairing request has ended. Check the Extension for its outcome.",
+ "ttyRequired": "Extension pairing requires interactive input, output and error terminals. Piping, redirection and JSON output are not supported.",
+ "cancelled": "Pairing code view closed. No approval or denial was sent.",
+ "invalidSelection": "Select exactly one listed request by its number.",
+ "unavailable": "The selected request expired, ended or changed. Start a new pairing attempt in the Extension."
+ }
},
"operatorUnlock": {
"error": "Некоректний токен оператора. Перевірте MOTRIX_OPERATOR_TOKEN або <dataDir>/operator-token на хості та спробуйте ще раз.",
diff --git a/src/shared/locales/vi.json b/src/shared/locales/vi.json
index 828e6fd3..38386669 100644
--- a/src/shared/locales/vi.json
+++ b/src/shared/locales/vi.json
@@ -7,7 +7,7 @@
"submit": "Mở khóa"
},
"operatorAdmin": {
- "help": "Cách dùng:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n\nLệnh chỉ giao tiếp với máy chủ Motrix đang chạy qua địa chỉ loopback của container.",
+ "help": "Cách dùng:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n motrix-admin extension pair\n\nLệnh chỉ giao tiếp với máy chủ Motrix đang chạy qua địa chỉ loopback của container.",
"errorPrefix": "motrix-admin: {{message}}",
"usageHint": "Chạy `motrix-admin --help` để xem cách dùng.",
"pending": {
@@ -55,6 +55,20 @@
"loopback": "Không thể truy cập máy chủ Motrix đang chạy qua địa chỉ loopback của container.",
"approvalNotReady": "Chức năng chấp thuận ghép đôi trên máy chủ Motrix đang chạy chưa sẵn sàng."
}
+ },
+ "extension": {
+ "heading": "Pending browser Extension pairing requests",
+ "identityNotice": "Verify that you initiated this request. Origin and claimed identity alone do not prove who is connecting. Terminal recording can capture the pairing code.",
+ "row": "{{index}}. {{browser}} [{{identity}}] Origin: {{origin}}; claimed ID: {{claimedId}}; Server: {{authority}}; {{seconds}} s remaining",
+ "select": "Enter the number of one request (Ctrl+C to exit): ",
+ "code": "Pairing code: {{code}}",
+ "instructions": "Type this code into the browser Extension. It expires at the original deadline. Ctrl+C closes this view without approving or denying the request.",
+ "none": "No pending Extension pairing requests. Start pairing in the Extension, then run this command again. If requests remain absent, check the remote Extension configuration.",
+ "ended": "The selected pairing request has ended. Check the Extension for its outcome.",
+ "ttyRequired": "Extension pairing requires interactive input, output and error terminals. Piping, redirection and JSON output are not supported.",
+ "cancelled": "Pairing code view closed. No approval or denial was sent.",
+ "invalidSelection": "Select exactly one listed request by its number.",
+ "unavailable": "The selected request expired, ended or changed. Start a new pairing attempt in the Extension."
}
},
"common": {
diff --git a/src/shared/locales/zh-CN.json b/src/shared/locales/zh-CN.json
index 9650e948..bc9a2a82 100644
--- a/src/shared/locales/zh-CN.json
+++ b/src/shared/locales/zh-CN.json
@@ -7,7 +7,7 @@
"submit": "解锁"
},
"operatorAdmin": {
- "help": "用法:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <配对码> [--json]\n motrix-admin pairing deny <配对码> [--json]\n\n此命令仅通过容器内的本机回环地址与正在运行的 Motrix 服务器通信。",
+ "help": "用法:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <配对码> [--json]\n motrix-admin pairing deny <配对码> [--json]\n motrix-admin extension pair\n\n此命令仅通过容器内的本机回环地址与正在运行的 Motrix 服务器通信。",
"errorPrefix": "motrix-admin:{{message}}",
"usageHint": "运行 `motrix-admin --help` 查看用法。",
"pending": {
@@ -55,6 +55,20 @@
"loopback": "无法通过容器内的本机回环地址连接正在运行的 Motrix 服务器。",
"approvalNotReady": "正在运行的 Motrix 服务器尚未准备好配对审批。"
}
+ },
+ "extension": {
+ "heading": "待处理的浏览器扩展配对请求",
+ "identityNotice": "请核对这是你刚发起的请求。Origin 和自报身份不能单独证明连接方身份。终端录制可能记录配对码。",
+ "row": "{{index}}. {{browser}} [{{identity}}] 来源:{{origin}};自报 ID:{{claimedId}};服务端:{{authority}};剩余 {{seconds}} 秒",
+ "select": "输入一个请求的序号(Ctrl+C 退出):",
+ "code": "配对码:{{code}}",
+ "instructions": "将此配对码输入浏览器扩展,有效期不会延长。Ctrl+C 仅关闭此视图,不批准或拒绝请求。",
+ "none": "没有待处理的扩展配对请求。请先在扩展中发起配对,再运行此命令。如果仍无请求,请检查远程扩展配置。",
+ "ended": "所选配对请求已结束,请在扩展中确认结果。",
+ "ttyRequired": "扩展配对要求输入、输出及错误输出均为交互终端,不支持管道、重定向或 JSON 输出。",
+ "cancelled": "已关闭配对码视图,未发送批准或拒绝操作。",
+ "invalidSelection": "请通过序号选择一个列表中的请求。",
+ "unavailable": "所选请求已过期、结束或发生变化,请在扩展中重新发起配对。"
}
},
"common": {
diff --git a/src/shared/locales/zh-TW.json b/src/shared/locales/zh-TW.json
index e474923f..80727051 100644
--- a/src/shared/locales/zh-TW.json
+++ b/src/shared/locales/zh-TW.json
@@ -7,7 +7,7 @@
"submit": "解鎖"
},
"operatorAdmin": {
- "help": "用法:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n\n此命令只會透過容器 loopback 與正在執行的 Motrix 伺服器通訊。",
+ "help": "用法:\n motrix-admin pairing pending [--json]\n motrix-admin pairing approve <user-code> [--json]\n motrix-admin pairing deny <user-code> [--json]\n motrix-admin extension pair\n\n此命令只會透過容器 loopback 與正在執行的 Motrix 伺服器通訊。",
"errorPrefix": "motrix-admin: {{message}}",
"usageHint": "執行「motrix-admin --help」查看用法。",
"pending": {
@@ -55,6 +55,20 @@
"loopback": "無法透過容器 loopback 連線至正在執行的 Motrix 伺服器。",
"approvalNotReady": "正在執行的 Motrix 伺服器尚未準備好核准配對。"
}
+ },
+ "extension": {
+ "heading": "待處理的瀏覽器擴充功能配對請求",
+ "identityNotice": "請核對這是你剛發起的請求。Origin 和自報身分不能單獨證明連線方身分。終端錄製可能記錄配對碼。",
+ "row": "{{index}}. {{browser}} [{{identity}}] 來源:{{origin}};自報 ID:{{claimedId}};伺服器:{{authority}};剩餘 {{seconds}} 秒",
+ "select": "輸入一個請求的序號(Ctrl+C 結束):",
+ "code": "配對碼:{{code}}",
+ "instructions": "將此配對碼輸入瀏覽器擴充功能,有效期限不會延長。Ctrl+C 僅關閉此檢視,不核准或拒絕請求。",
+ "none": "沒有待處理的擴充功能配對請求。請先在擴充功能中發起配對,再執行此命令。如果仍無請求,請檢查遠端擴充功能設定。",
+ "ended": "所選配對請求已結束,請在擴充功能中確認結果。",
+ "ttyRequired": "擴充功能配對要求輸入、輸出及錯誤輸出均為互動式終端,不支援管線、重新導向或 JSON 輸出。",
+ "cancelled": "已關閉配對碼檢視,未傳送核准或拒絕操作。",
+ "invalidSelection": "請透過序號選擇一個清單中的請求。",
+ "unavailable": "所選請求已過期、結束或發生變化,請在擴充功能中重新發起配對。"
}
},
"common": {