)
arrayID += 1
}
+ // Max size of OTPAuth select-option fetcher
+ let optMax = 6
+ // Set the size of OTPAuth select-option fetcher
+ secretopt.size = selectArray.length<=optMax ? selectArray.length : optMax
// Select option already built, Get the token
checkArray()
};
@@ -802,6 +806,7 @@
Custom OTPAuth Source
let option = document.createElement("option")
option.value = value
option.text = text
+ if(value==0) option.selected = true
// let select = document.getElementById("selectid")
select.appendChild(option)
/*
diff --git a/index.js b/index.js
index 047e0f5..5bd57bc 100644
--- a/index.js
+++ b/index.js
@@ -269,6 +269,10 @@ window.addEventListener("load", function () {
)
arrayID += 1
}
+ // Max size of OTPAuth select-option fetcher
+ let optMax = 6
+ // Set the size of OTPAuth select-option fetcher
+ secretopt.size = selectArray.length<=optMax ? selectArray.length : optMax
// Select option already built, Get the token
checkArray()
};
@@ -308,6 +312,7 @@ window.addEventListener("load", function () {
let option = document.createElement("option")
option.value = value
option.text = text
+ if(value==0) option.selected = true
// let select = document.getElementById("selectid")
select.appendChild(option)
/*
diff --git a/index.min.html b/index.min.html
index df3cc66..6c690ed 100644
--- a/index.min.html
+++ b/index.min.html
@@ -299,7 +299,7 @@
Custom OTPAuth Source
This is a modified version by A99US (https://github.com/A99US/totp-js)
*/
"use strict";var Convert=Convert||{};Convert.base32toHex=function(t){if("string"!=typeof t)throw new Error("Argument to base32toHex() is not a string");if(0===t.length)throw new Error("Argument to base32toHex() is empty");if(!t.match(/^[A-Z2-7]+=*$/i))throw new Error("Argument to base32toHex() contains invalid characters");var r="",e="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".split(""),n=(t.toUpperCase()+"========").match(/.{1,8}/g);n.pop();var o=n[n.length-1].match(/=*$/)[0].length;if(o>6)throw new Error("Invalid base32 data (too much padding)");for(var a=0;a10||!a(r))throw new Error("Invalid size value (default is 6)");if(!1!==n){if("number"!=typeof n||!a(n))throw new Error("Invalid interval value");e+=TOTP.getCurrentCounter(n)}let u=await TOTP.hmac(t,"00000000"+Convert.int32toHex(e),o),i=parseInt(u.substr(-1),16),s=2147483647&parseInt(u.substr(2*i,8),16);return s=("0000000000"+s%Math.pow(10,r)).substr(-r),o&&console.debug("Token",s),s},hmac:async function(t,r,e){var n={name:"HMAC",hash:"SHA-1"},o=Uint8Array.from(Convert.hexToArray(t)),a=Uint8Array.from(Convert.hexToArray(r));let u=await crypto.subtle.importKey("raw",o,n,!1,["sign","verify"]);return e&&console.debug("Key imported",t),u=await crypto.subtle.sign(n,u,a),u=Convert.arrayToHex(u),e&&console.debug("HMAC calculated",a,u),u},isCompatible:function(){var t=function(r){return typeof r==typeof t};return typeof crypto==typeof TOTP&&typeof Uint8Array==typeof t&&!!(crypto.subtle&&t(crypto.subtle.importKey)&&t(crypto.subtle.sign)&&t(crypto.subtle.digest))}};if(typeof Convert!=typeof TOTP)throw TOTP=null,alert("Data conversion module not loaded"),new Error("Data conversion module not loaded");
-"use strict";window.addEventListener("load",(function(){var e=document.querySelector.bind(document),t=document.querySelectorAll.bind(document),n=e("#getTokenSingle"),r=e("#getTokenArray"),o=e("#token"),a=e("#digits"),i=e("#enctype"),s=e("#interval"),l=e("#otpauthSource"),c=e("#secretopt");l.innerHTML="undefined"!=typeof otpauthsource?otpauthsource:"otpauth://totp?secret=CCDDBBAA333666\notpauth://totp/Example.Com:XMPLUser?secret=ABBCCDD2345&issuer=Example.Com\notpauth://totp/GitServer:Dev123?secret=CCBBDDAA5432&issuer=GitServer&digit=7&period=5";var d={1:{regex:"[A-Za-z2-7]+=*",title:"Secret should be Base32 encoded (using only a-z and 2-7)"},2:{regex:"([A-Fa-f0-9]{2})*",title:"Hexadecimal only (0-9 and a-f, even number of characters)"}},u=function(e,t,n){return 0|Math.max(Math.min(0|t,n),e)},p=function(e){return!e.reportValidity||e.reportValidity()},y=function(){if(p(o)&&p(a)&&p(i)){clearTimeout(g.single);var t=u(6,+a.value,8);let r=s.value;var n=o.value;if("1"===i.value){try{n=Convert.base32toHex(n)}catch(e){return void alert("Invalid Base32 characters")}!function(e,t,n,r){location.hash="#"+JSON.stringify({c:e,m:t,d:n,p:r})}(o.value,+i.value,t,r),e("#codes").style.display="block",v({secret:n,digits:t,period:parseInt(r),type:"single",init:!0,target:{time:".time",token:[["#totpPP",-2],["#totpP",-1],["#totpC",0],["#totpN",1]],countdown:[".counter","s"]}})}}},g={single:null,array:null},v=async function(t){try{if(t.debug&&console.debug("Getting TOTP for",t.secret),t.init||t.countdown==t.period){let n=TOTP.getCurrentCounter(t.period);t.countdown=TOTP.getCountdown(t.period);let r=0;for(e(t.target.time).textContent=(new Date).toLocaleTimeString();t.target.token[r];)e(t.target.token[r][0]).textContent=await TOTP.otp(t.secret,t.digits,n+t.target.token[r][1]),r+=1;t.init=!1}e(t.target.countdown[0]).textContent=t.countdown+(t.target.countdown[1]||""),t.countdown=1==t.countdown?t.period:t.countdown-1,g[t.type]=setTimeout((async()=>{await v(t)}),1e3)}catch(t){e("#codes").style.display="none",console.error(t),alert("Problem decoding Secret.\nVerify your secret and type are correct.\nMessage from decoder: "+t.message)}},m=[],h=async function(){if(c.options.length<1)return;clearTimeout(g.array);let t=m[c.value];t.init=!0;let n=(e,t="")=>""+t,r=(e,t)=>"