Add more `worktop/crypto` helpers
See original GitHub issueAs of #11, there is now a worktop/crypto
module that includes the following helpers:
digest(algo, message)
SHA1(message)
SHA256(message)
SHA384(message)
SHA512(message)
This ticket exists to collect suggestions for additional helpers that should be added to the module, if any. So far, I think these would be good additions, if for no other reason than type safety:
declare function importkey(secret: string, algo: ALGO, scopes = ['sign', 'verify']): Promise<CryptoKey>;
declare function verify(secret: string, algo: ALGO, message: string): Promise<ArrayBuffer>;
declare function sign(secret: string, algo: ALGO, message: string): Promise<ArrayBuffer>;
Additionally, I have a PBKDF2 implementation that I can extract from existing application(s) and generalize it:
declare function PBKDF2(input: string, salt: string, iterations: number, keylen: number, digest: string): Promise<ArrayBuffer>;
What else should be here? 🙏
Lastly, WRT importkey
, verify
, and sign
specifically – my applications’ implementations only made use of a “raw” imported key:
// example
crypto.subtle.importKey('raw', ....);
Is/Was this application-specific? Or is this “the norm” for a Workers environment?
My hesitation is that these utilities will be too reliant on my importKey
assumption/default and be incorrect for a larger audience.
Thanks!
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top GitHub Comments
Thanks @mattwebbio! Yeah, there will definitely be a
worktop/jwt
. Still working through the knowledge gap ofimportKey
so that I’m not setting everyone up for limited use cases.While worktop is still “young” I’d say go with whatever works for your use case right now, but make it easy to extend. I just set some defaults based on what I needed, but allowed everything to be passed as parameters. I’m looking forward to giving this framework a go!