diff --git a/.env.template b/.env.template index 772ed632..649cdfc0 100644 --- a/.env.template +++ b/.env.template @@ -1,14 +1,16 @@ -# サンプルやテストに利用する Sora の Signaling URL を指定してください +# サンプルに利用する Sora の Signaling URL を指定してください VITE_SORA_SIGNALING_URL=wss://sora.example.com/signaling -# サンプルやテストに利用する Sora の ChannelID を指定してください +# サンプルに利用する Sora の ChannelID を指定してください VITE_SORA_CHANNEL_ID=sora-js-sdk -# サンプルやテストに利用するアクセストークンを指定してください、不要であれば空欄で大丈夫です +# サンプルに利用するアクセストークンを指定してください、不要であれば空欄で大丈夫です VITE_ACCESS_TOKEN=access_token -# サンプルやテストに利用する Sora の API URL を指定ください、不要であれば空欄で大丈夫です -VITE_SORA_API_URL=https://sora.example.com/api -# サンプルやテストに利用する Sora の WHIP のエンドポイント URL を指定してください、不要であれば空欄で大丈夫です -VITE_SORA_WHIP_ENDPOINT_URL=https://sora.example.com/whip -# サンプルやテストに利用する Sora の WHEP のエンドポイント URL を指定してください、不要であれば空欄で大丈夫です -VITE_SORA_WHEP_ENDPOINT_URL=https://sora.example.com/whep \ No newline at end of file +# テストに利用する Sora の設定 +VITE_TEST_SIGNALING_URL= +VITE_TEST_CHANNEL_ID_PREFIX= +VITE_TEST_CHANNEL_ID_SUFFIX= +VITE_TEST_API_URL= +VITE_TEST_WHIP_ENDPOINT_URL= +VITE_TEST_WHEP_ENDPOINT_URL= +VITE_TEST_SECRET_KEY= \ No newline at end of file diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index 6770a991..a35876ee 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -23,12 +23,12 @@ jobs: # browser: ["chromium", "firefox", "webkit"] browser: ["chromium"] env: - VITE_SORA_SIGNALING_URL: ${{ secrets.TEST_SIGNALING_URL }} - VITE_SORA_WHIP_ENDPOINT_URL: ${{ secrets.TEST_WHIP_ENDPOINT_URL }} - VITE_SORA_WHEP_ENDPOINT_URL: ${{ secrets.TEST_WHEP_ENDPOINT_URL }} - VITE_SORA_CHANNEL_ID_PREFIX: ${{ secrets.TEST_CHANNEL_ID_PREFIX }} - VITE_SORA_API_URL: ${{ secrets.TEST_API_URL }} - VITE_ACCESS_TOKEN: ${{ secrets.TEST_SECRET_KEY }} + TEST_SIGNALING_URL: ${{ secrets.TEST_SIGNALING_URL }} + TEST_WHIP_ENDPOINT_URL: ${{ secrets.TEST_WHIP_ENDPOINT_URL }} + TEST_WHEP_ENDPOINT_URL: ${{ secrets.TEST_WHEP_ENDPOINT_URL }} + TEST_CHANNEL_ID_PREFIX: ${{ secrets.TEST_CHANNEL_ID_PREFIX }} + TEST_API_URL: ${{ secrets.TEST_API_URL }} + TEST_SECRET_KEY: ${{ secrets.TEST_SECRET_KEY }} steps: - uses: actions/checkout@v4 - uses: tailscale/github-action@v2 @@ -46,7 +46,7 @@ jobs: - run: pnpm exec playwright install ${{ matrix.browser }} --with-deps - run: pnpm exec playwright test --project=${{ matrix.browser }} env: - VITE_SORA_CHANNEL_ID_SUFFIX: _${{ matrix.node }} + VITE_TEST_CHANNEL_ID_SUFFIX: _${{ matrix.node }} # - uses: actions/upload-artifact@v4 # if: always() # with: diff --git a/.github/workflows/npm-pkg-e2e-test.yml b/.github/workflows/npm-pkg-e2e-test.yml index 37564990..473202c6 100644 --- a/.github/workflows/npm-pkg-e2e-test.yml +++ b/.github/workflows/npm-pkg-e2e-test.yml @@ -35,12 +35,12 @@ jobs: # browser: ["chromium", "firefox", "webkit"] browser: ["chromium"] env: - VITE_SORA_SIGNALING_URL: ${{ secrets.TEST_SIGNALING_URL }} - VITE_SORA_WHIP_ENDPOINT_URL: ${{ secrets.TEST_WHIP_ENDPOINT_URL }} - VITE_SORA_WHEP_ENDPOINT_URL: ${{ secrets.TEST_WHEP_ENDPOINT_URL }} - VITE_SORA_CHANNEL_ID_PREFIX: ${{ secrets.TEST_CHANNEL_ID_PREFIX }} - VITE_SORA_API_URL: ${{ secrets.TEST_API_URL }} - VITE_ACCESS_TOKEN: ${{ secrets.TEST_SECRET_KEY }} + VITE_TEST_SIGNALING_URL: ${{ secrets.TEST_SIGNALING_URL }} + VITE_TEST_WHIP_ENDPOINT_URL: ${{ secrets.TEST_WHIP_ENDPOINT_URL }} + VITE_TEST_WHEP_ENDPOINT_URL: ${{ secrets.TEST_WHEP_ENDPOINT_URL }} + VITE_TEST_CHANNEL_ID_PREFIX: ${{ secrets.TEST_CHANNEL_ID_PREFIX }} + VITE_TEST_API_URL: ${{ secrets.TEST_API_URL }} + VITE_TEST_SECRET_KEY: ${{ secrets.TEST_SECRET_KEY }} NPM_PKG_E2E_TEST: true steps: - uses: actions/checkout@v4 @@ -62,7 +62,7 @@ jobs: - run: pnpm exec playwright install ${{ matrix.browser }} --with-deps - run: pnpm exec playwright test --project=${{ matrix.browser }} env: - VITE_SORA_CHANNEL_ID_SUFFIX: _${{ matrix.node }}_${{ matrix.sdk_version }} + VITE_TEST_CHANNEL_ID_SUFFIX: _${{ matrix.node }}_${{ matrix.sdk_version }} # - uses: actions/upload-artifact@v4 # if: always() # with: diff --git a/e2e-tests/data_channel_signaling_only/main.mts b/e2e-tests/data_channel_signaling_only/main.mts index 95c0da32..4abb3977 100644 --- a/e2e-tests/data_channel_signaling_only/main.mts +++ b/e2e-tests/data_channel_signaling_only/main.mts @@ -7,16 +7,16 @@ import Sora, { } from 'sora-js-sdk' document.addEventListener('DOMContentLoaded', async () => { - const SORA_SIGNALING_URL = import.meta.env.VITE_SORA_SIGNALING_URL - const SORA_CHANNEL_ID_PREFIX = import.meta.env.VITE_SORA_CHANNEL_ID_PREFIX || '' - const SORA_CHANNEL_ID_SUFFIX = import.meta.env.VITE_SORA_CHANNEL_ID_SUFFIX || '' - const ACCESS_TOKEN = import.meta.env.VITE_ACCESS_TOKEN || '' + const signalingUrl = import.meta.env.VITE_TEST_SIGNALING_URL + const channelIdPrefix = import.meta.env.VITE_TEST_CHANNEL_ID_PREFIX || '' + const channelIdSuffix = import.meta.env.VITE_TEST_CHANNEL_ID_SUFFIX || '' + const secretKey = import.meta.env.VITE_TEST_SECRET_KEY const client = new SoraClient( - SORA_SIGNALING_URL, - SORA_CHANNEL_ID_PREFIX, - SORA_CHANNEL_ID_SUFFIX, - ACCESS_TOKEN, + signalingUrl, + channelIdPrefix, + channelIdSuffix, + secretKey, ) // SDK バージョンの表示 @@ -77,17 +77,17 @@ class SoraClient { private connection: ConnectionPublisher constructor( - signaling_url: string, - channel_id_prefix: string, - channel_id_suffix: string, - access_token: string, + signalingUrl: string, + channelIdPrefix: string, + channelIdSuffix: string, + secretKey: string, ) { - this.sora = Sora.connection(signaling_url, this.debug) + this.sora = Sora.connection(signalingUrl, this.debug) // channel_id の生成 - this.channelId = `${channel_id_prefix}sendonly_recvonly${channel_id_suffix}` + this.channelId = `${channelIdPrefix}sendonly_recvonly${channelIdSuffix}` // access_token を指定する metadata の生成 - this.metadata = { access_token: access_token } + this.metadata = { access_token: secretKey } this.connection = this.sora.sendonly(this.channelId, this.metadata, this.options) this.connection.on('notify', this.onNotify.bind(this)) diff --git a/e2e-tests/messaging/main.mts b/e2e-tests/messaging/main.mts index 411418ca..dfdd868f 100644 --- a/e2e-tests/messaging/main.mts +++ b/e2e-tests/messaging/main.mts @@ -16,10 +16,10 @@ const getChannelName = (): string => { } document.addEventListener('DOMContentLoaded', async () => { - const SORA_SIGNALING_URL = import.meta.env.VITE_SORA_SIGNALING_URL - const SORA_CHANNEL_ID_PREFIX = import.meta.env.VITE_SORA_CHANNEL_ID_PREFIX || '' - const SORA_CHANNEL_ID_SUFFIX = import.meta.env.VITE_SORA_CHANNEL_ID_SUFFIX || '' - const ACCESS_TOKEN = import.meta.env.VITE_ACCESS_TOKEN || '' + const signalingUrl = import.meta.env.VITE_TEST_SIGNALING_URL + const channelIdPrefix = import.meta.env.VITE_TEST_CHANNEL_ID_PREFIX || '' + const channelIdSuffix = import.meta.env.VITE_TEST_CHANNEL_ID_SUFFIX || '' + const secretKey = import.meta.env.VITE_TEST_SECRET_KEY const soraJsSdkVersion = Sora.version() const soraJsSdkVersionElement = document.getElementById('sora-js-sdk-version') @@ -32,10 +32,10 @@ document.addEventListener('DOMContentLoaded', async () => { document.querySelector('#connect')?.addEventListener('click', async () => { const channelName = getChannelName() client = new SoraClient( - SORA_SIGNALING_URL, - SORA_CHANNEL_ID_PREFIX, - SORA_CHANNEL_ID_SUFFIX, - ACCESS_TOKEN, + signalingUrl, + channelIdPrefix, + channelIdSuffix, + secretKey, channelName, ) const checkCompress = document.getElementById('check-compress') as HTMLInputElement @@ -94,12 +94,12 @@ class SoraClient { signalingUrl: string, channelIdPrefix: string, channelIdSuffix: string, - accessToken: string, + secretKey: string, channelName: string, ) { this.sora = Sora.connection(signalingUrl, this.debug) this.channelId = `${channelIdPrefix}${channelName}${channelIdSuffix}` - this.metadata = { access_token: accessToken } + this.metadata = { access_token: secretKey } this.options = { dataChannelSignaling: true, diff --git a/e2e-tests/recvonly/main.mts b/e2e-tests/recvonly/main.mts index 5193a186..77410767 100644 --- a/e2e-tests/recvonly/main.mts +++ b/e2e-tests/recvonly/main.mts @@ -6,17 +6,17 @@ import Sora, { document.addEventListener('DOMContentLoaded', () => { // 環境変数の読み込み - const SORA_SIGNALING_URL = import.meta.env.VITE_SORA_SIGNALING_URL - const SORA_CHANNEL_ID_PREFIX = import.meta.env.VITE_SORA_CHANNEL_ID_PREFIX || '' - const SORA_CHANNEL_ID_SUFFIX = import.meta.env.VITE_SORA_CHANNEL_ID_SUFFIX || '' - const ACCESS_TOKEN = import.meta.env.VITE_ACCESS_TOKEN || '' + const signalingUrl = import.meta.env.VITE_TEST_SIGNALING_URL + const channelIdPrefix = import.meta.env.VITE_TEST_CHANNEL_ID_PREFIX || '' + const channelIdSuffix = import.meta.env.VITE_TEST_CHANNEL_ID_SUFFIX || '' + const secretKey = import.meta.env.VITE_TEST_SECRET_KEY // Sora クライアントの初期化 const client = new SoraClient( - SORA_SIGNALING_URL, - SORA_CHANNEL_ID_PREFIX, - SORA_CHANNEL_ID_SUFFIX, - ACCESS_TOKEN, + signalingUrl, + channelIdPrefix, + channelIdSuffix, + secretKey, ) // SDK バージョンの表示 diff --git a/e2e-tests/sendonly/main.mts b/e2e-tests/sendonly/main.mts index a4ca9a4e..0f883cf0 100644 --- a/e2e-tests/sendonly/main.mts +++ b/e2e-tests/sendonly/main.mts @@ -6,16 +6,16 @@ import Sora, { } from 'sora-js-sdk' document.addEventListener('DOMContentLoaded', async () => { - const SORA_SIGNALING_URL = import.meta.env.VITE_SORA_SIGNALING_URL - const SORA_CHANNEL_ID_PREFIX = import.meta.env.VITE_SORA_CHANNEL_ID_PREFIX || '' - const SORA_CHANNEL_ID_SUFFIX = import.meta.env.VITE_SORA_CHANNEL_ID_SUFFIX || '' - const ACCESS_TOKEN = import.meta.env.VITE_ACCESS_TOKEN || '' + const signalingUrl = import.meta.env.VITE_TEST_SIGNALING_URL + const channelIdPrefix = import.meta.env.VITE_TEST_CHANNEL_ID_PREFIX || '' + const channelIdSuffix = import.meta.env.VITE_TEST_CHANNEL_ID_SUFFIX || '' + const secretKey = import.meta.env.VITE_TEST_SECRET_KEY const client = new SoraClient( - SORA_SIGNALING_URL, - SORA_CHANNEL_ID_PREFIX, - SORA_CHANNEL_ID_SUFFIX, - ACCESS_TOKEN, + signalingUrl, + channelIdPrefix, + channelIdSuffix, + secretKey, ) // SDK バージョンの表示 @@ -69,17 +69,17 @@ class SoraClient { private connection: ConnectionPublisher constructor( - signaling_url: string, - channel_id_prefix: string, - channel_id_suffix: string, - access_token: string, + signalingUrl: string, + channelIdPrefix: string, + channelIdSuffix: string, + secretKey: string, ) { - this.sora = Sora.connection(signaling_url, this.debug) + this.sora = Sora.connection(signalingUrl, this.debug) // channel_id の生成 - this.channelId = `${channel_id_prefix}sendonly_recvonly${channel_id_suffix}` + this.channelId = `${channelIdPrefix}sendonly_recvonly${channelIdSuffix}` // access_token を指定する metadata の生成 - this.metadata = { access_token: access_token } + this.metadata = { access_token: secretKey } this.connection = this.sora.sendonly(this.channelId, this.metadata, this.options) this.connection.on('notify', this.onNotify.bind(this)) diff --git a/e2e-tests/sendonly_audio/main.mts b/e2e-tests/sendonly_audio/main.mts index 9305e06b..d7b772ed 100644 --- a/e2e-tests/sendonly_audio/main.mts +++ b/e2e-tests/sendonly_audio/main.mts @@ -5,16 +5,16 @@ import Sora, { } from 'sora-js-sdk' document.addEventListener('DOMContentLoaded', async () => { - const SORA_SIGNALING_URL = import.meta.env.VITE_SORA_SIGNALING_URL - const SORA_CHANNEL_ID_PREFIX = import.meta.env.VITE_SORA_CHANNEL_ID_PREFIX || '' - const SORA_CHANNEL_ID_SUFFIX = import.meta.env.VITE_SORA_CHANNEL_ID_SUFFIX || '' - const ACCESS_TOKEN = import.meta.env.VITE_ACCESS_TOKEN || '' + const signalingUrl = import.meta.env.VITE_TEST_SIGNALING_URL + const channelIdPrefix = import.meta.env.VITE_TEST_CHANNEL_ID_PREFIX || '' + const channelIdSuffix = import.meta.env.VITE_TEST_CHANNEL_ID_SUFFIX || '' + const secretKey = import.meta.env.VITE_TEST_SECRET_KEY const client = new SoraClient( - SORA_SIGNALING_URL, - SORA_CHANNEL_ID_PREFIX, - SORA_CHANNEL_ID_SUFFIX, - ACCESS_TOKEN, + signalingUrl, + channelIdPrefix, + channelIdSuffix, + secretKey, ) document.querySelector('#connect')?.addEventListener('click', async () => { @@ -73,17 +73,17 @@ class SoraClient { private connection: ConnectionPublisher constructor( - signaling_url: string, - channel_id_prefix: string, - channel_id_suffix: string, - access_token: string, + signalingUrl: string, + channelIdPrefix: string, + channelIdSuffix: string, + secretKey: string, ) { - this.sora = Sora.connection(signaling_url, this.debug) + this.sora = Sora.connection(signalingUrl, this.debug) // channel_id の生成 - this.channelId = `${channel_id_prefix}sendonly_audio_codec${channel_id_suffix}` + this.channelId = `${channelIdPrefix}sendonly_audio_codec${channelIdSuffix}` // access_token を指定する metadata の生成 - this.metadata = { access_token: access_token } + this.metadata = { access_token: secretKey } this.connection = this.sora.sendonly(this.channelId, this.metadata, this.options) this.connection.on('notify', this.onnotify.bind(this)) diff --git a/e2e-tests/sendrecv/main.mts b/e2e-tests/sendrecv/main.mts index ca7f2c6d..9cef7cb8 100644 --- a/e2e-tests/sendrecv/main.mts +++ b/e2e-tests/sendrecv/main.mts @@ -25,10 +25,10 @@ const getVideoCodecType = (): VideoCodecType | undefined => { } document.addEventListener('DOMContentLoaded', async () => { - const SORA_SIGNALING_URL = import.meta.env.VITE_SORA_SIGNALING_URL - const SORA_CHANNEL_ID_PREFIX = import.meta.env.VITE_SORA_CHANNEL_ID_PREFIX || '' - const SORA_CHANNEL_ID_SUFFIX = import.meta.env.VITE_SORA_CHANNEL_ID_SUFFIX || '' - const ACCESS_TOKEN = import.meta.env.VITE_ACCESS_TOKEN || '' + const signalingUrl = import.meta.env.VITE_TEST_SIGNALING_URL + const channelIdPrefix = import.meta.env.VITE_TEST_CHANNEL_ID_PREFIX || '' + const channelIdSuffix = import.meta.env.VITE_TEST_CHANNEL_ID_SUFFIX || '' + const secretKey = import.meta.env.VITE_TEST_SECRET_KEY let client: SoraClient @@ -37,10 +37,10 @@ document.addEventListener('DOMContentLoaded', async () => { const videoCodecType = getVideoCodecType() client = new SoraClient( - SORA_SIGNALING_URL, - SORA_CHANNEL_ID_PREFIX, - SORA_CHANNEL_ID_SUFFIX, - ACCESS_TOKEN, + signalingUrl, + channelIdPrefix, + channelIdSuffix, + secretKey, channelName, videoCodecType, ) @@ -92,7 +92,7 @@ class SoraClient { signalingUrl: string, channelIdPrefix: string, channelIdSuffix: string, - accessToken: string, + secretKey: string, channelName: string, videoCodecType: VideoCodecType | undefined, ) { @@ -100,7 +100,7 @@ class SoraClient { this.channelId = `${channelIdPrefix}${channelName}${channelIdSuffix}` - this.metadata = { access_token: accessToken } + this.metadata = { access_token: secretKey } this.options = {} if (videoCodecType !== undefined) { diff --git a/e2e-tests/simulcast/main.mts b/e2e-tests/simulcast/main.mts index b34ed3ea..d195cfb3 100644 --- a/e2e-tests/simulcast/main.mts +++ b/e2e-tests/simulcast/main.mts @@ -7,39 +7,39 @@ import Sora, { } from 'sora-js-sdk' document.addEventListener('DOMContentLoaded', () => { - const SORA_SIGNALING_URL = import.meta.env.VITE_SORA_SIGNALING_URL - const SORA_CHANNEL_ID_PREFIX = import.meta.env.VITE_SORA_CHANNEL_ID_PREFIX || '' - const SORA_CHANNEL_ID_SUFFIX = import.meta.env.VITE_SORA_CHANNEL_ID_SUFFIX || '' - const ACCESS_TOKEN = import.meta.env.VITE_ACCESS_TOKEN || '' + const signalingUrl = import.meta.env.VITE_TEST_SIGNALING_URL + const channelIdPrefix = import.meta.env.VITE_TEST_CHANNEL_ID_PREFIX || '' + const channelIdSuffix = import.meta.env.VITE_TEST_CHANNEL_ID_SUFFIX || '' + const secretKey = import.meta.env.VITE_TEST_SECRET_KEY const sendonly = new SimulcastSendonlySoraClient( - SORA_SIGNALING_URL, - SORA_CHANNEL_ID_PREFIX, - SORA_CHANNEL_ID_SUFFIX, - ACCESS_TOKEN, + signalingUrl, + channelIdPrefix, + channelIdSuffix, + secretKey, ) const recvonlyR0 = new SimulcastRecvonlySoraClient( - SORA_SIGNALING_URL, - SORA_CHANNEL_ID_PREFIX, - SORA_CHANNEL_ID_SUFFIX, - ACCESS_TOKEN, + signalingUrl, + channelIdPrefix, + channelIdSuffix, + secretKey, 'r0', ) const recvonlyR1 = new SimulcastRecvonlySoraClient( - SORA_SIGNALING_URL, - SORA_CHANNEL_ID_PREFIX, - SORA_CHANNEL_ID_SUFFIX, - ACCESS_TOKEN, + signalingUrl, + channelIdPrefix, + channelIdSuffix, + secretKey, 'r1', ) const recvonlyR2 = new SimulcastRecvonlySoraClient( - SORA_SIGNALING_URL, - SORA_CHANNEL_ID_PREFIX, - SORA_CHANNEL_ID_SUFFIX, - ACCESS_TOKEN, + signalingUrl, + channelIdPrefix, + channelIdSuffix, + secretKey, 'r2', ) @@ -104,17 +104,17 @@ class SimulcastSendonlySoraClient { private connection: ConnectionPublisher constructor( - signaling_url: string, - channel_id_prefix: string, - channel_id_suffix: string, - access_token: string, + signalingUrl: string, + channelIdPrefix: string, + channelIdSuffix: string, + secretKey: string, ) { - this.channelId = `${channel_id_prefix}simulcast${channel_id_suffix}` + this.channelId = `${channelIdPrefix}simulcast${channelIdSuffix}` - this.sora = Sora.connection(signaling_url, this.debug) + this.sora = Sora.connection(signalingUrl, this.debug) this.connection = this.sora.sendonly( this.channelId, - { access_token }, + { access_token: secretKey }, { audio: false, video: true, videoCodecType: 'VP8', videoBitRate: 2500, simulcast: true }, ) @@ -167,19 +167,19 @@ class SimulcastRecvonlySoraClient { private connection: ConnectionSubscriber constructor( - signaling_url: string, - channel_id_prefix: string, - channel_id_suffix: string, - access_token: string, + signalingUrl: string, + channelIdPrefix: string, + channelIdSuffix: string, + secretKey: string, rid: SimulcastRid, ) { - this.channelId = `${channel_id_prefix}simulcast${channel_id_suffix}` + this.channelId = `${channelIdPrefix}simulcast${channelIdSuffix}` this.rid = rid - this.sora = Sora.connection(signaling_url, this.debug) + this.sora = Sora.connection(signalingUrl, this.debug) this.connection = this.sora.recvonly( this.channelId, - { access_token }, + { access_token: secretKey }, { simulcastRid: this.rid, simulcast: true }, ) diff --git a/e2e-tests/spotlight_recvonly/main.mts b/e2e-tests/spotlight_recvonly/main.mts index 7e00cf48..8f33c5a3 100644 --- a/e2e-tests/spotlight_recvonly/main.mts +++ b/e2e-tests/spotlight_recvonly/main.mts @@ -6,17 +6,17 @@ import Sora, { document.addEventListener('DOMContentLoaded', () => { // 環境変数の読み込み - const SORA_SIGNALING_URL = import.meta.env.VITE_SORA_SIGNALING_URL - const SORA_CHANNEL_ID_PREFIX = import.meta.env.VITE_SORA_CHANNEL_ID_PREFIX || '' - const SORA_CHANNEL_ID_SUFFIX = import.meta.env.VITE_SORA_CHANNEL_ID_SUFFIX || '' - const ACCESS_TOKEN = import.meta.env.VITE_ACCESS_TOKEN || '' + const signalingUrl = import.meta.env.VITE_TEST_SIGNALING_URL + const channelIdPrefix = import.meta.env.VITE_TEST_CHANNEL_ID_PREFIX || '' + const channelIdSuffix = import.meta.env.VITE_TEST_CHANNEL_ID_SUFFIX || '' + const secretKey = import.meta.env.VITE_TEST_SECRET_KEY // Sora クライアントの初期化 const client = new SoraClient( - SORA_SIGNALING_URL, - SORA_CHANNEL_ID_PREFIX, - SORA_CHANNEL_ID_SUFFIX, - ACCESS_TOKEN, + signalingUrl, + channelIdPrefix, + channelIdSuffix, + secretKey, ) document.querySelector('#connect')?.addEventListener('click', async () => { @@ -38,12 +38,12 @@ class SoraClient { private connection: ConnectionSubscriber constructor( - signaling_url: string, - channel_id_prefix: string, - channel_id_suffix: string, - access_token: string, + signalingUrl: string, + channelIdPrefix: string, + channelIdSuffix: string, + secretKey: string, ) { - this.sora = Sora.connection(signaling_url, this.debug) + this.sora = Sora.connection(signalingUrl, this.debug) this.options = { multistream: true, @@ -52,9 +52,9 @@ class SoraClient { } // channel_id の生成 - this.channelId = `${channel_id_prefix}spotlight_sendonly_recvonly${channel_id_suffix}` + this.channelId = `${channelIdPrefix}spotlight_recvonly${channelIdSuffix}` // access_token を指定する metadata の生成 - this.metadata = { access_token: access_token } + this.metadata = { access_token: secretKey } this.connection = this.sora.recvonly(this.channelId, this.metadata, this.options) this.connection.on('notify', this.onnotify.bind(this)) diff --git a/e2e-tests/spotlight_sendonly/main.mts b/e2e-tests/spotlight_sendonly/main.mts index bc80563c..c92c6593 100644 --- a/e2e-tests/spotlight_sendonly/main.mts +++ b/e2e-tests/spotlight_sendonly/main.mts @@ -5,16 +5,16 @@ import Sora, { } from 'sora-js-sdk' document.addEventListener('DOMContentLoaded', async () => { - const SORA_SIGNALING_URL = import.meta.env.VITE_SORA_SIGNALING_URL - const SORA_CHANNEL_ID_PREFIX = import.meta.env.VITE_SORA_CHANNEL_ID_PREFIX || '' - const SORA_CHANNEL_ID_SUFFIX = import.meta.env.VITE_SORA_CHANNEL_ID_SUFFIX || '' - const ACCESS_TOKEN = import.meta.env.VITE_ACCESS_TOKEN || '' + const signalingUrl = import.meta.env.VITE_TEST_SIGNALING_URL + const channelIdPrefix = import.meta.env.VITE_TEST_CHANNEL_ID_PREFIX || '' + const channelIdSuffix = import.meta.env.VITE_TEST_CHANNEL_ID_SUFFIX || '' + const secretKey = import.meta.env.VITE_TEST_SECRET_KEY const client = new SoraClient( - SORA_SIGNALING_URL, - SORA_CHANNEL_ID_PREFIX, - SORA_CHANNEL_ID_SUFFIX, - ACCESS_TOKEN, + signalingUrl, + channelIdPrefix, + channelIdSuffix, + secretKey, ) document.querySelector('#connect')?.addEventListener('click', async () => { @@ -37,12 +37,12 @@ class SoraClient { private connection: ConnectionPublisher constructor( - signaling_url: string, - channel_id_prefix: string, - channel_id_suffix: string, - access_token: string, + signalingUrl: string, + channelIdPrefix: string, + channelIdSuffix: string, + secretKey: string, ) { - this.sora = Sora.connection(signaling_url, this.debug) + this.sora = Sora.connection(signalingUrl, this.debug) this.options = { multistream: true, @@ -51,9 +51,9 @@ class SoraClient { } // channel_id の生成 - this.channelId = `${channel_id_prefix}spotlight_sendonly_recvonly${channel_id_suffix}` + this.channelId = `${channelIdPrefix}spotlight_sendonly_recvonly${channelIdSuffix}` // access_token を指定する metadata の生成 - this.metadata = { access_token: access_token } + this.metadata = { access_token: secretKey } this.connection = this.sora.sendonly(this.channelId, this.metadata, this.options) this.connection.on('notify', this.onnotify.bind(this)) diff --git a/e2e-tests/spotlight_sendrecv/main.mts b/e2e-tests/spotlight_sendrecv/main.mts index e9ee49ca..10d6fef0 100644 --- a/e2e-tests/spotlight_sendrecv/main.mts +++ b/e2e-tests/spotlight_sendrecv/main.mts @@ -5,25 +5,25 @@ import Sora, { } from 'sora-js-sdk' document.addEventListener('DOMContentLoaded', async () => { - const SORA_SIGNALING_URL = import.meta.env.VITE_SORA_SIGNALING_URL - const SORA_CHANNEL_ID_PREFIX = import.meta.env.VITE_SORA_CHANNEL_ID_PREFIX || '' - const SORA_CHANNEL_ID_SUFFIX = import.meta.env.VITE_SORA_CHANNEL_ID_SUFFIX || '' - const ACCESS_TOKEN = import.meta.env.VITE_ACCESS_TOKEN || '' + const signalingUrl = import.meta.env.VITE_TEST_SIGNALING_URL + const channelIdPrefix = import.meta.env.VITE_TEST_CHANNEL_ID_PREFIX || '' + const channelIdSuffix = import.meta.env.VITE_TEST_CHANNEL_ID_SUFFIX || '' + const secretKey = import.meta.env.VITE_TEST_SECRET_KEY const sendrecv1 = new SoraClient( 'sendrecv1', - SORA_SIGNALING_URL, - SORA_CHANNEL_ID_PREFIX, - SORA_CHANNEL_ID_SUFFIX, - ACCESS_TOKEN, + signalingUrl, + channelIdPrefix, + channelIdSuffix, + secretKey, ) const sendrecv2 = new SoraClient( 'sendrecv2', - SORA_SIGNALING_URL, - SORA_CHANNEL_ID_PREFIX, - SORA_CHANNEL_ID_SUFFIX, - ACCESS_TOKEN, + signalingUrl, + channelIdPrefix, + channelIdSuffix, + secretKey, ) document.querySelector('#sendrecv1-connect')?.addEventListener('click', async () => { @@ -63,13 +63,13 @@ class SoraClient { signalingUrl: string, channelIdPrefix: string, channelIdSuffix: string, - accessToken: string, + secretKey: string, ) { this.label = label this.sora = Sora.connection(signalingUrl, this.debug) this.channelId = `${channelIdPrefix}spotlight_sendrecv${channelIdSuffix}` - this.metadata = { access_token: accessToken } + this.metadata = { access_token: secretKey } this.options = { audio: true, video: true, diff --git a/e2e-tests/vite-env.d.ts b/e2e-tests/vite-env.d.ts index e71a892a..c6e893f9 100644 --- a/e2e-tests/vite-env.d.ts +++ b/e2e-tests/vite-env.d.ts @@ -1,14 +1,14 @@ /// interface ImportMetaEnv { - VITE_SORA_SIGNALING_URL: string - VITE_SORA_API_URL: string - VITE_SORA_CHANNEL_ID_PREFIX: string - VITE_SORA_CHANNEL_ID_SUFFIX: string - VITE_ACCESS_TOKEN: string + VITE_TEST_SIGNALING_URL: string + VITE_TEST_API_URL: string + VITE_TEST_CHANNEL_ID_PREFIX: string + VITE_TEST_CHANNEL_ID_SUFFIX: string + VITE_TEST_SECRET_KEY: string - VITE_SORA_WHIP_ENDPOINT_URL: string - VITE_SORA_WHEP_ENDPOINT_URL: string + VITE_TEST_WHIP_ENDPOINT_URL: string + VITE_TEST_WHEP_ENDPOINT_URL: string } interface ImportMeta { diff --git a/e2e-tests/whep/main.mts b/e2e-tests/whep/main.mts index 4f08e240..2b59fa69 100644 --- a/e2e-tests/whep/main.mts +++ b/e2e-tests/whep/main.mts @@ -1,8 +1,8 @@ document.addEventListener('DOMContentLoaded', async () => { - const endpointUrl = import.meta.env.VITE_SORA_WHEP_ENDPOINT_URL - const channelIdPrefix = import.meta.env.VITE_SORA_CHANNEL_ID_PREFIX || '' - const channelIdSuffix = import.meta.env.VITE_SORA_CHANNEL_ID_SUFFIX || '' - const accessToken = import.meta.env.VITE_ACCESS_TOKEN + const endpointUrl = import.meta.env.VITE_TEST_WHEP_ENDPOINT_URL + const channelIdPrefix = import.meta.env.VITE_TEST_CHANNEL_ID_PREFIX || '' + const channelIdSuffix = import.meta.env.VITE_TEST_CHANNEL_ID_SUFFIX || '' + const secretKey = import.meta.env.VITE_TEST_SECRET_KEY let whepClient: WhepClient | undefined @@ -18,7 +18,7 @@ document.addEventListener('DOMContentLoaded', async () => { throw new Error('Video codec type select element not found') } - whepClient = new WhepClient(endpointUrl, channelId, videoCodecTypeElement.value, accessToken) + whepClient = new WhepClient(endpointUrl, channelId, videoCodecTypeElement.value, secretKey) await whepClient.connect() }) @@ -38,14 +38,14 @@ class WhepClient { private channelId: string private videoCodecType: string - private accessToken: string + private secretKey: string private pc: RTCPeerConnection | undefined - constructor(endpointUrl: string, channelId: string, videoCodecType: string, accessToken: string) { + constructor(endpointUrl: string, channelId: string, videoCodecType: string, secretKey: string) { this.endpointUrl = endpointUrl this.channelId = channelId this.videoCodecType = videoCodecType - this.accessToken = accessToken + this.secretKey = secretKey } async connect(): Promise { @@ -112,7 +112,7 @@ class WhepClient { const response = await fetch(whepEndpointUrl, { method: 'POST', headers: { - Authorization: `Bearer ${this.accessToken}`, + Authorization: `Bearer ${this.secretKey}`, 'Content-Type': 'application/sdp', }, body: offer.sdp, @@ -165,7 +165,7 @@ class WhepClient { const response = await fetch(this.resourceUrl, { method: 'DELETE', headers: { - Authorization: `Bearer ${this.accessToken}`, + Authorization: `Bearer ${this.secretKey}`, }, }) diff --git a/e2e-tests/whip/main.mts b/e2e-tests/whip/main.mts index bc174d2c..06bec2a5 100644 --- a/e2e-tests/whip/main.mts +++ b/e2e-tests/whip/main.mts @@ -1,8 +1,8 @@ document.addEventListener('DOMContentLoaded', async () => { - const endpointUrl = import.meta.env.VITE_SORA_WHIP_ENDPOINT_URL - const channelIdPrefix = import.meta.env.VITE_SORA_CHANNEL_ID_PREFIX || '' - const channelIdSuffix = import.meta.env.VITE_SORA_CHANNEL_ID_SUFFIX || '' - const accessToken = import.meta.env.VITE_ACCESS_TOKEN + const endpointUrl = import.meta.env.VITE_TEST_WHIP_ENDPOINT_URL + const channelIdPrefix = import.meta.env.VITE_TEST_CHANNEL_ID_PREFIX || '' + const channelIdSuffix = import.meta.env.VITE_TEST_CHANNEL_ID_SUFFIX || '' + const secretKey = import.meta.env.VITE_TEST_SECRET_KEY let whipClient: WhipClient | undefined @@ -18,7 +18,7 @@ document.addEventListener('DOMContentLoaded', async () => { throw new Error('Video codec type select element not found') } - whipClient = new WhipClient(endpointUrl, channelId, videoCodecTypeElement.value, accessToken) + whipClient = new WhipClient(endpointUrl, channelId, videoCodecTypeElement.value, secretKey) const stream = await navigator.mediaDevices.getUserMedia({ video: true, @@ -58,16 +58,16 @@ class WhipClient { private videoCodecType: string - private accessToken: string + private secretKey: string private pc: RTCPeerConnection | undefined private stream: MediaStream | undefined - constructor(endpointUrl: string, channelId: string, videoCodecType: string, accessToken: string) { + constructor(endpointUrl: string, channelId: string, videoCodecType: string, secretKey: string) { this.endpointUrl = endpointUrl this.channelId = channelId this.videoCodecType = videoCodecType - this.accessToken = accessToken + this.secretKey = secretKey } async connect(stream: MediaStream, channelId: string): Promise { @@ -137,7 +137,7 @@ class WhipClient { method: 'POST', headers: { // 認証は Bearer Token を利用する - Authorization: `Bearer ${this.accessToken}`, + Authorization: `Bearer ${this.secretKey}`, // application/sdp を指定する 'Content-Type': 'application/sdp', }, @@ -196,7 +196,7 @@ class WhipClient { const response = await fetch(this.resourceUrl, { method: 'DELETE', headers: { - Authorization: `Bearer ${this.accessToken}`, + Authorization: `Bearer ${this.secretKey}`, }, })