sliit-foss / npm-catalogue

A curated list of NPM packages developed by the SLIIT FOSS community. Additionally, it houses the core libraries of the Timekeeper ecosystem
https://www.npmjs.com/~sliit.foss
MIT License
2 stars 6 forks source link

Add: New package JSON hash added #186

Open ThulinaWickramasinghe opened 5 days ago

ThulinaWickramasinghe commented 5 days ago

This package is intended to be used for hashing a provided JS object in both Node.js and browser(eg-: for Next.js). Users will be provided an option to sort the JS object since order of properties is not guaranteed by JSON.stringify. This sorting will be done using this package which will be imported dynamically. I've kept sorting optional, in case of a string being passed as a parameter to the algorithm.

On the browser side hashing will be done using the inbuilt SubteCrypto Web API which only provides the following algorithms for creating a hash.

In node.js we use the inbuilt crypto module, Even though node.js crpto module provides more algorithms than the ones available in the browser to maintain cross platform compatibility (browser and node.js), I've limited the available algorithms only the ones available in browser.