magic-sdk
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -15,2 +15,16 @@ ## Upcoming Changes | ||
## `2.0.2` - 06/12/2020 | ||
#### Changed | ||
- Update dependencies. | ||
- Circle CI tag in readme is broken after namechange from MagicHQ to MagicLabs | ||
## `2.0.1` - 06/11/2020 | ||
#### Changed | ||
- Update dependencies. | ||
## `2.0.0` - 06/02/2020 | ||
@@ -17,0 +31,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Magic=e()}(this,function(){function t(){return(t=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function e(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function n(t,e){return t(e={exports:{}},e.exports),e.exports}var o,i,a,s,u,c,l;n(function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(t,e,r,n){var o=Object.create((e&&e.prototype instanceof l?e:l).prototype),i=new b(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=_(a,r);if(s){if(s===c)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var l=u(t,e,r);if("normal"===l.type){if(n=r.done?"completed":"suspendedYield",l.arg===c)continue;return{value:l.arg,done:r.done}}"throw"===l.type&&(n="completed",r.method="throw",r.arg=l.arg)}}}(t,r,i),o}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var c={};function l(){}function f(){}function d(){}var h={};h[o]=function(){return this};var p=Object.getPrototypeOf,y=p&&p(p(A([])));y&&y!==e&&r.call(y,o)&&(h=y);var v=d.prototype=l.prototype=Object.create(h);function m(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function g(t,e){var n;this._invoke=function(o,i){function a(){return new e(function(n,a){!function n(o,i,a,s){var c=u(t[o],t,i);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==typeof f&&r.call(f,"__await")?e.resolve(f.__await).then(function(t){n("next",t,a,s)},function(t){n("throw",t,a,s)}):e.resolve(f).then(function(t){l.value=t,a(l)},function(t){return n("throw",t,a,s)})}s(c.arg)}(o,i,n,a)})}return n=n?n.then(a,a):a()}}function _(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,_(t,e),"throw"===e.method))return c;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return c}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,c;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,c):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,c)}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function w(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function b(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function A(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:I}}function I(){return{value:void 0,done:!0}}return f.prototype=v.constructor=d,d.constructor=f,d[a]=f.displayName="GeneratorFunction",t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===f||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,a in t||(t[a]="GeneratorFunction")),t.prototype=Object.create(v),t},t.awrap=function(t){return{__await:t}},m(g.prototype),g.prototype[i]=function(){return this},t.AsyncIterator=g,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new g(s(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then(function(t){return t.done?t.value:a.next()})},m(v),v[a]="Generator",v[o]=function(){return this},v.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=A,b.prototype={constructor:b,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(w),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(s&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,c):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),c},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),w(r),c}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;w(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:A(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),c}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}),function(t){t.LoginWithMagicLink="magic_auth_login_with_magic_link",t.GetIdToken="magic_auth_get_id_token",t.GenerateIdToken="magic_auth_generate_id_token",t.GetMetadata="magic_auth_get_metadata",t.IsLoggedIn="magic_auth_is_logged_in",t.Logout="magic_auth_logout",t.UpdateEmail="magic_auth_update_email"}(o||(o={})),function(t){t.MAGIC_HANDLE_RESPONSE="MAGIC_HANDLE_RESPONSE",t.MAGIC_OVERLAY_READY="MAGIC_OVERLAY_READY",t.MAGIC_SHOW_OVERLAY="MAGIC_SHOW_OVERLAY",t.MAGIC_HIDE_OVERLAY="MAGIC_HIDE_OVERLAY",t.MAGIC_HANDLE_EVENT="MAGIC_HANDLE_EVENT"}(i||(i={})),function(t){t.MAGIC_HANDLE_REQUEST="MAGIC_HANDLE_REQUEST"}(a||(a={})),function(t){t.MissingApiKey="MISSING_API_KEY",t.ModalNotReady="MODAL_NOT_READY",t.MalformedResponse="MALFORMED_RESPONSE",t.InvalidArgument="INVALID_ARGUMENT",t.ExtensionNotInitialized="EXTENSION_NOT_INITIALIZED"}(s||(s={})),function(t){t.SyncWeb3Method="SYNC_WEB3_METHOD",t.DuplicateIframe="DUPLICATE_IFRAME",t.ReactNativeEndpointConfiguration="REACT_NATIVE_ENDPOINT_CONFIGURATION"}(u||(u={})),function(t){t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError",t[t.MagicLinkFailedVerification=-1e4]="MagicLinkFailedVerification",t[t.MagicLinkExpired=-10001]="MagicLinkExpired",t[t.MagicLinkRateLimited=-10002]="MagicLinkRateLimited",t[t.UserAlreadyLoggedIn=-10003]="UserAlreadyLoggedIn",t[t.UpdateEmailFailed=-10004]="UpdateEmailFailed"}(c||(c={})),function(t){t.Harmony="HARMONY"}(l||(l={}));var f={__proto__:null,get EthChainType(){return l},get MagicIncomingWindowMessage(){return i},get MagicOutgoingWindowMessage(){return a},get MagicPayloadMethod(){return o},get RPCErrorCode(){return c},get SDKErrorCode(){return s},get SDKWarningCode(){return u}},d=n(function(t){var e=Object.prototype.hasOwnProperty,r="~";function n(){}function o(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function i(t,e,n,i,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new o(n,i||t,a),u=r?r+e:e;return t._events[u]?t._events[u].fn?t._events[u]=[t._events[u],s]:t._events[u].push(s):(t._events[u]=s,t._eventsCount++),t}function a(t,e){0==--t._eventsCount?t._events=new n:delete t._events[e]}function s(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),s.prototype.eventNames=function(){var t,n,o=[];if(0===this._eventsCount)return o;for(n in t=this._events)e.call(t,n)&&o.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(t)):o},s.prototype.listeners=function(t){var e=this._events[r?r+t:t];if(!e)return[];if(e.fn)return[e.fn];for(var n=0,o=e.length,i=new Array(o);n<o;n++)i[n]=e[n].fn;return i},s.prototype.listenerCount=function(t){var e=this._events[r?r+t:t];return e?e.fn?1:e.length:0},s.prototype.emit=function(t,e,n,o,i,a){var s=r?r+t:t;if(!this._events[s])return!1;var u,c,l=this._events[s],f=arguments.length;if(l.fn){switch(l.once&&this.removeListener(t,l.fn,void 0,!0),f){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,e),!0;case 3:return l.fn.call(l.context,e,n),!0;case 4:return l.fn.call(l.context,e,n,o),!0;case 5:return l.fn.call(l.context,e,n,o,i),!0;case 6:return l.fn.call(l.context,e,n,o,i,a),!0}for(c=1,u=new Array(f-1);c<f;c++)u[c-1]=arguments[c];l.fn.apply(l.context,u)}else{var d,h=l.length;for(c=0;c<h;c++)switch(l[c].once&&this.removeListener(t,l[c].fn,void 0,!0),f){case 1:l[c].fn.call(l[c].context);break;case 2:l[c].fn.call(l[c].context,e);break;case 3:l[c].fn.call(l[c].context,e,n);break;case 4:l[c].fn.call(l[c].context,e,n,o);break;default:if(!u)for(d=1,u=new Array(f-1);d<f;d++)u[d-1]=arguments[d];l[c].fn.apply(l[c].context,u)}}return!0},s.prototype.on=function(t,e,r){return i(this,t,e,r,!1)},s.prototype.once=function(t,e,r){return i(this,t,e,r,!0)},s.prototype.removeListener=function(t,e,n,o){var i=r?r+t:t;if(!this._events[i])return this;if(!e)return a(this,i),this;var s=this._events[i];if(s.fn)s.fn!==e||o&&!s.once||n&&s.context!==n||a(this,i);else{for(var u=0,c=[],l=s.length;u<l;u++)(s[u].fn!==e||o&&!s[u].once||n&&s[u].context!==n)&&c.push(s[u]);c.length?this._events[i]=1===c.length?c[0]:c:a(this,i)}return this},s.prototype.removeAllListeners=function(t){var e;return t?this._events[e=r?r+t:t]&&a(this,e):(this._events=new n,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=r,s.EventEmitter=s,t.exports=s});function h(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function p(t,e,r){return e&&h(t.prototype,e),r&&h(t,r),t}function y(){return(y=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function v(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function m(t){return(m=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function g(t,e){return(g=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function _(){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(t){return!1}}function E(t,e,r){return(E=_()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&g(o,r.prototype),o}).apply(null,arguments)}function w(t){var e="function"==typeof Map?new Map:void 0;return(w=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return E(t,arguments,m(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),g(r,t)})(t)}function b(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function A(t){return void 0===t}function I(t){return function(t){return null===t}(t)||A(t)}function L(t){if(!t)return!0;for(var e in t)if(Object.hasOwnProperty.call(t,e))return!1;return!0}var O={},M=function(t){function e(r,n){var o;return(o=t.call(this,"Magic SDK Error: ["+r+"] "+n)||this).code=r,o.rawMessage=n,o.__proto__=Error,Object.setPrototypeOf(b(o),e.prototype),o}return v(e,t),e}(w(Error)),P=function(){function t(t,e){this.code=t,this.rawMessage=e,this.message="Magic SDK Warning: ["+t+"] "+e}return t.prototype.log=function(){console.warn(this.message)},t}(),x=function(t){function e(r){var n;(n=t.call(this)||this).__proto__=Error;var o=Number(null==r?void 0:r.code);return n.rawMessage=(null==r?void 0:r.message)||"Internal error",n.code=function(t){return!I(t)&&"number"==typeof t&&Object.values(c).includes(t)}(o)?o:c.InternalError,n.message="Magic RPC Error: ["+n.code+"] "+n.rawMessage,Object.setPrototypeOf(b(n),e.prototype),n}return v(e,t),e}(w(Error)),R=regeneratorRuntime.mark(N);function N(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:t=0;case 1:if(!(t<Number.MAX_SAFE_INTEGER)){e.next=7;break}return e.next=5,++t;case 5:e.next=8;break;case 7:t=0;case 8:e.next=1;break;case 10:case"end":return e.stop()}},R)}var S=N();function j(){return S.next().value}var k=Symbol("Payload pre-processed by Magic SDK");function C(t){return Object.defineProperty(t,k,{value:!0,enumerable:!1}),t}function T(t){var e,r,n;return function(t){return!!t[k]}(t)||(t.jsonrpc=null!=(e=t.jsonrpc)?e:"2.0",t.id=j(),t.method=null!=(r=t.method)?r:"noop",t.params=null!=(n=t.params)?n:[],C(t)),t}function D(t,e){return void 0===e&&(e=[]),C({params:e,method:t,jsonrpc:"2.0",id:j()})}var G=function(){function t(e){e instanceof t?(this._jsonrpc=e.payload.jsonrpc,this._id=e.payload.id,this._result=e.payload.result,this._error=e.payload.error):function(t){return!I(t)&&!(A(t.jsonrpc)||A(t.id)||A(t.result)&&A(t.error))}(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)}var e=t.prototype;return e.applyError=function(t){return this._error=t,this},e.applyResult=function(t){return this._result=t,this},p(t,[{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}}}]),t}(),H=function(t){function e(){return t.apply(this,arguments)||this}return v(e,t),e}(d);function U(){var t=new H;return{emitter:t,createChainingEmitterMethod:function(e,r){return function(){return t[e].apply(t,[].slice.call(arguments)),r}},createBoundEmitterMethod:function(e){return function(){return t[e].apply(t,[].slice.call(arguments))}}}}var F=Symbol("isPromiEvent");function Q(t){return new Promise(function(e,r){var n=t(e,r);Promise.resolve(n).catch(r)})}var V=function(){function t(t){this.sdk=t}return t.prototype.request=function(t){var e=this.transport.post(this.overlay,a.MAGIC_HANDLE_REQUEST,T(t)),r=function(t){var e=Q(t),r=U(),n=r.createBoundEmitterMethod,o=r.createChainingEmitterMethod,i=Symbol("Promise.then"),a=Symbol("Promise.catch"),s=Symbol("Promise.finally"),u=function(t,e){return function(){var r=e[t].apply(e,[].slice.call(arguments));return c(r)}},c=function(t){var e;return Object.assign(t,((e={})[F]=!0,e[i]=t[i]||t.then,e[a]=t[a]||t.catch,e[s]=t[s]||t.finally,e.then=u(i,t),e.catch=u(a,t),e.finally=u(s,t),e.on=o("on",t),e.once=o("once",t),e.addListener=o("addListener",t),e.off=o("off",t),e.removeListener=o("removeListener",t),e.removeAllListeners=o("removeAllListeners",t),e.emit=n("emit"),e.eventNames=n("eventNames"),e.listeners=n("listeners"),e.listenerCount=n("listenerCount"),e))},l=c(e.then(function(t){return l.emit("done",t),l.emit("settled"),t},function(t){throw l.emit("error",t),l.emit("settled"),t}));return l}(function(t,r){e.then(function(e){if(n(),e.hasError)r(new x(e.payload.error));else{if(!e.hasResult)throw new M(s.MalformedResponse,"Response from the Magic iframe is malformed.");t(e.payload.result)}}).catch(function(t){n(),r(t)})}),n=this.transport.on(i.MAGIC_HANDLE_EVENT,function(e){var n,o=e.data.response;if(o.id===t.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},p(t,[{key:"transport",get:function(){return this.sdk.transport}},{key:"overlay",get:function(){return this.sdk.overlay}}]),t}(),W=function(t){function e(){return t.apply(this,arguments)||this}return v(e,t),e.prototype.loginWithMagicLink=function(t){var e=t.showUI,r=D(o.LoginWithMagicLink,[{email:t.email,showUI:void 0===e||e}]);return this.request(r)},e}(V),Y=function(t){function e(){return t.apply(this,arguments)||this}v(e,t);var r=e.prototype;return r.getIdToken=function(t){var e=D(o.GetIdToken,[t]);return this.request(e)},r.generateIdToken=function(t){var e=D(o.GenerateIdToken,[t]);return this.request(e)},r.getMetadata=function(){var t=D(o.GetMetadata);return this.request(t)},r.updateEmail=function(t){var e=t.showUI,r=D(o.UpdateEmail,[{email:t.email,showUI:void 0===e||e}]);return this.request(r)},r.isLoggedIn=function(){var t=D(o.IsLoggedIn);return this.request(t)},r.logout=function(){var t=D(o.Logout);return this.request(t)},e}(V),q=U(),K=q.createBoundEmitterMethod,z=q.createChainingEmitterMethod,B=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).isMagic=!0,e.on=z("on",b(e)),e.once=z("once",b(e)),e.addListener=z("addListener",b(e)),e.off=z("off",b(e)),e.removeListener=z("removeListener",b(e)),e.removeAllListeners=z("removeAllListeners",b(e)),e.emit=K("emit"),e.eventNames=K("eventNames"),e.listeners=K("listeners"),e.listenerCount=K("listenerCount"),e}v(e,t);var r=e.prototype;return r.sendAsync=function(t,e){if(!e)throw function(t){var e,r,n;return new M(s.InvalidArgument,"Invalid "+(n=(e=t.argument+1)%100,(1==(r=e%10)&&11!==n?e+"st":2===r&&12!==n?e+"nd":3===r&&13!==n?e+"rd":e+"th")+" argument given to `")+t.procedure+"`.\n Expected: `"+t.expected+"`\n Received: `"+t.received+"`")}({procedure:"Magic.rpcProvider.sendAsync",argument:1,expected:"function",received:null===e?"null":typeof e});if(Array.isArray(t))this.transport.post(this.overlay,a.MAGIC_HANDLE_REQUEST,t.map(function(t){return T(t)})).then(function(t){e(null,t.map(function(t){return y({},t.payload,{error:t.hasError?new x(t.payload.error):null})}))});else{var r=T(t);this.transport.post(this.overlay,a.MAGIC_HANDLE_REQUEST,r).then(function(t){e(t.hasError?new x(t.payload.error):null,t.payload)})}},r.send=function(t,e){if("string"==typeof t){var r=D(t,Array.isArray(e)?e:[]);return this.request(r)}if(!Array.isArray(t)&&!e){var n=new P(u.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.");return n.log(),new G(t).applyError({code:-32603,message:n.rawMessage}).payload}this.sendAsync(t,e)},r.enable=function(){var t=D("eth_accounts");return this.request(t)},e}(V);function J(t,e){return e?new URL(t,e):new URL(t)}var X=function(t){function e(){var e;return(e=t.call(this,void 0)||this).isInitialized=!1,e.createJsonRpcRequestPayload=D,e.standardizeJsonRpcRequestPayload=T,new Proxy(b(e),{get:function(t,r,n){if(["request","transport","overlay","sdk"].includes(r)&&!e.isInitialized)throw function(t){return new M(s.ExtensionNotInitialized,"Extensions must be initialized with a Magic SDK instance before `Extension."+t+"` can be accessed. Do not invoke `Extension."+t+"` inside an extension constructor.")}(r);return Reflect.get(t,r,n)}})||b(e)}return v(e,t),e.prototype.init=function(t){this.sdk=t,this.isInitialized=!0},e}(V),Z=function(t){function e(){return t.apply(this,arguments)||this}return v(e,t),e}(X),$=function(t){function e(){return t.apply(this,arguments)||this}return v(e,t),e}(X);$.Internal=Z;var tt=function(){function t(t,e){var r,n,o=this;if(this.apiKey=t,!t)throw new M(s.MissingApiKey,"Please provide an API key that you acquired from the Magic developer dashboard.");"react-native"===O.target&&(null==e?void 0:e.endpoint)&&new P(u.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 `"+O.defaultEndpoint+"`. Changing this default behavior will lead to unexpected results and potentially security-threatening bugs.").log();var i=O.version;this.endpoint=J(null!=(r=null==e?void 0:e.endpoint)?r:O.defaultEndpoint).origin,this.auth=new W(this),this.user=new Y(this),this.rpcProvider=new B(this);var a=null!=(n=null==e?void 0:e.extensions)?n:[],c={};Array.isArray(a)?a.forEach(function(t){t.init(o),o[t.name]=t,t instanceof $.Internal&&(L(t.config)||(c[t.name]=t.config))}):Object.keys(a).forEach(function(t){a[t].init(o);var e=a[t];o[t]=e,e instanceof $.Internal&&(L(e.config)||(c[a[t].name]=e.config))}),this.encodedQueryParams=function(t){return btoa(JSON.stringify(t))}({API_KEY:this.apiKey,DOMAIN_ORIGIN:window.location?window.location.origin:"",ETH_NETWORK:null==e?void 0:e.network,host:J(this.endpoint).host,sdk:O.sdkName,version:i,ext:L(c)?void 0:c})}return t.prototype.preload=function(){try{return Promise.resolve(this.overlay.ready).then(function(){})}catch(t){return Promise.reject(t)}},p(t,[{key:"transport",get:function(){return t.__transports__.has(this.encodedQueryParams)||t.__transports__.set(this.encodedQueryParams,new O.PayloadTransport(this.endpoint,this.encodedQueryParams)),t.__transports__.get(this.encodedQueryParams)}},{key:"overlay",get:function(){if(!t.__overlays__.has(this.encodedQueryParams)){var e=new O.ViewController(this.transport,this.endpoint,this.encodedQueryParams);t.__overlays__.set(this.encodedQueryParams,e)}return t.__overlays__.get(this.encodedQueryParams)}}]),t}();tt.__transports__=new Map,tt.__overlays__=new Map;var et,rt=function(){function t(t,e){this.endpoint=t,this.encodedQueryParams=e,this.messageHandlers=new Set,this.init()}var e=t.prototype;return e.post=function(t,e,r){try{var n=this;return Promise.resolve(Q(function(o){try{return Promise.resolve(t.ready).then(function(){var a=[],s=Array.isArray(r)?r.map(function(t){return t.id}):[];return Promise.resolve(t.postMessage({msgType:e+"-"+n.encodedQueryParams,payload:r})).then(function(){var t,e=n.on(i.MAGIC_HANDLE_RESPONSE,(t=function(){return e()},function(e){var n=function(t,e){var r,n=null===(r=e.data.response)||void 0===r?void 0:r.id,o=function(t,e){return e&&Array.isArray(t)?t.find(function(t){return t.id===e}):t}(t,n);return n&&o?{id:n,response:new G(o).applyResult(e.data.response.result).applyError(e.data.response.error)}:{}}(r,e),i=n.id,u=n.response;i&&u&&Array.isArray(r)&&s.includes(i)?(a.push(u),a.length===r.length&&(t(),o(a))):i&&u&&!Array.isArray(r)&&i===r.id&&(t(),o(u))}))})})}catch(t){return Promise.reject(t)}}))}catch(t){return Promise.reject(t)}},e.on=function(t,e){var r=this,n=e.bind(window),o=function(e){e.data.msgType===t+"-"+r.encodedQueryParams&&n(e)};return this.messageHandlers.add(o),function(){return r.messageHandlers.delete(o)}},t}(),nt=function(){function t(t,e,r){this.transport=t,this.endpoint=e,this.encodedQueryParams=r,this.ready=this.waitForReady(),this.init&&this.init(),this.listen()}var e=t.prototype;return e.waitForReady=function(){var t=this;return new Promise(function(e){t.transport.on(i.MAGIC_OVERLAY_READY,function(){return e()})})},e.listen=function(){var t=this;this.transport.on(i.MAGIC_HIDE_OVERLAY,function(){t.hideOverlay()}),this.transport.on(i.MAGIC_SHOW_OVERLAY,function(){t.showOverlay()})},t}(),ot={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",zIndex:"2147483647"},it=function(t){function r(){return t.apply(this,arguments)||this}e(r,t);var n=r.prototype;return n.init=function(){this.iframe=this.createIframe()},n.createIframe=function(){var t=this;return new Promise(function(e){var r=function(){if(n=encodeURIComponent(t.encodedQueryParams),o=[].slice.call(document.querySelectorAll(".magic-iframe")),Boolean(o.find(function(t){return t.src.includes(n)})))new P(u.DuplicateIframe,"Duplicate iframes found.").log();else{var r=document.createElement("iframe");r.classList.add("magic-iframe"),r.dataset.magicIframeLabel=J(t.endpoint).host,r.src=J("/send?params="+encodeURIComponent(t.encodedQueryParams),t.endpoint).href,function(t){for(var e=0,r=Object.entries(ot);e<r.length;e++){var n=r[e];t.style[n[0]]=n[1]}}(r),document.body.appendChild(r),e(r)}var n,o};["loaded","interactive","complete"].includes(document.readyState)?r():window.addEventListener("load",r,!1)})},n.showOverlay=function(){try{return Promise.resolve(this.iframe).then(function(t){t.style.display="block"})}catch(t){return Promise.reject(t)}},n.hideOverlay=function(){try{return Promise.resolve(this.iframe).then(function(t){t.style.display="none"})}catch(t){return Promise.reject(t)}},n.postMessage=function(t){try{return Promise.resolve(this.iframe).then(function(e){if(!e||!e.contentWindow)throw new M(s.ModalNotReady,"Modal is not ready.");e.contentWindow.postMessage(t,"*")})}catch(t){return Promise.reject(t)}},r}(nt),at=(et=tt,Object.assign(O,{target:"web",sdkName:"magic-sdk",version:"2.0.1",defaultEndpoint:"https://auth.magic.link/",ViewController:it,PayloadTransport:function(t){function n(){return t.apply(this,arguments)||this}return e(n,t),n.prototype.init=function(){var t=this;window.addEventListener("message",function(e){if(e.origin===t.endpoint&&e.data&&e.data.msgType&&t.messageHandlers.size){var n;e.data.response=null!=(n=e.data.response)?n:{};for(var o,i=function(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return r(t,void 0);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,void 0):void 0}}(t))){n&&(t=n);var o=0;return function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=t[Symbol.iterator]()).next.bind(n)}(t.messageHandlers.values());!(o=i()).done;)(0,o.value)(e)}})},n}(rt)}),et);return Object.assign(at,t({},f,{SDKError:M,SDKWarning:P,RPCError:x,Extension:$})),at}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Magic=e()}(this,function(){function t(){return(t=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function e(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function n(t,e){return t(e={exports:{}},e.exports),e.exports}var o,i,a,s,u,c,l;n(function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(t,e,r,n){var o=Object.create((e&&e.prototype instanceof l?e:l).prototype),i=new b(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=_(a,r);if(s){if(s===c)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var l=u(t,e,r);if("normal"===l.type){if(n=r.done?"completed":"suspendedYield",l.arg===c)continue;return{value:l.arg,done:r.done}}"throw"===l.type&&(n="completed",r.method="throw",r.arg=l.arg)}}}(t,r,i),o}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var c={};function l(){}function f(){}function d(){}var h={};h[o]=function(){return this};var p=Object.getPrototypeOf,y=p&&p(p(A([])));y&&y!==e&&r.call(y,o)&&(h=y);var v=d.prototype=l.prototype=Object.create(h);function m(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function g(t,e){var n;this._invoke=function(o,i){function a(){return new e(function(n,a){!function n(o,i,a,s){var c=u(t[o],t,i);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==typeof f&&r.call(f,"__await")?e.resolve(f.__await).then(function(t){n("next",t,a,s)},function(t){n("throw",t,a,s)}):e.resolve(f).then(function(t){l.value=t,a(l)},function(t){return n("throw",t,a,s)})}s(c.arg)}(o,i,n,a)})}return n=n?n.then(a,a):a()}}function _(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,_(t,e),"throw"===e.method))return c;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return c}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,c;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,c):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,c)}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function w(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function b(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function A(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:I}}function I(){return{value:void 0,done:!0}}return f.prototype=v.constructor=d,d.constructor=f,d[a]=f.displayName="GeneratorFunction",t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===f||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,a in t||(t[a]="GeneratorFunction")),t.prototype=Object.create(v),t},t.awrap=function(t){return{__await:t}},m(g.prototype),g.prototype[i]=function(){return this},t.AsyncIterator=g,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new g(s(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then(function(t){return t.done?t.value:a.next()})},m(v),v[a]="Generator",v[o]=function(){return this},v.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=A,b.prototype={constructor:b,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(w),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(s&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,c):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),c},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),w(r),c}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;w(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:A(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),c}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}),function(t){t.LoginWithMagicLink="magic_auth_login_with_magic_link",t.GetIdToken="magic_auth_get_id_token",t.GenerateIdToken="magic_auth_generate_id_token",t.GetMetadata="magic_auth_get_metadata",t.IsLoggedIn="magic_auth_is_logged_in",t.Logout="magic_auth_logout",t.UpdateEmail="magic_auth_update_email"}(o||(o={})),function(t){t.MAGIC_HANDLE_RESPONSE="MAGIC_HANDLE_RESPONSE",t.MAGIC_OVERLAY_READY="MAGIC_OVERLAY_READY",t.MAGIC_SHOW_OVERLAY="MAGIC_SHOW_OVERLAY",t.MAGIC_HIDE_OVERLAY="MAGIC_HIDE_OVERLAY",t.MAGIC_HANDLE_EVENT="MAGIC_HANDLE_EVENT"}(i||(i={})),function(t){t.MAGIC_HANDLE_REQUEST="MAGIC_HANDLE_REQUEST"}(a||(a={})),function(t){t.MissingApiKey="MISSING_API_KEY",t.ModalNotReady="MODAL_NOT_READY",t.MalformedResponse="MALFORMED_RESPONSE",t.InvalidArgument="INVALID_ARGUMENT",t.ExtensionNotInitialized="EXTENSION_NOT_INITIALIZED"}(s||(s={})),function(t){t.SyncWeb3Method="SYNC_WEB3_METHOD",t.DuplicateIframe="DUPLICATE_IFRAME",t.ReactNativeEndpointConfiguration="REACT_NATIVE_ENDPOINT_CONFIGURATION"}(u||(u={})),function(t){t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError",t[t.MagicLinkFailedVerification=-1e4]="MagicLinkFailedVerification",t[t.MagicLinkExpired=-10001]="MagicLinkExpired",t[t.MagicLinkRateLimited=-10002]="MagicLinkRateLimited",t[t.UserAlreadyLoggedIn=-10003]="UserAlreadyLoggedIn",t[t.UpdateEmailFailed=-10004]="UpdateEmailFailed"}(c||(c={})),function(t){t.Harmony="HARMONY"}(l||(l={}));var f={__proto__:null,get EthChainType(){return l},get MagicIncomingWindowMessage(){return i},get MagicOutgoingWindowMessage(){return a},get MagicPayloadMethod(){return o},get RPCErrorCode(){return c},get SDKErrorCode(){return s},get SDKWarningCode(){return u}},d=n(function(t){var e=Object.prototype.hasOwnProperty,r="~";function n(){}function o(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function i(t,e,n,i,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new o(n,i||t,a),u=r?r+e:e;return t._events[u]?t._events[u].fn?t._events[u]=[t._events[u],s]:t._events[u].push(s):(t._events[u]=s,t._eventsCount++),t}function a(t,e){0==--t._eventsCount?t._events=new n:delete t._events[e]}function s(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),s.prototype.eventNames=function(){var t,n,o=[];if(0===this._eventsCount)return o;for(n in t=this._events)e.call(t,n)&&o.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(t)):o},s.prototype.listeners=function(t){var e=this._events[r?r+t:t];if(!e)return[];if(e.fn)return[e.fn];for(var n=0,o=e.length,i=new Array(o);n<o;n++)i[n]=e[n].fn;return i},s.prototype.listenerCount=function(t){var e=this._events[r?r+t:t];return e?e.fn?1:e.length:0},s.prototype.emit=function(t,e,n,o,i,a){var s=r?r+t:t;if(!this._events[s])return!1;var u,c,l=this._events[s],f=arguments.length;if(l.fn){switch(l.once&&this.removeListener(t,l.fn,void 0,!0),f){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,e),!0;case 3:return l.fn.call(l.context,e,n),!0;case 4:return l.fn.call(l.context,e,n,o),!0;case 5:return l.fn.call(l.context,e,n,o,i),!0;case 6:return l.fn.call(l.context,e,n,o,i,a),!0}for(c=1,u=new Array(f-1);c<f;c++)u[c-1]=arguments[c];l.fn.apply(l.context,u)}else{var d,h=l.length;for(c=0;c<h;c++)switch(l[c].once&&this.removeListener(t,l[c].fn,void 0,!0),f){case 1:l[c].fn.call(l[c].context);break;case 2:l[c].fn.call(l[c].context,e);break;case 3:l[c].fn.call(l[c].context,e,n);break;case 4:l[c].fn.call(l[c].context,e,n,o);break;default:if(!u)for(d=1,u=new Array(f-1);d<f;d++)u[d-1]=arguments[d];l[c].fn.apply(l[c].context,u)}}return!0},s.prototype.on=function(t,e,r){return i(this,t,e,r,!1)},s.prototype.once=function(t,e,r){return i(this,t,e,r,!0)},s.prototype.removeListener=function(t,e,n,o){var i=r?r+t:t;if(!this._events[i])return this;if(!e)return a(this,i),this;var s=this._events[i];if(s.fn)s.fn!==e||o&&!s.once||n&&s.context!==n||a(this,i);else{for(var u=0,c=[],l=s.length;u<l;u++)(s[u].fn!==e||o&&!s[u].once||n&&s[u].context!==n)&&c.push(s[u]);c.length?this._events[i]=1===c.length?c[0]:c:a(this,i)}return this},s.prototype.removeAllListeners=function(t){var e;return t?this._events[e=r?r+t:t]&&a(this,e):(this._events=new n,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=r,s.EventEmitter=s,t.exports=s});function h(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function p(t,e,r){return e&&h(t.prototype,e),r&&h(t,r),t}function y(){return(y=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function v(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function m(t){return(m=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function g(t,e){return(g=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function _(){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(t){return!1}}function E(t,e,r){return(E=_()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&g(o,r.prototype),o}).apply(null,arguments)}function w(t){var e="function"==typeof Map?new Map:void 0;return(w=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return E(t,arguments,m(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),g(r,t)})(t)}function b(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function A(t){return void 0===t}function I(t){return function(t){return null===t}(t)||A(t)}function L(t){if(!t)return!0;for(var e in t)if(Object.hasOwnProperty.call(t,e))return!1;return!0}var O={},M=function(t){function e(r,n){var o;return(o=t.call(this,"Magic SDK Error: ["+r+"] "+n)||this).code=r,o.rawMessage=n,o.__proto__=Error,Object.setPrototypeOf(b(o),e.prototype),o}return v(e,t),e}(w(Error)),P=function(){function t(t,e){this.code=t,this.rawMessage=e,this.message="Magic SDK Warning: ["+t+"] "+e}return t.prototype.log=function(){console.warn(this.message)},t}(),x=function(t){function e(r){var n;(n=t.call(this)||this).__proto__=Error;var o=Number(null==r?void 0:r.code);return n.rawMessage=(null==r?void 0:r.message)||"Internal error",n.code=function(t){return!I(t)&&"number"==typeof t&&Object.values(c).includes(t)}(o)?o:c.InternalError,n.message="Magic RPC Error: ["+n.code+"] "+n.rawMessage,Object.setPrototypeOf(b(n),e.prototype),n}return v(e,t),e}(w(Error)),R=regeneratorRuntime.mark(N);function N(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:t=0;case 1:if(!(t<Number.MAX_SAFE_INTEGER)){e.next=7;break}return e.next=5,++t;case 5:e.next=8;break;case 7:t=0;case 8:e.next=1;break;case 10:case"end":return e.stop()}},R)}var S=N();function j(){return S.next().value}var k=Symbol("Payload pre-processed by Magic SDK");function C(t){return Object.defineProperty(t,k,{value:!0,enumerable:!1}),t}function T(t){var e,r,n;return function(t){return!!t[k]}(t)||(t.jsonrpc=null!=(e=t.jsonrpc)?e:"2.0",t.id=j(),t.method=null!=(r=t.method)?r:"noop",t.params=null!=(n=t.params)?n:[],C(t)),t}function D(t,e){return void 0===e&&(e=[]),C({params:e,method:t,jsonrpc:"2.0",id:j()})}var G=function(){function t(e){e instanceof t?(this._jsonrpc=e.payload.jsonrpc,this._id=e.payload.id,this._result=e.payload.result,this._error=e.payload.error):function(t){return!I(t)&&!(A(t.jsonrpc)||A(t.id)||A(t.result)&&A(t.error))}(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)}var e=t.prototype;return e.applyError=function(t){return this._error=t,this},e.applyResult=function(t){return this._result=t,this},p(t,[{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}}}]),t}(),H=function(t){function e(){return t.apply(this,arguments)||this}return v(e,t),e}(d);function U(){var t=new H;return{emitter:t,createChainingEmitterMethod:function(e,r){return function(){return t[e].apply(t,[].slice.call(arguments)),r}},createBoundEmitterMethod:function(e){return function(){return t[e].apply(t,[].slice.call(arguments))}}}}var F=Symbol("isPromiEvent");function Q(t){return new Promise(function(e,r){var n=t(e,r);Promise.resolve(n).catch(r)})}var V=function(){function t(t){this.sdk=t}return t.prototype.request=function(t){var e=this.transport.post(this.overlay,a.MAGIC_HANDLE_REQUEST,T(t)),r=function(t){var e=Q(t),r=U(),n=r.createBoundEmitterMethod,o=r.createChainingEmitterMethod,i=Symbol("Promise.then"),a=Symbol("Promise.catch"),s=Symbol("Promise.finally"),u=function(t,e){return function(){var r=e[t].apply(e,[].slice.call(arguments));return c(r)}},c=function(t){var e;return Object.assign(t,((e={})[F]=!0,e[i]=t[i]||t.then,e[a]=t[a]||t.catch,e[s]=t[s]||t.finally,e.then=u(i,t),e.catch=u(a,t),e.finally=u(s,t),e.on=o("on",t),e.once=o("once",t),e.addListener=o("addListener",t),e.off=o("off",t),e.removeListener=o("removeListener",t),e.removeAllListeners=o("removeAllListeners",t),e.emit=n("emit"),e.eventNames=n("eventNames"),e.listeners=n("listeners"),e.listenerCount=n("listenerCount"),e))},l=c(e.then(function(t){return l.emit("done",t),l.emit("settled"),t},function(t){throw l.emit("error",t),l.emit("settled"),t}));return l}(function(t,r){e.then(function(e){if(n(),e.hasError)r(new x(e.payload.error));else{if(!e.hasResult)throw new M(s.MalformedResponse,"Response from the Magic iframe is malformed.");t(e.payload.result)}}).catch(function(t){n(),r(t)})}),n=this.transport.on(i.MAGIC_HANDLE_EVENT,function(e){var n,o=e.data.response;if(o.id===t.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},p(t,[{key:"transport",get:function(){return this.sdk.transport}},{key:"overlay",get:function(){return this.sdk.overlay}}]),t}(),W=function(t){function e(){return t.apply(this,arguments)||this}return v(e,t),e.prototype.loginWithMagicLink=function(t){var e=t.showUI,r=D(o.LoginWithMagicLink,[{email:t.email,showUI:void 0===e||e}]);return this.request(r)},e}(V),Y=function(t){function e(){return t.apply(this,arguments)||this}v(e,t);var r=e.prototype;return r.getIdToken=function(t){var e=D(o.GetIdToken,[t]);return this.request(e)},r.generateIdToken=function(t){var e=D(o.GenerateIdToken,[t]);return this.request(e)},r.getMetadata=function(){var t=D(o.GetMetadata);return this.request(t)},r.updateEmail=function(t){var e=t.showUI,r=D(o.UpdateEmail,[{email:t.email,showUI:void 0===e||e}]);return this.request(r)},r.isLoggedIn=function(){var t=D(o.IsLoggedIn);return this.request(t)},r.logout=function(){var t=D(o.Logout);return this.request(t)},e}(V),q=U(),K=q.createBoundEmitterMethod,z=q.createChainingEmitterMethod,B=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).isMagic=!0,e.on=z("on",b(e)),e.once=z("once",b(e)),e.addListener=z("addListener",b(e)),e.off=z("off",b(e)),e.removeListener=z("removeListener",b(e)),e.removeAllListeners=z("removeAllListeners",b(e)),e.emit=K("emit"),e.eventNames=K("eventNames"),e.listeners=K("listeners"),e.listenerCount=K("listenerCount"),e}v(e,t);var r=e.prototype;return r.sendAsync=function(t,e){if(!e)throw function(t){var e,r,n;return new M(s.InvalidArgument,"Invalid "+(n=(e=t.argument+1)%100,(1==(r=e%10)&&11!==n?e+"st":2===r&&12!==n?e+"nd":3===r&&13!==n?e+"rd":e+"th")+" argument given to `")+t.procedure+"`.\n Expected: `"+t.expected+"`\n Received: `"+t.received+"`")}({procedure:"Magic.rpcProvider.sendAsync",argument:1,expected:"function",received:null===e?"null":typeof e});if(Array.isArray(t))this.transport.post(this.overlay,a.MAGIC_HANDLE_REQUEST,t.map(function(t){return T(t)})).then(function(t){e(null,t.map(function(t){return y({},t.payload,{error:t.hasError?new x(t.payload.error):null})}))});else{var r=T(t);this.transport.post(this.overlay,a.MAGIC_HANDLE_REQUEST,r).then(function(t){e(t.hasError?new x(t.payload.error):null,t.payload)})}},r.send=function(t,e){if("string"==typeof t){var r=D(t,Array.isArray(e)?e:[]);return this.request(r)}if(!Array.isArray(t)&&!e){var n=new P(u.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.");return n.log(),new G(t).applyError({code:-32603,message:n.rawMessage}).payload}this.sendAsync(t,e)},r.enable=function(){var t=D("eth_accounts");return this.request(t)},e}(V);function J(t,e){return e?new URL(t,e):new URL(t)}var X=function(t){function e(){var e;return(e=t.call(this,void 0)||this).isInitialized=!1,e.createJsonRpcRequestPayload=D,e.standardizeJsonRpcRequestPayload=T,new Proxy(b(e),{get:function(t,r,n){if(["request","transport","overlay","sdk"].includes(r)&&!e.isInitialized)throw function(t){return new M(s.ExtensionNotInitialized,"Extensions must be initialized with a Magic SDK instance before `Extension."+t+"` can be accessed. Do not invoke `Extension."+t+"` inside an extension constructor.")}(r);return Reflect.get(t,r,n)}})||b(e)}return v(e,t),e.prototype.init=function(t){this.sdk=t,this.isInitialized=!0},e}(V),Z=function(t){function e(){return t.apply(this,arguments)||this}return v(e,t),e}(X),$=function(t){function e(){return t.apply(this,arguments)||this}return v(e,t),e}(X);$.Internal=Z;var tt=function(){function t(t,e){var r,n,o=this;if(this.apiKey=t,!t)throw new M(s.MissingApiKey,"Please provide an API key that you acquired from the Magic developer dashboard.");"react-native"===O.target&&(null==e?void 0:e.endpoint)&&new P(u.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 `"+O.defaultEndpoint+"`. Changing this default behavior will lead to unexpected results and potentially security-threatening bugs.").log();var i=O.version;this.endpoint=J(null!=(r=null==e?void 0:e.endpoint)?r:O.defaultEndpoint).origin,this.auth=new W(this),this.user=new Y(this),this.rpcProvider=new B(this);var a=null!=(n=null==e?void 0:e.extensions)?n:[],c={};Array.isArray(a)?a.forEach(function(t){t.init(o),o[t.name]=t,t instanceof $.Internal&&(L(t.config)||(c[t.name]=t.config))}):Object.keys(a).forEach(function(t){a[t].init(o);var e=a[t];o[t]=e,e instanceof $.Internal&&(L(e.config)||(c[a[t].name]=e.config))}),this.encodedQueryParams=function(t){return btoa(JSON.stringify(t))}({API_KEY:this.apiKey,DOMAIN_ORIGIN:window.location?window.location.origin:"",ETH_NETWORK:null==e?void 0:e.network,host:J(this.endpoint).host,sdk:O.sdkName,version:i,ext:L(c)?void 0:c})}return t.prototype.preload=function(){try{return Promise.resolve(this.overlay.ready).then(function(){})}catch(t){return Promise.reject(t)}},p(t,[{key:"transport",get:function(){return t.__transports__.has(this.encodedQueryParams)||t.__transports__.set(this.encodedQueryParams,new O.PayloadTransport(this.endpoint,this.encodedQueryParams)),t.__transports__.get(this.encodedQueryParams)}},{key:"overlay",get:function(){if(!t.__overlays__.has(this.encodedQueryParams)){var e=new O.ViewController(this.transport,this.endpoint,this.encodedQueryParams);t.__overlays__.set(this.encodedQueryParams,e)}return t.__overlays__.get(this.encodedQueryParams)}}]),t}();tt.__transports__=new Map,tt.__overlays__=new Map;var et,rt=function(){function t(t,e){this.endpoint=t,this.encodedQueryParams=e,this.messageHandlers=new Set,this.init()}var e=t.prototype;return e.post=function(t,e,r){try{var n=this;return Promise.resolve(Q(function(o){try{return Promise.resolve(t.ready).then(function(){var a=[],s=Array.isArray(r)?r.map(function(t){return t.id}):[];return Promise.resolve(t.postMessage({msgType:e+"-"+n.encodedQueryParams,payload:r})).then(function(){var t,e=n.on(i.MAGIC_HANDLE_RESPONSE,(t=function(){return e()},function(e){var n=function(t,e){var r,n=null===(r=e.data.response)||void 0===r?void 0:r.id,o=function(t,e){return e&&Array.isArray(t)?t.find(function(t){return t.id===e}):t}(t,n);return n&&o?{id:n,response:new G(o).applyResult(e.data.response.result).applyError(e.data.response.error)}:{}}(r,e),i=n.id,u=n.response;i&&u&&Array.isArray(r)&&s.includes(i)?(a.push(u),a.length===r.length&&(t(),o(a))):i&&u&&!Array.isArray(r)&&i===r.id&&(t(),o(u))}))})})}catch(t){return Promise.reject(t)}}))}catch(t){return Promise.reject(t)}},e.on=function(t,e){var r=this,n=e.bind(window),o=function(e){e.data.msgType===t+"-"+r.encodedQueryParams&&n(e)};return this.messageHandlers.add(o),function(){return r.messageHandlers.delete(o)}},t}(),nt=function(){function t(t,e,r){this.transport=t,this.endpoint=e,this.encodedQueryParams=r,this.ready=this.waitForReady(),this.init&&this.init(),this.listen()}var e=t.prototype;return e.waitForReady=function(){var t=this;return new Promise(function(e){t.transport.on(i.MAGIC_OVERLAY_READY,function(){return e()})})},e.listen=function(){var t=this;this.transport.on(i.MAGIC_HIDE_OVERLAY,function(){t.hideOverlay()}),this.transport.on(i.MAGIC_SHOW_OVERLAY,function(){t.showOverlay()})},t}(),ot={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",zIndex:"2147483647"},it=function(t){function r(){return t.apply(this,arguments)||this}e(r,t);var n=r.prototype;return n.init=function(){this.iframe=this.createIframe()},n.createIframe=function(){var t=this;return new Promise(function(e){var r=function(){if(n=encodeURIComponent(t.encodedQueryParams),o=[].slice.call(document.querySelectorAll(".magic-iframe")),Boolean(o.find(function(t){return t.src.includes(n)})))new P(u.DuplicateIframe,"Duplicate iframes found.").log();else{var r=document.createElement("iframe");r.classList.add("magic-iframe"),r.dataset.magicIframeLabel=J(t.endpoint).host,r.src=J("/send?params="+encodeURIComponent(t.encodedQueryParams),t.endpoint).href,function(t){for(var e=0,r=Object.entries(ot);e<r.length;e++){var n=r[e];t.style[n[0]]=n[1]}}(r),document.body.appendChild(r),e(r)}var n,o};["loaded","interactive","complete"].includes(document.readyState)?r():window.addEventListener("load",r,!1)})},n.showOverlay=function(){try{return Promise.resolve(this.iframe).then(function(t){t.style.display="block"})}catch(t){return Promise.reject(t)}},n.hideOverlay=function(){try{return Promise.resolve(this.iframe).then(function(t){t.style.display="none"})}catch(t){return Promise.reject(t)}},n.postMessage=function(t){try{return Promise.resolve(this.iframe).then(function(e){if(!e||!e.contentWindow)throw new M(s.ModalNotReady,"Modal is not ready.");e.contentWindow.postMessage(t,"*")})}catch(t){return Promise.reject(t)}},r}(nt),at=(et=tt,Object.assign(O,{target:"web",sdkName:"magic-sdk",version:"2.0.2",defaultEndpoint:"https://auth.magic.link/",ViewController:it,PayloadTransport:function(t){function n(){return t.apply(this,arguments)||this}return e(n,t),n.prototype.init=function(){var t=this;window.addEventListener("message",function(e){if(e.origin===t.endpoint&&e.data&&e.data.msgType&&t.messageHandlers.size){var n;e.data.response=null!=(n=e.data.response)?n:{};for(var o,i=function(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return r(t,void 0);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,void 0):void 0}}(t))){n&&(t=n);var o=0;return function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=t[Symbol.iterator]()).next.bind(n)}(t.messageHandlers.values());!(o=i()).done;)(0,o.value)(e)}})},n}(rt)}),et);return Object.assign(at,t({},f,{SDKError:M,SDKWarning:P,RPCError:x,Extension:$})),at}); |
@@ -1,2 +0,2 @@ | ||
require("regenerator-runtime/runtime");var e=require("@magic-sdk/provider"),r=require("@magic-sdk/types");function t(e,r){e.prototype=Object.create(r.prototype),e.prototype.constructor=e,e.__proto__=r}function n(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var o={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",zIndex:"2147483647"},i=function(r){function n(){return r.apply(this,arguments)||this}t(n,r);var i=n.prototype;return i.init=function(){this.iframe=this.createIframe()},i.createIframe=function(){var r=this;return new Promise(function(t){var n=function(){if(i=encodeURIComponent(r.encodedQueryParams),a=[].slice.call(document.querySelectorAll(".magic-iframe")),Boolean(a.find(function(e){return e.src.includes(i)})))e.createDuplicateIframeWarning().log();else{var n=document.createElement("iframe");n.classList.add("magic-iframe"),n.dataset.magicIframeLabel=e.createURL(r.endpoint).host,n.src=e.createURL("/send?params="+encodeURIComponent(r.encodedQueryParams),r.endpoint).href,function(e){for(var r=0,t=Object.entries(o);r<t.length;r++){var n=t[r];e.style[n[0]]=n[1]}}(n),document.body.appendChild(n),t(n)}var i,a};["loaded","interactive","complete"].includes(document.readyState)?n():window.addEventListener("load",n,!1)})},i.showOverlay=function(){try{return Promise.resolve(this.iframe).then(function(e){e.style.display="block"})}catch(e){return Promise.reject(e)}},i.hideOverlay=function(){try{return Promise.resolve(this.iframe).then(function(e){e.style.display="none"})}catch(e){return Promise.reject(e)}},i.postMessage=function(r){try{return Promise.resolve(this.iframe).then(function(t){if(!t||!t.contentWindow)throw e.createModalNotReadyError();t.contentWindow.postMessage(r,"*")})}catch(e){return Promise.reject(e)}},n}(e.ViewController),a=e.createSDK(e.SDKBase,{target:"web",sdkName:"magic-sdk",version:"2.0.1",defaultEndpoint:"https://auth.magic.link/",ViewController:i,PayloadTransport:function(e){function r(){return e.apply(this,arguments)||this}return t(r,e),r.prototype.init=function(){var e=this;window.addEventListener("message",function(r){if(r.origin===e.endpoint&&r.data&&r.data.msgType&&e.messageHandlers.size){var t;r.data.response=null!=(t=r.data.response)?t:{};for(var o,i=function(e,r){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return n(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?n(e,void 0):void 0}}(e))){t&&(e=t);var o=0;return function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}(e.messageHandlers.values());!(o=i()).done;)(0,o.value)(r)}})},r}(e.PayloadTransport)});Object.keys(r).forEach(function(e){"default"!==e&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return r[e]}})}),Object.defineProperty(exports,"Extension",{enumerable:!0,get:function(){return e.Extension}}),Object.defineProperty(exports,"RPCError",{enumerable:!0,get:function(){return e.MagicRPCError}}),Object.defineProperty(exports,"SDKError",{enumerable:!0,get:function(){return e.MagicSDKError}}),Object.defineProperty(exports,"SDKWarning",{enumerable:!0,get:function(){return e.MagicSDKWarning}}),exports.Magic=a; | ||
require("regenerator-runtime/runtime");var e=require("@magic-sdk/provider"),r=require("@magic-sdk/types");function t(e,r){e.prototype=Object.create(r.prototype),e.prototype.constructor=e,e.__proto__=r}function n(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var o={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",zIndex:"2147483647"},i=function(r){function n(){return r.apply(this,arguments)||this}t(n,r);var i=n.prototype;return i.init=function(){this.iframe=this.createIframe()},i.createIframe=function(){var r=this;return new Promise(function(t){var n=function(){if(i=encodeURIComponent(r.encodedQueryParams),a=[].slice.call(document.querySelectorAll(".magic-iframe")),Boolean(a.find(function(e){return e.src.includes(i)})))e.createDuplicateIframeWarning().log();else{var n=document.createElement("iframe");n.classList.add("magic-iframe"),n.dataset.magicIframeLabel=e.createURL(r.endpoint).host,n.src=e.createURL("/send?params="+encodeURIComponent(r.encodedQueryParams),r.endpoint).href,function(e){for(var r=0,t=Object.entries(o);r<t.length;r++){var n=t[r];e.style[n[0]]=n[1]}}(n),document.body.appendChild(n),t(n)}var i,a};["loaded","interactive","complete"].includes(document.readyState)?n():window.addEventListener("load",n,!1)})},i.showOverlay=function(){try{return Promise.resolve(this.iframe).then(function(e){e.style.display="block"})}catch(e){return Promise.reject(e)}},i.hideOverlay=function(){try{return Promise.resolve(this.iframe).then(function(e){e.style.display="none"})}catch(e){return Promise.reject(e)}},i.postMessage=function(r){try{return Promise.resolve(this.iframe).then(function(t){if(!t||!t.contentWindow)throw e.createModalNotReadyError();t.contentWindow.postMessage(r,"*")})}catch(e){return Promise.reject(e)}},n}(e.ViewController),a=e.createSDK(e.SDKBase,{target:"web",sdkName:"magic-sdk",version:"2.0.2",defaultEndpoint:"https://auth.magic.link/",ViewController:i,PayloadTransport:function(e){function r(){return e.apply(this,arguments)||this}return t(r,e),r.prototype.init=function(){var e=this;window.addEventListener("message",function(r){if(r.origin===e.endpoint&&r.data&&r.data.msgType&&e.messageHandlers.size){var t;r.data.response=null!=(t=r.data.response)?t:{};for(var o,i=function(e,r){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return n(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?n(e,void 0):void 0}}(e))){t&&(e=t);var o=0;return function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}(e.messageHandlers.values());!(o=i()).done;)(0,o.value)(r)}})},r}(e.PayloadTransport)});Object.keys(r).forEach(function(e){"default"!==e&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return r[e]}})}),Object.defineProperty(exports,"Extension",{enumerable:!0,get:function(){return e.Extension}}),Object.defineProperty(exports,"RPCError",{enumerable:!0,get:function(){return e.MagicRPCError}}),Object.defineProperty(exports,"SDKError",{enumerable:!0,get:function(){return e.MagicSDKError}}),Object.defineProperty(exports,"SDKWarning",{enumerable:!0,get:function(){return e.MagicSDKWarning}}),exports.Magic=a; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import"regenerator-runtime/runtime";import{createModalNotReadyError as e,createURL as r,createDuplicateIframeWarning as t,ViewController as n,PayloadTransport as o,createSDK as i,SDKBase as a}from"@magic-sdk/provider";export{Extension,MagicRPCError as RPCError,MagicSDKError as SDKError,MagicSDKWarning as SDKWarning}from"@magic-sdk/provider";export*from"@magic-sdk/types";function s(e,r){e.prototype=Object.create(r.prototype),e.prototype.constructor=e,e.__proto__=r}function c(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var d={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",zIndex:"2147483647"},u=i(a,{target:"web",sdkName:"magic-sdk",version:"2.0.1",defaultEndpoint:"https://auth.magic.link/",ViewController:function(n){function o(){return n.apply(this,arguments)||this}s(o,n);var i=o.prototype;return i.init=function(){this.iframe=this.createIframe()},i.createIframe=function(){var e=this;return new Promise(function(n){var o=function(){if(i=encodeURIComponent(e.encodedQueryParams),a=[].slice.call(document.querySelectorAll(".magic-iframe")),Boolean(a.find(function(e){return e.src.includes(i)})))t().log();else{var o=document.createElement("iframe");o.classList.add("magic-iframe"),o.dataset.magicIframeLabel=r(e.endpoint).host,o.src=r("/send?params="+encodeURIComponent(e.encodedQueryParams),e.endpoint).href,function(e){for(var r=0,t=Object.entries(d);r<t.length;r++){var n=t[r];e.style[n[0]]=n[1]}}(o),document.body.appendChild(o),n(o)}var i,a};["loaded","interactive","complete"].includes(document.readyState)?o():window.addEventListener("load",o,!1)})},i.showOverlay=function(){try{return Promise.resolve(this.iframe).then(function(e){e.style.display="block"})}catch(e){return Promise.reject(e)}},i.hideOverlay=function(){try{return Promise.resolve(this.iframe).then(function(e){e.style.display="none"})}catch(e){return Promise.reject(e)}},i.postMessage=function(r){try{return Promise.resolve(this.iframe).then(function(t){if(!t||!t.contentWindow)throw e();t.contentWindow.postMessage(r,"*")})}catch(e){return Promise.reject(e)}},o}(n),PayloadTransport:function(e){function r(){return e.apply(this,arguments)||this}return s(r,e),r.prototype.init=function(){var e=this;window.addEventListener("message",function(r){if(r.origin===e.endpoint&&r.data&&r.data.msgType&&e.messageHandlers.size){var t;r.data.response=null!=(t=r.data.response)?t:{};for(var n,o=function(e,r){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return c(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?c(e,void 0):void 0}}(e))){t&&(e=t);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}(e.messageHandlers.values());!(n=o()).done;)(0,n.value)(r)}})},r}(o)});export{u as Magic}; | ||
import"regenerator-runtime/runtime";import{createModalNotReadyError as e,createURL as r,createDuplicateIframeWarning as t,ViewController as n,PayloadTransport as o,createSDK as i,SDKBase as a}from"@magic-sdk/provider";export{Extension,MagicRPCError as RPCError,MagicSDKError as SDKError,MagicSDKWarning as SDKWarning}from"@magic-sdk/provider";export*from"@magic-sdk/types";function s(e,r){e.prototype=Object.create(r.prototype),e.prototype.constructor=e,e.__proto__=r}function c(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var d={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",zIndex:"2147483647"},u=i(a,{target:"web",sdkName:"magic-sdk",version:"2.0.2",defaultEndpoint:"https://auth.magic.link/",ViewController:function(n){function o(){return n.apply(this,arguments)||this}s(o,n);var i=o.prototype;return i.init=function(){this.iframe=this.createIframe()},i.createIframe=function(){var e=this;return new Promise(function(n){var o=function(){if(i=encodeURIComponent(e.encodedQueryParams),a=[].slice.call(document.querySelectorAll(".magic-iframe")),Boolean(a.find(function(e){return e.src.includes(i)})))t().log();else{var o=document.createElement("iframe");o.classList.add("magic-iframe"),o.dataset.magicIframeLabel=r(e.endpoint).host,o.src=r("/send?params="+encodeURIComponent(e.encodedQueryParams),e.endpoint).href,function(e){for(var r=0,t=Object.entries(d);r<t.length;r++){var n=t[r];e.style[n[0]]=n[1]}}(o),document.body.appendChild(o),n(o)}var i,a};["loaded","interactive","complete"].includes(document.readyState)?o():window.addEventListener("load",o,!1)})},i.showOverlay=function(){try{return Promise.resolve(this.iframe).then(function(e){e.style.display="block"})}catch(e){return Promise.reject(e)}},i.hideOverlay=function(){try{return Promise.resolve(this.iframe).then(function(e){e.style.display="none"})}catch(e){return Promise.reject(e)}},i.postMessage=function(r){try{return Promise.resolve(this.iframe).then(function(t){if(!t||!t.contentWindow)throw e();t.contentWindow.postMessage(r,"*")})}catch(e){return Promise.reject(e)}},o}(n),PayloadTransport:function(e){function r(){return e.apply(this,arguments)||this}return s(r,e),r.prototype.init=function(){var e=this;window.addEventListener("message",function(r){if(r.origin===e.endpoint&&r.data&&r.data.msgType&&e.messageHandlers.size){var t;r.data.response=null!=(t=r.data.response)?t:{};for(var n,o=function(e,r){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return c(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?c(e,void 0):void 0}}(e))){t&&(e=t);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}(e.messageHandlers.values());!(n=o()).done;)(0,n.value)(r)}})},r}(o)});export{u as Magic}; | ||
//# sourceMappingURL=index.m.js.map |
@@ -1,2 +0,2 @@ | ||
import"regenerator-runtime/runtime";import{ViewController as e,createModalNotReadyError as t,createURL as a,createDuplicateIframeWarning as s,PayloadTransport as i,createSDK as n,SDKBase as r}from"@magic-sdk/provider";export{Extension,MagicRPCError as RPCError,MagicSDKError as SDKError,MagicSDKWarning as SDKWarning}from"@magic-sdk/provider";export*from"@magic-sdk/types";const o={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",zIndex:"2147483647"},d=n(r,{target:"web",sdkName:"magic-sdk",version:"2.0.1",defaultEndpoint:"https://auth.magic.link/",ViewController:class extends e{init(){this.iframe=this.createIframe()}createIframe(){return new Promise(e=>{const t=()=>{if(function(e){const t=[].slice.call(document.querySelectorAll(".magic-iframe"));return Boolean(t.find(t=>t.src.includes(e)))}(encodeURIComponent(this.encodedQueryParams)))s().log();else{const t=document.createElement("iframe");t.classList.add("magic-iframe"),t.dataset.magicIframeLabel=a(this.endpoint).host,t.src=a("/send?params="+encodeURIComponent(this.encodedQueryParams),this.endpoint).href,function(e){for(const[t,a]of Object.entries(o))e.style[t]=a}(t),document.body.appendChild(t),e(t)}};["loaded","interactive","complete"].includes(document.readyState)?t():window.addEventListener("load",t,!1)})}async showOverlay(){(await this.iframe).style.display="block"}async hideOverlay(){(await this.iframe).style.display="none"}async postMessage(e){const a=await this.iframe;if(!a||!a.contentWindow)throw t();a.contentWindow.postMessage(e,"*")}},PayloadTransport:class extends i{init(){window.addEventListener("message",e=>{if(e.origin===this.endpoint&&e.data&&e.data.msgType&&this.messageHandlers.size){e.data.response=e.data.response??{};for(const t of this.messageHandlers.values())t(e)}})}}});export{d as Magic}; | ||
import"regenerator-runtime/runtime";import{ViewController as e,createModalNotReadyError as t,createURL as a,createDuplicateIframeWarning as s,PayloadTransport as i,createSDK as n,SDKBase as r}from"@magic-sdk/provider";export{Extension,MagicRPCError as RPCError,MagicSDKError as SDKError,MagicSDKWarning as SDKWarning}from"@magic-sdk/provider";export*from"@magic-sdk/types";const o={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",zIndex:"2147483647"},d=n(r,{target:"web",sdkName:"magic-sdk",version:"2.0.2",defaultEndpoint:"https://auth.magic.link/",ViewController:class extends e{init(){this.iframe=this.createIframe()}createIframe(){return new Promise(e=>{const t=()=>{if(function(e){const t=[].slice.call(document.querySelectorAll(".magic-iframe"));return Boolean(t.find(t=>t.src.includes(e)))}(encodeURIComponent(this.encodedQueryParams)))s().log();else{const t=document.createElement("iframe");t.classList.add("magic-iframe"),t.dataset.magicIframeLabel=a(this.endpoint).host,t.src=a("/send?params="+encodeURIComponent(this.encodedQueryParams),this.endpoint).href,function(e){for(const[t,a]of Object.entries(o))e.style[t]=a}(t),document.body.appendChild(t),e(t)}};["loaded","interactive","complete"].includes(document.readyState)?t():window.addEventListener("load",t,!1)})}async showOverlay(){(await this.iframe).style.display="block"}async hideOverlay(){(await this.iframe).style.display="none"}async postMessage(e){const a=await this.iframe;if(!a||!a.contentWindow)throw t();a.contentWindow.postMessage(e,"*")}},PayloadTransport:class extends i{init(){window.addEventListener("message",e=>{if(e.origin===this.endpoint&&e.data&&e.data.msgType&&this.messageHandlers.size){e.data.response=e.data.response??{};for(const t of this.messageHandlers.values())t(e)}})}}});export{d as Magic}; | ||
//# sourceMappingURL=index.modern.js.map |
{ | ||
"name": "magic-sdk", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "Passwordless authentication for the web.", | ||
@@ -30,4 +30,4 @@ "author": "Fortmatic <team@fortmatic.com> (https://fortmatic.com/)", | ||
"@babel/runtime": "^7.9.6", | ||
"@magic-sdk/provider": "^1.0.1", | ||
"@magic-sdk/types": "^1.0.1", | ||
"@magic-sdk/provider": "^1.0.2", | ||
"@magic-sdk/types": "^1.0.2", | ||
"regenerator-runtime": "0.13.5" | ||
@@ -64,3 +64,3 @@ }, | ||
}, | ||
"gitHead": "6dd13cb1364f59dc3af4cc2ec724c97c2e14e006" | ||
"gitHead": "cb97140fb946519eae1706ef6cc96e109237eb6e" | ||
} |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
65841
2
Updated@magic-sdk/provider@^1.0.2
Updated@magic-sdk/types@^1.0.2