fix(v2): OTP is now only digits, v3, adding Account APP
This commit is contained in:
@@ -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 ){
|
||||
|
||||
Reference in New Issue
Block a user