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 CHANGED
@@ -3571,8 +3571,8 @@ Ho();
3571
3571
  const fe = Dn(), Un = U.create({
3572
3572
  baseURL: fe.baseUrl
3573
3573
  }), dt = new Do();
3574
- function li(e, t = {}) {
3575
- dt.show(t);
3574
+ function li(e = {}) {
3575
+ dt.show(e);
3576
3576
  }
3577
3577
  function ci() {
3578
3578
  dt.close();
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,t={}){pt.show(t)}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"})}));
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(data: string, sessionTime?: AuthSessionTime): void;
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oauth0-js-lib",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.umd.js",
6
6
  "module": "./dist/index.es.js",