lib/web/http.js
function logout(logoutOptions) {
    if (logoutOptions === void 0) { logoutOptions = {}; }
    var serverUrl = urls.resolveServer('/', logoutOptions);
    var serverObj = server.Server.getInstance(serverUrl);
    // process options
    var currentOptions = serverObj.applyOptions({
        serverUrl: serverUrl,
        agentOptions: logoutOptions.agentOptions || init.initOptions.agentOptions,
        agentClass: logoutOptions.agentClass || init.initOptions.agentClass,
    });
    return ajax(_.defaults({
        serverUrl: serverUrl,
        method: 'POST',
        url: '/gofer/security/rest/auth/logout',
        body: {}
    }, currentOptions)).catch(function (error) {
        if (error.statusCode === 422) {
            // REST-based logout URL currently is broken reporting a 422 in all cases
            return ajax(_.defaults({
                serverUrl: serverUrl,
                method: 'GET',
                url: '/gofer/security-logout'
            }, currentOptions)).then(function (result) {
                diag.debug.warn('BUG: resorted to classic PATH-based logout as REST-based logout failed:', error);
                return result;
            }, function (error2) {
                return Q.reject(error2.statusCode === 422 ? error : error2);
            });
        }
        return Q.reject(error);
    }).catch(function (error) {
        // ignore network failures on timeout, server forgets on session timeout anyways
        if (!error.statusCode) {
            return Q.resolve(undefined);
        }
        return Q.reject(error);
    }).finally(function () {
        // eventually erase offline login data
        if (logoutOptions.offlineCapable) {
            // requested to erase login data
            return offline.clearOfflineLogin(serverObj.credentials, currentOptions).catch(function (offlineError) {
                diag.debug.warn('failed erasing offline login data', offlineError);
                return Q.resolve(undefined);
            });
        }
    }).finally(function () {
        // forget everything about it
        serverObj.credentials = null;
        serverObj.authorization = auth.ANONYMOUS_AUTHORIZATION;
        serverObj.organization = null;
        serverObj.user = null;
        serverObj.sessionUserUuid = null;
    });
}
function logout(logoutOptions) {
    if (logoutOptions === void 0) { logoutOptions = {}; }
    var serverUrl = urls.resolveServer('/', logoutOptions);
    var serverObj = server.Server.getInstance(serverUrl);
    // process options
    var currentOptions = serverObj.applyOptions({
        serverUrl: serverUrl,
        agentOptions: logoutOptions.agentOptions || init.initOptions.agentOptions,
        agentClass: logoutOptions.agentClass || init.initOptions.agentClass,
    });
    return ajax(_.defaults({
        serverUrl: serverUrl,
        method: 'POST',
        url: '/gofer/security/rest/auth/logout',
        body: {}
    }, currentOptions)).catch(function (error) {
        if (error.statusCode === 422) {
            // REST-based logout URL currently is broken reporting a 422 in all cases
            return ajax(_.defaults({
                serverUrl: serverUrl,
                method: 'GET',
                url: '/gofer/security-logout'
            }, currentOptions)).then(function (result) {
                diag.debug.warn('BUG: resorted to classic PATH-based logout as REST-based logout failed:', error);
                return result;
            }, function (error2) {
                return Q.reject(error2.statusCode === 422 ? error : error2);
            });
        }
        return Q.reject(error);
    }).catch(function (error) {
        // ignore network failures on timeout, server forgets on session timeout anyways
        if (!error.statusCode) {
            return Q.resolve(undefined);
        }
        return Q.reject(error);
    }).finally(function () {
        // eventually erase offline login data
        if (logoutOptions.offlineCapable) {
            // requested to erase login data
            return offline.clearOfflineLogin(serverObj.credentials, currentOptions).catch(function (offlineError) {
                diag.debug.warn('failed erasing offline login data', offlineError);
                return Q.resolve(undefined);
            });
        }
    }).finally(function () {
        // forget everything about it
        serverObj.credentials = null;
        serverObj.authorization = auth.ANONYMOUS_AUTHORIZATION;
        serverObj.organization = null;
        serverObj.user = null;
        serverObj.sessionUserUuid = null;
    });
}
function logout ( logoutOptions ) { if ( logoutOptions === void 0 ) { logoutOptions = { } ; } var serverUrl = urls . resolveServer ( '/' , logoutOptions ) ; var serverObj = server . Server . getInstance ( serverUrl ) ; // process options var currentOptions = serverObj . applyOptions ( { serverUrl : serverUrl , agentOptions : logoutOptions . agentOptions || init . initOptions . agentOptions , agentClass : logoutOptions . agentClass || init . initOptions . agentClass , } ) ; return ajax ( _ . defaults ( { serverUrl : serverUrl , method : 'POST' , url : '/gofer/security/rest/auth/logout' , body : { } } , currentOptions ) ) . catch ( function ( error ) { if ( error . statusCode === 422 ) { // REST-based logout URL currently is broken reporting a 422 in all cases return ajax ( _ . defaults ( { serverUrl : serverUrl , method : 'GET' , url : '/gofer/security-logout' } , currentOptions ) ) . then ( function ( result ) { diag . debug . warn ( 'BUG: resorted to classic PATH-based logout as REST-based logout failed:' , error ) ; return result ; } , function ( error2 ) { return Q . reject ( error2 . statusCode === 422 ? error : error2 ) ; } ) ; } return Q . reject ( error ) ; } ) . catch ( function ( error ) { // ignore network failures on timeout, server forgets on session timeout anyways if ( ! error . statusCode ) { return Q . resolve ( undefined ) ; } return Q . reject ( error ) ; } ) . finally ( function ( ) { // eventually erase offline login data if ( logoutOptions . offlineCapable ) { // requested to erase login data return offline . clearOfflineLogin ( serverObj . credentials , currentOptions ) . catch ( function ( offlineError ) { diag . debug . warn ( 'failed erasing offline login data' , offlineError ) ; return Q . resolve ( undefined ) ; } ) ; } } ) . finally ( function ( ) { // forget everything about it serverObj . credentials = null ; serverObj . authorization = auth . ANONYMOUS_AUTHORIZATION ; serverObj . organization = null ; serverObj . user = null ; serverObj . sessionUserUuid = null ; } ) ; }
logs out of a Relution server.

For explicit logouts (trigger by app user pressing a logout button, for example) specifying
`offlineCapable = true` will drop any persisted offline login data for the server logging out
of.

@param logoutOptions overwriting [[init]] defaults.
@return {Q.Promise<void>} of logout response.

@example
```javascript

Relution.web.logout()
.then((resp) => console.log('resp', resp);)
.catch((e:Error) => console.error(e.message, e))
.finally(() => console.log('bye bye'));

//Observable
Observable.fromPromise(Relution.web.logout()).subscribe(
(resp: any) => console.log('resp', resp),
(e:Error) => console.error(e.message, e);,
() => console.log('bye bye')
)
```
logs out of a Relution server .