feat: Add proxying support for images (#2427)

- Closes #2418
This commit is contained in:
Dermot Duffy
2026-06-30 17:45:12 -07:00
committed by dermotduffy
parent 9384785d37
commit 1cd5520154
51 changed files with 2404 additions and 687 deletions
+14 -19
View File
@@ -1,7 +1,7 @@
import { ZodSchema } from 'zod';
import { localize } from '../localize/localize';
import { AdvancedCameraCardError, Endpoint } from '../types';
import { homeAssistantSignPath } from './sign-path';
import { homeAssistantGetSignedURLIfNecessary } from './sign-path';
import { HomeAssistant } from './types';
/**
@@ -22,25 +22,20 @@ export const homeAssistantSignAndFetch = async <T>(
timeoutSeconds?: number;
},
): Promise<T> => {
let url: string | null = endpoint.endpoint;
const sign = endpoint.sign;
let url: string | null;
try {
url = await homeAssistantGetSignedURLIfNecessary(hass, endpoint);
} catch (error) {
throw new AdvancedCameraCardError(localize('error.failed_sign'), {
endpoint,
error,
});
}
// Sign the path if needed
if (sign) {
try {
url = await homeAssistantSignPath(hass, url);
} catch (error) {
throw new AdvancedCameraCardError(localize('error.failed_sign'), {
endpoint,
error,
});
}
if (!url) {
throw new AdvancedCameraCardError(localize('error.failed_sign'), {
endpoint,
});
}
if (!url) {
throw new AdvancedCameraCardError(localize('error.failed_sign'), {
endpoint,
});
}
let response: Response;