github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/protocol/keybase1/prove_ui.go (about)

     1  // Auto-generated to Go types and interfaces using avdl-compiler v1.4.10 (https://github.com/keybase/node-avdl-compiler)
     2  //   Input file: avdl/keybase1/prove_ui.avdl
     3  
     4  package keybase1
     5  
     6  import (
     7  	"fmt"
     8  	"github.com/keybase/go-framed-msgpack-rpc/rpc"
     9  	context "golang.org/x/net/context"
    10  	"time"
    11  )
    12  
    13  type PromptOverwriteType int
    14  
    15  const (
    16  	PromptOverwriteType_SOCIAL PromptOverwriteType = 0
    17  	PromptOverwriteType_SITE   PromptOverwriteType = 1
    18  )
    19  
    20  func (o PromptOverwriteType) DeepCopy() PromptOverwriteType { return o }
    21  
    22  var PromptOverwriteTypeMap = map[string]PromptOverwriteType{
    23  	"SOCIAL": 0,
    24  	"SITE":   1,
    25  }
    26  
    27  var PromptOverwriteTypeRevMap = map[PromptOverwriteType]string{
    28  	0: "SOCIAL",
    29  	1: "SITE",
    30  }
    31  
    32  func (e PromptOverwriteType) String() string {
    33  	if v, ok := PromptOverwriteTypeRevMap[e]; ok {
    34  		return v
    35  	}
    36  	return fmt.Sprintf("%v", int(e))
    37  }
    38  
    39  type ProveParameters struct {
    40  	LogoFull    []SizedImage `codec:"logoFull" json:"logoFull"`
    41  	LogoBlack   []SizedImage `codec:"logoBlack" json:"logoBlack"`
    42  	LogoWhite   []SizedImage `codec:"logoWhite" json:"logoWhite"`
    43  	Title       string       `codec:"title" json:"title"`
    44  	Subtext     string       `codec:"subtext" json:"subtext"`
    45  	Suffix      string       `codec:"suffix" json:"suffix"`
    46  	ButtonLabel string       `codec:"buttonLabel" json:"buttonLabel"`
    47  }
    48  
    49  func (o ProveParameters) DeepCopy() ProveParameters {
    50  	return ProveParameters{
    51  		LogoFull: (func(x []SizedImage) []SizedImage {
    52  			if x == nil {
    53  				return nil
    54  			}
    55  			ret := make([]SizedImage, len(x))
    56  			for i, v := range x {
    57  				vCopy := v.DeepCopy()
    58  				ret[i] = vCopy
    59  			}
    60  			return ret
    61  		})(o.LogoFull),
    62  		LogoBlack: (func(x []SizedImage) []SizedImage {
    63  			if x == nil {
    64  				return nil
    65  			}
    66  			ret := make([]SizedImage, len(x))
    67  			for i, v := range x {
    68  				vCopy := v.DeepCopy()
    69  				ret[i] = vCopy
    70  			}
    71  			return ret
    72  		})(o.LogoBlack),
    73  		LogoWhite: (func(x []SizedImage) []SizedImage {
    74  			if x == nil {
    75  				return nil
    76  			}
    77  			ret := make([]SizedImage, len(x))
    78  			for i, v := range x {
    79  				vCopy := v.DeepCopy()
    80  				ret[i] = vCopy
    81  			}
    82  			return ret
    83  		})(o.LogoWhite),
    84  		Title:       o.Title,
    85  		Subtext:     o.Subtext,
    86  		Suffix:      o.Suffix,
    87  		ButtonLabel: o.ButtonLabel,
    88  	}
    89  }
    90  
    91  type PromptOverwriteArg struct {
    92  	SessionID int                 `codec:"sessionID" json:"sessionID"`
    93  	Account   string              `codec:"account" json:"account"`
    94  	Typ       PromptOverwriteType `codec:"typ" json:"typ"`
    95  }
    96  
    97  type PromptUsernameArg struct {
    98  	SessionID  int              `codec:"sessionID" json:"sessionID"`
    99  	Prompt     string           `codec:"prompt" json:"prompt"`
   100  	PrevError  *Status          `codec:"prevError,omitempty" json:"prevError,omitempty"`
   101  	Parameters *ProveParameters `codec:"parameters,omitempty" json:"parameters,omitempty"`
   102  }
   103  
   104  type OutputPrechecksArg struct {
   105  	SessionID int  `codec:"sessionID" json:"sessionID"`
   106  	Text      Text `codec:"text" json:"text"`
   107  }
   108  
   109  type PreProofWarningArg struct {
   110  	SessionID int  `codec:"sessionID" json:"sessionID"`
   111  	Text      Text `codec:"text" json:"text"`
   112  }
   113  
   114  type OutputInstructionsArg struct {
   115  	SessionID    int              `codec:"sessionID" json:"sessionID"`
   116  	Instructions Text             `codec:"instructions" json:"instructions"`
   117  	Proof        string           `codec:"proof" json:"proof"`
   118  	Parameters   *ProveParameters `codec:"parameters,omitempty" json:"parameters,omitempty"`
   119  }
   120  
   121  type OkToCheckArg struct {
   122  	SessionID int    `codec:"sessionID" json:"sessionID"`
   123  	Name      string `codec:"name" json:"name"`
   124  	Attempt   int    `codec:"attempt" json:"attempt"`
   125  }
   126  
   127  type CheckingArg struct {
   128  	SessionID int    `codec:"sessionID" json:"sessionID"`
   129  	Name      string `codec:"name" json:"name"`
   130  }
   131  
   132  type ContinueCheckingArg struct {
   133  	SessionID int `codec:"sessionID" json:"sessionID"`
   134  }
   135  
   136  type DisplayRecheckWarningArg struct {
   137  	SessionID int  `codec:"sessionID" json:"sessionID"`
   138  	Text      Text `codec:"text" json:"text"`
   139  }
   140  
   141  type ProveUiInterface interface {
   142  	PromptOverwrite(context.Context, PromptOverwriteArg) (bool, error)
   143  	PromptUsername(context.Context, PromptUsernameArg) (string, error)
   144  	OutputPrechecks(context.Context, OutputPrechecksArg) error
   145  	PreProofWarning(context.Context, PreProofWarningArg) (bool, error)
   146  	OutputInstructions(context.Context, OutputInstructionsArg) error
   147  	OkToCheck(context.Context, OkToCheckArg) (bool, error)
   148  	Checking(context.Context, CheckingArg) error
   149  	ContinueChecking(context.Context, int) (bool, error)
   150  	DisplayRecheckWarning(context.Context, DisplayRecheckWarningArg) error
   151  }
   152  
   153  func ProveUiProtocol(i ProveUiInterface) rpc.Protocol {
   154  	return rpc.Protocol{
   155  		Name: "keybase.1.proveUi",
   156  		Methods: map[string]rpc.ServeHandlerDescription{
   157  			"promptOverwrite": {
   158  				MakeArg: func() interface{} {
   159  					var ret [1]PromptOverwriteArg
   160  					return &ret
   161  				},
   162  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   163  					typedArgs, ok := args.(*[1]PromptOverwriteArg)
   164  					if !ok {
   165  						err = rpc.NewTypeError((*[1]PromptOverwriteArg)(nil), args)
   166  						return
   167  					}
   168  					ret, err = i.PromptOverwrite(ctx, typedArgs[0])
   169  					return
   170  				},
   171  			},
   172  			"promptUsername": {
   173  				MakeArg: func() interface{} {
   174  					var ret [1]PromptUsernameArg
   175  					return &ret
   176  				},
   177  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   178  					typedArgs, ok := args.(*[1]PromptUsernameArg)
   179  					if !ok {
   180  						err = rpc.NewTypeError((*[1]PromptUsernameArg)(nil), args)
   181  						return
   182  					}
   183  					ret, err = i.PromptUsername(ctx, typedArgs[0])
   184  					return
   185  				},
   186  			},
   187  			"outputPrechecks": {
   188  				MakeArg: func() interface{} {
   189  					var ret [1]OutputPrechecksArg
   190  					return &ret
   191  				},
   192  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   193  					typedArgs, ok := args.(*[1]OutputPrechecksArg)
   194  					if !ok {
   195  						err = rpc.NewTypeError((*[1]OutputPrechecksArg)(nil), args)
   196  						return
   197  					}
   198  					err = i.OutputPrechecks(ctx, typedArgs[0])
   199  					return
   200  				},
   201  			},
   202  			"preProofWarning": {
   203  				MakeArg: func() interface{} {
   204  					var ret [1]PreProofWarningArg
   205  					return &ret
   206  				},
   207  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   208  					typedArgs, ok := args.(*[1]PreProofWarningArg)
   209  					if !ok {
   210  						err = rpc.NewTypeError((*[1]PreProofWarningArg)(nil), args)
   211  						return
   212  					}
   213  					ret, err = i.PreProofWarning(ctx, typedArgs[0])
   214  					return
   215  				},
   216  			},
   217  			"outputInstructions": {
   218  				MakeArg: func() interface{} {
   219  					var ret [1]OutputInstructionsArg
   220  					return &ret
   221  				},
   222  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   223  					typedArgs, ok := args.(*[1]OutputInstructionsArg)
   224  					if !ok {
   225  						err = rpc.NewTypeError((*[1]OutputInstructionsArg)(nil), args)
   226  						return
   227  					}
   228  					err = i.OutputInstructions(ctx, typedArgs[0])
   229  					return
   230  				},
   231  			},
   232  			"okToCheck": {
   233  				MakeArg: func() interface{} {
   234  					var ret [1]OkToCheckArg
   235  					return &ret
   236  				},
   237  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   238  					typedArgs, ok := args.(*[1]OkToCheckArg)
   239  					if !ok {
   240  						err = rpc.NewTypeError((*[1]OkToCheckArg)(nil), args)
   241  						return
   242  					}
   243  					ret, err = i.OkToCheck(ctx, typedArgs[0])
   244  					return
   245  				},
   246  			},
   247  			"checking": {
   248  				MakeArg: func() interface{} {
   249  					var ret [1]CheckingArg
   250  					return &ret
   251  				},
   252  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   253  					typedArgs, ok := args.(*[1]CheckingArg)
   254  					if !ok {
   255  						err = rpc.NewTypeError((*[1]CheckingArg)(nil), args)
   256  						return
   257  					}
   258  					err = i.Checking(ctx, typedArgs[0])
   259  					return
   260  				},
   261  			},
   262  			"continueChecking": {
   263  				MakeArg: func() interface{} {
   264  					var ret [1]ContinueCheckingArg
   265  					return &ret
   266  				},
   267  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   268  					typedArgs, ok := args.(*[1]ContinueCheckingArg)
   269  					if !ok {
   270  						err = rpc.NewTypeError((*[1]ContinueCheckingArg)(nil), args)
   271  						return
   272  					}
   273  					ret, err = i.ContinueChecking(ctx, typedArgs[0].SessionID)
   274  					return
   275  				},
   276  			},
   277  			"displayRecheckWarning": {
   278  				MakeArg: func() interface{} {
   279  					var ret [1]DisplayRecheckWarningArg
   280  					return &ret
   281  				},
   282  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   283  					typedArgs, ok := args.(*[1]DisplayRecheckWarningArg)
   284  					if !ok {
   285  						err = rpc.NewTypeError((*[1]DisplayRecheckWarningArg)(nil), args)
   286  						return
   287  					}
   288  					err = i.DisplayRecheckWarning(ctx, typedArgs[0])
   289  					return
   290  				},
   291  			},
   292  		},
   293  	}
   294  }
   295  
   296  type ProveUiClient struct {
   297  	Cli rpc.GenericClient
   298  }
   299  
   300  func (c ProveUiClient) PromptOverwrite(ctx context.Context, __arg PromptOverwriteArg) (res bool, err error) {
   301  	err = c.Cli.Call(ctx, "keybase.1.proveUi.promptOverwrite", []interface{}{__arg}, &res, 0*time.Millisecond)
   302  	return
   303  }
   304  
   305  func (c ProveUiClient) PromptUsername(ctx context.Context, __arg PromptUsernameArg) (res string, err error) {
   306  	err = c.Cli.Call(ctx, "keybase.1.proveUi.promptUsername", []interface{}{__arg}, &res, 0*time.Millisecond)
   307  	return
   308  }
   309  
   310  func (c ProveUiClient) OutputPrechecks(ctx context.Context, __arg OutputPrechecksArg) (err error) {
   311  	err = c.Cli.Call(ctx, "keybase.1.proveUi.outputPrechecks", []interface{}{__arg}, nil, 0*time.Millisecond)
   312  	return
   313  }
   314  
   315  func (c ProveUiClient) PreProofWarning(ctx context.Context, __arg PreProofWarningArg) (res bool, err error) {
   316  	err = c.Cli.Call(ctx, "keybase.1.proveUi.preProofWarning", []interface{}{__arg}, &res, 0*time.Millisecond)
   317  	return
   318  }
   319  
   320  func (c ProveUiClient) OutputInstructions(ctx context.Context, __arg OutputInstructionsArg) (err error) {
   321  	err = c.Cli.Call(ctx, "keybase.1.proveUi.outputInstructions", []interface{}{__arg}, nil, 0*time.Millisecond)
   322  	return
   323  }
   324  
   325  func (c ProveUiClient) OkToCheck(ctx context.Context, __arg OkToCheckArg) (res bool, err error) {
   326  	err = c.Cli.Call(ctx, "keybase.1.proveUi.okToCheck", []interface{}{__arg}, &res, 0*time.Millisecond)
   327  	return
   328  }
   329  
   330  func (c ProveUiClient) Checking(ctx context.Context, __arg CheckingArg) (err error) {
   331  	err = c.Cli.Call(ctx, "keybase.1.proveUi.checking", []interface{}{__arg}, nil, 0*time.Millisecond)
   332  	return
   333  }
   334  
   335  func (c ProveUiClient) ContinueChecking(ctx context.Context, sessionID int) (res bool, err error) {
   336  	__arg := ContinueCheckingArg{SessionID: sessionID}
   337  	err = c.Cli.Call(ctx, "keybase.1.proveUi.continueChecking", []interface{}{__arg}, &res, 0*time.Millisecond)
   338  	return
   339  }
   340  
   341  func (c ProveUiClient) DisplayRecheckWarning(ctx context.Context, __arg DisplayRecheckWarningArg) (err error) {
   342  	err = c.Cli.Call(ctx, "keybase.1.proveUi.displayRecheckWarning", []interface{}{__arg}, nil, 0*time.Millisecond)
   343  	return
   344  }