Skip to content

Commit

Permalink
remove dependency on crypto.subtle
Browse files Browse the repository at this point in the history
  • Loading branch information
John Corser committed Jan 2, 2025
1 parent e49b203 commit 9c25e8c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 19 deletions.
6 changes: 3 additions & 3 deletions src/lib/jellyfin-api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Api, Jellyfin } from "@jellyfin/sdk";
import { generateFingerprint } from "./utils";
import { generateGuid } from "./utils";
import {
getCacheValue,
JELLYFIN_AUTH_TOKEN_CACHE_KEY,
Expand Down Expand Up @@ -46,7 +46,7 @@ export const authenticateByAuthToken = async (
},
deviceInfo: {
name: "Jellyfin-Wrapped",
id: await generateFingerprint(),
id: await generateGuid(),
},
});
api = jellyfin.createApi(serverUrl, jellyfinApiKey);
Expand All @@ -69,7 +69,7 @@ export const authenticateByUserName = async (
},
deviceInfo: {
name: "Jellyfin-Wrapped",
id: await generateFingerprint(),
id: await generateGuid(),
},
});
console.log("Connecting to server...", { serverUrl, username });
Expand Down
16 changes: 0 additions & 16 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,3 @@ export const generateGuid = () => {
});
};

export async function generateFingerprint() {
const components = [
navigator.userAgent,
navigator.language,
screen.width,
screen.height,
new Date().getTimezoneOffset(),
];

// Create a hash of the components
const text = components.join("|");
const msgBuffer = new TextEncoder().encode(text);
const hashBuffer = await crypto.subtle.digest("SHA-256", msgBuffer);
const hashArray = Array.from(new Uint8Array(hashBuffer));
return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
}

0 comments on commit 9c25e8c

Please sign in to comment.