cipher-kit 2.0.0-beta.1 → 2.0.0-beta.3

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 (40) hide show
  1. package/dist/chunk-6GBH7YTP.js +468 -0
  2. package/dist/chunk-6GBH7YTP.js.map +1 -0
  3. package/dist/{chunk-SRGSVNQ2.js → chunk-BNQERV4S.js} +195 -101
  4. package/dist/chunk-BNQERV4S.js.map +1 -0
  5. package/dist/chunk-NKLNWTQA.cjs +607 -0
  6. package/dist/chunk-NKLNWTQA.cjs.map +1 -0
  7. package/dist/chunk-UHP3PPXP.cjs +499 -0
  8. package/dist/chunk-UHP3PPXP.cjs.map +1 -0
  9. package/dist/{chunk-6HNTSQAP.js → chunk-YPYDYYV2.js} +28 -36
  10. package/dist/chunk-YPYDYYV2.js.map +1 -0
  11. package/dist/{chunk-ZIVTPFKN.cjs → chunk-ZJ32WGAA.cjs} +29 -37
  12. package/dist/chunk-ZJ32WGAA.cjs.map +1 -0
  13. package/dist/{export-DEWwhS-S.d.ts → export--ndIQ3j3.d.cts} +49 -42
  14. package/dist/{export-DzNR1ht3.d.ts → export-C2M5UPLX.d.cts} +49 -42
  15. package/dist/{export-oVEmcDLI.d.cts → export-CPUbAFZA.d.ts} +49 -42
  16. package/dist/{export-C2vQXrZa.d.cts → export-v9ULdDL0.d.ts} +49 -42
  17. package/dist/index.cjs +12 -104
  18. package/dist/index.d.cts +3 -3
  19. package/dist/index.d.ts +3 -3
  20. package/dist/index.js +3 -3
  21. package/dist/node.cjs +42 -34
  22. package/dist/node.d.cts +2 -2
  23. package/dist/node.d.ts +2 -2
  24. package/dist/node.js +2 -2
  25. package/dist/{validate-TRx4DDtg.d.cts → validate-CULVlPck.d.cts} +42 -8
  26. package/dist/{validate-TRx4DDtg.d.ts → validate-CULVlPck.d.ts} +42 -8
  27. package/dist/web-api.cjs +42 -34
  28. package/dist/web-api.d.cts +2 -2
  29. package/dist/web-api.d.ts +2 -2
  30. package/dist/web-api.js +2 -2
  31. package/package.json +1 -1
  32. package/dist/chunk-6HNTSQAP.js.map +0 -1
  33. package/dist/chunk-DZLEO2JD.cjs +0 -511
  34. package/dist/chunk-DZLEO2JD.cjs.map +0 -1
  35. package/dist/chunk-I25C3WUZ.js +0 -382
  36. package/dist/chunk-I25C3WUZ.js.map +0 -1
  37. package/dist/chunk-SRGSVNQ2.js.map +0 -1
  38. package/dist/chunk-UR5HPMNF.cjs +0 -411
  39. package/dist/chunk-UR5HPMNF.cjs.map +0 -1
  40. package/dist/chunk-ZIVTPFKN.cjs.map +0 -1
@@ -1,4 +1,4 @@
1
- import { R as Result, c as ENCRYPTION_ALGORITHMS, D as DIGEST_ALGORITHMS, S as SecretKey, b as EncodingFormat } from './validate-TRx4DDtg.cjs';
1
+ import { R as Result, d as CreateSecretKeyOptions, S as SecretKey, e as EncryptOptions, f as DecryptOptions, H as HashOptions, g as HashPasswordOptions, V as VerifyPasswordOptions, b as Encoding } from './validate-CULVlPck.js';
2
2
  import { Buffer } from 'node:buffer';
3
3
 
4
4
  /**
@@ -21,12 +21,7 @@ declare function generateUuid(): string;
21
21
  * @param secret - The input string to derive the secret key from.
22
22
  * @returns A Result containing a SecretKey object representing the derived secret key or an error.
23
23
  */
