Skip to content

Commit 42cabfc

Browse files
committed
cleanup basket
1 parent 190f73c commit 42cabfc

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

apps/basket/src/lib/security.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import crypto, { createHash } from "node:crypto";
1+
import crypto from "node:crypto";
22
import { cacheable, redis } from "@databuddy/redis";
33
import { captureError } from "@lib/tracing";
4+
import { CryptoHasher } from "bun";
45

56
const EXIT_EVENT_TTL = 172_800;
67
const STANDARD_EVENT_TTL = 86_400;
@@ -40,15 +41,17 @@ export const getDailySalt = cacheable(
4041

4142
export function saltAnonymousId(anonymousId: string, salt: string): string {
4243
try {
43-
return createHash("sha256")
44-
.update(anonymousId + salt)
45-
.digest("hex");
44+
const hasher = new CryptoHasher("sha256");
45+
hasher.update(anonymousId + salt);
46+
return hasher.digest("hex");
4647
} catch (error) {
4748
captureError(error, {
4849
message: "Failed to salt anonymous ID",
4950
anonymousId,
5051
});
51-
return createHash("sha256").update(anonymousId).digest("hex");
52+
const fallbackHasher = new CryptoHasher("sha256");
53+
fallbackHasher.update(anonymousId);
54+
return fallbackHasher.digest("hex");
5255
}
5356
}
5457

basket.Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,21 @@ COPY packages/ ./packages/
1717
RUN bun install
1818

1919
COPY apps/basket/src ./apps/basket/src
20+
COPY apps/basket/tsconfig.json ./apps/basket/tsconfig.json
2021

2122
ENV NODE_ENV=production
2223

24+
WORKDIR /app/apps/basket
25+
2326
RUN bun build \
2427
--compile \
2528
--minify-whitespace \
2629
--minify-syntax \
2730
--target bun \
28-
--outfile server \
31+
--outfile /app/server \
2932
--sourcemap \
3033
--bytecode \
31-
./apps/basket/src/index.ts
34+
./src/index.ts
3235

3336
FROM gcr.io/distroless/base
3437

0 commit comments

Comments
 (0)