From 914edfe8d477978a762486ca6c414688328748b6 Mon Sep 17 00:00:00 2001 From: Yash Khare Date: Mon, 28 Oct 2024 15:06:58 +0530 Subject: [PATCH 1/4] feat: Platform VSCODE flag Signed-off-by: Yash Khare --- src/SignIn.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/SignIn.ts b/src/SignIn.ts index bd301b1..4dde437 100644 --- a/src/SignIn.ts +++ b/src/SignIn.ts @@ -5,6 +5,7 @@ import { v4 as uuidv4 } from 'uuid'; const os = require('os'); const { execSync } = require('child_process'); import axios, { AxiosResponse } from 'axios'; +import { platform } from 'os'; async function fetchGitHubEmail(accessToken: string): Promise { @@ -118,7 +119,7 @@ export default async function SignInWithGitHub() { // vscode.env.openExternal(vscode.Uri.parse(backendUrl)); try { // Await the response from the backend - const response = await loginAPI(backendUrl, 'github', code?.toString()); + const response = await loginAPI(backendUrl, 'github', code?.toString(),"vscode"); if (response.error) { res.writeHead(400, { 'Content-Type': 'application/json' }); @@ -167,7 +168,7 @@ export async function SignInWithOthers() { // return data; // } -export async function loginAPI(url = "", provider = "", code = "") { +export async function loginAPI(url = "", provider = "", code = "",platform = "") { // Default options are marked with * // var response : Response try { @@ -182,7 +183,7 @@ export async function loginAPI(url = "", provider = "", code = "") { }, redirect: "follow", // manual, *follow, error referrerPolicy: "no-referrer", // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url - body: JSON.stringify({ provider: provider, code: code }) // body data type must match "Content-Type" header + body: JSON.stringify({ provider: provider, code: code,platform:platform }) // body data type must match "Content-Type" header }); if (response.status === 200) { From 28fd7a324d4360f95e5ed17dcb3f0efb6d3dc271 Mon Sep 17 00:00:00 2001 From: Yash Khare Date: Mon, 28 Oct 2024 15:07:36 +0530 Subject: [PATCH 2/4] remove extra imports Signed-off-by: Yash Khare --- src/SignIn.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/SignIn.ts b/src/SignIn.ts index 4dde437..1bf4b34 100644 --- a/src/SignIn.ts +++ b/src/SignIn.ts @@ -5,7 +5,6 @@ import { v4 as uuidv4 } from 'uuid'; const os = require('os'); const { execSync } = require('child_process'); import axios, { AxiosResponse } from 'axios'; -import { platform } from 'os'; async function fetchGitHubEmail(accessToken: string): Promise { From 0911ce6c89352e6f235d300c5f84bd1c6637bf97 Mon Sep 17 00:00:00 2001 From: shivamsouravjha <2019145@iiitdmj.ac.in> Date: Tue, 29 Oct 2024 20:22:59 +0530 Subject: [PATCH 3/4] chore: update body for github login Signed-off-by: shivamsouravjha <2019145@iiitdmj.ac.in> --- src/SignIn.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/SignIn.ts b/src/SignIn.ts index 1bf4b34..f0235ea 100644 --- a/src/SignIn.ts +++ b/src/SignIn.ts @@ -118,7 +118,7 @@ export default async function SignInWithGitHub() { // vscode.env.openExternal(vscode.Uri.parse(backendUrl)); try { // Await the response from the backend - const response = await loginAPI(backendUrl, 'github', code?.toString(),"vscode"); + const response = await loginAPI(backendUrl, 'github', code?.toString()); if (response.error) { res.writeHead(400, { 'Content-Type': 'application/json' }); @@ -167,7 +167,7 @@ export async function SignInWithOthers() { // return data; // } -export async function loginAPI(url = "", provider = "", code = "",platform = "") { +export async function loginAPI(url = "", provider = "", code = "") { // Default options are marked with * // var response : Response try { @@ -182,7 +182,7 @@ export async function loginAPI(url = "", provider = "", code = "",platform = "") }, redirect: "follow", // manual, *follow, error referrerPolicy: "no-referrer", // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url - body: JSON.stringify({ provider: provider, code: code,platform:platform }) // body data type must match "Content-Type" header + body: JSON.stringify({ provider: provider, code: code }) // body data type must match "Content-Type" header }); if (response.status === 200) { @@ -311,6 +311,7 @@ function extractID(output: any) { interface AuthReq { GitHubToken: string; InstallationID: string; + platform: string; } interface AuthResp { @@ -328,6 +329,7 @@ export async function validateFirst(token: string, serverURL: string): Promise<{ // extract string from promise const requestBody: AuthReq = { GitHubToken: token, + platform: "vscode", InstallationID: installationID, }; console.log("Request Body:", requestBody); From 6143ba219224806f05e9fe88b090fb3d66cfbc02 Mon Sep 17 00:00:00 2001 From: shivamsouravjha <2019145@iiitdmj.ac.in> Date: Tue, 29 Oct 2024 20:32:11 +0530 Subject: [PATCH 4/4] chore: update body for github login Signed-off-by: shivamsouravjha <2019145@iiitdmj.ac.in> --- src/SignIn.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SignIn.ts b/src/SignIn.ts index f0235ea..37a6aaf 100644 --- a/src/SignIn.ts +++ b/src/SignIn.ts @@ -311,7 +311,7 @@ function extractID(output: any) { interface AuthReq { GitHubToken: string; InstallationID: string; - platform: string; + Platform: string; } interface AuthResp { @@ -329,7 +329,7 @@ export async function validateFirst(token: string, serverURL: string): Promise<{ // extract string from promise const requestBody: AuthReq = { GitHubToken: token, - platform: "vscode", + Platform: "vscode", InstallationID: installationID, }; console.log("Request Body:", requestBody);