A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.
fix: jellyfin integration does not allow username password auth (#1714)
Manuel63a7be35a4cf
diff --git a/packages/integrations/src/base/integration.ts b/packages/integrations/src/base/integration.tsindex c9c953443..413ec6096 100644--- a/packages/integrations/src/base/integration.ts+++ b/packages/integrations/src/base/integration.ts@@ -29,6 +29,10 @@ export abstract class Integration {return secret.value;}+ protected hasSecretValue(kind: IntegrationSecretKind) {+ return this.integration.decryptedSecrets.some((secret) => secret.kind === kind);+ }+protected url(path: `/${string}`, queryParams?: Record<string, string | Date | number | boolean>) {const baseUrl = removeTrailingSlash(this.integration.url);const url = new URL(`${baseUrl}${path}`);diff --git a/packages/integrations/src/jellyfin/jellyfin-integration.ts b/packages/integrations/src/jellyfin/jellyfin-integration.tsindex 4a603d6c2..2383473cd 100644--- a/packages/integrations/src/jellyfin/jellyfin-integration.ts+++ b/packages/integrations/src/jellyfin/jellyfin-integration.ts@@ -18,13 +18,13 @@ export class JellyfinIntegration extends Integration {});public async testConnectionAsync(): Promise<void> {- const api = this.getApi();+ const api = await this.getApiAsync();const systemApi = getSystemApi(api);await systemApi.getPingSystem();}public async getCurrentSessionsAsync(): Promise<StreamSession[]> {- const api = this.getApi();+ const api = await this.getApiAsync();const sessionApi = getSessionApi(api);const sessions = await sessionApi.getSessions();@@ -59,8 +59,22 @@ export class JellyfinIntegration extends Integration {});}- private getApi() {- const apiKey = this.getSecretValue("apiKey");- return this.jellyfin.createApi(this.url("/").toString(), apiKey);+ /**+ * Constructs an ApiClient synchronously with an ApiKey or asynchronously+ * with a username and password.+ * @returns An instance of Api that has been authenticated+ */+ private async getApiAsync() {+ if (this.hasSecretValue("apiKey")) {+ const apiKey = this.getSecretValue("apiKey");+ return this.jellyfin.createApi(this.url("/").toString(), apiKey);+ }++ const apiClient = this.jellyfin.createApi(this.url("/").toString());+ // Authentication state is stored internally in the Api class, so now+ // requests that require authentication can be made normally.+ // see https://typescript-sdk.jellyfin.org/#usage+ await apiClient.authenticateUserByName(this.getSecretValue("username"), this.getSecretValue("password"));+ return apiClient;}}