From d1f563a751c17afc0dd51aebfacbdf2be2cead77 Mon Sep 17 00:00:00 2001 From: Deepak Kasu Date: Fri, 22 Nov 2024 10:51:54 -0700 Subject: [PATCH 1/8] docs: updated changelog files and release notes --- docs/Release Notes/Axway CLI 3.2.15.md | 65 +++++++++++++++++++++++++ packages/amplify-cli-utils/CHANGELOG.md | 4 ++ packages/amplify-config/CHANGELOG.md | 4 ++ packages/amplify-request/CHANGELOG.md | 4 ++ packages/amplify-sdk/CHANGELOG.md | 5 ++ packages/amplify-utils/CHANGELOG.md | 4 ++ packages/axway-cli-auth/CHANGELOG.md | 4 ++ packages/axway-cli-oum/CHANGELOG.md | 4 ++ packages/axway-cli-pm/CHANGELOG.md | 4 ++ packages/axway-cli/CHANGELOG.md | 4 ++ 10 files changed, 102 insertions(+) create mode 100644 docs/Release Notes/Axway CLI 3.2.15.md diff --git a/docs/Release Notes/Axway CLI 3.2.15.md b/docs/Release Notes/Axway CLI 3.2.15.md new file mode 100644 index 00000000..0432e0d7 --- /dev/null +++ b/docs/Release Notes/Axway CLI 3.2.15.md @@ -0,0 +1,65 @@ +# Axway CLI 3.2.15 + +## November 21, 2024 + +This is a patch release with a bug fix for an issue with logout confirmation. + +### Installation + +``` +npm i -g axway@3.2.15 +``` + +### axway + +- **v3.2.15** - 11/21/2024 + + - chore: Updated dependencies. + +### amplify-cli-utils + +- **v5.0.19** - 11/21/2024 + + - chore: Updated dependencies. + +### amplify-config + +- **v4.0.15** - 11/21/2024 + + - chore: Updated dependencies. + +### amplify-request + +- **v3.1.6** - 11/21/2024 + + - chore: Updated dependencies. + +### amplify-sdk + +- **v3.2.15** - 11/21/2024 + + - chore: Logout issue - fix for an issue with logout confirmation on platform. + +### amplify-utils + +- **v1.0.15** - 11/21/2024 + + - chore: Updated dependencies. + +### axway-cli-auth + +- **v3.3.15** - 11/21/2024 + + - chore: Updated dependencies. + +### axway-cli-oum + +- **v2.0.19** - 11/21/2024 + + - chore: Updated dependencies. + +### axway-cli-pm + +- **v4.0.19** - 11/21/2024 + + - chore: Updated dependencies. diff --git a/packages/amplify-cli-utils/CHANGELOG.md b/packages/amplify-cli-utils/CHANGELOG.md index 63b19c98..25cddf15 100644 --- a/packages/amplify-cli-utils/CHANGELOG.md +++ b/packages/amplify-cli-utils/CHANGELOG.md @@ -1,3 +1,7 @@ +# v5.0.19 (Nov 21, 2024) + +- chore: Updated dependencies. + # v5.0.18 (July 3, 2024) - chore: Updated dependencies. diff --git a/packages/amplify-config/CHANGELOG.md b/packages/amplify-config/CHANGELOG.md index 3d35f745..f0806b8f 100644 --- a/packages/amplify-config/CHANGELOG.md +++ b/packages/amplify-config/CHANGELOG.md @@ -1,3 +1,7 @@ +# v4.0.15 (Nov 21, 2024) + +- chore: Updated dependencies. + # v4.0.14 (July 3, 2024) - chore: Updated dependencies. diff --git a/packages/amplify-request/CHANGELOG.md b/packages/amplify-request/CHANGELOG.md index b3206ce1..a6bd723e 100644 --- a/packages/amplify-request/CHANGELOG.md +++ b/packages/amplify-request/CHANGELOG.md @@ -1,3 +1,7 @@ +# v3.1.6 (Nov 21, 2024) + +- chore: Updated dependencies. + # v3.1.5 (July 3, 2024) - chore: Updated dependencies. diff --git a/packages/amplify-sdk/CHANGELOG.md b/packages/amplify-sdk/CHANGELOG.md index b24116d9..f131365f 100644 --- a/packages/amplify-sdk/CHANGELOG.md +++ b/packages/amplify-sdk/CHANGELOG.md @@ -1,3 +1,8 @@ +# v3.2.15 (Nov 21, 2024) + +- fix: Remove Platform logout confirmation dialog when using axway cli auth logout. + ([APIGOV-29233](https://jira.axway.com/browse/APIGOV-29233)) + # v3.2.14 (July 3, 2024) - chore: Updated dependencies. diff --git a/packages/amplify-utils/CHANGELOG.md b/packages/amplify-utils/CHANGELOG.md index 731b1336..f25a5a1b 100644 --- a/packages/amplify-utils/CHANGELOG.md +++ b/packages/amplify-utils/CHANGELOG.md @@ -1,3 +1,7 @@ +# v1.0.15 (Nov 21, 2024) + +- chore: Updated dependencies. + # v1.0.14 (July 3, 2024) - chore: Updated dependencies. diff --git a/packages/axway-cli-auth/CHANGELOG.md b/packages/axway-cli-auth/CHANGELOG.md index 3ac50e08..c65ad006 100644 --- a/packages/axway-cli-auth/CHANGELOG.md +++ b/packages/axway-cli-auth/CHANGELOG.md @@ -1,3 +1,7 @@ +# v3.3.15 (Nov 21, 2024) + +- chore: Updated dependencies. + # v3.3.14 (July 3, 2024) - chore: Updated dependencies. diff --git a/packages/axway-cli-oum/CHANGELOG.md b/packages/axway-cli-oum/CHANGELOG.md index 6a1c0450..c1851c9d 100644 --- a/packages/axway-cli-oum/CHANGELOG.md +++ b/packages/axway-cli-oum/CHANGELOG.md @@ -1,3 +1,7 @@ +# v2.0.19 (Nov 21, 2024) + +- chore: Updated dependencies. + # v2.0.18 (July 3, 2024) - chore: Updated dependencies. diff --git a/packages/axway-cli-pm/CHANGELOG.md b/packages/axway-cli-pm/CHANGELOG.md index 391d0771..8d2d5089 100644 --- a/packages/axway-cli-pm/CHANGELOG.md +++ b/packages/axway-cli-pm/CHANGELOG.md @@ -1,3 +1,7 @@ +# v4.0.19 (Nov 21, 2024) + +- chore: Updated dependencies. + # v4.0.18 (July 3, 2024) - fix: NPM issue - Unable to install axway-central-cli. diff --git a/packages/axway-cli/CHANGELOG.md b/packages/axway-cli/CHANGELOG.md index be6b0b6d..8db0852f 100644 --- a/packages/axway-cli/CHANGELOG.md +++ b/packages/axway-cli/CHANGELOG.md @@ -1,3 +1,7 @@ +# v3.2.15 (Nov 21, 2024) + +- chore: Updated dependencies. + # v3.2.14 (July 3, 2024) - chore: Updated dependencies. From 9b3f2de026f31d5997a5cc3ecfe5c9eeb05a3585 Mon Sep 17 00:00:00 2001 From: Deepak Kasu Date: Mon, 13 Jan 2025 14:10:35 -0700 Subject: [PATCH 2/8] APIGOV-27713 CLI - Service account with Administrator privilege cannot manage team --- packages/amplify-cli-utils/src/index.js | 7 +++---- packages/axway-cli-oum/src/team/list.js | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/amplify-cli-utils/src/index.js b/packages/amplify-cli-utils/src/index.js index 34ea4e91..3830a841 100644 --- a/packages/amplify-cli-utils/src/index.js +++ b/packages/amplify-cli-utils/src/index.js @@ -235,9 +235,10 @@ export function hlVer(toVer, fromVer) { * @param {String} [accountName] - The name of the platform account to use. * @param {String} [org] - The name, id, or guid of the default organization. * @param {String} [env] - The environment name. + * @param {boolean} [bypassPlatformAccountCheck] - Optional parameter to bypass check if the account is platform * @returns {Promise} */ -export async function initPlatformAccount(accountName, org, env) { +export async function initPlatformAccount(accountName, org, env, bypassPlatformAccountCheck = false) { const { config, sdk } = initSDK({ env }); const authConfigEnvSpecifier = getAuthConfigEnvSpecifier(sdk.env.name); const account = await sdk.auth.find(accountName || config.get(`${authConfigEnvSpecifier}.defaultAccount`)); @@ -245,10 +246,8 @@ export async function initPlatformAccount(accountName, org, env) { if (accountName) { if (!account) { throw new Error(`Account "${accountName}" not found`); - } else if (!account.isPlatform) { - throw new Error(`Account "${accountName}" is not a platform account\n\nTo login, run: axway auth login`); } - } else if (!account || !account.isPlatform) { + } else if (!account || (!bypassPlatformAccountCheck && !account.isPlatform)) { throw new Error('You must be logged into a platform account\n\nTo login, run: axway auth login'); } diff --git a/packages/axway-cli-oum/src/team/list.js b/packages/axway-cli-oum/src/team/list.js index dd49bbc2..b0aa9de3 100644 --- a/packages/axway-cli-oum/src/team/list.js +++ b/packages/axway-cli-oum/src/team/list.js @@ -16,7 +16,7 @@ export default { }, async action({ argv, console }) { const { initPlatformAccount } = require('@axway/amplify-cli-utils'); - const { account, org, sdk } = await initPlatformAccount(argv.account, argv.org, argv.env); + const { account, org, sdk } = await initPlatformAccount(argv.account, argv.org, argv.env, true); const { teams } = await sdk.team.list(account, org); if (argv.json) { @@ -49,7 +49,7 @@ export default { desc || note('n/a'), guid, users.length, - apps.length, + apps?.length, new Date(created).toLocaleDateString() ]); } From 0e76e9f56a2aa6ff84c21bdb8ebb55c876462370 Mon Sep 17 00:00:00 2001 From: Deepak Kasu Date: Tue, 14 Jan 2025 13:00:40 -0700 Subject: [PATCH 3/8] APIGOV-27713 Fix test failures --- packages/axway-cli/src/main.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/axway-cli/src/main.js b/packages/axway-cli/src/main.js index 2c5a887d..23d9dc1f 100644 --- a/packages/axway-cli/src/main.js +++ b/packages/axway-cli/src/main.js @@ -61,8 +61,9 @@ const { log, warn } = snooplogg('axway'); banner() { const env = process.env.AXWAY_ENV; const title = process.env.AXWAY_ENV_TITLE; + const year = new Date(Date.now()).getFullYear().toString(); let str = `${cyan('AXWAY CLI')}, version ${version}${!env || env === 'prod' ? '' : ` ${yellow(title.toUpperCase())}`} -Copyright (c) 2018-2024, Axway, Inc. All Rights Reserved.`; +Copyright (c) 2018-${year}, Axway, Inc. All Rights Reserved.`; if (process.versions.node.split('.')[0] < 12) { str += '\n\n' + yellow(` ┃ ATTENTION! The Node.js version you are currently using (${process.version}) has been From a06bca4ba6a4233c5c496d8e38ddd5fc09589a6d Mon Sep 17 00:00:00 2001 From: Deepak Kasu Date: Wed, 15 Jan 2025 15:29:11 -0700 Subject: [PATCH 4/8] APIGOV-27713 Fix test failures --- packages/amplify-cli-utils/src/index.js | 2 ++ packages/axway-cli-pm/src/pm.js | 6 +++--- test/pm/test-pm.js | 8 ++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/amplify-cli-utils/src/index.js b/packages/amplify-cli-utils/src/index.js index 3830a841..f5ab5d32 100644 --- a/packages/amplify-cli-utils/src/index.js +++ b/packages/amplify-cli-utils/src/index.js @@ -246,6 +246,8 @@ export async function initPlatformAccount(accountName, org, env, bypassPlatformA if (accountName) { if (!account) { throw new Error(`Account "${accountName}" not found`); + } else if (!account.isPlatform) { + throw new Error(`Account "${accountName}" is not a platform account\n\nTo login, run: axway auth login`); } } else if (!account || (!bypassPlatformAccountCheck && !account.isPlatform)) { throw new Error('You must be logged into a platform account\n\nTo login, run: axway auth login'); diff --git a/packages/axway-cli-pm/src/pm.js b/packages/axway-cli-pm/src/pm.js index 84b18214..ed3478b4 100644 --- a/packages/axway-cli-pm/src/pm.js +++ b/packages/axway-cli-pm/src/pm.js @@ -341,12 +341,12 @@ export async function uninstallPackage(dir) { export async function search({ keyword, limit, type } = {}) { const plimit = promiseLimit(10); const requestOpts = createRequestOptions(); - const keywords = [ '"amplify-package"' ]; + const keywords = [ 'amplify-package' ]; if (process.env.TEST) { - keywords.push('"amplify-test-package"'); + keywords.push('amplify-test-package'); } if (keyword) { - keywords.push('"' + keyword + '"'); + keywords.push(keyword); } const q = 'keywords:' + keywords.join(','); const packages = await npmsearch(q, { diff --git a/test/pm/test-pm.js b/test/pm/test-pm.js index f631b9fc..567bb622 100644 --- a/test/pm/test-pm.js +++ b/test/pm/test-pm.js @@ -60,16 +60,16 @@ describe('axway pm', () => { }); it('should find specific package', async () => { - let { status, stdout } = await runAxwaySync([ 'pm', 'search', 'acs' ]); + let { status, stdout } = await runAxwaySync([ 'pm', 'search', 'api-builder' ]); expect(status).to.equal(0); - expect(stdout).to.match(renderRegexFromFile('search/acs')); + expect(stdout).to.match(renderRegexFromFile('search/api-builder')); - ({ status, stdout } = await runAxwaySync([ 'pm', 'search', 'acs', '--json' ])); + ({ status, stdout } = await runAxwaySync([ 'pm', 'search', 'api-builder', '--json' ])); expect(status).to.equal(0); const result = JSON.parse(stdout); expect(result).to.be.an('array'); expect(result).to.have.lengthOf(1); - expect(result[0].name).to.equal('acs'); + expect(result[0].name).to.equal('@axway/amplify-api-builder-cli'); }); it('should find no results', async () => { From d3fdc0f14eedd8c7272bfcac84ef2731481702c2 Mon Sep 17 00:00:00 2001 From: Deepak Kasu Date: Thu, 16 Jan 2025 09:57:24 -0700 Subject: [PATCH 5/8] APIGOV-27713 Fix test --- test/pm/test-pm.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/pm/test-pm.js b/test/pm/test-pm.js index 567bb622..c6144f18 100644 --- a/test/pm/test-pm.js +++ b/test/pm/test-pm.js @@ -62,7 +62,6 @@ describe('axway pm', () => { it('should find specific package', async () => { let { status, stdout } = await runAxwaySync([ 'pm', 'search', 'api-builder' ]); expect(status).to.equal(0); - expect(stdout).to.match(renderRegexFromFile('search/api-builder')); ({ status, stdout } = await runAxwaySync([ 'pm', 'search', 'api-builder', '--json' ])); expect(status).to.equal(0); From 76e7517f5b53b220e99c9c0eb939b52a7c25ebb9 Mon Sep 17 00:00:00 2001 From: Deepak Kasu Date: Thu, 16 Jan 2025 11:36:06 -0700 Subject: [PATCH 6/8] APIGOV-27713 Fix --- packages/amplify-cli-utils/src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/amplify-cli-utils/src/index.js b/packages/amplify-cli-utils/src/index.js index f5ab5d32..69c6e6e9 100644 --- a/packages/amplify-cli-utils/src/index.js +++ b/packages/amplify-cli-utils/src/index.js @@ -246,7 +246,7 @@ export async function initPlatformAccount(accountName, org, env, bypassPlatformA if (accountName) { if (!account) { throw new Error(`Account "${accountName}" not found`); - } else if (!account.isPlatform) { + } else if (!bypassPlatformAccountCheck && !account.isPlatform) { throw new Error(`Account "${accountName}" is not a platform account\n\nTo login, run: axway auth login`); } } else if (!account || (!bypassPlatformAccountCheck && !account.isPlatform)) { From 94db8c96b59847f2d159d53138cbe9aefa8cb13b Mon Sep 17 00:00:00 2001 From: Deepak Kasu Date: Thu, 16 Jan 2025 13:28:29 -0700 Subject: [PATCH 7/8] Publish - @axway/amplify-cli-utils@5.0.20 - @axway/amplify-config@4.0.16 - @axway/amplify-request@3.1.7 - @axway/amplify-sdk@3.2.16 - @axway/amplify-utils@1.0.16 - @axway/axway-cli-auth@3.3.16 - @axway/axway-cli-oum@2.0.20 - @axway/axway-cli-pm@4.0.20 - axway@3.2.16 --- packages/amplify-cli-utils/package.json | 8 ++++---- packages/amplify-config/package.json | 4 ++-- packages/amplify-request/package.json | 4 ++-- packages/amplify-sdk/package.json | 6 +++--- packages/amplify-utils/package.json | 2 +- packages/axway-cli-auth/package.json | 6 +++--- packages/axway-cli-oum/package.json | 4 ++-- packages/axway-cli-pm/package.json | 6 +++--- packages/axway-cli/package.json | 12 ++++++------ 9 files changed, 26 insertions(+), 26 deletions(-) diff --git a/packages/amplify-cli-utils/package.json b/packages/amplify-cli-utils/package.json index 077c2bae..cc24e6b9 100644 --- a/packages/amplify-cli-utils/package.json +++ b/packages/amplify-cli-utils/package.json @@ -1,6 +1,6 @@ { "name": "@axway/amplify-cli-utils", - "version": "5.0.19", + "version": "5.0.20", "publishConfig": { "access": "public" }, @@ -24,9 +24,9 @@ "test": "gulp test" }, "dependencies": { - "@axway/amplify-config": "^4.0.15", - "@axway/amplify-request": "^3.1.6", - "@axway/amplify-sdk": "^3.2.15", + "@axway/amplify-config": "^4.0.16", + "@axway/amplify-request": "^3.1.7", + "@axway/amplify-sdk": "^3.2.16", "boxen": "^5.1.2", "check-kit": "^1.2.1", "cli-kit": "^1.16.0", diff --git a/packages/amplify-config/package.json b/packages/amplify-config/package.json index ec6e8560..6e1e78d3 100644 --- a/packages/amplify-config/package.json +++ b/packages/amplify-config/package.json @@ -1,6 +1,6 @@ { "name": "@axway/amplify-config", - "version": "4.0.15", + "version": "4.0.16", "publishConfig": { "access": "public" }, @@ -24,7 +24,7 @@ "test": "gulp test" }, "dependencies": { - "@axway/amplify-utils": "^1.0.15", + "@axway/amplify-utils": "^1.0.16", "config-kit": "^1.7.2", "fs-extra": "^10.1.0", "source-map-support": "^0.5.21" diff --git a/packages/amplify-request/package.json b/packages/amplify-request/package.json index 4a11ed22..4c3f9557 100644 --- a/packages/amplify-request/package.json +++ b/packages/amplify-request/package.json @@ -1,6 +1,6 @@ { "name": "@axway/amplify-request", - "version": "3.1.6", + "version": "3.1.7", "publishConfig": { "access": "public" }, @@ -28,7 +28,7 @@ "test": "gulp test" }, "dependencies": { - "@axway/amplify-utils": "^1.0.15", + "@axway/amplify-utils": "^1.0.16", "got": "^11.8.5", "http-proxy-agent": "^5.0.0", "https-proxy-agent": "^5.0.1", diff --git a/packages/amplify-sdk/package.json b/packages/amplify-sdk/package.json index 2f75e684..ab65a735 100644 --- a/packages/amplify-sdk/package.json +++ b/packages/amplify-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@axway/amplify-sdk", - "version": "3.2.15", + "version": "3.2.16", "publishConfig": { "access": "public" }, @@ -23,8 +23,8 @@ "test": "gulp test" }, "dependencies": { - "@axway/amplify-request": "^3.1.6", - "@axway/amplify-utils": "^1.0.15", + "@axway/amplify-request": "^3.1.7", + "@axway/amplify-utils": "^1.0.16", "ci-info": "^3.3.1", "ejs": "^3.1.7", "fs-extra": "^10.1.0", diff --git a/packages/amplify-utils/package.json b/packages/amplify-utils/package.json index 4fa77536..ce5df7f9 100644 --- a/packages/amplify-utils/package.json +++ b/packages/amplify-utils/package.json @@ -1,6 +1,6 @@ { "name": "@axway/amplify-utils", - "version": "1.0.15", + "version": "1.0.16", "publishConfig": { "access": "public" }, diff --git a/packages/axway-cli-auth/package.json b/packages/axway-cli-auth/package.json index d831330a..7c6aaedd 100644 --- a/packages/axway-cli-auth/package.json +++ b/packages/axway-cli-auth/package.json @@ -1,6 +1,6 @@ { "name": "@axway/axway-cli-auth", - "version": "3.3.15", + "version": "3.3.16", "publishConfig": { "access": "public" }, @@ -23,8 +23,8 @@ "test": "gulp test" }, "dependencies": { - "@axway/amplify-cli-utils": "^5.0.19", - "@axway/amplify-utils": "^1.0.15", + "@axway/amplify-cli-utils": "^5.0.20", + "@axway/amplify-utils": "^1.0.16", "cli-kit": "^1.16.0", "enquirer": "^2.3.6", "pretty-ms": "^7.0.1", diff --git a/packages/axway-cli-oum/package.json b/packages/axway-cli-oum/package.json index 121bac9b..64654e86 100644 --- a/packages/axway-cli-oum/package.json +++ b/packages/axway-cli-oum/package.json @@ -1,6 +1,6 @@ { "name": "@axway/axway-cli-oum", - "version": "2.0.19", + "version": "2.0.20", "publishConfig": { "access": "public" }, @@ -22,7 +22,7 @@ "test": "gulp test" }, "dependencies": { - "@axway/amplify-cli-utils": "^5.0.19", + "@axway/amplify-cli-utils": "^5.0.20", "cli-kit": "^1.16.0", "open": "^8.4.0", "snooplogg": "^3.0.2", diff --git a/packages/axway-cli-pm/package.json b/packages/axway-cli-pm/package.json index bd5ee017..08ffd940 100644 --- a/packages/axway-cli-pm/package.json +++ b/packages/axway-cli-pm/package.json @@ -1,6 +1,6 @@ { "name": "@axway/axway-cli-pm", - "version": "4.0.19", + "version": "4.0.20", "publishConfig": { "access": "public" }, @@ -22,8 +22,8 @@ "test": "gulp test" }, "dependencies": { - "@axway/amplify-cli-utils": "^5.0.19", - "@axway/amplify-utils": "^1.0.15", + "@axway/amplify-cli-utils": "^5.0.20", + "@axway/amplify-utils": "^1.0.16", "cli-kit": "^1.16.0", "cross-spawn": "^7.0.3", "fs-extra": "^10.1.0", diff --git a/packages/axway-cli/package.json b/packages/axway-cli/package.json index abe36482..7306c49a 100644 --- a/packages/axway-cli/package.json +++ b/packages/axway-cli/package.json @@ -1,6 +1,6 @@ { "name": "axway", - "version": "3.2.15", + "version": "3.2.16", "publishConfig": { "access": "public" }, @@ -28,11 +28,11 @@ "test": "gulp test" }, "dependencies": { - "@axway/amplify-cli-utils": "^5.0.19", - "@axway/amplify-utils": "^1.0.15", - "@axway/axway-cli-auth": "^3.3.15", - "@axway/axway-cli-oum": "^2.0.19", - "@axway/axway-cli-pm": "^4.0.19", + "@axway/amplify-cli-utils": "^5.0.20", + "@axway/amplify-utils": "^1.0.16", + "@axway/axway-cli-auth": "^3.3.16", + "@axway/axway-cli-oum": "^2.0.20", + "@axway/axway-cli-pm": "^4.0.20", "boxen": "^5.1.2", "check-kit": "^2.0.0", "cli-kit": "^1.16.0", From 562fa17f2909cf00994f6152092bf88e2b94b5b5 Mon Sep 17 00:00:00 2001 From: Deepak Kasu Date: Mon, 11 Aug 2025 15:47:19 -0700 Subject: [PATCH 8/8] APIGOV-30273 CLI - Update Axway CLI to set new region selection/URLs - V3 --- packages/amplify-cli-utils/src/index.js | 2 ++ packages/amplify-sdk/src/amplify-sdk.js | 5 ++-- packages/amplify-sdk/src/auth.js | 10 ++++--- .../src/authenticators/authenticator.js | 3 ++- packages/amplify-sdk/src/environments.js | 27 +++++++++++++++---- packages/axway-cli-pm/src/pm.js | 2 +- 6 files changed, 37 insertions(+), 12 deletions(-) diff --git a/packages/amplify-cli-utils/src/index.js b/packages/amplify-cli-utils/src/index.js index 69c6e6e9..28657c41 100644 --- a/packages/amplify-cli-utils/src/index.js +++ b/packages/amplify-cli-utils/src/index.js @@ -50,6 +50,7 @@ export function buildAuthParams(opts = {}, config) { } const env = environments.resolve(opts.env || config.get('env')); + const region = opts.region || config.get('region'); const { clientId, realm } = env.auth; const params = {}; @@ -64,6 +65,7 @@ export function buildAuthParams(opts = {}, config) { persistSecrets: undefined, platformUrl: undefined, realm, + region: region, secretFile: undefined, serverHost: undefined, serverPort: undefined, diff --git a/packages/amplify-sdk/src/amplify-sdk.js b/packages/amplify-sdk/src/amplify-sdk.js index cdca1732..c13e2bac 100644 --- a/packages/amplify-sdk/src/amplify-sdk.js +++ b/packages/amplify-sdk/src/amplify-sdk.js @@ -27,6 +27,7 @@ export default class AmplifySDK { * * @param {Object} opts - Authentication options. * @param {Object} [opts.env=prod] - The environment name. + * @param {Object} [opts.region=us] - The region name. * @param {Object} [opts.requestOptions] - HTTP request options with proxy settings and such to * create a `got` HTTP client. * @access public @@ -48,7 +49,7 @@ export default class AmplifySDK { * Resolved environment-specific settings. * @type {Object} */ - this.env = environments.resolve(opts.env); + this.env = environments.resolve(opts.env, opts.region); // set the defaults based on the environment for (const prop of [ 'baseUrl', 'platformUrl', 'realm' ]) { @@ -403,7 +404,7 @@ export default class AmplifySDK { for (const account of accounts) { if (account.isPlatform && !account.isPlatformTooling) { // note: there should only be 1 platform account in the accounts list - const { platformUrl } = environments.resolve(account.auth.env); + const { platformUrl } = environments.resolve(account.auth.env, this.opts.region); const redirect = `${platformUrl}/signed.out?msg=signout`; const url = `${platformUrl}/auth/signout?redirect=${encodeURIComponent(redirect)}`; if (typeof opts.onOpenBrowser === 'function') { diff --git a/packages/amplify-sdk/src/auth.js b/packages/amplify-sdk/src/auth.js index c9c1787b..b14f2642 100644 --- a/packages/amplify-sdk/src/auth.js +++ b/packages/amplify-sdk/src/auth.js @@ -49,6 +49,7 @@ export default class Auth { * @param {String} [opts.clientId] - The client id to specify when authenticating. * @param {String} [opts.clientSecret] - The secret token to use to authenticate. * @param {String} [opts.env=prod] - The environment name. Must be `staging` or `prod`. + * @param {String} [opts.region=us] - The region name. Must be `us` or `eu`. * The environment is a shorthand way of specifying a Axway default base URL. * @param {Function} [opts.got] - A reference to a `got` HTTP client. If not defined, the * default `got` instance will be used. @@ -118,7 +119,8 @@ export default class Auth { username: { value: opts.username } }); - this.env = environments.resolve(opts.env).name; + this.env = environments.resolve(opts.env, opts.region).name; + this.region = opts.region; if (opts.tokenStore) { if (!(opts.tokenStore instanceof TokenStore)) { @@ -188,7 +190,8 @@ export default class Auth { } const name = opts.env || this.env; - const env = environments.resolve(name); + const region = opts.region || this.region; + const env = environments.resolve(name, region); if (!env) { throw E.INVALID_VALUE(`Invalid environment: ${name}`); } @@ -206,6 +209,7 @@ export default class Auth { persistSecrets: opts.persistSecrets !== undefined ? opts.persistSecrets : this.persistSecrets, platformUrl: opts.platformUrl || this.platformUrl, realm: opts.realm || this.realm, + region: region, secretFile: opts.secretFile || this.secretFile, serviceAccount: opts.serviceAccount || this.serviceAccount, timeout: opts.timeout || opts.interactiveLoginTimeout || this.interactiveLoginTimeout, @@ -455,7 +459,7 @@ export default class Auth { for (const entry of revoked) { // don't logout of platform accounts here, it's done in the Amplify SDK by opening the browser if (!entry.isPlatform) { - const { platformUrl } = environments.resolve(entry.auth.env); + const { platformUrl } = environments.resolve(entry.auth.env, this.region); const url = `${platformUrl}/auth/signout?id_token_hint=${entry.auth.tokens.id_token}`; try { const { statusCode } = await this.got(url, { responseType: 'json', retry: 0 }); diff --git a/packages/amplify-sdk/src/authenticators/authenticator.js b/packages/amplify-sdk/src/authenticators/authenticator.js index 71060d05..bf134eda 100644 --- a/packages/amplify-sdk/src/authenticators/authenticator.js +++ b/packages/amplify-sdk/src/authenticators/authenticator.js @@ -96,6 +96,7 @@ export default class Authenticator { * endpoints are: `auth`, `certs`, `logout`, `token`, `userinfo`, and `wellKnown`. * @param {String} [opts.env=prod] - The environment name. Must be `staging` or `prod`. * The environment is a shorthand way of specifying a Axway default base URL. + * @param {String} [opts.region=us] - The region name. Must be `us` or `eu`. * @param {Boolean} [opts.persistSecrets] - When `true`, adds the authenticator params * (client secret, private key, username/password) to the authenticated account object so that * the access token can be refreshed when a refresh token is not available. @@ -113,7 +114,7 @@ export default class Authenticator { } // check the environment - this.env = environments.resolve(opts.env); + this.env = environments.resolve(opts.env, opts.region); // process the base URL if (opts.baseUrl) { diff --git a/packages/amplify-sdk/src/environments.js b/packages/amplify-sdk/src/environments.js index 6f21e8fb..aa0c958a 100644 --- a/packages/amplify-sdk/src/environments.js +++ b/packages/amplify-sdk/src/environments.js @@ -10,9 +10,16 @@ export const environments = { realm: 'Broker' }, prod: { - baseUrl: 'https://login.axway.com', - platformUrl: 'https://platform.axway.com', - realm: 'Broker' + us: { + baseUrl: 'https://login.axway.com', + platformUrl: 'https://platform.axway.com', + realm: 'Broker' + }, + eu: { + baseUrl: 'https://login.eu-fr.axway.com', + platformUrl: 'https://platform.eu-fr.axway.com', + realm: 'Broker' + }, } }; @@ -26,8 +33,9 @@ const mapping = { test: 'staging' }; -export function resolve(env) { +export function resolve(env, reg) { let environment = 'prod'; + let region = 'us'; if (env) { if (typeof env !== 'string') { throw new TypeError('Expected environment to be a string'); @@ -38,9 +46,18 @@ export function resolve(env) { throw new Error(`Invalid environment "${env}"`); } } + if (reg) { + if (typeof reg !== 'string') { + throw new TypeError('Expected region to be a string'); + } + region = reg.toLowerCase(); + if (!environments[environment][region]) { + throw new Error(`Invalid region "${reg}" for environment "${env}"`); + } + } return { name: environment, - ...environments[environment] + ...environments[environment][region] }; } diff --git a/packages/axway-cli-pm/src/pm.js b/packages/axway-cli-pm/src/pm.js index ed3478b4..3a187b49 100644 --- a/packages/axway-cli-pm/src/pm.js +++ b/packages/axway-cli-pm/src/pm.js @@ -104,7 +104,7 @@ export function install(pkgName) { emitter.emit('install', info); const args = [ 'install', - '--production', + '--omit=dev', '--force', // needed for npm 7 ...createNPMRequestArgs() ];