text: System.register([],function(e){return{execute:function(){e(function(e){var o={};function t(n){if(o[n])return o[n].exports;var s=o[n]={i:n,l:!1,exports:{}};return e[n].call(s.exports,s,s.exports,t),s.l=!0,s.exports}return t.m=e,t.c=o,t.d=function(e,o,n){t.o(e,o)||Object.defineProperty(e,o,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,o){if(1&o&&(e=t(e)),8&o)return e;if(4&o&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&o&&"string"!=typeof e)for(var s in e)t.d(n,s,function(o){return e[o]}.bind(null,s));return n},t.n=function(e){var o=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(o,"a",o),o},t.o=function(e,o){return Object.prototype.hasOwnProperty.call(e,o)},t.p="",t(t.s=4)}([function(e,o,t){"use strict";let n,s,r;o.a=class{constructor(){console.log("[AbstractIdpProxy] constructor")}_init(e,o,t){let i=this;i.runtimeProtoStubURL=e,i.messageBus=o,i.config=t,n=t.idpProxy,s=t.convertUserProfile,r=t.accessTokenInput,i.messageBus.addListener("*",function(e){e.to===t.idpUrl&&i.requestToIdp(e)}),i._sendStatus("created")}requestToIdp(e){let o=this,t=e.body.params;switch(console.info("[AbstractIdpProxyProtoStub] receiving request: ",e),e.body.method){case"generateAssertion":n.generateAssertion(o.config,t.contents,t.origin,t.usernameHint).then(function(t){t.userProfile=s(t.userProfile),o.replyMessage(e,t)},function(t){o.replyMessage(e,t,401)});break;case"validateAssertion":n.validateAssertion(o.config,t.assertion,t.origin).then(function(t){o.replyMessage(e,t)},function(t){o.replyMessage(e,t)});break;case"refreshAssertion":n.refreshAssertion(t.identity).then(function(t){o.replyMessage(e,t)},function(t){o.replyMessage(e,t,value,401)});break;case"getAccessTokenAuthorisationEndpoint":n.getAccessTokenAuthorisationEndpoint(o.config,t.resources).then(function(t){o.replyMessage(e,t)},function(t){o.replyMessage(e,t,401)});break;case"getAccessToken":n.getAccessToken(o.config,t.resources,t.login).then(function(t){console.info("OIDC.getAccessToken result: ",t),t.input=r(t.input),o.replyMessage(e,t)},function(t){o.replyMessage(e,t,401)});break;case"refreshAccessToken":n.refreshAccessToken(o.config,t.token).then(function(t){console.info("OIDC.refreshAccessToken result: ",t),o.replyMessage(e,t)},function(t){o.replyMessage(e,t,401)});break;case"revokeAccessToken":n.revokeAccessToken(o.config,t.token).then(function(t){console.info("OIDC.revokeAccessToken result: ",t),o.replyMessage(e,t)},function(t){o.replyMessage(e,t,401)})}}replyMessage(e,o,t=200){let n={id:e.id,type:"response",to:e.from,from:e.to,body:{code:t}};t<300?n.body.value=o:n.body.description=o,console.log("[AbstractIdpProxyProtoStub.replyMessage] ",n),this.messageBus.postMessage(n)}_sendStatus(e,o){console.log("[AbstractIdpProxyProtoStub.sendStatus] ",e),this._state=e;let t={type:"update",from:this.runtimeProtoStubURL,to:this.runtimeProtoStubURL+"/status",body:{value:e}};o&&(t.body.desc=o),this.messageBus.postMessage(t)}}},,,,function(e,o,t){"use strict";t.r(o);let n,s,r,i,c,a={},u=0,l=location.protocol+"//"+location.hostname+(""!==location.port?":"+location.port:""),p=function(e){let o=!!e.hasOwnProperty("expires_in")&&e.expires_in;return o?o+=Math.floor(Date.now()/1e3):o=31536e5+Math.floor(Date.now()/1e3),Number(o)};function f(e,o){o=o.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");let t=new RegExp("[\\#&?]"+o+"=([^&#]*)").exec(e);return null!==t&&t[1]}function g(e,o){let t=new XMLHttpRequest;return"withCredentials"in t?t.open(e,o,!0):"undefined"!=typeof XDomainRequest?(t=new XDomainRequest).open(e,o):t=null,new Promise(function(e,o){t?(t.onreadystatechange=function(n){if(4===t.readyState)if(200===t.status){let o=JSON.parse(t.responseText);e(o)}else 400===t.status?o("There was an error processing the token"):o("something else other than 200 was returned")},t.send()):o("CORS not supported")})}let d=function(e,o,t,n,s){let i={domain:r,resources:e,accessToken:o,expires:t,input:n};return s&&(i.refresh=s),i},h={validateAssertion:(e,o,t)=>{console.info("[OIDC.validateAssertionProxy] assertion: ",atob(o));let n=atob(o),s=JSON.parse(n).tokenID.split(".");JSON.parse(atob(s[1]));return new Promise(function(t,n){let s=e.idpInfo,r=atob(o),i=JSON.parse(r);g("GET",s.tokenInfo+i.tokenID).then(e=>{JSON.stringify(e)===JSON.stringify(i.tokenIDJSON)?t({identity:i.tokenIDJSON.email,contents:i.tokenIDJSON}):n("invalid")}).catch(e=>{n(e)})})},refreshAssertion:e=>(console.log("OIDC.refreshAssertion:oldIdentity",e),new Promise(function(o,t){o(e)})),generateAssertion:(e,o,t,n)=>{console.log("[OIDC.generateAssertion:contents]",o),console.log("[OIDC.generateAssertion:origin]",t),console.log("[OIDC.generateAssertion:hint]",n);let s=e.idpInfo;return new Promise(function(e,t){if(n){let o=f(n,"access_token"),r=f(n,"id_token");f(n,"code");g("GET",s.userinfo+o).then(function(o){console.log("[OIDC.generateAssertion] obtained infoToken ",o),g("GET",s.tokenInfo+r).then(function(t){console.log("[OIDC.generateAssertion] obtained idToken ",t);let n={assertion:btoa(JSON.stringify({tokenID:r,tokenIDJSON:t})),idp:{domain:s.domain,protocol:"OIDC"},expires:t.exp,userProfile:o,refresh:!0};a[u]=n,++u,console.log("[OIDC.generateAssertion] returning: ",JSON.stringify(n)),e(n)},function(e){t(e)})},function(e){t(e)})}else{let e=s.authorisationEndpoint+"redirect_uri="+l+"&prompt=consent&response_type="+s.type+"&client_id="+s.clientID+"&scope="+s.scope+"&access_type="+s.accessType+"&nonce="+o+"&state="+s.state;console.log("[OIDC.generateAssertion] NO_HINT: rejecting with requestUrl ",e),t({name:"IdPLoginError",loginUrl:e})}})},getAccessTokenAuthorisationEndpoint:(e,o)=>{console.log("[OIDC.getAccessTokenAuthorisationEndpoint:config]",e),console.log("[OIDC.getAccessTokenAuthorisationEndpoint:resources]",o),i=e.accessTokenAuthorisationEndpoint;const t=e.mapping;return new Promise(function(e,n){e(i(t(o)))},function(e){reject(e)})},getAccessToken:(e,o,t)=>{console.log("[OIDC.getAccessToken:config]",e),console.log("[OIDC.getAccessToken:login]",t),n=e.accessTokenEndpoint,r=e.domain;return new Promise(function(e,s){let r=function(e){let o=f(e,"expires_in");return o?o+=Math.floor(Date.now()/1e3):o=31536e5+Math.floor(Date.now()/1e3),Number(o)}(t),i=f(t,"access_token");e(i?d(o,i,r,t):function(e,o){return new Promise(function(t,s){let r=f(o,"code");r||s("[OIDC.getAccessTokenWithCodeToken] code not include in the url: ",o),g("POST",n(r)).then(function(o){if(console.info("[OIDC.getAccessTokenWithCodeToken] response: ",o),o.hasOwnProperty("access_token")){let n=p(o),s=!!o.hasOwnProperty("refresh_token")&&o.refresh_token;t(d(e,o.access_token,n,o,s))}else s("[OIDC.getAccessTokenWithCodeToken] access token not returned in the exchange code result: ",o)},function(e){s(e)})})}(o,t))},function(e){reject(e)})},refreshAccessToken:(e,o)=>{console.log("[OIDC.refreshAccessToken:config]",e),console.log("[OIDC.refreshAccessToken:outdated token]",o),s=e.refreshAccessTokenEndpoint,r=e.domain;return new Promise(function(e,t){let n=o.refresh;n||t("[OIDC.refreshAccessToken] refresh token not available in the access token",o),g("POST",s(n)).then(function(s){if(console.info("[OIDC.refreshAccessToken] response: ",s),s.hasOwnProperty("access_token")){let t=p(s);e(d(o.resources,s.access_token,t,s,n))}else t("[OIDC.refreshAccessToken] new access token not returned in the response: ",s)},function(e){t(e)})},function(e){reject(e)})},revokeAccessToken:(e,o)=>{console.log("[OIDC.revokeAccessToken:config]",e),console.log("[OIDC.revokeAccessToken: token]",o),c=e.revokeAccessTokenEndpoint,r=e.domain;return new Promise(function(e,t){o.refresh||t("[OIDC.revokeAccessToken] refresh token not available in the access token",o),g("POST",c(o.accessToken)).then(function(o){console.info("[OIDC.revokeAccessToken] response: ",o),e(!0)},function(e){t(e)})},function(e){reject(e)})}},k=location.protocol+"//"+location.hostname+(""!==location.port?":"+location.port:""),y={clientID:"808329566012-tqr8qoh111942gd2kg007t0s8f277roi.apps.googleusercontent.com",issuer:"https://accounts.google.com",tokenEndpoint:"https://www.googleapis.com/oauth2/v4/token?",jwksUri:"https://www.googleapis.com/oauth2/v3/certs?",authorisationEndpoint:"https://accounts.google.com/o/oauth2/auth?",userinfo:"https://www.googleapis.com/oauth2/v3/userinfo?access_token=",tokenInfo:"https://www.googleapis.com/oauth2/v3/tokeninfo?id_token=",accessType:"online",type:"token id_token",scope:"openid%20email%20profile",state:"state",domain:"google.com"},m={clientID:"808329566012-tqr8qoh111942gd2kg007t0s8f277roi.apps.googleusercontent.com",issuer:"https://accounts.google.com",tokenEndpoint:"https://www.googleapis.com/oauth2/v4/token?",revokeEndpoint:"https://accounts.google.com/o/oauth2/revoke?",jwksUri:"https://www.googleapis.com/oauth2/v3/certs?",authorisationEndpoint:"https://accounts.google.com/o/oauth2/auth?",userinfo:"https://www.googleapis.com/oauth2/v3/userinfo?access_token=",tokenInfo:"https://www.googleapis.com/oauth2/v3/tokeninfo?id_token=",accessType:"offline",type:"code",scope:"https://www.googleapis.com/auth/fitness.location.read",state:"state",domain:"google.com",grant_type:"authorization_code",secret:"Xx4rKucb5ZYTaXlcZX9HLfZW"};function T(e){return m.tokenEndpoint+"client_id="+m.clientID+"&code="+e+"&grant_type=authorization_code&access_type=offline&client_secret="+m.secret+"&redirect_uri="+k}function w(e){return m.tokenEndpoint+"client_id="+m.clientID+"&refresh_token="+e+"&grant_type=refresh_token&client_secret="+m.secret}function A(e){return m.revokeEndpoint+"&token="+e}function I(e){if(!e)return"fitness.location.read%20https://www.googleapis.com/auth/fitness.activity.read";switch(e){case"user_activity_context":default:return"fitness.location.read%20https://www.googleapis.com/auth/fitness.activity.read"}}function _(e){let o=m.authorisationEndpoint+"redirect_uri="+k+"&response_type="+m.type+"&client_id="+m.clientID+"&scope=https://www.googleapis.com/auth/"+e+"&access_type="+m.accessType+"&state="+m.state;return console.log("[GoogleInfo.accessTokenAuthorisationEndpoint] ",o),o}function O(e){let o=m.authorisationEndpoint+"redirect_uri="+k+"&response_type="+m.type+"&client_id="+m.clientID+"&scope="+m.scope+"&access_type="+m.accessType+"&state="+e;return console.log("[GoogleInfo.authorisationEndpoint] ",o),o}function b(e){return{info:e}}function D(e){return e.userURL="user://google.com/"+e.email,e.hasOwnProperty("preferred_username")||(e.preferred_username=e.email.split("@")[0]),e}var v=t(0);t.d(o,"default",function(){return P});class P extends v.a{constructor(){super()}_start(e,o,t){console.log("[GoogleIdpProxyProtoStub._start] "),t.domain="google.com",t.idpUrl="domain-idp://google.com",t.idpProxy=h,t.idpInfo=y,t.apiInfo=m,t.accessTokenAuthorisationEndpoint=_,t.accessTokenEndpoint=T,t.refreshAccessTokenEndpoint=w,t.revokeAccessTokenEndpoint=A,t.accessTokenInput=b,t.authorisationEndpoint=O,t.convertUserProfile=D,t.mapping=I,super._init(e,o,t)}}}]))}}});