Skip to content

Commit e908b17

Browse files
committed
chore(token-providers): do not set profile from env (#126)
1 parent 744f177 commit e908b17

File tree

2 files changed

+5
-31
lines changed

2 files changed

+5
-31
lines changed

packages/token-providers/src/nodeProvider.spec.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,24 +61,6 @@ describe(nodeProvider.name, () => {
6161
expect(loadSharedConfigFiles).not.toHaveBeenCalled();
6262
});
6363

64-
it(`reads profile from env['${ENV_PROFILE}'], if not provided in init`, async () => {
65-
const ORIGINAL_ENV = process.env;
66-
process.env = {
67-
...ORIGINAL_ENV,
68-
[ENV_PROFILE]: "envProfile",
69-
};
70-
71-
const { profile, ...mockInitWithoutProfile } = mockInit;
72-
const receivedToken = await nodeProvider(mockInitWithoutProfile)();
73-
expect(receivedToken).toStrictEqual(mockToken);
74-
75-
for (const fromFn of [fromSso]) {
76-
expect(fromFn).toHaveBeenCalledWith({ ...mockInit, profile: process.env[ENV_PROFILE] });
77-
}
78-
79-
process.env = ORIGINAL_ENV;
80-
});
81-
8264
describe("memoize isExpired", () => {
8365
const mockDateNow = Date.now();
8466
beforeEach(async () => {

packages/token-providers/src/nodeProvider.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,11 @@ import { fromSso, FromSsoInit } from "./fromSso";
2020
* SSO cache or ssoOidc.createToken() call
2121
*/
2222

23-
export const nodeProvider = (init: FromSsoInit = {}): TokenProvider => {
24-
const options = {
25-
profile: process.env[ENV_PROFILE],
26-
...init,
27-
};
28-
29-
const providerChain = chain(fromSso(options), async () => {
30-
throw new TokenProviderError("Could not load token from any providers", false);
31-
});
32-
33-
return memoize(
34-
providerChain,
23+
export const nodeProvider = (init: FromSsoInit = {}): TokenProvider =>
24+
memoize(
25+
chain(fromSso(init), async () => {
26+
throw new TokenProviderError("Could not load token from any providers", false);
27+
}),
3528
(token) => token.expiration !== undefined && token.expiration.getTime() - Date.now() < 300000,
3629
(token) => token.expiration !== undefined
3730
);
38-
};

0 commit comments

Comments
 (0)