Skip to content

Commit 0f54b76

Browse files
committed
fix(idx): allow proceed when saved idxResponse is available - OKTA-513541
1 parent dd3078f commit 0f54b76

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

lib/idx/proceed.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ import { AuthSdkError } from '../errors';
2222

2323
export function canProceed(authClient: OktaAuthIdxInterface, options: ProceedOptions = {}): boolean {
2424
const meta = getSavedTransactionMeta(authClient, options);
25-
return !!(meta || options.stateHandle);
25+
const savedIdxResponse = authClient.transactionManager.loadIdxResponse(options);
26+
const stateHandle = savedIdxResponse?.stateHandle || options.stateHandle;
27+
return !!(meta || stateHandle);
2628
}
2729

2830
export async function proceed(

test/spec/idx/authenticate.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ describe('idx/authenticate', () => {
116116
clear: () => {},
117117
save: () => {},
118118
saveIdxResponse: () => {},
119+
loadIdxResponse: () => {},
119120
},
120121
token: {
121122
exchangeCodeForTokens: () => Promise.resolve(tokenResponse)

test/spec/idx/proceed.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ describe('idx/proceed', () => {
3939
urls: { authorizeUrl: 'meta-authorizeUrl' },
4040
ignoreSignature: true,
4141
};
42+
const savedIdxResponse = { stateHandle: 'fake-stateHandle' };
4243
const authClient = {
4344
options: {
4445
issuer,
@@ -48,6 +49,7 @@ describe('idx/proceed', () => {
4849
transactionManager: {
4950
exists: () => true,
5051
load: () => transactionMeta,
52+
loadIdxResponse: () => {},
5153
clear: () => {},
5254
save: () => {},
5355
},
@@ -62,16 +64,22 @@ describe('idx/proceed', () => {
6264
redirectUri,
6365
stateHandle,
6466
transactionMeta,
67+
savedIdxResponse,
6568
authClient
6669
};
6770
});
6871

6972
describe('canProceed', () => {
70-
it('returns true if there is a saved transaction', () => {
73+
it('returns true if there is a saved transaction meta', () => {
7174
const { authClient, transactionMeta } = testContext;
7275
jest.spyOn(mocked.transactionMeta, 'getSavedTransactionMeta').mockReturnValue(transactionMeta);
7376
expect(canProceed(authClient)).toBe(true);
7477
});
78+
it('returns true if there is a saved idxTransaction', () => {
79+
const { authClient, savedIdxResponse } = testContext;
80+
jest.spyOn(authClient.transactionManager, 'loadIdxResponse').mockReturnValue(savedIdxResponse);
81+
expect(canProceed(authClient)).toBe(true);
82+
});
7583
it('returns false if there is no saved transaction', () => {
7684
const { authClient } = testContext;
7785
jest.spyOn(mocked.transactionMeta, 'getSavedTransactionMeta').mockReturnValue(undefined);

0 commit comments

Comments
 (0)