Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade app-api deps #139840

Merged
merged 9 commits into from
Dec 18, 2024
8 changes: 4 additions & 4 deletions services/app-api/libs/authorization.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SSMClient, GetParameterCommand } from "@aws-sdk/client-ssm";
import jwt_decode from "jwt-decode";
import { jwtDecode } from "jwt-decode";
import { IdmRoles, AppRoles, APIGatewayProxyEvent } from "../types";
import { CognitoJwtVerifier } from "aws-jwt-verify";
import { logger } from "../libs/debug-lib";
Expand Down Expand Up @@ -91,7 +91,7 @@ export const isAuthorized = async (event: APIGatewayProxyEvent) => {
const requestState = event.pathParameters?.state;

// If a state user, always reject if their state does not match a state query param
const decoded = jwt_decode(event.headers["x-api-key"]) as DecodedToken;
const decoded = jwtDecode(event.headers["x-api-key"]) as DecodedToken;
const idmRole = decoded["custom:cms_roles"]
.split(",")
.find((r) => r.includes("mdctcarts")) as IdmRoles;
Expand All @@ -107,7 +107,7 @@ export const getUserNameFromJwt = (event: APIGatewayProxyEvent) => {
let userName = "branchUser";
if (!event.headers?.["x-api-key"]) return userName;

const decoded = jwt_decode(event.headers["x-api-key"]) as DecodedToken;
const decoded = jwtDecode(event.headers["x-api-key"]) as DecodedToken;

if (decoded["given_name"] && decoded["family_name"]) {
userName = `${decoded["given_name"]} ${decoded["family_name"]}`;
Expand All @@ -125,7 +125,7 @@ export const getUserNameFromJwt = (event: APIGatewayProxyEvent) => {
export const getUserCredentialsFromJwt = (event: APIGatewayProxyEvent) => {
if (!event?.headers || !event.headers?.["x-api-key"])
return new UserCredentials();
const decoded = jwt_decode(event.headers["x-api-key"]) as DecodedToken;
const decoded = jwtDecode(event.headers["x-api-key"]) as DecodedToken;
const credentials = new UserCredentials(decoded);
return credentials;
};
Expand Down
2 changes: 1 addition & 1 deletion services/app-api/libs/tests/authorization.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const mockedDecode = jest.fn();

jest.mock("jwt-decode", () => ({
__esModule: true,
default: () => {
jwtDecode: () => {
return mockedDecode();
},
}));
Expand Down
32 changes: 15 additions & 17 deletions services/app-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,27 @@
"url": "https://github.com/AnomalyInnovations/serverless-nodejs-starter.git"
},
"devDependencies": {
"@types/dompurify": "^3.0.5",
"@types/jest": "^27.4.0",
"@types/jest": "^29.5.14",
"@types/jsdom": "^21.1.7",
"aws-sdk-client-mock": "^3.0.0",
"jest": "^27.4.7",
"aws-sdk-client-mock": "^4.1.0",
"jest": "^29.7.0",
"serverless-associate-waf": "^1.2.1",
"serverless-plugin-typescript": "^2.1.0",
"ts-jest": "^27.1.3",
"typescript": "^4.5.4"
"serverless-plugin-typescript": "^2.1.5",
"ts-jest": "^29.2.5",
"typescript": "^5.7.2"
},
"dependencies": {
"@aws-sdk/client-dynamodb": "^3.687.0",
"@aws-sdk/client-s3": "^3.687.0",
"@aws-sdk/client-ssm": "^3.687.0",
"@aws-sdk/lib-dynamodb": "^3.687.0",
"@aws-sdk/s3-request-presigner": "^3.687.0",
"aws-jwt-verify": "^3.1.0",
"dompurify": "^3.1.4",
"jsdom": "^24.1.0",
"@aws-sdk/client-dynamodb": "^3.699.0",
"@aws-sdk/client-s3": "^3.699.0",
"@aws-sdk/client-ssm": "^3.699.0",
"@aws-sdk/lib-dynamodb": "^3.699.0",
"@aws-sdk/s3-request-presigner": "^3.699.0",
"aws-jwt-verify": "^4.0.1",
"dompurify": "^3.2.1",
"jsdom": "^25.0.1",
"jsonpath-plus": "^10.2.0",
"jsonschema": "^1.4.1",
"jwt-decode": "^3.1.2",
"uuid": "^7.0.3"
"jwt-decode": "^4.0.0"
},
"resolutions": {
"ws": "^8.18.0"
Expand Down
Loading
Loading