cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From za...@apache.org
Subject [05/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548 Install new node-firefox-* dependencies in node_modules
Date Wed, 01 Apr 2015 14:22:32 GMT
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/xhr.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/xhr.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/xhr.js
new file mode 100644
index 0000000..96082ad
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/xhr.js
@@ -0,0 +1,739 @@
+/**
+ * XmlHttpRequest implementation that uses TLS and flash SocketPool.
+ *
+ * @author Dave Longley
+ *
+ * Copyright (c) 2010-2013 Digital Bazaar, Inc.
+ */
+(function($) {
+
+// logging category
+var cat = 'forge.xhr';
+
+/*
+XMLHttpRequest interface definition from:
+http://www.w3.org/TR/XMLHttpRequest
+
+interface XMLHttpRequest {
+  // event handler
+  attribute EventListener onreadystatechange;
+
+  // state
+  const unsigned short UNSENT = 0;
+  const unsigned short OPENED = 1;
+  const unsigned short HEADERS_RECEIVED = 2;
+  const unsigned short LOADING = 3;
+  const unsigned short DONE = 4;
+  readonly attribute unsigned short readyState;
+
+  // request
+  void open(in DOMString method, in DOMString url);
+  void open(in DOMString method, in DOMString url, in boolean async);
+  void open(in DOMString method, in DOMString url,
+            in boolean async, in DOMString user);
+  void open(in DOMString method, in DOMString url,
+            in boolean async, in DOMString user, in DOMString password);
+  void setRequestHeader(in DOMString header, in DOMString value);
+  void send();
+  void send(in DOMString data);
+  void send(in Document data);
+  void abort();
+
+  // response
+  DOMString getAllResponseHeaders();
+  DOMString getResponseHeader(in DOMString header);
+  readonly attribute DOMString responseText;
+  readonly attribute Document responseXML;
+  readonly attribute unsigned short status;
+  readonly attribute DOMString statusText;
+};
+*/
+
+// readyStates
+var UNSENT = 0;
+var OPENED = 1;
+var HEADERS_RECEIVED = 2;
+var LOADING = 3;
+var DONE = 4;
+
+// exceptions
+var INVALID_STATE_ERR = 11;
+var SYNTAX_ERR = 12;
+var SECURITY_ERR = 18;
+var NETWORK_ERR = 19;
+var ABORT_ERR = 20;
+
+// private flash socket pool vars
+var _sp = null;
+var _policyPort = 0;
+var _policyUrl = null;
+
+// default client (used if no special URL provided when creating an XHR)
+var _client = null;
+
+// all clients including the default, key'd by full base url
+// (multiple cross-domain http clients are permitted so there may be more
+// than one client in this map)
+// TODO: provide optional clean up API for non-default clients
+var _clients = {};
+
+// the default maximum number of concurrents connections per client
+var _maxConnections = 10;
+
+// local aliases
+if(typeof forge === 'undefined') {
+  forge = {};
+}
+var net = forge.net;
+var http = forge.http;
+
+// define the xhr interface
+var xhrApi = {};
+
+/**
+ * Initializes flash XHR support.
+ *
+ * @param options:
+ *   url: the default base URL to connect to if xhr URLs are relative,
+ *     ie: https://myserver.com.
+ *   flashId: the dom ID of the flash SocketPool.
+ *   policyPort: the port that provides the server's flash policy, 0 to use
+ *     the flash default.
+ *   policyUrl: the policy file URL to use instead of a policy port.
+ *   msie: true if browser is internet explorer, false if not.
+ *   connections: the maximum number of concurrent connections.
+ *   caCerts: a list of PEM-formatted certificates to trust.
+ *   cipherSuites: an optional array of cipher suites to use,
+ *     see forge.tls.CipherSuites.
+ *   verify: optional TLS certificate verify callback to use (see forge.tls
+ *     for details).
+ *   getCertificate: an optional callback used to get a client-side
+ *     certificate (see forge.tls for details).
+ *   getPrivateKey: an optional callback used to get a client-side private
+ *     key (see forge.tls for details).
+ *   getSignature: an optional callback used to get a client-side signature
+ *     (see forge.tls for details).
+ *   persistCookies: true to use persistent cookies via flash local storage,
+ *     false to only keep cookies in javascript.
+ *   primeTlsSockets: true to immediately connect TLS sockets on their
+ *     creation so that they will cache TLS sessions for reuse.
+ */
+xhrApi.init = function(options) {
+  forge.log.debug(cat, 'initializing', options);
+
+  // update default policy port and max connections
+  _policyPort = options.policyPort || _policyPort;
+  _policyUrl = options.policyUrl || _policyUrl;
+  _maxConnections = options.connections || _maxConnections;
+
+  // create the flash socket pool
+  _sp = net.createSocketPool({
+    flashId: options.flashId,
+    policyPort: _policyPort,
+    policyUrl: _policyUrl,
+    msie: options.msie || false
+  });
+
+  // create default http client
+  _client = http.createClient({
+    url: options.url || (
+      window.location.protocol + '//' + window.location.host),
+    socketPool: _sp,
+    policyPort: _policyPort,
+    policyUrl: _policyUrl,
+    connections: options.connections || _maxConnections,
+    caCerts: options.caCerts,
+    cipherSuites: options.cipherSuites,
+    persistCookies: options.persistCookies || true,
+    primeTlsSockets: options.primeTlsSockets || false,
+    verify: options.verify,
+    getCertificate: options.getCertificate,
+    getPrivateKey: options.getPrivateKey,
+    getSignature: options.getSignature
+  });
+  _clients[_client.url.full] = _client;
+
+  forge.log.debug(cat, 'ready');
+};
+
+/**
+ * Called to clean up the clients and socket pool.
+ */
+xhrApi.cleanup = function() {
+  // destroy all clients
+  for(var key in _clients) {
+    _clients[key].destroy();
+  }
+  _clients = {};
+  _client = null;
+
+  // destroy socket pool
+  _sp.destroy();
+  _sp = null;
+};
+
+/**
+ * Sets a cookie.
+ *
+ * @param cookie the cookie with parameters:
+ *   name: the name of the cookie.
+ *   value: the value of the cookie.
+ *   comment: an optional comment string.
+ *   maxAge: the age of the cookie in seconds relative to created time.
+ *   secure: true if the cookie must be sent over a secure protocol.
+ *   httpOnly: true to restrict access to the cookie from javascript
+ *     (inaffective since the cookies are stored in javascript).
+ *   path: the path for the cookie.
+ *   domain: optional domain the cookie belongs to (must start with dot).
+ *   version: optional version of the cookie.
+ *   created: creation time, in UTC seconds, of the cookie.
+ */
+xhrApi.setCookie = function(cookie) {
+  // default cookie expiration to never
+  cookie.maxAge = cookie.maxAge || -1;
+
+  // if the cookie's domain is set, use the appropriate client
+  if(cookie.domain) {
+    // add the cookies to the applicable domains
+    for(var key in _clients) {
+      var client = _clients[key];
+      if(http.withinCookieDomain(client.url, cookie) &&
+        client.secure === cookie.secure) {
+        client.setCookie(cookie);
+      }
+    }
+  } else {
+    // use the default domain
+    // FIXME: should a null domain cookie be added to all clients? should
+    // this be an option?
+    _client.setCookie(cookie);
+  }
+};
+
+/**
+ * Gets a cookie.
+ *
+ * @param name the name of the cookie.
+ * @param path an optional path for the cookie (if there are multiple cookies
+ *          with the same name but different paths).
+ * @param domain an optional domain for the cookie (if not using the default
+ *          domain).
+ *
+ * @return the cookie, cookies (if multiple matches), or null if not found.
+ */
+xhrApi.getCookie = function(name, path, domain) {
+  var rval = null;
+
+  if(domain) {
+    // get the cookies from the applicable domains
+    for(var key in _clients) {
+      var client = _clients[key];
+      if(http.withinCookieDomain(client.url, domain)) {
+        var cookie = client.getCookie(name, path);
+        if(cookie !== null) {
+          if(rval === null) {
+            rval = cookie;
+          } else if(!forge.util.isArray(rval)) {
+            rval = [rval, cookie];
+          } else {
+            rval.push(cookie);
+          }
+        }
+      }
+    }
+  } else {
+    // get cookie from default domain
+    rval = _client.getCookie(name, path);
+  }
+
+  return rval;
+};
+
+/**
+ * Removes a cookie.
+ *
+ * @param name the name of the cookie.
+ * @param path an optional path for the cookie (if there are multiple cookies
+ *          with the same name but different paths).
+ * @param domain an optional domain for the cookie (if not using the default
+ *          domain).
+ *
+ * @return true if a cookie was removed, false if not.
+ */
+xhrApi.removeCookie = function(name, path, domain) {
+  var rval = false;
+
+  if(domain) {
+    // remove the cookies from the applicable domains
+    for(var key in _clients) {
+      var client = _clients[key];
+      if(http.withinCookieDomain(client.url, domain)) {
+        if(client.removeCookie(name, path)) {
+           rval = true;
+        }
+      }
+    }
+  } else {
+    // remove cookie from default domain
+    rval = _client.removeCookie(name, path);
+  }
+
+  return rval;
+};
+
+/**
+ * Creates a new XmlHttpRequest. By default the base URL, flash policy port,
+ * etc, will be used. However, an XHR can be created to point at another
+ * cross-domain URL.
+ *
+ * @param options:
+ *   logWarningOnError: If true and an HTTP error status code is received then
+ *     log a warning, otherwise log a verbose message.
+ *   verbose: If true be very verbose in the output including the response
+ *     event and response body, otherwise only include status, timing, and
+ *     data size.
+ *   logError: a multi-var log function for warnings that takes the log
+ *     category as the first var.
+ *   logWarning: a multi-var log function for warnings that takes the log
+ *     category as the first var.
+ *   logDebug: a multi-var log function for warnings that takes the log
+ *     category as the first var.
+ *   logVerbose: a multi-var log function for warnings that takes the log
+ *     category as the first var.
+ *   url: the default base URL to connect to if xhr URLs are relative,
+ *     eg: https://myserver.com, and note that the following options will be
+ *     ignored if the URL is absent or the same as the default base URL.
+ *   policyPort: the port that provides the server's flash policy, 0 to use
+ *     the flash default.
+ *   policyUrl: the policy file URL to use instead of a policy port.
+ *   connections: the maximum number of concurrent connections.
+ *   caCerts: a list of PEM-formatted certificates to trust.
+ *   cipherSuites: an optional array of cipher suites to use, see
+ *     forge.tls.CipherSuites.
+ *   verify: optional TLS certificate verify callback to use (see forge.tls
+ *     for details).
+ *   getCertificate: an optional callback used to get a client-side
+ *     certificate.
+ *   getPrivateKey: an optional callback used to get a client-side private key.
+ *   getSignature: an optional callback used to get a client-side signature.
+ *   persistCookies: true to use persistent cookies via flash local storage,
+ *     false to only keep cookies in javascript.
+ *   primeTlsSockets: true to immediately connect TLS sockets on their
+ *     creation so that they will cache TLS sessions for reuse.
+ *
+ * @return the XmlHttpRequest.
+ */
+xhrApi.create = function(options) {
+  // set option defaults
+  options = $.extend({
+    logWarningOnError: true,
+    verbose: false,
+    logError: function(){},
+    logWarning: function(){},
+    logDebug: function(){},
+    logVerbose: function(){},
+    url: null
+  }, options || {});
+
+  // private xhr state
+  var _state = {
+    // the http client to use
+    client: null,
+    // request storage
+    request: null,
+    // response storage
+    response: null,
+    // asynchronous, true if doing asynchronous communication
+    asynchronous: true,
+    // sendFlag, true if send has been called
+    sendFlag: false,
+    // errorFlag, true if a network error occurred
+    errorFlag: false
+  };
+
+  // private log functions
+  var _log = {
+    error: options.logError || forge.log.error,
+    warning: options.logWarning || forge.log.warning,
+    debug: options.logDebug || forge.log.debug,
+    verbose: options.logVerbose || forge.log.verbose
+  };
+
+  // create public xhr interface
+  var xhr = {
+    // an EventListener
+    onreadystatechange: null,
+    // readonly, the current readyState
+    readyState: UNSENT,
+    // a string with the response entity-body
+    responseText: '',
+    // a Document for response entity-bodies that are XML
+    responseXML: null,
+    // readonly, returns the HTTP status code (i.e. 404)
+    status: 0,
+    // readonly, returns the HTTP status message (i.e. 'Not Found')
+    statusText: ''
+  };
+
+  // determine which http client to use
+  if(options.url === null) {
+    // use default
+    _state.client = _client;
+  } else {
+    var url = http.parseUrl(options.url);
+    if(!url) {
+      var error = new Error('Invalid url.');
+      error.details = {
+        url: options.url
+      };
+    }
+
+    // find client
+    if(url.full in _clients) {
+      // client found
+      _state.client = _clients[url.full];
+    } else {
+      // create client
+      _state.client = http.createClient({
+        url: options.url,
+        socketPool: _sp,
+        policyPort: options.policyPort || _policyPort,
+        policyUrl: options.policyUrl || _policyUrl,
+        connections: options.connections || _maxConnections,
+        caCerts: options.caCerts,
+        cipherSuites: options.cipherSuites,
+        persistCookies: options.persistCookies || true,
+        primeTlsSockets: options.primeTlsSockets || false,
+        verify: options.verify,
+        getCertificate: options.getCertificate,
+        getPrivateKey: options.getPrivateKey,
+        getSignature: options.getSignature
+      });
+      _clients[url.full] = _state.client;
+    }
+  }
+
+  /**
+   * Opens the request. This method will create the HTTP request to send.
+   *
+   * @param method the HTTP method (i.e. 'GET').
+   * @param url the relative url (the HTTP request path).
+   * @param async always true, ignored.
+   * @param user always null, ignored.
+   * @param password always null, ignored.
+   */
+  xhr.open = function(method, url, async, user, password) {
+    // 1. validate Document if one is associated
+    // TODO: not implemented (not used yet)
+
+    // 2. validate method token
+    // 3. change method to uppercase if it matches a known
+    // method (here we just require it to be uppercase, and
+    // we do not allow the standard methods)
+    // 4. disallow CONNECT, TRACE, or TRACK with a security error
+    switch(method) {
+    case 'DELETE':
+    case 'GET':
+    case 'HEAD':
+    case 'OPTIONS':
+    case 'PATCH':
+    case 'POST':
+    case 'PUT':
+      // valid method
+      break;
+    case 'CONNECT':
+    case 'TRACE':
+    case 'TRACK':
+      throw new Error('CONNECT, TRACE and TRACK methods are disallowed');
+    default:
+      throw new Error('Invalid method: ' + method);;
+    }
+
+    // TODO: other validation steps in algorithm are not implemented
+
+    // 19. set send flag to false
+    // set response body to null
+    // empty list of request headers
+    // set request method to given method
+    // set request URL
+    // set username, password
+    // set asychronous flag
+    _state.sendFlag = false;
+    xhr.responseText = '';
+    xhr.responseXML = null;
+
+    // custom: reset status and statusText
+    xhr.status = 0;
+    xhr.statusText = '';
+
+    // create the HTTP request
+    _state.request = http.createRequest({
+      method: method,
+      path: url
+    });
+
+    // 20. set state to OPENED
+    xhr.readyState = OPENED;
+
+    // 21. dispatch onreadystatechange
+    if(xhr.onreadystatechange) {
+       xhr.onreadystatechange();
+    }
+  };
+
+  /**
+   * Adds an HTTP header field to the request.
+   *
+   * @param header the name of the header field.
+   * @param value the value of the header field.
+   */
+  xhr.setRequestHeader = function(header, value) {
+    // 1. if state is not OPENED or send flag is true, raise exception
+    if(xhr.readyState != OPENED || _state.sendFlag) {
+      throw new Error('XHR not open or sending');
+    }
+
+    // TODO: other validation steps in spec aren't implemented
+
+    // set header
+    _state.request.setField(header, value);
+  };
+
+  /**
+   * Sends the request and any associated data.
+   *
+   * @param data a string or Document object to send, null to send no data.
+   */
+  xhr.send = function(data) {
+    // 1. if state is not OPENED or 2. send flag is true, raise
+    // an invalid state exception
+    if(xhr.readyState != OPENED || _state.sendFlag) {
+      throw new Error('XHR not open or sending');
+    }
+
+    // 3. ignore data if method is GET or HEAD
+    if(data &&
+      _state.request.method !== 'GET' &&
+      _state.request.method !== 'HEAD') {
+      // handle non-IE case
+      if(typeof(XMLSerializer) !== 'undefined') {
+        if(data instanceof Document) {
+          var xs = new XMLSerializer();
+          _state.request.body = xs.serializeToString(data);
+        } else {
+          _state.request.body = data;
+        }
+      } else {
+        // poorly implemented IE case
+        if(typeof(data.xml) !== 'undefined') {
+          _state.request.body = data.xml;
+        } else {
+          _state.request.body = data;
+        }
+      }
+    }
+
+    // 4. release storage mutex (not used)
+
+    // 5. set error flag to false
+    _state.errorFlag = false;
+
+    // 6. if asynchronous is true (must be in this implementation)
+
+    // 6.1 set send flag to true
+    _state.sendFlag = true;
+
+    // 6.2 dispatch onreadystatechange
+    if(xhr.onreadystatechange) {
+      xhr.onreadystatechange();
+    }
+
+    // create send options
+    var options = {};
+    options.request = _state.request;
+    options.headerReady = function(e) {
+      // make cookies available for ease of use/iteration
+      xhr.cookies = _state.client.cookies;
+
+      // TODO: update document.cookie with any cookies where the
+      // script's domain matches
+
+      // headers received
+      xhr.readyState = HEADERS_RECEIVED;
+      xhr.status = e.response.code;
+      xhr.statusText = e.response.message;
+      _state.response = e.response;
+      if(xhr.onreadystatechange) {
+        xhr.onreadystatechange();
+      }
+      if(!_state.response.aborted) {
+        // now loading body
+        xhr.readyState = LOADING;
+        if(xhr.onreadystatechange) {
+           xhr.onreadystatechange();
+        }
+      }
+    };
+    options.bodyReady = function(e) {
+      xhr.readyState = DONE;
+      var ct = e.response.getField('Content-Type');
+      // Note: this null/undefined check is done outside because IE
+      // dies otherwise on a "'null' is null" error
+      if(ct) {
+        if(ct.indexOf('text/xml') === 0 ||
+          ct.indexOf('application/xml') === 0 ||
+          ct.indexOf('+xml') !== -1) {
+          try {
+            var doc = new ActiveXObject('MicrosoftXMLDOM');
+            doc.async = false;
+            doc.loadXML(e.response.body);
+            xhr.responseXML = doc;
+          } catch(ex) {
+            var parser = new DOMParser();
+            xhr.responseXML = parser.parseFromString(ex.body, 'text/xml');
+          }
+        }
+      }
+
+      var length = 0;
+      if(e.response.body !== null) {
+        xhr.responseText = e.response.body;
+        length = e.response.body.length;
+      }
+      // build logging output
+      var req = _state.request;
+      var output =
+        req.method + ' ' + req.path + ' ' +
+        xhr.status + ' ' + xhr.statusText + ' ' +
+        length + 'B ' +
+        (e.request.connectTime + e.request.time + e.response.time) +
+        'ms';
+      var lFunc;
+      if(options.verbose) {
+        lFunc = (xhr.status >= 400 && options.logWarningOnError) ?
+          _log.warning : _log.verbose;
+        lFunc(cat, output,
+          e, e.response.body ? '\n' + e.response.body : '\nNo content');
+      } else {
+        lFunc = (xhr.status >= 400 && options.logWarningOnError) ?
+          _log.warning : _log.debug;
+        lFunc(cat, output);
+      }
+      if(xhr.onreadystatechange) {
+        xhr.onreadystatechange();
+      }
+    };
+    options.error = function(e) {
+      var req = _state.request;
+      _log.error(cat, req.method + ' ' + req.path, e);
+
+      // 1. set response body to null
+      xhr.responseText = '';
+      xhr.responseXML = null;
+
+      // 2. set error flag to true (and reset status)
+      _state.errorFlag = true;
+      xhr.status = 0;
+      xhr.statusText = '';
+
+      // 3. set state to done
+      xhr.readyState = DONE;
+
+      // 4. asyc flag is always true, so dispatch onreadystatechange
+      if(xhr.onreadystatechange) {
+        xhr.onreadystatechange();
+      }
+    };
+
+    // 7. send request
+    _state.client.send(options);
+  };
+
+  /**
+   * Aborts the request.
+   */
+  xhr.abort = function() {
+    // 1. abort send
+    // 2. stop network activity
+    _state.request.abort();
+
+    // 3. set response to null
+    xhr.responseText = '';
+    xhr.responseXML = null;
+
+    // 4. set error flag to true (and reset status)
+    _state.errorFlag = true;
+    xhr.status = 0;
+    xhr.statusText = '';
+
+    // 5. clear user headers
+    _state.request = null;
+    _state.response = null;
+
+    // 6. if state is DONE or UNSENT, or if OPENED and send flag is false
+    if(xhr.readyState === DONE || xhr.readyState === UNSENT ||
+     (xhr.readyState === OPENED && !_state.sendFlag)) {
+      // 7. set ready state to unsent
+      xhr.readyState = UNSENT;
+    } else {
+      // 6.1 set state to DONE
+      xhr.readyState = DONE;
+
+      // 6.2 set send flag to false
+      _state.sendFlag = false;
+
+      // 6.3 dispatch onreadystatechange
+      if(xhr.onreadystatechange) {
+        xhr.onreadystatechange();
+      }
+
+      // 7. set state to UNSENT
+      xhr.readyState = UNSENT;
+    }
+  };
+
+  /**
+   * Gets all response headers as a string.
+   *
+   * @return the HTTP-encoded response header fields.
+   */
+  xhr.getAllResponseHeaders = function() {
+    var rval = '';
+    if(_state.response !== null) {
+      var fields = _state.response.fields;
+      $.each(fields, function(name, array) {
+        $.each(array, function(i, value) {
+          rval += name + ': ' + value + '\r\n';
+        });
+      });
+    }
+    return rval;
+  };
+
+  /**
+   * Gets a single header field value or, if there are multiple
+   * fields with the same name, a comma-separated list of header
+   * values.
+   *
+   * @return the header field value(s) or null.
+   */
+  xhr.getResponseHeader = function(header) {
+    var rval = null;
+    if(_state.response !== null) {
+      if(header in _state.response.fields) {
+        rval = _state.response.fields[header];
+        if(forge.util.isArray(rval)) {
+          rval = rval.join();
+        }
+      }
+    }
+    return rval;
+  };
+
+  return xhr;
+};
+
+// expose public api
+forge.xhr = xhrApi;
+
+})(jQuery);

http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/minify.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/minify.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/minify.js
new file mode 100644
index 0000000..36430a2
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/minify.js
@@ -0,0 +1,10 @@
+({
+  name: 'node_modules/almond/almond',
+  include: ['js/forge'],
+  out: 'js/forge.min.js',
+  wrap: {
+    startFile: 'start.frag',
+    endFile: 'end.frag'
+  },
+  preserveLicenseComments: false
+})

http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/mod_fsp/README
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/mod_fsp/README b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/mod_fsp/README
new file mode 100644
index 0000000..0331e01
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/mod_fsp/README
@@ -0,0 +1,135 @@
+=======
+mod_fsp
+=======
+
+mod_fsp is an Apache2 module for providing a Flash Socket Policy on the
+same port that HTTP is served. The cross-domain policy that is served is
+specified via a configuration option 'FSPPolicyFile'.
+
+If a flash application sends a policy file request to an Apache server
+that has enabled and configured the mod_fsp module over its HTTP port,
+then the configured cross-domain policy will be returned as the response.
+
+========
+Building
+========
+
+To build the mod_fsp source code you can use Apache2's module
+build and installation tool: 'apxs2' which is, at the time of
+this writing, available on debian in the package:
+
+apache2-threaded-dev
+
+To compile mod_fsp you would run the following command:
+
+apxs2 -c mod_fsp.c
+
+============
+Installation
+============
+
+To install mod_fsp you the following command as root:
+
+apxs2 -c -i -a mod_fsp.c
+
+You must then restart your apache2 process, typically like so:
+
+/etc/init.d/apache2 restart
+
+===================
+Manual Installation
+===================
+
+To manually enable mod_dsp on your Apache2 server, you must copy the
+module file to the appropriate directory and create a load file.
+
+The module file:
+
+fsp.so (The library extension may vary if you are not using linux).
+
+Must be copied to Apache's module installation directory which is
+typically located (on a debian system):
+
+/usr/lib/apache2/modules
+
+The load file:
+
+fsp.load
+
+Must be created in Apache2's 'mods-available' directory, typically
+located (on a debian system):
+
+/etc/apache2/mods-available
+
+The load file should contain:
+
+LoadModule fsp_module         /usr/lib/apache2/modules/mod_fsp.so
+
+If your Apache module installation directory is different from
+the one listed above, you will need to set the correct one in the
+fsp.load file.
+
+To actually enable the module you must create a symbolic link in
+Apache's 'mods-enabled' directory, typically located (on debian):
+
+/etc/apache2/mods-enabled
+
+By typing (from that directory):
+
+ln -s ../mods-available/fsp.load fsp.load
+
+=============
+Configuration
+=============
+
+Once mod_fsp is installed, it must be configured. There is currently
+only one configuration option for mod_fsp: 'FSPPolicyFile'. This
+configuration option will set the file that mod_fsp will look in
+on apache startup for the cross-domain policy to serve. This option
+can be provided on a per-port basis. Each port can use a different
+one, but VirtualServers on a single port will use the same one. This
+is a limitation of the design by Adobe.
+
+Note: The cross-domain policy may fail to be served if the configuration
+option isn't added in the first VirtualHost entry (for a given port) read
+by Apache.
+
+An example of this configuration in use:
+
+<VirtualHost *:80>
+   ServerName example.com
+   DocumentRoot /var/www/example.com
+   ErrorLog /var/log/apache2/example.com-error.log
+   CustomLog /var/log/apache2/example.com-access.log vhost_combined
+
+   # mod_fsp config option
+   FSPPolicyFile /etc/apache2/crossdomain/crossdomain.xml
+
+   <Directory /var/www/example.com>
+      Options Indexes FollowSymLinks MultiViews
+      AllowOverride All
+      Order allow,deny
+      allow from all
+   </Directory>
+
+</VirtualHost>
+
+And example of the most permissive cross-domain policy file for flash:
+
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE cross-domain-policy SYSTEM
+"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
+<cross-domain-policy>
+<site-control permitted-cross-domain-policies="all"/>
+<allow-access-from domain="*" to-ports="*"/>
+<allow-http-request-headers-from domain="*" headers="*"/>
+</cross-domain-policy>
+
+==================
+Note about SSL/TLS
+==================
+
+Flash currently has no built-in SSL/TLS support so there is no
+reason to specify an 'FSPPolicyFile' option for SSL servers. The
+Flash player cannot directly communicate with them when doing
+internal look ups of policy files.

http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/mod_fsp/mod_fsp.c
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/mod_fsp/mod_fsp.c b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/mod_fsp/mod_fsp.c
new file mode 100644
index 0000000..8beb824
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/mod_fsp/mod_fsp.c
@@ -0,0 +1,415 @@
+/**
+ * Flash Socket Policy Apache Module.
+ *
+ * This module provides a flash socket policy file on the same port that
+ * serves HTTP on Apache. This can help simplify setting up a server that
+ * supports cross-domain communication with flash.
+ *
+ * Quick note about Apache memory handling: Data is allocated from pools and
+ * is not manually returned to those pools. The pools are typically considered
+ * short-lived and will be cleaned up automatically by Apache.
+ *
+ * @author Dave Longley
+ *
+ * Copyright (c) 2010 Digital Bazaar, Inc. All rights reserved.
+ */
+#include "httpd.h"
+#include "http_config.h"
+#include "http_core.h"
+
+#include "ap_compat.h"
+
+#include <string.h>
+
+// length of a policy file request
+#define PFR_LENGTH 23
+
+// declare main module
+module AP_MODULE_DECLARE_DATA fsp_module;
+
+// configuration for the module
+typedef struct fsp_config
+{
+   // the cross-domain policy to serve
+   char* policy;
+   apr_size_t policy_length;
+} fsp_config;
+
+// filter state for keeping track of detected policy file requests
+typedef struct filter_state
+{
+   fsp_config* cfg;
+   int checked;
+   int found;
+} filter_state;
+
+// for registering hooks, filters, etc.
+static void fsp_register_hooks(apr_pool_t *p);
+static int fsp_pre_connection(conn_rec *c, void *csd);
+
+// filter handler declarations
+static apr_status_t fsp_input_filter(
+   ap_filter_t* f, apr_bucket_brigade* bb,
+	ap_input_mode_t mode, apr_read_type_e block, apr_off_t nbytes);
+static int fsp_output_filter(ap_filter_t* f, apr_bucket_brigade* bb);
+
+/**
+ * Registers the hooks for this module.
+ *
+ * @param p the pool to allocate from, if necessary.
+ */
+static void fsp_register_hooks(apr_pool_t* p)
+{
+   // registers the pre-connection hook to handle adding filters
+   ap_hook_pre_connection(
+      fsp_pre_connection, NULL, NULL, APR_HOOK_MIDDLE);
+
+   // will parse a policy file request, to be added in pre_connection
+   ap_register_input_filter(
+      "fsp_request", fsp_input_filter,
+      NULL, AP_FTYPE_CONNECTION);
+
+   // will emit a cross-domain policy response to be added in pre_connection
+   ap_register_output_filter(
+      "fsp_response", fsp_output_filter,
+      NULL, AP_FTYPE_CONNECTION);
+}
+
+/**
+ * A hook that is called before a connection is handled. This function will
+ * get the module configuration and add the flash socket policy filters if
+ * a cross-domain policy has been specified in the configuration.
+ *
+ * @param c the connection.
+ * @param csd the connection socket descriptor.
+ *
+ * @return OK on success.
+ */
+static int fsp_pre_connection(conn_rec* c, void* csd)
+{
+   // only install filters if a policy was specified in the module config
+   fsp_config* cfg = ap_get_module_config(
+      c->base_server->module_config, &fsp_module);
+   if(cfg->policy != NULL)
+   {
+      // allocate filter state
+      filter_state* state = apr_palloc(c->pool, sizeof(filter_state));
+      if(state != NULL)
+      {
+         // initialize state
+         state->cfg = cfg;
+         state->checked = state->found = 0;
+
+         // add filters
+         ap_add_input_filter("fsp_request", state, NULL, c);
+         ap_add_output_filter("fsp_response", state, NULL, c);
+      }
+   }
+
+   return OK;
+}
+
+/**
+ * Searches the input request for a flash socket policy request. This request,
+ * unfortunately, does not follow the HTTP protocol and cannot be handled
+ * via a special HTTP handler. Instead, it is a short xml string followed by
+ * a null character:
+ *
+ * '<policy-file-request/>\0'
+ *
+ * A peek into the incoming data checks the first character of the stream to
+ * see if it is '<' (as opposed to typically something else for HTTP). If it
+ * is not, then this function returns and HTTP input is read normally. If it
+ * is, then the remaining bytes in the policy-file-request are read and
+ * checked. If a match is found, then the filter state will be updated to
+ * inform the output filter to send a cross-domain policy as a response. If
+ * no match is found, HTTP traffic will proceed as usual.
+ *
+ * @param f the input filter.
+ * @param state the filter state.
+ *
+ * @return APR_SUCCESS on success, some other status on failure.
+ */
+static apr_status_t find_policy_file_request(
+   ap_filter_t* f, filter_state* state)
+{
+   apr_status_t rval = APR_SUCCESS;
+
+   // create a temp buffer for speculative reads
+   apr_bucket_brigade* tmp = apr_brigade_create(f->c->pool, f->c->bucket_alloc);
+
+   // FIXME: not sure how blocking mode works ... can it return fewer than
+   // the number of specified bytes?
+
+   // peek at the first PFR_LENGTH bytes
+   rval = ap_get_brigade(
+      f->next, tmp, AP_MODE_SPECULATIVE, APR_BLOCK_READ, PFR_LENGTH);
+   if(rval == APR_SUCCESS)
+   {
+      // quickly check the first bucket for the beginning of a pfr
+      const char* data;
+      apr_size_t length;
+      apr_bucket* b = APR_BRIGADE_FIRST(tmp);
+      rval = apr_bucket_read(b, &data, &length, APR_BLOCK_READ);
+      if(rval == APR_SUCCESS && length > 0 && data[0] == '<')
+      {
+         // possible policy file request, fill local buffer
+         char pfr[PFR_LENGTH];
+         char* ptr = pfr;
+         memcpy(ptr, data, length);
+         ptr += length;
+         memset(ptr, '\0', PFR_LENGTH - length);
+         b = APR_BUCKET_NEXT(b);
+         while(rval == APR_SUCCESS && b != APR_BRIGADE_SENTINEL(tmp))
+         {
+            rval = apr_bucket_read(b, &data, &length, APR_BLOCK_READ);
+            if(rval == APR_SUCCESS)
+            {
+               memcpy(ptr, data, length);
+               ptr += length;
+               b = APR_BUCKET_NEXT(b);
+            }
+         }
+
+         if(rval == APR_SUCCESS)
+         {
+            // see if pfr is a policy file request: '<policy-file-request/>\0'
+            if((ptr - pfr == PFR_LENGTH) && (pfr[PFR_LENGTH - 1] == '\0') &&
+               (strncmp(pfr, "<policy-file-request/>", PFR_LENGTH -1) == 0))
+            {
+               // pfr found
+               state->found = 1;
+            }
+         }
+      }
+   }
+
+   return rval;
+}
+
+/**
+ * Handles incoming data. If an attempt has not yet been made to look for
+ * a policy request (it is the beginning of the connection), then one is
+ * made. Otherwise this filter does nothing.
+ *
+ * If an attempt is made to find a policy request and one is not found, then
+ * reads proceed as normal. If one is found, then the filter state is modified
+ * to inform the output filter to send a policy request and the return value
+ * of this filter is EOF indicating that the connection should close after
+ * sending the cross-domain policy.
+ *
+ * @param f the input filter.
+ * @param bb the brigate to fill with input from the next filters in the chain
+ *           and then process (look for a policy file request).
+ * @param mode the type of read requested (ie: AP_MODE_GETLINE means read until
+ *           a CRLF is found, AP_MODE_GETBYTES means 'nbytes' of data, etc).
+ * @param block APR_BLOCK_READ or APR_NONBLOCK_READ, indicates the type of
+ *           blocking to do when trying to read.
+ * @param nbytes used if the read mode is appropriate to specify the number of
+ *           bytes to read (set to 0 for AP_MODE_GETLINE).
+ *
+ * @return the status of the input (ie: APR_SUCCESS for read success, APR_EOF
+ *         for end of stream, APR_EAGAIN to read again when non-blocking).
+ */
+static apr_status_t fsp_input_filter(
+   ap_filter_t* f, apr_bucket_brigade* bb,
+	ap_input_mode_t mode, apr_read_type_e block, apr_off_t nbytes)
+{
+   apr_status_t rval = APR_SUCCESS;
+
+   filter_state* state = f->ctx;
+   if(state->checked == 1)
+   {
+      // already checked for policy file request, just read from other filters
+      rval = ap_get_brigade(f->next, bb, mode, block, nbytes);
+   }
+   else
+   {
+      // try to find a policy file request
+      rval = find_policy_file_request(f, state);
+      state->checked = 1;
+
+      if(rval == APR_SUCCESS)
+      {
+         if(state->found)
+         {
+            // do read of PFR_LENGTH bytes, consider end of stream
+            rval = ap_get_brigade(
+               f->next, bb, AP_MODE_READBYTES, APR_BLOCK_READ, PFR_LENGTH);
+            rval = APR_EOF;
+         }
+         else
+         {
+            // do normal read
+            rval = ap_get_brigade(f->next, bb, mode, block, nbytes);
+         }
+      }
+   }
+
+   return rval;
+}
+
+/**
+ * Handles outgoing data. If the filter state indicates that a cross-domain
+ * policy should be sent then it is added to the outgoing brigade of data. If
+ * a policy request was not detected, then this filter makes no changes to
+ * the outgoing data.
+ *
+ * @param f the output filter.
+ * @param bb the outgoing brigade of data.
+ *
+ * @return APR_SUCCESS on success, some other status on error.
+ */
+static int fsp_output_filter(ap_filter_t* f, apr_bucket_brigade* bb)
+{
+   apr_status_t rval = APR_SUCCESS;
+
+   filter_state* state = f->ctx;
+   if(state->found)
+   {
+      // found policy-file-request, add response bucket
+      // bucket is immortal because the data is stored in the configuration
+      // and doesn't need to be copied
+      apr_bucket* head = apr_bucket_immortal_create(
+         state->cfg->policy, state->cfg->policy_length, bb->bucket_alloc);
+      APR_BRIGADE_INSERT_HEAD(bb, head);
+   }
+
+   if(rval == APR_SUCCESS)
+   {
+      // pass brigade to next filter
+      rval = ap_pass_brigade(f->next, bb);
+   }
+
+   return rval;
+}
+
+/**
+ * Creates the configuration for this module.
+ *
+ * @param p the pool to allocate from.
+ * @param s the server the configuration is for.
+ *
+ * @return the configuration data.
+ */
+static void* fsp_create_config(apr_pool_t* p, server_rec* s)
+{
+   // allocate config
+   fsp_config* cfg = apr_palloc(p, sizeof(fsp_config));
+
+   // no default policy
+   cfg->policy = NULL;
+   cfg->policy_length = 0;
+   return cfg;
+}
+
+/**
+ * Sets the policy file to use from the configuration.
+ *
+ * @param parms the command directive parameters.
+ * @param userdata NULL, not used.
+ * @param arg the string argument to the command directive (the file with
+ *           the cross-domain policy to serve as content).
+ *
+ * @return NULL on success, otherwise an error string to display.
+ */
+static const char* fsp_set_policy_file(
+   cmd_parms* parms, void* userdata, const char* arg)
+{
+   const char* rval = NULL;
+
+   apr_pool_t* pool = (apr_pool_t*)parms->pool;
+   fsp_config* cfg = ap_get_module_config(
+      parms->server->module_config, &fsp_module);
+
+   // ensure command is in the correct context
+   rval = ap_check_cmd_context(parms, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);
+   if(rval == NULL)
+   {
+      // get canonical file name
+      char* fname = ap_server_root_relative(pool, arg);
+      if(fname == NULL)
+      {
+         rval = (const char*)apr_psprintf(
+            pool, "%s: Invalid policy file '%s'",
+            parms->cmd->name, arg);
+      }
+      else
+      {
+         // try to open the file
+         apr_status_t rv;
+         apr_file_t* fd;
+         apr_finfo_t finfo;
+         rv = apr_file_open(&fd, fname, APR_READ, APR_OS_DEFAULT, pool);
+         if(rv == APR_SUCCESS)
+         {
+            // stat file
+            rv = apr_file_info_get(&finfo, APR_FINFO_NORM, fd);
+            if(rv == APR_SUCCESS)
+            {
+               // ensure file is not empty
+               apr_size_t length = (apr_size_t)finfo.size;
+               if(length <= 0)
+               {
+                  rval = (const char*)apr_psprintf(
+                     pool, "%s: policy file '%s' is empty",
+                     parms->cmd->name, fname);
+               }
+               // read file
+               else
+               {
+                  char* buf = (char*)apr_palloc(pool, length + 1);
+                  buf[length] = '\0';
+                  rv = apr_file_read_full(fd, buf, length, NULL);
+                  if(rv == APR_SUCCESS)
+                  {
+                     // TODO: validate file
+                     // save policy string
+                     cfg->policy = buf;
+                     cfg->policy_length = length + 1;
+                  }
+               }
+
+               // close the file
+               apr_file_close(fd);
+            }
+         }
+
+         // handle error case
+         if(rv != APR_SUCCESS)
+         {
+            char errmsg[120];
+            rval = (const char*)apr_psprintf(
+               pool, "%s: Invalid policy file '%s' (%s)",
+               parms->cmd->name, fname,
+               apr_strerror(rv, errmsg, sizeof(errmsg)));
+         }
+      }
+   }
+
+   return rval;
+}
+
+// table of configuration directives
+static const command_rec fsp_cmds[] =
+{
+   AP_INIT_TAKE1(
+      "FSPPolicyFile", /* the directive */
+      fsp_set_policy_file, /* function to call when directive is found */
+      NULL, /* user data to pass to function, not used */
+      RSRC_CONF, /* indicates the directive appears outside of <Location> */
+      "FSPPolicyFile (string) The cross-domain policy file to use"), /* docs */
+   {NULL}
+};
+
+// module setup
+module AP_MODULE_DECLARE_DATA fsp_module =
+{
+    STANDARD20_MODULE_STUFF,    /* stuff declared in every 2.0 mod       */
+    NULL,                       /* create per-directory config structure */
+    NULL,                       /* merge per-directory config structures */
+    fsp_create_config,          /* create per-server config structure    */
+    NULL,                       /* merge per-server config structures    */
+    fsp_cmds,                   /* command apr_table_t                   */
+    fsp_register_hooks          /* register hooks                        */
+};

http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/README.md
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/README.md b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/README.md
new file mode 100644
index 0000000..1be00fa
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/README.md
@@ -0,0 +1,34 @@
+Running all the tests (headless-browser and node.js)
+====================================================
+
+    npm install
+    npm test
+
+Running the browser-based tests
+===============================
+
+    npm install
+    node server.js
+
+Then go to http://localhost:8083/.
+
+Testing Require.js optimised version of the JavaScript
+------------------------------------------------------
+
+    npm install -g requirejs
+    r.js -o build.js
+
+You will now have a single optimised JS file at ui/test.min.js, containing the
+tests and all the forge dependencies.
+
+Now edit ui/index.html and change `data-main="test"` to `data-main="test.min"`,
+then reload http://localhost:8083/.
+
+Building a minimized single file for all forge modules
+------------------------------------------------------
+
+    npm install -g requirejs
+    r.js -o minify.js
+
+You will now have forge.min.js, in the 'js' directory, which will contain all
+forge modules.

http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/build.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/build.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/build.js
new file mode 100644
index 0000000..30ba7b5
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/build.js
@@ -0,0 +1,8 @@
+({
+    paths: {
+        forge: '../js'
+    },
+    name: 'ui/test.js',
+    out: 'ui/test.min.js',
+    preserveLicenseComments: false
+})

http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/minify.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/minify.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/minify.js
new file mode 100644
index 0000000..69d96a9
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/minify.js
@@ -0,0 +1,8 @@
+({
+    paths: {
+        forge: '../js'
+    },
+    name: '../js/forge',
+    out: '../js/forge.min.js',
+    preserveLicenseComments: false
+})

http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/package.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/package.json b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/package.json
new file mode 100644
index 0000000..f60f52a
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/package.json
@@ -0,0 +1,17 @@
+{
+    "name": "forge-nodejs-example",
+    "version": "0.1.0",
+    "private": true,
+    "main": "server.js",
+    "dependencies": {
+        "express": "~3.1.0",
+        "mocha": "~1.8.2",
+        "chai": "~1.5.0",
+        "grunt": "~0.4.1",
+        "grunt-mocha": "~0.3.1"
+    },
+    "scripts": {
+        "test": "mocha -t 20000 -R spec test/*.js",
+        "run": "node server"
+    }
+}

http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/server.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/server.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/server.js
new file mode 100644
index 0000000..175bd56
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/server.js
@@ -0,0 +1,46 @@
+var PATH = require('path');
+var express = require('express');
+var PORT = 8083;
+
+exports.main = function(callback) {
+  try {
+    var app = express();
+
+    mountStaticDir(app, /^\/forge\/(.*)$/, PATH.join(__dirname, '../js'));
+    mountStaticDir(app, /^\/test\/(.*)$/, PATH.join(__dirname, 'test'));
+    mountStaticDir(app, /^\/mocha\/(.*)$/, PATH.join(__dirname, 'node_modules/mocha'));
+    mountStaticDir(app, /^\/chai\/(.*)$/, PATH.join(__dirname, 'node_modules/chai'));
+    app.get(/^\//, express.static(PATH.join(__dirname, 'ui')));
+
+    var server = app.listen(PORT);
+
+    console.log('open http://localhost:' + PORT + '/');
+
+    return callback(null, {
+      server: server,
+      port: PORT
+    });
+  } catch(err) {
+    return callback(err);
+  }
+};
+
+function mountStaticDir(app, route, path) {
+  app.get(route, function(req, res, next) {
+    var originalUrl = req.url;
+    req.url = req.params[0];
+    express.static(path)(req, res, function() {
+      req.url = originalUrl;
+      return next.apply(null, arguments);
+    });
+  });
+}
+
+if(require.main === module) {
+  exports.main(function(err) {
+    if(err) {
+      console.error(err.stack);
+      process.exit(1);
+    }
+  });
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message