GithubHelp home page GithubHelp logo

bshreddy / vault-api Goto Github PK

View Code? Open in Web Editor NEW
10.0 1.0 1.0 121 KB

Axios-like NodeJS API for Hashicorp Vault.

Home Page: https://github.com/SaiHemanthBR/vault-api/wiki

License: MIT License

JavaScript 10.12% TypeScript 89.88%
vault vault-api hashicorp hashicorp-vault hashivault vaultproject secrets-management secrets manage

vault-api's Introduction

Vault-API

Axios-like NodeJS API for Hashicorp Vault.

Installation

vault-api require Node.js >= v8.17.0.

npm install vault-api

Basic Usage

Requests can be made by passing the relevant config to vault function.

Importing
import vault from 'vault-api';

// (or)
// import {vault} from 'vault-api';
// const {vault} = require('vault-api');
vault(config)
// Write data to vault
vault({
    method: 'write',
    path: 'secret/apiKey',
    data: {
        webApp: '5cfdf55e-cfa9-5da8-b2b2-64f30a462a09value'
    }
});
// Read data from vault
vault({
    method: 'read',
    path: 'secret/apiKey'
});

Docs

Documentation and guides are available at Repo's Github Wiki

Supported Secrets Engines

  • Key/Value Version 1
  • Key/Value Version 2

Contributing

See CONTRIBUTING.md for Contributing guidelines.

Code of Conduct

See CODE_OF_CONDUCT.md for Code of Conduct guidelines.

License

License: MIT

Checkout the project license at LICENSE.md.

Credits

vault-api is heavily inspired by axios. I was inspired by the simplicity of the axios and wanted to make a similar library for Hashicorp Vault. The ultimate goal of this library is to provide a simple, easy to use, extensible API for interacting with Hashicorp Vault. I hope you enjoy using it!

Resources

vault-api's People

Contributors

bshreddy avatar mindbreak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

mindbreak

vault-api's Issues

Better type definition required

Greetings,

The type definition in this client is rudimental. Types in question:

import Config from './config';
import DefaultConfig from './default-config';
import VaultResponse from './vault-response';
export declare type VaultFunctionWithoutData = (path: string) => Promise<any>;
export declare type VaultFunctionWithData = (path: string, data: any) => Promise<any>;
export interface VaultFunc {
    (config: Config): Promise<VaultResponse>;
    create?: (defaultConfig: DefaultConfig) => VaultFunc;
    read: VaultFunctionWithoutData;
    list: VaultFunctionWithoutData;
    delete: VaultFunctionWithoutData;
    help: VaultFunctionWithoutData;
    write: VaultFunctionWithData;
}
export default VaultFunc;
  1. VaultFunc returns itself on create that one is just odd. While axios does something similar [Link] it returns an instance interface it extend from. Which brings me to. This also means that after returning an instance. You can STILL call create according to type definition...
  2. All vault function return the same interface. None of them are generic all of them return an any promise. This will not play nice with strict checks and no implicit any configs.
  3. create? is optional which makes it potentially undefined. As such I have to do vault.create?({ /* [...] */ }) to avoid an error/warning. This feels awkward.

Unclear documentation and VaultInvalidConfigError

The Wiki does not provide a basic example to answer the following:

"I have VAULT_TOKEN, VAULT_ADDR, and I provide the path in the following code:

const Value = await vault({
      method: 'read',
      path: '.../.../.../KEY'
    })

These three things should be enough to retrieve a value from my vault's kv pair, ergo what is an example of the simplest config that need only these 3 things to make my app not land me in the same puddle as this person: https://stackoverflow.com/questions/76114726/vaultinvalidconfigerror-how-can-i-add-a-simple-config-to-typescriptss-vault-ap"

Secondly, I read the docs and realize that I should first create a vault-api instance
Screenshot 2023-04-26 at 1 35 52 PM

However as seen above my 2023.1 IntelliJ with Version 4.9.5 TypeScript doesn't know what create is.
I haveimport vault from 'vault-api'; and I got that from npmjs

Types are missing

Types are not being properly exported in the published project. If you look at the vault-api/dist/index.d.ts file in the node_modules folder, you'll notice it attempts to reference the types from the ./types folder. This folder doesn't exist in the package so types are basically missing in typescript. I believe the issue may be with the .npmignore file ignoring the types folder, so it doesn't make it to the distributed package.

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.