diff --git a/base64url/index.js b/base64url/index.js index f98d466..b53b196 100644 --- a/base64url/index.js +++ b/base64url/index.js @@ -12,11 +12,12 @@ * * @returns base64url {String} : a base64url encoded string */ -const encodeBase64URL = (dataStr) => { - let base64 = window.btoa(dataStr); - let base64url = base64.split('=')[0]; // Remove any trailing '='s +var encodeBase64URL = function encodeBase64URL(dataStr) { + var base64 = window.btoa(dataStr); + var base64url = base64.split('=')[0]; // Remove any trailing '='s base64url = base64url.replace(/\+/g, '-'); // 62nd char of encoding + base64url = base64url.replace(/\//g, '_'); // 63rd char of encoding return base64url; @@ -35,22 +36,33 @@ const encodeBase64URL = (dataStr) => { * * @returns {String} - a regular string */ -const decodeBase64URL = (str) => { - let base64 = str; +var decodeBase64URL = function decodeBase64URL(str) { + var base64 = str; base64 = base64.replace(/-/g, '+'); // 62nd char of encoding + base64 = base64.replace(/_/g, '/'); // 63rd char of encoding - switch (base64.length % 4) // Pad with trailing '='s - { + + switch (base64.length % 4) { + // Pad with trailing '='s case 0: - break; // No pad chars in this case + break; + // No pad chars in this case + case 2: - base64 += "=="; break; // Two pad chars + base64 += "=="; + break; + // Two pad chars + case 3: - base64 += "="; break; // One pad char + base64 += "="; + break; + // One pad char + default: - if(window.console && window.console.log){ + if (window.console && window.console.log) { window.console.log('### base64url::decodeBase64URL:: Illegal base64url string!'); } + } try { @@ -60,8 +72,8 @@ const decodeBase64URL = (str) => { } }; -const base64URL = { - encode : encodeBase64URL, +var base64URL = { + encode: encodeBase64URL, decode: decodeBase64URL }; diff --git a/browser/index.js b/browser/index.js index 89915cc..7dbcf9c 100644 --- a/browser/index.js +++ b/browser/index.js @@ -9,34 +9,29 @@ * * @returns {Object} - browserInfo an object containing the retrieved browser properties */ -const collectBrowserInfo = () => { +var collectBrowserInfo = function collectBrowserInfo() { + var screenWidth = window && window.screen ? window.screen.width : ''; + var screenHeight = window && window.screen ? window.screen.height : ''; + var colorDepth = window && window.screen ? window.screen.colorDepth : ''; + var userAgent = window && window.navigator ? window.navigator.userAgent : ''; + var javaEnabled = window && window.navigator ? navigator.javaEnabled() : false; + var language = ''; - const screenWidth = window && window.screen ? window.screen.width : ''; - const screenHeight = window && window.screen ? window.screen.height : ''; - const colorDepth = window && window.screen ? window.screen.colorDepth : ''; - const userAgent = window && window.navigator ? window.navigator.userAgent : ''; - const javaEnabled = window && window.navigator ? navigator.javaEnabled() : false; - - let language = ''; if (window && window.navigator) { - language = window.navigator.language - ? window.navigator.language - : window.navigator.browserLanguage; // Else is for IE <+ 10 + language = window.navigator.language ? window.navigator.language : window.navigator.browserLanguage; // Else is for IE <+ 10 } - const d = new Date(); - const timeZoneOffset = d.getTimezoneOffset(); - - const browserInfo = { - screenWidth, - screenHeight, - colorDepth, - userAgent, - timeZoneOffset, - language, - javaEnabled, + var d = new Date(); + var timeZoneOffset = d.getTimezoneOffset(); + var browserInfo = { + screenWidth: screenWidth, + screenHeight: screenHeight, + colorDepth: colorDepth, + userAgent: userAgent, + timeZoneOffset: timeZoneOffset, + language: language, + javaEnabled: javaEnabled }; - return browserInfo; }; diff --git a/dist/threeds2-js-utils.js b/dist/threeds2-js-utils.js index 939262a..1da1f4b 100644 --- a/dist/threeds2-js-utils.js +++ b/dist/threeds2-js-utils.js @@ -1 +1 @@ -!function(e,n){"object"===typeof exports&&"object"===typeof module?module.exports=n():"function"===typeof define&&define.amd?define([],n):"object"===typeof exports?exports.ThreedDS2Utils=n():e.ThreedDS2Utils=n()}(this,function(){return function(e){var n={};function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"===typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)t.d(r,o,function(n){return e[n]}.bind(null,o));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=0)}([function(e,n,t){"use strict";t.r(n);var r={container:void 0},o={"01":["250px","400px"],"02":["390px","400px"],"03":["500px","600px"],"04":["600px","400px"],"05":["100%","100%"]};function a(e){return o.hasOwnProperty(e)?e:"01"}var i={createIframe:function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"0",o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"0",a=arguments.length>4?arguments[4]:void 0;if(!n||0===n.length)throw new Error("Name parameter missing for iframe");e instanceof HTMLElement?r.container=e:r.container=document.body;var i=document.createElement("iframe");i.classList.add(n+"Class"),i.width=t,i.height=o,i.name=n,i.setAttribute("frameborder","0"),i.setAttribute("border","0");var d=document.createTextNode("
Your browser does not support iframes.
");return i.appendChild(d),r.container.appendChild(i),function(e,n){e.attachEvent?e.attachEvent("onload",function(){n&&"function"===typeof n&&n(e.contentWindow)}):e.onload=function(){n&&"function"===typeof n&&n(e.contentWindow)}}(i,a),i},createForm:function(e,n,t,r,o){if(!e||!n||!t||!r||!o)throw new Error("Not all required parameters provided for form creation");if(0===e.length||0===n.length||0===t.length||0===r.length||0===o.length)throw new Error("Not all required parameters have suitable values");var a=document.createElement("form");a.style.display="none",a.name=e,a.action=n,a.method="POST",a.target=t;var i=document.createElement("input");return i.name=r,i.value=o,a.appendChild(i),a},getBrowserInfo:function(){var e=window&&window.screen?window.screen.width:"",n=window&&window.screen?window.screen.height:"",t=window&&window.screen?window.screen.colorDepth:"",r=window&&window.navigator?window.navigator.userAgent:"",o=!(!window||!window.navigator)&&navigator.javaEnabled(),a="";return window&&window.navigator&&(a=window.navigator.language?window.navigator.language:window.navigator.browserLanguage),{screenWidth:e,screenHeight:n,colorDepth:t,userAgent:r,timeZoneOffset:(new Date).getTimezoneOffset(),language:a,javaEnabled:o}},base64Url:{encode:function(e){var n=window.btoa(e).split("=")[0];return n=(n=n.replace("/+/g","-")).replace("///g","_")},decode:function(e){var n=e;switch((n=(n=n.replace("/-/g","+")).replace("/_/g","/")).length%4){case 0:break;case 2:n+="==";break;case 3:n+="=";break;default:window.console&&window.console.log&&window.console.log("### base64url::decodeBase64URL:: Illegal base64url string!")}try{return window.atob(n)}catch(e){throw new Error(e)}}},config:{challengeWindowSizes:o,validateChallengeWindowSize:a,getChallengeWindowSize:function(e){return o[a(e)]},THREEDS_METHOD_TIMEOUT:1e4,CHALLENGE_TIMEOUT:6e5}};n.default=i}]).default}); \ No newline at end of file +!function(e,n){"object"===typeof exports&&"object"===typeof module?module.exports=n():"function"===typeof define&&define.amd?define([],n):"object"===typeof exports?exports.ThreedDS2Utils=n():e.ThreedDS2Utils=n()}(this,function(){return function(e){var n={};function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"===typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)t.d(r,o,function(n){return e[n]}.bind(null,o));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=0)}([function(e,n,t){"use strict";t.r(n);var r={container:void 0},o={"01":["250px","400px"],"02":["390px","400px"],"03":["500px","600px"],"04":["600px","400px"],"05":["100%","100%"]};function a(e){var n=1===e.length?"0".concat(e):e;return o.hasOwnProperty(n)?n:"01"}var i={createIframe:function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"0",o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"0",a=arguments.length>4?arguments[4]:void 0;if(!n||0===n.length)throw new Error("Name parameter missing for iframe");e instanceof HTMLElement?r.container=e:r.container=document.body;var i=document.createElement("iframe");i.classList.add(n+"Class"),i.width=t,i.height=o,i.name=n,i.setAttribute("frameborder","0"),i.setAttribute("border","0");var d=document.createTextNode("Your browser does not support iframes.
");return i.appendChild(d),r.container.appendChild(i),function(e,n){e.attachEvent?e.attachEvent("onload",function(){n&&"function"===typeof n&&n(e.contentWindow)}):e.onload=function(){n&&"function"===typeof n&&n(e.contentWindow)}}(i,a),i},createForm:function(e,n,t,r,o){if(!e||!n||!t||!r||!o)throw new Error("Not all required parameters provided for form creation");if(0===e.length||0===n.length||0===t.length||0===r.length||0===o.length)throw new Error("Not all required parameters have suitable values");var a=document.createElement("form");a.style.display="none",a.name=e,a.action=n,a.method="POST",a.target=t;var i=document.createElement("input");return i.name=r,i.value=o,a.appendChild(i),a},getBrowserInfo:function(){var e=window&&window.screen?window.screen.width:"",n=window&&window.screen?window.screen.height:"",t=window&&window.screen?window.screen.colorDepth:"",r=window&&window.navigator?window.navigator.userAgent:"",o=!(!window||!window.navigator)&&navigator.javaEnabled(),a="";return window&&window.navigator&&(a=window.navigator.language?window.navigator.language:window.navigator.browserLanguage),{screenWidth:e,screenHeight:n,colorDepth:t,userAgent:r,timeZoneOffset:(new Date).getTimezoneOffset(),language:a,javaEnabled:o}},base64Url:{encode:function(e){var n=window.btoa(e).split("=")[0];return n=(n=n.replace(/\+/g,"-")).replace(/\//g,"_")},decode:function(e){var n=e;switch((n=(n=n.replace(/-/g,"+")).replace(/_/g,"/")).length%4){case 0:break;case 2:n+="==";break;case 3:n+="=";break;default:window.console&&window.console.log&&window.console.log("### base64url::decodeBase64URL:: Illegal base64url string!")}try{return window.atob(n)}catch(e){throw new Error(e)}}},config:{challengeWindowSizes:o,validateChallengeWindowSize:a,getChallengeWindowSize:function(e){return o[a(e)]},THREEDS_METHOD_TIMEOUT:1e4,CHALLENGE_TIMEOUT:6e5}};n.default=i}]).default}); \ No newline at end of file diff --git a/form/index.js b/form/index.js index 2e1541d..54d93c2 100644 --- a/form/index.js +++ b/form/index.js @@ -11,8 +11,7 @@ * * @returns {Element} - Created form element */ -const createForm = (name, action, target, inputName, inputValue) => { - +var createForm = function createForm(name, action, target, inputName, inputValue) { if (!name || !action || !target || !inputName || !inputValue) { throw new Error('Not all required parameters provided for form creation'); } @@ -21,16 +20,16 @@ const createForm = (name, action, target, inputName, inputValue) => { throw new Error('Not all required parameters have suitable values'); } - const form = document.createElement( 'form' ); + var form = document.createElement('form'); form.style.display = 'none'; form.name = name; form.action = action; - form.method = "POST"; + form.method = 'POST'; form.target = target; - const input = document.createElement( 'input' ); + var input = document.createElement('input'); input.name = inputName; input.value = inputValue; - form.appendChild( input ); + form.appendChild(input); return form; }; diff --git a/iframe/index.js b/iframe/index.js index 0591787..71bff76 100644 --- a/iframe/index.js +++ b/iframe/index.js @@ -1,16 +1,16 @@ -const configObject = {}; +var configObject = {}; configObject.container = void 0; -const addIframeListener = (iframe, callback) => { - if (iframe.attachEvent){ +var addIframeListener = function addIframeListener(iframe, callback) { + if (iframe.attachEvent) { // IE fallback - iframe.attachEvent("onload", function(){ + iframe.attachEvent("onload", function () { if (callback && typeof callback === "function") { callback(iframe.contentWindow); } }); } else { - iframe.onload = function(){ + iframe.onload = function () { if (callback && typeof callback === "function") { callback(iframe.contentWindow); } @@ -31,34 +31,33 @@ const addIframeListener = (iframe, callback) => { * * @returns {Element} - Created iframe element */ -const createIframe = (container, name, width = '0', height = '0', callback) => { - if (!name || name.length === 0){ +var createIframe = function createIframe(container, name) { + var width = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '0'; + var height = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '0'; + var callback = arguments.length > 4 ? arguments[4] : undefined; + + if (!name || name.length === 0) { throw new Error('Name parameter missing for iframe'); - } + } // Resolve holding element for generated iframe else default to body + - // Resolve holding element for generated iframe else default to body if (container instanceof HTMLElement) { configObject.container = container; } else { configObject.container = document.body; } - const iframe = document.createElement('iframe'); - + var iframe = document.createElement('iframe'); iframe.classList.add(name + 'Class'); iframe.width = width; iframe.height = height; iframe.name = name; iframe.setAttribute('frameborder', '0'); iframe.setAttribute('border', '0'); - - const noIframeElContent = document.createTextNode('Your browser does not support iframes.
'); + var noIframeElContent = document.createTextNode('Your browser does not support iframes.
'); iframe.appendChild(noIframeElContent); - configObject.container.appendChild(iframe); - addIframeListener(iframe, callback); - return iframe; };