Skip to content

Commit

Permalink
fix: correctly map platform names in auth header
Browse files Browse the repository at this point in the history
  • Loading branch information
leinelissen committed Jul 25, 2024
1 parent 113eaea commit 9ec5811
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/utility/JellyfinApi/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ import { version } from '../../../package.json';

type Credentials = AppState['settings']['credentials'];

/** Map the output of `Platform.OS`, so that Jellyfin can understand it. */
const deviceMap: Record<typeof Platform['OS'], string> = {
ios: 'iOS',
android: 'Android',
macos: 'macOS',
web: 'Web',
windows: 'Windows',
};

/**
* This is a convenience function that converts a set of Jellyfin credentials
* from the Redux store to a HTTP Header that authenticates the user against the
Expand All @@ -12,7 +21,7 @@ type Credentials = AppState['settings']['credentials'];
function generateConfig(credentials: Credentials): RequestInit {
return {
headers: {
'X-Emby-Authorization': `MediaBrowser Client="Fintunes", Device="${Platform.OS}", DeviceId="${credentials?.device_id}", Version="${version}", Token="${credentials?.access_token}"`
'X-Emby-Authorization': `MediaBrowser Client="Fintunes", Device="${deviceMap[Platform.OS]}", DeviceId="${credentials?.device_id}", Version="${version}", Token="${credentials?.access_token}"`
}
};
}
Expand Down

0 comments on commit 9ec5811

Please sign in to comment.