Skip to content

Commit

Permalink
Merge branch 'google-lists' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
maryamsharif committed Jul 19, 2024
2 parents 4b9039c + 282469c commit 16d4b82
Show file tree
Hide file tree
Showing 10 changed files with 861 additions and 7 deletions.
3 changes: 2 additions & 1 deletion packages/browser-destinations/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ const unobfuscatedOutput = {
mainFields: ['exports', 'module', 'browser', 'main'],
extensions: ['.ts', '.js'],
fallback: {
vm: require.resolve('vm-browserify')
vm: require.resolve('vm-browserify'),
crypto: false
}
},
devServer: {
Expand Down
13 changes: 13 additions & 0 deletions packages/core/src/hashing-utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Checks if value is already hashed with sha256 to avoid double hashing
*/
import * as crypto from 'crypto'

const sha256HashedRegex = /^[a-f0-9]{64}$/i

export function sha256SmartHash(value: string): string {
if (sha256HashedRegex.test(value)) {
return value
}
return crypto.createHash('sha256').update(value).digest('hex')
}
1 change: 1 addition & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export {
export { get } from './get'
export { omit } from './omit'
export { removeUndefined } from './remove-undefined'
export { sha256SmartHash } from './hashing-utils'
export { time, duration } from './time'

export { realTypeOf, isObject, isArray, isString } from './real-type-of'
Expand Down
Loading

0 comments on commit 16d4b82

Please sign in to comment.