Add cdp support for xpath scrapers (#625)

Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
bnkai
2020-08-04 03:42:40 +03:00
committed by GitHub
parent 1b4a9eed36
commit 4373f9bf01
284 changed files with 133250 additions and 54 deletions

1170
vendor/github.com/chromedp/cdproto/webauthn/easyjson.go generated vendored Normal file

File diff suppressed because it is too large Load Diff

142
vendor/github.com/chromedp/cdproto/webauthn/types.go generated vendored Normal file
View File

@@ -0,0 +1,142 @@
package webauthn
// Code generated by cdproto-gen. DO NOT EDIT.
import (
"errors"
"github.com/mailru/easyjson"
"github.com/mailru/easyjson/jlexer"
"github.com/mailru/easyjson/jwriter"
)
// AuthenticatorID [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAuthn#type-AuthenticatorId
type AuthenticatorID string
// String returns the AuthenticatorID as string value.
func (t AuthenticatorID) String() string {
return string(t)
}
// AuthenticatorProtocol [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAuthn#type-AuthenticatorProtocol
type AuthenticatorProtocol string
// String returns the AuthenticatorProtocol as string value.
func (t AuthenticatorProtocol) String() string {
return string(t)
}
// AuthenticatorProtocol values.
const (
AuthenticatorProtocolU2f AuthenticatorProtocol = "u2f"
AuthenticatorProtocolCtap2 AuthenticatorProtocol = "ctap2"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t AuthenticatorProtocol) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t AuthenticatorProtocol) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *AuthenticatorProtocol) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch AuthenticatorProtocol(in.String()) {
case AuthenticatorProtocolU2f:
*t = AuthenticatorProtocolU2f
case AuthenticatorProtocolCtap2:
*t = AuthenticatorProtocolCtap2
default:
in.AddError(errors.New("unknown AuthenticatorProtocol value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *AuthenticatorProtocol) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// AuthenticatorTransport [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAuthn#type-AuthenticatorTransport
type AuthenticatorTransport string
// String returns the AuthenticatorTransport as string value.
func (t AuthenticatorTransport) String() string {
return string(t)
}
// AuthenticatorTransport values.
const (
AuthenticatorTransportUsb AuthenticatorTransport = "usb"
AuthenticatorTransportNfc AuthenticatorTransport = "nfc"
AuthenticatorTransportBle AuthenticatorTransport = "ble"
AuthenticatorTransportCable AuthenticatorTransport = "cable"
AuthenticatorTransportInternal AuthenticatorTransport = "internal"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t AuthenticatorTransport) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t AuthenticatorTransport) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *AuthenticatorTransport) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch AuthenticatorTransport(in.String()) {
case AuthenticatorTransportUsb:
*t = AuthenticatorTransportUsb
case AuthenticatorTransportNfc:
*t = AuthenticatorTransportNfc
case AuthenticatorTransportBle:
*t = AuthenticatorTransportBle
case AuthenticatorTransportCable:
*t = AuthenticatorTransportCable
case AuthenticatorTransportInternal:
*t = AuthenticatorTransportInternal
default:
in.AddError(errors.New("unknown AuthenticatorTransport value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *AuthenticatorTransport) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// VirtualAuthenticatorOptions [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAuthn#type-VirtualAuthenticatorOptions
type VirtualAuthenticatorOptions struct {
Protocol AuthenticatorProtocol `json:"protocol"`
Transport AuthenticatorTransport `json:"transport"`
HasResidentKey bool `json:"hasResidentKey,omitempty"` // Defaults to false.
HasUserVerification bool `json:"hasUserVerification,omitempty"` // Defaults to false.
AutomaticPresenceSimulation bool `json:"automaticPresenceSimulation,omitempty"` // If set to true, tests of user presence will succeed immediately. Otherwise, they will not be resolved. Defaults to true.
IsUserVerified bool `json:"isUserVerified,omitempty"` // Sets whether User Verification succeeds or fails for an authenticator. Defaults to false.
}
// Credential [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAuthn#type-Credential
type Credential struct {
CredentialID string `json:"credentialId"`
IsResidentCredential bool `json:"isResidentCredential"`
RpID string `json:"rpId,omitempty"` // Relying Party ID the credential is scoped to. Must be set when adding a credential.
PrivateKey string `json:"privateKey"` // The ECDSA P-256 private key in PKCS#8 format.
UserHandle string `json:"userHandle,omitempty"` // An opaque byte sequence with a maximum size of 64 bytes mapping the credential to a specific user.
SignCount int64 `json:"signCount"` // Signature counter. This is incremented by one for each successful assertion. See https://w3c.github.io/webauthn/#signature-counter
}

302
vendor/github.com/chromedp/cdproto/webauthn/webauthn.go generated vendored Normal file
View File

@@ -0,0 +1,302 @@
// Package webauthn provides the Chrome DevTools Protocol
// commands, types, and events for the WebAuthn domain.
//
// This domain allows configuring virtual authenticators to test the WebAuthn
// API.
//
// Generated by the cdproto-gen command.
package webauthn
// Code generated by cdproto-gen. DO NOT EDIT.
import (
"context"
"github.com/chromedp/cdproto/cdp"
)
// EnableParams enable the WebAuthn domain and start intercepting credential
// storage and retrieval with a virtual authenticator.
type EnableParams struct{}
// Enable enable the WebAuthn domain and start intercepting credential
// storage and retrieval with a virtual authenticator.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAuthn#method-enable
func Enable() *EnableParams {
return &EnableParams{}
}
// Do executes WebAuthn.enable against the provided context.
func (p *EnableParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandEnable, nil, nil)
}
// DisableParams disable the WebAuthn domain.
type DisableParams struct{}
// Disable disable the WebAuthn domain.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAuthn#method-disable
func Disable() *DisableParams {
return &DisableParams{}
}
// Do executes WebAuthn.disable against the provided context.
func (p *DisableParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandDisable, nil, nil)
}
// AddVirtualAuthenticatorParams creates and adds a virtual authenticator.
type AddVirtualAuthenticatorParams struct {
Options *VirtualAuthenticatorOptions `json:"options"`
}
// AddVirtualAuthenticator creates and adds a virtual authenticator.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAuthn#method-addVirtualAuthenticator
//
// parameters:
// options
func AddVirtualAuthenticator(options *VirtualAuthenticatorOptions) *AddVirtualAuthenticatorParams {
return &AddVirtualAuthenticatorParams{
Options: options,
}
}
// AddVirtualAuthenticatorReturns return values.
type AddVirtualAuthenticatorReturns struct {
AuthenticatorID AuthenticatorID `json:"authenticatorId,omitempty"`
}
// Do executes WebAuthn.addVirtualAuthenticator against the provided context.
//
// returns:
// authenticatorID
func (p *AddVirtualAuthenticatorParams) Do(ctx context.Context) (authenticatorID AuthenticatorID, err error) {
// execute
var res AddVirtualAuthenticatorReturns
err = cdp.Execute(ctx, CommandAddVirtualAuthenticator, p, &res)
if err != nil {
return "", err
}
return res.AuthenticatorID, nil
}
// RemoveVirtualAuthenticatorParams removes the given authenticator.
type RemoveVirtualAuthenticatorParams struct {
AuthenticatorID AuthenticatorID `json:"authenticatorId"`
}
// RemoveVirtualAuthenticator removes the given authenticator.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAuthn#method-removeVirtualAuthenticator
//
// parameters:
// authenticatorID
func RemoveVirtualAuthenticator(authenticatorID AuthenticatorID) *RemoveVirtualAuthenticatorParams {
return &RemoveVirtualAuthenticatorParams{
AuthenticatorID: authenticatorID,
}
}
// Do executes WebAuthn.removeVirtualAuthenticator against the provided context.
func (p *RemoveVirtualAuthenticatorParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandRemoveVirtualAuthenticator, p, nil)
}
// AddCredentialParams adds the credential to the specified authenticator.
type AddCredentialParams struct {
AuthenticatorID AuthenticatorID `json:"authenticatorId"`
Credential *Credential `json:"credential"`
}
// AddCredential adds the credential to the specified authenticator.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAuthn#method-addCredential
//
// parameters:
// authenticatorID
// credential
func AddCredential(authenticatorID AuthenticatorID, credential *Credential) *AddCredentialParams {
return &AddCredentialParams{
AuthenticatorID: authenticatorID,
Credential: credential,
}
}
// Do executes WebAuthn.addCredential against the provided context.
func (p *AddCredentialParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandAddCredential, p, nil)
}
// GetCredentialParams returns a single credential stored in the given
// virtual authenticator that matches the credential ID.
type GetCredentialParams struct {
AuthenticatorID AuthenticatorID `json:"authenticatorId"`
CredentialID string `json:"credentialId"`
}
// GetCredential returns a single credential stored in the given virtual
// authenticator that matches the credential ID.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAuthn#method-getCredential
//
// parameters:
// authenticatorID
// credentialID
func GetCredential(authenticatorID AuthenticatorID, credentialID string) *GetCredentialParams {
return &GetCredentialParams{
AuthenticatorID: authenticatorID,
CredentialID: credentialID,
}
}
// GetCredentialReturns return values.
type GetCredentialReturns struct {
Credential *Credential `json:"credential,omitempty"`
}
// Do executes WebAuthn.getCredential against the provided context.
//
// returns:
// credential
func (p *GetCredentialParams) Do(ctx context.Context) (credential *Credential, err error) {
// execute
var res GetCredentialReturns
err = cdp.Execute(ctx, CommandGetCredential, p, &res)
if err != nil {
return nil, err
}
return res.Credential, nil
}
// GetCredentialsParams returns all the credentials stored in the given
// virtual authenticator.
type GetCredentialsParams struct {
AuthenticatorID AuthenticatorID `json:"authenticatorId"`
}
// GetCredentials returns all the credentials stored in the given virtual
// authenticator.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAuthn#method-getCredentials
//
// parameters:
// authenticatorID
func GetCredentials(authenticatorID AuthenticatorID) *GetCredentialsParams {
return &GetCredentialsParams{
AuthenticatorID: authenticatorID,
}
}
// GetCredentialsReturns return values.
type GetCredentialsReturns struct {
Credentials []*Credential `json:"credentials,omitempty"`
}
// Do executes WebAuthn.getCredentials against the provided context.
//
// returns:
// credentials
func (p *GetCredentialsParams) Do(ctx context.Context) (credentials []*Credential, err error) {
// execute
var res GetCredentialsReturns
err = cdp.Execute(ctx, CommandGetCredentials, p, &res)
if err != nil {
return nil, err
}
return res.Credentials, nil
}
// RemoveCredentialParams removes a credential from the authenticator.
type RemoveCredentialParams struct {
AuthenticatorID AuthenticatorID `json:"authenticatorId"`
CredentialID string `json:"credentialId"`
}
// RemoveCredential removes a credential from the authenticator.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAuthn#method-removeCredential
//
// parameters:
// authenticatorID
// credentialID
func RemoveCredential(authenticatorID AuthenticatorID, credentialID string) *RemoveCredentialParams {
return &RemoveCredentialParams{
AuthenticatorID: authenticatorID,
CredentialID: credentialID,
}
}
// Do executes WebAuthn.removeCredential against the provided context.
func (p *RemoveCredentialParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandRemoveCredential, p, nil)
}
// ClearCredentialsParams clears all the credentials from the specified
// device.
type ClearCredentialsParams struct {
AuthenticatorID AuthenticatorID `json:"authenticatorId"`
}
// ClearCredentials clears all the credentials from the specified device.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAuthn#method-clearCredentials
//
// parameters:
// authenticatorID
func ClearCredentials(authenticatorID AuthenticatorID) *ClearCredentialsParams {
return &ClearCredentialsParams{
AuthenticatorID: authenticatorID,
}
}
// Do executes WebAuthn.clearCredentials against the provided context.
func (p *ClearCredentialsParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandClearCredentials, p, nil)
}
// SetUserVerifiedParams sets whether User Verification succeeds or fails for
// an authenticator. The default is true.
type SetUserVerifiedParams struct {
AuthenticatorID AuthenticatorID `json:"authenticatorId"`
IsUserVerified bool `json:"isUserVerified"`
}
// SetUserVerified sets whether User Verification succeeds or fails for an
// authenticator. The default is true.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAuthn#method-setUserVerified
//
// parameters:
// authenticatorID
// isUserVerified
func SetUserVerified(authenticatorID AuthenticatorID, isUserVerified bool) *SetUserVerifiedParams {
return &SetUserVerifiedParams{
AuthenticatorID: authenticatorID,
IsUserVerified: isUserVerified,
}
}
// Do executes WebAuthn.setUserVerified against the provided context.
func (p *SetUserVerifiedParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetUserVerified, p, nil)
}
// Command names.
const (
CommandEnable = "WebAuthn.enable"
CommandDisable = "WebAuthn.disable"
CommandAddVirtualAuthenticator = "WebAuthn.addVirtualAuthenticator"
CommandRemoveVirtualAuthenticator = "WebAuthn.removeVirtualAuthenticator"
CommandAddCredential = "WebAuthn.addCredential"
CommandGetCredential = "WebAuthn.getCredential"
CommandGetCredentials = "WebAuthn.getCredentials"
CommandRemoveCredential = "WebAuthn.removeCredential"
CommandClearCredentials = "WebAuthn.clearCredentials"
CommandSetUserVerified = "WebAuthn.setUserVerified"
)