fix fack location complated
All checks were successful
Build & Deploy on Dev / build (push) Successful in 2m22s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 2m22s
This commit is contained in:
parent
859d74056a
commit
3ae6e6eeac
4 changed files with 287 additions and 115 deletions
|
|
@ -24,6 +24,13 @@ export const VALIDATION_CONFIG = {
|
|||
POSITION_HISTORY_SIZE: 5, // number of positions to keep for pattern detection
|
||||
MOCK_INDICATOR_THRESHOLD: 3, // threshold for mock detection (indicators >= 3 = mock)
|
||||
SUSPICIOUS_ACCURACY_MAX: 5, // accuracy ≤ 5m AND integer = suspicious (real GPS never rounds to whole number)
|
||||
// Geographic service area (Thailand) to reduce spoofing risk from remote fake coordinates.
|
||||
SERVICE_AREA: {
|
||||
MIN_LAT: 5.0,
|
||||
MAX_LAT: 21.0,
|
||||
MIN_LON: 97.0,
|
||||
MAX_LON: 106.0,
|
||||
},
|
||||
} as const
|
||||
|
||||
export function useLocationValidation() {
|
||||
|
|
@ -41,6 +48,8 @@ export function useLocationValidation() {
|
|||
'ตรวจพบการเคลื่อนที่ด้วยความเร็วผิดปกติ อาจเป็นการจำลองตำแหน่ง',
|
||||
SUSPICIOUS_ACCURACY: 'ตรวจพบค่าความแม่นยำที่ผิดปกติ อาจเป็นการจำลองตำแหน่ง',
|
||||
DUPLICATE_POSITION: 'ตรวจพบพิกัดตำแหน่งซ้ำกัน อาจเป็นการจำลองตำแหน่ง',
|
||||
OUT_OF_SERVICE_AREA:
|
||||
'ตรวจพบตำแหน่งนอกพื้นที่ใช้งานของระบบ กรุณาปิดแอปจำลองตำแหน่งและลองใหม่',
|
||||
}
|
||||
|
||||
const previousPositions = ref<PositionSnapshot[]>([])
|
||||
|
|
@ -132,6 +141,16 @@ export function useLocationValidation() {
|
|||
)
|
||||
}
|
||||
|
||||
const isWithinServiceArea = (lat: number, lon: number): boolean => {
|
||||
const area = VALIDATION_CONFIG.SERVICE_AREA
|
||||
return (
|
||||
lat >= area.MIN_LAT &&
|
||||
lat <= area.MAX_LAT &&
|
||||
lon >= area.MIN_LON &&
|
||||
lon <= area.MAX_LON
|
||||
)
|
||||
}
|
||||
|
||||
// Main validation function
|
||||
const validateLocation = (
|
||||
position: GeolocationPosition
|
||||
|
|
@ -149,6 +168,12 @@ export function useLocationValidation() {
|
|||
mockIndicators += 3
|
||||
}
|
||||
|
||||
// 1.1 Service-area validation (critical for remote spoofed coordinates)
|
||||
if (!isWithinServiceArea(latitude, longitude)) {
|
||||
errors.push(errorMessages.OUT_OF_SERVICE_AREA)
|
||||
mockIndicators += 3
|
||||
}
|
||||
|
||||
// 2. Timestamp validation
|
||||
if (!validateTimestamp(timestamp)) {
|
||||
errors.push(errorMessages.STALE_TIMESTAMP)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue