@data-club/ai-hub 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/passwordPolicy.d.ts +55 -0
- package/dist/auth/passwordPolicy.d.ts.map +1 -0
- package/dist/auth/passwordPolicy.js +63 -0
- package/dist/auth/passwordPolicy.js.map +1 -0
- package/dist/auth/texts.d.ts +815 -0
- package/dist/auth/texts.d.ts.map +1 -0
- package/dist/auth/texts.js +429 -0
- package/dist/auth/texts.js.map +1 -0
- package/dist/client/AIHubClient.d.ts +1058 -0
- package/dist/client/AIHubClient.d.ts.map +1 -0
- package/dist/client/AIHubClient.js +950 -0
- package/dist/client/AIHubClient.js.map +1 -0
- package/dist/client/index.d.ts +11 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +9 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/sseParser.d.ts +41 -0
- package/dist/client/sseParser.d.ts.map +1 -0
- package/dist/client/sseParser.js +153 -0
- package/dist/client/sseParser.js.map +1 -0
- package/dist/client/tokenStorage.d.ts +56 -0
- package/dist/client/tokenStorage.d.ts.map +1 -0
- package/dist/client/tokenStorage.js +116 -0
- package/dist/client/tokenStorage.js.map +1 -0
- package/dist/components/AgentsPicker/index.d.ts +70 -0
- package/dist/components/AgentsPicker/index.d.ts.map +1 -0
- package/dist/components/AgentsPicker/index.js +63 -0
- package/dist/components/AgentsPicker/index.js.map +1 -0
- package/dist/components/AuthGate/index.d.ts +79 -0
- package/dist/components/AuthGate/index.d.ts.map +1 -0
- package/dist/components/AuthGate/index.js +61 -0
- package/dist/components/AuthGate/index.js.map +1 -0
- package/dist/components/CacheBadge/index.d.ts +88 -0
- package/dist/components/CacheBadge/index.d.ts.map +1 -0
- package/dist/components/CacheBadge/index.js +127 -0
- package/dist/components/CacheBadge/index.js.map +1 -0
- package/dist/components/ChangePassword/index.d.ts +109 -0
- package/dist/components/ChangePassword/index.d.ts.map +1 -0
- package/dist/components/ChangePassword/index.js +142 -0
- package/dist/components/ChangePassword/index.js.map +1 -0
- package/dist/components/ChatShell/ShellHeader.d.ts +44 -0
- package/dist/components/ChatShell/ShellHeader.d.ts.map +1 -0
- package/dist/components/ChatShell/ShellHeader.js +14 -0
- package/dist/components/ChatShell/ShellHeader.js.map +1 -0
- package/dist/components/ChatShell/UserMenu.d.ts +48 -0
- package/dist/components/ChatShell/UserMenu.d.ts.map +1 -0
- package/dist/components/ChatShell/UserMenu.js +86 -0
- package/dist/components/ChatShell/UserMenu.js.map +1 -0
- package/dist/components/ChatShell/index.d.ts +98 -0
- package/dist/components/ChatShell/index.d.ts.map +1 -0
- package/dist/components/ChatShell/index.js +124 -0
- package/dist/components/ChatShell/index.js.map +1 -0
- package/dist/components/DataClubAIHub/index.d.ts +132 -0
- package/dist/components/DataClubAIHub/index.d.ts.map +1 -0
- package/dist/components/DataClubAIHub/index.js +124 -0
- package/dist/components/DataClubAIHub/index.js.map +1 -0
- package/dist/components/DataClubAIHubAdmin/AgentEditorModal.d.ts +89 -0
- package/dist/components/DataClubAIHubAdmin/AgentEditorModal.d.ts.map +1 -0
- package/dist/components/DataClubAIHubAdmin/AgentEditorModal.js +199 -0
- package/dist/components/DataClubAIHubAdmin/AgentEditorModal.js.map +1 -0
- package/dist/components/DataClubAIHubAdmin/AgentsPage.d.ts +33 -0
- package/dist/components/DataClubAIHubAdmin/AgentsPage.d.ts.map +1 -0
- package/dist/components/DataClubAIHubAdmin/AgentsPage.js +137 -0
- package/dist/components/DataClubAIHubAdmin/AgentsPage.js.map +1 -0
- package/dist/components/DataClubAIHubAdmin/CreateUserModal.d.ts +50 -0
- package/dist/components/DataClubAIHubAdmin/CreateUserModal.d.ts.map +1 -0
- package/dist/components/DataClubAIHubAdmin/CreateUserModal.js +93 -0
- package/dist/components/DataClubAIHubAdmin/CreateUserModal.js.map +1 -0
- package/dist/components/DataClubAIHubAdmin/PasswordRevealModal.d.ts +49 -0
- package/dist/components/DataClubAIHubAdmin/PasswordRevealModal.d.ts.map +1 -0
- package/dist/components/DataClubAIHubAdmin/PasswordRevealModal.js +94 -0
- package/dist/components/DataClubAIHubAdmin/PasswordRevealModal.js.map +1 -0
- package/dist/components/DataClubAIHubAdmin/ResetPasswordModal.d.ts +37 -0
- package/dist/components/DataClubAIHubAdmin/ResetPasswordModal.d.ts.map +1 -0
- package/dist/components/DataClubAIHubAdmin/ResetPasswordModal.js +44 -0
- package/dist/components/DataClubAIHubAdmin/ResetPasswordModal.js.map +1 -0
- package/dist/components/DataClubAIHubAdmin/RotatingMessageEditorModal.d.ts +56 -0
- package/dist/components/DataClubAIHubAdmin/RotatingMessageEditorModal.d.ts.map +1 -0
- package/dist/components/DataClubAIHubAdmin/RotatingMessageEditorModal.js +158 -0
- package/dist/components/DataClubAIHubAdmin/RotatingMessageEditorModal.js.map +1 -0
- package/dist/components/DataClubAIHubAdmin/RotatingMessagesPage.d.ts +29 -0
- package/dist/components/DataClubAIHubAdmin/RotatingMessagesPage.d.ts.map +1 -0
- package/dist/components/DataClubAIHubAdmin/RotatingMessagesPage.js +183 -0
- package/dist/components/DataClubAIHubAdmin/RotatingMessagesPage.js.map +1 -0
- package/dist/components/DataClubAIHubAdmin/SessionsOverviewPage.d.ts +38 -0
- package/dist/components/DataClubAIHubAdmin/SessionsOverviewPage.d.ts.map +1 -0
- package/dist/components/DataClubAIHubAdmin/SessionsOverviewPage.js +294 -0
- package/dist/components/DataClubAIHubAdmin/SessionsOverviewPage.js.map +1 -0
- package/dist/components/DataClubAIHubAdmin/SettingsPage.d.ts +36 -0
- package/dist/components/DataClubAIHubAdmin/SettingsPage.d.ts.map +1 -0
- package/dist/components/DataClubAIHubAdmin/SettingsPage.js +373 -0
- package/dist/components/DataClubAIHubAdmin/SettingsPage.js.map +1 -0
- package/dist/components/DataClubAIHubAdmin/UsersPage.d.ts +47 -0
- package/dist/components/DataClubAIHubAdmin/UsersPage.d.ts.map +1 -0
- package/dist/components/DataClubAIHubAdmin/UsersPage.js +233 -0
- package/dist/components/DataClubAIHubAdmin/UsersPage.js.map +1 -0
- package/dist/components/DataClubAIHubAdmin/index.d.ts +87 -0
- package/dist/components/DataClubAIHubAdmin/index.d.ts.map +1 -0
- package/dist/components/DataClubAIHubAdmin/index.js +137 -0
- package/dist/components/DataClubAIHubAdmin/index.js.map +1 -0
- package/dist/components/DataClubAIHubLogin/index.d.ts +113 -0
- package/dist/components/DataClubAIHubLogin/index.d.ts.map +1 -0
- package/dist/components/DataClubAIHubLogin/index.js +123 -0
- package/dist/components/DataClubAIHubLogin/index.js.map +1 -0
- package/dist/components/EffortControl/index.d.ts +57 -0
- package/dist/components/EffortControl/index.d.ts.map +1 -0
- package/dist/components/EffortControl/index.js +84 -0
- package/dist/components/EffortControl/index.js.map +1 -0
- package/dist/components/Layout/index.d.ts +63 -0
- package/dist/components/Layout/index.d.ts.map +1 -0
- package/dist/components/Layout/index.js +45 -0
- package/dist/components/Layout/index.js.map +1 -0
- package/dist/components/MainColumn/index.d.ts +69 -0
- package/dist/components/MainColumn/index.d.ts.map +1 -0
- package/dist/components/MainColumn/index.js +47 -0
- package/dist/components/MainColumn/index.js.map +1 -0
- package/dist/components/MarkdownRenderer/index.d.ts +66 -0
- package/dist/components/MarkdownRenderer/index.d.ts.map +1 -0
- package/dist/components/MarkdownRenderer/index.js +153 -0
- package/dist/components/MarkdownRenderer/index.js.map +1 -0
- package/dist/components/MessageInput/index.d.ts +85 -0
- package/dist/components/MessageInput/index.d.ts.map +1 -0
- package/dist/components/MessageInput/index.js +139 -0
- package/dist/components/MessageInput/index.js.map +1 -0
- package/dist/components/MessageList/index.d.ts +156 -0
- package/dist/components/MessageList/index.d.ts.map +1 -0
- package/dist/components/MessageList/index.js +352 -0
- package/dist/components/MessageList/index.js.map +1 -0
- package/dist/components/ReasoningSelector/index.d.ts +77 -0
- package/dist/components/ReasoningSelector/index.d.ts.map +1 -0
- package/dist/components/ReasoningSelector/index.js +156 -0
- package/dist/components/ReasoningSelector/index.js.map +1 -0
- package/dist/components/ReasoningView/index.d.ts +94 -0
- package/dist/components/ReasoningView/index.d.ts.map +1 -0
- package/dist/components/ReasoningView/index.js +83 -0
- package/dist/components/ReasoningView/index.js.map +1 -0
- package/dist/components/ScrollToPresentButton/index.d.ts +54 -0
- package/dist/components/ScrollToPresentButton/index.d.ts.map +1 -0
- package/dist/components/ScrollToPresentButton/index.js +44 -0
- package/dist/components/ScrollToPresentButton/index.js.map +1 -0
- package/dist/components/SessionsPanel/SessionTitleModal.d.ts +79 -0
- package/dist/components/SessionsPanel/SessionTitleModal.d.ts.map +1 -0
- package/dist/components/SessionsPanel/SessionTitleModal.js +102 -0
- package/dist/components/SessionsPanel/SessionTitleModal.js.map +1 -0
- package/dist/components/SessionsPanel/index.d.ts +100 -0
- package/dist/components/SessionsPanel/index.d.ts.map +1 -0
- package/dist/components/SessionsPanel/index.js +176 -0
- package/dist/components/SessionsPanel/index.js.map +1 -0
- package/dist/components/SystemNotice/index.d.ts +66 -0
- package/dist/components/SystemNotice/index.d.ts.map +1 -0
- package/dist/components/SystemNotice/index.js +81 -0
- package/dist/components/SystemNotice/index.js.map +1 -0
- package/dist/components/ThemeSwitcher/index.d.ts +66 -0
- package/dist/components/ThemeSwitcher/index.d.ts.map +1 -0
- package/dist/components/ThemeSwitcher/index.js +73 -0
- package/dist/components/ThemeSwitcher/index.js.map +1 -0
- package/dist/components/ToolCallView/formatContent.d.ts +36 -0
- package/dist/components/ToolCallView/formatContent.d.ts.map +1 -0
- package/dist/components/ToolCallView/formatContent.js +53 -0
- package/dist/components/ToolCallView/formatContent.js.map +1 -0
- package/dist/components/ToolCallView/index.d.ts +120 -0
- package/dist/components/ToolCallView/index.d.ts.map +1 -0
- package/dist/components/ToolCallView/index.js +104 -0
- package/dist/components/ToolCallView/index.js.map +1 -0
- package/dist/components/TpmBanner/index.d.ts +53 -0
- package/dist/components/TpmBanner/index.d.ts.map +1 -0
- package/dist/components/TpmBanner/index.js +116 -0
- package/dist/components/TpmBanner/index.js.map +1 -0
- package/dist/components/TurnStatusIndicator/index.d.ts +77 -0
- package/dist/components/TurnStatusIndicator/index.d.ts.map +1 -0
- package/dist/components/TurnStatusIndicator/index.js +122 -0
- package/dist/components/TurnStatusIndicator/index.js.map +1 -0
- package/dist/components/internal/PasswordInput.d.ts +62 -0
- package/dist/components/internal/PasswordInput.d.ts.map +1 -0
- package/dist/components/internal/PasswordInput.js +42 -0
- package/dist/components/internal/PasswordInput.js.map +1 -0
- package/dist/context/AIHubContext.d.ts +220 -0
- package/dist/context/AIHubContext.d.ts.map +1 -0
- package/dist/context/AIHubContext.js +19 -0
- package/dist/context/AIHubContext.js.map +1 -0
- package/dist/context/AIHubProvider.d.ts +75 -0
- package/dist/context/AIHubProvider.d.ts.map +1 -0
- package/dist/context/AIHubProvider.js +954 -0
- package/dist/context/AIHubProvider.js.map +1 -0
- package/dist/context/index.d.ts +9 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +9 -0
- package/dist/context/index.js.map +1 -0
- package/dist/context/theme.d.ts +43 -0
- package/dist/context/theme.d.ts.map +1 -0
- package/dist/context/theme.js +70 -0
- package/dist/context/theme.js.map +1 -0
- package/dist/context/useAIHub.d.ts +104 -0
- package/dist/context/useAIHub.d.ts.map +1 -0
- package/dist/context/useAIHub.js +63 -0
- package/dist/context/useAIHub.js.map +1 -0
- package/dist/context/useAIHubAuth.d.ts +44 -0
- package/dist/context/useAIHubAuth.d.ts.map +1 -0
- package/dist/context/useAIHubAuth.js +35 -0
- package/dist/context/useAIHubAuth.js.map +1 -0
- package/dist/index.d.ts +76 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +57 -0
- package/dist/index.js.map +1 -0
- package/dist/primitives/index.d.ts +99 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/index.js +97 -0
- package/dist/primitives/index.js.map +1 -0
- package/dist/state/affordances.d.ts +182 -0
- package/dist/state/affordances.d.ts.map +1 -0
- package/dist/state/affordances.js +189 -0
- package/dist/state/affordances.js.map +1 -0
- package/dist/state/stateReducer.d.ts +72 -0
- package/dist/state/stateReducer.d.ts.map +1 -0
- package/dist/state/stateReducer.js +122 -0
- package/dist/state/stateReducer.js.map +1 -0
- package/dist/stories/EffortControl.stories.d.ts +14 -0
- package/dist/stories/EffortControl.stories.d.ts.map +1 -0
- package/dist/stories/EffortControl.stories.js +43 -0
- package/dist/stories/EffortControl.stories.js.map +1 -0
- package/dist/stories/MarkdownRenderer.stories.d.ts +25 -0
- package/dist/stories/MarkdownRenderer.stories.d.ts.map +1 -0
- package/dist/stories/MarkdownRenderer.stories.js +178 -0
- package/dist/stories/MarkdownRenderer.stories.js.map +1 -0
- package/dist/stories/MessageBubble.stories.d.ts +21 -0
- package/dist/stories/MessageBubble.stories.d.ts.map +1 -0
- package/dist/stories/MessageBubble.stories.js +59 -0
- package/dist/stories/MessageBubble.stories.js.map +1 -0
- package/dist/stories/ReasoningView.stories.d.ts +18 -0
- package/dist/stories/ReasoningView.stories.d.ts.map +1 -0
- package/dist/stories/ReasoningView.stories.js +62 -0
- package/dist/stories/ReasoningView.stories.js.map +1 -0
- package/dist/stories/ScrollToPresentButton.stories.d.ts +18 -0
- package/dist/stories/ScrollToPresentButton.stories.d.ts.map +1 -0
- package/dist/stories/ScrollToPresentButton.stories.js +34 -0
- package/dist/stories/ScrollToPresentButton.stories.js.map +1 -0
- package/dist/stories/SystemNotice.stories.d.ts +17 -0
- package/dist/stories/SystemNotice.stories.d.ts.map +1 -0
- package/dist/stories/SystemNotice.stories.js +42 -0
- package/dist/stories/SystemNotice.stories.js.map +1 -0
- package/dist/stories/ThemeSwitcher.stories.d.ts +15 -0
- package/dist/stories/ThemeSwitcher.stories.d.ts.map +1 -0
- package/dist/stories/ThemeSwitcher.stories.js +35 -0
- package/dist/stories/ThemeSwitcher.stories.js.map +1 -0
- package/dist/stories/ToolCallView.stories.d.ts +20 -0
- package/dist/stories/ToolCallView.stories.d.ts.map +1 -0
- package/dist/stories/ToolCallView.stories.js +65 -0
- package/dist/stories/ToolCallView.stories.js.map +1 -0
- package/dist/stories/TpmBanner.stories.d.ts +24 -0
- package/dist/stories/TpmBanner.stories.d.ts.map +1 -0
- package/dist/stories/TpmBanner.stories.js +63 -0
- package/dist/stories/TpmBanner.stories.js.map +1 -0
- package/dist/stories/TurnStatusIndicator.stories.d.ts +25 -0
- package/dist/stories/TurnStatusIndicator.stories.d.ts.map +1 -0
- package/dist/stories/TurnStatusIndicator.stories.js +56 -0
- package/dist/stories/TurnStatusIndicator.stories.js.map +1 -0
- package/dist/stories/_mockProvider.d.ts +44 -0
- package/dist/stories/_mockProvider.d.ts.map +1 -0
- package/dist/stories/_mockProvider.js +84 -0
- package/dist/stories/_mockProvider.js.map +1 -0
- package/dist/types.d.ts +787 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +19 -0
- package/dist/types.js.map +1 -0
- package/dist/webcomponent/defineWebComponent.d.ts +106 -0
- package/dist/webcomponent/defineWebComponent.d.ts.map +1 -0
- package/dist/webcomponent/defineWebComponent.js +126 -0
- package/dist/webcomponent/defineWebComponent.js.map +1 -0
- package/dist/webcomponent/index.d.ts +7 -0
- package/dist/webcomponent/index.d.ts.map +1 -0
- package/dist/webcomponent/index.js +7 -0
- package/dist/webcomponent/index.js.map +1 -0
- package/package.json +63 -0
- package/src/__lint-canary__/step1-lint-canary.ts.disabled +28 -0
- package/src/auth/passwordPolicy.ts +75 -0
- package/src/auth/texts.ts +1294 -0
- package/src/client/AIHubClient.ts +1718 -0
- package/src/client/index.ts +30 -0
- package/src/client/sseParser.ts +168 -0
- package/src/client/tokenStorage.ts +131 -0
- package/src/components/AgentsPicker/index.tsx +147 -0
- package/src/components/AuthGate/index.tsx +132 -0
- package/src/components/CacheBadge/index.tsx +245 -0
- package/src/components/ChangePassword/index.tsx +375 -0
- package/src/components/ChatShell/ShellHeader.tsx +80 -0
- package/src/components/ChatShell/UserMenu.tsx +196 -0
- package/src/components/ChatShell/index.tsx +307 -0
- package/src/components/DataClubAIHub/index.tsx +300 -0
- package/src/components/DataClubAIHubAdmin/AgentEditorModal.tsx +505 -0
- package/src/components/DataClubAIHubAdmin/AgentsPage.tsx +342 -0
- package/src/components/DataClubAIHubAdmin/CreateUserModal.tsx +214 -0
- package/src/components/DataClubAIHubAdmin/PasswordRevealModal.tsx +204 -0
- package/src/components/DataClubAIHubAdmin/ResetPasswordModal.tsx +122 -0
- package/src/components/DataClubAIHubAdmin/RotatingMessageEditorModal.tsx +408 -0
- package/src/components/DataClubAIHubAdmin/RotatingMessagesPage.tsx +373 -0
- package/src/components/DataClubAIHubAdmin/SessionsOverviewPage.tsx +639 -0
- package/src/components/DataClubAIHubAdmin/SettingsPage.tsx +979 -0
- package/src/components/DataClubAIHubAdmin/UsersPage.tsx +495 -0
- package/src/components/DataClubAIHubAdmin/index.tsx +277 -0
- package/src/components/DataClubAIHubLogin/index.tsx +282 -0
- package/src/components/EffortControl/index.tsx +138 -0
- package/src/components/Layout/index.tsx +92 -0
- package/src/components/MainColumn/index.tsx +131 -0
- package/src/components/MarkdownRenderer/index.tsx +256 -0
- package/src/components/MessageInput/index.tsx +283 -0
- package/src/components/MessageList/index.tsx +753 -0
- package/src/components/ReasoningSelector/index.tsx +268 -0
- package/src/components/ReasoningView/index.tsx +183 -0
- package/src/components/ScrollToPresentButton/index.tsx +85 -0
- package/src/components/SessionsPanel/SessionTitleModal.tsx +256 -0
- package/src/components/SessionsPanel/index.tsx +406 -0
- package/src/components/SystemNotice/index.tsx +151 -0
- package/src/components/ThemeSwitcher/index.tsx +136 -0
- package/src/components/ToolCallView/formatContent.ts +50 -0
- package/src/components/ToolCallView/index.tsx +274 -0
- package/src/components/TpmBanner/index.tsx +172 -0
- package/src/components/TurnStatusIndicator/index.tsx +203 -0
- package/src/components/internal/PasswordInput.tsx +145 -0
- package/src/context/AIHubContext.ts +249 -0
- package/src/context/AIHubProvider.tsx +1084 -0
- package/src/context/index.ts +9 -0
- package/src/context/theme.ts +76 -0
- package/src/context/useAIHub.ts +151 -0
- package/src/context/useAIHubAuth.ts +65 -0
- package/src/index.ts +275 -0
- package/src/primitives/index.ts +101 -0
- package/src/state/affordances.ts +321 -0
- package/src/state/stateReducer.ts +131 -0
- package/src/stories/EffortControl.stories.tsx +63 -0
- package/src/stories/MarkdownRenderer.stories.tsx +201 -0
- package/src/stories/MessageBubble.stories.tsx +101 -0
- package/src/stories/ReasoningView.stories.tsx +81 -0
- package/src/stories/ScrollToPresentButton.stories.tsx +52 -0
- package/src/stories/SystemNotice.stories.tsx +59 -0
- package/src/stories/ThemeSwitcher.stories.tsx +55 -0
- package/src/stories/ToolCallView.stories.tsx +95 -0
- package/src/stories/TpmBanner.stories.tsx +93 -0
- package/src/stories/TurnStatusIndicator.stories.tsx +86 -0
- package/src/stories/_mockProvider.tsx +116 -0
- package/src/styles/CLASSES.md +356 -0
- package/src/styles/default.css +2937 -0
- package/src/types.ts +867 -0
- package/src/webcomponent/defineWebComponent.tsx +193 -0
- package/src/webcomponent/index.ts +11 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `<PasswordRevealModal />` โ one-time-display of a server-generated
|
|
3
|
+
* password. Reused for the create-user and reset-password flows on the
|
|
4
|
+
* Admin Users page ([05-admin-users.md]).
|
|
5
|
+
*
|
|
6
|
+
* Once dismissed, the password is gone โ there's no path back. The
|
|
7
|
+
* component never logs the value and never lifts it into any persistent
|
|
8
|
+
* store; it lives in the host component's local state until `onClose`.
|
|
9
|
+
*
|
|
10
|
+
* Behavior contracts:
|
|
11
|
+
*
|
|
12
|
+
* - Clicking the copy button writes the password to the clipboard and
|
|
13
|
+
* flashes the "Copied!" confirmation for ~2s. The flash uses a timer
|
|
14
|
+
* that the host doesn't need to manage.
|
|
15
|
+
* - There is no "click outside to dismiss" โ the modal must be explicitly
|
|
16
|
+
* closed via the Done button. This is deliberate ([05-admin-users.md]):
|
|
17
|
+
* the admin can't accidentally lose the password by misclicking.
|
|
18
|
+
* - The password field is a read-only `<input>` so a screen-reader user
|
|
19
|
+
* can read + select it like any other text field (rather than putting
|
|
20
|
+
* it inside a `<div>` and forcing the user to mouse-drag-select).
|
|
21
|
+
*
|
|
22
|
+
* @see SPECIFICATIONS.md ยง8.5 โ password reset semantics
|
|
23
|
+
* @see ui-sketches/05-admin-users.md โ password_reveal_modal
|
|
24
|
+
*/
|
|
25
|
+
import { useEffect, useRef, useState, type ReactNode } from "react";
|
|
26
|
+
|
|
27
|
+
import type { AIHubAdminTexts } from "../../auth/texts.js";
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Props for `<PasswordRevealModal />`.
|
|
31
|
+
*/
|
|
32
|
+
export interface PasswordRevealModalProps {
|
|
33
|
+
/** Modal-title variant โ drives which texts key is used. */
|
|
34
|
+
variant: "create" | "reset";
|
|
35
|
+
/** Username the password belongs to. */
|
|
36
|
+
username: string;
|
|
37
|
+
/** The 16-char alphanumeric plaintext. Never logged; never stored. */
|
|
38
|
+
password: string;
|
|
39
|
+
/** Resolved admin texts (admin namespace). */
|
|
40
|
+
texts: AIHubAdminTexts;
|
|
41
|
+
/** Fired when the admin clicks Done โ the password is unrecoverable after. */
|
|
42
|
+
onClose: () => void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Renders the reveal modal.
|
|
47
|
+
*
|
|
48
|
+
* @param props - see `PasswordRevealModalProps`.
|
|
49
|
+
* @returns the rendered modal.
|
|
50
|
+
*/
|
|
51
|
+
export function PasswordRevealModal(
|
|
52
|
+
props: PasswordRevealModalProps,
|
|
53
|
+
): ReactNode {
|
|
54
|
+
const [copied, setCopied] = useState(false);
|
|
55
|
+
// Stash the timeout id so unmount during the flash cleans up properly.
|
|
56
|
+
const flashTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
return () => {
|
|
60
|
+
if (flashTimer.current !== null) clearTimeout(flashTimer.current);
|
|
61
|
+
};
|
|
62
|
+
}, []);
|
|
63
|
+
|
|
64
|
+
async function handleCopy(): Promise<void> {
|
|
65
|
+
// Two clipboard backends to cover JSDOM tests AND old browsers without
|
|
66
|
+
// the async clipboard API: prefer the modern one, fall back to
|
|
67
|
+
// `document.execCommand` via a hidden textarea.
|
|
68
|
+
let ok = false;
|
|
69
|
+
try {
|
|
70
|
+
if (
|
|
71
|
+
typeof navigator !== "undefined" &&
|
|
72
|
+
navigator.clipboard?.writeText
|
|
73
|
+
) {
|
|
74
|
+
await navigator.clipboard.writeText(props.password);
|
|
75
|
+
ok = true;
|
|
76
|
+
}
|
|
77
|
+
} catch {
|
|
78
|
+
ok = false;
|
|
79
|
+
}
|
|
80
|
+
if (!ok && typeof document !== "undefined") {
|
|
81
|
+
try {
|
|
82
|
+
const ta = document.createElement("textarea");
|
|
83
|
+
ta.value = props.password;
|
|
84
|
+
ta.setAttribute("readonly", "");
|
|
85
|
+
ta.style.position = "absolute";
|
|
86
|
+
ta.style.left = "-9999px";
|
|
87
|
+
document.body.appendChild(ta);
|
|
88
|
+
ta.select();
|
|
89
|
+
try {
|
|
90
|
+
document.execCommand("copy");
|
|
91
|
+
ok = true;
|
|
92
|
+
} finally {
|
|
93
|
+
document.body.removeChild(ta);
|
|
94
|
+
}
|
|
95
|
+
} catch {
|
|
96
|
+
ok = false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// Even if both paths failed (unlikely outside test envs), surface the
|
|
100
|
+
// flash so the admin knows their click registered; the password is
|
|
101
|
+
// still visible on screen for manual transcription.
|
|
102
|
+
setCopied(true);
|
|
103
|
+
if (flashTimer.current !== null) clearTimeout(flashTimer.current);
|
|
104
|
+
flashTimer.current = setTimeout(() => setCopied(false), 2000);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const title =
|
|
108
|
+
props.variant === "create"
|
|
109
|
+
? props.texts.passwordRevealCreateTitle
|
|
110
|
+
: props.texts.passwordRevealResetTitle;
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<div
|
|
114
|
+
className="data-club-ai-hub-admin__modal-backdrop"
|
|
115
|
+
data-testid="password-reveal-modal-backdrop"
|
|
116
|
+
role="presentation"
|
|
117
|
+
>
|
|
118
|
+
<div
|
|
119
|
+
className="data-club-ai-hub-admin__modal data-club-ai-hub-admin__modal--password-reveal"
|
|
120
|
+
role="dialog"
|
|
121
|
+
aria-modal="true"
|
|
122
|
+
aria-labelledby="password-reveal-title"
|
|
123
|
+
data-testid="password-reveal-modal"
|
|
124
|
+
>
|
|
125
|
+
<h2
|
|
126
|
+
id="password-reveal-title"
|
|
127
|
+
className="data-club-ai-hub-admin__modal-title"
|
|
128
|
+
>
|
|
129
|
+
{title}
|
|
130
|
+
</h2>
|
|
131
|
+
<p
|
|
132
|
+
className="data-club-ai-hub-admin__modal-warning"
|
|
133
|
+
data-testid="password-reveal-warning"
|
|
134
|
+
>
|
|
135
|
+
โ {props.texts.passwordRevealWarning}
|
|
136
|
+
</p>
|
|
137
|
+
<label
|
|
138
|
+
className="data-club-ai-hub-admin__modal-field"
|
|
139
|
+
data-testid="password-reveal-username-row"
|
|
140
|
+
>
|
|
141
|
+
<span className="data-club-ai-hub-admin__modal-label">
|
|
142
|
+
{props.texts.passwordRevealUsernameLabel}
|
|
143
|
+
</span>
|
|
144
|
+
<input
|
|
145
|
+
type="text"
|
|
146
|
+
readOnly
|
|
147
|
+
value={props.username}
|
|
148
|
+
className="data-club-ai-hub-admin__modal-input"
|
|
149
|
+
data-testid="password-reveal-username"
|
|
150
|
+
/>
|
|
151
|
+
</label>
|
|
152
|
+
<label
|
|
153
|
+
className="data-club-ai-hub-admin__modal-field"
|
|
154
|
+
data-testid="password-reveal-password-row"
|
|
155
|
+
>
|
|
156
|
+
<span className="data-club-ai-hub-admin__modal-label">
|
|
157
|
+
{props.texts.passwordRevealPasswordLabel}
|
|
158
|
+
</span>
|
|
159
|
+
<div className="data-club-ai-hub-admin__password-reveal-row">
|
|
160
|
+
<input
|
|
161
|
+
type="text"
|
|
162
|
+
readOnly
|
|
163
|
+
value={props.password}
|
|
164
|
+
className="data-club-ai-hub-admin__modal-input data-club-ai-hub-admin__modal-input--password"
|
|
165
|
+
data-testid="password-reveal-password"
|
|
166
|
+
spellCheck={false}
|
|
167
|
+
/>
|
|
168
|
+
<button
|
|
169
|
+
type="button"
|
|
170
|
+
className="data-club-ai-hub-admin__copy-button"
|
|
171
|
+
data-testid="password-reveal-copy"
|
|
172
|
+
aria-label={props.texts.passwordRevealCopyAriaLabel}
|
|
173
|
+
onClick={() => {
|
|
174
|
+
void handleCopy();
|
|
175
|
+
}}
|
|
176
|
+
>
|
|
177
|
+
๐
|
|
178
|
+
</button>
|
|
179
|
+
{copied ? (
|
|
180
|
+
<span
|
|
181
|
+
className="data-club-ai-hub-admin__copy-flash"
|
|
182
|
+
data-testid="password-reveal-copied-flash"
|
|
183
|
+
role="status"
|
|
184
|
+
aria-live="polite"
|
|
185
|
+
>
|
|
186
|
+
{props.texts.passwordRevealCopiedFlash}
|
|
187
|
+
</span>
|
|
188
|
+
) : null}
|
|
189
|
+
</div>
|
|
190
|
+
</label>
|
|
191
|
+
<div className="data-club-ai-hub-admin__modal-actions">
|
|
192
|
+
<button
|
|
193
|
+
type="button"
|
|
194
|
+
className="data-club-ai-hub-admin__button data-club-ai-hub-admin__button--primary"
|
|
195
|
+
data-testid="password-reveal-done"
|
|
196
|
+
onClick={props.onClose}
|
|
197
|
+
>
|
|
198
|
+
{props.texts.passwordRevealDoneButton}
|
|
199
|
+
</button>
|
|
200
|
+
</div>
|
|
201
|
+
</div>
|
|
202
|
+
</div>
|
|
203
|
+
);
|
|
204
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `<ResetPasswordModal />` โ Phase-1 confirm dialog for the password-reset
|
|
3
|
+
* flow ([05-admin-users.md]).
|
|
4
|
+
*
|
|
5
|
+
* Phase 2 (revealing the new plaintext) reuses `<PasswordRevealModal />`
|
|
6
|
+
* exactly as the create-user flow does โ the parent (`<AdminUsersPage />`)
|
|
7
|
+
* owns the phase transition.
|
|
8
|
+
*
|
|
9
|
+
* @see SPECIFICATIONS.md ยง8.5 โ password reset semantics
|
|
10
|
+
* @see ui-sketches/05-admin-users.md โ reset_password_confirm_modal
|
|
11
|
+
*/
|
|
12
|
+
import { useState, type ReactNode } from "react";
|
|
13
|
+
|
|
14
|
+
import type { AIHubAdminTexts } from "../../auth/texts.js";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Props for `<ResetPasswordModal />`.
|
|
18
|
+
*/
|
|
19
|
+
export interface ResetPasswordModalProps {
|
|
20
|
+
/** Username of the target โ substituted into the modal title. */
|
|
21
|
+
username: string;
|
|
22
|
+
/** Resolved admin texts. */
|
|
23
|
+
texts: AIHubAdminTexts;
|
|
24
|
+
/**
|
|
25
|
+
* Confirms the reset. Resolves on success; throws on failure so the modal
|
|
26
|
+
* can surface the message inline.
|
|
27
|
+
*/
|
|
28
|
+
onConfirm: () => Promise<void>;
|
|
29
|
+
/** Fired when the admin cancels โ no server call. */
|
|
30
|
+
onCancel: () => void;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Renders the reset-password confirm modal.
|
|
35
|
+
*
|
|
36
|
+
* @param props - see `ResetPasswordModalProps`.
|
|
37
|
+
* @returns the rendered modal.
|
|
38
|
+
*/
|
|
39
|
+
export function ResetPasswordModal(
|
|
40
|
+
props: ResetPasswordModalProps,
|
|
41
|
+
): ReactNode {
|
|
42
|
+
const [submitting, setSubmitting] = useState(false);
|
|
43
|
+
const [errorText, setErrorText] = useState<string | null>(null);
|
|
44
|
+
|
|
45
|
+
async function handleConfirm(): Promise<void> {
|
|
46
|
+
setErrorText(null);
|
|
47
|
+
setSubmitting(true);
|
|
48
|
+
try {
|
|
49
|
+
await props.onConfirm();
|
|
50
|
+
} catch (err) {
|
|
51
|
+
const message =
|
|
52
|
+
err instanceof Error && err.message
|
|
53
|
+
? err.message
|
|
54
|
+
: props.texts.resetPasswordGenericError;
|
|
55
|
+
setErrorText(message);
|
|
56
|
+
setSubmitting(false);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const title = props.texts.resetPasswordModalTitle.replace(
|
|
61
|
+
"{username}",
|
|
62
|
+
props.username,
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<div
|
|
67
|
+
className="data-club-ai-hub-admin__modal-backdrop"
|
|
68
|
+
role="presentation"
|
|
69
|
+
>
|
|
70
|
+
<div
|
|
71
|
+
className="data-club-ai-hub-admin__modal"
|
|
72
|
+
role="dialog"
|
|
73
|
+
aria-modal="true"
|
|
74
|
+
aria-labelledby="reset-password-modal-title"
|
|
75
|
+
data-testid="reset-password-modal"
|
|
76
|
+
>
|
|
77
|
+
<h2
|
|
78
|
+
id="reset-password-modal-title"
|
|
79
|
+
className="data-club-ai-hub-admin__modal-title"
|
|
80
|
+
>
|
|
81
|
+
{title}
|
|
82
|
+
</h2>
|
|
83
|
+
{errorText !== null ? (
|
|
84
|
+
<div
|
|
85
|
+
className="data-club-ai-hub-admin__modal-error"
|
|
86
|
+
data-testid="reset-password-error"
|
|
87
|
+
role="alert"
|
|
88
|
+
>
|
|
89
|
+
{errorText}
|
|
90
|
+
</div>
|
|
91
|
+
) : null}
|
|
92
|
+
<p className="data-club-ai-hub-admin__modal-body">
|
|
93
|
+
{props.texts.resetPasswordModalBody}
|
|
94
|
+
</p>
|
|
95
|
+
<div className="data-club-ai-hub-admin__modal-actions">
|
|
96
|
+
<button
|
|
97
|
+
type="button"
|
|
98
|
+
className="data-club-ai-hub-admin__button"
|
|
99
|
+
data-testid="reset-password-cancel"
|
|
100
|
+
onClick={props.onCancel}
|
|
101
|
+
disabled={submitting}
|
|
102
|
+
>
|
|
103
|
+
{props.texts.resetPasswordCancelButton}
|
|
104
|
+
</button>
|
|
105
|
+
<button
|
|
106
|
+
type="button"
|
|
107
|
+
className="data-club-ai-hub-admin__button data-club-ai-hub-admin__button--primary"
|
|
108
|
+
data-testid="reset-password-confirm"
|
|
109
|
+
onClick={() => {
|
|
110
|
+
void handleConfirm();
|
|
111
|
+
}}
|
|
112
|
+
disabled={submitting}
|
|
113
|
+
>
|
|
114
|
+
{submitting
|
|
115
|
+
? props.texts.resetPasswordConfirmingButton
|
|
116
|
+
: props.texts.resetPasswordConfirmButton}
|
|
117
|
+
</button>
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
</div>
|
|
121
|
+
);
|
|
122
|
+
}
|