Implement callback endpoints

VS Code uses these during the authentication flow.
This commit is contained in:
Asher
2020-12-10 15:59:24 -06:00
parent 98338e9a44
commit 58c1be57fa
3 changed files with 120 additions and 3 deletions

View File

@ -6,6 +6,7 @@ import { Readable } from "stream"
import * as tarFs from "tar-fs"
import * as zlib from "zlib"
import { HttpCode, HttpError } from "../../common/http"
import { getFirstString } from "../../common/util"
import { rootPath } from "../constants"
import { authenticated, ensureAuthenticated, replaceTemplates } from "../http"
import { getMediaMime, pathToFsPath } from "../util"
@ -15,8 +16,8 @@ export const router = Router()
// The commit is for caching.
router.get("/(:commit)(/*)?", async (req, res) => {
// Used by VS Code to load extensions into the web worker.
const tar = Array.isArray(req.query.tar) ? req.query.tar[0] : req.query.tar
if (typeof tar === "string") {
const tar = getFirstString(req.query.tar)
if (tar) {
ensureAuthenticated(req)
let stream: Readable = tarFs.pack(pathToFsPath(tar))
if (req.headers["accept-encoding"] && req.headers["accept-encoding"].includes("gzip")) {