chrome-devtools-frontend
Version:
Chrome DevTools UI
105 lines (83 loc) • 3.85 kB
text/typescript
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import type * as ProtocolProxyApi from '../../generated/protocol-proxy-api.js';
import type * as Protocol from '../../generated/protocol.js';
import {SDKModel} from './SDKModel.js';
import {Capability, type Target} from './Target.js';
export const enum Events {
CREDENTIAL_ADDED = 'CredentialAdded',
CREDENTIAL_ASSERTED = 'CredentialAsserted',
CREDENTIAL_DELETED = 'CredentialDeleted',
CREDENTIAL_UPDATED = 'CredentialUpdated',
}
export interface EventTypes {
[]: Protocol.WebAuthn.CredentialAddedEvent;
[]: Protocol.WebAuthn.CredentialAssertedEvent;
[]: Protocol.WebAuthn.CredentialDeletedEvent;
[]: Protocol.WebAuthn.CredentialUpdatedEvent;
}
export class WebAuthnModel extends SDKModel<EventTypes> {
readonly
constructor(target: Target) {
super(target);
this.
target.registerWebAuthnDispatcher(new WebAuthnDispatcher(this));
}
setVirtualAuthEnvEnabled(enable: boolean): Promise<Object> {
if (enable) {
return this.
}
return this.
}
async addAuthenticator(options: Protocol.WebAuthn.VirtualAuthenticatorOptions):
Promise<Protocol.WebAuthn.AuthenticatorId> {
const response = await this.
return response.authenticatorId;
}
async removeAuthenticator(authenticatorId: Protocol.WebAuthn.AuthenticatorId): Promise<void> {
await this.
}
async setAutomaticPresenceSimulation(authenticatorId: Protocol.WebAuthn.AuthenticatorId, enabled: boolean):
Promise<void> {
await this.
}
async getCredentials(authenticatorId: Protocol.WebAuthn.AuthenticatorId): Promise<Protocol.WebAuthn.Credential[]> {
const response = await this.
return response.credentials;
}
async removeCredential(authenticatorId: Protocol.WebAuthn.AuthenticatorId, credentialId: string): Promise<void> {
await this.
}
credentialAdded(params: Protocol.WebAuthn.CredentialAddedEvent): void {
this.dispatchEventToListeners(Events.CREDENTIAL_ADDED, params);
}
credentialAsserted(params: Protocol.WebAuthn.CredentialAssertedEvent): void {
this.dispatchEventToListeners(Events.CREDENTIAL_ASSERTED, params);
}
credentialDeleted(params: Protocol.WebAuthn.CredentialDeletedEvent): void {
this.dispatchEventToListeners(Events.CREDENTIAL_DELETED, params);
}
credentialUpdated(params: Protocol.WebAuthn.CredentialUpdatedEvent): void {
this.dispatchEventToListeners(Events.CREDENTIAL_UPDATED, params);
}
}
class WebAuthnDispatcher implements ProtocolProxyApi.WebAuthnDispatcher {
readonly
constructor(model: WebAuthnModel) {
this.
}
credentialAdded(params: Protocol.WebAuthn.CredentialAddedEvent): void {
this.
}
credentialAsserted(params: Protocol.WebAuthn.CredentialAssertedEvent): void {
this.
}
credentialDeleted(params: Protocol.WebAuthn.CredentialDeletedEvent): void {
this.
}
credentialUpdated(params: Protocol.WebAuthn.CredentialUpdatedEvent): void {
this.
}
}
SDKModel.register(WebAuthnModel, {capabilities: Capability.WEB_AUTHN, autostart: false});