bugsnag / bugsnag-js

JavaScript error handling tool for BugSnag. Monitor and report JavaScript bugs & errors.
https://docs.bugsnag.com/platforms/javascript
MIT License
858 stars 252 forks source link

add sendPayloadChecksums config option and implement Bugsnag-Integrity header #2221

Open djskinner opened 1 month ago

djskinner commented 1 month ago

Goal

Add Bugsnag-Integrity request header (where required APIs are available) and implement the sendPayloadChecksums core config option to allow opting out of this behavior.

Bugsnag-Integrity headers are set by default unless the endpoints configuration option is set, in which case they are disabled. This behavior can be overriden with the new sendPayloadChecksums config option.

Design

Changeset

Testing

github-actions[bot] commented 1 month ago

@bugsnag/browser bundle size diff

Minified Minfied + Gzipped
Before 45.89 kB 13.78 kB
After 46.96 kB 14.02 kB
± ⚠️ +1,073 bytes ⚠️ +242 bytes

code coverage diff

<_temporarily disabled_>

Generated by :no_entry_sign: dangerJS against d38cc52145d67ff10541d95f828018b36bc5e6cf

djskinner commented 1 week ago

Do we also need to set this in the delivery-x-domain-request package? I suppose IE8 and 9 won't support an integrity header?

No, XDomainRequest is only available on ie8 and ie9 neither which support the necessary APIs for calculating and setting the integrity header. even ie11 is excluded because it doesn't have full native promise support, hence the typeof Promise !== 'undefined' && Promise.toString().indexOf('[native code]') !== -1 check.