diff --git a/cdproto.go b/cdproto.go index 71deab4..ba5ea53 100644 --- a/cdproto.go +++ b/cdproto.go @@ -353,7 +353,7 @@ const ( CommandFedCmEnable = fedcm.CommandEnable CommandFedCmDisable = fedcm.CommandDisable CommandFedCmSelectAccount = fedcm.CommandSelectAccount - CommandFedCmConfirmIdpLogin = fedcm.CommandConfirmIdpLogin + CommandFedCmClickDialogButton = fedcm.CommandClickDialogButton CommandFedCmDismissDialog = fedcm.CommandDismissDialog CommandFedCmResetCooldown = fedcm.CommandResetCooldown EventFedCmDialogShown = "FedCm.dialogShown" @@ -1642,7 +1642,7 @@ func UnmarshalMessage(msg *Message) (interface{}, error) { case CommandFedCmSelectAccount: return emptyVal, nil - case CommandFedCmConfirmIdpLogin: + case CommandFedCmClickDialogButton: return emptyVal, nil case CommandFedCmDismissDialog: diff --git a/fedcm/easyjson.go b/fedcm/easyjson.go index 2bf03cb..5be7c9c 100644 --- a/fedcm/easyjson.go +++ b/fedcm/easyjson.go @@ -486,7 +486,7 @@ func (v *DisableParams) UnmarshalJSON(data []byte) error { func (v *DisableParams) UnmarshalEasyJSON(l *jlexer.Lexer) { easyjsonC5a4559bDecodeGithubComChromedpCdprotoFedcm5(l, v) } -func easyjsonC5a4559bDecodeGithubComChromedpCdprotoFedcm6(in *jlexer.Lexer, out *ConfirmIdpLoginParams) { +func easyjsonC5a4559bDecodeGithubComChromedpCdprotoFedcm6(in *jlexer.Lexer, out *ClickDialogButtonParams) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -507,6 +507,8 @@ func easyjsonC5a4559bDecodeGithubComChromedpCdprotoFedcm6(in *jlexer.Lexer, out switch key { case "dialogId": out.DialogID = string(in.String()) + case "dialogButton": + (out.DialogButton).UnmarshalEasyJSON(in) default: in.SkipRecursive() } @@ -517,7 +519,7 @@ func easyjsonC5a4559bDecodeGithubComChromedpCdprotoFedcm6(in *jlexer.Lexer, out in.Consumed() } } -func easyjsonC5a4559bEncodeGithubComChromedpCdprotoFedcm6(out *jwriter.Writer, in ConfirmIdpLoginParams) { +func easyjsonC5a4559bEncodeGithubComChromedpCdprotoFedcm6(out *jwriter.Writer, in ClickDialogButtonParams) { out.RawByte('{') first := true _ = first @@ -526,30 +528,35 @@ func easyjsonC5a4559bEncodeGithubComChromedpCdprotoFedcm6(out *jwriter.Writer, i out.RawString(prefix[1:]) out.String(string(in.DialogID)) } + { + const prefix string = ",\"dialogButton\":" + out.RawString(prefix) + (in.DialogButton).MarshalEasyJSON(out) + } out.RawByte('}') } // MarshalJSON supports json.Marshaler interface -func (v ConfirmIdpLoginParams) MarshalJSON() ([]byte, error) { +func (v ClickDialogButtonParams) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjsonC5a4559bEncodeGithubComChromedpCdprotoFedcm6(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface -func (v ConfirmIdpLoginParams) MarshalEasyJSON(w *jwriter.Writer) { +func (v ClickDialogButtonParams) MarshalEasyJSON(w *jwriter.Writer) { easyjsonC5a4559bEncodeGithubComChromedpCdprotoFedcm6(w, v) } // UnmarshalJSON supports json.Unmarshaler interface -func (v *ConfirmIdpLoginParams) UnmarshalJSON(data []byte) error { +func (v *ClickDialogButtonParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoFedcm6(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *ConfirmIdpLoginParams) UnmarshalEasyJSON(l *jlexer.Lexer) { +func (v *ClickDialogButtonParams) UnmarshalEasyJSON(l *jlexer.Lexer) { easyjsonC5a4559bDecodeGithubComChromedpCdprotoFedcm6(l, v) } func easyjsonC5a4559bDecodeGithubComChromedpCdprotoFedcm7(in *jlexer.Lexer, out *Account) { diff --git a/fedcm/fedcm.go b/fedcm/fedcm.go index fdd9e1f..4c8c366 100644 --- a/fedcm/fedcm.go +++ b/fedcm/fedcm.go @@ -82,29 +82,30 @@ func (p *SelectAccountParams) Do(ctx context.Context) (err error) { return cdp.Execute(ctx, CommandSelectAccount, p, nil) } -// ConfirmIdpLoginParams only valid if the dialog type is ConfirmIdpLogin. -// Acts as if the user had clicked the continue button. -type ConfirmIdpLoginParams struct { - DialogID string `json:"dialogId"` +// ClickDialogButtonParams [no description]. +type ClickDialogButtonParams struct { + DialogID string `json:"dialogId"` + DialogButton DialogButton `json:"dialogButton"` } -// ConfirmIdpLogin only valid if the dialog type is ConfirmIdpLogin. Acts as -// if the user had clicked the continue button. +// ClickDialogButton [no description]. // -// See: https://chromedevtools.github.io/devtools-protocol/tot/FedCm#method-confirmIdpLogin +// See: https://chromedevtools.github.io/devtools-protocol/tot/FedCm#method-clickDialogButton // // parameters: // // dialogID -func ConfirmIdpLogin(dialogID string) *ConfirmIdpLoginParams { - return &ConfirmIdpLoginParams{ - DialogID: dialogID, +// dialogButton +func ClickDialogButton(dialogID string, dialogButton DialogButton) *ClickDialogButtonParams { + return &ClickDialogButtonParams{ + DialogID: dialogID, + DialogButton: dialogButton, } } -// Do executes FedCm.confirmIdpLogin against the provided context. -func (p *ConfirmIdpLoginParams) Do(ctx context.Context) (err error) { - return cdp.Execute(ctx, CommandConfirmIdpLogin, p, nil) +// Do executes FedCm.clickDialogButton against the provided context. +func (p *ClickDialogButtonParams) Do(ctx context.Context) (err error) { + return cdp.Execute(ctx, CommandClickDialogButton, p, nil) } // DismissDialogParams [no description]. @@ -156,10 +157,10 @@ func (p *ResetCooldownParams) Do(ctx context.Context) (err error) { // Command names. const ( - CommandEnable = "FedCm.enable" - CommandDisable = "FedCm.disable" - CommandSelectAccount = "FedCm.selectAccount" - CommandConfirmIdpLogin = "FedCm.confirmIdpLogin" - CommandDismissDialog = "FedCm.dismissDialog" - CommandResetCooldown = "FedCm.resetCooldown" + CommandEnable = "FedCm.enable" + CommandDisable = "FedCm.disable" + CommandSelectAccount = "FedCm.selectAccount" + CommandClickDialogButton = "FedCm.clickDialogButton" + CommandDismissDialog = "FedCm.dismissDialog" + CommandResetCooldown = "FedCm.resetCooldown" ) diff --git a/fedcm/types.go b/fedcm/types.go index d0251a1..a5ed1f2 100644 --- a/fedcm/types.go +++ b/fedcm/types.go @@ -56,8 +56,7 @@ func (t *LoginState) UnmarshalJSON(buf []byte) error { return easyjson.Unmarshal(buf, t) } -// DialogType whether the dialog shown is an account chooser or an auto -// re-authentication dialog. +// DialogType the types of FedCM dialogs. // // See: https://chromedevtools.github.io/devtools-protocol/tot/FedCm#type-DialogType type DialogType string @@ -105,6 +104,48 @@ func (t *DialogType) UnmarshalJSON(buf []byte) error { return easyjson.Unmarshal(buf, t) } +// DialogButton the buttons on the FedCM dialog. +// +// See: https://chromedevtools.github.io/devtools-protocol/tot/FedCm#type-DialogButton +type DialogButton string + +// String returns the DialogButton as string value. +func (t DialogButton) String() string { + return string(t) +} + +// DialogButton values. +const ( + DialogButtonConfirmIdpLoginContinue DialogButton = "ConfirmIdpLoginContinue" +) + +// MarshalEasyJSON satisfies easyjson.Marshaler. +func (t DialogButton) MarshalEasyJSON(out *jwriter.Writer) { + out.String(string(t)) +} + +// MarshalJSON satisfies json.Marshaler. +func (t DialogButton) MarshalJSON() ([]byte, error) { + return easyjson.Marshal(t) +} + +// UnmarshalEasyJSON satisfies easyjson.Unmarshaler. +func (t *DialogButton) UnmarshalEasyJSON(in *jlexer.Lexer) { + v := in.String() + switch DialogButton(v) { + case DialogButtonConfirmIdpLoginContinue: + *t = DialogButtonConfirmIdpLoginContinue + + default: + in.AddError(fmt.Errorf("unknown DialogButton value: %v", v)) + } +} + +// UnmarshalJSON satisfies json.Unmarshaler. +func (t *DialogButton) UnmarshalJSON(buf []byte) error { + return easyjson.Unmarshal(buf, t) +} + // Account corresponds to IdentityRequestAccount. // // See: https://chromedevtools.github.io/devtools-protocol/tot/FedCm#type-Account