Skip to content

Commit

Permalink
docs(hashicorp-vault-signing-manager): clarify Vault URL description
Browse files Browse the repository at this point in the history
  • Loading branch information
monitz87 committed Mar 4, 2022
1 parent b7293ce commit e3247d8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions packages/hashicorp-vault-signing-manager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { Polymesh } from '@polymathnetwork/polymesh-sdk';

// setup
const signingManager = new HashicorpVaultSigningManager({
// URL where the vault is hosted
url: 'https://my-hosted-vault.io',
// URL of the Vault's transit engine
url: 'https://my-hosted-vault.io/v1/transit',
// authentication token
token: 'willNeverTell',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class HashicorpVaultSigningManager implements SigningManager {
/**
* Create an instance of the Hashicorp Vault Signing Manager
*
* @param args.url - points to where the vault is hosted
* @param args.url - points to where the Vault's transit engine is hosted (usually `<base-url>/v1/transit`)
* @param args.token - authentication token used for signing
*/
public constructor(args: { url: string; token: string }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('HashicorpVault class', () => {
});

describe('method: fetchAllKeys', () => {
it('should return all keys stored in the vault', async () => {
it('should return all keys stored in the Vault', async () => {
fetchStub
.mockResolvedValueOnce(
createMockResponse(200, 'Ok', {
Expand Down Expand Up @@ -79,7 +79,7 @@ describe('HashicorpVault class', () => {
expect(result).toEqual(expectedKeys);
});

it('should throw any errors returned by the vault API', () => {
it('should throw any errors returned by the Vault API', () => {
fetchStub.mockResolvedValue(
createMockResponse(400, 'Bad Request', {
errors: ['Something went wrong'],
Expand Down Expand Up @@ -116,7 +116,7 @@ describe('HashicorpVault class', () => {
expect(result).toEqual([expectedKeys[0], expectedKeys[1]]);
});

it('should throw any errors returned by the vault API', () => {
it('should throw any errors returned by the Vault API', () => {
fetchStub.mockResolvedValue(createMockResponse(400, 'Bad Request', {}));

return expect(vault.fetchAllKeys()).rejects.toThrow(
Expand Down Expand Up @@ -148,7 +148,7 @@ describe('HashicorpVault class', () => {
);
});

it('should throw any errors returned by the vault API', () => {
it('should throw any errors returned by the Vault API', () => {
fetchStub.mockResolvedValue(
createMockResponse(400, 'Bad Request', {
errors: ['THE END IS NIGH'],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fetch from 'cross-fetch';
import { flatten, map } from 'lodash';
import { flatten, map, trim } from 'lodash';

import {
GetKeyResponse,
Expand Down Expand Up @@ -122,7 +122,9 @@ export class HashicorpVault {

if (![200, 204].includes(status)) {
const { errors = [] } = await res.json();
const reasons = errors.length ? `. Reason(s): "${errors.join('", "')}"` : '';
const reasons = errors.length
? `. Reason(s): "${errors.join('", "').replace(/[\n\t*]/g, '')}"`
: '';
throw new Error(`Vault response error: ${status} - ${statusText}${reasons}`);
}
}
Expand Down

0 comments on commit e3247d8

Please sign in to comment.