diff --git a/check_stereo/main.ts b/check_stereo/main.ts index 0705c1b..0a42b90 100644 --- a/check_stereo/main.ts +++ b/check_stereo/main.ts @@ -21,6 +21,7 @@ document.addEventListener("DOMContentLoaded", async () => { channelIdSuffix, secretKey, ); + const recvonly = new RecvonlyClient( signalingUrl, channelIdPrefix, diff --git a/recvonly/main.ts b/recvonly/main.ts index 3c7ca76..7279bbe 100644 --- a/recvonly/main.ts +++ b/recvonly/main.ts @@ -10,7 +10,7 @@ document.addEventListener("DOMContentLoaded", () => { const signalingUrl = import.meta.env.VITE_SORA_SIGNALING_URL; const channelIdPrefix = import.meta.env.VITE_SORA_CHANNEL_ID_PREFIX; const channelIdSuffix = import.meta.env.VITE_SORA_CHANNEL_ID_SUFFIX; - const secretKey = import.meta.env.VITE_SORA_SECRET_KEY; + const secretKey = import.meta.env.VITE_SECRET_KEY; // Sora クライアントの初期化 const client = new SoraClient( diff --git a/replace_track/main.ts b/replace_track/main.ts index efc021e..6b15442 100644 --- a/replace_track/main.ts +++ b/replace_track/main.ts @@ -21,7 +21,7 @@ document.addEventListener("DOMContentLoaded", async () => { const signalingUrl = import.meta.env.VITE_SORA_SIGNALING_URL; const channelIdPrefix = import.meta.env.VITE_SORA_CHANNEL_ID_PREFIX || ""; const channelIdSuffix = import.meta.env.VITE_SORA_CHANNEL_ID_SUFFIX || ""; - const secretKey = import.meta.env.VITE_SORA_SECRET_KEY || ""; + const secretKey = import.meta.env.VITE_SECRET_KEY || ""; const client = new SoraClient( signalingUrl, diff --git a/sendonly/main.ts b/sendonly/main.ts index 0dced7e..8ccd7ab 100644 --- a/sendonly/main.ts +++ b/sendonly/main.ts @@ -11,7 +11,7 @@ document.addEventListener("DOMContentLoaded", async () => { const signalingUrl = import.meta.env.VITE_SORA_SIGNALING_URL; const channelIdPrefix = import.meta.env.VITE_SORA_CHANNEL_ID_PREFIX || ""; const channelIdSuffix = import.meta.env.VITE_SORA_CHANNEL_ID_SUFFIX || ""; - const secretKey = import.meta.env.VITE_SORA_SECRET_KEY || ""; + const secretKey = import.meta.env.VITE_SECRET_KEY || ""; const client = new SoraClient( signalingUrl, diff --git a/sendrecv/main.ts b/sendrecv/main.ts index 5a8dff3..8a2208f 100644 --- a/sendrecv/main.ts +++ b/sendrecv/main.ts @@ -21,7 +21,7 @@ document.addEventListener("DOMContentLoaded", async () => { const signalingUrl = import.meta.env.VITE_SORA_SIGNALING_URL; const channelIdPrefix = import.meta.env.VITE_SORA_CHANNEL_ID_PREFIX || ""; const channelIdSuffix = import.meta.env.VITE_SORA_CHANNEL_ID_SUFFIX || ""; - const secretKey = import.meta.env.VITE_SORA_SECRET_KEY || ""; + const secretKey = import.meta.env.VITE_SECRET_KEY || ""; const client = new SoraClient( signalingUrl, diff --git a/src/misc.ts b/src/misc.ts index 4ea13e6..c507291 100644 --- a/src/misc.ts +++ b/src/misc.ts @@ -1,17 +1,20 @@ -import jose from "jose"; +import * as jose from "jose"; export const generateJwt = async ( channelId: string, secretKey: string, ): Promise => { + if (secretKey === "") { + return ""; + } const header = { alg: "HS256", typ: "JWT" }; - const payload = { - // 30 秒後に有効期限切れ - exp: Math.floor(Date.now() / 1000) + 30, - channel_id: channelId, - }; - return await new jose.SignJWT(payload) - .setProtectedHeader(header) - .setIssuedAt() - .sign(new TextEncoder().encode(secretKey)); + return ( + new jose.SignJWT({ + channel_id: channelId, + }) + .setProtectedHeader(header) + // 30 秒後に有効期限切れ + .setExpirationTime("30s") + .sign(new TextEncoder().encode(secretKey)) + ); };