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.2 to 2.0.3

6

CHANGELOG.md

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

## [2.0.3](https://github.com/sapphire-project/plugins/compare/@sapphire/plugin-api@2.0.2...@sapphire/plugin-api@2.0.3) (2021-02-16)
### Bug Fixes
- **plugin-api:** automatically remove cookie on invalid token ([#62](https://github.com/sapphire-project/plugins/issues/62)) ([5ce667e](https://github.com/sapphire-project/plugins/commit/5ce667ed6fc1eb1b2b88fea7698041d71c4579b7))
## [2.0.2](https://github.com/sapphire-project/plugins/compare/@sapphire/plugin-api@2.0.1...@sapphire/plugin-api@2.0.2) (2021-02-13)

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

1

dist/lib/structures/api/CookieStore.d.ts

@@ -10,2 +10,3 @@ import type { ApiRequest } from './ApiRequest';

add(name: string, value: string, options?: SecureCookieStoreSetOptions): void;
remove(name: string): void;
protected insert(name: string, entry: string): void;

@@ -12,0 +13,0 @@ protected prepare(name: string, value: string, { expires, maxAge, domain, path, httpOnly }?: SecureCookieStoreSetOptions): string;

@@ -59,2 +59,5 @@ "use strict";

}
remove(name) {
this.add(name, '', { expires: new Date(0) });
}
insert(name, entry) {

@@ -61,0 +64,0 @@ let set = this.response.getHeader('Set-Cookie');

@@ -20,4 +20,12 @@ "use strict";

run(request, response) {
// If there are no cookies, set auth as null:
const authorization = response.cookies.get(this.cookieName);
request.auth = authorization ? this.context.server.auth.decrypt(authorization) : null;
if (!authorization) {
request.auth = null;
return;
}
// Decrypt the cookie, and if the token is invalid, remove the cookie:
request.auth = this.context.server.auth.decrypt(authorization);
if (request.auth === null)
response.cookies.remove(this.cookieName);
}

@@ -24,0 +32,0 @@ }

2

dist/routes/oauth/logout.js

@@ -51,3 +51,3 @@ "use strict";

// Sending an empty cookie with "expires" set to 1970-01-01 makes the browser instantly remove the cookie.
response.cookies.add(this.context.server.auth.cookie, '', { expires: new Date(0) });
response.cookies.remove(this.context.server.auth.cookie);
return response.json({ success: true });

@@ -54,0 +54,0 @@ }

{
"name": "@sapphire/plugin-api",
"version": "2.0.2",
"version": "2.0.3",
"description": "Plugin for @sapphire/framework to expose a REST API",

@@ -83,3 +83,3 @@ "author": "@sapphire",

},
"gitHead": "f8102b3f296c3287d9dc965c19743c25529524b2"
"gitHead": "a7641e736d3cb7351e35428d21666518f13b7996"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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