@@ -44,7 +44,7 @@ const isTokenExpired = (credentials) => {
44
44
45
45
// AUTHORIZATION CODE
46
46
47
- const getOAuth2TokenUsingAuthorizationCode = async ( { request, collectionUid, forceFetch = false } ) => {
47
+ const getOAuth2TokenUsingAuthorizationCode = async ( { request, collectionUid, forceFetch = false , certsAndProxyConfig } ) => {
48
48
let codeVerifier = generateCodeVerifier ( ) ;
49
49
let codeChallenge = generateCodeChallenge ( codeVerifier ) ;
50
50
@@ -76,7 +76,7 @@ const getOAuth2TokenUsingAuthorizationCode = async ({ request, collectionUid, fo
76
76
if ( autoRefreshToken && storedCredentials . refresh_token ) {
77
77
// Try to refresh token
78
78
try {
79
- const refreshedCredentialsData = await refreshOauth2Token ( requestCopy , collectionUid ) ;
79
+ const refreshedCredentialsData = await refreshOauth2Token ( { requestCopy, collectionUid, certsAndProxyConfig } ) ;
80
80
return { collectionUid, url, credentials : refreshedCredentialsData . credentials , credentialsId } ;
81
81
} catch ( error ) {
82
82
// Refresh failed
@@ -149,7 +149,8 @@ const getOAuth2TokenUsingAuthorizationCode = async ({ request, collectionUid, fo
149
149
let axiosResponseInfo = null ;
150
150
151
151
try {
152
- const axiosInstance = makeAxiosInstance ( ) ;
152
+ const { proxyMode, proxyConfig, httpsAgentRequestFields, interpolationOptions } = certsAndProxyConfig ;
153
+ const axiosInstance = makeAxiosInstance ( { proxyMode, proxyConfig, httpsAgentRequestFields, interpolationOptions } ) ;
153
154
// Interceptor to capture request data
154
155
axiosInstance . interceptors . request . use ( ( config ) => {
155
156
const requestData = typeof config ?. data === 'string' ? config ?. data : safeStringifyJSON ( config ?. data ) ;
@@ -282,7 +283,7 @@ const getOAuth2AuthorizationCode = (request, codeChallenge, collectionUid) => {
282
283
283
284
// CLIENT CREDENTIALS
284
285
285
- const getOAuth2TokenUsingClientCredentials = async ( { request, collectionUid, forceFetch = false } ) => {
286
+ const getOAuth2TokenUsingClientCredentials = async ( { request, collectionUid, forceFetch = false , certsAndProxyConfig } ) => {
286
287
let requestCopy = cloneDeep ( request ) ;
287
288
const oAuth = get ( requestCopy , 'oauth2' , { } ) ;
288
289
const {
@@ -310,7 +311,7 @@ const getOAuth2TokenUsingClientCredentials = async ({ request, collectionUid, fo
310
311
if ( autoRefreshToken && storedCredentials . refresh_token ) {
311
312
// Try to refresh token
312
313
try {
313
- const refreshedCredentialsData = await refreshOauth2Token ( requestCopy , collectionUid ) ;
314
+ const refreshedCredentialsData = await refreshOauth2Token ( { requestCopy, collectionUid, certsAndProxyConfig } ) ;
314
315
return { collectionUid, url, credentials : refreshedCredentialsData . credentials , credentialsId } ;
315
316
} catch ( error ) {
316
317
clearOauth2Credentials ( { collectionUid, url, credentialsId } ) ;
@@ -375,7 +376,8 @@ const getOAuth2TokenUsingClientCredentials = async ({ request, collectionUid, fo
375
376
let debugInfo = { data : [ ] } ;
376
377
377
378
try {
378
- const axiosInstance = makeAxiosInstance ( ) ;
379
+ const { proxyMode, proxyConfig, httpsAgentRequestFields, interpolationOptions } = certsAndProxyConfig ;
380
+ const axiosInstance = makeAxiosInstance ( { proxyMode, proxyConfig, httpsAgentRequestFields, interpolationOptions } ) ;
379
381
axiosInstance . interceptors . request . use ( ( config ) => {
380
382
const requestData = typeof config ?. data === 'string' ? config ?. data : safeStringifyJSON ( config ?. data ) ;
381
383
axiosRequestInfo = {
@@ -465,7 +467,7 @@ const getOAuth2TokenUsingClientCredentials = async ({ request, collectionUid, fo
465
467
466
468
// PASSWORD CREDENTIALS
467
469
468
- const getOAuth2TokenUsingPasswordCredentials = async ( { request, collectionUid, forceFetch = false } ) => {
470
+ const getOAuth2TokenUsingPasswordCredentials = async ( { request, collectionUid, forceFetch = false , certsAndProxyConfig } ) => {
469
471
let requestCopy = cloneDeep ( request ) ;
470
472
const oAuth = get ( requestCopy , 'oauth2' , { } ) ;
471
473
const {
@@ -494,7 +496,7 @@ const getOAuth2TokenUsingPasswordCredentials = async ({ request, collectionUid,
494
496
if ( autoRefreshToken && storedCredentials . refresh_token ) {
495
497
// Try to refresh token
496
498
try {
497
- const refreshedCredentialsData = await refreshOauth2Token ( requestCopy , collectionUid ) ;
499
+ const refreshedCredentialsData = await refreshOauth2Token ( { requestCopy, collectionUid, certsAndProxyConfig } ) ;
498
500
return { collectionUid, url, credentials : refreshedCredentialsData . credentials , credentialsId } ;
499
501
} catch ( error ) {
500
502
clearOauth2Credentials ( { collectionUid, url, credentialsId } ) ;
@@ -562,7 +564,8 @@ const getOAuth2TokenUsingPasswordCredentials = async ({ request, collectionUid,
562
564
let debugInfo = { data : [ ] } ;
563
565
564
566
try {
565
- const axiosInstance = makeAxiosInstance ( ) ;
567
+ const { proxyMode, proxyConfig, httpsAgentRequestFields, interpolationOptions } = certsAndProxyConfig ;
568
+ const axiosInstance = makeAxiosInstance ( { proxyMode, proxyConfig, httpsAgentRequestFields, interpolationOptions } ) ;
566
569
axiosInstance . interceptors . request . use ( ( config ) => {
567
570
const requestData = typeof config ?. data === 'string' ? config ?. data : safeStringifyJSON ( config ?. data ) ;
568
571
axiosRequestInfo = {
@@ -649,7 +652,7 @@ const getOAuth2TokenUsingPasswordCredentials = async ({ request, collectionUid,
649
652
}
650
653
} ;
651
654
652
- const refreshOauth2Token = async ( requestCopy , collectionUid ) => {
655
+ const refreshOauth2Token = async ( { requestCopy, collectionUid, certsAndProxyConfig } ) => {
653
656
const oAuth = get ( requestCopy , 'oauth2' , { } ) ;
654
657
const { clientId, clientSecret, credentialsId } = oAuth ;
655
658
const url = oAuth . refreshTokenUrl ? oAuth . refreshTokenUrl : oAuth . accessTokenUrl ;
@@ -680,7 +683,8 @@ const refreshOauth2Token = async (requestCopy, collectionUid) => {
680
683
let axiosResponseInfo = null ;
681
684
let debugInfo = { data : [ ] } ;
682
685
683
- const axiosInstance = makeAxiosInstance ( ) ;
686
+ const { proxyMode, proxyConfig, httpsAgentRequestFields, interpolationOptions } = certsAndProxyConfig ;
687
+ const axiosInstance = makeAxiosInstance ( { proxyMode, proxyConfig, httpsAgentRequestFields, interpolationOptions } ) ;
684
688
axiosInstance . interceptors . request . use ( ( config ) => {
685
689
const requestData = typeof config ?. data === 'string' ? config ?. data : safeStringifyJSON ( config ?. data ) ;
686
690
axiosRequestInfo = {
0 commit comments