@magic-sdk/provider 17.1.5 → 17.2.0-canary.520.5050210538.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 Nt=Object.create;var Y=Object.defineProperty,$t=Object.defineProperties,At=Object.getOwnPropertyDescriptor,Ct=Object.getOwnPropertyDescriptors,St=Object.getOwnPropertyNames,Ye=Object.getOwnPropertySymbols,Lt=Object.getPrototypeOf,Qe=Object.prototype.hasOwnProperty,Ot=Object.prototype.propertyIsEnumerable;var Ze=(n,e,t)=>e in n?Y(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,j=(n,e)=>{for(var t in e||(e={}))Qe.call(e,t)&&Ze(n,t,e[t]);if(Ye)for(var t of Ye(e))Ot.call(e,t)&&Ze(n,t,e[t]);return n},de=(n,e)=>$t(n,Ct(e));var _t=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),et=(n,e)=>{for(var t in e)Y(n,t,{get:e[t],enumerable:!0})},tt=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of St(e))!Qe.call(n,o)&&o!==t&&Y(n,o,{get:()=>e[o],enumerable:!(r=At(e,o))||r.enumerable});return n};var kt=(n,e,t)=>(t=n!=null?Nt(Lt(n)):{},tt(e||!n||!n.__esModule?Y(t,"default",{value:n,enumerable:!0}):t,n)),qt=n=>tt(Y({},"__esModule",{value:!0}),n);var f=(n,e,t)=>new Promise((r,o)=>{var s=l=>{try{i(t.next(l))}catch(u){o(u)}},a=l=>{try{i(t.throw(l))}catch(u){o(u)}},i=l=>l.done?r(l.value):Promise.resolve(l.value).then(s,a);i((t=t.apply(n,e)).next())});var Rt=_t((fr,Ke)=>{"use strict";var Ln=Object.prototype.hasOwnProperty,b="~";function re(){}Object.create&&(re.prototype=Object.create(null),new re().__proto__||(b=!1));function On(n,e,t){this.fn=n,this.context=e,this.once=t||!1}function yt(n,e,t,r,o){if(typeof t!="function")throw new TypeError("The listener must be a function");var s=new On(t,r||n,o),a=b?b+e:e;return n._events[a]?n._events[a].fn?n._events[a]=[n._events[a],s]:n._events[a].push(s):(n._events[a]=s,n._eventsCount++),n}function ye(n,e){--n._eventsCount===0?n._events=new re:delete n._events[e]}function I(){this._events=new re,this._eventsCount=0}I.prototype.eventNames=function(){var e=[],t,r;if(this._eventsCount===0)return e;for(r in t=this._events)Ln.call(t,r)&&e.push(b?r.slice(1):r);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};I.prototype.listeners=function(e){var t=b?b+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);o<s;o++)a[o]=r[o].fn;return a};I.prototype.listenerCount=function(e){var t=b?b+e:e,r=this._events[t];return r?r.fn?1:r.length:0};I.prototype.emit=function(e,t,r,o,s,a){var i=b?b+e:e;if(!this._events[i])return!1;var l=this._events[i],u=arguments.length,c,d;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),u){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,r),!0;case 4:return l.fn.call(l.context,t,r,o),!0;case 5:return l.fn.call(l.context,t,r,o,s),!0;case 6:return l.fn.call(l.context,t,r,o,s,a),!0}for(d=1,c=new Array(u-1);d<u;d++)c[d-1]=arguments[d];l.fn.apply(l.context,c)}else{var w=l.length,q;for(d=0;d<w;d++)switch(l[d].once&&this.removeListener(e,l[d].fn,void 0,!0),u){case 1:l[d].fn.call(l[d].context);break;case 2:l[d].fn.call(l[d].context,t);break;case 3:l[d].fn.call(l[d].context,t,r);break;case 4:l[d].fn.call(l[d].context,t,r,o);break;default:if(!c)for(q=1,c=new Array(u-1);q<u;q++)c[q-1]=arguments[q];l[d].fn.apply(l[d].context,c)}}return!0};I.prototype.on=function(e,t,r){return yt(this,e,t,r,!1)};I.prototype.once=function(e,t,r){return yt(this,e,t,r,!0)};I.prototype.removeListener=function(e,t,r,o){var s=b?b+e:e;if(!this._events[s])return this;if(!t)return ye(this,s),this;var a=this._events[s];if(a.fn)a.fn===t&&(!o||a.once)&&(!r||a.context===r)&&ye(this,s);else{for(var i=0,l=[],u=a.length;i<u;i++)(a[i].fn!==t||o&&!a[i].once||r&&a[i].context!==r)&&l.push(a[i]);l.length?this._events[s]=l.length===1?l[0]:l:ye(this,s)}return this};I.prototype.removeAllListeners=function(e){var t;return e?(t=b?b+e:e,this._events[t]&&ye(this,t)):(this._events=new re,this._eventsCount=0),this};I.prototype.off=I.prototype.removeListener;I.prototype.addListener=I.prototype.on;I.prefixed=b;I.EventEmitter=I;typeof Ke<"u"&&(Ke.exports=I)});var er={};et(er,{Extension:()=>L,MagicExtensionError:()=>G,MagicExtensionWarning:()=>X,MagicRPCError:()=>S,MagicSDKError:()=>C,MagicSDKWarning:()=>F,SDKBase:()=>le,STORE_KEY_PRIVATE_KEY:()=>Pe,STORE_KEY_PUBLIC_JWK:()=>ie,TypedEmitter:()=>Re,ViewController:()=>Ce,clearKeys:()=>ae,createDeprecationWarning:()=>v,createDuplicateIframeWarning:()=>$n,createExtensionNotInitializedError:()=>We,createIncompatibleExtensionsError:()=>Ue,createInvalidArgumentError:()=>Je,createJwt:()=>Ve,createMalformedResponseError:()=>De,createMissingApiKeyError:()=>qe,createModalNotReadyError:()=>Nn,createPromiEvent:()=>oe,createPromise:()=>ve,createReactNativeEndpointConfigurationWarning:()=>Ge,createSDK:()=>ht,createSynchronousWeb3MethodWarning:()=>Fe,createTypedEmitter:()=>se,createURL:()=>Ne,decodeJSON:()=>Oe,encodeJSON:()=>te,getPayloadId:()=>ge,isEmpty:()=>ne,isJsonRpcErrorCode:()=>ke,isJsonRpcRequestPayload:()=>xn,isJsonRpcResponsePayload:()=>_e,isMagicPayloadMethod:()=>wn,isPromiEvent:()=>je,storage:()=>H,uuid:()=>Be});module.exports=qt(er);function Dt(n){let e={exports:{}};return n(e,e.exports),e.exports}var Wt=Number.MAX_SAFE_INTEGER||9007199254740991;var Le={SEMVER_SPEC_VERSION:"2.0.0",MAX_LENGTH:256,MAX_SAFE_INTEGER:Wt,MAX_SAFE_COMPONENT_LENGTH:16},Ut=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...n)=>console.error("SEMVER",...n):()=>{},h=Ut,ee=Dt(function(n,e){let{MAX_SAFE_COMPONENT_LENGTH:t}=Le,r=(e=n.exports={}).re=[],o=e.src=[],s=e.t={},a=0,i=(l,u,c)=>{let d=a++;h(d,u),s[l]=d,o[d]=u,r[d]=new RegExp(u,c?"g":void 0)};i("NUMERICIDENTIFIER","0|[1-9]\\d*"),i("NUMERICIDENTIFIERLOOSE","[0-9]+"),i("NONNUMERICIDENTIFIER","\\d*[a-zA-Z-][a-zA-Z0-9-]*"),i("MAINVERSION",`(${o[s.NUMERICIDENTIFIER]})\\.(${o[s.NUMERICIDENTIFIER]})\\.(${o[s.NUMERICIDENTIFIER]})`),i("MAINVERSIONLOOSE",`(${o[s.NUMERICIDENTIFIERLOOSE]})\\.(${o[s.NUMERICIDENTIFIERLOOSE]})\\.(${o[s.NUMERICIDENTIFIERLOOSE]})`),i("PRERELEASEIDENTIFIER",`(?:${o[s.NUMERICIDENTIFIER]}|${o[s.NONNUMERICIDENTIFIER]})`),i("PRERELEASEIDENTIFIERLOOSE",`(?:${o[s.NUMERICIDENTIFIERLOOSE]}|${o[s.NONNUMERICIDENTIFIER]})`),i("PRERELEASE",`(?:-(${o[s.PRERELEASEIDENTIFIER]}(?:\\.${o[s.PRERELEASEIDENTIFIER]})*))`),i("PRERELEASELOOSE",`(?:-?(${o[s.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${o[s.PRERELEASEIDENTIFIERLOOSE]})*))`),i("BUILDIDENTIFIER","[0-9A-Za-z-]+"),i("BUILD",`(?:\\+(${o[s.BUILDIDENTIFIER]}(?:\\.${o[s.BUILDIDENTIFIER]})*))`),i("FULLPLAIN",`v?${o[s.MAINVERSION]}${o[s.PRERELEASE]}?${o[s.BUILD]}?`),i("FULL",`^${o[s.FULLPLAIN]}$`),i("LOOSEPLAIN",`[v=\\s]*${o[s.MAINVERSIONLOOSE]}${o[s.PRERELEASELOOSE]}?${o[s.BUILD]}?`),i("LOOSE",`^${o[s.LOOSEPLAIN]}$`),i("GTLT","((?:<|>)?=?)"),i("XRANGEIDENTIFIERLOOSE",`${o[s.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),i("XRANGEIDENTIFIER",`${o[s.NUMERICIDENTIFIER]}|x|X|\\*`),i("XRANGEPLAIN",`[v=\\s]*(${o[s.XRANGEIDENTIFIER]})(?:\\.(${o[s.XRANGEIDENTIFIER]})(?:\\.(${o[s.XRANGEIDENTIFIER]})(?:${o[s.PRERELEASE]})?${o[s.BUILD]}?)?)?`),i("XRANGEPLAINLOOSE",`[v=\\s]*(${o[s.XRANGEIDENTIFIERLOOSE]})(?:\\.(${o[s.XRANGEIDENTIFIERLOOSE]})(?:\\.(${o[s.XRANGEIDENTIFIERLOOSE]})(?:${o[s.PRERELEASELOOSE]})?${o[s.BUILD]}?)?)?`),i("XRANGE",`^${o[s.GTLT]}\\s*${o[s.XRANGEPLAIN]}$`),i("XRANGELOOSE",`^${o[s.GTLT]}\\s*${o[s.XRANGEPLAINLOOSE]}$`),i("COERCE",`(^|[^\\d])(\\d{1,${t}})(?:\\.(\\d{1,${t}}))?(?:\\.(\\d{1,${t}}))?(?:$|[^\\d])`),i("COERCERTL",o[s.COERCE],!0),i("LONETILDE","(?:~>?)"),i("TILDETRIM",`(\\s*)${o[s.LONETILDE]}\\s+`,!0),e.tildeTrimReplace="$1~",i("TILDE",`^${o[s.LONETILDE]}${o[s.XRANGEPLAIN]}$`),i("TILDELOOSE",`^${o[s.LONETILDE]}${o[s.XRANGEPLAINLOOSE]}$`),i("LONECARET","(?:\\^)"),i("CARETTRIM",`(\\s*)${o[s.LONECARET]}\\s+`,!0),e.caretTrimReplace="$1^",i("CARET",`^${o[s.LONECARET]}${o[s.XRANGEPLAIN]}$`),i("CARETLOOSE",`^${o[s.LONECARET]}${o[s.XRANGEPLAINLOOSE]}$`),i("COMPARATORLOOSE",`^${o[s.GTLT]}\\s*(${o[s.LOOSEPLAIN]})$|^$`),i("COMPARATOR",`^${o[s.GTLT]}\\s*(${o[s.FULLPLAIN]})$|^$`),i("COMPARATORTRIM",`(\\s*)${o[s.GTLT]}\\s*(${o[s.LOOSEPLAIN]}|${o[s.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace="$1$2$3",i("HYPHENRANGE",`^\\s*(${o[s.XRANGEPLAIN]})\\s+-\\s+(${o[s.XRANGEPLAIN]})\\s*$`),i("HYPHENRANGELOOSE",`^\\s*(${o[s.XRANGEPLAINLOOSE]})\\s+-\\s+(${o[s.XRANGEPLAINLOOSE]})\\s*$`),i("STAR","(<|>)?=?\\s*\\*"),i("GTE0","^\\s*>=\\s*0.0.0\\s*$"),i("GTE0PRE","^\\s*>=\\s*0.0.0-0\\s*$")}),nt=/^[0-9]+$/,dt=(n,e)=>{let t=nt.test(n),r=nt.test(e);return t&&r&&(n=+n,e=+e),n===e?0:t&&!r?-1:r&&!t?1:n<e?-1:1},Jt=(n,e)=>dt(e,n),Ft={compareIdentifiers:dt,rcompareIdentifiers:Jt},{MAX_LENGTH:rt,MAX_SAFE_INTEGER:pe}=Le,{re:st,t:ot}=ee,{compareIdentifiers:Z}=Ft,y=class{constructor(e,t){if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),e instanceof y){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>rt)throw new TypeError(`version is longer than ${rt} characters`);h("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;let r=e.trim().match(t.loose?st[ot.LOOSE]:st[ot.FULL]);if(!r)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+r[1],this.minor=+r[2],this.patch=+r[3],this.major>pe||this.major<0)throw new TypeError("Invalid major version");if(this.minor>pe||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>pe||this.patch<0)throw new TypeError("Invalid patch version");r[4]?this.prerelease=r[4].split(".").map(o=>{if(/^[0-9]+$/.test(o)){let s=+o;if(s>=0&&s<pe)return s}return o}):this.prerelease=[],this.build=r[5]?r[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(h("SemVer.compare",this.version,this.options,e),!(e instanceof y)){if(typeof e=="string"&&e===this.version)return 0;e=new y(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof y||(e=new y(e,this.options)),Z(this.major,e.major)||Z(this.minor,e.minor)||Z(this.patch,e.patch)}comparePre(e){if(e instanceof y||(e=new y(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 r=this.prerelease[t],o=e.prerelease[t];if(h("prerelease compare",t,r,o),r===void 0&&o===void 0)return 0;if(o===void 0)return 1;if(r===void 0)return-1;if(r!==o)return Z(r,o)}while(++t)}compareBuild(e){e instanceof y||(e=new y(e,this.options));let t=0;do{let r=this.build[t],o=e.build[t];if(h("prerelease compare",t,r,o),r===void 0&&o===void 0)return 0;if(o===void 0)return 1;if(r===void 0)return-1;if(r!==o)return Z(r,o)}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 r=this.prerelease.length;for(;--r>=0;)typeof this.prerelease[r]=="number"&&(this.prerelease[r]++,r=-2);r===-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}},Gt=(n,e,t)=>new y(n,t).compare(new y(e,t)),B=Gt,Kt=(n,e,t)=>B(n,e,t)===0,jt=Kt,Bt=(n,e,t)=>B(n,e,t)!==0,Xt=Bt,Vt=(n,e,t)=>B(n,e,t)>0,Ht=Vt,zt=(n,e,t)=>B(n,e,t)>=0,Yt=zt,Zt=(n,e,t)=>B(n,e,t)<0,Qt=Zt,en=(n,e,t)=>B(n,e,t)<=0,tn=en,nn=(n,e,t,r)=>{switch(e){case"===":return typeof n=="object"&&(n=n.version),typeof t=="object"&&(t=t.version),n===t;case"!==":return typeof n=="object"&&(n=n.version),typeof t=="object"&&(t=t.version),n!==t;case"":case"=":case"==":return jt(n,t,r);case"!=":return Xt(n,t,r);case">":return Ht(n,t,r);case">=":return Yt(n,t,r);case"<":return Qt(n,t,r);case"<=":return tn(n,t,r);default:throw new TypeError(`Invalid operator: ${e}`)}},Se=nn,Q=Symbol("SemVer ANY"),D=class{static get ANY(){return Q}constructor(e,t){if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),e instanceof D){if(e.loose===!!t.loose)return e;e=e.value}h("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===Q?this.value="":this.value=this.operator+this.semver.version,h("comp",this)}parse(e){let t=this.options.loose?it[at.COMPARATORLOOSE]:it[at.COMPARATOR],r=e.match(t);if(!r)throw new TypeError(`Invalid comparator: ${e}`);this.operator=r[1]!==void 0?r[1]:"",this.operator==="="&&(this.operator=""),r[2]?this.semver=new y(r[2],this.options.loose):this.semver=Q}toString(){return this.value}test(e){if(h("Comparator.test",e,this.options.loose),this.semver===Q||e===Q)return!0;if(typeof e=="string")try{e=new y(e,this.options)}catch(t){return!1}return Se(e,this.operator,this.semver,this.options)}intersects(e,t){if(!(e instanceof D))throw new TypeError("a Comparator is required");if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),this.operator==="")return this.value===""||new O(e.value,t).test(this.value);if(e.operator==="")return e.value===""||new O(this.value,t).test(e.semver);let r=!(this.operator!==">="&&this.operator!==">"||e.operator!==">="&&e.operator!==">"),o=!(this.operator!=="<="&&this.operator!=="<"||e.operator!=="<="&&e.operator!=="<"),s=this.semver.version===e.semver.version,a=!(this.operator!==">="&&this.operator!=="<="||e.operator!==">="&&e.operator!=="<="),i=Se(this.semver,"<",e.semver,t)&&(this.operator===">="||this.operator===">")&&(e.operator==="<="||e.operator==="<"),l=Se(this.semver,">",e.semver,t)&&(this.operator==="<="||this.operator==="<")&&(e.operator===">="||e.operator===">");return r||o||s&&a||i||l}},{re:it,t:at}=ee,O=class{constructor(e,t){if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),e instanceof O)return e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease?e:new O(e.raw,t);if(e instanceof D)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(r=>this.parseRange(r.trim())).filter(r=>r.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 r=t?T[R.HYPHENRANGELOOSE]:T[R.HYPHENRANGE];e=e.replace(r,fn(this.options.includePrerelease)),h("hyphen replace",e),e=e.replace(T[R.COMPARATORTRIM],rn),h("comparator trim",e,T[R.COMPARATORTRIM]),e=(e=(e=e.replace(T[R.TILDETRIM],sn)).replace(T[R.CARETTRIM],on)).split(/\s+/).join(" ");let o=t?T[R.COMPARATORLOOSE]:T[R.COMPARATOR];return e.split(" ").map(s=>an(s,this.options)).join(" ").split(/\s+/).map(s=>En(s,this.options)).filter(this.options.loose?s=>!!s.match(o):()=>!0).map(s=>new D(s,this.options))}intersects(e,t){if(!(e instanceof O))throw new TypeError("a Range is required");return this.set.some(r=>lt(r,t)&&e.set.some(o=>lt(o,t)&&r.every(s=>o.every(a=>s.intersects(a,t)))))}test(e){if(!e)return!1;if(typeof e=="string")try{e=new y(e,this.options)}catch(t){return!1}for(let t=0;t<this.set.length;t++)if(gn(this.set[t],e,this.options))return!0;return!1}},{re:T,t:R,comparatorTrimReplace:rn,tildeTrimReplace:sn,caretTrimReplace:on}=ee,lt=(n,e)=>{let t=!0,r=n.slice(),o=r.pop();for(;t&&r.length;)t=r.every(s=>o.intersects(s,e)),o=r.pop();return t},an=(n,e)=>(h("comp",n,e),n=un(n,e),h("caret",n),n=ln(n,e),h("tildes",n),n=pn(n,e),h("xrange",n),n=hn(n,e),h("stars",n),n),P=n=>!n||n.toLowerCase()==="x"||n==="*",ln=(n,e)=>n.trim().split(/\s+/).map(t=>cn(t,e)).join(" "),cn=(n,e)=>{let t=e.loose?T[R.TILDELOOSE]:T[R.TILDE];return n.replace(t,(r,o,s,a,i)=>{let l;return h("tilde",n,r,o,s,a,i),P(o)?l="":P(s)?l=`>=${o}.0.0 <${+o+1}.0.0-0`:P(a)?l=`>=${o}.${s}.0 <${o}.${+s+1}.0-0`:i?(h("replaceTilde pr",i),l=`>=${o}.${s}.${a}-${i} <${o}.${+s+1}.0-0`):l=`>=${o}.${s}.${a} <${o}.${+s+1}.0-0`,h("tilde return",l),l})},un=(n,e)=>n.trim().split(/\s+/).map(t=>dn(t,e)).join(" "),dn=(n,e)=>{h("caret",n,e);let t=e.loose?T[R.CARETLOOSE]:T[R.CARET],r=e.includePrerelease?"-0":"";return n.replace(t,(o,s,a,i,l)=>{let u;return h("caret",n,o,s,a,i,l),P(s)?u="":P(a)?u=`>=${s}.0.0${r} <${+s+1}.0.0-0`:P(i)?u=s==="0"?`>=${s}.${a}.0${r} <${s}.${+a+1}.0-0`:`>=${s}.${a}.0${r} <${+s+1}.0.0-0`:l?(h("replaceCaret pr",l),u=s==="0"?a==="0"?`>=${s}.${a}.${i}-${l} <${s}.${a}.${+i+1}-0`:`>=${s}.${a}.${i}-${l} <${s}.${+a+1}.0-0`:`>=${s}.${a}.${i}-${l} <${+s+1}.0.0-0`):(h("no pr"),u=s==="0"?a==="0"?`>=${s}.${a}.${i}${r} <${s}.${a}.${+i+1}-0`:`>=${s}.${a}.${i}${r} <${s}.${+a+1}.0-0`:`>=${s}.${a}.${i} <${+s+1}.0.0-0`),h("caret return",u),u})},pn=(n,e)=>(h("replaceXRanges",n,e),n.split(/\s+/).map(t=>mn(t,e)).join(" ")),mn=(n,e)=>{n=n.trim();let t=e.loose?T[R.XRANGELOOSE]:T[R.XRANGE];return n.replace(t,(r,o,s,a,i,l)=>{h("xRange",n,r,o,s,a,i,l);let u=P(s),c=u||P(a),d=c||P(i),w=d;return o==="="&&w&&(o=""),l=e.includePrerelease?"-0":"",u?r=o===">"||o==="<"?"<0.0.0-0":"*":o&&w?(c&&(a=0),i=0,o===">"?(o=">=",c?(s=+s+1,a=0,i=0):(a=+a+1,i=0)):o==="<="&&(o="<",c?s=+s+1:a=+a+1),o==="<"&&(l="-0"),r=`${o+s}.${a}.${i}${l}`):c?r=`>=${s}.0.0${l} <${+s+1}.0.0-0`:d&&(r=`>=${s}.${a}.0${l} <${s}.${+a+1}.0-0`),h("xRange return",r),r})},hn=(n,e)=>(h("replaceStars",n,e),n.trim().replace(T[R.STAR],"")),En=(n,e)=>(h("replaceGTE0",n,e),n.trim().replace(T[e.includePrerelease?R.GTE0PRE:R.GTE0],"")),fn=n=>(e,t,r,o,s,a,i,l,u,c,d,w,q)=>`${t=P(r)?"":P(o)?`>=${r}.0.0${n?"-0":""}`:P(s)?`>=${r}.${o}.0${n?"-0":""}`:a?`>=${t}`:`>=${t}${n?"-0":""}`} ${l=P(u)?"":P(c)?`<${+u+1}.0.0-0`:P(d)?`<${u}.${+c+1}.0-0`:w?`<=${u}.${c}.${d}-${w}`:n?`<${u}.${c}.${+d+1}-0`:`<=${l}`}`.trim(),gn=(n,e,t)=>{for(let r=0;r<n.length;r++)if(!n[r].test(e))return!1;if(e.prerelease.length&&!t.includePrerelease){for(let r=0;r<n.length;r++)if(h(n[r].semver),n[r].semver!==D.ANY&&n[r].semver.prerelease.length>0){let o=n[r].semver;if(o.major===e.major&&o.minor===e.minor&&o.patch===e.patch)return!0}return!1}return!0},pt=(n,e,t)=>{try{e=new O(e,t)}catch(r){return!1}return e.test(n)};var{MAX_LENGTH:yn}=Le,{re:ct,t:ut}=ee,Rn=(n,e)=>{if(e&&typeof e=="object"||(e={loose:!!e,includePrerelease:!1}),n instanceof y)return n;if(typeof n!="string"||n.length>yn||!(e.loose?ct[ut.LOOSE]:ct[ut.FULL]).test(n))return null;try{return new y(n,e)}catch(t){return null}},vn=Rn,{re:me,t:he}=ee,mt=(n,e)=>{if(n instanceof y)return n;if(typeof n=="number"&&(n=String(n)),typeof n!="string")return null;let t=null;if((e=e||{}).rtl){let r;for(;(r=me[he.COERCERTL].exec(n))&&(!t||t.index+t[0].length!==n.length);)t&&r.index+r[0].length===t.index+t[0].length||(t=r),me[he.COERCERTL].lastIndex=r.index+r[1].length+r[2].length;me[he.COERCERTL].lastIndex=-1}else t=n.match(me[he.COERCE]);return t===null?null:vn(`${t[2]}.${t[3]||"0"}.${t[4]||"0"}`,e)};function Tn(n){return String.fromCharCode(parseInt(n.slice(1),16))}function In(n){return`%${`00${n.charCodeAt(0).toString(16)}`.slice(-2)}`}function Pn(n){return btoa(encodeURIComponent(n).replace(/%[0-9A-F]{2}/g,Tn))}function bn(n){return decodeURIComponent(Array.from(atob(n),In).join(""))}function te(n){return Pn(JSON.stringify(n))}function Oe(n){return JSON.parse(bn(n))}var N=require("@magic-sdk/types");var Ee=require("@magic-sdk/types");function _(n){return typeof n=="undefined"}function Mn(n){return n===null}function fe(n){return Mn(n)||_(n)}function xn(n){return fe(n)?!1:!_(n.jsonrpc)&&!_(n.id)&&!_(n.method)&&!_(n.params)}function _e(n){return fe(n)?!1:!_(n.jsonrpc)&&!_(n.id)&&(!_(n.result)||!_(n.error))}function wn(n){return fe(n)?!1:typeof n=="string"&&Object.values(Ee.MagicPayloadMethod).includes(n)}function ke(n){return fe(n)?!1:typeof n=="number"&&Object.values(Ee.RPCErrorCode).includes(n)}function ne(n){if(!n)return!0;for(let e in n)if(Object.hasOwnProperty.call(n,e))return!1;return!0}var m={};function ht(n,e){return Object.assign(m,e),n}var Et={"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 C=class extends Error{constructor(t,r){super(`Magic SDK Error: [${t}] ${r}`);this.code=t;this.rawMessage=r;this.__proto__=Error;Object.setPrototypeOf(this,C.prototype)}},S=class extends Error{constructor(t){super();this.__proto__=Error;let r=Number(t==null?void 0:t.code);this.rawMessage=(t==null?void 0:t.message)||"Internal error",this.code=ke(r)?r:N.RPCErrorCode.InternalError,this.message=`Magic RPC Error: [${this.code}] ${this.rawMessage}`,this.data=(t==null?void 0:t.data)||void 0,Object.setPrototypeOf(this,S.prototype)}},F=class{constructor(e,t){this.code=e;this.rawMessage=t;this.message=`Magic SDK Warning: [${e}] ${t}`}log(){console.warn(this.message)}},G=class extends Error{constructor(t,r,o,s){super(`Magic Extension Error (${t.name}): [${r}] ${o}`);this.code=r;this.rawMessage=o;this.data=s;this.__proto__=Error;Object.setPrototypeOf(this,G.prototype)}},X=class{constructor(e,t,r){this.code=t;this.rawMessage=r;this.message=`Magic Extension Warning (${e.name}): [${t}] ${r}`}log(){console.warn(this.message)}};function qe(){return new C(N.SDKErrorCode.MissingApiKey,"Please provide an API key that you acquired from the Magic developer dashboard.")}function Nn(){return new C(N.SDKErrorCode.ModalNotReady,"Modal is not ready.")}function De(){return new C(N.SDKErrorCode.MalformedResponse,"Response from the Magic iframe is malformed.")}function We(n){return new C(N.SDKErrorCode.ExtensionNotInitialized,`Extensions must be initialized with a Magic SDK instance before \`Extension.${n}\` can be accessed. Do not invoke \`Extension.${n}\` inside an extension constructor.`)}function Ue(n){let e=`Some extensions are incompatible with \`${m.sdkName}@${m.version}\`:`;return n.filter(t=>typeof t.compat!="undefined"&&t.compat!==null).forEach(t=>{let r=t.compat[m.sdkName];typeof r=="string"?e+=`
1
+ "use strict";var Nt=Object.create;var Y=Object.defineProperty,$t=Object.defineProperties,At=Object.getOwnPropertyDescriptor,Ct=Object.getOwnPropertyDescriptors,St=Object.getOwnPropertyNames,Ye=Object.getOwnPropertySymbols,Lt=Object.getPrototypeOf,Qe=Object.prototype.hasOwnProperty,_t=Object.prototype.propertyIsEnumerable;var Ze=(n,e,t)=>e in n?Y(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,j=(n,e)=>{for(var t in e||(e={}))Qe.call(e,t)&&Ze(n,t,e[t]);if(Ye)for(var t of Ye(e))_t.call(e,t)&&Ze(n,t,e[t]);return n},de=(n,e)=>$t(n,Ct(e));var Ot=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),et=(n,e)=>{for(var t in e)Y(n,t,{get:e[t],enumerable:!0})},tt=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of St(e))!Qe.call(n,o)&&o!==t&&Y(n,o,{get:()=>e[o],enumerable:!(r=At(e,o))||r.enumerable});return n};var kt=(n,e,t)=>(t=n!=null?Nt(Lt(n)):{},tt(e||!n||!n.__esModule?Y(t,"default",{value:n,enumerable:!0}):t,n)),qt=n=>tt(Y({},"__esModule",{value:!0}),n);var f=(n,e,t)=>new Promise((r,o)=>{var s=l=>{try{i(t.next(l))}catch(u){o(u)}},a=l=>{try{i(t.throw(l))}catch(u){o(u)}},i=l=>l.done?r(l.value):Promise.resolve(l.value).then(s,a);i((t=t.apply(n,e)).next())});var Rt=Ot((fr,Ke)=>{"use strict";var Ln=Object.prototype.hasOwnProperty,b="~";function re(){}Object.create&&(re.prototype=Object.create(null),new re().__proto__||(b=!1));function _n(n,e,t){this.fn=n,this.context=e,this.once=t||!1}function yt(n,e,t,r,o){if(typeof t!="function")throw new TypeError("The listener must be a function");var s=new _n(t,r||n,o),a=b?b+e:e;return n._events[a]?n._events[a].fn?n._events[a]=[n._events[a],s]:n._events[a].push(s):(n._events[a]=s,n._eventsCount++),n}function ye(n,e){--n._eventsCount===0?n._events=new re:delete n._events[e]}function I(){this._events=new re,this._eventsCount=0}I.prototype.eventNames=function(){var e=[],t,r;if(this._eventsCount===0)return e;for(r in t=this._events)Ln.call(t,r)&&e.push(b?r.slice(1):r);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};I.prototype.listeners=function(e){var t=b?b+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);o<s;o++)a[o]=r[o].fn;return a};I.prototype.listenerCount=function(e){var t=b?b+e:e,r=this._events[t];return r?r.fn?1:r.length:0};I.prototype.emit=function(e,t,r,o,s,a){var i=b?b+e:e;if(!this._events[i])return!1;var l=this._events[i],u=arguments.length,c,d;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),u){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,r),!0;case 4:return l.fn.call(l.context,t,r,o),!0;case 5:return l.fn.call(l.context,t,r,o,s),!0;case 6:return l.fn.call(l.context,t,r,o,s,a),!0}for(d=1,c=new Array(u-1);d<u;d++)c[d-1]=arguments[d];l.fn.apply(l.context,c)}else{var w=l.length,q;for(d=0;d<w;d++)switch(l[d].once&&this.removeListener(e,l[d].fn,void 0,!0),u){case 1:l[d].fn.call(l[d].context);break;case 2:l[d].fn.call(l[d].context,t);break;case 3:l[d].fn.call(l[d].context,t,r);break;case 4:l[d].fn.call(l[d].context,t,r,o);break;default:if(!c)for(q=1,c=new Array(u-1);q<u;q++)c[q-1]=arguments[q];l[d].fn.apply(l[d].context,c)}}return!0};I.prototype.on=function(e,t,r){return yt(this,e,t,r,!1)};I.prototype.once=function(e,t,r){return yt(this,e,t,r,!0)};I.prototype.removeListener=function(e,t,r,o){var s=b?b+e:e;if(!this._events[s])return this;if(!t)return ye(this,s),this;var a=this._events[s];if(a.fn)a.fn===t&&(!o||a.once)&&(!r||a.context===r)&&ye(this,s);else{for(var i=0,l=[],u=a.length;i<u;i++)(a[i].fn!==t||o&&!a[i].once||r&&a[i].context!==r)&&l.push(a[i]);l.length?this._events[s]=l.length===1?l[0]:l:ye(this,s)}return this};I.prototype.removeAllListeners=function(e){var t;return e?(t=b?b+e:e,this._events[t]&&ye(this,t)):(this._events=new re,this._eventsCount=0),this};I.prototype.off=I.prototype.removeListener;I.prototype.addListener=I.prototype.on;I.prefixed=b;I.EventEmitter=I;typeof Ke<"u"&&(Ke.exports=I)});var er={};et(er,{Extension:()=>L,MagicExtensionError:()=>G,MagicExtensionWarning:()=>X,MagicRPCError:()=>S,MagicSDKError:()=>C,MagicSDKWarning:()=>F,SDKBase:()=>le,STORE_KEY_PRIVATE_KEY:()=>Pe,STORE_KEY_PUBLIC_JWK:()=>ie,TypedEmitter:()=>Re,ViewController:()=>Ce,clearKeys:()=>ae,createDeprecationWarning:()=>v,createDuplicateIframeWarning:()=>$n,createExtensionNotInitializedError:()=>We,createIncompatibleExtensionsError:()=>Ue,createInvalidArgumentError:()=>Je,createJwt:()=>Ve,createMalformedResponseError:()=>De,createMissingApiKeyError:()=>qe,createModalNotReadyError:()=>Nn,createPromiEvent:()=>oe,createPromise:()=>ve,createReactNativeEndpointConfigurationWarning:()=>Ge,createSDK:()=>ht,createSynchronousWeb3MethodWarning:()=>Fe,createTypedEmitter:()=>se,createURL:()=>Ne,decodeJSON:()=>_e,encodeJSON:()=>te,getPayloadId:()=>ge,isEmpty:()=>ne,isJsonRpcErrorCode:()=>ke,isJsonRpcRequestPayload:()=>xn,isJsonRpcResponsePayload:()=>Oe,isMagicPayloadMethod:()=>wn,isPromiEvent:()=>je,storage:()=>H,uuid:()=>Be});module.exports=qt(er);function Dt(n){let e={exports:{}};return n(e,e.exports),e.exports}var Wt=Number.MAX_SAFE_INTEGER||9007199254740991;var Le={SEMVER_SPEC_VERSION:"2.0.0",MAX_LENGTH:256,MAX_SAFE_INTEGER:Wt,MAX_SAFE_COMPONENT_LENGTH:16},Ut=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...n)=>console.error("SEMVER",...n):()=>{},h=Ut,ee=Dt(function(n,e){let{MAX_SAFE_COMPONENT_LENGTH:t}=Le,r=(e=n.exports={}).re=[],o=e.src=[],s=e.t={},a=0,i=(l,u,c)=>{let d=a++;h(d,u),s[l]=d,o[d]=u,r[d]=new RegExp(u,c?"g":void 0)};i("NUMERICIDENTIFIER","0|[1-9]\\d*"),i("NUMERICIDENTIFIERLOOSE","[0-9]+"),i("NONNUMERICIDENTIFIER","\\d*[a-zA-Z-][a-zA-Z0-9-]*"),i("MAINVERSION",`(${o[s.NUMERICIDENTIFIER]})\\.(${o[s.NUMERICIDENTIFIER]})\\.(${o[s.NUMERICIDENTIFIER]})`),i("MAINVERSIONLOOSE",`(${o[s.NUMERICIDENTIFIERLOOSE]})\\.(${o[s.NUMERICIDENTIFIERLOOSE]})\\.(${o[s.NUMERICIDENTIFIERLOOSE]})`),i("PRERELEASEIDENTIFIER",`(?:${o[s.NUMERICIDENTIFIER]}|${o[s.NONNUMERICIDENTIFIER]})`),i("PRERELEASEIDENTIFIERLOOSE",`(?:${o[s.NUMERICIDENTIFIERLOOSE]}|${o[s.NONNUMERICIDENTIFIER]})`),i("PRERELEASE",`(?:-(${o[s.PRERELEASEIDENTIFIER]}(?:\\.${o[s.PRERELEASEIDENTIFIER]})*))`),i("PRERELEASELOOSE",`(?:-?(${o[s.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${o[s.PRERELEASEIDENTIFIERLOOSE]})*))`),i("BUILDIDENTIFIER","[0-9A-Za-z-]+"),i("BUILD",`(?:\\+(${o[s.BUILDIDENTIFIER]}(?:\\.${o[s.BUILDIDENTIFIER]})*))`),i("FULLPLAIN",`v?${o[s.MAINVERSION]}${o[s.PRERELEASE]}?${o[s.BUILD]}?`),i("FULL",`^${o[s.FULLPLAIN]}$`),i("LOOSEPLAIN",`[v=\\s]*${o[s.MAINVERSIONLOOSE]}${o[s.PRERELEASELOOSE]}?${o[s.BUILD]}?`),i("LOOSE",`^${o[s.LOOSEPLAIN]}$`),i("GTLT","((?:<|>)?=?)"),i("XRANGEIDENTIFIERLOOSE",`${o[s.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),i("XRANGEIDENTIFIER",`${o[s.NUMERICIDENTIFIER]}|x|X|\\*`),i("XRANGEPLAIN",`[v=\\s]*(${o[s.XRANGEIDENTIFIER]})(?:\\.(${o[s.XRANGEIDENTIFIER]})(?:\\.(${o[s.XRANGEIDENTIFIER]})(?:${o[s.PRERELEASE]})?${o[s.BUILD]}?)?)?`),i("XRANGEPLAINLOOSE",`[v=\\s]*(${o[s.XRANGEIDENTIFIERLOOSE]})(?:\\.(${o[s.XRANGEIDENTIFIERLOOSE]})(?:\\.(${o[s.XRANGEIDENTIFIERLOOSE]})(?:${o[s.PRERELEASELOOSE]})?${o[s.BUILD]}?)?)?`),i("XRANGE",`^${o[s.GTLT]}\\s*${o[s.XRANGEPLAIN]}$`),i("XRANGELOOSE",`^${o[s.GTLT]}\\s*${o[s.XRANGEPLAINLOOSE]}$`),i("COERCE",`(^|[^\\d])(\\d{1,${t}})(?:\\.(\\d{1,${t}}))?(?:\\.(\\d{1,${t}}))?(?:$|[^\\d])`),i("COERCERTL",o[s.COERCE],!0),i("LONETILDE","(?:~>?)"),i("TILDETRIM",`(\\s*)${o[s.LONETILDE]}\\s+`,!0),e.tildeTrimReplace="$1~",i("TILDE",`^${o[s.LONETILDE]}${o[s.XRANGEPLAIN]}$`),i("TILDELOOSE",`^${o[s.LONETILDE]}${o[s.XRANGEPLAINLOOSE]}$`),i("LONECARET","(?:\\^)"),i("CARETTRIM",`(\\s*)${o[s.LONECARET]}\\s+`,!0),e.caretTrimReplace="$1^",i("CARET",`^${o[s.LONECARET]}${o[s.XRANGEPLAIN]}$`),i("CARETLOOSE",`^${o[s.LONECARET]}${o[s.XRANGEPLAINLOOSE]}$`),i("COMPARATORLOOSE",`^${o[s.GTLT]}\\s*(${o[s.LOOSEPLAIN]})$|^$`),i("COMPARATOR",`^${o[s.GTLT]}\\s*(${o[s.FULLPLAIN]})$|^$`),i("COMPARATORTRIM",`(\\s*)${o[s.GTLT]}\\s*(${o[s.LOOSEPLAIN]}|${o[s.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace="$1$2$3",i("HYPHENRANGE",`^\\s*(${o[s.XRANGEPLAIN]})\\s+-\\s+(${o[s.XRANGEPLAIN]})\\s*$`),i("HYPHENRANGELOOSE",`^\\s*(${o[s.XRANGEPLAINLOOSE]})\\s+-\\s+(${o[s.XRANGEPLAINLOOSE]})\\s*$`),i("STAR","(<|>)?=?\\s*\\*"),i("GTE0","^\\s*>=\\s*0.0.0\\s*$"),i("GTE0PRE","^\\s*>=\\s*0.0.0-0\\s*$")}),nt=/^[0-9]+$/,dt=(n,e)=>{let t=nt.test(n),r=nt.test(e);return t&&r&&(n=+n,e=+e),n===e?0:t&&!r?-1:r&&!t?1:n<e?-1:1},Jt=(n,e)=>dt(e,n),Ft={compareIdentifiers:dt,rcompareIdentifiers:Jt},{MAX_LENGTH:rt,MAX_SAFE_INTEGER:pe}=Le,{re:st,t:ot}=ee,{compareIdentifiers:Z}=Ft,y=class{constructor(e,t){if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),e instanceof y){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>rt)throw new TypeError(`version is longer than ${rt} characters`);h("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;let r=e.trim().match(t.loose?st[ot.LOOSE]:st[ot.FULL]);if(!r)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+r[1],this.minor=+r[2],this.patch=+r[3],this.major>pe||this.major<0)throw new TypeError("Invalid major version");if(this.minor>pe||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>pe||this.patch<0)throw new TypeError("Invalid patch version");r[4]?this.prerelease=r[4].split(".").map(o=>{if(/^[0-9]+$/.test(o)){let s=+o;if(s>=0&&s<pe)return s}return o}):this.prerelease=[],this.build=r[5]?r[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(h("SemVer.compare",this.version,this.options,e),!(e instanceof y)){if(typeof e=="string"&&e===this.version)return 0;e=new y(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof y||(e=new y(e,this.options)),Z(this.major,e.major)||Z(this.minor,e.minor)||Z(this.patch,e.patch)}comparePre(e){if(e instanceof y||(e=new y(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 r=this.prerelease[t],o=e.prerelease[t];if(h("prerelease compare",t,r,o),r===void 0&&o===void 0)return 0;if(o===void 0)return 1;if(r===void 0)return-1;if(r!==o)return Z(r,o)}while(++t)}compareBuild(e){e instanceof y||(e=new y(e,this.options));let t=0;do{let r=this.build[t],o=e.build[t];if(h("prerelease compare",t,r,o),r===void 0&&o===void 0)return 0;if(o===void 0)return 1;if(r===void 0)return-1;if(r!==o)return Z(r,o)}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 r=this.prerelease.length;for(;--r>=0;)typeof this.prerelease[r]=="number"&&(this.prerelease[r]++,r=-2);r===-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}},Gt=(n,e,t)=>new y(n,t).compare(new y(e,t)),B=Gt,Kt=(n,e,t)=>B(n,e,t)===0,jt=Kt,Bt=(n,e,t)=>B(n,e,t)!==0,Xt=Bt,Vt=(n,e,t)=>B(n,e,t)>0,Ht=Vt,zt=(n,e,t)=>B(n,e,t)>=0,Yt=zt,Zt=(n,e,t)=>B(n,e,t)<0,Qt=Zt,en=(n,e,t)=>B(n,e,t)<=0,tn=en,nn=(n,e,t,r)=>{switch(e){case"===":return typeof n=="object"&&(n=n.version),typeof t=="object"&&(t=t.version),n===t;case"!==":return typeof n=="object"&&(n=n.version),typeof t=="object"&&(t=t.version),n!==t;case"":case"=":case"==":return jt(n,t,r);case"!=":return Xt(n,t,r);case">":return Ht(n,t,r);case">=":return Yt(n,t,r);case"<":return Qt(n,t,r);case"<=":return tn(n,t,r);default:throw new TypeError(`Invalid operator: ${e}`)}},Se=nn,Q=Symbol("SemVer ANY"),D=class{static get ANY(){return Q}constructor(e,t){if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),e instanceof D){if(e.loose===!!t.loose)return e;e=e.value}h("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===Q?this.value="":this.value=this.operator+this.semver.version,h("comp",this)}parse(e){let t=this.options.loose?it[at.COMPARATORLOOSE]:it[at.COMPARATOR],r=e.match(t);if(!r)throw new TypeError(`Invalid comparator: ${e}`);this.operator=r[1]!==void 0?r[1]:"",this.operator==="="&&(this.operator=""),r[2]?this.semver=new y(r[2],this.options.loose):this.semver=Q}toString(){return this.value}test(e){if(h("Comparator.test",e,this.options.loose),this.semver===Q||e===Q)return!0;if(typeof e=="string")try{e=new y(e,this.options)}catch(t){return!1}return Se(e,this.operator,this.semver,this.options)}intersects(e,t){if(!(e instanceof D))throw new TypeError("a Comparator is required");if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),this.operator==="")return this.value===""||new _(e.value,t).test(this.value);if(e.operator==="")return e.value===""||new _(this.value,t).test(e.semver);let r=!(this.operator!==">="&&this.operator!==">"||e.operator!==">="&&e.operator!==">"),o=!(this.operator!=="<="&&this.operator!=="<"||e.operator!=="<="&&e.operator!=="<"),s=this.semver.version===e.semver.version,a=!(this.operator!==">="&&this.operator!=="<="||e.operator!==">="&&e.operator!=="<="),i=Se(this.semver,"<",e.semver,t)&&(this.operator===">="||this.operator===">")&&(e.operator==="<="||e.operator==="<"),l=Se(this.semver,">",e.semver,t)&&(this.operator==="<="||this.operator==="<")&&(e.operator===">="||e.operator===">");return r||o||s&&a||i||l}},{re:it,t:at}=ee,_=class{constructor(e,t){if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),e instanceof _)return e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease?e:new _(e.raw,t);if(e instanceof D)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(r=>this.parseRange(r.trim())).filter(r=>r.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 r=t?T[R.HYPHENRANGELOOSE]:T[R.HYPHENRANGE];e=e.replace(r,fn(this.options.includePrerelease)),h("hyphen replace",e),e=e.replace(T[R.COMPARATORTRIM],rn),h("comparator trim",e,T[R.COMPARATORTRIM]),e=(e=(e=e.replace(T[R.TILDETRIM],sn)).replace(T[R.CARETTRIM],on)).split(/\s+/).join(" ");let o=t?T[R.COMPARATORLOOSE]:T[R.COMPARATOR];return e.split(" ").map(s=>an(s,this.options)).join(" ").split(/\s+/).map(s=>En(s,this.options)).filter(this.options.loose?s=>!!s.match(o):()=>!0).map(s=>new D(s,this.options))}intersects(e,t){if(!(e instanceof _))throw new TypeError("a Range is required");return this.set.some(r=>lt(r,t)&&e.set.some(o=>lt(o,t)&&r.every(s=>o.every(a=>s.intersects(a,t)))))}test(e){if(!e)return!1;if(typeof e=="string")try{e=new y(e,this.options)}catch(t){return!1}for(let t=0;t<this.set.length;t++)if(gn(this.set[t],e,this.options))return!0;return!1}},{re:T,t:R,comparatorTrimReplace:rn,tildeTrimReplace:sn,caretTrimReplace:on}=ee,lt=(n,e)=>{let t=!0,r=n.slice(),o=r.pop();for(;t&&r.length;)t=r.every(s=>o.intersects(s,e)),o=r.pop();return t},an=(n,e)=>(h("comp",n,e),n=un(n,e),h("caret",n),n=ln(n,e),h("tildes",n),n=pn(n,e),h("xrange",n),n=hn(n,e),h("stars",n),n),P=n=>!n||n.toLowerCase()==="x"||n==="*",ln=(n,e)=>n.trim().split(/\s+/).map(t=>cn(t,e)).join(" "),cn=(n,e)=>{let t=e.loose?T[R.TILDELOOSE]:T[R.TILDE];return n.replace(t,(r,o,s,a,i)=>{let l;return h("tilde",n,r,o,s,a,i),P(o)?l="":P(s)?l=`>=${o}.0.0 <${+o+1}.0.0-0`:P(a)?l=`>=${o}.${s}.0 <${o}.${+s+1}.0-0`:i?(h("replaceTilde pr",i),l=`>=${o}.${s}.${a}-${i} <${o}.${+s+1}.0-0`):l=`>=${o}.${s}.${a} <${o}.${+s+1}.0-0`,h("tilde return",l),l})},un=(n,e)=>n.trim().split(/\s+/).map(t=>dn(t,e)).join(" "),dn=(n,e)=>{h("caret",n,e);let t=e.loose?T[R.CARETLOOSE]:T[R.CARET],r=e.includePrerelease?"-0":"";return n.replace(t,(o,s,a,i,l)=>{let u;return h("caret",n,o,s,a,i,l),P(s)?u="":P(a)?u=`>=${s}.0.0${r} <${+s+1}.0.0-0`:P(i)?u=s==="0"?`>=${s}.${a}.0${r} <${s}.${+a+1}.0-0`:`>=${s}.${a}.0${r} <${+s+1}.0.0-0`:l?(h("replaceCaret pr",l),u=s==="0"?a==="0"?`>=${s}.${a}.${i}-${l} <${s}.${a}.${+i+1}-0`:`>=${s}.${a}.${i}-${l} <${s}.${+a+1}.0-0`:`>=${s}.${a}.${i}-${l} <${+s+1}.0.0-0`):(h("no pr"),u=s==="0"?a==="0"?`>=${s}.${a}.${i}${r} <${s}.${a}.${+i+1}-0`:`>=${s}.${a}.${i}${r} <${s}.${+a+1}.0-0`:`>=${s}.${a}.${i} <${+s+1}.0.0-0`),h("caret return",u),u})},pn=(n,e)=>(h("replaceXRanges",n,e),n.split(/\s+/).map(t=>mn(t,e)).join(" ")),mn=(n,e)=>{n=n.trim();let t=e.loose?T[R.XRANGELOOSE]:T[R.XRANGE];return n.replace(t,(r,o,s,a,i,l)=>{h("xRange",n,r,o,s,a,i,l);let u=P(s),c=u||P(a),d=c||P(i),w=d;return o==="="&&w&&(o=""),l=e.includePrerelease?"-0":"",u?r=o===">"||o==="<"?"<0.0.0-0":"*":o&&w?(c&&(a=0),i=0,o===">"?(o=">=",c?(s=+s+1,a=0,i=0):(a=+a+1,i=0)):o==="<="&&(o="<",c?s=+s+1:a=+a+1),o==="<"&&(l="-0"),r=`${o+s}.${a}.${i}${l}`):c?r=`>=${s}.0.0${l} <${+s+1}.0.0-0`:d&&(r=`>=${s}.${a}.0${l} <${s}.${+a+1}.0-0`),h("xRange return",r),r})},hn=(n,e)=>(h("replaceStars",n,e),n.trim().replace(T[R.STAR],"")),En=(n,e)=>(h("replaceGTE0",n,e),n.trim().replace(T[e.includePrerelease?R.GTE0PRE:R.GTE0],"")),fn=n=>(e,t,r,o,s,a,i,l,u,c,d,w,q)=>`${t=P(r)?"":P(o)?`>=${r}.0.0${n?"-0":""}`:P(s)?`>=${r}.${o}.0${n?"-0":""}`:a?`>=${t}`:`>=${t}${n?"-0":""}`} ${l=P(u)?"":P(c)?`<${+u+1}.0.0-0`:P(d)?`<${u}.${+c+1}.0-0`:w?`<=${u}.${c}.${d}-${w}`:n?`<${u}.${c}.${+d+1}-0`:`<=${l}`}`.trim(),gn=(n,e,t)=>{for(let r=0;r<n.length;r++)if(!n[r].test(e))return!1;if(e.prerelease.length&&!t.includePrerelease){for(let r=0;r<n.length;r++)if(h(n[r].semver),n[r].semver!==D.ANY&&n[r].semver.prerelease.length>0){let o=n[r].semver;if(o.major===e.major&&o.minor===e.minor&&o.patch===e.patch)return!0}return!1}return!0},pt=(n,e,t)=>{try{e=new _(e,t)}catch(r){return!1}return e.test(n)};var{MAX_LENGTH:yn}=Le,{re:ct,t:ut}=ee,Rn=(n,e)=>{if(e&&typeof e=="object"||(e={loose:!!e,includePrerelease:!1}),n instanceof y)return n;if(typeof n!="string"||n.length>yn||!(e.loose?ct[ut.LOOSE]:ct[ut.FULL]).test(n))return null;try{return new y(n,e)}catch(t){return null}},vn=Rn,{re:me,t:he}=ee,mt=(n,e)=>{if(n instanceof y)return n;if(typeof n=="number"&&(n=String(n)),typeof n!="string")return null;let t=null;if((e=e||{}).rtl){let r;for(;(r=me[he.COERCERTL].exec(n))&&(!t||t.index+t[0].length!==n.length);)t&&r.index+r[0].length===t.index+t[0].length||(t=r),me[he.COERCERTL].lastIndex=r.index+r[1].length+r[2].length;me[he.COERCERTL].lastIndex=-1}else t=n.match(me[he.COERCE]);return t===null?null:vn(`${t[2]}.${t[3]||"0"}.${t[4]||"0"}`,e)};function Tn(n){return String.fromCharCode(parseInt(n.slice(1),16))}function In(n){return`%${`00${n.charCodeAt(0).toString(16)}`.slice(-2)}`}function Pn(n){return btoa(encodeURIComponent(n).replace(/%[0-9A-F]{2}/g,Tn))}function bn(n){return decodeURIComponent(Array.from(atob(n),In).join(""))}function te(n){return Pn(JSON.stringify(n))}function _e(n){return JSON.parse(bn(n))}var N=require("@magic-sdk/types");var Ee=require("@magic-sdk/types");function O(n){return typeof n=="undefined"}function Mn(n){return n===null}function fe(n){return Mn(n)||O(n)}function xn(n){return fe(n)?!1:!O(n.jsonrpc)&&!O(n.id)&&!O(n.method)&&!O(n.params)}function Oe(n){return fe(n)?!1:!O(n.jsonrpc)&&!O(n.id)&&(!O(n.result)||!O(n.error))}function wn(n){return fe(n)?!1:typeof n=="string"&&Object.values(Ee.MagicPayloadMethod).includes(n)}function ke(n){return fe(n)?!1:typeof n=="number"&&Object.values(Ee.RPCErrorCode).includes(n)}function ne(n){if(!n)return!0;for(let e in n)if(Object.hasOwnProperty.call(n,e))return!1;return!0}var m={};function ht(n,e){return Object.assign(m,e),n}var Et={"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 C=class extends Error{constructor(t,r){super(`Magic SDK Error: [${t}] ${r}`);this.code=t;this.rawMessage=r;this.__proto__=Error;Object.setPrototypeOf(this,C.prototype)}},S=class extends Error{constructor(t){super();this.__proto__=Error;let r=Number(t==null?void 0:t.code);this.rawMessage=(t==null?void 0:t.message)||"Internal error",this.code=ke(r)?r:N.RPCErrorCode.InternalError,this.message=`Magic RPC Error: [${this.code}] ${this.rawMessage}`,this.data=(t==null?void 0:t.data)||void 0,Object.setPrototypeOf(this,S.prototype)}},F=class{constructor(e,t){this.code=e;this.rawMessage=t;this.message=`Magic SDK Warning: [${e}] ${t}`}log(){console.warn(this.message)}},G=class extends Error{constructor(t,r,o,s){super(`Magic Extension Error (${t.name}): [${r}] ${o}`);this.code=r;this.rawMessage=o;this.data=s;this.__proto__=Error;Object.setPrototypeOf(this,G.prototype)}},X=class{constructor(e,t,r){this.code=t;this.rawMessage=r;this.message=`Magic Extension Warning (${e.name}): [${t}] ${r}`}log(){console.warn(this.message)}};function qe(){return new C(N.SDKErrorCode.MissingApiKey,"Please provide an API key that you acquired from the Magic developer dashboard.")}function Nn(){return new C(N.SDKErrorCode.ModalNotReady,"Modal is not ready.")}function De(){return new C(N.SDKErrorCode.MalformedResponse,"Response from the Magic iframe is malformed.")}function We(n){return new C(N.SDKErrorCode.ExtensionNotInitialized,`Extensions must be initialized with a Magic SDK instance before \`Extension.${n}\` can be accessed. Do not invoke \`Extension.${n}\` inside an extension constructor.`)}function Ue(n){let e=`Some extensions are incompatible with \`${m.sdkName}@${m.version}\`:`;return n.filter(t=>typeof t.compat!="undefined"&&t.compat!==null).forEach(t=>{let r=t.compat[m.sdkName];typeof r=="string"?e+=`
2
2
  - Extension \`${t.name}\` supports version(s) \`${r}\``:r||(e+=`
3
3
  - Extension \`${t.name}\` does not support ${m.platform} environments.`)}),new C(N.SDKErrorCode.IncompatibleExtensions,e)}function Je(n){let e=t=>{let r=t+1,o=r%10,s=r%100;return o===1&&s!==11?`${r}st`:o===2&&s!==12?`${r}nd`:o===3&&s!==13?`${r}rd`:`${r}th`};return new C(N.SDKErrorCode.InvalidArgument,`Invalid ${e(n.argument)} argument given to \`${n.procedure}\`.
4
4
  Expected: \`${n.expected}\`
5
- Received: \`${n.received}\``)}function $n(){return new F(N.SDKWarningCode.DuplicateIframe,"Duplicate iframes found.")}function Fe(){return new F(N.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 F(N.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 \`${m.defaultEndpoint}\`. Changing this default behavior will lead to unexpected results and potentially security-threatening bugs.`)}function v(n){let{method:e,removalVersions:t,useInstead:r}=n,o=t[m.sdkName],s=r?` Use \`${r}\` instead.`:"",a=`\`${e}\` will be removed from \`${m.sdkName}\` in version \`${o}\`.${s}`;return new F(N.SDKWarningCode.DeprecationNotice,a)}var $=require("@magic-sdk/types");var V=require("@magic-sdk/types");function*An(){let n=0;for(;;)n<Number.MAX_SAFE_INTEGER?yield++n:n=0}var Cn=An();function ge(){return Cn.next().value}var ft=Symbol("Payload pre-processed by Magic SDK");function gt(n){return Object.defineProperty(n,ft,{value:!0,enumerable:!1}),n}function Sn(n){return!!n[ft]}function K(n){var e,t,r;return Sn(n)||(n.jsonrpc=(e=n.jsonrpc)!=null?e:"2.0",n.id=ge(),n.method=(t=n.method)!=null?t:"noop",n.params=(r=n.params)!=null?r:[],gt(n)),n}function p(n,e=[]){return gt({params:e,method:n,jsonrpc:"2.0",id:ge()})}var W=class{constructor(e){e instanceof W?(this._jsonrpc=e.payload.jsonrpc,this._id=e.payload.id,this._result=e.payload.result,this._error=e.payload.error):_e(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 typeof this._error!="undefined"&&this._error!==null}get hasResult(){return typeof this._result!="undefined"}get payload(){return{jsonrpc:this._jsonrpc,id:this._id,result:this._result,error:this._error}}};var vt=kt(Rt()),Re=class extends vt.default{};function se(){let n=new Re;return{emitter:n,createChainingEmitterMethod:(r,o)=>(...s)=>(n[r].apply(n,s),o),createBoundEmitterMethod:r=>(...o)=>n[r].apply(n,o)}}var Tt=Symbol("isPromiEvent");function je(n){return!!n[Tt]}function oe(n){let e=ve(n),{createBoundEmitterMethod:t,createChainingEmitterMethod:r}=se(),o=Symbol("Promise.then"),s=Symbol("Promise.catch"),a=Symbol("Promise.finally"),i=(c,d)=>(...w)=>{let q=d[c].apply(d,w);return l(q)},l=c=>Object.assign(c,{[Tt]:!0,[o]:c[o]||c.then,[s]:c[s]||c.catch,[a]:c[a]||c.finally,then:i(o,c),catch:i(s,c),finally:i(a,c),on:r("on",c),once:r("once",c),addListener:r("addListener",c),off:r("off",c),removeListener:r("removeListener",c),removeAllListeners:r("removeAllListeners",c),emit:t("emit"),eventNames:t("eventNames"),listeners:t("listeners"),listenerCount:t("listenerCount")}),u=l(e.then(c=>(u.emit("done",c),u.emit("settled"),c),c=>{throw u.emit("error",c),u.emit("settled"),c}));return u}function ve(n){return new Promise((e,t)=>{let r=n(e,t);Promise.resolve(r).catch(t)})}var M=class{constructor(e){this.sdk=e}get overlay(){return this.sdk.overlay}request(e){let t=this.overlay.post(V.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST,K(e)),r=oe((s,a)=>{t.then(i=>{if(o(),i.hasError)a(new S(i.payload.error));else if(i.hasResult)s(i.payload.result);else throw De()}).catch(i=>{o(),a(i)})}),o=this.overlay.on(V.MagicIncomingWindowMessage.MAGIC_HANDLE_EVENT,s=>{var i;let{response:a}=s.data;if(a.id===e.id&&((i=a.result)==null?void 0:i.event)){let{event:l,params:u=[]}=a.result;r.emit(l,...u)}});return r}createIntermediaryEvent(e,t){return o=>{let s=p(V.MagicPayloadMethod.IntermediaryEvent,[{payloadId:t,eventType:e,args:o}]);this.request(s)}}};var x={"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"},Te=class extends M{loginWithMagicLink(e){let t=m.sdkName==="@magic-sdk/react-native"||m.sdkName==="@magic-sdk/react-native-bare"||m.sdkName==="@magic-sdk/react-native-expo";v({method:"auth.loginWithMagicLink()",removalVersions:x,useInstead:t?"@magic-ext/auth auth.loginWithEmailOTP()":"@magic-ext/auth auth.loginWithMagicLink()"}).log();let{email:r,showUI:o=!0,redirectURI:s}=e,a=p(this.sdk.testMode?$.MagicPayloadMethod.LoginWithMagicLinkTestMode:$.MagicPayloadMethod.LoginWithMagicLink,[{email:r,showUI:o,redirectURI:s}]);return this.request(a)}loginWithSMS(e){v({method:"auth.loginWithSMS()",removalVersions:x,useInstead:"@magic-ext/auth auth.loginWithSMS()"}).log();let{phoneNumber:t}=e,r=p(this.sdk.testMode?$.MagicPayloadMethod.LoginWithSmsTestMode:$.MagicPayloadMethod.LoginWithSms,[{phoneNumber:t,showUI:!0}]);return this.request(r)}loginWithEmailOTP(e){v({method:"auth.loginWithEmailOTP()",removalVersions:x,useInstead:"@magic-ext/auth auth.loginWithEmailOTP()"}).log();let{email:t,showUI:r}=e,o=p(this.sdk.testMode?$.MagicPayloadMethod.LoginWithEmailOTPTestMode:$.MagicPayloadMethod.LoginWithEmailOTP,[{email:t,showUI:r}]);if(!r){let s=this.request(o);return s&&(s.on("verify-email-otp",a=>{this.createIntermediaryEvent("verify-email-otp",o.id)(a)}),s.on("cancel",()=>{this.createIntermediaryEvent("cancel",o.id)()})),s}return this.request(o)}loginWithCredential(e){v({method:"auth.loginWithCredential()",removalVersions:x,useInstead:"@magic-ext/auth auth.loginWithCredential()"}).log();let t=e!=null?e:"";if(!e&&m.platform==="web"){t=window.location.search;let o=window.location.origin+window.location.pathname;window.history.replaceState(null,"",o)}let r=p(this.sdk.testMode?$.MagicPayloadMethod.LoginWithCredentialTestMode:$.MagicPayloadMethod.LoginWithCredential,[t]);return this.request(r)}setAuthorizationToken(e){v({method:"auth.setAuthorizationToken()",removalVersions:x,useInstead:"@magic-ext/auth auth.setAuthorizationToken()"}).log();let t=p($.MagicPayloadMethod.SetAuthorizationToken,[{jwt:e}]);return this.request(t)}updateEmailWithUI(e){v({method:"auth.updateEmailWithUI()",removalVersions:x,useInstead:"@magic-ext/auth auth.updateEmailWithUI()"}).log();let{email:t,showUI:r=!0}=e,o=p(this.sdk.testMode?$.MagicPayloadMethod.UpdateEmailTestMode:$.MagicPayloadMethod.UpdateEmail,[{email:t,showUI:r}]);return this.request(o)}updatePhoneNumberWithUI(){v({method:"auth.updatePhoneNumberWithUI()",removalVersions:x,useInstead:"@magic-ext/auth auth.updatePhoneNumberWithUI()"}).log();let e=p(this.sdk.testMode?$.MagicPayloadMethod.UpdatePhoneNumberTestMode:$.MagicPayloadMethod.UpdatePhoneNumber);return this.request(e)}};var g=require("@magic-sdk/types");var H={};et(H,{clear:()=>_n,getItem:()=>A,iterate:()=>Wn,key:()=>qn,keys:()=>Dn,length:()=>kn,removeItem:()=>J,setItem:()=>k});var Ie;function U(n){return(...e)=>f(this,null,function*(){return Ie||(Ie=yield m.configureStorage()),yield Ie.ready(),Ie[n](...e)})}var A=U("getItem"),k=U("setItem"),J=U("removeItem"),_n=U("clear"),kn=U("length"),qn=U("key"),Dn=U("keys"),Wn=U("iterate");function Be(){let n=window.crypto.getRandomValues(new Uint8Array(16));n[6]=n[6]&15|64,n[8]=n[8]&191|128;let e="";return e+=n[0].toString(16),e+=n[1].toString(16),e+=n[2].toString(16),e+=n[3].toString(16),e+="-",e+=n[4].toString(16),e+=n[5].toString(16),e+="-",e+=n[6].toString(16),e+=n[7].toString(16),e+="-",e+=n[8].toString(16),e+=n[9].toString(16),e+="-",e+=n[10].toString(16),e+=n[11].toString(16),e+=n[12].toString(16),e+=n[13].toString(16),e+=n[14].toString(16),e+=n[15].toString(16),e}var Pe="STORE_KEY_PRIVATE_KEY",ie="STORE_KEY_PUBLIC_JWK",Xe="ECDSA",Pt="P-256",Un={name:Xe,namedCurve:Pt},Jn={name:Xe,namedCurve:Pt};function ae(){J(ie),J(Pe)}function Ve(){return f(this,null,function*(){let n=yield Fn();if(!n){console.info("unable to create public key or webcrypto is unsupported");return}let{subtle:e}=window.crypto,t=yield A(Pe);if(!t||!e){console.info("unable to find private key or webcrypto unsupported");return}let r={iat:Math.floor(new Date().getTime()/1e3),jti:Be()},o={typ:"dpop+jwt",alg:"ES256",jwk:n},s={protected:It(JSON.stringify(o)),claims:It(JSON.stringify(r))},a=jn(`${s.protected}.${s.claims}`),i={name:Xe,hash:{name:"SHA-256"}},l=Xn(new Uint8Array(yield e.sign(i,t,a)));return`${s.protected}.${s.claims}.${l}`})}function Fn(){return f(this,null,function*(){if(!Kn()){console.info("webcrypto is not supported");return}return(yield A(ie))||(yield Gn()),A(ie)})}function Gn(){return f(this,null,function*(){let n=null,{subtle:e}=window.crypto,t=yield e.generateKey(Un,!0,["sign"]),r=yield e.exportKey("jwk",t.privateKey);n=yield e.exportKey("jwk",t.publicKey);let o=yield e.importKey("jwk",r,Jn,!1,["sign"]);yield k(Pe,o),yield k(ie,n)})}function Kn(){let n=typeof window!="undefined"&&!!window.crypto,e=n&&!!window.crypto.subtle;return n&&e}function It(n){return bt(Bn(n))}function jn(n){return new TextEncoder().encode(n)}function bt(n){return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+/g,"")}function Bn(n){return encodeURIComponent(n).replace(/%([0-9A-F]{2})/g,(t,r)=>String.fromCharCode(parseInt(r,16)))}function Xn(n){let e="";return n.forEach(t=>{e+=String.fromCharCode(t)}),bt(e)}var be=class extends M{constructor(){super(...arguments);this.localForageKey="mc_active_wallet"}getIdToken(t){let r=p(this.sdk.testMode?g.MagicPayloadMethod.GetIdTokenTestMode:g.MagicPayloadMethod.GetIdToken,[t]);return this.request(r)}generateIdToken(t){let r=p(this.sdk.testMode?g.MagicPayloadMethod.GenerateIdTokenTestMode:g.MagicPayloadMethod.GenerateIdToken,[t]);return this.request(r)}getInfo(){return f(this,null,function*(){let t=yield A(this.localForageKey),r=p(g.MagicPayloadMethod.GetInfo,[{walletType:t}]);return this.request(r)})}isLoggedIn(){let t=p(this.sdk.testMode?g.MagicPayloadMethod.IsLoggedInTestMode:g.MagicPayloadMethod.IsLoggedIn);return this.request(t)}logout(){ae(),J(this.localForageKey);let t=p(this.sdk.testMode?g.MagicPayloadMethod.LogoutTestMode:g.MagicPayloadMethod.Logout);return this.request(t)}requestInfoWithUI(t){let r=p(g.MagicPayloadMethod.RequestUserInfoWithUI,t?[t]:[]);return this.request(r)}showSettings(t){let r=p(this.sdk.testMode?g.MagicPayloadMethod.UserSettingsTestMode:g.MagicPayloadMethod.UserSettings,[t]);return this.request(r)}recoverAccount(t){let r=p(this.sdk.testMode?g.MagicPayloadMethod.RecoverAccountTestMode:g.MagicPayloadMethod.RecoverAccount,[t]);return this.request(r)}getMetadata(){v({method:"user.getMetadata()",removalVersions:x,useInstead:"user.getInfo()"}).log();let t=p(this.sdk.testMode?g.MagicPayloadMethod.GetMetadataTestMode:g.MagicPayloadMethod.GetMetadata);return this.request(t)}updateEmail(t){v({method:"user.updateEmail()",removalVersions:x,useInstead:"auth.updateEmailWithUI()"}).log();let{email:r,showUI:o=!0}=t,s=p(this.sdk.testMode?g.MagicPayloadMethod.UpdateEmailTestMode:g.MagicPayloadMethod.UpdateEmail,[{email:r,showUI:o}]);return this.request(s)}updatePhoneNumber(){v({method:"user.updatePhoneNumber()",removalVersions:x,useInstead:"auth.updatePhoneNumberWithUI()"}).log();let t=p(this.sdk.testMode?g.MagicPayloadMethod.UpdatePhoneNumberTestMode:g.MagicPayloadMethod.UpdatePhoneNumber);return this.request(t)}};var E=require("@magic-sdk/types");var Me=class extends M{constructor(){super(...arguments);this.localForageKey="mc_active_wallet"}connectWithUI(){return f(this,null,function*(){if(this.isMetaMaskBrowser())try{if(yield this.isWalletEnabled(E.Wallets.MetaMask))return this.autoConnectIfWalletBrowser(E.Wallets.MetaMask)}catch(s){console.error(s)}if(this.isCoinbaseWalletBrowser())try{if(yield this.isWalletEnabled(E.Wallets.CoinbaseWallet))return this.autoConnectIfWalletBrowser(E.Wallets.CoinbaseWallet)}catch(s){console.error(s)}let t=this.getUserEnv(),r=p(E.MagicPayloadMethod.Login,[t]),o=this.request(r);return o.on(E.Events.WalletSelected,s=>this.handleWalletSelected(de(j({},s),{payloadId:r.id}))),o})}showUI(){let t=p(E.MagicPayloadMethod.ShowUI);return this.request(t)}getInfo(){return f(this,null,function*(){v({method:"wallet.getInfo()",removalVersions:x,useInstead:"user.getInfo()"}).log();let t=yield A(this.localForageKey),r=p(E.MagicPayloadMethod.GetInfo,[{walletType:t}]);return this.request(r)})}disconnect(){v({method:"wallet.disconnect()",removalVersions:x,useInstead:"user.logout()"}).log(),ae(),J(this.localForageKey);let t=p(E.MagicPayloadMethod.Disconnect);return this.request(t)}requestUserInfoWithUI(t){v({method:"wallet.requestUserInfoWithUI()",removalVersions:x,useInstead:"user.requestUserInfoWithUI()"}).log();let r=p(E.MagicPayloadMethod.RequestUserInfoWithUI,t?[t]:[]);return this.request(r)}getProvider(){return f(this,null,function*(){switch(yield A(this.localForageKey)){case E.Wallets.MetaMask:return this.getMetaMaskProvider();case E.Wallets.CoinbaseWallet:return this.getCoinbaseProvider();default:return this.sdk.rpcProvider}})}isMetaMaskInstalled(){var t,r,o;return((t=window.ethereum)==null?void 0:t.isMetaMask)||!!((o=(r=window.ethereum)==null?void 0:r.providers)!=null&&o.find(s=>s==null?void 0:s.isMetaMask))}isMetaMaskBrowser(){return this.isMobile()&&this.isMetaMaskInstalled()}getMetaMaskProvider(){var t,r;return((r=(t=window.ethereum)==null?void 0:t.providers)==null?void 0:r.find(o=>o==null?void 0:o.isMetaMask))||window.ethereum}connectToMetaMask(){if(this.isMobile()&&!this.isMetaMaskInstalled()){let t=`https://metamask.app.link/dapp/${window.location.href.replace(/(^\w+:|^)\/\//,"")}`;window.location.href=t}return this.getMetaMaskProvider().request({method:"eth_requestAccounts"})}isCoinbaseWalletInstalled(){var t,r,o;return((t=window.ethereum)==null?void 0:t.isCoinbaseWallet)||!!((o=(r=window.ethereum)==null?void 0:r.providers)!=null&&o.find(s=>s==null?void 0:s.isCoinbaseWallet))}isCoinbaseWalletBrowser(){var t;return!!((t=window.ethereum)!=null&&t.isCoinbaseBrowser)}getCoinbaseProvider(){var t,r;return((r=(t=window.ethereum)==null?void 0:t.providers)==null?void 0:r.find(o=>o==null?void 0:o.isCoinbaseWallet))||window.ethereum}connectToCoinbaseWallet(){if(this.isMobile()&&!this.isCoinbaseWalletBrowser()){let r=`https://go.cb-w.com/dapp?cb_url=${encodeURIComponent(window.location.href)}`;window.location.href=r}return this.getCoinbaseProvider().request({method:"eth_requestAccounts"})}isMobile(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Silk|Opera Mini/i.test(navigator.userAgent)}getUserEnv(){return{env:{isMetaMaskInstalled:this.isMetaMaskInstalled(),isCoinbaseWalletInstalled:this.isCoinbaseWalletInstalled()}}}connectToThirdPartyWallet(t){switch(t){case E.Wallets.MetaMask:return this.connectToMetaMask();case E.Wallets.CoinbaseWallet:return this.connectToCoinbaseWallet();default:throw new Error(`Invalid provider: ${t}. Must be one of "metamask" or "coinbase_wallet".`)}}isWalletEnabled(t){let r=p("mc_is_wallet_enabled",[{wallet:t}]);return this.request(r)}handleWalletSelected(t){return f(this,null,function*(){try{let r=yield this.connectToThirdPartyWallet(t.wallet);yield k(this.localForageKey,t.wallet),this.createIntermediaryEvent(E.Events.WalletConnected,t.payloadId)(r)}catch(r){console.error(r),this.createIntermediaryEvent(E.Events.WalletRejected,t.payloadId)()}})}autoConnectIfWalletBrowser(t){return f(this,null,function*(){let r;t===E.Wallets.MetaMask&&(r=yield this.getMetaMaskProvider().request({method:"eth_requestAccounts"})),t===E.Wallets.CoinbaseWallet&&(r=yield this.getCoinbaseProvider().request({method:"eth_requestAccounts"})),yield k(this.localForageKey,t);let o=p(E.MagicPayloadMethod.AutoConnect,[{wallet:t,address:r}]);return this.request(o)})}};var He=require("@magic-sdk/types");var{createBoundEmitterMethod:xe,createChainingEmitterMethod:z}=se(),we=class extends M{constructor(){super(...arguments);this.isMagic=!0;this.on=z("on",this);this.once=z("once",this);this.addListener=z("addListener",this);this.off=z("off",this);this.removeListener=z("removeListener",this);this.removeAllListeners=z("removeAllListeners",this);this.emit=xe("emit");this.eventNames=xe("eventNames");this.listeners=xe("listeners");this.listenerCount=xe("listenerCount")}sendAsync(t,r){if(!r)throw Je({procedure:"Magic.rpcProvider.sendAsync",argument:1,expected:"function",received:r===null?"null":typeof r});if(Array.isArray(t))this.overlay.post(He.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST,t.map(o=>{let s=K(o);return this.prefixPayloadMethodForTestMode(s),s})).then(o=>{r(null,o.map(s=>de(j({},s.payload),{error:s.hasError?new S(s.payload.error):null})))});else{let o=K(t);this.prefixPayloadMethodForTestMode(o),this.overlay.post(He.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST,o).then(s=>{r(s.hasError?new S(s.payload.error):null,s.payload)})}}send(t,r){if(typeof t=="string"){let s=p(t,Array.isArray(r)?r:[]);return this.request(s)}if(Array.isArray(t)||!!r){this.sendAsync(t,r);return}let o=Fe();return o.log(),new W(t).applyError({code:-32603,message:o.rawMessage}).payload}enable(){let t=p("eth_accounts");return this.request(t)}request(t){return this.prefixPayloadMethodForTestMode(t),super.request(t)}prefixPayloadMethodForTestMode(t){let r="testMode/eth/";this.sdk.testMode&&(t.method=`${r}${t.method}`)}};function Ne(n,e){return e?new URL(n,e):new URL(n)}var Mt=["request","overlay","sdk"];function Vn(n){let e=Object.getPrototypeOf(n),t=[e];for(;e!==M.prototype;)e=Object.getPrototypeOf(e),t.push(e);return t}var $e=class extends M{constructor(){super(void 0);this.__sdk_access_field_descriptors__=new Map;this.__is_initialized__=!1;this.utils={createPromiEvent:oe,isPromiEvent:je,encodeJSON:te,decodeJSON:Oe,createJsonRpcRequestPayload:p,standardizeJsonRpcRequestPayload:K,storage:H};let t=[this,...Vn(this)];Mt.forEach(r=>{let o=t.map(l=>Object.getOwnPropertyDescriptor(l,r)),s=o.findIndex(l=>!!l),a=s>0,i=o[s];i&&(this.__sdk_access_field_descriptors__.set(r,{descriptor:i,isPrototypeField:a}),Object.defineProperty(this,r,{configurable:!0,get:()=>{throw We(r)}}))})}init(t){this.__is_initialized__||(Mt.forEach(r=>{if(this.__sdk_access_field_descriptors__.has(r)){let{descriptor:o,isPrototypeField:s}=this.__sdk_access_field_descriptors__.get(r);s?delete this[r]:Object.defineProperty(this,r,o)}}),this.sdk=t,this.__is_initialized__=!0)}createDeprecationWarning(t){let{method:r,removalVersion:o,useInstead:s}=t,a=s?` Use \`${s}\` instead.`:"",i=`\`${r}\` will be removed from this Extension in version \`${o}\`.${a}`;return new X(this,"DEPRECATION_NOTICE",i)}createWarning(t,r){return new X(this,t,r)}createError(t,r,o){return new G(this,t,r,o)}},ze=class extends $e{},L=class extends $e{};L.Internal=ze,L.Anonymous="anonymous extension";var xt=require("@magic-sdk/types");var Ae=class extends M{purchase(e){let t=p(xt.MagicPayloadMethod.NFTPurchase,[e]);return this.request(t)}};function wt(n){return n.compat&&n.compat[m.sdkName]!=null?typeof n.compat[m.sdkName]=="string"?pt(mt(m.version),n.compat[m.sdkName]):!!n.compat[m.sdkName]:!0}function Hn(n){var o;let e=(o=n==null?void 0:n.extensions)!=null?o:[],t={},r=[];if(Array.isArray(e)?e.forEach(s=>{wt(s)?(s.init(this),(s.name||s.name!==L.Anonymous)&&(this[s.name]=s),s instanceof L.Internal&&(ne(s.config)||(t[s.name]=s.config))):r.push(s)}):Object.keys(e).forEach(s=>{if(wt(e[s])){e[s].init(this);let a=e[s];this[s]=a,a instanceof L.Internal&&(ne(a.config)||(t[e[s].name]=a.config))}else r.push(e[s])}),r.length)throw Ue(r);return t}var ce=class{constructor(e,t){this.apiKey=e;var a;if(!e)throw qe();m.platform==="react-native"&&(t==null?void 0:t.endpoint)&&Ge().log();let{defaultEndpoint:r,version:o}=m;this.testMode=!!(t!=null&&t.testMode),this.endpoint=Ne((a=t==null?void 0:t.endpoint)!=null?a:r).origin,this.auth=new Te(this),this.user=new be(this),this.wallet=new Me(this),this.nft=new Ae(this),this.rpcProvider=new we(this);let s=Hn.call(this,t);this.parameters=te(j({API_KEY:this.apiKey,DOMAIN_ORIGIN:window.location?window.location.origin:"",ETH_NETWORK:t==null?void 0:t.network,host:Ne(this.endpoint).host,sdk:Et[m.sdkName],version:o,ext:ne(s)?void 0:s,locale:(t==null?void 0:t.locale)||"en_US"},m.bundleId?{bundleId:m.bundleId}:{}))}get overlay(){if(!ce.__overlays__.has(this.parameters)){let e=new m.ViewController(this.endpoint,this.parameters);e.init(),ce.__overlays__.set(this.parameters,e)}return ce.__overlays__.get(this.parameters)}preload(){return f(this,null,function*(){yield this.overlay.ready})}},le=ce;le.__overlays__=new Map;var ue=require("@magic-sdk/types");function zn(n,e){return e&&Array.isArray(n)?n.find(t=>t.id===e):n}function Yn(n,e){var o;let t=(o=e.data.response)==null?void 0:o.id,r=zn(n,t);if(t&&r){let s=new W(r).applyResult(e.data.response.result).applyError(e.data.response.error);return{id:t,response:s}}return{}}function Zn(n,e){return f(this,null,function*(){let t=yield A("rt"),r;if(m.platform==="web")try{r=yield Ve()}catch(o){console.error("webcrypto error",o)}return r?t?{msgType:n,payload:e,jwt:r,rt:t}:{msgType:n,payload:e,jwt:r}:{msgType:n,payload:e}})}function Qn(n){return f(this,null,function*(){!n.data.rt||(yield k("rt",n.data.rt))})}var Ce=class{constructor(e,t){this.endpoint=e;this.parameters=t;this.messageHandlers=new Set;this.ready=this.waitForReady(),this.listen()}post(e,t){return f(this,null,function*(){return ve(r=>f(this,null,function*(){yield this.ready;let o=[],s=Array.isArray(t)?t.map(u=>u.id):[],a=yield Zn(`${e}-${this.parameters}`,t);yield this._post(a);let i=u=>c=>{let{id:d,response:w}=Yn(t,c);Qn(c),d&&w&&Array.isArray(t)&&s.includes(d)?(o.push(w),o.length===t.length&&(u(),r(o))):d&&w&&!Array.isArray(t)&&d===t.id&&(u(),r(w))},l=this.on(ue.MagicIncomingWindowMessage.MAGIC_HANDLE_RESPONSE,i(()=>l()))}))})}on(e,t){let r=t.bind(window),o=s=>{s.data.msgType===`${e}-${this.parameters}`&&r(s)};return this.messageHandlers.add(o),()=>this.messageHandlers.delete(o)}waitForReady(){return new Promise(e=>{this.on(ue.MagicIncomingWindowMessage.MAGIC_OVERLAY_READY,()=>e())})}listen(){this.on(ue.MagicIncomingWindowMessage.MAGIC_HIDE_OVERLAY,()=>{this.hideOverlay()}),this.on(ue.MagicIncomingWindowMessage.MAGIC_SHOW_OVERLAY,()=>{this.showOverlay()})}};
5
+ Received: \`${n.received}\``)}function $n(){return new F(N.SDKWarningCode.DuplicateIframe,"Duplicate iframes found.")}function Fe(){return new F(N.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 F(N.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 \`${m.defaultEndpoint}\`. Changing this default behavior will lead to unexpected results and potentially security-threatening bugs.`)}function v(n){let{method:e,removalVersions:t,useInstead:r}=n,o=t[m.sdkName],s=r?` Use \`${r}\` instead.`:"",a=`\`${e}\` will be removed from \`${m.sdkName}\` in version \`${o}\`.${s}`;return new F(N.SDKWarningCode.DeprecationNotice,a)}var $=require("@magic-sdk/types");var V=require("@magic-sdk/types");function*An(){let n=0;for(;;)n<Number.MAX_SAFE_INTEGER?yield++n:n=0}var Cn=An();function ge(){return Cn.next().value}var ft=Symbol("Payload pre-processed by Magic SDK");function gt(n){return Object.defineProperty(n,ft,{value:!0,enumerable:!1}),n}function Sn(n){return!!n[ft]}function K(n){var e,t,r;return Sn(n)||(n.jsonrpc=(e=n.jsonrpc)!=null?e:"2.0",n.id=ge(),n.method=(t=n.method)!=null?t:"noop",n.params=(r=n.params)!=null?r:[],gt(n)),n}function p(n,e=[]){return gt({params:e,method:n,jsonrpc:"2.0",id:ge()})}var W=class{constructor(e){e instanceof W?(this._jsonrpc=e.payload.jsonrpc,this._id=e.payload.id,this._result=e.payload.result,this._error=e.payload.error):Oe(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 typeof this._error!="undefined"&&this._error!==null}get hasResult(){return typeof this._result!="undefined"}get payload(){return{jsonrpc:this._jsonrpc,id:this._id,result:this._result,error:this._error}}};var vt=kt(Rt()),Re=class extends vt.default{};function se(){let n=new Re;return{emitter:n,createChainingEmitterMethod:(r,o)=>(...s)=>(n[r].apply(n,s),o),createBoundEmitterMethod:r=>(...o)=>n[r].apply(n,o)}}var Tt=Symbol("isPromiEvent");function je(n){return!!n[Tt]}function oe(n){let e=ve(n),{createBoundEmitterMethod:t,createChainingEmitterMethod:r}=se(),o=Symbol("Promise.then"),s=Symbol("Promise.catch"),a=Symbol("Promise.finally"),i=(c,d)=>(...w)=>{let q=d[c].apply(d,w);return l(q)},l=c=>Object.assign(c,{[Tt]:!0,[o]:c[o]||c.then,[s]:c[s]||c.catch,[a]:c[a]||c.finally,then:i(o,c),catch:i(s,c),finally:i(a,c),on:r("on",c),once:r("once",c),addListener:r("addListener",c),off:r("off",c),removeListener:r("removeListener",c),removeAllListeners:r("removeAllListeners",c),emit:t("emit"),eventNames:t("eventNames"),listeners:t("listeners"),listenerCount:t("listenerCount")}),u=l(e.then(c=>(u.emit("done",c),u.emit("settled"),c),c=>{throw u.emit("error",c),u.emit("settled"),c}));return u}function ve(n){return new Promise((e,t)=>{let r=n(e,t);Promise.resolve(r).catch(t)})}var M=class{constructor(e){this.sdk=e}get overlay(){return this.sdk.overlay}request(e){let t=this.overlay.post(V.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST,K(e)),r=oe((s,a)=>{t.then(i=>{if(o(),i.hasError)a(new S(i.payload.error));else if(i.hasResult)s(i.payload.result);else throw De()}).catch(i=>{o(),a(i)})}),o=this.overlay.on(V.MagicIncomingWindowMessage.MAGIC_HANDLE_EVENT,s=>{var i;let{response:a}=s.data;if(a.id===e.id&&((i=a.result)==null?void 0:i.event)){let{event:l,params:u=[]}=a.result;r.emit(l,...u)}});return r}createIntermediaryEvent(e,t){return o=>{let s=p(V.MagicPayloadMethod.IntermediaryEvent,[{payloadId:t,eventType:e,args:o}]);this.request(s)}}};var x={"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"},Te=class extends M{loginWithMagicLink(e){let t=m.sdkName==="@magic-sdk/react-native"||m.sdkName==="@magic-sdk/react-native-bare"||m.sdkName==="@magic-sdk/react-native-expo";v({method:"auth.loginWithMagicLink()",removalVersions:x,useInstead:t?"@magic-ext/auth auth.loginWithEmailOTP()":"@magic-ext/auth auth.loginWithMagicLink()"}).log();let{email:r,showUI:o=!0,redirectURI:s}=e,a=p(this.sdk.testMode?$.MagicPayloadMethod.LoginWithMagicLinkTestMode:$.MagicPayloadMethod.LoginWithMagicLink,[{email:r,showUI:o,redirectURI:s}]);return this.request(a)}loginWithSMS(e){v({method:"auth.loginWithSMS()",removalVersions:x,useInstead:"@magic-ext/auth auth.loginWithSMS()"}).log();let{phoneNumber:t}=e,r=p(this.sdk.testMode?$.MagicPayloadMethod.LoginWithSmsTestMode:$.MagicPayloadMethod.LoginWithSms,[{phoneNumber:t,showUI:!0}]);return this.request(r)}loginWithEmailOTP(e){v({method:"auth.loginWithEmailOTP()",removalVersions:x,useInstead:"@magic-ext/auth auth.loginWithEmailOTP()"}).log();let{email:t,showUI:r}=e,o=p(this.sdk.testMode?$.MagicPayloadMethod.LoginWithEmailOTPTestMode:$.MagicPayloadMethod.LoginWithEmailOTP,[{email:t,showUI:r}]);if(!r){let s=this.request(o);return s&&(s.on("verify-email-otp",a=>{this.createIntermediaryEvent("verify-email-otp",o.id)(a)}),s.on("cancel",()=>{this.createIntermediaryEvent("cancel",o.id)()})),s}return this.request(o)}loginWithCredential(e){v({method:"auth.loginWithCredential()",removalVersions:x,useInstead:"@magic-ext/auth auth.loginWithCredential()"}).log();let t=e!=null?e:"";if(!e&&m.platform==="web"){t=window.location.search;let o=window.location.origin+window.location.pathname;window.history.replaceState(null,"",o)}let r=p(this.sdk.testMode?$.MagicPayloadMethod.LoginWithCredentialTestMode:$.MagicPayloadMethod.LoginWithCredential,[t]);return this.request(r)}setAuthorizationToken(e){v({method:"auth.setAuthorizationToken()",removalVersions:x,useInstead:"@magic-ext/auth auth.setAuthorizationToken()"}).log();let t=p($.MagicPayloadMethod.SetAuthorizationToken,[{jwt:e}]);return this.request(t)}updateEmailWithUI(e){v({method:"auth.updateEmailWithUI()",removalVersions:x,useInstead:"@magic-ext/auth auth.updateEmailWithUI()"}).log();let{email:t,showUI:r=!0}=e,o=p(this.sdk.testMode?$.MagicPayloadMethod.UpdateEmailTestMode:$.MagicPayloadMethod.UpdateEmail,[{email:t,showUI:r}]);return this.request(o)}updatePhoneNumberWithUI(){v({method:"auth.updatePhoneNumberWithUI()",removalVersions:x,useInstead:"@magic-ext/auth auth.updatePhoneNumberWithUI()"}).log();let e=p(this.sdk.testMode?$.MagicPayloadMethod.UpdatePhoneNumberTestMode:$.MagicPayloadMethod.UpdatePhoneNumber);return this.request(e)}};var g=require("@magic-sdk/types");var H={};et(H,{clear:()=>On,getItem:()=>A,iterate:()=>Wn,key:()=>qn,keys:()=>Dn,length:()=>kn,removeItem:()=>J,setItem:()=>k});var Ie;function U(n){return(...e)=>f(this,null,function*(){return Ie||(Ie=yield m.configureStorage()),yield Ie.ready(),Ie[n](...e)})}var A=U("getItem"),k=U("setItem"),J=U("removeItem"),On=U("clear"),kn=U("length"),qn=U("key"),Dn=U("keys"),Wn=U("iterate");function Be(){let n=window.crypto.getRandomValues(new Uint8Array(16));n[6]=n[6]&15|64,n[8]=n[8]&191|128;let e="";return e+=n[0].toString(16),e+=n[1].toString(16),e+=n[2].toString(16),e+=n[3].toString(16),e+="-",e+=n[4].toString(16),e+=n[5].toString(16),e+="-",e+=n[6].toString(16),e+=n[7].toString(16),e+="-",e+=n[8].toString(16),e+=n[9].toString(16),e+="-",e+=n[10].toString(16),e+=n[11].toString(16),e+=n[12].toString(16),e+=n[13].toString(16),e+=n[14].toString(16),e+=n[15].toString(16),e}var Pe="STORE_KEY_PRIVATE_KEY",ie="STORE_KEY_PUBLIC_JWK",Xe="ECDSA",Pt="P-256",Un={name:Xe,namedCurve:Pt},Jn={name:Xe,namedCurve:Pt};function ae(){J(ie),J(Pe)}function Ve(){return f(this,null,function*(){let n=yield Fn();if(!n){console.info("unable to create public key or webcrypto is unsupported");return}let{subtle:e}=window.crypto,t=yield A(Pe);if(!t||!e){console.info("unable to find private key or webcrypto unsupported");return}let r={iat:Math.floor(new Date().getTime()/1e3),jti:Be()},o={typ:"dpop+jwt",alg:"ES256",jwk:n},s={protected:It(JSON.stringify(o)),claims:It(JSON.stringify(r))},a=jn(`${s.protected}.${s.claims}`),i={name:Xe,hash:{name:"SHA-256"}},l=Xn(new Uint8Array(yield e.sign(i,t,a)));return`${s.protected}.${s.claims}.${l}`})}function Fn(){return f(this,null,function*(){if(!Kn()){console.info("webcrypto is not supported");return}return(yield A(ie))||(yield Gn()),A(ie)})}function Gn(){return f(this,null,function*(){let n=null,{subtle:e}=window.crypto,t=yield e.generateKey(Un,!0,["sign"]),r=yield e.exportKey("jwk",t.privateKey);n=yield e.exportKey("jwk",t.publicKey);let o=yield e.importKey("jwk",r,Jn,!1,["sign"]);yield k(Pe,o),yield k(ie,n)})}function Kn(){let n=typeof window!="undefined"&&!!window.crypto,e=n&&!!window.crypto.subtle;return n&&e}function It(n){return bt(Bn(n))}function jn(n){return new TextEncoder().encode(n)}function bt(n){return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+/g,"")}function Bn(n){return encodeURIComponent(n).replace(/%([0-9A-F]{2})/g,(t,r)=>String.fromCharCode(parseInt(r,16)))}function Xn(n){let e="";return n.forEach(t=>{e+=String.fromCharCode(t)}),bt(e)}var be=class extends M{constructor(){super(...arguments);this.localForageKey="mc_active_wallet"}getIdToken(t){let r=p(this.sdk.testMode?g.MagicPayloadMethod.GetIdTokenTestMode:g.MagicPayloadMethod.GetIdToken,[t]);return this.request(r)}generateIdToken(t){let r=p(this.sdk.testMode?g.MagicPayloadMethod.GenerateIdTokenTestMode:g.MagicPayloadMethod.GenerateIdToken,[t]);return this.request(r)}getInfo(){return f(this,null,function*(){let t=yield A(this.localForageKey),r=p(g.MagicPayloadMethod.GetInfo,[{walletType:t}]);return this.request(r)})}isLoggedIn(){let t=p(this.sdk.testMode?g.MagicPayloadMethod.IsLoggedInTestMode:g.MagicPayloadMethod.IsLoggedIn);return this.request(t)}logout(){ae(),J(this.localForageKey);let t=p(this.sdk.testMode?g.MagicPayloadMethod.LogoutTestMode:g.MagicPayloadMethod.Logout);return this.request(t)}requestInfoWithUI(t){let r=p(g.MagicPayloadMethod.RequestUserInfoWithUI,t?[t]:[]);return this.request(r)}showSettings(t){let r=p(this.sdk.testMode?g.MagicPayloadMethod.UserSettingsTestMode:g.MagicPayloadMethod.UserSettings,[t]);return this.request(r)}recoverAccount(t){let r=p(this.sdk.testMode?g.MagicPayloadMethod.RecoverAccountTestMode:g.MagicPayloadMethod.RecoverAccount,[t]);return this.request(r)}getMetadata(){v({method:"user.getMetadata()",removalVersions:x,useInstead:"user.getInfo()"}).log();let t=p(this.sdk.testMode?g.MagicPayloadMethod.GetMetadataTestMode:g.MagicPayloadMethod.GetMetadata);return this.request(t)}updateEmail(t){v({method:"user.updateEmail()",removalVersions:x,useInstead:"auth.updateEmailWithUI()"}).log();let{email:r,showUI:o=!0}=t,s=p(this.sdk.testMode?g.MagicPayloadMethod.UpdateEmailTestMode:g.MagicPayloadMethod.UpdateEmail,[{email:r,showUI:o}]);return this.request(s)}updatePhoneNumber(){v({method:"user.updatePhoneNumber()",removalVersions:x,useInstead:"auth.updatePhoneNumberWithUI()"}).log();let t=p(this.sdk.testMode?g.MagicPayloadMethod.UpdatePhoneNumberTestMode:g.MagicPayloadMethod.UpdatePhoneNumber);return this.request(t)}encryptWithPrivateKey(t,r={}){let o=p("magic_auth_encrypt_v1",[{message:t}]);return this.request(o)}decryptWithPrivateKey(t,r={}){let o=p("magic_auth_decrypt_v1",[{cipherText:t}]);return this.request(o)}};var E=require("@magic-sdk/types");var Me=class extends M{constructor(){super(...arguments);this.localForageKey="mc_active_wallet"}connectWithUI(){return f(this,null,function*(){if(this.isMetaMaskBrowser())try{if(yield this.isWalletEnabled(E.Wallets.MetaMask))return this.autoConnectIfWalletBrowser(E.Wallets.MetaMask)}catch(s){console.error(s)}if(this.isCoinbaseWalletBrowser())try{if(yield this.isWalletEnabled(E.Wallets.CoinbaseWallet))return this.autoConnectIfWalletBrowser(E.Wallets.CoinbaseWallet)}catch(s){console.error(s)}let t=this.getUserEnv(),r=p(E.MagicPayloadMethod.Login,[t]),o=this.request(r);return o.on(E.Events.WalletSelected,s=>this.handleWalletSelected(de(j({},s),{payloadId:r.id}))),o})}showUI(){let t=p(E.MagicPayloadMethod.ShowUI);return this.request(t)}getInfo(){return f(this,null,function*(){v({method:"wallet.getInfo()",removalVersions:x,useInstead:"user.getInfo()"}).log();let t=yield A(this.localForageKey),r=p(E.MagicPayloadMethod.GetInfo,[{walletType:t}]);return this.request(r)})}disconnect(){v({method:"wallet.disconnect()",removalVersions:x,useInstead:"user.logout()"}).log(),ae(),J(this.localForageKey);let t=p(E.MagicPayloadMethod.Disconnect);return this.request(t)}requestUserInfoWithUI(t){v({method:"wallet.requestUserInfoWithUI()",removalVersions:x,useInstead:"user.requestUserInfoWithUI()"}).log();let r=p(E.MagicPayloadMethod.RequestUserInfoWithUI,t?[t]:[]);return this.request(r)}getProvider(){return f(this,null,function*(){switch(yield A(this.localForageKey)){case E.Wallets.MetaMask:return this.getMetaMaskProvider();case E.Wallets.CoinbaseWallet:return this.getCoinbaseProvider();default:return this.sdk.rpcProvider}})}isMetaMaskInstalled(){var t,r,o;return((t=window.ethereum)==null?void 0:t.isMetaMask)||!!((o=(r=window.ethereum)==null?void 0:r.providers)!=null&&o.find(s=>s==null?void 0:s.isMetaMask))}isMetaMaskBrowser(){return this.isMobile()&&this.isMetaMaskInstalled()}getMetaMaskProvider(){var t,r;return((r=(t=window.ethereum)==null?void 0:t.providers)==null?void 0:r.find(o=>o==null?void 0:o.isMetaMask))||window.ethereum}connectToMetaMask(){if(this.isMobile()&&!this.isMetaMaskInstalled()){let t=`https://metamask.app.link/dapp/${window.location.href.replace(/(^\w+:|^)\/\//,"")}`;window.location.href=t}return this.getMetaMaskProvider().request({method:"eth_requestAccounts"})}isCoinbaseWalletInstalled(){var t,r,o;return((t=window.ethereum)==null?void 0:t.isCoinbaseWallet)||!!((o=(r=window.ethereum)==null?void 0:r.providers)!=null&&o.find(s=>s==null?void 0:s.isCoinbaseWallet))}isCoinbaseWalletBrowser(){var t;return!!((t=window.ethereum)!=null&&t.isCoinbaseBrowser)}getCoinbaseProvider(){var t,r;return((r=(t=window.ethereum)==null?void 0:t.providers)==null?void 0:r.find(o=>o==null?void 0:o.isCoinbaseWallet))||window.ethereum}connectToCoinbaseWallet(){if(this.isMobile()&&!this.isCoinbaseWalletBrowser()){let r=`https://go.cb-w.com/dapp?cb_url=${encodeURIComponent(window.location.href)}`;window.location.href=r}return this.getCoinbaseProvider().request({method:"eth_requestAccounts"})}isMobile(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Silk|Opera Mini/i.test(navigator.userAgent)}getUserEnv(){return{env:{isMetaMaskInstalled:this.isMetaMaskInstalled(),isCoinbaseWalletInstalled:this.isCoinbaseWalletInstalled()}}}connectToThirdPartyWallet(t){switch(t){case E.Wallets.MetaMask:return this.connectToMetaMask();case E.Wallets.CoinbaseWallet:return this.connectToCoinbaseWallet();default:throw new Error(`Invalid provider: ${t}. Must be one of "metamask" or "coinbase_wallet".`)}}isWalletEnabled(t){let r=p("mc_is_wallet_enabled",[{wallet:t}]);return this.request(r)}handleWalletSelected(t){return f(this,null,function*(){try{let r=yield this.connectToThirdPartyWallet(t.wallet);yield k(this.localForageKey,t.wallet),this.createIntermediaryEvent(E.Events.WalletConnected,t.payloadId)(r)}catch(r){console.error(r),this.createIntermediaryEvent(E.Events.WalletRejected,t.payloadId)()}})}autoConnectIfWalletBrowser(t){return f(this,null,function*(){let r;t===E.Wallets.MetaMask&&(r=yield this.getMetaMaskProvider().request({method:"eth_requestAccounts"})),t===E.Wallets.CoinbaseWallet&&(r=yield this.getCoinbaseProvider().request({method:"eth_requestAccounts"})),yield k(this.localForageKey,t);let o=p(E.MagicPayloadMethod.AutoConnect,[{wallet:t,address:r}]);return this.request(o)})}};var He=require("@magic-sdk/types");var{createBoundEmitterMethod:xe,createChainingEmitterMethod:z}=se(),we=class extends M{constructor(){super(...arguments);this.isMagic=!0;this.on=z("on",this);this.once=z("once",this);this.addListener=z("addListener",this);this.off=z("off",this);this.removeListener=z("removeListener",this);this.removeAllListeners=z("removeAllListeners",this);this.emit=xe("emit");this.eventNames=xe("eventNames");this.listeners=xe("listeners");this.listenerCount=xe("listenerCount")}sendAsync(t,r){if(!r)throw Je({procedure:"Magic.rpcProvider.sendAsync",argument:1,expected:"function",received:r===null?"null":typeof r});if(Array.isArray(t))this.overlay.post(He.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST,t.map(o=>{let s=K(o);return this.prefixPayloadMethodForTestMode(s),s})).then(o=>{r(null,o.map(s=>de(j({},s.payload),{error:s.hasError?new S(s.payload.error):null})))});else{let o=K(t);this.prefixPayloadMethodForTestMode(o),this.overlay.post(He.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST,o).then(s=>{r(s.hasError?new S(s.payload.error):null,s.payload)})}}send(t,r){if(typeof t=="string"){let s=p(t,Array.isArray(r)?r:[]);return this.request(s)}if(Array.isArray(t)||!!r){this.sendAsync(t,r);return}let o=Fe();return o.log(),new W(t).applyError({code:-32603,message:o.rawMessage}).payload}enable(){let t=p("eth_accounts");return this.request(t)}request(t){return this.prefixPayloadMethodForTestMode(t),super.request(t)}prefixPayloadMethodForTestMode(t){let r="testMode/eth/";this.sdk.testMode&&(t.method=`${r}${t.method}`)}};function Ne(n,e){return e?new URL(n,e):new URL(n)}var Mt=["request","overlay","sdk"];function Vn(n){let e=Object.getPrototypeOf(n),t=[e];for(;e!==M.prototype;)e=Object.getPrototypeOf(e),t.push(e);return t}var $e=class extends M{constructor(){super(void 0);this.__sdk_access_field_descriptors__=new Map;this.__is_initialized__=!1;this.utils={createPromiEvent:oe,isPromiEvent:je,encodeJSON:te,decodeJSON:_e,createJsonRpcRequestPayload:p,standardizeJsonRpcRequestPayload:K,storage:H};let t=[this,...Vn(this)];Mt.forEach(r=>{let o=t.map(l=>Object.getOwnPropertyDescriptor(l,r)),s=o.findIndex(l=>!!l),a=s>0,i=o[s];i&&(this.__sdk_access_field_descriptors__.set(r,{descriptor:i,isPrototypeField:a}),Object.defineProperty(this,r,{configurable:!0,get:()=>{throw We(r)}}))})}init(t){this.__is_initialized__||(Mt.forEach(r=>{if(this.__sdk_access_field_descriptors__.has(r)){let{descriptor:o,isPrototypeField:s}=this.__sdk_access_field_descriptors__.get(r);s?delete this[r]:Object.defineProperty(this,r,o)}}),this.sdk=t,this.__is_initialized__=!0)}createDeprecationWarning(t){let{method:r,removalVersion:o,useInstead:s}=t,a=s?` Use \`${s}\` instead.`:"",i=`\`${r}\` will be removed from this Extension in version \`${o}\`.${a}`;return new X(this,"DEPRECATION_NOTICE",i)}createWarning(t,r){return new X(this,t,r)}createError(t,r,o){return new G(this,t,r,o)}},ze=class extends $e{},L=class extends $e{};L.Internal=ze,L.Anonymous="anonymous extension";var xt=require("@magic-sdk/types");var Ae=class extends M{purchase(e){let t=p(xt.MagicPayloadMethod.NFTPurchase,[e]);return this.request(t)}};function wt(n){return n.compat&&n.compat[m.sdkName]!=null?typeof n.compat[m.sdkName]=="string"?pt(mt(m.version),n.compat[m.sdkName]):!!n.compat[m.sdkName]:!0}function Hn(n){var o;let e=(o=n==null?void 0:n.extensions)!=null?o:[],t={},r=[];if(Array.isArray(e)?e.forEach(s=>{wt(s)?(s.init(this),(s.name||s.name!==L.Anonymous)&&(this[s.name]=s),s instanceof L.Internal&&(ne(s.config)||(t[s.name]=s.config))):r.push(s)}):Object.keys(e).forEach(s=>{if(wt(e[s])){e[s].init(this);let a=e[s];this[s]=a,a instanceof L.Internal&&(ne(a.config)||(t[e[s].name]=a.config))}else r.push(e[s])}),r.length)throw Ue(r);return t}var ce=class{constructor(e,t){this.apiKey=e;var a;if(!e)throw qe();m.platform==="react-native"&&(t==null?void 0:t.endpoint)&&Ge().log();let{defaultEndpoint:r,version:o}=m;this.testMode=!!(t!=null&&t.testMode),this.endpoint=Ne((a=t==null?void 0:t.endpoint)!=null?a:r).origin,this.auth=new Te(this),this.user=new be(this),this.wallet=new Me(this),this.nft=new Ae(this),this.rpcProvider=new we(this);let s=Hn.call(this,t);this.parameters=te(j({API_KEY:this.apiKey,DOMAIN_ORIGIN:window.location?window.location.origin:"",ETH_NETWORK:t==null?void 0:t.network,host:Ne(this.endpoint).host,sdk:Et[m.sdkName],version:o,ext:ne(s)?void 0:s,locale:(t==null?void 0:t.locale)||"en_US"},m.bundleId?{bundleId:m.bundleId}:{}))}get overlay(){if(!ce.__overlays__.has(this.parameters)){let e=new m.ViewController(this.endpoint,this.parameters);e.init(),ce.__overlays__.set(this.parameters,e)}return ce.__overlays__.get(this.parameters)}preload(){return f(this,null,function*(){yield this.overlay.ready})}},le=ce;le.__overlays__=new Map;var ue=require("@magic-sdk/types");function zn(n,e){return e&&Array.isArray(n)?n.find(t=>t.id===e):n}function Yn(n,e){var o;let t=(o=e.data.response)==null?void 0:o.id,r=zn(n,t);if(t&&r){let s=new W(r).applyResult(e.data.response.result).applyError(e.data.response.error);return{id:t,response:s}}return{}}function Zn(n,e){return f(this,null,function*(){let t=yield A("rt"),r;if(m.platform==="web")try{r=yield Ve()}catch(o){console.error("webcrypto error",o)}return r?t?{msgType:n,payload:e,jwt:r,rt:t}:{msgType:n,payload:e,jwt:r}:{msgType:n,payload:e}})}function Qn(n){return f(this,null,function*(){!n.data.rt||(yield k("rt",n.data.rt))})}var Ce=class{constructor(e,t){this.endpoint=e;this.parameters=t;this.messageHandlers=new Set;this.ready=this.waitForReady(),this.listen()}post(e,t){return f(this,null,function*(){return ve(r=>f(this,null,function*(){yield this.ready;let o=[],s=Array.isArray(t)?t.map(u=>u.id):[],a=yield Zn(`${e}-${this.parameters}`,t);yield this._post(a);let i=u=>c=>{let{id:d,response:w}=Yn(t,c);Qn(c),d&&w&&Array.isArray(t)&&s.includes(d)?(o.push(w),o.length===t.length&&(u(),r(o))):d&&w&&!Array.isArray(t)&&d===t.id&&(u(),r(w))},l=this.on(ue.MagicIncomingWindowMessage.MAGIC_HANDLE_RESPONSE,i(()=>l()))}))})}on(e,t){let r=t.bind(window),o=s=>{s.data.msgType===`${e}-${this.parameters}`&&r(s)};return this.messageHandlers.add(o),()=>this.messageHandlers.delete(o)}waitForReady(){return new Promise(e=>{this.on(ue.MagicIncomingWindowMessage.MAGIC_OVERLAY_READY,()=>e())})}listen(){this.on(ue.MagicIncomingWindowMessage.MAGIC_HIDE_OVERLAY,()=>{this.hideOverlay()}),this.on(ue.MagicIncomingWindowMessage.MAGIC_SHOW_OVERLAY,()=>{this.showOverlay()})}};
6
6
  //# sourceMappingURL=index.js.map