Skip to content
This repository has been archived by the owner on Sep 5, 2022. It is now read-only.

Commit

Permalink
feat(sdk): use sdk, add update method
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerthebest committed Jul 7, 2021
1 parent a630b39 commit e94c90f
Show file tree
Hide file tree
Showing 40 changed files with 679 additions and 924 deletions.
548 changes: 230 additions & 318 deletions package-lock.json

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@
"lint:check": "eslint \"src/**/*.ts\""
},
"dependencies": {
"@sniptt/snip-sdk-js": "0.0.5",
"base64url": "3.0.1",
"chalk": "4.1.1",
"cli-table": "0.3.6",
"enquirer": "2.3.6",
"fs-extra": "10.0.0",
"got": "11.8.2",
"keytar": "7.7.0",
"openpgp": "5.0.0-3",
"ora": "5.4.1",
Expand All @@ -55,21 +55,21 @@
},
"devDependencies": {
"@types/cli-table": "0.3.0",
"@types/faker": "5.5.6",
"@types/fs-extra": "9.0.11",
"@types/node": "15.12.2",
"@types/yargs": "17.0.0",
"@typescript-eslint/eslint-plugin": "4.27.0",
"@typescript-eslint/parser": "4.27.0",
"@types/faker": "5.5.7",
"@types/fs-extra": "9.0.12",
"@types/node": "16.0.0",
"@types/yargs": "17.0.2",
"@typescript-eslint/eslint-plugin": "4.28.2",
"@typescript-eslint/parser": "4.28.2",
"ava": "3.15.0",
"eslint": "7.28.0",
"eslint": "7.30.0",
"eslint-config-prettier": "8.3.0",
"faker": "5.5.3",
"nyc": "15.1.0",
"pkg": "5.2.1",
"prettier": "2.3.1",
"pkg": "5.3.0",
"prettier": "2.3.2",
"ts-node": "10.0.0",
"typescript": "4.3.3"
"typescript": "4.3.5"
},
"pkg": {
"scripts": "build/**/*.js"
Expand Down
4 changes: 2 additions & 2 deletions src/commands/configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const handler: Handler = async (argv) => {

const accountConfiguration = await api.retrieveAccountConfiguration(
{},
{ ApiKey: apiKey },
apiKey,
);
spinner.succeed();

Expand Down Expand Up @@ -155,7 +155,7 @@ export const handler: Handler = async (argv) => {
PersonalVaultEncryptedPrivateKey:
keys.personalVaultKeyPair.encryptedPrivateKey,
},
{ ApiKey: apiKey },
apiKey,
);
spinner.succeed();

Expand Down
15 changes: 7 additions & 8 deletions src/commands/secret_commands/add.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { readFile, statSync } from 'fs-extra';
import ora from 'ora';
import { basename } from 'path';

import { Builder, Handler } from './add.types';
import * as prompts from './add.prompts';
import * as outputs from './add.outputs';
import { baseOptions } from '../../shared';
import api from '../../services/api';
import { readUserConfig } from '../../services/config';
import crypto from '../../services/crypto';
import { baseOptions } from '../../shared';
import * as outputs from './add.outputs';
import * as prompts from './add.prompts';
import { Builder, Handler } from './add.types';

export const command = 'add [name] [value]';
export const desc = 'Add end-to-end encrypted secret to vault';
Expand Down Expand Up @@ -67,7 +66,7 @@ export const handler: Handler = async (argv) => {
spinner.start('Fetching existing vault memberships');
const vaultMemberships = await api.searchVaultMemberships(
{ VaultName: vaultName },
{ ApiKey: userConfig.Account.ApiKey },
userConfig.Account.ApiKey,
);
spinner.succeed();

Expand All @@ -78,7 +77,7 @@ export const handler: Handler = async (argv) => {
spinner.start('Fetching vault keys');
const vaultKeys = await api.retrieveVaultKeys(
{ VaultId: vaultId },
{ ApiKey: userConfig.Account.ApiKey },
userConfig.Account.ApiKey,
);
spinner.succeed();

Expand Down Expand Up @@ -112,7 +111,7 @@ export const handler: Handler = async (argv) => {
SecretContentType: contentType === 'file' ? 'File' : 'Text',
VaultId: vaultId,
},
{ ApiKey: userConfig.Account.ApiKey },
userConfig.Account.ApiKey,
);
spinner.succeed();

Expand Down
6 changes: 3 additions & 3 deletions src/commands/secret_commands/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const handler: Handler = async (argv) => {
spinner.start('Fetching existing vault memberships');
const vaultMemberships = await api.searchVaultMemberships(
{ VaultName: vaultName },
{ ApiKey: userConfig.Account.ApiKey },
userConfig.Account.ApiKey,
);
spinner.succeed();

Expand All @@ -53,7 +53,7 @@ export const handler: Handler = async (argv) => {
spinner.start('Fetching vault keys');
const vaultKeys = await api.retrieveVaultKeys(
{ VaultId: vaultId },
{ ApiKey: userConfig.Account.ApiKey },
userConfig.Account.ApiKey,
);
spinner.succeed();

Expand All @@ -69,7 +69,7 @@ export const handler: Handler = async (argv) => {
SecretName: secretName,
VaultId: vaultId,
},
{ ApiKey: userConfig.Account.ApiKey },
userConfig.Account.ApiKey,
);
spinner.succeed();

Expand Down
4 changes: 2 additions & 2 deletions src/commands/secret_commands/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const handler: Handler = async (argv) => {
spinner.start('Fetching existing vault memberships');
const vaultMemberships = await api.searchVaultMemberships(
{ VaultName: vaultName },
{ ApiKey: userConfig.Account.ApiKey },
userConfig.Account.ApiKey,
);
spinner.succeed();

Expand All @@ -49,7 +49,7 @@ export const handler: Handler = async (argv) => {
spinner.start('Fetching vault secrets');
const vaultSecrets = await api.listVaultSecrets(
{ VaultId: vaultId },
{ ApiKey: userConfig.Account.ApiKey },
userConfig.Account.ApiKey,
);
spinner.succeed();

Expand Down
4 changes: 2 additions & 2 deletions src/commands/secret_commands/remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const handler: Handler = async (argv) => {
spinner.start('Fetching existing vault memberships');
const vaultMemberships = await api.searchVaultMemberships(
{ VaultName: vaultName },
{ ApiKey: userConfig.Account.ApiKey },
userConfig.Account.ApiKey,
);
spinner.succeed();

Expand All @@ -54,7 +54,7 @@ export const handler: Handler = async (argv) => {
SecretName: secretName,
VaultId: vaultId,
},
{ ApiKey: userConfig.Account.ApiKey },
userConfig.Account.ApiKey,
);
spinner.succeed();

Expand Down
2 changes: 1 addition & 1 deletion src/commands/secret_commands/share.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const handler: Handler = async (argv) => {
OneTimeSecretEncryptedContent: encryptedContent,
OneTimeSecretContentType: contentType === 'file' ? 'File' : 'Text',
},
{ ApiKey: userConfig.Account.ApiKey },
userConfig.Account.ApiKey,
);
spinner.succeed();

Expand Down
38 changes: 38 additions & 0 deletions src/commands/secret_commands/update.outputs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import chalk from 'chalk';

export const secretAdded = ({
secretName,
vaultName,
}: {
secretName: string;
vaultName: string | undefined;
}): never => {
process.stdout.write(`
${chalk.cyan(secretName)} added to ${chalk.cyan(
vaultName ? vaultName : 'Personal',
)} vault!
To view:
${chalk.bold(
`$ snip get "${secretName}"${vaultName ? ` --vault "${vaultName}"` : ''}`,
)}
`);

process.exit(0);
};

export const secretAddedJson = ({
secretId,
vaultId,
}: {
secretId: string;
vaultId: string;
}): never => {
process.stdout.write(
JSON.stringify({ SecretId: secretId, VaultId: vaultId }, null, 2),
);

process.exit(0);
};
Loading

0 comments on commit e94c90f

Please sign in to comment.