@rapidmx/web-client 0.20.0 → 0.21.0

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 (118) hide show
  1. package/README.md +381 -381
  2. package/apps/admin/branding/index.tsx +39 -39
  3. package/apps/admin/data-requests/index.tsx +482 -482
  4. package/apps/admin/domains/[uid].tsx +166 -166
  5. package/apps/admin/escrow-scopes/[uid].tsx +350 -350
  6. package/apps/admin/index.tsx +129 -129
  7. package/apps/admin/mailboxes/[uid].tsx +271 -271
  8. package/apps/admin/mailboxes/new/index.tsx +30 -30
  9. package/apps/admin/plugins/index.tsx +15 -15
  10. package/apps/admin/retention-policy/index.tsx +39 -39
  11. package/apps/admin/signing-certificates/index.tsx +343 -343
  12. package/apps/escrow/audit-log/index.tsx +196 -196
  13. package/apps/escrow/matters/[uid].tsx +621 -621
  14. package/apps/shared/auth/adminAccess.ts +99 -99
  15. package/apps/shared/components/admin/layout/AdminShell.tsx +384 -384
  16. package/apps/shared/components/admin/mailboxes/EraseLeftoverDataDialog.tsx +238 -238
  17. package/apps/shared/components/admin/mailboxes/EscrowScopeCard.tsx +152 -152
  18. package/apps/shared/components/admin/mailboxes/LeftoverMailboxesSection.tsx +194 -194
  19. package/apps/shared/components/admin/settings/BrandingForm.tsx +423 -423
  20. package/apps/shared/components/admin/settings/EncryptionPolicyForm.tsx +119 -119
  21. package/apps/shared/components/admin/settings/MailboxPolicyForm.tsx +198 -198
  22. package/apps/shared/components/admin/settings/PluginsManager.tsx +2093 -2093
  23. package/apps/shared/components/admin/settings/RetentionPolicyForm.tsx +182 -182
  24. package/apps/shared/components/admin/setup/EscrowSetupStep.tsx +288 -288
  25. package/apps/shared/components/admin/setup/SetupWizard.tsx +446 -446
  26. package/apps/shared/components/admin/usePagedList.tsx +129 -129
  27. package/apps/shared/components/calendar/EventModal.tsx +206 -206
  28. package/apps/shared/components/calendar/MonthView.tsx +185 -185
  29. package/apps/shared/components/calendar/RecurrenceEditor.tsx +227 -227
  30. package/apps/shared/components/calendar/SplitDayView.tsx +144 -144
  31. package/apps/shared/components/calendar/TimeGridView.tsx +246 -246
  32. package/apps/shared/components/calendar/allDay.ts +124 -124
  33. package/apps/shared/components/contacts/ContactForm.tsx +383 -383
  34. package/apps/shared/components/contacts/ContactsToolbar.tsx +103 -103
  35. package/apps/shared/components/escrow/layout/EscrowShell.tsx +155 -155
  36. package/apps/shared/components/layout/AppShell.tsx +463 -461
  37. package/apps/shared/components/layout/KeyEnrollmentGate.tsx +398 -398
  38. package/apps/shared/components/layout/MailboxProvisioning.tsx +168 -168
  39. package/apps/shared/components/layout/ResponsiveToolbar.tsx +315 -315
  40. package/apps/shared/components/layout/ThemeSwitch.tsx +84 -84
  41. package/apps/shared/components/layout/UserMenu.tsx +439 -439
  42. package/apps/shared/components/mail/ConversationList.tsx +332 -332
  43. package/apps/shared/components/mail/ConversationThreadPane.tsx +613 -613
  44. package/apps/shared/components/mail/MailSelectionBar.tsx +240 -240
  45. package/apps/shared/components/mail/MenuButton.tsx +404 -404
  46. package/apps/shared/components/mail/MessageDetailPane.tsx +1757 -1757
  47. package/apps/shared/components/mail/compose/ComposeContext.tsx +312 -312
  48. package/apps/shared/components/mail/compose/ComposeToolbar.tsx +422 -422
  49. package/apps/shared/components/mail/compose/ComposeWindow.tsx +1705 -1681
  50. package/apps/shared/components/mail/compose/RichTextEditor.tsx +147 -147
  51. package/apps/shared/components/mail/compose/composeFlushRegistry.ts +60 -60
  52. package/apps/shared/components/mail/compose/quotedBody.ts +161 -161
  53. package/apps/shared/components/mail/reading/MessageMoreMenu.tsx +258 -258
  54. package/apps/shared/components/mail/reading/MessageSourceDialog.tsx +79 -79
  55. package/apps/shared/components/mail/reading/messageExport.ts +59 -59
  56. package/apps/shared/components/mail/reading/printMessage.ts +99 -99
  57. package/apps/shared/components/mail/reading/useMessageActions.ts +443 -443
  58. package/apps/shared/components/mail/verificationSeals.ts +125 -125
  59. package/apps/shared/components/rules/RuleBuilder.tsx +311 -311
  60. package/apps/shared/components/settings/SigningCertificateCard.tsx +344 -344
  61. package/apps/shared/keyboard/GlobalShortcuts.tsx +51 -51
  62. package/apps/shared/keyboard/ShortcutProvider.tsx +62 -62
  63. package/apps/shared/keyboard/ShortcutsDialog.tsx +84 -84
  64. package/apps/shared/keyboard/dispatch.ts +124 -124
  65. package/apps/shared/keyboard/format.ts +89 -89
  66. package/apps/shared/keyboard/keymap.ts +114 -114
  67. package/apps/shared/keyboard/registry.ts +65 -65
  68. package/apps/shared/keyboard/targets.ts +79 -79
  69. package/apps/shared/mail/folderOfType.ts +49 -49
  70. package/apps/shared/mail/folderTree.ts +143 -143
  71. package/apps/shared/mail/listAllPages.ts +39 -39
  72. package/apps/shared/mail/newMailNotifications.ts +171 -171
  73. package/apps/shared/mail/outbox/sendJob.ts +445 -445
  74. package/apps/shared/mail/outbox/sendOutcomes.ts +155 -155
  75. package/apps/shared/mail/reportNotices.ts +66 -66
  76. package/apps/shared/mail/senderBlocking.ts +141 -141
  77. package/apps/shared/mail/useMailConnection.ts +205 -205
  78. package/apps/shared/mail/useMailLiveUpdates.ts +277 -277
  79. package/apps/shared/mail/useMailboxUpdateAccess.ts +60 -60
  80. package/apps/shared/mail/useMarkMessageRead.ts +47 -47
  81. package/apps/shared/mail/useNewMailNotifications.ts +178 -178
  82. package/apps/shared/notifications/store.ts +560 -560
  83. package/apps/shared/search/LocalIndexLifecycle.tsx +114 -114
  84. package/apps/shared/search/localIndexBuilder.ts +481 -481
  85. package/apps/shared/signing/enrollmentStorage.ts +33 -33
  86. package/apps/shared/signing/enrollmentTracker.ts +385 -385
  87. package/apps/shared/signing/enrollmentView.ts +251 -251
  88. package/apps/shared/signing/useNow.ts +19 -19
  89. package/apps/shared/signing/useSigningEnrollmentWatcher.ts +90 -90
  90. package/apps/shared/styles/app.css +396 -396
  91. package/apps/www/calendar/index.tsx +581 -581
  92. package/apps/www/contacts/[uid].tsx +112 -112
  93. package/apps/www/index.tsx +3012 -3012
  94. package/apps/www/messages/[uid].tsx +139 -139
  95. package/apps/www/settings/auto-reply/index.tsx +136 -136
  96. package/apps/www/settings/blocked-senders/index.tsx +303 -303
  97. package/apps/www/settings/encryption/index.tsx +1290 -1290
  98. package/apps/www/settings/filters/[uid].tsx +179 -179
  99. package/apps/www/settings/filters/index.tsx +105 -105
  100. package/apps/www/settings/filters/new/index.tsx +165 -165
  101. package/apps/www/settings/labels/index.tsx +207 -207
  102. package/apps/www/settings/privacy/index.tsx +495 -495
  103. package/apps/www/settings/profile/index.tsx +251 -251
  104. package/apps/www/settings/read-receipts/index.tsx +150 -150
  105. package/apps/www/settings/sharing/index.tsx +259 -259
  106. package/apps/www/settings/signatures/[uid].tsx +175 -175
  107. package/apps/www/settings/signatures/index.tsx +91 -91
  108. package/apps/www/settings/signatures/new/index.tsx +138 -138
  109. package/apps/www/tasks/index.tsx +654 -654
  110. package/dist/apps/shared/components/admin/layout/AdminShell.js +2 -2
  111. package/dist/apps/shared/components/admin/settings/BrandingForm.js +3 -3
  112. package/dist/apps/shared/components/escrow/layout/EscrowShell.js +2 -2
  113. package/dist/apps/shared/components/layout/AppShell.js +4 -2
  114. package/dist/apps/shared/components/mail/compose/ComposeWindow.d.ts +7 -1
  115. package/dist/apps/shared/components/mail/compose/ComposeWindow.js +20 -1
  116. package/dist/apps/shared/components/mail/reading/printMessage.js +11 -11
  117. package/dist/apps/shared/styles/app.css +396 -396
  118. package/package.json +2 -2
