2022-08-03 16:56:11 +02:00
|
|
|
import React, { useContext } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import AccountListItem from '../../account-list-item';
|
|
|
|
import { I18nContext } from '../../../../contexts/i18n';
|
|
|
|
import PermissionsConnectHeader from '../../permissions-connect-header';
|
2022-10-04 23:33:51 +02:00
|
|
|
import SignatureRequestSIWEIcon from '../signature-request-siwe-icon';
|
|
|
|
import SignatureRequestSIWETag from '../signature-request-siwe-tag';
|
|
|
|
import Tooltip from '../../../ui/tooltip';
|
2022-08-03 16:56:11 +02:00
|
|
|
|
|
|
|
export default function SignatureRequestSIWEHeader({
|
|
|
|
fromAccount,
|
|
|
|
domain,
|
|
|
|
isSIWEDomainValid,
|
|
|
|
subjectMetadata,
|
|
|
|
}) {
|
|
|
|
const t = useContext(I18nContext);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="signature-request-siwe-header">
|
|
|
|
<PermissionsConnectHeader
|
|
|
|
iconUrl={subjectMetadata.iconUrl}
|
|
|
|
iconName={subjectMetadata.name}
|
|
|
|
headerTitle={t('SIWESiteRequestTitle')}
|
|
|
|
headerText={t('SIWESiteRequestSubtitle')}
|
|
|
|
siteOrigin={domain}
|
|
|
|
className={isSIWEDomainValid ? '' : 'bad-domain'}
|
2022-10-04 23:33:51 +02:00
|
|
|
leftIcon={
|
|
|
|
!isSIWEDomainValid && (
|
|
|
|
<Tooltip
|
|
|
|
position="bottom"
|
|
|
|
html={<p>{t('SIWEDomainWarningBody', [domain])}</p>}
|
|
|
|
>
|
|
|
|
<SignatureRequestSIWEIcon />
|
|
|
|
</Tooltip>
|
|
|
|
)
|
|
|
|
}
|
2022-08-03 16:56:11 +02:00
|
|
|
rightIcon={
|
|
|
|
!isSIWEDomainValid && (
|
|
|
|
<Tooltip
|
|
|
|
position="bottom"
|
|
|
|
html={<p>{t('SIWEDomainWarningBody', [domain])}</p>}
|
|
|
|
>
|
2022-10-04 23:33:51 +02:00
|
|
|
<SignatureRequestSIWETag text={t('SIWEDomainWarningLabel')} />
|
2022-08-03 16:56:11 +02:00
|
|
|
</Tooltip>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
{fromAccount && (
|
|
|
|
<AccountListItem
|
|
|
|
account={fromAccount}
|
2023-05-24 13:41:21 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
|
|
hideDefaultMismatchWarning
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
2022-08-03 16:56:11 +02:00
|
|
|
className="signature-request-siwe-header__account-list-item"
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
SignatureRequestSIWEHeader.propTypes = {
|
|
|
|
/**
|
|
|
|
* The account that is requesting permissions
|
|
|
|
*/
|
|
|
|
fromAccount: PropTypes.object,
|
|
|
|
/**
|
|
|
|
* The domain that the request is for
|
|
|
|
*/
|
|
|
|
domain: PropTypes.string,
|
|
|
|
/**
|
|
|
|
* Whether the domain is valid
|
|
|
|
*/
|
|
|
|
isSIWEDomainValid: PropTypes.bool,
|
|
|
|
/**
|
|
|
|
* The metadata for the subject. This is used to display the icon and name
|
|
|
|
* and is selected from the domain in the SIWE request.
|
|
|
|
*/
|
|
|
|
subjectMetadata: PropTypes.object,
|
|
|
|
};
|