UNPKG

data-and-reporting-sdk

Version:

Data And Reporting product consists of API's which provides details of transaction and invoice informations about shell cards. The Shell Card Transaction and Invoice API is REST-based and employs Basic authentication in Version 1 and Oauth authentication

30 lines 1.4 kB
/** * Shell Data & Reporting APIsLib * * This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ). */ import { basicAuthenticationProvider, compositeAuthenticationProvider, requestAuthenticationProvider, } from './authentication'; export function createAuthProviderFromConfig(config, bearerToken) { const authConfig = { basicAuth: config.basicAuthCredentials && basicAuthenticationProvider(config.basicAuthCredentials.username, config.basicAuthCredentials.password), bearerToken: config.bearerTokenCredentials && requestAuthenticationProvider(config.bearerTokenCredentials.oAuthToken, bearerTokenTokenProvider(bearerToken, config.bearerTokenCredentials.oAuthTokenProvider), config.bearerTokenCredentials.oAuthOnTokenUpdate, { clockSkew: config.bearerTokenCredentials.oAuthClockSkew, }), }; return compositeAuthenticationProvider(authConfig); } function bearerTokenTokenProvider(bearerToken, defaultProvider) { return (token) => { const 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