From 2cb13327ffe669000e8152b509d14e060b3ea73b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petar=20Penovi=C4=87?= Date: Tue, 7 Jan 2025 15:15:20 +0100 Subject: [PATCH] fix: repair fetch utility for browser environments (#1293) * fix: limit fetch dependencies to patch versions * fix: bind window in fetch utility for browser environments --- package.json | 4 ++-- src/utils/fetchPonyfill.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index b8360221e..05d72fbb8 100644 --- a/package.json +++ b/package.json @@ -101,8 +101,8 @@ "@scure/base": "1.2.1", "@scure/starknet": "1.1.0", "abi-wan-kanabi": "^2.2.3", - "fetch-cookie": "^3.0.0", - "isomorphic-fetch": "^3.0.0", + "fetch-cookie": "~3.0.0", + "isomorphic-fetch": "~3.0.0", "lossless-json": "^4.0.1", "pako": "^2.0.4", "starknet-types-07": "npm:@starknet-io/types-js@^0.7.10", diff --git a/src/utils/fetchPonyfill.ts b/src/utils/fetchPonyfill.ts index 02888b3a6..0bf2bfae6 100644 --- a/src/utils/fetchPonyfill.ts +++ b/src/utils/fetchPonyfill.ts @@ -5,6 +5,6 @@ import isomorphicFetch from 'isomorphic-fetch'; import { IS_BROWSER } from './encode'; import { isUndefined } from './typed'; -export default (IS_BROWSER && window.fetch) || // use built-in fetch in browser if available +export default (IS_BROWSER && window.fetch.bind(window)) || // use built-in fetch in browser if available (!isUndefined(global) && makeFetchCookie(global.fetch)) || // use built-in fetch in node, react-native and service worker if available isomorphicFetch; // ponyfill fetch in node and browsers that don't have it