add the ability to read in cert
This commit is contained in:
@@ -1,8 +1,28 @@
|
|||||||
import {Octokit} from "@octokit/rest";
|
import {Octokit} from "@octokit/rest";
|
||||||
|
import { Agent } from "node:https";
|
||||||
|
import { readFileSync } from "fs";
|
||||||
|
|
||||||
export function getClient(token: string, userAgent?: string): Octokit {
|
export function getClient(token: string, userAgent?: string): Octokit {
|
||||||
|
const selfSignedCertPath = process.env.NODE_EXTRA_CA_CERTS;
|
||||||
|
|
||||||
|
// if NODE_EXTRA_CA_CERTS is set then use the self-signed cert to make the request
|
||||||
|
if (selfSignedCertPath) {
|
||||||
|
const httpsAgent = new Agent({
|
||||||
|
ca: readFileSync(selfSignedCertPath)
|
||||||
|
});
|
||||||
|
|
||||||
|
return new Octokit({
|
||||||
|
auth: token,
|
||||||
|
userAgent: userAgent || `GitHub Actions Language Server`,
|
||||||
|
request: {
|
||||||
|
agent: httpsAgent
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
return new Octokit({
|
return new Octokit({
|
||||||
auth: token,
|
auth: token,
|
||||||
userAgent: userAgent || `GitHub Actions Language Server`
|
userAgent: userAgent || `GitHub Actions Language Server`
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user