mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-16 07:57:33 +08:00
migrate webauthn.js to typescript
This commit is contained in:
@@ -119,8 +119,10 @@ import { useExchangeRatesStore } from '@/stores/exchangeRates.ts';
|
||||
|
||||
import { APPLICATION_LOGO_PATH } from '@/consts/asset.ts';
|
||||
import { ThemeType } from '@/core/theme.ts';
|
||||
import logger from '@/lib/logger.ts';
|
||||
import webauthn from '@/lib/webauthn.js';
|
||||
import {
|
||||
isWebAuthnSupported,
|
||||
verifyWebAuthnCredential
|
||||
} from '@/lib/webauthn.ts';
|
||||
import {
|
||||
unlockTokenByWebAuthn,
|
||||
unlockTokenByPinCode,
|
||||
@@ -128,6 +130,7 @@ import {
|
||||
getWebAuthnCredentialId
|
||||
} from '@/lib/userstate.ts';
|
||||
import { setExpenseAndIncomeAmountColor } from '@/lib/ui/common.ts';
|
||||
import logger from '@/lib/logger.ts';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
@@ -150,7 +153,7 @@ export default {
|
||||
isWebAuthnAvailable() {
|
||||
return this.settingsStore.appSettings.applicationLockWebAuthn
|
||||
&& hasWebAuthnConfig()
|
||||
&& webauthn.isSupported();
|
||||
&& isWebAuthnSupported();
|
||||
},
|
||||
isDarkMode() {
|
||||
return this.globalTheme.global.name.value === ThemeType.Dark;
|
||||
@@ -175,14 +178,14 @@ export default {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!webauthn.isSupported()) {
|
||||
if (!isWebAuthnSupported()) {
|
||||
self.$refs.snackbar.showMessage('WebAuth is not supported on this device');
|
||||
return;
|
||||
}
|
||||
|
||||
self.verifyingByWebAuthn = true;
|
||||
|
||||
webauthn.verifyCredential(
|
||||
verifyWebAuthnCredential(
|
||||
self.userStore.currentUserBasicInfo,
|
||||
getWebAuthnCredentialId()
|
||||
).then(({ id, userName, userSecret }) => {
|
||||
|
||||
@@ -66,8 +66,10 @@ import { useSettingsStore } from '@/stores/setting.ts';
|
||||
import { useUserStore } from '@/stores/user.ts';
|
||||
import { useTransactionsStore } from '@/stores/transaction.js';
|
||||
|
||||
import logger from '@/lib/logger.ts';
|
||||
import webauthn from '@/lib/webauthn.js';
|
||||
import {
|
||||
isWebAuthnCompletelySupported,
|
||||
registerWebAuthnCredential
|
||||
} from '@/lib/webauthn.ts';
|
||||
import {
|
||||
getUserAppLockState,
|
||||
encryptToken,
|
||||
@@ -76,6 +78,7 @@ import {
|
||||
saveWebAuthnConfig,
|
||||
clearWebAuthnConfig
|
||||
} from '@/lib/userstate.ts';
|
||||
import logger from '@/lib/logger.ts';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
@@ -114,7 +117,7 @@ export default {
|
||||
if (newValue) {
|
||||
self.enablingWebAuthn = true;
|
||||
|
||||
webauthn.registerCredential(
|
||||
registerWebAuthnCredential(
|
||||
getUserAppLockState(),
|
||||
self.userStore.currentUserBasicInfo,
|
||||
).then(({ id }) => {
|
||||
@@ -150,7 +153,7 @@ export default {
|
||||
},
|
||||
created() {
|
||||
const self = this;
|
||||
webauthn.isCompletelySupported().then(result => {
|
||||
isWebAuthnCompletelySupported().then(result => {
|
||||
self.isSupportedWebAuthn = result;
|
||||
});
|
||||
},
|
||||
|
||||
@@ -41,8 +41,10 @@ import { useSettingsStore } from '@/stores/setting.ts';
|
||||
import { useUserStore } from '@/stores/user.ts';
|
||||
import { useTransactionsStore } from '@/stores/transaction.js';
|
||||
|
||||
import logger from '@/lib/logger.ts';
|
||||
import webauthn from '@/lib/webauthn.js';
|
||||
import {
|
||||
isWebAuthnCompletelySupported,
|
||||
registerWebAuthnCredential
|
||||
} from '@/lib/webauthn.ts';
|
||||
import {
|
||||
getUserAppLockState,
|
||||
encryptToken,
|
||||
@@ -51,6 +53,7 @@ import {
|
||||
saveWebAuthnConfig,
|
||||
clearWebAuthnConfig
|
||||
} from '@/lib/userstate.ts';
|
||||
import logger from '@/lib/logger.ts';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
@@ -88,7 +91,7 @@ export default {
|
||||
if (newValue) {
|
||||
self.$showLoading();
|
||||
|
||||
webauthn.registerCredential(
|
||||
registerWebAuthnCredential(
|
||||
getUserAppLockState(),
|
||||
self.userStore.currentUserBasicInfo,
|
||||
).then(({ id }) => {
|
||||
@@ -124,7 +127,7 @@ export default {
|
||||
},
|
||||
created() {
|
||||
const self = this;
|
||||
webauthn.isCompletelySupported().then(result => {
|
||||
isWebAuthnCompletelySupported().then(result => {
|
||||
self.isSupportedWebAuthn = result;
|
||||
});
|
||||
},
|
||||
|
||||
@@ -74,8 +74,10 @@ import { useTransactionsStore } from '@/stores/transaction.js';
|
||||
import { useExchangeRatesStore } from '@/stores/exchangeRates.ts';
|
||||
|
||||
import { APPLICATION_LOGO_PATH } from '@/consts/asset.ts';
|
||||
import logger from '@/lib/logger.ts';
|
||||
import webauthn from '@/lib/webauthn.js';
|
||||
import {
|
||||
isWebAuthnSupported,
|
||||
verifyWebAuthnCredential
|
||||
} from '@/lib/webauthn.ts';
|
||||
import {
|
||||
unlockTokenByWebAuthn,
|
||||
unlockTokenByPinCode,
|
||||
@@ -84,6 +86,7 @@ import {
|
||||
} from '@/lib/userstate.ts';
|
||||
import { setExpenseAndIncomeAmountColor } from '@/lib/ui/common.ts';
|
||||
import { isModalShowing } from '@/lib/ui/mobile.ts';
|
||||
import logger from '@/lib/logger.ts';
|
||||
|
||||
export default {
|
||||
props: [
|
||||
@@ -108,7 +111,7 @@ export default {
|
||||
isWebAuthnAvailable() {
|
||||
return this.settingsStore.appSettings.applicationLockWebAuthn
|
||||
&& hasWebAuthnConfig()
|
||||
&& webauthn.isSupported();
|
||||
&& isWebAuthnSupported();
|
||||
},
|
||||
currentLanguageCode() {
|
||||
return this.$locale.getCurrentLanguageTag();
|
||||
@@ -127,14 +130,14 @@ export default {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!webauthn.isSupported()) {
|
||||
if (!isWebAuthnSupported()) {
|
||||
self.$toast('WebAuth is not supported on this device');
|
||||
return;
|
||||
}
|
||||
|
||||
self.$showLoading();
|
||||
|
||||
webauthn.verifyCredential(
|
||||
verifyWebAuthnCredential(
|
||||
self.userStore.currentUserBasicInfo,
|
||||
getWebAuthnCredentialId()
|
||||
).then(({ id, userName, userSecret }) => {
|
||||
|
||||
Reference in New Issue
Block a user