mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-07 21:47:02 +09:00
WIP invite join flow
This commit is contained in:
parent
a8699f38f9
commit
33a586c1af
7 changed files with 300 additions and 119 deletions
|
@ -351,7 +351,7 @@ func (m *AclAccountRequestJoin) GetMetadata() []byte {
|
|||
|
||||
// AclInviteJoin contains the reference to the invite record and the data of the person who wants to join, confirmed by the private invite key
|
||||
// The person must encrypt the key with its own public key
|
||||
type AclInviteJoin struct {
|
||||
type AclAccountInviteJoin struct {
|
||||
Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"`
|
||||
InviteRecordId string `protobuf:"bytes,2,opt,name=inviteRecordId,proto3" json:"inviteRecordId,omitempty"`
|
||||
InviteIdentitySignature []byte `protobuf:"bytes,3,opt,name=inviteIdentitySignature,proto3" json:"inviteIdentitySignature,omitempty"`
|
||||
|
@ -360,18 +360,18 @@ type AclInviteJoin struct {
|
|||
EncryptedReadKey []byte `protobuf:"bytes,5,opt,name=encryptedReadKey,proto3" json:"encryptedReadKey,omitempty"`
|
||||
}
|
||||
|
||||
func (m *AclInviteJoin) Reset() { *m = AclInviteJoin{} }
|
||||
func (m *AclInviteJoin) String() string { return proto.CompactTextString(m) }
|
||||
func (*AclInviteJoin) ProtoMessage() {}
|
||||
func (*AclInviteJoin) Descriptor() ([]byte, []int) {
|
||||
func (m *AclAccountInviteJoin) Reset() { *m = AclAccountInviteJoin{} }
|
||||
func (m *AclAccountInviteJoin) String() string { return proto.CompactTextString(m) }
|
||||
func (*AclAccountInviteJoin) ProtoMessage() {}
|
||||
func (*AclAccountInviteJoin) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_c8e9f754f34e929b, []int{3}
|
||||
}
|
||||
func (m *AclInviteJoin) XXX_Unmarshal(b []byte) error {
|
||||
func (m *AclAccountInviteJoin) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *AclInviteJoin) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
func (m *AclAccountInviteJoin) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_AclInviteJoin.Marshal(b, m, deterministic)
|
||||
return xxx_messageInfo_AclAccountInviteJoin.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
|
@ -381,7 +381,7 @@ func (m *AclInviteJoin) XXX_Marshal(b []byte, deterministic bool) ([]byte, error
|
|||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *AclInviteJoin) XXX_MarshalAppend(b []byte, newLen int) ([]byte, error) {
|
||||
func (m *AclAccountInviteJoin) XXX_MarshalAppend(b []byte, newLen int) ([]byte, error) {
|
||||
b = b[:newLen]
|
||||
_, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
|
@ -389,47 +389,47 @@ func (m *AclInviteJoin) XXX_MarshalAppend(b []byte, newLen int) ([]byte, error)
|
|||
}
|
||||
return b, nil
|
||||
}
|
||||
func (m *AclInviteJoin) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_AclInviteJoin.Merge(m, src)
|
||||
func (m *AclAccountInviteJoin) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_AclAccountInviteJoin.Merge(m, src)
|
||||
}
|
||||
func (m *AclInviteJoin) XXX_Size() int {
|
||||
func (m *AclAccountInviteJoin) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *AclInviteJoin) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_AclInviteJoin.DiscardUnknown(m)
|
||||
func (m *AclAccountInviteJoin) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_AclAccountInviteJoin.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_AclInviteJoin proto.InternalMessageInfo
|
||||
var xxx_messageInfo_AclAccountInviteJoin proto.InternalMessageInfo
|
||||
|
||||
func (m *AclInviteJoin) GetIdentity() []byte {
|
||||
func (m *AclAccountInviteJoin) GetIdentity() []byte {
|
||||
if m != nil {
|
||||
return m.Identity
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *AclInviteJoin) GetInviteRecordId() string {
|
||||
func (m *AclAccountInviteJoin) GetInviteRecordId() string {
|
||||
if m != nil {
|
||||
return m.InviteRecordId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *AclInviteJoin) GetInviteIdentitySignature() []byte {
|
||||
func (m *AclAccountInviteJoin) GetInviteIdentitySignature() []byte {
|
||||
if m != nil {
|
||||
return m.InviteIdentitySignature
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *AclInviteJoin) GetMetadata() []byte {
|
||||
func (m *AclAccountInviteJoin) GetMetadata() []byte {
|
||||
if m != nil {
|
||||
return m.Metadata
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *AclInviteJoin) GetEncryptedReadKey() []byte {
|
||||
func (m *AclAccountInviteJoin) GetEncryptedReadKey() []byte {
|
||||
if m != nil {
|
||||
return m.EncryptedReadKey
|
||||
}
|
||||
|
@ -1274,7 +1274,7 @@ type AclContentValue_RequestCancel struct {
|
|||
RequestCancel *AclAccountRequestCancel `protobuf:"bytes,12,opt,name=requestCancel,proto3,oneof" json:"requestCancel,omitempty"`
|
||||
}
|
||||
type AclContentValue_InviteJoin struct {
|
||||
InviteJoin *AclInviteJoin `protobuf:"bytes,13,opt,name=inviteJoin,proto3,oneof" json:"inviteJoin,omitempty"`
|
||||
InviteJoin *AclAccountInviteJoin `protobuf:"bytes,13,opt,name=inviteJoin,proto3,oneof" json:"inviteJoin,omitempty"`
|
||||
}
|
||||
|
||||
func (*AclContentValue_Invite) isAclContentValueValue() {}
|
||||
|
@ -1382,7 +1382,7 @@ func (m *AclContentValue) GetRequestCancel() *AclAccountRequestCancel {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (m *AclContentValue) GetInviteJoin() *AclInviteJoin {
|
||||
func (m *AclContentValue) GetInviteJoin() *AclAccountInviteJoin {
|
||||
if x, ok := m.GetValue().(*AclContentValue_InviteJoin); ok {
|
||||
return x.InviteJoin
|
||||
}
|
||||
|
@ -1467,7 +1467,7 @@ func init() {
|
|||
proto.RegisterType((*AclRoot)(nil), "aclrecord.AclRoot")
|
||||
proto.RegisterType((*AclAccountInvite)(nil), "aclrecord.AclAccountInvite")
|
||||
proto.RegisterType((*AclAccountRequestJoin)(nil), "aclrecord.AclAccountRequestJoin")
|
||||
proto.RegisterType((*AclInviteJoin)(nil), "aclrecord.AclInviteJoin")
|
||||
proto.RegisterType((*AclAccountInviteJoin)(nil), "aclrecord.AclAccountInviteJoin")
|
||||
proto.RegisterType((*AclAccountRequestAccept)(nil), "aclrecord.AclAccountRequestAccept")
|
||||
proto.RegisterType((*AclAccountRequestDecline)(nil), "aclrecord.AclAccountRequestDecline")
|
||||
proto.RegisterType((*AclAccountInviteRevoke)(nil), "aclrecord.AclAccountInviteRevoke")
|
||||
|
@ -1489,78 +1489,78 @@ func init() {
|
|||
}
|
||||
|
||||
var fileDescriptor_c8e9f754f34e929b = []byte{
|
||||
// 1122 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x57, 0xdf, 0x6e, 0xdb, 0x54,
|
||||
0x18, 0xb7, 0x93, 0xa6, 0x69, 0xbe, 0x34, 0x99, 0x7b, 0x06, 0x9b, 0xd7, 0x41, 0x14, 0x8c, 0x36,
|
||||
0x45, 0x15, 0x5a, 0x51, 0x50, 0xa7, 0xa9, 0x02, 0x3a, 0x2f, 0x9d, 0x96, 0x6c, 0x1a, 0x4c, 0x67,
|
||||
0x63, 0x43, 0x48, 0x20, 0xb9, 0xf6, 0xd1, 0x30, 0x38, 0xc7, 0xc1, 0x3e, 0x09, 0xca, 0x5b, 0xf0,
|
||||
0x1c, 0x70, 0xcb, 0x2d, 0xf7, 0x5c, 0x70, 0x51, 0x09, 0x21, 0x71, 0x89, 0xda, 0x27, 0xe0, 0x0d,
|
||||
0xd0, 0x39, 0x76, 0xec, 0x63, 0xc7, 0x4e, 0xd3, 0x0b, 0xb4, 0x8b, 0x36, 0xf6, 0xf7, 0xff, 0xcf,
|
||||
0xef, 0x3b, 0xdf, 0x31, 0x7c, 0x6c, 0xfb, 0xe3, 0xb1, 0x4f, 0xc3, 0x89, 0x65, 0x93, 0x7d, 0xff,
|
||||
0xe4, 0x3b, 0x62, 0xb3, 0x7d, 0xcb, 0xf6, 0xf8, 0x5f, 0x40, 0x6c, 0x3f, 0x70, 0x26, 0x81, 0xcf,
|
||||
0xfc, 0x7d, 0xf1, 0x3f, 0x4c, 0xa9, 0x77, 0x04, 0x01, 0x35, 0x12, 0x82, 0xf1, 0x6f, 0x05, 0xea,
|
||||
0xa6, 0xed, 0x61, 0xdf, 0x67, 0x68, 0x17, 0xb6, 0x5c, 0x87, 0x50, 0xe6, 0xb2, 0xb9, 0xae, 0x76,
|
||||
0xd5, 0xde, 0x36, 0x4e, 0xde, 0xd1, 0x3b, 0xd0, 0x18, 0x5b, 0x21, 0x23, 0xc1, 0x13, 0x32, 0xd7,
|
||||
0x2b, 0x82, 0x99, 0x12, 0x90, 0x0e, 0x75, 0x11, 0xca, 0xc8, 0xd1, 0xab, 0x5d, 0xb5, 0xd7, 0xc0,
|
||||
0x8b, 0x57, 0xb4, 0x07, 0x1a, 0xa1, 0x76, 0x30, 0x9f, 0x30, 0xe2, 0x60, 0x62, 0x39, 0x5c, 0x7d,
|
||||
0x43, 0xa8, 0x2f, 0xd1, 0xb9, 0x0f, 0xe6, 0x8e, 0x49, 0xc8, 0xac, 0xf1, 0x44, 0xaf, 0x75, 0xd5,
|
||||
0x5e, 0x15, 0xa7, 0x04, 0xf4, 0x01, 0xec, 0x2c, 0xa2, 0x79, 0xee, 0xbe, 0xa6, 0x16, 0x9b, 0x06,
|
||||
0x44, 0xdf, 0x14, 0xa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||
0xca, 0x1a, 0xe4, 0xfa, 0x5f, 0xb9, 0x6c, 0xff, 0x33, 0x63, 0x51, 0x5d, 0x63, 0x2c, 0x4a, 0x96,
|
||||
0x88, 0x71, 0x50, 0x30, 0x15, 0x03, 0x8b, 0xda, 0xc4, 0xe3, 0x2e, 0x82, 0x6c, 0xf3, 0x93, 0x77,
|
||||
0x63, 0x0e, 0xbb, 0xe5, 0xe5, 0xfd, 0x5f, 0x33, 0x37, 0x7e, 0xae, 0x88, 0x75, 0x10, 0x27, 0x10,
|
||||
0x7b, 0xbc, 0x0f, 0x4d, 0x2b, 0x0a, 0xe6, 0x09, 0x99, 0x2f, 0xfa, 0xd6, 0xc9, 0x5a, 0xcd, 0x83,
|
||||
0x14, 0xcb, 0x2a, 0x05, 0x1b, 0xb0, 0x72, 0xe9, 0x0d, 0x58, 0xbd, 0x60, 0x03, 0x7e, 0x08, 0x57,
|
||||
0xd3, 0x1d, 0xe7, 0xe5, 0x7a, 0x53, 0xc4, 0x42, 0x9f, 0x2e, 0x16, 0x99, 0x48, 0xab, 0xb6, 0x56,
|
||||
0x5a, 0x92, 0x86, 0x31, 0x95, 0x57, 0x27, 0x26, 0x63, 0x7f, 0x46, 0x50, 0x07, 0x20, 0xee, 0x86,
|
||||
0x1b, 0xcf, 0xcd, 0x36, 0x96, 0x28, 0xc8, 0x84, 0x56, 0x20, 0x17, 0x57, 0x14, 0xa2, 0xd9, 0xbf,
|
||||
0x99, 0x75, 0x9b, 0xa9, 0x3f, 0xce, 0x6a, 0x18, 0x37, 0x0a, 0x50, 0x15, 0x79, 0x37, 0xfe, 0xac,
|
||||
0xc3, 0x15, 0xd3, 0xf6, 0x06, 0x3e, 0x65, 0x84, 0xb2, 0x97, 0x96, 0x37, 0x25, 0xe8, 0x00, 0x36,
|
||||
0xa3, 0x98, 0x05, 0x5a, 0x96, 0x5c, 0x65, 0xce, 0xa7, 0xa1, 0x82, 0x63, 0x61, 0xf4, 0x08, 0xb6,
|
||||
0x5d, 0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||
0xce, 0x34, 0x92, 0x94, 0xa0, 0x16, 0x1f, 0xf3, 0x87, 0x8b, 0x23, 0x46, 0x60, 0xbf, 0x25, 0x0c,
|
||||
0x15, 0xde, 0x95, 0x63, 0xcc, 0x4b, 0xd2, 0x0f, 0xea, 0x50, 0x9b, 0xf1, 0x09, 0x36, 0x1e, 0x8a,
|
||||
0xcf, 0xa2, 0x63, 0xbe, 0x7d, 0x0e, 0x01, 0xac, 0x64, 0xbe, 0xe3, 0x93, 0x78, 0x37, 0x6b, 0x4f,
|
||||
0x1e, 0x7e, 0x2c, 0x49, 0xef, 0x1d, 0x48, 0x77, 0x4f, 0x71, 0x1d, 0xdf, 0x81, 0x56, 0x1c, 0xfe,
|
||||
0x0b, 0x9f, 0x7b, 0xd4, 0x14, 0x4e, 0x32, 0xe9, 0xdc, 0xa7, 0x64, 0x60, 0x51, 0x41, 0x52, 0xf7,
|
||||
0x5e, 0x01, 0x5a, 0xde, 0x1a, 0x68, 0x0b, 0x36, 0x3e, 0xf3, 0x29, 0xd1, 0x14, 0xd4, 0x80, 0x9a,
|
||||
0xf8, 0xa4, 0xd0, 0x54, 0xfe, 0x68, 0x3a, 0x63, 0x97, 0x6a, 0x15, 0x04, 0xb0, 0xf9, 0x2a, 0x70,
|
||||
0x19, 0x09, 0xb4, 0x2a, 0x7f, 0xe6, 0x90, 0x25, 0x81, 0xb6, 0xc1, 0x45, 0x1e, 0x71, 0x8f, 0x5a,
|
||||
0xed, 0xc1, 0xd1, 0xef, 0x67, 0x1d, 0xf5, 0xf4, 0xac, 0xa3, 0xfe, 0x73, 0xd6, 0x51, 0x7f, 0x3a,
|
||||
0xef, 0x28, 0xa7, 0xe7, 0x1d, 0xe5, 0xef, 0xf3, 0x8e, 0xf2, 0xd5, 0xad, 0xb5, 0xbe, 0x28, 0x4f,
|
||||
0x36, 0xc5, 0xcf, 0x47, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x48, 0xe7, 0x67, 0x87, 0x81, 0x0e,
|
||||
0x00, 0x00,
|
||||
// 1124 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x57, 0x5f, 0x6f, 0xdb, 0x54,
|
||||
0x14, 0xb7, 0x93, 0xa6, 0x69, 0x4e, 0x9a, 0xcc, 0xbd, 0x1b, 0x9b, 0xd7, 0x41, 0x08, 0x46, 0x9b,
|
||||
0xa2, 0x0a, 0xad, 0x28, 0xa8, 0xd3, 0x34, 0x01, 0x9d, 0x97, 0x4e, 0x4b, 0x36, 0x0d, 0xa6, 0xbb,
|
||||
0xb1, 0x21, 0x24, 0x90, 0x5c, 0xfb, 0x6a, 0x18, 0x9c, 0xeb, 0x60, 0xdf, 0x04, 0xe5, 0x5b, 0xf0,
|
||||
0x39, 0xe0, 0x95, 0x57, 0xde, 0x79, 0xe0, 0xa1, 0x8f, 0x08, 0xf1, 0x80, 0xda, 0x4f, 0xc0, 0x37,
|
||||
0x40, 0xf7, 0xda, 0xb1, 0xaf, 0x1d, 0x3b, 0x4d, 0x1f, 0xd0, 0x1e, 0xda, 0xf8, 0x9e, 0xff, 0xe7,
|
||||
0xfc, 0xce, 0xb9, 0xc7, 0x86, 0x8f, 0x6d, 0x7f, 0x3c, 0xf6, 0x69, 0x38, 0xb1, 0x6c, 0xb2, 0xef,
|
||||
0x1f, 0x7f, 0x47, 0x6c, 0xb6, 0x6f, 0xd9, 0x1e, 0xff, 0x0b, 0x88, 0xed, 0x07, 0xce, 0x24, 0xf0,
|
||||
0x99, 0xbf, 0x2f, 0xfe, 0x87, 0x29, 0xf5, 0xb6, 0x20, 0xa0, 0x46, 0x42, 0x30, 0xfe, 0xad, 0x40,
|
||||
0xdd, 0xb4, 0x3d, 0xec, 0xfb, 0x0c, 0xed, 0xc2, 0x96, 0xeb, 0x10, 0xca, 0x5c, 0x36, 0xd7, 0xd5,
|
||||
0xae, 0xda, 0xdb, 0xc6, 0xc9, 0x19, 0xbd, 0x0d, 0x8d, 0xb1, 0x15, 0x32, 0x12, 0x3c, 0x21, 0x73,
|
||||
0xbd, 0x22, 0x98, 0x29, 0x01, 0xe9, 0x50, 0x17, 0xa1, 0x8c, 0x1c, 0xbd, 0xda, 0x55, 0x7b, 0x0d,
|
||||
0xbc, 0x38, 0xa2, 0x3d, 0xd0, 0x08, 0xb5, 0x83, 0xf9, 0x84, 0x11, 0x07, 0x13, 0xcb, 0xe1, 0xea,
|
||||
0x1b, 0x42, 0x7d, 0x89, 0xce, 0x7d, 0x30, 0x77, 0x4c, 0x42, 0x66, 0x8d, 0x27, 0x7a, 0xad, 0xab,
|
||||
0xf6, 0xaa, 0x38, 0x25, 0xa0, 0x0f, 0x60, 0x67, 0x11, 0xcd, 0x73, 0xf7, 0x35, 0xb5, 0xd8, 0x34,
|
||||
0x20, 0xfa, 0xa6, 0x30, 0xb5, 0xcc, 0x40, 0xb7, 0xa0, 0x3d, 0x26, 0xcc, 0x72, 0x2c, 0x66, 0x3d,
|
||||
0x9b, 0x1e, 0x73, 0xaf, 0x75, 0x21, 0x9a, 0xa3, 0xa2, 0x7b, 0xa0, 0x27, 0x71, 0x3c, 0x5d, 0xb0,
|
||||
0x02, 0x77, 0xc6, 0x35, 0xb6, 0x84, 0x46, 0x29, 0x1f, 0xdd, 0x81, 0xab, 0x09, 0xef, 0xf3, 0x1f,
|
||||
0x29, 0x09, 0x16, 0x02, 0x7a, 0x43, 0x68, 0x96, 0x70, 0x8d, 0x5f, 0x54, 0xd0, 0x4c, 0xdb, 0x33,
|
||||
0x6d, 0xdb, 0x9f, 0x52, 0x36, 0xa2, 0x33, 0x97, 0x11, 0x9e, 0xbc, 0x2b, 0x9e, 0xb8, 0xe7, 0xa8,
|
||||
0xfa, 0x29, 0x01, 0xdd, 0x05, 0x88, 0x0e, 0x2f, 0xe6, 0x13, 0x22, 0xea, 0xdf, 0xee, 0xeb, 0xb7,
|
||||
0x53, 0x5c, 0x4d, 0xdb, 0x1b, 0x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0x92, 0x34, 0x8c, 0xa9, 0xbc, 0x41, 0x31, 0x19, 0xfb, 0x33, 0x82, 0x3a, 0x00, 0x31, 0x1a, 0x6e,
|
||||
0x3c, 0x37, 0xdb, 0x58, 0xa2, 0x20, 0x13, 0x5a, 0x81, 0x5c, 0x5c, 0x51, 0x88, 0x66, 0xff, 0x46,
|
||||
0xd6, 0x6d, 0xa6, 0xfe, 0x38, 0xab, 0x61, 0x5c, 0x2f, 0xe8, 0xaa, 0xc8, 0xbb, 0xf1, 0x57, 0x1d,
|
||||
0x2e, 0x99, 0xb6, 0x37, 0xf0, 0x29, 0x23, 0x94, 0xbd, 0xb4, 0xbc, 0x29, 0x41, 0x07, 0xb0, 0x19,
|
||||
0xc5, 0x2c, 0xba, 0x65, 0xc9, 0x55, 0xe6, 0x7e, 0x1a, 0x2a, 0x38, 0x16, 0x46, 0x8f, 0x60, 0xdb,
|
||||
0x95, 0xee, 0xac, 0x38, 0xce, 0xf7, 0x56, 0x28, 0x47, 0x82, 0x43, 0x05, 0x67, 0x14, 0xd1, 0x11,
|
||||
0x34, 0x83, 0x74, 0x5f, 0x0b, 0x18, 0x9b, 0xfd, 0x6e, 0xa1, 0x1d, 0x69, 0xaf, 0x0f, 0x15, 0x2c,
|
||||
0xab, 0xa1, 0xc7, 0xbc, 0x6e, 0xd2, 0x5a, 0x11, 0xb8, 0x36, 0xfb, 0xc6, 0x2a, 0x3b, 0x91, 0xe4,
|
||||
0x50, 0xc1, 0x59, 0x55, 0xf4, 0x1c, 0xb4, 0x49, 0x6e, 0xaa, 0xc4, 0x66, 0x5b, 0xf7, 0x86, 0x1b,
|
||||
0x2a, 0x78, 0xc9, 0x00, 0x1a, 0x40, 0xcb, 0x92, 0x3b, 0x41, 0xbc, 0x15, 0x96, 0x55, 0x3b, 0x12,
|
||||
0xe1, 0x91, 0x65, 0x74, 0xb8, 0x91, 0x6c, 0x77, 0xd4, 0xcf, 0xed, 0x8e, 0x28, 0x3d, 0x79, 0x5c,
|
||||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, 0xd4,
|
||||
0x80, 0x9a, 0xf8, 0xc0, 0xd0, 0x54, 0xfe, 0x68, 0x3a, 0x63, 0x97, 0x6a, 0x15, 0x04, 0xb0, 0xf9,
|
||||
0x2a, 0x70, 0x19, 0x09, 0xb4, 0x2a, 0x7f, 0xe6, 0x9d, 0x4b, 0x02, 0x6d, 0x83, 0x8b, 0x3c, 0xe2,
|
||||
0x1e, 0xb5, 0xda, 0x83, 0xc3, 0xdf, 0x4f, 0x3b, 0xea, 0xc9, 0x69, 0x47, 0xfd, 0xe7, 0xb4, 0xa3,
|
||||
0xfe, 0x74, 0xd6, 0x51, 0x4e, 0xce, 0x3a, 0xca, 0x9f, 0x67, 0x1d, 0xe5, 0xab, 0x9b, 0x6b, 0x7d,
|
||||
0x5f, 0x1e, 0x6f, 0x8a, 0x9f, 0x8f, 0xfe, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x3c, 0x5d, 0xff, 0xb8,
|
||||
0x8f, 0x0e, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *AclRoot) Marshal() (dAtA []byte, err error) {
|
||||
|
@ -1738,7 +1738,7 @@ func (m *AclAccountRequestJoin) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *AclInviteJoin) Marshal() (dAtA []byte, err error) {
|
||||
func (m *AclAccountInviteJoin) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
|
@ -1748,12 +1748,12 @@ func (m *AclInviteJoin) Marshal() (dAtA []byte, err error) {
|
|||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *AclInviteJoin) MarshalTo(dAtA []byte) (int, error) {
|
||||
func (m *AclAccountInviteJoin) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *AclInviteJoin) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
func (m *AclAccountInviteJoin) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
|
@ -2710,7 +2710,7 @@ func (m *AclAccountRequestJoin) Size() (n int) {
|
|||
return n
|
||||
}
|
||||
|
||||
func (m *AclInviteJoin) Size() (n int) {
|
||||
func (m *AclAccountInviteJoin) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
|
@ -3784,7 +3784,7 @@ func (m *AclAccountRequestJoin) Unmarshal(dAtA []byte) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
func (m *AclInviteJoin) Unmarshal(dAtA []byte) error {
|
||||
func (m *AclAccountInviteJoin) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
|
@ -3807,10 +3807,10 @@ func (m *AclInviteJoin) Unmarshal(dAtA []byte) error {
|
|||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: AclInviteJoin: wiretype end group for non-group")
|
||||
return fmt.Errorf("proto: AclAccountInviteJoin: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: AclInviteJoin: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
return fmt.Errorf("proto: AclAccountInviteJoin: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
|
@ -5843,7 +5843,7 @@ func (m *AclContentValue) Unmarshal(dAtA []byte) error {
|
|||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
v := &AclInviteJoin{}
|
||||
v := &AclAccountInviteJoin{}
|
||||
if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ message AclAccountRequestJoin {
|
|||
|
||||
// AclInviteJoin contains the reference to the invite record and the data of the person who wants to join, confirmed by the private invite key
|
||||
// The person must encrypt the key with its own public key
|
||||
message AclInviteJoin {
|
||||
message AclAccountInviteJoin {
|
||||
bytes identity = 1;
|
||||
string inviteRecordId = 2;
|
||||
bytes inviteIdentitySignature = 3;
|
||||
|
@ -137,7 +137,7 @@ message AclContentValue {
|
|||
AclAccountPermissionChanges permissionChanges = 10;
|
||||
AclAccountsAdd accountsAdd = 11;
|
||||
AclAccountRequestCancel requestCancel = 12;
|
||||
AclInviteJoin inviteJoin = 13;
|
||||
AclAccountInviteJoin inviteJoin = 13;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,12 @@ type RequestJoinPayload struct {
|
|||
Metadata []byte
|
||||
}
|
||||
|
||||
type InviteJoinPayload struct {
|
||||
InviteKey crypto.PrivKey
|
||||
ReadKey crypto.SymKey
|
||||
Metadata []byte
|
||||
}
|
||||
|
||||
type ReadKeyChangePayload struct {
|
||||
MetadataKey crypto.PrivKey
|
||||
ReadKey crypto.SymKey
|
||||
|
@ -81,6 +87,7 @@ type AclRecordBuilder interface {
|
|||
BuildRoot(content RootContent) (rec *consensusproto.RawRecordWithId, err error)
|
||||
BuildBatchRequest(payload BatchRequestPayload) (rawRecord *consensusproto.RawRecord, err error)
|
||||
BuildInvite() (res InviteResult, err error)
|
||||
BuildInviteAnyone() (res InviteResult, err error)
|
||||
BuildInviteRevoke(inviteRecordId string) (rawRecord *consensusproto.RawRecord, err error)
|
||||
BuildRequestJoin(payload RequestJoinPayload) (rawRecord *consensusproto.RawRecord, err error)
|
||||
BuildRequestAccept(payload RequestAcceptPayload) (rawRecord *consensusproto.RawRecord, err error)
|
||||
|
@ -314,6 +321,34 @@ func (a *aclRecordBuilder) BuildInvite() (res InviteResult, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func (a *aclRecordBuilder) BuildInviteAnyone() (res InviteResult, err error) {
|
||||
if !a.state.Permissions(a.state.pubKey).CanManageAccounts() {
|
||||
err = ErrInsufficientPermissions
|
||||
return
|
||||
}
|
||||
privKey, pubKey, err := crypto.GenerateRandomEd25519KeyPair()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
invitePubKey, err := pubKey.Marshall()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
inviteRec := &aclrecordproto.AclAccountInvite{
|
||||
InviteKey: invitePubKey,
|
||||
InviteType: aclrecordproto.AclInviteType_AnyoneCanJoin,
|
||||
Permissions: aclrecordproto.AclUserPermissions_Reader,
|
||||
}
|
||||
content := &aclrecordproto.AclContentValue{Value: &aclrecordproto.AclContentValue_Invite{Invite: inviteRec}}
|
||||
rawRec, err := a.buildRecord(content)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
res.InviteKey = privKey
|
||||
res.InviteRec = rawRec
|
||||
return
|
||||
}
|
||||
|
||||
func (a *aclRecordBuilder) BuildInviteRevoke(inviteRecordId string) (rawRecord *consensusproto.RawRecord, err error) {
|
||||
content, err := a.buildInviteRevoke(inviteRecordId)
|
||||
if err != nil {
|
||||
|
@ -389,6 +424,68 @@ func (a *aclRecordBuilder) BuildRequestJoin(payload RequestJoinPayload) (rawReco
|
|||
return a.buildRecord(content)
|
||||
}
|
||||
|
||||
func (a *aclRecordBuilder) BuildInviteJoin(payload InviteJoinPayload) (rawRecord *consensusproto.RawRecord, err error) {
|
||||
var inviteId string
|
||||
for id, inv := range a.state.invites {
|
||||
if inv.Key.Equals(payload.InviteKey.GetPublic()) && inv.Type == aclrecordproto.AclInviteType_AnyoneCanJoin {
|
||||
inviteId = id
|
||||
}
|
||||
}
|
||||
invite, exists := a.state.invites[inviteId]
|
||||
if !exists {
|
||||
err = ErrNoSuchInvite
|
||||
return
|
||||
}
|
||||
if !payload.InviteKey.GetPublic().Equals(invite.Key) {
|
||||
err = ErrIncorrectInviteKey
|
||||
return
|
||||
}
|
||||
if !a.state.Permissions(a.accountKeys.SignKey.GetPublic()).NoPermissions() {
|
||||
err = ErrInsufficientPermissions
|
||||
return
|
||||
}
|
||||
mkKey, err := a.state.CurrentMetadataKey()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
encMeta, err := mkKey.Encrypt(payload.Metadata)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(encMeta) > MaxMetadataLen {
|
||||
return nil, ErrMetadataTooLarge
|
||||
}
|
||||
rawIdentity, err := a.accountKeys.SignKey.GetPublic().Raw()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
signature, err := payload.InviteKey.Sign(rawIdentity)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
readKey, err := payload.ReadKey.Marshall()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
encReadKey, err := a.accountKeys.SignKey.GetPublic().Encrypt(readKey)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
protoIdentity, err := a.accountKeys.SignKey.GetPublic().Marshall()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
joinRec := &aclrecordproto.AclAccountInviteJoin{
|
||||
Identity: protoIdentity,
|
||||
InviteRecordId: inviteId,
|
||||
InviteIdentitySignature: signature,
|
||||
Metadata: encMeta,
|
||||
EncryptedReadKey: encReadKey,
|
||||
}
|
||||
content := &aclrecordproto.AclContentValue{Value: &aclrecordproto.AclContentValue_InviteJoin{InviteJoin: joinRec}}
|
||||
return a.buildRecord(content)
|
||||
}
|
||||
|
||||
func (a *aclRecordBuilder) BuildRequestAccept(payload RequestAcceptPayload) (rawRecord *consensusproto.RawRecord, err error) {
|
||||
content, err := a.buildRequestAccept(payload, nil)
|
||||
if err != nil {
|
||||
|
|
|
@ -372,6 +372,16 @@ func (a *AclTestExecutor) Execute(cmd string) (err error) {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
case "invite_anyone":
|
||||
res, err := acl.RecordBuilder().BuildInviteAnyone()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.invites[args[0]] = res.InviteKey
|
||||
err = addRec(WrapAclRecord(res.InviteRec))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
case "batch":
|
||||
afterAll, err = a.buildBatchRequest(args, acl, getPerm, addRec)
|
||||
if err != nil {
|
||||
|
|
|
@ -24,6 +24,8 @@ type AclRecord struct {
|
|||
AcceptorTimestamp int64
|
||||
Data []byte
|
||||
Identity crypto.PubKey
|
||||
AcceptorIdentity crypto.PubKey
|
||||
AcceptorSignature []byte
|
||||
Model interface{}
|
||||
Signature []byte
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package list
|
||||
|
||||
import (
|
||||
"golang.org/x/exp/slices"
|
||||
|
||||
"github.com/anyproto/any-sync/commonspace/object/acl/aclrecordproto"
|
||||
"github.com/anyproto/any-sync/util/crypto"
|
||||
)
|
||||
|
@ -11,6 +13,7 @@ type ContentValidator interface {
|
|||
ValidatePermissionChanges(ch *aclrecordproto.AclAccountPermissionChanges, authorIdentity crypto.PubKey) (err error)
|
||||
ValidateAccountsAdd(ch *aclrecordproto.AclAccountsAdd, authorIdentity crypto.PubKey) (err error)
|
||||
ValidateInvite(ch *aclrecordproto.AclAccountInvite, authorIdentity crypto.PubKey) (err error)
|
||||
ValidateInviteJoin(ch *aclrecordproto.AclInviteJoin, authorIdentity crypto.PubKey) (err error)
|
||||
ValidateInviteRevoke(ch *aclrecordproto.AclAccountInviteRevoke, authorIdentity crypto.PubKey) (err error)
|
||||
ValidateRequestJoin(ch *aclrecordproto.AclAccountRequestJoin, authorIdentity crypto.PubKey) (err error)
|
||||
ValidateRequestAccept(ch *aclrecordproto.AclAccountRequestAccept, authorIdentity crypto.PubKey) (err error)
|
||||
|
@ -66,6 +69,44 @@ func (c *contentValidator) ValidateAccountsAdd(ch *aclrecordproto.AclAccountsAdd
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c *contentValidator) ValidateInviteJoin(ch *aclrecordproto.AclInviteJoin, authorIdentity crypto.PubKey) (err error) {
|
||||
if !c.aclState.Permissions(authorIdentity).NoPermissions() {
|
||||
return ErrInsufficientPermissions
|
||||
}
|
||||
invite, exists := c.aclState.invites[ch.InviteRecordId]
|
||||
if !exists {
|
||||
return ErrNoSuchInvite
|
||||
}
|
||||
if invite.Type != aclrecordproto.AclInviteType_AnyoneCanJoin {
|
||||
return ErrNoSuchInvite
|
||||
}
|
||||
if !c.aclState.Permissions(authorIdentity).NoPermissions() {
|
||||
return ErrInsufficientPermissions
|
||||
}
|
||||
inviteIdentity, err := c.keyStore.PubKeyFromProto(ch.Identity)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if !authorIdentity.Equals(inviteIdentity) {
|
||||
return ErrIncorrectIdentity
|
||||
}
|
||||
rawInviteIdentity, err := inviteIdentity.Raw()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ok, err := invite.Key.Verify(rawInviteIdentity, ch.InviteIdentitySignature)
|
||||
if err != nil {
|
||||
return ErrInvalidSignature
|
||||
}
|
||||
if !ok {
|
||||
return ErrInvalidSignature
|
||||
}
|
||||
if len(ch.Metadata) > MaxMetadataLen {
|
||||
return ErrMetadataTooLarge
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *contentValidator) ValidateAclRecordContents(ch *AclRecord) (err error) {
|
||||
if ch.PrevId != c.aclState.lastRecordId {
|
||||
return ErrIncorrectRecordSequence
|
||||
|
@ -90,6 +131,8 @@ func (c *contentValidator) validateAclRecordContent(ch *aclrecordproto.AclConten
|
|||
return c.ValidateInviteRevoke(ch.GetInviteRevoke(), authorIdentity)
|
||||
case ch.GetRequestJoin() != nil:
|
||||
return c.ValidateRequestJoin(ch.GetRequestJoin(), authorIdentity)
|
||||
case ch.GetInviteJoin() != nil:
|
||||
return c.ValidateInviteJoin(ch.GetInviteJoin(), authorIdentity)
|
||||
case ch.GetRequestAccept() != nil:
|
||||
return c.ValidateRequestAccept(ch.GetRequestAccept(), authorIdentity)
|
||||
case ch.GetRequestDecline() != nil:
|
||||
|
@ -303,23 +346,55 @@ func (c *contentValidator) validateReadKeyChange(ch *aclrecordproto.AclReadKeyCh
|
|||
if ch.EncryptedMetadataPrivKey == nil || ch.EncryptedOldReadKey == nil {
|
||||
return ErrIncorrectReadKey
|
||||
}
|
||||
var (
|
||||
activeUsers []string
|
||||
updatedInvites []string
|
||||
activeInvites []string
|
||||
updatedUsers []string
|
||||
)
|
||||
for _, accState := range c.aclState.accountStates {
|
||||
if accState.Permissions.NoPermissions() {
|
||||
continue
|
||||
}
|
||||
pubKey := mapKeyFromPubKey(accState.PubKey)
|
||||
if _, exists := removedUsers[pubKey]; exists {
|
||||
continue
|
||||
}
|
||||
activeUsers = append(activeUsers, pubKey)
|
||||
}
|
||||
for _, invite := range c.aclState.invites {
|
||||
if invite.Type == aclrecordproto.AclInviteType_AnyoneCanJoin {
|
||||
activeInvites = append(activeInvites, mapKeyFromPubKey(invite.Key))
|
||||
}
|
||||
}
|
||||
for _, encKeys := range ch.AccountKeys {
|
||||
identity, err := c.keyStore.PubKeyFromProto(encKeys.Identity)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
idKey := mapKeyFromPubKey(identity)
|
||||
_, exists := c.aclState.accountStates[idKey]
|
||||
if !exists {
|
||||
return ErrNoSuchAccount
|
||||
}
|
||||
if removedUsers == nil {
|
||||
continue
|
||||
}
|
||||
_, exists = removedUsers[idKey]
|
||||
if exists {
|
||||
return ErrIncorrectNumberOfAccounts
|
||||
updatedUsers = append(updatedUsers, idKey)
|
||||
}
|
||||
for _, invKeys := range ch.InviteKeys {
|
||||
identity, err := c.keyStore.PubKeyFromProto(invKeys.Identity)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
idKey := mapKeyFromPubKey(identity)
|
||||
updatedInvites = append(updatedInvites, idKey)
|
||||
}
|
||||
if len(activeUsers) != len(updatedUsers) {
|
||||
return ErrIncorrectNumberOfAccounts
|
||||
}
|
||||
if len(activeInvites) != len(updatedInvites) {
|
||||
return ErrIncorrectNumberOfAccounts
|
||||
}
|
||||
slices.Sort(updatedUsers)
|
||||
slices.Sort(updatedInvites)
|
||||
slices.Sort(activeUsers)
|
||||
slices.Sort(activeInvites)
|
||||
if !slices.Equal(activeUsers, updatedUsers) || !slices.Equal(activeInvites, updatedInvites) {
|
||||
return ErrIncorrectNumberOfAccounts
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
@ -44,10 +44,7 @@ func (r *recordVerifier) VerifyAcceptor(rec *consensusproto.RawRecord) (err erro
|
|||
if err != nil {
|
||||
return fmt.Errorf("failed to get acceptor identity: %w", err)
|
||||
}
|
||||
if !identity.Equals(r.networkKey) {
|
||||
return fmt.Errorf("acceptor identity does not match network key")
|
||||
}
|
||||
verified, err := r.networkKey.Verify(rec.Payload, rec.AcceptorSignature)
|
||||
verified, err := identity.Verify(rec.Payload, rec.AcceptorSignature)
|
||||
if !verified || err != nil {
|
||||
return fmt.Errorf("failed to verify acceptor: %w", err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue