@magic-sdk/provider 33.7.0-canary.1062.23536168311.0 → 33.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -1,6 +1,6 @@
1
- "use strict";var Gt=Object.create;var ae=Object.defineProperty;var Kt=Object.getOwnPropertyDescriptor;var jt=Object.getOwnPropertyNames;var Vt=Object.getPrototypeOf,Bt=Object.prototype.hasOwnProperty;var Ht=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),it=(r,e)=>{for(var t in e)ae(r,t,{get:e[t],enumerable:!0})},ot=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of jt(e))!Bt.call(r,s)&&s!==t&&ae(r,s,{get:()=>e[s],enumerable:!(n=Kt(e,s))||n.enumerable});return r};var Xt=(r,e,t)=>(t=r!=null?Gt(Vt(r)):{},ot(e||!r||!r.__esModule?ae(t,"default",{value:r,enumerable:!0}):t,r)),zt=r=>ot(ae({},"__esModule",{value:!0}),r);var xt=Ht((Fn,ze)=>{"use strict";var rn=Object.prototype.hasOwnProperty,b="~";function ie(){}Object.create&&(ie.prototype=Object.create(null),new ie().__proto__||(b=!1));function nn(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function Mt(r,e,t,n,s){if(typeof t!="function")throw new TypeError("The listener must be a function");var i=new nn(t,n||r,s),o=b?b+e:e;return r._events[o]?r._events[o].fn?r._events[o]=[r._events[o],i]:r._events[o].push(i):(r._events[o]=i,r._eventsCount++),r}function Ee(r,e){--r._eventsCount===0?r._events=new ie:delete r._events[e]}function P(){this._events=new ie,this._eventsCount=0}P.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)rn.call(t,n)&&e.push(b?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};P.prototype.listeners=function(e){var t=b?b+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var s=0,i=n.length,o=new Array(i);s<i;s++)o[s]=n[s].fn;return o};P.prototype.listenerCount=function(e){var t=b?b+e:e,n=this._events[t];return n?n.fn?1:n.length:0};P.prototype.emit=function(e,t,n,s,i,o){var a=b?b+e:e;if(!this._events[a])return!1;var c=this._events[a],p=arguments.length,u,h;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),p){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,s),!0;case 5:return c.fn.call(c.context,t,n,s,i),!0;case 6:return c.fn.call(c.context,t,n,s,i,o),!0}for(h=1,u=new Array(p-1);h<p;h++)u[h-1]=arguments[h];c.fn.apply(c.context,u)}else{var w=c.length,S;for(h=0;h<w;h++)switch(c[h].once&&this.removeListener(e,c[h].fn,void 0,!0),p){case 1:c[h].fn.call(c[h].context);break;case 2:c[h].fn.call(c[h].context,t);break;case 3:c[h].fn.call(c[h].context,t,n);break;case 4:c[h].fn.call(c[h].context,t,n,s);break;default:if(!u)for(S=1,u=new Array(p-1);S<p;S++)u[S-1]=arguments[S];c[h].fn.apply(c[h].context,u)}}return!0};P.prototype.on=function(e,t,n){return Mt(this,e,t,n,!1)};P.prototype.once=function(e,t,n){return Mt(this,e,t,n,!0)};P.prototype.removeListener=function(e,t,n,s){var i=b?b+e:e;if(!this._events[i])return this;if(!t)return Ee(this,i),this;var o=this._events[i];if(o.fn)o.fn===t&&(!s||o.once)&&(!n||o.context===n)&&Ee(this,i);else{for(var a=0,c=[],p=o.length;a<p;a++)(o[a].fn!==t||s&&!o[a].once||n&&o[a].context!==n)&&c.push(o[a]);c.length?this._events[i]=c.length===1?c[0]:c:Ee(this,i)}return this};P.prototype.removeAllListeners=function(e){var t;return e?(t=b?b+e:e,this._events[t]&&Ee(this,t)):(this._events=new ie,this._eventsCount=0),this};P.prototype.off=P.prototype.removeListener;P.prototype.addListener=P.prototype.on;P.prefixed=b;P.EventEmitter=P;typeof ze<"u"&&(ze.exports=P)});var gn={};it(gn,{Extension:()=>Ae,MagicExtensionError:()=>te,MagicExtensionWarning:()=>K,MagicRPCError:()=>U,MagicSDKError:()=>_,MagicSDKWarning:()=>k,MultichainExtension:()=>$e,SDKBase:()=>xe,STORE_KEY_PRIVATE_KEY:()=>ge,STORE_KEY_PUBLIC_JWK:()=>se,TypedEmitter:()=>fe,ViewController:()=>Ce,clearKeys:()=>He,createDeprecationWarning:()=>je,createDuplicateIframeWarning:()=>Ur,createExtensionNotInitializedError:()=>Ue,createIncompatibleExtensionsError:()=>Fe,createInvalidArgumentError:()=>Je,createJwt:()=>Xe,createMalformedResponseError:()=>We,createMissingApiKeyError:()=>De,createModalNotReadyError:()=>re,createPromiEvent:()=>f,createPromise:()=>B,createReactNativeEndpointConfigurationWarning:()=>Ke,createSDK:()=>Rt,createSynchronousWeb3MethodWarning:()=>Ge,createTypedEmitter:()=>oe,createURL:()=>Te,decodeJSON:()=>_e,encodeJSON:()=>ee,getPayloadId:()=>he,isEmpty:()=>G,isJsonRpcErrorCode:()=>qe,isJsonRpcRequestPayload:()=>Dr,isJsonRpcResponsePayload:()=>ke,isMagicPayloadMethod:()=>Wr,isMajorVersionAtLeast:()=>Qe,isPromiEvent:()=>Ye,isWebCryptoSupported:()=>j,storage:()=>ne,uuid:()=>Be});module.exports=zt(gn);function Yt(r){let e={exports:{}};return r(e,e.exports),e.exports}var Qt=Number.MAX_SAFE_INTEGER||9007199254740991;var Oe={SEMVER_SPEC_VERSION:"2.0.0",MAX_LENGTH:256,MAX_SAFE_INTEGER:Qt,MAX_SAFE_COMPONENT_LENGTH:16},Zt=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...r)=>console.error("SEMVER",...r):()=>{},E=Zt,Z=Yt(function(r,e){let{MAX_SAFE_COMPONENT_LENGTH:t}=Oe,n=(e=r.exports={}).re=[],s=e.src=[],i=e.t={},o=0,a=(c,p,u)=>{let h=o++;E(h,p),i[c]=h,s[h]=p,n[h]=new RegExp(p,u?"g":void 0)};a("NUMERICIDENTIFIER","0|[1-9]\\d*"),a("NUMERICIDENTIFIERLOOSE","[0-9]+"),a("NONNUMERICIDENTIFIER","\\d*[a-zA-Z-][a-zA-Z0-9-]*"),a("MAINVERSION",`(${s[i.NUMERICIDENTIFIER]})\\.(${s[i.NUMERICIDENTIFIER]})\\.(${s[i.NUMERICIDENTIFIER]})`),a("MAINVERSIONLOOSE",`(${s[i.NUMERICIDENTIFIERLOOSE]})\\.(${s[i.NUMERICIDENTIFIERLOOSE]})\\.(${s[i.NUMERICIDENTIFIERLOOSE]})`),a("PRERELEASEIDENTIFIER",`(?:${s[i.NUMERICIDENTIFIER]}|${s[i.NONNUMERICIDENTIFIER]})`),a("PRERELEASEIDENTIFIERLOOSE",`(?:${s[i.NUMERICIDENTIFIERLOOSE]}|${s[i.NONNUMERICIDENTIFIER]})`),a("PRERELEASE",`(?:-(${s[i.PRERELEASEIDENTIFIER]}(?:\\.${s[i.PRERELEASEIDENTIFIER]})*))`),a("PRERELEASELOOSE",`(?:-?(${s[i.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${s[i.PRERELEASEIDENTIFIERLOOSE]})*))`),a("BUILDIDENTIFIER","[0-9A-Za-z-]+"),a("BUILD",`(?:\\+(${s[i.BUILDIDENTIFIER]}(?:\\.${s[i.BUILDIDENTIFIER]})*))`),a("FULLPLAIN",`v?${s[i.MAINVERSION]}${s[i.PRERELEASE]}?${s[i.BUILD]}?`),a("FULL",`^${s[i.FULLPLAIN]}$`),a("LOOSEPLAIN",`[v=\\s]*${s[i.MAINVERSIONLOOSE]}${s[i.PRERELEASELOOSE]}?${s[i.BUILD]}?`),a("LOOSE",`^${s[i.LOOSEPLAIN]}$`),a("GTLT","((?:<|>)?=?)"),a("XRANGEIDENTIFIERLOOSE",`${s[i.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),a("XRANGEIDENTIFIER",`${s[i.NUMERICIDENTIFIER]}|x|X|\\*`),a("XRANGEPLAIN",`[v=\\s]*(${s[i.XRANGEIDENTIFIER]})(?:\\.(${s[i.XRANGEIDENTIFIER]})(?:\\.(${s[i.XRANGEIDENTIFIER]})(?:${s[i.PRERELEASE]})?${s[i.BUILD]}?)?)?`),a("XRANGEPLAINLOOSE",`[v=\\s]*(${s[i.XRANGEIDENTIFIERLOOSE]})(?:\\.(${s[i.XRANGEIDENTIFIERLOOSE]})(?:\\.(${s[i.XRANGEIDENTIFIERLOOSE]})(?:${s[i.PRERELEASELOOSE]})?${s[i.BUILD]}?)?)?`),a("XRANGE",`^${s[i.GTLT]}\\s*${s[i.XRANGEPLAIN]}$`),a("XRANGELOOSE",`^${s[i.GTLT]}\\s*${s[i.XRANGEPLAINLOOSE]}$`),a("COERCE",`(^|[^\\d])(\\d{1,${t}})(?:\\.(\\d{1,${t}}))?(?:\\.(\\d{1,${t}}))?(?:$|[^\\d])`),a("COERCERTL",s[i.COERCE],!0),a("LONETILDE","(?:~>?)"),a("TILDETRIM",`(\\s*)${s[i.LONETILDE]}\\s+`,!0),e.tildeTrimReplace="$1~",a("TILDE",`^${s[i.LONETILDE]}${s[i.XRANGEPLAIN]}$`),a("TILDELOOSE",`^${s[i.LONETILDE]}${s[i.XRANGEPLAINLOOSE]}$`),a("LONECARET","(?:\\^)"),a("CARETTRIM",`(\\s*)${s[i.LONECARET]}\\s+`,!0),e.caretTrimReplace="$1^",a("CARET",`^${s[i.LONECARET]}${s[i.XRANGEPLAIN]}$`),a("CARETLOOSE",`^${s[i.LONECARET]}${s[i.XRANGEPLAINLOOSE]}$`),a("COMPARATORLOOSE",`^${s[i.GTLT]}\\s*(${s[i.LOOSEPLAIN]})$|^$`),a("COMPARATOR",`^${s[i.GTLT]}\\s*(${s[i.FULLPLAIN]})$|^$`),a("COMPARATORTRIM",`(\\s*)${s[i.GTLT]}\\s*(${s[i.LOOSEPLAIN]}|${s[i.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace="$1$2$3",a("HYPHENRANGE",`^\\s*(${s[i.XRANGEPLAIN]})\\s+-\\s+(${s[i.XRANGEPLAIN]})\\s*$`),a("HYPHENRANGELOOSE",`^\\s*(${s[i.XRANGEPLAINLOOSE]})\\s+-\\s+(${s[i.XRANGEPLAINLOOSE]})\\s*$`),a("STAR","(<|>)?=?\\s*\\*"),a("GTE0","^\\s*>=\\s*0.0.0\\s*$"),a("GTE0PRE","^\\s*>=\\s*0.0.0-0\\s*$")}),at=/^[0-9]+$/,Et=(r,e)=>{let t=at.test(r),n=at.test(e);return t&&n&&(r=+r,e=+e),r===e?0:t&&!n?-1:n&&!t?1:r<e?-1:1},er=(r,e)=>Et(e,r),tr={compareIdentifiers:Et,rcompareIdentifiers:er},{MAX_LENGTH:ct,MAX_SAFE_INTEGER:ce}=Oe,{re:lt,t:dt}=Z,{compareIdentifiers:X}=tr,A=class r{constructor(e,t){if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),e instanceof r){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;e=e.version}else if(typeof e!="string")throw new TypeError(`Invalid Version: ${e}`);if(e.length>ct)throw new TypeError(`version is longer than ${ct} characters`);E("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;let n=e.trim().match(t.loose?lt[dt.LOOSE]:lt[dt.FULL]);if(!n)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+n[1],this.minor=+n[2],this.patch=+n[3],this.major>ce||this.major<0)throw new TypeError("Invalid major version");if(this.minor>ce||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>ce||this.patch<0)throw new TypeError("Invalid patch version");n[4]?this.prerelease=n[4].split(".").map(s=>{if(/^[0-9]+$/.test(s)){let i=+s;if(i>=0&&i<ce)return i}return s}):this.prerelease=[],this.build=n[5]?n[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(e){if(E("SemVer.compare",this.version,this.options,e),!(e instanceof r)){if(typeof e=="string"&&e===this.version)return 0;e=new r(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof r||(e=new r(e,this.options)),X(this.major,e.major)||X(this.minor,e.minor)||X(this.patch,e.patch)}comparePre(e){if(e instanceof r||(e=new r(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let t=0;do{let n=this.prerelease[t],s=e.prerelease[t];if(E("prerelease compare",t,n,s),n===void 0&&s===void 0)return 0;if(s===void 0)return 1;if(n===void 0)return-1;if(n!==s)return X(n,s)}while(++t)}compareBuild(e){e instanceof r||(e=new r(e,this.options));let t=0;do{let n=this.build[t],s=e.build[t];if(E("prerelease compare",t,n,s),n===void 0&&s===void 0)return 0;if(s===void 0)return 1;if(n===void 0)return-1;if(n!==s)return X(n,s)}while(++t)}inc(e,t){switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t),this.inc("pre",t);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",t),this.inc("pre",t);break;case"major":this.minor===0&&this.patch===0&&this.prerelease.length!==0||this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":this.patch===0&&this.prerelease.length!==0||this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":if(this.prerelease.length===0)this.prerelease=[0];else{let n=this.prerelease.length;for(;--n>=0;)typeof this.prerelease[n]=="number"&&(this.prerelease[n]++,n=-2);n===-1&&this.prerelease.push(0)}t&&(this.prerelease[0]===t?isNaN(this.prerelease[1])&&(this.prerelease=[t,0]):this.prerelease=[t,0]);break;default:throw new Error(`invalid increment argument: ${e}`)}return this.format(),this.raw=this.version,this}},rr=(r,e,t)=>new A(r,t).compare(new A(e,t)),J=rr,nr=(r,e,t)=>J(r,e,t)===0,sr=nr,ir=(r,e,t)=>J(r,e,t)!==0,or=ir,ar=(r,e,t)=>J(r,e,t)>0,cr=ar,lr=(r,e,t)=>J(r,e,t)>=0,dr=lr,ur=(r,e,t)=>J(r,e,t)<0,pr=ur,hr=(r,e,t)=>J(r,e,t)<=0,mr=hr,gr=(r,e,t,n)=>{switch(e){case"===":return typeof r=="object"&&(r=r.version),typeof t=="object"&&(t=t.version),r===t;case"!==":return typeof r=="object"&&(r=r.version),typeof t=="object"&&(t=t.version),r!==t;case"":case"=":case"==":return sr(r,t,n);case"!=":return or(r,t,n);case">":return cr(r,t,n);case">=":return dr(r,t,n);case"<":return pr(r,t,n);case"<=":return mr(r,t,n);default:throw new TypeError(`Invalid operator: ${e}`)}},Le=gr,z=Symbol("SemVer ANY"),Y=class r{static get ANY(){return z}constructor(e,t){if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),e instanceof r){if(e.loose===!!t.loose)return e;e=e.value}E("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===z?this.value="":this.value=this.operator+this.semver.version,E("comp",this)}parse(e){let t=this.options.loose?ut[pt.COMPARATORLOOSE]:ut[pt.COMPARATOR],n=e.match(t);if(!n)throw new TypeError(`Invalid comparator: ${e}`);this.operator=n[1]!==void 0?n[1]:"",this.operator==="="&&(this.operator=""),n[2]?this.semver=new A(n[2],this.options.loose):this.semver=z}toString(){return this.value}test(e){if(E("Comparator.test",e,this.options.loose),this.semver===z||e===z)return!0;if(typeof e=="string")try{e=new A(e,this.options)}catch{return!1}return Le(e,this.operator,this.semver,this.options)}intersects(e,t){if(!(e instanceof r))throw new TypeError("a Comparator is required");if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),this.operator==="")return this.value===""||new Q(e.value,t).test(this.value);if(e.operator==="")return e.value===""||new Q(this.value,t).test(e.semver);let n=!(this.operator!==">="&&this.operator!==">"||e.operator!==">="&&e.operator!==">"),s=!(this.operator!=="<="&&this.operator!=="<"||e.operator!=="<="&&e.operator!=="<"),i=this.semver.version===e.semver.version,o=!(this.operator!==">="&&this.operator!=="<="||e.operator!==">="&&e.operator!=="<="),a=Le(this.semver,"<",e.semver,t)&&(this.operator===">="||this.operator===">")&&(e.operator==="<="||e.operator==="<"),c=Le(this.semver,">",e.semver,t)&&(this.operator==="<="||this.operator==="<")&&(e.operator===">="||e.operator===">");return n||s||i&&o||a||c}},{re:ut,t:pt}=Z,Q=class r{constructor(e,t){if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),e instanceof r)return e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease?e:new r(e.raw,t);if(e instanceof Y)return this.raw=e.value,this.set=[[e]],this.format(),this;if(this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease,this.raw=e,this.set=e.split(/\s*\|\|\s*/).map(n=>this.parseRange(n.trim())).filter(n=>n.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${e}`);this.format()}format(){return this.range=this.set.map(e=>e.join(" ").trim()).join("||").trim(),this.range}toString(){return this.range}parseRange(e){let{loose:t}=this.options;e=e.trim();let n=t?v[y.HYPHENRANGELOOSE]:v[y.HYPHENRANGE];e=e.replace(n,xr(this.options.includePrerelease)),E("hyphen replace",e),e=e.replace(v[y.COMPARATORTRIM],Er),E("comparator trim",e,v[y.COMPARATORTRIM]),e=(e=(e=e.replace(v[y.TILDETRIM],fr)).replace(v[y.CARETTRIM],yr)).split(/\s+/).join(" ");let s=t?v[y.COMPARATORLOOSE]:v[y.COMPARATOR];return e.split(" ").map(i=>Rr(i,this.options)).join(" ").split(/\s+/).map(i=>Mr(i,this.options)).filter(this.options.loose?i=>!!i.match(s):()=>!0).map(i=>new Y(i,this.options))}intersects(e,t){if(!(e instanceof r))throw new TypeError("a Range is required");return this.set.some(n=>ht(n,t)&&e.set.some(s=>ht(s,t)&&n.every(i=>s.every(o=>i.intersects(o,t)))))}test(e){if(!e)return!1;if(typeof e=="string")try{e=new A(e,this.options)}catch{return!1}for(let t=0;t<this.set.length;t++)if(Cr(this.set[t],e,this.options))return!0;return!1}},{re:v,t:y,comparatorTrimReplace:Er,tildeTrimReplace:fr,caretTrimReplace:yr}=Z,ht=(r,e)=>{let t=!0,n=r.slice(),s=n.pop();for(;t&&n.length;)t=n.every(i=>s.intersects(i,e)),s=n.pop();return t},Rr=(r,e)=>(E("comp",r,e),r=Pr(r,e),E("caret",r),r=vr(r,e),E("tildes",r),r=br(r,e),E("xrange",r),r=Sr(r,e),E("stars",r),r),I=r=>!r||r.toLowerCase()==="x"||r==="*",vr=(r,e)=>r.trim().split(/\s+/).map(t=>Tr(t,e)).join(" "),Tr=(r,e)=>{let t=e.loose?v[y.TILDELOOSE]:v[y.TILDE];return r.replace(t,(n,s,i,o,a)=>{let c;return E("tilde",r,n,s,i,o,a),I(s)?c="":I(i)?c=`>=${s}.0.0 <${+s+1}.0.0-0`:I(o)?c=`>=${s}.${i}.0 <${s}.${+i+1}.0-0`:a?(E("replaceTilde pr",a),c=`>=${s}.${i}.${o}-${a} <${s}.${+i+1}.0-0`):c=`>=${s}.${i}.${o} <${s}.${+i+1}.0-0`,E("tilde return",c),c})},Pr=(r,e)=>r.trim().split(/\s+/).map(t=>Ir(t,e)).join(" "),Ir=(r,e)=>{E("caret",r,e);let t=e.loose?v[y.CARETLOOSE]:v[y.CARET],n=e.includePrerelease?"-0":"";return r.replace(t,(s,i,o,a,c)=>{let p;return E("caret",r,s,i,o,a,c),I(i)?p="":I(o)?p=`>=${i}.0.0${n} <${+i+1}.0.0-0`:I(a)?p=i==="0"?`>=${i}.${o}.0${n} <${i}.${+o+1}.0-0`:`>=${i}.${o}.0${n} <${+i+1}.0.0-0`:c?(E("replaceCaret pr",c),p=i==="0"?o==="0"?`>=${i}.${o}.${a}-${c} <${i}.${o}.${+a+1}-0`:`>=${i}.${o}.${a}-${c} <${i}.${+o+1}.0-0`:`>=${i}.${o}.${a}-${c} <${+i+1}.0.0-0`):(E("no pr"),p=i==="0"?o==="0"?`>=${i}.${o}.${a}${n} <${i}.${o}.${+a+1}-0`:`>=${i}.${o}.${a}${n} <${i}.${+o+1}.0-0`:`>=${i}.${o}.${a} <${+i+1}.0.0-0`),E("caret return",p),p})},br=(r,e)=>(E("replaceXRanges",r,e),r.split(/\s+/).map(t=>wr(t,e)).join(" ")),wr=(r,e)=>{r=r.trim();let t=e.loose?v[y.XRANGELOOSE]:v[y.XRANGE];return r.replace(t,(n,s,i,o,a,c)=>{E("xRange",r,n,s,i,o,a,c);let p=I(i),u=p||I(o),h=u||I(a),w=h;return s==="="&&w&&(s=""),c=e.includePrerelease?"-0":"",p?n=s===">"||s==="<"?"<0.0.0-0":"*":s&&w?(u&&(o=0),a=0,s===">"?(s=">=",u?(i=+i+1,o=0,a=0):(o=+o+1,a=0)):s==="<="&&(s="<",u?i=+i+1:o=+o+1),s==="<"&&(c="-0"),n=`${s+i}.${o}.${a}${c}`):u?n=`>=${i}.0.0${c} <${+i+1}.0.0-0`:h&&(n=`>=${i}.${o}.0${c} <${i}.${+o+1}.0-0`),E("xRange return",n),n})},Sr=(r,e)=>(E("replaceStars",r,e),r.trim().replace(v[y.STAR],"")),Mr=(r,e)=>(E("replaceGTE0",r,e),r.trim().replace(v[e.includePrerelease?y.GTE0PRE:y.GTE0],"")),xr=r=>(e,t,n,s,i,o,a,c,p,u,h,w,S)=>`${t=I(n)?"":I(s)?`>=${n}.0.0${r?"-0":""}`:I(i)?`>=${n}.${s}.0${r?"-0":""}`:o?`>=${t}`:`>=${t}${r?"-0":""}`} ${c=I(p)?"":I(u)?`<${+p+1}.0.0-0`:I(h)?`<${p}.${+u+1}.0-0`:w?`<=${p}.${u}.${h}-${w}`:r?`<${p}.${u}.${+h+1}-0`:`<=${c}`}`.trim(),Cr=(r,e,t)=>{for(let n=0;n<r.length;n++)if(!r[n].test(e))return!1;if(e.prerelease.length&&!t.includePrerelease){for(let n=0;n<r.length;n++)if(E(r[n].semver),r[n].semver!==Y.ANY&&r[n].semver.prerelease.length>0){let s=r[n].semver;if(s.major===e.major&&s.minor===e.minor&&s.patch===e.patch)return!0}return!1}return!0},ft=(r,e,t)=>{try{e=new Q(e,t)}catch{return!1}return e.test(r)};var{MAX_LENGTH:Nr}=Oe,{re:mt,t:gt}=Z,Ar=(r,e)=>{if(e&&typeof e=="object"||(e={loose:!!e,includePrerelease:!1}),r instanceof A)return r;if(typeof r!="string"||r.length>Nr||!(e.loose?mt[gt.LOOSE]:mt[gt.FULL]).test(r))return null;try{return new A(r,e)}catch{return null}},$r=Ar,{re:le,t:de}=Z,yt=(r,e)=>{if(r instanceof A)return r;if(typeof r=="number"&&(r=String(r)),typeof r!="string")return null;let t=null;if((e=e||{}).rtl){let n;for(;(n=le[de.COERCERTL].exec(r))&&(!t||t.index+t[0].length!==r.length);)t&&n.index+n[0].length===t.index+t[0].length||(t=n),le[de.COERCERTL].lastIndex=n.index+n[1].length+n[2].length;le[de.COERCERTL].lastIndex=-1}else t=r.match(le[de.COERCE]);return t===null?null:$r(`${t[2]}.${t[3]||"0"}.${t[4]||"0"}`,e)};function Lr(r){return String.fromCharCode(parseInt(r.slice(1),16))}function Or(r){return`%${`00${r.charCodeAt(0).toString(16)}`.slice(-2)}`}function _r(r){return btoa(encodeURIComponent(r).replace(/%[0-9A-F]{2}/g,Lr))}function kr(r){return decodeURIComponent(Array.from(atob(r),Or).join(""))}function ee(r){return _r(JSON.stringify(r))}function _e(r){return JSON.parse(kr(r))}var M=require("@magic-sdk/types");var ue=require("@magic-sdk/types");function O(r){return typeof r>"u"}function qr(r){return r===null}function pe(r){return qr(r)||O(r)}function Dr(r){return pe(r)?!1:!O(r.jsonrpc)&&!O(r.id)&&!O(r.method)&&!O(r.params)}function ke(r){return pe(r)?!1:!O(r.jsonrpc)&&!O(r.id)&&(!O(r.result)||!O(r.error))}function Wr(r){return pe(r)?!1:typeof r=="string"&&Object.values(ue.MagicPayloadMethod).includes(r)}function qe(r){return pe(r)?!1:typeof r=="number"&&Object.values(ue.RPCErrorCode).includes(r)}function G(r){if(!r)return!0;for(let e in r)if(Object.hasOwnProperty.call(r,e))return!1;return!0}var g={};function Rt(r,e){return Object.assign(g,e),r}var vt={"magic-sdk":"magic-sdk","@magic-sdk/react-native":"magic-sdk-rn","@magic-sdk/react-native-bare":"magic-sdk-rn-bare","@magic-sdk/react-native-expo":"magic-sdk-rn-expo"};var _=class r extends Error{constructor(t,n){super(`Magic SDK Error: [${t}] ${n}`);this.code=t;this.rawMessage=n;Object.setPrototypeOf(this,r.prototype)}__proto__=Error},U=class r extends Error{__proto__=Error;code;rawMessage;data;constructor(e){super();let t=Number(e?.code);this.rawMessage=e?.message||"Internal error",this.code=qe(t)?t:M.RPCErrorCode.InternalError,this.message=`Magic RPC Error: [${this.code}] ${this.rawMessage}`,this.data=e?.data||void 0,Object.setPrototypeOf(this,r.prototype)}},k=class{constructor(e,t){this.code=e;this.rawMessage=t;this.message=`Magic SDK Warning: [${e}] ${t}`}message;log(){console.warn(this.message)}},te=class r extends Error{constructor(t,n,s,i){super(`Magic Extension Error (${t.name}): [${n}] ${s}`);this.code=n;this.rawMessage=s;this.data=i;Object.setPrototypeOf(this,r.prototype)}__proto__=Error},K=class{constructor(e,t,n){this.code=t;this.rawMessage=n;this.message=`Magic Extension Warning (${e.name}): [${t}] ${n}`}message;log(){console.warn(this.message)}};function De(){return new _(M.SDKErrorCode.MissingApiKey,"Please provide an API key that you acquired from the Magic developer dashboard.")}function re(){return new _(M.SDKErrorCode.ModalNotReady,"Modal is not ready")}function We(){return new _(M.SDKErrorCode.MalformedResponse,"Response from the Magic iframe is malformed.")}function Ue(r){return new _(M.SDKErrorCode.ExtensionNotInitialized,`Extensions must be initialized with a Magic SDK instance before \`Extension.${r}\` can be accessed. Do not invoke \`Extension.${r}\` inside an extension constructor.`)}function Fe(r){let e=`Some extensions are incompatible with \`${g.sdkName}@${g.version}\`:`;return r.filter(t=>typeof t.compat<"u"&&t.compat!==null).forEach(t=>{let n=t.compat[g.sdkName];typeof n=="string"?e+=`
1
+ "use strict";var Kt=Object.create;var ae=Object.defineProperty;var Gt=Object.getOwnPropertyDescriptor;var jt=Object.getOwnPropertyNames;var Vt=Object.getPrototypeOf,Bt=Object.prototype.hasOwnProperty;var Ht=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),it=(r,e)=>{for(var t in e)ae(r,t,{get:e[t],enumerable:!0})},ot=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of jt(e))!Bt.call(r,s)&&s!==t&&ae(r,s,{get:()=>e[s],enumerable:!(n=Gt(e,s))||n.enumerable});return r};var Xt=(r,e,t)=>(t=r!=null?Kt(Vt(r)):{},ot(e||!r||!r.__esModule?ae(t,"default",{value:r,enumerable:!0}):t,r)),zt=r=>ot(ae({},"__esModule",{value:!0}),r);var xt=Ht((Fn,ze)=>{"use strict";var rn=Object.prototype.hasOwnProperty,I="~";function ie(){}Object.create&&(ie.prototype=Object.create(null),new ie().__proto__||(I=!1));function nn(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function Mt(r,e,t,n,s){if(typeof t!="function")throw new TypeError("The listener must be a function");var i=new nn(t,n||r,s),o=I?I+e:e;return r._events[o]?r._events[o].fn?r._events[o]=[r._events[o],i]:r._events[o].push(i):(r._events[o]=i,r._eventsCount++),r}function Ee(r,e){--r._eventsCount===0?r._events=new ie:delete r._events[e]}function T(){this._events=new ie,this._eventsCount=0}T.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)rn.call(t,n)&&e.push(I?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};T.prototype.listeners=function(e){var t=I?I+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var s=0,i=n.length,o=new Array(i);s<i;s++)o[s]=n[s].fn;return o};T.prototype.listenerCount=function(e){var t=I?I+e:e,n=this._events[t];return n?n.fn?1:n.length:0};T.prototype.emit=function(e,t,n,s,i,o){var a=I?I+e:e;if(!this._events[a])return!1;var c=this._events[a],p=arguments.length,u,h;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),p){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,s),!0;case 5:return c.fn.call(c.context,t,n,s,i),!0;case 6:return c.fn.call(c.context,t,n,s,i,o),!0}for(h=1,u=new Array(p-1);h<p;h++)u[h-1]=arguments[h];c.fn.apply(c.context,u)}else{var b=c.length,w;for(h=0;h<b;h++)switch(c[h].once&&this.removeListener(e,c[h].fn,void 0,!0),p){case 1:c[h].fn.call(c[h].context);break;case 2:c[h].fn.call(c[h].context,t);break;case 3:c[h].fn.call(c[h].context,t,n);break;case 4:c[h].fn.call(c[h].context,t,n,s);break;default:if(!u)for(w=1,u=new Array(p-1);w<p;w++)u[w-1]=arguments[w];c[h].fn.apply(c[h].context,u)}}return!0};T.prototype.on=function(e,t,n){return Mt(this,e,t,n,!1)};T.prototype.once=function(e,t,n){return Mt(this,e,t,n,!0)};T.prototype.removeListener=function(e,t,n,s){var i=I?I+e:e;if(!this._events[i])return this;if(!t)return Ee(this,i),this;var o=this._events[i];if(o.fn)o.fn===t&&(!s||o.once)&&(!n||o.context===n)&&Ee(this,i);else{for(var a=0,c=[],p=o.length;a<p;a++)(o[a].fn!==t||s&&!o[a].once||n&&o[a].context!==n)&&c.push(o[a]);c.length?this._events[i]=c.length===1?c[0]:c:Ee(this,i)}return this};T.prototype.removeAllListeners=function(e){var t;return e?(t=I?I+e:e,this._events[t]&&Ee(this,t)):(this._events=new ie,this._eventsCount=0),this};T.prototype.off=T.prototype.removeListener;T.prototype.addListener=T.prototype.on;T.prefixed=I;T.EventEmitter=T;typeof ze<"u"&&(ze.exports=T)});var gn={};it(gn,{Extension:()=>Ae,MagicExtensionError:()=>te,MagicExtensionWarning:()=>G,MagicRPCError:()=>U,MagicSDKError:()=>_,MagicSDKWarning:()=>D,MultichainExtension:()=>$e,SDKBase:()=>xe,STORE_KEY_PRIVATE_KEY:()=>ge,STORE_KEY_PUBLIC_JWK:()=>se,TypedEmitter:()=>fe,ViewController:()=>Ce,clearKeys:()=>He,createDeprecationWarning:()=>je,createDuplicateIframeWarning:()=>Ur,createExtensionNotInitializedError:()=>Ue,createIncompatibleExtensionsError:()=>Fe,createInvalidArgumentError:()=>Je,createJwt:()=>Xe,createMalformedResponseError:()=>We,createMissingApiKeyError:()=>ke,createModalNotReadyError:()=>re,createPromiEvent:()=>M,createPromise:()=>B,createReactNativeEndpointConfigurationWarning:()=>Ge,createSDK:()=>Rt,createSynchronousWeb3MethodWarning:()=>Ke,createTypedEmitter:()=>oe,createURL:()=>Te,decodeJSON:()=>_e,encodeJSON:()=>ee,getPayloadId:()=>he,isEmpty:()=>K,isJsonRpcErrorCode:()=>qe,isJsonRpcRequestPayload:()=>kr,isJsonRpcResponsePayload:()=>De,isMagicPayloadMethod:()=>Wr,isMajorVersionAtLeast:()=>Qe,isPromiEvent:()=>Ye,isWebCryptoSupported:()=>j,storage:()=>ne,uuid:()=>Be});module.exports=zt(gn);function Yt(r){let e={exports:{}};return r(e,e.exports),e.exports}var Qt=Number.MAX_SAFE_INTEGER||9007199254740991;var Le={SEMVER_SPEC_VERSION:"2.0.0",MAX_LENGTH:256,MAX_SAFE_INTEGER:Qt,MAX_SAFE_COMPONENT_LENGTH:16},Zt=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...r)=>console.error("SEMVER",...r):()=>{},E=Zt,Z=Yt(function(r,e){let{MAX_SAFE_COMPONENT_LENGTH:t}=Le,n=(e=r.exports={}).re=[],s=e.src=[],i=e.t={},o=0,a=(c,p,u)=>{let h=o++;E(h,p),i[c]=h,s[h]=p,n[h]=new RegExp(p,u?"g":void 0)};a("NUMERICIDENTIFIER","0|[1-9]\\d*"),a("NUMERICIDENTIFIERLOOSE","[0-9]+"),a("NONNUMERICIDENTIFIER","\\d*[a-zA-Z-][a-zA-Z0-9-]*"),a("MAINVERSION",`(${s[i.NUMERICIDENTIFIER]})\\.(${s[i.NUMERICIDENTIFIER]})\\.(${s[i.NUMERICIDENTIFIER]})`),a("MAINVERSIONLOOSE",`(${s[i.NUMERICIDENTIFIERLOOSE]})\\.(${s[i.NUMERICIDENTIFIERLOOSE]})\\.(${s[i.NUMERICIDENTIFIERLOOSE]})`),a("PRERELEASEIDENTIFIER",`(?:${s[i.NUMERICIDENTIFIER]}|${s[i.NONNUMERICIDENTIFIER]})`),a("PRERELEASEIDENTIFIERLOOSE",`(?:${s[i.NUMERICIDENTIFIERLOOSE]}|${s[i.NONNUMERICIDENTIFIER]})`),a("PRERELEASE",`(?:-(${s[i.PRERELEASEIDENTIFIER]}(?:\\.${s[i.PRERELEASEIDENTIFIER]})*))`),a("PRERELEASELOOSE",`(?:-?(${s[i.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${s[i.PRERELEASEIDENTIFIERLOOSE]})*))`),a("BUILDIDENTIFIER","[0-9A-Za-z-]+"),a("BUILD",`(?:\\+(${s[i.BUILDIDENTIFIER]}(?:\\.${s[i.BUILDIDENTIFIER]})*))`),a("FULLPLAIN",`v?${s[i.MAINVERSION]}${s[i.PRERELEASE]}?${s[i.BUILD]}?`),a("FULL",`^${s[i.FULLPLAIN]}$`),a("LOOSEPLAIN",`[v=\\s]*${s[i.MAINVERSIONLOOSE]}${s[i.PRERELEASELOOSE]}?${s[i.BUILD]}?`),a("LOOSE",`^${s[i.LOOSEPLAIN]}$`),a("GTLT","((?:<|>)?=?)"),a("XRANGEIDENTIFIERLOOSE",`${s[i.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),a("XRANGEIDENTIFIER",`${s[i.NUMERICIDENTIFIER]}|x|X|\\*`),a("XRANGEPLAIN",`[v=\\s]*(${s[i.XRANGEIDENTIFIER]})(?:\\.(${s[i.XRANGEIDENTIFIER]})(?:\\.(${s[i.XRANGEIDENTIFIER]})(?:${s[i.PRERELEASE]})?${s[i.BUILD]}?)?)?`),a("XRANGEPLAINLOOSE",`[v=\\s]*(${s[i.XRANGEIDENTIFIERLOOSE]})(?:\\.(${s[i.XRANGEIDENTIFIERLOOSE]})(?:\\.(${s[i.XRANGEIDENTIFIERLOOSE]})(?:${s[i.PRERELEASELOOSE]})?${s[i.BUILD]}?)?)?`),a("XRANGE",`^${s[i.GTLT]}\\s*${s[i.XRANGEPLAIN]}$`),a("XRANGELOOSE",`^${s[i.GTLT]}\\s*${s[i.XRANGEPLAINLOOSE]}$`),a("COERCE",`(^|[^\\d])(\\d{1,${t}})(?:\\.(\\d{1,${t}}))?(?:\\.(\\d{1,${t}}))?(?:$|[^\\d])`),a("COERCERTL",s[i.COERCE],!0),a("LONETILDE","(?:~>?)"),a("TILDETRIM",`(\\s*)${s[i.LONETILDE]}\\s+`,!0),e.tildeTrimReplace="$1~",a("TILDE",`^${s[i.LONETILDE]}${s[i.XRANGEPLAIN]}$`),a("TILDELOOSE",`^${s[i.LONETILDE]}${s[i.XRANGEPLAINLOOSE]}$`),a("LONECARET","(?:\\^)"),a("CARETTRIM",`(\\s*)${s[i.LONECARET]}\\s+`,!0),e.caretTrimReplace="$1^",a("CARET",`^${s[i.LONECARET]}${s[i.XRANGEPLAIN]}$`),a("CARETLOOSE",`^${s[i.LONECARET]}${s[i.XRANGEPLAINLOOSE]}$`),a("COMPARATORLOOSE",`^${s[i.GTLT]}\\s*(${s[i.LOOSEPLAIN]})$|^$`),a("COMPARATOR",`^${s[i.GTLT]}\\s*(${s[i.FULLPLAIN]})$|^$`),a("COMPARATORTRIM",`(\\s*)${s[i.GTLT]}\\s*(${s[i.LOOSEPLAIN]}|${s[i.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace="$1$2$3",a("HYPHENRANGE",`^\\s*(${s[i.XRANGEPLAIN]})\\s+-\\s+(${s[i.XRANGEPLAIN]})\\s*$`),a("HYPHENRANGELOOSE",`^\\s*(${s[i.XRANGEPLAINLOOSE]})\\s+-\\s+(${s[i.XRANGEPLAINLOOSE]})\\s*$`),a("STAR","(<|>)?=?\\s*\\*"),a("GTE0","^\\s*>=\\s*0.0.0\\s*$"),a("GTE0PRE","^\\s*>=\\s*0.0.0-0\\s*$")}),at=/^[0-9]+$/,Et=(r,e)=>{let t=at.test(r),n=at.test(e);return t&&n&&(r=+r,e=+e),r===e?0:t&&!n?-1:n&&!t?1:r<e?-1:1},er=(r,e)=>Et(e,r),tr={compareIdentifiers:Et,rcompareIdentifiers:er},{MAX_LENGTH:ct,MAX_SAFE_INTEGER:ce}=Le,{re:lt,t:dt}=Z,{compareIdentifiers:X}=tr,A=class r{constructor(e,t){if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),e instanceof r){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;e=e.version}else if(typeof e!="string")throw new TypeError(`Invalid Version: ${e}`);if(e.length>ct)throw new TypeError(`version is longer than ${ct} characters`);E("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;let n=e.trim().match(t.loose?lt[dt.LOOSE]:lt[dt.FULL]);if(!n)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+n[1],this.minor=+n[2],this.patch=+n[3],this.major>ce||this.major<0)throw new TypeError("Invalid major version");if(this.minor>ce||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>ce||this.patch<0)throw new TypeError("Invalid patch version");n[4]?this.prerelease=n[4].split(".").map(s=>{if(/^[0-9]+$/.test(s)){let i=+s;if(i>=0&&i<ce)return i}return s}):this.prerelease=[],this.build=n[5]?n[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(e){if(E("SemVer.compare",this.version,this.options,e),!(e instanceof r)){if(typeof e=="string"&&e===this.version)return 0;e=new r(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof r||(e=new r(e,this.options)),X(this.major,e.major)||X(this.minor,e.minor)||X(this.patch,e.patch)}comparePre(e){if(e instanceof r||(e=new r(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let t=0;do{let n=this.prerelease[t],s=e.prerelease[t];if(E("prerelease compare",t,n,s),n===void 0&&s===void 0)return 0;if(s===void 0)return 1;if(n===void 0)return-1;if(n!==s)return X(n,s)}while(++t)}compareBuild(e){e instanceof r||(e=new r(e,this.options));let t=0;do{let n=this.build[t],s=e.build[t];if(E("prerelease compare",t,n,s),n===void 0&&s===void 0)return 0;if(s===void 0)return 1;if(n===void 0)return-1;if(n!==s)return X(n,s)}while(++t)}inc(e,t){switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t),this.inc("pre",t);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",t),this.inc("pre",t);break;case"major":this.minor===0&&this.patch===0&&this.prerelease.length!==0||this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":this.patch===0&&this.prerelease.length!==0||this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":if(this.prerelease.length===0)this.prerelease=[0];else{let n=this.prerelease.length;for(;--n>=0;)typeof this.prerelease[n]=="number"&&(this.prerelease[n]++,n=-2);n===-1&&this.prerelease.push(0)}t&&(this.prerelease[0]===t?isNaN(this.prerelease[1])&&(this.prerelease=[t,0]):this.prerelease=[t,0]);break;default:throw new Error(`invalid increment argument: ${e}`)}return this.format(),this.raw=this.version,this}},rr=(r,e,t)=>new A(r,t).compare(new A(e,t)),J=rr,nr=(r,e,t)=>J(r,e,t)===0,sr=nr,ir=(r,e,t)=>J(r,e,t)!==0,or=ir,ar=(r,e,t)=>J(r,e,t)>0,cr=ar,lr=(r,e,t)=>J(r,e,t)>=0,dr=lr,ur=(r,e,t)=>J(r,e,t)<0,pr=ur,hr=(r,e,t)=>J(r,e,t)<=0,mr=hr,gr=(r,e,t,n)=>{switch(e){case"===":return typeof r=="object"&&(r=r.version),typeof t=="object"&&(t=t.version),r===t;case"!==":return typeof r=="object"&&(r=r.version),typeof t=="object"&&(t=t.version),r!==t;case"":case"=":case"==":return sr(r,t,n);case"!=":return or(r,t,n);case">":return cr(r,t,n);case">=":return dr(r,t,n);case"<":return pr(r,t,n);case"<=":return mr(r,t,n);default:throw new TypeError(`Invalid operator: ${e}`)}},Oe=gr,z=Symbol("SemVer ANY"),Y=class r{static get ANY(){return z}constructor(e,t){if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),e instanceof r){if(e.loose===!!t.loose)return e;e=e.value}E("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===z?this.value="":this.value=this.operator+this.semver.version,E("comp",this)}parse(e){let t=this.options.loose?ut[pt.COMPARATORLOOSE]:ut[pt.COMPARATOR],n=e.match(t);if(!n)throw new TypeError(`Invalid comparator: ${e}`);this.operator=n[1]!==void 0?n[1]:"",this.operator==="="&&(this.operator=""),n[2]?this.semver=new A(n[2],this.options.loose):this.semver=z}toString(){return this.value}test(e){if(E("Comparator.test",e,this.options.loose),this.semver===z||e===z)return!0;if(typeof e=="string")try{e=new A(e,this.options)}catch{return!1}return Oe(e,this.operator,this.semver,this.options)}intersects(e,t){if(!(e instanceof r))throw new TypeError("a Comparator is required");if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),this.operator==="")return this.value===""||new Q(e.value,t).test(this.value);if(e.operator==="")return e.value===""||new Q(this.value,t).test(e.semver);let n=!(this.operator!==">="&&this.operator!==">"||e.operator!==">="&&e.operator!==">"),s=!(this.operator!=="<="&&this.operator!=="<"||e.operator!=="<="&&e.operator!=="<"),i=this.semver.version===e.semver.version,o=!(this.operator!==">="&&this.operator!=="<="||e.operator!==">="&&e.operator!=="<="),a=Oe(this.semver,"<",e.semver,t)&&(this.operator===">="||this.operator===">")&&(e.operator==="<="||e.operator==="<"),c=Oe(this.semver,">",e.semver,t)&&(this.operator==="<="||this.operator==="<")&&(e.operator===">="||e.operator===">");return n||s||i&&o||a||c}},{re:ut,t:pt}=Z,Q=class r{constructor(e,t){if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),e instanceof r)return e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease?e:new r(e.raw,t);if(e instanceof Y)return this.raw=e.value,this.set=[[e]],this.format(),this;if(this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease,this.raw=e,this.set=e.split(/\s*\|\|\s*/).map(n=>this.parseRange(n.trim())).filter(n=>n.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${e}`);this.format()}format(){return this.range=this.set.map(e=>e.join(" ").trim()).join("||").trim(),this.range}toString(){return this.range}parseRange(e){let{loose:t}=this.options;e=e.trim();let n=t?R[f.HYPHENRANGELOOSE]:R[f.HYPHENRANGE];e=e.replace(n,xr(this.options.includePrerelease)),E("hyphen replace",e),e=e.replace(R[f.COMPARATORTRIM],Er),E("comparator trim",e,R[f.COMPARATORTRIM]),e=(e=(e=e.replace(R[f.TILDETRIM],fr)).replace(R[f.CARETTRIM],yr)).split(/\s+/).join(" ");let s=t?R[f.COMPARATORLOOSE]:R[f.COMPARATOR];return e.split(" ").map(i=>Rr(i,this.options)).join(" ").split(/\s+/).map(i=>Mr(i,this.options)).filter(this.options.loose?i=>!!i.match(s):()=>!0).map(i=>new Y(i,this.options))}intersects(e,t){if(!(e instanceof r))throw new TypeError("a Range is required");return this.set.some(n=>ht(n,t)&&e.set.some(s=>ht(s,t)&&n.every(i=>s.every(o=>i.intersects(o,t)))))}test(e){if(!e)return!1;if(typeof e=="string")try{e=new A(e,this.options)}catch{return!1}for(let t=0;t<this.set.length;t++)if(Cr(this.set[t],e,this.options))return!0;return!1}},{re:R,t:f,comparatorTrimReplace:Er,tildeTrimReplace:fr,caretTrimReplace:yr}=Z,ht=(r,e)=>{let t=!0,n=r.slice(),s=n.pop();for(;t&&n.length;)t=n.every(i=>s.intersects(i,e)),s=n.pop();return t},Rr=(r,e)=>(E("comp",r,e),r=Pr(r,e),E("caret",r),r=vr(r,e),E("tildes",r),r=br(r,e),E("xrange",r),r=Sr(r,e),E("stars",r),r),P=r=>!r||r.toLowerCase()==="x"||r==="*",vr=(r,e)=>r.trim().split(/\s+/).map(t=>Tr(t,e)).join(" "),Tr=(r,e)=>{let t=e.loose?R[f.TILDELOOSE]:R[f.TILDE];return r.replace(t,(n,s,i,o,a)=>{let c;return E("tilde",r,n,s,i,o,a),P(s)?c="":P(i)?c=`>=${s}.0.0 <${+s+1}.0.0-0`:P(o)?c=`>=${s}.${i}.0 <${s}.${+i+1}.0-0`:a?(E("replaceTilde pr",a),c=`>=${s}.${i}.${o}-${a} <${s}.${+i+1}.0-0`):c=`>=${s}.${i}.${o} <${s}.${+i+1}.0-0`,E("tilde return",c),c})},Pr=(r,e)=>r.trim().split(/\s+/).map(t=>Ir(t,e)).join(" "),Ir=(r,e)=>{E("caret",r,e);let t=e.loose?R[f.CARETLOOSE]:R[f.CARET],n=e.includePrerelease?"-0":"";return r.replace(t,(s,i,o,a,c)=>{let p;return E("caret",r,s,i,o,a,c),P(i)?p="":P(o)?p=`>=${i}.0.0${n} <${+i+1}.0.0-0`:P(a)?p=i==="0"?`>=${i}.${o}.0${n} <${i}.${+o+1}.0-0`:`>=${i}.${o}.0${n} <${+i+1}.0.0-0`:c?(E("replaceCaret pr",c),p=i==="0"?o==="0"?`>=${i}.${o}.${a}-${c} <${i}.${o}.${+a+1}-0`:`>=${i}.${o}.${a}-${c} <${i}.${+o+1}.0-0`:`>=${i}.${o}.${a}-${c} <${+i+1}.0.0-0`):(E("no pr"),p=i==="0"?o==="0"?`>=${i}.${o}.${a}${n} <${i}.${o}.${+a+1}-0`:`>=${i}.${o}.${a}${n} <${i}.${+o+1}.0-0`:`>=${i}.${o}.${a} <${+i+1}.0.0-0`),E("caret return",p),p})},br=(r,e)=>(E("replaceXRanges",r,e),r.split(/\s+/).map(t=>wr(t,e)).join(" ")),wr=(r,e)=>{r=r.trim();let t=e.loose?R[f.XRANGELOOSE]:R[f.XRANGE];return r.replace(t,(n,s,i,o,a,c)=>{E("xRange",r,n,s,i,o,a,c);let p=P(i),u=p||P(o),h=u||P(a),b=h;return s==="="&&b&&(s=""),c=e.includePrerelease?"-0":"",p?n=s===">"||s==="<"?"<0.0.0-0":"*":s&&b?(u&&(o=0),a=0,s===">"?(s=">=",u?(i=+i+1,o=0,a=0):(o=+o+1,a=0)):s==="<="&&(s="<",u?i=+i+1:o=+o+1),s==="<"&&(c="-0"),n=`${s+i}.${o}.${a}${c}`):u?n=`>=${i}.0.0${c} <${+i+1}.0.0-0`:h&&(n=`>=${i}.${o}.0${c} <${i}.${+o+1}.0-0`),E("xRange return",n),n})},Sr=(r,e)=>(E("replaceStars",r,e),r.trim().replace(R[f.STAR],"")),Mr=(r,e)=>(E("replaceGTE0",r,e),r.trim().replace(R[e.includePrerelease?f.GTE0PRE:f.GTE0],"")),xr=r=>(e,t,n,s,i,o,a,c,p,u,h,b,w)=>`${t=P(n)?"":P(s)?`>=${n}.0.0${r?"-0":""}`:P(i)?`>=${n}.${s}.0${r?"-0":""}`:o?`>=${t}`:`>=${t}${r?"-0":""}`} ${c=P(p)?"":P(u)?`<${+p+1}.0.0-0`:P(h)?`<${p}.${+u+1}.0-0`:b?`<=${p}.${u}.${h}-${b}`:r?`<${p}.${u}.${+h+1}-0`:`<=${c}`}`.trim(),Cr=(r,e,t)=>{for(let n=0;n<r.length;n++)if(!r[n].test(e))return!1;if(e.prerelease.length&&!t.includePrerelease){for(let n=0;n<r.length;n++)if(E(r[n].semver),r[n].semver!==Y.ANY&&r[n].semver.prerelease.length>0){let s=r[n].semver;if(s.major===e.major&&s.minor===e.minor&&s.patch===e.patch)return!0}return!1}return!0},ft=(r,e,t)=>{try{e=new Q(e,t)}catch{return!1}return e.test(r)};var{MAX_LENGTH:Nr}=Le,{re:mt,t:gt}=Z,Ar=(r,e)=>{if(e&&typeof e=="object"||(e={loose:!!e,includePrerelease:!1}),r instanceof A)return r;if(typeof r!="string"||r.length>Nr||!(e.loose?mt[gt.LOOSE]:mt[gt.FULL]).test(r))return null;try{return new A(r,e)}catch{return null}},$r=Ar,{re:le,t:de}=Z,yt=(r,e)=>{if(r instanceof A)return r;if(typeof r=="number"&&(r=String(r)),typeof r!="string")return null;let t=null;if((e=e||{}).rtl){let n;for(;(n=le[de.COERCERTL].exec(r))&&(!t||t.index+t[0].length!==r.length);)t&&n.index+n[0].length===t.index+t[0].length||(t=n),le[de.COERCERTL].lastIndex=n.index+n[1].length+n[2].length;le[de.COERCERTL].lastIndex=-1}else t=r.match(le[de.COERCE]);return t===null?null:$r(`${t[2]}.${t[3]||"0"}.${t[4]||"0"}`,e)};function Or(r){return String.fromCharCode(parseInt(r.slice(1),16))}function Lr(r){return`%${`00${r.charCodeAt(0).toString(16)}`.slice(-2)}`}function _r(r){return btoa(encodeURIComponent(r).replace(/%[0-9A-F]{2}/g,Or))}function Dr(r){return decodeURIComponent(Array.from(atob(r),Lr).join(""))}function ee(r){return _r(JSON.stringify(r))}function _e(r){return JSON.parse(Dr(r))}var S=require("@magic-sdk/types");var ue=require("@magic-sdk/types");function L(r){return typeof r>"u"}function qr(r){return r===null}function pe(r){return qr(r)||L(r)}function kr(r){return pe(r)?!1:!L(r.jsonrpc)&&!L(r.id)&&!L(r.method)&&!L(r.params)}function De(r){return pe(r)?!1:!L(r.jsonrpc)&&!L(r.id)&&(!L(r.result)||!L(r.error))}function Wr(r){return pe(r)?!1:typeof r=="string"&&Object.values(ue.MagicPayloadMethod).includes(r)}function qe(r){return pe(r)?!1:typeof r=="number"&&Object.values(ue.RPCErrorCode).includes(r)}function K(r){if(!r)return!0;for(let e in r)if(Object.hasOwnProperty.call(r,e))return!1;return!0}var g={};function Rt(r,e){return Object.assign(g,e),r}var vt={"magic-sdk":"magic-sdk","@magic-sdk/react-native":"magic-sdk-rn","@magic-sdk/react-native-bare":"magic-sdk-rn-bare","@magic-sdk/react-native-expo":"magic-sdk-rn-expo"};var _=class r extends Error{constructor(t,n){super(`Magic SDK Error: [${t}] ${n}`);this.code=t;this.rawMessage=n;Object.setPrototypeOf(this,r.prototype)}__proto__=Error},U=class r extends Error{__proto__=Error;code;rawMessage;data;constructor(e){super();let t=Number(e?.code);this.rawMessage=e?.message||"Internal error",this.code=qe(t)?t:S.RPCErrorCode.InternalError,this.message=`Magic RPC Error: [${this.code}] ${this.rawMessage}`,this.data=e?.data||void 0,Object.setPrototypeOf(this,r.prototype)}},D=class{constructor(e,t){this.code=e;this.rawMessage=t;this.message=`Magic SDK Warning: [${e}] ${t}`}message;log(){console.warn(this.message)}},te=class r extends Error{constructor(t,n,s,i){super(`Magic Extension Error (${t.name}): [${n}] ${s}`);this.code=n;this.rawMessage=s;this.data=i;Object.setPrototypeOf(this,r.prototype)}__proto__=Error},G=class{constructor(e,t,n){this.code=t;this.rawMessage=n;this.message=`Magic Extension Warning (${e.name}): [${t}] ${n}`}message;log(){console.warn(this.message)}};function ke(){return new _(S.SDKErrorCode.MissingApiKey,"Please provide an API key that you acquired from the Magic developer dashboard.")}function re(){return new _(S.SDKErrorCode.ModalNotReady,"Modal is not ready")}function We(){return new _(S.SDKErrorCode.MalformedResponse,"Response from the Magic iframe is malformed.")}function Ue(r){return new _(S.SDKErrorCode.ExtensionNotInitialized,`Extensions must be initialized with a Magic SDK instance before \`Extension.${r}\` can be accessed. Do not invoke \`Extension.${r}\` inside an extension constructor.`)}function Fe(r){let e=`Some extensions are incompatible with \`${g.sdkName}@${g.version}\`:`;return r.filter(t=>typeof t.compat<"u"&&t.compat!==null).forEach(t=>{let n=t.compat[g.sdkName];typeof n=="string"?e+=`
2
2
  - Extension \`${t.name}\` supports version(s) \`${n}\``:n||(e+=`
3
- - Extension \`${t.name}\` does not support ${g.platform} environments.`)}),new _(M.SDKErrorCode.IncompatibleExtensions,e)}function Je(r){let e=t=>{let n=t+1,s=n%10,i=n%100;return s===1&&i!==11?`${n}st`:s===2&&i!==12?`${n}nd`:s===3&&i!==13?`${n}rd`:`${n}th`};return new _(M.SDKErrorCode.InvalidArgument,`Invalid ${e(r.argument)} argument given to \`${r.procedure}\`.
3
+ - Extension \`${t.name}\` does not support ${g.platform} environments.`)}),new _(S.SDKErrorCode.IncompatibleExtensions,e)}function Je(r){let e=t=>{let n=t+1,s=n%10,i=n%100;return s===1&&i!==11?`${n}st`:s===2&&i!==12?`${n}nd`:s===3&&i!==13?`${n}rd`:`${n}th`};return new _(S.SDKErrorCode.InvalidArgument,`Invalid ${e(r.argument)} argument given to \`${r.procedure}\`.
4
4
  Expected: \`${r.expected}\`
5
- Received: \`${r.received}\``)}function Ur(){return new k(M.SDKWarningCode.DuplicateIframe,"Duplicate iframes found.")}function Ge(){return new k(M.SDKWarningCode.SyncWeb3Method,"Non-async web3 methods are deprecated in web3 > 1.0 and are not supported by the Magic web3 provider. Please use an async method instead.")}function Ke(){return new k(M.SDKWarningCode.ReactNativeEndpointConfiguration,`CUSTOM DOMAINS ARE NOT SUPPORTED WHEN USING MAGIC SDK WITH REACT NATIVE! The \`endpoint\` parameter SHOULD NOT be provided. The Magic \`<iframe>\` is automatically wrapped by a WebView pointed at \`${g.defaultEndpoint}\`. Changing this default behavior will lead to unexpected results and potentially security-threatening bugs.`)}function je(r){let{method:e,removalVersions:t,useInstead:n}=r,s=t[g.sdkName],i=n?` Use \`${n}\` instead.`:"",o=`\`${e}\` will be removed from \`${g.sdkName}\` in version \`${s}\`.${i}`;return new k(M.SDKWarningCode.DeprecationNotice,o)}var d=require("@magic-sdk/types");var W=require("@magic-sdk/types");var bt=require("@magic-sdk/types");function*Fr(){let r=0;for(;;)r<Number.MAX_SAFE_INTEGER?yield++r:r=0}var Jr=Fr();function Gr(){return Math.floor(Math.random()*1e5)+1}function he(){return g.sdkName==="@magic-sdk/react-native-bare"||g.sdkName==="@magic-sdk/react-native-expo"?Gr():Jr.next().value}var ne={};it(ne,{clear:()=>Kr,getItem:()=>T,iterate:()=>Ve,key:()=>Vr,keys:()=>Br,length:()=>jr,removeItem:()=>$,setItem:()=>C});var me;function D(r){return async(...e)=>(me||(me=await g.configureStorage()),await me.ready(),me[r](...e))}var T=D("getItem"),C=D("setItem"),$=D("removeItem"),Kr=D("clear"),jr=D("length"),Vr=D("key"),Br=D("keys"),Ve=D("iterate");function Be(){let r=window.crypto.getRandomValues(new Uint8Array(16));r[6]=r[6]&15|64,r[8]=r[8]&191|128;let e="";return e+=r[0].toString(16),e+=r[1].toString(16),e+=r[2].toString(16),e+=r[3].toString(16),e+="-",e+=r[4].toString(16),e+=r[5].toString(16),e+="-",e+=r[6].toString(16),e+=r[7].toString(16),e+="-",e+=r[8].toString(16),e+=r[9].toString(16),e+="-",e+=r[10].toString(16),e+=r[11].toString(16),e+=r[12].toString(16),e+=r[13].toString(16),e+=r[14].toString(16),e+=r[15].toString(16),e}var ge="STORE_KEY_PRIVATE_KEY",se="STORE_KEY_PUBLIC_JWK",Pt="ECDSA",Hr="P-256",Xr={name:Pt,namedCurve:Hr};function j(){let r=typeof window<"u"&&!!window.crypto,e=r&&!!window.crypto.subtle;return r&&e}function He(){$(se),$(ge)}async function Xe(){let r=await zr();if(!r){console.info("unable to creat kee publicy or webcrypto is unsupported");return}let{subtle:e}=window.crypto,t=await T(ge);if(!t||!e){console.info("unable to find private key or webcrypto unsupported");return}let n={iat:Math.floor(new Date().getTime()/1e3),jti:Be()},i={protected:Tt(JSON.stringify({typ:"dpop+jwt",alg:"ES256",jwk:r})),claims:Tt(JSON.stringify(n))},o=Qr(`${i.protected}.${i.claims}`),a={name:Pt,hash:{name:"SHA-256"}},c=en(new Uint8Array(await e.sign(a,t,o)));return`${i.protected}.${i.claims}.${c}`}async function zr(){if(!j()){console.info("webcrypto is not supported");return}return await T(se)||await Yr(),T(se)}async function Yr(){let{subtle:r}=window.crypto,e=await r.generateKey(Xr,!1,["sign"]),t=await r.exportKey("jwk",e.publicKey);await C(ge,e.privateKey),await C(se,t)}function Tt(r){return It(Zr(r))}function Qr(r){return new TextEncoder().encode(r)}function It(r){return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+/g,"")}function Zr(r){return encodeURIComponent(r).replace(/%([0-9A-F]{2})/g,(t,n)=>String.fromCharCode(parseInt(n,16)))}function en(r){let e="";return r.forEach(t=>{e+=String.fromCharCode(t)}),It(e)}var wt=Symbol("Payload pre-processed by Magic SDK");function St(r){return Object.defineProperty(r,wt,{value:!0,enumerable:!1}),r}function tn(r){return!!r[wt]}function F(r){return tn(r)||(r.jsonrpc=r.jsonrpc??"2.0",r.id=he(),r.method=r.method??"noop",r.params=r.params??[],St(r)),r}function m(r,e=[]){return St({params:e,method:r,jsonrpc:"2.0",id:he()})}var V=class r{_jsonrpc;_id;_result;_error;constructor(e){e instanceof r?(this._jsonrpc=e.payload.jsonrpc,this._id=e.payload.id,this._result=e.payload.result,this._error=e.payload.error):ke(e)?(this._jsonrpc=e.jsonrpc,this._id=e.id,this._result=e.result,this._error=e.error):(this._jsonrpc=e.jsonrpc,this._id=e.id,this._result=void 0,this._error=void 0)}applyError(e){return this._error=e,this}applyResult(e){return this._result=e,this}get hasError(){return this._error?.code===bt.RPCErrorCode.DpopInvalidated&&He(),typeof this._error<"u"&&this._error!==null}get hasResult(){return typeof this._result<"u"}get payload(){return{jsonrpc:this._jsonrpc,id:this._id,result:this._result,error:this._error}}};var ye=require("@magic-sdk/types");var Ct=Xt(xt()),fe=class extends Ct.default{};function oe(){let r=new fe;return{emitter:r,createChainingEmitterMethod:(n,s)=>(...i)=>(r[n].apply(r,i),s),createBoundEmitterMethod:n=>(...s)=>r[n].apply(r,s)}}var Nt=Symbol("isPromiEvent");function Ye(r){return!!r[Nt]}function f(r){let e=B(r),{createBoundEmitterMethod:t,createChainingEmitterMethod:n}=oe(),s=Symbol("Promise.then"),i=Symbol("Promise.catch"),o=Symbol("Promise.finally"),a=(u,h)=>(...w)=>{let S=h[u].apply(h,w);return c(S)},c=u=>Object.assign(u,{[Nt]:!0,[s]:u[s]||u.then,[i]:u[i]||u.catch,[o]:u[o]||u.finally,then:a(s,u),catch:a(i,u),finally:a(o,u),on:n("on",u),once:n("once",u),addListener:n("addListener",u),off:n("off",u),removeListener:n("removeListener",u),removeAllListeners:n("removeAllListeners",u),emit:t("emit"),eventNames:t("eventNames"),listeners:t("listeners"),listenerCount:t("listenerCount")}),p=c(e.then(u=>(p.emit("done",u),p.emit("settled"),u),u=>{throw p.emit("error",u),p.emit("settled"),u}));return p.on(ye.UserEventsOnReceived.ClosedByUser,()=>{p.emit(ye.UserEventsEmit.ClosedByUser)}),p}function B(r){return new Promise((e,t)=>{let n=r(e,t);Promise.resolve(n).catch(t)})}var R=class{constructor(e){this.sdk=e}get overlay(){return this.sdk.overlay}request(e){return this.sdk.thirdPartyWallets.isConnected&&!W.routeToMagicMethods.includes(e.method)?this.requestThirdPartyWallets(e):this.requestOverlay(e)}requestThirdPartyWallets(e){return f((n,s)=>{this.sdk.thirdPartyWallets.requestOverride(e).then(n).catch(s)})}requestOverlay(e){let t=this.overlay.post(W.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST,F(e)),n=f((i,o)=>{t.then(a=>{if(s(),a.hasError)o(new U(a.payload.error));else if(a.hasResult)i(a.payload.result);else throw We()}).catch(a=>{s(),o(a)})}),s=this.overlay.on(W.MagicIncomingWindowMessage.MAGIC_HANDLE_EVENT,i=>{let{response:o}=i.data;if(o.id===e.id&&o.result?.event){let{event:a,params:c=[]}=o.result;n.emit(a,...c)}});return n}createIntermediaryEvent(e,t){return s=>{let i=m(W.MagicPayloadMethod.IntermediaryEvent,[{payloadId:t,eventType:e,args:s}]);this.request(i)}}};function Qe(r,e){let[t]=r.split(".").map(Number);return t>=e}var sn={"magic-sdk":"v18.0.0","@magic-sdk/react-native":"v14.0.0","@magic-sdk/react-native-bare":"v19.0.0","@magic-sdk/react-native-expo":"v19.0.0"},Re=class extends R{loginWithMagicLink(e){let t=g.sdkName==="@magic-sdk/react-native"||g.sdkName==="@magic-sdk/react-native-bare"||g.sdkName==="@magic-sdk/react-native-expo";if(t&&Qe(g.version,19))throw new Error("loginWithMagicLink() is deprecated for this package, please utilize a passcode method like loginWithSMS or loginWithEmailOTP instead.");t&&je({method:"auth.loginWithMagicLink()",removalVersions:sn,useInstead:"auth.loginWithEmailOTP()"}).log();let{email:n,showUI:s=!0,redirectURI:i,overrides:o,lifespan:a}=e,c=m(this.sdk.testMode?d.MagicPayloadMethod.LoginWithMagicLinkTestMode:d.MagicPayloadMethod.LoginWithMagicLink,[{email:n,showUI:s,redirectURI:i,overrides:o,lifespan:a}]);return this.request(c)}loginWithSMS(e){let{phoneNumber:t,showUI:n=!0,lifespan:s}=e,i=m(this.sdk.testMode?d.MagicPayloadMethod.LoginWithSmsTestMode:d.MagicPayloadMethod.LoginWithSms,[{phoneNumber:t,showUI:n,lifespan:s}]),o=this.request(i);return!n&&o&&(o.on(d.LoginWithSmsOTPEventEmit.VerifySmsOtp,a=>{this.createIntermediaryEvent(d.LoginWithSmsOTPEventEmit.VerifySmsOtp,i.id)(a)}),o.on(d.LoginWithSmsOTPEventEmit.VerifyMFACode,a=>{this.createIntermediaryEvent(d.LoginWithSmsOTPEventEmit.VerifyMFACode,i.id)(a)}),o.on(d.LoginWithSmsOTPEventEmit.LostDevice,()=>{this.createIntermediaryEvent(d.LoginWithSmsOTPEventEmit.LostDevice,i.id)()}),o.on(d.LoginWithSmsOTPEventEmit.VerifyRecoveryCode,a=>{this.createIntermediaryEvent(d.LoginWithSmsOTPEventEmit.VerifyRecoveryCode,i.id)(a)}),o.on(d.LoginWithSmsOTPEventEmit.Cancel,()=>{this.createIntermediaryEvent(d.LoginWithSmsOTPEventEmit.Cancel,i.id)()})),o}loginWithEmailOTP(e){let{email:t,showUI:n,deviceCheckUI:s,overrides:i,lifespan:o}=e,a=m(this.sdk.testMode?d.MagicPayloadMethod.LoginWithEmailOTPTestMode:d.MagicPayloadMethod.LoginWithEmailOTP,[{email:t,showUI:n,deviceCheckUI:s,overrides:i,lifespan:o}]),c=this.request(a);return!s&&c&&c.on(d.DeviceVerificationEventEmit.Retry,()=>{this.createIntermediaryEvent(d.DeviceVerificationEventEmit.Retry,a.id)()}),!n&&c&&(c.on(d.LoginWithEmailOTPEventEmit.VerifyEmailOtp,p=>{this.createIntermediaryEvent(d.LoginWithEmailOTPEventEmit.VerifyEmailOtp,a.id)(p)}),c.on(d.LoginWithEmailOTPEventEmit.VerifyMFACode,p=>{this.createIntermediaryEvent(d.LoginWithEmailOTPEventEmit.VerifyMFACode,a.id)(p)}),c.on(d.LoginWithEmailOTPEventEmit.LostDevice,()=>{this.createIntermediaryEvent(d.LoginWithEmailOTPEventEmit.LostDevice,a.id)()}),c.on(d.LoginWithEmailOTPEventEmit.VerifyRecoveryCode,p=>{this.createIntermediaryEvent(d.LoginWithEmailOTPEventEmit.VerifyRecoveryCode,a.id)(p)}),c.on(d.LoginWithEmailOTPEventEmit.Cancel,()=>{this.createIntermediaryEvent(d.LoginWithEmailOTPEventEmit.Cancel,a.id)()})),c}loginWithCredential(e){let{credentialOrQueryString:t,lifespan:n}=e||{},s=t??"";if(!t&&g.platform==="web"){s=window.location.search;let o=window.location.origin+window.location.pathname;window.history.replaceState(null,"",o)}let i=m(this.sdk.testMode?d.MagicPayloadMethod.LoginWithCredentialTestMode:d.MagicPayloadMethod.LoginWithCredential,[s,n]);return this.request(i)}setAuthorizationToken(e){let t=m(d.MagicPayloadMethod.SetAuthorizationToken,[{jwt:e}]);return this.request(t)}updateEmailWithUI(e){let{email:t,showUI:n=!0}=e,s=m(this.sdk.testMode?d.MagicPayloadMethod.UpdateEmailTestMode:d.MagicPayloadMethod.UpdateEmail,[{email:t,showUI:n}]),i=this.request(s);return n||(i.on(d.RecencyCheckEventEmit.Retry,()=>{this.createIntermediaryEvent(d.RecencyCheckEventEmit.Retry,s.id)()}),i.on(d.RecencyCheckEventEmit.Cancel,()=>{this.createIntermediaryEvent(d.RecencyCheckEventEmit.Cancel,s.id)()}),i.on(d.RecencyCheckEventEmit.VerifyEmailOtp,o=>{this.createIntermediaryEvent(d.RecencyCheckEventEmit.VerifyEmailOtp,s.id)(o)}),i.on(d.RecencyCheckEventEmit.VerifyMFACode,o=>{this.createIntermediaryEvent(d.RecencyCheckEventEmit.VerifyMFACode,s.id)(o)}),i.on(d.UpdateEmailEventEmit.RetryWithNewEmail,o=>{this.createIntermediaryEvent(d.UpdateEmailEventEmit.RetryWithNewEmail,s.id)(o)}),i.on(d.UpdateEmailEventEmit.Cancel,()=>{this.createIntermediaryEvent(d.UpdateEmailEventEmit.Cancel,s.id)()}),i.on(d.UpdateEmailEventEmit.VerifyEmailOtp,o=>{this.createIntermediaryEvent(d.UpdateEmailEventEmit.VerifyEmailOtp,s.id)(o)})),i}};var l=require("@magic-sdk/types");var Ze="ds",et="ek",tt="iv",rt="AES-GCM",on=256;async function ve(){let r=[];await Ve((e,t,n)=>{t.startsWith(`${Ze}_`)&&r.push(t)});for(let e of r)await $(e)}function At(r){let e="",t=new Uint8Array(r),n=t.byteLength;for(let s=0;s<n;s++)e+=String.fromCharCode(t[s]);return window.btoa(e)}function $t(r){let e=window.atob(r),t=e.length,n=new Uint8Array(t);for(let s=0;s<t;s++)n[s]=e.charCodeAt(s);return n.buffer}async function an(){if(!j()){console.info("webcrypto is not supported");return}let{crypto:r}=window,e=await T(tt);return e||r.getRandomValues(new Uint8Array(12))}async function cn(){if(!j()){console.info("webcrypto is not supported");return}let{subtle:r}=window.crypto,e=await T(et);return e||await r.generateKey({name:rt,length:on},!1,["encrypt","decrypt"])}async function Lt(r,e){let t=await an(),n=await cn();if(!t||!n||!r)return;let s=$t(r),{subtle:i}=window.crypto,o=await i.encrypt({name:rt,iv:t},n,s),a=At(o);await C(`${Ze}_${e}`,a),await C(et,n),await C(tt,t)}async function Ot(r){let e=await T(`${Ze}_${r}`),t=await T(tt),n=await T(et);if(!t||!e||!n||!j())return;let{subtle:s}=window.crypto,i=await s.decrypt({name:rt,iv:t},n,$t(e));return At(i)}function Te(r,e){return e?new URL(r,e):new URL(r)}var Pe=class extends R{getIdToken(e){let t=m(this.sdk.testMode?l.MagicPayloadMethod.GetIdTokenTestMode:l.MagicPayloadMethod.GetIdToken,[e]);return this.request(t)}generateIdToken(e){let t=m(this.sdk.testMode?l.MagicPayloadMethod.GenerateIdTokenTestMode:l.MagicPayloadMethod.GenerateIdToken,[e]);return this.request(t)}getInfo(){let e=m(l.MagicPayloadMethod.GetInfo,[]);return this.request(e)}isLoggedIn(){return f(async(e,t)=>{try{let n=!1;this.sdk.useStorageCache&&(n=await T(this.localForageIsLoggedInKey)==="true",n&&e(!0));let s=m(this.sdk.testMode?l.MagicPayloadMethod.IsLoggedInTestMode:l.MagicPayloadMethod.IsLoggedIn),i=await this.request(s);this.sdk.useStorageCache&&(i?C(this.localForageIsLoggedInKey,!0):$(this.localForageIsLoggedInKey),n&&!i&&this.emitUserLoggedOut(!0)),e(i)}catch(n){t(n)}})}logout(){return $(this.localForageIsLoggedInKey),$("rt"),ve(),f(async(e,t)=>{try{let n=m(this.sdk.testMode?l.MagicPayloadMethod.LogoutTestMode:l.MagicPayloadMethod.Logout),s=await this.request(n);this.sdk.useStorageCache&&this.emitUserLoggedOut(s),e(s)}catch(n){t(n)}})}requestInfoWithUI(e){let t=m(l.MagicPayloadMethod.RequestUserInfoWithUI,e?[e]:[]);return this.request(t)}showSettings(e){let{showUI:t=!0}=e||{},n=m(this.sdk.testMode?l.MagicPayloadMethod.UserSettingsTestMode:l.MagicPayloadMethod.UserSettings,[e]),s=this.request(n);return!t&&s&&(s.on(l.RecoveryFactorEventEmit.SendNewPhoneNumber,i=>{this.createIntermediaryEvent(l.RecoveryFactorEventEmit.SendNewPhoneNumber,n.id)(i)}),s.on(l.RecoveryFactorEventEmit.SendOtpCode,i=>{this.createIntermediaryEvent(l.RecoveryFactorEventEmit.SendOtpCode,n.id)(i)}),s.on(l.RecoveryFactorEventEmit.StartEditPhoneNumber,()=>{this.createIntermediaryEvent(l.RecoveryFactorEventEmit.StartEditPhoneNumber,n.id)()}),s.on(l.RecoveryFactorEventEmit.Cancel,()=>{this.createIntermediaryEvent(l.RecoveryFactorEventEmit.Cancel,n.id)()}),s.on(l.RecencyCheckEventEmit.VerifyEmailOtp,i=>{this.createIntermediaryEvent(l.RecencyCheckEventEmit.VerifyEmailOtp,n.id)(i)})),s}recoverAccount(e){let{email:t,showUI:n}=e,s=m(this.sdk.testMode?l.MagicPayloadMethod.RecoverAccountTestMode:l.MagicPayloadMethod.RecoverAccount,[{email:t,showUI:n}]),i=this.request(s);return!n&&i&&(i.on(l.RecoverAccountEventEmit.Cancel,()=>{this.createIntermediaryEvent(l.RecoverAccountEventEmit.Cancel,s.id)()}),i.on(l.RecoverAccountEventEmit.ResendSms,()=>{this.createIntermediaryEvent(l.RecoverAccountEventEmit.ResendSms,s.id)()}),i.on(l.RecoverAccountEventEmit.VerifyOtp,o=>{this.createIntermediaryEvent(l.RecoverAccountEventEmit.VerifyOtp,s.id)(o)}),i.on(l.RecoverAccountEventEmit.UpdateEmail,o=>{this.createIntermediaryEvent(l.RecoverAccountEventEmit.UpdateEmail,s.id)(o)}),i.on(l.UpdateEmailEventEmit.Cancel,()=>{this.createIntermediaryEvent(l.UpdateEmailEventEmit.Cancel,s.id)()}),i.on(l.UpdateEmailEventEmit.RetryWithNewEmail,o=>{this.createIntermediaryEvent(l.UpdateEmailEventEmit.RetryWithNewEmail,s.id)(o)}),i.on(l.UpdateEmailEventEmit.VerifyEmailOtp,o=>{this.createIntermediaryEvent(l.UpdateEmailEventEmit.VerifyEmailOtp,s.id)(o)})),i}revealEVMPrivateKey(){let e=m(l.MagicPayloadMethod.RevealPK,[{chain:"ETH"}]);return this.request(e)}revealPrivateKey(){throw new Error("revealPrivateKey() has been decommissioned. For EVM chains, use `user.revealEVMPrivateKey()` instead. For non-EVM chains, use `[extension].revealPrivateKey()` instead.")}onUserLoggedOut(e){this.userLoggedOutCallbacks.push(e)}enableMFA(e){let{showUI:t=!0}=e,n=m(l.MagicPayloadMethod.EnableMFA,[{showUI:t}]),s=this.request(n);return!t&&s&&(s.on(l.EnableMFAEventEmit.VerifyMFACode,i=>{this.createIntermediaryEvent(l.EnableMFAEventEmit.VerifyMFACode,n.id)(i)}),s.on(l.EnableMFAEventEmit.Cancel,()=>{this.createIntermediaryEvent(l.EnableMFAEventEmit.Cancel,n.id)()})),s}disableMFA(e){let{showUI:t=!0}=e,n=m(l.MagicPayloadMethod.DisableMFA,[{showUI:t}]),s=this.request(n);return!t&&s&&(s.on(l.DisableMFAEventEmit.VerifyMFACode,i=>{this.createIntermediaryEvent(l.DisableMFAEventEmit.VerifyMFACode,n.id)(i)}),s.on(l.DisableMFAEventEmit.LostDevice,i=>{this.createIntermediaryEvent(l.DisableMFAEventEmit.LostDevice,n.id)(i)}),s.on(l.DisableMFAEventEmit.Cancel,()=>{this.createIntermediaryEvent(l.DisableMFAEventEmit.Cancel,n.id)()})),s}emitUserLoggedOut(e){this.userLoggedOutCallbacks.forEach(t=>{t(e)})}localForageIsLoggedInKey="magic_auth_is_logged_in";userLoggedOutCallbacks=[]};var L=require("@magic-sdk/types");var Ie=class extends R{connectWithUI(e){let t=f(async(n,s)=>{try{let i=m(L.MagicPayloadMethod.Login,[{enabledWallets:this.sdk.thirdPartyWallets.enabledWallets,...e}]),o=this.request(i);this.sdk.thirdPartyWallets.eventListeners.forEach(({event:c,callback:p})=>{o.on(c,()=>p(i.id))}),o.on("id-token-created",c=>{t.emit("id-token-created",c)});let a=await o;a.error&&s(a),n(a)}catch(i){s(i)}});return t}showUI(e){return this.request(m(L.MagicPayloadMethod.ShowUI,[e]))}showAddress(){return this.request(m(L.MagicPayloadMethod.ShowAddress))}showSendTokensUI(){return this.request(m(L.MagicPayloadMethod.ShowSendTokensUI))}showOnRamp(){return this.request(m(L.MagicPayloadMethod.ShowOnRamp))}showNFTs(){return this.request(m(L.MagicPayloadMethod.ShowNFTs))}showBalances(){return this.request(m(L.MagicPayloadMethod.ShowBalances))}sign7702Authorization(e){return this.request(m(L.MagicPayloadMethod.Sign7702Authorization,[e]))}send7702Transaction(e){return this.request(m(L.MagicPayloadMethod.Send7702Transaction,[e]))}};var x=require("@magic-sdk/types");var be=class extends R{eventListeners=[];enabledWallets={};isConnected=!1;resetThirdPartyWalletState(){localStorage.removeItem(x.LocalStorageKeys.PROVIDER),localStorage.removeItem(x.LocalStorageKeys.ADDRESS),localStorage.removeItem(x.LocalStorageKeys.CHAIN_ID),this.isConnected=!1}requestOverride(e){if(e.method===x.MagicPayloadMethod.Login)return this.resetThirdPartyWalletState(),super.request(e);if(e.method===x.MagicPayloadMethod.GetInfo)return this.getInfo(e);if(e.method===x.MagicPayloadMethod.IsLoggedIn)return this.isLoggedIn(e);if(e.method===x.MagicPayloadMethod.Logout)return this.logout(e);switch(localStorage.getItem(x.LocalStorageKeys.PROVIDER)){case"web3modal":return this.web3modalRequest(e);case"magic-widget":return this.magicWidgetRequest(e);default:return this.resetThirdPartyWalletState(),super.request(e)}}isLoggedIn(e){switch(localStorage.getItem(x.LocalStorageKeys.PROVIDER)){case"web3modal":return this.web3modalIsLoggedIn();case"magic-widget":return super.requestOverlay(e);default:return this.resetThirdPartyWalletState(),super.request(e)}}getInfo(e){switch(localStorage.getItem(x.LocalStorageKeys.PROVIDER)){case"web3modal":return this.web3modalGetInfo();case"magic-widget":return super.requestOverlay(e);default:return this.resetThirdPartyWalletState(),super.request(e)}}logout(e){let t=localStorage.getItem(x.LocalStorageKeys.PROVIDER);switch(this.resetThirdPartyWalletState(),t){case"web3modal":return this.web3modalLogout();case"magic-widget":return this.magicWidgetLogout(e);default:return super.request(e)}}web3modalRequest(e){return f((t,n)=>{this.sdk.web3modal.modal.getWalletProvider().request(e).then(t).catch(n)})}web3modalIsLoggedIn(){return f(e=>{let t=this.sdk.web3modal.modal.getStatus();if(t==="connected"&&e(!0),t==="disconnected"&&(this.resetThirdPartyWalletState(),e(!1)),t==="reconnecting"){let n=this.sdk.web3modal.modal.subscribeProvider(({status:s})=>{s==="connected"&&(n(),e(!0)),s==="disconnected"&&(n(),this.resetThirdPartyWalletState(),e(!1))})}})}formatWeb3modalGetInfoResponse(){let e=this.sdk.web3modal.modal.getWalletInfo()?.name,t=this.sdk.web3modal.modal.getAddress();return{email:null,issuer:`did:ethr:${t}`,phoneNumber:null,isMfaEnabled:!1,recoveryFactors:[],firstLoginAt:null,wallets:{ethereum:{publicAddress:t,subAccounts:[]}}}}web3modalGetInfo(){return f((e,t)=>{let n=this.sdk.web3modal.modal.getStatus();if(n==="connected"&&e(this.formatWeb3modalGetInfoResponse()),n==="disconnected"&&(this.resetThirdPartyWalletState(),t("Magic RPC Error: [-32603] Internal error: User denied account access.")),n==="reconnecting"){let s=this.sdk.web3modal.modal.subscribeProvider(({status:i})=>{i==="connected"&&(s(),e(this.formatWeb3modalGetInfoResponse())),i==="disconnected"&&(s(),this.resetThirdPartyWalletState(),t("Magic RPC Error: [-32603] Internal error: User denied account access."))})}})}web3modalLogout(){return f(async e=>{try{await this.sdk.web3modal.modal.disconnect()}catch(t){console.error(t)}e(!0)})}magicWidgetRequest(e){return["eth_","wallet_","net_","web3_"].some(i=>e.method?.startsWith(i))||["personal_sign"].includes(e.method)?f((i,o)=>{this.sdk.walletKit.walletRequest(e).then(i).catch(a=>o(new U(a)))}):super.requestOverlay(e)}magicWidgetLogout(e){return f(async t=>{try{this.sdk.walletKit.clearConnectedState()}catch(n){console.error(n)}return super.requestOverlay(e)})}handleIframeThirdPartyWalletRequest(e){this.magicWidgetRequest(e.payload).then(t=>{this.overlay.postThirdPartyWalletResponse({id:e.payload.id,jsonrpc:"2.0",result:t})}).catch(t=>{this.overlay.postThirdPartyWalletResponse({id:e.payload.id,jsonrpc:"2.0",error:{code:t.code||-32603,message:t.message||"Internal error",data:t.data}})})}};var _t=require("@magic-sdk/types");var{createBoundEmitterMethod:we,createChainingEmitterMethod:H}=oe(),Se=class extends R{isMagic=!0;sendAsync(e,t){if(!t)throw Je({procedure:"Magic.rpcProvider.sendAsync",argument:1,expected:"function",received:t===null?"null":typeof t});if(Array.isArray(e)){let s=e.map(i=>F(i)).map(i=>this.request(i).then(o=>({jsonrpc:i.jsonrpc??"2.0",id:i.id??null,result:o,error:null})).catch(o=>({jsonrpc:i.jsonrpc??"2.0",id:i.id??null,error:o})));Promise.all(s).then(i=>{t(null,i)})}else this.request(F(e)).then(n=>{t(null,{jsonrpc:e.jsonrpc??"2.0",id:e.id??null,result:n,error:null})}).catch(n=>{t(n,{jsonrpc:e.jsonrpc??"2.0",id:e.id??null,error:n})})}send(e,t){if(typeof e=="string"){let s=m(e,Array.isArray(t)?t:[]);return this.request(s)}if(Array.isArray(e)||t){this.sendAsync(e,t);return}let n=Ge();return n.log(),new V(e).applyError({code:-32603,message:n.rawMessage}).payload}enable(){let e=m(_t.MagicPayloadMethod.Login);return this.request(e)}request(e){return this.prefixPayloadMethodForTestMode(e),super.request(e)}prefixPayloadMethodForTestMode(e){let t="testMode/eth/";this.sdk.testMode&&(e.method=`${t}${e.method}`)}on=H("on",this);once=H("once",this);addListener=H("addListener",this);off=H("off",this);removeListener=H("removeListener",this);removeAllListeners=H("removeAllListeners",this);emit=we("emit");eventNames=we("eventNames");listeners=we("listeners");listenerCount=we("listenerCount")};var q=require("@magic-sdk/types");var Me=class extends R{purchase(e){let t=m(q.MagicPayloadMethod.NFTPurchase,[e]);return this.request(t)}checkout(e){let t=this.sdk.thirdPartyWallets.isConnected,n=m(q.MagicPayloadMethod.NFTCheckout,[{...e,walletProvider:t?"web3modal":"magic"}]),s=this.request(n);return t&&(s.on(q.NftCheckoutIntermediaryEvents.Initiated,async i=>{try{let o=await this.request({method:"eth_sendTransaction",params:[i]});this.createIntermediaryEvent(q.NftCheckoutIntermediaryEvents.Success,n.id)(o)}catch{this.createIntermediaryEvent(q.NftCheckoutIntermediaryEvents.Failure,n.id)()}}),s.on(q.NftCheckoutIntermediaryEvents.Disconnect,()=>{this.sdk.thirdPartyWallets.resetThirdPartyWalletState(),s.emit("disconnect")})),s}transfer(e){let t=m(q.MagicPayloadMethod.NFTTransfer,[e]);return this.request(t)}};function kt(r){return r.compat&&r.compat[g.sdkName]!=null?typeof r.compat[g.sdkName]=="string"?ft(yt(g.version),r.compat[g.sdkName]):!!r.compat[g.sdkName]:!0}function ln(r,e,t){return!e&&!t?`${r}_eth_mainnet`:t?`${r}_${JSON.stringify(t)}`:e?typeof e=="string"?`${r}_eth_${e}`:`${r}_${e.rpcUrl}_${e.chainId}_${e.chainType}`:`${r}_unknown`}function dn(r){let e=r?.extensions??[],t={},n=[];if(Array.isArray(e)?e.forEach(s=>{kt(s)?(s.init(this),s.name&&(this[s.name]=s),G(s.config)||(t[s.name]=s.config)):n.push(s)}):Object.keys(e).forEach(s=>{if(kt(e[s])){e[s].init(this);let i=e[s];this[s]=i,G(i.config)||(t[e[s].name]=i.config)}else n.push(e[s])}),n.length)throw Fe(n);return t}var xe=class r{constructor(e,t){this.apiKey=e;if(!e)throw De();g.platform==="react-native"&&t?.endpoint&&Ke().log();let{defaultEndpoint:n,version:s}=g;this.testMode=!!t?.testMode,this.useStorageCache=!!t?.useStorageCache,this.endpoint=Te(t?.endpoint??n).origin,this.auth=new Re(this),this.user=new Pe(this),this.wallet=new Ie(this),this.nft=new Me(this),this.thirdPartyWallets=new be(this),this.rpcProvider=new Se(this);let i=dn.call(this,t);this.parameters=ee({API_KEY:this.apiKey,DOMAIN_ORIGIN:typeof window<"u"&&window?.location?window?.location.origin:"",ETH_NETWORK:t?.network,host:Te(this.endpoint).host,sdk:vt[g.sdkName],version:s,ext:G(i)?void 0:i,locale:t?.locale||"en_US",authConfig:t?.authConfig?{...t.authConfig}:void 0,...g.bundleId?{bundleId:g.bundleId}:{},meta:t?.meta}),this.networkHash=ln(this.apiKey,t?.network,G(i)?void 0:i),t?.deferPreload||this.preload()}static __overlays__=new Map;endpoint;parameters;networkHash;testMode;useStorageCache;auth;user;wallet;nft;thirdPartyWallets;rpcProvider;get overlay(){if(!r.__overlays__.has(this.parameters)){let e=new g.ViewController(this.endpoint,this.parameters,this.networkHash);e.init(),e.onThirdPartyWalletRequest(t=>this.thirdPartyWallets.handleIframeThirdPartyWalletRequest(t)),r.__overlays__.set(this.parameters,e)}return r.__overlays__.get(this.parameters)}async preload(){await this.overlay.waitForReady()}};var N=require("@magic-sdk/types");function un(r,e){return e&&Array.isArray(r)?r.find(t=>t.id===e):r}function qt(r,e){let t=e.data.response?.id,n=un(r,t);if(t&&n){let s=new V(n).applyResult(e.data.response.result).applyError(e.data.response.error);return{id:t,response:s}}return{}}function Dt(r,e){let t=null;return function(...n){t&&clearTimeout(t),t=setTimeout(()=>{r(...n)},e)}}var pn=1e3,Ut=60*pn,Wt=5*Ut,hn=60*Ut,Ce=class{constructor(e,t,n){this.endpoint=e;this.parameters=t;this.networkHash=n;this.listen()}isReadyForRequest=!1;messageHandlers=new Set;isConnectedToInternet=!0;lastPongTime=null;heartbeatIntervalTimer=null;heartbeatDebounce=Dt(()=>{this.endpoint==="https://auth.magic.link/"&&this.heartBeatCheck()},hn);thirdPartyWalletRequestHandler=()=>{};async post(e,t){return B(async(n,s)=>{if(!this.isConnectedToInternet){let u=re();s(u)}await this.checkRelayerExistsInDOM()||(this.isReadyForRequest=!1,await this.reloadRelayer()),this.isReadyForRequest||await this.waitForReady();let i=[],o=Array.isArray(t)?t.map(u=>u.id):[],a=await this.createMagicRequest(`${e}-${this.parameters}`,t,this.networkHash);await this._post(a);let c=u=>h=>{let{id:w,response:S}=qt(t,h);if(this.persistMagicEventRefreshToken(h),S?.payload.error?.message==="User denied account access.")ve();else if(h.data.deviceShare){let{deviceShare:Jt}=h.data;Lt(Jt,this.networkHash)}w&&S&&Array.isArray(t)&&o.includes(w)?(i.push(S),i.length===t.length&&(u(),n(i))):w&&S&&!Array.isArray(t)&&w===t.id&&(u(),n(S))},p=this.on(N.MagicIncomingWindowMessage.MAGIC_HANDLE_RESPONSE,c(()=>p()))})}async postThirdPartyWalletResponse(e){return B(async(t,n)=>{if(!this.isConnectedToInternet){let i=re();n(i)}await this.checkRelayerExistsInDOM()||(this.isReadyForRequest=!1,await this.reloadRelayer()),this.isReadyForRequest||await this.waitForReady();let s={msgType:`${N.MagicOutgoingWindowMessage.MAGIC_THIRD_PARTY_WALLET_RESPONSE}-${this.parameters}`,response:e};await this._post(s),t()})}async postThirdPartyWalletUpdate(e){return B(async(t,n)=>{if(!this.isConnectedToInternet){let o=re();n(o)}await this.checkRelayerExistsInDOM()||(this.isReadyForRequest=!1,await this.reloadRelayer()),this.isReadyForRequest||await this.waitForReady();let s=JSON.parse(JSON.stringify(e,(o,a)=>typeof a=="function"?void 0:a)),i={msgType:`${N.MagicOutgoingWindowMessage.MAGIC_THIRD_PARTY_WALLET_UPDATE}-${this.parameters}`,details:s};await this._post(i),t()})}on(e,t){let n=t.bind(window),s=i=>{i.data.msgType===`${e}-${this.parameters}`&&n(i)};return this.messageHandlers.add(s),()=>this.messageHandlers.delete(s)}waitForReady(){return new Promise(e=>{let t=this.on(N.MagicIncomingWindowMessage.MAGIC_OVERLAY_READY,()=>{this.isReadyForRequest=!0,e(),t()})})}onThirdPartyWalletRequest(e){this.thirdPartyWalletRequestHandler=e}listen(){this.on(N.MagicIncomingWindowMessage.MAGIC_HIDE_OVERLAY,()=>{this.hideOverlay()}),this.on(N.MagicIncomingWindowMessage.MAGIC_SHOW_OVERLAY,()=>{this.showOverlay()}),this.on(N.MagicIncomingWindowMessage.MAGIC_SEND_PRODUCT_ANNOUNCEMENT,e=>{e.data.response.result.product_announcement&&new k(N.SDKWarningCode.ProductAnnouncement,e.data.response.result.product_announcement).log()})}heartBeatCheck(){let e=!0,t=async()=>{let n={msgType:`${N.MagicOutgoingWindowMessage.MAGIC_PING}-${this.parameters}`,payload:[]};await this._post(n)};this.heartbeatIntervalTimer=setInterval(async()=>{if(this.lastPongTime){if(Date.now()-this.lastPongTime>Wt*2){this.reloadRelayer(),e=!0;return}}else if(!e){this.reloadRelayer(),e=!0;return}await t(),e=!1},Wt)}stopHeartBeat(){this.heartbeatDebounce(),this.lastPongTime=null,this.heartbeatIntervalTimer&&(clearInterval(this.heartbeatIntervalTimer),this.heartbeatIntervalTimer=null)}async persistMagicEventRefreshToken(e){e.data.rt&&await C("rt",e.data.rt)}async createMagicRequest(e,t,n){let s={msgType:e,payload:t},i=await this.getRT(),o=await this.getJWT(),a=await this.getDecryptedDeviceShare(n);return o&&(s.jwt=o),o&&i&&(s.rt=i),a&&(s.deviceShare=a),s}async getJWT(){if(g.platform==="web")try{let e=await T("jwt");return e||await Xe()}catch(e){return console.error("webcrypto error",e),null}else return null}async getRT(){return await T("rt")}async getDecryptedDeviceShare(e){return await Ot(e)}};var nt=require("@magic-sdk/types"),Ft=["request","overlay","sdk"];function mn(r){let e=Object.getPrototypeOf(r),t=[e];for(;e&&e!==R.prototype;)e=Object.getPrototypeOf(e),t.push(e);return t}var st=class extends R{compat;__sdk_access_field_descriptors__=new Map;__is_initialized__=!1;utils={createPromiEvent:f,isPromiEvent:Ye,encodeJSON:ee,decodeJSON:_e,createJsonRpcRequestPayload:m,standardizeJsonRpcRequestPayload:F,storage:ne};constructor(){super(void 0);let e=[this,...mn(this)];Ft.forEach(t=>{let n=e.map(a=>Object.getOwnPropertyDescriptor(a,t)),s=n.findIndex(a=>!!a),i=s>0,o=n[s];o&&(this.__sdk_access_field_descriptors__.set(t,{descriptor:o,isPrototypeField:i}),Object.defineProperty(this,t,{configurable:!0,get:()=>{throw Ue(t)}}))})}init(e){this.__is_initialized__||(Ft.forEach(t=>{if(this.__sdk_access_field_descriptors__.has(t)){let{descriptor:n,isPrototypeField:s}=this.__sdk_access_field_descriptors__.get(t);s?delete this[t]:Object.defineProperty(this,t,n)}}),this.sdk=e,this.__is_initialized__=!0)}createDeprecationWarning(e){let{method:t,removalVersion:n,useInstead:s}=e,i=s?` Use \`${s}\` instead.`:"",o=`\`${t}\` will be removed from this Extension in version \`${n}\`.${i}`;return new K(this,"DEPRECATION_NOTICE",o)}createWarning(e,t){return new K(this,e,t)}createError(e,t,n){return new te(this,e,t,n)}},Ne=class extends st{},Ae=class{static Internal=Ne},$e=class extends Ne{constructor(t){super();this.config=t;this.chain=t.chainType}chain;getPublicAddress(){return this.request(this.utils.createJsonRpcRequestPayload(nt.MagicPayloadMethod.GetMultichainPublicAddress,[{chain:this.chain}]))}revealPrivateKey(){return this.request(this.utils.createJsonRpcRequestPayload(nt.MagicPayloadMethod.RevealPK,[{chain:this.chain}]))}};
5
+ Received: \`${r.received}\``)}function Ur(){return new D(S.SDKWarningCode.DuplicateIframe,"Duplicate iframes found.")}function Ke(){return new D(S.SDKWarningCode.SyncWeb3Method,"Non-async web3 methods are deprecated in web3 > 1.0 and are not supported by the Magic web3 provider. Please use an async method instead.")}function Ge(){return new D(S.SDKWarningCode.ReactNativeEndpointConfiguration,`CUSTOM DOMAINS ARE NOT SUPPORTED WHEN USING MAGIC SDK WITH REACT NATIVE! The \`endpoint\` parameter SHOULD NOT be provided. The Magic \`<iframe>\` is automatically wrapped by a WebView pointed at \`${g.defaultEndpoint}\`. Changing this default behavior will lead to unexpected results and potentially security-threatening bugs.`)}function je(r){let{method:e,removalVersions:t,useInstead:n}=r,s=t[g.sdkName],i=n?` Use \`${n}\` instead.`:"",o=`\`${e}\` will be removed from \`${g.sdkName}\` in version \`${s}\`.${i}`;return new D(S.SDKWarningCode.DeprecationNotice,o)}var d=require("@magic-sdk/types");var W=require("@magic-sdk/types");var bt=require("@magic-sdk/types");function*Fr(){let r=0;for(;;)r<Number.MAX_SAFE_INTEGER?yield++r:r=0}var Jr=Fr();function Kr(){return Math.floor(Math.random()*1e5)+1}function he(){return g.sdkName==="@magic-sdk/react-native-bare"||g.sdkName==="@magic-sdk/react-native-expo"?Kr():Jr.next().value}var ne={};it(ne,{clear:()=>Gr,getItem:()=>v,iterate:()=>Ve,key:()=>Vr,keys:()=>Br,length:()=>jr,removeItem:()=>$,setItem:()=>C});var me;function k(r){return async(...e)=>(me||(me=await g.configureStorage()),await me.ready(),me[r](...e))}var v=k("getItem"),C=k("setItem"),$=k("removeItem"),Gr=k("clear"),jr=k("length"),Vr=k("key"),Br=k("keys"),Ve=k("iterate");function Be(){let r=window.crypto.getRandomValues(new Uint8Array(16));r[6]=r[6]&15|64,r[8]=r[8]&191|128;let e="";return e+=r[0].toString(16),e+=r[1].toString(16),e+=r[2].toString(16),e+=r[3].toString(16),e+="-",e+=r[4].toString(16),e+=r[5].toString(16),e+="-",e+=r[6].toString(16),e+=r[7].toString(16),e+="-",e+=r[8].toString(16),e+=r[9].toString(16),e+="-",e+=r[10].toString(16),e+=r[11].toString(16),e+=r[12].toString(16),e+=r[13].toString(16),e+=r[14].toString(16),e+=r[15].toString(16),e}var ge="STORE_KEY_PRIVATE_KEY",se="STORE_KEY_PUBLIC_JWK",Pt="ECDSA",Hr="P-256",Xr={name:Pt,namedCurve:Hr};function j(){let r=typeof window<"u"&&!!window.crypto,e=r&&!!window.crypto.subtle;return r&&e}function He(){$(se),$(ge)}async function Xe(){let r=await zr();if(!r){console.info("unable to creat kee publicy or webcrypto is unsupported");return}let{subtle:e}=window.crypto,t=await v(ge);if(!t||!e){console.info("unable to find private key or webcrypto unsupported");return}let n={iat:Math.floor(new Date().getTime()/1e3),jti:Be()},i={protected:Tt(JSON.stringify({typ:"dpop+jwt",alg:"ES256",jwk:r})),claims:Tt(JSON.stringify(n))},o=Qr(`${i.protected}.${i.claims}`),a={name:Pt,hash:{name:"SHA-256"}},c=en(new Uint8Array(await e.sign(a,t,o)));return`${i.protected}.${i.claims}.${c}`}async function zr(){if(!j()){console.info("webcrypto is not supported");return}return await v(se)||await Yr(),v(se)}async function Yr(){let{subtle:r}=window.crypto,e=await r.generateKey(Xr,!1,["sign"]),t=await r.exportKey("jwk",e.publicKey);await C(ge,e.privateKey),await C(se,t)}function Tt(r){return It(Zr(r))}function Qr(r){return new TextEncoder().encode(r)}function It(r){return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+/g,"")}function Zr(r){return encodeURIComponent(r).replace(/%([0-9A-F]{2})/g,(t,n)=>String.fromCharCode(parseInt(n,16)))}function en(r){let e="";return r.forEach(t=>{e+=String.fromCharCode(t)}),It(e)}var wt=Symbol("Payload pre-processed by Magic SDK");function St(r){return Object.defineProperty(r,wt,{value:!0,enumerable:!1}),r}function tn(r){return!!r[wt]}function F(r){return tn(r)||(r.jsonrpc=r.jsonrpc??"2.0",r.id=he(),r.method=r.method??"noop",r.params=r.params??[],St(r)),r}function m(r,e=[]){return St({params:e,method:r,jsonrpc:"2.0",id:he()})}var V=class r{_jsonrpc;_id;_result;_error;constructor(e){e instanceof r?(this._jsonrpc=e.payload.jsonrpc,this._id=e.payload.id,this._result=e.payload.result,this._error=e.payload.error):De(e)?(this._jsonrpc=e.jsonrpc,this._id=e.id,this._result=e.result,this._error=e.error):(this._jsonrpc=e.jsonrpc,this._id=e.id,this._result=void 0,this._error=void 0)}applyError(e){return this._error=e,this}applyResult(e){return this._result=e,this}get hasError(){return this._error?.code===bt.RPCErrorCode.DpopInvalidated&&He(),typeof this._error<"u"&&this._error!==null}get hasResult(){return typeof this._result<"u"}get payload(){return{jsonrpc:this._jsonrpc,id:this._id,result:this._result,error:this._error}}};var ye=require("@magic-sdk/types");var Ct=Xt(xt()),fe=class extends Ct.default{};function oe(){let r=new fe;return{emitter:r,createChainingEmitterMethod:(n,s)=>(...i)=>(r[n].apply(r,i),s),createBoundEmitterMethod:n=>(...s)=>r[n].apply(r,s)}}var Nt=Symbol("isPromiEvent");function Ye(r){return!!r[Nt]}function M(r){let e=B(r),{createBoundEmitterMethod:t,createChainingEmitterMethod:n}=oe(),s=Symbol("Promise.then"),i=Symbol("Promise.catch"),o=Symbol("Promise.finally"),a=(u,h)=>(...b)=>{let w=h[u].apply(h,b);return c(w)},c=u=>Object.assign(u,{[Nt]:!0,[s]:u[s]||u.then,[i]:u[i]||u.catch,[o]:u[o]||u.finally,then:a(s,u),catch:a(i,u),finally:a(o,u),on:n("on",u),once:n("once",u),addListener:n("addListener",u),off:n("off",u),removeListener:n("removeListener",u),removeAllListeners:n("removeAllListeners",u),emit:t("emit"),eventNames:t("eventNames"),listeners:t("listeners"),listenerCount:t("listenerCount")}),p=c(e.then(u=>(p.emit("done",u),p.emit("settled"),u),u=>{throw p.emit("error",u),p.emit("settled"),u}));return p.on(ye.UserEventsOnReceived.ClosedByUser,()=>{p.emit(ye.UserEventsEmit.ClosedByUser)}),p}function B(r){return new Promise((e,t)=>{let n=r(e,t);Promise.resolve(n).catch(t)})}var y=class{constructor(e){this.sdk=e}get overlay(){return this.sdk.overlay}request(e){return this.sdk.thirdPartyWallets.isConnected&&!W.routeToMagicMethods.includes(e.method)?this.requestThirdPartyWallets(e):this.requestOverlay(e)}requestThirdPartyWallets(e){return M((n,s)=>{this.sdk.thirdPartyWallets.requestOverride(e).then(n).catch(s)})}requestOverlay(e){let t=this.overlay.post(W.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST,F(e)),n=M((i,o)=>{t.then(a=>{if(s(),a.hasError)o(new U(a.payload.error));else if(a.hasResult)i(a.payload.result);else throw We()}).catch(a=>{s(),o(a)})}),s=this.overlay.on(W.MagicIncomingWindowMessage.MAGIC_HANDLE_EVENT,i=>{let{response:o}=i.data;if(o.id===e.id&&o.result?.event){let{event:a,params:c=[]}=o.result;n.emit(a,...c)}});return n}createIntermediaryEvent(e,t){return s=>{let i=m(W.MagicPayloadMethod.IntermediaryEvent,[{payloadId:t,eventType:e,args:s}]);this.request(i)}}};function Qe(r,e){let[t]=r.split(".").map(Number);return t>=e}var sn={"magic-sdk":"v18.0.0","@magic-sdk/react-native":"v14.0.0","@magic-sdk/react-native-bare":"v19.0.0","@magic-sdk/react-native-expo":"v19.0.0"},Re=class extends y{loginWithMagicLink(e){let t=g.sdkName==="@magic-sdk/react-native"||g.sdkName==="@magic-sdk/react-native-bare"||g.sdkName==="@magic-sdk/react-native-expo";if(t&&Qe(g.version,19))throw new Error("loginWithMagicLink() is deprecated for this package, please utilize a passcode method like loginWithSMS or loginWithEmailOTP instead.");t&&je({method:"auth.loginWithMagicLink()",removalVersions:sn,useInstead:"auth.loginWithEmailOTP()"}).log();let{email:n,showUI:s=!0,redirectURI:i,overrides:o,lifespan:a}=e,c=m(this.sdk.testMode?d.MagicPayloadMethod.LoginWithMagicLinkTestMode:d.MagicPayloadMethod.LoginWithMagicLink,[{email:n,showUI:s,redirectURI:i,overrides:o,lifespan:a}]);return this.request(c)}loginWithSMS(e){let{phoneNumber:t,showUI:n=!0,lifespan:s}=e,i=m(this.sdk.testMode?d.MagicPayloadMethod.LoginWithSmsTestMode:d.MagicPayloadMethod.LoginWithSms,[{phoneNumber:t,showUI:n,lifespan:s}]),o=this.request(i);return!n&&o&&(o.on(d.LoginWithSmsOTPEventEmit.VerifySmsOtp,a=>{this.createIntermediaryEvent(d.LoginWithSmsOTPEventEmit.VerifySmsOtp,i.id)(a)}),o.on(d.LoginWithSmsOTPEventEmit.VerifyMFACode,a=>{this.createIntermediaryEvent(d.LoginWithSmsOTPEventEmit.VerifyMFACode,i.id)(a)}),o.on(d.LoginWithSmsOTPEventEmit.LostDevice,()=>{this.createIntermediaryEvent(d.LoginWithSmsOTPEventEmit.LostDevice,i.id)()}),o.on(d.LoginWithSmsOTPEventEmit.VerifyRecoveryCode,a=>{this.createIntermediaryEvent(d.LoginWithSmsOTPEventEmit.VerifyRecoveryCode,i.id)(a)}),o.on(d.LoginWithSmsOTPEventEmit.Cancel,()=>{this.createIntermediaryEvent(d.LoginWithSmsOTPEventEmit.Cancel,i.id)()})),o}loginWithEmailOTP(e){let{email:t,showUI:n,deviceCheckUI:s,overrides:i,lifespan:o}=e,a=m(this.sdk.testMode?d.MagicPayloadMethod.LoginWithEmailOTPTestMode:d.MagicPayloadMethod.LoginWithEmailOTP,[{email:t,showUI:n,deviceCheckUI:s,overrides:i,lifespan:o}]),c=this.request(a);return!s&&c&&c.on(d.DeviceVerificationEventEmit.Retry,()=>{this.createIntermediaryEvent(d.DeviceVerificationEventEmit.Retry,a.id)()}),!n&&c&&(c.on(d.LoginWithEmailOTPEventEmit.VerifyEmailOtp,p=>{this.createIntermediaryEvent(d.LoginWithEmailOTPEventEmit.VerifyEmailOtp,a.id)(p)}),c.on(d.LoginWithEmailOTPEventEmit.VerifyMFACode,p=>{this.createIntermediaryEvent(d.LoginWithEmailOTPEventEmit.VerifyMFACode,a.id)(p)}),c.on(d.LoginWithEmailOTPEventEmit.LostDevice,()=>{this.createIntermediaryEvent(d.LoginWithEmailOTPEventEmit.LostDevice,a.id)()}),c.on(d.LoginWithEmailOTPEventEmit.VerifyRecoveryCode,p=>{this.createIntermediaryEvent(d.LoginWithEmailOTPEventEmit.VerifyRecoveryCode,a.id)(p)}),c.on(d.LoginWithEmailOTPEventEmit.Cancel,()=>{this.createIntermediaryEvent(d.LoginWithEmailOTPEventEmit.Cancel,a.id)()})),c}loginWithCredential(e){let{credentialOrQueryString:t,lifespan:n}=e||{},s=t??"";if(!t&&g.platform==="web"){s=window.location.search;let o=window.location.origin+window.location.pathname;window.history.replaceState(null,"",o)}let i=m(this.sdk.testMode?d.MagicPayloadMethod.LoginWithCredentialTestMode:d.MagicPayloadMethod.LoginWithCredential,[s,n]);return this.request(i)}setAuthorizationToken(e){let t=m(d.MagicPayloadMethod.SetAuthorizationToken,[{jwt:e}]);return this.request(t)}updateEmailWithUI(e){let{email:t,showUI:n=!0}=e,s=m(this.sdk.testMode?d.MagicPayloadMethod.UpdateEmailTestMode:d.MagicPayloadMethod.UpdateEmail,[{email:t,showUI:n}]),i=this.request(s);return n||(i.on(d.RecencyCheckEventEmit.Retry,()=>{this.createIntermediaryEvent(d.RecencyCheckEventEmit.Retry,s.id)()}),i.on(d.RecencyCheckEventEmit.Cancel,()=>{this.createIntermediaryEvent(d.RecencyCheckEventEmit.Cancel,s.id)()}),i.on(d.RecencyCheckEventEmit.VerifyEmailOtp,o=>{this.createIntermediaryEvent(d.RecencyCheckEventEmit.VerifyEmailOtp,s.id)(o)}),i.on(d.RecencyCheckEventEmit.VerifyMFACode,o=>{this.createIntermediaryEvent(d.RecencyCheckEventEmit.VerifyMFACode,s.id)(o)}),i.on(d.UpdateEmailEventEmit.RetryWithNewEmail,o=>{this.createIntermediaryEvent(d.UpdateEmailEventEmit.RetryWithNewEmail,s.id)(o)}),i.on(d.UpdateEmailEventEmit.Cancel,()=>{this.createIntermediaryEvent(d.UpdateEmailEventEmit.Cancel,s.id)()}),i.on(d.UpdateEmailEventEmit.VerifyEmailOtp,o=>{this.createIntermediaryEvent(d.UpdateEmailEventEmit.VerifyEmailOtp,s.id)(o)})),i}};var l=require("@magic-sdk/types");var Ze="ds",et="ek",tt="iv",rt="AES-GCM",on=256;async function ve(){let r=[];await Ve((e,t,n)=>{t.startsWith(`${Ze}_`)&&r.push(t)});for(let e of r)await $(e)}function At(r){let e="",t=new Uint8Array(r),n=t.byteLength;for(let s=0;s<n;s++)e+=String.fromCharCode(t[s]);return window.btoa(e)}function $t(r){let e=window.atob(r),t=e.length,n=new Uint8Array(t);for(let s=0;s<t;s++)n[s]=e.charCodeAt(s);return n.buffer}async function an(){if(!j()){console.info("webcrypto is not supported");return}let{crypto:r}=window,e=await v(tt);return e||r.getRandomValues(new Uint8Array(12))}async function cn(){if(!j()){console.info("webcrypto is not supported");return}let{subtle:r}=window.crypto,e=await v(et);return e||await r.generateKey({name:rt,length:on},!1,["encrypt","decrypt"])}async function Ot(r,e){let t=await an(),n=await cn();if(!t||!n||!r)return;let s=$t(r),{subtle:i}=window.crypto,o=await i.encrypt({name:rt,iv:t},n,s),a=At(o);await C(`${Ze}_${e}`,a),await C(et,n),await C(tt,t)}async function Lt(r){let e=await v(`${Ze}_${r}`),t=await v(tt),n=await v(et);if(!t||!e||!n||!j())return;let{subtle:s}=window.crypto,i=await s.decrypt({name:rt,iv:t},n,$t(e));return At(i)}function Te(r,e){return e?new URL(r,e):new URL(r)}var Pe=class extends y{getIdToken(e){let t=m(this.sdk.testMode?l.MagicPayloadMethod.GetIdTokenTestMode:l.MagicPayloadMethod.GetIdToken,[e]);return this.request(t)}generateIdToken(e){let t=m(this.sdk.testMode?l.MagicPayloadMethod.GenerateIdTokenTestMode:l.MagicPayloadMethod.GenerateIdToken,[e]);return this.request(t)}getInfo(){let e=m(l.MagicPayloadMethod.GetInfo,[]);return this.request(e)}isLoggedIn(){return M(async(e,t)=>{try{let n=!1;this.sdk.useStorageCache&&(n=await v(this.localForageIsLoggedInKey)==="true",n&&e(!0));let s=m(this.sdk.testMode?l.MagicPayloadMethod.IsLoggedInTestMode:l.MagicPayloadMethod.IsLoggedIn),i=await this.request(s);this.sdk.useStorageCache&&(i?C(this.localForageIsLoggedInKey,!0):$(this.localForageIsLoggedInKey),n&&!i&&this.emitUserLoggedOut(!0)),e(i)}catch(n){t(n)}})}logout(){return $(this.localForageIsLoggedInKey),$("rt"),ve(),M(async(e,t)=>{try{let n=m(this.sdk.testMode?l.MagicPayloadMethod.LogoutTestMode:l.MagicPayloadMethod.Logout),s=await this.request(n);this.sdk.useStorageCache&&this.emitUserLoggedOut(s),e(s)}catch(n){t(n)}})}requestInfoWithUI(e){let t=m(l.MagicPayloadMethod.RequestUserInfoWithUI,e?[e]:[]);return this.request(t)}showSettings(e){let{showUI:t=!0}=e||{},n=m(this.sdk.testMode?l.MagicPayloadMethod.UserSettingsTestMode:l.MagicPayloadMethod.UserSettings,[e]),s=this.request(n);return!t&&s&&(s.on(l.RecoveryFactorEventEmit.SendNewPhoneNumber,i=>{this.createIntermediaryEvent(l.RecoveryFactorEventEmit.SendNewPhoneNumber,n.id)(i)}),s.on(l.RecoveryFactorEventEmit.SendOtpCode,i=>{this.createIntermediaryEvent(l.RecoveryFactorEventEmit.SendOtpCode,n.id)(i)}),s.on(l.RecoveryFactorEventEmit.StartEditPhoneNumber,()=>{this.createIntermediaryEvent(l.RecoveryFactorEventEmit.StartEditPhoneNumber,n.id)()}),s.on(l.RecoveryFactorEventEmit.Cancel,()=>{this.createIntermediaryEvent(l.RecoveryFactorEventEmit.Cancel,n.id)()}),s.on(l.RecencyCheckEventEmit.VerifyEmailOtp,i=>{this.createIntermediaryEvent(l.RecencyCheckEventEmit.VerifyEmailOtp,n.id)(i)})),s}recoverAccount(e){let{email:t,showUI:n}=e,s=m(this.sdk.testMode?l.MagicPayloadMethod.RecoverAccountTestMode:l.MagicPayloadMethod.RecoverAccount,[{email:t,showUI:n}]),i=this.request(s);return!n&&i&&(i.on(l.RecoverAccountEventEmit.Cancel,()=>{this.createIntermediaryEvent(l.RecoverAccountEventEmit.Cancel,s.id)()}),i.on(l.RecoverAccountEventEmit.ResendSms,()=>{this.createIntermediaryEvent(l.RecoverAccountEventEmit.ResendSms,s.id)()}),i.on(l.RecoverAccountEventEmit.VerifyOtp,o=>{this.createIntermediaryEvent(l.RecoverAccountEventEmit.VerifyOtp,s.id)(o)}),i.on(l.RecoverAccountEventEmit.UpdateEmail,o=>{this.createIntermediaryEvent(l.RecoverAccountEventEmit.UpdateEmail,s.id)(o)}),i.on(l.UpdateEmailEventEmit.Cancel,()=>{this.createIntermediaryEvent(l.UpdateEmailEventEmit.Cancel,s.id)()}),i.on(l.UpdateEmailEventEmit.RetryWithNewEmail,o=>{this.createIntermediaryEvent(l.UpdateEmailEventEmit.RetryWithNewEmail,s.id)(o)}),i.on(l.UpdateEmailEventEmit.VerifyEmailOtp,o=>{this.createIntermediaryEvent(l.UpdateEmailEventEmit.VerifyEmailOtp,s.id)(o)})),i}revealEVMPrivateKey(){let e=m(l.MagicPayloadMethod.RevealPK,[{chain:"ETH"}]);return this.request(e)}revealPrivateKey(){throw new Error("revealPrivateKey() has been decommissioned. For EVM chains, use `user.revealEVMPrivateKey()` instead. For non-EVM chains, use `[extension].revealPrivateKey()` instead.")}onUserLoggedOut(e){this.userLoggedOutCallbacks.push(e)}enableMFA(e){let{showUI:t=!0}=e,n=m(l.MagicPayloadMethod.EnableMFA,[{showUI:t}]),s=this.request(n);return!t&&s&&(s.on(l.EnableMFAEventEmit.VerifyMFACode,i=>{this.createIntermediaryEvent(l.EnableMFAEventEmit.VerifyMFACode,n.id)(i)}),s.on(l.EnableMFAEventEmit.Cancel,()=>{this.createIntermediaryEvent(l.EnableMFAEventEmit.Cancel,n.id)()})),s}disableMFA(e){let{showUI:t=!0}=e,n=m(l.MagicPayloadMethod.DisableMFA,[{showUI:t}]),s=this.request(n);return!t&&s&&(s.on(l.DisableMFAEventEmit.VerifyMFACode,i=>{this.createIntermediaryEvent(l.DisableMFAEventEmit.VerifyMFACode,n.id)(i)}),s.on(l.DisableMFAEventEmit.LostDevice,i=>{this.createIntermediaryEvent(l.DisableMFAEventEmit.LostDevice,n.id)(i)}),s.on(l.DisableMFAEventEmit.Cancel,()=>{this.createIntermediaryEvent(l.DisableMFAEventEmit.Cancel,n.id)()})),s}emitUserLoggedOut(e){this.userLoggedOutCallbacks.forEach(t=>{t(e)})}localForageIsLoggedInKey="magic_auth_is_logged_in";userLoggedOutCallbacks=[]};var O=require("@magic-sdk/types");var Ie=class extends y{connectWithUI(e){let t=M(async(n,s)=>{try{let i=m(O.MagicPayloadMethod.Login,[{enabledWallets:this.sdk.thirdPartyWallets.enabledWallets,...e}]),o=this.request(i);this.sdk.thirdPartyWallets.eventListeners.forEach(({event:c,callback:p})=>{o.on(c,()=>p(i.id))}),o.on("id-token-created",c=>{t.emit("id-token-created",c)});let a=await o;a.error&&s(a),n(a)}catch(i){s(i)}});return t}showUI(e){return this.request(m(O.MagicPayloadMethod.ShowUI,[e]))}showAddress(){return this.request(m(O.MagicPayloadMethod.ShowAddress))}showSendTokensUI(){return this.request(m(O.MagicPayloadMethod.ShowSendTokensUI))}showOnRamp(){return this.request(m(O.MagicPayloadMethod.ShowOnRamp))}showNFTs(){return this.request(m(O.MagicPayloadMethod.ShowNFTs))}showBalances(){return this.request(m(O.MagicPayloadMethod.ShowBalances))}sign7702Authorization(e){return this.request(m(O.MagicPayloadMethod.Sign7702Authorization,[e]))}send7702Transaction(e){return this.request(m(O.MagicPayloadMethod.Send7702Transaction,[e]))}};var x=require("@magic-sdk/types");var be=class extends y{eventListeners=[];enabledWallets={};isConnected=!1;resetThirdPartyWalletState(){localStorage.removeItem(x.LocalStorageKeys.PROVIDER),localStorage.removeItem(x.LocalStorageKeys.ADDRESS),localStorage.removeItem(x.LocalStorageKeys.CHAIN_ID),this.isConnected=!1}requestOverride(e){if(e.method===x.MagicPayloadMethod.Login)return this.resetThirdPartyWalletState(),super.request(e);if(e.method===x.MagicPayloadMethod.GetInfo)return this.getInfo(e);if(e.method===x.MagicPayloadMethod.IsLoggedIn)return this.isLoggedIn(e);if(e.method===x.MagicPayloadMethod.Logout)return this.logout(e);switch(localStorage.getItem(x.LocalStorageKeys.PROVIDER)){case"magic-widget":return this.magicWidgetRequest(e);default:return this.resetThirdPartyWalletState(),super.request(e)}}isLoggedIn(e){switch(localStorage.getItem(x.LocalStorageKeys.PROVIDER)){case"magic-widget":return super.requestOverlay(e);default:return this.resetThirdPartyWalletState(),super.request(e)}}getInfo(e){switch(localStorage.getItem(x.LocalStorageKeys.PROVIDER)){case"magic-widget":return super.requestOverlay(e);default:return this.resetThirdPartyWalletState(),super.request(e)}}logout(e){let t=localStorage.getItem(x.LocalStorageKeys.PROVIDER);switch(this.resetThirdPartyWalletState(),t){case"magic-widget":return this.magicWidgetLogout(e);default:return super.request(e)}}magicWidgetRequest(e){return["eth_","wallet_","net_","web3_"].some(i=>e.method?.startsWith(i))||["personal_sign"].includes(e.method)?M((i,o)=>{this.sdk.walletKit.walletRequest(e).then(i).catch(a=>o(new U(a)))}):super.requestOverlay(e)}magicWidgetLogout(e){return M(async t=>{try{this.sdk.walletKit.clearConnectedState()}catch(n){console.error(n)}return super.requestOverlay(e)})}handleIframeThirdPartyWalletRequest(e){this.magicWidgetRequest(e.payload).then(t=>{this.overlay.postThirdPartyWalletResponse({id:e.payload.id,jsonrpc:"2.0",result:t})}).catch(t=>{this.overlay.postThirdPartyWalletResponse({id:e.payload.id,jsonrpc:"2.0",error:{code:t.code||-32603,message:t.message||"Internal error",data:t.data}})})}};var _t=require("@magic-sdk/types");var{createBoundEmitterMethod:we,createChainingEmitterMethod:H}=oe(),Se=class extends y{isMagic=!0;sendAsync(e,t){if(!t)throw Je({procedure:"Magic.rpcProvider.sendAsync",argument:1,expected:"function",received:t===null?"null":typeof t});if(Array.isArray(e)){let s=e.map(i=>F(i)).map(i=>this.request(i).then(o=>({jsonrpc:i.jsonrpc??"2.0",id:i.id??null,result:o,error:null})).catch(o=>({jsonrpc:i.jsonrpc??"2.0",id:i.id??null,error:o})));Promise.all(s).then(i=>{t(null,i)})}else this.request(F(e)).then(n=>{t(null,{jsonrpc:e.jsonrpc??"2.0",id:e.id??null,result:n,error:null})}).catch(n=>{t(n,{jsonrpc:e.jsonrpc??"2.0",id:e.id??null,error:n})})}send(e,t){if(typeof e=="string"){let s=m(e,Array.isArray(t)?t:[]);return this.request(s)}if(Array.isArray(e)||t){this.sendAsync(e,t);return}let n=Ke();return n.log(),new V(e).applyError({code:-32603,message:n.rawMessage}).payload}enable(){let e=m(_t.MagicPayloadMethod.Login);return this.request(e)}request(e){return this.prefixPayloadMethodForTestMode(e),super.request(e)}prefixPayloadMethodForTestMode(e){let t="testMode/eth/";this.sdk.testMode&&(e.method=`${t}${e.method}`)}on=H("on",this);once=H("once",this);addListener=H("addListener",this);off=H("off",this);removeListener=H("removeListener",this);removeAllListeners=H("removeAllListeners",this);emit=we("emit");eventNames=we("eventNames");listeners=we("listeners");listenerCount=we("listenerCount")};var q=require("@magic-sdk/types");var Me=class extends y{purchase(e){let t=m(q.MagicPayloadMethod.NFTPurchase,[e]);return this.request(t)}checkout(e){let t=this.sdk.thirdPartyWallets.isConnected,n=m(q.MagicPayloadMethod.NFTCheckout,[{...e,walletProvider:t?"web3modal":"magic"}]),s=this.request(n);return t&&(s.on(q.NftCheckoutIntermediaryEvents.Initiated,async i=>{try{let o=await this.request({method:"eth_sendTransaction",params:[i]});this.createIntermediaryEvent(q.NftCheckoutIntermediaryEvents.Success,n.id)(o)}catch{this.createIntermediaryEvent(q.NftCheckoutIntermediaryEvents.Failure,n.id)()}}),s.on(q.NftCheckoutIntermediaryEvents.Disconnect,()=>{this.sdk.thirdPartyWallets.resetThirdPartyWalletState(),s.emit("disconnect")})),s}transfer(e){let t=m(q.MagicPayloadMethod.NFTTransfer,[e]);return this.request(t)}};function Dt(r){return r.compat&&r.compat[g.sdkName]!=null?typeof r.compat[g.sdkName]=="string"?ft(yt(g.version),r.compat[g.sdkName]):!!r.compat[g.sdkName]:!0}function ln(r,e,t){return!e&&!t?`${r}_eth_mainnet`:t?`${r}_${JSON.stringify(t)}`:e?typeof e=="string"?`${r}_eth_${e}`:`${r}_${e.rpcUrl}_${e.chainId}_${e.chainType}`:`${r}_unknown`}function dn(r){let e=r?.extensions??[],t={},n=[];if(Array.isArray(e)?e.forEach(s=>{Dt(s)?(s.init(this),s.name&&(this[s.name]=s),K(s.config)||(t[s.name]=s.config)):n.push(s)}):Object.keys(e).forEach(s=>{if(Dt(e[s])){e[s].init(this);let i=e[s];this[s]=i,K(i.config)||(t[e[s].name]=i.config)}else n.push(e[s])}),n.length)throw Fe(n);return t}var xe=class r{constructor(e,t){this.apiKey=e;if(!e)throw ke();g.platform==="react-native"&&t?.endpoint&&Ge().log();let{defaultEndpoint:n,version:s}=g;this.testMode=!!t?.testMode,this.useStorageCache=!!t?.useStorageCache,this.endpoint=Te(t?.endpoint??n).origin,this.auth=new Re(this),this.user=new Pe(this),this.wallet=new Ie(this),this.nft=new Me(this),this.thirdPartyWallets=new be(this),this.rpcProvider=new Se(this);let i=dn.call(this,t);this.parameters=ee({API_KEY:this.apiKey,DOMAIN_ORIGIN:typeof window<"u"&&window?.location?window?.location.origin:"",ETH_NETWORK:t?.network,host:Te(this.endpoint).host,sdk:vt[g.sdkName],version:s,ext:K(i)?void 0:i,locale:t?.locale||"en_US",authConfig:t?.authConfig?{...t.authConfig}:void 0,...g.bundleId?{bundleId:g.bundleId}:{},meta:t?.meta}),this.networkHash=ln(this.apiKey,t?.network,K(i)?void 0:i),t?.deferPreload||this.preload()}static __overlays__=new Map;endpoint;parameters;networkHash;testMode;useStorageCache;auth;user;wallet;nft;thirdPartyWallets;rpcProvider;get overlay(){if(!r.__overlays__.has(this.parameters)){let e=new g.ViewController(this.endpoint,this.parameters,this.networkHash);e.init(),e.onThirdPartyWalletRequest(t=>this.thirdPartyWallets.handleIframeThirdPartyWalletRequest(t)),r.__overlays__.set(this.parameters,e)}return r.__overlays__.get(this.parameters)}async preload(){await this.overlay.waitForReady()}};var N=require("@magic-sdk/types");function un(r,e){return e&&Array.isArray(r)?r.find(t=>t.id===e):r}function qt(r,e){let t=e.data.response?.id,n=un(r,t);if(t&&n){let s=new V(n).applyResult(e.data.response.result).applyError(e.data.response.error);return{id:t,response:s}}return{}}function kt(r,e){let t=null;return function(...n){t&&clearTimeout(t),t=setTimeout(()=>{r(...n)},e)}}var pn=1e3,Ut=60*pn,Wt=5*Ut,hn=60*Ut,Ce=class{constructor(e,t,n){this.endpoint=e;this.parameters=t;this.networkHash=n;this.listen()}isReadyForRequest=!1;messageHandlers=new Set;isConnectedToInternet=!0;lastPongTime=null;heartbeatIntervalTimer=null;heartbeatDebounce=kt(()=>{this.endpoint==="https://auth.magic.link/"&&this.heartBeatCheck()},hn);thirdPartyWalletRequestHandler=()=>{};async post(e,t){return B(async(n,s)=>{if(!this.isConnectedToInternet){let u=re();s(u)}await this.checkRelayerExistsInDOM()||(this.isReadyForRequest=!1,await this.reloadRelayer()),this.isReadyForRequest||await this.waitForReady();let i=[],o=Array.isArray(t)?t.map(u=>u.id):[],a=await this.createMagicRequest(`${e}-${this.parameters}`,t,this.networkHash);await this._post(a);let c=u=>h=>{let{id:b,response:w}=qt(t,h);if(this.persistMagicEventRefreshToken(h),w?.payload.error?.message==="User denied account access.")ve();else if(h.data.deviceShare){let{deviceShare:Jt}=h.data;Ot(Jt,this.networkHash)}b&&w&&Array.isArray(t)&&o.includes(b)?(i.push(w),i.length===t.length&&(u(),n(i))):b&&w&&!Array.isArray(t)&&b===t.id&&(u(),n(w))},p=this.on(N.MagicIncomingWindowMessage.MAGIC_HANDLE_RESPONSE,c(()=>p()))})}async postThirdPartyWalletResponse(e){return B(async(t,n)=>{if(!this.isConnectedToInternet){let i=re();n(i)}await this.checkRelayerExistsInDOM()||(this.isReadyForRequest=!1,await this.reloadRelayer()),this.isReadyForRequest||await this.waitForReady();let s={msgType:`${N.MagicOutgoingWindowMessage.MAGIC_THIRD_PARTY_WALLET_RESPONSE}-${this.parameters}`,response:e};await this._post(s),t()})}async postThirdPartyWalletUpdate(e){return B(async(t,n)=>{if(!this.isConnectedToInternet){let o=re();n(o)}await this.checkRelayerExistsInDOM()||(this.isReadyForRequest=!1,await this.reloadRelayer()),this.isReadyForRequest||await this.waitForReady();let s=JSON.parse(JSON.stringify(e,(o,a)=>typeof a=="function"?void 0:a)),i={msgType:`${N.MagicOutgoingWindowMessage.MAGIC_THIRD_PARTY_WALLET_UPDATE}-${this.parameters}`,details:s};await this._post(i),t()})}on(e,t){let n=t.bind(window),s=i=>{i.data.msgType===`${e}-${this.parameters}`&&n(i)};return this.messageHandlers.add(s),()=>this.messageHandlers.delete(s)}waitForReady(){return new Promise(e=>{let t=this.on(N.MagicIncomingWindowMessage.MAGIC_OVERLAY_READY,()=>{this.isReadyForRequest=!0,e(),t()})})}onThirdPartyWalletRequest(e){this.thirdPartyWalletRequestHandler=e}listen(){this.on(N.MagicIncomingWindowMessage.MAGIC_HIDE_OVERLAY,()=>{this.hideOverlay()}),this.on(N.MagicIncomingWindowMessage.MAGIC_SHOW_OVERLAY,()=>{this.showOverlay()}),this.on(N.MagicIncomingWindowMessage.MAGIC_SEND_PRODUCT_ANNOUNCEMENT,e=>{e.data.response.result.product_announcement&&new D(N.SDKWarningCode.ProductAnnouncement,e.data.response.result.product_announcement).log()})}heartBeatCheck(){let e=!0,t=async()=>{let n={msgType:`${N.MagicOutgoingWindowMessage.MAGIC_PING}-${this.parameters}`,payload:[]};await this._post(n)};this.heartbeatIntervalTimer=setInterval(async()=>{if(this.lastPongTime){if(Date.now()-this.lastPongTime>Wt*2){this.reloadRelayer(),e=!0;return}}else if(!e){this.reloadRelayer(),e=!0;return}await t(),e=!1},Wt)}stopHeartBeat(){this.heartbeatDebounce(),this.lastPongTime=null,this.heartbeatIntervalTimer&&(clearInterval(this.heartbeatIntervalTimer),this.heartbeatIntervalTimer=null)}async persistMagicEventRefreshToken(e){e.data.rt&&await C("rt",e.data.rt)}async createMagicRequest(e,t,n){let s={msgType:e,payload:t},i=await this.getRT(),o=await this.getJWT(),a=await this.getDecryptedDeviceShare(n);return o&&(s.jwt=o),o&&i&&(s.rt=i),a&&(s.deviceShare=a),s}async getJWT(){if(g.platform==="web")try{let e=await v("jwt");return e||await Xe()}catch(e){return console.error("webcrypto error",e),null}else return null}async getRT(){return await v("rt")}async getDecryptedDeviceShare(e){return await Lt(e)}};var nt=require("@magic-sdk/types"),Ft=["request","overlay","sdk"];function mn(r){let e=Object.getPrototypeOf(r),t=[e];for(;e&&e!==y.prototype;)e=Object.getPrototypeOf(e),t.push(e);return t}var st=class extends y{compat;__sdk_access_field_descriptors__=new Map;__is_initialized__=!1;utils={createPromiEvent:M,isPromiEvent:Ye,encodeJSON:ee,decodeJSON:_e,createJsonRpcRequestPayload:m,standardizeJsonRpcRequestPayload:F,storage:ne};constructor(){super(void 0);let e=[this,...mn(this)];Ft.forEach(t=>{let n=e.map(a=>Object.getOwnPropertyDescriptor(a,t)),s=n.findIndex(a=>!!a),i=s>0,o=n[s];o&&(this.__sdk_access_field_descriptors__.set(t,{descriptor:o,isPrototypeField:i}),Object.defineProperty(this,t,{configurable:!0,get:()=>{throw Ue(t)}}))})}init(e){this.__is_initialized__||(Ft.forEach(t=>{if(this.__sdk_access_field_descriptors__.has(t)){let{descriptor:n,isPrototypeField:s}=this.__sdk_access_field_descriptors__.get(t);s?delete this[t]:Object.defineProperty(this,t,n)}}),this.sdk=e,this.__is_initialized__=!0)}createDeprecationWarning(e){let{method:t,removalVersion:n,useInstead:s}=e,i=s?` Use \`${s}\` instead.`:"",o=`\`${t}\` will be removed from this Extension in version \`${n}\`.${i}`;return new G(this,"DEPRECATION_NOTICE",o)}createWarning(e,t){return new G(this,e,t)}createError(e,t,n){return new te(this,e,t,n)}},Ne=class extends st{},Ae=class{static Internal=Ne},$e=class extends Ne{constructor(t){super();this.config=t;this.chain=t.chainType}chain;getPublicAddress(){return this.request(this.utils.createJsonRpcRequestPayload(nt.MagicPayloadMethod.GetMultichainPublicAddress,[{chain:this.chain}]))}revealPrivateKey(){return this.request(this.utils.createJsonRpcRequestPayload(nt.MagicPayloadMethod.RevealPK,[{chain:this.chain}]))}};
6
6
  //# sourceMappingURL=index.js.map