https://github.com/convergencelabs/convergence-jwt-util
A JWT Generator for Convergence.
https://github.com/convergencelabs/convergence-jwt-util
convergence jwt jwt-generator realtime
Last synced: 5 months ago
JSON representation
A JWT Generator for Convergence.
- Host: GitHub
- URL: https://github.com/convergencelabs/convergence-jwt-util
- Owner: convergencelabs
- License: mit
- Created: 2016-12-22T18:17:31.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T06:31:46.000Z (over 3 years ago)
- Last Synced: 2025-11-01T23:12:06.806Z (8 months ago)
- Topics: convergence, jwt, jwt-generator, realtime
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/@convergence/jwt-util
- Size: 854 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Convergence JWT Generator
[](https://travis-ci.org/convergencelabs/convergence-jwt-util)
This project helps users easily create a JavaScript Web Token (JWT) for logging into Convergence. JWTs allow Convergnece to trust that an external system has properly authenticated a user. Convergence uses asymetric RSA Public / Private keys to generate JWTs. Convergence will store your public key. You must store your private key in a safe place. The public / private key pair sets up trust between your application and Convergence.
You can learn more about JWTs at [http://jwt.io](http://jwt.io)
To create a JWT key for your domain log into the [Convergence Administration Console](https://convergence.io). If you have questions about generating a JWT Key Pair please consult the [Convergence Developer Guide](https://docs.convergence.io/guide/)
## Installation
`npm install --save @convergence/jwt-util`
## Example Usage
The below demonstrates how you can generate a JWT in node using a private key stored on the filesystem.
```js
var fs = require('fs');
var JwtGenerator = require('@convergence/jwt-util');
// replace with your private key
var privateKey = fs.readFileSync('test/private.key');
// Replace with your key id
var keyId = "my-convergence-key";
var gen = new JwtGenerator(keyId, privateKey);
// Provide optional information about the uers.
var claims = {
firstName: "John",
lastName: "Doe"
};
// Provide the username
var username = "jdoe";
// Generate the token
var token = gen.generate(username, claims);
```