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

@toruslabs/torus-embed

Package Overview
Dependencies
Maintainers
3
Versions
254
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@toruslabs/torus-embed - npm Package Compare versions

Comparing version 0.2.8 to 0.2.9

216

dist/embed.js

@@ -50,6 +50,23 @@ "use strict";

cleanContextForImports();
var iframeIntegrity = 'sha384-1SYzBoS8dq9Z5P0MpwjLID7T5h9YmPKWyx9lt670OFIU2NLMzF68JzXMj/ernwpc';
var iframeIntegrity = 'sha384-05R9PLUtMt85LrNqYYrb+eVWaYKjhCimXqdE+4nhHPEbKsL4f1zGlXFq9QEdx5AV';
var expectedCacheControlHeader = 'max-age=3600';
restoreContextAfterImports();
var thirdPartyCookiesSupported = true;
var receiveMessage = function receiveMessage(evt) {
if (evt.data === 'torus:3PCunsupported') {
_loglevel.default.info('unsupported 3rd party cookies');
thirdPartyCookiesSupported = false;
window.removeEventListener('message', receiveMessage);
} else if (evt.data === 'torus:3PCsupported') {
_loglevel.default.info('supported 3rd party cookies');
thirdPartyCookiesSupported = true;
window.removeEventListener('message', receiveMessage);
}
};
window.addEventListener('message', receiveMessage, false); // evt.data === 'torus:3PCunsupported'
var Torus =

@@ -86,2 +103,3 @@ /*#__PURE__*/

this.Web3 = _web.default;
this.torusAlert = {};
}

@@ -117,3 +135,3 @@

case 'staging':
torusUrl = 'https://staging.tor.us/v0.2.6';
torusUrl = 'https://staging.tor.us/v0.2.8';
logLevel = 'info';

@@ -133,3 +151,3 @@ break;

default:
torusUrl = 'https://app.tor.us/v0.2.8';
torusUrl = 'https://app.tor.us/v0.2.9';
logLevel = 'error';

