npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jwk-rsa-compute-primes

v1.0.1

Published

Compute p, q, dp, dq, and qi from e, d, and n for private JWKs without these parameters

Downloads

263

Readme

npm version

Compute primes from an existing RSA JWK

This code is extracted from https://github.com/dannycoates/pem-jwk.

Usage

import { computePrimes } from 'jwk-rsa-compute-primes';

console.log(computePrimes({
    kty: 'RSA',
    d: `
        X3R1wmXxK5FZWkoL9f2uH6ypNrvg0d6jZwioGVjtxqSmbBsE_of7-8Fr8pdQgS-ERUxWV7dz
        TCHq6sHjgYtsKtUCnr_NKsvqaESoAqbu2nVk6ex-4SNuAVvVha8JQYdUMKeFLJ67SHu7HICl
        79PjWUDCwhb0jBFsmRrilA55xzXM4y1JvZsGBRaQY16VC7UelhaIwsM5aTUD_RBwHdfmjYxz
        09TmixJDLq8UsMkG_iisOfb0PCHn6YMrMO0piNdLk3xoSThTukZxIIKnMMKlABvxmWC4Z3B-
        8gZJ0syA4qGxX-gxRuKoS6HCdebDNWoAVeZT5o308AjfzlJ6uCv-AQ`,
    e: 'AQAB',
    use: 'sig',
    kid: 's1',
    alg: 'RS256',
    n: `
        qj2UMQrfLVlTGfzvu707u9SsmWIe7gP61BqpdFsIZ9iwLO4uJLFUjR_T_9PhqDxI51l_MFNX
        S4TaQMC170JFVTrl_f8fI0BYMqd96mkGOxeQQG-_x51nQb4E2Gm3kNFe8nKyOCno_a_scIWp
        07gnt6HXEgjPZscC4YD4OZQ2WdSH9yk4BahPyg79aHslNn0vz2u-jizkr3d1BFWSWXC100te
        bWReaeqeXm_QOkLoyUMTHQzyteR_hx5uwWockuLgMooNhbOKPumM2XLf4G8Q-vlIsBo4nXp0
        mgSbpIJi1l4Ljmv3qYNQi__RIytteGtivrOo-OhI6YRh2JG_kz-8cQ`,
}));

Will output:

{
    "kty": "RSA",
    "d": "X3R1wmXxK5FZ...AQ",
    "e": "AQAB",
    "use": "sig",
    "kid": "s1",
    "alg": "RS256",
    "n": "qj2UMQrfLVlTGfzvu707u9SsmWIe7gP61BqpdFsIZ9iwLO4uJLFUjR_T_9P...-8cQ",
    "p": "2AxTFKklIK077je1CLhzolRnUdHuYOtfo0s69ipDWhGYaCb8owofQDllFxh...HSE",
    "q": "ybi7Vp89X_KGw-kPc8nIlJzjSTCdF2mCy9mF-...aSDW3Wp5VE",
    "dp": "vggRJ7IjqxtVBJLRVKtRYq5U9r3trCg8RhiM8yt3dIjXgn0QaK...3PAPqE",
    "dq": "apM4HwbYxVV8UAtVR6aHW8Ub7DJL_O-Y1ByjxGH...6_aVE",
    "qi": "fHBGcXSVdL3X-8JPeoCva6eP...Mzg4wT-16yLA",
}

Some values are abbreviated for readability purposes. To see the full length keys, look in test/test.ts.