cipher-kit 2.1.1 → 2.1.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 (39) hide show
  1. package/dist/{chunk-LTVOIZP5.cjs → chunk-66WIL32E.cjs} +145 -150
  2. package/dist/chunk-66WIL32E.cjs.map +1 -0
  3. package/dist/{chunk-X4CS7UXE.cjs → chunk-HTRGOBZF.cjs} +10 -2
  4. package/dist/chunk-HTRGOBZF.cjs.map +1 -0
  5. package/dist/{chunk-FSEA3UXJ.js → chunk-JLFVTZY4.js} +4 -8
  6. package/dist/chunk-JLFVTZY4.js.map +1 -0
  7. package/dist/{chunk-6C4NIWQ4.js → chunk-LU7QOSQH.js} +9 -3
  8. package/dist/chunk-LU7QOSQH.js.map +1 -0
  9. package/dist/{chunk-PWTFVMW6.js → chunk-S6SNCTU6.js} +4 -8
  10. package/dist/chunk-S6SNCTU6.js.map +1 -0
  11. package/dist/{chunk-56PVVFVM.cjs → chunk-ZNM5M6RD.cjs} +140 -145
  12. package/dist/chunk-ZNM5M6RD.cjs.map +1 -0
  13. package/dist/{export-DUgIcobC.d.ts → export-BaM_OTFk.d.ts} +13 -31
  14. package/dist/{export-C4DbO5zM.d.ts → export-CCTGAosO.d.ts} +13 -31
  15. package/dist/{export-CpZ7s25O.d.cts → export-FYHgb-8E.d.cts} +13 -31
  16. package/dist/{export-DO9n7Np-.d.cts → export-KFT0YyMg.d.cts} +13 -31
  17. package/dist/index.cjs +19 -11
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +3 -3
  20. package/dist/index.d.ts +3 -3
  21. package/dist/index.js +3 -3
  22. package/dist/index.js.map +1 -1
  23. package/dist/node.cjs +35 -35
  24. package/dist/node.d.cts +2 -2
  25. package/dist/node.d.ts +2 -2
  26. package/dist/node.js +2 -2
  27. package/dist/{validate-cJEdGlj1.d.cts → validate-lkJAHCeJ.d.cts} +39 -11
  28. package/dist/{validate-cJEdGlj1.d.ts → validate-lkJAHCeJ.d.ts} +39 -11
  29. package/dist/web-api.cjs +35 -35
  30. package/dist/web-api.d.cts +2 -2
  31. package/dist/web-api.d.ts +2 -2
  32. package/dist/web-api.js +2 -2
  33. package/package.json +1 -1
  34. package/dist/chunk-56PVVFVM.cjs.map +0 -1
  35. package/dist/chunk-6C4NIWQ4.js.map +0 -1
  36. package/dist/chunk-FSEA3UXJ.js.map +0 -1
  37. package/dist/chunk-LTVOIZP5.cjs.map +0 -1
  38. package/dist/chunk-PWTFVMW6.js.map +0 -1
  39. package/dist/chunk-X4CS7UXE.cjs.map +0 -1
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkX4CS7UXE_cjs = require('./chunk-X4CS7UXE.cjs');
3
+ var chunkHTRGOBZF_cjs = require('./chunk-HTRGOBZF.cjs');
4
4
  var buffer = require('buffer');
5
5
  var nodeCrypto = require('crypto');
6
6
 
@@ -10,7 +10,7 @@ var nodeCrypto__default = /*#__PURE__*/_interopDefault(nodeCrypto);
10
10
 
11
11
  // src/node/kit.ts
12
12
  var kit_exports = {};
