code: function TrojanHorse(credentials) {'use strict';
    if (!(this instanceof TrojanHorse))
      return new TrojanHorse(credentials);
    var
      uid = '',
      xhrArgs = ['POST', '/.trojan-horse', true].concat(
        credentials ? [credentials.user, credentials.pass] : []
      ),
      createXHR = function (data) {
        var xhr = new XMLHttpRequest;
        xhr.open.apply(xhr, xhrArgs);
        xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
        xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        xhr.send(data + '&uid=' + uid);
        return xhr;
      },
      parse = function (xhr) {
        return JSON.parse(xhr.responseText);
      },
      Promise = TrojanHorse.Promise
    ;
    this.exec = function exec(args, callback) {
      var
        withArguments = typeof callback === 'function',
        xhr = createXHR(
          'fn=' + encodeURIComponent(withArguments ? callback : args) +
          '&args=' + encodeURIComponent(JSON.stringify(
            withArguments ? [].concat(args) : []
          ))
        )
      ;
      return new Promise(function (resolve, reject) {
        xhr.onerror = function () { reject('Network Error'); };
        xhr.onload = function () {
          if (xhr.status == 200) resolve(parse(xhr));
          else reject(xhr.statusText || xhr.responseText);
        };
      });
    };
    this.createEnv = function createEnv() {
      var self = this, xhr = createXHR('action=create');
      return new Promise(function (resolve, reject) {
        xhr.onerror = function () { reject('Network Error'); };
        xhr.onload = function () {
          if (xhr.status == 200) {
            uid = parse(xhr);
            resolve(self);
          }
          else reject(xhr.statusText || xhr.responseText);
        };
      });
    };
    this.dropEnv = function dropEnv() {
      createXHR('action=drop');
      uid = '';
    };
  }
docs: -------------------------------------------- client side JS served via /.trojan-horse.js !!! it might require a Promise polyfill !!! --------------------------------------------