@authress/login 2.2.241 → 2.2.247

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.
@@ -1,2 +1,2 @@
1
- /*! Authress Login SDK 2.2.241 | Author - Authress Developers | License information can be found at https://github.com/Authress/login-sdk.js */
2
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.authress=t():e.authress=t()}(this,(()=>(()=>{var e,t,r={669:(e,t,r)=>{e.exports=r(609)},448:(e,t,r)=>{"use strict";var n=r(867),o=r(26),i=r(372),s=r(327),a=r(97),c=r(109),u=r(985),d=r(61);e.exports=function(e){return new Promise((function(t,r){var l=e.data,p=e.headers,h=e.responseType;n.isFormData(l)&&delete p["Content-Type"];var f=new XMLHttpRequest;if(e.auth){var m=e.auth.username||"",g=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";p.Authorization="Basic "+btoa(m+":"+g)}var w=a(e.baseURL,e.url);function y(){if(f){var n="getAllResponseHeaders"in f?c(f.getAllResponseHeaders()):null,i={data:h&&"text"!==h&&"json"!==h?f.response:f.responseText,status:f.status,statusText:f.statusText,headers:n,config:e,request:f};o(t,r,i),f=null}}if(f.open(e.method.toUpperCase(),s(w,e.params,e.paramsSerializer),!0),f.timeout=e.timeout,"onloadend"in f?f.onloadend=y:f.onreadystatechange=function(){f&&4===f.readyState&&(0!==f.status||f.responseURL&&0===f.responseURL.indexOf("file:"))&&setTimeout(y)},f.onabort=function(){f&&(r(d("Request aborted",e,"ECONNABORTED",f)),f=null)},f.onerror=function(){r(d("Network Error",e,null,f)),f=null},f.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r(d(t,e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",f)),f=null},n.isStandardBrowserEnv()){var v=(e.withCredentials||u(w))&&e.xsrfCookieName?i.read(e.xsrfCookieName):void 0;v&&(p[e.xsrfHeaderName]=v)}"setRequestHeader"in f&&n.forEach(p,(function(e,t){void 0===l&&"content-type"===t.toLowerCase()?delete p[t]:f.setRequestHeader(t,e)})),n.isUndefined(e.withCredentials)||(f.withCredentials=!!e.withCredentials),h&&"json"!==h&&(f.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&f.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&f.upload&&f.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){f&&(f.abort(),r(e),f=null)})),l||(l=null),f.send(l)}))}},609:(e,t,r)=>{"use strict";var n=r(867),o=r(849),i=r(321),s=r(185);function a(e){var t=new i(e),r=o(i.prototype.request,t);return n.extend(r,i.prototype,t),n.extend(r,t),r}var c=a(r(655));c.Axios=i,c.create=function(e){return a(s(c.defaults,e))},c.Cancel=r(263),c.CancelToken=r(972),c.isCancel=r(502),c.all=function(e){return Promise.all(e)},c.spread=r(713),c.isAxiosError=r(268),e.exports=c,e.exports.default=c},263:e=>{"use strict";function t(e){this.message=e}t.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},t.prototype.__CANCEL__=!0,e.exports=t},972:(e,t,r)=>{"use strict";var n=r(263);function o(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var r=this;e((function(e){r.reason||(r.reason=new n(e),t(r.reason))}))}o.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},o.source=function(){var e;return{token:new o((function(t){e=t})),cancel:e}},e.exports=o},502:e=>{"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},321:(e,t,r)=>{"use strict";var n=r(867),o=r(327),i=r(782),s=r(572),a=r(185),c=r(875),u=c.validators;function d(e){this.defaults=e,this.interceptors={request:new i,response:new i}}d.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=a(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;void 0!==t&&c.assertOptions(t,{silentJSONParsing:u.transitional(u.boolean,"1.0.0"),forcedJSONParsing:u.transitional(u.boolean,"1.0.0"),clarifyTimeoutError:u.transitional(u.boolean,"1.0.0")},!1);var r=[],n=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(n=n&&t.synchronous,r.unshift(t.fulfilled,t.rejected))}));var o,i=[];if(this.interceptors.response.forEach((function(e){i.push(e.fulfilled,e.rejected)})),!n){var d=[s,void 0];for(Array.prototype.unshift.apply(d,r),d=d.concat(i),o=Promise.resolve(e);d.length;)o=o.then(d.shift(),d.shift());return o}for(var l=e;r.length;){var p=r.shift(),h=r.shift();try{l=p(l)}catch(e){h(e);break}}try{o=s(l)}catch(e){return Promise.reject(e)}for(;i.length;)o=o.then(i.shift(),i.shift());return o},d.prototype.getUri=function(e){return e=a(this.defaults,e),o(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},n.forEach(["delete","get","head","options"],(function(e){d.prototype[e]=function(t,r){return this.request(a(r||{},{method:e,url:t,data:(r||{}).data}))}})),n.forEach(["post","put","patch"],(function(e){d.prototype[e]=function(t,r,n){return this.request(a(n||{},{method:e,url:t,data:r}))}})),e.exports=d},782:(e,t,r)=>{"use strict";var n=r(867);function o(){this.handlers=[]}o.prototype.use=function(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},o.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},o.prototype.forEach=function(e){n.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=o},97:(e,t,r)=>{"use strict";var n=r(793),o=r(303);e.exports=function(e,t){return e&&!n(t)?o(e,t):t}},61:(e,t,r)=>{"use strict";var n=r(481);e.exports=function(e,t,r,o,i){var s=new Error(e);return n(s,t,r,o,i)}},572:(e,t,r)=>{"use strict";var n=r(867),o=r(527),i=r(502),s=r(655);function a(e){e.cancelToken&&e.cancelToken.throwIfRequested()}e.exports=function(e){return a(e),e.headers=e.headers||{},e.data=o.call(e,e.data,e.headers,e.transformRequest),e.headers=n.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),n.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||s.adapter)(e).then((function(t){return a(e),t.data=o.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return i(t)||(a(e),t&&t.response&&(t.response.data=o.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},481:e=>{"use strict";e.exports=function(e,t,r,n,o){return e.config=t,r&&(e.code=r),e.request=n,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}},185:(e,t,r)=>{"use strict";var n=r(867);e.exports=function(e,t){t=t||{};var r={},o=["url","method","data"],i=["headers","auth","proxy","params"],s=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],a=["validateStatus"];function c(e,t){return n.isPlainObject(e)&&n.isPlainObject(t)?n.merge(e,t):n.isPlainObject(t)?n.merge({},t):n.isArray(t)?t.slice():t}function u(o){n.isUndefined(t[o])?n.isUndefined(e[o])||(r[o]=c(void 0,e[o])):r[o]=c(e[o],t[o])}n.forEach(o,(function(e){n.isUndefined(t[e])||(r[e]=c(void 0,t[e]))})),n.forEach(i,u),n.forEach(s,(function(o){n.isUndefined(t[o])?n.isUndefined(e[o])||(r[o]=c(void 0,e[o])):r[o]=c(void 0,t[o])})),n.forEach(a,(function(n){n in t?r[n]=c(e[n],t[n]):n in e&&(r[n]=c(void 0,e[n]))}));var d=o.concat(i).concat(s).concat(a),l=Object.keys(e).concat(Object.keys(t)).filter((function(e){return-1===d.indexOf(e)}));return n.forEach(l,u),r}},26:(e,t,r)=>{"use strict";var n=r(61);e.exports=function(e,t,r){var o=r.config.validateStatus;r.status&&o&&!o(r.status)?t(n("Request failed with status code "+r.status,r.config,null,r.request,r)):e(r)}},527:(e,t,r)=>{"use strict";var n=r(867),o=r(655);e.exports=function(e,t,r){var i=this||o;return n.forEach(r,(function(r){e=r.call(i,e,t)})),e}},655:(e,t,r)=>{"use strict";var n=r(867),o=r(16),i=r(481),s={"Content-Type":"application/x-www-form-urlencoded"};function a(e,t){!n.isUndefined(e)&&n.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var c,u={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(c=r(448)),c),transformRequest:[function(e,t){return o(t,"Accept"),o(t,"Content-Type"),n.isFormData(e)||n.isArrayBuffer(e)||n.isBuffer(e)||n.isStream(e)||n.isFile(e)||n.isBlob(e)?e:n.isArrayBufferView(e)?e.buffer:n.isURLSearchParams(e)?(a(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):n.isObject(e)||t&&"application/json"===t["Content-Type"]?(a(t,"application/json"),function(e,t,r){if(n.isString(e))try{return(t||JSON.parse)(e),n.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional,r=t&&t.silentJSONParsing,o=t&&t.forcedJSONParsing,s=!r&&"json"===this.responseType;if(s||o&&n.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(s){if("SyntaxError"===e.name)throw i(e,this,"E_JSON_PARSE");throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};u.headers={common:{Accept:"application/json, text/plain, */*"}},n.forEach(["delete","get","head"],(function(e){u.headers[e]={}})),n.forEach(["post","put","patch"],(function(e){u.headers[e]=n.merge(s)})),e.exports=u},849:e=>{"use strict";e.exports=function(e,t){return function(){for(var r=new Array(arguments.length),n=0;n<r.length;n++)r[n]=arguments[n];return e.apply(t,r)}}},327:(e,t,r)=>{"use strict";var n=r(867);function o(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,r){if(!t)return e;var i;if(r)i=r(t);else if(n.isURLSearchParams(t))i=t.toString();else{var s=[];n.forEach(t,(function(e,t){null!=e&&(n.isArray(e)?t+="[]":e=[e],n.forEach(e,(function(e){n.isDate(e)?e=e.toISOString():n.isObject(e)&&(e=JSON.stringify(e)),s.push(o(t)+"="+o(e))})))})),i=s.join("&")}if(i){var a=e.indexOf("#");-1!==a&&(e=e.slice(0,a)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}},303:e=>{"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},372:(e,t,r)=>{"use strict";var n=r(867);e.exports=n.isStandardBrowserEnv()?{write:function(e,t,r,o,i,s){var a=[];a.push(e+"="+encodeURIComponent(t)),n.isNumber(r)&&a.push("expires="+new Date(r).toGMTString()),n.isString(o)&&a.push("path="+o),n.isString(i)&&a.push("domain="+i),!0===s&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},793:e=>{"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},268:e=>{"use strict";e.exports=function(e){return"object"==typeof e&&!0===e.isAxiosError}},985:(e,t,r)=>{"use strict";var n=r(867);e.exports=n.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function o(e){var n=e;return t&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return e=o(window.location.href),function(t){var r=n.isString(t)?o(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0}},16:(e,t,r)=>{"use strict";var n=r(867);e.exports=function(e,t){n.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))}},109:(e,t,r)=>{"use strict";var n=r(867),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,r,i,s={};return e?(n.forEach(e.split("\n"),(function(e){if(i=e.indexOf(":"),t=n.trim(e.substr(0,i)).toLowerCase(),r=n.trim(e.substr(i+1)),t){if(s[t]&&o.indexOf(t)>=0)return;s[t]="set-cookie"===t?(s[t]?s[t]:[]).concat([r]):s[t]?s[t]+", "+r:r}})),s):s}},713:e=>{"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},875:(e,t,r)=>{"use strict";var n=r(593),o={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){o[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));var i={},s=n.version.split(".");function a(e,t){for(var r=t?t.split("."):s,n=e.split("."),o=0;o<3;o++){if(r[o]>n[o])return!0;if(r[o]<n[o])return!1}return!1}o.transitional=function(e,t,r){var o=t&&a(t);function s(e,t){return"[Axios v"+n.version+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return function(r,n,a){if(!1===e)throw new Error(s(n," has been removed in "+t));return o&&!i[n]&&(i[n]=!0,console.warn(s(n," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,n,a)}},e.exports={isOlderVersion:a,assertOptions:function(e,t,r){if("object"!=typeof e)throw new TypeError("options must be an object");for(var n=Object.keys(e),o=n.length;o-- >0;){var i=n[o],s=t[i];if(s){var a=e[i],c=void 0===a||s(a,i,e);if(!0!==c)throw new TypeError("option "+i+" must be "+c)}else if(!0!==r)throw Error("Unknown option "+i)}},validators:o}},867:(e,t,r)=>{"use strict";var n=r(849),o=Object.prototype.toString;function i(e){return"[object Array]"===o.call(e)}function s(e){return void 0===e}function a(e){return null!==e&&"object"==typeof e}function c(e){if("[object Object]"!==o.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function u(e){return"[object Function]"===o.call(e)}function d(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),i(e))for(var r=0,n=e.length;r<n;r++)t.call(null,e[r],r,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}e.exports={isArray:i,isArrayBuffer:function(e){return"[object ArrayBuffer]"===o.call(e)},isBuffer:function(e){return null!==e&&!s(e)&&null!==e.constructor&&!s(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:a,isPlainObject:c,isUndefined:s,isDate:function(e){return"[object Date]"===o.call(e)},isFile:function(e){return"[object File]"===o.call(e)},isBlob:function(e){return"[object Blob]"===o.call(e)},isFunction:u,isStream:function(e){return a(e)&&u(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:d,merge:function e(){var t={};function r(r,n){c(t[n])&&c(r)?t[n]=e(t[n],r):c(r)?t[n]=e({},r):i(r)?t[n]=r.slice():t[n]=r}for(var n=0,o=arguments.length;n<o;n++)d(arguments[n],r);return t},extend:function(e,t,r){return d(t,(function(t,o){e[o]=r&&"function"==typeof t?n(t,r):t})),e},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e}}},219:e=>{function t(e){return String.fromCharCode(parseInt(e.slice(1),16))}function r(e){return`%${`00${e.charCodeAt(0).toString(16)}`.slice(-2)}`}e.exports.decode=function(e){return function(e){return decodeURIComponent(Array.from(atob(e),r).join(""))}(e.replace(/-/g,"+").replace(/_/g,"/"))},e.exports.encode=function(e){return e&&"object"==typeof e?btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=+$/,""):function(e){return btoa(encodeURIComponent(e).replace(/%[0-9A-F]{2}/g,t))}(e).replace(/\//g,"_").replace(/\+/g,"-").replace(/=+$/,"")}},99:(e,t,r)=>{const n=r(219),o=r(215),i="ExtensionRequestNonce";let s=null;e.exports=class{constructor(e,t){if(this.extensionId=t,!e)throw Error('Missing required property "authressCustomDomain" in ExtensionClient constructor. The Custom Authress Domain Host is required.');if(!t)throw Error('Missing required property "extensionId" in ExtensionClient constructor. The extension is required for selecting the correct login method.');this.authressCustomDomain=`https://${e.replace(/^(https?:\/+)/,"")}`,this.accessToken=null,window.onload=async()=>{await this.requestToken({silent:!0})}}async getUserIdentity(){const e=await this.accessToken&&o.decode(this.accessToken);return e?1e3*e.exp<Date.now()?(this.accessToken=null,null):e:null}async getTokenResponse(){return await this.getUserIdentity()?{accessToken:this.accessToken}:null}requestToken(e={code:null,silent:!1}){if(s)return s=s.catch((()=>{})).then((()=>this.requestTokenContinuation(e)));const t=this.requestTokenContinuation(e);return t.catch((()=>{})),s=t}async requestTokenContinuation(e={code:null,silent:!1}){const t=e&&e.code||new URLSearchParams(window.location.search).get("code");if(!t){if(!e||!e.silent){const e=Error("OAuth Authorization code is required");throw e.code="InvalidAuthorizationCode",e}return this.getTokenResponse()}const r=new URL(this.authressCustomDomain);r.pathname="/api/authentication/oauth/tokens";const{codeVerifier:n,redirectUrl:o}=JSON.parse(localStorage.getItem(i)||"{}"),s=await fetch(r.toString(),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code_verifier:n,code:t,grant_type:"authorization_code",client_id:this.extensionId,redirect_uri:o})}),a=await s.json();this.accessToken=a.access_token;const c=new URL(window.location);return c.searchParams.delete("code"),c.searchParams.delete("iss"),c.searchParams.delete("nonce"),c.searchParams.delete("expires_in"),c.searchParams.delete("access_token"),c.searchParams.delete("id_token"),history.replaceState({},void 0,c.toString()),this.getTokenResponse()}async login(e){const t=await this.getTokenResponse();if(t)return t;const r=await this.requestToken({silent:!0});if(r)return r;const o=new URL(this.authressCustomDomain),s=n.encode((window.crypto||window.msCrypto).getRandomValues(new Uint32Array(16)).toString()),a=await(window.crypto||window.msCrypto).subtle.digest("SHA-256",(new TextEncoder).encode(s)),c=n.encode(a),u=e||window.location.href;return localStorage.setItem(i,JSON.stringify({codeVerifier:s,redirectUrl:u})),o.searchParams.set("client_id",this.extensionId),o.searchParams.set("code_challenge",c),o.searchParams.set("code_challenge_method","S256"),o.searchParams.set("redirect_uri",u),window.location.assign(o.toString()),await new Promise((e=>setTimeout(e,5e3))),null}}},965:(e,t,r)=>{const n=r(669),o={"Content-Type":"application/json"};async function i(e){let t=null;for(let r=0;r<5;r++)try{return await e()}catch(e){if(t=e,"Network Error"===e.message||"ERR_NETWORK"===e.code||!e.status||e.status>=500){await new Promise((e=>setTimeout(e,10*2**r)));continue}throw e}throw t}e.exports=class{constructor(e,t){if(!e)throw Error("Custom Authress Domain Host is required");const r=t||{debug(){},warn(){},critical(){}},o=`${new URL(`https://${e.replace(/^(https?:\/+)/,"")}`).origin}/api`,i=n.create({baseURL:o});i.interceptors.request.use((e=>(r.debug({title:"HttpClient Request",online:navigator.onLine,requestId:e.requestId,method:e.method,url:e.url}),e)),(e=>{let t,n,o=!1,i=e;e&&(i=e.message,e.response?(i={data:e.response.data,status:e.response.status,headers:e.response.headers},o=404===e.response.status):e.message&&(i={message:e.message,code:e.code,stack:e.stack}),e.config?(t=e.config.url,n=e.config.requestId):n=e.request&&e.request.config&&e.request.config.requestId);const s={title:"HttpClient Request Error",url:t,online:navigator.onLine,requestId:n,exception:i};throw o?r.debug(s):r.warn(s),i})),i.interceptors.response.use((e=>e),(e=>{if(e.re)throw e;const t=e&&e.response&&{url:e.config&&e.config.url,data:e.response.data,status:e.response.status,headers:e.response.headers}||e.message&&{message:e.message,code:e.code,stack:e.stack}||e;t.re=!0;const n=e&&(e.config&&e.config.requestId||e.request&&e.request.config&&e.request.config.requestId);let o="HttpClient Response Error",i="warn";throw e?e.response&&404===e.response.status?i="debug":e.response&&401===e.response.status&&(o="HttpClient Response Error due to invalid token"):o="HttpClient Response Error - Unknown error occurred",r[i]({title:o,online:navigator.onLine,requestId:n,exception:t,url:e&&e.config&&e.config.url}),t})),this.client=i}get(e,t,r,n="json"){return i((()=>this.client.get(e.toString(),{withCredentials:"localhost"!==window.location.hostname&&!!t,headers:Object.assign({},o,r),responseType:n})))}delete(e,t,r,n="json"){return i((()=>this.client.delete(e.toString(),{withCredentials:"localhost"!==window.location.hostname&&!!t,headers:Object.assign({},o,r),responseType:n})))}post(e,t,r,n){return i((()=>this.client.post(e.toString(),r,{withCredentials:"localhost"!==window.location.hostname&&!!t,headers:Object.assign({},o,n)})))}put(e,t,r,n){return i((()=>this.client.put(e.toString(),r,{withCredentials:"localhost"!==window.location.hostname&&!!t,headers:Object.assign({},o,n)})))}patch(e,t,r,n){return i((()=>this.client.patch(e.toString(),r,{withCredentials:"localhost"!==window.location.hostname&&!!t,headers:Object.assign({},o,n)})))}}},125:(e,t,r)=>{const n=r(489),o=r(802),i=r(965),s=r(215),a=r(429);let c,u=new Promise((e=>c=e)),d=null;const l="AuthenticationRequestNonce";const p=r(99);e.exports={LoginClient:class{constructor(e,t){this.settings=Object.assign({applicationId:"app_default"},e),this.logger=t||console;const r=this.settings.authressLoginHostUrl||this.settings.authenticationServiceUrl||"";if(!r)throw Error('Missing required property "authressLoginHostUrl" in LoginClient constructor. Custom Authress Domain Host is required.');this.hostUrl=`https://${r.replace(/^(https?:\/+)/,"")}`,this.httpClient=new i(this.hostUrl),this.lastSessionCheck=0,this.enableCredentials=this.getMatchingDomainInfo(this.hostUrl,"undefined"!=typeof window?window:void 0),e.skipBackgroundCredentialsCheck||(window.onload=async()=>{await this.userSessionExists(!0)})}isLocalHost(){return"undefined"!=typeof window&&window.location&&("localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname)}getMatchingDomainInfo(e,t){const r=new URL(e);if(this.isLocalHost())return!1;if(void 0===t)return!1;if("https:"!==t.location.protocol)return!1;const n=r.host.toLowerCase().split(".").reverse(),i=t.location.host.toLowerCase().split(".").reverse();let s=[];for(let e of n){const t=o(i,s.length+1).join(".");if(s.concat(e).join(".")!==t)break;s.push(e)}return s.length===n.length&&s.length===i.length||s.length>1}getUserIdentity(){const e=a.getUserCookie(),t=s.decodeOrParse(e);if(t){const r=t.exp?new Date(1e3*t.exp):new Date(Date.now()+864e5);return a.set(e,r),t.userId=t.sub,t}const r=a.get(),n=s.decodeOrParse(r);return n?(n.userId=n.sub,n):null}async getConnectionCredentials(){await this.waitForUserSession();try{const e=await this.ensureToken();return(await this.httpClient.get("/session/credentials",this.enableCredentials,{Authorization:e&&`Bearer ${e}`})).data}catch(e){return null}}async waitForUserSession(){try{return await u,!0}catch(e){return!1}}userSessionExists(e){return d?Date.now()-this.lastSessionCheck<50?d:(this.lastSessionCheck=Date.now(),d=d.catch((()=>{})).then((()=>this.userSessionContinuation(e)))):(this.lastSessionCheck=Date.now(),d=this.userSessionContinuation(e))}async userSessionContinuation(e){const t=new URLSearchParams(window.location.search),r=new URL(window.location);let o={};try{o=JSON.parse(localStorage.getItem(l)||"{}"),localStorage.removeItem(l),Object.hasOwnProperty.call(o,"enableCredentials")&&(this.enableCredentials=o.enableCredentials)}catch(e){this.logger&&this.logger.debug&&this.logger.debug({title:"LocalStorage failed in Browser",error:e})}if(t.get("state")&&"oauthLogin"===t.get("flow"))return!1;if(o.nonce&&t.get("code")&&(r.searchParams.delete("nonce"),r.searchParams.delete("iss"),r.searchParams.delete("code"),history.replaceState({},void 0,r.toString()),o.nonce===t.get("nonce"))){const e="cookie"===t.get("code")?n.parse(document.cookie)["auth-code"]:t.get("code"),r={grant_type:"authorization_code",redirect_uri:o.redirectUrl,client_id:this.settings.applicationId,code:e,code_verifier:o.codeVerifier};try{const e=await this.httpClient.post(`/authentication/${o.nonce}/tokens`,this.enableCredentials,r),t=s.decode(e.data.id_token),i=t.exp&&new Date(1e3*t.exp)||e.data.expires_in&&new Date(Date.now()+1e3*e.data.expires_in);return document.cookie=n.serialize("authorization",e.data.access_token||"",{expires:i,path:"/",sameSite:"strict"}),a.set(e.data.id_token,i),c(),!0}catch(e){if(e.data&&"invalid_request"===e.data.error)return this.logger&&this.logger.log({title:"Failed exchange authentication response for a token.",error:e}),!1;throw e.data||e}}if(this.isLocalHost()&&t.get("nonce")&&t.get("access_token")&&(r.searchParams.delete("iss"),r.searchParams.delete("nonce"),r.searchParams.delete("expires_in"),r.searchParams.delete("access_token"),r.searchParams.delete("id_token"),history.replaceState({},void 0,r.toString()),!o.nonce||o.nonce===t.get("nonce"))){const e=s.decode(t.get("id_token")),r=e.exp&&new Date(1e3*e.exp)||Number(t.get("expires_in"))&&new Date(Date.now()+1e3*Number(t.get("expires_in")));return document.cookie=n.serialize("authorization",t.get("access_token")||"",{expires:r,path:"/",sameSite:"strict"}),a.set(t.get("id_token"),r),c(),!0}if(this.getUserIdentity())return c(),!0;if(!this.isLocalHost()&&!e){try{const e=await this.httpClient.patch("/session",this.enableCredentials,{});if(e.data.access_token){const t=s.decode(e.data.id_token),r=t.exp&&new Date(1e3*t.exp)||e.data.expires_in&&new Date(Date.now()+1e3*e.data.expires_in);document.cookie=n.serialize("authorization",e.data.access_token||"",{expires:r,path:"/",sameSite:"strict"}),a.set(e.data.id_token,r)}}catch(e){400!==e.status&&404!==e.status&&409!==e.status&&this.logger&&this.logger.log({title:"Failed attempting to check if the user has an existing authentication session",error:e})}if(this.getUserIdentity())return c(),!0}return!1}async updateExtensionAuthenticationRequest({state:e,connectionId:t,tenantLookupIdentifier:r,connectionProperties:n}){if(!t&&!r){const e=Error("connectionId or tenantLookupIdentifier must be specified");throw e.code="InvalidConnection",e}const o=new URLSearchParams(window.location.search),i=e||o.get("state");if(!i){const e=Error("The `state` parameters must be specified to update this authentication request");throw e.code="InvalidAuthenticationRequest",e}try{const e=await this.httpClient.patch(`/authentication/${i}`,!0,{connectionId:t,tenantLookupIdentifier:r,connectionProperties:n});window.location.assign(e.data.authenticationUrl)}catch(e){if(e.status>=400&&e.status<500){const t=Error(e.data.title||e.data.errorCode);throw t.code=e.data.errorCode,t}throw e.data||e}await new Promise((e=>setTimeout(e,5e3)))}async unlinkIdentity(e){if(!e){const e=Error("connectionId must be specified");throw e.code="InvalidConnection",e}if(!this.getUserIdentity()){const e=Error("User must be logged into to unlink an account.");throw e.code="NotLoggedIn",e}let t;try{t=await this.ensureToken({timeoutInMillis:100})}catch(e){if("TokenTimeout"===e.code){const e=Error("User must be logged into an existing account before linking a second account.");throw e.code="NotLoggedIn",e}}const r=this.enableCredentials&&!this.isLocalHost()?{}:{Authorization:`Bearer ${t}`};try{await this.httpClient.delete(`/identities/${encodeURIComponent(e)}`,this.enableCredentials,r)}catch(e){if(e.status>=400&&e.status<500){const t=Error(e.data.title||e.data.errorCode);throw t.code=e.data.errorCode,t}throw e.data||e}}async linkIdentity({connectionId:e,tenantLookupIdentifier:t,redirectUrl:r,connectionProperties:n}){if(!e&&!t){const e=Error("connectionId or tenantLookupIdentifier must be specified");throw e.code="InvalidConnection",e}if(!this.getUserIdentity()){const e=Error("User must be logged into an existing account before linking a second account.");throw e.code="NotLoggedIn",e}let o;try{o=await this.ensureToken({timeoutInMillis:100})}catch(e){if("TokenTimeout"===e.code){const e=Error("User must be logged into an existing account before linking a second account.");throw e.code="NotLoggedIn",e}}const{codeChallenge:i}=await s.getAuthCodes();try{const s=r&&new URL(r).toString()||window.location.href,a=this.enableCredentials&&!this.isLocalHost()?{}:{Authorization:`Bearer ${o}`},c=await this.httpClient.post("/authentication",this.enableCredentials,{linkIdentity:!0,redirectUrl:s,codeChallengeMethod:"S256",codeChallenge:i,connectionId:e,tenantLookupIdentifier:t,connectionProperties:n,applicationId:this.settings.applicationId},a);window.location.assign(c.data.authenticationUrl)}catch(e){if(e.status>=400&&e.status<500){const t=Error(e.data.title||e.data.errorCode);throw t.code=e.data.errorCode,t}throw e}await new Promise((e=>setTimeout(e,5e3)))}async authenticate(e={}){const{connectionId:t,tenantLookupIdentifier:r,inviteId:n,redirectUrl:o,force:i,responseLocation:c,flowType:u,connectionProperties:d,openType:p,multiAccount:h,clearUserDataBeforeLogin:f}=e||{};if(c&&"cookie"!==c&&"query"!==c&&"none"!==c){const e=Error("Authentication response location is not valid");throw e.code="InvalidResponseLocation",e}if(!i&&!h&&await this.userSessionExists())return!0;const{codeVerifier:m,codeChallenge:g}=await s.getAuthCodes();try{const e=o&&new URL(o).toString()||window.location.href;!1!==f&&a.clear();const i=await this.httpClient.post("/authentication",!1,{redirectUrl:e,codeChallengeMethod:"S256",codeChallenge:g,connectionId:t,tenantLookupIdentifier:r,inviteId:n,connectionProperties:d,applicationId:this.settings.applicationId,responseLocation:c,flowType:u,multiAccount:h});if(localStorage.setItem(l,JSON.stringify({nonce:i.data.authenticationRequestId,codeVerifier:m,lastConnectionId:t,tenantLookupIdentifier:r,redirectUrl:e,enableCredentials:i.data.enableCredentials,multiAccount:h})),"tab"===p){const e=window.open(i.data.authenticationUrl,"_blank");e&&!e.closed&&void 0!==e.closed||window.location.assign(i.data.authenticationUrl)}else window.location.assign(i.data.authenticationUrl)}catch(e){if(e.status>=400&&e.status<500){const t=Error(e.data.title||e.data.errorCode);throw t.code=e.data.errorCode,t}throw e.data||e}return await new Promise((e=>setTimeout(e,5e3))),!1}async ensureToken(e){await this.userSessionExists();const t=Object.assign({timeoutInMillis:5e3},e||{}),r=this.waitForUserSession(),o=new Promise(((e,r)=>setTimeout(r,t.timeoutInMillis||0)));try{await Promise.race([r,o])}catch(e){const t=Error("No token retrieved after timeout");throw t.code="TokenTimeout",t}const i=n.parse(document.cookie);return"undefined"!==i.authorization&&i.authorization}async logout(e){if(a.clear(),u=new Promise((e=>c=e)),this.enableCredentials)try{return await this.httpClient.delete("/session",this.enableCredentials),void(e&&e!==window.location.href&&window.location.assign(e))}catch(e){}const t=new URL("/logout",this.hostUrl);t.searchParams.set("redirect_uri",e||window.location.href),t.searchParams.set("client_id",this.settings.applicationId),window.location.assign(t.toString())}},ExtensionClient:p}},215:(e,t,r)=>{const n=r(219);e.exports=new class{decode(e){if(!e)return null;try{const t=JSON.parse(n.decode(e.split(".")[1]));return t.exp&&(t.exp=t.exp-10),t}catch(e){return null}}decodeOrParse(e){if(!e)return null;if("object"==typeof e)return e;try{return JSON.parse(e)}catch(t){return this.decode(e)}}decodeFull(e){if(!e)return null;try{const t=JSON.parse(n.decode(e.split(".")[0])),r=JSON.parse(n.decode(e.split(".")[1]));return r.exp&&(r.exp=r.exp-10),{header:t,payload:r}}catch(e){return null}}async getAuthCodes(){const e=n.encode((window.crypto||window.msCrypto).getRandomValues(new Uint32Array(16)).toString()),t=await(window.crypto||window.msCrypto).subtle.digest("SHA-256",(new TextEncoder).encode(e));return{codeVerifier:e,codeChallenge:n.encode(t)}}}},429:(e,t,r)=>{const n=r(489),o="AuthenticationCredentialsStorage";e.exports=new class{getUserCookie(){return document.cookie.split(";").filter((e=>"user"===e.split("=")[0].trim())).map((e=>e.replace(/^user=/,""))).find((e=>e&&e.trim()))||null}set(e,t){try{const r=n.parse(document.cookie);localStorage.setItem(o,JSON.stringify({idToken:e,expiry:t&&t.getTime(),jsCookies:!!r.authorization})),this.clearCookies("user")}catch(e){console.debug("LocalStorage failed in Browser",e)}}get(){let e={};try{e=n.parse(document.cookie)}catch(e){console.debug("CookieManagement failed in Browser",e)}try{const{idToken:t,expiry:r,jsCookies:n}=JSON.parse(localStorage.getItem(o)||"{}");return t?r<Date.now()||n&&!e.authorization?null:t:this.getUserCookie()}catch(e){return console.debug("LocalStorage failed in Browser",e),this.getUserCookie()}}delete(){try{localStorage.removeItem(o)}catch(e){console.debug("LocalStorage failed in Browser",e)}try{this.clearCookies("user")}catch(e){console.debug("CookieManagement failed in Browser",e)}}clear(){this.clearCookies(),this.delete()}clearCookies(e){if("undefined"==typeof window)return;const t=document.cookie.split("; ");for(const r of t){if(!["user","authorization","auth-code"].includes(r.split("=")[0])||e&&r.split("=")[0]!==e)continue;const t=window.location.hostname.split("."),n=[...Array(t.length-1)].map(((e,r)=>t.reverse().slice(0,r+2).reverse().join("."))).map((e=>[e,`.${e}`])).flat(1).concat(null);"localhost"===window.location.hostname&&n.push("localhost");for(const e of n){const t=e?`domain=${e};`:"",n=`${encodeURIComponent(r.split(";")[0].split("=")[0])}=; expires=Thu, 01-Jan-1970 00:00:01 GMT; ${t} SameSite=Strict; path=`;document.cookie=`${n}/`;const o=location.pathname.split("/");for(;o.length>0;)document.cookie=n+o.join("/"),o.pop()}}}}},489:(e,t)=>{"use strict";t.parse=function(e,t){if("string"!=typeof e)throw new TypeError("argument str must be a string");var r={},n=(t||{}).decode||o,i=0;for(;i<e.length;){var a=e.indexOf("=",i);if(-1===a)break;var c=e.indexOf(";",i);if(-1===c)c=e.length;else if(c<a){i=e.lastIndexOf(";",a-1)+1;continue}var u=e.slice(i,a).trim();if(void 0===r[u]){var d=e.slice(a+1,c).trim();34===d.charCodeAt(0)&&(d=d.slice(1,-1)),r[u]=s(d,n)}i=c+1}return r},t.serialize=function(e,t,o){var s=o||{},a=s.encode||i;if("function"!=typeof a)throw new TypeError("option encode is invalid");if(!n.test(e))throw new TypeError("argument name is invalid");var c=a(t);if(c&&!n.test(c))throw new TypeError("argument val is invalid");var u=e+"="+c;if(null!=s.maxAge){var d=s.maxAge-0;if(isNaN(d)||!isFinite(d))throw new TypeError("option maxAge is invalid");u+="; Max-Age="+Math.floor(d)}if(s.domain){if(!n.test(s.domain))throw new TypeError("option domain is invalid");u+="; Domain="+s.domain}if(s.path){if(!n.test(s.path))throw new TypeError("option path is invalid");u+="; Path="+s.path}if(s.expires){var l=s.expires;if(!function(e){return"[object Date]"===r.call(e)||e instanceof Date}(l)||isNaN(l.valueOf()))throw new TypeError("option expires is invalid");u+="; Expires="+l.toUTCString()}s.httpOnly&&(u+="; HttpOnly");s.secure&&(u+="; Secure");if(s.priority){switch("string"==typeof s.priority?s.priority.toLowerCase():s.priority){case"low":u+="; Priority=Low";break;case"medium":u+="; Priority=Medium";break;case"high":u+="; Priority=High";break;default:throw new TypeError("option priority is invalid")}}if(s.sameSite){switch("string"==typeof s.sameSite?s.sameSite.toLowerCase():s.sameSite){case!0:u+="; SameSite=Strict";break;case"lax":u+="; SameSite=Lax";break;case"strict":u+="; SameSite=Strict";break;case"none":u+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return u};var r=Object.prototype.toString,n=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function o(e){return-1!==e.indexOf("%")?decodeURIComponent(e):e}function i(e){return encodeURIComponent(e)}function s(e,t){try{return t(e)}catch(t){return e}}},802:e=>{var t=1/0,r=17976931348623157e292,n=NaN,o="[object Symbol]",i=/^\s+|\s+$/g,s=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,c=/^0o[0-7]+$/i,u=parseInt,d=Object.prototype.toString;function l(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}e.exports=function(e,p,h){return e&&e.length?function(e,t,r){var n=-1,o=e.length;t<0&&(t=-t>o?0:o+t),(r=r>o?o:r)<0&&(r+=o),o=t>r?0:r-t>>>0,t>>>=0;for(var i=Array(o);++n<o;)i[n]=e[n+t];return i}(e,0,(p=h||void 0===p?1:(f=function(e){return e?(e=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&d.call(e)==o}(e))return n;if(l(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=l(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(i,"");var r=a.test(e);return r||c.test(e)?u(e.slice(2),r?2:8):s.test(e)?n:+e}(e))===t||e===-t?(e<0?-1:1)*r:e==e?e:0:0===e?e:0}(p),m=f%1,f==f?m?f-m:f:0))<0?0:p):[];var f,m}},593:e=>{"use strict";e.exports=JSON.parse('{"_from":"axios@^0.21","_id":"axios@0.21.4","_inBundle":false,"_integrity":"sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==","_location":"/axios","_phantomChildren":{},"_requested":{"type":"range","registry":true,"raw":"axios@^0.21","name":"axios","escapedName":"axios","rawSpec":"^0.21","saveSpec":null,"fetchSpec":"^0.21"},"_requiredBy":["/"],"_resolved":"https://registry.npmjs.org/axios/-/axios-0.21.4.tgz","_shasum":"c67b90dc0568e5c1cf2b0b858c43ba28e2eda575","_spec":"axios@^0.21","_where":"/home/runner/work/authress-login.js/authress-login.js","author":{"name":"Matt Zabriskie"},"browser":{"./lib/adapters/http.js":"./lib/adapters/xhr.js"},"bugs":{"url":"https://github.com/axios/axios/issues"},"bundleDependencies":false,"bundlesize":[{"path":"./dist/axios.min.js","threshold":"5kB"}],"dependencies":{"follow-redirects":"^1.14.0"},"deprecated":false,"description":"Promise based HTTP client for the browser and node.js","devDependencies":{"coveralls":"^3.0.0","es6-promise":"^4.2.4","grunt":"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1","karma":"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2","minimist":"^1.2.0","mocha":"^8.2.1","sinon":"^4.5.0","terser-webpack-plugin":"^4.2.3","typescript":"^4.0.5","url-search-params":"^0.10.0","webpack":"^4.44.2","webpack-dev-server":"^3.11.0"},"homepage":"https://axios-http.com","jsdelivr":"dist/axios.min.js","keywords":["xhr","http","ajax","promise","node"],"license":"MIT","main":"index.js","name":"axios","repository":{"type":"git","url":"git+https://github.com/axios/axios.git"},"scripts":{"build":"NODE_ENV=production grunt build","coveralls":"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js","examples":"node ./examples/server.js","fix":"eslint --fix lib/**/*.js","postversion":"git push && git push --tags","preversion":"npm test","start":"node ./sandbox/server.js","test":"grunt test","version":"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json"},"typings":"./index.d.ts","unpkg":"dist/axios.min.js","version":"0.21.4"}')}},n={};function o(e){var t=n[e];if(void 0!==t){if(void 0!==t.error)throw t.error;return t.exports}var i=n[e]={exports:{}};try{var s={id:e,module:i,factory:r[e],require:o};o.i.forEach((function(e){e(s)})),i=s.module,s.factory.call(i.exports,i,i.exports,s.require)}catch(e){throw i.error=e,e}return i.exports}return o.m=r,o.c=n,o.i=[],o.hu=e=>e+"."+o.h()+".hot-update.js",o.hmrF=()=>"main."+o.h()+".hot-update.json",o.h=()=>"9b2b47a6ee53141228d0",o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e={},t="authress:",o.l=(r,n,i,s)=>{if(e[r])e[r].push(n);else{var a,c;if(void 0!==i)for(var u=document.getElementsByTagName("script"),d=0;d<u.length;d++){var l=u[d];if(l.getAttribute("src")==r||l.getAttribute("data-webpack")==t+i){a=l;break}}a||(c=!0,(a=document.createElement("script")).charset="utf-8",a.timeout=120,o.nc&&a.setAttribute("nonce",o.nc),a.setAttribute("data-webpack",t+i),a.src=r),e[r]=[n];var p=(t,n)=>{a.onerror=a.onload=null,clearTimeout(h);var o=e[r];if(delete e[r],a.parentNode&&a.parentNode.removeChild(a),o&&o.forEach((e=>e(n))),t)return t(n)},h=setTimeout(p.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=p.bind(null,a.onerror),a.onload=p.bind(null,a.onload),c&&document.head.appendChild(a)}},(()=>{var e,t,r,n={},i=o.c,s=[],a=[],c="idle",u=0,d=[];function l(e){c=e;for(var t=[],r=0;r<a.length;r++)t[r]=a[r].call(null,e);return Promise.all(t)}function p(){0==--u&&l("ready").then((function(){if(0===u){var e=d;d=[];for(var t=0;t<e.length;t++)e[t]()}}))}function h(e){if("idle"!==c)throw new Error("check() is only allowed in idle status");return l("check").then(o.hmrM).then((function(r){return r?l("prepare").then((function(){var n=[];return t=[],Promise.all(Object.keys(o.hmrC).reduce((function(e,i){return o.hmrC[i](r.c,r.r,r.m,e,t,n),e}),[])).then((function(){return t=function(){return e?m(e):l("ready").then((function(){return n}))},0===u?t():new Promise((function(e){d.push((function(){e(t())}))}));var t}))})):l(g()?"ready":"idle").then((function(){return null}))}))}function f(e){return"ready"!==c?Promise.resolve().then((function(){throw new Error("apply() is only allowed in ready status (state: "+c+")")})):m(e)}function m(e){e=e||{},g();var n=t.map((function(t){return t(e)}));t=void 0;var o=n.map((function(e){return e.error})).filter(Boolean);if(o.length>0)return l("abort").then((function(){throw o[0]}));var i=l("dispose");n.forEach((function(e){e.dispose&&e.dispose()}));var s,a=l("apply"),c=function(e){s||(s=e)},u=[];return n.forEach((function(e){if(e.apply){var t=e.apply(c);if(t)for(var r=0;r<t.length;r++)u.push(t[r])}})),Promise.all([i,a]).then((function(){return s?l("fail").then((function(){throw s})):r?m(e).then((function(e){return u.forEach((function(t){e.indexOf(t)<0&&e.push(t)})),e})):l("idle").then((function(){return u}))}))}function g(){if(r)return t||(t=[]),Object.keys(o.hmrI).forEach((function(e){r.forEach((function(r){o.hmrI[e](r,t)}))})),r=void 0,!0}o.hmrD=n,o.i.push((function(d){var m,g,w,y,v=d.module,b=function(t,r){var n=i[r];if(!n)return t;var o=function(o){if(n.hot.active){if(i[o]){var a=i[o].parents;-1===a.indexOf(r)&&a.push(r)}else s=[r],e=o;-1===n.children.indexOf(o)&&n.children.push(o)}else console.warn("[HMR] unexpected require("+o+") from disposed module "+r),s=[];return t(o)},a=function(e){return{configurable:!0,enumerable:!0,get:function(){return t[e]},set:function(r){t[e]=r}}};for(var d in t)Object.prototype.hasOwnProperty.call(t,d)&&"e"!==d&&Object.defineProperty(o,d,a(d));return o.e=function(e){return function(e){switch(c){case"ready":l("prepare");case"prepare":return u++,e.then(p,p),e;default:return e}}(t.e(e))},o}(d.require,d.id);v.hot=(m=d.id,g=v,y={_acceptedDependencies:{},_acceptedErrorHandlers:{},_declinedDependencies:{},_selfAccepted:!1,_selfDeclined:!1,_selfInvalidated:!1,_disposeHandlers:[],_main:w=e!==m,_requireSelf:function(){s=g.parents.slice(),e=w?void 0:m,o(m)},active:!0,accept:function(e,t,r){if(void 0===e)y._selfAccepted=!0;else if("function"==typeof e)y._selfAccepted=e;else if("object"==typeof e&&null!==e)for(var n=0;n<e.length;n++)y._acceptedDependencies[e[n]]=t||function(){},y._acceptedErrorHandlers[e[n]]=r;else y._acceptedDependencies[e]=t||function(){},y._acceptedErrorHandlers[e]=r},decline:function(e){if(void 0===e)y._selfDeclined=!0;else if("object"==typeof e&&null!==e)for(var t=0;t<e.length;t++)y._declinedDependencies[e[t]]=!0;else y._declinedDependencies[e]=!0},dispose:function(e){y._disposeHandlers.push(e)},addDisposeHandler:function(e){y._disposeHandlers.push(e)},removeDisposeHandler:function(e){var t=y._disposeHandlers.indexOf(e);t>=0&&y._disposeHandlers.splice(t,1)},invalidate:function(){switch(this._selfInvalidated=!0,c){case"idle":t=[],Object.keys(o.hmrI).forEach((function(e){o.hmrI[e](m,t)})),l("ready");break;case"ready":Object.keys(o.hmrI).forEach((function(e){o.hmrI[e](m,t)}));break;case"prepare":case"check":case"dispose":case"apply":(r=r||[]).push(m)}},check:h,apply:f,status:function(e){if(!e)return c;a.push(e)},addStatusHandler:function(e){a.push(e)},removeStatusHandler:function(e){var t=a.indexOf(e);t>=0&&a.splice(t,1)},data:n[m]},e=void 0,y),v.parents=s,v.children=[],s=[],d.require=b})),o.hmrC={},o.hmrI={}})(),o.p="",(()=>{var e,t,r,n,i,s=o.hmrS_jsonp=o.hmrS_jsonp||{179:0},a={};function c(t,r){return e=r,new Promise(((e,r)=>{a[t]=e;var n=o.p+o.hu(t),i=new Error;o.l(n,(e=>{if(a[t]){a[t]=void 0;var n=e&&("load"===e.type?"missing":e.type),o=e&&e.target&&e.target.src;i.message="Loading hot update chunk "+t+" failed.\n("+n+": "+o+")",i.name="ChunkLoadError",i.type=n,i.request=o,r(i)}}))}))}function u(e){function a(e){for(var t=[e],r={},n=t.map((function(e){return{chain:[e],id:e}}));n.length>0;){var i=n.pop(),s=i.id,a=i.chain,u=o.c[s];if(u&&(!u.hot._selfAccepted||u.hot._selfInvalidated)){if(u.hot._selfDeclined)return{type:"self-declined",chain:a,moduleId:s};if(u.hot._main)return{type:"unaccepted",chain:a,moduleId:s};for(var d=0;d<u.parents.length;d++){var l=u.parents[d],p=o.c[l];if(p){if(p.hot._declinedDependencies[s])return{type:"declined",chain:a.concat([l]),moduleId:s,parentId:l};-1===t.indexOf(l)&&(p.hot._acceptedDependencies[s]?(r[l]||(r[l]=[]),c(r[l],[s])):(delete r[l],t.push(l),n.push({chain:a.concat([l]),id:l})))}}}}return{type:"accepted",moduleId:e,outdatedModules:t,outdatedDependencies:r}}function c(e,t){for(var r=0;r<t.length;r++){var n=t[r];-1===e.indexOf(n)&&e.push(n)}}o.f&&delete o.f.jsonpHmr,t=void 0;var u={},d=[],l={},p=function(e){console.warn("[HMR] unexpected require("+e.id+") to disposed module")};for(var h in r)if(o.o(r,h)){var f,m=r[h],g=!1,w=!1,y=!1,v="";switch((f=m?a(h):{type:"disposed",moduleId:h}).chain&&(v="\nUpdate propagation: "+f.chain.join(" -> ")),f.type){case"self-declined":e.onDeclined&&e.onDeclined(f),e.ignoreDeclined||(g=new Error("Aborted because of self decline: "+f.moduleId+v));break;case"declined":e.onDeclined&&e.onDeclined(f),e.ignoreDeclined||(g=new Error("Aborted because of declined dependency: "+f.moduleId+" in "+f.parentId+v));break;case"unaccepted":e.onUnaccepted&&e.onUnaccepted(f),e.ignoreUnaccepted||(g=new Error("Aborted because "+h+" is not accepted"+v));break;case"accepted":e.onAccepted&&e.onAccepted(f),w=!0;break;case"disposed":e.onDisposed&&e.onDisposed(f),y=!0;break;default:throw new Error("Unexception type "+f.type)}if(g)return{error:g};if(w)for(h in l[h]=m,c(d,f.outdatedModules),f.outdatedDependencies)o.o(f.outdatedDependencies,h)&&(u[h]||(u[h]=[]),c(u[h],f.outdatedDependencies[h]));y&&(c(d,[f.moduleId]),l[h]=p)}r=void 0;for(var b,x=[],k=0;k<d.length;k++){var C=d[k],S=o.c[C];S&&(S.hot._selfAccepted||S.hot._main)&&l[C]!==p&&!S.hot._selfInvalidated&&x.push({module:C,require:S.hot._requireSelf,errorHandler:S.hot._selfAccepted})}return{dispose:function(){var e;n.forEach((function(e){delete s[e]})),n=void 0;for(var t,r=d.slice();r.length>0;){var i=r.pop(),a=o.c[i];if(a){var c={},l=a.hot._disposeHandlers;for(k=0;k<l.length;k++)l[k].call(null,c);for(o.hmrD[i]=c,a.hot.active=!1,delete o.c[i],delete u[i],k=0;k<a.children.length;k++){var p=o.c[a.children[k]];p&&((e=p.parents.indexOf(i))>=0&&p.parents.splice(e,1))}}}for(var h in u)if(o.o(u,h)&&(a=o.c[h]))for(b=u[h],k=0;k<b.length;k++)t=b[k],(e=a.children.indexOf(t))>=0&&a.children.splice(e,1)},apply:function(t){for(var r in l)o.o(l,r)&&(o.m[r]=l[r]);for(var n=0;n<i.length;n++)i[n](o);for(var s in u)if(o.o(u,s)){var a=o.c[s];if(a){b=u[s];for(var c=[],p=[],h=[],f=0;f<b.length;f++){var m=b[f],g=a.hot._acceptedDependencies[m],w=a.hot._acceptedErrorHandlers[m];if(g){if(-1!==c.indexOf(g))continue;c.push(g),p.push(w),h.push(m)}}for(var y=0;y<c.length;y++)try{c[y].call(null,b)}catch(r){if("function"==typeof p[y])try{p[y](r,{moduleId:s,dependencyId:h[y]})}catch(n){e.onErrored&&e.onErrored({type:"accept-error-handler-errored",moduleId:s,dependencyId:h[y],error:n,originalError:r}),e.ignoreErrored||(t(n),t(r))}else e.onErrored&&e.onErrored({type:"accept-errored",moduleId:s,dependencyId:h[y],error:r}),e.ignoreErrored||t(r)}}}for(var v=0;v<x.length;v++){var k=x[v],C=k.module;try{k.require(C)}catch(r){if("function"==typeof k.errorHandler)try{k.errorHandler(r,{moduleId:C,module:o.c[C]})}catch(n){e.onErrored&&e.onErrored({type:"self-accept-error-handler-errored",moduleId:C,error:n,originalError:r}),e.ignoreErrored||(t(n),t(r))}else e.onErrored&&e.onErrored({type:"self-accept-errored",moduleId:C,error:r}),e.ignoreErrored||t(r)}}return d}}}this.webpackHotUpdateauthress=(t,n,s)=>{for(var c in n)o.o(n,c)&&(r[c]=n[c],e&&e.push(c));s&&i.push(s),a[t]&&(a[t](),a[t]=void 0)},o.hmrI.jsonp=function(e,t){r||(r={},i=[],n=[],t.push(u)),o.o(r,e)||(r[e]=o.m[e])},o.hmrC.jsonp=function(e,a,d,l,p,h){p.push(u),t={},n=a,r=d.reduce((function(e,t){return e[t]=!1,e}),{}),i=[],e.forEach((function(e){o.o(s,e)&&void 0!==s[e]?(l.push(c(e,h)),t[e]=!0):t[e]=!1})),o.f&&(o.f.jsonpHmr=function(e,r){t&&o.o(t,e)&&!t[e]&&(r.push(c(e)),t[e]=!0)})},o.hmrM=()=>{if("undefined"==typeof fetch)throw new Error("No browser support: need fetch API");return fetch(o.p+o.hmrF()).then((e=>{if(404!==e.status){if(!e.ok)throw new Error("Failed to fetch update manifest "+e.statusText);return e.json()}}))}})(),o(125)})()));
1
+ /*! Authress Login SDK 2.2.247 | Author - Authress Developers | License information can be found at https://github.com/Authress/login-sdk.js */
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.authress=t():e.authress=t()}(this,(()=>(()=>{var e,t,n={219:e=>{function t(e){return String.fromCharCode(parseInt(e.slice(1),16))}function n(e){return`%${`00${e.charCodeAt(0).toString(16)}`.slice(-2)}`}e.exports.decode=function(e){return function(e){return decodeURIComponent(Array.from(atob(e),n).join(""))}(e.replace(/-/g,"+").replace(/_/g,"/"))},e.exports.encode=function(e){return e&&"object"==typeof e?btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=+$/,""):function(e){return btoa(encodeURIComponent(e).replace(/%[0-9A-F]{2}/g,t))}(e).replace(/\//g,"_").replace(/\+/g,"-").replace(/=+$/,"")}},99:(e,t,n)=>{const o=n(219),r=n(215),i="ExtensionRequestNonce";let a=null;e.exports=class{constructor(e,t){if(this.extensionId=t,!e)throw Error('Missing required property "authressCustomDomain" in ExtensionClient constructor. The Custom Authress Domain Host is required.');if(!t)throw Error('Missing required property "extensionId" in ExtensionClient constructor. The extension is required for selecting the correct login method.');this.authressCustomDomain=`https://${e.replace(/^(https?:\/+)/,"")}`,this.accessToken=null,window.onload=async()=>{await this.requestToken({silent:!0})}}async getUserIdentity(){const e=await this.accessToken&&r.decode(this.accessToken);return e?1e3*e.exp<Date.now()?(this.accessToken=null,null):e:null}async getTokenResponse(){return await this.getUserIdentity()?{accessToken:this.accessToken}:null}requestToken(e={code:null,silent:!1}){if(a)return a=a.catch((()=>{})).then((()=>this.requestTokenContinuation(e)));const t=this.requestTokenContinuation(e);return t.catch((()=>{})),a=t}async requestTokenContinuation(e={code:null,silent:!1}){const t=e&&e.code||new URLSearchParams(window.location.search).get("code");if(!t){if(!e||!e.silent){const e=Error("OAuth Authorization code is required");throw e.code="InvalidAuthorizationCode",e}return this.getTokenResponse()}const n=new URL(this.authressCustomDomain);n.pathname="/api/authentication/oauth/tokens";const{codeVerifier:o,redirectUrl:r}=JSON.parse(localStorage.getItem(i)||"{}"),a=await fetch(n.toString(),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code_verifier:o,code:t,grant_type:"authorization_code",client_id:this.extensionId,redirect_uri:r})}),s=await a.json();this.accessToken=s.access_token;const c=new URL(window.location);return c.searchParams.delete("code"),c.searchParams.delete("iss"),c.searchParams.delete("nonce"),c.searchParams.delete("expires_in"),c.searchParams.delete("access_token"),c.searchParams.delete("id_token"),history.replaceState({},void 0,c.toString()),this.getTokenResponse()}async login(e){const t=await this.getTokenResponse();if(t)return t;const n=await this.requestToken({silent:!0});if(n)return n;const r=new URL(this.authressCustomDomain),a=o.encode((window.crypto||window.msCrypto).getRandomValues(new Uint32Array(16)).toString()),s=await(window.crypto||window.msCrypto).subtle.digest("SHA-256",(new TextEncoder).encode(a)),c=o.encode(s),d=e||window.location.href;return localStorage.setItem(i,JSON.stringify({codeVerifier:a,redirectUrl:d})),r.searchParams.set("client_id",this.extensionId),r.searchParams.set("code_challenge",c),r.searchParams.set("code_challenge_method","S256"),r.searchParams.set("redirect_uri",d),window.location.assign(r.toString()),await new Promise((e=>setTimeout(e,5e3))),null}}},965:e=>{const t={"Content-Type":"application/json"},n=new Set(["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed","fetch failed"]);function o(e){return!(!e||"TypeError"!==e.name||"string"!=typeof e.message)&&n.has(e.message)}async function r(e){let t=null;for(let n=0;n<5;n++)try{return await e()}catch(e){if(t=e,o(e)||"Network Error"===e.message||"ERR_NETWORK"===e.code||!e.status||e.status>=500){await new Promise((e=>setTimeout(e,10*2**n)));continue}throw e}throw t}e.exports=class{constructor(e,t){if(!e)throw Error("Custom Authress Domain Host is required");const n=t||{debug(){},warn(){},critical(){}};this.logger=n;const o=new URL(`https://${e.replace(/^(https?:\/+)/,"")}`);this.loginUrl=`${o.origin}/api`}get(e,t,n){return r((()=>this.fetchWrapper("GET",e,null,n,t)))}delete(e,t,n){return r((()=>this.fetchWrapper("DELETE",e,null,n,t)))}post(e,t,n,o){return r((()=>this.fetchWrapper("POST",e,n,o,t)))}put(e,t,n,o){return r((()=>this.fetchWrapper("PUT",e,n,o,t)))}patch(e,t,n,o){return r((()=>this.fetchWrapper("PATCH",e,n,o,t)))}async fetchWrapper(e,n,o,r,i){const a=`${this.loginUrl}${n.toString()}`,s=e.toUpperCase(),c=Object.assign({},t,r);try{this.logger.debug({title:"HttpClient Request",method:s,url:a});const e={method:s,headers:c};o&&(e.body=JSON.stringify(o)),"localhost"!==window.location.hostname&&i&&(e.credentials="include");const t=await fetch(a,e);if(!t.ok)throw t;return{url:a,headers:t.headers,status:t.status,data:await t.json()}}catch(e){const t="function"==typeof e.json?await e.json().catch((e=>e)):e,n=t.stack.match(/chrome-extension:[/][/](\w+)[/]/);if(n){this.logger.debug({title:`Fetch failed due to a browser extension - ${s} - ${a}`,method:s,url:a,data:o,headers:c,error:e,resolvedError:t,extensionErrorId:n});const r=new Error(`Extension Error ID: ${n}`);throw r.code="BROWSER_EXTENSION_ERROR",r}let r="HttpClient Response Error";throw e?e.response&&401===e.response.status&&(r="HttpClient Response Error due to invalid token"):r="HttpClient Response Error - Unknown error occurred",this.logger.warn({title:r,online:navigator.onLine,method:s,url:a,data:o,headers:c,error:e,resolvedError:t}),e||e}}}},125:(e,t,n)=>{const o=n(489),r=n(802),i=n(965),a=n(215),s=n(429);let c,d=new Promise((e=>c=e)),l=null;const u="AuthenticationRequestNonce";const h=n(99);e.exports={LoginClient:class{constructor(e,t){this.settings=Object.assign({applicationId:"app_default"},e),this.logger=t||console;const n=this.settings.authressLoginHostUrl||this.settings.authenticationServiceUrl||"";if(!n)throw Error('Missing required property "authressLoginHostUrl" in LoginClient constructor. Custom Authress Domain Host is required.');this.hostUrl=`https://${n.replace(/^(https?:\/+)/,"")}`,this.httpClient=new i(this.hostUrl),this.lastSessionCheck=0,this.enableCredentials=this.getMatchingDomainInfo(this.hostUrl,"undefined"!=typeof window?window:void 0),e.skipBackgroundCredentialsCheck||(window.onload=async()=>{await this.userSessionExists(!0)})}isLocalHost(){return"undefined"!=typeof window&&window.location&&("localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname)}getMatchingDomainInfo(e,t){const n=new URL(e);if(this.isLocalHost())return!1;if(void 0===t)return!1;if("https:"!==t.location.protocol)return!1;const o=n.host.toLowerCase().split(".").reverse(),i=t.location.host.toLowerCase().split(".").reverse();let a=[];for(let e of o){const t=r(i,a.length+1).join(".");if(a.concat(e).join(".")!==t)break;a.push(e)}return a.length===o.length&&a.length===i.length||a.length>1}getUserIdentity(){const e=s.getUserCookie(),t=a.decodeOrParse(e);if(t){const n=t.exp?new Date(1e3*t.exp):new Date(Date.now()+864e5);return s.set(e,n),t.userId=t.sub,t}const n=s.get(),o=a.decodeOrParse(n);return o?(o.userId=o.sub,o):null}async getConnectionCredentials(){await this.waitForUserSession();try{const e=await this.ensureToken();return(await this.httpClient.get("/session/credentials",this.enableCredentials,{Authorization:e&&`Bearer ${e}`})).data}catch(e){return null}}async waitForUserSession(){try{return await d,!0}catch(e){return!1}}userSessionExists(e){return l?Date.now()-this.lastSessionCheck<50?l:(this.lastSessionCheck=Date.now(),l=l.catch((()=>{})).then((()=>this.userSessionContinuation(e)))):(this.lastSessionCheck=Date.now(),l=this.userSessionContinuation(e))}async userSessionContinuation(e){const t=new URLSearchParams(window.location.search),n=new URL(window.location);let r={};try{r=JSON.parse(localStorage.getItem(u)||"{}"),localStorage.removeItem(u),Object.hasOwnProperty.call(r,"enableCredentials")&&(this.enableCredentials=r.enableCredentials)}catch(e){this.logger&&this.logger.debug&&this.logger.debug({title:"LocalStorage failed in Browser",error:e})}if(t.get("state")&&"oauthLogin"===t.get("flow"))return!1;if(r.nonce&&t.get("code")&&(n.searchParams.delete("nonce"),n.searchParams.delete("iss"),n.searchParams.delete("code"),history.replaceState({},void 0,n.toString()),r.nonce===t.get("nonce"))){const e="cookie"===t.get("code")?o.parse(document.cookie)["auth-code"]:t.get("code"),n={grant_type:"authorization_code",redirect_uri:r.redirectUrl,client_id:this.settings.applicationId,code:e,code_verifier:r.codeVerifier};try{const e=await this.httpClient.post(`/authentication/${r.nonce}/tokens`,this.enableCredentials,n),t=a.decode(e.data.id_token),i=t.exp&&new Date(1e3*t.exp)||e.data.expires_in&&new Date(Date.now()+1e3*e.data.expires_in);return document.cookie=o.serialize("authorization",e.data.access_token||"",{expires:i,path:"/",sameSite:"strict"}),s.set(e.data.id_token,i),c(),!0}catch(e){if(e.data&&"invalid_request"===e.data.error)return this.logger&&this.logger.log({title:"Failed exchange authentication response for a token.",error:e}),!1;throw e.data||e}}if(this.isLocalHost()&&t.get("nonce")&&t.get("access_token")&&(n.searchParams.delete("iss"),n.searchParams.delete("nonce"),n.searchParams.delete("expires_in"),n.searchParams.delete("access_token"),n.searchParams.delete("id_token"),history.replaceState({},void 0,n.toString()),!r.nonce||r.nonce===t.get("nonce"))){const e=a.decode(t.get("id_token")),n=e.exp&&new Date(1e3*e.exp)||Number(t.get("expires_in"))&&new Date(Date.now()+1e3*Number(t.get("expires_in")));return document.cookie=o.serialize("authorization",t.get("access_token")||"",{expires:n,path:"/",sameSite:"strict"}),s.set(t.get("id_token"),n),c(),!0}if(this.getUserIdentity())return c(),!0;if(!this.isLocalHost()&&!e){try{const e=await this.httpClient.patch("/session",this.enableCredentials,{});if(e.data.access_token){const t=a.decode(e.data.id_token),n=t.exp&&new Date(1e3*t.exp)||e.data.expires_in&&new Date(Date.now()+1e3*e.data.expires_in);document.cookie=o.serialize("authorization",e.data.access_token||"",{expires:n,path:"/",sameSite:"strict"}),s.set(e.data.id_token,n)}}catch(e){400!==e.status&&404!==e.status&&409!==e.status&&this.logger&&this.logger.log({title:"Failed attempting to check if the user has an existing authentication session",error:e})}if(this.getUserIdentity())return c(),!0}return!1}async updateExtensionAuthenticationRequest({state:e,connectionId:t,tenantLookupIdentifier:n,connectionProperties:o}){if(!t&&!n){const e=Error("connectionId or tenantLookupIdentifier must be specified");throw e.code="InvalidConnection",e}const r=new URLSearchParams(window.location.search),i=e||r.get("state");if(!i){const e=Error("The `state` parameters must be specified to update this authentication request");throw e.code="InvalidAuthenticationRequest",e}try{const e=await this.httpClient.patch(`/authentication/${i}`,!0,{connectionId:t,tenantLookupIdentifier:n,connectionProperties:o});window.location.assign(e.data.authenticationUrl)}catch(e){if(e.status>=400&&e.status<500){const t=Error(e.data.title||e.data.errorCode);throw t.code=e.data.errorCode,t}throw e.data||e}await new Promise((e=>setTimeout(e,5e3)))}async unlinkIdentity(e){if(!e){const e=Error("connectionId must be specified");throw e.code="InvalidConnection",e}if(!this.getUserIdentity()){const e=Error("User must be logged into to unlink an account.");throw e.code="NotLoggedIn",e}let t;try{t=await this.ensureToken({timeoutInMillis:100})}catch(e){if("TokenTimeout"===e.code){const e=Error("User must be logged into an existing account before linking a second account.");throw e.code="NotLoggedIn",e}}const n=this.enableCredentials&&!this.isLocalHost()?{}:{Authorization:`Bearer ${t}`};try{await this.httpClient.delete(`/identities/${encodeURIComponent(e)}`,this.enableCredentials,n)}catch(e){if(e.status>=400&&e.status<500){const t=Error(e.data.title||e.data.errorCode);throw t.code=e.data.errorCode,t}throw e.data||e}}async linkIdentity({connectionId:e,tenantLookupIdentifier:t,redirectUrl:n,connectionProperties:o}){if(!e&&!t){const e=Error("connectionId or tenantLookupIdentifier must be specified");throw e.code="InvalidConnection",e}if(!this.getUserIdentity()){const e=Error("User must be logged into an existing account before linking a second account.");throw e.code="NotLoggedIn",e}let r;try{r=await this.ensureToken({timeoutInMillis:100})}catch(e){if("TokenTimeout"===e.code){const e=Error("User must be logged into an existing account before linking a second account.");throw e.code="NotLoggedIn",e}}const{codeChallenge:i}=await a.getAuthCodes();try{const a=n&&new URL(n).toString()||window.location.href,s=this.enableCredentials&&!this.isLocalHost()?{}:{Authorization:`Bearer ${r}`},c=await this.httpClient.post("/authentication",this.enableCredentials,{linkIdentity:!0,redirectUrl:a,codeChallengeMethod:"S256",codeChallenge:i,connectionId:e,tenantLookupIdentifier:t,connectionProperties:o,applicationId:this.settings.applicationId},s);window.location.assign(c.data.authenticationUrl)}catch(e){if(e.status>=400&&e.status<500){const t=Error(e.data.title||e.data.errorCode);throw t.code=e.data.errorCode,t}throw e}await new Promise((e=>setTimeout(e,5e3)))}async authenticate(e={}){const{connectionId:t,tenantLookupIdentifier:n,inviteId:o,redirectUrl:r,force:i,responseLocation:c,flowType:d,connectionProperties:l,openType:h,multiAccount:p,clearUserDataBeforeLogin:f}=e||{};if(c&&"cookie"!==c&&"query"!==c&&"none"!==c){const e=Error("Authentication response location is not valid");throw e.code="InvalidResponseLocation",e}if(!i&&!p&&await this.userSessionExists())return!0;const{codeVerifier:g,codeChallenge:w}=await a.getAuthCodes();try{const e=r&&new URL(r).toString()||window.location.href;!1!==f&&s.clear();const i=await this.httpClient.post("/authentication",!1,{redirectUrl:e,codeChallengeMethod:"S256",codeChallenge:w,connectionId:t,tenantLookupIdentifier:n,inviteId:o,connectionProperties:l,applicationId:this.settings.applicationId,responseLocation:c,flowType:d,multiAccount:p});if(localStorage.setItem(u,JSON.stringify({nonce:i.data.authenticationRequestId,codeVerifier:g,lastConnectionId:t,tenantLookupIdentifier:n,redirectUrl:e,enableCredentials:i.data.enableCredentials,multiAccount:p})),"tab"===h){const e=window.open(i.data.authenticationUrl,"_blank");e&&!e.closed&&void 0!==e.closed||window.location.assign(i.data.authenticationUrl)}else window.location.assign(i.data.authenticationUrl)}catch(e){if(e.status>=400&&e.status<500){const t=Error(e.data.title||e.data.errorCode);throw t.code=e.data.errorCode,t}throw e.data||e}return await new Promise((e=>setTimeout(e,5e3))),!1}async ensureToken(e){await this.userSessionExists();const t=Object.assign({timeoutInMillis:5e3},e||{}),n=this.waitForUserSession(),r=new Promise(((e,n)=>setTimeout(n,t.timeoutInMillis||0)));try{await Promise.race([n,r])}catch(e){const t=Error("No token retrieved after timeout");throw t.code="TokenTimeout",t}const i=o.parse(document.cookie);return"undefined"!==i.authorization&&i.authorization}async logout(e){if(s.clear(),d=new Promise((e=>c=e)),this.enableCredentials)try{return await this.httpClient.delete("/session",this.enableCredentials),void(e&&e!==window.location.href&&window.location.assign(e))}catch(e){}const t=new URL("/logout",this.hostUrl);t.searchParams.set("redirect_uri",e||window.location.href),t.searchParams.set("client_id",this.settings.applicationId),window.location.assign(t.toString())}},ExtensionClient:h}},215:(e,t,n)=>{const o=n(219);e.exports=new class{decode(e){if(!e)return null;try{const t=JSON.parse(o.decode(e.split(".")[1]));return t.exp&&(t.exp=t.exp-10),t}catch(e){return null}}decodeOrParse(e){if(!e)return null;if("object"==typeof e)return e;try{return JSON.parse(e)}catch(t){return this.decode(e)}}decodeFull(e){if(!e)return null;try{const t=JSON.parse(o.decode(e.split(".")[0])),n=JSON.parse(o.decode(e.split(".")[1]));return n.exp&&(n.exp=n.exp-10),{header:t,payload:n}}catch(e){return null}}async getAuthCodes(){const e=o.encode((window.crypto||window.msCrypto).getRandomValues(new Uint32Array(16)).toString()),t=await(window.crypto||window.msCrypto).subtle.digest("SHA-256",(new TextEncoder).encode(e));return{codeVerifier:e,codeChallenge:o.encode(t)}}}},429:(e,t,n)=>{const o=n(489),r="AuthenticationCredentialsStorage";e.exports=new class{getUserCookie(){return document.cookie.split(";").filter((e=>"user"===e.split("=")[0].trim())).map((e=>e.replace(/^user=/,""))).find((e=>e&&e.trim()))||null}set(e,t){try{const n=o.parse(document.cookie);localStorage.setItem(r,JSON.stringify({idToken:e,expiry:t&&t.getTime(),jsCookies:!!n.authorization})),this.clearCookies("user")}catch(e){console.debug("LocalStorage failed in Browser",e)}}get(){let e={};try{e=o.parse(document.cookie)}catch(e){console.debug("CookieManagement failed in Browser",e)}try{const{idToken:t,expiry:n,jsCookies:o}=JSON.parse(localStorage.getItem(r)||"{}");return t?n<Date.now()||o&&!e.authorization?null:t:this.getUserCookie()}catch(e){return console.debug("LocalStorage failed in Browser",e),this.getUserCookie()}}delete(){try{localStorage.removeItem(r)}catch(e){console.debug("LocalStorage failed in Browser",e)}try{this.clearCookies("user")}catch(e){console.debug("CookieManagement failed in Browser",e)}}clear(){this.clearCookies(),this.delete()}clearCookies(e){if("undefined"==typeof window)return;const t=document.cookie.split("; ");for(const n of t){if(!["user","authorization","auth-code"].includes(n.split("=")[0])||e&&n.split("=")[0]!==e)continue;const t=window.location.hostname.split("."),o=[...Array(t.length-1)].map(((e,n)=>t.reverse().slice(0,n+2).reverse().join("."))).map((e=>[e,`.${e}`])).flat(1).concat(null);"localhost"===window.location.hostname&&o.push("localhost");for(const e of o){const t=e?`domain=${e};`:"",o=`${encodeURIComponent(n.split(";")[0].split("=")[0])}=; expires=Thu, 01-Jan-1970 00:00:01 GMT; ${t} SameSite=Strict; path=`;document.cookie=`${o}/`;const r=location.pathname.split("/");for(;r.length>0;)document.cookie=o+r.join("/"),r.pop()}}}}},489:(e,t)=>{"use strict";t.parse=function(e,t){if("string"!=typeof e)throw new TypeError("argument str must be a string");var n={},o=(t||{}).decode||r,i=0;for(;i<e.length;){var s=e.indexOf("=",i);if(-1===s)break;var c=e.indexOf(";",i);if(-1===c)c=e.length;else if(c<s){i=e.lastIndexOf(";",s-1)+1;continue}var d=e.slice(i,s).trim();if(void 0===n[d]){var l=e.slice(s+1,c).trim();34===l.charCodeAt(0)&&(l=l.slice(1,-1)),n[d]=a(l,o)}i=c+1}return n},t.serialize=function(e,t,r){var a=r||{},s=a.encode||i;if("function"!=typeof s)throw new TypeError("option encode is invalid");if(!o.test(e))throw new TypeError("argument name is invalid");var c=s(t);if(c&&!o.test(c))throw new TypeError("argument val is invalid");var d=e+"="+c;if(null!=a.maxAge){var l=a.maxAge-0;if(isNaN(l)||!isFinite(l))throw new TypeError("option maxAge is invalid");d+="; Max-Age="+Math.floor(l)}if(a.domain){if(!o.test(a.domain))throw new TypeError("option domain is invalid");d+="; Domain="+a.domain}if(a.path){if(!o.test(a.path))throw new TypeError("option path is invalid");d+="; Path="+a.path}if(a.expires){var u=a.expires;if(!function(e){return"[object Date]"===n.call(e)||e instanceof Date}(u)||isNaN(u.valueOf()))throw new TypeError("option expires is invalid");d+="; Expires="+u.toUTCString()}a.httpOnly&&(d+="; HttpOnly");a.secure&&(d+="; Secure");if(a.priority){switch("string"==typeof a.priority?a.priority.toLowerCase():a.priority){case"low":d+="; Priority=Low";break;case"medium":d+="; Priority=Medium";break;case"high":d+="; Priority=High";break;default:throw new TypeError("option priority is invalid")}}if(a.sameSite){switch("string"==typeof a.sameSite?a.sameSite.toLowerCase():a.sameSite){case!0:d+="; SameSite=Strict";break;case"lax":d+="; SameSite=Lax";break;case"strict":d+="; SameSite=Strict";break;case"none":d+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return d};var n=Object.prototype.toString,o=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function r(e){return-1!==e.indexOf("%")?decodeURIComponent(e):e}function i(e){return encodeURIComponent(e)}function a(e,t){try{return t(e)}catch(t){return e}}},802:e=>{var t=1/0,n=17976931348623157e292,o=NaN,r="[object Symbol]",i=/^\s+|\s+$/g,a=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,c=/^0o[0-7]+$/i,d=parseInt,l=Object.prototype.toString;function u(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}e.exports=function(e,h,p){return e&&e.length?function(e,t,n){var o=-1,r=e.length;t<0&&(t=-t>r?0:r+t),(n=n>r?r:n)<0&&(n+=r),r=t>n?0:n-t>>>0,t>>>=0;for(var i=Array(r);++o<r;)i[o]=e[o+t];return i}(e,0,(h=p||void 0===h?1:(f=function(e){return e?(e=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&l.call(e)==r}(e))return o;if(u(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=u(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(i,"");var n=s.test(e);return n||c.test(e)?d(e.slice(2),n?2:8):a.test(e)?o:+e}(e))===t||e===-t?(e<0?-1:1)*n:e==e?e:0:0===e?e:0}(h),g=f%1,f==f?g?f-g:f:0))<0?0:h):[];var f,g}}},o={};function r(e){var t=o[e];if(void 0!==t){if(void 0!==t.error)throw t.error;return t.exports}var i=o[e]={exports:{}};try{var a={id:e,module:i,factory:n[e],require:r};r.i.forEach((function(e){e(a)})),i=a.module,a.factory.call(i.exports,i,i.exports,a.require)}catch(e){throw i.error=e,e}return i.exports}return r.m=n,r.c=o,r.i=[],r.hu=e=>e+"."+r.h()+".hot-update.js",r.hmrF=()=>"main."+r.h()+".hot-update.json",r.h=()=>"a1ec7ac4ca49882689f8",r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e={},t="authress:",r.l=(n,o,i,a)=>{if(e[n])e[n].push(o);else{var s,c;if(void 0!==i)for(var d=document.getElementsByTagName("script"),l=0;l<d.length;l++){var u=d[l];if(u.getAttribute("src")==n||u.getAttribute("data-webpack")==t+i){s=u;break}}s||(c=!0,(s=document.createElement("script")).charset="utf-8",s.timeout=120,r.nc&&s.setAttribute("nonce",r.nc),s.setAttribute("data-webpack",t+i),s.src=n),e[n]=[o];var h=(t,o)=>{s.onerror=s.onload=null,clearTimeout(p);var r=e[n];if(delete e[n],s.parentNode&&s.parentNode.removeChild(s),r&&r.forEach((e=>e(o))),t)return t(o)},p=setTimeout(h.bind(null,void 0,{type:"timeout",target:s}),12e4);s.onerror=h.bind(null,s.onerror),s.onload=h.bind(null,s.onload),c&&document.head.appendChild(s)}},(()=>{var e,t,n,o={},i=r.c,a=[],s=[],c="idle",d=0,l=[];function u(e){c=e;for(var t=[],n=0;n<s.length;n++)t[n]=s[n].call(null,e);return Promise.all(t)}function h(){0==--d&&u("ready").then((function(){if(0===d){var e=l;l=[];for(var t=0;t<e.length;t++)e[t]()}}))}function p(e){if("idle"!==c)throw new Error("check() is only allowed in idle status");return u("check").then(r.hmrM).then((function(n){return n?u("prepare").then((function(){var o=[];return t=[],Promise.all(Object.keys(r.hmrC).reduce((function(e,i){return r.hmrC[i](n.c,n.r,n.m,e,t,o),e}),[])).then((function(){return t=function(){return e?g(e):u("ready").then((function(){return o}))},0===d?t():new Promise((function(e){l.push((function(){e(t())}))}));var t}))})):u(w()?"ready":"idle").then((function(){return null}))}))}function f(e){return"ready"!==c?Promise.resolve().then((function(){throw new Error("apply() is only allowed in ready status (state: "+c+")")})):g(e)}function g(e){e=e||{},w();var o=t.map((function(t){return t(e)}));t=void 0;var r=o.map((function(e){return e.error})).filter(Boolean);if(r.length>0)return u("abort").then((function(){throw r[0]}));var i=u("dispose");o.forEach((function(e){e.dispose&&e.dispose()}));var a,s=u("apply"),c=function(e){a||(a=e)},d=[];return o.forEach((function(e){if(e.apply){var t=e.apply(c);if(t)for(var n=0;n<t.length;n++)d.push(t[n])}})),Promise.all([i,s]).then((function(){return a?u("fail").then((function(){throw a})):n?g(e).then((function(e){return d.forEach((function(t){e.indexOf(t)<0&&e.push(t)})),e})):u("idle").then((function(){return d}))}))}function w(){if(n)return t||(t=[]),Object.keys(r.hmrI).forEach((function(e){n.forEach((function(n){r.hmrI[e](n,t)}))})),n=void 0,!0}r.hmrD=o,r.i.push((function(l){var g,w,m,y,v=l.module,k=function(t,n){var o=i[n];if(!o)return t;var r=function(r){if(o.hot.active){if(i[r]){var s=i[r].parents;-1===s.indexOf(n)&&s.push(n)}else a=[n],e=r;-1===o.children.indexOf(r)&&o.children.push(r)}else console.warn("[HMR] unexpected require("+r+") from disposed module "+n),a=[];return t(r)},s=function(e){return{configurable:!0,enumerable:!0,get:function(){return t[e]},set:function(n){t[e]=n}}};for(var l in t)Object.prototype.hasOwnProperty.call(t,l)&&"e"!==l&&Object.defineProperty(r,l,s(l));return r.e=function(e){return function(e){switch(c){case"ready":u("prepare");case"prepare":return d++,e.then(h,h),e;default:return e}}(t.e(e))},r}(l.require,l.id);v.hot=(g=l.id,w=v,y={_acceptedDependencies:{},_acceptedErrorHandlers:{},_declinedDependencies:{},_selfAccepted:!1,_selfDeclined:!1,_selfInvalidated:!1,_disposeHandlers:[],_main:m=e!==g,_requireSelf:function(){a=w.parents.slice(),e=m?void 0:g,r(g)},active:!0,accept:function(e,t,n){if(void 0===e)y._selfAccepted=!0;else if("function"==typeof e)y._selfAccepted=e;else if("object"==typeof e&&null!==e)for(var o=0;o<e.length;o++)y._acceptedDependencies[e[o]]=t||function(){},y._acceptedErrorHandlers[e[o]]=n;else y._acceptedDependencies[e]=t||function(){},y._acceptedErrorHandlers[e]=n},decline:function(e){if(void 0===e)y._selfDeclined=!0;else if("object"==typeof e&&null!==e)for(var t=0;t<e.length;t++)y._declinedDependencies[e[t]]=!0;else y._declinedDependencies[e]=!0},dispose:function(e){y._disposeHandlers.push(e)},addDisposeHandler:function(e){y._disposeHandlers.push(e)},removeDisposeHandler:function(e){var t=y._disposeHandlers.indexOf(e);t>=0&&y._disposeHandlers.splice(t,1)},invalidate:function(){switch(this._selfInvalidated=!0,c){case"idle":t=[],Object.keys(r.hmrI).forEach((function(e){r.hmrI[e](g,t)})),u("ready");break;case"ready":Object.keys(r.hmrI).forEach((function(e){r.hmrI[e](g,t)}));break;case"prepare":case"check":case"dispose":case"apply":(n=n||[]).push(g)}},check:p,apply:f,status:function(e){if(!e)return c;s.push(e)},addStatusHandler:function(e){s.push(e)},removeStatusHandler:function(e){var t=s.indexOf(e);t>=0&&s.splice(t,1)},data:o[g]},e=void 0,y),v.parents=a,v.children=[],a=[],l.require=k})),r.hmrC={},r.hmrI={}})(),r.p="",(()=>{var e,t,n,o,i,a=r.hmrS_jsonp=r.hmrS_jsonp||{179:0},s={};function c(t,n){return e=n,new Promise(((e,n)=>{s[t]=e;var o=r.p+r.hu(t),i=new Error;r.l(o,(e=>{if(s[t]){s[t]=void 0;var o=e&&("load"===e.type?"missing":e.type),r=e&&e.target&&e.target.src;i.message="Loading hot update chunk "+t+" failed.\n("+o+": "+r+")",i.name="ChunkLoadError",i.type=o,i.request=r,n(i)}}))}))}function d(e){function s(e){for(var t=[e],n={},o=t.map((function(e){return{chain:[e],id:e}}));o.length>0;){var i=o.pop(),a=i.id,s=i.chain,d=r.c[a];if(d&&(!d.hot._selfAccepted||d.hot._selfInvalidated)){if(d.hot._selfDeclined)return{type:"self-declined",chain:s,moduleId:a};if(d.hot._main)return{type:"unaccepted",chain:s,moduleId:a};for(var l=0;l<d.parents.length;l++){var u=d.parents[l],h=r.c[u];if(h){if(h.hot._declinedDependencies[a])return{type:"declined",chain:s.concat([u]),moduleId:a,parentId:u};-1===t.indexOf(u)&&(h.hot._acceptedDependencies[a]?(n[u]||(n[u]=[]),c(n[u],[a])):(delete n[u],t.push(u),o.push({chain:s.concat([u]),id:u})))}}}}return{type:"accepted",moduleId:e,outdatedModules:t,outdatedDependencies:n}}function c(e,t){for(var n=0;n<t.length;n++){var o=t[n];-1===e.indexOf(o)&&e.push(o)}}r.f&&delete r.f.jsonpHmr,t=void 0;var d={},l=[],u={},h=function(e){console.warn("[HMR] unexpected require("+e.id+") to disposed module")};for(var p in n)if(r.o(n,p)){var f,g=n[p],w=!1,m=!1,y=!1,v="";switch((f=g?s(p):{type:"disposed",moduleId:p}).chain&&(v="\nUpdate propagation: "+f.chain.join(" -> ")),f.type){case"self-declined":e.onDeclined&&e.onDeclined(f),e.ignoreDeclined||(w=new Error("Aborted because of self decline: "+f.moduleId+v));break;case"declined":e.onDeclined&&e.onDeclined(f),e.ignoreDeclined||(w=new Error("Aborted because of declined dependency: "+f.moduleId+" in "+f.parentId+v));break;case"unaccepted":e.onUnaccepted&&e.onUnaccepted(f),e.ignoreUnaccepted||(w=new Error("Aborted because "+p+" is not accepted"+v));break;case"accepted":e.onAccepted&&e.onAccepted(f),m=!0;break;case"disposed":e.onDisposed&&e.onDisposed(f),y=!0;break;default:throw new Error("Unexception type "+f.type)}if(w)return{error:w};if(m)for(p in u[p]=g,c(l,f.outdatedModules),f.outdatedDependencies)r.o(f.outdatedDependencies,p)&&(d[p]||(d[p]=[]),c(d[p],f.outdatedDependencies[p]));y&&(c(l,[f.moduleId]),u[p]=h)}n=void 0;for(var k,C=[],b=0;b<l.length;b++){var I=l[b],E=r.c[I];E&&(E.hot._selfAccepted||E.hot._main)&&u[I]!==h&&!E.hot._selfInvalidated&&C.push({module:I,require:E.hot._requireSelf,errorHandler:E.hot._selfAccepted})}return{dispose:function(){var e;o.forEach((function(e){delete a[e]})),o=void 0;for(var t,n=l.slice();n.length>0;){var i=n.pop(),s=r.c[i];if(s){var c={},u=s.hot._disposeHandlers;for(b=0;b<u.length;b++)u[b].call(null,c);for(r.hmrD[i]=c,s.hot.active=!1,delete r.c[i],delete d[i],b=0;b<s.children.length;b++){var h=r.c[s.children[b]];h&&((e=h.parents.indexOf(i))>=0&&h.parents.splice(e,1))}}}for(var p in d)if(r.o(d,p)&&(s=r.c[p]))for(k=d[p],b=0;b<k.length;b++)t=k[b],(e=s.children.indexOf(t))>=0&&s.children.splice(e,1)},apply:function(t){for(var n in u)r.o(u,n)&&(r.m[n]=u[n]);for(var o=0;o<i.length;o++)i[o](r);for(var a in d)if(r.o(d,a)){var s=r.c[a];if(s){k=d[a];for(var c=[],h=[],p=[],f=0;f<k.length;f++){var g=k[f],w=s.hot._acceptedDependencies[g],m=s.hot._acceptedErrorHandlers[g];if(w){if(-1!==c.indexOf(w))continue;c.push(w),h.push(m),p.push(g)}}for(var y=0;y<c.length;y++)try{c[y].call(null,k)}catch(n){if("function"==typeof h[y])try{h[y](n,{moduleId:a,dependencyId:p[y]})}catch(o){e.onErrored&&e.onErrored({type:"accept-error-handler-errored",moduleId:a,dependencyId:p[y],error:o,originalError:n}),e.ignoreErrored||(t(o),t(n))}else e.onErrored&&e.onErrored({type:"accept-errored",moduleId:a,dependencyId:p[y],error:n}),e.ignoreErrored||t(n)}}}for(var v=0;v<C.length;v++){var b=C[v],I=b.module;try{b.require(I)}catch(n){if("function"==typeof b.errorHandler)try{b.errorHandler(n,{moduleId:I,module:r.c[I]})}catch(o){e.onErrored&&e.onErrored({type:"self-accept-error-handler-errored",moduleId:I,error:o,originalError:n}),e.ignoreErrored||(t(o),t(n))}else e.onErrored&&e.onErrored({type:"self-accept-errored",moduleId:I,error:n}),e.ignoreErrored||t(n)}}return l}}}this.webpackHotUpdateauthress=(t,o,a)=>{for(var c in o)r.o(o,c)&&(n[c]=o[c],e&&e.push(c));a&&i.push(a),s[t]&&(s[t](),s[t]=void 0)},r.hmrI.jsonp=function(e,t){n||(n={},i=[],o=[],t.push(d)),r.o(n,e)||(n[e]=r.m[e])},r.hmrC.jsonp=function(e,s,l,u,h,p){h.push(d),t={},o=s,n=l.reduce((function(e,t){return e[t]=!1,e}),{}),i=[],e.forEach((function(e){r.o(a,e)&&void 0!==a[e]?(u.push(c(e,p)),t[e]=!0):t[e]=!1})),r.f&&(r.f.jsonpHmr=function(e,n){t&&r.o(t,e)&&!t[e]&&(n.push(c(e)),t[e]=!0)})},r.hmrM=()=>{if("undefined"==typeof fetch)throw new Error("No browser support: need fetch API");return fetch(r.p+r.hmrF()).then((e=>{if(404!==e.status){if(!e.ok)throw new Error("Failed to fetch update manifest "+e.statusText);return e.json()}}))}})(),r(125)})()));
@@ -7,7 +7,7 @@
7
7
 
8
8
  /**
9
9
  * @preserve
10
- * Authress Login SDK 2.2.241
10
+ * Authress Login SDK 2.2.247
11
11
  * License: Apache-2.0
12
12
  * Repo : https://github.com/Authress/login-sdk.js
13
13
  * Author : Authress Developers
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@authress/login",
3
- "version": "2.2.241",
3
+ "version": "2.2.247",
4
4
  "description": "Universal login sdk for Authress authentication as a service. Provides managed authentication for user identity, authentication, and token verification.",
5
5
  "main": "./src/index.js",
6
6
  "types": "./index.d.ts",
@@ -15,7 +15,6 @@
15
15
  "test": "check-dts index.d.ts && mocha tests/**/*.test.js -R spec"
16
16
  },
17
17
  "dependencies": {
18
- "axios": "^0.21",
19
18
  "cookie": "^0.5.0",
20
19
  "lodash.take": "^4.1.1"
21
20
  },
package/src/httpClient.js CHANGED
@@ -1,10 +1,25 @@
1
- /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
2
- const axios = require('axios');
3
-
4
1
  const defaultHeaders = {
5
2
  'Content-Type': 'application/json'
6
3
  };
7
4
 
5
+ const errorMessages = new Set([
6
+ 'Failed to fetch', // Chrome
7
+ 'NetworkError when attempting to fetch resource.', // Firefox
8
+ 'The Internet connection appears to be offline.', // Safari 16
9
+ 'Network request failed', // `cross-fetch`
10
+ 'fetch failed' // Undici (Node.js)
11
+ ]);
12
+
13
+ function isNetworkError(error) {
14
+ const isValid = error && error.name === 'TypeError' && typeof error.message === 'string';
15
+
16
+ if (!isValid) {
17
+ return false;
18
+ }
19
+
20
+ return errorMessages.has(error.message);
21
+ }
22
+
8
23
  async function retryExecutor(func) {
9
24
  let lastError = null;
10
25
  for (let iteration = 0; iteration < 5; iteration++) {
@@ -13,7 +28,7 @@ async function retryExecutor(func) {
13
28
  return result;
14
29
  } catch (error) {
15
30
  lastError = error;
16
- if (error.message === 'Network Error' || error.code === 'ERR_NETWORK' || !error.status || error.status >= 500) {
31
+ if (isNetworkError(error) || error.message === 'Network Error' || error.code === 'ERR_NETWORK' || !error.status || error.status >= 500) {
17
32
  await new Promise(resolve => setTimeout(resolve, 10 * 2 ** iteration));
18
33
  continue;
19
34
  }
@@ -30,137 +45,87 @@ class HttpClient {
30
45
  }
31
46
  // eslint-disable-next-line @typescript-eslint/no-empty-function
32
47
  const logger = overrideLogger || { debug() {}, warn() {}, critical() {} };
48
+ this.logger = logger;
33
49
 
34
50
  const loginHostFullUrl = new URL(`https://${authressLoginCustomDomain.replace(/^(https?:\/+)/, '')}`);
35
- const loginUrl = `${loginHostFullUrl.origin}/api`;
36
- const client = axios.create({ baseURL: loginUrl });
37
-
38
- client.interceptors.request.use(config => {
39
- logger.debug({ title: 'HttpClient Request', online: navigator.onLine, requestId: config.requestId, method: config.method, url: config.url });
40
-
41
- return config;
42
- }, error => {
43
- let notFound = false;
44
- let newError = error;
45
- let url;
46
- let requestId;
47
-
48
- if (error) {
49
- newError = error.message;
50
-
51
- if (error.response) {
52
- newError = {
53
- data: error.response.data,
54
- status: error.response.status,
55
- headers: error.response.headers
56
- };
57
- notFound = error.response.status === 404;
58
- } else if (error.message) {
59
- newError = {
60
- message: error.message,
61
- code: error.code,
62
- stack: error.stack
63
- };
64
- }
65
-
66
- if (error.config) {
67
- url = error.config.url;
68
- requestId = error.config.requestId;
69
- } else {
70
- requestId = error.request && error.request.config && error.request.config.requestId;
71
- }
72
- }
73
-
74
- const logObject = { title: 'HttpClient Request Error', url, online: navigator.onLine, requestId, exception: newError };
75
-
76
- if (notFound) {
77
- logger.debug(logObject);
78
- } else {
79
- logger.warn(logObject);
80
- }
81
-
82
- throw newError;
83
- });
84
-
85
- client.interceptors.response.use(response => response, error => {
86
- // Rewritten error object for easy consumption
87
- if (error.re) {
88
- throw error;
89
- }
90
-
91
- const newError = error && error.response && {
92
- url: error.config && error.config.url,
93
- data: error.response.data,
94
- status: error.response.status,
95
- headers: error.response.headers
96
- } || error.message && { message: error.message, code: error.code, stack: error.stack } || error;
97
- newError.re = true;
98
- const requestId = error && (error.config && error.config.requestId || error.request && error.request.config && error.request.config.requestId);
99
-
100
- let message = 'HttpClient Response Error';
101
- let logMethod = 'warn';
102
-
103
- if (!error) {
104
- message = 'HttpClient Response Error - Unknown error occurred';
105
- } else if (error.response && error.response.status === 404) {
106
- logMethod = 'debug';
107
- } else if (error.response && error.response.status === 401) {
108
- message = 'HttpClient Response Error due to invalid token';
109
- }
110
-
111
- logger[logMethod]({ title: message, online: navigator.onLine, requestId, exception: newError, url: error && error.config && error.config.url });
112
- throw newError;
113
- });
114
-
115
- this.client = client;
51
+ this.loginUrl = `${loginHostFullUrl.origin}/api`;
116
52
  }
117
53
 
118
- get(url, withCredentials, headers, type = 'json') {
54
+ get(url, withCredentials, headers) {
119
55
  return retryExecutor(() => {
120
- return this.client.get(url.toString(), {
121
- withCredentials: window.location.hostname !== 'localhost' && !!withCredentials,
122
- headers: Object.assign({}, defaultHeaders, headers),
123
- responseType: type
124
- });
56
+ return this.fetchWrapper('GET', url, null, headers, withCredentials);
125
57
  });
126
58
  }
127
59
 
128
- delete(url, withCredentials, headers, type = 'json') {
60
+ delete(url, withCredentials, headers) {
129
61
  return retryExecutor(() => {
130
- return this.client.delete(url.toString(), {
131
- withCredentials: window.location.hostname !== 'localhost' && !!withCredentials,
132
- headers: Object.assign({}, defaultHeaders, headers),
133
- responseType: type
134
- });
62
+ return this.fetchWrapper('DELETE', url, null, headers, withCredentials);
135
63
  });
136
64
  }
137
65
 
138
66
  post(url, withCredentials, data, headers) {
139
67
  return retryExecutor(() => {
140
- return this.client.post(url.toString(), data, {
141
- withCredentials: window.location.hostname !== 'localhost' && !!withCredentials,
142
- headers: Object.assign({}, defaultHeaders, headers)
143
- });
68
+ return this.fetchWrapper('POST', url, data, headers, withCredentials);
144
69
  });
145
70
  }
146
71
 
147
72
  put(url, withCredentials, data, headers) {
148
73
  return retryExecutor(() => {
149
- return this.client.put(url.toString(), data, {
150
- withCredentials: window.location.hostname !== 'localhost' && !!withCredentials,
151
- headers: Object.assign({}, defaultHeaders, headers)
152
- });
74
+ return this.fetchWrapper('PUT', url, data, headers, withCredentials);
153
75
  });
154
76
  }
155
77
 
156
78
  patch(url, withCredentials, data, headers) {
157
79
  return retryExecutor(() => {
158
- return this.client.patch(url.toString(), data, {
159
- withCredentials: window.location.hostname !== 'localhost' && !!withCredentials,
160
- headers: Object.assign({}, defaultHeaders, headers)
161
- });
80
+ return this.fetchWrapper('PATCH', url, data, headers, withCredentials);
162
81
  });
163
82
  }
83
+
84
+ async fetchWrapper(rawMethod, urlObject, data, requestHeaders, withCredentials) {
85
+ const url = `${this.loginUrl}${urlObject.toString()}`;
86
+ const method = rawMethod.toUpperCase();
87
+ const headers = Object.assign({}, defaultHeaders, requestHeaders);
88
+ try {
89
+ this.logger.debug({ title: 'HttpClient Request', method, url });
90
+ const request = { method, headers };
91
+ if (data) {
92
+ request.body = JSON.stringify(data);
93
+ }
94
+ if (window.location.hostname !== 'localhost' && !!withCredentials) {
95
+ request.credentials = 'include';
96
+ }
97
+ const response = await fetch(url, request);
98
+
99
+ if (!response.ok) {
100
+ throw response;
101
+ }
102
+ return {
103
+ url,
104
+ headers: response.headers,
105
+ status: response.status,
106
+ data: await response.json()
107
+ };
108
+ } catch (error) {
109
+ const resolvedError = typeof error.json === 'function' ? await error.json().catch(e => e) : error;
110
+ const extensionErrorId = resolvedError.stack.match(/chrome-extension:[/][/](\w+)[/]/);
111
+ if (extensionErrorId) {
112
+ this.logger.debug({ title: `Fetch failed due to a browser extension - ${method} - ${url}`, method, url, data, headers, error, resolvedError, extensionErrorId });
113
+ const newError = new Error(`Extension Error ID: ${extensionErrorId}`);
114
+ newError.code = 'BROWSER_EXTENSION_ERROR';
115
+ throw newError;
116
+ }
117
+
118
+ let message = 'HttpClient Response Error';
119
+ if (!error) {
120
+ message = 'HttpClient Response Error - Unknown error occurred';
121
+ } else if (error.response && error.response.status === 401) {
122
+ message = 'HttpClient Response Error due to invalid token';
123
+ }
124
+
125
+ this.logger.warn({ title: message, online: navigator.onLine, method, url, data, headers, error, resolvedError });
126
+ throw error || error;
127
+ }
128
+ }
164
129
  }
165
130
 
166
131
  module.exports = HttpClient;
package/src/index.js CHANGED
@@ -47,8 +47,8 @@ class LoginClient {
47
47
  return isLocalHost;
48
48
  }
49
49
 
50
- getMatchingDomainInfo(hostUrl, webWindow) {
51
- const host = new URL(hostUrl);
50
+ getMatchingDomainInfo(hostUrlString, webWindow) {
51
+ const hostUrl = new URL(hostUrlString);
52
52
 
53
53
  if (this.isLocalHost()) {
54
54
  return false;
@@ -62,7 +62,7 @@ class LoginClient {
62
62
  return false;
63
63
  }
64
64
 
65
- const tokenUrlList = host.host.toLowerCase().split('.').reverse();
65
+ const tokenUrlList = hostUrl.host.toLowerCase().split('.').reverse();
66
66
  // Login url may not be known all the time, in which case we will compare the token url to the appUrl
67
67
  const appUrlList = webWindow.location.host.toLowerCase().split('.').reverse();
68
68