1.2.0 • Published 1 year ago

@verimatrix/token-generation-middleware v1.2.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

token-generation-middleware

An express middleware that generates and includes a JWT token in the response.

Usage

Install the middleware plugin in your NPM project with npm or yarn:

  • npm install --save @verimatrix/token-generation-middleware
  • yarn add @verimatrix/token-generation-middleware

Import and use in your express app:

import express from "express";
import tokenGenerator from "@verimatrix/token-generation-middleware";

const app = express.app();

app.use(
  tokenGenerator({
    privateKey: "***",
    operator: {
      audience: "myAudience",
      issuer: "myIssuer",
      keyId: "myKeyId",
    },
    expiresIn: 30,
  })
);

Then, send a request to your express app:

curl "http://localhost:8080/token?subject=foo"

POST Request Support

The middleware supports generating tokens with GET or POST requests, but to allow the middleware to access data in the POST request bodies, you must enable JSON body parsing in the express app first.

import express from "express";
import tokenGenerator from "@verimatrix/token-generation-middleware";

const app = express.app();

// enable JSON body parsing
app.use(express.json());

app.use(tokenGenerator({ ... }));
1.2.0

1 year ago

1.1.0

1 year ago

1.2.0-beta.5

1 year ago

1.2.0-beta.4

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago