From f2342089012edf358851f45b14fb585a95462028 Mon Sep 17 00:00:00 2001 From: Aaron Granick Date: Fri, 15 Apr 2022 02:06:29 -0700 Subject: [PATCH 1/3] fixes types --- lib/OktaAuth.ts | 3 +- lib/errors/AuthApiError.ts | 4 +- lib/errors/AuthSdkError.ts | 4 +- lib/idx/authenticate.ts | 22 +-- lib/idx/cancel.ts | 4 +- lib/idx/interact.ts | 20 +-- lib/idx/introspect.ts | 9 +- lib/idx/proceed.ts | 17 +-- lib/idx/recoverPassword.ts | 18 +-- lib/idx/register.ts | 16 +- lib/idx/remediate.ts | 10 +- .../AuthenticatorVerificationData.ts | 3 +- lib/idx/remediators/Base/Remediator.ts | 4 +- lib/idx/remediators/EnrollmentChannelData.ts | 2 +- .../remediators/SelectEnrollmentChannel.ts | 2 +- lib/idx/run.ts | 15 +- lib/idx/startTransaction.ts | 6 +- lib/idx/types/api.ts | 124 +++++++++++++++ lib/idx/types/index.ts | 142 +----------------- lib/idx/types/options.ts | 104 +++++++++++++ lib/idx/unlockAccount.ts | 16 +- lib/oidc/exchangeCodeForTokens.ts | 4 +- lib/types/OAuth.ts | 5 + lib/types/OktaAuthOptions.ts | 59 ++++++-- lib/types/Transaction.ts | 70 +++++---- lib/types/api.ts | 55 +++---- 26 files changed, 375 insertions(+), 363 deletions(-) create mode 100644 lib/idx/types/api.ts create mode 100644 lib/idx/types/options.ts diff --git a/lib/OktaAuth.ts b/lib/OktaAuth.ts index 68375c809..5a77453a8 100644 --- a/lib/OktaAuth.ts +++ b/lib/OktaAuth.ts @@ -51,6 +51,7 @@ import { GetWithRedirectFunction, RequestOptions, IsAuthenticatedOptions, + OAuthResponseType, } from './types'; import { transactionStatus, @@ -729,7 +730,7 @@ class OktaAuth implements OktaAuthInterface, SigninAPI, SignoutAPI { return !!this.options.pkce; } - hasResponseType(responseType: string): boolean { + hasResponseType(responseType: OAuthResponseType): boolean { let hasResponseType = false; if (Array.isArray(this.options.responseType) && this.options.responseType.length) { hasResponseType = this.options.responseType.indexOf(responseType) >= 0; diff --git a/lib/errors/AuthApiError.ts b/lib/errors/AuthApiError.ts index 37f1b20fe..9bb1d498a 100644 --- a/lib/errors/AuthApiError.ts +++ b/lib/errors/AuthApiError.ts @@ -11,14 +11,14 @@ */ import CustomError from './CustomError'; -import { APIError, HttpResponse } from '../types'; +import { APIError, FieldError, HttpResponse } from '../types'; export default class AuthApiError extends CustomError implements APIError { errorSummary: string; errorCode?: string; errorLink?: string; errorId?: string; - errorCauses?: string[]; + errorCauses?: Array; xhr?: HttpResponse; constructor(err: APIError, xhr?: HttpResponse) { diff --git a/lib/errors/AuthSdkError.ts b/lib/errors/AuthSdkError.ts index df21d50c2..98cb04bdd 100644 --- a/lib/errors/AuthSdkError.ts +++ b/lib/errors/AuthSdkError.ts @@ -11,14 +11,14 @@ */ import CustomError from './CustomError'; -import { APIError } from '../types'; +import { APIError, FieldError } from '../types'; export default class AuthSdkError extends CustomError implements APIError { errorSummary: string; errorCode: string; errorLink: string; errorId: string; - errorCauses: string[]; + errorCauses: Array; xhr?: XMLHttpRequest; constructor(msg: string, xhr?: XMLHttpRequest) { diff --git a/lib/idx/authenticate.ts b/lib/idx/authenticate.ts index da2d42235..445a59b63 100644 --- a/lib/idx/authenticate.ts +++ b/lib/idx/authenticate.ts @@ -13,29 +13,11 @@ import { OktaAuthInterface, - IdxOptions, IdxTransaction, - AuthenticatorKey + AuthenticatorKey, + AuthenticationOptions } from '../types'; import { run } from './run'; -import { - IdentifyValues, - SelectAuthenticatorAuthenticateValues, - ChallengeAuthenticatorValues, - ReEnrollAuthenticatorValues, - AuthenticatorEnrollmentDataValues, - SelectAuthenticatorEnrollValues, - EnrollAuthenticatorValues, -} from './remediators'; - -export type AuthenticationOptions = IdxOptions - & IdentifyValues - & SelectAuthenticatorAuthenticateValues - & SelectAuthenticatorEnrollValues - & ChallengeAuthenticatorValues - & ReEnrollAuthenticatorValues - & AuthenticatorEnrollmentDataValues - & EnrollAuthenticatorValues; export async function authenticate( authClient: OktaAuthInterface, options: AuthenticationOptions = {} diff --git a/lib/idx/cancel.ts b/lib/idx/cancel.ts index c57caf40d..820ae289f 100644 --- a/lib/idx/cancel.ts +++ b/lib/idx/cancel.ts @@ -10,12 +10,10 @@ * See the License for the specific language governing permissions and limitations under the License. */ -import { OktaAuthInterface, IdxOptions, IdxTransactionMeta } from '../types'; +import { OktaAuthInterface, CancelOptions, IdxTransactionMeta } from '../types'; import { run } from './run'; import { getFlowSpecification } from './flow'; -export type CancelOptions = IdxOptions; - export async function cancel (authClient: OktaAuthInterface, options?: CancelOptions) { const meta = authClient.transactionManager.load() as IdxTransactionMeta; const flowSpec = getFlowSpecification(authClient, meta.flow); diff --git a/lib/idx/interact.ts b/lib/idx/interact.ts index f578d6f06..bf0a6372e 100644 --- a/lib/idx/interact.ts +++ b/lib/idx/interact.ts @@ -11,29 +11,13 @@ * See the License for the specific language governing permissions and limitations under the License. */ /* eslint complexity:[0,8] */ -import { OktaAuthInterface, IdxTransactionMeta } from '../types'; +import { OktaAuthInterface, IdxTransactionMeta, InteractOptions, InteractResponse } from '../types'; import { getSavedTransactionMeta, saveTransactionMeta } from './transactionMeta'; import { getOAuthBaseUrl } from '../oidc'; import { createTransactionMeta } from '.'; import { removeNils } from '../util'; import { httpRequest } from '../http'; -export interface InteractOptions { - withCredentials?: boolean; - state?: string; - scopes?: string[]; - codeChallenge?: string; - codeChallengeMethod?: string; - activationToken?: string; - recoveryToken?: string; - clientSecret?: string; -} - -export interface InteractResponse { - state?: string; - interactionHandle: string; - meta: IdxTransactionMeta; -} /* eslint-disable camelcase */ export interface InteractParams { @@ -92,7 +76,7 @@ export async function interact ( const url = `${baseUrl}/v1/interact`; const params = { client_id: clientId, - scope: scopes.join(' '), + scope: scopes!.join(' '), redirect_uri: redirectUri, code_challenge: codeChallenge, code_challenge_method: codeChallengeMethod, diff --git a/lib/idx/introspect.ts b/lib/idx/introspect.ts index 57bea80a9..03be7b677 100644 --- a/lib/idx/introspect.ts +++ b/lib/idx/introspect.ts @@ -12,20 +12,13 @@ */ import { makeIdxState, validateVersionConfig } from './idxState'; -import { OktaAuthInterface } from '../types'; +import { IntrospectOptions, OktaAuthInterface } from '../types'; import { IdxResponse, isRawIdxResponse } from './types/idx-js'; import { getOAuthDomain } from '../oidc'; import { IDX_API_VERSION } from '../constants'; import { httpRequest } from '../http'; import { isAuthApiError } from '../errors'; -export interface IntrospectOptions { - withCredentials?: boolean; - interactionHandle?: string; - stateHandle?: string; - version?: string; -} - export async function introspect ( authClient: OktaAuthInterface, options: IntrospectOptions = {} diff --git a/lib/idx/proceed.ts b/lib/idx/proceed.ts index a7b461f50..11923894a 100644 --- a/lib/idx/proceed.ts +++ b/lib/idx/proceed.ts @@ -14,27 +14,12 @@ import { OktaAuthInterface, IdxTransaction, + ProceedOptions, } from '../types'; import { run } from './run'; -import { AuthenticationOptions } from './authenticate'; -import { - EnrollPollValues as EnrollPollOptions, - SelectEnrollmentChannelValues as SelectEnrollmentChannelOptions -} from './remediators'; -import { RegistrationOptions } from './register'; -import { PasswordRecoveryOptions } from './recoverPassword'; -import { AccountUnlockOptions } from './unlockAccount'; import { getSavedTransactionMeta } from './transactionMeta'; import { AuthSdkError } from '../errors'; -export type ProceedOptions = AuthenticationOptions - & RegistrationOptions - & PasswordRecoveryOptions - & AccountUnlockOptions - & EnrollPollOptions - & SelectEnrollmentChannelOptions - & { step?: string }; - export function canProceed(authClient: OktaAuthInterface, options: ProceedOptions = {}): boolean { const meta = getSavedTransactionMeta(authClient, options); return !!(meta || options.stateHandle); diff --git a/lib/idx/recoverPassword.ts b/lib/idx/recoverPassword.ts index 359ef2d7a..62e2b9e3d 100644 --- a/lib/idx/recoverPassword.ts +++ b/lib/idx/recoverPassword.ts @@ -12,29 +12,13 @@ import { run } from './run'; -import { - IdentifyValues, - SelectAuthenticatorAuthenticateValues, - ChallengeAuthenticatorValues, - AuthenticatorVerificationDataValues, - ResetAuthenticatorValues, - ReEnrollAuthenticatorValues, -} from './remediators'; import { getFlowSpecification } from './flow'; import { OktaAuthInterface, - IdxOptions, + PasswordRecoveryOptions, IdxTransaction, } from '../types'; -export type PasswordRecoveryOptions = IdxOptions - & IdentifyValues - & SelectAuthenticatorAuthenticateValues - & ChallengeAuthenticatorValues - & ResetAuthenticatorValues - & AuthenticatorVerificationDataValues - & ReEnrollAuthenticatorValues; - export async function recoverPassword( authClient: OktaAuthInterface, options: PasswordRecoveryOptions = {} ): Promise { diff --git a/lib/idx/register.ts b/lib/idx/register.ts index efe351a20..c6dc45c3e 100644 --- a/lib/idx/register.ts +++ b/lib/idx/register.ts @@ -14,28 +14,14 @@ import { run } from './run'; import { hasSavedInteractionHandle } from './transactionMeta'; import { startTransaction } from './startTransaction'; -import { - EnrollProfileValues, - SelectAuthenticatorEnrollValues, - EnrollAuthenticatorValues, - AuthenticatorEnrollmentDataValues, - SkipValues, -} from './remediators'; import { AuthSdkError } from '../errors'; import { - IdxOptions, + RegistrationOptions, IdxTransaction, OktaAuthInterface, IdxFeature, } from '../types'; -export type RegistrationOptions = IdxOptions - & EnrollProfileValues - & SelectAuthenticatorEnrollValues - & EnrollAuthenticatorValues - & AuthenticatorEnrollmentDataValues - & SkipValues; - export async function register( authClient: OktaAuthInterface, options: RegistrationOptions = {} ): Promise { diff --git a/lib/idx/remediate.ts b/lib/idx/remediate.ts index 52fbc0866..d41dca919 100644 --- a/lib/idx/remediate.ts +++ b/lib/idx/remediate.ts @@ -14,8 +14,7 @@ /* eslint-disable max-statements, max-depth, complexity */ import { AuthSdkError } from '../errors'; import { RemediationValues } from './remediators'; -import { FlowIdentifier, RemediationResponse } from './types'; -import { RemediationFlow } from './flow'; +import { RemediateOptions, RemediationResponse } from './types'; import { IdxResponse, IdxActionParams, @@ -35,13 +34,6 @@ export interface RemediateActionWithOptionalParams { } export type RemediateAction = string | RemediateActionWithOptionalParams; -export interface RemediateOptions { - remediators?: RemediationFlow; - actions?: RemediateAction[]; - flow?: FlowIdentifier; - step?: string; - shouldProceedWithEmailAuthenticator?: boolean; // will be removed in next major version -} function getActionFromValues(values: RemediationValues, idxResponse: IdxResponse): string | undefined { diff --git a/lib/idx/remediators/AuthenticatorVerificationData.ts b/lib/idx/remediators/AuthenticatorVerificationData.ts index e7935200a..a476fe5b0 100644 --- a/lib/idx/remediators/AuthenticatorVerificationData.ts +++ b/lib/idx/remediators/AuthenticatorVerificationData.ts @@ -14,8 +14,7 @@ import { AuthSdkError } from '../../errors'; import { AuthenticatorData, AuthenticatorDataValues } from './Base/AuthenticatorData'; -import { IdxRemediation } from '../types/idx-js'; -import { RemediateOptions } from '../remediate'; +import { IdxRemediation, RemediateOptions } from '../types'; export type AuthenticatorVerificationDataValues = AuthenticatorDataValues; diff --git a/lib/idx/remediators/Base/Remediator.ts b/lib/idx/remediators/Base/Remediator.ts index 1c06786f4..6eba94299 100644 --- a/lib/idx/remediators/Base/Remediator.ts +++ b/lib/idx/remediators/Base/Remediator.ts @@ -13,7 +13,7 @@ /* eslint-disable complexity */ -import { NextStep, IdxMessage, Authenticator, Input, IdxOptions, RemediateOptions } from '../../types'; +import { NextStep, IdxMessage, Authenticator, Input, RemediateOptions } from '../../types'; import { IdxAuthenticator, IdxRemediation, IdxContext } from '../../types/idx-js'; import { getAllValues, getRequiredValues, titleCase, getAuthenticatorFromRemediation } from '../util'; import { formatAuthenticator, compareAuthenticators } from '../../authenticator/util'; @@ -21,7 +21,7 @@ import { formatAuthenticator, compareAuthenticators } from '../../authenticator/ // A map from IDX data values (server spec) to RemediationValues (client spec) export type IdxToRemediationValueMap = Record; -export interface RemediationValues extends IdxOptions { +export interface RemediationValues { stateHandle?: string; authenticators?: (Authenticator | string)[]; authenticator?: string | Authenticator; diff --git a/lib/idx/remediators/EnrollmentChannelData.ts b/lib/idx/remediators/EnrollmentChannelData.ts index fc53fbbb0..38509fc0a 100644 --- a/lib/idx/remediators/EnrollmentChannelData.ts +++ b/lib/idx/remediators/EnrollmentChannelData.ts @@ -56,7 +56,7 @@ export class EnrollmentChannelData extends Remediator !['email', 'phoneNumber'].includes(valueKey)); return trimmedValues.reduce((values, valueKey) => ({...values, [valueKey]: this.values[valueKey]}), {}); } diff --git a/lib/idx/remediators/SelectEnrollmentChannel.ts b/lib/idx/remediators/SelectEnrollmentChannel.ts index 72d665772..0d65bf2ce 100644 --- a/lib/idx/remediators/SelectEnrollmentChannel.ts +++ b/lib/idx/remediators/SelectEnrollmentChannel.ts @@ -58,7 +58,7 @@ export class SelectEnrollmentChannel extends Remediator valueKey !== 'channel'); return trimmedValues.reduce((values, valueKey) => ({...values, [valueKey]: this.values[valueKey]}), {}); } diff --git a/lib/idx/run.ts b/lib/idx/run.ts index b46295e16..1ad83a3e3 100644 --- a/lib/idx/run.ts +++ b/lib/idx/run.ts @@ -15,8 +15,8 @@ /* eslint-disable max-statements, complexity, max-depth */ import { interact } from './interact'; import { introspect } from './introspect'; -import { remediate, RemediateOptions } from './remediate'; -import { getFlowSpecification, RemediationFlow } from './flow'; +import { remediate } from './remediate'; +import { getFlowSpecification } from './flow'; import * as remediators from './remediators'; import { OktaAuthInterface, @@ -24,23 +24,14 @@ import { IdxTransaction, IdxFeature, NextStep, - FlowIdentifier, + RunOptions, IdxTransactionMeta, Tokens, APIError, } from '../types'; import { IdxMessage, IdxResponse, isIdxResponse } from './types/idx-js'; import { getSavedTransactionMeta, saveTransactionMeta } from './transactionMeta'; -import { ProceedOptions } from './proceed'; import { getAvailableSteps, getEnabledFeatures, getMessagesFromResponse, isTerminalResponse } from './util'; - -export type RunOptions = ProceedOptions & RemediateOptions & { - flow?: FlowIdentifier; - remediators?: RemediationFlow; - actions?: string[]; - withCredentials?: boolean; -} - declare interface RunData { options: RunOptions; values: remediators.RemediationValues; diff --git a/lib/idx/startTransaction.ts b/lib/idx/startTransaction.ts index 8880dd805..6a7675f5f 100644 --- a/lib/idx/startTransaction.ts +++ b/lib/idx/startTransaction.ts @@ -11,12 +11,12 @@ */ -import { run, RunOptions } from './run'; -import { OktaAuthInterface, IdxTransaction } from '../types'; +import { run } from './run'; +import { OktaAuthInterface, IdxTransaction, StartOptions } from '../types'; export async function startTransaction( authClient: OktaAuthInterface, - options: RunOptions = {} + options: StartOptions = {} ): Promise { // Clear IDX response cache and saved transaction meta (if any) authClient.transactionManager.clear(); diff --git a/lib/idx/types/api.ts b/lib/idx/types/api.ts new file mode 100644 index 000000000..7cc9cb3ac --- /dev/null +++ b/lib/idx/types/api.ts @@ -0,0 +1,124 @@ +import { APIError } from '../../types/api'; +import { Tokens } from '../../types/Token'; +import { PKCETransactionMeta } from '../../types/Transaction'; +import { FlowIdentifier } from './FlowIdentifier'; +import { + IdxActions, + IdxAuthenticator, + IdxContext, + IdxForm, + IdxMessage, + IdxOption, + IdxRemediation, + IdxResponse, + RawIdxResponse +} from './idx-js'; + +export enum IdxStatus { + SUCCESS = 'SUCCESS', + PENDING = 'PENDING', + FAILURE = 'FAILURE', + TERMINAL = 'TERMINAL', + CANCELED = 'CANCELED', +} + +export enum AuthenticatorKey { + OKTA_PASSWORD = 'okta_password', + OKTA_EMAIL = 'okta_email', + PHONE_NUMBER = 'phone_number', + GOOGLE_AUTHENTICATOR = 'google_otp', + SECURITY_QUESTION = 'security_question', + OKTA_VERIFY = 'okta_verify', + WEBAUTHN = 'webauthn', +} + +export type Input = { + name: string; + key?: string; + type?: string; + label?: string; + value?: string | {form: IdxForm}; + minLength?: number; + maxLength?: number; + secret?: boolean; + required?: boolean; +} + + +export interface IdxPollOptions { + required?: boolean; + refresh?: number; +} + +export type NextStep = { + name: string; + authenticator?: IdxAuthenticator; + canSkip?: boolean; + canResend?: boolean; + inputs?: Input[]; + options?: IdxOption[]; + poll?: IdxPollOptions; + authenticatorEnrollments?: IdxAuthenticator[]; +} + +export enum IdxFeature { + PASSWORD_RECOVERY = 'recover-password', + REGISTRATION = 'enroll-profile', + SOCIAL_IDP = 'redirect-idp', + ACCOUNT_UNLOCK = 'unlock-account', +} + +export interface IdxTransactionMeta extends PKCETransactionMeta { + interactionHandle?: string; + remediations?: string[]; + flow?: FlowIdentifier; + withCredentials?: boolean; + activationToken?: string; + recoveryToken?: string; +} + +export interface IdxTransaction { + status: IdxStatus; + tokens?: Tokens; + nextStep?: NextStep; + messages?: IdxMessage[]; + error?: APIError | IdxResponse; + meta?: IdxTransactionMeta; + enabledFeatures?: IdxFeature[]; + availableSteps?: NextStep[]; + requestDidSucceed?: boolean; + + // from idx-js, used by signin widget + proceed: (remediationName: string, params: unknown) => Promise; + neededToProceed: IdxRemediation[]; + rawIdxState: RawIdxResponse; + interactionCode?: string; + actions: IdxActions; + context: IdxContext; +} + + +export type Authenticator = { + id?: string; + key?: string; + methodType?: string; + phoneNumber?: string; +}; + +export function isAuthenticator(obj: any): obj is Authenticator { + return obj && (obj.key || obj.id); +} + +export interface RemediationResponse { + idxResponse: IdxResponse; + nextStep?: NextStep; + messages?: IdxMessage[]; + terminal?: boolean; + canceled?: boolean; +} + +export interface InteractResponse { + state?: string; + interactionHandle: string; + meta: IdxTransactionMeta; +} diff --git a/lib/idx/types/index.ts b/lib/idx/types/index.ts index 022d16c71..96703a84c 100644 --- a/lib/idx/types/index.ts +++ b/lib/idx/types/index.ts @@ -11,23 +11,8 @@ */ -import { InteractOptions } from '../interact'; -import { IntrospectOptions } from '../introspect'; -import { APIError, Tokens } from '../../types'; -import { PKCETransactionMeta } from '../../types/Transaction'; -import { - IdxActions, - IdxAuthenticator, - IdxContext, - IdxForm, - IdxMessage, - IdxOption, - IdxRemediation, - IdxResponse, - RawIdxResponse -} from './idx-js'; -import { FlowIdentifier } from './FlowIdentifier'; - +export * from './api'; +export * from './options'; export type { IdxMessage, IdxMessages, @@ -35,126 +20,11 @@ export type { ActivationData, IdxResponse, IdxContext, - RawIdxResponse + RawIdxResponse, + IdxRemediation, + IdxAuthenticator } from './idx-js'; -export type { AuthenticationOptions } from '../authenticate'; -export type { RegistrationOptions } from '../register'; -export type { PasswordRecoveryOptions } from '../recoverPassword'; -export type { AccountUnlockOptions } from '../unlockAccount'; -export type { ProceedOptions } from '../proceed'; -export type { CancelOptions } from '../cancel'; -export type { RemediateOptions } from '../remediate'; -export type { FlowIdentifier }; -export type { IdxAuthenticator }; +export type { FlowIdentifier } from './FlowIdentifier'; export type { EmailVerifyCallbackResponse } from '../emailVerify'; export type { WebauthnEnrollValues } from '../authenticator/WebauthnEnrollment'; export type { WebauthnVerificationValues } from '../authenticator/WebauthnVerification'; - -export enum IdxStatus { - SUCCESS = 'SUCCESS', - PENDING = 'PENDING', - FAILURE = 'FAILURE', - TERMINAL = 'TERMINAL', - CANCELED = 'CANCELED', -} - -export enum AuthenticatorKey { - OKTA_PASSWORD = 'okta_password', - OKTA_EMAIL = 'okta_email', - PHONE_NUMBER = 'phone_number', - GOOGLE_AUTHENTICATOR = 'google_otp', - SECURITY_QUESTION = 'security_question', - OKTA_VERIFY = 'okta_verify', - WEBAUTHN = 'webauthn', -} - -export type Input = { - name: string; - key?: string; - type?: string; - label?: string; - value?: string | {form: IdxForm}; - minLength?: number; - maxLength?: number; - secret?: boolean; - required?: boolean; -} - - -export interface IdxPollOptions { - required?: boolean; - refresh?: number; -} - -export type NextStep = { - name: string; - authenticator?: IdxAuthenticator; - canSkip?: boolean; - canResend?: boolean; - inputs?: Input[]; - options?: IdxOption[]; - poll?: IdxPollOptions; - authenticatorEnrollments?: IdxAuthenticator[]; -} - -export enum IdxFeature { - PASSWORD_RECOVERY = 'recover-password', - REGISTRATION = 'enroll-profile', - SOCIAL_IDP = 'redirect-idp', - ACCOUNT_UNLOCK = 'unlock-account', -} - -export interface IdxTransactionMeta extends PKCETransactionMeta { - interactionHandle?: string; - remediations?: string[]; - flow?: FlowIdentifier; - withCredentials?: boolean; - activationToken?: string; - recoveryToken?: string; -} - -export interface IdxTransaction { - status: IdxStatus; - tokens?: Tokens; - nextStep?: NextStep; - messages?: IdxMessage[]; - error?: APIError | IdxResponse; - meta?: IdxTransactionMeta; - enabledFeatures?: IdxFeature[]; - availableSteps?: NextStep[]; - requestDidSucceed?: boolean; - - // from idx-js, used by signin widget - proceed: (remediationName: string, params: unknown) => Promise; - neededToProceed: IdxRemediation[]; - rawIdxState: RawIdxResponse; - interactionCode?: string; - actions: IdxActions; - context: IdxContext; -} - -export type IdxOptions = InteractOptions & IntrospectOptions & { - flow?: FlowIdentifier; - exchangeCodeForTokens?: boolean; - autoRemediate?: boolean; - step?: string; -}; - -export type Authenticator = { - id?: string; - key?: string; - methodType?: string; - phoneNumber?: string; -}; - -export function isAuthenticator(obj: any): obj is Authenticator { - return obj && (obj.key || obj.id); -} - -export interface RemediationResponse { - idxResponse: IdxResponse; - nextStep?: NextStep; - messages?: IdxMessage[]; - terminal?: boolean; - canceled?: boolean; -} diff --git a/lib/idx/types/options.ts b/lib/idx/types/options.ts new file mode 100644 index 000000000..e79e28de4 --- /dev/null +++ b/lib/idx/types/options.ts @@ -0,0 +1,104 @@ +import { RemediationFlow } from '../flow'; +import { RemediateAction } from '../remediate'; +import { FlowIdentifier } from './FlowIdentifier'; +import { + AuthenticatorVerificationDataValues, + EnrollProfileValues, + ResetAuthenticatorValues, + SelectAuthenticatorUnlockAccountValues, + SkipValues, + EnrollPollValues as EnrollPollOptions, + SelectEnrollmentChannelValues as SelectEnrollmentChannelOptions, + IdentifyValues, + SelectAuthenticatorAuthenticateValues, + ChallengeAuthenticatorValues, + ReEnrollAuthenticatorValues, + AuthenticatorEnrollmentDataValues, + SelectAuthenticatorEnrollValues, + EnrollAuthenticatorValues, +} from '../remediators'; + +export interface IdxOptions { + flow?: FlowIdentifier; + exchangeCodeForTokens?: boolean; + autoRemediate?: boolean; + step?: string; + withCredentials?: boolean; +} + +export interface InteractOptions extends IdxOptions { + state?: string; + scopes?: string[]; + codeChallenge?: string; + codeChallengeMethod?: string; + activationToken?: string; + recoveryToken?: string; + clientSecret?: string; +} + +export interface IntrospectOptions extends IdxOptions { + interactionHandle?: string; + stateHandle?: string; + version?: string; +} + +export interface RemediateOptions extends IdxOptions { + remediators?: RemediationFlow; + actions?: RemediateAction[]; + shouldProceedWithEmailAuthenticator?: boolean; // will be removed in next major version +} + +export interface RunOptions extends RemediateOptions, InteractOptions, IntrospectOptions {} + +export interface AuthenticationOptions extends + RunOptions, + IdentifyValues, + SelectAuthenticatorAuthenticateValues, + SelectAuthenticatorEnrollValues, + ChallengeAuthenticatorValues, + ReEnrollAuthenticatorValues, + AuthenticatorEnrollmentDataValues, + EnrollAuthenticatorValues +{} + +export interface RegistrationOptions extends + RunOptions, + IdentifyValues, + EnrollProfileValues, + SelectAuthenticatorEnrollValues, + EnrollAuthenticatorValues, + AuthenticatorEnrollmentDataValues, + SkipValues +{} + +export interface PasswordRecoveryOptions extends + RunOptions, + IdentifyValues, + SelectAuthenticatorAuthenticateValues, + ChallengeAuthenticatorValues, + ResetAuthenticatorValues, + AuthenticatorVerificationDataValues, + ReEnrollAuthenticatorValues +{} + +export interface AccountUnlockOptions extends + RunOptions, + IdentifyValues, + SelectAuthenticatorUnlockAccountValues, + SelectAuthenticatorAuthenticateValues, + ChallengeAuthenticatorValues, + AuthenticatorVerificationDataValues +{} + +export interface ProceedOptions extends + AuthenticationOptions, + RegistrationOptions, + PasswordRecoveryOptions, + AccountUnlockOptions, + EnrollPollOptions, + SelectEnrollmentChannelOptions +{} + +export type CancelOptions = IdxOptions + +export type StartOptions = RunOptions diff --git a/lib/idx/unlockAccount.ts b/lib/idx/unlockAccount.ts index 83944d1de..672e0d045 100644 --- a/lib/idx/unlockAccount.ts +++ b/lib/idx/unlockAccount.ts @@ -14,28 +14,14 @@ import { run } from './run'; import { hasSavedInteractionHandle } from './transactionMeta'; import { startTransaction } from './startTransaction'; -import { - IdentifyValues, - SelectAuthenticatorUnlockAccountValues, - SelectAuthenticatorAuthenticateValues, - ChallengeAuthenticatorValues, - AuthenticatorVerificationDataValues -} from './remediators'; import { AuthSdkError } from '../errors'; import { OktaAuthInterface, - IdxOptions, + AccountUnlockOptions, IdxTransaction, IdxFeature, } from '../types'; -export type AccountUnlockOptions = IdxOptions - & IdentifyValues - & SelectAuthenticatorUnlockAccountValues - & SelectAuthenticatorAuthenticateValues - & ChallengeAuthenticatorValues - & AuthenticatorVerificationDataValues; - export async function unlockAccount( authClient: OktaAuthInterface, options: AccountUnlockOptions = {} ): Promise { diff --git a/lib/oidc/exchangeCodeForTokens.ts b/lib/oidc/exchangeCodeForTokens.ts index 3914fe0f0..ee8612a2f 100644 --- a/lib/oidc/exchangeCodeForTokens.ts +++ b/lib/oidc/exchangeCodeForTokens.ts @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and limitations under the License. * */ -import { CustomUrls, OAuthResponse, OktaAuthInterface, TokenParams, TokenResponse } from '../types'; +import { CustomUrls, OAuthResponse, OAuthResponseType, OktaAuthInterface, TokenParams, TokenResponse } from '../types'; import { getOAuthUrls, getDefaultTokenParams } from './util'; import { clone } from '../util'; import { postToTokenEndpoint } from './endpoints/token'; @@ -49,7 +49,7 @@ export function exchangeCodeForTokens(sdk: OktaAuthInterface, tokenParams: Token // `handleOAuthResponse` hanadles responses from both `/authorize` and `/token` endpoints // Here we modify the response from `/token` so that it more closely matches a response from `/authorize` // `responseType` is used to validate that the expected tokens were returned - const responseType = ['token']; // an accessToken will always be returned + const responseType: OAuthResponseType[] = ['token']; // an accessToken will always be returned if (scopes!.indexOf('openid') !== -1) { responseType.push('id_token'); // an idToken will be returned if "openid" is in the scopes } diff --git a/lib/types/OAuth.ts b/lib/types/OAuth.ts index f550d4c89..43db015dd 100644 --- a/lib/types/OAuth.ts +++ b/lib/types/OAuth.ts @@ -60,3 +60,8 @@ export interface WellKnownResponse { scopes_supported: string[]; claims_supported: string[]; } + + +export type OAuthResponseMode ='okta_post_message' |'fragment' |'query' |'form_post'; + +export type OAuthResponseType ='code' |'token' |'id_token'; diff --git a/lib/types/OktaAuthOptions.ts b/lib/types/OktaAuthOptions.ts index c9eae18d8..6776bbc1c 100644 --- a/lib/types/OktaAuthOptions.ts +++ b/lib/types/OktaAuthOptions.ts @@ -15,9 +15,10 @@ import { CookieOptions } from './Cookies'; import { HttpRequestClient } from './http'; import { AuthState } from './AuthState'; import { TransactionManagerOptions } from './Transaction'; -import { FlowIdentifier } from '../idx/types'; +import { IdxTransactionMeta } from '../idx/types'; import { ServiceManagerOptions } from './Service'; import OktaAuth from '../OktaAuth'; +import { OAuthResponseMode, OAuthResponseType } from './OAuth'; export interface IsAuthenticatedOptions { @@ -44,16 +45,57 @@ export interface CustomUrls { revokeUrl?: string; logoutUrl?: string; } -export interface OktaAuthOptions extends CustomUrls { + +export interface TokenParams extends CustomUrls { pkce?: boolean; clientId?: string; redirectUri?: string; - useInteractionCodeFlow?: boolean; - responseType?: string | string[]; - responseMode?: string; - scopes?: string[]; + responseType?: OAuthResponseType | OAuthResponseType[]; + responseMode?: OAuthResponseMode; state?: string; + nonce?: string; + scopes?: string[]; + display?: string; ignoreSignature?: boolean; + codeVerifier?: string; + authorizationCode?: string; + codeChallenge?: string; + codeChallengeMethod?: string; + interactionCode?: string; + idp?: string; + idpScope?: string | string[]; + loginHint?: string; + maxAge?: string | number; + prompt?: string; + sessionToken?: string; + timeout?: number; + extraParams?: { [propName: string]: string }; // custom authorize query params + // TODO: remove in the next major version + popupTitle?: string; +} + +export interface OktaAuthOptions extends + CustomUrls, + Pick, + Pick +{ + useInteractionCodeFlow?: boolean; ignoreLifetime?: boolean; tokenManager?: TokenManagerOptions; postLogoutRedirectUri?: string; @@ -70,11 +112,6 @@ export interface OktaAuthOptions extends CustomUrls { storageManager?: StorageManagerOptions; services?: ServiceManagerOptions; transactionManager?: TransactionManagerOptions; - flow?: FlowIdentifier; - codeChallenge?: string; - codeChallengeMethod?: string; - recoveryToken?: string; - activationToken?: string; // For server-side web applications ONLY! clientSecret?: string; diff --git a/lib/types/Transaction.ts b/lib/types/Transaction.ts index de842b07b..2e83b2cf9 100644 --- a/lib/types/Transaction.ts +++ b/lib/types/Transaction.ts @@ -12,8 +12,8 @@ import { StorageManager } from '../StorageManager'; -import { CustomUrls } from './OktaAuthOptions'; -import { FlowIdentifier, IdxTransactionMeta } from '../idx/types'; +import { CustomUrls, TokenParams } from './OktaAuthOptions'; +import { IdxTransactionMeta } from '../idx/types'; export interface TransactionManagerOptions { storageManager?: StorageManager; @@ -25,39 +25,33 @@ export interface TransactionManagerOptions { saveLastResponse?: boolean; // default true } -export interface TransactionMetaOptions { - pkce?: boolean; - oauth?: boolean; - muteWarning?: boolean; - state?: string; - flow?: FlowIdentifier; - codeVerifier?: string; - codeChallenge?: string; - codeChallengeMethod?: string; - activationToken?: string; - recoveryToken?: string; -} - // formerly known as "Redirect OAuth Params" -export interface OAuthTransactionMeta { - issuer: string; - redirectUri: string; - state: string; - nonce: string; - responseType: string | string []; - responseMode?: string; - scopes: string[]; - clientId: string; +export interface OAuthTransactionMeta extends + Pick +{ urls: CustomUrls; - ignoreSignature: boolean; originalUri?: string; } -export interface PKCETransactionMeta extends OAuthTransactionMeta { - codeVerifier: string; - codeChallengeMethod: string; - codeChallenge: string; -} +export interface PKCETransactionMeta extends + OAuthTransactionMeta, + Pick +{} export type CustomAuthTransactionMeta = Record; @@ -67,6 +61,22 @@ export type TransactionMeta = OAuthTransactionMeta | CustomAuthTransactionMeta; +export interface TransactionMetaOptions extends + Pick +{ + oauth?: boolean; + muteWarning?: boolean; +} + function isObjectWithProperties(obj) { if (!obj || typeof obj !== 'object' || Object.values(obj).length === 0) { return false; diff --git a/lib/types/api.ts b/lib/types/api.ts index 9d861be9c..7b31461cd 100644 --- a/lib/types/api.ts +++ b/lib/types/api.ts @@ -15,7 +15,7 @@ import { AuthTransaction } from '../tx/AuthTransaction'; import { Token, Tokens, RevocableToken, AccessToken, IDToken, RefreshToken } from './Token'; import { JWTObject } from './JWT'; import { UserClaims } from './UserClaims'; -import { CustomUrls, OktaAuthOptions } from './OktaAuthOptions'; +import { CustomUrls, OktaAuthOptions, TokenParams } from './OktaAuthOptions'; import { StorageManager } from '../StorageManager'; import TransactionManager from '../TransactionManager'; import { TokenManagerInterface } from './TokenManager'; @@ -28,7 +28,6 @@ import { AccountUnlockOptions, ProceedOptions, CancelOptions, - IdxOptions, IdxTransaction, IdxTransactionMeta, EmailVerifyCallbackResponse, @@ -38,11 +37,13 @@ import { WebauthnEnrollValues, WebauthnVerificationValues, FlowIdentifier, - IdxPollOptions + IdxPollOptions, + IdxResponse, + IntrospectOptions, + InteractOptions, + InteractResponse, + StartOptions } from '../idx/types'; -import { InteractOptions, InteractResponse } from '../idx/interact'; -import { IntrospectOptions } from '../idx/introspect'; -import { IdxResponse } from '../idx/types/idx-js'; import { TransactionMetaOptions } from './Transaction'; export interface OktaAuthInterface { options: OktaAuthOptions; @@ -62,12 +63,20 @@ export interface OktaAuthInterface { token: TokenAPI; } +export interface FieldError { + errorSummary: string; + reason?: string; + location?: string; + locationType?: string; + domain?: string; +} + export interface APIError { errorSummary: string; errorCode?: string; errorLink?: string; errorId?: string; - errorCauses?: string[]; + errorCauses?: Array; } // HTTP API @@ -111,34 +120,6 @@ export interface SessionAPI { setCookieAndRedirect: (sessionToken?: string, redirectUri?: string) => void; } -export interface TokenParams extends CustomUrls { - pkce?: boolean; - clientId?: string; - redirectUri?: string; - responseType?: string | string[]; - responseMode?: string; - state?: string; - nonce?: string; - scopes?: string[]; - display?: string; - ignoreSignature?: boolean; - codeVerifier?: string; - authorizationCode?: string; - codeChallenge?: string; - codeChallengeMethod?: string; - interactionCode?: string; - idp?: string; - idpScope?: string | string[]; - loginHint?: string; - maxAge?: string | number; - prompt?: string; - sessionToken?: string; - timeout?: number; - extraParams?: { [propName: string]: string }; // custom authorize query params - // TODO: remove in the next major version - popupTitle?: string; -} - export interface PopupParams { popupTitle?: string; popupWindow?: Window; @@ -307,7 +288,7 @@ export interface IdxAPI { poll: (options?: IdxPollOptions) => Promise; // flow control - start: (options?: IdxOptions) => Promise; + start: (options?: StartOptions) => Promise; canProceed(options?: ProceedOptions): boolean; proceed: (options?: ProceedOptions) => Promise; cancel: (options?: CancelOptions) => Promise; @@ -315,7 +296,7 @@ export interface IdxAPI { setFlow(flow: FlowIdentifier): void; // call `start` instead of `startTransaction`. `startTransaction` will be removed in next major version (7.0) - startTransaction: (options?: IdxOptions) => Promise; + startTransaction: (options?: StartOptions) => Promise; // redirect callbacks isInteractionRequired: (hashOrSearch?: string) => boolean; From 68e7565fdbb3eaaca031c70f895f299ded16fb45 Mon Sep 17 00:00:00 2001 From: Aaron Granick Date: Fri, 15 Apr 2022 02:32:52 -0700 Subject: [PATCH 2/3] fix test --- lib/types/OAuth.ts | 4 ++-- test/spec/OktaAuth/api.ts | 18 +++++++++--------- test/spec/idx/run.ts | 6 +++--- test/spec/oidc/endpoints/authorize.ts | 3 ++- test/spec/oidc/util/defaultTokenParams.ts | 8 ++++---- test/spec/oidc/util/handleOAuthResponse.ts | 16 ++++++++-------- 6 files changed, 28 insertions(+), 27 deletions(-) diff --git a/lib/types/OAuth.ts b/lib/types/OAuth.ts index 43db015dd..9864e0452 100644 --- a/lib/types/OAuth.ts +++ b/lib/types/OAuth.ts @@ -62,6 +62,6 @@ export interface WellKnownResponse { } -export type OAuthResponseMode ='okta_post_message' |'fragment' |'query' |'form_post'; +export type OAuthResponseMode = 'okta_post_message' |'fragment' |'query' |'form_post'; -export type OAuthResponseType ='code' |'token' |'id_token'; +export type OAuthResponseType = 'code' |'token' |'id_token' | 'refresh_token'; diff --git a/test/spec/OktaAuth/api.ts b/test/spec/OktaAuth/api.ts index e439196e1..7872cd03e 100644 --- a/test/spec/OktaAuth/api.ts +++ b/test/spec/OktaAuth/api.ts @@ -433,20 +433,20 @@ describe('OktaAuth (api)', function() { describe('hasResponseType', () => { it('returns true if responseType is a string', () => { - auth = new OktaAuth({ issuer, responseType: 'fake' }); - expect(auth.hasResponseType('fake')).toBe(true); + auth = new OktaAuth({ issuer, responseType: 'token' }); + expect(auth.hasResponseType('token')).toBe(true); }); it('returns true if responseType is an array', () => { - auth = new OktaAuth({ issuer, responseType: ['fake', 'alsofake'] }); - expect(auth.hasResponseType('fake')).toBe(true); + auth = new OktaAuth({ issuer, responseType: ['token', 'id_token'] }); + expect(auth.hasResponseType('token')).toBe(true); }); it('returns false if responseType does not match string', () => { - auth = new OktaAuth({ issuer, responseType: 'abc' }); - expect(auth.hasResponseType('fake')).toBe(false); + auth = new OktaAuth({ issuer, responseType: 'token' }); + expect(auth.hasResponseType('id_token')).toBe(false); }); it('returns false if responseType does not match entry in array', () => { - auth = new OktaAuth({ issuer, responseType: ['abc', 'def'] }); - expect(auth.hasResponseType('fake')).toBe(false); + auth = new OktaAuth({ issuer, responseType: ['token', 'id_token'] }); + expect(auth.hasResponseType('code')).toBe(false); }); }); @@ -464,7 +464,7 @@ describe('OktaAuth (api)', function() { expect(auth.isAuthorizationCodeFlow()).toBe(true); }); it('will be true if responseType is [..., "code"]', () => { - auth = new OktaAuth({ issuer, pkce: false, responseType: ['abc', 'code'] }); + auth = new OktaAuth({ issuer, pkce: false, responseType: ['token', 'code'] }); expect(auth.isAuthorizationCodeFlow()).toBe(true); }); }); diff --git a/test/spec/idx/run.ts b/test/spec/idx/run.ts index d1e751491..b7afde88d 100644 --- a/test/spec/idx/run.ts +++ b/test/spec/idx/run.ts @@ -11,8 +11,8 @@ */ -import { run, RunOptions } from '../../../lib/idx/run'; -import { IdxStatus } from '../../../lib/idx/types'; +import { run } from '../../../lib/idx/run'; +import { AuthenticationOptions, IdxStatus } from '../../../lib/idx/types'; import { IdxResponseFactory, IdentifyRemediationFactory } from '@okta/test.support/idx'; jest.mock('../../../lib/idx/transactionMeta', () => { @@ -221,7 +221,7 @@ describe('idx/run', () => { const username = 'x'; const password = 'y'; const shouldProceedWithEmailAuthenticator = false; - const options: RunOptions = { + const options: AuthenticationOptions = { username, password, flow, diff --git a/test/spec/oidc/endpoints/authorize.ts b/test/spec/oidc/endpoints/authorize.ts index f61302948..2b3e2ece8 100644 --- a/test/spec/oidc/endpoints/authorize.ts +++ b/test/spec/oidc/endpoints/authorize.ts @@ -12,6 +12,7 @@ import { buildAuthorizeParams } from '../../../../lib/oidc/endpoints'; import { AuthSdkError } from '../../../../lib/errors'; +import { OAuthResponseType } from '../../../../lib/types'; describe('authorize endpoint', () => { @@ -24,7 +25,7 @@ describe('authorize endpoint', () => { it('throws if multiple response types are specified as string', () => { expect(() => buildAuthorizeParams({ clientId: 'fakeClientId', - responseType: 'id_token token' + responseType: 'id_token token' as OAuthResponseType })).toThrow(new AuthSdkError('Multiple OAuth responseTypes must be defined as an array')); }); diff --git a/test/spec/oidc/util/defaultTokenParams.ts b/test/spec/oidc/util/defaultTokenParams.ts index bf57e828f..211092edb 100644 --- a/test/spec/oidc/util/defaultTokenParams.ts +++ b/test/spec/oidc/util/defaultTokenParams.ts @@ -67,14 +67,14 @@ describe('getDefaultTokenParams', () => { expect(getDefaultTokenParams({ options: {} } as OktaAuthInterface).responseType).toEqual(['token', 'id_token']); }); it('uses values from sdk.options', () => { - const sdk = { options: { responseType: 'abc' } } as OktaAuthInterface; - expect(getDefaultTokenParams(sdk).responseType).toBe('abc'); + const sdk = { options: { responseType: 'code' } } as OktaAuthInterface; + expect(getDefaultTokenParams(sdk).responseType).toBe('code'); }); }); it('`responseMode`: uses value from sdk.options', () => { - const sdk = { options: { responseMode: 'abc' } } as OktaAuthInterface; - expect(getDefaultTokenParams(sdk).responseMode).toBe('abc'); + const sdk = { options: { responseMode: 'fragment' } } as OktaAuthInterface; + expect(getDefaultTokenParams(sdk).responseMode).toBe('fragment'); }); describe('`state`: ', () => { diff --git a/test/spec/oidc/util/handleOAuthResponse.ts b/test/spec/oidc/util/handleOAuthResponse.ts index 05aaf33f0..22c503125 100644 --- a/test/spec/oidc/util/handleOAuthResponse.ts +++ b/test/spec/oidc/util/handleOAuthResponse.ts @@ -18,7 +18,7 @@ const verifyToken = jest.fn(); jest.mock('../../../../lib/oidc/verifyToken', () => { return { verifyToken }; }); import { handleOAuthResponse } from '../../../../lib/oidc'; -import { CustomUrls } from '../../../../lib/types'; +import { CustomUrls, TokenParams } from '../../../../lib/types'; describe('handleOAuthResponse', () => { let sdk; @@ -63,7 +63,7 @@ describe('handleOAuthResponse', () => { expect(res.tokens.refreshToken!.refreshToken).toBe('foo'); }); it('returns all tokens from the response', async () => { - const tokenParams = { responseType: ['token', 'id_token', 'refresh_token'] }; + const tokenParams: TokenParams = { responseType: ['token', 'id_token', 'refresh_token'] }; const oauthRes = { id_token: 'foo', access_token: 'blar', refresh_token: 'bloo' }; const res = await handleOAuthResponse(sdk, tokenParams, oauthRes, undefined as unknown as CustomUrls); expect(res.tokens).toBeTruthy(); @@ -75,7 +75,7 @@ describe('handleOAuthResponse', () => { expect(res.tokens.refreshToken!.refreshToken).toBe('bloo'); }); it('prefers "scope" value from endpoint response over method parameter', async () => { - const tokenParams = { responseType: ['token', 'id_token', 'refresh_token'], scopes: ['profile'] }; + const tokenParams: TokenParams = { responseType: ['token', 'id_token', 'refresh_token'], scopes: ['profile'] }; const oauthRes = { id_token: 'foo', access_token: 'blar', refresh_token: 'bloo', scope: 'openid offline_access' }; const res = await handleOAuthResponse(sdk, tokenParams, oauthRes, undefined as unknown as CustomUrls); expect(res.tokens.accessToken!.scopes).toEqual(['openid', 'offline_access']); @@ -112,7 +112,7 @@ describe('handleOAuthResponse', () => { let errorThrown = false; try { await handleOAuthResponse(sdk, {}, { error: 'error code', error_description: 'error description' }, undefined as unknown as CustomUrls); - } catch (err) { + } catch (err: any) { errorThrown = true; expect(err.name).toBe('OAuthError'); expect(err.errorCode).toBe('error code'); @@ -125,7 +125,7 @@ describe('handleOAuthResponse', () => { let errorThrown = false; try { await handleOAuthResponse(sdk, { state: 'bar' }, { state: 'foo' }, undefined as unknown as CustomUrls); - } catch (err) { + } catch (err: any) { errorThrown = true; expect(err.name).toBe('AuthSdkError'); expect(err.errorSummary).toBe(`OAuth flow response state doesn't match request state`); @@ -136,7 +136,7 @@ describe('handleOAuthResponse', () => { let errorThrown = false; try { await handleOAuthResponse(sdk, { responseType: ['token', 'id_token'] }, { access_token: 'foo' }, undefined as unknown as CustomUrls); - } catch (err) { + } catch (err: any) { errorThrown = true; expect(err.name).toBe('AuthSdkError'); expect(err.errorCode).toBe('INTERNAL'); @@ -148,7 +148,7 @@ describe('handleOAuthResponse', () => { let errorThrown = false; try { await handleOAuthResponse(sdk, { responseType: ['token', 'id_token'] }, { id_token: 'foo' }, undefined as unknown as CustomUrls); - } catch (err) { + } catch (err: any) { errorThrown = true; expect(err.name).toBe('AuthSdkError'); expect(err.errorCode).toBe('INTERNAL'); @@ -160,7 +160,7 @@ describe('handleOAuthResponse', () => { let errorThrown = false; try { await handleOAuthResponse(sdk, { responseType: ['token', 'id_token'] }, { }, undefined as unknown as CustomUrls); - } catch (err) { + } catch (err: any) { errorThrown = true; expect(err.name).toBe('AuthSdkError'); expect(err.errorCode).toBe('INTERNAL'); From 0d201510938f1ff06e09427a853d7949d963a1a1 Mon Sep 17 00:00:00 2001 From: Aaron Granick Date: Fri, 15 Apr 2022 10:35:36 -0700 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71da91107..0e1a9c5d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Fixes - [#1182](https://github.com/okta/okta-auth-js/pull/1182) Fixes security question verification to accept `credentials.answer` +- [#1184](https://github.com/okta/okta-auth-js/pull/1184) Fixes type declarations: `ApiError`, `responseType`, `responseMode` ## 6.4.2