From e94c90f6ff5326f75f94379f0f5cd971f8ea4787 Mon Sep 17 00:00:00 2001 From: Roger Date: Wed, 7 Jul 2021 18:24:29 +0100 Subject: [PATCH] feat(sdk): use sdk, add update method --- package-lock.json | 548 ++++++++---------- package.json | 22 +- src/commands/configure.ts | 4 +- src/commands/secret_commands/add.ts | 15 +- src/commands/secret_commands/get.ts | 6 +- src/commands/secret_commands/list.ts | 4 +- src/commands/secret_commands/remove.ts | 4 +- src/commands/secret_commands/share.ts | 2 +- .../secret_commands/update.outputs.ts | 38 ++ .../secret_commands/update.prompts.ts | 186 ++++++ src/commands/secret_commands/update.ts | 154 +++++ src/commands/secret_commands/update.types.ts | 14 + src/commands/vault_commands/add-member.ts | 10 +- src/commands/vault_commands/create.ts | 2 +- src/commands/vault_commands/list-members.ts | 4 +- src/commands/vault_commands/list.ts | 2 +- src/commands/vault_commands/remove-member.ts | 10 +- src/handleError.ts | 13 +- src/services/api.ts | 9 + src/services/api/httpClient.ts | 9 - src/services/api/index.ts | 37 -- src/services/api/methods/addMemberToVault.ts | 23 - src/services/api/methods/addSecret.ts | 32 - src/services/api/methods/configureAccount.ts | 35 -- .../api/methods/createOneTimeSecret.ts | 32 - src/services/api/methods/createVault.ts | 31 - src/services/api/methods/deleteSecret.ts | 21 - src/services/api/methods/listVaultMembers.ts | 32 - .../api/methods/listVaultMemberships.ts | 33 -- src/services/api/methods/listVaultSecrets.ts | 35 -- src/services/api/methods/registerDevice.ts | 24 - .../api/methods/removeMemberFromVault.ts | 22 - .../methods/retrieveAccountConfiguration.ts | 36 -- .../api/methods/retrieveAccountPublicKey.ts | 29 - src/services/api/methods/retrieveSecret.ts | 33 -- src/services/api/methods/retrieveVaultKeys.ts | 30 - .../api/methods/searchVaultMemberships.ts | 36 -- .../api/methods/sendEmailVerificationCode.ts | 9 - src/services/api/types.ts | 7 - src/services/api/validators.ts | 10 - 40 files changed, 679 insertions(+), 924 deletions(-) create mode 100644 src/commands/secret_commands/update.outputs.ts create mode 100644 src/commands/secret_commands/update.prompts.ts create mode 100644 src/commands/secret_commands/update.ts create mode 100644 src/commands/secret_commands/update.types.ts create mode 100644 src/services/api.ts delete mode 100644 src/services/api/httpClient.ts delete mode 100644 src/services/api/index.ts delete mode 100644 src/services/api/methods/addMemberToVault.ts delete mode 100644 src/services/api/methods/addSecret.ts delete mode 100644 src/services/api/methods/configureAccount.ts delete mode 100644 src/services/api/methods/createOneTimeSecret.ts delete mode 100644 src/services/api/methods/createVault.ts delete mode 100644 src/services/api/methods/deleteSecret.ts delete mode 100644 src/services/api/methods/listVaultMembers.ts delete mode 100644 src/services/api/methods/listVaultMemberships.ts delete mode 100644 src/services/api/methods/listVaultSecrets.ts delete mode 100644 src/services/api/methods/registerDevice.ts delete mode 100644 src/services/api/methods/removeMemberFromVault.ts delete mode 100644 src/services/api/methods/retrieveAccountConfiguration.ts delete mode 100644 src/services/api/methods/retrieveAccountPublicKey.ts delete mode 100644 src/services/api/methods/retrieveSecret.ts delete mode 100644 src/services/api/methods/retrieveVaultKeys.ts delete mode 100644 src/services/api/methods/searchVaultMemberships.ts delete mode 100644 src/services/api/methods/sendEmailVerificationCode.ts delete mode 100644 src/services/api/types.ts delete mode 100644 src/services/api/validators.ts diff --git a/package-lock.json b/package-lock.json index 87f9a96..5f9b4a8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -908,6 +908,23 @@ } } }, + "@humanwhocodes/config-array": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.5.0.tgz", + "integrity": "sha512-FagtKFz74XrTl7y6HCzQpwDfXP0yhxe9lHLD1UZxjvZIcbyRz8zTFF/yYNfSfzU414eDwZ1SrO0Qvtyf+wFMQg==", + "dev": true, + "requires": { + "@humanwhocodes/object-schema": "^1.2.0", + "debug": "^4.1.1", + "minimatch": "^3.0.4" + } + }, + "@humanwhocodes/object-schema": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.0.tgz", + "integrity": "sha512-wdppn25U8z/2yiaT6YGquE6X8sSv7hNMWSXYSSU1jGv/yd6XqjXgTDJ8KP4NgjTXfJ3GbRjeeb8RTV7a/VpM+w==", + "dev": true + }, "@istanbuljs/load-nyc-config": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", @@ -967,17 +984,14 @@ "fastq": "^1.6.0" } }, - "@sindresorhus/is": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.0.1.tgz", - "integrity": "sha512-Qm9hBEBu18wt1PO2flE7LPb30BHMQt1eQgbV76YntdNk73XZGpn3izvGTYxbGgzXKgbCjiia0uxTd3aTNQrY/g==" - }, - "@szmarczak/http-timer": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.5.tgz", - "integrity": "sha512-PyRA9sm1Yayuj5OIoJ1hGt2YISX45w9WcFbh6ddT0Z/0yaFxOtGLInr4jUfU1EAFVs0Yfyfev4RNwBlUaHdlDQ==", + "@sniptt/snip-sdk-js": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/@sniptt/snip-sdk-js/-/snip-sdk-js-0.0.5.tgz", + "integrity": "sha512-75ZG4JBEJPo6t6SdKB5UFjW4gp4nKdnEO+9Po8TEKqfQszB3InK9kWtjbSxjTEhlOhWSibRq/pe8HbUXUBIrkg==", "requires": { - "defer-to-connect": "^2.0.0" + "cross-fetch": "3.1.4", + "es6-promise": "4.2.8", + "isomorphic-fetch": "3.0.0" } }, "@tsconfig/node10": { @@ -1004,17 +1018,6 @@ "integrity": "sha512-FTgBI767POY/lKNDNbIzgAX6miIDBs6NTCbdlDb8TrWovHsSvaVIZDlTqym29C6UqhzwcJx4CYr+AlrMywA0cA==", "dev": true }, - "@types/cacheable-request": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.1.tgz", - "integrity": "sha512-ykFq2zmBGOCbpIXtoVbz4SKY5QriWPh3AjyU4G74RYbtt5yOc5OfaY75ftjg7mikMOla1CTGpX3lLbuJh8DTrQ==", - "requires": { - "@types/http-cache-semantics": "*", - "@types/keyv": "*", - "@types/node": "*", - "@types/responselike": "*" - } - }, "@types/cli-table": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/@types/cli-table/-/cli-table-0.3.0.tgz", @@ -1022,48 +1025,36 @@ "dev": true }, "@types/faker": { - "version": "5.5.6", - "resolved": "https://registry.npmjs.org/@types/faker/-/faker-5.5.6.tgz", - "integrity": "sha512-UCRj0kLg4sXs2XFVm48OU/wIjyJZkpRkwxhRGVQb5l5GmemkeW22WTz9iiDhYPBUqTzDsIWzhFRuF/4DD5+q2Q==", + "version": "5.5.7", + "resolved": "https://registry.npmjs.org/@types/faker/-/faker-5.5.7.tgz", + "integrity": "sha512-ejzb61Q5zQTtS0ZIafgQ7ahO5ACzmGhG5PfX2hxWyth3k0/aysb4ZOxKQB8DbzwSPppA5jmFBwqnBxjv5hqI5Q==", "dev": true }, "@types/fs-extra": { - "version": "9.0.11", - "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-9.0.11.tgz", - "integrity": "sha512-mZsifGG4QeQ7hlkhO56u7zt/ycBgGxSVsFI/6lGTU34VtwkiqrrSDgw0+ygs8kFGWcXnFQWMrzF2h7TtDFNixA==", + "version": "9.0.12", + "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-9.0.12.tgz", + "integrity": "sha512-I+bsBr67CurCGnSenZZ7v94gd3tc3+Aj2taxMT4yu4ABLuOgOjeFxX3dokG24ztSRg5tnT00sL8BszO7gSMoIw==", "dev": true, "requires": { "@types/node": "*" } }, - "@types/http-cache-semantics": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.0.tgz", - "integrity": "sha512-c3Xy026kOF7QOTn00hbIllV1dLR9hG9NkSrLQgCVs8NF6sBU+VGWjD3wLPhmh1TYAc7ugCFsvHYMN4VcBN1U1A==" - }, "@types/json-schema": { - "version": "7.0.7", - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.7.tgz", - "integrity": "sha512-cxWFQVseBm6O9Gbw1IWb8r6OS4OhSt3hPZLkFApLjM8TEXROBuQGLAH2i2gZpcXdLBIrpXuTDhH7Vbm1iXmNGA==", + "version": "7.0.8", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.8.tgz", + "integrity": "sha512-YSBPTLTVm2e2OoQIDYx8HaeWJ5tTToLH67kXR7zYNGupXMEHa2++G8k+DczX2cFVgalypqtyZIcU19AFcmOpmg==", "dev": true }, - "@types/keyv": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.1.tgz", - "integrity": "sha512-MPtoySlAZQ37VoLaPcTHCu1RWJ4llDkULYZIzOYxlhxBqYPB0RsRlmMU0R6tahtFe27mIdkHV+551ZWV4PLmVw==", - "requires": { - "@types/node": "*" - } - }, "@types/lodash": { "version": "4.14.170", "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.170.tgz", "integrity": "sha512-bpcvu/MKHHeYX+qeEN8GE7DIravODWdACVA1ctevD8CN24RhPZIKMn9ntfAsrvLfSX3cR5RrBKAbYm9bGs0A+Q==" }, "@types/node": { - "version": "15.12.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-15.12.2.tgz", - "integrity": "sha512-zjQ69G564OCIWIOHSXyQEEDpdpGl+G348RAKY0XXy9Z5kU9Vzv1GMNnkar/ZJ8dzXB3COzD9Mo9NtRZ4xfgUww==" + "version": "16.0.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.0.0.tgz", + "integrity": "sha512-TmCW5HoZ2o2/z2EYi109jLqIaPIi9y/lc2LmDCWzuCi35bcaQ+OtUh6nwBiFK7SOu25FAU5+YKdqFZUwtqGSdg==", + "dev": true }, "@types/normalize-package-data": { "version": "2.4.0", @@ -1071,40 +1062,31 @@ "integrity": "sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==", "dev": true }, - "@types/responselike": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.0.tgz", - "integrity": "sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA==", - "requires": { - "@types/node": "*" - } - }, "@types/yargs": { - "version": "17.0.0", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.0.tgz", - "integrity": "sha512-RS7u2X7vdXjVQs160PWY1pjLBw6GJj04utojn0KU8p2rRZR37FSzzK6XOT+KLzT/DVbDYRyezroc0LHIvM5Z2A==", + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.2.tgz", + "integrity": "sha512-JhZ+pNdKMfB0rXauaDlrIvm+U7V4m03PPOSVoPS66z8gf+G4Z/UW8UlrVIj2MRQOBzuoEvYtjS0bqYwnpZaS9Q==", "dev": true, "requires": { "@types/yargs-parser": "*" } }, "@types/yargs-parser": { - "version": "20.2.0", - "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-20.2.0.tgz", - "integrity": "sha512-37RSHht+gzzgYeobbG+KWryeAW8J33Nhr69cjTqSYymXVZEN9NbRYWoYlRtDhHKPVT1FyNKwaTPC1NynKZpzRA==", + "version": "20.2.1", + "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-20.2.1.tgz", + "integrity": "sha512-7tFImggNeNBVMsn0vLrpn1H1uPrUBdnARPTpZoitY37ZrdJREzf7I16tMrlK3hen349gr1NYh8CmZQa7CTG6Aw==", "dev": true }, "@typescript-eslint/eslint-plugin": { - "version": "4.27.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.27.0.tgz", - "integrity": "sha512-DsLqxeUfLVNp3AO7PC3JyaddmEHTtI9qTSAs+RB6ja27QvIM0TA8Cizn1qcS6vOu+WDLFJzkwkgweiyFhssDdQ==", + "version": "4.28.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.28.2.tgz", + "integrity": "sha512-PGqpLLzHSxq956rzNGasO3GsAPf2lY9lDUBXhS++SKonglUmJypaUtcKzRtUte8CV7nruwnDxtLUKpVxs0wQBw==", "dev": true, "requires": { - "@typescript-eslint/experimental-utils": "4.27.0", - "@typescript-eslint/scope-manager": "4.27.0", + "@typescript-eslint/experimental-utils": "4.28.2", + "@typescript-eslint/scope-manager": "4.28.2", "debug": "^4.3.1", "functional-red-black-tree": "^1.0.1", - "lodash": "^4.17.21", "regexpp": "^3.1.0", "semver": "^7.3.5", "tsutils": "^3.21.0" @@ -1122,55 +1104,55 @@ } }, "@typescript-eslint/experimental-utils": { - "version": "4.27.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.27.0.tgz", - "integrity": "sha512-n5NlbnmzT2MXlyT+Y0Jf0gsmAQzCnQSWXKy4RGSXVStjDvS5we9IWbh7qRVKdGcxT0WYlgcCYUK/HRg7xFhvjQ==", + "version": "4.28.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.28.2.tgz", + "integrity": "sha512-MwHPsL6qo98RC55IoWWP8/opTykjTp4JzfPu1VfO2Z0MshNP0UZ1GEV5rYSSnZSUI8VD7iHvtIPVGW5Nfh7klQ==", "dev": true, "requires": { "@types/json-schema": "^7.0.7", - "@typescript-eslint/scope-manager": "4.27.0", - "@typescript-eslint/types": "4.27.0", - "@typescript-eslint/typescript-estree": "4.27.0", + "@typescript-eslint/scope-manager": "4.28.2", + "@typescript-eslint/types": "4.28.2", + "@typescript-eslint/typescript-estree": "4.28.2", "eslint-scope": "^5.1.1", "eslint-utils": "^3.0.0" } }, "@typescript-eslint/parser": { - "version": "4.27.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.27.0.tgz", - "integrity": "sha512-XpbxL+M+gClmJcJ5kHnUpBGmlGdgNvy6cehgR6ufyxkEJMGP25tZKCaKyC0W/JVpuhU3VU1RBn7SYUPKSMqQvQ==", + "version": "4.28.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.28.2.tgz", + "integrity": "sha512-Q0gSCN51eikAgFGY+gnd5p9bhhCUAl0ERMiDKrTzpSoMYRubdB8MJrTTR/BBii8z+iFwz8oihxd0RAdP4l8w8w==", "dev": true, "requires": { - "@typescript-eslint/scope-manager": "4.27.0", - "@typescript-eslint/types": "4.27.0", - "@typescript-eslint/typescript-estree": "4.27.0", + "@typescript-eslint/scope-manager": "4.28.2", + "@typescript-eslint/types": "4.28.2", + "@typescript-eslint/typescript-estree": "4.28.2", "debug": "^4.3.1" } }, "@typescript-eslint/scope-manager": { - "version": "4.27.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.27.0.tgz", - "integrity": "sha512-DY73jK6SEH6UDdzc6maF19AHQJBFVRf6fgAXHPXCGEmpqD4vYgPEzqpFz1lf/daSbOcMpPPj9tyXXDPW2XReAw==", + "version": "4.28.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.28.2.tgz", + "integrity": "sha512-MqbypNjIkJFEFuOwPWNDjq0nqXAKZvDNNs9yNseoGBB1wYfz1G0WHC2AVOy4XD7di3KCcW3+nhZyN6zruqmp2A==", "dev": true, "requires": { - "@typescript-eslint/types": "4.27.0", - "@typescript-eslint/visitor-keys": "4.27.0" + "@typescript-eslint/types": "4.28.2", + "@typescript-eslint/visitor-keys": "4.28.2" } }, "@typescript-eslint/types": { - "version": "4.27.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.27.0.tgz", - "integrity": "sha512-I4ps3SCPFCKclRcvnsVA/7sWzh7naaM/b4pBO2hVxnM3wrU51Lveybdw5WoIktU/V4KfXrTt94V9b065b/0+wA==", + "version": "4.28.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.28.2.tgz", + "integrity": "sha512-Gr15fuQVd93uD9zzxbApz3wf7ua3yk4ZujABZlZhaxxKY8ojo448u7XTm/+ETpy0V0dlMtj6t4VdDvdc0JmUhA==", "dev": true }, "@typescript-eslint/typescript-estree": { - "version": "4.27.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.27.0.tgz", - "integrity": "sha512-KH03GUsUj41sRLLEy2JHstnezgpS5VNhrJouRdmh6yNdQ+yl8w5LrSwBkExM+jWwCJa7Ct2c8yl8NdtNRyQO6g==", + "version": "4.28.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.28.2.tgz", + "integrity": "sha512-86lLstLvK6QjNZjMoYUBMMsULFw0hPHJlk1fzhAVoNjDBuPVxiwvGuPQq3fsBMCxuDJwmX87tM/AXoadhHRljg==", "dev": true, "requires": { - "@typescript-eslint/types": "4.27.0", - "@typescript-eslint/visitor-keys": "4.27.0", + "@typescript-eslint/types": "4.28.2", + "@typescript-eslint/visitor-keys": "4.28.2", "debug": "^4.3.1", "globby": "^11.0.3", "is-glob": "^4.0.1", @@ -1190,12 +1172,12 @@ } }, "@typescript-eslint/visitor-keys": { - "version": "4.27.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.27.0.tgz", - "integrity": "sha512-es0GRYNZp0ieckZ938cEANfEhsfHrzuLrePukLKtY3/KPXcq1Xd555Mno9/GOgXhKzn0QfkDLVgqWO3dGY80bg==", + "version": "4.28.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.28.2.tgz", + "integrity": "sha512-aT2B4PLyyRDUVUafXzpZFoc0C9t0za4BJAKP5sgWIhG+jHECQZUEjuQSCIwZdiJJ4w4cgu5r3Kh20SOdtEBl0w==", "dev": true, "requires": { - "@typescript-eslint/types": "4.27.0", + "@typescript-eslint/types": "4.28.2", "eslint-visitor-keys": "^2.0.0" } }, @@ -1650,25 +1632,6 @@ "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", "dev": true }, - "cacheable-lookup": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz", - "integrity": "sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA==" - }, - "cacheable-request": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-7.0.1.tgz", - "integrity": "sha512-lt0mJ6YAnsrBErpTMWeu5kl/tg9xMAWjavYTN6VQXM1A/teBITuNcccXsCxF0tDQQJf9DfAaX5O4e0zp0KlfZw==", - "requires": { - "clone-response": "^1.0.2", - "get-stream": "^5.1.0", - "http-cache-semantics": "^4.0.0", - "keyv": "^4.0.0", - "lowercase-keys": "^2.0.0", - "normalize-url": "^4.1.0", - "responselike": "^2.0.0" - } - }, "caching-transform": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/caching-transform/-/caching-transform-4.0.0.tgz", @@ -1828,6 +1791,7 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.2.tgz", "integrity": "sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws=", + "dev": true, "requires": { "mimic-response": "^1.0.0" } @@ -1968,6 +1932,14 @@ "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", "dev": true }, + "cross-fetch": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.4.tgz", + "integrity": "sha512-1eAtFWdIubi6T4XPy6ei9iUFoKpUkIF971QLN8lIvvvwueI65+Nw5haMNKUwfJxabqlIIDODJKGrQ66gxC0PbQ==", + "requires": { + "node-fetch": "2.6.1" + } + }, "cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -2018,21 +1990,6 @@ "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", "dev": true }, - "decompress-response": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", - "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", - "requires": { - "mimic-response": "^3.1.0" - }, - "dependencies": { - "mimic-response": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", - "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==" - } - } - }, "deep-extend": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", @@ -2069,11 +2026,6 @@ "clone": "^1.0.2" } }, - "defer-to-connect": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.1.tgz", - "integrity": "sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg==" - }, "del": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/del/-/del-6.0.0.tgz", @@ -2193,6 +2145,11 @@ "integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==", "dev": true }, + "es6-promise": { + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", + "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==" + }, "escalade": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", @@ -2221,16 +2178,64 @@ "esutils": "^2.0.2", "optionator": "^0.8.1", "source-map": "~0.6.1" + }, + "dependencies": { + "estraverse": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz", + "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==", + "dev": true + }, + "levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "dev": true, + "requires": { + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" + } + }, + "optionator": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", + "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", + "dev": true, + "requires": { + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.6", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "word-wrap": "~1.2.3" + } + }, + "prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", + "dev": true + }, + "type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "dev": true, + "requires": { + "prelude-ls": "~1.1.2" + } + } } }, "eslint": { - "version": "7.28.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.28.0.tgz", - "integrity": "sha512-UMfH0VSjP0G4p3EWirscJEQ/cHqnT/iuH6oNZOB94nBjWbMnhGEPxsZm1eyIW0C/9jLI0Fow4W5DXLjEI7mn1g==", + "version": "7.30.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.30.0.tgz", + "integrity": "sha512-VLqz80i3as3NdloY44BQSJpFw534L9Oh+6zJOUaViV4JPd+DaHwutqP7tcpkW3YiXbK6s05RZl7yl7cQn+lijg==", "dev": true, "requires": { "@babel/code-frame": "7.12.11", "@eslint/eslintrc": "^0.4.2", + "@humanwhocodes/config-array": "^0.5.0", "ajv": "^6.10.0", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", @@ -2293,36 +2298,6 @@ "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", "dev": true }, - "levn": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", - "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", - "dev": true, - "requires": { - "prelude-ls": "^1.2.1", - "type-check": "~0.4.0" - } - }, - "optionator": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", - "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", - "dev": true, - "requires": { - "deep-is": "^0.1.3", - "fast-levenshtein": "^2.0.6", - "levn": "^0.4.1", - "prelude-ls": "^1.2.1", - "type-check": "^0.4.0", - "word-wrap": "^1.2.3" - } - }, - "prelude-ls": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", - "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", - "dev": true - }, "semver": { "version": "7.3.5", "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", @@ -2337,15 +2312,6 @@ "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", "dev": true - }, - "type-check": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", - "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", - "dev": true, - "requires": { - "prelude-ls": "^1.2.1" - } } } }, @@ -2363,14 +2329,6 @@ "requires": { "esrecurse": "^4.3.0", "estraverse": "^4.1.1" - }, - "dependencies": { - "estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "dev": true - } } }, "eslint-utils": { @@ -2420,6 +2378,14 @@ "dev": true, "requires": { "estraverse": "^5.1.0" + }, + "dependencies": { + "estraverse": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz", + "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==", + "dev": true + } } }, "esrecurse": { @@ -2429,12 +2395,20 @@ "dev": true, "requires": { "estraverse": "^5.2.0" + }, + "dependencies": { + "estraverse": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz", + "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==", + "dev": true + } } }, "estraverse": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz", - "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", "dev": true }, "esutils": { @@ -2568,9 +2542,9 @@ } }, "flatted": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.1.1.tgz", - "integrity": "sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.0.tgz", + "integrity": "sha512-XprP7lDrVT+kE2c2YlfiV+IfS9zxukiIOvNamPNsImNhXadSsQEbosItdL9bUQlCZXR13SvPk20BjWSWLA7m4A==", "dev": true }, "foreground-child": { @@ -2736,14 +2710,6 @@ "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==", "dev": true }, - "get-stream": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz", - "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==", - "requires": { - "pump": "^3.0.0" - } - }, "github-from-package": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", @@ -2812,24 +2778,6 @@ "slash": "^3.0.0" } }, - "got": { - "version": "11.8.2", - "resolved": "https://registry.npmjs.org/got/-/got-11.8.2.tgz", - "integrity": "sha512-D0QywKgIe30ODs+fm8wMZiAcZjypcCodPNuMz5H9Mny7RJ+IjJ10BdmGW7OM7fHXP+O7r6ZwapQ/YQmMSvB0UQ==", - "requires": { - "@sindresorhus/is": "^4.0.0", - "@szmarczak/http-timer": "^4.0.5", - "@types/cacheable-request": "^6.0.1", - "@types/responselike": "^1.0.0", - "cacheable-lookup": "^5.0.3", - "cacheable-request": "^7.0.1", - "decompress-response": "^6.0.0", - "http2-wrapper": "^1.0.0-beta.5.2", - "lowercase-keys": "^2.0.0", - "p-cancelable": "^2.0.0", - "responselike": "^2.0.0" - } - }, "graceful-fs": { "version": "4.2.6", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz", @@ -2893,16 +2841,8 @@ "http-cache-semantics": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz", - "integrity": "sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ==" - }, - "http2-wrapper": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-1.0.3.tgz", - "integrity": "sha512-V+23sDMr12Wnz7iTcDeJr3O6AIxlnvT/bmaAAAP/Xda35C90p9599p0F1eHR/N1KILWSoWVAiOMFjBBXaXSMxg==", - "requires": { - "quick-lru": "^5.1.1", - "resolve-alpn": "^1.0.0" - } + "integrity": "sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ==", + "dev": true }, "https-proxy-agent": { "version": "5.0.0", @@ -3161,6 +3101,15 @@ "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", "dev": true }, + "isomorphic-fetch": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-3.0.0.tgz", + "integrity": "sha512-qvUtwJ3j6qwsF3jLxkZ72qCgjMysPzDfeV240JHiGZsANBYd+EEuu35v7dfrJ9Up0Ak07D7GGSkGhCHTqg/5wA==", + "requires": { + "node-fetch": "^2.6.1", + "whatwg-fetch": "^3.4.1" + } + }, "istanbul-lib-coverage": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.0.0.tgz", @@ -3282,11 +3231,6 @@ "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", "dev": true }, - "json-buffer": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", - "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==" - }, "json-parse-better-errors": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", @@ -3338,14 +3282,6 @@ "prebuild-install": "^6.0.0" } }, - "keyv": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.0.3.tgz", - "integrity": "sha512-zdGa2TOpSZPq5mU6iowDARnMBZgtCqJ11dJROFi6tg6kTn4nuUdU09lFyLFSaHrWqpIJ+EBq4E8/Dc0Vx5vLdA==", - "requires": { - "json-buffer": "3.0.1" - } - }, "latest-version": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/latest-version/-/latest-version-5.1.0.tgz", @@ -3356,13 +3292,13 @@ } }, "levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", "dev": true, "requires": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" } }, "lines-and-columns": { @@ -3444,11 +3380,6 @@ "is-unicode-supported": "^0.1.0" } }, - "lowercase-keys": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz", - "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==" - }, "lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -3550,7 +3481,8 @@ "mimic-response": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", - "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==" + "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==", + "dev": true }, "minimalistic-assert": { "version": "1.0.1", @@ -3624,8 +3556,7 @@ "node-fetch": { "version": "2.6.1", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", - "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==", - "dev": true + "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==" }, "node-preload": { "version": "0.2.1", @@ -3668,7 +3599,8 @@ "normalize-url": { "version": "4.5.1", "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.1.tgz", - "integrity": "sha512-9UZCFRHQdNrfTpGg8+1INIg93B6zE0aXMVFkw1WFwvO4SlZywU6aLg5Of0Ap/PgcbSw4LNxvMWXMeugwMCX0AA==" + "integrity": "sha512-9UZCFRHQdNrfTpGg8+1INIg93B6zE0aXMVFkw1WFwvO4SlZywU6aLg5Of0Ap/PgcbSw4LNxvMWXMeugwMCX0AA==", + "dev": true }, "npmlog": { "version": "4.1.2", @@ -3831,17 +3763,17 @@ } }, "optionator": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", - "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", + "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", "dev": true, "requires": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.6", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "word-wrap": "~1.2.3" + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.3" } }, "ora": { @@ -3860,11 +3792,6 @@ "wcwidth": "^1.0.1" } }, - "p-cancelable": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-2.1.1.tgz", - "integrity": "sha512-BZOr3nRQHOntUjTrH8+Lh54smKHoHyur8We1V8DSMVrl5A2malOOwuJRnKRDjSnkoeBh4at6BwEnb5I7Jl31wg==" - }, "p-defer": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-1.0.0.tgz", @@ -4160,9 +4087,9 @@ "dev": true }, "pkg": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/pkg/-/pkg-5.2.1.tgz", - "integrity": "sha512-kQ5Fla+76rdmFJNrEOgoklxAURl3uvhvX+m4LCQCRrI+q2lOgsx9pS02NhNuDVnyXsthluAuXCh5SKcMyw+cWw==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/pkg/-/pkg-5.3.0.tgz", + "integrity": "sha512-/DGG+QcSPraMAIxaoGCNqb2A6Xkm2jBQMsj2mjb4ag236ByTY9Xhpikvj5ixwlSQV0euuJw4fphKCd5YHRPS8w==", "dev": true, "requires": { "@babel/parser": "7.13.13", @@ -4216,6 +4143,12 @@ "tunnel-agent": "^0.6.0", "which-pm-runs": "^1.0.0" } + }, + "tslib": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.1.0.tgz", + "integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==", + "dev": true } } }, @@ -4358,9 +4291,9 @@ } }, "prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "dev": true }, "prepend-http": { @@ -4370,9 +4303,9 @@ "dev": true }, "prettier": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.3.1.tgz", - "integrity": "sha512-p+vNbgpLjif/+D+DwAZAbndtRrR0md0MwfmOVN9N+2RgyACMT+7tfaRnT+WDPkqnuVwleyuBIG2XBxKDme3hPA==", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.3.2.tgz", + "integrity": "sha512-lnJzDfJ66zkMy58OL5/NY5zp70S7Nz6KqcKkXYzn2tMVrNxvbqaBpg7H3qHaLxCJ5lNMsGuM8+ohS7cZrthdLQ==", "dev": true }, "pretty-ms": { @@ -4439,11 +4372,6 @@ "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", "dev": true }, - "quick-lru": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz", - "integrity": "sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==" - }, "rc": { "version": "1.2.8", "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", @@ -4512,9 +4440,9 @@ "integrity": "sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew==" }, "regexpp": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.1.0.tgz", - "integrity": "sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", + "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", "dev": true }, "registry-auth-token": { @@ -4571,11 +4499,6 @@ "path-parse": "^1.0.6" } }, - "resolve-alpn": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.1.2.tgz", - "integrity": "sha512-8OyfzhAtA32LVUsJSke3auIyINcwdh5l3cvYKdKO0nvsYSKuiLfTM5i78PJswFPT8y6cPW+L1v6/hE95chcpDA==" - }, "resolve-cwd": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz", @@ -4599,14 +4522,6 @@ "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", "dev": true }, - "responselike": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/responselike/-/responselike-2.0.0.tgz", - "integrity": "sha512-xH48u3FTB9VsZw7R+vvgaKeLKzT6jOogbQhEe/jewwnZgzPcnyWui2Av6JpoYZF/91uueC+lqhWqeURw5/qhCw==", - "requires": { - "lowercase-keys": "^2.0.0" - } - }, "restore-cursor": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", @@ -4960,9 +4875,9 @@ }, "dependencies": { "ajv": { - "version": "8.6.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.6.0.tgz", - "integrity": "sha512-cnUG4NSBiM4YFBxgZIj/In3/6KX+rQ2l2YPRVcvAMQGWEPKuXoPIhxzwqh31jA3IPbI4qEOp/5ILI4ynioXsGQ==", + "version": "8.6.1", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.6.1.tgz", + "integrity": "sha512-42VLtQUOLefAvKFAQIxIZDaThq6om/PrfP0CYk3/vn+y4BMNkKnbli8ON2QCiHov4KkzOSJ/xSoBJdayiiYvVQ==", "dev": true, "requires": { "fast-deep-equal": "^3.1.1", @@ -5082,9 +4997,9 @@ } }, "tslib": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.1.0.tgz", - "integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==", + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", "dev": true }, "tsutils": { @@ -5094,14 +5009,6 @@ "dev": true, "requires": { "tslib": "^1.8.1" - }, - "dependencies": { - "tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", - "dev": true - } } }, "tunnel-agent": { @@ -5113,12 +5020,12 @@ } }, "type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", "dev": true, "requires": { - "prelude-ls": "~1.1.2" + "prelude-ls": "^1.2.1" } }, "type-fest": { @@ -5137,9 +5044,9 @@ } }, "typescript": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.3.tgz", - "integrity": "sha512-rUvLW0WtF7PF2b9yenwWUi9Da9euvDRhmH7BLyBG4DCFfOJ850LGNknmRpp8Z8kXNUPObdZQEfKOiHtXuQHHKA==", + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.5.tgz", + "integrity": "sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==", "dev": true }, "unique-names-generator": { @@ -5253,6 +5160,11 @@ "integrity": "sha512-ZMjC3ho+KXo0BfJb7JgtQ5IBuvnShdlACNkKkdsqBmYw3bPAaJfPeYUo6tLUaT5tG/Gkh7xkpBhKRQ9e7pyg9Q==", "dev": true }, + "whatwg-fetch": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.6.2.tgz", + "integrity": "sha512-bJlen0FcuU/0EMLrdbJ7zOnW6ITZLrZMIarMUVmdKtsGvZna8vxKYaexICWPfZ8qwf9fzNq+UEIZrnSaApt6RA==" + }, "which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", diff --git a/package.json b/package.json index 5d629dd..63e1091 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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" diff --git a/src/commands/configure.ts b/src/commands/configure.ts index f64e2d6..a9ffe3d 100644 --- a/src/commands/configure.ts +++ b/src/commands/configure.ts @@ -84,7 +84,7 @@ export const handler: Handler = async (argv) => { const accountConfiguration = await api.retrieveAccountConfiguration( {}, - { ApiKey: apiKey }, + apiKey, ); spinner.succeed(); @@ -155,7 +155,7 @@ export const handler: Handler = async (argv) => { PersonalVaultEncryptedPrivateKey: keys.personalVaultKeyPair.encryptedPrivateKey, }, - { ApiKey: apiKey }, + apiKey, ); spinner.succeed(); diff --git a/src/commands/secret_commands/add.ts b/src/commands/secret_commands/add.ts index 1aeeb06..34879b5 100644 --- a/src/commands/secret_commands/add.ts +++ b/src/commands/secret_commands/add.ts @@ -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'; @@ -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(); @@ -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(); @@ -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(); diff --git a/src/commands/secret_commands/get.ts b/src/commands/secret_commands/get.ts index b0f2d8f..d2b5f4d 100644 --- a/src/commands/secret_commands/get.ts +++ b/src/commands/secret_commands/get.ts @@ -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(); @@ -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(); @@ -69,7 +69,7 @@ export const handler: Handler = async (argv) => { SecretName: secretName, VaultId: vaultId, }, - { ApiKey: userConfig.Account.ApiKey }, + userConfig.Account.ApiKey, ); spinner.succeed(); diff --git a/src/commands/secret_commands/list.ts b/src/commands/secret_commands/list.ts index 392060d..a5c1084 100644 --- a/src/commands/secret_commands/list.ts +++ b/src/commands/secret_commands/list.ts @@ -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(); @@ -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(); diff --git a/src/commands/secret_commands/remove.ts b/src/commands/secret_commands/remove.ts index 61039e6..1289b20 100644 --- a/src/commands/secret_commands/remove.ts +++ b/src/commands/secret_commands/remove.ts @@ -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(); @@ -54,7 +54,7 @@ export const handler: Handler = async (argv) => { SecretName: secretName, VaultId: vaultId, }, - { ApiKey: userConfig.Account.ApiKey }, + userConfig.Account.ApiKey, ); spinner.succeed(); diff --git a/src/commands/secret_commands/share.ts b/src/commands/secret_commands/share.ts index b254efa..6b9da65 100644 --- a/src/commands/secret_commands/share.ts +++ b/src/commands/secret_commands/share.ts @@ -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(); diff --git a/src/commands/secret_commands/update.outputs.ts b/src/commands/secret_commands/update.outputs.ts new file mode 100644 index 0000000..1af36bf --- /dev/null +++ b/src/commands/secret_commands/update.outputs.ts @@ -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); +}; diff --git a/src/commands/secret_commands/update.prompts.ts b/src/commands/secret_commands/update.prompts.ts new file mode 100644 index 0000000..1877df4 --- /dev/null +++ b/src/commands/secret_commands/update.prompts.ts @@ -0,0 +1,186 @@ +import type { PrivateKey, PublicKey } from 'openpgp'; +import { prompt } from 'enquirer'; +import { + uniqueNamesGenerator, + adjectives, + colors, + animals, +} from 'unique-names-generator'; +import * as yup from 'yup'; + +const generateName = () => + uniqueNamesGenerator({ + dictionaries: [adjectives, colors, animals], + separator: ' ', + style: 'capital', + }); + +import crypto from '../../services/crypto'; +import { getAccountEncryptionKey } from '../../services/keychain'; + +export const confirmSecretName = async (): Promise => { + const secretNameSchema = yup.string().max(64).required(); + + const { secretName } = await prompt<{ secretName: string }>({ + type: 'input', + name: 'secretName', + message: 'What would you like to call this secret?', + required: true, + initial: generateName(), + validate: async (value) => { + try { + await secretNameSchema.validate(value); + return true; + } catch (error) { + return error.message; + } + }, + }); + + return secretName; +}; + +export const confirmSecretValue = async (): Promise => { + const secretValueSchema = yup.string().max(100_000).required(); + + const { secretValue } = await prompt<{ secretValue: string }>({ + type: 'invisible', + name: 'secretValue', + message: `What's the value of the secret you'd like to store?`, + required: true, + validate: async (value) => { + try { + await secretValueSchema.validate(value); + return true; + } catch (error) { + return error.message; + } + }, + }); + + return secretValue; +}; + +export const confirmVaultId = async ({ + vaultMemberships, +}: { + vaultMemberships: Array<{ + Role: string; + VaultId: string; + VaultName: string; + VaultOwnerAccountName: string; + VaultOwnerAccountEmail: string; + }>; +}): Promise => { + if (vaultMemberships.length === 0) { + throw new Error('vault not found'); + } + + if (vaultMemberships.length === 1) { + const [vaultMembership] = vaultMemberships; + return vaultMembership.VaultId; + } + + if (vaultMemberships.length > 1) { + const { vaultId: result } = await prompt<{ + vaultId: { [k: string]: string }; + }>({ + type: 'select', + name: 'vaultId', + message: + 'You are a member of multiple vaults with this name. Which one did you mean?', + // NOTE: Resulting type cast as any due to a bug in + // type definitions (name is required although it should not be). + choices: vaultMemberships.map((vaultMembership) => ({ + name: `${vaultMembership.VaultName} (${vaultMembership.Role})`, + value: vaultMembership.VaultId, + hint: `Created by ${vaultMembership.VaultOwnerAccountName} <${vaultMembership.VaultOwnerAccountEmail}>`, + })), + result(res) { + // NOTE: See https://github.com/enquirer/enquirer/blob/8d626c206733420637660ac7c2098d7de45e8590/examples/multiselect/option-result.js + // for relevant example. Had to dig in to get to the bottom of this. + // If we do not do this, it's pretty much impossible to maintain + // user-friendly display names in options and confirms. + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + return this.map(res); + }, + required: true, + }); + + const [vaultId] = Object.values(result); + + return vaultId; + } + + throw new Error('unexpected result'); +}; + +export const promptForExistingMasterPassword = async ({ + accountPublicKey, + accountEncryptedPrivateKey, + accountEncryptionKeySalt, + useKeychain, + profile, +}: { + accountPublicKey: string; + accountEncryptedPrivateKey: string; + accountEncryptionKeySalt: string; + useKeychain: boolean; + profile: string; +}): Promise<{ accountPublicKey: PublicKey; accountPrivateKey: PrivateKey }> => { + if (useKeychain) { + const accountEncryptionKey = await getAccountEncryptionKey({ profile }); + + // Ensure the provided master password can + // in fact be used to decrypt the master key. + const { publicKey, privateKey } = + await crypto.decryptAccountEncryptedPrivateKey({ + accountPublicKey, + accountEncryptedPrivateKey, + accountEncryptionKey, + }); + + return { accountPublicKey: publicKey, accountPrivateKey: privateKey }; + } + + const accountPassphraseSchema = yup.string().min(12).max(256).required(); + + let result: { accountPublicKey: PublicKey; accountPrivateKey: PrivateKey }; + + await prompt<{ existingMasterPassword: string }>({ + type: 'invisible', + name: 'existingMasterPassword', + message: 'Please enter your (existing) master password', + required: true, + validate: async (value) => { + try { + await accountPassphraseSchema.validate(value); + + const { encryptionKey: accountEncryptionKey } = + crypto.deriveEncryptionKey({ + passphrase: value, + salt: Buffer.from(accountEncryptionKeySalt, 'base64'), + }); + + // Ensure the provided master password can + // in fact be used to decrypt the master key. + const { publicKey, privateKey } = + await crypto.decryptAccountEncryptedPrivateKey({ + accountPublicKey, + accountEncryptedPrivateKey, + accountEncryptionKey, + }); + + // NOTE: Not the prettiest way to do this but want to avoid over-engineering. + result = { accountPublicKey: publicKey, accountPrivateKey: privateKey }; + + return true; + } catch (error) { + return error.message; + } + }, + }); + + return result!; +}; diff --git a/src/commands/secret_commands/update.ts b/src/commands/secret_commands/update.ts new file mode 100644 index 0000000..3f237fd --- /dev/null +++ b/src/commands/secret_commands/update.ts @@ -0,0 +1,154 @@ +import { readFile, statSync } from 'fs-extra'; +import ora from 'ora'; +import { basename } from 'path'; +import api from '../../services/api'; +import { readUserConfig } from '../../services/config'; +import crypto from '../../services/crypto'; +import { baseOptions } from '../../shared'; +import * as outputs from './update.outputs'; +import * as prompts from './update.prompts'; +import { Builder, Handler } from './update.types'; + +export const command = 'update [name] [value]'; +export const desc = 'Update existing end-to-end encrypted secret'; + +export const builder: Builder = (yargs) => + yargs + .options({ + ...baseOptions, + file: { type: 'string', alias: 'f', conflicts: 'value' }, + vault: { type: 'string', alias: 'v' }, + }) + .positional('name', { type: 'string' }) + .positional('value', { type: 'string', conflicts: 'file' }) + .example([ + ['$0 update'], + ['$0 update DB_PASSWORD 5Fqp2Mrs74Bp1RwSyV --profile project:phoenix'], + ['$0 update --file .env.prod --vault devs'], + [ + '$0 update -f alice.csv -v creds:aws -q --json | jq -r .SecretId | pbcopy', + ], + ]) + .check((argv, _options) => { + const { value, file } = argv; + + let contentLength: number; + + if (file) { + contentLength = statSync(file).size; + } else if (value) { + contentLength = Buffer.from(value, 'utf8').length; + } else { + contentLength = 0; + } + + if (contentLength > 100_000) { + throw new Error('size of input binary cannot exceed 100kB'); + } + + return argv; + }); + +export const handler: Handler = async (argv) => { + const spinner = ora({ + isSilent: argv.quiet, + }); + + const { profile, value, file, vault: vaultName, json } = argv; + + const userConfig = await readUserConfig(profile); + + const { name: secretName = await getSecretName({ file }) } = argv; + + const { content, contentType } = await getBinaryValue({ file, value }); + + let vaultId = userConfig.PersonalVault.Id; + + if (vaultName) { + spinner.start('Fetching existing vault memberships'); + const vaultMemberships = await api.searchVaultMemberships( + { VaultName: vaultName }, + userConfig.Account.ApiKey, + ); + spinner.succeed(); + + vaultId = await prompts.confirmVaultId({ vaultMemberships }); + } + + // TODO: Can likely be moved to the if block above. + spinner.start('Fetching vault keys'); + const vaultKeys = await api.retrieveVaultKeys( + { VaultId: vaultId }, + userConfig.Account.ApiKey, + ); + spinner.succeed(); + + const { accountPrivateKey } = await prompts.promptForExistingMasterPassword({ + accountPublicKey: userConfig.Account.PublicKey, + accountEncryptedPrivateKey: userConfig.Account.EncryptedPrivateKey, + accountEncryptionKeySalt: userConfig.Account.EncryptionKeySalt, + useKeychain: userConfig.Device.UseKeychain, + profile, + }); + + spinner.start('Encrypting contents'); + const vaultKeyPair = await crypto.decryptVaultEncryptedPrivateKey({ + accountPrivateKey, + vaultPublicKey: vaultKeys.VaultPublicKey, + vaultEncryptedPrivateKey: vaultKeys.VaultEncryptedPrivateKey, + }); + + const encryptedContent = await crypto.encryptBinaryWithVaultKeys({ + binary: content, + vaultPublicKey: vaultKeyPair.publicKey, + vaultPrivateKey: vaultKeyPair.privateKey, + }); + spinner.succeed(); + + spinner.start('Adding secret to vault'); + const { SecretId: secretId } = await api.updateSecret( + { + SecretName: secretName, + SecretEncryptedContent: encryptedContent, + SecretContentType: contentType === 'file' ? 'File' : 'Text', + VaultId: vaultId, + }, + userConfig.Account.ApiKey, + ); + spinner.succeed(); + + json + ? outputs.secretAddedJson({ secretId, vaultId }) + : outputs.secretAdded({ secretName, vaultName }); +}; + +const getSecretName = async ({ + file, +}: { + file: string | undefined; +}): Promise => { + if (file) { + return basename(file); + } else { + return prompts.confirmSecretName(); + } +}; + +const getBinaryValue = async ({ + file, + value, +}: { + file: string | undefined; + value: string | undefined; +}): Promise<{ contentType: 'file' | 'text'; content: Buffer }> => { + if (file) { + return { contentType: 'file', content: await readFile(file) }; + } else if (value) { + return { contentType: 'text', content: Buffer.from(value, 'utf8') }; + } else { + return { + contentType: 'text', + content: Buffer.from(await prompts.confirmSecretValue(), 'utf8'), + }; + } +}; diff --git a/src/commands/secret_commands/update.types.ts b/src/commands/secret_commands/update.types.ts new file mode 100644 index 0000000..e16498a --- /dev/null +++ b/src/commands/secret_commands/update.types.ts @@ -0,0 +1,14 @@ +import type { Arguments, CommandBuilder } from 'yargs'; + +import type { BaseOptions } from '../../shared'; + +export type Options = BaseOptions & { + name: string | undefined; + value: string | undefined; + file: string | undefined; + vault: string | undefined; +}; + +export type Builder = CommandBuilder; + +export type Handler = (argv: Arguments) => PromiseLike; diff --git a/src/commands/vault_commands/add-member.ts b/src/commands/vault_commands/add-member.ts index d269370..5aacaf4 100644 --- a/src/commands/vault_commands/add-member.ts +++ b/src/commands/vault_commands/add-member.ts @@ -44,14 +44,14 @@ export const handler: Handler = async (argv) => { const { AccountPublicKey: counterpartAccountPublicKey } = await api.retrieveAccountPublicKey( { AccountEmail: email }, - { ApiKey: userConfig.Account.ApiKey }, + userConfig.Account.ApiKey, ); spinner.succeed(); spinner.start('Fetching existing vault memberships'); const vaultMemberships = await api.searchVaultMemberships( { VaultName: vaultName }, - { ApiKey: userConfig.Account.ApiKey }, + userConfig.Account.ApiKey, ); spinner.succeed(); @@ -63,11 +63,11 @@ export const handler: Handler = async (argv) => { spinner.start(`Fetching vault members for ${vaultName}`); const vaultKeys = await api.retrieveVaultKeys( { VaultId: vaultId }, - { ApiKey: userConfig.Account.ApiKey }, + userConfig.Account.ApiKey, ); const vaultMembers = await api.listVaultMembers( { VaultId: vaultId }, - { ApiKey: userConfig.Account.ApiKey }, + userConfig.Account.ApiKey, ); const existingPublicKeys = vaultMembers.map( ({ AccountPublicKey }) => AccountPublicKey, @@ -106,7 +106,7 @@ export const handler: Handler = async (argv) => { AccountEmail: email, Role: role === 'read' ? 'Read' : 'Admin', }, - { ApiKey: userConfig.Account.ApiKey }, + userConfig.Account.ApiKey, ); spinner.succeed(); diff --git a/src/commands/vault_commands/create.ts b/src/commands/vault_commands/create.ts index 8025880..75a57ca 100644 --- a/src/commands/vault_commands/create.ts +++ b/src/commands/vault_commands/create.ts @@ -74,7 +74,7 @@ export const handler: Handler = async (argv) => { VaultPublicKey: vaultKeyPair.publicKey, VaultEncryptedPrivateKey: vaultKeyPair.encryptedPrivateKey, }, - { ApiKey: userConfig.Account.ApiKey }, + userConfig.Account.ApiKey, ); spinner.succeed(); diff --git a/src/commands/vault_commands/list-members.ts b/src/commands/vault_commands/list-members.ts index 32858a4..8c42e46 100644 --- a/src/commands/vault_commands/list-members.ts +++ b/src/commands/vault_commands/list-members.ts @@ -34,7 +34,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(); @@ -43,7 +43,7 @@ export const handler: Handler = async (argv) => { spinner.start(`Fetching vault members for ${vaultName}`); const vaultMembers = await api.listVaultMembers( { VaultId: vaultId }, - { ApiKey: userConfig.Account.ApiKey }, + userConfig.Account.ApiKey, ); spinner.succeed(); diff --git a/src/commands/vault_commands/list.ts b/src/commands/vault_commands/list.ts index 9f51b7e..0efff12 100644 --- a/src/commands/vault_commands/list.ts +++ b/src/commands/vault_commands/list.ts @@ -33,7 +33,7 @@ export const handler: Handler = async (argv) => { spinner.start('Fetching vault memberships'); const vaultMemberships = await api.listVaultMemberships( {}, - { ApiKey: userConfig.Account.ApiKey }, + userConfig.Account.ApiKey, ); spinner.succeed(); diff --git a/src/commands/vault_commands/remove-member.ts b/src/commands/vault_commands/remove-member.ts index 48828a0..d5f2cae 100644 --- a/src/commands/vault_commands/remove-member.ts +++ b/src/commands/vault_commands/remove-member.ts @@ -37,14 +37,14 @@ export const handler: Handler = async (argv) => { const { AccountPublicKey: counterpartAccountPublicKey } = await api.retrieveAccountPublicKey( { AccountEmail: email }, - { ApiKey: userConfig.Account.ApiKey }, + userConfig.Account.ApiKey, ); spinner.succeed(); spinner.start('Fetching existing vault memberships'); const vaultMemberships = await api.searchVaultMemberships( { VaultName: vaultName }, - { ApiKey: userConfig.Account.ApiKey }, + userConfig.Account.ApiKey, ); spinner.succeed(); @@ -56,11 +56,11 @@ export const handler: Handler = async (argv) => { spinner.start(`Fetching vault members for ${vaultName}`); const vaultKeys = await api.retrieveVaultKeys( { VaultId: vaultId }, - { ApiKey: userConfig.Account.ApiKey }, + userConfig.Account.ApiKey, ); const vaultMembers = await api.listVaultMembers( { VaultId: vaultId }, - { ApiKey: userConfig.Account.ApiKey }, + userConfig.Account.ApiKey, ); const existingPublicKeys = vaultMembers.map( ({ AccountPublicKey }) => AccountPublicKey, @@ -98,7 +98,7 @@ export const handler: Handler = async (argv) => { VaultEncryptedPrivateKey: vaultEncryptedPrivateKey, AccountEmail: email, }, - { ApiKey: userConfig.Account.ApiKey }, + userConfig.Account.ApiKey, ); spinner.succeed(); diff --git a/src/handleError.ts b/src/handleError.ts index 06bbafc..3e61ca2 100644 --- a/src/handleError.ts +++ b/src/handleError.ts @@ -1,5 +1,4 @@ import chalk from 'chalk'; -import { RequestError } from 'got'; import { EOL } from 'os'; const printMessage = (message: string) => { @@ -11,7 +10,7 @@ const printMessage = (message: string) => { ); }; -export default (message: string, error: Error): never => { +export default async (message: string, error: Error): Promise => { if (message) { printMessage(message); process.exit(1); @@ -19,13 +18,13 @@ export default (message: string, error: Error): never => { let errorMessage = 'Unknown error occurred'; - if (error instanceof RequestError) { - const errorDetails = error.response?.body; + if (error instanceof Response) { + const { ErrorMessage } = await error.json(); - if (typeof errorDetails === 'string') { - errorMessage = errorDetails; + if (ErrorMessage) { + errorMessage = ErrorMessage; } - } else if (error instanceof Error) { + } else { errorMessage = error.message; } diff --git a/src/services/api.ts b/src/services/api.ts new file mode 100644 index 0000000..69ef96c --- /dev/null +++ b/src/services/api.ts @@ -0,0 +1,9 @@ +import Sniptt from '@sniptt/snip-sdk-js'; + +const { SNIPTT_BASE_PATH = 'https://api.sniptt.com' } = process.env; + +const api = new Sniptt({ + basePath: SNIPTT_BASE_PATH, +}); + +export default api; diff --git a/src/services/api/httpClient.ts b/src/services/api/httpClient.ts deleted file mode 100644 index f643c4d..0000000 --- a/src/services/api/httpClient.ts +++ /dev/null @@ -1,9 +0,0 @@ -import got from 'got'; - -const { BASE_URI = 'api.sniptt.com' } = process.env; - -const httpClient = got.extend({ - prefixUrl: `https://${BASE_URI}`, -}); - -export default httpClient; diff --git a/src/services/api/index.ts b/src/services/api/index.ts deleted file mode 100644 index 1e46491..0000000 --- a/src/services/api/index.ts +++ /dev/null @@ -1,37 +0,0 @@ -import addMemberToVault from './methods/addMemberToVault'; -import addSecret from './methods/addSecret'; -import configureAccount from './methods/configureAccount'; -import createOneTimeSecret from './methods/createOneTimeSecret'; -import createVault from './methods/createVault'; -import deleteSecret from './methods/deleteSecret'; -import listVaultMembers from './methods/listVaultMembers'; -import listVaultMemberships from './methods/listVaultMemberships'; -import listVaultSecrets from './methods/listVaultSecrets'; -import registerDevice from './methods/registerDevice'; -import removeMemberFromVault from './methods/removeMemberFromVault'; -import retrieveAccountConfiguration from './methods/retrieveAccountConfiguration'; -import retrieveAccountPublicKey from './methods/retrieveAccountPublicKey'; -import retrieveSecret from './methods/retrieveSecret'; -import retrieveVaultKeys from './methods/retrieveVaultKeys'; -import searchVaultMemberships from './methods/searchVaultMemberships'; -import sendEmailVerificationCode from './methods/sendEmailVerificationCode'; - -export default { - addMemberToVault, - addSecret, - configureAccount, - createOneTimeSecret, - createVault, - deleteSecret, - listVaultMembers, - listVaultMemberships, - listVaultSecrets, - registerDevice, - removeMemberFromVault, - retrieveAccountConfiguration, - retrieveAccountPublicKey, - retrieveSecret, - retrieveVaultKeys, - searchVaultMemberships, - sendEmailVerificationCode, -}; diff --git a/src/services/api/methods/addMemberToVault.ts b/src/services/api/methods/addMemberToVault.ts deleted file mode 100644 index fd02007..0000000 --- a/src/services/api/methods/addMemberToVault.ts +++ /dev/null @@ -1,23 +0,0 @@ -import client from '../httpClient'; -import { Header, ProtectedApiCallOpts } from '../types'; - -type Params = { - VaultId: string; - VaultEncryptedPrivateKey: string; - AccountEmail: string; - Role: 'Read' | 'Admin'; -}; - -export default async ( - params: Params, - opts: ProtectedApiCallOpts, -): Promise => { - await client - .post('addMemberToVault', { - headers: { - [Header.ApiKey]: opts.ApiKey, - }, - json: params, - }) - .json(); -}; diff --git a/src/services/api/methods/addSecret.ts b/src/services/api/methods/addSecret.ts deleted file mode 100644 index 8eb61c6..0000000 --- a/src/services/api/methods/addSecret.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { Asserts, object, string } from 'yup'; - -import client from '../httpClient'; -import { Header, ProtectedApiCallOpts } from '../types'; -import { validateResponseAttributes } from '../validators'; - -type Params = { - SecretName: string; - SecretEncryptedContent: string; - SecretContentType: 'Text' | 'File'; - VaultId: string; -}; - -const ResponseSchema = object({ - SecretId: string().required(), -}).required(); - -export default async ( - params: Params, - opts: ProtectedApiCallOpts, -): Promise> => { - const response = await client - .post('addSecret', { - headers: { - [Header.ApiKey]: opts.ApiKey, - }, - json: params, - }) - .json(); - - return validateResponseAttributes(response, ResponseSchema); -}; diff --git a/src/services/api/methods/configureAccount.ts b/src/services/api/methods/configureAccount.ts deleted file mode 100644 index 3f9fa8d..0000000 --- a/src/services/api/methods/configureAccount.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { Asserts, object, string } from 'yup'; - -import { Header, ProtectedApiCallOpts } from '../types'; -import client from '../httpClient'; -import { validateResponseAttributes } from '../validators'; - -type Params = { - AccountName: string; - AccountEncryptionKeySalt: string; - AccountPublicKey: string; - AccountEncryptedPrivateKey: string; - PersonalVaultPublicKey: string; - PersonalVaultEncryptedPrivateKey: string; -}; - -const ResponseSchema = object({ - AccountId: string().required(), - PersonalVaultId: string().required(), -}).required(); - -export default async ( - params: Params, - opts: ProtectedApiCallOpts, -): Promise> => { - const response = await client - .post('configureAccount', { - headers: { - [Header.ApiKey]: opts.ApiKey, - }, - json: params, - }) - .json(); - - return validateResponseAttributes(response, ResponseSchema); -}; diff --git a/src/services/api/methods/createOneTimeSecret.ts b/src/services/api/methods/createOneTimeSecret.ts deleted file mode 100644 index d7782de..0000000 --- a/src/services/api/methods/createOneTimeSecret.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { Asserts, object, string } from 'yup'; - -import client from '../httpClient'; -import { Header, ProtectedApiCallOpts } from '../types'; -import { validateResponseAttributes } from '../validators'; - -type Params = { - OneTimeSecretPublicKey: string; - OneTimeSecretEncryptedPrivateKey: string; - OneTimeSecretEncryptedContent: string; - OneTimeSecretContentType: 'Text' | 'File'; -}; - -const ResponseSchema = object({ - OneTimeSecretId: string().required(), -}).required(); - -export default async ( - params: Params, - opts: ProtectedApiCallOpts, -): Promise> => { - const response = await client - .post('createOneTimeSecret', { - headers: { - [Header.ApiKey]: opts.ApiKey, - }, - json: params, - }) - .json(); - - return validateResponseAttributes(response, ResponseSchema); -}; diff --git a/src/services/api/methods/createVault.ts b/src/services/api/methods/createVault.ts deleted file mode 100644 index 3202c5b..0000000 --- a/src/services/api/methods/createVault.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { Asserts, object, string } from 'yup'; - -import { Header, ProtectedApiCallOpts } from '../types'; -import client from '../httpClient'; -import { validateResponseAttributes } from '../validators'; - -type Params = { - VaultName: string; - VaultPublicKey: string; - VaultEncryptedPrivateKey: string; -}; - -const ResponseSchema = object({ - VaultId: string().required(), -}).required(); - -export default async ( - params: Params, - opts: ProtectedApiCallOpts, -): Promise> => { - const response = await client - .post('createVault', { - headers: { - [Header.ApiKey]: opts.ApiKey, - }, - json: params, - }) - .json(); - - return validateResponseAttributes(response, ResponseSchema); -}; diff --git a/src/services/api/methods/deleteSecret.ts b/src/services/api/methods/deleteSecret.ts deleted file mode 100644 index 415683a..0000000 --- a/src/services/api/methods/deleteSecret.ts +++ /dev/null @@ -1,21 +0,0 @@ -import client from '../httpClient'; -import { Header, ProtectedApiCallOpts } from '../types'; - -type Params = { - SecretName: string; - VaultId: string; -}; - -export default async ( - params: Params, - opts: ProtectedApiCallOpts, -): Promise => { - await client - .post('deleteSecret', { - headers: { - [Header.ApiKey]: opts.ApiKey, - }, - json: params, - }) - .json(); -}; diff --git a/src/services/api/methods/listVaultMembers.ts b/src/services/api/methods/listVaultMembers.ts deleted file mode 100644 index 943f6a3..0000000 --- a/src/services/api/methods/listVaultMembers.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { Asserts, object, string } from 'yup'; -import client from '../httpClient'; -import { Header, ProtectedApiCallOpts } from '../types'; -import { validateResponseAttributes } from '../validators'; - -type Params = { VaultId: string }; - -const ResponseSchema = object({ - Role: string().required(), - AccountId: string().required(), - AccountName: string().required(), - AccountEmail: string().required(), - AccountPublicKey: string().required(), -}).required(); - -export default async ( - params: Params, - opts: ProtectedApiCallOpts, -): Promise>> => { - const response = await client - .post('listVaultMembers', { - headers: { - [Header.ApiKey]: opts.ApiKey, - }, - json: params, - }) - .json>(); - - return Promise.all( - response.map((item) => validateResponseAttributes(item, ResponseSchema)), - ); -}; diff --git a/src/services/api/methods/listVaultMemberships.ts b/src/services/api/methods/listVaultMemberships.ts deleted file mode 100644 index 8825932..0000000 --- a/src/services/api/methods/listVaultMemberships.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { Asserts, object, string } from 'yup'; -import client from '../httpClient'; -import { Header, ProtectedApiCallOpts } from '../types'; -import { validateResponseAttributes } from '../validators'; - -type Params = Record; - -const ResponseSchema = object({ - Role: string().required(), - VaultId: string().required(), - VaultName: string().required(), - VaultOwnerAccountId: string().required(), - VaultOwnerAccountEmail: string().required(), - VaultOwnerAccountName: string().required(), -}).required(); - -export default async ( - params: Params, - opts: ProtectedApiCallOpts, -): Promise>> => { - const response = await client - .post('listVaultMemberships', { - headers: { - [Header.ApiKey]: opts.ApiKey, - }, - json: params, - }) - .json>(); - - return Promise.all( - response.map((item) => validateResponseAttributes(item, ResponseSchema)), - ); -}; diff --git a/src/services/api/methods/listVaultSecrets.ts b/src/services/api/methods/listVaultSecrets.ts deleted file mode 100644 index fad14da..0000000 --- a/src/services/api/methods/listVaultSecrets.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { Asserts, object, string } from 'yup'; - -import client from '../httpClient'; -import { Header, ProtectedApiCallOpts } from '../types'; -import { validateResponseAttributes } from '../validators'; - -type Params = { - VaultId: string; -}; - -const ResponseSchema = object({ - SecretId: string().required(), - SecretName: string().required(), - SecretOwnerAccountId: string().required(), - SecretOwnerAccountName: string().required(), - SecretOwnerAccountEmail: string().required(), -}).required(); - -export default async ( - params: Params, - opts: ProtectedApiCallOpts, -): Promise>> => { - const response = await client - .post('listVaultSecrets', { - headers: { - [Header.ApiKey]: opts.ApiKey, - }, - json: params, - }) - .json>(); - - return Promise.all( - response.map((item) => validateResponseAttributes(item, ResponseSchema)), - ); -}; diff --git a/src/services/api/methods/registerDevice.ts b/src/services/api/methods/registerDevice.ts deleted file mode 100644 index 598e0f5..0000000 --- a/src/services/api/methods/registerDevice.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Asserts, object, string, boolean } from 'yup'; - -import client from '../httpClient'; -import { validateResponseAttributes } from '../validators'; - -type Params = { - Code: string; - DeviceName: string; - Email: string; -}; - -const ResponseSchema = object({ - ApiKey: string().required(), - AccountId: string().required(), - DeviceId: string().required(), - IsAccountConfigured: boolean().required(), -}).required(); - -export default async ( - params: Params, -): Promise> => { - const response = await client.post('registerDevice', { json: params }).json(); - return validateResponseAttributes(response, ResponseSchema); -}; diff --git a/src/services/api/methods/removeMemberFromVault.ts b/src/services/api/methods/removeMemberFromVault.ts deleted file mode 100644 index 74e7999..0000000 --- a/src/services/api/methods/removeMemberFromVault.ts +++ /dev/null @@ -1,22 +0,0 @@ -import client from '../httpClient'; -import { Header, ProtectedApiCallOpts } from '../types'; - -type Params = { - VaultId: string; - VaultEncryptedPrivateKey: string; - AccountEmail: string; -}; - -export default async ( - params: Params, - opts: ProtectedApiCallOpts, -): Promise => { - await client - .post('removeMemberFromVault', { - headers: { - [Header.ApiKey]: opts.ApiKey, - }, - json: params, - }) - .json(); -}; diff --git a/src/services/api/methods/retrieveAccountConfiguration.ts b/src/services/api/methods/retrieveAccountConfiguration.ts deleted file mode 100644 index 49d57c5..0000000 --- a/src/services/api/methods/retrieveAccountConfiguration.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { Asserts, object, string } from 'yup'; - -import client from '../httpClient'; -import { Header, ProtectedApiCallOpts } from '../types'; -import { validateResponseAttributes } from '../validators'; - -type Params = Record; - -const ResponseSchema = object({ - AccountId: string().required(), - AccountEmail: string().required(), - AccountName: string().required(), - AccountTier: string().required(), - AccountPublicKey: string().required(), - AccountEncryptedPrivateKey: string().required(), - AccountEncryptionKeySalt: string().required(), - PersonalVaultId: string().required(), - PersonalVaultPublicKey: string().required(), - PersonalVaultEncryptedPrivateKey: string().required(), -}).required(); - -export default async ( - params: Params, - opts: ProtectedApiCallOpts, -): Promise> => { - const response = await client - .post('retrieveAccountConfiguration', { - headers: { - [Header.ApiKey]: opts.ApiKey, - }, - json: params, - }) - .json(); - - return validateResponseAttributes(response, ResponseSchema); -}; diff --git a/src/services/api/methods/retrieveAccountPublicKey.ts b/src/services/api/methods/retrieveAccountPublicKey.ts deleted file mode 100644 index 4c8cfc4..0000000 --- a/src/services/api/methods/retrieveAccountPublicKey.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { Asserts, object, string } from 'yup'; - -import client from '../httpClient'; -import { Header, ProtectedApiCallOpts } from '../types'; -import { validateResponseAttributes } from '../validators'; - -type Params = { - AccountEmail: string; -}; - -const ResponseSchema = object({ - AccountPublicKey: string().required(), -}).required(); - -export default async ( - params: Params, - opts: ProtectedApiCallOpts, -): Promise> => { - const response = await client - .post('retrieveAccountPublicKey', { - headers: { - [Header.ApiKey]: opts.ApiKey, - }, - json: params, - }) - .json(); - - return validateResponseAttributes(response, ResponseSchema); -}; diff --git a/src/services/api/methods/retrieveSecret.ts b/src/services/api/methods/retrieveSecret.ts deleted file mode 100644 index 01730d9..0000000 --- a/src/services/api/methods/retrieveSecret.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { Asserts, object, string } from 'yup'; - -import client from '../httpClient'; -import { Header, ProtectedApiCallOpts } from '../types'; -import { validateResponseAttributes } from '../validators'; - -type Params = { - SecretName: string; - VaultId: string; -}; - -const ResponseSchema = object({ - SecretId: string().required(), - SecretName: string().required(), - SecretEncryptedContent: string().required(), - SecretContentType: string().required(), -}).required(); - -export default async ( - params: Params, - opts: ProtectedApiCallOpts, -): Promise> => { - const response = await client - .post('retrieveSecret', { - headers: { - [Header.ApiKey]: opts.ApiKey, - }, - json: params, - }) - .json(); - - return validateResponseAttributes(response, ResponseSchema); -}; diff --git a/src/services/api/methods/retrieveVaultKeys.ts b/src/services/api/methods/retrieveVaultKeys.ts deleted file mode 100644 index 2768538..0000000 --- a/src/services/api/methods/retrieveVaultKeys.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { Asserts, object, string } from 'yup'; - -import client from '../httpClient'; -import { Header, ProtectedApiCallOpts } from '../types'; -import { validateResponseAttributes } from '../validators'; - -type Params = { - VaultId: string; -}; - -const ResponseSchema = object({ - VaultPublicKey: string().required(), - VaultEncryptedPrivateKey: string().required(), -}).required(); - -export default async ( - params: Params, - opts: ProtectedApiCallOpts, -): Promise> => { - const response = await client - .post('retrieveVaultKeys', { - headers: { - [Header.ApiKey]: opts.ApiKey, - }, - json: params, - }) - .json>(); - - return validateResponseAttributes(response, ResponseSchema); -}; diff --git a/src/services/api/methods/searchVaultMemberships.ts b/src/services/api/methods/searchVaultMemberships.ts deleted file mode 100644 index 1661e42..0000000 --- a/src/services/api/methods/searchVaultMemberships.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { Asserts, object, string } from 'yup'; - -import client from '../httpClient'; -import { Header, ProtectedApiCallOpts } from '../types'; -import { validateResponseAttributes } from '../validators'; - -type Params = { - VaultName: string; -}; - -const ResponseSchema = object({ - Role: string().required(), - VaultId: string().required(), - VaultName: string().required(), - VaultOwnerAccountId: string().required(), - VaultOwnerAccountEmail: string().required(), - VaultOwnerAccountName: string().required(), -}).required(); - -export default async ( - params: Params, - opts: ProtectedApiCallOpts, -): Promise>> => { - const response = await client - .post('searchVaultMemberships', { - headers: { - [Header.ApiKey]: opts.ApiKey, - }, - json: params, - }) - .json>(); - - return Promise.all( - response.map((item) => validateResponseAttributes(item, ResponseSchema)), - ); -}; diff --git a/src/services/api/methods/sendEmailVerificationCode.ts b/src/services/api/methods/sendEmailVerificationCode.ts deleted file mode 100644 index d331084..0000000 --- a/src/services/api/methods/sendEmailVerificationCode.ts +++ /dev/null @@ -1,9 +0,0 @@ -import client from '../httpClient'; - -type Params = { - Email: string; -}; - -export default async (params: Params): Promise => { - await client.post('sendEmailVerificationCode', { json: params }); -}; diff --git a/src/services/api/types.ts b/src/services/api/types.ts deleted file mode 100644 index 4c78177..0000000 --- a/src/services/api/types.ts +++ /dev/null @@ -1,7 +0,0 @@ -export enum Header { - ApiKey = 'x-api-key', -} - -export interface ProtectedApiCallOpts { - ApiKey: string; -} diff --git a/src/services/api/validators.ts b/src/services/api/validators.ts deleted file mode 100644 index d9ae11b..0000000 --- a/src/services/api/validators.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Asserts, BaseSchema } from 'yup'; - -export const validateResponseAttributes = ( - item: unknown, - schema: T, -): Asserts => - schema.validate(item, { - stripUnknown: true, - abortEarly: true, - });