From b6211bb1bdccfc0089936b6d38f292c781020d0f Mon Sep 17 00:00:00 2001 From: Jared Perreault Date: Mon, 18 Sep 2023 16:47:38 -0400 Subject: [PATCH 1/6] test --- lib/idx/flow/FlowSpecification.ts | 8 +++++++- lib/idx/run.ts | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/idx/flow/FlowSpecification.ts b/lib/idx/flow/FlowSpecification.ts index 06d6229ac..06f5f3b5c 100644 --- a/lib/idx/flow/FlowSpecification.ts +++ b/lib/idx/flow/FlowSpecification.ts @@ -15,7 +15,8 @@ export interface FlowSpecification { // eslint-disable-next-line complexity export function getFlowSpecification( oktaAuth: OktaAuthIdxInterface, - flow: FlowIdentifier = 'default' + flow: FlowIdentifier = 'default', + useGenericRemediation: boolean = false ): FlowSpecification { let remediators, actions, withCredentials = true; switch (flow) { @@ -23,6 +24,11 @@ export function getFlowSpecification( case 'signup': case 'enrollProfile': remediators = RegistrationFlow; + if (useGenericRemediation) { + actions = [ + 'select-enroll-profile' + ]; + } withCredentials = false; break; case 'recoverPassword': diff --git a/lib/idx/run.ts b/lib/idx/run.ts index b7550ce00..49aa20aa5 100644 --- a/lib/idx/run.ts +++ b/lib/idx/run.ts @@ -81,6 +81,7 @@ function initializeData(authClient, data: RunData): RunData { withCredentials, remediators, actions, + useGenericRemediator } = options; const status = IdxStatus.PENDING; @@ -89,7 +90,7 @@ function initializeData(authClient, data: RunData): RunData { flow = flow || authClient.idx.getFlow() || 'default'; if (flow) { authClient.idx.setFlow(flow); - const flowSpec = getFlowSpecification(authClient, flow); + const flowSpec = getFlowSpecification(authClient, flow, useGenericRemediator); // Favor option values over flow spec withCredentials = (typeof withCredentials !== 'undefined') ? withCredentials : flowSpec.withCredentials; remediators = remediators || flowSpec.remediators; From 13b9206bcffa79752c05f637552fa483ea25b881 Mon Sep 17 00:00:00 2001 From: Jared Perreault Date: Mon, 18 Sep 2023 16:51:35 -0400 Subject: [PATCH 2/6] test --- scripts/publish.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/publish.sh b/scripts/publish.sh index c730a65f1..462464d16 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -1,4 +1,4 @@ -#!/bin/bash -xe +#!/bin/bash -e source ${OKTA_HOME}/${REPO}/scripts/setup.sh From 8f8052cd817b0666ed4d2215a018c891caebc843 Mon Sep 17 00:00:00 2001 From: Jared Perreault Date: Mon, 18 Sep 2023 16:54:11 -0400 Subject: [PATCH 3/6] test --- scripts/publish.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/publish.sh b/scripts/publish.sh index 462464d16..cde5e5a94 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -1,4 +1,4 @@ -#!/bin/bash -e +#!/bin/bash -x source ${OKTA_HOME}/${REPO}/scripts/setup.sh From f6d0c33745ea3bec80041a4877267e59fbe8fe22 Mon Sep 17 00:00:00 2001 From: Jared Perreault Date: Tue, 19 Sep 2023 08:12:20 -0400 Subject: [PATCH 4/6] fixes tests --- lib/idx/flow/FlowSpecification.ts | 2 +- test/spec/idx/run.ts | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/idx/flow/FlowSpecification.ts b/lib/idx/flow/FlowSpecification.ts index 06f5f3b5c..0f558f3f9 100644 --- a/lib/idx/flow/FlowSpecification.ts +++ b/lib/idx/flow/FlowSpecification.ts @@ -16,7 +16,7 @@ export interface FlowSpecification { export function getFlowSpecification( oktaAuth: OktaAuthIdxInterface, flow: FlowIdentifier = 'default', - useGenericRemediation: boolean = false + useGenericRemediation = false ): FlowSpecification { let remediators, actions, withCredentials = true; switch (flow) { diff --git a/test/spec/idx/run.ts b/test/spec/idx/run.ts index 15584e85f..ff818a7c8 100644 --- a/test/spec/idx/run.ts +++ b/test/spec/idx/run.ts @@ -156,7 +156,7 @@ describe('idx/run', () => { const { authClient } = testContext; jest.spyOn(mocked.FlowSpecification, 'getFlowSpecification'); await run(authClient, { flow: 'signup' }); - expect(mocked.FlowSpecification.getFlowSpecification).toHaveBeenCalledWith(authClient, 'signup'); + expect(mocked.FlowSpecification.getFlowSpecification).toHaveBeenCalledWith(authClient, 'signup', undefined); }); }); @@ -232,8 +232,9 @@ describe('idx/run', () => { password, stateHandle: idxResponse.rawIdxState.stateHandle }; - const flowSpec = mocked.FlowSpecification.getFlowSpecification(authClient, flow); + const flowSpec = mocked.FlowSpecification.getFlowSpecification(authClient, flow, options.useGenericRemediator); const { remediators, actions, flowMonitor } = flowSpec; + expect(actions).toEqual(['select-enroll-profile']); // GenericRemediator now returns register as action await run(authClient, options); expect(mocked.remediate.remediate).toHaveBeenCalledWith(authClient, idxResponse, values, { remediators, @@ -267,7 +268,7 @@ describe('idx/run', () => { password, stateHandle: idxResponse.rawIdxState.stateHandle }; - const flowSpec = mocked.FlowSpecification.getFlowSpecification(authClient, flow); + const flowSpec = mocked.FlowSpecification.getFlowSpecification(authClient, flow, true); const { remediators, actions, flowMonitor } = flowSpec; await run(authClient, options); expect(mocked.remediate.remediate).toHaveBeenCalledWith(authClient, idxResponse, values, { From 914d2f83b0ac0e253ba25a5715dad2a20e99527c Mon Sep 17 00:00:00 2001 From: Jared Perreault Date: Tue, 19 Sep 2023 08:14:33 -0400 Subject: [PATCH 5/6] version bump --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2dc2f6cc9..7c884649c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 7.4.3 + +- [#1457](https://github.com/okta/okta-auth-js/pull/1457) Fix: `flow: register` now works with `useGenericRemediator: true` + ## 7.4.2 ### Bug Fix diff --git a/package.json b/package.json index fba0f97a6..ad82d0f26 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "private": true, "name": "@okta/okta-auth-js", "description": "The Okta Auth SDK", - "version": "7.4.2", + "version": "7.4.3", "homepage": "https://github.com/okta/okta-auth-js", "license": "Apache-2.0", "main": "build/cjs/exports/default.js", From d716efe86a24c3b291578e475476708e8a08583f Mon Sep 17 00:00:00 2001 From: Jared Perreault Date: Tue, 19 Sep 2023 08:20:39 -0400 Subject: [PATCH 6/6] fixes bacon script --- scripts/lint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lint.sh b/scripts/lint.sh index 1ba5e3252..43fd38bef 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -1,4 +1,4 @@ -#!/bin/bash -e +#!/bin/bash source ${OKTA_HOME}/${REPO}/scripts/setup.sh