oauth0-js-lib 2.2.1 → 2.2.2

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
@@ -3511,7 +3511,7 @@ class Do {
3511
3511
  startTimer(t) {
3512
3512
  this.timerInterval && clearInterval(this.timerInterval);
3513
3513
  const r = () => {
3514
- const n = (/* @__PURE__ */ new Date()).getTime(), i = new Date(t).getTime() - n;
3514
+ const n = (/* @__PURE__ */ new Date()).getTime(), i = (/* @__PURE__ */ new Date(t + "Z")).getTime() - n;
3515
3515
  if (i > 0) {
3516
3516
  const s = Math.floor(i % 36e5 / 6e4), a = Math.floor(i % (1e3 * 60) / 1e3);
3517
3517
  this.timerContainer.textContent = `Ссылка действительна еще: ${String(s).padStart(2, "0")}:${String(a).padStart(2, "0")}`;
package/dist/index.umd.js CHANGED
@@ -178,7 +178,7 @@ Make sure your charset is UTF-8`);i=(i>>>8&255)*192+(i&255),n.put(i,13)}},lt=r,l
178
178
  The chosen QR Code version cannot contain this amount of data.
179
179
  Minimum version required to store current data is: `+B+`.
180
180
  `);const N=E(S,A,L),T=e.getSymbolSize(S),O=new n(T);return y(O,S),d(O),p(O,S),w(O,A,0),S>=7&&g(O,S),P(O,N),isNaN(C)&&(C=s.getBestMask(O,w.bind(null,O,A))),s.applyMask(C,O),w(O,A,C),{modules:O,version:S,errorCorrectionLevel:A,maskPattern:C,segments:L}}return Ve.create=function(S,A){if(typeof S>"u"||S==="")throw new Error("No input text");let C=t.M,L,B;return typeof A<"u"&&(C=t.from(A.errorCorrectionLevel,t.M),L=l.from(A.version),B=s.from(A.maskPattern),A.toSJISFunc&&e.setToSJISFunction(A.toSJISFunc)),_(S,L,C,B)},Ve}var ft={},dt={},Ln;function In(){return Ln||(Ln=1,(function(e){function t(r){if(typeof r=="number"&&(r=r.toString()),typeof r!="string")throw new Error("Color should be defined as hex string");let n=r.slice().replace("#","").split("");if(n.length<3||n.length===5||n.length>8)throw new Error("Invalid hex color: "+r);(n.length===3||n.length===4)&&(n=Array.prototype.concat.apply([],n.map(function(i){return[i,i]}))),n.length===6&&n.push("F","F");const o=parseInt(n.join(""),16);return{r:o>>24&255,g:o>>16&255,b:o>>8&255,a:o&255,hex:"#"+n.slice(0,6).join("")}}e.getOptions=function(n){n||(n={}),n.color||(n.color={});const o=typeof n.margin>"u"||n.margin===null||n.margin<0?4:n.margin,i=n.width&&n.width>=21?n.width:void 0,s=n.scale||4;return{width:i,scale:i?4:s,margin:o,color:{dark:t(n.color.dark||"#000000ff"),light:t(n.color.light||"#ffffffff")},type:n.type,rendererOpts:n.rendererOpts||{}}},e.getScale=function(n,o){return o.width&&o.width>=n+o.margin*2?o.width/(n+o.margin*2):o.scale},e.getImageWidth=function(n,o){const i=e.getScale(n,o);return Math.floor((n+o.margin*2)*i)},e.qrToImageData=function(n,o,i){const s=o.modules.size,a=o.modules.data,u=e.getScale(s,i),l=Math.floor((s+i.margin*2)*u),f=i.margin*u,h=[i.color.light,i.color.dark];for(let m=0;m<l;m++)for(let y=0;y<l;y++){let d=(m*l+y)*4,p=i.color.light;if(m>=f&&y>=f&&m<l-f&&y<l-f){const g=Math.floor((m-f)/u),w=Math.floor((y-f)/u);p=h[a[g*s+w]?1:0]}n[d++]=p.r,n[d++]=p.g,n[d++]=p.b,n[d]=p.a}}})(dt)),dt}var _n;function Io(){return _n||(_n=1,(function(e){const t=In();function r(o,i,s){o.clearRect(0,0,i.width,i.height),i.style||(i.style={}),i.height=s,i.width=s,i.style.height=s+"px",i.style.width=s+"px"}function n(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}e.render=function(i,s,a){let u=a,l=s;typeof u>"u"&&(!s||!s.getContext)&&(u=s,s=void 0),s||(l=n()),u=t.getOptions(u);const f=t.getImageWidth(i.modules.size,u),h=l.getContext("2d"),m=h.createImageData(f,f);return t.qrToImageData(m.data,i,u),r(h,l,f),h.putImageData(m,0,0),l},e.renderToDataURL=function(i,s,a){let u=a;typeof u>"u"&&(!s||!s.getContext)&&(u=s,s=void 0),u||(u={});const l=e.render(i,s,u),f=u.type||"image/png",h=u.rendererOpts||{};return l.toDataURL(f,h.quality)}})(ft)),ft}var ht={},Un;function _o(){if(Un)return ht;Un=1;const e=In();function t(o,i){const s=o.a/255,a=i+'="'+o.hex+'"';return s<1?a+" "+i+'-opacity="'+s.toFixed(2).slice(1)+'"':a}function r(o,i,s){let a=o+i;return typeof s<"u"&&(a+=" "+s),a}function n(o,i,s){let a="",u=0,l=!1,f=0;for(let h=0;h<o.length;h++){const m=Math.floor(h%i),y=Math.floor(h/i);!m&&!l&&(l=!0),o[h]?(f++,h>0&&m>0&&o[h-1]||(a+=l?r("M",m+s,.5+y+s):r("m",u,0),u=0,l=!1),m+1<i&&o[h+1]||(a+=r("h",f),f=0)):u++}return a}return ht.render=function(i,s,a){const u=e.getOptions(s),l=i.modules.size,f=i.modules.data,h=l+u.margin*2,m=u.color.light.a?"<path "+t(u.color.light,"fill")+' d="M0 0h'+h+"v"+h+'H0z"/>':"",y="<path "+t(u.color.dark,"stroke")+' d="'+n(f,l,u.margin)+'"/>',d='viewBox="0 0 '+h+" "+h+'"',g='<svg xmlns="http://www.w3.org/2000/svg" '+(u.width?'width="'+u.width+'" height="'+u.width+'" ':"")+d+' shape-rendering="crispEdges">'+m+y+`</svg>
181
- `;return typeof a=="function"&&a(null,g),g},ht}var vn;function Uo(){if(vn)return ae;vn=1;const e=ho(),t=Lo(),r=Io(),n=_o();function o(i,s,a,u,l){const f=[].slice.call(arguments,1),h=f.length,m=typeof f[h-1]=="function";if(!m&&!e())throw new Error("Callback required as last argument");if(m){if(h<2)throw new Error("Too few arguments provided");h===2?(l=a,a=s,s=u=void 0):h===3&&(s.getContext&&typeof l>"u"?(l=u,u=void 0):(l=u,u=a,a=s,s=void 0))}else{if(h<1)throw new Error("Too few arguments provided");return h===1?(a=s,s=u=void 0):h===2&&!s.getContext&&(u=a,a=s,s=void 0),new Promise(function(y,d){try{const p=t.create(a,u);y(i(p,s,u))}catch(p){d(p)}})}try{const y=t.create(a,u);l(null,i(y,s,u))}catch(y){l(y)}}return ae.create=t.create,ae.toCanvas=o.bind(null,r.render),ae.toDataURL=o.bind(null,r.renderToDataURL),ae.toString=o.bind(null,function(i,s,a){return n.render(i,a)}),ae}var vo=Uo();class Fo{constructor(){D(this,"overlay",null);D(this,"isOpen",!1);D(this,"errorCallback",null);D(this,"authEvent",null);D(this,"contentContainer",null);D(this,"loader",null);D(this,"qrContainer",null);D(this,"separator",null);D(this,"loginButton",null);D(this,"errorContainer",null);D(this,"timerContainer",null);D(this,"timerInterval",null);D(this,"requestData",null)}createElement(t,r,n){const o=document.createElement(t);return o.className=r,n&&(o.textContent=n),o}createModal(){this.overlay=this.createElement("div","oauth-modal-overlay"),this.contentContainer=this.createElement("div","oauth-modal-content");const t=this.createElement("h3","","Отсканируйте QR-код");this.contentContainer.appendChild(t),this.loader=this.createElement("div","oauth-loader"),this.loader.innerHTML='<div class="oauth-spinner"></div>',this.contentContainer.appendChild(this.loader),this.qrContainer=this.createElement("div","oauth-qrcode-container"),this.contentContainer.appendChild(this.qrContainer),this.timerContainer=this.createElement("div","oauth-timer-container"),this.contentContainer.appendChild(this.timerContainer),this.separator=this.createElement("p","oauth-modal-separator","ИЛИ"),this.contentContainer.appendChild(this.separator),this.loginButton=this.createElement("button","oauth-login-button","Войдите с текущего устройства"),this.contentContainer.appendChild(this.loginButton),this.errorContainer=this.createElement("div","oauth-error-container"),this.errorContainer.style.display="none",this.contentContainer.appendChild(this.errorContainer),this.overlay.appendChild(this.contentContainer),this.overlay.addEventListener("click",r=>{r.target===this.overlay&&this.close()}),document.body.appendChild(this.overlay)}async generateQR(t,r){try{t.innerHTML="";const n=document.createElement("canvas");await vo.toCanvas(n,r,{width:200,margin:1}),t.appendChild(n)}catch(n){console.error("Ошибка при генерации QR-кода:",n),t.innerHTML="<p>Не удалось загрузить QR-код</p>"}}startTimer(t){this.timerInterval&&clearInterval(this.timerInterval);const r=()=>{const n=new Date().getTime(),i=new Date(t).getTime()-n;if(i>0){const s=Math.floor(i%36e5/6e4),a=Math.floor(i%(1e3*60)/1e3);this.timerContainer.textContent=`Ссылка действительна еще: ${String(s).padStart(2,"0")}:${String(a).padStart(2,"0")}`}else clearInterval(this.timerInterval),this.timerInterval=null,this.renderExpiredState()};r(),this.timerInterval=window.setInterval(r,1e3)}setLoadingState(){this.loader.style.display="flex",this.qrContainer.style.display="none",this.separator.style.display="none",this.loginButton.style.display="none",this.errorContainer.style.display="none",this.timerContainer.style.display="none"}renderSuccessState(t){this.loader.style.display="none",this.errorContainer.style.display="none",this.qrContainer.style.display="flex",this.separator.style.display="block",this.loginButton.style.display="block";const r=t.links[0].link;this.generateQR(this.qrContainer,r),this.loginButton.onclick=()=>window.open(r),this.authEvent=xn(()=>this.close(),n=>this.renderErrorState(n)),t.validUntil?(this.timerContainer.style.display="block",this.startTimer(t.validUntil)):this.timerContainer.style.display="none"}renderErrorState(t){this.loader.style.display="none",this.qrContainer.style.display="none",this.separator.style.display="none",this.loginButton.style.display="none",this.timerContainer.style.display="none",this.errorContainer.style.display="block",this.errorContainer.innerHTML=`
181
+ `;return typeof a=="function"&&a(null,g),g},ht}var vn;function Uo(){if(vn)return ae;vn=1;const e=ho(),t=Lo(),r=Io(),n=_o();function o(i,s,a,u,l){const f=[].slice.call(arguments,1),h=f.length,m=typeof f[h-1]=="function";if(!m&&!e())throw new Error("Callback required as last argument");if(m){if(h<2)throw new Error("Too few arguments provided");h===2?(l=a,a=s,s=u=void 0):h===3&&(s.getContext&&typeof l>"u"?(l=u,u=void 0):(l=u,u=a,a=s,s=void 0))}else{if(h<1)throw new Error("Too few arguments provided");return h===1?(a=s,s=u=void 0):h===2&&!s.getContext&&(u=a,a=s,s=void 0),new Promise(function(y,d){try{const p=t.create(a,u);y(i(p,s,u))}catch(p){d(p)}})}try{const y=t.create(a,u);l(null,i(y,s,u))}catch(y){l(y)}}return ae.create=t.create,ae.toCanvas=o.bind(null,r.render),ae.toDataURL=o.bind(null,r.renderToDataURL),ae.toString=o.bind(null,function(i,s,a){return n.render(i,a)}),ae}var vo=Uo();class Fo{constructor(){D(this,"overlay",null);D(this,"isOpen",!1);D(this,"errorCallback",null);D(this,"authEvent",null);D(this,"contentContainer",null);D(this,"loader",null);D(this,"qrContainer",null);D(this,"separator",null);D(this,"loginButton",null);D(this,"errorContainer",null);D(this,"timerContainer",null);D(this,"timerInterval",null);D(this,"requestData",null)}createElement(t,r,n){const o=document.createElement(t);return o.className=r,n&&(o.textContent=n),o}createModal(){this.overlay=this.createElement("div","oauth-modal-overlay"),this.contentContainer=this.createElement("div","oauth-modal-content");const t=this.createElement("h3","","Отсканируйте QR-код");this.contentContainer.appendChild(t),this.loader=this.createElement("div","oauth-loader"),this.loader.innerHTML='<div class="oauth-spinner"></div>',this.contentContainer.appendChild(this.loader),this.qrContainer=this.createElement("div","oauth-qrcode-container"),this.contentContainer.appendChild(this.qrContainer),this.timerContainer=this.createElement("div","oauth-timer-container"),this.contentContainer.appendChild(this.timerContainer),this.separator=this.createElement("p","oauth-modal-separator","ИЛИ"),this.contentContainer.appendChild(this.separator),this.loginButton=this.createElement("button","oauth-login-button","Войдите с текущего устройства"),this.contentContainer.appendChild(this.loginButton),this.errorContainer=this.createElement("div","oauth-error-container"),this.errorContainer.style.display="none",this.contentContainer.appendChild(this.errorContainer),this.overlay.appendChild(this.contentContainer),this.overlay.addEventListener("click",r=>{r.target===this.overlay&&this.close()}),document.body.appendChild(this.overlay)}async generateQR(t,r){try{t.innerHTML="";const n=document.createElement("canvas");await vo.toCanvas(n,r,{width:200,margin:1}),t.appendChild(n)}catch(n){console.error("Ошибка при генерации QR-кода:",n),t.innerHTML="<p>Не удалось загрузить QR-код</p>"}}startTimer(t){this.timerInterval&&clearInterval(this.timerInterval);const r=()=>{const n=new Date().getTime(),i=new Date(t+"Z").getTime()-n;if(i>0){const s=Math.floor(i%36e5/6e4),a=Math.floor(i%(1e3*60)/1e3);this.timerContainer.textContent=`Ссылка действительна еще: ${String(s).padStart(2,"0")}:${String(a).padStart(2,"0")}`}else clearInterval(this.timerInterval),this.timerInterval=null,this.renderExpiredState()};r(),this.timerInterval=window.setInterval(r,1e3)}setLoadingState(){this.loader.style.display="flex",this.qrContainer.style.display="none",this.separator.style.display="none",this.loginButton.style.display="none",this.errorContainer.style.display="none",this.timerContainer.style.display="none"}renderSuccessState(t){this.loader.style.display="none",this.errorContainer.style.display="none",this.qrContainer.style.display="flex",this.separator.style.display="block",this.loginButton.style.display="block";const r=t.links[0].link;this.generateQR(this.qrContainer,r),this.loginButton.onclick=()=>window.open(r),this.authEvent=xn(()=>this.close(),n=>this.renderErrorState(n)),t.validUntil?(this.timerContainer.style.display="block",this.startTimer(t.validUntil)):this.timerContainer.style.display="none"}renderErrorState(t){this.loader.style.display="none",this.qrContainer.style.display="none",this.separator.style.display="none",this.loginButton.style.display="none",this.timerContainer.style.display="none",this.errorContainer.style.display="block",this.errorContainer.innerHTML=`
182
182
  <p class="oauth-error-message">Ошибка: ${t.message||"Неизвестная ошибка"}</p>
183
183
  <button class="oauth-retry-button">Повторить</button>
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=`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oauth0-js-lib",
3
- "version": "2.2.1",
3
+ "version": "2.2.2",
4
4
  "type": "module",
5
5
  "main": "./dist/index.umd.js",
6
6
  "module": "./dist/index.es.js",