Welcome to mirror list, hosted at ThFree Co, Russian Federation.

mock_webauthn_device.js « webauthn « authentication « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 39df94df46b777f6b56c77f394391526c91d6b84 (plain)
1
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
35
/* 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);
  }
}