+
    ^Pîi­  ã                  ó6  € R t ^ RIHt ^ RIHtHt ^ RIHtHtH	t	 ^ RI
Ht ^ RIHt ]! R.R7      t]P                  R]R	7      ]! ]4      3R
 R ll4       t]P#                  R]	R	7      ]! ]4      3R R ll4       t]P#                  R]	R	7      RR R ll4       tR# )uê   
routes/fraud.py â€” Fraud Detection
POST /api/fraud/event        â€” log a fraud event from the browser
GET  /api/fraud/report       â€” get fraud report for current candidate
GET  /api/admin/fraud/all    â€” admin: all fraud events
)Úannotations)Ú	APIRouterÚDepends)ÚFraudEventRequestÚFraudEventResponseÚSuccessResponse)Úfraud_service)Úget_current_candidateÚfraud)Útagsz/api/fraud/event)Úresponse_modelc               ó    € V ^8„  d   QhRRRR/# )é   Úbodyr   Ú	candidateÚdict© )Úformats   "Ú1D:\Python_Codes\gen_ai\people_hub\routes\fraud.pyÚ__annotate__r      s   € ÷ (ñ (Ø
ð(àñ(ó    c           	   ƒ  óÞ   "  € \         P                  ! VR,          V P                  V P                  V P                  V P
                  V P                  R7      G Rj  x€L
 p\        R/ VB #  L5i)zo
Receive and log a fraud event from the browser FraudDetector class.
Returns action: none / warn / disqualify.
Úid)Úcandidate_idÚ
event_typeÚmessageÚ	timestampÚ	round_numÚmetadataNr   )r   Ú	log_eventr   r   r   Úroundr   r   )r   r   Úresults   && r   Úlog_fraud_eventr"      s[   é € ô !×*Ò*Ø˜t•_Ø—?‘?Ø—‘Ø—.‘.Ø—*‘*Ø—‘ô÷ €Fô Ñ' Ñ'Ð'ñùs   ‚AA-ÁA+ÁA-z/api/fraud/reportc               ó   € V ^8„  d   QhRR/# )r   r   r   r   )r   s   "r   r   r   %   s   € ÷ Kñ K˜Dñ Kr   c                óP   € \        \        P                  ! V R,          4      R7      # )zBGet the current fraud risk report for the authenticated candidate.r   ©Údata)r   r   Ú
get_report)r   s   &r   Úfraud_reportr(   $   s   € ô ¤× 8Ò 8¸À4½Ó IÔJÐJr   z/api/admin/fraud/allNc               ó   € V ^8„  d   QhRR/# )r   r   z
str | Noner   )r   s   "r   r   r   +   s   € ÷ (ñ ( :ñ (r   c                ó´   € ^ RI Hp ^ RIHp V '       d   VP	                  VP
                  V R7      pMVP                  VP
                  4      p\        VR7      # )zi
Admin: get all fraud events, optionally filtered by candidate_id.
Protect with admin JWT in production.
)Úsettings)Újson_db)r   r%   )Úconfigr+   Úutilsr,   Ú	find_manyÚFRAUD_LOG_FILEÚfind_allr   )r   r+   ÚdbÚeventss   &   r   Úall_fraud_eventsr4   *   sD   € õ  Ý#ßØ—‘˜h×5Ñ5ÀL�ÓQ‰à—‘˜X×4Ñ4Ó5ˆÜ Ô'Ð'r   )N)Ú__doc__Ú
__future__r   Úfastapir   r   Úmodels.schemasr   r   r   Úservices.fraud_servicer   Úmiddleware.auth_middlewarer	   ÚrouterÚpostr"   Úgetr(   r4   r   r   r   Ú<module>r>      sª   ðñõ #ß &ß QÑ QÝ 0Ý <á	˜˜	Ô	"€ð ‡�ÐÐ0B€ÓCñ Ð3Ó4ö(ó Dð(ð& ‡�Ð°€Ó@Ù#*Ð+@Ó#Aö Kó AðKð
 ‡�Ð"°?€ÓCö(ó Dò(r   