make common module as any-sync repo
This commit is contained in:
1 parent
aac5b3e83c
commit
596a315c5f
320 files changed
+453
-29202
No files matched your search
@@ -0,0 +1,44 @@
|
||||
package accounttest
|
||||
|
||||
import (
|
||||
accountService "github.com/anytypeio/any-sync/accountservice"
|
||||
"github.com/anytypeio/any-sync/app"
|
||||
"github.com/anytypeio/any-sync/commonspace/object/accountdata"
|
||||
"github.com/anytypeio/any-sync/util/keys/asymmetric/encryptionkey"
|
||||
"github.com/anytypeio/any-sync/util/keys/asymmetric/signingkey"
|
||||
)
|
||||
|
||||
// AccountTestService provides service for test purposes, generates new random account every Init
|
||||
type AccountTestService struct {
|
||||
acc *accountdata.AccountData
|
||||
}
|
||||
|
||||
func (s *AccountTestService) Init(a *app.App) (err error) {
|
||||
encKey, _, err := encryptionkey.GenerateRandomRSAKeyPair(2048)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
signKey, _, err := signingkey.GenerateRandomEd25519KeyPair()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
ident, err := signKey.GetPublic().Raw()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
s.acc = &accountdata.AccountData{
|
||||
Identity: ident,
|
||||
SignKey: signKey,
|
||||
EncKey: encKey,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *AccountTestService) Name() (name string) {
|
||||
return accountService.CName
|
||||
}
|
||||
|
||||
func (s *AccountTestService) Account() *accountdata.AccountData {
|
||||
return s.acc
|
||||
}
|
||||
Reference in new issue
Block a user