kjur / jsrsasign

The 'jsrsasign' (RSA-Sign JavaScript Library) is an opensource free cryptography library supporting RSA/RSAPSS/ECDSA/DSA signing/validation, ASN.1, PKCS#1/5/8 private/public key, X.509 certificate, CRL, OCSP, CMS SignedData, TimeStamp, CAdES and JSON Web Signature/Token in pure JavaScript.
https://kjur.github.io/jsrsasign
Other
3.27k stars 643 forks source link

ESM module using rollup or similar #365

Closed manelclos closed 6 years ago

manelclos commented 6 years ago

Hi,

I just need RSA256 verification, and I was wondering if making the library available as an ESM module would allow to reduce the size of the library from 256KB to something under 100KB. I tried the -rsa-min.js variant, but it is lacking KEYUTIL. Using it like this:

      const pubkey = KEYUTIL.getKey(certStr)
      const isValid = KJUR.jws.JWS.verifyJWT(token, pubkey, {
        alg: ['RS256']
      })

With the rsa-min.js version the error is:

TypeError: Cannot read property 'getKey' of undefined

Any pointers appreciated!

Thanks!

brockallen commented 6 years ago

FWIW, this is what I have done: https://github.com/IdentityModel/oidc-client-js/blob/dev/gulpfile.js#L96-L156

manelclos commented 6 years ago

Thanks @brockallen if there is no other option that will help!

brockallen commented 6 years ago

If you have or find a better approach, I'd love to know about it! :)

kjur commented 6 years ago

Hi @manelcos ,

@brockallen 's resolution is the one of best way.

jsrsasign is Swiss army knife style library which has rich APIs, is easy to use but has huge size as you said. To reduce size for your specific purpose, you need to make code snippet of jsrsasign.

Hi @brockallen , thank you for your mention.

Thanks.

manelclos commented 6 years ago

ok, noted. Thanks a lot!