Skip to content
Snippets Groups Projects
keycloak.js 91.5 KiB
Newer Older
  • Learn to ignore specific revisions
  • Elisa Giglio's avatar
    Elisa Giglio committed
    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000
    (function (global, factory) {
    	typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
    	typeof define === 'function' && define.amd ? define('keycloak', factory) :
    	(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Keycloak = factory());
    })(this, (function () { 'use strict';
    
    	var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
    
    	function commonjsRequire(path) {
    		throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
    	}
    
    	var es6Promise_min = {exports: {}};
    
    	(function (module, exports) {
    		!function(t,e){module.exports=e();}(commonjsGlobal,function(){function t(t){var e=typeof t;return null!==t&&("object"===e||"function"===e)}function e(t){return "function"==typeof t}function n(t){W=t;}function r(t){z=t;}function o(){return function(){return process.nextTick(a)}}function i(){return "undefined"!=typeof U?function(){U(a);}:c()}function s(){var t=0,e=new H(a),n=document.createTextNode("");return e.observe(n,{characterData:!0}),function(){n.data=t=++t%2;}}function u(){var t=new MessageChannel;return t.port1.onmessage=a,function(){return t.port2.postMessage(0)}}function c(){var t=setTimeout;return function(){return t(a,1)}}function a(){for(var t=0;t<N;t+=2){var e=Q[t],n=Q[t+1];e(n),Q[t]=void 0,Q[t+1]=void 0;}N=0;}function f(){try{var t=Function("return this")().require("vertx");return U=t.runOnLoop||t.runOnContext,i()}catch(e){return c()}}function l(t,e){var n=this,r=new this.constructor(v);void 0===r[V]&&x(r);var o=n._state;if(o){var i=arguments[o-1];z(function(){return T(o,r,i,n._result)});}else j(n,r,t,e);return r}function h(t){var e=this;if(t&&"object"==typeof t&&t.constructor===e)return t;var n=new e(v);return w(n,t),n}function v(){}function p(){return new TypeError("You cannot resolve a promise with itself")}function d(){return new TypeError("A promises callback cannot return that same promise.")}function _(t,e,n,r){try{t.call(e,n,r);}catch(o){return o}}function y(t,e,n){z(function(t){var r=!1,o=_(n,e,function(n){r||(r=!0,e!==n?w(t,n):A(t,n));},function(e){r||(r=!0,S(t,e));},"Settle: "+(t._label||" unknown promise"));!r&&o&&(r=!0,S(t,o));},t);}function m(t,e){e._state===Z?A(t,e._result):e._state===$?S(t,e._result):j(e,void 0,function(e){return w(t,e)},function(e){return S(t,e)});}function b(t,n,r){n.constructor===t.constructor&&r===l&&n.constructor.resolve===h?m(t,n):void 0===r?A(t,n):e(r)?y(t,n,r):A(t,n);}function w(e,n){if(e===n)S(e,p());else if(t(n)){var r=void 0;try{r=n.then;}catch(o){return void S(e,o)}b(e,n,r);}else A(e,n);}function g(t){t._onerror&&t._onerror(t._result),E(t);}function A(t,e){t._state===X&&(t._result=e,t._state=Z,0!==t._subscribers.length&&z(E,t));}function S(t,e){t._state===X&&(t._state=$,t._result=e,z(g,t));}function j(t,e,n,r){var o=t._subscribers,i=o.length;t._onerror=null,o[i]=e,o[i+Z]=n,o[i+$]=r,0===i&&t._state&&z(E,t);}function E(t){var e=t._subscribers,n=t._state;if(0!==e.length){for(var r=void 0,o=void 0,i=t._result,s=0;s<e.length;s+=3)r=e[s],o=e[s+n],r?T(n,r,o,i):o(i);t._subscribers.length=0;}}function T(t,n,r,o){var i=e(r),s=void 0,u=void 0,c=!0;if(i){try{s=r(o);}catch(a){c=!1,u=a;}if(n===s)return void S(n,d())}else s=o;n._state!==X||(i&&c?w(n,s):c===!1?S(n,u):t===Z?A(n,s):t===$&&S(n,s));}function M(t,e){try{e(function(e){w(t,e);},function(e){S(t,e);});}catch(n){S(t,n);}}function P(){return tt++}function x(t){t[V]=tt++,t._state=void 0,t._result=void 0,t._subscribers=[];}function C(){return new Error("Array Methods must be provided an Array")}function O(t){return new et(this,t).promise}function k(t){var e=this;return new e(L(t)?function(n,r){for(var o=t.length,i=0;i<o;i++)e.resolve(t[i]).then(n,r);}:function(t,e){return e(new TypeError("You must pass an array to race."))})}function F(t){var e=this,n=new e(v);return S(n,t),n}function Y(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function q(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function D(){var t=void 0;if("undefined"!=typeof commonjsGlobal)t=commonjsGlobal;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")();}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var n=t.Promise;if(n){var r=null;try{r=Object.prototype.toString.call(n.resolve());}catch(e){}if("[object Promise]"===r&&!n.cast)return}t.Promise=nt;}var K=void 0;K=Array.isArray?Array.isArray:function(t){return "[object Array]"===Object.prototype.toString.call(t)};var L=K,N=0,U=void 0,W=void 0,z=function(t,e){Q[N]=t,Q[N+1]=e,N+=2,2===N&&(W?W(a):R());},B="undefined"!=typeof window?window:void 0,G=B||{},H=G.MutationObserver||G.WebKitMutationObserver,I="undefined"==typeof self&&"undefined"!=typeof process&&"[object process]"==={}.toString.call(process),J="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,Q=new Array(1e3),R=void 0;R=I?o():H?s():J?u():void 0===B&&"function"==typeof commonjsRequire?f():c();var V=Math.random().toString(36).substring(2),X=void 0,Z=1,$=2,tt=0,et=function(){function t(t,e){this._instanceConstructor=t,this.promise=new t(v),this.promise[V]||x(this.promise),L(e)?(this.length=e.length,this._remaining=e.length,this._result=new Array(this.length),0===this.length?A(this.promise,this._result):(this.length=this.length||0,this._enumerate(e),0===this._remaining&&A(this.promise,this._result))):S(this.promise,C());}return t.prototype._enumerate=function(t){for(var e=0;this._state===X&&e<t.length;e++)this._eachEntry(t[e],e);},t.prototype._eachEntry=function(t,e){var n=this._instanceConstructor,r=n.resolve;if(r===h){var o=void 0,i=void 0,s=!1;try{o=t.then;}catch(u){s=!0,i=u;}if(o===l&&t._state!==X)this._settledAt(t._state,e,t._result);else if("function"!=typeof o)this._remaining--,this._result[e]=t;else if(n===nt){var c=new n(v);s?S(c,i):b(c,t,o),this._willSettleAt(c,e);}else this._willSettleAt(new n(function(e){return e(t)}),e);}else this._willSettleAt(r(t),e);},t.prototype._settledAt=function(t,e,n){var r=this.promise;r._state===X&&(this._remaining--,t===$?S(r,n):this._result[e]=n),0===this._remaining&&A(r,this._result);},t.prototype._willSettleAt=function(t,e){var n=this;j(t,void 0,function(t){return n._settledAt(Z,e,t)},function(t){return n._settledAt($,e,t)});},t}(),nt=function(){function t(e){this[V]=P(),this._result=this._state=void 0,this._subscribers=[],v!==e&&("function"!=typeof e&&Y(),this instanceof t?M(this,e):q());}return t.prototype["catch"]=function(t){return this.then(null,t)},t.prototype["finally"]=function(t){var n=this,r=n.constructor;return e(t)?n.then(function(e){return r.resolve(t()).then(function(){return e})},function(e){return r.resolve(t()).then(function(){throw e})}):n.then(t,t)},t}();return nt.prototype.then=l,nt.all=O,nt.race=k,nt.resolve=h,nt.reject=F,nt._setScheduler=n,nt._setAsap=r,nt._asap=z,nt.polyfill=D,nt.Promise=nt,nt});
    	} (es6Promise_min));
    
    	var base64Js = {};
    
    	base64Js.byteLength = byteLength;
    	base64Js.toByteArray = toByteArray;
    	base64Js.fromByteArray = fromByteArray;
    
    	var lookup = [];
    	var revLookup = [];
    	var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array;
    
    	var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
    	for (var i = 0, len = code.length; i < len; ++i) {
    	  lookup[i] = code[i];
    	  revLookup[code.charCodeAt(i)] = i;
    	}
    
    	// Support decoding URL-safe base64 strings, as Node.js does.
    	// See: https://en.wikipedia.org/wiki/Base64#URL_applications
    	revLookup['-'.charCodeAt(0)] = 62;
    	revLookup['_'.charCodeAt(0)] = 63;
    
    	function getLens (b64) {
    	  var len = b64.length;
    
    	  if (len % 4 > 0) {
    	    throw new Error('Invalid string. Length must be a multiple of 4')
    	  }
    
    	  // Trim off extra bytes after placeholder bytes are found
    	  // See: https://github.com/beatgammit/base64-js/issues/42
    	  var validLen = b64.indexOf('=');
    	  if (validLen === -1) validLen = len;
    
    	  var placeHoldersLen = validLen === len
    	    ? 0
    	    : 4 - (validLen % 4);
    
    	  return [validLen, placeHoldersLen]
    	}
    
    	// base64 is 4/3 + up to two characters of the original data
    	function byteLength (b64) {
    	  var lens = getLens(b64);
    	  var validLen = lens[0];
    	  var placeHoldersLen = lens[1];
    	  return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
    	}
    
    	function _byteLength (b64, validLen, placeHoldersLen) {
    	  return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
    	}
    
    	function toByteArray (b64) {
    	  var tmp;
    	  var lens = getLens(b64);
    	  var validLen = lens[0];
    	  var placeHoldersLen = lens[1];
    
    	  var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
    
    	  var curByte = 0;
    
    	  // if there are placeholders, only get up to the last complete 4 chars
    	  var len = placeHoldersLen > 0
    	    ? validLen - 4
    	    : validLen;
    
    	  var i;
    	  for (i = 0; i < len; i += 4) {
    	    tmp =
    	      (revLookup[b64.charCodeAt(i)] << 18) |
    	      (revLookup[b64.charCodeAt(i + 1)] << 12) |
    	      (revLookup[b64.charCodeAt(i + 2)] << 6) |
    	      revLookup[b64.charCodeAt(i + 3)];
    	    arr[curByte++] = (tmp >> 16) & 0xFF;
    	    arr[curByte++] = (tmp >> 8) & 0xFF;
    	    arr[curByte++] = tmp & 0xFF;
    	  }
    
    	  if (placeHoldersLen === 2) {
    	    tmp =
    	      (revLookup[b64.charCodeAt(i)] << 2) |
    	      (revLookup[b64.charCodeAt(i + 1)] >> 4);
    	    arr[curByte++] = tmp & 0xFF;
    	  }
    
    	  if (placeHoldersLen === 1) {
    	    tmp =
    	      (revLookup[b64.charCodeAt(i)] << 10) |
    	      (revLookup[b64.charCodeAt(i + 1)] << 4) |
    	      (revLookup[b64.charCodeAt(i + 2)] >> 2);
    	    arr[curByte++] = (tmp >> 8) & 0xFF;
    	    arr[curByte++] = tmp & 0xFF;
    	  }
    
    	  return arr
    	}
    
    	function tripletToBase64 (num) {
    	  return lookup[num >> 18 & 0x3F] +
    	    lookup[num >> 12 & 0x3F] +
    	    lookup[num >> 6 & 0x3F] +
    	    lookup[num & 0x3F]
    	}
    
    	function encodeChunk (uint8, start, end) {
    	  var tmp;
    	  var output = [];
    	  for (var i = start; i < end; i += 3) {
    	    tmp =
    	      ((uint8[i] << 16) & 0xFF0000) +
    	      ((uint8[i + 1] << 8) & 0xFF00) +
    	      (uint8[i + 2] & 0xFF);
    	    output.push(tripletToBase64(tmp));
    	  }
    	  return output.join('')
    	}
    
    	function fromByteArray (uint8) {
    	  var tmp;
    	  var len = uint8.length;
    	  var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
    	  var parts = [];
    	  var maxChunkLength = 16383; // must be multiple of 3
    
    	  // go through the array every three bytes, we'll deal with trailing stuff later
    	  for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
    	    parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)));
    	  }
    
    	  // pad the end with zeros, but make sure to not forget the extra bytes
    	  if (extraBytes === 1) {
    	    tmp = uint8[len - 1];
    	    parts.push(
    	      lookup[tmp >> 2] +
    	      lookup[(tmp << 4) & 0x3F] +
    	      '=='
    	    );
    	  } else if (extraBytes === 2) {
    	    tmp = (uint8[len - 2] << 8) + uint8[len - 1];
    	    parts.push(
    	      lookup[tmp >> 10] +
    	      lookup[(tmp >> 4) & 0x3F] +
    	      lookup[(tmp << 2) & 0x3F] +
    	      '='
    	    );
    	  }
    
    	  return parts.join('')
    	}
    
    	var sha256$1 = {exports: {}};
    
    	/**
    	 * [js-sha256]{@link https://github.com/emn178/js-sha256}
    	 *
    	 * @version 0.9.0
    	 * @author Chen, Yi-Cyuan [emn178@gmail.com]
    	 * @copyright Chen, Yi-Cyuan 2014-2017
    	 * @license MIT
    	 */
    
    	(function (module) {
    		/*jslint bitwise: true */
    		(function () {
    
    		  var ERROR = 'input is invalid type';
    		  var WINDOW = typeof window === 'object';
    		  var root = WINDOW ? window : {};
    		  if (root.JS_SHA256_NO_WINDOW) {
    		    WINDOW = false;
    		  }
    		  var WEB_WORKER = !WINDOW && typeof self === 'object';
    		  var NODE_JS = !root.JS_SHA256_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node;
    		  if (NODE_JS) {
    		    root = commonjsGlobal;
    		  } else if (WEB_WORKER) {
    		    root = self;
    		  }
    		  var COMMON_JS = !root.JS_SHA256_NO_COMMON_JS && 'object' === 'object' && module.exports;
    		  var ARRAY_BUFFER = !root.JS_SHA256_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined';
    		  var HEX_CHARS = '0123456789abcdef'.split('');
    		  var EXTRA = [-2147483648, 8388608, 32768, 128];
    		  var SHIFT = [24, 16, 8, 0];
    		  var K = [
    		    0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
    		    0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
    		    0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
    		    0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
    		    0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
    		    0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
    		    0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
    		    0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
    		  ];
    		  var OUTPUT_TYPES = ['hex', 'array', 'digest', 'arrayBuffer'];
    
    		  var blocks = [];
    
    		  if (root.JS_SHA256_NO_NODE_JS || !Array.isArray) {
    		    Array.isArray = function (obj) {
    		      return Object.prototype.toString.call(obj) === '[object Array]';
    		    };
    		  }
    
    		  if (ARRAY_BUFFER && (root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) {
    		    ArrayBuffer.isView = function (obj) {
    		      return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer;
    		    };
    		  }
    
    		  var createOutputMethod = function (outputType, is224) {
    		    return function (message) {
    		      return new Sha256(is224, true).update(message)[outputType]();
    		    };
    		  };
    
    		  var createMethod = function (is224) {
    		    var method = createOutputMethod('hex', is224);
    		    if (NODE_JS) {
    		      method = nodeWrap(method, is224);
    		    }
    		    method.create = function () {
    		      return new Sha256(is224);
    		    };
    		    method.update = function (message) {
    		      return method.create().update(message);
    		    };
    		    for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
    		      var type = OUTPUT_TYPES[i];
    		      method[type] = createOutputMethod(type, is224);
    		    }
    		    return method;
    		  };
    
    		  var nodeWrap = function (method, is224) {
    		    var crypto = eval("require('crypto')");
    		    var Buffer = eval("require('buffer').Buffer");
    		    var algorithm = is224 ? 'sha224' : 'sha256';
    		    var nodeMethod = function (message) {
    		      if (typeof message === 'string') {
    		        return crypto.createHash(algorithm).update(message, 'utf8').digest('hex');
    		      } else {
    		        if (message === null || message === undefined) {
    		          throw new Error(ERROR);
    		        } else if (message.constructor === ArrayBuffer) {
    		          message = new Uint8Array(message);
    		        }
    		      }
    		      if (Array.isArray(message) || ArrayBuffer.isView(message) ||
    		        message.constructor === Buffer) {
    		        return crypto.createHash(algorithm).update(new Buffer(message)).digest('hex');
    		      } else {
    		        return method(message);
    		      }
    		    };
    		    return nodeMethod;
    		  };
    
    		  var createHmacOutputMethod = function (outputType, is224) {
    		    return function (key, message) {
    		      return new HmacSha256(key, is224, true).update(message)[outputType]();
    		    };
    		  };
    
    		  var createHmacMethod = function (is224) {
    		    var method = createHmacOutputMethod('hex', is224);
    		    method.create = function (key) {
    		      return new HmacSha256(key, is224);
    		    };
    		    method.update = function (key, message) {
    		      return method.create(key).update(message);
    		    };
    		    for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
    		      var type = OUTPUT_TYPES[i];
    		      method[type] = createHmacOutputMethod(type, is224);
    		    }
    		    return method;
    		  };
    
    		  function Sha256(is224, sharedMemory) {
    		    if (sharedMemory) {
    		      blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] =
    		        blocks[4] = blocks[5] = blocks[6] = blocks[7] =
    		        blocks[8] = blocks[9] = blocks[10] = blocks[11] =
    		        blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
    		      this.blocks = blocks;
    		    } else {
    		      this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
    		    }
    
    		    if (is224) {
    		      this.h0 = 0xc1059ed8;
    		      this.h1 = 0x367cd507;
    		      this.h2 = 0x3070dd17;
    		      this.h3 = 0xf70e5939;
    		      this.h4 = 0xffc00b31;
    		      this.h5 = 0x68581511;
    		      this.h6 = 0x64f98fa7;
    		      this.h7 = 0xbefa4fa4;
    		    } else { // 256
    		      this.h0 = 0x6a09e667;
    		      this.h1 = 0xbb67ae85;
    		      this.h2 = 0x3c6ef372;
    		      this.h3 = 0xa54ff53a;
    		      this.h4 = 0x510e527f;
    		      this.h5 = 0x9b05688c;
    		      this.h6 = 0x1f83d9ab;
    		      this.h7 = 0x5be0cd19;
    		    }
    
    		    this.block = this.start = this.bytes = this.hBytes = 0;
    		    this.finalized = this.hashed = false;
    		    this.first = true;
    		    this.is224 = is224;
    		  }
    
    		  Sha256.prototype.update = function (message) {
    		    if (this.finalized) {
    		      return;
    		    }
    		    var notString, type = typeof message;
    		    if (type !== 'string') {
    		      if (type === 'object') {
    		        if (message === null) {
    		          throw new Error(ERROR);
    		        } else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) {
    		          message = new Uint8Array(message);
    		        } else if (!Array.isArray(message)) {
    		          if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) {
    		            throw new Error(ERROR);
    		          }
    		        }
    		      } else {
    		        throw new Error(ERROR);
    		      }
    		      notString = true;
    		    }
    		    var code, index = 0, i, length = message.length, blocks = this.blocks;
    
    		    while (index < length) {
    		      if (this.hashed) {
    		        this.hashed = false;
    		        blocks[0] = this.block;
    		        blocks[16] = blocks[1] = blocks[2] = blocks[3] =
    		          blocks[4] = blocks[5] = blocks[6] = blocks[7] =
    		          blocks[8] = blocks[9] = blocks[10] = blocks[11] =
    		          blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
    		      }
    
    		      if (notString) {
    		        for (i = this.start; index < length && i < 64; ++index) {
    		          blocks[i >> 2] |= message[index] << SHIFT[i++ & 3];
    		        }
    		      } else {
    		        for (i = this.start; index < length && i < 64; ++index) {
    		          code = message.charCodeAt(index);
    		          if (code < 0x80) {
    		            blocks[i >> 2] |= code << SHIFT[i++ & 3];
    		          } else if (code < 0x800) {
    		            blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3];
    		            blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
    		          } else if (code < 0xd800 || code >= 0xe000) {
    		            blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3];
    		            blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
    		            blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
    		          } else {
    		            code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));
    		            blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3];
    		            blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3];
    		            blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
    		            blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
    		          }
    		        }
    		      }
    
    		      this.lastByteIndex = i;
    		      this.bytes += i - this.start;
    		      if (i >= 64) {
    		        this.block = blocks[16];
    		        this.start = i - 64;
    		        this.hash();
    		        this.hashed = true;
    		      } else {
    		        this.start = i;
    		      }
    		    }
    		    if (this.bytes > 4294967295) {
    		      this.hBytes += this.bytes / 4294967296 << 0;
    		      this.bytes = this.bytes % 4294967296;
    		    }
    		    return this;
    		  };
    
    		  Sha256.prototype.finalize = function () {
    		    if (this.finalized) {
    		      return;
    		    }
    		    this.finalized = true;
    		    var blocks = this.blocks, i = this.lastByteIndex;
    		    blocks[16] = this.block;
    		    blocks[i >> 2] |= EXTRA[i & 3];
    		    this.block = blocks[16];
    		    if (i >= 56) {
    		      if (!this.hashed) {
    		        this.hash();
    		      }
    		      blocks[0] = this.block;
    		      blocks[16] = blocks[1] = blocks[2] = blocks[3] =
    		        blocks[4] = blocks[5] = blocks[6] = blocks[7] =
    		        blocks[8] = blocks[9] = blocks[10] = blocks[11] =
    		        blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
    		    }
    		    blocks[14] = this.hBytes << 3 | this.bytes >>> 29;
    		    blocks[15] = this.bytes << 3;
    		    this.hash();
    		  };
    
    		  Sha256.prototype.hash = function () {
    		    var a = this.h0, b = this.h1, c = this.h2, d = this.h3, e = this.h4, f = this.h5, g = this.h6,
    		      h = this.h7, blocks = this.blocks, j, s0, s1, maj, t1, t2, ch, ab, da, cd, bc;
    
    		    for (j = 16; j < 64; ++j) {
    		      // rightrotate
    		      t1 = blocks[j - 15];
    		      s0 = ((t1 >>> 7) | (t1 << 25)) ^ ((t1 >>> 18) | (t1 << 14)) ^ (t1 >>> 3);
    		      t1 = blocks[j - 2];
    		      s1 = ((t1 >>> 17) | (t1 << 15)) ^ ((t1 >>> 19) | (t1 << 13)) ^ (t1 >>> 10);
    		      blocks[j] = blocks[j - 16] + s0 + blocks[j - 7] + s1 << 0;
    		    }
    
    		    bc = b & c;
    		    for (j = 0; j < 64; j += 4) {
    		      if (this.first) {
    		        if (this.is224) {
    		          ab = 300032;
    		          t1 = blocks[0] - 1413257819;
    		          h = t1 - 150054599 << 0;
    		          d = t1 + 24177077 << 0;
    		        } else {
    		          ab = 704751109;
    		          t1 = blocks[0] - 210244248;
    		          h = t1 - 1521486534 << 0;
    		          d = t1 + 143694565 << 0;
    		        }
    		        this.first = false;
    		      } else {
    		        s0 = ((a >>> 2) | (a << 30)) ^ ((a >>> 13) | (a << 19)) ^ ((a >>> 22) | (a << 10));
    		        s1 = ((e >>> 6) | (e << 26)) ^ ((e >>> 11) | (e << 21)) ^ ((e >>> 25) | (e << 7));
    		        ab = a & b;
    		        maj = ab ^ (a & c) ^ bc;
    		        ch = (e & f) ^ (~e & g);
    		        t1 = h + s1 + ch + K[j] + blocks[j];
    		        t2 = s0 + maj;
    		        h = d + t1 << 0;
    		        d = t1 + t2 << 0;
    		      }
    		      s0 = ((d >>> 2) | (d << 30)) ^ ((d >>> 13) | (d << 19)) ^ ((d >>> 22) | (d << 10));
    		      s1 = ((h >>> 6) | (h << 26)) ^ ((h >>> 11) | (h << 21)) ^ ((h >>> 25) | (h << 7));
    		      da = d & a;
    		      maj = da ^ (d & b) ^ ab;
    		      ch = (h & e) ^ (~h & f);
    		      t1 = g + s1 + ch + K[j + 1] + blocks[j + 1];
    		      t2 = s0 + maj;
    		      g = c + t1 << 0;
    		      c = t1 + t2 << 0;
    		      s0 = ((c >>> 2) | (c << 30)) ^ ((c >>> 13) | (c << 19)) ^ ((c >>> 22) | (c << 10));
    		      s1 = ((g >>> 6) | (g << 26)) ^ ((g >>> 11) | (g << 21)) ^ ((g >>> 25) | (g << 7));
    		      cd = c & d;
    		      maj = cd ^ (c & a) ^ da;
    		      ch = (g & h) ^ (~g & e);
    		      t1 = f + s1 + ch + K[j + 2] + blocks[j + 2];
    		      t2 = s0 + maj;
    		      f = b + t1 << 0;
    		      b = t1 + t2 << 0;
    		      s0 = ((b >>> 2) | (b << 30)) ^ ((b >>> 13) | (b << 19)) ^ ((b >>> 22) | (b << 10));
    		      s1 = ((f >>> 6) | (f << 26)) ^ ((f >>> 11) | (f << 21)) ^ ((f >>> 25) | (f << 7));
    		      bc = b & c;
    		      maj = bc ^ (b & d) ^ cd;
    		      ch = (f & g) ^ (~f & h);
    		      t1 = e + s1 + ch + K[j + 3] + blocks[j + 3];
    		      t2 = s0 + maj;
    		      e = a + t1 << 0;
    		      a = t1 + t2 << 0;
    		    }
    
    		    this.h0 = this.h0 + a << 0;
    		    this.h1 = this.h1 + b << 0;
    		    this.h2 = this.h2 + c << 0;
    		    this.h3 = this.h3 + d << 0;
    		    this.h4 = this.h4 + e << 0;
    		    this.h5 = this.h5 + f << 0;
    		    this.h6 = this.h6 + g << 0;
    		    this.h7 = this.h7 + h << 0;
    		  };
    
    		  Sha256.prototype.hex = function () {
    		    this.finalize();
    
    		    var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4, h5 = this.h5,
    		      h6 = this.h6, h7 = this.h7;
    
    		    var hex = HEX_CHARS[(h0 >> 28) & 0x0F] + HEX_CHARS[(h0 >> 24) & 0x0F] +
    		      HEX_CHARS[(h0 >> 20) & 0x0F] + HEX_CHARS[(h0 >> 16) & 0x0F] +
    		      HEX_CHARS[(h0 >> 12) & 0x0F] + HEX_CHARS[(h0 >> 8) & 0x0F] +
    		      HEX_CHARS[(h0 >> 4) & 0x0F] + HEX_CHARS[h0 & 0x0F] +
    		      HEX_CHARS[(h1 >> 28) & 0x0F] + HEX_CHARS[(h1 >> 24) & 0x0F] +
    		      HEX_CHARS[(h1 >> 20) & 0x0F] + HEX_CHARS[(h1 >> 16) & 0x0F] +
    		      HEX_CHARS[(h1 >> 12) & 0x0F] + HEX_CHARS[(h1 >> 8) & 0x0F] +
    		      HEX_CHARS[(h1 >> 4) & 0x0F] + HEX_CHARS[h1 & 0x0F] +
    		      HEX_CHARS[(h2 >> 28) & 0x0F] + HEX_CHARS[(h2 >> 24) & 0x0F] +
    		      HEX_CHARS[(h2 >> 20) & 0x0F] + HEX_CHARS[(h2 >> 16) & 0x0F] +
    		      HEX_CHARS[(h2 >> 12) & 0x0F] + HEX_CHARS[(h2 >> 8) & 0x0F] +
    		      HEX_CHARS[(h2 >> 4) & 0x0F] + HEX_CHARS[h2 & 0x0F] +
    		      HEX_CHARS[(h3 >> 28) & 0x0F] + HEX_CHARS[(h3 >> 24) & 0x0F] +
    		      HEX_CHARS[(h3 >> 20) & 0x0F] + HEX_CHARS[(h3 >> 16) & 0x0F] +
    		      HEX_CHARS[(h3 >> 12) & 0x0F] + HEX_CHARS[(h3 >> 8) & 0x0F] +
    		      HEX_CHARS[(h3 >> 4) & 0x0F] + HEX_CHARS[h3 & 0x0F] +
    		      HEX_CHARS[(h4 >> 28) & 0x0F] + HEX_CHARS[(h4 >> 24) & 0x0F] +
    		      HEX_CHARS[(h4 >> 20) & 0x0F] + HEX_CHARS[(h4 >> 16) & 0x0F] +
    		      HEX_CHARS[(h4 >> 12) & 0x0F] + HEX_CHARS[(h4 >> 8) & 0x0F] +
    		      HEX_CHARS[(h4 >> 4) & 0x0F] + HEX_CHARS[h4 & 0x0F] +
    		      HEX_CHARS[(h5 >> 28) & 0x0F] + HEX_CHARS[(h5 >> 24) & 0x0F] +
    		      HEX_CHARS[(h5 >> 20) & 0x0F] + HEX_CHARS[(h5 >> 16) & 0x0F] +
    		      HEX_CHARS[(h5 >> 12) & 0x0F] + HEX_CHARS[(h5 >> 8) & 0x0F] +
    		      HEX_CHARS[(h5 >> 4) & 0x0F] + HEX_CHARS[h5 & 0x0F] +
    		      HEX_CHARS[(h6 >> 28) & 0x0F] + HEX_CHARS[(h6 >> 24) & 0x0F] +
    		      HEX_CHARS[(h6 >> 20) & 0x0F] + HEX_CHARS[(h6 >> 16) & 0x0F] +
    		      HEX_CHARS[(h6 >> 12) & 0x0F] + HEX_CHARS[(h6 >> 8) & 0x0F] +
    		      HEX_CHARS[(h6 >> 4) & 0x0F] + HEX_CHARS[h6 & 0x0F];
    		    if (!this.is224) {
    		      hex += HEX_CHARS[(h7 >> 28) & 0x0F] + HEX_CHARS[(h7 >> 24) & 0x0F] +
    		        HEX_CHARS[(h7 >> 20) & 0x0F] + HEX_CHARS[(h7 >> 16) & 0x0F] +
    		        HEX_CHARS[(h7 >> 12) & 0x0F] + HEX_CHARS[(h7 >> 8) & 0x0F] +
    		        HEX_CHARS[(h7 >> 4) & 0x0F] + HEX_CHARS[h7 & 0x0F];
    		    }
    		    return hex;
    		  };
    
    		  Sha256.prototype.toString = Sha256.prototype.hex;
    
    		  Sha256.prototype.digest = function () {
    		    this.finalize();
    
    		    var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4, h5 = this.h5,
    		      h6 = this.h6, h7 = this.h7;
    
    		    var arr = [
    		      (h0 >> 24) & 0xFF, (h0 >> 16) & 0xFF, (h0 >> 8) & 0xFF, h0 & 0xFF,
    		      (h1 >> 24) & 0xFF, (h1 >> 16) & 0xFF, (h1 >> 8) & 0xFF, h1 & 0xFF,
    		      (h2 >> 24) & 0xFF, (h2 >> 16) & 0xFF, (h2 >> 8) & 0xFF, h2 & 0xFF,
    		      (h3 >> 24) & 0xFF, (h3 >> 16) & 0xFF, (h3 >> 8) & 0xFF, h3 & 0xFF,
    		      (h4 >> 24) & 0xFF, (h4 >> 16) & 0xFF, (h4 >> 8) & 0xFF, h4 & 0xFF,
    		      (h5 >> 24) & 0xFF, (h5 >> 16) & 0xFF, (h5 >> 8) & 0xFF, h5 & 0xFF,
    		      (h6 >> 24) & 0xFF, (h6 >> 16) & 0xFF, (h6 >> 8) & 0xFF, h6 & 0xFF
    		    ];
    		    if (!this.is224) {
    		      arr.push((h7 >> 24) & 0xFF, (h7 >> 16) & 0xFF, (h7 >> 8) & 0xFF, h7 & 0xFF);
    		    }
    		    return arr;
    		  };
    
    		  Sha256.prototype.array = Sha256.prototype.digest;
    
    		  Sha256.prototype.arrayBuffer = function () {
    		    this.finalize();
    
    		    var buffer = new ArrayBuffer(this.is224 ? 28 : 32);
    		    var dataView = new DataView(buffer);
    		    dataView.setUint32(0, this.h0);
    		    dataView.setUint32(4, this.h1);
    		    dataView.setUint32(8, this.h2);
    		    dataView.setUint32(12, this.h3);
    		    dataView.setUint32(16, this.h4);
    		    dataView.setUint32(20, this.h5);
    		    dataView.setUint32(24, this.h6);
    		    if (!this.is224) {
    		      dataView.setUint32(28, this.h7);
    		    }
    		    return buffer;
    		  };
    
    		  function HmacSha256(key, is224, sharedMemory) {
    		    var i, type = typeof key;
    		    if (type === 'string') {
    		      var bytes = [], length = key.length, index = 0, code;
    		      for (i = 0; i < length; ++i) {
    		        code = key.charCodeAt(i);
    		        if (code < 0x80) {
    		          bytes[index++] = code;
    		        } else if (code < 0x800) {
    		          bytes[index++] = (0xc0 | (code >> 6));
    		          bytes[index++] = (0x80 | (code & 0x3f));
    		        } else if (code < 0xd800 || code >= 0xe000) {
    		          bytes[index++] = (0xe0 | (code >> 12));
    		          bytes[index++] = (0x80 | ((code >> 6) & 0x3f));
    		          bytes[index++] = (0x80 | (code & 0x3f));
    		        } else {
    		          code = 0x10000 + (((code & 0x3ff) << 10) | (key.charCodeAt(++i) & 0x3ff));
    		          bytes[index++] = (0xf0 | (code >> 18));
    		          bytes[index++] = (0x80 | ((code >> 12) & 0x3f));
    		          bytes[index++] = (0x80 | ((code >> 6) & 0x3f));
    		          bytes[index++] = (0x80 | (code & 0x3f));
    		        }
    		      }
    		      key = bytes;
    		    } else {
    		      if (type === 'object') {
    		        if (key === null) {
    		          throw new Error(ERROR);
    		        } else if (ARRAY_BUFFER && key.constructor === ArrayBuffer) {
    		          key = new Uint8Array(key);
    		        } else if (!Array.isArray(key)) {
    		          if (!ARRAY_BUFFER || !ArrayBuffer.isView(key)) {
    		            throw new Error(ERROR);
    		          }
    		        }
    		      } else {
    		        throw new Error(ERROR);
    		      }
    		    }
    
    		    if (key.length > 64) {
    		      key = (new Sha256(is224, true)).update(key).array();
    		    }
    
    		    var oKeyPad = [], iKeyPad = [];
    		    for (i = 0; i < 64; ++i) {
    		      var b = key[i] || 0;
    		      oKeyPad[i] = 0x5c ^ b;
    		      iKeyPad[i] = 0x36 ^ b;
    		    }
    
    		    Sha256.call(this, is224, sharedMemory);
    
    		    this.update(iKeyPad);
    		    this.oKeyPad = oKeyPad;
    		    this.inner = true;
    		    this.sharedMemory = sharedMemory;
    		  }
    		  HmacSha256.prototype = new Sha256();
    
    		  HmacSha256.prototype.finalize = function () {
    		    Sha256.prototype.finalize.call(this);
    		    if (this.inner) {
    		      this.inner = false;
    		      var innerHash = this.array();
    		      Sha256.call(this, this.is224, this.sharedMemory);
    		      this.update(this.oKeyPad);
    		      this.update(innerHash);
    		      Sha256.prototype.finalize.call(this);
    		    }
    		  };
    
    		  var exports = createMethod();
    		  exports.sha256 = exports;
    		  exports.sha224 = createMethod(true);
    		  exports.sha256.hmac = createHmacMethod();
    		  exports.sha224.hmac = createHmacMethod(true);
    
    		  if (COMMON_JS) {
    		    module.exports = exports;
    		  } else {
    		    root.sha256 = exports.sha256;
    		    root.sha224 = exports.sha224;
    		  }
    		})();
    	} (sha256$1));
    
    	var sha256 = sha256$1.exports;
    
    	if (typeof es6Promise_min.exports.Promise === 'undefined') {
    	    throw Error('Keycloak requires an environment that supports Promises. Make sure that you include the appropriate polyfill.');
    	}
    
    	var loggedPromiseDeprecation = false;
    
    	function logPromiseDeprecation() {
    	    if (!loggedPromiseDeprecation) {
    	        loggedPromiseDeprecation = true;
    	        console.warn('[KEYCLOAK] Usage of legacy style promise methods such as `.error()` and `.success()` has been deprecated and support will be removed in future versions. Use standard style promise methods such as `.then() and `.catch()` instead.');
    	    }
    	}
    
    	function Keycloak (config) {
    	    if (!(this instanceof Keycloak)) {
    	        return new Keycloak(config);
    	    }
    
    	    var kc = this;
    	    var adapter;
    	    var refreshQueue = [];
    	    var callbackStorage;
    
    	    var loginIframe = {
    	        enable: true,
    	        callbackList: [],
    	        interval: 5
    	    };
    
    	    var scripts = document.getElementsByTagName('script');
    	    for (var i = 0; i < scripts.length; i++) {
    	        if ((scripts[i].src.indexOf('keycloak.js') !== -1 || scripts[i].src.indexOf('keycloak.min.js') !== -1) && scripts[i].src.indexOf('version=') !== -1) {
    	            kc.iframeVersion = scripts[i].src.substring(scripts[i].src.indexOf('version=') + 8).split('&')[0];
    	        }
    	    }
    
    	    var useNonce = true;
    	    var logInfo = createLogger(console.info);
    	    var logWarn = createLogger(console.warn);
    
    	    kc.init = function (initOptions) {
    	        kc.authenticated = false;
    
    	        callbackStorage = createCallbackStorage();
    	        var adapters = ['default', 'cordova', 'cordova-native'];
    
    	        if (initOptions && adapters.indexOf(initOptions.adapter) > -1) {
    	            adapter = loadAdapter(initOptions.adapter);
    	        } else if (initOptions && typeof initOptions.adapter === "object") {
    	            adapter = initOptions.adapter;
    	        } else {
    	            if (window.Cordova || window.cordova) {
    	                adapter = loadAdapter('cordova');
    	            } else {
    	                adapter = loadAdapter();
    	            }
    	        }
    
    	        if (initOptions) {
    	            if (typeof initOptions.useNonce !== 'undefined') {
    	                useNonce = initOptions.useNonce;
    	            }
    
    	            if (typeof initOptions.checkLoginIframe !== 'undefined') {
    	                loginIframe.enable = initOptions.checkLoginIframe;
    	            }
    
    	            if (initOptions.checkLoginIframeInterval) {
    	                loginIframe.interval = initOptions.checkLoginIframeInterval;
    	            }
    
    	            if (initOptions.onLoad === 'login-required') {
    	                kc.loginRequired = true;
    	            }
    
    	            if (initOptions.responseMode) {
    	                if (initOptions.responseMode === 'query' || initOptions.responseMode === 'fragment') {
    	                    kc.responseMode = initOptions.responseMode;
    	                } else {
    	                    throw 'Invalid value for responseMode';
    	                }
    	            }
    
    	            if (initOptions.flow) {
    	                switch (initOptions.flow) {
    	                    case 'standard':
    	                        kc.responseType = 'code';
    	                        break;
    	                    case 'implicit':
    	                        kc.responseType = 'id_token token';
    	                        break;
    	                    case 'hybrid':
    	                        kc.responseType = 'code id_token token';
    	                        break;
    	                    default:
    	                        throw 'Invalid value for flow';
    	                }
    	                kc.flow = initOptions.flow;
    	            }
    
    	            if (initOptions.timeSkew != null) {
    	                kc.timeSkew = initOptions.timeSkew;
    	            }
    
    	            if(initOptions.redirectUri) {
    	                kc.redirectUri = initOptions.redirectUri;
    	            }
    
    	            if (initOptions.silentCheckSsoRedirectUri) {
    	                kc.silentCheckSsoRedirectUri = initOptions.silentCheckSsoRedirectUri;
    	            }
    
    	            if (typeof initOptions.silentCheckSsoFallback === 'boolean') {
    	                kc.silentCheckSsoFallback = initOptions.silentCheckSsoFallback;
    	            } else {
    	                kc.silentCheckSsoFallback = true;
    	            }
    
    	            if (initOptions.pkceMethod) {
    	                if (initOptions.pkceMethod !== "S256") {
    	                    throw 'Invalid value for pkceMethod';
    	                }
    	                kc.pkceMethod = initOptions.pkceMethod;
    	            }
    
    	            if (typeof initOptions.enableLogging === 'boolean') {
    	                kc.enableLogging = initOptions.enableLogging;
    	            } else {
    	                kc.enableLogging = false;
    	            }
    
    	            if (typeof initOptions.scope === 'string') {
    	                kc.scope = initOptions.scope;
    	            }
    
    	            if (typeof initOptions.messageReceiveTimeout === 'number' && initOptions.messageReceiveTimeout > 0) {
    	                kc.messageReceiveTimeout = initOptions.messageReceiveTimeout;
    	            } else {
    	                kc.messageReceiveTimeout = 10000;
    	            }
    	        }
    
    	        if (!kc.responseMode) {
    	            kc.responseMode = 'fragment';
    	        }
    	        if (!kc.responseType) {
    	            kc.responseType = 'code';
    	            kc.flow = 'standard';
    	        }
    
    	        var promise = createPromise();
    
    	        var initPromise = createPromise();
    	        initPromise.promise.then(function() {
    	            kc.onReady && kc.onReady(kc.authenticated);
    	            promise.setSuccess(kc.authenticated);
    	        }).catch(function(error) {
    	            promise.setError(error);
    	        });
    
    	        var configPromise = loadConfig();
    
    	        function onLoad() {
    	            var doLogin = function(prompt) {
    	                if (!prompt) {
    	                    options.prompt = 'none';
    	                }
    
    	                kc.login(options).then(function () {
    	                    initPromise.setSuccess();
    	                }).catch(function (error) {
    	                    initPromise.setError(error);
    	                });
    	            };
    
    	            var checkSsoSilently = function() {
    	                var ifrm = document.createElement("iframe");
    	                var src = kc.createLoginUrl({prompt: 'none', redirectUri: kc.silentCheckSsoRedirectUri});
    	                ifrm.setAttribute("src", src);
    	                ifrm.setAttribute("title", "keycloak-silent-check-sso");
    	                ifrm.style.display = "none";
    	                document.body.appendChild(ifrm);
    
    	                var messageCallback = function(event) {
    	                    if (event.origin !== window.location.origin || ifrm.contentWindow !== event.source) {
    	                        return;
    	                    }
    
    	                    var oauth = parseCallback(event.data);
    	                    processCallback(oauth, initPromise);
    
    	                    document.body.removeChild(ifrm);
    	                    window.removeEventListener("message", messageCallback);
    	                };
    
    	                window.addEventListener("message", messageCallback);
    	            };
    
    	            var options = {};
    	            switch (initOptions.onLoad) {
    	                case 'check-sso':
    	                    if (loginIframe.enable) {
    	                        setupCheckLoginIframe().then(function() {
    	                            checkLoginIframe().then(function (unchanged) {
    	                                if (!unchanged) {
    	                                    kc.silentCheckSsoRedirectUri ? checkSsoSilently() : doLogin(false);
    	                                } else {
    	                                    initPromise.setSuccess();
    	                                }
    	                            }).catch(function (error) {
    	                                initPromise.setError(error);
    	                            });
    	                        });
    	                    } else {
    	                        kc.silentCheckSsoRedirectUri ? checkSsoSilently() : doLogin(false);
    	                    }
    	                    break;
    	                case 'login-required':
    	                    doLogin(true);
    	                    break;
    	                default:
    	                    throw 'Invalid value for onLoad';
    	            }
    	        }
    
    	        function processInit() {
    	            var callback = parseCallback(window.location.href);
    
    	            if (callback) {
    	                window.history.replaceState(window.history.state, null, callback.newUrl);
    	            }
    
    	            if (callback && callback.valid) {
    	                return setupCheckLoginIframe().then(function() {
    	                    processCallback(callback, initPromise);
    	                }).catch(function (error) {
    	                    initPromise.setError(error);
    	                });
    	            } else if (initOptions) {
    	                if (initOptions.token && initOptions.refreshToken) {
    	                    setToken(initOptions.token, initOptions.refreshToken, initOptions.idToken);
    
    	                    if (loginIframe.enable) {
    	                        setupCheckLoginIframe().then(function() {
    	                            checkLoginIframe().then(function (unchanged) {
    	                                if (unchanged) {
    	                                    kc.onAuthSuccess && kc.onAuthSuccess();
    	                                    initPromise.setSuccess();
    	                                    scheduleCheckIframe();
    	                                } else {
    	                                    initPromise.setSuccess();
    	                                }
    	                            }).catch(function (error) {
    	                                initPromise.setError(error);
    	                            });
    	                        });
    	                    } else {
    	                        kc.updateToken(-1).then(function() {
    	                            kc.onAuthSuccess && kc.onAuthSuccess();
    	                            initPromise.setSuccess();
    	                        }).catch(function(error) {
    	                            kc.onAuthError && kc.onAuthError();
    	                            if (initOptions.onLoad) {
    	                                onLoad();
    	                            } else {
    	                                initPromise.setError(error);
    	                            }
    	                        });
    	                    }
    	                } else if (initOptions.onLoad) {
    	                    onLoad();
    	                } else {
    	                    initPromise.setSuccess();
    	                }
    	            } else {
    	                initPromise.setSuccess();
    	            }
    	        }
    
    	        function domReady() {
    	            var promise = createPromise();
    
    	            var checkReadyState = function () {
    	                if (document.readyState === 'interactive' || document.readyState === 'complete') {
    	                    document.removeEventListener('readystatechange', checkReadyState);
    	                    promise.setSuccess();
    	                }
    	            };
    	            document.addEventListener('readystatechange', checkReadyState);
    
    	            checkReadyState(); // just in case the event was already fired and we missed it (in case the init is done later than at the load time, i.e. it's done from code)
    
    	            return promise.promise;
    	        }
    
    	        configPromise.then(function () {
    	            domReady()
    	                .then(check3pCookiesSupported)
    	                .then(processInit)
    	                .catch(function (error) {
    	                    promise.setError(error);
    	                });
    	        });
    	        configPromise.catch(function (error) {
    	            promise.setError(error);
    	        });
    
    	        return promise.promise;
    	    };
    
    	    kc.login = function (options) {
    	        return adapter.login(options);