@brightchain/brightchain-lib 0.20.0 → 0.21.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/package.json +5 -1
- package/brightchain-lib/BLOCK_COVERAGE_AUDIT.md +0 -169
- package/brightchain-lib/BROWSER_COMPAT.md +0 -54
- package/brightchain-lib/DEPRECATIONS.md +0 -454
- package/brightchain-lib/DEPRECATIONS_REMOVED.md +0 -160
- package/brightchain-lib/MIGRATION.md +0 -801
- package/brightchain-lib/NAMING_AUDIT.md +0 -233
- package/brightchain-lib/NAMING_CONVENTIONS.md +0 -346
- package/brightchain-lib/README.md +0 -611
package/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightchain/brightchain-lib",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "BrightChain core library - browser-compatible blockchain storage",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
7
7
|
"browser": "src/browser.js",
|
|
8
|
+
"files": [
|
|
9
|
+
"src",
|
|
10
|
+
"README.md"
|
|
11
|
+
],
|
|
8
12
|
"exports": {
|
|
9
13
|
".": {
|
|
10
14
|
"types": "./src/index.d.ts",
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
# Block Test Coverage Audit
|
|
2
|
-
|
|
3
|
-
**Date**: 2026-01-24
|
|
4
|
-
**Overall Coverage**: 61.6% statements, 46.76% branches, 51.8% functions, 62.04% lines
|
|
5
|
-
|
|
6
|
-
## Block Files Below 90% Coverage
|
|
7
|
-
|
|
8
|
-
### Critical Block Files (Core Block Types)
|
|
9
|
-
|
|
10
|
-
| File | Statements | Branches | Functions | Lines | Priority |
|
|
11
|
-
|------|-----------|----------|-----------|-------|----------|
|
|
12
|
-
| `lib/blocks/encrypted.ts` | 25.66% | 22% | 30.43% | 25.66% | **HIGH** |
|
|
13
|
-
| `lib/blocks/extendedCbl.ts` | 6.06% | 0% | 0% | 6.06% | **HIGH** |
|
|
14
|
-
| `lib/blocks/cblBase.ts` | 50.96% | 49.09% | 47.61% | 51.45% | **HIGH** |
|
|
15
|
-
| `lib/blocks/ephemeral.ts` | 66.36% | 60.46% | 93.75% | 66.36% | **MEDIUM** |
|
|
16
|
-
| `lib/blocks/handleTuple.ts` | 60.34% | 26.31% | 58.33% | 59.61% | **MEDIUM** |
|
|
17
|
-
| `lib/blocks/memoryTuple.ts` | 21.21% | 12.5% | 20% | 21.31% | **MEDIUM** |
|
|
18
|
-
| `lib/blocks/parity.ts` | 85.71% | 75% | 100% | 85.71% | **LOW** |
|
|
19
|
-
| `lib/blocks/base.ts` | 81.25% | 58.33% | 73.68% | 80.43% | **LOW** |
|
|
20
|
-
| `lib/blocks/cbl.ts` | 71.42% | 100% | 33.33% | 71.42% | **LOW** |
|
|
21
|
-
| `lib/blocks/whitened.ts` | 70.76% | 90.9% | 78.57% | 70.96% | **LOW** |
|
|
22
|
-
| `lib/blocks/random.ts` | 70.73% | 90% | 83.33% | 71.79% | **LOW** |
|
|
23
|
-
|
|
24
|
-
### Block Metadata Files
|
|
25
|
-
|
|
26
|
-
| File | Statements | Branches | Functions | Lines | Priority |
|
|
27
|
-
|------|-----------|----------|-----------|-------|----------|
|
|
28
|
-
| `lib/encryptedBlockMetadata.ts` | 61.53% | 53.84% | 50% | 61.53% | **MEDIUM** |
|
|
29
|
-
| `lib/cblBlockMetadata.ts` | 0% | 100% | 0% | 0% | **HIGH** |
|
|
30
|
-
| `lib/extendedCblBlockMetadata.ts` | 0% | 100% | 0% | 0% | **HIGH** |
|
|
31
|
-
|
|
32
|
-
### Block-Related Services
|
|
33
|
-
|
|
34
|
-
| File | Statements | Branches | Functions | Lines | Priority |
|
|
35
|
-
|------|-----------|----------|-----------|-------|----------|
|
|
36
|
-
| `lib/services/blockService.ts` | 26.95% | 10% | 25% | 26.69% | **HIGH** |
|
|
37
|
-
| `lib/services/tuple.service.ts` | 32.54% | 18.36% | 42.1% | 33.33% | **HIGH** |
|
|
38
|
-
|
|
39
|
-
## Coverage Gaps by Category
|
|
40
|
-
|
|
41
|
-
### 1. Edge Cases Not Tested
|
|
42
|
-
|
|
43
|
-
#### Empty Data Blocks
|
|
44
|
-
- **Missing**: Tests for blocks with zero-length data
|
|
45
|
-
- **Files affected**: `base.ts`, `rawData.ts`, `ephemeral.ts`
|
|
46
|
-
- **Lines uncovered**: Base block constructor edge cases
|
|
47
|
-
|
|
48
|
-
#### Maximum Size Blocks
|
|
49
|
-
- **Missing**: Tests for blocks at BlockSize limits (Small=1024, Medium=4096, Large=32768, Huge=262144)
|
|
50
|
-
- **Files affected**: All block types
|
|
51
|
-
- **Lines uncovered**: Size validation paths
|
|
52
|
-
|
|
53
|
-
#### Invalid Checksum Handling
|
|
54
|
-
- **Missing**: Comprehensive tests for checksum mismatch scenarios
|
|
55
|
-
- **Files affected**: `base.ts` (lines 248-261), `rawData.ts` (lines 86-97)
|
|
56
|
-
- **Lines uncovered**: Checksum validation error paths
|
|
57
|
-
|
|
58
|
-
#### Boundary Conditions
|
|
59
|
-
- **Missing**: Tests for:
|
|
60
|
-
- Blocks exactly at size boundaries
|
|
61
|
-
- Blocks with padding edge cases
|
|
62
|
-
- Blocks with maximum tuple counts
|
|
63
|
-
- **Files affected**: `cblBase.ts`, `handleTuple.ts`, `memoryTuple.ts`
|
|
64
|
-
|
|
65
|
-
### 2. Error Conditions Not Tested
|
|
66
|
-
|
|
67
|
-
#### EncryptedBlock Errors (25.66% coverage)
|
|
68
|
-
- **Uncovered lines**: 53, 267-271, 300-314, 317, 325-354, 382, 399, 410-777
|
|
69
|
-
- **Missing error tests**:
|
|
70
|
-
- Decryption failures with invalid keys
|
|
71
|
-
- Encryption with missing recipients
|
|
72
|
-
- Malformed encrypted data parsing
|
|
73
|
-
- ECIES encryption/decryption errors
|
|
74
|
-
- Multi-recipient encryption edge cases
|
|
75
|
-
|
|
76
|
-
#### ExtendedCBL Errors (6.06% coverage)
|
|
77
|
-
- **Uncovered lines**: 32-269 (almost entire file)
|
|
78
|
-
- **Missing error tests**:
|
|
79
|
-
- Invalid file name encoding
|
|
80
|
-
- Invalid MIME type
|
|
81
|
-
- Extended header parsing failures
|
|
82
|
-
- File name length validation
|
|
83
|
-
|
|
84
|
-
#### CBLBase Errors (50.96% coverage)
|
|
85
|
-
- **Uncovered lines**: 108, 221-225, 248-249, 272-273, 288-330, 340, 356-390
|
|
86
|
-
- **Missing error tests**:
|
|
87
|
-
- Invalid address count
|
|
88
|
-
- Tuple size validation failures
|
|
89
|
-
- Circular dependency scenarios
|
|
90
|
-
- Cache invalidation edge cases
|
|
91
|
-
|
|
92
|
-
#### BlockService Errors (26.95% coverage)
|
|
93
|
-
- **Uncovered lines**: 46-120, 154, 156, 158, 172, 230-699, 764-833
|
|
94
|
-
- **Missing error tests**:
|
|
95
|
-
- Service initialization failures
|
|
96
|
-
- Block creation with invalid parameters
|
|
97
|
-
- Encryption service unavailable
|
|
98
|
-
- Validation service failures
|
|
99
|
-
|
|
100
|
-
### 3. Constructor Invariants Not Property-Tested
|
|
101
|
-
|
|
102
|
-
#### Missing Property Tests for:
|
|
103
|
-
1. **BaseBlock**: Constructor should maintain data integrity
|
|
104
|
-
2. **EphemeralBlock**: Creator ID should be preserved
|
|
105
|
-
3. **EncryptedBlock**: Encryption details should be cached correctly
|
|
106
|
-
4. **CBLBase**: Address count should match parsed addresses
|
|
107
|
-
5. **ExtendedCBL**: File metadata should round-trip correctly
|
|
108
|
-
6. **WhitenedBlock**: Whitening should be reversible
|
|
109
|
-
7. **RandomBlock**: Random data should have correct entropy
|
|
110
|
-
8. **HandleTuple**: Tuple handles should be valid
|
|
111
|
-
9. **MemoryTuple**: Memory tuples should maintain consistency
|
|
112
|
-
|
|
113
|
-
## Recommended Test Additions
|
|
114
|
-
|
|
115
|
-
### High Priority (Task 12.2 - Edge Cases)
|
|
116
|
-
1. **Empty data block tests** - All block types with zero-length data
|
|
117
|
-
2. **Maximum size block tests** - All block types at size limits
|
|
118
|
-
3. **Invalid checksum tests** - Comprehensive checksum mismatch scenarios
|
|
119
|
-
4. **Boundary condition tests** - Size boundaries, padding edge cases
|
|
120
|
-
|
|
121
|
-
### High Priority (Task 12.3 - Error Conditions)
|
|
122
|
-
1. **EncryptedBlock error tests** - All encryption/decryption failure paths
|
|
123
|
-
2. **ExtendedCBL error tests** - File metadata validation failures
|
|
124
|
-
3. **CBLBase error tests** - Address validation and cache errors
|
|
125
|
-
4. **BlockService error tests** - Service initialization and operation failures
|
|
126
|
-
|
|
127
|
-
### High Priority (Task 12.4 - Property Tests)
|
|
128
|
-
1. **Block constructor property tests** - Invariants for all block types
|
|
129
|
-
2. **Serialization round-trip property tests** - All block types
|
|
130
|
-
3. **Immutability property tests** - Already implemented (passing)
|
|
131
|
-
4. **Cache consistency property tests** - CBL and EncryptedBlock caches
|
|
132
|
-
|
|
133
|
-
## Files Requiring Immediate Attention
|
|
134
|
-
|
|
135
|
-
### Critical (< 30% coverage)
|
|
136
|
-
1. `lib/blocks/encrypted.ts` (25.66%) - Core encryption functionality
|
|
137
|
-
2. `lib/services/blockService.ts` (26.95%) - Core block operations
|
|
138
|
-
3. `lib/blocks/memoryTuple.ts` (21.21%) - Tuple storage
|
|
139
|
-
4. `lib/blocks/extendedCbl.ts` (6.06%) - Extended CBL functionality
|
|
140
|
-
5. `lib/cblBlockMetadata.ts` (0%) - CBL metadata
|
|
141
|
-
6. `lib/extendedCblBlockMetadata.ts` (0%) - Extended CBL metadata
|
|
142
|
-
|
|
143
|
-
### Important (30-70% coverage)
|
|
144
|
-
1. `lib/blocks/cblBase.ts` (50.96%) - CBL base functionality
|
|
145
|
-
2. `lib/blocks/ephemeral.ts` (66.36%) - Ephemeral blocks
|
|
146
|
-
3. `lib/blocks/handleTuple.ts` (60.34%) - Handle tuples
|
|
147
|
-
4. `lib/encryptedBlockMetadata.ts` (61.53%) - Encrypted metadata
|
|
148
|
-
5. `lib/services/tuple.service.ts` (32.54%) - Tuple service
|
|
149
|
-
|
|
150
|
-
## Coverage Goal
|
|
151
|
-
|
|
152
|
-
**Target**: 90% coverage for all block-related files
|
|
153
|
-
**Current**: 61.6% overall, with critical block files at 25-50%
|
|
154
|
-
**Gap**: Need to add approximately 200-300 test cases to reach target
|
|
155
|
-
|
|
156
|
-
## Notes
|
|
157
|
-
|
|
158
|
-
- Existing property tests are passing and provide good coverage for:
|
|
159
|
-
- XOR operations (constantTimeXor)
|
|
160
|
-
- Type guards (typeGuards)
|
|
161
|
-
- Date utilities (dateUtils)
|
|
162
|
-
- Block immutability (immutability.property.spec.ts)
|
|
163
|
-
- CBL consistency (cbl.consistency.property.spec.ts)
|
|
164
|
-
|
|
165
|
-
- Need to focus on:
|
|
166
|
-
- EncryptedBlock encryption/decryption paths
|
|
167
|
-
- ExtendedCBL file metadata handling
|
|
168
|
-
- BlockService initialization and operations
|
|
169
|
-
- Error condition coverage across all block types
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
# Browser Compatibility Guide — `brightchain-lib`
|
|
2
|
-
|
|
3
|
-
`brightchain-lib` is the shared library used by both frontend (`brightchain-react`) and backend (`brightchain-api-lib`, `brightchain-db`) packages. It should remain browser-compatible wherever possible so that types, interfaces, and core logic can be consumed by web applications without Node.js polyfills.
|
|
4
|
-
|
|
5
|
-
## Platform Detection Boundary Pattern
|
|
6
|
-
|
|
7
|
-
When Node.js-specific code is unavoidable, `brightchain-lib` uses a **platform detection boundary** to isolate it. The canonical example is [`src/lib/crypto/platformCrypto.ts`](src/lib/crypto/platformCrypto.ts):
|
|
8
|
-
|
|
9
|
-
```typescript
|
|
10
|
-
import { isBrowserEnvironment } from './platformCrypto';
|
|
11
|
-
|
|
12
|
-
if (isBrowserEnvironment()) {
|
|
13
|
-
// Use Web Crypto API (window.crypto.getRandomValues)
|
|
14
|
-
} else {
|
|
15
|
-
// Lazy-load Node.js crypto via require('crypto')
|
|
16
|
-
}
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
Key rules for this pattern:
|
|
20
|
-
|
|
21
|
-
1. **Never import Node.js modules at the top level.** Use dynamic `require()` inside a runtime branch so bundlers can tree-shake the Node.js path.
|
|
22
|
-
2. **Detect the environment at call time**, not at module load time. Use `isBrowserEnvironment()` / `isNodeEnvironment()` from `platformCrypto.ts`.
|
|
23
|
-
3. **Prefer cross-platform libraries** (`@noble/hashes`, `@noble/curves`, `TextEncoder`/`TextDecoder`) over platform-specific APIs when performance is acceptable.
|
|
24
|
-
|
|
25
|
-
## Known Platform-Specific Files
|
|
26
|
-
|
|
27
|
-
| File | Node.js Dependency | Why It Exists | Notes |
|
|
28
|
-
| ------------------------------------------- | ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
|
|
29
|
-
| `src/lib/crypto/platformCrypto.ts` | `require('crypto')` (lazy) | `getRandomBytes()` needs a CSPRNG; Web Crypto API has a 65 KB limit per call | Already behind platform detection boundary — the correct pattern |
|
|
30
|
-
| `src/lib/services/messaging/emailParser.ts` | `Buffer.from()` | Base64/quoted-printable decoding and charset conversion (ISO-8859-1, ASCII, etc.) in RFC 2047 encoded-word handling | Could be replaced with `TextDecoder` + `atob()` for browser use, or moved to `brightchain-api-lib` |
|
|
31
|
-
| `src/lib/types/checksum.ts` | `Buffer` type in `fromBuffer()` / `toBuffer()` | Convenience methods for Node.js callers | Both methods are **deprecated** — use `fromUint8Array()` / `toUint8Array()` instead. Internal storage is already `Uint8Array` |
|
|
32
|
-
|
|
33
|
-
## Guidelines for Contributors
|
|
34
|
-
|
|
35
|
-
### Do
|
|
36
|
-
|
|
37
|
-
- Use `Uint8Array` in all new interfaces and shared types. `Buffer` is a Node.js-only global.
|
|
38
|
-
- Use `TextEncoder` / `TextDecoder` for string ↔ bytes conversion.
|
|
39
|
-
- Use `@noble/hashes` and `@noble/curves` for cryptographic operations (already project dependencies).
|
|
40
|
-
- Use `crypto.getRandomValues()` (Web Crypto API) for random bytes in browser-targeted code.
|
|
41
|
-
- Mark any unavoidable Node.js code with `@platform Node.js` in its JSDoc.
|
|
42
|
-
|
|
43
|
-
### Don't
|
|
44
|
-
|
|
45
|
-
- Import `fs`, `path`, `crypto`, `os`, `net`, `child_process`, or `buffer` at the top level of any file in `brightchain-lib`.
|
|
46
|
-
- Use `Buffer` in interface definitions — use `Uint8Array` with a generic type parameter (`<TData>`) if backend code needs `Buffer`.
|
|
47
|
-
- Add Node.js-only dependencies to `brightchain-lib`'s `package.json`. If a dependency requires Node.js, the code belongs in `brightchain-api-lib` or `brightchain-db`.
|
|
48
|
-
|
|
49
|
-
### When Node.js Code Is Unavoidable
|
|
50
|
-
|
|
51
|
-
1. Isolate it behind the platform detection boundary (see pattern above).
|
|
52
|
-
2. Add a `@platform Node.js` JSDoc tag explaining what Node.js API is used and why.
|
|
53
|
-
3. Add an entry to the table in this file.
|
|
54
|
-
4. Consider whether the code should live in `brightchain-api-lib` instead.
|
|
@@ -1,454 +0,0 @@
|
|
|
1
|
-
# BrightChain Deprecations
|
|
2
|
-
|
|
3
|
-
This document lists all deprecated APIs in BrightChain and their recommended replacements.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
Deprecated APIs are marked with `@deprecated` JSDoc tags and will emit warnings when used. All deprecated APIs will be removed in version 3.0.0.
|
|
8
|
-
|
|
9
|
-
**Timeline:**
|
|
10
|
-
- **v2.0**: Deprecated APIs marked, warnings added
|
|
11
|
-
- **v2.x**: Deprecated APIs still functional
|
|
12
|
-
- **v3.0**: Deprecated APIs removed (planned Q4 2024)
|
|
13
|
-
|
|
14
|
-
## Deprecated APIs
|
|
15
|
-
|
|
16
|
-
### Checksum Types
|
|
17
|
-
|
|
18
|
-
#### ChecksumBuffer
|
|
19
|
-
**Status:** Deprecated in v2.0, will be removed in v3.0
|
|
20
|
-
|
|
21
|
-
**Old:**
|
|
22
|
-
```typescript
|
|
23
|
-
import { ChecksumBuffer } from 'brightchain-lib';
|
|
24
|
-
const checksum: ChecksumBuffer = Buffer.from(...);
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
**New:**
|
|
28
|
-
```typescript
|
|
29
|
-
import { Checksum } from 'brightchain-lib';
|
|
30
|
-
const checksum = Checksum.fromBuffer(Buffer.from(...));
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
**Reason:** Unified checksum type system provides better type safety and consistent API.
|
|
34
|
-
|
|
35
|
-
---
|
|
36
|
-
|
|
37
|
-
#### ChecksumUint8Array
|
|
38
|
-
**Status:** Deprecated in v2.0, will be removed in v3.0
|
|
39
|
-
|
|
40
|
-
**Old:**
|
|
41
|
-
```typescript
|
|
42
|
-
import { ChecksumUint8Array } from 'brightchain-lib';
|
|
43
|
-
const checksum: ChecksumUint8Array = new Uint8Array(...);
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
**New:**
|
|
47
|
-
```typescript
|
|
48
|
-
import { Checksum } from 'brightchain-lib';
|
|
49
|
-
const checksum = Checksum.fromUint8Array(new Uint8Array(...));
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
**Reason:** Unified checksum type system provides better type safety and consistent API.
|
|
53
|
-
|
|
54
|
-
---
|
|
55
|
-
|
|
56
|
-
### ChecksumService Methods
|
|
57
|
-
|
|
58
|
-
#### calculateChecksum()
|
|
59
|
-
**Status:** Deprecated in v2.0, will be removed in v3.0
|
|
60
|
-
|
|
61
|
-
**Old:**
|
|
62
|
-
```typescript
|
|
63
|
-
const checksum = checksumService.calculateChecksum(data);
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
**New:**
|
|
67
|
-
```typescript
|
|
68
|
-
const checksum = checksumService.calculateChecksumAsClass(data);
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
**Reason:** New method returns Checksum class instance with helpful methods.
|
|
72
|
-
|
|
73
|
-
---
|
|
74
|
-
|
|
75
|
-
#### calculateChecksumForBuffers()
|
|
76
|
-
**Status:** Deprecated in v2.0, will be removed in v3.0
|
|
77
|
-
|
|
78
|
-
**Old:**
|
|
79
|
-
```typescript
|
|
80
|
-
const checksum = checksumService.calculateChecksumForBuffers(buffers);
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
**New:**
|
|
84
|
-
```typescript
|
|
85
|
-
const checksum = checksumService.calculateChecksumForBuffersAsClass(buffers);
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
**Reason:** New method returns Checksum class instance with helpful methods.
|
|
89
|
-
|
|
90
|
-
---
|
|
91
|
-
|
|
92
|
-
#### calculateChecksumForString()
|
|
93
|
-
**Status:** Deprecated in v2.0, will be removed in v3.0
|
|
94
|
-
|
|
95
|
-
**Old:**
|
|
96
|
-
```typescript
|
|
97
|
-
const checksum = checksumService.calculateChecksumForString(str);
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
**New:**
|
|
101
|
-
```typescript
|
|
102
|
-
const checksum = checksumService.calculateChecksumForStringAsClass(str);
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
**Reason:** New method returns Checksum class instance with helpful methods.
|
|
106
|
-
|
|
107
|
-
---
|
|
108
|
-
|
|
109
|
-
#### calculateChecksumForFile()
|
|
110
|
-
**Status:** Deprecated in v2.0, will be removed in v3.0
|
|
111
|
-
|
|
112
|
-
**Old:**
|
|
113
|
-
```typescript
|
|
114
|
-
const checksum = await checksumService.calculateChecksumForFile(file);
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
**New:**
|
|
118
|
-
```typescript
|
|
119
|
-
const checksum = await checksumService.calculateChecksumForFileAsClass(file);
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
**Reason:** New method returns Checksum class instance with helpful methods.
|
|
123
|
-
|
|
124
|
-
---
|
|
125
|
-
|
|
126
|
-
#### calculateChecksumForStream()
|
|
127
|
-
**Status:** Deprecated in v2.0, will be removed in v3.0
|
|
128
|
-
|
|
129
|
-
**Old:**
|
|
130
|
-
```typescript
|
|
131
|
-
const checksum = await checksumService.calculateChecksumForStream(stream);
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
**New:**
|
|
135
|
-
```typescript
|
|
136
|
-
const checksum = await checksumService.calculateChecksumForStreamAsClass(stream);
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
**Reason:** New method returns Checksum class instance with helpful methods.
|
|
140
|
-
|
|
141
|
-
---
|
|
142
|
-
|
|
143
|
-
### Checksum Utility Functions
|
|
144
|
-
|
|
145
|
-
#### checksumToBuffer()
|
|
146
|
-
**Status:** Deprecated in v2.0, will be removed in v3.0
|
|
147
|
-
|
|
148
|
-
**Old:**
|
|
149
|
-
```typescript
|
|
150
|
-
import { checksumToBuffer } from 'brightchain-lib';
|
|
151
|
-
const buffer = checksumToBuffer(checksum);
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
**New:**
|
|
155
|
-
```typescript
|
|
156
|
-
const buffer = checksum.toBuffer();
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
**Reason:** Checksum class provides built-in conversion methods.
|
|
160
|
-
|
|
161
|
-
---
|
|
162
|
-
|
|
163
|
-
#### checksumToUint8Array()
|
|
164
|
-
**Status:** Deprecated in v2.0, will be removed in v3.0
|
|
165
|
-
|
|
166
|
-
**Old:**
|
|
167
|
-
```typescript
|
|
168
|
-
import { checksumToUint8Array } from 'brightchain-lib';
|
|
169
|
-
const array = checksumToUint8Array(checksum);
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
**New:**
|
|
173
|
-
```typescript
|
|
174
|
-
const array = checksum.toUint8Array();
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
**Reason:** Checksum class provides built-in conversion methods.
|
|
178
|
-
|
|
179
|
-
---
|
|
180
|
-
|
|
181
|
-
#### checksumToHex()
|
|
182
|
-
**Status:** Deprecated in v2.0, will be removed in v3.0
|
|
183
|
-
|
|
184
|
-
**Old:**
|
|
185
|
-
```typescript
|
|
186
|
-
import { checksumToHex } from 'brightchain-lib';
|
|
187
|
-
const hex = checksumToHex(checksum);
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
**New:**
|
|
191
|
-
```typescript
|
|
192
|
-
const hex = checksum.toHex();
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
**Reason:** Checksum class provides built-in conversion methods.
|
|
196
|
-
|
|
197
|
-
---
|
|
198
|
-
|
|
199
|
-
#### checksumFromHex()
|
|
200
|
-
**Status:** Deprecated in v2.0, will be removed in v3.0
|
|
201
|
-
|
|
202
|
-
**Old:**
|
|
203
|
-
```typescript
|
|
204
|
-
import { checksumFromHex } from 'brightchain-lib';
|
|
205
|
-
const checksum = checksumFromHex(hex);
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
**New:**
|
|
209
|
-
```typescript
|
|
210
|
-
const checksum = Checksum.fromHex(hex);
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
**Reason:** Checksum class provides built-in factory methods.
|
|
214
|
-
|
|
215
|
-
---
|
|
216
|
-
|
|
217
|
-
#### checksumFromBuffer()
|
|
218
|
-
**Status:** Deprecated in v2.0, will be removed in v3.0
|
|
219
|
-
|
|
220
|
-
**Old:**
|
|
221
|
-
```typescript
|
|
222
|
-
import { checksumFromBuffer } from 'brightchain-lib';
|
|
223
|
-
const checksum = checksumFromBuffer(buffer);
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
**New:**
|
|
227
|
-
```typescript
|
|
228
|
-
const checksum = Checksum.fromBuffer(buffer);
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
**Reason:** Checksum class provides built-in factory methods.
|
|
232
|
-
|
|
233
|
-
---
|
|
234
|
-
|
|
235
|
-
#### checksumFromUint8Array()
|
|
236
|
-
**Status:** Deprecated in v2.0, will be removed in v3.0
|
|
237
|
-
|
|
238
|
-
**Old:**
|
|
239
|
-
```typescript
|
|
240
|
-
import { checksumFromUint8Array } from 'brightchain-lib';
|
|
241
|
-
const checksum = checksumFromUint8Array(array);
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
**New:**
|
|
245
|
-
```typescript
|
|
246
|
-
const checksum = Checksum.fromUint8Array(array);
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
**Reason:** Checksum class provides built-in factory methods.
|
|
250
|
-
|
|
251
|
-
---
|
|
252
|
-
|
|
253
|
-
### Other Deprecated APIs
|
|
254
|
-
|
|
255
|
-
#### IConstants Interface
|
|
256
|
-
**Status:** Deprecated in v2.0, will be removed in v3.0
|
|
257
|
-
|
|
258
|
-
**Old:**
|
|
259
|
-
```typescript
|
|
260
|
-
import { IConstants } from 'brightchain-lib';
|
|
261
|
-
const constants: IConstants = { ... };
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
**New:**
|
|
265
|
-
```typescript
|
|
266
|
-
import { ICBLConsts, IFECConsts, ITupleConsts } from 'brightchain-lib';
|
|
267
|
-
const cblConsts: ICBLConsts = { ... };
|
|
268
|
-
```
|
|
269
|
-
|
|
270
|
-
**Reason:** Specific constant interfaces provide better type safety.
|
|
271
|
-
|
|
272
|
-
---
|
|
273
|
-
|
|
274
|
-
#### CBLService.CreatorLength (static)
|
|
275
|
-
**Status:** Deprecated in v2.0, will be removed in v3.0
|
|
276
|
-
|
|
277
|
-
**Old:**
|
|
278
|
-
```typescript
|
|
279
|
-
const length = CBLService.CreatorLength;
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
**New:**
|
|
283
|
-
```typescript
|
|
284
|
-
const cblService = new CBLService(...);
|
|
285
|
-
const length = cblService.creatorLength;
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
**Reason:** Instance method provides better encapsulation.
|
|
289
|
-
|
|
290
|
-
---
|
|
291
|
-
|
|
292
|
-
#### StringLanguages
|
|
293
|
-
**Status:** Deprecated in v2.0, will be removed in v3.0
|
|
294
|
-
|
|
295
|
-
**Old:**
|
|
296
|
-
```typescript
|
|
297
|
-
import { StringLanguages } from 'brightchain-lib';
|
|
298
|
-
const lang = StringLanguages.EN_US;
|
|
299
|
-
```
|
|
300
|
-
|
|
301
|
-
**New:**
|
|
302
|
-
```typescript
|
|
303
|
-
import { LanguageCodes } from '@digitaldefiance/i18n-lib';
|
|
304
|
-
const lang = LanguageCodes.EN_US;
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
**Reason:** Use the canonical i18n-lib implementation.
|
|
308
|
-
|
|
309
|
-
---
|
|
310
|
-
|
|
311
|
-
#### registerTranslation()
|
|
312
|
-
**Status:** Deprecated in v2.0, will be removed in v3.0
|
|
313
|
-
|
|
314
|
-
**Old:**
|
|
315
|
-
```typescript
|
|
316
|
-
import { registerTranslation } from 'brightchain-lib';
|
|
317
|
-
registerTranslation(enumObj, translations);
|
|
318
|
-
```
|
|
319
|
-
|
|
320
|
-
**New:**
|
|
321
|
-
```typescript
|
|
322
|
-
// Use i18n-lib directly for translation management
|
|
323
|
-
import { i18n } from '@digitaldefiance/i18n-lib';
|
|
324
|
-
```
|
|
325
|
-
|
|
326
|
-
**Reason:** Stub function, use i18n-lib directly.
|
|
327
|
-
|
|
328
|
-
---
|
|
329
|
-
|
|
330
|
-
#### EnumLanguageTranslation Type
|
|
331
|
-
**Status:** Deprecated in v2.0, will be removed in v3.0
|
|
332
|
-
|
|
333
|
-
**Old:**
|
|
334
|
-
```typescript
|
|
335
|
-
import { EnumLanguageTranslation } from 'brightchain-lib';
|
|
336
|
-
type MyTranslation = EnumLanguageTranslation<MyEnum>;
|
|
337
|
-
```
|
|
338
|
-
|
|
339
|
-
**New:**
|
|
340
|
-
```typescript
|
|
341
|
-
// Use i18n-lib types directly
|
|
342
|
-
import { TranslationMap } from '@digitaldefiance/i18n-lib';
|
|
343
|
-
```
|
|
344
|
-
|
|
345
|
-
**Reason:** Stub type, use i18n-lib directly.
|
|
346
|
-
|
|
347
|
-
---
|
|
348
|
-
|
|
349
|
-
#### createTranslations()
|
|
350
|
-
**Status:** Deprecated in v2.0, will be removed in v3.0
|
|
351
|
-
|
|
352
|
-
**Old:**
|
|
353
|
-
```typescript
|
|
354
|
-
import { createTranslations } from 'brightchain-lib';
|
|
355
|
-
const translations = createTranslations({ ... });
|
|
356
|
-
```
|
|
357
|
-
|
|
358
|
-
**New:**
|
|
359
|
-
```typescript
|
|
360
|
-
// Use i18n-lib directly for translation management
|
|
361
|
-
import { i18n } from '@digitaldefiance/i18n-lib';
|
|
362
|
-
```
|
|
363
|
-
|
|
364
|
-
**Reason:** Stub function, use i18n-lib directly.
|
|
365
|
-
|
|
366
|
-
---
|
|
367
|
-
|
|
368
|
-
## Migration Strategy
|
|
369
|
-
|
|
370
|
-
### Step 1: Identify Usage
|
|
371
|
-
Search your codebase for deprecated API usage:
|
|
372
|
-
|
|
373
|
-
```bash
|
|
374
|
-
# Search for deprecated imports
|
|
375
|
-
grep -r "ChecksumBuffer\|ChecksumUint8Array" src/
|
|
376
|
-
|
|
377
|
-
# Search for deprecated methods
|
|
378
|
-
grep -r "calculateChecksum\|checksumTo\|checksumFrom" src/
|
|
379
|
-
|
|
380
|
-
# Search for deprecated utilities
|
|
381
|
-
grep -r "StringLanguages\|registerTranslation" src/
|
|
382
|
-
```
|
|
383
|
-
|
|
384
|
-
### Step 2: Update Imports
|
|
385
|
-
Replace deprecated imports with new ones:
|
|
386
|
-
|
|
387
|
-
```typescript
|
|
388
|
-
// Old
|
|
389
|
-
import { ChecksumBuffer, ChecksumUint8Array } from 'brightchain-lib';
|
|
390
|
-
|
|
391
|
-
// New
|
|
392
|
-
import { Checksum } from 'brightchain-lib';
|
|
393
|
-
```
|
|
394
|
-
|
|
395
|
-
### Step 3: Update Usage
|
|
396
|
-
Replace deprecated API calls with new ones:
|
|
397
|
-
|
|
398
|
-
```typescript
|
|
399
|
-
// Old
|
|
400
|
-
const checksum = checksumService.calculateChecksum(data);
|
|
401
|
-
const hex = Buffer.from(checksum).toString('hex');
|
|
402
|
-
|
|
403
|
-
// New
|
|
404
|
-
const checksum = checksumService.calculateChecksumAsClass(data);
|
|
405
|
-
const hex = checksum.toHex();
|
|
406
|
-
```
|
|
407
|
-
|
|
408
|
-
### Step 4: Test
|
|
409
|
-
Run your test suite to ensure everything works:
|
|
410
|
-
|
|
411
|
-
```bash
|
|
412
|
-
npm test
|
|
413
|
-
```
|
|
414
|
-
|
|
415
|
-
### Step 5: Remove Warnings
|
|
416
|
-
Verify no deprecation warnings appear in console output.
|
|
417
|
-
|
|
418
|
-
## Automated Migration
|
|
419
|
-
|
|
420
|
-
We provide scripts to help automate migration:
|
|
421
|
-
|
|
422
|
-
```bash
|
|
423
|
-
# Run migration scripts
|
|
424
|
-
npm run migrate:checksums
|
|
425
|
-
npm run migrate:properties
|
|
426
|
-
|
|
427
|
-
# Validate migration
|
|
428
|
-
npm run validate:migration
|
|
429
|
-
```
|
|
430
|
-
|
|
431
|
-
See [MIGRATION.md](./MIGRATION.md) for detailed migration instructions.
|
|
432
|
-
|
|
433
|
-
## Getting Help
|
|
434
|
-
|
|
435
|
-
If you need help migrating:
|
|
436
|
-
|
|
437
|
-
1. Check the [Migration Guide](./MIGRATION.md)
|
|
438
|
-
2. Review [Code Examples](./examples/)
|
|
439
|
-
3. Search [GitHub Issues](https://github.com/Digital-Defiance/BrightChain/issues)
|
|
440
|
-
4. Ask in [GitHub Discussions](https://github.com/Digital-Defiance/BrightChain/discussions)
|
|
441
|
-
|
|
442
|
-
## Deprecation Policy
|
|
443
|
-
|
|
444
|
-
BrightChain follows semantic versioning:
|
|
445
|
-
|
|
446
|
-
- **Minor versions (2.x)**: Deprecations added, old APIs still work
|
|
447
|
-
- **Major versions (3.0)**: Deprecated APIs removed
|
|
448
|
-
|
|
449
|
-
We maintain deprecated APIs for at least one major version to give you time to migrate.
|
|
450
|
-
|
|
451
|
-
---
|
|
452
|
-
|
|
453
|
-
**Last Updated:** January 2024
|
|
454
|
-
**Applies to:** BrightChain v2.0+
|