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

cssserve

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cssserve - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

6

CHANGELOG.md

@@ -7,2 +7,8 @@ # Change Log

## 1.1.2
_2020-05-08_
- fix: Return 404/403 for "not found" and "forbidden" bundling tokens
## 1.1.1

@@ -9,0 +15,0 @@

2

package.json
{
"name": "cssserve",
"version": "1.1.1",
"version": "1.1.2",
"license": "MIT",

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

@@ -16,2 +16,31 @@ #!/usr/bin/env node

/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) { if (b.hasOwnProperty(p)) { d[p] = b[p]; } } };
return extendStatics(d, b);
};
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
// ---------------------------------------------------------------------------

@@ -261,38 +290,17 @@ /**

/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
// ---------------------------------------------------------------------------
var NotFoundError = /** @class */ (function (_super) {
__extends(NotFoundError, _super);
function NotFoundError(message) {
var _newTarget = this.constructor;
var _this = _super.call(this, message) || this;
_this.__proto__ = _newTarget.prototype; // TS Extend native type Workaround
return _this;
}
return NotFoundError;
}(Error));
var ModuleError = /** @class */ (function (_super) {
__extends(ModuleError, _super);
function ModuleError(message, moduleName) {
var _newTarget = this.constructor;
var _this = _super.call(this, message + ': ' + JSON.stringify(moduleName)) || this;
_this.__proto__ = _newTarget.prototype; // TS Extend native type Workaround
_this.moduleName = moduleName;

@@ -302,3 +310,3 @@ return _this;

return ModuleError;
}(Error));
}(NotFoundError));
var NonExistentModuleError = /** @class */ (function (_super) {

@@ -432,7 +440,12 @@ __extends(NonExistentModuleError, _super);

// ===========================================================================
var retInvalidVersion = function (versionParam) {
return Promise.reject('Invalid version ' + JSON.stringify(versionParam));
};
var VersionError = /** @class */ (function (_super) {
__extends(VersionError, _super);
function VersionError(versionParam) {
return _super.call(this, 'Invalid version ' + JSON.stringify(versionParam)) || this;
}
return VersionError;
}(NotFoundError));
var getCssBundle = function (req) {
return Promise.resolve().then(function () {
return Promise.resolve()
.then(function () {
var url = req.req.url;

@@ -449,11 +462,11 @@ var cachedBundle = bundleCache.get(url);

refreshCache();
return retInvalidVersion(versionParam);
throw new VersionError(versionParam);
}
var versionFolder = resolveCssVersionFolder(staticFolder, versionParam);
if (!versionFolder) {
return retInvalidVersion(versionParam);
throw new VersionError(versionParam);
}
var modules = getModuleListFromQuery(req.query);
if (modules.length === 0) {
return Promise.reject('No modules specified');
throw new NotFoundError('No modules specified');
}

@@ -479,2 +492,8 @@ // Check if a cached result exists for the normalized version of the token list

});
})
.catch(function (error) {
if (error instanceof NotFoundError) {
return { error: error };
}
throw error;
});

@@ -495,12 +514,19 @@ };

}
return getCssBundle(req).then(function (_a) {
var css = _a.css, linkHeader = _a.linkHeader;
res.headers({
Link: linkHeader,
ETag: lastModified,
'Content-Type': 'text/css; charset=UTF-8',
'Cache-Control': CACHE_CONTROL_VALUE,
});
res.status(200);
res.send(css);
return getCssBundle(req).then(function (result) {
if ('error' in result) {
var status_1 = result.error instanceof UnsafeModuleTokenError ? 403 : 404;
res.status(status_1);
res.send(result.error.message);
}
else {
var css = result.css, linkHeader = result.linkHeader;
res.headers({
Link: linkHeader,
ETag: lastModified,
'Content-Type': 'text/css; charset=UTF-8',
'Cache-Control': CACHE_CONTROL_VALUE,
});
res.status(200);
res.send(css);
}
});

@@ -507,0 +533,0 @@ };

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