@toruslabs/torus-embed
Advanced tools
Comparing version 0.2.3 to 0.2.4
@@ -13,3 +13,3 @@ import Web3 from 'web3' | ||
hideTorusButton(): void | ||
getUserInfo(): Promise<UserInfo> | ||
getUserInfo(message: string): Promise<UserInfo> | ||
init(params: TorusParams): Promise<void> | ||
@@ -42,2 +42,4 @@ login(params: LoginParams): Promise<string[]> | ||
profileImage: string; | ||
verifier: string; | ||
verifierId: string; | ||
} | ||
@@ -50,4 +52,13 @@ | ||
showTorusButton?: boolean; | ||
enabledVerifiers?: VerifierStatus | ||
} | ||
interface VerifierStatus { | ||
google?: boolean; | ||
facebook?: boolean; | ||
reddit?: boolean; | ||
twitch?: boolean; | ||
discord?: boolean; | ||
} | ||
interface NetworkInterface { | ||
@@ -54,0 +65,0 @@ host: 'mainnet' | 'rinkeby' | 'ropsten' | 'kovan' | 'goerli' | 'localhost' | 'matic' | string, |
@@ -26,4 +26,10 @@ "use strict"; | ||
var _defaultVerifiers; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -35,4 +41,14 @@ | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var _configuration$enums = _config.default.enums, | ||
GOOGLE = _configuration$enums.GOOGLE, | ||
FACEBOOK = _configuration$enums.FACEBOOK, | ||
REDDIT = _configuration$enums.REDDIT, | ||
TWITCH = _configuration$enums.TWITCH, | ||
DISCORD = _configuration$enums.DISCORD; | ||
var defaultVerifiers = (_defaultVerifiers = {}, _defineProperty(_defaultVerifiers, GOOGLE, true), _defineProperty(_defaultVerifiers, FACEBOOK, true), _defineProperty(_defaultVerifiers, REDDIT, true), _defineProperty(_defaultVerifiers, TWITCH, true), _defineProperty(_defaultVerifiers, DISCORD, true), _defaultVerifiers); | ||
cleanContextForImports(); | ||
var iframeIntegrity = 'sha384-QnOqOsinR+o2RyZI3HEXDuYzjJayzvkOoyfTjr9qmejlIqUJUMMtNe8KSFLgu/NE'; | ||
var iframeIntegrity = 'sha384-k9DHCQEzI1FS5yf3WsCzTZB8Fs/dBQO8iAkpAOr9tgmwBLeDPj76Mw8ugZehleau'; | ||
var expectedCacheControlHeader = 'max-age=3600'; | ||
restoreContextAfterImports(); | ||
@@ -69,2 +85,3 @@ | ||
this.currentVerifier = ''; | ||
this.enabledVerifiers = {}; | ||
this.Web3 = _web.default; | ||
@@ -83,2 +100,4 @@ } | ||
enableLogging = _ref2$enableLogging === void 0 ? false : _ref2$enableLogging, | ||
_ref2$enabledVerifier = _ref2.enabledVerifiers, | ||
enabledVerifiers = _ref2$enabledVerifier === void 0 ? defaultVerifiers : _ref2$enabledVerifier, | ||
_ref2$network = _ref2.network, | ||
@@ -100,3 +119,3 @@ network = _ref2$network === void 0 ? { | ||
case 'staging': | ||
torusUrl = 'https://staging.tor.us/v0.1.2'; | ||
torusUrl = 'https://staging.tor.us/v0.2.3'; | ||
logLevel = 'info'; | ||
@@ -116,3 +135,3 @@ break; | ||
default: | ||
torusUrl = 'https://app.tor.us/v0.2.3'; | ||
torusUrl = 'https://app.tor.us/v0.2.4'; | ||
logLevel = 'error'; | ||
@@ -122,2 +141,4 @@ break; | ||
_this.enabledVerifiers = _objectSpread({}, defaultVerifiers, {}, enabledVerifiers); | ||
_loglevel.default.setDefaultLevel(logLevel); | ||
@@ -136,4 +157,10 @@ | ||
// hacky solution to check for iframe integrity | ||
var fetchUrl = torusUrl + '/index.html'; | ||
fetch(fetchUrl).then(function (resp) { | ||
var fetchUrl = torusUrl + '/popup'; | ||
fetch(fetchUrl, { | ||
cache: 'reload' | ||
}).then(function (resp) { | ||
if (resp.headers.get('Cache-Control') !== expectedCacheControlHeader) { | ||
throw new Error('Unexpected Cache-Control headers, got ' + resp.headers.get('Cache-Control')); | ||
} | ||
return resp.text(); | ||
@@ -198,2 +225,3 @@ }).then(function (response) { | ||
if (this.isLoggedIn) throw new Error('User has already logged in'); | ||
if (verifier && !this.enabledVerifiers[verifier]) throw new Error('Given verifier is not enabled'); | ||
@@ -368,8 +396,12 @@ if (!verifier) { | ||
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); | ||
if (this.enabledVerifiers[FACEBOOK]) loginList.appendChild(this.facebookLogin); | ||
if (this.enabledVerifiers[TWITCH]) loginList.appendChild(this.twitchLogin); | ||
if (this.enabledVerifiers[REDDIT]) loginList.appendChild(this.redditLogin); | ||
if (this.enabledVerifiers[DISCORD]) loginList.appendChild(this.discordLogin); | ||
if (this.enabledVerifiers[GOOGLE]) { | ||
modalContent.appendChild(this.googleLogin); | ||
modalContent.appendChild(otherAccount); | ||
} | ||
modalContent.appendChild(loginList); | ||
@@ -699,3 +731,3 @@ 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>'); | ||
var googleHandler = function googleHandler() { | ||
_this7.requestedVerifier = _config.default.enums.GOOGLE; | ||
_this7.requestedVerifier = GOOGLE; | ||
@@ -710,3 +742,3 @@ _this7.googleLogin.removeEventListener('click', googleHandler); | ||
var facebookHandler = function facebookHandler() { | ||
_this7.requestedVerifier = _config.default.enums.FACEBOOK; | ||
_this7.requestedVerifier = FACEBOOK; | ||
@@ -721,3 +753,3 @@ _this7.facebookLogin.removeEventListener('click', facebookHandler); | ||
var twitchHandler = function twitchHandler() { | ||
_this7.requestedVerifier = _config.default.enums.TWITCH; | ||
_this7.requestedVerifier = TWITCH; | ||
@@ -732,3 +764,3 @@ _this7.twitchLogin.removeEventListener('click', twitchHandler); | ||
var redditHandler = function redditHandler() { | ||
_this7.requestedVerifier = _config.default.enums.REDDIT; | ||
_this7.requestedVerifier = REDDIT; | ||
@@ -743,3 +775,3 @@ _this7.redditLogin.removeEventListener('click', redditHandler); | ||
var discordHandler = function discordHandler() { | ||
_this7.requestedVerifier = _config.default.enums.DISCORD; | ||
_this7.requestedVerifier = DISCORD; | ||
@@ -986,2 +1018,3 @@ _this7.discordLogin.removeEventListener('click', discordHandler); | ||
* Exposes the loggedin user info to the Dapp | ||
* @param {String} message Message to be displayed to the user | ||
*/ | ||
@@ -991,3 +1024,3 @@ | ||
key: "getUserInfo", | ||
value: function getUserInfo() { | ||
value: function getUserInfo(message) { | ||
var _this10 = this; | ||
@@ -1000,3 +1033,6 @@ | ||
userInfoStream.write({ | ||
name: 'user_info_request' | ||
name: 'user_info_request', | ||
data: { | ||
message: message | ||
} | ||
}); | ||
@@ -1003,0 +1039,0 @@ |
{ | ||
"name": "@toruslabs/torus-embed", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"description": "Embed script for Torus", | ||
@@ -40,6 +40,6 @@ "directories": { | ||
"devDependencies": { | ||
"@babel/cli": "^7.6.2", | ||
"@babel/core": "^7.6.2", | ||
"@babel/cli": "^7.7.0", | ||
"@babel/core": "^7.7.0", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.6.2", | ||
"@babel/preset-env": "^7.6.2", | ||
"@babel/preset-env": "^7.7.1", | ||
"assert": "^2.0.0", | ||
@@ -50,5 +50,5 @@ "browserify": "^16.5.0", | ||
"envify": "^4.1.0", | ||
"eslint": "^6.5.1", | ||
"eslint": "^6.6.0", | ||
"eslint-config-airbnb-base": "^14.0.0", | ||
"eslint-config-prettier": "^6.3.0", | ||
"eslint-config-prettier": "^6.5.0", | ||
"eslint-config-standard": "^14.1.0", | ||
@@ -58,3 +58,3 @@ "eslint-plugin-flowtype": "^4.3.0", | ||
"eslint-plugin-import": "^2.18.2", | ||
"eslint-plugin-mocha": "^6.1.1", | ||
"eslint-plugin-mocha": "^6.2.1", | ||
"eslint-plugin-node": "^10.0.0", | ||
@@ -65,8 +65,8 @@ "eslint-plugin-prettier": "^3.1.1", | ||
"express": "^4.17.1", | ||
"husky": "^3.0.8", | ||
"lint-staged": "^9.4.1", | ||
"mocha": "^6.2.1", | ||
"husky": "^3.0.9", | ||
"lint-staged": "^9.4.2", | ||
"mocha": "^6.2.2", | ||
"mocha-eslint": "^5.0.0", | ||
"prettier": "^1.18.2", | ||
"puppeteer": "^1.20.0", | ||
"puppeteer": "^2.0.0", | ||
"rimraf": "^3.0.0", | ||
@@ -100,3 +100,3 @@ "uglifyify": "^5.0.2" | ||
"engines": { | ||
"node": "10.x" | ||
"node": ">=8.0.0" | ||
}, | ||
@@ -103,0 +103,0 @@ "husky": { |
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
70850
1451