src/request.js
function prepareResponse(response) {
  Safe.log('Received response: ', response);
  return response.text().then(function(text) {
    // If we get a 2xx...
    Safe.log('Launcher returned status '+response.status);
    if (response.ok) {
      // If not an authorized request, or not encrypted, no decryption necessary
      if (!this._needAuth || doNotDecrypt.indexOf(text) > -1)
        var body = utils.parseJson(text);

      // Otherwise, decrypt response
      else
        var body = utils.decrypt(text, this.Safe.getAuth('symNonce'), this.Safe.getAuth('symKey'));

      // Lastly, if any meta data was requested (e.g. the headers), then return an object
      if (this._returnMeta) {
        return {body: body, meta: response.headers.entries()};
      } else {
        // No need to return 'OK' for responses that return that.
        return (typeof body === 'string' && body.toUpperCase() === 'OK') ? undefined : body;
      }
    } else {
      // If authentication was requested, then decrypt the error message received.
      if (this._needAuth && doNotDecrypt.indexOf(text) === -1) {
        var message = utils.decrypt(text, this.Safe.getAuth('symNonce'), this.Safe.getAuth('symKey')),
            parsed = parseSafeMessage(message, response.status);

        // Throw a "launcher" error type, which is an error from the launcher.
        throw new SafeError('launcher', parsed.message, parsed.status, response);
      } else {
        // If no message received, it's a standard http response error
        var parsed = parseSafeMessage(utils.parseJson(text), response.status);
        throw new SafeError('http', parsed.message, parsed.status, response);
      }
    }
  }.bind(this));
}
function prepareResponse(response) {
  Safe.log('Received response: ', response);
  return response.text().then(function(text) {
    // If we get a 2xx...
    Safe.log('Launcher returned status '+response.status);
    if (response.ok) {
      // If not an authorized request, or not encrypted, no decryption necessary
      if (!this._needAuth || doNotDecrypt.indexOf(text) > -1)
        var body = utils.parseJson(text);

      // Otherwise, decrypt response
      else
        var body = utils.decrypt(text, this.Safe.getAuth('symNonce'), this.Safe.getAuth('symKey'));

      // Lastly, if any meta data was requested (e.g. the headers), then return an object
      if (this._returnMeta) {
        return {body: body, meta: response.headers.entries()};
      } else {
        // No need to return 'OK' for responses that return that.
        return (typeof body === 'string' && body.toUpperCase() === 'OK') ? undefined : body;
      }
    } else {
      // If authentication was requested, then decrypt the error message received.
      if (this._needAuth && doNotDecrypt.indexOf(text) === -1) {
        var message = utils.decrypt(text, this.Safe.getAuth('symNonce'), this.Safe.getAuth('symKey')),
            parsed = parseSafeMessage(message, response.status);

        // Throw a "launcher" error type, which is an error from the launcher.
        throw new SafeError('launcher', parsed.message, parsed.status, response);
      } else {
        // If no message received, it's a standard http response error
        var parsed = parseSafeMessage(utils.parseJson(text), response.status);
        throw new SafeError('http', parsed.message, parsed.status, response);
      }
    }
  }.bind(this));
}
function prepareResponse ( response ) { Safe . log ( 'Received response: ' , response ) ; return response . text ( ) . then ( function ( text ) { // If we get a 2xx... Safe . log ( 'Launcher returned status ' + response . status ) ; if ( response . ok ) { // If not an authorized request, or not encrypted, no decryption necessary if ( ! this . _needAuth || doNotDecrypt . indexOf ( text ) > - 1 ) var body = utils . parseJson ( text ) ; // Otherwise, decrypt response else var body = utils . decrypt ( text , this . Safe . getAuth ( 'symNonce' ) , this . Safe . getAuth ( 'symKey' ) ) ; // Lastly, if any meta data was requested (e.g. the headers), then return an object if ( this . _returnMeta ) { return { body : body , meta : response . headers . entries ( ) } ; } else { // No need to return 'OK' for responses that return that. return ( typeof body === 'string' && body . toUpperCase ( ) === 'OK' ) ? undefined : body ; } } else { // If authentication was requested, then decrypt the error message received. if ( this . _needAuth && doNotDecrypt . indexOf ( text ) === - 1 ) { var message = utils . decrypt ( text , this . Safe . getAuth ( 'symNonce' ) , this . Safe . getAuth ( 'symKey' ) ) , parsed = parseSafeMessage ( message , response . status ) ; // Throw a "launcher" error type, which is an error from the launcher. throw new SafeError ( 'launcher' , parsed . message , parsed . status , response ) ; } else { // If no message received, it's a standard http response error var parsed = parseSafeMessage ( utils . parseJson ( text ) , response . status ) ; throw new SafeError ( 'http' , parsed . message , parsed . status , response ) ; } } } . bind ( this ) ) ; }
If request was with auth token, returned data is encrypted, otherwise it's plain ol' json
If request was with auth token returned data is encrypted otherwise it s plain ol json