lumefuse-sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +212 -0
- package/dist/index.d.mts +373 -0
- package/dist/index.d.ts +373 -0
- package/dist/index.js +544 -0
- package/dist/index.mjs +509 -0
- package/package.json +64 -0
- package/src/client.ts +391 -0
- package/src/errors.ts +84 -0
- package/src/index.ts +28 -0
- package/src/stream.ts +253 -0
- package/src/types.ts +156 -0
package/README.md
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# LumeFuse JavaScript/TypeScript SDK
|
|
2
|
+
|
|
3
|
+
The official JavaScript/TypeScript SDK for [LumeFuse](https://lumefuse.io) - Atomic Veracity Protocol for Born-Signed Data.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @lumefuse/sdk
|
|
9
|
+
# or
|
|
10
|
+
yarn add @lumefuse/sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { LumeFuse } from '@lumefuse/sdk';
|
|
17
|
+
|
|
18
|
+
// Initialize the client
|
|
19
|
+
const lf = new LumeFuse({ apiKey: 'lf_your_api_key' });
|
|
20
|
+
|
|
21
|
+
// Open a data stream (The "Latch")
|
|
22
|
+
const stream = lf.openStream('medical_lab_results');
|
|
23
|
+
|
|
24
|
+
// Every data point is automatically:
|
|
25
|
+
// 1. Hashed (SHA-256)
|
|
26
|
+
// 2. Linked to previous packet (Recursive DNA)
|
|
27
|
+
// 3. Anchored to BSV ledger
|
|
28
|
+
|
|
29
|
+
await stream.write({ patient_id: 'P-001', glucose: 95, timestamp: '2026-02-20T14:30:00Z' });
|
|
30
|
+
await stream.write({ patient_id: 'P-001', glucose: 102, timestamp: '2026-02-20T15:30:00Z' });
|
|
31
|
+
|
|
32
|
+
// Close stream and get the Merkle root
|
|
33
|
+
const result = await stream.close();
|
|
34
|
+
console.log(`Chain Root: ${result.merkleRoot}`);
|
|
35
|
+
console.log(`Total Packets: ${result.totalPackets}`);
|
|
36
|
+
console.log(`BSV TX: ${result.anchorTxid}`);
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Features
|
|
40
|
+
|
|
41
|
+
### Recursive DNA Binding (The Cryptographic Heartbeat)
|
|
42
|
+
|
|
43
|
+
Every Bit-Packet contains the DNA of the previous packet:
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
H_N = SHA256(Data_N + H_{N-1})
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
This creates an unbreakable chain where altering any packet breaks all subsequent packets.
|
|
50
|
+
|
|
51
|
+
### Quantum Resistance
|
|
52
|
+
|
|
53
|
+
The recursive hashing model provides practical resistance against quantum computing attacks.
|
|
54
|
+
|
|
55
|
+
### Self-Healing Data
|
|
56
|
+
|
|
57
|
+
The Sentinel system automatically detects and heals data corruption:
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
// Verify chain integrity
|
|
61
|
+
const status = await lf.verifyChain('medical_lab_results');
|
|
62
|
+
|
|
63
|
+
if (status.chainIntact) {
|
|
64
|
+
console.log('Data integrity verified');
|
|
65
|
+
} else {
|
|
66
|
+
console.log(`Break detected at sequence ${status.breakSequence}`);
|
|
67
|
+
if (status.healed) {
|
|
68
|
+
console.log('Data automatically healed!');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## API Reference
|
|
74
|
+
|
|
75
|
+
### LumeFuse Client
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
import { LumeFuse } from '@lumefuse/sdk';
|
|
79
|
+
|
|
80
|
+
const lf = new LumeFuse({
|
|
81
|
+
apiKey: 'lf_your_api_key',
|
|
82
|
+
baseUrl: 'https://api.lumefuse.io/v1', // Optional
|
|
83
|
+
timeout: 30000, // Optional, in milliseconds
|
|
84
|
+
autoHeal: true, // Optional
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Data Streams
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
// Open a stream
|
|
92
|
+
const stream = lf.openStream('source_id', {
|
|
93
|
+
autoAnchor: true, // Default: true
|
|
94
|
+
batchSize: 100, // Default: 100
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// Write data (any JSON-serializable object)
|
|
98
|
+
await stream.write({ key: 'value' });
|
|
99
|
+
await stream.write(['array', 'of', 'items']);
|
|
100
|
+
await stream.write('plain string');
|
|
101
|
+
|
|
102
|
+
// Close and get result
|
|
103
|
+
const result = await stream.close();
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Verification
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
// Verify single data item
|
|
110
|
+
const result = await lf.verify({ key: 'value' });
|
|
111
|
+
console.log(`Verified: ${result.verified}`);
|
|
112
|
+
|
|
113
|
+
// Verify entire chain
|
|
114
|
+
const status = await lf.verifyChain('source_id');
|
|
115
|
+
console.log(`Chain intact: ${status.chainIntact}`);
|
|
116
|
+
console.log(`Quantum resistant: ${status.quantumResistant}`);
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Sentinel (Self-Healing)
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
// Get sentinel status
|
|
123
|
+
const status = await lf.getSentinelStatus();
|
|
124
|
+
|
|
125
|
+
// Manually trigger audit
|
|
126
|
+
const audit = await lf.triggerAudit();
|
|
127
|
+
|
|
128
|
+
// Manually heal a break
|
|
129
|
+
const result = await lf.heal('source_id', 5);
|
|
130
|
+
|
|
131
|
+
// Get healing history
|
|
132
|
+
const history = await lf.getHealingHistory('source_id');
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Credits
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
// Get credit balance
|
|
139
|
+
const balance = await lf.getCredits();
|
|
140
|
+
console.log(`Packets available: ${balance.packetsAvailable}`);
|
|
141
|
+
console.log(`Satoshi balance: ${balance.satoshiBalance}`);
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## TypeScript Support
|
|
145
|
+
|
|
146
|
+
Full TypeScript support with type definitions included:
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
import type {
|
|
150
|
+
BitPacket,
|
|
151
|
+
VerificationResult,
|
|
152
|
+
ChainStatus,
|
|
153
|
+
CreditBalance,
|
|
154
|
+
HealingEvent,
|
|
155
|
+
} from '@lumefuse/sdk';
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Error Handling
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
import { LumeFuse } from '@lumefuse/sdk';
|
|
162
|
+
import {
|
|
163
|
+
AuthenticationError,
|
|
164
|
+
RateLimitError,
|
|
165
|
+
ChainIntegrityError,
|
|
166
|
+
InsufficientCreditsError,
|
|
167
|
+
} from '@lumefuse/sdk';
|
|
168
|
+
|
|
169
|
+
try {
|
|
170
|
+
const lf = new LumeFuse({ apiKey: 'lf_invalid' });
|
|
171
|
+
} catch (error) {
|
|
172
|
+
if (error instanceof AuthenticationError) {
|
|
173
|
+
console.log('Invalid API key');
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
try {
|
|
178
|
+
const status = await lf.verifyChain('source', false); // autoHeal = false
|
|
179
|
+
} catch (error) {
|
|
180
|
+
if (error instanceof ChainIntegrityError) {
|
|
181
|
+
console.log(`Chain broken at sequence ${error.breakSequence}`);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Environment Variables
|
|
187
|
+
|
|
188
|
+
- `LUMEFUSE_API_KEY` - Your API key
|
|
189
|
+
- `LUMEFUSE_BASE_URL` - Custom API base URL (optional)
|
|
190
|
+
|
|
191
|
+
## Publishing to npm
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
# Build the package
|
|
195
|
+
npm run build
|
|
196
|
+
|
|
197
|
+
# Login to npm
|
|
198
|
+
npm login
|
|
199
|
+
|
|
200
|
+
# Publish
|
|
201
|
+
npm publish --access public
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## License
|
|
205
|
+
|
|
206
|
+
MIT License - see LICENSE file for details.
|
|
207
|
+
|
|
208
|
+
## Support
|
|
209
|
+
|
|
210
|
+
- Documentation: https://docs.lumefuse.io
|
|
211
|
+
- Email: support@lumefuse.io
|
|
212
|
+
- Enterprise: enterprise@lumefuse.io
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LumeFuse SDK Type Definitions
|
|
3
|
+
*/
|
|
4
|
+
type PacketStatus = 'pending' | 'anchored' | 'verified' | 'corrupted' | 'healed';
|
|
5
|
+
type ChainHealth = 'healthy' | 'infected' | 'quarantined' | 'healing' | 'healed' | 'terminal';
|
|
6
|
+
interface LumeFuseConfig {
|
|
7
|
+
/** Your LumeFuse API key (starts with 'lf_') */
|
|
8
|
+
apiKey: string;
|
|
9
|
+
/** API base URL (default: https://api.lumefuse.io/v1) */
|
|
10
|
+
baseUrl?: string;
|
|
11
|
+
/** Request timeout in milliseconds (default: 30000) */
|
|
12
|
+
timeout?: number;
|
|
13
|
+
/** Whether to automatically heal chain breaks (default: true) */
|
|
14
|
+
autoHeal?: boolean;
|
|
15
|
+
}
|
|
16
|
+
interface BitPacket {
|
|
17
|
+
/** Unique identifier for the data source */
|
|
18
|
+
sourceId: string;
|
|
19
|
+
/** Sequence number in the chain */
|
|
20
|
+
sequenceNo: number;
|
|
21
|
+
/** SHA-256 hash of the payload */
|
|
22
|
+
payloadHash: string;
|
|
23
|
+
/** Recursive DNA linking to previous packet */
|
|
24
|
+
recursiveDna: string;
|
|
25
|
+
/** Previous packet's recursive DNA */
|
|
26
|
+
prevPacketHash: string | null;
|
|
27
|
+
/** Creation timestamp */
|
|
28
|
+
timestamp: string;
|
|
29
|
+
/** BSV transaction ID (if anchored) */
|
|
30
|
+
txId: string | null;
|
|
31
|
+
/** Current status */
|
|
32
|
+
status: PacketStatus;
|
|
33
|
+
/** Whether chain is valid at this point */
|
|
34
|
+
chainValid: boolean;
|
|
35
|
+
/** Preview of original data */
|
|
36
|
+
originalDataPreview?: string;
|
|
37
|
+
}
|
|
38
|
+
interface VerificationResult {
|
|
39
|
+
/** Whether the data was verified */
|
|
40
|
+
verified: boolean;
|
|
41
|
+
/** Source ID */
|
|
42
|
+
sourceId: string;
|
|
43
|
+
/** Hash of the verified data */
|
|
44
|
+
dataHash: string;
|
|
45
|
+
/** Expected hash from ledger */
|
|
46
|
+
expectedHash: string | null;
|
|
47
|
+
/** BSV transaction ID */
|
|
48
|
+
txId: string | null;
|
|
49
|
+
/** Verification timestamp */
|
|
50
|
+
timestamp: string | null;
|
|
51
|
+
/** Human-readable message */
|
|
52
|
+
message: string;
|
|
53
|
+
/** Whether protected by quantum-resistant hashing */
|
|
54
|
+
quantumResistant: boolean;
|
|
55
|
+
}
|
|
56
|
+
interface ChainStatus {
|
|
57
|
+
/** Source ID */
|
|
58
|
+
sourceId: string;
|
|
59
|
+
/** Whether the entire chain is intact */
|
|
60
|
+
chainIntact: boolean;
|
|
61
|
+
/** Total number of packets in chain */
|
|
62
|
+
totalPackets: number;
|
|
63
|
+
/** Number of verified packets */
|
|
64
|
+
verifiedPackets: number;
|
|
65
|
+
/** Sequence number where break occurred (if any) */
|
|
66
|
+
breakSequence: number | null;
|
|
67
|
+
/** Timestamp of break (if any) */
|
|
68
|
+
breakTimestamp: string | null;
|
|
69
|
+
/** Chain health status */
|
|
70
|
+
health: ChainHealth;
|
|
71
|
+
/** Whether protected by quantum-resistant hashing */
|
|
72
|
+
quantumResistant: boolean;
|
|
73
|
+
/** Whether chain was healed */
|
|
74
|
+
healed: boolean;
|
|
75
|
+
/** Forensic analysis message */
|
|
76
|
+
forensicMessage: string | null;
|
|
77
|
+
}
|
|
78
|
+
interface CreditBalance {
|
|
79
|
+
/** Balance in satoshis */
|
|
80
|
+
satoshiBalance: number;
|
|
81
|
+
/** Number of packets that can be created */
|
|
82
|
+
packetsAvailable: number;
|
|
83
|
+
/** Total satoshis deposited */
|
|
84
|
+
totalDeposited: number;
|
|
85
|
+
/** Total satoshis spent */
|
|
86
|
+
totalSpent: number;
|
|
87
|
+
}
|
|
88
|
+
interface HealingEvent {
|
|
89
|
+
/** Unique event ID */
|
|
90
|
+
id: string;
|
|
91
|
+
/** Source ID */
|
|
92
|
+
sourceId: string;
|
|
93
|
+
/** Sequence where break occurred */
|
|
94
|
+
breakSequence: number;
|
|
95
|
+
/** Original payload hash */
|
|
96
|
+
originalHash: string;
|
|
97
|
+
/** Corrupted payload hash */
|
|
98
|
+
corruptedHash: string;
|
|
99
|
+
/** How data was recovered */
|
|
100
|
+
recoverySource: string;
|
|
101
|
+
/** When healing completed */
|
|
102
|
+
healedAt: string;
|
|
103
|
+
/** Whether healing was successful */
|
|
104
|
+
success: boolean;
|
|
105
|
+
/** Immutable receipt hash */
|
|
106
|
+
receiptHash: string | null;
|
|
107
|
+
/** Human-readable message */
|
|
108
|
+
message: string;
|
|
109
|
+
}
|
|
110
|
+
interface SentinelStatus {
|
|
111
|
+
/** Whether sentinel is active */
|
|
112
|
+
active: boolean;
|
|
113
|
+
/** Whether continuous monitoring is running */
|
|
114
|
+
monitoring: boolean;
|
|
115
|
+
/** Audit interval in seconds */
|
|
116
|
+
auditIntervalSeconds: number;
|
|
117
|
+
/** Number of quarantined sources */
|
|
118
|
+
quarantinedSources: number;
|
|
119
|
+
/** Available features */
|
|
120
|
+
features: {
|
|
121
|
+
continuousAudit: boolean;
|
|
122
|
+
autoHeal: boolean;
|
|
123
|
+
webhooks: boolean;
|
|
124
|
+
quantumResistant: boolean;
|
|
125
|
+
};
|
|
126
|
+
/** Description */
|
|
127
|
+
description: string;
|
|
128
|
+
}
|
|
129
|
+
interface AuditResult {
|
|
130
|
+
/** Audit ID */
|
|
131
|
+
auditId: string;
|
|
132
|
+
/** Audit timestamp */
|
|
133
|
+
timestamp: string;
|
|
134
|
+
/** Number of sources audited */
|
|
135
|
+
sourcesAudited: number;
|
|
136
|
+
/** Number of packets verified */
|
|
137
|
+
packetsVerified: number;
|
|
138
|
+
/** Number of healthy sources */
|
|
139
|
+
healthySources: number;
|
|
140
|
+
/** Number of infected sources */
|
|
141
|
+
infectedSources: number;
|
|
142
|
+
/** Number of healed sources */
|
|
143
|
+
healedSources: number;
|
|
144
|
+
/** Audit duration in milliseconds */
|
|
145
|
+
auditDurationMs: number;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* LumeFuse DataStream - The "Latch" for Born-Signed Data
|
|
150
|
+
*/
|
|
151
|
+
|
|
152
|
+
interface StreamResult {
|
|
153
|
+
/** Source ID */
|
|
154
|
+
sourceId: string;
|
|
155
|
+
/** Total packets created */
|
|
156
|
+
totalPackets: number;
|
|
157
|
+
/** Merkle root of all packet hashes */
|
|
158
|
+
merkleRoot: string;
|
|
159
|
+
/** Last anchor transaction ID */
|
|
160
|
+
anchorTxid: string | null;
|
|
161
|
+
/** All created packets */
|
|
162
|
+
packets: BitPacket[];
|
|
163
|
+
/** Stream creation timestamp */
|
|
164
|
+
createdAt: string;
|
|
165
|
+
/** Whether chain is quantum resistant */
|
|
166
|
+
quantumResistant: boolean;
|
|
167
|
+
}
|
|
168
|
+
interface StreamConfig {
|
|
169
|
+
/** Whether to automatically anchor packets */
|
|
170
|
+
autoAnchor?: boolean;
|
|
171
|
+
/** Number of packets to batch before anchoring */
|
|
172
|
+
batchSize?: number;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* A data stream for creating Bit-Packets with Recursive DNA Binding.
|
|
176
|
+
*
|
|
177
|
+
* This is the core "Latch" - data written to this stream is automatically:
|
|
178
|
+
* 1. Hashed (SHA-256)
|
|
179
|
+
* 2. Linked to previous packet (Recursive DNA)
|
|
180
|
+
* 3. Queued for BSV anchoring
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* ```typescript
|
|
184
|
+
* const stream = lf.openStream('sensor_data');
|
|
185
|
+
* await stream.write({ temperature: 72.5, humidity: 45 });
|
|
186
|
+
* await stream.write({ temperature: 73.1, humidity: 44 });
|
|
187
|
+
* const result = await stream.close();
|
|
188
|
+
* console.log(`Merkle Root: ${result.merkleRoot}`);
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
declare class DataStream {
|
|
192
|
+
private sourceId;
|
|
193
|
+
private client;
|
|
194
|
+
private autoAnchor;
|
|
195
|
+
private batchSize;
|
|
196
|
+
private packets;
|
|
197
|
+
private prevRecursiveDna;
|
|
198
|
+
private sequenceNo;
|
|
199
|
+
private closed;
|
|
200
|
+
private createdAt;
|
|
201
|
+
constructor(sourceId: string, client: any, config?: StreamConfig);
|
|
202
|
+
/**
|
|
203
|
+
* Compute SHA-256 hash of data
|
|
204
|
+
*/
|
|
205
|
+
private computeHash;
|
|
206
|
+
/**
|
|
207
|
+
* Compute Recursive DNA - the Cryptographic Heartbeat
|
|
208
|
+
* Formula: recursive_dna[N] = SHA256(payload_hash[N] + recursive_dna[N-1])
|
|
209
|
+
*/
|
|
210
|
+
private computeRecursiveDna;
|
|
211
|
+
/**
|
|
212
|
+
* Write data to the stream, creating a Bit-Packet with Recursive DNA
|
|
213
|
+
*/
|
|
214
|
+
write(data: unknown): Promise<BitPacket>;
|
|
215
|
+
/**
|
|
216
|
+
* Write multiple data items to the stream
|
|
217
|
+
*/
|
|
218
|
+
writeMany(dataList: unknown[]): Promise<BitPacket[]>;
|
|
219
|
+
/**
|
|
220
|
+
* Anchor pending packets to BSV (internal method)
|
|
221
|
+
*/
|
|
222
|
+
private anchorBatch;
|
|
223
|
+
/**
|
|
224
|
+
* Compute Merkle root of all packet hashes
|
|
225
|
+
*/
|
|
226
|
+
private computeMerkleRoot;
|
|
227
|
+
/**
|
|
228
|
+
* Close the stream and finalize all packets
|
|
229
|
+
*/
|
|
230
|
+
close(): Promise<StreamResult>;
|
|
231
|
+
/**
|
|
232
|
+
* Number of packets written to this stream
|
|
233
|
+
*/
|
|
234
|
+
get packetCount(): number;
|
|
235
|
+
/**
|
|
236
|
+
* Whether the stream is closed
|
|
237
|
+
*/
|
|
238
|
+
get isClosed(): boolean;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* LumeFuse Client - Main SDK Client
|
|
243
|
+
*/
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* LumeFuse SDK Client - The "Born-Signed" Data Integrity Platform
|
|
247
|
+
*
|
|
248
|
+
* This client provides methods to:
|
|
249
|
+
* - Open data streams for Bit-Packet creation
|
|
250
|
+
* - Verify data against the BSV ledger
|
|
251
|
+
* - Check chain integrity
|
|
252
|
+
* - Monitor healing events
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```typescript
|
|
256
|
+
* import { LumeFuse } from '@lumefuse/sdk';
|
|
257
|
+
*
|
|
258
|
+
* const lf = new LumeFuse({ apiKey: 'lf_your_api_key' });
|
|
259
|
+
*
|
|
260
|
+
* // Create a data stream
|
|
261
|
+
* const stream = lf.openStream('sensor_data');
|
|
262
|
+
* await stream.write({ temperature: 72.5 });
|
|
263
|
+
* const result = await stream.close();
|
|
264
|
+
*
|
|
265
|
+
* // Verify chain integrity
|
|
266
|
+
* const status = await lf.verifyChain('sensor_data');
|
|
267
|
+
* console.log(`Chain intact: ${status.chainIntact}`);
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
|
+
declare class LumeFuse {
|
|
271
|
+
private apiKey;
|
|
272
|
+
private baseUrl;
|
|
273
|
+
private timeout;
|
|
274
|
+
private autoHeal;
|
|
275
|
+
constructor(config: LumeFuseConfig);
|
|
276
|
+
/**
|
|
277
|
+
* Make an API request
|
|
278
|
+
*/
|
|
279
|
+
private request;
|
|
280
|
+
/**
|
|
281
|
+
* Open a new data stream for Bit-Packet creation.
|
|
282
|
+
*
|
|
283
|
+
* This is the core "Latch" - data written to the returned stream is
|
|
284
|
+
* automatically hashed, linked with Recursive DNA, and anchored to BSV.
|
|
285
|
+
*
|
|
286
|
+
* @param sourceId - Unique identifier for this data source
|
|
287
|
+
* @param config - Stream configuration options
|
|
288
|
+
* @returns DataStream for writing data
|
|
289
|
+
*
|
|
290
|
+
* @example
|
|
291
|
+
* ```typescript
|
|
292
|
+
* const stream = lf.openStream('medical_lab_results');
|
|
293
|
+
* await stream.write({ patient_id: 'P-001', glucose: 95 });
|
|
294
|
+
* await stream.write({ patient_id: 'P-001', glucose: 102 });
|
|
295
|
+
* const result = await stream.close();
|
|
296
|
+
* console.log(`Merkle Root: ${result.merkleRoot}`);
|
|
297
|
+
* ```
|
|
298
|
+
*/
|
|
299
|
+
openStream(sourceId: string, config?: StreamConfig): DataStream;
|
|
300
|
+
/**
|
|
301
|
+
* Wrap data into a single Bit-Packet with Recursive DNA.
|
|
302
|
+
*/
|
|
303
|
+
wrap(sourceId: string, data: unknown): Promise<BitPacket>;
|
|
304
|
+
/**
|
|
305
|
+
* Verify data against the BSV ledger.
|
|
306
|
+
*/
|
|
307
|
+
verify(data: unknown): Promise<VerificationResult>;
|
|
308
|
+
/**
|
|
309
|
+
* Verify the entire Recursive DNA chain for a source.
|
|
310
|
+
*/
|
|
311
|
+
verifyChain(sourceId: string, autoHeal?: boolean): Promise<ChainStatus>;
|
|
312
|
+
/**
|
|
313
|
+
* Get the current status of the Sentinel (self-healing system).
|
|
314
|
+
*/
|
|
315
|
+
getSentinelStatus(): Promise<SentinelStatus>;
|
|
316
|
+
/**
|
|
317
|
+
* Manually trigger a full audit of all data sources.
|
|
318
|
+
*/
|
|
319
|
+
triggerAudit(): Promise<AuditResult>;
|
|
320
|
+
/**
|
|
321
|
+
* Manually trigger healing for a specific data break.
|
|
322
|
+
*/
|
|
323
|
+
heal(sourceId: string, breakSequence: number): Promise<Record<string, unknown>>;
|
|
324
|
+
/**
|
|
325
|
+
* Get history of healing events.
|
|
326
|
+
*/
|
|
327
|
+
getHealingHistory(sourceId?: string): Promise<HealingEvent[]>;
|
|
328
|
+
/**
|
|
329
|
+
* Get current BSV credit balance.
|
|
330
|
+
*/
|
|
331
|
+
getCredits(): Promise<CreditBalance>;
|
|
332
|
+
/**
|
|
333
|
+
* Get all packets for a source.
|
|
334
|
+
*/
|
|
335
|
+
getPackets(sourceId: string, limit?: number): Promise<BitPacket[]>;
|
|
336
|
+
private mapBitPacket;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* LumeFuse SDK Error Classes
|
|
341
|
+
*/
|
|
342
|
+
declare class LumeFuseError extends Error {
|
|
343
|
+
code: string;
|
|
344
|
+
details: Record<string, unknown>;
|
|
345
|
+
constructor(message: string, code?: string, details?: Record<string, unknown>);
|
|
346
|
+
}
|
|
347
|
+
declare class AuthenticationError extends LumeFuseError {
|
|
348
|
+
constructor(message?: string);
|
|
349
|
+
}
|
|
350
|
+
declare class RateLimitError extends LumeFuseError {
|
|
351
|
+
retryAfter: number | null;
|
|
352
|
+
constructor(message?: string, retryAfter?: number | null);
|
|
353
|
+
}
|
|
354
|
+
declare class ChainIntegrityError extends LumeFuseError {
|
|
355
|
+
breakSequence: number | null;
|
|
356
|
+
breakTimestamp: string | null;
|
|
357
|
+
constructor(message?: string, breakSequence?: number | null, breakTimestamp?: string | null);
|
|
358
|
+
}
|
|
359
|
+
declare class InsufficientCreditsError extends LumeFuseError {
|
|
360
|
+
required: number | null;
|
|
361
|
+
available: number | null;
|
|
362
|
+
constructor(message?: string, required?: number | null, available?: number | null);
|
|
363
|
+
}
|
|
364
|
+
declare class NetworkError extends LumeFuseError {
|
|
365
|
+
statusCode: number | null;
|
|
366
|
+
constructor(message?: string, statusCode?: number | null);
|
|
367
|
+
}
|
|
368
|
+
declare class ValidationError extends LumeFuseError {
|
|
369
|
+
field: string | null;
|
|
370
|
+
constructor(message?: string, field?: string | null);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
export { AuthenticationError, type BitPacket, type ChainHealth, ChainIntegrityError, type ChainStatus, type CreditBalance, DataStream, type HealingEvent, InsufficientCreditsError, LumeFuse, type LumeFuseConfig, LumeFuseError, NetworkError, type PacketStatus, RateLimitError, type StreamResult, ValidationError, type VerificationResult };
|