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

jwt-js

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jwt-js - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

2

lib/tokenizer.js

@@ -35,3 +35,3 @@ 'use strict'

Tokenizer.prototype.encode = function(payload, rawPrivateKey) {
Tokenizer.prototype.sign = function(payload, rawPrivateKey) {
var tokenParts = []

@@ -38,0 +38,0 @@

{
"name": "jwt-js",
"version": "0.1.0",
"version": "0.2.0",
"description": "node.js library for encoding, decoding, and verifying JSON Web Tokens (JWTs)",

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

@@ -1,5 +0,10 @@

# jsonwebtoken-js
# jwt-js
node.js library for encoding, decoding, and verifying JSON Web Tokens (JWTs)
[![npm](https://img.shields.io/npm/l/jwt-js.svg)](https://www.npmjs.com/package/jwt-js)
[![Slack](http://slack.blockstack.org/badge.svg)](http://slack.blockstack.org/)
[![](https://nodei.co/npm/jwt-js.png)](https://www.npmjs.com/package/jwt-js)
node.js library for signing, decoding, and verifying JSON Web Tokens (JWTs)
### Installation

@@ -26,12 +31,13 @@

### Encoding Tokens
### Signing Tokens
```js
var tokenPayload = {"issuedAt": "1440713414.85", "challenge": "7cd9ed5e-bb0e-49ea-a323-f28bde3a0549", "issuer": {"publicKey": "03fdd57adec3d438ea237fe46b33ee1e016eda6b585c3e27ea66686c2ea5358479", "chainPath": "bd62885ec3f0e3838043115f4ce25eedd22cc86711803fb0c19601eeef185e39", "publicKeychain": "xpub661MyMwAqRbcFQVrQr4Q4kPjaP4JjWaf39fBVKjPdK6oGBayE46GAmKzo5UDPQdLSM9DufZiP8eauy56XNuHicBySvZp7J5wsyQVpi2axzZ", "blockchainid": "ryan"}}
var encodedToken = tokenizer.encode(tokenPayload, rawPrivateKey)
var tokenPayload = {"issuedAt": "1440713414.85", "challenge": "7cd9ed5e-bb0e-49ea-a323-f28bde3a0549", "issuer": {"publicKey": "03fdd57adec3d438ea237fe46b33ee1e016eda6b585c3e27ea66686c2ea5358479", "chainPath": "bd62885ec3f0e3838043115f4ce25eedd22cc86711803fb0c19601eeef185e39", "publicKeychain": "xpub661MyMwAqRbcFQVrQr4Q4kPjaP4JjWaf39fBVKjPdK6oGBayE46GAmKzo5UDPQdLSM9DufZiP8eauy56XNuHicBySvZp7J5wsyQVpi2axzZ", "blockchainid": "ryan"}},
encodedToken = tokenizer.sign(tokenPayload, rawPrivateKey)
```
Example output:
##### Example output:
```
```js
> console.log(encodedToken)
eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3N1ZWRBdCI6IjE0NDA3MTM0MTQuODUiLCJjaGFsbGVuZ2UiOiI3Y2Q5ZWQ1ZS1iYjBlLTQ5ZWEtYTMyMy1mMjhiZGUzYTA1NDkiLCJpc3N1ZXIiOnsicHVibGljS2V5IjoiMDNmZGQ1N2FkZWMzZDQzOGVhMjM3ZmU0NmIzM2VlMWUwMTZlZGE2YjU4NWMzZTI3ZWE2NjY4NmMyZWE1MzU4NDc5IiwiY2hhaW5QYXRoIjoiYmQ2Mjg4NWVjM2YwZTM4MzgwNDMxMTVmNGNlMjVlZWRkMjJjYzg2NzExODAzZmIwYzE5NjAxZWVlZjE4NWUzOSIsInB1YmxpY0tleWNoYWluIjoieHB1YjY2MU15TXdBcVJiY0ZRVnJRcjRRNGtQamFQNEpqV2FmMzlmQlZLalBkSzZvR0JheUU0NkdBbUt6bzVVRFBRZExTTTlEdWZaaVA4ZWF1eTU2WE51SGljQnlTdlpwN0o1d3N5UVZwaTJheHpaIiwiYmxvY2tjaGFpbmlkIjoicnlhbiJ9fQ.oO7ROPKq3T3X0azAXzHsf6ub6CYy5nUUFDoy8MS22B3TlYisqsBrRtzWIQcSYiFXLytrXwAdt6vjehj3OFioDQ

@@ -46,5 +52,6 @@ ```

Example output:
##### Example output:
```
```js
> console.log(decodedToken)
{ header: { alg: 'ES256', typ: 'JWT' },

@@ -65,3 +72,10 @@ payload:

```js
var verified = tokenizer.verify(sampleToken, rawPublicKey)
var verified = tokenizer.verify(encodedToken, rawPublicKey)
```
##### Example output:
```js
> console.log(verified)
true
```

@@ -27,3 +27,3 @@ 'use strict'

var encodedToken = tokenizer.encode(sampleDecodedToken.payload, rawPrivateKey)
var encodedToken = tokenizer.sign(sampleDecodedToken.payload, rawPrivateKey)
t.ok(encodedToken, 'token should have been created')

@@ -30,0 +30,0 @@ t.equal(typeof encodedToken, 'string', 'token should be a string')

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