@rapidmx/web-client 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/admin/data-requests/index.tsx +485 -0
- package/apps/admin/escrow-scopes/[uid].tsx +237 -0
- package/apps/admin/escrow-scopes/index.tsx +124 -0
- package/apps/admin/escrow-scopes/new/index.tsx +128 -0
- package/apps/admin/mailboxes/[uid].tsx +66 -8
- package/apps/admin/retention-policy/index.tsx +132 -0
- package/apps/escrow/_layout.tsx +41 -0
- package/apps/escrow/audit-log/index.tsx +168 -0
- package/apps/escrow/index.tsx +139 -0
- package/apps/escrow/matters/[uid].tsx +521 -0
- package/apps/escrow/matters/new/index.tsx +173 -0
- package/apps/shared/components/admin/escrowScopes/EscrowScopeKeyAndHoldersFields.tsx +171 -0
- package/apps/shared/components/admin/layout/AdminShell.tsx +24 -0
- package/apps/shared/components/contacts/ContactDetailPane.tsx +44 -0
- package/apps/shared/components/escrow/layout/EscrowShell.tsx +134 -0
- package/apps/shared/components/forms/StringListField.tsx +104 -0
- package/apps/shared/components/layout/AppShell.tsx +4 -0
- package/apps/shared/components/layout/KeyEnrollmentGate.tsx +265 -0
- package/apps/shared/components/mail/ConversationThreadPane.tsx +8 -1
- package/apps/shared/components/mail/MessageDetailPane.tsx +214 -9
- package/apps/shared/components/mail/compose/ComposeContext.tsx +10 -1
- package/apps/shared/components/mail/compose/ComposeWindow.tsx +271 -24
- package/apps/shared/components/mail/layout/MailShell.tsx +302 -287
- package/apps/shared/components/settings/layout/SettingsShell.tsx +3 -0
- package/apps/www/index.tsx +122 -11
- package/apps/www/messages/[uid].tsx +15 -1
- package/apps/www/settings/encryption/index.tsx +664 -0
- package/apps/www/settings/labels/index.tsx +201 -0
- package/apps/www/settings/privacy/index.tsx +436 -0
- package/dist/apps/admin/data-requests/index.js +197 -0
- package/dist/apps/admin/escrow-scopes/[uid].js +141 -0
- package/dist/apps/admin/escrow-scopes/index.js +31 -0
- package/dist/apps/admin/escrow-scopes/new/index.js +69 -0
- package/dist/apps/admin/mailboxes/[uid].js +26 -2
- package/dist/apps/admin/retention-policy/index.js +65 -0
- package/dist/apps/escrow/_layout.js +10 -0
- package/dist/apps/escrow/audit-log/index.js +66 -0
- package/dist/apps/escrow/index.js +31 -0
- package/dist/apps/escrow/matters/[uid].js +234 -0
- package/dist/apps/escrow/matters/new/index.js +75 -0
- package/dist/apps/shared/components/admin/escrowScopes/EscrowScopeKeyAndHoldersFields.js +26 -0
- package/dist/apps/shared/components/admin/layout/AdminShell.js +19 -1
- package/dist/apps/shared/components/contacts/ContactDetailPane.js +10 -1
- package/dist/apps/shared/components/escrow/layout/EscrowShell.js +75 -0
- package/dist/apps/shared/components/forms/StringListField.js +39 -0
- package/dist/apps/shared/components/layout/AppShell.js +4 -0
- package/dist/apps/shared/components/layout/KeyEnrollmentGate.js +142 -0
- package/dist/apps/shared/components/mail/ConversationThreadPane.js +2 -2
- package/dist/apps/shared/components/mail/MessageDetailPane.js +105 -6
- package/dist/apps/shared/components/mail/compose/ComposeContext.js +2 -1
- package/dist/apps/shared/components/mail/compose/ComposeWindow.js +184 -21
- package/dist/apps/shared/components/mail/layout/MailShell.js +11 -2
- package/dist/apps/shared/components/settings/layout/SettingsShell.js +3 -0
- package/dist/apps/www/index.js +110 -10
- package/dist/apps/www/messages/[uid].js +12 -2
- package/dist/apps/www/settings/encryption/index.js +330 -0
- package/dist/apps/www/settings/labels/index.js +95 -0
- package/dist/apps/www/settings/privacy/index.js +167 -0
- package/package.json +9 -3
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
+
import React, { useState } from "react";
|
|
6
|
+
import Button from "@rapidmx/react-shared/components/buttons/Button.js";
|
|
7
|
+
|
|
8
|
+
export interface StringListFieldProps {
|
|
9
|
+
label: string;
|
|
10
|
+
/** Associates the label with the add-input via `htmlFor`/`id`, same as `FormField` — required so the
|
|
11
|
+
* field is reachable via `getByLabelText()` in tests and by assistive tech, not just visually. */
|
|
12
|
+
id: string;
|
|
13
|
+
values: string[];
|
|
14
|
+
onChange: (values: string[]) => void;
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
emptyMessage?: string;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A plain, controlled add/remove list-of-strings editor — the same visual add-row/per-item-remove shape
|
|
22
|
+
* `MemberListCard` already established for a `DistributionList`'s `memberAddresses`, but operating on a
|
|
23
|
+
* local `value`/`onChange` pair rather than persisting itself via its own API call. `MemberListCard`
|
|
24
|
+
* isn't reusable here as-is: `EscrowScope.holderUserUids` (at least one required) and
|
|
25
|
+
* `Matter.custodianMailboxUids` (also non-empty) are both required *at creation time*, before there's any
|
|
26
|
+
* uid yet to `PUT` against — this needs to compose into an ordinary create/edit form's own local state
|
|
27
|
+
* instead, same as every other field on those forms.
|
|
28
|
+
*/
|
|
29
|
+
export default function StringListField({
|
|
30
|
+
label,
|
|
31
|
+
id,
|
|
32
|
+
values,
|
|
33
|
+
onChange,
|
|
34
|
+
placeholder,
|
|
35
|
+
emptyMessage = "None added yet.",
|
|
36
|
+
disabled,
|
|
37
|
+
}: StringListFieldProps) {
|
|
38
|
+
const [draft, setDraft] = useState("");
|
|
39
|
+
|
|
40
|
+
/** Accepts either the "Add" button's own form submit or the input's Enter keydown — both just need
|
|
41
|
+
* `preventDefault()` (submitting would otherwise reload the page; Enter would otherwise do nothing
|
|
42
|
+
* harmful here, but is prevented for consistency). */
|
|
43
|
+
function handleAdd(e: { preventDefault(): void }) {
|
|
44
|
+
e.preventDefault();
|
|
45
|
+
const trimmed = draft.trim();
|
|
46
|
+
if (!trimmed || values.includes(trimmed)) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
onChange([...values, trimmed]);
|
|
50
|
+
setDraft("");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function handleRemove(value: string) {
|
|
54
|
+
onChange(values.filter((v) => v !== value));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<div className="mb-4">
|
|
59
|
+
<label htmlFor={id} className="block text-sm font-semibold mb-1.5 text-text">
|
|
60
|
+
{label}
|
|
61
|
+
</label>
|
|
62
|
+
|
|
63
|
+
<ul className="flex flex-col gap-2 mb-2">
|
|
64
|
+
{values.length === 0 && <li className="text-sm text-text-muted">{emptyMessage}</li>}
|
|
65
|
+
{values.map((value) => (
|
|
66
|
+
<li
|
|
67
|
+
key={value}
|
|
68
|
+
className="flex items-center justify-between gap-3 py-2 px-3 border border-border rounded-sm"
|
|
69
|
+
>
|
|
70
|
+
<span className="text-sm font-medium break-all">{value}</span>
|
|
71
|
+
<button
|
|
72
|
+
type="button"
|
|
73
|
+
onClick={() => handleRemove(value)}
|
|
74
|
+
disabled={disabled}
|
|
75
|
+
className="text-sm text-danger hover:underline disabled:opacity-55 shrink-0"
|
|
76
|
+
>
|
|
77
|
+
Remove
|
|
78
|
+
</button>
|
|
79
|
+
</li>
|
|
80
|
+
))}
|
|
81
|
+
</ul>
|
|
82
|
+
|
|
83
|
+
<div className="flex gap-2">
|
|
84
|
+
<input
|
|
85
|
+
id={id}
|
|
86
|
+
type="text"
|
|
87
|
+
value={draft}
|
|
88
|
+
onChange={(e) => setDraft(e.target.value)}
|
|
89
|
+
onKeyDown={(e) => {
|
|
90
|
+
if (e.key === "Enter") {
|
|
91
|
+
handleAdd(e);
|
|
92
|
+
}
|
|
93
|
+
}}
|
|
94
|
+
placeholder={placeholder}
|
|
95
|
+
disabled={disabled}
|
|
96
|
+
className="flex-1 text-sm py-2 px-3 border border-border rounded-sm bg-surface text-text focus:outline-none focus:border-primary"
|
|
97
|
+
/>
|
|
98
|
+
<Button type="button" variant="secondary" disabled={disabled} className="!w-auto" onClick={handleAdd}>
|
|
99
|
+
Add
|
|
100
|
+
</Button>
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
@@ -9,6 +9,7 @@ import { HiOutlineCalendarDays, HiOutlineClipboardDocumentList, HiOutlineEnvelop
|
|
|
9
9
|
import { useRedirectIfUnauthenticated } from "@rapidmx/react-shared/auth/session.js";
|
|
10
10
|
import { stopImpersonating } from "@rapidmx/react-shared/mail/mailApi.js";
|
|
11
11
|
import useBranding from "@rapidmx/react-shared/branding/useBranding.js";
|
|
12
|
+
import { useIdleKeyTimeout } from "@rapidmx/react-shared/crypto/useIdleKeyTimeout.js";
|
|
12
13
|
import ComposeProvider from "../mail/compose/ComposeContext.js";
|
|
13
14
|
import BottomTabBar from "@rapidmx/react-shared/components/navigation/BottomTabBar.js";
|
|
14
15
|
import { BrandingFooter, BrandingHeader } from "./BrandingChrome.js";
|
|
@@ -84,6 +85,9 @@ export default function AppShell({
|
|
|
84
85
|
const { branding, iconSrc } = useBranding();
|
|
85
86
|
|
|
86
87
|
useRedirectIfUnauthenticated(userUid, authServerUrl);
|
|
88
|
+
// Mounted here, not scoped to Mail/Settings (the only shells that actually read unlocked keys),
|
|
89
|
+
// specifically so activity in *any* app resets the idle clock - see that hook's own doc comment.
|
|
90
|
+
useIdleKeyTimeout();
|
|
87
91
|
|
|
88
92
|
function handleSignOut() {
|
|
89
93
|
window.location.href = authServerUrl ?? "/";
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
+
import React, { useEffect, useState } from "react";
|
|
6
|
+
import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
|
|
7
|
+
import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
|
|
8
|
+
import Button from "@rapidmx/react-shared/components/buttons/Button.js";
|
|
9
|
+
import FormField from "@rapidmx/react-shared/components/forms/FormField.js";
|
|
10
|
+
import { enrollKey, getKeyVault, PublicKey } from "@rapidmx/react-shared/crypto/keyvaultApi.js";
|
|
11
|
+
import {
|
|
12
|
+
ENCRYPTION_PRIVATE_KEY_AAD_PURPOSE,
|
|
13
|
+
getUnlockedKeys,
|
|
14
|
+
unlockWithPassword,
|
|
15
|
+
} from "@rapidmx/react-shared/crypto/keySession.js";
|
|
16
|
+
import { buildAad, generateMasterKey, sealWithKey } from "@rapidmx/react-shared/crypto/masterKey.js";
|
|
17
|
+
import { buildPasswordWrap, buildRecoveryWraps } from "@rapidmx/react-shared/crypto/masterKeyWraps.js";
|
|
18
|
+
import { exportPrivateKeyPkcs8, generateKeyPairWithCsr } from "@rapidmx/react-shared/crypto/keys.js";
|
|
19
|
+
|
|
20
|
+
type Status = "checking" | "setup_password" | "enrolling" | "show_recovery_codes" | "unlock" | "unlocking" | "ready";
|
|
21
|
+
|
|
22
|
+
const MIN_PASSWORD_LENGTH = 8;
|
|
23
|
+
|
|
24
|
+
async function provisionEncryptionKey(
|
|
25
|
+
mailboxUid: string,
|
|
26
|
+
mailboxAddress: string,
|
|
27
|
+
password: string,
|
|
28
|
+
): Promise<{ recoveryCodes: string[] }> {
|
|
29
|
+
const mk = generateMasterKey();
|
|
30
|
+
const passwordWrap = await buildPasswordWrap(mailboxUid, mk, password);
|
|
31
|
+
const { wraps: recoveryWraps, codes: recoveryCodes } = await buildRecoveryWraps(mailboxUid, mk);
|
|
32
|
+
|
|
33
|
+
// Only the encryption key is provisioned here. The signing key's spec-required public-CA enrolment
|
|
34
|
+
// (RFC 8823 ACME automation) is a real but genuinely asynchronous flow (a live email round-trip with
|
|
35
|
+
// a public CA, likely minutes) - it's a deliberate opt-in action in Settings > Encryption
|
|
36
|
+
// ("Enable digital signatures"), not something to block first-sign-in mailbox setup on.
|
|
37
|
+
const { keyPair, csrPem } = await generateKeyPairWithCsr(mailboxAddress, "encrypt");
|
|
38
|
+
const privateKeyRaw = await exportPrivateKeyPkcs8(keyPair.privateKey);
|
|
39
|
+
const wrappedKeySealed = await sealWithKey(mk, privateKeyRaw, buildAad(mailboxUid, ENCRYPTION_PRIVATE_KEY_AAD_PURPOSE));
|
|
40
|
+
|
|
41
|
+
await enrollKey(mailboxUid, {
|
|
42
|
+
useType: "encrypt",
|
|
43
|
+
csr: csrPem,
|
|
44
|
+
wrappedKey: { ciphertext: wrappedKeySealed.ciphertext, nonce: wrappedKeySealed.nonce, algorithm: "AES-256-GCM" },
|
|
45
|
+
masterKeyWraps: [passwordWrap, ...recoveryWraps],
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return { recoveryCodes };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface KeyEnrollmentGateProps {
|
|
52
|
+
/** Undefined while the caller's mailbox hasn't resolved yet (or has none) - renders `children`
|
|
53
|
+
* unchanged in that case, so this component can be mounted unconditionally at a stable tree
|
|
54
|
+
* position (see this component's own doc comment for why that matters). */
|
|
55
|
+
mailboxUid?: string;
|
|
56
|
+
mailboxAddress?: string;
|
|
57
|
+
/** The mailbox's currently-published public keys (`Mailbox.keys`) - needed to unlock an
|
|
58
|
+
* already-enrolled vault (see `unlockWithPassword()`'s own signature), not just to provision a new
|
|
59
|
+
* one. Treated as empty when undefined - a mailbox with no public keys published yet has nothing to
|
|
60
|
+
* unlock, so this only affects the already-enrolled path. */
|
|
61
|
+
mailboxKeys?: PublicKey[];
|
|
62
|
+
children: React.ReactNode;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Gates a mailbox's normal content behind one-time E2E encryption key setup, per
|
|
67
|
+
* `specs/end-to-end_encryption.md`'s "Generate signing and encryption keypairs on the client's device on
|
|
68
|
+
* first sign-in." Rendered by `MailShell` wrapping its own returned content unconditionally, not only
|
|
69
|
+
* once a mailbox is resolved — mounting this component at a *different* tree position depending on
|
|
70
|
+
* `mailboxUid`'s readiness (e.g. only wrapping once ready, rendering bare content beforehand) would make
|
|
71
|
+
* `children` (real `AppShell` chrome) itself remount the moment `mailboxUid` resolves, tearing down any
|
|
72
|
+
* state/effects it had already started. Always wrapping keeps `AppShell` mounted continuously across
|
|
73
|
+
* that transition; this component simply passes `children` through untouched while `mailboxUid` is
|
|
74
|
+
* still unresolved, and only starts its own check once a real `mailboxUid` is supplied.
|
|
75
|
+
*
|
|
76
|
+
* A `getKeyVault()` failure (network error, server not yet wired up to serve this endpoint) also renders
|
|
77
|
+
* `children` unchanged rather than blocking mail entirely - encryption is optional and gradual by design
|
|
78
|
+
* (the spec's own "near zero frictionless experience" goal), not a hard prerequisite for reading mail.
|
|
79
|
+
*/
|
|
80
|
+
export default function KeyEnrollmentGate({ mailboxUid, mailboxAddress, mailboxKeys, children }: KeyEnrollmentGateProps) {
|
|
81
|
+
const [status, setStatus] = useState<Status>(mailboxUid ? "checking" : "ready");
|
|
82
|
+
const [password, setPassword] = useState("");
|
|
83
|
+
const [confirmPassword, setConfirmPassword] = useState("");
|
|
84
|
+
const [error, setError] = useState<string | null>(null);
|
|
85
|
+
const [recoveryCodes, setRecoveryCodes] = useState<string[]>([]);
|
|
86
|
+
const [codesSaved, setCodesSaved] = useState(false);
|
|
87
|
+
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
if (!mailboxUid) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
// A remount within the same browser session (e.g. navigating between pages) shouldn't re-prompt
|
|
93
|
+
// for a password the in-memory session store (`keySession.ts`) already has unwrapped - only a
|
|
94
|
+
// fresh session (reload, new tab, post-logout) has nothing there.
|
|
95
|
+
if (getUnlockedKeys(mailboxUid)) {
|
|
96
|
+
setStatus("ready");
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
let cancelled = false;
|
|
100
|
+
getKeyVault(mailboxUid)
|
|
101
|
+
.then((vault) => {
|
|
102
|
+
if (!cancelled) {
|
|
103
|
+
setStatus(vault.wrappedKeys.length > 0 ? "unlock" : "setup_password");
|
|
104
|
+
}
|
|
105
|
+
})
|
|
106
|
+
.catch(() => {
|
|
107
|
+
if (!cancelled) {
|
|
108
|
+
setStatus("ready");
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
return () => {
|
|
112
|
+
cancelled = true;
|
|
113
|
+
};
|
|
114
|
+
}, [mailboxUid]);
|
|
115
|
+
|
|
116
|
+
async function handleUnlock(e: React.FormEvent) {
|
|
117
|
+
e.preventDefault();
|
|
118
|
+
setError(null);
|
|
119
|
+
setStatus("unlocking");
|
|
120
|
+
try {
|
|
121
|
+
// Only reachable via "unlock", which the effect above only ever sets once mailboxUid was
|
|
122
|
+
// defined.
|
|
123
|
+
await unlockWithPassword(mailboxUid!, mailboxKeys ?? [], password);
|
|
124
|
+
setStatus("ready");
|
|
125
|
+
} catch {
|
|
126
|
+
// Deliberately generic - see `unlockWithPassword()`'s own doc comment: it throws the same way
|
|
127
|
+
// for "no password wrap enrolled" and "wrong password" today, and this UI has no way to tell
|
|
128
|
+
// those apart without leaking which is which to a potential attacker guessing passwords.
|
|
129
|
+
setError("Incorrect password.");
|
|
130
|
+
setStatus("unlock");
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async function handleSetPassword(e: React.FormEvent) {
|
|
135
|
+
e.preventDefault();
|
|
136
|
+
if (password.length < MIN_PASSWORD_LENGTH) {
|
|
137
|
+
setError(`Password must be at least ${MIN_PASSWORD_LENGTH} characters.`);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (password !== confirmPassword) {
|
|
141
|
+
setError("Passwords do not match.");
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
setError(null);
|
|
145
|
+
setStatus("enrolling");
|
|
146
|
+
try {
|
|
147
|
+
// Only reachable via "setup_password", which the effect above only ever sets once mailboxUid
|
|
148
|
+
// was defined (and mailboxAddress necessarily came with it - see KeyEnrollmentGateProps).
|
|
149
|
+
const { recoveryCodes: codes } = await provisionEncryptionKey(mailboxUid!, mailboxAddress!, password);
|
|
150
|
+
setRecoveryCodes(codes);
|
|
151
|
+
setStatus("show_recovery_codes");
|
|
152
|
+
} catch (err) {
|
|
153
|
+
setError(err instanceof ApiRequestError ? err.message : "Could not set up encryption for this mailbox.");
|
|
154
|
+
setStatus("setup_password");
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (status === "checking") {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (status === "unlock" || status === "unlocking") {
|
|
163
|
+
const unlocking = status === "unlocking";
|
|
164
|
+
return (
|
|
165
|
+
<div className="min-h-screen flex items-center justify-center p-8 bg-surface-alt">
|
|
166
|
+
<div className="w-full max-w-md bg-surface border border-border rounded-md p-8">
|
|
167
|
+
<h1 className="text-lg font-bold mb-2">Unlock your mailbox</h1>
|
|
168
|
+
<p className="text-sm text-text-muted mb-5">
|
|
169
|
+
Enter your encryption password to unlock signing and reading protected mail this session.
|
|
170
|
+
</p>
|
|
171
|
+
{error && <Alert>{error}</Alert>}
|
|
172
|
+
<form onSubmit={handleUnlock}>
|
|
173
|
+
<FormField label="Encryption password" htmlFor="key-unlock-password">
|
|
174
|
+
<input
|
|
175
|
+
id="key-unlock-password"
|
|
176
|
+
type="password"
|
|
177
|
+
className="w-full text-sm border border-border rounded-sm py-1.5 px-2 bg-surface"
|
|
178
|
+
value={password}
|
|
179
|
+
onChange={(e) => setPassword(e.target.value)}
|
|
180
|
+
disabled={unlocking}
|
|
181
|
+
autoComplete="current-password"
|
|
182
|
+
/>
|
|
183
|
+
</FormField>
|
|
184
|
+
<Button type="submit" loading={unlocking} disabled={unlocking}>
|
|
185
|
+
Unlock
|
|
186
|
+
</Button>
|
|
187
|
+
</form>
|
|
188
|
+
</div>
|
|
189
|
+
</div>
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (status === "setup_password" || status === "enrolling") {
|
|
194
|
+
const enrolling = status === "enrolling";
|
|
195
|
+
return (
|
|
196
|
+
<div className="min-h-screen flex items-center justify-center p-8 bg-surface-alt">
|
|
197
|
+
<div className="w-full max-w-md bg-surface border border-border rounded-md p-8">
|
|
198
|
+
<h1 className="text-lg font-bold mb-2">Protect your mailbox</h1>
|
|
199
|
+
<p className="text-sm text-text-muted mb-5">
|
|
200
|
+
Choose a password to protect your encryption keys. This is separate from your sign-in
|
|
201
|
+
password and is never sent to the server.
|
|
202
|
+
</p>
|
|
203
|
+
{error && <Alert>{error}</Alert>}
|
|
204
|
+
<form onSubmit={handleSetPassword}>
|
|
205
|
+
<FormField label="Encryption password" htmlFor="key-enrollment-password">
|
|
206
|
+
<input
|
|
207
|
+
id="key-enrollment-password"
|
|
208
|
+
type="password"
|
|
209
|
+
className="w-full text-sm border border-border rounded-sm py-1.5 px-2 bg-surface"
|
|
210
|
+
value={password}
|
|
211
|
+
onChange={(e) => setPassword(e.target.value)}
|
|
212
|
+
disabled={enrolling}
|
|
213
|
+
autoComplete="new-password"
|
|
214
|
+
/>
|
|
215
|
+
</FormField>
|
|
216
|
+
<FormField label="Confirm password" htmlFor="key-enrollment-password-confirm">
|
|
217
|
+
<input
|
|
218
|
+
id="key-enrollment-password-confirm"
|
|
219
|
+
type="password"
|
|
220
|
+
className="w-full text-sm border border-border rounded-sm py-1.5 px-2 bg-surface"
|
|
221
|
+
value={confirmPassword}
|
|
222
|
+
onChange={(e) => setConfirmPassword(e.target.value)}
|
|
223
|
+
disabled={enrolling}
|
|
224
|
+
autoComplete="new-password"
|
|
225
|
+
/>
|
|
226
|
+
</FormField>
|
|
227
|
+
<Button type="submit" loading={enrolling} disabled={enrolling}>
|
|
228
|
+
Continue
|
|
229
|
+
</Button>
|
|
230
|
+
</form>
|
|
231
|
+
</div>
|
|
232
|
+
</div>
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (status === "show_recovery_codes") {
|
|
237
|
+
return (
|
|
238
|
+
<div className="min-h-screen flex items-center justify-center p-8 bg-surface-alt">
|
|
239
|
+
<div className="w-full max-w-md bg-surface border border-border rounded-md p-8">
|
|
240
|
+
<h1 className="text-lg font-bold mb-2">Save your recovery codes</h1>
|
|
241
|
+
<p className="text-sm text-text-muted mb-5">
|
|
242
|
+
If you lose your password, these codes are the only way to recover your encrypted mail.
|
|
243
|
+
Each code can be used once. Store them somewhere safe — they will not be shown again.
|
|
244
|
+
</p>
|
|
245
|
+
<ul className="grid grid-cols-2 gap-2 mb-5 font-mono text-sm">
|
|
246
|
+
{recoveryCodes.map((code) => (
|
|
247
|
+
<li key={code} className="bg-surface-alt rounded-sm py-1.5 px-2 text-center">
|
|
248
|
+
{code}
|
|
249
|
+
</li>
|
|
250
|
+
))}
|
|
251
|
+
</ul>
|
|
252
|
+
<label className="flex items-center gap-2 text-sm mb-4">
|
|
253
|
+
<input type="checkbox" checked={codesSaved} onChange={(e) => setCodesSaved(e.target.checked)} />
|
|
254
|
+
I have saved these recovery codes in a safe place.
|
|
255
|
+
</label>
|
|
256
|
+
<Button type="button" disabled={!codesSaved} onClick={() => setStatus("ready")}>
|
|
257
|
+
Continue
|
|
258
|
+
</Button>
|
|
259
|
+
</div>
|
|
260
|
+
</div>
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return <>{children}</>;
|
|
265
|
+
}
|
|
@@ -6,6 +6,7 @@ import React, { useEffect, useState } from "react";
|
|
|
6
6
|
import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
|
|
7
7
|
import { Attachment, Folder, Message, getMessage, listAttachments, setMessageRead } from "@rapidmx/react-shared/mail/mailApi.js";
|
|
8
8
|
import { ConversationSummary } from "@rapidmx/react-shared/mail/conversationsApi.js";
|
|
9
|
+
import { Label } from "@rapidmx/react-shared/mail/labelsApi.js";
|
|
9
10
|
import MessageDetailPane from "./MessageDetailPane.js";
|
|
10
11
|
import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
|
|
11
12
|
|
|
@@ -15,6 +16,9 @@ export interface ConversationThreadPaneProps {
|
|
|
15
16
|
* Sent Items copy of its reply), so each message's own recall eligibility is looked up individually
|
|
16
17
|
* against its own `folderUid` rather than assuming one folder for the whole thread. */
|
|
17
18
|
folders: Folder[];
|
|
19
|
+
/** The mailbox's labels, fetched once by the parent (`apps/www/index.tsx`) and passed through to
|
|
20
|
+
* every expanded message's own `MessageDetailPane` — see that component's own `labels` prop. */
|
|
21
|
+
labels?: Label[];
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
/**
|
|
@@ -25,7 +29,7 @@ export interface ConversationThreadPaneProps {
|
|
|
25
29
|
* lightweight summary, since mounting a full `MessageDetailPane` (and its iframe) for every message in
|
|
26
30
|
* a long thread up front would be wasteful.
|
|
27
31
|
*/
|
|
28
|
-
export default function ConversationThreadPane({ conversation, folders }: ConversationThreadPaneProps) {
|
|
32
|
+
export default function ConversationThreadPane({ conversation, folders, labels }: ConversationThreadPaneProps) {
|
|
29
33
|
const [messages, setMessages] = useState<Record<string, Message>>({});
|
|
30
34
|
const [attachmentsByUid, setAttachmentsByUid] = useState<Record<string, Attachment[]>>({});
|
|
31
35
|
const [expandedUids, setExpandedUids] = useState<Set<string>>(new Set());
|
|
@@ -165,6 +169,9 @@ export default function ConversationThreadPane({ conversation, folders }: Conver
|
|
|
165
169
|
isInbox={folders.find((f) => f.uid === message.folderUid)?.type === "inbox"}
|
|
166
170
|
onClassified={(updated) => setMessages((prev) => ({ ...prev, [uid]: updated }))}
|
|
167
171
|
onReceiptHandled={(updated) => setMessages((prev) => ({ ...prev, [uid]: updated }))}
|
|
172
|
+
onArchived={(updated) => setMessages((prev) => ({ ...prev, [uid]: updated }))}
|
|
173
|
+
labels={labels}
|
|
174
|
+
onLabelsChanged={(updated) => setMessages((prev) => ({ ...prev, [uid]: updated }))}
|
|
168
175
|
/>
|
|
169
176
|
</div>
|
|
170
177
|
);
|