Skip to content

Commit

Permalink
fix:vulnerabilities fixes [CS-16657]
Browse files Browse the repository at this point in the history
  • Loading branch information
Amitkanswal committed Aug 31, 2021
1 parent 4680c31 commit 6eaa3c4
Show file tree
Hide file tree
Showing 90 changed files with 90,440 additions and 19,279 deletions.
21 changes: 21 additions & 0 deletions ace-editor/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Contentstack

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
21 changes: 21 additions & 0 deletions color-picker/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Contentstack

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
21 changes: 21 additions & 0 deletions dashboard-widget-google-analytics/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Contentstack

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
54 changes: 32 additions & 22 deletions dashboard-widget-google-analytics/gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
const gulp = require('gulp');
const inline = require('gulp-inline');
const uglify = require('gulp-uglify');
const minifyCss = require('gulp-clean-css');
const babel = require('gulp-babel');

gulp.task('build', () => {
return gulp.src('./src/index.html')
.pipe(inline({
js: [babel({
presets: ['es2015']
}), uglify],
const gulp = require('gulp'),
inline = require('gulp-inline'),
uglify = require('gulp-uglify'),
minifyCss = require('gulp-clean-css'),
babel = require('gulp-babel'),
concat = require('gulp-concat');
gulp.task('js', function () {
return gulp
.src('./src/analytics.js')
.pipe(concat('scripts.js'))
.pipe(
babel({
presets: ['@babel/env'],
})
)
.pipe(gulp.dest('./src/dist'));
});
gulp.task('inline', function () {
return gulp
.src('./src/index.html')
.pipe(
inline({
css: [minifyCss],
disabledTypes: ['svg', 'img']
}))
.pipe(gulp.dest('./'));
});

gulp.task('watch', function() {
gulp.watch('src/*', gulp.series('build'));
});
gulp.task('default', gulp.series('build'));
js: uglify,
})
)
.pipe(gulp.dest('./'));
});
gulp.task('watch', function () {
gulp.watch(['src/dist/*', 'src/*'], gulp.series('build'));
});
gulp.task('build', gulp.series('js', 'inline'));
gulp.task('default', gulp.series('build'));
2 changes: 1 addition & 1 deletion dashboard-widget-google-analytics/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<div id="canvasbody">
</div>
<script>
"use strict";var _createClass=function(){function r(e,t){for(var a=0;a<t.length;a++){var r=t[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(e,t,a){return t&&r(e.prototype,t),a&&r(e,a),e}}();function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var extensionDashboardField=void 0,analytics=void 0,currentData=void 0,Analytics=function(){function n(e){var t=e.url,a=e.view_id,r=e["x-api-key"];_classCallCheck(this,n),this.baseUrl=t,this.viewId=a,this.xApiKey=r}return _createClass(n,[{key:"getData",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:30,t=this,a={};return t.xApiKey&&(a["x-api-key"]=t.xApiKey),fetch(t.baseUrl+"?view_id="+t.viewId+"&start_date="+e+"daysAgo&end_date=today&metrics=ga:pageviews,ga:uniquePageviews,ga:users,ga:newUsers,ga:avgTimeOnPage,ga:pageLoadTime,ga:bounceRate&dimensions=ga:date",{method:"GET",headers:a}).then(function(e){if(200===e.status)return e.json();throw new Error("Error in fetching data.</br>Please check extension configuration.")}).catch(function(e){return Promise.reject(e)})}}]),n}();function toggleLoader(e){document.getElementById("loader").style.display=e?"block":"none"}function toggleButtons(e){for(var t=document.getElementsByClassName("btn cs-btn-primary"),a=0;a<t.length;a+=1)t[a].disabled=e;toggleLoader(e)}function formatDate(e){return e[0]+e[1]+e[2]+e[3]+"-"+(e[4]+e[5])+"-"+(e[6]+e[7])}function addPadding(e){return 1===e.length?"0"+e:""+e}function formatTime(e){var t,a,r,n=e;return t=((n%=86400)/3600).toFixed(),a=((n%=3600)/60).toFixed(),r=(n%=60).toFixed(),addPadding(t)+":"+addPadding(a)+":"+addPadding(r)}function drawChart(e,t){var a=google.visualization.arrayToDataTable(e);new google.visualization.AreaChart(document.getElementById("chart_container_"+t)).draw(a,{hAxis:{textPosition:"none"},vAxis:{minValue:0},legend:"none",colors:["#098ec8"],backgroundColor:"#F8F8F8"})}function renderMetric(e,t,a,r){document.getElementById("canvasbody").innerHTML+='<div class="graph-wrap"><div class="metric-details"><p>'+r+"</p><h1>"+t+'</h1></div><div id="chart_container_'+a+'"></div></div>',drawChart(e,a)}function displayError(e){document.getElementById("error").innerHTML="<p>"+e+"</p>"}function renderData(e){document.getElementById("canvasbody").innerHTML=" ";var t,a=void 0,r=void 0,n=void 0,o=void 0,i=void 0,s=void 0,u=void 0,c=(currentData=e||currentData).totalsForAllResults["ga:pageviews"],d=currentData.totalsForAllResults["ga:uniquePageviews"],l=currentData.totalsForAllResults["ga:users"],g=currentData.totalsForAllResults["ga:newUsers"],m=currentData.totalsForAllResults["ga:avgTimeOnPage"],v=currentData.totalsForAllResults["ga:pageLoadTime"],h=currentData.totalsForAllResults["ga:bounceRate"];a=[["year","count"]],r=[["year","count"]],n=[["year","count"]],o=[["year","count"]],i=[["year","count"]],s=[["year","count"]],u=[["year","count"]],t=currentData.rows.length;for(var b=0;b<t;b+=1)a.push([formatDate(currentData.rows[b][0]),Number(currentData.rows[b][1])]),r.push([formatDate(currentData.rows[b][0]),Number(currentData.rows[b][2])]),n.push([formatDate(currentData.rows[b][0]),Number(currentData.rows[b][3])]),o.push([formatDate(currentData.rows[b][0]),Number(currentData.rows[b][4])]),i.push([formatDate(currentData.rows[b][0]),Number(currentData.rows[b][5])]),s.push([formatDate(currentData.rows[b][0]),Number(currentData.rows[b][6])]),u.push([formatDate(currentData.rows[b][0]),Number(currentData.rows[b][7])]);Number(c)||Number(d)||Number(l)||Number(g)||Number(m)||Number(v)||Number(h)?(document.getElementById("error").innerHTML="",renderMetric(a,c,1,"Pageviews"),renderMetric(r,d,2,"Unique Pageviews"),renderMetric(n,l,3,"Users"),renderMetric(o,g,4,"New Users"),renderMetric(i,formatTime(m),5,"Avg. Time on Page"),renderMetric(s,formatTime(v),6,"Page Load Time"),renderMetric(u,h+"%",7,"Bounce Rate")):(document.getElementById("canvasbody").innerHTML=" ",displayError("No data available")),"full_width"===extensionDashboardField.window.state&&extensionDashboardField.window.enableAutoResizing()}function loadIntervalData(e,t){document.getElementById("error").innerHTML=" ",document.getElementById("canvasbody").innerHTML="";for(var a=document.getElementsByClassName("btn cs-btn-primary"),r=t,n=0;n<a.length;n+=1)a[n].style.backgroundColor="white";r.style.backgroundColor="#e6eaf2",toggleButtons(!0),analytics.getData(e).then(function(e){renderData(currentData=e),toggleButtons(!1)}).catch(function(e){displayError(e.message),toggleButtons(!1)})}ContentstackUIExtension.init().then(function(e){var t=document.getElementsByClassName("btn cs-btn-primary");extensionDashboardField=e,google.charts.load("current",{packages:["corechart"]}),google.charts.setOnLoadCallback(loadIntervalData.bind(null,30,t[3])),e.window.onDashboardResize(function(){setTimeout(function(){renderData()},500)}),analytics=new Analytics(extensionDashboardField.config),extensionDashboardField.window.enableResizing()});
let extensionDashboardField,analytics,currentData;class Analytics{constructor({url:e,view_id:t,"x-api-key":a}){this.baseUrl=e,this.viewId=t,this.xApiKey=a}getData(e=30){var t=this;let a={};return t.xApiKey&&(a["x-api-key"]=t.xApiKey),fetch(`${t.baseUrl}?view_id=${t.viewId}&start_date=${e}daysAgo&end_date=today&metrics=ga:pageviews,ga:uniquePageviews,ga:users,ga:newUsers,ga:avgTimeOnPage,ga:pageLoadTime,ga:bounceRate&dimensions=ga:date`,{method:"GET",headers:a}).then(e=>{if(200===e.status)return e.json();throw new Error("Error in fetching data.</br>Please check extension configuration.")}).catch(e=>Promise.reject(e))}}function toggleLoader(e){document.getElementById("loader").style.display=e?"block":"none"}function toggleButtons(t){let a=document.getElementsByClassName("btn cs-btn-primary");for(let e=0;e<a.length;e+=1)a[e].disabled=t;toggleLoader(t)}function formatDate(e){return`${e[0]+e[1]+e[2]+e[3]}-${e[4]+e[5]}-${e[6]+e[7]}`}function addPadding(e){return 1===e.length?`0${e}`:`${e}`}function formatTime(e){var t,a;let r=e;return r%=86400,t=(r/3600).toFixed(),r%=3600,a=(r/60).toFixed(),r%=60,e=r.toFixed(),`${addPadding(t)}:${addPadding(a)}:${addPadding(e)}`}function drawChart(e,t){e=google.visualization.arrayToDataTable(e);let a=new google.visualization.AreaChart(document.getElementById("chart_container_"+t));a.draw(e,{hAxis:{textPosition:"none"},vAxis:{minValue:0},legend:"none",colors:["#098ec8"],backgroundColor:"#F8F8F8"})}function renderMetric(e,t,a,r){let n=document.getElementById("canvasbody");n.innerHTML+=`<div class="graph-wrap"><div class="metric-details"><p>${r}</p><h1>${t}</h1></div><div id="chart_container_${a}"></div></div>`,drawChart(e,a)}function displayError(e){let t=document.getElementById("error");t.innerHTML=`<p>${e}</p>`}function renderData(e){document.getElementById("canvasbody").innerHTML=" ",currentData=e||currentData;let t,a,r,n,o,s,i;var l,d=currentData.totalsForAllResults["ga:pageviews"],u=currentData.totalsForAllResults["ga:uniquePageviews"],c=currentData.totalsForAllResults["ga:users"],g=currentData.totalsForAllResults["ga:newUsers"],m=currentData.totalsForAllResults["ga:avgTimeOnPage"],D=currentData.totalsForAllResults["ga:pageLoadTime"],e=currentData.totalsForAllResults["ga:bounceRate"];t=[["year","count"]],a=[["year","count"]],r=[["year","count"]],n=[["year","count"]],o=[["year","count"]],s=[["year","count"]],i=[["year","count"]],l=currentData.rows.length;for(let e=0;e<l;e+=1)t.push([formatDate(currentData.rows[e][0]),Number(currentData.rows[e][1])]),a.push([formatDate(currentData.rows[e][0]),Number(currentData.rows[e][2])]),r.push([formatDate(currentData.rows[e][0]),Number(currentData.rows[e][3])]),n.push([formatDate(currentData.rows[e][0]),Number(currentData.rows[e][4])]),o.push([formatDate(currentData.rows[e][0]),Number(currentData.rows[e][5])]),s.push([formatDate(currentData.rows[e][0]),Number(currentData.rows[e][6])]),i.push([formatDate(currentData.rows[e][0]),Number(currentData.rows[e][7])]);Number(d)||Number(u)||Number(c)||Number(g)||Number(m)||Number(D)||Number(e)?(document.getElementById("error").innerHTML="",renderMetric(t,d,1,"Pageviews"),renderMetric(a,u,2,"Unique Pageviews"),renderMetric(r,c,3,"Users"),renderMetric(n,g,4,"New Users"),renderMetric(o,formatTime(m),5,"Avg. Time on Page"),renderMetric(s,formatTime(D),6,"Page Load Time"),renderMetric(i,e+"%",7,"Bounce Rate")):(document.getElementById("canvasbody").innerHTML=" ",displayError("No data available")),"full_width"===extensionDashboardField.window.state&&extensionDashboardField.window.enableAutoResizing()}function loadIntervalData(e,t){document.getElementById("error").innerHTML=" ",document.getElementById("canvasbody").innerHTML="";let a=document.getElementsByClassName("btn cs-btn-primary"),r=t;for(let e=0;e<a.length;e+=1)a[e].style.backgroundColor="white";r.style.backgroundColor="#e6eaf2",toggleButtons(!0),analytics.getData(e).then(e=>{renderData(currentData=e),toggleButtons(!1)}).catch(e=>{displayError(e.message),toggleButtons(!1)})}ContentstackUIExtension.init().then(e=>{var t=document.getElementsByClassName("btn cs-btn-primary");extensionDashboardField=e,google.charts.load("current",{packages:["corechart"]}),google.charts.setOnLoadCallback(loadIntervalData.bind(null,30,t[3])),e.window.onDashboardResize(()=>{setTimeout(()=>{renderData()},500)}),analytics=new Analytics(extensionDashboardField.config),extensionDashboardField.window.enableResizing()});
</script>
</body>
</html>
Loading

0 comments on commit 6eaa3c4

Please sign in to comment.