Skip to content

Virgil SDK 6.1.2 Type Error in Node v16.13.1 #91

Description

@supertopoz

[Context]
I'm building a small server to collect JWT tokens. The route handling looks below. When the server runs there is a TypeError from the Virgil-SDK

RuntimeError: abort(TypeError: Invalid format of 'Data'.). Build with -s ASSERTIONS=1 for more info.
at process.B (/Users/MY_USER_NAME/Documents/sendbird-virgil-uikit-sample/server/node_modules/@virgilsecurity/core-foundation/node.cjs.js:1:2501)

[Environment]
MAC Pro - Monterey - Intel not M1
Node v16.13.1
npm v8.1.2

[Impact]
I'm working to write a guide for Virgil security and Sendbird. However, I'm stuck at the moment as it seems that Node.js above v13 (two years old) is not supported

My jwt route example:

`
import express from 'express';
import { JwtGenerator } from 'virgil-sdk';

import {
initCrypto,
VirgilCrypto,
VirgilAccessTokenSigner,
} from 'virgil-crypto';

const getJwtGenerator = async () => {

await initCrypto();
const virgilCrypto = new VirgilCrypto();
return new JwtGenerator({
appId: process.env.VIRGIL_APP_ID,
apiKeyId: process.env.VIRGIL_APP_KEY_ID,
apiKey: virgilCrypto.importPrivateKey(process.env.VIRGIL_APP_KEY),
accessTokenSigner: new VirgilAccessTokenSigner(virgilCrypto),
});

};

const generatorPromise = getJwtGenerator();

export const virgilRouter = express.Router();

virgilRouter.get('/jwt/:userId', async (req, res) => {

const generator = await generatorPromise;
const virgilJwtToken = generator.generateToken(req.user.identity);
console.log({ virgilToken: virgilJwtToken.toString() });
res.json({ virgilToken: virgilJwtToken.toString() })

`});``

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions