Integration Guide
Learn how to integrate OikosTV features into your own applications using our official SDK.
The @crewvid/outpost-sdk
Our SDK is designed to make it easy for developers to build applications that interact with the OikosTV peer network. It handles complex tasks like chunk fetching, AES decryption, and reward tracking automatically.
Installation
npm install @crewvid/outpost-sdkBasic Implementation
Initialize the client and listen for events to build interactive experiences.
import { CrewOutpostClient } from '@crewvid/outpost-sdk';
// Initialize the client with your credentials and storage quota
const client = new CrewOutpostClient({
apiKey: 'your_api_key',
storageQuota: 50, // in GB
});
// Listen for events to update your UI or trigger actions
client.on('chunkServed', (data) => {
console.log(`Successfully served chunk: ${data.chunkId}`);
});
client.on('rewardEarned', (amount) => {
console.log(`You earned ${amount} PeerCredits!`);
});Key Features
Automated Chunk Fetching
The SDK manages the complex logic of finding and fetching video chunks from multiple peers in order, falling back to B2 storage if necessary.
Fetch priority:
- Try WebRTC for each peer in manifest order
- On failure, move to next peer
- After all peers exhausted, fetch from B2 fallback URL
- Only then emit error
Seamless Decryption
Integrated AES-256-GCM decryption ensures that content is decrypted on the fly in a secure, performant manner using the Web Crypto API.
- Uses
crypto.subtleexclusively (no Node.jscrypto) - Nonce is extracted from first 12 bytes of ciphertext
- Decrypted data is never persisted to storage
Best Practices
- Error Handling: Always handle network errors and peer disconnection gracefully to ensure a smooth user experience
- Resource Management: Be mindful of the storage quota set in your client configuration to avoid unexpected disk usage
- Security: Never hardcode API keys or sensitive credentials directly in your frontend code; use secure environment variables or backend proxies
- Session JWT: The
sessionJWTmust never touchlocalStorage,sessionStorage,IndexedDB, or cookies — keep it in memory only
Security
Never log, return, or persist raw encryption keys outside the vault. This applies to both server-side code and browser SDK usage.