-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
tlf_keys.go
258 lines (229 loc) · 7.6 KB
/
tlf_keys.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
253
254
255
256
257
258
// Auto-generated to Go types and interfaces using avdl-compiler v1.4.10 (https://github.com/keybase/node-avdl-compiler)
// Input file: avdl/keybase1/tlf_keys.avdl
package keybase1
import (
"fmt"
"github.com/keybase/go-framed-msgpack-rpc/rpc"
context "golang.org/x/net/context"
"time"
)
type TLFIdentifyBehavior int
const (
TLFIdentifyBehavior_UNSET TLFIdentifyBehavior = 0
TLFIdentifyBehavior_CHAT_CLI TLFIdentifyBehavior = 1
TLFIdentifyBehavior_CHAT_GUI TLFIdentifyBehavior = 2
TLFIdentifyBehavior_REMOVED_AND_UNUSED TLFIdentifyBehavior = 3
TLFIdentifyBehavior_KBFS_REKEY TLFIdentifyBehavior = 4
TLFIdentifyBehavior_KBFS_QR TLFIdentifyBehavior = 5
TLFIdentifyBehavior_CHAT_SKIP TLFIdentifyBehavior = 6
TLFIdentifyBehavior_SALTPACK TLFIdentifyBehavior = 7
TLFIdentifyBehavior_CLI TLFIdentifyBehavior = 8
TLFIdentifyBehavior_GUI TLFIdentifyBehavior = 9
TLFIdentifyBehavior_DEFAULT_KBFS TLFIdentifyBehavior = 10
TLFIdentifyBehavior_KBFS_CHAT TLFIdentifyBehavior = 11
TLFIdentifyBehavior_RESOLVE_AND_CHECK TLFIdentifyBehavior = 12
TLFIdentifyBehavior_GUI_PROFILE TLFIdentifyBehavior = 13
TLFIdentifyBehavior_KBFS_INIT TLFIdentifyBehavior = 14
TLFIdentifyBehavior_FS_GUI TLFIdentifyBehavior = 15
)
func (o TLFIdentifyBehavior) DeepCopy() TLFIdentifyBehavior { return o }
var TLFIdentifyBehaviorMap = map[string]TLFIdentifyBehavior{
"UNSET": 0,
"CHAT_CLI": 1,
"CHAT_GUI": 2,
"REMOVED_AND_UNUSED": 3,
"KBFS_REKEY": 4,
"KBFS_QR": 5,
"CHAT_SKIP": 6,
"SALTPACK": 7,
"CLI": 8,
"GUI": 9,
"DEFAULT_KBFS": 10,
"KBFS_CHAT": 11,
"RESOLVE_AND_CHECK": 12,
"GUI_PROFILE": 13,
"KBFS_INIT": 14,
"FS_GUI": 15,
}
var TLFIdentifyBehaviorRevMap = map[TLFIdentifyBehavior]string{
0: "UNSET",
1: "CHAT_CLI",
2: "CHAT_GUI",
3: "REMOVED_AND_UNUSED",
4: "KBFS_REKEY",
5: "KBFS_QR",
6: "CHAT_SKIP",
7: "SALTPACK",
8: "CLI",
9: "GUI",
10: "DEFAULT_KBFS",
11: "KBFS_CHAT",
12: "RESOLVE_AND_CHECK",
13: "GUI_PROFILE",
14: "KBFS_INIT",
15: "FS_GUI",
}
func (e TLFIdentifyBehavior) String() string {
if v, ok := TLFIdentifyBehaviorRevMap[e]; ok {
return v
}
return fmt.Sprintf("%v", int(e))
}
type CanonicalTlfName string
func (o CanonicalTlfName) DeepCopy() CanonicalTlfName {
return o
}
type CryptKey struct {
KeyGeneration int `codec:"KeyGeneration" json:"KeyGeneration"`
Key Bytes32 `codec:"Key" json:"Key"`
}
func (o CryptKey) DeepCopy() CryptKey {
return CryptKey{
KeyGeneration: o.KeyGeneration,
Key: o.Key.DeepCopy(),
}
}
type TLFBreak struct {
Breaks []TLFIdentifyFailure `codec:"breaks" json:"breaks"`
}
func (o TLFBreak) DeepCopy() TLFBreak {
return TLFBreak{
Breaks: (func(x []TLFIdentifyFailure) []TLFIdentifyFailure {
if x == nil {
return nil
}
ret := make([]TLFIdentifyFailure, len(x))
for i, v := range x {
vCopy := v.DeepCopy()
ret[i] = vCopy
}
return ret
})(o.Breaks),
}
}
type TLFIdentifyFailure struct {
User User `codec:"user" json:"user"`
Breaks *IdentifyTrackBreaks `codec:"breaks,omitempty" json:"breaks,omitempty"`
}
func (o TLFIdentifyFailure) DeepCopy() TLFIdentifyFailure {
return TLFIdentifyFailure{
User: o.User.DeepCopy(),
Breaks: (func(x *IdentifyTrackBreaks) *IdentifyTrackBreaks {
if x == nil {
return nil
}
tmp := (*x).DeepCopy()
return &tmp
})(o.Breaks),
}
}
type CanonicalTLFNameAndIDWithBreaks struct {
TlfID TLFID `codec:"tlfID" json:"tlfID"`
CanonicalName CanonicalTlfName `codec:"CanonicalName" json:"CanonicalName"`
Breaks TLFBreak `codec:"breaks" json:"breaks"`
}
func (o CanonicalTLFNameAndIDWithBreaks) DeepCopy() CanonicalTLFNameAndIDWithBreaks {
return CanonicalTLFNameAndIDWithBreaks{
TlfID: o.TlfID.DeepCopy(),
CanonicalName: o.CanonicalName.DeepCopy(),
Breaks: o.Breaks.DeepCopy(),
}
}
type GetTLFCryptKeysRes struct {
NameIDBreaks CanonicalTLFNameAndIDWithBreaks `codec:"nameIDBreaks" json:"nameIDBreaks"`
CryptKeys []CryptKey `codec:"CryptKeys" json:"CryptKeys"`
}
func (o GetTLFCryptKeysRes) DeepCopy() GetTLFCryptKeysRes {
return GetTLFCryptKeysRes{
NameIDBreaks: o.NameIDBreaks.DeepCopy(),
CryptKeys: (func(x []CryptKey) []CryptKey {
if x == nil {
return nil
}
ret := make([]CryptKey, len(x))
for i, v := range x {
vCopy := v.DeepCopy()
ret[i] = vCopy
}
return ret
})(o.CryptKeys),
}
}
type TLFQuery struct {
TlfName string `codec:"tlfName" json:"tlfName"`
IdentifyBehavior TLFIdentifyBehavior `codec:"identifyBehavior" json:"identifyBehavior"`
}
func (o TLFQuery) DeepCopy() TLFQuery {
return TLFQuery{
TlfName: o.TlfName,
IdentifyBehavior: o.IdentifyBehavior.DeepCopy(),
}
}
type GetTLFCryptKeysArg struct {
Query TLFQuery `codec:"query" json:"query"`
}
type GetPublicCanonicalTLFNameAndIDArg struct {
Query TLFQuery `codec:"query" json:"query"`
}
type TlfKeysInterface interface {
// getTLFCryptKeys returns TLF crypt keys from all generations and the TLF ID.
// TLF ID should not be cached or stored persistently.
GetTLFCryptKeys(context.Context, TLFQuery) (GetTLFCryptKeysRes, error)
// getPublicCanonicalTLFNameAndID return the canonical name and TLFID for tlfName.
// TLF ID should not be cached or stored persistently.
GetPublicCanonicalTLFNameAndID(context.Context, TLFQuery) (CanonicalTLFNameAndIDWithBreaks, error)
}
func TlfKeysProtocol(i TlfKeysInterface) rpc.Protocol {
return rpc.Protocol{
Name: "keybase.1.tlfKeys",
Methods: map[string]rpc.ServeHandlerDescription{
"getTLFCryptKeys": {
MakeArg: func() interface{} {
var ret [1]GetTLFCryptKeysArg
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[1]GetTLFCryptKeysArg)
if !ok {
err = rpc.NewTypeError((*[1]GetTLFCryptKeysArg)(nil), args)
return
}
ret, err = i.GetTLFCryptKeys(ctx, typedArgs[0].Query)
return
},
},
"getPublicCanonicalTLFNameAndID": {
MakeArg: func() interface{} {
var ret [1]GetPublicCanonicalTLFNameAndIDArg
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[1]GetPublicCanonicalTLFNameAndIDArg)
if !ok {
err = rpc.NewTypeError((*[1]GetPublicCanonicalTLFNameAndIDArg)(nil), args)
return
}
ret, err = i.GetPublicCanonicalTLFNameAndID(ctx, typedArgs[0].Query)
return
},
},
},
}
}
type TlfKeysClient struct {
Cli rpc.GenericClient
}
// getTLFCryptKeys returns TLF crypt keys from all generations and the TLF ID.
// TLF ID should not be cached or stored persistently.
func (c TlfKeysClient) GetTLFCryptKeys(ctx context.Context, query TLFQuery) (res GetTLFCryptKeysRes, err error) {
__arg := GetTLFCryptKeysArg{Query: query}
err = c.Cli.Call(ctx, "keybase.1.tlfKeys.getTLFCryptKeys", []interface{}{__arg}, &res, 0*time.Millisecond)
return
}
// getPublicCanonicalTLFNameAndID return the canonical name and TLFID for tlfName.
// TLF ID should not be cached or stored persistently.
func (c TlfKeysClient) GetPublicCanonicalTLFNameAndID(ctx context.Context, query TLFQuery) (res CanonicalTLFNameAndIDWithBreaks, err error) {
__arg := GetPublicCanonicalTLFNameAndIDArg{Query: query}
err = c.Cli.Call(ctx, "keybase.1.tlfKeys.getPublicCanonicalTLFNameAndID", []interface{}{__arg}, &res, 0*time.Millisecond)
return
}