mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-08 05:57:03 +09:00
31 lines
869 B
Go
31 lines
869 B
Go
package list
|
|
|
|
import (
|
|
"github.com/anyproto/any-sync/commonspace/object/accountdata"
|
|
"github.com/anyproto/any-sync/commonspace/object/acl/aclrecordproto"
|
|
"github.com/anyproto/any-sync/commonspace/object/acl/liststorage"
|
|
"github.com/anyproto/any-sync/util/crypto"
|
|
)
|
|
|
|
func NewTestDerivedAcl(spaceId string, keys *accountdata.AccountKeys) (AclList, error) {
|
|
builder := NewAclRecordBuilder("", crypto.NewKeyStorage())
|
|
masterKey, _, err := crypto.GenerateRandomEd25519KeyPair()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
root, err := builder.BuildRoot(RootContent{
|
|
PrivKey: keys.SignKey,
|
|
SpaceId: spaceId,
|
|
MasterKey: masterKey,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
st, err := liststorage.NewInMemoryAclListStorage(root.Id, []*aclrecordproto.RawAclRecordWithId{
|
|
root,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return BuildAclListWithIdentity(keys, st)
|
|
}
|