card-management-sdk
Version:
The Shell Card Management API is REST-based and employs OAUTH 2.0,Basic and ApiKey authentication. The API endpoints accept JSON-encoded request bodies, return JSON-encoded responses and use standard HTTP response codes. All resources are located in the S
34 lines • 1.54 kB
JavaScript
;
/**
* Shell Card Management APIsLib
*
* This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
*/
exports.__esModule = true;
exports.createAuthProviderFromConfig = void 0;
var authentication_1 = require("./authentication");
function createAuthProviderFromConfig(config, bearerToken) {
var authConfig = {
basicAuth: config.basicAuthCredentials &&
(0, authentication_1.basicAuthenticationProvider)(config.basicAuthCredentials.username, config.basicAuthCredentials.password),
bearerToken: config.bearerTokenCredentials &&
(0, authentication_1.requestAuthenticationProvider)(config.bearerTokenCredentials.oAuthToken, bearerTokenTokenProvider(bearerToken, config.bearerTokenCredentials.oAuthTokenProvider), config.bearerTokenCredentials.oAuthOnTokenUpdate, {
clockSkew: config.bearerTokenCredentials.oAuthClockSkew
})
};
return (0, authentication_1.compositeAuthenticationProvider)(authConfig);
}
exports.createAuthProviderFromConfig = createAuthProviderFromConfig;
function bearerTokenTokenProvider(bearerToken, defaultProvider) {
return function (token) {
var manager = bearerToken();
if (manager === undefined) {
throw Error('Unable to find the OAuthManager instance');
}
if (defaultProvider === undefined) {
return manager.updateToken(token);
}
return defaultProvider(token, manager);
};
}
//# sourceMappingURL=authProvider.js.map