debian-mirror-gitlab/spec/frontend/u2f/mock_u2f_device.js
2020-04-22 19:07:51 +05:30

23 lines
732 B
JavaScript

/* eslint-disable no-unused-expressions */
export default class MockU2FDevice {
constructor() {
this.respondToAuthenticateRequest = this.respondToAuthenticateRequest.bind(this);
this.respondToRegisterRequest = this.respondToRegisterRequest.bind(this);
window.u2f || (window.u2f = {});
window.u2f.register = (appId, registerRequests, signRequests, callback) => {
this.registerCallback = callback;
};
window.u2f.sign = (appId, challenges, signRequests, callback) => {
this.authenticateCallback = callback;
};
}
respondToRegisterRequest(params) {
return this.registerCallback(params);
}
respondToAuthenticateRequest(params) {
return this.authenticateCallback(params);
}
}