Documentation
¶
Overview ¶
Package auth provides API authentication for the Thalex SDK.
It supports RSA key-based authentication using RS512-signed JWT tokens. Keys can be loaded from PEM-encoded data in either PKCS1 or PKCS8 format.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Credentials ¶
type Credentials struct {
// KeyID is the API key identifier (kid).
KeyID string
// PrivateKey is the RSA private key used for signing JWT tokens.
PrivateKey *rsa.PrivateKey
}
Credentials holds the API key ID and private key for authentication.
func NewCredentials ¶
func NewCredentials(keyID string, privateKey *rsa.PrivateKey) *Credentials
NewCredentials creates Credentials from a pre-parsed RSA private key.
func NewCredentialsFromPEM ¶
func NewCredentialsFromPEM(keyID string, pemData []byte) (*Credentials, error)
NewCredentialsFromPEM creates Credentials from a PEM-encoded RSA private key. It supports both PKCS1 and PKCS8 PEM formats.
func (*Credentials) GenerateToken ¶
func (c *Credentials) GenerateToken() (string, error)
GenerateToken creates a signed JWT token using RS512 for API authentication. The token contains the key ID (kid) in the header and issued-at (iat) in the payload.