mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-15 07:27:33 +08:00
use pinia to replace vuex, code refactor
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import accountConstants from '../../consts/account.js';
|
||||
import accountConstants from '@/consts/account.js';
|
||||
|
||||
export function getAccountCategoryInfo(categoryId) {
|
||||
for (let i = 0; i < accountConstants.allCategories.length; i++) {
|
||||
@@ -1,5 +1,5 @@
|
||||
import categoryConstants from '../../consts/category.js';
|
||||
import transactionConstants from '../../consts/transaction.js';
|
||||
import categoryConstants from '@/consts/category.js';
|
||||
import transactionConstants from '@/consts/transaction.js';
|
||||
|
||||
export function transactionTypeToCategoryType(transactionType) {
|
||||
if (transactionType === transactionConstants.allTransactionTypes.Income) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import settings from "../../lib/settings";
|
||||
import settings from './settings.js';
|
||||
|
||||
export function isFunction(val) {
|
||||
return typeof(val) === 'function';
|
||||
@@ -227,9 +227,9 @@ export function copyObjectTo(fromObject, toObject) {
|
||||
const toValue = toObject[key];
|
||||
|
||||
if (isArray(fromValue)) {
|
||||
toObject[key] = this.copyArrayTo(fromValue, toValue);
|
||||
toObject[key] = copyArrayTo(fromValue, toValue);
|
||||
} else if (isObject(fromValue)) {
|
||||
toObject[key] = this.copyObjectTo(fromValue, toValue);
|
||||
toObject[key] = copyObjectTo(fromValue, toValue);
|
||||
} else {
|
||||
if (fromValue !== toValue) {
|
||||
toObject[key] = fromValue;
|
||||
@@ -256,9 +256,9 @@ export function copyArrayTo(fromArray, toArray) {
|
||||
const toValue = toArray[i];
|
||||
|
||||
if (isArray(fromValue)) {
|
||||
toArray[i] = this.copyArrayTo(fromValue, toValue);
|
||||
toArray[i] = copyArrayTo(fromValue, toValue);
|
||||
} else if (isObject(fromValue)) {
|
||||
toArray[i] = this.copyObjectTo(fromValue, toValue);
|
||||
toArray[i] = copyObjectTo(fromValue, toValue);
|
||||
} else {
|
||||
if (fromValue !== toValue) {
|
||||
toArray[i] = fromValue;
|
||||
@@ -266,9 +266,9 @@ export function copyArrayTo(fromArray, toArray) {
|
||||
}
|
||||
} else {
|
||||
if (isArray(fromValue)) {
|
||||
toArray.push(this.copyArrayTo(fromValue, []));
|
||||
toArray.push(copyArrayTo(fromValue, []));
|
||||
} else if (isObject(fromValue)) {
|
||||
toArray.push(this.copyObjectTo(fromValue, {}));
|
||||
toArray.push(copyObjectTo(fromValue, {}));
|
||||
} else {
|
||||
toArray.push(fromValue);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { isNumber, appendThousandsSeparator } from "./common.js";
|
||||
import { isNumber, appendThousandsSeparator } from './common.js';
|
||||
|
||||
export function numericCurrencyToString(num) {
|
||||
let str = num.toString();
|
||||
@@ -1,7 +1,7 @@
|
||||
import moment from 'moment';
|
||||
|
||||
import dateTimeConstants from '../../consts/datetime.js';
|
||||
import { isNumber } from "./common.js";
|
||||
import dateTimeConstants from '@/consts/datetime.js';
|
||||
import { isNumber } from './common.js';
|
||||
|
||||
export function getUtcOffsetMinutesByUtcOffset(utcOffset) {
|
||||
if (!utcOffset) {
|
||||
+32
-19
@@ -1,9 +1,22 @@
|
||||
import { defaultLanguage, allLanguages } from '../locales/index.js';
|
||||
import datetime from "../consts/datetime.js";
|
||||
import timezone from "../consts/timezone.js";
|
||||
import currency from "../consts/currency.js";
|
||||
import settings from "./settings.js";
|
||||
import utilities from './utilities/index.js';
|
||||
import { defaultLanguage, allLanguages } from '@/locales/index.js';
|
||||
import datetime from '@/consts/datetime.js';
|
||||
import timezone from '@/consts/timezone.js';
|
||||
import currency from '@/consts/currency.js';
|
||||
import settings from './settings.js';
|
||||
import {
|
||||
isString,
|
||||
isNumber
|
||||
} from './common.js';
|
||||
import {
|
||||
formatTime,
|
||||
getCurrentDateTime,
|
||||
getTimezoneOffset,
|
||||
getTimezoneOffsetMinutes,
|
||||
getDateTimeFormatType
|
||||
} from './datetime.js';
|
||||
import {
|
||||
numericCurrencyToString
|
||||
} from './currency.js';
|
||||
|
||||
const apiNotFoundErrorCode = 100001;
|
||||
const specifiedApiNotFoundErrors = {
|
||||
@@ -332,27 +345,27 @@ export function getI18nShortTimeFormat(translateFn, formatTypeValue) {
|
||||
|
||||
export function isLongTime24HourFormat(translateFn, formatTypeValue) {
|
||||
const defaultLongTimeFormatTypeName = translateFn('default.longTimeFormat');
|
||||
const type = utilities.getDateTimeFormatType(datetime.allLongTimeFormat, datetime.allLongTimeFormatArray, defaultLongTimeFormatTypeName, datetime.defaultLongTimeFormat, formatTypeValue);
|
||||
const type = getDateTimeFormatType(datetime.allLongTimeFormat, datetime.allLongTimeFormatArray, defaultLongTimeFormatTypeName, datetime.defaultLongTimeFormat, formatTypeValue);
|
||||
return type.is24HourFormat;
|
||||
}
|
||||
|
||||
export function isShortTime24HourFormat(translateFn, formatTypeValue) {
|
||||
const defaultShortTimeFormatTypeName = translateFn('default.shortTimeFormat');
|
||||
const type = utilities.getDateTimeFormatType(datetime.allShortTimeFormat, datetime.allShortTimeFormatArray, defaultShortTimeFormatTypeName, datetime.defaultShortTimeFormat, formatTypeValue);
|
||||
const type = getDateTimeFormatType(datetime.allShortTimeFormat, datetime.allShortTimeFormatArray, defaultShortTimeFormatTypeName, datetime.defaultShortTimeFormat, formatTypeValue);
|
||||
return type.is24HourFormat;
|
||||
}
|
||||
|
||||
export function getAllTimezones(includeSystemDefault, translateFn) {
|
||||
const defaultTimezoneOffset = utilities.getTimezoneOffset();
|
||||
const defaultTimezoneOffsetMinutes = utilities.getTimezoneOffsetMinutes();
|
||||
const defaultTimezoneOffset = getTimezoneOffset();
|
||||
const defaultTimezoneOffsetMinutes = getTimezoneOffsetMinutes();
|
||||
const allTimezones = timezone.all;
|
||||
const allTimezoneInfos = [];
|
||||
|
||||
for (let i = 0; i < allTimezones.length; i++) {
|
||||
allTimezoneInfos.push({
|
||||
name: allTimezones[i].timezoneName,
|
||||
utcOffset: (allTimezones[i].timezoneName !== timezone.utcTimezoneName ? utilities.getTimezoneOffset(allTimezones[i].timezoneName) : ''),
|
||||
utcOffsetMinutes: utilities.getTimezoneOffsetMinutes(allTimezones[i].timezoneName),
|
||||
utcOffset: (allTimezones[i].timezoneName !== timezone.utcTimezoneName ? getTimezoneOffset(allTimezones[i].timezoneName) : ''),
|
||||
utcOffsetMinutes: getTimezoneOffsetMinutes(allTimezones[i].timezoneName),
|
||||
displayName: translateFn(`timezone.${allTimezones[i].displayName}`)
|
||||
});
|
||||
}
|
||||
@@ -403,22 +416,22 @@ export function getAllCurrencies(translateFn) {
|
||||
}
|
||||
|
||||
export function getDisplayCurrency(value, currencyCode, notConvertValue, translateFn) {
|
||||
if (!utilities.isNumber(value) && !utilities.isString(value)) {
|
||||
if (!isNumber(value) && !isString(value)) {
|
||||
return value;
|
||||
}
|
||||
|
||||
if (utilities.isNumber(value)) {
|
||||
if (isNumber(value)) {
|
||||
value = value.toString();
|
||||
}
|
||||
|
||||
if (!notConvertValue) {
|
||||
const hasIncompleteFlag = utilities.isString(value) && value.charAt(value.length - 1) === '+';
|
||||
const hasIncompleteFlag = isString(value) && value.charAt(value.length - 1) === '+';
|
||||
|
||||
if (hasIncompleteFlag) {
|
||||
value = value.substring(0, value.length - 1);
|
||||
}
|
||||
|
||||
value = utilities.numericCurrencyToString(value);
|
||||
value = numericCurrencyToString(value);
|
||||
|
||||
if (hasIncompleteFlag) {
|
||||
value = value + '+';
|
||||
@@ -563,7 +576,7 @@ function getDateTimeFormats(translateFn, allFormatMap, allFormatArray, localeFor
|
||||
ret.push({
|
||||
type: datetime.defaultDateTimeFormatValue,
|
||||
format: defaultFormat,
|
||||
displayName: `${translateFn('Language Default')} (${utilities.formatTime(utilities.getCurrentDateTime(), defaultFormat)})`
|
||||
displayName: `${translateFn('Language Default')} (${formatTime(getCurrentDateTime(), defaultFormat)})`
|
||||
});
|
||||
|
||||
for (let i = 0; i < allFormatArray.length; i++) {
|
||||
@@ -573,7 +586,7 @@ function getDateTimeFormats(translateFn, allFormatMap, allFormatArray, localeFor
|
||||
ret.push({
|
||||
type: formatType.type,
|
||||
format: format,
|
||||
displayName: utilities.formatTime(utilities.getCurrentDateTime(), format)
|
||||
displayName: formatTime(getCurrentDateTime(), format)
|
||||
});
|
||||
}
|
||||
|
||||
@@ -581,7 +594,7 @@ function getDateTimeFormats(translateFn, allFormatMap, allFormatArray, localeFor
|
||||
}
|
||||
|
||||
function getDateTimeFormat(translateFn, allFormatMap, allFormatArray, localeFormatPathPrefix, localeDefaultFormatTypeName, systemDefaultFormatType, formatTypeValue) {
|
||||
const type = utilities.getDateTimeFormatType(allFormatMap, allFormatArray,
|
||||
const type = getDateTimeFormatType(allFormatMap, allFormatArray,
|
||||
localeDefaultFormatTypeName, systemDefaultFormatType, formatTypeValue);
|
||||
return translateFn(`${localeFormatPathPrefix}.${type.key}`);
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
import axios from 'axios';
|
||||
|
||||
import api from '../consts/api.js';
|
||||
import api from '@/consts/api.js';
|
||||
import userState from './userstate.js';
|
||||
import settings from './settings.js';
|
||||
import utilities from './utilities/index.js';
|
||||
import { getTimezoneOffsetMinutes } from './datetime.js';
|
||||
|
||||
let needBlockRequest = false;
|
||||
let blockedRequests = [];
|
||||
@@ -17,7 +17,7 @@ axios.interceptors.request.use(config => {
|
||||
config.headers.Authorization = `Bearer ${token}`;
|
||||
}
|
||||
|
||||
config.headers['X-Timezone-Offset'] = utilities.getTimezoneOffsetMinutes();
|
||||
config.headers['X-Timezone-Offset'] = getTimezoneOffsetMinutes();
|
||||
|
||||
if (needBlockRequest && !config.ignoreBlocked) {
|
||||
return new Promise(resolve => {
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
import Cookies from 'js-cookie';
|
||||
|
||||
import currencyConstants from '../consts/currency.js';
|
||||
import statisticsConstants from '../consts/statistics.js';
|
||||
import currencyConstants from '@/consts/currency.js';
|
||||
import statisticsConstants from '@/consts/statistics.js';
|
||||
|
||||
const settingsLocalStorageKey = 'ebk_app_settings';
|
||||
const serverSettingsCookieKey = 'ebk_server_settings';
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { f7, f7ready } from 'framework7-vue';
|
||||
|
||||
import settings from "../settings.js";
|
||||
import settings from './settings.js';
|
||||
import {
|
||||
getLocalizedError,
|
||||
getLocalizedErrorParameters
|
||||
} from "../i18n.js";
|
||||
} from './i18n.js';
|
||||
|
||||
export function showAlert(message, confirmCallback, translateFn) {
|
||||
let parameters = {};
|
||||
@@ -1,7 +1,7 @@
|
||||
import CryptoJS from 'crypto-js';
|
||||
|
||||
import settings from './settings.js';
|
||||
import utilities from './utilities/index.js';
|
||||
import { isString, isObject } from './common.js';
|
||||
|
||||
const appLockSecretBaseStringPrefix = 'EBK_LOCK_SECRET_';
|
||||
|
||||
@@ -141,7 +141,7 @@ function isCorrectPinCode(pinCode) {
|
||||
}
|
||||
|
||||
function updateToken(token) {
|
||||
if (utilities.isString(token)) {
|
||||
if (isString(token)) {
|
||||
if (settings.isEnableApplicationLock()) {
|
||||
sessionStorage.setItem(tokenSessionStorageKey, token);
|
||||
|
||||
@@ -155,7 +155,7 @@ function updateToken(token) {
|
||||
}
|
||||
|
||||
function updateUserInfo(user) {
|
||||
if (utilities.isObject(user)) {
|
||||
if (isObject(user)) {
|
||||
localStorage.setItem(userInfoLocalStorageKey, JSON.stringify(user));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,179 +0,0 @@
|
||||
import {
|
||||
isFunction,
|
||||
isObject,
|
||||
isArray,
|
||||
isString,
|
||||
isNumber,
|
||||
isBoolean,
|
||||
isEquals,
|
||||
appendThousandsSeparator,
|
||||
formatPercent,
|
||||
limitText,
|
||||
base64encode,
|
||||
arrayBufferToString,
|
||||
stringToArrayBuffer,
|
||||
getNameByKeyValue,
|
||||
copyObjectTo,
|
||||
copyArrayTo,
|
||||
arrangeArrayWithNewStartIndex,
|
||||
} from './common.js'
|
||||
|
||||
import {
|
||||
getUtcOffsetMinutesByUtcOffset,
|
||||
getUtcOffsetByUtcOffsetMinutes,
|
||||
getTimezoneOffset,
|
||||
getTimezoneOffsetMinutes,
|
||||
getBrowserTimezoneOffsetMinutes,
|
||||
getLocalDatetimeFromUnixTime,
|
||||
getUnixTimeFromLocalDatetime,
|
||||
getActualUnixTimeForStore,
|
||||
getDummyUnixTimeForLocalUsage,
|
||||
getCurrentUnixTime,
|
||||
getCurrentDateTime,
|
||||
parseDateFromUnixTime,
|
||||
formatUnixTime,
|
||||
formatTime,
|
||||
getUnixTime,
|
||||
getYear,
|
||||
getMonth,
|
||||
getYearAndMonth,
|
||||
getDay,
|
||||
getDayOfWeekName,
|
||||
getHour,
|
||||
getMinute,
|
||||
getSecond,
|
||||
getUnixTimeBeforeUnixTime,
|
||||
getUnixTimeAfterUnixTime,
|
||||
getMinuteFirstUnixTime,
|
||||
getMinuteLastUnixTime,
|
||||
getTodayFirstUnixTime,
|
||||
getTodayLastUnixTime,
|
||||
getThisWeekFirstUnixTime,
|
||||
getThisWeekLastUnixTime,
|
||||
getThisMonthFirstUnixTime,
|
||||
getThisMonthLastUnixTime,
|
||||
getThisYearFirstUnixTime,
|
||||
getThisYearLastUnixTime,
|
||||
getDateTimeFormatType,
|
||||
getShiftedDateRange,
|
||||
getDateRangeByDateType,
|
||||
isDateRangeMatchFullYears,
|
||||
isDateRangeMatchFullMonths,
|
||||
} from './datetime.js'
|
||||
|
||||
import {
|
||||
numericCurrencyToString,
|
||||
stringCurrencyToNumeric,
|
||||
getExchangedAmount,
|
||||
} from './currency.js'
|
||||
|
||||
import {
|
||||
generateRandomString,
|
||||
parseUserAgent,
|
||||
parseDeviceInfo,
|
||||
makeButtonCopyToClipboard,
|
||||
changeClipboardObjectText,
|
||||
} from './misc.js'
|
||||
|
||||
import {
|
||||
transactionTypeToCategoryType,
|
||||
categoryTypeToTransactionType,
|
||||
getTransactionPrimaryCategoryName,
|
||||
getTransactionSecondaryCategoryName,
|
||||
allVisibleTransactionCategories,
|
||||
} from './category.js'
|
||||
|
||||
import {
|
||||
getAccountCategoryInfo,
|
||||
getCategorizedAccounts,
|
||||
getVisibleCategorizedAccounts,
|
||||
getAllFilteredAccountsBalance,
|
||||
} from './account.js'
|
||||
|
||||
export default {
|
||||
// common.js
|
||||
isFunction,
|
||||
isObject,
|
||||
isArray,
|
||||
isString,
|
||||
isNumber,
|
||||
isBoolean,
|
||||
isEquals,
|
||||
appendThousandsSeparator,
|
||||
formatPercent,
|
||||
limitText,
|
||||
base64encode,
|
||||
arrayBufferToString,
|
||||
stringToArrayBuffer,
|
||||
getNameByKeyValue,
|
||||
copyObjectTo,
|
||||
copyArrayTo,
|
||||
arrangeArrayWithNewStartIndex,
|
||||
|
||||
// datetime.js
|
||||
getUtcOffsetMinutesByUtcOffset,
|
||||
getUtcOffsetByUtcOffsetMinutes,
|
||||
getTimezoneOffset,
|
||||
getTimezoneOffsetMinutes,
|
||||
getBrowserTimezoneOffsetMinutes,
|
||||
getLocalDatetimeFromUnixTime,
|
||||
getUnixTimeFromLocalDatetime,
|
||||
getActualUnixTimeForStore,
|
||||
getDummyUnixTimeForLocalUsage,
|
||||
getCurrentUnixTime,
|
||||
getCurrentDateTime,
|
||||
parseDateFromUnixTime,
|
||||
formatUnixTime,
|
||||
formatTime,
|
||||
getUnixTime,
|
||||
getYear,
|
||||
getMonth,
|
||||
getYearAndMonth,
|
||||
getDay,
|
||||
getDayOfWeekName,
|
||||
getHour,
|
||||
getMinute,
|
||||
getSecond,
|
||||
getUnixTimeBeforeUnixTime,
|
||||
getUnixTimeAfterUnixTime,
|
||||
getMinuteFirstUnixTime,
|
||||
getMinuteLastUnixTime,
|
||||
getTodayFirstUnixTime,
|
||||
getTodayLastUnixTime,
|
||||
getThisWeekFirstUnixTime,
|
||||
getThisWeekLastUnixTime,
|
||||
getThisMonthFirstUnixTime,
|
||||
getThisMonthLastUnixTime,
|
||||
getThisYearFirstUnixTime,
|
||||
getThisYearLastUnixTime,
|
||||
getDateTimeFormatType,
|
||||
getShiftedDateRange,
|
||||
getDateRangeByDateType,
|
||||
isDateRangeMatchFullYears,
|
||||
isDateRangeMatchFullMonths,
|
||||
|
||||
// currency.js
|
||||
numericCurrencyToString,
|
||||
stringCurrencyToNumeric,
|
||||
getExchangedAmount,
|
||||
|
||||
// misc.js
|
||||
generateRandomString,
|
||||
parseUserAgent,
|
||||
parseDeviceInfo,
|
||||
makeButtonCopyToClipboard,
|
||||
changeClipboardObjectText,
|
||||
|
||||
// category.js
|
||||
transactionTypeToCategoryType,
|
||||
categoryTypeToTransactionType,
|
||||
getTransactionPrimaryCategoryName,
|
||||
getTransactionSecondaryCategoryName,
|
||||
allVisibleTransactionCategories,
|
||||
|
||||
// account.js
|
||||
getAccountCategoryInfo,
|
||||
getCategorizedAccounts,
|
||||
getVisibleCategorizedAccounts,
|
||||
getAllFilteredAccountsBalance,
|
||||
};
|
||||
+19
-11
@@ -1,6 +1,14 @@
|
||||
import CBOR from 'cbor-js';
|
||||
import logger from './logger.js';
|
||||
import utilities from './utilities/index.js';
|
||||
import {
|
||||
isFunction,
|
||||
stringToArrayBuffer,
|
||||
arrayBufferToString,
|
||||
base64encode
|
||||
} from './common.js';
|
||||
import {
|
||||
generateRandomString
|
||||
} from './misc.js';
|
||||
|
||||
const publicKeyCredentialCreationOptionsBaseTemplate = {
|
||||
attestation: "none",
|
||||
@@ -28,7 +36,7 @@ const publicKeyCredentialRequestOptionsBaseTemplate = {
|
||||
function isSupported() {
|
||||
return !!window.PublicKeyCredential
|
||||
&& !!navigator.credentials
|
||||
&& utilities.isFunction(window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable);
|
||||
&& isFunction(window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable);
|
||||
}
|
||||
|
||||
function isCompletelySupported() {
|
||||
@@ -52,17 +60,17 @@ function registerCredential({ username, secret }, { nickname }) {
|
||||
});
|
||||
}
|
||||
|
||||
const challenge = utilities.generateRandomString();
|
||||
const challenge = generateRandomString();
|
||||
const userId = `${username}|${secret}`; // username 32bytes(max) + secret 24bytes = 56bytes(max)
|
||||
|
||||
const publicKeyCredentialCreationOptions = Object.assign({}, publicKeyCredentialCreationOptionsBaseTemplate, {
|
||||
challenge: utilities.stringToArrayBuffer(challenge),
|
||||
challenge: stringToArrayBuffer(challenge),
|
||||
rp: {
|
||||
name: window.location.hostname,
|
||||
id: window.location.hostname
|
||||
},
|
||||
user: {
|
||||
id: utilities.stringToArrayBuffer(userId),
|
||||
id: stringToArrayBuffer(userId),
|
||||
name: username,
|
||||
displayName: nickname
|
||||
}
|
||||
@@ -83,7 +91,7 @@ function registerCredential({ username, secret }, { nickname }) {
|
||||
if (rawCredential && rawCredential.rawId &&
|
||||
clientData && clientData.type === 'webauthn.create' && challengeFromClientData === challenge) {
|
||||
const ret = {
|
||||
id: utilities.base64encode(rawCredential.rawId),
|
||||
id: base64encode(rawCredential.rawId),
|
||||
clientData: clientData,
|
||||
publicKey: publicKey,
|
||||
rawCredential: rawCredential
|
||||
@@ -133,12 +141,12 @@ function verifyCredential({ username }, credentialId) {
|
||||
});
|
||||
}
|
||||
|
||||
const challenge = utilities.generateRandomString();
|
||||
const challenge = generateRandomString();
|
||||
const publicKeyCredentialRequestOptions = Object.assign({}, publicKeyCredentialRequestOptionsBaseTemplate, {
|
||||
challenge: utilities.stringToArrayBuffer(challenge),
|
||||
challenge: stringToArrayBuffer(challenge),
|
||||
rpId: window.location.hostname
|
||||
});
|
||||
publicKeyCredentialRequestOptions.allowCredentials[0].id = utilities.stringToArrayBuffer(atob(credentialId));
|
||||
publicKeyCredentialRequestOptions.allowCredentials[0].id = stringToArrayBuffer(atob(credentialId));
|
||||
|
||||
logger.debug('webauthn get options', publicKeyCredentialRequestOptions);
|
||||
|
||||
@@ -147,7 +155,7 @@ function verifyCredential({ username }, credentialId) {
|
||||
}).then(rawCredential => {
|
||||
const clientData = rawCredential ? parseClientData(rawCredential) : null;
|
||||
const challengeFromClientData = clientData && clientData.challenge ? atob(clientData.challenge) : null;
|
||||
const userIdParts = rawCredential && rawCredential.response && rawCredential.response.userHandle ? utilities.arrayBufferToString(rawCredential.response.userHandle).split('|') : null;
|
||||
const userIdParts = rawCredential && rawCredential.response && rawCredential.response.userHandle ? arrayBufferToString(rawCredential.response.userHandle).split('|') : null;
|
||||
|
||||
logger.debug('webauthn get raw response', rawCredential);
|
||||
|
||||
@@ -155,7 +163,7 @@ function verifyCredential({ username }, credentialId) {
|
||||
clientData && clientData.type === 'webauthn.get' && challengeFromClientData === challenge &&
|
||||
userIdParts && userIdParts.length === 2 && userIdParts[0] === username) {
|
||||
const ret = {
|
||||
id: utilities.base64encode(rawCredential.rawId),
|
||||
id: base64encode(rawCredential.rawId),
|
||||
userName: userIdParts[0],
|
||||
userSecret: userIdParts[1],
|
||||
clientData: clientData,
|
||||
|
||||
Reference in New Issue
Block a user