@@ -1,103 +1,103 @@
1
- ///////////////////////////////////////////////////////////////////////////////
2
- // Copyright (C) 2026 Jean-Philippe Steinmetz
3
- // SPDX-License-Identifier: MPL-2.0
4
- ///////////////////////////////////////////////////////////////////////////////
5
- import React, { ChangeEvent, useRef } from "react";
6
- import {
7
- HiOutlineArrowDownTray,
8
- HiOutlineArrowUpTray,
9
- HiOutlineEnvelope,
10
- HiOutlinePencil,
11
- HiOutlineStar,
12
- HiOutlineTag,
13
- HiOutlineTrash,
14
- HiOutlineUserPlus,
15
- HiStar,
16
- } from "react-icons/hi2";
17
- import { SHORTCUTS } from "../../keyboard/keymap.js";
18
- import { useShortcutProps } from "../../keyboard/useShortcutProps.js";
19
- import ResponsiveToolbar, { ToolbarAction } from "../layout/ResponsiveToolbar.js";
20
-
21
- export interface ContactsToolbarProps {
22
- selectedCount: number;
23
- /** `true` only when every currently-selected contact is already favorited — flips the "favorite" button
24
- * to act (and read) as a removal instead of an addition. */
25
- allSelectedFavorited: boolean;
26
- onNewContact: () => void;
27
- onEdit: () => void;
28
- onDelete: () => void;
29
- onEmail: () => void;
30
- onToggleFavorite: () => void;
31
- onAddCategory: () => void;
32
- onExportVCard: () => void;
33
- /** A `.vcf` file the user picked via the toolbar's own hidden file input — parsing/import is the
34
- * page's responsibility (it has the mailbox/folder context and the actual `createContact` calls). */
35
- onImportFile: (file: File) => void;
36
- /** The keyboard's "New contact" is registered by the page: the button names its shortcut in its tooltip and `aria-keyshortcuts`. */
37
- shortcuts?: boolean;
38
- /** Leaves the New contact button out - the phone layout offers it as a floating button instead. */
39
- hideNew?: boolean;
40
- }
41
-
42
- /**
43
- * Contacts' Outlook-style ribbon toolbar, fitted to its column (`ResponsiveToolbar`): captions under the icons while there is room, then icons
44
- * alone, then the rarely used actions - Import, Export, Add category, and so on up - in a "More" menu; the bar can never spill into the pane
45
- * beside it. Every button keeps its tooltip (New contact its shortcut's) and accessible name in every layout. Deliberately presentational — every action is a callback the
46
- * page (`apps/www/contacts/index.tsx`) implements, since it owns the actual contact data, the current
47
- * selection, and the mailbox/folder context every real action (create/delete/email/favorite/category)
48
- * needs. "New contact list" isn't duplicated here — `ContactsSidebar` already has its own inline
49
- * "+ New list" affordance next to the "Your contact lists" heading.
50
- */
51
- export default function ContactsToolbar({
52
- selectedCount,
53
- allSelectedFavorited,
54
- onNewContact,
55
- onEdit,
56
- onDelete,
57
- onEmail,
58
- onToggleFavorite,
59
- onAddCategory,
60
- onExportVCard,
61
- onImportFile,
62
- shortcuts,
63
- hideNew,
64
- }: ContactsToolbarProps) {
65
- const newContactHint = useShortcutProps("New contact", SHORTCUTS.contacts.create, !!shortcuts);
66
- const importInputRef = useRef<HTMLInputElement | null>(null);
67
- const hasSelection = selectedCount > 0;
68
-
69
- function handleImportFileChosen(e: ChangeEvent<HTMLInputElement>) {
70
- const file = e.target.files?.[0];
71
- e.target.value = "";
72
- if (file) {
73
- onImportFile(file);
74
- }
75
- }
76
-
77
- const actions: ToolbarAction[] = [
78
- ...(hideNew
79
- ? []
80
- : [{ id: "new", label: "New contact", icon: HiOutlineUserPlus, onClick: onNewContact, hint: shortcuts ? newContactHint : undefined, group: 0, rank: 99, essential: true }]),
81
- { id: "edit", label: "Edit", icon: HiOutlinePencil, onClick: onEdit, disabled: selectedCount !== 1, group: 1, rank: 6 },
82
- { id: "delete", label: "Delete", icon: HiOutlineTrash, onClick: onDelete, disabled: !hasSelection, group: 1, rank: 5 },
83
- { id: "email", label: "Email", icon: HiOutlineEnvelope, onClick: onEmail, disabled: !hasSelection, group: 2, rank: 4 },
84
- {
85
- id: "favorite",
86
- label: allSelectedFavorited ? "Unfavorite" : "Favorite",
87
- icon: allSelectedFavorited ? HiStar : HiOutlineStar,
88
- onClick: onToggleFavorite,
89
- disabled: !hasSelection,
90
- group: 2,
91
- rank: 3,
92
- },
93
- { id: "category", label: "Add category", icon: HiOutlineTag, onClick: onAddCategory, disabled: !hasSelection, group: 2, rank: 2 },
94
- { id: "export", label: "Export", icon: HiOutlineArrowUpTray, onClick: onExportVCard, disabled: !hasSelection, group: 3, rank: 1 },
95
- { id: "import", label: "Import", icon: HiOutlineArrowDownTray, onClick: () => importInputRef.current?.click(), group: 3, rank: 0 },
96
- ];
97
-
98
- return (
99
- <ResponsiveToolbar label="Contacts actions" actions={actions}>
100
- <input ref={importInputRef} type="file" accept=".vcf" className="sr-only" aria-label="Import contacts file" onChange={handleImportFileChosen} />
101
- </ResponsiveToolbar>
102
- );
103
- }
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2026 Jean-Philippe Steinmetz
3
+ // SPDX-License-Identifier: MPL-2.0
4
+ ///////////////////////////////////////////////////////////////////////////////
5
+ import React, { ChangeEvent, useRef } from "react";
6
+ import {
7
+ HiOutlineArrowDownTray,
8
+ HiOutlineArrowUpTray,
9
+ HiOutlineEnvelope,
10
+ HiOutlinePencil,
11
+ HiOutlineStar,
12
+ HiOutlineTag,
13
+ HiOutlineTrash,
14
+ HiOutlineUserPlus,
15
+ HiStar,
16
+ } from "react-icons/hi2";
17
+ import { SHORTCUTS } from "../../keyboard/keymap.js";
18
+ import { useShortcutProps } from "../../keyboard/useShortcutProps.js";
19
+ import ResponsiveToolbar, { ToolbarAction } from "../layout/ResponsiveToolbar.js";
20
+
21
+ export interface ContactsToolbarProps {
22
+ selectedCount: number;
23
+ /** `true` only when every currently-selected contact is already favorited — flips the "favorite" button
24
+ * to act (and read) as a removal instead of an addition. */
25
+ allSelectedFavorited: boolean;
26
+ onNewContact: () => void;
27
+ onEdit: () => void;
28
+ onDelete: () => void;
29
+ onEmail: () => void;
30
+ onToggleFavorite: () => void;
31
+ onAddCategory: () => void;
32
+ onExportVCard: () => void;
33
+ /** A `.vcf` file the user picked via the toolbar's own hidden file input — parsing/import is the
34
+ * page's responsibility (it has the mailbox/folder context and the actual `createContact` calls). */
35
+ onImportFile: (file: File) => void;
36
+ /** The keyboard's "New contact" is registered by the page: the button names its shortcut in its tooltip and `aria-keyshortcuts`. */
37
+ shortcuts?: boolean;
38
+ /** Leaves the New contact button out - the phone layout offers it as a floating button instead. */
39
+ hideNew?: boolean;
40
+ }
41
+
42
+ /**
43
+ * Contacts' Outlook-style ribbon toolbar, fitted to its column (`ResponsiveToolbar`): captions under the icons while there is room, then icons
44
+ * alone, then the rarely used actions - Import, Export, Add category, and so on up - in a "More" menu; the bar can never spill into the pane
45
+ * beside it. Every button keeps its tooltip (New contact its shortcut's) and accessible name in every layout. Deliberately presentational — every action is a callback the
46
+ * page (`apps/www/contacts/index.tsx`) implements, since it owns the actual contact data, the current
47
+ * selection, and the mailbox/folder context every real action (create/delete/email/favorite/category)
48
+ * needs. "New contact list" isn't duplicated here — `ContactsSidebar` already has its own inline
49
+ * "+ New list" affordance next to the "Your contact lists" heading.
50
+ */
51
+ export default function ContactsToolbar({
52
+ selectedCount,
53
+ allSelectedFavorited,
54
+ onNewContact,
55
+ onEdit,
56
+ onDelete,
57
+ onEmail,
58
+ onToggleFavorite,
59
+ onAddCategory,
60
+ onExportVCard,
61
+ onImportFile,
62
+ shortcuts,
63
+ hideNew,
64
+ }: ContactsToolbarProps) {
65
+ const newContactHint = useShortcutProps("New contact", SHORTCUTS.contacts.create, !!shortcuts);
66
+ const importInputRef = useRef<HTMLInputElement | null>(null);
67
+ const hasSelection = selectedCount > 0;
68
+
69
+ function handleImportFileChosen(e: ChangeEvent<HTMLInputElement>) {
70
+ const file = e.target.files?.[0];
71
+ e.target.value = "";
72
+ if (file) {
73
+ onImportFile(file);
74
+ }
75
+ }
76
+
77
+ const actions: ToolbarAction[] = [
78
+ ...(hideNew
79
+ ? []
80
+ : [{ id: "new", label: "New contact", icon: HiOutlineUserPlus, onClick: onNewContact, hint: shortcuts ? newContactHint : undefined, group: 0, rank: 99, essential: true }]),
81
+ { id: "edit", label: "Edit", icon: HiOutlinePencil, onClick: onEdit, disabled: selectedCount !== 1, group: 1, rank: 6 },
82
+ { id: "delete", label: "Delete", icon: HiOutlineTrash, onClick: onDelete, disabled: !hasSelection, group: 1, rank: 5 },
83
+ { id: "email", label: "Email", icon: HiOutlineEnvelope, onClick: onEmail, disabled: !hasSelection, group: 2, rank: 4 },
84
+ {
85
+ id: "favorite",
86
+ label: allSelectedFavorited ? "Unfavorite" : "Favorite",
87
+ icon: allSelectedFavorited ? HiStar : HiOutlineStar,
88
+ onClick: onToggleFavorite,
89
+ disabled: !hasSelection,
90
+ group: 2,
91
+ rank: 3,
92
+ },
93
+ { id: "category", label: "Add category", icon: HiOutlineTag, onClick: onAddCategory, disabled: !hasSelection, group: 2, rank: 2 },
94
+ { id: "export", label: "Export", icon: HiOutlineArrowUpTray, onClick: onExportVCard, disabled: !hasSelection, group: 3, rank: 1 },
95
+ { id: "import", label: "Import", icon: HiOutlineArrowDownTray, onClick: () => importInputRef.current?.click(), group: 3, rank: 0 },
96
+ ];
97
+
98
+ return (
99
+ <ResponsiveToolbar label="Contacts actions" actions={actions}>
100
+ <input ref={importInputRef} type="file" accept=".vcf" className="sr-only" aria-label="Import contacts file" onChange={handleImportFileChosen} />
101
+ </ResponsiveToolbar>
102
+ );
103
+ }
@@ -1,155 +1,155 @@
1
- ///////////////////////////////////////////////////////////////////////////////
2
- // Copyright (C) 2026 Jean-Philippe Steinmetz
3
- // SPDX-License-Identifier: MPL-2.0
4
- ///////////////////////////////////////////////////////////////////////////////
5
- import "../../../styles/app.css";
6
- import React, { PropsWithChildren, ReactNode, useEffect, useState } from "react";
7
- import { HiOutlineClipboardDocumentList, HiOutlineFolderOpen } from "react-icons/hi2";
8
- import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
9
- import { listMatters } from "@rapidmx/react-shared/admin/mattersApi.js";
10
- import { useRedirectIfUnauthenticated } from "@rapidmx/react-shared/auth/session.js";
11
- import { getBranding } from "@rapidmx/react-shared/branding/brandingApi.js";
12
- import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
13
- import BottomTabBar, { NavItem } from "@rapidmx/react-shared/components/navigation/BottomTabBar.js";
14
- import UserMenu from "../../layout/UserMenu.js";
15
- import RailIcon from "../../layout/RailIcon.js";
16
- import AppearanceProvider from "../../../appearance/AppearanceProvider.js";
17
- import { signOutOfConsole } from "../../admin/signOut.js";
18
-
19
- export type EscrowSection = "matters" | "auditLog";
20
-
21
- export interface EscrowShellProps {
22
- active: EscrowSection;
23
- userUid?: string;
24
- authServerUrl?: string;
25
- }
26
-
27
- type Status = "checking" | "error" | "authorized";
28
-
29
- const DEFAULT_ICON_SRC = "/images/logo.svg";
30
-
31
- const NAV_ITEMS: NavItem[] = [
32
- { id: "matters", href: "/escrow", label: "Matters", icon: HiOutlineFolderOpen },
33
- { id: "auditLog", href: "/escrow/audit-log", label: "Audit Log", icon: HiOutlineClipboardDocumentList },
34
- ];
35
-
36
- /**
37
- * Gates every `apps/escrow` page behind "is this an authenticated caller at all" — deliberately **not**
38
- * the same "does a canary endpoint 403 me" pattern `AdminShell` uses for the trusted `admin` role.
39
- * `specs/end-to-end_encryption.md`'s "Separation of duties" makes holder-ness a per-`EscrowScope` grant
40
- * (`EscrowScope.holderUserUids`), checked directly against `holderUserUids` in every restapi route that
41
- * needs it (`requireEscrowHolder()`) — never a role, and never global. There is no canary endpoint a
42
- * non-holder gets a clean 403 from: `GET /escrow/matters` (`BaseMatterRoute.find()`) returns `200 []` for
43
- * *any* authenticated caller who holds no scope at all, the same as it would for a holder of zero matters
44
- * — so unlike `AdminShell`, this shell cannot distinguish "holds nothing" from "holds no scope at all" up
45
- * front, and does not try to. It only confirms the caller is signed in and the API is reachable; every
46
- * actual holder-gated action (create a Matter, approve/deny a request, read material) is enforced
47
- * server-side and surfaces its own 403 `ApiRequestError` on the specific page that attempted it, same as
48
- * any other gated action elsewhere in this codebase. A non-holder who reaches `/escrow` simply sees an
49
- * empty Matters list and gets a real error if they try to act on something they don't hold — this is a
50
- * deliberate, documented scope trim rather than an oversight (see this session's own report on it).
51
- */
52
- export default function EscrowShell({ active, userUid, authServerUrl, children }: PropsWithChildren<EscrowShellProps>) {
53
- const [status, setStatus] = useState<Status>("checking");
54
- const [error, setError] = useState<string | null>(null);
55
- const [iconSrc, setIconSrc] = useState(DEFAULT_ICON_SRC);
56
-
57
- useRedirectIfUnauthenticated(userUid, authServerUrl);
58
-
59
- // Only the icon is taken from branding here. The escrow console deliberately skips `useBranding()`, which
60
- // would inject the custom stylesheet, and never renders the admin-configured header/footer HTML - this
61
- // console handles escrow key material, so no admin-supplied markup or CSS runs on it.
62
- useEffect(() => {
63
- let cancelled = false;
64
- getBranding()
65
- .then((branding) => {
66
- if (!cancelled) setIconSrc(branding.iconUrl || branding.logoUrl || DEFAULT_ICON_SRC);
67
- })
68
- .catch(() => {
69
- // Decorative only - keep the default icon.
70
- });
71
- return () => {
72
- cancelled = true;
73
- };
74
- }, []);
75
-
76
- useEffect(() => {
77
- if (!userUid) {
78
- return;
79
- }
80
- // limit=1 - this call exists only to confirm the API is reachable for this signed-in caller, not
81
- // to read any real data (every page below fetches its own data itself).
82
- listMatters({ limit: 1 })
83
- .then(() => setStatus("authorized"))
84
- .catch((err) => {
85
- setError(err instanceof ApiRequestError ? err.message : "Could not verify escrow console access.");
86
- setStatus("error");
87
- });
88
- }, [userUid]);
89
-
90
- function handleSignOut() {
91
- // Ends the auth-server session and tells other tabs, not just navigates - see `signOutOfConsole()`.
92
- void signOutOfConsole(authServerUrl);
93
- }
94
-
95
- let content: ReactNode;
96
- if (!userUid || status === "checking") {
97
- content = <div className="min-h-screen" />;
98
- } else if (status === "error") {
99
- content = (
100
- <div className="min-h-screen flex items-center justify-center p-8">
101
- <div className="w-full max-w-md">
102
- <Alert>{error}</Alert>
103
- </div>
104
- </div>
105
- );
106
- } else {
107
- const activeItem = NAV_ITEMS.find((item) => item.id === active);
108
- content = (
109
- <div className="rr-frame-bg min-h-screen flex flex-col">
110
- <div className="flex-1 flex min-h-0">
111
- <nav
112
- aria-label="Escrow sections"
113
- className="hidden md:flex w-16 shrink-0 bg-surface border-r border-border flex-col items-center pb-3 gap-1"
114
- >
115
- <RailIcon src={iconSrc} />
116
- {NAV_ITEMS.map(({ id, href, label, icon: Icon }) => (
117
- <a
118
- key={id}
119
- href={href}
120
- aria-label={label}
121
- aria-current={id === active ? "page" : undefined}
122
- title={label}
123
- className={[
124
- "w-10 h-10 flex items-center justify-center rounded-sm",
125
- id === active
126
- ? "bg-primary/10 text-primary-dark"
127
- : "text-text-muted hover:bg-surface-alt hover:text-text",
128
- ].join(" ")}
129
- >
130
- <Icon size={20} aria-hidden="true" />
131
- </a>
132
- ))}
133
- </nav>
134
- <BottomTabBar apps={NAV_ITEMS} active={active} />
135
- <div className="flex-1 flex flex-col min-w-0">
136
- <header className="rr-solid sticky top-0 z-30 h-16 shrink-0 bg-surface border-b border-border flex items-center justify-between gap-4 px-6">
137
- <span className="font-display font-bold text-lg uppercase tracking-wide">{activeItem?.label}</span>
138
- <UserMenu userUid={userUid} authServerUrl={authServerUrl} onSignOut={handleSignOut} />
139
- </header>
140
- <div id="app-content" className="flex-1 pb-14 md:pb-0">
141
- <main className="max-w-6xl mx-auto px-6 py-8">{children}</main>
142
- </div>
143
- </div>
144
- </div>
145
- </div>
146
- );
147
- }
148
-
149
- // The user's own colours and background (`AppearanceProvider`), from what the last webmail page cached in this browser: the console never asks the server.
150
- return (
151
- <AppearanceProvider userUid={userUid} lookUp={false}>
152
- {content}
153
- </AppearanceProvider>
154
- );
155
- }
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2026 Jean-Philippe Steinmetz
3
+ // SPDX-License-Identifier: MPL-2.0
4
+ ///////////////////////////////////////////////////////////////////////////////
5
+ import "../../../styles/app.css";
6
+ import React, { PropsWithChildren, ReactNode, useEffect, useState } from "react";
7
+ import { HiOutlineClipboardDocumentList, HiOutlineFolderOpen } from "react-icons/hi2";
8
+ import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
9
+ import { listMatters } from "@rapidmx/react-shared/admin/mattersApi.js";
10
+ import { useSessionRefresh } from "@rapidmx/react-shared/auth/session.js";
11
+ import { getBranding } from "@rapidmx/react-shared/branding/brandingApi.js";
12
+ import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
13
+ import BottomTabBar, { NavItem } from "@rapidmx/react-shared/components/navigation/BottomTabBar.js";
14
+ import UserMenu from "../../layout/UserMenu.js";
15
+ import RailIcon from "../../layout/RailIcon.js";
16
+ import AppearanceProvider from "../../../appearance/AppearanceProvider.js";
17
+ import { signOutOfConsole } from "../../admin/signOut.js";
18
+
19
+ export type EscrowSection = "matters" | "auditLog";
20
+
21
+ export interface EscrowShellProps {
22
+ active: EscrowSection;
23
+ userUid?: string;
24
+ authServerUrl?: string;
25
+ }
26
+
27
+ type Status = "checking" | "error" | "authorized";
28
+
29
+ const DEFAULT_ICON_SRC = "/images/logo.svg";
30
+
31
+ const NAV_ITEMS: NavItem[] = [
32
+ { id: "matters", href: "/escrow", label: "Matters", icon: HiOutlineFolderOpen },
33
+ { id: "auditLog", href: "/escrow/audit-log", label: "Audit Log", icon: HiOutlineClipboardDocumentList },
34
+ ];
35
+
36
+ /**
37
+ * Gates every `apps/escrow` page behind "is this an authenticated caller at all" — deliberately **not**
38
+ * the same "does a canary endpoint 403 me" pattern `AdminShell` uses for the trusted `admin` role.
39
+ * `specs/end-to-end_encryption.md`'s "Separation of duties" makes holder-ness a per-`EscrowScope` grant
40
+ * (`EscrowScope.holderUserUids`), checked directly against `holderUserUids` in every restapi route that
41
+ * needs it (`requireEscrowHolder()`) — never a role, and never global. There is no canary endpoint a
42
+ * non-holder gets a clean 403 from: `GET /escrow/matters` (`BaseMatterRoute.find()`) returns `200 []` for
43
+ * *any* authenticated caller who holds no scope at all, the same as it would for a holder of zero matters
44
+ * — so unlike `AdminShell`, this shell cannot distinguish "holds nothing" from "holds no scope at all" up
45
+ * front, and does not try to. It only confirms the caller is signed in and the API is reachable; every
46
+ * actual holder-gated action (create a Matter, approve/deny a request, read material) is enforced
47
+ * server-side and surfaces its own 403 `ApiRequestError` on the specific page that attempted it, same as
48
+ * any other gated action elsewhere in this codebase. A non-holder who reaches `/escrow` simply sees an
49
+ * empty Matters list and gets a real error if they try to act on something they don't hold — this is a
50
+ * deliberate, documented scope trim rather than an oversight (see this session's own report on it).
51
+ */
52
+ export default function EscrowShell({ active, userUid, authServerUrl, children }: PropsWithChildren<EscrowShellProps>) {
53
+ const [status, setStatus] = useState<Status>("checking");
54
+ const [error, setError] = useState<string | null>(null);
55
+ const [iconSrc, setIconSrc] = useState(DEFAULT_ICON_SRC);
56
+
57
+ useSessionRefresh(userUid, authServerUrl);
58
+
59
+ // Only the icon is taken from branding here. The escrow console deliberately skips `useBranding()`, which
60
+ // would inject the custom stylesheet, and never renders the admin-configured header/footer HTML - this
61
+ // console handles escrow key material, so no admin-supplied markup or CSS runs on it.
62
+ useEffect(() => {
63
+ let cancelled = false;
64
+ getBranding()
65
+ .then((branding) => {
66
+ if (!cancelled) setIconSrc(branding.iconUrl || branding.logoUrl || DEFAULT_ICON_SRC);
67
+ })
68
+ .catch(() => {
69
+ // Decorative only - keep the default icon.
70
+ });
71
+ return () => {
72
+ cancelled = true;
73
+ };
74
+ }, []);
75
+
76
+ useEffect(() => {
77
+ if (!userUid) {
78
+ return;
79
+ }
80
+ // limit=1 - this call exists only to confirm the API is reachable for this signed-in caller, not
81
+ // to read any real data (every page below fetches its own data itself).
82
+ listMatters({ limit: 1 })
83
+ .then(() => setStatus("authorized"))
84
+ .catch((err) => {
85
+ setError(err instanceof ApiRequestError ? err.message : "Could not verify escrow console access.");
86
+ setStatus("error");
87
+ });
88
+ }, [userUid]);
89
+
90
+ function handleSignOut() {
91
+ // Ends the auth-server session and tells other tabs, not just navigates - see `signOutOfConsole()`.
92
+ void signOutOfConsole(authServerUrl);
93
+ }
94
+
95
+ let content: ReactNode;
96
+ if (!userUid || status === "checking") {
97
+ content = <div className="min-h-screen" />;
98
+ } else if (status === "error") {
99
+ content = (
100
+ <div className="min-h-screen flex items-center justify-center p-8">
101
+ <div className="w-full max-w-md">
102
+ <Alert>{error}</Alert>
103
+ </div>
104
+ </div>
105
+ );
106
+ } else {
107
+ const activeItem = NAV_ITEMS.find((item) => item.id === active);
108
+ content = (
109
+ <div className="rr-frame-bg min-h-screen flex flex-col">
110
+ <div className="flex-1 flex min-h-0">
111
+ <nav
112
+ aria-label="Escrow sections"
113
+ className="hidden md:flex w-16 shrink-0 bg-surface border-r border-border flex-col items-center pb-3 gap-1"
114
+ >
115
+ <RailIcon src={iconSrc} />
116
+ {NAV_ITEMS.map(({ id, href, label, icon: Icon }) => (
117
+ <a
118
+ key={id}
119
+ href={href}
120
+ aria-label={label}
121
+ aria-current={id === active ? "page" : undefined}
122
+ title={label}
123
+ className={[
124
+ "w-10 h-10 flex items-center justify-center rounded-sm",
125
+ id === active
126
+ ? "bg-primary/10 text-primary-dark"
127
+ : "text-text-muted hover:bg-surface-alt hover:text-text",
128
+ ].join(" ")}
129
+ >
130
+ <Icon size={20} aria-hidden="true" />
131
+ </a>
132
+ ))}
133
+ </nav>
134
+ <BottomTabBar apps={NAV_ITEMS} active={active} />
135
+ <div className="flex-1 flex flex-col min-w-0">
136
+ <header className="rr-solid sticky top-0 z-30 h-16 shrink-0 bg-surface border-b border-border flex items-center justify-between gap-4 px-6">
137
+ <span className="font-display font-bold text-lg uppercase tracking-wide">{activeItem?.label}</span>
138
+ <UserMenu userUid={userUid} authServerUrl={authServerUrl} onSignOut={handleSignOut} />
139
+ </header>
140
+ <div id="app-content" className="flex-1 pb-14 md:pb-0">
141
+ <main className="max-w-6xl mx-auto px-6 py-8">{children}</main>
142
+ </div>
143
+ </div>
144
+ </div>
145
+ </div>
146
+ );
147
+ }
148
+
149
+ // The user's own colours and background (`AppearanceProvider`), from what the last webmail page cached in this browser: the console never asks the server.
150
+ return (
151
+ <AppearanceProvider userUid={userUid} lookUp={false}>
152
+ {content}
153
+ </AppearanceProvider>
154
+ );
155
+ }