Skip to content

Commit

Permalink
Merge pull request #481 from jellyfin/nvv-drop-global
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsvanvelzen committed Oct 3, 2023
2 parents c2ac063 + 02301a7 commit 2391436
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/components/__tests__/jellyfinApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"`;

Expand All @@ -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);
Expand Down
11 changes: 3 additions & 8 deletions src/components/jellyfinApi.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { version as packageVersion } from '../../package.json';
import { ajax } from './fetchhelper';

export abstract class JellyfinApi {
Expand All @@ -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,
Expand Down Expand Up @@ -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;
}
Expand Down
1 change: 0 additions & 1 deletion src/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ interface SupportedCommands {
// /From commandHandler

declare global {
export const RECEIVERVERSION: string;
export interface Window {
mediaElement: HTMLElement | null;
playerManager: PlayerManager;
Expand Down
4 changes: 0 additions & 4 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable sort-keys */

import { defineConfig } from 'vite';
import { version } from './package.json';

export default defineConfig({
root: 'src',
Expand All @@ -14,8 +13,5 @@ export default defineConfig({
},
server: {
port: 9000
},
define: {
RECEIVERVERSION: JSON.stringify(version)
}
});

0 comments on commit 2391436

Please sign in to comment.