Node.js SDK

SDK to integrate Phase in server-side applications running Node.js.

The Node.js SDK allows you to encrypt data server-side, as well as decrypt data.


In order to use the Node.js sdk you will need to create an account and add a new app. You require the APP_ID, APP_SECRET, and JWT_SECRET in order to properly use the app


Install the SDK

The Node.js SDK is distributed via npm. You can install it using the following command for your preferred package manager.

npm install @sklyerx/cypher

Import the SDK

Once installed, you can import the Node.js SDK into your project.

const { Cypher } = require("@sklyerx/cypher");
ESM
import { Cypher } from "@sklyerx/cypher";

Initialize the SDK

initialize the SDK with your APP_ID, APP_SECRET, and JWT_SECRET

const cypher = new Cypher({
  appId: APP_ID,
  appSecret: APP_SECRET,
  JWT_SECRET: JWT_SECRET,
});

Usage

Encrypt

The encrypt API allows you to encrypt data. It returns an encrypted string in the Cypher format.

const ciphertext = cypher.encrypt("hello world");

Decrypt

The decrypt API allows you to decrypt data the encrypted data as long as you have it in the Cypher Format and you have the correct credentials.

const plaintext = await phase.decrypt(ciphertext);