Skip to content

Commit

Permalink
Stop using CryptoJS for token request signing
Browse files Browse the repository at this point in the history
Instead, use the HMAC implementation added in fc94b80.

Resolves #1295.
  • Loading branch information
lawrence-forooghian committed Jun 7, 2023
1 parent 32833d4 commit 90dde04
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/platform/web/lib/util/bufferutils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import WordArray from 'crypto-js/build/lib-typedarrays';
import Platform from 'common/platform';
import IBufferUtils from 'common/types/IBufferUtils';
import HmacSHA256 from 'crypto-js/build/hmac-sha256';
import { sign as hmacSha256 } from './hmac-sha256';

/* Most BufferUtils methods that return a binary object return an ArrayBuffer
* The exception is toBuffer, which returns a Uint8Array (and won't work on
Expand Down Expand Up @@ -218,12 +218,7 @@ class BufferUtils implements IBufferUtils<Bufferlike, Output, ToBufferOutput, Wo
}

hmacSha256(message: Bufferlike, key: Bufferlike): Output {
const messageWordArray = this.toWordArray(message);
const keyWordArray = this.toWordArray(key);

const digest = HmacSHA256(messageWordArray, keyWordArray);

return this.toArrayBuffer(digest);
return hmacSha256(this.toBuffer(key), this.toBuffer(message));
}
}

Expand Down

0 comments on commit 90dde04

Please sign in to comment.