@magic-sdk/provider
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -1,2 +0,2 @@ | ||
var e,t=require("@magic-sdk/types"),r=(e=require("eventemitter3"))&&"object"==typeof e&&"default"in e?e.default:e;function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function o(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}function i(){return(i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function a(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function u(e,t){return(u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}function d(e,t,r){return(d=c()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&u(o,r.prototype),o}).apply(null,arguments)}function l(e){var t="function"==typeof Map?new Map:void 0;return(l=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return d(e,arguments,s(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),u(r,e)})(e)}function p(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function f(e){return btoa(JSON.stringify(e))}function h(e){return void 0===e}function y(e){return function(e){return null===e}(e)||h(e)}function v(e){return!y(e)&&!(h(e.jsonrpc)||h(e.id)||h(e.result)&&h(e.error))}function g(e){return!y(e)&&"number"==typeof e&&Object.values(t.RPCErrorCode).includes(e)}function m(e){if(!e)return!0;for(var t in e)if(Object.hasOwnProperty.call(e,t))return!1;return!0}var _={},M=function(e){function t(r,n){var o;return(o=e.call(this,"Magic SDK Error: ["+r+"] "+n)||this).code=r,o.rawMessage=n,o.__proto__=Error,Object.setPrototypeOf(p(o),t.prototype),o}return a(t,e),t}(l(Error)),E=function(){function e(e,t){this.code=e,this.rawMessage=t,this.message="Magic SDK Warning: ["+e+"] "+t}return e.prototype.log=function(){console.warn(this.message)},e}(),w=function(e){function r(n){var o;(o=e.call(this)||this).__proto__=Error;var i=Number(null==n?void 0:n.code);return o.rawMessage=(null==n?void 0:n.message)||"Internal error",o.code=g(i)?i:t.RPCErrorCode.InternalError,o.message="Magic RPC Error: ["+o.code+"] "+o.rawMessage,Object.setPrototypeOf(p(o),r.prototype),o}return a(r,e),r}(l(Error));function P(){return new M(t.SDKErrorCode.MissingApiKey,"Please provide an API key that you acquired from the Magic developer dashboard.")}function b(){return new M(t.SDKErrorCode.MalformedResponse,"Response from the Magic iframe is malformed.")}function A(e){return new M(t.SDKErrorCode.ExtensionNotInitialized,"Extensions must be initialized with a Magic SDK instance before `Extension."+e+"` can be accessed. Do not invoke `Extension."+e+"` inside an extension constructor.")}function R(e){var r,n,o;return new M(t.SDKErrorCode.InvalidArgument,"Invalid "+(o=(r=e.argument+1)%100,(1==(n=r%10)&&11!==o?r+"st":2===n&&12!==o?r+"nd":3===n&&13!==o?r+"rd":r+"th")+" argument given to `")+e.procedure+"`.\n Expected: `"+e.expected+"`\n Received: `"+e.received+"`")}function I(){return new E(t.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 x(){return new E(t.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 `"+_.defaultEndpoint+"`. Changing this default behavior will lead to unexpected results and potentially security-threatening bugs.")}var O=regeneratorRuntime.mark(S);function S(){var e;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:e=0;case 1:if(!(e<Number.MAX_SAFE_INTEGER)){t.next=7;break}return t.next=5,++e;case 5:t.next=8;break;case 7:e=0;case 8:t.next=1;break;case 10:case"end":return t.stop()}},O)}var C=S();function j(){return C.next().value}var D=Symbol("Payload pre-processed by Magic SDK");function N(e){return Object.defineProperty(e,D,{value:!0,enumerable:!1}),e}function k(e){var t,r,n;return function(e){return!!e[D]}(e)||(e.jsonrpc=null!=(t=e.jsonrpc)?t:"2.0",e.id=j(),e.method=null!=(r=e.method)?r:"noop",e.params=null!=(n=e.params)?n:[],N(e)),e}function L(e,t){return void 0===t&&(t=[]),N({params:t,method:e,jsonrpc:"2.0",id:j()})}var T=function(){function e(t){t instanceof e?(this._jsonrpc=t.payload.jsonrpc,this._id=t.payload.id,this._result=t.payload.result,this._error=t.payload.error):v(t)?(this._jsonrpc=t.jsonrpc,this._id=t.id,this._result=t.result,this._error=t.error):(this._jsonrpc=t.jsonrpc,this._id=t.id,this._result=void 0,this._error=void 0)}var t=e.prototype;return t.applyError=function(e){return this._error=e,this},t.applyResult=function(e){return this._result=e,this},o(e,[{key:"hasError",get:function(){return null!=this._error}},{key:"hasResult",get:function(){return void 0!==this._result}},{key:"payload",get:function(){return{jsonrpc:this._jsonrpc,id:this._id,result:this._result,error:this._error}}}]),e}(),W=function(e){function t(){return e.apply(this,arguments)||this}return a(t,e),t}(r);function K(){var e=new W;return{emitter:e,createChainingEmitterMethod:function(t,r){return function(){return e[t].apply(e,[].slice.call(arguments)),r}},createBoundEmitterMethod:function(t){return function(){return e[t].apply(e,[].slice.call(arguments))}}}}var q=Symbol("isPromiEvent");function Q(e){var t=G(e),r=K(),n=r.createBoundEmitterMethod,o=r.createChainingEmitterMethod,i=Symbol("Promise.then"),a=Symbol("Promise.catch"),s=Symbol("Promise.finally"),u=function(e,t){return function(){var r=t[e].apply(t,[].slice.call(arguments));return c(r)}},c=function(e){var t;return Object.assign(e,((t={})[q]=!0,t[i]=e[i]||e.then,t[a]=e[a]||e.catch,t[s]=e[s]||e.finally,t.then=u(i,e),t.catch=u(a,e),t.finally=u(s,e),t.on=o("on",e),t.once=o("once",e),t.addListener=o("addListener",e),t.off=o("off",e),t.removeListener=o("removeListener",e),t.removeAllListeners=o("removeAllListeners",e),t.emit=n("emit"),t.eventNames=n("eventNames"),t.listeners=n("listeners"),t.listenerCount=n("listenerCount"),t))},d=c(t.then(function(e){return d.emit("done",e),d.emit("settled"),e},function(e){throw d.emit("error",e),d.emit("settled"),e}));return d}function G(e){return new Promise(function(t,r){var n=e(t,r);Promise.resolve(n).catch(r)})}var U=function(){function e(e){this.sdk=e}return e.prototype.request=function(e){var r=this.transport.post(this.overlay,t.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST,k(e)),n=Q(function(e,t){r.then(function(r){if(o(),r.hasError)t(new w(r.payload.error));else{if(!r.hasResult)throw b();e(r.payload.result)}}).catch(function(e){o(),t(e)})}),o=this.transport.on(t.MagicIncomingWindowMessage.MAGIC_HANDLE_EVENT,function(t){var r,o=t.data.response;if(o.id===e.id&&(null===(r=o.result)||void 0===r?void 0:r.event)){var i=o.result,a=i.params;n.emit.apply(n,[i.event].concat(void 0===a?[]:a))}});return n},o(e,[{key:"transport",get:function(){return this.sdk.transport}},{key:"overlay",get:function(){return this.sdk.overlay}}]),e}(),H=function(e){function r(){return e.apply(this,arguments)||this}return a(r,e),r.prototype.loginWithMagicLink=function(e){var r=e.showUI,n=L(t.MagicPayloadMethod.LoginWithMagicLink,[{email:e.email,showUI:void 0===r||r}]);return this.request(n)},r}(U),V=function(e){function r(){return e.apply(this,arguments)||this}a(r,e);var n=r.prototype;return n.getIdToken=function(e){var r=L(t.MagicPayloadMethod.GetIdToken,[e]);return this.request(r)},n.generateIdToken=function(e){var r=L(t.MagicPayloadMethod.GenerateIdToken,[e]);return this.request(r)},n.getMetadata=function(){var e=L(t.MagicPayloadMethod.GetMetadata);return this.request(e)},n.updateEmail=function(e){var r=e.showUI,n=L(t.MagicPayloadMethod.UpdateEmail,[{email:e.email,showUI:void 0===r||r}]);return this.request(n)},n.isLoggedIn=function(){var e=L(t.MagicPayloadMethod.IsLoggedIn);return this.request(e)},n.logout=function(){var e=L(t.MagicPayloadMethod.Logout);return this.request(e)},r}(U),z=K(),J=z.createBoundEmitterMethod,F=z.createChainingEmitterMethod,Y=function(e){function r(){var t;return(t=e.apply(this,arguments)||this).isMagic=!0,t.on=F("on",p(t)),t.once=F("once",p(t)),t.addListener=F("addListener",p(t)),t.off=F("off",p(t)),t.removeListener=F("removeListener",p(t)),t.removeAllListeners=F("removeAllListeners",p(t)),t.emit=J("emit"),t.eventNames=J("eventNames"),t.listeners=J("listeners"),t.listenerCount=J("listenerCount"),t}a(r,e);var n=r.prototype;return n.sendAsync=function(e,r){if(!r)throw R({procedure:"Magic.rpcProvider.sendAsync",argument:1,expected:"function",received:null===r?"null":typeof r});if(Array.isArray(e))this.transport.post(this.overlay,t.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST,e.map(function(e){return k(e)})).then(function(e){r(null,e.map(function(e){return i(i({},e.payload),{},{error:e.hasError?new w(e.payload.error):null})}))});else{var n=k(e);this.transport.post(this.overlay,t.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST,n).then(function(e){r(e.hasError?new w(e.payload.error):null,e.payload)})}},n.send=function(e,t){if("string"==typeof e){var r=L(e,Array.isArray(t)?t:[]);return this.request(r)}if(!Array.isArray(e)&&!t){var n=I();return n.log(),new T(e).applyError({code:-32603,message:n.rawMessage}).payload}this.sendAsync(e,t)},n.enable=function(){var e=L("eth_accounts");return this.request(e)},r}(U);function B(e,t){return t?new URL(e,t):new URL(e)}var X=function(e){function t(){var t;return(t=e.call(this,void 0)||this).isInitialized=!1,t.createJsonRpcRequestPayload=L,t.standardizeJsonRpcRequestPayload=k,new Proxy(p(t),{get:function(e,r,n){if(["request","transport","overlay","sdk"].includes(r)&&!t.isInitialized)throw A(r);return Reflect.get(e,r,n)}})||p(t)}return a(t,e),t.prototype.init=function(e){this.sdk=e,this.isInitialized=!0},t}(U),Z=function(e){function t(){return e.apply(this,arguments)||this}return a(t,e),t}(X),$=function(){var e=function(e){function t(){return e.apply(this,arguments)||this}return a(t,e),t}(X);return e.Internal=Z,e}(),ee=function(){var e=function(){function e(e,t){var r,n,o=this;if(this.apiKey=e,!e)throw P();"react-native"===_.target&&(null==t?void 0:t.endpoint)&&x().log();var i=_.version;this.endpoint=B(null!=(r=null==t?void 0:t.endpoint)?r:_.defaultEndpoint).origin,this.auth=new H(this),this.user=new V(this),this.rpcProvider=new Y(this);var a=null!=(n=null==t?void 0:t.extensions)?n:[],s={};Array.isArray(a)?a.forEach(function(e){e.init(o),o[e.name]=e,e instanceof $.Internal&&(m(e.config)||(s[e.name]=e.config))}):Object.keys(a).forEach(function(e){a[e].init(o);var t=a[e];o[e]=t,t instanceof $.Internal&&(m(t.config)||(s[a[e].name]=t.config))}),this.encodedQueryParams=f({API_KEY:this.apiKey,DOMAIN_ORIGIN:window.location?window.location.origin:"",ETH_NETWORK:null==t?void 0:t.network,host:B(this.endpoint).host,sdk:_.sdkName,version:i,ext:m(s)?void 0:s})}return e.prototype.preload=function(){try{return Promise.resolve(this.overlay.ready).then(function(){})}catch(e){return Promise.reject(e)}},o(e,[{key:"transport",get:function(){return e.__transports__.has(this.encodedQueryParams)||e.__transports__.set(this.encodedQueryParams,new _.PayloadTransport(this.endpoint,this.encodedQueryParams)),e.__transports__.get(this.encodedQueryParams)}},{key:"overlay",get:function(){if(!e.__overlays__.has(this.encodedQueryParams)){var t=new _.ViewController(this.transport,this.endpoint,this.encodedQueryParams);e.__overlays__.set(this.encodedQueryParams,t)}return e.__overlays__.get(this.encodedQueryParams)}}]),e}();return e.__transports__=new Map,e.__overlays__=new Map,e}(),te=function(){function e(e,t){this.endpoint=e,this.encodedQueryParams=t,this.messageHandlers=new Set,this.init()}var r=e.prototype;return r.post=function(e,r,n){try{var o=this;return Promise.resolve(G(function(i){try{return Promise.resolve(e.ready).then(function(){var a=[],s=Array.isArray(n)?n.map(function(e){return e.id}):[];return Promise.resolve(e.postMessage({msgType:r+"-"+o.encodedQueryParams,payload:n})).then(function(){var e,r=o.on(t.MagicIncomingWindowMessage.MAGIC_HANDLE_RESPONSE,(e=function(){return r()},function(t){var r=function(e,t){var r,n=null===(r=t.data.response)||void 0===r?void 0:r.id,o=function(e,t){return t&&Array.isArray(e)?e.find(function(e){return e.id===t}):e}(e,n);return n&&o?{id:n,response:new T(o).applyResult(t.data.response.result).applyError(t.data.response.error)}:{}}(n,t),o=r.id,u=r.response;o&&u&&Array.isArray(n)&&s.includes(o)?(a.push(u),a.length===n.length&&(e(),i(a))):o&&u&&!Array.isArray(n)&&o===n.id&&(e(),i(u))}))})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},r.on=function(e,t){var r=this,n=t.bind(window),o=function(t){t.data.msgType===e+"-"+r.encodedQueryParams&&n(t)};return this.messageHandlers.add(o),function(){return r.messageHandlers.delete(o)}},e}(),re=function(){function e(e,t,r){this.transport=e,this.endpoint=t,this.encodedQueryParams=r,this.ready=this.waitForReady(),this.init&&this.init(),this.listen()}var r=e.prototype;return r.waitForReady=function(){var e=this;return new Promise(function(r){e.transport.on(t.MagicIncomingWindowMessage.MAGIC_OVERLAY_READY,function(){return r()})})},r.listen=function(){var e=this;this.transport.on(t.MagicIncomingWindowMessage.MAGIC_HIDE_OVERLAY,function(){e.hideOverlay()}),this.transport.on(t.MagicIncomingWindowMessage.MAGIC_SHOW_OVERLAY,function(){e.showOverlay()})},e}();exports.Extension=$,exports.MagicRPCError=w,exports.MagicSDKError=M,exports.MagicSDKWarning=E,exports.PayloadTransport=te,exports.SDKBase=ee,exports.ViewController=re,exports.createAutoCatchingPromise=G,exports.createDuplicateIframeWarning=function(){return new E(t.SDKWarningCode.DuplicateIframe,"Duplicate iframes found.")},exports.createExtensionNotInitializedError=A,exports.createInvalidArgumentError=R,exports.createMalformedResponseError=b,exports.createMissingApiKeyError=P,exports.createModalNotReadyError=function(){return new M(t.SDKErrorCode.ModalNotReady,"Modal is not ready.")},exports.createPromiEvent=Q,exports.createReactNativeEndpointConfigurationWarning=x,exports.createSDK=function(e,t){return Object.assign(_,t),e},exports.createSynchronousWeb3MethodWarning=I,exports.createURL=B,exports.encodeQueryParameters=f,exports.getPayloadId=j,exports.isEmpty=m,exports.isJsonRpcErrorCode=g,exports.isJsonRpcRequestPayload=function(e){return!y(e)&&!(h(e.jsonrpc)||h(e.id)||h(e.method)||h(e.params))},exports.isJsonRpcResponsePayload=v,exports.isMagicPayloadMethod=function(e){return!y(e)&&"string"==typeof e&&Object.values(t.MagicPayloadMethod).includes(e)},exports.isPromiEvent=function(e){return!!e[q]}; | ||
var e,t=require("@magic-sdk/types"),r=(e=require("eventemitter3"))&&"object"==typeof e&&"default"in e?e.default:e;function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function o(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}function i(){return(i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function a(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function u(e,t){return(u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}function d(e,t,r){return(d=c()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&u(o,r.prototype),o}).apply(null,arguments)}function l(e){var t="function"==typeof Map?new Map:void 0;return(l=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return d(e,arguments,s(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),u(r,e)})(e)}function p(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function f(e){return btoa(JSON.stringify(e))}function h(e){return void 0===e}function y(e){return function(e){return null===e}(e)||h(e)}function v(e){return!y(e)&&!(h(e.jsonrpc)||h(e.id)||h(e.result)&&h(e.error))}function g(e){return!y(e)&&"number"==typeof e&&Object.values(t.RPCErrorCode).includes(e)}function m(e){if(!e)return!0;for(var t in e)if(Object.hasOwnProperty.call(e,t))return!1;return!0}var _={},M=function(e){function t(r,n){var o;return(o=e.call(this,"Magic SDK Error: ["+r+"] "+n)||this).code=r,o.rawMessage=n,o.__proto__=Error,Object.setPrototypeOf(p(o),t.prototype),o}return a(t,e),t}(l(Error)),E=function(){function e(e,t){this.code=e,this.rawMessage=t,this.message="Magic SDK Warning: ["+e+"] "+t}return e.prototype.log=function(){console.warn(this.message)},e}(),w=function(e){function r(n){var o;(o=e.call(this)||this).__proto__=Error;var i=Number(null==n?void 0:n.code);return o.rawMessage=(null==n?void 0:n.message)||"Internal error",o.code=g(i)?i:t.RPCErrorCode.InternalError,o.message="Magic RPC Error: ["+o.code+"] "+o.rawMessage,Object.setPrototypeOf(p(o),r.prototype),o}return a(r,e),r}(l(Error));function P(){return new M(t.SDKErrorCode.MissingApiKey,"Please provide an API key that you acquired from the Magic developer dashboard.")}function b(){return new M(t.SDKErrorCode.MalformedResponse,"Response from the Magic iframe is malformed.")}function A(e){return new M(t.SDKErrorCode.ExtensionNotInitialized,"Extensions must be initialized with a Magic SDK instance before `Extension."+e+"` can be accessed. Do not invoke `Extension."+e+"` inside an extension constructor.")}function R(e){var r,n,o;return new M(t.SDKErrorCode.InvalidArgument,"Invalid "+(o=(r=e.argument+1)%100,(1==(n=r%10)&&11!==o?r+"st":2===n&&12!==o?r+"nd":3===n&&13!==o?r+"rd":r+"th")+" argument given to `")+e.procedure+"`.\n Expected: `"+e.expected+"`\n Received: `"+e.received+"`")}function I(){return new E(t.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 x(){return new E(t.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 `"+_.defaultEndpoint+"`. Changing this default behavior will lead to unexpected results and potentially security-threatening bugs.")}var O=regeneratorRuntime.mark(S);function S(){var e;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:e=0;case 1:if(!(e<Number.MAX_SAFE_INTEGER)){t.next=7;break}return t.next=5,++e;case 5:t.next=8;break;case 7:e=0;case 8:t.next=1;break;case 10:case"end":return t.stop()}},O)}var C=S();function j(){return C.next().value}var D=Symbol("Payload pre-processed by Magic SDK");function N(e){return Object.defineProperty(e,D,{value:!0,enumerable:!1}),e}function k(e){var t,r,n;return function(e){return!!e[D]}(e)||(e.jsonrpc=null!=(t=e.jsonrpc)?t:"2.0",e.id=j(),e.method=null!=(r=e.method)?r:"noop",e.params=null!=(n=e.params)?n:[],N(e)),e}function L(e,t){return void 0===t&&(t=[]),N({params:t,method:e,jsonrpc:"2.0",id:j()})}var T=function(){function e(t){t instanceof e?(this._jsonrpc=t.payload.jsonrpc,this._id=t.payload.id,this._result=t.payload.result,this._error=t.payload.error):v(t)?(this._jsonrpc=t.jsonrpc,this._id=t.id,this._result=t.result,this._error=t.error):(this._jsonrpc=t.jsonrpc,this._id=t.id,this._result=void 0,this._error=void 0)}var t=e.prototype;return t.applyError=function(e){return this._error=e,this},t.applyResult=function(e){return this._result=e,this},o(e,[{key:"hasError",get:function(){return null!=this._error}},{key:"hasResult",get:function(){return void 0!==this._result}},{key:"payload",get:function(){return{jsonrpc:this._jsonrpc,id:this._id,result:this._result,error:this._error}}}]),e}(),W=function(e){function t(){return e.apply(this,arguments)||this}return a(t,e),t}(r);function K(){var e=new W;return{emitter:e,createChainingEmitterMethod:function(t,r){return function(){return e[t].apply(e,[].slice.call(arguments)),r}},createBoundEmitterMethod:function(t){return function(){return e[t].apply(e,[].slice.call(arguments))}}}}var q=Symbol("isPromiEvent");function Q(e){var t=G(e),r=K(),n=r.createBoundEmitterMethod,o=r.createChainingEmitterMethod,i=Symbol("Promise.then"),a=Symbol("Promise.catch"),s=Symbol("Promise.finally"),u=function(e,t){return function(){var r=t[e].apply(t,[].slice.call(arguments));return c(r)}},c=function(e){var t;return Object.assign(e,((t={})[q]=!0,t[i]=e[i]||e.then,t[a]=e[a]||e.catch,t[s]=e[s]||e.finally,t.then=u(i,e),t.catch=u(a,e),t.finally=u(s,e),t.on=o("on",e),t.once=o("once",e),t.addListener=o("addListener",e),t.off=o("off",e),t.removeListener=o("removeListener",e),t.removeAllListeners=o("removeAllListeners",e),t.emit=n("emit"),t.eventNames=n("eventNames"),t.listeners=n("listeners"),t.listenerCount=n("listenerCount"),t))},d=c(t.then(function(e){return d.emit("done",e),d.emit("settled"),e},function(e){throw d.emit("error",e),d.emit("settled"),e}));return d}function G(e){return new Promise(function(t,r){var n=e(t,r);Promise.resolve(n).catch(r)})}var U=function(){function e(e){this.sdk=e}return e.prototype.request=function(e){var r=this.transport.post(this.overlay,t.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST,k(e)),n=Q(function(e,t){r.then(function(r){if(o(),r.hasError)t(new w(r.payload.error));else{if(!r.hasResult)throw b();e(r.payload.result)}}).catch(function(e){o(),t(e)})}),o=this.transport.on(t.MagicIncomingWindowMessage.MAGIC_HANDLE_EVENT,function(t){var r,o=t.data.response;if(o.id===e.id&&(null===(r=o.result)||void 0===r?void 0:r.event)){var i=o.result,a=i.params;n.emit.apply(n,[i.event].concat(void 0===a?[]:a))}});return n},o(e,[{key:"transport",get:function(){return this.sdk.transport}},{key:"overlay",get:function(){return this.sdk.overlay}}]),e}(),H=function(e){function r(){return e.apply(this,arguments)||this}return a(r,e),r.prototype.loginWithMagicLink=function(e){var r=e.showUI,n=L(t.MagicPayloadMethod.LoginWithMagicLink,[{email:e.email,showUI:void 0===r||r}]);return this.request(n)},r}(U),V=function(e){function r(){return e.apply(this,arguments)||this}a(r,e);var n=r.prototype;return n.getIdToken=function(e){var r=L(t.MagicPayloadMethod.GetIdToken,[e]);return this.request(r)},n.generateIdToken=function(e){var r=L(t.MagicPayloadMethod.GenerateIdToken,[e]);return this.request(r)},n.getMetadata=function(){var e=L(t.MagicPayloadMethod.GetMetadata);return this.request(e)},n.updateEmail=function(e){var r=e.showUI,n=L(t.MagicPayloadMethod.UpdateEmail,[{email:e.email,showUI:void 0===r||r}]);return this.request(n)},n.isLoggedIn=function(){var e=L(t.MagicPayloadMethod.IsLoggedIn);return this.request(e)},n.logout=function(){var e=L(t.MagicPayloadMethod.Logout);return this.request(e)},r}(U),z=K(),J=z.createBoundEmitterMethod,F=z.createChainingEmitterMethod,Y=function(e){function r(){var t;return(t=e.apply(this,arguments)||this).isMagic=!0,t.on=F("on",p(t)),t.once=F("once",p(t)),t.addListener=F("addListener",p(t)),t.off=F("off",p(t)),t.removeListener=F("removeListener",p(t)),t.removeAllListeners=F("removeAllListeners",p(t)),t.emit=J("emit"),t.eventNames=J("eventNames"),t.listeners=J("listeners"),t.listenerCount=J("listenerCount"),t}a(r,e);var n=r.prototype;return n.sendAsync=function(e,r){if(!r)throw R({procedure:"Magic.rpcProvider.sendAsync",argument:1,expected:"function",received:null===r?"null":typeof r});if(Array.isArray(e))this.transport.post(this.overlay,t.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST,e.map(function(e){return k(e)})).then(function(e){r(null,e.map(function(e){return i({},e.payload,{error:e.hasError?new w(e.payload.error):null})}))});else{var n=k(e);this.transport.post(this.overlay,t.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST,n).then(function(e){r(e.hasError?new w(e.payload.error):null,e.payload)})}},n.send=function(e,t){if("string"==typeof e){var r=L(e,Array.isArray(t)?t:[]);return this.request(r)}if(!Array.isArray(e)&&!t){var n=I();return n.log(),new T(e).applyError({code:-32603,message:n.rawMessage}).payload}this.sendAsync(e,t)},n.enable=function(){var e=L("eth_accounts");return this.request(e)},r}(U);function B(e,t){return t?new URL(e,t):new URL(e)}var X=function(e){function t(){var t;return(t=e.call(this,void 0)||this).isInitialized=!1,t.createJsonRpcRequestPayload=L,t.standardizeJsonRpcRequestPayload=k,new Proxy(p(t),{get:function(e,r,n){if(["request","transport","overlay","sdk"].includes(r)&&!t.isInitialized)throw A(r);return Reflect.get(e,r,n)}})||p(t)}return a(t,e),t.prototype.init=function(e){this.sdk=e,this.isInitialized=!0},t}(U),Z=function(e){function t(){return e.apply(this,arguments)||this}return a(t,e),t}(X),$=function(e){function t(){return e.apply(this,arguments)||this}return a(t,e),t}(X);$.Internal=Z;var ee=function(){function e(e,t){var r,n,o=this;if(this.apiKey=e,!e)throw P();"react-native"===_.target&&(null==t?void 0:t.endpoint)&&x().log();var i=_.version;this.endpoint=B(null!=(r=null==t?void 0:t.endpoint)?r:_.defaultEndpoint).origin,this.auth=new H(this),this.user=new V(this),this.rpcProvider=new Y(this);var a=null!=(n=null==t?void 0:t.extensions)?n:[],s={};Array.isArray(a)?a.forEach(function(e){e.init(o),o[e.name]=e,e instanceof $.Internal&&(m(e.config)||(s[e.name]=e.config))}):Object.keys(a).forEach(function(e){a[e].init(o);var t=a[e];o[e]=t,t instanceof $.Internal&&(m(t.config)||(s[a[e].name]=t.config))}),this.encodedQueryParams=f({API_KEY:this.apiKey,DOMAIN_ORIGIN:window.location?window.location.origin:"",ETH_NETWORK:null==t?void 0:t.network,host:B(this.endpoint).host,sdk:_.sdkName,version:i,ext:m(s)?void 0:s})}return e.prototype.preload=function(){try{return Promise.resolve(this.overlay.ready).then(function(){})}catch(e){return Promise.reject(e)}},o(e,[{key:"transport",get:function(){return e.__transports__.has(this.encodedQueryParams)||e.__transports__.set(this.encodedQueryParams,new _.PayloadTransport(this.endpoint,this.encodedQueryParams)),e.__transports__.get(this.encodedQueryParams)}},{key:"overlay",get:function(){if(!e.__overlays__.has(this.encodedQueryParams)){var t=new _.ViewController(this.transport,this.endpoint,this.encodedQueryParams);e.__overlays__.set(this.encodedQueryParams,t)}return e.__overlays__.get(this.encodedQueryParams)}}]),e}();ee.__transports__=new Map,ee.__overlays__=new Map;var te=function(){function e(e,t){this.endpoint=e,this.encodedQueryParams=t,this.messageHandlers=new Set,this.init()}var r=e.prototype;return r.post=function(e,r,n){try{var o=this;return Promise.resolve(G(function(i){try{return Promise.resolve(e.ready).then(function(){var a=[],s=Array.isArray(n)?n.map(function(e){return e.id}):[];return Promise.resolve(e.postMessage({msgType:r+"-"+o.encodedQueryParams,payload:n})).then(function(){var e,r=o.on(t.MagicIncomingWindowMessage.MAGIC_HANDLE_RESPONSE,(e=function(){return r()},function(t){var r=function(e,t){var r,n=null===(r=t.data.response)||void 0===r?void 0:r.id,o=function(e,t){return t&&Array.isArray(e)?e.find(function(e){return e.id===t}):e}(e,n);return n&&o?{id:n,response:new T(o).applyResult(t.data.response.result).applyError(t.data.response.error)}:{}}(n,t),o=r.id,u=r.response;o&&u&&Array.isArray(n)&&s.includes(o)?(a.push(u),a.length===n.length&&(e(),i(a))):o&&u&&!Array.isArray(n)&&o===n.id&&(e(),i(u))}))})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},r.on=function(e,t){var r=this,n=t.bind(window),o=function(t){t.data.msgType===e+"-"+r.encodedQueryParams&&n(t)};return this.messageHandlers.add(o),function(){return r.messageHandlers.delete(o)}},e}(),re=function(){function e(e,t,r){this.transport=e,this.endpoint=t,this.encodedQueryParams=r,this.ready=this.waitForReady(),this.init&&this.init(),this.listen()}var r=e.prototype;return r.waitForReady=function(){var e=this;return new Promise(function(r){e.transport.on(t.MagicIncomingWindowMessage.MAGIC_OVERLAY_READY,function(){return r()})})},r.listen=function(){var e=this;this.transport.on(t.MagicIncomingWindowMessage.MAGIC_HIDE_OVERLAY,function(){e.hideOverlay()}),this.transport.on(t.MagicIncomingWindowMessage.MAGIC_SHOW_OVERLAY,function(){e.showOverlay()})},e}();exports.Extension=$,exports.MagicRPCError=w,exports.MagicSDKError=M,exports.MagicSDKWarning=E,exports.PayloadTransport=te,exports.SDKBase=ee,exports.ViewController=re,exports.createAutoCatchingPromise=G,exports.createDuplicateIframeWarning=function(){return new E(t.SDKWarningCode.DuplicateIframe,"Duplicate iframes found.")},exports.createExtensionNotInitializedError=A,exports.createInvalidArgumentError=R,exports.createMalformedResponseError=b,exports.createMissingApiKeyError=P,exports.createModalNotReadyError=function(){return new M(t.SDKErrorCode.ModalNotReady,"Modal is not ready.")},exports.createPromiEvent=Q,exports.createReactNativeEndpointConfigurationWarning=x,exports.createSDK=function(e,t){return Object.assign(_,t),e},exports.createSynchronousWeb3MethodWarning=I,exports.createURL=B,exports.encodeQueryParameters=f,exports.getPayloadId=j,exports.isEmpty=m,exports.isJsonRpcErrorCode=g,exports.isJsonRpcRequestPayload=function(e){return!y(e)&&!(h(e.jsonrpc)||h(e.id)||h(e.method)||h(e.params))},exports.isJsonRpcResponsePayload=v,exports.isMagicPayloadMethod=function(e){return!y(e)&&"string"==typeof e&&Object.values(t.MagicPayloadMethod).includes(e)},exports.isPromiEvent=function(e){return!!e[q]}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import{MagicPayloadMethod as e,RPCErrorCode as t,SDKErrorCode as r,SDKWarningCode as n,MagicOutgoingWindowMessage as o,MagicIncomingWindowMessage as i}from"@magic-sdk/types";import a from"eventemitter3";function s(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function u(e,t,r){return t&&s(e.prototype,t),r&&s(e,r),e}function c(){return(c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function l(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function f(e,t){return(f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function p(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}function h(e,t,r){return(h=p()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&f(o,r.prototype),o}).apply(null,arguments)}function y(e){var t="function"==typeof Map?new Map:void 0;return(y=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return h(e,arguments,d(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),f(r,e)})(e)}function v(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function m(e){return btoa(JSON.stringify(e))}function g(e){return void 0===e}function _(e){return function(e){return null===e}(e)||g(e)}function w(e){return!_(e)&&!(g(e.jsonrpc)||g(e.id)||g(e.method)||g(e.params))}function E(e){return!_(e)&&!(g(e.jsonrpc)||g(e.id)||g(e.result)&&g(e.error))}function b(t){return!_(t)&&"string"==typeof t&&Object.values(e).includes(t)}function P(e){return!_(e)&&"number"==typeof e&&Object.values(t).includes(e)}function A(e){if(!e)return!0;for(var t in e)if(Object.hasOwnProperty.call(e,t))return!1;return!0}var M={};function O(e,t){return Object.assign(M,t),e}var I=function(e){function t(r,n){var o;return(o=e.call(this,"Magic SDK Error: ["+r+"] "+n)||this).code=r,o.rawMessage=n,o.__proto__=Error,Object.setPrototypeOf(v(o),t.prototype),o}return l(t,e),t}(y(Error)),R=function(){function e(e,t){this.code=e,this.rawMessage=t,this.message="Magic SDK Warning: ["+e+"] "+t}return e.prototype.log=function(){console.warn(this.message)},e}(),j=function(e){function r(n){var o;(o=e.call(this)||this).__proto__=Error;var i=Number(null==n?void 0:n.code);return o.rawMessage=(null==n?void 0:n.message)||"Internal error",o.code=P(i)?i:t.InternalError,o.message="Magic RPC Error: ["+o.code+"] "+o.rawMessage,Object.setPrototypeOf(v(o),r.prototype),o}return l(r,e),r}(y(Error));function k(){return new I(r.MissingApiKey,"Please provide an API key that you acquired from the Magic developer dashboard.")}function L(){return new I(r.ModalNotReady,"Modal is not ready.")}function N(){return new I(r.MalformedResponse,"Response from the Magic iframe is malformed.")}function S(e){return new I(r.ExtensionNotInitialized,"Extensions must be initialized with a Magic SDK instance before `Extension."+e+"` can be accessed. Do not invoke `Extension."+e+"` inside an extension constructor.")}function T(e){var t,n,o;return new I(r.InvalidArgument,"Invalid "+(o=(t=e.argument+1)%100,(1==(n=t%10)&&11!==o?t+"st":2===n&&12!==o?t+"nd":3===n&&13!==o?t+"rd":t+"th")+" argument given to `")+e.procedure+"`.\n Expected: `"+e.expected+"`\n Received: `"+e.received+"`")}function x(){return new R(n.DuplicateIframe,"Duplicate iframes found.")}function C(){return new R(n.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 D(){return new R(n.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.")}var Q=regeneratorRuntime.mark(G);function G(){var e;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:e=0;case 1:if(!(e<Number.MAX_SAFE_INTEGER)){t.next=7;break}return t.next=5,++e;case 5:t.next=8;break;case 7:e=0;case 8:t.next=1;break;case 10:case"end":return t.stop()}},Q)}var q=G();function H(){return q.next().value}var U=Symbol("Payload pre-processed by Magic SDK");function K(e){return Object.defineProperty(e,U,{value:!0,enumerable:!1}),e}function W(e){var t,r,n;return function(e){return!!e[U]}(e)||(e.jsonrpc=null!=(t=e.jsonrpc)?t:"2.0",e.id=H(),e.method=null!=(r=e.method)?r:"noop",e.params=null!=(n=e.params)?n:[],K(e)),e}function V(e,t){return void 0===t&&(t=[]),K({params:t,method:e,jsonrpc:"2.0",id:H()})}var z=function(){function e(t){t instanceof e?(this._jsonrpc=t.payload.jsonrpc,this._id=t.payload.id,this._result=t.payload.result,this._error=t.payload.error):E(t)?(this._jsonrpc=t.jsonrpc,this._id=t.id,this._result=t.result,this._error=t.error):(this._jsonrpc=t.jsonrpc,this._id=t.id,this._result=void 0,this._error=void 0)}var t=e.prototype;return t.applyError=function(e){return this._error=e,this},t.applyResult=function(e){return this._result=e,this},u(e,[{key:"hasError",get:function(){return null!=this._error}},{key:"hasResult",get:function(){return void 0!==this._result}},{key:"payload",get:function(){return{jsonrpc:this._jsonrpc,id:this._id,result:this._result,error:this._error}}}]),e}(),F=function(e){function t(){return e.apply(this,arguments)||this}return l(t,e),t}(a);function Y(){var e=new F;return{emitter:e,createChainingEmitterMethod:function(t,r){return function(){return e[t].apply(e,[].slice.call(arguments)),r}},createBoundEmitterMethod:function(t){return function(){return e[t].apply(e,[].slice.call(arguments))}}}}var B=Symbol("isPromiEvent");function J(e){return!!e[B]}function X(e){var t=Z(e),r=Y(),n=r.createBoundEmitterMethod,o=r.createChainingEmitterMethod,i=Symbol("Promise.then"),a=Symbol("Promise.catch"),s=Symbol("Promise.finally"),u=function(e,t){return function(){var r=t[e].apply(t,[].slice.call(arguments));return c(r)}},c=function(e){var t;return Object.assign(e,((t={})[B]=!0,t[i]=e[i]||e.then,t[a]=e[a]||e.catch,t[s]=e[s]||e.finally,t.then=u(i,e),t.catch=u(a,e),t.finally=u(s,e),t.on=o("on",e),t.once=o("once",e),t.addListener=o("addListener",e),t.off=o("off",e),t.removeListener=o("removeListener",e),t.removeAllListeners=o("removeAllListeners",e),t.emit=n("emit"),t.eventNames=n("eventNames"),t.listeners=n("listeners"),t.listenerCount=n("listenerCount"),t))},l=c(t.then(function(e){return l.emit("done",e),l.emit("settled"),e},function(e){throw l.emit("error",e),l.emit("settled"),e}));return l}function Z(e){return new Promise(function(t,r){var n=e(t,r);Promise.resolve(n).catch(r)})}var $=function(){function e(e){this.sdk=e}return e.prototype.request=function(e){var t=this.transport.post(this.overlay,o.MAGIC_HANDLE_REQUEST,W(e)),r=X(function(e,r){t.then(function(t){if(n(),t.hasError)r(new j(t.payload.error));else{if(!t.hasResult)throw N();e(t.payload.result)}}).catch(function(e){n(),r(e)})}),n=this.transport.on(i.MAGIC_HANDLE_EVENT,function(t){var n,o=t.data.response;if(o.id===e.id&&(null===(n=o.result)||void 0===n?void 0:n.event)){var i=o.result,a=i.params;r.emit.apply(r,[i.event].concat(void 0===a?[]:a))}});return r},u(e,[{key:"transport",get:function(){return this.sdk.transport}},{key:"overlay",get:function(){return this.sdk.overlay}}]),e}(),ee=function(t){function r(){return t.apply(this,arguments)||this}return l(r,t),r.prototype.loginWithMagicLink=function(t){var r=t.showUI,n=V(e.LoginWithMagicLink,[{email:t.email,showUI:void 0===r||r}]);return this.request(n)},r}($),te=function(t){function r(){return t.apply(this,arguments)||this}l(r,t);var n=r.prototype;return n.getIdToken=function(t){var r=V(e.GetIdToken,[t]);return this.request(r)},n.generateIdToken=function(t){var r=V(e.GenerateIdToken,[t]);return this.request(r)},n.getMetadata=function(){var t=V(e.GetMetadata);return this.request(t)},n.updateEmail=function(t){var r=t.showUI,n=V(e.UpdateEmail,[{email:t.email,showUI:void 0===r||r}]);return this.request(n)},n.isLoggedIn=function(){var t=V(e.IsLoggedIn);return this.request(t)},n.logout=function(){var t=V(e.Logout);return this.request(t)},r}($),re=Y(),ne=re.createBoundEmitterMethod,oe=re.createChainingEmitterMethod,ie=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).isMagic=!0,t.on=oe("on",v(t)),t.once=oe("once",v(t)),t.addListener=oe("addListener",v(t)),t.off=oe("off",v(t)),t.removeListener=oe("removeListener",v(t)),t.removeAllListeners=oe("removeAllListeners",v(t)),t.emit=ne("emit"),t.eventNames=ne("eventNames"),t.listeners=ne("listeners"),t.listenerCount=ne("listenerCount"),t}l(t,e);var r=t.prototype;return r.sendAsync=function(e,t){if(!t)throw T({procedure:"Magic.rpcProvider.sendAsync",argument:1,expected:"function",received:null===t?"null":typeof t});if(Array.isArray(e))this.transport.post(this.overlay,o.MAGIC_HANDLE_REQUEST,e.map(function(e){return W(e)})).then(function(e){t(null,e.map(function(e){return c(c({},e.payload),{},{error:e.hasError?new j(e.payload.error):null})}))});else{var r=W(e);this.transport.post(this.overlay,o.MAGIC_HANDLE_REQUEST,r).then(function(e){t(e.hasError?new j(e.payload.error):null,e.payload)})}},r.send=function(e,t){if("string"==typeof e){var r=V(e,Array.isArray(t)?t:[]);return this.request(r)}if(!Array.isArray(e)&&!t){var n=C();return n.log(),new z(e).applyError({code:-32603,message:n.rawMessage}).payload}this.sendAsync(e,t)},r.enable=function(){var e=V("eth_accounts");return this.request(e)},t}($);function ae(e,t){return t?new URL(e,t):new URL(e)}var se=function(e){function t(){var t;return(t=e.call(this,void 0)||this).isInitialized=!1,t.createJsonRpcRequestPayload=V,t.standardizeJsonRpcRequestPayload=W,new Proxy(v(t),{get:function(e,r,n){if(["request","transport","overlay","sdk"].includes(r)&&!t.isInitialized)throw S(r);return Reflect.get(e,r,n)}})||v(t)}return l(t,e),t.prototype.init=function(e){this.sdk=e,this.isInitialized=!0},t}($),ue=function(e){function t(){return e.apply(this,arguments)||this}return l(t,e),t}(se),ce=function(){var e=function(e){function t(){return e.apply(this,arguments)||this}return l(t,e),t}(se);return e.Internal=ue,e}(),le=function(){var e=function(){function e(e,t){var r,n,o=this;if(this.apiKey=e,!e)throw k();"react-native"===M.target&&(null==t?void 0:t.endpoint)&&D().log();var i=M.version;this.endpoint=ae(null!=(r=null==t?void 0:t.endpoint)?r:M.defaultEndpoint).origin,this.auth=new ee(this),this.user=new te(this),this.rpcProvider=new ie(this);var a=null!=(n=null==t?void 0:t.extensions)?n:[],s={};Array.isArray(a)?a.forEach(function(e){e.init(o),o[e.name]=e,e instanceof ce.Internal&&(A(e.config)||(s[e.name]=e.config))}):Object.keys(a).forEach(function(e){a[e].init(o);var t=a[e];o[e]=t,t instanceof ce.Internal&&(A(t.config)||(s[a[e].name]=t.config))}),this.encodedQueryParams=m({API_KEY:this.apiKey,DOMAIN_ORIGIN:window.location?window.location.origin:"",ETH_NETWORK:null==t?void 0:t.network,host:ae(this.endpoint).host,sdk:M.sdkName,version:i,ext:A(s)?void 0:s})}return e.prototype.preload=function(){try{return Promise.resolve(this.overlay.ready).then(function(){})}catch(e){return Promise.reject(e)}},u(e,[{key:"transport",get:function(){return e.__transports__.has(this.encodedQueryParams)||e.__transports__.set(this.encodedQueryParams,new M.PayloadTransport(this.endpoint,this.encodedQueryParams)),e.__transports__.get(this.encodedQueryParams)}},{key:"overlay",get:function(){if(!e.__overlays__.has(this.encodedQueryParams)){var t=new M.ViewController(this.transport,this.endpoint,this.encodedQueryParams);e.__overlays__.set(this.encodedQueryParams,t)}return e.__overlays__.get(this.encodedQueryParams)}}]),e}();return e.__transports__=new Map,e.__overlays__=new Map,e}(),de=function(){function e(e,t){this.endpoint=e,this.encodedQueryParams=t,this.messageHandlers=new Set,this.init()}var t=e.prototype;return t.post=function(e,t,r){try{var n=this;return Promise.resolve(Z(function(o){try{return Promise.resolve(e.ready).then(function(){var a=[],s=Array.isArray(r)?r.map(function(e){return e.id}):[];return Promise.resolve(e.postMessage({msgType:t+"-"+n.encodedQueryParams,payload:r})).then(function(){var e,t=n.on(i.MAGIC_HANDLE_RESPONSE,(e=function(){return t()},function(t){var n=function(e,t){var r,n=null===(r=t.data.response)||void 0===r?void 0:r.id,o=function(e,t){return t&&Array.isArray(e)?e.find(function(e){return e.id===t}):e}(e,n);return n&&o?{id:n,response:new z(o).applyResult(t.data.response.result).applyError(t.data.response.error)}:{}}(r,t),i=n.id,u=n.response;i&&u&&Array.isArray(r)&&s.includes(i)?(a.push(u),a.length===r.length&&(e(),o(a))):i&&u&&!Array.isArray(r)&&i===r.id&&(e(),o(u))}))})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},t.on=function(e,t){var r=this,n=t.bind(window),o=function(t){t.data.msgType===e+"-"+r.encodedQueryParams&&n(t)};return this.messageHandlers.add(o),function(){return r.messageHandlers.delete(o)}},e}(),fe=function(){function e(e,t,r){this.transport=e,this.endpoint=t,this.encodedQueryParams=r,this.ready=this.waitForReady(),this.init&&this.init(),this.listen()}var t=e.prototype;return t.waitForReady=function(){var e=this;return new Promise(function(t){e.transport.on(i.MAGIC_OVERLAY_READY,function(){return t()})})},t.listen=function(){var e=this;this.transport.on(i.MAGIC_HIDE_OVERLAY,function(){e.hideOverlay()}),this.transport.on(i.MAGIC_SHOW_OVERLAY,function(){e.showOverlay()})},e}();export{ce as Extension,j as MagicRPCError,I as MagicSDKError,R as MagicSDKWarning,de as PayloadTransport,le as SDKBase,fe as ViewController,Z as createAutoCatchingPromise,x as createDuplicateIframeWarning,S as createExtensionNotInitializedError,T as createInvalidArgumentError,N as createMalformedResponseError,k as createMissingApiKeyError,L as createModalNotReadyError,X as createPromiEvent,D as createReactNativeEndpointConfigurationWarning,O as createSDK,C as createSynchronousWeb3MethodWarning,ae as createURL,m as encodeQueryParameters,H as getPayloadId,A as isEmpty,P as isJsonRpcErrorCode,w as isJsonRpcRequestPayload,E as isJsonRpcResponsePayload,b as isMagicPayloadMethod,J as isPromiEvent}; | ||
import{MagicPayloadMethod as e,RPCErrorCode as t,SDKErrorCode as r,SDKWarningCode as n,MagicOutgoingWindowMessage as o,MagicIncomingWindowMessage as i}from"@magic-sdk/types";import a from"eventemitter3";function s(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function u(e,t,r){return t&&s(e.prototype,t),r&&s(e,r),e}function c(){return(c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function l(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function f(e,t){return(f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function p(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}function h(e,t,r){return(h=p()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&f(o,r.prototype),o}).apply(null,arguments)}function y(e){var t="function"==typeof Map?new Map:void 0;return(y=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return h(e,arguments,d(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),f(r,e)})(e)}function v(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function m(e){return btoa(JSON.stringify(e))}function g(e){return void 0===e}function _(e){return function(e){return null===e}(e)||g(e)}function w(e){return!_(e)&&!(g(e.jsonrpc)||g(e.id)||g(e.method)||g(e.params))}function E(e){return!_(e)&&!(g(e.jsonrpc)||g(e.id)||g(e.result)&&g(e.error))}function b(t){return!_(t)&&"string"==typeof t&&Object.values(e).includes(t)}function P(e){return!_(e)&&"number"==typeof e&&Object.values(t).includes(e)}function A(e){if(!e)return!0;for(var t in e)if(Object.hasOwnProperty.call(e,t))return!1;return!0}var M={};function O(e,t){return Object.assign(M,t),e}var I=function(e){function t(r,n){var o;return(o=e.call(this,"Magic SDK Error: ["+r+"] "+n)||this).code=r,o.rawMessage=n,o.__proto__=Error,Object.setPrototypeOf(v(o),t.prototype),o}return l(t,e),t}(y(Error)),R=function(){function e(e,t){this.code=e,this.rawMessage=t,this.message="Magic SDK Warning: ["+e+"] "+t}return e.prototype.log=function(){console.warn(this.message)},e}(),j=function(e){function r(n){var o;(o=e.call(this)||this).__proto__=Error;var i=Number(null==n?void 0:n.code);return o.rawMessage=(null==n?void 0:n.message)||"Internal error",o.code=P(i)?i:t.InternalError,o.message="Magic RPC Error: ["+o.code+"] "+o.rawMessage,Object.setPrototypeOf(v(o),r.prototype),o}return l(r,e),r}(y(Error));function k(){return new I(r.MissingApiKey,"Please provide an API key that you acquired from the Magic developer dashboard.")}function L(){return new I(r.ModalNotReady,"Modal is not ready.")}function N(){return new I(r.MalformedResponse,"Response from the Magic iframe is malformed.")}function S(e){return new I(r.ExtensionNotInitialized,"Extensions must be initialized with a Magic SDK instance before `Extension."+e+"` can be accessed. Do not invoke `Extension."+e+"` inside an extension constructor.")}function T(e){var t,n,o;return new I(r.InvalidArgument,"Invalid "+(o=(t=e.argument+1)%100,(1==(n=t%10)&&11!==o?t+"st":2===n&&12!==o?t+"nd":3===n&&13!==o?t+"rd":t+"th")+" argument given to `")+e.procedure+"`.\n Expected: `"+e.expected+"`\n Received: `"+e.received+"`")}function x(){return new R(n.DuplicateIframe,"Duplicate iframes found.")}function C(){return new R(n.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 D(){return new R(n.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.")}var Q=regeneratorRuntime.mark(G);function G(){var e;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:e=0;case 1:if(!(e<Number.MAX_SAFE_INTEGER)){t.next=7;break}return t.next=5,++e;case 5:t.next=8;break;case 7:e=0;case 8:t.next=1;break;case 10:case"end":return t.stop()}},Q)}var q=G();function H(){return q.next().value}var U=Symbol("Payload pre-processed by Magic SDK");function K(e){return Object.defineProperty(e,U,{value:!0,enumerable:!1}),e}function W(e){var t,r,n;return function(e){return!!e[U]}(e)||(e.jsonrpc=null!=(t=e.jsonrpc)?t:"2.0",e.id=H(),e.method=null!=(r=e.method)?r:"noop",e.params=null!=(n=e.params)?n:[],K(e)),e}function V(e,t){return void 0===t&&(t=[]),K({params:t,method:e,jsonrpc:"2.0",id:H()})}var z=function(){function e(t){t instanceof e?(this._jsonrpc=t.payload.jsonrpc,this._id=t.payload.id,this._result=t.payload.result,this._error=t.payload.error):E(t)?(this._jsonrpc=t.jsonrpc,this._id=t.id,this._result=t.result,this._error=t.error):(this._jsonrpc=t.jsonrpc,this._id=t.id,this._result=void 0,this._error=void 0)}var t=e.prototype;return t.applyError=function(e){return this._error=e,this},t.applyResult=function(e){return this._result=e,this},u(e,[{key:"hasError",get:function(){return null!=this._error}},{key:"hasResult",get:function(){return void 0!==this._result}},{key:"payload",get:function(){return{jsonrpc:this._jsonrpc,id:this._id,result:this._result,error:this._error}}}]),e}(),F=function(e){function t(){return e.apply(this,arguments)||this}return l(t,e),t}(a);function Y(){var e=new F;return{emitter:e,createChainingEmitterMethod:function(t,r){return function(){return e[t].apply(e,[].slice.call(arguments)),r}},createBoundEmitterMethod:function(t){return function(){return e[t].apply(e,[].slice.call(arguments))}}}}var B=Symbol("isPromiEvent");function J(e){return!!e[B]}function X(e){var t=Z(e),r=Y(),n=r.createBoundEmitterMethod,o=r.createChainingEmitterMethod,i=Symbol("Promise.then"),a=Symbol("Promise.catch"),s=Symbol("Promise.finally"),u=function(e,t){return function(){var r=t[e].apply(t,[].slice.call(arguments));return c(r)}},c=function(e){var t;return Object.assign(e,((t={})[B]=!0,t[i]=e[i]||e.then,t[a]=e[a]||e.catch,t[s]=e[s]||e.finally,t.then=u(i,e),t.catch=u(a,e),t.finally=u(s,e),t.on=o("on",e),t.once=o("once",e),t.addListener=o("addListener",e),t.off=o("off",e),t.removeListener=o("removeListener",e),t.removeAllListeners=o("removeAllListeners",e),t.emit=n("emit"),t.eventNames=n("eventNames"),t.listeners=n("listeners"),t.listenerCount=n("listenerCount"),t))},l=c(t.then(function(e){return l.emit("done",e),l.emit("settled"),e},function(e){throw l.emit("error",e),l.emit("settled"),e}));return l}function Z(e){return new Promise(function(t,r){var n=e(t,r);Promise.resolve(n).catch(r)})}var $=function(){function e(e){this.sdk=e}return e.prototype.request=function(e){var t=this.transport.post(this.overlay,o.MAGIC_HANDLE_REQUEST,W(e)),r=X(function(e,r){t.then(function(t){if(n(),t.hasError)r(new j(t.payload.error));else{if(!t.hasResult)throw N();e(t.payload.result)}}).catch(function(e){n(),r(e)})}),n=this.transport.on(i.MAGIC_HANDLE_EVENT,function(t){var n,o=t.data.response;if(o.id===e.id&&(null===(n=o.result)||void 0===n?void 0:n.event)){var i=o.result,a=i.params;r.emit.apply(r,[i.event].concat(void 0===a?[]:a))}});return r},u(e,[{key:"transport",get:function(){return this.sdk.transport}},{key:"overlay",get:function(){return this.sdk.overlay}}]),e}(),ee=function(t){function r(){return t.apply(this,arguments)||this}return l(r,t),r.prototype.loginWithMagicLink=function(t){var r=t.showUI,n=V(e.LoginWithMagicLink,[{email:t.email,showUI:void 0===r||r}]);return this.request(n)},r}($),te=function(t){function r(){return t.apply(this,arguments)||this}l(r,t);var n=r.prototype;return n.getIdToken=function(t){var r=V(e.GetIdToken,[t]);return this.request(r)},n.generateIdToken=function(t){var r=V(e.GenerateIdToken,[t]);return this.request(r)},n.getMetadata=function(){var t=V(e.GetMetadata);return this.request(t)},n.updateEmail=function(t){var r=t.showUI,n=V(e.UpdateEmail,[{email:t.email,showUI:void 0===r||r}]);return this.request(n)},n.isLoggedIn=function(){var t=V(e.IsLoggedIn);return this.request(t)},n.logout=function(){var t=V(e.Logout);return this.request(t)},r}($),re=Y(),ne=re.createBoundEmitterMethod,oe=re.createChainingEmitterMethod,ie=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).isMagic=!0,t.on=oe("on",v(t)),t.once=oe("once",v(t)),t.addListener=oe("addListener",v(t)),t.off=oe("off",v(t)),t.removeListener=oe("removeListener",v(t)),t.removeAllListeners=oe("removeAllListeners",v(t)),t.emit=ne("emit"),t.eventNames=ne("eventNames"),t.listeners=ne("listeners"),t.listenerCount=ne("listenerCount"),t}l(t,e);var r=t.prototype;return r.sendAsync=function(e,t){if(!t)throw T({procedure:"Magic.rpcProvider.sendAsync",argument:1,expected:"function",received:null===t?"null":typeof t});if(Array.isArray(e))this.transport.post(this.overlay,o.MAGIC_HANDLE_REQUEST,e.map(function(e){return W(e)})).then(function(e){t(null,e.map(function(e){return c({},e.payload,{error:e.hasError?new j(e.payload.error):null})}))});else{var r=W(e);this.transport.post(this.overlay,o.MAGIC_HANDLE_REQUEST,r).then(function(e){t(e.hasError?new j(e.payload.error):null,e.payload)})}},r.send=function(e,t){if("string"==typeof e){var r=V(e,Array.isArray(t)?t:[]);return this.request(r)}if(!Array.isArray(e)&&!t){var n=C();return n.log(),new z(e).applyError({code:-32603,message:n.rawMessage}).payload}this.sendAsync(e,t)},r.enable=function(){var e=V("eth_accounts");return this.request(e)},t}($);function ae(e,t){return t?new URL(e,t):new URL(e)}var se=function(e){function t(){var t;return(t=e.call(this,void 0)||this).isInitialized=!1,t.createJsonRpcRequestPayload=V,t.standardizeJsonRpcRequestPayload=W,new Proxy(v(t),{get:function(e,r,n){if(["request","transport","overlay","sdk"].includes(r)&&!t.isInitialized)throw S(r);return Reflect.get(e,r,n)}})||v(t)}return l(t,e),t.prototype.init=function(e){this.sdk=e,this.isInitialized=!0},t}($),ue=function(e){function t(){return e.apply(this,arguments)||this}return l(t,e),t}(se),ce=function(e){function t(){return e.apply(this,arguments)||this}return l(t,e),t}(se);ce.Internal=ue;var le=function(){function e(e,t){var r,n,o=this;if(this.apiKey=e,!e)throw k();"react-native"===M.target&&(null==t?void 0:t.endpoint)&&D().log();var i=M.version;this.endpoint=ae(null!=(r=null==t?void 0:t.endpoint)?r:M.defaultEndpoint).origin,this.auth=new ee(this),this.user=new te(this),this.rpcProvider=new ie(this);var a=null!=(n=null==t?void 0:t.extensions)?n:[],s={};Array.isArray(a)?a.forEach(function(e){e.init(o),o[e.name]=e,e instanceof ce.Internal&&(A(e.config)||(s[e.name]=e.config))}):Object.keys(a).forEach(function(e){a[e].init(o);var t=a[e];o[e]=t,t instanceof ce.Internal&&(A(t.config)||(s[a[e].name]=t.config))}),this.encodedQueryParams=m({API_KEY:this.apiKey,DOMAIN_ORIGIN:window.location?window.location.origin:"",ETH_NETWORK:null==t?void 0:t.network,host:ae(this.endpoint).host,sdk:M.sdkName,version:i,ext:A(s)?void 0:s})}return e.prototype.preload=function(){try{return Promise.resolve(this.overlay.ready).then(function(){})}catch(e){return Promise.reject(e)}},u(e,[{key:"transport",get:function(){return e.__transports__.has(this.encodedQueryParams)||e.__transports__.set(this.encodedQueryParams,new M.PayloadTransport(this.endpoint,this.encodedQueryParams)),e.__transports__.get(this.encodedQueryParams)}},{key:"overlay",get:function(){if(!e.__overlays__.has(this.encodedQueryParams)){var t=new M.ViewController(this.transport,this.endpoint,this.encodedQueryParams);e.__overlays__.set(this.encodedQueryParams,t)}return e.__overlays__.get(this.encodedQueryParams)}}]),e}();le.__transports__=new Map,le.__overlays__=new Map;var de=function(){function e(e,t){this.endpoint=e,this.encodedQueryParams=t,this.messageHandlers=new Set,this.init()}var t=e.prototype;return t.post=function(e,t,r){try{var n=this;return Promise.resolve(Z(function(o){try{return Promise.resolve(e.ready).then(function(){var a=[],s=Array.isArray(r)?r.map(function(e){return e.id}):[];return Promise.resolve(e.postMessage({msgType:t+"-"+n.encodedQueryParams,payload:r})).then(function(){var e,t=n.on(i.MAGIC_HANDLE_RESPONSE,(e=function(){return t()},function(t){var n=function(e,t){var r,n=null===(r=t.data.response)||void 0===r?void 0:r.id,o=function(e,t){return t&&Array.isArray(e)?e.find(function(e){return e.id===t}):e}(e,n);return n&&o?{id:n,response:new z(o).applyResult(t.data.response.result).applyError(t.data.response.error)}:{}}(r,t),i=n.id,u=n.response;i&&u&&Array.isArray(r)&&s.includes(i)?(a.push(u),a.length===r.length&&(e(),o(a))):i&&u&&!Array.isArray(r)&&i===r.id&&(e(),o(u))}))})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},t.on=function(e,t){var r=this,n=t.bind(window),o=function(t){t.data.msgType===e+"-"+r.encodedQueryParams&&n(t)};return this.messageHandlers.add(o),function(){return r.messageHandlers.delete(o)}},e}(),fe=function(){function e(e,t,r){this.transport=e,this.endpoint=t,this.encodedQueryParams=r,this.ready=this.waitForReady(),this.init&&this.init(),this.listen()}var t=e.prototype;return t.waitForReady=function(){var e=this;return new Promise(function(t){e.transport.on(i.MAGIC_OVERLAY_READY,function(){return t()})})},t.listen=function(){var e=this;this.transport.on(i.MAGIC_HIDE_OVERLAY,function(){e.hideOverlay()}),this.transport.on(i.MAGIC_SHOW_OVERLAY,function(){e.showOverlay()})},e}();export{ce as Extension,j as MagicRPCError,I as MagicSDKError,R as MagicSDKWarning,de as PayloadTransport,le as SDKBase,fe as ViewController,Z as createAutoCatchingPromise,x as createDuplicateIframeWarning,S as createExtensionNotInitializedError,T as createInvalidArgumentError,N as createMalformedResponseError,k as createMissingApiKeyError,L as createModalNotReadyError,X as createPromiEvent,D as createReactNativeEndpointConfigurationWarning,O as createSDK,C as createSynchronousWeb3MethodWarning,ae as createURL,m as encodeQueryParameters,H as getPayloadId,A as isEmpty,P as isJsonRpcErrorCode,w as isJsonRpcRequestPayload,E as isJsonRpcResponsePayload,b as isMagicPayloadMethod,J as isPromiEvent}; | ||
//# sourceMappingURL=index.m.js.map |
@@ -1,2 +0,2 @@ | ||
import{MagicPayloadMethod as e,RPCErrorCode as t,SDKErrorCode as r,SDKWarningCode as n,MagicOutgoingWindowMessage as s,MagicIncomingWindowMessage as i}from"@magic-sdk/types";import o from"eventemitter3";function a(e){return btoa(JSON.stringify(e))}function d(e){return void 0===e}function c(e){return function(e){return null===e}(e)||d(e)}function u(e){return!c(e)&&!(d(e.jsonrpc)||d(e.id)||d(e.method)||d(e.params))}function l(e){return!c(e)&&!(d(e.jsonrpc)||d(e.id)||d(e.result)&&d(e.error))}function h(t){return!c(t)&&"string"==typeof t&&Object.values(e).includes(t)}function p(e){return!c(e)&&"number"==typeof e&&Object.values(t).includes(e)}function y(e){if(!e)return!0;for(const t in e)if(Object.hasOwnProperty.call(e,t))return!1;return!0}const m={};function f(e,t){return Object.assign(m,t),e}class g extends Error{constructor(e,t){super(`Magic SDK Error: [${e}] ${t}`),this.code=e,this.rawMessage=t,this.__proto__=Error,Object.setPrototypeOf(this,g.prototype)}}class _{constructor(e,t){this.code=e,this.rawMessage=t,this.message=`Magic SDK Warning: [${e}] ${t}`}log(){console.warn(this.message)}}class v extends Error{constructor(e){super(),this.__proto__=Error;const r=Number(null==e?void 0:e.code);this.rawMessage=(null==e?void 0:e.message)||"Internal error",this.code=p(r)?r:t.InternalError,this.message=`Magic RPC Error: [${this.code}] ${this.rawMessage}`,Object.setPrototypeOf(this,v.prototype)}}function w(){return new g(r.MissingApiKey,"Please provide an API key that you acquired from the Magic developer dashboard.")}function E(){return new g(r.ModalNotReady,"Modal is not ready.")}function A(){return new g(r.MalformedResponse,"Response from the Magic iframe is malformed.")}function M(e){return new g(r.ExtensionNotInitialized,`Extensions must be initialized with a Magic SDK instance before \`Extension.${e}\` can be accessed. Do not invoke \`Extension.${e}\` inside an extension constructor.`)}function I(e){return new g(r.InvalidArgument,`Invalid ${(e=>{const t=e+1,r=t%10,n=t%100;return 1===r&&11!==n?t+"st":2===r&&12!==n?t+"nd":3===r&&13!==n?t+"rd":t+"th"})(e.argument)} argument given to \`${e.procedure}\`.\n Expected: \`${e.expected}\`\n Received: \`${e.received}\``)}function P(){return new _(n.DuplicateIframe,"Duplicate iframes found.")}function b(){return new _(n.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 R(){return new _(n.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.`)}const L=function*(){let e=0;for(;;)e<Number.MAX_SAFE_INTEGER?yield++e:e=0}();function N(){return L.next().value}const O=Symbol("Payload pre-processed by Magic SDK");function S(e){return Object.defineProperty(e,O,{value:!0,enumerable:!1}),e}function x(e){return function(e){return!!e[O]}(e)||(e.jsonrpc=e.jsonrpc??"2.0",e.id=N(),e.method=e.method??"noop",e.params=e.params??[],S(e)),e}function T(e,t=[]){return S({params:t,method:e,jsonrpc:"2.0",id:N()})}class j{constructor(e){e instanceof j?(this._jsonrpc=e.payload.jsonrpc,this._id=e.payload.id,this._result=e.payload.result,this._error=e.payload.error):l(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 null!=this._error}get hasResult(){return void 0!==this._result}get payload(){return{jsonrpc:this._jsonrpc,id:this._id,result:this._result,error:this._error}}}class C extends o{}function D(){const e=new C;return{emitter:e,createChainingEmitterMethod:(t,r)=>(...n)=>(e[t].apply(e,n),r),createBoundEmitterMethod:t=>(...r)=>e[t].apply(e,r)}}const k=Symbol("isPromiEvent");function $(e){return!!e[k]}function Q(e){const t=G(e),{createBoundEmitterMethod:r,createChainingEmitterMethod:n}=D(),s=Symbol("Promise.then"),i=Symbol("Promise.catch"),o=Symbol("Promise.finally"),a=(e,t)=>(...r)=>{const n=t[e].apply(t,r);return d(n)},d=e=>Object.assign(e,{[k]:!0,[s]:e[s]||e.then,[i]:e[i]||e.catch,[o]:e[o]||e.finally,then:a(s,e),catch:a(i,e),finally:a(o,e),on:n("on",e),once:n("once",e),addListener:n("addListener",e),off:n("off",e),removeListener:n("removeListener",e),removeAllListeners:n("removeAllListeners",e),emit:r("emit"),eventNames:r("eventNames"),listeners:r("listeners"),listenerCount:r("listenerCount")}),c=d(t.then(e=>(c.emit("done",e),c.emit("settled"),e),e=>{throw c.emit("error",e),c.emit("settled"),e}));return c}function G(e){return new Promise((t,r)=>{const n=e(t,r);Promise.resolve(n).catch(r)})}class q{constructor(e){this.sdk=e}get transport(){return this.sdk.transport}get overlay(){return this.sdk.overlay}request(e){const t=this.transport.post(this.overlay,s.MAGIC_HANDLE_REQUEST,x(e)),r=Q((e,r)=>{t.then(t=>{if(n(),t.hasError)r(new v(t.payload.error));else{if(!t.hasResult)throw A();e(t.payload.result)}}).catch(e=>{n(),r(e)})}),n=this.transport.on(i.MAGIC_HANDLE_EVENT,t=>{var n;const{response:s}=t.data;if(s.id===e.id&&(null===(n=s.result)||void 0===n?void 0:n.event)){const{event:e,params:t=[]}=s.result;r.emit(e,...t)}});return r}}class H extends q{loginWithMagicLink(t){const{email:r,showUI:n=!0}=t,s=T(e.LoginWithMagicLink,[{email:r,showUI:n}]);return this.request(s)}}class U extends q{getIdToken(t){const r=T(e.GetIdToken,[t]);return this.request(r)}generateIdToken(t){const r=T(e.GenerateIdToken,[t]);return this.request(r)}getMetadata(){const t=T(e.GetMetadata);return this.request(t)}updateEmail(t){const{email:r,showUI:n=!0}=t,s=T(e.UpdateEmail,[{email:r,showUI:n}]);return this.request(s)}isLoggedIn(){const t=T(e.IsLoggedIn);return this.request(t)}logout(){const t=T(e.Logout);return this.request(t)}}const{createBoundEmitterMethod:K,createChainingEmitterMethod:W}=D();class V extends q{constructor(){super(...arguments),this.isMagic=!0,this.on=W("on",this),this.once=W("once",this),this.addListener=W("addListener",this),this.off=W("off",this),this.removeListener=W("removeListener",this),this.removeAllListeners=W("removeAllListeners",this),this.emit=K("emit"),this.eventNames=K("eventNames"),this.listeners=K("listeners"),this.listenerCount=K("listenerCount")}sendAsync(e,t){if(!t)throw I({procedure:"Magic.rpcProvider.sendAsync",argument:1,expected:"function",received:null===t?"null":typeof t});if(Array.isArray(e))this.transport.post(this.overlay,s.MAGIC_HANDLE_REQUEST,e.map(e=>x(e))).then(e=>{t(null,e.map(e=>({...e.payload,error:e.hasError?new v(e.payload.error):null})))});else{const r=x(e);this.transport.post(this.overlay,s.MAGIC_HANDLE_REQUEST,r).then(e=>{t(e.hasError?new v(e.payload.error):null,e.payload)})}}send(e,t){if("string"==typeof e){const r=T(e,Array.isArray(t)?t:[]);return this.request(r)}if(Array.isArray(e)||t)return void this.sendAsync(e,t);const r=b();return r.log(),new j(e).applyError({code:-32603,message:r.rawMessage}).payload}enable(){const e=T("eth_accounts");return this.request(e)}}function z(e,t){return t?new URL(e,t):new URL(e)}class Y extends q{constructor(){return super(void 0),this.isInitialized=!1,this.createJsonRpcRequestPayload=T,this.standardizeJsonRpcRequestPayload=x,new Proxy(this,{get:(e,t,r)=>{if(["request","transport","overlay","sdk"].includes(t)&&!this.isInitialized)throw M(t);return Reflect.get(e,t,r)}})}init(e){this.sdk=e,this.isInitialized=!0}}class B extends Y{}let F=(()=>{class e extends Y{}return e.Internal=B,e})(),J=(()=>{class e{constructor(e,t){if(this.apiKey=e,!e)throw w();"react-native"===m.target&&(null==t?void 0:t.endpoint)&&R().log();const{defaultEndpoint:r,version:n}=m;this.endpoint=z((null==t?void 0:t.endpoint)??r).origin,this.auth=new H(this),this.user=new U(this),this.rpcProvider=new V(this);const s=(null==t?void 0:t.extensions)??[],i={};Array.isArray(s)?s.forEach(e=>{e.init(this),this[e.name]=e,e instanceof F.Internal&&(y(e.config)||(i[e.name]=e.config))}):Object.keys(s).forEach(e=>{s[e].init(this);const t=s[e];this[e]=t,t instanceof F.Internal&&(y(t.config)||(i[s[e].name]=t.config))}),this.encodedQueryParams=a({API_KEY:this.apiKey,DOMAIN_ORIGIN:window.location?window.location.origin:"",ETH_NETWORK:null==t?void 0:t.network,host:z(this.endpoint).host,sdk:m.sdkName,version:n,ext:y(i)?void 0:i})}get transport(){return e.__transports__.has(this.encodedQueryParams)||e.__transports__.set(this.encodedQueryParams,new m.PayloadTransport(this.endpoint,this.encodedQueryParams)),e.__transports__.get(this.encodedQueryParams)}get overlay(){if(!e.__overlays__.has(this.encodedQueryParams)){const t=new m.ViewController(this.transport,this.endpoint,this.encodedQueryParams);e.__overlays__.set(this.encodedQueryParams,t)}return e.__overlays__.get(this.encodedQueryParams)}async preload(){await this.overlay.ready}}return e.__transports__=new Map,e.__overlays__=new Map,e})();class X{constructor(e,t){this.endpoint=e,this.encodedQueryParams=t,this.messageHandlers=new Set,this.init()}async post(e,t,r){var n=this;return G(async function(s){await e.ready;const o=[],a=Array.isArray(r)?r.map(e=>e.id):[];await e.postMessage({msgType:`${t}-${n.encodedQueryParams}`,payload:r});const d=n.on(i.MAGIC_HANDLE_RESPONSE,(c=()=>d(),e=>{const{id:t,response:n}=function(e,t){var r;const n=null===(r=t.data.response)||void 0===r?void 0:r.id,s=function(e,t){return t&&Array.isArray(e)?e.find(e=>e.id===t):e}(e,n);return n&&s?{id:n,response:new j(s).applyResult(t.data.response.result).applyError(t.data.response.error)}:{}}(r,e);t&&n&&Array.isArray(r)&&a.includes(t)?(o.push(n),o.length===r.length&&(c(),s(o))):t&&n&&!Array.isArray(r)&&t===r.id&&(c(),s(n))}));var c})}on(e,t){const r=t.bind(window),n=t=>{t.data.msgType===`${e}-${this.encodedQueryParams}`&&r(t)};return this.messageHandlers.add(n),()=>this.messageHandlers.delete(n)}}class Z{constructor(e,t,r){this.transport=e,this.endpoint=t,this.encodedQueryParams=r,this.ready=this.waitForReady(),this.init&&this.init(),this.listen()}waitForReady(){return new Promise(e=>{this.transport.on(i.MAGIC_OVERLAY_READY,()=>e())})}listen(){this.transport.on(i.MAGIC_HIDE_OVERLAY,()=>{this.hideOverlay()}),this.transport.on(i.MAGIC_SHOW_OVERLAY,()=>{this.showOverlay()})}}export{F as Extension,v as MagicRPCError,g as MagicSDKError,_ as MagicSDKWarning,X as PayloadTransport,J as SDKBase,Z as ViewController,G as createAutoCatchingPromise,P as createDuplicateIframeWarning,M as createExtensionNotInitializedError,I as createInvalidArgumentError,A as createMalformedResponseError,w as createMissingApiKeyError,E as createModalNotReadyError,Q as createPromiEvent,R as createReactNativeEndpointConfigurationWarning,f as createSDK,b as createSynchronousWeb3MethodWarning,z as createURL,a as encodeQueryParameters,N as getPayloadId,y as isEmpty,p as isJsonRpcErrorCode,u as isJsonRpcRequestPayload,l as isJsonRpcResponsePayload,h as isMagicPayloadMethod,$ as isPromiEvent}; | ||
import{MagicPayloadMethod as e,RPCErrorCode as t,SDKErrorCode as r,SDKWarningCode as s,MagicOutgoingWindowMessage as n,MagicIncomingWindowMessage as i}from"@magic-sdk/types";import o from"eventemitter3";function a(e){return btoa(JSON.stringify(e))}function d(e){return void 0===e}function c(e){return function(e){return null===e}(e)||d(e)}function u(e){return!c(e)&&!(d(e.jsonrpc)||d(e.id)||d(e.method)||d(e.params))}function l(e){return!c(e)&&!(d(e.jsonrpc)||d(e.id)||d(e.result)&&d(e.error))}function h(t){return!c(t)&&"string"==typeof t&&Object.values(e).includes(t)}function p(e){return!c(e)&&"number"==typeof e&&Object.values(t).includes(e)}function y(e){if(!e)return!0;for(const t in e)if(Object.hasOwnProperty.call(e,t))return!1;return!0}const m={};function f(e,t){return Object.assign(m,t),e}class g extends Error{constructor(e,t){super(`Magic SDK Error: [${e}] ${t}`),this.code=e,this.rawMessage=t,this.__proto__=Error,Object.setPrototypeOf(this,g.prototype)}}class _{constructor(e,t){this.code=e,this.rawMessage=t,this.message=`Magic SDK Warning: [${e}] ${t}`}log(){console.warn(this.message)}}class v extends Error{constructor(e){super(),this.__proto__=Error;const r=Number(null==e?void 0:e.code);this.rawMessage=(null==e?void 0:e.message)||"Internal error",this.code=p(r)?r:t.InternalError,this.message=`Magic RPC Error: [${this.code}] ${this.rawMessage}`,Object.setPrototypeOf(this,v.prototype)}}function w(){return new g(r.MissingApiKey,"Please provide an API key that you acquired from the Magic developer dashboard.")}function E(){return new g(r.ModalNotReady,"Modal is not ready.")}function A(){return new g(r.MalformedResponse,"Response from the Magic iframe is malformed.")}function M(e){return new g(r.ExtensionNotInitialized,`Extensions must be initialized with a Magic SDK instance before \`Extension.${e}\` can be accessed. Do not invoke \`Extension.${e}\` inside an extension constructor.`)}function I(e){return new g(r.InvalidArgument,`Invalid ${(e=>{const t=e+1,r=t%10,s=t%100;return 1===r&&11!==s?t+"st":2===r&&12!==s?t+"nd":3===r&&13!==s?t+"rd":t+"th"})(e.argument)} argument given to \`${e.procedure}\`.\n Expected: \`${e.expected}\`\n Received: \`${e.received}\``)}function P(){return new _(s.DuplicateIframe,"Duplicate iframes found.")}function b(){return new _(s.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 R(){return new _(s.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.`)}const L=function*(){let e=0;for(;;)e<Number.MAX_SAFE_INTEGER?yield++e:e=0}();function N(){return L.next().value}const O=Symbol("Payload pre-processed by Magic SDK");function S(e){return Object.defineProperty(e,O,{value:!0,enumerable:!1}),e}function x(e){return function(e){return!!e[O]}(e)||(e.jsonrpc=e.jsonrpc??"2.0",e.id=N(),e.method=e.method??"noop",e.params=e.params??[],S(e)),e}function T(e,t=[]){return S({params:t,method:e,jsonrpc:"2.0",id:N()})}class j{constructor(e){e instanceof j?(this._jsonrpc=e.payload.jsonrpc,this._id=e.payload.id,this._result=e.payload.result,this._error=e.payload.error):l(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 null!=this._error}get hasResult(){return void 0!==this._result}get payload(){return{jsonrpc:this._jsonrpc,id:this._id,result:this._result,error:this._error}}}class C extends o{}function D(){const e=new C;return{emitter:e,createChainingEmitterMethod:(t,r)=>(...s)=>(e[t].apply(e,s),r),createBoundEmitterMethod:t=>(...r)=>e[t].apply(e,r)}}const k=Symbol("isPromiEvent");function $(e){return!!e[k]}function Q(e){const t=G(e),{createBoundEmitterMethod:r,createChainingEmitterMethod:s}=D(),n=Symbol("Promise.then"),i=Symbol("Promise.catch"),o=Symbol("Promise.finally"),a=(e,t)=>(...r)=>{const s=t[e].apply(t,r);return d(s)},d=e=>Object.assign(e,{[k]:!0,[n]:e[n]||e.then,[i]:e[i]||e.catch,[o]:e[o]||e.finally,then:a(n,e),catch:a(i,e),finally:a(o,e),on:s("on",e),once:s("once",e),addListener:s("addListener",e),off:s("off",e),removeListener:s("removeListener",e),removeAllListeners:s("removeAllListeners",e),emit:r("emit"),eventNames:r("eventNames"),listeners:r("listeners"),listenerCount:r("listenerCount")}),c=d(t.then(e=>(c.emit("done",e),c.emit("settled"),e),e=>{throw c.emit("error",e),c.emit("settled"),e}));return c}function G(e){return new Promise((t,r)=>{const s=e(t,r);Promise.resolve(s).catch(r)})}class q{constructor(e){this.sdk=e}get transport(){return this.sdk.transport}get overlay(){return this.sdk.overlay}request(e){const t=this.transport.post(this.overlay,n.MAGIC_HANDLE_REQUEST,x(e)),r=Q((e,r)=>{t.then(t=>{if(s(),t.hasError)r(new v(t.payload.error));else{if(!t.hasResult)throw A();e(t.payload.result)}}).catch(e=>{s(),r(e)})}),s=this.transport.on(i.MAGIC_HANDLE_EVENT,t=>{var s;const{response:n}=t.data;if(n.id===e.id&&(null===(s=n.result)||void 0===s?void 0:s.event)){const{event:e,params:t=[]}=n.result;r.emit(e,...t)}});return r}}class H extends q{loginWithMagicLink(t){const{email:r,showUI:s=!0}=t,n=T(e.LoginWithMagicLink,[{email:r,showUI:s}]);return this.request(n)}}class U extends q{getIdToken(t){const r=T(e.GetIdToken,[t]);return this.request(r)}generateIdToken(t){const r=T(e.GenerateIdToken,[t]);return this.request(r)}getMetadata(){const t=T(e.GetMetadata);return this.request(t)}updateEmail(t){const{email:r,showUI:s=!0}=t,n=T(e.UpdateEmail,[{email:r,showUI:s}]);return this.request(n)}isLoggedIn(){const t=T(e.IsLoggedIn);return this.request(t)}logout(){const t=T(e.Logout);return this.request(t)}}const{createBoundEmitterMethod:K,createChainingEmitterMethod:W}=D();class V extends q{constructor(){super(...arguments),this.isMagic=!0,this.on=W("on",this),this.once=W("once",this),this.addListener=W("addListener",this),this.off=W("off",this),this.removeListener=W("removeListener",this),this.removeAllListeners=W("removeAllListeners",this),this.emit=K("emit"),this.eventNames=K("eventNames"),this.listeners=K("listeners"),this.listenerCount=K("listenerCount")}sendAsync(e,t){if(!t)throw I({procedure:"Magic.rpcProvider.sendAsync",argument:1,expected:"function",received:null===t?"null":typeof t});if(Array.isArray(e))this.transport.post(this.overlay,n.MAGIC_HANDLE_REQUEST,e.map(e=>x(e))).then(e=>{t(null,e.map(e=>({...e.payload,error:e.hasError?new v(e.payload.error):null})))});else{const r=x(e);this.transport.post(this.overlay,n.MAGIC_HANDLE_REQUEST,r).then(e=>{t(e.hasError?new v(e.payload.error):null,e.payload)})}}send(e,t){if("string"==typeof e){const r=T(e,Array.isArray(t)?t:[]);return this.request(r)}if(Array.isArray(e)||t)return void this.sendAsync(e,t);const r=b();return r.log(),new j(e).applyError({code:-32603,message:r.rawMessage}).payload}enable(){const e=T("eth_accounts");return this.request(e)}}function z(e,t){return t?new URL(e,t):new URL(e)}class Y extends q{constructor(){return super(void 0),this.isInitialized=!1,this.createJsonRpcRequestPayload=T,this.standardizeJsonRpcRequestPayload=x,new Proxy(this,{get:(e,t,r)=>{if(["request","transport","overlay","sdk"].includes(t)&&!this.isInitialized)throw M(t);return Reflect.get(e,t,r)}})}init(e){this.sdk=e,this.isInitialized=!0}}class B extends Y{}B.Internal=class extends Y{};class F{constructor(e,t){if(this.apiKey=e,!e)throw w();"react-native"===m.target&&(null==t?void 0:t.endpoint)&&R().log();const{defaultEndpoint:r,version:s}=m;this.endpoint=z((null==t?void 0:t.endpoint)??r).origin,this.auth=new H(this),this.user=new U(this),this.rpcProvider=new V(this);const n=(null==t?void 0:t.extensions)??[],i={};Array.isArray(n)?n.forEach(e=>{e.init(this),this[e.name]=e,e instanceof B.Internal&&(y(e.config)||(i[e.name]=e.config))}):Object.keys(n).forEach(e=>{n[e].init(this);const t=n[e];this[e]=t,t instanceof B.Internal&&(y(t.config)||(i[n[e].name]=t.config))}),this.encodedQueryParams=a({API_KEY:this.apiKey,DOMAIN_ORIGIN:window.location?window.location.origin:"",ETH_NETWORK:null==t?void 0:t.network,host:z(this.endpoint).host,sdk:m.sdkName,version:s,ext:y(i)?void 0:i})}get transport(){return F.__transports__.has(this.encodedQueryParams)||F.__transports__.set(this.encodedQueryParams,new m.PayloadTransport(this.endpoint,this.encodedQueryParams)),F.__transports__.get(this.encodedQueryParams)}get overlay(){if(!F.__overlays__.has(this.encodedQueryParams)){const e=new m.ViewController(this.transport,this.endpoint,this.encodedQueryParams);F.__overlays__.set(this.encodedQueryParams,e)}return F.__overlays__.get(this.encodedQueryParams)}async preload(){await this.overlay.ready}}F.__transports__=new Map,F.__overlays__=new Map;class J{constructor(e,t){this.endpoint=e,this.encodedQueryParams=t,this.messageHandlers=new Set,this.init()}async post(e,t,r){var s=this;return G(async function(n){await e.ready;const o=[],a=Array.isArray(r)?r.map(e=>e.id):[];await e.postMessage({msgType:`${t}-${s.encodedQueryParams}`,payload:r});const d=s.on(i.MAGIC_HANDLE_RESPONSE,(c=()=>d(),e=>{const{id:t,response:s}=function(e,t){var r;const s=null===(r=t.data.response)||void 0===r?void 0:r.id,n=function(e,t){return t&&Array.isArray(e)?e.find(e=>e.id===t):e}(e,s);return s&&n?{id:s,response:new j(n).applyResult(t.data.response.result).applyError(t.data.response.error)}:{}}(r,e);t&&s&&Array.isArray(r)&&a.includes(t)?(o.push(s),o.length===r.length&&(c(),n(o))):t&&s&&!Array.isArray(r)&&t===r.id&&(c(),n(s))}));var c})}on(e,t){const r=t.bind(window),s=t=>{t.data.msgType===`${e}-${this.encodedQueryParams}`&&r(t)};return this.messageHandlers.add(s),()=>this.messageHandlers.delete(s)}}class X{constructor(e,t,r){this.transport=e,this.endpoint=t,this.encodedQueryParams=r,this.ready=this.waitForReady(),this.init&&this.init(),this.listen()}waitForReady(){return new Promise(e=>{this.transport.on(i.MAGIC_OVERLAY_READY,()=>e())})}listen(){this.transport.on(i.MAGIC_HIDE_OVERLAY,()=>{this.hideOverlay()}),this.transport.on(i.MAGIC_SHOW_OVERLAY,()=>{this.showOverlay()})}}export{B as Extension,v as MagicRPCError,g as MagicSDKError,_ as MagicSDKWarning,J as PayloadTransport,F as SDKBase,X as ViewController,G as createAutoCatchingPromise,P as createDuplicateIframeWarning,M as createExtensionNotInitializedError,I as createInvalidArgumentError,A as createMalformedResponseError,w as createMissingApiKeyError,E as createModalNotReadyError,Q as createPromiEvent,R as createReactNativeEndpointConfigurationWarning,f as createSDK,b as createSynchronousWeb3MethodWarning,z as createURL,a as encodeQueryParameters,N as getPayloadId,y as isEmpty,p as isJsonRpcErrorCode,u as isJsonRpcRequestPayload,l as isJsonRpcResponsePayload,h as isMagicPayloadMethod,$ as isPromiEvent}; | ||
//# sourceMappingURL=index.modern.js.map |
{ | ||
"name": "@magic-sdk/provider", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Core business logic for Magic SDK packages.", | ||
@@ -25,3 +25,3 @@ "author": "Fortmatic <team@fortmatic.com> (https://fortmatic.com/)", | ||
"dependencies": { | ||
"@magic-sdk/types": "^1.0.0", | ||
"@magic-sdk/types": "^1.0.1", | ||
"eventemitter3": "^4.0.4" | ||
@@ -61,3 +61,3 @@ }, | ||
}, | ||
"gitHead": "967d0bd51c08bb0ccb3a7d2d92a1bdd3e1f70f8f" | ||
"gitHead": "6dd13cb1364f59dc3af4cc2ec724c97c2e14e006" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
245026
Updated@magic-sdk/types@^1.0.1