PageSourceSearch

https://fgc.org.br/o/oauth2-provider-web/__liferay__/global.js

js fgc.org.br collected 2026-10-02 08:22:23 UTC 3,841 bytes, 2 lines download raw bytes

1import{pkceChallenge as U}from"../../frontend-js-web/__liferay__/index.js";var c=class{authorizeURL;clientId;debug;homePageURL;redirectURIs;tokenURL;constructor(e){this.authorizeURL=e.authorizeURL,this.clientId=e.clientId,this.debug=e.debug||!1,this.homePageURL=e.homePageURL,this.redirectURIs=e.redirectURIs,this.tokenURL=e.tokenURL}async fetch(e,n={}){return this._fetch(e,n).then(t=>{if(t.ok){let o=t.headers.get("content-type");return o&&o.indexOf("application/json")!==-1?t.json():Promise.resolve(t)}return Promise.reject(t)})}_createIframe(e,n){let r=this,t=window.location.origin,o=r.redirectURIs.find(h=>h.startsWith(t));if(!o)return Promise.reject(`No redirectURI in ${r.redirectURIs} matching origin ${t}`);let s=document.createElement("iframe");return s.src=`${r.authorizeURL}?client_id=${r.clientId}&code_challenge=${e.code_challenge}&code_challenge_method=S256&redirect_uri=${encodeURIComponent(o)}&response_type=code&prompt=none&state=${n}`,s.style.display="none",document.body.appendChild(s),new Promise((h,d)=>{let R=i=>{if(r.debug&&console.debug("OAuth2Client._createIframe.event",i),i.data.error){i.target&&i.target.parentElement&&i.target.parentElement.removeChild(i.target),d(i.data.error);return}else if(!i.data.code)return;if(i.data.state!==n){i.target&&i.target.parentElement&&i.target.parentElement.removeChild(i.target),d("state does not match");return}let u=r._requestToken(e.code_verifier,i.data.code,o);h(u),u.then(f=>Liferay.Util.SessionStorage.setItem(n,JSON.stringify({...f,expires_after_ms:new Date().getTime()+f.expires_in*1e3}),Liferay.Util.SessionStorage.TYPES.NECESSARY)).then(()=>{i.target&&i.target.parentElement&&i.target.parentElement.removeChild(i.target)})};s.contentWindow&&s.contentWindow.addEventListener("message",R)})}async _fetch(e,n={}){let r=this,t=e instanceof Request?e.url:e.toString();if(t.includes("//")&&!t.startsWith(r.homePageURL))throw new Error(`This client only supports calls to ${r.homePageURL}`);t.startsWith(r.homePageURL)||(t.startsWith("/")&&(t=t.substring(1)),t=`${r.homePageURL}/${t}`);let o=await r._getOrRequestToken();return e=e instanceof Request?{...e,url:t}:t,await fetch(e,{...n,headers:{...n?.headers,Authorization:`Bearer ${o.access_token}`}})}async _getOrRequestToken(){let e=this,n=`${e.clientId}-${Liferay.authToken}-token`,r=Liferay.Util.SessionStorage.getItem(n,Liferay.Util.SessionStorage.TYPES.NECESSARY);if(e.debug&&r&&console.debug("OAuth2Client._getOrRequestToken.cachedTokenData",r),r!=null){let t=JSON.parse(r);if(new Date().getTime()<t.expires_after_ms)return t}return await e._requestTokenSilently(n)}async _requestTokenSilently(e){let n=this,r=await U(128);return n._createIframe(r,e)}async _requestToken(e,n,r){let t=this,o=await fetch(t.tokenURL,{body:new URLSearchParams({client_id:t.clientId,code:n,code_verifier:e,grant_type:"authorization_code",redirect_uri:r}),cache:"no-cache",headers:{"Content-Type":"application/x-www-form-urlencoded"},method:"POST",mode:"cors"});return o.ok?o.json():await Promise.reject(o)}};function m(a){return new c({authorizeURL:a.authorizeURL||g(),clientId:a.clientId,debug:a.debug,homePageURL:a.homePageURL,redirectURIs:a.redirectURIs||[p()],tokenURL:a.tokenURL||l()})}function g(){return Liferay.ThemeDisplay.getPathContext()+"/o/oauth2/authorize"}function p(){return Liferay.ThemeDisplay.getPathContext()+"/o/oauth2/redirect"}function l(){return Liferay.ThemeDisplay.getPathContext()+"/o/oauth2/token"}window.Liferay=window.Liferay||{};window.Liferay.OAuth2Client={FromParameters:m,FromUserAgentApplication(a,e){let n=Liferay.OAuth2.getUserAgentApplication(a);if(!n)throw new Error(`No Application User Agent profile found for ${a}`);return new c({authorizeURL:g(),clientId:n.clientId,debug:e,homePageURL:n.homePageURL,redirectURIs:n.redirectURIs,tokenURL:l()})}};
2//# sourceMappingURL=global.(RI4GBHHA).js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.