SDK Advanced Configuration
This guide covers every configuration option available in the Orbitport SDK, including timeouts, retries, custom IPFS gateways, and debug mode.
Full configuration reference
OrbitportConfig
interface OrbitportConfig {
clientId?: string; // Your client ID
clientSecret?: string; // Your client secret
authUrl?: string; // Auth server URL (default: https://auth.spacecomputer.io/oauth/token)
apiUrl?: string; // API server URL (default: https://op.spacecomputer.io/api/v1/services/trng)
timeout?: number; // Request timeout in ms (default: 30000)
retryAttempts?: number; // Number of retry attempts (default: 3)
retryDelay?: number; // Delay between retries in ms (default: 1000)
ipfs?: IPFSConfig; // Custom IPFS settings
}
IPFSConfig
interface IPFSConfig {
gateway?: string; // IPFS gateway URL (default: "https://ipfs.io")
apiUrl?: string; // IPFS API URL (default: "https://ipfs.io")
timeout?: number; // IPFS-specific timeout in ms
defaultBeaconPath?: string; // Beacon IPNS path (default: "/ipns/k2k4r8lvomw737sajfnpav0dpeernugnryng50uheyk1k39lursmn09f")
}
Example: full custom configuration
import { OrbitportSDK } from "@spacecomputer-io/orbitport-sdk-ts";
const sdk = new OrbitportSDK({
config: {
clientId: "your-client-id",
clientSecret: "your-client-secret",
timeout: 60000,
retryAttempts: 5,
retryDelay: 2000,
ipfs: {
gateway: "https://ipfs.io",
apiUrl: "https://ipfs.io",
defaultBeaconPath:
"/ipns/k2k4r8lvomw737sajfnpav0dpeernugnryng50uheyk1k39lursmn09f",
},
},
});
Custom IPFS gateway
If you run your own IPFS gateway or prefer a different public one, override the gateway and API URLs:
const sdk = new OrbitportSDK({
config: {
ipfs: {
gateway: "https://my-gateway.example.com",
apiUrl: "https://my-ipfs-api.example.com",
},
},
});
The SDK fetches from both the gateway and the API node and compares results for integrity. If you use a single endpoint for both, set them to the same value.
Timeout and retry tuning
Adjust timeouts and retries to match your application's requirements:
const sdk = new OrbitportSDK({
config: {
timeout: 10000, // 10 seconds -- tighter for user-facing requests
retryAttempts: 1, // Fewer retries for low-latency paths
retryDelay: 500, // Shorter delay between retries
},
});
For background jobs where reliability matters more than latency:
const sdk = new OrbitportSDK({
config: {
timeout: 120000, // 2 minutes
retryAttempts: 10,
retryDelay: 5000, // 5 seconds between retries
},
});
Enable debug mode
Set debug: true to get detailed logs of IPFS operations. This is useful for diagnosing connectivity or data-integrity issues:
const sdk = new OrbitportSDK({
config: {
debug: true,
},
});
Example debug output:
[OrbitportSDK] Reading from BOTH IPFS sources:
- Gateway: https://ipfs.io
- API: https://ipfs.io
- Path: /ipns/k2k4r8lvomw737sajfnpav0dpeernugnryng50uheyk1k39lursmn09f
[OrbitportSDK] Gateway and API agree on sequence/previous
Debug mode logs the gateway and API URLs being used, the beacon path, and whether the two sources agree.
Next steps
- SDK Quickstart -- Get started with the SDK.
- SDK Error Handling -- Handle errors and understand retry behavior.
- SDK IPFS Beacon -- Use IPFS beacon features like block traversal and custom beacons.