Skip to content

Commit

Permalink
frontend/bitbox02/settings: handle attestation==null
Browse files Browse the repository at this point in the history
The backend can in theory return nil/null in the attestation endpoint,
if the endpoint is called before the device.Init() function has
finished, where the attesation check is performed.

The bb02 init is a bit messy, in the above state probably most/all
other bb02 calls would be broken too. For now, we simply adjust the
return type of `verifyAttestation()` to match the backend.
  • Loading branch information
benma committed Oct 26, 2022
1 parent d45103a commit 2cdd792
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion frontends/web/src/api/bitbox02.ts
Expand Up @@ -93,6 +93,6 @@ export const setMnemonicPassphraseEnabled = (

export const verifyAttestation = (
deviceID: string,
): Promise<boolean> => {
): Promise<boolean | null> => {
return apiGet(`devices/bitbox02/${deviceID}/attestation`);
};
5 changes: 2 additions & 3 deletions frontends/web/src/routes/device/bitbox02/settings.tsx
Expand Up @@ -40,8 +40,7 @@ type Props = {
export const Settings: FunctionComponent<Props> = ({ deviceID }) => {
const { t } = useTranslation();
const [deviceInfo, setDeviceInfo] = useState<DeviceInfo>();
const [attestation, setAttestation] = useState<boolean>();

const [attestation, setAttestation] = useState<boolean | null>(null);
useEffect(() => {
getDeviceInfo(deviceID).then(setDeviceInfo).catch(error => {
console.error(error);
Expand Down Expand Up @@ -89,7 +88,7 @@ export const Settings: FunctionComponent<Props> = ({ deviceID }) => {
{t('deviceSettings.hardware.securechip')}
</SettingsItem>
) }
{attestation !== undefined && (
{attestation !== null && (
<SettingsItem
optionalText={t(`deviceSettings.hardware.attestation.${attestation}`)}
optionalIcon={attestation ? <Checked/> : <Warning/>}>
Expand Down

0 comments on commit 2cdd792

Please sign in to comment.