import { HttpMiddleware } from 'kinvey-html5-sdk/dist/middleware';
import pkg from 'package.json';

// Helper function to detect the browser name and version.
function browserDetect(ua) {
  // Cast arguments.
  ua = ua.toLowerCase();

  // User-Agent patterns.
  const rChrome = /(chrome)\/([\w]+)/;
  const rFirefox = /(firefox)\/([\w.]+)/;
  const rIE = /(msie) ([\w.]+)/i;
  const rOpera = /(opera)(?:.*version)?[ /]([\w.]+)/;
  const rSafari = /(safari)\/([\w.]+)/;

  return rChrome.exec(ua) || rFirefox.exec(ua) || rIE.exec(ua) ||
    rOpera.exec(ua) || rSafari.exec(ua) || [];
}

export function deviceInformation() {
  const libraries = [];
  let browser;
  let platform;
  let version;
  let manufacturer;
  let id;

  if (global.cordova !== undefined && global.device !== undefined) { // PhoneGap
    const device = global.device;
    libraries.push(`phonegap/${device.cordova}`);
    platform = device.platform;
    version = device.version;
    manufacturer = device.model;
    id = device.uuid;
  }

  // Default platform, most likely this is just a plain web app.
  if ((platform === null || platform === undefined) && global.navigator) {
    browser = browserDetect(global.navigator.userAgent);
    platform = browser[1];
    version = browser[2];
    manufacturer = global.navigator.platform;
  }

  // Libraries.
  if (global.angular !== undefined) { // AngularJS.
    libraries.push(`angularjs/${global.angular.version.full}`);
  }
  if (global.Backbone !== undefined) { // Backbone.js.
    libraries.push(`backbonejs/${global.Backbone.VERSION}`);
  }
  if (global.Ember !== undefined) { // Ember.js.
    libraries.push(`emberjs/${global.Ember.VERSION}`);
  }
  if (global.jQuery !== undefined) { // jQuery.
    libraries.push(`jquery/${global.jQuery.fn.jquery}`);
  }
  if (global.ko !== undefined) { // Knockout.
    libraries.push(`knockout/${global.ko.version}`);
  }
  if (global.Zepto !== undefined) { // Zepto.js.
    libraries.push('zeptojs');
  }

  // Return the device information string.
  const parts = [`js-${pkg.name}/${pkg.version}`];

  if (libraries.length !== 0) { // Add external library information.
    parts.push(`(${libraries.sort().join(', ')})`);
  }

  return parts.concat([platform, version, manufacturer, id]).map((part) => {
    if (part) {
      return part.toString().replace(/\s/g, '_').toLowerCase();
    }

    return 'unknown';
  }).join(' ');
}

export default class PhoneGapHttpMiddleware extends HttpMiddleware {
  get deviceInformation() {
    return deviceInformation();
  }
}

@@ -17,16 +17,39 @@
 dleware 
+as HTML5HttpMiddleware 
 %7D from '
@@ -2438,24 +2438,16 @@
 t class 
-PhoneGap
 HttpMidd
@@ -2461,16 +2461,21 @@
 extends 
+HTML5
 HttpMidd

Update HttpMiddleware