mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-08 20:58:24 +08:00
This patch adds a credential table to each authenticator. Design Doc: https://docs.google.com/document/d/1A-cn0rxuHHAyGhywayk7xcTqSsR2X7va6H4kSMThOoY Bug: 1034663 Change-Id: I1214a6cd7e04834552545a069b6ac5c42f413312 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2332318 Commit-Queue: Nina Satragno <nsatragno@chromium.org> Reviewed-by: Jan Scheffler <janscheffler@chromium.org> Reviewed-by: Nina Satragno <nsatragno@chromium.org>
70 lines
2.0 KiB
JavaScript
70 lines
2.0 KiB
JavaScript
// Copyright 2020 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import {Capability, SDKModel, Target} from './SDKModel.js'; // eslint-disable-line no-unused-vars
|
|
|
|
export class WebAuthnModel extends SDKModel {
|
|
/**
|
|
* @param {!Target} target
|
|
*/
|
|
constructor(target) {
|
|
super(target);
|
|
this._agent = target.webAuthnAgent();
|
|
}
|
|
|
|
/**
|
|
* @param {boolean} enable
|
|
* @return {!Promise<!Object>}
|
|
*/
|
|
setVirtualAuthEnvEnabled(enable) {
|
|
if (enable) {
|
|
return this._agent.invoke_enable();
|
|
}
|
|
return this._agent.invoke_disable();
|
|
}
|
|
|
|
/**
|
|
* @param {!Protocol.WebAuthn.VirtualAuthenticatorOptions} options
|
|
* @return {!Promise<!Protocol.WebAuthn.AuthenticatorId>}
|
|
*/
|
|
async addAuthenticator(options) {
|
|
const response = await this._agent.invoke_addVirtualAuthenticator({options});
|
|
return response.authenticatorId;
|
|
}
|
|
|
|
/**
|
|
* @param {!Protocol.WebAuthn.AuthenticatorId} authenticatorId
|
|
*/
|
|
async removeAuthenticator(authenticatorId) {
|
|
await this._agent.invoke_removeVirtualAuthenticator({authenticatorId});
|
|
}
|
|
|
|
/**
|
|
* @param {!Protocol.WebAuthn.AuthenticatorId} authenticatorId
|
|
* @param {boolean} enabled
|
|
*/
|
|
async setAutomaticPresenceSimulation(authenticatorId, enabled) {
|
|
await this._agent.invoke_setAutomaticPresenceSimulation({authenticatorId, enabled});
|
|
}
|
|
|
|
/**
|
|
* @param {!Protocol.WebAuthn.AuthenticatorId} authenticatorId
|
|
* @return {!Promise<!Array<!Protocol.WebAuthn.Credential>>}
|
|
*/
|
|
async getCredentials(authenticatorId) {
|
|
const response = await this._agent.invoke_getCredentials({authenticatorId});
|
|
return response.credentials;
|
|
}
|
|
|
|
/**
|
|
* @param {!Protocol.WebAuthn.AuthenticatorId} authenticatorId
|
|
* @param {string} credentialId
|
|
*/
|
|
async removeCredential(authenticatorId, credentialId) {
|
|
await this._agent.invoke_removeCredential({authenticatorId, credentialId});
|
|
}
|
|
}
|
|
|
|
SDKModel.register(WebAuthnModel, Capability.WebAuthn, false);
|