Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
apiKeySid,
apiKeySecret,
{ ttl });
accessToken.identity = identity;
let grant = options.grant;
switch (grant) {
case 'conversations':
grant = new AccessToken.ConversationsGrant({
identity,
configurationProfileSid
});
break;
case 'video':
grant = new AccessToken.VideoGrant({
identity
});
break;
default:
// Do nothing.
}
if (grant) {
accessToken.addGrant(grant);
}
return accessToken.toJwt('HS256');
}
function createToken(identity) {
const token = new AccessToken(
process.env.ACCOUNT_SID,
process.env.API_KEY_SID,
process.env.API_KEY_SECRET);
token.identity = identity;
token.addGrant(new AccessToken.VideoGrant());
return token.toJwt();
}
function createAccessToken(identity, options) {
options = options || {};
const accessTokenGenerator = new AccessToken(
process.env.ACCOUNT_SID,
process.env.API_KEY_SID,
process.env.API_KEY_SECRET,
options);
accessTokenGenerator.identity = identity;
accessTokenGenerator.addGrant(new AccessToken.VideoGrant());
return accessTokenGenerator.toJwt();
}