This repository has been archived by the owner on Jul 7, 2020. It is now read-only.
forked from keybase/client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gpg_ui.go
252 lines (227 loc) · 6.78 KB
/
gpg_ui.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
// Auto-generated by avdl-compiler v1.3.19 (https://github.com/keybase/node-avdl-compiler)
// Input file: avdl/keybase1/gpg_ui.avdl
package keybase1
import (
"github.com/keybase/go-framed-msgpack-rpc/rpc"
context "golang.org/x/net/context"
)
type SelectKeyRes struct {
KeyID string `codec:"keyID" json:"keyID"`
DoSecretPush bool `codec:"doSecretPush" json:"doSecretPush"`
}
func (o SelectKeyRes) DeepCopy() SelectKeyRes {
return SelectKeyRes{
KeyID: o.KeyID,
DoSecretPush: o.DoSecretPush,
}
}
type WantToAddGPGKeyArg struct {
SessionID int `codec:"sessionID" json:"sessionID"`
}
func (o WantToAddGPGKeyArg) DeepCopy() WantToAddGPGKeyArg {
return WantToAddGPGKeyArg{
SessionID: o.SessionID,
}
}
type ConfirmDuplicateKeyChosenArg struct {
SessionID int `codec:"sessionID" json:"sessionID"`
}
func (o ConfirmDuplicateKeyChosenArg) DeepCopy() ConfirmDuplicateKeyChosenArg {
return ConfirmDuplicateKeyChosenArg{
SessionID: o.SessionID,
}
}
type SelectKeyAndPushOptionArg struct {
SessionID int `codec:"sessionID" json:"sessionID"`
Keys []GPGKey `codec:"keys" json:"keys"`
}
func (o SelectKeyAndPushOptionArg) DeepCopy() SelectKeyAndPushOptionArg {
return SelectKeyAndPushOptionArg{
SessionID: o.SessionID,
Keys: (func(x []GPGKey) []GPGKey {
var ret []GPGKey
for _, v := range x {
vCopy := v.DeepCopy()
ret = append(ret, vCopy)
}
return ret
})(o.Keys),
}
}
type SelectKeyArg struct {
SessionID int `codec:"sessionID" json:"sessionID"`
Keys []GPGKey `codec:"keys" json:"keys"`
}
func (o SelectKeyArg) DeepCopy() SelectKeyArg {
return SelectKeyArg{
SessionID: o.SessionID,
Keys: (func(x []GPGKey) []GPGKey {
var ret []GPGKey
for _, v := range x {
vCopy := v.DeepCopy()
ret = append(ret, vCopy)
}
return ret
})(o.Keys),
}
}
type SignArg struct {
Msg []byte `codec:"msg" json:"msg"`
Fingerprint []byte `codec:"fingerprint" json:"fingerprint"`
}
func (o SignArg) DeepCopy() SignArg {
return SignArg{
Msg: (func(x []byte) []byte {
if x == nil {
return nil
}
return append([]byte(nil), x...)
})(o.Msg),
Fingerprint: (func(x []byte) []byte {
if x == nil {
return nil
}
return append([]byte(nil), x...)
})(o.Fingerprint),
}
}
type GetTTYArg struct {
}
func (o GetTTYArg) DeepCopy() GetTTYArg {
return GetTTYArg{}
}
type GpgUiInterface interface {
WantToAddGPGKey(context.Context, int) (bool, error)
ConfirmDuplicateKeyChosen(context.Context, int) (bool, error)
SelectKeyAndPushOption(context.Context, SelectKeyAndPushOptionArg) (SelectKeyRes, error)
SelectKey(context.Context, SelectKeyArg) (string, error)
Sign(context.Context, SignArg) (string, error)
GetTTY(context.Context) (string, error)
}
func GpgUiProtocol(i GpgUiInterface) rpc.Protocol {
return rpc.Protocol{
Name: "keybase.1.gpgUi",
Methods: map[string]rpc.ServeHandlerDescription{
"wantToAddGPGKey": {
MakeArg: func() interface{} {
ret := make([]WantToAddGPGKeyArg, 1)
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[]WantToAddGPGKeyArg)
if !ok {
err = rpc.NewTypeError((*[]WantToAddGPGKeyArg)(nil), args)
return
}
ret, err = i.WantToAddGPGKey(ctx, (*typedArgs)[0].SessionID)
return
},
MethodType: rpc.MethodCall,
},
"confirmDuplicateKeyChosen": {
MakeArg: func() interface{} {
ret := make([]ConfirmDuplicateKeyChosenArg, 1)
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[]ConfirmDuplicateKeyChosenArg)
if !ok {
err = rpc.NewTypeError((*[]ConfirmDuplicateKeyChosenArg)(nil), args)
return
}
ret, err = i.ConfirmDuplicateKeyChosen(ctx, (*typedArgs)[0].SessionID)
return
},
MethodType: rpc.MethodCall,
},
"selectKeyAndPushOption": {
MakeArg: func() interface{} {
ret := make([]SelectKeyAndPushOptionArg, 1)
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[]SelectKeyAndPushOptionArg)
if !ok {
err = rpc.NewTypeError((*[]SelectKeyAndPushOptionArg)(nil), args)
return
}
ret, err = i.SelectKeyAndPushOption(ctx, (*typedArgs)[0])
return
},
MethodType: rpc.MethodCall,
},
"selectKey": {
MakeArg: func() interface{} {
ret := make([]SelectKeyArg, 1)
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[]SelectKeyArg)
if !ok {
err = rpc.NewTypeError((*[]SelectKeyArg)(nil), args)
return
}
ret, err = i.SelectKey(ctx, (*typedArgs)[0])
return
},
MethodType: rpc.MethodCall,
},
"sign": {
MakeArg: func() interface{} {
ret := make([]SignArg, 1)
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[]SignArg)
if !ok {
err = rpc.NewTypeError((*[]SignArg)(nil), args)
return
}
ret, err = i.Sign(ctx, (*typedArgs)[0])
return
},
MethodType: rpc.MethodCall,
},
"getTTY": {
MakeArg: func() interface{} {
ret := make([]GetTTYArg, 1)
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
ret, err = i.GetTTY(ctx)
return
},
MethodType: rpc.MethodCall,
},
},
}
}
type GpgUiClient struct {
Cli rpc.GenericClient
}
func (c GpgUiClient) WantToAddGPGKey(ctx context.Context, sessionID int) (res bool, err error) {
__arg := WantToAddGPGKeyArg{SessionID: sessionID}
err = c.Cli.Call(ctx, "keybase.1.gpgUi.wantToAddGPGKey", []interface{}{__arg}, &res)
return
}
func (c GpgUiClient) ConfirmDuplicateKeyChosen(ctx context.Context, sessionID int) (res bool, err error) {
__arg := ConfirmDuplicateKeyChosenArg{SessionID: sessionID}
err = c.Cli.Call(ctx, "keybase.1.gpgUi.confirmDuplicateKeyChosen", []interface{}{__arg}, &res)
return
}
func (c GpgUiClient) SelectKeyAndPushOption(ctx context.Context, __arg SelectKeyAndPushOptionArg) (res SelectKeyRes, err error) {
err = c.Cli.Call(ctx, "keybase.1.gpgUi.selectKeyAndPushOption", []interface{}{__arg}, &res)
return
}
func (c GpgUiClient) SelectKey(ctx context.Context, __arg SelectKeyArg) (res string, err error) {
err = c.Cli.Call(ctx, "keybase.1.gpgUi.selectKey", []interface{}{__arg}, &res)
return
}
func (c GpgUiClient) Sign(ctx context.Context, __arg SignArg) (res string, err error) {
err = c.Cli.Call(ctx, "keybase.1.gpgUi.sign", []interface{}{__arg}, &res)
return
}
func (c GpgUiClient) GetTTY(ctx context.Context) (res string, err error) {
err = c.Cli.Call(ctx, "keybase.1.gpgUi.getTTY", []interface{}{GetTTYArg{}}, &res)
return
}