Commit 620757ad authored by Anthony Martynov's avatar Anthony Martynov

Updated tokend/go to version 3.3.2

parent 06efacfa
......@@ -215,7 +215,7 @@
version = "v1.2"
[[projects]]
digest = "1:8bd69f3d58ec64c355ddcd7e9f36db49de816c96d2d60aa81e8f2b660c7a269c"
digest = "1:ef57710b77b20159f7c72d759355bb0f97d4552c9c2320c404308d31d1d67f2a"
name = "gitlab.com/tokend/go"
packages = [
"amount",
......@@ -231,8 +231,8 @@
"xdrbuild/internal",
]
pruneopts = "UT"
revision = "37830e08742fa3c398c31f33b5bc3dd230c96acb"
version = "v3.2.1"
revision = "4912d9d0be3775e861c0f095ece478d0a514a8b9"
version = "v3.8.0"
[[projects]]
branch = "master"
......
......@@ -28,7 +28,7 @@
[[constraint]]
name = "gitlab.com/tokend/go"
version = "3.2.1"
version = "3.3.2"
[[constraint]]
name = "github.com/stretchr/testify"
......
......@@ -187,7 +187,11 @@ func requestTargetLine(req *http.Request) string {
url = req.URL.RequestURI()
}
return fmt.Sprintf("%s: %s %s", RequestTarget, strings.ToLower(req.Method), url)
return fmt.Sprintf("%s: %s", RequestTarget, RequestTargetValue(strings.ToLower(req.Method), url))
}
func RequestTargetValue(method, url string) string {
return fmt.Sprintf("%s %s", strings.ToLower(method), url)
}
func headerLine(req *http.Request, header string) (string, error) {
......
......@@ -3,7 +3,6 @@ package httpsignatures
import (
"net/http"
"strings"
"time"
)
// Signer is used to create a signature for a given request.
......@@ -38,10 +37,6 @@ func (s Signer) SignRequest(keyId string, key interface{}, r *http.Request) erro
}
func (s Signer) buildSignature(keyId string, key interface{}, r *http.Request) (*Signature, error) {
if r.Header.Get("date") == "" {
r.Header.Set("date", time.Now().UTC().Format(http.TimeFormat))
}
sig := &Signature{
KeyID: keyId,
Algorithm: s.algorithm,
......
......@@ -21,6 +21,8 @@ const (
SignatureAlgorithm = "ed25519-sha256"
signatureExpireAfter = 1 * time.Hour
realRequestTargetHeader = "Real-Request-Target"
)
var (
......@@ -55,7 +57,19 @@ func SignRequest(request *http.Request, kp keypair.KP) error {
if err != nil {
return errors.Wrap(err, "failed to get signature algorithm")
}
signer := httpsignatures.NewSigner(algorithm, "date", httpsignatures.RequestTarget)
if request.Header.Get(realRequestTargetHeader) == "" {
request.Header.Set(
realRequestTargetHeader,
httpsignatures.RequestTargetValue(request.Method, request.URL.RequestURI()),
)
}
if request.Header.Get("date") == "" {
request.Header.Set("date", time.Now().UTC().Format(http.TimeFormat))
}
signer := httpsignatures.NewSigner(algorithm, "date", realRequestTargetHeader)
if err = signer.SignRequest(kp.Address(), kp, request); err != nil {
return err
}
......
package xdrbuild
import (
"gitlab.com/distributed_lab/logan/v3/errors"
"gitlab.com/tokend/go/xdr"
)
type InitiateKYCRecovery struct {
AccountID string
Signer string
}
func (op *InitiateKYCRecovery) XDR() (*xdr.Operation, error) {
var account xdr.AccountId
err := account.SetAddress(op.AccountID)
if err != nil {
return nil, errors.Wrap(err, "failed to set account")
}
var signer xdr.AccountId
err = signer.SetAddress(op.Signer)
if err != nil {
return nil, errors.Wrap(err, "failed to set signer")
}
return &xdr.Operation{
Body: xdr.OperationBody{
Type: xdr.OperationTypeInitiateKycRecovery,
InitiateKycRecoveryOp: &xdr.InitiateKycRecoveryOp{
Account: account,
Signer: xdr.PublicKey(signer),
},
},
}, nil
}
package xdrbuild
import (
"gitlab.com/distributed_lab/logan/v3/errors"
"gitlab.com/tokend/go/xdr"
)
type CreateAccountSaleRule struct {
SaleID uint64
Forbids bool
AccountID string
}
func (op *CreateAccountSaleRule) XDR() (*xdr.Operation, error) {
destination := &xdr.AccountId{}
if op.AccountID != "" {
if err := destination.SetAddress(op.AccountID); err != nil {
return nil, errors.Wrap(err, "failed to set account id address")
}
}
return &xdr.Operation{
Body: xdr.OperationBody{
Type: xdr.OperationTypeManageAccountSpecificRule,
ManageAccountSpecificRuleOp: &xdr.ManageAccountSpecificRuleOp{
Data: xdr.ManageAccountSpecificRuleOpData{
Action: xdr.ManageAccountSpecificRuleActionCreate,
CreateData: &xdr.CreateAccountSpecificRuleData{
LedgerKey: xdr.LedgerKey{
Type: xdr.LedgerEntryTypeSale,
Sale: &xdr.LedgerKeySale{
SaleId: xdr.Uint64(op.SaleID),
},
},
Forbids: op.Forbids,
AccountId: destination,
},
},
},
},
}, nil
}
type RemoveAccountSaleRule struct {
RuleID uint64
}
func (op *RemoveAccountSaleRule) XDR() (*xdr.Operation, error) {
return &xdr.Operation{
Body: xdr.OperationBody{
Type: xdr.OperationTypeManageAccountSpecificRule,
ManageAccountSpecificRuleOp: &xdr.ManageAccountSpecificRuleOp{
Data: xdr.ManageAccountSpecificRuleOpData{
Action: xdr.ManageAccountSpecificRuleActionRemove,
RemoveData: &xdr.RemoveAccountSpecificRuleData{
RuleId: xdr.Uint64(op.RuleID),
},
},
},
},
}, nil
}
......@@ -100,7 +100,7 @@ type AtomicSwapDetails struct{}
func (d AtomicSwapDetails) ReviewRequestDetails() xdr.ReviewRequestOpRequestDetails {
return xdr.ReviewRequestOpRequestDetails{
RequestType: xdr.ReviewableRequestTypeCreateAtomicSwap,
RequestType: xdr.ReviewableRequestTypeCreateAtomicSwapBid,
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment