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/lib/idx/flow/FlowSpecification.ts b/lib/idx/flow/FlowSpecification.ts index 06d6229ac..0f558f3f9 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 = 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; 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", 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 diff --git a/scripts/publish.sh b/scripts/publish.sh index c730a65f1..cde5e5a94 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -1,4 +1,4 @@ -#!/bin/bash -xe +#!/bin/bash -x source ${OKTA_HOME}/${REPO}/scripts/setup.sh 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, {