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

@teamteanpm2024/pariatur-dolorem-nemo

v1.0.4

Published

Downloads

12

Maintainers

shivamkalsi2024shivamkalsi2024

Keywords

sharednopeponyfillReactiveXexecpropertieswordwrapcoreSymboloptionlazyemojitddmake dirpushlruhooksreact-hook-formcolourstyled-componentscss-in-jstranspilerdescriptorssyntaxdefinePropertyidphoneexpressirqjoitoStringTagweaksetoffsetttyreduceString.prototype.trimES3typesclassnamesform-validationramdawatchingbundlerregexconsolequerystringdomrapidimmutableUint8ClampedArrayinstallUint16ArraypolyfillnegativeworkerarraysflatMapiteratespinnerprotocol-bufferscore-jsrmdebuggerbusynode256rfc4122zodprotobufspinnersapollocreatepyyamlinspectfigletes6collectiontypescriptgetterthroatArrayBuffer#slicePromisegradients cssdirfastclonelanguagebootstrap cssgdprutil.inspecttypeerrornodejssignalflattenchaiparsearraybufferdatastructureincludesbufferssequencekarmaoptimizerJSONwindowsxdgutilitiesnested cssmoveparentsdom-testing-librarydiffmiddlewarevalidationtypedarraysmimefoldersymlinkweakmaputiltestercharacterstringStyleSheetparentCSScryptotc39inputfindLastIndexpackage.jsonindicatorserializationdeep-clonehardlinksmakefile systemboundfast-deep-cloneregular expressionstypesafepreserve-symlinksbatchspecseteslint-pluginreducerpurereduxintrinsicArrayBuffersideeventEmitterregulartrimansireact-testing-libraryArrayBuffer.prototype.slicefiletranspilereact animationlibphonenumberlogschemeshambundlingmruiterationpropinternal slotwriteSetcryptbytegradients css3shrinkwrapmaprm -frES2023fseventsECMAScript 2019ECMAScript 7ES2017eventDispatcheriestreamextendrm -rfgroupHyBijsonpathwebsiteextensioncliautoprefixerencryptionpackage manageropenssortmixinssomeflagsmonorepoentriessetterSymbol.toStringTagArray.prototype.findLastIndexwarningeslintkoreanratelimitqueueawesomesauceless mixinspromisesjavascriptWebSocketreadablestreamconsttypeofnegative zeroRxJSforEachmimetypesopenercss variabledragcensorsymbolmatchAllcallbindgenericsuser-streamsreadableratekeysfindless.jsvariables in cssformtyped arrayjsdiffFloat64ArrayharmonyspawnexecssRxmetadataECMAScript 2020astes2016computed-typestoucheslintpluginMapMicrosoftloggerES6byteLengthvarECMAScript 2021point-freeuuidxssprogressajaxdataViewqueueMicrotaskReactiveExtensionsajvECMAScript 2023browserrgbsigtermpostcss-pluginAsyncIteratorsameValueZeroes-abstractpreprocessorrangeerrorbddquerypositiveobjprettybyteOffsettsES2015typedarraysharedarraybufferArray.prototype.findLastfind-uputilitysuperagentdeterministicslotfantasy-landpicomatchapijapaneseWeakSettostringtaggraphqlFloat32ArraydebugartECMAScript 5envperformancetermPushstylessigintjsdombabel-corepruneeventspropertystableUint8ArrayjsonschemacachestatelessObject.isoutputES2020qsInt8ArrayObject.getPrototypeOfdefaultspringstartercss nestingworkspace:*momentRegExp.prototype.flagscode pointsmoduleswordbreakcurriedES2018schemaargumentslimitgetOwnPropertyDescriptorshelllinuxpipeObjecttesteveryremoveexitfastifytasktext[[Prototype]]browserlistfunctionsnamesformattingStreamsfromdeepaccessortrimEndhttpserror.envtslibfast-copyreadlimitednativeObject.assignmatchminimalrmdirECMAScript 2018trimLeftjsxsetPrototypeOfarktypesanitizerecursivetoobjectlockfilees2015ES5environmentpromisetestingreal-timecolumns$.extendReflect.getPrototypeOfcjkESnextFunction.prototype.namefunctionshim__proto__namehookformjsxdg-openurlsi18nloadingl10nwatcherES8validatores2018viewredactRegExp#flagsformsisConcatSpreadablescheme-validationECMAScript 3emithelperswatchsetImmediatees-shim APIcommand-linewhatwghashfullarrayES2019stringifyavaanimationlinkcommandposetypedsuperstructfsauthquoteECMAScript 2017letBigUint64ArrayclassnamerequestsymlinksconcatMapassertjestshebang0es5characterscallguidlessformat

Readme

Get KeyCloak Public Key pipeline status coverage report License: MIT Known Vulnerabilities Downloads Counter

Provides access to PEM Public Keys from a KeyCloak server for JWT validation.

Introduction

KeyCloak has a bunch of libraries, but for NodeJs the only solution is a Connect based adapter. In case you want to use koa, or something else, you are toast with your token.

This module provides access to the PEM encoded Public Key used for the token based on the KID value, so you can validate the token with anything you want.

The module has no dependencies, the algorithm used to reconstruct the PEM encoded value from the modulus and the exponent is taken from tracker1's solution.

Features

The idea is to keep this simple and stupid, so nothing fancy is included. It can download the certificates JSON from a KeyCloak server, find the one with matching KID value, and reconstruct the Public Key in PEM format. End of story.

If you need improved behavior like caching of Public Keys, you can easily implement one.

Installation

$ npm install --save get-keycloak-public-key

Usage

const KeyCloakCerts = require('get-keycloak-public-key');

const keyCloakCerts = new KeyCloakCerts('https://my-keycloak.com', 'my-realm');

// You can also pass the full URL instead, as a single argument:
// 'https://my-keycloak.com/auth/realms/my-realm/protocol/openid-connect/certs'

const publicKey = keyCloakCerts.fetch('my-kid')

Example

Verifying the token using koa and jsonwebtoken:

const Koa = require('koa');
const KeyCloakCerts = require('get-keycloak-public-key');
const jwt = require('jsonwebtoken');

const keyCloakCerts = new KeyCloakCerts('https://my-keycloak.com', 'my-realm');
const app = new Koa();
app.use(async (ctx) => {
  // Check the Authorization header
  if (!(ctx.request.header.autorization && ctx.request.header.authorization.startsWith('Bearer '))) {
    // Authorization header is missing
    ctx.status = 401;
    return;
  }

  // Get the token from the Authorization header, skip 'Bearer ' prefix
  const token = ctx.request.header.authorization.substr(7);

  // decode the token without verification to have the kid value
  const kid = jwt.decode(token, { complete: true }).header.kid;

  // fetch the PEM Public Key
  const publicKey = await keyCloakCerts.fetch(kid);

  if (publicKey) {
    try {
      // Verify and decode the token
      const decoded = jwt.verify(token, publicKey);
      ctx.body = decoded;
    } catch (error) {
      // Token is not valid
      process.stderr.write(error.toString());
      ctx.status = 401;
    }
  } else {
    // KeyCloak has no Public Key for the specified KID
    ctx.status = 401;
  }
});
app.listen(3000);