cipher-kit 2.0.0-beta.1 → 2.0.0-beta.2
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/chunk-3XGARINH.cjs +480 -0
- package/dist/chunk-3XGARINH.cjs.map +1 -0
- package/dist/{chunk-I25C3WUZ.js → chunk-AEQNI5EZ.js} +167 -98
- package/dist/chunk-AEQNI5EZ.js.map +1 -0
- package/dist/{chunk-6HNTSQAP.js → chunk-LOJKJJX5.js} +4 -7
- package/dist/chunk-LOJKJJX5.js.map +1 -0
- package/dist/{chunk-ZIVTPFKN.cjs → chunk-RXXVBCWL.cjs} +4 -8
- package/dist/chunk-RXXVBCWL.cjs.map +1 -0
- package/dist/{chunk-SRGSVNQ2.js → chunk-SUGN4VDZ.js} +169 -96
- package/dist/chunk-SUGN4VDZ.js.map +1 -0
- package/dist/chunk-WIZT7AYM.cjs +584 -0
- package/dist/chunk-WIZT7AYM.cjs.map +1 -0
- package/dist/{export-oVEmcDLI.d.cts → export-Bq9tslUU.d.ts} +30 -42
- package/dist/{export-C2vQXrZa.d.cts → export-C0WDJZUy.d.ts} +30 -42
- package/dist/{export-DzNR1ht3.d.ts → export-LPOfeH2z.d.cts} +30 -42
- package/dist/{export-DEWwhS-S.d.ts → export-RD2Af4CJ.d.cts} +30 -42
- package/dist/index.cjs +12 -104
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/node.cjs +34 -34
- package/dist/node.d.cts +2 -2
- package/dist/node.d.ts +2 -2
- package/dist/node.js +2 -2
- package/dist/{validate-TRx4DDtg.d.cts → validate-CS4PFmY1.d.cts} +39 -3
- package/dist/{validate-TRx4DDtg.d.ts → validate-CS4PFmY1.d.ts} +39 -3
- package/dist/web-api.cjs +34 -34
- package/dist/web-api.d.cts +2 -2
- package/dist/web-api.d.ts +2 -2
- package/dist/web-api.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-6HNTSQAP.js.map +0 -1
- package/dist/chunk-DZLEO2JD.cjs +0 -511
- package/dist/chunk-DZLEO2JD.cjs.map +0 -1
- package/dist/chunk-I25C3WUZ.js.map +0 -1
- package/dist/chunk-SRGSVNQ2.js.map +0 -1
- package/dist/chunk-UR5HPMNF.cjs +0 -411
- package/dist/chunk-UR5HPMNF.cjs.map +0 -1
- package/dist/chunk-ZIVTPFKN.cjs.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { E as ENCRYPTED_REGEX, b as
|
|
2
|
-
export {
|
|
3
|
-
export { k as webKit } from './export-
|
|
1
|
+
export { C as CreateSecretKeyOptions, e as DecryptOptions, D as DigestAlgorithm, E as ENCRYPTED_REGEX, b as Encoding, d as EncryptOptions, c as EncryptionAlgorithm, H as HashOptions, f as HashPasswordOptions, S as SecretKey, V as VerifyPasswordOptions, i as isSecretKey, m as matchPattern, p as parseToObj, s as stringifyObj, t as tryParseToObj, a as tryStringifyObj } from './validate-CS4PFmY1.js';
|
|
2
|
+
export { k as nodeKit } from './export-Bq9tslUU.js';
|
|
3
|
+
export { k as webKit } from './export-C0WDJZUy.js';
|
|
4
4
|
import 'node:crypto';
|
|
5
5
|
import 'node:buffer';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { kit_exports as webKit } from './chunk-
|
|
3
|
-
export { ENCRYPTED_REGEX, isSecretKey, matchPattern, parseToObj, stringifyObj, tryParseToObj, tryStringifyObj } from './chunk-
|
|
1
|
+
export { kit_exports as nodeKit } from './chunk-AEQNI5EZ.js';
|
|
2
|
+
export { kit_exports as webKit } from './chunk-SUGN4VDZ.js';
|
|
3
|
+
export { ENCRYPTED_REGEX, isSecretKey, matchPattern, parseToObj, stringifyObj, tryParseToObj, tryStringifyObj } from './chunk-LOJKJJX5.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/dist/node.cjs
CHANGED
|
@@ -1,129 +1,129 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunk3XGARINH_cjs = require('./chunk-3XGARINH.cjs');
|
|
4
|
+
var chunkRXXVBCWL_cjs = require('./chunk-RXXVBCWL.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, "convertBytesToStr", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunk3XGARINH_cjs.convertBytesToStr; }
|
|
11
11
|
});
|
|
12
|
-
Object.defineProperty(exports, "
|
|
12
|
+
Object.defineProperty(exports, "convertEncoding", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunk3XGARINH_cjs.convertEncoding; }
|
|
15
15
|
});
|
|
16
16
|
Object.defineProperty(exports, "convertStrToBytes", {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunk3XGARINH_cjs.convertStrToBytes; }
|
|
19
19
|
});
|
|
20
20
|
Object.defineProperty(exports, "createSecretKey", {
|
|
21
21
|
enumerable: true,
|
|
22
|
-
get: function () { return
|
|
22
|
+
get: function () { return chunk3XGARINH_cjs.createSecretKey; }
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "decrypt", {
|
|
25
25
|
enumerable: true,
|
|
26
|
-
get: function () { return
|
|
26
|
+
get: function () { return chunk3XGARINH_cjs.decrypt; }
|
|
27
27
|
});
|
|
28
28
|
Object.defineProperty(exports, "decryptObj", {
|
|
29
29
|
enumerable: true,
|
|
30
|
-
get: function () { return
|
|
30
|
+
get: function () { return chunk3XGARINH_cjs.decryptObj; }
|
|
31
31
|
});
|
|
32
32
|
Object.defineProperty(exports, "encrypt", {
|
|
33
33
|
enumerable: true,
|
|
34
|
-
get: function () { return
|
|
34
|
+
get: function () { return chunk3XGARINH_cjs.encrypt; }
|
|
35
35
|
});
|
|
36
36
|
Object.defineProperty(exports, "encryptObj", {
|
|
37
37
|
enumerable: true,
|
|
38
|
-
get: function () { return
|
|
38
|
+
get: function () { return chunk3XGARINH_cjs.encryptObj; }
|
|
39
39
|
});
|
|
40
40
|
Object.defineProperty(exports, "generateUuid", {
|
|
41
41
|
enumerable: true,
|
|
42
|
-
get: function () { return
|
|
42
|
+
get: function () { return chunk3XGARINH_cjs.generateUuid; }
|
|
43
43
|
});
|
|
44
44
|
Object.defineProperty(exports, "hash", {
|
|
45
45
|
enumerable: true,
|
|
46
|
-
get: function () { return
|
|
46
|
+
get: function () { return chunk3XGARINH_cjs.hash; }
|
|
47
47
|
});
|
|
48
48
|
Object.defineProperty(exports, "hashPassword", {
|
|
49
49
|
enumerable: true,
|
|
50
|
-
get: function () { return
|
|
50
|
+
get: function () { return chunk3XGARINH_cjs.hashPassword; }
|
|
51
51
|
});
|
|
52
52
|
Object.defineProperty(exports, "tryConvertBytesToStr", {
|
|
53
53
|
enumerable: true,
|
|
54
|
-
get: function () { return
|
|
54
|
+
get: function () { return chunk3XGARINH_cjs.tryConvertBytesToStr; }
|
|
55
55
|
});
|
|
56
|
-
Object.defineProperty(exports, "
|
|
56
|
+
Object.defineProperty(exports, "tryConvertEncoding", {
|
|
57
57
|
enumerable: true,
|
|
58
|
-
get: function () { return
|
|
58
|
+
get: function () { return chunk3XGARINH_cjs.tryConvertEncoding; }
|
|
59
59
|
});
|
|
60
60
|
Object.defineProperty(exports, "tryConvertStrToBytes", {
|
|
61
61
|
enumerable: true,
|
|
62
|
-
get: function () { return
|
|
62
|
+
get: function () { return chunk3XGARINH_cjs.tryConvertStrToBytes; }
|
|
63
63
|
});
|
|
64
64
|
Object.defineProperty(exports, "tryCreateSecretKey", {
|
|
65
65
|
enumerable: true,
|
|
66
|
-
get: function () { return
|
|
66
|
+
get: function () { return chunk3XGARINH_cjs.tryCreateSecretKey; }
|
|
67
67
|
});
|
|
68
68
|
Object.defineProperty(exports, "tryDecrypt", {
|
|
69
69
|
enumerable: true,
|
|
70
|
-
get: function () { return
|
|
70
|
+
get: function () { return chunk3XGARINH_cjs.tryDecrypt; }
|
|
71
71
|
});
|
|
72
72
|
Object.defineProperty(exports, "tryDecryptObj", {
|
|
73
73
|
enumerable: true,
|
|
74
|
-
get: function () { return
|
|
74
|
+
get: function () { return chunk3XGARINH_cjs.tryDecryptObj; }
|
|
75
75
|
});
|
|
76
76
|
Object.defineProperty(exports, "tryEncrypt", {
|
|
77
77
|
enumerable: true,
|
|
78
|
-
get: function () { return
|
|
78
|
+
get: function () { return chunk3XGARINH_cjs.tryEncrypt; }
|
|
79
79
|
});
|
|
80
80
|
Object.defineProperty(exports, "tryEncryptObj", {
|
|
81
81
|
enumerable: true,
|
|
82
|
-
get: function () { return
|
|
82
|
+
get: function () { return chunk3XGARINH_cjs.tryEncryptObj; }
|
|
83
83
|
});
|
|
84
84
|
Object.defineProperty(exports, "tryGenerateUuid", {
|
|
85
85
|
enumerable: true,
|
|
86
|
-
get: function () { return
|
|
86
|
+
get: function () { return chunk3XGARINH_cjs.tryGenerateUuid; }
|
|
87
87
|
});
|
|
88
88
|
Object.defineProperty(exports, "tryHash", {
|
|
89
89
|
enumerable: true,
|
|
90
|
-
get: function () { return
|
|
90
|
+
get: function () { return chunk3XGARINH_cjs.tryHash; }
|
|
91
91
|
});
|
|
92
92
|
Object.defineProperty(exports, "tryHashPassword", {
|
|
93
93
|
enumerable: true,
|
|
94
|
-
get: function () { return
|
|
94
|
+
get: function () { return chunk3XGARINH_cjs.tryHashPassword; }
|
|
95
95
|
});
|
|
96
96
|
Object.defineProperty(exports, "verifyPassword", {
|
|
97
97
|
enumerable: true,
|
|
98
|
-
get: function () { return
|
|
98
|
+
get: function () { return chunk3XGARINH_cjs.verifyPassword; }
|
|
99
99
|
});
|
|
100
100
|
Object.defineProperty(exports, "ENCRYPTED_REGEX", {
|
|
101
101
|
enumerable: true,
|
|
102
|
-
get: function () { return
|
|
102
|
+
get: function () { return chunkRXXVBCWL_cjs.ENCRYPTED_REGEX; }
|
|
103
103
|
});
|
|
104
104
|
Object.defineProperty(exports, "isSecretKey", {
|
|
105
105
|
enumerable: true,
|
|
106
|
-
get: function () { return
|
|
106
|
+
get: function () { return chunkRXXVBCWL_cjs.isSecretKey; }
|
|
107
107
|
});
|
|
108
108
|
Object.defineProperty(exports, "matchPattern", {
|
|
109
109
|
enumerable: true,
|
|
110
|
-
get: function () { return
|
|
110
|
+
get: function () { return chunkRXXVBCWL_cjs.matchPattern; }
|
|
111
111
|
});
|
|
112
112
|
Object.defineProperty(exports, "parseToObj", {
|
|
113
113
|
enumerable: true,
|
|
114
|
-
get: function () { return
|
|
114
|
+
get: function () { return chunkRXXVBCWL_cjs.parseToObj; }
|
|
115
115
|
});
|
|
116
116
|
Object.defineProperty(exports, "stringifyObj", {
|
|
117
117
|
enumerable: true,
|
|
118
|
-
get: function () { return
|
|
118
|
+
get: function () { return chunkRXXVBCWL_cjs.stringifyObj; }
|
|
119
119
|
});
|
|
120
120
|
Object.defineProperty(exports, "tryParseToObj", {
|
|
121
121
|
enumerable: true,
|
|
122
|
-
get: function () { return
|
|
122
|
+
get: function () { return chunkRXXVBCWL_cjs.tryParseToObj; }
|
|
123
123
|
});
|
|
124
124
|
Object.defineProperty(exports, "tryStringifyObj", {
|
|
125
125
|
enumerable: true,
|
|
126
|
-
get: function () { return
|
|
126
|
+
get: function () { return chunkRXXVBCWL_cjs.tryStringifyObj; }
|
|
127
127
|
});
|
|
128
128
|
//# sourceMappingURL=node.cjs.map
|
|
129
129
|
//# sourceMappingURL=node.cjs.map
|
package/dist/node.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
2
|
-
export { u as convertBytesToStr, x as
|
|
1
|
+
export { C as CreateSecretKeyOptions, e as DecryptOptions, D as DigestAlgorithm, E as ENCRYPTED_REGEX, b as Encoding, d as EncryptOptions, c as EncryptionAlgorithm, H as HashOptions, f as HashPasswordOptions, S as SecretKey, V as VerifyPasswordOptions, i as isSecretKey, m as matchPattern, p as parseToObj, s as stringifyObj, t as tryParseToObj, a as tryStringifyObj } from './validate-CS4PFmY1.cjs';
|
|
2
|
+
export { u as convertBytesToStr, x as convertEncoding, 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 tryConvertEncoding, 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-RD2Af4CJ.cjs';
|
|
3
3
|
import 'node:crypto';
|
|
4
4
|
import 'node:buffer';
|
package/dist/node.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
2
|
-
export { u as convertBytesToStr, x as
|
|
1
|
+
export { C as CreateSecretKeyOptions, e as DecryptOptions, D as DigestAlgorithm, E as ENCRYPTED_REGEX, b as Encoding, d as EncryptOptions, c as EncryptionAlgorithm, H as HashOptions, f as HashPasswordOptions, S as SecretKey, V as VerifyPasswordOptions, i as isSecretKey, m as matchPattern, p as parseToObj, s as stringifyObj, t as tryParseToObj, a as tryStringifyObj } from './validate-CS4PFmY1.js';
|
|
2
|
+
export { u as convertBytesToStr, x as convertEncoding, 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 tryConvertEncoding, 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-Bq9tslUU.js';
|
|
3
3
|
import 'node:crypto';
|
|
4
4
|
import 'node:buffer';
|
package/dist/node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { convertBytesToStr,
|
|
2
|
-
export { ENCRYPTED_REGEX, isSecretKey, matchPattern, parseToObj, stringifyObj, tryParseToObj, tryStringifyObj } from './chunk-
|
|
1
|
+
export { convertBytesToStr, convertEncoding, convertStrToBytes, createSecretKey, decrypt, decryptObj, encrypt, encryptObj, generateUuid, hash, hashPassword, tryConvertBytesToStr, tryConvertEncoding, tryConvertStrToBytes, tryCreateSecretKey, tryDecrypt, tryDecryptObj, tryEncrypt, tryEncryptObj, tryGenerateUuid, tryHash, tryHashPassword, verifyPassword } from './chunk-AEQNI5EZ.js';
|
|
2
|
+
export { ENCRYPTED_REGEX, isSecretKey, matchPattern, parseToObj, stringifyObj, tryParseToObj, tryStringifyObj } from './chunk-LOJKJJX5.js';
|
|
3
3
|
//# sourceMappingURL=node.js.map
|
|
4
4
|
//# sourceMappingURL=node.js.map
|
|
@@ -57,7 +57,7 @@ declare function tryParseToObj<T extends object = Record<string, unknown>>(str:
|
|
|
57
57
|
*/
|
|
58
58
|
declare function parseToObj<T extends object = Record<string, unknown>>(str: string): T;
|
|
59
59
|
|
|
60
|
-
declare const
|
|
60
|
+
declare const ENCODINGS: readonly ["base64", "base64url", "hex", "utf8", "latin1"];
|
|
61
61
|
declare const DIGEST_ALGORITHMS: Readonly<{
|
|
62
62
|
readonly sha256: {
|
|
63
63
|
readonly node: "sha256";
|
|
@@ -108,7 +108,43 @@ type SecretKey<Platform extends 'web' | 'node'> = {
|
|
|
108
108
|
readonly key: Platform extends 'web' ? webcrypto.CryptoKey : nodeCrypto.KeyObject;
|
|
109
109
|
} & Brand<`secretKey-${Platform}`>;
|
|
110
110
|
/** Supported encoding formats */
|
|
111
|
-
type
|
|
111
|
+
type Encoding = (typeof ENCODINGS)[number];
|
|
112
|
+
/** Supported encryption algorithms */
|
|
113
|
+
type EncryptionAlgorithm = keyof typeof ENCRYPTION_ALGORITHMS;
|
|
114
|
+
/** Supported digest algorithms */
|
|
115
|
+
type DigestAlgorithm = keyof typeof DIGEST_ALGORITHMS;
|
|
116
|
+
interface CreateSecretKeyOptions {
|
|
117
|
+
algorithm?: EncryptionAlgorithm;
|
|
118
|
+
digest?: DigestAlgorithm;
|
|
119
|
+
salt?: string;
|
|
120
|
+
info?: string;
|
|
121
|
+
}
|
|
122
|
+
interface EncryptOptions {
|
|
123
|
+
inputEncoding?: Encoding;
|
|
124
|
+
outputEncoding?: Encoding;
|
|
125
|
+
}
|
|
126
|
+
interface DecryptOptions {
|
|
127
|
+
inputEncoding?: Encoding;
|
|
128
|
+
outputEncoding?: Encoding;
|
|
129
|
+
}
|
|
130
|
+
interface HashOptions {
|
|
131
|
+
digest?: DigestAlgorithm;
|
|
132
|
+
inputEncoding?: Encoding;
|
|
133
|
+
outputEncoding?: Encoding;
|
|
134
|
+
}
|
|
135
|
+
interface HashPasswordOptions {
|
|
136
|
+
digest?: DigestAlgorithm;
|
|
137
|
+
outputEncoding?: Encoding;
|
|
138
|
+
saltLength?: number;
|
|
139
|
+
iterations?: number;
|
|
140
|
+
keyLength?: number;
|
|
141
|
+
}
|
|
142
|
+
interface VerifyPasswordOptions {
|
|
143
|
+
digest?: DigestAlgorithm;
|
|
144
|
+
inputEncoding?: Encoding;
|
|
145
|
+
iterations?: number;
|
|
146
|
+
keyLength?: number;
|
|
147
|
+
}
|
|
112
148
|
|
|
113
149
|
declare function isSecretKey<Platform extends 'node' | 'web'>(x: unknown, platform: Platform): x is SecretKey<Platform>;
|
|
114
150
|
/** Regular expressions for encrypted data patterns */
|
|
@@ -120,4 +156,4 @@ declare const ENCRYPTED_REGEX: Readonly<{
|
|
|
120
156
|
/** Checks if the input string matches the specified encrypted data pattern. */
|
|
121
157
|
declare function matchPattern(data: string, format: 'general' | 'node' | 'web'): boolean;
|
|
122
158
|
|
|
123
|
-
export {
|
|
159
|
+
export { type CreateSecretKeyOptions as C, type DigestAlgorithm as D, ENCRYPTED_REGEX as E, type HashOptions as H, type Result as R, type SecretKey as S, type VerifyPasswordOptions as V, tryStringifyObj as a, type Encoding as b, type EncryptionAlgorithm as c, type EncryptOptions as d, type DecryptOptions as e, type HashPasswordOptions as f, isSecretKey as i, matchPattern as m, parseToObj as p, stringifyObj as s, tryParseToObj as t };
|
|
@@ -57,7 +57,7 @@ declare function tryParseToObj<T extends object = Record<string, unknown>>(str:
|
|
|
57
57
|
*/
|
|
58
58
|
declare function parseToObj<T extends object = Record<string, unknown>>(str: string): T;
|
|
59
59
|
|
|
60
|
-
declare const
|
|
60
|
+
declare const ENCODINGS: readonly ["base64", "base64url", "hex", "utf8", "latin1"];
|
|
61
61
|
declare const DIGEST_ALGORITHMS: Readonly<{
|
|
62
62
|
readonly sha256: {
|
|
63
63
|
readonly node: "sha256";
|
|
@@ -108,7 +108,43 @@ type SecretKey<Platform extends 'web' | 'node'> = {
|
|
|
108
108
|
readonly key: Platform extends 'web' ? webcrypto.CryptoKey : nodeCrypto.KeyObject;
|
|
109
109
|
} & Brand<`secretKey-${Platform}`>;
|
|
110
110
|
/** Supported encoding formats */
|
|
111
|
-
type
|
|
111
|
+
type Encoding = (typeof ENCODINGS)[number];
|
|
112
|
+
/** Supported encryption algorithms */
|
|
113
|
+
type EncryptionAlgorithm = keyof typeof ENCRYPTION_ALGORITHMS;
|
|
114
|
+
/** Supported digest algorithms */
|
|
115
|
+
type DigestAlgorithm = keyof typeof DIGEST_ALGORITHMS;
|
|
116
|
+
interface CreateSecretKeyOptions {
|
|
117
|
+
algorithm?: EncryptionAlgorithm;
|
|
118
|
+
digest?: DigestAlgorithm;
|
|
119
|
+
salt?: string;
|
|
120
|
+
info?: string;
|
|
121
|
+
}
|
|
122
|
+
interface EncryptOptions {
|
|
123
|
+
inputEncoding?: Encoding;
|
|
124
|
+
outputEncoding?: Encoding;
|
|
125
|
+
}
|
|
126
|
+
interface DecryptOptions {
|
|
127
|
+
inputEncoding?: Encoding;
|
|
128
|
+
outputEncoding?: Encoding;
|
|
129
|
+
}
|
|
130
|
+
interface HashOptions {
|
|
131
|
+
digest?: DigestAlgorithm;
|
|
132
|
+
inputEncoding?: Encoding;
|
|
133
|
+
outputEncoding?: Encoding;
|
|
134
|
+
}
|
|
135
|
+
interface HashPasswordOptions {
|
|
136
|
+
digest?: DigestAlgorithm;
|
|
137
|
+
outputEncoding?: Encoding;
|
|
138
|
+
saltLength?: number;
|
|
139
|
+
iterations?: number;
|
|
140
|
+
keyLength?: number;
|
|
141
|
+
}
|
|
142
|
+
interface VerifyPasswordOptions {
|
|
143
|
+
digest?: DigestAlgorithm;
|
|
144
|
+
inputEncoding?: Encoding;
|
|
145
|
+
iterations?: number;
|
|
146
|
+
keyLength?: number;
|
|
147
|
+
}
|
|
112
148
|
|
|
113
149
|
declare function isSecretKey<Platform extends 'node' | 'web'>(x: unknown, platform: Platform): x is SecretKey<Platform>;
|
|
114
150
|
/** Regular expressions for encrypted data patterns */
|
|
@@ -120,4 +156,4 @@ declare const ENCRYPTED_REGEX: Readonly<{
|
|
|
120
156
|
/** Checks if the input string matches the specified encrypted data pattern. */
|
|
121
157
|
declare function matchPattern(data: string, format: 'general' | 'node' | 'web'): boolean;
|
|
122
158
|
|
|
123
|
-
export {
|
|
159
|
+
export { type CreateSecretKeyOptions as C, type DigestAlgorithm as D, ENCRYPTED_REGEX as E, type HashOptions as H, type Result as R, type SecretKey as S, type VerifyPasswordOptions as V, tryStringifyObj as a, type Encoding as b, type EncryptionAlgorithm as c, type EncryptOptions as d, type DecryptOptions as e, type HashPasswordOptions as f, isSecretKey as i, matchPattern as m, parseToObj as p, stringifyObj as s, tryParseToObj as t };
|
package/dist/web-api.cjs
CHANGED
|
@@ -1,129 +1,129 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkWIZT7AYM_cjs = require('./chunk-WIZT7AYM.cjs');
|
|
4
|
+
var chunkRXXVBCWL_cjs = require('./chunk-RXXVBCWL.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, "convertBytesToStr", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunkWIZT7AYM_cjs.convertBytesToStr; }
|
|
11
11
|
});
|
|
12
|
-
Object.defineProperty(exports, "
|
|
12
|
+
Object.defineProperty(exports, "convertEncoding", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkWIZT7AYM_cjs.convertEncoding; }
|
|
15
15
|
});
|
|
16
16
|
Object.defineProperty(exports, "convertStrToBytes", {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunkWIZT7AYM_cjs.convertStrToBytes; }
|
|
19
19
|
});
|
|
20
20
|
Object.defineProperty(exports, "createSecretKey", {
|
|
21
21
|
enumerable: true,
|
|
22
|
-
get: function () { return
|
|
22
|
+
get: function () { return chunkWIZT7AYM_cjs.createSecretKey; }
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "decrypt", {
|
|
25
25
|
enumerable: true,
|
|
26
|
-
get: function () { return
|
|
26
|
+
get: function () { return chunkWIZT7AYM_cjs.decrypt; }
|
|
27
27
|
});
|
|
28
28
|
Object.defineProperty(exports, "decryptObj", {
|
|
29
29
|
enumerable: true,
|
|
30
|
-
get: function () { return
|
|
30
|
+
get: function () { return chunkWIZT7AYM_cjs.decryptObj; }
|
|
31
31
|
});
|
|
32
32
|
Object.defineProperty(exports, "encrypt", {
|
|
33
33
|
enumerable: true,
|
|
34
|
-
get: function () { return
|
|
34
|
+
get: function () { return chunkWIZT7AYM_cjs.encrypt; }
|
|
35
35
|
});
|
|
36
36
|
Object.defineProperty(exports, "encryptObj", {
|
|
37
37
|
enumerable: true,
|
|
38
|
-
get: function () { return
|
|
38
|
+
get: function () { return chunkWIZT7AYM_cjs.encryptObj; }
|
|
39
39
|
});
|
|
40
40
|
Object.defineProperty(exports, "generateUuid", {
|
|
41
41
|
enumerable: true,
|
|
42
|
-
get: function () { return
|
|
42
|
+
get: function () { return chunkWIZT7AYM_cjs.generateUuid; }
|
|
43
43
|
});
|
|
44
44
|
Object.defineProperty(exports, "hash", {
|
|
45
45
|
enumerable: true,
|
|
46
|
-
get: function () { return
|
|
46
|
+
get: function () { return chunkWIZT7AYM_cjs.hash; }
|
|
47
47
|
});
|
|
48
48
|
Object.defineProperty(exports, "hashPassword", {
|
|
49
49
|
enumerable: true,
|
|
50
|
-
get: function () { return
|
|
50
|
+
get: function () { return chunkWIZT7AYM_cjs.hashPassword; }
|
|
51
51
|
});
|
|
52
52
|
Object.defineProperty(exports, "tryConvertBytesToStr", {
|
|
53
53
|
enumerable: true,
|
|
54
|
-
get: function () { return
|
|
54
|
+
get: function () { return chunkWIZT7AYM_cjs.tryConvertBytesToStr; }
|
|
55
55
|
});
|
|
56
|
-
Object.defineProperty(exports, "
|
|
56
|
+
Object.defineProperty(exports, "tryConvertEncoding", {
|
|
57
57
|
enumerable: true,
|
|
58
|
-
get: function () { return
|
|
58
|
+
get: function () { return chunkWIZT7AYM_cjs.tryConvertEncoding; }
|
|
59
59
|
});
|
|
60
60
|
Object.defineProperty(exports, "tryConvertStrToBytes", {
|
|
61
61
|
enumerable: true,
|
|
62
|
-
get: function () { return
|
|
62
|
+
get: function () { return chunkWIZT7AYM_cjs.tryConvertStrToBytes; }
|
|
63
63
|
});
|
|
64
64
|
Object.defineProperty(exports, "tryCreateSecretKey", {
|
|
65
65
|
enumerable: true,
|
|
66
|
-
get: function () { return
|
|
66
|
+
get: function () { return chunkWIZT7AYM_cjs.tryCreateSecretKey; }
|
|
67
67
|
});
|
|
68
68
|
Object.defineProperty(exports, "tryDecrypt", {
|
|
69
69
|
enumerable: true,
|
|
70
|
-
get: function () { return
|
|
70
|
+
get: function () { return chunkWIZT7AYM_cjs.tryDecrypt; }
|
|
71
71
|
});
|
|
72
72
|
Object.defineProperty(exports, "tryDecryptObj", {
|
|
73
73
|
enumerable: true,
|
|
74
|
-
get: function () { return
|
|
74
|
+
get: function () { return chunkWIZT7AYM_cjs.tryDecryptObj; }
|
|
75
75
|
});
|
|
76
76
|
Object.defineProperty(exports, "tryEncrypt", {
|
|
77
77
|
enumerable: true,
|
|
78
|
-
get: function () { return
|
|
78
|
+
get: function () { return chunkWIZT7AYM_cjs.tryEncrypt; }
|
|
79
79
|
});
|
|
80
80
|
Object.defineProperty(exports, "tryEncryptObj", {
|
|
81
81
|
enumerable: true,
|
|
82
|
-
get: function () { return
|
|
82
|
+
get: function () { return chunkWIZT7AYM_cjs.tryEncryptObj; }
|
|
83
83
|
});
|
|
84
84
|
Object.defineProperty(exports, "tryGenerateUuid", {
|
|
85
85
|
enumerable: true,
|
|
86
|
-
get: function () { return
|
|
86
|
+
get: function () { return chunkWIZT7AYM_cjs.tryGenerateUuid; }
|
|
87
87
|
});
|
|
88
88
|
Object.defineProperty(exports, "tryHash", {
|
|
89
89
|
enumerable: true,
|
|
90
|
-
get: function () { return
|
|
90
|
+
get: function () { return chunkWIZT7AYM_cjs.tryHash; }
|
|
91
91
|
});
|
|
92
92
|
Object.defineProperty(exports, "tryHashPassword", {
|
|
93
93
|
enumerable: true,
|
|
94
|
-
get: function () { return
|
|
94
|
+
get: function () { return chunkWIZT7AYM_cjs.tryHashPassword; }
|
|
95
95
|
});
|
|
96
96
|
Object.defineProperty(exports, "verifyPassword", {
|
|
97
97
|
enumerable: true,
|
|
98
|
-
get: function () { return
|
|
98
|
+
get: function () { return chunkWIZT7AYM_cjs.verifyPassword; }
|
|
99
99
|
});
|
|
100
100
|
Object.defineProperty(exports, "ENCRYPTED_REGEX", {
|
|
101
101
|
enumerable: true,
|
|
102
|
-
get: function () { return
|
|
102
|
+
get: function () { return chunkRXXVBCWL_cjs.ENCRYPTED_REGEX; }
|
|
103
103
|
});
|
|
104
104
|
Object.defineProperty(exports, "isSecretKey", {
|
|
105
105
|
enumerable: true,
|
|
106
|
-
get: function () { return
|
|
106
|
+
get: function () { return chunkRXXVBCWL_cjs.isSecretKey; }
|
|
107
107
|
});
|
|
108
108
|
Object.defineProperty(exports, "matchPattern", {
|
|
109
109
|
enumerable: true,
|
|
110
|
-
get: function () { return
|
|
110
|
+
get: function () { return chunkRXXVBCWL_cjs.matchPattern; }
|
|
111
111
|
});
|
|
112
112
|
Object.defineProperty(exports, "parseToObj", {
|
|
113
113
|
enumerable: true,
|
|
114
|
-
get: function () { return
|
|
114
|
+
get: function () { return chunkRXXVBCWL_cjs.parseToObj; }
|
|
115
115
|
});
|
|
116
116
|
Object.defineProperty(exports, "stringifyObj", {
|
|
117
117
|
enumerable: true,
|
|
118
|
-
get: function () { return
|
|
118
|
+
get: function () { return chunkRXXVBCWL_cjs.stringifyObj; }
|
|
119
119
|
});
|
|
120
120
|
Object.defineProperty(exports, "tryParseToObj", {
|
|
121
121
|
enumerable: true,
|
|
122
|
-
get: function () { return
|
|
122
|
+
get: function () { return chunkRXXVBCWL_cjs.tryParseToObj; }
|
|
123
123
|
});
|
|
124
124
|
Object.defineProperty(exports, "tryStringifyObj", {
|
|
125
125
|
enumerable: true,
|
|
126
|
-
get: function () { return
|
|
126
|
+
get: function () { return chunkRXXVBCWL_cjs.tryStringifyObj; }
|
|
127
127
|
});
|
|
128
128
|
//# sourceMappingURL=web-api.cjs.map
|
|
129
129
|
//# sourceMappingURL=web-api.cjs.map
|
package/dist/web-api.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
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-
|
|
2
|
-
export { u as convertBytesToStr, x as
|
|
1
|
+
export { C as CreateSecretKeyOptions, e as DecryptOptions, D as DigestAlgorithm, E as ENCRYPTED_REGEX, b as Encoding, d as EncryptOptions, c as EncryptionAlgorithm, H as HashOptions, f as HashPasswordOptions, S as SecretKey, V as VerifyPasswordOptions, i as isSecretKey, m as matchPattern, p as parseToObj, s as stringifyObj, t as tryParseToObj, a as tryStringifyObj } from './validate-CS4PFmY1.cjs';
|
|
2
|
+
export { u as convertBytesToStr, x as convertEncoding, 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 tryConvertEncoding, 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-LPOfeH2z.cjs';
|
|
3
3
|
import 'node:crypto';
|
package/dist/web-api.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
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-
|
|
2
|
-
export { u as convertBytesToStr, x as
|
|
1
|
+
export { C as CreateSecretKeyOptions, e as DecryptOptions, D as DigestAlgorithm, E as ENCRYPTED_REGEX, b as Encoding, d as EncryptOptions, c as EncryptionAlgorithm, H as HashOptions, f as HashPasswordOptions, S as SecretKey, V as VerifyPasswordOptions, i as isSecretKey, m as matchPattern, p as parseToObj, s as stringifyObj, t as tryParseToObj, a as tryStringifyObj } from './validate-CS4PFmY1.js';
|
|
2
|
+
export { u as convertBytesToStr, x as convertEncoding, 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 tryConvertEncoding, 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-C0WDJZUy.js';
|
|
3
3
|
import 'node:crypto';
|
package/dist/web-api.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { convertBytesToStr,
|
|
2
|
-
export { ENCRYPTED_REGEX, isSecretKey, matchPattern, parseToObj, stringifyObj, tryParseToObj, tryStringifyObj } from './chunk-
|
|
1
|
+
export { convertBytesToStr, convertEncoding, convertStrToBytes, createSecretKey, decrypt, decryptObj, encrypt, encryptObj, generateUuid, hash, hashPassword, tryConvertBytesToStr, tryConvertEncoding, tryConvertStrToBytes, tryCreateSecretKey, tryDecrypt, tryDecryptObj, tryEncrypt, tryEncryptObj, tryGenerateUuid, tryHash, tryHashPassword, verifyPassword } from './chunk-SUGN4VDZ.js';
|
|
2
|
+
export { ENCRYPTED_REGEX, isSecretKey, matchPattern, parseToObj, stringifyObj, tryParseToObj, tryStringifyObj } from './chunk-LOJKJJX5.js';
|
|
3
3
|
//# sourceMappingURL=web-api.js.map
|
|
4
4
|
//# sourceMappingURL=web-api.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cipher-kit",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.2",
|
|
4
4
|
"description": "🔐 Secure, Lightweight, and Cross-Platform Encryption, Decryption, and Hashing for Web, Node.js, Deno, Bun, and Cloudflare Workers",
|
|
5
5
|
"homepage": "https://github.com/WolfieLeader/npm/tree/main/packages/cipher-kit#readme",
|
|
6
6
|
"repository": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/helpers/consts.ts","../src/helpers/validate.ts","../src/helpers/error.ts","../src/helpers/object.ts"],"names":[],"mappings":";;;;;;;;;AAAO,IAAM,gBAAA,GAAmB,OAAO,MAAA,CAAO,CAAC,UAAU,WAAA,EAAa,KAAA,EAAO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CAAA;AAC3C,EAAA,IAAI,OAAO,MAAM,IAAI,KAAA,CAAM,aAAA,CAAc,KAAK,CAAC,CAAA;AAC/C,EAAA,OAAO,MAAA;AACT;AAQO,SAAS,gBAA4D,GAAA,EAAwB;AAClG,EAAA,OAAO,cAAc,GAAG,CAAA;AAC1B;AAEO,SAAS,YAAwD,GAAA,EAAoC;AAC1G,EAAA,IAAI;AACF,IAAA,IAAI,CAAC,MAAA,CAAO,GAAG,CAAA,EAAG,OAAO,IAAA,CAAK,EAAE,GAAA,EAAK,wBAAA,EAA0B,IAAA,EAAM,6BAAA,EAA+B,CAAA;AACpG,IAAA,MAAM,GAAA,GAAM,IAAA,CAAK,KAAA,CAAM,GAAG,CAAA;AAE1B,IAAA,IAAI,CAAC,MAAA,CAAO,GAAG,CAAA,EAAG,OAAO,IAAA,CAAK,EAAE,GAAA,EAAK,gCAAA,EAAkC,IAAA,EAAM,mCAAA,EAAqC,CAAA;AAClH,IAAA,OAAO,GAAA,CAAI,EAAE,MAAA,EAAQ,GAAA,EAAU,CAAA;AAAA,EACjC,SAAS,KAAA,EAAO;AACd,IAAA,OAAO,IAAA,CAAK,EAAE,GAAA,EAAK,yBAAA,EAA2B,MAAM,SAAA,CAAU,KAAK,GAAG,CAAA;AAAA,EACxE;AACF;AAQO,SAAS,cAA0D,GAAA,EAAoC;AAC5G,EAAA,OAAO,YAAe,GAAG,CAAA;AAC3B;AASO,SAAS,WAAuD,GAAA,EAAgB;AACrF,EAAA,MAAM,EAAE,MAAA,EAAQ,KAAA,EAAM,GAAI,YAAe,GAAG,CAAA;AAC5C,EAAA,IAAI,OAAO,MAAM,IAAI,KAAA,CAAM,aAAA,CAAc,KAAK,CAAC,CAAA;AAC/C,EAAA,OAAO,MAAA;AACT","file":"chunk-6HNTSQAP.js","sourcesContent":["export const ENCODING_FORMATS = Object.freeze(['base64', 'base64url', 'hex', 'utf8', 'latin1'] as const);\r\n\r\nexport const DIGEST_ALGORITHMS = Object.freeze({\r\n sha256: { node: 'sha256', web: 'SHA-256' },\r\n sha384: { node: 'sha384', web: 'SHA-384' },\r\n sha512: { node: 'sha512', web: 'SHA-512' },\r\n} as const);\r\n\r\nexport const ENCRYPTION_ALGORITHMS = Object.freeze({\r\n aes256gcm: { name: 'aes256gcm', keyBytes: 32, ivLength: 12, node: 'aes-256-gcm', web: 'AES-GCM' },\r\n aes192gcm: { name: 'aes192gcm', keyBytes: 24, ivLength: 12, node: 'aes-192-gcm', web: 'AES-GCM' },\r\n aes128gcm: { name: 'aes128gcm', keyBytes: 16, ivLength: 12, node: 'aes-128-gcm', web: 'AES-GCM' },\r\n} as const);\r\n\r\nexport const PASSWORD_HASHING = Object.freeze({\r\n pbkdf2: { saltLength: 16, iterations: 320_000, keyLength: 64 },\r\n} as const);\r\n","import nodeCrypto from 'node:crypto';\r\nimport type { SecretKey } from '~/helpers/types';\r\nimport { DIGEST_ALGORITHMS, ENCRYPTION_ALGORITHMS } from './consts';\r\n\r\nexport function $isStr(x: unknown, min = 1): x is string {\r\n return x !== null && x !== undefined && typeof x === 'string' && x.trim().length >= min;\r\n}\r\n\r\nexport function $isObj(x: unknown): x is Record<string, unknown> {\r\n if (typeof x !== 'object' || x === null || x === undefined) return false;\r\n const proto = Object.getPrototypeOf(x);\r\n return proto === Object.prototype || proto === null;\r\n}\r\n\r\nexport function $isLooseObj(x: unknown): x is Record<string, unknown> {\r\n return typeof x === 'object' && x !== null && x !== undefined;\r\n}\r\n\r\nconst expectedKeys = new Set(['platform', 'digest', 'algo', 'key']);\r\nconst expectedAlgoKeys = new Set(['name', 'keyBytes', 'ivLength', 'node', 'web']);\r\n\r\nexport function isSecretKey<Platform extends 'node' | 'web'>(x: unknown, platform: Platform): x is SecretKey<Platform> {\r\n if (!$isLooseObj(x) || (platform !== 'node' && platform !== 'web') || x.platform !== platform) return false;\r\n\r\n const keys = Object.keys(x);\r\n if (keys.length !== expectedKeys.size) return false;\r\n for (const key of keys) if (!expectedKeys.has(key)) return false;\r\n for (const key of expectedKeys) if (!Object.hasOwn(x, key)) return false;\r\n\r\n if (typeof x.digest !== 'string' || !(x.digest in DIGEST_ALGORITHMS)) return false;\r\n if (!$isLooseObj(x.algo) || typeof x.algo.name !== 'string' || !(x.algo.name in ENCRYPTION_ALGORITHMS)) return false;\r\n\r\n const algoKeys = Object.keys(x.algo);\r\n if (algoKeys.length !== expectedAlgoKeys.size) return false;\r\n for (const key of algoKeys) if (!expectedAlgoKeys.has(key)) return false;\r\n for (const key of expectedAlgoKeys) if (!Object.hasOwn(x.algo, key)) return false;\r\n\r\n const algo = ENCRYPTION_ALGORITHMS[x.algo.name as keyof typeof ENCRYPTION_ALGORITHMS];\r\n if (\r\n x.algo.keyBytes !== algo.keyBytes ||\r\n x.algo.ivLength !== algo.ivLength ||\r\n x.algo.node !== algo.node ||\r\n x.algo.web !== algo.web\r\n ) {\r\n return false;\r\n }\r\n\r\n if (!$isLooseObj(x.key) || x.key.type !== 'secret') return false;\r\n\r\n if (platform === 'node') {\r\n if (\r\n !(x.key instanceof nodeCrypto.KeyObject) ||\r\n (typeof x.key.symmetricKeySize === 'number' && x.key.symmetricKeySize !== algo.keyBytes)\r\n ) {\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n if (\r\n !$isLooseObj(x.key.algorithm) ||\r\n x.key.algorithm.name !== algo.web ||\r\n (typeof x.key.algorithm.length === 'number' && x.key.algorithm.length !== algo.keyBytes * 8) ||\r\n typeof x.key.extractable !== 'boolean' ||\r\n !Array.isArray(x.key.usages) ||\r\n x.key.usages.length !== 2 ||\r\n !(x.key.usages.includes('encrypt') && x.key.usages.includes('decrypt'))\r\n ) {\r\n return false;\r\n }\r\n return true;\r\n}\r\n\r\n/** Regular expressions for encrypted data patterns */\r\nexport const ENCRYPTED_REGEX = Object.freeze({\r\n general: /^(?:[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+(?:\\.[A-Za-z0-9_-]+)?\\.)$/,\r\n node: /^([A-Za-z0-9_-]+)\\.([A-Za-z0-9_-]+)\\.([A-Za-z0-9_-]+)\\.$/,\r\n web: /^([A-Za-z0-9_-]+)\\.([A-Za-z0-9_-]+)\\.$/,\r\n});\r\n\r\n/** Checks if the input string matches the specified encrypted data pattern. */\r\nexport function matchPattern(data: string, format: 'general' | 'node' | 'web'): boolean {\r\n if (typeof data !== 'string') return false;\r\n if (!(format in ENCRYPTED_REGEX)) throw new Error(`Unknown format: ${format}`);\r\n return ENCRYPTED_REGEX[format].test(data);\r\n}\r\n","import { $isObj } from './validate';\r\n\r\nexport interface ResultErr {\r\n readonly message: string;\r\n readonly description: string;\r\n}\r\n\r\nexport type Result<T, E = ResultErr> = T extends object\r\n ?\r\n | ({ readonly [K in keyof T]: T[K] } & { readonly success: true; readonly error?: undefined })\r\n | ({ readonly [K in keyof T]?: undefined } & { readonly success: false; readonly error: E })\r\n :\r\n | { readonly success: true; readonly result: T; readonly error?: undefined }\r\n | { readonly success: false; readonly error: E; readonly result?: undefined };\r\n\r\nexport function $ok<T>(result?: T): Result<T> {\r\n if ($isObj(result)) return { success: true, ...(result as T & object) } as Result<T>;\r\n return { success: true, result } as Result<T>;\r\n}\r\n\r\nexport function $err(err: { msg: string; desc: string }): Result<never, ResultErr>;\r\nexport function $err(err: ResultErr): Result<never, ResultErr>;\r\nexport function $err(err: { msg: string; desc: string } | ResultErr): Result<never, ResultErr> {\r\n return {\r\n success: false,\r\n error: {\r\n message: 'msg' in err ? err.msg : err.message,\r\n description: 'desc' in err ? err.desc : err.description,\r\n },\r\n } as Result<never, ResultErr>;\r\n}\r\n\r\nexport function $fmtError(error: unknown): string {\r\n if (error instanceof Error) return error.message;\r\n if (typeof error === 'string') return error;\r\n return String(error);\r\n}\r\n\r\nexport function $fmtResultErr(err: ResultErr): string {\r\n return `${err.message} - ${err.description}`;\r\n}\r\n","import { $err, $fmtError, $fmtResultErr, $ok, type Result } from './error';\r\nimport { $isObj, $isStr } from './validate';\r\n\r\nexport function $stringifyObj<T extends object = Record<string, unknown>>(obj: T): Result<string> {\r\n try {\r\n if (!$isObj(obj)) return $err({ msg: 'Invalid object', desc: 'Input is not a plain object' });\r\n return $ok(JSON.stringify(obj));\r\n } catch (error) {\r\n return $err({ msg: 'Utility: Stringify error', desc: $fmtError(error) });\r\n }\r\n}\r\n\r\n/**\r\n * Stringify an object.\r\n *\r\n * @param obj - The object to stringify.\r\n * @returns An JSON string.\r\n * @throws {Error} If the object cannot be stringified.\r\n */\r\nexport function stringifyObj<T extends object = Record<string, unknown>>(obj: T): string {\r\n const { result, error } = $stringifyObj(obj);\r\n if (error) throw new Error($fmtResultErr(error));\r\n return result;\r\n}\r\n\r\n/**\r\n * Stringify an object.\r\n *\r\n * @param obj - The object to stringify.\r\n * @returns A Result containing the JSON string or an error.\r\n */\r\nexport function tryStringifyObj<T extends object = Record<string, unknown>>(obj: T): Result<string> {\r\n return $stringifyObj(obj);\r\n}\r\n\r\nexport function $parseToObj<T extends object = Record<string, unknown>>(str: string): Result<{ result: T }> {\r\n try {\r\n if (!$isStr(str)) return $err({ msg: 'Utility: Invalid input', desc: 'Input is not a valid string' });\r\n const obj = JSON.parse(str);\r\n\r\n if (!$isObj(obj)) return $err({ msg: 'Utility: Invalid object format', desc: 'Parsed data is not a plain object' });\r\n return $ok({ result: obj as T });\r\n } catch (error) {\r\n return $err({ msg: 'Utility: Invalid format', desc: $fmtError(error) });\r\n }\r\n}\r\n\r\n/**\r\n * Parse a string to an object.\r\n *\r\n * @param str - The JSON string to parse.\r\n * @returns A Result containing the parsed object or an error.\r\n */\r\nexport function tryParseToObj<T extends object = Record<string, unknown>>(str: string): Result<{ result: T }> {\r\n return $parseToObj<T>(str);\r\n}\r\n\r\n/**\r\n * Parse a string to an object.\r\n *\r\n * @param str - The JSON string to parse.\r\n * @returns A parsed object.\r\n * @throws {Error} If the string cannot be parsed or is not a valid object.\r\n */\r\nexport function parseToObj<T extends object = Record<string, unknown>>(str: string): T {\r\n const { result, error } = $parseToObj<T>(str);\r\n if (error) throw new Error($fmtResultErr(error));\r\n return result;\r\n}\r\n"]}
|