debian-mirror-gitlab/spec/frontend/authentication/webauthn/mock_webauthn_device.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-11-24 15:15:51 +05:30
/* eslint-disable no-unused-expressions */
export default class MockWebAuthnDevice {
constructor() {
this.respondToAuthenticateRequest = this.respondToAuthenticateRequest.bind(this);
this.respondToRegisterRequest = this.respondToRegisterRequest.bind(this);
window.navigator.credentials || (window.navigator.credentials = {});
window.navigator.credentials.create = () =>
new Promise((resolve, reject) => {
this.registerCallback = resolve;
this.registerRejectCallback = reject;
});
window.navigator.credentials.get = () =>
new Promise((resolve, reject) => {
this.authenticateCallback = resolve;
this.authenticateRejectCallback = reject;
});
}
respondToRegisterRequest(params) {
return this.registerCallback(params);
}
respondToAuthenticateRequest(params) {
return this.authenticateCallback(params);
}
rejectRegisterRequest(params) {
return this.registerRejectCallback(params);
}
rejectAuthenticateRequest(params) {
return this.authenticateRejectCallback(params);
}
}