@vaadin/vaadin-license-checker
Advanced tools
Comparing version 2.1.0-alpha1 to 2.1.0-alpha2
{ | ||
"description": "Web Component validating licenses for the commercial Vaadin Pro Tools", | ||
"repository": "vaadin/license-checker", | ||
"name": "@vaadin/vaadin-license-checker", | ||
"version": "2.1.0-alpha1", | ||
"version": "2.1.0-alpha2", | ||
"author": "Vaadin Ltd", | ||
"license": "Apache-2.0", | ||
"directories": { | ||
"test": "test" | ||
}, | ||
"files": [ | ||
"vaadin-license-checker.js" | ||
], | ||
"resolutions": { | ||
@@ -12,12 +20,11 @@ "inherits": "2.0.3", | ||
}, | ||
"author": "Vaadin Ltd", | ||
"dependencies": { | ||
"@polymer/polymer": "^3.0.0" | ||
"@vaadin/vaadin-development-mode-detector": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"@polymer/iron-test-helpers": "^3.0.0-pre.12", | ||
"@polymer/polymer": "^3.0.0", | ||
"@vaadin/vaadin-development-mode-detector": "^1.1.0-alpha2", | ||
"wct-browser-legacy": "0.0.1-pre.11" | ||
"wct-browser-legacy": "^1.0.1", | ||
"@polymer/iron-test-helpers": "^3.0.0-pre.18", | ||
"@webcomponents/webcomponentsjs": "^2.0.0" | ||
} | ||
} |
@@ -1,151 +0,184 @@ | ||
/* Validates Vaadin Subscription licenses */ | ||
const licenseBoxTemplate = document.createElement('template'); | ||
licenseBoxTemplate.innerHTML = ` | ||
<style> | ||
:host { | ||
font: 16px/1.625 -apple-system, BlinkMacSystemFont, "Roboto", "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; | ||
position: fixed; | ||
top: .5em; | ||
right: .5em; | ||
z-index: 10000; | ||
cursor: pointer; | ||
backface-visibility: hidden; | ||
} | ||
/* This file is autogenerated from src/vaadin-license-checker.tpl.html */ | ||
/* | ||
FIXME(polymer-modulizer): the above comments were extracted | ||
from HTML and may be out of place here. Review them and | ||
then delete this comment! | ||
*/ | ||
import { runIfDevelopmentMode } from '@vaadin/vaadin-development-mode-detector/vaadin-development-mode-detector.js'; | ||
#content { | ||
padding: 1em 1.5em; | ||
margin: 0; | ||
display: inline-block; | ||
text-align: left; | ||
font-size: inherit; | ||
line-height: inherit; | ||
font-weight: inherit; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothin: grayscale; | ||
white-space: nowrap; | ||
letter-spacing: 0; | ||
border-radius: 4px; | ||
box-shadow: 0 2px 6px -1px hsla(214, 53%, 23%, 0.16), 0 8px 24px -4px hsla(214, 47%, 21%, 0.38); | ||
color: #fff; | ||
} | ||
function maybeCheckLicenses() { | ||
/** vaadin-dev-mode:start | ||
(function () { | ||
'use strict'; | ||
#content[type="needsvalidation"] { | ||
background-color: hsl(3, 100%, 61%); | ||
} | ||
var classCallCheck = function (instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
}; | ||
#content[type="ok"] { | ||
background-color: hsl(145, 80%, 42%); | ||
var createClass = function () { | ||
function defineProperties(target, props) { | ||
for (var i = 0; i < props.length; i++) { | ||
var descriptor = props[i]; | ||
descriptor.enumerable = descriptor.enumerable || false; | ||
descriptor.configurable = true; | ||
if ("value" in descriptor) descriptor.writable = true; | ||
Object.defineProperty(target, descriptor.key, descriptor); | ||
} | ||
} | ||
#content > svg { | ||
display: none; | ||
fill: currentColor; | ||
stroke: currentColor 1px; | ||
padding-left: 1.25em; | ||
} | ||
return function (Constructor, protoProps, staticProps) { | ||
if (protoProps) defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) defineProperties(Constructor, staticProps); | ||
return Constructor; | ||
}; | ||
}(); | ||
#content[type="needsvalidation"] > #link { | ||
display: inline; | ||
} | ||
var inherits = function (subClass, superClass) { | ||
if (typeof superClass !== "function" && superClass !== null) { | ||
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); | ||
} | ||
#content[type="ok"] > #close { | ||
display: inline; | ||
vertical-align: -.125em; | ||
subClass.prototype = Object.create(superClass && superClass.prototype, { | ||
constructor: { | ||
value: subClass, | ||
enumerable: false, | ||
writable: true, | ||
configurable: true | ||
} | ||
</style> | ||
}); | ||
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; | ||
}; | ||
<div id="content"> | ||
<span></span> | ||
<svg id="link" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"> | ||
<g id="external-link"><path d="M14 16v-11l-1 1v9h-12v-12h9l1-1h-11v14z"/><path d="M16 0h-5l1.8 1.8-6.8 6.8 1.4 1.4 6.8-6.8 1.8 1.8z"/></g> | ||
</svg> | ||
<svg id="close" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"> | ||
<g id="close-big"><path d="M16 0l-1 0.010-7 6.99-7-6.99-1-0.010v1l7 7-7 7v1h1l7-7 7 7h1v-1l-7-7 7-7v-1z"/></g> | ||
</svg> | ||
</div> | ||
`; | ||
var possibleConstructorReturn = function (self, call) { | ||
if (!self) { | ||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | ||
} | ||
return call && (typeof call === "object" || typeof call === "function") ? call : self; | ||
}; | ||
function _CustomElement() { | ||
return Reflect.construct(HTMLElement, [], this.__proto__.constructor); | ||
} | ||
Object.setPrototypeOf(_CustomElement.prototype, HTMLElement.prototype); | ||
Object.setPrototypeOf(_CustomElement, HTMLElement); | ||
var licenseBoxTemplate = document.createElement('template'); | ||
licenseBoxTemplate.innerHTML = '\n <style>\n :host {\n font: 16px/1.625 -apple-system, BlinkMacSystemFont, "Roboto", "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";\n position: fixed;\n top: .5em;\n right: .5em;\n z-index: 10000;\n cursor: pointer;\n backface-visibility: hidden;\n }\n\n #content {\n padding: 1em 1.5em;\n margin: 0;\n display: inline-block;\n text-align: left;\n font-size: inherit;\n line-height: inherit;\n font-weight: inherit;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothin: grayscale;\n white-space: nowrap;\n letter-spacing: 0;\n border-radius: 4px;\n box-shadow: 0 2px 6px -1px hsla(214, 53%, 23%, 0.16), 0 8px 24px -4px hsla(214, 47%, 21%, 0.38);\n color: #fff;\n }\n\n #content[type="needsvalidation"] {\n background-color: hsl(3, 100%, 61%);\n }\n\n #content[type="ok"] {\n background-color: hsl(145, 80%, 42%);\n }\n\n #content > svg {\n display: none;\n fill: currentColor;\n stroke: currentColor 1px;\n padding-left: 1.25em;\n }\n\n #content[type="needsvalidation"] > #link {\n display: inline;\n }\n\n #content[type="ok"] > #close {\n display: inline;\n vertical-align: -.125em;\n }\n </style>\n\n <div id="content">\n <span></span>\n <svg id="link" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16">\n <g id="external-link"><path d="M14 16v-11l-1 1v9h-12v-12h9l1-1h-11v14z"/><path d="M16 0h-5l1.8 1.8-6.8 6.8 1.4 1.4 6.8-6.8 1.8 1.8z"/></g>\n </svg>\n <svg id="close" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16">\n <g id="close-big"><path d="M16 0l-1 0.010-7 6.99-7-6.99-1-0.010v1l7 7-7 7v1h1l7-7 7 7h1v-1l-7-7 7-7v-1z"/></g>\n </svg>\n </div>\n'; | ||
window.ShadyCSS && window.ShadyCSS.prepareTemplate(licenseBoxTemplate, 'vaadin-license-box'); | ||
class LicenseBoxElement extends HTMLElement { | ||
connectedCallback() { | ||
window.ShadyCSS && window.ShadyCSS.styleElement(this); | ||
var LicenseBoxElement = function (_CustomElement2) { | ||
inherits(LicenseBoxElement, _CustomElement2); | ||
if (!this.shadowRoot) { | ||
this.attachShadow({mode: 'open'}); | ||
this.shadowRoot.appendChild(document.importNode(licenseBoxTemplate.content, true)); | ||
this._contentElement = this.shadowRoot.querySelector('#content'); | ||
this._render(); | ||
} | ||
function LicenseBoxElement() { | ||
classCallCheck(this, LicenseBoxElement); | ||
return possibleConstructorReturn(this, (LicenseBoxElement.__proto__ || Object.getPrototypeOf(LicenseBoxElement)).apply(this, arguments)); | ||
} | ||
_render() { | ||
if (!this._contentElement) { | ||
return; | ||
} | ||
createClass(LicenseBoxElement, [{ | ||
key: 'connectedCallback', | ||
value: function connectedCallback() { | ||
window.ShadyCSS && window.ShadyCSS.styleElement(this); | ||
if (this._type) { | ||
this._contentElement.setAttribute('type', this._type); | ||
} else { | ||
this._contentElement.removeAttribute('type'); | ||
if (!this.shadowRoot) { | ||
this.attachShadow({ mode: 'open' }); | ||
this.shadowRoot.appendChild(document.importNode(licenseBoxTemplate.content, true)); | ||
this._contentElement = this.shadowRoot.querySelector('#content'); | ||
this._render(); | ||
} | ||
} | ||
}, { | ||
key: '_render', | ||
value: function _render() { | ||
if (!this._contentElement) { | ||
return; | ||
} | ||
this._contentElement.firstElementChild.textContent = this._content; | ||
} | ||
if (this._type) { | ||
this._contentElement.setAttribute('type', this._type); | ||
} else { | ||
this._contentElement.removeAttribute('type'); | ||
} | ||
get type() { | ||
return this._type; | ||
} | ||
this._contentElement.firstElementChild.textContent = this._content; | ||
} | ||
}, { | ||
key: 'type', | ||
get: function () { | ||
return this._type; | ||
}, | ||
set: function (type) { | ||
this._type = type; | ||
this._render(); | ||
} | ||
}, { | ||
key: 'content', | ||
get: function () { | ||
return this._content; | ||
}, | ||
set: function (content) { | ||
this._content = content; | ||
this._render(); | ||
} | ||
}]); | ||
return LicenseBoxElement; | ||
}(_CustomElement); | ||
set type(type) { | ||
this._type = type; | ||
this._render(); | ||
} | ||
customElements.define('vaadin-license-box', LicenseBoxElement); | ||
get content() { | ||
return this._content; | ||
} | ||
var LicenseCheckerLogger = function () { | ||
function LicenseCheckerLogger() { | ||
classCallCheck(this, LicenseCheckerLogger); | ||
set content(content) { | ||
this._content = content; | ||
this._render(); | ||
this.id = "vaadin-license-checker"; | ||
} | ||
} | ||
customElements.define('vaadin-license-box', LicenseBoxElement); | ||
createClass(LicenseCheckerLogger, [{ | ||
key: 'isDebug', | ||
value: function isDebug() { | ||
return localStorage.getItem("vaadin.licenses.debug"); | ||
} | ||
}, { | ||
key: 'debug', | ||
value: function debug(msg) { | ||
if (this.isDebug()) { | ||
console.info(this.id + ": " + msg); | ||
} | ||
} | ||
}]); | ||
return LicenseCheckerLogger; | ||
}(); | ||
class LicenseCheckerLogger { | ||
constructor() { | ||
this.id = "vaadin-license-checker"; | ||
} | ||
var LicenseCheckerStorage = function () { | ||
function LicenseCheckerStorage() { | ||
classCallCheck(this, LicenseCheckerStorage); | ||
isDebug() { | ||
return localStorage.getItem("vaadin.licenses.debug"); | ||
this.logger = new LicenseCheckerLogger(); | ||
} | ||
debug(msg) { | ||
if (this.isDebug()) { | ||
console.info(this.id + ": " + msg); | ||
createClass(LicenseCheckerStorage, [{ | ||
key: 'getLastCheckKey', | ||
value: function getLastCheckKey(productInfo) { | ||
return "vaadin.licenses.{product}.lastCheck".replace("{product}", productInfo.name); | ||
} | ||
} | ||
} | ||
class LicenseCheckerStorage { | ||
constructor() { | ||
this.logger = new LicenseCheckerLogger(); | ||
} | ||
getLastCheckKey(productInfo) { | ||
return "vaadin.licenses.{product}.lastCheck".replace("{product}", productInfo.name); | ||
} | ||
}, { | ||
key: 'getLastCheck', | ||
value: function getLastCheck(productInfo) { | ||
return Number(localStorage.getItem(this.getLastCheckKey(productInfo))); | ||
} | ||
}, { | ||
key: 'setLastCheck', | ||
value: function setLastCheck(productInfo, timestamp) { | ||
this.logger.debug("Setting last check time to " + new Date(timestamp)); | ||
localStorage.setItem(this.getLastCheckKey(productInfo), timestamp); | ||
} | ||
}]); | ||
return LicenseCheckerStorage; | ||
}(); | ||
getLastCheck(productInfo) { | ||
return Number(localStorage.getItem(this.getLastCheckKey(productInfo))); | ||
} | ||
var VaadinLicenseChecker = function () { | ||
function VaadinLicenseChecker() { | ||
classCallCheck(this, VaadinLicenseChecker); | ||
setLastCheck(productInfo, timestamp) { | ||
this.logger.debug("Setting last check time to " + new Date(timestamp)); | ||
localStorage.setItem(this.getLastCheckKey(productInfo), timestamp); | ||
} | ||
} | ||
class VaadinLicenseChecker { | ||
constructor() { | ||
this.okNotifier = new LicenseOkNotifier(); | ||
@@ -159,167 +192,209 @@ this.validationNeededNotifier = new LicenseValidationNeededNotifier(); | ||
static get version() { | ||
return '2.1.0-alpha1'; | ||
} | ||
getForcedResponseKey(productInfo) { | ||
return 'vaadin.licenses.{product}.forcedResponse'.replace('{product}', productInfo.name); | ||
} | ||
getForcedResponse(productInfo) { | ||
return localStorage.getItem(this.getForcedResponseKey(productInfo)); | ||
} | ||
clearForcedResponse(productInfo) { | ||
return localStorage.removeItem(this.getForcedResponseKey(productInfo)); | ||
} | ||
maybeCheck(productInfo) { | ||
this.logger.debug("maybeCheck(" + JSON.stringify(productInfo) + ")"); | ||
// Defer first check until interval has expired to avoid interfering with tests etc | ||
const now = new Date().getTime(); | ||
const lastCheck = this.storage.getLastCheck(productInfo); | ||
if (!lastCheck) { | ||
this.logger.debug("Deferring first check until " + new Date(now + this.checkInterval)); | ||
this.storage.setLastCheck(productInfo, now); | ||
return; | ||
} else { | ||
const sinceLastCheck = Math.round((now - lastCheck) / 1000); | ||
const nextCheck = Math.round(this.checkInterval / 1000 - sinceLastCheck); | ||
if (nextCheck > 0) { | ||
// Checked recently | ||
const nextCheckDate = new Date(lastCheck + this.checkInterval); | ||
this.logger.debug("Checked " + sinceLastCheck + "s ago. Next check in " + nextCheck + "s at " + nextCheckDate + "."); | ||
createClass(VaadinLicenseChecker, [{ | ||
key: 'getForcedResponseKey', | ||
value: function getForcedResponseKey(productInfo) { | ||
return 'vaadin.licenses.{product}.forcedResponse'.replace('{product}', productInfo.name); | ||
} | ||
}, { | ||
key: 'getForcedResponse', | ||
value: function getForcedResponse(productInfo) { | ||
return localStorage.getItem(this.getForcedResponseKey(productInfo)); | ||
} | ||
}, { | ||
key: 'clearForcedResponse', | ||
value: function clearForcedResponse(productInfo) { | ||
return localStorage.removeItem(this.getForcedResponseKey(productInfo)); | ||
} | ||
}, { | ||
key: 'maybeCheck', | ||
value: function maybeCheck(productInfo) { | ||
this.logger.debug("maybeCheck(" + JSON.stringify(productInfo) + ")"); | ||
// Defer first check until interval has expired to avoid interfering with tests etc | ||
var now = new Date().getTime(); | ||
var lastCheck = this.storage.getLastCheck(productInfo); | ||
if (!lastCheck) { | ||
this.logger.debug("Deferring first check until " + new Date(now + this.checkInterval)); | ||
this.storage.setLastCheck(productInfo, now); | ||
return; | ||
} else { | ||
this.logger.debug("Last check was " + sinceLastCheck + "s ago."); | ||
var sinceLastCheck = Math.round((now - lastCheck) / 1000); | ||
var nextCheck = Math.round(this.checkInterval / 1000 - sinceLastCheck); | ||
if (nextCheck > 0) { | ||
// Checked recently | ||
var nextCheckDate = new Date(lastCheck + this.checkInterval); | ||
this.logger.debug("Checked " + sinceLastCheck + "s ago. Next check in " + nextCheck + "s at " + nextCheckDate + "."); | ||
return; | ||
} else { | ||
this.logger.debug("Last check was " + sinceLastCheck + "s ago."); | ||
} | ||
} | ||
this.check(productInfo); | ||
} | ||
this.check(productInfo); | ||
} | ||
}, { | ||
key: 'check', | ||
value: function check(productInfo) { | ||
this.logger.debug("check(" + JSON.stringify(productInfo) + ")"); | ||
check(productInfo) { | ||
this.logger.debug("check(" + JSON.stringify(productInfo) + ")"); | ||
// Only show an ok notification if the "validation needed" notification was shown. | ||
// For background checks, show no visual notification if all goes well | ||
var showOkOnSuccess = this.validationNeededNotifier.isVisible(productInfo); | ||
// Only show an ok notification if the "validation needed" notification was shown. | ||
// For background checks, show no visual notification if all goes well | ||
var showOkOnSuccess = this.validationNeededNotifier.isVisible(productInfo); | ||
var checker = this; | ||
var onerror = function () { | ||
// Offline or blocked, just log to console and let people get work done | ||
console.error("Unable to validate the license for " + productInfo.name + ". Check your internet access."); | ||
}; | ||
var onresponse = function (responseText) { | ||
var response = JSON.parse(responseText); | ||
if (response.result == "ok") { | ||
// Everything is fine, stop | ||
checker.logger.debug("License check ok for " + JSON.stringify(productInfo)); | ||
checker.storage.setLastCheck(productInfo, new Date().getTime()); | ||
if (showOkOnSuccess) { | ||
checker.logger.debug("Showing validation-ok dialog"); | ||
checker.okNotifier.show(productInfo); | ||
} | ||
} else { | ||
checker.logger.debug("License check failed for " + JSON.stringify(productInfo)); | ||
checker.logger.debug("Showing validation-needed dialog"); | ||
checker.validationNeededNotifier.show(productInfo); | ||
} | ||
if (response.message) { | ||
console.log(response.message); | ||
} | ||
}; | ||
const checker = this; | ||
const onerror = function () { | ||
// Offline or blocked, just log to console and let people get work done | ||
console.error("Unable to validate the license for " + productInfo.name + ". Check your internet access."); | ||
}; | ||
const onresponse = function (responseText) { | ||
const response = JSON.parse(responseText); | ||
if (response.result == "ok") { | ||
// Everything is fine, stop | ||
checker.logger.debug("License check ok for " + JSON.stringify(productInfo)); | ||
checker.storage.setLastCheck(productInfo, new Date().getTime()); | ||
if (showOkOnSuccess) { | ||
checker.logger.debug("Showing validation-ok dialog"); | ||
checker.okNotifier.show(productInfo); | ||
// This is typically hidden already but when receiving a window message it is not | ||
this.logger.debug("Ensuring validation-needed dialog is hidden"); | ||
this.validationNeededNotifier.hide(productInfo); | ||
if (this.logger.isDebug() && this.getForcedResponse(productInfo)) { | ||
var respJson = this.getForcedResponse(productInfo); | ||
this.clearForcedResponse(productInfo); | ||
if (JSON.parse(respJson).type == "error") { | ||
this.logger.debug("Forced error for check"); | ||
onerror(); | ||
} else { | ||
this.logger.debug("Forced response for check: " + respJson); | ||
onresponse(respJson); | ||
} | ||
} else { | ||
checker.logger.debug("License check failed for " + JSON.stringify(productInfo)); | ||
checker.logger.debug("Showing validation-needed dialog"); | ||
checker.validationNeededNotifier.show(productInfo); | ||
this.send(this.url, productInfo, onresponse, onerror); | ||
} | ||
if (response.message) { | ||
console.log(response.message); | ||
} | ||
}; | ||
} | ||
}, { | ||
key: 'send', | ||
value: function send(url, productInfo, onsuccess, onerror) { | ||
this.logger.debug("Sending request to " + url); | ||
var req = new XMLHttpRequest(); | ||
req.withCredentials = true; | ||
req.addEventListener("readystatechange", function () { | ||
if (req.readyState === XMLHttpRequest.DONE && req.status === 200) { | ||
onsuccess(req.responseText); | ||
} | ||
}); | ||
req.addEventListener("error", function () { | ||
onerror(); | ||
}); | ||
req.open("GET", url); | ||
req.setRequestHeader("check-source", "webcomponent"); | ||
req.setRequestHeader("product-name", productInfo.name); | ||
req.setRequestHeader("product-version", productInfo.version); | ||
// This is typically hidden already but when receiving a window message it is not | ||
this.logger.debug("Ensuring validation-needed dialog is hidden"); | ||
this.validationNeededNotifier.hide(productInfo); | ||
req.send(); | ||
} | ||
}], [{ | ||
key: 'version', | ||
get: function () { | ||
return '2.1.0-alpha2'; | ||
} | ||
}]); | ||
return VaadinLicenseChecker; | ||
}(); | ||
if (this.logger.isDebug() && this.getForcedResponse(productInfo)) { | ||
const respJson = this.getForcedResponse(productInfo); | ||
this.clearForcedResponse(productInfo); | ||
if (JSON.parse(respJson).type == "error") { | ||
this.logger.debug("Forced error for check"); | ||
onerror(); | ||
} else { | ||
this.logger.debug("Forced response for check: " + respJson); | ||
onresponse(respJson); | ||
var LicenseOkNotifier = function () { | ||
function LicenseOkNotifier() { | ||
classCallCheck(this, LicenseOkNotifier); | ||
} | ||
createClass(LicenseOkNotifier, [{ | ||
key: 'getInstance', | ||
value: function getInstance() { | ||
return document.getElementById(LicenseOkNotifier.id); | ||
} | ||
}, { | ||
key: 'show', | ||
value: function show(productInfo) { | ||
// Only show one ok box even if multiple licenses were checked | ||
if (this.getInstance()) { | ||
// Already shown | ||
return; | ||
} | ||
} else { | ||
this.send(this.url, productInfo, onresponse, onerror); | ||
var instance = document.createElement("vaadin-license-box"); | ||
instance.id = LicenseOkNotifier.id; | ||
instance.type = "ok"; | ||
instance.content = "Your license has been validated"; | ||
document.body.appendChild(instance); | ||
instance.addEventListener("click", function () { | ||
instance.parentElement.removeChild(instance); | ||
}); | ||
} | ||
}], [{ | ||
key: 'id', | ||
get: function () { | ||
return 'vaadin-license-validation-ok'; | ||
} | ||
}]); | ||
return LicenseOkNotifier; | ||
}(); | ||
var LicenseValidationNeededNotifier = function () { | ||
function LicenseValidationNeededNotifier() { | ||
classCallCheck(this, LicenseValidationNeededNotifier); | ||
} | ||
send(url, productInfo, onsuccess, onerror) { | ||
this.logger.debug("Sending request to " + url); | ||
var req = new XMLHttpRequest(); | ||
req.withCredentials = true; | ||
req.addEventListener("readystatechange", function () { | ||
if (req.readyState === XMLHttpRequest.DONE && req.status === 200) { | ||
onsuccess(req.responseText); | ||
} | ||
}); | ||
req.addEventListener("error", function () { | ||
onerror(); | ||
}); | ||
req.open("GET", url); | ||
req.setRequestHeader("check-source","webcomponent"); | ||
req.setRequestHeader("product-name", productInfo.name); | ||
req.setRequestHeader("product-version", productInfo.version); | ||
req.send(); | ||
}; | ||
} | ||
class LicenseOkNotifier { | ||
static get id() { | ||
return 'vaadin-license-validation-ok'; | ||
} | ||
getInstance() { | ||
return document.getElementById(LicenseOkNotifier.id); | ||
} | ||
show(productInfo) { | ||
// Only show one ok box even if multiple licenses were checked | ||
if (this.getInstance()) { | ||
// Already shown | ||
return; | ||
createClass(LicenseValidationNeededNotifier, [{ | ||
key: 'id', | ||
value: function id(productInfo) { | ||
return "vaadin-license-validation-notification-{product}".replace("{product}", productInfo.name); | ||
} | ||
const instance = document.createElement("vaadin-license-box"); | ||
instance.id = LicenseOkNotifier.id; | ||
instance.type = "ok"; | ||
instance.content = "Your license has been validated"; | ||
document.body.appendChild(instance); | ||
instance.addEventListener("click", function () { | ||
instance.parentElement.removeChild(instance); | ||
}); | ||
} | ||
} | ||
class LicenseValidationNeededNotifier { | ||
id(productInfo) { | ||
return "vaadin-license-validation-notification-{product}".replace("{product}", productInfo.name); | ||
} | ||
getInstance(productInfo) { | ||
return document.getElementById(this.id(productInfo)); | ||
} | ||
show(productInfo) { | ||
if (this.getInstance(productInfo)) { | ||
// Already shown | ||
return; | ||
}, { | ||
key: 'getInstance', | ||
value: function getInstance(productInfo) { | ||
return document.getElementById(this.id(productInfo)); | ||
} | ||
const instance = document.createElement("vaadin-license-box"); | ||
instance.id = this.id(productInfo); | ||
instance.type = "needsvalidation"; | ||
instance.content = "Click to validate your Vaadin Subscription"; | ||
document.body.appendChild(instance); | ||
instance.addEventListener("click", function () { | ||
window.open("https://vaadin.com/pro/validate-license", "_blank"); | ||
}); | ||
} | ||
hide(productInfo) { | ||
const instance = this.getInstance(productInfo); | ||
if (instance) { | ||
instance.parentElement.removeChild(instance); | ||
}, { | ||
key: 'show', | ||
value: function show(productInfo) { | ||
if (this.getInstance(productInfo)) { | ||
// Already shown | ||
return; | ||
} | ||
var instance = document.createElement("vaadin-license-box"); | ||
instance.id = this.id(productInfo); | ||
instance.type = "needsvalidation"; | ||
instance.content = "Click to validate your Vaadin Subscription"; | ||
document.body.appendChild(instance); | ||
instance.addEventListener("click", function () { | ||
window.open("https://vaadin.com/pro/validate-license", "_blank"); | ||
}); | ||
} | ||
} | ||
isVisible(productInfo) { | ||
return !!this.getInstance(productInfo); | ||
} | ||
} | ||
}, { | ||
key: 'hide', | ||
value: function hide(productInfo) { | ||
var instance = this.getInstance(productInfo); | ||
if (instance) { | ||
instance.parentElement.removeChild(instance); | ||
} | ||
} | ||
}, { | ||
key: 'isVisible', | ||
value: function isVisible(productInfo) { | ||
return !!this.getInstance(productInfo); | ||
} | ||
}]); | ||
return LicenseValidationNeededNotifier; | ||
}(); | ||
const proProducts = []; | ||
var proProducts = []; | ||
@@ -341,8 +416,17 @@ window.Vaadin = window.Vaadin || {}; | ||
// Force checking of all licenses to avoid e.g. popups during presentations when the grace period just has ended | ||
proProducts.forEach(productInfo => { | ||
proProducts.forEach(function (productInfo) { | ||
window.Vaadin.LicenseChecker.check(productInfo); | ||
}); | ||
} | ||
}; | ||
window.Vaadin.LicenseChecker.maybeCheck(productInfo); | ||
}; | ||
}()); | ||
vaadin-dev-mode:end **/ | ||
} | ||
if (typeof runIfDevelopmentMode === 'function') { | ||
runIfDevelopmentMode(maybeCheckLicenses); | ||
} |
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
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
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
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
395
17440
3
+ Added@vaadin/vaadin-development-mode-detector@2.0.7(transitive)
- Removed@polymer/polymer@^3.0.0
- Removed@polymer/polymer@3.5.2(transitive)
- Removed@webcomponents/shadycss@1.11.2(transitive)