Skip to content

Instantly share code, notes, and snippets.


nparsons08/virgil.js Secret

Created Nov 11, 2019
What would you like to do?
// backend/src/virgil.js
const virgilCrypto = new VirgilCrypto();
const generator = new JwtGenerator({
appId: process.env.VIRGIL_APP_ID,
apiKeyId: process.env.VIRGIL_KEY_ID,
apiKey: virgilCrypto.importPrivateKey(process.env.VIRGIL_PRIVATE_KEY),
accessTokenSigner: new VirgilAccessTokenSigner(virgilCrypto)
exports.virgilToken = (user) => generator.generateToken(user);
// backend/src/controllers/v1/virgil-credentials.js
import { virgilToken } from '../../virgil';
exports.virgilCredentials = (req, res) => {
const virgilJwtToken = virgilToken(req.user.sender);
res.json({ token: virgilJwtToken.toString() });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.