@blaxel/core 0.2.13 → 0.2.14-dev.92
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/common/internal.js +6 -4
- package/dist/common/internal.test.js +20 -11
- package/package.json +1 -1
package/dist/common/internal.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getAlphanumericLimitedHash = getAlphanumericLimitedHash;
|
|
4
4
|
exports.getGlobalUniqueHash = getGlobalUniqueHash;
|
|
5
5
|
/* eslint-disable */
|
|
6
|
-
// Pure JS MD5 implementation
|
|
6
|
+
// Pure JS MD5 implementation that matches standard crypto MD5
|
|
7
7
|
function md5(input) {
|
|
8
8
|
function cmn(q, a, b, x, s, t) {
|
|
9
9
|
a = (((a + q) | 0) + ((x + t) | 0)) | 0;
|
|
@@ -121,10 +121,12 @@ function md5(input) {
|
|
|
121
121
|
md5cycle(state, tail);
|
|
122
122
|
return state;
|
|
123
123
|
}
|
|
124
|
+
// Fixed hex conversion function
|
|
124
125
|
function rhex(n) {
|
|
125
|
-
let s = ''
|
|
126
|
-
for (; j < 4; j++)
|
|
127
|
-
s += (
|
|
126
|
+
let s = '';
|
|
127
|
+
for (let j = 0; j < 4; j++) {
|
|
128
|
+
s += ((n >> (j * 8)) & 0xFF).toString(16).padStart(2, '0');
|
|
129
|
+
}
|
|
128
130
|
return s;
|
|
129
131
|
}
|
|
130
132
|
return md51(input).map(rhex).join('');
|
|
@@ -5,26 +5,35 @@ const internal_1 = require("./internal");
|
|
|
5
5
|
(0, vitest_1.describe)('getAlphanumericLimitedHash', () => {
|
|
6
6
|
(0, vitest_1.it)('returns correct MD5 hash for a known string', () => {
|
|
7
7
|
// MD5 of 'hello' is 5d41402abc4b2a76b9719d911017c592
|
|
8
|
-
(0, vitest_1.expect)((0, internal_1.getAlphanumericLimitedHash)('hello')).toBe('
|
|
8
|
+
(0, vitest_1.expect)((0, internal_1.getAlphanumericLimitedHash)('hello')).toBe('5d41402abc4b2a76b9719d911017c592');
|
|
9
9
|
});
|
|
10
10
|
(0, vitest_1.it)('respects the maxSize parameter', () => {
|
|
11
11
|
const hash = (0, internal_1.getAlphanumericLimitedHash)('hello', 8);
|
|
12
12
|
(0, vitest_1.expect)(hash.length).toBe(8);
|
|
13
|
-
(0, vitest_1.expect)(hash).toBe('
|
|
13
|
+
(0, vitest_1.expect)(hash).toBe('5d41402a');
|
|
14
14
|
});
|
|
15
15
|
(0, vitest_1.it)('returns full hash if maxSize is larger than hash', () => {
|
|
16
16
|
const hash = (0, internal_1.getAlphanumericLimitedHash)('hello', 64);
|
|
17
|
-
(0, vitest_1.expect)(hash).toBe('
|
|
17
|
+
(0, vitest_1.expect)(hash).toBe('5d41402abc4b2a76b9719d911017c592');
|
|
18
18
|
});
|
|
19
19
|
});
|
|
20
|
+
const testCases = [
|
|
21
|
+
{
|
|
22
|
+
workspace: 'charlou-dev',
|
|
23
|
+
type: 'function',
|
|
24
|
+
name: 'blaxel-search',
|
|
25
|
+
expected: '594d9322779f4a07a55a7bf1050360c6'
|
|
26
|
+
}, {
|
|
27
|
+
workspace: 'charlou-dev',
|
|
28
|
+
type: 'agent',
|
|
29
|
+
name: 'toto',
|
|
30
|
+
expected: '1bb3a151bda194751b062df8edb59eaf',
|
|
31
|
+
}
|
|
32
|
+
];
|
|
20
33
|
(0, vitest_1.describe)('getGlobalUniqueHash', () => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
});
|
|
26
|
-
(0, vitest_1.it)('returns a 48-character hash by default', () => {
|
|
27
|
-
const hash = (0, internal_1.getGlobalUniqueHash)('a', 'b', 'c');
|
|
28
|
-
(0, vitest_1.expect)(hash.length).toBeLessThanOrEqual(48);
|
|
34
|
+
testCases.forEach(({ workspace, type, name, expected }) => {
|
|
35
|
+
(0, vitest_1.it)(`returns ${expected} for ${workspace}-${type}-${name}`, () => {
|
|
36
|
+
(0, vitest_1.expect)((0, internal_1.getGlobalUniqueHash)(workspace, type, name)).toBe(expected);
|
|
37
|
+
});
|
|
29
38
|
});
|
|
30
39
|
});
|