@digitaldefiance/node-ecies-lib 4.10.7 → 4.11.1
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 +126 -4
- package/package.json +2 -2
- package/src/examples/typed-configuration-usage.d.ts +54 -0
- package/src/examples/typed-configuration-usage.d.ts.map +1 -0
- package/src/examples/typed-configuration-usage.js +178 -0
- package/src/examples/typed-configuration-usage.js.map +1 -0
- package/src/index.d.ts +1 -0
- package/src/index.d.ts.map +1 -1
- package/src/index.js +2 -0
- package/src/index.js.map +1 -1
- package/src/interfaces/guid.d.ts +80 -0
- package/src/interfaces/guid.d.ts.map +1 -0
- package/src/interfaces/guid.js +3 -0
- package/src/interfaces/guid.js.map +1 -0
- package/src/lib/guid.d.ts +420 -0
- package/src/lib/guid.d.ts.map +1 -0
- package/src/lib/guid.js +1082 -0
- package/src/lib/guid.js.map +1 -0
- package/src/member.d.ts +52 -0
- package/src/member.d.ts.map +1 -1
- package/src/member.js +72 -0
- package/src/member.js.map +1 -1
- package/src/services/ecies/multi-recipient.d.ts +1 -1
- package/src/services/ecies/multi-recipient.d.ts.map +1 -1
- package/src/services/ecies/multi-recipient.js +3 -4
- package/src/services/ecies/multi-recipient.js.map +1 -1
- package/src/services/encryption-stream.d.ts.map +1 -1
- package/src/services/encryption-stream.js +12 -4
- package/src/services/encryption-stream.js.map +1 -1
- package/src/services/multi-recipient-processor.d.ts.map +1 -1
- package/src/services/multi-recipient-processor.js +2 -3
- package/src/services/multi-recipient-processor.js.map +1 -1
- package/src/typed-configuration.d.ts +208 -0
- package/src/typed-configuration.d.ts.map +1 -0
- package/src/typed-configuration.js +230 -0
- package/src/typed-configuration.js.map +1 -0
- package/src/types/guid-versions.d.ts +34 -0
- package/src/types/guid-versions.d.ts.map +1 -0
- package/src/types/guid-versions.js +7 -0
- package/src/types/guid-versions.js.map +1 -0
- package/src/types/index.d.ts +1 -0
- package/src/types/index.d.ts.map +1 -1
- package/src/types/index.js +1 -0
- package/src/types/index.js.map +1 -1
- package/src/types.d.ts +9 -1
- package/src/types.d.ts.map +1 -1
- package/src/types.js.map +1 -1
package/README.md
CHANGED
|
@@ -163,7 +163,89 @@ const decrypted = ecies.decryptSimpleOrSingleWithHeader(false, privateKey, encry
|
|
|
163
163
|
console.log(decrypted.toString()); // "Hello, Secure World!"
|
|
164
164
|
```
|
|
165
165
|
|
|
166
|
-
### 2.
|
|
166
|
+
### 2. Strong Typing with ID Providers (New in v4.10.7)
|
|
167
|
+
|
|
168
|
+
The Node.js library now includes a comprehensive strong typing system for ID providers, eliminating the need for manual type casting and providing compile-time type safety.
|
|
169
|
+
|
|
170
|
+
#### The Problem (Before v4.10.7)
|
|
171
|
+
|
|
172
|
+
```typescript
|
|
173
|
+
const Constants = getNodeRuntimeConfiguration();
|
|
174
|
+
const id = Constants.idProvider.generate(); // Returns Uint8Array (no strong typing)
|
|
175
|
+
const obj = Constants.idProvider.fromBytes(bytes); // Returns unknown (requires casting)
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
#### The Solution (v4.10.7+)
|
|
179
|
+
|
|
180
|
+
**Enhanced Provider (Drop-in Replacement):**
|
|
181
|
+
```typescript
|
|
182
|
+
import { getEnhancedNodeIdProvider } from '@digitaldefiance/node-ecies-lib';
|
|
183
|
+
|
|
184
|
+
const provider = getEnhancedNodeIdProvider<ObjectId>();
|
|
185
|
+
const id = provider.generateTyped(); // Returns ObjectId (strongly typed)
|
|
186
|
+
const obj = provider.fromBytesTyped(bytes); // Returns ObjectId (no casting needed)
|
|
187
|
+
|
|
188
|
+
// Original methods still work for backward compatibility
|
|
189
|
+
const rawBytes = provider.generate(); // Returns Uint8Array
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
**Simple Typed Provider (Clean API):**
|
|
193
|
+
```typescript
|
|
194
|
+
import { getTypedNodeIdProvider } from '@digitaldefiance/node-ecies-lib';
|
|
195
|
+
|
|
196
|
+
const provider = getTypedNodeIdProvider<ObjectId>();
|
|
197
|
+
const id = provider.generateTyped(); // Returns ObjectId
|
|
198
|
+
const bytes = provider.toBytesTyped(id); // Type-safe conversion
|
|
199
|
+
const restored = provider.fromBytesTyped(bytes); // Type-safe restoration
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**Complete Typed Configuration:**
|
|
203
|
+
```typescript
|
|
204
|
+
import { createNodeObjectIdConfiguration } from '@digitaldefiance/node-ecies-lib';
|
|
205
|
+
|
|
206
|
+
const config = createNodeObjectIdConfiguration();
|
|
207
|
+
const objectId = config.generateId(); // Returns ObjectId (strongly typed)
|
|
208
|
+
const bytes = config.idToBytes(objectId); // Convert to bytes
|
|
209
|
+
const restored = config.idFromBytes(bytes); // Convert back to ObjectId
|
|
210
|
+
|
|
211
|
+
// Access full Node.js runtime configuration
|
|
212
|
+
const constants = config.constants; // Complete IConstants with ObjectIdProvider
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
**Custom Provider Types:**
|
|
216
|
+
```typescript
|
|
217
|
+
import {
|
|
218
|
+
createNodeTypedConfiguration,
|
|
219
|
+
GuidV4Provider,
|
|
220
|
+
UuidProvider
|
|
221
|
+
} from '@digitaldefiance/node-ecies-lib';
|
|
222
|
+
|
|
223
|
+
// GUID configuration
|
|
224
|
+
const guidConfig = createNodeTypedConfiguration<string>({
|
|
225
|
+
idProvider: new GuidV4Provider()
|
|
226
|
+
});
|
|
227
|
+
const guidId = guidConfig.generateId(); // Returns GUID object (strongly typed)
|
|
228
|
+
|
|
229
|
+
// UUID configuration
|
|
230
|
+
const uuidConfig = createNodeTypedConfiguration<string>({
|
|
231
|
+
idProvider: new UuidProvider()
|
|
232
|
+
});
|
|
233
|
+
const uuidId = uuidConfig.generateId(); // Returns UUID string (strongly typed)
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
**Integration with ECIESService:**
|
|
237
|
+
```typescript
|
|
238
|
+
import { ECIESService, createNodeObjectIdConfiguration } from '@digitaldefiance/node-ecies-lib';
|
|
239
|
+
|
|
240
|
+
const config = createNodeObjectIdConfiguration();
|
|
241
|
+
const service = new ECIESService(config.constants);
|
|
242
|
+
|
|
243
|
+
// Service uses the configured typed provider
|
|
244
|
+
console.log(service.idProvider.name); // "ObjectID"
|
|
245
|
+
console.log(service.idProvider.byteLength); // 12
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### 3. Using Custom ID Providers (e.g., GUID)
|
|
167
249
|
|
|
168
250
|
```typescript
|
|
169
251
|
import {
|
|
@@ -198,7 +280,7 @@ const ecies2 = new ECIESService({
|
|
|
198
280
|
const ecies3 = new ECIESService();
|
|
199
281
|
```
|
|
200
282
|
|
|
201
|
-
###
|
|
283
|
+
### 4. Streaming Encryption (Large Files)
|
|
202
284
|
|
|
203
285
|
Encrypt gigabytes of data with minimal memory footprint (<10MB).
|
|
204
286
|
|
|
@@ -223,7 +305,7 @@ async function processFile(filePath: string, publicKey: Buffer) {
|
|
|
223
305
|
}
|
|
224
306
|
```
|
|
225
307
|
|
|
226
|
-
###
|
|
308
|
+
### 5. Voting System (Node.js Optimized)
|
|
227
309
|
|
|
228
310
|
The Node.js voting system extends the browser implementation with Buffer support and mongoose integration:
|
|
229
311
|
|
|
@@ -311,7 +393,7 @@ console.log(member.id); // Buffer (size depends on provider)
|
|
|
311
393
|
const encrypted = member.encryptData('My Secrets');
|
|
312
394
|
```
|
|
313
395
|
|
|
314
|
-
###
|
|
396
|
+
### 6. Member System
|
|
315
397
|
|
|
316
398
|
### Core Services
|
|
317
399
|
|
|
@@ -571,6 +653,46 @@ describe('Integration with suite-core-lib', () => {
|
|
|
571
653
|
|
|
572
654
|
## ChangeLog
|
|
573
655
|
|
|
656
|
+
### v4.10.7 - Strong Typing for ID Providers
|
|
657
|
+
|
|
658
|
+
**Major Features:**
|
|
659
|
+
- **Strong Typing System**: Added comprehensive strong typing for Node.js ID provider operations
|
|
660
|
+
- `getEnhancedNodeIdProvider<T>()`: Drop-in replacement with both original and typed methods
|
|
661
|
+
- `getTypedNodeIdProvider<T>()`: Simple typed provider with minimal API surface
|
|
662
|
+
- `createNodeTypedConfiguration<T>()`: Complete typed configuration wrapper
|
|
663
|
+
- `createNodeObjectIdConfiguration()`: Pre-configured ObjectId setup
|
|
664
|
+
- **Type Safety Benefits**: Eliminates manual casting and provides compile-time type safety
|
|
665
|
+
- `generateTyped()`: Returns strongly-typed IDs (ObjectId, string, etc.)
|
|
666
|
+
- `fromBytesTyped()`: Type-safe byte conversion without casting
|
|
667
|
+
- `toBytesTyped()`, `serializeTyped()`, `deserializeTyped()`: Complete typed API
|
|
668
|
+
- **Backward Compatibility**: Enhanced providers include original methods for seamless migration
|
|
669
|
+
- **Integration Ready**: Works seamlessly with ECIESService and Member system
|
|
670
|
+
|
|
671
|
+
**Usage Examples:**
|
|
672
|
+
```typescript
|
|
673
|
+
// Enhanced provider (drop-in replacement)
|
|
674
|
+
const provider = getEnhancedNodeIdProvider<ObjectId>();
|
|
675
|
+
const id = provider.generateTyped(); // Returns ObjectId (strongly typed)
|
|
676
|
+
|
|
677
|
+
// Complete typed configuration
|
|
678
|
+
const config = createNodeObjectIdConfiguration();
|
|
679
|
+
const objectId = config.generateId(); // Returns ObjectId
|
|
680
|
+
const bytes = config.idToBytes(objectId); // Type-safe conversion
|
|
681
|
+
|
|
682
|
+
// Custom provider types
|
|
683
|
+
const guidConfig = createNodeTypedConfiguration<string>({
|
|
684
|
+
idProvider: new GuidV4Provider()
|
|
685
|
+
});
|
|
686
|
+
const guidId = guidConfig.generateId(); // Returns GUID object (strongly typed)
|
|
687
|
+
```
|
|
688
|
+
|
|
689
|
+
**Breaking Changes:** None - fully backward compatible
|
|
690
|
+
|
|
691
|
+
**Files Added:**
|
|
692
|
+
- `src/typed-configuration.ts` - Main implementation
|
|
693
|
+
- `src/typed-configuration.spec.ts` - Comprehensive tests
|
|
694
|
+
- `src/examples/typed-configuration-usage.ts` - Usage examples
|
|
695
|
+
|
|
574
696
|
### v4.10.6 - Voting System & PlatformID Integration
|
|
575
697
|
|
|
576
698
|
**Major Features:**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digitaldefiance/node-ecies-lib",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.11.1",
|
|
4
4
|
"description": "Digital Defiance Node ECIES Library",
|
|
5
5
|
"homepage": "https://github.com/Digital-Defiance/node-ecies-lib",
|
|
6
6
|
"repository": {
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"license": "MIT",
|
|
63
63
|
"packageManager": "yarn@4.10.3",
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@digitaldefiance/ecies-lib": "4.
|
|
65
|
+
"@digitaldefiance/ecies-lib": "4.11.1",
|
|
66
66
|
"@digitaldefiance/express-suite-test-utils": "1.0.14",
|
|
67
67
|
"@digitaldefiance/i18n-lib": "3.8.16",
|
|
68
68
|
"@ethereumjs/wallet": "^10.0.0",
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Usage examples for Node.js ECIES typed configuration system
|
|
3
|
+
*
|
|
4
|
+
* This file demonstrates how to use the strongly-typed ID provider system
|
|
5
|
+
* in Node.js applications for better type safety and developer experience.
|
|
6
|
+
*
|
|
7
|
+
* @version 4.10.7
|
|
8
|
+
* @since 4.10.7
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Example 1: Enhanced ID Provider (Drop-in Replacement)
|
|
12
|
+
*
|
|
13
|
+
* The enhanced provider includes both original and typed methods,
|
|
14
|
+
* making it a perfect drop-in replacement for existing code.
|
|
15
|
+
*/
|
|
16
|
+
declare function enhancedProviderExample(): void;
|
|
17
|
+
/**
|
|
18
|
+
* Example 2: Simple Typed Provider (Minimal API)
|
|
19
|
+
*
|
|
20
|
+
* The typed provider only exposes strongly-typed methods,
|
|
21
|
+
* providing a clean API surface for new code.
|
|
22
|
+
*/
|
|
23
|
+
declare function typedProviderExample(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Example 3: Complete Typed Configuration
|
|
26
|
+
*
|
|
27
|
+
* The typed configuration provides access to the full Node.js runtime
|
|
28
|
+
* configuration plus convenient typed ID helpers.
|
|
29
|
+
*/
|
|
30
|
+
declare function typedConfigurationExample(): void;
|
|
31
|
+
/**
|
|
32
|
+
* Example 4: Custom Provider Configuration
|
|
33
|
+
*
|
|
34
|
+
* Demonstrates how to use different ID providers with strong typing.
|
|
35
|
+
*/
|
|
36
|
+
declare function customProviderExample(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Example 5: Type Safety Demonstration
|
|
39
|
+
*
|
|
40
|
+
* Shows how the typed system prevents common type-related errors.
|
|
41
|
+
*/
|
|
42
|
+
declare function typeSafetyExample(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Example 6: Integration with ECIESService
|
|
45
|
+
*
|
|
46
|
+
* Shows how to use typed configurations with the ECIES service.
|
|
47
|
+
*/
|
|
48
|
+
declare function eciesIntegrationExample(): void;
|
|
49
|
+
/**
|
|
50
|
+
* Run all examples
|
|
51
|
+
*/
|
|
52
|
+
declare function runAllExamples(): void;
|
|
53
|
+
export { enhancedProviderExample, typedProviderExample, typedConfigurationExample, customProviderExample, typeSafetyExample, eciesIntegrationExample, runAllExamples, };
|
|
54
|
+
//# sourceMappingURL=typed-configuration-usage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typed-configuration-usage.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-node-ecies-lib/src/examples/typed-configuration-usage.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAYH;;;;;GAKG;AACH,iBAAS,uBAAuB,SAkB/B;AAED;;;;;GAKG;AACH,iBAAS,oBAAoB,SAqB5B;AAED;;;;;GAKG;AACH,iBAAS,yBAAyB,SAkBjC;AAED;;;;GAIG;AACH,iBAAS,qBAAqB,SAqB7B;AAED;;;;GAIG;AACH,iBAAS,iBAAiB,SAwBzB;AAED;;;;GAIG;AACH,iBAAS,uBAAuB,SAmB/B;AAED;;GAEG;AACH,iBAAS,cAAc,SAsBtB;AAGD,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,yBAAyB,EACzB,qBAAqB,EACrB,iBAAiB,EACjB,uBAAuB,EACvB,cAAc,GACf,CAAC"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Usage examples for Node.js ECIES typed configuration system
|
|
4
|
+
*
|
|
5
|
+
* This file demonstrates how to use the strongly-typed ID provider system
|
|
6
|
+
* in Node.js applications for better type safety and developer experience.
|
|
7
|
+
*
|
|
8
|
+
* @version 4.10.7
|
|
9
|
+
* @since 4.10.7
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.enhancedProviderExample = enhancedProviderExample;
|
|
13
|
+
exports.typedProviderExample = typedProviderExample;
|
|
14
|
+
exports.typedConfigurationExample = typedConfigurationExample;
|
|
15
|
+
exports.customProviderExample = customProviderExample;
|
|
16
|
+
exports.typeSafetyExample = typeSafetyExample;
|
|
17
|
+
exports.eciesIntegrationExample = eciesIntegrationExample;
|
|
18
|
+
exports.runAllExamples = runAllExamples;
|
|
19
|
+
const ecies_lib_1 = require("@digitaldefiance/ecies-lib");
|
|
20
|
+
const typed_configuration_1 = require("../typed-configuration");
|
|
21
|
+
/**
|
|
22
|
+
* Example 1: Enhanced ID Provider (Drop-in Replacement)
|
|
23
|
+
*
|
|
24
|
+
* The enhanced provider includes both original and typed methods,
|
|
25
|
+
* making it a perfect drop-in replacement for existing code.
|
|
26
|
+
*/
|
|
27
|
+
function enhancedProviderExample() {
|
|
28
|
+
console.log('=== Enhanced Provider Example ===');
|
|
29
|
+
// Get enhanced provider with strong typing
|
|
30
|
+
const provider = (0, typed_configuration_1.getEnhancedNodeIdProvider)();
|
|
31
|
+
// Original methods still work (backward compatibility)
|
|
32
|
+
const rawBytes = provider.generate(); // Returns Uint8Array
|
|
33
|
+
// const _unknownObj = provider.fromBytes(rawBytes); // Returns unknown (requires casting)
|
|
34
|
+
// New typed methods provide type safety
|
|
35
|
+
const typedId = provider.generateTyped(); // Returns ObjectId (strongly typed)
|
|
36
|
+
const typedFromBytes = provider.fromBytesTyped(rawBytes); // Returns ObjectId (no casting needed)
|
|
37
|
+
console.log('Provider name:', provider.name);
|
|
38
|
+
console.log('Byte length:', provider.byteLength);
|
|
39
|
+
console.log('Typed ID generated:', typedId);
|
|
40
|
+
console.log('Round-trip successful:', typedFromBytes);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Example 2: Simple Typed Provider (Minimal API)
|
|
44
|
+
*
|
|
45
|
+
* The typed provider only exposes strongly-typed methods,
|
|
46
|
+
* providing a clean API surface for new code.
|
|
47
|
+
*/
|
|
48
|
+
function typedProviderExample() {
|
|
49
|
+
console.log('=== Typed Provider Example ===');
|
|
50
|
+
// Get simple typed provider
|
|
51
|
+
const provider = (0, typed_configuration_1.getTypedNodeIdProvider)();
|
|
52
|
+
// Only typed methods available
|
|
53
|
+
const typedId = provider.generateTyped(); // Returns ObjectId
|
|
54
|
+
const bytes = provider.toBytesTyped(typedId); // Convert to bytes
|
|
55
|
+
const restored = provider.fromBytesTyped(bytes); // Convert back to ObjectId
|
|
56
|
+
// Serialization methods
|
|
57
|
+
const serialized = provider.serializeTyped(typedId);
|
|
58
|
+
const deserialized = provider.deserializeTyped(serialized);
|
|
59
|
+
console.log('Provider name:', provider.name);
|
|
60
|
+
console.log('Byte length:', provider.byteLength);
|
|
61
|
+
console.log('Original ID:', typedId);
|
|
62
|
+
console.log('Restored ID:', restored);
|
|
63
|
+
console.log('Serialized:', serialized);
|
|
64
|
+
console.log('Deserialized:', deserialized);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Example 3: Complete Typed Configuration
|
|
68
|
+
*
|
|
69
|
+
* The typed configuration provides access to the full Node.js runtime
|
|
70
|
+
* configuration plus convenient typed ID helpers.
|
|
71
|
+
*/
|
|
72
|
+
function typedConfigurationExample() {
|
|
73
|
+
console.log('=== Typed Configuration Example ===');
|
|
74
|
+
// Create ObjectId configuration
|
|
75
|
+
const config = (0, typed_configuration_1.createNodeObjectIdConfiguration)();
|
|
76
|
+
// Access full Node.js runtime configuration
|
|
77
|
+
console.log('PBKDF2 algorithm:', config.constants.PBKDF2.ALGORITHM);
|
|
78
|
+
console.log('Member ID length:', config.constants.MEMBER_ID_LENGTH);
|
|
79
|
+
// Use convenient typed methods
|
|
80
|
+
const objectId = config.generateId(); // Returns ObjectId
|
|
81
|
+
const bytes = config.idToBytes(objectId);
|
|
82
|
+
const restored = config.idFromBytes(bytes);
|
|
83
|
+
console.log('Generated ObjectId:', objectId);
|
|
84
|
+
console.log('Byte length:', bytes.length);
|
|
85
|
+
console.log('Restored ObjectId:', restored);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Example 4: Custom Provider Configuration
|
|
89
|
+
*
|
|
90
|
+
* Demonstrates how to use different ID providers with strong typing.
|
|
91
|
+
*/
|
|
92
|
+
function customProviderExample() {
|
|
93
|
+
console.log('=== Custom Provider Example ===');
|
|
94
|
+
// GUID configuration
|
|
95
|
+
const guidConfig = (0, typed_configuration_1.createNodeTypedConfiguration)({
|
|
96
|
+
idProvider: new ecies_lib_1.GuidV4Provider(),
|
|
97
|
+
});
|
|
98
|
+
// UUID configuration
|
|
99
|
+
const uuidConfig = (0, typed_configuration_1.createNodeTypedConfiguration)({
|
|
100
|
+
idProvider: new ecies_lib_1.UuidProvider(),
|
|
101
|
+
});
|
|
102
|
+
// Generate typed IDs
|
|
103
|
+
// const _guidId = guidConfig.generateId(); // Returns GUID object (strongly typed)
|
|
104
|
+
// const _uuidId = uuidConfig.generateId(); // Returns UUID string (strongly typed)
|
|
105
|
+
console.log('GUID provider name:', guidConfig.constants.idProvider.name);
|
|
106
|
+
console.log('GUID byte length:', guidConfig.constants.idProvider.byteLength);
|
|
107
|
+
console.log('UUID provider name:', uuidConfig.constants.idProvider.name);
|
|
108
|
+
console.log('UUID byte length:', uuidConfig.constants.idProvider.byteLength);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Example 5: Type Safety Demonstration
|
|
112
|
+
*
|
|
113
|
+
* Shows how the typed system prevents common type-related errors.
|
|
114
|
+
*/
|
|
115
|
+
function typeSafetyExample() {
|
|
116
|
+
console.log('=== Type Safety Example ===');
|
|
117
|
+
const objectIdConfig = (0, typed_configuration_1.createNodeObjectIdConfiguration)();
|
|
118
|
+
const guidConfig = (0, typed_configuration_1.createNodeTypedConfiguration)({
|
|
119
|
+
idProvider: new ecies_lib_1.GuidV4Provider(),
|
|
120
|
+
});
|
|
121
|
+
// Generate strongly-typed IDs
|
|
122
|
+
const objectId = objectIdConfig.generateId(); // ObjectId type
|
|
123
|
+
const guidId = guidConfig.generateId(); // GUID object type
|
|
124
|
+
// Type-safe operations (no casting needed)
|
|
125
|
+
const objectIdBytes = objectIdConfig.idToBytes(objectId);
|
|
126
|
+
const guidBytes = guidConfig.idToBytes(guidId);
|
|
127
|
+
// Restore with type safety
|
|
128
|
+
const restoredObjectId = objectIdConfig.idFromBytes(objectIdBytes);
|
|
129
|
+
const restoredGuid = guidConfig.idFromBytes(guidBytes);
|
|
130
|
+
console.log('ObjectId bytes length:', objectIdBytes.length);
|
|
131
|
+
console.log('GUID bytes length:', guidBytes.length);
|
|
132
|
+
console.log('ObjectId restored:', restoredObjectId);
|
|
133
|
+
console.log('GUID restored:', restoredGuid);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Example 6: Integration with ECIESService
|
|
137
|
+
*
|
|
138
|
+
* Shows how to use typed configurations with the ECIES service.
|
|
139
|
+
*/
|
|
140
|
+
function eciesIntegrationExample() {
|
|
141
|
+
console.log('=== ECIES Integration Example ===');
|
|
142
|
+
// Import ECIESService (commented out to avoid circular dependencies in examples)
|
|
143
|
+
// import { ECIESService } from '../services/ecies/service';
|
|
144
|
+
// Create typed configuration
|
|
145
|
+
const config = (0, typed_configuration_1.createNodeObjectIdConfiguration)();
|
|
146
|
+
// Use with ECIESService
|
|
147
|
+
// const service = new ECIESService(config.constants);
|
|
148
|
+
// The service will use the configured ID provider
|
|
149
|
+
// console.log('Service ID provider:', service.idProvider.name);
|
|
150
|
+
// console.log('Service ID byte length:', service.idProvider.byteLength);
|
|
151
|
+
console.log('Configuration ready for ECIESService');
|
|
152
|
+
console.log('ID provider:', config.constants.idProvider.name);
|
|
153
|
+
console.log('Byte length:', config.constants.idProvider.byteLength);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Run all examples
|
|
157
|
+
*/
|
|
158
|
+
function runAllExamples() {
|
|
159
|
+
console.log('Node.js ECIES Typed Configuration Examples\n');
|
|
160
|
+
enhancedProviderExample();
|
|
161
|
+
console.log();
|
|
162
|
+
typedProviderExample();
|
|
163
|
+
console.log();
|
|
164
|
+
typedConfigurationExample();
|
|
165
|
+
console.log();
|
|
166
|
+
customProviderExample();
|
|
167
|
+
console.log();
|
|
168
|
+
typeSafetyExample();
|
|
169
|
+
console.log();
|
|
170
|
+
eciesIntegrationExample();
|
|
171
|
+
console.log();
|
|
172
|
+
console.log('All examples completed successfully!');
|
|
173
|
+
}
|
|
174
|
+
// Run examples if this file is executed directly
|
|
175
|
+
if (require.main === module) {
|
|
176
|
+
runAllExamples();
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=typed-configuration-usage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typed-configuration-usage.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-node-ecies-lib/src/examples/typed-configuration-usage.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;AA+MD,0DAAuB;AACvB,oDAAoB;AACpB,8DAAyB;AACzB,sDAAqB;AACrB,8CAAiB;AACjB,0DAAuB;AACvB,wCAAc;AAnNhB,0DAA0E;AAG1E,gEAKgC;AAEhC;;;;;GAKG;AACH,SAAS,uBAAuB;I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BAAyB,EAAE,CAAC;IAC5B,OAAO,CAAC,GAAG,EAAE,CAAC;IAEd,qBAAqB,EAAE,CAAC;IACxB,OAAO,CAAC,GAAG,EAAE,CAAC;IAEd,iBAAiB,EAAE,CAAC;IACpB,OAAO,CAAC,GAAG,EAAE,CAAC;IAEd,uBAAuB,EAAE,CAAC;IAC1B,OAAO,CAAC,GAAG,EAAE,CAAC;IAEd,OAAO,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;AACtD,CAAC;AAaD,iDAAiD;AACjD,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC5B,cAAc,EAAE,CAAC;AACnB,CAAC"}
|
package/src/index.d.ts
CHANGED
|
@@ -19,4 +19,5 @@ export * from './services/voting.service';
|
|
|
19
19
|
export { IsolatedPublicKey } from './isolated-public';
|
|
20
20
|
export { IsolatedPrivateKey } from './isolated-private';
|
|
21
21
|
export type { PrivateKey, PublicKey, KeyPair as PaillierKeyPair, } from 'paillier-bigint';
|
|
22
|
+
export * from './typed-configuration';
|
|
22
23
|
//# sourceMappingURL=index.d.ts.map
|
package/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/digitaldefiance-node-ecies-lib/src/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AAGtB,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAGhC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,gB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AC;AAGxD,YAAY,EACV,UAAU,EACV,SAAS,EACT,OAAO,IAAI,eAAe,GAC3B,MAAM,iBAAiB,CAAC;AAGzB,cAAc,uBAAuB,CAAC"}
|
package/src/index.js
CHANGED
|
@@ -34,4 +34,6 @@ var isolated_public_1 = require("./isolated-public");
|
|
|
34
34
|
Object.defineProperty(exports, "IsolatedPublicKey", { enumerable: true, get: function () { return isolated_public_1.IsolatedPublicKey; } });
|
|
35
35
|
var isolated_private_1 = require("./isolated-private");
|
|
36
36
|
Object.defineProperty(exports, "IsolatedPrivateKey", { enumerable: true, get: function () { return isolated_private_1.IsolatedPrivateKey; } });
|
|
37
|
+
// Typed configuration system for strong typing with ID providers
|
|
38
|
+
tslib_1.__exportStar(require("./typed-configuration"), exports);
|
|
37
39
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/digitaldefiance-node-ecies-lib/src/index.ts"],"names":[],"mappings":";;;;AAAA,0BAA0B;AAC1B,qDAA2B;AAC3B,iDAAuB;AACvB,gDAAsB;AAEtB,4CAA4C;AAC5C,sDAA4B;AAC5B,yDAA+B;AAC/B,iDAAuB;AACvB,uDAA6B;AAC7B,mDAAyB;AACzB,kDAAwB;AACxB,0DAAgC;AAEhC,iDAAiD;AACjD,8CAAmD;AAA1C,wGAAA,aAAa,OAAA;AACtB,8DAA4D;AAAnD,iHAAA,cAAc,OAAA;AACvB,2DAAiC;AACjC,kEAAgE;AAAvD,qHAAA,gBAAgB,OAAA;AACzB,kFAA+E;AAAtE,oIAAA,uBAAuB,OAAA;AAChC,4CAAkD;AAAzC,uGAAA,aAAa,OAAA;AACtB,gEAA8D;AAArD,mHAAA,eAAe,OAAA;AACxB,oEAA0C;AAE1C,kCAAkC;AAClC,qDAAsD;AAA7C,oHAAA,iBAAiB,OAAA;AAC1B,uDAAwD;AAA/C,sHAAA,kBAAkB,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/digitaldefiance-node-ecies-lib/src/index.ts"],"names":[],"mappings":";;;;AAAA,0BAA0B;AAC1B,qDAA2B;AAC3B,iDAAuB;AACvB,gDAAsB;AAEtB,4CAA4C;AAC5C,sDAA4B;AAC5B,yDAA+B;AAC/B,iDAAuB;AACvB,uDAA6B;AAC7B,mDAAyB;AACzB,kDAAwB;AACxB,0DAAgC;AAEhC,iDAAiD;AACjD,8CAAmD;AAA1C,wGAAA,aAAa,OAAA;AACtB,8DAA4D;AAAnD,iHAAA,cAAc,OAAA;AACvB,2DAAiC;AACjC,kEAAgE;AAAvD,qHAAA,gBAAgB,OAAA;AACzB,kFAA+E;AAAtE,oIAAA,uBAAuB,OAAA;AAChC,4CAAkD;AAAzC,uGAAA,aAAa,OAAA;AACtB,gEAA8D;AAArD,mHAAA,eAAe,OAAA;AACxB,oEAA0C;AAE1C,kCAAkC;AAClC,qDAAsD;AAA7C,oHAAA,iBAAiB,OAAA;AAC1B,uDAAwD;AAA/C,sHAAA,kBAAkB,OAAA;AAS3B,iEAAiE;AACjE,gEAAsC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { Base64Guid, BigIntGuid, FullHexGuid, IGuid as IGuidBase, ShortHexGuid } from '@digitaldefiance/ecies-lib';
|
|
2
|
+
import type { RawGuidPlatformBuffer } from '../types';
|
|
3
|
+
import type { PlatformBuffer } from './platform-buffer';
|
|
4
|
+
export interface IGuidV4 extends IGuidBase {
|
|
5
|
+
/**
|
|
6
|
+
* Returns the GUID as a raw buffer.
|
|
7
|
+
*/
|
|
8
|
+
get asRawGuidPlatformBuffer(): RawGuidPlatformBuffer;
|
|
9
|
+
/**
|
|
10
|
+
* Returns the GUID as a full hex string.
|
|
11
|
+
*/
|
|
12
|
+
get asFullHexGuid(): FullHexGuid;
|
|
13
|
+
/**
|
|
14
|
+
* Returns the GUID as a Buffer.
|
|
15
|
+
*/
|
|
16
|
+
get asPlatformBuffer(): PlatformBuffer;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the GUID as a short hex string.
|
|
19
|
+
*/
|
|
20
|
+
get asShortHexGuid(): ShortHexGuid;
|
|
21
|
+
/**
|
|
22
|
+
* Returns the GUID as a BigInt.
|
|
23
|
+
*/
|
|
24
|
+
get asBigIntGuid(): BigIntGuid;
|
|
25
|
+
/**
|
|
26
|
+
* Returns the GUID as a Base64 string.
|
|
27
|
+
*/
|
|
28
|
+
get asBase64Guid(): Base64Guid;
|
|
29
|
+
/**
|
|
30
|
+
* Returns the GUID as a base64 string
|
|
31
|
+
*/
|
|
32
|
+
serialize(): string;
|
|
33
|
+
/**
|
|
34
|
+
* Returns the GUID as a JSON string
|
|
35
|
+
*/
|
|
36
|
+
toJson(): string;
|
|
37
|
+
/**
|
|
38
|
+
* Returns the GUID as a Base64 string
|
|
39
|
+
*/
|
|
40
|
+
toString(): Base64Guid;
|
|
41
|
+
/**
|
|
42
|
+
* Compares this GUID to another GUID
|
|
43
|
+
* @param other The GUID to compare to (can be null/undefined)
|
|
44
|
+
* @param constantTime Use constant-time comparison to prevent timing attacks
|
|
45
|
+
*/
|
|
46
|
+
equals(other: IGuidV4 | null | undefined, constantTime?: boolean): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Creates a new GuidV4 instance with the same value as this one.
|
|
49
|
+
* @returns A new GuidV4 instance with identical value
|
|
50
|
+
*/
|
|
51
|
+
clone(): IGuidV4;
|
|
52
|
+
/**
|
|
53
|
+
* Returns the hash code for this GUID based on its buffer content.
|
|
54
|
+
* Useful for using GUIDs as Map/Set keys.
|
|
55
|
+
* @returns A numeric hash code
|
|
56
|
+
*/
|
|
57
|
+
hashCode(): number;
|
|
58
|
+
/**
|
|
59
|
+
* Checks if this GUID is empty (all zeros).
|
|
60
|
+
* @returns True if the GUID is all zeros, false otherwise
|
|
61
|
+
*/
|
|
62
|
+
isEmpty(): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Extracts the RFC 4122 version from the GUID.
|
|
65
|
+
* @returns The version number (1-5) or undefined
|
|
66
|
+
*/
|
|
67
|
+
getVersion(): number | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Validates that this GUID is a proper v4 GUID according to RFC 4122.
|
|
70
|
+
* @returns True if valid v4 GUID or boundary value, false otherwise
|
|
71
|
+
*/
|
|
72
|
+
isValidV4(): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Compares two GUIDs for ordering.
|
|
75
|
+
* @param other The other GUID to compare to
|
|
76
|
+
* @returns -1 if this < other, 0 if equal, 1 if this > other
|
|
77
|
+
*/
|
|
78
|
+
compareTo(other: IGuidV4): number;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=guid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guid.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-node-ecies-lib/src/interfaces/guid.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,KAAK,IAAI,SAAS,EAClB,YAAY,EACb,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,MAAM,WAAW,OAAQ,SAAQ,SAAS;IACxC;;OAEG;IACH,IAAI,uBAAuB,IAAI,qBAAqB,CAAC;IACrD;;OAEG;IACH,IAAI,aAAa,IAAI,WAAW,CAAC;IACjC;;OAEG;IACH,IAAI,gBAAgB,IAAI,cAAc,CAAC;IACvC;;OAEG;IACH,IAAI,cAAc,IAAI,YAAY,CAAC;IACnC;;OAEG;IACH,IAAI,YAAY,IAAI,UAAU,CAAC;IAC/B;;OAEG;IACH,IAAI,YAAY,IAAI,UAAU,CAAC;IAE/B;;OAEG;IACH,SAAS,IAAI,MAAM,CAAC;IACpB;;OAEG;IACH,MAAM,IAAI,MAAM,CAAC;IACjB;;OAEG;IACH,QAAQ,IAAI,UAAU,CAAC;IACvB;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,EAAE,YAAY,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IAC3E;;;OAGG;IACH,KAAK,IAAI,OAAO,CAAC;IACjB;;;;OAIG;IACH,QAAQ,IAAI,MAAM,CAAC;IACnB;;;OAGG;IACH,OAAO,IAAI,OAAO,CAAC;IACnB;;;OAGG;IACH,UAAU,IAAI,MAAM,GAAG,SAAS,CAAC;IACjC;;;OAGG;IACH,SAAS,IAAI,OAAO,CAAC;IACrB;;;;OAIG;IACH,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;CACnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guid.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-node-ecies-lib/src/interfaces/guid.ts"],"names":[],"mappings":""}
|