diff --git a/CHANGELOG.md b/CHANGELOG.md index 7eeaf1b23..36b4fcc80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to the Imperative package will be documented in this file. +## Recent Changes + +- Enhancement: Replaced use of `node-keytar` with the new `keyring` module from `@zowe/secrets-for-zowe-sdk`. [zowe-cli#1622](https://github.com/zowe/zowe-cli/issues/1622) + ## `5.17.0` - Enhancement: Added `inSchema` property for ProfileInfo to indicate if argument is a known schema argument [#899](https://github.com/zowe/imperative/issues/899) diff --git a/__tests__/__integration__/imperative/__tests__/__integration__/cli/auth/imperative.test.cli.auth.login.fruit.integration.test.ts b/__tests__/__integration__/imperative/__tests__/__integration__/cli/auth/imperative.test.cli.auth.login.fruit.integration.test.ts index 4ef0b5fea..d361c78c8 100644 --- a/__tests__/__integration__/imperative/__tests__/__integration__/cli/auth/imperative.test.cli.auth.login.fruit.integration.test.ts +++ b/__tests__/__integration__/imperative/__tests__/__integration__/cli/auth/imperative.test.cli.auth.login.fruit.integration.test.ts @@ -14,7 +14,7 @@ import { runCliScript } from "../../../../../../src/TestUtil"; import { ITestEnvironment } from "../../../../../../__src__/environment/doc/response/ITestEnvironment"; import { SetupTestEnvironment } from "../../../../../../__src__/environment/SetupTestEnvironment"; import * as fs from "fs"; -import * as keytar from "keytar"; +import { keyring as keytar } from "@zowe/secrets-for-zowe-sdk"; // Test Environment populated in the beforeAll(); let TEST_ENVIRONMENT: ITestEnvironment; diff --git a/__tests__/__integration__/imperative/__tests__/__integration__/cli/auth/imperative.test.cli.auth.logout.fruit.integration.test.ts b/__tests__/__integration__/imperative/__tests__/__integration__/cli/auth/imperative.test.cli.auth.logout.fruit.integration.test.ts index 37387912b..ae52e1141 100644 --- a/__tests__/__integration__/imperative/__tests__/__integration__/cli/auth/imperative.test.cli.auth.logout.fruit.integration.test.ts +++ b/__tests__/__integration__/imperative/__tests__/__integration__/cli/auth/imperative.test.cli.auth.logout.fruit.integration.test.ts @@ -13,7 +13,7 @@ import { runCliScript } from "../../../../../../src/TestUtil"; import { ITestEnvironment } from "../../../../../../__src__/environment/doc/response/ITestEnvironment"; import { SetupTestEnvironment } from "../../../../../../__src__/environment/SetupTestEnvironment"; import * as fs from "fs"; -import * as keytar from "keytar"; +import { keyring as keytar } from "@zowe/secrets-for-zowe-sdk"; // Test Environment populated in the beforeAll(); let TEST_ENVIRONMENT: ITestEnvironment; diff --git a/__tests__/__integration__/imperative/__tests__/__integration__/cli/config/auto-init/imperative.test.cli.config.auto-init.fruit.integration.test.ts b/__tests__/__integration__/imperative/__tests__/__integration__/cli/config/auto-init/imperative.test.cli.config.auto-init.fruit.integration.test.ts index d9e742212..a07b4c259 100644 --- a/__tests__/__integration__/imperative/__tests__/__integration__/cli/config/auto-init/imperative.test.cli.config.auto-init.fruit.integration.test.ts +++ b/__tests__/__integration__/imperative/__tests__/__integration__/cli/config/auto-init/imperative.test.cli.config.auto-init.fruit.integration.test.ts @@ -12,7 +12,7 @@ import * as fs from "fs"; import * as glob from "glob"; import * as jsonfile from "jsonfile"; -import * as keytar from "keytar"; +import { keyring as keytar } from "@zowe/secrets-for-zowe-sdk"; import { IConfig } from "../../../../../../../../packages"; import { IConfigSecureProperties } from "../../../../../../../../packages/config/src/doc/IConfigSecure"; import { runCliScript } from "../../../../../../../src/TestUtil"; diff --git a/__tests__/__integration__/imperative/__tests__/__integration__/cli/config/convert-profiles/cli.imperative-test-cli.config.convert-profiles.integration.test.ts b/__tests__/__integration__/imperative/__tests__/__integration__/cli/config/convert-profiles/cli.imperative-test-cli.config.convert-profiles.integration.test.ts index b7e9c84a3..c849cc4f3 100644 --- a/__tests__/__integration__/imperative/__tests__/__integration__/cli/config/convert-profiles/cli.imperative-test-cli.config.convert-profiles.integration.test.ts +++ b/__tests__/__integration__/imperative/__tests__/__integration__/cli/config/convert-profiles/cli.imperative-test-cli.config.convert-profiles.integration.test.ts @@ -12,7 +12,7 @@ import * as fs from "fs"; import * as fsExtra from "fs-extra"; import * as path from "path"; -import * as keytar from "keytar"; +import { keyring as keytar } from "@zowe/secrets-for-zowe-sdk"; import { ITestEnvironment } from "../../../../../../../__src__/environment/doc/response/ITestEnvironment"; import { SetupTestEnvironment } from "../../../../../../../__src__/environment/SetupTestEnvironment"; import { runCliScript } from "../../../../../../../src/TestUtil"; diff --git a/__tests__/__integration__/imperative/__tests__/__integration__/cli/config/secure/cli.imperative-test-cli.config.secure.integration.test.ts b/__tests__/__integration__/imperative/__tests__/__integration__/cli/config/secure/cli.imperative-test-cli.config.secure.integration.test.ts index 48f8f12dc..3c20c5721 100644 --- a/__tests__/__integration__/imperative/__tests__/__integration__/cli/config/secure/cli.imperative-test-cli.config.secure.integration.test.ts +++ b/__tests__/__integration__/imperative/__tests__/__integration__/cli/config/secure/cli.imperative-test-cli.config.secure.integration.test.ts @@ -14,7 +14,7 @@ import { SetupTestEnvironment } from "../../../../../../../__src__/environment/S import { runCliScript } from "../../../../../../../src/TestUtil"; import { expectedConfigObject, expectedUserConfigObject } from "../__resources__/expectedObjects"; import * as fs from "fs"; -import * as keytar from "keytar"; +import { keyring as keytar } from "@zowe/secrets-for-zowe-sdk"; import * as path from "path"; import * as lodash from "lodash"; import { IConfigProfile } from "../../../../../../../../packages"; diff --git a/__tests__/__integration__/imperative/__tests__/__integration__/cli/config/set/cli.imperative-test-cli.config.set.integration.test.ts b/__tests__/__integration__/imperative/__tests__/__integration__/cli/config/set/cli.imperative-test-cli.config.set.integration.test.ts index e64c0117f..0ba08977c 100644 --- a/__tests__/__integration__/imperative/__tests__/__integration__/cli/config/set/cli.imperative-test-cli.config.set.integration.test.ts +++ b/__tests__/__integration__/imperative/__tests__/__integration__/cli/config/set/cli.imperative-test-cli.config.set.integration.test.ts @@ -15,7 +15,7 @@ import { runCliScript } from "../../../../../../../src/TestUtil"; import { expectedConfigObject, expectedUserConfigObject } from "../__resources__/expectedObjects"; import * as fs from "fs"; import * as path from "path"; -import * as keytar from "keytar"; +import { keyring as keytar } from "@zowe/secrets-for-zowe-sdk"; import * as lodash from "lodash"; // Test Environment populated in the beforeAll(); diff --git a/__tests__/__integration__/imperative/package.json b/__tests__/__integration__/imperative/package.json index 94f06fa80..4c35fd256 100644 --- a/__tests__/__integration__/imperative/package.json +++ b/__tests__/__integration__/imperative/package.json @@ -35,7 +35,7 @@ }, "dependencies": { "@zowe/imperative": "../../..", - "keytar": "^7.1.0" + "@zowe/secrets-for-zowe-sdk": "7.18.0-next.4" }, "engines": { "node": ">=8.0.0" diff --git a/__tests__/src/packages/profiles/__integration__/CliProfileManager.credentials.spec.ts b/__tests__/src/packages/profiles/__integration__/CliProfileManager.credentials.spec.ts index 62864607d..2bd3cb1fd 100644 --- a/__tests__/src/packages/profiles/__integration__/CliProfileManager.credentials.spec.ts +++ b/__tests__/src/packages/profiles/__integration__/CliProfileManager.credentials.spec.ts @@ -240,8 +240,8 @@ describe("Cli Profile Manager", () => { describe("Missing keytar installation", () => { const profileName = "missing-keytar"; - const keyTarDir = path.join(__dirname, "../../../../../node_modules/keytar"); - const renamedKeyTarDir = path.join(__dirname, "../../../../../node_modules/keytar-renamed"); + const keyTarDir = path.join(__dirname, "../../../../../node_modules/@zowe/secrets-for-zowe-sdk"); + const renamedKeyTarDir = path.join(__dirname, "../../../../../node_modules/@zowe/zowe-for-secrets-sdk"); const renameKeyTar = () => { if (fs.existsSync(keyTarDir)) { diff --git a/__tests__/src/packages/profiles/test_cli/package.json b/__tests__/src/packages/profiles/test_cli/package.json index 586e7c000..3e5cc07e1 100644 --- a/__tests__/src/packages/profiles/test_cli/package.json +++ b/__tests__/src/packages/profiles/test_cli/package.json @@ -1,6 +1,6 @@ { "name": "test-cli-for-profiles", "dependencies": { - "keytar": "rock-out-with-a-keytar" + "@zowe/secrets-for-zowe-sdk": "plaintext" } } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index ed5420ea3..7a86d1c0b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -68,6 +68,7 @@ "@types/which": "^2.0.1", "@typescript-eslint/eslint-plugin": "^5.33.0", "@typescript-eslint/parser": "^5.33.0", + "@zowe/secrets-for-zowe-sdk": "^7.18.0-next.4", "ansi-colors": "^4.1.1", "clear-require": "^2.0.0", "concurrently": "^7.5.0", @@ -86,7 +87,6 @@ "jest-junit": "^6.3.0", "jest-sonar-reporter": "^2.0.0", "jest-stare": "^2.2.0", - "keytar": "^7.9.0", "madge": "^4.0.1", "serve": "^12.0.1", "shebang-regex": "^2.0.0", @@ -4004,6 +4004,16 @@ "node": ">=8.5.0" } }, + "node_modules/@zowe/secrets-for-zowe-sdk": { + "version": "7.18.0-next.4", + "resolved": "https://zowe.jfrog.io/zowe/api/npm/npm-release/@zowe/secrets-for-zowe-sdk/-/@zowe/secrets-for-zowe-sdk-7.18.0-next.4.tgz", + "integrity": "sha512-H3UElOA7UxZL+Ee3Q2cHCwF/T0s+SEv8Wof9kyzC0TiP71awBHZiPONY7bZIe3vbpRlckt2ECcG/os6qrDrjJw==", + "dev": true, + "hasInstallScript": true, + "engines": { + "node": ">= 14" + } + }, "node_modules/abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", @@ -5722,21 +5732,6 @@ "npm": ">=2.15" } }, - "node_modules/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==", - "dev": true, - "dependencies": { - "mimic-response": "^3.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/dedent": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz", @@ -5890,15 +5885,6 @@ "node": ">=4.2.0" } }, - "node_modules/detect-libc": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.1.tgz", - "integrity": "sha512-463v3ZeIrcWtdgIg6vI6XUncguvr2TnGl4SzDXinkt9mSLpBJKXT3mW6xT3VQdDN11+WVs29pgvivTc4Lp8v+w==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/detect-newline": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", @@ -6840,15 +6826,6 @@ "node": ">= 0.8.0" } }, - "node_modules/expand-template": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", - "integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==", - "dev": true, - "engines": { - "node": ">=6" - } - }, "node_modules/expect": { "version": "28.1.3", "resolved": "https://registry.npmjs.org/expect/-/expect-28.1.3.tgz", @@ -7079,12 +7056,6 @@ "integrity": "sha1-g8YK/Fi5xWmXAH7Rp2izqzA6RP4=", "dev": true }, - "node_modules/fs-constants": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", - "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==", - "dev": true - }, "node_modules/fs-extra": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", @@ -7241,12 +7212,6 @@ "node": ">=6" } }, - "node_modules/github-from-package": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", - "integrity": "sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==", - "dev": true - }, "node_modules/github-markdown-css": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/github-markdown-css/-/github-markdown-css-5.1.0.tgz", @@ -11177,17 +11142,6 @@ "integrity": "sha512-g3UB796vUFIY90VIv/WX3L2c8CS2MdWUww3CNrYmqza1Fg0DURc2K/O4YrnklBdQarSJ/y8JnJYDGc+1iumQjg==", "dev": true }, - "node_modules/keytar": { - "version": "7.9.0", - "resolved": "https://registry.npmjs.org/keytar/-/keytar-7.9.0.tgz", - "integrity": "sha512-VPD8mtVtm5JNtA2AErl6Chp06JBfy7diFQ7TQQhdpWOl6MrCRB+eRbvAZUsbGQS9kiMq0coJsy0W0vHpDCkWsQ==", - "dev": true, - "hasInstallScript": true, - "dependencies": { - "node-addon-api": "^4.3.0", - "prebuild-install": "^7.0.1" - } - }, "node_modules/kleur": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", @@ -11720,18 +11674,6 @@ "node": ">=6" } }, - "node_modules/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==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/minimatch": { "version": "3.0.8", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.8.tgz", @@ -11851,12 +11793,6 @@ "node": ">=10" } }, - "node_modules/mkdirp-classic": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", - "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==", - "dev": true - }, "node_modules/module-definition": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/module-definition/-/module-definition-3.3.1.tgz", @@ -11940,12 +11876,6 @@ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" } }, - "node_modules/napi-build-utils": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-1.0.2.tgz", - "integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==", - "dev": true - }, "node_modules/natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", @@ -11995,24 +11925,6 @@ "isarray": "0.0.1" } }, - "node_modules/node-abi": { - "version": "3.24.0", - "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.24.0.tgz", - "integrity": "sha512-YPG3Co0luSu6GwOBsmIdGW6Wx0NyNDLg/hriIyDllVsNwnI6UeqaWShxC3lbH4LtEQUgoLP3XR1ndXiDAWvmRw==", - "dev": true, - "dependencies": { - "semver": "^7.3.5" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/node-addon-api": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-4.3.0.tgz", - "integrity": "sha512-73sE9+3UaLYYFmDsFZnqCInzPyh3MqIwZO9cw58yIqAZhONrrabrYyYe3TuIqtIiOuTXVhsGau8hcrhhwSsDIQ==", - "dev": true - }, "node_modules/node-cleanup": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/node-cleanup/-/node-cleanup-2.1.2.tgz", @@ -12881,32 +12793,6 @@ "integrity": "sha512-cMlDqaLEqfSaW8Z7N5Jw+lyIW869EzT73/F5lhtY9cLGoVxSXznfgfXMO0Z5K0o0Q2TkTXq+0KFsdnSe3jDViA==", "dev": true }, - "node_modules/prebuild-install": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.1.tgz", - "integrity": "sha512-jAXscXWMcCK8GgCoHOfIr0ODh5ai8mj63L2nWrjuAgXE6tDyYGnx4/8o/rCgU+B4JSyZBKbeZqzhtwtC3ovxjw==", - "dev": true, - "dependencies": { - "detect-libc": "^2.0.0", - "expand-template": "^2.0.3", - "github-from-package": "0.0.0", - "minimist": "^1.2.3", - "mkdirp-classic": "^0.5.3", - "napi-build-utils": "^1.0.1", - "node-abi": "^3.3.0", - "pump": "^3.0.0", - "rc": "^1.2.7", - "simple-get": "^4.0.0", - "tar-fs": "^2.0.0", - "tunnel-agent": "^0.6.0" - }, - "bin": { - "prebuild-install": "bin.js" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/precinct": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/precinct/-/precinct-7.1.0.tgz", @@ -13779,51 +13665,6 @@ "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", "dev": true }, - "node_modules/simple-concat": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", - "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, - "node_modules/simple-get": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.1.tgz", - "integrity": "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "dependencies": { - "decompress-response": "^6.0.0", - "once": "^1.3.1", - "simple-concat": "^1.0.0" - } - }, "node_modules/sinon": { "version": "9.2.4", "resolved": "https://registry.npmjs.org/sinon/-/sinon-9.2.4.tgz", @@ -14269,48 +14110,6 @@ "node": ">= 10" } }, - "node_modules/tar-fs": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz", - "integrity": "sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==", - "dev": true, - "dependencies": { - "chownr": "^1.1.1", - "mkdirp-classic": "^0.5.2", - "pump": "^3.0.0", - "tar-stream": "^2.1.4" - } - }, - "node_modules/tar-stream": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", - "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", - "dev": true, - "dependencies": { - "bl": "^4.0.3", - "end-of-stream": "^1.4.1", - "fs-constants": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^3.1.1" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/tar-stream/node_modules/readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "dev": true, - "dependencies": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/tar/node_modules/chownr": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", @@ -14648,18 +14447,6 @@ "typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta" } }, - "node_modules/tunnel-agent": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==", - "dev": true, - "dependencies": { - "safe-buffer": "^5.0.1" - }, - "engines": { - "node": "*" - } - }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -18114,6 +17901,12 @@ "pkg-up": "2.0.0" } }, + "@zowe/secrets-for-zowe-sdk": { + "version": "7.18.0-next.4", + "resolved": "https://zowe.jfrog.io/zowe/api/npm/npm-release/@zowe/secrets-for-zowe-sdk/-/@zowe/secrets-for-zowe-sdk-7.18.0-next.4.tgz", + "integrity": "sha512-H3UElOA7UxZL+Ee3Q2cHCwF/T0s+SEv8Wof9kyzC0TiP71awBHZiPONY7bZIe3vbpRlckt2ECcG/os6qrDrjJw==", + "dev": true + }, "abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", @@ -19407,15 +19200,6 @@ "esprima": "4.0.1" } }, - "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==", - "dev": true, - "requires": { - "mimic-response": "^3.1.0" - } - }, "dedent": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz", @@ -19536,12 +19320,6 @@ } } }, - "detect-libc": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.1.tgz", - "integrity": "sha512-463v3ZeIrcWtdgIg6vI6XUncguvr2TnGl4SzDXinkt9mSLpBJKXT3mW6xT3VQdDN11+WVs29pgvivTc4Lp8v+w==", - "dev": true - }, "detect-newline": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", @@ -20219,12 +19997,6 @@ "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", "dev": true }, - "expand-template": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", - "integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==", - "dev": true - }, "expect": { "version": "28.1.3", "resolved": "https://registry.npmjs.org/expect/-/expect-28.1.3.tgz", @@ -20418,12 +20190,6 @@ "integrity": "sha1-g8YK/Fi5xWmXAH7Rp2izqzA6RP4=", "dev": true }, - "fs-constants": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", - "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==", - "dev": true - }, "fs-extra": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", @@ -20540,12 +20306,6 @@ "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", - "integrity": "sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==", - "dev": true - }, "github-markdown-css": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/github-markdown-css/-/github-markdown-css-5.1.0.tgz", @@ -23494,16 +23254,6 @@ "integrity": "sha512-g3UB796vUFIY90VIv/WX3L2c8CS2MdWUww3CNrYmqza1Fg0DURc2K/O4YrnklBdQarSJ/y8JnJYDGc+1iumQjg==", "dev": true }, - "keytar": { - "version": "7.9.0", - "resolved": "https://registry.npmjs.org/keytar/-/keytar-7.9.0.tgz", - "integrity": "sha512-VPD8mtVtm5JNtA2AErl6Chp06JBfy7diFQ7TQQhdpWOl6MrCRB+eRbvAZUsbGQS9kiMq0coJsy0W0vHpDCkWsQ==", - "dev": true, - "requires": { - "node-addon-api": "^4.3.0", - "prebuild-install": "^7.0.1" - } - }, "kleur": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", @@ -23911,12 +23661,6 @@ "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", "dev": true }, - "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==", - "dev": true - }, "minimatch": { "version": "3.0.8", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.8.tgz", @@ -24004,12 +23748,6 @@ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==" }, - "mkdirp-classic": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", - "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==", - "dev": true - }, "module-definition": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/module-definition/-/module-definition-3.3.1.tgz", @@ -24068,12 +23806,6 @@ "integrity": "sha512-fmsZYa9lpn69Ad5eDn7FMcnnSR+8R34W9qJEijxYhTbfOWzr22n1QxCMzXLK+ODyW2973V3Fux959iQoUxzUIA==", "dev": true }, - "napi-build-utils": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-1.0.2.tgz", - "integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==", - "dev": true - }, "natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", @@ -24122,21 +23854,6 @@ } } }, - "node-abi": { - "version": "3.24.0", - "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.24.0.tgz", - "integrity": "sha512-YPG3Co0luSu6GwOBsmIdGW6Wx0NyNDLg/hriIyDllVsNwnI6UeqaWShxC3lbH4LtEQUgoLP3XR1ndXiDAWvmRw==", - "dev": true, - "requires": { - "semver": "^7.3.5" - } - }, - "node-addon-api": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-4.3.0.tgz", - "integrity": "sha512-73sE9+3UaLYYFmDsFZnqCInzPyh3MqIwZO9cw58yIqAZhONrrabrYyYe3TuIqtIiOuTXVhsGau8hcrhhwSsDIQ==", - "dev": true - }, "node-cleanup": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/node-cleanup/-/node-cleanup-2.1.2.tgz", @@ -24795,26 +24512,6 @@ "uniq": "^1.0.1" } }, - "prebuild-install": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.1.tgz", - "integrity": "sha512-jAXscXWMcCK8GgCoHOfIr0ODh5ai8mj63L2nWrjuAgXE6tDyYGnx4/8o/rCgU+B4JSyZBKbeZqzhtwtC3ovxjw==", - "dev": true, - "requires": { - "detect-libc": "^2.0.0", - "expand-template": "^2.0.3", - "github-from-package": "0.0.0", - "minimist": "^1.2.3", - "mkdirp-classic": "^0.5.3", - "napi-build-utils": "^1.0.1", - "node-abi": "^3.3.0", - "pump": "^3.0.0", - "rc": "^1.2.7", - "simple-get": "^4.0.0", - "tar-fs": "^2.0.0", - "tunnel-agent": "^0.6.0" - } - }, "precinct": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/precinct/-/precinct-7.1.0.tgz", @@ -25501,23 +25198,6 @@ "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", "dev": true }, - "simple-concat": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", - "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==", - "dev": true - }, - "simple-get": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.1.tgz", - "integrity": "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==", - "dev": true, - "requires": { - "decompress-response": "^6.0.0", - "once": "^1.3.1", - "simple-concat": "^1.0.0" - } - }, "sinon": { "version": "9.2.4", "resolved": "https://registry.npmjs.org/sinon/-/sinon-9.2.4.tgz", @@ -25869,44 +25549,6 @@ } } }, - "tar-fs": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz", - "integrity": "sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==", - "dev": true, - "requires": { - "chownr": "^1.1.1", - "mkdirp-classic": "^0.5.2", - "pump": "^3.0.0", - "tar-stream": "^2.1.4" - } - }, - "tar-stream": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", - "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", - "dev": true, - "requires": { - "bl": "^4.0.3", - "end-of-stream": "^1.4.1", - "fs-constants": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^3.1.1" - }, - "dependencies": { - "readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "dev": true, - "requires": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - } - } - } - }, "temp": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/temp/-/temp-0.4.0.tgz", @@ -26148,15 +25790,6 @@ "tslib": "^1.8.1" } }, - "tunnel-agent": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==", - "dev": true, - "requires": { - "safe-buffer": "^5.0.1" - } - }, "type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", diff --git a/package.json b/package.json index 2d1d6b436..732a06183 100644 --- a/package.json +++ b/package.json @@ -111,6 +111,7 @@ "@types/which": "^2.0.1", "@typescript-eslint/eslint-plugin": "^5.33.0", "@typescript-eslint/parser": "^5.33.0", + "@zowe/secrets-for-zowe-sdk": "^7.18.0-next.4", "ansi-colors": "^4.1.1", "clear-require": "^2.0.0", "concurrently": "^7.5.0", @@ -129,7 +130,6 @@ "jest-junit": "^6.3.0", "jest-sonar-reporter": "^2.0.0", "jest-stare": "^2.2.0", - "keytar": "^7.9.0", "madge": "^4.0.1", "serve": "^12.0.1", "shebang-regex": "^2.0.0", diff --git a/packages/cmd/__tests__/help/WebHelpGenerator.test.ts b/packages/cmd/__tests__/help/WebHelpGenerator.test.ts index 96c153a14..18a153e08 100644 --- a/packages/cmd/__tests__/help/WebHelpGenerator.test.ts +++ b/packages/cmd/__tests__/help/WebHelpGenerator.test.ts @@ -119,12 +119,13 @@ describe("WebHelpGenerator", () => { it("should create Help files", async () => { const cmdResp = new CommandResponse({ silent: false }); + const existsSync = jest.requireActual("fs").existsSync; /* When jenkins machine runs this test as an integration test, * it needs the path to docs to exist, even though Windows does not care. */ const webHelpDocsDirNm = webHelpDirNm + "/docs"; - if (!fs.existsSync(webHelpDocsDirNm)) { + if (!existsSync(webHelpDocsDirNm)) { IO.mkdirp(webHelpDocsDirNm); } @@ -172,13 +173,13 @@ Allowed values: banana, coconut

