Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@opensea/embedded-wallet-sdk

Package Overview
Dependencies
Maintainers
0
Versions
474
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opensea/embedded-wallet-sdk - npm Package Compare versions

Comparing version 0.1.14 to 0.1.15

2

dist/index.js

@@ -1,2 +0,2 @@

import{EventEmitter as e}from"eventemitter3";import{Vessel as t}from"@opensea/vessel";var n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},n(e,t)};function r(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function u(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,u)}c((r=r.apply(e,t||[])).next())}))}function i(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&u[0]?r.return:u[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,u[1])).done)return i;switch(r=0,i&&(u=[2&u[0],i.value]),u[0]){case 0:case 1:i=u;break;case 4:return s.label++,{value:u[1],done:!1};case 5:s.label++,r=u[1],u=[0];continue;case 7:u=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==u[0]&&2!==u[0])){s=0;continue}if(3===u[0]&&(!i||u[1]>i[0]&&u[1]<i[3])){s.label=u[1];break}if(6===u[0]&&s.label<i[1]){s.label=i[1],i=u;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(u);break}i[2]&&s.ops.pop(),s.trys.pop();continue}u=t.call(e,s)}catch(e){u=[6,e],r=0}finally{n=i=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}"function"==typeof SuppressedError&&SuppressedError;var o=function(e){function t(t){var n=t.message,r=t.code,i=t.data,o=e.call(this,n)||this;return o.code=r,o.data=i,o}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(t,e),t}(Error),s=new e,u=function(){function e(e){var t=e.vessel;this.vessel=t,this.messageListener=this.handleInboundMessage.bind(this),this.vessel.addListener("message",this.messageListener)}return e.prototype.handleInboundMessage=function(e,t){return!!function(e){return!!e&&"object"==typeof e&&"type"in e&&"event"===e.type&&"event"in e&&"string"==typeof e.event}(e.payload)&&(s.emit(e.payload.event,e.payload.data),t(),!0)},e.prototype.request=function(e){return r(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.vessel.send({type:"action",action:"HeadlessRPCRequest",payload:e},{timeout:void 0})];case 1:return[2,n.sent()];case 2:if(t=n.sent(),(r=t)&&"object"==typeof r&&"message"in r&&"code"in r&&"number"==typeof r.code)throw new o(t);if(t instanceof Error)throw t.message="Error sending message to wallet: ".concat(t.message),t;throw new Error("Error sending message to wallet: ".concat(JSON.stringify(t)));case 3:return[2]}var r}))}))},e.prototype.on=function(e,t){s.on(e,t)},e.prototype.removeListener=function(e,t){s.removeListener(e,t)},e.prototype.disconnect=function(){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return this.vessel.removeListener("message",this.messageListener),[4,this.vessel.send({type:"action",action:"Logout"})];case 1:return e.sent(),[2]}}))}))},e}(),c="https://wallets.opensea.io/hidden",a="https://dev-wallets.opensea.io/hidden",d="http://localhost:5001/hidden",l=new e,f=function(e){return l.addListener("mfa-required",e),function(){return l.removeListener("mfa-required",e)}},v=function(e){return r(void 0,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,M()];case 1:return[4,t.sent().vessel.send({type:"action",action:"InitMfa",mfaMethod:e},{timeout:void 0})];case 2:return[2,t.sent()]}}))}))},h=function(e,t){return r(void 0,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,M()];case 1:return[4,n.sent().vessel.send({type:"action",action:"SubmitMfa",mfaCode:t,mfaMethod:e},{timeout:void 0})];case 2:return[2,n.sent()]}}))}))},p=function(){return r(void 0,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,M()];case 1:return[4,e.sent().vessel.send({type:"action",action:"CancelMfa"},{timeout:void 0})];case 2:return[2,e.sent()]}}))}))},m=function(e){return r(void 0,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,M()];case 1:return[4,t.sent().vessel.send({type:"action",action:"InitMfaEnrollmentWithSms",phoneNumber:e},{timeout:void 0})];case 2:return[2,t.sent()]}}))}))},y=function(e,t){return r(void 0,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,M()];case 1:return[4,n.sent().vessel.send({type:"action",action:"SubmitMfaEnrollmentWithSms",phoneNumber:e,mfaCode:t},{timeout:void 0})];case 2:return[2,n.sent()]}}))}))},b=function(){return r(void 0,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,M()];case 1:return[4,e.sent().vessel.send({type:"action",action:"InitMfaEnrollmentWithTotp"},{timeout:void 0})];case 2:return[2,e.sent()]}}))}))},w=function(e){return r(void 0,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,M()];case 1:return[4,t.sent().vessel.send({type:"action",action:"SubmitMfaEnrollmentWithTotp",mfaCode:e},{timeout:void 0})];case 2:return[2,t.sent()]}}))}))},g=void 0,E=void 0,L=void 0,S=function(e){var n=void 0===e?{}:e,o=n.url,s=void 0===o?a:o,u=n.debug,c=void 0!==u&&u,d=n.retries,l=void 0===d?1:d;return r(void 0,void 0,void 0,(function(){return i(this,(function(e){return L?[2,L]:"undefined"==typeof document?[2]:((g=document.createElement("iframe")).src=s,g.hidden=!0,g.id="os-embedded-wallet-iframe",document.body.appendChild(g),E=new t({iframe:g,targetOrigin:new URL(s).origin,debug:c,handshakeTimeout:5e3}),L=r(void 0,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,E.handshake()];case 1:return t.sent(),E.addListener("message",_),[3,3];case 2:if(e=t.sent(),console.error("Error initializing embedded wallet",e),L=void 0,l>0)return console.debug("Retrying embedded wallet initialization (".concat(l," retries left)")),[2,S({url:s,debug:c,retries:l-1})];throw e;case 3:return[2]}}))})),[2,L])}))}))},M=function(){return r(void 0,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:if(!E)throw new Error("Wallet module not initialized");return[4,L];case 1:return e.sent(),[2,{vessel:E,iframe:g}]}}))}))},_=function(e,t){return!!((i=e.payload)&&"object"==typeof i&&"type"in i&&"action"===i.type&&"action"in i&&"PromptMfa"===i.action)&&(n=e.payload.mfaMethods,r=function(){return t({success:!0})},l.emit("mfa-required",n,r),!0);var n,r,i},C=void 0,q=function(){return r(void 0,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return"undefined"==typeof document?[2,void 0]:[4,M()];case 1:return e=t.sent().vessel,C||(C=new u({vessel:e})),[2,C]}}))}))},I=function(){return r(void 0,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,q()];case 1:if(!(e=t.sent()))throw new Error("Wallet module not initialized");return[2,e]}}))}))},x=function(){return r(void 0,void 0,void 0,(function(){var e,t,n,r;return i(this,(function(i){switch(i.label){case 0:return"undefined"==typeof document?[2,{accounts:[],chainId:1}]:[4,I()];case 1:return e=i.sent(),[4,Promise.all([e.request({method:"eth_accounts"}),e.request({method:"eth_chainId"})])];case 2:return t=i.sent(),n=t[0],r=t[1],[2,{accounts:n,chainId:r}]}}))}))},W=function(){return r(void 0,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,I()];case 1:return[4,e.sent().disconnect()];case 2:return e.sent(),[2]}}))}))},k=function(){return r(void 0,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return"undefined"==typeof document?[2,[]]:[4,I()];case 1:return[2,e.sent().request({method:"eth_accounts"})]}}))}))},O=function(){return r(void 0,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return"undefined"==typeof document?[2,1]:[4,I()];case 1:return e=t.sent(),[2,e.request({method:"eth_chainId"})]}}))}))},j=function(){return r(void 0,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return"undefined"==typeof document?[2,!1]:[4,M()];case 1:return[4,e.sent().vessel.send({type:"action",action:"CheckAuthStatus"})];case 2:return[2,e.sent()]}}))}))},P=function(e){return r(void 0,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,I()];case 1:return[4,t.sent().request({method:"wallet_switchEthereumChain",params:[{chainId:"0x".concat(e.toString(16))}]})];case 2:return t.sent(),[2]}}))}))},T=function(e){return r(void 0,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,M()];case 1:return[4,t.sent().vessel.send({type:"action",action:"SendLoginCode",email:e})];case 2:return[2,t.sent()]}}))}))},z=function(e){return r(void 0,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,M()];case 1:return[4,t.sent().vessel.send({type:"action",action:"LoginWithCode",code:e})];case 2:return[2,t.sent()]}}))}))},R=function(){return r(void 0,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,M()];case 1:return[4,e.sent().vessel.send({type:"action",action:"CreateEmbeddedWallet"})];case 2:return[2,e.sent()]}}))}))},N=function(){return r(void 0,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,M()];case 1:return[4,e.sent().vessel.send({type:"action",action:"GetUser"})];case 2:return[2,e.sent()]}}))}))};export{a as DEV_OPENSEA_WALLET_URL,d as LOCAL_OPENSEA_WALLET_URL,c as PROD_OPENSEA_WALLET_URL,p as cancelMfaChallenge,x as connect,R as createWallet,W as disconnect,k as getAccounts,O as getChainId,q as getProvider,N as getUser,v as initMfaChallenge,m as initMfaEnrollmentWithSms,b as initMfaEnrollmentWithTotp,S as initialize,j as isAuthorized,z as loginWithCode,f as onMfaRequired,T as sendLoginCode,h as submitMfaChallenge,y as submitMfaEnrollmentWithSms,w as submitMfaEnrollmentWithTotp,P as switchChain};
import{EventEmitter as e}from"eventemitter3";import{Vessel as t}from"@opensea/vessel";var n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},n(e,t)};function r(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function u(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,u)}c((r=r.apply(e,t||[])).next())}))}function o(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return s.label++,{value:u[1],done:!1};case 5:s.label++,r=u[1],u=[0];continue;case 7:u=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){s=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){s.label=u[1];break}if(6===u[0]&&s.label<o[1]){s.label=o[1],o=u;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(u);break}o[2]&&s.ops.pop(),s.trys.pop();continue}u=t.call(e,s)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}"function"==typeof SuppressedError&&SuppressedError;var i=function(e){function t(t){var n=t.message,r=t.code,o=t.data,i=e.call(this,n)||this;return i.code=r,i.data=o,i}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(t,e),t}(Error),s=new e,u=function(){function e(e){var t=e.vessel;this.vessel=t,this.messageListener=this.handleInboundMessage.bind(this),this.vessel.addListener("message",this.messageListener)}return e.prototype.handleInboundMessage=function(e,t){return!!function(e){return!!e&&"object"==typeof e&&"type"in e&&"event"===e.type&&"event"in e&&"string"==typeof e.event}(e.payload)&&(s.emit(e.payload.event,e.payload.data),t(),!0)},e.prototype.request=function(e){return r(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.vessel.send({type:"action",action:"HeadlessRPCRequest",payload:e},{timeout:void 0})];case 1:return[2,n.sent()];case 2:if(t=n.sent(),(r=t)&&"object"==typeof r&&"message"in r&&"code"in r&&"number"==typeof r.code)throw new i(t);if(t instanceof Error)throw t.message="Error sending message to wallet: ".concat(t.message),t;throw new Error("Error sending message to wallet: ".concat(JSON.stringify(t)));case 3:return[2]}var r}))}))},e.prototype.on=function(e,t){s.on(e,t)},e.prototype.removeListener=function(e,t){s.removeListener(e,t)},e.prototype.disconnect=function(){return r(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.vessel.removeListener("message",this.messageListener),[4,this.vessel.send({type:"action",action:"Logout"})];case 1:return e.sent(),[2]}}))}))},e}(),c="https://wallets.opensea.io/hidden",a="https://dev-wallets.opensea.io/hidden",d="http://localhost:5001/hidden",l=new e,f=function(e){return l.addListener("mfa-required",e),function(){return l.removeListener("mfa-required",e)}},v=function(e){return r(void 0,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,M()];case 1:return[4,t.sent().vessel.send({type:"action",action:"InitMfa",mfaMethod:e},{timeout:void 0})];case 2:return[2,t.sent()]}}))}))},h=function(e,t){return r(void 0,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return[4,M()];case 1:return[4,n.sent().vessel.send({type:"action",action:"SubmitMfa",mfaCode:t,mfaMethod:e},{timeout:void 0})];case 2:return[2,n.sent()]}}))}))},p=function(){return r(void 0,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,M()];case 1:return[4,e.sent().vessel.send({type:"action",action:"CancelMfa"},{timeout:void 0})];case 2:return[2,e.sent()]}}))}))},m=function(e){return r(void 0,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,M()];case 1:return[4,t.sent().vessel.send({type:"action",action:"InitMfaEnrollmentWithSms",phoneNumber:e},{timeout:void 0})];case 2:return[2,t.sent()]}}))}))},y=function(e,t){return r(void 0,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return[4,M()];case 1:return[4,n.sent().vessel.send({type:"action",action:"SubmitMfaEnrollmentWithSms",phoneNumber:e,mfaCode:t},{timeout:void 0})];case 2:return[2,n.sent()]}}))}))},b=function(){return r(void 0,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,M()];case 1:return[4,e.sent().vessel.send({type:"action",action:"InitMfaEnrollmentWithTotp"},{timeout:void 0})];case 2:return[2,e.sent()]}}))}))},w=function(e){return r(void 0,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,M()];case 1:return[4,t.sent().vessel.send({type:"action",action:"SubmitMfaEnrollmentWithTotp",mfaCode:e},{timeout:void 0})];case 2:return[2,t.sent()]}}))}))},g=void 0,E=void 0,S=void 0,L=function(e){var n=void 0===e?{}:e,i=n.url,s=void 0===i?a:i,u=n.debug,c=void 0!==u&&u,d=n.retries,l=void 0===d?10:d;return r(void 0,void 0,void 0,(function(){var e;return o(this,(function(n){return S?[2,S]:"undefined"==typeof document?[2]:((g=null!==(e=document.querySelector("iframe#os-embedded-wallet-iframe"))&&void 0!==e?e:void 0)||((g=document.createElement("iframe")).src=s,g.hidden=!0,g.id="os-embedded-wallet-iframe",document.body.appendChild(g)),E=new t({iframe:g,targetOrigin:new URL(s).origin,debug:c,handshakeTimeout:1e3}),S=r(void 0,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,E.handshake()];case 1:return t.sent(),E.addListener("message",_),[3,3];case 2:if(e=t.sent(),S=void 0,l>0)return c&&console.debug("Retrying embedded wallet initialization (".concat(l-1," retries left)")),[2,L({url:s,debug:c,retries:l-1})];throw e;case 3:return[2]}}))})),[2,S])}))}))},M=function(){return r(void 0,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:if(!E)throw new Error("Wallet module not initialized");return[4,S];case 1:return e.sent(),[2,{vessel:E,iframe:g}]}}))}))},_=function(e,t){return!!((o=e.payload)&&"object"==typeof o&&"type"in o&&"action"===o.type&&"action"in o&&"PromptMfa"===o.action)&&(n=e.payload.mfaMethods,r=function(){return t({success:!0})},l.emit("mfa-required",n,r),!0);var n,r,o},C=void 0,q=function(){return r(void 0,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return"undefined"==typeof document?[2,void 0]:[4,M()];case 1:return e=t.sent().vessel,C||(C=new u({vessel:e})),[2,C]}}))}))},I=function(){return r(void 0,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return[4,q()];case 1:if(!(e=t.sent()))throw new Error("Wallet module not initialized");return[2,e]}}))}))},x=function(){return r(void 0,void 0,void 0,(function(){var e,t,n,r;return o(this,(function(o){switch(o.label){case 0:return"undefined"==typeof document?[2,{accounts:[],chainId:1}]:[4,I()];case 1:return e=o.sent(),[4,Promise.all([e.request({method:"eth_accounts"}),e.request({method:"eth_chainId"})])];case 2:return t=o.sent(),n=t[0],r=t[1],[2,{accounts:n,chainId:r}]}}))}))},W=function(){return r(void 0,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,I()];case 1:return[4,e.sent().disconnect()];case 2:return e.sent(),[2]}}))}))},k=function(){return r(void 0,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return"undefined"==typeof document?[2,[]]:[4,I()];case 1:return[2,e.sent().request({method:"eth_accounts"})]}}))}))},O=function(){return r(void 0,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return"undefined"==typeof document?[2,1]:[4,I()];case 1:return e=t.sent(),[2,e.request({method:"eth_chainId"})]}}))}))},j=function(){return r(void 0,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return"undefined"==typeof document?[2,!1]:[4,M()];case 1:return[4,e.sent().vessel.send({type:"action",action:"CheckAuthStatus"})];case 2:return[2,e.sent()]}}))}))},P=function(e){return r(void 0,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,I()];case 1:return[4,t.sent().request({method:"wallet_switchEthereumChain",params:[{chainId:"0x".concat(e.toString(16))}]})];case 2:return t.sent(),[2]}}))}))},T=function(e){return r(void 0,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,M()];case 1:return[4,t.sent().vessel.send({type:"action",action:"SendLoginCode",email:e})];case 2:return[2,t.sent()]}}))}))},R=function(e){return r(void 0,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,M()];case 1:return[4,t.sent().vessel.send({type:"action",action:"LoginWithCode",code:e})];case 2:return[2,t.sent()]}}))}))},z=function(){return r(void 0,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,M()];case 1:return[4,e.sent().vessel.send({type:"action",action:"CreateEmbeddedWallet"})];case 2:return[2,e.sent()]}}))}))},N=function(){return r(void 0,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,M()];case 1:return[4,e.sent().vessel.send({type:"action",action:"GetUser"})];case 2:return[2,e.sent()]}}))}))};export{a as DEV_OPENSEA_WALLET_URL,d as LOCAL_OPENSEA_WALLET_URL,c as PROD_OPENSEA_WALLET_URL,p as cancelMfaChallenge,x as connect,z as createWallet,W as disconnect,k as getAccounts,O as getChainId,q as getProvider,N as getUser,v as initMfaChallenge,m as initMfaEnrollmentWithSms,b as initMfaEnrollmentWithTotp,L as initialize,j as isAuthorized,R as loginWithCode,f as onMfaRequired,T as sendLoginCode,h as submitMfaChallenge,y as submitMfaEnrollmentWithSms,w as submitMfaEnrollmentWithTotp,P as switchChain};
//# sourceMappingURL=index.js.map
{
"name": "@opensea/embedded-wallet-sdk",
"version": "0.1.14",
"version": "0.1.15",
"description": "SDK for interacting with the OpenSea wallet product",

@@ -5,0 +5,0 @@ "license": "ISC",

@@ -18,3 +18,3 @@ import { Vessel, VesselMessage } from "@opensea/vessel"

debug = false,
retries = 1,
retries = 10,
}: InitializeOptions = {}): Promise<void> => {

@@ -28,8 +28,15 @@ if (initializationPromise) {

}
iframe = document.createElement("iframe")
iframe.src = url
iframe.hidden = true
iframe.id = "os-embedded-wallet-iframe"
document.body.appendChild(iframe)
iframe =
document.querySelector<HTMLIFrameElement>(
"iframe#os-embedded-wallet-iframe",
) ?? undefined
if (!iframe) {
iframe = document.createElement("iframe")
iframe.src = url
iframe.hidden = true
iframe.id = "os-embedded-wallet-iframe"
document.body.appendChild(iframe)
}
vessel = new Vessel({

@@ -39,3 +46,7 @@ iframe,

debug,
handshakeTimeout: 5_000,
/**
* Handshake failure is usually due to hydration errors where iframe is removed from document.
* So fail quickly and find the iframe or add it to the document again in a retry.
*/
handshakeTimeout: 1_000,
})

@@ -47,9 +58,10 @@ initializationPromise = (async () => {

} catch (error) {
console.error("Error initializing embedded wallet", error)
initializationPromise = undefined
if (retries > 0) {
// eslint-disable-next-line no-console
console.debug(
`Retrying embedded wallet initialization (${retries} retries left)`,
)
if (debug) {
// eslint-disable-next-line no-console
console.debug(
`Retrying embedded wallet initialization (${retries - 1} retries left)`,
)
}
return initialize({ url, debug, retries: retries - 1 })

@@ -56,0 +68,0 @@ }

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc