cipher-kit 2.0.0-beta.0 → 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.
Files changed (44) hide show
  1. package/dist/chunk-3XGARINH.cjs +480 -0
  2. package/dist/chunk-3XGARINH.cjs.map +1 -0
  3. package/dist/chunk-AEQNI5EZ.js +451 -0
  4. package/dist/chunk-AEQNI5EZ.js.map +1 -0
  5. package/dist/chunk-LOJKJJX5.js +136 -0
  6. package/dist/chunk-LOJKJJX5.js.map +1 -0
  7. package/dist/{chunk-D656BYPA.cjs → chunk-RXXVBCWL.cjs} +58 -32
  8. package/dist/chunk-RXXVBCWL.cjs.map +1 -0
  9. package/dist/chunk-SUGN4VDZ.js +559 -0
  10. package/dist/chunk-SUGN4VDZ.js.map +1 -0
  11. package/dist/chunk-WIZT7AYM.cjs +584 -0
  12. package/dist/chunk-WIZT7AYM.cjs.map +1 -0
  13. package/dist/{export-VUQLKGvM.d.ts → export-Bq9tslUU.d.ts} +43 -46
  14. package/dist/{export-CrT_Y2Cy.d.cts → export-C0WDJZUy.d.ts} +43 -46
  15. package/dist/{export-Bh49U7Yf.d.ts → export-LPOfeH2z.d.cts} +43 -46
  16. package/dist/{export-VtQvdOuA.d.cts → export-RD2Af4CJ.d.cts} +43 -46
  17. package/dist/index.cjs +13 -109
  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 +35 -35
  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-CS4PFmY1.d.cts +159 -0
  26. package/dist/validate-CS4PFmY1.d.ts +159 -0
  27. package/dist/web-api.cjs +35 -35
  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-4IOWANDJ.cjs +0 -376
  33. package/dist/chunk-4IOWANDJ.cjs.map +0 -1
  34. package/dist/chunk-D656BYPA.cjs.map +0 -1
  35. package/dist/chunk-IYMK2O3K.cjs +0 -473
  36. package/dist/chunk-IYMK2O3K.cjs.map +0 -1
  37. package/dist/chunk-J5YHHXDC.js +0 -108
  38. package/dist/chunk-J5YHHXDC.js.map +0 -1
  39. package/dist/chunk-M7V4HSRH.js +0 -347
  40. package/dist/chunk-M7V4HSRH.js.map +0 -1
  41. package/dist/chunk-N2ZI2CIT.js +0 -448
  42. package/dist/chunk-N2ZI2CIT.js.map +0 -1
  43. package/dist/validate-CPWPEEAt.d.cts +0 -86
  44. package/dist/validate-CPWPEEAt.d.ts +0 -86
@@ -1,4 +1,4 @@
1
- import { R as Result, W as WebSecretKey, c as EncodingFormat, b as isWebSecretKey } from './validate-CPWPEEAt.cjs';
1
+ import { R as Result, C as CreateSecretKeyOptions, S as SecretKey, d as EncryptOptions, e as DecryptOptions, H as HashOptions, f as HashPasswordOptions, V as VerifyPasswordOptions, b as Encoding } from './validate-CS4PFmY1.js';
2
2
 
3
3
  /**
4
4
  * Generates a UUID (v4).
@@ -17,90 +17,90 @@ declare function generateUuid(): string;
17
17
  * Derives a secret key from the provided string for encryption/decryption.
18
18
  * Internally, the key is hashed using SHA-256 to ensure it meets the required length.
19
19
  *
20
- * @param key - The input string to derive the secret key from.
21
- * @returns A Result containing a WebApiKey object representing the derived secret key or an error.
20
+ * @param secret - The input string to derive the secret key from.
21
+ * @returns A Result containing a SecretKey object representing the derived secret key or an error.
22
22
  */
23
- declare function tryCreateSecretKey(key: string): Promise<Result<{
24
- result: WebSecretKey;
23
+ declare function tryCreateSecretKey(secret: string, options?: CreateSecretKeyOptions): Promise<Result<{
24
+ result: SecretKey<'web'>;
25
25
  }>>;
26
26
  /**
27
27
  * Derives a secret key from the provided string for encryption/decryption.
28
28
  * Internally, the key is hashed using SHA-256 to ensure it meets the required length.
29
29
  *
30
- * @param key - The input string to derive the secret key from.
31
- * @returns A WebApiKey object representing the derived secret key.
30
+ * @param secret - The input string to derive the secret key from.
31
+ * @returns A SecretKey object representing the derived secret key.
32
32
  * @throws {Error} If the input key is invalid or key generation fails.
33
33
  */
34
- declare function createSecretKey(key: string): Promise<WebSecretKey>;
34
+ declare function createSecretKey(secret: string, options?: CreateSecretKeyOptions): Promise<SecretKey<'web'>>;
35
35
  /**
36
36
  * Encrypts the input string using the provided secret key.
37
37
  * The output is a string in the format "iv.cipherWithTag." where each component is base64url encoded.
38
38
  *
39
39
  * @param data - The input string to encrypt.
40
- * @param secretKey - The WebApiKey object used for encryption.
40
+ * @param secretKey - The SecretKey object used for encryption.
41
41
  * @returns A Result containing a string representing the encrypted data in the specified format or an error.
42
42
  */
43
- declare function tryEncrypt(data: string, secretKey: WebSecretKey): Promise<Result<string>>;
43
+ declare function tryEncrypt(data: string, secretKey: SecretKey<'web'>, options?: EncryptOptions): Promise<Result<string>>;
44
44
  /**
45
45
  * Encrypts the input string using the provided secret key.
46
46
  * The output is a string in the format "iv.cipherWithTag." where each component is base64url encoded.
47
47
  *
48
48
  * @param data - The input string to encrypt.
49
- * @param secretKey - The WebApiKey object used for encryption.
49
+ * @param secretKey - The SecretKey object used for encryption.
50
50
  * @returns A string representing the encrypted data in the specified format.
51
51
  * @throws {Error} If the input data or key is invalid, or if encryption fails.
52
52
  */
53
- declare function encrypt(data: string, secretKey: WebSecretKey): Promise<string>;
53
+ declare function encrypt(data: string, secretKey: SecretKey<'web'>, options?: EncryptOptions): Promise<string>;
54
54
  /**
55
55
  * Decrypts the input string using the provided secret key.
56
56
  * The input must be in the format "iv.cipherWithTag." where each component is base64url encoded.
57
57
  *
58
58
  * @param encrypted - The input string to decrypt.
59
- * @param secretKey - The WebApiKey object used for decryption.
59
+ * @param secretKey - The SecretKey object used for decryption.
60
60
  * @returns A Result containing a string representing the decrypted data or an error.
61
61
  */
62
- declare function tryDecrypt(encrypted: string, secretKey: WebSecretKey): Promise<Result<string>>;
62
+ declare function tryDecrypt(encrypted: string, secretKey: SecretKey<'web'>, options?: DecryptOptions): Promise<Result<string>>;
63
63
  /**
64
64
  * Decrypts the input string using the provided secret key.
65
65
  * The input must be in the format "iv.cipherWithTag" where each component is base64url encoded.
66
66
  *
67
67
  * @param encrypted - The input string to decrypt.
68
- * @param secretKey - The WebApiKey object used for decryption.
68
+ * @param secretKey - The SecretKey object used for decryption.
69
69
  * @returns A string representing the decrypted data.
70
70
  * @throws {Error} If the input data or key is invalid, or if decryption fails.
71
71
  */
72
- declare function decrypt(encrypted: string, secretKey: WebSecretKey): Promise<string>;
72
+ declare function decrypt(encrypted: string, secretKey: SecretKey<'web'>, options?: DecryptOptions): Promise<string>;
73
73
  /**
74
74
  * Encrypts the input object using the provided secret key.
75
75
  * The object is first serialized to a JSON string before encryption.
76
76
  * The output is a string in the format "iv.cipherWithTag." where each component is base64url encoded.
77
77
  *
78
78
  * @param data - The input object to encrypt.
79
- * @param secretKey - The WebApiKey object used for encryption.
79
+ * @param secretKey - The SecretKey object used for encryption.
80
80
  * @returns A Result containing a string representing the encrypted object in the specified format or an error.
81
81
  */
82
- declare function tryEncryptObj<T extends object = Record<string, unknown>>(data: T, secretKey: WebSecretKey): Promise<Result<string>>;
82
+ declare function tryEncryptObj<T extends object = Record<string, unknown>>(data: T, secretKey: SecretKey<'web'>, options?: EncryptOptions): Promise<Result<string>>;
83
83
  /**
84
84
  * Encrypts the input object using the provided secret key.
85
85
  * The object is first serialized to a JSON string before encryption.
86
86
  * The output is a string in the format "iv.cipherWithTag." where each component is base64url encoded.
87
87
  *
88
88
  * @param data - The input object to encrypt.
89
- * @param secretKey - The WebApiKey object used for encryption.
89
+ * @param secretKey - The SecretKey object used for encryption.
90
90
  * @returns A string representing the encrypted object in the specified format.
91
91
  * @throws {Error} If the input data or key is invalid, or if encryption fails.
92
92
  */
93
- declare function encryptObj<T extends object = Record<string, unknown>>(data: T, secretKey: WebSecretKey): Promise<string>;
93
+ declare function encryptObj<T extends object = Record<string, unknown>>(data: T, secretKey: SecretKey<'web'>, options?: EncryptOptions): Promise<string>;
94
94
  /**
95
95
  * Decrypts the input string to an object using the provided secret key.
96
96
  * The input must be in the format "iv.cipherWithTag." where each component is base64url encoded.
97
97
  * The decrypted string is parsed as JSON to reconstruct the original object.
98
98
  *
99
99
  * @param encrypted - The input string to decrypt.
100
- * @param secretKey - The WebApiKey object used for decryption.
100
+ * @param secretKey - The SecretKey object used for decryption.
101
101
  * @returns A Result containing an object representing the decrypted data or an error.
102
102
  */
103
- declare function tryDecryptObj<T extends object = Record<string, unknown>>(encrypted: string, secretKey: WebSecretKey): Promise<Result<{
103
+ declare function tryDecryptObj<T extends object = Record<string, unknown>>(encrypted: string, secretKey: SecretKey<'web'>, options?: DecryptOptions): Promise<Result<{
104
104
  result: T;
105
105
  }>>;
106
106
  /**
@@ -109,20 +109,18 @@ declare function tryDecryptObj<T extends object = Record<string, unknown>>(encry
109
109
  * The decrypted string is parsed as JSON to reconstruct the original object.
110
110
  *
111
111
  * @param encrypted - The input string to decrypt.
112
- * @param secretKey - The WebApiKey object used for decryption.
112
+ * @param secretKey - The SecretKey object used for decryption.
113
113
  * @returns An object representing the decrypted data.
114
114
  * @throws {Error} If the input data or key is invalid, or if decryption fails.
115
115
  */
116
- declare function decryptObj<T extends object = Record<string, unknown>>(encrypted: string, secretKey: WebSecretKey): Promise<{
117
- result: T;
118
- }>;
116
+ declare function decryptObj<T extends object = Record<string, unknown>>(encrypted: string, secretKey: SecretKey<'web'>, options?: DecryptOptions): Promise<T>;
119
117
  /**
120
118
  * Hashes the input string using SHA-256 and returns the hash in base64url format.
121
119
  *
122
120
  * @param data - The input string to hash.
123
121
  * @returns A Result containing a string representing the SHA-256 hash in base64url format or an error.
124
122
  */
125
- declare function tryHash(data: string): Promise<Result<string>>;
123
+ declare function tryHash(data: string, options?: HashOptions): Promise<Result<string>>;
126
124
  /**
127
125
  * Hashes the input string using SHA-256 and returns the hash in base64url format.
128
126
  *
@@ -130,14 +128,14 @@ declare function tryHash(data: string): Promise<Result<string>>;
130
128
  * @returns A string representing the SHA-256 hash in base64url format.
131
129
  * @throws {Error} If the input data is invalid or hashing fails.
132
130
  */
133
- declare function hash(data: string): Promise<string>;
131
+ declare function hash(data: string, options?: HashOptions): Promise<string>;
134
132
  /**
135
133
  * Hashes a password using PBKDF2 with SHA-512.
136
134
  *
137
135
  * @param password - The password to hash.
138
136
  * @returns A Result containing an object with the hash and salt, or an error.
139
137
  */
140
- declare function tryHashPassword(password: string): Promise<Result<{
138
+ declare function tryHashPassword(password: string, options?: HashPasswordOptions): Promise<Result<{
141
139
  hash: string;
142
140
  salt: string;
143
141
  }>>;
@@ -148,7 +146,7 @@ declare function tryHashPassword(password: string): Promise<Result<{
148
146
  * @returns An object with the hash and salt.
149
147
  * @throws {Error} If the input password is invalid or hashing fails.
150
148
  */
151
- declare function hashPassword(password: string): Promise<{
149
+ declare function hashPassword(password: string, options?: HashPasswordOptions): Promise<{
152
150
  hash: string;
153
151
  salt: string;
154
152
  }>;
@@ -160,16 +158,16 @@ declare function hashPassword(password: string): Promise<{
160
158
  * @param salt - The salt used during hashing (in base64url format).
161
159
  * @returns A boolean indicating whether the password matches the hashed password.
162
160
  */
163
- declare function verifyPassword(password: string, hashedPassword: string, salt: string): Promise<boolean>;
161
+ declare function verifyPassword(password: string, hashedPassword: string, salt: string, options?: VerifyPasswordOptions): Promise<boolean>;
164
162
  /**
165
163
  * Converts a string to a Buffer (byte array) using the specified encoding format.
166
164
  * Supported formats: 'base64', 'base64url', 'hex', 'utf8', 'latin1'.
167
165
  *
168
166
  * @param data - The input string to convert.
169
- * @param format - The encoding format to use (default is 'utf8').
167
+ * @param inputEncoding - The encoding format to use (default is 'utf8').
170
168
  * @returns A Result containing a Uint8Array with the encoded data or an error.
171
169
  */
172
- declare function tryConvertStrToBytes(data: string, format?: EncodingFormat): Result<{
170
+ declare function tryConvertStrToBytes(data: string, inputEncoding?: Encoding): Result<{
173
171
  result: Uint8Array<ArrayBuffer>;
174
172
  }>;
175
173
  /**
@@ -177,30 +175,30 @@ declare function tryConvertStrToBytes(data: string, format?: EncodingFormat): Re
177
175
  * Supported formats: 'base64', 'base64url', 'hex', 'utf8', 'latin1'.
178
176
  *
179
177
  * @param data - The input string to convert.
180
- * @param format - The encoding format to use (default is 'utf8').
178
+ * @param inputEncoding - The encoding format to use (default is 'utf8').
181
179
  * @returns A Uint8Array containing the encoded data.
182
180
  * @throws {Error} If the input data is invalid or conversion fails.
183
181
  */
184
- declare function convertStrToBytes(data: string, format?: EncodingFormat): Uint8Array<ArrayBuffer>;
182
+ declare function convertStrToBytes(data: string, inputEncoding?: Encoding): Uint8Array<ArrayBuffer>;
185
183
  /**
186
184
  * Converts a Uint8Array or ArrayBuffer (byte array) to a string using the specified encoding format.
187
185
  * Supported formats: 'base64', 'base64url', 'hex', 'utf8', 'latin1'.
188
186
  *
189
187
  * @param data - The input Uint8Array or ArrayBuffer to convert.
190
- * @param format - The encoding format to use (default is 'utf8').
188
+ * @param outputEncoding - The encoding format to use (default is 'utf8').
191
189
  * @returns A Result containing the string representation of the Uint8Array or an error.
192
190
  */
193
- declare function tryConvertBytesToStr(data: Uint8Array | ArrayBuffer, format?: EncodingFormat): Result<string>;
191
+ declare function tryConvertBytesToStr(data: Uint8Array | ArrayBuffer, outputEncoding?: Encoding): Result<string>;
194
192
  /**
195
193
  * Converts a Uint8Array or ArrayBuffer (byte array) to a string using the specified encoding format.
196
194
  * Supported formats: 'base64', 'base64url', 'hex', 'utf8', 'latin1'.
197
195
  *
198
196
  * @param data - The input Uint8Array or ArrayBuffer to convert.
199
- * @param format - The encoding format to use (default is 'utf8').
197
+ * @param outputEncoding - The encoding format to use (default is 'utf8').
200
198
  * @returns A string representation of the Uint8Array in the specified format.
201
199
  * @throws {Error} If the input data is invalid or conversion fails.
202
200
  */
203
- declare function convertBytesToStr(data: Uint8Array | ArrayBuffer, format?: EncodingFormat): string;
201
+ declare function convertBytesToStr(data: Uint8Array | ArrayBuffer, outputEncoding?: Encoding): string;
204
202
  /**
205
203
  * Convert data from one encoding format to another.
206
204
  *
@@ -209,7 +207,7 @@ declare function convertBytesToStr(data: Uint8Array | ArrayBuffer, format?: Enco
209
207
  * @param to - The encoding format to convert to.
210
208
  * @returns A Result containing the converted string or an error.
211
209
  */
212
- declare function tryConvertFormat(data: string, from: EncodingFormat, to: EncodingFormat): Result<{
210
+ declare function tryConvertEncoding(data: string, from: Encoding, to: Encoding): Result<{
213
211
  result: string;
214
212
  }>;
215
213
  /**
@@ -221,10 +219,10 @@ declare function tryConvertFormat(data: string, from: EncodingFormat, to: Encodi
221
219
  * @returns A converted string.
222
220
  * @throws {Error} If the input data is invalid or conversion fails.
223
221
  */
224
- declare function convertFormat(data: string, from: EncodingFormat, to: EncodingFormat): string;
222
+ declare function convertEncoding(data: string, from: Encoding, to: Encoding): string;
225
223
 
226
224
  declare const kit_convertBytesToStr: typeof convertBytesToStr;
227
- declare const kit_convertFormat: typeof convertFormat;
225
+ declare const kit_convertEncoding: typeof convertEncoding;
228
226
  declare const kit_convertStrToBytes: typeof convertStrToBytes;
229
227
  declare const kit_createSecretKey: typeof createSecretKey;
230
228
  declare const kit_decrypt: typeof decrypt;
@@ -234,9 +232,8 @@ declare const kit_encryptObj: typeof encryptObj;
234
232
  declare const kit_generateUuid: typeof generateUuid;
235
233
  declare const kit_hash: typeof hash;
236
234
  declare const kit_hashPassword: typeof hashPassword;
237
- declare const kit_isWebSecretKey: typeof isWebSecretKey;
238
235
  declare const kit_tryConvertBytesToStr: typeof tryConvertBytesToStr;
239
- declare const kit_tryConvertFormat: typeof tryConvertFormat;
236
+ declare const kit_tryConvertEncoding: typeof tryConvertEncoding;
240
237
  declare const kit_tryConvertStrToBytes: typeof tryConvertStrToBytes;
241
238
  declare const kit_tryCreateSecretKey: typeof tryCreateSecretKey;
242
239
  declare const kit_tryDecrypt: typeof tryDecrypt;
@@ -248,7 +245,7 @@ declare const kit_tryHash: typeof tryHash;
248
245
  declare const kit_tryHashPassword: typeof tryHashPassword;
249
246
  declare const kit_verifyPassword: typeof verifyPassword;
250
247
  declare namespace kit {
251
- 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_isWebSecretKey as isWebSecretKey, 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 };
248
+ 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_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_tryHashPassword as tryHashPassword, kit_verifyPassword as verifyPassword };
252
249
  }
253
250
 
254
- 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 };
251
+ 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, tryConvertEncoding as w, convertEncoding as x };
@@ -1,4 +1,4 @@
1
- import { R as Result, W as WebSecretKey, c as EncodingFormat, b as isWebSecretKey } from './validate-CPWPEEAt.js';
1
+ import { R as Result, C as CreateSecretKeyOptions, S as SecretKey, d as EncryptOptions, e as DecryptOptions, H as HashOptions, f as HashPasswordOptions, V as VerifyPasswordOptions, b as Encoding } from './validate-CS4PFmY1.cjs';
2
2
 
3
3
  /**
4
4
  * Generates a UUID (v4).
@@ -17,90 +17,90 @@ declare function generateUuid(): string;
17
17
  * Derives a secret key from the provided string for encryption/decryption.
18
18
  * Internally, the key is hashed using SHA-256 to ensure it meets the required length.
19
19
  *
20
- * @param key - The input string to derive the secret key from.
21
- * @returns A Result containing a WebApiKey object representing the derived secret key or an error.
20
+ * @param secret - The input string to derive the secret key from.
21
+ * @returns A Result containing a SecretKey object representing the derived secret key or an error.
22
22
  */
23
- declare function tryCreateSecretKey(key: string): Promise<Result<{
24
- result: WebSecretKey;
23
+ declare function tryCreateSecretKey(secret: string, options?: CreateSecretKeyOptions): Promise<Result<{
24
+ result: SecretKey<'web'>;
25
25
  }>>;
26
26
  /**
27
27
  * Derives a secret key from the provided string for encryption/decryption.
28
28
  * Internally, the key is hashed using SHA-256 to ensure it meets the required length.
29
29
  *
30
- * @param key - The input string to derive the secret key from.
31
- * @returns A WebApiKey object representing the derived secret key.
30
+ * @param secret - The input string to derive the secret key from.
31
+ * @returns A SecretKey object representing the derived secret key.
32
32
  * @throws {Error} If the input key is invalid or key generation fails.
33
33
  */
34
- declare function createSecretKey(key: string): Promise<WebSecretKey>;
34
+ declare function createSecretKey(secret: string, options?: CreateSecretKeyOptions): Promise<SecretKey<'web'>>;
35
35
  /**
36
36
  * Encrypts the input string using the provided secret key.
37
37
  * The output is a string in the format "iv.cipherWithTag." where each component is base64url encoded.
38
38
  *
39
39
  * @param data - The input string to encrypt.
40
- * @param secretKey - The WebApiKey object used for encryption.
40
+ * @param secretKey - The SecretKey object used for encryption.
41
41
  * @returns A Result containing a string representing the encrypted data in the specified format or an error.
42
42
  */
43
- declare function tryEncrypt(data: string, secretKey: WebSecretKey): Promise<Result<string>>;
43
+ declare function tryEncrypt(data: string, secretKey: SecretKey<'web'>, options?: EncryptOptions): Promise<Result<string>>;
44
44
  /**
45
45
  * Encrypts the input string using the provided secret key.
46
46
  * The output is a string in the format "iv.cipherWithTag." where each component is base64url encoded.
47
47
  *
48
48
  * @param data - The input string to encrypt.
49
- * @param secretKey - The WebApiKey object used for encryption.
49
+ * @param secretKey - The SecretKey object used for encryption.
50
50
  * @returns A string representing the encrypted data in the specified format.
51
51
  * @throws {Error} If the input data or key is invalid, or if encryption fails.
52
52
  */
53
- declare function encrypt(data: string, secretKey: WebSecretKey): Promise<string>;
53
+ declare function encrypt(data: string, secretKey: SecretKey<'web'>, options?: EncryptOptions): Promise<string>;
54
54
  /**
55
55
  * Decrypts the input string using the provided secret key.
56
56
  * The input must be in the format "iv.cipherWithTag." where each component is base64url encoded.
57
57
  *
58
58
  * @param encrypted - The input string to decrypt.
59
- * @param secretKey - The WebApiKey object used for decryption.
59
+ * @param secretKey - The SecretKey object used for decryption.
60
60
  * @returns A Result containing a string representing the decrypted data or an error.
61
61
  */
62
- declare function tryDecrypt(encrypted: string, secretKey: WebSecretKey): Promise<Result<string>>;
62
+ declare function tryDecrypt(encrypted: string, secretKey: SecretKey<'web'>, options?: DecryptOptions): Promise<Result<string>>;
63
63
  /**
64
64
  * Decrypts the input string using the provided secret key.
65
65
  * The input must be in the format "iv.cipherWithTag" where each component is base64url encoded.
66
66
  *
67
67
  * @param encrypted - The input string to decrypt.
68
- * @param secretKey - The WebApiKey object used for decryption.
68
+ * @param secretKey - The SecretKey object used for decryption.
69
69
  * @returns A string representing the decrypted data.
70
70
  * @throws {Error} If the input data or key is invalid, or if decryption fails.
71
71
  */
72
- declare function decrypt(encrypted: string, secretKey: WebSecretKey): Promise<string>;
72
+ declare function decrypt(encrypted: string, secretKey: SecretKey<'web'>, options?: DecryptOptions): Promise<string>;
73
73
  /**
74
74
  * Encrypts the input object using the provided secret key.
75
75
  * The object is first serialized to a JSON string before encryption.
76
76
  * The output is a string in the format "iv.cipherWithTag." where each component is base64url encoded.
77
77
  *
78
78
  * @param data - The input object to encrypt.
79
- * @param secretKey - The WebApiKey object used for encryption.
79
+ * @param secretKey - The SecretKey object used for encryption.
80
80
  * @returns A Result containing a string representing the encrypted object in the specified format or an error.
81
81
  */
82
- declare function tryEncryptObj<T extends object = Record<string, unknown>>(data: T, secretKey: WebSecretKey): Promise<Result<string>>;
82
+ declare function tryEncryptObj<T extends object = Record<string, unknown>>(data: T, secretKey: SecretKey<'web'>, options?: EncryptOptions): Promise<Result<string>>;
83
83
  /**
84
84
  * Encrypts the input object using the provided secret key.
85
85
  * The object is first serialized to a JSON string before encryption.
86
86
  * The output is a string in the format "iv.cipherWithTag." where each component is base64url encoded.
87
87
  *
88
88
  * @param data - The input object to encrypt.
89
- * @param secretKey - The WebApiKey object used for encryption.
89
+ * @param secretKey - The SecretKey object used for encryption.
90
90
  * @returns A string representing the encrypted object in the specified format.
91
91
  * @throws {Error} If the input data or key is invalid, or if encryption fails.
92
92
  */
93
- declare function encryptObj<T extends object = Record<string, unknown>>(data: T, secretKey: WebSecretKey): Promise<string>;
93
+ declare function encryptObj<T extends object = Record<string, unknown>>(data: T, secretKey: SecretKey<'web'>, options?: EncryptOptions): Promise<string>;
94
94
  /**
95
95
  * Decrypts the input string to an object using the provided secret key.
96
96
  * The input must be in the format "iv.cipherWithTag." where each component is base64url encoded.
97
97
  * The decrypted string is parsed as JSON to reconstruct the original object.
98
98
  *
99
99
  * @param encrypted - The input string to decrypt.
100
- * @param secretKey - The WebApiKey object used for decryption.
100
+ * @param secretKey - The SecretKey object used for decryption.
101
101
  * @returns A Result containing an object representing the decrypted data or an error.
102
102
  */
103
- declare function tryDecryptObj<T extends object = Record<string, unknown>>(encrypted: string, secretKey: WebSecretKey): Promise<Result<{
103
+ declare function tryDecryptObj<T extends object = Record<string, unknown>>(encrypted: string, secretKey: SecretKey<'web'>, options?: DecryptOptions): Promise<Result<{
104
104
  result: T;
105
105
  }>>;
106
106
  /**
@@ -109,20 +109,18 @@ declare function tryDecryptObj<T extends object = Record<string, unknown>>(encry
109
109
  * The decrypted string is parsed as JSON to reconstruct the original object.
110
110
  *
111
111
  * @param encrypted - The input string to decrypt.
112
- * @param secretKey - The WebApiKey object used for decryption.
112
+ * @param secretKey - The SecretKey object used for decryption.
113
113
  * @returns An object representing the decrypted data.
114
114
  * @throws {Error} If the input data or key is invalid, or if decryption fails.
115
115
  */
116
- declare function decryptObj<T extends object = Record<string, unknown>>(encrypted: string, secretKey: WebSecretKey): Promise<{
117
- result: T;
118
- }>;
116
+ declare function decryptObj<T extends object = Record<string, unknown>>(encrypted: string, secretKey: SecretKey<'web'>, options?: DecryptOptions): Promise<T>;
119
117
  /**
120
118
  * Hashes the input string using SHA-256 and returns the hash in base64url format.
121
119
  *
122
120
  * @param data - The input string to hash.
123
121
  * @returns A Result containing a string representing the SHA-256 hash in base64url format or an error.
124
122
  */
125
- declare function tryHash(data: string): Promise<Result<string>>;
123
+ declare function tryHash(data: string, options?: HashOptions): Promise<Result<string>>;
126
124
  /**
127
125
  * Hashes the input string using SHA-256 and returns the hash in base64url format.
128
126
  *
@@ -130,14 +128,14 @@ declare function tryHash(data: string): Promise<Result<string>>;
130
128
  * @returns A string representing the SHA-256 hash in base64url format.
131
129
  * @throws {Error} If the input data is invalid or hashing fails.
132
130
  */
133
- declare function hash(data: string): Promise<string>;
131
+ declare function hash(data: string, options?: HashOptions): Promise<string>;
134
132
  /**
135
133
  * Hashes a password using PBKDF2 with SHA-512.
136
134
  *
137
135
  * @param password - The password to hash.
138
136
  * @returns A Result containing an object with the hash and salt, or an error.
139
137
  */
140
- declare function tryHashPassword(password: string): Promise<Result<{
138
+ declare function tryHashPassword(password: string, options?: HashPasswordOptions): Promise<Result<{
141
139
  hash: string;
142
140
  salt: string;
143
141
  }>>;
@@ -148,7 +146,7 @@ declare function tryHashPassword(password: string): Promise<Result<{
148
146
  * @returns An object with the hash and salt.
149
147
  * @throws {Error} If the input password is invalid or hashing fails.
150
148
  */
151
- declare function hashPassword(password: string): Promise<{
149
+ declare function hashPassword(password: string, options?: HashPasswordOptions): Promise<{
152
150
  hash: string;
153
151
  salt: string;
154
152
  }>;
@@ -160,16 +158,16 @@ declare function hashPassword(password: string): Promise<{
160
158
  * @param salt - The salt used during hashing (in base64url format).
161
159
  * @returns A boolean indicating whether the password matches the hashed password.
162
160
  */
163
- declare function verifyPassword(password: string, hashedPassword: string, salt: string): Promise<boolean>;
161
+ declare function verifyPassword(password: string, hashedPassword: string, salt: string, options?: VerifyPasswordOptions): Promise<boolean>;
164
162
  /**
165
163
  * Converts a string to a Buffer (byte array) using the specified encoding format.
166
164
  * Supported formats: 'base64', 'base64url', 'hex', 'utf8', 'latin1'.
167
165
  *
168
166
  * @param data - The input string to convert.
169
- * @param format - The encoding format to use (default is 'utf8').
167
+ * @param inputEncoding - The encoding format to use (default is 'utf8').
170
168
  * @returns A Result containing a Uint8Array with the encoded data or an error.
171
169
  */
172
- declare function tryConvertStrToBytes(data: string, format?: EncodingFormat): Result<{
170
+ declare function tryConvertStrToBytes(data: string, inputEncoding?: Encoding): Result<{
173
171
  result: Uint8Array<ArrayBuffer>;
174
172
  }>;
175
173
  /**
@@ -177,30 +175,30 @@ declare function tryConvertStrToBytes(data: string, format?: EncodingFormat): Re
177
175
  * Supported formats: 'base64', 'base64url', 'hex', 'utf8', 'latin1'.
178
176
  *
179
177
  * @param data - The input string to convert.
180
- * @param format - The encoding format to use (default is 'utf8').
178
+ * @param inputEncoding - The encoding format to use (default is 'utf8').
181
179
  * @returns A Uint8Array containing the encoded data.
182
180
  * @throws {Error} If the input data is invalid or conversion fails.
183
181
  */
184
- declare function convertStrToBytes(data: string, format?: EncodingFormat): Uint8Array<ArrayBuffer>;
182
+ declare function convertStrToBytes(data: string, inputEncoding?: Encoding): Uint8Array<ArrayBuffer>;
185
183
  /**
186
184
  * Converts a Uint8Array or ArrayBuffer (byte array) to a string using the specified encoding format.
187
185
  * Supported formats: 'base64', 'base64url', 'hex', 'utf8', 'latin1'.
188
186
  *
189
187
  * @param data - The input Uint8Array or ArrayBuffer to convert.
190
- * @param format - The encoding format to use (default is 'utf8').
188
+ * @param outputEncoding - The encoding format to use (default is 'utf8').
191
189
  * @returns A Result containing the string representation of the Uint8Array or an error.
192
190
  */
193
- declare function tryConvertBytesToStr(data: Uint8Array | ArrayBuffer, format?: EncodingFormat): Result<string>;
191
+ declare function tryConvertBytesToStr(data: Uint8Array | ArrayBuffer, outputEncoding?: Encoding): Result<string>;
194
192
  /**
195
193
  * Converts a Uint8Array or ArrayBuffer (byte array) to a string using the specified encoding format.
196
194
  * Supported formats: 'base64', 'base64url', 'hex', 'utf8', 'latin1'.
197
195
  *
198
196
  * @param data - The input Uint8Array or ArrayBuffer to convert.
199
- * @param format - The encoding format to use (default is 'utf8').
197
+ * @param outputEncoding - The encoding format to use (default is 'utf8').
200
198
  * @returns A string representation of the Uint8Array in the specified format.
201
199
  * @throws {Error} If the input data is invalid or conversion fails.
202
200
  */
203
- declare function convertBytesToStr(data: Uint8Array | ArrayBuffer, format?: EncodingFormat): string;
201
+ declare function convertBytesToStr(data: Uint8Array | ArrayBuffer, outputEncoding?: Encoding): string;
204
202
  /**
205
203
  * Convert data from one encoding format to another.
206
204
  *
@@ -209,7 +207,7 @@ declare function convertBytesToStr(data: Uint8Array | ArrayBuffer, format?: Enco
209
207
  * @param to - The encoding format to convert to.
210
208
  * @returns A Result containing the converted string or an error.
211
209
  */
212
- declare function tryConvertFormat(data: string, from: EncodingFormat, to: EncodingFormat): Result<{
210
+ declare function tryConvertEncoding(data: string, from: Encoding, to: Encoding): Result<{
213
211
  result: string;
214
212
  }>;
215
213
  /**
@@ -221,10 +219,10 @@ declare function tryConvertFormat(data: string, from: EncodingFormat, to: Encodi
221
219
  * @returns A converted string.
222
220
  * @throws {Error} If the input data is invalid or conversion fails.
223
221
  */
224
- declare function convertFormat(data: string, from: EncodingFormat, to: EncodingFormat): string;
222
+ declare function convertEncoding(data: string, from: Encoding, to: Encoding): string;
225
223
 
226
224
  declare const kit_convertBytesToStr: typeof convertBytesToStr;
227
- declare const kit_convertFormat: typeof convertFormat;
225
+ declare const kit_convertEncoding: typeof convertEncoding;
228
226
  declare const kit_convertStrToBytes: typeof convertStrToBytes;
229
227
  declare const kit_createSecretKey: typeof createSecretKey;
230
228
  declare const kit_decrypt: typeof decrypt;
@@ -234,9 +232,8 @@ declare const kit_encryptObj: typeof encryptObj;
234
232
  declare const kit_generateUuid: typeof generateUuid;
235
233
  declare const kit_hash: typeof hash;
236
234
  declare const kit_hashPassword: typeof hashPassword;
237
- declare const kit_isWebSecretKey: typeof isWebSecretKey;
238
235
  declare const kit_tryConvertBytesToStr: typeof tryConvertBytesToStr;
239
- declare const kit_tryConvertFormat: typeof tryConvertFormat;
236
+ declare const kit_tryConvertEncoding: typeof tryConvertEncoding;
240
237
  declare const kit_tryConvertStrToBytes: typeof tryConvertStrToBytes;
241
238
  declare const kit_tryCreateSecretKey: typeof tryCreateSecretKey;
242
239
  declare const kit_tryDecrypt: typeof tryDecrypt;
@@ -248,7 +245,7 @@ declare const kit_tryHash: typeof tryHash;
248
245
  declare const kit_tryHashPassword: typeof tryHashPassword;
249
246
  declare const kit_verifyPassword: typeof verifyPassword;
250
247
  declare namespace kit {
251
- 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_isWebSecretKey as isWebSecretKey, 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 };
248
+ 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_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_tryHashPassword as tryHashPassword, kit_verifyPassword as verifyPassword };
252
249
  }
253
250
 
254
- 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 };
251
+ 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, tryConvertEncoding as w, convertEncoding as x };