`https://example.com

`); // do a reasonable set of generated files exist? - expect(fs.existsSync(webHelpDocsDirNm + "/" + moduleFileNm + ".html")).toBe(true); - expect(fs.existsSync(webHelpDocsDirNm + "/" + moduleFileNm + "_config.html")).toBe(true); - expect(fs.existsSync(webHelpDocsDirNm + "/" + moduleFileNm + "_hello_wordWrap.html")).toBe(true); - expect(fs.existsSync(webHelpDocsDirNm + "/" + moduleFileNm + "_hello_universe.html")).toBe(true); - expect(fs.existsSync(webHelpDocsDirNm + "/" + moduleFileNm + "_hello_world.html")).toBe(true); - expect(fs.existsSync(webHelpDocsDirNm + "/" + moduleFileNm + "_plugins_install.html")).toBe(true); - expect(fs.existsSync(webHelpDocsDirNm + "/" + moduleFileNm + "_plugins_uninstall.html")).toBe(true); + expect(existsSync(webHelpDocsDirNm + "/" + moduleFileNm + ".html")).toBe(true); + expect(existsSync(webHelpDocsDirNm + "/" + moduleFileNm + "_config.html")).toBe(true); + expect(existsSync(webHelpDocsDirNm + "/" + moduleFileNm + "_hello_wordWrap.html")).toBe(true); + expect(existsSync(webHelpDocsDirNm + "/" + moduleFileNm + "_hello_universe.html")).toBe(true); + expect(existsSync(webHelpDocsDirNm + "/" + moduleFileNm + "_hello_world.html")).toBe(true); + expect(existsSync(webHelpDocsDirNm + "/" + moduleFileNm + "_plugins_install.html")).toBe(true); + expect(existsSync(webHelpDocsDirNm + "/" + moduleFileNm + "_plugins_uninstall.html")).toBe(true); }); }); }); diff --git a/packages/imperative/__tests__/OverridesLoader.test.ts b/packages/imperative/__tests__/OverridesLoader.test.ts index 67b726652..1bc0f3ae2 100644 --- a/packages/imperative/__tests__/OverridesLoader.test.ts +++ b/packages/imperative/__tests__/OverridesLoader.test.ts @@ -73,7 +73,7 @@ describe("OverridesLoader", () => { const packageJson = { name: "host-package", dependencies: { - keytar: "1.0" + "@zowe/secrets-for-zowe-sdk": "1.0" } }; @@ -98,7 +98,7 @@ describe("OverridesLoader", () => { const packageJson = { name: "host-package", dependencies: { - keytar: "1.0" + "@zowe/secrets-for-zowe-sdk": "1.0" } }; @@ -124,7 +124,7 @@ describe("OverridesLoader", () => { const packageJson = { name: "host-package", dependencies: { - keytar: "1.0" + "@zowe/secrets-for-zowe-sdk": "1.0" } }; @@ -275,7 +275,7 @@ describe("OverridesLoader", () => { // Fake out package.json for the overrides loader const packageJson = { dependencies: { - keytar: "1.0" + "@zowe/secrets-for-zowe-sdk": "1.0" } }; @@ -299,7 +299,7 @@ describe("OverridesLoader", () => { // Fake out package.json for the overrides loader const packageJson = { optionalDependencies: { - keytar: "1.0" + "@zowe/secrets-for-zowe-sdk": "1.0" } }; @@ -323,7 +323,7 @@ describe("OverridesLoader", () => { // Fake out package.json for the overrides loader const packageJson = { dependencies: { - keytar: "1.0" + "@zowe/secrets-for-zowe-sdk": "1.0" } }; diff --git a/packages/imperative/__tests__/config/cmd/convert-profiles/convert-profiles.handler.test.ts b/packages/imperative/__tests__/config/cmd/convert-profiles/convert-profiles.handler.test.ts index 4f8c95ab4..63d61f88d 100644 --- a/packages/imperative/__tests__/config/cmd/convert-profiles/convert-profiles.handler.test.ts +++ b/packages/imperative/__tests__/config/cmd/convert-profiles/convert-profiles.handler.test.ts @@ -11,7 +11,7 @@ import * as fs from "fs"; import * as fsExtra from "fs-extra"; -import * as keytar from "keytar"; +import { keyring as keytar } from "@zowe/secrets-for-zowe-sdk"; import { Config, ConfigBuilder, ConfigSchema } from "../../../../../config"; import { IHandlerParameters } from "../../../../../cmd"; import { ProfileIO } from "../../../../../profiles"; diff --git a/packages/imperative/__tests__/config/cmd/secure/secure.handler.test.ts b/packages/imperative/__tests__/config/cmd/secure/secure.handler.test.ts index 2e2e350ff..03de4eed4 100644 --- a/packages/imperative/__tests__/config/cmd/secure/secure.handler.test.ts +++ b/packages/imperative/__tests__/config/cmd/secure/secure.handler.test.ts @@ -20,15 +20,13 @@ import { expectedConfigObject } from "../../../../../../__tests__/__integration__/imperative/__tests__/__integration__/cli/config/__resources__/expectedObjects"; import SecureHandler from "../../../../src/config/cmd/secure/secure.handler"; import * as config from "../../../../../../__tests__/__integration__/imperative/src/imperative"; -import * as keytar from "keytar"; +import { keyring as keytar } from "@zowe/secrets-for-zowe-sdk"; import * as path from "path"; import * as lodash from "lodash"; import * as fs from "fs"; import { SessConstants } from "../../../../../rest"; import { setupConfigToLoad } from "../../../../../../__tests__/src/TestUtil"; -jest.mock("fs"); - const getIHandlerParametersObject = (): IHandlerParameters => { const x: any = { response: { @@ -106,7 +104,7 @@ describe("Configuration Secure command handler", () => { // Start mocking out some of the credential management functions // Any secure data being loaded will appear to be fakeSecureValue - keytarGetPasswordSpy.mockReturnValue(fakeSecureData); + keytarGetPasswordSpy.mockResolvedValue(fakeSecureData); keytarSetPasswordSpy.mockImplementation(); keytarDeletePasswordSpy.mockImplementation(); diff --git a/packages/imperative/__tests__/config/cmd/set/set.handler.test.ts b/packages/imperative/__tests__/config/cmd/set/set.handler.test.ts index d38e3b821..fbb71d035 100644 --- a/packages/imperative/__tests__/config/cmd/set/set.handler.test.ts +++ b/packages/imperative/__tests__/config/cmd/set/set.handler.test.ts @@ -20,14 +20,12 @@ import { expectedConfigObject, expectedUserConfigObject } from "../../../../../../__tests__/__integration__/imperative/__tests__/__integration__/cli/config/__resources__/expectedObjects"; import SetHandler from "../../../../src/config/cmd/set/set.handler"; import * as config from "../../../../../../__tests__/__integration__/imperative/src/imperative"; -import * as keytar from "keytar"; +import { keyring as keytar } from "@zowe/secrets-for-zowe-sdk"; import * as path from "path"; import * as lodash from "lodash"; import * as fs from "fs"; import { setupConfigToLoad } from "../../../../../../__tests__/src/TestUtil"; -jest.mock("fs"); - const getIHandlerParametersObject = (): IHandlerParameters => { const x: any = { response: { @@ -103,7 +101,7 @@ describe("Configuration Set command handler", () => { // Start mocking out some of the credential management functions // Any secure data being loaded will appear to be fakeSecureValue - keytarGetPasswordSpy.mockReturnValue(fakeSecureData); + keytarGetPasswordSpy.mockResolvedValue(fakeSecureData); keytarSetPasswordSpy.mockImplementation(); keytarDeletePasswordSpy.mockImplementation(); diff --git a/packages/imperative/src/OverridesLoader.ts b/packages/imperative/src/OverridesLoader.ts index 3aae8349e..1e7267544 100644 --- a/packages/imperative/src/OverridesLoader.ts +++ b/packages/imperative/src/OverridesLoader.ts @@ -111,7 +111,9 @@ export class OverridesLoader { * @returns True if DefaultCredentialManager should be used */ private static shouldUseKeytar(packageJson: any, useTeamConfig: boolean): boolean { - return (packageJson.dependencies?.keytar != null || packageJson.optionalDependencies?.keytar != null) && + const deps = packageJson.dependencies ?? {}; + const optionalDeps = packageJson.optionalDependencies ?? {}; + return ("@zowe/secrets-for-zowe-sdk" in deps || "@zowe/secrets-for-zowe-sdk" in optionalDeps) && (!AppSettings.initialized || useTeamConfig || AppSettings.instance.getNamespace("overrides")?.CredentialManager === packageJson.name); } diff --git a/packages/imperative/src/config/cmd/convert-profiles/convert-profiles.handler.ts b/packages/imperative/src/config/cmd/convert-profiles/convert-profiles.handler.ts index dd40646d7..43c7113c2 100644 --- a/packages/imperative/src/config/cmd/convert-profiles/convert-profiles.handler.ts +++ b/packages/imperative/src/config/cmd/convert-profiles/convert-profiles.handler.ts @@ -12,7 +12,7 @@ import * as fs from "fs"; import { removeSync } from "fs-extra"; import * as path from "path"; -import * as keytar from "keytar"; +import { keyring as keytar } from "@zowe/secrets-for-zowe-sdk"; import { ICommandHandler, IHandlerParameters } from "../../../../../cmd"; import { ConfigBuilder, ConfigSchema } from "../../../../../config"; import { ProfileIO, ProfileUtils } from "../../../../../profiles"; @@ -263,8 +263,8 @@ export default class ConvertProfilesHandler implements ICommandHandler { requireOpts.paths = [process.mainModule.filename]; } try { - const keytarPath = require.resolve("keytar", requireOpts); - this.keytar = await import(keytarPath); + const keytarPath = require.resolve("@zowe/secrets-for-zowe-sdk", requireOpts); + this.keytar = (await import(keytarPath)).keyring; await this.keytar.findCredentials(this.ZOWE_CLI_PACKAGE_NAME); success = true; } catch (err) { diff --git a/packages/security/__tests__/DefaultCredentialManager.test.ts b/packages/security/__tests__/DefaultCredentialManager.test.ts index 41ed14f24..ea415ba2a 100644 --- a/packages/security/__tests__/DefaultCredentialManager.test.ts +++ b/packages/security/__tests__/DefaultCredentialManager.test.ts @@ -9,11 +9,11 @@ * */ -jest.mock("keytar"); +jest.mock("@zowe/secrets-for-zowe-sdk"); import * as path from "path"; import { DefaultCredentialManager } from ".."; -import * as keytar from "keytar"; +import { keyring as keytar } from "@zowe/secrets-for-zowe-sdk"; import { ImperativeError } from "../../error"; const winMaxCredentialLength = 2560; @@ -78,7 +78,7 @@ describe("DefaultCredentialManager", () => { const fakeCliPath = "/root/fakeCli"; const mainModule = process.mainModule; process.mainModule = { filename: fakeCliPath } as any; - const pathResolveSpy = jest.spyOn(path, "resolve").mockReturnValue(path.parse(__dirname).root); + const resolveSpy = jest.spyOn(path, "resolve").mockReturnValue(fakeCliPath); // Force enter the try catch Object.defineProperty(manager, "keytar", { @@ -96,7 +96,7 @@ describe("DefaultCredentialManager", () => { expect(error.message).toContain(fakeCliPath); } finally { process.mainModule = mainModule; - pathResolveSpy.mockRestore(); + resolveSpy.mockRestore(); } }); diff --git a/packages/security/src/DefaultCredentialManager.ts b/packages/security/src/DefaultCredentialManager.ts index 926c8cf09..8a2b9e43e 100644 --- a/packages/security/src/DefaultCredentialManager.ts +++ b/packages/security/src/DefaultCredentialManager.ts @@ -13,7 +13,7 @@ import { AbstractCredentialManager, SecureCredential } from "./abstract/Abstract import { ImperativeError } from "../../error"; import { Logger } from "../../logger"; -import * as keytar from "keytar"; // Used for typing purposes only +import { keyring as keytar } from "@zowe/secrets-for-zowe-sdk"; // Used for typing purposes only /** * Default Credential Manager is our implementation of the Imperative Credential Manager. This manager invokes methods @@ -121,11 +121,12 @@ export class DefaultCredentialManager extends AbstractCredentialManager { // within our caller's path. const requireOpts: any = {}; if (process.mainModule?.filename != null) { - requireOpts.paths = [process.mainModule.filename, ...require.resolve.paths("keytar")]; + requireOpts.paths = [process.mainModule.filename, ...require.resolve.paths("@zowe/secrets-for-zowe-sdk")]; } - const keytarPath = require.resolve("keytar", requireOpts); + // use helper function for require.resolve so it can be mocked in jest tests + const keytarPath = require.resolve("@zowe/secrets-for-zowe-sdk", requireOpts); Logger.getImperativeLogger().debug("Loading Keytar module from", keytarPath); - this.keytar = await import(keytarPath); + this.keytar = (await import(keytarPath)).keyring; } catch (error) { this.loadError = new ImperativeError({ msg: `Failed to load Keytar module: ${error.message}`,