github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/protocol/keybase1/provision_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/provision_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 ProvisionMethod int 14 15 const ( 16 ProvisionMethod_DEVICE ProvisionMethod = 0 17 ProvisionMethod_PAPER_KEY ProvisionMethod = 1 18 ProvisionMethod_PASSPHRASE ProvisionMethod = 2 19 ProvisionMethod_GPG_IMPORT ProvisionMethod = 3 20 ProvisionMethod_GPG_SIGN ProvisionMethod = 4 21 ) 22 23 func (o ProvisionMethod) DeepCopy() ProvisionMethod { return o } 24 25 var ProvisionMethodMap = map[string]ProvisionMethod{ 26 "DEVICE": 0, 27 "PAPER_KEY": 1, 28 "PASSPHRASE": 2, 29 "GPG_IMPORT": 3, 30 "GPG_SIGN": 4, 31 } 32 33 var ProvisionMethodRevMap = map[ProvisionMethod]string{ 34 0: "DEVICE", 35 1: "PAPER_KEY", 36 2: "PASSPHRASE", 37 3: "GPG_IMPORT", 38 4: "GPG_SIGN", 39 } 40 41 func (e ProvisionMethod) String() string { 42 if v, ok := ProvisionMethodRevMap[e]; ok { 43 return v 44 } 45 return fmt.Sprintf("%v", int(e)) 46 } 47 48 type GPGMethod int 49 50 const ( 51 GPGMethod_GPG_NONE GPGMethod = 0 52 GPGMethod_GPG_IMPORT GPGMethod = 1 53 GPGMethod_GPG_SIGN GPGMethod = 2 54 ) 55 56 func (o GPGMethod) DeepCopy() GPGMethod { return o } 57 58 var GPGMethodMap = map[string]GPGMethod{ 59 "GPG_NONE": 0, 60 "GPG_IMPORT": 1, 61 "GPG_SIGN": 2, 62 } 63 64 var GPGMethodRevMap = map[GPGMethod]string{ 65 0: "GPG_NONE", 66 1: "GPG_IMPORT", 67 2: "GPG_SIGN", 68 } 69 70 func (e GPGMethod) String() string { 71 if v, ok := GPGMethodRevMap[e]; ok { 72 return v 73 } 74 return fmt.Sprintf("%v", int(e)) 75 } 76 77 type ChooseType int 78 79 const ( 80 ChooseType_EXISTING_DEVICE ChooseType = 0 81 ChooseType_NEW_DEVICE ChooseType = 1 82 ) 83 84 func (o ChooseType) DeepCopy() ChooseType { return o } 85 86 var ChooseTypeMap = map[string]ChooseType{ 87 "EXISTING_DEVICE": 0, 88 "NEW_DEVICE": 1, 89 } 90 91 var ChooseTypeRevMap = map[ChooseType]string{ 92 0: "EXISTING_DEVICE", 93 1: "NEW_DEVICE", 94 } 95 96 func (e ChooseType) String() string { 97 if v, ok := ChooseTypeRevMap[e]; ok { 98 return v 99 } 100 return fmt.Sprintf("%v", int(e)) 101 } 102 103 // SecretResponse should be returned by DisplayAndPromptSecret. Use either secret or phrase. 104 type SecretResponse struct { 105 Secret []byte `codec:"secret" json:"secret"` 106 Phrase string `codec:"phrase" json:"phrase"` 107 } 108 109 func (o SecretResponse) DeepCopy() SecretResponse { 110 return SecretResponse{ 111 Secret: (func(x []byte) []byte { 112 if x == nil { 113 return nil 114 } 115 return append([]byte{}, x...) 116 })(o.Secret), 117 Phrase: o.Phrase, 118 } 119 } 120 121 type ChooseProvisioningMethodArg struct { 122 SessionID int `codec:"sessionID" json:"sessionID"` 123 GpgOption bool `codec:"gpgOption" json:"gpgOption"` 124 } 125 126 type ChooseGPGMethodArg struct { 127 SessionID int `codec:"sessionID" json:"sessionID"` 128 Keys []GPGKey `codec:"keys" json:"keys"` 129 } 130 131 type SwitchToGPGSignOKArg struct { 132 SessionID int `codec:"sessionID" json:"sessionID"` 133 Key GPGKey `codec:"key" json:"key"` 134 ImportError string `codec:"importError" json:"importError"` 135 } 136 137 type ChooseDeviceArg struct { 138 SessionID int `codec:"sessionID" json:"sessionID"` 139 Devices []Device `codec:"devices" json:"devices"` 140 CanSelectNoDevice bool `codec:"canSelectNoDevice" json:"canSelectNoDevice"` 141 } 142 143 type ChooseDeviceTypeArg struct { 144 SessionID int `codec:"sessionID" json:"sessionID"` 145 Kind ChooseType `codec:"kind" json:"kind"` 146 } 147 148 type DisplayAndPromptSecretArg struct { 149 SessionID int `codec:"sessionID" json:"sessionID"` 150 Secret []byte `codec:"secret" json:"secret"` 151 Phrase string `codec:"phrase" json:"phrase"` 152 OtherDeviceType DeviceType `codec:"otherDeviceType" json:"otherDeviceType"` 153 PreviousErr string `codec:"previousErr" json:"previousErr"` 154 } 155 156 type DisplaySecretExchangedArg struct { 157 SessionID int `codec:"sessionID" json:"sessionID"` 158 } 159 160 type PromptNewDeviceNameArg struct { 161 SessionID int `codec:"sessionID" json:"sessionID"` 162 ExistingDevices []string `codec:"existingDevices" json:"existingDevices"` 163 ErrorMessage string `codec:"errorMessage" json:"errorMessage"` 164 } 165 166 type ProvisioneeSuccessArg struct { 167 SessionID int `codec:"sessionID" json:"sessionID"` 168 Username string `codec:"username" json:"username"` 169 DeviceName string `codec:"deviceName" json:"deviceName"` 170 } 171 172 type ProvisionerSuccessArg struct { 173 SessionID int `codec:"sessionID" json:"sessionID"` 174 DeviceName string `codec:"deviceName" json:"deviceName"` 175 DeviceType DeviceTypeV2 `codec:"deviceType" json:"deviceType"` 176 } 177 178 type ProvisionUiInterface interface { 179 // DEPRECATED: 180 // Called during device provisioning for the user to select a 181 // method for provisioning. gpgOption will be true if GPG 182 // should be offered as an option. 183 ChooseProvisioningMethod(context.Context, ChooseProvisioningMethodArg) (ProvisionMethod, error) 184 // Called during device provisioning for the user to select a 185 // GPG method, either import the key into keybase's local keyring 186 // or use GPG to sign a provisioning statement. 187 // 188 // The keys are provided for display purposes, so the UI can 189 // do something like "We found the following GPG keys on this 190 // machine. How would you like to use one of them to provision 191 // this device?" 192 // 193 // After this, gpg_ui.selectKey will be called (if there are 194 // multiple keys available). 195 ChooseGPGMethod(context.Context, ChooseGPGMethodArg) (GPGMethod, error) 196 // If there was an error importing a gpg key into the local 197 // keyring, tell the user and offer to switch to GPG signing 198 // with this key. Return true to switch to GPG signing, 199 // false to abort provisioning. 200 SwitchToGPGSignOK(context.Context, SwitchToGPGSignOKArg) (bool, error) 201 ChooseDevice(context.Context, ChooseDeviceArg) (DeviceID, error) 202 // If provisioning via device, this will be called so user can select the provisioner/provisionee device type: desktop or mobile. 203 // If selecting the existing device type, set kind to EXISTING_DEVICE_0. 204 // If selecting the new device type, set kind to NEW_DEVICE_1. 205 ChooseDeviceType(context.Context, ChooseDeviceTypeArg) (DeviceType, error) 206 // DisplayAndPromptSecret displays a secret that the user can enter into the other device. 207 // It also can return a secret that the user enters into this device (from the other device). 208 // If it does not return a secret, it will be canceled when this device receives the secret via kex2. 209 // If there is an error in the phrase, then previousErr will be set when this is called again. 210 DisplayAndPromptSecret(context.Context, DisplayAndPromptSecretArg) (SecretResponse, error) 211 // DisplaySecretExchanged is called when the kex2 secret has successfully been exchanged by the two 212 // devices. 213 DisplaySecretExchanged(context.Context, int) error 214 // PromptNewDeviceName is called when the device provisioning process needs a name for the new device. 215 // To help the clients not send a duplicate name, existingDevices is populated with the current device 216 // names for the user. If the device name returned to the service is invalid or already 217 // taken, it will call this again with an error message in errorMessage. 218 PromptNewDeviceName(context.Context, PromptNewDeviceNameArg) (string, error) 219 // ProvisioneeSuccess is called on provisionee when it is successfully provisioned. 220 ProvisioneeSuccess(context.Context, ProvisioneeSuccessArg) error 221 // ProvisionerSuccess is called on provisioner when it successfully provisions another device. 222 ProvisionerSuccess(context.Context, ProvisionerSuccessArg) error 223 } 224 225 func ProvisionUiProtocol(i ProvisionUiInterface) rpc.Protocol { 226 return rpc.Protocol{ 227 Name: "keybase.1.provisionUi", 228 Methods: map[string]rpc.ServeHandlerDescription{ 229 "chooseProvisioningMethod": { 230 MakeArg: func() interface{} { 231 var ret [1]ChooseProvisioningMethodArg 232 return &ret 233 }, 234 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 235 typedArgs, ok := args.(*[1]ChooseProvisioningMethodArg) 236 if !ok { 237 err = rpc.NewTypeError((*[1]ChooseProvisioningMethodArg)(nil), args) 238 return 239 } 240 ret, err = i.ChooseProvisioningMethod(ctx, typedArgs[0]) 241 return 242 }, 243 }, 244 "chooseGPGMethod": { 245 MakeArg: func() interface{} { 246 var ret [1]ChooseGPGMethodArg 247 return &ret 248 }, 249 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 250 typedArgs, ok := args.(*[1]ChooseGPGMethodArg) 251 if !ok { 252 err = rpc.NewTypeError((*[1]ChooseGPGMethodArg)(nil), args) 253 return 254 } 255 ret, err = i.ChooseGPGMethod(ctx, typedArgs[0]) 256 return 257 }, 258 }, 259 "switchToGPGSignOK": { 260 MakeArg: func() interface{} { 261 var ret [1]SwitchToGPGSignOKArg 262 return &ret 263 }, 264 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 265 typedArgs, ok := args.(*[1]SwitchToGPGSignOKArg) 266 if !ok { 267 err = rpc.NewTypeError((*[1]SwitchToGPGSignOKArg)(nil), args) 268 return 269 } 270 ret, err = i.SwitchToGPGSignOK(ctx, typedArgs[0]) 271 return 272 }, 273 }, 274 "chooseDevice": { 275 MakeArg: func() interface{} { 276 var ret [1]ChooseDeviceArg 277 return &ret 278 }, 279 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 280 typedArgs, ok := args.(*[1]ChooseDeviceArg) 281 if !ok { 282 err = rpc.NewTypeError((*[1]ChooseDeviceArg)(nil), args) 283 return 284 } 285 ret, err = i.ChooseDevice(ctx, typedArgs[0]) 286 return 287 }, 288 }, 289 "chooseDeviceType": { 290 MakeArg: func() interface{} { 291 var ret [1]ChooseDeviceTypeArg 292 return &ret 293 }, 294 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 295 typedArgs, ok := args.(*[1]ChooseDeviceTypeArg) 296 if !ok { 297 err = rpc.NewTypeError((*[1]ChooseDeviceTypeArg)(nil), args) 298 return 299 } 300 ret, err = i.ChooseDeviceType(ctx, typedArgs[0]) 301 return 302 }, 303 }, 304 "DisplayAndPromptSecret": { 305 MakeArg: func() interface{} { 306 var ret [1]DisplayAndPromptSecretArg 307 return &ret 308 }, 309 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 310 typedArgs, ok := args.(*[1]DisplayAndPromptSecretArg) 311 if !ok { 312 err = rpc.NewTypeError((*[1]DisplayAndPromptSecretArg)(nil), args) 313 return 314 } 315 ret, err = i.DisplayAndPromptSecret(ctx, typedArgs[0]) 316 return 317 }, 318 }, 319 "DisplaySecretExchanged": { 320 MakeArg: func() interface{} { 321 var ret [1]DisplaySecretExchangedArg 322 return &ret 323 }, 324 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 325 typedArgs, ok := args.(*[1]DisplaySecretExchangedArg) 326 if !ok { 327 err = rpc.NewTypeError((*[1]DisplaySecretExchangedArg)(nil), args) 328 return 329 } 330 err = i.DisplaySecretExchanged(ctx, typedArgs[0].SessionID) 331 return 332 }, 333 }, 334 "PromptNewDeviceName": { 335 MakeArg: func() interface{} { 336 var ret [1]PromptNewDeviceNameArg 337 return &ret 338 }, 339 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 340 typedArgs, ok := args.(*[1]PromptNewDeviceNameArg) 341 if !ok { 342 err = rpc.NewTypeError((*[1]PromptNewDeviceNameArg)(nil), args) 343 return 344 } 345 ret, err = i.PromptNewDeviceName(ctx, typedArgs[0]) 346 return 347 }, 348 }, 349 "ProvisioneeSuccess": { 350 MakeArg: func() interface{} { 351 var ret [1]ProvisioneeSuccessArg 352 return &ret 353 }, 354 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 355 typedArgs, ok := args.(*[1]ProvisioneeSuccessArg) 356 if !ok { 357 err = rpc.NewTypeError((*[1]ProvisioneeSuccessArg)(nil), args) 358 return 359 } 360 err = i.ProvisioneeSuccess(ctx, typedArgs[0]) 361 return 362 }, 363 }, 364 "ProvisionerSuccess": { 365 MakeArg: func() interface{} { 366 var ret [1]ProvisionerSuccessArg 367 return &ret 368 }, 369 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 370 typedArgs, ok := args.(*[1]ProvisionerSuccessArg) 371 if !ok { 372 err = rpc.NewTypeError((*[1]ProvisionerSuccessArg)(nil), args) 373 return 374 } 375 err = i.ProvisionerSuccess(ctx, typedArgs[0]) 376 return 377 }, 378 }, 379 }, 380 } 381 } 382 383 type ProvisionUiClient struct { 384 Cli rpc.GenericClient 385 } 386 387 // DEPRECATED: 388 // Called during device provisioning for the user to select a 389 // method for provisioning. gpgOption will be true if GPG 390 // should be offered as an option. 391 func (c ProvisionUiClient) ChooseProvisioningMethod(ctx context.Context, __arg ChooseProvisioningMethodArg) (res ProvisionMethod, err error) { 392 err = c.Cli.Call(ctx, "keybase.1.provisionUi.chooseProvisioningMethod", []interface{}{__arg}, &res, 0*time.Millisecond) 393 return 394 } 395 396 // Called during device provisioning for the user to select a 397 // GPG method, either import the key into keybase's local keyring 398 // or use GPG to sign a provisioning statement. 399 // 400 // The keys are provided for display purposes, so the UI can 401 // do something like "We found the following GPG keys on this 402 // machine. How would you like to use one of them to provision 403 // this device?" 404 // 405 // After this, gpg_ui.selectKey will be called (if there are 406 // multiple keys available). 407 func (c ProvisionUiClient) ChooseGPGMethod(ctx context.Context, __arg ChooseGPGMethodArg) (res GPGMethod, err error) { 408 err = c.Cli.Call(ctx, "keybase.1.provisionUi.chooseGPGMethod", []interface{}{__arg}, &res, 0*time.Millisecond) 409 return 410 } 411 412 // If there was an error importing a gpg key into the local 413 // keyring, tell the user and offer to switch to GPG signing 414 // with this key. Return true to switch to GPG signing, 415 // false to abort provisioning. 416 func (c ProvisionUiClient) SwitchToGPGSignOK(ctx context.Context, __arg SwitchToGPGSignOKArg) (res bool, err error) { 417 err = c.Cli.Call(ctx, "keybase.1.provisionUi.switchToGPGSignOK", []interface{}{__arg}, &res, 0*time.Millisecond) 418 return 419 } 420 421 func (c ProvisionUiClient) ChooseDevice(ctx context.Context, __arg ChooseDeviceArg) (res DeviceID, err error) { 422 err = c.Cli.Call(ctx, "keybase.1.provisionUi.chooseDevice", []interface{}{__arg}, &res, 0*time.Millisecond) 423 return 424 } 425 426 // If provisioning via device, this will be called so user can select the provisioner/provisionee device type: desktop or mobile. 427 // If selecting the existing device type, set kind to EXISTING_DEVICE_0. 428 // If selecting the new device type, set kind to NEW_DEVICE_1. 429 func (c ProvisionUiClient) ChooseDeviceType(ctx context.Context, __arg ChooseDeviceTypeArg) (res DeviceType, err error) { 430 err = c.Cli.Call(ctx, "keybase.1.provisionUi.chooseDeviceType", []interface{}{__arg}, &res, 0*time.Millisecond) 431 return 432 } 433 434 // DisplayAndPromptSecret displays a secret that the user can enter into the other device. 435 // It also can return a secret that the user enters into this device (from the other device). 436 // If it does not return a secret, it will be canceled when this device receives the secret via kex2. 437 // If there is an error in the phrase, then previousErr will be set when this is called again. 438 func (c ProvisionUiClient) DisplayAndPromptSecret(ctx context.Context, __arg DisplayAndPromptSecretArg) (res SecretResponse, err error) { 439 err = c.Cli.Call(ctx, "keybase.1.provisionUi.DisplayAndPromptSecret", []interface{}{__arg}, &res, 0*time.Millisecond) 440 return 441 } 442 443 // DisplaySecretExchanged is called when the kex2 secret has successfully been exchanged by the two 444 // devices. 445 func (c ProvisionUiClient) DisplaySecretExchanged(ctx context.Context, sessionID int) (err error) { 446 __arg := DisplaySecretExchangedArg{SessionID: sessionID} 447 err = c.Cli.Call(ctx, "keybase.1.provisionUi.DisplaySecretExchanged", []interface{}{__arg}, nil, 0*time.Millisecond) 448 return 449 } 450 451 // PromptNewDeviceName is called when the device provisioning process needs a name for the new device. 452 // To help the clients not send a duplicate name, existingDevices is populated with the current device 453 // names for the user. If the device name returned to the service is invalid or already 454 // taken, it will call this again with an error message in errorMessage. 455 func (c ProvisionUiClient) PromptNewDeviceName(ctx context.Context, __arg PromptNewDeviceNameArg) (res string, err error) { 456 err = c.Cli.Call(ctx, "keybase.1.provisionUi.PromptNewDeviceName", []interface{}{__arg}, &res, 0*time.Millisecond) 457 return 458 } 459 460 // ProvisioneeSuccess is called on provisionee when it is successfully provisioned. 461 func (c ProvisionUiClient) ProvisioneeSuccess(ctx context.Context, __arg ProvisioneeSuccessArg) (err error) { 462 err = c.Cli.Call(ctx, "keybase.1.provisionUi.ProvisioneeSuccess", []interface{}{__arg}, nil, 0*time.Millisecond) 463 return 464 } 465 466 // ProvisionerSuccess is called on provisioner when it successfully provisions another device. 467 func (c ProvisionUiClient) ProvisionerSuccess(ctx context.Context, __arg ProvisionerSuccessArg) (err error) { 468 err = c.Cli.Call(ctx, "keybase.1.provisionUi.ProvisionerSuccess", []interface{}{__arg}, nil, 0*time.Millisecond) 469 return 470 }