Remove "RECEIVERVERSION" global

This commit is contained in:
Niels van Velzen 2023-10-03 16:34:18 +02:00
parent c2ac0632d9
commit 02301a799e
4 changed files with 5 additions and 15 deletions

View File

@ -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);

View File

@ -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<string, string> = {
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;
}

View File

@ -90,7 +90,6 @@ interface SupportedCommands {
// /From commandHandler
declare global {
export const RECEIVERVERSION: string;
export interface Window {
mediaElement: HTMLElement | null;
playerManager: PlayerManager;

View File

@ -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)
}
});