File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { BSON } from './bson' ;
12import { type AWSCredentials } from './deps' ;
23
34export type Options = {
@@ -23,14 +24,11 @@ export type SignedHeaders = {
2324 } ;
2425} ;
2526
26- const crypto = globalThis . crypto ;
27-
2827const getHash = async ( str : string ) : Promise < string > => {
2928 const encoder = new TextEncoder ( ) ;
3029 const data = encoder . encode ( str ) ;
3130 const hashBuffer = await crypto . subtle . digest ( 'SHA-256' , data ) ;
32- const hashArray = Array . from ( new Uint8Array ( hashBuffer ) ) ;
33- const hashHex = hashArray . map ( b => b . toString ( 16 ) . padStart ( 2 , '0' ) ) . join ( '' ) ;
31+ const hashHex = BSON . onDemand . ByteUtils . toHex ( new Uint8Array ( hashBuffer ) ) ;
3432 return hashHex ;
3533} ;
3634const getHmacBuffer = async ( key : string | Uint8Array , str : string ) : Promise < Uint8Array > => {
@@ -49,8 +47,7 @@ const getHmacBuffer = async (key: string | Uint8Array, str: string): Promise<Uin
4947} ;
5048const getHmacString = async ( key : Uint8Array , str : string ) : Promise < string > => {
5149 const hmacBuffer = await getHmacBuffer ( key , str ) ;
52- const hashArray = Array . from ( hmacBuffer ) ;
53- const hashHex = hashArray . map ( b => b . toString ( 16 ) . padStart ( 2 , '0' ) ) . join ( '' ) ;
50+ const hashHex = BSON . onDemand . ByteUtils . toHex ( hmacBuffer ) ;
5451 return hashHex ;
5552} ;
5653
You can’t perform that action at this time.
0 commit comments