code refactor

This commit is contained in:
MaysWind
2025-01-05 20:43:19 +08:00
parent 53ab441486
commit 49f1f3c86b
2 changed files with 10 additions and 9 deletions
+9
View File
@@ -55,6 +55,15 @@ export interface LocaleDefaultSettings {
firstDayOfWeek: number;
}
export interface ApplicationLockState {
readonly username: string;
readonly secret: string;
}
export interface WebAuthnConfig {
readonly credentialId: string;
}
export const DEFAULT_APPLICATION_SETTINGS: ApplicationSettings = {
theme: 'auto',
fontSize: 1,
+1 -9
View File
@@ -1,5 +1,6 @@
import CryptoJS from 'crypto-js';
import type { ApplicationLockState, WebAuthnConfig } from '@/core/setting.ts';
import type { UserBasicInfo } from '@/models/user.ts';
import { isString, isObject } from './common.ts';
@@ -17,15 +18,6 @@ const tokenSessionStorageKey: string = 'ebk_user_session_token';
const encryptedTokenSessionStorageKey: string = 'ebk_user_session_encrypted_token';
const appLockStateSessionStorageKey: string = 'ebk_user_app_lock_state'; // { 'username': '', secret: '' }
export interface ApplicationLockState {
readonly username: string;
readonly secret: string;
}
export interface WebAuthnConfig {
readonly credentialId: string;
}
function getAppLockSecret(pinCode: string): string {
const hashedPinCode = CryptoJS.SHA256(appLockSecretBaseStringPrefix + pinCode).toString();
return hashedPinCode.substring(0, 24); // put secret into user id of webauthn (user id total length must less 64 bytes)