feat(i18n): update error messages for device trust operations

This commit is contained in:
shuaiplus
2026-03-08 22:24:11 +08:00
parent c34c44ce5b
commit 54cf1ff718
2 changed files with 25 additions and 14 deletions
+7 -6
View File
@@ -1,4 +1,5 @@
import { base64ToBytes, bytesToBase64, decryptBw, decryptBwFileData, decryptStr, encryptBw, encryptBwFileData, hkdf, hkdfExpand, pbkdf2 } from './crypto'; import { base64ToBytes, bytesToBase64, decryptBw, decryptBwFileData, decryptStr, encryptBw, encryptBwFileData, hkdf, hkdfExpand, pbkdf2 } from './crypto';
import { t } from './i18n';
import type { import type {
AuthorizedDevice, AuthorizedDevice,
AdminInvite, AdminInvite,
@@ -748,7 +749,7 @@ export async function getAuthorizedDevices(
authedFetch: (input: string, init?: RequestInit) => Promise<Response> authedFetch: (input: string, init?: RequestInit) => Promise<Response>
): Promise<AuthorizedDevice[]> { ): Promise<AuthorizedDevice[]> {
const resp = await authedFetch('/api/devices/authorized'); const resp = await authedFetch('/api/devices/authorized');
if (!resp.ok) throw new Error('Failed to load authorized devices'); if (!resp.ok) throw new Error(t('txt_load_devices_failed'));
const body = await parseJson<ListResponse<AuthorizedDevice>>(resp); const body = await parseJson<ListResponse<AuthorizedDevice>>(resp);
return body?.data || []; return body?.data || [];
} }
@@ -758,14 +759,14 @@ export async function revokeAuthorizedDeviceTrust(
deviceIdentifier: string deviceIdentifier: string
): Promise<void> { ): Promise<void> {
const resp = await authedFetch(`/api/devices/authorized/${encodeURIComponent(deviceIdentifier)}`, { method: 'DELETE' }); const resp = await authedFetch(`/api/devices/authorized/${encodeURIComponent(deviceIdentifier)}`, { method: 'DELETE' });
if (!resp.ok) throw new Error('Failed to revoke device authorization'); if (!resp.ok) throw new Error(t('txt_revoke_device_trust_failed'));
} }
export async function revokeAllAuthorizedDeviceTrust( export async function revokeAllAuthorizedDeviceTrust(
authedFetch: (input: string, init?: RequestInit) => Promise<Response> authedFetch: (input: string, init?: RequestInit) => Promise<Response>
): Promise<void> { ): Promise<void> {
const resp = await authedFetch('/api/devices/authorized', { method: 'DELETE' }); const resp = await authedFetch('/api/devices/authorized', { method: 'DELETE' });
if (!resp.ok) throw new Error('Failed to revoke all authorized devices'); if (!resp.ok) throw new Error(t('txt_revoke_all_device_trust_failed'));
} }
export async function deleteAuthorizedDevice( export async function deleteAuthorizedDevice(
@@ -773,14 +774,14 @@ export async function deleteAuthorizedDevice(
deviceIdentifier: string deviceIdentifier: string
): Promise<void> { ): Promise<void> {
const resp = await authedFetch(`/api/devices/${encodeURIComponent(deviceIdentifier)}`, { method: 'DELETE' }); const resp = await authedFetch(`/api/devices/${encodeURIComponent(deviceIdentifier)}`, { method: 'DELETE' });
if (!resp.ok) throw new Error('Failed to remove device'); if (!resp.ok) throw new Error(t('txt_remove_device_failed'));
} }
export async function deleteAllAuthorizedDevices( export async function deleteAllAuthorizedDevices(
authedFetch: (input: string, init?: RequestInit) => Promise<Response> authedFetch: (input: string, init?: RequestInit) => Promise<Response>
): Promise<void> { ): Promise<void> {
const resp = await authedFetch('/api/devices', { method: 'DELETE' }); const resp = await authedFetch('/api/devices', { method: 'DELETE' });
if (!resp.ok) throw new Error('Failed to remove all devices'); if (!resp.ok) throw new Error(t('txt_remove_all_devices_failed'));
} }
export async function listAdminUsers(authedFetch: (input: string, init?: RequestInit) => Promise<Response>): Promise<AdminUser[]> { export async function listAdminUsers(authedFetch: (input: string, init?: RequestInit) => Promise<Response>): Promise<AdminUser[]> {
@@ -973,7 +974,7 @@ async function normalizeFido2Credentials(
, ,
enc: Uint8Array, enc: Uint8Array,
mac: Uint8Array mac: Uint8Array
): Array<Record<string, unknown>> | null { ): Promise<Array<Record<string, unknown>> | null> {
if (!Array.isArray(credentials) || credentials.length === 0) return null; if (!Array.isArray(credentials) || credentials.length === 0) return null;
const out: Array<Record<string, unknown>> = []; const out: Array<Record<string, unknown>> = [];
for (const credential of credentials) { for (const credential of credentials) {
+18 -8
View File
@@ -44,7 +44,7 @@ const messages: Record<Locale, Record<string, string>> = {
txt_address_1: "Address 1", txt_address_1: "Address 1",
txt_address_2: "Address 2", txt_address_2: "Address 2",
txt_address_3: "Address 3", txt_address_3: "Address 3",
txt_all_device_authorizations_revoked: "All device authorizations revoked", txt_all_device_authorizations_revoked: "All device trust revoked",
txt_all_invites_deleted: "All invites deleted", txt_all_invites_deleted: "All invites deleted",
txt_all_items: "All Items", txt_all_items: "All Items",
txt_all_sends: "All Sends", txt_all_sends: "All Sends",
@@ -116,9 +116,10 @@ const messages: Record<Locale, Record<string, string>> = {
txt_deletion_date: "Deletion Date", txt_deletion_date: "Deletion Date",
txt_deletion_days: "Deletion Days", txt_deletion_days: "Deletion Days",
txt_device: "Device", txt_device: "Device",
txt_device_authorization_revoked: "Device authorization revoked", txt_device_authorization_revoked: "Device trust revoked",
txt_device_management: "Device Management", txt_device_management: "Device Management",
txt_device_removed: "Device removed", txt_device_removed: "Device removed",
txt_load_devices_failed: "Failed to load devices",
txt_disable_this_send: "Disable this send", txt_disable_this_send: "Disable this send",
txt_disable_totp: "Disable TOTP", txt_disable_totp: "Disable TOTP",
txt_disable_totp_failed: "Disable TOTP failed", txt_disable_totp_failed: "Disable TOTP failed",
@@ -312,8 +313,10 @@ const messages: Record<Locale, Record<string, string>> = {
txt_revoke_30_day_totp_trust_for_name: "Revoke 30-day TOTP trust for \"{name}\"?", txt_revoke_30_day_totp_trust_for_name: "Revoke 30-day TOTP trust for \"{name}\"?",
txt_revoke_30_day_totp_trust_from_all_devices: "Revoke 30-day TOTP trust from all devices?", txt_revoke_30_day_totp_trust_from_all_devices: "Revoke 30-day TOTP trust from all devices?",
txt_revoke_all_trusted: "Revoke All Trusted", txt_revoke_all_trusted: "Revoke All Trusted",
txt_revoke_all_trusted_devices: "Revoke all trusted devices", txt_revoke_all_trusted_devices: "Revoke all device trust",
txt_revoke_device_authorization: "Revoke device authorization", txt_revoke_device_authorization: "Revoke device trust",
txt_revoke_device_trust_failed: "Failed to revoke device trust",
txt_revoke_all_device_trust_failed: "Failed to revoke all device trust",
txt_revoke_trust: "Revoke Trust", txt_revoke_trust: "Revoke Trust",
txt_role: "Role", txt_role: "Role",
txt_save: "Save", txt_save: "Save",
@@ -390,6 +393,8 @@ const messages: Record<Locale, Record<string, string>> = {
txt_unignore: "Unignore", txt_unignore: "Unignore",
txt_unlocked: "Unlocked", txt_unlocked: "Unlocked",
txt_all_devices_removed: "All devices removed", txt_all_devices_removed: "All devices removed",
txt_remove_device_failed: "Failed to remove device",
txt_remove_all_devices_failed: "Failed to remove all devices",
txt_update_item_failed: "Update item failed", txt_update_item_failed: "Update item failed",
txt_update_send_failed: "Update send failed", txt_update_send_failed: "Update send failed",
txt_use_recovery_code: "Use Recovery Code", txt_use_recovery_code: "Use Recovery Code",
@@ -622,7 +627,7 @@ const zhCNOverrides: Record<string, string> = {
txt_actions: '操作', txt_actions: '操作',
txt_type: '类型', txt_type: '类型',
txt_revoke_all_trusted: '撤销全部受信任设备', txt_revoke_all_trusted: '撤销全部受信任设备',
txt_revoke_all_trusted_devices: '撤销所有受信任设备', txt_revoke_all_trusted_devices: '撤销所有设备信任',
txt_revoke_30_day_totp_trust_from_all_devices: '确认撤销所有设备的 30 天 TOTP 信任吗?', txt_revoke_30_day_totp_trust_from_all_devices: '确认撤销所有设备的 30 天 TOTP 信任吗?',
txt_revoke_30_day_totp_trust_for_name: '确认撤销“{name}”的 30 天 TOTP 信任吗?', txt_revoke_30_day_totp_trust_for_name: '确认撤销“{name}”的 30 天 TOTP 信任吗?',
txt_remove_device_name_and_clear_its_2fa_trust: '确认移除设备“{name}”并清除其 2FA 信任吗?', txt_remove_device_name_and_clear_its_2fa_trust: '确认移除设备“{name}”并清除其 2FA 信任吗?',
@@ -642,7 +647,7 @@ const zhCNOverrides: Record<string, string> = {
txt_address_1: '地址 1', txt_address_1: '地址 1',
txt_address_2: '地址 2', txt_address_2: '地址 2',
txt_address_3: '地址 3', txt_address_3: '地址 3',
txt_all_device_authorizations_revoked: '已撤销所有设备授权', txt_all_device_authorizations_revoked: '已撤销所有设备信任',
txt_all_invites_deleted: '已删除所有邀请码', txt_all_invites_deleted: '已删除所有邀请码',
txt_all_sends: '所有发送', txt_all_sends: '所有发送',
txt_android: '安卓', txt_android: '安卓',
@@ -676,8 +681,9 @@ const zhCNOverrides: Record<string, string> = {
txt_delete_user: '删除用户', txt_delete_user: '删除用户',
txt_deleted_selected_items: '已删除所选项目', txt_deleted_selected_items: '已删除所选项目',
txt_deleted_selected_sends: '已删除所选发送', txt_deleted_selected_sends: '已删除所选发送',
txt_device_authorization_revoked: '已撤销设备授权', txt_device_authorization_revoked: '设备信任已撤销',
txt_device_removed: '设备已移除', txt_device_removed: '设备已移除',
txt_load_devices_failed: '加载设备失败',
txt_disable_totp_failed: '禁用 TOTP 失败', txt_disable_totp_failed: '禁用 TOTP 失败',
txt_download_failed: '下载失败', txt_download_failed: '下载失败',
txt_edge_browser: 'Edge 浏览器', txt_edge_browser: 'Edge 浏览器',
@@ -745,7 +751,9 @@ const zhCNOverrides: Record<string, string> = {
txt_registration_succeeded_please_sign_in: '注册成功,请登录', txt_registration_succeeded_please_sign_in: '注册成功,请登录',
txt_remove_device: '移除设备', txt_remove_device: '移除设备',
txt_revoke: '撤销', txt_revoke: '撤销',
txt_revoke_device_authorization: '撤销设备授权', txt_revoke_device_authorization: '撤销设备信任',
txt_revoke_device_trust_failed: '撤销设备信任失败',
txt_revoke_all_device_trust_failed: '撤销所有设备信任失败',
txt_save_profile_failed: '保存资料失败', txt_save_profile_failed: '保存资料失败',
txt_secret_and_code_are_required: '密钥和代码不能为空', txt_secret_and_code_are_required: '密钥和代码不能为空',
txt_secret_copied: '密钥已复制', txt_secret_copied: '密钥已复制',
@@ -778,6 +786,8 @@ const zhCNOverrides: Record<string, string> = {
txt_unlock_failed_master_password_is_incorrect: '解锁失败,主密码不正确。', txt_unlock_failed_master_password_is_incorrect: '解锁失败,主密码不正确。',
txt_unlocked: '已解锁', txt_unlocked: '已解锁',
txt_all_devices_removed: '已移除所有设备', txt_all_devices_removed: '已移除所有设备',
txt_remove_device_failed: '移除设备失败',
txt_remove_all_devices_failed: '移除所有设备失败',
txt_update_item_failed: '更新项目失败', txt_update_item_failed: '更新项目失败',
txt_update_send_failed: '更新发送失败', txt_update_send_failed: '更新发送失败',
txt_use_your_one_time_recovery_code_to_disable_two_step_verification: '使用一次性恢复代码禁用两步验证。', txt_use_your_one_time_recovery_code_to_disable_two_step_verification: '使用一次性恢复代码禁用两步验证。',