1.6.22 • Published 4 months ago

@sap/node-jwt v1.6.22

Weekly downloads
10,839
License
SAP DEVELOPER LIC...
Repository
-
Last release
4 months ago

@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
1.6.22

4 months ago

1.6.21

6 months ago

1.6.20

1 year ago

1.6.19

1 year ago

1.6.18

1 year ago

1.6.16

2 years ago

1.6.15

3 years ago

1.6.14

3 years ago

1.6.13

4 years ago

1.6.12

4 years ago

1.6.11

4 years ago

1.6.3

4 years ago

1.6.2

4 years ago

1.4.1

4 years ago

1.3.0

4 years ago

1.4.9

4 years ago

1.4.12

4 years ago

1.4.11

4 years ago

1.4.7

4 years ago

1.5.0

4 years ago

1.6.5

4 years ago

1.4.0

4 years ago

1.4.10

4 years ago

1.1.0

4 years ago

1.6.7

4 years ago

1.4.8

4 years ago

1.4.3

4 years ago

1.6.8

4 years ago

1.3.13

4 years ago

1.4.6

4 years ago

1.5.2

4 years ago

1.6.6

4 years ago

1.5.1

4 years ago

1.6.9

4 years ago

1.0.0

4 years ago

1.4.4

4 years ago

1.4.2

4 years ago

1.4.5

4 years ago

1.2.0

4 years ago

1.6.4

4 years ago

1.4.13

4 years ago