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

@sapphire/plugin-api

Package Overview
Dependencies
Maintainers
3
Versions
792
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sapphire/plugin-api - npm Package Compare versions

Comparing version 2.0.4 to 2.0.5

6

CHANGELOG.md

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

## [2.0.5](https://github.com/sapphire-project/plugins/compare/@sapphire/plugin-api@2.0.4...@sapphire/plugin-api@2.0.5) (2021-04-03)
### Bug Fixes
- **api:** fixed how domain is retrieved for cookies ([#72](https://github.com/sapphire-project/plugins/issues/72)) ([bd5302f](https://github.com/sapphire-project/plugins/commit/bd5302fca79606f887bed19ffc828dccbecdb991))
## [2.0.4](https://github.com/sapphire-project/plugins/compare/@sapphire/plugin-api@2.0.3...@sapphire/plugin-api@2.0.4) (2021-03-16)

@@ -8,0 +14,0 @@

@@ -13,2 +13,9 @@ import type { ApiRequest } from './ApiRequest';

protected prepare(name: string, value: string, { expires, maxAge, domain, path, httpOnly }?: SecureCookieStoreSetOptions): string;
/**
* Parses a host using the {@link https://github.com/lupomontero/psl psl} library to extract the domain.
* This is used for the domain of the cookie
* @param host The hot to parse
* @returns Either the host in all lower case or the parsed domain, ready for use on cookies
*/
private getHostDomain;
private static readonly octetRegExp;

@@ -15,0 +22,0 @@ private static encodeCookieOctet;

27

dist/lib/structures/api/CookieStore.js

@@ -6,2 +6,4 @@ "use strict";

exports.CookieStore = void 0;
const tslib_1 = require("tslib");
const psl_1 = tslib_1.__importDefault(require("psl"));
class CookieStore extends Map {

@@ -48,5 +50,4 @@ constructor(request, response, secure) {

}
const [domain] = (_b = (_a = this.request.headers.host) === null || _a === void 0 ? void 0 : _a.split(':')) !== null && _b !== void 0 ? _b : [''];
// RFC 6265 5.1.3 Domain Matching
this.domain = domain.toLowerCase();
const [splitHost] = (_b = (_a = this.request.headers.host) === null || _a === void 0 ? void 0 : _a.split(':')) !== null && _b !== void 0 ? _b : [''];
this.domain = this.getHostDomain(splitHost);
if (this.request.socket.remoteAddress === this.domain) {

@@ -105,2 +106,22 @@ throw new Error('The connection must be established from the domain name (i.e., not an IP address)');

}
/**
* Parses a host using the {@link https://github.com/lupomontero/psl psl} library to extract the domain.
* This is used for the domain of the cookie
* @param host The hot to parse
* @returns Either the host in all lower case or the parsed domain, ready for use on cookies
*/
getHostDomain(host) {
// Transform the host to lower case
const lowercaseHost = host.toLowerCase();
// Try parsing the host with psl
const pslParsedInfo = psl_1.default.parse(lowercaseHost);
// If an error ocurred then return the host in lowercase
if (pslParsedInfo.error)
return lowercaseHost;
// If the domain property is not defined then return the host in lowercase
if (!pslParsedInfo.domain)
return lowercaseHost;
// If the domain was found from parsing then prefix it with a . for a cookie that works with subdomains and return it
return `.${pslParsedInfo.domain}`;
}
static encodeCookieOctet(value) {

@@ -107,0 +128,0 @@ if (CookieStore.octetRegExp.test(value)) {

2

dist/lib/structures/MediaParser.d.ts

@@ -39,4 +39,4 @@ /// <reference types="node" />

*/
protected contentStream(request: ApiRequest): import("zlib").BrotliDecompress | ApiRequest | null;
protected contentStream(request: ApiRequest): ApiRequest | import("zlib").Gunzip | null;
}
//# sourceMappingURL=MediaParser.d.ts.map
{
"name": "@sapphire/plugin-api",
"version": "2.0.4",
"version": "2.0.5",
"description": "Plugin for @sapphire/framework to expose a REST API",

@@ -31,11 +31,13 @@ "author": "@sapphire",

"dependencies": {
"@types/psl": "^1.1.0",
"node-fetch": "^2.6.1",
"psl": "^1.8.0",
"tslib": "^2.1.0"
},
"peerDependencies": {
"@sapphire/framework": "^1.0.0",
"@sapphire/framework": "^1.x",
"@sapphire/pieces": "1.x",
"@types/node-fetch": "^2.x",
"@types/ws": "latest",
"discord-api-types": "^0.12.1",
"discord-api-types": "^0.13.x",
"discord.js": "12.x"

@@ -84,3 +86,3 @@ },

},
"gitHead": "f4047eda318d2f52d2f84071b29300c6a5f6e2db"
"gitHead": "fb75c67a069f3b3cc08d52a3293d2442c17241fa"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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