Fix jwt-token

This commit is contained in:
2025-08-28 11:40:04 +02:00
parent f54a763ebb
commit 5919794408
6 changed files with 421 additions and 21 deletions

217
server/utils/droneTypes.js Normal file
View File

@@ -0,0 +1,217 @@
/**
* Drone Type Mappings
* Maps integer drone_type values to human-readable names and categories
*/
const DRONE_TYPES = {
// Military/Combat Drones
0: {
name: "Russian Orlan",
category: "Military/Reconnaissance",
threat_level: "high",
description: "Russian military reconnaissance drone"
},
1: {
name: "Bayraktar TB2",
category: "Military/Combat",
threat_level: "critical",
description: "Turkish military combat drone"
},
2: {
name: "MQ-9 Reaper",
category: "Military/Combat",
threat_level: "critical",
description: "US military combat drone"
},
3: {
name: "Iranian Shahed",
category: "Military/Kamikaze",
threat_level: "critical",
description: "Iranian kamikaze/suicide drone"
},
4: {
name: "Chinese Wing Loong",
category: "Military/Combat",
threat_level: "critical",
description: "Chinese military combat drone"
},
5: {
name: "Israeli Hermes",
category: "Military/Reconnaissance",
threat_level: "high",
description: "Israeli military reconnaissance drone"
},
// Commercial/Professional Drones
10: {
name: "DJI Mavic",
category: "Commercial/Professional",
threat_level: "medium",
description: "DJI professional quadcopter"
},
11: {
name: "DJI Phantom",
category: "Commercial/Professional",
threat_level: "medium",
description: "DJI professional quadcopter"
},
12: {
name: "DJI Inspire",
category: "Commercial/Professional",
threat_level: "medium",
description: "DJI professional cinematography drone"
},
13: {
name: "Autel EVO",
category: "Commercial/Professional",
threat_level: "medium",
description: "Autel professional quadcopter"
},
14: {
name: "Parrot Anafi",
category: "Commercial/Professional",
threat_level: "medium",
description: "Parrot professional quadcopter"
},
// Consumer/Hobby Drones
20: {
name: "DJI Mini",
category: "Consumer/Hobby",
threat_level: "low",
description: "DJI consumer mini drone"
},
21: {
name: "DJI Spark",
category: "Consumer/Hobby",
threat_level: "low",
description: "DJI consumer compact drone"
},
22: {
name: "Ryze Tello",
category: "Consumer/Hobby",
threat_level: "low",
description: "Consumer toy/education drone"
},
23: {
name: "Holy Stone",
category: "Consumer/Hobby",
threat_level: "low",
description: "Consumer hobby quadcopter"
},
24: {
name: "Syma X5C",
category: "Consumer/Hobby",
threat_level: "low",
description: "Consumer toy quadcopter"
},
// Racing/FPV Drones
30: {
name: "Racing Quadcopter",
category: "Racing/FPV",
threat_level: "low",
description: "Custom racing/FPV quadcopter"
},
31: {
name: "TinyHawk",
category: "Racing/FPV",
threat_level: "low",
description: "Micro racing quadcopter"
},
// Fixed-Wing Drones
40: {
name: "Fixed-Wing Surveillance",
category: "Fixed-Wing/Surveillance",
threat_level: "medium",
description: "Fixed-wing surveillance aircraft"
},
41: {
name: "Fixed-Wing Cargo",
category: "Fixed-Wing/Commercial",
threat_level: "medium",
description: "Fixed-wing cargo/delivery aircraft"
},
// Unknown/Unclassified
99: {
name: "Unknown Drone",
category: "Unknown/Unclassified",
threat_level: "medium",
description: "Unidentified or unclassified drone"
}
};
/**
* Get drone type information by ID
* @param {number} droneTypeId - The integer drone type ID
* @returns {object} Drone type information or default for unknown types
*/
function getDroneTypeInfo(droneTypeId) {
const typeInfo = DRONE_TYPES[droneTypeId];
if (typeInfo) {
return {
id: droneTypeId,
...typeInfo
};
}
// Return default for unknown types
return {
id: droneTypeId,
name: `Unknown Type ${droneTypeId}`,
category: "Unknown/Unclassified",
threat_level: "medium",
description: `Unrecognized drone type ID: ${droneTypeId}`
};
}
/**
* Get just the drone name by ID
* @param {number} droneTypeId - The integer drone type ID
* @returns {string} Drone name
*/
function getDroneTypeName(droneTypeId) {
return getDroneTypeInfo(droneTypeId).name;
}
/**
* Get all available drone types
* @returns {object} All drone type mappings
*/
function getAllDroneTypes() {
return DRONE_TYPES;
}
/**
* Get drone types by category
* @param {string} category - The category to filter by
* @returns {array} Array of drone types in the category
*/
function getDroneTypesByCategory(category) {
return Object.entries(DRONE_TYPES)
.filter(([id, info]) => info.category === category)
.map(([id, info]) => ({ id: parseInt(id), ...info }));
}
/**
* Get drone types by threat level
* @param {string} threatLevel - The threat level to filter by
* @returns {array} Array of drone types with the threat level
*/
function getDroneTypesByThreatLevel(threatLevel) {
return Object.entries(DRONE_TYPES)
.filter(([id, info]) => info.threat_level === threatLevel)
.map(([id, info]) => ({ id: parseInt(id), ...info }));
}
module.exports = {
DRONE_TYPES,
getDroneTypeInfo,
getDroneTypeName,
getAllDroneTypes,
getDroneTypesByCategory,
getDroneTypesByThreatLevel
};