From 6263fffe0edbb0548e5c296a6760d34d72711856 Mon Sep 17 00:00:00 2001 From: Devraj Mehta Date: Fri, 17 Jan 2025 12:55:22 -0500 Subject: [PATCH 1/2] Attempt to use Electron fetch for github-authentication Also changes fallback from node-fetch to the built-in Node fetch --- extensions/github-authentication/src/node/fetch.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/extensions/github-authentication/src/node/fetch.ts b/extensions/github-authentication/src/node/fetch.ts index 58718078e6995..ca344d436b111 100644 --- a/extensions/github-authentication/src/node/fetch.ts +++ b/extensions/github-authentication/src/node/fetch.ts @@ -2,6 +2,11 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import fetch from 'node-fetch'; -export const fetching = fetch; +let _fetch: typeof fetch; +try { + _fetch = require('electron').net.fetch; +} catch { + _fetch = fetch; +} +export const fetching = _fetch; From 419205a8ff1252fc6a3a8e085b8645f2ab51a0ec Mon Sep 17 00:00:00 2001 From: Devraj Mehta Date: Fri, 17 Jan 2025 13:05:41 -0500 Subject: [PATCH 2/2] Remove Content-Length header Electron compatibility It looks like it was set incorrectly to the body contents anyways. --- extensions/github-authentication/src/flows.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/extensions/github-authentication/src/flows.ts b/extensions/github-authentication/src/flows.ts index a2497b2b0b2e7..8920ea5d3578b 100644 --- a/extensions/github-authentication/src/flows.ts +++ b/extensions/github-authentication/src/flows.ts @@ -105,8 +105,6 @@ async function exchangeCodeForToken( headers: { Accept: 'application/json', 'Content-Type': 'application/x-www-form-urlencoded', - 'Content-Length': body.toString() - }, body: body.toString() });