Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// backend/src/controllers/v1/virgil-credentials.js
async function getJwtGenerator() {
await initCrypto();
const virgilCrypto = new VirgilCrypto();
// initialize JWT generator with your App ID and App Key ID you got in
// Virgil Dashboard.
return 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)
const generatorPromise = getJwtGenerator();
exports.virgilCredentials = async (req, res) => {
const generator = await generatorPromise;
const virgilJwtToken = generator.generateToken(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.