Skip to content

Commit 59253f6

Browse files
committed
reduce bundle size
1 parent 8381949 commit 59253f6

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ build: src/ cloudformation/
6464
sam build --template-file cloudformation/main.yml --use-container --parallel
6565
mkdir -p .aws-sam/build/AppApiLambdaFunction/node_modules/aws-crt/
6666
cp -r node_modules/aws-crt/dist .aws-sam/build/AppApiLambdaFunction/node_modules/aws-crt
67+
## IF WE EVER CHANGE THE LAMBDA ARCH, BE SURE TO CHANGE THESE ##
68+
rm -rf .aws-sam/build/AppApiLambdaFunction/node_modules/aws-crt/dist/bin/darwin*
69+
rm -rf .aws-sam/build/AppApiLambdaFunction/node_modules/aws-crt/dist/bin/linux-x64*
70+
rm -rf .aws-sam/build/AppApiLambdaFunction/node_modules/aws-crt/dist/bin/linux-arm64-musl
71+
rm -rf .aws-sam/build/AppApiLambdaFunction/node_modules/argon2/prebuilds/darwin*
72+
rm -rf .aws-sam/build/AppApiLambdaFunction/node_modules/argon2/prebuilds/freebsd*
73+
rm -rf .aws-sam/build/AppApiLambdaFunction/node_modules/argon2/prebuilds/linux-arm
74+
rm -rf .aws-sam/build/AppApiLambdaFunction/node_modules/argon2/prebuilds/linux-x64*
75+
rm -rf .aws-sam/build/AppApiLambdaFunction/node_modules/argon2/prebuilds/win32-x64*
76+
rm -rf .aws-sam/build/AppApiLambdaFunction/node_modules/argon2/prebuilds/linux-arm64/argon2.armv8.musl.node
6777

6878
local:
6979
VITE_BUILD_HASH=$(GIT_HASH) yarn run dev

src/api/createLambdaPackage.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ function getPath() {
99
return { pathname, dirname, basename };
1010
}
1111
// These are packages not bundled into the JS file by esbuild
12+
// These packages have native deps that break when bundled
1213
export const packagesToTransfer = [
1314
"moment-timezone",
1415
"passkit-generator",

src/api/functions/apiKey.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createHash, randomBytes } from "crypto";
2-
import * as argon2 from "argon2";
2+
import { hash, verify } from "argon2";
33
import { UnauthenticatedError } from "common/errors/index.js";
44
import NodeCache from "node-cache";
55
import {
@@ -33,7 +33,7 @@ export const createApiKey = async () => {
3333
const rawKey = randomBytes(32).toString("hex");
3434
const checksum = createChecksum(rawKey);
3535
const apiKey = `${prefix}_${rawKey}_${checksum}`;
36-
const hashedKey = await argon2.hash(rawKey);
36+
const hashedKey = await hash(rawKey);
3737
return { apiKey, hashedKey, keyId };
3838
};
3939

@@ -75,7 +75,7 @@ export const verifyApiKey = async ({
7575
if (!isChecksumValid) {
7676
return false;
7777
}
78-
return await argon2.verify(hashedKey, rawKey);
78+
return await verify(hashedKey, rawKey);
7979
} catch (e) {
8080
if (e instanceof UnauthenticatedError) {
8181
return false;

src/api/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
"ioredis": "^5.6.1",
4949
"jsonwebtoken": "^9.0.2",
5050
"jwks-rsa": "^3.2.0",
51-
"lambda-warmer": "^2.3.0",
5251
"moment": "^2.30.1",
5352
"moment-timezone": "^0.6.0",
5453
"node-cache": "^5.1.2",
@@ -71,4 +70,4 @@
7170
"nodemon": "^3.1.10",
7271
"pino-pretty": "^13.0.0"
7372
}
74-
}
73+
}

yarn.lock

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7041,11 +7041,6 @@ known-css-properties@^0.37.0:
70417041
resolved "https://registry.yarnpkg.com/known-css-properties/-/known-css-properties-0.37.0.tgz#10ebe49b9dbb6638860ff8a002fb65a053f4aec5"
70427042
integrity sha512-JCDrsP4Z1Sb9JwG0aJ8Eo2r7k4Ou5MwmThS/6lcIe1ICyb7UBJKGRIUUdqc2ASdE/42lgz6zFUnzAIhtXnBVrQ==
70437043

7044-
lambda-warmer@^2.3.0:
7045-
version "2.3.0"
7046-
resolved "https://registry.yarnpkg.com/lambda-warmer/-/lambda-warmer-2.3.0.tgz#c4dcb46c73cbdf732824d3c54a99b4752c6b8a04"
7047-
integrity sha512-k3E+5tXtzXdBX2JDaL+f59CREWTch+fsNk5tyrX69TpC6FgERoFS8xG/vQ4dHR9dUgpKxRf1+y+aH8EI4oF/MQ==
7048-
70497044
language-subtag-registry@^0.3.20:
70507045
version "0.3.23"
70517046
resolved "https://registry.yarnpkg.com/language-subtag-registry/-/language-subtag-registry-0.3.23.tgz#23529e04d9e3b74679d70142df3fd2eb6ec572e7"

0 commit comments

Comments
 (0)