UNPKG

@luxorai/sandbox

Version:

TypeScript SDK for Luxor Sandbox: cloud sandboxes (microVMs) for AI agents on Luxor Agent Cloud

41 lines • 2.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.githubInjectionCredentials = githubInjectionCredentials; exports.githubInjectionEnv = githubInjectionEnv; const injection_credentials_js_1 = require("./injection-credentials.js"); function githubInjectionCredentials(token) { token = token.trim(); if (!token) throw new Error("GitHub token injection requires a nonempty github token"); return [ new injection_credentials_js_1.InjectionCredentialInput("SDK_GITHUB_API", Buffer.from(token), [ { origin: "https://api.github.com", methods: ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"], pathPrefix: "/", header: "Authorization", }, ]), new injection_credentials_js_1.InjectionCredentialInput("SDK_GITHUB_GIT", Buffer.from(Buffer.from("x-access-token:" + token).toString("base64")), [{ origin: "https://github.com", methods: ["GET", "POST"], pathPrefix: "/", header: "Authorization" }]), ]; } function githubInjectionEnv(env) { if (env.GH_HOST && env.GH_HOST !== "github.com") throw new Error("GitHub token injection supports github.com only"); if (Object.keys(env).some((key) => key.startsWith("GIT_CONFIG"))) throw new Error("GitHub token injection reserves GIT_CONFIG environment variables"); env.GH_TOKEN = "secrets://SDK_GITHUB_API"; env.GIT_TOKEN = env.GH_TOKEN; const settings = [ ["http.https://github.com/.extraHeader", "Authorization: Basic secrets://SDK_GITHUB_GIT"], ["http.https://github.com/.version", "HTTP/1.1"], ["credential.https://github.com.helper", ""], ["http.https://github.com/.followRedirects", "false"], ]; env.GIT_CONFIG_COUNT = String(settings.length); settings.forEach(([key, value], i) => { env[`GIT_CONFIG_KEY_${i}`] = key; env[`GIT_CONFIG_VALUE_${i}`] = value; }); } //# sourceMappingURL=github-token.js.map