JSPM

  • Created
  • Published
  • Downloads 77671
  • Score
    100M100P100Q16500F
  • License ISC

Package Exports

  • infisical-node
  • infisical-node/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (infisical-node) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

infisical

Open-source, end-to-end encrypted tool to manage secrets and configs across your team, devices, and infrastructure.

Installation

$ npm install infisical-node

Import

// ES6 syntax
import infisical from "infisical-node";
// ES5 syntax
const infisical = require("infisical-node");

Initialization

If your app only needs to connect to one Infisical project, you should use infisical.connect. If you need to connect to multiple Infisical projects, use infisical.createConnection.

Both connect and createConnection take a parameter token and pull in the secrets accessible by that Infisical token.

// using async-await (recommended)
await infisical.connect({
  token: "your_infisical_token",
});
// using promise chaining
infisical.connect({
    token: "your_infisical_token"
})
.then(() => {
    console.log('Success!)
})
.catch(err => {
    console.error('Error: ', err);
})

Options

  • siteURL: Your self-hosted Infisical site URL. Type: string. Default: https://app.infisical.com.
  • attachToProcessEnv: Whether or not to attach fetched secrets to process.env. Type: boolean. Default: false.
  • debug: Turns debug mode on or off. If debug mode is enabled then the SDK will attempt to print out useful debugging information. Type: boolean. Default: false.

Access a Secret Value

const dbURL = infisical.get("DB_URL");

Access all Secret Values

const secrets = infisical.getAll();

Example with Express

const express = require("express");
const port = 3000;
const infisical = require("infisical-node");

const main = async () => {
  await infisical.connect({
    token: "YOUR_INFISICAL_TOKEN",
  });

  app.get("/", (req, res) => {
    // access value
    const name = infisical.get("NAME");
    res.send(`Hello! My name is: ${name}`);
  });

  app.get("/secrets", (req, res) => {
    // access value
    const secrets = infisical.getAll();
    res.json({ secrets });
  });

  app.listen(port, async () => {
    // initialize client
    console.log(`App listening on port ${port}`);
  });
};

main();