Skip to content

Commit 52957bd

Browse files
passes exchangeCodeForTokens from idx.poll (#1585)
OKTA-912523 fix: passes exchangeCodeForTokens from idx.poll
1 parent 22ab3b9 commit 52957bd

File tree

5 files changed

+40
-3
lines changed

5 files changed

+40
-3
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
# 7.12.1
4+
5+
### Fixes
6+
7+
- [#1585](https://github.com/okta/okta-auth-js/pull/1585) fix: `idx.poll` now respects `exchangeCodeForTokens` and `withCredentials` options
8+
39
# 7.12.0
410

511
### Features

lib/idx/poll.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ import { getSavedTransactionMeta } from './transactionMeta';
2121
import { warn } from '../util';
2222

2323
export async function poll(authClient: OktaAuthIdxInterface, options: IdxPollOptions = {}): Promise<IdxTransaction> {
24+
const { withCredentials, exchangeCodeForTokens } = options;
2425
let transaction = await proceed(authClient, {
25-
startPolling: true
26+
startPolling: true,
27+
withCredentials,
28+
exchangeCodeForTokens
2629
});
2730

2831
const meta = getSavedTransactionMeta(authClient);

lib/idx/types/api.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import {
3636
ActivationData,
3737
} from './idx-js';
3838
import {
39+
IdxOptions,
3940
AccountUnlockOptions,
4041
AuthenticationOptions,
4142
CancelOptions,
@@ -91,7 +92,7 @@ export type Input = {
9192
}
9293

9394

94-
export interface IdxPollOptions {
95+
export interface IdxPollOptions extends Pick<IdxOptions, 'exchangeCodeForTokens' | 'withCredentials' > {
9596
required?: boolean;
9697
refresh?: number;
9798
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"private": true,
33
"name": "@okta/okta-auth-js",
44
"description": "The Okta Auth SDK",
5-
"version": "7.12.0",
5+
"version": "7.12.1",
66
"homepage": "https://github.com/okta/okta-auth-js",
77
"license": "Apache-2.0",
88
"main": "build/cjs/exports/default.js",

test/spec/idx/poll.ts

+27
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,33 @@ describe('idx/poll', () => {
159159
expect(mocked.proceed.proceed).toHaveBeenCalledTimes(1);
160160
});
161161

162+
it('passes RunOptions through to `procced`', async () => {
163+
const {
164+
authClient,
165+
enrollPollResponse
166+
} = testContext;
167+
168+
chainResponses([
169+
enrollPollResponse,
170+
enrollPollResponse,
171+
]);
172+
173+
jest.spyOn(mocked.introspect, 'introspect')
174+
.mockResolvedValue(enrollPollResponse);
175+
const proccedSpy = jest.spyOn(mocked.proceed, 'proceed');
176+
177+
await poll(authClient, {
178+
exchangeCodeForTokens: false,
179+
withCredentials: false
180+
});
181+
expect(proccedSpy).toHaveBeenCalledTimes(1);
182+
expect(proccedSpy).toHaveBeenLastCalledWith(authClient, expect.objectContaining({
183+
startPolling: true,
184+
exchangeCodeForTokens: false,
185+
withCredentials: false
186+
}));
187+
});
188+
162189
it('polls until completion when refresh parameter is passed', async () => {
163190
const {
164191
authClient,

0 commit comments

Comments
 (0)