mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-18 16:54:25 +08:00
code refactor
This commit is contained in:
@@ -55,6 +55,15 @@ export interface LocaleDefaultSettings {
|
|||||||
firstDayOfWeek: number;
|
firstDayOfWeek: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ApplicationLockState {
|
||||||
|
readonly username: string;
|
||||||
|
readonly secret: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface WebAuthnConfig {
|
||||||
|
readonly credentialId: string;
|
||||||
|
}
|
||||||
|
|
||||||
export const DEFAULT_APPLICATION_SETTINGS: ApplicationSettings = {
|
export const DEFAULT_APPLICATION_SETTINGS: ApplicationSettings = {
|
||||||
theme: 'auto',
|
theme: 'auto',
|
||||||
fontSize: 1,
|
fontSize: 1,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import CryptoJS from 'crypto-js';
|
import CryptoJS from 'crypto-js';
|
||||||
|
|
||||||
|
import type { ApplicationLockState, WebAuthnConfig } from '@/core/setting.ts';
|
||||||
import type { UserBasicInfo } from '@/models/user.ts';
|
import type { UserBasicInfo } from '@/models/user.ts';
|
||||||
|
|
||||||
import { isString, isObject } from './common.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 encryptedTokenSessionStorageKey: string = 'ebk_user_session_encrypted_token';
|
||||||
const appLockStateSessionStorageKey: string = 'ebk_user_app_lock_state'; // { 'username': '', secret: '' }
|
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 {
|
function getAppLockSecret(pinCode: string): string {
|
||||||
const hashedPinCode = CryptoJS.SHA256(appLockSecretBaseStringPrefix + pinCode).toString();
|
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)
|
return hashedPinCode.substring(0, 24); // put secret into user id of webauthn (user id total length must less 64 bytes)
|
||||||
|
|||||||
Reference in New Issue
Block a user