13
- chunkX4CS7UXE_cjs.__export(kit_exports, {
13
+ chunkHTRGOBZF_cjs.__export(kit_exports, {
14
14
  convertBytesToStr: () => convertBytesToStr,
15
15
  convertEncoding: () => convertEncoding,
16
16
  convertStrToBytes: () => convertStrToBytes,
@@ -22,7 +22,6 @@ chunkX4CS7UXE_cjs.__export(kit_exports, {
22
22
  generateUuid: () => generateUuid,
23
23
  hash: () => hash,
24
24
  hashPassword: () => hashPassword,
25
- isNodeSecretKey: () => isNodeSecretKey,
26
25
  tryConvertBytesToStr: () => tryConvertBytesToStr,
27
26
  tryConvertEncoding: () => tryConvertEncoding,
28
27
  tryConvertStrToBytes: () => tryConvertStrToBytes,
@@ -37,112 +36,112 @@ chunkX4CS7UXE_cjs.__export(kit_exports, {
37
36
  verifyPassword: () => verifyPassword
38
37
  });
39
38
  function $convertStrToBytes(data, inputEncoding = "utf8") {
40
- if (!chunkX4CS7UXE_cjs.$isStr(data)) {
41
- return chunkX4CS7UXE_cjs.$err({
39
+ if (!chunkHTRGOBZF_cjs.$isStr(data)) {
40
+ return chunkHTRGOBZF_cjs.$err({
42
41
  msg: "Crypto NodeJS API - String to Bytes: Empty data",
43
42
  desc: "Data must be a non-empty string"
44
43
  });
45
44
  }
46
- if (!chunkX4CS7UXE_cjs.ENCODING.includes(inputEncoding)) {
47
- return chunkX4CS7UXE_cjs.$err({
45
+ if (!chunkHTRGOBZF_cjs.ENCODING.includes(inputEncoding)) {
46
+ return chunkHTRGOBZF_cjs.$err({
48
47
  msg: `Crypto NodeJS API - String to Bytes: Unsupported encoding: ${inputEncoding}`,
49
48
  desc: "Use base64, base64url, hex, utf8, or latin1"
50
49
  });
51
50
  }
52
51
  try {
53
- return chunkX4CS7UXE_cjs.$ok({ result: buffer.Buffer.from(data, inputEncoding) });
52
+ return chunkHTRGOBZF_cjs.$ok({ result: buffer.Buffer.from(data, inputEncoding) });
54
53
  } catch (error) {
55
- return chunkX4CS7UXE_cjs.$err({ msg: "Crypto NodeJS API - String to Bytes: Failed to convert data", desc: chunkX4CS7UXE_cjs.$fmtError(error) });
54
+ return chunkHTRGOBZF_cjs.$err({ msg: "Crypto NodeJS API - String to Bytes: Failed to convert data", desc: chunkHTRGOBZF_cjs.$fmtError(error) });
56
55
  }
57
56
  }
58
57
  function $convertBytesToStr(data, outputEncoding = "utf8") {
59
58
  if (!(data instanceof buffer.Buffer)) {
60
- return chunkX4CS7UXE_cjs.$err({
59
+ return chunkHTRGOBZF_cjs.$err({
61
60
  msg: "Crypto NodeJS API - Bytes to String: Invalid data type",
62
61
  desc: "Data must be a Buffer"
63
62
  });
64
63
  }
65
- if (!chunkX4CS7UXE_cjs.ENCODING.includes(outputEncoding)) {
66
- return chunkX4CS7UXE_cjs.$err({
64
+ if (!chunkHTRGOBZF_cjs.ENCODING.includes(outputEncoding)) {
65
+ return chunkHTRGOBZF_cjs.$err({
67
66
  msg: `Crypto NodeJS API - Bytes to String: Unsupported encoding: ${outputEncoding}`,
68
67
  desc: "Use base64, base64url, hex, utf8, or latin1"
69
68
  });
70
69
  }
71
70
  try {
72
- return chunkX4CS7UXE_cjs.$ok(buffer.Buffer.from(data).toString(outputEncoding));
71
+ return chunkHTRGOBZF_cjs.$ok(buffer.Buffer.from(data).toString(outputEncoding));
73
72
  } catch (error) {
74
- return chunkX4CS7UXE_cjs.$err({ msg: "Crypto NodeJS API - Bytes to String: Failed to convert data", desc: chunkX4CS7UXE_cjs.$fmtError(error) });
73
+ return chunkHTRGOBZF_cjs.$err({ msg: "Crypto NodeJS API - Bytes to String: Failed to convert data", desc: chunkHTRGOBZF_cjs.$fmtError(error) });
75
74
  }
76
75
  }
77
76
  function $convertEncoding(data, from, to) {
78
- if (!chunkX4CS7UXE_cjs.$isStr(data)) {
79
- return chunkX4CS7UXE_cjs.$err({
77
+ if (!chunkHTRGOBZF_cjs.$isStr(data)) {
78
+ return chunkHTRGOBZF_cjs.$err({
80
79
  msg: "Crypto NodeJS API - Convert Format: Empty data",
81
80
  desc: "Data must be a non-empty string"
82
81
  });
83
82
  }
84
- if (!chunkX4CS7UXE_cjs.ENCODING.includes(from) || !chunkX4CS7UXE_cjs.ENCODING.includes(to)) {
85
- return chunkX4CS7UXE_cjs.$err({
83
+ if (!chunkHTRGOBZF_cjs.ENCODING.includes(from) || !chunkHTRGOBZF_cjs.ENCODING.includes(to)) {
84
+ return chunkHTRGOBZF_cjs.$err({
86
85
  msg: `Crypto NodeJS API - Convert Format: Unsupported encoding: from ${from} to ${to}`,
87
86
  desc: "Use base64, base64url, hex, utf8, or latin1"
88
87
  });
89
88
  }
90
89
  const bytes = $convertStrToBytes(data, from);
91
- if (bytes.error) return chunkX4CS7UXE_cjs.$err({ msg: bytes.error.message, desc: bytes.error.description });
90
+ if (bytes.error) return chunkHTRGOBZF_cjs.$err({ msg: bytes.error.message, desc: bytes.error.description });
92
91
  const str = $convertBytesToStr(bytes.result, to);
93
- if (str.error) return chunkX4CS7UXE_cjs.$err({ msg: str.error.message, desc: str.error.description });
94
- return chunkX4CS7UXE_cjs.$ok({ result: str.result });
92
+ if (str.error) return chunkHTRGOBZF_cjs.$err({ msg: str.error.message, desc: str.error.description });
93
+ return chunkHTRGOBZF_cjs.$ok({ result: str.result });
95
94
  }
96
95
  function $generateUuid() {
97
96
  try {
98
- return chunkX4CS7UXE_cjs.$ok(nodeCrypto__default.default.randomUUID());
97
+ return chunkHTRGOBZF_cjs.$ok(nodeCrypto__default.default.randomUUID());
99
98
  } catch (error) {
100
- return chunkX4CS7UXE_cjs.$err({ msg: `${chunkX4CS7UXE_cjs.title("node", "UUID Generation")}: Failed to generate UUID`, desc: chunkX4CS7UXE_cjs.$fmtError(error) });
99
+ return chunkHTRGOBZF_cjs.$err({ msg: `${chunkHTRGOBZF_cjs.title("node", "UUID Generation")}: Failed to generate UUID`, desc: chunkHTRGOBZF_cjs.$fmtError(error) });
101
100
  }
102
101
  }
103
102
  function $createSecretKey(secret, options) {
104
- if (!chunkX4CS7UXE_cjs.$isStr(secret, 8)) {
105
- return chunkX4CS7UXE_cjs.$err({
106
- msg: `${chunkX4CS7UXE_cjs.title("node", "Key Generation")}: Empty Secret`,
103
+ if (!chunkHTRGOBZF_cjs.$isStr(secret, 8)) {
104
+ return chunkHTRGOBZF_cjs.$err({
105
+ msg: `${chunkHTRGOBZF_cjs.title("node", "Key Generation")}: Empty Secret`,
107
106
  desc: "Secret must be a non-empty string with at least 8 characters"
108
107
  });
109
108
  }
110
- if (!chunkX4CS7UXE_cjs.$isPlainObj(options)) {
111
- return chunkX4CS7UXE_cjs.$err({
112
- msg: `${chunkX4CS7UXE_cjs.title("node", "Key Generation")}: Invalid options`,
109
+ if (!chunkHTRGOBZF_cjs.$isPlainObj(options)) {
110
+ return chunkHTRGOBZF_cjs.$err({
111
+ msg: `${chunkHTRGOBZF_cjs.title("node", "Key Generation")}: Invalid options`,
113
112
  desc: "Options must be an object"
114
113
  });
115
114
  }
116
115
  const algorithm = options.algorithm ?? "aes256gcm";
117
- if (!(algorithm in chunkX4CS7UXE_cjs.ENCRYPTION_ALGORITHMS)) {
118
- return chunkX4CS7UXE_cjs.$err({
119
- msg: `${chunkX4CS7UXE_cjs.title("node", "Key Generation")}: Unsupported algorithm: ${algorithm}`,
120
- desc: `Supported algorithms are: ${Object.keys(chunkX4CS7UXE_cjs.ENCRYPTION_ALGORITHMS).join(", ")}`
116
+ if (!(algorithm in chunkHTRGOBZF_cjs.ENCRYPTION_ALGORITHMS)) {
117
+ return chunkHTRGOBZF_cjs.$err({
118
+ msg: `${chunkHTRGOBZF_cjs.title("node", "Key Generation")}: Unsupported algorithm: ${algorithm}`,
119
+ desc: `Supported algorithms are: ${Object.keys(chunkHTRGOBZF_cjs.ENCRYPTION_ALGORITHMS).join(", ")}`
121
120
  });
122
121
  }
123
122
  const digest = options.digest ?? "sha256";
124
- if (!(digest in chunkX4CS7UXE_cjs.DIGEST_ALGORITHMS)) {
125
- return chunkX4CS7UXE_cjs.$err({
126
- msg: `${chunkX4CS7UXE_cjs.title("node", "Key Generation")}: Unsupported digest: ${digest}`,
127
- desc: `Supported digests are: ${Object.keys(chunkX4CS7UXE_cjs.DIGEST_ALGORITHMS).join(", ")}`
123
+ if (!(digest in chunkHTRGOBZF_cjs.DIGEST_ALGORITHMS)) {
124
+ return chunkHTRGOBZF_cjs.$err({
125
+ msg: `${chunkHTRGOBZF_cjs.title("node", "Key Generation")}: Unsupported digest: ${digest}`,
126
+ desc: `Supported digests are: ${Object.keys(chunkHTRGOBZF_cjs.DIGEST_ALGORITHMS).join(", ")}`
128
127
  });
129
128
  }
130
129
  const salt = options.salt ?? "cipher-kit-salt";
131
- if (!chunkX4CS7UXE_cjs.$isStr(salt, 8)) {
132
- return chunkX4CS7UXE_cjs.$err({
133
- msg: `${chunkX4CS7UXE_cjs.title("node", "Key Generation")}: Weak salt`,
130
+ if (!chunkHTRGOBZF_cjs.$isStr(salt, 8)) {
131
+ return chunkHTRGOBZF_cjs.$err({
132
+ msg: `${chunkHTRGOBZF_cjs.title("node", "Key Generation")}: Weak salt`,
134
133
  desc: "Salt must be a non-empty string with at least 8 characters"
135
134
  });
136
135
  }
137
136
  const info = options.info ?? "cipher-kit";
138
- if (!chunkX4CS7UXE_cjs.$isStr(info)) {
139
- return chunkX4CS7UXE_cjs.$err({
140
- msg: `${chunkX4CS7UXE_cjs.title("node", "Key Generation")}: Invalid info`,
137
+ if (!chunkHTRGOBZF_cjs.$isStr(info)) {
138
+ return chunkHTRGOBZF_cjs.$err({
139
+ msg: `${chunkHTRGOBZF_cjs.title("node", "Key Generation")}: Invalid info`,
141
140
  desc: "Info must be a non-empty string"
142
141
  });
143
142
  }
144
- const encryptAlgo = chunkX4CS7UXE_cjs.ENCRYPTION_ALGORITHMS[algorithm];
145
- const digestAlgo = chunkX4CS7UXE_cjs.DIGEST_ALGORITHMS[digest];
143
+ const encryptAlgo = chunkHTRGOBZF_cjs.ENCRYPTION_ALGORITHMS[algorithm];
144
+ const digestAlgo = chunkHTRGOBZF_cjs.DIGEST_ALGORITHMS[digest];
146
145
  try {
147
146
  const derivedKey = nodeCrypto__default.default.hkdfSync(
148
147
  digestAlgo.node,
@@ -158,40 +157,40 @@ function $createSecretKey(secret, options) {
158
157
  algorithm,
159
158
  key
160
159
  });
161
- return chunkX4CS7UXE_cjs.$ok({ result: secretKey });
160
+ return chunkHTRGOBZF_cjs.$ok({ result: secretKey });
162
161
  } catch (error) {
163
- return chunkX4CS7UXE_cjs.$err({ msg: `${chunkX4CS7UXE_cjs.title("node", "Key Generation")}: Failed to create secret key`, desc: chunkX4CS7UXE_cjs.$fmtError(error) });
162
+ return chunkHTRGOBZF_cjs.$err({ msg: `${chunkHTRGOBZF_cjs.title("node", "Key Generation")}: Failed to create secret key`, desc: chunkHTRGOBZF_cjs.$fmtError(error) });
164
163
  }
165
164
  }
166
165
  function $encrypt(data, secretKey, options) {
167
- if (!chunkX4CS7UXE_cjs.$isStr(data)) {
168
- return chunkX4CS7UXE_cjs.$err({
169
- msg: `${chunkX4CS7UXE_cjs.title("node", "Encryption")}: Empty data for encryption`,
166
+ if (!chunkHTRGOBZF_cjs.$isStr(data)) {
167
+ return chunkHTRGOBZF_cjs.$err({
168
+ msg: `${chunkHTRGOBZF_cjs.title("node", "Encryption")}: Empty data for encryption`,
170
169
  desc: "Data must be a non-empty string"
171
170
  });
172
171
  }
173
- if (!chunkX4CS7UXE_cjs.$isPlainObj(options)) {
174
- return chunkX4CS7UXE_cjs.$err({
175
- msg: `${chunkX4CS7UXE_cjs.title("node", "Encryption")}: Invalid options`,
172
+ if (!chunkHTRGOBZF_cjs.$isPlainObj(options)) {
173
+ return chunkHTRGOBZF_cjs.$err({
174
+ msg: `${chunkHTRGOBZF_cjs.title("node", "Encryption")}: Invalid options`,
176
175
  desc: "Options must be an object"
177
176
  });
178
177
  }
179
178
  const outputEncoding = options.outputEncoding ?? "base64url";
180
- if (!chunkX4CS7UXE_cjs.CIPHER_ENCODING.includes(outputEncoding)) {
181
- return chunkX4CS7UXE_cjs.$err({
182
- msg: `${chunkX4CS7UXE_cjs.title("node", "Encryption")}: Unsupported output encoding: ${outputEncoding}`,
179
+ if (!chunkHTRGOBZF_cjs.CIPHER_ENCODING.includes(outputEncoding)) {
180
+ return chunkHTRGOBZF_cjs.$err({
181
+ msg: `${chunkHTRGOBZF_cjs.title("node", "Encryption")}: Unsupported output encoding: ${outputEncoding}`,
183
182
  desc: "Use base64, base64url, or hex"
184
183
  });
185
184
  }
186
- const injectedKey = chunkX4CS7UXE_cjs.$isSecretKey(secretKey, "node");
185
+ const injectedKey = chunkHTRGOBZF_cjs.$isSecretKey(secretKey, "node");
187
186
  if (!injectedKey) {
188
- return chunkX4CS7UXE_cjs.$err({
189
- msg: `${chunkX4CS7UXE_cjs.title("node", "Encryption")}: Invalid Secret Key`,
187
+ return chunkHTRGOBZF_cjs.$err({
188
+ msg: `${chunkHTRGOBZF_cjs.title("node", "Encryption")}: Invalid Secret Key`,
190
189
  desc: "Expected a Node SecretKey"
191
190
  });
192
191
  }
193
192
  const { result, error } = $convertStrToBytes(data, "utf8");
194
- if (error) return chunkX4CS7UXE_cjs.$err(error);
193
+ if (error) return chunkHTRGOBZF_cjs.$err(error);
195
194
  try {
196
195
  const iv = nodeCrypto__default.default.randomBytes(injectedKey.injected.ivLength);
197
196
  const cipher = nodeCrypto__default.default.createCipheriv(injectedKey.injected.node, injectedKey.key, iv);
@@ -201,46 +200,46 @@ function $encrypt(data, secretKey, options) {
201
200
  const cipherStr = $convertBytesToStr(encrypted, outputEncoding);
202
201
  const tagStr = $convertBytesToStr(tag, outputEncoding);
203
202
  if (ivStr.error || cipherStr.error || tagStr.error) {
204
- return chunkX4CS7UXE_cjs.$err({
203
+ return chunkHTRGOBZF_cjs.$err({
205
204
  msg: "Crypto NodeJS API - Encryption: Failed to convert IV or encrypted data or tag",
206
- desc: `Conversion error: ${chunkX4CS7UXE_cjs.$fmtResultErr(ivStr.error || cipherStr.error || tagStr.error)}`
205
+ desc: `Conversion error: ${chunkHTRGOBZF_cjs.$fmtResultErr(ivStr.error || cipherStr.error || tagStr.error)}`
207
206
  });
208
207
  }
209
- return chunkX4CS7UXE_cjs.$ok(`${ivStr.result}.${cipherStr.result}.${tagStr.result}.`);
208
+ return chunkHTRGOBZF_cjs.$ok(`${ivStr.result}.${cipherStr.result}.${tagStr.result}.`);
210
209
  } catch (error2) {
211
- return chunkX4CS7UXE_cjs.$err({ msg: `${chunkX4CS7UXE_cjs.title("node", "Encryption")}: Failed to encrypt data`, desc: chunkX4CS7UXE_cjs.$fmtError(error2) });
210
+ return chunkHTRGOBZF_cjs.$err({ msg: `${chunkHTRGOBZF_cjs.title("node", "Encryption")}: Failed to encrypt data`, desc: chunkHTRGOBZF_cjs.$fmtError(error2) });
212
211
  }
213
212
  }
214
213
  function $decrypt(encrypted, secretKey, options) {
215
- if (!chunkX4CS7UXE_cjs.matchEncryptedPattern(encrypted, "node")) {
216
- return chunkX4CS7UXE_cjs.$err({
217
- msg: `${chunkX4CS7UXE_cjs.title("node", "Decryption")}: Invalid encrypted data format`,
214
+ if (!chunkHTRGOBZF_cjs.matchEncryptedPattern(encrypted, "node")) {
215
+ return chunkHTRGOBZF_cjs.$err({
216
+ msg: `${chunkHTRGOBZF_cjs.title("node", "Decryption")}: Invalid encrypted data format`,
218
217
  desc: 'Encrypted data must be in the format "iv.cipher.tag."'
219
218
  });
220
219
  }
221
- if (!chunkX4CS7UXE_cjs.$isPlainObj(options)) {
222
- return chunkX4CS7UXE_cjs.$err({
223
- msg: `${chunkX4CS7UXE_cjs.title("node", "Decryption")}: Invalid options`,
220
+ if (!chunkHTRGOBZF_cjs.$isPlainObj(options)) {
221
+ return chunkHTRGOBZF_cjs.$err({
222
+ msg: `${chunkHTRGOBZF_cjs.title("node", "Decryption")}: Invalid options`,
224
223
  desc: "Options must be an object"
225
224
  });
226
225
  }
227
226
  const inputEncoding = options.inputEncoding ?? "base64url";
228
- if (!chunkX4CS7UXE_cjs.CIPHER_ENCODING.includes(inputEncoding)) {
229
- return chunkX4CS7UXE_cjs.$err({
230
- msg: `${chunkX4CS7UXE_cjs.title("node", "Decryption")}: Unsupported input encoding: ${inputEncoding}`,
227
+ if (!chunkHTRGOBZF_cjs.CIPHER_ENCODING.includes(inputEncoding)) {
228
+ return chunkHTRGOBZF_cjs.$err({
229
+ msg: `${chunkHTRGOBZF_cjs.title("node", "Decryption")}: Unsupported input encoding: ${inputEncoding}`,
231
230
  desc: "Use base64, base64url, or hex"
232
231
  });
233
232
  }
234
233
  const [iv, cipher, tag] = encrypted.split(".", 4);
235
- if (!chunkX4CS7UXE_cjs.$isStr(iv) || !chunkX4CS7UXE_cjs.$isStr(cipher) || !chunkX4CS7UXE_cjs.$isStr(tag)) {
236
- return chunkX4CS7UXE_cjs.$err({
237
- msg: `${chunkX4CS7UXE_cjs.title("node", "Decryption")}: Invalid encrypted data`,
234
+ if (!chunkHTRGOBZF_cjs.$isStr(iv) || !chunkHTRGOBZF_cjs.$isStr(cipher) || !chunkHTRGOBZF_cjs.$isStr(tag)) {
235
+ return chunkHTRGOBZF_cjs.$err({
236
+ msg: `${chunkHTRGOBZF_cjs.title("node", "Decryption")}: Invalid encrypted data`,
238
237
  desc: "Encrypted data must contain valid IV, encrypted data, and tag components"
239
238
  });
240
239
  }
241
- const injectedKey = chunkX4CS7UXE_cjs.$isSecretKey(secretKey, "node");
240
+ const injectedKey = chunkHTRGOBZF_cjs.$isSecretKey(secretKey, "node");
242
241
  if (!injectedKey) {
243
- return chunkX4CS7UXE_cjs.$err({
242
+ return chunkHTRGOBZF_cjs.$err({
244
243
  msg: "Crypto NodeJS API - Decryption: Invalid Secret Key",
245
244
  desc: "Expected a Node SecretKey"
246
245
  });
@@ -249,9 +248,9 @@ function $decrypt(encrypted, secretKey, options) {
249
248
  const cipherBytes = $convertStrToBytes(cipher, inputEncoding);
250
249
  const tagBytes = $convertStrToBytes(tag, inputEncoding);
251
250
  if (ivBytes.error || cipherBytes.error || tagBytes.error) {
252
- return chunkX4CS7UXE_cjs.$err({
253
- msg: `${chunkX4CS7UXE_cjs.title("node", "Decryption")}: Failed to convert IV or encrypted data or tag`,
254
- desc: `Conversion error: ${chunkX4CS7UXE_cjs.$fmtResultErr(ivBytes.error || cipherBytes.error || tagBytes.error)}`
251
+ return chunkHTRGOBZF_cjs.$err({
252
+ msg: `${chunkHTRGOBZF_cjs.title("node", "Decryption")}: Failed to convert IV or encrypted data or tag`,
253
+ desc: `Conversion error: ${chunkHTRGOBZF_cjs.$fmtResultErr(ivBytes.error || cipherBytes.error || tagBytes.error)}`
255
254
  });
256
255
  }
257
256
  try {
@@ -260,122 +259,122 @@ function $decrypt(encrypted, secretKey, options) {
260
259
  const decrypted = buffer.Buffer.concat([decipher.update(cipherBytes.result), decipher.final()]);
261
260
  return $convertBytesToStr(decrypted, "utf8");
262
261
  } catch (error) {
263
- return chunkX4CS7UXE_cjs.$err({ msg: `${chunkX4CS7UXE_cjs.title("node", "Decryption")}: Failed to decrypt data`, desc: chunkX4CS7UXE_cjs.$fmtError(error) });
262
+ return chunkHTRGOBZF_cjs.$err({ msg: `${chunkHTRGOBZF_cjs.title("node", "Decryption")}: Failed to decrypt data`, desc: chunkHTRGOBZF_cjs.$fmtError(error) });
264
263
  }
265
264
  }
266
265
  function $encryptObj(data, secretKey, options) {
267
- const { result, error } = chunkX4CS7UXE_cjs.$stringifyObj(data);
268
- if (error) return chunkX4CS7UXE_cjs.$err(error);
266
+ const { result, error } = chunkHTRGOBZF_cjs.$stringifyObj(data);
267
+ if (error) return chunkHTRGOBZF_cjs.$err(error);
269
268
  return $encrypt(result, secretKey, options);
270
269
  }
271
270
  function $decryptObj(encrypted, secretKey, options) {
272
271
  const { result, error } = $decrypt(encrypted, secretKey, options);
273
- if (error) return chunkX4CS7UXE_cjs.$err(error);
274
- return chunkX4CS7UXE_cjs.$parseToObj(result);
272
+ if (error) return chunkHTRGOBZF_cjs.$err(error);
273
+ return chunkHTRGOBZF_cjs.$parseToObj(result);
275
274
  }
276
275
  function $hash(data, options = {}) {
277
- if (!chunkX4CS7UXE_cjs.$isStr(data)) {
278
- return chunkX4CS7UXE_cjs.$err({
279
- msg: `${chunkX4CS7UXE_cjs.title("node", "Hashing")}: Empty data for hashing`,
276
+ if (!chunkHTRGOBZF_cjs.$isStr(data)) {
277
+ return chunkHTRGOBZF_cjs.$err({
278
+ msg: `${chunkHTRGOBZF_cjs.title("node", "Hashing")}: Empty data for hashing`,
280
279
  desc: "Data must be a non-empty string"
281
280
  });
282
281
  }
283
- if (!chunkX4CS7UXE_cjs.$isPlainObj(options)) {
284
- return chunkX4CS7UXE_cjs.$err({
285
- msg: `${chunkX4CS7UXE_cjs.title("node", "Hashing")}: Invalid options`,
282
+ if (!chunkHTRGOBZF_cjs.$isPlainObj(options)) {
283
+ return chunkHTRGOBZF_cjs.$err({
284
+ msg: `${chunkHTRGOBZF_cjs.title("node", "Hashing")}: Invalid options`,
286
285
  desc: "Options must be an object"
287
286
  });
288
287
  }
289
288
  const outputEncoding = options.outputEncoding ?? "base64url";
290
- if (!chunkX4CS7UXE_cjs.CIPHER_ENCODING.includes(outputEncoding)) {
291
- return chunkX4CS7UXE_cjs.$err({
292
- msg: `${chunkX4CS7UXE_cjs.title("node", "Hashing")}: Unsupported output encoding: ${outputEncoding}`,
289
+ if (!chunkHTRGOBZF_cjs.CIPHER_ENCODING.includes(outputEncoding)) {
290
+ return chunkHTRGOBZF_cjs.$err({
291
+ msg: `${chunkHTRGOBZF_cjs.title("node", "Hashing")}: Unsupported output encoding: ${outputEncoding}`,
293
292
  desc: "Use base64, base64url, or hex"
294
293
  });
295
294
  }
296
295
  const digest = options.digest ?? "sha256";
297
- if (!(digest in chunkX4CS7UXE_cjs.DIGEST_ALGORITHMS)) {
298
- return chunkX4CS7UXE_cjs.$err({
299
- msg: `${chunkX4CS7UXE_cjs.title("node", "Hashing")}: Unsupported digest: ${digest}`,
300
- desc: `Supported digests are: ${Object.keys(chunkX4CS7UXE_cjs.DIGEST_ALGORITHMS).join(", ")}`
296
+ if (!(digest in chunkHTRGOBZF_cjs.DIGEST_ALGORITHMS)) {
297
+ return chunkHTRGOBZF_cjs.$err({
298
+ msg: `${chunkHTRGOBZF_cjs.title("node", "Hashing")}: Unsupported digest: ${digest}`,
299
+ desc: `Supported digests are: ${Object.keys(chunkHTRGOBZF_cjs.DIGEST_ALGORITHMS).join(", ")}`
301
300
  });
302
301
  }
303
- const digestAlgo = chunkX4CS7UXE_cjs.DIGEST_ALGORITHMS[digest];
302
+ const digestAlgo = chunkHTRGOBZF_cjs.DIGEST_ALGORITHMS[digest];
304
303
  const { result, error } = $convertStrToBytes(data, "utf8");
305
- if (error) return chunkX4CS7UXE_cjs.$err(error);
304
+ if (error) return chunkHTRGOBZF_cjs.$err(error);
306
305
  try {
307
306
  const hashed = nodeCrypto__default.default.createHash(digestAlgo.node).update(result).digest();
308
307
  return $convertBytesToStr(hashed, outputEncoding);
309
308
  } catch (error2) {
310
- return chunkX4CS7UXE_cjs.$err({ msg: `${chunkX4CS7UXE_cjs.title("node", "Hashing")}: Failed to hash data with Crypto NodeJS`, desc: chunkX4CS7UXE_cjs.$fmtError(error2) });
309
+ return chunkHTRGOBZF_cjs.$err({ msg: `${chunkHTRGOBZF_cjs.title("node", "Hashing")}: Failed to hash data with Crypto NodeJS`, desc: chunkHTRGOBZF_cjs.$fmtError(error2) });
311
310
  }
312
311
  }
313
312
  function $hashPassword(password, options) {
314
- if (!chunkX4CS7UXE_cjs.$isStr(password)) {
315
- return chunkX4CS7UXE_cjs.$err({
316
- msg: `${chunkX4CS7UXE_cjs.title("node", "Password Hashing")}: Empty password for hashing`,
313
+ if (!chunkHTRGOBZF_cjs.$isStr(password)) {
314
+ return chunkHTRGOBZF_cjs.$err({
315
+ msg: `${chunkHTRGOBZF_cjs.title("node", "Password Hashing")}: Empty password for hashing`,
317
316
  desc: "Password must be a non-empty string"
318
317
  });
319
318
  }
320
- if (!chunkX4CS7UXE_cjs.$isPlainObj(options)) {
321
- return chunkX4CS7UXE_cjs.$err({
322
- msg: `${chunkX4CS7UXE_cjs.title("node", "Password Hashing")}: Invalid options`,
319
+ if (!chunkHTRGOBZF_cjs.$isPlainObj(options)) {
320
+ return chunkHTRGOBZF_cjs.$err({
321
+ msg: `${chunkHTRGOBZF_cjs.title("node", "Password Hashing")}: Invalid options`,
323
322
  desc: "Options must be an object"
324
323
  });
325
324
  }
326
325
  const digest = options.digest ?? "sha512";
327
- if (!(digest in chunkX4CS7UXE_cjs.DIGEST_ALGORITHMS)) {
328
- return chunkX4CS7UXE_cjs.$err({
329
- msg: `${chunkX4CS7UXE_cjs.title("node", "Password Hashing")}: Unsupported digest: ${digest}`,
330
- desc: `Supported digests are: ${Object.keys(chunkX4CS7UXE_cjs.DIGEST_ALGORITHMS).join(", ")}`
326
+ if (!(digest in chunkHTRGOBZF_cjs.DIGEST_ALGORITHMS)) {
327
+ return chunkHTRGOBZF_cjs.$err({
328
+ msg: `${chunkHTRGOBZF_cjs.title("node", "Password Hashing")}: Unsupported digest: ${digest}`,
329
+ desc: `Supported digests are: ${Object.keys(chunkHTRGOBZF_cjs.DIGEST_ALGORITHMS).join(", ")}`
331
330
  });
332
331
  }
333
- const digestAlgo = chunkX4CS7UXE_cjs.DIGEST_ALGORITHMS[digest];
332
+ const digestAlgo = chunkHTRGOBZF_cjs.DIGEST_ALGORITHMS[digest];
334
333
  const outputEncoding = options.outputEncoding ?? "base64url";
335
- if (!chunkX4CS7UXE_cjs.CIPHER_ENCODING.includes(outputEncoding)) {
336
- return chunkX4CS7UXE_cjs.$err({
337
- msg: `${chunkX4CS7UXE_cjs.title("node", "Password Hashing")}: Unsupported encoding: ${outputEncoding}`,
334
+ if (!chunkHTRGOBZF_cjs.CIPHER_ENCODING.includes(outputEncoding)) {
335
+ return chunkHTRGOBZF_cjs.$err({
336
+ msg: `${chunkHTRGOBZF_cjs.title("node", "Password Hashing")}: Unsupported encoding: ${outputEncoding}`,
338
337
  desc: "Use base64, base64url, or hex"
339
338
  });
340
339
  }
341
340
  const saltLength = options.saltLength ?? 16;
342
341
  if (typeof saltLength !== "number" || saltLength < 8) {
343
- return chunkX4CS7UXE_cjs.$err({
344
- msg: `${chunkX4CS7UXE_cjs.title("node", "Password Hashing")}: Weak salt length`,
342
+ return chunkHTRGOBZF_cjs.$err({
343
+ msg: `${chunkHTRGOBZF_cjs.title("node", "Password Hashing")}: Weak salt length`,
345
344
  desc: "Salt length must be a number and at least 8 bytes (recommended 16 or more)"
346
345
  });
347
346
  }
348
347
  const iterations = options.iterations ?? 32e4;
349
348
  if (typeof iterations !== "number" || iterations < 1e3) {
350
- return chunkX4CS7UXE_cjs.$err({
351
- msg: `${chunkX4CS7UXE_cjs.title("node", "Password Hashing")}: Weak iterations count`,
349
+ return chunkHTRGOBZF_cjs.$err({
350
+ msg: `${chunkHTRGOBZF_cjs.title("node", "Password Hashing")}: Weak iterations count`,
352
351
  desc: "Iterations must be a number and at least 1000 (recommended 320,000 or more)"
353
352
  });
354
353
  }
355
354
  const keyLength = options.keyLength ?? 64;
356
355
  if (typeof keyLength !== "number" || keyLength < 16) {
357
- return chunkX4CS7UXE_cjs.$err({
358
- msg: `${chunkX4CS7UXE_cjs.title("node", "Password Hashing")}: Invalid key length`,
356
+ return chunkHTRGOBZF_cjs.$err({
357
+ msg: `${chunkHTRGOBZF_cjs.title("node", "Password Hashing")}: Invalid key length`,
359
358
  desc: "Key length must be a number and at least 16 bytes (recommended 64 or more)"
360
359
  });
361
360
  }
362
361
  try {
363
362
  const salt = nodeCrypto__default.default.randomBytes(saltLength);
364
363
  const hash2 = nodeCrypto__default.default.pbkdf2Sync(password.normalize("NFKC"), salt, iterations, keyLength, digestAlgo.node);
365
- return chunkX4CS7UXE_cjs.$ok({ result: hash2.toString(outputEncoding), salt: salt.toString(outputEncoding) });
364
+ return chunkHTRGOBZF_cjs.$ok({ result: hash2.toString(outputEncoding), salt: salt.toString(outputEncoding) });
366
365
  } catch (error) {
367
- return chunkX4CS7UXE_cjs.$err({ msg: `${chunkX4CS7UXE_cjs.title("node", "Password Hashing")}: Failed to hash password`, desc: chunkX4CS7UXE_cjs.$fmtError(error) });
366
+ return chunkHTRGOBZF_cjs.$err({ msg: `${chunkHTRGOBZF_cjs.title("node", "Password Hashing")}: Failed to hash password`, desc: chunkHTRGOBZF_cjs.$fmtError(error) });
368
367
  }
369
368
  }
370
369
  function $verifyPassword(password, hashedPassword, salt, options) {
371
- if (!chunkX4CS7UXE_cjs.$isStr(password) || !chunkX4CS7UXE_cjs.$isStr(hashedPassword) || !chunkX4CS7UXE_cjs.$isStr(salt) || !chunkX4CS7UXE_cjs.$isPlainObj(options)) {
370
+ if (!chunkHTRGOBZF_cjs.$isStr(password) || !chunkHTRGOBZF_cjs.$isStr(hashedPassword) || !chunkHTRGOBZF_cjs.$isStr(salt) || !chunkHTRGOBZF_cjs.$isPlainObj(options)) {
372
371
  return false;
373
372
  }
374
373
  const digest = options.digest ?? "sha512";
375
- if (!(digest in chunkX4CS7UXE_cjs.DIGEST_ALGORITHMS)) return false;
376
- const digestAlgo = chunkX4CS7UXE_cjs.DIGEST_ALGORITHMS[digest];
374
+ if (!(digest in chunkHTRGOBZF_cjs.DIGEST_ALGORITHMS)) return false;
375
+ const digestAlgo = chunkHTRGOBZF_cjs.DIGEST_ALGORITHMS[digest];
377
376
  const inputEncoding = options.inputEncoding ?? "base64url";
378
- if (!chunkX4CS7UXE_cjs.CIPHER_ENCODING.includes(inputEncoding)) return false;
377
+ if (!chunkHTRGOBZF_cjs.CIPHER_ENCODING.includes(inputEncoding)) return false;
379
378
  const iterations = options.iterations ?? 32e4;
380
379
  if (typeof iterations !== "number" || iterations < 1e3) return false;
381
380
  const keyLength = options.keyLength ?? 64;
@@ -395,15 +394,12 @@ function $verifyPassword(password, hashedPassword, salt, options) {
395
394
  }
396
395
 
397
396
  // src/node/kit.ts
398
- function isNodeSecretKey(x) {
399
- return chunkX4CS7UXE_cjs.$isSecretKey(x, "node") !== null;
400
- }
401
397
  function tryGenerateUuid() {
402
398
  return $generateUuid();
403
399
  }
404
400
  function generateUuid() {
405
401
  const { result, error } = $generateUuid();
406
- if (error) throw new Error(chunkX4CS7UXE_cjs.$fmtResultErr(error));
402
+ if (error) throw new Error(chunkHTRGOBZF_cjs.$fmtResultErr(error));
407
403
  return result;
408
404
  }
409
405
  function tryCreateSecretKey(secret, options = {}) {
@@ -411,7 +407,7 @@ function tryCreateSecretKey(secret, options = {}) {
411
407
  }
412
408
  function createSecretKey(secret, options = {}) {
413
409
  const { result, error } = $createSecretKey(secret, options);
414
- if (error) throw new Error(chunkX4CS7UXE_cjs.$fmtResultErr(error));
410
+ if (error) throw new Error(chunkHTRGOBZF_cjs.$fmtResultErr(error));
415
411
  return result;
416
412
  }
417
413
  function tryEncrypt(data, secretKey, options = {}) {
@@ -419,7 +415,7 @@ function tryEncrypt(data, secretKey, options = {}) {
419
415
  }
420
416
  function encrypt(data, secretKey, options = {}) {
421
417
  const { result, error } = $encrypt(data, secretKey, options);
422
- if (error) throw new Error(chunkX4CS7UXE_cjs.$fmtResultErr(error));
418
+ if (error) throw new Error(chunkHTRGOBZF_cjs.$fmtResultErr(error));
423
419
  return result;
424
420
  }
425
421
  function tryDecrypt(encrypted, secretKey, options = {}) {
@@ -427,7 +423,7 @@ function tryDecrypt(encrypted, secretKey, options = {}) {
427
423
  }
428
424
  function decrypt(encrypted, secretKey, options = {}) {
429
425
  const { result, error } = $decrypt(encrypted, secretKey, options);
430
- if (error) throw new Error(chunkX4CS7UXE_cjs.$fmtResultErr(error));
426
+ if (error) throw new Error(chunkHTRGOBZF_cjs.$fmtResultErr(error));
431
427
  return result;
432
428
  }
433
429
  function tryEncryptObj(obj, secretKey, options = {}) {
@@ -435,7 +431,7 @@ function tryEncryptObj(obj, secretKey, options = {}) {
435
431
  }
436
432
  function encryptObj(obj, secretKey, options = {}) {
437
433
  const { result, error } = $encryptObj(obj, secretKey, options);
438
- if (error) throw new Error(chunkX4CS7UXE_cjs.$fmtResultErr(error));
434
+ if (error) throw new Error(chunkHTRGOBZF_cjs.$fmtResultErr(error));
439
435
  return result;
440
436
  }
441
437
  function tryDecryptObj(encrypted, secretKey, options = {}) {
@@ -443,7 +439,7 @@ function tryDecryptObj(encrypted, secretKey, options = {}) {
443
439
  }
444
440
  function decryptObj(encrypted, secretKey, options = {}) {
445
441
  const { result, error } = $decryptObj(encrypted, secretKey, options);
446
- if (error) throw new Error(chunkX4CS7UXE_cjs.$fmtResultErr(error));
442
+ if (error) throw new Error(chunkHTRGOBZF_cjs.$fmtResultErr(error));
447
443
  return result;
448
444
  }
449
445
  function tryHash(data, options = {}) {
@@ -451,7 +447,7 @@ function tryHash(data, options = {}) {
451
447
  }
452
448
  function hash(data, options = {}) {
453
449
  const { result, error } = $hash(data, options);
454
- if (error) throw new Error(chunkX4CS7UXE_cjs.$fmtResultErr(error));
450
+ if (error) throw new Error(chunkHTRGOBZF_cjs.$fmtResultErr(error));
455
451
  return result;
456
452
  }
457
453
  function tryHashPassword(password, options = {}) {
@@ -459,7 +455,7 @@ function tryHashPassword(password, options = {}) {
459
455
  }
460
456
  function hashPassword(password, options = {}) {
461
457
  const { result, salt, error } = $hashPassword(password, options);
462
- if (error) throw new Error(chunkX4CS7UXE_cjs.$fmtResultErr(error));
458
+ if (error) throw new Error(chunkHTRGOBZF_cjs.$fmtResultErr(error));
463
459
  return { result, salt };
464
460
  }
465
461
  function verifyPassword(password, hashedPassword, salt, options = {}) {
@@ -470,7 +466,7 @@ function tryConvertStrToBytes(data, inputEncoding = "utf8") {
470
466
  }
471
467
  function convertStrToBytes(data, inputEncoding = "utf8") {
472
468
  const { result, error } = $convertStrToBytes(data, inputEncoding);
473
- if (error) throw new Error(chunkX4CS7UXE_cjs.$fmtResultErr(error));
469
+ if (error) throw new Error(chunkHTRGOBZF_cjs.$fmtResultErr(error));
474
470
  return result;
475
471
  }
476
472
  function tryConvertBytesToStr(data, outputEncoding = "utf8") {
@@ -478,7 +474,7 @@ function tryConvertBytesToStr(data, outputEncoding = "utf8") {
478
474
  }
479
475
  function convertBytesToStr(data, outputEncoding = "utf8") {
480
476
  const { result, error } = $convertBytesToStr(data, outputEncoding);
481
- if (error) throw new Error(chunkX4CS7UXE_cjs.$fmtResultErr(error));
477
+ if (error) throw new Error(chunkHTRGOBZF_cjs.$fmtResultErr(error));
482
478
  return result;
483
479
  }
484
480
  function tryConvertEncoding(data, from, to) {
@@ -486,7 +482,7 @@ function tryConvertEncoding(data, from, to) {
486
482
  }
487
483
  function convertEncoding(data, from, to) {
488
484
  const { result, error } = $convertEncoding(data, from, to);
489
- if (error) throw new Error(chunkX4CS7UXE_cjs.$fmtResultErr(error));
485
+ if (error) throw new Error(chunkHTRGOBZF_cjs.$fmtResultErr(error));
490
486
  return result;
491
487
  }
492
488
 
@@ -501,7 +497,6 @@ exports.encryptObj = encryptObj;
501
497
  exports.generateUuid = generateUuid;
502
498
  exports.hash = hash;
503
499
  exports.hashPassword = hashPassword;
504
- exports.isNodeSecretKey = isNodeSecretKey;
505
500
  exports.kit_exports = kit_exports;
506
501
  exports.tryConvertBytesToStr = tryConvertBytesToStr;
507
502
  exports.tryConvertEncoding = tryConvertEncoding;
@@ -515,5 +510,5 @@ exports.tryGenerateUuid = tryGenerateUuid;
515
510
  exports.tryHash = tryHash;
516
511
  exports.tryHashPassword = tryHashPassword;
517
512
  exports.verifyPassword = verifyPassword;
518
- //# sourceMappingURL=chunk-56PVVFVM.cjs.map
519
- //# sourceMappingURL=chunk-56PVVFVM.cjs.map
513
+ //# sourceMappingURL=chunk-ZNM5M6RD.cjs.map
514
+ //# sourceMappingURL=chunk-ZNM5M6RD.cjs.map