@h-ai/ui 0.1.0-alpha.72 → 0.1.0-alpha.74
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.en.md +43 -3
- package/README.ja.md +44 -4
- package/README.md +44 -4
- package/auto-import.d.ts +3 -0
- package/auto-import.js +3 -0
- package/dist/components/scenes/app/FeedbackDetail.svelte +11 -1
- package/dist/components/scenes/app/FeedbackDetail.svelte.d.ts +6 -0
- package/dist/components/scenes/app/FeedbackForm.svelte +1 -1
- package/dist/components/scenes/iam/AuthPanel.svelte +75 -11
- package/dist/components/scenes/iam/AuthShell.svelte +6 -1
- package/dist/components/scenes/iam/AuthShell.svelte.d.ts +2 -0
- package/dist/components/scenes/iam/ChangePasswordForm.svelte +1 -1
- package/dist/components/scenes/iam/ForgotPasswordForm.svelte +1 -1
- package/dist/components/scenes/iam/LoginForm.svelte +4 -2
- package/dist/components/scenes/iam/ReauthenticationDialog.svelte +68 -0
- package/dist/components/scenes/iam/ReauthenticationDialog.svelte.d.ts +17 -0
- package/dist/components/scenes/iam/RegisterForm.svelte +1 -1
- package/dist/components/scenes/iam/SensitiveOperationsForm.svelte +70 -0
- package/dist/components/scenes/iam/SensitiveOperationsForm.svelte.d.ts +21 -0
- package/dist/components/scenes/iam/SessionRecoveryDialog.svelte +64 -0
- package/dist/components/scenes/iam/SessionRecoveryDialog.svelte.d.ts +22 -0
- package/dist/components/scenes/iam/auth-captcha.d.ts +21 -0
- package/dist/components/scenes/iam/auth-captcha.js +23 -0
- package/dist/components/scenes/iam/auth-error-message.js +4 -0
- package/dist/components/scenes/iam/index.d.ts +7 -0
- package/dist/components/scenes/iam/index.js +5 -0
- package/dist/components/scenes/iam/password-utils.js +5 -0
- package/dist/components/scenes/iam/sensitive-actions.svelte.d.ts +68 -0
- package/dist/components/scenes/iam/sensitive-actions.svelte.js +100 -0
- package/dist/components/scenes/iam/session-recovery.svelte.d.ts +44 -0
- package/dist/components/scenes/iam/session-recovery.svelte.js +57 -0
- package/dist/components/scenes/types.d.ts +51 -3
- package/dist/messages/en-US.json +19 -1
- package/dist/messages/ja-JP.json +19 -1
- package/dist/messages/zh-CN.json +19 -1
- package/dist/types.d.ts +2 -2
- package/package.json +3 -2
package/README.en.md
CHANGED
|
@@ -293,7 +293,7 @@ Client validation appears on the first blur and updates as invalid input is corr
|
|
|
293
293
|
| ------------ | ----------- | ----------------------------------------------- |
|
|
294
294
|
| `PageHeader` | Page header | `title`, `description`; supports `actions` slot |
|
|
295
295
|
|
|
296
|
-
#### Scenes (
|
|
296
|
+
#### Scenes (43)
|
|
297
297
|
|
|
298
298
|
##### Guide (2)
|
|
299
299
|
|
|
@@ -309,7 +309,7 @@ Client validation appears on the first blur and updates as invalid input is corr
|
|
|
309
309
|
| `FeedbackModal` | Feedback modal | `open`, `onsubmit` |
|
|
310
310
|
| `FeedbackForm` | Standalone feedback form | `attachments`, `evidenceSummary`, `onsubmit`, `onfileschange` |
|
|
311
311
|
| `FeedbackList` | Server pagination, filters and processing actions | `data`, `query`, `permissions`, `onquerychange`, `onstatus` |
|
|
312
|
-
| `FeedbackDetail` | Diagnostic evidence, history and exports | `report`, `evidence`, `attachments`, `history`, `onexport` |
|
|
312
|
+
| `FeedbackDetail` | Diagnostic evidence, history and exports | `report`, `evidence`, `attachments`, `history`, `webhook`, `onretry`, `onexport` |
|
|
313
313
|
| `FeedbackScreenshot` | Image preview, highlighting and masking | `attachment`, `onannotate` |
|
|
314
314
|
| `SettingsModal` | Settings modal | `open`, `onclose` |
|
|
315
315
|
| `SettingsLayout` | Settings layout (section navigation + content) | `title`, `description`, `sections`, `active`, `onselect` |
|
|
@@ -318,9 +318,11 @@ Client validation appears on the first blur and updates as invalid input is corr
|
|
|
318
318
|
| `ThemeSelector` | Full theme selector | No props required |
|
|
319
319
|
| `ThemeToggle` | Light/dark toggle | No props required |
|
|
320
320
|
|
|
321
|
+
Pass the type: webhook task from report jobs into FeedbackDetail.webhook to show status, attempts and safe error codes; onretry calls the authenticated retry API. The Business evidence tab paginates kind: business, and archives download from the scene tab.
|
|
322
|
+
|
|
321
323
|
Descriptions are optional. Call `prepare()` from `@h-ai/feedback/client` before opening the modal. Connect `onfileschange` to attachment preparation and `onannotate` to image editing that burns annotations into the pixels. Failed submissions retain input and support local export. The list shows the description or server summary and requests pages through `onquerychange`; UI permissions do not replace server authorization. See the [feedback module](../feedback/README.en.md) for integration and offline tools.
|
|
322
324
|
|
|
323
|
-
##### IAM authentication (
|
|
325
|
+
##### IAM authentication (11)
|
|
324
326
|
|
|
325
327
|
| Component | Description | Key props |
|
|
326
328
|
| -------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------ |
|
|
@@ -332,8 +334,11 @@ Descriptions are optional. Call `prepare()` from `@h-ai/feedback/client` before
|
|
|
332
334
|
| `ResetPasswordForm` | Reset password | `loading`, `errors`, `showCode`, `onsubmit` |
|
|
333
335
|
| `ChangePasswordForm` | Change password | `loading`, `errors`, `requireOldPassword`, `onsubmit` |
|
|
334
336
|
| `PasswordInput` | Password input | `value`, `showToggle`, `showStrength`, `minLength` |
|
|
337
|
+
| `ReauthenticationDialog` | Sensitive action confirmation | `open`, `loading`, `error`, `onsubmit`, `onclose` |
|
|
335
338
|
| `PermGuard` | Permission guard | `permissions`, `mode`, `fallback` |
|
|
336
339
|
| `UserProfile` | User profile | `user`, `editable`, `fields`, `avatarAccept`, `avatarHint`, `onsubmit` |
|
|
340
|
+
| `SessionRecoveryDialog` | In-place session recovery | `recovery`, `actions` |
|
|
341
|
+
| `SensitiveOperationsForm` | Permission operation editor | `operations`, `onsubmit`, `ondone` |
|
|
337
342
|
|
|
338
343
|
##### Storage (4)
|
|
339
344
|
|
|
@@ -825,6 +830,35 @@ AuthPanel disables native form controls during SSR and enables input after clien
|
|
|
825
830
|
|
|
826
831
|
When an authentication link points to the current complete URL, AuthPanel switches scenes without navigating again, so input entered after returning to login is preserved. Links with a different path, query, or hash use application routing. Modified clicks such as Ctrl/Cmd retain browser behavior.
|
|
827
832
|
|
|
833
|
+
`createSensitiveActions` can refresh database rules before an action through standard `actions.publicConfig()`. `SensitiveOperationsForm` shares line-based input, deduplication, validation and errors. Pass `operations`, async `onsubmit(operations)` returning HaiResult, and optional `ondone` for successful saves. Clearing database additions does not remove file rules.
|
|
834
|
+
|
|
835
|
+
Use `createSessionRecovery()` with `SessionRecoveryDialog` for expired sessions. Configure it with the public config and original `{ id, username }`, pass `recovery.recover` as Kit/API client's `recoverSession`, and give the dialog the same controller and standard actions. Call `cancel()` on teardown. The UI stores no passwords or business requests. `expectedUserId` restricts server session issuance to the original principal; captcha, lockout, access and password-renewal policies remain active. Cancellation preserves input and stops continuation; ambiguous network writes are never replayed. Reloaded/closed documents cannot recover lost in-memory drafts.
|
|
836
|
+
|
|
837
|
+
`createSensitiveActions(actions)` accepts Kit/API client authentication actions and shares confirmation, cancellation, retry, duplicate-submit and late-response handling. Create one per application root layout, update it with `configure(publicPolicy)`, and call `cancel()` on teardown. `authorize(operation)` returns undefined when confirmation is unnecessary, null when cancelled/busy, or the proof for that action. Do not send the business request on cancellation; pass a proof only to its intended request, never to global headers or persistent storage. Bind `ReauthenticationDialog` to the controller’s `open/loading/error/submit/cancel`; confirmation grants no permissions. `Input` supports `datetime-local`: convert its browser-local value to an explicit timestamp in the service layer.
|
|
838
|
+
|
|
839
|
+
```svelte
|
|
840
|
+
<!-- actions comes from Kit/API client; policy is the public IAM reauthentication policy. -->
|
|
841
|
+
<script lang='ts'>
|
|
842
|
+
import type { SensitiveActionsOptions } from '@h-ai/ui'
|
|
843
|
+
import { createSensitiveActions, ReauthenticationDialog } from '@h-ai/ui'
|
|
844
|
+
|
|
845
|
+
const { actions, policy }: { actions: SensitiveActionsOptions, policy: { enabled: boolean, operations: string[] } } = $props()
|
|
846
|
+
const confirmation = createSensitiveActions(actions)
|
|
847
|
+
$effect(() => {
|
|
848
|
+
confirmation.configure(policy)
|
|
849
|
+
return () => confirmation.cancel()
|
|
850
|
+
})
|
|
851
|
+
// Await confirmation.authorize(operation) in the business action; stop on null.
|
|
852
|
+
</script>
|
|
853
|
+
<ReauthenticationDialog
|
|
854
|
+
open={confirmation.open}
|
|
855
|
+
loading={confirmation.loading}
|
|
856
|
+
error={confirmation.error}
|
|
857
|
+
onsubmit={password => confirmation.submit(password)}
|
|
858
|
+
onclose={() => confirmation.cancel()}
|
|
859
|
+
/>
|
|
860
|
+
```
|
|
861
|
+
|
|
828
862
|
[完整 IAM 配置 / IAM configuration](../iam/README.en.md)
|
|
829
863
|
|
|
830
864
|
### Onboarding and help center
|
|
@@ -935,6 +969,12 @@ HTTP errors expose localized safe messages followed by `(traceId: …)`, with th
|
|
|
935
969
|
|
|
936
970
|
Use `core.error.toPublic(error, traceId?)` at HTTP/UI boundaries and `core.error.formatMessage(error)` after translating messages; formatting is idempotent. Pass complete Error objects to logs instead of discarding their context. Database failures log driver codes, sanitized messages/stacks and table/column context; SQL text, bound values and connection credentials are excluded.
|
|
937
971
|
|
|
972
|
+
## Optional interactive challenges
|
|
973
|
+
|
|
974
|
+
AuthPanel uses actions.createCaptcha to automatically create and asynchronously solve self-hosted ALTCHA when config.captcha.enabled, submitting one-use proofs for login/register/sendOtp/passwordReset/renewPassword. The solver is not loaded when disabled. createAuthActions supplies the action; custom actions must preserve captcha and missing actions fail closed. Proofs stay in request memory and are always verified/consumed on the server.
|
|
975
|
+
|
|
976
|
+
See policy, defaults and recovery boundaries in [IAM](../iam/README.en.md).
|
|
977
|
+
|
|
938
978
|
## Development and testing
|
|
939
979
|
|
|
940
980
|
```sh
|
package/README.ja.md
CHANGED
|
@@ -293,7 +293,7 @@ components/
|
|
|
293
293
|
| -------------- | -------------- | ---------------------------------------------- |
|
|
294
294
|
| `PageHeader` | ページヘッダー | `title`, `description`、`actions` スロット対応 |
|
|
295
295
|
|
|
296
|
-
#### Scenes:用途別コンポーネント(
|
|
296
|
+
#### Scenes:用途別コンポーネント(41)
|
|
297
297
|
|
|
298
298
|
##### Guide:案内・ヘルプ(2)
|
|
299
299
|
|
|
@@ -302,14 +302,14 @@ components/
|
|
|
302
302
|
| `GuideHost` | 初回案内・ガイド・ヘルプダイアログ | `guide`, `locale`, `scope`, `autoStart` |
|
|
303
303
|
| `HelpCenter` | 独立して使える検索付きヘルプ | `articles`, `tours`, `locale`, `selectedId`, `onstart` |
|
|
304
304
|
|
|
305
|
-
##### App:アプリ全体(
|
|
305
|
+
##### App:アプリ全体(13)
|
|
306
306
|
|
|
307
307
|
| コンポーネント | 説明 | 主なプロパティ |
|
|
308
308
|
| ------------------ | ------------------------------------------- | -------------------------------------------------------- |
|
|
309
309
|
| `FeedbackModal` | フィードバックモーダル | `open`, `onsubmit` |
|
|
310
310
|
| `FeedbackForm` | 独立したフィードバックフォーム | `attachments`, `evidenceSummary`, `onsubmit`, `onfileschange` |
|
|
311
311
|
| `FeedbackList` | サーバー側ページング・絞り込み・処理操作 | `data`, `query`, `permissions`, `onquerychange`, `onstatus` |
|
|
312
|
-
| `FeedbackDetail` | 診断情報・処理履歴・エクスポート | `report`, `evidence`, `attachments`, `history`, `onexport` |
|
|
312
|
+
| `FeedbackDetail` | 診断情報・処理履歴・エクスポート | `report`, `evidence`, `attachments`, `history`, `webhook`, `onretry`, `onexport` |
|
|
313
313
|
| `FeedbackScreenshot` | 画像のプレビュー・強調・マスキング | `attachment`, `onannotate` |
|
|
314
314
|
| `SettingsModal` | 設定モーダル | `open`, `onclose` |
|
|
315
315
|
| `SettingsLayout` | 設定レイアウト(区分ナビゲーション + 本文) | `title`, `description`, `sections`, `active`, `onselect` |
|
|
@@ -318,9 +318,11 @@ components/
|
|
|
318
318
|
| `ThemeSelector` | テーマ選択パネル | プロパティ不要 |
|
|
319
319
|
| `ThemeToggle` | ライト・ダーク切り替え | プロパティ不要 |
|
|
320
320
|
|
|
321
|
+
詳細 jobs の type: webhook を FeedbackDetail.webhook に渡すと状態・試行回数・安全なエラーコードを表示し、onretry から認可付き retry API を呼びます。「業務情報」タブは kind: business をページ取得し、圧縮添付は操作現場からダウンロードします。
|
|
322
|
+
|
|
321
323
|
説明は任意です。モーダルを開く前に `@h-ai/feedback/client` の `prepare()` で現場を固定します。`onfileschange` で添付を準備し、`onannotate` で注釈を画像のピクセルに反映します。送信失敗時は入力を保持し、ローカルに出力できます。一覧は説明またはサーバーの要約を表示し、`onquerychange` でページを取得します。UI の権限表示とは別にサーバーの認可が必要です。接続方法とオフラインツールは [feedback モジュール](../feedback/README.ja.md) を参照してください。
|
|
322
324
|
|
|
323
|
-
##### IAM:認証(
|
|
325
|
+
##### IAM:認証(13)
|
|
324
326
|
|
|
325
327
|
| コンポーネント | 説明 | 主なプロパティ |
|
|
326
328
|
| -------------------- | --------------------------------------- | ------------------------------------------------------------------------------------------------------ |
|
|
@@ -332,8 +334,11 @@ components/
|
|
|
332
334
|
| `ResetPasswordForm` | パスワードリセット | `loading`, `errors`, `showCode`, `onsubmit` |
|
|
333
335
|
| `ChangePasswordForm` | パスワード変更 | `loading`, `errors`, `requireOldPassword`, `onsubmit` |
|
|
334
336
|
| `PasswordInput` | パスワード入力 | `value`, `showToggle`, `showStrength`, `minLength` |
|
|
337
|
+
| `ReauthenticationDialog` | 機密操作の確認 | `open`, `loading`, `error`, `onsubmit`, `onclose` |
|
|
335
338
|
| `PermGuard` | 権限ガード | `permissions`, `mode`, `fallback` |
|
|
336
339
|
| `UserProfile` | ユーザープロフィール | `user`, `editable`, `fields`, `avatarAccept`, `avatarHint`, `onsubmit` |
|
|
340
|
+
| `SessionRecoveryDialog` | 画面内のセッション復帰 | `recovery`, `actions` |
|
|
341
|
+
| `SensitiveOperationsForm` | 権限の重要操作編集 | `operations`, `onsubmit`, `ondone` |
|
|
337
342
|
|
|
338
343
|
##### Storage:ストレージ(4)
|
|
339
344
|
|
|
@@ -825,6 +830,35 @@ AuthPanel は SSR 中のフォーム操作を無効にし、クライアント
|
|
|
825
830
|
|
|
826
831
|
認証リンクが現在の完全な URL を指す場合、AuthPanel は再ナビゲーションせずに画面だけを切り替え、ログインに戻った直後の入力を保持します。パス、クエリー、hash が異なる場合はアプリのルーターに任せます。Ctrl/Cmd などの修飾キーを使ったクリックはブラウザーの動作を維持します。
|
|
827
832
|
|
|
833
|
+
`createSensitiveActions` は標準 actions の `publicConfig()` で操作前に DB 規則を更新できます。`SensitiveOperationsForm` は行入力・重複除去・検証・エラー表示を共通化します。`operations` と HaiResult を返す非同期 `onsubmit(operations)` を渡し、成功時のみ `ondone` を呼びます。DB の追加を空にしてもファイルの規則は解除しません。
|
|
834
|
+
|
|
835
|
+
期限切れの画面内復帰は `createSessionRecovery()` と `SessionRecoveryDialog` を使います。公開設定と元の `{ id, username }` を configure し、`recovery.recover` を Kit/API client の `recoverSession` に渡します。ダイアログに同じ controller と標準 actions を渡し、破棄時に `cancel()` します。UI にパスワードや業務要求を保存しません。`expectedUserId` は発行前に元の本人を検証し、通常の CAPTCHA・ロック・アクセス・改密方針を適用します。取消は入力を保持し、結果不明の通信障害では書込を再送しません。再読込や終了で失われたメモリの入力は復元できません。
|
|
836
|
+
|
|
837
|
+
`createSensitiveActions(actions)` はKit/API clientの認証アクションを受け取り、ログイン済み利用者の確認・取消・再試行・重複送信・遅延応答を共通処理します。アプリのルートレイアウトごとに生成し、`configure(公開設定)` で更新、破棄時は `cancel()` を呼びます。`authorize(operation)` は確認不要ならundefined、取消/処理中ならnull、成功なら当該操作の証明を返します。取消時は業務リクエストを送らず、証明は対象リクエストにのみ渡します。共有ヘッダーや永続ストレージには保存しません。`ReauthenticationDialog` に `open/loading/error/submit/cancel` を接続します。確認は権限を増やしません。`Input` の `datetime-local` はブラウザーのローカル時刻のため、サービスで明確なタイムスタンプへ変換して送信します。
|
|
838
|
+
|
|
839
|
+
```svelte
|
|
840
|
+
<!-- actionsはKit/API clientの認証アクション、policyはIAMの公開再認証設定です。 -->
|
|
841
|
+
<script lang='ts'>
|
|
842
|
+
import type { SensitiveActionsOptions } from '@h-ai/ui'
|
|
843
|
+
import { createSensitiveActions, ReauthenticationDialog } from '@h-ai/ui'
|
|
844
|
+
|
|
845
|
+
const { actions, policy }: { actions: SensitiveActionsOptions, policy: { enabled: boolean, operations: string[] } } = $props()
|
|
846
|
+
const confirmation = createSensitiveActions(actions)
|
|
847
|
+
$effect(() => {
|
|
848
|
+
confirmation.configure(policy)
|
|
849
|
+
return () => confirmation.cancel()
|
|
850
|
+
})
|
|
851
|
+
// 業務操作でconfirmation.authorize(operation)を待ち、nullなら中止します。
|
|
852
|
+
</script>
|
|
853
|
+
<ReauthenticationDialog
|
|
854
|
+
open={confirmation.open}
|
|
855
|
+
loading={confirmation.loading}
|
|
856
|
+
error={confirmation.error}
|
|
857
|
+
onsubmit={password => confirmation.submit(password)}
|
|
858
|
+
onclose={() => confirmation.cancel()}
|
|
859
|
+
/>
|
|
860
|
+
```
|
|
861
|
+
|
|
828
862
|
[完整 IAM 配置 / IAM configuration](../iam/README.ja.md)
|
|
829
863
|
|
|
830
864
|
### 初回ガイドとヘルプセンター
|
|
@@ -935,6 +969,12 @@ HTTP エラーはローカライズ済みの安全な表示に `(traceId: …)`
|
|
|
935
969
|
|
|
936
970
|
HTTP/UI 境界には core.error.toPublic(error, traceId?)、再翻訳後の表示には core.error.formatMessage(error) を使い、ID を重複追加しません。ログには完全な Error を渡してください。DB ログにはドライバーコード、脱機密化したメッセージ・スタック、表・列を残し、SQL 本文、バインド値と接続認証情報を記録しません。
|
|
937
971
|
|
|
972
|
+
## 任意の対話チャレンジ
|
|
973
|
+
|
|
974
|
+
AuthPanel は config.captcha.enabled の場合 actions.createCaptcha で自己ホスト ALTCHA を自動生成・非同期求解し、login/register/sendOtp/passwordReset/renewPassword 用の単用証明を送信します。無効時は求解器を読み込みません。createAuthActions は対応済みで、独自動作は captcha を保持し、不足時は通過しません。証明は現在のメモリ内だけに保持し、サーバーで必ず検証・消費します。
|
|
975
|
+
|
|
976
|
+
方針・既定値・復旧範囲は次を参照: [IAM](../iam/README.ja.md)。
|
|
977
|
+
|
|
938
978
|
## 開発とテスト
|
|
939
979
|
|
|
940
980
|
```sh
|
package/README.md
CHANGED
|
@@ -293,7 +293,7 @@ components/
|
|
|
293
293
|
| ------------ | -------- | ------------------------------------------- |
|
|
294
294
|
| `PageHeader` | 页面头部 | `title`, `description`,支持 `actions` 插槽 |
|
|
295
295
|
|
|
296
|
-
#### 场景组件 Scenes(
|
|
296
|
+
#### 场景组件 Scenes(43 个)
|
|
297
297
|
|
|
298
298
|
##### Guide 引导与帮助(2 个)
|
|
299
299
|
|
|
@@ -302,14 +302,14 @@ components/
|
|
|
302
302
|
| `GuideHost` | 首次邀请、页面导览与帮助弹窗宿主 | `guide`, `locale`, `scope`, `autoStart` |
|
|
303
303
|
| `HelpCenter` | 可独立使用的帮助中心 | `articles`, `tours`, `locale`, `selectedId`, `onstart` |
|
|
304
304
|
|
|
305
|
-
##### App 应用级(
|
|
305
|
+
##### App 应用级(13 个)
|
|
306
306
|
|
|
307
307
|
| 组件 | 描述 | 主要属性 |
|
|
308
308
|
| ---------------- | ---------------- | ------------------ |
|
|
309
309
|
| `FeedbackModal` | 反馈模态框 | `open`, `onsubmit` |
|
|
310
310
|
| `FeedbackForm` | 独立反馈表单 | `attachments`, `evidenceSummary`, `onsubmit`, `onfileschange` |
|
|
311
311
|
| `FeedbackList` | 服务端分页、筛选与处理操作 | `data`, `query`, `permissions`, `onquerychange`, `onstatus` |
|
|
312
|
-
| `FeedbackDetail` | 诊断材料、处理历史与导出 | `report`, `evidence`, `attachments`, `history`, `onexport` |
|
|
312
|
+
| `FeedbackDetail` | 诊断材料、处理历史与导出 | `report`, `evidence`, `attachments`, `history`, `webhook`, `onretry`, `onexport` |
|
|
313
313
|
| `FeedbackScreenshot` | 图片预览、圈选与遮挡 | `attachment`, `onannotate` |
|
|
314
314
|
| `SettingsModal` | 设置模态框 | `open`, `onclose` |
|
|
315
315
|
| `SettingsLayout` | 设置页布局(分区导航 + 内容区) | `title`, `description`, `sections`, `active`, `onselect` |
|
|
@@ -318,9 +318,11 @@ components/
|
|
|
318
318
|
| `ThemeSelector` | 完整主题选择面板 | 无需 Props |
|
|
319
319
|
| `ThemeToggle` | 明/暗主题切换 | 无需 Props |
|
|
320
320
|
|
|
321
|
+
将详情 jobs 中 type: webhook 的任务传给 FeedbackDetail.webhook,显示状态、尝试次数及安全错误码;onretry 负责调用受权 retry API。业务异步证据在“业务信息”页签分页查询 kind: business,压缩附件在“操作现场”下载。
|
|
322
|
+
|
|
321
323
|
反馈说明可为空;宿主先用 `@h-ai/feedback/client` 的 `prepare()` 固定现场,再打开弹窗。表单通过 `onfileschange` 准备主动附件、通过 `onannotate` 将标注烧录到图片;受理失败保留输入并可本地导出。列表展示说明或服务端事实摘要,以 `onquerychange` 取得分页数据;界面权限不代替服务端授权。完整接入与离线工具见 [feedback 模块](../feedback/README.md)。
|
|
322
324
|
|
|
323
|
-
##### IAM 身份认证(
|
|
325
|
+
##### IAM 身份认证(13 个)
|
|
324
326
|
|
|
325
327
|
| 组件 | 描述 | 主要属性 |
|
|
326
328
|
| -------------------- | ---------- | ----------------------------------------------------- |
|
|
@@ -332,8 +334,11 @@ components/
|
|
|
332
334
|
| `ResetPasswordForm` | 重置密码 | `loading`, `errors`, `showCode`, `onsubmit` |
|
|
333
335
|
| `ChangePasswordForm` | 修改密码 | `loading`, `errors`, `requireOldPassword`, `onsubmit` |
|
|
334
336
|
| `PasswordInput` | 密码输入框 | `value`, `showToggle`, `showStrength`, `minLength` |
|
|
337
|
+
| `ReauthenticationDialog` | 敏感操作再认证 | `open`, `loading`, `error`, `onsubmit`, `onclose` |
|
|
335
338
|
| `PermGuard` | 权限守卫 | `permissions`, `mode`, `fallback` |
|
|
336
339
|
| `UserProfile` | 用户资料 | `user`, `editable`, `fields`, `avatarAccept`, `avatarHint`, `onsubmit` |
|
|
340
|
+
| `SessionRecoveryDialog` | 原地会话恢复 | `recovery`, `actions` |
|
|
341
|
+
| `SensitiveOperationsForm` | 权限敏感操作编辑 | `operations`, `onsubmit`, `ondone` |
|
|
337
342
|
|
|
338
343
|
##### Storage 存储(4 个)
|
|
339
344
|
|
|
@@ -841,6 +846,35 @@ AuthPanel 在 SSR 阶段禁用原生表单控件,客户端挂载并绑定事
|
|
|
841
846
|
|
|
842
847
|
认证链接指向当前完整 URL 时,AuthPanel 只切换场景并阻止重复导航,返回登录后可立即输入。路径、查询串或 hash 不同时交给应用路由处理;Ctrl/Cmd 等修改键点击保留浏览器行为。
|
|
843
848
|
|
|
849
|
+
`createSensitiveActions` 可利用标准 actions 的 `publicConfig()` 在操作前更新数据库规则。`SensitiveOperationsForm` 复用逐行输入、去重、校验与错误状态;传入 `operations`、异步 `onsubmit(operations)`(返回 HaiResult),`ondone` 只在保存成功后调用。数据库规则与文件规则取并集,表单清空不能取消文件规则。
|
|
850
|
+
|
|
851
|
+
会话过期后的重新登录使用 `createSessionRecovery()` + `SessionRecoveryDialog`。根布局通过 `configure(publicConfig, { id, username })` 绑定原用户,把 `recovery.recover` 传给 Kit/API client 的 `recoverSession`;弹窗传入同一份 controller 和标准 actions,布局卸载时 `cancel()`。UI 不保存密码或业务请求,不切换页面。登录携带 `expectedUserId`,服务端在发会话前限制原主体;验证码、锁定、登录限制和改密流程仍按正常登录执行。取消保留当前输入并结束本次续接;真实网络失败不重放写入。整页刷新/关闭后的内存输入无法恢复。
|
|
852
|
+
|
|
853
|
+
`createSensitiveActions(actions)` 复用 Kit/API client 的认证动作,统一管理已登录用户的二次确认、取消、错误重试、重复提交与迟到响应。每个应用根布局创建一份,用 `configure(公开策略)` 更新清单;布局卸载时 `cancel()`。`authorize(operation)` 返回 undefined 表示不需确认、null 表示取消/忙、字符串为本次操作凭据;取消时不要发业务请求。有凭据时只传给本次请求,不放全局 header 或持久存储。`ReauthenticationDialog` 绑定控制器的 `open/loading/error/submit/cancel`,不会增加权限。`Input` 支持 `datetime-local`,其值为浏览器本地时间,服务层转换为明确时间戳后提交。
|
|
854
|
+
|
|
855
|
+
```svelte
|
|
856
|
+
<!-- actions 为 Kit/API client 的标准认证动作;policy 为 IAM 公开再认证策略。 -->
|
|
857
|
+
<script lang='ts'>
|
|
858
|
+
import type { SensitiveActionsOptions } from '@h-ai/ui'
|
|
859
|
+
import { createSensitiveActions, ReauthenticationDialog } from '@h-ai/ui'
|
|
860
|
+
|
|
861
|
+
const { actions, policy }: { actions: SensitiveActionsOptions, policy: { enabled: boolean, operations: string[] } } = $props()
|
|
862
|
+
const confirmation = createSensitiveActions(actions)
|
|
863
|
+
$effect(() => {
|
|
864
|
+
confirmation.configure(policy)
|
|
865
|
+
return () => confirmation.cancel()
|
|
866
|
+
})
|
|
867
|
+
// 业务动作 await confirmation.authorize(operation);null 时中止该动作。
|
|
868
|
+
</script>
|
|
869
|
+
<ReauthenticationDialog
|
|
870
|
+
open={confirmation.open}
|
|
871
|
+
loading={confirmation.loading}
|
|
872
|
+
error={confirmation.error}
|
|
873
|
+
onsubmit={password => confirmation.submit(password)}
|
|
874
|
+
onclose={() => confirmation.cancel()}
|
|
875
|
+
/>
|
|
876
|
+
```
|
|
877
|
+
|
|
844
878
|
[完整 IAM 配置 / IAM configuration](../iam/README.md)
|
|
845
879
|
|
|
846
880
|
### 新手引导与帮助中心
|
|
@@ -938,6 +972,12 @@ HTTP 错误只向用户返回本地化的安全提示,末尾显示 `(traceId:
|
|
|
938
972
|
|
|
939
973
|
`core.error.toPublic(error, traceId?)` 用于接口/UI 边界;`core.error.formatMessage(error)` 用于重新翻译后的提示,重复调用不会重复追加标识。日志传入完整 Error 对象,不能只记录通用标题或提前 String(error) 丢失上下文。数据库失败记录驱动错误码、消息、堆栈及表/列;SQL 原文、绑定值和连接凭据不进入日志。
|
|
940
974
|
|
|
975
|
+
## 可选交互挑战
|
|
976
|
+
|
|
977
|
+
AuthPanel 在 config.captcha.enabled 时通过 actions.createCaptcha 自动生成并异步求解自托管 ALTCHA,按 login/register/sendOtp/passwordReset/renewPassword 用途提交单用证明;关闭时不加载求解器。createAuthActions 已提供动作,自定义动作须保留 captcha,缺少动作时不放行。证明仅存在当前请求内存,服务端始终校验与消费。
|
|
978
|
+
|
|
979
|
+
策略、默认值和恢复边界见 [IAM](../iam/README.md)。
|
|
980
|
+
|
|
941
981
|
## 开发测试
|
|
942
982
|
|
|
943
983
|
```sh
|
package/auto-import.d.ts
CHANGED
|
@@ -101,8 +101,11 @@ declare global {
|
|
|
101
101
|
const LoginForm: typeof import('@h-ai/ui')['LoginForm']
|
|
102
102
|
const PasswordInput: typeof import('@h-ai/ui')['PasswordInput']
|
|
103
103
|
const PermGuard: typeof import('@h-ai/ui')['PermGuard']
|
|
104
|
+
const ReauthenticationDialog: typeof import('@h-ai/ui')['ReauthenticationDialog']
|
|
104
105
|
const RegisterForm: typeof import('@h-ai/ui')['RegisterForm']
|
|
105
106
|
const ResetPasswordForm: typeof import('@h-ai/ui')['ResetPasswordForm']
|
|
107
|
+
const SensitiveOperationsForm: typeof import('@h-ai/ui')['SensitiveOperationsForm']
|
|
108
|
+
const SessionRecoveryDialog: typeof import('@h-ai/ui')['SessionRecoveryDialog']
|
|
106
109
|
const UserProfile: typeof import('@h-ai/ui')['UserProfile']
|
|
107
110
|
|
|
108
111
|
// scenes - storage
|
package/auto-import.js
CHANGED
|
@@ -92,8 +92,11 @@ const UI_COMPONENTS = new Set([
|
|
|
92
92
|
'LoginForm',
|
|
93
93
|
'PasswordInput',
|
|
94
94
|
'PermGuard',
|
|
95
|
+
'ReauthenticationDialog',
|
|
95
96
|
'RegisterForm',
|
|
96
97
|
'ResetPasswordForm',
|
|
98
|
+
'SensitiveOperationsForm',
|
|
99
|
+
'SessionRecoveryDialog',
|
|
97
100
|
'UserProfile',
|
|
98
101
|
// scenes - storage
|
|
99
102
|
'AvatarUpload',
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
evidence = { items: [], total: 0, page: 1, pageSize: 20 },
|
|
31
31
|
attachments = [],
|
|
32
32
|
history = [],
|
|
33
|
+
webhook,
|
|
33
34
|
permissions = {},
|
|
34
35
|
loading = false,
|
|
35
36
|
error = '',
|
|
@@ -48,6 +49,8 @@
|
|
|
48
49
|
evidence?: FeedbackPage<FeedbackEvidenceView>
|
|
49
50
|
attachments?: FeedbackAttachmentView[]
|
|
50
51
|
history?: FeedbackHistoryView[]
|
|
52
|
+
/** 持久 Webhook 任务的公开状态,由反馈详情 jobs 中的 webhook 项提供。 */
|
|
53
|
+
webhook?: { status: 'pending' | 'running' | 'succeeded' | 'failed', attempts: number, lastError?: string }
|
|
51
54
|
permissions?: FeedbackPermissions
|
|
52
55
|
loading?: boolean
|
|
53
56
|
error?: string
|
|
@@ -79,6 +82,7 @@
|
|
|
79
82
|
{ key: 'scene', label: uiM('feedback_scene') },
|
|
80
83
|
{ key: 'replay', label: uiM('feedback_replay') },
|
|
81
84
|
{ key: 'logs', label: uiM('feedback_logs') },
|
|
85
|
+
{ key: 'business', label: uiM('feedback_business') },
|
|
82
86
|
{ key: 'environment', label: uiM('feedback_environment') },
|
|
83
87
|
{ key: 'history', label: uiM('feedback_history') },
|
|
84
88
|
])
|
|
@@ -122,6 +126,8 @@
|
|
|
122
126
|
void query({ page: 1, kind: 'interaction' })
|
|
123
127
|
else if (tab === 'logs')
|
|
124
128
|
void query({ page: 1, kind: undefined })
|
|
129
|
+
else if (tab === 'business')
|
|
130
|
+
void query({ page: 1, kind: 'business', requestId: undefined, errorId: undefined })
|
|
125
131
|
}
|
|
126
132
|
</script>
|
|
127
133
|
|
|
@@ -147,17 +153,21 @@
|
|
|
147
153
|
<dl class='grid grid-cols-1 gap-3 text-sm sm:grid-cols-2 xl:grid-cols-3'>
|
|
148
154
|
<div><dt class='text-base-content/55'>{uiM('feedback_collection')}</dt><dd>{collectionLabel(report.collectionStatus)}</dd></div>
|
|
149
155
|
<div><dt class='text-base-content/55'>{uiM('feedback_notification')}</dt><dd>{notificationLabel(report.notificationStatus)}</dd></div>
|
|
156
|
+
{#if webhook}
|
|
157
|
+
<div><dt class='text-base-content/55'>{uiM('feedback_webhook')}</dt><dd>{notificationLabel(webhook.status === 'succeeded' ? 'sent' : webhook.status === 'running' ? 'sending' : webhook.status)} · {uiM('feedback_attempts')}: {webhook.attempts}</dd>{#if webhook.lastError}<dd class='break-all text-error'>{webhook.lastError}</dd>{/if}</div>
|
|
158
|
+
{/if}
|
|
150
159
|
<div><dt class='text-base-content/55'>{uiM('feedback_submitter')}</dt><dd class='break-all'>{report.userId || '—'}</dd></div>
|
|
151
160
|
<div><dt class='text-base-content/55'>{uiM('feedback_revision')}</dt><dd>{report.evidenceRevision}</dd></div>
|
|
152
161
|
{#if report.buildId}<div><dt class='text-base-content/55'>{uiM('feedback_build_id')}</dt><dd class='break-all'>{report.buildId}</dd></div>{/if}
|
|
153
162
|
{#if report.commit}<div><dt class='text-base-content/55'>{uiM('feedback_commit')}</dt><dd class='break-all'>{report.commit}</dd></div>{/if}
|
|
154
163
|
</dl>
|
|
164
|
+
{#if webhook?.status === 'failed' && permissions.retry && onretry}<Button size='sm' disabled={busy} onclick={() => run(() => onretry(report!))}>{uiM('feedback_retry')}</Button>{/if}
|
|
155
165
|
</div>
|
|
156
166
|
{:else if tab === 'replay'}
|
|
157
167
|
<div class='py-4'>
|
|
158
168
|
{#if onreplay}<FeedbackReplay load={onreplay} />{:else}<p class='text-sm'>{uiM('feedback_replay_empty')}</p>{/if}
|
|
159
169
|
</div>
|
|
160
|
-
{:else if tab === 'scene' || tab === 'logs' || tab === 'environment'}
|
|
170
|
+
{:else if tab === 'scene' || tab === 'logs' || tab === 'environment' || tab === 'business'}
|
|
161
171
|
<div class='space-y-4 py-4'>
|
|
162
172
|
{#if tab === 'scene'}
|
|
163
173
|
<div class='grid grid-cols-1 gap-3 xl:grid-cols-2'>
|
|
@@ -5,6 +5,12 @@ type $$ComponentProps = {
|
|
|
5
5
|
evidence?: FeedbackPage<FeedbackEvidenceView>;
|
|
6
6
|
attachments?: FeedbackAttachmentView[];
|
|
7
7
|
history?: FeedbackHistoryView[];
|
|
8
|
+
/** 持久 Webhook 任务的公开状态,由反馈详情 jobs 中的 webhook 项提供。 */
|
|
9
|
+
webhook?: {
|
|
10
|
+
status: 'pending' | 'running' | 'succeeded' | 'failed';
|
|
11
|
+
attempts: number;
|
|
12
|
+
lastError?: string;
|
|
13
|
+
};
|
|
8
14
|
permissions?: FeedbackPermissions;
|
|
9
15
|
loading?: boolean;
|
|
10
16
|
error?: string;
|
|
@@ -268,7 +268,7 @@
|
|
|
268
268
|
{#if oncapture}<Button size='sm' variant='outline' disabled={loading || annotating || staging || exporting} onclick={() => oncapture()}>{uiM('feedback_capture_add')}</Button>{/if}
|
|
269
269
|
<label class='btn btn-sm btn-ghost focus-within:outline focus-within:outline-primary'>
|
|
270
270
|
{uiM('feedback_add_files')}
|
|
271
|
-
<BareInput id={`${instanceId}-files`} type='file' aria-label={uiM('feedback_add_files')} accept='.png,.jpg,.jpeg,.webp,.webm,.mp4,.txt,.log,.json,.pdf,image/png,image/jpeg,image/webp,video/webm,video/mp4,text/plain,application/json,application/pdf' multiple disabled={loading || staging || exporting} class='sr-only' onchange={selectFiles} />
|
|
271
|
+
<BareInput id={`${instanceId}-files`} type='file' aria-label={uiM('feedback_add_files')} accept='.png,.jpg,.jpeg,.webp,.webm,.mp4,.txt,.log,.json,.pdf,.zip,.gz,.tgz,image/png,image/jpeg,image/webp,video/webm,video/mp4,text/plain,application/json,application/pdf,application/zip,application/gzip' multiple disabled={loading || staging || exporting} class='sr-only' onchange={selectFiles} />
|
|
272
272
|
</label>
|
|
273
273
|
{#if onfileschange}<FeedbackRecorder maxBytes={recordingBytes} disabled={loading || annotating || staging || exporting || attachmentLimitReached} onactive={recordingChanged} onrecord={recorded} />{/if}
|
|
274
274
|
</div>
|
|
@@ -26,44 +26,84 @@
|
|
|
26
26
|
<script lang='ts'>
|
|
27
27
|
import type { HaiError, HaiResult } from '@h-ai/core'
|
|
28
28
|
import type { UIMessageKey } from '../../../messages.js'
|
|
29
|
-
import type { AuthLoginMethod, AuthPanelMode, AuthPanelProps } from '../types.js'
|
|
29
|
+
import type { AuthLoginMethod, AuthPanelActions, AuthPanelMode, AuthPanelProps } from '../types.js'
|
|
30
|
+
import { err, HaiCommonError } from '@h-ai/core'
|
|
30
31
|
import { onMount, untrack } from 'svelte'
|
|
31
32
|
import { uiM } from '../../../messages.js'
|
|
32
33
|
import { getDataAttributes } from '../../../utils.js'
|
|
33
34
|
import Alert from '../../compounds/Alert.svelte'
|
|
35
|
+
import FormField from '../../compounds/FormField.svelte'
|
|
34
36
|
import BareButton from '../../primitives/BareButton.svelte'
|
|
35
37
|
import Button from '../../primitives/Button.svelte'
|
|
38
|
+
import Input from '../../primitives/Input.svelte'
|
|
36
39
|
import Spinner from '../../primitives/Spinner.svelte'
|
|
40
|
+
import { solveAuthCaptcha } from './auth-captcha.js'
|
|
37
41
|
import { authErrorMessage } from './auth-error-message.js'
|
|
38
42
|
import AuthShell from './AuthShell.svelte'
|
|
43
|
+
import ChangePasswordForm from './ChangePasswordForm.svelte'
|
|
39
44
|
import ForgotPasswordForm from './ForgotPasswordForm.svelte'
|
|
40
45
|
import LoginForm from './LoginForm.svelte'
|
|
41
46
|
import RegisterForm from './RegisterForm.svelte'
|
|
42
47
|
import ResetPasswordForm from './ResetPasswordForm.svelte'
|
|
43
48
|
|
|
44
|
-
const { config, actions, columns = 1, labelPosition = 'top', labelWidth = '8rem', initialMode = 'login', resetToken = '', loginUrl, registerUrl, forgotPasswordUrl, onauthenticated, error = '', onretry, loginHeader, loginFields, loginFooter, registerHeader, registerFields, registerFooter, ...restProps }: AuthPanelProps = $props()
|
|
49
|
+
const { config, actions, embedded = false, initialIdentifier = '', columns = 1, labelPosition = 'top', labelWidth = '8rem', initialMode = 'login', resetToken = '', loginUrl, registerUrl, forgotPasswordUrl, onauthenticated, error = '', onretry, loginHeader, loginFields, loginFooter, registerHeader, registerFields, registerFooter, ...restProps }: AuthPanelProps = $props()
|
|
45
50
|
const dataAttributes = $derived(getDataAttributes(restProps))
|
|
46
51
|
let mode = $state<AuthPanelMode>(untrack(() => initialMode))
|
|
47
52
|
let loading = $state(false)
|
|
53
|
+
let renewalIdentifier = $state('')
|
|
48
54
|
let actionError = $state<Pick<HaiError, 'code' | 'message'>>()
|
|
49
55
|
let networkFailed = $state(false)
|
|
50
56
|
const errors = $derived<Record<string, string>>(actionError ? { general: authErrorMessage(actionError) } : networkFailed ? { general: uiM('auth_network_error') } : {})
|
|
51
57
|
let notice = $state<UIMessageKey | ''>('')
|
|
52
58
|
// SSR 表单先显示但不可编辑;客户端绑定事件后开放输入,避免接管时丢失早到的输入。
|
|
53
59
|
let interactive = $state(false)
|
|
60
|
+
let verifying = $state(false)
|
|
61
|
+
let captchaController: AbortController | undefined
|
|
54
62
|
onMount(() => {
|
|
55
63
|
interactive = true
|
|
64
|
+
return () => captchaController?.abort()
|
|
56
65
|
})
|
|
57
66
|
const methods = $derived(config ? (['password', 'ldap', 'email', 'sms'] as AuthLoginMethod[]).filter(method => config.login[method]) : [])
|
|
58
|
-
const title = $derived(mode === 'register' ? uiM('register_title') : mode === 'forgot' ? uiM('forgot_password_title') : mode === 'reset' ? uiM('reset_password_title') : uiM('login_title'))
|
|
59
|
-
const available = $derived(config && (mode === 'login' || (mode === 'register' ? config.register.enabled : config.passwordReset.enabled)))
|
|
67
|
+
const title = $derived(mode === 'register' ? uiM('register_title') : mode === 'forgot' ? uiM('forgot_password_title') : mode === 'renew' ? uiM('auth_renew_title') : mode === 'reset' ? uiM('reset_password_title') : uiM('login_title'))
|
|
68
|
+
const available = $derived(config && (mode === 'login' || (mode === 'renew' ? Boolean(actions.renewPassword) : mode === 'register' ? config.register.enabled : config.passwordReset.enabled)))
|
|
60
69
|
|
|
61
70
|
function switchMode(next: AuthPanelMode) {
|
|
71
|
+
captchaController?.abort()
|
|
62
72
|
mode = next
|
|
63
73
|
actionError = undefined
|
|
64
74
|
networkFailed = false
|
|
65
75
|
notice = ''
|
|
66
76
|
}
|
|
77
|
+
async function withCaptcha<T>(operation: Parameters<NonNullable<AuthPanelActions['createCaptcha']>>[0]['operation'], request: (proof?: string) => Promise<HaiResult<T>>): Promise<HaiResult<T>> {
|
|
78
|
+
if (!config?.captcha?.enabled)
|
|
79
|
+
return request()
|
|
80
|
+
if (!actions.createCaptcha)
|
|
81
|
+
return err(HaiCommonError.SERVICE_UNAVAILABLE, uiM('auth_captcha_error'))
|
|
82
|
+
captchaController?.abort()
|
|
83
|
+
const controller = new AbortController()
|
|
84
|
+
captchaController = controller
|
|
85
|
+
verifying = true
|
|
86
|
+
try {
|
|
87
|
+
const challenge = await actions.createCaptcha({ operation })
|
|
88
|
+
if (!challenge.success)
|
|
89
|
+
return challenge
|
|
90
|
+
controller.signal.throwIfAborted()
|
|
91
|
+
const proof = await solveAuthCaptcha(challenge.data, controller)
|
|
92
|
+
controller.signal.throwIfAborted()
|
|
93
|
+
if (!proof)
|
|
94
|
+
return err(HaiCommonError.SERVICE_UNAVAILABLE, uiM('auth_captcha_error'))
|
|
95
|
+
return request(proof)
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return err(HaiCommonError.SERVICE_UNAVAILABLE, uiM('auth_captcha_error'))
|
|
99
|
+
}
|
|
100
|
+
finally {
|
|
101
|
+
if (captchaController === controller) {
|
|
102
|
+
captchaController = undefined
|
|
103
|
+
verifying = false
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
67
107
|
async function run(operation: () => Promise<HaiResult<unknown>>, authenticate = false, successNotice: UIMessageKey | '' = '') {
|
|
68
108
|
if (loading)
|
|
69
109
|
return
|
|
@@ -80,6 +120,8 @@
|
|
|
80
120
|
notice = 'auth_registration_pending'
|
|
81
121
|
}
|
|
82
122
|
else {
|
|
123
|
+
if (authenticate && actions.renewPassword && ['hai:iam:007', 'hai:iam:025'].includes(result.error.code))
|
|
124
|
+
mode = 'renew'
|
|
83
125
|
actionError = result.error
|
|
84
126
|
}
|
|
85
127
|
}
|
|
@@ -93,6 +135,15 @@
|
|
|
93
135
|
catch { networkFailed = true }
|
|
94
136
|
finally { loading = false }
|
|
95
137
|
}
|
|
138
|
+
|
|
139
|
+
async function renewPassword(password: string, newPassword: string) {
|
|
140
|
+
const renew = actions.renewPassword
|
|
141
|
+
if (!renew || loading || !renewalIdentifier.trim())
|
|
142
|
+
return
|
|
143
|
+
await run(() => withCaptcha('renewPassword', captcha => renew({ identifier: renewalIdentifier.trim(), password, newPassword, captcha })), false, 'auth_reset_done')
|
|
144
|
+
if (!actionError && !networkFailed)
|
|
145
|
+
mode = 'login'
|
|
146
|
+
}
|
|
96
147
|
</script>
|
|
97
148
|
|
|
98
149
|
{#snippet link(next: AuthPanelMode, label: string, href?: string)}
|
|
@@ -113,7 +164,7 @@
|
|
|
113
164
|
{:else}<BareButton type='button' class='link link-primary text-sm' disabled={loading} onclick={() => switchMode(next)}>{label}</BareButton>{/if}
|
|
114
165
|
{/snippet}
|
|
115
166
|
|
|
116
|
-
<AuthShell {...dataAttributes} {...config?.ui} title={config?.ui.title || title} brandTitle={config?.ui.brandTitle || uiM('auth_brand')}>
|
|
167
|
+
<AuthShell {embedded} {...dataAttributes} {...config?.ui} title={config?.ui.title || title} brandTitle={config?.ui.brandTitle || uiM('auth_brand')}>
|
|
117
168
|
<fieldset class='m-0 min-w-0 border-0 p-0' disabled={!interactive}>
|
|
118
169
|
<!-- 固定内容包装节点,避免 fieldset 插入通知时丢失容器查询子树的布局。 -->
|
|
119
170
|
<div class='min-w-0'>
|
|
@@ -127,29 +178,42 @@
|
|
|
127
178
|
<div class='mt-4 text-center'>{@render link('login', uiM('login_submit'), loginUrl)}</div>
|
|
128
179
|
{:else}
|
|
129
180
|
{#if notice}<Alert variant='success' class='mb-4'>{uiM(notice)}</Alert>{/if}
|
|
181
|
+
<span role='status' class='sr-only'>{verifying ? uiM('auth_captcha_verifying') : ''}</span>
|
|
130
182
|
{#if mode === 'login'}
|
|
131
|
-
<LoginForm {columns} {labelPosition} {labelWidth} {methods} {loading} {errors} header={loginHeader} extraFields={loginFields} showForgotPassword={config.passwordReset.enabled} {forgotPasswordUrl}
|
|
183
|
+
<LoginForm {initialIdentifier} submitText={verifying ? uiM('auth_captcha_verifying') : undefined} {columns} {labelPosition} {labelWidth} {methods} {loading} {errors} header={loginHeader} extraFields={loginFields} showForgotPassword={config.passwordReset.enabled} {forgotPasswordUrl}
|
|
132
184
|
onforgotpassword={forgotPasswordUrl ? undefined : () => switchMode('forgot')}
|
|
133
|
-
otpLength={config.otp.length} resendInterval={config.otp.resendInterval} onsendotp={actions.sendOtp}
|
|
185
|
+
otpLength={config.otp.length} resendInterval={config.otp.resendInterval} onsendotp={identifier => withCaptcha('sendOtp', captcha => actions.sendOtp(identifier, { captcha }))}
|
|
134
186
|
agreements={config.agreements.showOnLogin ? config.agreements : undefined}
|
|
135
|
-
onsubmit={data
|
|
187
|
+
onsubmit={(data) => {
|
|
188
|
+
renewalIdentifier = data.username
|
|
189
|
+
return run(() => withCaptcha('login', captcha => actions.login({ identifier: data.username, password: data.password, method: data.method, code: data.code, captcha })), true)
|
|
190
|
+
}}>
|
|
136
191
|
{#snippet footer()}
|
|
137
192
|
{#if loginFooter}{@render loginFooter()}{/if}
|
|
138
193
|
{#if config?.register.enabled}<div class='text-center text-sm'>{uiM('login_no_account')} {@render link('register', uiM('login_register_now'), registerUrl)}</div>{/if}
|
|
139
194
|
{/snippet}
|
|
140
195
|
</LoginForm>
|
|
141
196
|
{:else if mode === 'register'}
|
|
142
|
-
<RegisterForm {columns} {labelPosition} {labelWidth} {loading} {errors} header={registerHeader} extraFields={registerFields} fields={config.passwordReset.mode === 'phone' ? ['username', 'phone', 'password'] : ['username', 'email', 'password']} passwordPolicy={config.password} minPasswordLength={config.password.minLength}
|
|
143
|
-
agreements={config.agreements.showOnRegister ? config.agreements : undefined} onsubmit={data => run(() => actions.register({ username: data.username || '', password: data.password, email: data.email, phone: data.phone, displayName: data.nickname }), true)}>
|
|
197
|
+
<RegisterForm submitText={verifying ? uiM('auth_captcha_verifying') : undefined} {columns} {labelPosition} {labelWidth} {loading} {errors} header={registerHeader} extraFields={registerFields} fields={config.passwordReset.mode === 'phone' ? ['username', 'phone', 'password'] : ['username', 'email', 'password']} passwordPolicy={config.password} minPasswordLength={config.password.minLength}
|
|
198
|
+
agreements={config.agreements.showOnRegister ? config.agreements : undefined} onsubmit={data => run(() => withCaptcha('register', captcha => actions.register({ username: data.username || '', password: data.password, email: data.email, phone: data.phone, displayName: data.nickname, captcha })), true)}>
|
|
144
199
|
{#snippet footer()}
|
|
145
200
|
{#if registerFooter}{@render registerFooter()}{/if}
|
|
146
201
|
<div class='text-center'>{@render link('login', uiM('register_login_now'), loginUrl)}</div>
|
|
147
202
|
{/snippet}
|
|
148
203
|
</RegisterForm>
|
|
149
204
|
{:else if mode === 'forgot'}
|
|
150
|
-
<ForgotPasswordForm {columns} {labelPosition} {labelWidth} {loading} {errors} mode={config.passwordReset.mode ?? 'email'} onsubmit={data => run(() => actions.requestPasswordReset(data.email || data.phone || ''), false, 'auth_reset_sent')}>
|
|
205
|
+
<ForgotPasswordForm submitText={verifying ? uiM('auth_captcha_verifying') : undefined} {columns} {labelPosition} {labelWidth} {loading} {errors} mode={config.passwordReset.mode ?? 'email'} onsubmit={data => run(() => withCaptcha('passwordReset', captcha => actions.requestPasswordReset(data.email || data.phone || '', { captcha })), false, 'auth_reset_sent')}>
|
|
151
206
|
{#snippet footer()}<div class='flex justify-between gap-3'>{@render link('login', uiM('login_submit'), loginUrl)}{@render link('reset', uiM('auth_have_token'))}</div>{/snippet}
|
|
152
207
|
</ForgotPasswordForm>
|
|
208
|
+
{:else if mode === 'renew'}
|
|
209
|
+
<div class='mb-5'>
|
|
210
|
+
<FormField for='renew-identifier' label={uiM('login_username')}>
|
|
211
|
+
<Input id='renew-identifier' autocomplete='username' bind:value={renewalIdentifier} disabled={loading} required />
|
|
212
|
+
</FormField>
|
|
213
|
+
</div>
|
|
214
|
+
<ChangePasswordForm submitText={verifying ? uiM('auth_captcha_verifying') : undefined} {columns} {labelPosition} {labelWidth} {loading} {errors} disabled={!renewalIdentifier.trim()} passwordPolicy={config.password} minPasswordLength={config.password.minLength}
|
|
215
|
+
onsubmit={data => renewPassword(data.oldPassword || '', data.newPassword)} />
|
|
216
|
+
<div class='mt-4 text-center'>{@render link('login', uiM('login_submit'), loginUrl)}</div>
|
|
153
217
|
{:else}
|
|
154
218
|
<ResetPasswordForm {columns} {labelPosition} {labelWidth} {loading} {errors} showCode={!resetToken} passwordPolicy={config.password} minPasswordLength={config.password.minLength}
|
|
155
219
|
onsubmit={data => run(() => actions.confirmPasswordReset(resetToken || data.code || '', data.newPassword), false, 'auth_reset_done')} />
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
const {
|
|
26
26
|
variant = 'card',
|
|
27
27
|
title = '',
|
|
28
|
+
embedded = false,
|
|
28
29
|
subtitle = '',
|
|
29
30
|
brandTitle = '',
|
|
30
31
|
brandText = '',
|
|
@@ -42,6 +43,8 @@
|
|
|
42
43
|
}: {
|
|
43
44
|
/** 布局形态:'card'(居中卡片,默认)或 'split'(左右分栏) */
|
|
44
45
|
variant?: 'card' | 'split'
|
|
46
|
+
/** 嵌入已有弹窗/布局,只渲染表单内容。 */
|
|
47
|
+
embedded?: boolean
|
|
45
48
|
/** 表单区标题 */
|
|
46
49
|
title?: string
|
|
47
50
|
/** 表单区副标题 */
|
|
@@ -96,7 +99,9 @@
|
|
|
96
99
|
</div>
|
|
97
100
|
{/snippet}
|
|
98
101
|
|
|
99
|
-
{#if
|
|
102
|
+
{#if embedded}
|
|
103
|
+
<div {...dataAttributes} class={className}>{#if children}{@render children()}{/if}</div>
|
|
104
|
+
{:else if isSplit}
|
|
100
105
|
<div class={cn('grid min-h-screen lg:grid-cols-2', className)}>
|
|
101
106
|
<!-- 品牌区 -->
|
|
102
107
|
<div class='relative hidden overflow-hidden bg-primary p-10 text-primary-content lg:flex'>
|
|
@@ -150,7 +150,7 @@
|
|
|
150
150
|
<Button
|
|
151
151
|
type='submit'
|
|
152
152
|
variant='primary'
|
|
153
|
-
class='w-full sm:w-auto sm:min-w-40'
|
|
153
|
+
class='disabled:text-base-content/70 w-full sm:w-auto sm:min-w-40'
|
|
154
154
|
disabled={loading || disabled || !canSubmit || Boolean(policyError)}
|
|
155
155
|
{loading}
|
|
156
156
|
>
|