github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/protocol/keybase1/tlf_keys.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/tlf_keys.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 TLFIdentifyBehavior int
    14  
    15  const (
    16  	TLFIdentifyBehavior_UNSET              TLFIdentifyBehavior = 0
    17  	TLFIdentifyBehavior_CHAT_CLI           TLFIdentifyBehavior = 1
    18  	TLFIdentifyBehavior_CHAT_GUI           TLFIdentifyBehavior = 2
    19  	TLFIdentifyBehavior_REMOVED_AND_UNUSED TLFIdentifyBehavior = 3
    20  	TLFIdentifyBehavior_KBFS_REKEY         TLFIdentifyBehavior = 4
    21  	TLFIdentifyBehavior_KBFS_QR            TLFIdentifyBehavior = 5
    22  	TLFIdentifyBehavior_CHAT_SKIP          TLFIdentifyBehavior = 6
    23  	TLFIdentifyBehavior_SALTPACK           TLFIdentifyBehavior = 7
    24  	TLFIdentifyBehavior_CLI                TLFIdentifyBehavior = 8
    25  	TLFIdentifyBehavior_GUI                TLFIdentifyBehavior = 9
    26  	TLFIdentifyBehavior_DEFAULT_KBFS       TLFIdentifyBehavior = 10
    27  	TLFIdentifyBehavior_KBFS_CHAT          TLFIdentifyBehavior = 11
    28  	TLFIdentifyBehavior_RESOLVE_AND_CHECK  TLFIdentifyBehavior = 12
    29  	TLFIdentifyBehavior_GUI_PROFILE        TLFIdentifyBehavior = 13
    30  	TLFIdentifyBehavior_KBFS_INIT          TLFIdentifyBehavior = 14
    31  	TLFIdentifyBehavior_FS_GUI             TLFIdentifyBehavior = 15
    32  )
    33  
    34  func (o TLFIdentifyBehavior) DeepCopy() TLFIdentifyBehavior { return o }
    35  
    36  var TLFIdentifyBehaviorMap = map[string]TLFIdentifyBehavior{
    37  	"UNSET":              0,
    38  	"CHAT_CLI":           1,
    39  	"CHAT_GUI":           2,
    40  	"REMOVED_AND_UNUSED": 3,
    41  	"KBFS_REKEY":         4,
    42  	"KBFS_QR":            5,
    43  	"CHAT_SKIP":          6,
    44  	"SALTPACK":           7,
    45  	"CLI":                8,
    46  	"GUI":                9,
    47  	"DEFAULT_KBFS":       10,
    48  	"KBFS_CHAT":          11,
    49  	"RESOLVE_AND_CHECK":  12,
    50  	"GUI_PROFILE":        13,
    51  	"KBFS_INIT":          14,
    52  	"FS_GUI":             15,
    53  }
    54  
    55  var TLFIdentifyBehaviorRevMap = map[TLFIdentifyBehavior]string{
    56  	0:  "UNSET",
    57  	1:  "CHAT_CLI",
    58  	2:  "CHAT_GUI",
    59  	3:  "REMOVED_AND_UNUSED",
    60  	4:  "KBFS_REKEY",
    61  	5:  "KBFS_QR",
    62  	6:  "CHAT_SKIP",
    63  	7:  "SALTPACK",
    64  	8:  "CLI",
    65  	9:  "GUI",
    66  	10: "DEFAULT_KBFS",
    67  	11: "KBFS_CHAT",
    68  	12: "RESOLVE_AND_CHECK",
    69  	13: "GUI_PROFILE",
    70  	14: "KBFS_INIT",
    71  	15: "FS_GUI",
    72  }
    73  
    74  func (e TLFIdentifyBehavior) String() string {
    75  	if v, ok := TLFIdentifyBehaviorRevMap[e]; ok {
    76  		return v
    77  	}
    78  	return fmt.Sprintf("%v", int(e))
    79  }
    80  
    81  type CanonicalTlfName string
    82  
    83  func (o CanonicalTlfName) DeepCopy() CanonicalTlfName {
    84  	return o
    85  }
    86  
    87  type CryptKey struct {
    88  	KeyGeneration int     `codec:"KeyGeneration" json:"KeyGeneration"`
    89  	Key           Bytes32 `codec:"Key" json:"Key"`
    90  }
    91  
    92  func (o CryptKey) DeepCopy() CryptKey {
    93  	return CryptKey{
    94  		KeyGeneration: o.KeyGeneration,
    95  		Key:           o.Key.DeepCopy(),
    96  	}
    97  }
    98  
    99  type TLFBreak struct {
   100  	Breaks []TLFIdentifyFailure `codec:"breaks" json:"breaks"`
   101  }
   102  
   103  func (o TLFBreak) DeepCopy() TLFBreak {
   104  	return TLFBreak{
   105  		Breaks: (func(x []TLFIdentifyFailure) []TLFIdentifyFailure {
   106  			if x == nil {
   107  				return nil
   108  			}
   109  			ret := make([]TLFIdentifyFailure, len(x))
   110  			for i, v := range x {
   111  				vCopy := v.DeepCopy()
   112  				ret[i] = vCopy
   113  			}
   114  			return ret
   115  		})(o.Breaks),
   116  	}
   117  }
   118  
   119  type TLFIdentifyFailure struct {
   120  	User   User                 `codec:"user" json:"user"`
   121  	Breaks *IdentifyTrackBreaks `codec:"breaks,omitempty" json:"breaks,omitempty"`
   122  }
   123  
   124  func (o TLFIdentifyFailure) DeepCopy() TLFIdentifyFailure {
   125  	return TLFIdentifyFailure{
   126  		User: o.User.DeepCopy(),
   127  		Breaks: (func(x *IdentifyTrackBreaks) *IdentifyTrackBreaks {
   128  			if x == nil {
   129  				return nil
   130  			}
   131  			tmp := (*x).DeepCopy()
   132  			return &tmp
   133  		})(o.Breaks),
   134  	}
   135  }
   136  
   137  type CanonicalTLFNameAndIDWithBreaks struct {
   138  	TlfID         TLFID            `codec:"tlfID" json:"tlfID"`
   139  	CanonicalName CanonicalTlfName `codec:"CanonicalName" json:"CanonicalName"`
   140  	Breaks        TLFBreak         `codec:"breaks" json:"breaks"`
   141  }
   142  
   143  func (o CanonicalTLFNameAndIDWithBreaks) DeepCopy() CanonicalTLFNameAndIDWithBreaks {
   144  	return CanonicalTLFNameAndIDWithBreaks{
   145  		TlfID:         o.TlfID.DeepCopy(),
   146  		CanonicalName: o.CanonicalName.DeepCopy(),
   147  		Breaks:        o.Breaks.DeepCopy(),
   148  	}
   149  }
   150  
   151  type GetTLFCryptKeysRes struct {
   152  	NameIDBreaks CanonicalTLFNameAndIDWithBreaks `codec:"nameIDBreaks" json:"nameIDBreaks"`
   153  	CryptKeys    []CryptKey                      `codec:"CryptKeys" json:"CryptKeys"`
   154  }
   155  
   156  func (o GetTLFCryptKeysRes) DeepCopy() GetTLFCryptKeysRes {
   157  	return GetTLFCryptKeysRes{
   158  		NameIDBreaks: o.NameIDBreaks.DeepCopy(),
   159  		CryptKeys: (func(x []CryptKey) []CryptKey {
   160  			if x == nil {
   161  				return nil
   162  			}
   163  			ret := make([]CryptKey, len(x))
   164  			for i, v := range x {
   165  				vCopy := v.DeepCopy()
   166  				ret[i] = vCopy
   167  			}
   168  			return ret
   169  		})(o.CryptKeys),
   170  	}
   171  }
   172  
   173  type TLFQuery struct {
   174  	TlfName          string              `codec:"tlfName" json:"tlfName"`
   175  	IdentifyBehavior TLFIdentifyBehavior `codec:"identifyBehavior" json:"identifyBehavior"`
   176  }
   177  
   178  func (o TLFQuery) DeepCopy() TLFQuery {
   179  	return TLFQuery{
   180  		TlfName:          o.TlfName,
   181  		IdentifyBehavior: o.IdentifyBehavior.DeepCopy(),
   182  	}
   183  }
   184  
   185  type GetTLFCryptKeysArg struct {
   186  	Query TLFQuery `codec:"query" json:"query"`
   187  }
   188  
   189  type GetPublicCanonicalTLFNameAndIDArg struct {
   190  	Query TLFQuery `codec:"query" json:"query"`
   191  }
   192  
   193  type TlfKeysInterface interface {
   194  	// getTLFCryptKeys returns TLF crypt keys from all generations and the TLF ID.
   195  	// TLF ID should not be cached or stored persistently.
   196  	GetTLFCryptKeys(context.Context, TLFQuery) (GetTLFCryptKeysRes, error)
   197  	// getPublicCanonicalTLFNameAndID return the canonical name and TLFID for tlfName.
   198  	// TLF ID should not be cached or stored persistently.
   199  	GetPublicCanonicalTLFNameAndID(context.Context, TLFQuery) (CanonicalTLFNameAndIDWithBreaks, error)
   200  }
   201  
   202  func TlfKeysProtocol(i TlfKeysInterface) rpc.Protocol {
   203  	return rpc.Protocol{
   204  		Name: "keybase.1.tlfKeys",
   205  		Methods: map[string]rpc.ServeHandlerDescription{
   206  			"getTLFCryptKeys": {
   207  				MakeArg: func() interface{} {
   208  					var ret [1]GetTLFCryptKeysArg
   209  					return &ret
   210  				},
   211  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   212  					typedArgs, ok := args.(*[1]GetTLFCryptKeysArg)
   213  					if !ok {
   214  						err = rpc.NewTypeError((*[1]GetTLFCryptKeysArg)(nil), args)
   215  						return
   216  					}
   217  					ret, err = i.GetTLFCryptKeys(ctx, typedArgs[0].Query)
   218  					return
   219  				},
   220  			},
   221  			"getPublicCanonicalTLFNameAndID": {
   222  				MakeArg: func() interface{} {
   223  					var ret [1]GetPublicCanonicalTLFNameAndIDArg
   224  					return &ret
   225  				},
   226  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   227  					typedArgs, ok := args.(*[1]GetPublicCanonicalTLFNameAndIDArg)
   228  					if !ok {
   229  						err = rpc.NewTypeError((*[1]GetPublicCanonicalTLFNameAndIDArg)(nil), args)
   230  						return
   231  					}
   232  					ret, err = i.GetPublicCanonicalTLFNameAndID(ctx, typedArgs[0].Query)
   233  					return
   234  				},
   235  			},
   236  		},
   237  	}
   238  }
   239  
   240  type TlfKeysClient struct {
   241  	Cli rpc.GenericClient
   242  }
   243  
   244  // getTLFCryptKeys returns TLF crypt keys from all generations and the TLF ID.
   245  // TLF ID should not be cached or stored persistently.
   246  func (c TlfKeysClient) GetTLFCryptKeys(ctx context.Context, query TLFQuery) (res GetTLFCryptKeysRes, err error) {
   247  	__arg := GetTLFCryptKeysArg{Query: query}
   248  	err = c.Cli.Call(ctx, "keybase.1.tlfKeys.getTLFCryptKeys", []interface{}{__arg}, &res, 0*time.Millisecond)
   249  	return
   250  }
   251  
   252  // getPublicCanonicalTLFNameAndID return the canonical name and TLFID for tlfName.
   253  // TLF ID should not be cached or stored persistently.
   254  func (c TlfKeysClient) GetPublicCanonicalTLFNameAndID(ctx context.Context, query TLFQuery) (res CanonicalTLFNameAndIDWithBreaks, err error) {
   255  	__arg := GetPublicCanonicalTLFNameAndIDArg{Query: query}
   256  	err = c.Cli.Call(ctx, "keybase.1.tlfKeys.getPublicCanonicalTLFNameAndID", []interface{}{__arg}, &res, 0*time.Millisecond)
   257  	return
   258  }