From 02301a799e5aadd9cd1b3568f8dc65f62008312c Mon Sep 17 00:00:00 2001 From: Niels van Velzen Date: Tue, 3 Oct 2023 16:34:18 +0200 Subject: [PATCH] Remove "RECEIVERVERSION" global --- src/components/__tests__/jellyfinApi.test.ts | 4 ++-- src/components/jellyfinApi.ts | 11 +++-------- src/types/global.d.ts | 1 - vite.config.ts | 4 ---- 4 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/components/__tests__/jellyfinApi.test.ts b/src/components/__tests__/jellyfinApi.test.ts index b7cd016c..fc905c65 100644 --- a/src/components/__tests__/jellyfinApi.test.ts +++ b/src/components/__tests__/jellyfinApi.test.ts @@ -215,7 +215,7 @@ describe('getting security headers', () => { // @ts-expect-error Since the method is private. const result = JellyfinApi.getSecurityHeaders(); - const correctAuth = `MediaBrowser Client="Chromecast", Token="thisIsAccessToken", Version="${version}", DeviceId="${btoa( + const correctAuth = `MediaBrowser Client="Chromecast", Version="${version}", Token="thisIsAccessToken", DeviceId="${btoa( 'thisIsReceiverName' )}", Device="thisIsReceiverName"`; @@ -233,7 +233,7 @@ describe('getting security headers', () => { // @ts-expect-error Since the method is private. const result = JellyfinApi.getSecurityHeaders(); const correct = { - Authorization: `MediaBrowser Client="Chromecast", Token="thisIsAccessToken", Version="${version}", DeviceId="thisIsSenderId", Device="Google%20Cast"` + Authorization: `MediaBrowser Client="Chromecast", Version="${version}", Token="thisIsAccessToken", DeviceId="thisIsSenderId", Device="Google%20Cast"` }; expect(result).toMatchObject(correct); diff --git a/src/components/jellyfinApi.ts b/src/components/jellyfinApi.ts index 9c016938..af31222a 100644 --- a/src/components/jellyfinApi.ts +++ b/src/components/jellyfinApi.ts @@ -1,3 +1,4 @@ +import { version as packageVersion } from '../../package.json'; import { ajax } from './fetchhelper'; export abstract class JellyfinApi { @@ -16,9 +17,6 @@ export abstract class JellyfinApi { // unique id public static deviceId = ''; - // version - public static versionNumber = RECEIVERVERSION; - public static setServerInfo( userId?: string, accessToken?: string, @@ -54,17 +52,14 @@ export abstract class JellyfinApi { // create the necessary headers for authentication private static getSecurityHeaders(): { Authorization?: string } { const parameters: Record = { - Client: 'Chromecast' + Client: 'Chromecast', + Version: packageVersion }; if (this.accessToken) { parameters['Token'] = this.accessToken; } - if (this.versionNumber) { - parameters['Version'] = this.versionNumber; - } - if (this.deviceId) { parameters['DeviceId'] = this.deviceId; } diff --git a/src/types/global.d.ts b/src/types/global.d.ts index 67a1af09..9268c09c 100644 --- a/src/types/global.d.ts +++ b/src/types/global.d.ts @@ -90,7 +90,6 @@ interface SupportedCommands { // /From commandHandler declare global { - export const RECEIVERVERSION: string; export interface Window { mediaElement: HTMLElement | null; playerManager: PlayerManager; diff --git a/vite.config.ts b/vite.config.ts index 55d8ba5a..62c080e3 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,7 +1,6 @@ /* eslint-disable sort-keys */ import { defineConfig } from 'vite'; -import { version } from './package.json'; export default defineConfig({ root: 'src', @@ -14,8 +13,5 @@ export default defineConfig({ }, server: { port: 9000 - }, - define: { - RECEIVERVERSION: JSON.stringify(version) } });