mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-25 03:20:23 +01:00
34375a57e5
* security-prov: isFlaggedSecurityProviderResponse * security-prov: create shared/modules/util * security prov: rn isFlagged -> isSuspcious - util fn returns true if response is not verified and flagged * security prov: add util test and support undefined param * security prov: reorg util fn - no logic changes
20 lines
601 B
TypeScript
20 lines
601 B
TypeScript
import { Json } from '@metamask/utils';
|
|
import { SECURITY_PROVIDER_MESSAGE_SEVERITY } from '../constants/security-provider';
|
|
|
|
export function isSuspiciousResponse(
|
|
securityProviderResponse: Record<string, Json> | undefined,
|
|
): boolean {
|
|
if (!securityProviderResponse) {
|
|
return false;
|
|
}
|
|
|
|
const isFlagged =
|
|
securityProviderResponse.flagAsDangerous !== undefined &&
|
|
securityProviderResponse.flagAsDangerous !==
|
|
SECURITY_PROVIDER_MESSAGE_SEVERITY.NOT_MALICIOUS;
|
|
|
|
const isNotVerified = Object.keys(securityProviderResponse).length === 0;
|
|
|
|
return isFlagged || isNotVerified;
|
|
}
|