@bonniernews/b0rker
Advanced tools
Comparing version 3.0.2 to 3.1.0
@@ -15,4 +15,3 @@ import GoogleAuth from "google-auth-library"; | ||
const authHeaders = await gcpAuthHeaders(params.baseUrl); | ||
const authHeaders = await gcpAuthHeaders(params.audience || params.baseUrl); | ||
const opts = { | ||
@@ -111,3 +110,3 @@ method, | ||
async function gcpAuthHeaders(baseUrl) { | ||
async function gcpAuthHeaders(audience) { | ||
// this should ONLY be set to true if running locally | ||
@@ -117,3 +116,3 @@ if (config.unauthenticatedHttp) { | ||
} | ||
const client = await auth.getIdTokenClient(baseUrl); | ||
const client = await auth.getIdTokenClient(audience); | ||
return await client.getRequestHeaders(); | ||
@@ -120,0 +119,0 @@ } |
{ | ||
"name": "@bonniernews/b0rker", | ||
"version": "3.0.2", | ||
"version": "3.1.0", | ||
"engines": { | ||
@@ -5,0 +5,0 @@ "node": ">=16 <=18" |
@@ -23,2 +23,9 @@ import nock from "nock"; | ||
}); | ||
describe("google auth", () => { | ||
it("should append auth header", async () => { | ||
fakeApi.get("/some/path").matchHeader("Authorization", "Bearer some-gcp-token").reply(200, { ok: true }); | ||
const result = await http.asserted.get({ baseUrl, path: "/some/path", audience: "some-audience" }); | ||
result.should.eql({ ok: true }); | ||
}); | ||
}); | ||
describe("asserted", () => { | ||
@@ -25,0 +32,0 @@ const correlationId = "http-test-asserted"; |
94723
2495