Add basic daemon connection authentication

This commit is contained in:
hensm
2022-08-13 01:45:21 +01:00
parent e7788c1b17
commit 9f719132bf
9 changed files with 294 additions and 124 deletions

View File

@@ -44,6 +44,7 @@ export interface BridgeInfo {
export class BridgeConnectionError extends Error {}
export class BridgeTimedOutError extends Error {}
export class BridgeAuthenticationError extends Error {}
/**
* Creates a temporary bridge to query the version info,
@@ -73,10 +74,14 @@ const getInfo = () =>
{ subject: "bridge:/getInfo", data: version }
);
} catch (err) {
logger.error("Bridge connection failed.");
reject(new BridgeConnectionError());
clearTimeout(bridgeTimeoutId);
if (err === 401) {
reject(new BridgeAuthenticationError());
} else {
logger.error("Bridge connection failed.");
reject(new BridgeConnectionError());
}
clearTimeout(bridgeTimeoutId);
return;
}