Configuring the DaVinci module
PingOne JavaScript
Configure DaVinci module for JavaScript properties to connect to PingOne and step through an associated DaVinci flow.
There are two methods for configuring the DaVinci module:
- Full configuration
-
Use the JavaScript factory function to access all available settings, including JavaScript-specific options such as request middleware and custom loggers.
- Common JSON configuration
-
Use a shared key-value structure that works identically across Android, iOS, and JavaScript, letting you load a single config file across platforms.
Full configuration
The following shows a full DaVinci module configuration:
import { davinci } from '@forgerock/davinci-client';
const davinciClient = await davinci({
logger: {
level: 'warn',
custom: customLogger,
},
config: {
clientId: '6c7eb89a-66e9-ab12-cd34-eeaf795650b2',
redirectUri: 'https://localhost:8443/callback',
serverConfig: {
wellknown: 'https://auth.pingone.com/3072206d-c6ce-ch15-m0nd-f87e972c7cc3/as/.well-known/openid-configuration',
timeout: 3000,
},
scope: 'openid profile email phone',
responseType: 'code',
},
});
Common JSON configuration
You can provide the same configuration as a JSON object, which lets you share a single config file across Android, iOS, and JavaScript.
Use the makeDavinciConfig() helper from @forgerock/sdk-utilities to convert the JSON to native config, then pass it to davinci():
DaVinci module from a JSON objectimport { davinci } from '@forgerock/davinci-client';
import { makeDavinciConfig } from '@forgerock/sdk-utilities';
const unifiedConfig = {
timeout: 30000, // milliseconds
log: 'WARN',
oidc: {
clientId: '6c7eb89a-66e9-ab12-cd34-eeaf795650b2',
discoveryEndpoint:
'https://auth.pingone.com/3072206d-c6ce-ch15-m0nd-f87e972c7cc3/as/.well-known/openid-configuration',
scopes: ['openid', 'profile', 'email', 'revoke'],
redirectUri: 'https://localhost:8443/callback',
},
};
const davinciClient = await davinci({
config: makeDavinciConfig(unifiedConfig),
});
Because makeDavinciConfig() returns a standard native config object, you can combine it with JavaScript-specific options in the same davinci() call:
const davinciClient = await davinci({
config: makeDavinciConfig(unifiedConfig),
logger: { level: 'debug', custom: myCustomLogger },
requestMiddleware: [customHeaderMiddleware],
});
The makeDavinciConfig() helper maps JSON properties to the native config automatically:
-
oidc.discoveryEndpoint→config.serverConfig.wellknown -
oidc.scopes(array) →config.scope(space-separated string) -
timeout→config.serverConfig.timeout
Optionally, you can store the JSON in a file alongside your app and load it at runtime so the same file can be shared across platforms.
Configuration property reference
The following properties are available when configuring the DaVinci module for JavaScript.
The JSON property column shows the equivalent key when using JSON configuration.
| Property | JSON property | Description | Required? | ||
|---|---|---|---|---|---|
|
|
A timeout, in milliseconds, for each request that communicates with your server. For example, for 30 seconds specify Defaults to When using JSON configuration, specify |
No |
||
|
|
Your PingOne server’s Example:
|
Yes |
||
|
|
The For example, |
Yes |
||
|
|
The
For example, |
Yes |
||
|
|
A list of scopes to request when performing an OAuth 2.0 authorization flow, separated by spaces. For example, When using JSON configuration, provide scopes as an array. The SDK joins the values into a space-separated string. |
Yes |
||
|
|
Whether to use Pushed Authorization Requests (PAR) for communicating with the authorization server. Learn more in Securing OIDC sign-on with Pushed Authorization Requests. |
No |
||
|
The type of OAuth 2.0 flow to use, either Defaults to |
No |
| Property | JSON property | Description | Required? |
|---|---|---|---|
|
|
Specify what level of logging the Orchestration SDK should output. Select one of the following:
Learn more in Configuring JavaScript logging. In JSON configuration, set the |
No |
|
Specify a custom logger the Orchestration SDK should use to output messages. Learn more in Customizing JavaScript logging. Example:
|
No |