From 715277e9936c34c7e9d4bdc2c5f381d912a79dd9 Mon Sep 17 00:00:00 2001 From: voluntas Date: Fri, 10 Jan 2025 13:54:40 +0900 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- check_stereo/main.ts | 8 ++++++-- check_stereo_multi/main.ts | 10 ++++++---- messaging/main.ts | 8 ++++++-- recvonly/main.ts | 8 ++++++-- replace_track/main.ts | 10 ++++++---- sendonly/main.ts | 10 ++++++---- sendrecv/main.ts | 10 ++++++---- simulcast/main.ts | 10 ++++++---- spotlight_sendrecv/main.ts | 10 ++++++---- src/misc.ts | 3 --- 10 files changed, 54 insertions(+), 33 deletions(-) diff --git a/check_stereo/main.ts b/check_stereo/main.ts index 0a42b90..78786f4 100644 --- a/check_stereo/main.ts +++ b/check_stereo/main.ts @@ -123,8 +123,12 @@ class SendonlyClient { } async connect(stream: MediaStream): Promise { - const jwt = await generateJwt(this.channelId, this.secretKey); - this.connection.metadata = { access_token: jwt }; + if (this.secretKey !== "") { + const jwt = await generateJwt(this.channelId, this.secretKey); + this.connection.metadata = { + access_token: jwt, + }; + } const audioTrack = stream.getAudioTracks()[0]; if (!audioTrack) { diff --git a/check_stereo_multi/main.ts b/check_stereo_multi/main.ts index 4040e6a..adcddce 100644 --- a/check_stereo_multi/main.ts +++ b/check_stereo_multi/main.ts @@ -160,10 +160,12 @@ class SendonlyClient { } async connect(stream: MediaStream): Promise { - const jwt = await generateJwt(this.channelId, this.secretKey); - this.connection.metadata = { - access_token: jwt, - }; + if (this.secretKey !== "") { + const jwt = await generateJwt(this.channelId, this.secretKey); + this.connection.metadata = { + access_token: jwt, + }; + } const audioTrack = stream.getAudioTracks()[0]; if (!audioTrack) { diff --git a/messaging/main.ts b/messaging/main.ts index ae4305b..bc53dff 100644 --- a/messaging/main.ts +++ b/messaging/main.ts @@ -114,8 +114,12 @@ class SoraClient { } async connect(compress: boolean, header: boolean) { - const jwt = await generateJwt(this.channelId, this.secretKey); - this.connection.metadata = { access_token: jwt }; + if (this.secretKey !== "") { + const jwt = await generateJwt(this.channelId, this.secretKey); + this.connection.metadata = { + access_token: jwt, + }; + } // connect ボタンを無効にする const connectButton = document.querySelector("#connect"); diff --git a/recvonly/main.ts b/recvonly/main.ts index 7279bbe..5a39bf1 100644 --- a/recvonly/main.ts +++ b/recvonly/main.ts @@ -86,8 +86,12 @@ class SoraClient { } async connect(): Promise { - const jwt = await generateJwt(this.channelId, this.secretKey); - this.connection.metadata = { access_token: jwt }; + if (this.secretKey !== "") { + const jwt = await generateJwt(this.channelId, this.secretKey); + this.connection.metadata = { + access_token: jwt, + }; + } await this.connection.connect(); } diff --git a/replace_track/main.ts b/replace_track/main.ts index 6b15442..2b77a31 100644 --- a/replace_track/main.ts +++ b/replace_track/main.ts @@ -121,10 +121,12 @@ class SoraClient { } async connect() { - const jwt = await generateJwt(this.channelId, this.secretKey); - this.connection.metadata = { - access_token: jwt, - }; + if (this.secretKey !== "") { + const jwt = await generateJwt(this.channelId, this.secretKey); + this.connection.metadata = { + access_token: jwt, + }; + } await this.connection.connect(this.stream); const localVideo = document.querySelector("#local-video"); diff --git a/sendonly/main.ts b/sendonly/main.ts index 8ccd7ab..a8abd5b 100644 --- a/sendonly/main.ts +++ b/sendonly/main.ts @@ -92,10 +92,12 @@ class SoraClient { } async connect(stream: MediaStream): Promise { - const jwt = await generateJwt(this.channelId, this.secretKey); - this.connection.metadata = { - access_token: jwt, - }; + if (this.secretKey !== "") { + const jwt = await generateJwt(this.channelId, this.secretKey); + this.connection.metadata = { + access_token: jwt, + }; + } await this.connection.connect(stream); diff --git a/sendrecv/main.ts b/sendrecv/main.ts index 8a2208f..b208cb8 100644 --- a/sendrecv/main.ts +++ b/sendrecv/main.ts @@ -109,10 +109,12 @@ class SoraClient { } async connect(stream: MediaStream) { - const jwt = await generateJwt(this.channelId, this.secretKey); - this.connection.metadata = { - access_token: jwt, - }; + if (this.secretKey !== "") { + const jwt = await generateJwt(this.channelId, this.secretKey); + this.connection.metadata = { + access_token: jwt, + }; + } await this.connection.connect(stream); const localVideo = document.querySelector("#local-video"); diff --git a/simulcast/main.ts b/simulcast/main.ts index 4ad71b8..1dc5e1f 100644 --- a/simulcast/main.ts +++ b/simulcast/main.ts @@ -146,10 +146,12 @@ class SimulcastSendonlySoraClient { } async connect(stream: MediaStream) { - const jwt = await generateJwt(this.channelId, this.secretKey); - this.connection.metadata = { - access_token: jwt, - }; + if (this.secretKey !== "") { + const jwt = await generateJwt(this.channelId, this.secretKey); + this.connection.metadata = { + access_token: jwt, + }; + } await this.connection.connect(stream); diff --git a/spotlight_sendrecv/main.ts b/spotlight_sendrecv/main.ts index 7f828e9..b95e911 100644 --- a/spotlight_sendrecv/main.ts +++ b/spotlight_sendrecv/main.ts @@ -72,10 +72,12 @@ class SoraClient { } async connect(stream: MediaStream) { - const jwt = await generateJwt(this.channelId, this.secretKey); - this.connection.metadata = { - access_token: jwt, - }; + if (this.secretKey !== "") { + const jwt = await generateJwt(this.channelId, this.secretKey); + this.connection.metadata = { + access_token: jwt, + }; + } await this.connection.connect(stream); diff --git a/src/misc.ts b/src/misc.ts index c507291..07b9d49 100644 --- a/src/misc.ts +++ b/src/misc.ts @@ -4,9 +4,6 @@ export const generateJwt = async ( channelId: string, secretKey: string, ): Promise => { - if (secretKey === "") { - return ""; - } const header = { alg: "HS256", typ: "JWT" }; return ( new jose.SignJWT({