Giter Club home page Giter Club logo

vaults's Introduction

Typescript Library for HashiCorp vault

This is yet another typescript vault client. While other clients usually provide more APIs, we aim to fully type the requests and responses for an improved Developing experience.

Typing every request and response is rather time consuming, only a few vault APIs are implemented at the moment. If there is demand for us to use other APIs, they will be added. We are also always open to Pull Requests :)

Supported APIs

Currently, these APIs are implemented:

  • Health()
  • Transit(mountPoint)
  • Totp(mountPoint)
  • KV(version: 1|2, mountPoint)

Authentication

Token-based and Kubernetes Auth are supported as of now.

Token-Based

Initialize a new Vault Client using your token and endpoint:

const cert = await fs.readFile("../vault-cacert", "utf8");
const client = new Vault({
    vaultAddress: "http://127.0.0.1:8200",
    vaultToken: "SECRET",
    vaultCaCertificate: cert, // vault CA Cert, required for secure communication
});

Kubernetes In-Cluster Example

const client = new Vault({
    vaultAddress: "https://vault:8200",
    vaultCaCertificate: cert,
    vaultCaCertificatePath: "../vault-cacert",
});

const k8sauth = client.KubernetesAuth({
    role: "myrole",
});

await client.Auth(k8sauth).login();

client
    .Health()
    .health()
    .then((a) => console.log(a));

Usage

Once the Vault Client is created, instanciate new clients for each engine:

client.Health() // returns Health client
client.Transit("transit") // returns Transit client (uses mountpoint transit)
client.KV(2, "kv2") // returns KV2 client (uses mountpoint kv2)
client.KV(1, "kv") // returns KV client (uses mountpoint kv)
client.Totp("totp") // returns Totp client (uses mountpoint totp)

Each client supports the CRUD operations show in its respective API docs. Reqest and Response for each operation are fully typed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.