feat(network): add ProxyCheck IP intelligence
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
type UnknownMap = Record<string, unknown>;
|
||||
|
||||
function objectValue(value: unknown): UnknownMap | null {
|
||||
return value && typeof value === "object" && !Array.isArray(value)
|
||||
? value as UnknownMap
|
||||
: null;
|
||||
}
|
||||
|
||||
export function intelligenceSummary(value: unknown) {
|
||||
const intelligence = objectValue(value);
|
||||
const location = objectValue(intelligence?.location);
|
||||
const locationLabel = [location?.city, location?.region, location?.countryCode ?? location?.country]
|
||||
.filter((value): value is string => typeof value === "string" && value.length > 0)
|
||||
.join(", ");
|
||||
const classification = typeof intelligence?.classification === "string"
|
||||
? intelligence.classification
|
||||
: null;
|
||||
|
||||
return {
|
||||
location: locationLabel || null,
|
||||
classification,
|
||||
};
|
||||
}
|
||||
|
||||
export function eventIpSummary(data: UnknownMap) {
|
||||
return intelligenceSummary(data.ipIntelligence);
|
||||
}
|
||||
Reference in New Issue
Block a user