nl_tokens: Adds the given ip address to the websocket whitelist of the given virtual proxy . Be careful : this restarts the proxy . The restart can take 1 - 2 seconds . All subsequent API calls within this restart will fail miserably with various random & useless error messages .
pl_tokens: function ( options , params ) { // create connection to qrs var qrsApi = qrs ( options ) ; var ip = params . ip ; var vp = params . vp ; // Returned object var task = new Task ( ) ; // Promise chain // TODO: Convert this to a rx based logic var vpConfig = promise ( ) . then ( function ( ) { // Get proxy configuration return qrsApi . proxyservice . local . get ( ) ; } ) . then ( function ( settings ) { // Get virtual proxy configuration var vpsettings = undef . child ( settings , 'settings.virtualProxies' , [ ] ) . filter ( function ( elem , index ) { if ( undef . is ( vp ) ) return true ; else if ( parseInt ( vp ) === vp ) return index == vp ; else return elem . prefix == vp ; } ) ; return promise . all ( vpsettings . map ( function ( vp ) { return qrsApi . virtualproxyconfig . id ( vp . id ) . get ( ) ; } ) ) ; } ) . then ( function ( vpSettings ) { return promise . all ( vpSettings . map ( function ( settings ) { // If IP not already in whitelist if ( settings . websocketCrossOriginWhiteList . indexOf ( ip ) == - 1 ) { // Add it and push new config // The mechanism with dates below makes sure that there is no desync between // the client and the Qlik Sense server settings . websocketCrossOriginWhiteList . push ( ip ) ; var currDate = new Date ( ) ; var oldDate = new Date ( settings . modifiedDate ) ; var newDate ; if ( currDate > oldDate ) { newDate = currDate ; } else { newDate = oldDate ; newDate . setSeconds ( newDate . getSeconds ( ) + 1 ) ; } settings . modifiedDate = newDate . toISOString ( ) ; return qrsApi . virtualproxyconfig . <mask> ( settings . id ) . put ( settings ) ; } else { // Else just return the VP config return settings ; } } ) ) ; } ) ; // Convert the promise chain to an observable and register our task object Rx . Observable . from ( vpConfig ) . subscribe ( task ) ; if ( returnObservable ) { return task ; } else { return task . toPromise ( extPromise ) ; } }