@mitre/hdf-utilities 3.4.2 → 3.4.4

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.
Files changed (2) hide show
  1. package/README.md +16 -16
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -69,22 +69,22 @@ Generate and verify cryptographic hashes for data integrity:
69
69
  ```typescript
70
70
  import { sha256, sha512, generateHash, hashObject, verifyHash } from '@mitre/hdf-utilities';
71
71
 
72
- // Quick SHA-256 hash
73
- const hash = sha256('content to hash');
72
+ // Quick SHA-256 hash (hash functions are async)
73
+ const hash = await sha256('content to hash');
74
74
  console.log(hash); // hex-encoded hash
75
75
 
76
76
  // Hash with custom options
77
- const customHash = generateHash('data', {
77
+ const customHash = await generateHash('data', {
78
78
  algorithm: 'sha512',
79
79
  encoding: 'base64'
80
80
  });
81
81
 
82
82
  // Hash JavaScript objects (deterministic JSON serialization)
83
83
  const baseline = { name: 'My Baseline', version: '1.0' };
84
- const objectHash = hashObject(baseline, { algorithm: 'sha256' });
84
+ const objectHash = await hashObject(baseline, { algorithm: 'sha256' });
85
85
 
86
86
  // Verify data integrity
87
- const isValid = verifyHash('original data', hash, { algorithm: 'sha256' });
87
+ const isValid = await verifyHash('original data', hash, { algorithm: 'sha256' });
88
88
  if (!isValid) {
89
89
  console.error('Data integrity check failed!');
90
90
  }
@@ -229,42 +229,42 @@ Check if string can be parsed as JSON.
229
229
 
230
230
  ### Hash Utilities
231
231
 
232
- #### `sha256(data: string): string`
232
+ #### `sha256(data: string): Promise<string>`
233
233
 
234
234
  Generate SHA-256 hash (hex-encoded).
235
235
 
236
236
  - **Parameters:**
237
237
  - `data` - String to hash
238
- - **Returns:** Hex-encoded hash string
238
+ - **Returns:** Promise resolving to a hex-encoded hash string
239
239
 
240
- #### `sha512(data: string): string`
240
+ #### `sha512(data: string): Promise<string>`
241
241
 
242
242
  Generate SHA-512 hash (hex-encoded).
243
243
 
244
244
  - **Parameters:**
245
245
  - `data` - String to hash
246
- - **Returns:** Hex-encoded hash string
246
+ - **Returns:** Promise resolving to a hex-encoded hash string
247
247
 
248
- #### `generateHash(data: string, options?: HashOptions): string`
248
+ #### `generateHash(data: string, options?: HashOptions): Promise<string>`
249
249
 
250
250
  Generate hash with custom algorithm and encoding.
251
251
 
252
252
  - **Parameters:**
253
253
  - `data` - String to hash
254
254
  - `options.algorithm` - Hash algorithm: `'sha256'` | `'sha512'` (default: `'sha256'`)
255
- - `options.encoding` - Output encoding: `'hex'` | `'base64'` | `'base64url'` (default: `'hex'`)
256
- - **Returns:** Encoded hash string
255
+ - `options.encoding` - Output encoding: `'hex'` | `'base64'` (default: `'hex'`)
256
+ - **Returns:** Promise resolving to the encoded hash string
257
257
 
258
- #### `hashObject(obj: unknown, options?: HashOptions): string`
258
+ #### `hashObject(obj: unknown, options?: HashOptions): Promise<string>`
259
259
 
260
260
  Generate deterministic hash of JavaScript object.
261
261
 
262
262
  - **Parameters:**
263
263
  - `obj` - Object to hash (will be JSON-stringified)
264
264
  - `options` - Same as `generateHash`
265
- - **Returns:** Hash of serialized object
265
+ - **Returns:** Promise resolving to the hash of the serialized object
266
266
 
267
- #### `verifyHash(data: string, expectedHash: string, options?: HashOptions): boolean`
267
+ #### `verifyHash(data: string, expectedHash: string, options?: HashOptions): Promise<boolean>`
268
268
 
269
269
  Verify data matches expected hash.
270
270
 
@@ -272,7 +272,7 @@ Verify data matches expected hash.
272
272
  - `data` - Original data to verify
273
273
  - `expectedHash` - Expected hash value
274
274
  - `options` - Same hash options used during generation
275
- - **Returns:** `true` if hash matches, `false` otherwise
275
+ - **Returns:** Promise resolving to `true` if the hash matches, `false` otherwise
276
276
 
277
277
  ### XML Utilities
278
278
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mitre/hdf-utilities",
3
- "version": "3.4.2",
3
+ "version": "3.4.4",
4
4
  "description": "Utility functions for HDF libraries (JSON parsing, validation helpers)",
5
5
  "publishConfig": {
6
6
  "access": "public"