/
signup.go
229 lines (207 loc) · 6.81 KB
/
signup.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
// Auto-generated by avdl-compiler v1.3.20 (https://github.com/keybase/node-avdl-compiler)
// Input file: avdl/keybase1/signup.avdl
package keybase1
import (
"github.com/keybase/go-framed-msgpack-rpc/rpc"
context "golang.org/x/net/context"
)
type SignupRes struct {
PassphraseOk bool `codec:"passphraseOk" json:"passphraseOk"`
PostOk bool `codec:"postOk" json:"postOk"`
WriteOk bool `codec:"writeOk" json:"writeOk"`
}
func (o SignupRes) DeepCopy() SignupRes {
return SignupRes{
PassphraseOk: o.PassphraseOk,
PostOk: o.PostOk,
WriteOk: o.WriteOk,
}
}
type CheckUsernameAvailableArg struct {
SessionID int `codec:"sessionID" json:"sessionID"`
Username string `codec:"username" json:"username"`
}
func (o CheckUsernameAvailableArg) DeepCopy() CheckUsernameAvailableArg {
return CheckUsernameAvailableArg{
SessionID: o.SessionID,
Username: o.Username,
}
}
type SignupArg struct {
SessionID int `codec:"sessionID" json:"sessionID"`
Email string `codec:"email" json:"email"`
InviteCode string `codec:"inviteCode" json:"inviteCode"`
Passphrase string `codec:"passphrase" json:"passphrase"`
Username string `codec:"username" json:"username"`
DeviceName string `codec:"deviceName" json:"deviceName"`
DeviceType DeviceType `codec:"deviceType" json:"deviceType"`
StoreSecret bool `codec:"storeSecret" json:"storeSecret"`
SkipMail bool `codec:"skipMail" json:"skipMail"`
GenPGPBatch bool `codec:"genPGPBatch" json:"genPGPBatch"`
GenPaper bool `codec:"genPaper" json:"genPaper"`
}
func (o SignupArg) DeepCopy() SignupArg {
return SignupArg{
SessionID: o.SessionID,
Email: o.Email,
InviteCode: o.InviteCode,
Passphrase: o.Passphrase,
Username: o.Username,
DeviceName: o.DeviceName,
DeviceType: o.DeviceType.DeepCopy(),
StoreSecret: o.StoreSecret,
SkipMail: o.SkipMail,
GenPGPBatch: o.GenPGPBatch,
GenPaper: o.GenPaper,
}
}
type InviteRequestArg struct {
SessionID int `codec:"sessionID" json:"sessionID"`
Email string `codec:"email" json:"email"`
Fullname string `codec:"fullname" json:"fullname"`
Notes string `codec:"notes" json:"notes"`
}
func (o InviteRequestArg) DeepCopy() InviteRequestArg {
return InviteRequestArg{
SessionID: o.SessionID,
Email: o.Email,
Fullname: o.Fullname,
Notes: o.Notes,
}
}
type CheckInvitationCodeArg struct {
SessionID int `codec:"sessionID" json:"sessionID"`
InvitationCode string `codec:"invitationCode" json:"invitationCode"`
}
func (o CheckInvitationCodeArg) DeepCopy() CheckInvitationCodeArg {
return CheckInvitationCodeArg{
SessionID: o.SessionID,
InvitationCode: o.InvitationCode,
}
}
type GetInvitationCodeArg struct {
SessionID int `codec:"sessionID" json:"sessionID"`
}
func (o GetInvitationCodeArg) DeepCopy() GetInvitationCodeArg {
return GetInvitationCodeArg{
SessionID: o.SessionID,
}
}
type SignupInterface interface {
CheckUsernameAvailable(context.Context, CheckUsernameAvailableArg) error
Signup(context.Context, SignupArg) (SignupRes, error)
InviteRequest(context.Context, InviteRequestArg) error
CheckInvitationCode(context.Context, CheckInvitationCodeArg) error
GetInvitationCode(context.Context, int) (string, error)
}
func SignupProtocol(i SignupInterface) rpc.Protocol {
return rpc.Protocol{
Name: "keybase.1.signup",
Methods: map[string]rpc.ServeHandlerDescription{
"checkUsernameAvailable": {
MakeArg: func() interface{} {
ret := make([]CheckUsernameAvailableArg, 1)
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[]CheckUsernameAvailableArg)
if !ok {
err = rpc.NewTypeError((*[]CheckUsernameAvailableArg)(nil), args)
return
}
err = i.CheckUsernameAvailable(ctx, (*typedArgs)[0])
return
},
MethodType: rpc.MethodCall,
},
"signup": {
MakeArg: func() interface{} {
ret := make([]SignupArg, 1)
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[]SignupArg)
if !ok {
err = rpc.NewTypeError((*[]SignupArg)(nil), args)
return
}
ret, err = i.Signup(ctx, (*typedArgs)[0])
return
},
MethodType: rpc.MethodCall,
},
"inviteRequest": {
MakeArg: func() interface{} {
ret := make([]InviteRequestArg, 1)
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[]InviteRequestArg)
if !ok {
err = rpc.NewTypeError((*[]InviteRequestArg)(nil), args)
return
}
err = i.InviteRequest(ctx, (*typedArgs)[0])
return
},
MethodType: rpc.MethodCall,
},
"checkInvitationCode": {
MakeArg: func() interface{} {
ret := make([]CheckInvitationCodeArg, 1)
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[]CheckInvitationCodeArg)
if !ok {
err = rpc.NewTypeError((*[]CheckInvitationCodeArg)(nil), args)
return
}
err = i.CheckInvitationCode(ctx, (*typedArgs)[0])
return
},
MethodType: rpc.MethodCall,
},
"getInvitationCode": {
MakeArg: func() interface{} {
ret := make([]GetInvitationCodeArg, 1)
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[]GetInvitationCodeArg)
if !ok {
err = rpc.NewTypeError((*[]GetInvitationCodeArg)(nil), args)
return
}
ret, err = i.GetInvitationCode(ctx, (*typedArgs)[0].SessionID)
return
},
MethodType: rpc.MethodCall,
},
},
}
}
type SignupClient struct {
Cli rpc.GenericClient
}
func (c SignupClient) CheckUsernameAvailable(ctx context.Context, __arg CheckUsernameAvailableArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.signup.checkUsernameAvailable", []interface{}{__arg}, nil)
return
}
func (c SignupClient) Signup(ctx context.Context, __arg SignupArg) (res SignupRes, err error) {
err = c.Cli.Call(ctx, "keybase.1.signup.signup", []interface{}{__arg}, &res)
return
}
func (c SignupClient) InviteRequest(ctx context.Context, __arg InviteRequestArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.signup.inviteRequest", []interface{}{__arg}, nil)
return
}
func (c SignupClient) CheckInvitationCode(ctx context.Context, __arg CheckInvitationCodeArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.signup.checkInvitationCode", []interface{}{__arg}, nil)
return
}
func (c SignupClient) GetInvitationCode(ctx context.Context, sessionID int) (res string, err error) {
__arg := GetInvitationCodeArg{SessionID: sessionID}
err = c.Cli.Call(ctx, "keybase.1.signup.getInvitationCode", []interface{}{__arg}, &res)
return
}