@peers-app/peers-ui 0.27.3 → 0.27.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (311) hide show
  1. package/dist/screens/network-viewer/group-details-modal.d.ts +4 -0
  2. package/dist/screens/network-viewer/group-details-modal.js +6 -46
  3. package/dist/screens/network-viewer/network-viewer-ipc.d.ts +3 -2
  4. package/dist/screens/network-viewer/network-viewer-ipc.js +6 -0
  5. package/dist/screens/network-viewer/sync-recovery.js +103 -1
  6. package/dist/screens/variables/variable-details.js +2 -1
  7. package/dist/tabs-layout/network-status-indicator.js +26 -12
  8. package/dist/tabs-layout/use-network-status.d.ts +6 -1
  9. package/dist/tabs-layout/use-network-status.js +27 -4
  10. package/package.json +9 -3
  11. package/.claude/settings.local.json +0 -34
  12. package/.github/README.md +0 -52
  13. package/.github/workflows/delete-all-artifacts.yml +0 -49
  14. package/.github/workflows/publish.yml +0 -51
  15. package/babel.config.js +0 -7
  16. package/biome.json +0 -198
  17. package/dist/app-updates/app-updates-consumer.test.d.ts +0 -1
  18. package/dist/app-updates/app-updates-consumer.test.js +0 -56
  19. package/dist/app-updates/app-updates-settings.test.d.ts +0 -1
  20. package/dist/app-updates/app-updates-settings.test.js +0 -93
  21. package/dist/app-updates/remote-app-update-panel.test.d.ts +0 -1
  22. package/dist/app-updates/remote-app-update-panel.test.js +0 -165
  23. package/dist/components/access-level-field.test.d.ts +0 -1
  24. package/dist/components/access-level-field.test.js +0 -28
  25. package/dist/components/message-logs/tool-access-approval-card.test.d.ts +0 -1
  26. package/dist/components/message-logs/tool-access-approval-card.test.js +0 -102
  27. package/dist/components/responsive-section-nav.test.d.ts +0 -1
  28. package/dist/components/responsive-section-nav.test.js +0 -45
  29. package/dist/globals-hash.test.d.ts +0 -1
  30. package/dist/globals-hash.test.js +0 -16
  31. package/dist/hooks/use-observable-state.test.d.ts +0 -1
  32. package/dist/hooks/use-observable-state.test.js +0 -64
  33. package/dist/hooks/use-observable.test.d.ts +0 -1
  34. package/dist/hooks/use-observable.test.js +0 -191
  35. package/dist/hooks/use-rows.test.d.ts +0 -1
  36. package/dist/hooks/use-rows.test.js +0 -175
  37. package/dist/hooks/use-tool.test.d.ts +0 -1
  38. package/dist/hooks/use-tool.test.js +0 -190
  39. package/dist/host-shell/host-shell-consumer.test.d.ts +0 -1
  40. package/dist/host-shell/host-shell-consumer.test.js +0 -28
  41. package/dist/root-layout/root-layout-host.test.d.ts +0 -1
  42. package/dist/root-layout/root-layout-host.test.js +0 -86
  43. package/dist/screens/account/account-screen.test.d.ts +0 -1
  44. package/dist/screens/account/account-screen.test.js +0 -51
  45. package/dist/screens/assistants/assistant-config.test.d.ts +0 -1
  46. package/dist/screens/assistants/assistant-config.test.js +0 -57
  47. package/dist/screens/contacts/contact-list.test.d.ts +0 -1
  48. package/dist/screens/contacts/contact-list.test.js +0 -48
  49. package/dist/screens/device-pairing/device-pairing.test.d.ts +0 -1
  50. package/dist/screens/device-pairing/device-pairing.test.js +0 -119
  51. package/dist/screens/devices/devices-list.test.d.ts +0 -1
  52. package/dist/screens/devices/devices-list.test.js +0 -53
  53. package/dist/screens/groups/group-list.test.d.ts +0 -1
  54. package/dist/screens/groups/group-list.test.js +0 -38
  55. package/dist/screens/identity/identity-routes.test.d.ts +0 -1
  56. package/dist/screens/identity/identity-routes.test.js +0 -51
  57. package/dist/screens/identity/identity-screen.test.d.ts +0 -1
  58. package/dist/screens/identity/identity-screen.test.js +0 -103
  59. package/dist/screens/invites/accept-invite.test.d.ts +0 -1
  60. package/dist/screens/invites/accept-invite.test.js +0 -103
  61. package/dist/screens/invites/activity-view.test.d.ts +0 -1
  62. package/dist/screens/invites/activity-view.test.js +0 -108
  63. package/dist/screens/invites/invite-classify.test.d.ts +0 -1
  64. package/dist/screens/invites/invite-classify.test.js +0 -115
  65. package/dist/screens/network-viewer/network-viewer-ipc.test.d.ts +0 -1
  66. package/dist/screens/network-viewer/network-viewer-ipc.test.js +0 -61
  67. package/dist/screens/network-viewer/network-viewer.section.test.d.ts +0 -1
  68. package/dist/screens/network-viewer/network-viewer.section.test.js +0 -63
  69. package/dist/screens/network-viewer/sync-recovery.test.d.ts +0 -1
  70. package/dist/screens/network-viewer/sync-recovery.test.js +0 -104
  71. package/dist/screens/packages/package-helpers.test.d.ts +0 -1
  72. package/dist/screens/packages/package-helpers.test.js +0 -53
  73. package/dist/screens/packages/package-runtime-status.test.d.ts +0 -1
  74. package/dist/screens/packages/package-runtime-status.test.js +0 -50
  75. package/dist/screens/packages/packages-ipc.test.d.ts +0 -1
  76. package/dist/screens/packages/packages-ipc.test.js +0 -43
  77. package/dist/screens/settings/settings-page.test.d.ts +0 -1
  78. package/dist/screens/settings/settings-page.test.js +0 -19
  79. package/dist/screens/tools/tool-access-ipc.test.d.ts +0 -1
  80. package/dist/screens/tools/tool-access-ipc.test.js +0 -40
  81. package/dist/screens/tools/tool-catalog-ipc.test.d.ts +0 -1
  82. package/dist/screens/tools/tool-catalog-ipc.test.js +0 -52
  83. package/dist/tabs-layout/network-status-indicator.test.d.ts +0 -1
  84. package/dist/tabs-layout/network-status-indicator.test.js +0 -665
  85. package/dist/tabs-layout/tabs-state.test.d.ts +0 -1
  86. package/dist/tabs-layout/tabs-state.test.js +0 -110
  87. package/dist/tabs-layout/use-network-status.test.d.ts +0 -1
  88. package/dist/tabs-layout/use-network-status.test.js +0 -45
  89. package/dist/ui-router/ui-loader.test.d.ts +0 -1
  90. package/dist/ui-router/ui-loader.test.js +0 -91
  91. package/jest.config.js +0 -25
  92. package/release-guard.js +0 -10
  93. package/src/app-updates/app-update-controls.tsx +0 -73
  94. package/src/app-updates/app-updates-consumer.test.ts +0 -83
  95. package/src/app-updates/app-updates-consumer.ts +0 -121
  96. package/src/app-updates/app-updates-settings.test.tsx +0 -109
  97. package/src/app-updates/app-updates-settings.tsx +0 -136
  98. package/src/app-updates/remote-app-update-panel.test.tsx +0 -205
  99. package/src/app-updates/remote-app-update-panel.tsx +0 -210
  100. package/src/app-updates/use-app-update-status.ts +0 -16
  101. package/src/command-palette/command-palette-ui.tsx +0 -564
  102. package/src/command-palette/command-palette.ts +0 -242
  103. package/src/components/access-level-field.test.tsx +0 -32
  104. package/src/components/access-level-field.tsx +0 -68
  105. package/src/components/checkbox.tsx +0 -25
  106. package/src/components/group-switcher.tsx +0 -526
  107. package/src/components/input-date.tsx +0 -29
  108. package/src/components/input-number.tsx +0 -83
  109. package/src/components/input.tsx +0 -25
  110. package/src/components/inverse-lazy-list.tsx +0 -107
  111. package/src/components/io-schema-values.tsx +0 -103
  112. package/src/components/io-schema.tsx +0 -259
  113. package/src/components/lazy-list.tsx +0 -115
  114. package/src/components/list-screen.tsx +0 -126
  115. package/src/components/loading-indicator.tsx +0 -7
  116. package/src/components/markdown-editor/autolink-plugin.tsx +0 -29
  117. package/src/components/markdown-editor/editor-inline.tsx +0 -9
  118. package/src/components/markdown-editor/editor.tsx +0 -158
  119. package/src/components/markdown-editor/markdown-plugin.tsx +0 -202
  120. package/src/components/markdown-editor/mention-node.ts +0 -204
  121. package/src/components/markdown-editor/mentions-plugin.tsx +0 -354
  122. package/src/components/markdown-editor/move-line-plugin.tsx +0 -186
  123. package/src/components/markdown-editor/select-line-boundary-plugin.tsx +0 -95
  124. package/src/components/markdown-editor/theme.ts +0 -46
  125. package/src/components/markdown-editor/toolbar.tsx +0 -269
  126. package/src/components/markdown-with-mentions.tsx +0 -198
  127. package/src/components/message-logs/message-logs.tsx +0 -523
  128. package/src/components/message-logs/tool-access-approval-card.test.tsx +0 -127
  129. package/src/components/message-logs/tool-access-approval-card.tsx +0 -178
  130. package/src/components/messages/avatar.tsx +0 -171
  131. package/src/components/messages/channel-message-list.tsx +0 -189
  132. package/src/components/messages/channel-view.tsx +0 -92
  133. package/src/components/messages/message-compose.tsx +0 -192
  134. package/src/components/messages/message-display.tsx +0 -231
  135. package/src/components/messages/thread-message-list.tsx +0 -135
  136. package/src/components/qr-scanner.tsx +0 -180
  137. package/src/components/responsive-section-nav.test.tsx +0 -88
  138. package/src/components/responsive-section-nav.tsx +0 -92
  139. package/src/components/router.tsx +0 -175
  140. package/src/components/save-button.tsx +0 -134
  141. package/src/components/sortable-list.tsx +0 -130
  142. package/src/components/tabs.tsx +0 -76
  143. package/src/components/tooltip.tsx +0 -43
  144. package/src/components/trust-level-badge.tsx +0 -44
  145. package/src/components/trust-level-dropdown.tsx +0 -136
  146. package/src/components/typeahead.tsx +0 -357
  147. package/src/globals-hash.test.ts +0 -19
  148. package/src/globals.tsx +0 -226
  149. package/src/hooks/index.ts +0 -8
  150. package/src/hooks/use-host-contract.ts +0 -75
  151. package/src/hooks/use-observable-state.test.tsx +0 -101
  152. package/src/hooks/use-observable-state.ts +0 -29
  153. package/src/hooks/use-observable.test.tsx +0 -258
  154. package/src/hooks/use-observable.ts +0 -67
  155. package/src/hooks/use-on-screen.ts +0 -24
  156. package/src/hooks/use-promise.ts +0 -34
  157. package/src/hooks/use-rows.test.tsx +0 -196
  158. package/src/hooks/use-rows.ts +0 -120
  159. package/src/hooks/use-subscription.ts +0 -24
  160. package/src/hooks/use-tool.test.tsx +0 -225
  161. package/src/hooks/use-tool.ts +0 -116
  162. package/src/host-shell/host-shell-consumer.test.ts +0 -32
  163. package/src/host-shell/host-shell-consumer.ts +0 -53
  164. package/src/index.tsx +0 -42
  165. package/src/mention-configs.ts +0 -185
  166. package/src/operator-console/operator-console-state.ts +0 -119
  167. package/src/operator-console/operator-console.tsx +0 -233
  168. package/src/peers-services-registration.ts +0 -6
  169. package/src/root-layout/global-overlays.ts +0 -50
  170. package/src/root-layout/layout-picker.tsx +0 -47
  171. package/src/root-layout/layouts/full-screen-layout.tsx +0 -144
  172. package/src/root-layout/layouts/tabs-with-console-layout.tsx +0 -260
  173. package/src/root-layout/root-layout-host.test.tsx +0 -108
  174. package/src/root-layout/root-layout-host.tsx +0 -147
  175. package/src/root-layout/root-layout-registry.ts +0 -51
  176. package/src/root-layout/root-layout-state.ts +0 -55
  177. package/src/root-layout/root-layout.ts +0 -32
  178. package/src/screens/account/account-screen.test.tsx +0 -65
  179. package/src/screens/account/account-screen.tsx +0 -942
  180. package/src/screens/assistants/assistant-config.test.tsx +0 -54
  181. package/src/screens/assistants/assistant-config.tsx +0 -121
  182. package/src/screens/assistants/assistant-details.tsx +0 -89
  183. package/src/screens/assistants/assistant-info.tsx +0 -66
  184. package/src/screens/assistants/assistant-list.tsx +0 -145
  185. package/src/screens/assistants/assistant-tools.tsx +0 -82
  186. package/src/screens/console-logs/console-logs-list.tsx +0 -374
  187. package/src/screens/console-logs/log-display.tsx +0 -137
  188. package/src/screens/console-logs/log-filters.tsx +0 -64
  189. package/src/screens/console-logs/mobile-log-card.tsx +0 -161
  190. package/src/screens/console-logs/resizable-table-header.tsx +0 -110
  191. package/src/screens/contacts/contact-details.tsx +0 -123
  192. package/src/screens/contacts/contact-list.test.tsx +0 -59
  193. package/src/screens/contacts/contact-list.tsx +0 -286
  194. package/src/screens/contacts/index.ts +0 -2
  195. package/src/screens/data-explorer/data-explorer.tsx +0 -633
  196. package/src/screens/data-explorer/index.ts +0 -6
  197. package/src/screens/data-explorer/query-executor.tsx +0 -520
  198. package/src/screens/device-pairing/device-pairing.test.tsx +0 -143
  199. package/src/screens/device-pairing/device-pairing.tsx +0 -461
  200. package/src/screens/device-pairing/identity-ipc.ts +0 -25
  201. package/src/screens/device-pairing/index.ts +0 -2
  202. package/src/screens/device-pairing/use-device-pairing-state.ts +0 -15
  203. package/src/screens/devices/devices-list.test.tsx +0 -68
  204. package/src/screens/devices/devices-list.tsx +0 -365
  205. package/src/screens/devices/index.ts +0 -1
  206. package/src/screens/groups/group-details.tsx +0 -160
  207. package/src/screens/groups/group-invite-panel.tsx +0 -311
  208. package/src/screens/groups/group-list.test.tsx +0 -44
  209. package/src/screens/groups/group-list.tsx +0 -317
  210. package/src/screens/groups/group-members.tsx +0 -343
  211. package/src/screens/groups/index.ts +0 -3
  212. package/src/screens/identity/identity-routes.test.ts +0 -70
  213. package/src/screens/identity/identity-routes.ts +0 -301
  214. package/src/screens/identity/identity-screen.test.tsx +0 -138
  215. package/src/screens/identity/identity-screen.tsx +0 -282
  216. package/src/screens/identity/index.ts +0 -2
  217. package/src/screens/identity/invite-contact-panel.tsx +0 -45
  218. package/src/screens/identity/profile-invite.tsx +0 -93
  219. package/src/screens/invites/accept-invite.test.tsx +0 -115
  220. package/src/screens/invites/accept-invite.tsx +0 -318
  221. package/src/screens/invites/activity-view.test.tsx +0 -127
  222. package/src/screens/invites/activity-view.tsx +0 -162
  223. package/src/screens/invites/index.ts +0 -6
  224. package/src/screens/invites/invite-capture.ts +0 -104
  225. package/src/screens/invites/invite-classify.test.ts +0 -129
  226. package/src/screens/invites/invite-share.tsx +0 -104
  227. package/src/screens/invites/invites-ipc.ts +0 -25
  228. package/src/screens/invites/pending-invites-list.tsx +0 -256
  229. package/src/screens/network-viewer/connection-troubleshooter.tsx +0 -395
  230. package/src/screens/network-viewer/cpu-usage-graph.tsx +0 -294
  231. package/src/screens/network-viewer/device-details-modal.tsx +0 -339
  232. package/src/screens/network-viewer/group-details-modal.tsx +0 -421
  233. package/src/screens/network-viewer/index.ts +0 -8
  234. package/src/screens/network-viewer/network-viewer-ipc.test.ts +0 -72
  235. package/src/screens/network-viewer/network-viewer-ipc.ts +0 -39
  236. package/src/screens/network-viewer/network-viewer-section.ts +0 -12
  237. package/src/screens/network-viewer/network-viewer.section.test.tsx +0 -68
  238. package/src/screens/network-viewer/network-viewer.tsx +0 -708
  239. package/src/screens/network-viewer/remote-logs-panel.tsx +0 -190
  240. package/src/screens/network-viewer/sync-recovery.test.tsx +0 -114
  241. package/src/screens/network-viewer/sync-recovery.tsx +0 -461
  242. package/src/screens/network-viewer/usage-graph.tsx +0 -455
  243. package/src/screens/packages/local-folder-grants-panel.tsx +0 -290
  244. package/src/screens/packages/local-folders-ipc.ts +0 -28
  245. package/src/screens/packages/package-details.tsx +0 -166
  246. package/src/screens/packages/package-helpers.test.ts +0 -57
  247. package/src/screens/packages/package-helpers.ts +0 -137
  248. package/src/screens/packages/package-info.tsx +0 -354
  249. package/src/screens/packages/package-list.tsx +0 -519
  250. package/src/screens/packages/package-network-panel.tsx +0 -82
  251. package/src/screens/packages/package-new-local.tsx +0 -100
  252. package/src/screens/packages/package-runtime-status.test.tsx +0 -58
  253. package/src/screens/packages/package-runtime-status.tsx +0 -68
  254. package/src/screens/packages/package-versions.tsx +0 -298
  255. package/src/screens/packages/packages-ipc.test.ts +0 -47
  256. package/src/screens/packages/packages-ipc.ts +0 -125
  257. package/src/screens/peer-types/peer-type-details.tsx +0 -172
  258. package/src/screens/peer-types/peer-type-list.tsx +0 -64
  259. package/src/screens/search/global-search.tsx +0 -406
  260. package/src/screens/settings/color-mode-dropdown.tsx +0 -82
  261. package/src/screens/settings/settings-page.test.tsx +0 -24
  262. package/src/screens/settings/settings-page.tsx +0 -426
  263. package/src/screens/setup-user.tsx +0 -355
  264. package/src/screens/tools/tool-access-ipc.test.ts +0 -55
  265. package/src/screens/tools/tool-access-ipc.ts +0 -27
  266. package/src/screens/tools/tool-catalog-ipc.test.ts +0 -52
  267. package/src/screens/tools/tool-catalog-ipc.ts +0 -51
  268. package/src/screens/tools/tool-details.tsx +0 -52
  269. package/src/screens/tools/tool-info.tsx +0 -45
  270. package/src/screens/tools/tool-list.tsx +0 -106
  271. package/src/screens/tools/tool-schema.tsx +0 -44
  272. package/src/screens/tools/tool-test-details.tsx +0 -89
  273. package/src/screens/tools/tool-test-list.tsx +0 -73
  274. package/src/screens/variables/variable-details.tsx +0 -289
  275. package/src/screens/variables/variable-list.tsx +0 -110
  276. package/src/screens/welcome-modal.tsx +0 -294
  277. package/src/screens/workflows/workflow-details.tsx +0 -115
  278. package/src/screens/workflows/workflow-info.tsx +0 -22
  279. package/src/screens/workflows/workflow-instructions.tsx +0 -134
  280. package/src/screens/workflows/workflow-list.tsx +0 -117
  281. package/src/setupTests.ts +0 -38
  282. package/src/system-apps/assistants.app.ts +0 -7
  283. package/src/system-apps/console-logs.app.ts +0 -7
  284. package/src/system-apps/data-explorer.app.ts +0 -8
  285. package/src/system-apps/identity.app.ts +0 -9
  286. package/src/system-apps/index.ts +0 -77
  287. package/src/system-apps/mobile-settings.app.ts +0 -7
  288. package/src/system-apps/network-viewer.app.ts +0 -8
  289. package/src/system-apps/packages.app.ts +0 -7
  290. package/src/system-apps/search.app.ts +0 -8
  291. package/src/system-apps/settings.app.ts +0 -7
  292. package/src/system-apps/threads.app.ts +0 -7
  293. package/src/system-apps/tools.app.ts +0 -7
  294. package/src/system-apps/types.app.ts +0 -7
  295. package/src/system-apps/variables.app.ts +0 -7
  296. package/src/system-apps/workflows.app.ts +0 -7
  297. package/src/tabs-layout/network-status-indicator.test.tsx +0 -799
  298. package/src/tabs-layout/network-status-indicator.tsx +0 -756
  299. package/src/tabs-layout/tabs-layout.tsx +0 -857
  300. package/src/tabs-layout/tabs-state.test.ts +0 -152
  301. package/src/tabs-layout/tabs-state.ts +0 -587
  302. package/src/tabs-layout/use-network-status.test.tsx +0 -58
  303. package/src/tabs-layout/use-network-status.ts +0 -68
  304. package/src/ui-defaults/index.ts +0 -2
  305. package/src/ui-defaults/list-screen.tsx +0 -94
  306. package/src/ui-defaults/markdown-field.tsx +0 -87
  307. package/src/ui-router/routes-loader.ts +0 -193
  308. package/src/ui-router/ui-loader.test.tsx +0 -108
  309. package/src/ui-router/ui-loader.tsx +0 -606
  310. package/src/utils.ts +0 -95
  311. package/tsconfig.json +0 -18
