BigW Consortium Gitlab

mock_u2f_device.js 929 Bytes
Newer Older
1 2
/* eslint-disable prefer-rest-params, wrap-iife,
no-unused-expressions, no-return-assign, no-param-reassign*/
3

4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
export default class MockU2FDevice {
  constructor() {
    this.respondToAuthenticateRequest = this.respondToAuthenticateRequest.bind(this);
    this.respondToRegisterRequest = this.respondToRegisterRequest.bind(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);
  }
Fatih Acet committed
20

21 22 23
  respondToRegisterRequest(params) {
    return this.registerCallback(params);
  }
Fatih Acet committed
24

25 26 27 28
  respondToAuthenticateRequest(params) {
    return this.authenticateCallback(params);
  }
}