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

@sap/node-jwt

v1.6.26

Published

JWT validation library for Node.js

Downloads

5,137

Readme

@sap/node-jwt

JSON Web Token (JWT) offline validation for Node with current binaries

This project contains the JWT binding for Node.js. It also includes the native libraries to run on Windows/Linux. If you need another platforms, please create a SAP support ticket to BC-XS-SEC. The library is supposed to be used for on-premise systems, because for cloud scenarios there is another solution.

Platforms

Supported platforms: Windows | Linux | MacOS Supported architectures: x64 on supported platforms. Please see also section dependencies for Node.js version.

Hello world

This standard example is from http://jwt.io

// you can either load a HMAC key for signatures with HSxxx
v.setSecret("secret"); // load HMAC key
v.setBase64Secret("c2VjcmV0"); // load a Base64 encoded HMAC key
// or you can load a PEM encoded X509 certificate for signatures with RSxxx
v.loadPEM("MIICozCCAYsCCAogFQcmCUcJMA0GCSqGSIb3DQEBCwUAMBQ...."); // load X509 public certificate OR public key for RSA signature validation
// check the token signature and validity
v.checkToken("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ");
console.log("Test JWT for Node.js");
if (v.getErrorDescription() !== "") {
   // error handling
   console.log("Error in JWT: " + v.getErrorDescription());
} else {
   // in case of success, retrieve the payload
   console.log("JWT Payload : " + v.getPayload());
}

Getting started

From your project directory, run (see below for requirements):

$ var jwt = require('@sap/node-jwt');

Released versions

npm install @sap/node-jwt

Dependencies

  • NodeJS v0.10.x is the minimum version. The maximum version is always the last LTS (long term support, https://nodejs.org/en/about/releases/) , however due to missing binaries, there might be errors in using this project
  • You dont need node-gyp or any compiler (e.g. Visual Studio on Windows). The source code and binding.gyp is part of this project in case of errors.
  • If you run in error with generic node exceptions, please inform the author. The root cause can be missing jwt.node modules.

Error situations

The standard error for signature operations is the situation, that the signature is not valid. This error is typical and you should handle it carefully! and not as fatal error or assert. If you think, it must work, but it does not, then you can trace the native functions. SAPSSOEXT library allows you to set the environment variables:

  • SAP_EXT_TRC to define a trace file in your file system
  • SAP_EXT_TRL an integer 0 to 3
set SAP_EXT_TRC=stdout
set SAP_EXT_TRL=3

If you run your application in CloudFoundry or XSA then you can define environment variables with client command tool cf / xs, see https://docs.run.pivotal.io/devguide/deploy-apps/manifest.html#env-block

In cf landscapes you can then cf logs and you will see trace from JWT validation

Install via NPM

In order to configure the sap NPM registry you need to issue the following command:

npm install @sap/node-jwt