Skip to content

Commit

Permalink
chore: start using wiki pages (shahradelahi#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
shahradelahi authored May 26, 2024
1 parent 865148a commit 63ca563
Show file tree
Hide file tree
Showing 15 changed files with 371 additions and 169 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/wiki.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Wiki

on:
push:
branches: [master]
paths:
- .wiki/**
- .github/workflows/wiki.yml

concurrency:
group: publish-wiki
cancel-in-progress: true

permissions:
contents: write

jobs:
publish-wiki:
if: github.repository == 'shahradelahi/node-vault'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- uses: Andrew-Chen-Wang/github-wiki-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: '${{ env.SHORT_SHA }}: ${{ github.event.head_commit.message }}'
repository: ${{ github.repository }}
path: .wiki
187 changes: 187 additions & 0 deletions .wiki/Home.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
Welcome to the node-vault wiki!

# Supported features

## Secrets Engines

- [ ] [AliCloud](https://developer.hashicorp.com/vault/api-docs/secret/alicloud)
- [x] [AWS](https://developer.hashicorp.com/vault/api-docs/secret/aws)
- [ ] [Azure](https://developer.hashicorp.com/vault/api-docs/secret/azure)
- [ ] [Consul](https://developer.hashicorp.com/vault/api-docs/secret/consul)
- [ ] [Cubbyhole](https://developer.hashicorp.com/vault/api-docs/secret/cubbyhole)
- [ ] [Google Cloud](https://developer.hashicorp.com/vault/api-docs/secret/gcp)
- [ ] [Google Cloud KMS](https://developer.hashicorp.com/vault/api-docs/secret/gcpkms)
- [ ] [KMIP](https://developer.hashicorp.com/vault/api-docs/secret/kmip)
- [x] [Kubernetes](https://developer.hashicorp.com/vault/api-docs/secret/kubernetes)
- [ ] [MongoDB Atlas](https://developer.hashicorp.com/vault/api-docs/secret/mongodbatlas)
- [ ] [Nomad](https://developer.hashicorp.com/vault/api-docs/secret/nomad)
- [ ] [LDAP](https://developer.hashicorp.com/vault/api-docs/secret/ldap)
- [ ] [PKI](https://developer.hashicorp.com/vault/api-docs/secret/pki)
- [ ] [RabbitMQ](https://developer.hashicorp.com/vault/api-docs/secret/rabbitmq)
- [ ] [SSH](https://developer.hashicorp.com/vault/api-docs/secret/ssh)
- [ ] [Terraform Cloud](https://developer.hashicorp.com/vault/api-docs/secret/terraform)
- [ ] [TOTP](https://developer.hashicorp.com/vault/api-docs/secret/totp)
- [ ] [Transform](https://developer.hashicorp.com/vault/api-docs/secret/transform)
- [ ] [Transit](https://developer.hashicorp.com/vault/api-docs/secret/transit)

### Database

- [ ] [Cassandra](https://developer.hashicorp.com/vault/api-docs/secret/databases/cassandra)
- [ ] [Couchbase](https://developer.hashicorp.com/vault/api-docs/secret/databases/couchbase)
- [ ] [Elasticsearch](https://developer.hashicorp.com/vault/api-docs/secret/databases/elasticdb)
- [ ] [InfluxDB](https://developer.hashicorp.com/vault/api-docs/secret/databases/influxdb)
- [ ] [HanaDB](https://developer.hashicorp.com/vault/api-docs/secret/databases/hanadb)
- [ ] [MongoDB](https://developer.hashicorp.com/vault/api-docs/secret/databases/mongodb)
- [ ] [MongoDB Atlas](https://developer.hashicorp.com/vault/api-docs/secret/databases/mongodbatlas)
- [ ] [MSSQL](https://developer.hashicorp.com/vault/api-docs/secret/databases/mssql)
- [ ] [MySQL/MariaDB](https://developer.hashicorp.com/vault/api-docs/secret/databases/mysql-maria)
- [ ] [Oracle](https://developer.hashicorp.com/vault/api-docs/secret/databases/oracle)
- [ ] [PostgreSQL](https://developer.hashicorp.com/vault/api-docs/secret/databases/postgresql)
- [ ] [Redis](https://developer.hashicorp.com/vault/api-docs/secret/databases/redis)
- [ ] [Redis ElastiCache](https://developer.hashicorp.com/vault/api-docs/secret/databases/rediselasticache)
- [ ] [Redshift](https://developer.hashicorp.com/vault/api-docs/secret/databases/redshift)
- [ ] [Snowflake](https://developer.hashicorp.com/vault/api-docs/secret/databases/snowflake)

### Identity

- [ ] [Entity](https://developer.hashicorp.com/vault/api-docs/secret/identity/entity)
- [ ] [Entity Alias](https://developer.hashicorp.com/vault/api-docs/secret/identity/entity-alias)
- [ ] [Group](https://developer.hashicorp.com/vault/api-docs/secret/identity/group)
- [ ] [Group Alias](https://developer.hashicorp.com/vault/api-docs/secret/identity/group-alias)
- [ ] [Identity Tokens](https://developer.hashicorp.com/vault/api-docs/secret/identity/tokens)
- [ ] [Lookup](https://developer.hashicorp.com/vault/api-docs/secret/identity/lookup)
- [ ] [OIDC Provider](https://developer.hashicorp.com/vault/api-docs/secret/identity/oidc-provider)

#### MFA

- [ ] [Duo](https://developer.hashicorp.com/vault/api-docs/secret/identity/mfa/duo)
- [ ] [Okta](https://developer.hashicorp.com/vault/api-docs/secret/identity/mfa/okta)
- [ ] [PingID](https://developer.hashicorp.com/vault/api-docs/secret/identity/mfa/pingid)
- [ ] [TOTP](https://developer.hashicorp.com/vault/api-docs/secret/identity/mfa/totp)
- [ ] [Login Enforcement](https://developer.hashicorp.com/vault/api-docs/secret/identity/mfa/login-enforcement)

### Key/Value

- [x] [K/V Version 1](https://developer.hashicorp.com/vault/api-docs/secret/kv/kv-v1)
- [x] [K/V Version 2](https://developer.hashicorp.com/vault/api-docs/secret/kv/kv-v2)

### Key Management

- [ ] [Azure Key Vault](https://developer.hashicorp.com/vault/api-docs/secret/key-management/azurekeyvault)
- [ ] [AWS KMS](https://developer.hashicorp.com/vault/api-docs/secret/key-management/awskms)
- [ ] [GCP Cloud KMS](https://developer.hashicorp.com/vault/api-docs/secret/key-management/gcpkms)

## Auth Methods

- [ ] [AliCloud](https://developer.hashicorp.com/vault/api-docs/auth/alicloud)
- [ ] [AppRole](https://developer.hashicorp.com/vault/api-docs/auth/approle)
- [ ] [AWS](https://developer.hashicorp.com/vault/api-docs/auth/aws)
- [ ] [Azure](https://developer.hashicorp.com/vault/api-docs/auth/azure)
- [ ] [Cloud Foundry](https://developer.hashicorp.com/vault/api-docs/auth/cf)
- [ ] [GitHub](https://developer.hashicorp.com/vault/api-docs/auth/github)
- [ ] [Google Cloud](https://developer.hashicorp.com/vault/api-docs/auth/gcp)
- [ ] [JWT/OIDC](https://developer.hashicorp.com/vault/api-docs/auth/jwt)
- [ ] [Kerberos](https://developer.hashicorp.com/vault/api-docs/auth/kerberos)
- [ ] [Kubernetes](https://developer.hashicorp.com/vault/api-docs/auth/kubernetes)
- [ ] [LDAP](https://developer.hashicorp.com/vault/api-docs/auth/ldap)
- [ ] [OCI](https://developer.hashicorp.com/vault/api-docs/auth/oci)
- [ ] [Okta](https://developer.hashicorp.com/vault/api-docs/auth/okta)
- [ ] [RADIUS](https://developer.hashicorp.com/vault/api-docs/auth/radius)
- [ ] [SAML](https://developer.hashicorp.com/vault/api-docs/auth/saml)
- [ ] [TLS Certificates](https://developer.hashicorp.com/vault/api-docs/auth/cert)
- [ ] [Token](https://developer.hashicorp.com/vault/api-docs/auth/token)
- [ ] [Username & Password](https://developer.hashicorp.com/vault/api-docs/auth/userpass)

## System Backend

- [x] [/sys/audit](https://developer.hashicorp.com/vault/api-docs/system/audit)
- [ ] [/sys/audit-hash](https://developer.hashicorp.com/vault/api-docs/system/audit-hash)
- [ ] [/sys/auth](https://developer.hashicorp.com/vault/api-docs/system/auth)
- [x] [/sys/capabilities](https://developer.hashicorp.com/vault/api-docs/system/capabilities)
- [ ] [/sys/capabilities-accessor](https://developer.hashicorp.com/vault/api-docs/system/capabilities-accessor)
- [ ] [/sys/capabilities-self](https://developer.hashicorp.com/vault/api-docs/system/capabilities-self)
- [ ] [/sys/config/auditing/request-headers](https://developer.hashicorp.com/vault/api-docs/system/config-auditing)
- [ ] [/sys/config/control-group](https://developer.hashicorp.com/vault/api-docs/system/config-control-group)
- [ ] [/sys/config/cors](https://developer.hashicorp.com/vault/api-docs/system/config-cors)
- [ ] [/sys/config/group-policy-application](https://developer.hashicorp.com/vault/api-docs/system/config-group-policy-application)
- [ ] [/sys/config/reload](https://developer.hashicorp.com/vault/api-docs/system/config-reload)
- [ ] [/sys/config/state](https://developer.hashicorp.com/vault/api-docs/system/config-state)
- [ ] [/sys/config/ui](https://developer.hashicorp.com/vault/api-docs/system/config-ui)
- [ ] [/sys/control-group](https://developer.hashicorp.com/vault/api-docs/system/control-group)
- [ ] [/sys/decode-token](https://developer.hashicorp.com/vault/api-docs/system/decode-token)
- [ ] [/sys/experiments](https://developer.hashicorp.com/vault/api-docs/system/experiments)
- [ ] [/sys/generate-recovery-token](https://developer.hashicorp.com/vault/api-docs/system/generate-recovery-token)
- [x] [/sys/generate-root](https://developer.hashicorp.com/vault/api-docs/system/generate-root)
- [x] [/sys/health](https://developer.hashicorp.com/vault/api-docs/system/health)
- [x] [/sys/host-info](https://developer.hashicorp.com/vault/api-docs/system/host-info)
- [ ] [/sys/in-flight-req](https://developer.hashicorp.com/vault/api-docs/system/in-flight-req)
- [x] [/sys/init](https://developer.hashicorp.com/vault/api-docs/system/init)
- [ ] [/sys/internal/counters](https://developer.hashicorp.com/vault/api-docs/system/internal-counters)
- [ ] [/sys/internal/specs/openapi](https://developer.hashicorp.com/vault/api-docs/system/internal-specs-openapi)
- [ ] [/sys/internal/ui/feature-flags](https://developer.hashicorp.com/vault/api-docs/system/internal-ui-feature)
- [ ] [/sys/internal/ui/mounts](https://developer.hashicorp.com/vault/api-docs/system/internal-ui-mounts)
- [ ] [/sys/internal/ui/namespaces](https://developer.hashicorp.com/vault/api-docs/system/internal-ui-namespaces)
- [ ] [/sys/internal/ui/resultant-acl](https://developer.hashicorp.com/vault/api-docs/system/internal-ui-resultant-acl)
- [ ] [/sys/key-status](https://developer.hashicorp.com/vault/api-docs/system/key-status)
- [ ] [/sys/ha-status](https://developer.hashicorp.com/vault/api-docs/system/ha-status)
- [ ] [/sys/leader](https://developer.hashicorp.com/vault/api-docs/system/leader)
- [ ] [/sys/leases](https://developer.hashicorp.com/vault/api-docs/system/leases)
- [ ] [/sys/license/status](https://developer.hashicorp.com/vault/api-docs/system/license)
- [ ] [/sys/locked-users](https://developer.hashicorp.com/vault/api-docs/system/user-lockout)
- [ ] [/sys/loggers](https://developer.hashicorp.com/vault/api-docs/system/loggers)
- [ ] [/sys/managed-keys](https://developer.hashicorp.com/vault/api-docs/system/managed-keys)
- [ ] [/sys/metrics](https://developer.hashicorp.com/vault/api-docs/system/metrics)
- [ ] [/sys/monitor](https://developer.hashicorp.com/vault/api-docs/system/monitor)
- [x] [/sys/mounts](https://developer.hashicorp.com/vault/api-docs/system/mounts)
- [ ] [/sys/namespaces](https://developer.hashicorp.com/vault/api-docs/system/namespaces)
- [ ] [/sys/plugins/reload/backend](https://developer.hashicorp.com/vault/api-docs/system/plugins-reload-backend)
- [ ] [/sys/plugins/catalog](https://developer.hashicorp.com/vault/api-docs/system/plugins-catalog)
- [ ] [/sys/plugins/runtimes/catalog](https://developer.hashicorp.com/vault/api-docs/system/plugins-runtimes-catalog)
- [ ] [/sys/policy](https://developer.hashicorp.com/vault/api-docs/system/policy)
- [ ] [/sys/policies](https://developer.hashicorp.com/vault/api-docs/system/policies)
- [ ] [/sys/policies/password](https://developer.hashicorp.com/vault/api-docs/system/policies-password)
- [ ] [/sys/pprof](https://developer.hashicorp.com/vault/api-docs/system/pprof)
- [ ] [/sys/quotas/config](https://developer.hashicorp.com/vault/api-docs/system/quotas-config)
- [ ] [/sys/quotas/rate-limit](https://developer.hashicorp.com/vault/api-docs/system/rate-limit-quotas)
- [ ] [/sys/quotas/lease-count](https://developer.hashicorp.com/vault/api-docs/system/lease-count-quotas)
- [ ] [/sys/raw](https://developer.hashicorp.com/vault/api-docs/system/raw)
- [ ] [/sys/rekey](https://developer.hashicorp.com/vault/api-docs/system/rekey)
- [ ] [/sys/rekey-recovery-key](https://developer.hashicorp.com/vault/api-docs/system/rekey-recovery-key)
- [ ] [/sys/remount](https://developer.hashicorp.com/vault/api-docs/system/remount)
- [ ] [/sys/rotate](https://developer.hashicorp.com/vault/api-docs/system/rotate)
- [ ] [/sys/rotate/config](https://developer.hashicorp.com/vault/api-docs/system/rotate-config)
- [x] [/sys/seal](https://developer.hashicorp.com/vault/api-docs/system/seal)
- [x] [/sys/seal-status](https://developer.hashicorp.com/vault/api-docs/system/seal-status)
- [ ] [/sys/seal-backend-status](https://developer.hashicorp.com/vault/api-docs/system/seal-backend-status)
- [ ] [/sys/sealwrap/rewrap](https://developer.hashicorp.com/vault/api-docs/system/sealwrap-rewrap)
- [ ] [/sys/step-down](https://developer.hashicorp.com/vault/api-docs/system/step-down)
- [ ] [/sys/sync](https://developer.hashicorp.com/vault/api-docs/system/secrets-sync)
- [ ] [/sys/tools](https://developer.hashicorp.com/vault/api-docs/system/tools)
- [x] [/sys/unseal](https://developer.hashicorp.com/vault/api-docs/system/unseal)
- [ ] [/sys/version-history](https://developer.hashicorp.com/vault/api-docs/system/version-history)
- [ ] [/sys/wrapping/lookup](https://developer.hashicorp.com/vault/api-docs/system/wrapping-lookup)
- [ ] [/sys/wrapping/rewrap](https://developer.hashicorp.com/vault/api-docs/system/wrapping-rewrap)
- [ ] [/sys/wrapping/unwrap](https://developer.hashicorp.com/vault/api-docs/system/wrapping-unwrap)
- [ ] [/sys/wrapping/wrap](https://developer.hashicorp.com/vault/api-docs/system/wrapping-wrap)

### /sys/internal/inspect

- [ ] [/sys/internal/inspect/router](https://developer.hashicorp.com/vault/api-docs/system/inspect/router)

### /sys/mfa

- [ ] [/sys/mfa/method/duo](https://developer.hashicorp.com/vault/api-docs/system/mfa/duo)
- [ ] [/sys/mfa/method/okta](https://developer.hashicorp.com/vault/api-docs/system/mfa/okta)
- [ ] [/sys/mfa/method/pingid](https://developer.hashicorp.com/vault/api-docs/system/mfa/pingid)
- [ ] [/sys/mfa/method/totp](https://developer.hashicorp.com/vault/api-docs/system/mfa/totp)
- [ ] [/sys/mfa/validate](https://developer.hashicorp.com/vault/api-docs/system/mfa/validate)

### /sys/replication

- [ ] [/sys/replication/performance](https://developer.hashicorp.com/vault/api-docs/system/replication/replication-performance)
- [ ] [/sys/replication/dr](https://developer.hashicorp.com/vault/api-docs/system/replication/replication-dr)

### /sys/storage

- [ ] [/sys/storage/raft](https://developer.hashicorp.com/vault/api-docs/system/storage/raft)
- [ ] [/sys/storage/raft/snapshot-auto](https://developer.hashicorp.com/vault/api-docs/system/storage/raftautosnapshots)
74 changes: 74 additions & 0 deletions .wiki/Usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
## Custom Command Implementation

At times, you may need to use a command or endpoint that is not available in the library, or you may want to use it in a
different way. Here is an example of how to do that:

```typescript
import { Client } from '@litehex/node-vault';
import { z } from 'zod';

const vc = new Client({
/** ... */
});

const status = generateCommand({
path: '/sys/seal-status',
method: 'GET',
client: vc,
// refine: change the request before sending
refine: (req, args) => {
req.headers = Object.assign(req.headers || {}, {
'X-Custom-Header': 'bar'
});

console.log(args); // { 'X-Zone': 'foo' }

return req;
},
schema: {
// path: z.object({}), Schema for template in path
// searchParams: z.object({}), Any schema for query params
// headers: z.object({}), Headers schema
headers: z.object({
'X-Zone': z.string()
}),
// body: z.object({}), // Schema for request body
response: z.object({
sealed: z.boolean()
})
}
});

await status({ 'X-Zone': 'foo' });
```

If you do not understand how you must write your command, please refer
to [the source code](https://github.com/shahradelahi/node-vault). There is various of the working code in the source
code.

## Send Requests Using Proxy

To connect to a Vault server in a private network, you can use proxies to send the request.

First, install the `undici` package, which is the default HTTP client for Node.js:

```bash
npm install undici
```

Then, using the following code, create a proxy agent and pass it to the client:

```typescript
import { Client } from '@litehex/node-vault';
import { ProxyAgent } from 'undici';

const agent = new ProxyAgent('http://localhost:8080');

const vc = new Client({
// ... other params
request: { dispatcher: agent }
});

// Each individual command accepts the a second parameter to modify the request
const status = vc.sealStatus(undefined, { dispatcher: agent });
```
59 changes: 40 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,46 @@
# node-vault

> A modern JavaScript client for HashiCorp's Vault with a focus on ease-of-use.
[![Build status](https://github.com/shahradelahi/node-vault/actions/workflows/ci.yml/badge.svg)](https://github.com/shahradelahi/node-vault/actions/workflows/ci.yml)
[![Dependency Status](https://img.shields.io/librariesio/release/npm/@litehex%2Fnode-vault.svg)](https://libraries.io/npm/@litehex%2Fnode-vault/)
[![npm](https://img.shields.io/npm/v/@litehex/node-vault)](https://www.npmjs.com/package/@litehex/node-vault)
[![install size](https://packagephobia.com/badge?p=@litehex/node-vault)](https://packagephobia.com/result?p=@litehex/node-vault)
[![GPL-3.0 Licensed](https://img.shields.io/badge/License-GPL3.0-blue.svg?style=flat)](https://opensource.org/licenses/GPL-3.0)

### Notable features

- Mostly type-safe
- Highly extendable and configurable

### πŸ“¦ Installation
<div style="text-align: center;">
<img src="logo.svg" alt="NodeVault Logo" style="width: 100%;max-width: 200px;"/>
<br/>
<p>
<a href="https://github.com/shahradelahi/node-vault/actions/workflows/ci.yml" title="Build status"><img src="https://github.com/shahradelahi/node-vault/actions/workflows/ci.yml/badge.svg" alt="Build status"></a>
<a href="https://www.npmjs.com/package/@litehex/node-vault" title="NPM Version"><img src="https://img.shields.io/npm/v/@litehex/node-vault" alt="npm"></a>
<a href="https://libraries.io/npm/@litehex%2Fnode-vault/" title="Dependency Status"><img src="https://img.shields.io/librariesio/release/npm/@litehex%2Fnode-vault.svg" alt="Dependency Status"></a>
<a href="https://opensource.org/licenses/GPL-3.0" title="License"><img src="https://img.shields.io/badge/License-GPL3.0-blue.svg?style=flat" alt="GPL-3.0 Licensed"></a>
<br/>
<a href="https://packagephobia.com/result?p=@litehex/node-vault" title="Install size"><img src="https://packagephobia.com/badge?p=@litehex/node-vault" alt="install size"></a>
<a href="https://www.npmjs.com/package/@litehex/node-vault" title="Unpacked Size"><img alt="NPM Unpacked Size" src="https://img.shields.io/npm/unpacked-size/%40litehex%2Fnode-vault"></a>
<a href="https://visitorbadge.io/status?path=https%3A%2F%2Fgithub.com%2Fshahradelahi%2Fnode-vault" title="Visitors"><img src="https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fgithub.com%2Fshahradelahi%2Fnode-vault&amp;countColor=%23263759&amp;style=flat&amp;labelStyle=upper" alt="Visitors"></a>
</p>
</div>

# Node Vault

> A Modern javascript client for [HashiCorp's Vault](https://developer.hashicorp.com/vault/api-docs) with a focus on ease-of-use.
---

- [Features](#features)
- [Installation](#-installation)
- [Usage](#-usage)
- [Init and unseal vault](#init-and-unseal-vault)
- [Create Key/Value V2 engine](#create-keyvalue-v2-engine)
- [Create, read, update, delete secrets](#write-read-and-delete-secrets)
- [Documentation](#-documentation)
- [Contributing](#-contributing)
- [License](#license)

## Features

- Typesafe API
- Extendable by create custom commands

## πŸ“¦ Installation

```bash
npm install @litehex/node-vault
```

### πŸ“– Usage
## πŸ“– Usage

##### Init and unseal vault

Expand Down Expand Up @@ -81,10 +102,10 @@ const deleted = await vc.kv2.deleteLatest({ mountPath, path });
console.log(deleted); // true
```

Check out the [examples](/examples) and [tests](/tests) directory for more examples.

### πŸ“š Documentation

For complete usages, please dive into the [Wiki](https://github.com/shahradelahi/node-vault/wiki).

For all configuration options, please see [the API docs](https://paka.dev/npm/@litehex/node-vault).

### 🀝 Contributing
Expand Down
Loading

0 comments on commit 63ca563

Please sign in to comment.