From 8d5e8bd88a611136b82fb4fa110aa03abdb78975 Mon Sep 17 00:00:00 2001 From: Oleksandr Pravosudko <71440851+oleksandrpravosudko-okta@users.noreply.github.com> Date: Mon, 7 Nov 2022 16:43:46 +0100 Subject: [PATCH 1/3] chore: add uiDisplay property to IdxContext type (#1335) OKTA-538692 fix: add `uiDisplay` property to `IdxContext` type --- CHANGELOG.md | 6 ++++++ lib/idx/types/idx-js.ts | 9 +++++++++ lib/idx/types/index.ts | 2 ++ package.json | 2 +- test/types/auth-idx.test-d.ts | 5 ++++- 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 744ae045d..93a9fa671 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 7.0.2 + +### Fixes + +- [#1335](https://github.com/okta/okta-auth-js/pull/1335) IDX: add uiDisplay property to IdxContext type + ## 7.0.1 ### Fixes diff --git a/lib/idx/types/idx-js.ts b/lib/idx/types/idx-js.ts index bb71c618d..5e5f42126 100644 --- a/lib/idx/types/idx-js.ts +++ b/lib/idx/types/idx-js.ts @@ -173,6 +173,7 @@ export interface IdxContext { type: string; value: Record; }; + uiDisplay?: IdxContextUIDisplay app: { type: string; value: Record; @@ -182,6 +183,14 @@ export interface IdxContext { failure?: IdxRemediation; } +export interface IdxContextUIDisplay { + type: string; + value: { + label?: string; + buttonLabel?: string; + } +} + export interface IdxMessage { message: string; class: string; diff --git a/lib/idx/types/index.ts b/lib/idx/types/index.ts index e35cfa1a7..bb0996fb3 100644 --- a/lib/idx/types/index.ts +++ b/lib/idx/types/index.ts @@ -24,6 +24,8 @@ export type { IdxRemediation, IdxAuthenticator, IdxActionParams, + IdxContextUIDisplay, + } from './idx-js'; export * from './meta'; export type { FlowIdentifier } from './FlowIdentifier'; diff --git a/package.json b/package.json index 62fc06c4f..6b5398543 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "private": true, "name": "@okta/okta-auth-js", "description": "The Okta Auth SDK", - "version": "7.0.1", + "version": "7.0.2", "homepage": "https://github.com/okta/okta-auth-js", "license": "Apache-2.0", "main": "build/cjs/exports/default.js", diff --git a/test/types/auth-idx.test-d.ts b/test/types/auth-idx.test-d.ts index 371dff5d4..fffc470ae 100644 --- a/test/types/auth-idx.test-d.ts +++ b/test/types/auth-idx.test-d.ts @@ -14,7 +14,7 @@ import { IdxResponse, IdxTransaction, IdxTransactionMeta, - IdxTransactionMetaOptions, + IdxContextUIDisplay, InteractResponse, OktaAuth, } from '@okta/okta-auth-js'; @@ -31,6 +31,9 @@ expectType(await authClient.idx.proceed()); expectType(await authClient.idx.cancel()); expectType(await authClient.idx.authenticate()); +const transaction = await authClient.idx.start(); +expectType(transaction.context.uiDisplay); + expectType(await authClient.idx.interact()); expectType(await authClient.idx.introspect()); expectType(await authClient.idx.proceed()); From e2f1bd68dd6da825a137d531e368da51b8af64db Mon Sep 17 00:00:00 2001 From: Oleksandr Pravosudko <71440851+oleksandrpravosudko-okta@users.noreply.github.com> Date: Tue, 8 Nov 2022 10:27:25 +0100 Subject: [PATCH 2/3] fix: add `deviceKnown` property to `IdxAuthenticator` type (#1336) OKTA-541266 fix: add `deviceKnown` property to `IdxAuthenticator` type --- CHANGELOG.md | 3 ++- lib/idx/types/idx-js.ts | 1 + test/types/auth-idx.test-d.ts | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93a9fa671..466e4e836 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,8 @@ ### Fixes -- [#1335](https://github.com/okta/okta-auth-js/pull/1335) IDX: add uiDisplay property to IdxContext type +- [#1335](https://github.com/okta/okta-auth-js/pull/1335) IDX: adds `uiDisplay` property to `IdxContext` type +- [#1336](https://github.com/okta/okta-auth-js/pull/1319) IDX: adds `deviceKnown` property to `IdxAuthenticator` type ## 7.0.1 diff --git a/lib/idx/types/idx-js.ts b/lib/idx/types/idx-js.ts index 5e5f42126..e286aa33b 100644 --- a/lib/idx/types/idx-js.ts +++ b/lib/idx/types/idx-js.ts @@ -88,6 +88,7 @@ export interface IdxAuthenticator { resend?: Record; poll?: Record; recover?: Record; + deviceKnown?: boolean; } export interface IdxForm { diff --git a/test/types/auth-idx.test-d.ts b/test/types/auth-idx.test-d.ts index fffc470ae..f0b017b8d 100644 --- a/test/types/auth-idx.test-d.ts +++ b/test/types/auth-idx.test-d.ts @@ -33,6 +33,7 @@ expectType(await authClient.idx.authenticate()); const transaction = await authClient.idx.start(); expectType(transaction.context.uiDisplay); +expectType(transaction.context.currentAuthenticator.value.deviceKnown); expectType(await authClient.idx.interact()); expectType(await authClient.idx.introspect()); From 8ff05e7ad8d53a9a99ef8cdb1d69634bf4bf907a Mon Sep 17 00:00:00 2001 From: denysoblohin-okta <72614880+denysoblohin-okta@users.noreply.github.com> Date: Wed, 9 Nov 2022 13:14:07 +0200 Subject: [PATCH 3/3] fix: Don't check for 'identify' remediation if 'activationToken' is used (#1337) OKTA-548934 fix: Don't check for 'identify' remediation if 'activationToken' is used --- CHANGELOG.md | 1 + lib/idx/register.ts | 5 +---- test/spec/idx/register.ts | 25 +++++++++++++------------ 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 466e4e836..0963401b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - [#1335](https://github.com/okta/okta-auth-js/pull/1335) IDX: adds `uiDisplay` property to `IdxContext` type - [#1336](https://github.com/okta/okta-auth-js/pull/1319) IDX: adds `deviceKnown` property to `IdxAuthenticator` type +- [#1337](https://github.com/okta/okta-auth-js/pull/1337) IDX: fixes account activation flow by removing check for `identify` remediation ## 7.0.1 diff --git a/lib/idx/register.ts b/lib/idx/register.ts index d0f7a8550..fef3a351d 100644 --- a/lib/idx/register.ts +++ b/lib/idx/register.ts @@ -28,7 +28,7 @@ export async function register( // Only check at the beginning of the transaction if (!hasSavedInteractionHandle(authClient)) { - const { enabledFeatures, availableSteps } = await startTransaction(authClient, { + const { enabledFeatures } = await startTransaction(authClient, { ...options, flow: 'register', autoRemediate: false @@ -36,9 +36,6 @@ export async function register( if (!options.activationToken && enabledFeatures && !enabledFeatures.includes(IdxFeature.REGISTRATION)) { throw new AuthSdkError('Registration is not supported based on your current org configuration.'); } - if (options.activationToken && availableSteps?.some(({ name }) => name === 'identify')) { - throw new AuthSdkError('activationToken is not supported based on your current org configuration.'); - } } return run(authClient, { diff --git a/test/spec/idx/register.ts b/test/spec/idx/register.ts index 9b48ab955..c59ce29f3 100644 --- a/test/spec/idx/register.ts +++ b/test/spec/idx/register.ts @@ -321,26 +321,27 @@ describe('idx/register', () => { expect(didThrow).toBe(true); expect(mocked.startTransaction.startTransaction).toHaveBeenCalledWith(authClient, { flow: 'register', autoRemediate: false }); }); - it('presence of identify remediation means activationToken is not supported', async () => { + it('presence of identify remediation should not break account activation with activationToken', async () => { const { authClient, transactionMeta } = testContext; jest.spyOn(authClient.transactionManager, 'exists').mockReturnValue(false); authClient.token.prepareTokenParams = jest.fn().mockResolvedValue(transactionMeta); const identifyResponse = IdxResponseFactory.build({ neededToProceed: [ - IdentifyRemediationFactory.build() + IdentifyRemediationFactory.build(), + SelectAuthenticatorEnrollRemediationFactory.build({ + value: [ + AuthenticatorValueFactory.build({ + options: [ + PasswordAuthenticatorOptionFactory.build() + ] + }) + ] + }) ] }); jest.spyOn(mocked.introspect, 'introspect').mockResolvedValue(identifyResponse); - - let didThrow = false; - try { - await register(authClient, { activationToken: 'fn-activationToken' }); - } catch (error) { - didThrow = true; - expect(error).toBeInstanceOf(AuthSdkError); - expect((error as any).errorSummary).toBe('activationToken is not supported based on your current org configuration.'); - } - expect(didThrow).toBe(true); + const res = await register(authClient, { activationToken: 'fn-activationToken' }); + expect(res.status).toBe(IdxStatus.PENDING); }); it('with activationToken should not check select-enroll-profile remediation', async () => { const { authClient, transactionMeta } = testContext;