From 3abba5338e2b4cdbf8acd574e924e45338556ed6 Mon Sep 17 00:00:00 2001 From: Tobias Speicher Date: Thu, 24 Mar 2022 16:54:21 +0100 Subject: Replace deprecated String.prototype.substr() .substr() is deprecated so we replace it with .slice() which works similarily but isn't deprecated Signed-off-by: Tobias Speicher --- js/app/directives/otp.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'js/app') diff --git a/js/app/directives/otp.js b/js/app/directives/otp.js index 69e5b608..cfcc40ce 100644 --- a/js/app/directives/otp.js +++ b/js/app/directives/otp.js @@ -54,7 +54,7 @@ } for (i = 0; i + 4 <= bits.length; i += 4) { - var chunk = bits.substr(i, 4); + var chunk = bits.slice(i, i + 4); hex = hex + parseInt(chunk, 2).toString(16); } return hex.length % 2 ? hex + "0" : hex; @@ -91,8 +91,8 @@ var hmacObj = new jsSHA(time, 'HEX'); var hmac = hmacObj.getHMAC(key, 'HEX', 'SHA-1', "HEX"); var offset = hex2dec(hmac.substring(hmac.length - 1)); - var otp = (hex2dec(hmac.substr(offset * 2, 8)) & hex2dec('7fffffff')) + ''; - otp = (otp).substr(otp.length - 6, 6); + var otp = (hex2dec(hmac.slice(offset * 2, offset * 2 + 8)) & hex2dec('7fffffff')) + ''; + otp = (otp).slice(-6); scope.otp = otp; }; -- cgit v1.2.3