@digitaldefiance/node-ecies-lib 4.13.1 → 4.13.6
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 -3
- package/src/interfaces/platform-id.d.ts +4 -2
- package/src/interfaces/platform-id.d.ts.map +1 -1
- package/src/lib/guid.d.ts +30 -408
- package/src/lib/guid.d.ts.map +1 -1
- package/src/lib/guid.js +71 -1046
- package/src/lib/guid.js.map +1 -1
- package/src/lib/id-providers/guidv4-provider.js +2 -2
- package/src/lib/id-providers/guidv4-provider.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digitaldefiance/node-ecies-lib",
|
|
3
|
-
"version": "4.13.
|
|
3
|
+
"version": "4.13.6",
|
|
4
4
|
"description": "Digital Defiance Node ECIES Library",
|
|
5
5
|
"homepage": "https://github.com/Digital-Defiance/node-ecies-lib",
|
|
6
6
|
"repository": {
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
27
|
"build": "npx nx build digitaldefiance-node-ecies-lib",
|
|
28
|
+
"build:prod": "NODE_ENV=production npx nx build digitaldefiance-node-ecies-lib --configuration=production",
|
|
28
29
|
"build:stream": "npx nx build --outputStyle=stream digitaldefiance-node-ecies-lib",
|
|
29
30
|
"build:logged": "npx nx build --outputStyle=stream digitaldefiance-node-ecies-lib 2>&1 | ansifilter -o build.log",
|
|
30
31
|
"test": "npx nx test digitaldefiance-node-ecies-lib",
|
|
@@ -62,7 +63,7 @@
|
|
|
62
63
|
"license": "MIT",
|
|
63
64
|
"packageManager": "yarn@4.10.3",
|
|
64
65
|
"dependencies": {
|
|
65
|
-
"@digitaldefiance/ecies-lib": "4.13.
|
|
66
|
+
"@digitaldefiance/ecies-lib": "4.13.6",
|
|
66
67
|
"@digitaldefiance/express-suite-test-utils": "1.0.14",
|
|
67
68
|
"@digitaldefiance/i18n-lib": "3.8.16",
|
|
68
69
|
"@ethereumjs/wallet": "^10.0.0",
|
|
@@ -74,7 +75,8 @@
|
|
|
74
75
|
"ethereum-cryptography": "^3.2.0",
|
|
75
76
|
"js-sha3": "^0.9.3",
|
|
76
77
|
"paillier-bigint": "^3.4.1",
|
|
77
|
-
"ts-brand": "^0.2.0"
|
|
78
|
+
"ts-brand": "^0.2.0",
|
|
79
|
+
"uuid": "^13.0.0"
|
|
78
80
|
},
|
|
79
81
|
"devDependencies": {
|
|
80
82
|
"@digitaldefiance/express-suite-test-utils": "1.0.12",
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Platform-agnostic ID type for Node.js.
|
|
3
|
+
* Extends the base PlatformID with Node.js-specific types.
|
|
3
4
|
*/
|
|
4
5
|
import type { PlatformID as BasePlatformID } from '@digitaldefiance/ecies-lib';
|
|
5
6
|
import { Types } from '@digitaldefiance/mongoose-types';
|
|
6
|
-
|
|
7
|
+
import type { GuidV4Buffer } from '../types/guid-versions';
|
|
8
|
+
export type PlatformID = BasePlatformID | GuidV4Buffer | Buffer | Types.ObjectId;
|
|
7
9
|
//# sourceMappingURL=platform-id.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-id.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-node-ecies-lib/src/interfaces/platform-id.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"platform-id.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-node-ecies-lib/src/interfaces/platform-id.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AAExD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3D,MAAM,MAAM,UAAU,GAClB,cAAc,GACd,YAAY,GACZ,MAAM,GACN,KAAK,CAAC,QAAQ,CAAC"}
|
package/src/lib/guid.d.ts
CHANGED
|
@@ -1,444 +1,66 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* RFC 4122 compliant GUID implementation for Node.js.
|
|
3
|
-
*
|
|
4
|
-
* validation, conversion between formats (hex, base64, bigint, Buffer), and type-safe
|
|
5
|
-
* branded types for compile-time format verification.
|
|
3
|
+
* Extends GuidUint8Array from ecies-lib to ensure type compatibility while using Buffer internally.
|
|
6
4
|
*/
|
|
7
|
-
import {
|
|
5
|
+
import { GuidInput, GuidUint8Array, IGuid } from '@digitaldefiance/ecies-lib';
|
|
6
|
+
import * as uuid from 'uuid';
|
|
8
7
|
import { PlatformBuffer } from '../interfaces';
|
|
9
|
-
import { RawGuidPlatformBuffer } from '../types';
|
|
10
8
|
/**
|
|
11
9
|
* Type representing a GuidBuffer with its RFC 4122 version attached.
|
|
12
|
-
* The version is determined at parse time and provides compile-time information.
|
|
13
10
|
*/
|
|
14
|
-
export type VersionedGuidBuffer<V extends 1 | 3 | 4 | 5 | undefined = 1 | 3 | 4 | 5 | undefined> = GuidBuffer & {
|
|
11
|
+
export type VersionedGuidBuffer<V extends 1 | 3 | 4 | 5 | 6 | 7 | undefined = 1 | 3 | 4 | 5 | 6 | 7 | undefined> = GuidBuffer & {
|
|
15
12
|
readonly __version: V;
|
|
16
13
|
};
|
|
17
14
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* - FullHexGuid: A 36-character string representation of the GUID, including dashes
|
|
21
|
-
* - ShortHexGuid: A 32-character string representation of the GUID, excluding dashes
|
|
22
|
-
* - Base64Guid: A 24-character base64-encoded string representation of the GUID
|
|
23
|
-
* - BigIntGuid: A bigint representation of the GUID
|
|
24
|
-
* - RawGuidPlatformBuffer: A 16-byte Buffer representation of the GUID
|
|
25
|
-
* Guid instances can be converted to any of these representations using the appropriate method.
|
|
15
|
+
* Node.js GUID implementation that extends GuidUint8Array but uses Buffer internally.
|
|
16
|
+
* This ensures type compatibility with ecies-lib while leveraging Node.js Buffer capabilities.
|
|
26
17
|
*/
|
|
27
|
-
export declare class GuidBuffer implements IGuid {
|
|
28
|
-
/**
|
|
29
|
-
* GUID is stored internally as a raw 16-byte Buffer.
|
|
30
|
-
*/
|
|
31
|
-
private readonly _value;
|
|
32
|
-
/**
|
|
33
|
-
* Boundary value constants for special GUID validation
|
|
34
|
-
*/
|
|
35
|
-
private static readonly BOUNDARY_VALUES;
|
|
36
|
-
/**
|
|
37
|
-
* Maximum valid bigint value for a 128-bit GUID
|
|
38
|
-
*/
|
|
39
|
-
private static readonly MAX_BIGINT_VALUE;
|
|
40
|
-
/**
|
|
41
|
-
* Cached full hex representation for performance
|
|
42
|
-
*/
|
|
43
|
-
private _cachedFullHex?;
|
|
44
|
-
/**
|
|
45
|
-
* Cached short hex representation for performance
|
|
46
|
-
*/
|
|
47
|
-
private _cachedShortHex?;
|
|
48
|
-
/**
|
|
49
|
-
* Cached base64 representation for performance
|
|
50
|
-
*/
|
|
51
|
-
private _cachedBase64?;
|
|
52
|
-
/**
|
|
53
|
-
* The RFC 4122 version of this GUID (1, 3, 4, 5, or undefined for boundary/invalid)
|
|
54
|
-
*/
|
|
55
|
-
__version?: 1 | 3 | 4 | 5 | undefined;
|
|
56
|
-
/**
|
|
57
|
-
* Regex for validating hex strings (case insensitive)
|
|
58
|
-
*/
|
|
59
|
-
private static readonly HEX_PATTERN;
|
|
60
|
-
/**
|
|
61
|
-
* Regex for validating full hex GUID format
|
|
62
|
-
*/
|
|
63
|
-
private static readonly FULL_HEX_PATTERN;
|
|
64
|
-
/**
|
|
65
|
-
* Type guard to check if a value is a Buffer
|
|
66
|
-
*/
|
|
67
|
-
private static isBuffer;
|
|
68
|
-
/**
|
|
69
|
-
* Type guard to check if a value is a Buffer or Uint8Array
|
|
70
|
-
*/
|
|
71
|
-
private static isBufferLike;
|
|
72
|
-
/**
|
|
73
|
-
* Cached empty/nil GUID constant (all zeros)
|
|
74
|
-
*/
|
|
75
|
-
private static _empty?;
|
|
76
|
-
/**
|
|
77
|
-
* Empty/nil GUID constant (all zeros)
|
|
78
|
-
*/
|
|
79
|
-
static get Empty(): GuidBuffer;
|
|
18
|
+
export declare class GuidBuffer extends GuidUint8Array implements IGuid {
|
|
80
19
|
constructor(value: GuidInput);
|
|
81
|
-
/**
|
|
82
|
-
* Validates input and converts to raw buffer with comprehensive error handling.
|
|
83
|
-
* This centralizes all validation logic for better maintainability.
|
|
84
|
-
* @param value The input value to validate and convert
|
|
85
|
-
* @returns The validated raw GUID buffer
|
|
86
|
-
* @throws {GuidError} If validation fails
|
|
87
|
-
*/
|
|
88
|
-
private static validateAndConvert;
|
|
89
|
-
static validateUuid(value: string): boolean;
|
|
90
|
-
serialize(): string;
|
|
91
|
-
static hydrate(value: string): VersionedGuidBuffer;
|
|
92
|
-
private static readonly LengthMap;
|
|
93
|
-
private static readonly ReverseLengthMap;
|
|
94
|
-
private static readonly VerifyFunctions;
|
|
95
20
|
/**
|
|
96
21
|
* Returns the GUID as a raw Buffer.
|
|
97
|
-
* NOTE: Returns a defensive copy to prevent external mutation.
|
|
98
|
-
* Use asRawGuidPlatformBufferUnsafe() if you need the internal buffer and guarantee no mutation.
|
|
99
22
|
*/
|
|
100
|
-
get
|
|
23
|
+
get asBuffer(): Buffer;
|
|
101
24
|
/**
|
|
102
|
-
* Returns the
|
|
103
|
-
* ⚠️ WARNING: Do NOT mutate the returned buffer! This is for performance-critical paths only.
|
|
104
|
-
* Mutating this buffer will corrupt the GUID instance.
|
|
105
|
-
* @internal
|
|
25
|
+
* Returns the GUID as a native Uint8Array (not a Buffer).
|
|
106
26
|
*/
|
|
107
|
-
get
|
|
27
|
+
get asUint8Array(): Uint8Array;
|
|
28
|
+
get asPlatformBuffer(): PlatformBuffer;
|
|
108
29
|
/**
|
|
109
|
-
*
|
|
110
|
-
* @param guid The GuidBuffer instance to attach version to
|
|
111
|
-
* @returns The same instance with __version property set
|
|
30
|
+
* Factory method to create a GUID from a raw buffer.
|
|
112
31
|
*/
|
|
113
|
-
|
|
32
|
+
static fromBuffer(buffer: Buffer): VersionedGuidBuffer;
|
|
114
33
|
/**
|
|
115
|
-
*
|
|
116
|
-
* @returns A new Guid instance with a randomly generated value
|
|
34
|
+
* Factory method to create a GUID from a raw Uint8Array.
|
|
117
35
|
*/
|
|
118
|
-
static
|
|
36
|
+
static fromUint8Array(bytes: Uint8Array): VersionedGuidBuffer;
|
|
119
37
|
/**
|
|
120
|
-
* Alias for
|
|
121
|
-
* @returns A new Guid instance with a randomly generated v4 value
|
|
38
|
+
* Alias for isRawGuidPlatformBuffer for backward compatibility
|
|
122
39
|
*/
|
|
123
|
-
static
|
|
40
|
+
static isRawGuidBuffer: typeof GuidUint8Array.isRawGuidUint8Array;
|
|
124
41
|
/**
|
|
125
|
-
*
|
|
126
|
-
* @deprecated Use generate() instead for clearer intent
|
|
42
|
+
* Converts a GUID input to a raw Buffer (Node.js specific).
|
|
127
43
|
*/
|
|
128
|
-
static
|
|
44
|
+
static toRawGuidBuffer(value: GuidInput): Buffer;
|
|
129
45
|
/**
|
|
130
|
-
*
|
|
131
|
-
* This is the primary parsing method for when you expect valid input.
|
|
132
|
-
* @param value The value to parse
|
|
133
|
-
* @returns A new Guid instance with __version attached
|
|
134
|
-
* @throws {GuidError} If the value is not a valid GUID
|
|
46
|
+
* Attaches the RFC 4122 version to a GuidBuffer instance.
|
|
135
47
|
*/
|
|
48
|
+
private static attachVersion;
|
|
49
|
+
static v4(): VersionedGuidBuffer<4>;
|
|
50
|
+
static v5(name: string, namespace: string | Uint8Array): VersionedGuidBuffer<5>;
|
|
51
|
+
static v3(name: string, namespace: string | Uint8Array): VersionedGuidBuffer<3>;
|
|
52
|
+
static v6(options?: uuid.Version6Options): VersionedGuidBuffer<6>;
|
|
53
|
+
static v7(options?: uuid.Version7Options): VersionedGuidBuffer<7>;
|
|
54
|
+
static v1(options?: uuid.Version1Options): VersionedGuidBuffer<1>;
|
|
136
55
|
static parse(value: GuidInput): VersionedGuidBuffer;
|
|
137
|
-
/**
|
|
138
|
-
* Attempts to parse a GUID, returning null on failure instead of throwing.
|
|
139
|
-
* Use this when you're uncertain if the input is valid.
|
|
140
|
-
* @param value The value to parse
|
|
141
|
-
* @returns A new Guid instance with __version attached, or null if parsing fails
|
|
142
|
-
*/
|
|
143
56
|
static tryParse(value: GuidInput): VersionedGuidBuffer | null;
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
* More efficient than tryParse when you only need validation.
|
|
147
|
-
* @param value The value to validate
|
|
148
|
-
* @returns True if valid, false otherwise
|
|
149
|
-
*/
|
|
150
|
-
static isValid(value: unknown): boolean;
|
|
151
|
-
/**
|
|
152
|
-
* Factory method to create a GUID from a full hex string.
|
|
153
|
-
* @param fullHex The full hex string (with dashes)
|
|
154
|
-
* @returns A new Guid instance with __version attached
|
|
155
|
-
*/
|
|
57
|
+
static generate(): VersionedGuidBuffer<4>;
|
|
58
|
+
static new(): VersionedGuidBuffer<4>;
|
|
156
59
|
static fromFullHex(fullHex: string): VersionedGuidBuffer;
|
|
157
|
-
/**
|
|
158
|
-
* Factory method to create a GUID from a short hex string.
|
|
159
|
-
* @param shortHex The short hex string (without dashes)
|
|
160
|
-
* @returns A new Guid instance with __version attached
|
|
161
|
-
*/
|
|
162
60
|
static fromShortHex(shortHex: string): VersionedGuidBuffer;
|
|
163
|
-
/**
|
|
164
|
-
* Factory method to create a GUID from a base64 string.
|
|
165
|
-
* @param base64 The base64 encoded string
|
|
166
|
-
* @returns A new Guid instance with __version attached
|
|
167
|
-
*/
|
|
168
61
|
static fromBase64(base64: string): VersionedGuidBuffer;
|
|
169
|
-
/**
|
|
170
|
-
* Factory method to create a GUID from a bigint.
|
|
171
|
-
* @param bigint The bigint value
|
|
172
|
-
* @returns A new Guid instance with __version attached
|
|
173
|
-
*/
|
|
174
62
|
static fromBigInt(bigint: bigint): VersionedGuidBuffer;
|
|
175
|
-
|
|
176
|
-
* Factory method to create a GUID from a raw buffer.
|
|
177
|
-
* @param buffer The raw 16-byte buffer
|
|
178
|
-
* @returns A new Guid instance with __version attached
|
|
179
|
-
*/
|
|
180
|
-
static fromBuffer(buffer: Buffer): VersionedGuidBuffer;
|
|
181
|
-
/**
|
|
182
|
-
* Factory method to create a GUID from a raw Uint8Array.
|
|
183
|
-
* This converts the Uint8Array to a Buffer first.
|
|
184
|
-
* @param bytes The raw 16-byte Uint8Array
|
|
185
|
-
* @returns A new Guid instance with __version attached
|
|
186
|
-
*/
|
|
187
|
-
static fromUint8Array(bytes: Uint8Array): VersionedGuidBuffer;
|
|
188
|
-
/**
|
|
189
|
-
* Creates a namespace-based v3 GUID (MD5 hash).
|
|
190
|
-
* Use this for deterministic GUIDs based on a namespace and name.
|
|
191
|
-
* @param namespace The namespace GUID (e.g., uuid.v3.DNS)
|
|
192
|
-
* @param name The name to hash within the namespace
|
|
193
|
-
* @returns A new Guid instance containing the v3 GUID with __version attached
|
|
194
|
-
* @example
|
|
195
|
-
* const guid = Guid.v3('example.com', uuid.v3.DNS);
|
|
196
|
-
*/
|
|
197
|
-
static v3(name: string, namespace: string | Buffer): VersionedGuidBuffer<3>;
|
|
198
|
-
/**
|
|
199
|
-
* Creates a namespace-based v5 GUID (SHA-1 hash).
|
|
200
|
-
* Use this for deterministic GUIDs based on a namespace and name.
|
|
201
|
-
* Preferred over v3 as SHA-1 is stronger than MD5.
|
|
202
|
-
* @param namespace The namespace GUID (e.g., uuid.v5.DNS)
|
|
203
|
-
* @param name The name to hash within the namespace
|
|
204
|
-
* @returns A new Guid instance containing the v5 GUID with __version attached
|
|
205
|
-
* @example
|
|
206
|
-
* const guid = Guid.v5('example.com', uuid.v5.DNS);
|
|
207
|
-
*/
|
|
208
|
-
static v5(name: string, namespace: string | Buffer): VersionedGuidBuffer<5>;
|
|
209
|
-
/**
|
|
210
|
-
* Common namespace constants for use with v3/v5 GUIDs.
|
|
211
|
-
* These are the standard RFC 4122 namespace UUIDs, defined inline for browser compatibility.
|
|
212
|
-
* (Avoids issues with uuid library's namespace exports in some bundler configurations)
|
|
213
|
-
*/
|
|
214
|
-
static readonly Namespaces: {
|
|
215
|
-
/** DNS namespace UUID per RFC 4122 */
|
|
216
|
-
readonly DNS: "6ba7b810-9dad-11d1-80b4-00c04fd430c8";
|
|
217
|
-
/** URL namespace UUID per RFC 4122 */
|
|
218
|
-
readonly URL: "6ba7b811-9dad-11d1-80b4-00c04fd430c8";
|
|
219
|
-
};
|
|
220
|
-
/**
|
|
221
|
-
* Returns the GUID as a full hex string.
|
|
222
|
-
* Result is cached for performance.
|
|
223
|
-
*/
|
|
224
|
-
get asFullHexGuid(): FullHexGuid;
|
|
225
|
-
/**
|
|
226
|
-
* Returns the GUID as a raw Buffer.
|
|
227
|
-
*/
|
|
228
|
-
get asBuffer(): Buffer;
|
|
229
|
-
/**
|
|
230
|
-
* Returns the GUID as a native Uint8Array (not a Buffer).
|
|
231
|
-
*/
|
|
232
|
-
get asUint8Array(): Uint8Array;
|
|
233
|
-
/**
|
|
234
|
-
* Returns the GUID as a short hex string.
|
|
235
|
-
* Result is cached for performance.
|
|
236
|
-
*/
|
|
237
|
-
get asShortHexGuid(): ShortHexGuid;
|
|
238
|
-
/**
|
|
239
|
-
* Returns the GUID as a base64 string.
|
|
240
|
-
*/
|
|
241
|
-
toString(): Base64Guid;
|
|
242
|
-
/**
|
|
243
|
-
* Returns the GUID as a JSON string.
|
|
244
|
-
* @returns The GUID as a JSON string.
|
|
245
|
-
*/
|
|
246
|
-
toJson(): string;
|
|
247
|
-
/**
|
|
248
|
-
* Returns the GUID as a bigint.
|
|
249
|
-
*/
|
|
250
|
-
get asBigIntGuid(): BigIntGuid;
|
|
251
|
-
/**
|
|
252
|
-
* Returns the GUID as a base64 string.
|
|
253
|
-
* Result is cached for performance.
|
|
254
|
-
*/
|
|
255
|
-
get asBase64Guid(): Base64Guid;
|
|
256
|
-
get asPlatformBuffer(): PlatformBuffer;
|
|
257
|
-
/**
|
|
258
|
-
* Checks if a GUID value is a boundary value (all zeros or all Fs).
|
|
259
|
-
* @param value The GUID value to check.
|
|
260
|
-
* @returns True if the value is a boundary value.
|
|
261
|
-
*/
|
|
262
|
-
private static isBoundaryValue;
|
|
263
|
-
/**
|
|
264
|
-
* Verifies if a given GUID is valid for the given brand.
|
|
265
|
-
* @param guidBrand The brand of the GUID to verify.
|
|
266
|
-
* @param guid The GUID to verify.
|
|
267
|
-
* @returns True if the GUID is valid for the given brand, false otherwise.
|
|
268
|
-
*/
|
|
269
|
-
static verifyGuid(guidBrand: GuidBrandType, guid: GuidInput): boolean;
|
|
270
|
-
/**
|
|
271
|
-
* Returns the length of the GUID for the given brand.
|
|
272
|
-
* @param guidBrand The brand of the GUID to get the length for.
|
|
273
|
-
* @returns The length of the GUID for the given brand.
|
|
274
|
-
*/
|
|
275
|
-
static guidBrandToLength(guidBrand: GuidBrandType): number;
|
|
276
|
-
/**
|
|
277
|
-
* Returns the brand of the GUID for the given length.
|
|
278
|
-
* @param length The length of the GUID to get the brand for.
|
|
279
|
-
* @param isBuffer Whether the GUID is a Buffer.
|
|
280
|
-
* @returns The brand of the GUID for the given length.
|
|
281
|
-
*/
|
|
282
|
-
static lengthToGuidBrand(length: number, isBuffer: boolean): GuidBrandType;
|
|
283
|
-
/**
|
|
284
|
-
* Verifies if a given GUID is a valid full hex GUID.
|
|
285
|
-
* @param fullHexGuidValue The full hex GUID to verify.
|
|
286
|
-
* @returns True if the GUID is a valid full hex GUID, false otherwise.
|
|
287
|
-
*/
|
|
288
|
-
static isFullHexGuid(fullHexGuidValue: GuidInput): boolean;
|
|
289
|
-
/**
|
|
290
|
-
* Verifies if a given GUID is a valid short hex GUID.
|
|
291
|
-
* @param shortHexGuidValue The short hex GUID to verify.
|
|
292
|
-
* @returns True if the GUID is a valid short hex GUID, false otherwise.
|
|
293
|
-
*/
|
|
294
|
-
static isShortHexGuid(shortHexGuidValue: GuidInput): boolean;
|
|
295
|
-
/**
|
|
296
|
-
* Verifies if a given GUID is a valid base64 GUID.
|
|
297
|
-
* @param value The base64 GUID to verify.
|
|
298
|
-
* @returns True if the GUID is a valid base64 GUID, false otherwise.
|
|
299
|
-
*/
|
|
300
|
-
static isBase64Guid(value: GuidInput): boolean;
|
|
301
|
-
/**
|
|
302
|
-
* Verifies if a given GUID is a valid raw GUID buffer.
|
|
303
|
-
* @param value The raw GUID buffer to verify.
|
|
304
|
-
* @returns True if the GUID is a valid raw GUID buffer, false otherwise.
|
|
305
|
-
*/
|
|
306
|
-
static isRawGuidPlatformBuffer(value: GuidInput): boolean;
|
|
307
|
-
/**
|
|
308
|
-
* Verifies if a given GUID is a valid bigint GUID.
|
|
309
|
-
* @param value The bigint GUID to verify.
|
|
310
|
-
* @returns True if the GUID is a valid bigint GUID, false otherwise.
|
|
311
|
-
*/
|
|
312
|
-
static isBigIntGuid(value: GuidInput): boolean;
|
|
313
|
-
/**
|
|
314
|
-
* Determines the brand of a given GUID value.
|
|
315
|
-
* @param value The GUID value to determine the brand of.
|
|
316
|
-
* @returns The brand of the GUID value.
|
|
317
|
-
*/
|
|
318
|
-
static whichBrand(value: GuidInput): GuidBrandType;
|
|
319
|
-
/**
|
|
320
|
-
* Converts a given short hex GUID to a full hex GUID.
|
|
321
|
-
* @param shortGuid The short hex GUID to convert.
|
|
322
|
-
* @returns The short hex GUID as a full hex GUID.
|
|
323
|
-
*/
|
|
324
|
-
private static shortGuidToFullGuid;
|
|
325
|
-
/**
|
|
326
|
-
* Converts a given GUID value to a full hex GUID.
|
|
327
|
-
* @param guid The GUID value to convert.
|
|
328
|
-
* @returns The GUID value as a full hex GUID.
|
|
329
|
-
*/
|
|
330
|
-
static toFullHexGuid(guid: RawGuidPlatformBuffer | BigIntGuid | Base64Guid | ShortHexGuid | FullHexGuid | string): FullHexGuid;
|
|
331
|
-
static toShortHexGuid(guid: RawGuidPlatformBuffer | BigIntGuid | Base64Guid | ShortHexGuid | FullHexGuid | string): ShortHexGuid;
|
|
332
|
-
/**
|
|
333
|
-
* Converts a given bigint to a full hex GUID.
|
|
334
|
-
* @param bigInt The bigint to convert.
|
|
335
|
-
* @returns The bigint as a full hex GUID.
|
|
336
|
-
*/
|
|
337
|
-
static toFullHexFromBigInt(bigInt: bigint): FullHexGuid;
|
|
338
|
-
/**
|
|
339
|
-
* Converts a given GUID value to a raw GUID buffer.
|
|
340
|
-
* @param value The GUID value to convert.
|
|
341
|
-
* @returns The GUID value as a raw GUID buffer.
|
|
342
|
-
*/
|
|
343
|
-
static toRawGuidPlatformBuffer(value: GuidInput): RawGuidPlatformBuffer;
|
|
344
|
-
/**
|
|
345
|
-
* Compare two Guid instances for equality.
|
|
346
|
-
* @param other - The other Guid instance to compare (can be null/undefined)
|
|
347
|
-
* @param constantTime - Use constant-time comparison to prevent timing attacks (default: false)
|
|
348
|
-
* @returns True if the two Guid instances are equal, false otherwise
|
|
349
|
-
*/
|
|
350
|
-
equals(other: IGuid | null | undefined, constantTime?: boolean): boolean;
|
|
351
|
-
/**
|
|
352
|
-
* Checks if this GUID is empty (all zeros).
|
|
353
|
-
* @returns True if the GUID is all zeros, false otherwise
|
|
354
|
-
*/
|
|
355
|
-
isEmpty(): boolean;
|
|
356
|
-
/**
|
|
357
|
-
* Static helper to check if a GUID is null, undefined, or empty.
|
|
358
|
-
* @param guid The GUID to check
|
|
359
|
-
* @returns True if the GUID is null, undefined, or empty
|
|
360
|
-
*/
|
|
361
|
-
static isNilOrEmpty(guid: IGuid | null | undefined): boolean;
|
|
362
|
-
/**
|
|
363
|
-
* Creates a new Guid instance with the same value as this one.
|
|
364
|
-
* @returns A new Guid instance with identical value and __version attached
|
|
365
|
-
*/
|
|
63
|
+
static fromPlatformBuffer(bytes: Uint8Array): VersionedGuidBuffer;
|
|
366
64
|
clone(): VersionedGuidBuffer;
|
|
367
|
-
/**
|
|
368
|
-
* Returns the hash code for this GUID based on its buffer content.
|
|
369
|
-
* Useful for using GUIDs as Map/Set keys.
|
|
370
|
-
* @returns A numeric hash code
|
|
371
|
-
*/
|
|
372
|
-
hashCode(): number;
|
|
373
|
-
/**
|
|
374
|
-
* Extracts the RFC 4122 version from the GUID.
|
|
375
|
-
* Returns undefined for boundary values or invalid GUIDs.
|
|
376
|
-
* @returns The version number (1-5) or undefined
|
|
377
|
-
*/
|
|
378
|
-
getVersion(): number | undefined;
|
|
379
|
-
/**
|
|
380
|
-
* Validates that this GUID is a proper v3 GUID according to RFC 4122.
|
|
381
|
-
* @returns True if valid v3 GUID, false otherwise
|
|
382
|
-
*/
|
|
383
|
-
isValidV3(): boolean;
|
|
384
|
-
/**
|
|
385
|
-
* Validates that this GUID is a proper v4 GUID according to RFC 4122.
|
|
386
|
-
* Boundary values (all zeros/all Fs) return true as they're mathematically valid.
|
|
387
|
-
* @returns True if valid v4 GUID or boundary value, false otherwise
|
|
388
|
-
*/
|
|
389
|
-
isValidV4(): boolean;
|
|
390
|
-
/**
|
|
391
|
-
* Validates that this GUID is a proper v5 GUID according to RFC 4122.
|
|
392
|
-
* @returns True if valid v5 GUID, false otherwise
|
|
393
|
-
*/
|
|
394
|
-
isValidV5(): boolean;
|
|
395
|
-
/**
|
|
396
|
-
* Returns a human-readable string representation.
|
|
397
|
-
*/
|
|
398
|
-
toDebugString(): string;
|
|
399
|
-
/**
|
|
400
|
-
* Compares two GUIDs for ordering.
|
|
401
|
-
* Useful for sorting GUID arrays.
|
|
402
|
-
* @param other The other GUID to compare to
|
|
403
|
-
* @returns -1 if this < other, 0 if equal, 1 if this > other
|
|
404
|
-
*/
|
|
405
|
-
compareTo(other: IGuid): number;
|
|
406
|
-
/**
|
|
407
|
-
* Returns the timestamp from a v1 GUID.
|
|
408
|
-
* @returns Date object or undefined if not a v1 GUID
|
|
409
|
-
*/
|
|
410
|
-
getTimestamp(): Date | undefined;
|
|
411
|
-
/**
|
|
412
|
-
* Extracts the variant from the GUID.
|
|
413
|
-
* @returns The variant (0-2) or undefined
|
|
414
|
-
*/
|
|
415
|
-
getVariant(): number | undefined;
|
|
416
|
-
/**
|
|
417
|
-
* Creates a v1 GUID (time-based).
|
|
418
|
-
* @returns A new Guid instance containing a v1 GUID with __version attached
|
|
419
|
-
*/
|
|
420
|
-
static v1(): VersionedGuidBuffer<1>;
|
|
421
|
-
/**
|
|
422
|
-
* Validates that this GUID is a proper v1 GUID.
|
|
423
|
-
* @returns True if valid v1 GUID, false otherwise
|
|
424
|
-
*/
|
|
425
|
-
isValidV1(): boolean;
|
|
426
|
-
/**
|
|
427
|
-
* Returns a URL-safe base64 representation (no padding, URL-safe chars).
|
|
428
|
-
*/
|
|
429
|
-
get asUrlSafeBase64(): string;
|
|
430
|
-
/**
|
|
431
|
-
* Creates a GUID from URL-safe base64.
|
|
432
|
-
* @returns A new Guid instance with __version attached
|
|
433
|
-
*/
|
|
434
|
-
static fromUrlSafeBase64(urlSafe: string): VersionedGuidBuffer;
|
|
435
|
-
/**
|
|
436
|
-
* Alias for isRawGuidPlatformBuffer for backward compatibility
|
|
437
|
-
*/
|
|
438
|
-
static isRawGuidBuffer: typeof GuidBuffer.isRawGuidPlatformBuffer;
|
|
439
|
-
/**
|
|
440
|
-
* Alias for toRawGuidPlatformBuffer for backward compatibility
|
|
441
|
-
*/
|
|
442
|
-
static toRawGuidBuffer: typeof GuidBuffer.toRawGuidPlatformBuffer;
|
|
443
65
|
}
|
|
444
66
|
//# sourceMappingURL=guid.d.ts.map
|
package/src/lib/guid.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guid.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-node-ecies-lib/src/lib/guid.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"guid.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-node-ecies-lib/src/lib/guid.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C;;GAEG;AACH,MAAM,MAAM,mBAAmB,CAC7B,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,SAAS,GACvC,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,SAAS,IACX,UAAU,GAAG;IAAE,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAA;CAAE,CAAC;AAE3C;;;GAGG;AACH,qBAAa,UAAW,SAAQ,cAAe,YAAW,KAAK;gBACjD,KAAK,EAAE,SAAS;IAc5B;;OAEG;IACH,IAAW,QAAQ,IAAI,MAAM,CAI5B;IAED;;OAEG;IACH,IAAW,YAAY,IAAI,UAAU,CAEpC;IAED,IAAW,gBAAgB,IAAI,cAAc,CAI5C;IAED;;OAEG;WACW,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,mBAAmB;IAI7D;;OAEG;WACW,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,mBAAmB;IAIpE;;OAEG;IACH,OAAc,eAAe,4CAAsC;IAEnE;;OAEG;WACW,eAAe,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM;IAKvD;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,aAAa;WASL,EAAE,IAAI,mBAAmB,CAAC,CAAC,CAAC;WAM5B,EAAE,CACvB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,GAAG,UAAU,GAC7B,mBAAmB,CAAC,CAAC,CAAC;WAMF,EAAE,CACvB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,GAAG,UAAU,GAC7B,mBAAmB,CAAC,CAAC,CAAC;WAMF,EAAE,CACvB,OAAO,CAAC,EAAE,IAAI,CAAC,eAAe,GAC7B,mBAAmB,CAAC,CAAC,CAAC;WAMF,EAAE,CACvB,OAAO,CAAC,EAAE,IAAI,CAAC,eAAe,GAC7B,mBAAmB,CAAC,CAAC,CAAC;WAMF,EAAE,CACvB,OAAO,CAAC,EAAE,IAAI,CAAC,eAAe,GAC7B,mBAAmB,CAAC,CAAC,CAAC;WAMF,KAAK,CAAC,KAAK,EAAE,SAAS,GAAG,mBAAmB;WAI5C,QAAQ,CAC7B,KAAK,EAAE,SAAS,GACf,mBAAmB,GAAG,IAAI;WAQN,QAAQ,IAAI,mBAAmB,CAAC,CAAC,CAAC;WAIlC,GAAG,IAAI,mBAAmB,CAAC,CAAC,CAAC;WAI7B,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,mBAAmB;WAIjD,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,mBAAmB;WAInD,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,mBAAmB;WAI/C,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,mBAAmB;WAI/C,kBAAkB,CACvC,KAAK,EAAE,UAAU,GAChB,mBAAmB;IAIN,KAAK,IAAI,mBAAmB;CAG7C"}
|