From 7177ddfb3698512cd9cb2ba0a567a528d3ba02f2 Mon Sep 17 00:00:00 2001 From: Dan Skinner Date: Wed, 16 Oct 2024 16:37:23 +0100 Subject: [PATCH] do not use async syntax --- packages/delivery-xml-http-request/delivery.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/delivery-xml-http-request/delivery.js b/packages/delivery-xml-http-request/delivery.js index d9225f578..c15a2bfdf 100644 --- a/packages/delivery-xml-http-request/delivery.js +++ b/packages/delivery-xml-http-request/delivery.js @@ -1,16 +1,19 @@ const payload = require('@bugsnag/core/lib/json-payload') -async function getIntegrity (windowOrWorkerGlobalScope, requestBody) { +function getIntegrity (windowOrWorkerGlobalScope, requestBody) { if (windowOrWorkerGlobalScope.isSecureContext && windowOrWorkerGlobalScope.crypto && windowOrWorkerGlobalScope.crypto.subtle && windowOrWorkerGlobalScope.crypto.subtle.digest && typeof TextEncoder === 'function') { const msgUint8 = new TextEncoder().encode(requestBody) - const hashBuffer = await windowOrWorkerGlobalScope.crypto.subtle.digest('SHA-1', msgUint8) - const hashArray = Array.from(new Uint8Array(hashBuffer)) - const hashHex = hashArray - .map((b) => b.toString(16).padStart(2, '0')) - .join('') - return 'sha1 ' + hashHex + return windowOrWorkerGlobalScope.crypto.subtle.digest('SHA-1', msgUint8).then((hashBuffer) => { + const hashArray = Array.from(new Uint8Array(hashBuffer)) + const hashHex = hashArray + .map((b) => b.toString(16).padStart(2, '0')) + .join('') + + return 'sha1 ' + hashHex + }) } + return Promise.resolve() } module.exports = (client, win = window) => ({