Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove "RECEIVERVERSION" global #481

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
});