File tree Expand file tree Collapse file tree 1 file changed +17
-7
lines changed
Expand file tree Collapse file tree 1 file changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -267,20 +267,30 @@ export default class RoktManager {
267267 return { } ;
268268 }
269269
270- const hashedAttributes : IRoktPartnerAttributes = { } ;
270+ // Get own property keys only
271+ const keys = Object . keys ( attributes ) ;
272+
273+ if ( keys . length === 0 ) {
274+ return { } ;
275+ }
271276
272- for ( const key in attributes ) {
277+ // Hash all attributes in parallel
278+ const hashPromises = keys . map ( async ( key ) => {
273279 const attributeValue = attributes [ key ] ;
274-
275- hashedAttributes [ key ] = attributeValue ;
276-
277280 const hashedValue = await this . hashSha256 ( attributeValue ) ;
278-
281+ return { key, attributeValue, hashedValue } ;
282+ } ) ;
283+
284+ const results = await Promise . all ( hashPromises ) ;
285+
286+ // Build the result object
287+ const hashedAttributes : IRoktPartnerAttributes = { } ;
288+ for ( const { key, attributeValue, hashedValue } of results ) {
289+ hashedAttributes [ key ] = attributeValue ;
279290 if ( hashedValue ) {
280291 hashedAttributes [ `${ key } sha256` ] = hashedValue ;
281292 }
282293 }
283-
284294 return hashedAttributes ;
285295
286296 } catch ( error ) {
You can’t perform that action at this time.
0 commit comments