@@ -323,3 +323,7 @@ export const generateFloatApproximatelyEqualsCustomizer = (
|
||||
: undefined;
|
||||
};
|
||||
};
|
||||
|
||||
export const convertHTTPAdressToWebsocket = (url: string): string => {
|
||||
return url.replace(/^http/i, 'ws');
|
||||
};
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
import { homeAssistantSignPath } from '../ha/sign-path';
|
||||
import { HomeAssistant } from '../ha/types';
|
||||
import { Endpoint } from '../types';
|
||||
import { errorToConsole } from './basic';
|
||||
|
||||
export const convertEndpointAddressToSignedWebsocket = async (
|
||||
hass: HomeAssistant,
|
||||
endpoint: Endpoint,
|
||||
expires?: number,
|
||||
): Promise<string | null> => {
|
||||
if (!endpoint.sign) {
|
||||
return endpoint.endpoint;
|
||||
}
|
||||
|
||||
let response: string | null | undefined;
|
||||
try {
|
||||
response = await homeAssistantSignPath(hass, endpoint.endpoint, expires);
|
||||
} catch (e) {
|
||||
errorToConsole(e as Error);
|
||||
}
|
||||
|
||||
return response ? response.replace(/^http/i, 'ws') : null;
|
||||
};
|
||||
Reference in New Issue
Block a user