cipher-kit 1.0.1 → 2.0.0-beta.1

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 (46) hide show
  1. package/README.md +123 -1
  2. package/dist/chunk-6HNTSQAP.js +139 -0
  3. package/dist/chunk-6HNTSQAP.js.map +1 -0
  4. package/dist/chunk-DZLEO2JD.cjs +511 -0
  5. package/dist/chunk-DZLEO2JD.cjs.map +1 -0
  6. package/dist/chunk-I25C3WUZ.js +382 -0
  7. package/dist/chunk-I25C3WUZ.js.map +1 -0
  8. package/dist/chunk-SRGSVNQ2.js +486 -0
  9. package/dist/chunk-SRGSVNQ2.js.map +1 -0
  10. package/dist/chunk-UR5HPMNF.cjs +411 -0
  11. package/dist/chunk-UR5HPMNF.cjs.map +1 -0
  12. package/dist/chunk-ZIVTPFKN.cjs +163 -0
  13. package/dist/chunk-ZIVTPFKN.cjs.map +1 -0
  14. package/dist/export-C2vQXrZa.d.cts +263 -0
  15. package/dist/export-DEWwhS-S.d.ts +264 -0
  16. package/dist/export-DzNR1ht3.d.ts +263 -0
  17. package/dist/export-oVEmcDLI.d.cts +264 -0
  18. package/dist/index.cjs +82 -38
  19. package/dist/index.d.cts +3 -22
  20. package/dist/index.d.ts +3 -22
  21. package/dist/index.js +3 -3
  22. package/dist/node.cjs +84 -28
  23. package/dist/node.d.cts +3 -22
  24. package/dist/node.d.ts +3 -22
  25. package/dist/node.js +2 -2
  26. package/dist/validate-TRx4DDtg.d.cts +123 -0
  27. package/dist/validate-TRx4DDtg.d.ts +123 -0
  28. package/dist/web-api.cjs +84 -28
  29. package/dist/web-api.d.cts +2 -21
  30. package/dist/web-api.d.ts +2 -21
  31. package/dist/web-api.js +2 -2
  32. package/package.json +6 -4
  33. package/dist/chunk-5MYBXP4A.cjs +0 -228
  34. package/dist/chunk-5MYBXP4A.cjs.map +0 -1
  35. package/dist/chunk-DC4WFPHL.js +0 -141
  36. package/dist/chunk-DC4WFPHL.js.map +0 -1
  37. package/dist/chunk-NGVIYM6K.js +0 -217
  38. package/dist/chunk-NGVIYM6K.js.map +0 -1
  39. package/dist/chunk-SBXDW4MY.cjs +0 -99
  40. package/dist/chunk-SBXDW4MY.cjs.map +0 -1
  41. package/dist/chunk-THMEBIZB.js +0 -79
  42. package/dist/chunk-THMEBIZB.js.map +0 -1
  43. package/dist/chunk-XTA6TKBQ.cjs +0 -156
  44. package/dist/chunk-XTA6TKBQ.cjs.map +0 -1
  45. package/dist/utils-Bryp07ny.d.cts +0 -48
  46. package/dist/utils-Bryp07ny.d.ts +0 -48
package/dist/index.cjs CHANGED
@@ -1,94 +1,138 @@
1
1
  'use strict';
2
2
 
3
- var chunkXTA6TKBQ_cjs = require('./chunk-XTA6TKBQ.cjs');
4
- var chunk5MYBXP4A_cjs = require('./chunk-5MYBXP4A.cjs');
5
- var chunkSBXDW4MY_cjs = require('./chunk-SBXDW4MY.cjs');
3
+ var chunkUR5HPMNF_cjs = require('./chunk-UR5HPMNF.cjs');
4
+ var chunkDZLEO2JD_cjs = require('./chunk-DZLEO2JD.cjs');
5
+ var chunkZIVTPFKN_cjs = require('./chunk-ZIVTPFKN.cjs');
6
6
 
7
7
 
8
8
 
