github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/client/cmd_rekey_paper.go (about) 1 // Copyright 2016 Keybase, Inc. All rights reserved. Use of 2 // this source code is governed by the included BSD license. 3 4 package client 5 6 import ( 7 "golang.org/x/net/context" 8 9 "github.com/keybase/cli" 10 "github.com/keybase/client/go/libcmdline" 11 "github.com/keybase/client/go/libkb" 12 keybase1 "github.com/keybase/client/go/protocol/keybase1" 13 "github.com/keybase/go-framed-msgpack-rpc/rpc" 14 ) 15 16 type CmdRekeyPaper struct { 17 libkb.Contextified 18 } 19 20 func NewCmdRekeyPaper(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command { 21 return cli.Command{ 22 Name: "paper", 23 Usage: "Submit a paper key to help rekeying", 24 Action: func(c *cli.Context) { 25 cmd := &CmdRekeyPaper{Contextified: libkb.NewContextified(g)} 26 cl.ChooseCommand(cmd, "paper", c) 27 }, 28 } 29 } 30 31 func (c *CmdRekeyPaper) ParseArgv(ctx *cli.Context) error { 32 if len(ctx.Args()) > 0 { 33 return UnexpectedArgsError("paper") 34 } 35 return nil 36 } 37 38 func (c *CmdRekeyPaper) Run() error { 39 protocols := []rpc.Protocol{ 40 NewSecretUIProtocol(c.G()), 41 } 42 if err := RegisterProtocolsWithContext(protocols, c.G()); err != nil { 43 return err 44 } 45 46 phrase, err := PromptPaperPhrase(c.G()) 47 if err != nil { 48 return err 49 } 50 51 cli, err := GetLoginClient(c.G()) 52 if err != nil { 53 return err 54 } 55 arg := keybase1.PaperKeySubmitArg{ 56 PaperPhrase: phrase, 57 } 58 return cli.PaperKeySubmit(context.Background(), arg) 59 } 60 61 func (c *CmdRekeyPaper) GetUsage() libkb.Usage { 62 return libkb.Usage{ 63 API: true, 64 Config: true, 65 } 66 }