navigatorinfo.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright 2018 Scytl Secure Electronic Voting SA
  3. *
  4. * All rights reserved
  5. *
  6. * See our extended copyright notice in *file 'Copyright.txt' which is part of this source code package
  7. */
  8. /* jshint node:true */
  9. 'use strict';
  10. module.exports = NavigatorInfoCollector;
  11. var collectEntropy_ = function() {};
  12. function NavigatorInfoCollector(collectEntropyCallback) {
  13. collectEntropy_ = collectEntropyCallback;
  14. }
  15. NavigatorInfoCollector.prototype = {
  16. startCollector: function() {
  17. if (typeof(navigator) !== 'undefined') {
  18. var _navString = '';
  19. for (var key in navigator) {
  20. if (typeof key !== 'undefined') {
  21. try {
  22. if (typeof(navigator[key]) === 'string') {
  23. _navString += navigator[key];
  24. }
  25. } catch (e) {
  26. // ignore any kind of exception
  27. }
  28. }
  29. }
  30. collectEntropy_(_navString, 1);
  31. }
  32. },
  33. stopCollector: function() {
  34. // just executed once, so no need to execute anything else
  35. return true;
  36. }
  37. };