@linxin666/dsh-remote-bridge 0.0.0-stage → 0.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/LICENSE +202 -0
  2. package/README.i18n.yaml +6 -0
  3. package/README.md +277 -2
  4. package/README.zh.md +276 -0
  5. package/cordis.patch.yml +17 -0
  6. package/icon.svg +3 -0
  7. package/lib/client.js +1830 -0
  8. package/lib/client.js.map +1 -0
  9. package/lib/index.js +5789 -0
  10. package/lib/types/client/PairEntry.d.ts +16 -0
  11. package/lib/types/client/PairPanel.d.ts +55 -0
  12. package/lib/types/client/icons.d.ts +18 -0
  13. package/lib/types/client/index.d.ts +35 -0
  14. package/lib/types/client/locales.d.ts +42 -0
  15. package/lib/types/client/pair-token.d.ts +73 -0
  16. package/lib/types/client/semantic.d.ts +28 -0
  17. package/lib/types/core/approvals.d.ts +99 -0
  18. package/lib/types/core/connection.d.ts +170 -0
  19. package/lib/types/core/crypto.d.ts +48 -0
  20. package/lib/types/core/delta.d.ts +101 -0
  21. package/lib/types/core/devices.d.ts +72 -0
  22. package/lib/types/core/dsh-frames.d.ts +332 -0
  23. package/lib/types/core/envelope.d.ts +132 -0
  24. package/lib/types/core/extension.d.ts +144 -0
  25. package/lib/types/core/gateway-errors.d.ts +49 -0
  26. package/lib/types/core/hub.d.ts +127 -0
  27. package/lib/types/core/jobs.d.ts +204 -0
  28. package/lib/types/core/loopback.d.ts +35 -0
  29. package/lib/types/core/owner-peer.d.ts +49 -0
  30. package/lib/types/core/pairing.d.ts +61 -0
  31. package/lib/types/core/protocol.d.ts +319 -0
  32. package/lib/types/core/questions.d.ts +294 -0
  33. package/lib/types/core/session-meta.d.ts +105 -0
  34. package/lib/types/core/session-permissions.d.ts +134 -0
  35. package/lib/types/core/wire.d.ts +115 -0
  36. package/lib/types/core/ws-frames.d.ts +72 -0
  37. package/lib/types/host/dsh-home.d.ts +16 -0
  38. package/lib/types/host/pair-origin.d.ts +44 -0
  39. package/lib/types/host/routes.d.ts +27 -0
  40. package/lib/types/host/websocket.d.ts +111 -0
  41. package/lib/types/index.d.ts +55 -0
  42. package/lib/types/mount-once.d.ts +55 -0
  43. package/locale/en.json +6 -0
  44. package/locale/ru.json +6 -0
  45. package/locale/zh.json +6 -0
  46. package/package.json +93 -3
  47. package/src/client/PairEntry.tsx +151 -0
  48. package/src/client/PairPanel.tsx +183 -0
  49. package/src/client/icons.tsx +72 -0
  50. package/src/client/index.ts +81 -0
  51. package/src/client/locales.ts +72 -0
  52. package/src/client/pair-token.ts +104 -0
  53. package/src/client/panel.module.css +344 -0
  54. package/src/client/semantic.ts +37 -0
  55. package/src/core/approvals.ts +173 -0
  56. package/src/core/connection.ts +1906 -0
  57. package/src/core/crypto.ts +113 -0
  58. package/src/core/delta.ts +204 -0
  59. package/src/core/devices.ts +209 -0
  60. package/src/core/dsh-frames.ts +843 -0
  61. package/src/core/envelope.ts +219 -0
  62. package/src/core/extension.ts +197 -0
  63. package/src/core/gateway-errors.ts +92 -0
  64. package/src/core/hub.ts +310 -0
  65. package/src/core/jobs.ts +372 -0
  66. package/src/core/loopback.ts +60 -0
  67. package/src/core/owner-peer.ts +70 -0
  68. package/src/core/pairing.ts +113 -0
  69. package/src/core/protocol.ts +381 -0
  70. package/src/core/questions.ts +630 -0
  71. package/src/core/session-meta.ts +176 -0
  72. package/src/core/session-permissions.ts +266 -0
  73. package/src/core/wire.ts +159 -0
  74. package/src/core/ws-frames.ts +139 -0
  75. package/src/css-modules.d.ts +6 -0
  76. package/src/host/dsh-home.ts +42 -0
  77. package/src/host/pair-origin.ts +77 -0
  78. package/src/host/routes.ts +85 -0
  79. package/src/host/websocket.ts +359 -0
  80. package/src/index.ts +257 -0
  81. package/src/mount-once.ts +142 -0
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Protocol v1 pairing panel — browser half. Registers the `remote-bridge`
3
+ * dictionary and the sidebar-foot trigger (into the ui-sidebar-declared
4
+ * `sidebar.footer.action` list slot) that opens the panel showing this
5
+ * package's own one-shot bootstrap token as a QR symbol plus its plaintext.
6
+ *
7
+ * The panel is display-only for the native path: it reads the same loopback-only
8
+ * `GET /remote-bridge/pair/token` route an operator would curl, and never spends
9
+ * the token (`pair.begin` stays the phone's call). The browser half therefore
10
+ * adds no wire surface — the envelope, the method names, the topic names and
11
+ * the events are untouched — and it does not touch `dsh-remote-web-ui`'s pairing
12
+ * service, its roster, or its browser cookie path.
13
+ *
14
+ * Export discipline (packages/AGENTS.md): the /client surface carries only what
15
+ * cordis loading needs plus types.
16
+ */
17
+ import type { Context as ClientContext } from '@deepseek-ai/cordis'
18
+ // Type-only: pulls the locale plugin's Context merge (ctx.locale) and its
19
+ // LocaleNamespaceMap merge table.
20
+ import type {} from '@deepseek-ai/dsh-client-locale/client'
21
+ // Type-only: pulls the ctx.slots merge (the renderer owns the slot registry).
22
+ import type {} from '@deepseek-ai/dsh-client-ui-renderer/client'
23
+ // Type-only: pulls the ui-sidebar SlotMap merge (the 'sidebar.footer.action' hole).
24
+ import type {} from '@deepseek-ai/dsh-client-ui-sidebar/client'
25
+ import { writeClipboard } from '@deepseek-ai/dsh-client-ui-primitives'
26
+ import { PairEntry } from './PairEntry.tsx'
27
+ import { readPairToken } from './pair-token.ts'
28
+ import { en, zh, type RemoteBridgeKey } from './locales.ts'
29
+
30
+ declare module '@deepseek-ai/dsh-client-ui-slots' {
31
+ interface LocaleNamespaceMap {
32
+ /** Protocol v1 pairing panel copy. */
33
+ 'remote-bridge': RemoteBridgeKey
34
+ }
35
+ }
36
+
37
+ /** Dictionary namespace owned by this plugin. */
38
+ const NS = 'remote-bridge'
39
+
40
+ /** Unique occupant id inside the shared footer.action list slot. */
41
+ const ENTRY_ID = 'remote-bridge'
42
+
43
+ /** Services required by this plugin. */
44
+ export const inject = ['slots', 'locale']
45
+
46
+ /**
47
+ * Register the protocol v1 pairing surface.
48
+ * @param ctx - client root context.
49
+ */
50
+ export function apply(ctx: ClientContext): void {
51
+ ctx.effect(() => {
52
+ try {
53
+ return ctx.locale.register(NS, { zh, en })
54
+ } catch {
55
+ return () => {}
56
+ }
57
+ }, 'remote-bridge: dictionaries')
58
+
59
+ // Sidebar foot entry. The shell declares 'sidebar.footer.action' (list kind:
60
+ // multiple occupants may share the seat) and registration is
61
+ // declaration-aware via slots.inject. Read and clipboard arrive as an
62
+ // injected face rather than a module import, which keeps the trigger's
63
+ // rendered tree free of closure-factory bundles.
64
+ ctx.slots.inject('sidebar.footer.action', () => {
65
+ try {
66
+ return ctx.slots.register({
67
+ name: 'sidebar.footer.action',
68
+ id: ENTRY_ID,
69
+ locale: NS,
70
+ inject: () => ({ read: readPairToken, copy: writeClipboard }),
71
+ }, PairEntry)
72
+ } catch {
73
+ return () => {}
74
+ }
75
+ })
76
+ }
77
+
78
+ export type { PairEntryProps } from './PairEntry.tsx'
79
+ export type { PairCopyState, PairPanelProps, PairPanelState } from './PairPanel.tsx'
80
+ export type { PairTokenFetch, PairTokenOutcome, PairTokenResponse, ReadPairTokenOptions } from './pair-token.ts'
81
+ export type { RemoteBridgeKey } from './locales.ts'
@@ -0,0 +1,72 @@
1
+ /**
2
+ * `remote-bridge` namespace dictionaries: the protocol v1 pairing panel copy.
3
+ *
4
+ * The panel has one job — show the operator the one-shot bootstrap token as a
5
+ * QR symbol plus its plaintext — so the copy is dominated by the two facts a
6
+ * reader has to get right: where the phone's origin points (the public relay,
7
+ * never this machine's loopback address) and why the token vanished (30 s, one
8
+ * use, or a fresh mint).
9
+ */
10
+
11
+ /** Simplified Chinese dictionary (the key-set source of truth). */
12
+ export const zh = {
13
+ 'entry.label': '配对手机(协议 v1)',
14
+ 'title': '协议 v1 配对',
15
+ 'subtitle': '用手机 App 扫描下方二维码,即可以协议 v1 配对这台宿主。配对码由本机签发,仅在本机可读。',
16
+ 'state.reading': '正在取配对码…',
17
+ 'pair.qrLabel': '配对二维码',
18
+ 'pair.payloadLabel': '二维码内容(可复制后粘贴到手机)',
19
+ 'pair.countdown': '剩余 {s} 秒',
20
+ 'pair.expired': '配对码已过期(30 秒)',
21
+ 'pair.expiredHint': '过期的配对码不会被手机接受,请重新取码。',
22
+ 'pair.usedHint': '配对码一次性:手机调用 pair.begin 的瞬间即作废,重新取码也会作废上一张。',
23
+ 'pair.refresh': '重新取码',
24
+ 'origin.title': '没能自动定位公网地址,二维码只装裸配对码',
25
+ 'origin.body': '这台机器既没有 DSH_REMOTE_PUBLIC_BASE_URL,也没有中继注册表记录,因此无法把地址写进二维码。请先在手机 App 里把连接地址设成你的公网中继(形如 wss://<id>.dsh-market.com),再扫上面的码;本页所在的 {host} 只有本机能连,手机连不上。',
26
+ 'origin.located.title': '手机将直接连到公网中继(地址已写进二维码)',
27
+ 'origin.located.body': '二维码里已经带上 {origin}:手机扫一次就同时设好连接地址与配对码,不需要手填任何东西。',
28
+ 'forbidden.title': '这个页面不是从本机打开的',
29
+ 'forbidden.body': '配对码只能在本机 Web UI 上取。请在本机浏览器打开 http://127.0.0.1:<端口> 后重试。',
30
+ 'failed.title': '取配对码失败',
31
+ 'failed.body': '宿主返回了 HTTP {status},请刷新页面后重试。',
32
+ 'unreachable.title': '无法连接本机宿主',
33
+ 'unreachable.body': '请求没有到达宿主,请确认 dsh web 仍在运行后重试。',
34
+ 'action.close': '关闭',
35
+ 'action.copy': '复制配对码',
36
+ 'action.copied': '已复制',
37
+ 'action.copyFailed': '复制失败',
38
+ 'action.retry': '重试',
39
+ } as const
40
+
41
+ /** English dictionary, key-for-key with the zh source. */
42
+ export const en: Record<RemoteBridgeKey, string> = {
43
+ 'entry.label': 'Pair a phone (protocol v1)',
44
+ 'title': 'Protocol v1 pairing',
45
+ 'subtitle': 'Scan the QR code with the phone app to pair it with this host over protocol v1. The code is minted by this machine and only readable here.',
46
+ 'state.reading': 'Requesting a pairing code…',
47
+ 'pair.qrLabel': 'Pairing QR code',
48
+ 'pair.payloadLabel': 'What the QR encodes (copy it to paste on the phone)',
49
+ 'pair.countdown': '{s} s left',
50
+ 'pair.expired': 'The pairing code expired (30 s)',
51
+ 'pair.expiredHint': 'An expired code is never accepted; request a new one.',
52
+ 'pair.usedHint': 'The code is single-use: the phone spends it the moment it calls pair.begin, and requesting a new one voids the previous code.',
53
+ 'pair.refresh': 'New code',
54
+ 'origin.title': 'No public address could be located, so the QR carries the bare code',
55
+ 'origin.body': 'This machine has neither DSH_REMOTE_PUBLIC_BASE_URL nor a relay registry row, so the address cannot go into the QR. Set the phone app to your public relay first (such as wss://<id>.dsh-market.com), then scan the code above; {host} (this page) is reachable only from this machine and never from the phone.',
56
+ 'origin.located.title': 'The phone dials the public relay directly (address is in the QR)',
57
+ 'origin.located.body': 'The QR carries {origin}: one scan sets both the connection address and the pairing code, with nothing to type.',
58
+ 'forbidden.title': 'This page is not open on this machine',
59
+ 'forbidden.body': 'Pairing codes can only be read from the machine itself. Open http://127.0.0.1:<port> in a browser on this machine and retry.',
60
+ 'failed.title': 'Could not read a pairing code',
61
+ 'failed.body': 'The host answered HTTP {status}. Reload the page and retry.',
62
+ 'unreachable.title': 'Cannot reach the local host',
63
+ 'unreachable.body': 'The request never reached the host. Check that dsh web is still running and retry.',
64
+ 'action.close': 'Close',
65
+ 'action.copy': 'Copy pairing code',
66
+ 'action.copied': 'Copied',
67
+ 'action.copyFailed': 'Copy failed',
68
+ 'action.retry': 'Retry',
69
+ }
70
+
71
+ /** Every key the `remote-bridge` namespace carries. */
72
+ export type RemoteBridgeKey = keyof typeof zh
@@ -0,0 +1,104 @@
1
+ /**
2
+ * The panel's one wire call: read the one-shot bootstrap token from this
3
+ * package's own Host route.
4
+ *
5
+ * The route is same-origin and document-relative (the GUI is served with
6
+ * `<base href="./">`, so a sub-path deployment resolves it against its entry
7
+ * directory instead of escaping to the origin root — the same rule
8
+ * `dsh-remote-web-ui`'s pair API follows). It is NOT consumed here: the panel
9
+ * only displays the secret, and the phone spends it in `pair.begin`, so a
10
+ * mis-click on "new code" voids a token without ever pairing a device.
11
+ *
12
+ * `403` is a fact, not an error: the loopback gate in `core/loopback.ts`
13
+ * refuses any page whose socket or `Host` is not this machine, which is exactly
14
+ * the case the panel must name out loud.
15
+ * @module dsh-remote-bridge/client/pair-token
16
+ */
17
+
18
+ import { PAIR_TOKEN_PATH } from '../core/protocol.ts'
19
+
20
+ /** Document-relative form of the Host route, for a page served under any base. */
21
+ export const PAIR_TOKEN_URL = PAIR_TOKEN_PATH.replace(/^\/+/, '')
22
+
23
+ /** The outcome of one token read. */
24
+ export type PairTokenOutcome =
25
+ /**
26
+ * A live one-shot token and the instant it stops being accepted, plus the
27
+ * address half when this machine can name its own public origin. `pairingUrl`
28
+ * is the code a QR should carry: a `{token, url}` document the phone parses
29
+ * into both halves of its configuration.
30
+ */
31
+ | { kind: 'ok'; token: string; expiresAt: number; origin: string | null; pairingUrl: string | null }
32
+ /** 403: the page is not open on the machine itself, so the loopback gate refused it. */
33
+ | { kind: 'forbidden' }
34
+ /** The route answered with a status the panel does not know, or with a body that is not a token. */
35
+ | { kind: 'failed'; status: number }
36
+ /** The request never reached the host (offline, host stopped, connection reset). */
37
+ | { kind: 'unreachable' }
38
+
39
+ /** The minimal response surface the reader uses, so a test can inject its own. */
40
+ export interface PairTokenResponse {
41
+ readonly ok: boolean
42
+ readonly status: number
43
+ json(): Promise<unknown>
44
+ }
45
+
46
+ /** The minimal fetch surface the reader uses, so a test can inject its own. */
47
+ export type PairTokenFetch = (url: string, init: { signal?: AbortSignal; cache: string }) => Promise<PairTokenResponse>
48
+
49
+ export interface ReadPairTokenOptions {
50
+ /** Injected transport; defaults to the global fetch. */
51
+ readonly fetchImpl?: PairTokenFetch
52
+ /** Aborts an in-flight read (the panel closed, the entry unmounted). */
53
+ readonly signal?: AbortSignal
54
+ }
55
+
56
+ /** Read a string field, treating a missing, mistyped or empty value as absent. */
57
+ function stringOrNull(value: unknown): string | null {
58
+ return typeof value === 'string' && value !== '' ? value : null
59
+ }
60
+
61
+ /**
62
+ * Read one bootstrap token.
63
+ *
64
+ * Never throws: every failure is one of the outcome arms, because the panel has
65
+ * to render each of them. A `200` whose body is not `{token, expiresAt}` is
66
+ * reported as a failure rather than shown as an empty QR.
67
+ * @param options - injected transport and abort signal.
68
+ * @returns the read outcome.
69
+ */
70
+ export async function readPairToken(options: ReadPairTokenOptions = {}): Promise<PairTokenOutcome> {
71
+ const send = options.fetchImpl ?? (globalThis.fetch as unknown as PairTokenFetch | undefined)
72
+ if (send === undefined) return { kind: 'unreachable' }
73
+ let response: PairTokenResponse
74
+ try {
75
+ response = await send(PAIR_TOKEN_URL, {
76
+ cache: 'no-store',
77
+ ...(options.signal === undefined ? {} : { signal: options.signal }),
78
+ })
79
+ } catch {
80
+ // A network failure and an aborted read are indistinguishable here, and
81
+ // both mean "no token arrived" — the panel says so instead of guessing.
82
+ return { kind: 'unreachable' }
83
+ }
84
+ if (response.status === 403) return { kind: 'forbidden' }
85
+ if (!response.ok) return { kind: 'failed', status: response.status }
86
+ let body: unknown
87
+ try {
88
+ body = await response.json()
89
+ } catch {
90
+ return { kind: 'failed', status: response.status }
91
+ }
92
+ if (typeof body !== 'object' || body === null) return { kind: 'failed', status: response.status }
93
+ const token = (body as { token?: unknown }).token
94
+ const expiresAt = (body as { expiresAt?: unknown }).expiresAt
95
+ if (typeof token !== 'string' || token === '') return { kind: 'failed', status: response.status }
96
+ if (typeof expiresAt !== 'number' || !Number.isFinite(expiresAt)) return { kind: 'failed', status: response.status }
97
+ // Additive fields: a host that predates origin discovery answers without
98
+ // them, and the panel then falls back to the bare-token code instead of
99
+ // refusing to show anything.
100
+ const origin = stringOrNull((body as { origin?: unknown }).origin)
101
+ const candidate = stringOrNull((body as { pairingUrl?: unknown }).pairingUrl)
102
+ const pairingUrl = candidate !== null && /^wss?:\/\/\S+$/.test(candidate) ? candidate : null
103
+ return { kind: 'ok', token, expiresAt, origin, pairingUrl }
104
+ }
@@ -0,0 +1,344 @@
1
+ /* Protocol v1 pairing panel: the sidebar-foot trigger plus the QR modal.
2
+ Design tokens only — no literal colors. The modal follows the family's
3
+ centered overlay + card contract (mask, 24px radius, layer-2 surface). */
4
+
5
+ /* ── Sidebar foot trigger ── */
6
+
7
+ .trigger {
8
+ position: relative;
9
+ flex: none;
10
+ display: inline-flex;
11
+ align-items: center;
12
+ justify-content: center;
13
+ width: 36px;
14
+ height: 36px;
15
+ border: none;
16
+ border-radius: 50%;
17
+ padding: 0;
18
+ background: transparent;
19
+ color: var(--dsw-alias-label-secondary);
20
+ cursor: pointer;
21
+ /* Ahead of the update/remote stack in the shared footer-action seat. */
22
+ order: -1;
23
+ transition: background-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
24
+ }
25
+
26
+ .trigger:hover:not(:disabled) {
27
+ background: var(--dsw-alias-interactive-bg-hover);
28
+ color: var(--dsw-alias-label-primary);
29
+ }
30
+
31
+ .trigger:active:not(:disabled) {
32
+ background: var(--dsw-alias-interactive-bg-active);
33
+ }
34
+
35
+ .trigger:focus-visible {
36
+ outline: none;
37
+ box-shadow: 0 0 0 2px var(--dsw-alias-bg-layer-2), 0 0 0 4px var(--dsw-alias-brand-primary);
38
+ }
39
+
40
+ /* ── Rail seat geometry (official-shell compatibility) ──
41
+
42
+ The shell renders `sidebar.footer.action` as a centered horizontal row, so
43
+ this trigger is the third occupant of a seat the 56px rail cannot widen. In
44
+ rail mode stack the seat vertically, keeping every occupant in the 36px
45
+ column the shell uses elsewhere. The selector carries no class names (they
46
+ stay global under CSS Modules) and matches only a seat that actually holds
47
+ this trigger. */
48
+ [class*='footerActions']:has([data-dsh-plugin='remote-bridge'][data-wide='rail']) {
49
+ flex-direction: column;
50
+ align-items: center;
51
+ gap: 4px;
52
+ }
53
+
54
+ /* ── Centered modal ── */
55
+
56
+ .overlay {
57
+ position: fixed;
58
+ inset: 0;
59
+ z-index: 1000;
60
+ display: flex;
61
+ align-items: center;
62
+ justify-content: center;
63
+ }
64
+
65
+ .mask {
66
+ position: absolute;
67
+ inset: 0;
68
+ background: var(--dsw-alias-bg-mask-1);
69
+ backdrop-filter: var(--dsw-mask-blur);
70
+ }
71
+
72
+ .panel {
73
+ position: relative;
74
+ z-index: 1;
75
+ display: flex;
76
+ flex-direction: column;
77
+ gap: 14px;
78
+ box-sizing: border-box;
79
+ width: 460px;
80
+ max-width: calc(100vw - 48px);
81
+ max-height: calc(100vh - 48px);
82
+ overflow: auto;
83
+ padding: 24px;
84
+ border-radius: 24px;
85
+ background: var(--dsw-alias-bg-layer-2);
86
+ box-shadow: var(--dsw-shadow-lv3);
87
+ color: var(--dsw-alias-label-primary);
88
+ font-size: 14px;
89
+ line-height: 22px;
90
+ }
91
+
92
+ .header {
93
+ display: flex;
94
+ align-items: flex-start;
95
+ gap: 12px;
96
+ }
97
+
98
+ .heading {
99
+ flex: 1;
100
+ min-width: 0;
101
+ }
102
+
103
+ .title {
104
+ margin: 0;
105
+ font-size: 18px;
106
+ font-weight: 600;
107
+ line-height: 26px;
108
+ }
109
+
110
+ .subtitle {
111
+ margin: 4px 0 0;
112
+ color: var(--dsw-alias-label-secondary);
113
+ font-size: 13px;
114
+ line-height: 20px;
115
+ }
116
+
117
+ .closeButton {
118
+ flex: none;
119
+ display: inline-flex;
120
+ align-items: center;
121
+ justify-content: center;
122
+ width: 28px;
123
+ height: 28px;
124
+ border: none;
125
+ border-radius: 8px;
126
+ padding: 0;
127
+ background: transparent;
128
+ color: var(--dsw-alias-label-secondary);
129
+ cursor: pointer;
130
+ transition: background-color 120ms ease, color 120ms ease;
131
+ }
132
+
133
+ .closeButton:hover {
134
+ background: var(--dsw-alias-interactive-bg-hover);
135
+ color: var(--dsw-alias-label-primary);
136
+ }
137
+
138
+ .closeButton:focus-visible {
139
+ outline: none;
140
+ box-shadow: 0 0 0 2px var(--dsw-alias-bg-layer-2), 0 0 0 4px var(--dsw-alias-brand-primary);
141
+ }
142
+
143
+ /* ── QR card ── */
144
+
145
+ .qrCard {
146
+ display: flex;
147
+ flex-direction: column;
148
+ align-items: center;
149
+ gap: 10px;
150
+ padding: 18px;
151
+ border: 1px solid var(--dsw-alias-border-l2);
152
+ border-radius: 16px;
153
+ background: var(--dsw-alias-bg-layer-1);
154
+ }
155
+
156
+ /* No background of its own: QRCodeSVG paints its full-size white quiet zone
157
+ itself (its default bgColor), so the symbol keeps scanner contrast in either
158
+ theme and this wrapper adds no literal colour. */
159
+ .qrWrap {
160
+ display: flex;
161
+ align-items: center;
162
+ justify-content: center;
163
+ }
164
+
165
+ .qr {
166
+ display: block;
167
+ width: 184px;
168
+ height: 184px;
169
+ }
170
+
171
+ .countdown {
172
+ display: flex;
173
+ flex-direction: column;
174
+ align-items: center;
175
+ gap: 6px;
176
+ width: 100%;
177
+ }
178
+
179
+ .countdownText {
180
+ color: var(--dsw-alias-label-secondary);
181
+ font-size: 13px;
182
+ line-height: 18px;
183
+ font-variant-numeric: tabular-nums;
184
+ }
185
+
186
+ .bar {
187
+ display: block;
188
+ width: 100%;
189
+ height: 4px;
190
+ overflow: hidden;
191
+ border-radius: 999px;
192
+ background: var(--dsw-alias-interactive-bg-hover);
193
+ }
194
+
195
+ .barFill {
196
+ display: block;
197
+ height: 100%;
198
+ border-radius: 999px;
199
+ background: var(--dsw-alias-brand-primary);
200
+ transition: width 1s linear;
201
+ }
202
+
203
+ /* ── Plaintext code ── */
204
+
205
+ .tokenRow {
206
+ display: flex;
207
+ flex-direction: column;
208
+ gap: 4px;
209
+ min-width: 0;
210
+ }
211
+
212
+ .tokenLabel {
213
+ color: var(--dsw-alias-label-secondary);
214
+ font-size: 13px;
215
+ line-height: 18px;
216
+ }
217
+
218
+ .token {
219
+ display: block;
220
+ padding: 8px 10px;
221
+ border: 1px solid var(--dsw-alias-border-l2);
222
+ border-radius: 8px;
223
+ background: var(--dsw-alias-bg-layer-1);
224
+ color: var(--dsw-alias-label-primary);
225
+ font-family: var(--dsw-font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
226
+ font-size: 12px;
227
+ line-height: 18px;
228
+ word-break: break-all;
229
+ user-select: all;
230
+ }
231
+
232
+ /* ── Notices ── */
233
+
234
+ .notice {
235
+ padding: 10px 12px;
236
+ border: 1px solid var(--dsw-alias-border-l2);
237
+ border-radius: 12px;
238
+ background: var(--dsw-alias-bg-layer-1);
239
+ }
240
+
241
+ .notice[data-tone='alert'] {
242
+ border-color: var(--dsw-alias-state-error-primary);
243
+ }
244
+
245
+ .notice[data-tone='warning'] {
246
+ border-color: var(--dsw-alias-state-warn-primary);
247
+ }
248
+
249
+ .noticeTitle {
250
+ margin: 0;
251
+ font-weight: 600;
252
+ line-height: 20px;
253
+ }
254
+
255
+ .noticeBody {
256
+ margin: 4px 0 0;
257
+ color: var(--dsw-alias-label-secondary);
258
+ font-size: 13px;
259
+ line-height: 20px;
260
+ }
261
+
262
+ .hint {
263
+ margin: 0;
264
+ color: var(--dsw-alias-label-tertiary);
265
+ font-size: 12px;
266
+ line-height: 18px;
267
+ }
268
+
269
+ /* ── Actions ── */
270
+
271
+ .actions {
272
+ display: flex;
273
+ justify-content: flex-end;
274
+ gap: 8px;
275
+ }
276
+
277
+ /* The panel's one primary action: a filled button over the primary-action
278
+ token trio, so a skin's light and dark sets both keep readable contrast.
279
+ brand-primary must not be a fill colour (it equals the foreground). */
280
+ .refresh {
281
+ display: inline-flex;
282
+ align-items: center;
283
+ gap: 6px;
284
+ height: 32px;
285
+ border: none;
286
+ border-radius: 16px;
287
+ padding: 0 16px;
288
+ background: var(--dsw-alias-button-primary-fill);
289
+ color: var(--dsw-alias-label-primary-foreground);
290
+ font-size: 14px;
291
+ line-height: 20px;
292
+ cursor: pointer;
293
+ transition: background-color 120ms ease;
294
+ }
295
+
296
+ .refresh:hover:not(:disabled) {
297
+ background: var(--dsw-alias-button-primary-hover);
298
+ }
299
+
300
+ .refresh:disabled {
301
+ opacity: 0.5;
302
+ cursor: default;
303
+ }
304
+
305
+ .refresh:focus-visible {
306
+ outline: none;
307
+ box-shadow: 0 0 0 2px var(--dsw-alias-bg-layer-2), 0 0 0 4px var(--dsw-alias-brand-primary);
308
+ }
309
+
310
+ .copyButton {
311
+ display: inline-flex;
312
+ align-items: center;
313
+ justify-content: center;
314
+ gap: 4px;
315
+ align-self: flex-start;
316
+ height: 28px;
317
+ border: none;
318
+ border-radius: 8px;
319
+ padding: 0 10px;
320
+ background: transparent;
321
+ color: var(--dsw-alias-label-secondary);
322
+ font-size: 12px;
323
+ line-height: 18px;
324
+ cursor: pointer;
325
+ transition: background-color 120ms ease, color 120ms ease;
326
+ }
327
+
328
+ .copyButton:hover {
329
+ background: var(--dsw-alias-interactive-bg-hover);
330
+ color: var(--dsw-alias-label-primary);
331
+ }
332
+
333
+ .copyButton[data-copied='true'] {
334
+ color: var(--dsw-alias-brand-primary);
335
+ }
336
+
337
+ .copyButton[data-failed='true'] {
338
+ color: var(--dsw-alias-state-error-primary);
339
+ }
340
+
341
+ .copyButton:focus-visible {
342
+ outline: none;
343
+ box-shadow: 0 0 0 2px var(--dsw-alias-bg-layer-2), 0 0 0 4px var(--dsw-alias-brand-primary);
344
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Semantic attribute values for the protocol v1 pairing panel (contract:
3
+ * skins/skin-center/contracts/semantic-attrs-v1.md). Root containers carry
4
+ * `data-dsh-plugin`; parts carry bare `data-dsh-part` values owned by that
5
+ * plugin attribute.
6
+ */
7
+
8
+ /** Plugin short name stamped on the footer trigger and the modal root. */
9
+ export const PLUGIN_ATTR = 'remote-bridge'
10
+
11
+ /** The sidebar footer seat trigger. */
12
+ export const PART_ENTRY = 'entry'
13
+
14
+ /** The modal panel root. */
15
+ export const PART_PANEL = 'panel'
16
+
17
+ /** The QR symbol's wrapper — it also mirrors the encoded string. */
18
+ export const PART_QR = 'qr'
19
+
20
+ /** The plaintext pairing code row. */
21
+ export const PART_TOKEN = 'token'
22
+
23
+ /** A state notice: the origin warning, or a refusal the host raised. */
24
+ export const PART_NOTICE = 'notice'
25
+
26
+ /** The mint-again button. */
27
+ export const PART_REFRESH = 'refresh'
28
+
29
+ /** The copy-the-code button. */
30
+ export const PART_COPY = 'copy'
31
+
32
+ /**
33
+ * Attribute carrying the exact string the QR symbol encodes, so the operator
34
+ * (and a UI check) can compare it against the host route's answer without
35
+ * decoding the symbol. The same string is already on screen in plaintext.
36
+ */
37
+ export const QR_VALUE_ATTR = 'data-dsh-qr-value'