oauth0-js-lib 2.0.0 → 2.1.0
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/dist/index.es.js +2 -2
- package/dist/index.umd.js +1 -1
- package/dist/main.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
package/dist/index.umd.js
CHANGED
|
@@ -184,4 +184,4 @@ Minimum version required to store current data is: `+B+`.
|
|
|
184
184
|
`,this.errorContainer.querySelector(".oauth-retry-button").addEventListener("click",()=>{this.startAuthFlow()})}renderExpiredState(){this.qrContainer.style.display="none",this.separator.style.display="none",this.loginButton.style.display="none",this.errorContainer.style.display="block",this.errorContainer.innerHTML=`
|
|
185
185
|
<p class="oauth-error-message">Срок действия ссылки истек.</p>
|
|
186
186
|
<button class="oauth-retry-button">Обновить</button>
|
|
187
|
-
`,this.errorContainer.querySelector(".oauth-retry-button").addEventListener("click",()=>{this.startAuthFlow()})}async show(t,r){this.isOpen||(this.requestData=t,this.errorCallback=r||null,this.overlay||this.createModal(),this.isOpen=!0,setTimeout(()=>{var n;return(n=this.overlay)==null?void 0:n.classList.add("active")},10),this.startAuthFlow())}async startAuthFlow(){if(this.requestData){this.setLoadingState();try{const t=await Mn(this.requestData);this.renderSuccessState(t)}catch(t){this.renderErrorState(t),this.errorCallback&&this.errorCallback(t)}}}close(){!this.isOpen||!this.overlay||(this.authEvent&&this.authEvent.close(),this.timerInterval&&(clearInterval(this.timerInterval),this.timerInterval=null),this.overlay.classList.remove("active"),setTimeout(()=>{this.overlay&&this.overlay.parentNode&&this.overlay.parentNode.removeChild(this.overlay),this.overlay=null,this.isOpen=!1,this.requestData=null},400))}}ko();const ye=mt(),Fn=U.create({baseURL:ye.baseUrl}),pt=new Fo;function Mo(e
|
|
187
|
+
`,this.errorContainer.querySelector(".oauth-retry-button").addEventListener("click",()=>{this.startAuthFlow()})}async show(t,r){this.isOpen||(this.requestData=t,this.errorCallback=r||null,this.overlay||this.createModal(),this.isOpen=!0,setTimeout(()=>{var n;return(n=this.overlay)==null?void 0:n.classList.add("active")},10),this.startAuthFlow())}async startAuthFlow(){if(this.requestData){this.setLoadingState();try{const t=await Mn(this.requestData);this.renderSuccessState(t)}catch(t){this.renderErrorState(t),this.errorCallback&&this.errorCallback(t)}}}close(){!this.isOpen||!this.overlay||(this.authEvent&&this.authEvent.close(),this.timerInterval&&(clearInterval(this.timerInterval),this.timerInterval=null),this.overlay.classList.remove("active"),setTimeout(()=>{this.overlay&&this.overlay.parentNode&&this.overlay.parentNode.removeChild(this.overlay),this.overlay=null,this.isOpen=!1,this.requestData=null},400))}}ko();const ye=mt(),Fn=U.create({baseURL:ye.baseUrl}),pt=new Fo;function Mo(e={}){pt.show(e)}function xo(){pt.close()}async function Mn(e={}){return(await Fn.post(ye.createEndpoint,e,{withCredentials:!0})).data}function xn(e=()=>pt.close(),t=()=>{}){const r=new URL(ye.authEventEndpoint,ye.baseUrl),n=new EventSource(r,{withCredentials:!0});return n.addEventListener("auth-success",async o=>{try{await Fn.post(ye.authConfirmEndpoint,null,{withCredentials:!0}),e()}catch(i){console.error(i),t(i)}finally{n.close()}}),n.onerror=o=>{console.error("EventSource failed:",o),n.close()},n}function ko(){if(document.getElementById("oauth0-js-lib-styles"))return;const e=document.createElement("style");e.id="oauth0-js-lib-styles",e.innerHTML=fo,document.head.appendChild(e)}v.closeQrLogin=xo,v.createAuthEvent=xn,v.createAuthSession=Mn,v.getConfig=mt,v.setConfig=jn,v.showQrLogin=Mo,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})}));
|
package/dist/main.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export interface AuthSession {
|
|
|
9
9
|
sessionId: string;
|
|
10
10
|
validUntil: string | null;
|
|
11
11
|
}
|
|
12
|
-
export declare function showQrLogin(
|
|
12
|
+
export declare function showQrLogin(sessionTime?: AuthSessionTime): void;
|
|
13
13
|
export declare function closeQrLogin(): void;
|
|
14
14
|
export declare function createAuthSession(sessionTime?: AuthSessionTime): Promise<AuthSession>;
|
|
15
15
|
export declare function createAuthEvent(successCallback?: Function, errorCallback?: Function): EventSource;
|