@rapidmx/web-client 0.9.0 → 0.11.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 +373 -88
- package/apps/admin/_layout.tsx +8 -2
- package/apps/admin/index.tsx +7 -1
- package/apps/admin/ingest-queue/index.tsx +2 -1
- package/apps/admin/mailboxes/[uid].tsx +23 -10
- package/apps/admin/quarantine/index.tsx +2 -1
- package/apps/admin/signing-certificates/index.tsx +343 -0
- package/apps/escrow/_layout.tsx +8 -2
- package/apps/shared/appearance/AppearanceForm.tsx +392 -0
- package/apps/shared/appearance/AppearanceHead.tsx +49 -0
- package/apps/shared/appearance/AppearanceProvider.tsx +470 -0
- package/apps/shared/appearance/ColorField.tsx +107 -0
- package/apps/shared/appearance/appearanceCache.ts +106 -0
- package/apps/shared/appearance/appearanceContext.ts +77 -0
- package/apps/shared/appearance/bootScript.ts +35 -0
- package/apps/shared/appearance/color.ts +169 -0
- package/apps/shared/appearance/photo.ts +88 -0
- package/apps/shared/appearance/resolvedTheme.ts +67 -0
- package/apps/shared/appearance/theme.ts +355 -0
- package/apps/shared/auth/accountUrl.ts +9 -0
- package/apps/shared/auth/adminAccess.ts +99 -0
- package/apps/shared/components/admin/layout/AdminShell.tsx +22 -10
- package/apps/shared/components/admin/mailboxes/ShareAccessCard.tsx +107 -60
- package/apps/shared/components/admin/settings/BrandingForm.tsx +24 -0
- package/apps/shared/components/admin/settings/DomainDnsSetup.tsx +2 -1
- package/apps/shared/components/admin/settings/PluginsManager.tsx +228 -25
- package/apps/shared/components/admin/setup/SetupWizard.tsx +2 -1
- package/apps/shared/components/calendar/CalendarListSidebar.tsx +4 -5
- package/apps/shared/components/calendar/layout/CalendarShell.tsx +8 -2
- package/apps/shared/components/contacts/ContactForm.tsx +11 -5
- package/apps/shared/components/contacts/ContactsSidebar.tsx +5 -3
- package/apps/shared/components/contacts/ContactsToolbar.tsx +98 -115
- package/apps/shared/components/contacts/layout/ContactsShell.tsx +25 -8
- package/apps/shared/components/escrow/layout/EscrowShell.tsx +13 -6
- package/apps/shared/components/layout/AppShell.tsx +477 -288
- package/apps/shared/components/layout/BrandingChrome.tsx +200 -13
- package/apps/shared/components/layout/KeyEnrollmentGate.tsx +398 -389
- package/apps/shared/components/layout/MailboxProvisioning.tsx +168 -164
- package/apps/shared/components/layout/RailIcon.tsx +100 -0
- package/apps/shared/components/layout/ResponsiveToolbar.tsx +315 -0
- package/apps/shared/components/layout/ThemeSwitch.tsx +84 -0
- package/apps/shared/components/layout/UserMenu.tsx +372 -185
- package/apps/shared/components/mail/ConversationList.tsx +271 -262
- package/apps/shared/components/mail/ConversationThreadPane.tsx +147 -94
- package/apps/shared/components/mail/LazyReadingPane.tsx +113 -0
- package/apps/shared/components/mail/MailSelectionBar.tsx +227 -222
- package/apps/shared/components/mail/MessageDetailPane.tsx +1537 -1387
- package/apps/shared/components/mail/OutboxBadge.tsx +44 -0
- package/apps/shared/components/mail/OutboxRowStatus.tsx +31 -0
- package/apps/shared/components/mail/compose/ComposeContext.tsx +312 -160
- package/apps/shared/components/mail/compose/ComposeToolbar.tsx +422 -418
- package/apps/shared/components/mail/compose/ComposeWindow.tsx +1644 -1736
- package/apps/shared/components/mail/compose/ComposeWindowPlaceholder.tsx +111 -0
- package/apps/shared/components/mail/compose/RichTextEditor.tsx +147 -118
- package/apps/shared/components/mail/compose/composePerf.ts +46 -0
- package/apps/shared/components/mail/compose/encryptionRequirement.ts +86 -0
- package/apps/shared/components/mail/compose/quotedBody.ts +161 -100
- package/apps/shared/components/mail/layout/MailShell.tsx +490 -472
- package/apps/shared/components/mail/reading/EncryptedBody.tsx +65 -0
- package/apps/shared/components/mail/reading/EncryptedPreview.tsx +35 -0
- package/apps/shared/components/mail/reading/MessageBody.tsx +240 -0
- package/apps/shared/components/mail/reading/MessageCard.tsx +174 -0
- package/apps/shared/components/mail/reading/bodyContent.ts +100 -0
- package/apps/shared/components/mail/reading/bodyHtml.ts +298 -0
- package/apps/shared/components/mail/reading/color.ts +245 -0
- package/apps/shared/components/mail/reading/frameControl.ts +142 -0
- package/apps/shared/components/mail/reading/frameDocument.ts +123 -0
- package/apps/shared/components/mail/reading/safeDocument.ts +24 -0
- package/apps/shared/components/mail/reading/themeAdaptation.ts +221 -0
- package/apps/shared/components/mail/reading/themeSurface.ts +90 -0
- package/apps/shared/components/mail/reading/viewOriginal.ts +38 -0
- package/apps/shared/components/mail/unreadStyle.tsx +75 -0
- package/apps/shared/components/settings/SigningCertificateCard.tsx +344 -0
- package/apps/shared/components/settings/layout/SettingsShell.tsx +253 -240
- package/apps/shared/components/sharing/PrincipalPicker.tsx +145 -0
- package/apps/shared/components/tasks/TasksSidebar.tsx +5 -3
- package/apps/shared/components/tasks/layout/TasksShell.tsx +24 -8
- package/apps/shared/keyboard/GlobalShortcuts.tsx +51 -0
- package/apps/shared/keyboard/ShortcutProvider.tsx +62 -0
- package/apps/shared/keyboard/ShortcutsDialog.tsx +84 -0
- package/apps/shared/keyboard/dispatch.ts +124 -0
- package/apps/shared/keyboard/format.ts +89 -0
- package/apps/shared/keyboard/keymap.ts +114 -0
- package/apps/shared/keyboard/match.ts +44 -0
- package/apps/shared/keyboard/parse.ts +136 -0
- package/apps/shared/keyboard/platform.ts +34 -0
- package/apps/shared/keyboard/registry.ts +65 -0
- package/apps/shared/keyboard/targets.ts +79 -0
- package/apps/shared/keyboard/useShortcut.ts +50 -0
- package/apps/shared/keyboard/useShortcutProps.ts +17 -0
- package/apps/shared/mail/folderCounts.ts +308 -0
- package/apps/shared/mail/folderTree.ts +143 -0
- package/apps/shared/mail/listSnapshots.ts +87 -0
- package/apps/shared/mail/messageReadState.ts +85 -0
- package/apps/shared/mail/newMailNotifications.ts +183 -0
- package/apps/shared/mail/outbox/UnlockBridge.tsx +23 -0
- package/apps/shared/mail/outbox/composeBridge.ts +69 -0
- package/apps/shared/mail/outbox/outboxState.ts +88 -0
- package/apps/shared/mail/outbox/pendingSends.ts +146 -0
- package/apps/shared/mail/outbox/sendDecision.ts +157 -0
- package/apps/shared/mail/outbox/sendJob.ts +427 -0
- package/apps/shared/mail/outbox/sendOutcomes.ts +146 -0
- package/apps/shared/mail/outbox/sendState.ts +35 -0
- package/apps/shared/mail/outbox/useOutboxStatus.ts +61 -0
- package/apps/shared/mail/useMailConnection.ts +203 -0
- package/apps/shared/mail/useMailLiveUpdates.ts +277 -224
- package/apps/shared/mail/useMarkMessageRead.ts +47 -0
- package/apps/shared/mail/useNewMailNotifications.ts +178 -0
- package/apps/shared/mail/useUnreadTitle.ts +42 -0
- package/apps/shared/navigation/AppRouter.tsx +300 -0
- package/apps/shared/navigation/appHrefs.ts +23 -0
- package/apps/shared/navigation/frameContext.tsx +35 -0
- package/apps/shared/navigation/idle.ts +45 -0
- package/apps/shared/navigation/routerContext.tsx +83 -0
- package/apps/shared/navigation/routes.ts +72 -0
- package/apps/shared/notifications/NotificationCenter.tsx +215 -0
- package/apps/shared/notifications/NotificationHistoryDialog.tsx +90 -0
- package/apps/shared/notifications/apiErrors.ts +98 -0
- package/apps/shared/notifications/headerOffset.ts +35 -0
- package/apps/shared/notifications/pushStatus.ts +56 -0
- package/apps/shared/notifications/store.ts +549 -0
- package/apps/shared/notifications/systemErrors.ts +63 -0
- package/apps/shared/notifications/useNotifications.ts +41 -0
- package/apps/shared/search/LocalIndexLifecycle.tsx +114 -98
- package/apps/shared/signing/enrollmentStorage.ts +33 -0
- package/apps/shared/signing/enrollmentTracker.ts +385 -0
- package/apps/shared/signing/enrollmentView.ts +251 -0
- package/apps/shared/signing/signingInfo.ts +58 -0
- package/apps/shared/signing/useNow.ts +19 -0
- package/apps/shared/signing/useSigningEnrollmentWatcher.ts +90 -0
- package/apps/shared/styles/app.css +108 -10
- package/apps/www/_layout.tsx +8 -2
- package/apps/www/_routedPage.tsx +24 -0
- package/apps/www/_routes.ts +36 -0
- package/apps/www/calendar/index.tsx +64 -33
- package/apps/www/contacts/[uid].tsx +109 -107
- package/apps/www/contacts/index.tsx +62 -42
- package/apps/www/index.tsx +2291 -1917
- package/apps/www/messages/[uid].tsx +108 -101
- package/apps/www/settings/appearance/index.tsx +21 -0
- package/apps/www/settings/auto-reply/index.tsx +7 -8
- package/apps/www/settings/encryption/index.tsx +1287 -1249
- package/apps/www/settings/filters/[uid].tsx +7 -2
- package/apps/www/settings/filters/index.tsx +102 -99
- package/apps/www/settings/filters/new/index.tsx +140 -133
- package/apps/www/settings/labels/index.tsx +204 -201
- package/apps/www/settings/privacy/index.tsx +7 -9
- package/apps/www/settings/read-receipts/index.tsx +7 -8
- package/apps/www/settings/sharing/index.tsx +256 -274
- package/apps/www/settings/signatures/[uid].tsx +172 -167
- package/apps/www/settings/signatures/index.tsx +88 -85
- package/apps/www/settings/signatures/new/index.tsx +135 -129
- package/apps/www/tasks/index.tsx +29 -18
- package/dist/apps/admin/_layout.d.ts +5 -1
- package/dist/apps/admin/_layout.js +3 -2
- package/dist/apps/admin/index.js +3 -2
- package/dist/apps/admin/ingest-queue/index.js +2 -1
- package/dist/apps/admin/mailboxes/[uid].js +9 -6
- package/dist/apps/admin/quarantine/index.js +2 -1
- package/dist/apps/admin/signing-certificates/index.d.ts +3 -0
- package/dist/apps/admin/signing-certificates/index.js +161 -0
- package/dist/apps/escrow/_layout.d.ts +5 -1
- package/dist/apps/escrow/_layout.js +3 -2
- package/dist/apps/shared/appearance/AppearanceForm.d.ts +7 -0
- package/dist/apps/shared/appearance/AppearanceForm.js +131 -0
- package/dist/apps/shared/appearance/AppearanceHead.d.ts +15 -0
- package/dist/apps/shared/appearance/AppearanceHead.js +31 -0
- package/dist/apps/shared/appearance/AppearanceProvider.d.ts +32 -0
- package/dist/apps/shared/appearance/AppearanceProvider.js +390 -0
- package/dist/apps/shared/appearance/ColorField.d.ts +22 -0
- package/dist/apps/shared/appearance/ColorField.js +40 -0
- package/dist/apps/shared/appearance/appearanceCache.d.ts +45 -0
- package/dist/apps/shared/appearance/appearanceCache.js +80 -0
- package/dist/apps/shared/appearance/appearanceContext.d.ts +45 -0
- package/dist/apps/shared/appearance/appearanceContext.js +29 -0
- package/dist/apps/shared/appearance/bootScript.d.ts +16 -0
- package/dist/apps/shared/appearance/bootScript.js +33 -0
- package/dist/apps/shared/appearance/color.d.ts +65 -0
- package/dist/apps/shared/appearance/color.js +132 -0
- package/dist/apps/shared/appearance/photo.d.ts +17 -0
- package/dist/apps/shared/appearance/photo.js +79 -0
- package/dist/apps/shared/appearance/resolvedTheme.d.ts +21 -0
- package/dist/apps/shared/appearance/resolvedTheme.js +55 -0
- package/dist/apps/shared/appearance/theme.d.ts +111 -0
- package/dist/apps/shared/appearance/theme.js +251 -0
- package/dist/apps/shared/auth/accountUrl.d.ts +2 -0
- package/dist/apps/shared/auth/accountUrl.js +8 -0
- package/dist/apps/shared/auth/adminAccess.d.ts +30 -0
- package/dist/apps/shared/auth/adminAccess.js +89 -0
- package/dist/apps/shared/components/admin/layout/AdminShell.d.ts +1 -1
- package/dist/apps/shared/components/admin/layout/AdminShell.js +16 -6
- package/dist/apps/shared/components/admin/mailboxes/ShareAccessCard.d.ts +10 -5
- package/dist/apps/shared/components/admin/mailboxes/ShareAccessCard.js +49 -34
- package/dist/apps/shared/components/admin/settings/BrandingForm.d.ts +2 -0
- package/dist/apps/shared/components/admin/settings/BrandingForm.js +7 -1
- package/dist/apps/shared/components/admin/settings/DomainDnsSetup.js +1 -1
- package/dist/apps/shared/components/admin/settings/PluginsManager.js +106 -20
- package/dist/apps/shared/components/admin/setup/SetupWizard.js +2 -1
- package/dist/apps/shared/components/calendar/CalendarListSidebar.js +8 -8
- package/dist/apps/shared/components/calendar/layout/CalendarShell.d.ts +1 -1
- package/dist/apps/shared/components/calendar/layout/CalendarShell.js +8 -4
- package/dist/apps/shared/components/contacts/ContactForm.js +1 -1
- package/dist/apps/shared/components/contacts/ContactsSidebar.js +4 -2
- package/dist/apps/shared/components/contacts/ContactsToolbar.d.ts +6 -2
- package/dist/apps/shared/components/contacts/ContactsToolbar.js +28 -10
- package/dist/apps/shared/components/contacts/layout/ContactsShell.d.ts +1 -1
- package/dist/apps/shared/components/contacts/layout/ContactsShell.js +19 -6
- package/dist/apps/shared/components/escrow/layout/EscrowShell.js +7 -4
- package/dist/apps/shared/components/layout/AppShell.d.ts +34 -4
- package/dist/apps/shared/components/layout/AppShell.js +122 -17
- package/dist/apps/shared/components/layout/BrandingChrome.d.ts +69 -10
- package/dist/apps/shared/components/layout/BrandingChrome.js +140 -12
- package/dist/apps/shared/components/layout/KeyEnrollmentGate.js +10 -9
- package/dist/apps/shared/components/layout/MailboxProvisioning.js +3 -1
- package/dist/apps/shared/components/layout/RailIcon.d.ts +21 -0
- package/dist/apps/shared/components/layout/RailIcon.js +85 -0
- package/dist/apps/shared/components/layout/ResponsiveToolbar.d.ts +55 -0
- package/dist/apps/shared/components/layout/ResponsiveToolbar.js +199 -0
- package/dist/apps/shared/components/layout/ThemeSwitch.d.ts +9 -0
- package/dist/apps/shared/components/layout/ThemeSwitch.js +54 -0
- package/dist/apps/shared/components/layout/UserMenu.d.ts +25 -3
- package/dist/apps/shared/components/layout/UserMenu.js +88 -7
- package/dist/apps/shared/components/mail/ConversationList.js +5 -11
- package/dist/apps/shared/components/mail/ConversationThreadPane.d.ts +6 -2
- package/dist/apps/shared/components/mail/ConversationThreadPane.js +87 -40
- package/dist/apps/shared/components/mail/LazyReadingPane.d.ts +9 -0
- package/dist/apps/shared/components/mail/LazyReadingPane.js +83 -0
- package/dist/apps/shared/components/mail/MailSelectionBar.d.ts +6 -4
- package/dist/apps/shared/components/mail/MailSelectionBar.js +11 -4
- package/dist/apps/shared/components/mail/MessageDetailPane.d.ts +25 -8
- package/dist/apps/shared/components/mail/MessageDetailPane.js +167 -73
- package/dist/apps/shared/components/mail/OutboxBadge.d.ts +17 -0
- package/dist/apps/shared/components/mail/OutboxBadge.js +18 -0
- package/dist/apps/shared/components/mail/OutboxRowStatus.d.ts +10 -0
- package/dist/apps/shared/components/mail/OutboxRowStatus.js +19 -0
- package/dist/apps/shared/components/mail/compose/ComposeContext.d.ts +38 -0
- package/dist/apps/shared/components/mail/compose/ComposeContext.js +97 -6
- package/dist/apps/shared/components/mail/compose/ComposeToolbar.js +4 -3
- package/dist/apps/shared/components/mail/compose/ComposeWindow.d.ts +3 -2
- package/dist/apps/shared/components/mail/compose/ComposeWindow.js +316 -339
- package/dist/apps/shared/components/mail/compose/ComposeWindowPlaceholder.d.ts +19 -0
- package/dist/apps/shared/components/mail/compose/ComposeWindowPlaceholder.js +33 -0
- package/dist/apps/shared/components/mail/compose/RichTextEditor.d.ts +9 -1
- package/dist/apps/shared/components/mail/compose/RichTextEditor.js +20 -2
- package/dist/apps/shared/components/mail/compose/composePerf.d.ts +16 -0
- package/dist/apps/shared/components/mail/compose/composePerf.js +41 -0
- package/dist/apps/shared/components/mail/compose/encryptionRequirement.d.ts +49 -0
- package/dist/apps/shared/components/mail/compose/encryptionRequirement.js +35 -0
- package/dist/apps/shared/components/mail/compose/quotedBody.d.ts +13 -0
- package/dist/apps/shared/components/mail/compose/quotedBody.js +67 -11
- package/dist/apps/shared/components/mail/layout/MailShell.d.ts +14 -4
- package/dist/apps/shared/components/mail/layout/MailShell.js +90 -104
- package/dist/apps/shared/components/mail/reading/EncryptedBody.d.ts +21 -0
- package/dist/apps/shared/components/mail/reading/EncryptedBody.js +22 -0
- package/dist/apps/shared/components/mail/reading/EncryptedPreview.d.ts +18 -0
- package/dist/apps/shared/components/mail/reading/EncryptedPreview.js +22 -0
- package/dist/apps/shared/components/mail/reading/MessageBody.d.ts +32 -0
- package/dist/apps/shared/components/mail/reading/MessageBody.js +136 -0
- package/dist/apps/shared/components/mail/reading/MessageCard.d.ts +62 -0
- package/dist/apps/shared/components/mail/reading/MessageCard.js +58 -0
- package/dist/apps/shared/components/mail/reading/bodyContent.d.ts +38 -0
- package/dist/apps/shared/components/mail/reading/bodyContent.js +84 -0
- package/dist/apps/shared/components/mail/reading/bodyHtml.d.ts +47 -0
- package/dist/apps/shared/components/mail/reading/bodyHtml.js +267 -0
- package/dist/apps/shared/components/mail/reading/color.d.ts +63 -0
- package/dist/apps/shared/components/mail/reading/color.js +201 -0
- package/dist/apps/shared/components/mail/reading/frameControl.d.ts +33 -0
- package/dist/apps/shared/components/mail/reading/frameControl.js +120 -0
- package/dist/apps/shared/components/mail/reading/frameDocument.d.ts +52 -0
- package/dist/apps/shared/components/mail/reading/frameDocument.js +98 -0
- package/dist/apps/shared/components/mail/reading/safeDocument.d.ts +3 -0
- package/dist/apps/shared/components/mail/reading/safeDocument.js +12 -0
- package/dist/apps/shared/components/mail/reading/themeAdaptation.d.ts +56 -0
- package/dist/apps/shared/components/mail/reading/themeAdaptation.js +144 -0
- package/dist/apps/shared/components/mail/reading/themeSurface.d.ts +17 -0
- package/dist/apps/shared/components/mail/reading/themeSurface.js +83 -0
- package/dist/apps/shared/components/mail/reading/viewOriginal.d.ts +9 -0
- package/dist/apps/shared/components/mail/reading/viewOriginal.js +32 -0
- package/dist/apps/shared/components/mail/unreadStyle.d.ts +45 -0
- package/dist/apps/shared/components/mail/unreadStyle.js +61 -0
- package/dist/apps/shared/components/settings/SigningCertificateCard.d.ts +32 -0
- package/dist/apps/shared/components/settings/SigningCertificateCard.js +98 -0
- package/dist/apps/shared/components/settings/layout/SettingsShell.d.ts +1 -1
- package/dist/apps/shared/components/settings/layout/SettingsShell.js +16 -5
- package/dist/apps/shared/components/sharing/PrincipalPicker.d.ts +26 -0
- package/dist/apps/shared/components/sharing/PrincipalPicker.js +77 -0
- package/dist/apps/shared/components/tasks/TasksSidebar.js +4 -2
- package/dist/apps/shared/components/tasks/layout/TasksShell.d.ts +1 -1
- package/dist/apps/shared/components/tasks/layout/TasksShell.js +18 -6
- package/dist/apps/shared/keyboard/GlobalShortcuts.d.ts +14 -0
- package/dist/apps/shared/keyboard/GlobalShortcuts.js +37 -0
- package/dist/apps/shared/keyboard/ShortcutProvider.d.ts +20 -0
- package/dist/apps/shared/keyboard/ShortcutProvider.js +52 -0
- package/dist/apps/shared/keyboard/ShortcutsDialog.d.ts +14 -0
- package/dist/apps/shared/keyboard/ShortcutsDialog.js +42 -0
- package/dist/apps/shared/keyboard/dispatch.d.ts +16 -0
- package/dist/apps/shared/keyboard/dispatch.js +109 -0
- package/dist/apps/shared/keyboard/format.d.ts +12 -0
- package/dist/apps/shared/keyboard/format.js +74 -0
- package/dist/apps/shared/keyboard/keymap.d.ts +294 -0
- package/dist/apps/shared/keyboard/keymap.js +84 -0
- package/dist/apps/shared/keyboard/match.d.ts +20 -0
- package/dist/apps/shared/keyboard/match.js +31 -0
- package/dist/apps/shared/keyboard/parse.d.ts +31 -0
- package/dist/apps/shared/keyboard/parse.js +107 -0
- package/dist/apps/shared/keyboard/platform.d.ts +15 -0
- package/dist/apps/shared/keyboard/platform.js +22 -0
- package/dist/apps/shared/keyboard/registry.d.ts +39 -0
- package/dist/apps/shared/keyboard/registry.js +33 -0
- package/dist/apps/shared/keyboard/targets.d.ts +14 -0
- package/dist/apps/shared/keyboard/targets.js +67 -0
- package/dist/apps/shared/keyboard/useShortcut.d.ts +19 -0
- package/dist/apps/shared/keyboard/useShortcut.js +35 -0
- package/dist/apps/shared/keyboard/useShortcutProps.d.ts +10 -0
- package/dist/apps/shared/keyboard/useShortcutProps.js +15 -0
- package/dist/apps/shared/mail/folderCounts.d.ts +78 -0
- package/dist/apps/shared/mail/folderCounts.js +218 -0
- package/dist/apps/shared/mail/folderTree.d.ts +55 -0
- package/dist/apps/shared/mail/folderTree.js +116 -0
- package/dist/apps/shared/mail/listSnapshots.d.ts +46 -0
- package/dist/apps/shared/mail/listSnapshots.js +43 -0
- package/dist/apps/shared/mail/messageReadState.d.ts +32 -0
- package/dist/apps/shared/mail/messageReadState.js +63 -0
- package/dist/apps/shared/mail/newMailNotifications.d.ts +62 -0
- package/dist/apps/shared/mail/newMailNotifications.js +138 -0
- package/dist/apps/shared/mail/outbox/UnlockBridge.d.ts +5 -0
- package/dist/apps/shared/mail/outbox/UnlockBridge.js +18 -0
- package/dist/apps/shared/mail/outbox/composeBridge.d.ts +34 -0
- package/dist/apps/shared/mail/outbox/composeBridge.js +32 -0
- package/dist/apps/shared/mail/outbox/outboxState.d.ts +41 -0
- package/dist/apps/shared/mail/outbox/outboxState.js +42 -0
- package/dist/apps/shared/mail/outbox/pendingSends.d.ts +39 -0
- package/dist/apps/shared/mail/outbox/pendingSends.js +109 -0
- package/dist/apps/shared/mail/outbox/sendDecision.d.ts +80 -0
- package/dist/apps/shared/mail/outbox/sendDecision.js +94 -0
- package/dist/apps/shared/mail/outbox/sendJob.d.ts +68 -0
- package/dist/apps/shared/mail/outbox/sendJob.js +319 -0
- package/dist/apps/shared/mail/outbox/sendOutcomes.d.ts +3 -0
- package/dist/apps/shared/mail/outbox/sendOutcomes.js +141 -0
- package/dist/apps/shared/mail/outbox/sendState.d.ts +25 -0
- package/dist/apps/shared/mail/outbox/sendState.js +8 -0
- package/dist/apps/shared/mail/outbox/useOutboxStatus.d.ts +11 -0
- package/dist/apps/shared/mail/outbox/useOutboxStatus.js +49 -0
- package/dist/apps/shared/mail/useMailConnection.d.ts +56 -0
- package/dist/apps/shared/mail/useMailConnection.js +138 -0
- package/dist/apps/shared/mail/useMailLiveUpdates.d.ts +29 -9
- package/dist/apps/shared/mail/useMailLiveUpdates.js +60 -32
- package/dist/apps/shared/mail/useMarkMessageRead.d.ts +12 -0
- package/dist/apps/shared/mail/useMarkMessageRead.js +44 -0
- package/dist/apps/shared/mail/useNewMailNotifications.d.ts +35 -0
- package/dist/apps/shared/mail/useNewMailNotifications.js +130 -0
- package/dist/apps/shared/mail/useUnreadTitle.d.ts +18 -0
- package/dist/apps/shared/mail/useUnreadTitle.js +31 -0
- package/dist/apps/shared/navigation/AppRouter.d.ts +52 -0
- package/dist/apps/shared/navigation/AppRouter.js +242 -0
- package/dist/apps/shared/navigation/appHrefs.d.ts +14 -0
- package/dist/apps/shared/navigation/appHrefs.js +20 -0
- package/dist/apps/shared/navigation/frameContext.d.ts +19 -0
- package/dist/apps/shared/navigation/frameContext.js +24 -0
- package/dist/apps/shared/navigation/idle.d.ts +14 -0
- package/dist/apps/shared/navigation/idle.js +43 -0
- package/dist/apps/shared/navigation/routerContext.d.ts +37 -0
- package/dist/apps/shared/navigation/routerContext.js +56 -0
- package/dist/apps/shared/navigation/routes.d.ts +32 -0
- package/dist/apps/shared/navigation/routes.js +37 -0
- package/dist/apps/shared/notifications/NotificationCenter.d.ts +19 -0
- package/dist/apps/shared/notifications/NotificationCenter.js +90 -0
- package/dist/apps/shared/notifications/NotificationHistoryDialog.d.ts +10 -0
- package/dist/apps/shared/notifications/NotificationHistoryDialog.js +36 -0
- package/dist/apps/shared/notifications/apiErrors.d.ts +19 -0
- package/dist/apps/shared/notifications/apiErrors.js +86 -0
- package/dist/apps/shared/notifications/headerOffset.d.ts +8 -0
- package/dist/apps/shared/notifications/headerOffset.js +33 -0
- package/dist/apps/shared/notifications/pushStatus.d.ts +9 -0
- package/dist/apps/shared/notifications/pushStatus.js +54 -0
- package/dist/apps/shared/notifications/store.d.ts +136 -0
- package/dist/apps/shared/notifications/store.js +416 -0
- package/dist/apps/shared/notifications/systemErrors.d.ts +9 -0
- package/dist/apps/shared/notifications/systemErrors.js +58 -0
- package/dist/apps/shared/notifications/useNotifications.d.ts +17 -0
- package/dist/apps/shared/notifications/useNotifications.js +18 -0
- package/dist/apps/shared/search/LocalIndexLifecycle.js +17 -3
- package/dist/apps/shared/signing/enrollmentStorage.d.ts +10 -0
- package/dist/apps/shared/signing/enrollmentStorage.js +33 -0
- package/dist/apps/shared/signing/enrollmentTracker.d.ts +73 -0
- package/dist/apps/shared/signing/enrollmentTracker.js +307 -0
- package/dist/apps/shared/signing/enrollmentView.d.ts +57 -0
- package/dist/apps/shared/signing/enrollmentView.js +214 -0
- package/dist/apps/shared/signing/signingInfo.d.ts +11 -0
- package/dist/apps/shared/signing/signingInfo.js +48 -0
- package/dist/apps/shared/signing/useNow.d.ts +2 -0
- package/dist/apps/shared/signing/useNow.js +18 -0
- package/dist/apps/shared/signing/useSigningEnrollmentWatcher.d.ts +16 -0
- package/dist/apps/shared/signing/useSigningEnrollmentWatcher.js +87 -0
- package/dist/apps/shared/styles/app.css +108 -10
- package/dist/apps/www/_layout.d.ts +5 -1
- package/dist/apps/www/_layout.js +3 -2
- package/dist/apps/www/_routedPage.d.ts +12 -0
- package/dist/apps/www/_routedPage.js +19 -0
- package/dist/apps/www/_routes.d.ts +11 -0
- package/dist/apps/www/_routes.js +30 -0
- package/dist/apps/www/calendar/index.d.ts +2 -2
- package/dist/apps/www/calendar/index.js +41 -11
- package/dist/apps/www/contacts/[uid].d.ts +3 -9
- package/dist/apps/www/contacts/[uid].js +11 -9
- package/dist/apps/www/contacts/index.d.ts +2 -2
- package/dist/apps/www/contacts/index.js +30 -24
- package/dist/apps/www/index.d.ts +2 -2
- package/dist/apps/www/index.js +332 -48
- package/dist/apps/www/messages/[uid].d.ts +3 -7
- package/dist/apps/www/messages/[uid].js +10 -5
- package/dist/apps/www/settings/appearance/index.d.ts +4 -0
- package/dist/apps/www/settings/appearance/index.js +13 -0
- package/dist/apps/www/settings/auto-reply/index.d.ts +2 -2
- package/dist/apps/www/settings/auto-reply/index.js +6 -7
- package/dist/apps/www/settings/encryption/index.d.ts +2 -2
- package/dist/apps/www/settings/encryption/index.js +106 -96
- package/dist/apps/www/settings/filters/[uid].d.ts +2 -2
- package/dist/apps/www/settings/filters/[uid].js +6 -2
- package/dist/apps/www/settings/filters/index.d.ts +2 -2
- package/dist/apps/www/settings/filters/index.js +3 -1
- package/dist/apps/www/settings/filters/new/index.d.ts +2 -2
- package/dist/apps/www/settings/filters/new/index.js +9 -3
- package/dist/apps/www/settings/labels/index.d.ts +2 -2
- package/dist/apps/www/settings/labels/index.js +3 -1
- package/dist/apps/www/settings/privacy/index.d.ts +2 -2
- package/dist/apps/www/settings/privacy/index.js +8 -9
- package/dist/apps/www/settings/read-receipts/index.d.ts +2 -2
- package/dist/apps/www/settings/read-receipts/index.js +6 -7
- package/dist/apps/www/settings/sharing/index.d.ts +2 -2
- package/dist/apps/www/settings/sharing/index.js +22 -34
- package/dist/apps/www/settings/signatures/[uid].d.ts +2 -2
- package/dist/apps/www/settings/signatures/[uid].js +6 -2
- package/dist/apps/www/settings/signatures/index.d.ts +2 -2
- package/dist/apps/www/settings/signatures/index.js +3 -1
- package/dist/apps/www/settings/signatures/new/index.d.ts +2 -2
- package/dist/apps/www/settings/signatures/new/index.js +9 -4
- package/dist/apps/www/tasks/index.d.ts +2 -2
- package/dist/apps/www/tasks/index.js +22 -16
- package/package.json +2 -2
- package/apps/shared/components/mail/compose/SendFailureAlert.tsx +0 -48
- package/dist/apps/shared/components/mail/compose/SendFailureAlert.d.ts +0 -14
- package/dist/apps/shared/components/mail/compose/SendFailureAlert.js +0 -11
|
@@ -1,98 +1,114 @@
|
|
|
1
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
-
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
|
-
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
-
/**
|
|
6
|
-
* Mounts the Tier 2 local index's lifecycle: starts the background build for the active mailbox once it's
|
|
7
|
-
* unlocked, and destroys an index on the same events that destroy that mailbox's unlocked keys (spec §11
|
|
8
|
-
* "MUST be destroyed on the same events that destroy private keys: explicit logout, session revocation,
|
|
9
|
-
* and the configurable idle timeout").
|
|
10
|
-
*
|
|
11
|
-
* **Why polling, not hooking the existing destroy call sites directly**: `destroyUnlockedKeys()`
|
|
12
|
-
* (`react-shared/src/crypto/keySession.ts`) has no observer/callback hook. Watching `getUnlockedKeys()`
|
|
13
|
-
* for a present-to-absent transition catches *every* destroy path uniformly - idle timeout, the manual
|
|
14
|
-
* button, or anything else that calls it - without needing to know which one fired.
|
|
15
|
-
*
|
|
16
|
-
* Every mailbox this component has seen unlocked is tracked for the life of the mount - not just whichever
|
|
17
|
-
* is active right now - so switching mailboxes (or a folders-list refresh re-running the build effect)
|
|
18
|
-
* can never lose a pending unlocked-to-locked transition for a mailbox whose index was already built.
|
|
19
|
-
*
|
|
20
|
-
* **Explicit logout** navigates away immediately, which may not leave time for a poll tick - `AppShell.tsx`
|
|
21
|
-
* handles that case itself via `destroyAllLocalIndexes()`.
|
|
22
|
-
*/
|
|
23
|
-
import { useEffect, useRef } from "react";
|
|
24
|
-
import { getUnlockedKeys } from "@rapidmx/react-shared/crypto/keySession.js";
|
|
25
|
-
import type { PublicKey } from "@rapidmx/react-shared/crypto/keyvaultApi.js";
|
|
26
|
-
import type { Folder } from "@rapidmx/react-shared/mail/mailApi.js";
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
export
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
+
/**
|
|
6
|
+
* Mounts the Tier 2 local index's lifecycle: starts the background build for the active mailbox once it's
|
|
7
|
+
* unlocked, and destroys an index on the same events that destroy that mailbox's unlocked keys (spec §11
|
|
8
|
+
* "MUST be destroyed on the same events that destroy private keys: explicit logout, session revocation,
|
|
9
|
+
* and the configurable idle timeout").
|
|
10
|
+
*
|
|
11
|
+
* **Why polling, not hooking the existing destroy call sites directly**: `destroyUnlockedKeys()`
|
|
12
|
+
* (`react-shared/src/crypto/keySession.ts`) has no observer/callback hook. Watching `getUnlockedKeys()`
|
|
13
|
+
* for a present-to-absent transition catches *every* destroy path uniformly - idle timeout, the manual
|
|
14
|
+
* button, or anything else that calls it - without needing to know which one fired.
|
|
15
|
+
*
|
|
16
|
+
* Every mailbox this component has seen unlocked is tracked for the life of the mount - not just whichever
|
|
17
|
+
* is active right now - so switching mailboxes (or a folders-list refresh re-running the build effect)
|
|
18
|
+
* can never lose a pending unlocked-to-locked transition for a mailbox whose index was already built.
|
|
19
|
+
*
|
|
20
|
+
* **Explicit logout** navigates away immediately, which may not leave time for a poll tick - `AppShell.tsx`
|
|
21
|
+
* handles that case itself via `destroyAllLocalIndexes()`.
|
|
22
|
+
*/
|
|
23
|
+
import { useEffect, useRef } from "react";
|
|
24
|
+
import { getUnlockedKeys } from "@rapidmx/react-shared/crypto/keySession.js";
|
|
25
|
+
import type { PublicKey } from "@rapidmx/react-shared/crypto/keyvaultApi.js";
|
|
26
|
+
import type { Folder } from "@rapidmx/react-shared/mail/mailApi.js";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The index builder (with the message security code it decrypts through - PKI.js and the ASN.1/X.509 libraries, over half a
|
|
30
|
+
* megabyte) is loaded only once a mailbox is actually unlocked and a build is due, so an inbox that never unlocks - the
|
|
31
|
+
* common case - never downloads it.
|
|
32
|
+
*/
|
|
33
|
+
let builder: Promise<typeof import("./localIndexBuilder.js")> | undefined;
|
|
34
|
+
const loadBuilder = () =>
|
|
35
|
+
(builder ??= import("./localIndexBuilder.js").catch((err) => {
|
|
36
|
+
// A failed download is tried again the next time one is due.
|
|
37
|
+
builder = undefined;
|
|
38
|
+
throw err;
|
|
39
|
+
}));
|
|
40
|
+
import { destroyLocalIndex, pruneInaccessibleLocalIndexes } from "./localIndexRpcClient.js";
|
|
41
|
+
|
|
42
|
+
export const POLL_INTERVAL_MS = 5_000;
|
|
43
|
+
|
|
44
|
+
export interface LocalIndexLifecycleProps {
|
|
45
|
+
mailboxUid?: string;
|
|
46
|
+
mailboxKeys?: PublicKey[];
|
|
47
|
+
folders: Folder[];
|
|
48
|
+
/** Every mailbox the signed-in user can currently access. Once known, indexes on this device for any
|
|
49
|
+
* other mailbox (e.g. left behind by a different user who never signed out) are removed. */
|
|
50
|
+
accessibleMailboxUids?: string[];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Renders nothing - pure side-effect component, mounted by `MailShell.tsx`. */
|
|
54
|
+
export default function LocalIndexLifecycle({ mailboxUid, folders, accessibleMailboxUids }: LocalIndexLifecycleProps) {
|
|
55
|
+
// mailboxUid -> whether it was unlocked at the last check. An entry exists for every mailbox whose
|
|
56
|
+
// build this component started; only ever changed by a real observed transition, never reset by an
|
|
57
|
+
// effect re-run.
|
|
58
|
+
const trackedRef = useRef(new Map<string, boolean>());
|
|
59
|
+
// The latest props, for the long-lived polling interval below.
|
|
60
|
+
const latestRef = useRef({ mailboxUid, folders });
|
|
61
|
+
latestRef.current = { mailboxUid, folders };
|
|
62
|
+
|
|
63
|
+
function startBuildIfUnlocked(targetMailboxUid: string, targetFolders: Folder[]) {
|
|
64
|
+
const unlocked = getUnlockedKeys(targetMailboxUid);
|
|
65
|
+
if (!unlocked || targetFolders.length === 0 || trackedRef.current.get(targetMailboxUid)) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
trackedRef.current.set(targetMailboxUid, true);
|
|
69
|
+
// Never an unhandled rejection - a broken local index is best-effort infrastructure, not a build
|
|
70
|
+
// the rest of the app depends on.
|
|
71
|
+
loadBuilder()
|
|
72
|
+
.then(({ buildLocalIndex }) => buildLocalIndex(targetMailboxUid, unlocked, targetFolders))
|
|
73
|
+
.catch(() => undefined);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (mailboxUid) {
|
|
78
|
+
startBuildIfUnlocked(mailboxUid, folders);
|
|
79
|
+
}
|
|
80
|
+
}, [mailboxUid, folders]);
|
|
81
|
+
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
const interval = setInterval(() => {
|
|
84
|
+
for (const [trackedUid, wasUnlocked] of trackedRef.current) {
|
|
85
|
+
if (wasUnlocked && !getUnlockedKeys(trackedUid)) {
|
|
86
|
+
// A present-to-absent transition: something just destroyed this mailbox's keys.
|
|
87
|
+
trackedRef.current.set(trackedUid, false);
|
|
88
|
+
// Stop the pass still running with the now-destroyed keys; the destroy itself also makes
|
|
89
|
+
// the Worker reject anything that pass still sends.
|
|
90
|
+
loadBuilder()
|
|
91
|
+
.then(({ cancelLocalIndexBuild }) => cancelLocalIndexBuild(trackedUid))
|
|
92
|
+
.catch(() => undefined);
|
|
93
|
+
void destroyLocalIndex(trackedUid);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
// The active mailbox was (re-)unlocked since the last check, e.g. via an on-demand unlock prompt.
|
|
97
|
+
const { mailboxUid: activeUid, folders: activeFolders } = latestRef.current;
|
|
98
|
+
if (activeUid) {
|
|
99
|
+
startBuildIfUnlocked(activeUid, activeFolders);
|
|
100
|
+
}
|
|
101
|
+
}, POLL_INTERVAL_MS);
|
|
102
|
+
return () => clearInterval(interval);
|
|
103
|
+
}, []);
|
|
104
|
+
|
|
105
|
+
// A stable string key so a re-render with an equal-but-new array doesn't re-scan OPFS.
|
|
106
|
+
const accessibleKey = accessibleMailboxUids && accessibleMailboxUids.length > 0 ? JSON.stringify([...accessibleMailboxUids].sort()) : "";
|
|
107
|
+
useEffect(() => {
|
|
108
|
+
if (accessibleKey) {
|
|
109
|
+
void pruneInaccessibleLocalIndexes(JSON.parse(accessibleKey) as string[]);
|
|
110
|
+
}
|
|
111
|
+
}, [accessibleKey]);
|
|
112
|
+
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A started signing enrollment's id, per mailbox. Kept only so a reload - and the app frame's watcher, on any page - can ask the server
|
|
8
|
+
* (`checkSignEnrollmentStatus()`) whether that enrollment is still pending: a rotation while it is pending would strand the enrollment's
|
|
9
|
+
* already-submitted private key under a master key that no longer exists. The stored id is never trusted on its own - the server's answer
|
|
10
|
+
* decides the state, and restapi's own `rekey()` refuses (409) a rotation during an enrollment this browser never saw (e.g. one started on
|
|
11
|
+
* another device).
|
|
12
|
+
*/
|
|
13
|
+
export const SIGN_ENROLLMENT_STORAGE_PREFIX = "rapidmx.signEnrollment.";
|
|
14
|
+
|
|
15
|
+
export function readStoredSignEnrollment(mailboxUid: string): string | null {
|
|
16
|
+
try {
|
|
17
|
+
return localStorage.getItem(SIGN_ENROLLMENT_STORAGE_PREFIX + mailboxUid);
|
|
18
|
+
} catch {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function storeSignEnrollment(mailboxUid: string, enrollmentId: string | null): void {
|
|
24
|
+
try {
|
|
25
|
+
if (enrollmentId) {
|
|
26
|
+
localStorage.setItem(SIGN_ENROLLMENT_STORAGE_PREFIX + mailboxUid, enrollmentId);
|
|
27
|
+
} else {
|
|
28
|
+
localStorage.removeItem(SIGN_ENROLLMENT_STORAGE_PREFIX + mailboxUid);
|
|
29
|
+
}
|
|
30
|
+
} catch {
|
|
31
|
+
// Storage blocked - restapi's own 409 on rekey still guards a rotation.
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
+
import { useSyncExternalStore } from "react";
|
|
6
|
+
import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
|
|
7
|
+
import {
|
|
8
|
+
CurrentSignEnrollment,
|
|
9
|
+
EnrollmentResult,
|
|
10
|
+
checkNowRetryAfterSeconds,
|
|
11
|
+
checkSignEnrollmentNow,
|
|
12
|
+
checkSignEnrollmentStatus,
|
|
13
|
+
} from "@rapidmx/react-shared/crypto/keyvaultApi.js";
|
|
14
|
+
import { SIGNING_ENROLLMENT_UNKNOWN } from "@rapidmx/react-shared/crypto/signingProviderApi.js";
|
|
15
|
+
import { storeSignEnrollment } from "./enrollmentStorage.js";
|
|
16
|
+
import { resetSigningInfo } from "./signingInfo.js";
|
|
17
|
+
|
|
18
|
+
/** The code of the 404 the server answers for an enrollment id it does not know (another provider after a configuration change, one long gone).
|
|
19
|
+
* Re-exported from react-shared's `signingProviderApi.js` (R6's) rather than a second copy of the literal. */
|
|
20
|
+
export const UNKNOWN_ENROLLMENT_CODE = SIGNING_ENROLLMENT_UNKNOWN;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Follows the signing-certificate enrollments this browser knows about, one per mailbox, for everyone who wants to show or react to one:
|
|
24
|
+
* the Settings > Encryption card and the app frame's watcher share it, so an enrollment is asked about once however many look at it.
|
|
25
|
+
*
|
|
26
|
+
* An enrollment is a real e-mail round trip with a public CA (minutes), so it is read - not hammered: after the first answer it asks again
|
|
27
|
+
* after 15 s, then 30 s, then every 60 s, **only while the page is visible** (a hidden tab asks nothing; coming back to the front, or the
|
|
28
|
+
* window taking focus, asks at once and starts the backoff over), and it stops for good when the enrollment is issued or failed.
|
|
29
|
+
* `checkNow()` is the user's "Check status": it asks the server to re-check with the CA, with a cooldown so it can't be spammed.
|
|
30
|
+
*
|
|
31
|
+
* Framework-free apart from the `useSyncExternalStore` hook at the bottom; safe where there is no window (nothing runs until `watch()`).
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/** The wait before each re-read of a pending enrollment: the last value repeats. */
|
|
35
|
+
export const ENROLLMENT_POLL_DELAYS_MS = [15_000, 30_000, 60_000];
|
|
36
|
+
|
|
37
|
+
/** How long "Check status" stays unavailable after a check (the server refuses one within about ten seconds of the last). */
|
|
38
|
+
export const ENROLLMENT_CHECK_COOLDOWN_MS = 10_000;
|
|
39
|
+
|
|
40
|
+
/** What came of the last manual check. */
|
|
41
|
+
export type CheckOutcome = "changed" | "unchanged" | "limited" | "failed";
|
|
42
|
+
|
|
43
|
+
export interface EnrollmentSnapshot {
|
|
44
|
+
mailboxUid: string;
|
|
45
|
+
enrollmentId: string;
|
|
46
|
+
/** The latest answer. `null` until the server has answered (or when its answers never arrive). */
|
|
47
|
+
result: EnrollmentResult | null;
|
|
48
|
+
/** When this browser last got an answer (its own clock), or `null`. */
|
|
49
|
+
answeredAt: number | null;
|
|
50
|
+
/** A read is in flight. */
|
|
51
|
+
checking: boolean;
|
|
52
|
+
/** A manual check is in flight: the button's busy state. */
|
|
53
|
+
checkingNow: boolean;
|
|
54
|
+
/** "Check status" is unavailable until this time (epoch ms); `0` when it is available. */
|
|
55
|
+
retryAt: number;
|
|
56
|
+
/** The last read did not get an answer (offline, a server error) - what is shown is what was known. */
|
|
57
|
+
offline: boolean;
|
|
58
|
+
/** The server no longer knows this enrollment (404). */
|
|
59
|
+
gone: boolean;
|
|
60
|
+
/** The last manual check, for the words under the button. */
|
|
61
|
+
lastCheck: { at: number; outcome: CheckOutcome } | null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
interface Entry {
|
|
65
|
+
snapshot: EnrollmentSnapshot;
|
|
66
|
+
refs: number;
|
|
67
|
+
timer: ReturnType<typeof setTimeout> | undefined;
|
|
68
|
+
/** Reads since the backoff began: picks the next delay. */
|
|
69
|
+
attempt: number;
|
|
70
|
+
/** A timer came due while the page was hidden: nothing is scheduled until it is visible again. */
|
|
71
|
+
paused: boolean;
|
|
72
|
+
/** Ended while this browser was watching a pending enrollment: worth announcing once. */
|
|
73
|
+
expectPending: boolean;
|
|
74
|
+
announced: boolean;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const entries = new Map<string, Entry>();
|
|
78
|
+
const listeners = new Set<() => void>();
|
|
79
|
+
const terminalListeners = new Set<(snapshot: EnrollmentSnapshot) => void>();
|
|
80
|
+
let environmentBound = false;
|
|
81
|
+
|
|
82
|
+
function isVisible(): boolean {
|
|
83
|
+
return typeof document === "undefined" || document.visibilityState === "visible";
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function isTerminal(result: EnrollmentResult | null): boolean {
|
|
87
|
+
return result?.status === "issued" || result?.status === "failed";
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function emit(): void {
|
|
91
|
+
listeners.forEach((listener) => listener());
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function update(entry: Entry, patch: Partial<EnrollmentSnapshot>): void {
|
|
95
|
+
entry.snapshot = { ...entry.snapshot, ...patch };
|
|
96
|
+
emit();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function isCurrent(entry: Entry): boolean {
|
|
100
|
+
return entries.get(entry.snapshot.mailboxUid) === entry;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function stop(entry: Entry): void {
|
|
104
|
+
clearTimeout(entry.timer);
|
|
105
|
+
entry.timer = undefined;
|
|
106
|
+
entry.paused = false;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function schedule(entry: Entry): void {
|
|
110
|
+
stop(entry);
|
|
111
|
+
const delay = ENROLLMENT_POLL_DELAYS_MS[Math.min(entry.attempt, ENROLLMENT_POLL_DELAYS_MS.length - 1)];
|
|
112
|
+
entry.attempt += 1;
|
|
113
|
+
entry.timer = setTimeout(() => {
|
|
114
|
+
entry.timer = undefined;
|
|
115
|
+
// (Whatever replaces or ends an entry clears its timer first, so this one is always for the entry as it is.)
|
|
116
|
+
if (!isVisible()) {
|
|
117
|
+
entry.paused = true;
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
void read(entry);
|
|
121
|
+
}, delay);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Puts an answer on the entry and decides what happens next: keep asking, or end (and tell the watchers once). */
|
|
125
|
+
function apply(entry: Entry, result: EnrollmentResult, patch: Partial<EnrollmentSnapshot> = {}): void {
|
|
126
|
+
if (!isCurrent(entry)) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
update(entry, { result, answeredAt: Date.now(), offline: false, gone: false, checking: false, ...patch });
|
|
130
|
+
if (!isTerminal(result)) {
|
|
131
|
+
schedule(entry);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
stop(entry);
|
|
135
|
+
// The enrollment is over: nothing is pending, so the id is not kept (it is what blocks a rotation across a reload).
|
|
136
|
+
storeSignEnrollment(entry.snapshot.mailboxUid, null);
|
|
137
|
+
if (entry.expectPending && !entry.announced) {
|
|
138
|
+
entry.announced = true;
|
|
139
|
+
terminalListeners.forEach((listener) => listener(entry.snapshot));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** A failed read: the server no longer has the enrollment (nothing is pending), or it could not be reached (assume it is still going). */
|
|
144
|
+
function fail(entry: Entry, err: unknown, patch: Partial<EnrollmentSnapshot> = {}): void {
|
|
145
|
+
if (!isCurrent(entry)) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
if (err instanceof ApiRequestError && err.status === 404) {
|
|
149
|
+
stop(entry);
|
|
150
|
+
storeSignEnrollment(entry.snapshot.mailboxUid, null);
|
|
151
|
+
update(entry, { gone: true, offline: false, checking: false, ...patch });
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
update(entry, { offline: true, checking: false, ...patch });
|
|
155
|
+
schedule(entry);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
async function read(entry: Entry): Promise<void> {
|
|
159
|
+
update(entry, { checking: true });
|
|
160
|
+
try {
|
|
161
|
+
apply(entry, await checkSignEnrollmentStatus(entry.snapshot.mailboxUid, entry.snapshot.enrollmentId));
|
|
162
|
+
} catch (err) {
|
|
163
|
+
fail(entry, err);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function resume(): void {
|
|
168
|
+
if (!isVisible()) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
entries.forEach((entry) => {
|
|
172
|
+
if (entry.paused && !isTerminal(entry.snapshot.result)) {
|
|
173
|
+
entry.paused = false;
|
|
174
|
+
entry.attempt = 0;
|
|
175
|
+
void read(entry);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function bindEnvironment(): void {
|
|
181
|
+
if (!environmentBound && typeof document !== "undefined") {
|
|
182
|
+
environmentBound = true;
|
|
183
|
+
document.addEventListener("visibilitychange", resume);
|
|
184
|
+
window.addEventListener("focus", resume);
|
|
185
|
+
window.addEventListener("online", resume);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function unbindEnvironment(): void {
|
|
190
|
+
if (environmentBound && entries.size === 0) {
|
|
191
|
+
environmentBound = false;
|
|
192
|
+
document.removeEventListener("visibilitychange", resume);
|
|
193
|
+
window.removeEventListener("focus", resume);
|
|
194
|
+
window.removeEventListener("online", resume);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export interface WatchOptions {
|
|
199
|
+
/** What is already known (a `getCurrentSignEnrollment()` answer): shown at once and not asked again first. */
|
|
200
|
+
initial?: EnrollmentResult;
|
|
201
|
+
/** This enrollment was pending when it was stored, so its ending is news (a stored id, a pending one found on the server). Default `true`. */
|
|
202
|
+
expectPending?: boolean;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Starts following `enrollmentId` for `mailboxUid` (one enrollment per mailbox; a different id replaces the old one) and returns the
|
|
207
|
+
* function that lets go. Reads it now unless `initial` says what it is, then keeps reading with backoff while it is pending. Following is
|
|
208
|
+
* shared, and a pending enrollment stays followed after everyone has let go (until it ends); an ended one is forgotten.
|
|
209
|
+
*/
|
|
210
|
+
export function watchEnrollment(mailboxUid: string, enrollmentId: string, options: WatchOptions = {}): () => void {
|
|
211
|
+
const { initial, expectPending = true } = options;
|
|
212
|
+
let entry = entries.get(mailboxUid);
|
|
213
|
+
if (entry && entry.snapshot.enrollmentId !== enrollmentId) {
|
|
214
|
+
stop(entry);
|
|
215
|
+
entry = undefined;
|
|
216
|
+
}
|
|
217
|
+
if (entry) {
|
|
218
|
+
entry.refs += 1;
|
|
219
|
+
entry.expectPending ||= expectPending && !isTerminal(entry.snapshot.result);
|
|
220
|
+
if (initial && !entry.snapshot.result) {
|
|
221
|
+
apply(entry, initial);
|
|
222
|
+
}
|
|
223
|
+
} else {
|
|
224
|
+
const created: Entry = {
|
|
225
|
+
snapshot: {
|
|
226
|
+
mailboxUid,
|
|
227
|
+
enrollmentId,
|
|
228
|
+
result: null,
|
|
229
|
+
answeredAt: null,
|
|
230
|
+
checking: false,
|
|
231
|
+
checkingNow: false,
|
|
232
|
+
retryAt: 0,
|
|
233
|
+
offline: false,
|
|
234
|
+
gone: false,
|
|
235
|
+
lastCheck: null,
|
|
236
|
+
},
|
|
237
|
+
refs: 1,
|
|
238
|
+
timer: undefined,
|
|
239
|
+
attempt: 0,
|
|
240
|
+
paused: false,
|
|
241
|
+
expectPending,
|
|
242
|
+
announced: false,
|
|
243
|
+
};
|
|
244
|
+
entries.set(mailboxUid, created);
|
|
245
|
+
bindEnvironment();
|
|
246
|
+
emit();
|
|
247
|
+
if (initial) {
|
|
248
|
+
apply(created, initial);
|
|
249
|
+
} else {
|
|
250
|
+
void read(created);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
const held = entries.get(mailboxUid)!;
|
|
254
|
+
let released = false;
|
|
255
|
+
return () => {
|
|
256
|
+
if (released) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
released = true;
|
|
260
|
+
held.refs -= 1;
|
|
261
|
+
// A pending enrollment is followed on with nobody looking - that is what lets the frame tell the user it finished wherever they are, and
|
|
262
|
+
// what the next visit to the page shows at once. One that ended (or that the server no longer knows) has nothing left to follow.
|
|
263
|
+
if (held.refs <= 0 && isCurrent(held) && (isTerminal(held.snapshot.result) || held.snapshot.gone)) {
|
|
264
|
+
stop(held);
|
|
265
|
+
entries.delete(mailboxUid);
|
|
266
|
+
unbindEnvironment();
|
|
267
|
+
emit();
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/** Whether a manual check changed what the user sees: the step, the state or the progress. */
|
|
273
|
+
function differs(before: EnrollmentResult | null, after: EnrollmentResult): boolean {
|
|
274
|
+
return !before || before.status !== after.status || before.stage !== after.stage || before.progress !== after.progress;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/** "Check status": asks the server to re-check with the CA now. Does nothing while one is under way or within the cooldown. */
|
|
278
|
+
export async function checkEnrollmentNow(mailboxUid: string): Promise<void> {
|
|
279
|
+
const entry = entries.get(mailboxUid);
|
|
280
|
+
if (!entry || entry.snapshot.checkingNow || entry.snapshot.retryAt > Date.now() || isTerminal(entry.snapshot.result)) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
const before = entry.snapshot.result;
|
|
284
|
+
update(entry, { checkingNow: true, checking: true });
|
|
285
|
+
entry.attempt = 0;
|
|
286
|
+
const done = (outcome: CheckOutcome, patch: Partial<EnrollmentSnapshot> = {}) => ({
|
|
287
|
+
checkingNow: false,
|
|
288
|
+
lastCheck: { at: Date.now(), outcome },
|
|
289
|
+
...patch,
|
|
290
|
+
});
|
|
291
|
+
try {
|
|
292
|
+
const result = await checkSignEnrollmentNow(mailboxUid, entry.snapshot.enrollmentId);
|
|
293
|
+
apply(entry, result, done(differs(before, result) ? "changed" : "unchanged", { retryAt: Date.now() + ENROLLMENT_CHECK_COOLDOWN_MS }));
|
|
294
|
+
return;
|
|
295
|
+
} catch (err) {
|
|
296
|
+
const seconds = checkNowRetryAfterSeconds(err);
|
|
297
|
+
if (seconds !== undefined) {
|
|
298
|
+
update(entry, done("limited", { retryAt: Date.now() + seconds * 1000, checking: false }));
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
if (err instanceof ApiRequestError && err.status === 404 && err.code === UNKNOWN_ENROLLMENT_CODE) {
|
|
302
|
+
// The server says this enrollment does not exist: there is nothing to fall back to.
|
|
303
|
+
fail(entry, err, done("failed"));
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
if (!(err instanceof ApiRequestError && [404, 405, 501].includes(err.status))) {
|
|
307
|
+
if (isCurrent(entry)) {
|
|
308
|
+
update(entry, done("failed", { checking: false }));
|
|
309
|
+
}
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
// A server without the check endpoint: a plain read is the "check" it has - and a 404 there says the enrollment itself is gone.
|
|
314
|
+
try {
|
|
315
|
+
const result = await checkSignEnrollmentStatus(mailboxUid, entry.snapshot.enrollmentId);
|
|
316
|
+
apply(entry, result, done(differs(before, result) ? "changed" : "unchanged", { retryAt: Date.now() + ENROLLMENT_CHECK_COOLDOWN_MS }));
|
|
317
|
+
} catch (err) {
|
|
318
|
+
fail(entry, err, done("failed"));
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/** Adopts an enrollment the server reported (`getCurrentSignEnrollment()`) - see `watchEnrollment()`. */
|
|
323
|
+
export function watchCurrentEnrollment(mailboxUid: string, current: CurrentSignEnrollment, expectPending = true): () => void {
|
|
324
|
+
const { enrollmentId, ...result } = current;
|
|
325
|
+
return watchEnrollment(mailboxUid, enrollmentId, { initial: result, expectPending });
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/** Puts an answer the caller got itself (the reply to a cancel that found the certificate already issued) on `mailboxUid`'s enrollment, if it is the one followed. */
|
|
329
|
+
export function recordEnrollmentResult(mailboxUid: string, enrollmentId: string, result: EnrollmentResult): void {
|
|
330
|
+
const entry = entries.get(mailboxUid);
|
|
331
|
+
if (entry && entry.snapshot.enrollmentId === enrollmentId) {
|
|
332
|
+
apply(entry, result);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/** Stops following `mailboxUid`'s enrollment altogether (it was cancelled): nothing is kept, whoever else was watching. */
|
|
337
|
+
export function forgetEnrollment(mailboxUid: string): void {
|
|
338
|
+
const entry = entries.get(mailboxUid);
|
|
339
|
+
if (entry) {
|
|
340
|
+
stop(entry);
|
|
341
|
+
entries.delete(mailboxUid);
|
|
342
|
+
unbindEnvironment();
|
|
343
|
+
emit();
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/** The current state of `mailboxUid`'s followed enrollment, or `undefined` when none is followed. */
|
|
348
|
+
export function getEnrollmentSnapshot(mailboxUid: string): EnrollmentSnapshot | undefined {
|
|
349
|
+
return entries.get(mailboxUid)?.snapshot;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
export function subscribeToEnrollments(listener: () => void): () => void {
|
|
353
|
+
listeners.add(listener);
|
|
354
|
+
return () => {
|
|
355
|
+
listeners.delete(listener);
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/** Called once when an enrollment this browser was following ends (issued or failed) - the frame's watcher raises the pop-up. */
|
|
360
|
+
export function onEnrollmentEnded(listener: (snapshot: EnrollmentSnapshot) => void): () => void {
|
|
361
|
+
terminalListeners.add(listener);
|
|
362
|
+
return () => {
|
|
363
|
+
terminalListeners.delete(listener);
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/** `mailboxUid`'s followed enrollment, kept current (`undefined` when none is followed). */
|
|
368
|
+
export function useEnrollmentSnapshot(mailboxUid: string | undefined): EnrollmentSnapshot | undefined {
|
|
369
|
+
return useSyncExternalStore(
|
|
370
|
+
subscribeToEnrollments,
|
|
371
|
+
() => (mailboxUid ? getEnrollmentSnapshot(mailboxUid) : undefined),
|
|
372
|
+
() => undefined,
|
|
373
|
+
);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/** Forgets everything and stops every timer: for tests, which share the module. */
|
|
377
|
+
export function resetEnrollmentTracker(): void {
|
|
378
|
+
resetSigningInfo();
|
|
379
|
+
entries.forEach(stop);
|
|
380
|
+
entries.clear();
|
|
381
|
+
listeners.clear();
|
|
382
|
+
terminalListeners.clear();
|
|
383
|
+
unbindEnvironment();
|
|
384
|
+
environmentBound = false;
|
|
385
|
+
}
|