onesignal-jwt-generator
TypeScript icon, indicating that this package has built-in type declarations

0.3.3 • Public • Published

JWT Generator for OneSignal

A simple JWT token generator for OneSignal. This module allows you to set your app's secret and generate JWT tokens easily.

Installation

Install the package using npm:

npm install onesignal-jwt-generator

Usage

First, import the JwtGenerator class:

import JwtGenerator from 'onesignal-jwt-generator';

Next, create an instance and set your app's secret:

const jwtGenerator = new OneSignalJwtGenerator();

jwtGenerator.setSecret('your-apps-256bit-device-api-shared-secret');

You can now generate JWT tokens by calling the createJwtToken method with your app ID and identity object:

const identity = {
  external_id: 'rodrigo',
  onesignal_id: 'ea62cd50-e06f-11ed-b5ea-0242ac120002'
};
const jwtToken = jwtGenerator.createJwtToken('your-app-id', identity);

console.log(jwtToken);

/onesignal-jwt-generator/

    Package Sidebar

    Install

    npm i onesignal-jwt-generator

    Weekly Downloads

    61

    Version

    0.3.3

    License

    MIT

    Unpacked Size

    8.04 kB

    Total Files

    11

    Last publish

    Collaborators

    • rgomezp