cipher-kit 2.0.0 → 2.1.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 +25 -27
- package/dist/{chunk-3UX5MZ2P.cjs → chunk-BHG5RSUV.cjs} +22 -20
- package/dist/chunk-BHG5RSUV.cjs.map +1 -0
- package/dist/{chunk-4MFF6V3R.js → chunk-CRTOKS3Q.js} +76 -41
- package/dist/chunk-CRTOKS3Q.js.map +1 -0
- package/dist/{chunk-N2EW2FDZ.cjs → chunk-HMTHK2IY.cjs} +183 -148
- package/dist/chunk-HMTHK2IY.cjs.map +1 -0
- package/dist/{chunk-ACFPMIXO.js → chunk-RAEBT46G.js} +75 -40
- package/dist/chunk-RAEBT46G.js.map +1 -0
- package/dist/{chunk-FKSYSPJR.js → chunk-RUTGDMVR.js} +21 -20
- package/dist/chunk-RUTGDMVR.js.map +1 -0
- package/dist/{chunk-CVCDAHDW.cjs → chunk-UVEMRK5F.cjs} +189 -154
- package/dist/chunk-UVEMRK5F.cjs.map +1 -0
- package/dist/{export-BMvZq46v.d.ts → export-5hmOiU0J.d.cts} +194 -20
- package/dist/{export-CQNsJFh_.d.cts → export-BF9wW56f.d.ts} +194 -20
- package/dist/{export-llM6c7Do.d.ts → export-DVERZibl.d.cts} +194 -20
- package/dist/{export-55tHE0Bw.d.cts → export-w8sBcKXw.d.ts} +194 -20
- package/dist/index.cjs +12 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/node.cjs +33 -33
- package/dist/node.d.cts +2 -2
- package/dist/node.d.ts +2 -2
- package/dist/node.js +2 -2
- package/dist/{validate-EHuJC5QQ.d.cts → validate-B3uHoP8n.d.cts} +26 -38
- package/dist/{validate-EHuJC5QQ.d.ts → validate-B3uHoP8n.d.ts} +26 -38
- package/dist/web-api.cjs +33 -33
- 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 +6 -7
- package/dist/chunk-3UX5MZ2P.cjs.map +0 -1
- package/dist/chunk-4MFF6V3R.js.map +0 -1
- package/dist/chunk-ACFPMIXO.js.map +0 -1
- package/dist/chunk-CVCDAHDW.cjs.map +0 -1
- package/dist/chunk-FKSYSPJR.js.map +0 -1
- package/dist/chunk-N2EW2FDZ.cjs.map +0 -1
package/dist/node.cjs
CHANGED
|
@@ -1,129 +1,129 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkHMTHK2IY_cjs = require('./chunk-HMTHK2IY.cjs');
|
|
4
|
+
var chunkBHG5RSUV_cjs = require('./chunk-BHG5RSUV.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 chunkHMTHK2IY_cjs.convertBytesToStr; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "convertEncoding", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkHMTHK2IY_cjs.convertEncoding; }
|
|
15
15
|
});
|
|
16
16
|
Object.defineProperty(exports, "convertStrToBytes", {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunkHMTHK2IY_cjs.convertStrToBytes; }
|
|
19
19
|
});
|
|
20
20
|
Object.defineProperty(exports, "createSecretKey", {
|
|
21
21
|
enumerable: true,
|
|
22
|
-
get: function () { return
|
|
22
|
+
get: function () { return chunkHMTHK2IY_cjs.createSecretKey; }
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "decrypt", {
|
|
25
25
|
enumerable: true,
|
|
26
|
-
get: function () { return
|
|
26
|
+
get: function () { return chunkHMTHK2IY_cjs.decrypt; }
|
|
27
27
|
});
|
|
28
28
|
Object.defineProperty(exports, "decryptObj", {
|
|
29
29
|
enumerable: true,
|
|
30
|
-
get: function () { return
|
|
30
|
+
get: function () { return chunkHMTHK2IY_cjs.decryptObj; }
|
|
31
31
|
});
|
|
32
32
|
Object.defineProperty(exports, "encrypt", {
|
|
33
33
|
enumerable: true,
|
|
34
|
-
get: function () { return
|
|
34
|
+
get: function () { return chunkHMTHK2IY_cjs.encrypt; }
|
|
35
35
|
});
|
|
36
36
|
Object.defineProperty(exports, "encryptObj", {
|
|
37
37
|
enumerable: true,
|
|
38
|
-
get: function () { return
|
|
38
|
+
get: function () { return chunkHMTHK2IY_cjs.encryptObj; }
|
|
39
39
|
});
|
|
40
40
|
Object.defineProperty(exports, "generateUuid", {
|
|
41
41
|
enumerable: true,
|
|
42
|
-
get: function () { return
|
|
42
|
+
get: function () { return chunkHMTHK2IY_cjs.generateUuid; }
|
|
43
43
|
});
|
|
44
44
|
Object.defineProperty(exports, "hash", {
|
|
45
45
|
enumerable: true,
|
|
46
|
-
get: function () { return
|
|
46
|
+
get: function () { return chunkHMTHK2IY_cjs.hash; }
|
|
47
47
|
});
|
|
48
48
|
Object.defineProperty(exports, "hashPassword", {
|
|
49
49
|
enumerable: true,
|
|
50
|
-
get: function () { return
|
|
50
|
+
get: function () { return chunkHMTHK2IY_cjs.hashPassword; }
|
|
51
51
|
});
|
|
52
52
|
Object.defineProperty(exports, "isNodeSecretKey", {
|
|
53
53
|
enumerable: true,
|
|
54
|
-
get: function () { return
|
|
54
|
+
get: function () { return chunkHMTHK2IY_cjs.isNodeSecretKey; }
|
|
55
55
|
});
|
|
56
56
|
Object.defineProperty(exports, "tryConvertBytesToStr", {
|
|
57
57
|
enumerable: true,
|
|
58
|
-
get: function () { return
|
|
58
|
+
get: function () { return chunkHMTHK2IY_cjs.tryConvertBytesToStr; }
|
|
59
59
|
});
|
|
60
60
|
Object.defineProperty(exports, "tryConvertEncoding", {
|
|
61
61
|
enumerable: true,
|
|
62
|
-
get: function () { return
|
|
62
|
+
get: function () { return chunkHMTHK2IY_cjs.tryConvertEncoding; }
|
|
63
63
|
});
|
|
64
64
|
Object.defineProperty(exports, "tryConvertStrToBytes", {
|
|
65
65
|
enumerable: true,
|
|
66
|
-
get: function () { return
|
|
66
|
+
get: function () { return chunkHMTHK2IY_cjs.tryConvertStrToBytes; }
|
|
67
67
|
});
|
|
68
68
|
Object.defineProperty(exports, "tryCreateSecretKey", {
|
|
69
69
|
enumerable: true,
|
|
70
|
-
get: function () { return
|
|
70
|
+
get: function () { return chunkHMTHK2IY_cjs.tryCreateSecretKey; }
|
|
71
71
|
});
|
|
72
72
|
Object.defineProperty(exports, "tryDecrypt", {
|
|
73
73
|
enumerable: true,
|
|
74
|
-
get: function () { return
|
|
74
|
+
get: function () { return chunkHMTHK2IY_cjs.tryDecrypt; }
|
|
75
75
|
});
|
|
76
76
|
Object.defineProperty(exports, "tryDecryptObj", {
|
|
77
77
|
enumerable: true,
|
|
78
|
-
get: function () { return
|
|
78
|
+
get: function () { return chunkHMTHK2IY_cjs.tryDecryptObj; }
|
|
79
79
|
});
|
|
80
80
|
Object.defineProperty(exports, "tryEncrypt", {
|
|
81
81
|
enumerable: true,
|
|
82
|
-
get: function () { return
|
|
82
|
+
get: function () { return chunkHMTHK2IY_cjs.tryEncrypt; }
|
|
83
83
|
});
|
|
84
84
|
Object.defineProperty(exports, "tryEncryptObj", {
|
|
85
85
|
enumerable: true,
|
|
86
|
-
get: function () { return
|
|
86
|
+
get: function () { return chunkHMTHK2IY_cjs.tryEncryptObj; }
|
|
87
87
|
});
|
|
88
88
|
Object.defineProperty(exports, "tryGenerateUuid", {
|
|
89
89
|
enumerable: true,
|
|
90
|
-
get: function () { return
|
|
90
|
+
get: function () { return chunkHMTHK2IY_cjs.tryGenerateUuid; }
|
|
91
91
|
});
|
|
92
92
|
Object.defineProperty(exports, "tryHash", {
|
|
93
93
|
enumerable: true,
|
|
94
|
-
get: function () { return
|
|
94
|
+
get: function () { return chunkHMTHK2IY_cjs.tryHash; }
|
|
95
95
|
});
|
|
96
96
|
Object.defineProperty(exports, "tryHashPassword", {
|
|
97
97
|
enumerable: true,
|
|
98
|
-
get: function () { return
|
|
98
|
+
get: function () { return chunkHMTHK2IY_cjs.tryHashPassword; }
|
|
99
99
|
});
|
|
100
100
|
Object.defineProperty(exports, "verifyPassword", {
|
|
101
101
|
enumerable: true,
|
|
102
|
-
get: function () { return
|
|
102
|
+
get: function () { return chunkHMTHK2IY_cjs.verifyPassword; }
|
|
103
103
|
});
|
|
104
104
|
Object.defineProperty(exports, "ENCRYPTED_REGEX", {
|
|
105
105
|
enumerable: true,
|
|
106
|
-
get: function () { return
|
|
106
|
+
get: function () { return chunkBHG5RSUV_cjs.ENCRYPTED_REGEX; }
|
|
107
107
|
});
|
|
108
|
-
Object.defineProperty(exports, "
|
|
108
|
+
Object.defineProperty(exports, "matchEncryptedPattern", {
|
|
109
109
|
enumerable: true,
|
|
110
|
-
get: function () { return
|
|
110
|
+
get: function () { return chunkBHG5RSUV_cjs.matchEncryptedPattern; }
|
|
111
111
|
});
|
|
112
112
|
Object.defineProperty(exports, "parseToObj", {
|
|
113
113
|
enumerable: true,
|
|
114
|
-
get: function () { return
|
|
114
|
+
get: function () { return chunkBHG5RSUV_cjs.parseToObj; }
|
|
115
115
|
});
|
|
116
116
|
Object.defineProperty(exports, "stringifyObj", {
|
|
117
117
|
enumerable: true,
|
|
118
|
-
get: function () { return
|
|
118
|
+
get: function () { return chunkBHG5RSUV_cjs.stringifyObj; }
|
|
119
119
|
});
|
|
120
120
|
Object.defineProperty(exports, "tryParseToObj", {
|
|
121
121
|
enumerable: true,
|
|
122
|
-
get: function () { return
|
|
122
|
+
get: function () { return chunkBHG5RSUV_cjs.tryParseToObj; }
|
|
123
123
|
});
|
|
124
124
|
Object.defineProperty(exports, "tryStringifyObj", {
|
|
125
125
|
enumerable: true,
|
|
126
|
-
get: function () { return
|
|
126
|
+
get: function () { return chunkBHG5RSUV_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 { C as CipherEncoding, d as CreateSecretKeyOptions, f as DecryptOptions, D as DigestAlgorithm, E as ENCRYPTED_REGEX, b as Encoding, e as EncryptOptions, c as EncryptionAlgorithm, H as HashOptions, g as HashPasswordOptions, S as SecretKey, V as VerifyPasswordOptions, m as
|
|
2
|
-
export { w as convertBytesToStr, y as convertEncoding, s as convertStrToBytes, c as createSecretKey, f as decrypt, l as decryptObj, e as encrypt, j as encryptObj, g as generateUuid, o as hash, q as hashPassword, i as isNodeSecretKey, u as tryConvertBytesToStr, x as tryConvertEncoding, r as tryConvertStrToBytes, a as tryCreateSecretKey, d as tryDecrypt, k as tryDecryptObj, b as tryEncrypt, h as tryEncryptObj, t as tryGenerateUuid, m as tryHash, p as tryHashPassword, v as verifyPassword } from './export-
|
|
1
|
+
export { C as CipherEncoding, d as CreateSecretKeyOptions, f as DecryptOptions, D as DigestAlgorithm, E as ENCRYPTED_REGEX, b as Encoding, e as EncryptOptions, c as EncryptionAlgorithm, H as HashOptions, g as HashPasswordOptions, S as SecretKey, V as VerifyPasswordOptions, m as matchEncryptedPattern, p as parseToObj, s as stringifyObj, t as tryParseToObj, a as tryStringifyObj } from './validate-B3uHoP8n.cjs';
|
|
2
|
+
export { w as convertBytesToStr, y as convertEncoding, s as convertStrToBytes, c as createSecretKey, f as decrypt, l as decryptObj, e as encrypt, j as encryptObj, g as generateUuid, o as hash, q as hashPassword, i as isNodeSecretKey, u as tryConvertBytesToStr, x as tryConvertEncoding, r as tryConvertStrToBytes, a as tryCreateSecretKey, d as tryDecrypt, k as tryDecryptObj, b as tryEncrypt, h as tryEncryptObj, t as tryGenerateUuid, m as tryHash, p as tryHashPassword, v as verifyPassword } from './export-5hmOiU0J.cjs';
|
|
3
3
|
import 'node:crypto';
|
|
4
4
|
import 'node:buffer';
|
package/dist/node.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { C as CipherEncoding, d as CreateSecretKeyOptions, f as DecryptOptions, D as DigestAlgorithm, E as ENCRYPTED_REGEX, b as Encoding, e as EncryptOptions, c as EncryptionAlgorithm, H as HashOptions, g as HashPasswordOptions, S as SecretKey, V as VerifyPasswordOptions, m as
|
|
2
|
-
export { w as convertBytesToStr, y as convertEncoding, s as convertStrToBytes, c as createSecretKey, f as decrypt, l as decryptObj, e as encrypt, j as encryptObj, g as generateUuid, o as hash, q as hashPassword, i as isNodeSecretKey, u as tryConvertBytesToStr, x as tryConvertEncoding, r as tryConvertStrToBytes, a as tryCreateSecretKey, d as tryDecrypt, k as tryDecryptObj, b as tryEncrypt, h as tryEncryptObj, t as tryGenerateUuid, m as tryHash, p as tryHashPassword, v as verifyPassword } from './export-
|
|
1
|
+
export { C as CipherEncoding, d as CreateSecretKeyOptions, f as DecryptOptions, D as DigestAlgorithm, E as ENCRYPTED_REGEX, b as Encoding, e as EncryptOptions, c as EncryptionAlgorithm, H as HashOptions, g as HashPasswordOptions, S as SecretKey, V as VerifyPasswordOptions, m as matchEncryptedPattern, p as parseToObj, s as stringifyObj, t as tryParseToObj, a as tryStringifyObj } from './validate-B3uHoP8n.js';
|
|
2
|
+
export { w as convertBytesToStr, y as convertEncoding, s as convertStrToBytes, c as createSecretKey, f as decrypt, l as decryptObj, e as encrypt, j as encryptObj, g as generateUuid, o as hash, q as hashPassword, i as isNodeSecretKey, u as tryConvertBytesToStr, x as tryConvertEncoding, r as tryConvertStrToBytes, a as tryCreateSecretKey, d as tryDecrypt, k as tryDecryptObj, b as tryEncrypt, h as tryEncryptObj, t as tryGenerateUuid, m as tryHash, p as tryHashPassword, v as verifyPassword } from './export-BF9wW56f.js';
|
|
3
3
|
import 'node:crypto';
|
|
4
4
|
import 'node:buffer';
|
package/dist/node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { convertBytesToStr, convertEncoding, convertStrToBytes, createSecretKey, decrypt, decryptObj, encrypt, encryptObj, generateUuid, hash, hashPassword, isNodeSecretKey, tryConvertBytesToStr, tryConvertEncoding, tryConvertStrToBytes, tryCreateSecretKey, tryDecrypt, tryDecryptObj, tryEncrypt, tryEncryptObj, tryGenerateUuid, tryHash, tryHashPassword, verifyPassword } from './chunk-
|
|
2
|
-
export { ENCRYPTED_REGEX,
|
|
1
|
+
export { convertBytesToStr, convertEncoding, convertStrToBytes, createSecretKey, decrypt, decryptObj, encrypt, encryptObj, generateUuid, hash, hashPassword, isNodeSecretKey, tryConvertBytesToStr, tryConvertEncoding, tryConvertStrToBytes, tryCreateSecretKey, tryDecrypt, tryDecryptObj, tryEncrypt, tryEncryptObj, tryGenerateUuid, tryHash, tryHashPassword, verifyPassword } from './chunk-RAEBT46G.js';
|
|
2
|
+
export { ENCRYPTED_REGEX, matchEncryptedPattern, parseToObj, stringifyObj, tryParseToObj, tryStringifyObj } from './chunk-RUTGDMVR.js';
|
|
3
3
|
//# sourceMappingURL=node.js.map
|
|
4
4
|
//# sourceMappingURL=node.js.map
|
|
@@ -152,11 +152,11 @@ interface CreateSecretKeyOptions {
|
|
|
152
152
|
* ### 🍼 Explain Like I'm Five
|
|
153
153
|
* After locking your message, how should we write the locked message down?
|
|
154
154
|
*
|
|
155
|
-
* - `
|
|
155
|
+
* - `outputEncoding`: output ciphertext encoding (`'base64' | 'base64url' | 'hex'`) (default: `'base64url'`)
|
|
156
156
|
*/
|
|
157
157
|
interface EncryptOptions {
|
|
158
158
|
/** Encoding format for the output ciphertext (default: `'base64url'`). */
|
|
159
|
-
|
|
159
|
+
outputEncoding?: CipherEncoding;
|
|
160
160
|
}
|
|
161
161
|
/**
|
|
162
162
|
* Options for decryption.
|
|
@@ -164,11 +164,11 @@ interface EncryptOptions {
|
|
|
164
164
|
* ### 🍼 Explain Like I'm Five
|
|
165
165
|
* To unlock the message, we must know how it was written down.
|
|
166
166
|
*
|
|
167
|
-
* - `
|
|
167
|
+
* - `inputEncoding`: input ciphertext encoding (`'base64' | 'base64url' | 'hex'`) (default: `'base64url'`)
|
|
168
168
|
*/
|
|
169
169
|
interface DecryptOptions {
|
|
170
170
|
/** Encoding format for the input ciphertext (default: `'base64url'`). */
|
|
171
|
-
|
|
171
|
+
inputEncoding?: CipherEncoding;
|
|
172
172
|
}
|
|
173
173
|
/**
|
|
174
174
|
* Options for hashing arbitrary data.
|
|
@@ -178,13 +178,13 @@ interface DecryptOptions {
|
|
|
178
178
|
* You can choose how to create the fingerprint (digest) and how to write it down (encoding).
|
|
179
179
|
*
|
|
180
180
|
* - `digest`: `'sha256' | 'sha384' | 'sha512'` (default: `'sha256'`)
|
|
181
|
-
* - `
|
|
181
|
+
* - `outputEncoding`: output ciphertext encoding for the hash (`'base64' | 'base64url' | 'hex'`; default: `'base64url'`)
|
|
182
182
|
*/
|
|
183
183
|
interface HashOptions {
|
|
184
184
|
/** Digest algorithm to use (default: `'sha256'`). */
|
|
185
185
|
digest?: DigestAlgorithm;
|
|
186
186
|
/** Encoding format for the output hash (default: `'base64url'`). */
|
|
187
|
-
|
|
187
|
+
outputEncoding?: CipherEncoding;
|
|
188
188
|
}
|
|
189
189
|
/**
|
|
190
190
|
* Options for password hashing (PBKDF2).
|
|
@@ -194,7 +194,7 @@ interface HashOptions {
|
|
|
194
194
|
* stirring many times (iterations), and making a long result (keyLength).
|
|
195
195
|
*
|
|
196
196
|
* - `digest`: `'sha256' | 'sha384' | 'sha512'` (default: `'sha512'`)
|
|
197
|
-
* - `
|
|
197
|
+
* - `outputEncoding`: output ciphertext encoding for the hash (`'base64' | 'base64url' | 'hex'`; default: `'base64url'`)
|
|
198
198
|
* - `saltLength`: size of the random salt in bytes (default: `16` bytes)
|
|
199
199
|
* - `iterations`: number of iterations (default: `320000`)
|
|
200
200
|
* - `keyLength`: length of the derived key in bytes (default: `64` bytes)
|
|
@@ -203,7 +203,7 @@ interface HashPasswordOptions {
|
|
|
203
203
|
/** Digest algorithm to use (default: `'sha512'`). */
|
|
204
204
|
digest?: DigestAlgorithm;
|
|
205
205
|
/** Encoding format for the output hash (default: `'base64url'`). */
|
|
206
|
-
|
|
206
|
+
outputEncoding?: CipherEncoding;
|
|
207
207
|
/** Length of the salt in bytes (default: `16` bytes, min: `8` bytes). */
|
|
208
208
|
saltLength?: number;
|
|
209
209
|
/** Number of iterations for key derivation (default: `320000`, min: `1000`). */
|
|
@@ -219,7 +219,7 @@ interface HashPasswordOptions {
|
|
|
219
219
|
* same size—so the new result matches the old one.
|
|
220
220
|
*
|
|
221
221
|
* - `digest`: `'sha256' | 'sha384' | 'sha512'` (default: `'sha512'`)
|
|
222
|
-
* - `
|
|
222
|
+
* - `inputEncoding`: input ciphertext encoding for the hash (`'base64' | 'base64url' | 'hex'`; default: `'base64url'`)
|
|
223
223
|
* - `iterations`: number of iterations (default: `320000`)
|
|
224
224
|
* - `keyLength`: length of the derived key in bytes (default: `64` bytes)
|
|
225
225
|
*/
|
|
@@ -227,7 +227,7 @@ interface VerifyPasswordOptions {
|
|
|
227
227
|
/** Digest algorithm to use (default: `'sha512'`). */
|
|
228
228
|
digest?: DigestAlgorithm;
|
|
229
229
|
/** Encoding format of the input hash (default: `'base64url'`). */
|
|
230
|
-
|
|
230
|
+
inputEncoding?: CipherEncoding;
|
|
231
231
|
/** Number of iterations for key derivation (default: `320000`). */
|
|
232
232
|
iterations?: number;
|
|
233
233
|
/** Length of the derived key in bytes (default: `64` bytes). */
|
|
@@ -250,12 +250,10 @@ interface VerifyPasswordOptions {
|
|
|
250
250
|
*
|
|
251
251
|
* @example
|
|
252
252
|
* ```ts
|
|
253
|
-
* const
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
257
|
-
* console.error(res.error.message, res.error.description);
|
|
258
|
-
* }
|
|
253
|
+
* const { result, error, success } = tryStringifyObj({ a: 1 });
|
|
254
|
+
*
|
|
255
|
+
* if (success) console.log(result); // "{\"a\":1}"
|
|
256
|
+
* else console.error(error); // { message: "...", description: "..." }
|
|
259
257
|
* ```
|
|
260
258
|
*/
|
|
261
259
|
declare function tryStringifyObj<T extends object = Record<string, unknown>>(obj: T): Result<string>;
|
|
@@ -276,11 +274,7 @@ declare function tryStringifyObj<T extends object = Record<string, unknown>>(obj
|
|
|
276
274
|
*
|
|
277
275
|
* @example
|
|
278
276
|
* ```ts
|
|
279
|
-
*
|
|
280
|
-
* const json = stringifyObj({ a: 1 }); // {"a":1}
|
|
281
|
-
* } catch (error: unknown) {
|
|
282
|
-
* console.error(error);
|
|
283
|
-
* }
|
|
277
|
+
* const json = stringifyObj({ a: 1 }); // "{\"a\":1}"
|
|
284
278
|
* ```
|
|
285
279
|
*/
|
|
286
280
|
declare function stringifyObj<T extends object = Record<string, unknown>>(obj: T): string;
|
|
@@ -298,12 +292,10 @@ declare function stringifyObj<T extends object = Record<string, unknown>>(obj: T
|
|
|
298
292
|
*
|
|
299
293
|
* @example
|
|
300
294
|
* ```ts
|
|
301
|
-
* const
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
* console.error(res.error.message, res.error.description);
|
|
306
|
-
* }
|
|
295
|
+
* const {result, error, success} = tryParseToObj<{ a: number }>('{"a":1}');
|
|
296
|
+
*
|
|
297
|
+
* if (success) console.log(result); // { a: 1 }
|
|
298
|
+
* else console.error(error) // { message: "...", description: "..." }
|
|
307
299
|
* ```
|
|
308
300
|
*/
|
|
309
301
|
declare function tryParseToObj<T extends object = Record<string, unknown>>(str: string): Result<{
|
|
@@ -324,11 +316,7 @@ declare function tryParseToObj<T extends object = Record<string, unknown>>(str:
|
|
|
324
316
|
*
|
|
325
317
|
* @example
|
|
326
318
|
* ```ts
|
|
327
|
-
*
|
|
328
|
-
* const obj = parseToObj<{ a: number }>('{"a":1}'); // obj.a === 1
|
|
329
|
-
* } catch (error: unknown) {
|
|
330
|
-
* console.error(error);
|
|
331
|
-
* }
|
|
319
|
+
* const obj = parseToObj<{ a: number }>('{"a":1}'); // obj.a === 1
|
|
332
320
|
* ```
|
|
333
321
|
*/
|
|
334
322
|
declare function parseToObj<T extends object = Record<string, unknown>>(str: string): T;
|
|
@@ -373,12 +361,12 @@ declare const ENCRYPTED_REGEX: Readonly<{
|
|
|
373
361
|
*
|
|
374
362
|
* @example
|
|
375
363
|
* ```ts
|
|
376
|
-
*
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
*
|
|
364
|
+
* matchEncryptedPattern("abc.def.ghi.", "node"); // true
|
|
365
|
+
* matchEncryptedPattern("abc.def.", "web"); // true
|
|
366
|
+
* matchEncryptedPattern("abc.def.", "node"); // false
|
|
367
|
+
* matchEncryptedPattern("abc.def.ghi.", "general"); // true
|
|
380
368
|
* ```
|
|
381
369
|
*/
|
|
382
|
-
declare function
|
|
370
|
+
declare function matchEncryptedPattern(data: string, format: "general" | "node" | "web"): boolean;
|
|
383
371
|
|
|
384
|
-
export { type CipherEncoding 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 CreateSecretKeyOptions as d, type EncryptOptions as e, type DecryptOptions as f, type HashPasswordOptions as g,
|
|
372
|
+
export { type CipherEncoding 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 CreateSecretKeyOptions as d, type EncryptOptions as e, type DecryptOptions as f, type HashPasswordOptions as g, matchEncryptedPattern as m, parseToObj as p, stringifyObj as s, tryParseToObj as t };
|
|
@@ -152,11 +152,11 @@ interface CreateSecretKeyOptions {
|
|
|
152
152
|
* ### 🍼 Explain Like I'm Five
|
|
153
153
|
* After locking your message, how should we write the locked message down?
|
|
154
154
|
*
|
|
155
|
-
* - `
|
|
155
|
+
* - `outputEncoding`: output ciphertext encoding (`'base64' | 'base64url' | 'hex'`) (default: `'base64url'`)
|
|
156
156
|
*/
|
|
157
157
|
interface EncryptOptions {
|
|
158
158
|
/** Encoding format for the output ciphertext (default: `'base64url'`). */
|
|
159
|
-
|
|
159
|
+
outputEncoding?: CipherEncoding;
|
|
160
160
|
}
|
|
161
161
|
/**
|
|
162
162
|
* Options for decryption.
|
|
@@ -164,11 +164,11 @@ interface EncryptOptions {
|
|
|
164
164
|
* ### 🍼 Explain Like I'm Five
|
|
165
165
|
* To unlock the message, we must know how it was written down.
|
|
166
166
|
*
|
|
167
|
-
* - `
|
|
167
|
+
* - `inputEncoding`: input ciphertext encoding (`'base64' | 'base64url' | 'hex'`) (default: `'base64url'`)
|
|
168
168
|
*/
|
|
169
169
|
interface DecryptOptions {
|
|
170
170
|
/** Encoding format for the input ciphertext (default: `'base64url'`). */
|
|
171
|
-
|
|
171
|
+
inputEncoding?: CipherEncoding;
|
|
172
172
|
}
|
|
173
173
|
/**
|
|
174
174
|
* Options for hashing arbitrary data.
|
|
@@ -178,13 +178,13 @@ interface DecryptOptions {
|
|
|
178
178
|
* You can choose how to create the fingerprint (digest) and how to write it down (encoding).
|
|
179
179
|
*
|
|
180
180
|
* - `digest`: `'sha256' | 'sha384' | 'sha512'` (default: `'sha256'`)
|
|
181
|
-
* - `
|
|
181
|
+
* - `outputEncoding`: output ciphertext encoding for the hash (`'base64' | 'base64url' | 'hex'`; default: `'base64url'`)
|
|
182
182
|
*/
|
|
183
183
|
interface HashOptions {
|
|
184
184
|
/** Digest algorithm to use (default: `'sha256'`). */
|
|
185
185
|
digest?: DigestAlgorithm;
|
|
186
186
|
/** Encoding format for the output hash (default: `'base64url'`). */
|
|
187
|
-
|
|
187
|
+
outputEncoding?: CipherEncoding;
|
|
188
188
|
}
|
|
189
189
|
/**
|
|
190
190
|
* Options for password hashing (PBKDF2).
|
|
@@ -194,7 +194,7 @@ interface HashOptions {
|
|
|
194
194
|
* stirring many times (iterations), and making a long result (keyLength).
|
|
195
195
|
*
|
|
196
196
|
* - `digest`: `'sha256' | 'sha384' | 'sha512'` (default: `'sha512'`)
|
|
197
|
-
* - `
|
|
197
|
+
* - `outputEncoding`: output ciphertext encoding for the hash (`'base64' | 'base64url' | 'hex'`; default: `'base64url'`)
|
|
198
198
|
* - `saltLength`: size of the random salt in bytes (default: `16` bytes)
|
|
199
199
|
* - `iterations`: number of iterations (default: `320000`)
|
|
200
200
|
* - `keyLength`: length of the derived key in bytes (default: `64` bytes)
|
|
@@ -203,7 +203,7 @@ interface HashPasswordOptions {
|
|
|
203
203
|
/** Digest algorithm to use (default: `'sha512'`). */
|
|
204
204
|
digest?: DigestAlgorithm;
|
|
205
205
|
/** Encoding format for the output hash (default: `'base64url'`). */
|
|
206
|
-
|
|
206
|
+
outputEncoding?: CipherEncoding;
|
|
207
207
|
/** Length of the salt in bytes (default: `16` bytes, min: `8` bytes). */
|
|
208
208
|
saltLength?: number;
|
|
209
209
|
/** Number of iterations for key derivation (default: `320000`, min: `1000`). */
|
|
@@ -219,7 +219,7 @@ interface HashPasswordOptions {
|
|
|
219
219
|
* same size—so the new result matches the old one.
|
|
220
220
|
*
|
|
221
221
|
* - `digest`: `'sha256' | 'sha384' | 'sha512'` (default: `'sha512'`)
|
|
222
|
-
* - `
|
|
222
|
+
* - `inputEncoding`: input ciphertext encoding for the hash (`'base64' | 'base64url' | 'hex'`; default: `'base64url'`)
|
|
223
223
|
* - `iterations`: number of iterations (default: `320000`)
|
|
224
224
|
* - `keyLength`: length of the derived key in bytes (default: `64` bytes)
|
|
225
225
|
*/
|
|
@@ -227,7 +227,7 @@ interface VerifyPasswordOptions {
|
|
|
227
227
|
/** Digest algorithm to use (default: `'sha512'`). */
|
|
228
228
|
digest?: DigestAlgorithm;
|
|
229
229
|
/** Encoding format of the input hash (default: `'base64url'`). */
|
|
230
|
-
|
|
230
|
+
inputEncoding?: CipherEncoding;
|
|
231
231
|
/** Number of iterations for key derivation (default: `320000`). */
|
|
232
232
|
iterations?: number;
|
|
233
233
|
/** Length of the derived key in bytes (default: `64` bytes). */
|
|
@@ -250,12 +250,10 @@ interface VerifyPasswordOptions {
|
|
|
250
250
|
*
|
|
251
251
|
* @example
|
|
252
252
|
* ```ts
|
|
253
|
-
* const
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
257
|
-
* console.error(res.error.message, res.error.description);
|
|
258
|
-
* }
|
|
253
|
+
* const { result, error, success } = tryStringifyObj({ a: 1 });
|
|
254
|
+
*
|
|
255
|
+
* if (success) console.log(result); // "{\"a\":1}"
|
|
256
|
+
* else console.error(error); // { message: "...", description: "..." }
|
|
259
257
|
* ```
|
|
260
258
|
*/
|
|
261
259
|
declare function tryStringifyObj<T extends object = Record<string, unknown>>(obj: T): Result<string>;
|
|
@@ -276,11 +274,7 @@ declare function tryStringifyObj<T extends object = Record<string, unknown>>(obj
|
|
|
276
274
|
*
|
|
277
275
|
* @example
|
|
278
276
|
* ```ts
|
|
279
|
-
*
|
|
280
|
-
* const json = stringifyObj({ a: 1 }); // {"a":1}
|
|
281
|
-
* } catch (error: unknown) {
|
|
282
|
-
* console.error(error);
|
|
283
|
-
* }
|
|
277
|
+
* const json = stringifyObj({ a: 1 }); // "{\"a\":1}"
|
|
284
278
|
* ```
|
|
285
279
|
*/
|
|
286
280
|
declare function stringifyObj<T extends object = Record<string, unknown>>(obj: T): string;
|
|
@@ -298,12 +292,10 @@ declare function stringifyObj<T extends object = Record<string, unknown>>(obj: T
|
|
|
298
292
|
*
|
|
299
293
|
* @example
|
|
300
294
|
* ```ts
|
|
301
|
-
* const
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
* console.error(res.error.message, res.error.description);
|
|
306
|
-
* }
|
|
295
|
+
* const {result, error, success} = tryParseToObj<{ a: number }>('{"a":1}');
|
|
296
|
+
*
|
|
297
|
+
* if (success) console.log(result); // { a: 1 }
|
|
298
|
+
* else console.error(error) // { message: "...", description: "..." }
|
|
307
299
|
* ```
|
|
308
300
|
*/
|
|
309
301
|
declare function tryParseToObj<T extends object = Record<string, unknown>>(str: string): Result<{
|
|
@@ -324,11 +316,7 @@ declare function tryParseToObj<T extends object = Record<string, unknown>>(str:
|
|
|
324
316
|
*
|
|
325
317
|
* @example
|
|
326
318
|
* ```ts
|
|
327
|
-
*
|
|
328
|
-
* const obj = parseToObj<{ a: number }>('{"a":1}'); // obj.a === 1
|
|
329
|
-
* } catch (error: unknown) {
|
|
330
|
-
* console.error(error);
|
|
331
|
-
* }
|
|
319
|
+
* const obj = parseToObj<{ a: number }>('{"a":1}'); // obj.a === 1
|
|
332
320
|
* ```
|
|
333
321
|
*/
|
|
334
322
|
declare function parseToObj<T extends object = Record<string, unknown>>(str: string): T;
|
|
@@ -373,12 +361,12 @@ declare const ENCRYPTED_REGEX: Readonly<{
|
|
|
373
361
|
*
|
|
374
362
|
* @example
|
|
375
363
|
* ```ts
|
|
376
|
-
*
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
*
|
|
364
|
+
* matchEncryptedPattern("abc.def.ghi.", "node"); // true
|
|
365
|
+
* matchEncryptedPattern("abc.def.", "web"); // true
|
|
366
|
+
* matchEncryptedPattern("abc.def.", "node"); // false
|
|
367
|
+
* matchEncryptedPattern("abc.def.ghi.", "general"); // true
|
|
380
368
|
* ```
|
|
381
369
|
*/
|
|
382
|
-
declare function
|
|
370
|
+
declare function matchEncryptedPattern(data: string, format: "general" | "node" | "web"): boolean;
|
|
383
371
|
|
|
384
|
-
export { type CipherEncoding 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 CreateSecretKeyOptions as d, type EncryptOptions as e, type DecryptOptions as f, type HashPasswordOptions as g,
|
|
372
|
+
export { type CipherEncoding 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 CreateSecretKeyOptions as d, type EncryptOptions as e, type DecryptOptions as f, type HashPasswordOptions as g, matchEncryptedPattern as m, parseToObj as p, stringifyObj as s, tryParseToObj as t };
|