9
- Object.defineProperty(exports, "createSecretKey", {
9
+ Object.defineProperty(exports, "convertBytesToStr", {
10
10
  enumerable: true,
11
- get: function () { return chunkXTA6TKBQ_cjs.createSecretKey; }
11
+ get: function () { return chunkUR5HPMNF_cjs.convertBytesToStr; }
12
12
  });
13
- Object.defineProperty(exports, "decode", {
13
+ Object.defineProperty(exports, "convertFormat", {
14
14
  enumerable: true,
15
- get: function () { return chunkXTA6TKBQ_cjs.decode; }
15
+ get: function () { return chunkUR5HPMNF_cjs.convertFormat; }
16
16
  });
17
- Object.defineProperty(exports, "decrypt", {
17
+ Object.defineProperty(exports, "convertStrToBytes", {
18
18
  enumerable: true,
19
- get: function () { return chunkXTA6TKBQ_cjs.decrypt; }
19
+ get: function () { return chunkUR5HPMNF_cjs.convertStrToBytes; }
20
20
  });
21
- Object.defineProperty(exports, "decryptObj", {
21
+ Object.defineProperty(exports, "createSecretKey", {
22
+ enumerable: true,
23
+ get: function () { return chunkUR5HPMNF_cjs.createSecretKey; }
24
+ });
25
+ Object.defineProperty(exports, "decrypt", {
22
26
  enumerable: true,
23
- get: function () { return chunkXTA6TKBQ_cjs.decryptObj; }
27
+ get: function () { return chunkUR5HPMNF_cjs.decrypt; }
24
28
  });
25
- Object.defineProperty(exports, "encode", {
29
+ Object.defineProperty(exports, "decryptObj", {
26
30
  enumerable: true,
27
- get: function () { return chunkXTA6TKBQ_cjs.encode; }
31
+ get: function () { return chunkUR5HPMNF_cjs.decryptObj; }
28
32
  });
29
33
  Object.defineProperty(exports, "encrypt", {
30
34
  enumerable: true,
31
- get: function () { return chunkXTA6TKBQ_cjs.encrypt; }
35
+ get: function () { return chunkUR5HPMNF_cjs.encrypt; }
32
36
  });
33
37
  Object.defineProperty(exports, "encryptObj", {
34
38
  enumerable: true,
35
- get: function () { return chunkXTA6TKBQ_cjs.encryptObj; }
39
+ get: function () { return chunkUR5HPMNF_cjs.encryptObj; }
36
40
  });
37
41
  Object.defineProperty(exports, "generateUuid", {
38
42
  enumerable: true,
39
- get: function () { return chunkXTA6TKBQ_cjs.generateUuid; }
43
+ get: function () { return chunkUR5HPMNF_cjs.generateUuid; }
40
44
  });
41
45
  Object.defineProperty(exports, "hash", {
42
46
  enumerable: true,
43
- get: function () { return chunkXTA6TKBQ_cjs.hash; }
47
+ get: function () { return chunkUR5HPMNF_cjs.hash; }
48
+ });
49
+ Object.defineProperty(exports, "hashPassword", {
50
+ enumerable: true,
51
+ get: function () { return chunkUR5HPMNF_cjs.hashPassword; }
44
52
  });
45
53
  Object.defineProperty(exports, "nodeKit", {
46
54
  enumerable: true,
47
- get: function () { return chunkXTA6TKBQ_cjs.export_exports; }
55
+ get: function () { return chunkUR5HPMNF_cjs.kit_exports; }
56
+ });
57
+ Object.defineProperty(exports, "tryConvertBytesToStr", {
58
+ enumerable: true,
59
+ get: function () { return chunkUR5HPMNF_cjs.tryConvertBytesToStr; }
60
+ });
61
+ Object.defineProperty(exports, "tryConvertFormat", {
62
+ enumerable: true,
63
+ get: function () { return chunkUR5HPMNF_cjs.tryConvertFormat; }
48
64
  });
49
- Object.defineProperty(exports, "webApiKit", {
65
+ Object.defineProperty(exports, "tryConvertStrToBytes", {
50
66
  enumerable: true,
51
- get: function () { return chunk5MYBXP4A_cjs.export_exports; }
67
+ get: function () { return chunkUR5HPMNF_cjs.tryConvertStrToBytes; }
52
68
  });
53
- Object.defineProperty(exports, "ENCRYPTION_REGEX", {
69
+ Object.defineProperty(exports, "tryCreateSecretKey", {
54
70
  enumerable: true,
55
- get: function () { return chunkSBXDW4MY_cjs.ENCRYPTION_REGEX; }
71
+ get: function () { return chunkUR5HPMNF_cjs.tryCreateSecretKey; }
56
72
  });
57
- Object.defineProperty(exports, "NODE_ALGORITHM", {
73
+ Object.defineProperty(exports, "tryDecrypt", {
58
74
  enumerable: true,
59
- get: function () { return chunkSBXDW4MY_cjs.NODE_ALGORITHM; }
75
+ get: function () { return chunkUR5HPMNF_cjs.tryDecrypt; }
60
76
  });
61
- Object.defineProperty(exports, "WEB_API_ALGORITHM", {
77
+ Object.defineProperty(exports, "tryDecryptObj", {
62
78
  enumerable: true,
63
- get: function () { return chunkSBXDW4MY_cjs.WEB_API_ALGORITHM; }
79
+ get: function () { return chunkUR5HPMNF_cjs.tryDecryptObj; }
64
80
  });
65
- Object.defineProperty(exports, "isInEncryptionFormat", {
81
+ Object.defineProperty(exports, "tryEncrypt", {
66
82
  enumerable: true,
67
- get: function () { return chunkSBXDW4MY_cjs.isInEncryptionFormat; }
83
+ get: function () { return chunkUR5HPMNF_cjs.tryEncrypt; }
68
84
  });
69
- Object.defineProperty(exports, "isInNodeEncryptionFormat", {
85
+ Object.defineProperty(exports, "tryEncryptObj", {
70
86
  enumerable: true,
71
- get: function () { return chunkSBXDW4MY_cjs.isInNodeEncryptionFormat; }
87
+ get: function () { return chunkUR5HPMNF_cjs.tryEncryptObj; }
72
88
  });
73
- Object.defineProperty(exports, "isInWebApiEncryptionFormat", {
89
+ Object.defineProperty(exports, "tryGenerateUuid", {
74
90
  enumerable: true,
75
- get: function () { return chunkSBXDW4MY_cjs.isInWebApiEncryptionFormat; }
91
+ get: function () { return chunkUR5HPMNF_cjs.tryGenerateUuid; }
76
92
  });
77
- Object.defineProperty(exports, "isNodeKey", {
93
+ Object.defineProperty(exports, "tryHash", {
78
94
  enumerable: true,
79
- get: function () { return chunkSBXDW4MY_cjs.isNodeKey; }
95
+ get: function () { return chunkUR5HPMNF_cjs.tryHash; }
80
96
  });
81
- Object.defineProperty(exports, "isWebApiKey", {
97
+ Object.defineProperty(exports, "tryHashPassword", {
82
98
  enumerable: true,
83
- get: function () { return chunkSBXDW4MY_cjs.isWebApiKey; }
99
+ get: function () { return chunkUR5HPMNF_cjs.tryHashPassword; }
100
+ });
101
+ Object.defineProperty(exports, "verifyPassword", {
102
+ enumerable: true,
103
+ get: function () { return chunkUR5HPMNF_cjs.verifyPassword; }
104
+ });
105
+ Object.defineProperty(exports, "webKit", {
106
+ enumerable: true,
107
+ get: function () { return chunkDZLEO2JD_cjs.kit_exports; }
108
+ });
109
+ Object.defineProperty(exports, "ENCRYPTED_REGEX", {
110
+ enumerable: true,
111
+ get: function () { return chunkZIVTPFKN_cjs.ENCRYPTED_REGEX; }
112
+ });
113
+ Object.defineProperty(exports, "isSecretKey", {
114
+ enumerable: true,
115
+ get: function () { return chunkZIVTPFKN_cjs.isSecretKey; }
116
+ });
117
+ Object.defineProperty(exports, "matchPattern", {
118
+ enumerable: true,
119
+ get: function () { return chunkZIVTPFKN_cjs.matchPattern; }
84
120
  });
85
121
  Object.defineProperty(exports, "parseToObj", {
86
122
  enumerable: true,
87
- get: function () { return chunkSBXDW4MY_cjs.parseToObj; }
123
+ get: function () { return chunkZIVTPFKN_cjs.parseToObj; }
88
124
  });
89
125
  Object.defineProperty(exports, "stringifyObj", {
90
126
  enumerable: true,
91
- get: function () { return chunkSBXDW4MY_cjs.stringifyObj; }
127
+ get: function () { return chunkZIVTPFKN_cjs.stringifyObj; }
128
+ });
129
+ Object.defineProperty(exports, "tryParseToObj", {
130
+ enumerable: true,
131
+ get: function () { return chunkZIVTPFKN_cjs.tryParseToObj; }
132
+ });
133
+ Object.defineProperty(exports, "tryStringifyObj", {
134
+ enumerable: true,
135
+ get: function () { return chunkZIVTPFKN_cjs.tryStringifyObj; }
92
136
  });
93
137
  //# sourceMappingURL=index.cjs.map
94
138
  //# sourceMappingURL=index.cjs.map
package/dist/index.d.cts CHANGED
@@ -1,24 +1,5 @@
1
- export { E as ENCRYPTION_REGEX, N as NODE_ALGORITHM, e as NodeKey, W as WEB_API_ALGORITHM, f as WebApiKey, i as isInEncryptionFormat, a as isInNodeEncryptionFormat, b as isInWebApiEncryptionFormat, c as isNodeKey, d as isWebApiKey, p as parseToObj, s as stringifyObj } from './utils-Bryp07ny.cjs';
2
- import { createSecretKey, decode, decrypt, decryptObj, encode, encrypt, encryptObj, generateUuid, hash } from './node.cjs';
3
- import { createSecretKey as createSecretKey$1, decode as decode$1, decrypt as decrypt$1, decryptObj as decryptObj$1, encode as encode$1, encrypt as encrypt$1, encryptObj as encryptObj$1, generateUuid as generateUuid$1, hash as hash$1 } from './web-api.cjs';
1
+ export { E as ENCRYPTED_REGEX, b as EncodingFormat, S as SecretKey, i as isSecretKey, m as matchPattern, p as parseToObj, s as stringifyObj, t as tryParseToObj, a as tryStringifyObj } from './validate-TRx4DDtg.cjs';
2
+ export { u as convertBytesToStr, x as convertFormat, r as convertStrToBytes, c as createSecretKey, f as decrypt, l as decryptObj, e as encrypt, i as encryptObj, g as generateUuid, n as hash, p as hashPassword, k as nodeKit, s as tryConvertBytesToStr, w as tryConvertFormat, q as tryConvertStrToBytes, a as tryCreateSecretKey, d as tryDecrypt, j as tryDecryptObj, b as tryEncrypt, h as tryEncryptObj, t as tryGenerateUuid, m as tryHash, o as tryHashPassword, v as verifyPassword } from './export-oVEmcDLI.cjs';
3
+ export { k as webKit } from './export-C2vQXrZa.cjs';
4
4
  import 'node:crypto';
5
5
  import 'node:buffer';
6
-
7
- declare const _export$1_createSecretKey: typeof createSecretKey;
8
- declare const _export$1_decode: typeof decode;
9
- declare const _export$1_decrypt: typeof decrypt;
10
- declare const _export$1_decryptObj: typeof decryptObj;
11
- declare const _export$1_encode: typeof encode;
12
- declare const _export$1_encrypt: typeof encrypt;
13
- declare const _export$1_encryptObj: typeof encryptObj;
14
- declare const _export$1_generateUuid: typeof generateUuid;
15
- declare const _export$1_hash: typeof hash;
16
- declare namespace _export$1 {
17
- export { _export$1_createSecretKey as createSecretKey, _export$1_decode as decode, _export$1_decrypt as decrypt, _export$1_decryptObj as decryptObj, _export$1_encode as encode, _export$1_encrypt as encrypt, _export$1_encryptObj as encryptObj, _export$1_generateUuid as generateUuid, _export$1_hash as hash };
18
- }
19
-
20
- declare namespace _export {
21
- export { createSecretKey$1 as createSecretKey, decode$1 as decode, decrypt$1 as decrypt, decryptObj$1 as decryptObj, encode$1 as encode, encrypt$1 as encrypt, encryptObj$1 as encryptObj, generateUuid$1 as generateUuid, hash$1 as hash };
22
- }
23
-
24
- export { createSecretKey, decode, decrypt, decryptObj, encode, encrypt, encryptObj, generateUuid, hash, _export$1 as nodeKit, _export as webApiKit };
package/dist/index.d.ts CHANGED
@@ -1,24 +1,5 @@
1
- export { E as ENCRYPTION_REGEX, N as NODE_ALGORITHM, e as NodeKey, W as WEB_API_ALGORITHM, f as WebApiKey, i as isInEncryptionFormat, a as isInNodeEncryptionFormat, b as isInWebApiEncryptionFormat, c as isNodeKey, d as isWebApiKey, p as parseToObj, s as stringifyObj } from './utils-Bryp07ny.js';
2
- import { createSecretKey, decode, decrypt, decryptObj, encode, encrypt, encryptObj, generateUuid, hash } from './node.js';
3
- import { createSecretKey as createSecretKey$1, decode as decode$1, decrypt as decrypt$1, decryptObj as decryptObj$1, encode as encode$1, encrypt as encrypt$1, encryptObj as encryptObj$1, generateUuid as generateUuid$1, hash as hash$1 } from './web-api.js';
1
+ export { E as ENCRYPTED_REGEX, b as EncodingFormat, S as SecretKey, i as isSecretKey, m as matchPattern, p as parseToObj, s as stringifyObj, t as tryParseToObj, a as tryStringifyObj } from './validate-TRx4DDtg.js';
2
+ export { u as convertBytesToStr, x as convertFormat, r as convertStrToBytes, c as createSecretKey, f as decrypt, l as decryptObj, e as encrypt, i as encryptObj, g as generateUuid, n as hash, p as hashPassword, k as nodeKit, s as tryConvertBytesToStr, w as tryConvertFormat, q as tryConvertStrToBytes, a as tryCreateSecretKey, d as tryDecrypt, j as tryDecryptObj, b as tryEncrypt, h as tryEncryptObj, t as tryGenerateUuid, m as tryHash, o as tryHashPassword, v as verifyPassword } from './export-DEWwhS-S.js';
3
+ export { k as webKit } from './export-DzNR1ht3.js';
4
4
  import 'node:crypto';
5
5
  import 'node:buffer';
6
-
7
- declare const _export$1_createSecretKey: typeof createSecretKey;
8
- declare const _export$1_decode: typeof decode;
9
- declare const _export$1_decrypt: typeof decrypt;
10
- declare const _export$1_decryptObj: typeof decryptObj;
11
- declare const _export$1_encode: typeof encode;
12
- declare const _export$1_encrypt: typeof encrypt;
13
- declare const _export$1_encryptObj: typeof encryptObj;
14
- declare const _export$1_generateUuid: typeof generateUuid;
15
- declare const _export$1_hash: typeof hash;
16
- declare namespace _export$1 {
17
- export { _export$1_createSecretKey as createSecretKey, _export$1_decode as decode, _export$1_decrypt as decrypt, _export$1_decryptObj as decryptObj, _export$1_encode as encode, _export$1_encrypt as encrypt, _export$1_encryptObj as encryptObj, _export$1_generateUuid as generateUuid, _export$1_hash as hash };
18
- }
19
-
20
- declare namespace _export {
21
- export { createSecretKey$1 as createSecretKey, decode$1 as decode, decrypt$1 as decrypt, decryptObj$1 as decryptObj, encode$1 as encode, encrypt$1 as encrypt, encryptObj$1 as encryptObj, generateUuid$1 as generateUuid, hash$1 as hash };
22
- }
23
-
24
- export { createSecretKey, decode, decrypt, decryptObj, encode, encrypt, encryptObj, generateUuid, hash, _export$1 as nodeKit, _export as webApiKit };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- export { createSecretKey, decode, decrypt, decryptObj, encode, encrypt, encryptObj, generateUuid, hash, export_exports as nodeKit } from './chunk-DC4WFPHL.js';
2
- export { export_exports as webApiKit } from './chunk-NGVIYM6K.js';
3
- export { ENCRYPTION_REGEX, NODE_ALGORITHM, WEB_API_ALGORITHM, isInEncryptionFormat, isInNodeEncryptionFormat, isInWebApiEncryptionFormat, isNodeKey, isWebApiKey, parseToObj, stringifyObj } from './chunk-THMEBIZB.js';
1
+ export { convertBytesToStr, convertFormat, convertStrToBytes, createSecretKey, decrypt, decryptObj, encrypt, encryptObj, generateUuid, hash, hashPassword, kit_exports as nodeKit, tryConvertBytesToStr, tryConvertFormat, tryConvertStrToBytes, tryCreateSecretKey, tryDecrypt, tryDecryptObj, tryEncrypt, tryEncryptObj, tryGenerateUuid, tryHash, tryHashPassword, verifyPassword } from './chunk-I25C3WUZ.js';
2
+ export { kit_exports as webKit } from './chunk-SRGSVNQ2.js';
3
+ export { ENCRYPTED_REGEX, isSecretKey, matchPattern, parseToObj, stringifyObj, tryParseToObj, tryStringifyObj } from './chunk-6HNTSQAP.js';
4
4
  //# sourceMappingURL=index.js.map
5
5
  //# sourceMappingURL=index.js.map
package/dist/node.cjs CHANGED
@@ -1,73 +1,129 @@
1
1
  'use strict';
2
2
 
3
- var chunkXTA6TKBQ_cjs = require('./chunk-XTA6TKBQ.cjs');
4
- var chunkSBXDW4MY_cjs = require('./chunk-SBXDW4MY.cjs');
3
+ var chunkUR5HPMNF_cjs = require('./chunk-UR5HPMNF.cjs');
4
+ var chunkZIVTPFKN_cjs = require('./chunk-ZIVTPFKN.cjs');
5
5
 
6
6
 
7
7
 
8
- Object.defineProperty(exports, "createSecretKey", {
8
+ Object.defineProperty(exports, "convertBytesToStr", {
9
9
  enumerable: true,
10
- get: function () { return chunkXTA6TKBQ_cjs.createSecretKey; }
10
+ get: function () { return chunkUR5HPMNF_cjs.convertBytesToStr; }
11
11
  });
12
- Object.defineProperty(exports, "decode", {
12
+ Object.defineProperty(exports, "convertFormat", {
13
13
  enumerable: true,
14
- get: function () { return chunkXTA6TKBQ_cjs.decode; }
14
+ get: function () { return chunkUR5HPMNF_cjs.convertFormat; }
15
15
  });
16
- Object.defineProperty(exports, "decrypt", {
16
+ Object.defineProperty(exports, "convertStrToBytes", {
17
17
  enumerable: true,
18
- get: function () { return chunkXTA6TKBQ_cjs.decrypt; }
18
+ get: function () { return chunkUR5HPMNF_cjs.convertStrToBytes; }
19
19
  });
20
- Object.defineProperty(exports, "decryptObj", {
20
+ Object.defineProperty(exports, "createSecretKey", {
21
21
  enumerable: true,
22
- get: function () { return chunkXTA6TKBQ_cjs.decryptObj; }
22
+ get: function () { return chunkUR5HPMNF_cjs.createSecretKey; }
23
23
  });
24
- Object.defineProperty(exports, "encode", {
24
+ Object.defineProperty(exports, "decrypt", {
25
25
  enumerable: true,
26
- get: function () { return chunkXTA6TKBQ_cjs.encode; }
26
+ get: function () { return chunkUR5HPMNF_cjs.decrypt; }
27
+ });
28
+ Object.defineProperty(exports, "decryptObj", {
29
+ enumerable: true,
30
+ get: function () { return chunkUR5HPMNF_cjs.decryptObj; }
27
31
  });
28
32
  Object.defineProperty(exports, "encrypt", {
29
33
  enumerable: true,
30
- get: function () { return chunkXTA6TKBQ_cjs.encrypt; }
34
+ get: function () { return chunkUR5HPMNF_cjs.encrypt; }
31
35
  });
32
36
  Object.defineProperty(exports, "encryptObj", {
33
37
  enumerable: true,
34
- get: function () { return chunkXTA6TKBQ_cjs.encryptObj; }
38
+ get: function () { return chunkUR5HPMNF_cjs.encryptObj; }
35
39
  });
36
40
  Object.defineProperty(exports, "generateUuid", {
37
41
  enumerable: true,
38
- get: function () { return chunkXTA6TKBQ_cjs.generateUuid; }
42
+ get: function () { return chunkUR5HPMNF_cjs.generateUuid; }
39
43
  });
40
44
  Object.defineProperty(exports, "hash", {
41
45
  enumerable: true,
42
- get: function () { return chunkXTA6TKBQ_cjs.hash; }
46
+ get: function () { return chunkUR5HPMNF_cjs.hash; }
47
+ });
48
+ Object.defineProperty(exports, "hashPassword", {
49
+ enumerable: true,
50
+ get: function () { return chunkUR5HPMNF_cjs.hashPassword; }
51
+ });
52
+ Object.defineProperty(exports, "tryConvertBytesToStr", {
53
+ enumerable: true,
54
+ get: function () { return chunkUR5HPMNF_cjs.tryConvertBytesToStr; }
55
+ });
56
+ Object.defineProperty(exports, "tryConvertFormat", {
57
+ enumerable: true,
58
+ get: function () { return chunkUR5HPMNF_cjs.tryConvertFormat; }
59
+ });
60
+ Object.defineProperty(exports, "tryConvertStrToBytes", {
61
+ enumerable: true,
62
+ get: function () { return chunkUR5HPMNF_cjs.tryConvertStrToBytes; }
63
+ });
64
+ Object.defineProperty(exports, "tryCreateSecretKey", {
65
+ enumerable: true,
66
+ get: function () { return chunkUR5HPMNF_cjs.tryCreateSecretKey; }
67
+ });
68
+ Object.defineProperty(exports, "tryDecrypt", {
69
+ enumerable: true,
70
+ get: function () { return chunkUR5HPMNF_cjs.tryDecrypt; }
71
+ });
72
+ Object.defineProperty(exports, "tryDecryptObj", {
73
+ enumerable: true,
74
+ get: function () { return chunkUR5HPMNF_cjs.tryDecryptObj; }
75
+ });
76
+ Object.defineProperty(exports, "tryEncrypt", {
77
+ enumerable: true,
78
+ get: function () { return chunkUR5HPMNF_cjs.tryEncrypt; }
79
+ });
80
+ Object.defineProperty(exports, "tryEncryptObj", {
81
+ enumerable: true,
82
+ get: function () { return chunkUR5HPMNF_cjs.tryEncryptObj; }
43
83
  });
44
- Object.defineProperty(exports, "ENCRYPTION_REGEX", {
84
+ Object.defineProperty(exports, "tryGenerateUuid", {
45
85
  enumerable: true,
46
- get: function () { return chunkSBXDW4MY_cjs.ENCRYPTION_REGEX; }
86
+ get: function () { return chunkUR5HPMNF_cjs.tryGenerateUuid; }
47
87
  });
48
- Object.defineProperty(exports, "NODE_ALGORITHM", {
88
+ Object.defineProperty(exports, "tryHash", {
49
89
  enumerable: true,
50
- get: function () { return chunkSBXDW4MY_cjs.NODE_ALGORITHM; }
90
+ get: function () { return chunkUR5HPMNF_cjs.tryHash; }
51
91
  });
52
- Object.defineProperty(exports, "isInEncryptionFormat", {
92
+ Object.defineProperty(exports, "tryHashPassword", {
53
93
  enumerable: true,
54
- get: function () { return chunkSBXDW4MY_cjs.isInEncryptionFormat; }
94
+ get: function () { return chunkUR5HPMNF_cjs.tryHashPassword; }
55
95
  });
56
- Object.defineProperty(exports, "isInNodeEncryptionFormat", {
96
+ Object.defineProperty(exports, "verifyPassword", {
57
97
  enumerable: true,
58
- get: function () { return chunkSBXDW4MY_cjs.isInNodeEncryptionFormat; }
98
+ get: function () { return chunkUR5HPMNF_cjs.verifyPassword; }
59
99
  });
60
- Object.defineProperty(exports, "isNodeKey", {
100
+ Object.defineProperty(exports, "ENCRYPTED_REGEX", {
61
101
  enumerable: true,
62
- get: function () { return chunkSBXDW4MY_cjs.isNodeKey; }
102
+ get: function () { return chunkZIVTPFKN_cjs.ENCRYPTED_REGEX; }
103
+ });
104
+ Object.defineProperty(exports, "isSecretKey", {
105
+ enumerable: true,
106
+ get: function () { return chunkZIVTPFKN_cjs.isSecretKey; }
107
+ });
108
+ Object.defineProperty(exports, "matchPattern", {
109
+ enumerable: true,
110
+ get: function () { return chunkZIVTPFKN_cjs.matchPattern; }
63
111
  });
64
112
  Object.defineProperty(exports, "parseToObj", {
65
113
  enumerable: true,
66
- get: function () { return chunkSBXDW4MY_cjs.parseToObj; }
114
+ get: function () { return chunkZIVTPFKN_cjs.parseToObj; }
67
115
  });
68
116
  Object.defineProperty(exports, "stringifyObj", {
69
117
  enumerable: true,
70
- get: function () { return chunkSBXDW4MY_cjs.stringifyObj; }
118
+ get: function () { return chunkZIVTPFKN_cjs.stringifyObj; }
119
+ });
120
+ Object.defineProperty(exports, "tryParseToObj", {
121
+ enumerable: true,
122
+ get: function () { return chunkZIVTPFKN_cjs.tryParseToObj; }
123
+ });
124
+ Object.defineProperty(exports, "tryStringifyObj", {
125
+ enumerable: true,
126
+ get: function () { return chunkZIVTPFKN_cjs.tryStringifyObj; }
71
127
  });
72
128
  //# sourceMappingURL=node.cjs.map
73
129
  //# sourceMappingURL=node.cjs.map
package/dist/node.d.cts CHANGED
@@ -1,23 +1,4 @@
1
- import { g as EncodingFormat, R as Result, e as NodeKey } from './utils-Bryp07ny.cjs';
2
- export { E as ENCRYPTION_REGEX, N as NODE_ALGORITHM, i as isInEncryptionFormat, a as isInNodeEncryptionFormat, c as isNodeKey, p as parseToObj, s as stringifyObj } from './utils-Bryp07ny.cjs';
3
- import { Buffer } from 'node:buffer';
1
+ export { E as ENCRYPTED_REGEX, S as SecretKey, i as isSecretKey, m as matchPattern, p as parseToObj, s as stringifyObj, t as tryParseToObj, a as tryStringifyObj } from './validate-TRx4DDtg.cjs';
2
+ export { u as convertBytesToStr, x as convertFormat, r as convertStrToBytes, c as createSecretKey, f as decrypt, l as decryptObj, e as encrypt, i as encryptObj, g as generateUuid, n as hash, p as hashPassword, s as tryConvertBytesToStr, w as tryConvertFormat, q as tryConvertStrToBytes, a as tryCreateSecretKey, d as tryDecrypt, j as tryDecryptObj, b as tryEncrypt, h as tryEncryptObj, t as tryGenerateUuid, m as tryHash, o as tryHashPassword, v as verifyPassword } from './export-oVEmcDLI.cjs';
4
3
  import 'node:crypto';
5
-
6
- declare function encode(data: string, format?: EncodingFormat): Result<{
7
- bytes: Buffer;
8
- }>;
9
- declare function decode(data: Buffer, format?: EncodingFormat): Result<string>;
10
-
11
- declare function generateUuid(): Result<string>;
12
- declare function hash(data: string): Result<string>;
13
- declare function createSecretKey(key: string | NodeKey): Result<{
14
- secretKey: NodeKey;
15
- }>;
16
- declare function encrypt(data: string, secretKey: NodeKey): Result<string>;
17
- declare function decrypt(encrypted: string, secretKey: NodeKey): Result<string>;
18
- declare function encryptObj(data: Record<string, unknown>, secretKey: NodeKey): Result<string>;
19
- declare function decryptObj(encrypted: string, secretKey: NodeKey): Result<{
20
- result: Record<string, unknown>;
21
- }>;
22
-
23
- export { NodeKey, createSecretKey, decode, decrypt, decryptObj, encode, encrypt, encryptObj, generateUuid, hash };
4
+ import 'node:buffer';
package/dist/node.d.ts CHANGED
@@ -1,23 +1,4 @@
1
- import { g as EncodingFormat, R as Result, e as NodeKey } from './utils-Bryp07ny.js';
2
- export { E as ENCRYPTION_REGEX, N as NODE_ALGORITHM, i as isInEncryptionFormat, a as isInNodeEncryptionFormat, c as isNodeKey, p as parseToObj, s as stringifyObj } from './utils-Bryp07ny.js';
3
- import { Buffer } from 'node:buffer';
1
+ export { E as ENCRYPTED_REGEX, S as SecretKey, i as isSecretKey, m as matchPattern, p as parseToObj, s as stringifyObj, t as tryParseToObj, a as tryStringifyObj } from './validate-TRx4DDtg.js';
2
+ export { u as convertBytesToStr, x as convertFormat, r as convertStrToBytes, c as createSecretKey, f as decrypt, l as decryptObj, e as encrypt, i as encryptObj, g as generateUuid, n as hash, p as hashPassword, s as tryConvertBytesToStr, w as tryConvertFormat, q as tryConvertStrToBytes, a as tryCreateSecretKey, d as tryDecrypt, j as tryDecryptObj, b as tryEncrypt, h as tryEncryptObj, t as tryGenerateUuid, m as tryHash, o as tryHashPassword, v as verifyPassword } from './export-DEWwhS-S.js';
4
3
  import 'node:crypto';
5
-
6
- declare function encode(data: string, format?: EncodingFormat): Result<{
7
- bytes: Buffer;
8
- }>;
9
- declare function decode(data: Buffer, format?: EncodingFormat): Result<string>;
10
-
11
- declare function generateUuid(): Result<string>;
12
- declare function hash(data: string): Result<string>;
13
- declare function createSecretKey(key: string | NodeKey): Result<{
14
- secretKey: NodeKey;
15
- }>;
16
- declare function encrypt(data: string, secretKey: NodeKey): Result<string>;
17
- declare function decrypt(encrypted: string, secretKey: NodeKey): Result<string>;
18
- declare function encryptObj(data: Record<string, unknown>, secretKey: NodeKey): Result<string>;
19
- declare function decryptObj(encrypted: string, secretKey: NodeKey): Result<{
20
- result: Record<string, unknown>;
21
- }>;
22
-
23
- export { NodeKey, createSecretKey, decode, decrypt, decryptObj, encode, encrypt, encryptObj, generateUuid, hash };
4
+ import 'node:buffer';
package/dist/node.js CHANGED
@@ -1,4 +1,4 @@
1
- export { createSecretKey, decode, decrypt, decryptObj, encode, encrypt, encryptObj, generateUuid, hash } from './chunk-DC4WFPHL.js';
2
- export { ENCRYPTION_REGEX, NODE_ALGORITHM, isInEncryptionFormat, isInNodeEncryptionFormat, isNodeKey, parseToObj, stringifyObj } from './chunk-THMEBIZB.js';
1
+ export { convertBytesToStr, convertFormat, convertStrToBytes, createSecretKey, decrypt, decryptObj, encrypt, encryptObj, generateUuid, hash, hashPassword, tryConvertBytesToStr, tryConvertFormat, tryConvertStrToBytes, tryCreateSecretKey, tryDecrypt, tryDecryptObj, tryEncrypt, tryEncryptObj, tryGenerateUuid, tryHash, tryHashPassword, verifyPassword } from './chunk-I25C3WUZ.js';
2
+ export { ENCRYPTED_REGEX, isSecretKey, matchPattern, parseToObj, stringifyObj, tryParseToObj, tryStringifyObj } from './chunk-6HNTSQAP.js';
3
3
  //# sourceMappingURL=node.js.map
4
4
  //# sourceMappingURL=node.js.map
@@ -0,0 +1,123 @@
1
+ import nodeCrypto, { webcrypto } from 'node:crypto';
2
+
3
+ interface ResultErr {
4
+ readonly message: string;
5
+ readonly description: string;
6
+ }
7
+ type Result<T, E = ResultErr> = T extends object ? ({
8
+ readonly [K in keyof T]: T[K];
9
+ } & {
10
+ readonly success: true;
11
+ readonly error?: undefined;
12
+ }) | ({
13
+ readonly [K in keyof T]?: undefined;
14
+ } & {
15
+ readonly success: false;
16
+ readonly error: E;
17
+ }) : {
18
+ readonly success: true;
19
+ readonly result: T;
20
+ readonly error?: undefined;
21
+ } | {
22
+ readonly success: false;
23
+ readonly error: E;
24
+ readonly result?: undefined;
25
+ };
26
+
27
+ /**
28
+ * Stringify an object.
29
+ *
30
+ * @param obj - The object to stringify.
31
+ * @returns An JSON string.
32
+ * @throws {Error} If the object cannot be stringified.
33
+ */
34
+ declare function stringifyObj<T extends object = Record<string, unknown>>(obj: T): string;
35
+ /**
36
+ * Stringify an object.
37
+ *
38
+ * @param obj - The object to stringify.
39
+ * @returns A Result containing the JSON string or an error.
40
+ */
41
+ declare function tryStringifyObj<T extends object = Record<string, unknown>>(obj: T): Result<string>;
42
+ /**
43
+ * Parse a string to an object.
44
+ *
45
+ * @param str - The JSON string to parse.
46
+ * @returns A Result containing the parsed object or an error.
47
+ */
48
+ declare function tryParseToObj<T extends object = Record<string, unknown>>(str: string): Result<{
49
+ result: T;
50
+ }>;
51
+ /**
52
+ * Parse a string to an object.
53
+ *
54
+ * @param str - The JSON string to parse.
55
+ * @returns A parsed object.
56
+ * @throws {Error} If the string cannot be parsed or is not a valid object.
57
+ */
58
+ declare function parseToObj<T extends object = Record<string, unknown>>(str: string): T;
59
+
60
+ declare const ENCODING_FORMATS: readonly ["base64", "base64url", "hex", "utf8", "latin1"];
61
+ declare const DIGEST_ALGORITHMS: Readonly<{
62
+ readonly sha256: {
63
+ readonly node: "sha256";
64
+ readonly web: "SHA-256";
65
+ };
66
+ readonly sha384: {
67
+ readonly node: "sha384";
68
+ readonly web: "SHA-384";
69
+ };
70
+ readonly sha512: {
71
+ readonly node: "sha512";
72
+ readonly web: "SHA-512";
73
+ };
74
+ }>;
75
+ declare const ENCRYPTION_ALGORITHMS: Readonly<{
76
+ readonly aes256gcm: {
77
+ readonly name: "aes256gcm";
78
+ readonly keyBytes: 32;
79
+ readonly ivLength: 12;
80
+ readonly node: "aes-256-gcm";
81
+ readonly web: "AES-GCM";
82
+ };
83
+ readonly aes192gcm: {
84
+ readonly name: "aes192gcm";
85
+ readonly keyBytes: 24;
86
+ readonly ivLength: 12;
87
+ readonly node: "aes-192-gcm";
88
+ readonly web: "AES-GCM";
89
+ };
90
+ readonly aes128gcm: {
91
+ readonly name: "aes128gcm";
92
+ readonly keyBytes: 16;
93
+ readonly ivLength: 12;
94
+ readonly node: "aes-128-gcm";
95
+ readonly web: "AES-GCM";
96
+ };
97
+ }>;
98
+
99
+ declare const __brand: unique symbol;
100
+ type Brand<T> = {
101
+ readonly [__brand]: T;
102
+ };
103
+ /** Secret Key Type */
104
+ type SecretKey<Platform extends 'web' | 'node'> = {
105
+ readonly platform: Platform;
106
+ readonly digest: keyof typeof DIGEST_ALGORITHMS;
107
+ readonly algo: (typeof ENCRYPTION_ALGORITHMS)[keyof typeof ENCRYPTION_ALGORITHMS];
108
+ readonly key: Platform extends 'web' ? webcrypto.CryptoKey : nodeCrypto.KeyObject;
109
+ } & Brand<`secretKey-${Platform}`>;
110
+ /** Supported encoding formats */
111
+ type EncodingFormat = (typeof ENCODING_FORMATS)[number];
112
+
113
+ declare function isSecretKey<Platform extends 'node' | 'web'>(x: unknown, platform: Platform): x is SecretKey<Platform>;
114
+ /** Regular expressions for encrypted data patterns */
115
+ declare const ENCRYPTED_REGEX: Readonly<{
116
+ general: RegExp;
117
+ node: RegExp;
118
+ web: RegExp;
119
+ }>;
120
+ /** Checks if the input string matches the specified encrypted data pattern. */
121
+ declare function matchPattern(data: string, format: 'general' | 'node' | 'web'): boolean;
122
+
123
+ export { DIGEST_ALGORITHMS as D, ENCRYPTED_REGEX as E, type Result as R, type SecretKey as S, tryStringifyObj as a, type EncodingFormat as b, ENCRYPTION_ALGORITHMS as c, isSecretKey as i, matchPattern as m, parseToObj as p, stringifyObj as s, tryParseToObj as t };