fedcm.go 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. // Package fedcm provides the Chrome DevTools Protocol
  2. // commands, types, and events for the FedCm domain.
  3. //
  4. // This domain allows interacting with the FedCM dialog.
  5. //
  6. // Generated by the cdproto-gen command.
  7. package fedcm
  8. // Code generated by cdproto-gen. DO NOT EDIT.
  9. import (
  10. "context"
  11. "github.com/chromedp/cdproto/cdp"
  12. )
  13. // EnableParams [no description].
  14. type EnableParams struct {
  15. DisableRejectionDelay bool `json:"disableRejectionDelay"` // 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)
  16. }
  17. // Enable [no description].
  18. //
  19. // See: https://chromedevtools.github.io/devtools-protocol/tot/FedCm#method-enable
  20. //
  21. // parameters:
  22. func Enable() *EnableParams {
  23. return &EnableParams{
  24. DisableRejectionDelay: false,
  25. }
  26. }
  27. // WithDisableRejectionDelay allows callers to disable the promise rejection
  28. // delay that would normally happen, if this is unimportant to what's being
  29. // tested. (step 4 of https://fedidcg.github.io/FedCM/#browser-api-rp-sign-in).
  30. func (p EnableParams) WithDisableRejectionDelay(disableRejectionDelay bool) *EnableParams {
  31. p.DisableRejectionDelay = disableRejectionDelay
  32. return &p
  33. }
  34. // Do executes FedCm.enable against the provided context.
  35. func (p *EnableParams) Do(ctx context.Context) (err error) {
  36. return cdp.Execute(ctx, CommandEnable, p, nil)
  37. }
  38. // DisableParams [no description].
  39. type DisableParams struct{}
  40. // Disable [no description].
  41. //
  42. // See: https://chromedevtools.github.io/devtools-protocol/tot/FedCm#method-disable
  43. func Disable() *DisableParams {
  44. return &DisableParams{}
  45. }
  46. // Do executes FedCm.disable against the provided context.
  47. func (p *DisableParams) Do(ctx context.Context) (err error) {
  48. return cdp.Execute(ctx, CommandDisable, nil, nil)
  49. }
  50. // SelectAccountParams [no description].
  51. type SelectAccountParams struct {
  52. DialogID string `json:"dialogId"`
  53. AccountIndex int64 `json:"accountIndex"`
  54. }
  55. // SelectAccount [no description].
  56. //
  57. // See: https://chromedevtools.github.io/devtools-protocol/tot/FedCm#method-selectAccount
  58. //
  59. // parameters:
  60. //
  61. // dialogID
  62. // accountIndex
  63. func SelectAccount(dialogID string, accountIndex int64) *SelectAccountParams {
  64. return &SelectAccountParams{
  65. DialogID: dialogID,
  66. AccountIndex: accountIndex,
  67. }
  68. }
  69. // Do executes FedCm.selectAccount against the provided context.
  70. func (p *SelectAccountParams) Do(ctx context.Context) (err error) {
  71. return cdp.Execute(ctx, CommandSelectAccount, p, nil)
  72. }
  73. // ClickDialogButtonParams [no description].
  74. type ClickDialogButtonParams struct {
  75. DialogID string `json:"dialogId"`
  76. DialogButton DialogButton `json:"dialogButton"`
  77. }
  78. // ClickDialogButton [no description].
  79. //
  80. // See: https://chromedevtools.github.io/devtools-protocol/tot/FedCm#method-clickDialogButton
  81. //
  82. // parameters:
  83. //
  84. // dialogID
  85. // dialogButton
  86. func ClickDialogButton(dialogID string, dialogButton DialogButton) *ClickDialogButtonParams {
  87. return &ClickDialogButtonParams{
  88. DialogID: dialogID,
  89. DialogButton: dialogButton,
  90. }
  91. }
  92. // Do executes FedCm.clickDialogButton against the provided context.
  93. func (p *ClickDialogButtonParams) Do(ctx context.Context) (err error) {
  94. return cdp.Execute(ctx, CommandClickDialogButton, p, nil)
  95. }
  96. // OpenURLParams [no description].
  97. type OpenURLParams struct {
  98. DialogID string `json:"dialogId"`
  99. AccountIndex int64 `json:"accountIndex"`
  100. AccountURLType AccountURLType `json:"accountUrlType"`
  101. }
  102. // OpenURL [no description].
  103. //
  104. // See: https://chromedevtools.github.io/devtools-protocol/tot/FedCm#method-openUrl
  105. //
  106. // parameters:
  107. //
  108. // dialogID
  109. // accountIndex
  110. // accountURLType
  111. func OpenURL(dialogID string, accountIndex int64, accountURLType AccountURLType) *OpenURLParams {
  112. return &OpenURLParams{
  113. DialogID: dialogID,
  114. AccountIndex: accountIndex,
  115. AccountURLType: accountURLType,
  116. }
  117. }
  118. // Do executes FedCm.openUrl against the provided context.
  119. func (p *OpenURLParams) Do(ctx context.Context) (err error) {
  120. return cdp.Execute(ctx, CommandOpenURL, p, nil)
  121. }
  122. // DismissDialogParams [no description].
  123. type DismissDialogParams struct {
  124. DialogID string `json:"dialogId"`
  125. TriggerCooldown bool `json:"triggerCooldown"`
  126. }
  127. // DismissDialog [no description].
  128. //
  129. // See: https://chromedevtools.github.io/devtools-protocol/tot/FedCm#method-dismissDialog
  130. //
  131. // parameters:
  132. //
  133. // dialogID
  134. func DismissDialog(dialogID string) *DismissDialogParams {
  135. return &DismissDialogParams{
  136. DialogID: dialogID,
  137. TriggerCooldown: false,
  138. }
  139. }
  140. // WithTriggerCooldown [no description].
  141. func (p DismissDialogParams) WithTriggerCooldown(triggerCooldown bool) *DismissDialogParams {
  142. p.TriggerCooldown = triggerCooldown
  143. return &p
  144. }
  145. // Do executes FedCm.dismissDialog against the provided context.
  146. func (p *DismissDialogParams) Do(ctx context.Context) (err error) {
  147. return cdp.Execute(ctx, CommandDismissDialog, p, nil)
  148. }
  149. // ResetCooldownParams resets the cooldown time, if any, to allow the next
  150. // FedCM call to show a dialog even if one was recently dismissed by the user.
  151. type ResetCooldownParams struct{}
  152. // ResetCooldown resets the cooldown time, if any, to allow the next FedCM
  153. // call to show a dialog even if one was recently dismissed by the user.
  154. //
  155. // See: https://chromedevtools.github.io/devtools-protocol/tot/FedCm#method-resetCooldown
  156. func ResetCooldown() *ResetCooldownParams {
  157. return &ResetCooldownParams{}
  158. }
  159. // Do executes FedCm.resetCooldown against the provided context.
  160. func (p *ResetCooldownParams) Do(ctx context.Context) (err error) {
  161. return cdp.Execute(ctx, CommandResetCooldown, nil, nil)
  162. }
  163. // Command names.
  164. const (
  165. CommandEnable = "FedCm.enable"
  166. CommandDisable = "FedCm.disable"
  167. CommandSelectAccount = "FedCm.selectAccount"
  168. CommandClickDialogButton = "FedCm.clickDialogButton"
  169. CommandOpenURL = "FedCm.openUrl"
  170. CommandDismissDialog = "FedCm.dismissDialog"
  171. CommandResetCooldown = "FedCm.resetCooldown"
  172. )