@authress/login 2.6.396 → 2.6.407
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/authress.min.js +2 -2
- package/dist/authress.min.js.map +1 -0
- package/index.d.ts +2 -2
- package/package.json +27 -21
- package/src/base64url.js +6 -4
- package/src/extensionClient.js +4 -4
- package/src/httpClient.js +10 -11
- package/src/index.js +51 -47
- package/src/jwtManager.js +5 -5
- package/src/userIdentityTokenStorageManager.js +3 -3
- package/src/util.js +2 -2
- package/src/windowManager.js +2 -1
- package/dist/authress.min.js.LICENSE.txt +0 -14
- package/dist/authress.min.js.LICENSE.txt.gz +0 -0
- package/dist/authress.min.js.gz +0 -0
package/README.md
CHANGED
|
@@ -79,7 +79,7 @@ On the service API side, pull in the Authress service client companion library,
|
|
|
79
79
|
* Then verify the incoming tokens from the Authorization header:
|
|
80
80
|
|
|
81
81
|
```js
|
|
82
|
-
|
|
82
|
+
import { TokenVerifier } from '@authress/sdk';
|
|
83
83
|
|
|
84
84
|
try {
|
|
85
85
|
// Grab authorization token from the request header, the best way to do this will be framework specific.
|
|
@@ -96,7 +96,7 @@ try {
|
|
|
96
96
|
The goal of the platform extension is to make it easy for your platform extension developers to login with Authress. Embed the `ExtensionClient` in your javascript UI SDK, and pass in the `extensionId`.
|
|
97
97
|
|
|
98
98
|
```js
|
|
99
|
-
|
|
99
|
+
import { ExtensionClient } from '@authress/login';
|
|
100
100
|
|
|
101
101
|
// What is my custom Domain? => https://authress.io/app/#/setup?focus=domain
|
|
102
102
|
// What is my extensionId => https://authress.io/app/#/manage?focus=extensions
|
package/dist/authress.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! Authress Login SDK 2.6.396 | 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={75:(e,t,n)=>{const{sanitizeUrl:o}=n(332),i=n(629),r={"Content-Type":"application/json","X-Powered-By":`Authress Login SDK; Javascript; ${n(330).version}`},s=new Set(["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed","fetch failed","Load failed","<HTML DOCUMENT></HTML>"]);function a(e){return"Network Error"===e.message||"ERR_NETWORK"===e.code||!e.status||e.status>=500||"string"==typeof e.message&&s.has(e.message)||"string"==typeof e.data&&s.has(e.data)}async function c(e){let t=null;for(let n=0;n<5;n++)try{return await e()}catch(e){if(e.retryCount=n,!a(e))throw e;t=e,t.isNetworkError=!0,await new Promise((e=>setTimeout(e,10*2**n)));continue}const n=new Error("[Authress Login SDK] Http Request failed due to a Network Error even after multiple retries",{cause:t});throw n.code="AuthressSdkNetworkError",n}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 i=new URL(o(e));this.loginUrl=`${i.origin}/api`}get(e,t,n,o){return c((()=>this.fetchWrapper("GET",e,null,n,t,o)))}delete(e,t,n,o){return c((()=>this.fetchWrapper("DELETE",e,null,n,t,o)))}post(e,t,n,o,i){return c((()=>this.fetchWrapper("POST",e,n,o,t,i)))}put(e,t,n,o,i){return c((()=>this.fetchWrapper("PUT",e,n,o,t,i)))}patch(e,t,n,o,i){return c((()=>this.fetchWrapper("PATCH",e,n,o,t,i)))}async fetchWrapper(e,t,n,o,s,a){const c=`${this.loginUrl}${t.toString()}`,l=e.toUpperCase(),d=Object.assign({},r,o);try{this.logger&&this.logger.debug&&this.logger.debug({title:"[Authress Login SDK] HttpClient Request",method:l,url:c});const e={method:l,headers:d};n&&(e.body=JSON.stringify(n)),!i.isLocalHost()&&s&&(e.credentials="include");const t=await fetch(c,e);if(!t.ok)throw t;let o={};try{o=await t.text(),o=JSON.parse(o)}catch(e){}return{url:c,method:l,headers:t.headers,status:t.status,data:o}}catch(e){let t=e;try{t=await e.text(),t=JSON.parse(t)}catch(e){}const o=t.stack&&t.stack.match(/chrome-extension:[/][/](\w+)[/]/);if(o){this.logger&&this.logger.debug&&this.logger.debug({title:`[Authress Login SDK] Fetch failed due to a browser extension - ${l} - ${c}`,method:l,url:c,data:n,headers:d,error:e,resolvedError:t,extensionErrorId:o});const i=new Error(`Extension Error ID: ${o}`);throw i.code="BROWSER_EXTENSION_ERROR",i}const i=e.status;let r="warn",s="[Authress Login SDK] HttpClient Response Error";e?401===i?(s="[Authress Login SDK] HttpClient Response Error due to invalid token",r="debug"):404===i?(s="[Authress Login SDK] HttpClient Response: Not Found",r="debug"):i<500&&a&&(r="debug"):s="[Authress Login SDK] HttpClient Response Error - Unknown error occurred",this.logger&&this.logger[r]&&this.logger[r]({title:s,online:"undefined"==typeof navigator||navigator.onLine,method:l,url:c,status:i,data:n,headers:d,error:e,resolvedError:t});throw{url:c,method:l,status:i,data:t,headers:e.headers}}}}},160:(e,t,n)=>{const o=n(427),i=n(629),r="AuthenticationCredentialsStorage",s={user:"user",authorization:"authorization",authCode:"auth-code",authUserId:"AuthUserId"};e.exports=new class{constructor(){this.retainUserCookie=!1}getUserCookie(){const e=i.getDocument();if(!e)return null;return e.cookie.split(";").filter((e=>e.split("=")[0].trim()===s.user)).map((e=>e.trim().replace(/^user=/,""))).find((e=>e&&e.trim()))||null}getAuthorizationTokens(){if("undefined"==typeof window||"undefined"==typeof document)return[];return document.cookie.split(";").filter((e=>e.split("=")[0].trim()===s.authorization)).map((e=>e.trim().replace(/^authorization=/,""))).filter((e=>e&&e.trim()))}set(e,t){if("undefined"!=typeof window&&"undefined"!=typeof document)try{const n=o.parse(document.cookie);localStorage.setItem(r,JSON.stringify({idToken:e,expiry:t&&t.getTime(),jsCookies:!!n.authorization})),this.retainUserCookie||this.clearCookies(s.user)}catch(e){console.debug("LocalStorage failed in Browser",e)}}get(){if("undefined"==typeof window||"undefined"==typeof document)return null;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(s.user)}catch(e){console.debug("CookieManagement failed in Browser",e)}}clear(){this.clearCookies(),this.delete()}clearCookies(e){if("undefined"==typeof window||"undefined"==typeof document)return;const t=document.cookie.split("; ");for(const n of t){if(!Object.values(s).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 i=location.pathname.split("/");for(;i.length>0;)document.cookie=o+i.join("/"),i.pop()}}}}},321:e=>{var t=1/0,n=17976931348623157e292,o=NaN,i="[object Symbol]",r=/^\s+|\s+$/g,s=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,c=/^0o[0-7]+$/i,l=parseInt,d=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,i=e.length;t<0&&(t=-t>i?0:i+t),(n=n>i?i:n)<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var r=Array(i);++o<i;)r[o]=e[o+t];return r}(e,0,(h=p||void 0===h?1:(g=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)==i}(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(r,"");var n=a.test(e);return n||c.test(e)?l(e.slice(2),n?2:8):s.test(e)?o:+e}(e))===t||e===-1/0?(e<0?-1:1)*n:e==e?e:0:0===e?e:0}(h),f=g%1,g==g?f?g-f:g:0))<0?0:h):[];var g,f}},330:e=>{"use strict";e.exports=JSON.parse('{"name":"@authress/login","version":"2.6.396","description":"Universal login sdk for Authress authentication as a service. Provides managed authentication for user identity, authentication, and token verification.","main":"./src/index.js","types":"./index.d.ts","files":["index.d.ts","src","dist"],"scripts":{"build":"node make.js build && NODE_ENV=production webpack --mode=production","lint":"eslint --ext .js,.ts src tests make.js index.d.ts","test":"check-dts index.d.ts && mocha tests/*.test.js tests/**/*.test.js -R spec"},"dependencies":{"cookie":"<1","lodash.take":"^4.1.1"},"devDependencies":{"@babel/core":"^7.17.5","@babel/preset-env":"^7.16.11","@types/node":"^14.14.35","@typescript-eslint/eslint-plugin":"^3.1.0","@typescript-eslint/parser":"^3.1.0","babel-loader":"^8.2.3","chai":"^4.2.0","check-dts":"^0.4.4","ci-build-tools":"^1.0.13","commander":"^4.0.1","compression-webpack-plugin":"^9.2.0","eslint":"^7.12.1","eslint-config-cimpress-atsquad":"^1.0.67","eslint-loader":"^4.0.2","eslint-plugin-mocha":"^7.0.1","eslint-plugin-node":"^11.1.0","eslint-plugin-promise":"^6.1.1","fs-extra":"^8.1.0","glob":"^7.1.6","mocha":"^11.1.0","path-browserify":"^1.0.1","sinon":"^7.5.0","sinon-chai":"^3.3.0","terser-webpack-plugin":"^5.3.1","typescript":"^3.9.5","webpack":"^5.69.1","webpack-cli":"^4.9.2"},"repository":{"type":"git","url":"git+https://github.com/Authress/authress-login.js"},"keywords":["authentication","authentication as a service","Login","Login Client","universal login","auth","federated login","secure login","application security","IDaaS","authentication","user authentication","user identity","Oauth2","Oauth2.1","Oauth3","platform","platform login","extension","Authress","Authress client","user security","DBSC","Device Bound Session Credentials"],"author":"Authress Developers <developers@authress.io> (https://authress.io)","license":"Apache-2.0","bugs":{"url":"https://github.com/Authress/authress-login.js/issues"},"homepage":"https://authress.io","engines":{"node":">=18"}}')},332:e=>{e.exports.sanitizeUrl=function(e){let t=e;t.startsWith("http")||(t=`https://${t}`);const n=new URL(t),o=n.host.match(/^([a-z0-9-]+)[.][a-z0-9-]+[.]authress[.]io$/);return o&&(n.host=`${o[1]}.login.authress.io`,t=n.toString()),t.replace(/[/]+$/,"")}},354:(e,t,n)=>{const o=n(427),i=n(321),r=n(629),s=n(75),a=n(836),{sanitizeUrl:c}=n(332),l=n(160);let d,u=new Promise((e=>d=e)),h=Promise.resolve(),p=!1;const g="AuthenticationRequestNonce";const f=n(568);e.exports={LoginClient:class{constructor(e,t){var n;const o=Object.assign({applicationId:"app_default"},e);this.logger=t||console;const i=o.authressApiUrl||o.authressLoginHostUrl||o.authenticationServiceUrl||"";if(!i)throw Error('Missing required property "authressApiUrl" in LoginClient constructor. Custom Authress Domain Host is required.');if(this.applicationId=null===(n=o.applicationId)||void 0===n?void 0:n.trim(),!this.applicationId){const e=Error("Application ID is required.");throw e.code="InvalidApplication",e}if(this.applicationId.match(/^(sc_|ext_)/)){const e=Error("You have incorrectly specified an Authress Service Client or Extension as the applicationId instead of a valid application. The applicationId is your application that your users will log into, usually hosted on your domain https://example.yourdomain.com. Users cannot log *into* a Service Client, but they can log in *with* one. Users can use a Service Client to log in, by setting the connection ID in the *authenticate({ connectionId })* method to be the Authress Service Client.\n(1) If you are building an Custom Login Portal, then the application ID should correspond to this login portal.\n(2) If you are replacing or extending an Authress connection, then specify the Service Client as the connectionId and the end user application as the applicationId.\n(3) If you are building a platform or plugin marketplace, where users will log into third party extensions or apps, then distribute in your SDK a wrapper for the Authress Extension Client using: import { extensionClient } from '@authress/login' found within this SDK.\n(4) If you aren't sure what to do here to fix the problem, the fastest and usually correct solution is go to https://authress.io/app/#/settings?focus=applications create a new application, specify your site in the application url property and then update the value here.");throw e.code="InvalidApplication",e}this.hostUrl=c(i),this.httpClient=new s(this.hostUrl,t),this.lastSessionCheck=0,this.enableCredentials=this.getMatchingDomainInfo(this.hostUrl),l.retainUserCookie=e.retainUserCookie,o.skipBackgroundCredentialsCheck||r.onLoad((async()=>{await this.userSessionExists({backgroundTrigger:!0})}))}getMatchingDomainInfo(e){const t=new URL(e);if(r.isLocalHost())return!1;const n=r.getCurrentLocation();if("https:"!==n.protocol)return!1;const o=t.host.toLowerCase().split(".").reverse(),s=n.host.toLowerCase().split(".").reverse();let a=[];for(let e of o){const t=i(s,a.length+1).join(".");if(a.concat(e).join(".")!==t)break;a.push(e)}return a.length===o.length&&a.length===s.length||a.length>1}getUserIdentity(){const e=l.getUserCookie(),t=a.decodeOrParse(e);if(t){const n=t.exp?new Date(1e3*t.exp):new Date(Date.now()+864e5);return l.set(e,n),t.userId=t.sub,t}const n=l.get(),o=a.decodeOrParse(n);if(!o)return null;const i=new URL(o.iss).hostname,r=new URL(this.hostUrl).hostname;return i.endsWith(r)||r.endsWith(i)?(o.userId=o.sub,o):(l.clear(),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 getDevices(){try{const e=await this.ensureToken();return(await this.httpClient.get("/session/devices",this.enableCredentials,{Authorization:e&&`Bearer ${e}`})).data.devices}catch(e){return[]}}async deleteDevice(e){try{const t=await this.ensureToken();await this.httpClient.delete(`/session/devices/${encodeURIComponent(e)}`,this.enableCredentials,{Authorization:t&&`Bearer ${t}`})}catch(e){throw this.logger&&this.logger.log({title:"[Authress Login SDK] Failed to delete device",error:e}),e}}async openUserConfigurationScreen(e={redirectUrl:null,startPage:"Profile"}){if(!await this.userSessionExists()){const e=Error("User must be logged to configure user profile data.");throw e.code="NotLoggedIn",e}const t=new URL("/settings",this.hostUrl);t.searchParams.set("client_id",this.applicationId),t.searchParams.set("start_page",e&&e.startPage||"Profile"),t.searchParams.set("redirect_uri",e&&e.redirectUrl||r.getCurrentLocation().href),r.assign(t.toString()),await Promise.resolve()}async registerDevice(e={name:"",type:"",totp:{}}){const t=await this.getUserIdentity();if(!t){const e=Error("User must be logged to configure user profile data.");throw e.code="NotLoggedIn",e}if(!e){const e=Error("Register Device missing required parameter: 'Options'");throw e.code="InvalidInput",e}let n;if(e.type&&"WebAuthN"!==e.type)"TOTP"===e.type&&(n={name:e.name,code:e.totp.verificationCode,totpData:e.totp,type:"TOTP"});else{const o=t.sub,i={challenge:Uint8Array.from(o,(e=>e.charCodeAt(0))),rp:{id:this.hostUrl.split(".").slice(1).join("."),name:"WebAuthN Login"},user:{id:Uint8Array.from(o,(e=>e.charCodeAt(0))),name:o,displayName:`Generated User ID: ${o}`},pubKeyCredParams:[{type:"public-key",alg:-7},{type:"public-key",alg:-257}],authenticatorSelection:{residentKey:"discouraged",requireResidentKey:!1,userVerification:"discouraged"},timeout:6e4,attestation:"direct"},r=await navigator.credentials.create({publicKey:i}),s={authenticatorAttachment:r.authenticatorAttachment,credentialId:r.id,type:r.type,userId:o,attestation:btoa(String.fromCharCode(...new Uint8Array(r.response.attestationObject))),client:btoa(String.fromCharCode(...new Uint8Array(r.response.clientDataJSON)))};n={name:e&&e.name,code:s,type:"WebAuthN"}}try{const e=await this.ensureToken();return(await this.httpClient.post("/session/devices",this.enableCredentials,n,{Authorization:e&&`Bearer ${e}`})).data}catch(e){throw this.logger&&this.logger.log({title:"[Authress Login SDK] Failed to register new device",error:e,request:n}),e}}async waitForUserSession(){try{return await u,!0}catch(e){return!1}}userSessionExists(e={backgroundTrigger:!1}){return Date.now()-this.lastSessionCheck<50||p?h:(this.lastSessionCheck=Date.now(),p=!0,h=h.catch((()=>{})).then((async()=>{try{const t=await this.userSessionContinuation(null==e?void 0:e.backgroundTrigger);return p=!1,t}catch(e){throw p=!1,e}})))}async userSessionContinuation(e=!1){const t=new URLSearchParams(r.getCurrentLocation().search);let n={};if("undefined"!=typeof localStorage)try{n=JSON.parse(localStorage.getItem(g)||"{}"),localStorage.removeItem(g),Object.hasOwnProperty.call(n,"enableCredentials")&&(this.enableCredentials=n.enableCredentials)}catch(e){this.logger&&this.logger.debug&&this.logger.debug({title:"[Authress Login SDK] LocalStorage failed in Browser",error:e})}if((n.nonce||t.get("iss")&&t.get("iss").includes(this.hostUrl))&&this.sanitizeQueryParameters(),n.nonce&&t.get("code")&&n.nonce===t.get("nonce")){const e="cookie"===t.get("code")?o.parse(document.cookie)["auth-code"]:t.get("code"),i=await a.calculateAntiAbuseHash({client_id:this.applicationId,authenticationRequestId:n.nonce,code:e}),r={grant_type:"authorization_code",redirect_uri:n.redirectUrl,client_id:this.applicationId,code:e,code_verifier:n.codeVerifier,antiAbuseHash:i};try{const e=await this.httpClient.post(`/authentication/${n.nonce}/tokens`,this.enableCredentials,r),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"}),l.set(e.data.id_token,i),d(),!0}catch(e){if(this.logger&&this.logger.log({title:"[Authress Login SDK] Failed exchange authentication response for a token.",error:e}),e.data&&"invalid_request"===e.data.error)return!1;throw e.data||e}}if(r.isLocalHost()&&t.get("nonce")&&t.get("access_token")&&(!n.nonce||n.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"}),l.set(t.get("id_token"),n),d(),!0}if(this.getUserIdentity())return d(),!0;if(!r.isLocalHost()&&!e){try{const e=await this.httpClient.patch("/session",this.enableCredentials,{},null,!0);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"}),l.set(e.data.id_token,n)}}catch(e){400===e.status||404===e.status||409===e.status?this.logger&&this.logger.log&&this.logger.log({title:"[Authress Login SDK] User does not have an existing authentication session",error:e}):this.logger&&this.logger.log&&this.logger.log({title:"[Authress Login SDK] Failed attempting to check if the user has an existing authentication session",error:e})}if(this.getUserIdentity())return d(),!0}return!1}async updateExtensionAuthenticationRequest({state:e,connectionId:t,tenantLookupIdentifier:n,connectionProperties:o,hint:i}){if(!t&&!n&&!i){const e=Error("connectionId or tenantLookupIdentifier must be specified");throw e.code="InvalidConnection",e}const s=new URLSearchParams(r.getCurrentLocation().search),c=e||s.get("state");if(!c){const e=Error("The `state` parameters must be specified to update this authentication request");throw e.code="InvalidAuthenticationRequest",e}try{const e=i||n,s=await a.calculateAntiAbuseHash({connectionId:t,tenantLookupIdentifier:e,authenticationRequestId:c}),l=await this.httpClient.patch(`/authentication/${c}`,!0,{antiAbuseHash:s,connectionId:t,tenantLookupIdentifier:e,connectionProperties:o});if(new URL(l.data.authenticationUrl).hostname===r.getCurrentLocation().hostname)return{authenticationUrl:l.data.authenticationUrl};r.assign(l.data.authenticationUrl)}catch(e){if(this.logger&&this.logger.log&&this.logger.log({title:"[Authress Login SDK] Failed to update extension authentication request",error:e}),e.status&&e.status>=400&&e.status<500){const t=Error(e.data&&(e.data.title||e.data.errorCode)||e.data||"Unknown Error");throw t.code=e.data&&e.data.errorCode,t}throw e.data||e}return await new Promise((e=>setTimeout(e,5e3))),null}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 in 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&&!r.isLocalHost()?{}:{Authorization:`Bearer ${t}`};try{await this.httpClient.delete(`/identities/${encodeURIComponent(e)}`,this.enableCredentials,n)}catch(e){if(this.logger&&this.logger.log&&this.logger.log({title:"[Authress Login SDK] Failed to unlink user identity",error:e}),e.status&&e.status>=400&&e.status<500){const t=Error(e.data&&(e.data.title||e.data.errorCode)||e.data||"Unknown Error");throw t.code=e.data&&e.data.errorCode,t}throw e.data||e}}async linkIdentityWithOneTimeCode({connectionId:e,redirectUrl:t}){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 an existing account before linking a second account.");throw e.code="NotLoggedIn",e}let n;try{n=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:o}=await a.getAuthCodes(),i=await a.calculateAntiAbuseHash({connectionId:e,applicationId:this.applicationId});try{const s=t&&new URL(t).toString()||r.getCurrentLocation().href,a=this.enableCredentials&&!r.isLocalHost()?{}:{Authorization:`Bearer ${n}`},c=await this.httpClient.post("/authentication",this.enableCredentials,{antiAbuseHash:i,linkIdentity:!0,redirectUrl:s,codeChallengeMethod:"S256",codeChallenge:o,connectionId:e,applicationId:this.applicationId},a);return{authenticationUrl:c.data.authenticationUrl,authenticationRequestId:c.data.authenticationRequestId}}catch(e){if(this.logger&&this.logger.log&&this.logger.log({title:"[Authress Login SDK] Failed to start user identity link",error:e}),e.status&&e.status>=400&&e.status<500){const t=Error(e.data&&(e.data.title||e.data.errorCode)||e.data||"Unknown Error");throw t.code=e.data&&e.data.errorCode,t}throw 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 i;try{i=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:s}=await a.getAuthCodes(),c=await a.calculateAntiAbuseHash({connectionId:e,tenantLookupIdentifier:t,applicationId:this.applicationId});try{const a=n&&new URL(n).toString()||r.getCurrentLocation().href,l=this.enableCredentials&&!r.isLocalHost()?{}:{Authorization:`Bearer ${i}`},d=await this.httpClient.post("/authentication",this.enableCredentials,{antiAbuseHash:c,linkIdentity:!0,redirectUrl:a,codeChallengeMethod:"S256",codeChallenge:s,connectionId:e,tenantLookupIdentifier:t,connectionProperties:o,applicationId:this.applicationId},l);r.assign(d.data.authenticationUrl)}catch(e){if(this.logger&&this.logger.log&&this.logger.log({title:"[Authress Login SDK] Failed to start user identity link",error:e}),e.status&&e.status>=400&&e.status<500){const t=Error(e.data&&(e.data.title||e.data.errorCode)||e.data||"Unknown Error");throw t.code=e.data&&e.data.errorCode,t}throw e}await new Promise((e=>setTimeout(e,5e3)))}async authenticateWithOneTimeCode(e={}){const{serviceClientId:t,inviteId:n,redirectUrl:o,force:i,responseLocation:s,flowType:c,clearUserDataBeforeLogin:d,audiences:u}=e||{};if(s&&"cookie"!==s&&"query"!==s&&"none"!==s){const e=Error("Authentication response location is not valid");throw e.code="InvalidResponseLocation",e}if(!t){const e=Error("The Passwordless Service Client ID is required");throw e.code="InvalidInput",e}if(!n&&!i&&await this.userSessionExists()){const n=await this.ensureToken(),o=a.decode(n);if(o&&o.azp&&t!==o.azp){this.logger&&this.logger.log&&this.logger.log({title:"[Authress Login SDK] Authentication blocked because the user is already logged in, and the requested authentication parameters do not match the original session.",requestedAuthenticationOptions:e,currentAuthenticationSessionData:o});const t=Error('Authentication requested for user that is already logged in, but the connectionId specified does not match their existing session.\n Recommended Options:\n (1) If the goal is to force them to log in with this new connection and ignore their existing session, use the "force" flag.\n (2) If the goal is link their current identity with a new from the new connection, use the linkIdentity() method.\n (3) If the goal is skip log in if they are already logged in or force log in with the connectionId, first check if userSessionExists() and then only if "false", call authenticate().');throw t.code="AuthenticationConstraintContention",t}return null}const{codeVerifier:h,codeChallenge:p}=await a.getAuthCodes(),f=await a.calculateAntiAbuseHash({serviceClientId:t,inviteId:n,applicationId:this.applicationId,audiences:u});try{const e=o&&new URL(o).toString()||r.getCurrentLocation().href;!1!==d&&l.clear();const i=await this.httpClient.post("/authentication",this.enableCredentials,{antiAbuseHash:f,redirectUrl:e,codeChallengeMethod:"S256",codeChallenge:p,audiences:u,connectionId:t,inviteId:n,applicationId:this.applicationId,responseLocation:s,flowType:c});return localStorage.setItem(g,JSON.stringify({nonce:i.data.authenticationRequestId,codeVerifier:h,lastConnectionId:t,redirectUrl:e,enableCredentials:i.data.enableCredentials})),{authenticationUrl:i.data.authenticationUrl,authenticationRequestId:i.data.authenticationRequestId}}catch(e){if(this.logger&&this.logger.log&&this.logger.log({title:"[Authress Login SDK] Failed to start authentication for user",error:e}),e.status&&e.status>=400&&e.status<500){const t=Error(e.data&&(e.data.title||e.data.errorCode)||e.data||"Unknown Error");throw t.code=e.data&&e.data.errorCode,t}throw e.data||e}}async authenticate(e={}){const{connectionId:t,tenantLookupIdentifier:n,inviteId:o,redirectUrl:i,force:s,responseLocation:c,flowType:d,connectionProperties:u,openType:h,multiAccount:p,clearUserDataBeforeLogin:f,audiences:m}=e||{};if(c&&"cookie"!==c&&"query"!==c&&"none"!==c){const e=Error("Authentication response location is not valid");throw e.code="InvalidResponseLocation",e}if(!o&&!s&&!p&&await this.userSessionExists()){const n=await this.ensureToken(),o=a.decode(n);if(t&&o&&o.azp&&t!==o.azp){this.logger&&this.logger.log&&this.logger.log({title:"[Authress Login SDK] Authentication blocked because the user is already logged in, and the requested authentication parameters do not match the original session.",requestedAuthenticationOptions:e,currentAuthenticationSessionData:o});const t=Error('Authentication requested for user that is already logged in, but the connectionId specified does not match their existing session.\n Recommended Options:\n (1) If the goal is to force them to log in with this new connection and ignore their existing session, use the "force" flag.\n (2) If the goal is link their current identity with a new from the new connection, use the linkIdentity() method.\n (3) If the goal is skip log in if they are already logged in or force log in with the connectionId, first check if userSessionExists() and then only if "false", call authenticate().');throw t.code="AuthenticationConstraintContention",t}return null}const{codeVerifier:w,codeChallenge:y}=await a.getAuthCodes(),k=await a.calculateAntiAbuseHash({connectionId:t,tenantLookupIdentifier:n,inviteId:o,applicationId:this.applicationId,audiences:m});try{const e=i&&new URL(i).toString()||r.getCurrentLocation().href;!1!==f&&l.clear();const s=await this.httpClient.post("/authentication",this.enableCredentials,{antiAbuseHash:k,redirectUrl:e,codeChallengeMethod:"S256",codeChallenge:y,audiences:m,connectionId:t,tenantLookupIdentifier:n,inviteId:o,connectionProperties:u,applicationId:this.applicationId,responseLocation:c,flowType:d,multiAccount:p});if(localStorage.setItem(g,JSON.stringify({nonce:s.data.authenticationRequestId,codeVerifier:w,lastConnectionId:t,tenantLookupIdentifier:n,redirectUrl:e,enableCredentials:s.data.enableCredentials,multiAccount:p})),!s.data.authenticationUrl||new URL(s.data.authenticationUrl).hostname===r.getCurrentLocation().hostname)return{authenticationUrl:s.data.authenticationUrl,authenticationRequestId:s.data.authenticationRequestId};if("tab"===h){const e=r.open(s.data.authenticationUrl,"_blank");e&&!e.closed&&void 0!==e.closed||r.assign(s.data.authenticationUrl)}else r.assign(s.data.authenticationUrl)}catch(e){if(this.logger&&this.logger.log&&this.logger.log({title:"[Authress Login SDK] Failed to start authentication for user",error:e}),e.status&&e.status>=400&&e.status<500){const t=Error(e.data&&(e.data.title||e.data.errorCode)||e.data||"Unknown Error");throw t.code=e.data&&e.data.errorCode,t}throw e.data||e}return await new Promise((e=>setTimeout(e,5e3))),null}async ensureToken(e){if(e&&0===e.timeoutInMillis){if(!this.getUserIdentity()){const e=Error("No token available because the user is not logged in.");throw e.code="TokenTimeout",e}const t=l.getAuthorizationTokens(),n=t.find((t=>{try{const n=a.decode(t);return(null==n?void 0:n.iss)===this.hostUrl||(this.logger&&this.logger.log&&this.logger.log({title:"[Authress Login SDK] Skipping stored authorization cookie because the issuer does not match the library configured value.",requestedAuthenticationOptions:e,currentAuthenticationSessionData:n}),!1)}catch(n){return this.logger&&this.logger.log&&this.logger.log({title:"[Authress Login SDK] Skipping stored authorization cookie because it is no longer a valid token.",requestedAuthenticationOptions:e,currentAuthenticationSessionDataToken:t,error:n}),!1}}));return n||(t.length?(this.logger&&this.logger.error&&this.logger.log({title:"[Authress Login SDK] No matching issuer token found, returning the first valid token instead."}),t[0]):(this.logger&&this.logger.error&&this.logger.error({title:"[Authress Login SDK] HttpOnly access token configuration has blocked the returning of a valid token. The application specified in the Authress LoginClient constructor has been configured to block returning access tokens via the enableAccessToToken property. To use the loginClient.ensureToken() method in production, please set the enableAccessToToken to true. Note: This setting does not affect localhost.",options:e}),null))}await this.userSessionExists();const t=Object.assign({timeoutInMillis:5e3},e||{}),n=this.waitForUserSession(),o=-1===t.timeoutInMillis||t.timeoutInMillis>2**31-1?2**31-1:t.timeoutInMillis,i=new Promise(((e,t)=>setTimeout(t,o||0)));try{await Promise.race([n,i])}catch(e){const t=Error("No token available because the user is still not logged in and the timeout has been exceeded. If you are seeing this error, it is because you have called ensureToken() without first validating that the user is logged. Review the route guards and checks for user sessions in your source code. ensureToken() should only ever be called after you have verified that the user is logged in.");throw t.code="TokenTimeout",t}const r=l.getAuthorizationTokens(),s=r.find((t=>{try{const n=a.decode(t);return(null==n?void 0:n.iss)===this.hostUrl||(this.logger&&this.logger.log&&this.logger.log({title:"[Authress Login SDK] Skipping stored authorization cookie because the issuer does not match the library configured value.",requestedAuthenticationOptions:e,currentAuthenticationSessionData:n}),!1)}catch(n){return this.logger&&this.logger.log&&this.logger.log({title:"[Authress Login SDK] Skipping stored authorization cookie because it is no longer a valid token.",requestedAuthenticationOptions:e,currentAuthenticationSessionDataToken:t,error:n}),!1}}));if(s)return s;if(r.length)return this.logger&&this.logger.error&&this.logger.log({title:"[Authress Login SDK] No matching issuer token found, returning the first valid token instead."}),r[0];return this.getUserIdentity()?(this.logger&&this.logger.error&&this.logger.error({title:"[Authress Login SDK] Your Authress Application access token configuration has blocked the returning of a valid token because the setting HttpOnly has been enabled. The application specified in the Authress LoginClient constructor has been configured to block returning access tokens via the enableAccessToToken property. To use the loginClient.ensureToken() method in production, please set the enableAccessToToken to true. (LocalHost Note: This setting does not affect localhost development, and you may still see ensureToken work successfully during development, but fail with this error in production. This is because HttpOnly does not work for LocalHost)",options:e}),null):(this.logger&&this.logger.error&&this.logger.error({title:"[Authress Login SDK] User completed login but the user identity still does not exist. This happened because there is a race condition in your code and why waiting for ensureToken() to complete, the user was logged out. Returning null."}),null)}async logout(e){let t;if(e)try{new URL(e),t=e}catch(n){try{t=new URL(e,r.getCurrentLocation().href).toString()}catch(t){const n=Error(`The logout redirect url is not valid URL: ${e}`);throw n.code="InvalidRedirectUrl",n}}if(l.clear(),this.sanitizeQueryParameters(),u=new Promise((e=>d=e)),this.enableCredentials)try{return await this.httpClient.delete("/session",this.enableCredentials),this.lastSessionCheck=0,void(e&&e!==r.getCurrentLocation().href&&r.assign(e))}catch(e){}const n=new URL("/logout",this.hostUrl);n.searchParams.set("redirect_uri",t||r.getCurrentLocation().href),n.searchParams.set("client_id",this.applicationId),r.assign(n.toString()),this.lastSessionCheck=0,await new Promise((e=>setTimeout(e,500)))}sanitizeQueryParameters(){const e=new URL(r.getCurrentLocation());e.searchParams.delete("iss"),e.searchParams.delete("nonce"),e.searchParams.delete("code"),e.searchParams.delete("expires_in"),e.searchParams.delete("access_token"),e.searchParams.delete("id_token"),history.replaceState({},void 0,e.toString())}},ExtensionClient:f,UserConfigurationScreen:{Profile:"Profile",MFA:"MFA"}}},427:(e,t)=>{"use strict";t.parse=function(e,t){if("string"!=typeof e)throw new TypeError("argument str must be a string");var n={},i=e.length;if(i<2)return n;var r=t&&t.decode||d,s=0,a=0,h=0;do{if(-1===(a=e.indexOf("=",s)))break;if(-1===(h=e.indexOf(";",s)))h=i;else if(a>h){s=e.lastIndexOf(";",a-1)+1;continue}var p=c(e,s,a),g=l(e,a,p),f=e.slice(p,g);if(!o.call(n,f)){var m=c(e,a+1,h),w=l(e,h,m);34===e.charCodeAt(m)&&34===e.charCodeAt(w-1)&&(m++,w--);var y=e.slice(m,w);n[f]=u(y,r)}s=h+1}while(s<i);return n},t.serialize=function(e,t,o){var c=o&&o.encode||encodeURIComponent;if("function"!=typeof c)throw new TypeError("option encode is invalid");if(!i.test(e))throw new TypeError("argument name is invalid");var l=c(t);if(!r.test(l))throw new TypeError("argument val is invalid");var d=e+"="+l;if(!o)return d;if(null!=o.maxAge){var u=Math.floor(o.maxAge);if(!isFinite(u))throw new TypeError("option maxAge is invalid");d+="; Max-Age="+u}if(o.domain){if(!s.test(o.domain))throw new TypeError("option domain is invalid");d+="; Domain="+o.domain}if(o.path){if(!a.test(o.path))throw new TypeError("option path is invalid");d+="; Path="+o.path}if(o.expires){var h=o.expires;if(!function(e){return"[object Date]"===n.call(e)}(h)||isNaN(h.valueOf()))throw new TypeError("option expires is invalid");d+="; Expires="+h.toUTCString()}o.httpOnly&&(d+="; HttpOnly");o.secure&&(d+="; Secure");o.partitioned&&(d+="; Partitioned");if(o.priority){switch("string"==typeof o.priority?o.priority.toLowerCase():o.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(o.sameSite){switch("string"==typeof o.sameSite?o.sameSite.toLowerCase():o.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=Object.prototype.hasOwnProperty,i=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,r=/^("?)[\u0021\u0023-\u002B\u002D-\u003A\u003C-\u005B\u005D-\u007E]*\1$/,s=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,a=/^[\u0020-\u003A\u003D-\u007E]*$/;function c(e,t,n){do{var o=e.charCodeAt(t);if(32!==o&&9!==o)return t}while(++t<n);return n}function l(e,t,n){for(;t>n;){var o=e.charCodeAt(--t);if(32!==o&&9!==o)return t+1}return n}function d(e){return-1!==e.indexOf("%")?decodeURIComponent(e):e}function u(e,t){try{return t(e)}catch(t){return e}}},568:(e,t,n)=>{const o=n(836),{sanitizeUrl:i}=n(332),r=n(629),s="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=i(e),this.accessToken=null,r.onLoad((async()=>{await this.requestToken({silent:!0})}))}async getUserIdentity(){const e=this.accessToken&&await 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(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(r.getCurrentLocation().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:i}=JSON.parse(localStorage.getItem(s)||"{}"),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:i})}),c=await a.json();this.accessToken=c.access_token;const l=new URL(r.getCurrentLocation());return l.searchParams.delete("code"),l.searchParams.delete("iss"),l.searchParams.delete("nonce"),l.searchParams.delete("expires_in"),l.searchParams.delete("access_token"),l.searchParams.delete("id_token"),history.replaceState({},void 0,l.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 i=new URL(this.authressCustomDomain),{codeVerifier:a,codeChallenge:c}=o.getAuthCodes(),l=e||r.getCurrentLocation().href;return localStorage.setItem(s,JSON.stringify({codeVerifier:a,redirectUrl:l})),i.searchParams.set("client_id",this.extensionId),i.searchParams.set("code_challenge",c),i.searchParams.set("code_challenge_method","S256"),i.searchParams.set("redirect_uri",l),r.assign(i.toString()),await new Promise((e=>setTimeout(e,5e3))),null}}},629:e=>{e.exports=new class{onLoad(e){"undefined"!=typeof window&&(window.onload=e)}isLocalHost(){return"undefined"!=typeof window&&window.location&&("localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname)}getCurrentLocation(){return"undefined"!=typeof window&&new URL(window.location)||new URL("http://localhost:8080")}getDocument(){return"undefined"==typeof window||"undefined"==typeof document?null:document}assign(e){return"undefined"==typeof window?null:window.location.assign(e.toString())}open(e){return"undefined"==typeof window?null:window.open(e.toString())}}},836:(e,t,n)=>{const o=n(878);e.exports=new class{decode(e){var t;return e?null===(t=this.decodeFull(e))||void 0===t?void 0:t.payload: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;let t=null;try{t=JSON.parse(o.decode(e.split(".")[0]))}catch(e){}try{const 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)}}async calculateAntiAbuseHash(e){const t=Date.now(),n=Object.values(e).filter((e=>e)).join("|");let i=0,r=null;for(;++i&&(r=o.encode(await(window.crypto||window.msCrypto).subtle.digest("SHA-256",(new TextEncoder).encode(`${t};${i};${n}`))),!r.match(/^00/)););return`v2;${t};${i};${r}`}}},878: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(/=+$/,"")}}},o={};function i(e){var t=o[e];if(void 0!==t){if(void 0!==t.error)throw t.error;return t.exports}var r=o[e]={exports:{}};try{var s={id:e,module:r,factory:n[e],require:i};i.i.forEach((function(e){e(s)})),r=s.module,s.factory.call(r.exports,r,r.exports,s.require)}catch(e){throw r.error=e,e}return r.exports}return i.m=n,i.c=o,i.i=[],i.hu=e=>e+"."+i.h()+".hot-update.js",i.hmrF=()=>"main."+i.h()+".hot-update.json",i.h=()=>"96fb51b97194bd81793d",i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e={},t="authress:",i.l=(n,o,r,s)=>{if(e[n])e[n].push(o);else{var a,c;if(void 0!==r)for(var l=document.getElementsByTagName("script"),d=0;d<l.length;d++){var u=l[d];if(u.getAttribute("src")==n||u.getAttribute("data-webpack")==t+r){a=u;break}}a||(c=!0,(a=document.createElement("script")).charset="utf-8",a.timeout=120,i.nc&&a.setAttribute("nonce",i.nc),a.setAttribute("data-webpack",t+r),a.src=n),e[n]=[o];var h=(t,o)=>{a.onerror=a.onload=null,clearTimeout(p);var i=e[n];if(delete e[n],a.parentNode&&a.parentNode.removeChild(a),i&&i.forEach((e=>e(o))),t)return t(o)},p=setTimeout(h.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=h.bind(null,a.onerror),a.onload=h.bind(null,a.onload),c&&document.head.appendChild(a)}},(()=>{var e,t,n,o={},r=i.c,s=[],a=[],c="idle",l=0,d=[];function u(e){c=e;for(var t=[],n=0;n<a.length;n++)t[n]=a[n].call(null,e);return Promise.all(t).then((function(){}))}function h(){0==--l&&u("ready").then((function(){if(0===l){var e=d;d=[];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(i.hmrM).then((function(n){return n?u("prepare").then((function(){var o=[];return t=[],Promise.all(Object.keys(i.hmrC).reduce((function(e,r){return i.hmrC[r](n.c,n.r,n.m,e,t,o),e}),[])).then((function(){return t=function(){return e?f(e):u("ready").then((function(){return o}))},0===l?t():new Promise((function(e){d.push((function(){e(t())}))}));var t}))})):u(m()?"ready":"idle").then((function(){return null}))}))}function g(e){return"ready"!==c?Promise.resolve().then((function(){throw new Error("apply() is only allowed in ready status (state: "+c+")")})):f(e)}function f(e){e=e||{},m();var o=t.map((function(t){return t(e)}));t=void 0;var i=o.map((function(e){return e.error})).filter(Boolean);if(i.length>0)return u("abort").then((function(){throw i[0]}));var r=u("dispose");o.forEach((function(e){e.dispose&&e.dispose()}));var s,a=u("apply"),c=function(e){s||(s=e)},l=[];return o.forEach((function(e){if(e.apply){var t=e.apply(c);if(t)for(var n=0;n<t.length;n++)l.push(t[n])}})),Promise.all([r,a]).then((function(){return s?u("fail").then((function(){throw s})):n?f(e).then((function(e){return l.forEach((function(t){e.indexOf(t)<0&&e.push(t)})),e})):u("idle").then((function(){return l}))}))}function m(){if(n)return t||(t=[]),Object.keys(i.hmrI).forEach((function(e){n.forEach((function(n){i.hmrI[e](n,t)}))})),n=void 0,!0}i.hmrD=o,i.i.push((function(d){var f,m,w,y,k=d.module,v=function(t,n){var o=r[n];if(!o)return t;var i=function(i){if(o.hot.active){if(r[i]){var a=r[i].parents;-1===a.indexOf(n)&&a.push(n)}else s=[n],e=i;-1===o.children.indexOf(i)&&o.children.push(i)}else console.warn("[HMR] unexpected require("+i+") from disposed module "+n),s=[];return t(i)},a=function(e){return{configurable:!0,enumerable:!0,get:function(){return t[e]},set:function(n){t[e]=n}}};for(var d in t)Object.prototype.hasOwnProperty.call(t,d)&&"e"!==d&&Object.defineProperty(i,d,a(d));return i.e=function(e,n){return function(e){switch(c){case"ready":u("prepare");case"prepare":return l++,e.then(h,h),e;default:return e}}(t.e(e,n))},i}(d.require,d.id);k.hot=(f=d.id,m=k,y={_acceptedDependencies:{},_acceptedErrorHandlers:{},_declinedDependencies:{},_selfAccepted:!1,_selfDeclined:!1,_selfInvalidated:!1,_disposeHandlers:[],_main:w=e!==f,_requireSelf:function(){s=m.parents.slice(),e=w?void 0:f,i(f)},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(i.hmrI).forEach((function(e){i.hmrI[e](f,t)})),u("ready");break;case"ready":Object.keys(i.hmrI).forEach((function(e){i.hmrI[e](f,t)}));break;case"prepare":case"check":case"dispose":case"apply":(n=n||[]).push(f)}},check:p,apply:g,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:o[f]},e=void 0,y),k.parents=s,k.children=[],s=[],d.require=v})),i.hmrC={},i.hmrI={}})(),i.p="",(()=>{var e,t,n,o,r,s=i.hmrS_jsonp=i.hmrS_jsonp||{792:0},a={};function c(t,n){return e=n,new Promise(((e,n)=>{a[t]=e;var o=i.p+i.hu(t),r=new Error;i.l(o,(e=>{if(a[t]){a[t]=void 0;var o=e&&("load"===e.type?"missing":e.type),i=e&&e.target&&e.target.src;r.message="Loading hot update chunk "+t+" failed.\n("+o+": "+i+")",r.name="ChunkLoadError",r.type=o,r.request=i,n(r)}}))}))}function l(e){function a(e){for(var t=[e],n={},o=t.map((function(e){return{chain:[e],id:e}}));o.length>0;){var r=o.pop(),s=r.id,a=r.chain,l=i.c[s];if(l&&(!l.hot._selfAccepted||l.hot._selfInvalidated)){if(l.hot._selfDeclined)return{type:"self-declined",chain:a,moduleId:s};if(l.hot._main)return{type:"unaccepted",chain:a,moduleId:s};for(var d=0;d<l.parents.length;d++){var u=l.parents[d],h=i.c[u];if(h){if(h.hot._declinedDependencies[s])return{type:"declined",chain:a.concat([u]),moduleId:s,parentId:u};-1===t.indexOf(u)&&(h.hot._acceptedDependencies[s]?(n[u]||(n[u]=[]),c(n[u],[s])):(delete n[u],t.push(u),o.push({chain:a.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)}}i.f&&delete i.f.jsonpHmr,t=void 0;var l={},d=[],u={},h=function(e){console.warn("[HMR] unexpected require("+e.id+") to disposed module")};for(var p in n)if(i.o(n,p)){var g=n[p],f=g?a(p):{type:"disposed",moduleId:p},m=!1,w=!1,y=!1,k="";switch(f.chain&&(k="\nUpdate propagation: "+f.chain.join(" -> ")),f.type){case"self-declined":e.onDeclined&&e.onDeclined(f),e.ignoreDeclined||(m=new Error("Aborted because of self decline: "+f.moduleId+k));break;case"declined":e.onDeclined&&e.onDeclined(f),e.ignoreDeclined||(m=new Error("Aborted because of declined dependency: "+f.moduleId+" in "+f.parentId+k));break;case"unaccepted":e.onUnaccepted&&e.onUnaccepted(f),e.ignoreUnaccepted||(m=new Error("Aborted because "+p+" is not accepted"+k));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(m)return{error:m};if(w)for(p in u[p]=g,c(d,f.outdatedModules),f.outdatedDependencies)i.o(f.outdatedDependencies,p)&&(l[p]||(l[p]=[]),c(l[p],f.outdatedDependencies[p]));y&&(c(d,[f.moduleId]),u[p]=h)}n=void 0;for(var v,b=[],C=0;C<d.length;C++){var I=d[C],A=i.c[I];A&&(A.hot._selfAccepted||A.hot._main)&&u[I]!==h&&!A.hot._selfInvalidated&&b.push({module:I,require:A.hot._requireSelf,errorHandler:A.hot._selfAccepted})}return{dispose:function(){var e;o.forEach((function(e){delete s[e]})),o=void 0;for(var t,n=d.slice();n.length>0;){var r=n.pop(),a=i.c[r];if(a){var c={},u=a.hot._disposeHandlers;for(C=0;C<u.length;C++)u[C].call(null,c);for(i.hmrD[r]=c,a.hot.active=!1,delete i.c[r],delete l[r],C=0;C<a.children.length;C++){var h=i.c[a.children[C]];h&&((e=h.parents.indexOf(r))>=0&&h.parents.splice(e,1))}}}for(var p in l)if(i.o(l,p)&&(a=i.c[p]))for(v=l[p],C=0;C<v.length;C++)t=v[C],(e=a.children.indexOf(t))>=0&&a.children.splice(e,1)},apply:function(t){for(var n in u)i.o(u,n)&&(i.m[n]=u[n]);for(var o=0;o<r.length;o++)r[o](i);for(var s in l)if(i.o(l,s)){var a=i.c[s];if(a){v=l[s];for(var c=[],h=[],p=[],g=0;g<v.length;g++){var f=v[g],m=a.hot._acceptedDependencies[f],w=a.hot._acceptedErrorHandlers[f];if(m){if(-1!==c.indexOf(m))continue;c.push(m),h.push(w),p.push(f)}}for(var y=0;y<c.length;y++)try{c[y].call(null,v)}catch(n){if("function"==typeof h[y])try{h[y](n,{moduleId:s,dependencyId:p[y]})}catch(o){e.onErrored&&e.onErrored({type:"accept-error-handler-errored",moduleId:s,dependencyId:p[y],error:o,originalError:n}),e.ignoreErrored||(t(o),t(n))}else e.onErrored&&e.onErrored({type:"accept-errored",moduleId:s,dependencyId:p[y],error:n}),e.ignoreErrored||t(n)}}}for(var k=0;k<b.length;k++){var C=b[k],I=C.module;try{C.require(I)}catch(n){if("function"==typeof C.errorHandler)try{C.errorHandler(n,{moduleId:I,module:i.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 d}}}this.webpackHotUpdateauthress=(t,o,s)=>{for(var c in o)i.o(o,c)&&(n[c]=o[c],e&&e.push(c));s&&r.push(s),a[t]&&(a[t](),a[t]=void 0)},i.hmrI.jsonp=function(e,t){n||(n={},r=[],o=[],t.push(l)),i.o(n,e)||(n[e]=i.m[e])},i.hmrC.jsonp=function(e,a,d,u,h,p){h.push(l),t={},o=a,n=d.reduce((function(e,t){return e[t]=!1,e}),{}),r=[],e.forEach((function(e){i.o(s,e)&&void 0!==s[e]?(u.push(c(e,p)),t[e]=!0):t[e]=!1})),i.f&&(i.f.jsonpHmr=function(e,n){t&&i.o(t,e)&&!t[e]&&(n.push(c(e)),t[e]=!0)})},i.hmrM=()=>{if("undefined"==typeof fetch)throw new Error("No browser support: need fetch API");return fetch(i.p+i.hmrF()).then((e=>{if(404!==e.status){if(!e.ok)throw new Error("Failed to fetch update manifest "+e.statusText);return e.json()}}))}})(),i(354)})()));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Authress={})}(this,function(e){"use strict";function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function n(e,t,n,r,o,i,a){try{var s=e[i](a),c=s.value}catch(u){return void n(u)}s.done?t(c):Promise.resolve(c).then(r,o)}function r(e){return function(){var t=this,r=arguments;return new Promise(function(o,i){var a=e.apply(t,r);function s(e){n(a,o,i,s,c,"next",e)}function c(e){n(a,o,i,s,c,"throw",e)}s(void 0)})}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,d(r.key),r)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function a(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=f(e))||t){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function s(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var s=r&&r.prototype instanceof u?r:u,l=Object.create(s.prototype);return c(l,"_invoke",function(n,r,o){var i,s,c,u=0,l=o||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return i=t,s=0,c=e,h.n=n,a}};function f(n,r){for(s=n,c=r,t=0;!d&&u&&!o&&t<l.length;t++){var o,i=l[t],f=h.p,p=i[2];n>3?(o=p===r)&&(c=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=e):i[0]<=f&&((o=n<2&&f<i[1])?(s=0,h.v=r,h.n=i[1]):f<p&&(o=n<3||i[0]>r||r>p)&&(i[4]=n,i[5]=r,h.n=p,s=0))}if(o||n>1)return a;throw d=!0,r}return function(o,l,p){if(u>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,c=p;(t=s<2?e:c)||!d;){i||(s?s<3?(s>1&&(h.n=-1),f(s,c)):h.n=c:h.v=c);try{if(u=2,i){if(s||(o="next"),t=i[o]){if(!(t=t.call(i,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,s<2&&(s=0)}else 1===s&&(t=i.return)&&t.call(i),s<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),s=1);i=e}else if((t=(d=h.n<0)?c:n.call(r,h))!==a)break}catch(g){i=e,s=1,c=g}finally{u=1}}return{value:t,done:d}}}(n,o,i),!0),l}var a={};function u(){}function l(){}function d(){}t=Object.getPrototypeOf;var h=[][r]?t(t([][r]())):(c(t={},r,function(){return this}),t),f=d.prototype=u.prototype=Object.create(h);function p(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,c(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return l.prototype=d,c(f,"constructor",d),c(d,"constructor",l),l.displayName="GeneratorFunction",c(d,o,"GeneratorFunction"),c(f),c(f,o,"Generator"),c(f,r,function(){return this}),c(f,"toString",function(){return"[object Generator]"}),(s=function(){return{w:i,m:p}})()}function c(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(i){o=0}(c=function(e,t,n,r){function i(t,n){c(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(i("next",0),i("throw",1),i("return",2))})(e,t,n,r)}function u(e){if(null!=e){var t=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}throw new TypeError(typeof e+" is not iterable")}function l(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||f(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function h(e){return(h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function f(e,n){if(e){if("string"==typeof e)return t(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}}function p(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var g,v={};const y=p(function(){if(g)return v;g=1,v.parse=function(e,n){if("string"!=typeof e)throw new TypeError("argument str must be a string");var r={},o=e.length;if(o<2)return r;var i=n&&n.decode||c,l=0,d=0,h=0;do{if(-1===(d=e.indexOf("=",l)))break;if(-1===(h=e.indexOf(";",l)))h=o;else if(d>h){l=e.lastIndexOf(";",d-1)+1;continue}var f=a(e,l,d),p=s(e,d,f),g=e.slice(f,p);if(!t.call(r,g)){var v=a(e,d+1,h),y=s(e,h,v);34===e.charCodeAt(v)&&34===e.charCodeAt(y-1)&&(v++,y--);var w=e.slice(v,y);r[g]=u(w,i)}l=h+1}while(l<o);return r},v.serialize=function(t,a,s){var c=s&&s.encode||encodeURIComponent;if("function"!=typeof c)throw new TypeError("option encode is invalid");if(!n.test(t))throw new TypeError("argument name is invalid");var u=c(a);if(!r.test(u))throw new TypeError("argument val is invalid");var l=t+"="+u;if(!s)return l;if(null!=s.maxAge){var d=Math.floor(s.maxAge);if(!isFinite(d))throw new TypeError("option maxAge is invalid");l+="; Max-Age="+d}if(s.domain){if(!o.test(s.domain))throw new TypeError("option domain is invalid");l+="; Domain="+s.domain}if(s.path){if(!i.test(s.path))throw new TypeError("option path is invalid");l+="; Path="+s.path}if(s.expires){var h=s.expires;if(!function(t){return"[object Date]"===e.call(t)}(h)||isNaN(h.valueOf()))throw new TypeError("option expires is invalid");l+="; Expires="+h.toUTCString()}s.httpOnly&&(l+="; HttpOnly");s.secure&&(l+="; Secure");s.partitioned&&(l+="; Partitioned");if(s.priority){switch("string"==typeof s.priority?s.priority.toLowerCase():s.priority){case"low":l+="; Priority=Low";break;case"medium":l+="; Priority=Medium";break;case"high":l+="; 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:l+="; SameSite=Strict";break;case"lax":l+="; SameSite=Lax";break;case"strict":l+="; SameSite=Strict";break;case"none":l+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return l};var e=Object.prototype.toString,t=Object.prototype.hasOwnProperty,n=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,r=/^("?)[\u0021\u0023-\u002B\u002D-\u003A\u003C-\u005B\u005D-\u007E]*\1$/,o=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,i=/^[\u0020-\u003A\u003D-\u007E]*$/;function a(e,t,n){do{var r=e.charCodeAt(t);if(32!==r&&9!==r)return t}while(++t<n);return n}function s(e,t,n){for(;t>n;){var r=e.charCodeAt(--t);if(32!==r&&9!==r)return t+1}return n}function c(e){return-1!==e.indexOf("%")?decodeURIComponent(e):e}function u(e,t){try{return t(e)}catch(n){return e}}return v}());var w,m;const k=p(function(){if(m)return w;m=1;var e=1/0,t=17976931348623157e292,n=NaN,r="[object Symbol]",o=/^\s+|\s+$/g,i=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,s=/^0o[0-7]+$/i,c=parseInt,u=Object.prototype.toString;function l(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}return w=function(d,h,f){return d&&d.length?function(e,t,n){var r=-1,o=e.length;t<0&&(t=-t>o?0:o+t),(n=n>o?o:n)<0&&(n+=o),o=t>n?0:n-t>>>0,t>>>=0;for(var i=Array(o);++r<o;)i[r]=e[r+t];return i}(d,0,(h=f||void 0===h?1:(p=function(d){return d?(d=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&u.call(e)==r}(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(o,"");var d=a.test(e);return d||s.test(e)?c(e.slice(2),d?2:8):i.test(e)?n:+e}(d))===e||d===-1/0?(d<0?-1:1)*t:d==d?d:0:0===d?d:0}(h),g=p%1,p==p?g?p-g:p:0))<0?0:h):[];var p,g}}());const b=new(function(){return i(function e(){o(this,e)},[{key:"onLoad",value:function(e){"undefined"!=typeof window&&(window.onload=e)}},{key:"isLocalHost",value:function(){return"undefined"!=typeof window&&window.location&&("localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname)}},{key:"getCurrentLocation",value:function(){return"undefined"!=typeof window&&new URL(window.location)||new URL("http://localhost:8080")}},{key:"getDocument",value:function(){return"undefined"==typeof window||"undefined"==typeof document?null:document}},{key:"assign",value:function(e){return"undefined"==typeof window?null:window.location.assign(e.toString())}},{key:"open",value:function(e){return"undefined"==typeof window?null:window.open(e.toString())}}])}());function C(e){var t=e;t.startsWith("http")||(t="https://".concat(t));var n=new URL(t),r=n.host.match(/^([a-z0-9-]+)[.][a-z0-9-]+[.]authress[.]io$/);return r&&(n.host="".concat(r[1],".login.authress.io"),t=n.toString()),t.replace(/[/]+$/,"")}var S={"Content-Type":"application/json","X-Powered-By":"Authress Login SDK; Javascript; ".concat("2.6.407")},I=new Set(["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed","fetch failed","Load failed","<HTML DOCUMENT></HTML>"]);function A(e){return"Network Error"===e.message||"ERR_NETWORK"===e.code||!e.status||e.status>=500||"string"==typeof e.message&&I.has(e.message)||"string"==typeof e.data&&I.has(e.data)}function L(e){return U.apply(this,arguments)}function U(){return(U=r(s().m(function e(t){var n,r,o,i,a;return s().w(function(e){for(;;)switch(e.n){case 0:n=null,r=s().m(function e(r){var o,i;return s().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,t();case 1:return o=e.v,e.a(2,{v:o});case 2:if(e.p=2,(i=e.v).retryCount=r,A(i)){e.n=3;break}throw i;case 3:return(n=i).isNetworkError=!0,e.n=4,new Promise(function(e){return setTimeout(e,10*Math.pow(2,r))});case 4:return e.a(2,0)}},e,null,[[0,2]])}),i=0;case 1:if(!(i<5)){e.n=5;break}return e.d(u(r(i)),2);case 2:if(0!==(o=e.v)){e.n=3;break}return e.a(3,4);case 3:if(!o){e.n=4;break}return e.a(2,o.v);case 4:i++,e.n=1;break;case 5:throw(a=new Error("[Authress Login SDK] Http Request failed due to a Network Error even after multiple retries",{cause:n})).code="AuthressSdkNetworkError",a;case 6:return e.a(2)}},e)}))).apply(this,arguments)}var T=function(){return i(function e(t,n){if(o(this,e),!t)throw Error("Custom Authress Domain Host is required");this.logger=n;var r=new URL(C(t));this.loginUrl="".concat(r.origin,"/api")},[{key:"get",value:function(e,t,n,r){var o=this;return L(function(){return o.fetchWrapper("GET",e,null,n,t,r)})}},{key:"delete",value:function(e,t,n,r){var o=this;return L(function(){return o.fetchWrapper("DELETE",e,null,n,t,r)})}},{key:"post",value:function(e,t,n,r,o){var i=this;return L(function(){return i.fetchWrapper("POST",e,n,r,t,o)})}},{key:"put",value:function(e,t,n,r,o){var i=this;return L(function(){return i.fetchWrapper("PUT",e,n,r,t,o)})}},{key:"patch",value:function(e,t,n,r,o){var i=this;return L(function(){return i.fetchWrapper("PATCH",e,n,r,t,o)})}},{key:"fetchWrapper",value:(e=r(s().m(function e(t,n,r,o,i,a){var c,u,l,d,h,f,p,g,v,y,w,m,k;return s().w(function(e){for(;;)switch(e.p=e.n){case 0:return c="".concat(this.loginUrl).concat(n.toString()),u=t.toUpperCase(),l=Object.assign({},S,o),e.p=1,this.logger.debug({title:"[Authress Login SDK] HttpClient Request",method:u,url:c}),d={method:u,headers:l},r&&(d.body=JSON.stringify(r)),!b.isLocalHost()&&i&&(d.credentials="include"),e.n=2,fetch(c,d);case 2:if((h=e.v).ok){e.n=3;break}throw h;case 3:return f={},e.p=4,e.n=5,h.text();case 5:f=e.v,f=JSON.parse(f),e.n=7;break;case 6:e.p=6,e.v;case 7:return e.a(2,{url:c,method:u,headers:h.headers,status:h.status,data:f});case 8:return e.p=8,k=e.v,p=k,e.p=9,e.n=10,k.text();case 10:p=e.v,p=JSON.parse(p),e.n=12;break;case 11:e.p=11,e.v;case 12:if(!(g=p.stack&&p.stack.match(/chrome-extension:[/][/](\w+)[/]/))){e.n=13;break}throw this.logger.debug({title:"[Authress Login SDK] Fetch failed due to a browser extension - ".concat(u," - ").concat(c),method:u,url:c,data:r,headers:l,error:k,resolvedError:p,extensionErrorId:g}),(v=new Error("Extension Error ID: ".concat(g))).code="BROWSER_EXTENSION_ERROR",v;case 13:throw y=k.status,w="warn",m="[Authress Login SDK] HttpClient Response Error",k?401===y?(m="[Authress Login SDK] HttpClient Response Error due to invalid token",w="debug"):404===y?(m="[Authress Login SDK] HttpClient Response: Not Found",w="debug"):y<500&&a&&(w="debug"):m="[Authress Login SDK] HttpClient Response Error - Unknown error occurred",this.logger&&this.logger[w]&&this.logger[w]({title:m,online:"undefined"==typeof navigator||navigator.onLine,method:u,url:c,status:y,data:r,headers:l,error:k,resolvedError:p}),{url:c,method:u,status:y,data:p,headers:k.headers};case 14:return e.a(2)}},e,this,[[9,11],[4,6],[1,8]])})),function(t,n,r,o,i,a){return e.apply(this,arguments)})}]);var e}();function E(e){return String.fromCharCode(parseInt(e.slice(1),16))}function x(e){return"%".concat("00".concat(e.charCodeAt(0).toString(16)).slice(-2))}const D={decode:function(e){return function(e){return decodeURIComponent(Array.from(atob(e),x).join(""))}(e.replace(/-/g,"+").replace(/_/g,"/"))},encode:function(e){return e&&"object"===h(e)?btoa(String.fromCharCode.apply(String,l(new Uint8Array(e)))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=+$/,""):function(e){return btoa(encodeURIComponent(e).replace(/%[0-9A-F]{2}/g,E))}(e).replace(/\//g,"_").replace(/\+/g,"-").replace(/=+$/,"")}};var O=function(){return i(function e(){o(this,e)},[{key:"decode",value:function(e){var t;return e?null===(t=this.decodeFull(e))||void 0===t?void 0:t.payload:null}},{key:"decodeOrParse",value:function(e){if(!e)return null;if("object"===h(e))return e;try{return JSON.parse(e)}catch(t){return this.decode(e)}}},{key:"decodeFull",value:function(e){if(!e)return null;var t=null;try{t=JSON.parse(D.decode(e.split(".")[0]))}catch(r){}try{var n=JSON.parse(D.decode(e.split(".")[1]));return n.exp&&(n.exp=n.exp-10),{header:t,payload:n}}catch(r){return null}}},{key:"getAuthCodes",value:(t=r(s().m(function e(){var t,n,r;return s().w(function(e){for(;;)switch(e.n){case 0:return t=D.encode((window.crypto||window.msCrypto).getRandomValues(new Uint32Array(16)).toString()),e.n=1,(window.crypto||window.msCrypto).subtle.digest("SHA-256",(new TextEncoder).encode(t));case 1:return n=e.v,r=D.encode(n),e.a(2,{codeVerifier:t,codeChallenge:r})}},e)})),function(){return t.apply(this,arguments)})},{key:"calculateAntiAbuseHash",value:(e=r(s().m(function e(t){var n,r,o,i,a;return s().w(function(e){for(;;)switch(e.n){case 0:n=Date.now(),r=Object.values(t).filter(function(e){return e}).join("|"),o=0,i=null;case 1:if(!++o){e.n=4;break}return a=D,e.n=2,(window.crypto||window.msCrypto).subtle.digest("SHA-256",(new TextEncoder).encode("".concat(n,";").concat(o,";").concat(r)));case 2:if(!(i=a.encode.call(a,e.v)).match(/^00/)){e.n=3;break}return e.a(3,4);case 3:e.n=1;break;case 4:return e.a(2,"v2;".concat(n,";").concat(o,";").concat(i))}},e)})),function(t){return e.apply(this,arguments)})}]);var e,t}();const P=new O;var R="AuthenticationCredentialsStorage",N={user:"user",authorization:"authorization",authCode:"auth-code",authUserId:"AuthUserId"};const _=new(function(){return i(function e(){o(this,e),this.retainUserCookie=!1},[{key:"getUserCookie",value:function(){var e=b.getDocument();return e&&e.cookie.split(";").filter(function(e){return e.split("=")[0].trim()===N.user}).map(function(e){return e.trim().replace(/^user=/,"")}).find(function(e){return e&&e.trim()})||null}},{key:"getAuthorizationTokens",value:function(){return"undefined"==typeof window||"undefined"==typeof document?[]:document.cookie.split(";").filter(function(e){return e.split("=")[0].trim()===N.authorization}).map(function(e){return e.trim().replace(/^authorization=/,"")}).filter(function(e){return e&&e.trim()})}},{key:"set",value:function(e,t){if("undefined"!=typeof window&&"undefined"!=typeof document)try{var n=y.parse(document.cookie);localStorage.setItem(R,JSON.stringify({idToken:e,expiry:t&&t.getTime(),jsCookies:!!n.authorization})),this.retainUserCookie||this.clearCookies(N.user)}catch(r){console.debug("LocalStorage failed in Browser",r)}}},{key:"get",value:function(){if("undefined"==typeof window||"undefined"==typeof document)return null;var e={};try{e=y.parse(document.cookie)}catch(i){console.debug("CookieManagement failed in Browser",i)}try{var t=JSON.parse(localStorage.getItem(R)||"{}"),n=t.idToken,r=t.expiry,o=t.jsCookies;return n?r<Date.now()||o&&!e.authorization?null:n:this.getUserCookie()}catch(i){return console.debug("LocalStorage failed in Browser",i),this.getUserCookie()}}},{key:"delete",value:function(){try{localStorage.removeItem(R)}catch(e){console.debug("LocalStorage failed in Browser",e)}try{this.clearCookies(N.user)}catch(e){console.debug("CookieManagement failed in Browser",e)}}},{key:"clear",value:function(){this.clearCookies(),this.delete()}},{key:"clearCookies",value:function(e){if("undefined"!=typeof window&&"undefined"!=typeof document){var t,n=a(document.cookie.split("; "));try{var r=function(){var n=t.value;if(!Object.values(N).includes(n.split("=")[0])||e&&n.split("=")[0]!==e)return 1;var r=window.location.hostname.split("."),o=l(Array(r.length-1)).map(function(e,t){return r.reverse().slice(0,t+2).reverse().join(".")}).map(function(e){return[e,".".concat(e)]}).flat(1).concat(null);"localhost"===window.location.hostname&&o.push("localhost");var i,s=a(o);try{for(s.s();!(i=s.n()).done;){var c=i.value,u=c?"domain=".concat(c,";"):"",d="".concat(encodeURIComponent(n.split(";")[0].split("=")[0]),"=; expires=Thu, 01-Jan-1970 00:00:01 GMT; ").concat(u," SameSite=Strict; path=");document.cookie="".concat(d,"/");for(var h=location.pathname.split("/");h.length>0;)document.cookie=d+h.join("/"),h.pop()}}catch(f){s.e(f)}finally{s.f()}};for(n.s();!(t=n.n()).done;)r()}catch(o){n.e(o)}finally{n.f()}}}}])}());var j,z=new Promise(function(e){return j=e}),H=Promise.resolve(),q=!1,K="AuthenticationRequestNonce",M=function(){return i(function e(t,n){var i,a=this;o(this,e);var c=Object.assign({applicationId:"app_default"},t),u=Object.assign({debug:function(){},log:function(){},error:function(){},warn:function(){},critical:function(){}},n||console);this.logger=u;var l=c.authressApiUrl||c.authressLoginHostUrl||c.authenticationServiceUrl||"";if(!l)throw Error('Missing required property "authressApiUrl" in LoginClient constructor. Custom Authress Domain Host is required.');if(this.applicationId=null===(i=c.applicationId)||void 0===i?void 0:i.trim(),!this.applicationId){var d=Error("Application ID is required.");throw d.code="InvalidApplication",d}if(this.applicationId.match(/^(sc_|ext_)/)){var h=Error("You have incorrectly specified an Authress Service Client or Extension as the applicationId instead of a valid application. The applicationId is your application that your users will log into, usually hosted on your domain https://example.yourdomain.com. Users cannot log *into* a Service Client, but they can log in *with* one. Users can use a Service Client to log in, by setting the connection ID in the *authenticate({ connectionId })* method to be the Authress Service Client.\n(1) If you are building an Custom Login Portal, then the application ID should correspond to this login portal.\n(2) If you are replacing or extending an Authress connection, then specify the Service Client as the connectionId and the end user application as the applicationId.\n(3) If you are building a platform or plugin marketplace, where users will log into third party extensions or apps, then distribute in your SDK a wrapper for the Authress Extension Client using: import { extensionClient } from '@authress/login' found within this SDK.\n(4) If you aren't sure what to do here to fix the problem, the fastest and usually correct solution is go to https://authress.io/app/#/settings?focus=applications create a new application, specify your site in the application url property and then update the value here.");throw h.code="InvalidApplication",h}this.hostUrl=C(l),this.httpClient=new T(this.hostUrl,u),this.lastSessionCheck=0,this.enableCredentials=this.getMatchingDomainInfo(this.hostUrl),_.retainUserCookie=t.retainUserCookie,c.skipBackgroundCredentialsCheck||b.onLoad(r(s().m(function e(){return s().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,a.userSessionExists({backgroundTrigger:!0});case 1:return e.a(2)}},e)})))},[{key:"getMatchingDomainInfo",value:function(e){var t=new URL(e);if(b.isLocalHost())return!1;var n=b.getCurrentLocation();if("https:"!==n.protocol)return!1;var r,o=t.host.toLowerCase().split(".").reverse(),i=n.host.toLowerCase().split(".").reverse(),s=[],c=a(o);try{for(c.s();!(r=c.n()).done;){var u=r.value,l=k(i,s.length+1).join(".");if(s.concat(u).join(".")!==l)break;s.push(u)}}catch(d){c.e(d)}finally{c.f()}return s.length===o.length&&s.length===i.length||s.length>1}},{key:"getUserIdentity",value:function(){var e=_.getUserCookie(),t=P.decodeOrParse(e);if(t){var n=t.exp?new Date(1e3*t.exp):new Date(Date.now()+864e5);return _.set(e,n),t.userId=t.sub,t}var r=_.get(),o=P.decodeOrParse(r);if(!o)return null;var i=new URL(o.iss).hostname,a=new URL(this.hostUrl).hostname;return i.endsWith(a)||a.endsWith(i)?(o.userId=o.sub,o):(_.clear(),null)}},{key:"getConnectionCredentials",value:(I=r(s().m(function e(){var t,n;return s().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.n=1,this.waitForUserSession();case 1:return e.p=1,e.n=2,this.ensureToken();case 2:return t=e.v,e.n=3,this.httpClient.get("/session/credentials",this.enableCredentials,{Authorization:t&&"Bearer ".concat(t)});case 3:return n=e.v,e.a(2,n.data);case 4:return e.p=4,e.v,e.a(2,null)}},e,this,[[1,4]])})),function(){return I.apply(this,arguments)})},{key:"getDevices",value:(S=r(s().m(function e(){var t,n;return s().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,this.ensureToken();case 1:return t=e.v,e.n=2,this.httpClient.get("/session/devices",this.enableCredentials,{Authorization:t&&"Bearer ".concat(t)});case 2:return n=e.v,e.a(2,n.data.devices);case 3:return e.p=3,e.v,e.a(2,[])}},e,this,[[0,3]])})),function(){return S.apply(this,arguments)})},{key:"deleteDevice",value:(m=r(s().m(function e(t){var n,r;return s().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,this.ensureToken();case 1:return n=e.v,e.n=2,this.httpClient.delete("/session/devices/".concat(encodeURIComponent(t)),this.enableCredentials,{Authorization:n&&"Bearer ".concat(n)});case 2:e.n=4;break;case 3:throw e.p=3,r=e.v,this.logger.log({title:"[Authress Login SDK] Failed to delete device",error:r}),r;case 4:return e.a(2)}},e,this,[[0,3]])})),function(e){return m.apply(this,arguments)})},{key:"openUserConfigurationScreen",value:(w=r(s().m(function e(){var t,n,r,o=arguments;return s().w(function(e){for(;;)switch(e.n){case 0:return t=o.length>0&&void 0!==o[0]?o[0]:{redirectUrl:null,startPage:"Profile"},e.n=1,this.userSessionExists();case 1:if(e.v){e.n=2;break}throw(n=Error("User must be logged to configure user profile data.")).code="NotLoggedIn",n;case 2:return(r=new URL("/settings",this.hostUrl)).searchParams.set("client_id",this.applicationId),r.searchParams.set("start_page",t&&t.startPage||"Profile"),r.searchParams.set("redirect_uri",t&&t.redirectUrl||b.getCurrentLocation().href),b.assign(r.toString()),e.n=3,Promise.resolve();case 3:return e.a(2)}},e,this)})),function(){return w.apply(this,arguments)})},{key:"registerDevice",value:(v=r(s().m(function e(){var t,n,r,o,i,a,c,u,d,h,f,p,g=arguments;return s().w(function(e){for(;;)switch(e.p=e.n){case 0:return t=g.length>0&&void 0!==g[0]?g[0]:{name:"",type:"",totp:{}},e.n=1,this.getUserIdentity();case 1:if(n=e.v){e.n=2;break}throw(r=Error("User must be logged to configure user profile data.")).code="NotLoggedIn",r;case 2:if(t){e.n=3;break}throw(o=Error("Register Device missing required parameter: 'Options'")).code="InvalidInput",o;case 3:if(t.type&&"WebAuthN"!==t.type){e.n=5;break}return a=n.sub,c={challenge:Uint8Array.from(a,function(e){return e.charCodeAt(0)}),rp:{id:this.hostUrl.split(".").slice(1).join("."),name:"WebAuthN Login"},user:{id:Uint8Array.from(a,function(e){return e.charCodeAt(0)}),name:a,displayName:"Generated User ID: ".concat(a)},pubKeyCredParams:[{type:"public-key",alg:-7},{type:"public-key",alg:-257}],authenticatorSelection:{residentKey:"discouraged",requireResidentKey:!1,userVerification:"discouraged"},timeout:6e4,attestation:"direct"},e.n=4,navigator.credentials.create({publicKey:c});case 4:u=e.v,d={authenticatorAttachment:u.authenticatorAttachment,credentialId:u.id,type:u.type,userId:a,attestation:btoa(String.fromCharCode.apply(String,l(new Uint8Array(u.response.attestationObject)))),client:btoa(String.fromCharCode.apply(String,l(new Uint8Array(u.response.clientDataJSON))))},i={name:t&&t.name,code:d,type:"WebAuthN"},e.n=6;break;case 5:"TOTP"===t.type&&(i={name:t.name,code:t.totp.verificationCode,totpData:t.totp,type:"TOTP"});case 6:return e.p=6,e.n=7,this.ensureToken();case 7:return h=e.v,e.n=8,this.httpClient.post("/session/devices",this.enableCredentials,i,{Authorization:h&&"Bearer ".concat(h)});case 8:return f=e.v,e.a(2,f.data);case 9:throw e.p=9,p=e.v,this.logger.log({title:"[Authress Login SDK] Failed to register new device",error:p,request:i}),p;case 10:return e.a(2)}},e,this,[[6,9]])})),function(){return v.apply(this,arguments)})},{key:"waitForUserSession",value:(g=r(s().m(function e(){return s().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,z;case 1:return e.a(2,!0);case 2:return e.p=2,e.v,e.a(2,!1)}},e,null,[[0,2]])})),function(){return g.apply(this,arguments)})},{key:"userSessionExists",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{backgroundTrigger:!1};return Date.now()-this.lastSessionCheck<50||q?H:(this.lastSessionCheck=Date.now(),q=!0,H=H.catch(function(){}).then(r(s().m(function n(){var r,o;return s().w(function(n){for(;;)switch(n.p=n.n){case 0:return n.p=0,n.n=1,e.userSessionContinuation(null==t?void 0:t.backgroundTrigger);case 1:return r=n.v,q=!1,n.a(2,r);case 2:throw n.p=2,o=n.v,q=!1,o;case 3:return n.a(2)}},n,null,[[0,2]])}))))}},{key:"userSessionContinuation",value:(p=r(s().m(function e(){var t,n,r,o,i,a,c,u,l,d,h,f,p,g,v,w,m=arguments;return s().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t=m.length>0&&void 0!==m[0]&&m[0],n=new URLSearchParams(b.getCurrentLocation().search),r={},"undefined"!=typeof localStorage)try{r=JSON.parse(localStorage.getItem(K)||"{}"),localStorage.removeItem(K),Object.hasOwnProperty.call(r,"enableCredentials")&&(this.enableCredentials=r.enableCredentials)}catch(s){this.logger.debug({title:"[Authress Login SDK] LocalStorage failed in Browser",error:s})}if((r.nonce||n.get("iss")&&n.get("iss").includes(this.hostUrl))&&this.sanitizeQueryParameters(),!r.nonce||!n.get("code")){e.n=6;break}if(r.nonce!==n.get("nonce")){e.n=6;break}return o="cookie"===n.get("code")?y.parse(document.cookie)["auth-code"]:n.get("code"),e.n=1,P.calculateAntiAbuseHash({client_id:this.applicationId,authenticationRequestId:r.nonce,code:o});case 1:return i=e.v,a={grant_type:"authorization_code",redirect_uri:r.redirectUrl,client_id:this.applicationId,code:o,code_verifier:r.codeVerifier,antiAbuseHash:i},e.p=2,e.n=3,this.httpClient.post("/authentication/".concat(r.nonce,"/tokens"),this.enableCredentials,a);case 3:return c=e.v,u=P.decode(c.data.id_token),l=u.exp&&new Date(1e3*u.exp)||c.data.expires_in&&new Date(Date.now()+1e3*c.data.expires_in),document.cookie=y.serialize("authorization",c.data.access_token||"",{expires:l,path:"/",sameSite:"strict"}),_.set(c.data.id_token,l),j(),e.a(2,!0);case 4:if(e.p=4,v=e.v,this.logger.log({title:"[Authress Login SDK] Failed exchange authentication response for a token.",error:v}),!v.data||"invalid_request"!==v.data.error){e.n=5;break}return e.a(2,!1);case 5:throw v.data||v;case 6:if(!b.isLocalHost()){e.n=7;break}if(!n.get("nonce")||!n.get("access_token")){e.n=7;break}if(r.nonce&&r.nonce!==n.get("nonce")){e.n=7;break}return d=P.decode(n.get("id_token")),h=d.exp&&new Date(1e3*d.exp)||Number(n.get("expires_in"))&&new Date(Date.now()+1e3*Number(n.get("expires_in"))),document.cookie=y.serialize("authorization",n.get("access_token")||"",{expires:h,path:"/",sameSite:"strict"}),_.set(n.get("id_token"),h),j(),e.a(2,!0);case 7:if(!this.getUserIdentity()){e.n=8;break}return j(),e.a(2,!0);case 8:if(b.isLocalHost()||t){e.n=13;break}return e.p=9,e.n=10,this.httpClient.patch("/session",this.enableCredentials,{},null,!0);case 10:(f=e.v).data.access_token&&(p=P.decode(f.data.id_token),g=p.exp&&new Date(1e3*p.exp)||f.data.expires_in&&new Date(Date.now()+1e3*f.data.expires_in),document.cookie=y.serialize("authorization",f.data.access_token||"",{expires:g,path:"/",sameSite:"strict"}),_.set(f.data.id_token,g)),e.n=12;break;case 11:e.p=11,400===(w=e.v).status||404===w.status||409===w.status?this.logger.log({title:"[Authress Login SDK] User does not have an existing authentication session",error:w}):this.logger.log({title:"[Authress Login SDK] Failed attempting to check if the user has an existing authentication session",error:w});case 12:if(!this.getUserIdentity()){e.n=13;break}return j(),e.a(2,!0);case 13:return e.a(2,!1)}},e,this,[[9,11],[2,4]])})),function(){return p.apply(this,arguments)})},{key:"updateExtensionAuthenticationRequest",value:(f=r(s().m(function e(t){var n,r,o,i,a,c,u,l,d,h,f,p,g,v,y;return s().w(function(e){for(;;)switch(e.p=e.n){case 0:if(n=t.state,r=t.connectionId,o=t.tenantLookupIdentifier,i=t.connectionProperties,a=t.hint,r||o||a){e.n=1;break}throw(c=Error("connectionId or tenantLookupIdentifier must be specified")).code="InvalidConnection",c;case 1:if(u=new URLSearchParams(b.getCurrentLocation().search),l=n||u.get("state")){e.n=2;break}throw(d=Error("The `state` parameters must be specified to update this authentication request")).code="InvalidAuthenticationRequest",d;case 2:if(this.enableCredentials||b.isLocalHost()){e.n=3;break}throw(h=Error('"updateExtensionAuthenticationRequest()" can only be run on sites that match the login domain. '.concat(b.getCurrentLocation().host," Does not match ").concat(this.hostUrl))).code="OriginMismatch",h;case 3:return e.p=3,f=a||o,e.n=4,P.calculateAntiAbuseHash({connectionId:r,tenantLookupIdentifier:f,authenticationRequestId:l});case 4:return p=e.v,e.n=5,this.httpClient.patch("/authentication/".concat(l),this.enableCredentials,{antiAbuseHash:p,connectionId:r,tenantLookupIdentifier:f,connectionProperties:i});case 5:if(g=e.v,new URL(g.data.authenticationUrl).hostname!==b.getCurrentLocation().hostname){e.n=6;break}return e.a(2,{authenticationUrl:g.data.authenticationUrl});case 6:b.assign(g.data.authenticationUrl),e.n=9;break;case 7:if(e.p=7,y=e.v,this.logger.log({title:"[Authress Login SDK] Failed to update extension authentication request",error:y}),!(y.status&&y.status>=400&&y.status<500)){e.n=8;break}throw(v=Error(y.data&&(y.data.title||y.data.errorCode)||y.data||"Unknown Error")).code=y.data&&y.data.errorCode,v;case 8:throw y.data||y;case 9:return e.n=10,new Promise(function(e){return setTimeout(e,5e3)});case 10:return e.a(2,null)}},e,this,[[3,7]])})),function(e){return f.apply(this,arguments)})},{key:"unlinkIdentity",value:(h=r(s().m(function e(t){var n,r,o,i,a,c,u;return s().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t){e.n=1;break}throw(n=Error("connectionId must be specified")).code="InvalidConnection",n;case 1:if(this.getUserIdentity()){e.n=2;break}throw(r=Error("User must be logged in to unlink an account.")).code="NotLoggedIn",r;case 2:return e.p=2,e.n=3,this.ensureToken({timeoutInMillis:100});case 3:o=e.v,e.n=5;break;case 4:if(e.p=4,"TokenTimeout"!==e.v.code){e.n=5;break}throw(i=Error("User must be logged into an existing account before linking a second account.")).code="NotLoggedIn",i;case 5:return a=this.enableCredentials&&!b.isLocalHost()?{}:{Authorization:"Bearer ".concat(o)},e.p=6,e.n=7,this.httpClient.delete("/identities/".concat(encodeURIComponent(t)),this.enableCredentials,a);case 7:e.n=10;break;case 8:if(e.p=8,u=e.v,this.logger.log({title:"[Authress Login SDK] Failed to unlink user identity",error:u}),!(u.status&&u.status>=400&&u.status<500)){e.n=9;break}throw(c=Error(u.data&&(u.data.title||u.data.errorCode)||u.data||"Unknown Error")).code=u.data&&u.data.errorCode,c;case 9:throw u.data||u;case 10:return e.a(2)}},e,this,[[6,8],[2,4]])})),function(e){return h.apply(this,arguments)})},{key:"linkIdentityWithOneTimeCode",value:(d=r(s().m(function e(t){var n,r,o,i,a,c,u,l,d,h,f,p,g,v,y;return s().w(function(e){for(;;)switch(e.p=e.n){case 0:if(n=t.connectionId,r=t.redirectUrl,n){e.n=1;break}throw(o=Error("connectionId must be specified")).code="InvalidConnection",o;case 1:if(this.getUserIdentity()){e.n=2;break}throw(i=Error("User must be logged into an existing account before linking a second account.")).code="NotLoggedIn",i;case 2:return e.p=2,e.n=3,this.ensureToken({timeoutInMillis:100});case 3:a=e.v,e.n=5;break;case 4:if(e.p=4,"TokenTimeout"!==e.v.code){e.n=5;break}throw(c=Error("User must be logged into an existing account before linking a second account.")).code="NotLoggedIn",c;case 5:return e.n=6,P.getAuthCodes();case 6:return u=e.v,l=u.codeChallenge,e.n=7,P.calculateAntiAbuseHash({connectionId:n,applicationId:this.applicationId});case 7:return d=e.v,e.p=8,h=r&&new URL(r).toString(),f=h||b.getCurrentLocation().href,p=this.enableCredentials&&!b.isLocalHost()?{}:{Authorization:"Bearer ".concat(a)},e.n=9,this.httpClient.post("/authentication",this.enableCredentials,{antiAbuseHash:d,linkIdentity:!0,redirectUrl:f,codeChallengeMethod:"S256",codeChallenge:l,connectionId:n,applicationId:this.applicationId},p);case 9:return g=e.v,e.a(2,{authenticationUrl:g.data.authenticationUrl,authenticationRequestId:g.data.authenticationRequestId});case 10:if(e.p=10,y=e.v,this.logger.log({title:"[Authress Login SDK] Failed to start user identity link",error:y}),!(y.status&&y.status>=400&&y.status<500)){e.n=11;break}throw(v=Error(y.data&&(y.data.title||y.data.errorCode)||y.data||"Unknown Error")).code=y.data&&y.data.errorCode,v;case 11:throw y;case 12:return e.a(2)}},e,this,[[8,10],[2,4]])})),function(e){return d.apply(this,arguments)})},{key:"linkIdentity",value:(u=r(s().m(function e(t){var n,r,o,i,a,c,u,l,d,h,f,p,g,v,y,w,m;return s().w(function(e){for(;;)switch(e.p=e.n){case 0:if(n=t.connectionId,r=t.tenantLookupIdentifier,o=t.redirectUrl,i=t.connectionProperties,n||r){e.n=1;break}throw(a=Error("connectionId or tenantLookupIdentifier must be specified")).code="InvalidConnection",a;case 1:if(this.getUserIdentity()){e.n=2;break}throw(c=Error("User must be logged into an existing account before linking a second account.")).code="NotLoggedIn",c;case 2:return e.p=2,e.n=3,this.ensureToken({timeoutInMillis:100});case 3:u=e.v,e.n=5;break;case 4:if(e.p=4,"TokenTimeout"!==e.v.code){e.n=5;break}throw(l=Error("User must be logged into an existing account before linking a second account.")).code="NotLoggedIn",l;case 5:return e.n=6,P.getAuthCodes();case 6:return d=e.v,h=d.codeChallenge,e.n=7,P.calculateAntiAbuseHash({connectionId:n,tenantLookupIdentifier:r,applicationId:this.applicationId});case 7:return f=e.v,e.p=8,p=o&&new URL(o).toString(),g=p||b.getCurrentLocation().href,v=this.enableCredentials&&!b.isLocalHost()?{}:{Authorization:"Bearer ".concat(u)},e.n=9,this.httpClient.post("/authentication",this.enableCredentials,{antiAbuseHash:f,linkIdentity:!0,redirectUrl:g,codeChallengeMethod:"S256",codeChallenge:h,connectionId:n,tenantLookupIdentifier:r,connectionProperties:i,applicationId:this.applicationId},v);case 9:y=e.v,b.assign(y.data.authenticationUrl),e.n=12;break;case 10:if(e.p=10,m=e.v,this.logger.log({title:"[Authress Login SDK] Failed to start user identity link",error:m}),!(m.status&&m.status>=400&&m.status<500)){e.n=11;break}throw(w=Error(m.data&&(m.data.title||m.data.errorCode)||m.data||"Unknown Error")).code=m.data&&m.data.errorCode,w;case 11:throw m;case 12:return e.n=13,new Promise(function(e){return setTimeout(e,5e3)});case 13:return e.a(2)}},e,this,[[8,10],[2,4]])})),function(e){return u.apply(this,arguments)})},{key:"authenticateWithOneTimeCode",value:(c=r(s().m(function e(){var t,n,r,o,i,a,c,u,l,d,h,f,p,g,v,y,w,m,k,C,S,I,A,L,U,T=arguments;return s().w(function(e){for(;;)switch(e.p=e.n){case 0:if(r=(n=(t=T.length>0&&void 0!==T[0]?T[0]:{})||{}).serviceClientId,o=n.inviteId,i=n.redirectUrl,a=n.force,c=n.responseLocation,u=n.flowType,l=n.clearUserDataBeforeLogin,d=n.audiences,!c||"cookie"===c||"query"===c||"none"===c){e.n=1;break}throw(h=Error("Authentication response location is not valid")).code="InvalidResponseLocation",h;case 1:if(r){e.n=2;break}throw(f=Error("The Passwordless Service Client ID is required")).code="InvalidInput",f;case 2:if(!(L=!o&&!a)){e.n=4;break}return e.n=3,this.userSessionExists();case 3:L=e.v;case 4:if(!L){e.n=7;break}return e.n=5,this.ensureToken();case 5:if(p=e.v,!(g=P.decode(p))||!g.azp||r===g.azp){e.n=6;break}throw this.logger.log({title:"[Authress Login SDK] Authentication blocked because the user is already logged in, and the requested authentication parameters do not match the original session.",requestedAuthenticationOptions:t,currentAuthenticationSessionData:g}),(v=Error('Authentication requested for user that is already logged in, but the connectionId specified does not match their existing session.\n Recommended Options:\n (1) If the goal is to force them to log in with this new connection and ignore their existing session, use the "force" flag.\n (2) If the goal is link their current identity with a new from the new connection, use the linkIdentity() method.\n (3) If the goal is skip log in if they are already logged in or force log in with the connectionId, first check if userSessionExists() and then only if "false", call authenticate().')).code="AuthenticationConstraintContention",v;case 6:return e.a(2,null);case 7:return e.n=8,P.getAuthCodes();case 8:return y=e.v,w=y.codeVerifier,m=y.codeChallenge,e.n=9,P.calculateAntiAbuseHash({serviceClientId:r,inviteId:o,applicationId:this.applicationId,audiences:d});case 9:return k=e.v,e.p=10,C=i&&new URL(i).toString(),S=C||b.getCurrentLocation().href,!1!==l&&_.clear(),e.n=11,this.httpClient.post("/authentication",this.enableCredentials,{antiAbuseHash:k,redirectUrl:S,codeChallengeMethod:"S256",codeChallenge:m,audiences:d,connectionId:r,inviteId:o,applicationId:this.applicationId,responseLocation:c,flowType:u});case 11:return I=e.v,localStorage.setItem(K,JSON.stringify({nonce:I.data.authenticationRequestId,codeVerifier:w,lastConnectionId:r,redirectUrl:S,enableCredentials:I.data.enableCredentials})),e.a(2,{authenticationUrl:I.data.authenticationUrl,authenticationRequestId:I.data.authenticationRequestId});case 12:if(e.p=12,U=e.v,this.logger.log({title:"[Authress Login SDK] Failed to start authentication for user",error:U}),!(U.status&&U.status>=400&&U.status<500)){e.n=13;break}throw(A=Error(U.data&&(U.data.title||U.data.errorCode)||U.data||"Unknown Error")).code=U.data&&U.data.errorCode,A;case 13:throw U.data||U;case 14:return e.a(2)}},e,this,[[10,12]])})),function(){return c.apply(this,arguments)})},{key:"authenticate",value:(n=r(s().m(function e(){var t,n,r,o,i,a,c,u,l,d,h,f,p,g,v,y,w,m,k,C,S,I,A,L,U,T,E,x,D,O=arguments;return s().w(function(e){for(;;)switch(e.p=e.n){case 0:if(r=(n=(t=O.length>0&&void 0!==O[0]?O[0]:{})||{}).connectionId,o=n.tenantLookupIdentifier,i=n.inviteId,a=n.redirectUrl,c=n.force,u=n.responseLocation,l=n.flowType,d=n.connectionProperties,h=n.openType,f=n.multiAccount,p=n.clearUserDataBeforeLogin,g=n.audiences,!u||"cookie"===u||"query"===u||"none"===u){e.n=1;break}throw(v=Error("Authentication response location is not valid")).code="InvalidResponseLocation",v;case 1:if(!(x=!i&&!c&&!f)){e.n=3;break}return e.n=2,this.userSessionExists();case 2:x=e.v;case 3:if(!x){e.n=6;break}return e.n=4,this.ensureToken();case 4:if(y=e.v,w=P.decode(y),!(r&&w&&w.azp&&r!==w.azp)){e.n=5;break}throw this.logger.log({title:"[Authress Login SDK] Authentication blocked because the user is already logged in, and the requested authentication parameters do not match the original session.",requestedAuthenticationOptions:t,currentAuthenticationSessionData:w}),(m=Error('Authentication requested for user that is already logged in, but the connectionId specified does not match their existing session.\n Recommended Options:\n (1) If the goal is to force them to log in with this new connection and ignore their existing session, use the "force" flag.\n (2) If the goal is link their current identity with a new from the new connection, use the linkIdentity() method.\n (3) If the goal is skip log in if they are already logged in or force log in with the connectionId, first check if userSessionExists() and then only if "false", call authenticate().')).code="AuthenticationConstraintContention",m;case 5:return e.a(2,null);case 6:return e.n=7,P.getAuthCodes();case 7:return k=e.v,C=k.codeVerifier,S=k.codeChallenge,e.n=8,P.calculateAntiAbuseHash({connectionId:r,tenantLookupIdentifier:o,inviteId:i,applicationId:this.applicationId,audiences:g});case 8:return I=e.v,e.p=9,A=a&&new URL(a).toString(),L=A||b.getCurrentLocation().href,!1!==p&&_.clear(),e.n=10,this.httpClient.post("/authentication",this.enableCredentials,{antiAbuseHash:I,redirectUrl:L,codeChallengeMethod:"S256",codeChallenge:S,audiences:g,connectionId:r,tenantLookupIdentifier:o,inviteId:i,connectionProperties:d,applicationId:this.applicationId,responseLocation:u,flowType:l,multiAccount:f});case 10:if(U=e.v,localStorage.setItem(K,JSON.stringify({nonce:U.data.authenticationRequestId,codeVerifier:C,lastConnectionId:r,tenantLookupIdentifier:o,redirectUrl:L,enableCredentials:U.data.enableCredentials,multiAccount:f})),U.data.authenticationUrl&&new URL(U.data.authenticationUrl).hostname!==b.getCurrentLocation().hostname){e.n=11;break}return e.a(2,{authenticationUrl:U.data.authenticationUrl,authenticationRequestId:U.data.authenticationRequestId});case 11:"tab"===h&&(T=b.open(U.data.authenticationUrl,"_blank"))&&!T.closed&&void 0!==T.closed||b.assign(U.data.authenticationUrl),e.n=14;break;case 12:if(e.p=12,D=e.v,this.logger.log({title:"[Authress Login SDK] Failed to start authentication for user",error:D}),!(D.status&&D.status>=400&&D.status<500)){e.n=13;break}throw(E=Error(D.data&&(D.data.title||D.data.errorCode)||D.data||"Unknown Error")).code=D.data&&D.data.errorCode,E;case 13:throw D.data||D;case 14:return e.n=15,new Promise(function(e){return setTimeout(e,5e3)});case 15:return e.a(2,null)}},e,this,[[9,12]])})),function(){return n.apply(this,arguments)})},{key:"ensureToken",value:(t=r(s().m(function e(t){var n,r,o,i,a,c,u,l,d,h,f=this;return s().w(function(e){for(;;)switch(e.p=e.n){case 0:if(!t||0!==t.timeoutInMillis){e.n=4;break}if(this.getUserIdentity()){e.n=1;break}throw(n=Error("No token available because the user is not logged in.")).code="TokenTimeout",n;case 1:if(r=_.getAuthorizationTokens(),!(o=r.find(function(e){try{var n=P.decode(e);return(null==n?void 0:n.iss)===f.hostUrl||(f.logger.log({title:"[Authress Login SDK] Skipping stored authorization cookie because the issuer does not match the library configured value.",requestedAuthenticationOptions:t,currentAuthenticationSessionData:n}),!1)}catch(r){return f.logger.log({title:"[Authress Login SDK] Skipping stored authorization cookie because it is no longer a valid token.",requestedAuthenticationOptions:t,currentAuthenticationSessionDataToken:e,error:r}),!1}}))){e.n=2;break}return e.a(2,o);case 2:if(!r.length){e.n=3;break}return this.logger.log({title:"[Authress Login SDK] No matching issuer token found, returning the first valid token instead."}),e.a(2,r[0]);case 3:return this.logger.error({title:"[Authress Login SDK] HttpOnly access token configuration has blocked the returning of a valid token. The application specified in the Authress LoginClient constructor has been configured to block returning access tokens via the enableAccessToToken property. To use the loginClient.ensureToken() method in production, please set the enableAccessToToken to true. Note: This setting does not affect localhost.",options:t}),e.a(2,null);case 4:return e.n=5,this.userSessionExists();case 5:return i=Object.assign({timeoutInMillis:5e3},t||{}),a=this.waitForUserSession(),c=-1===i.timeoutInMillis||i.timeoutInMillis>Math.pow(2,31)-1?Math.pow(2,31)-1:i.timeoutInMillis,u=new Promise(function(e,t){return setTimeout(t,c||0)}),e.p=6,e.n=7,Promise.race([a,u]);case 7:e.n=9;break;case 8:throw e.p=8,e.v,(l=Error("No token available because the user is still not logged in and the timeout has been exceeded. If you are seeing this error, it is because you have called ensureToken() without first validating that the user is logged. Review the route guards and checks for user sessions in your source code. ensureToken() should only ever be called after you have verified that the user is logged in.")).code="TokenTimeout",l;case 9:if(d=_.getAuthorizationTokens(),!(h=d.find(function(e){try{var n=P.decode(e);return(null==n?void 0:n.iss)===f.hostUrl||(f.logger.log({title:"[Authress Login SDK] Skipping stored authorization cookie because the issuer does not match the library configured value.",requestedAuthenticationOptions:t,currentAuthenticationSessionData:n}),!1)}catch(r){return f.logger.log({title:"[Authress Login SDK] Skipping stored authorization cookie because it is no longer a valid token.",requestedAuthenticationOptions:t,currentAuthenticationSessionDataToken:e,error:r}),!1}}))){e.n=10;break}return e.a(2,h);case 10:if(!d.length){e.n=11;break}return this.logger.log({title:"[Authress Login SDK] No matching issuer token found, returning the first valid token instead."}),e.a(2,d[0]);case 11:if(this.getUserIdentity()){e.n=12;break}return this.logger.error({title:"[Authress Login SDK] User completed login but the user identity still does not exist. This happened because there is a race condition in your code and why waiting for ensureToken() to complete, the user was logged out. Returning null."}),e.a(2,null);case 12:return this.logger.error({title:"[Authress Login SDK] Your Authress Application access token configuration has blocked the returning of a valid token because the setting HttpOnly has been enabled. The application specified in the Authress LoginClient constructor has been configured to block returning access tokens via the enableAccessToToken property. To use the loginClient.ensureToken() method in production, please set the enableAccessToToken to true. (LocalHost Note: This setting does not affect localhost development, and you may still see ensureToken work successfully during development, but fail with this error in production. This is because HttpOnly does not work for LocalHost)",options:t}),e.a(2,null)}},e,this,[[6,8]])})),function(e){return t.apply(this,arguments)})},{key:"logout",value:(e=r(s().m(function e(t){var n,r,o;return s().w(function(e){for(;;)switch(e.p=e.n){case 0:if(!t){e.n=5;break}e.p=1,new URL(t),n=t,e.n=5;break;case 2:e.p=2,e.v,e.p=3,n=new URL(t,b.getCurrentLocation().href).toString(),e.n=5;break;case 4:throw e.p=4,e.v,(r=Error("The logout redirect url is not valid URL: ".concat(t))).code="InvalidRedirectUrl",r;case 5:if(_.clear(),this.sanitizeQueryParameters(),z=new Promise(function(e){return j=e}),!this.enableCredentials){e.n=9;break}return e.p=6,e.n=7,this.httpClient.delete("/session",this.enableCredentials);case 7:return this.lastSessionCheck=0,t&&t!==b.getCurrentLocation().href&&b.assign(t),e.a(2);case 8:e.p=8,e.v;case 9:return(o=new URL("/logout",this.hostUrl)).searchParams.set("redirect_uri",n||b.getCurrentLocation().href),o.searchParams.set("client_id",this.applicationId),b.assign(o.toString()),this.lastSessionCheck=0,e.n=10,new Promise(function(e){return setTimeout(e,500)});case 10:return e.a(2)}},e,this,[[6,8],[3,4],[1,2]])})),function(t){return e.apply(this,arguments)})},{key:"sanitizeQueryParameters",value:function(){var e=new URL(b.getCurrentLocation());e.searchParams.delete("iss"),e.searchParams.delete("nonce"),e.searchParams.delete("code"),e.searchParams.delete("expires_in"),e.searchParams.delete("access_token"),e.searchParams.delete("id_token"),history.replaceState({},void 0,e.toString())}}]);var e,t,n,c,u,d,h,f,p,g,v,w,m,S,I}();e.LoginClient=M,e.UserConfigurationScreen={Profile:"Profile",MFA:"MFA"},Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
|
|
2
|
+
//# sourceMappingURL=authress.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authress.min.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* eslint-disable no-unused-vars */
|
|
2
|
+
|
|
1
3
|
export interface Settings {
|
|
2
4
|
/** Your Authress custom domain - see https://authress.io/app/#/setup?focus=domain */
|
|
3
5
|
authressApiUrl?: string;
|
|
@@ -149,7 +151,6 @@ export class LoginClient {
|
|
|
149
151
|
* @param {Settings} settings Authress LoginClient settings
|
|
150
152
|
* @param {Object} [logger] a configured logger object, optionally `console`, which can used to display debug and warning messages.
|
|
151
153
|
*/
|
|
152
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
153
154
|
constructor(settings: Settings, logger?: unknown);
|
|
154
155
|
|
|
155
156
|
/**
|
|
@@ -273,7 +274,6 @@ export class ExtensionClient {
|
|
|
273
274
|
* @param {string} authressCustomDomain Your Authress custom domain - see https://authress.io/app/#/manage?focus=domain
|
|
274
275
|
* @param {string} extensionId The platform extensionId for this app - see https://authress.io/app/#/manage?focus=extensions
|
|
275
276
|
*/
|
|
276
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
277
277
|
constructor(authressCustomDomain: string, extensionId: string);
|
|
278
278
|
|
|
279
279
|
/**
|
package/package.json
CHANGED
|
@@ -1,51 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@authress/login",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.407",
|
|
4
4
|
"description": "Universal login sdk for Authress authentication as a service. Provides managed authentication for user identity, authentication, and token verification.",
|
|
5
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"module": "./src/index.js",
|
|
7
|
+
"main": "./dist/authress.min.js",
|
|
6
8
|
"types": "./index.d.ts",
|
|
7
9
|
"files": [
|
|
8
10
|
"index.d.ts",
|
|
9
11
|
"src",
|
|
10
12
|
"dist"
|
|
11
13
|
],
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"import": "./src/index.js",
|
|
17
|
+
"require": "./dist/authress.min.js",
|
|
18
|
+
"default": "./src/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
12
21
|
"scripts": {
|
|
13
|
-
"build": "node make.js build &&
|
|
22
|
+
"build": "node make.js build && vite build",
|
|
14
23
|
"lint": "eslint --ext .js,.ts src tests make.js index.d.ts",
|
|
15
|
-
"test": "check-dts index.d.ts &&
|
|
24
|
+
"test": "check-dts index.d.ts && vitest"
|
|
16
25
|
},
|
|
17
26
|
"dependencies": {
|
|
18
27
|
"cookie": "<1",
|
|
19
28
|
"lodash.take": "^4.1.1"
|
|
20
29
|
},
|
|
21
30
|
"devDependencies": {
|
|
22
|
-
"@
|
|
23
|
-
"@babel/
|
|
24
|
-
"@
|
|
25
|
-
"@
|
|
26
|
-
"@typescript-eslint/
|
|
27
|
-
"
|
|
31
|
+
"@authress/eslint-config": "^2.0.14",
|
|
32
|
+
"@babel/core": "^7.28.5",
|
|
33
|
+
"@babel/preset-env": "^7.28.5",
|
|
34
|
+
"@rollup/plugin-babel": "^6.1.0",
|
|
35
|
+
"@typescript-eslint/eslint-plugin": "^8.49.0",
|
|
36
|
+
"@typescript-eslint/parser": "^8.49.0",
|
|
28
37
|
"chai": "^4.2.0",
|
|
29
38
|
"check-dts": "^0.4.4",
|
|
30
|
-
"ci-build-tools": "^1.0.13",
|
|
31
39
|
"commander": "^4.0.1",
|
|
32
|
-
"
|
|
33
|
-
"eslint": "^
|
|
34
|
-
"eslint-config-cimpress-atsquad": "^1.0.67",
|
|
35
|
-
"eslint-loader": "^4.0.2",
|
|
40
|
+
"eslint": "^9.39.1",
|
|
41
|
+
"eslint-plugin-import": "^2.32.0",
|
|
36
42
|
"eslint-plugin-mocha": "^7.0.1",
|
|
37
43
|
"eslint-plugin-node": "^11.1.0",
|
|
38
44
|
"eslint-plugin-promise": "^6.1.1",
|
|
39
45
|
"fs-extra": "^8.1.0",
|
|
40
46
|
"glob": "^7.1.6",
|
|
41
47
|
"mocha": "^11.1.0",
|
|
42
|
-
"path-browserify": "^1.0.1",
|
|
43
48
|
"sinon": "^7.5.0",
|
|
44
49
|
"sinon-chai": "^3.3.0",
|
|
45
|
-
"terser
|
|
46
|
-
"typescript": "^
|
|
47
|
-
"
|
|
48
|
-
"
|
|
50
|
+
"terser": "^5.44.1",
|
|
51
|
+
"typescript": "^5.9.3",
|
|
52
|
+
"typescript-eslint": "^8.49.0",
|
|
53
|
+
"vite": "^7.2.7",
|
|
54
|
+
"vitest": "^4.0.15"
|
|
49
55
|
},
|
|
50
56
|
"repository": {
|
|
51
57
|
"type": "git",
|
|
@@ -84,6 +90,6 @@
|
|
|
84
90
|
},
|
|
85
91
|
"homepage": "https://authress.io",
|
|
86
92
|
"engines": {
|
|
87
|
-
"node": ">=
|
|
93
|
+
"node": ">=20"
|
|
88
94
|
}
|
|
89
95
|
}
|
package/src/base64url.js
CHANGED
|
@@ -14,11 +14,11 @@ function decodeBase64(str) {
|
|
|
14
14
|
return decodeURIComponent(Array.from(atob(str), byteToPercent).join(''));
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
function decode(str) {
|
|
18
18
|
return decodeBase64(str.replace(/-/g, '+').replace(/_/g, '/'));
|
|
19
|
-
}
|
|
19
|
+
}
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
function encode(str) {
|
|
22
22
|
if (str && typeof str === 'object') {
|
|
23
23
|
return btoa(String.fromCharCode(...new Uint8Array(str))).replace(/\//g, '_')
|
|
24
24
|
.replace(/\+/g, '-')
|
|
@@ -29,4 +29,6 @@ module.exports.encode = function encode(str) {
|
|
|
29
29
|
.replace(/\//g, '_')
|
|
30
30
|
.replace(/\+/g, '-')
|
|
31
31
|
.replace(/=+$/, '');
|
|
32
|
-
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default { decode, encode };
|
package/src/extensionClient.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import jwtManager from './jwtManager.js';
|
|
2
|
+
import { sanitizeUrl } from './util.js';
|
|
3
|
+
import windowManager from './windowManager.js';
|
|
4
4
|
|
|
5
5
|
const AuthenticationRequestNonceKey = 'ExtensionRequestNonce';
|
|
6
6
|
|
|
@@ -147,4 +147,4 @@ class ExtensionClient {
|
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
|
|
150
|
+
export default ExtensionClient;
|
package/src/httpClient.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { sanitizeUrl } from './util.js';
|
|
2
|
+
import windowManager from './windowManager.js';
|
|
3
|
+
import packageInfo from '../package.json';
|
|
4
4
|
|
|
5
5
|
const defaultHeaders = {
|
|
6
6
|
'Content-Type': 'application/json',
|
|
@@ -53,9 +53,8 @@ class HttpClient {
|
|
|
53
53
|
if (!authressLoginCustomDomain) {
|
|
54
54
|
throw Error('Custom Authress Domain Host is required');
|
|
55
55
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
this.logger = logger;
|
|
56
|
+
|
|
57
|
+
this.logger = overrideLogger;
|
|
59
58
|
|
|
60
59
|
const loginHostFullUrl = new URL(sanitizeUrl(authressLoginCustomDomain));
|
|
61
60
|
this.loginUrl = `${loginHostFullUrl.origin}/api`;
|
|
@@ -96,7 +95,7 @@ class HttpClient {
|
|
|
96
95
|
const method = rawMethod.toUpperCase();
|
|
97
96
|
const headers = Object.assign({}, defaultHeaders, requestHeaders);
|
|
98
97
|
try {
|
|
99
|
-
this.logger
|
|
98
|
+
this.logger.debug({ title: '[Authress Login SDK] HttpClient Request', method, url });
|
|
100
99
|
const request = { method, headers };
|
|
101
100
|
if (data) {
|
|
102
101
|
request.body = JSON.stringify(data);
|
|
@@ -114,7 +113,7 @@ class HttpClient {
|
|
|
114
113
|
try {
|
|
115
114
|
responseBody = await response.text();
|
|
116
115
|
responseBody = JSON.parse(responseBody);
|
|
117
|
-
} catch (
|
|
116
|
+
} catch (_) {
|
|
118
117
|
/* */
|
|
119
118
|
}
|
|
120
119
|
return {
|
|
@@ -129,13 +128,13 @@ class HttpClient {
|
|
|
129
128
|
try {
|
|
130
129
|
resolvedError = await error.text();
|
|
131
130
|
resolvedError = JSON.parse(resolvedError);
|
|
132
|
-
} catch (
|
|
131
|
+
} catch (_) {
|
|
133
132
|
/* */
|
|
134
133
|
}
|
|
135
134
|
|
|
136
135
|
const extensionErrorId = resolvedError.stack && resolvedError.stack.match(/chrome-extension:[/][/](\w+)[/]/);
|
|
137
136
|
if (extensionErrorId) {
|
|
138
|
-
this.logger
|
|
137
|
+
this.logger.debug({ title: `[Authress Login SDK] Fetch failed due to a browser extension - ${method} - ${url}`, method, url, data, headers, error, resolvedError, extensionErrorId });
|
|
139
138
|
const newError = new Error(`Extension Error ID: ${extensionErrorId}`);
|
|
140
139
|
newError.code = 'BROWSER_EXTENSION_ERROR';
|
|
141
140
|
throw newError;
|
|
@@ -176,4 +175,4 @@ class HttpClient {
|
|
|
176
175
|
}
|
|
177
176
|
}
|
|
178
177
|
|
|
179
|
-
|
|
178
|
+
export default HttpClient;
|
package/src/index.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import cookieManager from 'cookie';
|
|
2
|
+
import take from 'lodash.take';
|
|
3
|
+
|
|
4
|
+
import windowManager from './windowManager.js';
|
|
5
|
+
import HttpClient from './httpClient.js';
|
|
6
|
+
import jwtManager from './jwtManager.js';
|
|
7
|
+
import { sanitizeUrl } from './util.js';
|
|
8
|
+
import userIdentityTokenStorageManager from './userIdentityTokenStorageManager.js';
|
|
10
9
|
let userSessionResolver;
|
|
11
10
|
let userSessionPromise = new Promise(resolve => userSessionResolver = resolve);
|
|
12
11
|
|
|
@@ -15,7 +14,7 @@ let userSessionCheckIsInProgress = false;
|
|
|
15
14
|
|
|
16
15
|
const AuthenticationRequestNonceKey = 'AuthenticationRequestNonce';
|
|
17
16
|
|
|
18
|
-
class LoginClient {
|
|
17
|
+
export class LoginClient {
|
|
19
18
|
/**
|
|
20
19
|
* @constructor constructs the LoginClient with a given configuration
|
|
21
20
|
* @param {Object} settings
|
|
@@ -25,7 +24,8 @@ class LoginClient {
|
|
|
25
24
|
*/
|
|
26
25
|
constructor(settings, logger) {
|
|
27
26
|
const settingsWithDefault = Object.assign({ applicationId: 'app_default' }, settings);
|
|
28
|
-
|
|
27
|
+
const loggerWithFallbacks = Object.assign({ debug() {}, log() {}, error() {}, warn() {}, critical() {} }, logger || console);
|
|
28
|
+
this.logger = loggerWithFallbacks;
|
|
29
29
|
const hostUrl = settingsWithDefault.authressApiUrl || settingsWithDefault.authressLoginHostUrl || settingsWithDefault.authenticationServiceUrl || '';
|
|
30
30
|
|
|
31
31
|
if (!hostUrl) {
|
|
@@ -46,7 +46,7 @@ class LoginClient {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
this.hostUrl = sanitizeUrl(hostUrl);
|
|
49
|
-
this.httpClient = new HttpClient(this.hostUrl,
|
|
49
|
+
this.httpClient = new HttpClient(this.hostUrl, loggerWithFallbacks);
|
|
50
50
|
this.lastSessionCheck = 0;
|
|
51
51
|
|
|
52
52
|
this.enableCredentials = this.getMatchingDomainInfo(this.hostUrl);
|
|
@@ -150,7 +150,7 @@ class LoginClient {
|
|
|
150
150
|
const token = await this.ensureToken();
|
|
151
151
|
const credentialsResult = await this.httpClient.get('/session/credentials', this.enableCredentials, { Authorization: token && `Bearer ${token}` });
|
|
152
152
|
return credentialsResult.data;
|
|
153
|
-
} catch (
|
|
153
|
+
} catch (_) {
|
|
154
154
|
return null;
|
|
155
155
|
}
|
|
156
156
|
}
|
|
@@ -160,7 +160,7 @@ class LoginClient {
|
|
|
160
160
|
const token = await this.ensureToken();
|
|
161
161
|
const deviceResult = await this.httpClient.get('/session/devices', this.enableCredentials, { Authorization: token && `Bearer ${token}` });
|
|
162
162
|
return deviceResult.data.devices;
|
|
163
|
-
} catch (
|
|
163
|
+
} catch (_) {
|
|
164
164
|
return [];
|
|
165
165
|
}
|
|
166
166
|
}
|
|
@@ -170,7 +170,7 @@ class LoginClient {
|
|
|
170
170
|
const token = await this.ensureToken();
|
|
171
171
|
await this.httpClient.delete(`/session/devices/${encodeURIComponent(deviceId)}`, this.enableCredentials, { Authorization: token && `Bearer ${token}` });
|
|
172
172
|
} catch (error) {
|
|
173
|
-
this.logger
|
|
173
|
+
this.logger.log({ title: '[Authress Login SDK] Failed to delete device', error });
|
|
174
174
|
throw error;
|
|
175
175
|
}
|
|
176
176
|
}
|
|
@@ -278,7 +278,7 @@ class LoginClient {
|
|
|
278
278
|
const deviceCreationResult = await this.httpClient.post('/session/devices', this.enableCredentials, request, { Authorization: token && `Bearer ${token}` });
|
|
279
279
|
return deviceCreationResult.data;
|
|
280
280
|
} catch (error) {
|
|
281
|
-
this.logger
|
|
281
|
+
this.logger.log({ title: '[Authress Login SDK] Failed to register new device', error, request });
|
|
282
282
|
throw error;
|
|
283
283
|
}
|
|
284
284
|
}
|
|
@@ -291,7 +291,7 @@ class LoginClient {
|
|
|
291
291
|
try {
|
|
292
292
|
await userSessionPromise;
|
|
293
293
|
return true;
|
|
294
|
-
} catch (
|
|
294
|
+
} catch (_) {
|
|
295
295
|
return false;
|
|
296
296
|
}
|
|
297
297
|
}
|
|
@@ -341,7 +341,7 @@ class LoginClient {
|
|
|
341
341
|
this.enableCredentials = authRequest.enableCredentials;
|
|
342
342
|
}
|
|
343
343
|
} catch (error) {
|
|
344
|
-
this.logger
|
|
344
|
+
this.logger.debug({ title: '[Authress Login SDK] LocalStorage failed in Browser', error });
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
347
|
|
|
@@ -366,7 +366,7 @@ class LoginClient {
|
|
|
366
366
|
userSessionResolver();
|
|
367
367
|
return true;
|
|
368
368
|
} catch (error) {
|
|
369
|
-
this.logger
|
|
369
|
+
this.logger.log({ title: '[Authress Login SDK] Failed exchange authentication response for a token.', error });
|
|
370
370
|
|
|
371
371
|
// The code was expired, contaminated, or already exchanged.
|
|
372
372
|
if (error.data && error.data.error === 'invalid_request') {
|
|
@@ -414,9 +414,9 @@ class LoginClient {
|
|
|
414
414
|
} catch (error) {
|
|
415
415
|
// On 400, 404, 409 we know that the session is no longer able to be continued.
|
|
416
416
|
if (error.status === 400 || error.status === 404 || error.status === 409) {
|
|
417
|
-
this.logger
|
|
417
|
+
this.logger.log({ title: '[Authress Login SDK] User does not have an existing authentication session', error });
|
|
418
418
|
} else {
|
|
419
|
-
this.logger
|
|
419
|
+
this.logger.log({ title: '[Authress Login SDK] Failed attempting to check if the user has an existing authentication session', error });
|
|
420
420
|
}
|
|
421
421
|
}
|
|
422
422
|
const newUserData = this.getUserIdentity();
|
|
@@ -453,10 +453,16 @@ class LoginClient {
|
|
|
453
453
|
throw e;
|
|
454
454
|
}
|
|
455
455
|
|
|
456
|
+
if (!this.enableCredentials && !windowManager.isLocalHost()) {
|
|
457
|
+
const e = Error(`"updateExtensionAuthenticationRequest()" can only be run on sites that match the login domain. ${windowManager.getCurrentLocation().host} Does not match ${this.hostUrl}`);
|
|
458
|
+
e.code = 'OriginMismatch';
|
|
459
|
+
throw e;
|
|
460
|
+
}
|
|
461
|
+
|
|
456
462
|
try {
|
|
457
463
|
const resolvedTenantLookupIdentifier = hint || tenantLookupIdentifier;
|
|
458
464
|
const antiAbuseHash = await jwtManager.calculateAntiAbuseHash({ connectionId, tenantLookupIdentifier: resolvedTenantLookupIdentifier, authenticationRequestId });
|
|
459
|
-
const requestOptions = await this.httpClient.patch(`/authentication/${authenticationRequestId}`,
|
|
465
|
+
const requestOptions = await this.httpClient.patch(`/authentication/${authenticationRequestId}`, this.enableCredentials, {
|
|
460
466
|
antiAbuseHash,
|
|
461
467
|
connectionId,
|
|
462
468
|
tenantLookupIdentifier: resolvedTenantLookupIdentifier,
|
|
@@ -472,7 +478,7 @@ class LoginClient {
|
|
|
472
478
|
|
|
473
479
|
windowManager.assign(requestOptions.data.authenticationUrl);
|
|
474
480
|
} catch (error) {
|
|
475
|
-
this.logger
|
|
481
|
+
this.logger.log({ title: '[Authress Login SDK] Failed to update extension authentication request', error });
|
|
476
482
|
if (error.status && error.status >= 400 && error.status < 500) {
|
|
477
483
|
const e = Error(error.data && (error.data.title || error.data.errorCode) || error.data || 'Unknown Error');
|
|
478
484
|
e.code = error.data && error.data.errorCode;
|
|
@@ -522,7 +528,7 @@ class LoginClient {
|
|
|
522
528
|
try {
|
|
523
529
|
await this.httpClient.delete(`/identities/${encodeURIComponent(identityId)}`, this.enableCredentials, headers);
|
|
524
530
|
} catch (error) {
|
|
525
|
-
this.logger
|
|
531
|
+
this.logger.log({ title: '[Authress Login SDK] Failed to unlink user identity', error });
|
|
526
532
|
if (error.status && error.status >= 400 && error.status < 500) {
|
|
527
533
|
const e = Error(error.data && (error.data.title || error.data.errorCode) || error.data || 'Unknown Error');
|
|
528
534
|
e.code = error.data && error.data.errorCode;
|
|
@@ -584,7 +590,7 @@ class LoginClient {
|
|
|
584
590
|
authenticationRequestId: requestOptions.data.authenticationRequestId
|
|
585
591
|
};
|
|
586
592
|
} catch (error) {
|
|
587
|
-
this.logger
|
|
593
|
+
this.logger.log({ title: '[Authress Login SDK] Failed to start user identity link', error });
|
|
588
594
|
if (error.status && error.status >= 400 && error.status < 500) {
|
|
589
595
|
const e = Error(error.data && (error.data.title || error.data.errorCode) || error.data || 'Unknown Error');
|
|
590
596
|
e.code = error.data && error.data.errorCode;
|
|
@@ -645,7 +651,7 @@ class LoginClient {
|
|
|
645
651
|
}, headers);
|
|
646
652
|
windowManager.assign(requestOptions.data.authenticationUrl);
|
|
647
653
|
} catch (error) {
|
|
648
|
-
this.logger
|
|
654
|
+
this.logger.log({ title: '[Authress Login SDK] Failed to start user identity link', error });
|
|
649
655
|
if (error.status && error.status >= 400 && error.status < 500) {
|
|
650
656
|
const e = Error(error.data && (error.data.title || error.data.errorCode) || error.data || 'Unknown Error');
|
|
651
657
|
e.code = error.data && error.data.errorCode;
|
|
@@ -688,7 +694,7 @@ class LoginClient {
|
|
|
688
694
|
const existingJwtTokenString = await this.ensureToken();
|
|
689
695
|
const jwtPayload = jwtManager.decode(existingJwtTokenString);
|
|
690
696
|
if (jwtPayload && jwtPayload.azp && serviceClientId !== jwtPayload.azp) {
|
|
691
|
-
this.logger
|
|
697
|
+
this.logger.log({ title: '[Authress Login SDK] Authentication blocked because the user is already logged in, and the requested authentication parameters do not match the original session.', requestedAuthenticationOptions: options, currentAuthenticationSessionData: jwtPayload });
|
|
692
698
|
const e = Error(`Authentication requested for user that is already logged in, but the connectionId specified does not match their existing session.
|
|
693
699
|
Recommended Options:
|
|
694
700
|
(1) If the goal is to force them to log in with this new connection and ignore their existing session, use the "force" flag.
|
|
@@ -729,7 +735,7 @@ class LoginClient {
|
|
|
729
735
|
authenticationRequestId: authResponse.data.authenticationRequestId
|
|
730
736
|
};
|
|
731
737
|
} catch (error) {
|
|
732
|
-
this.logger
|
|
738
|
+
this.logger.log({ title: '[Authress Login SDK] Failed to start authentication for user', error });
|
|
733
739
|
if (error.status && error.status >= 400 && error.status < 500) {
|
|
734
740
|
const e = Error(error.data && (error.data.title || error.data.errorCode) || error.data || 'Unknown Error');
|
|
735
741
|
e.code = error.data && error.data.errorCode;
|
|
@@ -769,7 +775,7 @@ class LoginClient {
|
|
|
769
775
|
const existingJwtTokenString = await this.ensureToken();
|
|
770
776
|
const jwtPayload = jwtManager.decode(existingJwtTokenString);
|
|
771
777
|
if (connectionId && jwtPayload && jwtPayload.azp && connectionId !== jwtPayload.azp) {
|
|
772
|
-
this.logger
|
|
778
|
+
this.logger.log({ title: '[Authress Login SDK] Authentication blocked because the user is already logged in, and the requested authentication parameters do not match the original session.', requestedAuthenticationOptions: options, currentAuthenticationSessionData: jwtPayload });
|
|
773
779
|
const e = Error(`Authentication requested for user that is already logged in, but the connectionId specified does not match their existing session.
|
|
774
780
|
Recommended Options:
|
|
775
781
|
(1) If the goal is to force them to log in with this new connection and ignore their existing session, use the "force" flag.
|
|
@@ -823,7 +829,7 @@ class LoginClient {
|
|
|
823
829
|
windowManager.assign(authResponse.data.authenticationUrl);
|
|
824
830
|
}
|
|
825
831
|
} catch (error) {
|
|
826
|
-
this.logger
|
|
832
|
+
this.logger.log({ title: '[Authress Login SDK] Failed to start authentication for user', error });
|
|
827
833
|
if (error.status && error.status >= 400 && error.status < 500) {
|
|
828
834
|
const e = Error(error.data && (error.data.title || error.data.errorCode) || error.data || 'Unknown Error');
|
|
829
835
|
e.code = error.data && error.data.errorCode;
|
|
@@ -863,10 +869,10 @@ class LoginClient {
|
|
|
863
869
|
return true;
|
|
864
870
|
}
|
|
865
871
|
|
|
866
|
-
this.logger
|
|
872
|
+
this.logger.log({ title: '[Authress Login SDK] Skipping stored authorization cookie because the issuer does not match the library configured value.', requestedAuthenticationOptions: options, currentAuthenticationSessionData: jwtPayload });
|
|
867
873
|
return false;
|
|
868
874
|
} catch (error) {
|
|
869
|
-
this.logger
|
|
875
|
+
this.logger.log({ title: '[Authress Login SDK] Skipping stored authorization cookie because it is no longer a valid token.', requestedAuthenticationOptions: options, currentAuthenticationSessionDataToken: token, error });
|
|
870
876
|
return false;
|
|
871
877
|
}
|
|
872
878
|
});
|
|
@@ -876,11 +882,11 @@ class LoginClient {
|
|
|
876
882
|
}
|
|
877
883
|
|
|
878
884
|
if (authorizationValues.length) {
|
|
879
|
-
this.logger
|
|
885
|
+
this.logger.log({ title: '[Authress Login SDK] No matching issuer token found, returning the first valid token instead.' });
|
|
880
886
|
return authorizationValues[0];
|
|
881
887
|
}
|
|
882
888
|
|
|
883
|
-
this.logger
|
|
889
|
+
this.logger.error({ title: '[Authress Login SDK] HttpOnly access token configuration has blocked the returning of a valid token. The application specified in the Authress LoginClient constructor has been configured to block returning access tokens via the enableAccessToToken property. To use the loginClient.ensureToken() method in production, please set the enableAccessToToken to true. Note: This setting does not affect localhost.', options });
|
|
884
890
|
return null;
|
|
885
891
|
}
|
|
886
892
|
|
|
@@ -899,7 +905,7 @@ class LoginClient {
|
|
|
899
905
|
const timeoutAsync = new Promise((resolve, reject) => setTimeout(reject, timeoutInMillis || 0));
|
|
900
906
|
try {
|
|
901
907
|
await Promise.race([sessionWaiterAsync, timeoutAsync]);
|
|
902
|
-
} catch (
|
|
908
|
+
} catch (_) {
|
|
903
909
|
const error = Error('No token available because the user is still not logged in and the timeout has been exceeded. If you are seeing this error, it is because you have called ensureToken() without first validating that the user is logged. Review the route guards and checks for user sessions in your source code. ensureToken() should only ever be called after you have verified that the user is logged in.');
|
|
904
910
|
error.code = 'TokenTimeout';
|
|
905
911
|
throw error;
|
|
@@ -913,10 +919,10 @@ class LoginClient {
|
|
|
913
919
|
return true;
|
|
914
920
|
}
|
|
915
921
|
|
|
916
|
-
this.logger
|
|
922
|
+
this.logger.log({ title: '[Authress Login SDK] Skipping stored authorization cookie because the issuer does not match the library configured value.', requestedAuthenticationOptions: options, currentAuthenticationSessionData: jwtPayload });
|
|
917
923
|
return false;
|
|
918
924
|
} catch (error) {
|
|
919
|
-
this.logger
|
|
925
|
+
this.logger.log({ title: '[Authress Login SDK] Skipping stored authorization cookie because it is no longer a valid token.', requestedAuthenticationOptions: options, currentAuthenticationSessionDataToken: token, error });
|
|
920
926
|
return false;
|
|
921
927
|
}
|
|
922
928
|
});
|
|
@@ -926,18 +932,18 @@ class LoginClient {
|
|
|
926
932
|
}
|
|
927
933
|
|
|
928
934
|
if (authorizationValues.length) {
|
|
929
|
-
this.logger
|
|
935
|
+
this.logger.log({ title: '[Authress Login SDK] No matching issuer token found, returning the first valid token instead.' });
|
|
930
936
|
return authorizationValues[0];
|
|
931
937
|
}
|
|
932
938
|
|
|
933
939
|
// If there is no user identity then we hit a race condition and there is nothing more that can be done, just return.
|
|
934
940
|
const userIdentity = this.getUserIdentity();
|
|
935
941
|
if (!userIdentity) {
|
|
936
|
-
this.logger
|
|
942
|
+
this.logger.error({ title: '[Authress Login SDK] User completed login but the user identity still does not exist. This happened because there is a race condition in your code and why waiting for ensureToken() to complete, the user was logged out. Returning null.' });
|
|
937
943
|
return null;
|
|
938
944
|
}
|
|
939
945
|
|
|
940
|
-
this.logger
|
|
946
|
+
this.logger.error({ title: '[Authress Login SDK] Your Authress Application access token configuration has blocked the returning of a valid token because the setting HttpOnly has been enabled. The application specified in the Authress LoginClient constructor has been configured to block returning access tokens via the enableAccessToToken property. To use the loginClient.ensureToken() method in production, please set the enableAccessToToken to true. (LocalHost Note: This setting does not affect localhost development, and you may still see ensureToken work successfully during development, but fail with this error in production. This is because HttpOnly does not work for LocalHost)', options });
|
|
941
947
|
return null;
|
|
942
948
|
}
|
|
943
949
|
|
|
@@ -953,10 +959,10 @@ class LoginClient {
|
|
|
953
959
|
// eslint-disable-next-line no-new
|
|
954
960
|
new URL(requestedRedirectUrl);
|
|
955
961
|
redirectUrl = requestedRedirectUrl;
|
|
956
|
-
} catch (
|
|
962
|
+
} catch (_ /* original requested redirect url is not a url */) {
|
|
957
963
|
try {
|
|
958
964
|
redirectUrl = new URL(requestedRedirectUrl, windowManager.getCurrentLocation().href).toString();
|
|
959
|
-
} catch (relativeRedirectUrlAlsoFailed) {
|
|
965
|
+
} catch (__ /* relativeRedirectUrlAlsoFailed */) {
|
|
960
966
|
const e = Error(`The logout redirect url is not valid URL: ${requestedRedirectUrl}`);
|
|
961
967
|
e.code = 'InvalidRedirectUrl';
|
|
962
968
|
throw e;
|
|
@@ -981,7 +987,7 @@ class LoginClient {
|
|
|
981
987
|
windowManager.assign(requestedRedirectUrl);
|
|
982
988
|
}
|
|
983
989
|
return;
|
|
984
|
-
} catch (
|
|
990
|
+
} catch (_) { /**/ }
|
|
985
991
|
}
|
|
986
992
|
|
|
987
993
|
const fullLogoutUrl = new URL('/logout', this.hostUrl);
|
|
@@ -1007,11 +1013,9 @@ class LoginClient {
|
|
|
1007
1013
|
}
|
|
1008
1014
|
}
|
|
1009
1015
|
|
|
1010
|
-
const
|
|
1011
|
-
|
|
1012
|
-
const UserConfigurationScreen = {
|
|
1016
|
+
export const UserConfigurationScreen = {
|
|
1013
1017
|
Profile: 'Profile',
|
|
1014
1018
|
MFA: 'MFA'
|
|
1015
1019
|
};
|
|
1016
1020
|
|
|
1017
|
-
|
|
1021
|
+
export * from './extensionClient.js';
|
package/src/jwtManager.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import base64url from './base64url.js';
|
|
2
2
|
|
|
3
3
|
class JwtManager {
|
|
4
4
|
decode(token) {
|
|
@@ -20,7 +20,7 @@ class JwtManager {
|
|
|
20
20
|
|
|
21
21
|
try {
|
|
22
22
|
return JSON.parse(token);
|
|
23
|
-
} catch (
|
|
23
|
+
} catch (_) {
|
|
24
24
|
return this.decode(token);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -33,7 +33,7 @@ class JwtManager {
|
|
|
33
33
|
let header = null;
|
|
34
34
|
try {
|
|
35
35
|
header = JSON.parse(base64url.decode(token.split('.')[0]));
|
|
36
|
-
} catch (
|
|
36
|
+
} catch (_) {
|
|
37
37
|
/* Ignore header errors, because there is a mode where the header actually does not exist */
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -46,7 +46,7 @@ class JwtManager {
|
|
|
46
46
|
payload.exp = payload.exp - 10;
|
|
47
47
|
}
|
|
48
48
|
return { header, payload };
|
|
49
|
-
} catch (
|
|
49
|
+
} catch (_) {
|
|
50
50
|
return null;
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -76,4 +76,4 @@ class JwtManager {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
export default new JwtManager();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import cookieManager from 'cookie';
|
|
2
|
+
import windowManager from './windowManager.js';
|
|
3
3
|
|
|
4
4
|
const AuthenticationCredentialsStorageKey = 'AuthenticationCredentialsStorage';
|
|
5
5
|
|
|
@@ -146,4 +146,4 @@ class UserIdentityTokenStorageManager {
|
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
|
|
149
|
+
export default new UserIdentityTokenStorageManager();
|
package/src/util.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export function sanitizeUrl(rawUrlString) {
|
|
2
2
|
let sanitizedUrl = rawUrlString;
|
|
3
3
|
if (!sanitizedUrl.startsWith('http')) {
|
|
4
4
|
sanitizedUrl = `https://${sanitizedUrl}`;
|
|
@@ -12,4 +12,4 @@ module.exports.sanitizeUrl = function sanitizeUrl(rawUrlString) {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
return sanitizedUrl.replace(/[/]+$/, '');
|
|
15
|
-
}
|
|
15
|
+
}
|
package/src/windowManager.js
CHANGED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* cookie
|
|
3
|
-
* Copyright(c) 2012-2014 Roman Shtylman
|
|
4
|
-
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
5
|
-
* MIT Licensed
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @preserve
|
|
10
|
-
* Authress Login SDK 2.6.396
|
|
11
|
-
* License: Apache-2.0
|
|
12
|
-
* Repo : https://github.com/Authress/login-sdk.js
|
|
13
|
-
* Author : Authress Developers
|
|
14
|
-
*/
|
|
Binary file
|
package/dist/authress.min.js.gz
DELETED
|
Binary file
|