github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/protocol/keybase1/account.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/account.avdl 3 4 package keybase1 5 6 import ( 7 gregor1 "github.com/keybase/client/go/protocol/gregor1" 8 "github.com/keybase/go-framed-msgpack-rpc/rpc" 9 context "golang.org/x/net/context" 10 "time" 11 ) 12 13 type HasServerKeysRes struct { 14 HasServerKeys bool `codec:"hasServerKeys" json:"hasServerKeys"` 15 } 16 17 func (o HasServerKeysRes) DeepCopy() HasServerKeysRes { 18 return HasServerKeysRes{ 19 HasServerKeys: o.HasServerKeys, 20 } 21 } 22 23 type LockdownHistory struct { 24 Status bool `codec:"status" json:"status"` 25 CreationTime Time `codec:"creationTime" json:"ctime"` 26 DeviceID DeviceID `codec:"deviceID" json:"device_id"` 27 DeviceName string `codec:"deviceName" json:"deviceName"` 28 } 29 30 func (o LockdownHistory) DeepCopy() LockdownHistory { 31 return LockdownHistory{ 32 Status: o.Status, 33 CreationTime: o.CreationTime.DeepCopy(), 34 DeviceID: o.DeviceID.DeepCopy(), 35 DeviceName: o.DeviceName, 36 } 37 } 38 39 type GetLockdownResponse struct { 40 History []LockdownHistory `codec:"history" json:"history"` 41 Status bool `codec:"status" json:"status"` 42 } 43 44 func (o GetLockdownResponse) DeepCopy() GetLockdownResponse { 45 return GetLockdownResponse{ 46 History: (func(x []LockdownHistory) []LockdownHistory { 47 if x == nil { 48 return nil 49 } 50 ret := make([]LockdownHistory, len(x)) 51 for i, v := range x { 52 vCopy := v.DeepCopy() 53 ret[i] = vCopy 54 } 55 return ret 56 })(o.History), 57 Status: o.Status, 58 } 59 } 60 61 type TeamContactSettings struct { 62 TeamID TeamID `codec:"teamID" json:"team_id"` 63 Enabled bool `codec:"enabled" json:"enabled"` 64 } 65 66 func (o TeamContactSettings) DeepCopy() TeamContactSettings { 67 return TeamContactSettings{ 68 TeamID: o.TeamID.DeepCopy(), 69 Enabled: o.Enabled, 70 } 71 } 72 73 type ContactSettings struct { 74 Version *int `codec:"version,omitempty" json:"version,omitempty"` 75 AllowFolloweeDegrees int `codec:"allowFolloweeDegrees" json:"allow_followee_degrees"` 76 AllowGoodTeams bool `codec:"allowGoodTeams" json:"allow_good_teams"` 77 Enabled bool `codec:"enabled" json:"enabled"` 78 Teams []TeamContactSettings `codec:"teams" json:"teams"` 79 } 80 81 func (o ContactSettings) DeepCopy() ContactSettings { 82 return ContactSettings{ 83 Version: (func(x *int) *int { 84 if x == nil { 85 return nil 86 } 87 tmp := (*x) 88 return &tmp 89 })(o.Version), 90 AllowFolloweeDegrees: o.AllowFolloweeDegrees, 91 AllowGoodTeams: o.AllowGoodTeams, 92 Enabled: o.Enabled, 93 Teams: (func(x []TeamContactSettings) []TeamContactSettings { 94 if x == nil { 95 return nil 96 } 97 ret := make([]TeamContactSettings, len(x)) 98 for i, v := range x { 99 vCopy := v.DeepCopy() 100 ret[i] = vCopy 101 } 102 return ret 103 })(o.Teams), 104 } 105 } 106 107 type PassphraseChangeArg struct { 108 SessionID int `codec:"sessionID" json:"sessionID"` 109 OldPassphrase string `codec:"oldPassphrase" json:"oldPassphrase"` 110 Passphrase string `codec:"passphrase" json:"passphrase"` 111 Force bool `codec:"force" json:"force"` 112 } 113 114 type PassphrasePromptArg struct { 115 SessionID int `codec:"sessionID" json:"sessionID"` 116 GuiArg GUIEntryArg `codec:"guiArg" json:"guiArg"` 117 } 118 119 type PassphraseCheckArg struct { 120 SessionID int `codec:"sessionID" json:"sessionID"` 121 Passphrase string `codec:"passphrase" json:"passphrase"` 122 } 123 124 type EmailChangeArg struct { 125 SessionID int `codec:"sessionID" json:"sessionID"` 126 NewEmail string `codec:"newEmail" json:"newEmail"` 127 } 128 129 type HasServerKeysArg struct { 130 SessionID int `codec:"sessionID" json:"sessionID"` 131 } 132 133 type ResetAccountArg struct { 134 SessionID int `codec:"sessionID" json:"sessionID"` 135 Passphrase string `codec:"passphrase" json:"passphrase"` 136 } 137 138 type GetLockdownModeArg struct { 139 SessionID int `codec:"sessionID" json:"sessionID"` 140 } 141 142 type SetLockdownModeArg struct { 143 SessionID int `codec:"sessionID" json:"sessionID"` 144 Enabled bool `codec:"enabled" json:"enabled"` 145 } 146 147 type RecoverUsernameWithEmailArg struct { 148 SessionID int `codec:"sessionID" json:"sessionID"` 149 Email string `codec:"email" json:"email"` 150 } 151 152 type RecoverUsernameWithPhoneArg struct { 153 SessionID int `codec:"sessionID" json:"sessionID"` 154 Phone PhoneNumber `codec:"phone" json:"phone"` 155 } 156 157 type EnterResetPipelineArg struct { 158 SessionID int `codec:"sessionID" json:"sessionID"` 159 UsernameOrEmail string `codec:"usernameOrEmail" json:"usernameOrEmail"` 160 Passphrase string `codec:"passphrase" json:"passphrase"` 161 Interactive bool `codec:"interactive" json:"interactive"` 162 } 163 164 type CancelResetArg struct { 165 SessionID int `codec:"sessionID" json:"sessionID"` 166 } 167 168 type TimeTravelResetArg struct { 169 SessionID int `codec:"sessionID" json:"sessionID"` 170 Username string `codec:"username" json:"username"` 171 Duration gregor1.DurationSec `codec:"duration" json:"duration"` 172 } 173 174 type GuessCurrentLocationArg struct { 175 SessionID int `codec:"sessionID" json:"sessionID"` 176 DefaultCountry string `codec:"defaultCountry" json:"defaultCountry"` 177 } 178 179 type UserGetContactSettingsArg struct { 180 } 181 182 type UserSetContactSettingsArg struct { 183 Settings ContactSettings `codec:"settings" json:"settings"` 184 } 185 186 type AccountInterface interface { 187 // Change the passphrase from old to new. If old isn't set, and force is false, 188 // then prompt at the UI for it. If old isn't set and force is true, then 189 // we'll try to force a passphrase change. 190 PassphraseChange(context.Context, PassphraseChangeArg) error 191 PassphrasePrompt(context.Context, PassphrasePromptArg) (GetPassphraseRes, error) 192 // * Check if user passphrase matches argument. Launches SecretUI prompt if 193 // * passphrase argument is empty. Returns `true` if passphrase is correct, 194 // * false if not, or an error if something else went wrong. 195 PassphraseCheck(context.Context, PassphraseCheckArg) (bool, error) 196 // * change email to the new given email by signing a statement. 197 EmailChange(context.Context, EmailChangeArg) error 198 // * Whether the logged-in user has uploaded private keys 199 // * Will error if not logged in. 200 HasServerKeys(context.Context, int) (HasServerKeysRes, error) 201 // resetAccount resets the user's account. It is used in the CLI. 202 // passphrase is optional and will be prompted for if not supplied. 203 ResetAccount(context.Context, ResetAccountArg) error 204 GetLockdownMode(context.Context, int) (GetLockdownResponse, error) 205 SetLockdownMode(context.Context, SetLockdownModeArg) error 206 RecoverUsernameWithEmail(context.Context, RecoverUsernameWithEmailArg) error 207 RecoverUsernameWithPhone(context.Context, RecoverUsernameWithPhoneArg) error 208 // Start reset process for the user based on their username or email. If 209 // neither are known the user will be prompted for their passphrase to start 210 // the process. 211 // TODO: change this to just username 212 EnterResetPipeline(context.Context, EnterResetPipelineArg) error 213 // Aborts the reset process 214 CancelReset(context.Context, int) error 215 TimeTravelReset(context.Context, TimeTravelResetArg) error 216 GuessCurrentLocation(context.Context, GuessCurrentLocationArg) (string, error) 217 UserGetContactSettings(context.Context) (ContactSettings, error) 218 UserSetContactSettings(context.Context, ContactSettings) error 219 } 220 221 func AccountProtocol(i AccountInterface) rpc.Protocol { 222 return rpc.Protocol{ 223 Name: "keybase.1.account", 224 Methods: map[string]rpc.ServeHandlerDescription{ 225 "passphraseChange": { 226 MakeArg: func() interface{} { 227 var ret [1]PassphraseChangeArg 228 return &ret 229 }, 230 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 231 typedArgs, ok := args.(*[1]PassphraseChangeArg) 232 if !ok { 233 err = rpc.NewTypeError((*[1]PassphraseChangeArg)(nil), args) 234 return 235 } 236 err = i.PassphraseChange(ctx, typedArgs[0]) 237 return 238 }, 239 }, 240 "passphrasePrompt": { 241 MakeArg: func() interface{} { 242 var ret [1]PassphrasePromptArg 243 return &ret 244 }, 245 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 246 typedArgs, ok := args.(*[1]PassphrasePromptArg) 247 if !ok { 248 err = rpc.NewTypeError((*[1]PassphrasePromptArg)(nil), args) 249 return 250 } 251 ret, err = i.PassphrasePrompt(ctx, typedArgs[0]) 252 return 253 }, 254 }, 255 "passphraseCheck": { 256 MakeArg: func() interface{} { 257 var ret [1]PassphraseCheckArg 258 return &ret 259 }, 260 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 261 typedArgs, ok := args.(*[1]PassphraseCheckArg) 262 if !ok { 263 err = rpc.NewTypeError((*[1]PassphraseCheckArg)(nil), args) 264 return 265 } 266 ret, err = i.PassphraseCheck(ctx, typedArgs[0]) 267 return 268 }, 269 }, 270 "emailChange": { 271 MakeArg: func() interface{} { 272 var ret [1]EmailChangeArg 273 return &ret 274 }, 275 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 276 typedArgs, ok := args.(*[1]EmailChangeArg) 277 if !ok { 278 err = rpc.NewTypeError((*[1]EmailChangeArg)(nil), args) 279 return 280 } 281 err = i.EmailChange(ctx, typedArgs[0]) 282 return 283 }, 284 }, 285 "hasServerKeys": { 286 MakeArg: func() interface{} { 287 var ret [1]HasServerKeysArg 288 return &ret 289 }, 290 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 291 typedArgs, ok := args.(*[1]HasServerKeysArg) 292 if !ok { 293 err = rpc.NewTypeError((*[1]HasServerKeysArg)(nil), args) 294 return 295 } 296 ret, err = i.HasServerKeys(ctx, typedArgs[0].SessionID) 297 return 298 }, 299 }, 300 "resetAccount": { 301 MakeArg: func() interface{} { 302 var ret [1]ResetAccountArg 303 return &ret 304 }, 305 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 306 typedArgs, ok := args.(*[1]ResetAccountArg) 307 if !ok { 308 err = rpc.NewTypeError((*[1]ResetAccountArg)(nil), args) 309 return 310 } 311 err = i.ResetAccount(ctx, typedArgs[0]) 312 return 313 }, 314 }, 315 "getLockdownMode": { 316 MakeArg: func() interface{} { 317 var ret [1]GetLockdownModeArg 318 return &ret 319 }, 320 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 321 typedArgs, ok := args.(*[1]GetLockdownModeArg) 322 if !ok { 323 err = rpc.NewTypeError((*[1]GetLockdownModeArg)(nil), args) 324 return 325 } 326 ret, err = i.GetLockdownMode(ctx, typedArgs[0].SessionID) 327 return 328 }, 329 }, 330 "setLockdownMode": { 331 MakeArg: func() interface{} { 332 var ret [1]SetLockdownModeArg 333 return &ret 334 }, 335 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 336 typedArgs, ok := args.(*[1]SetLockdownModeArg) 337 if !ok { 338 err = rpc.NewTypeError((*[1]SetLockdownModeArg)(nil), args) 339 return 340 } 341 err = i.SetLockdownMode(ctx, typedArgs[0]) 342 return 343 }, 344 }, 345 "recoverUsernameWithEmail": { 346 MakeArg: func() interface{} { 347 var ret [1]RecoverUsernameWithEmailArg 348 return &ret 349 }, 350 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 351 typedArgs, ok := args.(*[1]RecoverUsernameWithEmailArg) 352 if !ok { 353 err = rpc.NewTypeError((*[1]RecoverUsernameWithEmailArg)(nil), args) 354 return 355 } 356 err = i.RecoverUsernameWithEmail(ctx, typedArgs[0]) 357 return 358 }, 359 }, 360 "recoverUsernameWithPhone": { 361 MakeArg: func() interface{} { 362 var ret [1]RecoverUsernameWithPhoneArg 363 return &ret 364 }, 365 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 366 typedArgs, ok := args.(*[1]RecoverUsernameWithPhoneArg) 367 if !ok { 368 err = rpc.NewTypeError((*[1]RecoverUsernameWithPhoneArg)(nil), args) 369 return 370 } 371 err = i.RecoverUsernameWithPhone(ctx, typedArgs[0]) 372 return 373 }, 374 }, 375 "enterResetPipeline": { 376 MakeArg: func() interface{} { 377 var ret [1]EnterResetPipelineArg 378 return &ret 379 }, 380 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 381 typedArgs, ok := args.(*[1]EnterResetPipelineArg) 382 if !ok { 383 err = rpc.NewTypeError((*[1]EnterResetPipelineArg)(nil), args) 384 return 385 } 386 err = i.EnterResetPipeline(ctx, typedArgs[0]) 387 return 388 }, 389 }, 390 "cancelReset": { 391 MakeArg: func() interface{} { 392 var ret [1]CancelResetArg 393 return &ret 394 }, 395 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 396 typedArgs, ok := args.(*[1]CancelResetArg) 397 if !ok { 398 err = rpc.NewTypeError((*[1]CancelResetArg)(nil), args) 399 return 400 } 401 err = i.CancelReset(ctx, typedArgs[0].SessionID) 402 return 403 }, 404 }, 405 "timeTravelReset": { 406 MakeArg: func() interface{} { 407 var ret [1]TimeTravelResetArg 408 return &ret 409 }, 410 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 411 typedArgs, ok := args.(*[1]TimeTravelResetArg) 412 if !ok { 413 err = rpc.NewTypeError((*[1]TimeTravelResetArg)(nil), args) 414 return 415 } 416 err = i.TimeTravelReset(ctx, typedArgs[0]) 417 return 418 }, 419 }, 420 "guessCurrentLocation": { 421 MakeArg: func() interface{} { 422 var ret [1]GuessCurrentLocationArg 423 return &ret 424 }, 425 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 426 typedArgs, ok := args.(*[1]GuessCurrentLocationArg) 427 if !ok { 428 err = rpc.NewTypeError((*[1]GuessCurrentLocationArg)(nil), args) 429 return 430 } 431 ret, err = i.GuessCurrentLocation(ctx, typedArgs[0]) 432 return 433 }, 434 }, 435 "userGetContactSettings": { 436 MakeArg: func() interface{} { 437 var ret [1]UserGetContactSettingsArg 438 return &ret 439 }, 440 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 441 ret, err = i.UserGetContactSettings(ctx) 442 return 443 }, 444 }, 445 "userSetContactSettings": { 446 MakeArg: func() interface{} { 447 var ret [1]UserSetContactSettingsArg 448 return &ret 449 }, 450 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 451 typedArgs, ok := args.(*[1]UserSetContactSettingsArg) 452 if !ok { 453 err = rpc.NewTypeError((*[1]UserSetContactSettingsArg)(nil), args) 454 return 455 } 456 err = i.UserSetContactSettings(ctx, typedArgs[0].Settings) 457 return 458 }, 459 }, 460 }, 461 } 462 } 463 464 type AccountClient struct { 465 Cli rpc.GenericClient 466 } 467 468 // Change the passphrase from old to new. If old isn't set, and force is false, 469 // then prompt at the UI for it. If old isn't set and force is true, then 470 // we'll try to force a passphrase change. 471 func (c AccountClient) PassphraseChange(ctx context.Context, __arg PassphraseChangeArg) (err error) { 472 err = c.Cli.Call(ctx, "keybase.1.account.passphraseChange", []interface{}{__arg}, nil, 0*time.Millisecond) 473 return 474 } 475 476 func (c AccountClient) PassphrasePrompt(ctx context.Context, __arg PassphrasePromptArg) (res GetPassphraseRes, err error) { 477 err = c.Cli.Call(ctx, "keybase.1.account.passphrasePrompt", []interface{}{__arg}, &res, 0*time.Millisecond) 478 return 479 } 480 481 // * Check if user passphrase matches argument. Launches SecretUI prompt if 482 // * passphrase argument is empty. Returns `true` if passphrase is correct, 483 // * false if not, or an error if something else went wrong. 484 func (c AccountClient) PassphraseCheck(ctx context.Context, __arg PassphraseCheckArg) (res bool, err error) { 485 err = c.Cli.Call(ctx, "keybase.1.account.passphraseCheck", []interface{}{__arg}, &res, 0*time.Millisecond) 486 return 487 } 488 489 // * change email to the new given email by signing a statement. 490 func (c AccountClient) EmailChange(ctx context.Context, __arg EmailChangeArg) (err error) { 491 err = c.Cli.Call(ctx, "keybase.1.account.emailChange", []interface{}{__arg}, nil, 0*time.Millisecond) 492 return 493 } 494 495 // * Whether the logged-in user has uploaded private keys 496 // * Will error if not logged in. 497 func (c AccountClient) HasServerKeys(ctx context.Context, sessionID int) (res HasServerKeysRes, err error) { 498 __arg := HasServerKeysArg{SessionID: sessionID} 499 err = c.Cli.Call(ctx, "keybase.1.account.hasServerKeys", []interface{}{__arg}, &res, 0*time.Millisecond) 500 return 501 } 502 503 // resetAccount resets the user's account. It is used in the CLI. 504 // passphrase is optional and will be prompted for if not supplied. 505 func (c AccountClient) ResetAccount(ctx context.Context, __arg ResetAccountArg) (err error) { 506 err = c.Cli.Call(ctx, "keybase.1.account.resetAccount", []interface{}{__arg}, nil, 0*time.Millisecond) 507 return 508 } 509 510 func (c AccountClient) GetLockdownMode(ctx context.Context, sessionID int) (res GetLockdownResponse, err error) { 511 __arg := GetLockdownModeArg{SessionID: sessionID} 512 err = c.Cli.Call(ctx, "keybase.1.account.getLockdownMode", []interface{}{__arg}, &res, 0*time.Millisecond) 513 return 514 } 515 516 func (c AccountClient) SetLockdownMode(ctx context.Context, __arg SetLockdownModeArg) (err error) { 517 err = c.Cli.Call(ctx, "keybase.1.account.setLockdownMode", []interface{}{__arg}, nil, 0*time.Millisecond) 518 return 519 } 520 521 func (c AccountClient) RecoverUsernameWithEmail(ctx context.Context, __arg RecoverUsernameWithEmailArg) (err error) { 522 err = c.Cli.Call(ctx, "keybase.1.account.recoverUsernameWithEmail", []interface{}{__arg}, nil, 0*time.Millisecond) 523 return 524 } 525 526 func (c AccountClient) RecoverUsernameWithPhone(ctx context.Context, __arg RecoverUsernameWithPhoneArg) (err error) { 527 err = c.Cli.Call(ctx, "keybase.1.account.recoverUsernameWithPhone", []interface{}{__arg}, nil, 0*time.Millisecond) 528 return 529 } 530 531 // Start reset process for the user based on their username or email. If 532 // neither are known the user will be prompted for their passphrase to start 533 // the process. 534 // TODO: change this to just username 535 func (c AccountClient) EnterResetPipeline(ctx context.Context, __arg EnterResetPipelineArg) (err error) { 536 err = c.Cli.Call(ctx, "keybase.1.account.enterResetPipeline", []interface{}{__arg}, nil, 0*time.Millisecond) 537 return 538 } 539 540 // Aborts the reset process 541 func (c AccountClient) CancelReset(ctx context.Context, sessionID int) (err error) { 542 __arg := CancelResetArg{SessionID: sessionID} 543 err = c.Cli.Call(ctx, "keybase.1.account.cancelReset", []interface{}{__arg}, nil, 0*time.Millisecond) 544 return 545 } 546 547 func (c AccountClient) TimeTravelReset(ctx context.Context, __arg TimeTravelResetArg) (err error) { 548 err = c.Cli.Call(ctx, "keybase.1.account.timeTravelReset", []interface{}{__arg}, nil, 0*time.Millisecond) 549 return 550 } 551 552 func (c AccountClient) GuessCurrentLocation(ctx context.Context, __arg GuessCurrentLocationArg) (res string, err error) { 553 err = c.Cli.Call(ctx, "keybase.1.account.guessCurrentLocation", []interface{}{__arg}, &res, 0*time.Millisecond) 554 return 555 } 556 557 func (c AccountClient) UserGetContactSettings(ctx context.Context) (res ContactSettings, err error) { 558 err = c.Cli.Call(ctx, "keybase.1.account.userGetContactSettings", []interface{}{UserGetContactSettingsArg{}}, &res, 0*time.Millisecond) 559 return 560 } 561 562 func (c AccountClient) UserSetContactSettings(ctx context.Context, settings ContactSettings) (err error) { 563 __arg := UserSetContactSettingsArg{Settings: settings} 564 err = c.Cli.Call(ctx, "keybase.1.account.userSetContactSettings", []interface{}{__arg}, nil, 0*time.Millisecond) 565 return 566 }