API Improvment
See original GitHub issueDescription
Expose a constructor to allow the users to have multiple instance of upash instead of having it as a singleton.
Examples
const UPASH = require('upash');
// Create an instance of upash providing the algorithms of your choice.
const upash = new UPASH({
argon2: require('@phc/argon2'),
pbkdf2: require('@phc/pbkdf2')
}, {default: 'argon2'});
// You can explicitly tell upash which algorithm to use.
const hashstr_pbkdf2 = await upash.use('pbkdf2').hash('password');
// => "$pbkdf2-sha512$i=10000$O484sW7giRw+nt5WVnp15w$jEUMVZ9adB+63ko/8Dr9oB1jWdndpVVQ65xRlT+tA1GTKcJ7BWlTjdaiILzZAhIPEtgTImKvbgnu8TS/ZrjKgA"
// If you don't do so it will automatically use the default one.
const hashstr_argon2 = await upash.hash('password');
// => "$argon2i$v=19$m=4096,t=3,p=1$mTFYKhlcxmjS/v6Y8aEd5g$IKGY+vj0MdezVEKHQ9bvjpROoR5HPun5/AUCjQrHSIs"
// When you verify upash will automatically choose the algorithm to use based
// on the identifier contained in the hash string.
const match_pbkdf2 = await upash.verify(hashstr_pbkdf2, 'password');
// => true
// This will allow you to easily migrate from an algorithm to another.
const match_argon2 = await upash.verify(hashstr_argon2, 'password');
// => true
Notes
Probably it makes sense to remove install
and uninstall
methods and add a getDefault
method.
This would lead to a breaking change.
cc @mcollina
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
API Improvement Proposals
AIPs are design documents that summarize Google's API design decisions. They also provide a framework and system for others to document their own...
Read more >API Improvement Proposals - GitHub
AIP stands for API Improvement Proposal, which is a design document providing high-level, concise documentation for API development. The goal is for these ......
Read more >Chapter 5. Continuous API Improvement - O'Reilly
The lifecycle and its ten pillars define the work that you’ll need to do for your first API release. The pillars are also...
Read more >Understanding Google's API Improvement Proposals System
AIPs are documents that detail the guidelines for API design. They tend to focus on resource naming, pagination, error handling, and other ...
Read more >API Improvement Proposals: Google's Take on the API ...
API Improvement Proposals, or AIPs, are documents outlining Google's guidelines for API design. Most AIPs focus on universal design standards — ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m happy help 😃 Will open a PR in the next few days. I have a few questions first though.
Is this finialised?
Is there ever going to be any other options passed in the second object? If not I would favour this approach:
Also what do we want the behaviour to be if no default is specified?
Good work! I would actually go ahead and remove
install
anduninstall
.