Authentication
ThorPulse uses NATS JWT authentication to secure access and enforce subscription limits based on your tier.
Subscription Tiers
Tier
Subscriptions
Available Topics
Flash
100
all topics
Thor
250
all topics
Prime
Unlimited
all topics
Getting Credentials
Contact Thor Labs to obtain your credentials. You will receive:
A
.credsfile containing your JWT and NKey seedThe NATS server URL (e.g.,
nats://ny-rpc.thornode.io:4223)
Credentials File Format
A .creds file looks like:
-----BEGIN NATS USER JWT-----
eyJ0eXAiOiJKV1QiLCJhbGciOiJlZDI1NTE5LW5rZXkifQ.eyJqdGkiOiJBQk...
------END NATS USER JWT------
************************* IMPORTANT *************************
NKEY Seed printed below can be used to sign and prove identity.
NKEYs are sensitive and should be treated as secrets.
-----BEGIN USER NKEY SEED-----
SUAM4QXBNMN3FHPJQ7VUPNKJ3HZ3TJWMHFQ4KJ6UJKA7AB2CD3EF...
------END USER NKEY SEED------
*************************************************************Keep this file secure! The NKey seed can be used to authenticate as you.
Using Credentials
Go SDK
package main
import (
"github.com/thorlabsDev/thorpulse-go"
"log"
)
func main() {
// Option 1: Load from file
creds, err := client.LoadCredentials("user.creds")
if err != nil {
log.Fatal(err)
}
c, err := client.New(
client.WithURL("nats://ny-rpc.thornode.io:4223"),
client.WithCredentials(creds),
)
// Option 2: Load directly
c, err := client.New(
client.WithURL("nats://ny-rpc.thornode.io:4223"),
client.WithCredentialsFile("user.creds"),
)
// Option 3: From environment
// Set THORPULSE_CREDS_FILE=/path/to/user.creds
c, err := client.New(
client.WithURL("nats://ny-rpc.thornode.io:4223"),
client.WithCredentialsFromEnv(),
)
}Rust SDK
use thorpulse_client::{ThorPulseClient, Credentials, Config};
use std::time::Duration;
#[tokio::main]
async fn main() -> thorpulse_client::Result<()> {
// Load credentials
let creds = Credentials::from_file("user.creds")?;
// Connect with credentials
let config = Config::builder("nats://ny-rpc.thornode.io:4223")
.name("my-app")
.credentials(creds)
.build();
let client = ThorPulseClient::connect(config).await?;
// Use client...
Ok(())
}Environment Variables
Configure authentication via environment variables:
Variable
Description
THORPULSE_CREDS_FILE
Path to credentials file
THORPULSE_JWT
JWT token directly
THORPULSE_NKEY_SEED
NKey seed directly
Troubleshooting
Security Best Practices
Last updated