Socket
Socket
Sign inDemoInstall

jwt-mock-server

Package Overview
Dependencies
76
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.1 to 0.0.2

2

package.json
{
"name": "jwt-mock-server",
"version": "0.0.1",
"version": "0.0.2",
"description": "Start a mock jwt authentication server for local development",

@@ -5,0 +5,0 @@ "keywords": [

@@ -21,2 +21,3 @@ ## A JWT mock server for local development

get a jwt token and pass claims in post body
```shell

@@ -28,2 +29,8 @@ curl --location --request POST 'localhost:9000/jwt/token' \

get a jwt using get and pass claims in query params:
```shell
curl --location --request GET 'localhost:9000/jwt/token?username=abc@test.com.au&authorities=AUTH_WP&authorities=AUTH_WP2' \
--header 'Content-Type: application/json'
```
shutdown the server gracefully

@@ -30,0 +37,0 @@ ```shell

@@ -27,6 +27,6 @@ var express = require('express');

var token = await new Promise((resolve) => {
jose.JWS.createSign({ alg: 'RS256', format: 'compact' }, key).
update(JSON.stringify(req.body)).
final().
then(function(result) {
jose.JWS.createSign({ alg: 'RS256', format: 'compact' }, key)
.update(JSON.stringify(req.body))
.final()
.then(function(result) {
resolve(result);

@@ -39,3 +39,21 @@ });

router.get('/token', async function(req, res) {
var keys = await getKeyStore();
var key = keys.all()[0];
var body = req.query;
body["iat"] = Math.floor(Date.now() / 1000);
body["exp"] = Math.floor(Date.now() / 1000) + 3600;
var token = await new Promise((resolve) => {
jose.JWS.createSign({ alg: 'RS256', format: 'compact' }, key)
.update(JSON.stringify(body))
.final()
.then(function(result) {
resolve(result);
});
});
res.json({token: token});
});
module.exports = router;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc