1.0.22 • Published 4 years ago

knox-token-library-js v1.0.22

Weekly downloads
14
License
Apache-2.0
Repository
-
Last release
4 years ago

This library provides utility methods to generate and sign Knox Tokens using server side Javascript. The pre-requisites for using this utility are

  • You have downloaded the Knox Certificate file (certificate.json)
  • You have generated a Client Identifier (api-key) for accessing apis of Knox Cloud Services.

Intended Use

The workflow for making api calls to Knox Cloud Services is divided into a portal workflow, and a programmatic workflow.

Portal flow

  1. Download Certificate from Knox Api Portal
  2. Generate and Download ClientIdentifier (api-key) for a specific Knox Solution

Programmatic flow

  1. Call Knox api to generate an Api Access Token. This api call requires a signed ClientIdentifier, and specific contents of your Certificate (Public Key).
  2. Call Knox api for your intended workflow (eg: upload device, configure device etc). This api call requires your signed Api Access Token, and specific contents of your Certificate (Public Key).

This utility js library helps generate signed clientIdentifiers, and signed accessTokens.

Install using npm

npm install knox-token-library-js

Generate Signed ClientIdentifier

The following method is provided to generate a signed client identifier.

const knoxTokenLibraryJs = require('knox-token-library-js');
var signedClientId = knoxTokenLibraryJs.generateSignedClientIdentifierJWT("certificate.json", "my-client-identifier");

Input parameters:

  • certificate: An input stream of the Knox certificate (certificate.json) that was downloaded from Knox Api portal.
  • clientIdentifier: The string ClientIdentifier downloaded from Knox Api portal.

Output:

  • A String representing the ClientIdentifier signed with the primary key from the downloaded Certificate.

Generate Signed Api Access Token

KnoxTokenUtility class provides the following method to generate a signed api access token.

const knoxTokenLibraryJs = require('knox-token-library-js');
var signedAccessToken = knoxTokenLibraryJs.generateSignedAccessTokenJWT("certificate.json", "my-access-token");

Input parameters:

  • certificate: An input stream of the Knox certificate (certificate.json) that was downloaded from Knox Api portal.
  • accessToken: The string api AccessToken returned by calling Knox Cloud Services' generateAccessToken api.

Output:

  • A String representing the AccessToken signed with the primary key from the downloaded Certificate.

License

Apache

1.0.22

4 years ago

1.0.21

5 years ago

1.0.20

5 years ago

1.0.19

5 years ago

1.0.18

5 years ago

1.0.17

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago