github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/protocol/keybase1/rekey.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/rekey.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 TLF struct { 14 Id TLFID `codec:"id" json:"id"` 15 Name string `codec:"name" json:"name"` 16 Writers []string `codec:"writers" json:"writers"` 17 Readers []string `codec:"readers" json:"readers"` 18 IsPrivate bool `codec:"isPrivate" json:"isPrivate"` 19 } 20 21 func (o TLF) DeepCopy() TLF { 22 return TLF{ 23 Id: o.Id.DeepCopy(), 24 Name: o.Name, 25 Writers: (func(x []string) []string { 26 if x == nil { 27 return nil 28 } 29 ret := make([]string, len(x)) 30 for i, v := range x { 31 vCopy := v 32 ret[i] = vCopy 33 } 34 return ret 35 })(o.Writers), 36 Readers: (func(x []string) []string { 37 if x == nil { 38 return nil 39 } 40 ret := make([]string, len(x)) 41 for i, v := range x { 42 vCopy := v 43 ret[i] = vCopy 44 } 45 return ret 46 })(o.Readers), 47 IsPrivate: o.IsPrivate, 48 } 49 } 50 51 type ProblemTLF struct { 52 Tlf TLF `codec:"tlf" json:"tlf"` 53 Score int `codec:"score" json:"score"` 54 Solution_kids []KID `codec:"solution_kids" json:"solution_kids"` 55 } 56 57 func (o ProblemTLF) DeepCopy() ProblemTLF { 58 return ProblemTLF{ 59 Tlf: o.Tlf.DeepCopy(), 60 Score: o.Score, 61 Solution_kids: (func(x []KID) []KID { 62 if x == nil { 63 return nil 64 } 65 ret := make([]KID, len(x)) 66 for i, v := range x { 67 vCopy := v.DeepCopy() 68 ret[i] = vCopy 69 } 70 return ret 71 })(o.Solution_kids), 72 } 73 } 74 75 // ProblemSet is for a particular (user,kid) that initiated a rekey problem. 76 // This problem consists of one or more problem TLFs, which are individually scored 77 // and have attendant solutions --- devices that if they came online can rekey and 78 // solve the ProblemTLF. 79 type ProblemSet struct { 80 User User `codec:"user" json:"user"` 81 Kid KID `codec:"kid" json:"kid"` 82 Tlfs []ProblemTLF `codec:"tlfs" json:"tlfs"` 83 } 84 85 func (o ProblemSet) DeepCopy() ProblemSet { 86 return ProblemSet{ 87 User: o.User.DeepCopy(), 88 Kid: o.Kid.DeepCopy(), 89 Tlfs: (func(x []ProblemTLF) []ProblemTLF { 90 if x == nil { 91 return nil 92 } 93 ret := make([]ProblemTLF, len(x)) 94 for i, v := range x { 95 vCopy := v.DeepCopy() 96 ret[i] = vCopy 97 } 98 return ret 99 })(o.Tlfs), 100 } 101 } 102 103 type ProblemSetDevices struct { 104 ProblemSet ProblemSet `codec:"problemSet" json:"problemSet"` 105 Devices []Device `codec:"devices" json:"devices"` 106 } 107 108 func (o ProblemSetDevices) DeepCopy() ProblemSetDevices { 109 return ProblemSetDevices{ 110 ProblemSet: o.ProblemSet.DeepCopy(), 111 Devices: (func(x []Device) []Device { 112 if x == nil { 113 return nil 114 } 115 ret := make([]Device, len(x)) 116 for i, v := range x { 117 vCopy := v.DeepCopy() 118 ret[i] = vCopy 119 } 120 return ret 121 })(o.Devices), 122 } 123 } 124 125 type Outcome int 126 127 const ( 128 Outcome_NONE Outcome = 0 129 Outcome_FIXED Outcome = 1 130 Outcome_IGNORED Outcome = 2 131 ) 132 133 func (o Outcome) DeepCopy() Outcome { return o } 134 135 var OutcomeMap = map[string]Outcome{ 136 "NONE": 0, 137 "FIXED": 1, 138 "IGNORED": 2, 139 } 140 141 var OutcomeRevMap = map[Outcome]string{ 142 0: "NONE", 143 1: "FIXED", 144 2: "IGNORED", 145 } 146 147 func (e Outcome) String() string { 148 if v, ok := OutcomeRevMap[e]; ok { 149 return v 150 } 151 return fmt.Sprintf("%v", int(e)) 152 } 153 154 type RevokeWarning struct { 155 EndangeredTLFs []TLF `codec:"endangeredTLFs" json:"endangeredTLFs"` 156 } 157 158 func (o RevokeWarning) DeepCopy() RevokeWarning { 159 return RevokeWarning{ 160 EndangeredTLFs: (func(x []TLF) []TLF { 161 if x == nil { 162 return nil 163 } 164 ret := make([]TLF, len(x)) 165 for i, v := range x { 166 vCopy := v.DeepCopy() 167 ret[i] = vCopy 168 } 169 return ret 170 })(o.EndangeredTLFs), 171 } 172 } 173 174 type ShowPendingRekeyStatusArg struct { 175 SessionID int `codec:"sessionID" json:"sessionID"` 176 } 177 178 type GetPendingRekeyStatusArg struct { 179 SessionID int `codec:"sessionID" json:"sessionID"` 180 } 181 182 type DebugShowRekeyStatusArg struct { 183 SessionID int `codec:"sessionID" json:"sessionID"` 184 } 185 186 type RekeyStatusFinishArg struct { 187 SessionID int `codec:"sessionID" json:"sessionID"` 188 } 189 190 type RekeySyncArg struct { 191 SessionID int `codec:"sessionID" json:"sessionID"` 192 Force bool `codec:"force" json:"force"` 193 } 194 195 type GetRevokeWarningArg struct { 196 SessionID int `codec:"sessionID" json:"sessionID"` 197 ActingDevice DeviceID `codec:"actingDevice" json:"actingDevice"` 198 TargetDevice DeviceID `codec:"targetDevice" json:"targetDevice"` 199 } 200 201 type RekeyInterface interface { 202 // ShowPendingRekeyStatus shows either pending gregor-initiated rekey harassments 203 // or nothing if none were pending. 204 ShowPendingRekeyStatus(context.Context, int) error 205 // GetPendingRekeyStatus returns the pending ProblemSetDevices. 206 GetPendingRekeyStatus(context.Context, int) (ProblemSetDevices, error) 207 // DebugShowRekeyStatus is used by the CLI to kick off a "ShowRekeyStatus" window for 208 // the current user. 209 DebugShowRekeyStatus(context.Context, int) error 210 // RekeyStatusFinish is called when work is completed on a given RekeyStatus window. The Outcome 211 // can be Fixed or Ignored. 212 RekeyStatusFinish(context.Context, int) (Outcome, error) 213 // RekeySync flushes the current rekey loop and gets to a good stopping point 214 // to assert state. Good for race-free testing, not very useful in production. 215 // Force overrides a long-snooze. 216 RekeySync(context.Context, RekeySyncArg) error 217 // GetRevokeWarning computes the TLFs that will be endangered if actingDevice 218 // revokes targetDevice. 219 GetRevokeWarning(context.Context, GetRevokeWarningArg) (RevokeWarning, error) 220 } 221 222 func RekeyProtocol(i RekeyInterface) rpc.Protocol { 223 return rpc.Protocol{ 224 Name: "keybase.1.rekey", 225 Methods: map[string]rpc.ServeHandlerDescription{ 226 "showPendingRekeyStatus": { 227 MakeArg: func() interface{} { 228 var ret [1]ShowPendingRekeyStatusArg 229 return &ret 230 }, 231 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 232 typedArgs, ok := args.(*[1]ShowPendingRekeyStatusArg) 233 if !ok { 234 err = rpc.NewTypeError((*[1]ShowPendingRekeyStatusArg)(nil), args) 235 return 236 } 237 err = i.ShowPendingRekeyStatus(ctx, typedArgs[0].SessionID) 238 return 239 }, 240 }, 241 "getPendingRekeyStatus": { 242 MakeArg: func() interface{} { 243 var ret [1]GetPendingRekeyStatusArg 244 return &ret 245 }, 246 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 247 typedArgs, ok := args.(*[1]GetPendingRekeyStatusArg) 248 if !ok { 249 err = rpc.NewTypeError((*[1]GetPendingRekeyStatusArg)(nil), args) 250 return 251 } 252 ret, err = i.GetPendingRekeyStatus(ctx, typedArgs[0].SessionID) 253 return 254 }, 255 }, 256 "debugShowRekeyStatus": { 257 MakeArg: func() interface{} { 258 var ret [1]DebugShowRekeyStatusArg 259 return &ret 260 }, 261 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 262 typedArgs, ok := args.(*[1]DebugShowRekeyStatusArg) 263 if !ok { 264 err = rpc.NewTypeError((*[1]DebugShowRekeyStatusArg)(nil), args) 265 return 266 } 267 err = i.DebugShowRekeyStatus(ctx, typedArgs[0].SessionID) 268 return 269 }, 270 }, 271 "rekeyStatusFinish": { 272 MakeArg: func() interface{} { 273 var ret [1]RekeyStatusFinishArg 274 return &ret 275 }, 276 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 277 typedArgs, ok := args.(*[1]RekeyStatusFinishArg) 278 if !ok { 279 err = rpc.NewTypeError((*[1]RekeyStatusFinishArg)(nil), args) 280 return 281 } 282 ret, err = i.RekeyStatusFinish(ctx, typedArgs[0].SessionID) 283 return 284 }, 285 }, 286 "rekeySync": { 287 MakeArg: func() interface{} { 288 var ret [1]RekeySyncArg 289 return &ret 290 }, 291 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 292 typedArgs, ok := args.(*[1]RekeySyncArg) 293 if !ok { 294 err = rpc.NewTypeError((*[1]RekeySyncArg)(nil), args) 295 return 296 } 297 err = i.RekeySync(ctx, typedArgs[0]) 298 return 299 }, 300 }, 301 "getRevokeWarning": { 302 MakeArg: func() interface{} { 303 var ret [1]GetRevokeWarningArg 304 return &ret 305 }, 306 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 307 typedArgs, ok := args.(*[1]GetRevokeWarningArg) 308 if !ok { 309 err = rpc.NewTypeError((*[1]GetRevokeWarningArg)(nil), args) 310 return 311 } 312 ret, err = i.GetRevokeWarning(ctx, typedArgs[0]) 313 return 314 }, 315 }, 316 }, 317 } 318 } 319 320 type RekeyClient struct { 321 Cli rpc.GenericClient 322 } 323 324 // ShowPendingRekeyStatus shows either pending gregor-initiated rekey harassments 325 // or nothing if none were pending. 326 func (c RekeyClient) ShowPendingRekeyStatus(ctx context.Context, sessionID int) (err error) { 327 __arg := ShowPendingRekeyStatusArg{SessionID: sessionID} 328 err = c.Cli.Call(ctx, "keybase.1.rekey.showPendingRekeyStatus", []interface{}{__arg}, nil, 0*time.Millisecond) 329 return 330 } 331 332 // GetPendingRekeyStatus returns the pending ProblemSetDevices. 333 func (c RekeyClient) GetPendingRekeyStatus(ctx context.Context, sessionID int) (res ProblemSetDevices, err error) { 334 __arg := GetPendingRekeyStatusArg{SessionID: sessionID} 335 err = c.Cli.Call(ctx, "keybase.1.rekey.getPendingRekeyStatus", []interface{}{__arg}, &res, 0*time.Millisecond) 336 return 337 } 338 339 // DebugShowRekeyStatus is used by the CLI to kick off a "ShowRekeyStatus" window for 340 // the current user. 341 func (c RekeyClient) DebugShowRekeyStatus(ctx context.Context, sessionID int) (err error) { 342 __arg := DebugShowRekeyStatusArg{SessionID: sessionID} 343 err = c.Cli.Call(ctx, "keybase.1.rekey.debugShowRekeyStatus", []interface{}{__arg}, nil, 0*time.Millisecond) 344 return 345 } 346 347 // RekeyStatusFinish is called when work is completed on a given RekeyStatus window. The Outcome 348 // can be Fixed or Ignored. 349 func (c RekeyClient) RekeyStatusFinish(ctx context.Context, sessionID int) (res Outcome, err error) { 350 __arg := RekeyStatusFinishArg{SessionID: sessionID} 351 err = c.Cli.Call(ctx, "keybase.1.rekey.rekeyStatusFinish", []interface{}{__arg}, &res, 0*time.Millisecond) 352 return 353 } 354 355 // RekeySync flushes the current rekey loop and gets to a good stopping point 356 // to assert state. Good for race-free testing, not very useful in production. 357 // Force overrides a long-snooze. 358 func (c RekeyClient) RekeySync(ctx context.Context, __arg RekeySyncArg) (err error) { 359 err = c.Cli.Call(ctx, "keybase.1.rekey.rekeySync", []interface{}{__arg}, nil, 0*time.Millisecond) 360 return 361 } 362 363 // GetRevokeWarning computes the TLFs that will be endangered if actingDevice 364 // revokes targetDevice. 365 func (c RekeyClient) GetRevokeWarning(ctx context.Context, __arg GetRevokeWarningArg) (res RevokeWarning, err error) { 366 err = c.Cli.Call(ctx, "keybase.1.rekey.getRevokeWarning", []interface{}{__arg}, &res, 0*time.Millisecond) 367 return 368 }