github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/service/secretkeys.go (about) 1 // Copyright 2015 Keybase, Inc. All rights reserved. Use of 2 // this source code is governed by the included BSD license. 3 4 package service 5 6 import ( 7 "errors" 8 9 "github.com/keybase/client/go/engine" 10 "github.com/keybase/client/go/libkb" 11 keybase1 "github.com/keybase/client/go/protocol/keybase1" 12 "github.com/keybase/go-framed-msgpack-rpc/rpc" 13 "golang.org/x/net/context" 14 ) 15 16 type SecretKeysHandler struct { 17 *BaseHandler 18 libkb.Contextified 19 } 20 21 func NewSecretKeysHandler(xp rpc.Transporter, g *libkb.GlobalContext) *SecretKeysHandler { 22 return &SecretKeysHandler{ 23 BaseHandler: NewBaseHandler(g, xp), 24 Contextified: libkb.NewContextified(g), 25 } 26 } 27 28 func (h *SecretKeysHandler) GetSecretKeys(ctx context.Context, sessionID int) (keybase1.SecretKeys, error) { 29 if h.G().Env.GetRunMode() == libkb.ProductionRunMode { 30 return keybase1.SecretKeys{}, errors.New("GetSecretKeys is a devel-only RPC") 31 } 32 uis := libkb.UIs{ 33 LogUI: h.getLogUI(sessionID), 34 SecretUI: h.getSecretUI(sessionID, h.G()), 35 SessionID: sessionID, 36 } 37 eng := engine.NewSecretKeysEngine(h.G()) 38 m := libkb.NewMetaContext(ctx, h.G()).WithUIs(uis) 39 err := engine.RunEngine2(m, eng) 40 if err != nil { 41 return keybase1.SecretKeys{}, err 42 } 43 return eng.Result(), nil 44 }