@okta/okta-auth-js 7.5.0 → 7.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/README.md +1 -1
- package/cjs/browser/fingerprint.js +1 -2
- package/cjs/browser/fingerprint.js.map +1 -1
- package/cjs/core/ServiceManager/browser.js +3 -4
- package/cjs/core/ServiceManager/browser.js.map +1 -1
- package/cjs/core/types/api.js.map +1 -1
- package/cjs/fetch/fetchRequest.js +1 -2
- package/cjs/fetch/fetchRequest.js.map +1 -1
- package/cjs/http/OktaUserAgent.js +2 -2
- package/cjs/http/request.js +11 -5
- package/cjs/http/request.js.map +1 -1
- package/cjs/idx/IdxTransactionManager.js +1 -1
- package/cjs/idx/IdxTransactionManager.js.map +1 -1
- package/cjs/idx/authenticator/OktaPassword.js +1 -2
- package/cjs/idx/authenticator/OktaPassword.js.map +1 -1
- package/cjs/idx/authenticator/VerificationCodeAuthenticator.js +1 -2
- package/cjs/idx/authenticator/VerificationCodeAuthenticator.js.map +1 -1
- package/cjs/idx/authenticator/getAuthenticator.js +3 -4
- package/cjs/idx/authenticator/getAuthenticator.js.map +1 -1
- package/cjs/idx/idxState/index.js +1 -1
- package/cjs/idx/idxState/index.js.map +1 -1
- package/cjs/idx/idxState/v1/generateIdxAction.js +2 -2
- package/cjs/idx/idxState/v1/generateIdxAction.js.map +1 -1
- package/cjs/idx/idxState/v1/idxResponseParser.js +2 -4
- package/cjs/idx/idxState/v1/idxResponseParser.js.map +1 -1
- package/cjs/idx/idxState/v1/makeIdxState.js +1 -2
- package/cjs/idx/idxState/v1/makeIdxState.js.map +1 -1
- package/cjs/idx/interact.js +1 -2
- package/cjs/idx/interact.js.map +1 -1
- package/cjs/idx/poll.js +3 -5
- package/cjs/idx/poll.js.map +1 -1
- package/cjs/idx/proceed.js +1 -1
- package/cjs/idx/proceed.js.map +1 -1
- package/cjs/idx/remediators/Base/AuthenticatorData.js +1 -1
- package/cjs/idx/remediators/Base/AuthenticatorData.js.map +1 -1
- package/cjs/idx/remediators/Base/Remediator.js +5 -7
- package/cjs/idx/remediators/Base/Remediator.js.map +1 -1
- package/cjs/idx/remediators/Base/SelectAuthenticator.js +3 -4
- package/cjs/idx/remediators/Base/SelectAuthenticator.js.map +1 -1
- package/cjs/idx/remediators/Base/VerifyAuthenticator.js +1 -2
- package/cjs/idx/remediators/Base/VerifyAuthenticator.js.map +1 -1
- package/cjs/idx/remediators/EnrollPoll.js +1 -1
- package/cjs/idx/remediators/EnrollPoll.js.map +1 -1
- package/cjs/idx/remediators/SelectAuthenticatorAuthenticate.js +2 -3
- package/cjs/idx/remediators/SelectAuthenticatorAuthenticate.js.map +1 -1
- package/cjs/idx/remediators/SelectAuthenticatorUnlockAccount.js +2 -3
- package/cjs/idx/remediators/SelectAuthenticatorUnlockAccount.js.map +1 -1
- package/cjs/idx/remediators/SelectEnrollmentChannel.js +1 -2
- package/cjs/idx/remediators/SelectEnrollmentChannel.js.map +1 -1
- package/cjs/idx/remediators/util.js +2 -4
- package/cjs/idx/remediators/util.js.map +1 -1
- package/cjs/idx/run.js +6 -10
- package/cjs/idx/run.js.map +1 -1
- package/cjs/idx/transactionMeta.js +1 -1
- package/cjs/idx/transactionMeta.js.map +1 -1
- package/cjs/idx/util.js +3 -6
- package/cjs/idx/util.js.map +1 -1
- package/cjs/myaccount/emailApi.js +1 -1
- package/cjs/myaccount/emailApi.js.map +1 -1
- package/cjs/myaccount/passwordApi.js +2 -2
- package/cjs/myaccount/passwordApi.js.map +1 -1
- package/cjs/myaccount/phoneApi.js +1 -1
- package/cjs/myaccount/phoneApi.js.map +1 -1
- package/cjs/myaccount/profileApi.js +2 -2
- package/cjs/myaccount/profileApi.js.map +1 -1
- package/cjs/myaccount/request.js +1 -1
- package/cjs/myaccount/request.js.map +1 -1
- package/cjs/oidc/TokenManager.js +1 -2
- package/cjs/oidc/TokenManager.js.map +1 -1
- package/cjs/oidc/TransactionManager.js +1 -1
- package/cjs/oidc/TransactionManager.js.map +1 -1
- package/cjs/oidc/getToken.js +1 -2
- package/cjs/oidc/getToken.js.map +1 -1
- package/cjs/oidc/introspect.js +3 -5
- package/cjs/oidc/introspect.js.map +1 -1
- package/cjs/oidc/mixin/index.js +2 -3
- package/cjs/oidc/mixin/index.js.map +1 -1
- package/cjs/oidc/renewTokens.js +1 -2
- package/cjs/oidc/renewTokens.js.map +1 -1
- package/cjs/oidc/util/errors.js +2 -2
- package/cjs/oidc/util/errors.js.map +1 -1
- package/cjs/oidc/util/validateClaims.js +1 -1
- package/cjs/oidc/util/validateClaims.js.map +1 -1
- package/cjs/oidc/verifyToken.js +1 -1
- package/cjs/oidc/verifyToken.js.map +1 -1
- package/cjs/services/LeaderElectionService.js +3 -6
- package/cjs/services/LeaderElectionService.js.map +1 -1
- package/cjs/services/SyncStorageService.js +6 -11
- package/cjs/services/SyncStorageService.js.map +1 -1
- package/dist/okta-auth-js.authn.min.analyzer.html +2 -2
- package/dist/okta-auth-js.authn.min.js +1 -1
- package/dist/okta-auth-js.authn.min.js.map +1 -1
- package/dist/okta-auth-js.core.min.analyzer.html +2 -2
- package/dist/okta-auth-js.core.min.js +1 -1
- package/dist/okta-auth-js.core.min.js.map +1 -1
- package/dist/okta-auth-js.idx.min.analyzer.html +2 -2
- package/dist/okta-auth-js.idx.min.js +1 -1
- package/dist/okta-auth-js.idx.min.js.map +1 -1
- package/dist/okta-auth-js.min.analyzer.html +2 -2
- package/dist/okta-auth-js.min.js +1 -1
- package/dist/okta-auth-js.min.js.map +1 -1
- package/dist/okta-auth-js.myaccount.min.analyzer.html +2 -2
- package/dist/okta-auth-js.myaccount.min.js +1 -1
- package/dist/okta-auth-js.myaccount.min.js.map +1 -1
- package/esm/browser/http/OktaUserAgent.js +2 -2
- package/esm/browser/http/request.js +7 -1
- package/esm/browser/http/request.js.map +1 -1
- package/esm/browser/oidc/introspect.js +1 -1
- package/esm/browser/oidc/introspect.js.map +1 -1
- package/esm/browser/oidc/util/validateClaims.js +2 -1
- package/esm/browser/oidc/util/validateClaims.js.map +1 -1
- package/esm/browser/package.json +1 -1
- package/esm/node/http/OktaUserAgent.js +2 -2
- package/esm/node/http/request.js +7 -1
- package/esm/node/http/request.js.map +1 -1
- package/esm/node/oidc/introspect.js +1 -1
- package/esm/node/oidc/introspect.js.map +1 -1
- package/esm/node/oidc/util/validateClaims.js +2 -1
- package/esm/node/oidc/util/validateClaims.js.map +1 -1
- package/esm/node/package.json +1 -1
- package/package.json +3 -3
- package/types/lib/core/types/api.d.ts +1 -0
- package/umd/authn.js +1 -1
- package/umd/authn.js.map +1 -1
- package/umd/core.js +1 -1
- package/umd/core.js.map +1 -1
- package/umd/default.js +1 -1
- package/umd/default.js.map +1 -1
- package/umd/idx.js +1 -1
- package/umd/idx.js.map +1 -1
- package/umd/myaccount.js +1 -1
- package/umd/myaccount.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idxResponseParser.js","names":["SKIP_FIELDS","parseNonRemediations","authClient","idxResponse","toPersist","actions","context","Object","keys","filter","field","forEach","fieldIsObject","rel","name","generateIdxAction","value","fieldValue","type","info","entries","subField","expandRelatesTo","k","query","Array","isArray","result","jsonpath","path","json","AuthSdkError","innerValue","convertRemediationAction","remediation","remediationActions","generateRemediationFunctions","actionFn","action","parseIdxResponse","remediationData","relatesTo","authenticatorChallenge","remediations","map"],"sources":["../../../../../lib/idx/idxState/v1/idxResponseParser.ts"],"sourcesContent":["/*!\n * Copyright (c) 2021-Present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\n/* eslint-disable max-len */\n\nimport { OktaAuthIdxInterface, IdxResponse, IdxRemediation, IdxContext } from '../../types'; // auth-js/types\nimport { IdxActions } from '../../types/idx-js';\nimport { generateRemediationFunctions } from './remediationParser';\nimport generateIdxAction from './generateIdxAction';\nimport { jsonpath } from '../../../util/jsonpath';\nimport { AuthSdkError } from '../../../errors';\n\nconst SKIP_FIELDS = {\n 'remediation': true, // remediations are put into proceed/neededToProceed\n 'context': true, // the API response of 'context' isn't externally useful. We ignore it and put all non-action (contextual) info into idxState.context\n};\n\nexport const parseNonRemediations = function parseNonRemediations( authClient: OktaAuthIdxInterface, idxResponse: IdxResponse, toPersist = {} ) {\n const actions = {};\n const context = {} as IdxContext;\n\n Object.keys(idxResponse)\n .filter( field => !SKIP_FIELDS[field])\n .forEach( field => {\n const fieldIsObject = typeof idxResponse[field] === 'object' && !!idxResponse[field];\n\n if ( !fieldIsObject ) {\n // simple fields are contextual info\n context[field] = idxResponse[field];\n return;\n }\n\n if ( idxResponse[field].rel ) {\n // top level actions\n actions[idxResponse[field].name] = generateIdxAction(authClient, idxResponse[field], toPersist);\n return;\n }\n\n const { value: fieldValue, type, ...info} = idxResponse[field];\n context[field] = { type, ...info}; // add the non-action parts as context\n\n if ( type !== 'object' ) {\n // only object values hold actions\n context[field].value = fieldValue;\n return;\n }\n\n // We are an object field containing an object value\n context[field].value = {};\n Object.entries<IdxRemediation>(fieldValue)\n .forEach( ([subField, value]) => {\n if (value.rel) { // is [field].value[subField] an action?\n // add any \"action\" value subfields to actions\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n actions[`${field}-${subField.name || subField}`] = generateIdxAction(authClient, value, toPersist);\n } else {\n // add non-action value subfields to context\n context[field].value[subField] = value;\n }\n });\n });\n\n return { context, actions };\n};\n\nconst expandRelatesTo = (idxResponse, value) => {\n Object.keys(value).forEach(k => {\n if (k === 'relatesTo') {\n const query = Array.isArray(value[k]) ? value[k][0] : value[k];\n if (typeof query === 'string') {\n const result = jsonpath({ path: query, json: idxResponse })[0];\n if (result) {\n value[k] = result;\n return;\n } else {\n throw new AuthSdkError(`Cannot resolve relatesTo: ${query}`);\n }\n }\n }\n if (Array.isArray(value[k])) {\n value[k].forEach(innerValue => expandRelatesTo(idxResponse, innerValue));\n }\n });\n};\n\nconst convertRemediationAction = (authClient: OktaAuthIdxInterface, remediation, toPersist) => {\n // Only remediation that has `rel` field (indicator for form submission) can have http action\n if (remediation.rel) {\n const remediationActions = generateRemediationFunctions( authClient, [remediation], toPersist );\n const actionFn = remediationActions[remediation.name];\n return {\n ...remediation,\n action: actionFn,\n };\n }\n\n return remediation;\n};\n\nexport const parseIdxResponse = function parseIdxResponse( authClient: OktaAuthIdxInterface, idxResponse, toPersist = {} ): {\n remediations: IdxRemediation[];\n context: IdxContext;\n actions: IdxActions;\n} {\n const remediationData = idxResponse.remediation?.value || [];\n\n remediationData.forEach(\n remediation => {\n // TODO: remove once IDX is fixed - OKTA-659181\n if (remediation.name === 'launch-authenticator' &&\n remediation?.relatesTo?.[0] === 'authenticatorChallenge' &&\n !idxResponse?.authenticatorChallenge\n ) {\n delete remediation.relatesTo;\n return;\n }\n\n return expandRelatesTo(idxResponse, remediation);\n }\n );\n\n const remediations = remediationData.map(remediation => convertRemediationAction( authClient, remediation, toPersist ));\n\n const { context, actions } = parseNonRemediations( authClient, idxResponse, toPersist );\n\n return {\n remediations,\n context,\n actions,\n };\n};\n"],"mappings":";;;;AAgBA;AACA;AACA;AACA;AAnBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEgG;;AAOhG,MAAMA,WAAW,GAAG;EAClB,aAAa,EAAE,IAAI;EAAE;EACrB,SAAS,EAAE,IAAI,CAAE;AACnB,CAAC;;AAEM,MAAMC,oBAAoB,GAAG,SAASA,oBAAoB,CAAEC,UAAgC,EAAEC,WAAwB,EAAEC,SAAS,GAAG,CAAC,CAAC,EAAG;EAC9I,MAAMC,OAAO,GAAG,CAAC,CAAC;EAClB,M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EgC,WAAW,EAAE9B,SAAS,KAAK;EAC7F;EACA,IAAI8B,WAAW,CAACrB,GAAG,EAAE;IACnB,MAAMsB,kBAAkB,GAAG,IAAAC,+CAA4B,EAAElC,UAAU,EAAE,CAACgC,WAAW,CAAC,EAAE9B,SAAS,CAAE;IAC/F,MAAMiC,QAAQ,GAAGF,kBAAkB,CAACD,WAAW,CAACpB,IAAI,CAAC;IACrD,OAAO;MACL,GAAGoB,WAAW;MACdI,MAAM,EAAED;IACV,CAAC;EACH;EAEA,OAAOH,WAAW;AACpB,CAAC;AAEM,MAAMK,gBAAgB,GAAG,SAASA,gBAAgB,CAAErC,UAAgC,EAAEC,WAAW,EAAEC,SAAS,GAAG,CAAC,CAAC,EAItH;
|
|
1
|
+
{"version":3,"file":"idxResponseParser.js","names":["SKIP_FIELDS","parseNonRemediations","authClient","idxResponse","toPersist","actions","context","Object","keys","filter","field","forEach","fieldIsObject","rel","name","generateIdxAction","value","fieldValue","type","info","entries","subField","expandRelatesTo","k","query","Array","isArray","result","jsonpath","path","json","AuthSdkError","innerValue","convertRemediationAction","remediation","remediationActions","generateRemediationFunctions","actionFn","action","parseIdxResponse","remediationData","relatesTo","authenticatorChallenge","remediations","map"],"sources":["../../../../../lib/idx/idxState/v1/idxResponseParser.ts"],"sourcesContent":["/*!\n * Copyright (c) 2021-Present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\n/* eslint-disable max-len */\n\nimport { OktaAuthIdxInterface, IdxResponse, IdxRemediation, IdxContext } from '../../types'; // auth-js/types\nimport { IdxActions } from '../../types/idx-js';\nimport { generateRemediationFunctions } from './remediationParser';\nimport generateIdxAction from './generateIdxAction';\nimport { jsonpath } from '../../../util/jsonpath';\nimport { AuthSdkError } from '../../../errors';\n\nconst SKIP_FIELDS = {\n 'remediation': true, // remediations are put into proceed/neededToProceed\n 'context': true, // the API response of 'context' isn't externally useful. We ignore it and put all non-action (contextual) info into idxState.context\n};\n\nexport const parseNonRemediations = function parseNonRemediations( authClient: OktaAuthIdxInterface, idxResponse: IdxResponse, toPersist = {} ) {\n const actions = {};\n const context = {} as IdxContext;\n\n Object.keys(idxResponse)\n .filter( field => !SKIP_FIELDS[field])\n .forEach( field => {\n const fieldIsObject = typeof idxResponse[field] === 'object' && !!idxResponse[field];\n\n if ( !fieldIsObject ) {\n // simple fields are contextual info\n context[field] = idxResponse[field];\n return;\n }\n\n if ( idxResponse[field].rel ) {\n // top level actions\n actions[idxResponse[field].name] = generateIdxAction(authClient, idxResponse[field], toPersist);\n return;\n }\n\n const { value: fieldValue, type, ...info} = idxResponse[field];\n context[field] = { type, ...info}; // add the non-action parts as context\n\n if ( type !== 'object' ) {\n // only object values hold actions\n context[field].value = fieldValue;\n return;\n }\n\n // We are an object field containing an object value\n context[field].value = {};\n Object.entries<IdxRemediation>(fieldValue)\n .forEach( ([subField, value]) => {\n if (value.rel) { // is [field].value[subField] an action?\n // add any \"action\" value subfields to actions\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n actions[`${field}-${subField.name || subField}`] = generateIdxAction(authClient, value, toPersist);\n } else {\n // add non-action value subfields to context\n context[field].value[subField] = value;\n }\n });\n });\n\n return { context, actions };\n};\n\nconst expandRelatesTo = (idxResponse, value) => {\n Object.keys(value).forEach(k => {\n if (k === 'relatesTo') {\n const query = Array.isArray(value[k]) ? value[k][0] : value[k];\n if (typeof query === 'string') {\n const result = jsonpath({ path: query, json: idxResponse })[0];\n if (result) {\n value[k] = result;\n return;\n } else {\n throw new AuthSdkError(`Cannot resolve relatesTo: ${query}`);\n }\n }\n }\n if (Array.isArray(value[k])) {\n value[k].forEach(innerValue => expandRelatesTo(idxResponse, innerValue));\n }\n });\n};\n\nconst convertRemediationAction = (authClient: OktaAuthIdxInterface, remediation, toPersist) => {\n // Only remediation that has `rel` field (indicator for form submission) can have http action\n if (remediation.rel) {\n const remediationActions = generateRemediationFunctions( authClient, [remediation], toPersist );\n const actionFn = remediationActions[remediation.name];\n return {\n ...remediation,\n action: actionFn,\n };\n }\n\n return remediation;\n};\n\nexport const parseIdxResponse = function parseIdxResponse( authClient: OktaAuthIdxInterface, idxResponse, toPersist = {} ): {\n remediations: IdxRemediation[];\n context: IdxContext;\n actions: IdxActions;\n} {\n const remediationData = idxResponse.remediation?.value || [];\n\n remediationData.forEach(\n remediation => {\n // TODO: remove once IDX is fixed - OKTA-659181\n if (remediation.name === 'launch-authenticator' &&\n remediation?.relatesTo?.[0] === 'authenticatorChallenge' &&\n !idxResponse?.authenticatorChallenge\n ) {\n delete remediation.relatesTo;\n return;\n }\n\n return expandRelatesTo(idxResponse, remediation);\n }\n );\n\n const remediations = remediationData.map(remediation => convertRemediationAction( authClient, remediation, toPersist ));\n\n const { context, actions } = parseNonRemediations( authClient, idxResponse, toPersist );\n\n return {\n remediations,\n context,\n actions,\n };\n};\n"],"mappings":";;;;AAgBA;AACA;AACA;AACA;AAnBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEgG;;AAOhG,MAAMA,WAAW,GAAG;EAClB,aAAa,EAAE,IAAI;EAAE;EACrB,SAAS,EAAE,IAAI,CAAE;AACnB,CAAC;;AAEM,MAAMC,oBAAoB,GAAG,SAASA,oBAAoB,CAAEC,UAAgC,EAAEC,WAAwB,EAAEC,SAAS,GAAG,CAAC,CAAC,EAAG;EAC9I,MAAMC,OAAO,GAAG,CAAC,CAAC;EAClB,MAAMC,OAAO,GAAG,CAAC,CAAe;EAEhCC,MAAM,CAACC,IAAI,CAACL,WAAW,CAAC,CACrBM,MAAM,CAAEC,KAAK,IAAI,CAACV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,+CAA4B,EAAElC,UAAU,EAAE,CAACgC,WAAW,CAAC,EAAE9B,SAAS,CAAE;IAC/F,MAAMiC,QAAQ,GAAGF,kBAAkB,CAACD,WAAW,CAACpB,IAAI,CAAC;IACrD,OAAO;MACL,GAAGoB,WAAW;MACdI,MAAM,EAAED;IACV,CAAC;EACH;EAEA,OAAOH,WAAW;AACpB,CAAC;AAEM,MAAMK,gBAAgB,GAAG,SAASA,gBAAgB,CAAErC,UAAgC,EAAEC,WAAW,EAAEC,SAAS,GAAG,CAAC,CAAC,EAItH;EACA,MAAMoC,eAAe,GAAGrC,WAAW,CAAC+B,WAAW,EAAElB,KAAK,IAAI,EAAE;EAE5DwB,eAAe,CAAC7B,OAAO,CACrBuB,WAAW,IAAI;IACb;IACA,IAAIA,WAAW,CAACpB,IAAI,KAAK,sBAAsB,IAC7CoB,WAAW,EAAEO,SAAS,GAAG,CAAC,CAAC,KAAK,wBAAwB,IACxD,CAACtC,WAAW,EAAEuC,sBAAsB,EACpC;MACA,OAAOR,WAAW,CAACO,SAAS;MAC5B;IACF;IAEA,OAAOnB,eAAe,CAACnB,WAAW,EAAE+B,WAAW,CAAC;EAClD,CAAC,CACF;EAED,MAAMS,YAAY,GAAGH,eAAe,CAACI,GAAG,CAACV,WAAW,IAAID,wBAAwB,CAAE/B,UAAU,EAAEgC,WAAW,EAAE9B,SAAS,CAAE,CAAC;EAEvH,MAAM;IAAEE,OAAO;IAAED;EAAQ,CAAC,GAAGJ,oBAAoB,CAAEC,UAAU,EAAEC,WAAW,EAAEC,SAAS,CAAE;EAEvF,OAAO;IACLuC,YAAY;IACZrC,OAAO;IACPD;EACF,CAAC;AACH,CAAC;AAAC"}
|
|
@@ -17,7 +17,6 @@ var _idxResponseParser = require("./idxResponseParser");
|
|
|
17
17
|
// auth-js/types
|
|
18
18
|
|
|
19
19
|
function makeIdxState(authClient, idxResponse, toPersist, requestDidSucceed) {
|
|
20
|
-
var _rawIdxResponse$succe, _rawIdxResponse$succe2, _rawIdxResponse$succe3;
|
|
21
20
|
const rawIdxResponse = idxResponse;
|
|
22
21
|
const {
|
|
23
22
|
remediations,
|
|
@@ -43,7 +42,7 @@ function makeIdxState(authClient, idxResponse, toPersist, requestDidSucceed) {
|
|
|
43
42
|
return remediationChoiceObject.action(paramsFromUser);
|
|
44
43
|
};
|
|
45
44
|
const findCode = item => item.name === 'interaction_code';
|
|
46
|
-
const interactionCode =
|
|
45
|
+
const interactionCode = rawIdxResponse.successWithInteractionCode?.value?.find(findCode)?.value;
|
|
47
46
|
return {
|
|
48
47
|
proceed,
|
|
49
48
|
neededToProceed,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"makeIdxState.js","names":["makeIdxState","authClient","idxResponse","toPersist","requestDidSucceed","rawIdxResponse","remediations","context","actions","parseIdxResponse","neededToProceed","proceed","remediationChoice","paramsFromUser","remediationChoiceObject","find","remediation","name","Promise","reject","actionFn","action","findCode","item","interactionCode","successWithInteractionCode","value","rawIdxState"],"sources":["../../../../../lib/idx/idxState/v1/makeIdxState.ts"],"sourcesContent":["/*!\n * Copyright (c) 2021-Present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { IdxResponse, IdxToPersist, IdxActionParams } from '../../types/idx-js';\nimport { OktaAuthIdxInterface, RawIdxResponse } from '../../types'; // auth-js/types\nimport { parseIdxResponse } from './idxResponseParser';\n\nexport function makeIdxState( \n authClient: OktaAuthIdxInterface,\n idxResponse: RawIdxResponse,\n toPersist: IdxToPersist,\n requestDidSucceed: boolean\n): IdxResponse {\n const rawIdxResponse = idxResponse;\n const { remediations, context, actions } = parseIdxResponse( authClient, idxResponse, toPersist );\n const neededToProceed = [...remediations];\n\n const proceed: IdxResponse['proceed'] = async function( remediationChoice, paramsFromUser = {} ) {\n /*\n remediationChoice is the name attribute on each form\n name should remain unique for items inside the remediation that are considered forms(identify, select-factor)\n name can be duplicate for items like redirect where its not considered a form(redirect)\n when names are not unique its a redirect to a href, so widget wont POST to idx-js layer.\n */\n const remediationChoiceObject = remediations.find((remediation) => remediation.name === remediationChoice);\n if ( !remediationChoiceObject ) {\n return Promise.reject(`Unknown remediation choice: [${remediationChoice}]`);\n }\n\n const actionFn = remediationChoiceObject.action;\n if (typeof actionFn !== 'function') {\n return Promise.reject(`Current remediation cannot make form submit action: [${remediationChoice}]`);\n }\n\n return remediationChoiceObject.action!(paramsFromUser as IdxActionParams);\n };\n\n const findCode = item => item.name === 'interaction_code';\n const interactionCode = rawIdxResponse.successWithInteractionCode?.value?.find( findCode )?.value as string;\n\n return {\n proceed,\n neededToProceed,\n actions,\n context,\n rawIdxState: rawIdxResponse,\n interactionCode,\n toPersist,\n requestDidSucceed,\n };\n}\n"],"mappings":";;;AAcA;AAdA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGuE;;AAGhE,SAASA,YAAY,CAC1BC,UAAgC,EAChCC,WAA2B,EAC3BC,SAAuB,EACvBC,iBAA0B,EACb;
|
|
1
|
+
{"version":3,"file":"makeIdxState.js","names":["makeIdxState","authClient","idxResponse","toPersist","requestDidSucceed","rawIdxResponse","remediations","context","actions","parseIdxResponse","neededToProceed","proceed","remediationChoice","paramsFromUser","remediationChoiceObject","find","remediation","name","Promise","reject","actionFn","action","findCode","item","interactionCode","successWithInteractionCode","value","rawIdxState"],"sources":["../../../../../lib/idx/idxState/v1/makeIdxState.ts"],"sourcesContent":["/*!\n * Copyright (c) 2021-Present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { IdxResponse, IdxToPersist, IdxActionParams } from '../../types/idx-js';\nimport { OktaAuthIdxInterface, RawIdxResponse } from '../../types'; // auth-js/types\nimport { parseIdxResponse } from './idxResponseParser';\n\nexport function makeIdxState( \n authClient: OktaAuthIdxInterface,\n idxResponse: RawIdxResponse,\n toPersist: IdxToPersist,\n requestDidSucceed: boolean\n): IdxResponse {\n const rawIdxResponse = idxResponse;\n const { remediations, context, actions } = parseIdxResponse( authClient, idxResponse, toPersist );\n const neededToProceed = [...remediations];\n\n const proceed: IdxResponse['proceed'] = async function( remediationChoice, paramsFromUser = {} ) {\n /*\n remediationChoice is the name attribute on each form\n name should remain unique for items inside the remediation that are considered forms(identify, select-factor)\n name can be duplicate for items like redirect where its not considered a form(redirect)\n when names are not unique its a redirect to a href, so widget wont POST to idx-js layer.\n */\n const remediationChoiceObject = remediations.find((remediation) => remediation.name === remediationChoice);\n if ( !remediationChoiceObject ) {\n return Promise.reject(`Unknown remediation choice: [${remediationChoice}]`);\n }\n\n const actionFn = remediationChoiceObject.action;\n if (typeof actionFn !== 'function') {\n return Promise.reject(`Current remediation cannot make form submit action: [${remediationChoice}]`);\n }\n\n return remediationChoiceObject.action!(paramsFromUser as IdxActionParams);\n };\n\n const findCode = item => item.name === 'interaction_code';\n const interactionCode = rawIdxResponse.successWithInteractionCode?.value?.find( findCode )?.value as string;\n\n return {\n proceed,\n neededToProceed,\n actions,\n context,\n rawIdxState: rawIdxResponse,\n interactionCode,\n toPersist,\n requestDidSucceed,\n };\n}\n"],"mappings":";;;AAcA;AAdA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGuE;;AAGhE,SAASA,YAAY,CAC1BC,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
|
32
32
|
// Begin or resume a transaction. Returns an interaction handle
|
|
33
33
|
async function interact(authClient, options = {}) {
|
|
34
|
-
var _meta;
|
|
35
34
|
options = (0, _util.removeNils)(options);
|
|
36
35
|
let meta = (0, _transactionMeta.getSavedTransactionMeta)(authClient, options);
|
|
37
36
|
// If meta exists, it has been validated against all options
|
|
38
37
|
|
|
39
|
-
if (
|
|
38
|
+
if (meta?.interactionHandle) {
|
|
40
39
|
return getResponse(meta); // Saved transaction, return meta
|
|
41
40
|
}
|
|
42
41
|
|
package/cjs/idx/interact.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interact.js","names":["getResponse","meta","interactionHandle","state","interact","authClient","options","removeNils","getSavedTransactionMeta","createTransactionMeta","baseUrl","getOAuthBaseUrl","clientId","redirectUri","scopes","withCredentials","codeChallenge","codeChallengeMethod","activationToken","recoveryToken","maxAge","acrValues","nonce","clientSecret","url","params","client_id","scope","join","redirect_uri","code_challenge","code_challenge_method","activation_token","recovery_token","client_secret","max_age","acr_values","headers","resp","httpRequest","method","args","interaction_handle","newMeta","saveTransactionMeta"],"sources":["../../../lib/idx/interact.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-non-null-assertion */\n/*!\n * Copyright (c) 2021, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n/* eslint complexity:[0,8] */\nimport { OktaAuthIdxInterface, IdxTransactionMeta, InteractOptions, InteractResponse } from './types';\nimport { getSavedTransactionMeta, saveTransactionMeta, createTransactionMeta } from './transactionMeta';\nimport { getOAuthBaseUrl } from '../oidc';\nimport { removeNils } from '../util';\nimport { httpRequest } from '../http';\n\n\n/* eslint-disable camelcase */\nexport interface InteractParams {\n client_id: string;\n scope: string;\n redirect_uri: string;\n code_challenge: string;\n code_challenge_method: string;\n state: string;\n activation_token?: string;\n recovery_token?: string;\n client_secret?: string;\n max_age?: string | number;\n acr_values?: string;\n nonce?: string;\n}\n/* eslint-enable camelcase */\n\nfunction getResponse(meta: IdxTransactionMeta): InteractResponse {\n return {\n meta,\n interactionHandle: meta.interactionHandle!,\n state: meta.state\n };\n}\n\n// Begin or resume a transaction. Returns an interaction handle\nexport async function interact (\n authClient: OktaAuthIdxInterface, \n options: InteractOptions = {}\n): Promise<InteractResponse> {\n options = removeNils(options);\n\n let meta = getSavedTransactionMeta(authClient, options);\n // If meta exists, it has been validated against all options\n\n if (meta?.interactionHandle) {\n return getResponse(meta); // Saved transaction, return meta\n }\n\n // Create new meta, respecting previous meta if it has been set and is not overridden\n meta = await createTransactionMeta(authClient, { ...meta, ...options });\n const baseUrl = getOAuthBaseUrl(authClient);\n let {\n clientId,\n redirectUri,\n state,\n scopes,\n withCredentials,\n codeChallenge,\n codeChallengeMethod,\n activationToken,\n recoveryToken,\n maxAge,\n acrValues,\n nonce\n } = meta as IdxTransactionMeta;\n const clientSecret = options.clientSecret || authClient.options.clientSecret;\n withCredentials = withCredentials ?? true;\n\n /* eslint-disable camelcase */\n const url = `${baseUrl}/v1/interact`;\n const params = {\n client_id: clientId,\n scope: scopes!.join(' '),\n redirect_uri: redirectUri,\n code_challenge: codeChallenge,\n code_challenge_method: codeChallengeMethod,\n state,\n ...(activationToken && { activation_token: activationToken }),\n ...(recoveryToken && { recovery_token: recoveryToken }),\n // X-Device-Token header need to pair with `client_secret`\n // eslint-disable-next-line max-len\n // https://oktawiki.atlassian.net/wiki/spaces/eng/pages/2445902453/Support+Device+Binding+in+interact#Scenario-1%3A-Non-User-Agent-with-Confidential-Client-(top-priority)\n ...(clientSecret && { client_secret: clientSecret }),\n ...(maxAge && { max_age: maxAge }),\n ...(acrValues && { acr_values: acrValues }),\n ...(nonce && { nonce }),\n } as InteractParams;\n /* eslint-enable camelcase */\n\n const headers = {\n 'Content-Type': 'application/x-www-form-urlencoded',\n };\n\n const resp = await httpRequest(authClient, {\n method: 'POST',\n url,\n headers,\n withCredentials,\n args: params\n });\n const interactionHandle = resp.interaction_handle;\n\n const newMeta = {\n ...meta,\n interactionHandle,\n \n // Options which can be passed into interact() should be saved in the meta\n withCredentials,\n state,\n scopes,\n recoveryToken,\n activationToken\n };\n // Save transaction meta so it can be resumed\n saveTransactionMeta(authClient, newMeta);\n\n return getResponse(newMeta);\n}\n"],"mappings":";;;AAcA;AACA;AACA;AACA;AAjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAuBA;;AAEA,SAASA,WAAW,CAACC,IAAwB,EAAoB;EAC/D,OAAO;IACLA,IAAI;IACJC,iBAAiB,EAAED,IAAI,CAACC,iBAAkB;IAC1CC,KAAK,EAAEF,IAAI,CAACE;EACd,CAAC;AACH;;AAEA;AACO,eAAeC,QAAQ,CAC5BC,UAAgC,EAChCC,OAAwB,GAAG,CAAC,CAAC,EACF;
|
|
1
|
+
{"version":3,"file":"interact.js","names":["getResponse","meta","interactionHandle","state","interact","authClient","options","removeNils","getSavedTransactionMeta","createTransactionMeta","baseUrl","getOAuthBaseUrl","clientId","redirectUri","scopes","withCredentials","codeChallenge","codeChallengeMethod","activationToken","recoveryToken","maxAge","acrValues","nonce","clientSecret","url","params","client_id","scope","join","redirect_uri","code_challenge","code_challenge_method","activation_token","recovery_token","client_secret","max_age","acr_values","headers","resp","httpRequest","method","args","interaction_handle","newMeta","saveTransactionMeta"],"sources":["../../../lib/idx/interact.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-non-null-assertion */\n/*!\n * Copyright (c) 2021, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n/* eslint complexity:[0,8] */\nimport { OktaAuthIdxInterface, IdxTransactionMeta, InteractOptions, InteractResponse } from './types';\nimport { getSavedTransactionMeta, saveTransactionMeta, createTransactionMeta } from './transactionMeta';\nimport { getOAuthBaseUrl } from '../oidc';\nimport { removeNils } from '../util';\nimport { httpRequest } from '../http';\n\n\n/* eslint-disable camelcase */\nexport interface InteractParams {\n client_id: string;\n scope: string;\n redirect_uri: string;\n code_challenge: string;\n code_challenge_method: string;\n state: string;\n activation_token?: string;\n recovery_token?: string;\n client_secret?: string;\n max_age?: string | number;\n acr_values?: string;\n nonce?: string;\n}\n/* eslint-enable camelcase */\n\nfunction getResponse(meta: IdxTransactionMeta): InteractResponse {\n return {\n meta,\n interactionHandle: meta.interactionHandle!,\n state: meta.state\n };\n}\n\n// Begin or resume a transaction. Returns an interaction handle\nexport async function interact (\n authClient: OktaAuthIdxInterface, \n options: InteractOptions = {}\n): Promise<InteractResponse> {\n options = removeNils(options);\n\n let meta = getSavedTransactionMeta(authClient, options);\n // If meta exists, it has been validated against all options\n\n if (meta?.interactionHandle) {\n return getResponse(meta); // Saved transaction, return meta\n }\n\n // Create new meta, respecting previous meta if it has been set and is not overridden\n meta = await createTransactionMeta(authClient, { ...meta, ...options });\n const baseUrl = getOAuthBaseUrl(authClient);\n let {\n clientId,\n redirectUri,\n state,\n scopes,\n withCredentials,\n codeChallenge,\n codeChallengeMethod,\n activationToken,\n recoveryToken,\n maxAge,\n acrValues,\n nonce\n } = meta as IdxTransactionMeta;\n const clientSecret = options.clientSecret || authClient.options.clientSecret;\n withCredentials = withCredentials ?? true;\n\n /* eslint-disable camelcase */\n const url = `${baseUrl}/v1/interact`;\n const params = {\n client_id: clientId,\n scope: scopes!.join(' '),\n redirect_uri: redirectUri,\n code_challenge: codeChallenge,\n code_challenge_method: codeChallengeMethod,\n state,\n ...(activationToken && { activation_token: activationToken }),\n ...(recoveryToken && { recovery_token: recoveryToken }),\n // X-Device-Token header need to pair with `client_secret`\n // eslint-disable-next-line max-len\n // https://oktawiki.atlassian.net/wiki/spaces/eng/pages/2445902453/Support+Device+Binding+in+interact#Scenario-1%3A-Non-User-Agent-with-Confidential-Client-(top-priority)\n ...(clientSecret && { client_secret: clientSecret }),\n ...(maxAge && { max_age: maxAge }),\n ...(acrValues && { acr_values: acrValues }),\n ...(nonce && { nonce }),\n } as InteractParams;\n /* eslint-enable camelcase */\n\n const headers = {\n 'Content-Type': 'application/x-www-form-urlencoded',\n };\n\n const resp = await httpRequest(authClient, {\n method: 'POST',\n url,\n headers,\n withCredentials,\n args: params\n });\n const interactionHandle = resp.interaction_handle;\n\n const newMeta = {\n ...meta,\n interactionHandle,\n \n // Options which can be passed into interact() should be saved in the meta\n withCredentials,\n state,\n scopes,\n recoveryToken,\n activationToken\n };\n // Save transaction meta so it can be resumed\n saveTransactionMeta(authClient, newMeta);\n\n return getResponse(newMeta);\n}\n"],"mappings":";;;AAcA;AACA;AACA;AACA;AAjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAuBA;;AAEA,SAASA,WAAW,CAACC,IAAwB,EAAoB;EAC/D,OAAO;IACLA,IAAI;IACJC,iBAAiB,EAAED,IAAI,CAACC,iBAAkB;IAC1CC,KAAK,EAAEF,IAAI,CAACE;EACd,CAAC;AACH;;AAEA;AACO,eAAeC,QAAQ,CAC5BC,UAAgC,EAChCC,OAAwB,GAAG,CAAC,CAAC,EACF;EAC3BA,OAAO,GAAG,IAAAC,gBAAU,EAACD,OAAO,CAAC;EAE7B,IAAIL,IAAI,GAAG,IAAAO,wCAAuB,EAACH,UAAU,EAAEC,OAAO,CAAC;EACvD;;EAEA,IAAIL,IAAI,EAAEC,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EA,MAAMe,OAAO,GAAG;IACd,cAAc,EAAE;EAClB,CAAC;EAED,MAAMC,IAAI,GAAG,MAAM,IAAAC,iBAAW,EAAClC,UAAU,EAAE;IACzCmC,MAAM,EAAE,MAAM;IACdhB,GAAG;IACHa,OAAO;IACPtB,eAAe;IACf0B,IAAI,EAAEhB;EACR,CAAC,CAAC;EACF,MAAMvB,iBAAiB,GAAGoC,IAAI,CAACI,kBAAkB;EAEjD,MAAMC,OAAO,GAAG;IACd,GAAG1C,IAAI;IACPC,iBAAiB;IAEjB;IACAa,eAAe;IACfZ,KAAK;IACLW,MAAM;IACNK,aAAa;IACbD;EACF,CAAC;EACD;EACA,IAAA0B,oCAAmB,EAACvC,UAAU,EAAEsC,OAAO,CAAC;EAExC,OAAO3C,WAAW,CAAC2C,OAAO,CAAC;AAC7B"}
|
package/cjs/idx/poll.js
CHANGED
|
@@ -17,21 +17,19 @@ var _util = require("../util");
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
async function poll(authClient, options = {}) {
|
|
20
|
-
var _meta$remediations;
|
|
21
20
|
let transaction = await (0, _proceed.proceed)(authClient, {
|
|
22
21
|
startPolling: true
|
|
23
22
|
});
|
|
24
23
|
const meta = (0, _transactionMeta.getSavedTransactionMeta)(authClient);
|
|
25
|
-
let availablePollingRemeditaions = meta
|
|
26
|
-
if (!
|
|
24
|
+
let availablePollingRemeditaions = meta?.remediations?.find(remediation => remediation.includes('poll'));
|
|
25
|
+
if (!availablePollingRemeditaions?.length) {
|
|
27
26
|
(0, _util.warn)('No polling remediations available at the current IDX flow stage');
|
|
28
27
|
}
|
|
29
28
|
if (Number.isInteger(options.refresh)) {
|
|
30
29
|
return new Promise(function (resolve, reject) {
|
|
31
30
|
setTimeout(async function () {
|
|
32
31
|
try {
|
|
33
|
-
|
|
34
|
-
const refresh = (_transaction$nextStep = transaction.nextStep) === null || _transaction$nextStep === void 0 ? void 0 : (_transaction$nextStep2 = _transaction$nextStep.poll) === null || _transaction$nextStep2 === void 0 ? void 0 : _transaction$nextStep2.refresh;
|
|
32
|
+
const refresh = transaction.nextStep?.poll?.refresh;
|
|
35
33
|
if (refresh) {
|
|
36
34
|
resolve(poll(authClient, {
|
|
37
35
|
refresh
|
package/cjs/idx/poll.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poll.js","names":["poll","authClient","options","transaction","proceed","startPolling","meta","getSavedTransactionMeta","availablePollingRemeditaions","remediations","find","remediation","includes","length","warn","Number","isInteger","refresh","Promise","resolve","reject","setTimeout","nextStep","err"],"sources":["../../../lib/idx/poll.ts"],"sourcesContent":["/*!\n * Copyright (c) 2021-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { proceed } from './proceed';\n\nimport { \n IdxPollOptions,\n IdxTransaction,\n OktaAuthIdxInterface,\n} from './types';\nimport { getSavedTransactionMeta } from './transactionMeta';\nimport { warn } from '../util';\n\nexport async function poll(authClient: OktaAuthIdxInterface, options: IdxPollOptions = {}): Promise<IdxTransaction> {\n let transaction = await proceed(authClient, {\n startPolling: true\n });\n\n const meta = getSavedTransactionMeta(authClient);\n let availablePollingRemeditaions = meta?.remediations?.find(remediation => remediation.includes('poll'));\n if (!availablePollingRemeditaions?.length) {\n warn('No polling remediations available at the current IDX flow stage');\n }\n\n if (Number.isInteger(options.refresh)) {\n return new Promise(function (resolve, reject) {\n setTimeout(async function () {\n try {\n const refresh = transaction.nextStep?.poll?.refresh;\n if (refresh) {\n resolve(poll(authClient, {\n refresh\n }));\n } else {\n resolve(transaction);\n }\n } catch (err) {\n reject(err);\n }\n }, options.refresh);\n });\n }\n\n return transaction;\n}\n"],"mappings":";;;AAYA;AAOA;AACA;AApBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYO,eAAeA,IAAI,CAACC,UAAgC,EAAEC,OAAuB,GAAG,CAAC,CAAC,EAA2B;
|
|
1
|
+
{"version":3,"file":"poll.js","names":["poll","authClient","options","transaction","proceed","startPolling","meta","getSavedTransactionMeta","availablePollingRemeditaions","remediations","find","remediation","includes","length","warn","Number","isInteger","refresh","Promise","resolve","reject","setTimeout","nextStep","err"],"sources":["../../../lib/idx/poll.ts"],"sourcesContent":["/*!\n * Copyright (c) 2021-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { proceed } from './proceed';\n\nimport { \n IdxPollOptions,\n IdxTransaction,\n OktaAuthIdxInterface,\n} from './types';\nimport { getSavedTransactionMeta } from './transactionMeta';\nimport { warn } from '../util';\n\nexport async function poll(authClient: OktaAuthIdxInterface, options: IdxPollOptions = {}): Promise<IdxTransaction> {\n let transaction = await proceed(authClient, {\n startPolling: true\n });\n\n const meta = getSavedTransactionMeta(authClient);\n let availablePollingRemeditaions = meta?.remediations?.find(remediation => remediation.includes('poll'));\n if (!availablePollingRemeditaions?.length) {\n warn('No polling remediations available at the current IDX flow stage');\n }\n\n if (Number.isInteger(options.refresh)) {\n return new Promise(function (resolve, reject) {\n setTimeout(async function () {\n try {\n const refresh = transaction.nextStep?.poll?.refresh;\n if (refresh) {\n resolve(poll(authClient, {\n refresh\n }));\n } else {\n resolve(transaction);\n }\n } catch (err) {\n reject(err);\n }\n }, options.refresh);\n });\n }\n\n return transaction;\n}\n"],"mappings":";;;AAYA;AAOA;AACA;AApBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYO,eAAeA,IAAI,CAACC,UAAgC,EAAEC,OAAuB,GAAG,CAAC,CAAC,EAA2B;EAClH,IAAIC,WAAW,GAAG,MAAM,IAAAC,gBAAO,EAACH,UAAU,EAAE;IAC1CI,YAAY,EAAE;EAChB,CAAC,CAAC;EAEF,MAAMC,IAAI,GAAG,IAAAC,wCAAuB,EAACN,UAAU,CAAC;EAChD,IAAIO,4BAA4B,GAAGF,IAAI,EAAEG,YAAY,EAAEC,IAAI,CAACC,WAAW,IAAIA,WAAW,CAACC,QAAQ,CAAC,MAAM,CAAC,CAAC;EACxG,IAAI,CAACJ,4BAA4B,EAAEK,MAAM,EAAE;IACzC,IAAAC,UAAI,EAAC,iEAAiE,CAAC;EACzE;EAEA,IAAIC,MAAM,CAACC,SAAS,CAACd,OAAO,CAACe,OAAO,CAAC,EAAE;IACrC,OAAO,IAAIC,OAAO,CAAC,UAAUC,OAAO,EAAEC,MAAM,EAAE;MAC5CC,UAAU,CAAC,kBAAkB;QAC3B,IAAI;UACF,MAAMJ,OAAO,GAAGd,WAAW,CAACmB,QAAQ,EAAEtB,IAAI,EAAEiB,OAAO;UACnD,IAAIA,OAAO,EAAE;YACXE,OAAO,CAACnB,IAAI,CAACC,UAAU,EAAE;cACvBgB;YACF,CAAC,CAAC,CAAC;UACL,CAAC,MAAM;YACLE,OAAO,CAAChB,WAAW,CAAC;UACtB;QACF,CAAC,CAAC,OAAOoB,GAAG,EAAE;UACZH,MAAM,CAACG,GAAG,CAAC;QACb;MACF,CAAC,EAAErB,OAAO,CAACe,OAAO,CAAC;IACrB,CAAC,CAAC;EACJ;EAEA,OAAOd,WAAW;AACpB"}
|
package/cjs/idx/proceed.js
CHANGED
|
@@ -33,7 +33,7 @@ async function proceed(authClient, options = {}) {
|
|
|
33
33
|
const meta = (0, _transactionMeta.getSavedTransactionMeta)(authClient, {
|
|
34
34
|
state
|
|
35
35
|
});
|
|
36
|
-
flow = meta
|
|
36
|
+
flow = meta?.flow;
|
|
37
37
|
}
|
|
38
38
|
return (0, _run.run)(authClient, {
|
|
39
39
|
...options,
|
package/cjs/idx/proceed.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proceed.js","names":["canProceed","authClient","options","meta","getSavedTransactionMeta","stateHandle","proceed","AuthSdkError","flow","state","run"],"sources":["../../../lib/idx/proceed.ts"],"sourcesContent":["/*!\n * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * \n * See the License for the specific language governing permissions and limitations under the License.\n */\n\n\nimport { \n OktaAuthIdxInterface,\n IdxTransaction,\n ProceedOptions,\n} from './types';\nimport { run } from './run';\nimport { getSavedTransactionMeta } from './transactionMeta';\nimport { AuthSdkError } from '../errors';\n\nexport function canProceed(authClient: OktaAuthIdxInterface, options: ProceedOptions = {}): boolean {\n const meta = getSavedTransactionMeta(authClient, options);\n return !!(meta || options.stateHandle);\n}\n\nexport async function proceed(\n authClient: OktaAuthIdxInterface,\n options: ProceedOptions = {}\n): Promise<IdxTransaction> {\n\n if (!canProceed(authClient, options)) {\n throw new AuthSdkError('Unable to proceed: saved transaction could not be loaded');\n }\n\n let { flow, state } = options;\n if (!flow) {\n const meta = getSavedTransactionMeta(authClient, { state });\n flow = meta?.flow;\n }\n\n return run(authClient, { \n ...options, \n flow\n });\n}\n"],"mappings":";;;;AAkBA;AACA;AACA;AApBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYO,SAASA,UAAU,CAACC,UAAgC,EAAEC,OAAuB,GAAG,CAAC,CAAC,EAAW;EAClG,MAAMC,IAAI,GAAG,IAAAC,wCAAuB,EAACH,UAAU,EAAEC,OAAO,CAAC;EACzD,OAAO,CAAC,EAAEC,IAAI,IAAID,OAAO,CAACG,WAAW,CAAC;AACxC;AAEO,eAAeC,OAAO,CAC3BL,UAAgC,EAChCC,OAAuB,GAAG,CAAC,CAAC,EACH;EAEzB,IAAI,CAACF,UAAU,CAACC,UAAU,EAAEC,OAAO,CAAC,EAAE;IACpC,MAAM,IAAIK,oBAAY,CAAC,0DAA0D,CAAC;EACpF;EAEA,IAAI;IAAEC,IAAI;IAAEC;EAAM,CAAC,GAAGP,OAAO;EAC7B,IAAI,CAACM,IAAI,EAAE;IACT,MAAML,IAAI,GAAG,IAAAC,wCAAuB,EAACH,UAAU,EAAE;MAAEQ;IAAM,CAAC,CAAC;IAC3DD,IAAI,GAAGL,IAAI,
|
|
1
|
+
{"version":3,"file":"proceed.js","names":["canProceed","authClient","options","meta","getSavedTransactionMeta","stateHandle","proceed","AuthSdkError","flow","state","run"],"sources":["../../../lib/idx/proceed.ts"],"sourcesContent":["/*!\n * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * \n * See the License for the specific language governing permissions and limitations under the License.\n */\n\n\nimport { \n OktaAuthIdxInterface,\n IdxTransaction,\n ProceedOptions,\n} from './types';\nimport { run } from './run';\nimport { getSavedTransactionMeta } from './transactionMeta';\nimport { AuthSdkError } from '../errors';\n\nexport function canProceed(authClient: OktaAuthIdxInterface, options: ProceedOptions = {}): boolean {\n const meta = getSavedTransactionMeta(authClient, options);\n return !!(meta || options.stateHandle);\n}\n\nexport async function proceed(\n authClient: OktaAuthIdxInterface,\n options: ProceedOptions = {}\n): Promise<IdxTransaction> {\n\n if (!canProceed(authClient, options)) {\n throw new AuthSdkError('Unable to proceed: saved transaction could not be loaded');\n }\n\n let { flow, state } = options;\n if (!flow) {\n const meta = getSavedTransactionMeta(authClient, { state });\n flow = meta?.flow;\n }\n\n return run(authClient, { \n ...options, \n flow\n });\n}\n"],"mappings":";;;;AAkBA;AACA;AACA;AApBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYO,SAASA,UAAU,CAACC,UAAgC,EAAEC,OAAuB,GAAG,CAAC,CAAC,EAAW;EAClG,MAAMC,IAAI,GAAG,IAAAC,wCAAuB,EAACH,UAAU,EAAEC,OAAO,CAAC;EACzD,OAAO,CAAC,EAAEC,IAAI,IAAID,OAAO,CAACG,WAAW,CAAC;AACxC;AAEO,eAAeC,OAAO,CAC3BL,UAAgC,EAChCC,OAAuB,GAAG,CAAC,CAAC,EACH;EAEzB,IAAI,CAACF,UAAU,CAACC,UAAU,EAAEC,OAAO,CAAC,EAAE;IACpC,MAAM,IAAIK,oBAAY,CAAC,0DAA0D,CAAC;EACpF;EAEA,IAAI;IAAEC,IAAI;IAAEC;EAAM,CAAC,GAAGP,OAAO;EAC7B,IAAI,CAACM,IAAI,EAAE;IACT,MAAML,IAAI,GAAG,IAAAC,wCAAuB,EAACH,UAAU,EAAE;MAAEQ;IAAM,CAAC,CAAC;IAC3DD,IAAI,GAAGL,IAAI,EAAEK,IAAI;EACnB;EAEA,OAAO,IAAAE,QAAG,EAACT,UAAU,EAAE;IACrB,GAAGC,OAAO;IACVM;EACF,CAAC,CAAC;AACJ"}
|
|
@@ -55,7 +55,7 @@ class AuthenticatorData extends _Remediator.Remediator {
|
|
|
55
55
|
authenticator
|
|
56
56
|
} = this.values;
|
|
57
57
|
if (!methodType && (0, _api.isAuthenticator)(authenticator)) {
|
|
58
|
-
methodType = authenticator
|
|
58
|
+
methodType = authenticator?.methodType;
|
|
59
59
|
}
|
|
60
60
|
const {
|
|
61
61
|
id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthenticatorData.js","names":["AuthenticatorData","Remediator","constructor","remediation","values","authenticator","getAuthenticator","formatAuthenticatorData","authenticatorData","getAuthenticatorData","authenticatorsData","map","data","compareAuthenticators","mapAuthenticatorDataFromValues","push","find","canRemediate","some","methodType","isAuthenticator","id","enrollmentId","getAuthenticatorFromRemediation","value","name","getValuesAfterProceed","filter"],"sources":["../../../../../lib/idx/remediators/Base/AuthenticatorData.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-non-null-assertion */\n/*!\n * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * \n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { Remediator, RemediationValues } from './Remediator';\nimport { IdxRemediationValue, IdxRemediation, IdxAuthenticator } from '../../types/idx-js';\nimport { isAuthenticator } from '../../types/api';\nimport { compareAuthenticators } from '../../authenticator/util';\n\nexport type AuthenticatorDataValues = RemediationValues & {\n methodType?: string;\n};\n\n// Base class - DO NOT expose static remediationName\nexport class AuthenticatorData<T extends AuthenticatorDataValues = AuthenticatorDataValues> extends Remediator<T> {\n authenticator: IdxAuthenticator;\n\n constructor(remediation: IdxRemediation, values: T = {} as T) {\n super(remediation, values);\n\n // set before other data calculation\n this.authenticator = this.getAuthenticator()!;\n\n this.formatAuthenticatorData();\n }\n\n protected formatAuthenticatorData() {\n const authenticatorData = this.getAuthenticatorData();\n if (authenticatorData) {\n this.values.authenticatorsData = this.values.authenticatorsData!.map(data => {\n if (compareAuthenticators(this.authenticator, data)) {\n return this.mapAuthenticatorDataFromValues(data);\n }\n return data;\n });\n } else {\n const data = this.mapAuthenticatorDataFromValues();\n if (data) {\n this.values.authenticatorsData!.push(data);\n }\n }\n }\n\n protected getAuthenticatorData() {\n return this.values.authenticatorsData!\n .find((data) => compareAuthenticators(this.authenticator, data));\n }\n\n canRemediate() {\n return this.values.authenticatorsData!\n .some(data => compareAuthenticators(this.authenticator, data));\n }\n\n protected mapAuthenticatorDataFromValues(authenticatorData?) {\n // add methodType to authenticatorData if it exists in values\n let { methodType, authenticator } = this.values;\n if (!methodType && isAuthenticator(authenticator)) {\n methodType = authenticator?.methodType;\n }\n \n const { id, enrollmentId } = this.authenticator;\n const data = { \n id,\n enrollmentId,\n ...(authenticatorData && authenticatorData),\n ...(methodType && { methodType }) \n };\n\n return data.methodType ? data : null;\n }\n\n protected getAuthenticatorFromRemediation(): IdxRemediationValue {\n const authenticator = this.remediation.value!\n .find(({ name }) => name === 'authenticator') as IdxRemediationValue;\n return authenticator;\n }\n\n getValuesAfterProceed(): T {\n this.values = super.getValuesAfterProceed();\n // remove used authenticatorData\n const authenticatorsData = this.values.authenticatorsData!\n .filter(data => compareAuthenticators(this.authenticator, data) !== true);\n return { ...this.values, authenticatorsData };\n }\n}\n"],"mappings":";;;AAaA;AAEA;AACA;AAhBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWA;AACO,MAAMA,iBAAiB,SAAsEC,sBAAU,CAAI;EAGhHC,WAAW,CAACC,WAA2B,EAAEC,MAAS,GAAG,CAAC,CAAM,EAAE;IAC5D,KAAK,CAACD,WAAW,EAAEC,MAAM,CAAC;;IAE1B;IACA,IAAI,CAACC,aAAa,GAAG,IAAI,CAACC,gBAAgB,EAAG;IAE7C,IAAI,CAACC,uBAAuB,EAAE;EAChC;EAEUA,uBAAuB,GAAG;IAClC,MAAMC,iBAAiB,GAAG,IAAI,CAACC,oBAAoB,EAAE;IACrD,IAAID,iBAAiB,EAAE;MACrB,IAAI,CAACJ,MAAM,CAACM,kBAAkB,GAAG,IAAI,CAACN,MAAM,CAACM,kBAAkB,CAAEC,GAAG,CAACC,IAAI,IAAI;QAC3E,IAAI,IAAAC,2BAAqB,EAAC,IAAI,CAACR,aAAa,EAAEO,IAAI,CAAC,EAAE;UACnD,OAAO,IAAI,CAACE,8BAA8B,CAACF,IAAI,CAAC;QAClD;QACA,OAAOA,IAAI;MACb,CAAC,CAAC;IACJ,CAAC,MAAM;MACL,MAAMA,IAAI,GAAG,IAAI,CAACE,8BAA8B,EAAE;MAClD,IAAIF,IAAI,EAAE;QACR,IAAI,CAACR,MAAM,CAACM,kBAAkB,CAAEK,IAAI,CAACH,IAAI,CAAC;MAC5C;IACF;EACF;EAEUH,oBAAoB,GAAG;IAC/B,OAAO,IAAI,CAACL,MAAM,CAACM,kBAAkB,CAClCM,IAAI,CAAEJ,IAAI,IAAK,IAAAC,2BAAqB,EAAC,IAAI,CAACR,aAAa,EAAEO,IAAI,CAAC,CAAC;EACpE;EAEAK,YAAY,GAAG;IACb,OAAO,IAAI,CAACb,MAAM,CAACM,kBAAkB,CAClCQ,IAAI,CAACN,IAAI,IAAI,IAAAC,2BAAqB,EAAC,IAAI,CAACR,aAAa,EAAEO,IAAI,CAAC,CAAC;EAClE;EAEUE,8BAA8B,CAACN,iBAAkB,EAAE;IAC3D;IACA,IAAI;MAAEW,UAAU;MAAEd;IAAc,CAAC,GAAG,IAAI,CAACD,MAAM;IAC/C,IAAI,CAACe,UAAU,IAAI,IAAAC,oBAAe,EAACf,aAAa,CAAC,EAAE;MAClDc,UAAU,GAAGd,aAAa,
|
|
1
|
+
{"version":3,"file":"AuthenticatorData.js","names":["AuthenticatorData","Remediator","constructor","remediation","values","authenticator","getAuthenticator","formatAuthenticatorData","authenticatorData","getAuthenticatorData","authenticatorsData","map","data","compareAuthenticators","mapAuthenticatorDataFromValues","push","find","canRemediate","some","methodType","isAuthenticator","id","enrollmentId","getAuthenticatorFromRemediation","value","name","getValuesAfterProceed","filter"],"sources":["../../../../../lib/idx/remediators/Base/AuthenticatorData.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-non-null-assertion */\n/*!\n * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * \n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { Remediator, RemediationValues } from './Remediator';\nimport { IdxRemediationValue, IdxRemediation, IdxAuthenticator } from '../../types/idx-js';\nimport { isAuthenticator } from '../../types/api';\nimport { compareAuthenticators } from '../../authenticator/util';\n\nexport type AuthenticatorDataValues = RemediationValues & {\n methodType?: string;\n};\n\n// Base class - DO NOT expose static remediationName\nexport class AuthenticatorData<T extends AuthenticatorDataValues = AuthenticatorDataValues> extends Remediator<T> {\n authenticator: IdxAuthenticator;\n\n constructor(remediation: IdxRemediation, values: T = {} as T) {\n super(remediation, values);\n\n // set before other data calculation\n this.authenticator = this.getAuthenticator()!;\n\n this.formatAuthenticatorData();\n }\n\n protected formatAuthenticatorData() {\n const authenticatorData = this.getAuthenticatorData();\n if (authenticatorData) {\n this.values.authenticatorsData = this.values.authenticatorsData!.map(data => {\n if (compareAuthenticators(this.authenticator, data)) {\n return this.mapAuthenticatorDataFromValues(data);\n }\n return data;\n });\n } else {\n const data = this.mapAuthenticatorDataFromValues();\n if (data) {\n this.values.authenticatorsData!.push(data);\n }\n }\n }\n\n protected getAuthenticatorData() {\n return this.values.authenticatorsData!\n .find((data) => compareAuthenticators(this.authenticator, data));\n }\n\n canRemediate() {\n return this.values.authenticatorsData!\n .some(data => compareAuthenticators(this.authenticator, data));\n }\n\n protected mapAuthenticatorDataFromValues(authenticatorData?) {\n // add methodType to authenticatorData if it exists in values\n let { methodType, authenticator } = this.values;\n if (!methodType && isAuthenticator(authenticator)) {\n methodType = authenticator?.methodType;\n }\n \n const { id, enrollmentId } = this.authenticator;\n const data = { \n id,\n enrollmentId,\n ...(authenticatorData && authenticatorData),\n ...(methodType && { methodType }) \n };\n\n return data.methodType ? data : null;\n }\n\n protected getAuthenticatorFromRemediation(): IdxRemediationValue {\n const authenticator = this.remediation.value!\n .find(({ name }) => name === 'authenticator') as IdxRemediationValue;\n return authenticator;\n }\n\n getValuesAfterProceed(): T {\n this.values = super.getValuesAfterProceed();\n // remove used authenticatorData\n const authenticatorsData = this.values.authenticatorsData!\n .filter(data => compareAuthenticators(this.authenticator, data) !== true);\n return { ...this.values, authenticatorsData };\n }\n}\n"],"mappings":";;;AAaA;AAEA;AACA;AAhBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWA;AACO,MAAMA,iBAAiB,SAAsEC,sBAAU,CAAI;EAGhHC,WAAW,CAACC,WAA2B,EAAEC,MAAS,GAAG,CAAC,CAAM,EAAE;IAC5D,KAAK,CAACD,WAAW,EAAEC,MAAM,CAAC;;IAE1B;IACA,IAAI,CAACC,aAAa,GAAG,IAAI,CAACC,gBAAgB,EAAG;IAE7C,IAAI,CAACC,uBAAuB,EAAE;EAChC;EAEUA,uBAAuB,GAAG;IAClC,MAAMC,iBAAiB,GAAG,IAAI,CAACC,oBAAoB,EAAE;IACrD,IAAID,iBAAiB,EAAE;MACrB,IAAI,CAACJ,MAAM,CAACM,kBAAkB,GAAG,IAAI,CAACN,MAAM,CAACM,kBAAkB,CAAEC,GAAG,CAACC,IAAI,IAAI;QAC3E,IAAI,IAAAC,2BAAqB,EAAC,IAAI,CAACR,aAAa,EAAEO,IAAI,CAAC,EAAE;UACnD,OAAO,IAAI,CAACE,8BAA8B,CAACF,IAAI,CAAC;QAClD;QACA,OAAOA,IAAI;MACb,C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AqB,GAAM;IACzB,IAAI,CAACtB,MAAM,GAAG,KAAK,CAACsB,qBAAqB,EAAE;IAC3C;IACA,MAAMhB,kBAAkB,GAAG,IAAI,CAACN,MAAM,CAACM,kBAAkB,CACtDiB,MAAM,CAACf,IAAI,IAAI,IAAAC,2BAAqB,EAAC,IAAI,CAACR,aAAa,EAAEO,IAAI,CAAC,KAAK,IAAI,CAAC;IAC3E,OAAO;MAAE,GAAG,IAAI,CAACR,MAAM;MAAEM;IAAmB,CAAC;EAC/C;AACF;AAAC"}
|
|
@@ -121,7 +121,7 @@ class Remediator {
|
|
|
121
121
|
const authenticator = this.getAuthenticator();
|
|
122
122
|
// TODO: remove type field in the next major version change
|
|
123
123
|
// https://oktainc.atlassian.net/browse/OKTA-431749
|
|
124
|
-
const type = authenticator
|
|
124
|
+
const type = authenticator?.type;
|
|
125
125
|
return {
|
|
126
126
|
name,
|
|
127
127
|
inputs,
|
|
@@ -185,11 +185,10 @@ class Remediator {
|
|
|
185
185
|
return inputs;
|
|
186
186
|
}
|
|
187
187
|
static getMessages(remediation) {
|
|
188
|
-
var _remediation$value$, _remediation$value$$f;
|
|
189
188
|
if (!remediation.value) {
|
|
190
189
|
return;
|
|
191
190
|
}
|
|
192
|
-
return
|
|
191
|
+
return remediation.value[0]?.form?.value.reduce((messages, field) => {
|
|
193
192
|
if (field.messages) {
|
|
194
193
|
messages = [...messages, ...field.messages.value];
|
|
195
194
|
}
|
|
@@ -211,9 +210,8 @@ class Remediator {
|
|
|
211
210
|
return this.values;
|
|
212
211
|
}
|
|
213
212
|
getAuthenticator() {
|
|
214
|
-
var _this$remediation$rel, _value$find;
|
|
215
213
|
// relatesTo value may be an authenticator or an authenticatorEnrollment
|
|
216
|
-
const relatesTo =
|
|
214
|
+
const relatesTo = this.remediation.relatesTo?.value;
|
|
217
215
|
if (!relatesTo) {
|
|
218
216
|
return;
|
|
219
217
|
}
|
|
@@ -228,9 +226,9 @@ class Remediator {
|
|
|
228
226
|
const id = authenticatorFromRemediation.form.value.find(({
|
|
229
227
|
name
|
|
230
228
|
}) => name === 'id').value;
|
|
231
|
-
const enrollmentId =
|
|
229
|
+
const enrollmentId = authenticatorFromRemediation.form.value.find(({
|
|
232
230
|
name
|
|
233
|
-
}) => name === 'enrollmentId')
|
|
231
|
+
}) => name === 'enrollmentId')?.value;
|
|
234
232
|
return {
|
|
235
233
|
...relatesTo,
|
|
236
234
|
id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Remediator.js","names":["Remediator","constructor","remediation","values","options","formatAuthenticators","authenticators","map","authenticator","formatAuthenticator","hasAuthenticatorInList","some","existing","compareAuthenticators","push","authenticatorsData","reduce","acc","Object","keys","length","getName","name","canRemediate","context","required","getRequiredValues","needed","find","key","hasData","getData","allValues","getAllValues","res","data","titleCase","val","value","entry","i","getNextStep","_authClient","_context","inputs","getInputs","getAuthenticator","type","inputsFromRemediation","forEach","inputFromRemediation","input","visible","messages","alias","aliases","includes","Array","isArray","getMessages","form","field","getValuesAfterProceed","inputsFromRemediator","relatesTo","authenticatorFromRemediation","getAuthenticatorFromRemediation","id","enrollmentId"],"sources":["../../../../../lib/idx/remediators/Base/Remediator.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-non-null-assertion */\n/*!\n * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * \n * See the License for the specific language governing permissions and limitations under the License.\n */\n\n\n/* eslint-disable complexity */\nimport { OktaAuthIdxInterface, NextStep, IdxMessage, Authenticator, Input, RemediateOptions } from '../../types';\nimport { IdxAuthenticator, IdxRemediation, IdxContext } from '../../types/idx-js';\nimport { getAllValues, getRequiredValues, titleCase, getAuthenticatorFromRemediation } from '../util';\nimport { formatAuthenticator, compareAuthenticators } from '../../authenticator/util';\n\n// A map from IDX data values (server spec) to RemediationValues (client spec)\nexport type IdxToRemediationValueMap = Record<string, string[]>;\n\nexport interface RemediationValues {\n stateHandle?: string;\n authenticators?: (Authenticator | string)[];\n authenticator?: string | Authenticator;\n authenticatorsData?: Authenticator[];\n resend?: boolean;\n}\n\nexport interface RemediatorConstructor {\n remediationName: string;\n new<T extends RemediationValues>(\n remediation: IdxRemediation, \n values?: T, \n options?: RemediateOptions\n ): any;\n}\n\n// Base class - DO NOT expose static remediationName\nexport class Remediator<T extends RemediationValues = RemediationValues> {\n static remediationName: string;\n\n remediation: IdxRemediation;\n values: T;\n options: RemediateOptions;\n map?: IdxToRemediationValueMap;\n\n constructor(\n remediation: IdxRemediation, \n values: T = {} as T, \n options: RemediateOptions = {}\n ) {\n // assign fields to the instance\n this.values = { ...values };\n this.options = { ...options };\n this.formatAuthenticators();\n this.remediation = remediation;\n }\n\n private formatAuthenticators() {\n this.values.authenticators = (this.values.authenticators || []) as Authenticator[];\n\n // ensure authenticators are in the correct format\n this.values.authenticators = this.values.authenticators.map(authenticator => {\n return formatAuthenticator(authenticator);\n });\n\n // add authenticator (if any) to \"authenticators\"\n if (this.values.authenticator) {\n const authenticator = formatAuthenticator(this.values.authenticator);\n const hasAuthenticatorInList = this.values.authenticators.some(existing => {\n return compareAuthenticators(authenticator, existing);\n });\n if (!hasAuthenticatorInList) {\n this.values.authenticators.push(authenticator);\n }\n }\n\n // save non-key meta to \"authenticatorsData\" field\n // authenticators will be removed after selection to avoid select-authenticator loop\n this.values.authenticatorsData = this.values.authenticators.reduce((acc, authenticator) => {\n if (typeof authenticator === 'object' && Object.keys(authenticator).length > 1) {\n // save authenticator meta into authenticator data\n acc.push(authenticator);\n }\n return acc;\n }, this.values.authenticatorsData || []);\n }\n\n getName(): string {\n return this.remediation.name;\n }\n\n // Override this method to provide custom check\n /* eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars */\n canRemediate(context?: IdxContext): boolean {\n const required = getRequiredValues(this.remediation);\n const needed = required!.find((key) => !this.hasData(key));\n if (needed) {\n return false; // missing data for a required field\n }\n return true; // all required fields have available data\n }\n\n // returns an object for the entire remediation form, or just a part\n getData(key?: string) {\n if (!key) {\n let allValues = getAllValues(this.remediation);\n let res = allValues!.reduce((data, key) => {\n data[key] = this.getData(key); // recursive\n return data;\n }, {});\n return res;\n }\n\n // Map value by \"map${Property}\" function in each subClass\n if (typeof this[`map${titleCase(key)}`] === 'function') {\n const val = this[`map${titleCase(key)}`](\n this.remediation.value!.find(({name}) => name === key)\n );\n if (val) {\n return val;\n }\n }\n\n // If a map is defined for this key, return the first aliased property that returns a truthy value\n if (this.map && this.map[key]) {\n const entry = this.map[key];\n for (let i = 0; i < entry.length; i++) {\n let val = this.values[entry[i]];\n if (val) {\n return val;\n }\n }\n }\n\n // fallback: return the value by key\n return this.values[key];\n }\n\n hasData(\n key: string // idx name\n ): boolean \n {\n // no attempt to format, we want simple true/false\n return !!this.getData(key);\n }\n\n getNextStep(_authClient: OktaAuthIdxInterface, _context?: IdxContext): NextStep {\n const name = this.getName();\n const inputs = this.getInputs();\n const authenticator = this.getAuthenticator();\n // TODO: remove type field in the next major version change\n // https://oktainc.atlassian.net/browse/OKTA-431749\n const type = authenticator?.type;\n return { \n name, \n inputs, \n ...(type && { type }),\n ...(authenticator && { authenticator }),\n };\n }\n\n // Get inputs for the next step\n getInputs(): Input[] {\n const inputs: Input[] = [];\n const inputsFromRemediation = this.remediation.value || [];\n inputsFromRemediation.forEach(inputFromRemediation => {\n let input;\n let { name, type, visible, messages } = inputFromRemediation;\n if (visible === false) {\n return; // Filter out invisible inputs, like stateHandle\n }\n if (typeof this[`getInput${titleCase(name)}`] === 'function') {\n input = this[`getInput${titleCase(name)}`](inputFromRemediation);\n } else if (type !== 'object') {\n // handle general primitive types\n let alias;\n const aliases = (this.map ? this.map[name] : null) || [];\n if (aliases.length === 1) {\n alias = aliases[0];\n } else {\n // try find key from values\n alias = aliases.find(name => Object.keys(this.values).includes(name));\n }\n if (alias) {\n input = { ...inputFromRemediation, name: alias };\n }\n }\n if (!input) {\n input = inputFromRemediation;\n }\n if (Array.isArray(input)) {\n input.forEach(i => inputs.push(i));\n } else {\n // guarantees field-level messages are passed back\n if (messages) {\n input.messages = messages;\n }\n inputs.push(input);\n }\n });\n return inputs;\n }\n\n static getMessages(remediation: IdxRemediation): IdxMessage[] | undefined {\n if (!remediation.value) {\n return;\n }\n return remediation.value[0]?.form?.value.reduce((messages: IdxMessage[], field) => {\n if (field.messages) {\n messages = [...messages, ...field.messages.value];\n }\n return messages;\n }, []);\n }\n\n // Prepare values for the next remediation\n // In general, remove used values from inputs for the current remediation\n // Override this method if special cases need be handled\n getValuesAfterProceed(): T {\n const inputsFromRemediation = this.remediation.value || []; // \"raw\" inputs from server response\n const inputsFromRemediator = this.getInputs(); // \"aliased\" inputs from SDK remediator\n const inputs = [\n ...inputsFromRemediation,\n ...inputsFromRemediator\n ];\n // scrub all values related to this remediation\n for (const input of inputs) {\n delete this.values[input.name];\n }\n return this.values;\n }\n\n protected getAuthenticator(): IdxAuthenticator | undefined {\n // relatesTo value may be an authenticator or an authenticatorEnrollment\n const relatesTo = this.remediation.relatesTo?.value;\n if (!relatesTo) {\n return;\n }\n\n const authenticatorFromRemediation = getAuthenticatorFromRemediation(this.remediation);\n if (!authenticatorFromRemediation) {\n // Hopefully value is an authenticator\n return relatesTo;\n }\n\n // If relatesTo is an authenticatorEnrollment, the id is actually the enrollmentId\n // Let's get the correct authenticator id from the form value\n const id = authenticatorFromRemediation.form!.value\n .find(({ name }) => name === 'id')!.value as string;\n const enrollmentId = authenticatorFromRemediation.form!.value\n .find(({ name }) => name === 'enrollmentId')?.value as string;\n\n return {\n ...relatesTo,\n id,\n enrollmentId\n };\n }\n}\n"],"mappings":";;;AAiBA;AACA;AAlBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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EAAE;MACd;IACF;IAEA,MAAMC,4BAA4B,GAAG,IAAAC,qCAA+B,EAAC,IAAI,CAAChE,WAAW,CAAC;IACtF,IAAI,CAAC+D,4BAA4B,EAAE;MACjC;MACA,OAAOD,SAAS;IAClB;;IAEA;IACA;IACA,MAAMG,EAAE,GAAGF,4BAA4B,CAACL,IAAI,CAAEtB,KAAK,CAChDV,IAAI,CAAC,CAAC;MAAEN;IAAK,CAAC,KAAKA,IAAI,KAAK,IAAI,CAAC,CAAEgB,KAAe;IACrD,MAAM8B,YAAY,kBAAGH,4BAA4B,CAACL,IAAI,CAAEtB,KAAK,CAC1DV,IAAI,CAAC,CAAC;MAAEN;IAAK,CAAC,KAAKA,IAAI,KAAK,cAAc,CAAC,gDADzB,YAC2BgB,KAAe;IAE/D,OAAO;MACL,GAAG0B,SAAS;MACZG,EAAE;MACFC;IACF,CAAC;EACH;AACF;AAAC"}
|
|
1
|
+
{"version":3,"file":"Remediator.js","names":["Remediator","constructor","remediation","values","options","formatAuthenticators","authenticators","map","authenticator","formatAuthenticator","hasAuthenticatorInList","some","existing","compareAuthenticators","push","authenticatorsData","reduce","acc","Object","keys","length","getName","name","canRemediate","context","required","getRequiredValues","needed","find","key","hasData","getData","allValues","getAllValues","res","data","titleCase","val","value","entry","i","getNextStep","_authClient","_context","inputs","getInputs","getAuthenticator","type","inputsFromRemediation","forEach","inputFromRemediation","input","visible","messages","alias","aliases","includes","Array","isArray","getMessages","form","field","getValuesAfterProceed","inputsFromRemediator","relatesTo","authenticatorFromRemediation","getAuthenticatorFromRemediation","id","enrollmentId"],"sources":["../../../../../lib/idx/remediators/Base/Remediator.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-non-null-assertion */\n/*!\n * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * \n * See the License for the specific language governing permissions and limitations under the License.\n */\n\n\n/* eslint-disable complexity */\nimport { OktaAuthIdxInterface, NextStep, IdxMessage, Authenticator, Input, RemediateOptions } from '../../types';\nimport { IdxAuthenticator, IdxRemediation, IdxContext } from '../../types/idx-js';\nimport { getAllValues, getRequiredValues, titleCase, getAuthenticatorFromRemediation } from '../util';\nimport { formatAuthenticator, compareAuthenticators } from '../../authenticator/util';\n\n// A map from IDX data values (server spec) to RemediationValues (client spec)\nexport type IdxToRemediationValueMap = Record<string, string[]>;\n\nexport interface RemediationValues {\n stateHandle?: string;\n authenticators?: (Authenticator | string)[];\n authenticator?: string | Authenticator;\n authenticatorsData?: Authenticator[];\n resend?: boolean;\n}\n\nexport interface RemediatorConstructor {\n remediationName: string;\n new<T extends RemediationValues>(\n remediation: IdxRemediation, \n values?: T, \n options?: RemediateOptions\n ): any;\n}\n\n// Base class - DO NOT expose static remediationName\nexport class Remediator<T extends RemediationValues = RemediationValues> {\n static remediationName: string;\n\n remediation: IdxRemediation;\n values: T;\n options: RemediateOptions;\n map?: IdxToRemediationValueMap;\n\n constructor(\n remediation: IdxRemediation, \n values: T = {} as T, \n options: RemediateOptions = {}\n ) {\n // assign fields to the instance\n this.values = { ...values };\n this.options = { ...options };\n this.formatAuthenticators();\n this.remediation = remediation;\n }\n\n private formatAuthenticators() {\n this.values.authenticators = (this.values.authenticators || []) as Authenticator[];\n\n // ensure authenticators are in the correct format\n this.values.authenticators = this.values.authenticators.map(authenticator => {\n return formatAuthenticator(authenticator);\n });\n\n // add authenticator (if any) to \"authenticators\"\n if (this.values.authenticator) {\n const authenticator = formatAuthenticator(this.values.authenticator);\n const hasAuthenticatorInList = this.values.authenticators.some(existing => {\n return compareAuthenticators(authenticator, existing);\n });\n if (!hasAuthenticatorInList) {\n this.values.authenticators.push(authenticator);\n }\n }\n\n // save non-key meta to \"authenticatorsData\" field\n // authenticators will be removed after selection to avoid select-authenticator loop\n this.values.authenticatorsData = this.values.authenticators.reduce((acc, authenticator) => {\n if (typeof authenticator === 'object' && Object.keys(authenticator).length > 1) {\n // save authenticator meta into authenticator data\n acc.push(authenticator);\n }\n return acc;\n }, this.values.authenticatorsData || []);\n }\n\n getName(): string {\n return this.remediation.name;\n }\n\n // Override this method to provide custom check\n /* eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars */\n canRemediate(context?: IdxContext): boolean {\n const required = getRequiredValues(this.remediation);\n const needed = required!.find((key) => !this.hasData(key));\n if (needed) {\n return false; // missing data for a required field\n }\n return true; // all required fields have available data\n }\n\n // returns an object for the entire remediation form, or just a part\n getData(key?: string) {\n if (!key) {\n let allValues = getAllValues(this.remediation);\n let res = allValues!.reduce((data, key) => {\n data[key] = this.getData(key); // recursive\n return data;\n }, {});\n return res;\n }\n\n // Map value by \"map${Property}\" function in each subClass\n if (typeof this[`map${titleCase(key)}`] === 'function') {\n const val = this[`map${titleCase(key)}`](\n this.remediation.value!.find(({name}) => name === key)\n );\n if (val) {\n return val;\n }\n }\n\n // If a map is defined for this key, return the first aliased property that returns a truthy value\n if (this.map && this.map[key]) {\n const entry = this.map[key];\n for (let i = 0; i < entry.length; i++) {\n let val = this.values[entry[i]];\n if (val) {\n return val;\n }\n }\n }\n\n // fallback: return the value by key\n return this.values[key];\n }\n\n hasData(\n key: string // idx name\n ): boolean \n {\n // no attempt to format, we want simple true/false\n return !!this.getData(key);\n }\n\n getNextStep(_authClient: OktaAuthIdxInterface, _context?: IdxContext): NextStep {\n const name = this.getName();\n const inputs = this.getInputs();\n const authenticator = this.getAuthenticator();\n // TODO: remove type field in the next major version change\n // https://oktainc.atlassian.net/browse/OKTA-431749\n const type = authenticator?.type;\n return { \n name, \n inputs, \n ...(type && { type }),\n ...(authenticator && { authenticator }),\n };\n }\n\n // Get inputs for the next step\n getInputs(): Input[] {\n const inputs: Input[] = [];\n const inputsFromRemediation = this.remediation.value || [];\n inputsFromRemediation.forEach(inputFromRemediation => {\n let input;\n let { name, type, visible, messages } = inputFromRemediation;\n if (visible === false) {\n return; // Filter out invisible inputs, like stateHandle\n }\n if (typeof this[`getInput${titleCase(name)}`] === 'function') {\n input = this[`getInput${titleCase(name)}`](inputFromRemediation);\n } else if (type !== 'object') {\n // handle general primitive types\n let alias;\n const aliases = (this.map ? this.map[name] : null) || [];\n if (aliases.length === 1) {\n alias = aliases[0];\n } else {\n // try find key from values\n alias = aliases.find(name => Object.keys(this.values).includes(name));\n }\n if (alias) {\n input = { ...inputFromRemediation, name: alias };\n }\n }\n if (!input) {\n input = inputFromRemediation;\n }\n if (Array.isArray(input)) {\n input.forEach(i => inputs.push(i));\n } else {\n // guarantees field-level messages are passed back\n if (messages) {\n input.messages = messages;\n }\n inputs.push(input);\n }\n });\n return inputs;\n }\n\n static getMessages(remediation: IdxRemediation): IdxMessage[] | undefined {\n if (!remediation.value) {\n return;\n }\n return remediation.value[0]?.form?.value.reduce((messages: IdxMessage[], field) => {\n if (field.messages) {\n messages = [...messages, ...field.messages.value];\n }\n return messages;\n }, []);\n }\n\n // Prepare values for the next remediation\n // In general, remove used values from inputs for the current remediation\n // Override this method if special cases need be handled\n getValuesAfterProceed(): T {\n const inputsFromRemediation = this.remediation.value || []; // \"raw\" inputs from server response\n const inputsFromRemediator = this.getInputs(); // \"aliased\" inputs from SDK remediator\n const inputs = [\n ...inputsFromRemediation,\n ...inputsFromRemediator\n ];\n // scrub all values related to this remediation\n for (const input of inputs) {\n delete this.values[input.name];\n }\n return this.values;\n }\n\n protected getAuthenticator(): IdxAuthenticator | undefined {\n // relatesTo value may be an authenticator or an authenticatorEnrollment\n const relatesTo = this.remediation.relatesTo?.value;\n if (!relatesTo) {\n return;\n }\n\n const authenticatorFromRemediation = getAuthenticatorFromRemediation(this.remediation);\n if (!authenticatorFromRemediation) {\n // Hopefully value is an authenticator\n return relatesTo;\n }\n\n // If relatesTo is an authenticatorEnrollment, the id is actually the enrollmentId\n // Let's get the correct authenticator id from the form value\n const id = authenticatorFromRemediation.form!.value\n .find(({ name }) => name === 'id')!.value as string;\n const enrollmentId = authenticatorFromRemediation.form!.value\n .find(({ name }) => name === 'enrollmentId')?.value as string;\n\n return {\n ...relatesTo,\n id,\n enrollmentId\n };\n }\n}\n"],"mappings":";;;AAiBA;AACA;AAlBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;;AA0BA;AACO,MAAMA,UAAU,CAAkD;EAQvEC,WAAW,CACTC,WAA2B,EAC3BC,MAAS,GAAG,CAAC,CAAM,EACnBC,OAAyB,GAAG,CAAC,CAAC,EAC9B;IACA;IACA,IAAI,CAACD,MAAM,GAAG;MAAE,GAAGA;IAAO,CAAC;IAC3B,IAAI,CAACC,OAAO,GAAG;MAAE,GAAGA;IAAQ,CAAC;IAC7B,IAAI,CAACC,oBAAoB,EAAE;IAC3B,IAAI,CAACH,WAAW,GAAGA,WAAW;EAChC;EAEQG,oBAAoB,GAAG;IAC7B,IAAI,CAACF,MAAM,CAACG,cAAc,GAAI,IAAI,CAACH,MAAM,CAACG,cAAc,IAAI,EAAsB;;IAElF;IACA,IAAI,CAACH,MAAM,CAACG,cAAc,GAAG,IAAI,CAACH,MAAM,CAACG,cAAc,CAACC,GAAG,CAACC,aAAa,IAAI;MAC3E,OAAO,IAAAC,0BAAmB,EAACD,aAAa,CAAC;IAC3C,CAAC,CAAC;;IAEF;IACA,IAAI,IAAI,CAACL,MAAM,CAACK,aAAa,EAAE;MAC7B,MAAMA,aAAa,GAAG,IAAAC,0BAAmB,EAAC,IAAI,CAACN,MAAM,CAACK,aAAa,CAAC;MACpE,MAAME,sBAAsB,GAAG,IAAI,CAACP,MAAM,CAACG,cAAc,CAACK,IAAI,CAACC,QAAQ,IAAI;QACzE,OAAO,IAAAC,4BAAqB,EAACL,aAAa,EAAEI,QAAQ,CAAC;MACvD,CAAC,CAAC;MACF,IAAI,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CAACgD,KAAK,CAAC7B,IAAI,CAAC;IAChC;IACA,OAAO,IAAI,CAACnB,MAAM;EACpB;EAEU2C,gBAAgB,GAAiC;IACzD;IACA,MAAMkB,SAAS,GAAG,IAAI,CAAC9D,WAAW,CAAC8D,SAAS,EAAE1B,KAAK;IACnD,IAAI,CAAC0B,SAAS,EAAE;MACd;IACF;IAEA,MAAMC,4BAA4B,GAAG,IAAAC,qCAA+B,EAAC,IAAI,CAAChE,WAAW,CAAC;IACtF,IAAI,CAAC+D,4BAA4B,EAAE;MACjC;MACA,OAAOD,SAAS;IAClB;;IAEA;IACA;IACA,MAAMG,EAAE,GAAGF,4BAA4B,CAACL,IAAI,CAAEtB,KAAK,CAChDV,IAAI,CAAC,CAAC;MAAEN;IAAK,CAAC,KAAKA,IAAI,KAAK,IAAI,CAAC,CAAEgB,KAAe;IACrD,MAAM8B,YAAY,GAAGH,4BAA4B,CAACL,IAAI,CAAEtB,KAAK,CAC1DV,IAAI,CAAC,CAAC;MAAEN;IAAK,CAAC,KAAKA,IAAI,KAAK,cAAc,CAAC,EAAEgB,KAAe;IAE/D,OAAO;MACL,GAAG0B,SAAS;MACZG,EAAE;MACFC;IACF,CAAC;EACH;AACF;AAAC"}
|
|
@@ -57,10 +57,9 @@ class SelectAuthenticator extends _Remediator.Remediator {
|
|
|
57
57
|
// Proceed with provided authenticators
|
|
58
58
|
const matchedOption = this.findMatchedOption(authenticators, options);
|
|
59
59
|
if (matchedOption) {
|
|
60
|
-
var _matchedOption$relate, _matchedOption$relate2;
|
|
61
60
|
// Don't select current authenticator (OKTA-612939)
|
|
62
|
-
const isCurrentAuthenticator =
|
|
63
|
-
const isCurrentAuthenticatorEnrollment =
|
|
61
|
+
const isCurrentAuthenticator = context?.currentAuthenticator && context?.currentAuthenticator.value.id === matchedOption.relatesTo?.id;
|
|
62
|
+
const isCurrentAuthenticatorEnrollment = context?.currentAuthenticatorEnrollment && context?.currentAuthenticatorEnrollment.value.id === matchedOption.relatesTo?.id;
|
|
64
63
|
return !isCurrentAuthenticator && !isCurrentAuthenticatorEnrollment;
|
|
65
64
|
}
|
|
66
65
|
return false;
|
|
@@ -83,7 +82,7 @@ class SelectAuthenticator extends _Remediator.Remediator {
|
|
|
83
82
|
this.selectedAuthenticator = selectedOption.relatesTo; // track the selected authenticator
|
|
84
83
|
this.selectedOption = selectedOption;
|
|
85
84
|
return {
|
|
86
|
-
id: selectedOption
|
|
85
|
+
id: selectedOption?.value.form.value.find(({
|
|
87
86
|
name
|
|
88
87
|
}) => name === 'id').value
|
|
89
88
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectAuthenticator.js","names":["SelectAuthenticator","Remediator","findMatchedOption","authenticators","options","option","authenticator","find","relatesTo","key","canRemediate","context","values","authenticatorFromRemediation","getAuthenticatorFromRemediation","remediation","length","isAuthenticator","id","matchedOption","isCurrentAuthenticator","currentAuthenticator","value","isCurrentAuthenticatorEnrollment","currentAuthenticatorEnrollment","mapAuthenticator","remediationValue","selectedAuthenticator","selectedOption","form","name","getInputAuthenticator","map","label","type","getValuesAfterProceed","filter","compareAuthenticators"],"sources":["../../../../../lib/idx/remediators/Base/SelectAuthenticator.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-non-null-assertion */\n/*!\n * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * \n * See the License for the specific language governing permissions and limitations under the License.\n */\n\n\nimport { Remediator, RemediationValues } from './Remediator';\nimport { getAuthenticatorFromRemediation } from '../util';\nimport { IdxRemediationValue, IdxContext, IdxOption } from '../../types/idx-js';\nimport { Authenticator, isAuthenticator } from '../../types/api';\nimport { compareAuthenticators, findMatchedOption} from '../../authenticator/util';\n\nexport type SelectAuthenticatorValues = RemediationValues & {\n authenticator?: string | Authenticator;\n};\n\n// Base class - DO NOT expose static remediationName\nexport class SelectAuthenticator<T extends SelectAuthenticatorValues = SelectAuthenticatorValues>\n extends Remediator<T> {\n selectedAuthenticator?: Authenticator;\n selectedOption?: any;\n\n // Find matched authenticator in provided order\n findMatchedOption(authenticators, options) {\n let option: IdxOption | undefined;\n for (let authenticator of authenticators) {\n option = options\n .find(({ relatesTo }) => relatesTo.key && relatesTo.key === authenticator.key);\n if (option) {\n break;\n }\n }\n return option;\n }\n\n /* eslint complexity:[0,9] */\n canRemediate(context?: IdxContext) {\n const { authenticators, authenticator } = this.values;\n const authenticatorFromRemediation = getAuthenticatorFromRemediation(this.remediation);\n const { options } = authenticatorFromRemediation;\n // Let users select authenticator if no input is provided\n if (!authenticators || !authenticators.length) {\n return false;\n }\n\n // Authenticator is explicitly specified by id\n if (isAuthenticator(authenticator) && authenticator.id) {\n return true;\n }\n\n // Proceed with provided authenticators\n const matchedOption = this.findMatchedOption(authenticators, options!);\n if (matchedOption) {\n // Don't select current authenticator (OKTA-612939)\n const isCurrentAuthenticator = context?.currentAuthenticator\n && context?.currentAuthenticator.value.id === matchedOption.relatesTo?.id;\n const isCurrentAuthenticatorEnrollment = context?.currentAuthenticatorEnrollment\n && context?.currentAuthenticatorEnrollment.value.id === matchedOption.relatesTo?.id;\n return !isCurrentAuthenticator && !isCurrentAuthenticatorEnrollment;\n }\n \n return false;\n }\n\n mapAuthenticator(remediationValue: IdxRemediationValue) {\n const { authenticators, authenticator } = this.values;\n\n // Authenticator is explicitly specified by id\n if (isAuthenticator(authenticator) && authenticator.id) {\n this.selectedAuthenticator = authenticator; // track the selected authenticator\n return authenticator;\n }\n\n const { options } = remediationValue;\n const selectedOption = findMatchedOption(authenticators, options);\n this.selectedAuthenticator = selectedOption.relatesTo; // track the selected authenticator\n this.selectedOption = selectedOption;\n return {\n id: selectedOption?.value.form.value.find(({ name }) => name === 'id').value\n };\n }\n\n getInputAuthenticator(remediation) {\n const options = remediation.options.map(({ label, relatesTo }) => {\n return {\n label,\n value: relatesTo.key\n };\n });\n return { name: 'authenticator', type: 'string', options };\n }\n\n getValuesAfterProceed(): T {\n this.values = super.getValuesAfterProceed();\n // remove used authenticators\n const authenticators = (this.values.authenticators as Authenticator[])\n .filter(authenticator => {\n return compareAuthenticators(authenticator, this.selectedAuthenticator) !== true;\n });\n return { ...this.values, authenticators };\n }\n\n}\n"],"mappings":";;;AAcA;AACA;AAEA;AACA;AAlBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA;AACO,MAAMA,mBAAmB,SACtBC,sBAAU,CAAI;EAItB;EACAC,iBAAiB,CAACC,cAAc,EAAEC,OAAO,EAAE;IACzC,IAAIC,MAA6B;IACjC,KAAK,IAAIC,aAAa,IAAIH,cAAc,EAAE;MACxCE,MAAM,GAAGD,OAAO,CACbG,IAAI,CAAC,CAAC;QAAEC;MAAU,CAAC,KAAKA,SAAS,CAACC,GAAG,IAAID,SAAS,CAACC,GAAG,KAAKH,aAAa,CAACG,GAAG,CAAC;MAChF,IAAIJ,MAAM,EAAE;QACV;MACF;IACF;IACA,OAAOA,MAAM;EACf;;EAEA;EACAK,YAAY,CAACC,OAAoB,EAAE;IACjC,MAAM;MAAER,cAAc;MAAEG;IAAc,CAAC,GAAG,IAAI,CAACM,MAAM;IACrD,MAAMC,4BAA4B,GAAG,IAAAC,qCAA+B,EAAC,IAAI,CAACC,WAAW,CAAC;IACtF,MAAM;MAAEX;IAAQ,CAAC,GAAGS,4BAA4B;IAChD;IACA,IAAI,CAACV,cAAc,IAAI,CAACA,cAAc,CAACa,MAAM,EAAE;MAC7C,OAAO,KAAK;IACd;;IAEA;IACA,IAAI,IAAAC,oBAAe,EAACX,aAAa,CAAC,IAAIA,aAAa,CAACY,EAAE,EAAE;MACtD,OAAO,IAAI;IACb;;IAEA;IACA,MAAMC,aAAa,GAAG,IAAI,CAACjB,iBAAiB,CAACC,cAAc,EAAEC,OAAO,CAAE;IACtE,IAAIe,aAAa,EAAE;
|
|
1
|
+
{"version":3,"file":"SelectAuthenticator.js","names":["SelectAuthenticator","Remediator","findMatchedOption","authenticators","options","option","authenticator","find","relatesTo","key","canRemediate","context","values","authenticatorFromRemediation","getAuthenticatorFromRemediation","remediation","length","isAuthenticator","id","matchedOption","isCurrentAuthenticator","currentAuthenticator","value","isCurrentAuthenticatorEnrollment","currentAuthenticatorEnrollment","mapAuthenticator","remediationValue","selectedAuthenticator","selectedOption","form","name","getInputAuthenticator","map","label","type","getValuesAfterProceed","filter","compareAuthenticators"],"sources":["../../../../../lib/idx/remediators/Base/SelectAuthenticator.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-non-null-assertion */\n/*!\n * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * \n * See the License for the specific language governing permissions and limitations under the License.\n */\n\n\nimport { Remediator, RemediationValues } from './Remediator';\nimport { getAuthenticatorFromRemediation } from '../util';\nimport { IdxRemediationValue, IdxContext, IdxOption } from '../../types/idx-js';\nimport { Authenticator, isAuthenticator } from '../../types/api';\nimport { compareAuthenticators, findMatchedOption} from '../../authenticator/util';\n\nexport type SelectAuthenticatorValues = RemediationValues & {\n authenticator?: string | Authenticator;\n};\n\n// Base class - DO NOT expose static remediationName\nexport class SelectAuthenticator<T extends SelectAuthenticatorValues = SelectAuthenticatorValues>\n extends Remediator<T> {\n selectedAuthenticator?: Authenticator;\n selectedOption?: any;\n\n // Find matched authenticator in provided order\n findMatchedOption(authenticators, options) {\n let option: IdxOption | undefined;\n for (let authenticator of authenticators) {\n option = options\n .find(({ relatesTo }) => relatesTo.key && relatesTo.key === authenticator.key);\n if (option) {\n break;\n }\n }\n return option;\n }\n\n /* eslint complexity:[0,9] */\n canRemediate(context?: IdxContext) {\n const { authenticators, authenticator } = this.values;\n const authenticatorFromRemediation = getAuthenticatorFromRemediation(this.remediation);\n const { options } = authenticatorFromRemediation;\n // Let users select authenticator if no input is provided\n if (!authenticators || !authenticators.length) {\n return false;\n }\n\n // Authenticator is explicitly specified by id\n if (isAuthenticator(authenticator) && authenticator.id) {\n return true;\n }\n\n // Proceed with provided authenticators\n const matchedOption = this.findMatchedOption(authenticators, options!);\n if (matchedOption) {\n // Don't select current authenticator (OKTA-612939)\n const isCurrentAuthenticator = context?.currentAuthenticator\n && context?.currentAuthenticator.value.id === matchedOption.relatesTo?.id;\n const isCurrentAuthenticatorEnrollment = context?.currentAuthenticatorEnrollment\n && context?.currentAuthenticatorEnrollment.value.id === matchedOption.relatesTo?.id;\n return !isCurrentAuthenticator && !isCurrentAuthenticatorEnrollment;\n }\n \n return false;\n }\n\n mapAuthenticator(remediationValue: IdxRemediationValue) {\n const { authenticators, authenticator } = this.values;\n\n // Authenticator is explicitly specified by id\n if (isAuthenticator(authenticator) && authenticator.id) {\n this.selectedAuthenticator = authenticator; // track the selected authenticator\n return authenticator;\n }\n\n const { options } = remediationValue;\n const selectedOption = findMatchedOption(authenticators, options);\n this.selectedAuthenticator = selectedOption.relatesTo; // track the selected authenticator\n this.selectedOption = selectedOption;\n return {\n id: selectedOption?.value.form.value.find(({ name }) => name === 'id').value\n };\n }\n\n getInputAuthenticator(remediation) {\n const options = remediation.options.map(({ label, relatesTo }) => {\n return {\n label,\n value: relatesTo.key\n };\n });\n return { name: 'authenticator', type: 'string', options };\n }\n\n getValuesAfterProceed(): T {\n this.values = super.getValuesAfterProceed();\n // remove used authenticators\n const authenticators = (this.values.authenticators as Authenticator[])\n .filter(authenticator => {\n return compareAuthenticators(authenticator, this.selectedAuthenticator) !== true;\n });\n return { ...this.values, authenticators };\n }\n\n}\n"],"mappings":";;;AAcA;AACA;AAEA;AACA;AAlBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA;AACO,MAAMA,mBAAmB,SACtBC,sBAAU,CAAI;EAItB;EACAC,iBAAiB,CAACC,cAAc,EAAEC,OAAO,EAAE;IACzC,IAAIC,MAA6B;IACjC,KAAK,IAAIC,aAAa,IAAIH,cAAc,EAAE;MACxCE,MAAM,GAAGD,OAAO,CACbG,IAAI,CAAC,CAAC;QAAEC;MAAU,CAAC,KAAKA,SAAS,CAACC,GAAG,IAAID,SAAS,CAACC,GAAG,KAAKH,aAAa,CAACG,GAAG,CAAC;MAChF,IAAIJ,MAAM,EAAE;QACV;MACF;IACF;IACA,OAAOA,MAAM;EACf;;EAEA;EACAK,YAAY,CAACC,OAAoB,EAAE;IACjC,MAAM;MAAER,cAAc;MAAEG;IAAc,CAAC,GAAG,IAAI,CAACM,MAAM;IACrD,MAAMC,4BAA4B,GAAG,IAAAC,qCAA+B,EAAC,IAAI,CAACC,WAAW,CAAC;IACtF,MAAM;MAAEX;IAAQ,CAAC,GAAGS,4BAA4B;IAChD;IACA,IAAI,CAACV,cAAc,IAAI,CAACA,cAAc,CAACa,MAAM,EAAE;MAC7C,OAAO,KAAK;IACd;;IAEA;IACA,IAAI,IAAAC,oBAAe,EAACX,aAAa,CAAC,IAAIA,aAAa,CAACY,EAAE,EAAE;MACtD,OAAO,IAAI;IACb;;IAEA;IACA,MAAMC,aAAa,GAAG,IAAI,CAACjB,iBAAiB,CAACC,cAAc,EAAEC,OAAO,CAAE;IACtE,IAAIe,aAAa,EAAE;MACjB;MACA,MAAMC,sBAAsB,GAAGT,OAAO,EAAEU,oBAAoB,IACvDV,OAAO,EAAEU,oBAAoB,CAACC,KAAK,CAACJ,EAAE,KAAKC,aAAa,CAACX,SAAS,EAAEU,EAAE;MAC3E,MAAMK,gCAAgC,GAAGZ,OAA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,KAAK,CAACuB,qBAAqB,EAAE;IAC3C;IACA,MAAMhC,cAAc,GAAI,IAAI,CAACS,MAAM,CAACT,cAAc,CAC/CiC,MAAM,CAAC9B,aAAa,IAAI;MACvB,OAAO,IAAA+B,4BAAqB,EAAC/B,aAAa,EAAE,IAAI,CAACqB,qBAAqB,CAAC,KAAK,IAAI;IAClF,CAAC,CAAC;IACJ,OAAO;MAAE,GAAG,IAAI,CAACf,MAAM;MAAET;IAAe,CAAC;EAC3C;AAEF;AAAC"}
|
|
@@ -22,9 +22,8 @@ class VerifyAuthenticator extends _Remediator.Remediator {
|
|
|
22
22
|
this.authenticator = (0, _authenticator.getAuthenticator)(remediation);
|
|
23
23
|
}
|
|
24
24
|
getNextStep(authClient, context) {
|
|
25
|
-
var _context$authenticato;
|
|
26
25
|
const nextStep = super.getNextStep(authClient, context);
|
|
27
|
-
const authenticatorEnrollments = context
|
|
26
|
+
const authenticatorEnrollments = context?.authenticatorEnrollments?.value;
|
|
28
27
|
return {
|
|
29
28
|
...nextStep,
|
|
30
29
|
authenticatorEnrollments
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VerifyAuthenticator.js","names":["VerifyAuthenticator","Remediator","constructor","remediation","values","authenticator","getAuthenticator","getNextStep","authClient","context","nextStep","authenticatorEnrollments","value","canRemediate","canVerify","mapCredentials","getInputCredentials","input","getInputs","getValuesAfterProceed","trimmedValues","Object","keys","filter","valueKey","reduce"],"sources":["../../../../../lib/idx/remediators/Base/VerifyAuthenticator.ts"],"sourcesContent":["/*!\n * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * \n * See the License for the specific language governing permissions and limitations under the License.\n */\n\n\nimport { Remediator, RemediationValues } from './Remediator';\nimport { getAuthenticator, Authenticator, AuthenticatorValues } from '../../authenticator';\nimport { IdxRemediation, IdxContext } from '../../types/idx-js';\nimport { OktaAuthIdxInterface, NextStep } from '../../types';\n\nexport type VerifyAuthenticatorValues = AuthenticatorValues & RemediationValues;\n\n// Base class - DO NOT expose static remediationName\nexport class VerifyAuthenticator<T extends VerifyAuthenticatorValues = VerifyAuthenticatorValues>\n extends Remediator<T> {\n\n authenticator: Authenticator<VerifyAuthenticatorValues>;\n\n constructor(remediation: IdxRemediation, values: T = {} as T) {\n super(remediation, values);\n this.authenticator = getAuthenticator(remediation);\n }\n\n getNextStep(authClient: OktaAuthIdxInterface, context?: IdxContext): NextStep {\n const nextStep = super.getNextStep(authClient, context);\n const authenticatorEnrollments = context?.authenticatorEnrollments?.value;\n\n return {\n ...nextStep,\n authenticatorEnrollments\n };\n }\n\n canRemediate() {\n return this.authenticator.canVerify(this.values);\n }\n\n mapCredentials() {\n return this.authenticator.mapCredentials(this.values);\n }\n\n getInputCredentials(input) {\n return this.authenticator.getInputs(input);\n }\n\n getValuesAfterProceed(): T {\n this.values = super.getValuesAfterProceed();\n let trimmedValues = Object.keys(this.values).filter(valueKey => valueKey !== 'credentials');\n return trimmedValues.reduce((values, valueKey) => ({...values, [valueKey]: this.values[valueKey]}), {} as T);\n }\n}\n"],"mappings":";;;AAaA;AACA;AAdA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA;AACO,MAAMA,mBAAmB,SACtBC,sBAAU,CAAI;EAItBC,WAAW,CAACC,WAA2B,EAAEC,MAAS,GAAG,CAAC,CAAM,EAAE;IAC5D,KAAK,CAACD,WAAW,EAAEC,MAAM,CAAC;IAC1B,IAAI,CAACC,aAAa,GAAG,IAAAC,+BAAgB,EAACH,WAAW,CAAC;EACpD;EAEAI,WAAW,CAACC,UAAgC,EAAEC,OAAoB,EAAY;
|
|
1
|
+
{"version":3,"file":"VerifyAuthenticator.js","names":["VerifyAuthenticator","Remediator","constructor","remediation","values","authenticator","getAuthenticator","getNextStep","authClient","context","nextStep","authenticatorEnrollments","value","canRemediate","canVerify","mapCredentials","getInputCredentials","input","getInputs","getValuesAfterProceed","trimmedValues","Object","keys","filter","valueKey","reduce"],"sources":["../../../../../lib/idx/remediators/Base/VerifyAuthenticator.ts"],"sourcesContent":["/*!\n * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * \n * See the License for the specific language governing permissions and limitations under the License.\n */\n\n\nimport { Remediator, RemediationValues } from './Remediator';\nimport { getAuthenticator, Authenticator, AuthenticatorValues } from '../../authenticator';\nimport { IdxRemediation, IdxContext } from '../../types/idx-js';\nimport { OktaAuthIdxInterface, NextStep } from '../../types';\n\nexport type VerifyAuthenticatorValues = AuthenticatorValues & RemediationValues;\n\n// Base class - DO NOT expose static remediationName\nexport class VerifyAuthenticator<T extends VerifyAuthenticatorValues = VerifyAuthenticatorValues>\n extends Remediator<T> {\n\n authenticator: Authenticator<VerifyAuthenticatorValues>;\n\n constructor(remediation: IdxRemediation, values: T = {} as T) {\n super(remediation, values);\n this.authenticator = getAuthenticator(remediation);\n }\n\n getNextStep(authClient: OktaAuthIdxInterface, context?: IdxContext): NextStep {\n const nextStep = super.getNextStep(authClient, context);\n const authenticatorEnrollments = context?.authenticatorEnrollments?.value;\n\n return {\n ...nextStep,\n authenticatorEnrollments\n };\n }\n\n canRemediate() {\n return this.authenticator.canVerify(this.values);\n }\n\n mapCredentials() {\n return this.authenticator.mapCredentials(this.values);\n }\n\n getInputCredentials(input) {\n return this.authenticator.getInputs(input);\n }\n\n getValuesAfterProceed(): T {\n this.values = super.getValuesAfterProceed();\n let trimmedValues = Object.keys(this.values).filter(valueKey => valueKey !== 'credentials');\n return trimmedValues.reduce((values, valueKey) => ({...values, [valueKey]: this.values[valueKey]}), {} as T);\n }\n}\n"],"mappings":";;;AAaA;AACA;AAdA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA;AACO,MAAMA,mBAAmB,SACtBC,sBAAU,CAAI;EAItBC,WAAW,CAACC,WAA2B,EAAEC,MAAS,GAAG,CAAC,CAAM,EAAE;IAC5D,KAAK,CAACD,WAAW,EAAEC,MAAM,CAAC;IAC1B,IAAI,CAACC,aAAa,GAAG,IAAAC,+BAAgB,EAACH,WAAW,CAAC;EACpD;EAEAI,WAAW,CAACC,UAAgC,EAAEC,OAAoB,EAAY;IAC5E,MAAMC,QAAQ,GAAG,KAAK,CAACH,WAAW,CAACC,UAAU,EAAEC,OAAO,CAAC;IACvD,MAAME,wBAAwB,GAAGF,OAAO,EAAEE,wBAAwB,EAAEC,KAAK;IAEzE,OAAO;MACL,GAAGF,QAAQ;MACXC;IACF,CAAC;EACH;EAEAE,YAAY,GAAG;IACb,OAAO,IAAI,CAACR,aAAa,CAACS,SAAS,CAAC,IAAI,CAACV,MAAM,CAAC;EAClD;EAEAW,cAAc,GAAG;IACf,OAAO,IAAI,CAACV,aAAa,CAACU,cAAc,CAAC,IAAI,CAACX,MAAM,CAAC;EACvD;EAEAY,mBAAmB,CAACC,KAAK,EAAE;IACzB,OAAO,IAAI,CAACZ,aAAa,CAACa,SAAS,CAACD,KAAK,CAAC;EAC5C;EAEAE,qBAAqB,GAAM;IACzB,IAAI,CAACf,MAAM,GAAG,KAAK,CAACe,qBAAqB,EAAE;IAC3C,IAAIC,aAAa,GAAGC,MAAM,CAACC,IAAI,CAAC,IAAI,CAAClB,MAAM,CAAC,CAACmB,MAAM,CAACC,QAAQ,IAAIA,QAAQ,KAAK,aAAa,CAAC;IAC3F,OAAOJ,aAAa,CAACK,MAAM,CAAC,CAACrB,MAAM,EAAEoB,QAAQ,MAAM;MAAC,GAAGpB,MAAM;MAAE,CAACoB,QAAQ,GAAG,IAAI,CAACpB,MAAM,CAACoB,QAAQ;IAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAM;EAC9G;AACF;AAAC"}
|
|
@@ -23,7 +23,7 @@ class EnrollPoll extends _Remediator.Remediator {
|
|
|
23
23
|
getNextStep(authClient, context) {
|
|
24
24
|
const common = super.getNextStep(authClient, context);
|
|
25
25
|
let authenticator = this.getAuthenticator();
|
|
26
|
-
if (!authenticator && context
|
|
26
|
+
if (!authenticator && context?.currentAuthenticator) {
|
|
27
27
|
authenticator = context.currentAuthenticator.value;
|
|
28
28
|
}
|
|
29
29
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnrollPoll.js","names":["EnrollPoll","Remediator","canRemediate","values","startPolling","options","step","getNextStep","authClient","context","common","authenticator","getAuthenticator","currentAuthenticator","value","poll","required","refresh","remediation","getValuesAfterProceed","trimmedValues","Object","keys","filter","valueKey","reduce"],"sources":["../../../../lib/idx/remediators/EnrollPoll.ts"],"sourcesContent":["/*!\n * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * \n * See the License for the specific language governing permissions and limitations under the License.\n */\n\n\nimport { Remediator, RemediationValues } from './Base/Remediator';\nimport { NextStep, OktaAuthIdxInterface } from '../types';\nimport { IdxContext } from '../types/idx-js';\n\nexport interface EnrollPollValues extends RemediationValues {\n startPolling?: boolean;\n}\n\nexport class EnrollPoll extends Remediator<EnrollPollValues> {\n static remediationName = 'enroll-poll';\n\n canRemediate() {\n return !!this.values.startPolling || this.options.step === 'enroll-poll';\n }\n\n getNextStep(authClient: OktaAuthIdxInterface, context?: IdxContext): NextStep {\n const common = super.getNextStep(authClient, context);\n let authenticator = this.getAuthenticator();\n if (!authenticator && context?.currentAuthenticator) {\n authenticator = context.currentAuthenticator.value;\n }\n return {\n ...common,\n authenticator,\n poll: {\n required: true,\n refresh: this.remediation.refresh\n },\n };\n }\n\n getValuesAfterProceed(): EnrollPollValues {\n let trimmedValues = Object.keys(this.values).filter(valueKey => valueKey !== 'startPolling');\n return trimmedValues.reduce((values, valueKey) => ({...values, [valueKey]: this.values[valueKey]}), {});\n }\n}\n"],"mappings":";;;;;AAaA;AAbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWO,MAAMA,UAAU,SAASC,sBAAU,CAAmB;EAG3DC,YAAY,GAAG;IACb,OAAO,CAAC,CAAC,IAAI,CAACC,MAAM,CAACC,YAAY,IAAI,IAAI,CAACC,OAAO,CAACC,IAAI,KAAK,aAAa;EAC1E;EAEAC,WAAW,CAACC,UAAgC,EAAEC,OAAoB,EAAY;IAC5E,MAAMC,MAAM,GAAG,KAAK,CAACH,WAAW,CAACC,UAAU,EAAEC,OAAO,CAAC;IACrD,IAAIE,aAAa,GAAG,IAAI,CAACC,gBAAgB,EAAE;IAC3C,IAAI,CAACD,aAAa,IAAIF,OAAO,
|
|
1
|
+
{"version":3,"file":"EnrollPoll.js","names":["EnrollPoll","Remediator","canRemediate","values","startPolling","options","step","getNextStep","authClient","context","common","authenticator","getAuthenticator","currentAuthenticator","value","poll","required","refresh","remediation","getValuesAfterProceed","trimmedValues","Object","keys","filter","valueKey","reduce"],"sources":["../../../../lib/idx/remediators/EnrollPoll.ts"],"sourcesContent":["/*!\n * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * \n * See the License for the specific language governing permissions and limitations under the License.\n */\n\n\nimport { Remediator, RemediationValues } from './Base/Remediator';\nimport { NextStep, OktaAuthIdxInterface } from '../types';\nimport { IdxContext } from '../types/idx-js';\n\nexport interface EnrollPollValues extends RemediationValues {\n startPolling?: boolean;\n}\n\nexport class EnrollPoll extends Remediator<EnrollPollValues> {\n static remediationName = 'enroll-poll';\n\n canRemediate() {\n return !!this.values.startPolling || this.options.step === 'enroll-poll';\n }\n\n getNextStep(authClient: OktaAuthIdxInterface, context?: IdxContext): NextStep {\n const common = super.getNextStep(authClient, context);\n let authenticator = this.getAuthenticator();\n if (!authenticator && context?.currentAuthenticator) {\n authenticator = context.currentAuthenticator.value;\n }\n return {\n ...common,\n authenticator,\n poll: {\n required: true,\n refresh: this.remediation.refresh\n },\n };\n }\n\n getValuesAfterProceed(): EnrollPollValues {\n let trimmedValues = Object.keys(this.values).filter(valueKey => valueKey !== 'startPolling');\n return trimmedValues.reduce((values, valueKey) => ({...values, [valueKey]: this.values[valueKey]}), {});\n }\n}\n"],"mappings":";;;;;AAaA;AAbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWO,MAAMA,UAAU,SAASC,sBAAU,CAAmB;EAG3DC,YAAY,GAAG;IACb,OAAO,CAAC,CAAC,IAAI,CAACC,MAAM,CAACC,YAAY,IAAI,IAAI,CAACC,OAAO,CAACC,IAAI,KAAK,aAAa;EAC1E;EAEAC,WAAW,CAACC,UAAgC,EAAEC,OAAoB,EAAY;IAC5E,MAAMC,MAAM,GAAG,KAAK,CAACH,WAAW,CAACC,UAAU,EAAEC,OAAO,CAAC;IACrD,IAAIE,aAAa,GAAG,IAAI,CAACC,gBAAgB,EAAE;IAC3C,IAAI,CAACD,aAAa,IAAIF,OAAO,EAAEI,oBAAoB,EAAE;MACnDF,aAAa,GAAGF,OAAO,CAACI,oBAAoB,CAACC,KAAK;IACpD;IACA,OAAO;MACL,GAAGJ,MAAM;MACTC,aAAa;MACbI,IAAI,EAAE;QACJC,QAAQ,EAAE,IAAI;QACdC,OAAO,EAAE,IAAI,CAACC,WAAW,CAACD;MAC5B;IACF,CAAC;EACH;EAEAE,qBAAqB,GAAqB;IACxC,IAAIC,aAAa,GAAGC,MAAM,CAACC,IAAI,CAAC,IAAI,CAACnB,MAAM,CAAC,CAACoB,MAAM,CAACC,QAAQ,IAAIA,QAAQ,KAAK,cAAc,CAAC;IAC5F,OAAOJ,aAAa,CAACK,MAAM,CAAC,CAACtB,MAAM,EAAEqB,QAAQ,MAAM;MAAC,GAAGrB,MAAM;MAAE,CAACqB,QAAQ,GAAG,IAAI,CAACrB,MAAM,CAACqB,QAAQ;IAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;EACzG;AACF;AAAC;AAAA,8BA3BYxB,UAAU,qBACI,aAAa"}
|
|
@@ -20,14 +20,13 @@ var _types = require("../types");
|
|
|
20
20
|
|
|
21
21
|
class SelectAuthenticatorAuthenticate extends _SelectAuthenticator.SelectAuthenticator {
|
|
22
22
|
constructor(remediation, values = {}, options = {}) {
|
|
23
|
-
var _getAuthenticatorFrom;
|
|
24
23
|
super(remediation, values, options);
|
|
25
24
|
|
|
26
25
|
// Preset password authenticator to trigger recover action
|
|
27
26
|
const isRecoveryFlow = this.options.flow === 'recoverPassword';
|
|
28
|
-
const hasPasswordInOptions = (
|
|
27
|
+
const hasPasswordInOptions = (0, _util.getAuthenticatorFromRemediation)(remediation).options?.some(({
|
|
29
28
|
relatesTo
|
|
30
|
-
}) =>
|
|
29
|
+
}) => relatesTo?.key === _types.AuthenticatorKey.OKTA_PASSWORD);
|
|
31
30
|
if (hasPasswordInOptions && (isRecoveryFlow || this.values.password)) {
|
|
32
31
|
this.values.authenticators = [...(this.values.authenticators || []), {
|
|
33
32
|
key: _types.AuthenticatorKey.OKTA_PASSWORD
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectAuthenticatorAuthenticate.js","names":["SelectAuthenticatorAuthenticate","SelectAuthenticator","constructor","remediation","values","options","isRecoveryFlow","flow","hasPasswordInOptions","getAuthenticatorFromRemediation","some","relatesTo","key","AuthenticatorKey","OKTA_PASSWORD","password","authenticators"],"sources":["../../../../lib/idx/remediators/SelectAuthenticatorAuthenticate.ts"],"sourcesContent":["/*!\n * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * \n * See the License for the specific language governing permissions and limitations under the License.\n */\n\n\nimport { SelectAuthenticator, SelectAuthenticatorValues } from './Base/SelectAuthenticator';\nimport { getAuthenticatorFromRemediation } from './util';\nimport { IdxRemediation } from '../types/idx-js';\nimport { AuthenticatorKey, Authenticator, RemediateOptions } from '../types';\n\nexport type SelectAuthenticatorAuthenticateValues = SelectAuthenticatorValues & {\n password?: string;\n};\n\nexport class SelectAuthenticatorAuthenticate extends SelectAuthenticator<SelectAuthenticatorAuthenticateValues> {\n static remediationName = 'select-authenticator-authenticate';\n\n constructor(\n remediation: IdxRemediation, \n values: SelectAuthenticatorValues = {}, \n options: RemediateOptions = {}\n ) {\n super(remediation, values, options);\n\n // Preset password authenticator to trigger recover action\n const isRecoveryFlow = this.options.flow === 'recoverPassword';\n const hasPasswordInOptions = getAuthenticatorFromRemediation(remediation)\n .options?.some(({ relatesTo }) => relatesTo?.key === AuthenticatorKey.OKTA_PASSWORD);\n if (hasPasswordInOptions && (isRecoveryFlow || this.values.password)) {\n this.values.authenticators = [\n ...this.values.authenticators || [],\n { key: AuthenticatorKey.OKTA_PASSWORD }\n ] as Authenticator[];\n }\n }\n}\n"],"mappings":";;;;;AAaA;AACA;AAEA;AAhBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYO,MAAMA,+BAA+B,SAASC,wCAAmB,CAAwC;EAG9GC,WAAW,CACTC,WAA2B,EAC3BC,MAAiC,GAAG,CAAC,CAAC,EACtCC,OAAyB,GAAG,CAAC,CAAC,EAC9B;
|
|
1
|
+
{"version":3,"file":"SelectAuthenticatorAuthenticate.js","names":["SelectAuthenticatorAuthenticate","SelectAuthenticator","constructor","remediation","values","options","isRecoveryFlow","flow","hasPasswordInOptions","getAuthenticatorFromRemediation","some","relatesTo","key","AuthenticatorKey","OKTA_PASSWORD","password","authenticators"],"sources":["../../../../lib/idx/remediators/SelectAuthenticatorAuthenticate.ts"],"sourcesContent":["/*!\n * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * \n * See the License for the specific language governing permissions and limitations under the License.\n */\n\n\nimport { SelectAuthenticator, SelectAuthenticatorValues } from './Base/SelectAuthenticator';\nimport { getAuthenticatorFromRemediation } from './util';\nimport { IdxRemediation } from '../types/idx-js';\nimport { AuthenticatorKey, Authenticator, RemediateOptions } from '../types';\n\nexport type SelectAuthenticatorAuthenticateValues = SelectAuthenticatorValues & {\n password?: string;\n};\n\nexport class SelectAuthenticatorAuthenticate extends SelectAuthenticator<SelectAuthenticatorAuthenticateValues> {\n static remediationName = 'select-authenticator-authenticate';\n\n constructor(\n remediation: IdxRemediation, \n values: SelectAuthenticatorValues = {}, \n options: RemediateOptions = {}\n ) {\n super(remediation, values, options);\n\n // Preset password authenticator to trigger recover action\n const isRecoveryFlow = this.options.flow === 'recoverPassword';\n const hasPasswordInOptions = getAuthenticatorFromRemediation(remediation)\n .options?.some(({ relatesTo }) => relatesTo?.key === AuthenticatorKey.OKTA_PASSWORD);\n if (hasPasswordInOptions && (isRecoveryFlow || this.values.password)) {\n this.values.authenticators = [\n ...this.values.authenticators || [],\n { key: AuthenticatorKey.OKTA_PASSWORD }\n ] as Authenticator[];\n }\n }\n}\n"],"mappings":";;;;;AAaA;AACA;AAEA;AAhBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYO,MAAMA,+BAA+B,SAASC,wCAAmB,CAAwC;EAG9GC,WAAW,CACTC,WAA2B,EAC3BC,MAAiC,GAAG,CAAC,CAAC,EACtCC,OAAyB,GAAG,CAAC,CAAC,EAC9B;IACA,KAAK,CAACF,WAAW,EAAEC,MAAM,EAAEC,OAAO,CAAC;;IAEnC;IACA,MAAMC,cAAc,GAAG,IAAI,CAACD,OAAO,CAACE,IAAI,KAAK,iBAAiB;IAC9D,MAAMC,oBAAoB,GAAG,IAAAC,qCAA+B,EAACN,WAAW,CAAC,CACtEE,OAAO,EAAEK,IAAI,CAAC,CAAC;MAAEC;IAAU,CAAC,KAAKA,SAAS,EAAEC,GAAG,KAAKC,uBAAgB,CAACC,aAAa,CAAC;IACtF,IAAIN,oBAAoB,KAAKF,cAAc,IAAI,IAAI,CAACF,MAAM,CAACW,QAAQ,CAAC,EAAE;MACpE,IAAI,CAACX,MAAM,CAACY,cAAc,GAAG,CAC3B,IAAG,IAAI,CAACZ,MAAM,CAACY,cAAc,IAAI,EAAE,GACnC;QAAEJ,GAAG,EAAEC,uBAAgB,CAACC;MAAc,CAAC,CACrB;IACtB;EACF;AACF;AAAC;AAAA,8BArBYd,+BAA+B,qBACjB,mCAAmC"}
|
|
@@ -28,16 +28,15 @@ class SelectAuthenticatorUnlockAccount extends _SelectAuthenticator.SelectAuthen
|
|
|
28
28
|
return !!identifier && super.canRemediate();
|
|
29
29
|
}
|
|
30
30
|
mapAuthenticator(remediationValue) {
|
|
31
|
-
var _this$selectedOption, _methodTypeOption$opt, _methodTypeOption$opt2;
|
|
32
31
|
const authenticatorMap = super.mapAuthenticator(remediationValue);
|
|
33
|
-
const methodTypeOption =
|
|
32
|
+
const methodTypeOption = this.selectedOption?.value.form.value.find(({
|
|
34
33
|
name
|
|
35
34
|
}) => name === 'methodType');
|
|
36
35
|
|
|
37
36
|
// defaults to 'manually defined' value
|
|
38
37
|
// 2nd: option may have pre-defined value, like stateHandle
|
|
39
38
|
// 3rd: if only a single OV option is available, default to that option
|
|
40
|
-
const methodTypeValue = this.values.methodType ||
|
|
39
|
+
const methodTypeValue = this.values.methodType || methodTypeOption?.value || methodTypeOption?.options?.[0]?.value;
|
|
41
40
|
if (methodTypeValue) {
|
|
42
41
|
return {
|
|
43
42
|
...authenticatorMap,
|