fix(v2): OTP is now only digits, v3, adding Account APP

This commit is contained in:
Josepablo C
2024-04-18 10:36:10 -06:00
parent 3819508342
commit ab98e96e8b
5 changed files with 189 additions and 39 deletions

View File

@@ -13,6 +13,8 @@ const s3Client = new S3Client({
});
const secret = apiConfig.authentication.jwtSecret;
const tokenSecret = apiConfig.authentication.tokenSecret;
/**
* Convert string to sha256 string in hex
* @param {*} text
@@ -28,12 +30,14 @@ function toSha256( text ){
* @param {*} text
* @returns
*/
function genKey( len = 6 , key="" ){
function genKey( len = 5 , key="" ){
if( len >= 64 ){
throw "invalid key len";
}
const complete_string = toSha256( key + new Date() + secret );
return complete_string.substr(0 , len );
const shacode = toSha256( key + new Date() + tokenSecret );
const otp_hex = shacode.slice(0 , len );
const otp_dec = Number.parseInt( otp_hex , 16 );
return ""+otp_dec;
}
function getPagination( query ){