@antimatterhq/cryptoserver
TypeScript icon, indicating that this package has built-in type declarations

0.5.14-rc5 • Public • Published

The purpose of the client library is to provide a convenient way to encrypt and decrypt data using the cryptoserver encryption as a service.

Installation

To install the typescript library, run

npm install --save --ignore-scripts @antimatterhq/cryptoserver

Usage

First, you must configure the client with authentication information. You will need to provide your API key, the name of the role to assume, and the name of the circumstance under which to assume the role. Then you can use the client to encrypt and decrypt.

import * as cryptoserver from '@antimatterhq/cryptoserver';

const client = new cryptoserver.Client(
    cryptoserver.AuthConfig.APIKey(
        "role",
        "circumstance",
        "apiKey",
    ),
    "localhost:8080",
);

// Alternatively, this can be done using a connection string
client = new cryptoserver.Client(
    undefined,
    "localhost:8080?role=role&circumstance=circumstance&api-key=apiKey",
);

// Define the compartment for encryption
const compartment = new cryptoserver.Compartment(
    process.env.EXTERNAL_ID || "",
    "default", // product name
    "default", // service name
    cryptoserver.DataType.Object,
);

// Encrypt some data
const plaintext = Buffer.from("this is some plaintext");
const ciphertext = client.encrypt(compartment, plaintext);

// Decrypt the data
const decryptedPlaintext = client.decrypt(ciphertext);

console.log(decryptedPlaintext.toString());

/@antimatterhq/cryptoserver/

    Package Sidebar

    Install

    npm i @antimatterhq/cryptoserver

    Weekly Downloads

    9

    Version

    0.5.14-rc5

    License

    none

    Unpacked Size

    633 kB

    Total Files

    17

    Last publish

    Collaborators

    • rock-antimatter
    • chris-antimatter
    • antimatter-michael