BigW Consortium Gitlab

mock_u2f_device.js 1.26 KB
Newer Older
1
/* eslint-disable space-before-function-paren, no-var, space-before-blocks, prefer-rest-params, wrap-iife, no-unused-expressions, no-return-assign, no-param-reassign, padded-blocks, max-len */
Fatih Acet committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
(function() {
  var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };

  this.MockU2FDevice = (function() {
    function MockU2FDevice() {
      this.respondToAuthenticateRequest = bind(this.respondToAuthenticateRequest, this);
      this.respondToRegisterRequest = bind(this.respondToRegisterRequest, this);
      window.u2f || (window.u2f = {});
      window.u2f.register = (function(_this) {
        return function(appId, registerRequests, signRequests, callback) {
          return _this.registerCallback = callback;
        };
      })(this);
      window.u2f.sign = (function(_this) {
        return function(appId, challenges, signRequests, callback) {
          return _this.authenticateCallback = callback;
        };
      })(this);
    }

    MockU2FDevice.prototype.respondToRegisterRequest = function(params) {
      return this.registerCallback(params);
    };

    MockU2FDevice.prototype.respondToAuthenticateRequest = function(params) {
      return this.authenticateCallback(params);
    };

    return MockU2FDevice;

  })();

}).call(this);