24
- declare function tryCreateSecretKey(secret: string, options?: {
25
- algorithm?: keyof typeof ENCRYPTION_ALGORITHMS;
26
- digest?: keyof typeof DIGEST_ALGORITHMS;
27
- salt?: string;
28
- info?: string;
29
- }): Result<{
24
+ declare function tryCreateSecretKey(secret: string, options?: CreateSecretKeyOptions): Result<{
30
25
  result: SecretKey<'node'>;
31
26
  }>;
32
27
  /**
@@ -37,12 +32,7 @@ declare function tryCreateSecretKey(secret: string, options?: {
37
32
  * @returns A SecretKey object representing the derived secret key.
38
33
  * @throws {Error} If the input key is invalid or key generation fails.
39
34
  */
40
- declare function createSecretKey(secret: string, options?: {
41
- algorithm?: keyof typeof ENCRYPTION_ALGORITHMS;
42
- digest?: keyof typeof DIGEST_ALGORITHMS;
43
- salt?: string;
44
- info?: string;
45
- }): SecretKey<'node'>;
35
+ declare function createSecretKey(secret: string, options?: CreateSecretKeyOptions): SecretKey<'node'>;
46
36
  /**
47
37
  * Encrypts the input string using the provided secret key.
48
38
  * The output is a string in the format "iv.cipher.tag." where each component is base64url encoded.
@@ -51,7 +41,7 @@ declare function createSecretKey(secret: string, options?: {
51
41
  * @param secretKey - The SecretKey object used for encryption.
52
42
  * @returns A Result containing a string representing the encrypted data in the specified format or an error.
53
43
  */
54
- declare function tryEncrypt(data: string, secretKey: SecretKey<'node'>): Result<string>;
44
+ declare function tryEncrypt(data: string, secretKey: SecretKey<'node'>, options?: EncryptOptions): Result<string>;
55
45
  /**
56
46
  * Encrypts the input string using the provided secret key.
57
47
  * The output is a string in the format "iv.cipher.tag." where each component is base64url encoded.
@@ -61,7 +51,7 @@ declare function tryEncrypt(data: string, secretKey: SecretKey<'node'>): Result<
61
51
  * @returns A string representing the encrypted data in the specified format.
62
52
  * @throws {Error} If the input data or key is invalid, or if encryption fails.
63
53
  */
64
- declare function encrypt(data: string, secretKey: SecretKey<'node'>): string;
54
+ declare function encrypt(data: string, secretKey: SecretKey<'node'>, options?: EncryptOptions): string;
65
55
  /**
66
56
  * Decrypts the input string using the provided secret key.
67
57
  * The input must be in the format "iv.cipher.tag." where each component is base64url encoded.
@@ -70,7 +60,7 @@ declare function encrypt(data: string, secretKey: SecretKey<'node'>): string;
70
60
  * @param secretKey - The SecretKey object used for decryption.
71
61
  * @returns A Result containing a string representing the decrypted data or an error.
72
62
  */
73
- declare function tryDecrypt(encrypted: string, secretKey: SecretKey<'node'>): Result<string>;
63
+ declare function tryDecrypt(encrypted: string, secretKey: SecretKey<'node'>, options?: DecryptOptions): Result<string>;
74
64
  /**
75
65
  * Decrypts the input string using the provided secret key.
76
66
  * The input must be in the format "iv.cipher.tag." where each component is base64url encoded.
@@ -80,7 +70,7 @@ declare function tryDecrypt(encrypted: string, secretKey: SecretKey<'node'>): Re
80
70
  * @returns A string representing the decrypted data.
81
71
  * @throws {Error} If the input data or key is invalid, or if decryption fails.
82
72
  */
83
- declare function decrypt(encrypted: string, secretKey: SecretKey<'node'>): string;
73
+ declare function decrypt(encrypted: string, secretKey: SecretKey<'node'>, options?: DecryptOptions): string;
84
74
  /**
85
75
  * Encrypts the input object using the provided secret key.
86
76
  * The object is first serialized to a JSON string before encryption.
@@ -90,7 +80,7 @@ declare function decrypt(encrypted: string, secretKey: SecretKey<'node'>): strin
90
80
  * @param secretKey - The SecretKey object used for encryption.
91
81
  * @returns A Result containing a string representing the encrypted object in the specified format or an error.
92
82
  */
93
- declare function tryEncryptObj<T extends object = Record<string, unknown>>(data: T, secretKey: SecretKey<'node'>): Result<string>;
83
+ declare function tryEncryptObj<T extends object = Record<string, unknown>>(data: T, secretKey: SecretKey<'node'>, options?: EncryptOptions): Result<string>;
94
84
  /**
95
85
  * Encrypts the input object using the provided secret key.
96
86
  * The object is first serialized to a JSON string before encryption.
@@ -101,7 +91,7 @@ declare function tryEncryptObj<T extends object = Record<string, unknown>>(data:
101
91
  * @returns A string representing the encrypted object in the specified format.
102
92
  * @throws {Error} If the input data or key is invalid, or if encryption fails.
103
93
  */
104
- declare function encryptObj<T extends object = Record<string, unknown>>(data: T, secretKey: SecretKey<'node'>): string;
94
+ declare function encryptObj<T extends object = Record<string, unknown>>(data: T, secretKey: SecretKey<'node'>, options?: EncryptOptions): string;
105
95
  /**
106
96
  * Decrypts the input string to an object using the provided secret key.
107
97
  * The input must be in the format "iv.cipher.tag." where each component is base64url encoded.
@@ -111,7 +101,7 @@ declare function encryptObj<T extends object = Record<string, unknown>>(data: T,
111
101
  * @param secretKey - The SecretKey object used for decryption.
112
102
  * @returns A Result containing an object representing the decrypted data or an error.
113
103
  */
114
- declare function tryDecryptObj<T extends object = Record<string, unknown>>(encrypted: string, secretKey: SecretKey<'node'>): Result<{
104
+ declare function tryDecryptObj<T extends object = Record<string, unknown>>(encrypted: string, secretKey: SecretKey<'node'>, options?: DecryptOptions): Result<{
115
105
  result: T;
116
106
  }>;
117
107
  /**
@@ -124,16 +114,14 @@ declare function tryDecryptObj<T extends object = Record<string, unknown>>(encry
124
114
  * @returns An object representing the decrypted data.
125
115
  * @throws {Error} If the input data or key is invalid, or if decryption fails.
126
116
  */
127
- declare function decryptObj<T extends object = Record<string, unknown>>(encrypted: string, secretKey: SecretKey<'node'>): {
128
- result: T;
129
- };
117
+ declare function decryptObj<T extends object = Record<string, unknown>>(encrypted: string, secretKey: SecretKey<'node'>, options?: DecryptOptions): T;
130
118
  /**
131
119
  * Hashes the input string using SHA-256 and returns the hash in base64url format.
132
120
  *
133
121
  * @param data - The input string to hash.
134
122
  * @returns A Result containing a string representing the SHA-256 hash in base64url format or an error.
135
123
  */
136
- declare function tryHash(data: string): Result<string>;
124
+ declare function tryHash(data: string, options?: HashOptions): Result<string>;
137
125
  /**
138
126
  * Hashes the input string using SHA-256 and returns the hash in base64url format.
139
127
  *
@@ -141,14 +129,31 @@ declare function tryHash(data: string): Result<string>;
141
129
  * @returns A string representing the SHA-256 hash in base64url format.
142
130
  * @throws {Error} If the input data is invalid or hashing fails.
143
131
  */
144
- declare function hash(data: string): string;
132
+ declare function hash(data: string, options?: HashOptions): string;
133
+ /**
134
+ * Hashes the input object by first serializing it to a JSON string using stable key ordering,
135
+ * then hashing the string using SHA-256 and returning the hash in base64url format.
136
+ *
137
+ * @param data - The input object to hash.
138
+ * @returns A Result containing a string representing the SHA-256 hash of the serialized object in base64url format or an error.
139
+ * */
140
+ declare function tryHashObj<T extends object = Record<string, unknown>>(data: T, options?: HashOptions): Result<string>;
141
+ /**
142
+ * Hashes the input object by first serializing it to a JSON string using stable key ordering,
143
+ * then hashing the string using SHA-256 and returning the hash in base64url format.
144
+ *
145
+ * @param data - The input object to hash.
146
+ * @returns A string representing the SHA-256 hash of the serialized object in base64url format.
147
+ * @throws {Error} If the input data is invalid or hashing fails.
148
+ */
149
+ declare function hashObj<T extends object = Record<string, unknown>>(data: T, options?: HashOptions): string;
145
150
  /**
146
151
  * Hashes a password using PBKDF2 with SHA-512.
147
152
  *
148
153
  * @param password - The password to hash.
149
154
  * @returns A Result containing an object with the hash and salt, or an error.
150
155
  */
151
- declare function tryHashPassword(password: string): Result<{
156
+ declare function tryHashPassword(password: string, options?: HashPasswordOptions): Result<{
152
157
  hash: string;
153
158
  salt: string;
154
159
  }>;
@@ -159,7 +164,7 @@ declare function tryHashPassword(password: string): Result<{
159
164
  * @returns An object with the hash and salt.
160
165
  * @throws {Error} If the input password is invalid or hashing fails.
161
166
  */
162
- declare function hashPassword(password: string): {
167
+ declare function hashPassword(password: string, options?: HashPasswordOptions): {
163
168
  hash: string;
164
169
  salt: string;
165
170
  };
@@ -171,16 +176,16 @@ declare function hashPassword(password: string): {
171
176
  * @param salt - The salt used during hashing (in base64url format).
172
177
  * @returns A boolean indicating whether the password matches the hashed password.
173
178
  */
174
- declare function verifyPassword(password: string, hashedPassword: string, salt: string): boolean;
179
+ declare function verifyPassword(password: string, hashedPassword: string, salt: string, options?: VerifyPasswordOptions): boolean;
175
180
  /**
176
181
  * Converts a string to a Buffer (byte array) using the specified encoding format.
177
182
  * Supported formats: 'base64', 'base64url', 'hex', 'utf8', 'latin1'.
178
183
  *
179
184
  * @param data - The input string to convert.
180
- * @param format - The encoding format to use (default is 'utf8').
185
+ * @param inputEncoding - The encoding format to use (default is 'utf8').
181
186
  * @returns A Result containing a Node.js Buffer with the encoded data or an error.
182
187
  */
183
- declare function tryConvertStrToBytes(data: string, format?: EncodingFormat): Result<{
188
+ declare function tryConvertStrToBytes(data: string, inputEncoding?: Encoding): Result<{
184
189
  result: Buffer;
185
190
  }>;
186
191
  /**
@@ -188,30 +193,30 @@ declare function tryConvertStrToBytes(data: string, format?: EncodingFormat): Re
188
193
  * Supported formats: 'base64', 'base64url', 'hex', 'utf8', 'latin1'.
189
194
  *
190
195
  * @param data - The input string to convert.
191
- * @param format - The encoding format to use (default is 'utf8').
196
+ * @param inputEncoding - The encoding format to use (default is 'utf8').
192
197
  * @returns A Node.js Buffer containing the encoded data.
193
198
  * @throws {Error} If the input data is invalid or conversion fails.
194
199
  */
195
- declare function convertStrToBytes(data: string, format?: EncodingFormat): Buffer;
200
+ declare function convertStrToBytes(data: string, inputEncoding?: Encoding): Buffer;
196
201
  /**
197
202
  * Converts a Buffer (byte array) to a string using the specified encoding format.
198
203
  * Supported formats: 'base64', 'base64url', 'hex', 'utf8', 'latin1'.
199
204
  *
200
205
  * @param data - The input Buffer to convert.
201
- * @param format - The encoding format to use (default is 'utf8').
206
+ * @param outputEncoding - The encoding format to use (default is 'utf8').
202
207
  * @returns A Result containing the string representation of the Buffer or an error.
203
208
  */
204
- declare function tryConvertBytesToStr(data: Buffer, format?: EncodingFormat): Result<string>;
209
+ declare function tryConvertBytesToStr(data: Buffer, outputEncoding?: Encoding): Result<string>;
205
210
  /**
206
211
  * Converts a Buffer (byte array) to a string using the specified encoding format.
207
212
  * Supported formats: 'base64', 'base64url', 'hex', 'utf8', 'latin1'.
208
213
  *
209
214
  * @param data - The input Buffer to convert.
210
- * @param format - The encoding format to use (default is 'utf8').
215
+ * @param outputEncoding - The encoding format to use (default is 'utf8').
211
216
  * @returns A string representation of the Buffer in the specified format.
212
217
  * @throws {Error} If the input data is invalid or conversion fails.
213
218
  */
214
- declare function convertBytesToStr(data: Buffer, format?: EncodingFormat): string;
219
+ declare function convertBytesToStr(data: Buffer, outputEncoding?: Encoding): string;
215
220
  /**
216
221
  * Convert data from one encoding format to another.
217
222
  *
@@ -220,7 +225,7 @@ declare function convertBytesToStr(data: Buffer, format?: EncodingFormat): strin
220
225
  * @param to - The encoding format to convert to.
221
226
  * @returns A Result containing the converted string or an error.
222
227
  */
223
- declare function tryConvertFormat(data: string, from: EncodingFormat, to: EncodingFormat): Result<{
228
+ declare function tryConvertEncoding(data: string, from: Encoding, to: Encoding): Result<{
224
229
  result: string;
225
230
  }>;
226
231
  /**
@@ -232,10 +237,10 @@ declare function tryConvertFormat(data: string, from: EncodingFormat, to: Encodi
232
237
  * @returns A converted string.
233
238
  * @throws {Error} If the input data is invalid or conversion fails.
234
239
  */
235
- declare function convertFormat(data: string, from: EncodingFormat, to: EncodingFormat): string;
240
+ declare function convertEncoding(data: string, from: Encoding, to: Encoding): string;
236
241
 
237
242
  declare const kit_convertBytesToStr: typeof convertBytesToStr;
238
- declare const kit_convertFormat: typeof convertFormat;
243
+ declare const kit_convertEncoding: typeof convertEncoding;
239
244
  declare const kit_convertStrToBytes: typeof convertStrToBytes;
240
245
  declare const kit_createSecretKey: typeof createSecretKey;
241
246
  declare const kit_decrypt: typeof decrypt;
@@ -244,9 +249,10 @@ declare const kit_encrypt: typeof encrypt;
244
249
  declare const kit_encryptObj: typeof encryptObj;
245
250
  declare const kit_generateUuid: typeof generateUuid;
246
251
  declare const kit_hash: typeof hash;
252
+ declare const kit_hashObj: typeof hashObj;
247
253
  declare const kit_hashPassword: typeof hashPassword;
248
254
  declare const kit_tryConvertBytesToStr: typeof tryConvertBytesToStr;
249
- declare const kit_tryConvertFormat: typeof tryConvertFormat;
255
+ declare const kit_tryConvertEncoding: typeof tryConvertEncoding;
250
256
  declare const kit_tryConvertStrToBytes: typeof tryConvertStrToBytes;
251
257
  declare const kit_tryCreateSecretKey: typeof tryCreateSecretKey;
252
258
  declare const kit_tryDecrypt: typeof tryDecrypt;
@@ -255,10 +261,11 @@ declare const kit_tryEncrypt: typeof tryEncrypt;
255
261
  declare const kit_tryEncryptObj: typeof tryEncryptObj;
256
262
  declare const kit_tryGenerateUuid: typeof tryGenerateUuid;
257
263
  declare const kit_tryHash: typeof tryHash;
264
+ declare const kit_tryHashObj: typeof tryHashObj;
258
265
  declare const kit_tryHashPassword: typeof tryHashPassword;
259
266
  declare const kit_verifyPassword: typeof verifyPassword;
260
267
  declare namespace kit {
261
- export { kit_convertBytesToStr as convertBytesToStr, kit_convertFormat as convertFormat, kit_convertStrToBytes as convertStrToBytes, kit_createSecretKey as createSecretKey, kit_decrypt as decrypt, kit_decryptObj as decryptObj, kit_encrypt as encrypt, kit_encryptObj as encryptObj, kit_generateUuid as generateUuid, kit_hash as hash, kit_hashPassword as hashPassword, kit_tryConvertBytesToStr as tryConvertBytesToStr, kit_tryConvertFormat as tryConvertFormat, kit_tryConvertStrToBytes as tryConvertStrToBytes, kit_tryCreateSecretKey as tryCreateSecretKey, kit_tryDecrypt as tryDecrypt, kit_tryDecryptObj as tryDecryptObj, kit_tryEncrypt as tryEncrypt, kit_tryEncryptObj as tryEncryptObj, kit_tryGenerateUuid as tryGenerateUuid, kit_tryHash as tryHash, kit_tryHashPassword as tryHashPassword, kit_verifyPassword as verifyPassword };
268
+ export { kit_convertBytesToStr as convertBytesToStr, kit_convertEncoding as convertEncoding, kit_convertStrToBytes as convertStrToBytes, kit_createSecretKey as createSecretKey, kit_decrypt as decrypt, kit_decryptObj as decryptObj, kit_encrypt as encrypt, kit_encryptObj as encryptObj, kit_generateUuid as generateUuid, kit_hash as hash, kit_hashObj as hashObj, kit_hashPassword as hashPassword, kit_tryConvertBytesToStr as tryConvertBytesToStr, kit_tryConvertEncoding as tryConvertEncoding, kit_tryConvertStrToBytes as tryConvertStrToBytes, kit_tryCreateSecretKey as tryCreateSecretKey, kit_tryDecrypt as tryDecrypt, kit_tryDecryptObj as tryDecryptObj, kit_tryEncrypt as tryEncrypt, kit_tryEncryptObj as tryEncryptObj, kit_tryGenerateUuid as tryGenerateUuid, kit_tryHash as tryHash, kit_tryHashObj as tryHashObj, kit_tryHashPassword as tryHashPassword, kit_verifyPassword as verifyPassword };
262
269
  }
263
270
 
264
- export { tryCreateSecretKey as a, tryEncrypt as b, createSecretKey as c, tryDecrypt as d, encrypt as e, decrypt as f, generateUuid as g, tryEncryptObj as h, encryptObj as i, tryDecryptObj as j, kit as k, decryptObj as l, tryHash as m, hash as n, tryHashPassword as o, hashPassword as p, tryConvertStrToBytes as q, convertStrToBytes as r, tryConvertBytesToStr as s, tryGenerateUuid as t, convertBytesToStr as u, verifyPassword as v, tryConvertFormat as w, convertFormat as x };
271
+ export { tryCreateSecretKey as a, tryEncrypt as b, createSecretKey as c, tryDecrypt as d, encrypt as e, decrypt as f, generateUuid as g, tryEncryptObj as h, encryptObj as i, tryDecryptObj as j, kit as k, decryptObj as l, tryHash as m, hash as n, tryHashObj as o, hashObj as p, tryHashPassword as q, hashPassword as r, tryConvertStrToBytes as s, tryGenerateUuid as t, convertStrToBytes as u, verifyPassword as v, tryConvertBytesToStr as w, convertBytesToStr as x, tryConvertEncoding as y, convertEncoding as z };
@@ -1,4 +1,4 @@
1
- import { R as Result, c as ENCRYPTION_ALGORITHMS, D as DIGEST_ALGORITHMS, S as SecretKey, b as EncodingFormat } from './validate-TRx4DDtg.cjs';
1
+ import { R as Result, d as CreateSecretKeyOptions, S as SecretKey, e as EncryptOptions, f as DecryptOptions, H as HashOptions, g as HashPasswordOptions, V as VerifyPasswordOptions, b as Encoding } from './validate-CULVlPck.js';
2
2
 
3
3
  /**
4
4
  * Generates a UUID (v4).
@@ -20,12 +20,7 @@ declare function generateUuid(): string;
20
20
  * @param secret - The input string to derive the secret key from.
21
21
  * @returns A Result containing a SecretKey object representing the derived secret key or an error.
22
22
  */
23
- declare function tryCreateSecretKey(secret: string, options?: {
24
- algorithm?: keyof typeof ENCRYPTION_ALGORITHMS;
25
- digest?: keyof typeof DIGEST_ALGORITHMS;
26
- salt?: string;
27
- info?: string;
28
- }): Promise<Result<{
23
+ declare function tryCreateSecretKey(secret: string, options?: CreateSecretKeyOptions): Promise<Result<{
29
24
  result: SecretKey<'web'>;
30
25
  }>>;
31
26
  /**
@@ -36,12 +31,7 @@ declare function tryCreateSecretKey(secret: string, options?: {
36
31
  * @returns A SecretKey object representing the derived secret key.
37
32
  * @throws {Error} If the input key is invalid or key generation fails.
38
33
  */
39
- declare function createSecretKey(secret: string, options?: {
40
- algorithm?: keyof typeof ENCRYPTION_ALGORITHMS;
41
- digest?: keyof typeof DIGEST_ALGORITHMS;
42
- salt?: string;
43
- info?: string;
44
- }): Promise<SecretKey<'web'>>;
34
+ declare function createSecretKey(secret: string, options?: CreateSecretKeyOptions): Promise<SecretKey<'web'>>;
45
35
  /**
46
36
  * Encrypts the input string using the provided secret key.
47
37
  * The output is a string in the format "iv.cipherWithTag." where each component is base64url encoded.
@@ -50,7 +40,7 @@ declare function createSecretKey(secret: string, options?: {
50
40
  * @param secretKey - The SecretKey object used for encryption.
51
41
  * @returns A Result containing a string representing the encrypted data in the specified format or an error.
52
42
  */
53
- declare function tryEncrypt(data: string, secretKey: SecretKey<'web'>): Promise<Result<string>>;
43
+ declare function tryEncrypt(data: string, secretKey: SecretKey<'web'>, options?: EncryptOptions): Promise<Result<string>>;
54
44
  /**
55
45
  * Encrypts the input string using the provided secret key.
56
46
  * The output is a string in the format "iv.cipherWithTag." where each component is base64url encoded.
@@ -60,7 +50,7 @@ declare function tryEncrypt(data: string, secretKey: SecretKey<'web'>): Promise<
60
50
  * @returns A string representing the encrypted data in the specified format.
61
51
  * @throws {Error} If the input data or key is invalid, or if encryption fails.
62
52
  */
63
- declare function encrypt(data: string, secretKey: SecretKey<'web'>): Promise<string>;
53
+ declare function encrypt(data: string, secretKey: SecretKey<'web'>, options?: EncryptOptions): Promise<string>;
64
54
  /**
65
55
  * Decrypts the input string using the provided secret key.
66
56
  * The input must be in the format "iv.cipherWithTag." where each component is base64url encoded.
@@ -69,7 +59,7 @@ declare function encrypt(data: string, secretKey: SecretKey<'web'>): Promise<str
69
59
  * @param secretKey - The SecretKey object used for decryption.
70
60
  * @returns A Result containing a string representing the decrypted data or an error.
71
61
  */
72
- declare function tryDecrypt(encrypted: string, secretKey: SecretKey<'web'>): Promise<Result<string>>;
62
+ declare function tryDecrypt(encrypted: string, secretKey: SecretKey<'web'>, options?: DecryptOptions): Promise<Result<string>>;
73
63
  /**
74
64
  * Decrypts the input string using the provided secret key.
75
65
  * The input must be in the format "iv.cipherWithTag" where each component is base64url encoded.
@@ -79,7 +69,7 @@ declare function tryDecrypt(encrypted: string, secretKey: SecretKey<'web'>): Pro
79
69
  * @returns A string representing the decrypted data.
80
70
  * @throws {Error} If the input data or key is invalid, or if decryption fails.
81
71
  */
82
- declare function decrypt(encrypted: string, secretKey: SecretKey<'web'>): Promise<string>;
72
+ declare function decrypt(encrypted: string, secretKey: SecretKey<'web'>, options?: DecryptOptions): Promise<string>;
83
73
  /**
84
74
  * Encrypts the input object using the provided secret key.
85
75
  * The object is first serialized to a JSON string before encryption.
@@ -89,7 +79,7 @@ declare function decrypt(encrypted: string, secretKey: SecretKey<'web'>): Promis
89
79
  * @param secretKey - The SecretKey object used for encryption.
90
80
  * @returns A Result containing a string representing the encrypted object in the specified format or an error.
91
81
  */
92
- declare function tryEncryptObj<T extends object = Record<string, unknown>>(data: T, secretKey: SecretKey<'web'>): Promise<Result<string>>;
82
+ declare function tryEncryptObj<T extends object = Record<string, unknown>>(data: T, secretKey: SecretKey<'web'>, options?: EncryptOptions): Promise<Result<string>>;
93
83
  /**
94
84
  * Encrypts the input object using the provided secret key.
95
85
  * The object is first serialized to a JSON string before encryption.
@@ -100,7 +90,7 @@ declare function tryEncryptObj<T extends object = Record<string, unknown>>(data:
100
90
  * @returns A string representing the encrypted object in the specified format.
101
91
  * @throws {Error} If the input data or key is invalid, or if encryption fails.
102
92
  */
103
- declare function encryptObj<T extends object = Record<string, unknown>>(data: T, secretKey: SecretKey<'web'>): Promise<string>;
93
+ declare function encryptObj<T extends object = Record<string, unknown>>(data: T, secretKey: SecretKey<'web'>, options?: EncryptOptions): Promise<string>;
104
94
  /**
105
95
  * Decrypts the input string to an object using the provided secret key.
106
96
  * The input must be in the format "iv.cipherWithTag." where each component is base64url encoded.
@@ -110,7 +100,7 @@ declare function encryptObj<T extends object = Record<string, unknown>>(data: T,
110
100
  * @param secretKey - The SecretKey object used for decryption.
111
101
  * @returns A Result containing an object representing the decrypted data or an error.
112
102
  */
113
- declare function tryDecryptObj<T extends object = Record<string, unknown>>(encrypted: string, secretKey: SecretKey<'web'>): Promise<Result<{
103
+ declare function tryDecryptObj<T extends object = Record<string, unknown>>(encrypted: string, secretKey: SecretKey<'web'>, options?: DecryptOptions): Promise<Result<{
114
104
  result: T;
115
105
  }>>;
116
106
  /**
@@ -123,16 +113,14 @@ declare function tryDecryptObj<T extends object = Record<string, unknown>>(encry
123
113
  * @returns An object representing the decrypted data.
124
114
  * @throws {Error} If the input data or key is invalid, or if decryption fails.
125
115
  */
126
- declare function decryptObj<T extends object = Record<string, unknown>>(encrypted: string, secretKey: SecretKey<'web'>): Promise<{
127
- result: T;
128
- }>;
116
+ declare function decryptObj<T extends object = Record<string, unknown>>(encrypted: string, secretKey: SecretKey<'web'>, options?: DecryptOptions): Promise<T>;
129
117
  /**
130
118
  * Hashes the input string using SHA-256 and returns the hash in base64url format.
131
119
  *
132
120
  * @param data - The input string to hash.
133
121
  * @returns A Result containing a string representing the SHA-256 hash in base64url format or an error.
134
122
  */
135
- declare function tryHash(data: string): Promise<Result<string>>;
123
+ declare function tryHash(data: string, options?: HashOptions): Promise<Result<string>>;
136
124
  /**
137
125
  * Hashes the input string using SHA-256 and returns the hash in base64url format.
138
126
  *
@@ -140,14 +128,31 @@ declare function tryHash(data: string): Promise<Result<string>>;
140
128
  * @returns A string representing the SHA-256 hash in base64url format.
141
129
  * @throws {Error} If the input data is invalid or hashing fails.
142
130
  */
143
- declare function hash(data: string): Promise<string>;
131
+ declare function hash(data: string, options?: HashOptions): Promise<string>;
132
+ /**
133
+ * Hashes the input object by first serializing it to a JSON string using stable key ordering,
134
+ * then hashing the string using SHA-256 and returning the hash in base64url format.
135
+ *
136
+ * @param data - The input object to hash.
137
+ * @returns A Result containing a string representing the SHA-256 hash of the serialized object in base64url format or an error.
138
+ * */
139
+ declare function tryHashObj<T extends object = Record<string, unknown>>(data: T, options?: HashOptions): Promise<Result<string>>;
140
+ /**
141
+ * Hashes the input object by first serializing it to a JSON string using stable key ordering,
142
+ * then hashing the string using SHA-256 and returning the hash in base64url format.
143
+ *
144
+ * @param data - The input object to hash.
145
+ * @returns A string representing the SHA-256 hash of the serialized object in base64url format.
146
+ * @throws {Error} If the input data is invalid or hashing fails.
147
+ */
148
+ declare function hashObj<T extends object = Record<string, unknown>>(data: T, options?: HashOptions): Promise<string>;
144
149
  /**
145
150
  * Hashes a password using PBKDF2 with SHA-512.
146
151
  *
147
152
  * @param password - The password to hash.
148
153
  * @returns A Result containing an object with the hash and salt, or an error.
149
154
  */
150
- declare function tryHashPassword(password: string): Promise<Result<{
155
+ declare function tryHashPassword(password: string, options?: HashPasswordOptions): Promise<Result<{
151
156
  hash: string;
152
157
  salt: string;
153
158
  }>>;
@@ -158,7 +163,7 @@ declare function tryHashPassword(password: string): Promise<Result<{
158
163
  * @returns An object with the hash and salt.
159
164
  * @throws {Error} If the input password is invalid or hashing fails.
160
165
  */
161
- declare function hashPassword(password: string): Promise<{
166
+ declare function hashPassword(password: string, options?: HashPasswordOptions): Promise<{
162
167
  hash: string;
163
168
  salt: string;
164
169
  }>;
@@ -170,16 +175,16 @@ declare function hashPassword(password: string): Promise<{
170
175
  * @param salt - The salt used during hashing (in base64url format).
171
176
  * @returns A boolean indicating whether the password matches the hashed password.
172
177
  */
173
- declare function verifyPassword(password: string, hashedPassword: string, salt: string): Promise<boolean>;
178
+ declare function verifyPassword(password: string, hashedPassword: string, salt: string, options?: VerifyPasswordOptions): Promise<boolean>;
174
179
  /**
175
180
  * Converts a string to a Buffer (byte array) using the specified encoding format.
176
181
  * Supported formats: 'base64', 'base64url', 'hex', 'utf8', 'latin1'.
177
182
  *
178
183
  * @param data - The input string to convert.
179
- * @param format - The encoding format to use (default is 'utf8').
184
+ * @param inputEncoding - The encoding format to use (default is 'utf8').
180
185
  * @returns A Result containing a Uint8Array with the encoded data or an error.
181
186
  */
182
- declare function tryConvertStrToBytes(data: string, format?: EncodingFormat): Result<{
187
+ declare function tryConvertStrToBytes(data: string, inputEncoding?: Encoding): Result<{
183
188
  result: Uint8Array<ArrayBuffer>;
184
189
  }>;
185
190
  /**
@@ -187,30 +192,30 @@ declare function tryConvertStrToBytes(data: string, format?: EncodingFormat): Re
187
192
  * Supported formats: 'base64', 'base64url', 'hex', 'utf8', 'latin1'.
188
193
  *
189
194
  * @param data - The input string to convert.
190
- * @param format - The encoding format to use (default is 'utf8').
195
+ * @param inputEncoding - The encoding format to use (default is 'utf8').
191
196
  * @returns A Uint8Array containing the encoded data.
192
197
  * @throws {Error} If the input data is invalid or conversion fails.
193
198
  */
194
- declare function convertStrToBytes(data: string, format?: EncodingFormat): Uint8Array<ArrayBuffer>;
199
+ declare function convertStrToBytes(data: string, inputEncoding?: Encoding): Uint8Array<ArrayBuffer>;
195
200
  /**
196
201
  * Converts a Uint8Array or ArrayBuffer (byte array) to a string using the specified encoding format.
197
202
  * Supported formats: 'base64', 'base64url', 'hex', 'utf8', 'latin1'.
198
203
  *
199
204
  * @param data - The input Uint8Array or ArrayBuffer to convert.
200
- * @param format - The encoding format to use (default is 'utf8').
205
+ * @param outputEncoding - The encoding format to use (default is 'utf8').
201
206
  * @returns A Result containing the string representation of the Uint8Array or an error.
202
207
  */
203
- declare function tryConvertBytesToStr(data: Uint8Array | ArrayBuffer, format?: EncodingFormat): Result<string>;
208
+ declare function tryConvertBytesToStr(data: Uint8Array | ArrayBuffer, outputEncoding?: Encoding): Result<string>;
204
209
  /**
205
210
  * Converts a Uint8Array or ArrayBuffer (byte array) to a string using the specified encoding format.
206
211
  * Supported formats: 'base64', 'base64url', 'hex', 'utf8', 'latin1'.
207
212
  *
208
213
  * @param data - The input Uint8Array or ArrayBuffer to convert.
209
- * @param format - The encoding format to use (default is 'utf8').
214
+ * @param outputEncoding - The encoding format to use (default is 'utf8').
210
215
  * @returns A string representation of the Uint8Array in the specified format.
211
216
  * @throws {Error} If the input data is invalid or conversion fails.
212
217
  */
213
- declare function convertBytesToStr(data: Uint8Array | ArrayBuffer, format?: EncodingFormat): string;
218
+ declare function convertBytesToStr(data: Uint8Array | ArrayBuffer, outputEncoding?: Encoding): string;
214
219
  /**
215
220
  * Convert data from one encoding format to another.
216
221
  *
@@ -219,7 +224,7 @@ declare function convertBytesToStr(data: Uint8Array | ArrayBuffer, format?: Enco
219
224
  * @param to - The encoding format to convert to.
220
225
  * @returns A Result containing the converted string or an error.
221
226
  */
222
- declare function tryConvertFormat(data: string, from: EncodingFormat, to: EncodingFormat): Result<{
227
+ declare function tryConvertEncoding(data: string, from: Encoding, to: Encoding): Result<{
223
228
  result: string;
224
229
  }>;
225
230
  /**
@@ -231,10 +236,10 @@ declare function tryConvertFormat(data: string, from: EncodingFormat, to: Encodi
231
236
  * @returns A converted string.
232
237
  * @throws {Error} If the input data is invalid or conversion fails.
233
238
  */
234
- declare function convertFormat(data: string, from: EncodingFormat, to: EncodingFormat): string;
239
+ declare function convertEncoding(data: string, from: Encoding, to: Encoding): string;
235
240
 
236
241
  declare const kit_convertBytesToStr: typeof convertBytesToStr;
237
- declare const kit_convertFormat: typeof convertFormat;
242
+ declare const kit_convertEncoding: typeof convertEncoding;
238
243
  declare const kit_convertStrToBytes: typeof convertStrToBytes;
239
244
  declare const kit_createSecretKey: typeof createSecretKey;
240
245
  declare const kit_decrypt: typeof decrypt;
@@ -243,9 +248,10 @@ declare const kit_encrypt: typeof encrypt;
243
248
  declare const kit_encryptObj: typeof encryptObj;
244
249
  declare const kit_generateUuid: typeof generateUuid;
245
250
  declare const kit_hash: typeof hash;
251
+ declare const kit_hashObj: typeof hashObj;
246
252
  declare const kit_hashPassword: typeof hashPassword;
247
253
  declare const kit_tryConvertBytesToStr: typeof tryConvertBytesToStr;
248
- declare const kit_tryConvertFormat: typeof tryConvertFormat;
254
+ declare const kit_tryConvertEncoding: typeof tryConvertEncoding;
249
255
  declare const kit_tryConvertStrToBytes: typeof tryConvertStrToBytes;
250
256
  declare const kit_tryCreateSecretKey: typeof tryCreateSecretKey;
251
257
  declare const kit_tryDecrypt: typeof tryDecrypt;
@@ -254,10 +260,11 @@ declare const kit_tryEncrypt: typeof tryEncrypt;
254
260
  declare const kit_tryEncryptObj: typeof tryEncryptObj;
255
261
  declare const kit_tryGenerateUuid: typeof tryGenerateUuid;
256
262
  declare const kit_tryHash: typeof tryHash;
263
+ declare const kit_tryHashObj: typeof tryHashObj;
257
264
  declare const kit_tryHashPassword: typeof tryHashPassword;
258
265
  declare const kit_verifyPassword: typeof verifyPassword;
259
266
  declare namespace kit {
260
- export { kit_convertBytesToStr as convertBytesToStr, kit_convertFormat as convertFormat, kit_convertStrToBytes as convertStrToBytes, kit_createSecretKey as createSecretKey, kit_decrypt as decrypt, kit_decryptObj as decryptObj, kit_encrypt as encrypt, kit_encryptObj as encryptObj, kit_generateUuid as generateUuid, kit_hash as hash, kit_hashPassword as hashPassword, kit_tryConvertBytesToStr as tryConvertBytesToStr, kit_tryConvertFormat as tryConvertFormat, kit_tryConvertStrToBytes as tryConvertStrToBytes, kit_tryCreateSecretKey as tryCreateSecretKey, kit_tryDecrypt as tryDecrypt, kit_tryDecryptObj as tryDecryptObj, kit_tryEncrypt as tryEncrypt, kit_tryEncryptObj as tryEncryptObj, kit_tryGenerateUuid as tryGenerateUuid, kit_tryHash as tryHash, kit_tryHashPassword as tryHashPassword, kit_verifyPassword as verifyPassword };
267
+ export { kit_convertBytesToStr as convertBytesToStr, kit_convertEncoding as convertEncoding, kit_convertStrToBytes as convertStrToBytes, kit_createSecretKey as createSecretKey, kit_decrypt as decrypt, kit_decryptObj as decryptObj, kit_encrypt as encrypt, kit_encryptObj as encryptObj, kit_generateUuid as generateUuid, kit_hash as hash, kit_hashObj as hashObj, kit_hashPassword as hashPassword, kit_tryConvertBytesToStr as tryConvertBytesToStr, kit_tryConvertEncoding as tryConvertEncoding, kit_tryConvertStrToBytes as tryConvertStrToBytes, kit_tryCreateSecretKey as tryCreateSecretKey, kit_tryDecrypt as tryDecrypt, kit_tryDecryptObj as tryDecryptObj, kit_tryEncrypt as tryEncrypt, kit_tryEncryptObj as tryEncryptObj, kit_tryGenerateUuid as tryGenerateUuid, kit_tryHash as tryHash, kit_tryHashObj as tryHashObj, kit_tryHashPassword as tryHashPassword, kit_verifyPassword as verifyPassword };
261
268
  }
262
269
 
263
- export { tryCreateSecretKey as a, tryEncrypt as b, createSecretKey as c, tryDecrypt as d, encrypt as e, decrypt as f, generateUuid as g, tryEncryptObj as h, encryptObj as i, tryDecryptObj as j, kit as k, decryptObj as l, tryHash as m, hash as n, tryHashPassword as o, hashPassword as p, tryConvertStrToBytes as q, convertStrToBytes as r, tryConvertBytesToStr as s, tryGenerateUuid as t, convertBytesToStr as u, verifyPassword as v, tryConvertFormat as w, convertFormat as x };
270
+ export { tryCreateSecretKey as a, tryEncrypt as b, createSecretKey as c, tryDecrypt as d, encrypt as e, decrypt as f, generateUuid as g, tryEncryptObj as h, encryptObj as i, tryDecryptObj as j, kit as k, decryptObj as l, tryHash as m, hash as n, tryHashObj as o, hashObj as p, tryHashPassword as q, hashPassword as r, tryConvertStrToBytes as s, tryGenerateUuid as t, convertStrToBytes as u, verifyPassword as v, tryConvertBytesToStr as w, convertBytesToStr as x, tryConvertEncoding as y, convertEncoding as z };