diff --git a/CHANGELOG.md b/CHANGELOG.md index cb10b9402..aaaa11508 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ # Changelog -# 6.7.2 +## 6.7.3 + +### Fixes + +- [#1255](https://github.com/okta/okta-auth-js/pull/1255) IDX: allows `idx.proceed` when saved idx response is available + +## 6.7.2 ### Fixes diff --git a/lib/idx/proceed.ts b/lib/idx/proceed.ts index 8f910e3da..f135a85a6 100644 --- a/lib/idx/proceed.ts +++ b/lib/idx/proceed.ts @@ -22,7 +22,9 @@ import { AuthSdkError } from '../errors'; export function canProceed(authClient: OktaAuthIdxInterface, options: ProceedOptions = {}): boolean { const meta = getSavedTransactionMeta(authClient, options); - return !!(meta || options.stateHandle); + const savedIdxResponse = authClient.transactionManager.loadIdxResponse(options); + const stateHandle = savedIdxResponse?.stateHandle || options.stateHandle; + return !!(meta || stateHandle); } export async function proceed( diff --git a/package.json b/package.json index 895694534..b10086d8b 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "private": true, "name": "@okta/okta-auth-js", "description": "The Okta Auth SDK", - "version": "6.7.2", + "version": "6.7.3", "homepage": "https://github.com/okta/okta-auth-js", "license": "Apache-2.0", "main": "build/cjs/index.js", diff --git a/test/spec/idx/authenticate.ts b/test/spec/idx/authenticate.ts index 042f99a49..54dc07a7f 100644 --- a/test/spec/idx/authenticate.ts +++ b/test/spec/idx/authenticate.ts @@ -116,6 +116,7 @@ describe('idx/authenticate', () => { clear: () => {}, save: () => {}, saveIdxResponse: () => {}, + loadIdxResponse: () => {}, }, token: { exchangeCodeForTokens: () => Promise.resolve(tokenResponse) diff --git a/test/spec/idx/proceed.ts b/test/spec/idx/proceed.ts index b70bbafd0..8481e22ed 100644 --- a/test/spec/idx/proceed.ts +++ b/test/spec/idx/proceed.ts @@ -39,6 +39,7 @@ describe('idx/proceed', () => { urls: { authorizeUrl: 'meta-authorizeUrl' }, ignoreSignature: true, }; + const savedIdxResponse = { stateHandle: 'fake-stateHandle' }; const authClient = { options: { issuer, @@ -48,6 +49,7 @@ describe('idx/proceed', () => { transactionManager: { exists: () => true, load: () => transactionMeta, + loadIdxResponse: () => {}, clear: () => {}, save: () => {}, }, @@ -62,16 +64,22 @@ describe('idx/proceed', () => { redirectUri, stateHandle, transactionMeta, + savedIdxResponse, authClient }; }); describe('canProceed', () => { - it('returns true if there is a saved transaction', () => { + it('returns true if there is a saved transaction meta', () => { const { authClient, transactionMeta } = testContext; jest.spyOn(mocked.transactionMeta, 'getSavedTransactionMeta').mockReturnValue(transactionMeta); expect(canProceed(authClient)).toBe(true); }); + it('returns true if there is a saved idxTransaction', () => { + const { authClient, savedIdxResponse } = testContext; + jest.spyOn(authClient.transactionManager, 'loadIdxResponse').mockReturnValue(savedIdxResponse); + expect(canProceed(authClient)).toBe(true); + }); it('returns false if there is no saved transaction', () => { const { authClient } = testContext; jest.spyOn(mocked.transactionMeta, 'getSavedTransactionMeta').mockReturnValue(undefined);