@@ -7,7 +7,7 @@ import { Logger } from '../logger';
77import Hook from 'require-in-the-middle' ;
88import { wrap } from 'shimmer' ;
99import ActionsList from './../actions-list' ;
10- import { clientIpFromRequest , contextFromRequest } from './../utils/utils' ;
10+ import { clientIpFromRequest , contextFromRequest , contextFromResponse } from './../utils/utils' ;
1111import { SecureNativeOptions } from '../types/securenative-options' ;
1212import { getDeviceFp } from './../utils/utils' ;
1313import SetType from '../enums/set-type' ;
@@ -95,14 +95,23 @@ export default class HttpServerInterceptor extends Interceptor implements IInter
9595 const risk = this . apiManager . risk . bind ( this ) ;
9696
9797 return function ( ) {
98- if ( ! this && ! this . sn_finished ) {
99- intercept ( this . req && this . req . sn_uid , 'end' ) ;
100- return original . apply ( this , arguments ) ;
98+ if ( this && this . sn_finished ) {
99+ SessionManager . cleanSession ( this . req && this . req . sn_uid ) ;
100+ return ;
101101 }
102102
103- const context = contextFromRequest ( this . req ) ;
104- risk ( { eventType : EventType . RISK , context : context } ) ;
105- return SessionManager . cleanSession ( this . req && this . req . sn_uid ) ;
103+ intercept ( this . req && this . req . sn_uid , 'end' ) ;
104+ const { req, res } = SessionManager . getSession ( this . req ?. sn_uid ) ;
105+ if ( req && res ) {
106+ const reqContext = contextFromRequest ( req ) ;
107+ const resContext = contextFromResponse ( res ) ;
108+
109+ risk ( { eventType : EventType . RISK , context : { reqContext, resContext } } ) ;
110+ }
111+
112+ SessionManager . cleanSession ( this . req && this . req . sn_uid ) ;
113+
114+ return original . apply ( this , arguments ) ;
106115 } ;
107116 } ) ;
108117
0 commit comments