@livechat/accounts-sdk 2.0.3 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accounts-sdk.js +555 -1169
- package/dist/accounts-sdk.js.map +1 -1
- package/dist/accounts-sdk.min.js +4 -4
- package/dist/accounts-sdk.min.js.map +1 -1
- package/dist/index.cjs.js +666 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +665 -1
- package/dist/index.esm.js.map +1 -1
- package/package.json +2 -3
- package/readme.md +38 -21
package/dist/accounts-sdk.min.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("crypto")):"function"==typeof define&&define.amd?define(["crypto"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).AccountsSDK=e(t.crypto)}(this,(function(t){"use strict";function e(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var r=e(t);function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function a(t,e,r){return e&&o(t.prototype,e),r&&o(t,r),t}var c={extend:function(t){return t.oauth_exception&&this.oauth_exception[t.oauth_exception]?Object.assign(t,{description:this.oauth_exception[t.oauth_exception]}):t.identity_exception&&this.identity_exception[t.identity_exception]?Object.assign(t,{description:this.identity_exception[t.identity_exception]}):t},oauth_exception:{invalid_request:"You may be loading accounts-sdk on a domain that is not whitelisted.",unauthorized_client:"Client not found, not provided or incorectly configured.",access_denied:"Probably this application is installed on a different account and you do not have access to it.",unsupported_response_type:"Provided response type is incorrect or unavailable for a given client."},identity_exception:{unauthorized:"Resource owner identity is not known or consent is missing."}},s=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i(this,t),this.options=e,this.listening=!1,this.receiveMessage=this.receiveMessage.bind(this)}return a(t,[{key:"start",value:function(t,e){var r=this;this._listenerInited||(this.listening=!0,this.callback=e,t&&(this.tid=setTimeout((function(){r.stop(),e("timeout",null)}),t)),window.addEventListener("message",this.receiveMessage))}},{key:"stop",value:function(){this.listening=!1,clearTimeout(this.tid),window.removeEventListener("message",this.receiveMessage,!1)}},{key:"receiveMessage",value:function(t){t.origin!==this.options.server_url&&t.origin!==this.options.server_url.replace(/livechat\.com$/,"livechatinc.com")||(t.data.data||t.data.error)&&(this.stop(),t.data.error?this.callback(c.extend(t.data.error),null):(t.data.data.scopes&&(t.data.data.scope=t.data.data.scopes,delete t.data.data.scopes),t.data.data.expires_in&&(t.data.data.expires_in=parseInt(t.data.data.expires_in)||0),this.callback(null,t.data.data)))}}]),t}(),l=function(){function t(e,r){i(this,t),this.options=r,this.sdk=e}return a(t,[{key:"authorize",value:function(){var t=this;return new Promise((function(e,r){var n=t.sdk.authorizeURL(t.options,"button"),i=window.screen.width/2-250,o=window.screen.height/2-325;new s(t.options).start(null,(function(t,n){if(t)return r(t);e(n)}));var a=function(){window.open(n,"livechat-login-popup","resizable,scrollbars,width=".concat(500,",height=").concat(650,",left=").concat(i,",top=").concat(o))};document.requestStorageAccess?document.requestStorageAccess().then(a,a):a()}))}}]),t}(),u=Object.prototype.hasOwnProperty,h=Array.isArray,f=function(){for(var t=[],e=0;e<256;++e)t.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return t}(),d=function(t,e){for(var r=e&&e.plainObjects?Object.create(null):{},n=0;n<t.length;++n)void 0!==t[n]&&(r[n]=t[n]);return r},p={arrayToObject:d,assign:function(t,e){return Object.keys(e).reduce((function(t,r){return t[r]=e[r],t}),t)},combine:function(t,e){return[].concat(t,e)},compact:function(t){for(var e=[{obj:{o:t},prop:"o"}],r=[],i=0;i<e.length;++i)for(var o=e[i],a=o.obj[o.prop],c=Object.keys(a),s=0;s<c.length;++s){var l=c[s],u=a[l];"object"===n(u)&&null!==u&&-1===r.indexOf(u)&&(e.push({obj:a,prop:l}),r.push(u))}return function(t){for(;t.length>1;){var e=t.pop(),r=e.obj[e.prop];if(h(r)){for(var n=[],i=0;i<r.length;++i)void 0!==r[i]&&n.push(r[i]);e.obj[e.prop]=n}}}(e),t},decode:function(t,e,r){var n=t.replace(/\+/g," ");if("iso-8859-1"===r)return n.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(n)}catch(t){return n}},encode:function(t,e,r){if(0===t.length)return t;var i=t;if("symbol"===n(t)?i=Symbol.prototype.toString.call(t):"string"!=typeof t&&(i=String(t)),"iso-8859-1"===r)return escape(i).replace(/%u[0-9a-f]{4}/gi,(function(t){return"%26%23"+parseInt(t.slice(2),16)+"%3B"}));for(var o="",a=0;a<i.length;++a){var c=i.charCodeAt(a);45===c||46===c||95===c||126===c||c>=48&&c<=57||c>=65&&c<=90||c>=97&&c<=122?o+=i.charAt(a):c<128?o+=f[c]:c<2048?o+=f[192|c>>6]+f[128|63&c]:c<55296||c>=57344?o+=f[224|c>>12]+f[128|c>>6&63]+f[128|63&c]:(a+=1,c=65536+((1023&c)<<10|1023&i.charCodeAt(a)),o+=f[240|c>>18]+f[128|c>>12&63]+f[128|c>>6&63]+f[128|63&c])}return o},isBuffer:function(t){return!(!t||"object"!==n(t))&&!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},isRegExp:function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},maybeMap:function(t,e){if(h(t)){for(var r=[],n=0;n<t.length;n+=1)r.push(e(t[n]));return r}return e(t)},merge:function t(e,r,i){if(!r)return e;if("object"!==n(r)){if(h(e))e.push(r);else{if(!e||"object"!==n(e))return[e,r];(i&&(i.plainObjects||i.allowPrototypes)||!u.call(Object.prototype,r))&&(e[r]=!0)}return e}if(!e||"object"!==n(e))return[e].concat(r);var o=e;return h(e)&&!h(r)&&(o=d(e,i)),h(e)&&h(r)?(r.forEach((function(r,o){if(u.call(e,o)){var a=e[o];a&&"object"===n(a)&&r&&"object"===n(r)?e[o]=t(a,r,i):e.push(r)}else e[o]=r})),e):Object.keys(r).reduce((function(e,n){var o=r[n];return u.call(e,n)?e[n]=t(e[n],o,i):e[n]=o,e}),o)}},m=String.prototype.replace,y=/%20/g,g={RFC1738:"RFC1738",RFC3986:"RFC3986"},v=p.assign({default:g.RFC3986,formatters:{RFC1738:function(t){return m.call(t,y,"+")},RFC3986:function(t){return String(t)}}},g),b=Object.prototype.hasOwnProperty,w={brackets:function(t){return t+"[]"},comma:"comma",indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},k=Array.isArray,x=Array.prototype.push,A=function(t,e){x.apply(t,k(e)?e:[e])},j=Date.prototype.toISOString,_=v.default,S={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:p.encode,encodeValuesOnly:!1,format:_,formatter:v.formatters[_],indices:!1,serializeDate:function(t){return j.call(t)},skipNulls:!1,strictNullHandling:!1},O=function t(e,r,i,o,a,c,s,l,u,h,f,d,m){var y,g=e;if("function"==typeof s?g=s(r,g):g instanceof Date?g=h(g):"comma"===i&&k(g)&&(g=p.maybeMap(g,(function(t){return t instanceof Date?h(t):t})).join(",")),null===g){if(o)return c&&!d?c(r,S.encoder,m,"key"):r;g=""}if("string"==typeof(y=g)||"number"==typeof y||"boolean"==typeof y||"symbol"===n(y)||"bigint"==typeof y||p.isBuffer(g))return c?[f(d?r:c(r,S.encoder,m,"key"))+"="+f(c(g,S.encoder,m,"value"))]:[f(r)+"="+f(String(g))];var v,b=[];if(void 0===g)return b;if(k(s))v=s;else{var w=Object.keys(g);v=l?w.sort(l):w}for(var x=0;x<v.length;++x){var j=v[x],_=g[j];if(!a||null!==_){var O=k(g)?"function"==typeof i?i(r,j):r:r+(u?"."+j:"["+j+"]");A(b,t(_,O,i,o,a,c,s,l,u,h,f,d,m))}}return b},C=Object.prototype.hasOwnProperty,E=Array.isArray,B={allowDots:!1,allowPrototypes:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:p.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},L=function(t){return t.replace(/&#(\d+);/g,(function(t,e){return String.fromCharCode(parseInt(e,10))}))},I=function(t,e){return t&&"string"==typeof t&&e.comma&&t.indexOf(",")>-1?t.split(","):t},P=function(t,e,r,n){if(t){var i=r.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t,o=/(\[[^[\]]*])/g,a=r.depth>0&&/(\[[^[\]]*])/.exec(i),c=a?i.slice(0,a.index):i,s=[];if(c){if(!r.plainObjects&&C.call(Object.prototype,c)&&!r.allowPrototypes)return;s.push(c)}for(var l=0;r.depth>0&&null!==(a=o.exec(i))&&l<r.depth;){if(l+=1,!r.plainObjects&&C.call(Object.prototype,a[1].slice(1,-1))&&!r.allowPrototypes)return;s.push(a[1])}return a&&s.push("["+i.slice(a.index)+"]"),function(t,e,r,n){for(var i=n?e:I(e,r),o=t.length-1;o>=0;--o){var a,c=t[o];if("[]"===c&&r.parseArrays)a=[].concat(i);else{a=r.plainObjects?Object.create(null):{};var s="["===c.charAt(0)&&"]"===c.charAt(c.length-1)?c.slice(1,-1):c,l=parseInt(s,10);r.parseArrays||""!==s?!isNaN(l)&&c!==s&&String(l)===s&&l>=0&&r.parseArrays&&l<=r.arrayLimit?(a=[])[l]=i:a[s]=i:a={0:i}}i=a}return i}(s,e,r,n)}},D=function(t,e){var r=function(t){if(!t)return B;if(null!==t.decoder&&void 0!==t.decoder&&"function"!=typeof t.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==t.charset&&"utf-8"!==t.charset&&"iso-8859-1"!==t.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var e=void 0===t.charset?B.charset:t.charset;return{allowDots:void 0===t.allowDots?B.allowDots:!!t.allowDots,allowPrototypes:"boolean"==typeof t.allowPrototypes?t.allowPrototypes:B.allowPrototypes,arrayLimit:"number"==typeof t.arrayLimit?t.arrayLimit:B.arrayLimit,charset:e,charsetSentinel:"boolean"==typeof t.charsetSentinel?t.charsetSentinel:B.charsetSentinel,comma:"boolean"==typeof t.comma?t.comma:B.comma,decoder:"function"==typeof t.decoder?t.decoder:B.decoder,delimiter:"string"==typeof t.delimiter||p.isRegExp(t.delimiter)?t.delimiter:B.delimiter,depth:"number"==typeof t.depth||!1===t.depth?+t.depth:B.depth,ignoreQueryPrefix:!0===t.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof t.interpretNumericEntities?t.interpretNumericEntities:B.interpretNumericEntities,parameterLimit:"number"==typeof t.parameterLimit?t.parameterLimit:B.parameterLimit,parseArrays:!1!==t.parseArrays,plainObjects:"boolean"==typeof t.plainObjects?t.plainObjects:B.plainObjects,strictNullHandling:"boolean"==typeof t.strictNullHandling?t.strictNullHandling:B.strictNullHandling}}(e);if(""===t||null==t)return r.plainObjects?Object.create(null):{};for(var n="string"==typeof t?function(t,e){var r,n={},i=e.ignoreQueryPrefix?t.replace(/^\?/,""):t,o=e.parameterLimit===1/0?void 0:e.parameterLimit,a=i.split(e.delimiter,o),c=-1,s=e.charset;if(e.charsetSentinel)for(r=0;r<a.length;++r)0===a[r].indexOf("utf8=")&&("utf8=%E2%9C%93"===a[r]?s="utf-8":"utf8=%26%2310003%3B"===a[r]&&(s="iso-8859-1"),c=r,r=a.length);for(r=0;r<a.length;++r)if(r!==c){var l,u,h=a[r],f=h.indexOf("]="),d=-1===f?h.indexOf("="):f+1;-1===d?(l=e.decoder(h,B.decoder,s,"key"),u=e.strictNullHandling?null:""):(l=e.decoder(h.slice(0,d),B.decoder,s,"key"),u=p.maybeMap(I(h.slice(d+1),e),(function(t){return e.decoder(t,B.decoder,s,"value")}))),u&&e.interpretNumericEntities&&"iso-8859-1"===s&&(u=L(u)),h.indexOf("[]=")>-1&&(u=E(u)?[u]:u),C.call(n,l)?n[l]=p.combine(n[l],u):n[l]=u}return n}(t,r):t,i=r.plainObjects?Object.create(null):{},o=Object.keys(n),a=0;a<o.length;++a){var c=o[a],s=P(c,n[c],r,"string"==typeof t);i=p.merge(i,s,r)}return p.compact(i)},R=function(t,e){var r,i=t,o=function(t){if(!t)return S;if(null!==t.encoder&&void 0!==t.encoder&&"function"!=typeof t.encoder)throw new TypeError("Encoder has to be a function.");var e=t.charset||S.charset;if(void 0!==t.charset&&"utf-8"!==t.charset&&"iso-8859-1"!==t.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var r=v.default;if(void 0!==t.format){if(!b.call(v.formatters,t.format))throw new TypeError("Unknown format option provided.");r=t.format}var n=v.formatters[r],i=S.filter;return("function"==typeof t.filter||k(t.filter))&&(i=t.filter),{addQueryPrefix:"boolean"==typeof t.addQueryPrefix?t.addQueryPrefix:S.addQueryPrefix,allowDots:void 0===t.allowDots?S.allowDots:!!t.allowDots,charset:e,charsetSentinel:"boolean"==typeof t.charsetSentinel?t.charsetSentinel:S.charsetSentinel,delimiter:void 0===t.delimiter?S.delimiter:t.delimiter,encode:"boolean"==typeof t.encode?t.encode:S.encode,encoder:"function"==typeof t.encoder?t.encoder:S.encoder,encodeValuesOnly:"boolean"==typeof t.encodeValuesOnly?t.encodeValuesOnly:S.encodeValuesOnly,filter:i,formatter:n,serializeDate:"function"==typeof t.serializeDate?t.serializeDate:S.serializeDate,skipNulls:"boolean"==typeof t.skipNulls?t.skipNulls:S.skipNulls,sort:"function"==typeof t.sort?t.sort:null,strictNullHandling:"boolean"==typeof t.strictNullHandling?t.strictNullHandling:S.strictNullHandling}}(e);"function"==typeof o.filter?i=(0,o.filter)("",i):k(o.filter)&&(r=o.filter);var a,c=[];if("object"!==n(i)||null===i)return"";a=e&&e.arrayFormat in w?e.arrayFormat:e&&"indices"in e?e.indices?"indices":"repeat":"indices";var s=w[a];r||(r=Object.keys(i)),o.sort&&r.sort(o.sort);for(var l=0;l<r.length;++l){var u=r[l];o.skipNulls&&null===i[u]||A(c,O(i[u],u,s,o.strictNullHandling,o.skipNulls,o.encode?o.encoder:null,o.filter,o.sort,o.allowDots,o.serializeDate,o.formatter,o.encodeValuesOnly,o.charset))}var h=c.join(o.delimiter),f=!0===o.addQueryPrefix?"?":"";return o.charsetSentinel&&("iso-8859-1"===o.charset?f+="utf8=%26%2310003%3B&":f+="utf8=%E2%9C%93&"),h.length>0?f+h:""};
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).AccountsSDK=t()}(this,(function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function n(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}var i={extend:function(e){return e.oauth_exception&&this.oauth_exception[e.oauth_exception]?Object.assign(e,{description:this.oauth_exception[e.oauth_exception]}):e.identity_exception&&this.identity_exception[e.identity_exception]?Object.assign(e,{description:this.identity_exception[e.identity_exception]}):e},oauth_exception:{invalid_request:"You may be loading accounts-sdk on a domain that is not whitelisted.",unauthorized_client:"Client not found, not provided or incorectly configured.",access_denied:"Probably this application is installed on a different account and you do not have access to it.",unsupported_response_type:"Provided response type is incorrect or unavailable for a given client."},identity_exception:{unauthorized:"Resource owner identity is not known or consent is missing."}},o=function(){function e(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t(this,e),this.options=r,this.listening=!1,this.receiveMessage=this.receiveMessage.bind(this)}return n(e,[{key:"start",value:function(e,t){var r=this;this._listenerInited||(this.listening=!0,this.callback=t,e&&(this.tid=setTimeout((function(){r.stop(),t("timeout",null)}),e)),window.addEventListener("message",this.receiveMessage))}},{key:"stop",value:function(){this.listening=!1,clearTimeout(this.tid),window.removeEventListener("message",this.receiveMessage,!1)}},{key:"receiveMessage",value:function(e){e.origin!==this.options.server_url&&e.origin!==this.options.server_url.replace(/livechat\.com$/,"livechatinc.com")||(e.data.data||e.data.error)&&(this.stop(),e.data.error?this.callback(i.extend(e.data.error),null):(e.data.data.scopes&&(e.data.data.scope=e.data.data.scopes,delete e.data.data.scopes),e.data.data.expires_in&&(e.data.data.expires_in=parseInt(e.data.data.expires_in)||0),this.callback(null,e.data.data)))}}]),e}(),a=function(){function e(r,n){t(this,e),this.options=n,this.sdk=r}return n(e,[{key:"authorize",value:function(){var e=this;return new Promise((function(t,r){var n=e.sdk.authorizeURL(e.options,"button"),i=window.screen.width/2-250,a=window.screen.height/2-325;new o(e.options).start(null,(function(e,n){if(e)return r(e);t(n)}));var s=function(){window.open(n,"livechat-login-popup","resizable,scrollbars,width=".concat(500,",height=").concat(650,",left=").concat(i,",top=").concat(a))};document.requestStorageAccess?document.requestStorageAccess().then(s,s):s()}))}}]),e}(),s=Object.prototype.hasOwnProperty,c=Array.isArray,u=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),l=function(e,t){for(var r=t&&t.plainObjects?Object.create(null):{},n=0;n<e.length;++n)void 0!==e[n]&&(r[n]=e[n]);return r},f={arrayToObject:l,assign:function(e,t){return Object.keys(t).reduce((function(e,r){return e[r]=t[r],e}),e)},combine:function(e,t){return[].concat(e,t)},compact:function(t){for(var r=[{obj:{o:t},prop:"o"}],n=[],i=0;i<r.length;++i)for(var o=r[i],a=o.obj[o.prop],s=Object.keys(a),u=0;u<s.length;++u){var l=s[u],f=a[l];"object"===e(f)&&null!==f&&-1===n.indexOf(f)&&(r.push({obj:a,prop:l}),n.push(f))}return function(e){for(;e.length>1;){var t=e.pop(),r=t.obj[t.prop];if(c(r)){for(var n=[],i=0;i<r.length;++i)void 0!==r[i]&&n.push(r[i]);t.obj[t.prop]=n}}}(r),t},decode:function(e,t,r){var n=e.replace(/\+/g," ");if("iso-8859-1"===r)return n.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(n)}catch(e){return n}},encode:function(t,r,n){if(0===t.length)return t;var i=t;if("symbol"===e(t)?i=Symbol.prototype.toString.call(t):"string"!=typeof t&&(i=String(t)),"iso-8859-1"===n)return escape(i).replace(/%u[0-9a-f]{4}/gi,(function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"}));for(var o="",a=0;a<i.length;++a){var s=i.charCodeAt(a);45===s||46===s||95===s||126===s||s>=48&&s<=57||s>=65&&s<=90||s>=97&&s<=122?o+=i.charAt(a):s<128?o+=u[s]:s<2048?o+=u[192|s>>6]+u[128|63&s]:s<55296||s>=57344?o+=u[224|s>>12]+u[128|s>>6&63]+u[128|63&s]:(a+=1,s=65536+((1023&s)<<10|1023&i.charCodeAt(a)),o+=u[240|s>>18]+u[128|s>>12&63]+u[128|s>>6&63]+u[128|63&s])}return o},isBuffer:function(t){return!(!t||"object"!==e(t))&&!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(c(e)){for(var r=[],n=0;n<e.length;n+=1)r.push(t(e[n]));return r}return t(e)},merge:function t(r,n,i){if(!n)return r;if("object"!==e(n)){if(c(r))r.push(n);else{if(!r||"object"!==e(r))return[r,n];(i&&(i.plainObjects||i.allowPrototypes)||!s.call(Object.prototype,n))&&(r[n]=!0)}return r}if(!r||"object"!==e(r))return[r].concat(n);var o=r;return c(r)&&!c(n)&&(o=l(r,i)),c(r)&&c(n)?(n.forEach((function(n,o){if(s.call(r,o)){var a=r[o];a&&"object"===e(a)&&n&&"object"===e(n)?r[o]=t(a,n,i):r.push(n)}else r[o]=n})),r):Object.keys(n).reduce((function(e,r){var o=n[r];return s.call(e,r)?e[r]=t(e[r],o,i):e[r]=o,e}),o)}},p=String.prototype.replace,h=/%20/g,d={RFC1738:"RFC1738",RFC3986:"RFC3986"},y=f.assign({default:d.RFC3986,formatters:{RFC1738:function(e){return p.call(e,h,"+")},RFC3986:function(e){return String(e)}}},d),g=Object.prototype.hasOwnProperty,m={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},v=Array.isArray,b=Array.prototype.push,_=function(e,t){b.apply(e,v(t)?t:[t])},w=Date.prototype.toISOString,k=y.default,x={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:f.encode,encodeValuesOnly:!1,format:k,formatter:y.formatters[k],indices:!1,serializeDate:function(e){return w.call(e)},skipNulls:!1,strictNullHandling:!1},O=function t(r,n,i,o,a,s,c,u,l,p,h,d,y){var g,m=r;if("function"==typeof c?m=c(n,m):m instanceof Date?m=p(m):"comma"===i&&v(m)&&(m=f.maybeMap(m,(function(e){return e instanceof Date?p(e):e})).join(",")),null===m){if(o)return s&&!d?s(n,x.encoder,y,"key"):n;m=""}if("string"==typeof(g=m)||"number"==typeof g||"boolean"==typeof g||"symbol"===e(g)||"bigint"==typeof g||f.isBuffer(m))return s?[h(d?n:s(n,x.encoder,y,"key"))+"="+h(s(m,x.encoder,y,"value"))]:[h(n)+"="+h(String(m))];var b,w=[];if(void 0===m)return w;if(v(c))b=c;else{var k=Object.keys(m);b=u?k.sort(u):k}for(var O=0;O<b.length;++O){var j=b[O],S=m[j];if(!a||null!==S){var A=v(m)?"function"==typeof i?i(n,j):n:n+(l?"."+j:"["+j+"]");_(w,t(S,A,i,o,a,s,c,u,l,p,h,d,y))}}return w},j=Object.prototype.hasOwnProperty,S=Array.isArray,A={allowDots:!1,allowPrototypes:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:f.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},I=function(e){return e.replace(/&#(\d+);/g,(function(e,t){return String.fromCharCode(parseInt(t,10))}))},C=function(e,t){return e&&"string"==typeof e&&t.comma&&e.indexOf(",")>-1?e.split(","):e},D=function(e,t,r,n){if(e){var i=r.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,o=/(\[[^[\]]*])/g,a=r.depth>0&&/(\[[^[\]]*])/.exec(i),s=a?i.slice(0,a.index):i,c=[];if(s){if(!r.plainObjects&&j.call(Object.prototype,s)&&!r.allowPrototypes)return;c.push(s)}for(var u=0;r.depth>0&&null!==(a=o.exec(i))&&u<r.depth;){if(u+=1,!r.plainObjects&&j.call(Object.prototype,a[1].slice(1,-1))&&!r.allowPrototypes)return;c.push(a[1])}return a&&c.push("["+i.slice(a.index)+"]"),function(e,t,r,n){for(var i=n?t:C(t,r),o=e.length-1;o>=0;--o){var a,s=e[o];if("[]"===s&&r.parseArrays)a=[].concat(i);else{a=r.plainObjects?Object.create(null):{};var c="["===s.charAt(0)&&"]"===s.charAt(s.length-1)?s.slice(1,-1):s,u=parseInt(c,10);r.parseArrays||""!==c?!isNaN(u)&&s!==c&&String(u)===c&&u>=0&&r.parseArrays&&u<=r.arrayLimit?(a=[])[u]=i:a[c]=i:a={0:i}}i=a}return i}(c,t,r,n)}},N=function(e,t){var r=function(e){if(!e)return A;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?A.charset:e.charset;return{allowDots:void 0===e.allowDots?A.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:A.allowPrototypes,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:A.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:A.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:A.comma,decoder:"function"==typeof e.decoder?e.decoder:A.decoder,delimiter:"string"==typeof e.delimiter||f.isRegExp(e.delimiter)?e.delimiter:A.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:A.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:A.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:A.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:A.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:A.strictNullHandling}}(t);if(""===e||null==e)return r.plainObjects?Object.create(null):{};for(var n="string"==typeof e?function(e,t){var r,n={},i=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,o=t.parameterLimit===1/0?void 0:t.parameterLimit,a=i.split(t.delimiter,o),s=-1,c=t.charset;if(t.charsetSentinel)for(r=0;r<a.length;++r)0===a[r].indexOf("utf8=")&&("utf8=%E2%9C%93"===a[r]?c="utf-8":"utf8=%26%2310003%3B"===a[r]&&(c="iso-8859-1"),s=r,r=a.length);for(r=0;r<a.length;++r)if(r!==s){var u,l,p=a[r],h=p.indexOf("]="),d=-1===h?p.indexOf("="):h+1;-1===d?(u=t.decoder(p,A.decoder,c,"key"),l=t.strictNullHandling?null:""):(u=t.decoder(p.slice(0,d),A.decoder,c,"key"),l=f.maybeMap(C(p.slice(d+1),t),(function(e){return t.decoder(e,A.decoder,c,"value")}))),l&&t.interpretNumericEntities&&"iso-8859-1"===c&&(l=I(l)),p.indexOf("[]=")>-1&&(l=S(l)?[l]:l),j.call(n,u)?n[u]=f.combine(n[u],l):n[u]=l}return n}(e,r):e,i=r.plainObjects?Object.create(null):{},o=Object.keys(n),a=0;a<o.length;++a){var s=o[a],c=D(s,n[s],r,"string"==typeof e);i=f.merge(i,c,r)}return f.compact(i)},P=function(t,r){var n,i=t,o=function(e){if(!e)return x;if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||x.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var r=y.default;if(void 0!==e.format){if(!g.call(y.formatters,e.format))throw new TypeError("Unknown format option provided.");r=e.format}var n=y.formatters[r],i=x.filter;return("function"==typeof e.filter||v(e.filter))&&(i=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:x.addQueryPrefix,allowDots:void 0===e.allowDots?x.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:x.charsetSentinel,delimiter:void 0===e.delimiter?x.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:x.encode,encoder:"function"==typeof e.encoder?e.encoder:x.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:x.encodeValuesOnly,filter:i,formatter:n,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:x.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:x.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:x.strictNullHandling}}(r);"function"==typeof o.filter?i=(0,o.filter)("",i):v(o.filter)&&(n=o.filter);var a,s=[];if("object"!==e(i)||null===i)return"";a=r&&r.arrayFormat in m?r.arrayFormat:r&&"indices"in r?r.indices?"indices":"repeat":"indices";var c=m[a];n||(n=Object.keys(i)),o.sort&&n.sort(o.sort);for(var u=0;u<n.length;++u){var l=n[u];o.skipNulls&&null===i[l]||_(s,O(i[l],l,c,o.strictNullHandling,o.skipNulls,o.encode?o.encoder:null,o.filter,o.sort,o.allowDots,o.serializeDate,o.formatter,o.encodeValuesOnly,o.charset))}var f=s.join(o.delimiter),p=!0===o.addQueryPrefix?"?":"";return o.charsetSentinel&&("iso-8859-1"===o.charset?p+="utf8=%26%2310003%3B&":p+="utf8=%E2%9C%93&"),f.length>0?p+f:""};
|
|
2
2
|
/** @fileOverview
|
|
3
3
|
* @author Auth0 https://github.com/auth0/auth0.js
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
function
|
|
6
|
+
function R(e,t){return t.reduce((function(t,r){return e[r]&&(t[r]=e[r]),t}),{})}var E=function(){function e(r,n){t(this,e),this.options=n,this.sdk=r}return n(e,[{key:"authorize",value:function(){var e=this.sdk.authorizeURL(this.options);window.location=e}},{key:"authorizeData",value:function(){var e=this;return new Promise((function(t,r){var n={},o=[];switch(e.options.response_type){case"token":if(o=["access_token","expires_in","token_type"],n=R(n=N(window.location.hash.substring(1)),["access_token","expires_in","state","scope","token_type"]),!o.every((function(e){return n.hasOwnProperty(e)})))return void r(i.extend({identity_exception:"unauthorized"}));n.expires_in=parseInt(n.expires_in);break;case"code":if(o=["code"],n=R(n=N(window.location.search,{ignoreQueryPrefix:!0}),["state","code"]),!o.every((function(e){return n.hasOwnProperty(e)})))return void r(i.extend({identity_exception:"unauthorized"}))}t(n)}))}}]),e}(),L=function(){function e(r,n){t(this,e),this.options=n,this.sdk=r}return n(e,[{key:"authorize",value:function(){var e=this;return new Promise((function(t,r){var n=e.sdk.authorizeURL(e.options,"button");new o(e.options).start(5e3,(function(n,i){if(e.removeIframe(),n)return r(n);t(i)}));var i=document.createElement("iframe");i.setAttribute("src",n),i.setAttribute("id",e.iframeID()),i.style.width="1px",i.style.height="1px",i.style.position="fixed",i.style.top="0",i.style.right="0",i.style.opacity="0",i.style.visibility="none",document.body.appendChild(i)}))}},{key:"iframeID",value:function(){return this.options.client_id+this.options.response_type}},{key:"removeIframe",value:function(){var e=document.getElementById(this.iframeID());e&&e.parentNode&&e.parentNode.removeChild(e)}}]),e}();var U={string:
|
|
7
7
|
/** @fileOverview
|
|
8
8
|
* @author Auth0 https://github.com/auth0/auth0.js
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
function(
|
|
11
|
+
function(e){var t=new Uint8Array(e),r=[],n="0123456789ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyz-._~",i=window.crypto||window.msCrypto,o="";if(i)o=i.getRandomValues(t);else for(var a=0;a<e;a++)o+=n.charAt(Math.floor(Math.random()*n.length));for(var s=0;s<o.length;s++)r.push(n[o[s]%n.length]);return r.join("")}};
|
|
12
12
|
/** @fileOverview
|
|
13
13
|
* @author Auth0 https://github.com/auth0/auth0.js
|
|
14
14
|
* @license MIT
|
|
15
|
-
*/function T(){}function H(t,e,r){return t(r={path:e,exports:{},require:function(t,e){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==e&&r.path)}},r.exports),r.exports}T.prototype.getItem=function(){return null},T.prototype.removeItem=function(){},T.prototype.setItem=function(){};var F=H((function(t,e){var r;r=function(){function t(){for(var t=0,e={};t<arguments.length;t++){var r=arguments[t];for(var n in r)e[n]=r[n]}return e}function e(t){return t.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}return function r(n){function i(){}function o(e,r,o){if("undefined"!=typeof document){"number"==typeof(o=t({path:"/"},i.defaults,o)).expires&&(o.expires=new Date(1*new Date+864e5*o.expires)),o.expires=o.expires?o.expires.toUTCString():"";try{var a=JSON.stringify(r);/^[\{\[]/.test(a)&&(r=a)}catch(t){}r=n.write?n.write(r,e):encodeURIComponent(String(r)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),e=encodeURIComponent(String(e)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var c="";for(var s in o)o[s]&&(c+="; "+s,!0!==o[s]&&(c+="="+o[s].split(";")[0]));return document.cookie=e+"="+r+c}}function a(t,r){if("undefined"!=typeof document){for(var i={},o=document.cookie?document.cookie.split("; "):[],a=0;a<o.length;a++){var c=o[a].split("="),s=c.slice(1).join("=");r||'"'!==s.charAt(0)||(s=s.slice(1,-1));try{var l=e(c[0]);if(s=(n.read||n)(s,l)||e(s),r)try{s=JSON.parse(s)}catch(t){}if(i[l]=s,t===l)break}catch(t){}}return t?i[t]:i}}return i.set=o,i.get=function(t){return a(t,!1)},i.getJSON=function(t){return a(t,!0)},i.remove=function(e,r){o(e,"",t(r,{expires:-1}))},i.defaults={},i.withConverter=r,i}((function(){}))},t.exports=r()}));function V(){}function G(t){if(this.storage=new V,!0===t.force_local_storage)try{var e=window.localStorage;e&&(this.storage=e)}catch(t){console.warn(t),console.warn("Cant use localStorage. Using CookieStorage instead.")}}function q(t){this.handler=new G(t)}V.prototype.getItem=function(t){return F.get(t)},V.prototype.removeItem=function(t){F.remove(t)},V.prototype.setItem=function(t,e,r){var n=Object.assign({expires:1},r);F.set(t,e,n)},G.prototype.failover=function(){this.storage instanceof T?console.warn("DummyStorage: ignore failover"):this.storage instanceof V?(console.warn("CookieStorage: failing over DummyStorage"),this.storage=new T):(console.warn("LocalStorage: failing over CookieStorage"),this.storage=new V)},G.prototype.getItem=function(t){try{return this.storage.getItem(t)}catch(e){return console.warn(e),this.failover(),this.getItem(t)}},G.prototype.removeItem=function(t){try{return this.storage.removeItem(t)}catch(e){return console.warn(e),this.failover(),this.removeItem(t)}},G.prototype.setItem=function(t,e,r){try{return this.storage.setItem(t,e,r)}catch(n){return console.warn(n),this.failover(),this.setItem(t,e,r)}},q.prototype.getItem=function(t){var e=this.handler.getItem(t);try{return JSON.parse(e)}catch(t){return e}},q.prototype.removeItem=function(t){return this.handler.removeItem(t)},q.prototype.setItem=function(t,e,r){var n=JSON.stringify(e);return this.handler.setItem(t,n,r)};var Q=function(){function t(e){i(this,t),this.options=e.transaction,this.storage=new q(this.options)}return a(t,[{key:"generate",value:function(t){t.state||(t.state=M.string(this.options.key_length)),this.storage.setItem(this.options.namespace+t.state,{state:t.state,code_verifier:t.code_verifier},{expires:1/48})}},{key:"get",value:function(t){var e=this.storage.getItem(this.options.namespace+t);return this.clear(t),e||{}}},{key:"clear",value:function(t){this.storage.removeItem(this.options.namespace+t)}}]),t}(),J=H((function(t){var e={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(t){this.toString=function(){return"CORRUPT: "+this.message},this.message=t},invalid:function(t){this.toString=function(){return"INVALID: "+this.message},this.message=t},bug:function(t){this.toString=function(){return"BUG: "+this.message},this.message=t},notReady:function(t){this.toString=function(){return"NOT READY: "+this.message},this.message=t}}};function i(t,r,n){if(4!==r.length)throw new e.exception.invalid("invalid aes block size");var i=t.b[n],o=r[0]^i[0],a=r[n?3:1]^i[1],c=r[2]^i[2];r=r[n?1:3]^i[3];var s,l,u,h,f=i.length/4-2,d=4,p=[0,0,0,0];t=(s=t.s[n])[0];var m=s[1],y=s[2],g=s[3],v=s[4];for(h=0;h<f;h++)s=t[o>>>24]^m[a>>16&255]^y[c>>8&255]^g[255&r]^i[d],l=t[a>>>24]^m[c>>16&255]^y[r>>8&255]^g[255&o]^i[d+1],u=t[c>>>24]^m[r>>16&255]^y[o>>8&255]^g[255&a]^i[d+2],r=t[r>>>24]^m[o>>16&255]^y[a>>8&255]^g[255&c]^i[d+3],d+=4,o=s,a=l,c=u;for(h=0;4>h;h++)p[n?3&-h:h]=v[o>>>24]<<24^v[a>>16&255]<<16^v[c>>8&255]<<8^v[255&r]^i[d++],s=o,o=a,a=c,c=r,r=s;return p}function o(t,e){var r,n,i,o=t.F,a=t.b,c=o[0],s=o[1],l=o[2],u=o[3],h=o[4],f=o[5],d=o[6],p=o[7];for(r=0;64>r;r++)16>r?n=e[r]:(n=e[r+1&15],i=e[r+14&15],n=e[15&r]=(n>>>7^n>>>18^n>>>3^n<<25^n<<14)+(i>>>17^i>>>19^i>>>10^i<<15^i<<13)+e[15&r]+e[r+9&15]|0),n=n+p+(h>>>6^h>>>11^h>>>25^h<<26^h<<21^h<<7)+(d^h&(f^d))+a[r],p=d,d=f,f=h,h=u+n|0,u=l,l=s,c=n+((s=c)&l^u&(s^l))+(s>>>2^s>>>13^s>>>22^s<<30^s<<19^s<<10)|0;o[0]=o[0]+c|0,o[1]=o[1]+s|0,o[2]=o[2]+l|0,o[3]=o[3]+u|0,o[4]=o[4]+h|0,o[5]=o[5]+f|0,o[6]=o[6]+d|0,o[7]=o[7]+p|0}function a(t,r){var n,i=e.random.K[t],o=[];for(n in i)i.hasOwnProperty(n)&&o.push(i[n]);for(n=0;n<o.length;n++)o[n](r)}function c(t,e){"undefined"!=typeof window&&window.performance&&"function"==typeof window.performance.now?t.addEntropy(window.performance.now(),e,"loadtime"):t.addEntropy((new Date).valueOf(),e,"loadtime")}function s(t){t.b=l(t).concat(l(t)),t.L=new e.cipher.aes(t.b)}function l(t){for(var e=0;4>e&&(t.h[e]=t.h[e]+1|0,!t.h[e]);e++);return t.L.encrypt(t.h)}function u(t,e){return function(){e.apply(t,arguments)}}e.cipher.aes=function(t){this.s[0][0][0]||this.O();var r,n,i,o,a=this.s[0][4],c=this.s[1],s=1;if(4!==(r=t.length)&&6!==r&&8!==r)throw new e.exception.invalid("invalid aes key size");for(this.b=[i=t.slice(0),o=[]],t=r;t<4*r+28;t++)n=i[t-1],(0==t%r||8===r&&4==t%r)&&(n=a[n>>>24]<<24^a[n>>16&255]<<16^a[n>>8&255]<<8^a[255&n],0==t%r&&(n=n<<8^n>>>24^s<<24,s=s<<1^283*(s>>7))),i[t]=i[t-r]^n;for(r=0;t;r++,t--)n=i[3&r?t:t-4],o[r]=4>=t||4>r?n:c[0][a[n>>>24]]^c[1][a[n>>16&255]]^c[2][a[n>>8&255]]^c[3][a[255&n]]},e.cipher.aes.prototype={encrypt:function(t){return i(this,t,0)},decrypt:function(t){return i(this,t,1)},s:[[[],[],[],[],[]],[[],[],[],[],[]]],O:function(){var t,e,r,n,i,o,a,c=this.s[0],s=this.s[1],l=c[4],u=s[4],h=[],f=[];for(t=0;256>t;t++)f[(h[t]=t<<1^283*(t>>7))^t]=t;for(e=r=0;!l[e];e^=n||1,r=f[r]||1)for(o=(o=r^r<<1^r<<2^r<<3^r<<4)>>8^255&o^99,l[e]=o,u[o]=e,a=16843009*(i=h[t=h[n=h[e]]])^65537*t^257*n^16843008*e,i=257*h[o]^16843008*o,t=0;4>t;t++)c[t][e]=i=i<<24^i>>>8,s[t][o]=a=a<<24^a>>>8;for(t=0;5>t;t++)c[t]=c[t].slice(0),s[t]=s[t].slice(0)}},e.bitArray={bitSlice:function(t,r,n){return t=e.bitArray.$(t.slice(r/32),32-(31&r)).slice(1),void 0===n?t:e.bitArray.clamp(t,n-r)},extract:function(t,e,r){var n=Math.floor(-e-r&31);return(-32&(e+r-1^e)?t[e/32|0]<<32-n^t[e/32+1|0]>>>n:t[e/32|0]>>>n)&(1<<r)-1},concat:function(t,r){if(0===t.length||0===r.length)return t.concat(r);var n=t[t.length-1],i=e.bitArray.getPartial(n);return 32===i?t.concat(r):e.bitArray.$(r,i,0|n,t.slice(0,t.length-1))},bitLength:function(t){var r=t.length;return 0===r?0:32*(r-1)+e.bitArray.getPartial(t[r-1])},clamp:function(t,r){if(32*t.length<r)return t;var n=(t=t.slice(0,Math.ceil(r/32))).length;return r&=31,0<n&&r&&(t[n-1]=e.bitArray.partial(r,t[n-1]&2147483648>>r-1,1)),t},partial:function(t,e,r){return 32===t?e:(r?0|e:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,r){if(e.bitArray.bitLength(t)!==e.bitArray.bitLength(r))return!1;var n,i=0;for(n=0;n<t.length;n++)i|=t[n]^r[n];return 0===i},$:function(t,r,n,i){var o;for(o=0,void 0===i&&(i=[]);32<=r;r-=32)i.push(n),n=0;if(0===r)return i.concat(t);for(o=0;o<t.length;o++)i.push(n|t[o]>>>r),n=t[o]<<32-r;return o=t.length?t[t.length-1]:0,t=e.bitArray.getPartial(o),i.push(e.bitArray.partial(r+t&31,32<r+t?n:i.pop(),1)),i},i:function(t,e){return[t[0]^e[0],t[1]^e[1],t[2]^e[2],t[3]^e[3]]},byteswapM:function(t){var e,r;for(e=0;e<t.length;++e)r=t[e],t[e]=r>>>24|r>>>8&65280|(65280&r)<<8|r<<24;return t}},e.codec.utf8String={fromBits:function(t){var r,n,i="",o=e.bitArray.bitLength(t);for(r=0;r<o/8;r++)0==(3&r)&&(n=t[r/4]),i+=String.fromCharCode(n>>>8>>>8>>>8),n<<=8;return decodeURIComponent(escape(i))},toBits:function(t){t=unescape(encodeURIComponent(t));var r,n=[],i=0;for(r=0;r<t.length;r++)i=i<<8|t.charCodeAt(r),3==(3&r)&&(n.push(i),i=0);return 3&r&&n.push(e.bitArray.partial(8*(3&r),i)),n}},e.codec.hex={fromBits:function(t){var r,n="";for(r=0;r<t.length;r++)n+=(0xf00000000000+(0|t[r])).toString(16).substr(4);return n.substr(0,e.bitArray.bitLength(t)/4)},toBits:function(t){var r,n,i=[];for(n=(t=t.replace(/\s|0x/g,"")).length,t+="00000000",r=0;r<t.length;r+=8)i.push(0^parseInt(t.substr(r,8),16));return e.bitArray.clamp(i,4*n)}},e.codec.base32={B:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",X:"0123456789ABCDEFGHIJKLMNOPQRSTUV",BITS:32,BASE:5,REMAINING:27,fromBits:function(t,r,n){var i=e.codec.base32.BASE,o=e.codec.base32.REMAINING,a="",c=0,s=e.codec.base32.B,l=0,u=e.bitArray.bitLength(t);for(n&&(s=e.codec.base32.X),n=0;a.length*i<u;)a+=s.charAt((l^t[n]>>>c)>>>o),c<i?(l=t[n]<<i-c,c+=o,n++):(l<<=i,c-=i);for(;7&a.length&&!r;)a+="=";return a},toBits:function(t,r){t=t.replace(/\s|=/g,"").toUpperCase();var n,i,o=e.codec.base32.BITS,a=e.codec.base32.BASE,c=e.codec.base32.REMAINING,s=[],l=0,u=e.codec.base32.B,h=0,f="base32";for(r&&(u=e.codec.base32.X,f="base32hex"),n=0;n<t.length;n++){if(0>(i=u.indexOf(t.charAt(n)))){if(!r)try{return e.codec.base32hex.toBits(t)}catch(t){}throw new e.exception.invalid("this isn't "+f+"!")}l>c?(l-=c,s.push(h^i>>>l),h=i<<o-l):h^=i<<o-(l+=a)}return 56&l&&s.push(e.bitArray.partial(56&l,h,1)),s}},e.codec.base32hex={fromBits:function(t,r){return e.codec.base32.fromBits(t,r,1)},toBits:function(t){return e.codec.base32.toBits(t,1)}},e.codec.base64={B:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fromBits:function(t,r,n){var i="",o=0,a=e.codec.base64.B,c=0,s=e.bitArray.bitLength(t);for(n&&(a=a.substr(0,62)+"-_"),n=0;6*i.length<s;)i+=a.charAt((c^t[n]>>>o)>>>26),6>o?(c=t[n]<<6-o,o+=26,n++):(c<<=6,o-=6);for(;3&i.length&&!r;)i+="=";return i},toBits:function(t,r){t=t.replace(/\s|=/g,"");var n,i,o=[],a=0,c=e.codec.base64.B,s=0;for(r&&(c=c.substr(0,62)+"-_"),n=0;n<t.length;n++){if(0>(i=c.indexOf(t.charAt(n))))throw new e.exception.invalid("this isn't base64!");26<a?(a-=26,o.push(s^i>>>a),s=i<<32-a):s^=i<<32-(a+=6)}return 56&a&&o.push(e.bitArray.partial(56&a,s,1)),o}},e.codec.base64url={fromBits:function(t){return e.codec.base64.fromBits(t,1,1)},toBits:function(t){return e.codec.base64.toBits(t,1)}},e.hash.sha256=function(t){this.b[0]||this.O(),t?(this.F=t.F.slice(0),this.A=t.A.slice(0),this.l=t.l):this.reset()},e.hash.sha256.hash=function(t){return(new e.hash.sha256).update(t).finalize()},e.hash.sha256.prototype={blockSize:512,reset:function(){return this.F=this.Y.slice(0),this.A=[],this.l=0,this},update:function(t){"string"==typeof t&&(t=e.codec.utf8String.toBits(t));var r,n=this.A=e.bitArray.concat(this.A,t);if(r=this.l,9007199254740991<(t=this.l=r+e.bitArray.bitLength(t)))throw new e.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!=typeof Uint32Array){var i=new Uint32Array(n),a=0;for(r=512+r-(512+r&511);r<=t;r+=512)o(this,i.subarray(16*a,16*(a+1))),a+=1;n.splice(0,16*a)}else for(r=512+r-(512+r&511);r<=t;r+=512)o(this,n.splice(0,16));return this},finalize:function(){var t,r=this.A,n=this.F;for(t=(r=e.bitArray.concat(r,[e.bitArray.partial(1,1)])).length+2;15&t;t++)r.push(0);for(r.push(Math.floor(this.l/4294967296)),r.push(0|this.l);r.length;)o(this,r.splice(0,16));return this.reset(),n},Y:[],b:[],O:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}for(var e,r,n=0,i=2;64>n;i++){for(r=!0,e=2;e*e<=i;e++)if(0==i%e){r=!1;break}r&&(8>n&&(this.Y[n]=t(Math.pow(i,.5))),this.b[n]=t(Math.pow(i,1/3)),n++)}}},e.mode.ccm={name:"ccm",G:[],listenProgress:function(t){e.mode.ccm.G.push(t)},unListenProgress:function(t){-1<(t=e.mode.ccm.G.indexOf(t))&&e.mode.ccm.G.splice(t,1)},fa:function(t){var r,n=e.mode.ccm.G.slice();for(r=0;r<n.length;r+=1)n[r](t)},encrypt:function(t,r,n,i,o){var a,c=r.slice(0),s=e.bitArray,l=s.bitLength(n)/8,u=s.bitLength(c)/8;if(o=o||64,i=i||[],7>l)throw new e.exception.invalid("ccm: iv must be at least 7 bytes");for(a=2;4>a&&u>>>8*a;a++);return a<15-l&&(a=15-l),n=s.clamp(n,8*(15-a)),r=e.mode.ccm.V(t,r,n,i,o,a),c=e.mode.ccm.C(t,c,n,r,o,a),s.concat(c.data,c.tag)},decrypt:function(t,r,n,i,o){o=o||64,i=i||[];var a=e.bitArray,c=a.bitLength(n)/8,s=a.bitLength(r),l=a.clamp(r,s-o),u=a.bitSlice(r,s-o);s=(s-o)/8;if(7>c)throw new e.exception.invalid("ccm: iv must be at least 7 bytes");for(r=2;4>r&&s>>>8*r;r++);if(r<15-c&&(r=15-c),n=a.clamp(n,8*(15-r)),l=e.mode.ccm.C(t,l,n,u,o,r),t=e.mode.ccm.V(t,l.data,n,i,o,r),!a.equal(l.tag,t))throw new e.exception.corrupt("ccm: tag doesn't match");return l.data},na:function(t,r,n,i,o,a){var c=[],s=e.bitArray,l=s.i;if(i=[s.partial(8,(r.length?64:0)|i-2<<2|a-1)],(i=s.concat(i,n))[3]|=o,i=t.encrypt(i),r.length)for(65279>=(n=s.bitLength(r)/8)?c=[s.partial(16,n)]:4294967295>=n&&(c=s.concat([s.partial(16,65534)],[n])),c=s.concat(c,r),r=0;r<c.length;r+=4)i=t.encrypt(l(i,c.slice(r,r+4).concat([0,0,0])));return i},V:function(t,r,n,i,o,a){var c=e.bitArray,s=c.i;if((o/=8)%2||4>o||16<o)throw new e.exception.invalid("ccm: invalid tag length");if(4294967295<i.length||4294967295<r.length)throw new e.exception.bug("ccm: can't deal with 4GiB or more data");for(n=e.mode.ccm.na(t,i,n,o,c.bitLength(r)/8,a),i=0;i<r.length;i+=4)n=t.encrypt(s(n,r.slice(i,i+4).concat([0,0,0])));return c.clamp(n,8*o)},C:function(t,r,n,i,o,a){var c,s=e.bitArray;c=s.i;var l=r.length,u=s.bitLength(r),h=l/50,f=h;if(n=s.concat([s.partial(8,a-1)],n).concat([0,0,0]).slice(0,4),i=s.bitSlice(c(i,t.encrypt(n)),0,o),!l)return{tag:i,data:[]};for(c=0;c<l;c+=4)c>h&&(e.mode.ccm.fa(c/l),h+=f),n[3]++,o=t.encrypt(n),r[c]^=o[0],r[c+1]^=o[1],r[c+2]^=o[2],r[c+3]^=o[3];return{tag:i,data:s.clamp(r,u)}}},e.mode.ocb2={name:"ocb2",encrypt:function(t,r,n,i,o,a){if(128!==e.bitArray.bitLength(n))throw new e.exception.invalid("ocb iv must be 128 bits");var c,s=e.mode.ocb2.S,l=e.bitArray,u=l.i,h=[0,0,0,0];n=s(t.encrypt(n));var f,d=[];for(i=i||[],o=o||64,c=0;c+4<r.length;c+=4)h=u(h,f=r.slice(c,c+4)),d=d.concat(u(n,t.encrypt(u(n,f)))),n=s(n);return f=r.slice(c),r=l.bitLength(f),c=t.encrypt(u(n,[0,0,0,r])),f=l.clamp(u(f.concat([0,0,0]),c),r),h=u(h,u(f.concat([0,0,0]),c)),h=t.encrypt(u(h,u(n,s(n)))),i.length&&(h=u(h,a?i:e.mode.ocb2.pmac(t,i))),d.concat(l.concat(f,l.clamp(h,o)))},decrypt:function(t,r,n,i,o,a){if(128!==e.bitArray.bitLength(n))throw new e.exception.invalid("ocb iv must be 128 bits");o=o||64;var c,s,l=e.mode.ocb2.S,u=e.bitArray,h=u.i,f=[0,0,0,0],d=l(t.encrypt(n)),p=e.bitArray.bitLength(r)-o,m=[];for(i=i||[],n=0;n+4<p/32;n+=4)c=h(d,t.decrypt(h(d,r.slice(n,n+4)))),f=h(f,c),m=m.concat(c),d=l(d);if(s=p-32*n,c=t.encrypt(h(d,[0,0,0,s])),c=h(c,u.clamp(r.slice(n),s).concat([0,0,0])),f=h(f,c),f=t.encrypt(h(f,h(d,l(d)))),i.length&&(f=h(f,a?i:e.mode.ocb2.pmac(t,i))),!u.equal(u.clamp(f,o),u.bitSlice(r,p)))throw new e.exception.corrupt("ocb: tag doesn't match");return m.concat(u.clamp(c,s))},pmac:function(t,r){var n,i=e.mode.ocb2.S,o=e.bitArray,a=o.i,c=[0,0,0,0],s=a(s=t.encrypt([0,0,0,0]),i(i(s)));for(n=0;n+4<r.length;n+=4)s=i(s),c=a(c,t.encrypt(a(s,r.slice(n,n+4))));return n=r.slice(n),128>o.bitLength(n)&&(s=a(s,i(s)),n=o.concat(n,[-2147483648,0,0,0])),c=a(c,n),t.encrypt(a(i(a(s,i(s))),c))},S:function(t){return[t[0]<<1^t[1]>>>31,t[1]<<1^t[2]>>>31,t[2]<<1^t[3]>>>31,t[3]<<1^135*(t[0]>>>31)]}},e.mode.gcm={name:"gcm",encrypt:function(t,r,n,i,o){var a=r.slice(0);return r=e.bitArray,i=i||[],t=e.mode.gcm.C(!0,t,a,i,n,o||128),r.concat(t.data,t.tag)},decrypt:function(t,r,n,i,o){var a=r.slice(0),c=e.bitArray,s=c.bitLength(a);if(i=i||[],(o=o||128)<=s?(r=c.bitSlice(a,s-o),a=c.bitSlice(a,0,s-o)):(r=a,a=[]),t=e.mode.gcm.C(!1,t,a,i,n,o),!c.equal(t.tag,r))throw new e.exception.corrupt("gcm: tag doesn't match");return t.data},ka:function(t,r){var n,i,o,a,c,s=e.bitArray.i;for(o=[0,0,0,0],a=r.slice(0),n=0;128>n;n++){for((i=0!=(t[Math.floor(n/32)]&1<<31-n%32))&&(o=s(o,a)),c=0!=(1&a[3]),i=3;0<i;i--)a[i]=a[i]>>>1|(1&a[i-1])<<31;a[0]>>>=1,c&&(a[0]^=-520093696)}return o},j:function(t,r,n){var i,o=n.length;for(r=r.slice(0),i=0;i<o;i+=4)r[0]^=4294967295&n[i],r[1]^=4294967295&n[i+1],r[2]^=4294967295&n[i+2],r[3]^=4294967295&n[i+3],r=e.mode.gcm.ka(r,t);return r},C:function(t,r,n,i,o,a){var c,s,l,u,h,f,d,p,m=e.bitArray;for(f=n.length,d=m.bitLength(n),p=m.bitLength(i),s=m.bitLength(o),c=r.encrypt([0,0,0,0]),96===s?(o=o.slice(0),o=m.concat(o,[1])):(o=e.mode.gcm.j(c,[0,0,0,0],o),o=e.mode.gcm.j(c,o,[0,0,Math.floor(s/4294967296),4294967295&s])),s=e.mode.gcm.j(c,[0,0,0,0],i),h=o.slice(0),i=s.slice(0),t||(i=e.mode.gcm.j(c,s,n)),u=0;u<f;u+=4)h[3]++,l=r.encrypt(h),n[u]^=l[0],n[u+1]^=l[1],n[u+2]^=l[2],n[u+3]^=l[3];return n=m.clamp(n,d),t&&(i=e.mode.gcm.j(c,s,n)),t=[Math.floor(p/4294967296),4294967295&p,Math.floor(d/4294967296),4294967295&d],i=e.mode.gcm.j(c,i,t),l=r.encrypt(o),i[0]^=l[0],i[1]^=l[1],i[2]^=l[2],i[3]^=l[3],{tag:m.bitSlice(i,0,a),data:n}}},e.misc.hmac=function(t,r){this.W=r=r||e.hash.sha256;var n,i=[[],[]],o=r.prototype.blockSize/32;for(this.w=[new r,new r],t.length>o&&(t=r.hash(t)),n=0;n<o;n++)i[0][n]=909522486^t[n],i[1][n]=1549556828^t[n];this.w[0].update(i[0]),this.w[1].update(i[1]),this.R=new r(this.w[0])},e.misc.hmac.prototype.encrypt=e.misc.hmac.prototype.mac=function(t){if(this.aa)throw new e.exception.invalid("encrypt on already updated hmac called!");return this.update(t),this.digest(t)},e.misc.hmac.prototype.reset=function(){this.R=new this.W(this.w[0]),this.aa=!1},e.misc.hmac.prototype.update=function(t){this.aa=!0,this.R.update(t)},e.misc.hmac.prototype.digest=function(){var t=this.R.finalize();t=new this.W(this.w[1]).update(t).finalize();return this.reset(),t},e.misc.pbkdf2=function(t,r,n,i,o){if(n=n||1e4,0>i||0>n)throw new e.exception.invalid("invalid params to pbkdf2");"string"==typeof t&&(t=e.codec.utf8String.toBits(t)),"string"==typeof r&&(r=e.codec.utf8String.toBits(r)),t=new(o=o||e.misc.hmac)(t);var a,c,s,l,u=[],h=e.bitArray;for(l=1;32*u.length<(i||1);l++){for(o=a=t.encrypt(h.concat(r,[l])),c=1;c<n;c++)for(a=t.encrypt(a),s=0;s<a.length;s++)o[s]^=a[s];u=u.concat(o)}return i&&(u=h.clamp(u,i)),u},e.prng=function(t){this.c=[new e.hash.sha256],this.m=[0],this.P=0,this.H={},this.N=0,this.U={},this.Z=this.f=this.o=this.ha=0,this.b=[0,0,0,0,0,0,0,0],this.h=[0,0,0,0],this.L=void 0,this.M=t,this.D=!1,this.K={progress:{},seeded:{}},this.u=this.ga=0,this.I=1,this.J=2,this.ca=65536,this.T=[0,48,64,96,128,192,256,384,512,768,1024],this.da=3e4,this.ba=80},e.prng.prototype={randomWords:function(t,r){var n,i,o=[];if((n=this.isReady(r))===this.u)throw new e.exception.notReady("generator isn't seeded");if(n&this.J){n=!(n&this.I),i=[];var a,c=0;for(this.Z=i[0]=(new Date).valueOf()+this.da,a=0;16>a;a++)i.push(4294967296*Math.random()|0);for(a=0;a<this.c.length&&(i=i.concat(this.c[a].finalize()),c+=this.m[a],this.m[a]=0,n||!(this.P&1<<a));a++);for(this.P>=1<<this.c.length&&(this.c.push(new e.hash.sha256),this.m.push(0)),this.f-=c,c>this.o&&(this.o=c),this.P++,this.b=e.hash.sha256.hash(this.b.concat(i)),this.L=new e.cipher.aes(this.b),n=0;4>n&&(this.h[n]=this.h[n]+1|0,!this.h[n]);n++);}for(n=0;n<t;n+=4)0==(n+1)%this.ca&&s(this),i=l(this),o.push(i[0],i[1],i[2],i[3]);return s(this),o.slice(0,t)},setDefaultParanoia:function(t,r){if(0===t&&"Setting paranoia=0 will ruin your security; use it only for testing"!==r)throw new e.exception.invalid("Setting paranoia=0 will ruin your security; use it only for testing");this.M=t},addEntropy:function(t,r,i){i=i||"user";var o,c,s=(new Date).valueOf(),l=this.H[i],u=this.isReady(),h=0;switch(void 0===(o=this.U[i])&&(o=this.U[i]=this.ha++),void 0===l&&(l=this.H[i]=0),this.H[i]=(this.H[i]+1)%this.c.length,n(t)){case"number":void 0===r&&(r=1),this.c[l].update([o,this.N++,1,r,s,1,0|t]);break;case"object":if("[object Uint32Array]"===(i=Object.prototype.toString.call(t))){for(c=[],i=0;i<t.length;i++)c.push(t[i]);t=c}else for("[object Array]"!==i&&(h=1),i=0;i<t.length&&!h;i++)"number"!=typeof t[i]&&(h=1);if(!h){if(void 0===r)for(i=r=0;i<t.length;i++)for(c=t[i];0<c;)r++,c>>>=1;this.c[l].update([o,this.N++,2,r,s,t.length].concat(t))}break;case"string":void 0===r&&(r=t.length),this.c[l].update([o,this.N++,3,r,s,t.length]),this.c[l].update(t);break;default:h=1}if(h)throw new e.exception.bug("random: addEntropy only supports number, array of numbers or string");this.m[l]+=r,this.f+=r,u===this.u&&(this.isReady()!==this.u&&a("seeded",Math.max(this.o,this.f)),a("progress",this.getProgress()))},isReady:function(t){return t=this.T[void 0!==t?t:this.M],this.o&&this.o>=t?this.m[0]>this.ba&&(new Date).valueOf()>this.Z?this.J|this.I:this.I:this.f>=t?this.J|this.u:this.u},getProgress:function(t){return t=this.T[t||this.M],this.o>=t||this.f>t?1:this.f/t},startCollectors:function(){if(!this.D){if(this.a={loadTimeCollector:u(this,this.ma),mouseCollector:u(this,this.oa),keyboardCollector:u(this,this.la),accelerometerCollector:u(this,this.ea),touchCollector:u(this,this.qa)},window.addEventListener)window.addEventListener("load",this.a.loadTimeCollector,!1),window.addEventListener("mousemove",this.a.mouseCollector,!1),window.addEventListener("keypress",this.a.keyboardCollector,!1),window.addEventListener("devicemotion",this.a.accelerometerCollector,!1),window.addEventListener("touchmove",this.a.touchCollector,!1);else{if(!document.attachEvent)throw new e.exception.bug("can't attach event");document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector)}this.D=!0}},stopCollectors:function(){this.D&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,!1),window.removeEventListener("mousemove",this.a.mouseCollector,!1),window.removeEventListener("keypress",this.a.keyboardCollector,!1),window.removeEventListener("devicemotion",this.a.accelerometerCollector,!1),window.removeEventListener("touchmove",this.a.touchCollector,!1)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove",this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.D=!1)},addEventListener:function(t,e){this.K[t][this.ga++]=e},removeEventListener:function(t,e){var r,n,i=this.K[t],o=[];for(n in i)i.hasOwnProperty(n)&&i[n]===e&&o.push(n);for(r=0;r<o.length;r++)delete i[n=o[r]]},la:function(){c(this,1)},oa:function(t){var e,r;try{e=t.x||t.clientX||t.offsetX||0,r=t.y||t.clientY||t.offsetY||0}catch(t){r=e=0}0!=e&&0!=r&&this.addEntropy([e,r],2,"mouse"),c(this,0)},qa:function(t){t=t.touches[0]||t.changedTouches[0],this.addEntropy([t.pageX||t.clientX,t.pageY||t.clientY],1,"touch"),c(this,0)},ma:function(){c(this,2)},ea:function(t){if(t=t.accelerationIncludingGravity.x||t.accelerationIncludingGravity.y||t.accelerationIncludingGravity.z,window.orientation){var e=window.orientation;"number"==typeof e&&this.addEntropy(e,1,"accelerometer")}t&&this.addEntropy(t,2,"accelerometer"),c(this,0)}},e.random=new e.prng(6);t:try{var h,f,d,p;if(p=t.exports){var m;try{m=r.default}catch(t){m=null}p=f=m}if(p&&f.randomBytes)h=f.randomBytes(128),h=new Uint32Array(new Uint8Array(h).buffer),e.random.addEntropy(h,1024,"crypto['randomBytes']");else if("undefined"!=typeof window&&"undefined"!=typeof Uint32Array){if(d=new Uint32Array(32),window.crypto&&window.crypto.getRandomValues)window.crypto.getRandomValues(d);else{if(!window.msCrypto||!window.msCrypto.getRandomValues)break t;window.msCrypto.getRandomValues(d)}e.random.addEntropy(d,1024,"crypto['getRandomValues']")}}catch(t){"undefined"!=typeof window&&window.console&&(console.log("There was an error collecting entropy from the browser:"),console.log(t))}e.json={defaults:{v:1,iter:1e4,ks:128,ts:64,mode:"ccm",adata:"",cipher:"aes"},ja:function(t,r,n,i){n=n||{},i=i||{};var o,a=e.json,c=a.g({iv:e.random.randomWords(4,0)},a.defaults);if(a.g(c,n),n=c.adata,"string"==typeof c.salt&&(c.salt=e.codec.base64.toBits(c.salt)),"string"==typeof c.iv&&(c.iv=e.codec.base64.toBits(c.iv)),!e.mode[c.mode]||!e.cipher[c.cipher]||"string"==typeof t&&100>=c.iter||64!==c.ts&&96!==c.ts&&128!==c.ts||128!==c.ks&&192!==c.ks&&256!==c.ks||2>c.iv.length||4<c.iv.length)throw new e.exception.invalid("json encrypt: invalid parameters");return"string"==typeof t?(t=(o=e.misc.cachedPbkdf2(t,c)).key.slice(0,c.ks/32),c.salt=o.salt):e.ecc&&t instanceof e.ecc.elGamal.publicKey&&(o=t.kem(),c.kemtag=o.tag,t=o.key.slice(0,c.ks/32)),"string"==typeof r&&(r=e.codec.utf8String.toBits(r)),"string"==typeof n&&(c.adata=n=e.codec.utf8String.toBits(n)),o=new e.cipher[c.cipher](t),a.g(i,c),i.key=t,c.ct="ccm"===c.mode&&e.arrayBuffer&&e.arrayBuffer.ccm&&r instanceof ArrayBuffer?e.arrayBuffer.ccm.encrypt(o,r,c.iv,n,c.ts):e.mode[c.mode].encrypt(o,r,c.iv,n,c.ts),c},encrypt:function(t,r,n,i){var o=e.json,a=o.ja.apply(o,arguments);return o.encode(a)},ia:function(t,r,n,i){n=n||{},i=i||{};var o,a,c=e.json;if(o=(r=c.g(c.g(c.g({},c.defaults),r),n,!0)).adata,"string"==typeof r.salt&&(r.salt=e.codec.base64.toBits(r.salt)),"string"==typeof r.iv&&(r.iv=e.codec.base64.toBits(r.iv)),!e.mode[r.mode]||!e.cipher[r.cipher]||"string"==typeof t&&100>=r.iter||64!==r.ts&&96!==r.ts&&128!==r.ts||128!==r.ks&&192!==r.ks&&256!==r.ks||!r.iv||2>r.iv.length||4<r.iv.length)throw new e.exception.invalid("json decrypt: invalid parameters");return"string"==typeof t?(t=(a=e.misc.cachedPbkdf2(t,r)).key.slice(0,r.ks/32),r.salt=a.salt):e.ecc&&t instanceof e.ecc.elGamal.secretKey&&(t=t.unkem(e.codec.base64.toBits(r.kemtag)).slice(0,r.ks/32)),"string"==typeof o&&(o=e.codec.utf8String.toBits(o)),a=new e.cipher[r.cipher](t),o="ccm"===r.mode&&e.arrayBuffer&&e.arrayBuffer.ccm&&r.ct instanceof ArrayBuffer?e.arrayBuffer.ccm.decrypt(a,r.ct,r.iv,r.tag,o,r.ts):e.mode[r.mode].decrypt(a,r.ct,r.iv,o,r.ts),c.g(i,r),i.key=t,1===n.raw?o:e.codec.utf8String.fromBits(o)},decrypt:function(t,r,n,i){var o=e.json;return o.ia(t,o.decode(r),n,i)},encode:function(t){var r,i="{",o="";for(r in t)if(t.hasOwnProperty(r)){if(!r.match(/^[a-z0-9]+$/i))throw new e.exception.invalid("json encode: invalid property name");switch(i+=o+'"'+r+'":',o=",",n(t[r])){case"number":case"boolean":i+=t[r];break;case"string":i+='"'+escape(t[r])+'"';break;case"object":i+='"'+e.codec.base64.fromBits(t[r],0)+'"';break;default:throw new e.exception.bug("json encode: unsupported type")}}return i+"}"},decode:function(t){if(!(t=t.replace(/\s/g,"")).match(/^\{.*\}$/))throw new e.exception.invalid("json decode: this isn't json!");t=t.replace(/^\{|\}$/g,"").split(/,/);var r,n,i={};for(r=0;r<t.length;r++){if(!(n=t[r].match(/^\s*(?:(["']?)([a-z][a-z0-9]*)\1)\s*:\s*(?:(-?\d+)|"([a-z0-9+\/%*_.@=\-]*)"|(true|false))$/i)))throw new e.exception.invalid("json decode: this isn't json!");null!=n[3]?i[n[2]]=parseInt(n[3],10):null!=n[4]?i[n[2]]=n[2].match(/^(ct|adata|salt|iv)$/)?e.codec.base64.toBits(n[4]):unescape(n[4]):null!=n[5]&&(i[n[2]]="true"===n[5])}return i},g:function(t,r,n){if(void 0===t&&(t={}),void 0===r)return t;for(var i in r)if(r.hasOwnProperty(i)){if(n&&void 0!==t[i]&&t[i]!==r[i])throw new e.exception.invalid("required parameter overridden");t[i]=r[i]}return t},sa:function(t,e){var r,n={};for(r in t)t.hasOwnProperty(r)&&t[r]!==e[r]&&(n[r]=t[r]);return n},ra:function(t,e){var r,n={};for(r=0;r<e.length;r++)void 0!==t[e[r]]&&(n[e[r]]=t[e[r]]);return n}},e.encrypt=e.json.encrypt,e.decrypt=e.json.decrypt,e.misc.pa={},e.misc.cachedPbkdf2=function(t,r){var n,i=e.misc.pa;return n=(r=r||{}).iter||1e3,(n=(i=i[t]=i[t]||{})[n]=i[n]||{firstSalt:r.salt&&r.salt.length?r.salt.slice(0):e.random.randomWords(2,0)})[i=void 0===r.salt?n.firstSalt:r.salt]=n[i]||e.misc.pbkdf2(t,i,r.iter),{key:n[i].slice(0),salt:i.slice(0)}},t.exports&&(t.exports=e)}));var Y={base64URLEncode:function(t){return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}};return function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(i(this,t),null==e.client_id)throw new Error("client id not provided");var r={prompt:"",response_type:"token",popup_flow:"auto",state:"",verify_state:!0,verify_callback:!0,scope:null,redirect_uri:"",email_hint:null,server_url:"https://accounts.livechat.com",tracking:{utm_source:"accounts.livechat.com",utm_medium:"accounts-sdk"},transaction:{namespace:"com.livechat.accounts",key_length:32,force_local_storage:!1},pkce:{enabled:!0,code_verifier_length:128,code_challange_method:"S256"}};this.options=Object.assign({},r,e),this.transaction=new Q(this.options)}return a(t,[{key:"iframe",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=Object.assign({},this.options,t);return new z(this,e)}},{key:"popup",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=Object.assign({},this.options,t);return new l(this,e)}},{key:"redirect",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=Object.assign({},this.options,t);return new U(this,e)}},{key:"authorizeURL",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=Object.assign({},this.options,t);r.redirect_uri||(r.redirect_uri=window.location.origin+window.location.pathname);var n=N(r,["client_id","redirect_uri","state","response_type","scope","prompt"]);Object.assign(n,r.tracking),null===n.scope&&delete n.scope,null!=e&&(n.flow=e),r.email_hint&&(n.email=r.email_hint);var i=r.server_url;if("manual"===r.popup_flow&&(i+="/signin"),r.path&&(i+=r.path),"code"===r.response_type&&r.pkce.enabled){var o=r.pkce.code_verifier||M.string(r.pkce.code_verifier_length);switch(r.pkce.code_challange_method){case"S256":var a=J.hash.sha256.hash(o);Object.assign(n,{code_verifier:o,code_challenge:Y.base64URLEncode(a),code_challenge_method:r.pkce.code_challange_method});break;default:Object.assign(n,{code_verifier:o,code_challenge:o,code_challenge_method:r.pkce.code_challange_method})}}return this.transaction.generate(n),delete n.code_verifier,i+"?"+R(n)}},{key:"verify",value:function(t){var e=this.transaction.get(t.state);return t.state&&this.options.verify_state&&e.state!=t.state?null:e}}]),t}()}));
|
|
15
|
+
*/function z(){}z.prototype.getItem=function(){return null},z.prototype.removeItem=function(){},z.prototype.setItem=function(){};var M=function(e,t,r){return e(r={path:t,exports:{},require:function(e,t){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==t&&r.path)}},r.exports),r.exports}((function(e,t){var r;r=function(){function e(){for(var e=0,t={};e<arguments.length;e++){var r=arguments[e];for(var n in r)t[n]=r[n]}return t}function t(e){return e.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}return function r(n){function i(){}function o(t,r,o){if("undefined"!=typeof document){"number"==typeof(o=e({path:"/"},i.defaults,o)).expires&&(o.expires=new Date(1*new Date+864e5*o.expires)),o.expires=o.expires?o.expires.toUTCString():"";try{var a=JSON.stringify(r);/^[\{\[]/.test(a)&&(r=a)}catch(e){}r=n.write?n.write(r,t):encodeURIComponent(String(r)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),t=encodeURIComponent(String(t)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var s="";for(var c in o)o[c]&&(s+="; "+c,!0!==o[c]&&(s+="="+o[c].split(";")[0]));return document.cookie=t+"="+r+s}}function a(e,r){if("undefined"!=typeof document){for(var i={},o=document.cookie?document.cookie.split("; "):[],a=0;a<o.length;a++){var s=o[a].split("="),c=s.slice(1).join("=");r||'"'!==c.charAt(0)||(c=c.slice(1,-1));try{var u=t(s[0]);if(c=(n.read||n)(c,u)||t(c),r)try{c=JSON.parse(c)}catch(e){}if(i[u]=c,e===u)break}catch(e){}}return e?i[e]:i}}return i.set=o,i.get=function(e){return a(e,!1)},i.getJSON=function(e){return a(e,!0)},i.remove=function(t,r){o(t,"",e(r,{expires:-1}))},i.defaults={},i.withConverter=r,i}((function(){}))},e.exports=r()}));function B(){}function T(e){if(this.storage=new B,!0===e.force_local_storage)try{var t=window.localStorage;t&&(this.storage=t)}catch(e){console.warn(e),console.warn("Cant use localStorage. Using CookieStorage instead.")}}function H(e){this.handler=new T(e)}B.prototype.getItem=function(e){return M.get(e)},B.prototype.removeItem=function(e){M.remove(e)},B.prototype.setItem=function(e,t,r){var n=Object.assign({expires:1},r);M.set(e,t,n)},T.prototype.failover=function(){this.storage instanceof z?console.warn("DummyStorage: ignore failover"):this.storage instanceof B?(console.warn("CookieStorage: failing over DummyStorage"),this.storage=new z):(console.warn("LocalStorage: failing over CookieStorage"),this.storage=new B)},T.prototype.getItem=function(e){try{return this.storage.getItem(e)}catch(t){return console.warn(t),this.failover(),this.getItem(e)}},T.prototype.removeItem=function(e){try{return this.storage.removeItem(e)}catch(t){return console.warn(t),this.failover(),this.removeItem(e)}},T.prototype.setItem=function(e,t,r){try{return this.storage.setItem(e,t,r)}catch(n){return console.warn(n),this.failover(),this.setItem(e,t,r)}},H.prototype.getItem=function(e){var t=this.handler.getItem(e);try{return JSON.parse(t)}catch(e){return t}},H.prototype.removeItem=function(e){return this.handler.removeItem(e)},H.prototype.setItem=function(e,t,r){var n=JSON.stringify(t);return this.handler.setItem(e,n,r)};var F=function(){function e(r){t(this,e),this.options=r.transaction,this.storage=new H(this.options)}return n(e,[{key:"generate",value:function(e){e.state||(e.state=U.string(this.options.key_length)),this.storage.setItem(this.options.namespace+e.state,{state:e.state,code_verifier:e.code_verifier},{expires:1/48})}},{key:"get",value:function(e){var t=this.storage.getItem(this.options.namespace+e);return this.clear(e),t||{}}},{key:"clear",value:function(e){this.storage.removeItem(this.options.namespace+e)}}]),e}(),Q={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(e){this.toString=function(){return"CORRUPT: "+this.message},this.message=e},invalid:function(e){this.toString=function(){return"INVALID: "+this.message},this.message=e},bug:function(e){this.toString=function(){return"BUG: "+this.message},this.message=e},notReady:function(e){this.toString=function(){return"NOT READY: "+this.message},this.message=e}}};Q.bitArray={bitSlice:function(e,t,r){return e=Q.bitArray._shiftRight(e.slice(t/32),32-(31&t)).slice(1),void 0===r?e:Q.bitArray.clamp(e,r-t)},extract:function(e,t,r){var n=Math.floor(-t-r&31);return(-32&(t+r-1^t)?e[t/32|0]<<32-n^e[t/32+1|0]>>>n:e[t/32|0]>>>n)&(1<<r)-1},concat:function(e,t){if(0===e.length||0===t.length)return e.concat(t);var r=e[e.length-1],n=Q.bitArray.getPartial(r);return 32===n?e.concat(t):Q.bitArray._shiftRight(t,n,0|r,e.slice(0,e.length-1))},bitLength:function(e){var t,r=e.length;return 0===r?0:(t=e[r-1],32*(r-1)+Q.bitArray.getPartial(t))},clamp:function(e,t){if(32*e.length<t)return e;var r=(e=e.slice(0,Math.ceil(t/32))).length;return t&=31,r>0&&t&&(e[r-1]=Q.bitArray.partial(t,e[r-1]&2147483648>>t-1,1)),e},partial:function(e,t,r){return 32===e?t:(r?0|t:t<<32-e)+1099511627776*e},getPartial:function(e){return Math.round(e/1099511627776)||32},equal:function(e,t){if(Q.bitArray.bitLength(e)!==Q.bitArray.bitLength(t))return!1;var r,n=0;for(r=0;r<e.length;r++)n|=e[r]^t[r];return 0===n},_shiftRight:function(e,t,r,n){var i,o,a;for(void 0===n&&(n=[]);t>=32;t-=32)n.push(r),r=0;if(0===t)return n.concat(e);for(i=0;i<e.length;i++)n.push(r|e[i]>>>t),r=e[i]<<32-t;return o=e.length?e[e.length-1]:0,a=Q.bitArray.getPartial(o),n.push(Q.bitArray.partial(t+a&31,t+a>32?r:n.pop(),1)),n},_xor4:function(e,t){return[e[0]^t[0],e[1]^t[1],e[2]^t[2],e[3]^t[3]]},byteswapM:function(e){var t,r;for(t=0;t<e.length;++t)r=e[t],e[t]=r>>>24|r>>>8&65280|(65280&r)<<8|r<<24;return e}},Q.codec.utf8String={fromBits:function(e){var t,r,n="",i=Q.bitArray.bitLength(e);for(t=0;t<i/8;t++)0==(3&t)&&(r=e[t/4]),n+=String.fromCharCode(r>>>8>>>8>>>8),r<<=8;return decodeURIComponent(escape(n))},toBits:function(e){e=unescape(encodeURIComponent(e));var t,r=[],n=0;for(t=0;t<e.length;t++)n=n<<8|e.charCodeAt(t),3==(3&t)&&(r.push(n),n=0);return 3&t&&r.push(Q.bitArray.partial(8*(3&t),n)),r}},Q.hash.sha256=function(e){this._key[0]||this._precompute(),e?(this._h=e._h.slice(0),this._buffer=e._buffer.slice(0),this._length=e._length):this.reset()},Q.hash.sha256.hash=function(e){return(new Q.hash.sha256).update(e).finalize()},Q.hash.sha256.prototype={blockSize:512,reset:function(){return this._h=this._init.slice(0),this._buffer=[],this._length=0,this},update:function(e){"string"==typeof e&&(e=Q.codec.utf8String.toBits(e));var t,r=this._buffer=Q.bitArray.concat(this._buffer,e),n=this._length,i=this._length=n+Q.bitArray.bitLength(e);if(i>9007199254740991)throw new Q.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!=typeof Uint32Array){var o=new Uint32Array(r),a=0;for(t=512+n-(512+n&511);t<=i;t+=512)this._block(o.subarray(16*a,16*(a+1))),a+=1;r.splice(0,16*a)}else for(t=512+n-(512+n&511);t<=i;t+=512)this._block(r.splice(0,16));return this},finalize:function(){var e,t=this._buffer,r=this._h;for(e=(t=Q.bitArray.concat(t,[Q.bitArray.partial(1,1)])).length+2;15&e;e++)t.push(0);for(t.push(Math.floor(this._length/4294967296)),t.push(0|this._length);t.length;)this._block(t.splice(0,16));return this.reset(),r},_init:[],_key:[],_precompute:function(){var e,t,r=0,n=2;function i(e){return 4294967296*(e-Math.floor(e))|0}for(;r<64;n++){for(t=!0,e=2;e*e<=n;e++)if(n%e==0){t=!1;break}t&&(r<8&&(this._init[r]=i(Math.pow(n,.5))),this._key[r]=i(Math.pow(n,1/3)),r++)}},_block:function(e){var t,r,n,i,o=this._h,a=this._key,s=o[0],c=o[1],u=o[2],l=o[3],f=o[4],p=o[5],h=o[6],d=o[7];for(t=0;t<64;t++)t<16?r=e[t]:(n=e[t+1&15],i=e[t+14&15],r=e[15&t]=(n>>>7^n>>>18^n>>>3^n<<25^n<<14)+(i>>>17^i>>>19^i>>>10^i<<15^i<<13)+e[15&t]+e[t+9&15]|0),r=r+d+(f>>>6^f>>>11^f>>>25^f<<26^f<<21^f<<7)+(h^f&(p^h))+a[t],d=h,h=p,p=f,f=l+r|0,l=u,u=c,s=r+((c=s)&u^l&(c^u))+(c>>>2^c>>>13^c>>>22^c<<30^c<<19^c<<10)|0;o[0]=o[0]+s|0,o[1]=o[1]+c|0,o[2]=o[2]+u|0,o[3]=o[3]+l|0,o[4]=o[4]+f|0,o[5]=o[5]+p|0,o[6]=o[6]+h|0,o[7]=o[7]+d|0}};var V={base64URLEncode:function(e){return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}};return function(){function e(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(t(this,e),null==r.client_id)throw new Error("client id not provided");var n={prompt:"",response_type:"token",popup_flow:"auto",state:"",verify_state:!0,verify_callback:!0,scope:null,redirect_uri:"",email_hint:null,server_url:"https://accounts.livechat.com",tracking:{utm_source:"accounts.livechat.com",utm_medium:"accounts-sdk"},transaction:{namespace:"com.livechat.accounts",key_length:32,force_local_storage:!1},pkce:{enabled:!0,code_verifier_length:128,code_challange_method:"S256"}};this.options=Object.assign({},n,r),this.transaction=new F(this.options)}return n(e,[{key:"iframe",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=Object.assign({},this.options,e);return new L(this,t)}},{key:"popup",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=Object.assign({},this.options,e);return new a(this,t)}},{key:"redirect",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=Object.assign({},this.options,e);return new E(this,t)}},{key:"authorizeURL",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=Object.assign({},this.options,e);r.redirect_uri||(r.redirect_uri=window.location.origin+window.location.pathname);var n=R(r,["client_id","redirect_uri","state","response_type","scope","prompt"]);Object.assign(n,r.tracking),null===n.scope&&delete n.scope,null!=t&&(n.flow=t),r.email_hint&&(n.email=r.email_hint);var i=r.server_url;if("manual"===r.popup_flow&&(i+="/signin"),r.path&&(i+=r.path),"code"===r.response_type&&r.pkce.enabled){var o=r.pkce.code_verifier||U.string(r.pkce.code_verifier_length);switch(r.pkce.code_challange_method){case"S256":var a=Q.hash.sha256.hash(o);Object.assign(n,{code_verifier:o,code_challenge:V.base64URLEncode(a),code_challenge_method:r.pkce.code_challange_method});break;default:Object.assign(n,{code_verifier:o,code_challenge:o,code_challenge_method:r.pkce.code_challange_method})}}return this.transaction.generate(n),delete n.code_verifier,i+"?"+P(n)}},{key:"verify",value:function(e){var t=this.transaction.get(e.state);return e.state&&this.options.verify_state&&t.state!=e.state?null:t}}]),e}()}));
|
|
16
16
|
//# sourceMappingURL=accounts-sdk.min.js.map
|