MCPcopy Create free account
hub / github.com/ACM-VIT/conclave / signTranscriptSfuRelayStartToken

Function signTranscriptSfuRelayStartToken

apps/web/transcript-worker/src/auth.ts:47–80  ·  view source on GitHub ↗
(
  options: {
    userId: string;
    displayName: string;
    roomId: string;
    clientId?: string;
    channelId?: string;
    connectionId: string;
  },
  secret: string,
  ttlSeconds = 30,
)

Source from the content-addressed store, hash-verified

45};
46
47export const signTranscriptSfuRelayStartToken = async (
48 options: {
49 userId: string;
50 displayName: string;
51 roomId: string;
52 clientId?: string;
53 channelId?: string;
54 connectionId: string;
55 },
56 secret: string,
57 ttlSeconds = 30,
58): Promise<{ token: string; expiresAt: number }> => {
59 const nowSeconds = Math.floor(Date.now() / 1000);
60 const expiresAt = (nowSeconds + ttlSeconds) * 1000;
61 const token = await signHs256Jwt(
62 {
63 iss: "conclave-transcript-worker",
64 aud: "conclave-sfu",
65 sub: options.userId,
66 tokenUse: "transcript:sfuRelayStart",
67 userId: options.userId,
68 displayName: options.displayName,
69 roomId: options.roomId,
70 clientId: options.clientId,
71 channelId: options.channelId,
72 connectionId: options.connectionId,
73 sessionStatus: "live",
74 transportMode: "sfu",
75 exp: nowSeconds + ttlSeconds,
76 },
77 secret,
78 );
79 return { token, expiresAt };
80};
81
82export const verifyTranscriptToken = async (
83 token: string,

Callers 1

Calls 2

signHs256JwtFunction · 0.85
nowMethod · 0.80

Tested by

no test coverage detected