Module @forgerock/sdk-utilities

@forgerock/sdk-utilities

A collection of utility functions used by the ForgeRock/Ping Identity JavaScript SDK packages.

This package is intended to be used as a dependency within the ForgeRock/Ping Identity JavaScript SDK ecosystem and is not meant to be installed directly by end users.

Utilities for formatting and handling URLs for ForgeRock/Ping Identity services:

  • getRealmUrlPath: Formats realm paths for use in API calls
  • getEndpointPath: Constructs endpoint paths for various API endpoints

Utilities for OAuth2/OIDC related operations:

  • PKCE (Proof Key for Code Exchange) utilities for OAuth2 authorization code flow
import { getRealmUrlPath, getEndpointPath } from '@forgerock/sdk-utilities';

// Get a formatted realm path
const realmPath = getRealmUrlPath('alpha/beta');
// Returns: "realms/root/realms/alpha/realms/beta"

// Get a specific endpoint path
const authEndpoint = getEndpointPath({
endpoint: 'authenticate',
realmPath: 'alpha',
});
// Returns: "json/realms/root/realms/alpha/authenticate"

// With custom path
const customAuthEndpoint = getEndpointPath({
endpoint: 'authenticate',
realmPath: 'alpha',
customPaths: { authenticate: 'custom/authenticate' },
});
// Returns: "custom/authenticate"
import { createVerifier, createChallenge } from '@forgerock/sdk-utilities';

// Create a PKCE verifier
const verifier = createVerifier();

// Generate a challenge from the verifier
const challenge = await createChallenge(verifier);

To run tests:

pnpm test

To run tests in watch mode:

pnpm test:watch

To lint the codebase:

pnpm lint

This project is licensed under the terms of the MIT license. See the LICENSE file for details.

Modules

index
types