@opensea/embedded-wallet-sdk
Advanced tools
Comparing version 0.1.11 to 0.1.12
@@ -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(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",f=new e,l=function(e){return f.addListener("mfa-required",e),function(){return f.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()]}}))}))},w=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()]}}))}))},b=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,L=void 0,S=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;return r(void 0,void 0,void 0,(function(){return o(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}),L=r(void 0,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,E.handshake()];case 1:return e.sent(),E.addListener("message",_),[2]}}))})),[2,L])}))}))},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,L];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})},f.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}]}}))}))},O=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]}}))}))},W=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"})]}}))}))},j=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"})]}}))}))},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,!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]}}))}))},N=function(e,t){var n=t.sendForNewUser;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,sendForNewUser:n})];case 2:return[2,t.sent()]}}))}))},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:"LoginWithCode",code:e})];case 2:return[2,t.sent()]}}))}))},U=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,O as disconnect,W as getAccounts,j as getChainId,q as getProvider,U as getUser,v as initMfaChallenge,m as initMfaEnrollmentWithSms,w as initMfaEnrollmentWithTotp,S as initialize,k as isAuthorized,T as loginWithCode,l as onMfaRequired,N as sendLoginCode,h as submitMfaChallenge,y as submitMfaEnrollmentWithSms,b 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",f=new e,l=function(e){return f.addListener("mfa-required",e),function(){return f.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()]}}))}))},w=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()]}}))}))},b=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,L=void 0,S=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;return r(void 0,void 0,void 0,(function(){return o(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}),L=r(void 0,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,E.handshake()];case 1:return e.sent(),E.addListener("message",_),[2]}}))})),[2,L])}))}))},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,L];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})},f.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]}}))}))},O=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"})]}}))}))},j=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"})]}}))}))},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,!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()]}}))}))},N=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()]}}))}))},R=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()]}}))}))},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:"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,O as getAccounts,j as getChainId,q as getProvider,z as getUser,v as initMfaChallenge,m as initMfaEnrollmentWithSms,w as initMfaEnrollmentWithTotp,S as initialize,k as isAuthorized,N as loginWithCode,l as onMfaRequired,T as sendLoginCode,h as submitMfaChallenge,y as submitMfaEnrollmentWithSms,b as submitMfaEnrollmentWithTotp,P as switchChain}; | ||
//# sourceMappingURL=index.js.map |
import { EventEmitter } from "eventemitter3"; | ||
export type EventName = "message" | "connect" | "disconnect" | "accountsChanged" | "chainChanged"; | ||
interface ProviderMessage { | ||
type ProviderMessage = { | ||
readonly type: string; | ||
readonly data: unknown; | ||
} | ||
interface ProviderConnectInfo { | ||
}; | ||
type ProviderConnectInfo = { | ||
readonly chainId: string; | ||
} | ||
export interface EventCallbackByEventName { | ||
}; | ||
export type EventCallbackByEventName = { | ||
message: (message: ProviderMessage) => void; | ||
@@ -16,10 +16,10 @@ connect: (connectInfo: ProviderConnectInfo) => void; | ||
chainChanged: (chainId: string) => void; | ||
} | ||
}; | ||
export declare const emitter: EventEmitter<string | symbol, any>; | ||
interface EventMessage { | ||
type EventMessage = { | ||
event: EventName; | ||
data?: unknown; | ||
} | ||
}; | ||
export declare const isEventMessage: (message: unknown) => message is EventMessage; | ||
export {}; | ||
//# sourceMappingURL=events.d.ts.map |
import { Vessel } from "@opensea/vessel"; | ||
interface InitializeOptions { | ||
type InitializeOptions = { | ||
url?: string; | ||
debug?: boolean; | ||
} | ||
}; | ||
export declare const initialize: ({ url, debug, }?: InitializeOptions) => Promise<void>; | ||
@@ -7,0 +7,0 @@ export declare const getState: () => Promise<{ |
@@ -1,9 +0,9 @@ | ||
import { GetUserResponse, SendLoginCodeResponse } from "@opensea/wallet-messages"; | ||
import { CreateEmbeddedWalletResponse, GetUserResponse, LoginWithCodeResponse, SendLoginCodeResponse } from "@opensea/wallet-messages"; | ||
import { EIP1193Provider } from "./EIP1193Provider"; | ||
export declare const getProvider: () => Promise<EIP1193Provider | undefined>; | ||
type Address = `0x${string}`; | ||
interface ConnectResponse { | ||
type ConnectResponse = { | ||
accounts: readonly Address[]; | ||
chainId: number; | ||
} | ||
}; | ||
export declare const connect: () => Promise<ConnectResponse>; | ||
@@ -15,11 +15,7 @@ export declare const disconnect: () => Promise<void>; | ||
export declare const switchChain: (chainId: number) => Promise<void>; | ||
export declare const sendLoginCode: (email: string, { sendForNewUser }: { | ||
sendForNewUser: boolean; | ||
}) => Promise<SendLoginCodeResponse>; | ||
export declare const loginWithCode: (code: string) => Promise<{ | ||
accessToken: string; | ||
privyId: string; | ||
}>; | ||
export declare const sendLoginCode: (email: string) => Promise<SendLoginCodeResponse>; | ||
export declare const loginWithCode: (code: string) => Promise<LoginWithCodeResponse>; | ||
export declare const createWallet: () => Promise<CreateEmbeddedWalletResponse>; | ||
export declare const getUser: () => Promise<GetUserResponse>; | ||
export {}; | ||
//# sourceMappingURL=sdk.d.ts.map |
import React from "react"; | ||
export interface ChildProps { | ||
export type ChildProps = { | ||
emitEvents?: boolean; | ||
} | ||
}; | ||
export declare const Child: ({ emitEvents }: ChildProps) => React.JSX.Element; | ||
//# sourceMappingURL=Child.d.ts.map |
import React from "react"; | ||
export interface ParentProps { | ||
export type ParentProps = { | ||
url: string; | ||
} | ||
}; | ||
export declare const Parent: ({ url }: ParentProps) => React.JSX.Element; | ||
//# sourceMappingURL=Parent.d.ts.map |
{ | ||
"name": "@opensea/embedded-wallet-sdk", | ||
"version": "0.1.11", | ||
"version": "0.1.12", | ||
"description": "SDK for interacting with the OpenSea wallet product", | ||
@@ -46,3 +46,3 @@ "license": "ISC", | ||
"typescript": "^5.2.2", | ||
"@opensea/wallet-messages": "0.0.21", | ||
"@opensea/wallet-messages": "0.0.22", | ||
"eslint-config-custom": "0.0.0" | ||
@@ -49,0 +49,0 @@ }, |
@@ -10,3 +10,3 @@ import { EventEmitter } from "eventemitter3" | ||
interface ProviderMessage { | ||
type ProviderMessage = { | ||
readonly type: string | ||
@@ -16,7 +16,7 @@ readonly data: unknown | ||
interface ProviderConnectInfo { | ||
type ProviderConnectInfo = { | ||
readonly chainId: string | ||
} | ||
export interface EventCallbackByEventName { | ||
export type EventCallbackByEventName = { | ||
message: (message: ProviderMessage) => void | ||
@@ -31,3 +31,3 @@ connect: (connectInfo: ProviderConnectInfo) => void | ||
interface EventMessage { | ||
type EventMessage = { | ||
event: EventName | ||
@@ -34,0 +34,0 @@ data?: unknown |
@@ -9,3 +9,3 @@ import { Vessel, VesselMessage } from "@opensea/vessel" | ||
interface InitializeOptions { | ||
type InitializeOptions = { | ||
url?: string | ||
@@ -12,0 +12,0 @@ debug?: boolean |
import { | ||
CreateEmbeddedWalletPayload, | ||
CreateEmbeddedWalletResponse, | ||
GetUserResponse, | ||
LoginWithCodeResponse, | ||
SendLoginCodePayload, | ||
@@ -32,3 +35,3 @@ SendLoginCodeResponse, | ||
interface ConnectResponse { | ||
type ConnectResponse = { | ||
accounts: readonly Address[] | ||
@@ -94,3 +97,2 @@ chainId: number | ||
email: string, | ||
{ sendForNewUser }: { sendForNewUser: boolean }, | ||
): Promise<SendLoginCodeResponse> => { | ||
@@ -102,3 +104,2 @@ const { vessel } = await getState() | ||
email, | ||
sendForNewUser, | ||
}) | ||
@@ -109,6 +110,3 @@ } | ||
code: string, | ||
): Promise<{ | ||
accessToken: string | ||
privyId: string | ||
}> => { | ||
): Promise<LoginWithCodeResponse> => { | ||
const { vessel } = await getState() | ||
@@ -122,2 +120,13 @@ return await vessel.send({ | ||
export const createWallet = async (): Promise<CreateEmbeddedWalletResponse> => { | ||
const { vessel } = await getState() | ||
return await vessel.send< | ||
CreateEmbeddedWalletResponse, | ||
CreateEmbeddedWalletPayload | ||
>({ | ||
type: "action", | ||
action: "CreateEmbeddedWallet", | ||
}) | ||
} | ||
export const getUser = async (): Promise<GetUserResponse> => { | ||
@@ -124,0 +133,0 @@ const { vessel } = await getState() |
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
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
Sorry, the diff of this file is not supported yet
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
242043
645
0