update jslib to support modules

This commit is contained in:
Kyle Spearrin 2018-06-08 10:11:28 -04:00
parent bfaebb6b92
commit 8a1bc30fc9
1 changed files with 25 additions and 13 deletions

View File

@ -3,16 +3,28 @@
* Copyright 2017, Duo Security * Copyright 2017, Duo Security
*/ */
var Duo;
(function (root, factory) { (function (root, factory) {
// Browser globals (root is window) /*eslint-disable */
var d = factory(); if (typeof define === 'function' && define.amd) {
// If the Javascript was loaded via a script tag, attempt to autoload // AMD. Register as an anonymous module.
// the frame. define([], factory);
d._onReady(d.init); /*eslint-enable */
// Attach Duo to the `window` object } else if (typeof module === 'object' && module.exports) {
root.Duo = Duo = d; // Node. Does not work with strict CommonJS, but
}(window, function () { // only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory();
} else {
// Browser globals (root is window)
var Duo = factory();
// If the Javascript was loaded via a script tag, attempt to autoload
// the frame.
Duo._onReady(Duo.init);
// Attach Duo to the `window` object
root.Duo = Duo;
}
}(this, function() {
var DUO_MESSAGE_FORMAT = /^(?:AUTH|ENROLL)+\|[A-Za-z0-9\+\/=]+\|[A-Za-z0-9\+\/=]+$/; var DUO_MESSAGE_FORMAT = /^(?:AUTH|ENROLL)+\|[A-Za-z0-9\+\/=]+\|[A-Za-z0-9\+\/=]+$/;
var DUO_ERROR_FORMAT = /^ERR\|[\w\s\.\(\)]+$/; var DUO_ERROR_FORMAT = /^ERR\|[\w\s\.\(\)]+$/;
var DUO_OPEN_WINDOW_FORMAT = /^DUO_OPEN_WINDOW\|/; var DUO_OPEN_WINDOW_FORMAT = /^DUO_OPEN_WINDOW\|/;
@ -311,10 +323,10 @@ var Duo;
} }
for (var i = 0; i < VALID_OPEN_WINDOW_DOMAINS.length; i++) { for (var i = 0; i < VALID_OPEN_WINDOW_DOMAINS.length; i++) {
if (parser.hostname.endsWith("." + VALID_OPEN_WINDOW_DOMAINS[i]) || if (parser.hostname.endsWith("." + VALID_OPEN_WINDOW_DOMAINS[i]) ||
parser.hostname === VALID_OPEN_WINDOW_DOMAINS[i]) { parser.hostname === VALID_OPEN_WINDOW_DOMAINS[i]) {
return true; return true;
} }
} }
return false; return false;
} }