@@ -209,2 +227,11 @@ break;

}
}, {
key: "_checkThirdPartyCookies",
value: function _checkThirdPartyCookies() {
if (!thirdPartyCookiesSupported) {
this._createAlert();
throw new Error('Third party cookies not supported');
}
}
/**

@@ -303,9 +330,9 @@ * Logs the user in

if (isElement(this.styleLink)) {
window.document.head.removeChild(this.styleLink);
if (isElement(this.styleLink) && window.document.body.contains(this.styleLink)) {
this.styleLink.remove();
this.styleLink = {};
}
if (isElement(this.torusWidget)) {
window.document.body.removeChild(this.torusWidget);
if (isElement(this.torusWidget) && window.document.body.contains(this.torusWidget)) {
this.torusWidget.remove();
this.torusWidget = {};

@@ -318,8 +345,39 @@ this.torusLogin = {};

if (isElement(this.torusIframe)) {
window.document.body.removeChild(this.torusIframe);
if (isElement(this.torusIframe) && window.document.body.contains(this.torusIframe)) {
this.torusIframe.remove();
this.torusIframe = {};
}
if (isElement(this.torusAlert) && window.document.body.contains(this.torusAlert)) {
this.torusAlert.remove();
this.torusAlert = {};
}
}
/**
* Show alert for Cookies Required
*/
}, {
key: "_createAlert",
value: function _createAlert() {
var _this4 = this;
this.torusAlert = (0, _embedUtils.htmlToElement)('<div id="torusAlert" class="torus-alert">' + '<h1>Cookies Required</h1>' + '<p>Please enable cookies in your browser preferences to access Torus.</p></div>');
var closeAlert = (0, _embedUtils.htmlToElement)('<span class="torus-alert-close">x<span>');
this.torusAlert.appendChild(closeAlert);
var bindOnLoad = function bindOnLoad() {
closeAlert.addEventListener('click', function () {
_this4.torusAlert.remove();
});
};
var attachOnLoad = function attachOnLoad() {
window.document.body.appendChild(_this4.torusAlert);
};
(0, _embedUtils.runOnLoad)(attachOnLoad.bind(this));
(0, _embedUtils.runOnLoad)(bindOnLoad.bind(this));
}
/**
* Creates the widget

@@ -331,3 +389,3 @@ */

value: function _createWidget(torusUrl) {
var _this4 = this;
var _this5 = this;

@@ -416,21 +474,21 @@ var link = window.document.createElement('link');

var bindOnLoad = function bindOnLoad() {
_this4.torusLogin.addEventListener('click', function () {
_this4._showLoginPopup(false);
_this5.torusLogin.addEventListener('click', function () {
_this5._showLoginPopup(false);
});
homeBtn.addEventListener('click', function () {
_this4.showWallet();
_this5.showWallet();
_this4._toggleSpeedDial();
_this5._toggleSpeedDial();
});
transferBtn.addEventListener('click', function () {
_this4.showWallet('transfer');
_this5.showWallet('transfer');
_this4._toggleSpeedDial();
_this5._toggleSpeedDial();
});
_this4.keyBtn.addEventListener('click', function () {
var publicKey = (0, _embedUtils.htmlToElement)('<input type="text" value="' + _this4.ethereum.selectedAddress + '">');
_this5.keyBtn.addEventListener('click', function () {
var publicKey = (0, _embedUtils.htmlToElement)('<input type="text" value="' + _this5.ethereum.selectedAddress + '">');
_this4.torusWidget.prepend(publicKey);
_this5.torusWidget.prepend(publicKey);

@@ -442,7 +500,7 @@ publicKey.select();

_this4.torusWidget.removeChild(publicKey);
_this5.torusWidget.removeChild(publicKey);
tooltipCopied.classList.add('active');
tooltipNote.classList.add('active');
var self = _this4;
var self = _this5;
setTimeout(function () {

@@ -456,4 +514,4 @@ tooltipCopied.classList.remove('active');

_this4.torusMenuBtn.addEventListener('click', function () {
_this4._toggleSpeedDial();
_this5.torusMenuBtn.addEventListener('click', function () {
_this5._toggleSpeedDial();
}); // Login Modal Listeners

@@ -463,5 +521,5 @@

modalContainer.querySelector('#close').addEventListener('click', function () {
_this4.torusLoginModal.style.display = 'none';
if (_this4.modalCloseHandler) _this4.modalCloseHandler();
delete _this4.modalCloseHandler;
_this5.torusLoginModal.style.display = 'none';
if (_this5.modalCloseHandler) _this5.modalCloseHandler();
delete _this5.modalCloseHandler;
});

@@ -472,3 +530,3 @@ };

window.document.head.appendChild(link);
window.document.body.appendChild(_this4.torusWidget);
window.document.body.appendChild(_this5.torusWidget);
};

@@ -559,3 +617,3 @@

value: function _setupWeb3() {
var _this5 = this;
var _this6 = this;

@@ -587,3 +645,3 @@ _loglevel.default.info('setupWeb3 running'); // setup background connection

var originalMethod = inpageProvider[m];
var self = _this5;
var self = _this6;

@@ -606,9 +664,11 @@ inpageProvider[m] = function (_ref4) {

inpageProvider.enable = function () {
_this5._showLoggingIn();
_this6._checkThirdPartyCookies();
_this6._showLoggingIn();
return new Promise(function (resolve, reject) {
// TODO: Handle errors when pipe is broken (eg. popup window is closed)
// If user is already logged in, we assume they have given access to the website
_this5.web3.eth.getAccounts(function (err, res) {
var _this6 = this;
_this6.web3.eth.getAccounts(function (err, res) {
var _this7 = this;

@@ -627,11 +687,11 @@ var self = this;

var handleRehydration = function handleRehydration() {
_this6.isLoggedIn = true;
_this7.isLoggedIn = true;
if (_this6.requestedVerifier !== '' && _this6.currentVerifier !== _this6.requestedVerifier) {
var requestedVerifier = _this6.requestedVerifier;
if (_this7.requestedVerifier !== '' && _this7.currentVerifier !== _this7.requestedVerifier) {
var requestedVerifier = _this7.requestedVerifier;
_this6.logout().then(function (_) {
_this6.requestedVerifier = requestedVerifier;
_this7.logout().then(function (_) {
_this7.requestedVerifier = requestedVerifier;
_this6._showLoginPopup(true, resolve, reject);
_this7._showLoginPopup(true, resolve, reject);
}).catch(function (err) {

@@ -656,3 +716,3 @@ return reject(err);

}
}.bind(_this5));
}.bind(_this6));
});

@@ -679,18 +739,18 @@ }; // Work around for web3@1.0 deleting the bound `sendAsync` but not the unbound

if (status.rehydrate && status.loggedIn) {
_this5.isRehydrated = status.rehydrate;
_this5.currentVerifier = status.verifier;
_this6.isRehydrated = status.rehydrate;
_this6.currentVerifier = status.verifier;
if (_this5.isRehydratedCallback) {
_this5.isRehydratedCallback();
if (_this6.isRehydratedCallback) {
_this6.isRehydratedCallback();
delete _this5.isRehydratedCallback;
delete _this6.isRehydratedCallback;
}
} // normal login
else if (status.loggedIn) {
_this5.isLoggedIn = status.loggedIn;
_this5.currentVerifier = status.verifier;
_this6.isLoggedIn = status.loggedIn;
_this6.currentVerifier = status.verifier;
_this5._showLoggedIn();
_this6._showLoggedIn();
} // logout
else _this5._showLoggedOut();
else _this6._showLoggedOut();
}); // if (typeof window.web3 !== 'undefined') {

@@ -728,3 +788,3 @@ // console.log(`Torus detected another web3.

value: function _showLoginPopup(calledFromEmbed, resolve, reject) {
var _this7 = this;
var _this8 = this;

@@ -735,3 +795,3 @@ this._showLoggingIn();

this.modalCloseHandler = function () {
_this7._showLoggedOut();
_this8._showLoggedOut();

@@ -742,7 +802,7 @@ if (reject) reject(new Error('Modal has been closed'));

var googleHandler = function googleHandler() {
_this7.requestedVerifier = GOOGLE;
_this8.requestedVerifier = GOOGLE;
_this7.googleLogin.removeEventListener('click', googleHandler);
_this8.googleLogin.removeEventListener('click', googleHandler);
_this7._showLoginPopup(calledFromEmbed, resolve, reject);
_this8._showLoginPopup(calledFromEmbed, resolve, reject);
};

@@ -753,7 +813,7 @@

var facebookHandler = function facebookHandler() {
_this7.requestedVerifier = FACEBOOK;
_this8.requestedVerifier = FACEBOOK;
_this7.facebookLogin.removeEventListener('click', facebookHandler);
_this8.facebookLogin.removeEventListener('click', facebookHandler);
_this7._showLoginPopup(calledFromEmbed, resolve, reject);
_this8._showLoginPopup(calledFromEmbed, resolve, reject);
};

@@ -764,7 +824,7 @@

var twitchHandler = function twitchHandler() {
_this7.requestedVerifier = TWITCH;
_this8.requestedVerifier = TWITCH;
_this7.twitchLogin.removeEventListener('click', twitchHandler);
_this8.twitchLogin.removeEventListener('click', twitchHandler);
_this7._showLoginPopup(calledFromEmbed, resolve, reject);
_this8._showLoginPopup(calledFromEmbed, resolve, reject);
};

@@ -775,7 +835,7 @@

var redditHandler = function redditHandler() {
_this7.requestedVerifier = REDDIT;
_this8.requestedVerifier = REDDIT;
_this7.redditLogin.removeEventListener('click', redditHandler);
_this8.redditLogin.removeEventListener('click', redditHandler);
_this7._showLoginPopup(calledFromEmbed, resolve, reject);
_this8._showLoginPopup(calledFromEmbed, resolve, reject);
};

@@ -786,7 +846,7 @@

var discordHandler = function discordHandler() {
_this7.requestedVerifier = DISCORD;
_this8.requestedVerifier = DISCORD;
_this7.discordLogin.removeEventListener('click', discordHandler);
_this8.discordLogin.removeEventListener('click', discordHandler);
_this7._showLoginPopup(calledFromEmbed, resolve, reject);
_this8._showLoginPopup(calledFromEmbed, resolve, reject);
};

@@ -832,3 +892,3 @@

value: function setProvider() {
var _this8 = this;
var _this9 = this;

@@ -844,5 +904,5 @@ var _ref5 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},

return new Promise(function (resolve, reject) {
var providerChangeStream = _this8.communicationMux.getStream('show_provider_change');
var providerChangeStream = _this9.communicationMux.getStream('show_provider_change');
var providerChangeSuccess = _this8.communicationMux.getStream('provider_change_status');
var providerChangeSuccess = _this9.communicationMux.getStream('provider_change_status');

@@ -893,3 +953,3 @@ var handler = function handler(ev) {

value: function _setProvider() {
var _this9 = this;
var _this10 = this;

@@ -905,6 +965,6 @@ var _ref6 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},

return new Promise(function (resolve, reject) {
if (!_this9.isInitalized) {
var providerChangeStream = _this9.communicationMux.getStream('show_provider_change');
if (!_this10.isInitalized) {
var providerChangeStream = _this10.communicationMux.getStream('show_provider_change');
var providerChangeSuccess = _this9.communicationMux.getStream('provider_change_status');
var providerChangeSuccess = _this10.communicationMux.getStream('provider_change_status');

@@ -1039,7 +1099,7 @@ var handler = function handler(ev) {

value: function getUserInfo(message) {
var _this10 = this;
var _this11 = this;
return new Promise(function (resolve, reject) {
if (_this10.isLoggedIn) {
var userInfoStream = _this10.communicationMux.getStream('user_info');
if (_this11.isLoggedIn) {
var userInfoStream = _this11.communicationMux.getStream('user_info');

@@ -1081,7 +1141,7 @@ userInfoStream.write({

value: function initiateTopup(provider, params) {
var _this11 = this;
var _this12 = this;
return new Promise(function (resolve, reject) {
if (_this11.isLoggedIn) {
var topupStream = _this11.communicationMux.getStream('topup');
if (_this12.isLoggedIn) {
var topupStream = _this12.communicationMux.getStream('topup');

@@ -1088,0 +1148,0 @@ topupStream.write({

{
"name": "@toruslabs/torus-embed",
"version": "0.2.8",
"version": "0.2.9",
"description": "Embed script for Torus",

@@ -5,0 +5,0 @@ "directories": {

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