@@ -23,6 +23,7 @@ import { CancellationToken } from '../internal/utils.js';
23
23
import { sdToJson } from '../serialization/json.js' ;
24
24
import { SerializedData } from '../serialization/json.js' ;
25
25
import { computeWebhookSignature } from '../internal/utils.js' ;
26
+ import { compareSignatures } from '../internal/utils.js' ;
26
27
import { dateTimeFromString } from '../internal/utils.js' ;
27
28
import { getEpochTimeInSeconds } from '../internal/utils.js' ;
28
29
import { dateTimeToEpochSeconds } from '../internal/utils.js' ;
@@ -680,29 +681,37 @@ export class WebhooksManager {
680
681
}
681
682
if (
682
683
primaryKey &&
683
- ( await computeWebhookSignature ( body , headers , primaryKey , false ) ) ==
684
- headers [ 'box-signature-primary' ]
684
+ ( await compareSignatures (
685
+ await computeWebhookSignature ( body , headers , primaryKey , false ) ,
686
+ headers [ 'box-signature-primary' ] ,
687
+ ) )
685
688
) {
686
689
return true ;
687
690
}
688
691
if (
689
692
primaryKey &&
690
- ( await computeWebhookSignature ( body , headers , primaryKey , true ) ) ==
691
- headers [ 'box-signature-primary' ]
693
+ ( await compareSignatures (
694
+ await computeWebhookSignature ( body , headers , primaryKey , true ) ,
695
+ headers [ 'box-signature-primary' ] ,
696
+ ) )
692
697
) {
693
698
return true ;
694
699
}
695
700
if (
696
701
secondaryKey &&
697
- ( await computeWebhookSignature ( body , headers , secondaryKey , false ) ) ==
698
- headers [ 'box-signature-secondary' ]
702
+ ( await compareSignatures (
703
+ await computeWebhookSignature ( body , headers , secondaryKey , false ) ,
704
+ headers [ 'box-signature-secondary' ] ,
705
+ ) )
699
706
) {
700
707
return true ;
701
708
}
702
709
if (
703
710
secondaryKey &&
704
- ( await computeWebhookSignature ( body , headers , secondaryKey , true ) ) ==
705
- headers [ 'box-signature-secondary' ]
711
+ ( await compareSignatures (
712
+ await computeWebhookSignature ( body , headers , secondaryKey , true ) ,
713
+ headers [ 'box-signature-secondary' ] ,
714
+ ) )
706
715
) {
707
716
return true ;
708
717
}
0 commit comments