Skip to main content

@wildix/auth-utils

auth-utils package

Classes

Class

Description

OpenIdPbxProvider

The OpenIdPbxProvider class is a token provider implementation that facilitates the retrieval of OpenID tokens. It works with auth service to securely obtain OpenID tokens by using pbx credentials.

Example Usage:

const openIdPbxInput: OpenIdPbxInput = {
pbxSerial: "221100ffffff",
pbxKey: "myPbxLicenseKey",
aud: "myServiceAudience",
scope: "get"
};

const environment: ServiceTokenEnv = "prod"; // Optional, could be "prod", "stage", or "stable"

const openIdProvider = new OpenIdPbxProvider(openIdPbxInput, environment);

try {
const idToken = await openIdProvider.token();
console.log("Received OpenID Token:", idToken);
} catch (error) {
console.error("Error fetching OpenID Token:", error.message);
}

The implementation encapsulates the logic for obtaining and caching OpenID tokens securely, abstracting away the details of the authentication process involving the auth service. The tokens are used primarily for authenticating with services that require OpenID compliance.

OpenIdUserProvider

The OpenIdUserProvider class is a token provider implementation that facilitates the retrieval of OpenID tokens. It interacts with a PBX server and an authentication service to securely obtain OpenID tokens.

Example Usage:

const openIdUserInput: OpenIdUserInput = {
pbxUri: "https://pbx.example.com",
user: "test@example.com",
pass: "securepassword123",
aud: "myServiceAudience",
scope: "get"
};

const environment: ServiceTokenEnv = "prod"; // Optional, could be "prod", "stage", or "stable"

const openIdProvider = new OpenIdUserProvider(openIdUserInput, environment);

try {
const idToken = await openIdProvider.token();
console.log("Received OpenID Token:", idToken);
} catch (error) {
console.error("Error fetching OpenID Token:", error.message);
}

The implementation encapsulates the logic for obtaining and caching OpenID tokens securely, abstracting away the details of the authentication process involving the PBX server and auth services. The tokens are used primarily for authenticating with services that require OpenID compliance.

PbxTokenAuthorizationError

PbxTokenProvider

The PbxTokenProvider class is a token provider implementation that facilitates the retrieval of access tokens for the organization.

Example Usage:

const tokenProvider = new PbxTokenProvider('221100007e84', '<secretKey>');

try {
const token = await tokenProvider.token();
console.log('ID Token:', token);
} catch (error) {
console.error('Error retrieving token:', error);
}

The implementation encapsulates the logic for obtaining and caching access tokens securely, abstracting away the details of the authentication process.

ServiceTokenAuthorizationError

ServiceTokenProvider

The ServiceTokenProvider class is a token provider implementation that facilitates the retrieval of access tokens for a service.

Example Usage:

const clientId = 'yourClientId';
const clientSecret = 'yourClientSecret';
const tokenProvider = new ServiceTokenProvider(clientId, clientSecret);

try {
const accessToken = await tokenProvider.token();
console.log('Access Token:', accessToken);
} catch (error) {
console.error('Error retrieving access token:', error);
}

The implementation encapsulates the logic for obtaining and caching access tokens securely, abstracting away the details of the authentication process.

WmpTokenProvider

The WmpTokenProvider class is a token provider implementation that facilitates the retrieval of access tokens for the WMP Server.

Example Usage:

const wmpClientIss = 'wmpClientIss';
const wmpClientSecret = 'wmpClientSecret';
const env = 'prod'; // always use WMP production
const tokenProvider = new WmpTokenProvider(wmpClientIss, wmpClientSecret, env);

try {
const accessToken = await tokenProvider.token();
console.log('Access Token:', accessToken);
} catch (error) {
console.error('Error retrieving access token:', error);
}

The implementation encapsulates the logic for obtaining and caching access tokens securely, abstracting away the details of the authentication process.

WmsApiTokenAuthorizationError

WmsApiTokenProvider

The WmsApiTokenProvider class is a token provider implementation that facilitates the retrieval of access tokens for the WMS Server.

Example Usage:

const clientId = 'yourClientId';
const clientSecret = 'yourClientSecret';
const tokenProvider = new WmsApiTokenProvider(new ServiceTokenProvider(clientId, clientSecret), 'admin', 'crm-test');

try {
const accessToken = await tokenProvider.token();
console.log('Access Token:', accessToken);
} catch (error) {
console.error('Error retrieving access token:', error);
}

The implementation encapsulates the logic for obtaining and caching access tokens securely, abstracting away the details of the authentication process.

XbsTokenAuthorizationError

XbsTokenProvider

The XbsTokenProvider class is a token provider implementation that facilitates the retrieval of access tokens for the XBS User.

Example Usage:

const tokenProvider = new XbsTokenProvider('autotests-xbees+gststage3autotest@wildix.com', 'OTP', 'stage');

try {
const token = await tokenProvider.token();
console.log('ID Token:', token);
} catch (error) {
console.error('Error retrieving token:', error);
}

The implementation encapsulates the logic for obtaining and caching access tokens securely, abstracting away the details of the authentication process.

Enumerations

Enumeration

Description

ServiceTokenScope

XbsClients

Interfaces

Interface

Description

XbsOtpProvider

Type Aliases

Type Alias

Description

OpenIdPbxInput

OpenIdUserInput

ServiceTokenEnv

WmsApiTokenEnv

XbsOtp

XbsTokenEnv