1- import crypto from 'crypto ' ;
1+ import { xxh3 , Xxh3 } from '@node-rs/xxhash ' ;
22import R from 'ramda' ;
33import { createQuery , compile , queryClass , PreAggregations , QueryFactory } from '@cubejs-backend/schema-compiler' ;
44import { v4 as uuidv4 , parse as uuidParse , stringify as uuidStringify } from 'uuid' ;
@@ -55,7 +55,7 @@ export class CompilerApi {
5555
5656 if ( this . options . devServer || this . options . fastReload ) {
5757 const files = await this . repository . dataSchemaFiles ( ) ;
58- compilerVersion += `_${ crypto . createHash ( 'md5' ) . update ( JSON . stringify ( files ) ) . digest ( 'hex' ) } ` ;
58+ compilerVersion += `_${ xxh3 . xxh64 ( JSON . stringify ( files ) ) . toString ( 16 ) } ` ;
5959 }
6060
6161 if ( ! this . compilers || this . compilerVersion !== compilerVersion ) {
@@ -224,7 +224,7 @@ export class CompilerApi {
224224
225225 hashRequestContext ( context ) {
226226 if ( ! context . __hash ) {
227- context . __hash = crypto . createHash ( 'md5' ) . update ( JSON . stringify ( context ) ) . digest ( 'hex' ) ;
227+ context . __hash = xxh3 . xxh64 ( JSON . stringify ( context ) ) . toString ( 16 ) ;
228228 }
229229 return context . __hash ;
230230 }
@@ -505,7 +505,7 @@ export class CompilerApi {
505505 const visibiliyMask = JSON . stringify ( isMemberVisibleInContext , Object . keys ( isMemberVisibleInContext ) . sort ( ) ) ;
506506 // This hash will be returned along the modified meta config and can be used
507507 // to distinguish between different "schema versions" after DAP visibility is applied
508- const visibilityMaskHash = crypto . createHash ( 'sha256' ) . update ( visibiliyMask ) . digest ( 'hex' ) ;
508+ const visibilityMaskHash = xxh3 . xxh64 ( visibiliyMask ) . toString ( 16 ) ;
509509
510510 return {
511511 cubes : cubes
@@ -525,8 +525,8 @@ export class CompilerApi {
525525 mixInVisibilityMaskHash ( compilerId , visibilityMaskHash ) {
526526 const uuidBytes = uuidParse ( compilerId ) ;
527527 const hashBytes = Buffer . from ( visibilityMaskHash , 'hex' ) ;
528- return uuidv4 ( { random : crypto . createHash ( 'sha256' ) . update ( uuidBytes ) . update ( hashBytes ) . digest ( )
529- . subarray ( 0 , 16 ) } ) ;
528+ return uuidv4 ( { random : Buffer . from ( new Xxh3 ( ) . update ( uuidBytes ) . update ( hashBytes ) . digest ( )
529+ . toString ( 16 ) , 'hex' ) . subarray ( 0 , 16 ) } ) ;
530530 }
531531
532532 async metaConfig ( requestContext , options = { } ) {
0 commit comments