1.0.0 • Published 2 years ago

sf-jwt-generator v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

SalesForce JWT generator

Generates a JWT using the provided config. Then it's your part to use this JWT to retrieve the actual token from SF OAuth.

Installation

yarn

Configuration

The configuration has the following properties (all of them except the offsetInMs are mandatory):

const config = {
    clientId: '<YOUR CLIENT ID HERE>',
    offsetInMs: '<HOW MANY MILLISECONDS THE TOKEN IS VALID (OPTIONAL, DEFAULT IS 1 DAY)',
    privateKey: '<YOUR PRIVATE KEY AS UTF-8 STRING>',
    url: '<SALESFORCE BASE URL>',
    username: '<YOUR SALESFORCE USERNAME>'
}

The url should be one of:

https://login.salesforce.com
https://test.salesforce.com

Usage

import {generateJwt} from 'sf-jwt-generator';

const jwt = generateJwt(config); // the config provided above

To import the config type definition in TypeScript:

import {ConnectionConfig} from 'sf-jwt-validator';

const config:ConnectionConfig = {
    // config here
}