@h-ai/ui 1.0.0-beta.14 → 1.0.0-beta.16
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
CHANGED
|
@@ -877,7 +877,7 @@ agreements:
|
|
|
877
877
|
|
|
878
878
|
AuthPanel accepts public IAM config and actions for password/LDAP/email/SMS login, registration and recovery. config.ui supplies layout, branding and images. LoginForm supports methods, onsendotp, otpLength and resendInterval; password forms accept passwordPolicy. Network and token storage remain in actions.
|
|
879
879
|
|
|
880
|
-
Use `authErrorMessage(error)` from `@h-ai/ui/components/scenes/iam/index` for authentication failures. It maps public codes to the current UI language, combines username/password failures, hides raw unknown/server errors and preserves a valid `traceId`. AuthPanel, OTP sending, sensitive confirmation and fullstack password changes share this mapping. Initial/expired passwords, reuse of the current password (`hai:iam:034`) and session limits have actionable messages. Authentication errors and successful operations use the unified Toast. Password confirmation compares exact strings without Unicode normalization or trimming and reports mismatches through Toast while retaining field associations.
|
|
880
|
+
Use `authErrorMessage(error)` from `@h-ai/ui/components/scenes/iam/index` for authentication failures. It maps public codes to the current UI language, combines username/password failures, hides raw unknown/server errors and preserves a valid `traceId`. AuthPanel, OTP sending, sensitive confirmation and fullstack password changes share this mapping. Initial/expired passwords, reuse of the current password (`hai:iam:034`) and session limits have actionable messages. Authentication errors and successful operations use the unified Toast. Password confirmation compares exact strings without Unicode normalization or trimming and reports mismatches through Toast while retaining field associations. AuthPanel displays the server’s UTC time and synchronization guidance for time errors verified by Kit or API Client.
|
|
881
881
|
|
|
882
882
|
AuthPanel disables native form controls during SSR and enables input after client mount binds events, preventing early input from being lost during hydration. Applications need no extra readiness code. E2E tests wait for editable controls and cover delayed client scripts.
|
|
883
883
|
|
package/README.ja.md
CHANGED
|
@@ -877,7 +877,7 @@ agreements:
|
|
|
877
877
|
|
|
878
878
|
AuthPanel に IAM 公開設定と actions を渡すと、複数方式のログイン、登録、復旧、規約を利用できます。config.ui でレイアウトとブランド画像を指定し、パスワードフォームは passwordPolicy を受け取ります。通信と Token 保存は actions の責務です。
|
|
879
879
|
|
|
880
|
-
認証エラーには `@h-ai/ui/components/scenes/iam/index` の `authErrorMessage(error)` を使用します。公開コードを現在の UI 言語に変換し、ユーザー名とパスワードの誤りを区別せず、未知・サーバーエラーの原文を隠し、有効な `traceId` を保持します。AuthPanel、OTP 送信、重要操作の再認証、fullstack のパスワード変更で共用します。初期・期限切れパスワード、現在のパスワードの再使用(`hai:iam:034`)、セッション数上限には操作案内を表示します。認証エラーと操作成功は統一 Toast を使用します。確認パスワードはサーバーと同じく Unicode 正規化や空白除去をせず厳密に比較し、不一致をフィールドに表示します。
|
|
880
|
+
認証エラーには `@h-ai/ui/components/scenes/iam/index` の `authErrorMessage(error)` を使用します。公開コードを現在の UI 言語に変換し、ユーザー名とパスワードの誤りを区別せず、未知・サーバーエラーの原文を隠し、有効な `traceId` を保持します。AuthPanel、OTP 送信、重要操作の再認証、fullstack のパスワード変更で共用します。初期・期限切れパスワード、現在のパスワードの再使用(`hai:iam:034`)、セッション数上限には操作案内を表示します。認証エラーと操作成功は統一 Toast を使用します。確認パスワードはサーバーと同じく Unicode 正規化や空白除去をせず厳密に比較し、不一致をフィールドに表示します。Kit または API Client で検証した時刻エラーでは、AuthPanel がサーバーの UTC 時刻と時刻調整の案内を表示します。
|
|
881
881
|
|
|
882
882
|
AuthPanel は SSR 中のフォーム操作を無効にし、クライアントのマウントとイベント登録が完了してから入力を有効にします。ハイドレーションによる入力の消失を防ぎ、アプリ側の追加の準備処理は不要です。E2E では入力可能な状態を待ち、クライアントスクリプトの読み込みが遅れる場合も検証します。
|
|
883
883
|
|
package/README.md
CHANGED
|
@@ -893,7 +893,7 @@ agreements:
|
|
|
893
893
|
|
|
894
894
|
AuthPanel 直接接收 IAM 白名单配置和 actions,内置登录(密码/LDAP/邮件/短信)、注册、找回、重置及协议展示。使用 `config.ui` 配置卡片/分栏、标题、品牌、Logo 和配图。`LoginForm` 提供 methods、onsendotp、otpLength、resendInterval;密码表单接受 passwordPolicy。组件只渲染与交互,网络和 Token 存储通过 actions 注入。
|
|
895
895
|
|
|
896
|
-
认证错误统一使用 `authErrorMessage(error)`(从 `@h-ai/ui/components/scenes/iam/index` 导入):按公开错误码显示当前 UI 语言,凭据错误统一为“用户名或密码不正确”,未知错误及服务异常不显示原文,保留有效 `traceId`。AuthPanel、验证码发送、敏感操作确认与 fullstack 改密共用此映射。首次改密、密码过期、当前密码复用(`hai:iam:034`)和会话上限各有操作指引;操作成功和错误均使用统一 Toast。确认密码与服务端一样逐字符比较,不归一化 Unicode 或裁剪空白,输入不一致时由 Toast 提示,并保留字段关联。
|
|
896
|
+
认证错误统一使用 `authErrorMessage(error)`(从 `@h-ai/ui/components/scenes/iam/index` 导入):按公开错误码显示当前 UI 语言,凭据错误统一为“用户名或密码不正确”,未知错误及服务异常不显示原文,保留有效 `traceId`。AuthPanel、验证码发送、敏感操作确认与 fullstack 改密共用此映射。首次改密、密码过期、当前密码复用(`hai:iam:034`)和会话上限各有操作指引;操作成功和错误均使用统一 Toast。确认密码与服务端一样逐字符比较,不归一化 Unicode 或裁剪空白,输入不一致时由 Toast 提示,并保留字段关联。Kit 和 API Client 确认的时间窗口错误会在认证提示中显示服务器 UTC 时间及校时建议。
|
|
897
897
|
|
|
898
898
|
AuthPanel 在 SSR 阶段禁用原生表单控件,客户端挂载并绑定事件后自动开放输入,避免接管时丢失早到的输入。应用无需额外的就绪适配;E2E 等待控件可编辑,并覆盖客户端脚本延迟加载的场景。
|
|
899
899
|
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
let mode = $state<AuthPanelMode>(untrack(() => initialMode))
|
|
52
52
|
let loading = $state(false)
|
|
53
53
|
let renewalIdentifier = $state('')
|
|
54
|
-
let actionError = $state<
|
|
54
|
+
let actionError = $state<HaiError>()
|
|
55
55
|
let networkFailed = $state(false)
|
|
56
56
|
const errors = $derived<Record<string, string>>(actionError ? { general: authErrorMessage(actionError) } : networkFailed ? { general: uiM('auth_network_error') } : {})
|
|
57
57
|
let notice = $state<UIMessageKey | ''>('')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HaiError } from '@h-ai/core';
|
|
2
2
|
/**
|
|
3
|
-
* 将 IAM
|
|
3
|
+
* 将 IAM 错误映射为当前语言的安全认证提示,并保留标准客户端生成的校时建议。
|
|
4
4
|
* @param error - 待显示的安全错误对象或消息。
|
|
5
5
|
* @returns 本地化提示及有效 traceId,不包含原始异常、账户字段原因或其他内部信息。
|
|
6
6
|
*
|
|
@@ -10,4 +10,4 @@ import type { HaiError } from '@h-ai/core';
|
|
|
10
10
|
* const message = authErrorMessage({ code: 'hai:iam:020', message: '登录失败' })
|
|
11
11
|
* ```
|
|
12
12
|
*/
|
|
13
|
-
export declare function authErrorMessage(error: Pick<HaiError, 'code' | 'message' | 'traceId' | 'httpStatus'>): string;
|
|
13
|
+
export declare function authErrorMessage(error: Pick<HaiError, 'code' | 'message' | 'traceId' | 'httpStatus' | 'cause'>): string;
|
|
@@ -49,7 +49,7 @@ const messages = {
|
|
|
49
49
|
'hai:iam:999': 'auth_error_service',
|
|
50
50
|
};
|
|
51
51
|
/**
|
|
52
|
-
* 将 IAM
|
|
52
|
+
* 将 IAM 错误映射为当前语言的安全认证提示,并保留标准客户端生成的校时建议。
|
|
53
53
|
* @param error - 待显示的安全错误对象或消息。
|
|
54
54
|
* @returns 本地化提示及有效 traceId,不包含原始异常、账户字段原因或其他内部信息。
|
|
55
55
|
*
|
|
@@ -60,6 +60,11 @@ const messages = {
|
|
|
60
60
|
* ```
|
|
61
61
|
*/
|
|
62
62
|
export function authErrorMessage(error) {
|
|
63
|
+
const { cause } = error;
|
|
64
|
+
if (error.httpStatus === 400 && (error.code === 'hai:crypto:071' || error.code === 'hai:api-client:007')
|
|
65
|
+
&& cause && typeof cause === 'object' && 'transportCode' in cause && cause.transportCode === 'hai:crypto:071') {
|
|
66
|
+
return core.error.formatMessage({ message: core.sanitize.sanitizeText(error.message), traceId: error.traceId });
|
|
67
|
+
}
|
|
63
68
|
const key = (error.httpStatus ?? 400) >= 500 || !Object.hasOwn(messages, error.code) ? 'auth_error_service' : messages[error.code] ?? 'auth_error_service';
|
|
64
69
|
return core.error.formatMessage({ message: uiM(key), traceId: error.traceId });
|
|
65
70
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h-ai/ui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.0-beta.
|
|
4
|
+
"version": "1.0.0-beta.16",
|
|
5
5
|
"description": "Hai Framework UI component library for Svelte 5 Runes.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"svelte": "./dist/index.js",
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
"svelte": "^5.57.2"
|
|
125
125
|
},
|
|
126
126
|
"dependencies": {
|
|
127
|
-
"@h-ai/core": "1.0.0-beta.
|
|
127
|
+
"@h-ai/core": "1.0.0-beta.16",
|
|
128
128
|
"@internationalized/date": "^3.12.4",
|
|
129
129
|
"@rrweb/replay": "^2.1.7",
|
|
130
130
|
"@shikijs/langs": "^4.5.0",
|