gdc-common-utils-ts 1.4.1 → 1.4.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/dist/index.d.ts CHANGED
@@ -2,3 +2,4 @@ export * from './AesManager';
2
2
  export * from './CryptographyService';
3
3
  export * from './hmac';
4
4
  export * from './storage';
5
+ export * from './utils';
package/dist/index.js CHANGED
@@ -2,3 +2,4 @@ export * from './AesManager.js';
2
2
  export * from './CryptographyService.js';
3
3
  export * from './hmac.js';
4
4
  export * from './storage/index.js';
5
+ export * from './utils/index.js';
@@ -14,3 +14,4 @@ export * from './multibase58';
14
14
  export * from './multibasehash';
15
15
  export * from './normalize';
16
16
  export * from './object-convert';
17
+ export * from './normalize-uuid';
@@ -14,3 +14,4 @@ export * from './multibase58.js';
14
14
  export * from './multibasehash.js';
15
15
  export * from './normalize.js';
16
16
  export * from './object-convert.js';
17
+ export * from './normalize-uuid.js';
@@ -0,0 +1 @@
1
+ export declare function normalizeSubjectUuid(input: string | undefined): string | undefined;
@@ -0,0 +1,24 @@
1
+ // Normalizes a subject identifier to a canonical UUID (hexadecimal, lowercase, no dashes)
2
+ // Accepts: urn:uuid:<uuid>, <ResourceType>/<uuid>, <uuid> (with or without dashes), base58 (optional)
3
+ // Returns: canonical hex string (no dashes, lowercase) or undefined if not valid
4
+ export function normalizeSubjectUuid(input) {
5
+ if (!input)
6
+ return undefined;
7
+ let s = String(input).trim();
8
+ // urn:uuid:<uuid>
9
+ if (s.startsWith('urn:uuid:'))
10
+ s = s.slice(9);
11
+ // <ResourceType>/<uuid>
12
+ const slashIdx = s.indexOf('/');
13
+ if (slashIdx >= 0)
14
+ s = s.slice(slashIdx + 1);
15
+ // Remove dashes
16
+ s = s.replace(/-/g, '');
17
+ // Lowercase
18
+ s = s.toLowerCase();
19
+ // Validate: must be 32 hex chars
20
+ if (/^[0-9a-f]{32}$/.test(s))
21
+ return s;
22
+ // Optionally: add base58 or other formats here
23
+ return undefined;
24
+ }
@@ -0,0 +1 @@
1
+ export declare function normalizeUuid(input: string | undefined): string | undefined;
@@ -0,0 +1,35 @@
1
+ // Normalizes a subject identifier to a canonical UUID (hexadecimal, lowercase, no dashes)
2
+ // Accepts: urn:uuid:<uuid>, <ResourceType>/<uuid>, <uuid> (with or without dashes), base58 (optional)
3
+ // Returns: canonical hex string (no dashes, lowercase) or undefined if not valid
4
+ import { decodeMultibase58btcToHex } from './multibase58.js';
5
+ export function normalizeUuid(input) {
6
+ if (!input)
7
+ return undefined;
8
+ let s = String(input).trim();
9
+ // urn:uuid:<...>
10
+ if (s.startsWith('urn:uuid:'))
11
+ s = s.slice(9);
12
+ // <ResourceType>/<...>
13
+ const slashIdx = s.indexOf('/');
14
+ if (slashIdx >= 0)
15
+ s = s.slice(slashIdx + 1);
16
+ // Si es multibase58btc (z...)
17
+ if (s.startsWith('z')) {
18
+ try {
19
+ const hex = decodeMultibase58btcToHex(s);
20
+ if (/^[0-9a-f]{32}$/.test(hex))
21
+ return hex;
22
+ }
23
+ catch (e) {
24
+ // no válido, ignorar
25
+ }
26
+ }
27
+ // Remove dashes
28
+ s = s.replace(/-/g, '');
29
+ // Lowercase
30
+ s = s.toLowerCase();
31
+ // Validate: must be 32 hex chars
32
+ if (/^[0-9a-f]{32}$/.test(s))
33
+ return s;
34
+ return undefined;
35
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gdc-common-utils-ts",
3
- "version": "1.4.1",
3
+ "version": "1.4.6",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },