@toruslabs/torus-embed
Advanced tools
Comparing version 0.1.2 to 0.2.0
@@ -7,6 +7,17 @@ "use strict"; | ||
exports.default = void 0; | ||
var enums = { | ||
GOOGLE: 'google', | ||
FACEBOOK: 'facebook', | ||
TWITCH: 'twitch', | ||
REDDIT: 'reddit', | ||
DISCORD: 'discord' | ||
}; | ||
var verifierList = Object.values(enums); | ||
var _default = { | ||
torusNodeEndpoints: ['https://binancelabs-main-2.tor.us/jrpc', 'https://waseda-main-2.tor.us/jrpc', 'https://vgr-main-2.torusnode.com/jrpc', 'https://torus-main-2.torusnode.com/jrpc', 'https://etc-main-2.tor.us/jrpc'], | ||
networkList: ['mainnet', 'rinkeby', 'ropsten', 'kovan', 'goerli', 'localhost', 'matic'] | ||
torusNodeEndpoints: ['https://binance-main-3.torusnode.com/jrpc', 'https://waseda-main-3.torusnode.com/jrpc', 'https://vgr-main-3.torusnode.com/jrpc', 'https://torus-main-3.torusnode.com/jrpc', 'https://etc-main-3.torusnode.com/jrpc'], | ||
networkList: ['mainnet', 'rinkeby', 'ropsten', 'kovan', 'goerli', 'localhost', 'matic'], | ||
enums: enums, | ||
verifierList: verifierList, | ||
supportedVerifierList: [enums.GOOGLE, enums.REDDIT, enums.DISCORD] | ||
}; | ||
exports.default = _default; |
@@ -8,3 +8,3 @@ import Web3 from 'web3' | ||
ethereum: Provider | ||
getPublicAddress(email: string): Promise<string>; | ||
getPublicAddress(verifierArgs: VerifierArgs): Promise<string>; | ||
setProvider(networkParams: NetworkInterface): Promise<void>; | ||
@@ -16,3 +16,3 @@ showWallet(path: 'transfer' | 'topup' | 'home' | 'settings' | 'history'): void | ||
init(params: TorusParams): Promise<void> | ||
login(): Promise<string[]> | ||
login(params: LoginParams): Promise<string[]> | ||
logout(): Promise<void> | ||
@@ -26,2 +26,11 @@ cleanUp(): Promise<void> | ||
interface VerifierArgs { | ||
verifier: 'google' | 'reddit' | 'discord' | ||
verifierId: string | ||
} | ||
interface LoginParams { | ||
verifier?: 'google' | 'facebook' | 'twitch' | 'reddit' | 'discord' | ||
} | ||
interface TorusCtorArgs { | ||
@@ -28,0 +37,0 @@ buttonPosition?: 'top-left' | 'top-right' | 'bottom-right' | 'bottom-left' |
@@ -35,3 +35,3 @@ "use strict"; | ||
cleanContextForImports(); | ||
var iframeIntegrity = 'sha384-qRzrb3+BvNdUdclRzy68s/YntoRL3szmAW/y46KtER5feGtN94RbNkZn4H+1lByn'; | ||
var iframeIntegrity = 'sha384-MLn61IOJDOfand28zoBPXp9NnTKbWO1PQP5zPo9a3LPYoJYQ6jQLpFHIDgZtrGSP'; | ||
restoreContextAfterImports(); | ||
@@ -55,2 +55,5 @@ | ||
this.torusIframe = {}; | ||
this.torusLoginModal = {}; | ||
this.torusSpeedDial = {}; | ||
this.keyBtn = {}; | ||
this.styleLink = {}; | ||
@@ -64,2 +67,4 @@ this.isRehydrated = false; // rehydrated | ||
this.torusButtonVisibility = true; | ||
this.requestedVerifier = ''; | ||
this.currentVerifier = ''; | ||
this.Web3 = _web.default; | ||
@@ -94,3 +99,3 @@ } | ||
case 'staging': | ||
torusUrl = 'https://staging.tor.us/v0.1.1'; | ||
torusUrl = 'https://staging.tor.us/v0.1.2'; | ||
logLevel = 'info'; | ||
@@ -110,3 +115,3 @@ break; | ||
default: | ||
torusUrl = 'https://app.tor.us/v0.1.2'; | ||
torusUrl = 'https://app.tor.us/v0.2.0'; | ||
logLevel = 'error'; | ||
@@ -148,2 +153,4 @@ break; | ||
resolve(); | ||
}).catch(function (err) { | ||
return reject(err); | ||
}); | ||
@@ -170,2 +177,4 @@ }); | ||
resolve(); | ||
}).catch(function (err) { | ||
return reject(err); | ||
}); | ||
@@ -183,5 +192,16 @@ }); | ||
value: function login() { | ||
var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
verifier = _ref3.verifier; | ||
if (!this.isInitalized) throw new Error('Call init() first'); | ||
if (this.isLoggedIn) throw new Error('User has already logged in');else { | ||
if (this.isLoggedIn) throw new Error('User has already logged in'); | ||
if (!verifier) { | ||
this.requestedVerifier = ''; | ||
return this.ethereum.enable(); | ||
} else if (_config.default.verifierList.includes(verifier)) { | ||
this.requestedVerifier = verifier; | ||
return this.ethereum.enable(); | ||
} else { | ||
throw new Error('Unsupported verifier'); | ||
} | ||
@@ -212,2 +232,4 @@ } | ||
_this2.isRehydrated = false; | ||
_this2.currentVerifier = ''; | ||
_this2.requestedVerifier = ''; | ||
resolve(); | ||
@@ -268,2 +290,3 @@ } else reject(new Error('Some Error Occured')); | ||
this.torusLoadingBtn = {}; | ||
this.torusLoginModal = {}; | ||
} | ||
@@ -318,17 +341,44 @@ | ||
this.torusSpeedDial = (0, _embedUtils.htmlToElement)('<ul class="speed-dial-list">'); | ||
this.homeBtn = (0, _embedUtils.htmlToElement)('<li><button class="torus-btn torus-btn--home"></button></li>'); | ||
this.torusSpeedDial = (0, _embedUtils.htmlToElement)('<ul class="speed-dial-list" style="transition-delay: 0.05s">'); | ||
this.torusSpeedDial.style.opacity = '0'; | ||
var homeBtn = (0, _embedUtils.htmlToElement)('<li><button class="torus-btn torus-btn--home" title="Wallet Home Page"></button></li>'); | ||
var tooltipNote = (0, _embedUtils.htmlToElement)('<div class="tooltip-text tooltip-note">Copy public address to clipboard</div>'); | ||
var tooltipCopied = (0, _embedUtils.htmlToElement)('<div class="tooltip-text tooltip-copied">Copied!</div>'); | ||
this.keyBtn = (0, _embedUtils.htmlToElement)('<button class="torus-btn torus-btn--text">0xe5..</button>'); | ||
this.keyContainer = (0, _embedUtils.htmlToElement)('<li class="tooltip"></li>'); | ||
this.keyContainer.appendChild(this.keyBtn); | ||
this.keyContainer.appendChild(tooltipNote); | ||
this.keyContainer.appendChild(tooltipCopied); | ||
this.transferBtn = (0, _embedUtils.htmlToElement)('<li><button class="torus-btn torus-btn--transfer"></button></li>'); | ||
this.torusSpeedDial.appendChild(this.homeBtn); | ||
this.torusSpeedDial.appendChild(this.keyContainer); | ||
this.torusSpeedDial.appendChild(this.transferBtn); | ||
this.torusWidget.prepend(this.torusSpeedDial); // Iframe code | ||
var keyContainer = (0, _embedUtils.htmlToElement)('<li class="tooltip"></li>'); | ||
keyContainer.appendChild(this.keyBtn); | ||
keyContainer.appendChild(tooltipNote); | ||
keyContainer.appendChild(tooltipCopied); | ||
var transferBtn = (0, _embedUtils.htmlToElement)('<li><button class="torus-btn torus-btn--transfer" title="Wallet Transfer Page"></button></li>'); | ||
this.torusSpeedDial.appendChild(homeBtn); | ||
this.torusSpeedDial.appendChild(keyContainer); | ||
this.torusSpeedDial.appendChild(transferBtn); | ||
this.torusWidget.prepend(this.torusSpeedDial); // Multiple login modal | ||
this.torusLoginModal = (0, _embedUtils.htmlToElement)('<div id="login-modal" class="login-modal"></div>'); | ||
this.torusLoginModal.style.display = 'none'; | ||
var modalContainer = (0, _embedUtils.htmlToElement)('<div class="modal-container"><div class="close-container"><span id="close" class="close">×</span></div></div>'); | ||
var modalContent = (0, _embedUtils.htmlToElement)('<div class="modal-content">' + '<div class="logo-container"><img src="' + torusUrl + '/images/torus-logo-blue.svg' + '"></div>' + '<div><h1 class="login-header">Login to Torus</h1>' + '<p class="login-subtitle">You are just one step away from getting your digital wallet for your cryptocurrencies</p></div>' + '</div>'); | ||
this.googleLogin = (0, _embedUtils.htmlToElement)('<button id="login-google" class="login-google"><img src="' + torusUrl + '/img/icons/google.svg' + '">Sign in with Google</button>'); | ||
var otherAccount = (0, _embedUtils.htmlToElement)('<div>Or, use another account:</div>'); // List for other logins | ||
var loginList = (0, _embedUtils.htmlToElement)('<ul id="login-list" class="login-list"></ul>'); | ||
this.facebookLogin = (0, _embedUtils.htmlToElement)('<li><button id="login-facebook" class="login-btn login-btn--facebook" title="Login with Facebook"><img src="' + torusUrl + '/img/icons/facebook.svg' + '"></button></li>'); | ||
this.twitchLogin = (0, _embedUtils.htmlToElement)('<li><button id="login-twitch" class="login-btn login-btn--twitch" title="Login with Twitch"><img src="' + torusUrl + '/img/icons/twitch.svg' + '"></button></li>'); | ||
this.redditLogin = (0, _embedUtils.htmlToElement)('<li><button id="login-reddit" class="login-btn login-btn--reddit" title="Login with Reddit"><img src="' + torusUrl + '/img/icons/reddit.svg' + '"></button></li>'); | ||
this.discordLogin = (0, _embedUtils.htmlToElement)('<li><button id="login-discord" class="login-btn login-btn--discord" title="Login with Discord"><img src="' + torusUrl + '/img/icons/discord.svg' + '"></button></li>'); | ||
loginList.appendChild(this.facebookLogin); | ||
loginList.appendChild(this.twitchLogin); | ||
loginList.appendChild(this.redditLogin); | ||
loginList.appendChild(this.discordLogin); | ||
modalContent.appendChild(this.googleLogin); | ||
modalContent.appendChild(otherAccount); | ||
modalContent.appendChild(loginList); | ||
var loginNote = (0, _embedUtils.htmlToElement)('<div class="login-note">By clicking Login, you accept our ' + '<a href="https://docs.tor.us/legal/terms-and-conditions" target="_blank">Terms and Conditions</a></div>'); | ||
modalContent.appendChild(loginNote); | ||
modalContainer.appendChild(modalContent); | ||
this.torusLoginModal.appendChild(modalContainer); // Append login codes to widget | ||
this.torusWidget.appendChild(this.torusLoginModal); // Iframe code | ||
this.torusIframe = (0, _embedUtils.htmlToElement)('<iframe id="torusIframe" frameBorder="0" src="' + torusUrl + '/popup"></iframe>'); // Setup on load code | ||
@@ -338,8 +388,6 @@ | ||
_this4.torusLogin.addEventListener('click', function () { | ||
_this4._showLoadingAndHideGoogleAndTorus(); | ||
_this4._showLoginPopup(false); | ||
}); | ||
_this4.homeBtn.addEventListener('click', function () { | ||
homeBtn.addEventListener('click', function () { | ||
_this4.showWallet(); | ||
@@ -349,4 +397,3 @@ | ||
}); | ||
_this4.transferBtn.addEventListener('click', function () { | ||
transferBtn.addEventListener('click', function () { | ||
_this4.showWallet('transfer'); | ||
@@ -382,2 +429,9 @@ | ||
_this4._toggleSpeedDial(); | ||
}); // Login Modal Listeners | ||
modalContainer.querySelector('#close').addEventListener('click', function () { | ||
_this4.torusLoginModal.style.display = 'none'; | ||
if (_this4.modalCloseHandler) _this4.modalCloseHandler(); | ||
delete _this4.modalCloseHandler; | ||
}); | ||
@@ -423,28 +477,25 @@ }; | ||
}, { | ||
key: "_showLoadingAndHideGoogleAndTorus", | ||
value: function _showLoadingAndHideGoogleAndTorus() { | ||
if (this.torusButtonVisibility) { | ||
this.torusLoadingBtn.style.display = 'block'; | ||
this.torusMenuBtn.style.display = 'none'; | ||
this.torusLogin.style.display = 'none'; | ||
} | ||
key: "_showLoggedOut", | ||
value: function _showLoggedOut() { | ||
this.torusMenuBtn.style.display = 'none'; | ||
this.torusLogin.style.display = this.torusButtonVisibility ? 'block' : 'none'; | ||
this.torusLoadingBtn.style.display = 'none'; | ||
this.torusLoginModal.style.display = 'none'; | ||
this.torusSpeedDial.style.opacity = '0'; | ||
} | ||
}, { | ||
key: "_showTorusButtonAndHideGoogle", | ||
value: function _showTorusButtonAndHideGoogle() { | ||
if (this.torusButtonVisibility) { | ||
// torusIframeContainer.style.display = 'none' | ||
this.torusLoadingBtn.style.display = 'none'; | ||
this.torusMenuBtn.style.display = 'block'; | ||
this.torusLogin.style.display = 'none'; | ||
} | ||
key: "_showLoggingIn", | ||
value: function _showLoggingIn() { | ||
this.torusMenuBtn.style.display = 'none'; | ||
this.torusLogin.style.display = 'none'; | ||
this.torusLoadingBtn.style.display = this.torusButtonVisibility ? 'block' : 'none'; | ||
this.torusLoginModal.style.display = this.requestedVerifier === '' ? 'block' : 'none'; | ||
} | ||
}, { | ||
key: "_hideTorusButtonAndShowGoogle", | ||
value: function _hideTorusButtonAndShowGoogle() { | ||
if (this.torusButtonVisibility) { | ||
this.torusLoadingBtn.style.display = 'none'; | ||
this.torusLogin.style.display = 'block'; | ||
this.torusMenuBtn.style.display = 'none'; | ||
} | ||
key: "_showLoggedIn", | ||
value: function _showLoggedIn() { | ||
this.torusMenuBtn.style.display = this.torusButtonVisibility ? 'block' : 'none'; | ||
this.torusLogin.style.display = 'none'; | ||
this.torusLoadingBtn.style.display = 'none'; | ||
this.torusLoginModal.style.display = 'none'; | ||
} | ||
@@ -459,5 +510,6 @@ /** | ||
this.torusButtonVisibility = false; | ||
this.torusLoadingBtn.style.display = 'none'; | ||
this.torusMenuBtn.style.display = 'none'; | ||
this.torusLogin.style.display = 'none'; | ||
this.torusLoadingBtn.style.display = 'none'; | ||
this.torusSpeedDial.style.opacity = '0'; | ||
} | ||
@@ -473,3 +525,3 @@ /** | ||
this.torusButtonVisibility = true; | ||
if (this.isLoggedIn) this._showTorusButtonAndHideGoogle();else this._hideTorusButtonAndShowGoogle(); | ||
if (this.isLoggedIn) this._showLoggedIn();else this._showLoggedOut(); | ||
} | ||
@@ -508,4 +560,4 @@ }, { | ||
inpageProvider[m] = function (_ref3) { | ||
var method = _ref3.method; | ||
inpageProvider[m] = function (_ref4) { | ||
var method = _ref4.method; | ||
@@ -525,3 +577,3 @@ if (method === 'eth_requestAccounts') { | ||
inpageProvider.enable = function () { | ||
_this5._showLoadingAndHideGoogleAndTorus(); | ||
_this5._showLoggingIn(); | ||
@@ -538,3 +590,3 @@ return new Promise(function (resolve, reject) { | ||
setTimeout(function () { | ||
self._showTorusButtonAndHideGoogle(); | ||
self._showLoggedOut(); | ||
@@ -546,24 +598,26 @@ reject(err); | ||
// else wait for something to be written to status stream | ||
if (this.isRehydrated) { | ||
resolve(res); | ||
var handleRehydration = function handleRehydration() { | ||
_this6.isLoggedIn = true; | ||
self._showTorusButtonAndHideGoogle(); | ||
if (_this6.requestedVerifier !== '' && _this6.currentVerifier !== _this6.requestedVerifier) { | ||
var requestedVerifier = _this6.requestedVerifier; | ||
this.isLoggedIn = true; | ||
} else { | ||
var _statusStream = this.communicationMux.getStream('status'); | ||
_this6.logout().then(function (_) { | ||
_this6.requestedVerifier = requestedVerifier; | ||
var statusStreamHandler = function statusStreamHandler(status) { | ||
if (status.loggedIn) { | ||
_this6.isRehydrated = true; | ||
_this6.isLoggedIn = true; | ||
resolve(res); | ||
} else reject(new Error('User has not logged in yet')); | ||
_this6._showLoginPopup(true, resolve, reject); | ||
}).catch(function (err) { | ||
return reject(err); | ||
}); | ||
} else { | ||
self._showLoggedIn(); | ||
self._showTorusButtonAndHideGoogle(); | ||
resolve(res); | ||
} | ||
}; | ||
_statusStream.removeListener('data', statusStreamHandler); | ||
}; | ||
_statusStream.on('data', statusStreamHandler); | ||
if (this.isRehydrated) { | ||
handleRehydration(); | ||
} else { | ||
this.isRehydratedCallback = handleRehydration; | ||
} | ||
@@ -595,9 +649,19 @@ } else { | ||
// rehydration | ||
if (status.rehydrate && status.loggedIn) _this5.isRehydrated = status.rehydrate; // normal login | ||
if (status.rehydrate && status.loggedIn) { | ||
_this5.isRehydrated = status.rehydrate; | ||
_this5.currentVerifier = status.verifier; | ||
if (_this5.isRehydratedCallback) { | ||
_this5.isRehydratedCallback(); | ||
delete _this5.isRehydratedCallback; | ||
} | ||
} // normal login | ||
else if (status.loggedIn) { | ||
_this5.isLoggedIn = status.loggedIn; | ||
_this5.currentVerifier = status.verifier; | ||
_this5._showTorusButtonAndHideGoogle(); | ||
_this5._showLoggedIn(); | ||
} // logout | ||
else _this5._hideTorusButtonAndShowGoogle(); | ||
else _this5._showLoggedOut(); | ||
}); // if (typeof window.web3 !== 'undefined') { | ||
@@ -635,32 +699,95 @@ // console.log(`Torus detected another web3. | ||
value: function _showLoginPopup(calledFromEmbed, resolve, reject) { | ||
var oauthStream = this.communicationMux.getStream('oauth'); | ||
var self = this; | ||
var _this7 = this; | ||
var handler = function handler(data) { | ||
var err = data.err, | ||
selectedAddress = data.selectedAddress; | ||
this._showLoggingIn(); | ||
if (err) { | ||
_loglevel.default.error(err); | ||
if (this.requestedVerifier === undefined || this.requestedVerifier === '') { | ||
this.modalCloseHandler = function () { | ||
_this7._showLoggedOut(); | ||
self._hideTorusButtonAndShowGoogle(); | ||
if (reject) reject(new Error('Modal has been closed')); | ||
}; | ||
if (reject) reject(err); | ||
} else { | ||
// returns an array (cause accounts expects it) | ||
if (resolve) resolve([(0, _embedUtils.transformEthAddress)(selectedAddress)]); | ||
var googleHandler = function googleHandler() { | ||
_this7.requestedVerifier = _config.default.enums.GOOGLE; | ||
self._showTorusButtonAndHideGoogle(); | ||
} | ||
_this7.googleLogin.removeEventListener('click', googleHandler); | ||
oauthStream.removeListener('data', handler); | ||
}; | ||
_this7._showLoginPopup(calledFromEmbed, resolve, reject); | ||
}; | ||
oauthStream.on('data', handler); | ||
oauthStream.write({ | ||
name: 'oauth', | ||
data: { | ||
calledFromEmbed: calledFromEmbed | ||
} | ||
}); | ||
this.googleLogin.addEventListener('click', googleHandler); | ||
var facebookHandler = function facebookHandler() { | ||
_this7.requestedVerifier = _config.default.enums.FACEBOOK; | ||
_this7.facebookLogin.removeEventListener('click', facebookHandler); | ||
_this7._showLoginPopup(calledFromEmbed, resolve, reject); | ||
}; | ||
this.facebookLogin.addEventListener('click', facebookHandler); | ||
var twitchHandler = function twitchHandler() { | ||
_this7.requestedVerifier = _config.default.enums.TWITCH; | ||
_this7.twitchLogin.removeEventListener('click', twitchHandler); | ||
_this7._showLoginPopup(calledFromEmbed, resolve, reject); | ||
}; | ||
this.twitchLogin.addEventListener('click', twitchHandler); | ||
var redditHandler = function redditHandler() { | ||
_this7.requestedVerifier = _config.default.enums.REDDIT; | ||
_this7.redditLogin.removeEventListener('click', redditHandler); | ||
_this7._showLoginPopup(calledFromEmbed, resolve, reject); | ||
}; | ||
this.redditLogin.addEventListener('click', redditHandler); | ||
var discordHandler = function discordHandler() { | ||
_this7.requestedVerifier = _config.default.enums.DISCORD; | ||
_this7.discordLogin.removeEventListener('click', discordHandler); | ||
_this7._showLoginPopup(calledFromEmbed, resolve, reject); | ||
}; | ||
this.discordLogin.addEventListener('click', discordHandler); | ||
} else { | ||
var oauthStream = this.communicationMux.getStream('oauth'); | ||
var self = this; | ||
var handler = function handler(data) { | ||
var err = data.err, | ||
selectedAddress = data.selectedAddress; | ||
if (err) { | ||
_loglevel.default.error(err); | ||
self._showLoggedOut(); | ||
if (reject) reject(err); | ||
} else { | ||
// returns an array (cause accounts expects it) | ||
if (resolve) resolve([(0, _embedUtils.transformEthAddress)(selectedAddress)]); | ||
self._showLoggedIn(); | ||
} | ||
oauthStream.removeListener('data', handler); | ||
}; | ||
oauthStream.on('data', handler); | ||
oauthStream.write({ | ||
name: 'oauth', | ||
data: { | ||
calledFromEmbed: calledFromEmbed, | ||
verifier: this.requestedVerifier | ||
} | ||
}); | ||
} | ||
} | ||
@@ -670,16 +797,16 @@ }, { | ||
value: function setProvider() { | ||
var _this7 = this; | ||
var _this8 = this; | ||
var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
_ref4$host = _ref4.host, | ||
host = _ref4$host === void 0 ? 'mainnet' : _ref4$host, | ||
_ref4$chainId = _ref4.chainId, | ||
chainId = _ref4$chainId === void 0 ? 1 : _ref4$chainId, | ||
_ref4$networkName = _ref4.networkName, | ||
networkName = _ref4$networkName === void 0 ? 'mainnet' : _ref4$networkName; | ||
var _ref5 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
_ref5$host = _ref5.host, | ||
host = _ref5$host === void 0 ? 'mainnet' : _ref5$host, | ||
_ref5$chainId = _ref5.chainId, | ||
chainId = _ref5$chainId === void 0 ? 1 : _ref5$chainId, | ||
_ref5$networkName = _ref5.networkName, | ||
networkName = _ref5$networkName === void 0 ? 'mainnet' : _ref5$networkName; | ||
return new Promise(function (resolve, reject) { | ||
var providerChangeStream = _this7.communicationMux.getStream('show_provider_change'); | ||
var providerChangeStream = _this8.communicationMux.getStream('show_provider_change'); | ||
var providerChangeSuccess = _this7.communicationMux.getStream('provider_change_status'); | ||
var providerChangeSuccess = _this8.communicationMux.getStream('provider_change_status'); | ||
@@ -730,17 +857,17 @@ var handler = function handler(ev) { | ||
value: function _setProvider() { | ||
var _this8 = this; | ||
var _this9 = this; | ||
var _ref5 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
_ref5$host = _ref5.host, | ||
host = _ref5$host === void 0 ? 'mainnet' : _ref5$host, | ||
_ref5$chainId = _ref5.chainId, | ||
chainId = _ref5$chainId === void 0 ? 1 : _ref5$chainId, | ||
_ref5$networkName = _ref5.networkName, | ||
networkName = _ref5$networkName === void 0 ? 'mainnet' : _ref5$networkName; | ||
var _ref6 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
_ref6$host = _ref6.host, | ||
host = _ref6$host === void 0 ? 'mainnet' : _ref6$host, | ||
_ref6$chainId = _ref6.chainId, | ||
chainId = _ref6$chainId === void 0 ? 1 : _ref6$chainId, | ||
_ref6$networkName = _ref6.networkName, | ||
networkName = _ref6$networkName === void 0 ? 'mainnet' : _ref6$networkName; | ||
return new Promise(function (resolve, reject) { | ||
if (!_this8.isInitalized) { | ||
var providerChangeStream = _this8.communicationMux.getStream('show_provider_change'); | ||
if (!_this9.isInitalized) { | ||
var providerChangeStream = _this9.communicationMux.getStream('show_provider_change'); | ||
var providerChangeSuccess = _this8.communicationMux.getStream('provider_change_status'); | ||
var providerChangeSuccess = _this9.communicationMux.getStream('provider_change_status'); | ||
@@ -813,3 +940,6 @@ var handler = function handler(ev) { | ||
var torusSpeedDial = this.torusSpeedDial; | ||
torusSpeedDial.style.opacity = torusSpeedDial.style.opacity === '0' ? '1' : '0'; | ||
torusSpeedDial.classList.toggle('active'); | ||
var mainTime = isActive ? 0.05 : 1.2; | ||
torusSpeedDial.style.transitionDelay = mainTime + 's'; | ||
setTimeout(function () { | ||
@@ -825,3 +955,4 @@ var time = isActive ? 0.05 : 0.15; | ||
* Gets the public address of an user with email | ||
* @param {String} email Email address of the user | ||
* @param {String} verifier Oauth Provider | ||
* @param {String} verifierId Unique idenfier of oauth provider | ||
*/ | ||
@@ -831,3 +962,5 @@ | ||
key: "getPublicAddress", | ||
value: function getPublicAddress(email) { | ||
value: function getPublicAddress(_ref7) { | ||
var verifier = _ref7.verifier, | ||
verifierId = _ref7.verifierId; | ||
// Select random node from the list of endpoints | ||
@@ -837,12 +970,13 @@ var randomNumber = Math.floor(Math.random() * _config.default.torusNodeEndpoints.length); | ||
return new Promise(function (resolve, reject) { | ||
if (!_config.default.supportedVerifierList.includes(verifier)) reject(new Error('Unsupported verifier')); | ||
(0, _httpHelpers.post)(node, (0, _httpHelpers.generateJsonRPCObject)('VerifierLookupRequest', { | ||
verifier: 'google', | ||
verifier_id: email.toLowerCase() | ||
verifier: verifier, | ||
verifier_id: verifierId.toString().toLowerCase() | ||
})).catch(function (err) { | ||
return console.error(err); | ||
return _loglevel.default.error(err); | ||
}).then(function (lookupShare) { | ||
if (lookupShare.error) { | ||
return (0, _httpHelpers.post)(node, (0, _httpHelpers.generateJsonRPCObject)('KeyAssign', { | ||
verifier: 'google', | ||
verifier_id: email.toLowerCase() | ||
verifier: verifier, | ||
verifier_id: verifierId.toString().toLowerCase() | ||
})); | ||
@@ -853,3 +987,3 @@ } else if (lookupShare.result) { | ||
}).catch(function (err) { | ||
return console.error(err); | ||
return _loglevel.default.error(err); | ||
}).then(function (lookupShare) { | ||
@@ -859,3 +993,4 @@ var ethAddress = lookupShare.result.keys[0].address; | ||
}).catch(function (err) { | ||
console.error(err); | ||
_loglevel.default.error(err); | ||
reject(err); | ||
@@ -872,7 +1007,7 @@ }); | ||
value: function getUserInfo() { | ||
var _this9 = this; | ||
var _this10 = this; | ||
return new Promise(function (resolve, reject) { | ||
if (_this9.isLoggedIn) { | ||
var userInfoStream = _this9.communicationMux.getStream('user_info'); | ||
if (_this10.isLoggedIn) { | ||
var userInfoStream = _this10.communicationMux.getStream('user_info'); | ||
@@ -879,0 +1014,0 @@ userInfoStream.write({ |
{ | ||
"name": "@toruslabs/torus-embed", | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"description": "Embed script for Torus", | ||
@@ -27,3 +27,3 @@ "directories": { | ||
"dependencies": { | ||
"json-rpc-engine": "^5.1.3", | ||
"json-rpc-engine": "^5.1.4", | ||
"json-rpc-middleware-stream": "^2.1.1", | ||
@@ -41,12 +41,12 @@ "loglevel": "^1.6.4", | ||
"devDependencies": { | ||
"@babel/cli": "^7.6.0", | ||
"@babel/core": "^7.6.0", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.5.5", | ||
"@babel/preset-env": "^7.6.0", | ||
"@babel/cli": "^7.6.2", | ||
"@babel/core": "^7.6.2", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.6.2", | ||
"@babel/preset-env": "^7.6.2", | ||
"assert": "^2.0.0", | ||
"browserify": "^16.5.0", | ||
"cross-env": "^6.0.0", | ||
"cross-env": "^6.0.3", | ||
"discify": "^1.6.3", | ||
"envify": "^4.1.0", | ||
"eslint": "^6.4.0", | ||
"eslint": "^6.5.1", | ||
"eslint-config-airbnb-base": "^14.0.0", | ||
@@ -60,9 +60,9 @@ "eslint-config-prettier": "^6.3.0", | ||
"eslint-plugin-node": "^10.0.0", | ||
"eslint-plugin-prettier": "^3.1.0", | ||
"eslint-plugin-prettier": "^3.1.1", | ||
"eslint-plugin-promise": "^4.2.1", | ||
"eslint-plugin-standard": "^4.0.1", | ||
"express": "^4.17.1", | ||
"husky": "^3.0.5", | ||
"lint-staged": "^9.2.5", | ||
"mocha": "^6.2.0", | ||
"husky": "^3.0.8", | ||
"lint-staged": "^9.4.1", | ||
"mocha": "^6.2.1", | ||
"mocha-eslint": "^5.0.0", | ||
@@ -69,0 +69,0 @@ "prettier": "^1.18.2", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
68017
1410
Updatedjson-rpc-engine@^5.1.4