Skip to content

Commit

Permalink
Merge pull request #28 from Automattic/fix/insecure-dependencies
Browse files Browse the repository at this point in the history
Update dependencies to secure versions
  • Loading branch information
thingalon authored Jan 12, 2022
2 parents fda7427 + 7febd62 commit a4721f4
Show file tree
Hide file tree
Showing 11 changed files with 3,927 additions and 5,815 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
},
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2020
"ecmaVersion": 2020,
"requireConfigFile": false
},
"extends": [
"eslint:recommended",
Expand Down
4 changes: 2 additions & 2 deletions lib/browser-interface-iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ class BrowserInterfaceIframe extends BrowserInterface {
* Wrapper for window.fetch. Overload this to change CSS or HTML fetching
* behaviour.
*
* @param {string} url URL to fetch.
* @param {string} url URL to fetch.
* @param {Object} options Fetch options.
* @param {string} _role 'css' or 'html' indicating what kind of thing is being fetched.
* @param {string} _role 'css' or 'html' indicating what kind of thing is being fetched.
*/
async fetch( url, options, _role ) {
return window.fetch( url, options );
Expand Down
4 changes: 2 additions & 2 deletions lib/browser-interface-playwright.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ class BrowserInterfacePlaywright extends BrowserInterface {
* Replacement for browser.fetch, uses node-fetch to simulate the same
* interface.
*
* @param {string} url URL to fetch.
* @param {string} url URL to fetch.
* @param {Object} options Fetch options.
* @param {string} _role 'css' or 'html' indicating what kind of thing is being fetched.
* @param {string} _role 'css' or 'html' indicating what kind of thing is being fetched.
*/
async fetch( url, options, _role ) {
const nodeFetch = require( 'node-fetch' );
Expand Down
4 changes: 2 additions & 2 deletions lib/browser-interface-puppeteer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ class BrowserInterfacePuppeteer extends BrowserInterface {
* Replacement for browser.fetch, uses node-fetch to simulate the same
* interface.
*
* @param {string} url URL to fetch.
* @param {string} url URL to fetch.
* @param {Object} options Fetch options.
* @param {string} _role 'css' or 'html' indicating what kind of thing is being fetched.
* @param {string} _role 'css' or 'html' indicating what kind of thing is being fetched.
*/
async fetch( url, options, _role ) {
const nodeFetch = require( 'node-fetch' );
Expand Down
22 changes: 11 additions & 11 deletions lib/browser-interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class BrowserInterface {
* Context-specific wrapper for fetch; uses window.fetch in browsers, or a
* node library when using Puppeteer.
*
* @param {string} _url URL to fetch.
* @param {string} _url URL to fetch.
* @param {Object} _options Fetch options.
* @param {string} _role 'css' or 'html' indicating what kind of thing is being fetched.
* @param {string} _role 'css' or 'html' indicating what kind of thing is being fetched.
*/
async fetch( _url, _options, _role ) {
throw new Error(
Expand Down Expand Up @@ -60,10 +60,10 @@ class BrowserInterface {
* for easy querySelector calling (values), return an array of selectors which match
* _any_ element on the page.
*
* @param {Object} wrappedArgs
* @param {Window} wrappedArgs.innerWindow - Window inside the browser interface.
* @param {Object[]} wrappedArgs.args - Array of arguments.
* {Object} wrappedArgs.args[selectors] - Map containing selectors (object keys), and simplified versions for easy matching (values).
* @param {Object} wrappedArgs
* @param {Window} wrappedArgs.innerWindow - Window inside the browser interface.
* @param {Object[]} wrappedArgs.args - Array of arguments.
* {Object} wrappedArgs.args[selectors] - Map containing selectors (object keys), and simplified versions for easy matching (values).
*/
static innerFindMatchingSelectors( { innerWindow, args: [ selectors ] } ) {
innerWindow = null === innerWindow ? window : innerWindow;
Expand All @@ -84,11 +84,11 @@ class BrowserInterface {
* for easy querySelector calling (values), return an array of selectors which match
* any above-the-fold element on the page.
*
* @param {Object} wrappedArgs
* @param {Window} wrappedArgs.innerWindow - Window inside the browser interface.
* @param {Object[]} wrappedArgs.args - Array of arguments.
* {Object} wrappedArgs.args[selectors] - Map containing selectors (object keys), and simplified versions for easy matching (values).
* {string[]} wrappedArgs.args[pageSelectors] - String array containing selectors that appear anywhere on this page (as returned by innerFindMatchingSelectors) - should be a subset of keys in selectors.
* @param {Object} wrappedArgs
* @param {Window} wrappedArgs.innerWindow - Window inside the browser interface.
* @param {Object[]} wrappedArgs.args - Array of arguments.
* {Object} wrappedArgs.args[selectors] - Map containing selectors (object keys), and simplified versions for easy matching (values).
* {string[]} wrappedArgs.args[pageSelectors] - String array containing selectors that appear anywhere on this page (as returned by innerFindMatchingSelectors) - should be a subset of keys in selectors.
*/
static innerFindAboveFoldSelectors( {
innerWindow,
Expand Down
16 changes: 8 additions & 8 deletions lib/css-file-set.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CSSFileSet {
/**
* Add a set of CSS URLs from an HTML page to this set.
*
* @param {string} page - URL of the page the CSS URLs were found on.
* @param {string} page - URL of the page the CSS URLs were found on.
* @param {Object} cssIncludes - Included CSS Files. Keyed by URL.
*/
async addMultiple( page, cssIncludes ) {
Expand All @@ -34,8 +34,8 @@ class CSSFileSet {
/**
* Add a CSS URL from an HTML page to this set.
*
* @param {string} page - URL of the page the CSS URL was found on.
* @param {string} cssUrl - The CSS file URL.
* @param {string} page - URL of the page the CSS URL was found on.
* @param {string} cssUrl - The CSS file URL.
* @param {Object} settings
*/
async add( page, cssUrl, settings = {} ) {
Expand Down Expand Up @@ -183,9 +183,9 @@ class CSSFileSet {
* Internal method: Store the specified css found at the cssUrl for an HTML page,
* de-duplicating CSS files by content along the way.
*
* @param {string} page - URL of HTML page this CSS file was found on.
* @param {string} page - URL of HTML page this CSS file was found on.
* @param {string} cssUrl - URL of the CSS file.
* @param {string} css - Content of the CSS File.
* @param {string} css - Content of the CSS File.
*/
storeCss( page, cssUrl, css ) {
// De-duplicate css contents in case cache busters in URLs or WAFs, etc confound URL de-duplication.
Expand All @@ -210,8 +210,8 @@ class CSSFileSet {
* Internal method: Add an extra reference to a previously known CSS file found either
* on a new HTML page, or at a new URL.
*
* @param {string} page - URL of the page this CSS file was found on.
* @param {string} cssUrl - URL of the CSS File.
* @param {string} page - URL of the page this CSS file was found on.
* @param {string} cssUrl - URL of the CSS File.
* @param {Object} matchingFile - Internal CSS File object.
*/
addExtraReference( page, cssUrl, matchingFile ) {
Expand All @@ -227,7 +227,7 @@ class CSSFileSet {
* Stores an error that occurred while fetching or parsing CSS at the given URL.
*
* @param {string} url - CSS URL that failed to fetch or parse.
* @param {Error} err - Error object describing the problem.
* @param {Error} err - Error object describing the problem.
*/
storeError( url, err ) {
this.knownUrls[ url ] = err;
Expand Down
20 changes: 10 additions & 10 deletions lib/generate-critical-css.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ const BrowserInterface = require( './browser-interface' );
*
* Errors that occur during this process are collated, but not thrown yet.
*
* @param {BrowserInterface} browserInterface - interface to access pages
* @param {string[]} urls - list of URLs to scan for CSS files
* @param {number} successUrlsThreshold - success urls amount threshold
* @param {BrowserInterface} browserInterface - interface to access pages
* @param {string[]} urls - list of URLs to scan for CSS files
* @param {number} successUrlsThreshold - success urls amount threshold
* @return {Array} - Two member array; CSSFileSet, and an object containing errors that occurred at each URL.
*/
async function collateCssFiles( browserInterface, urls, successUrlsThreshold ) {
Expand Down Expand Up @@ -51,13 +51,13 @@ async function collateCssFiles( browserInterface, urls, successUrlsThreshold ) {
/**
* Get CSS selectors for above the fold content for the valid URLs.
*
* @param {Object} param - All the parameters as object.
* @param {BrowserInterface} param.browserInterface - Interface to access pages
* @param {Object} param.selectorPages - All the CSS selectors to URLs map object
* @param {string[]} param.validUrls - List of all the valid URLs
* @param {Array} param.viewports - Browser viewports
* @param {number} param.successUrlsThreshold - Success URLs amount threshold
* @param {Function} param.updateProgress - Update progress callback function
* @param {Object} param - All the parameters as object.
* @param {BrowserInterface} param.browserInterface - Interface to access pages
* @param {Object} param.selectorPages - All the CSS selectors to URLs map object
* @param {string[]} param.validUrls - List of all the valid URLs
* @param {Array} param.viewports - Browser viewports
* @param {number} param.successUrlsThreshold - Success URLs amount threshold
* @param {Function} param.updateProgress - Update progress callback function
*
* @return {Set<string>} - List of above the fold selectors.
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/minify-css.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const CleanCSS = require( 'clean-css' );
*
* @param {string} css - CSS to minify.
*
* return {[ string, string[] ]} - Minified CSS and a list of errors returned.
* return {[ string, string[] ]} - Minified CSS and a list of errors returned.
*/
function minifyCss( css ) {
const result = new CleanCSS().minify( css );
Expand Down
Loading

0 comments on commit a4721f4

Please sign in to comment.