@e2y/occ-client
Version:
OCC client for SAP Commerce Cloud
36 lines (35 loc) • 1.98 kB
TypeScript
import { OAuth2ClientCredentialsConfiguration } from './types/OAuth2ClientCredentialsConfiguration';
import { OAuth2PasswordConfiguration } from './types/OAuth2PasswordConfiguration';
import { OAuth2TokenResponse } from './types/OAuth2TokenResponse';
/**
* Represents an OAuth2 client that can retrieve a token from an OAuth2 token URL using either client credentials or a username and password.
*/
export declare class OAuth2Client {
private readonly oauth2Configuration;
/**
* Creates an instance of Oauth2Client.
* @param {OAuth2PasswordConfiguration | OAuth2ClientCredentialsConfiguration} oauth2Configuration - The OAuth2 configuration to use for retrieving the token.
*/
constructor(oauth2Configuration: OAuth2PasswordConfiguration | OAuth2ClientCredentialsConfiguration);
/**
* Retrieves an OAuth2 token from the OAuth2 token URL using the provided configuration.
* @returns {Promise<OAuth2TokenResponse>} A promise that resolves to an OAuth2TokenResponse object containing the access token.
*/
getToken(): Promise<OAuth2TokenResponse>;
/**
* Generates a basic authorization string using the OAuth2 client ID and client secret.
* @returns {string} A string representing the basic authorization header value.
*/
private generateBasicAuthorization;
/**
* Generates the body of the OAuth2 token request based on the provided configuration.
* @returns {string} A string representing the URL encoded body of the OAuth2 token request.
*/
private generateOAuth2Body;
/**
* Determines if the provided OAuth2 configuration is an instance of OAuth2PasswordConfiguration.
* @param {unknown} oauth2Configuration - The OAuth2 configuration to check.
* @returns {oauth2Configuration is OAuth2PasswordConfiguration} A boolean indicating whether the provided configuration is an instance of OAuth2PasswordConfiguration.
*/
private isOAuth2PasswordConfiguration;
}