@digitaldefiance/ecies-lib 4.4.11 → 4.4.13
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
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
// Type definition for GCM cipher algorithms (from Node.js crypto module)
|
|
2
|
+
export type CipherGCMTypes = 'aes-128-gcm' | 'aes-192-gcm' | 'aes-256-gcm';
|
|
3
|
+
|
|
2
4
|
export interface IECIESConstants {
|
|
3
5
|
/** The elliptic curve to use for all ECDSA operations */
|
|
4
6
|
CURVE_NAME: string;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { randomBytes } from 'crypto';
|
|
3
|
-
import { IdProviderError } from '../../errors/id-provider';
|
|
1
|
+
import { randomBytes } from '@noble/hashes/utils.js';
|
|
4
2
|
import { IdProviderErrorType } from '../../enumerations/id-provider-error-type';
|
|
3
|
+
import { IdProviderError } from '../../errors/id-provider';
|
|
4
|
+
import { BaseIdProvider } from '../../interfaces/id-provider';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Custom ID provider that accepts any fixed byte length.
|
|
8
|
-
*
|
|
8
|
+
*
|
|
9
9
|
* Use this when you need a non-standard ID size or custom validation logic.
|
|
10
10
|
* For standard formats, prefer ObjectIdProvider, GuidV4Provider, or UuidProvider.
|
|
11
|
-
*
|
|
11
|
+
*
|
|
12
12
|
* Example:
|
|
13
13
|
* ```typescript
|
|
14
14
|
* // 20-byte SHA-1 hash as recipient ID
|
|
@@ -27,7 +27,7 @@ export class CustomIdProvider extends BaseIdProvider {
|
|
|
27
27
|
IdProviderErrorType.InvalidByteLengthParameter,
|
|
28
28
|
undefined,
|
|
29
29
|
undefined,
|
|
30
|
-
{ value: byteLength }
|
|
30
|
+
{ value: byteLength },
|
|
31
31
|
);
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -55,9 +55,9 @@ export class CustomIdProvider extends BaseIdProvider {
|
|
|
55
55
|
*/
|
|
56
56
|
serialize(id: Uint8Array): string {
|
|
57
57
|
this.validateLength(id, `${this.name}.serialize`);
|
|
58
|
-
|
|
58
|
+
|
|
59
59
|
return Array.from(id)
|
|
60
|
-
.map(b => b.toString(16).padStart(2, '0'))
|
|
60
|
+
.map((b) => b.toString(16).padStart(2, '0'))
|
|
61
61
|
.join('');
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -75,7 +75,7 @@ export class CustomIdProvider extends BaseIdProvider {
|
|
|
75
75
|
IdProviderErrorType.InvalidStringLength,
|
|
76
76
|
undefined,
|
|
77
77
|
undefined,
|
|
78
|
-
{ expected: expectedLength, actual: str.length }
|
|
78
|
+
{ expected: expectedLength, actual: str.length },
|
|
79
79
|
);
|
|
80
80
|
}
|
|
81
81
|
|