From 97ef972dd48d0fb40a7417443ca816bdd76a20e0 Mon Sep 17 00:00:00 2001 From: Narcis Radu Date: Thu, 26 Oct 2023 09:51:51 +0300 Subject: [PATCH] load imslib from deps --- libs/deps/imslib.js | 4 ++++ libs/utils/utils.js | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 libs/deps/imslib.js diff --git a/libs/deps/imslib.js b/libs/deps/imslib.js new file mode 100644 index 0000000000..eb60c0be2b --- /dev/null +++ b/libs/deps/imslib.js @@ -0,0 +1,4 @@ +/*! + * imslib built on Thu, 26 Oct 2023 06:37:57 GMT + * +*/!function(){"use strict";var e,t={6071:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},n(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]I.default.lastUserInteraction&&(I.default.lastUserInteraction=o)}return t.tokenService.refreshToken(e).then((function(e){return t.onTokenProfileReceived(e)})).catch((function(e){if(c.default.error("refresh token error",e),e instanceof w.HttpErrorResponse)return Promise.reject(e);var r=t.verifyRideErrorExceptionStrict(e);return r||(t.profileService.removeProfile(),t.onTokenExpired(),Promise.reject(e))}))},this.switchProfile=function(e,r){return void 0===r&&(r={}),e?t.tokenService.switchProfile(e,r).then((function(e){return t.onTokenProfileReceived(e)})).catch((function(e){return t.verifyRideErrorException(e)})):Promise.reject(new Error("Please provide the user id for switchProfile"))},this.executeErrorCallback=function(e){c.default.info("initialize exception ended",e);var r=t.adobeIdData.onError;r&&r(b.IErrorType.HTTP,"Initialization error")},this.triggerOnImsInstance=function(e){var r=document.createEvent("CustomEvent"),n={clientId:t.adobeIdData.client_id,instance:e};r.initCustomEvent(T.ON_IMSLIB_INSTANCE,!1,!1,n),window.dispatchEvent(r)},this.processInitializeException=function(e){return void 0===e&&(e={}),c.default.warn("initialize",e),t.restoreHash(),Promise.reject(e)},this.verifyModalSignInEvent=function(e){return e instanceof R.ModalSignInEvent?t.notifyParentAboutModalSignIn(e):Promise.reject(e)},this.verifyTokenExpiredException=function(e){return e instanceof k.TokenExpiredException?(t.adobeIdData.handlers.triggerOnAccessTokenHasExpired(),Promise.resolve()):Promise.reject(e)},this.verifyRideErrorException=function(e){return o(t,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return e instanceof S.RideException?this.adobeIdData.overrideErrorHandler&&!this.adobeIdData.overrideErrorHandler(e)?[2,Promise.reject(e)]:e.isPbaExpiredIdleSessionWorkaround?[4,this.signIn()]:[3,2]:[3,4];case 1:return t.sent(),[3,4];case 2:return e.jump?[4,y.default.replaceUrlAndWait(e.jump,1e4)]:[3,4];case 3:t.sent(),t.label=4;case 4:return[2,Promise.reject(e)]}}))}))},this.verifyRideErrorExceptionStrict=function(e){return e instanceof S.RideException?t.verifyRideErrorException(e):null},this.verifyCsrfException=function(e){var r=e.type;return r&&r===b.IErrorType.CSRF&&t.signOut(),Promise.reject(e)},this.processTokenResponse=function(e){var r=t.adobeIdData.handlers,n=e.tokenFields,o=e.profile,i=n.tokenValue,a=n.state,s=n.expire,u=n.sid,l=n.user_id,d=n.other,f=void 0===d?{}:d,p=n.impersonatorId,h=n.isImpersonatedSession,v=n.pbaSatisfiedPolicies;c.default.info("token",i),f.from_ims&&y.default.setHash(f.old_hash||""),t.profileService.removeProfileIfOtherUser(l);var g={token:i,expire:s,sid:u,impersonatorId:p,isImpersonatedSession:h,pbaSatisfiedPolicies:v};return n.isReauth()?r.triggerOnReauthAccessToken(g):t.tokenReceived(g),o&&t.profileService.saveProfileToStorage(o),Promise.resolve(a)},this.exchangeIjt=function(e){var r=t.adobeIdData.ijt;return e||r?t.tokenService.exchangeIjt(e||r).then((function(e){return e.profile?t.profileService.saveProfileToStorage(e.profile):t.profileService.removeProfile(),Promise.resolve(e)})):Promise.reject(new Error("please set the adobeid.ijt value"))},this.adobeIdData=new f.AdobeIdData(e);var r=this.adobeIdData,a=r.api_parameters,v=void 0===a?{}:a,_=r.client_id,E=r.scope,O=r.useLocalStorage,x=r.autoValidateToken,D=r.modalMode,M=r.modalSettings;this.imsApis=new p.ImsApis(v),this.csrfService=new s.CsrfService(_),this.serviceRequest={clientId:_,scope:E,imsApis:this.imsApis},this.tokenService=new m.TokenService(n(n({},this.serviceRequest),{useLocalStorage:O,autoValidateToken:x}),this.csrfService),this.profileService=new g.ProfileService(this.serviceRequest),this.signInservice=D?new l.SignInModalService(this.onPopupMessage,M):new u.SignInService}return Object.defineProperty(e.prototype,"version",{get:function(){return E.default.jslibver},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"adobeid",{get:function(){return n({},this.adobeIdData)},enumerable:!0,configurable:!0}),e.prototype.enableLogging=function(){c.default.enableLogging()},e.prototype.disableLogging=function(){c.default.disableLogging()},e.prototype.checkInitialized=function(){this.initialized},e.prototype.signUp=function(e,t){var r=this;void 0===e&&(e={}),this.checkInitialized();var n=this.adobeIdData,o=this.csrfService;if(!n)throw new Error("no adobeId on reAuthenticate");var i=o.initialize();return n.createSignUpRedirectRequest(e,t,i).then((function(e){r.signInservice.signIn(e)}))},e.prototype.isSignedInUser=function(){return!(!this.getAccessToken()&&!this.getReauthAccessToken())},e.prototype.getProfile=function(){var e=this,t=this.profileService.getProfileFromStorage();if(t)return Promise.resolve(t);var r=this.getAccessToken()||this.getReauthAccessToken();if(!r){return Promise.reject(new v.ProfileException("please login before getting the profile"))}return this.profileService.getProfile(r.token).then((function(e){return Promise.resolve(e)})).catch((function(t){return c.default.error("get profile exception ",t),t instanceof w.HttpErrorResponse?e.refreshToken().then((function(e){return Promise.resolve(e.profile)})):Promise.reject(new v.ProfileException(t.message||t))}))},e.prototype.avatarUrl=function(e){return this.imsApis.avatarUrl(e)},e.prototype.getReleaseFlags=function(e){return void 0===e&&(e=!1),e?this.tokenService.getDecodedReleaseFlags():this.tokenService.getReleaseFlags()},e.prototype.getAccessToken=function(){return this.getTokenFromStorage(!1)},e.prototype.getReauthAccessToken=function(){return this.getTokenFromStorage(!0)},e.prototype.getTokenFromStorage=function(e){var t=this.tokenService.getTokenFieldsFromStorage(e);return t?{token:t.tokenValue,expire:t.expire,sid:t.sid,impersonatorId:t.impersonatorId,isImpersonatedSession:t.isImpersonatedSession,pbaSatisfiedPolicies:t.pbaSatisfiedPolicies}:null},e.prototype.listSocialProviders=function(){var e=this;return new Promise((function(t,r){var n=e.adobeIdData.client_id;e.imsApis.listSocialProviders({client_id:n}).then((function(e){t(e)})).catch((function(e){r(e)}))}))},e.prototype.tokenReceived=function(e){this.adobeIdData.handlers.triggerOnAccessToken(e),I.default.startAutoRefreshFlow({expire:e.expire,refreshTokenMethod:this.refreshToken})},e.prototype.onTokenProfileReceived=function(e){var t=e.tokenInfo,r=e.profile;return c.default.info("token",t),this.tokenReceived(t),this.profileService.saveProfileToStorage(r),Promise.resolve(e)},e.prototype.validateToken=function(){var e=this;return this.tokenService.validateToken().then((function(){return Promise.resolve(!0)})).catch((function(t){return c.default.warn("validate token exception",t),t instanceof w.HttpErrorResponse||e.profileService.removeProfile(),Promise.reject(!1)}))},e.prototype.onTokenExpired=function(){var e=this.adobeIdData.handlers;this.tokenService.purge(),e.triggerOnAccessTokenHasExpired()},e.prototype.setStandAloneToken=function(e){return this.tokenService.setStandAloneToken(e)},e.prototype.initialize=function(){var e=this,t=this.adobeIdData,r=t.handlers,n=t.standalone,o=t.ijt,i=null;return n&&this.setStandAloneToken(n),(o?this.exchangeIjt:this.tokenService.getTokenAndProfile)().then(this.processTokenResponse,this.processError.apply(this)).then((function(e){i=e})).finally((function(){c.default.info("onReady initialization"),window.addEventListener(T.ASK_FOR_IMSLIB_INSTANCE_DOM_EVENT_NAME,(function(){e.triggerOnImsInstance(e)}),!1),r.triggerOnReady(i?i.context:null),e.triggerOnImsInstance(e),e.initialized=!0}))},e.prototype.processError=function(){var e=this;return function(t){return e.verifyModalSignInEvent(t).catch(e.processInitializeException).catch(e.verifyTokenExpiredException).catch(e.verifyRideErrorException).catch(e.verifyCsrfException).catch(e.executeErrorCallback)}},e.prototype.notifyParentAboutModalSignIn=function(e){var t=window.location.href.replace("imslibmodal","wasmodal");if(window.opener)window.opener.postMessage(t,window.location.origin),window.close();else{var r=new BroadcastChannel("imslib");r.postMessage(t),r.close(),window.close()}return Promise.reject("popup")},e.prototype.restoreHash=function(){var e=_.default.fragmentToObject();e&&e.from_ims&&y.default.setHash(e.old_hash||"")},e.prototype.getTransitoryAuthorizationCode=function(e,t){return void 0===t&&(t={}),(e=e||{}).response_type=e.response_type||"code",e.target_client_id=e.target_client_id||this.adobeIdData.client_id,e.target_scope=e.target_scope||this.adobeIdData.scope,this.imsApis.getTransitoryAuthorizationCode(e,t,this.adobeIdData.client_id)},e.prototype.jumpToken=function(e,t){return void 0===t&&(t={}),e.target_client_id=e.target_client_id||this.adobeIdData.client_id,e.target_scope=e.target_scope||this.adobeIdData.scope,this.imsApis.jumpToken(e,t,this.adobeIdData.client_id)},e.prototype.getVerifierByKey=function(e){return(new O.CodeChallenge).getVerifierByKey(e)},e.prototype.socialHeadlessSignIn=function(e,t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){var r=this;return i(this,(function(n){return[2,this.imsApis.socialHeadlessSignIn(e,t).then((function(e){return r.exchangeIjt(e.token)})).catch((function(t){return"ride_AdobeID_social"===t.error&&r.signIn({idp_flow:"social.native",provider_id:e.provider_id,idp_token:e.idp_token}),Promise.reject(t)}))]}))}))},e}();t.AdobeIMS=x},1692:function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=function(e,t){this.profile=null,this.tokenFields=e,this.profile=t};t.TokenProfileResponse=r},2323:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(r(7561)),i=r(7932);t.ONE_HOUR=1296e4;var a=function(){function e(e){this.storageInstance=null,this.nonceStorageKey="",this.nonceStorageKey="nonce"+e}return Object.defineProperty(e.prototype,"storage",{get:function(){return this.storageInstance||(this.storageInstance=o.default.getAvailableStorage()),this.storageInstance},enumerable:!0,configurable:!0}),e.prototype.initialize=function(){if(!this.isStorageAvailable())return"";var t=e.generateNonce(),r=this.getNonceFromStorage()||{};return r=this.clearOlderNonceKeys(r),this.addNonceToObject(r,t),this.saveNonceValuesToStorage(r),t.value},e.prototype.addNonceToObject=function(e,t){e[t.value]=t.expiry},e.prototype.clearOlderNonceKeys=function(e,r){void 0===r&&(r=t.ONE_HOUR);var n=Date.now()-r;return Object.keys(e).forEach((function(t){parseInt(e[t])=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t,r){void 0===e&&(e=!1),void 0===t&&(t=""),void 0===r&&(r=""),this.proxied=e,this.url=t,this.fallbackUrl=r}return e.computeEndpoint=function(t,n,o,i){var a,s;if(t){var c=o?e.THIRD_PARTY_DOMAINS_STAGE:e.THIRD_PARTY_DOMAINS_PROD;try{for(var u=r(Object.keys(c)),l=u.next();!l.done;l=u.next()){var d=l.value;if(n===d||n.endsWith("."+d))return new e(!0,c[d],i)}}catch(e){a={error:e}}finally{try{l&&!l.done&&(s=u.return)&&s.call(u)}finally{if(a)throw a.error}}}return new e(!1,i)},e.prototype.shouldFallbackToAdobe=function(e){return!!this.proxied&&("feature_disabled"===e.error&&"cdsc"===e.error_description)},e.THIRD_PARTY_DOMAINS_PROD={"behance.net":"https://sso.behance.net"},e.THIRD_PARTY_DOMAINS_STAGE={"s2stagehance.com":"https://sso.s2stagehance.com"},e}();t.CheckTokenEndpoint=n},8467:function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var n=r(1075),o=r(3263),i=function(){function e(){this.baseUrlAdobe="",this.baseUrlServices="",this.checkTokenEndpoint=new o.CheckTokenEndpoint,this.jslibver="v2-v0.31.0-2-g1e8a8a8"}return e.prototype.loadEnvironment=function(e,t,r){void 0===t&&(t=!1),void 0===r&&(r="");var i=e===n.IEnvironment.STAGE;i?(this.baseUrlAdobe="https://ims-na1-stg1.adobelogin.com",this.baseUrlServices="https://adobeid-na1-stg1.services.adobe.com"):(this.baseUrlAdobe="https://ims-na1.adobelogin.com",this.baseUrlServices="https://adobeid-na1.services.adobe.com"),this.checkTokenEndpoint=o.CheckTokenEndpoint.computeEndpoint(t,r,i,this.baseUrlServices)},e}();t.default=new i},4381:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.token="token",e.code="code"}(t.IGrantTypes||(t.IGrantTypes={}))},4551:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.force="force",e.check="check"}(t.IReauth||(t.IReauth={}))},4458:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(r(837)),i=r(596),a=function(){function e(){}return e.getInitialRedirectUri=function(e,t){var r=e.redirect_uri||t||window.location.href,n="function"==typeof r?r():r,o=n.indexOf("from_ims");return-1===o?n:("#"===n[o-1]&&o--,n.substr(0,o))},e.createDefaultRedirectUrl=function(e,t,r,n){var o=this.getInitialRedirectUri(r,e),i=this.createOldHash(o);return i.indexOf("?")>0?i+"&client_id="+t+"&api="+n:i+"?client_id="+t+"&api="+n},e.createRedirectUrl=function(e,t,r,n,o){void 0===o&&(o="");var i=this.createDefaultRedirectUrl(e,t,r,n);(o=o||r.scope||"")&&(i=i+"&scope="+o);var a=r.reauth||"";return a&&(i=i+"&reauth="+a),i},e.createOldHash=function(e){var t=e.indexOf("#");return t<0?e+"#old_hash=&from_ims=true":e.substring(0,t)+"#old_hash="+e.substring(t+1)+"&from_ims=true"},e.mergeApiParamsWithExternalParams=function(e,t,r){return i.merge(o.default.getCustomApiParameters(e,r),t)},e}();t.RedirectHelper=a},7821:function(e,t,r){var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},o=this&&this.__spread||function(){for(var e=[],t=0;t0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},n=this&&this.__spread||function(){for(var e=[],t=0;t=0?new o.RideException("ride_pba_idle_session","",!0):null;var i=this.addRedirectUriToJump(r,n);return new o.RideException(r,i)},e.prototype.addRedirectUriToJump=function(e,t){if(!t||"string"!=typeof t)return"";var r=t;this.adobeIdThinData||(this.adobeIdThinData=new n.AdobeIdThinData);var o=this.adobeIdThinData.computeRideRedirectUri(e);if(!o||0===o.length)return r;try{var i=new URL(r);return i.searchParams.append("redirect_uri",o),i.toString()}catch(e){return r}},e.prototype.isUnauthorizedException=function(e){var t=e.status;return 401===(void 0===t?0:t)},e}();t.default=new a},228:function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=function(e){var t=e.error,r=e.retryAfter,n=void 0===r?0:r,o=e.message,i=void 0===o?"":o;this.error=t,this.retryAfter=n,this.message=i};t.HttpErrorResponse=r},2:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r2048&&(delete o.redirect_uri,d=i+"?"+(l=a.default.uriEncodeData(o)));var f=this.addClientIdInHeader(r);return u.default.get(d,f)},e.prototype.avatarUrl=function(e){return c.default.baseUrlAdobe+"/ims/avatar/download/"+e},e.prototype.getReleaseFlags=function(e){var t=e.token,r=e.client_id,o=n({},s.default.getCustomApiParameters(this.apiParameters,"fg_value")),i=this.createAuthorizationHeader(t);this.addClientIdInHeader(r,i);var l=a.default.uriEncodeData(n({client_id:r},o)),d=c.default.baseUrlAdobe+"/ims/fg/value/v1?"+l+"&jslVersion="+c.default.jslibver;return u.default.get(d,i)},e.prototype.getTransitoryAuthorizationCode=function(e,t,r){void 0===t&&(t={});var o=n({},s.default.mergeExternalParameters(t,this.apiParameters,"check_token")),i=a.default.uriEncodeData(n(n({},o),e));return this.callCheckToken(i,r,"/check/v6/token?client_id="+r+"&jslVersion="+c.default.jslibver)},e.prototype.getTokenFromCode=function(e,t){void 0===t&&(t={});var r=n({},s.default.mergeExternalParameters(t,this.apiParameters,"token"));r.grant_type="authorization_code",delete e.other;var o=c.default.baseUrlServices+"/ims/token/v3?jslVersion="+c.default.jslibver,i=a.default.uriEncodeData(n(n({},r),e)),l=this.formEncoded();return this.addClientIdInHeader(e.client_id,l),u.default.post(o,i,l)},e.prototype.jumpToken=function(e,t,r){void 0===t&&(t={});var o=n({},s.default.mergeExternalParameters(t,this.apiParameters,"jumptoken")),i=c.default.baseUrlServices+"/ims/jumptoken/v1?client_id="+r+"&jslVersion="+c.default.jslibver,l=a.default.uriEncodeData(n(n({},o),e)),d=this.formEncoded();return this.addClientIdInHeader(r,d),u.default.post(i,l,d)},e.prototype.socialHeadlessSignIn=function(e,t){void 0===t&&(t={});var r=n({},s.default.mergeExternalParameters(t,this.apiParameters,"jumptoken")),o=c.default.baseUrlServices+"/ims/social/v2/native?jslVersion="+c.default.jslibver,i=a.default.uriEncodeData(n(n(n({},r),e),{response_type:"implicit_jump"}));return u.default.post(o,i,this.formEncoded())},e.prototype.createAuthorizationHeader=function(e){var t={};return e&&(t[i.HEADERS.AUTHORIZATION]="Bearer "+e),t},e.prototype.formEncoded=function(e){return void 0===e&&(e={}),e["content-type"]=this.CONTENT_FORM_ENCODED,e},e.prototype.addClientIdInHeader=function(e,t){return void 0===t&&(t={}),t.client_id=e,t},e.prototype.callCheckToken=function(e,t,r){var n=this.formEncoded();return this.addClientIdInHeader(t,n),u.default.post(c.default.checkTokenEndpoint.url+"/ims"+r,e,n).catch((function(t){if(!c.default.checkTokenEndpoint.shouldFallbackToAdobe(t))throw t;return u.default.post(c.default.checkTokenEndpoint.fallbackUrl+"/ims"+r,e,n)}))},e}();t.ImsApis=l},9689:function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){this.status=0,this.data="",this.status=e,this.data=this.toJson(t)}return e.prototype.toJson=function(e){try{return"string"!=typeof e?e:JSON.parse(e)}catch(t){return e}},e}();t.ApiResponse=r},5918:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(r(6094)),i=n(r(3316)),a=n(r(6754));t.default=new(function(){function e(){this.triggerOnError=null}return e.prototype.post=function(e,t,r){var n=this;void 0===r&&(r={});var i=o.default.getCachedApiResponse(e,t);if(i){var s=i.status,c=i.data;return 200===s?Promise.resolve(c):Promise.reject(c)}return a.default.post(e,t,r).then((function(r){return n.storeApiResponse(e,JSON.stringify(t),r)})).catch((function(r){return n.verifyError(e,JSON.stringify(t),r)}))},e.prototype.get=function(e,t){var r=this;void 0===t&&(t={});var n=o.default.getCachedApiResponse(e);if(n){var i=n.status,s=n.data;return 200===i?Promise.resolve(s):Promise.reject(s)}return a.default.get(e,t).then((function(t){return r.storeApiResponse(e,"",t)})).catch((function(t){return r.verifyError(e,"",t)}))},e.prototype.verifyError=function(e,t,r){this.storeApiResponse(e,t,r);var n=i.default.verify(r,e);return Promise.reject(n||r.data)},e.prototype.storeApiResponse=function(e,t,r){return void 0===t&&(t=""),o.default.storeApiResponse(e,t,r),Promise.resolve(r.data)},e}())},6754:function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var n=r(9689);t.default=new(function(){function e(){}return e.prototype.http=function(e){return new Promise((function(t,r){var o=new(0,window.XMLHttpRequest);"boolean"==typeof e.withCredentials?o.withCredentials=e.withCredentials:o.withCredentials=!0,"number"==typeof e.timeout&&(o.timeout=e.timeout),o.open(e.method,e.url,!0);var i;o.onload=function(){return this.status>=200&&this.status<300?t(new n.ApiResponse(this.status,this.response)):r(new n.ApiResponse(this.status,this.response))},o.onerror=function(){var e=new n.ApiResponse(this.status,this.response);return r(e)},o.ontimeout=function(){var e=new n.ApiResponse(0,"timeout");return r(e)},o.onabort=function(){var e=new n.ApiResponse(0,"aborted");return r(e)},(i=e.headers)&&Object.keys(i).forEach((function(e){o.setRequestHeader(e,i[e])})),o.send(e.data)}))},e.prototype.post=function(e,t,r,n,o){return void 0===r&&(r={}),this.http({headers:r,method:"POST",url:e,data:t,withCredentials:n,timeout:o})},e.prototype.get=function(e,t,r,n){return void 0===t&&(t={}),this.http({headers:t,method:"GET",url:e,withCredentials:r,timeout:n})},e}())},5996:function(e,t){var r=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},n=this&&this.__spread||function(){for(var e=[],t=0;t=0},this.client_id="",this.scope="",this.expire=new Date,this.user_id="",this.tokenValue="",this.sid="",this.state=null,this.fromFragment=!1,this.impersonatorId="",this.isImpersonatedSession=!1;var n=e.valid,i=e.tokenValue,a=e.access_token,s=e.state,c=e.other,u=i||a,l=this.parseJwt(u);if(!l)throw new Error("token cannot be decoded "+u);this.state=o.default.toJson(s);var d=l.client_id,f=l.user_id,p=l.scope,h=l.sid,v=l.imp_id,g=l.imp_sid,m=l.pba;this.client_id=d,this.expire=t,this.user_id=f,this.scope=p,this.valid=n,this.tokenValue=u,this.sid=h,this.other=c,this.impersonatorId=v||"",this.isImpersonatedSession=!!g,this.pbaSatisfiedPolicies=m&&m.split(",")||[]}return e.prototype.parseJwt=function(e){if(!e)return null;try{return JSON.parse(atob(e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/")))}catch(t){return i.default.error("error on decoding token ",e,t),null}},e.prototype.validate=function(e,t){var r=this,n=r.valid,o=r.client_id,s=r.scope,c=r.expire;return c expires_at",c),!1):null==n||n?o!==e?(i.default.error("token invalid --> client id",o,e),!1):!!a.validateScopeInclusion(t,s)||(i.default.error("token invalid --> scope"," token scope =",s,"vs adobeIdScope =",t,"."),!1):(i.default.error("token invalid --> valid"),!1)},e}();t.TokenFields=s},147:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r no response");var r=e.access_token,i=e.expires_in,a=e.token_type,s=e.error,c=e.error_description,u=void 0===c?"":c,l=e.sid,d=o(e,["access_token","expires_in","token_type","error","error_description","sid"]);if(s)throw new Error(s+" "+u);var f=Object.keys(d).length?d:null,p={token:r,expire:new Date(Date.now()+parseFloat(i)),token_type:a,sid:l},h=t.updateToken(p)||{},v={tokenInfo:n(n({},p),{impersonatorId:h.impersonatorId||"",isImpersonatedSession:h.isImpersonatedSession||!1,pbaSatisfiedPolicies:h.pbaSatisfiedPolicies||[]}),profile:f};return Promise.resolve(v)})).catch((function(e){return void 0===e&&(e={}),e instanceof g.HttpErrorResponse||e instanceof p.RideException?Promise.reject(e):(t.removeTokenFromLocalStorage(),Promise.reject(new h.TokenExpiredException(e)))}))},e.prototype.switchProfile=function(e,t){var r=this;void 0===t&&(t={});var i=this.tokenServiceRequest,a=i.clientId,s=i.imsApis,c=i.scope;return s.switchProfile({client_id:a,scope:c},t,e).then((function(e){if(!e)throw new Error("refresh token --> no response");var t=e.access_token,i=e.expires_in,a=e.token_type,s=e.error,c=e.error_description,u=void 0===c?"":c,l=e.sid,d=o(e,["access_token","expires_in","token_type","error","error_description","sid"]);if(s)throw new Error(s+" "+u);var f=Object.keys(d).length?d:null,p={token:t,expire:new Date(Date.now()+parseFloat(i)),token_type:a,sid:l},h=r.updateToken(p)||{},v={tokenInfo:n(n({},p),{impersonatorId:h.impersonatorId||"",isImpersonatedSession:h.isImpersonatedSession||!1}),profile:f};return Promise.resolve(v)})).catch((function(e){return void 0===e&&(e={}),Promise.reject(e)}))},e.prototype.callRefreshToken=function(e){return void 0===e&&(e={}),this.refreshToken(e).then((function(e){var t=e.tokenInfo,r=t.token,n=t.expire,o=e.profile,i=new c.TokenFields({valid:!0,tokenValue:r},n),a=new f.TokenProfileResponse(i,o);return Promise.resolve(a)})).catch((function(e){return Promise.reject(e)}))},e.prototype.updateToken=function(e){var t=e.token,r=e.expire,n=new c.TokenFields({tokenValue:t},r);return n?(n.tokenValue=t,this.addTokenToStorage(n),n):null},e.prototype.purge=function(){this.removeTokenFromLocalStorage(),this.removeReauthTokenFromLocalStorage()},e.prototype.setStandAloneToken=function(e){var t=e.token,r=e.sid,n=e.expirems,o=void 0===n?-1:n,i=this.tokenServiceRequest,a=i.clientId,s=i.scope,u=new Date((new Date).getTime()+o);if(!new c.TokenFields({valid:!0,tokenValue:t},u).validate(a,s))return!1;var l={expire:u,token:t,sid:r};return this.updateToken(l),!0},e.prototype.exchangeIjt=function(e){var t=this,r=this.tokenServiceRequest,n={client_id:r.clientId,scope:r.scope};return r.imsApis.exchangeIjt(n,e).then((function(e){var r=e.valid,n=e.access_token,o=e.expires_in,i=e.profile;if(!1===r)return Promise.reject(e);var a=new Date(Date.now()+1e3*parseFloat(o)),s=new c.TokenFields({valid:!0,tokenValue:n},a);t.addTokenToStorage(s);var u=new f.TokenProfileResponse(s,i);return Promise.resolve(u)}))},e}();t.TokenService=w},5973:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(r(837)),i=function(){function e(){}return e.prototype.fragmentToObject=function(e){var t=this.getHashFromURL(e);if(!t)return null;var r=this.processHashUrl(t),n=this.getOldHash(r),i=n?r.slice(r.indexOf("old_hash")):r,a=this.removeOldHash(i),s=this.getQueryParamsAsMap(a);n&&(s.old_hash=n);var c=s.state;return c&&(s.state=o.default.toJson(c)),s},e.prototype.getOldHash=function(e){if(!e)return"";var t=e.match("old_hash=(.*?)&from_ims=true");return t?t[1]:""},e.prototype.removeOldHash=function(e){return e?e.replace(/old_hash=(.*?)&from_ims=true/gi,"from_ims=true"):e},e.prototype.getHashFromURL=function(e){void 0===e&&(e=window.location.href);var t=e.indexOf("#");return-1!==t?e.substring(t+1):""},e.prototype.getQueryParamsAsMap=function(e){if(!e)return{};var t={};return(e=e.replace(/^(#\/|\/|#|\?|&)/,"")).split("&").forEach((function(e){if(e.length){var r=e.split("=");t[r[0]]=decodeURIComponent(r[1])}})),t},e.prototype.processHashUrl=function(e){return e.replace("?error","#error").replace(/#/gi,"&").replace("from_ims=true?","from_ims=true&")},e}();t.default=new i},3801:function(e,t){var r=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{c(n.next(e))}catch(e){i(e)}}function s(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))},n=this&&this.__generator||function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]0&&(r=new Array(n+1).join(e)+r),r}("0",5,e.toString(2))};t.decodeToBitstring=function(e,t){if(void 0===t&&(t=!1),"string"!=typeof e)throw new Error("Data is not a string");var o=e.toLowerCase().split("");!function(e){if(e.length%8!=0)throw new Error("Data length is not a multiple of 8");e.forEach((function(e){if(!(e in r))throw new Error("Unknown encoded character "+e)}));var t=!1;e.forEach((function(e){if("="!==e&&t)throw new Error("Found padding char in the middle of the string");"="===e&&(t=!0)}))}(o);var i=function(e){for(var t=e.length-1,r=0;"="===e[t];)++r,--t;return r}(o),a=[];o.forEach((function(e){a.push(n(r[e]))}));var s=a.join("");return i>0&&(s=s.slice(0,-5*i)),s.length%8!=0&&(s=s.slice(0,s.length%8*-1)),t?function(e){var t="";if(e.length%8!=0)throw new Error("Length must be a multiple of 8");for(var r=0,n=e.length;r { const { locale, imsClientId, imsScope, env } = getConfig(); + const { miloLibs, codeRoot } = getConfig(); if (!imsClientId) { reject(new Error('Missing IMS Client ID')); return; @@ -758,7 +759,9 @@ export async function loadIms() { }, onError: reject, }; - loadScript('https://auth.services.adobe.com/imslib/imslib.min.js'); + + const path = miloLibs || codeRoot; + loadScript(`${path}/deps/imslib.js`); }); return imsLoaded; }