@@ -1,461 +0,0 @@
1
- import { copyToClipboard, type DevicePairingState, parsePairingCode } from "@peers-app/peers-sdk";
2
- import { useEffect, useRef, useState } from "react";
3
- import QRCode from "react-qr-code";
4
- import { canScanQr, QrScanner } from "../../components/qr-scanner";
5
- import { identityTools } from "./identity-ipc";
6
- import { useDevicePairingState } from "./use-device-pairing-state";
7
-
8
- function isPairingCode(text: string): boolean {
9
- try {
10
- parsePairingCode(text);
11
- return true;
12
- } catch {
13
- return false;
14
- }
15
- }
16
-
17
- const TERMINAL_PHASES: DevicePairingState["phase"][] = ["complete", "rejected", "error"];
18
-
19
- function formatCountdown(expiresAt?: number): string {
20
- if (!expiresAt) {
21
- return "";
22
- }
23
- const seconds = Math.max(0, Math.ceil((expiresAt - Date.now()) / 1000));
24
- return `${Math.floor(seconds / 60)}:${(seconds % 60).toString().padStart(2, "0")}`;
25
- }
26
-
27
- function detectDeviceType(): string {
28
- return /Mobi|Android/i.test(navigator.userAgent) ? "mobile" : "browser";
29
- }
30
-
31
- function useCountdownClock(expiresAt?: number) {
32
- const [, setClock] = useState(0);
33
- useEffect(() => {
34
- if (!expiresAt) {
35
- return;
36
- }
37
- const timer = window.setInterval(() => setClock((value) => value + 1), 1000);
38
- return () => window.clearInterval(timer);
39
- }, [expiresAt]);
40
- }
41
-
42
- function PairingProgress(props: {
43
- state: DevicePairingState;
44
- messages: Partial<Record<string, string>>;
45
- }) {
46
- return (
47
- <output className="text-center py-4 d-block">
48
- <div className="spinner-border text-primary mb-3" aria-hidden="true" />
49
- <p className="text-muted mb-0">{props.messages[props.state.phase] ?? "Working…"}</p>
50
- </output>
51
- );
52
- }
53
-
54
- function ProgressWithCancel(props: {
55
- state: DevicePairingState;
56
- messages: Partial<Record<string, string>>;
57
- onCancel: () => void;
58
- }) {
59
- return (
60
- <>
61
- <PairingProgress state={props.state} messages={props.messages} />
62
- <div className="text-center">
63
- <button type="button" className="btn btn-outline-secondary" onClick={props.onCancel}>
64
- Cancel
65
- </button>
66
- </div>
67
- </>
68
- );
69
- }
70
-
71
- function RemoteDeviceLabel({ state }: { state: DevicePairingState }) {
72
- return (
73
- <>
74
- {state.remoteDevice?.deviceName || "Unnamed device"}
75
- {state.remoteDevice?.deviceType ? ` (${state.remoteDevice.deviceType})` : ""}
76
- </>
77
- );
78
- }
79
-
80
- function SourceApproval(props: {
81
- state: DevicePairingState;
82
- approving: boolean;
83
- onApprove: () => void;
84
- onReject: () => void;
85
- onCancel: () => void;
86
- }) {
87
- return (
88
- <div className="text-center" style={{ maxWidth: 440, margin: "0 auto" }}>
89
- <h4>Add this device?</h4>
90
- <p className="text-muted">
91
- The code matched. Approving sends your account credentials to this device so it can sign in
92
- as you.
93
- </p>
94
- <p className="fs-5 mb-4">
95
- <RemoteDeviceLabel state={props.state} />
96
- </p>
97
- <div className="d-flex gap-2 justify-content-center">
98
- <button
99
- type="button"
100
- className="btn btn-primary"
101
- disabled={props.approving}
102
- onClick={props.onApprove}
103
- >
104
- {props.approving ? "Approving…" : "Approve"}
105
- </button>
106
- <button
107
- type="button"
108
- className="btn btn-outline-danger"
109
- disabled={props.approving}
110
- onClick={props.onReject}
111
- >
112
- Reject
113
- </button>
114
- <button
115
- type="button"
116
- className="btn btn-outline-secondary"
117
- disabled={props.approving}
118
- onClick={props.onCancel}
119
- >
120
- Cancel
121
- </button>
122
- </div>
123
- </div>
124
- );
125
- }
126
-
127
- function TerminalPanel(props: { state: DevicePairingState; onClose: () => void }) {
128
- const complete = props.state.phase === "complete";
129
- return (
130
- <div className="text-center" style={{ maxWidth: 440, margin: "0 auto" }}>
131
- <output className={`alert d-block ${complete ? "alert-success" : "alert-warning"}`}>
132
- {complete
133
- ? "Device added successfully."
134
- : props.state.phase === "rejected"
135
- ? "Pairing was rejected. No credentials were installed."
136
- : props.state.error || "Pairing could not be completed. No credentials were installed."}
137
- </output>
138
- <button type="button" className="btn btn-outline-secondary" onClick={props.onClose}>
139
- {complete ? "Done" : "Back"}
140
- </button>
141
- </div>
142
- );
143
- }
144
-
145
- function usePairingSessionLifecycle(state: DevicePairingState) {
146
- const sessionId = useRef<string | undefined>(undefined);
147
- const phase = useRef<DevicePairingState["phase"]>("idle");
148
- const mounted = useRef(true);
149
-
150
- useEffect(() => {
151
- if (state.sessionId) {
152
- // The host may rotate to a new session (destination code rotation); follow it.
153
- sessionId.current = state.sessionId;
154
- phase.current = state.phase;
155
- }
156
- }, [state.phase, state.sessionId]);
157
-
158
- useEffect(() => {
159
- mounted.current = true;
160
- return () => {
161
- mounted.current = false;
162
- const activeSessionId = sessionId.current;
163
- if (activeSessionId && !["idle", ...TERMINAL_PHASES].includes(phase.current)) {
164
- void identityTools()
165
- .then((tools) => tools.cancel({ sessionId: activeSessionId }))
166
- .catch(() => undefined);
167
- }
168
- };
169
- }, []);
170
-
171
- return { sessionId, phase, mounted };
172
- }
173
-
174
- function useCeremonyActions(
175
- lifecycle: ReturnType<typeof usePairingSessionLifecycle>,
176
- onLeave: () => void,
177
- setLocalError: (value: string) => void,
178
- ) {
179
- const [approving, setApproving] = useState(false);
180
-
181
- const act = async (action: "approve" | "reject") => {
182
- const sessionId = lifecycle.sessionId.current;
183
- if (!sessionId) {
184
- return;
185
- }
186
- setApproving(true);
187
- try {
188
- const tools = await identityTools();
189
- if (action === "approve") {
190
- await tools.approve({ sessionId });
191
- } else {
192
- await tools.reject({ sessionId });
193
- }
194
- } catch {
195
- setLocalError("Could not update the pairing ceremony.");
196
- } finally {
197
- setApproving(false);
198
- }
199
- };
200
-
201
- const cancel = async () => {
202
- const sessionId = lifecycle.sessionId.current;
203
- lifecycle.phase.current = "idle";
204
- if (sessionId) {
205
- await identityTools()
206
- .then((tools) => tools.cancel({ sessionId }))
207
- .catch(() => undefined);
208
- }
209
- onLeave();
210
- };
211
-
212
- return { approving, act, cancel };
213
- }
214
-
215
- const SOURCE_PROGRESS_MESSAGES: Partial<Record<DevicePairingState["phase"], string>> = {
216
- connecting: "Connecting to the new device…",
217
- authenticating: "Verifying the pairing code…",
218
- transferring: "Sending encrypted account credentials…",
219
- };
220
-
221
- /** Signed-in source flow opened from Settings: type the code shown on the new device, then approve. */
222
- export function SourceDevicePairing(props: { onClose: () => void }) {
223
- const state = useDevicePairingState();
224
- const lifecycle = usePairingSessionLifecycle(state);
225
- const [code, setCode] = useState("");
226
- const [scanning, setScanning] = useState(false);
227
- const [starting, setStarting] = useState(false);
228
- const [localError, setLocalError] = useState("");
229
- const { approving, act, cancel } = useCeremonyActions(lifecycle, props.onClose, setLocalError);
230
- useCountdownClock(state.expiresAt);
231
-
232
- const start = async (rawCode: string = code) => {
233
- setLocalError("");
234
- setStarting(true);
235
- try {
236
- const tools = await identityTools();
237
- const result = await tools.startSource({ code: rawCode.trim() });
238
- lifecycle.sessionId.current = result.sessionId;
239
- lifecycle.phase.current = result.phase;
240
- if (!lifecycle.mounted.current && result.sessionId) {
241
- await tools.cancel({ sessionId: result.sessionId }).catch(() => undefined);
242
- }
243
- } catch {
244
- setLocalError("That code was not recognized or the new device is no longer waiting.");
245
- } finally {
246
- setStarting(false);
247
- }
248
- };
249
-
250
- if (TERMINAL_PHASES.includes(state.phase)) {
251
- return <TerminalPanel state={state} onClose={props.onClose} />;
252
- }
253
- if (state.phase === "waiting-for-approval") {
254
- return (
255
- <SourceApproval
256
- state={state}
257
- approving={approving}
258
- onApprove={() => void act("approve")}
259
- onReject={() => void act("reject")}
260
- onCancel={() => void cancel()}
261
- />
262
- );
263
- }
264
- if (
265
- state.phase === "connecting" ||
266
- state.phase === "authenticating" ||
267
- state.phase === "transferring"
268
- ) {
269
- return (
270
- <ProgressWithCancel
271
- state={state}
272
- messages={SOURCE_PROGRESS_MESSAGES}
273
- onCancel={() => void cancel()}
274
- />
275
- );
276
- }
277
- if (scanning) {
278
- return (
279
- <div className="text-center" style={{ maxWidth: 440, margin: "0 auto" }}>
280
- <p className="text-muted">Point the camera at the code on the new device.</p>
281
- <QrScanner
282
- accept={isPairingCode}
283
- onScan={(scanned) => {
284
- setScanning(false);
285
- setCode(scanned);
286
- void start(scanned);
287
- }}
288
- onError={(message) => {
289
- setScanning(false);
290
- setLocalError(message);
291
- }}
292
- />
293
- <button
294
- type="button"
295
- className="btn btn-outline-secondary mt-3"
296
- onClick={() => setScanning(false)}
297
- >
298
- Type it instead
299
- </button>
300
- </div>
301
- );
302
- }
303
- return (
304
- <form
305
- className="text-center"
306
- style={{ maxWidth: 440, margin: "0 auto" }}
307
- onSubmit={(event) => {
308
- event.preventDefault();
309
- void start();
310
- }}
311
- >
312
- <p className="text-muted">
313
- On the new device, open Peers and choose <strong>Sign in from another device</strong>. Scan
314
- the code it shows, or type it here.
315
- </p>
316
- {canScanQr() ? (
317
- <button
318
- type="button"
319
- className="btn btn-outline-primary mb-3"
320
- disabled={starting}
321
- onClick={() => setScanning(true)}
322
- >
323
- <i className="bi bi-qr-code-scan me-1" />
324
- Scan code
325
- </button>
326
- ) : null}
327
- <input
328
- className="form-control form-control-lg font-monospace text-center mb-3"
329
- placeholder="7-guitar-revenge-tunnel"
330
- value={code}
331
- onChange={(event) => setCode(event.target.value)}
332
- autoComplete="off"
333
- autoCapitalize="none"
334
- spellCheck={false}
335
- aria-label="Pairing code"
336
- disabled={starting}
337
- />
338
- {localError ? <div className="alert alert-danger">{localError}</div> : null}
339
- <div className="d-flex gap-2 justify-content-center">
340
- <button
341
- type="submit"
342
- className="btn btn-primary"
343
- disabled={starting || code.trim().split(/[\s-]+/).length < 4}
344
- >
345
- {starting ? "Connecting…" : "Connect"}
346
- </button>
347
- <button
348
- type="button"
349
- className="btn btn-outline-secondary"
350
- disabled={starting}
351
- onClick={props.onClose}
352
- >
353
- Cancel
354
- </button>
355
- </div>
356
- </form>
357
- );
358
- }
359
-
360
- const DESTINATION_PROGRESS_MESSAGES: Partial<Record<DevicePairingState["phase"], string>> = {
361
- idle: "Preparing a pairing code…",
362
- connecting: "Connecting to your other device…",
363
- authenticating: "Verifying the pairing code…",
364
- "waiting-for-approval": "Waiting for approval on your other device…",
365
- transferring: "Installing encrypted account credentials…",
366
- };
367
-
368
- function ShowingCode(props: { state: DevicePairingState; onCancel: () => void }) {
369
- const code = props.state.code ?? "";
370
- return (
371
- <div className="text-center" style={{ maxWidth: 480, margin: "0 auto" }}>
372
- <h3>Sign in from another device</h3>
373
- <p className="text-muted">
374
- On a device already signed in to Peers, open{" "}
375
- <strong>Identity → Devices → Add a device</strong> and type this code or scan it.
376
- </p>
377
- {props.state.notice ? <div className="alert alert-warning">{props.state.notice}</div> : null}
378
- <output
379
- className="d-block fs-3 font-monospace text-primary mb-3"
380
- style={{ letterSpacing: "0.04em", wordBreak: "break-word" }}
381
- aria-label="Pairing code"
382
- >
383
- {code}
384
- </output>
385
- <div className="d-inline-block bg-white rounded p-3 mb-3">
386
- <QRCode value={code} size={200} aria-label="Pairing code QR" />
387
- </div>
388
- <p className="small text-muted">Expires in {formatCountdown(props.state.expiresAt)}</p>
389
- <div className="d-flex gap-2 justify-content-center">
390
- <button
391
- type="button"
392
- className="btn btn-outline-primary"
393
- onClick={() => void copyToClipboard(code)}
394
- >
395
- Copy code
396
- </button>
397
- <button type="button" className="btn btn-outline-secondary" onClick={props.onCancel}>
398
- Cancel
399
- </button>
400
- </div>
401
- </div>
402
- );
403
- }
404
-
405
- /** Signed-out destination flow: shows a code and QR, then installs credentials after approval. */
406
- export function DestinationDevicePairing(props: { onBack: () => void }) {
407
- const state = useDevicePairingState();
408
- const lifecycle = usePairingSessionLifecycle(state);
409
- const [localError, setLocalError] = useState("");
410
- const started = useRef(false);
411
- const { cancel } = useCeremonyActions(lifecycle, props.onBack, setLocalError);
412
- useCountdownClock(state.expiresAt);
413
-
414
- useEffect(() => {
415
- if (started.current) {
416
- return;
417
- }
418
- started.current = true;
419
- void identityTools()
420
- .then(async (tools) => {
421
- const result = await tools.startDestination({ deviceType: detectDeviceType() });
422
- lifecycle.sessionId.current = result.sessionId;
423
- lifecycle.phase.current = result.phase;
424
- if (!lifecycle.mounted.current && result.sessionId) {
425
- await tools.cancel({ sessionId: result.sessionId }).catch(() => undefined);
426
- }
427
- })
428
- .catch(() => setLocalError("Could not reach the pairing service. Check your connection."));
429
- }, []);
430
-
431
- useEffect(() => {
432
- if (state.phase !== "complete") {
433
- return;
434
- }
435
- window.setTimeout(() => window.location.reload(), 750);
436
- }, [state.phase]);
437
-
438
- if (localError) {
439
- return (
440
- <div className="text-center" style={{ maxWidth: 440, margin: "0 auto" }}>
441
- <div className="alert alert-danger">{localError}</div>
442
- <button type="button" className="btn btn-outline-secondary" onClick={props.onBack}>
443
- Back
444
- </button>
445
- </div>
446
- );
447
- }
448
- if (TERMINAL_PHASES.includes(state.phase)) {
449
- return <TerminalPanel state={state} onClose={props.onBack} />;
450
- }
451
- if (state.phase === "showing-code" && state.code) {
452
- return <ShowingCode state={state} onCancel={() => void cancel()} />;
453
- }
454
- return (
455
- <ProgressWithCancel
456
- state={state}
457
- messages={DESTINATION_PROGRESS_MESSAGES}
458
- onCancel={() => void cancel()}
459
- />
460
- );
461
- }
@@ -1,25 +0,0 @@
1
- import {
2
- getIdentityContractDefinition,
3
- hostContractConsumer,
4
- type IHostContractConsumer,
5
- type IIdentityConsumer,
6
- } from "@peers-app/peers-sdk";
7
-
8
- /**
9
- * Cached local-host consumer for System Identity.
10
- *
11
- * Pairing and session tools resolve before sign-in, so this handle passes no data context.
12
- */
13
- export const identityContract: IHostContractConsumer<IIdentityConsumer> = hostContractConsumer(
14
- getIdentityContractDefinition(),
15
- );
16
-
17
- /** Return the typed local-host consumer for System Identity. */
18
- export async function getIdentityConsumer(): Promise<IIdentityConsumer> {
19
- return identityContract.get();
20
- }
21
-
22
- /** Shorthand for `(await getIdentityConsumer()).tools`. */
23
- export async function identityTools(): Promise<IIdentityConsumer["tools"]> {
24
- return (await getIdentityConsumer()).tools;
25
- }
@@ -1,2 +0,0 @@
1
- export * from "./device-pairing";
2
- export * from "./use-device-pairing-state";
@@ -1,15 +0,0 @@
1
- import type { DevicePairingState } from "@peers-app/peers-sdk";
2
- import { useObservable } from "../../hooks";
3
- import { useHostContract } from "../../hooks/use-host-contract";
4
- import { identityContract } from "./identity-ipc";
5
-
6
- const IDLE_PAIRING_STATE: DevicePairingState = { phase: "idle" };
7
-
8
- /** Subscribe to the host pairing ceremony. Idle until the identity consumer is ready. */
9
- export function useDevicePairingState(): DevicePairingState {
10
- const { consumer } = useHostContract(identityContract);
11
- const [state] = useObservable<DevicePairingState>(
12
- consumer?.observables.state ?? IDLE_PAIRING_STATE,
13
- );
14
- return state ?? IDLE_PAIRING_STATE;
15
- }
@@ -1,68 +0,0 @@
1
- import { type IDevice, TrustLevel } from "@peers-app/peers-sdk";
2
- import { render, screen } from "@testing-library/react";
3
- import { DeviceRow, devicesForUser } from "./devices-list";
4
-
5
- jest.mock("../../globals", () => ({
6
- mainContentPath: jest.fn(),
7
- }));
8
-
9
- jest.mock("../../hooks", () => ({
10
- useObservable: jest.fn(),
11
- useObservableState: jest.fn(),
12
- usePromise: jest.fn(),
13
- }));
14
-
15
- jest.mock("../device-pairing", () => ({
16
- SourceDevicePairing: () => null,
17
- }));
18
-
19
- jest.mock("../invites/activity-view", () => ({
20
- PendingWorkLink: () => null,
21
- }));
22
-
23
- jest.mock("../network-viewer/network-viewer-ipc", () => ({
24
- getNetworkControlConsumer: jest.fn(),
25
- getNetworkDiagnosticsConsumer: jest.fn(),
26
- }));
27
-
28
- function device(deviceId: string, userId: string, name: string): IDevice {
29
- return {
30
- deviceId,
31
- userId,
32
- name,
33
- firstSeen: new Date("2026-01-01T00:00:00Z"),
34
- lastSeen: new Date(),
35
- trustLevel: TrustLevel.Trusted,
36
- };
37
- }
38
-
39
- describe("Devices identity list", () => {
40
- it("filters out devices owned by other users", () => {
41
- const mine = device("abcdefghijklmnopqrstuvwxy", "mine000000000000000000001", "Laptop");
42
- const theirs = device("zyxwvutsrqponmlkjihgfedcb", "theirs000000000000000001", "Other");
43
-
44
- expect(devicesForUser([mine, theirs], mine.userId)).toEqual([mine]);
45
- });
46
-
47
- it("shows the current-device and connection context without a destructive row action", () => {
48
- const mine = device("abcdefghijklmnopqrstuvwxy", "mine000000000000000000001", "Laptop");
49
- render(
50
- <DeviceRow
51
- device={mine}
52
- isThisDevice
53
- connection={
54
- {
55
- deviceId: mine.deviceId,
56
- connectionState: "connected",
57
- pathType: "direct",
58
- } as never
59
- }
60
- />,
61
- );
62
-
63
- expect(screen.getByText("Laptop")).toBeInTheDocument();
64
- expect(screen.getByText("This device")).toBeInTheDocument();
65
- expect(screen.getByText("Online")).toBeInTheDocument();
66
- expect(screen.queryByRole("button", { name: /Forget/i })).not.toBeInTheDocument();
67
- });
68
- });