-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #164 from multiversx/merge-main-rc-v1.6.0-2023.12.21
Merge main rc v1.6.0 2023.12.21
- Loading branch information
Showing
67 changed files
with
2,742 additions
and
2,317 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,50 @@ | ||
package authentication | ||
|
||
import "errors" | ||
import ( | ||
"errors" | ||
"fmt" | ||
"net/http" | ||
) | ||
|
||
// ErrNilTxSigner signals that a nil transaction signer was provided | ||
var ErrNilTxSigner = errors.New("nil transaction signer") | ||
// ErrNilTokenHandler signals that a nil token handler has been provided | ||
var ErrNilTokenHandler = errors.New("nil token handler") | ||
|
||
// ErrNilProxy signals that a nil proxy was provided | ||
var ErrNilProxy = errors.New("nil proxy") | ||
// ErrNilSigner signals that a nil signer has been provided | ||
var ErrNilSigner = errors.New("nil signer") | ||
|
||
// ErrNilSignature signals that the token has a nil signature | ||
var ErrNilSignature = errors.New("nil token signature") | ||
|
||
// ErrNilAddress signals that the token has a nil address | ||
var ErrNilAddress = errors.New("nil token address") | ||
|
||
// ErrNilBody signals that the token has a nil body | ||
var ErrNilBody = errors.New("nil token body") | ||
|
||
// ErrTokenExpired signals that the provided token is expired | ||
var ErrTokenExpired = errors.New("token expired") | ||
|
||
// ErrNilCryptoComponentsHolder signals that a nil cryptoComponentsHolder has been provided | ||
var ErrNilCryptoComponentsHolder = errors.New("nil cryptoComponentsHolder") | ||
|
||
// ErrNilHttpClientWrapper signals that a nil http client wrapper was provided | ||
var ErrNilHttpClientWrapper = errors.New("nil http client wrapper") | ||
|
||
// ErrHTTPStatusCodeIsNotOK signals that the returned HTTP status code is not OK | ||
var ErrHTTPStatusCodeIsNotOK = errors.New("HTTP status code is not OK") | ||
|
||
// ErrNilCacher signals that a nil cacher has been provided | ||
var ErrNilCacher = errors.New("nil cacher") | ||
|
||
// ErrInvalidValue signals that an invalid value has been provided | ||
var ErrInvalidValue = errors.New("invalid value") | ||
|
||
// CreateHTTPStatusError creates an error with the provided http status code and error | ||
func CreateHTTPStatusError(httpStatusCode int, err error) error { | ||
if err == nil { | ||
err = ErrHTTPStatusCodeIsNotOK | ||
} | ||
|
||
return fmt.Errorf("%w, returned http status: %d, %s", | ||
err, httpStatusCode, http.StatusText(httpStatusCode)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,43 @@ | ||
package authentication | ||
|
||
import "context" | ||
|
||
// AuthClient defines the behavior of an authentication client | ||
type AuthClient interface { | ||
GetAccessToken() (string, error) | ||
IsInterfaceNil() bool | ||
} | ||
|
||
// AuthServer defines the behavior of an authentication server | ||
type AuthServer interface { | ||
Validate(accessToken AuthToken) error | ||
IsInterfaceNil() bool | ||
} | ||
|
||
// AuthTokenHandler defines the behavior of an authentication token handler | ||
type AuthTokenHandler interface { | ||
Decode(accessToken string) (AuthToken, error) | ||
Encode(authToken AuthToken) (string, error) | ||
GetUnsignedToken(authToken AuthToken) []byte | ||
GetSignableMessage(address, unsignedToken []byte) []byte | ||
GetSignableMessageLegacy(address, unsignedToken []byte) []byte | ||
IsInterfaceNil() bool | ||
} | ||
|
||
// AuthToken defines the behavior of an authentication token | ||
type AuthToken interface { | ||
GetTtl() int64 | ||
GetAddress() []byte | ||
GetHost() []byte | ||
GetSignature() []byte | ||
GetBlockHash() string | ||
GetExtraInfo() []byte | ||
IsInterfaceNil() bool | ||
} | ||
|
||
// HttpClientWrapper defines the behavior of http client able to make http requests | ||
type HttpClientWrapper interface { | ||
GetHTTP(ctx context.Context, endpoint string) ([]byte, int, error) | ||
PostHTTP(ctx context.Context, endpoint string, data []byte) ([]byte, int, error) | ||
IsInterfaceNil() bool | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.