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.
  • defaultValues: Default values for secrets if they aren't fetched/passed in. Type: object. Default: {}.
  • 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.

Example Initialization with Options

await infisical.connect({
  token: "your_infisical_token",
  siteURL: "your_site_url",
  attachToProcessEnv: true,
  defaultValues: {
    JWT_LIFETIME: "15m",
  },
});

Access a Secret Value

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

Example with Express

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

app.get("/", (req, res) => {
  // access value
  const name = infisical.getSecret("NAME");

  res.send(`Hello! My name is: ${name}`);
});

app.listen(port, async () => {
  // initialize client
  await infisical.connect({
    token: "YOUR_INFISICAL_TOKEN",
  });

  console.log(`App listening on port ${port}`);
});