Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: New package JSON hash added #186

Open
wants to merge 54 commits into
base: development
Choose a base branch
from

Conversation

ThulinaWickramasinghe
Copy link
Collaborator

@ThulinaWickramasinghe ThulinaWickramasinghe commented Jun 23, 2024

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.

  • SHA-1
  • SHA-256
  • SHA-384
  • SHA-512

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.

Akalanka47000 and others added 30 commits March 25, 2024 15:05
…lter-support

Mongoose filter query - added support for more complex filters
Fix(mongoose-audit): exception when change is null
Add #111 Switch to lefthook for git hooks
Fix:  Docs for default export require statements updated
Add #104 Type support for actions-exec-wrapper added
…rsing

Fix(filter-query): added automatic parsing of object ids
Fix(mongoose-filter-query): incorrect parsing of regexp
github-actions bot and others added 21 commits April 16, 2024 07:17
…ean-parse

Fix(mongoose-filter-query): default boolean parsing
…iers

Feat(filter-query): added support for regexp modifiers
Feat(service-connector): added support for retrying
…rsing

Fix(filter-query): in & nin object id parse
};

export const isAvailableAlgo = (algorithm) => {
if (Object.prototype.hasOwnProperty.call(algos, algorithm)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use algos[algorithm] here instead right, will be more readable

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

const objectToHash = { name: "Siri", age: 30, country: "Sri Lanka" };

beforeAll(() => {
global.unit_tests_running = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we won't need this, this flag was used to handle a few edge cases of tests in a couple of other packages

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will remove

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@Akalanka47000 Akalanka47000 changed the base branch from main to development June 23, 2024 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants