btrz-api-client 5.224.1 → 5.225.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -16,6 +16,10 @@ function authorizationHeaders(_ref) {
|
|
|
16
16
|
_headers["x-api-key"] = "" + token;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
if (headers && headers.cookie && headers.cookie.includes("btrz-trusted")) {
|
|
20
|
+
_headers.cookie = headers.cookie;
|
|
21
|
+
}
|
|
22
|
+
|
|
19
23
|
if (jwtToken && jwtToken === constants.INTERNAL_AUTH_TOKEN_SYMBOL) {
|
|
20
24
|
if (!internalAuthTokenProvider || typeof internalAuthTokenProvider.getToken !== "function") {
|
|
21
25
|
throw new Error("Tried to make an internal API request, but no 'internalAuthTokenProvider' with a 'getToken' function " + "was supplied to the API client");
|
package/package.json
CHANGED
|
@@ -9,6 +9,10 @@ function authorizationHeaders({
|
|
|
9
9
|
_headers["x-api-key"] = `${token}`;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
if (headers && headers.cookie && headers.cookie.includes("btrz-trusted")) {
|
|
13
|
+
_headers.cookie = headers.cookie;
|
|
14
|
+
}
|
|
15
|
+
|
|
12
16
|
if (jwtToken && jwtToken === constants.INTERNAL_AUTH_TOKEN_SYMBOL) {
|
|
13
17
|
if (!internalAuthTokenProvider || typeof internalAuthTokenProvider.getToken !== "function") {
|
|
14
18
|
throw new Error("Tried to make an internal API request, but no 'internalAuthTokenProvider' with a 'getToken' function " +
|
|
@@ -16,6 +16,16 @@ describe("endpoints helpers", () => {
|
|
|
16
16
|
});
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
+
it("should return a headers object which includes the btrz-trusted cookie", () => {
|
|
20
|
+
const jwtToken = "7A0mvzROJIucrSPYHlgd";
|
|
21
|
+
const headers = authorizationHeaders({jwtToken, headers: {cookie: "btrz-trusted=teststuff"}});
|
|
22
|
+
|
|
23
|
+
expect(headers).to.deep.equal({
|
|
24
|
+
authorization: `Bearer ${jwtToken}`,
|
|
25
|
+
cookie: "btrz-trusted=teststuff"
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
19
29
|
it("should return a headers object which includes an auth token created using the 'internalAuthTokenProvider', when the caller " +
|
|
20
30
|
"is trying to make an internal service-to-service API request", () => {
|
|
21
31
|
const jwtToken = constants.INTERNAL_AUTH_TOKEN_SYMBOL,
|