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