Skip to content

Commit 36a1cfd

Browse files
committed
chore: comments
1 parent 5802073 commit 36a1cfd

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

src/cmap/auth/mongodb_oidc/azure_machine_workflow.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { addAzureParams, AZURE_BASE_URL } from '../../../client-side-encryption/providers/azure';
22
import { MongoAzureError } from '../../../error';
33
import { get } from '../../../utils';
4-
import type { OIDCCallbackParams, OIDCResponse } from '../mongodb_oidc';
4+
import type { OIDCCallbackFunction, OIDCCallbackParams, OIDCResponse } from '../mongodb_oidc';
55

66
/** Azure request headers. */
77
const AZURE_HEADERS = Object.freeze({ Metadata: 'true', Accept: 'application/json' });
@@ -19,7 +19,9 @@ const TOKEN_RESOURCE_MISSING_ERROR =
1919
* @param params - The OIDC callback parameters.
2020
* @returns The OIDC response.
2121
*/
22-
export async function callback(params: OIDCCallbackParams): Promise<OIDCResponse> {
22+
export const callback: OIDCCallbackFunction = async (
23+
params: OIDCCallbackParams
24+
): Promise<OIDCResponse> => {
2325
const tokenAudience = params.tokenAudience;
2426
const username = params.username;
2527
if (!tokenAudience) {
@@ -30,7 +32,7 @@ export async function callback(params: OIDCCallbackParams): Promise<OIDCResponse
3032
throw new MongoAzureError(ENDPOINT_RESULT_ERROR);
3133
}
3234
return response;
33-
}
35+
};
3436

3537
/**
3638
* Hit the Azure endpoint to get the token data.

src/cmap/auth/mongodb_oidc/gcp_machine_workflow.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { MongoGCPError } from '../../../error';
22
import { get } from '../../../utils';
3-
import type { OIDCCallbackParams, OIDCResponse } from '../mongodb_oidc';
3+
import type { OIDCCallbackFunction, OIDCCallbackParams, OIDCResponse } from '../mongodb_oidc';
44

55
/** GCP base URL. */
66
const GCP_BASE_URL =
@@ -18,13 +18,15 @@ const TOKEN_RESOURCE_MISSING_ERROR =
1818
* @param params - The OIDC callback parameters.
1919
* @returns The OIDC response.
2020
*/
21-
export async function callback(params: OIDCCallbackParams): Promise<OIDCResponse> {
21+
export const callback: OIDCCallbackFunction = async (
22+
params: OIDCCallbackParams
23+
): Promise<OIDCResponse> => {
2224
const tokenAudience = params.tokenAudience;
2325
if (!tokenAudience) {
2426
throw new MongoGCPError(TOKEN_RESOURCE_MISSING_ERROR);
2527
}
2628
return await getGcpTokenData(tokenAudience);
27-
}
29+
};
2830

2931
/**
3032
* Hit the GCP endpoint to get the token data.

src/cmap/auth/mongodb_oidc/k8s_machine_workflow.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { readFile } from 'fs/promises';
22

3-
import type { OIDCResponse } from '../mongodb_oidc';
3+
import type { OIDCCallbackFunction, OIDCResponse } from '../mongodb_oidc';
44

55
/** The fallback file name */
66
const FALLBACK_FILENAME = '/var/run/secrets/kubernetes.io/serviceaccount/token';
@@ -16,7 +16,7 @@ const AWS_FILENAME = 'AWS_WEB_IDENTITY_TOKEN_FILE';
1616
* @param params - The OIDC callback parameters.
1717
* @returns The OIDC response.
1818
*/
19-
export async function callback(): Promise<OIDCResponse> {
19+
export const callback: OIDCCallbackFunction = async (): Promise<OIDCResponse> => {
2020
let filename: string;
2121
if (process.env[AZURE_FILENAME]) {
2222
filename = process.env[AZURE_FILENAME];
@@ -27,4 +27,4 @@ export async function callback(): Promise<OIDCResponse> {
2727
}
2828
const token = await readFile(filename, 'utf8');
2929
return { accessToken: token };
30-
}
30+
};
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as fs from 'fs';
22

33
import { MongoAWSError } from '../../../error';
4-
import { type OIDCResponse } from '../mongodb_oidc';
4+
import type { OIDCCallbackFunction, OIDCResponse } from '../mongodb_oidc';
55

66
/** Error for when the token is missing in the environment. */
77
const TOKEN_MISSING_ERROR = 'OIDC_TOKEN_FILE must be set in the environment.';
@@ -11,11 +11,11 @@ const TOKEN_MISSING_ERROR = 'OIDC_TOKEN_FILE must be set in the environment.';
1111
* @param params - The OIDC callback parameters.
1212
* @returns The OIDC response.
1313
*/
14-
export async function callback(): Promise<OIDCResponse> {
14+
export const callback: OIDCCallbackFunction = async (): Promise<OIDCResponse> => {
1515
const tokenFile = process.env.OIDC_TOKEN_FILE;
1616
if (!tokenFile) {
1717
throw new MongoAWSError(TOKEN_MISSING_ERROR);
1818
}
1919
const token = await fs.promises.readFile(tokenFile, 'utf8');
2020
return { accessToken: token };
21-
}
21+
};

0 commit comments

Comments
 (0)