Skip to content

Commit f4a1687

Browse files
committed
fix errors and mark getProxySettings() as deprecated
1 parent 6ad2823 commit f4a1687

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

packages/cubejs-api-gateway/src/jwk.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
/* eslint-disable no-restricted-syntax */
22
import crypto from 'crypto';
3-
import { asyncMemoizeBackground, asyncRetry, BackgroundMemoizeOptions, getHttpAgentForProxySettings } from '@cubejs-backend/shared';
3+
import {
4+
asyncMemoizeBackground,
5+
asyncRetry,
6+
BackgroundMemoizeOptions,
7+
getHttpAgentForProxySettings
8+
} from '@cubejs-backend/shared';
49
import fetch from 'node-fetch';
510
import jwkToPem from 'jwk-to-pem';
611
import { JWTOptions } from './interfaces';
@@ -51,7 +56,7 @@ export type JWKsFetcherOptions = Pick<BackgroundMemoizeOptions<any, any>, 'onBac
5156

5257
export const createJWKsFetcher = (jwtOptions: JWTOptions, options: JWKsFetcherOptions) => {
5358
const fetchJwkUrl = asyncMemoizeBackground(async (url: string) => {
54-
const response = await asyncRetry(() => fetch(url, { agent: await getHttpAgentForProxySettings() }), {
59+
const response = await asyncRetry(async () => fetch(url, { agent: await getHttpAgentForProxySettings() }), {
5560
times: jwtOptions.jwkRetry || 3,
5661
});
5762
const json = await response.json();

packages/cubejs-backend-shared/src/proxy.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ function getCommandOutput(command: string) {
1414
});
1515
}
1616

17-
// deprecated, use ProxyAgent instead
17+
/**
18+
* @deprecated
19+
* use ProxyAgent instead
20+
*/
1821
export async function getProxySettings() {
1922
const [proxy] = (
2023
await Promise.all([getCommandOutput('npm config -g get https-proxy'), getCommandOutput('npm config -g get proxy')])
@@ -26,5 +29,12 @@ export async function getProxySettings() {
2629
}
2730

2831
export async function getHttpAgentForProxySettings() {
32+
const proxy = await getProxySettings();
33+
34+
if (proxy) {
35+
console.warn('Npm proxy settings are deprecated. Please use HTTP_PROXY, HTTPS_PROXY environment variables instead.');
36+
return proxy;
37+
}
38+
2939
return new ProxyAgent();
3040
}

0 commit comments

Comments
 (0)