Replies: 1 comment
-
Hello @BennyAlex , Thank you for bringing up this issue with the Bun.password.hash function. Based on the error message you've encountered, it seems that the method's type definition does not recognize a salt property within the options object. This typically implies that the method does not support a custom salt, or it's possible that the library expects the salt to be provided in a different way. In most cryptographic libraries, the ability to provide a custom salt is crucial for certain applications. However, it's also common for these libraries to automatically generate a secure, random salt for each password hash to ensure the best practices for security. It's possible that Bun's implementation is designed to handle salt generation internally. As for the example code you've posted, if Bun.password.hash does support a custom salt, it should conform to the expected type for the salt property. The salt should usually be a binary value, not a string, and the type definitions would reflect this requirement. If the library documentation does not specify the ability to provide a custom salt, the functionality might not be supported or might need to be done in a different way: Test using another algorithm, like on this example: Bun.password.hash(randomData , {
algorithm: "argon2id",
memoryCost: 120,
timeCost: 1,
salt: "TEST-SALT"
}); However, if custom salts are a must for your use case and are not supported by Bun's hashing function, you may need to look into alternative hashing libraries that provide more flexibility with salt management, like bcrypt or argon2. Before moving forward, I would recommend checking the latest official documentation for Bun.password.hash or reaching out to the maintainers for clarification on the matter. If the feature is indeed unsupported, it could be a valuable contribution to the Bun community to request this feature be added or to contribute to the library yourself. I hope this helps |
Beta Was this translation helpful? Give feedback.
-
When using Bun.password.hash it looks like a custom salt is not supported?
Beta Was this translation helpful? Give feedback.
All reactions