Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(idx): allow proceed when saved idxResponse is available - OKTA-513541 #1255

Open
wants to merge 2 commits into
base: 6.7
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
4 changes: 3 additions & 1 deletion lib/idx/proceed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
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.7.2",
"version": "6.7.3",
"homepage": "https://github.com/okta/okta-auth-js",
"license": "Apache-2.0",
"main": "build/cjs/index.js",
Expand Down
1 change: 1 addition & 0 deletions test/spec/idx/authenticate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ describe('idx/authenticate', () => {
clear: () => {},
save: () => {},
saveIdxResponse: () => {},
loadIdxResponse: () => {},
},
token: {
exchangeCodeForTokens: () => Promise.resolve(tokenResponse)
Expand Down
10 changes: 9 additions & 1 deletion test/spec/idx/proceed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ describe('idx/proceed', () => {
urls: { authorizeUrl: 'meta-authorizeUrl' },
ignoreSignature: true,
};
const savedIdxResponse = { stateHandle: 'fake-stateHandle' };
const authClient = {
options: {
issuer,
Expand All @@ -48,6 +49,7 @@ describe('idx/proceed', () => {
transactionManager: {
exists: () => true,
load: () => transactionMeta,
loadIdxResponse: () => {},
clear: () => {},
save: () => {},
},
Expand All @@ -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);
Expand Down