Skip to content

Commit

Permalink
fix: add stepUp to IdxTransaction
Browse files Browse the repository at this point in the history
version 6.4.5

OKTA-496172
<<<Jenkins Check-In of Tested SHA: 77c7756 for eng_productivity_ci_bot_okta@okta.com>>>
Artifact: okta-auth-js
Files changed count: 5
PR Link: #1204
  • Loading branch information
aarongranick-okta authored and eng-prod-CI-bot-okta committed May 5, 2022
1 parent fa993ca commit 445b4fb
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 6.4.5

- [#1240](https://github.com/okta/okta-auth-js/pull/1204) Fixes Apple SSO flow: includes `stepUp` on returned `IdxTransaction`

## 6.4.4

- [#1199](https://github.com/okta/okta-auth-js/pull/1199) Fixes webauthn enrollment/verification to accept `credentials` object
Expand Down
5 changes: 3 additions & 2 deletions lib/idx/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ export async function run(
}
}

// from idx-js, used by the widget
const { actions, context, neededToProceed, proceed, rawIdxState, requestDidSucceed } = idxResponse || {};
// copy all fields from idxResponse which are needed by the widget
const { actions, context, neededToProceed, proceed, rawIdxState, requestDidSucceed, stepUp } = idxResponse || {};
return {
status: status!,
...(meta && { meta }),
Expand All @@ -354,6 +354,7 @@ export async function run(
...(nextStep && { nextStep }),
...(messages && messages.length && { messages }),
...(error && { error }),
...(stepUp && { stepUp }),
interactionCode, // if options.exchangeCodeForTokens is false

// from idx-js
Expand Down
3 changes: 2 additions & 1 deletion lib/idx/types/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ export interface IdxTransaction {
enabledFeatures?: IdxFeature[];
availableSteps?: NextStep[];
requestDidSucceed?: boolean;

stepUp?: boolean;

// from idx-js, used by signin widget
proceed: (remediationName: string, params: unknown) => Promise<IdxResponse>;
neededToProceed: IdxRemediation[];
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"private": true,
"name": "@okta/okta-auth-js",
"description": "The Okta Auth SDK",
"version": "6.4.4",
"version": "6.4.5",
"homepage": "https://github.com/okta/okta-auth-js",
"license": "Apache-2.0",
"main": "build/cjs/index.js",
Expand Down
41 changes: 30 additions & 11 deletions test/spec/idx/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,20 +351,39 @@ describe('idx/run', () => {
expect(authClient.transactionManager.clear).not.toHaveBeenCalled();
});

it('does not include "stepUp" on the returned transaction', async () => {
const { authClient } = testContext;
const res = await run(authClient);
expect(res.stepUp).toBe(undefined);
});

// Special case of an error response that can be continued
it('does save the idxResponse if stepUp is true', async () =>{
const { authClient, idxResponse, transactionMeta } = testContext;
idxResponse.requestDidSucceed = false;
idxResponse.stepUp = true;
jest.spyOn(authClient.transactionManager, 'saveIdxResponse');
await run(authClient);
expect(authClient.transactionManager.saveIdxResponse).toHaveBeenCalledWith({
rawIdxResponse: idxResponse.rawIdxState,
requestDidSucceed: false,
stateHandle: idxResponse.context.stateHandle,
interactionHandle: transactionMeta.interactionHandle
describe('stepUp', () => {
beforeEach(() => {
const { idxResponse } = testContext;
idxResponse.stepUp = true;
});

it('does save the idxResponse', async () =>{
const { authClient, idxResponse, transactionMeta } = testContext;
jest.spyOn(authClient.transactionManager, 'saveIdxResponse');
await run(authClient);
expect(authClient.transactionManager.saveIdxResponse).toHaveBeenCalledWith({
rawIdxResponse: idxResponse.rawIdxState,
requestDidSucceed: false,
stateHandle: idxResponse.context.stateHandle,
interactionHandle: transactionMeta.interactionHandle
});
});

it('includes "stepUp" on the returned transaction', async () => {
const { authClient } = testContext;
const res = await run(authClient);
expect(res.stepUp).toBe(true);
});

});

});
});

Expand Down

0 comments on commit 445b4fb

Please sign in to comment.