diff --git a/.github/README.md b/.github/README.md index 1bd76a8e..9bb5a274 100644 --- a/.github/README.md +++ b/.github/README.md @@ -27,6 +27,25 @@ Frodo-lib powers [frodo-cli](https://github.com/rockcarver/frodo-cli), the comma Removing the singleton pattern and introducing multi-instantiability forced a radical redesign of the core library functions while striving to maintain the basic usage pattern. The library is now exposing two main types describing its modules ([Frodo](https://rockcarver.github.io/frodo-lib/types/Reference.Frodo.html)) and state ([State](https://rockcarver.github.io/frodo-lib/types/Reference.State.html)). Each module in turn exports all its collection of functions as a type as well. Exposing the library structure as types enables auto-completion for both JS and TS developers with properly configured IDEs like Visual Studio Code or other and also serves as an abstraction layer between what the library exposes vs what and how it's implemented. +#### New `FrodoError` Class + +All the errors thrown by the library are of the class `FrodoError`, introduced in 2.x. The new error class addresses the following challenges of earlier library versions: + +- Allows applications using the library to determine if the error originated in the library or is an unexpected and unhandled error from deeper down the stack. +- Nesting of errors: + + When the library throws because it caught an error thrown deeper down the stack, it wraps the caught `Error` in a `FrodoError`. + +- Nesting of arrays of errors + + The library supports many operation that require a number of actions to occur in a row or in parallel. Often these operations are REST API calls and any of those calls may fail for any reason. To preserve status of every operation, `FrodoError` can also wrap an array of errors, each of which may be another instance of `FrodoError` wrapping an individual or an array of errors. + +- Provides a stack-like combined error message concatenating the messages of all wrapped errors and nested errors. + +- Includes standardized fields to surface network errors in case the `Error` on top of the stack is an `AxiosError`. + +- The new `printError` function recognizes `FrodoError` and prints a uniformly formatted expression of the error including an interpretation of the fields for network stack errors. + ### New Modules The following modules have been updated and/or added since [1.x](https://github.com/rockcarver/frodo-lib/tree/1.x): diff --git a/CHANGELOG.md b/CHANGELOG.md index a0925c9a..78a01300 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,124 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +#### Multi-Instantiability + +2.x introduces breaking changes to support multiple instances of the library to run concurrently and connect to multiple different ForgeRock Identity Platform instances at the same time. [1.x](https://github.com/rockcarver/frodo-lib/tree/1.x) operates using a global singleton, making it impossible to connect to more than one platform instance at a time. + +#### New Library Structure + +Removing the singleton pattern and introducing multi-instantiability forced a radical redesign of the core library functions while striving to maintain the basic usage pattern. The library is now exposing two main types describing its modules ([Frodo](https://rockcarver.github.io/frodo-lib/types/Reference.Frodo.html)) and state ([State](https://rockcarver.github.io/frodo-lib/types/Reference.State.html)). Each module in turn exports all its collection of functions as a type as well. Exposing the library structure as types enables auto-completion for both JS and TS developers with properly configured IDEs like Visual Studio Code or other and also serves as an abstraction layer between what the library exposes vs what and how it's implemented. + +#### New `FrodoError` Class + +All the errors thrown by the library are of the class `FrodoError`, introduced in 2.x. The new error class addresses the following challenges of earlier library versions: + +- Allows applications using the library to determine if the error originated in the library or is an unexpected and unhandled error from deeper down the stack. +- Nesting of errors: + + When the library throws because it caught an error thrown deeper down the stack, it wraps the caught `Error` in a `FrodoError`. + +- Nesting of arrays of errors + + The library supports many operation that require a number of actions to occur in a row or in parallel. Often these operations are REST API calls and any of those calls may fail for any reason. To preserve status of every operation, `FrodoError` can also wrap an array of errors, each of which may be another instance of `FrodoError` wrapping an individual or an array of errors. + +- Provides a stack-like combined error message concatenating the messages of all wrapped errors and nested errors. + +- Includes standardized fields to surface network errors in case the `Error` on top of the stack is an `AxiosError`. + +- The new `printError` function recognizes `FrodoError` and prints a uniformly formatted expression of the error including an interpretation of the fields for network stack errors. + +#### New Modules + +The following modules have been updated and/or added since [1.x](https://github.com/rockcarver/frodo-lib/tree/1.x): + +| Module | Since | Capabilities | +| -------------------------- | ----- | ----------------------------------------------------------------------------------------------- | +| frodo.admin | 1.0.0 | Library of common and complex admin tasks. | +| frodo.agent | 1.0.0 | Manage web, java, and gateway agents. | +| frodo.app | 2.0.0 | Manage platform applications and dependencies. | +| frodo.authn.journey | 1.0.0 | Manage authentication journeys. | +| frodo.authn.node | 1.0.0 | Manage authentication nodes. | +| frodo.authn.settings | 2.0.0 | Manage realm-wide authentication settings. | +| frodo.authz.policy | 1.0.0 | Manage authorization policies and dependencies. | +| frodo.authz.policySet | 1.0.0 | Manage policy sets and dependencies. | +| frodo.authz.resourceType | 1.0.0 | Manage resource types and dependencies. | +| frodo.cache | 2.0.0 | Token cache management exposed through the library but primarily used internally. | +| frodo.cloud.adminFed | 1.0.0 | Manage PingOne Advanced Identity Cloud admin federation. | +| frodo.cloud.feature | 1.0.0 | Obtain info on PingOne Advanced Identity Cloud features. | +| frodo.cloud.log | 1.0.0 | Access PingOne Advanced Identity Cloud debug and audit logs. | +| frodo.cloud.secret | 1.0.0 | Mange secrets in PingOne Advanced Identity Cloud. | +| frodo.cloud.serviceAccount | 1.0.0 | Manage service accounts in PingOne Advanced Identity Cloud. | +| frodo.cloud.startup | 1.0.0 | Apply changes to secrets and variables and restart services in PingOne Advanced Identity Cloud. | +| frodo.cloud.variable | 1.0.0 | Manage variables in PingOne Advanced Identity Cloud. | +| frodo.conn | 1.0.0 | Manage connection profiles. | +| frodo.config | 2.0.0 | Manage the whole platform configuration. | +| frodo.email.template | 1.0.0 | Manage email templates (IDM). | +| frodo.idm.config | 2.0.0 | Manage any IDM configuration object. | +| frodo.idm.connector | 2.0.0 | Manage IDM connector configuration. | +| frodo.idm.managed | 1.0.0 | Manage IDM managed object schema (managed.json). | +| frodo.idm.mapping | 2.0.0 | Manage IDM mappings (sync.json). | +| frodo.idm.organization | 1.0.0 | Limited Org Model management exposed through the library but primarily used internally. | +| frodo.idm.recon | 2.0.0 | Read, start, cancel IDM recons. | +| frodo.idm.system | 2.0.0 | Manage data in connected systems. | +| frodo.info | 1.0.0 | Obtain information about the connected instance and authenticated identity. | +| frodo.login | 1.0.0 | Authenticate and obtain necessary tokens. | +| frodo.oauth2oidc.client | 1.0.0 | Manage OAuth 2.0 clients. | +| frodo.oauth2oidc.endpoint | 2.0.0 | Limited OAuth 2.0 grant flows exposed through the library but primarily used internally. | +| frodo.oauth2oidc.external | 1.0.0 | Manage external OAuth 2.0/OIDC 1.0 (social) identity providers. | +| frodo.oauth2oidc.issuer | 2.0.0 | Manage trusted OAuth 2.0 JWT issuers. | +| frodo.oauth2oidc.provider | 1.0.0 | Manage the realm OAuth 2.0 provider. | +| frodo.realm | 1.0.0 | Manage realms. | +| frodo.saml.circlesOfTrust | 1.0.0 | Manage SAML 2.0 circles of trust. | +| frodo.saml.entityProvider | 1.0.0 | Manage SAML 2.0 entity providers. | +| frodo.script | 1.0.0 | Manage access management scripts. | +| frodo.service | 1.0.0 | Manage access management services. | +| frodo.session | 2.0.0 | Limited session management exposed through the library but primarily used internally. | +| frodo.state | 1.0.0 | Manage library state. | +| frodo.theme | 1.0.0 | Manage platform themes (hosted pages). | +| frodo.utils.constants | 1.0.0 | Access relevant library constants. | +| frodo.utils.jose | 1.0.0 | Jose utility functions exposed through the library but primarily used internally. | +| frodo.utils.json | 1.0.0 | JSON utility functions exposed through the library but primarily used internally. | +| frodo.utils.version | 1.0.0 | Utility functions to obtain current library version and available released versions. | + +#### Secure Token Caching + +The 2.x version of the library uses a secure token cache, which is active by default. The cache makes it so that when the `frodo.login.getTokens()` method is called, available tokens are updated in `state` from cache and if none are available, they are obtained from the instance configured in `state`. The cache is tokenized and encrypted on disk, so it persists across library instantiations. You can disable the cache by either setting the `FRODO_NO_CACHE` environment variable or by calling `state.setUseTokenCache(false)` from your application. +You can change the default location of the cache file (`~/.frodo/TokenCache.json`) by either setting the `FRODO_TOKEN_CACHE_PATH` environment variable or by calling `state.setTokenCachePath('/path/to/cache.json')`. + +#### Automatic Token Refresh + +The 2.x version of the library automatically refreshes session and access tokens before they expire. Combined with the new token cache, the library will maintain a set of valid tokens in `state` at all times until it is shut down. If you do not want to automatically refresh tokens, set the `autoRefresh` parameter (2nd param) of your `frodo.login.getTokens()` call to `false`. + +#### Node.js Versions + +- Dropped support for Node.js 14 and 16. +- Kept supporting Node.js 18. +- Added support for Node.js 20 and 22. + +| Node.js | frodo-lib 1.x | **_frodo-lib 2.x_** | frodo-lib 3.x | +| :-----: | :----------------: | :-----------------: | :----------------: | +| 14 | :white_check_mark: | :heavy_minus_sign: | :heavy_minus_sign: | +| 16 | :white_check_mark: | :heavy_minus_sign: | :heavy_minus_sign: | +| 18 | :white_check_mark: | :white_check_mark: | :heavy_minus_sign: | +| 20 | :heavy_minus_sign: | :white_check_mark: | :white_check_mark: | +| 22 | :heavy_minus_sign: | :white_check_mark: | :white_check_mark: | +| 24 | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: | + +### Considerations + +#### Platform Passwords And Secrets + +Platform passwords and secrets are configuration values that are stored encrypted as part of platform configuration. Examples are oauth2 client secrets or service account passwords. + +Frodo generally doesn't export platform passwords and secrets. The platform supports configuration placeholders and environment secrets and variables allowing administrators to separate the functional configuration from sensitive secrets and variable configuration values. `frodo` assumes administrators take full advantage of these capabilities so that there is no need or expectation that exports include passwords and secrets. However, where the APIs support it, administrators can seed import data with raw secrets and `frodo` will import them. + +#### Advanced Identity Cloud Environment Secrets And Variables (ESVs) + +Frodo supports exporting and importing of ESV secret values. To leave stuartship of secret values with the cloud environment where they belong, frodo always encrypts values using either encryption keys from the source environment (default) or the target environment. Frodo never exports secrets in the clear. + ## [2.0.0-96] - 2024-07-17 ## [2.0.0-95] - 2024-07-15 @@ -318,6 +436,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ```javascript import { frodo, state, FrodoLib } from '@rockcarver/frodo-lib'; ``` + - CJS: Member style require any other modules from the library" @@ -510,7 +629,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -- \#165: Frodo now properly lists saved connections in those circumstances where this wasn't the case. +- \#165: Frodo now properly lists saved connections in those circumstances where this wasn't the case. ## [0.18.0] - 2023-01-13 @@ -522,30 +641,33 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ```js import { createJwkRsa, createJwks, getJwkRsaPublic } from './JoseOps'; - import { createServiceAccount, isServiceAccountsFeatureAvailable } from './ServiceAccountOps'; + import { + createServiceAccount, + isServiceAccountsFeatureAvailable, + } from './ServiceAccountOps'; // check if the tenant supports service accounts if (isServiceAccountsFeatureAvailable()) { - const name = 'sa'; - const description = 'service account'; - const accountStatus = 'Active'; - const scopes = ['fr:am:*', 'fr:idm:*', 'fr:idc:esv:*']; - // create a java web key (JWK) using RSA - const jwk = await createJwkRsa(); - // extract only the public key as a JWK from the full JWK - const publicJwk = await getJwkRsaPublic(jwk); - // create a java wek key set (JWKS) from the public JWK - const jwks = await createJwks(publicJwk); - // create service account - const payload = await ServiceAccount.createServiceAccount( - name, - description, - accountStatus, - scopes, - jwks - ); - // uuid of new service account if creation succeeded - const saId = payload._id; + const name = 'sa'; + const description = 'service account'; + const accountStatus = 'Active'; + const scopes = ['fr:am:*', 'fr:idm:*', 'fr:idc:esv:*']; + // create a java web key (JWK) using RSA + const jwk = await createJwkRsa(); + // extract only the public key as a JWK from the full JWK + const publicJwk = await getJwkRsaPublic(jwk); + // create a java wek key set (JWKS) from the public JWK + const jwks = await createJwks(publicJwk); + // create service account + const payload = await ServiceAccount.createServiceAccount( + name, + description, + accountStatus, + scopes, + jwks + ); + // uuid of new service account if creation succeeded + const saId = payload._id; } ``` @@ -638,30 +760,33 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ```js import { createJwkRsa, createJwks, getJwkRsaPublic } from './JoseOps'; - import { createServiceAccount, isServiceAccountsFeatureAvailable } from './ServiceAccountOps'; + import { + createServiceAccount, + isServiceAccountsFeatureAvailable, + } from './ServiceAccountOps'; // check if the tenant supports service accounts if (isServiceAccountsFeatureAvailable()) { - const name = 'sa'; - const description = 'service account'; - const accountStatus = 'Active'; - const scopes = ['fr:am:*', 'fr:idm:*', 'fr:idc:esv:*']; - // create a java web key (JWK) using RSA - const jwk = await createJwkRsa(); - // extract only the public key as a JWK from the full JWK - const publicJwk = await getJwkRsaPublic(jwk); - // create a java wek key set (JWKS) from the public JWK - const jwks = await createJwks(publicJwk); - // create service account - const payload = await ServiceAccount.createServiceAccount( - name, - description, - accountStatus, - scopes, - jwks - ); - // uuid of new service account if creation succeeded - const saId = payload._id; + const name = 'sa'; + const description = 'service account'; + const accountStatus = 'Active'; + const scopes = ['fr:am:*', 'fr:idm:*', 'fr:idc:esv:*']; + // create a java web key (JWK) using RSA + const jwk = await createJwkRsa(); + // extract only the public key as a JWK from the full JWK + const publicJwk = await getJwkRsaPublic(jwk); + // create a java wek key set (JWKS) from the public JWK + const jwks = await createJwks(publicJwk); + // create service account + const payload = await ServiceAccount.createServiceAccount( + name, + description, + accountStatus, + scopes, + jwks + ); + // uuid of new service account if creation succeeded + const saId = payload._id; } ``` @@ -683,15 +808,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 import { Service } from '@rockcarver/frodo-lib'; const { - createServiceExportTemplate, - deleteFullServices, - deleteFullService, - getListOfServices, - getFullServices, - exportServices, - exportService, - importServices, - importService, + createServiceExportTemplate, + deleteFullServices, + deleteFullService, + getListOfServices, + getFullServices, + exportServices, + exportService, + importServices, + importService, } = Service; ``` @@ -709,34 +834,35 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 import { Agent } from '@rockcarver/frodo-lib'; const { - AGENT_TYPE_IG, - AGENT_TYPE_JAVA, - AGENT_TYPE_WEB, - createAgentExportTemplate, - getAgents, - getIdentityGatewayAgents, - getJavaAgents, - getWebAgents, - exportAgents, - exportIdentityGatewayAgents, - exportJavaAgents, - exportWebAgents, - exportAgent, - exportIdentityGatewayAgent, - exportJavaAgent, - exportWebAgent, - importAgents, - importIdentityGatewayAgents, - importJavaAgents, - importWebAgents, - importAgent, - importIdentityGatewayAgent, - importJavaAgent, - importWebAgent, + AGENT_TYPE_IG, + AGENT_TYPE_JAVA, + AGENT_TYPE_WEB, + createAgentExportTemplate, + getAgents, + getIdentityGatewayAgents, + getJavaAgents, + getWebAgents, + exportAgents, + exportIdentityGatewayAgents, + exportJavaAgents, + exportWebAgents, + exportAgent, + exportIdentityGatewayAgent, + exportJavaAgent, + exportWebAgent, + importAgents, + importIdentityGatewayAgents, + importJavaAgents, + importWebAgents, + importAgent, + importIdentityGatewayAgent, + importJavaAgent, + importWebAgent, } = Agent; ``` - \#180: Allow all connection parameters to be supplied using environment variables for secure CI/CD: + - `FRODO_HOST` - `FRODO_REALM` - `FRODO_USERNAME` @@ -757,8 +883,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * @param {string} message the message */ export function curlirizeMessage(message) { - if (!message) return; - console.error(message['brightBlue']); + if (!message) return; + console.error(message['brightBlue']); } state.setCurlirizeHandler(curlirizeMessage); @@ -769,11 +895,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ```js import { Saml2 } from '@rockcarver/frodo-lib'; - const { - getRawProviders, - getRawProvider, - putRawProvider, - } = Saml2; + const { getRawProviders, getRawProvider, putRawProvider } = Saml2; ``` - More automated tests