github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/service/revoke.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  	"github.com/keybase/client/go/engine"
     8  	"github.com/keybase/client/go/libkb"
     9  	keybase1 "github.com/keybase/client/go/protocol/keybase1"
    10  	"github.com/keybase/go-framed-msgpack-rpc/rpc"
    11  	"golang.org/x/net/context"
    12  )
    13  
    14  type RevokeHandler struct {
    15  	*BaseHandler
    16  	libkb.Contextified
    17  }
    18  
    19  func NewRevokeHandler(xp rpc.Transporter, g *libkb.GlobalContext) *RevokeHandler {
    20  	return &RevokeHandler{
    21  		BaseHandler:  NewBaseHandler(g, xp),
    22  		Contextified: libkb.NewContextified(g),
    23  	}
    24  }
    25  
    26  func (h *RevokeHandler) RevokeKey(ctx context.Context, arg keybase1.RevokeKeyArg) error {
    27  	sessionID := arg.SessionID
    28  	uis := libkb.UIs{
    29  		LogUI:     h.getLogUI(sessionID),
    30  		SecretUI:  h.getSecretUI(sessionID, h.G()),
    31  		SessionID: arg.SessionID,
    32  	}
    33  	eng := engine.NewRevokeKeyEngine(h.G(), arg.KeyID)
    34  	m := libkb.NewMetaContext(ctx, h.G()).WithUIs(uis)
    35  	return engine.RunEngine2(m, eng)
    36  }
    37  
    38  func (h *RevokeHandler) RevokeDevice(ctx context.Context, arg keybase1.RevokeDeviceArg) error {
    39  	sessionID := arg.SessionID
    40  	uis := libkb.UIs{
    41  		LogUI:     h.getLogUI(sessionID),
    42  		SecretUI:  h.getSecretUI(sessionID, h.G()),
    43  		SessionID: arg.SessionID,
    44  	}
    45  	eng := engine.NewRevokeDeviceEngine(h.G(), engine.RevokeDeviceEngineArgs{ID: arg.DeviceID, ForceSelf: arg.ForceSelf, ForceLast: arg.ForceLast})
    46  	m := libkb.NewMetaContext(ctx, h.G()).WithUIs(uis)
    47  	return engine.RunEngine2(m, eng)
    48  }
    49  
    50  func (h *RevokeHandler) RevokeSigs(ctx context.Context, arg keybase1.RevokeSigsArg) error {
    51  	uis := libkb.UIs{
    52  		LogUI:     h.getLogUI(arg.SessionID),
    53  		SecretUI:  h.getSecretUI(arg.SessionID, h.G()),
    54  		SessionID: arg.SessionID,
    55  	}
    56  	eng := engine.NewRevokeSigsEngine(h.G(), arg.SigIDQueries)
    57  	m := libkb.NewMetaContext(ctx, h.G()).WithUIs(uis)
    58  	return engine.RunEngine2(m, eng)
    59  }