This guide will help you get started with SecureFabric SDKs.
- Access to a SecureFabric node endpoint
- Bearer authentication token
- TLS certificates (if using mTLS)
Add to your Cargo.toml:
[dependencies]
securefabric-sdk = "0.1"
tokio = { version = "1", features = ["full"] }npm install @securefabric/sdkpip install securefabric-sdkuse securefabric_sdk::{SecureFabricClient, ClientConfig};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = ClientConfig {
endpoint: "YOUR_ENDPOINT_HERE".to_string(),
bearer_token: Some("YOUR_TOKEN_HERE".to_string()),
..Default::default()
};
let client = SecureFabricClient::connect(config).await?;
// Send a message
client.send(
b"test-topic",
b"recipient-id",
b"Hello, SecureFabric!"
).await?;
// Subscribe to messages
let mut stream = client.subscribe(b"test-topic").await?;
while let Some(envelope) = stream.next().await {
println!("Received message: {:?}", envelope);
}
Ok(())
}import { SecureFabricClient } from '@securefabric/sdk';
const client = new SecureFabricClient({
endpoint: process.env.SF_ENDPOINT || 'YOUR_ENDPOINT_HERE',
bearerToken: process.env.SF_TOKEN || 'YOUR_TOKEN_HERE'
});
// Send a message
await client.send(
'test-topic',
'recipient-id',
Buffer.from('Hello, SecureFabric!')
);
// Subscribe to messages
const stream = await client.subscribe('test-topic');
for await (const envelope of stream) {
console.log('Received message:', envelope);
}import asyncio
from securefabric import SecureFabricClient
async def main():
client = SecureFabricClient(
target='YOUR_ENDPOINT_HERE',
bearer='YOUR_TOKEN_HERE'
)
# Send a message
ok = await client.send(
topic=b'test-topic',
to=b'recipient-id',
payload=b'Hello, SecureFabric!'
)
print(f"Message sent: {ok}")
# Subscribe to messages
async for envelope in client.subscribe(topic=b'test-topic'):
print(f"Received: {envelope}")
await client.close()
if __name__ == '__main__':
asyncio.run(main())It's recommended to use environment variables for sensitive configuration:
export SF_ENDPOINT="YOUR_ENDPOINT_HERE"
export SF_TOKEN="YOUR_TOKEN_HERE"For production, always use TLS:
let config = ClientConfig {
endpoint: "YOUR_ENDPOINT_HERE".to_string(),
bearer_token: Some(std::env::var("SF_TOKEN")?),
tls_enabled: true,
..Default::default()
};- Read the Architecture documentation
- Explore the examples/ directory
- Review the API specifications
- Check the Protocol Buffers schema
- Documentation: https://secure-fabric.io/docs
- Issues: GitHub Issues
- Security: See SECURITY.md
For production deployment of SecureFabric nodes, contact https://secure-fabric.io.