Documentation
¶
Overview ¶
Package protect provides the Taurus-PROTECT SDK client.
Index ¶
- Constants
- Variables
- func IsConfigurationError(err error) bool
- func IsIntegrityError(err error) bool
- func IsWhitelistError(err error) bool
- type APIError
- func AuthenticationError(message string, err error) *APIError
- func AuthorizationError(message string, err error) *APIError
- func IsAPIError(err error) (*APIError, bool)
- func NotFoundError(message string, err error) *APIError
- func RateLimitError(message string, retryAfter time.Duration, err error) *APIError
- func ServerError(code int, message string, err error) *APIError
- func ValidationError(message string, err error) *APIError
- type Client
- func (c *Client) Actions() *service.ActionService
- func (c *Client) Addresses() *service.AddressService
- func (c *Client) AirGap() *service.AirGapService
- func (c *Client) Assets() *service.AssetService
- func (c *Client) Audits() *service.AuditService
- func (c *Client) Balances() *service.BalanceService
- func (c *Client) BaseURL() string
- func (c *Client) Blockchains() *service.BlockchainService
- func (c *Client) BusinessRules() *service.BusinessRuleService
- func (c *Client) Changes() *service.ChangeService
- func (c *Client) Close() error
- func (c *Client) Config() *service.ConfigService
- func (c *Client) Currencies() *service.CurrencyService
- func (c *Client) Exchanges() *service.ExchangeService
- func (c *Client) FeePayers() *service.FeePayerService
- func (c *Client) Fees() *service.FeeService
- func (c *Client) Fiat() *service.FiatService
- func (c *Client) GovernanceRules() *service.GovernanceRuleService
- func (c *Client) Groups() *service.GroupService
- func (c *Client) HTTPClient() *http.Client
- func (c *Client) Health() *service.HealthService
- func (c *Client) Jobs() *service.JobService
- func (c *Client) MinValidSignatures() int
- func (c *Client) MultiFactorSignature() *service.MultiFactorSignatureService
- func (c *Client) Prices() *service.PriceService
- func (c *Client) Requests() *service.RequestService
- func (c *Client) Reservations() *service.ReservationService
- func (c *Client) RulesCache() *cache.RulesContainerCache
- func (c *Client) Scores() *service.ScoreService
- func (c *Client) Staking() *service.StakingService
- func (c *Client) Statistics() *service.StatisticsService
- func (c *Client) SuperAdminKeys() []*ecdsa.PublicKey
- func (c *Client) Tags() *service.TagService
- func (c *Client) TaurusNetwork() *TaurusNetworkClient
- func (c *Client) TokenMetadata() *service.TokenMetadataService
- func (c *Client) Transactions() *service.TransactionService
- func (c *Client) UserDevices() *service.UserDeviceService
- func (c *Client) Users() *service.UserService
- func (c *Client) VisibilityGroups() *service.VisibilityGroupService
- func (c *Client) Wallets() *service.WalletService
- func (c *Client) WebhookCalls() *service.WebhookCallService
- func (c *Client) Webhooks() *service.WebhookService
- func (c *Client) WhitelistedAddresses() *service.WhitelistedAddressService
- func (c *Client) WhitelistedAssets() *service.WhitelistedAssetService
- func (c *Client) WhitelistedContracts() *service.WhitelistedContractService
- type ConfigurationError
- type IntegrityError
- type Option
- func WithCredentials(apiKey, apiSecret string) Option
- func WithHTTPClient(client *http.Client) Option
- func WithHTTPTimeout(timeout time.Duration) Option
- func WithMinValidSignatures(n int) Option
- func WithRulesCacheTTL(ttl time.Duration) Option
- func WithSuperAdminKeys(keys []*ecdsa.PublicKey) Option
- func WithSuperAdminKeysPEM(pemKeys []string) Option
- type RequestMetadataError
- type TPV1Transport
- type TaurusNetworkClient
- func (tn *TaurusNetworkClient) Lending() *service.TaurusNetworkLendingService
- func (tn *TaurusNetworkClient) Participants() *service.TaurusNetworkParticipantService
- func (tn *TaurusNetworkClient) Pledges() *service.TaurusNetworkPledgeService
- func (tn *TaurusNetworkClient) Settlements() *service.TaurusNetworkSettlementService
- func (tn *TaurusNetworkClient) Sharing() *service.TaurusNetworkSharingService
- type WhitelistError
Constants ¶
const ( // DefaultRulesCacheTTL is the default TTL for the rules container cache. DefaultRulesCacheTTL = 5 * time.Minute // DefaultHTTPTimeout is the default timeout for HTTP requests. DefaultHTTPTimeout = 30 * time.Second )
Default configuration values.
Variables ¶
var ( // ErrValidation indicates a 400 Bad Request error. ErrValidation = &APIError{Code: 400, StatusCode: 400, Message: "validation error"} // ErrAuthentication indicates a 401 Unauthorized error. ErrAuthentication = &APIError{Code: 401, StatusCode: 401, Message: "authentication error"} // ErrAuthorization indicates a 403 Forbidden error. ErrAuthorization = &APIError{Code: 403, StatusCode: 403, Message: "authorization error"} // ErrNotFound indicates a 404 Not Found error. ErrNotFound = &APIError{Code: 404, StatusCode: 404, Message: "not found"} // ErrRateLimit indicates a 429 Too Many Requests error. ErrRateLimit = &APIError{Code: 429, StatusCode: 429, Message: "rate limit exceeded"} // ErrServer indicates a 5xx server error. ErrServer = &APIError{Code: 500, StatusCode: 500, Message: "server error"} )
Sentinel errors for type checking with errors.Is().
var ErrConfiguration = &ConfigurationError{Message: "invalid configuration"}
ErrConfiguration is the sentinel error for configuration failures.
var ErrIntegrity = &IntegrityError{Message: "integrity verification failed"}
ErrIntegrity is the sentinel error for integrity failures.
var ErrRequestMetadata = &RequestMetadataError{Message: "invalid request metadata"}
ErrRequestMetadata is the sentinel error for request metadata failures.
var ErrWhitelist = &WhitelistError{Message: "whitelist verification failed"}
ErrWhitelist is the sentinel error for whitelist failures.
Functions ¶
func IsConfigurationError ¶
IsConfigurationError checks if the error is a ConfigurationError.
func IsIntegrityError ¶
IsIntegrityError checks if the error is an IntegrityError.
func IsWhitelistError ¶
IsWhitelistError checks if the error is a WhitelistError.
Types ¶
type APIError ¶
APIError is the base error type for all Taurus-PROTECT API errors.
func AuthenticationError ¶
AuthenticationError creates a new authentication error (401).
func AuthorizationError ¶
AuthorizationError creates a new authorization error (403).
func IsAPIError ¶
IsAPIError checks if the error is an APIError and returns it.
func NotFoundError ¶
NotFoundError creates a new not found error (404).
func RateLimitError ¶
RateLimitError creates a new rate limit error (429).
func ServerError ¶
ServerError creates a new server error (5xx).
func ValidationError ¶
ValidationError creates a new validation error (400).
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the main entry point for the Taurus-PROTECT SDK. It provides access to all API services and handles authentication.
Use NewClient to create a new instance with the functional options pattern:
client, err := protect.NewClient(
"https://api.taurus.example.com",
protect.WithCredentials(apiKey, apiSecret),
protect.WithSuperAdminKeysPEM(pemKeys),
protect.WithMinValidSignatures(2),
)
if err != nil {
log.Fatal(err)
}
defer client.Close()
Client implements io.Closer and should be closed when no longer needed to securely wipe credentials from memory.
func NewClient ¶
NewClient creates a new Taurus-PROTECT API client.
The host parameter should be the base URL of the Taurus-PROTECT API (e.g., "https://api.taurus.example.com").
At minimum, WithCredentials, WithSuperAdminKeysPEM (or WithSuperAdminKeys), and WithMinValidSignatures must be provided:
client, err := protect.NewClient(
"https://api.taurus.example.com",
protect.WithCredentials(apiKey, apiSecret),
protect.WithSuperAdminKeysPEM(pemKeys),
protect.WithMinValidSignatures(2),
)
func (*Client) Actions ¶
func (c *Client) Actions() *service.ActionService
Actions returns the action service for managing automated actions.
func (*Client) Addresses ¶
func (c *Client) Addresses() *service.AddressService
Addresses returns the address service for managing blockchain addresses. Address signature verification is mandatory on all get and list operations.
func (*Client) AirGap ¶
func (c *Client) AirGap() *service.AirGapService
AirGap returns the air-gap service for cold HSM integration operations.
func (*Client) Assets ¶
func (c *Client) Assets() *service.AssetService
Assets returns the asset service for querying asset balances at address and wallet level.
func (*Client) Audits ¶
func (c *Client) Audits() *service.AuditService
Audits returns the audit service for querying audit trails.
func (*Client) Balances ¶
func (c *Client) Balances() *service.BalanceService
Balances returns the balance service for querying asset balances.
func (*Client) Blockchains ¶
func (c *Client) Blockchains() *service.BlockchainService
Blockchains returns the blockchain service for querying blockchain metadata.
func (*Client) BusinessRules ¶
func (c *Client) BusinessRules() *service.BusinessRuleService
BusinessRules returns the business rule service for querying business rules.
func (*Client) Changes ¶
func (c *Client) Changes() *service.ChangeService
Changes returns the change service for managing configuration changes.
func (*Client) Close ¶
Close releases resources and securely wipes credentials from memory. It is safe to call Close multiple times.
func (*Client) Config ¶
func (c *Client) Config() *service.ConfigService
Config returns the config service for querying tenant configuration.
func (*Client) Currencies ¶
func (c *Client) Currencies() *service.CurrencyService
Currencies returns the currency service for querying available currencies.
func (*Client) Exchanges ¶
func (c *Client) Exchanges() *service.ExchangeService
Exchanges returns the exchange service for managing exchange accounts.
func (*Client) FeePayers ¶
func (c *Client) FeePayers() *service.FeePayerService
FeePayers returns the fee payer service for managing fee payers.
func (*Client) Fees ¶
func (c *Client) Fees() *service.FeeService
Fees returns the fee service for querying blockchain fee estimates.
func (*Client) Fiat ¶
func (c *Client) Fiat() *service.FiatService
Fiat returns the fiat service for managing fiat provider accounts.
func (*Client) GovernanceRules ¶
func (c *Client) GovernanceRules() *service.GovernanceRuleService
GovernanceRules returns the governance rule service for managing governance rules.
func (*Client) Groups ¶
func (c *Client) Groups() *service.GroupService
Groups returns the group service for managing user groups.
func (*Client) HTTPClient ¶
HTTPClient returns the underlying HTTP client. This can be used for advanced use cases, but most users should use the service methods instead.
func (*Client) Health ¶
func (c *Client) Health() *service.HealthService
Health returns the health service for querying system health checks.
func (*Client) Jobs ¶
func (c *Client) Jobs() *service.JobService
Jobs returns the job service for managing background jobs.
func (*Client) MinValidSignatures ¶
MinValidSignatures returns the minimum number of valid signatures required.
func (*Client) MultiFactorSignature ¶
func (c *Client) MultiFactorSignature() *service.MultiFactorSignatureService
MultiFactorSignature returns the multi-factor signature service for MFA approval workflows.
func (*Client) Prices ¶
func (c *Client) Prices() *service.PriceService
Prices returns the price service for querying currency prices and conversions.
func (*Client) Requests ¶
func (c *Client) Requests() *service.RequestService
Requests returns the request service for managing transaction requests.
func (*Client) Reservations ¶
func (c *Client) Reservations() *service.ReservationService
Reservations returns the reservation service for managing UTXO reservations.
func (*Client) RulesCache ¶
func (c *Client) RulesCache() *cache.RulesContainerCache
RulesCache returns the rules container cache used for address signature verification. This is always non-nil as address signature verification is mandatory.
func (*Client) Scores ¶
func (c *Client) Scores() *service.ScoreService
Scores returns the score service for managing address risk scores.
func (*Client) Staking ¶
func (c *Client) Staking() *service.StakingService
Staking returns the staking service for blockchain staking operations.
func (*Client) Statistics ¶
func (c *Client) Statistics() *service.StatisticsService
Statistics returns the statistics service for querying portfolio and tag statistics.
func (*Client) SuperAdminKeys ¶
SuperAdminKeys returns the configured SuperAdmin public keys.
func (*Client) Tags ¶
func (c *Client) Tags() *service.TagService
Tags returns the tag service for managing tags.
func (*Client) TaurusNetwork ¶
func (c *Client) TaurusNetwork() *TaurusNetworkClient
TaurusNetwork returns the Taurus Network namespace client providing access to all Taurus Network services: Participants, Pledges, Lending, Settlements, and Sharing.
Example usage:
client.TaurusNetwork().Participants().GetMyParticipant(ctx) client.TaurusNetwork().Pledges().Create(ctx, req) client.TaurusNetwork().Lending().GetAgreement(ctx, agreementID) client.TaurusNetwork().Settlements().Get(ctx, settlementID) client.TaurusNetwork().Sharing().ShareAddress(ctx, req)
func (*Client) TokenMetadata ¶
func (c *Client) TokenMetadata() *service.TokenMetadataService
TokenMetadata returns the token metadata service for querying NFT and token metadata.
func (*Client) Transactions ¶
func (c *Client) Transactions() *service.TransactionService
Transactions returns the transaction service for querying transactions.
func (*Client) UserDevices ¶
func (c *Client) UserDevices() *service.UserDeviceService
UserDevices returns the user device service for managing device pairing.
func (*Client) Users ¶
func (c *Client) Users() *service.UserService
Users returns the user service for managing users.
func (*Client) VisibilityGroups ¶
func (c *Client) VisibilityGroups() *service.VisibilityGroupService
VisibilityGroups returns the visibility group service for managing restricted visibility groups.
func (*Client) Wallets ¶
func (c *Client) Wallets() *service.WalletService
Wallets returns the wallet service for managing cryptocurrency wallets.
func (*Client) WebhookCalls ¶
func (c *Client) WebhookCalls() *service.WebhookCallService
WebhookCalls returns the webhook call service for querying webhook call history.
func (*Client) Webhooks ¶
func (c *Client) Webhooks() *service.WebhookService
Webhooks returns the webhook service for managing webhook configurations.
func (*Client) WhitelistedAddresses ¶
func (c *Client) WhitelistedAddresses() *service.WhitelistedAddressService
WhitelistedAddresses returns the whitelisted address service for managing external addresses. The service always verifies the integrity of all retrieved addresses using the 6-step cryptographic verification flow with the configured SuperAdmin keys.
func (*Client) WhitelistedAssets ¶
func (c *Client) WhitelistedAssets() *service.WhitelistedAssetService
WhitelistedAssets returns the whitelisted asset service for managing whitelisted contracts/tokens. The service always verifies the integrity of all retrieved assets using the cryptographic verification flow with the configured SuperAdmin keys.
func (*Client) WhitelistedContracts ¶
func (c *Client) WhitelistedContracts() *service.WhitelistedContractService
WhitelistedContracts returns the whitelisted contract service for smart contract whitelisting.
type ConfigurationError ¶
ConfigurationError indicates invalid SDK configuration. This error is raised when the SDK is configured with invalid or incompatible settings, such as missing credentials or invalid key formats.
func (*ConfigurationError) Error ¶
func (e *ConfigurationError) Error() string
func (*ConfigurationError) Is ¶
func (e *ConfigurationError) Is(target error) bool
Is implements errors.Is for ConfigurationError.
func (*ConfigurationError) Unwrap ¶
func (e *ConfigurationError) Unwrap() error
type IntegrityError ¶
IntegrityError indicates a cryptographic verification failure. This is a security-critical error that should never be retried.
func (*IntegrityError) Error ¶
func (e *IntegrityError) Error() string
func (*IntegrityError) Is ¶
func (e *IntegrityError) Is(target error) bool
Is implements errors.Is for IntegrityError.
func (*IntegrityError) Unwrap ¶
func (e *IntegrityError) Unwrap() error
type Option ¶
type Option func(*clientConfig) error
Option configures a ProtectClient.
func WithCredentials ¶
WithCredentials sets the API key and secret for authentication. The apiSecret should be hex-encoded.
func WithHTTPClient ¶
WithHTTPClient sets a custom HTTP client to use for requests. Note: The client's Transport will be wrapped with TPV1 authentication.
func WithHTTPTimeout ¶
WithHTTPTimeout sets the timeout for HTTP requests. The default is 30 seconds.
func WithMinValidSignatures ¶
WithMinValidSignatures sets the minimum number of valid SuperAdmin signatures required to verify governance rules.
func WithRulesCacheTTL ¶
WithRulesCacheTTL sets the TTL for the rules container cache. The default is 5 minutes.
func WithSuperAdminKeys ¶
WithSuperAdminKeys sets the SuperAdmin public keys directly.
func WithSuperAdminKeysPEM ¶
WithSuperAdminKeysPEM sets the SuperAdmin public keys from PEM-encoded strings. These keys are used to verify governance rules signatures.
type RequestMetadataError ¶
RequestMetadataError indicates missing or invalid request metadata.
func (*RequestMetadataError) Error ¶
func (e *RequestMetadataError) Error() string
func (*RequestMetadataError) Is ¶
func (e *RequestMetadataError) Is(target error) bool
Is implements errors.Is for RequestMetadataError.
func (*RequestMetadataError) Unwrap ¶
func (e *RequestMetadataError) Unwrap() error
type TPV1Transport ¶
type TPV1Transport struct {
// Base is the underlying transport. If nil, http.DefaultTransport is used.
Base http.RoundTripper
// Auth provides TPV1 credentials for signing.
Auth *crypto.TPV1Auth
}
TPV1Transport is an http.RoundTripper that signs requests with TPV1-HMAC-SHA256.
Important: This transport reads and clones the request body for signing. If you use middleware that wraps this transport and expects to retry requests, be aware that the original request body is consumed during signing. The transport properly resets the body on the cloned request, but middleware should not rely on re-reading the original request's body.
Middleware ordering: Place retry middleware ABOVE this transport (closer to the http.Client), so retries create fresh requests rather than reusing requests with consumed bodies.
type TaurusNetworkClient ¶
type TaurusNetworkClient struct {
// contains filtered or unexported fields
}
TaurusNetworkClient provides namespaced access to Taurus Network services. Use client.TaurusNetwork() to access this client.
Example usage:
client.TaurusNetwork().Participants().GetMyParticipant(ctx) client.TaurusNetwork().Pledges().Create(ctx, req) client.TaurusNetwork().Lending().GetAgreement(ctx, agreementID) client.TaurusNetwork().Settlements().Get(ctx, settlementID) client.TaurusNetwork().Sharing().ShareAddress(ctx, req)
func (*TaurusNetworkClient) Lending ¶
func (tn *TaurusNetworkClient) Lending() *service.TaurusNetworkLendingService
Lending returns the lending offers and agreements service. Provides operations for managing lending offers and agreements.
func (*TaurusNetworkClient) Participants ¶
func (tn *TaurusNetworkClient) Participants() *service.TaurusNetworkParticipantService
Participants returns the participant management service. Provides operations for managing Taurus Network participants and their attributes.
func (*TaurusNetworkClient) Pledges ¶
func (tn *TaurusNetworkClient) Pledges() *service.TaurusNetworkPledgeService
Pledges returns the pledge management service. Provides operations for creating, managing, and withdrawing pledges.
func (*TaurusNetworkClient) Settlements ¶
func (tn *TaurusNetworkClient) Settlements() *service.TaurusNetworkSettlementService
Settlements returns the settlement management service. Provides operations for creating and managing settlements between participants.
func (*TaurusNetworkClient) Sharing ¶
func (tn *TaurusNetworkClient) Sharing() *service.TaurusNetworkSharingService
Sharing returns the address/asset sharing service. Provides operations for sharing and unsharing addresses and assets with other participants.
type WhitelistError ¶
WhitelistError indicates a whitelist verification failure.
func (*WhitelistError) Error ¶
func (e *WhitelistError) Error() string
func (*WhitelistError) Is ¶
func (e *WhitelistError) Is(target error) bool
Is implements errors.Is for WhitelistError.
func (*WhitelistError) Unwrap ¶
func (e *WhitelistError) Unwrap() error
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cache provides thread-safe caching for the Taurus-PROTECT SDK.
|
Package cache provides thread-safe caching for the Taurus-PROTECT SDK. |
|
Package crypto provides cryptographic utilities for the Taurus-PROTECT SDK.
|
Package crypto provides cryptographic utilities for the Taurus-PROTECT SDK. |
|
Package helper provides signature verification and validation utilities.
|
Package helper provides signature verification and validation utilities. |
|
Package mapper provides functions to convert between OpenAPI DTOs and domain models.
|
Package mapper provides functions to convert between OpenAPI DTOs and domain models. |
|
Package service provides high-level service wrappers for the Taurus-PROTECT API.
|
Package service provides high-level service wrappers for the Taurus-PROTECT API. |