Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/lib/jitsi.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { JwtHeader } from 'jsonwebtoken';
import { v4 } from 'uuid';
import configuration from '../config/configuration';

const JITSI_JWT_EXPIRATION_TIME = 300; // 5 minutes
const JITSI_ADMIN_JWT_EXPIRATION_TIME = 60; // 1 minute

export const getJitsiJWTSecret = () => {
const jitsiSecret = configuration().secrets.jitsiSecret;

Expand All @@ -18,7 +20,7 @@ export const getJitsiJWTPayload = (
room: string,
moderator: boolean,
) => {
const now = Math.round(new Date().getTime() / 1000);
const now = Math.round(Date.now() / 1000);
const appId = configuration().jitsi.appId;
const userContextId = user.id + '/' + user.userRoomId;

Expand All @@ -42,7 +44,7 @@ export const getJitsiJWTPayload = (
iss: 'chat',
sub: appId,
room: room,
exp: now + 60,
exp: now + JITSI_JWT_EXPIRATION_TIME,
nbf: now - 10,
iat: now,
};
Expand All @@ -58,12 +60,12 @@ export const getJitsiJWTHeader = () => {
};

export const getJitsiAdminJWTPayload = () => {
const now = Math.round(new Date().getTime() / 1000);
const now = Math.round(Date.now() / 1000);
const appId = configuration().jitsi.appId;

return {
aud: 'jitsi',
exp: now + 600, // 1 minute expiration
exp: now + JITSI_ADMIN_JWT_EXPIRATION_TIME,
iss: 'chat',
admin: true, // Required for conference management endpoints
sub: appId,
Expand Down
Loading