conditionally load forge
This commit is contained in:
parent
579250c5a8
commit
06317d1812
|
@ -5,7 +5,14 @@ var Authenticator = exports.Authenticator || exports;
|
||||||
var Unibabel = window.Unibabel; // || require('unibabel');
|
var Unibabel = window.Unibabel; // || require('unibabel');
|
||||||
var totp = window.totp; // || require('notp').totp;
|
var totp = window.totp; // || require('notp').totp;
|
||||||
|
|
||||||
if (!window.crypto) {
|
function loadForge() {
|
||||||
|
var script = document.createElement('script');
|
||||||
|
script.src = 'demo/bower_components/forge/dist/forge.min.js';
|
||||||
|
script.addEventListener('load', collectRandom);
|
||||||
|
document.body.appendChild(script);
|
||||||
|
}
|
||||||
|
|
||||||
|
function collectRandom() {
|
||||||
document.addEventListener('mousemove', function (event) {
|
document.addEventListener('mousemove', function (event) {
|
||||||
var ev = event || window.event;
|
var ev = event || window.event;
|
||||||
|
|
||||||
|
@ -14,6 +21,14 @@ if (!window.crypto) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!window.crypto) {
|
||||||
|
if (!window.forge) {
|
||||||
|
loadForge();
|
||||||
|
} else {
|
||||||
|
collectRandom();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Generate a key
|
// Generate a key
|
||||||
function generateOtpKey() {
|
function generateOtpKey() {
|
||||||
// 20 cryptographically random binary bytes (160-bit key)
|
// 20 cryptographically random binary bytes (160-bit key)
|
||||||
|
|
|
@ -93,7 +93,9 @@
|
||||||
<script src="demo/bower_components/unibabel/unibabel.base32.js"></script>
|
<script src="demo/bower_components/unibabel/unibabel.base32.js"></script>
|
||||||
|
|
||||||
<!-- forge.* -->
|
<!-- forge.* -->
|
||||||
|
<!--[if lt IE 11]>
|
||||||
<script src="demo/bower_components/forge/dist/forge.min.js"></script>
|
<script src="demo/bower_components/forge/dist/forge.min.js"></script>
|
||||||
|
<![endif]-->
|
||||||
|
|
||||||
<!-- botp.totp -->
|
<!-- botp.totp -->
|
||||||
<script src="demo/bower_components/botp/sha1-hmac.js"></script>
|
<script src="demo/bower_components/botp/sha1-hmac.js"></script>
|
||||||
|
|
Loading…
Reference in New Issue