Skip to content

Commit 04feb93

Browse files
author
VishnuGadekar7
committed
crypto api inconsistency error resolved
1 parent bbd10fc commit 04feb93

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

docker/Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:lts-alpine as BUILD
1+
FROM node:lts-alpine as build
22

33
WORKDIR /chat-e2ee
44
# todo break apart client and server dep installs/builds so that they can be cached b/w builds
@@ -15,11 +15,11 @@ FROM node:lts-alpine
1515
WORKDIR /chat-e2ee
1616
COPY package*.json /chat-e2ee/
1717
RUN mkdir -p /chat-e2ee/client/dist
18-
COPY --from=BUILD /chat-e2ee/dist /chat-e2ee/dist
19-
COPY --from=BUILD /chat-e2ee/client/dist /chat-e2ee/client/dist
18+
COPY --from=build /chat-e2ee/dist /chat-e2ee/dist
19+
COPY --from=build /chat-e2ee/client/dist /chat-e2ee/client/dist
2020

2121
# dont install dev deps
22-
ENV NODE_ENV "production"
22+
ENV NODE_ENV=production
2323
# dont run scripts to avoid pulling all client build deps + stuff
2424
RUN npm ci --ignore-scripts=true --omit dev
2525

service/src/cryptoAES.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ export class AesGcmEncryption {
3030
if (!this.aesKeyLocal) {
3131
throw new Error('AES key not generated');
3232
}
33-
const jsonWebKey = await crypto.subtle.exportKey("jwk", this.aesKeyLocal);
33+
const jsonWebKey = await window.crypto.subtle.exportKey("jwk", this.aesKeyLocal);
3434
return JSON.stringify(jsonWebKey);
3535
}
3636

3737
public async setRemoteAesKey(key: string): Promise<void> {
3838
const jsonWebKey = JSON.parse(key);
39-
this.aesKeyRemote = await crypto.subtle.importKey(
39+
this.aesKeyRemote = await window.crypto.subtle.importKey(
4040
"jwk",
4141
jsonWebKey,
4242
{ name: "AES-GCM" },
@@ -47,13 +47,13 @@ export class AesGcmEncryption {
4747
}
4848

4949
public async encryptData(data: ArrayBuffer) {
50-
if(!this.aesKeyLocal) {
50+
if (!this.aesKeyLocal) {
5151
throw new Error('Local AES key not generated.')
5252
};
5353
// Generate an Initialization Vector (IV) for AES-GCM (12 bytes)
54-
const iv = crypto.getRandomValues(new Uint8Array(12));
54+
const iv = window.crypto.getRandomValues(new Uint8Array(12));
5555
// Encrypt the frame data using AES-GCM
56-
const encryptedData = await crypto.subtle.encrypt(
56+
const encryptedData = await window.crypto.subtle.encrypt(
5757
{
5858
name: "AES-GCM",
5959
iv: iv
@@ -70,7 +70,7 @@ export class AesGcmEncryption {
7070
if (!this.aesKeyRemote) {
7171
throw new Error('Remote AES key not set.')
7272
}
73-
return crypto.subtle.decrypt(
73+
return window.crypto.subtle.decrypt(
7474
{
7575
name: "AES-GCM",
7676
iv

0 commit comments

Comments
 (0)