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

jwt-koa

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jwt-koa - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

2

package.json
{
"name": "jwt-koa",
"version": "1.0.6",
"version": "1.0.7",
"main": "index.js",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -22,2 +22,40 @@ # jwt-koa

### Usage
#### Import
```js
const jwtKoa = require('jwt-koa');
```
#### Set middleware to secured Router
```js
process.env.secret = 'SECRET';
securedRouter.use(jwtKoa);
securedRouter.get('/secured', async ctx => {
ctx.body = { data: 'Secured Data' };
});
```
#### Send token to client
```js
notSecuredRouter.post('/send', async ctx => {
const token = jwt.sign({ data: 'DATA' }, process.env.secret, {
expiresIn: 3000
});
ctx.response.body = token;
});
```
### Client-side example
```js
fetch('/secured', { method: 'GET', headers: { Authorization: /* There is token from backend*/ } })
.then(j => j.json())
.then(data => /* There is secured data*/);
```
#### [Usage example](https://github.com/VamOSGS/jwt-koa/blob/master/example/index.js)
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