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

@koopjs/auth-direct-file

Package Overview
Dependencies
Maintainers
7
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@koopjs/auth-direct-file - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

4

CHANGELOG.md

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

## 2.0.3
### Fixed
* username and password can arrive on query or body
## 2.0.2

@@ -7,0 +11,0 @@ * patch - invalidate with user not found

2

package.json
{
"name": "@koopjs/auth-direct-file",
"version": "2.0.2",
"version": "2.0.3",
"description": "Module for implementing a direct authentication pattern with file-based user-store in Koop",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -75,5 +75,6 @@ const fs = require('fs');

async function authenticate(req) {
const username = req.query?.username;
const password = req.query?.password;
const { query = {}, body = {} } = req;
const { username, password } = {...query, ...body};
// Validate user's credentials

@@ -80,0 +81,0 @@ const valid = await validateCredentials(

@@ -76,3 +76,3 @@ const helpers = require('./validate-credentials');

test('should validate and send jwt', async () => {
test('should validate creds from query and send jwt', async () => {
helpers.validateCredentials.mockImplementationOnce(() => {

@@ -97,2 +97,23 @@ return true;

});
test('should validate creds from body and send jwt', async () => {
helpers.validateCredentials.mockImplementationOnce(() => {
return true;
});
jwt.sign.mockImplementationOnce(() => {
return 'abc';
});
const authPlugin = require('./index.js')(
secret,
path.join(__dirname, '../test/fixtures/user-store.json'),
{ useHttp: true }
);
const result = await authPlugin.authenticate({ body: { username: 'foo', password: 'bar' } });
expect(result.token).toEqual('abc');
expect(result.expires).toBeGreaterThan(Date.now());
});
});

@@ -99,0 +120,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