@imtbl/auth 2.12.5 → 2.12.6-alpha.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/README.md +163 -0
- package/dist/browser/index.js +79 -27
- package/dist/node/index.cjs +96 -40
- package/dist/node/index.js +79 -27
- package/dist/types/index.d.ts +2 -1
- package/dist/types/login/standalone.d.ts +141 -0
- package/dist/types/types.d.ts +32 -3
- package/package.json +6 -6
- package/src/Auth.test.ts +225 -0
- package/src/Auth.ts +23 -10
- package/src/index.ts +16 -0
- package/src/login/standalone.ts +745 -0
- package/src/types.ts +36 -2
package/dist/browser/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { UserManager, User, ErrorTimeout, ErrorResponse, InMemoryWebStorage, WebStorageStateStore } from 'oidc-client-ts';
|
|
2
|
-
import
|
|
2
|
+
import In from 'localforage';
|
|
3
3
|
import { track, identify, getDetail, Detail, trackFlow, trackError } from '@imtbl/metrics';
|
|
4
4
|
|
|
5
|
-
function Oe(c){throw new Error("Node.js process "+c+" is not supported by JSPM core outside of Node.js")}var K=[],te=!1,j,he=-1;function Ut(){!te||!j||(te=!1,j.length?K=j.concat(K):he=-1,K.length&&Ze());}function Ze(){if(!te){var c=setTimeout(Ut,0);te=!0;for(var n=K.length;n;){for(j=K,K=[];++he<n;)j&&j[he].run();he=-1,n=K.length;}j=null,te=!1,clearTimeout(c);}}function Bt(c){var n=new Array(arguments.length-1);if(arguments.length>1)for(var a=1;a<arguments.length;a++)n[a-1]=arguments[a];K.push(new We(c,n)),K.length===1&&!te&&setTimeout(Ze,0);}function We(c,n){this.fun=c,this.array=n;}We.prototype.run=function(){this.fun.apply(null,this.array);};var kt="browser",bt="x64",xt="browser",St={PATH:"/usr/bin",LANG:navigator.language+".UTF-8",PWD:"/",HOME:"/home",TMP:"/tmp"},Mt=["/usr/bin/node"],Nt=[],Dt="v16.8.0",Ft={},Ht=function(c,n){console.warn((n?n+": ":"")+c);},Vt=function(c){Oe("binding");},Gt=function(c){return 0},$t=function(){return "/"},Kt=function(c){},Zt={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};function b(){}var Wt=b,Yt=[];function zt(c){Oe("_linkedBinding");}var Jt={},jt=!1,qt={};function Xt(c){Oe("dlopen");}function Qt(){return []}function er(){return []}var tr=b,rr=b,Le=function(){return {}},nr=Le,ir=Le,or=b,sr=b,ar=b,lr={};function ur(c,n){if(!c)throw new Error(n||"assertion error")}var cr={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},pr=b,dr=b;function hr(){return !1}var fr=b,mr=b,gr=b,Er=b,yr=b,wr=void 0,_r=void 0,Cr=void 0,Ir=b,Rr=2,Tr=1,vr="/bin/usr/node",Ar=9229,Or="node",Lr=[],Pr=b,W={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};W.now===void 0&&(Te=Date.now(),W.timing&&W.timing.navigationStart&&(Te=W.timing.navigationStart),W.now=()=>Date.now()-Te);var Te;function Ur(){return W.now()/1e3}var ve=1e9;function Ae(c){var n=Math.floor((Date.now()-W.now())*.001),a=W.now()*.001,u=Math.floor(a)+n,d=Math.floor(a%1*1e9);return c&&(u=u-c[0],d=d-c[1],d<0&&(u--,d+=ve)),[u,d]}Ae.bigint=function(c){var n=Ae(c);return typeof BigInt>"u"?n[0]*ve+n[1]:BigInt(n[0]*ve)+BigInt(n[1])};var Br=10,kr={},br=0;function Y(){return v}var xr=Y,Sr=Y,Mr=Y,Nr=Y,Dr=Y,Fr=b,Hr=Y,Vr=Y;function Gr(c){return []}var v={version:Dt,versions:Ft,arch:bt,platform:xt,release:Zt,_rawDebug:Wt,moduleLoadList:Yt,binding:Vt,_linkedBinding:zt,_events:kr,_eventsCount:br,_maxListeners:Br,on:Y,addListener:xr,once:Sr,off:Mr,removeListener:Nr,removeAllListeners:Dr,emit:Fr,prependListener:Hr,prependOnceListener:Vr,listeners:Gr,domain:Jt,_exiting:jt,config:qt,dlopen:Xt,uptime:Ur,_getActiveRequests:Qt,_getActiveHandles:er,reallyExit:tr,_kill:rr,cpuUsage:Le,resourceUsage:nr,memoryUsage:ir,kill:or,exit:sr,openStdin:ar,allowedNodeEnvironmentFlags:lr,assert:ur,features:cr,_fatalExceptions:pr,setUncaughtExceptionCaptureCallback:dr,hasUncaughtExceptionCaptureCallback:hr,emitWarning:Ht,nextTick:Bt,_tickCallback:fr,_debugProcess:mr,_debugEnd:gr,_startProfilerIdleNotifier:Er,_stopProfilerIdleNotifier:yr,stdout:wr,stdin:Cr,stderr:_r,abort:Ir,umask:Gt,chdir:Kt,cwd:$t,env:St,title:kt,argv:Mt,execArgv:Nt,pid:Rr,ppid:Tr,execPath:vr,debugPort:Ar,hrtime:Ae,argv0:Or,_preload_modules:Lr,setSourceMapsEnabled:Pr};var se={},Ye=!1;function $r(){if(Ye)return se;Ye=!0,se.byteLength=y,se.toByteArray=k,se.fromByteArray=F;for(var c=[],n=[],a=typeof Uint8Array<"u"?Uint8Array:Array,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",d=0,h=u.length;d<h;++d)c[d]=u[d],n[u.charCodeAt(d)]=d;n[45]=62,n[95]=63;function s(f){var E=f.length;if(E%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var _=f.indexOf("=");_===-1&&(_=E);var U=_===E?0:4-_%4;return [_,U]}function y(f){var E=s(f),_=E[0],U=E[1];return (_+U)*3/4-U}function T(f,E,_){return (E+_)*3/4-_}function k(f){var E,_=s(f),U=_[0],S=_[1],P=new a(T(f,U,S)),M=0,D=S>0?U-4:U,x;for(x=0;x<D;x+=4)E=n[f.charCodeAt(x)]<<18|n[f.charCodeAt(x+1)]<<12|n[f.charCodeAt(x+2)]<<6|n[f.charCodeAt(x+3)],P[M++]=E>>16&255,P[M++]=E>>8&255,P[M++]=E&255;return S===2&&(E=n[f.charCodeAt(x)]<<2|n[f.charCodeAt(x+1)]>>4,P[M++]=E&255),S===1&&(E=n[f.charCodeAt(x)]<<10|n[f.charCodeAt(x+1)]<<4|n[f.charCodeAt(x+2)]>>2,P[M++]=E>>8&255,P[M++]=E&255),P}function m(f){return c[f>>18&63]+c[f>>12&63]+c[f>>6&63]+c[f&63]}function I(f,E,_){for(var U,S=[],P=E;P<_;P+=3)U=(f[P]<<16&16711680)+(f[P+1]<<8&65280)+(f[P+2]&255),S.push(m(U));return S.join("")}function F(f){for(var E,_=f.length,U=_%3,S=[],P=16383,M=0,D=_-U;M<D;M+=P)S.push(I(f,M,M+P>D?D:M+P));return U===1?(E=f[_-1],S.push(c[E>>2]+c[E<<4&63]+"==")):U===2&&(E=(f[_-2]<<8)+f[_-1],S.push(c[E>>10]+c[E>>4&63]+c[E<<2&63]+"=")),S.join("")}return se}var fe={},ze=!1;function Kr(){if(ze)return fe;ze=!0;return fe.read=function(c,n,a,u,d){var h,s,y=d*8-u-1,T=(1<<y)-1,k=T>>1,m=-7,I=a?d-1:0,F=a?-1:1,f=c[n+I];for(I+=F,h=f&(1<<-m)-1,f>>=-m,m+=y;m>0;h=h*256+c[n+I],I+=F,m-=8);for(s=h&(1<<-m)-1,h>>=-m,m+=u;m>0;s=s*256+c[n+I],I+=F,m-=8);if(h===0)h=1-k;else {if(h===T)return s?NaN:(f?-1:1)*(1/0);s=s+Math.pow(2,u),h=h-k;}return (f?-1:1)*s*Math.pow(2,h-u)},fe.write=function(c,n,a,u,d,h){var s,y,T,k=h*8-d-1,m=(1<<k)-1,I=m>>1,F=d===23?Math.pow(2,-24)-Math.pow(2,-77):0,f=u?0:h-1,E=u?1:-1,_=n<0||n===0&&1/n<0?1:0;for(n=Math.abs(n),isNaN(n)||n===1/0?(y=isNaN(n)?1:0,s=m):(s=Math.floor(Math.log(n)/Math.LN2),n*(T=Math.pow(2,-s))<1&&(s--,T*=2),s+I>=1?n+=F/T:n+=F*Math.pow(2,1-I),n*T>=2&&(s++,T/=2),s+I>=m?(y=0,s=m):s+I>=1?(y=(n*T-1)*Math.pow(2,d),s=s+I):(y=n*Math.pow(2,I-1)*Math.pow(2,d),s=0));d>=8;c[a+f]=y&255,f+=E,y/=256,d-=8);for(s=s<<d|y,k+=d;k>0;c[a+f]=s&255,f+=E,s/=256,k-=8);c[a+f-E]|=_*128;},fe}var q={},Je=!1;function Zr(){if(Je)return q;Je=!0;let c=$r(),n=Kr(),a=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;q.Buffer=s,q.SlowBuffer=S,q.INSPECT_MAX_BYTES=50;let u=2147483647;q.kMaxLength=u,s.TYPED_ARRAY_SUPPORT=d(),!s.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function d(){try{let r=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(r,e),r.foo()===42}catch{return !1}}Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}});function h(r){if(r>u)throw new RangeError('The value "'+r+'" is invalid for option "size"');let e=new Uint8Array(r);return Object.setPrototypeOf(e,s.prototype),e}function s(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return m(r)}return y(r,e,t)}s.poolSize=8192;function y(r,e,t){if(typeof r=="string")return I(r,e);if(ArrayBuffer.isView(r))return f(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(V(r,ArrayBuffer)||r&&V(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(V(r,SharedArrayBuffer)||r&&V(r.buffer,SharedArrayBuffer)))return E(r,e,t);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let i=r.valueOf&&r.valueOf();if(i!=null&&i!==r)return s.from(i,e,t);let o=_(r);if(o)return o;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return s.from(r[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}s.from=function(r,e,t){return y(r,e,t)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array);function T(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function k(r,e,t){return T(r),r<=0?h(r):e!==void 0?typeof t=="string"?h(r).fill(e,t):h(r).fill(e):h(r)}s.alloc=function(r,e,t){return k(r,e,t)};function m(r){return T(r),h(r<0?0:U(r)|0)}s.allocUnsafe=function(r){return m(r)},s.allocUnsafeSlow=function(r){return m(r)};function I(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=P(r,e)|0,i=h(t),o=i.write(r,e);return o!==t&&(i=i.slice(0,o)),i}function F(r){let e=r.length<0?0:U(r.length)|0,t=h(e);for(let i=0;i<e;i+=1)t[i]=r[i]&255;return t}function f(r){if(V(r,Uint8Array)){let e=new Uint8Array(r);return E(e.buffer,e.byteOffset,e.byteLength)}return F(r)}function E(r,e,t){if(e<0||r.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<e+(t||0))throw new RangeError('"length" is outside of buffer bounds');let i;return e===void 0&&t===void 0?i=new Uint8Array(r):t===void 0?i=new Uint8Array(r,e):i=new Uint8Array(r,e,t),Object.setPrototypeOf(i,s.prototype),i}function _(r){if(s.isBuffer(r)){let e=U(r.length)|0,t=h(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r.length!="number"||Re(r.length)?h(0):F(r);if(r.type==="Buffer"&&Array.isArray(r.data))return F(r.data)}function U(r){if(r>=u)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u.toString(16)+" bytes");return r|0}function S(r){return +r!=r&&(r=0),s.alloc(+r)}s.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==s.prototype},s.compare=function(e,t){if(V(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),V(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(e)||!s.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let i=e.length,o=t.length;for(let l=0,p=Math.min(i,o);l<p;++l)if(e[l]!==t[l]){i=e[l],o=t[l];break}return i<o?-1:o<i?1:0},s.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return !0;default:return !1}},s.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return s.alloc(0);let i;if(t===void 0)for(t=0,i=0;i<e.length;++i)t+=e[i].length;let o=s.allocUnsafe(t),l=0;for(i=0;i<e.length;++i){let p=e[i];if(V(p,Uint8Array))l+p.length>o.length?(s.isBuffer(p)||(p=s.from(p)),p.copy(o,l)):Uint8Array.prototype.set.call(o,p,l);else if(s.isBuffer(p))p.copy(o,l);else throw new TypeError('"list" argument must be an Array of Buffers');l+=p.length;}return o};function P(r,e){if(s.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||V(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);let t=r.length,i=arguments.length>2&&arguments[2]===!0;if(!i&&t===0)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return Ie(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return Ke(r).length;default:if(o)return i?-1:Ie(r).length;e=(""+e).toLowerCase(),o=!0;}}s.byteLength=P;function M(r,e,t){let i=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return "";for(r||(r="utf8");;)switch(r){case"hex":return Ct(this,e,t);case"utf8":case"utf-8":return Se(this,e,t);case"ascii":return wt(this,e,t);case"latin1":case"binary":return _t(this,e,t);case"base64":return Et(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return It(this,e,t);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),i=!0;}}s.prototype._isBuffer=!0;function D(r,e,t){let i=r[e];r[e]=r[t],r[t]=i;}s.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)D(this,t,t+1);return this},s.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)D(this,t,t+3),D(this,t+1,t+2);return this},s.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)D(this,t,t+7),D(this,t+1,t+6),D(this,t+2,t+5),D(this,t+3,t+4);return this},s.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?Se(this,0,e):M.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(e){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:s.compare(this,e)===0},s.prototype.inspect=function(){let e="",t=q.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},a&&(s.prototype[a]=s.prototype.inspect),s.prototype.compare=function(e,t,i,o,l){if(V(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),i===void 0&&(i=e?e.length:0),o===void 0&&(o=0),l===void 0&&(l=this.length),t<0||i>e.length||o<0||l>this.length)throw new RangeError("out of range index");if(o>=l&&t>=i)return 0;if(o>=l)return -1;if(t>=i)return 1;if(t>>>=0,i>>>=0,o>>>=0,l>>>=0,this===e)return 0;let p=l-o,g=i-t,A=Math.min(p,g),R=this.slice(o,l),O=e.slice(t,i);for(let w=0;w<A;++w)if(R[w]!==O[w]){p=R[w],g=O[w];break}return p<g?-1:g<p?1:0};function x(r,e,t,i,o){if(r.length===0)return -1;if(typeof t=="string"?(i=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,Re(t)&&(t=o?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(o)return -1;t=r.length-1;}else if(t<0)if(o)t=0;else return -1;if(typeof e=="string"&&(e=s.from(e,i)),s.isBuffer(e))return e.length===0?-1:C(r,e,t,i,o);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?o?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):C(r,[e],t,i,o);throw new TypeError("val must be string, number or Buffer")}function C(r,e,t,i,o){let l=1,p=r.length,g=e.length;if(i!==void 0&&(i=String(i).toLowerCase(),i==="ucs2"||i==="ucs-2"||i==="utf16le"||i==="utf-16le")){if(r.length<2||e.length<2)return -1;l=2,p/=2,g/=2,t/=2;}function A(O,w){return l===1?O[w]:O.readUInt16BE(w*l)}let R;if(o){let O=-1;for(R=t;R<p;R++)if(A(r,R)===A(e,O===-1?0:R-O)){if(O===-1&&(O=R),R-O+1===g)return O*l}else O!==-1&&(R-=R-O),O=-1;}else for(t+g>p&&(t=p-g),R=t;R>=0;R--){let O=!0;for(let w=0;w<g;w++)if(A(r,R+w)!==A(e,w)){O=!1;break}if(O)return R}return -1}s.prototype.includes=function(e,t,i){return this.indexOf(e,t,i)!==-1},s.prototype.indexOf=function(e,t,i){return x(this,e,t,i,!0)},s.prototype.lastIndexOf=function(e,t,i){return x(this,e,t,i,!1)};function dt(r,e,t,i){t=Number(t)||0;let o=r.length-t;i?(i=Number(i),i>o&&(i=o)):i=o;let l=e.length;i>l/2&&(i=l/2);let p;for(p=0;p<i;++p){let g=parseInt(e.substr(p*2,2),16);if(Re(g))return p;r[t+p]=g;}return p}function ht(r,e,t,i){return de(Ie(e,r.length-t),r,t,i)}function ft(r,e,t,i){return de(At(e),r,t,i)}function mt(r,e,t,i){return de(Ke(e),r,t,i)}function gt(r,e,t,i){return de(Ot(e,r.length-t),r,t,i)}s.prototype.write=function(e,t,i,o){if(t===void 0)o="utf8",i=this.length,t=0;else if(i===void 0&&typeof t=="string")o=t,i=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(i)?(i=i>>>0,o===void 0&&(o="utf8")):(o=i,i=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let l=this.length-t;if((i===void 0||i>l)&&(i=l),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");let p=!1;for(;;)switch(o){case"hex":return dt(this,e,t,i);case"utf8":case"utf-8":return ht(this,e,t,i);case"ascii":case"latin1":case"binary":return ft(this,e,t,i);case"base64":return mt(this,e,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return gt(this,e,t,i);default:if(p)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),p=!0;}},s.prototype.toJSON=function(){return {type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Et(r,e,t){return e===0&&t===r.length?c.fromByteArray(r):c.fromByteArray(r.slice(e,t))}function Se(r,e,t){t=Math.min(r.length,t);let i=[],o=e;for(;o<t;){let l=r[o],p=null,g=l>239?4:l>223?3:l>191?2:1;if(o+g<=t){let A,R,O,w;switch(g){case 1:l<128&&(p=l);break;case 2:A=r[o+1],(A&192)===128&&(w=(l&31)<<6|A&63,w>127&&(p=w));break;case 3:A=r[o+1],R=r[o+2],(A&192)===128&&(R&192)===128&&(w=(l&15)<<12|(A&63)<<6|R&63,w>2047&&(w<55296||w>57343)&&(p=w));break;case 4:A=r[o+1],R=r[o+2],O=r[o+3],(A&192)===128&&(R&192)===128&&(O&192)===128&&(w=(l&15)<<18|(A&63)<<12|(R&63)<<6|O&63,w>65535&&w<1114112&&(p=w));}}p===null?(p=65533,g=1):p>65535&&(p-=65536,i.push(p>>>10&1023|55296),p=56320|p&1023),i.push(p),o+=g;}return yt(i)}let Me=4096;function yt(r){let e=r.length;if(e<=Me)return String.fromCharCode.apply(String,r);let t="",i=0;for(;i<e;)t+=String.fromCharCode.apply(String,r.slice(i,i+=Me));return t}function wt(r,e,t){let i="";t=Math.min(r.length,t);for(let o=e;o<t;++o)i+=String.fromCharCode(r[o]&127);return i}function _t(r,e,t){let i="";t=Math.min(r.length,t);for(let o=e;o<t;++o)i+=String.fromCharCode(r[o]);return i}function Ct(r,e,t){let i=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>i)&&(t=i);let o="";for(let l=e;l<t;++l)o+=Lt[r[l]];return o}function It(r,e,t){let i=r.slice(e,t),o="";for(let l=0;l<i.length-1;l+=2)o+=String.fromCharCode(i[l]+i[l+1]*256);return o}s.prototype.slice=function(e,t){let i=this.length;e=~~e,t=t===void 0?i:~~t,e<0?(e+=i,e<0&&(e=0)):e>i&&(e=i),t<0?(t+=i,t<0&&(t=0)):t>i&&(t=i),t<e&&(t=e);let o=this.subarray(e,t);return Object.setPrototypeOf(o,s.prototype),o};function B(r,e,t){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to access beyond buffer length")}s.prototype.readUintLE=s.prototype.readUIntLE=function(e,t,i){e=e>>>0,t=t>>>0,i||B(e,t,this.length);let o=this[e],l=1,p=0;for(;++p<t&&(l*=256);)o+=this[e+p]*l;return o},s.prototype.readUintBE=s.prototype.readUIntBE=function(e,t,i){e=e>>>0,t=t>>>0,i||B(e,t,this.length);let o=this[e+--t],l=1;for(;t>0&&(l*=256);)o+=this[e+--t]*l;return o},s.prototype.readUint8=s.prototype.readUInt8=function(e,t){return e=e>>>0,t||B(e,1,this.length),this[e]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||B(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||B(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||B(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||B(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readBigUInt64LE=Z(function(e){e=e>>>0,ee(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&oe(e,this.length-8);let o=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,l=this[++e]+this[++e]*2**8+this[++e]*2**16+i*2**24;return BigInt(o)+(BigInt(l)<<BigInt(32))}),s.prototype.readBigUInt64BE=Z(function(e){e=e>>>0,ee(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&oe(e,this.length-8);let o=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],l=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+i;return (BigInt(o)<<BigInt(32))+BigInt(l)}),s.prototype.readIntLE=function(e,t,i){e=e>>>0,t=t>>>0,i||B(e,t,this.length);let o=this[e],l=1,p=0;for(;++p<t&&(l*=256);)o+=this[e+p]*l;return l*=128,o>=l&&(o-=Math.pow(2,8*t)),o},s.prototype.readIntBE=function(e,t,i){e=e>>>0,t=t>>>0,i||B(e,t,this.length);let o=t,l=1,p=this[e+--o];for(;o>0&&(l*=256);)p+=this[e+--o]*l;return l*=128,p>=l&&(p-=Math.pow(2,8*t)),p},s.prototype.readInt8=function(e,t){return e=e>>>0,t||B(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},s.prototype.readInt16LE=function(e,t){e=e>>>0,t||B(e,2,this.length);let i=this[e]|this[e+1]<<8;return i&32768?i|4294901760:i},s.prototype.readInt16BE=function(e,t){e=e>>>0,t||B(e,2,this.length);let i=this[e+1]|this[e]<<8;return i&32768?i|4294901760:i},s.prototype.readInt32LE=function(e,t){return e=e>>>0,t||B(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return e=e>>>0,t||B(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readBigInt64LE=Z(function(e){e=e>>>0,ee(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&oe(e,this.length-8);let o=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(i<<24);return (BigInt(o)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)}),s.prototype.readBigInt64BE=Z(function(e){e=e>>>0,ee(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&oe(e,this.length-8);let o=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return (BigInt(o)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+i)}),s.prototype.readFloatLE=function(e,t){return e=e>>>0,t||B(e,4,this.length),n.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e=e>>>0,t||B(e,4,this.length),n.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||B(e,8,this.length),n.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||B(e,8,this.length),n.read(this,e,!1,52,8)};function N(r,e,t,i,o,l){if(!s.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<l)throw new RangeError('"value" argument is out of bounds');if(t+i>r.length)throw new RangeError("Index out of range")}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(e,t,i,o){if(e=+e,t=t>>>0,i=i>>>0,!o){let g=Math.pow(2,8*i)-1;N(this,e,t,i,g,0);}let l=1,p=0;for(this[t]=e&255;++p<i&&(l*=256);)this[t+p]=e/l&255;return t+i},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(e,t,i,o){if(e=+e,t=t>>>0,i=i>>>0,!o){let g=Math.pow(2,8*i)-1;N(this,e,t,i,g,0);}let l=i-1,p=1;for(this[t+l]=e&255;--l>=0&&(p*=256);)this[t+l]=e/p&255;return t+i},s.prototype.writeUint8=s.prototype.writeUInt8=function(e,t,i){return e=+e,t=t>>>0,i||N(this,e,t,1,255,0),this[t]=e&255,t+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(e,t,i){return e=+e,t=t>>>0,i||N(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(e,t,i){return e=+e,t=t>>>0,i||N(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(e,t,i){return e=+e,t=t>>>0,i||N(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(e,t,i){return e=+e,t=t>>>0,i||N(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function Ne(r,e,t,i,o){$e(e,i,o,r,t,7);let l=Number(e&BigInt(4294967295));r[t++]=l,l=l>>8,r[t++]=l,l=l>>8,r[t++]=l,l=l>>8,r[t++]=l;let p=Number(e>>BigInt(32)&BigInt(4294967295));return r[t++]=p,p=p>>8,r[t++]=p,p=p>>8,r[t++]=p,p=p>>8,r[t++]=p,t}function De(r,e,t,i,o){$e(e,i,o,r,t,7);let l=Number(e&BigInt(4294967295));r[t+7]=l,l=l>>8,r[t+6]=l,l=l>>8,r[t+5]=l,l=l>>8,r[t+4]=l;let p=Number(e>>BigInt(32)&BigInt(4294967295));return r[t+3]=p,p=p>>8,r[t+2]=p,p=p>>8,r[t+1]=p,p=p>>8,r[t]=p,t+8}s.prototype.writeBigUInt64LE=Z(function(e,t=0){return Ne(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeBigUInt64BE=Z(function(e,t=0){return De(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeIntLE=function(e,t,i,o){if(e=+e,t=t>>>0,!o){let A=Math.pow(2,8*i-1);N(this,e,t,i,A-1,-A);}let l=0,p=1,g=0;for(this[t]=e&255;++l<i&&(p*=256);)e<0&&g===0&&this[t+l-1]!==0&&(g=1),this[t+l]=(e/p>>0)-g&255;return t+i},s.prototype.writeIntBE=function(e,t,i,o){if(e=+e,t=t>>>0,!o){let A=Math.pow(2,8*i-1);N(this,e,t,i,A-1,-A);}let l=i-1,p=1,g=0;for(this[t+l]=e&255;--l>=0&&(p*=256);)e<0&&g===0&&this[t+l+1]!==0&&(g=1),this[t+l]=(e/p>>0)-g&255;return t+i},s.prototype.writeInt8=function(e,t,i){return e=+e,t=t>>>0,i||N(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},s.prototype.writeInt16LE=function(e,t,i){return e=+e,t=t>>>0,i||N(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,i){return e=+e,t=t>>>0,i||N(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},s.prototype.writeInt32LE=function(e,t,i){return e=+e,t=t>>>0,i||N(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},s.prototype.writeInt32BE=function(e,t,i){return e=+e,t=t>>>0,i||N(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},s.prototype.writeBigInt64LE=Z(function(e,t=0){return Ne(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),s.prototype.writeBigInt64BE=Z(function(e,t=0){return De(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Fe(r,e,t,i,o,l){if(t+i>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function He(r,e,t,i,o){return e=+e,t=t>>>0,o||Fe(r,e,t,4),n.write(r,e,t,i,23,4),t+4}s.prototype.writeFloatLE=function(e,t,i){return He(this,e,t,!0,i)},s.prototype.writeFloatBE=function(e,t,i){return He(this,e,t,!1,i)};function Ve(r,e,t,i,o){return e=+e,t=t>>>0,o||Fe(r,e,t,8),n.write(r,e,t,i,52,8),t+8}s.prototype.writeDoubleLE=function(e,t,i){return Ve(this,e,t,!0,i)},s.prototype.writeDoubleBE=function(e,t,i){return Ve(this,e,t,!1,i)},s.prototype.copy=function(e,t,i,o){if(!s.isBuffer(e))throw new TypeError("argument should be a Buffer");if(i||(i=0),!o&&o!==0&&(o=this.length),t>=e.length&&(t=e.length),t||(t=0),o>0&&o<i&&(o=i),o===i||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),e.length-t<o-i&&(o=e.length-t+i);let l=o-i;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,i,o):Uint8Array.prototype.set.call(e,this.subarray(i,o),t),l},s.prototype.fill=function(e,t,i,o){if(typeof e=="string"){if(typeof t=="string"?(o=t,t=0,i=this.length):typeof i=="string"&&(o=i,i=this.length),o!==void 0&&typeof o!="string")throw new TypeError("encoding must be a string");if(typeof o=="string"&&!s.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(e.length===1){let p=e.charCodeAt(0);(o==="utf8"&&p<128||o==="latin1")&&(e=p);}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<i)throw new RangeError("Out of range index");if(i<=t)return this;t=t>>>0,i=i===void 0?this.length:i>>>0,e||(e=0);let l;if(typeof e=="number")for(l=t;l<i;++l)this[l]=e;else {let p=s.isBuffer(e)?e:s.from(e,o),g=p.length;if(g===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(l=0;l<i-t;++l)this[l+t]=p[l%g];}return this};let Q={};function Ce(r,e,t){Q[r]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name;}get code(){return r}set code(o){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:o,writable:!0});}toString(){return `${this.name} [${r}]: ${this.message}`}};}Ce("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Ce("ERR_INVALID_ARG_TYPE",function(r,e){return `The "${r}" argument must be of type number. Received type ${typeof e}`},TypeError),Ce("ERR_OUT_OF_RANGE",function(r,e,t){let i=`The value of "${r}" is out of range.`,o=t;return Number.isInteger(t)&&Math.abs(t)>2**32?o=Ge(String(t)):typeof t=="bigint"&&(o=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(o=Ge(o)),o+="n"),i+=` It must be ${e}. Received ${o}`,i},RangeError);function Ge(r){let e="",t=r.length,i=r[0]==="-"?1:0;for(;t>=i+4;t-=3)e=`_${r.slice(t-3,t)}${e}`;return `${r.slice(0,t)}${e}`}function Rt(r,e,t){ee(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&oe(e,r.length-(t+1));}function $e(r,e,t,i,o,l){if(r>t||r<e){let p=typeof e=="bigint"?"n":"",g;throw e===0||e===BigInt(0)?g=`>= 0${p} and < 2${p} ** ${(l+1)*8}${p}`:g=`>= -(2${p} ** ${(l+1)*8-1}${p}) and < 2 ** ${(l+1)*8-1}${p}`,new Q.ERR_OUT_OF_RANGE("value",g,r)}Rt(i,o,l);}function ee(r,e){if(typeof r!="number")throw new Q.ERR_INVALID_ARG_TYPE(e,"number",r)}function oe(r,e,t){throw Math.floor(r)!==r?(ee(r,t),new Q.ERR_OUT_OF_RANGE("offset","an integer",r)):e<0?new Q.ERR_BUFFER_OUT_OF_BOUNDS:new Q.ERR_OUT_OF_RANGE("offset",`>= ${0} and <= ${e}`,r)}let Tt=/[^+/0-9A-Za-z-_]/g;function vt(r){if(r=r.split("=")[0],r=r.trim().replace(Tt,""),r.length<2)return "";for(;r.length%4!==0;)r=r+"=";return r}function Ie(r,e){e=e||1/0;let t,i=r.length,o=null,l=[];for(let p=0;p<i;++p){if(t=r.charCodeAt(p),t>55295&&t<57344){if(!o){if(t>56319){(e-=3)>-1&&l.push(239,191,189);continue}else if(p+1===i){(e-=3)>-1&&l.push(239,191,189);continue}o=t;continue}if(t<56320){(e-=3)>-1&&l.push(239,191,189),o=t;continue}t=(o-55296<<10|t-56320)+65536;}else o&&(e-=3)>-1&&l.push(239,191,189);if(o=null,t<128){if((e-=1)<0)break;l.push(t);}else if(t<2048){if((e-=2)<0)break;l.push(t>>6|192,t&63|128);}else if(t<65536){if((e-=3)<0)break;l.push(t>>12|224,t>>6&63|128,t&63|128);}else if(t<1114112){if((e-=4)<0)break;l.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128);}else throw new Error("Invalid code point")}return l}function At(r){let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function Ot(r,e){let t,i,o,l=[];for(let p=0;p<r.length&&!((e-=2)<0);++p)t=r.charCodeAt(p),i=t>>8,o=t%256,l.push(o),l.push(i);return l}function Ke(r){return c.toByteArray(vt(r))}function de(r,e,t,i){let o;for(o=0;o<i&&!(o+t>=e.length||o>=r.length);++o)e[o+t]=r[o];return o}function V(r,e){return r instanceof e||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===e.name}function Re(r){return r!==r}let Lt=function(){let r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){let i=t*16;for(let o=0;o<16;++o)e[i+o]=r[t]+r[o];}return e}();function Z(r){return typeof BigInt>"u"?Pt:r}function Pt(){throw new Error("BigInt not supported")}return q}var X=Zr();X.Buffer;X.SlowBuffer;X.INSPECT_MAX_BYTES;X.kMaxLength;var L=X.Buffer;X.INSPECT_MAX_BYTES;X.kMaxLength;var me=(C=>(C.AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",C.INVALID_CONFIGURATION="INVALID_CONFIGURATION",C.WALLET_CONNECTION_ERROR="WALLET_CONNECTION_ERROR",C.NOT_LOGGED_IN_ERROR="NOT_LOGGED_IN_ERROR",C.SILENT_LOGIN_ERROR="SILENT_LOGIN_ERROR",C.REFRESH_TOKEN_ERROR="REFRESH_TOKEN_ERROR",C.USER_REGISTRATION_ERROR="USER_REGISTRATION_ERROR",C.USER_NOT_REGISTERED_ERROR="USER_NOT_REGISTERED_ERROR",C.LOGOUT_ERROR="LOGOUT_ERROR",C.TRANSFER_ERROR="TRANSFER_ERROR",C.CREATE_ORDER_ERROR="CREATE_ORDER_ERROR",C.CANCEL_ORDER_ERROR="CANCEL_ORDER_ERROR",C.EXCHANGE_TRANSFER_ERROR="EXCHANGE_TRANSFER_ERROR",C.CREATE_TRADE_ERROR="CREATE_TRADE_ERROR",C.OPERATION_NOT_SUPPORTED_ERROR="OPERATION_NOT_SUPPORTED_ERROR",C.LINK_WALLET_ALREADY_LINKED_ERROR="LINK_WALLET_ALREADY_LINKED_ERROR",C.LINK_WALLET_MAX_WALLETS_LINKED_ERROR="LINK_WALLET_MAX_WALLETS_LINKED_ERROR",C.LINK_WALLET_VALIDATION_ERROR="LINK_WALLET_VALIDATION_ERROR",C.LINK_WALLET_DUPLICATE_NONCE_ERROR="LINK_WALLET_DUPLICATE_NONCE_ERROR",C.LINK_WALLET_GENERIC_ERROR="LINK_WALLET_GENERIC_ERROR",C.SERVICE_UNAVAILABLE_ERROR="SERVICE_UNAVAILABLE_ERROR",C.TRANSACTION_REJECTED="TRANSACTION_REJECTED",C))(me||{});function Pe(c){return typeof c=="object"&&c!==null&&"code"in c&&"message"in c}var Wr=c=>{if(Pe(c))return c;if(typeof c=="object"&&c!==null&&"response"in c){let{response:n}=c;if(n?.data&&Pe(n.data))return n.data}},G=class extends Error{type;constructor(n,a){super(n),this.type=a;}},z=async(c,n)=>{try{return await c()}catch(a){let u;if(a instanceof G&&a.type==="SERVICE_UNAVAILABLE_ERROR")throw new G(a.message,a.type);let d=Wr(a);throw d?u=d.message:u=a.message,new G(u,n)}};var Yr=(c,n,a)=>{let u=n.map(d=>!c[d]&&d).filter(d=>d).join(", ");if(u!==""){let d=`${u} cannot be null`;throw new G(d,"INVALID_CONFIGURATION")}},ae=class{authenticationDomain;passportDomain;oidcConfiguration;crossSdkBridgeEnabled;popupOverlayOptions;constructor({authenticationDomain:n,passportDomain:a,crossSdkBridgeEnabled:u,popupOverlayOptions:d,...h}){Yr(h,["clientId","redirectUri"]),this.oidcConfiguration=h,this.crossSdkBridgeEnabled=u||!1,this.popupOverlayOptions=d,this.authenticationDomain=n||"https://auth.immutable.com",this.passportDomain=a||"https://passport.immutable.com";}};var je=(n=>(n.ZKEVM="zkEvm",n))(je||{}),ge=(a=>(a.ZKEVM="zkevm",a.ARBITRUM_ONE="arbitrum_one",a))(ge||{}),Ue=c=>!!c.zkEvm,qe=(u=>(u.OptedIn="opted_in",u.Unsubscribed="unsubscribed",u.Subscribed="subscribed",u))(qe||{}),Be=(a=>(a.LOGGED_OUT="loggedOut",a.LOGGED_IN="loggedIn",a))(Be||{});var Xe="im_passport_embedded_login_prompt";var re="passport-overlay",le="passport-overlay-contents",Ee=`${re}-close`,ye=`${re}-try-again`,Qe=`
|
|
5
|
+
function Ae(c){throw new Error("Node.js process "+c+" is not supported by JSPM core outside of Node.js")}var W=[],re=!1,X,fe=-1;function $t(){!re||!X||(re=!1,X.length?W=X.concat(W):fe=-1,W.length&&Je());}function Je(){if(!re){var c=setTimeout($t,0);re=!0;for(var n=W.length;n;){for(X=W,W=[];++fe<n;)X&&X[fe].run();fe=-1,n=W.length;}X=null,re=!1,clearTimeout(c);}}function Kt(c){var n=new Array(arguments.length-1);if(arguments.length>1)for(var s=1;s<arguments.length;s++)n[s-1]=arguments[s];W.push(new qe(c,n)),W.length===1&&!re&&setTimeout(Je,0);}function qe(c,n){this.fun=c,this.array=n;}qe.prototype.run=function(){this.fun.apply(null,this.array);};var Wt="browser",Zt="x64",Yt="browser",zt={PATH:"/usr/bin",LANG:navigator.language+".UTF-8",PWD:"/",HOME:"/home",TMP:"/tmp"},Jt=["/usr/bin/node"],qt=[],Xt="v16.8.0",jt={},Qt=function(c,n){console.warn((n?n+": ":"")+c);},er=function(c){Ae("binding");},tr=function(c){return 0},rr=function(){return "/"},nr=function(c){},ir={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};function S(){}var or=S,sr=[];function ar(c){Ae("_linkedBinding");}var cr={},lr=!1,dr={};function ur(c){Ae("dlopen");}function pr(){return []}function hr(){return []}var fr=S,mr=S,ke=function(){return {}},gr=ke,Er=ke,yr=S,wr=S,_r=S,Cr={};function Rr(c,n){if(!c)throw new Error(n||"assertion error")}var Tr={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},Ir=S,vr=S;function Lr(){return !1}var Or=S,Pr=S,Ar=S,kr=S,Ur=S,br=void 0,xr=void 0,Br=void 0,Sr=S,Mr=2,Nr=1,Dr="/bin/usr/node",Fr=9229,Hr="node",Vr=[],Gr=S,Y={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};Y.now===void 0&&(Le=Date.now(),Y.timing&&Y.timing.navigationStart&&(Le=Y.timing.navigationStart),Y.now=()=>Date.now()-Le);var Le;function $r(){return Y.now()/1e3}var Oe=1e9;function Pe(c){var n=Math.floor((Date.now()-Y.now())*.001),s=Y.now()*.001,l=Math.floor(s)+n,u=Math.floor(s%1*1e9);return c&&(l=l-c[0],u=u-c[1],u<0&&(l--,u+=Oe)),[l,u]}Pe.bigint=function(c){var n=Pe(c);return typeof BigInt>"u"?n[0]*Oe+n[1]:BigInt(n[0]*Oe)+BigInt(n[1])};var Kr=10,Wr={},Zr=0;function z(){return O}var Yr=z,zr=z,Jr=z,qr=z,Xr=z,jr=S,Qr=z,en=z;function tn(c){return []}var O={version:Xt,versions:jt,arch:Zt,platform:Yt,release:ir,_rawDebug:or,moduleLoadList:sr,binding:er,_linkedBinding:ar,_events:Wr,_eventsCount:Zr,_maxListeners:Kr,on:z,addListener:Yr,once:zr,off:Jr,removeListener:qr,removeAllListeners:Xr,emit:jr,prependListener:Qr,prependOnceListener:en,listeners:tn,domain:cr,_exiting:lr,config:dr,dlopen:ur,uptime:$r,_getActiveRequests:pr,_getActiveHandles:hr,reallyExit:fr,_kill:mr,cpuUsage:ke,resourceUsage:gr,memoryUsage:Er,kill:yr,exit:wr,openStdin:_r,allowedNodeEnvironmentFlags:Cr,assert:Rr,features:Tr,_fatalExceptions:Ir,setUncaughtExceptionCaptureCallback:vr,hasUncaughtExceptionCaptureCallback:Lr,emitWarning:Qt,nextTick:Kt,_tickCallback:Or,_debugProcess:Pr,_debugEnd:Ar,_startProfilerIdleNotifier:kr,_stopProfilerIdleNotifier:Ur,stdout:br,stdin:Br,stderr:xr,abort:Sr,umask:tr,chdir:nr,cwd:rr,env:zt,title:Wt,argv:Jt,execArgv:qt,pid:Mr,ppid:Nr,execPath:Dr,debugPort:Fr,hrtime:Pe,argv0:Hr,_preload_modules:Vr,setSourceMapsEnabled:Gr};var ae={},Xe=!1;function rn(){if(Xe)return ae;Xe=!0,ae.byteLength=f,ae.toByteArray=_,ae.fromByteArray=D;for(var c=[],n=[],s=typeof Uint8Array<"u"?Uint8Array:Array,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=0,h=l.length;u<h;++u)c[u]=l[u],n[l.charCodeAt(u)]=u;n[45]=62,n[95]=63;function o(m){var y=m.length;if(y%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var C=m.indexOf("=");C===-1&&(C=y);var v=C===y?0:4-C%4;return [C,v]}function f(m){var y=o(m),C=y[0],v=y[1];return (C+v)*3/4-v}function E(m,y,C){return (y+C)*3/4-C}function _(m){var y,C=o(m),v=C[0],x=C[1],A=new s(E(m,v,x)),B=0,M=x>0?v-4:v,N;for(N=0;N<M;N+=4)y=n[m.charCodeAt(N)]<<18|n[m.charCodeAt(N+1)]<<12|n[m.charCodeAt(N+2)]<<6|n[m.charCodeAt(N+3)],A[B++]=y>>16&255,A[B++]=y>>8&255,A[B++]=y&255;return x===2&&(y=n[m.charCodeAt(N)]<<2|n[m.charCodeAt(N+1)]>>4,A[B++]=y&255),x===1&&(y=n[m.charCodeAt(N)]<<10|n[m.charCodeAt(N+1)]<<4|n[m.charCodeAt(N+2)]>>2,A[B++]=y>>8&255,A[B++]=y&255),A}function g(m){return c[m>>18&63]+c[m>>12&63]+c[m>>6&63]+c[m&63]}function R(m,y,C){for(var v,x=[],A=y;A<C;A+=3)v=(m[A]<<16&16711680)+(m[A+1]<<8&65280)+(m[A+2]&255),x.push(g(v));return x.join("")}function D(m){for(var y,C=m.length,v=C%3,x=[],A=16383,B=0,M=C-v;B<M;B+=A)x.push(R(m,B,B+A>M?M:B+A));return v===1?(y=m[C-1],x.push(c[y>>2]+c[y<<4&63]+"==")):v===2&&(y=(m[C-2]<<8)+m[C-1],x.push(c[y>>10]+c[y>>4&63]+c[y<<2&63]+"=")),x.join("")}return ae}var me={},je=!1;function nn(){if(je)return me;je=!0;return me.read=function(c,n,s,l,u){var h,o,f=u*8-l-1,E=(1<<f)-1,_=E>>1,g=-7,R=s?u-1:0,D=s?-1:1,m=c[n+R];for(R+=D,h=m&(1<<-g)-1,m>>=-g,g+=f;g>0;h=h*256+c[n+R],R+=D,g-=8);for(o=h&(1<<-g)-1,h>>=-g,g+=l;g>0;o=o*256+c[n+R],R+=D,g-=8);if(h===0)h=1-_;else {if(h===E)return o?NaN:(m?-1:1)*(1/0);o=o+Math.pow(2,l),h=h-_;}return (m?-1:1)*o*Math.pow(2,h-l)},me.write=function(c,n,s,l,u,h){var o,f,E,_=h*8-u-1,g=(1<<_)-1,R=g>>1,D=u===23?Math.pow(2,-24)-Math.pow(2,-77):0,m=l?0:h-1,y=l?1:-1,C=n<0||n===0&&1/n<0?1:0;for(n=Math.abs(n),isNaN(n)||n===1/0?(f=isNaN(n)?1:0,o=g):(o=Math.floor(Math.log(n)/Math.LN2),n*(E=Math.pow(2,-o))<1&&(o--,E*=2),o+R>=1?n+=D/E:n+=D*Math.pow(2,1-R),n*E>=2&&(o++,E/=2),o+R>=g?(f=0,o=g):o+R>=1?(f=(n*E-1)*Math.pow(2,u),o=o+R):(f=n*Math.pow(2,R-1)*Math.pow(2,u),o=0));u>=8;c[s+m]=f&255,m+=y,f/=256,u-=8);for(o=o<<u|f,_+=u;_>0;c[s+m]=o&255,m+=y,o/=256,_-=8);c[s+m-y]|=C*128;},me}var j={},Qe=!1;function on(){if(Qe)return j;Qe=!0;let c=rn(),n=nn(),s=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;j.Buffer=o,j.SlowBuffer=x,j.INSPECT_MAX_BYTES=50;let l=2147483647;j.kMaxLength=l,o.TYPED_ARRAY_SUPPORT=u(),!o.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function u(){try{let r=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(r,e),r.foo()===42}catch{return !1}}Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}});function h(r){if(r>l)throw new RangeError('The value "'+r+'" is invalid for option "size"');let e=new Uint8Array(r);return Object.setPrototypeOf(e,o.prototype),e}function o(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return g(r)}return f(r,e,t)}o.poolSize=8192;function f(r,e,t){if(typeof r=="string")return R(r,e);if(ArrayBuffer.isView(r))return m(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(G(r,ArrayBuffer)||r&&G(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(G(r,SharedArrayBuffer)||r&&G(r.buffer,SharedArrayBuffer)))return y(r,e,t);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let i=r.valueOf&&r.valueOf();if(i!=null&&i!==r)return o.from(i,e,t);let a=C(r);if(a)return a;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return o.from(r[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}o.from=function(r,e,t){return f(r,e,t)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array);function E(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function _(r,e,t){return E(r),r<=0?h(r):e!==void 0?typeof t=="string"?h(r).fill(e,t):h(r).fill(e):h(r)}o.alloc=function(r,e,t){return _(r,e,t)};function g(r){return E(r),h(r<0?0:v(r)|0)}o.allocUnsafe=function(r){return g(r)},o.allocUnsafeSlow=function(r){return g(r)};function R(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!o.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=A(r,e)|0,i=h(t),a=i.write(r,e);return a!==t&&(i=i.slice(0,a)),i}function D(r){let e=r.length<0?0:v(r.length)|0,t=h(e);for(let i=0;i<e;i+=1)t[i]=r[i]&255;return t}function m(r){if(G(r,Uint8Array)){let e=new Uint8Array(r);return y(e.buffer,e.byteOffset,e.byteLength)}return D(r)}function y(r,e,t){if(e<0||r.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<e+(t||0))throw new RangeError('"length" is outside of buffer bounds');let i;return e===void 0&&t===void 0?i=new Uint8Array(r):t===void 0?i=new Uint8Array(r,e):i=new Uint8Array(r,e,t),Object.setPrototypeOf(i,o.prototype),i}function C(r){if(o.isBuffer(r)){let e=v(r.length)|0,t=h(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r.length!="number"||ve(r.length)?h(0):D(r);if(r.type==="Buffer"&&Array.isArray(r.data))return D(r.data)}function v(r){if(r>=l)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+l.toString(16)+" bytes");return r|0}function x(r){return +r!=r&&(r=0),o.alloc(+r)}o.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==o.prototype},o.compare=function(e,t){if(G(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),G(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(e)||!o.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let i=e.length,a=t.length;for(let d=0,p=Math.min(i,a);d<p;++d)if(e[d]!==t[d]){i=e[d],a=t[d];break}return i<a?-1:a<i?1:0},o.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return !0;default:return !1}},o.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return o.alloc(0);let i;if(t===void 0)for(t=0,i=0;i<e.length;++i)t+=e[i].length;let a=o.allocUnsafe(t),d=0;for(i=0;i<e.length;++i){let p=e[i];if(G(p,Uint8Array))d+p.length>a.length?(o.isBuffer(p)||(p=o.from(p)),p.copy(a,d)):Uint8Array.prototype.set.call(a,p,d);else if(o.isBuffer(p))p.copy(a,d);else throw new TypeError('"list" argument must be an Array of Buffers');d+=p.length;}return a};function A(r,e){if(o.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||G(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);let t=r.length,i=arguments.length>2&&arguments[2]===!0;if(!i&&t===0)return 0;let a=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return Ie(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return ze(r).length;default:if(a)return i?-1:Ie(r).length;e=(""+e).toLowerCase(),a=!0;}}o.byteLength=A;function B(r,e,t){let i=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return "";for(r||(r="utf8");;)switch(r){case"hex":return Bt(this,e,t);case"utf8":case"utf-8":return Fe(this,e,t);case"ascii":return bt(this,e,t);case"latin1":case"binary":return xt(this,e,t);case"base64":return kt(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return St(this,e,t);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),i=!0;}}o.prototype._isBuffer=!0;function M(r,e,t){let i=r[e];r[e]=r[t],r[t]=i;}o.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)M(this,t,t+1);return this},o.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)M(this,t,t+3),M(this,t+1,t+2);return this},o.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)M(this,t,t+7),M(this,t+1,t+6),M(this,t+2,t+5),M(this,t+3,t+4);return this},o.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?Fe(this,0,e):B.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(e){if(!o.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:o.compare(this,e)===0},o.prototype.inspect=function(){let e="",t=j.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},s&&(o.prototype[s]=o.prototype.inspect),o.prototype.compare=function(e,t,i,a,d){if(G(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),!o.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),i===void 0&&(i=e?e.length:0),a===void 0&&(a=0),d===void 0&&(d=this.length),t<0||i>e.length||a<0||d>this.length)throw new RangeError("out of range index");if(a>=d&&t>=i)return 0;if(a>=d)return -1;if(t>=i)return 1;if(t>>>=0,i>>>=0,a>>>=0,d>>>=0,this===e)return 0;let p=d-a,w=i-t,k=Math.min(p,w),L=this.slice(a,d),U=e.slice(t,i);for(let T=0;T<k;++T)if(L[T]!==U[T]){p=L[T],w=U[T];break}return p<w?-1:w<p?1:0};function N(r,e,t,i,a){if(r.length===0)return -1;if(typeof t=="string"?(i=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,ve(t)&&(t=a?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(a)return -1;t=r.length-1;}else if(t<0)if(a)t=0;else return -1;if(typeof e=="string"&&(e=o.from(e,i)),o.isBuffer(e))return e.length===0?-1:I(r,e,t,i,a);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?a?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):I(r,[e],t,i,a);throw new TypeError("val must be string, number or Buffer")}function I(r,e,t,i,a){let d=1,p=r.length,w=e.length;if(i!==void 0&&(i=String(i).toLowerCase(),i==="ucs2"||i==="ucs-2"||i==="utf16le"||i==="utf-16le")){if(r.length<2||e.length<2)return -1;d=2,p/=2,w/=2,t/=2;}function k(U,T){return d===1?U[T]:U.readUInt16BE(T*d)}let L;if(a){let U=-1;for(L=t;L<p;L++)if(k(r,L)===k(e,U===-1?0:L-U)){if(U===-1&&(U=L),L-U+1===w)return U*d}else U!==-1&&(L-=L-U),U=-1;}else for(t+w>p&&(t=p-w),L=t;L>=0;L--){let U=!0;for(let T=0;T<w;T++)if(k(r,L+T)!==k(e,T)){U=!1;break}if(U)return L}return -1}o.prototype.includes=function(e,t,i){return this.indexOf(e,t,i)!==-1},o.prototype.indexOf=function(e,t,i){return N(this,e,t,i,!0)},o.prototype.lastIndexOf=function(e,t,i){return N(this,e,t,i,!1)};function vt(r,e,t,i){t=Number(t)||0;let a=r.length-t;i?(i=Number(i),i>a&&(i=a)):i=a;let d=e.length;i>d/2&&(i=d/2);let p;for(p=0;p<i;++p){let w=parseInt(e.substr(p*2,2),16);if(ve(w))return p;r[t+p]=w;}return p}function Lt(r,e,t,i){return he(Ie(e,r.length-t),r,t,i)}function Ot(r,e,t,i){return he(Ft(e),r,t,i)}function Pt(r,e,t,i){return he(ze(e),r,t,i)}function At(r,e,t,i){return he(Ht(e,r.length-t),r,t,i)}o.prototype.write=function(e,t,i,a){if(t===void 0)a="utf8",i=this.length,t=0;else if(i===void 0&&typeof t=="string")a=t,i=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(i)?(i=i>>>0,a===void 0&&(a="utf8")):(a=i,i=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let d=this.length-t;if((i===void 0||i>d)&&(i=d),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");a||(a="utf8");let p=!1;for(;;)switch(a){case"hex":return vt(this,e,t,i);case"utf8":case"utf-8":return Lt(this,e,t,i);case"ascii":case"latin1":case"binary":return Ot(this,e,t,i);case"base64":return Pt(this,e,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return At(this,e,t,i);default:if(p)throw new TypeError("Unknown encoding: "+a);a=(""+a).toLowerCase(),p=!0;}},o.prototype.toJSON=function(){return {type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function kt(r,e,t){return e===0&&t===r.length?c.fromByteArray(r):c.fromByteArray(r.slice(e,t))}function Fe(r,e,t){t=Math.min(r.length,t);let i=[],a=e;for(;a<t;){let d=r[a],p=null,w=d>239?4:d>223?3:d>191?2:1;if(a+w<=t){let k,L,U,T;switch(w){case 1:d<128&&(p=d);break;case 2:k=r[a+1],(k&192)===128&&(T=(d&31)<<6|k&63,T>127&&(p=T));break;case 3:k=r[a+1],L=r[a+2],(k&192)===128&&(L&192)===128&&(T=(d&15)<<12|(k&63)<<6|L&63,T>2047&&(T<55296||T>57343)&&(p=T));break;case 4:k=r[a+1],L=r[a+2],U=r[a+3],(k&192)===128&&(L&192)===128&&(U&192)===128&&(T=(d&15)<<18|(k&63)<<12|(L&63)<<6|U&63,T>65535&&T<1114112&&(p=T));}}p===null?(p=65533,w=1):p>65535&&(p-=65536,i.push(p>>>10&1023|55296),p=56320|p&1023),i.push(p),a+=w;}return Ut(i)}let He=4096;function Ut(r){let e=r.length;if(e<=He)return String.fromCharCode.apply(String,r);let t="",i=0;for(;i<e;)t+=String.fromCharCode.apply(String,r.slice(i,i+=He));return t}function bt(r,e,t){let i="";t=Math.min(r.length,t);for(let a=e;a<t;++a)i+=String.fromCharCode(r[a]&127);return i}function xt(r,e,t){let i="";t=Math.min(r.length,t);for(let a=e;a<t;++a)i+=String.fromCharCode(r[a]);return i}function Bt(r,e,t){let i=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>i)&&(t=i);let a="";for(let d=e;d<t;++d)a+=Vt[r[d]];return a}function St(r,e,t){let i=r.slice(e,t),a="";for(let d=0;d<i.length-1;d+=2)a+=String.fromCharCode(i[d]+i[d+1]*256);return a}o.prototype.slice=function(e,t){let i=this.length;e=~~e,t=t===void 0?i:~~t,e<0?(e+=i,e<0&&(e=0)):e>i&&(e=i),t<0?(t+=i,t<0&&(t=0)):t>i&&(t=i),t<e&&(t=e);let a=this.subarray(e,t);return Object.setPrototypeOf(a,o.prototype),a};function b(r,e,t){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to access beyond buffer length")}o.prototype.readUintLE=o.prototype.readUIntLE=function(e,t,i){e=e>>>0,t=t>>>0,i||b(e,t,this.length);let a=this[e],d=1,p=0;for(;++p<t&&(d*=256);)a+=this[e+p]*d;return a},o.prototype.readUintBE=o.prototype.readUIntBE=function(e,t,i){e=e>>>0,t=t>>>0,i||b(e,t,this.length);let a=this[e+--t],d=1;for(;t>0&&(d*=256);)a+=this[e+--t]*d;return a},o.prototype.readUint8=o.prototype.readUInt8=function(e,t){return e=e>>>0,t||b(e,1,this.length),this[e]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||b(e,2,this.length),this[e]|this[e+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||b(e,2,this.length),this[e]<<8|this[e+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||b(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||b(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},o.prototype.readBigUInt64LE=Z(function(e){e=e>>>0,te(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&se(e,this.length-8);let a=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,d=this[++e]+this[++e]*2**8+this[++e]*2**16+i*2**24;return BigInt(a)+(BigInt(d)<<BigInt(32))}),o.prototype.readBigUInt64BE=Z(function(e){e=e>>>0,te(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&se(e,this.length-8);let a=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],d=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+i;return (BigInt(a)<<BigInt(32))+BigInt(d)}),o.prototype.readIntLE=function(e,t,i){e=e>>>0,t=t>>>0,i||b(e,t,this.length);let a=this[e],d=1,p=0;for(;++p<t&&(d*=256);)a+=this[e+p]*d;return d*=128,a>=d&&(a-=Math.pow(2,8*t)),a},o.prototype.readIntBE=function(e,t,i){e=e>>>0,t=t>>>0,i||b(e,t,this.length);let a=t,d=1,p=this[e+--a];for(;a>0&&(d*=256);)p+=this[e+--a]*d;return d*=128,p>=d&&(p-=Math.pow(2,8*t)),p},o.prototype.readInt8=function(e,t){return e=e>>>0,t||b(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},o.prototype.readInt16LE=function(e,t){e=e>>>0,t||b(e,2,this.length);let i=this[e]|this[e+1]<<8;return i&32768?i|4294901760:i},o.prototype.readInt16BE=function(e,t){e=e>>>0,t||b(e,2,this.length);let i=this[e+1]|this[e]<<8;return i&32768?i|4294901760:i},o.prototype.readInt32LE=function(e,t){return e=e>>>0,t||b(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},o.prototype.readInt32BE=function(e,t){return e=e>>>0,t||b(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},o.prototype.readBigInt64LE=Z(function(e){e=e>>>0,te(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&se(e,this.length-8);let a=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(i<<24);return (BigInt(a)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)}),o.prototype.readBigInt64BE=Z(function(e){e=e>>>0,te(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&se(e,this.length-8);let a=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return (BigInt(a)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+i)}),o.prototype.readFloatLE=function(e,t){return e=e>>>0,t||b(e,4,this.length),n.read(this,e,!0,23,4)},o.prototype.readFloatBE=function(e,t){return e=e>>>0,t||b(e,4,this.length),n.read(this,e,!1,23,4)},o.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||b(e,8,this.length),n.read(this,e,!0,52,8)},o.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||b(e,8,this.length),n.read(this,e,!1,52,8)};function F(r,e,t,i,a,d){if(!o.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>a||e<d)throw new RangeError('"value" argument is out of bounds');if(t+i>r.length)throw new RangeError("Index out of range")}o.prototype.writeUintLE=o.prototype.writeUIntLE=function(e,t,i,a){if(e=+e,t=t>>>0,i=i>>>0,!a){let w=Math.pow(2,8*i)-1;F(this,e,t,i,w,0);}let d=1,p=0;for(this[t]=e&255;++p<i&&(d*=256);)this[t+p]=e/d&255;return t+i},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(e,t,i,a){if(e=+e,t=t>>>0,i=i>>>0,!a){let w=Math.pow(2,8*i)-1;F(this,e,t,i,w,0);}let d=i-1,p=1;for(this[t+d]=e&255;--d>=0&&(p*=256);)this[t+d]=e/p&255;return t+i},o.prototype.writeUint8=o.prototype.writeUInt8=function(e,t,i){return e=+e,t=t>>>0,i||F(this,e,t,1,255,0),this[t]=e&255,t+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(e,t,i){return e=+e,t=t>>>0,i||F(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(e,t,i){return e=+e,t=t>>>0,i||F(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(e,t,i){return e=+e,t=t>>>0,i||F(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(e,t,i){return e=+e,t=t>>>0,i||F(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function Ve(r,e,t,i,a){Ye(e,i,a,r,t,7);let d=Number(e&BigInt(4294967295));r[t++]=d,d=d>>8,r[t++]=d,d=d>>8,r[t++]=d,d=d>>8,r[t++]=d;let p=Number(e>>BigInt(32)&BigInt(4294967295));return r[t++]=p,p=p>>8,r[t++]=p,p=p>>8,r[t++]=p,p=p>>8,r[t++]=p,t}function Ge(r,e,t,i,a){Ye(e,i,a,r,t,7);let d=Number(e&BigInt(4294967295));r[t+7]=d,d=d>>8,r[t+6]=d,d=d>>8,r[t+5]=d,d=d>>8,r[t+4]=d;let p=Number(e>>BigInt(32)&BigInt(4294967295));return r[t+3]=p,p=p>>8,r[t+2]=p,p=p>>8,r[t+1]=p,p=p>>8,r[t]=p,t+8}o.prototype.writeBigUInt64LE=Z(function(e,t=0){return Ve(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeBigUInt64BE=Z(function(e,t=0){return Ge(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeIntLE=function(e,t,i,a){if(e=+e,t=t>>>0,!a){let k=Math.pow(2,8*i-1);F(this,e,t,i,k-1,-k);}let d=0,p=1,w=0;for(this[t]=e&255;++d<i&&(p*=256);)e<0&&w===0&&this[t+d-1]!==0&&(w=1),this[t+d]=(e/p>>0)-w&255;return t+i},o.prototype.writeIntBE=function(e,t,i,a){if(e=+e,t=t>>>0,!a){let k=Math.pow(2,8*i-1);F(this,e,t,i,k-1,-k);}let d=i-1,p=1,w=0;for(this[t+d]=e&255;--d>=0&&(p*=256);)e<0&&w===0&&this[t+d+1]!==0&&(w=1),this[t+d]=(e/p>>0)-w&255;return t+i},o.prototype.writeInt8=function(e,t,i){return e=+e,t=t>>>0,i||F(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},o.prototype.writeInt16LE=function(e,t,i){return e=+e,t=t>>>0,i||F(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},o.prototype.writeInt16BE=function(e,t,i){return e=+e,t=t>>>0,i||F(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},o.prototype.writeInt32LE=function(e,t,i){return e=+e,t=t>>>0,i||F(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},o.prototype.writeInt32BE=function(e,t,i){return e=+e,t=t>>>0,i||F(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},o.prototype.writeBigInt64LE=Z(function(e,t=0){return Ve(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeBigInt64BE=Z(function(e,t=0){return Ge(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function $e(r,e,t,i,a,d){if(t+i>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function Ke(r,e,t,i,a){return e=+e,t=t>>>0,a||$e(r,e,t,4),n.write(r,e,t,i,23,4),t+4}o.prototype.writeFloatLE=function(e,t,i){return Ke(this,e,t,!0,i)},o.prototype.writeFloatBE=function(e,t,i){return Ke(this,e,t,!1,i)};function We(r,e,t,i,a){return e=+e,t=t>>>0,a||$e(r,e,t,8),n.write(r,e,t,i,52,8),t+8}o.prototype.writeDoubleLE=function(e,t,i){return We(this,e,t,!0,i)},o.prototype.writeDoubleBE=function(e,t,i){return We(this,e,t,!1,i)},o.prototype.copy=function(e,t,i,a){if(!o.isBuffer(e))throw new TypeError("argument should be a Buffer");if(i||(i=0),!a&&a!==0&&(a=this.length),t>=e.length&&(t=e.length),t||(t=0),a>0&&a<i&&(a=i),a===i||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("Index out of range");if(a<0)throw new RangeError("sourceEnd out of bounds");a>this.length&&(a=this.length),e.length-t<a-i&&(a=e.length-t+i);let d=a-i;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,i,a):Uint8Array.prototype.set.call(e,this.subarray(i,a),t),d},o.prototype.fill=function(e,t,i,a){if(typeof e=="string"){if(typeof t=="string"?(a=t,t=0,i=this.length):typeof i=="string"&&(a=i,i=this.length),a!==void 0&&typeof a!="string")throw new TypeError("encoding must be a string");if(typeof a=="string"&&!o.isEncoding(a))throw new TypeError("Unknown encoding: "+a);if(e.length===1){let p=e.charCodeAt(0);(a==="utf8"&&p<128||a==="latin1")&&(e=p);}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<i)throw new RangeError("Out of range index");if(i<=t)return this;t=t>>>0,i=i===void 0?this.length:i>>>0,e||(e=0);let d;if(typeof e=="number")for(d=t;d<i;++d)this[d]=e;else {let p=o.isBuffer(e)?e:o.from(e,a),w=p.length;if(w===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(d=0;d<i-t;++d)this[d+t]=p[d%w];}return this};let ee={};function Te(r,e,t){ee[r]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name;}get code(){return r}set code(a){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:a,writable:!0});}toString(){return `${this.name} [${r}]: ${this.message}`}};}Te("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Te("ERR_INVALID_ARG_TYPE",function(r,e){return `The "${r}" argument must be of type number. Received type ${typeof e}`},TypeError),Te("ERR_OUT_OF_RANGE",function(r,e,t){let i=`The value of "${r}" is out of range.`,a=t;return Number.isInteger(t)&&Math.abs(t)>2**32?a=Ze(String(t)):typeof t=="bigint"&&(a=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(a=Ze(a)),a+="n"),i+=` It must be ${e}. Received ${a}`,i},RangeError);function Ze(r){let e="",t=r.length,i=r[0]==="-"?1:0;for(;t>=i+4;t-=3)e=`_${r.slice(t-3,t)}${e}`;return `${r.slice(0,t)}${e}`}function Mt(r,e,t){te(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&se(e,r.length-(t+1));}function Ye(r,e,t,i,a,d){if(r>t||r<e){let p=typeof e=="bigint"?"n":"",w;throw e===0||e===BigInt(0)?w=`>= 0${p} and < 2${p} ** ${(d+1)*8}${p}`:w=`>= -(2${p} ** ${(d+1)*8-1}${p}) and < 2 ** ${(d+1)*8-1}${p}`,new ee.ERR_OUT_OF_RANGE("value",w,r)}Mt(i,a,d);}function te(r,e){if(typeof r!="number")throw new ee.ERR_INVALID_ARG_TYPE(e,"number",r)}function se(r,e,t){throw Math.floor(r)!==r?(te(r,t),new ee.ERR_OUT_OF_RANGE("offset","an integer",r)):e<0?new ee.ERR_BUFFER_OUT_OF_BOUNDS:new ee.ERR_OUT_OF_RANGE("offset",`>= ${0} and <= ${e}`,r)}let Nt=/[^+/0-9A-Za-z-_]/g;function Dt(r){if(r=r.split("=")[0],r=r.trim().replace(Nt,""),r.length<2)return "";for(;r.length%4!==0;)r=r+"=";return r}function Ie(r,e){e=e||1/0;let t,i=r.length,a=null,d=[];for(let p=0;p<i;++p){if(t=r.charCodeAt(p),t>55295&&t<57344){if(!a){if(t>56319){(e-=3)>-1&&d.push(239,191,189);continue}else if(p+1===i){(e-=3)>-1&&d.push(239,191,189);continue}a=t;continue}if(t<56320){(e-=3)>-1&&d.push(239,191,189),a=t;continue}t=(a-55296<<10|t-56320)+65536;}else a&&(e-=3)>-1&&d.push(239,191,189);if(a=null,t<128){if((e-=1)<0)break;d.push(t);}else if(t<2048){if((e-=2)<0)break;d.push(t>>6|192,t&63|128);}else if(t<65536){if((e-=3)<0)break;d.push(t>>12|224,t>>6&63|128,t&63|128);}else if(t<1114112){if((e-=4)<0)break;d.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128);}else throw new Error("Invalid code point")}return d}function Ft(r){let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function Ht(r,e){let t,i,a,d=[];for(let p=0;p<r.length&&!((e-=2)<0);++p)t=r.charCodeAt(p),i=t>>8,a=t%256,d.push(a),d.push(i);return d}function ze(r){return c.toByteArray(Dt(r))}function he(r,e,t,i){let a;for(a=0;a<i&&!(a+t>=e.length||a>=r.length);++a)e[a+t]=r[a];return a}function G(r,e){return r instanceof e||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===e.name}function ve(r){return r!==r}let Vt=function(){let r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){let i=t*16;for(let a=0;a<16;++a)e[i+a]=r[t]+r[a];}return e}();function Z(r){return typeof BigInt>"u"?Gt:r}function Gt(){throw new Error("BigInt not supported")}return j}var Q=on();Q.Buffer;Q.SlowBuffer;Q.INSPECT_MAX_BYTES;Q.kMaxLength;var P=Q.Buffer;Q.INSPECT_MAX_BYTES;Q.kMaxLength;var ge=(I=>(I.AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",I.INVALID_CONFIGURATION="INVALID_CONFIGURATION",I.WALLET_CONNECTION_ERROR="WALLET_CONNECTION_ERROR",I.NOT_LOGGED_IN_ERROR="NOT_LOGGED_IN_ERROR",I.SILENT_LOGIN_ERROR="SILENT_LOGIN_ERROR",I.REFRESH_TOKEN_ERROR="REFRESH_TOKEN_ERROR",I.USER_REGISTRATION_ERROR="USER_REGISTRATION_ERROR",I.USER_NOT_REGISTERED_ERROR="USER_NOT_REGISTERED_ERROR",I.LOGOUT_ERROR="LOGOUT_ERROR",I.TRANSFER_ERROR="TRANSFER_ERROR",I.CREATE_ORDER_ERROR="CREATE_ORDER_ERROR",I.CANCEL_ORDER_ERROR="CANCEL_ORDER_ERROR",I.EXCHANGE_TRANSFER_ERROR="EXCHANGE_TRANSFER_ERROR",I.CREATE_TRADE_ERROR="CREATE_TRADE_ERROR",I.OPERATION_NOT_SUPPORTED_ERROR="OPERATION_NOT_SUPPORTED_ERROR",I.LINK_WALLET_ALREADY_LINKED_ERROR="LINK_WALLET_ALREADY_LINKED_ERROR",I.LINK_WALLET_MAX_WALLETS_LINKED_ERROR="LINK_WALLET_MAX_WALLETS_LINKED_ERROR",I.LINK_WALLET_VALIDATION_ERROR="LINK_WALLET_VALIDATION_ERROR",I.LINK_WALLET_DUPLICATE_NONCE_ERROR="LINK_WALLET_DUPLICATE_NONCE_ERROR",I.LINK_WALLET_GENERIC_ERROR="LINK_WALLET_GENERIC_ERROR",I.SERVICE_UNAVAILABLE_ERROR="SERVICE_UNAVAILABLE_ERROR",I.TRANSACTION_REJECTED="TRANSACTION_REJECTED",I))(ge||{});function Ue(c){return typeof c=="object"&&c!==null&&"code"in c&&"message"in c}var sn=c=>{if(Ue(c))return c;if(typeof c=="object"&&c!==null&&"response"in c){let{response:n}=c;if(n?.data&&Ue(n.data))return n.data}},$=class extends Error{type;constructor(n,s){super(n),this.type=s;}},J=async(c,n)=>{try{return await c()}catch(s){let l;if(s instanceof $&&s.type==="SERVICE_UNAVAILABLE_ERROR")throw new $(s.message,s.type);let u=sn(s);throw u?l=u.message:l=s.message,new $(l,n)}};var an=(c,n,s)=>{let l=n.map(u=>!c[u]&&u).filter(u=>u).join(", ");if(l!==""){let u=`${l} cannot be null`;throw new $(u,"INVALID_CONFIGURATION")}},ce=class{authenticationDomain;passportDomain;oidcConfiguration;crossSdkBridgeEnabled;popupOverlayOptions;constructor({authenticationDomain:n,passportDomain:s,crossSdkBridgeEnabled:l,popupOverlayOptions:u,...h}){an(h,["clientId","redirectUri"]),this.oidcConfiguration=h,this.crossSdkBridgeEnabled=l||!1,this.popupOverlayOptions=u,this.authenticationDomain=n||"https://auth.immutable.com",this.passportDomain=s||"https://passport.immutable.com";}};var et=(n=>(n.ZKEVM="zkEvm",n))(et||{}),Ee=(s=>(s.ZKEVM="zkevm",s.ARBITRUM_ONE="arbitrum_one",s))(Ee||{}),be=c=>!!c.zkEvm,tt=(l=>(l.OptedIn="opted_in",l.Unsubscribed="unsubscribed",l.Subscribed="subscribed",l))(tt||{}),xe=(u=>(u.LOGGED_OUT="loggedOut",u.LOGGED_IN="loggedIn",u.TOKEN_REFRESHED="tokenRefreshed",u.USER_REMOVED="userRemoved",u))(xe||{});var rt="im_passport_embedded_login_prompt";var ne="passport-overlay",q="passport-overlay-contents",ye=`${ne}-close`,we=`${ne}-try-again`,nt=`
|
|
6
6
|
<svg
|
|
7
7
|
viewBox="0 0 20 20"
|
|
8
8
|
fill="none"
|
|
@@ -14,7 +14,7 @@ function Oe(c){throw new Error("Node.js process "+c+" is not supported by JSPM c
|
|
|
14
14
|
fill="#F3F3F3"
|
|
15
15
|
/>
|
|
16
16
|
</svg>
|
|
17
|
-
`,
|
|
17
|
+
`,it=`
|
|
18
18
|
<svg
|
|
19
19
|
viewBox="0 0 17 16"
|
|
20
20
|
fill="none"
|
|
@@ -28,7 +28,7 @@ function Oe(c){throw new Error("Node.js process "+c+" is not supported by JSPM c
|
|
|
28
28
|
fill="#E01A3D"
|
|
29
29
|
/>
|
|
30
30
|
</svg>
|
|
31
|
-
`,
|
|
31
|
+
`,Be=`
|
|
32
32
|
<svg
|
|
33
33
|
style="
|
|
34
34
|
max-width: 123px !important;
|
|
@@ -211,9 +211,9 @@ function Oe(c){throw new Error("Node.js process "+c+" is not supported by JSPM c
|
|
|
211
211
|
</clipPath>
|
|
212
212
|
</defs>
|
|
213
213
|
</svg>
|
|
214
|
-
`;var
|
|
214
|
+
`;var cn=()=>`
|
|
215
215
|
<button
|
|
216
|
-
id="${
|
|
216
|
+
id="${ye}"
|
|
217
217
|
style="
|
|
218
218
|
background: #f3f3f326 !important;
|
|
219
219
|
border: none !important;
|
|
@@ -229,11 +229,11 @@ function Oe(c){throw new Error("Node.js process "+c+" is not supported by JSPM c
|
|
|
229
229
|
justify-content: center !important;
|
|
230
230
|
"
|
|
231
231
|
>
|
|
232
|
-
${
|
|
232
|
+
${nt}
|
|
233
233
|
</button>
|
|
234
|
-
`,
|
|
234
|
+
`,ot=()=>`
|
|
235
235
|
<button
|
|
236
|
-
id="${
|
|
236
|
+
id="${we}"
|
|
237
237
|
style="
|
|
238
238
|
margin-top: 27px !important;
|
|
239
239
|
color: #f3f3f3 !important;
|
|
@@ -248,8 +248,8 @@ function Oe(c){throw new Error("Node.js process "+c+" is not supported by JSPM c
|
|
|
248
248
|
>
|
|
249
249
|
Try again
|
|
250
250
|
</button>
|
|
251
|
-
`,
|
|
252
|
-
${
|
|
251
|
+
`,ln=()=>`
|
|
252
|
+
${Be}
|
|
253
253
|
<div
|
|
254
254
|
style="
|
|
255
255
|
color: #e01a3d !important;
|
|
@@ -259,7 +259,7 @@ function Oe(c){throw new Error("Node.js process "+c+" is not supported by JSPM c
|
|
|
259
259
|
margin-bottom: 10px !important;
|
|
260
260
|
"
|
|
261
261
|
>
|
|
262
|
-
${
|
|
262
|
+
${it}
|
|
263
263
|
Pop-up blocked
|
|
264
264
|
</div>
|
|
265
265
|
<p style="
|
|
@@ -272,9 +272,9 @@ function Oe(c){throw new Error("Node.js process "+c+" is not supported by JSPM c
|
|
|
272
272
|
If the problem continues, adjust your<br />
|
|
273
273
|
browser settings.
|
|
274
274
|
</p>
|
|
275
|
-
${
|
|
276
|
-
`,
|
|
277
|
-
${
|
|
275
|
+
${ot()}
|
|
276
|
+
`,dn=()=>`
|
|
277
|
+
${Be}
|
|
278
278
|
<p style="
|
|
279
279
|
color: #b6b6b6 !important;
|
|
280
280
|
text-align: center !important;
|
|
@@ -283,10 +283,10 @@ function Oe(c){throw new Error("Node.js process "+c+" is not supported by JSPM c
|
|
|
283
283
|
>
|
|
284
284
|
Secure pop-up not showing?<br />We'll help you re-launch
|
|
285
285
|
</p>
|
|
286
|
-
${
|
|
287
|
-
`,
|
|
286
|
+
${ot()}
|
|
287
|
+
`,st=c=>`
|
|
288
288
|
<div
|
|
289
|
-
id="${
|
|
289
|
+
id="${ne}"
|
|
290
290
|
style="
|
|
291
291
|
position: fixed !important;
|
|
292
292
|
top: 0 !important;
|
|
@@ -309,9 +309,9 @@ function Oe(c){throw new Error("Node.js process "+c+" is not supported by JSPM c
|
|
|
309
309
|
z-index: 2147483647 !important;
|
|
310
310
|
"
|
|
311
311
|
>
|
|
312
|
-
${
|
|
312
|
+
${cn()}
|
|
313
313
|
<div
|
|
314
|
-
id="${
|
|
314
|
+
id="${q}"
|
|
315
315
|
style="
|
|
316
316
|
display: flex !important;
|
|
317
317
|
flex-direction: column !important;
|
|
@@ -322,9 +322,9 @@ function Oe(c){throw new Error("Node.js process "+c+" is not supported by JSPM c
|
|
|
322
322
|
${c??""}
|
|
323
323
|
</div>
|
|
324
324
|
</div>
|
|
325
|
-
`,
|
|
325
|
+
`,at=()=>`
|
|
326
326
|
<div
|
|
327
|
-
id="${
|
|
327
|
+
id="${ne}"
|
|
328
328
|
style="
|
|
329
329
|
position: fixed;
|
|
330
330
|
top: 0;
|
|
@@ -342,7 +342,7 @@ function Oe(c){throw new Error("Node.js process "+c+" is not supported by JSPM c
|
|
|
342
342
|
"
|
|
343
343
|
>
|
|
344
344
|
<div
|
|
345
|
-
id="${
|
|
345
|
+
id="${q}"
|
|
346
346
|
style="
|
|
347
347
|
display: flex;
|
|
348
348
|
flex-direction: column;
|
|
@@ -351,7 +351,7 @@ function Oe(c){throw new Error("Node.js process "+c+" is not supported by JSPM c
|
|
|
351
351
|
"
|
|
352
352
|
/>
|
|
353
353
|
</div>
|
|
354
|
-
`;function
|
|
354
|
+
`;function _e({id:c,href:n,rel:s,crossOrigin:l}){let u=`${ne}-${c}`;if(!document.getElementById(u)){let h=document.createElement("link");h.id=u,h.href=n,s&&(h.rel=s),l&&(h.crossOrigin=l),document.head.appendChild(h);}}var ct=()=>st(ln()),lt=()=>st(dn());var K=class{static overlay;static onCloseListener;static closeButton;static remove(){this.onCloseListener&&this.closeButton?.removeEventListener?.("click",this.onCloseListener),this.overlay?.remove(),this.closeButton=void 0,this.onCloseListener=void 0,this.overlay=void 0;}static appendOverlay(n,s){if(!this.overlay){let l=document.createElement("div");l.innerHTML=at(),document.body.insertAdjacentElement("beforeend",l);let u=document.querySelector(`#${q}`);u&&u.appendChild(n),l.addEventListener("click",s),this.overlay=l;}}};var hn=660,fn=440,mn="16px",dt="passport-embedded-login-keyframes",ut="passport-embedded-login-iframe",le=class c{config;constructor(n){this.config=n;}getHref=()=>`${this.config.authenticationDomain}/im-embedded-login-prompt?client_id=${this.config.oidcConfiguration.clientId}&rid=${getDetail(Detail.RUNTIME_ID)}`;static appendIFrameStylesIfNeeded=()=>{if(document.getElementById(dt))return;let n=document.createElement("style");n.id=dt,n.textContent=`
|
|
355
355
|
@keyframes passportEmbeddedLoginPromptPopBounceIn {
|
|
356
356
|
0% {
|
|
357
357
|
opacity: 0.5;
|
|
@@ -370,7 +370,7 @@ function Oe(c){throw new Error("Node.js process "+c+" is not supported by JSPM c
|
|
|
370
370
|
}
|
|
371
371
|
|
|
372
372
|
@media (max-height: 400px) {
|
|
373
|
-
#${
|
|
373
|
+
#${ut} {
|
|
374
374
|
width: 100% !important;
|
|
375
375
|
max-width: none !important;
|
|
376
376
|
}
|
|
@@ -384,6 +384,58 @@ function Oe(c){throw new Error("Node.js process "+c+" is not supported by JSPM c
|
|
|
384
384
|
opacity: 1;
|
|
385
385
|
}
|
|
386
386
|
}
|
|
387
|
-
`,document.head.appendChild(n);};getEmbeddedLoginIFrame=()=>{let n=document.createElement("iframe");return n.id=at,n.src=this.getHref(),n.style.height="100vh",n.style.width="100vw",n.style.maxHeight=`${Qr}px`,n.style.maxWidth=`${en}px`,n.style.borderRadius=tn,n.style.opacity="0",n.style.transform="scale(0.6)",n.style.animation="passportEmbeddedLoginPromptPopBounceIn 1s ease forwards",c.appendIFrameStylesIfNeeded(),n};displayEmbeddedLoginPrompt(){return new Promise((n,a)=>{let u=this.getEmbeddedLoginIFrame(),d=({data:h,origin:s})=>{if(!(s!==this.config.authenticationDomain||h.eventType!==Xe))switch(h.messageType){case"login_method_selected":{let y=h.payload;window.removeEventListener("message",d),$.remove(),n(y);break}case"login_prompt_error":{window.removeEventListener("message",d),$.remove(),a(new Error("Error during embedded login prompt",{cause:h.payload}));break}case"login_prompt_closed":{window.removeEventListener("message",d),$.remove(),a(new Error("Popup closed by user"));break}default:window.removeEventListener("message",d),$.remove(),a(new Error(`Unsupported message type: ${h.messageType}`));break}};window.addEventListener("message",d),$.appendOverlay(u,()=>{window.removeEventListener("message",d),$.remove(),a(new Error("Popup closed by user"));});})}};var ne=class{listeners=new Map;emit(n,...a){let u=this.listeners.get(n);!u||u.size===0||[...u].forEach(d=>{d(...a);});}on(n,a){let u=this.listeners.get(n)??new Set;u.add(a),this.listeners.set(n,u);}removeListener(n,a){let u=this.listeners.get(n);u&&(u.delete(a),u.size===0&&this.listeners.delete(n));}};var H=async(c,n,a=!0,u=!0)=>{let d=trackFlow("passport",n,a);try{return await c(d)}catch(h){throw h instanceof Error?trackError("passport",n,h,{flowId:d.details.flowId}):d.addEvent("errored"),h}finally{u&&d.addEvent("End");}};var on=()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof globalThis<"u"?globalThis:{},sn=c=>{let n=c.replace(/-/g,"+").replace(/_/g,"/"),a=n.length%4===0?"":"=".repeat(4-n.length%4);return n+a},an=c=>{let n=on();if(typeof n.atob!="function")return null;let a=n.atob(c),u=new Uint8Array(a.length);for(let h=0;h<a.length;h+=1)u[h]=a.charCodeAt(h);if(typeof n.TextDecoder=="function")return new n.TextDecoder("utf-8").decode(u);let d="";for(let h=0;h<u.length;h+=1)d+=String.fromCharCode(u[h]);return d},ln=c=>{if(typeof L<"u")return L.from(c,"base64").toString("utf-8");let n=an(c);if(n===null)throw new Error("Base64 decoding is not supported in this environment");return n},J=c=>{if(typeof c!="string")throw new Error("JWT must be a string");let n=c.split(".");if(n.length<2)throw new Error("Invalid JWT: payload segment is missing");let a=n[1],u=ln(sn(a));try{return JSON.parse(u)}catch{throw new Error("Invalid JWT payload: unable to parse JSON")}};var lt="pkce_state",ut="pkce_verifier",un=3600,ce=class{isTokenValid(n){try{let u=J(n).exp??0,d=Date.now()/1e3+un;return u>d}catch{return !1}}savePKCEData(n){localStorage.setItem(lt,n.state),localStorage.setItem(ut,n.verifier);}getPKCEData(){let n=localStorage.getItem(lt),a=localStorage.getItem(ut);return n&&a?{state:n,verifier:a}:null}};var cn=(...c)=>{if(typeof v>"u")return;v?.env?.JEST_WORKER_ID===void 0&&console.warn(...c);},ie={warn:cn};function ct(c){try{let n=J(c),a=Math.floor(Date.now()/1e3);return n.exp?n.exp<=a+30:!0}catch{return !0}}function pt(c){let{id_token:n,access_token:a}=c;return !a||!n?!0:ct(a)||ct(n)}var pe=class{disableGenericPopupOverlay;disableBlockedPopupOverlay;overlay;isBlockedOverlay;tryAgainListener;onCloseListener;constructor(n,a=!1){this.disableBlockedPopupOverlay=n.disableBlockedPopupOverlay||!1,this.disableGenericPopupOverlay=n.disableGenericPopupOverlay||!1,this.isBlockedOverlay=a;}append(n,a){this.shouldAppendOverlay()&&(this.appendOverlay(),this.updateTryAgainButton(n),this.updateCloseButton(a));}update(n){this.updateTryAgainButton(n);}remove(){this.overlay&&this.overlay.remove();}shouldAppendOverlay(){return !(this.disableGenericPopupOverlay&&this.disableBlockedPopupOverlay||this.disableGenericPopupOverlay&&!this.isBlockedOverlay||this.disableBlockedPopupOverlay&&this.isBlockedOverlay)}appendOverlay(){if(!this.overlay){we({id:"link-googleapis",href:"https://fonts.googleapis.com"}),we({id:"link-gstatic",href:"https://fonts.gstatic.com",crossOrigin:"anonymous"}),we({id:"link-roboto",href:"https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,500;0,700;1,400;1,500;1,700&display=swap",rel:"stylesheet"});let a=document.createElement("div");a.innerHTML=this.isBlockedOverlay?it():ot(),document.body.insertAdjacentElement("beforeend",a),this.overlay=a;}}updateTryAgainButton(n){let a=document.getElementById(ye);a&&(this.tryAgainListener&&a.removeEventListener("click",this.tryAgainListener),this.tryAgainListener=n,a.addEventListener("click",n));}updateCloseButton(n){let a=document.getElementById(Ee);a&&(this.onCloseListener&&a.removeEventListener("click",this.onCloseListener),this.onCloseListener=n,a.addEventListener("click",n));}};var _e=class{storage;constructor(n,a){this.storage=pn.createInstance({name:n,driver:a});}get length(){return this.storage.length()}clear(){return this.storage.clear()}getItem(n){return this.storage.getItem(n)}key(n){return this.storage.key(n)}async removeItem(n){await this.storage.removeItem(n);}async setItem(n,a){await this.storage.setItem(n,a);}};var Tn={"Content-Type":"application/x-www-form-urlencoded"},vn=c=>{if(c)try{return JSON.parse(c)}catch{return}},An=(c,n,a)=>{if(c&&typeof c=="object"){let u=c,d=u.error_description??u.message??u.error;if(typeof d=="string"&&d.trim().length>0)return d}return n.trim().length>0?n:`Token request failed with status ${a}`},On="/v2/logout",Ln="/im-logged-out",Pn="/authorize",Un=c=>c?Ln:On,Bn=c=>{let{authenticationDomain:n,oidcConfiguration:a}=c,u;c.crossSdkBridgeEnabled?u=new _e("ImmutableSDKPassport",pn.INDEXEDDB):typeof window<"u"?u=window.localStorage:u=new InMemoryWebStorage;let d=new WebStorageStateStore({store:u}),h=new URL(Un(c.crossSdkBridgeEnabled),n.replace(/^(?:https?:\/\/)?(.*)/,"https://$1"));return h.searchParams.set("client_id",a.clientId),a.logoutRedirectUri&&h.searchParams.set("returnTo",a.logoutRedirectUri),{authority:n,redirect_uri:a.redirectUri,popup_redirect_uri:a.popupRedirectUri||a.redirectUri,client_id:a.clientId,metadata:{authorization_endpoint:`${n}/authorize`,token_endpoint:`${n}/oauth/token`,userinfo_endpoint:`${n}/userinfo`,end_session_endpoint:h.toString(),revocation_endpoint:`${n}/oauth/revoke`},automaticSilentRenew:!1,scope:a.scope,userStore:d,revokeTokenTypes:["refresh_token"],extraQueryParams:{...a.audience?{audience:a.audience}:{}}}};function be(c){return btoa(String.fromCharCode(...new Uint8Array(c))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}async function kn(c){let a=new TextEncoder().encode(c);return window.crypto.subtle.digest("SHA-256",a)}var xe=class c{config;userManager;deviceCredentialsManager;embeddedLoginPrompt;logoutMode;refreshingPromise=null;eventEmitter;constructor(n){this.config=new ae(n),this.embeddedLoginPrompt=new ue(this.config),this.userManager=new UserManager(Bn(this.config)),this.deviceCredentialsManager=new ce,this.logoutMode=this.config.oidcConfiguration.logoutMode||"redirect",this.eventEmitter=new ne,track("passport","initialise");}async login(n){return H(async()=>{let{useCachedSession:a=!1,useSilentLogin:u}=n||{},d=null;try{d=await this.getUserInternal();}catch(h){if(h instanceof Error&&!h.message.includes("Unknown or invalid refresh token")&&trackError("passport","login",h),a)throw h;ie.warn("Failed to retrieve a cached user session",h);}if(!d&&u)d=await this.forceUserRefreshInternal();else if(!d&&!a){if(n?.useRedirectFlow)return await this.loginWithRedirectInternal(n?.directLoginOptions),null;d=await this.loginWithPopup(n?.directLoginOptions);}return d&&this.handleSuccessfulLogin(d),d},"login")}async loginWithRedirect(n){await this.loginWithRedirectInternal(n);}async loginCallback(){return H(async()=>{let n=await this.loginCallbackInternal();return n&&this.handleSuccessfulLogin(n),n},"loginCallback")}async logout(){await H(async()=>{await this.logoutInternal(),this.eventEmitter.emit("loggedOut");},"logout");}async getUser(){return this.getUserInternal()}async getUserOrLogin(){let n=null;try{n=await this.getUserInternal();}catch(u){ie.warn("Failed to retrieve a cached user session",u);}if(n)return n;let a=await this.loginWithPopup();return this.handleSuccessfulLogin(a),a}async getUserZkEvm(){return this.getUserZkEvmInternal()}async getIdToken(){return H(async()=>(await this.getUserInternal())?.idToken,"getIdToken",!1)}async getAccessToken(){return H(async()=>(await this.getUserInternal())?.accessToken,"getAccessToken",!1,!1)}async isLoggedIn(){return await this.getUser()!==null}async forceUserRefresh(){return this.forceUserRefreshInternal()}forceUserRefreshInBackground(){this.forceUserRefreshInBackgroundInternal();}async loginWithPKCEFlow(n,a){return H(async()=>this.getPKCEAuthorizationUrl(n,a),"loginWithPKCEFlow")}async loginWithPKCEFlowCallback(n,a){return H(async()=>{let u=await this.loginWithPKCEFlowCallbackInternal(n,a);return this.handleSuccessfulLogin(u),u},"loginWithPKCEFlowCallback")}async storeTokens(n){return H(async()=>{let a=await this.storeTokensInternal(n);return this.handleSuccessfulLogin(a),a},"storeTokens")}async getLogoutUrl(){return H(async()=>(await this.userManager.removeUser(),this.eventEmitter.emit("loggedOut"),await this.getLogoutUrlInternal()||void 0),"getLogoutUrl")}async logoutSilentCallback(n){return H(()=>this.userManager.signoutSilentCallback(n),"logoutSilentCallback")}getConfig(){return this.config}async getClientId(){return this.config.oidcConfiguration.clientId}handleSuccessfulLogin(n){this.eventEmitter.emit("loggedIn",n),identify({passportId:n.profile.sub});}buildExtraQueryParams(n,a){let u={...this.userManager.settings?.extraQueryParams??{},rid:getDetail(Detail.RUNTIME_ID)||""};if(n){if(n.directLoginMethod==="email"){let d=n.email;d&&(u.direct=n.directLoginMethod,u.email=d);}else u.direct=n.directLoginMethod;n.marketingConsentStatus&&(u.marketingConsent=n.marketingConsentStatus);}return a&&(u.im_passport_trace_id=a),u}async loginWithRedirectInternal(n){await this.userManager.clearStaleState(),await z(async()=>{let a=this.buildExtraQueryParams(n);await this.userManager.signinRedirect({extraQueryParams:a});},"AUTHENTICATION_ERROR");}async loginWithPopup(n){return z(async()=>{let a,u;if(n)a=n;else if(!this.config.popupOverlayOptions?.disableHeadlessLoginPromptOverlay){let{imPassportTraceId:s,...y}=await this.embeddedLoginPrompt.displayEmbeddedLoginPrompt();a=y,u=s;}let d=window.crypto.randomUUID(),h=async()=>{let s=this.buildExtraQueryParams(a,u);return this.userManager.signinPopup({extraQueryParams:s,popupWindowFeatures:{width:410,height:450},popupWindowTarget:d,popupAbortOnClose:!0})};return new Promise((s,y)=>{h().then(T=>s(c.mapOidcUserToDomainModel(T))).catch(T=>{if(!(T instanceof Error)||T.message!=="Attempted to navigate on a disposed window"){y(T);return}let k=!1,m=new pe(this.config.popupOverlayOptions||{},!0);m.append(async()=>{try{if(k)window.open("",d);else {k=!0;let I=await h();m.remove(),s(c.mapOidcUserToDomainModel(I));}}catch(I){m.remove(),y(I);}},()=>{m.remove(),y(new Error("Popup closed by user"));});});})},"AUTHENTICATION_ERROR")}static mapOidcUserToDomainModel=n=>{let a,u;if(n.id_token){let s=J(n.id_token);a=s?.passport,s?.username&&(u=s?.username);}let d={expired:n.expired,idToken:n.id_token,accessToken:n.access_token,refreshToken:n.refresh_token,profile:{sub:n.profile.sub,email:n.profile.email,nickname:n.profile.nickname,username:u}};a?.zkevm_eth_address&&a?.zkevm_user_admin_address&&(d.zkEvm={ethAddress:a.zkevm_eth_address,userAdminAddress:a.zkevm_user_admin_address});let h=Object.values(ge).filter(s=>s!=="zkevm");for(let s of h){let y=a?.[s];y?.eth_address&&y?.user_admin_address&&(d[s]={ethAddress:y.eth_address,userAdminAddress:y.user_admin_address});}return d};static mapDeviceTokenResponseToOidcUser=n=>{let a=J(n.id_token);return new User({id_token:n.id_token,access_token:n.access_token,refresh_token:n.refresh_token,token_type:n.token_type,profile:{sub:a.sub,iss:a.iss,aud:a.aud,exp:a.exp,iat:a.iat,email:a.email,nickname:a.nickname,passport:a.passport,...a.username?{username:a.username}:{}}})};async loginCallbackInternal(){return z(async()=>{let n=await this.userManager.signinCallback();if(n)return c.mapOidcUserToDomainModel(n)},"AUTHENTICATION_ERROR")}async getPKCEAuthorizationUrl(n,a){let u=be(window.crypto.getRandomValues(new Uint8Array(32))),d=be(await kn(u)),h=be(window.crypto.getRandomValues(new Uint8Array(32))),{redirectUri:s,scope:y,audience:T,clientId:k}=this.config.oidcConfiguration;this.deviceCredentialsManager.savePKCEData({state:h,verifier:u});let m=new URL(Pn,this.config.authenticationDomain);if(m.searchParams.set("response_type","code"),m.searchParams.set("code_challenge",d),m.searchParams.set("code_challenge_method","S256"),m.searchParams.set("client_id",k),m.searchParams.set("redirect_uri",s),m.searchParams.set("state",h),y&&m.searchParams.set("scope",y),T&&m.searchParams.set("audience",T),n){if(n.directLoginMethod==="email"){let I=n.email;I&&(m.searchParams.set("direct",n.directLoginMethod),m.searchParams.set("email",I));}else m.searchParams.set("direct",n.directLoginMethod);n.marketingConsentStatus&&m.searchParams.set("marketingConsent",n.marketingConsentStatus);}return a&&m.searchParams.set("im_passport_trace_id",a),m.toString()}async loginWithPKCEFlowCallbackInternal(n,a){return z(async()=>{let u=this.deviceCredentialsManager.getPKCEData();if(!u)throw new Error("No code verifier or state for PKCE");if(a!==u.state)throw new Error("Provided state does not match stored state");let d=await this.getPKCEToken(n,u.verifier),h=c.mapDeviceTokenResponseToOidcUser(d),s=c.mapOidcUserToDomainModel(h);return await this.userManager.storeUser(h),s},"AUTHENTICATION_ERROR")}async getPKCEToken(n,a){let u=await fetch(`${this.config.authenticationDomain}/oauth/token`,{method:"POST",headers:Tn,body:new URLSearchParams({client_id:this.config.oidcConfiguration.clientId,grant_type:"authorization_code",code_verifier:a,code:n,redirect_uri:this.config.oidcConfiguration.redirectUri})}),d=await u.text(),h=vn(d);if(!u.ok)throw new Error(An(h,d,u.status));if(!h||typeof h!="object")throw new Error("Token endpoint returned an invalid response");return h}async storeTokensInternal(n){return z(async()=>{let a=c.mapDeviceTokenResponseToOidcUser(n),u=c.mapOidcUserToDomainModel(a);return await this.userManager.storeUser(a),u},"AUTHENTICATION_ERROR")}async logoutInternal(){await z(async()=>{await this.userManager.revokeTokens(["refresh_token"]),this.logoutMode==="silent"?await this.userManager.signoutSilent():await this.userManager.signoutRedirect();},"LOGOUT_ERROR");}async getLogoutUrlInternal(){let n=this.userManager.settings?.metadata?.end_session_endpoint;return n||(ie.warn("Failed to get logout URL"),null)}forceUserRefreshInBackgroundInternal(){this.refreshTokenAndUpdatePromise().catch(n=>{ie.warn("Failed to refresh user token",n);});}async forceUserRefreshInternal(){return this.refreshTokenAndUpdatePromise().catch(n=>(ie.warn("Failed to refresh user token",n),null))}async refreshTokenAndUpdatePromise(){return this.refreshingPromise?this.refreshingPromise:(this.refreshingPromise=new Promise((n,a)=>{(async()=>{try{let u=await this.userManager.signinSilent();if(u){n(c.mapOidcUserToDomainModel(u));return}n(null);}catch(u){let d="AUTHENTICATION_ERROR",h="Failed to refresh token",s=!0;if(u instanceof ErrorTimeout?(d="SILENT_LOGIN_ERROR",h=`${h}: ${u.message}`,s=!1):u instanceof ErrorResponse?(d="NOT_LOGGED_IN_ERROR",h=`${h}: ${u.message||u.error_description}`):u instanceof Error?h=`${h}: ${u.message}`:typeof u=="string"&&(h=`${h}: ${u}`),s)try{await this.userManager.removeUser();}catch(y){y instanceof Error&&(h=`${h}: Failed to remove user: ${y.message}`);}a(new G(h,d));}finally{this.refreshingPromise=null;}})();}),this.refreshingPromise)}async getUserInternal(n=a=>!0){if(this.refreshingPromise){let u=await this.refreshingPromise;return u&&n(u)?u:null}let a=await this.userManager.getUser();if(!a)return null;if(!pt(a)){let u=c.mapOidcUserToDomainModel(a);if(u&&n(u))return u}if(a.refresh_token){let u=await this.refreshTokenAndUpdatePromise();if(u&&n(u))return u}return null}async getUserZkEvmInternal(){let n=await this.getUserInternal(Ue);if(!n)throw new Error("Failed to obtain a User with the required ZkEvm attributes");return n}};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
387
|
+
`,document.head.appendChild(n);};getEmbeddedLoginIFrame=()=>{let n=document.createElement("iframe");return n.id=ut,n.src=this.getHref(),n.style.height="100vh",n.style.width="100vw",n.style.maxHeight=`${hn}px`,n.style.maxWidth=`${fn}px`,n.style.borderRadius=mn,n.style.opacity="0",n.style.transform="scale(0.6)",n.style.animation="passportEmbeddedLoginPromptPopBounceIn 1s ease forwards",c.appendIFrameStylesIfNeeded(),n};displayEmbeddedLoginPrompt(){return new Promise((n,s)=>{let l=this.getEmbeddedLoginIFrame(),u=({data:h,origin:o})=>{if(!(o!==this.config.authenticationDomain||h.eventType!==rt))switch(h.messageType){case"login_method_selected":{let f=h.payload;window.removeEventListener("message",u),K.remove(),n(f);break}case"login_prompt_error":{window.removeEventListener("message",u),K.remove(),s(new Error("Error during embedded login prompt",{cause:h.payload}));break}case"login_prompt_closed":{window.removeEventListener("message",u),K.remove(),s(new Error("Popup closed by user"));break}default:window.removeEventListener("message",u),K.remove(),s(new Error(`Unsupported message type: ${h.messageType}`));break}};window.addEventListener("message",u),K.appendOverlay(l,()=>{window.removeEventListener("message",u),K.remove(),s(new Error("Popup closed by user"));});})}};var ie=class{listeners=new Map;emit(n,...s){let l=this.listeners.get(n);!l||l.size===0||[...l].forEach(u=>{u(...s);});}on(n,s){let l=this.listeners.get(n)??new Set;l.add(s),this.listeners.set(n,l);}removeListener(n,s){let l=this.listeners.get(n);l&&(l.delete(s),l.size===0&&this.listeners.delete(n));}};var H=async(c,n,s=!0,l=!0)=>{let u=trackFlow("passport",n,s);try{return await c(u)}catch(h){throw h instanceof Error?trackError("passport",n,h,{flowId:u.details.flowId}):u.addEvent("errored"),h}finally{l&&u.addEvent("End");}};var yn=()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof globalThis<"u"?globalThis:{},wn=c=>{let n=c.replace(/-/g,"+").replace(/_/g,"/"),s=n.length%4===0?"":"=".repeat(4-n.length%4);return n+s},_n=c=>{let n=yn();if(typeof n.atob!="function")return null;let s=n.atob(c),l=new Uint8Array(s.length);for(let h=0;h<s.length;h+=1)l[h]=s.charCodeAt(h);if(typeof n.TextDecoder=="function")return new n.TextDecoder("utf-8").decode(l);let u="";for(let h=0;h<l.length;h+=1)u+=String.fromCharCode(l[h]);return u},Cn=c=>{if(typeof P<"u")return P.from(c,"base64").toString("utf-8");let n=_n(c);if(n===null)throw new Error("Base64 decoding is not supported in this environment");return n},V=c=>{if(typeof c!="string")throw new Error("JWT must be a string");let n=c.split(".");if(n.length<2)throw new Error("Invalid JWT: payload segment is missing");let s=n[1],l=Cn(wn(s));try{return JSON.parse(l)}catch{throw new Error("Invalid JWT payload: unable to parse JSON")}};var pt="pkce_state",ht="pkce_verifier",Rn=3600,de=class{isTokenValid(n){try{let l=V(n).exp??0,u=Date.now()/1e3+Rn;return l>u}catch{return !1}}savePKCEData(n){localStorage.setItem(pt,n.state),localStorage.setItem(ht,n.verifier);}getPKCEData(){let n=localStorage.getItem(pt),s=localStorage.getItem(ht);return n&&s?{state:n,verifier:s}:null}};var Tn=(...c)=>{if(typeof O>"u")return;O?.env?.JEST_WORKER_ID===void 0&&console.warn(...c);},oe={warn:Tn};function ft(c){try{let n=V(c),s=Math.floor(Date.now()/1e3);return n.exp?n.exp<=s+30:!0}catch{return !0}}function mt(c){let{id_token:n,access_token:s}=c;return !s||!n?!0:ft(s)||ft(n)}var ue=class{disableGenericPopupOverlay;disableBlockedPopupOverlay;overlay;isBlockedOverlay;tryAgainListener;onCloseListener;constructor(n,s=!1){this.disableBlockedPopupOverlay=n.disableBlockedPopupOverlay||!1,this.disableGenericPopupOverlay=n.disableGenericPopupOverlay||!1,this.isBlockedOverlay=s;}append(n,s){this.shouldAppendOverlay()&&(this.appendOverlay(),this.updateTryAgainButton(n),this.updateCloseButton(s));}update(n){this.updateTryAgainButton(n);}remove(){this.overlay&&this.overlay.remove();}shouldAppendOverlay(){return !(this.disableGenericPopupOverlay&&this.disableBlockedPopupOverlay||this.disableGenericPopupOverlay&&!this.isBlockedOverlay||this.disableBlockedPopupOverlay&&this.isBlockedOverlay)}appendOverlay(){if(!this.overlay){_e({id:"link-googleapis",href:"https://fonts.googleapis.com"}),_e({id:"link-gstatic",href:"https://fonts.gstatic.com",crossOrigin:"anonymous"}),_e({id:"link-roboto",href:"https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,500;0,700;1,400;1,500;1,700&display=swap",rel:"stylesheet"});let s=document.createElement("div");s.innerHTML=this.isBlockedOverlay?ct():lt(),document.body.insertAdjacentElement("beforeend",s),this.overlay=s;}}updateTryAgainButton(n){let s=document.getElementById(we);s&&(this.tryAgainListener&&s.removeEventListener("click",this.tryAgainListener),this.tryAgainListener=n,s.addEventListener("click",n));}updateCloseButton(n){let s=document.getElementById(ye);s&&(this.onCloseListener&&s.removeEventListener("click",this.onCloseListener),this.onCloseListener=n,s.addEventListener("click",n));}};var Ce=class{storage;constructor(n,s){this.storage=In.createInstance({name:n,driver:s});}get length(){return this.storage.length()}clear(){return this.storage.clear()}getItem(n){return this.storage.getItem(n)}key(n){return this.storage.key(n)}async removeItem(n){await this.storage.removeItem(n);}async setItem(n,s){await this.storage.setItem(n,s);}};var Nn={"Content-Type":"application/x-www-form-urlencoded"},Dn=c=>{if(c)try{return JSON.parse(c)}catch{return}},Fn=(c,n,s)=>{if(c&&typeof c=="object"){let l=c,u=l.error_description??l.message??l.error;if(typeof u=="string"&&u.trim().length>0)return u}return n.trim().length>0?n:`Token request failed with status ${s}`},gt=(c,n)=>({ethAddress:c,userAdminAddress:n}),Hn="/v2/logout",Vn="/im-logged-out",Gn="/authorize",$n=c=>c?Vn:Hn,Kn=c=>{let{authenticationDomain:n,oidcConfiguration:s}=c,l;c.crossSdkBridgeEnabled?l=new Ce("ImmutableSDKPassport",In.INDEXEDDB):typeof window<"u"?l=window.localStorage:l=new InMemoryWebStorage;let u=new WebStorageStateStore({store:l}),h=new URL($n(c.crossSdkBridgeEnabled),n.replace(/^(?:https?:\/\/)?(.*)/,"https://$1"));return h.searchParams.set("client_id",s.clientId),s.logoutRedirectUri&&h.searchParams.set("returnTo",s.logoutRedirectUri),{authority:n,redirect_uri:s.redirectUri,popup_redirect_uri:s.popupRedirectUri||s.redirectUri,client_id:s.clientId,metadata:{authorization_endpoint:`${n}/authorize`,token_endpoint:`${n}/oauth/token`,userinfo_endpoint:`${n}/userinfo`,end_session_endpoint:h.toString(),revocation_endpoint:`${n}/oauth/revoke`},automaticSilentRenew:!1,scope:s.scope,userStore:u,revokeTokenTypes:["refresh_token"],extraQueryParams:{...s.audience?{audience:s.audience}:{}}}};function Se(c){return btoa(String.fromCharCode(...new Uint8Array(c))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}async function Wn(c){let s=new TextEncoder().encode(c);return window.crypto.subtle.digest("SHA-256",s)}var Me=class c{config;userManager;deviceCredentialsManager;embeddedLoginPrompt;logoutMode;refreshingPromise=null;eventEmitter;constructor(n){this.config=new ce(n),this.embeddedLoginPrompt=new le(this.config),this.userManager=new UserManager(Kn(this.config)),this.deviceCredentialsManager=new de,this.logoutMode=this.config.oidcConfiguration.logoutMode||"redirect",this.eventEmitter=new ie,track("passport","initialise");}async login(n){return H(async()=>{let{useCachedSession:s=!1,useSilentLogin:l}=n||{},u=null;try{u=await this.getUserInternal();}catch(h){if(h instanceof Error&&!h.message.includes("Unknown or invalid refresh token")&&trackError("passport","login",h),s)throw h;oe.warn("Failed to retrieve a cached user session",h);}if(!u&&l)u=await this.forceUserRefreshInternal();else if(!u&&!s){if(n?.useRedirectFlow)return await this.loginWithRedirectInternal(n?.directLoginOptions),null;u=await this.loginWithPopup(n?.directLoginOptions);}return u&&this.handleSuccessfulLogin(u),u},"login")}async loginWithRedirect(n){await this.loginWithRedirectInternal(n);}async loginCallback(){return H(async()=>{let n=await this.loginCallbackInternal();return n&&this.handleSuccessfulLogin(n),n},"loginCallback")}async logout(){await H(async()=>{await this.logoutInternal(),this.eventEmitter.emit("loggedOut");},"logout");}async getUser(){return this.getUserInternal()}async getUserOrLogin(){let n=null;try{n=await this.getUserInternal();}catch(l){oe.warn("Failed to retrieve a cached user session",l);}if(n)return n;let s=await this.loginWithPopup();return this.handleSuccessfulLogin(s),s}async getUserZkEvm(){return this.getUserZkEvmInternal()}async getIdToken(){return H(async()=>(await this.getUserInternal())?.idToken,"getIdToken",!1)}async getAccessToken(){return H(async()=>(await this.getUserInternal())?.accessToken,"getAccessToken",!1,!1)}async isLoggedIn(){return await this.getUser()!==null}async forceUserRefresh(){return this.forceUserRefreshInternal()}forceUserRefreshInBackground(){this.forceUserRefreshInBackgroundInternal();}async loginWithPKCEFlow(n,s){return H(async()=>this.getPKCEAuthorizationUrl(n,s),"loginWithPKCEFlow")}async loginWithPKCEFlowCallback(n,s){return H(async()=>{let l=await this.loginWithPKCEFlowCallbackInternal(n,s);return this.handleSuccessfulLogin(l),l},"loginWithPKCEFlowCallback")}async storeTokens(n){return H(async()=>{let s=await this.storeTokensInternal(n);return this.handleSuccessfulLogin(s),s},"storeTokens")}async getLogoutUrl(){return H(async()=>(await this.userManager.removeUser(),this.eventEmitter.emit("loggedOut"),await this.getLogoutUrlInternal()||void 0),"getLogoutUrl")}async logoutSilentCallback(n){return H(()=>this.userManager.signoutSilentCallback(n),"logoutSilentCallback")}getConfig(){return this.config}async getClientId(){return this.config.oidcConfiguration.clientId}handleSuccessfulLogin(n){this.eventEmitter.emit("loggedIn",n),identify({passportId:n.profile.sub});}buildExtraQueryParams(n,s){let l={...this.userManager.settings?.extraQueryParams??{},rid:getDetail(Detail.RUNTIME_ID)||""};if(n){if(n.directLoginMethod==="email"){let u=n.email;u&&(l.direct=n.directLoginMethod,l.email=u);}else l.direct=n.directLoginMethod;n.marketingConsentStatus&&(l.marketingConsent=n.marketingConsentStatus);}return s&&(l.im_passport_trace_id=s),l}async loginWithRedirectInternal(n){await this.userManager.clearStaleState(),await J(async()=>{let s=this.buildExtraQueryParams(n);await this.userManager.signinRedirect({extraQueryParams:s});},"AUTHENTICATION_ERROR");}async loginWithPopup(n){return J(async()=>{let s,l;if(n)s=n;else if(!this.config.popupOverlayOptions?.disableHeadlessLoginPromptOverlay){let{imPassportTraceId:o,...f}=await this.embeddedLoginPrompt.displayEmbeddedLoginPrompt();s=f,l=o;}let u=window.crypto.randomUUID(),h=async()=>{let o=this.buildExtraQueryParams(s,l);return this.userManager.signinPopup({extraQueryParams:o,popupWindowFeatures:{width:410,height:450},popupWindowTarget:u,popupAbortOnClose:!0})};return new Promise((o,f)=>{h().then(E=>o(c.mapOidcUserToDomainModel(E))).catch(E=>{if(!(E instanceof Error)||E.message!=="Attempted to navigate on a disposed window"){f(E);return}let _=!1,g=new ue(this.config.popupOverlayOptions||{},!0);g.append(async()=>{try{if(_)window.open("",u);else {_=!0;let R=await h();g.remove(),o(c.mapOidcUserToDomainModel(R));}}catch(R){g.remove(),f(R);}},()=>{g.remove(),f(new Error("Popup closed by user"));});});})},"AUTHENTICATION_ERROR")}static mapOidcUserToDomainModel=n=>{let s,l;if(n.id_token){let o=V(n.id_token);s=o?.passport,o?.username&&(l=o?.username);}let u={expired:n.expired,idToken:n.id_token,accessToken:n.access_token,refreshToken:n.refresh_token,profile:{sub:n.profile.sub,email:n.profile.email,nickname:n.profile.nickname,username:l}};s?.zkevm_eth_address&&s?.zkevm_user_admin_address&&(u.zkEvm=gt(s.zkevm_eth_address,s.zkevm_user_admin_address));let h=Object.values(Ee).filter(o=>o!=="zkevm");for(let o of h){let f=s?.[o];f?.eth_address&&f?.user_admin_address&&(u[o]=gt(f.eth_address,f.user_admin_address));}return u};static mapDeviceTokenResponseToOidcUser=n=>{let s=V(n.id_token);return new User({id_token:n.id_token,access_token:n.access_token,refresh_token:n.refresh_token,token_type:n.token_type,profile:{sub:s.sub,iss:s.iss,aud:s.aud,exp:s.exp,iat:s.iat,email:s.email,nickname:s.nickname,passport:s.passport,...s.username?{username:s.username}:{}}})};async loginCallbackInternal(){return J(async()=>{let n=await this.userManager.signinCallback();if(n)return c.mapOidcUserToDomainModel(n)},"AUTHENTICATION_ERROR")}async getPKCEAuthorizationUrl(n,s){let l=Se(window.crypto.getRandomValues(new Uint8Array(32))),u=Se(await Wn(l)),h=Se(window.crypto.getRandomValues(new Uint8Array(32))),{redirectUri:o,scope:f,audience:E,clientId:_}=this.config.oidcConfiguration;this.deviceCredentialsManager.savePKCEData({state:h,verifier:l});let g=new URL(Gn,this.config.authenticationDomain);if(g.searchParams.set("response_type","code"),g.searchParams.set("code_challenge",u),g.searchParams.set("code_challenge_method","S256"),g.searchParams.set("client_id",_),g.searchParams.set("redirect_uri",o),g.searchParams.set("state",h),f&&g.searchParams.set("scope",f),E&&g.searchParams.set("audience",E),n){if(n.directLoginMethod==="email"){let R=n.email;R&&(g.searchParams.set("direct",n.directLoginMethod),g.searchParams.set("email",R));}else g.searchParams.set("direct",n.directLoginMethod);n.marketingConsentStatus&&g.searchParams.set("marketingConsent",n.marketingConsentStatus);}return s&&g.searchParams.set("im_passport_trace_id",s),g.toString()}async loginWithPKCEFlowCallbackInternal(n,s){return J(async()=>{let l=this.deviceCredentialsManager.getPKCEData();if(!l)throw new Error("No code verifier or state for PKCE");if(s!==l.state)throw new Error("Provided state does not match stored state");let u=await this.getPKCEToken(n,l.verifier),h=c.mapDeviceTokenResponseToOidcUser(u),o=c.mapOidcUserToDomainModel(h);return await this.userManager.storeUser(h),o},"AUTHENTICATION_ERROR")}async getPKCEToken(n,s){let l=await fetch(`${this.config.authenticationDomain}/oauth/token`,{method:"POST",headers:Nn,body:new URLSearchParams({client_id:this.config.oidcConfiguration.clientId,grant_type:"authorization_code",code_verifier:s,code:n,redirect_uri:this.config.oidcConfiguration.redirectUri})}),u=await l.text(),h=Dn(u);if(!l.ok)throw new Error(Fn(h,u,l.status));if(!h||typeof h!="object")throw new Error("Token endpoint returned an invalid response");return h}async storeTokensInternal(n){return J(async()=>{let s=c.mapDeviceTokenResponseToOidcUser(n),l=c.mapOidcUserToDomainModel(s);return await this.userManager.storeUser(s),l},"AUTHENTICATION_ERROR")}async logoutInternal(){await J(async()=>{await this.userManager.revokeTokens(["refresh_token"]),this.logoutMode==="silent"?await this.userManager.signoutSilent():await this.userManager.signoutRedirect();},"LOGOUT_ERROR");}async getLogoutUrlInternal(){let n=this.userManager.settings?.metadata?.end_session_endpoint;return n||(oe.warn("Failed to get logout URL"),null)}forceUserRefreshInBackgroundInternal(){this.refreshTokenAndUpdatePromise().catch(n=>{oe.warn("Failed to refresh user token",n);});}async forceUserRefreshInternal(){return this.refreshTokenAndUpdatePromise().catch(n=>(oe.warn("Failed to refresh user token",n),null))}async refreshTokenAndUpdatePromise(){return this.refreshingPromise?this.refreshingPromise:(this.refreshingPromise=new Promise((n,s)=>{(async()=>{try{let l=await this.userManager.signinSilent();if(l){let u=c.mapOidcUserToDomainModel(l);this.eventEmitter.emit("tokenRefreshed",u),n(u);return}n(null);}catch(l){let u="AUTHENTICATION_ERROR",h="Failed to refresh token",o=!0;if(l instanceof ErrorTimeout?(u="SILENT_LOGIN_ERROR",h=`${h}: ${l.message}`,o=!1):l instanceof ErrorResponse?(u="NOT_LOGGED_IN_ERROR",h=`${h}: ${l.message||l.error_description}`):l instanceof Error?h=`${h}: ${l.message}`:typeof l=="string"&&(h=`${h}: ${l}`),o){this.eventEmitter.emit("userRemoved",{reason:"refresh_failed",error:h});try{await this.userManager.removeUser();}catch(f){f instanceof Error&&(h=`${h}: Failed to remove user: ${f.message}`);}}s(new $(h,u));}finally{this.refreshingPromise=null;}})();}),this.refreshingPromise)}async getUserInternal(n=s=>!0){if(this.refreshingPromise){let l=await this.refreshingPromise;return l&&n(l)?l:null}let s=await this.userManager.getUser();if(!s)return null;if(!mt(s)){let l=c.mapOidcUserToDomainModel(s);if(l&&n(l))return l}if(s.refresh_token){let l=await this.refreshTokenAndUpdatePromise();if(l&&n(l))return l}return null}async getUserZkEvmInternal(){let n=await this.getUserInternal(be);if(!n)throw new Error("Failed to obtain a User with the required ZkEvm attributes");return n}};var zn="im_passport_embedded_login_prompt",wt="passport-embedded-login-iframe",_t="passport-overlay";var Jn="https://auth.immutable.com",qn="platform_api",Xn="openid profile email offline_access transact",jn="/authorize",Qn="/oauth/token",Ne="imtbl_pkce_data";function Ct(c){return btoa(String.fromCharCode(...new Uint8Array(c))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}async function ei(c){let s=new TextEncoder().encode(c);return window.crypto.subtle.digest("SHA-256",s)}function Et(){return Ct(window.crypto.getRandomValues(new Uint8Array(32)))}function De(c){return c.authenticationDomain||Jn}function ti(c){try{let n=V(c);if(n.exp)return n.exp*1e3}catch{}return Date.now()+3600*1e3}function ri(c){let{access_token:n,refresh_token:s,id_token:l}=c,u={sub:""},h;if(l)try{let{sub:o,email:f,nickname:E,passport:_}=V(l);u={sub:o,email:f,nickname:E},_?.zkevm_eth_address&&_?.zkevm_user_admin_address&&(h={ethAddress:_.zkevm_eth_address,userAdminAddress:_.zkevm_user_admin_address});}catch{}return {accessToken:n,refreshToken:s,idToken:l,accessTokenExpires:ti(n),profile:u,zkEvm:h}}function ni(c){typeof window<"u"&&window.sessionStorage&&window.sessionStorage.setItem(Ne,JSON.stringify(c));}function ii(){if(typeof window<"u"&&window.sessionStorage){let c=window.sessionStorage.getItem(Ne);if(c)try{return JSON.parse(c)}catch{return null}}return null}function yt(){typeof window<"u"&&window.sessionStorage&&window.sessionStorage.removeItem(Ne);}function oi(){let c="passport-embedded-login-keyframes";if(document.getElementById(c))return;let n=document.createElement("style");n.id=c,n.textContent=`
|
|
388
|
+
@keyframes passportEmbeddedLoginPromptPopBounceIn {
|
|
389
|
+
0% {
|
|
390
|
+
opacity: 0.5;
|
|
391
|
+
}
|
|
392
|
+
50% {
|
|
393
|
+
opacity: 1;
|
|
394
|
+
transform: scale(1.05);
|
|
395
|
+
}
|
|
396
|
+
75% {
|
|
397
|
+
transform: scale(0.98);
|
|
398
|
+
}
|
|
399
|
+
100% {
|
|
400
|
+
opacity: 1;
|
|
401
|
+
transform: scale(1);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
@media (max-height: 400px) {
|
|
406
|
+
#${wt} {
|
|
407
|
+
width: 100% !important;
|
|
408
|
+
max-width: none !important;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
@keyframes passportEmbeddedLoginPromptOverlayFadeIn {
|
|
413
|
+
from {
|
|
414
|
+
opacity: 0;
|
|
415
|
+
}
|
|
416
|
+
to {
|
|
417
|
+
opacity: 1;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
`,document.head.appendChild(n);}function si(c,n){let s=getDetail(Detail.RUNTIME_ID),l=document.createElement("iframe");return l.id=wt,l.src=`${c}/im-embedded-login-prompt?client_id=${n}&rid=${s}`,l.style.height="100vh",l.style.width="100vw",l.style.maxHeight="660px",l.style.maxWidth="440px",l.style.borderRadius="16px",l.style.border="none",l.style.opacity="0",l.style.transform="scale(0.6)",l.style.animation="passportEmbeddedLoginPromptPopBounceIn 1s ease forwards",oi(),l}function ai(){let c=document.createElement("div");c.id=_t,c.style.cssText=`
|
|
421
|
+
position: fixed;
|
|
422
|
+
top: 0;
|
|
423
|
+
left: 0;
|
|
424
|
+
width: 100%;
|
|
425
|
+
height: 100%;
|
|
426
|
+
display: flex;
|
|
427
|
+
flex-direction: column;
|
|
428
|
+
justify-content: center;
|
|
429
|
+
align-items: center;
|
|
430
|
+
z-index: 2147483647;
|
|
431
|
+
background: rgba(247, 247, 247, 0.24);
|
|
432
|
+
animation-name: passportEmbeddedLoginPromptOverlayFadeIn;
|
|
433
|
+
animation-duration: 0.8s;
|
|
434
|
+
`;let n=document.createElement("div");return n.id=q,n.style.cssText=`
|
|
435
|
+
display: flex;
|
|
436
|
+
flex-direction: column;
|
|
437
|
+
align-items: center;
|
|
438
|
+
width: 100%;
|
|
439
|
+
`,c.appendChild(n),c}function pe(){document.getElementById(_t)?.remove();}function ci(c,n){return new Promise((s,l)=>{let u=si(c,n),h=ai(),o=({data:_,origin:g})=>{if(!(g!==c||_.eventType!==zn))switch(_.messageType){case"login_method_selected":{let R=_.payload;window.removeEventListener("message",o),pe(),s(R);break}case"login_prompt_error":{window.removeEventListener("message",o),pe(),l(new Error("Error during embedded login prompt",{cause:_.payload}));break}case"login_prompt_closed":{window.removeEventListener("message",o),pe(),l(new Error("Login closed by user"));break}default:window.removeEventListener("message",o),pe(),l(new Error(`Unsupported message type: ${_.messageType}`));break}},f=_=>{_.target===h&&(window.removeEventListener("message",o),h.removeEventListener("click",f),pe(),l(new Error("Login closed by user")));};window.addEventListener("message",o),h.addEventListener("click",f);let E=h.querySelector(`#${q}`);E&&E.appendChild(u),document.body.appendChild(h);})}async function Rt(c,n){let s=De(c),l=Et(),u=Ct(await ei(l)),h=Et(),o=new URL(jn,s);o.searchParams.set("response_type","code"),o.searchParams.set("code_challenge",u),o.searchParams.set("code_challenge_method","S256"),o.searchParams.set("client_id",c.clientId),o.searchParams.set("redirect_uri",c.redirectUri),o.searchParams.set("state",h),o.searchParams.set("scope",c.scope||Xn),c.audience?o.searchParams.set("audience",c.audience):o.searchParams.set("audience",qn);let f=n?.directLoginOptions;return f&&(f.directLoginMethod==="email"?f.email&&(o.searchParams.set("direct","email"),o.searchParams.set("email",f.email)):o.searchParams.set("direct",f.directLoginMethod),f.marketingConsentStatus&&o.searchParams.set("marketingConsent",f.marketingConsentStatus)),{url:o.toString(),verifier:l,state:h}}async function Tt(c,n,s,l){let h=`${De(c)}${Qn}`,o=await fetch(h,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"authorization_code",client_id:c.clientId,code_verifier:s,code:n,redirect_uri:l})});if(!o.ok){let E=await o.text(),_=`Token exchange failed with status ${o.status}`;try{let g=JSON.parse(E);g.error_description?_=g.error_description:g.error&&(_=g.error);}catch{E&&(_=E);}throw new Error(_)}let f=await o.json();return ri(f)}async function It(c,n){track("passport","standaloneLoginWithPopup");let s=c.popupRedirectUri||c.redirectUri,l={...c,redirectUri:s},{url:u,verifier:h,state:o}=await Rt(l,n);return new Promise((f,E)=>{let R=window.screenX+(window.outerWidth-500)/2,D=window.screenY+(window.outerHeight-600)/2,m=window.open(u,"immutable_login",`width=500,height=600,left=${R},top=${D},toolbar=no,menubar=no`);if(!m){E(new Error("Popup was blocked. Please allow popups for this site."));return}let y=setInterval(()=>{try{if(m.closed){clearInterval(y),E(new Error("Login popup was closed"));return}let C=m.location.href;if(C&&C.startsWith(s)){clearInterval(y),m.close();let v=new URL(C),x=v.searchParams.get("code"),A=v.searchParams.get("state"),B=v.searchParams.get("error"),M=v.searchParams.get("error_description");if(B){E(new Error(M||B));return}if(!x){E(new Error("No authorization code received"));return}if(A!==o){E(new Error("State mismatch - possible CSRF attack"));return}Tt(l,x,h,s).then(f).catch(E);}}catch{}},100);setTimeout(()=>{clearInterval(y),m.closed||m.close(),E(new Error("Login timed out"));},5*60*1e3);})}async function li(c){track("passport","standaloneLoginWithEmbedded");let n=De(c),s=await ci(n,c.clientId),l={directLoginOptions:{directLoginMethod:s.directLoginMethod,marketingConsentStatus:s.marketingConsentStatus,...s.directLoginMethod==="email"&&s.email?{email:s.email}:{}}};return It(c,l)}async function di(c,n){track("passport","standaloneLoginWithRedirect");let{url:s,verifier:l,state:u}=await Rt(c,n);ni({state:u,verifier:l,redirectUri:c.redirectUri}),window.location.href=s;}async function ui(c){if(track("passport","standaloneHandleCallback"),typeof window>"u")return;let n=new URLSearchParams(window.location.search),s=n.get("code"),l=n.get("state"),u=n.get("error"),h=n.get("error_description");if(u)throw new Error(h||u);if(!s)return;let o=ii();if(!o)throw new Error("No PKCE data found. Login may have been initiated in a different session.");if(l!==o.state)throw yt(),new Error("State mismatch - possible CSRF attack");let f=await Tt(c,s,o.verifier,o.redirectUri);return yt(),f}/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
388
440
|
|
|
389
|
-
export {
|
|
441
|
+
export { Me as Auth, ce as AuthConfiguration, xe as AuthEvents, Ee as EvmChain, tt as MarketingConsentStatus, $ as PassportError, ge as PassportErrorType, et as RollupType, ie as TypedEventEmitter, V as decodeJwtPayload, ui as handleLoginCallback, Ue as isAPIError, be as isUserZkEvm, li as loginWithEmbedded, It as loginWithPopup, di as loginWithRedirect, J as withPassportError };
|