@rapidmx/web-client 0.15.1 → 0.17.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.
- package/README.md +381 -373
- package/apps/admin/branding/index.tsx +39 -39
- package/apps/admin/data-requests/index.tsx +482 -480
- package/apps/admin/distribution-lists/new/index.tsx +3 -1
- package/apps/admin/domains/[uid].tsx +166 -164
- package/apps/admin/domains/new/index.tsx +3 -1
- package/apps/admin/escrow-scopes/[uid].tsx +350 -348
- package/apps/admin/escrow-scopes/new/index.tsx +3 -1
- package/apps/admin/index.tsx +129 -124
- package/apps/admin/mailboxes/[uid].tsx +271 -224
- package/apps/admin/mailboxes/new/index.tsx +30 -28
- package/apps/admin/plugins/index.tsx +15 -15
- package/apps/admin/retention-policy/index.tsx +39 -39
- package/apps/admin/signing-certificates/index.tsx +343 -343
- package/apps/admin/transport-rules/new/index.tsx +3 -1
- package/apps/escrow/audit-log/index.tsx +196 -196
- package/apps/escrow/matters/[uid].tsx +621 -621
- package/apps/escrow/matters/new/index.tsx +3 -1
- package/apps/shared/auth/adminAccess.ts +99 -99
- package/apps/shared/components/admin/layout/AdminShell.tsx +381 -378
- package/apps/shared/components/admin/mailboxes/EraseLeftoverDataDialog.tsx +238 -0
- package/apps/shared/components/admin/mailboxes/EscrowScopeCard.tsx +152 -152
- package/apps/shared/components/admin/mailboxes/LeftoverMailboxesSection.tsx +194 -0
- package/apps/shared/components/admin/settings/BrandingForm.tsx +423 -423
- package/apps/shared/components/admin/settings/EncryptionPolicyForm.tsx +119 -119
- package/apps/shared/components/admin/settings/MailboxCreateForm.tsx +50 -3
- package/apps/shared/components/admin/settings/MailboxPolicyForm.tsx +198 -198
- package/apps/shared/components/admin/settings/PluginsManager.tsx +1545 -1545
- package/apps/shared/components/admin/settings/RetentionPolicyForm.tsx +182 -182
- package/apps/shared/components/admin/setup/EscrowSetupStep.tsx +288 -288
- package/apps/shared/components/admin/setup/SetupWizard.tsx +446 -444
- package/apps/shared/components/admin/usePagedList.tsx +129 -129
- package/apps/shared/components/calendar/EventEditor.tsx +5 -10
- package/apps/shared/components/calendar/EventFormParts.tsx +16 -47
- package/apps/shared/components/calendar/EventModal.tsx +206 -206
- package/apps/shared/components/calendar/GuestInput.tsx +100 -0
- package/apps/shared/components/calendar/MonthView.tsx +185 -185
- package/apps/shared/components/calendar/RecurrenceEditor.tsx +227 -227
- package/apps/shared/components/calendar/RequestChangeForm.tsx +23 -54
- package/apps/shared/components/calendar/SplitDayView.tsx +144 -144
- package/apps/shared/components/calendar/TimeGridView.tsx +246 -246
- package/apps/shared/components/calendar/allDay.ts +124 -124
- package/apps/shared/components/calendar/eventForm.ts +2 -2
- package/apps/shared/components/calendar/eventFormat.ts +49 -22
- package/apps/shared/components/calendar/layout/CalendarShell.tsx +201 -200
- package/apps/shared/components/contacts/ContactForm.tsx +383 -383
- package/apps/shared/components/contacts/ContactsSidebar.tsx +1 -1
- package/apps/shared/components/contacts/ContactsToolbar.tsx +103 -98
- package/apps/shared/components/contacts/layout/ContactsShell.tsx +218 -216
- package/apps/shared/components/escrow/layout/EscrowShell.tsx +155 -155
- package/apps/shared/components/layout/AppShell.tsx +461 -480
- package/apps/shared/components/layout/FloatingActionButton.tsx +31 -0
- package/apps/shared/components/layout/KeyEnrollmentGate.tsx +398 -398
- package/apps/shared/components/layout/MailboxProvisioning.tsx +168 -168
- package/apps/shared/components/layout/ResponsiveToolbar.tsx +315 -315
- package/apps/shared/components/layout/ThemeSwitch.tsx +84 -84
- package/apps/shared/components/layout/UserMenu.tsx +439 -424
- package/apps/shared/components/mail/ConversationList.tsx +323 -323
- package/apps/shared/components/mail/ConversationThreadPane.tsx +613 -491
- package/apps/shared/components/mail/EmptyFolderBar.tsx +41 -0
- package/apps/shared/components/mail/MailSelectionBar.tsx +240 -227
- package/apps/shared/components/mail/MenuButton.tsx +31 -11
- package/apps/shared/components/mail/MessageDetailPane.tsx +1757 -1559
- package/apps/shared/components/mail/PermanentDeleteDialog.tsx +47 -0
- package/apps/shared/components/mail/compose/ComposeContext.tsx +312 -312
- package/apps/shared/components/mail/compose/ComposeToolbar.tsx +422 -422
- package/apps/shared/components/mail/compose/ComposeWindow.tsx +1681 -1677
- package/apps/shared/components/mail/compose/RecipientInput.tsx +54 -11
- package/apps/shared/components/mail/compose/RichTextEditor.tsx +147 -147
- package/apps/shared/components/mail/compose/composeFlushRegistry.ts +60 -60
- package/apps/shared/components/mail/compose/quotedBody.ts +161 -161
- package/apps/shared/components/mail/layout/FolderBadgeChip.tsx +21 -0
- package/apps/shared/components/mail/layout/MailShell.tsx +161 -134
- package/apps/shared/components/mail/layout/SidebarSection.tsx +66 -0
- package/apps/shared/components/mail/reading/MessageMoreMenu.tsx +258 -0
- package/apps/shared/components/mail/reading/MessageSourceDialog.tsx +79 -0
- package/apps/shared/components/mail/reading/PendingMessageCard.tsx +68 -0
- package/apps/shared/components/mail/reading/messageExport.ts +59 -0
- package/apps/shared/components/mail/reading/printMessage.ts +99 -0
- package/apps/shared/components/mail/reading/useMessageActions.ts +443 -0
- package/apps/shared/components/mail/verificationSeals.ts +125 -125
- package/apps/shared/components/rules/RuleBuilder.tsx +311 -311
- package/apps/shared/components/settings/SigningCertificateCard.tsx +344 -344
- package/apps/shared/components/settings/layout/SettingsShell.tsx +257 -254
- package/apps/shared/components/tasks/TasksSidebar.tsx +1 -1
- package/apps/shared/components/tasks/layout/TasksShell.tsx +219 -217
- package/apps/shared/keyboard/GlobalShortcuts.tsx +51 -51
- package/apps/shared/keyboard/ShortcutProvider.tsx +62 -62
- package/apps/shared/keyboard/ShortcutsDialog.tsx +84 -84
- package/apps/shared/keyboard/dispatch.ts +124 -124
- package/apps/shared/keyboard/format.ts +89 -89
- package/apps/shared/keyboard/keymap.ts +114 -114
- package/apps/shared/keyboard/registry.ts +65 -65
- package/apps/shared/keyboard/targets.ts +79 -79
- package/apps/shared/mail/folderCounts.ts +17 -0
- package/apps/shared/mail/folderOfType.ts +49 -0
- package/apps/shared/mail/folderTree.ts +143 -143
- package/apps/shared/mail/listAllPages.ts +39 -39
- package/apps/shared/mail/newMailNotifications.ts +171 -171
- package/apps/shared/mail/outbox/outgoingReplies.ts +192 -0
- package/apps/shared/mail/outbox/sendJob.ts +19 -1
- package/apps/shared/mail/outbox/sendOutcomes.ts +13 -4
- package/apps/shared/mail/permanentDelete.ts +160 -0
- package/apps/shared/mail/primaryMailbox.ts +71 -0
- package/apps/shared/mail/reportNotices.ts +66 -0
- package/apps/shared/mail/senderBlocking.ts +141 -0
- package/apps/shared/mail/useCollapsedSections.ts +146 -0
- package/apps/shared/mail/useMailConnection.ts +205 -203
- package/apps/shared/mail/useMailLiveUpdates.ts +277 -277
- package/apps/shared/mail/useMailboxUpdateAccess.ts +60 -0
- package/apps/shared/mail/useMarkMessageRead.ts +47 -47
- package/apps/shared/mail/useNewMailNotifications.ts +178 -178
- package/apps/shared/mail/usePermanentDelete.tsx +160 -0
- package/apps/shared/navigation/frameContext.tsx +1 -1
- package/apps/shared/navigation/index.ts +43 -0
- package/apps/shared/navigation/pageTitle.ts +19 -0
- package/apps/shared/notifications/store.ts +560 -560
- package/apps/shared/search/LocalIndexLifecycle.tsx +114 -114
- package/apps/shared/search/crossMailboxSearch.ts +169 -0
- package/apps/shared/search/localIndexBuilder.ts +481 -481
- package/apps/shared/signing/enrollmentStorage.ts +33 -33
- package/apps/shared/signing/enrollmentTracker.ts +385 -385
- package/apps/shared/signing/enrollmentView.ts +251 -251
- package/apps/shared/signing/useNow.ts +19 -19
- package/apps/shared/signing/useSigningEnrollmentWatcher.ts +90 -90
- package/apps/shared/styles/app.css +396 -386
- package/apps/www/_shell.tsx +82 -0
- package/apps/www/calendar/index.tsx +581 -571
- package/apps/www/contacts/[uid].tsx +112 -109
- package/apps/www/contacts/index.tsx +14 -3
- package/apps/www/index.tsx +2962 -2479
- package/apps/www/messages/[uid].tsx +139 -135
- package/apps/www/settings/appearance/index.tsx +5 -2
- package/apps/www/settings/auto-reply/index.tsx +136 -133
- package/apps/www/settings/blocked-senders/index.tsx +303 -0
- package/apps/www/settings/encryption/index.tsx +1290 -1287
- package/apps/www/settings/filters/[uid].tsx +179 -176
- package/apps/www/settings/filters/index.tsx +105 -102
- package/apps/www/settings/filters/new/index.tsx +165 -140
- package/apps/www/settings/labels/index.tsx +207 -204
- package/apps/www/settings/privacy/index.tsx +495 -492
- package/apps/www/settings/profile/index.tsx +251 -248
- package/apps/www/settings/read-receipts/index.tsx +150 -147
- package/apps/www/settings/sharing/index.tsx +259 -256
- package/apps/www/settings/signatures/[uid].tsx +175 -172
- package/apps/www/settings/signatures/index.tsx +91 -88
- package/apps/www/settings/signatures/new/index.tsx +138 -135
- package/apps/www/tasks/index.tsx +654 -649
- package/dist/apps/admin/data-requests/index.js +1 -1
- package/dist/apps/admin/distribution-lists/new/index.js +3 -1
- package/dist/apps/admin/domains/[uid].js +3 -1
- package/dist/apps/admin/domains/new/index.js +3 -1
- package/dist/apps/admin/escrow-scopes/[uid].js +3 -1
- package/dist/apps/admin/escrow-scopes/new/index.js +3 -1
- package/dist/apps/admin/index.js +5 -2
- package/dist/apps/admin/mailboxes/[uid].js +15 -3
- package/dist/apps/admin/mailboxes/new/index.js +3 -1
- package/dist/apps/admin/transport-rules/new/index.js +3 -1
- package/dist/apps/escrow/matters/new/index.js +3 -1
- package/dist/apps/shared/components/admin/layout/AdminShell.js +6 -3
- package/dist/apps/shared/components/admin/mailboxes/EraseLeftoverDataDialog.d.ts +35 -0
- package/dist/apps/shared/components/admin/mailboxes/EraseLeftoverDataDialog.js +115 -0
- package/dist/apps/shared/components/admin/mailboxes/LeftoverMailboxesSection.d.ts +16 -0
- package/dist/apps/shared/components/admin/mailboxes/LeftoverMailboxesSection.js +92 -0
- package/dist/apps/shared/components/admin/settings/BrandingForm.js +3 -3
- package/dist/apps/shared/components/admin/settings/MailboxCreateForm.js +25 -3
- package/dist/apps/shared/components/admin/setup/SetupWizard.js +3 -1
- package/dist/apps/shared/components/calendar/EventEditor.js +5 -10
- package/dist/apps/shared/components/calendar/EventFormParts.d.ts +3 -2
- package/dist/apps/shared/components/calendar/EventFormParts.js +5 -16
- package/dist/apps/shared/components/calendar/GuestInput.d.ts +45 -0
- package/dist/apps/shared/components/calendar/GuestInput.js +30 -0
- package/dist/apps/shared/components/calendar/RequestChangeForm.js +11 -22
- package/dist/apps/shared/components/calendar/eventForm.d.ts +2 -2
- package/dist/apps/shared/components/calendar/eventFormat.d.ts +21 -8
- package/dist/apps/shared/components/calendar/eventFormat.js +50 -23
- package/dist/apps/shared/components/calendar/layout/CalendarShell.js +5 -4
- package/dist/apps/shared/components/contacts/ContactsSidebar.js +1 -1
- package/dist/apps/shared/components/contacts/ContactsToolbar.d.ts +3 -1
- package/dist/apps/shared/components/contacts/ContactsToolbar.js +4 -2
- package/dist/apps/shared/components/contacts/layout/ContactsShell.js +7 -5
- package/dist/apps/shared/components/layout/AppShell.d.ts +8 -11
- package/dist/apps/shared/components/layout/AppShell.js +24 -33
- package/dist/apps/shared/components/layout/FloatingActionButton.d.ts +13 -0
- package/dist/apps/shared/components/layout/FloatingActionButton.js +9 -0
- package/dist/apps/shared/components/layout/UserMenu.d.ts +4 -1
- package/dist/apps/shared/components/layout/UserMenu.js +6 -5
- package/dist/apps/shared/components/mail/ConversationThreadPane.js +127 -22
- package/dist/apps/shared/components/mail/EmptyFolderBar.d.ts +18 -0
- package/dist/apps/shared/components/mail/EmptyFolderBar.js +10 -0
- package/dist/apps/shared/components/mail/MailSelectionBar.d.ts +14 -4
- package/dist/apps/shared/components/mail/MailSelectionBar.js +11 -13
- package/dist/apps/shared/components/mail/MenuButton.d.ts +9 -2
- package/dist/apps/shared/components/mail/MenuButton.js +15 -11
- package/dist/apps/shared/components/mail/MessageDetailPane.d.ts +5 -0
- package/dist/apps/shared/components/mail/MessageDetailPane.js +147 -7
- package/dist/apps/shared/components/mail/PermanentDeleteDialog.d.ts +19 -0
- package/dist/apps/shared/components/mail/PermanentDeleteDialog.js +11 -0
- package/dist/apps/shared/components/mail/compose/ComposeWindow.js +8 -4
- package/dist/apps/shared/components/mail/compose/RecipientInput.d.ts +21 -1
- package/dist/apps/shared/components/mail/compose/RecipientInput.js +18 -10
- package/dist/apps/shared/components/mail/layout/FolderBadgeChip.d.ts +6 -0
- package/dist/apps/shared/components/mail/layout/FolderBadgeChip.js +9 -0
- package/dist/apps/shared/components/mail/layout/MailShell.d.ts +16 -7
- package/dist/apps/shared/components/mail/layout/MailShell.js +78 -65
- package/dist/apps/shared/components/mail/layout/SidebarSection.d.ts +23 -0
- package/dist/apps/shared/components/mail/layout/SidebarSection.js +16 -0
- package/dist/apps/shared/components/mail/reading/MessageMoreMenu.d.ts +56 -0
- package/dist/apps/shared/components/mail/reading/MessageMoreMenu.js +153 -0
- package/dist/apps/shared/components/mail/reading/MessageSourceDialog.d.ts +27 -0
- package/dist/apps/shared/components/mail/reading/MessageSourceDialog.js +27 -0
- package/dist/apps/shared/components/mail/reading/PendingMessageCard.d.ts +14 -0
- package/dist/apps/shared/components/mail/reading/PendingMessageCard.js +16 -0
- package/dist/apps/shared/components/mail/reading/messageExport.d.ts +19 -0
- package/dist/apps/shared/components/mail/reading/messageExport.js +51 -0
- package/dist/apps/shared/components/mail/reading/printMessage.d.ts +30 -0
- package/dist/apps/shared/components/mail/reading/printMessage.js +70 -0
- package/dist/apps/shared/components/mail/reading/useMessageActions.d.ts +57 -0
- package/dist/apps/shared/components/mail/reading/useMessageActions.js +366 -0
- package/dist/apps/shared/components/settings/layout/SettingsShell.js +10 -7
- package/dist/apps/shared/components/tasks/TasksSidebar.js +1 -1
- package/dist/apps/shared/components/tasks/layout/TasksShell.js +7 -5
- package/dist/apps/shared/keyboard/GlobalShortcuts.js +1 -1
- package/dist/apps/shared/mail/folderCounts.d.ts +10 -0
- package/dist/apps/shared/mail/folderCounts.js +12 -0
- package/dist/apps/shared/mail/folderOfType.d.ts +13 -0
- package/dist/apps/shared/mail/folderOfType.js +40 -0
- package/dist/apps/shared/mail/outbox/outgoingReplies.d.ts +80 -0
- package/dist/apps/shared/mail/outbox/outgoingReplies.js +131 -0
- package/dist/apps/shared/mail/outbox/sendJob.d.ts +5 -1
- package/dist/apps/shared/mail/outbox/sendJob.js +14 -1
- package/dist/apps/shared/mail/outbox/sendOutcomes.js +13 -4
- package/dist/apps/shared/mail/permanentDelete.d.ts +62 -0
- package/dist/apps/shared/mail/permanentDelete.js +127 -0
- package/dist/apps/shared/mail/primaryMailbox.d.ts +29 -0
- package/dist/apps/shared/mail/primaryMailbox.js +61 -0
- package/dist/apps/shared/mail/reportNotices.d.ts +21 -0
- package/dist/apps/shared/mail/reportNotices.js +47 -0
- package/dist/apps/shared/mail/senderBlocking.d.ts +26 -0
- package/dist/apps/shared/mail/senderBlocking.js +92 -0
- package/dist/apps/shared/mail/useCollapsedSections.d.ts +32 -0
- package/dist/apps/shared/mail/useCollapsedSections.js +110 -0
- package/dist/apps/shared/mail/useMailConnection.js +3 -1
- package/dist/apps/shared/mail/useMailboxUpdateAccess.d.ts +11 -0
- package/dist/apps/shared/mail/useMailboxUpdateAccess.js +52 -0
- package/dist/apps/shared/mail/usePermanentDelete.d.ts +35 -0
- package/dist/apps/shared/mail/usePermanentDelete.js +96 -0
- package/dist/apps/shared/navigation/frameContext.d.ts +1 -1
- package/dist/apps/shared/navigation/index.d.ts +16 -0
- package/dist/apps/shared/navigation/index.js +34 -0
- package/dist/apps/shared/navigation/pageTitle.d.ts +11 -0
- package/dist/apps/shared/navigation/pageTitle.js +12 -0
- package/dist/apps/shared/search/crossMailboxSearch.d.ts +72 -0
- package/dist/apps/shared/search/crossMailboxSearch.js +136 -0
- package/dist/apps/shared/styles/app.css +396 -386
- package/dist/apps/www/_shell.d.ts +26 -0
- package/dist/apps/www/_shell.js +31 -0
- package/dist/apps/www/calendar/index.d.ts +7 -2
- package/dist/apps/www/calendar/index.js +7 -4
- package/dist/apps/www/contacts/[uid].d.ts +14 -3
- package/dist/apps/www/contacts/[uid].js +5 -3
- package/dist/apps/www/contacts/index.d.ts +7 -2
- package/dist/apps/www/contacts/index.js +8 -4
- package/dist/apps/www/index.d.ts +7 -2
- package/dist/apps/www/index.js +542 -207
- package/dist/apps/www/messages/[uid].d.ts +14 -3
- package/dist/apps/www/messages/[uid].js +7 -5
- package/dist/apps/www/settings/appearance/index.d.ts +8 -2
- package/dist/apps/www/settings/appearance/index.js +4 -2
- package/dist/apps/www/settings/auto-reply/index.d.ts +7 -2
- package/dist/apps/www/settings/auto-reply/index.js +4 -2
- package/dist/apps/www/settings/blocked-senders/index.d.ts +9 -0
- package/dist/apps/www/settings/blocked-senders/index.js +134 -0
- package/dist/apps/www/settings/encryption/index.d.ts +7 -2
- package/dist/apps/www/settings/encryption/index.js +4 -2
- package/dist/apps/www/settings/filters/[uid].d.ts +7 -2
- package/dist/apps/www/settings/filters/[uid].js +4 -2
- package/dist/apps/www/settings/filters/index.d.ts +7 -2
- package/dist/apps/www/settings/filters/index.js +4 -2
- package/dist/apps/www/settings/filters/new/index.d.ts +7 -2
- package/dist/apps/www/settings/filters/new/index.js +28 -5
- package/dist/apps/www/settings/labels/index.d.ts +7 -2
- package/dist/apps/www/settings/labels/index.js +4 -2
- package/dist/apps/www/settings/privacy/index.d.ts +7 -2
- package/dist/apps/www/settings/privacy/index.js +4 -2
- package/dist/apps/www/settings/profile/index.d.ts +7 -2
- package/dist/apps/www/settings/profile/index.js +4 -2
- package/dist/apps/www/settings/read-receipts/index.d.ts +7 -2
- package/dist/apps/www/settings/read-receipts/index.js +4 -2
- package/dist/apps/www/settings/sharing/index.d.ts +7 -2
- package/dist/apps/www/settings/sharing/index.js +4 -2
- package/dist/apps/www/settings/signatures/[uid].d.ts +7 -2
- package/dist/apps/www/settings/signatures/[uid].js +4 -2
- package/dist/apps/www/settings/signatures/index.d.ts +7 -2
- package/dist/apps/www/settings/signatures/index.js +4 -2
- package/dist/apps/www/settings/signatures/new/index.d.ts +7 -2
- package/dist/apps/www/settings/signatures/new/index.js +5 -3
- package/dist/apps/www/tasks/index.d.ts +7 -2
- package/dist/apps/www/tasks/index.js +5 -3
- package/package.json +4 -2
- package/apps/shared/navigation/AppRouter.tsx +0 -300
- package/apps/shared/navigation/idle.ts +0 -45
- package/apps/shared/navigation/routerContext.tsx +0 -83
- package/apps/shared/navigation/routes.ts +0 -72
- package/apps/www/_routedPage.tsx +0 -24
- package/apps/www/_routes.ts +0 -37
- package/dist/apps/shared/navigation/AppRouter.d.ts +0 -52
- package/dist/apps/shared/navigation/AppRouter.js +0 -242
- package/dist/apps/shared/navigation/idle.d.ts +0 -14
- package/dist/apps/shared/navigation/idle.js +0 -43
- package/dist/apps/shared/navigation/routerContext.d.ts +0 -37
- package/dist/apps/shared/navigation/routerContext.js +0 -56
- package/dist/apps/shared/navigation/routes.d.ts +0 -32
- package/dist/apps/shared/navigation/routes.js +0 -37
- package/dist/apps/www/_routedPage.d.ts +0 -12
- package/dist/apps/www/_routedPage.js +0 -19
- package/dist/apps/www/_routes.d.ts +0 -11
- package/dist/apps/www/_routes.js +0 -31
|
@@ -1,398 +1,398 @@
|
|
|
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, VaultAlreadyInitializedError } from "@rapidmx/react-shared/crypto/keyvaultApi.js";
|
|
11
|
-
import { UnopenableKeysNotice, unlockErrorMessage } from "./UnlockPromptProvider.js";
|
|
12
|
-
import { FrameTakeover } from "../../navigation/frameContext.js";
|
|
13
|
-
import { RecoveryFollowUp, RecoveryFollowUpModal, UnlockModeToggle, startRecoveryUnlock } from "./RecoveryCodeUnlock.js";
|
|
14
|
-
import {
|
|
15
|
-
ENCRYPTION_PRIVATE_KEY_AAD_PURPOSE,
|
|
16
|
-
getUnlockedKeys,
|
|
17
|
-
unlockWithPassword,
|
|
18
|
-
type UnlockResult,
|
|
19
|
-
} from "@rapidmx/react-shared/crypto/keySession.js";
|
|
20
|
-
import { buildAad, generateMasterKey, sealWithKey } from "@rapidmx/react-shared/crypto/masterKey.js";
|
|
21
|
-
import { buildPasswordWrap, buildRecoveryWraps } from "@rapidmx/react-shared/crypto/masterKeyWraps.js";
|
|
22
|
-
import { exportPrivateKeyPkcs8, generateKeyPairWithCsr } from "@rapidmx/react-shared/crypto/keys.js";
|
|
23
|
-
|
|
24
|
-
type Status = "checking" | "setup_password" | "enrolling" | "already_set_up" | "show_recovery_codes" | "unlock" | "unlocking" | "ready";
|
|
25
|
-
|
|
26
|
-
const MIN_PASSWORD_LENGTH = 8;
|
|
27
|
-
|
|
28
|
-
async function provisionEncryptionKey(
|
|
29
|
-
mailboxUid: string,
|
|
30
|
-
mailboxAddress: string,
|
|
31
|
-
password: string,
|
|
32
|
-
): Promise<{ recoveryCodes: string[] }> {
|
|
33
|
-
const mk = generateMasterKey();
|
|
34
|
-
const passwordWrap = await buildPasswordWrap(mailboxUid, mk, password);
|
|
35
|
-
const { wraps: recoveryWraps, codes: recoveryCodes } = await buildRecoveryWraps(mailboxUid, mk);
|
|
36
|
-
|
|
37
|
-
// Only the encryption key is provisioned here. The signing key's spec-required public-CA enrolment
|
|
38
|
-
// (RFC 8823 ACME automation) is a real but genuinely asynchronous flow (a live email round-trip with
|
|
39
|
-
// a public CA, likely minutes) - it's a deliberate opt-in action in Settings > Encryption
|
|
40
|
-
// ("Enable digital signatures"), not something to block first-sign-in mailbox setup on.
|
|
41
|
-
const { keyPair, csrPem } = await generateKeyPairWithCsr(mailboxAddress, "encrypt");
|
|
42
|
-
const privateKeyRaw = await exportPrivateKeyPkcs8(keyPair.privateKey);
|
|
43
|
-
const wrappedKeySealed = await sealWithKey(mk, privateKeyRaw, buildAad(mailboxUid, ENCRYPTION_PRIVATE_KEY_AAD_PURPOSE));
|
|
44
|
-
|
|
45
|
-
await enrollKey(mailboxUid, {
|
|
46
|
-
useType: "encrypt",
|
|
47
|
-
csr: csrPem,
|
|
48
|
-
wrappedKey: { ciphertext: wrappedKeySealed.ciphertext, nonce: wrappedKeySealed.nonce, algorithm: "AES-256-GCM" },
|
|
49
|
-
masterKeyWraps: [passwordWrap, ...recoveryWraps],
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
return { recoveryCodes };
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface KeyEnrollmentGateProps {
|
|
56
|
-
/** Undefined while the caller's mailbox hasn't resolved yet (or has none) - renders `children`
|
|
57
|
-
* unchanged in that case, so this component can be mounted unconditionally at a stable tree
|
|
58
|
-
* position (see this component's own doc comment for why that matters). */
|
|
59
|
-
mailboxUid?: string;
|
|
60
|
-
mailboxAddress?: string;
|
|
61
|
-
/** The mailbox's currently-published public keys (`Mailbox.keys`) - needed to unlock an
|
|
62
|
-
* already-enrolled vault (see `unlockWithPassword()`'s own signature), not just to provision a new
|
|
63
|
-
* one. Treated as empty when undefined - a mailbox with no public keys published yet has nothing to
|
|
64
|
-
* unlock, so this only affects the already-enrolled path. */
|
|
65
|
-
mailboxKeys?: PublicKey[];
|
|
66
|
-
/**
|
|
67
|
-
* `true` (default) preserves this component's original behavior: a mailbox with an existing vault
|
|
68
|
-
* but no unlocked session blocks `children` behind a full-page unlock form. Set to `false` for a
|
|
69
|
-
* mount point that shouldn't block merely because a mailbox resolved - `MailShell` does this, since
|
|
70
|
-
* unlocking is only actually required to sign/encrypt a compose, read an already-encrypted message,
|
|
71
|
-
* or change encryption settings (see `UnlockPromptProvider.tsx`'s `useUnlockPrompt()`, which those
|
|
72
|
-
* specific call sites use instead). Has no effect on first-time provisioning
|
|
73
|
-
* (`setup_password`/`enrolling`/`show_recovery_codes`), which still always blocks regardless - that
|
|
74
|
-
* only ever happens once per mailbox and is a genuine prerequisite, not the source of "unlock keeps
|
|
75
|
-
* popping up" friction this prop exists to avoid.
|
|
76
|
-
*/
|
|
77
|
-
blocking?: boolean;
|
|
78
|
-
/**
|
|
79
|
-
* `true` when the caller may provision this mailbox's first encryption key - i.e. they own it and aren't
|
|
80
|
-
* an administrator impersonating them. `false` (default, so a caller that forgets it never provisions) for
|
|
81
|
-
* a shared/delegated mailbox the caller doesn't own, or an impersonated session: a mailbox with no vault yet then
|
|
82
|
-
* renders `children` instead of the "Protect your mailbox" setup, so a delegate never enrolls keys
|
|
83
|
-
* (and recovery codes) for someone else's mailbox. Unlocking an existing vault is unaffected.
|
|
84
|
-
*/
|
|
85
|
-
canProvision?: boolean;
|
|
86
|
-
children: React.ReactNode;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Gates a mailbox's normal content behind one-time E2E encryption key setup, per
|
|
91
|
-
* `specs/end-to-end_encryption.md`'s "Generate signing and encryption keypairs on the client's device on
|
|
92
|
-
* first sign-in." Rendered by `MailShell` wrapping its own returned content unconditionally, not only
|
|
93
|
-
* once a mailbox is resolved — mounting this component at a *different* tree position depending on
|
|
94
|
-
* `mailboxUid`'s readiness (e.g. only wrapping once ready, rendering bare content beforehand) would make
|
|
95
|
-
* `children` (real `AppShell` chrome) itself remount the moment `mailboxUid` resolves, tearing down any
|
|
96
|
-
* state/effects it had already started. Always wrapping keeps `AppShell` mounted continuously across
|
|
97
|
-
* that transition; this component simply passes `children` through untouched while `mailboxUid` is
|
|
98
|
-
* still unresolved, and only starts its own check once a real `mailboxUid` is supplied.
|
|
99
|
-
*
|
|
100
|
-
* A `getKeyVault()` failure (network error, server not yet wired up to serve this endpoint) also renders
|
|
101
|
-
* `children` unchanged rather than blocking mail entirely - encryption is optional and gradual by design
|
|
102
|
-
* (the spec's own "near zero frictionless experience" goal), not a hard prerequisite for reading mail.
|
|
103
|
-
*/
|
|
104
|
-
export default function KeyEnrollmentGate({
|
|
105
|
-
mailboxUid,
|
|
106
|
-
mailboxAddress,
|
|
107
|
-
mailboxKeys,
|
|
108
|
-
blocking = true,
|
|
109
|
-
canProvision = false,
|
|
110
|
-
children,
|
|
111
|
-
}: KeyEnrollmentGateProps) {
|
|
112
|
-
const [status, setStatus] = useState<Status>(mailboxUid ? "checking" : "ready");
|
|
113
|
-
const [password, setPassword] = useState("");
|
|
114
|
-
const [confirmPassword, setConfirmPassword] = useState("");
|
|
115
|
-
const [error, setError] = useState<string | null>(null);
|
|
116
|
-
const [recoveryCodes, setRecoveryCodes] = useState<string[]>([]);
|
|
117
|
-
const [codesSaved, setCodesSaved] = useState(false);
|
|
118
|
-
const [codesCopied, setCodesCopied] = useState(false);
|
|
119
|
-
const [unopenableKeys, setUnopenableKeys] = useState<string[] | null>(null);
|
|
120
|
-
const [unlockMode, setUnlockMode] = useState<"password" | "recovery">("password");
|
|
121
|
-
const [recoveryCode, setRecoveryCode] = useState("");
|
|
122
|
-
// Set after a recovery-code unlock: `children` render at once, with the follow-up steps in a dialog on top.
|
|
123
|
-
const [followUp, setFollowUp] = useState<RecoveryFollowUp | null>(null);
|
|
124
|
-
|
|
125
|
-
useEffect(() => {
|
|
126
|
-
if (!mailboxUid) {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
// A remount within the same browser session (e.g. navigating between pages) shouldn't re-prompt
|
|
130
|
-
// for a password the in-memory session store (`keySession.ts`) already has unwrapped - only a
|
|
131
|
-
// fresh session (reload, new tab, post-logout) has nothing there.
|
|
132
|
-
if (getUnlockedKeys(mailboxUid)) {
|
|
133
|
-
setStatus("ready");
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
let cancelled = false;
|
|
137
|
-
getKeyVault(mailboxUid)
|
|
138
|
-
.then((vault) => {
|
|
139
|
-
if (!cancelled) {
|
|
140
|
-
setStatus(vault.wrappedKeys.length > 0 ? "unlock" : canProvision ? "setup_password" : "ready");
|
|
141
|
-
}
|
|
142
|
-
})
|
|
143
|
-
.catch(() => {
|
|
144
|
-
if (!cancelled) {
|
|
145
|
-
setStatus("ready");
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
return () => {
|
|
149
|
-
cancelled = true;
|
|
150
|
-
};
|
|
151
|
-
}, [mailboxUid, canProvision]);
|
|
152
|
-
|
|
153
|
-
async function handleUnlock(e: React.FormEvent) {
|
|
154
|
-
e.preventDefault();
|
|
155
|
-
setError(null);
|
|
156
|
-
setStatus("unlocking");
|
|
157
|
-
try {
|
|
158
|
-
// Only reachable via "unlock", which the effect above only ever sets once mailboxUid was
|
|
159
|
-
// defined.
|
|
160
|
-
const result: UnlockResult | RecoveryFollowUp = await (unlockMode === "recovery"
|
|
161
|
-
? startRecoveryUnlock(mailboxUid!, mailboxKeys ?? [], recoveryCode)
|
|
162
|
-
: unlockWithPassword(mailboxUid!, mailboxKeys ?? [], password));
|
|
163
|
-
const recovery = unlockMode === "recovery" ? (result as RecoveryFollowUp) : null;
|
|
164
|
-
if (result.unopenableKeys.length > 0) {
|
|
165
|
-
setUnopenableKeys(result.unopenableKeys);
|
|
166
|
-
}
|
|
167
|
-
setRecoveryCode("");
|
|
168
|
-
setFollowUp(recovery);
|
|
169
|
-
setStatus("ready");
|
|
170
|
-
} catch (err) {
|
|
171
|
-
// "Incorrect password." (or "That recovery code didn't work.") unless the secret was right but the
|
|
172
|
-
// encryption key won't open - see `unlockErrorMessage()`.
|
|
173
|
-
setError(unlockErrorMessage(err, unlockMode));
|
|
174
|
-
setStatus("unlock");
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
async function handleSetPassword(e: React.FormEvent) {
|
|
179
|
-
e.preventDefault();
|
|
180
|
-
if (password.length < MIN_PASSWORD_LENGTH) {
|
|
181
|
-
setError(`Password must be at least ${MIN_PASSWORD_LENGTH} characters.`);
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
if (password !== confirmPassword) {
|
|
185
|
-
setError("Passwords do not match.");
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
setError(null);
|
|
189
|
-
setStatus("enrolling");
|
|
190
|
-
try {
|
|
191
|
-
// The vault was only checked on mount - another tab or device may have set encryption up since.
|
|
192
|
-
// Provisioning now would publish a second master key, orphaning whichever setup lost the race, so
|
|
193
|
-
// re-check right before generating anything. restapi's enrollKey() also refuses (409) wraps for a
|
|
194
|
-
// vault that already has them, for a race inside this window.
|
|
195
|
-
// Only reachable via "setup_password", which the effect above only ever sets once mailboxUid
|
|
196
|
-
// was defined (and mailboxAddress necessarily came with it - see KeyEnrollmentGateProps).
|
|
197
|
-
const fresh = await getKeyVault(mailboxUid!);
|
|
198
|
-
if (fresh.wrappedKeys.length > 0 || fresh.masterKeyWraps.length > 0) {
|
|
199
|
-
setStatus("already_set_up");
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
const { recoveryCodes: codes } = await provisionEncryptionKey(mailboxUid!, mailboxAddress!, password);
|
|
203
|
-
setRecoveryCodes(codes);
|
|
204
|
-
setStatus("show_recovery_codes");
|
|
205
|
-
} catch (err) {
|
|
206
|
-
// Only a 409 that is really "the vault already has wraps" - an unrelated lost optimistic-lock race is shown
|
|
207
|
-
// as an ordinary error.
|
|
208
|
-
if (err instanceof VaultAlreadyInitializedError) {
|
|
209
|
-
setStatus("already_set_up");
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
setError(err instanceof ApiRequestError ? err.message : "Could not set up encryption for this mailbox.");
|
|
213
|
-
setStatus("setup_password");
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
async function handleCopyCodes() {
|
|
218
|
-
try {
|
|
219
|
-
await navigator.clipboard.writeText(recoveryCodes.join("\n"));
|
|
220
|
-
setCodesCopied(true);
|
|
221
|
-
setTimeout(() => setCodesCopied(false), 2000);
|
|
222
|
-
} catch {
|
|
223
|
-
// Clipboard access can be denied by the browser - the codes are still selectable/copyable by
|
|
224
|
-
// hand from the list below.
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
if (status === "checking") {
|
|
229
|
-
return null;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
if ((status === "unlock" || status === "unlocking") && blocking) {
|
|
233
|
-
const unlocking = status === "unlocking";
|
|
234
|
-
return (
|
|
235
|
-
<FrameTakeover>
|
|
236
|
-
<div className="min-h-screen flex items-center justify-center p-8 bg-surface-alt">
|
|
237
|
-
<div className="w-full max-w-md bg-surface border border-border rounded-md p-8">
|
|
238
|
-
<h1 className="text-lg font-bold mb-2">Unlock your mailbox</h1>
|
|
239
|
-
<p className="text-sm text-text-muted mb-5">
|
|
240
|
-
{unlockMode === "password"
|
|
241
|
-
? "Enter your encryption password to unlock signing and reading protected mail this session."
|
|
242
|
-
: "Enter one of your recovery codes to unlock signing and reading protected mail this session. Each code works once."}
|
|
243
|
-
</p>
|
|
244
|
-
{error && <Alert>{error}</Alert>}
|
|
245
|
-
<form onSubmit={handleUnlock}>
|
|
246
|
-
{unlockMode === "password" ? (
|
|
247
|
-
<FormField label="Encryption password" htmlFor="key-unlock-password">
|
|
248
|
-
<input
|
|
249
|
-
id="key-unlock-password"
|
|
250
|
-
type="password"
|
|
251
|
-
className="w-full text-sm border border-border rounded-sm py-1.5 px-2 bg-surface"
|
|
252
|
-
value={password}
|
|
253
|
-
onChange={(e) => setPassword(e.target.value)}
|
|
254
|
-
disabled={unlocking}
|
|
255
|
-
autoComplete="current-password"
|
|
256
|
-
/>
|
|
257
|
-
</FormField>
|
|
258
|
-
) : (
|
|
259
|
-
<FormField label="Recovery code" htmlFor="key-unlock-recovery-code">
|
|
260
|
-
<input
|
|
261
|
-
id="key-unlock-recovery-code"
|
|
262
|
-
type="text"
|
|
263
|
-
className="w-full text-sm font-mono border border-border rounded-sm py-1.5 px-2 bg-surface"
|
|
264
|
-
value={recoveryCode}
|
|
265
|
-
onChange={(e) => setRecoveryCode(e.target.value)}
|
|
266
|
-
disabled={unlocking}
|
|
267
|
-
autoComplete="off"
|
|
268
|
-
autoCapitalize="characters"
|
|
269
|
-
spellCheck={false}
|
|
270
|
-
/>
|
|
271
|
-
</FormField>
|
|
272
|
-
)}
|
|
273
|
-
<Button type="submit" loading={unlocking} disabled={unlocking}>
|
|
274
|
-
Unlock
|
|
275
|
-
</Button>
|
|
276
|
-
</form>
|
|
277
|
-
<div className="mt-3">
|
|
278
|
-
<UnlockModeToggle
|
|
279
|
-
mode={unlockMode}
|
|
280
|
-
disabled={unlocking}
|
|
281
|
-
onChange={(next) => {
|
|
282
|
-
setUnlockMode(next);
|
|
283
|
-
setError(null);
|
|
284
|
-
}}
|
|
285
|
-
/>
|
|
286
|
-
</div>
|
|
287
|
-
</div>
|
|
288
|
-
</div>
|
|
289
|
-
</FrameTakeover>
|
|
290
|
-
);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
if (status === "setup_password" || status === "enrolling") {
|
|
294
|
-
const enrolling = status === "enrolling";
|
|
295
|
-
return (
|
|
296
|
-
<FrameTakeover>
|
|
297
|
-
<div className="min-h-screen flex items-center justify-center p-8 bg-surface-alt">
|
|
298
|
-
<div className="w-full max-w-md bg-surface border border-border rounded-md p-8">
|
|
299
|
-
<h1 className="text-lg font-bold mb-2">Protect your mailbox</h1>
|
|
300
|
-
<p className="text-sm text-text-muted mb-5">
|
|
301
|
-
Choose a password to protect your encryption keys. This is separate from your sign-in
|
|
302
|
-
password and is never sent to the server.
|
|
303
|
-
</p>
|
|
304
|
-
{error && <Alert>{error}</Alert>}
|
|
305
|
-
<form onSubmit={handleSetPassword}>
|
|
306
|
-
<FormField label="Encryption password" htmlFor="key-enrollment-password">
|
|
307
|
-
<input
|
|
308
|
-
id="key-enrollment-password"
|
|
309
|
-
type="password"
|
|
310
|
-
className="w-full text-sm border border-border rounded-sm py-1.5 px-2 bg-surface"
|
|
311
|
-
value={password}
|
|
312
|
-
onChange={(e) => setPassword(e.target.value)}
|
|
313
|
-
disabled={enrolling}
|
|
314
|
-
autoComplete="new-password"
|
|
315
|
-
/>
|
|
316
|
-
</FormField>
|
|
317
|
-
<FormField label="Confirm password" htmlFor="key-enrollment-password-confirm">
|
|
318
|
-
<input
|
|
319
|
-
id="key-enrollment-password-confirm"
|
|
320
|
-
type="password"
|
|
321
|
-
className="w-full text-sm border border-border rounded-sm py-1.5 px-2 bg-surface"
|
|
322
|
-
value={confirmPassword}
|
|
323
|
-
onChange={(e) => setConfirmPassword(e.target.value)}
|
|
324
|
-
disabled={enrolling}
|
|
325
|
-
autoComplete="new-password"
|
|
326
|
-
/>
|
|
327
|
-
</FormField>
|
|
328
|
-
<Button type="submit" loading={enrolling} disabled={enrolling}>
|
|
329
|
-
Continue
|
|
330
|
-
</Button>
|
|
331
|
-
</form>
|
|
332
|
-
</div>
|
|
333
|
-
</div>
|
|
334
|
-
</FrameTakeover>
|
|
335
|
-
);
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
if (status === "already_set_up") {
|
|
339
|
-
return (
|
|
340
|
-
<FrameTakeover>
|
|
341
|
-
<div className="min-h-screen flex items-center justify-center p-8 bg-surface-alt">
|
|
342
|
-
<div className="w-full max-w-md bg-surface border border-border rounded-md p-8">
|
|
343
|
-
<h1 className="text-lg font-bold mb-2">Encryption is already set up</h1>
|
|
344
|
-
<p className="text-sm text-text-muted mb-5">
|
|
345
|
-
This mailbox’s encryption was set up in another tab or on another device while this
|
|
346
|
-
page was open, so nothing was changed here. Reload the page and unlock with the password
|
|
347
|
-
chosen there.
|
|
348
|
-
</p>
|
|
349
|
-
<Button type="button" onClick={() => window.location.reload()}>
|
|
350
|
-
Reload
|
|
351
|
-
</Button>
|
|
352
|
-
</div>
|
|
353
|
-
</div>
|
|
354
|
-
</FrameTakeover>
|
|
355
|
-
);
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
if (status === "show_recovery_codes") {
|
|
359
|
-
return (
|
|
360
|
-
<FrameTakeover>
|
|
361
|
-
<div className="min-h-screen flex items-center justify-center p-8 bg-surface-alt">
|
|
362
|
-
<div className="w-full max-w-md bg-surface border border-border rounded-md p-8">
|
|
363
|
-
<h1 className="text-lg font-bold mb-2">Save your recovery codes</h1>
|
|
364
|
-
<p className="text-sm text-text-muted mb-5">
|
|
365
|
-
If you lose your password, these codes are the only way to recover your encrypted mail.
|
|
366
|
-
Each code can be used once. Store them somewhere safe — they will not be shown again.
|
|
367
|
-
</p>
|
|
368
|
-
<ul className="grid grid-cols-2 gap-2 mb-3 font-mono text-sm">
|
|
369
|
-
{recoveryCodes.map((code) => (
|
|
370
|
-
<li key={code} className="bg-surface-alt rounded-sm py-1.5 px-2 text-center">
|
|
371
|
-
{code}
|
|
372
|
-
</li>
|
|
373
|
-
))}
|
|
374
|
-
</ul>
|
|
375
|
-
<Button type="button" variant="secondary" className="!w-auto mb-5" onClick={handleCopyCodes}>
|
|
376
|
-
{codesCopied ? "Copied" : "Copy codes to clipboard"}
|
|
377
|
-
</Button>
|
|
378
|
-
<label className="flex items-center gap-2 text-sm mb-4">
|
|
379
|
-
<input type="checkbox" checked={codesSaved} onChange={(e) => setCodesSaved(e.target.checked)} />
|
|
380
|
-
I have saved these recovery codes in a safe place.
|
|
381
|
-
</label>
|
|
382
|
-
<Button type="button" disabled={!codesSaved} onClick={() => setStatus("ready")}>
|
|
383
|
-
Continue
|
|
384
|
-
</Button>
|
|
385
|
-
</div>
|
|
386
|
-
</div>
|
|
387
|
-
</FrameTakeover>
|
|
388
|
-
);
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
return (
|
|
392
|
-
<>
|
|
393
|
-
{children}
|
|
394
|
-
{unopenableKeys && <UnopenableKeysNotice fingerprints={unopenableKeys} onDismiss={() => setUnopenableKeys(null)} />}
|
|
395
|
-
{followUp && <RecoveryFollowUpModal followUp={followUp} onDone={() => setFollowUp(null)} />}
|
|
396
|
-
</>
|
|
397
|
-
);
|
|
398
|
-
}
|
|
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, VaultAlreadyInitializedError } from "@rapidmx/react-shared/crypto/keyvaultApi.js";
|
|
11
|
+
import { UnopenableKeysNotice, unlockErrorMessage } from "./UnlockPromptProvider.js";
|
|
12
|
+
import { FrameTakeover } from "../../navigation/frameContext.js";
|
|
13
|
+
import { RecoveryFollowUp, RecoveryFollowUpModal, UnlockModeToggle, startRecoveryUnlock } from "./RecoveryCodeUnlock.js";
|
|
14
|
+
import {
|
|
15
|
+
ENCRYPTION_PRIVATE_KEY_AAD_PURPOSE,
|
|
16
|
+
getUnlockedKeys,
|
|
17
|
+
unlockWithPassword,
|
|
18
|
+
type UnlockResult,
|
|
19
|
+
} from "@rapidmx/react-shared/crypto/keySession.js";
|
|
20
|
+
import { buildAad, generateMasterKey, sealWithKey } from "@rapidmx/react-shared/crypto/masterKey.js";
|
|
21
|
+
import { buildPasswordWrap, buildRecoveryWraps } from "@rapidmx/react-shared/crypto/masterKeyWraps.js";
|
|
22
|
+
import { exportPrivateKeyPkcs8, generateKeyPairWithCsr } from "@rapidmx/react-shared/crypto/keys.js";
|
|
23
|
+
|
|
24
|
+
type Status = "checking" | "setup_password" | "enrolling" | "already_set_up" | "show_recovery_codes" | "unlock" | "unlocking" | "ready";
|
|
25
|
+
|
|
26
|
+
const MIN_PASSWORD_LENGTH = 8;
|
|
27
|
+
|
|
28
|
+
async function provisionEncryptionKey(
|
|
29
|
+
mailboxUid: string,
|
|
30
|
+
mailboxAddress: string,
|
|
31
|
+
password: string,
|
|
32
|
+
): Promise<{ recoveryCodes: string[] }> {
|
|
33
|
+
const mk = generateMasterKey();
|
|
34
|
+
const passwordWrap = await buildPasswordWrap(mailboxUid, mk, password);
|
|
35
|
+
const { wraps: recoveryWraps, codes: recoveryCodes } = await buildRecoveryWraps(mailboxUid, mk);
|
|
36
|
+
|
|
37
|
+
// Only the encryption key is provisioned here. The signing key's spec-required public-CA enrolment
|
|
38
|
+
// (RFC 8823 ACME automation) is a real but genuinely asynchronous flow (a live email round-trip with
|
|
39
|
+
// a public CA, likely minutes) - it's a deliberate opt-in action in Settings > Encryption
|
|
40
|
+
// ("Enable digital signatures"), not something to block first-sign-in mailbox setup on.
|
|
41
|
+
const { keyPair, csrPem } = await generateKeyPairWithCsr(mailboxAddress, "encrypt");
|
|
42
|
+
const privateKeyRaw = await exportPrivateKeyPkcs8(keyPair.privateKey);
|
|
43
|
+
const wrappedKeySealed = await sealWithKey(mk, privateKeyRaw, buildAad(mailboxUid, ENCRYPTION_PRIVATE_KEY_AAD_PURPOSE));
|
|
44
|
+
|
|
45
|
+
await enrollKey(mailboxUid, {
|
|
46
|
+
useType: "encrypt",
|
|
47
|
+
csr: csrPem,
|
|
48
|
+
wrappedKey: { ciphertext: wrappedKeySealed.ciphertext, nonce: wrappedKeySealed.nonce, algorithm: "AES-256-GCM" },
|
|
49
|
+
masterKeyWraps: [passwordWrap, ...recoveryWraps],
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return { recoveryCodes };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface KeyEnrollmentGateProps {
|
|
56
|
+
/** Undefined while the caller's mailbox hasn't resolved yet (or has none) - renders `children`
|
|
57
|
+
* unchanged in that case, so this component can be mounted unconditionally at a stable tree
|
|
58
|
+
* position (see this component's own doc comment for why that matters). */
|
|
59
|
+
mailboxUid?: string;
|
|
60
|
+
mailboxAddress?: string;
|
|
61
|
+
/** The mailbox's currently-published public keys (`Mailbox.keys`) - needed to unlock an
|
|
62
|
+
* already-enrolled vault (see `unlockWithPassword()`'s own signature), not just to provision a new
|
|
63
|
+
* one. Treated as empty when undefined - a mailbox with no public keys published yet has nothing to
|
|
64
|
+
* unlock, so this only affects the already-enrolled path. */
|
|
65
|
+
mailboxKeys?: PublicKey[];
|
|
66
|
+
/**
|
|
67
|
+
* `true` (default) preserves this component's original behavior: a mailbox with an existing vault
|
|
68
|
+
* but no unlocked session blocks `children` behind a full-page unlock form. Set to `false` for a
|
|
69
|
+
* mount point that shouldn't block merely because a mailbox resolved - `MailShell` does this, since
|
|
70
|
+
* unlocking is only actually required to sign/encrypt a compose, read an already-encrypted message,
|
|
71
|
+
* or change encryption settings (see `UnlockPromptProvider.tsx`'s `useUnlockPrompt()`, which those
|
|
72
|
+
* specific call sites use instead). Has no effect on first-time provisioning
|
|
73
|
+
* (`setup_password`/`enrolling`/`show_recovery_codes`), which still always blocks regardless - that
|
|
74
|
+
* only ever happens once per mailbox and is a genuine prerequisite, not the source of "unlock keeps
|
|
75
|
+
* popping up" friction this prop exists to avoid.
|
|
76
|
+
*/
|
|
77
|
+
blocking?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* `true` when the caller may provision this mailbox's first encryption key - i.e. they own it and aren't
|
|
80
|
+
* an administrator impersonating them. `false` (default, so a caller that forgets it never provisions) for
|
|
81
|
+
* a shared/delegated mailbox the caller doesn't own, or an impersonated session: a mailbox with no vault yet then
|
|
82
|
+
* renders `children` instead of the "Protect your mailbox" setup, so a delegate never enrolls keys
|
|
83
|
+
* (and recovery codes) for someone else's mailbox. Unlocking an existing vault is unaffected.
|
|
84
|
+
*/
|
|
85
|
+
canProvision?: boolean;
|
|
86
|
+
children: React.ReactNode;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Gates a mailbox's normal content behind one-time E2E encryption key setup, per
|
|
91
|
+
* `specs/end-to-end_encryption.md`'s "Generate signing and encryption keypairs on the client's device on
|
|
92
|
+
* first sign-in." Rendered by `MailShell` wrapping its own returned content unconditionally, not only
|
|
93
|
+
* once a mailbox is resolved — mounting this component at a *different* tree position depending on
|
|
94
|
+
* `mailboxUid`'s readiness (e.g. only wrapping once ready, rendering bare content beforehand) would make
|
|
95
|
+
* `children` (real `AppShell` chrome) itself remount the moment `mailboxUid` resolves, tearing down any
|
|
96
|
+
* state/effects it had already started. Always wrapping keeps `AppShell` mounted continuously across
|
|
97
|
+
* that transition; this component simply passes `children` through untouched while `mailboxUid` is
|
|
98
|
+
* still unresolved, and only starts its own check once a real `mailboxUid` is supplied.
|
|
99
|
+
*
|
|
100
|
+
* A `getKeyVault()` failure (network error, server not yet wired up to serve this endpoint) also renders
|
|
101
|
+
* `children` unchanged rather than blocking mail entirely - encryption is optional and gradual by design
|
|
102
|
+
* (the spec's own "near zero frictionless experience" goal), not a hard prerequisite for reading mail.
|
|
103
|
+
*/
|
|
104
|
+
export default function KeyEnrollmentGate({
|
|
105
|
+
mailboxUid,
|
|
106
|
+
mailboxAddress,
|
|
107
|
+
mailboxKeys,
|
|
108
|
+
blocking = true,
|
|
109
|
+
canProvision = false,
|
|
110
|
+
children,
|
|
111
|
+
}: KeyEnrollmentGateProps) {
|
|
112
|
+
const [status, setStatus] = useState<Status>(mailboxUid ? "checking" : "ready");
|
|
113
|
+
const [password, setPassword] = useState("");
|
|
114
|
+
const [confirmPassword, setConfirmPassword] = useState("");
|
|
115
|
+
const [error, setError] = useState<string | null>(null);
|
|
116
|
+
const [recoveryCodes, setRecoveryCodes] = useState<string[]>([]);
|
|
117
|
+
const [codesSaved, setCodesSaved] = useState(false);
|
|
118
|
+
const [codesCopied, setCodesCopied] = useState(false);
|
|
119
|
+
const [unopenableKeys, setUnopenableKeys] = useState<string[] | null>(null);
|
|
120
|
+
const [unlockMode, setUnlockMode] = useState<"password" | "recovery">("password");
|
|
121
|
+
const [recoveryCode, setRecoveryCode] = useState("");
|
|
122
|
+
// Set after a recovery-code unlock: `children` render at once, with the follow-up steps in a dialog on top.
|
|
123
|
+
const [followUp, setFollowUp] = useState<RecoveryFollowUp | null>(null);
|
|
124
|
+
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
if (!mailboxUid) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
// A remount within the same browser session (e.g. navigating between pages) shouldn't re-prompt
|
|
130
|
+
// for a password the in-memory session store (`keySession.ts`) already has unwrapped - only a
|
|
131
|
+
// fresh session (reload, new tab, post-logout) has nothing there.
|
|
132
|
+
if (getUnlockedKeys(mailboxUid)) {
|
|
133
|
+
setStatus("ready");
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
let cancelled = false;
|
|
137
|
+
getKeyVault(mailboxUid)
|
|
138
|
+
.then((vault) => {
|
|
139
|
+
if (!cancelled) {
|
|
140
|
+
setStatus(vault.wrappedKeys.length > 0 ? "unlock" : canProvision ? "setup_password" : "ready");
|
|
141
|
+
}
|
|
142
|
+
})
|
|
143
|
+
.catch(() => {
|
|
144
|
+
if (!cancelled) {
|
|
145
|
+
setStatus("ready");
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
return () => {
|
|
149
|
+
cancelled = true;
|
|
150
|
+
};
|
|
151
|
+
}, [mailboxUid, canProvision]);
|
|
152
|
+
|
|
153
|
+
async function handleUnlock(e: React.FormEvent) {
|
|
154
|
+
e.preventDefault();
|
|
155
|
+
setError(null);
|
|
156
|
+
setStatus("unlocking");
|
|
157
|
+
try {
|
|
158
|
+
// Only reachable via "unlock", which the effect above only ever sets once mailboxUid was
|
|
159
|
+
// defined.
|
|
160
|
+
const result: UnlockResult | RecoveryFollowUp = await (unlockMode === "recovery"
|
|
161
|
+
? startRecoveryUnlock(mailboxUid!, mailboxKeys ?? [], recoveryCode)
|
|
162
|
+
: unlockWithPassword(mailboxUid!, mailboxKeys ?? [], password));
|
|
163
|
+
const recovery = unlockMode === "recovery" ? (result as RecoveryFollowUp) : null;
|
|
164
|
+
if (result.unopenableKeys.length > 0) {
|
|
165
|
+
setUnopenableKeys(result.unopenableKeys);
|
|
166
|
+
}
|
|
167
|
+
setRecoveryCode("");
|
|
168
|
+
setFollowUp(recovery);
|
|
169
|
+
setStatus("ready");
|
|
170
|
+
} catch (err) {
|
|
171
|
+
// "Incorrect password." (or "That recovery code didn't work.") unless the secret was right but the
|
|
172
|
+
// encryption key won't open - see `unlockErrorMessage()`.
|
|
173
|
+
setError(unlockErrorMessage(err, unlockMode));
|
|
174
|
+
setStatus("unlock");
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
async function handleSetPassword(e: React.FormEvent) {
|
|
179
|
+
e.preventDefault();
|
|
180
|
+
if (password.length < MIN_PASSWORD_LENGTH) {
|
|
181
|
+
setError(`Password must be at least ${MIN_PASSWORD_LENGTH} characters.`);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (password !== confirmPassword) {
|
|
185
|
+
setError("Passwords do not match.");
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
setError(null);
|
|
189
|
+
setStatus("enrolling");
|
|
190
|
+
try {
|
|
191
|
+
// The vault was only checked on mount - another tab or device may have set encryption up since.
|
|
192
|
+
// Provisioning now would publish a second master key, orphaning whichever setup lost the race, so
|
|
193
|
+
// re-check right before generating anything. restapi's enrollKey() also refuses (409) wraps for a
|
|
194
|
+
// vault that already has them, for a race inside this window.
|
|
195
|
+
// Only reachable via "setup_password", which the effect above only ever sets once mailboxUid
|
|
196
|
+
// was defined (and mailboxAddress necessarily came with it - see KeyEnrollmentGateProps).
|
|
197
|
+
const fresh = await getKeyVault(mailboxUid!);
|
|
198
|
+
if (fresh.wrappedKeys.length > 0 || fresh.masterKeyWraps.length > 0) {
|
|
199
|
+
setStatus("already_set_up");
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const { recoveryCodes: codes } = await provisionEncryptionKey(mailboxUid!, mailboxAddress!, password);
|
|
203
|
+
setRecoveryCodes(codes);
|
|
204
|
+
setStatus("show_recovery_codes");
|
|
205
|
+
} catch (err) {
|
|
206
|
+
// Only a 409 that is really "the vault already has wraps" - an unrelated lost optimistic-lock race is shown
|
|
207
|
+
// as an ordinary error.
|
|
208
|
+
if (err instanceof VaultAlreadyInitializedError) {
|
|
209
|
+
setStatus("already_set_up");
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
setError(err instanceof ApiRequestError ? err.message : "Could not set up encryption for this mailbox.");
|
|
213
|
+
setStatus("setup_password");
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
async function handleCopyCodes() {
|
|
218
|
+
try {
|
|
219
|
+
await navigator.clipboard.writeText(recoveryCodes.join("\n"));
|
|
220
|
+
setCodesCopied(true);
|
|
221
|
+
setTimeout(() => setCodesCopied(false), 2000);
|
|
222
|
+
} catch {
|
|
223
|
+
// Clipboard access can be denied by the browser - the codes are still selectable/copyable by
|
|
224
|
+
// hand from the list below.
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (status === "checking") {
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if ((status === "unlock" || status === "unlocking") && blocking) {
|
|
233
|
+
const unlocking = status === "unlocking";
|
|
234
|
+
return (
|
|
235
|
+
<FrameTakeover>
|
|
236
|
+
<div className="min-h-screen flex items-center justify-center p-8 bg-surface-alt">
|
|
237
|
+
<div className="w-full max-w-md bg-surface border border-border rounded-md p-8">
|
|
238
|
+
<h1 className="text-lg font-bold mb-2">Unlock your mailbox</h1>
|
|
239
|
+
<p className="text-sm text-text-muted mb-5">
|
|
240
|
+
{unlockMode === "password"
|
|
241
|
+
? "Enter your encryption password to unlock signing and reading protected mail this session."
|
|
242
|
+
: "Enter one of your recovery codes to unlock signing and reading protected mail this session. Each code works once."}
|
|
243
|
+
</p>
|
|
244
|
+
{error && <Alert>{error}</Alert>}
|
|
245
|
+
<form onSubmit={handleUnlock}>
|
|
246
|
+
{unlockMode === "password" ? (
|
|
247
|
+
<FormField label="Encryption password" htmlFor="key-unlock-password">
|
|
248
|
+
<input
|
|
249
|
+
id="key-unlock-password"
|
|
250
|
+
type="password"
|
|
251
|
+
className="w-full text-sm border border-border rounded-sm py-1.5 px-2 bg-surface"
|
|
252
|
+
value={password}
|
|
253
|
+
onChange={(e) => setPassword(e.target.value)}
|
|
254
|
+
disabled={unlocking}
|
|
255
|
+
autoComplete="current-password"
|
|
256
|
+
/>
|
|
257
|
+
</FormField>
|
|
258
|
+
) : (
|
|
259
|
+
<FormField label="Recovery code" htmlFor="key-unlock-recovery-code">
|
|
260
|
+
<input
|
|
261
|
+
id="key-unlock-recovery-code"
|
|
262
|
+
type="text"
|
|
263
|
+
className="w-full text-sm font-mono border border-border rounded-sm py-1.5 px-2 bg-surface"
|
|
264
|
+
value={recoveryCode}
|
|
265
|
+
onChange={(e) => setRecoveryCode(e.target.value)}
|
|
266
|
+
disabled={unlocking}
|
|
267
|
+
autoComplete="off"
|
|
268
|
+
autoCapitalize="characters"
|
|
269
|
+
spellCheck={false}
|
|
270
|
+
/>
|
|
271
|
+
</FormField>
|
|
272
|
+
)}
|
|
273
|
+
<Button type="submit" loading={unlocking} disabled={unlocking}>
|
|
274
|
+
Unlock
|
|
275
|
+
</Button>
|
|
276
|
+
</form>
|
|
277
|
+
<div className="mt-3">
|
|
278
|
+
<UnlockModeToggle
|
|
279
|
+
mode={unlockMode}
|
|
280
|
+
disabled={unlocking}
|
|
281
|
+
onChange={(next) => {
|
|
282
|
+
setUnlockMode(next);
|
|
283
|
+
setError(null);
|
|
284
|
+
}}
|
|
285
|
+
/>
|
|
286
|
+
</div>
|
|
287
|
+
</div>
|
|
288
|
+
</div>
|
|
289
|
+
</FrameTakeover>
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if (status === "setup_password" || status === "enrolling") {
|
|
294
|
+
const enrolling = status === "enrolling";
|
|
295
|
+
return (
|
|
296
|
+
<FrameTakeover>
|
|
297
|
+
<div className="min-h-screen flex items-center justify-center p-8 bg-surface-alt">
|
|
298
|
+
<div className="w-full max-w-md bg-surface border border-border rounded-md p-8">
|
|
299
|
+
<h1 className="text-lg font-bold mb-2">Protect your mailbox</h1>
|
|
300
|
+
<p className="text-sm text-text-muted mb-5">
|
|
301
|
+
Choose a password to protect your encryption keys. This is separate from your sign-in
|
|
302
|
+
password and is never sent to the server.
|
|
303
|
+
</p>
|
|
304
|
+
{error && <Alert>{error}</Alert>}
|
|
305
|
+
<form onSubmit={handleSetPassword}>
|
|
306
|
+
<FormField label="Encryption password" htmlFor="key-enrollment-password">
|
|
307
|
+
<input
|
|
308
|
+
id="key-enrollment-password"
|
|
309
|
+
type="password"
|
|
310
|
+
className="w-full text-sm border border-border rounded-sm py-1.5 px-2 bg-surface"
|
|
311
|
+
value={password}
|
|
312
|
+
onChange={(e) => setPassword(e.target.value)}
|
|
313
|
+
disabled={enrolling}
|
|
314
|
+
autoComplete="new-password"
|
|
315
|
+
/>
|
|
316
|
+
</FormField>
|
|
317
|
+
<FormField label="Confirm password" htmlFor="key-enrollment-password-confirm">
|
|
318
|
+
<input
|
|
319
|
+
id="key-enrollment-password-confirm"
|
|
320
|
+
type="password"
|
|
321
|
+
className="w-full text-sm border border-border rounded-sm py-1.5 px-2 bg-surface"
|
|
322
|
+
value={confirmPassword}
|
|
323
|
+
onChange={(e) => setConfirmPassword(e.target.value)}
|
|
324
|
+
disabled={enrolling}
|
|
325
|
+
autoComplete="new-password"
|
|
326
|
+
/>
|
|
327
|
+
</FormField>
|
|
328
|
+
<Button type="submit" loading={enrolling} disabled={enrolling}>
|
|
329
|
+
Continue
|
|
330
|
+
</Button>
|
|
331
|
+
</form>
|
|
332
|
+
</div>
|
|
333
|
+
</div>
|
|
334
|
+
</FrameTakeover>
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
if (status === "already_set_up") {
|
|
339
|
+
return (
|
|
340
|
+
<FrameTakeover>
|
|
341
|
+
<div className="min-h-screen flex items-center justify-center p-8 bg-surface-alt">
|
|
342
|
+
<div className="w-full max-w-md bg-surface border border-border rounded-md p-8">
|
|
343
|
+
<h1 className="text-lg font-bold mb-2">Encryption is already set up</h1>
|
|
344
|
+
<p className="text-sm text-text-muted mb-5">
|
|
345
|
+
This mailbox’s encryption was set up in another tab or on another device while this
|
|
346
|
+
page was open, so nothing was changed here. Reload the page and unlock with the password
|
|
347
|
+
chosen there.
|
|
348
|
+
</p>
|
|
349
|
+
<Button type="button" onClick={() => window.location.reload()}>
|
|
350
|
+
Reload
|
|
351
|
+
</Button>
|
|
352
|
+
</div>
|
|
353
|
+
</div>
|
|
354
|
+
</FrameTakeover>
|
|
355
|
+
);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
if (status === "show_recovery_codes") {
|
|
359
|
+
return (
|
|
360
|
+
<FrameTakeover>
|
|
361
|
+
<div className="min-h-screen flex items-center justify-center p-8 bg-surface-alt">
|
|
362
|
+
<div className="w-full max-w-md bg-surface border border-border rounded-md p-8">
|
|
363
|
+
<h1 className="text-lg font-bold mb-2">Save your recovery codes</h1>
|
|
364
|
+
<p className="text-sm text-text-muted mb-5">
|
|
365
|
+
If you lose your password, these codes are the only way to recover your encrypted mail.
|
|
366
|
+
Each code can be used once. Store them somewhere safe — they will not be shown again.
|
|
367
|
+
</p>
|
|
368
|
+
<ul className="grid grid-cols-2 gap-2 mb-3 font-mono text-sm">
|
|
369
|
+
{recoveryCodes.map((code) => (
|
|
370
|
+
<li key={code} className="bg-surface-alt rounded-sm py-1.5 px-2 text-center">
|
|
371
|
+
{code}
|
|
372
|
+
</li>
|
|
373
|
+
))}
|
|
374
|
+
</ul>
|
|
375
|
+
<Button type="button" variant="secondary" className="!w-auto mb-5" onClick={handleCopyCodes}>
|
|
376
|
+
{codesCopied ? "Copied" : "Copy codes to clipboard"}
|
|
377
|
+
</Button>
|
|
378
|
+
<label className="flex items-center gap-2 text-sm mb-4">
|
|
379
|
+
<input type="checkbox" checked={codesSaved} onChange={(e) => setCodesSaved(e.target.checked)} />
|
|
380
|
+
I have saved these recovery codes in a safe place.
|
|
381
|
+
</label>
|
|
382
|
+
<Button type="button" disabled={!codesSaved} onClick={() => setStatus("ready")}>
|
|
383
|
+
Continue
|
|
384
|
+
</Button>
|
|
385
|
+
</div>
|
|
386
|
+
</div>
|
|
387
|
+
</FrameTakeover>
|
|
388
|
+
);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
return (
|
|
392
|
+
<>
|
|
393
|
+
{children}
|
|
394
|
+
{unopenableKeys && <UnopenableKeysNotice fingerprints={unopenableKeys} onDismiss={() => setUnopenableKeys(null)} />}
|
|
395
|
+
{followUp && <RecoveryFollowUpModal followUp={followUp} onDone={() => setFollowUp(null)} />}
|
|
396
|
+
</>
|
|
397
|
+
);
|
|
398
|
+
}
|