Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@okta/okta-idx-js
Advanced tools
:warning: Okta recommends against integrating directly with this module. Developers wishing to use IDX APIs in an end-to-end flow should use the Okta AuthJS SDK instead. See the guide: Using IDX with AuthJS.
:grey_exclamation: The use of this SDK requires usage of the Okta Identity Engine. If you want to request to gain access to the Okta Identity Engine, please reach out to your account manager. If you do not have an account manager, please reach out to oie@okta.com for more information.
okta-idx-js
is a low-level protocol library used internally by Okta AuthJS and the Okta Signin Widget to parse responses from the IDX API. This library does not contain any OAuth/PKCE code and cannot retrieve tokens.
This library is intended to ease JS-based integration with the Okta Identity Engine (OIE) making use if the Okta Identity Experience (IDX) API. This library wraps the sequence of calls to the Okta IDX endpoints so that the consumer doesn't have to parse the entirety of each response, nor manage XHR calls.
Though this library exposes the metadata needed to generate a UI to gather needed data and select between available options, the consumer is responsible for interpeting and acting on that metadata - idx-js is focused on sending passed data to the appropriate endpoint for the selected actions only.
This library uses semantic versioning and follows Okta's Library Version Policy.
Version | Status |
---|---|
0.x.x | :warning: Beta |
The latest release can always be found on the releases page.
If you run into problems using the SDK, you can
You will need:
# npm
npm install @okta/okta-idx-js
# yarn
yarn install @okta/okta-idx-js
idx-js is compatible with node 12+
idx-js uses ES module syntax:
import idx from `@okta/okta-idx-js`;
idx.start()
is passed a config object and returns a promise that resolves to an idxState
object.
Configuration params:
idx.start()
is called anytime you don't have an idxState object (such as after a browser full-page redirect) and will resume any OIE flow in-progress based on the passed interactionHandle (customer-hosted)
let idxState;
try {
idxState = await idx.start({ issuer, clientId, redirectUri, version, codeChallenge, codeChallengeMethod });
// idxState has properties and methods
} catch (err) {
// err.error has an error message
}
The happy path for idx-js is:
idx.start()
initially to get an idxState
idxState.neededToProceed
array to see what data to send
idxState.context
object for any additional information to displayidxState.proceed('name of remediation', dataObject)
idxState
objectidxState.hasInteractionCode()
returns trueinteractionCode
from idxState.interactionCode
interactionCode
to obtain tokens. This is outside idx-js, but can be done with (for example) okta-auth-js token.exchangeCodeForTokens(...)
The less-than-happy paths include these options:
idxState.actions
idxState.rawIdxResponse
gives you access to the uninterpreted responseTo read, modify, or perform additional logic before a HTTP request is performed, add a custom interceptor:
idx.client.interceptors.request.use(requestConfig => {
// Add a custom header to the request
requestConfig.headers['X-Custom-Header'] = 'my-custom-header';
return requestConfig;
});
Clear all attached interceptors.
idx.client.interceptors.request.clear();
proceed()
is called to move forward to the next step of authentication.
proceed()
returns a promise that resolves to a new idxState.
remediationChoice
is the name of the corresponding entry in neededToProceed
(note that any actions that can't be called with proceed
, such as full-page redirects, are not valid remediationChoices)params
is an object of key/value pairs for data (matching the list in neededToProceed
Ion entry)neededToProceed
is an array of objects, with each object having:
.name
property that will be used as a remediationChoice
for calling proceed()
.value
property that is an array of Ion-based descriptions of the values to pass to proceed()
context
is an object of any metadata values about the current state of the IDX request and/or potential remediations. Possible properties within this object include:
expiresAt
- When the current stateHandle expiresintent
- The intent (e.g. "LOGIN") of the IDX flowuser
- Information about the user currently in the flowstateHandle
- The current stateHandle valueversion
- What version of the IDX API in usefactor
- Information about the current factor being used for authenticationterminal
- Any terminal errorsmessages
- Any message information. Note that messages that pertain to particular fields will be in the remediation structures describing those fields.success
- The result information for a successful flowactions
is an object of functions that do not return a new idxState, but can still be called as background (XHR) requests. Potential actions include:
actions.cancel()
- Cancels the current authentication flowhasInteractionCode()
returns true
if the flow has resulted in a final success and the idxState contains an interactionCode that can be exchanged for tokens. Not used in the Okta-hosted flow.
interactionCode
is the value returned at the end of a successful IDX flow. This value can be sent to the Okta v1/token
endpoint to be exchanged for the tokens matching the requesting scope. The PKCE code_verifier
used to produce the codeChallenge
sent to idx.start(...)
must be sent to the token endpoint as well.
rawIdxResponse
is an object containing the raw Ion response. It is included to cover the uncommon cases that idx-js doesn't serve well, but the goal is to minimize the need and use of it, as any useful information should be more easily obtained in .neededToProceed
, .actions
, or .context
.
We are happy to accept contributions and PRs! Please see the contribution guide to understand how to structure a contribution.
Create a .env
file with the below or set the same environment variables:
ISSUER_URL=https://{yourOktaDomain}
CLIENT_ID={clientId}
REDIRECT_URI=http://localhost:8080/implicit/callback
USER_IDENTIFIER={userEmailAddress}
FAQs
Okta JS-based consumption layer for IDX API
The npm package @okta/okta-idx-js receives a total of 27,865 weekly downloads. As such, @okta/okta-idx-js popularity was classified as popular.
We found that @okta/okta-idx-js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.