nhb-toolbox 4.28.6 → 4.28.7
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/CHANGELOG.md +6 -1
- package/dist/cjs/hash/core.js +3 -0
- package/dist/dts/hash/core.d.ts +2 -2
- package/dist/dts/utils/index.d.ts +0 -1
- package/dist/esm/hash/core.js +3 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,9 +6,14 @@ All notable changes to the package will be documented here.
|
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
+
## [4.28.7] - 2025-12-02
|
|
10
|
+
|
|
11
|
+
- **Updated** *invalid links* in *tsdoc* of the *hash utilities*.
|
|
12
|
+
- **Implemented** input type *validation* for `sha256` utility.
|
|
13
|
+
|
|
9
14
|
## [4.28.6] - 2025-12-02
|
|
10
15
|
|
|
11
|
-
- **Updated** *tsdoc* for `stableStringify` + *type augmentation* for `String` methods: `toLowerCase` and `toUpperCase
|
|
16
|
+
- **Updated** *tsdoc* for `stableStringify` + *type augmentation* for `String` methods: `toLowerCase` and `toUpperCase`.
|
|
12
17
|
|
|
13
18
|
## [4.28.4] - 2025-12-02
|
|
14
19
|
|
package/dist/cjs/hash/core.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.md5 = md5;
|
|
4
4
|
exports.sha1 = sha1;
|
|
5
5
|
exports.sha256 = sha256;
|
|
6
|
+
const primitives_1 = require("../guards/primitives");
|
|
6
7
|
const helpers_1 = require("./helpers");
|
|
7
8
|
const utils_1 = require("./utils");
|
|
8
9
|
function md5(str) {
|
|
@@ -85,5 +86,7 @@ function sha1(msg) {
|
|
|
85
86
|
return h.map(toHex).join('');
|
|
86
87
|
}
|
|
87
88
|
function sha256(msg) {
|
|
89
|
+
if (!(0, primitives_1.isString)(msg))
|
|
90
|
+
throw new TypeError('Input must be of type string!');
|
|
88
91
|
return (0, utils_1.bytesToHex)((0, utils_1.sha256Bytes)((0, utils_1.utf8ToBytes)(msg)));
|
|
89
92
|
}
|
package/dist/dts/hash/core.d.ts
CHANGED
|
@@ -59,8 +59,8 @@ export declare function sha1(msg: string): string;
|
|
|
59
59
|
* // Returns: '7037e204b825b83553ba336a6ec35b796d505599286ae864729ed6cb33ae9fe1'
|
|
60
60
|
* ```
|
|
61
61
|
*
|
|
62
|
-
* @see {@link https://toolbox.nazmul-nhb.dev/docs/utilities/hash/
|
|
62
|
+
* @see {@link https://toolbox.nazmul-nhb.dev/docs/utilities/hash/encoding#sha256bytes sha256Bytes} for hashing raw bytes
|
|
63
63
|
* @see {@link https://toolbox.nazmul-nhb.dev/docs/utilities/hash/encoding#utf8tobytes utf8ToBytes} for converting string to bytes
|
|
64
|
-
* @see {@link https://toolbox.nazmul-nhb.dev/docs/utilities/hash/encoding#
|
|
64
|
+
* @see {@link https://toolbox.nazmul-nhb.dev/docs/utilities/hash/encoding#bytestohex bytesToHex} for converting bytes to a hexadecimal string
|
|
65
65
|
*/
|
|
66
66
|
export declare function sha256(msg: string): string;
|
|
@@ -124,7 +124,6 @@ export declare function getClassDetails(cls: Constructor): ClassDetails;
|
|
|
124
124
|
* * Create a deterministic JSON string representation of any value.
|
|
125
125
|
* - The output format matches standard JSON but with guaranteed sorted keys.
|
|
126
126
|
*
|
|
127
|
-
*
|
|
128
127
|
* @remarks
|
|
129
128
|
* - This function guarantees **stable, repeatable output** by:
|
|
130
129
|
* - Sorting all object keys alphabetically.
|
package/dist/esm/hash/core.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isString } from '../guards/primitives.js';
|
|
1
2
|
import { _md5cycle, _numToHex, _stringToNumbers } from './helpers.js';
|
|
2
3
|
import { bytesToHex, sha256Bytes, utf8ToBytes } from './utils.js';
|
|
3
4
|
export function md5(str) {
|
|
@@ -80,5 +81,7 @@ export function sha1(msg) {
|
|
|
80
81
|
return h.map(toHex).join('');
|
|
81
82
|
}
|
|
82
83
|
export function sha256(msg) {
|
|
84
|
+
if (!isString(msg))
|
|
85
|
+
throw new TypeError('Input must be of type string!');
|
|
83
86
|
return bytesToHex(sha256Bytes(utf8ToBytes(msg)));
|
|
84
87
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nhb-toolbox",
|
|
3
|
-
"version": "4.28.
|
|
3
|
+
"version": "4.28.7",
|
|
4
4
|
"description": "A versatile collection of smart, efficient, and reusable utility functions, classes and types for everyday development needs.",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|