fedcm.go 5.8 KB

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