-
Notifications
You must be signed in to change notification settings - Fork 54
/
fedcm.go
165 lines (141 loc) · 5.03 KB
/
fedcm.go
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
// Package fedcm provides the Chrome DevTools Protocol
// commands, types, and events for the FedCm domain.
//
// This domain allows interacting with the FedCM dialog.
//
// Generated by the cdproto-gen command.
package fedcm
// Code generated by cdproto-gen. DO NOT EDIT.
import (
"context"
"github.com/chromedp/cdproto/cdp"
)
// EnableParams [no description].
type EnableParams struct {
DisableRejectionDelay bool `json:"disableRejectionDelay,omitempty"` // Allows callers to disable the promise rejection delay that would normally happen, if this is unimportant to what's being tested. (step 4 of https://fedidcg.github.io/FedCM/#browser-api-rp-sign-in)
}
// Enable [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/FedCm#method-enable
//
// parameters:
func Enable() *EnableParams {
return &EnableParams{}
}
// WithDisableRejectionDelay allows callers to disable the promise rejection
// delay that would normally happen, if this is unimportant to what's being
// tested. (step 4 of https://fedidcg.github.io/FedCM/#browser-api-rp-sign-in).
func (p EnableParams) WithDisableRejectionDelay(disableRejectionDelay bool) *EnableParams {
p.DisableRejectionDelay = disableRejectionDelay
return &p
}
// Do executes FedCm.enable against the provided context.
func (p *EnableParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandEnable, p, nil)
}
// DisableParams [no description].
type DisableParams struct{}
// Disable [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/FedCm#method-disable
func Disable() *DisableParams {
return &DisableParams{}
}
// Do executes FedCm.disable against the provided context.
func (p *DisableParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandDisable, nil, nil)
}
// SelectAccountParams [no description].
type SelectAccountParams struct {
DialogID string `json:"dialogId"`
AccountIndex int64 `json:"accountIndex"`
}
// SelectAccount [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/FedCm#method-selectAccount
//
// parameters:
//
// dialogID
// accountIndex
func SelectAccount(dialogID string, accountIndex int64) *SelectAccountParams {
return &SelectAccountParams{
DialogID: dialogID,
AccountIndex: accountIndex,
}
}
// Do executes FedCm.selectAccount against the provided context.
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"`
}
// ConfirmIdpLogin only valid if the dialog type is ConfirmIdpLogin. Acts as
// if the user had clicked the continue button.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/FedCm#method-confirmIdpLogin
//
// parameters:
//
// dialogID
func ConfirmIdpLogin(dialogID string) *ConfirmIdpLoginParams {
return &ConfirmIdpLoginParams{
DialogID: dialogID,
}
}
// Do executes FedCm.confirmIdpLogin against the provided context.
func (p *ConfirmIdpLoginParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandConfirmIdpLogin, p, nil)
}
// DismissDialogParams [no description].
type DismissDialogParams struct {
DialogID string `json:"dialogId"`
TriggerCooldown bool `json:"triggerCooldown,omitempty"`
}
// DismissDialog [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/FedCm#method-dismissDialog
//
// parameters:
//
// dialogID
func DismissDialog(dialogID string) *DismissDialogParams {
return &DismissDialogParams{
DialogID: dialogID,
}
}
// WithTriggerCooldown [no description].
func (p DismissDialogParams) WithTriggerCooldown(triggerCooldown bool) *DismissDialogParams {
p.TriggerCooldown = triggerCooldown
return &p
}
// Do executes FedCm.dismissDialog against the provided context.
func (p *DismissDialogParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandDismissDialog, p, nil)
}
// ResetCooldownParams resets the cooldown time, if any, to allow the next
// FedCM call to show a dialog even if one was recently dismissed by the user.
type ResetCooldownParams struct{}
// ResetCooldown resets the cooldown time, if any, to allow the next FedCM
// call to show a dialog even if one was recently dismissed by the user.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/FedCm#method-resetCooldown
func ResetCooldown() *ResetCooldownParams {
return &ResetCooldownParams{}
}
// Do executes FedCm.resetCooldown against the provided context.
func (p *ResetCooldownParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandResetCooldown, nil, nil)
}
// Command names.
const (
CommandEnable = "FedCm.enable"
CommandDisable = "FedCm.disable"
CommandSelectAccount = "FedCm.selectAccount"
CommandConfirmIdpLogin = "FedCm.confirmIdpLogin"
CommandDismissDialog = "FedCm.dismissDialog"
CommandResetCooldown = "FedCm.resetCooldown"
)