lumefuse-sdk
v1.0.0
Published
LumeFuse SDK - Atomic Veracity Protocol for Born-Signed Data
Downloads
21
Maintainers
Readme
LumeFuse JavaScript/TypeScript SDK
The official JavaScript/TypeScript SDK for LumeFuse - Atomic Veracity Protocol for Born-Signed Data.
Installation
npm install @lumefuse/sdk
# or
yarn add @lumefuse/sdkQuick Start
import { LumeFuse } from '@lumefuse/sdk';
// Initialize the client
const lf = new LumeFuse({ apiKey: 'lf_your_api_key' });
// Open a data stream (The "Latch")
const stream = lf.openStream('medical_lab_results');
// Every data point is automatically:
// 1. Hashed (SHA-256)
// 2. Linked to previous packet (Recursive DNA)
// 3. Anchored to BSV ledger
await stream.write({ patient_id: 'P-001', glucose: 95, timestamp: '2026-02-20T14:30:00Z' });
await stream.write({ patient_id: 'P-001', glucose: 102, timestamp: '2026-02-20T15:30:00Z' });
// Close stream and get the Merkle root
const result = await stream.close();
console.log(`Chain Root: ${result.merkleRoot}`);
console.log(`Total Packets: ${result.totalPackets}`);
console.log(`BSV TX: ${result.anchorTxid}`);Features
Recursive DNA Binding (The Cryptographic Heartbeat)
Every Bit-Packet contains the DNA of the previous packet:
H_N = SHA256(Data_N + H_{N-1})This creates an unbreakable chain where altering any packet breaks all subsequent packets.
Quantum Resistance
The recursive hashing model provides practical resistance against quantum computing attacks.
Self-Healing Data
The Sentinel system automatically detects and heals data corruption:
// Verify chain integrity
const status = await lf.verifyChain('medical_lab_results');
if (status.chainIntact) {
console.log('Data integrity verified');
} else {
console.log(`Break detected at sequence ${status.breakSequence}`);
if (status.healed) {
console.log('Data automatically healed!');
}
}API Reference
LumeFuse Client
import { LumeFuse } from '@lumefuse/sdk';
const lf = new LumeFuse({
apiKey: 'lf_your_api_key',
baseUrl: 'https://api.lumefuse.io/v1', // Optional
timeout: 30000, // Optional, in milliseconds
autoHeal: true, // Optional
});Data Streams
// Open a stream
const stream = lf.openStream('source_id', {
autoAnchor: true, // Default: true
batchSize: 100, // Default: 100
});
// Write data (any JSON-serializable object)
await stream.write({ key: 'value' });
await stream.write(['array', 'of', 'items']);
await stream.write('plain string');
// Close and get result
const result = await stream.close();Verification
// Verify single data item
const result = await lf.verify({ key: 'value' });
console.log(`Verified: ${result.verified}`);
// Verify entire chain
const status = await lf.verifyChain('source_id');
console.log(`Chain intact: ${status.chainIntact}`);
console.log(`Quantum resistant: ${status.quantumResistant}`);Sentinel (Self-Healing)
// Get sentinel status
const status = await lf.getSentinelStatus();
// Manually trigger audit
const audit = await lf.triggerAudit();
// Manually heal a break
const result = await lf.heal('source_id', 5);
// Get healing history
const history = await lf.getHealingHistory('source_id');Credits
// Get credit balance
const balance = await lf.getCredits();
console.log(`Packets available: ${balance.packetsAvailable}`);
console.log(`Satoshi balance: ${balance.satoshiBalance}`);TypeScript Support
Full TypeScript support with type definitions included:
import type {
BitPacket,
VerificationResult,
ChainStatus,
CreditBalance,
HealingEvent,
} from '@lumefuse/sdk';Error Handling
import { LumeFuse } from '@lumefuse/sdk';
import {
AuthenticationError,
RateLimitError,
ChainIntegrityError,
InsufficientCreditsError,
} from '@lumefuse/sdk';
try {
const lf = new LumeFuse({ apiKey: 'lf_invalid' });
} catch (error) {
if (error instanceof AuthenticationError) {
console.log('Invalid API key');
}
}
try {
const status = await lf.verifyChain('source', false); // autoHeal = false
} catch (error) {
if (error instanceof ChainIntegrityError) {
console.log(`Chain broken at sequence ${error.breakSequence}`);
}
}Environment Variables
LUMEFUSE_API_KEY- Your API keyLUMEFUSE_BASE_URL- Custom API base URL (optional)
Publishing to npm
# Build the package
npm run build
# Login to npm
npm login
# Publish
npm publish --access publicLicense
MIT License - see LICENSE file for details.
Support
- Documentation: https://docs.lumefuse.io
- Email: [email protected]
- Enterprise: [email protected]
