kmod-cli 1.9.0 → 1.10.0
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/README.md +1 -0
- package/component-templates/utils/hash/fanhash.ts +107 -0
- package/components.json +39 -108
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SHA_256 clearly
|
|
3
|
+
*/
|
|
4
|
+
function _sha256Internal(ascii: string): string {
|
|
5
|
+
const rightRotate = (v: number, a: number): number => (v >>> a) | (v << (32 - a));
|
|
6
|
+
const maxWord = Math.pow(2, 32);
|
|
7
|
+
let hash = [0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19];
|
|
8
|
+
const k = [
|
|
9
|
+
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
10
|
+
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
11
|
+
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
12
|
+
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
|
13
|
+
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
|
14
|
+
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
15
|
+
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
|
16
|
+
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
let str = ascii + '\x80';
|
|
20
|
+
while (str.length % 64 - 56) str += '\x00';
|
|
21
|
+
const words: number[] = [];
|
|
22
|
+
for (let i = 0; i < str.length; i++) words[i >> 2] |= str.charCodeAt(i) << ((3 - i) % 4) * 8;
|
|
23
|
+
words[words.length] = ((ascii.length * 8 / maxWord) | 0);
|
|
24
|
+
words[words.length] = (ascii.length * 8 | 0);
|
|
25
|
+
|
|
26
|
+
for (let j = 0; j < words.length;) {
|
|
27
|
+
const w = words.slice(j, j += 16);
|
|
28
|
+
const oldHash = [...hash];
|
|
29
|
+
for (let i = 0; i < 64; i++) {
|
|
30
|
+
if (i >= 16) {
|
|
31
|
+
const s0 = rightRotate(w[i - 15], 7) ^ rightRotate(w[i - 15], 18) ^ (w[i - 15] >>> 3);
|
|
32
|
+
const s1 = rightRotate(w[i - 2], 17) ^ rightRotate(w[i - 2], 19) ^ (w[i - 2] >>> 10);
|
|
33
|
+
w[i] = (w[i - 16] + s0 + w[i - 7] + s1) | 0;
|
|
34
|
+
}
|
|
35
|
+
const t1 = (hash[7] + (rightRotate(hash[4], 6) ^ rightRotate(hash[4], 11) ^ rightRotate(hash[4], 25)) + ((hash[4] & hash[5]) ^ (~hash[4] & hash[6])) + k[i] + (w[i] | 0)) | 0;
|
|
36
|
+
const t2 = ((rightRotate(hash[0], 2) ^ rightRotate(hash[0], 13) ^ rightRotate(hash[0], 22)) + ((hash[0] & hash[1]) ^ (hash[0] & hash[2]) ^ (hash[1] & hash[2]))) | 0;
|
|
37
|
+
hash = [(t1 + t2) | 0, ...hash.slice(0, 7)];
|
|
38
|
+
hash[4] = (hash[4] + t1) | 0;
|
|
39
|
+
}
|
|
40
|
+
for (let i = 0; i < 8; i++) hash[i] = (hash[i] + oldHash[i]) | 0;
|
|
41
|
+
}
|
|
42
|
+
return hash.map(h => (h >>> 0).toString(16).padStart(8, '0')).join('');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Encrypts a password
|
|
47
|
+
*/
|
|
48
|
+
export function encryptFanHash(password: string, useXor: boolean = false): string {
|
|
49
|
+
const hex = _sha256Internal(password);
|
|
50
|
+
const data: Uint8Array = new Uint8Array(hex.match(/.{1,2}/g)!.map(b => parseInt(b, 16)));
|
|
51
|
+
const n: number = 61 + (password.length % 11);
|
|
52
|
+
|
|
53
|
+
for (let k = 0; k < n; k++) {
|
|
54
|
+
const offset = k % data.length;
|
|
55
|
+
for (let i = offset; i < data.length - 1; i += 2) {
|
|
56
|
+
// Permutation (Swap)
|
|
57
|
+
[data[i], data[i + 1]] = [data[i + 1], data[i]];
|
|
58
|
+
// Bitwise XOR
|
|
59
|
+
if (useXor) {
|
|
60
|
+
const charCode = password.charCodeAt(i % password.length);
|
|
61
|
+
data[i] ^= (charCode + k) % 256;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const finalHex = Array.from(data).map(b => b.toString(16).padStart(2, '0')).join('');
|
|
66
|
+
return finalHex.match(/.{1,8}/g)!.join('.');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Verifies a stored FanHash against a raw password.
|
|
71
|
+
*/
|
|
72
|
+
export function verifyFanHash(password: string, storedHash: string, useXor: boolean = false): boolean {
|
|
73
|
+
const clean = storedHash.replace(/\./g, '');
|
|
74
|
+
const data: Uint8Array = new Uint8Array(clean.match(/.{1,2}/g)!.map(b => parseInt(b, 16)));
|
|
75
|
+
const n: number = 61 + (password.length % 11);
|
|
76
|
+
|
|
77
|
+
for (let k = n - 1; k >= 0; k--) {
|
|
78
|
+
const offset = k % data.length;
|
|
79
|
+
for (let i = offset; i < data.length - 1; i += 2) {
|
|
80
|
+
if (useXor) {
|
|
81
|
+
const charCode = password.charCodeAt(i % password.length);
|
|
82
|
+
data[i] ^= (charCode + k) % 256;
|
|
83
|
+
}
|
|
84
|
+
[data[i], data[i + 1]] = [data[i + 1], data[i]];
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return Array.from(data).map(b => b.toString(16).padStart(2, '0')).join('') === _sha256Internal(password);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @method encrypt
|
|
92
|
+
* @method veriify
|
|
93
|
+
*/
|
|
94
|
+
export class FanHashEngine {
|
|
95
|
+
public static encrypt(password: string, useXor: boolean = false): string {
|
|
96
|
+
return encryptFanHash(password, useXor);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
public static verify(password: string, storedHash: string, useXor: boolean = false): boolean {
|
|
100
|
+
return verifyFanHash(password, storedHash, useXor);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// const myPass = "Abc@123456";
|
|
105
|
+
// const myHash = encryptFanHash(myPass, true);
|
|
106
|
+
// console.log("Hash:", myHash);
|
|
107
|
+
// console.log("Valid:", verifyFanHash(myPass, myHash, true));
|
package/components.json
CHANGED
|
@@ -1,46 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"access-denied": {
|
|
3
3
|
"path": "component-templates/components/access-denied.tsx",
|
|
4
|
-
"dependencies": [
|
|
5
|
-
"lucide-react"
|
|
6
|
-
],
|
|
4
|
+
"dependencies": ["lucide-react"],
|
|
7
5
|
"devDependencies": []
|
|
8
6
|
},
|
|
9
7
|
"breadcumb": {
|
|
10
8
|
"path": "component-templates/components/breadcumb.tsx",
|
|
11
|
-
"dependencies": [
|
|
12
|
-
"lucide-react"
|
|
13
|
-
],
|
|
9
|
+
"dependencies": ["lucide-react"],
|
|
14
10
|
"devDependencies": []
|
|
15
11
|
},
|
|
16
12
|
"count-down": {
|
|
17
13
|
"path": "component-templates/hooks/count-down.ts",
|
|
18
|
-
"dependencies": [
|
|
19
|
-
"zustand"
|
|
20
|
-
],
|
|
14
|
+
"dependencies": ["zustand"],
|
|
21
15
|
"devDependencies": []
|
|
22
16
|
},
|
|
23
17
|
"count-input": {
|
|
24
18
|
"path": "component-templates/components/count-input.tsx",
|
|
25
|
-
"dependencies": [
|
|
26
|
-
"lucide-react"
|
|
27
|
-
],
|
|
19
|
+
"dependencies": ["lucide-react"],
|
|
28
20
|
"devDependencies": []
|
|
29
21
|
},
|
|
30
22
|
"button": {
|
|
31
23
|
"path": "component-templates/components/datetime-picker/button.tsx",
|
|
32
|
-
"dependencies": [
|
|
33
|
-
"class-variance-authority",
|
|
34
|
-
"@radix-ui/react-slot"
|
|
35
|
-
],
|
|
24
|
+
"dependencies": ["class-variance-authority", "@radix-ui/react-slot"],
|
|
36
25
|
"devDependencies": []
|
|
37
26
|
},
|
|
38
27
|
"calendar": {
|
|
39
28
|
"path": "component-templates/components/datetime-picker/calendar.tsx",
|
|
40
|
-
"dependencies": [
|
|
41
|
-
"lucide-react",
|
|
42
|
-
"react-day-picker"
|
|
43
|
-
],
|
|
29
|
+
"dependencies": ["lucide-react", "react-day-picker"],
|
|
44
30
|
"devDependencies": []
|
|
45
31
|
},
|
|
46
32
|
"date-input": {
|
|
@@ -50,47 +36,32 @@
|
|
|
50
36
|
},
|
|
51
37
|
"date-range-picker": {
|
|
52
38
|
"path": "component-templates/components/date-range-calendar/date-range-picker.tsx",
|
|
53
|
-
"dependencies": [
|
|
54
|
-
"@radix-ui/react-icons"
|
|
55
|
-
],
|
|
39
|
+
"dependencies": ["@radix-ui/react-icons"],
|
|
56
40
|
"devDependencies": []
|
|
57
41
|
},
|
|
58
42
|
"label": {
|
|
59
43
|
"path": "component-templates/components/datetime-picker/label.tsx",
|
|
60
|
-
"dependencies": [
|
|
61
|
-
"class-variance-authority",
|
|
62
|
-
"@radix-ui/react-label"
|
|
63
|
-
],
|
|
44
|
+
"dependencies": ["class-variance-authority", "@radix-ui/react-label"],
|
|
64
45
|
"devDependencies": []
|
|
65
46
|
},
|
|
66
47
|
"popover": {
|
|
67
48
|
"path": "component-templates/components/datetime-picker/popover.tsx",
|
|
68
|
-
"dependencies": [
|
|
69
|
-
"@radix-ui/react-popover"
|
|
70
|
-
],
|
|
49
|
+
"dependencies": ["@radix-ui/react-popover"],
|
|
71
50
|
"devDependencies": []
|
|
72
51
|
},
|
|
73
52
|
"select": {
|
|
74
53
|
"path": "component-templates/components/datetime-picker/select.tsx",
|
|
75
|
-
"dependencies": [
|
|
76
|
-
"@radix-ui/react-icons",
|
|
77
|
-
"@radix-ui/react-select"
|
|
78
|
-
],
|
|
54
|
+
"dependencies": ["@radix-ui/react-icons", "@radix-ui/react-select"],
|
|
79
55
|
"devDependencies": []
|
|
80
56
|
},
|
|
81
57
|
"switch": {
|
|
82
58
|
"path": "component-templates/components/date-range-calendar/switch.tsx",
|
|
83
|
-
"dependencies": [
|
|
84
|
-
"@radix-ui/react-switch"
|
|
85
|
-
],
|
|
59
|
+
"dependencies": ["@radix-ui/react-switch"],
|
|
86
60
|
"devDependencies": []
|
|
87
61
|
},
|
|
88
62
|
"datetime-picker": {
|
|
89
63
|
"path": "component-templates/components/datetime-picker/datetime-picker.tsx",
|
|
90
|
-
"dependencies": [
|
|
91
|
-
"date-fns",
|
|
92
|
-
"lucide-react"
|
|
93
|
-
],
|
|
64
|
+
"dependencies": ["date-fns", "lucide-react"],
|
|
94
65
|
"devDependencies": []
|
|
95
66
|
},
|
|
96
67
|
"input": {
|
|
@@ -125,16 +96,12 @@
|
|
|
125
96
|
},
|
|
126
97
|
"gradient-svg": {
|
|
127
98
|
"path": "component-templates/components/gradient-svg.tsx",
|
|
128
|
-
"dependencies": [
|
|
129
|
-
"react-svg"
|
|
130
|
-
],
|
|
99
|
+
"dependencies": ["react-svg"],
|
|
131
100
|
"devDependencies": []
|
|
132
101
|
},
|
|
133
102
|
"grid-layout": {
|
|
134
103
|
"path": "component-templates/components/grid-layout.tsx",
|
|
135
|
-
"dependencies": [
|
|
136
|
-
"tailwind-merge"
|
|
137
|
-
],
|
|
104
|
+
"dependencies": ["tailwind-merge"],
|
|
138
105
|
"devDependencies": []
|
|
139
106
|
},
|
|
140
107
|
"hydrate-guard": {
|
|
@@ -168,17 +135,12 @@
|
|
|
168
135
|
},
|
|
169
136
|
"modal": {
|
|
170
137
|
"path": "component-templates/components/modal.tsx",
|
|
171
|
-
"dependencies": [
|
|
172
|
-
"react-dom"
|
|
173
|
-
],
|
|
138
|
+
"dependencies": ["react-dom"],
|
|
174
139
|
"devDependencies": []
|
|
175
140
|
},
|
|
176
141
|
"multi-select": {
|
|
177
142
|
"path": "component-templates/components/multi-select.tsx",
|
|
178
|
-
"dependencies": [
|
|
179
|
-
"class-variance-authority",
|
|
180
|
-
"lucide-react"
|
|
181
|
-
],
|
|
143
|
+
"dependencies": ["class-variance-authority", "lucide-react"],
|
|
182
144
|
"devDependencies": []
|
|
183
145
|
},
|
|
184
146
|
"non-hydration": {
|
|
@@ -188,9 +150,7 @@
|
|
|
188
150
|
},
|
|
189
151
|
"portal": {
|
|
190
152
|
"path": "component-templates/components/portal.tsx",
|
|
191
|
-
"dependencies": [
|
|
192
|
-
"react-dom"
|
|
193
|
-
],
|
|
153
|
+
"dependencies": ["react-dom"],
|
|
194
154
|
"devDependencies": []
|
|
195
155
|
},
|
|
196
156
|
"scroll-spy": {
|
|
@@ -205,9 +165,7 @@
|
|
|
205
165
|
},
|
|
206
166
|
"single-select": {
|
|
207
167
|
"path": "component-templates/components/single-select.tsx",
|
|
208
|
-
"dependencies": [
|
|
209
|
-
"lucide-react"
|
|
210
|
-
],
|
|
168
|
+
"dependencies": ["lucide-react"],
|
|
211
169
|
"devDependencies": []
|
|
212
170
|
},
|
|
213
171
|
"stroke-circle": {
|
|
@@ -217,23 +175,17 @@
|
|
|
217
175
|
},
|
|
218
176
|
"column-table": {
|
|
219
177
|
"path": "component-templates/components/table/column-table.tsx",
|
|
220
|
-
"dependencies": [
|
|
221
|
-
"@tanstack/react-table"
|
|
222
|
-
],
|
|
178
|
+
"dependencies": ["@tanstack/react-table"],
|
|
223
179
|
"devDependencies": []
|
|
224
180
|
},
|
|
225
181
|
"data-table": {
|
|
226
182
|
"path": "component-templates/components/table/data-table.tsx",
|
|
227
|
-
"dependencies": [
|
|
228
|
-
"@tanstack/react-table"
|
|
229
|
-
],
|
|
183
|
+
"dependencies": ["@tanstack/react-table"],
|
|
230
184
|
"devDependencies": []
|
|
231
185
|
},
|
|
232
186
|
"readme": {
|
|
233
187
|
"path": "component-templates/components/table/readme.tsx",
|
|
234
|
-
"dependencies": [
|
|
235
|
-
"@tanstack/react-table"
|
|
236
|
-
],
|
|
188
|
+
"dependencies": ["@tanstack/react-table"],
|
|
237
189
|
"devDependencies": []
|
|
238
190
|
},
|
|
239
191
|
"table": {
|
|
@@ -243,9 +195,7 @@
|
|
|
243
195
|
},
|
|
244
196
|
"text-hover-effect": {
|
|
245
197
|
"path": "component-templates/components/text-hover-effect.tsx",
|
|
246
|
-
"dependencies": [
|
|
247
|
-
"motion/react"
|
|
248
|
-
],
|
|
198
|
+
"dependencies": ["motion"],
|
|
249
199
|
"devDependencies": []
|
|
250
200
|
},
|
|
251
201
|
"timout-loader": {
|
|
@@ -255,10 +205,7 @@
|
|
|
255
205
|
},
|
|
256
206
|
"toast": {
|
|
257
207
|
"path": "component-templates/components/toast.tsx",
|
|
258
|
-
"dependencies": [
|
|
259
|
-
"react-dom",
|
|
260
|
-
"lucide-react"
|
|
261
|
-
],
|
|
208
|
+
"dependencies": ["react-dom", "lucide-react"],
|
|
262
209
|
"devDependencies": []
|
|
263
210
|
},
|
|
264
211
|
"config": {
|
|
@@ -278,9 +225,7 @@
|
|
|
278
225
|
},
|
|
279
226
|
"api-service": {
|
|
280
227
|
"path": "component-templates/core/api-service.ts",
|
|
281
|
-
"dependencies": [
|
|
282
|
-
"axios"
|
|
283
|
-
],
|
|
228
|
+
"dependencies": ["axios"],
|
|
284
229
|
"devDependencies": []
|
|
285
230
|
},
|
|
286
231
|
"calculate": {
|
|
@@ -290,17 +235,12 @@
|
|
|
290
235
|
},
|
|
291
236
|
"idb": {
|
|
292
237
|
"path": "component-templates/core/idb.ts",
|
|
293
|
-
"dependencies": [
|
|
294
|
-
"idb"
|
|
295
|
-
],
|
|
238
|
+
"dependencies": ["idb"],
|
|
296
239
|
"devDependencies": []
|
|
297
240
|
},
|
|
298
241
|
"lib": {
|
|
299
242
|
"path": "component-templates/core/lib.ts",
|
|
300
|
-
"dependencies": [
|
|
301
|
-
"clsx",
|
|
302
|
-
"tailwind-merge"
|
|
303
|
-
],
|
|
243
|
+
"dependencies": ["clsx", "tailwind-merge"],
|
|
304
244
|
"devDependencies": []
|
|
305
245
|
},
|
|
306
246
|
"storage": {
|
|
@@ -315,9 +255,7 @@
|
|
|
315
255
|
},
|
|
316
256
|
"safe-action": {
|
|
317
257
|
"path": "component-templates/hooks/safe-action.ts",
|
|
318
|
-
"dependencies": [
|
|
319
|
-
"lodash"
|
|
320
|
-
],
|
|
258
|
+
"dependencies": ["lodash"],
|
|
321
259
|
"devDependencies": []
|
|
322
260
|
},
|
|
323
261
|
"spam-guard": {
|
|
@@ -327,10 +265,7 @@
|
|
|
327
265
|
},
|
|
328
266
|
"utils": {
|
|
329
267
|
"path": "component-templates/lib/utils.ts",
|
|
330
|
-
"dependencies": [
|
|
331
|
-
"clsx",
|
|
332
|
-
"tailwind-merge"
|
|
333
|
-
],
|
|
268
|
+
"dependencies": ["clsx", "tailwind-merge"],
|
|
334
269
|
"devDependencies": []
|
|
335
270
|
},
|
|
336
271
|
"feature-guard": {
|
|
@@ -345,10 +280,7 @@
|
|
|
345
280
|
},
|
|
346
281
|
"refine-provider": {
|
|
347
282
|
"path": "component-templates/providers/refine-provider.tsx",
|
|
348
|
-
"dependencies": [
|
|
349
|
-
"axios",
|
|
350
|
-
"js-cookie"
|
|
351
|
-
],
|
|
283
|
+
"dependencies": ["axios", "js-cookie"],
|
|
352
284
|
"devDependencies": []
|
|
353
285
|
},
|
|
354
286
|
"query": {
|
|
@@ -358,9 +290,7 @@
|
|
|
358
290
|
},
|
|
359
291
|
"color-by-text": {
|
|
360
292
|
"path": "component-templates/utils/colors/color-by-text.ts",
|
|
361
|
-
"dependencies": [
|
|
362
|
-
"unidecode"
|
|
363
|
-
],
|
|
293
|
+
"dependencies": ["unidecode"],
|
|
364
294
|
"devDependencies": []
|
|
365
295
|
},
|
|
366
296
|
"stripe-effect": {
|
|
@@ -370,21 +300,22 @@
|
|
|
370
300
|
},
|
|
371
301
|
"kookies": {
|
|
372
302
|
"path": "component-templates/utils/cookies/kookies.ts",
|
|
373
|
-
"dependencies": [
|
|
374
|
-
|
|
375
|
-
|
|
303
|
+
"dependencies": ["js-cookie"],
|
|
304
|
+
"devDependencies": []
|
|
305
|
+
},
|
|
306
|
+
"fanhash": {
|
|
307
|
+
"path": "component-templates/utils/hash/fanhash.ts",
|
|
308
|
+
"dependencies": [],
|
|
376
309
|
"devDependencies": []
|
|
377
310
|
},
|
|
378
311
|
"hash-aes": {
|
|
379
312
|
"path": "component-templates/utils/hash/hash-aes.ts",
|
|
380
|
-
"dependencies": [
|
|
381
|
-
"crypto-js"
|
|
382
|
-
],
|
|
313
|
+
"dependencies": ["crypto-js"],
|
|
383
314
|
"devDependencies": []
|
|
384
315
|
},
|
|
385
316
|
"simple-validate": {
|
|
386
317
|
"path": "component-templates/utils/validator/simple-validate.ts",
|
|
387
|
-
"dependencies": [],
|
|
318
|
+
"dependencies": ["@/utils/validate/simple-validate"],
|
|
388
319
|
"devDependencies": []
|
|
389
320
|
}
|
|
390
|
-
}
|
|
321
|
+
}
|