diff --git a/lerna.json b/lerna.json index fa0c8f20..32d67206 100644 --- a/lerna.json +++ b/lerna.json @@ -2,7 +2,7 @@ "packages": [ "packages/*" ], - "version": "0.11.2", + "version": "0.11.3", "npmClient": "yarn", "command": { "publish": { diff --git a/packages/atlas-theme/package.json b/packages/atlas-theme/package.json index fd042513..a4aaf8f1 100644 --- a/packages/atlas-theme/package.json +++ b/packages/atlas-theme/package.json @@ -1,6 +1,6 @@ { "name": "@iq-firebolt/atlas-theme", - "version": "0.11.2", + "version": "0.11.3", "description": "> ATLAS Theme", "author": "iq team", "homepage": "https://github.com/IQ-tech/firebolt#readme", diff --git a/packages/aurora-theme/package.json b/packages/aurora-theme/package.json index bb56b34c..5ab7c0d7 100644 --- a/packages/aurora-theme/package.json +++ b/packages/aurora-theme/package.json @@ -1,6 +1,6 @@ { "name": "@iq-firebolt/aurora-theme", - "version": "0.11.2", + "version": "0.11.3", "description": "> AURORA Theme", "author": "iq team", "homepage": "https://github.com/IQ-tech/firebolt#readme", diff --git a/packages/blueberry/package.json b/packages/blueberry/package.json index fbd0a412..da51582b 100644 --- a/packages/blueberry/package.json +++ b/packages/blueberry/package.json @@ -1,6 +1,6 @@ { "name": "@iq-firebolt/blueberry-theme", - "version": "0.11.2", + "version": "0.11.3", "description": "> TODO: description", "author": "iq team", "homepage": "https://github.com/IQ-tech/firebolt#readme", diff --git a/packages/br-addons/package.json b/packages/br-addons/package.json index 961c4c53..8a5ba11f 100644 --- a/packages/br-addons/package.json +++ b/packages/br-addons/package.json @@ -1,6 +1,6 @@ { "name": "@iq-firebolt/br-addons", - "version": "0.11.2", + "version": "0.11.3", "description": "> TODO: description", "author": "iq team", "homepage": "https://github.com/IQ-tech/firebolt#readme", diff --git a/packages/client-core/lib/services/API.test.ts b/packages/client-core/lib/services/API.test.ts index 53f5691e..7264af87 100644 --- a/packages/client-core/lib/services/API.test.ts +++ b/packages/client-core/lib/services/API.test.ts @@ -82,3 +82,28 @@ describe("API Error handling work correctly", () => { test.todo("throw correct errors on connection error") test.todo("throw correct errors on validation error") }) + +describe("Auth header", () => { + const withKey = new APIService({ + formAccess: { + root: "https://api.test", + formName: "form", + apiKey: "the-client-id", + }, + }) + + test("sends the client id as x-client-id, not x-api-key", async () => { + const getMock = axios.get as MockedFunction + getMock.mockClear() + getMock.mockResolvedValue({ data: startFormResponse }) + + await withKey.getStartForm() + + const [, config] = getMock.mock.calls[0] as [ + string, + { headers?: Record }, + ] + expect(config?.headers?.["x-client-id"]).toBe("the-client-id") + expect(config?.headers?.["x-api-key"]).toBeUndefined() + }) +}) diff --git a/packages/client-core/lib/services/API.ts b/packages/client-core/lib/services/API.ts index ec19c093..b161821b 100644 --- a/packages/client-core/lib/services/API.ts +++ b/packages/client-core/lib/services/API.ts @@ -2,7 +2,7 @@ import axios, { AxiosRequestConfig } from "axios" import { formatStepResponseData, formatReqPayload } from "../helpers/formatData" import { IApiService, IFormResponseData } from "../types" -const X_API_KEY = "x-api-key" +const CLIENT_ID_HEADER = "x-client-id" class APIService { debug?: boolean @@ -35,7 +35,7 @@ class APIService { } if (this.endpoints?.apiKey) { - headers[X_API_KEY] = this.endpoints.apiKey + headers[CLIENT_ID_HEADER] = this.endpoints.apiKey } return await axios @@ -53,7 +53,7 @@ class APIService { } if (this.endpoints?.apiKey) { - headers[X_API_KEY] = this.endpoints.apiKey + headers[CLIENT_ID_HEADER] = this.endpoints.apiKey } const endpoint = `${this.endpoints.base}/next` @@ -73,7 +73,7 @@ class APIService { authorization: `Bearer ${sessionKey}`, } if (this.endpoints?.apiKey) { - headers[X_API_KEY] = this.endpoints.apiKey + headers[CLIENT_ID_HEADER] = this.endpoints.apiKey } const endpoint = `${this.endpoints.base}/${currentStepSlug}/previous` @@ -86,7 +86,7 @@ class APIService { async getDebugStep(stepSlug) { const headers = {} if (this.endpoints?.apiKey) { - headers[X_API_KEY] = this.endpoints.apiKey + headers[CLIENT_ID_HEADER] = this.endpoints.apiKey } const endpoint = `${this.endpoints.root}/debug/${this.formName}/${stepSlug}` @@ -102,7 +102,7 @@ class APIService { "Content-Type": "multipart/form-data", } if (this.endpoints?.apiKey) { - headers[X_API_KEY] = this.endpoints.apiKey + headers[CLIENT_ID_HEADER] = this.endpoints.apiKey } const formData = new FormData() diff --git a/packages/client-core/package.json b/packages/client-core/package.json index dc88bc4d..eeff5bb2 100644 --- a/packages/client-core/package.json +++ b/packages/client-core/package.json @@ -1,6 +1,6 @@ { "name": "@iq-firebolt/client-core", - "version": "0.11.2", + "version": "0.11.3", "description": "> TODO: description", "author": "iq team", "homepage": "https://github.com/IQ-tech/firebolt#readme", diff --git a/packages/client/package.json b/packages/client/package.json index 5257898e..b092ffa5 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@iq-firebolt/client", - "version": "0.11.2", + "version": "0.11.3", "description": "> TODO: description", "author": "iq team", "homepage": "https://github.com/IQ-tech/firebolt#readme", @@ -36,8 +36,8 @@ }, "dependencies": { "@babel/runtime": "^7.16.3", - "@iq-firebolt/client-core": "0.11.2", - "@iq-firebolt/validators": "0.11.2", + "@iq-firebolt/client-core": "0.11.3", + "@iq-firebolt/validators": "0.11.3", "classnames": "^2.3.1", "fast-levenshtein": "^3.0.0", "regex-parser": "^2.2.11", diff --git a/packages/entities/package.json b/packages/entities/package.json index 69337ecb..f73a3b3d 100644 --- a/packages/entities/package.json +++ b/packages/entities/package.json @@ -1,6 +1,6 @@ { "name": "@iq-firebolt/entities", - "version": "0.11.2", + "version": "0.11.3", "description": "> TODO: description", "author": "iq team", "private": true, diff --git a/packages/json-schema/package.json b/packages/json-schema/package.json index 64393645..9a07311c 100644 --- a/packages/json-schema/package.json +++ b/packages/json-schema/package.json @@ -1,6 +1,6 @@ { "name": "@iq-firebolt/json-schema", - "version": "0.11.2", + "version": "0.11.3", "description": "json schema lib", "author": "iq team", "homepage": "https://github.com/IQ-tech/firebolt#readme", diff --git a/packages/lab/package.json b/packages/lab/package.json index 5da5f543..51e059cb 100644 --- a/packages/lab/package.json +++ b/packages/lab/package.json @@ -1,14 +1,14 @@ { "name": "@iq-firebolt/lab", - "version": "0.11.2", + "version": "0.11.3", "private": true, "license": "Apache-2.0", "dependencies": { - "@iq-firebolt/blueberry-theme": "0.11.2", - "@iq-firebolt/br-addons": "0.11.2", - "@iq-firebolt/client": "0.11.2", - "@iq-firebolt/client-core": "0.11.2", - "@iq-firebolt/material-theme": "0.11.2", + "@iq-firebolt/blueberry-theme": "0.11.3", + "@iq-firebolt/br-addons": "0.11.3", + "@iq-firebolt/client": "0.11.3", + "@iq-firebolt/client-core": "0.11.3", + "@iq-firebolt/material-theme": "0.11.3", "iq-blueberry": "^0.0.88", "react": "18.2.0", "react-dom": "18.2.0", diff --git a/packages/material-theme/package.json b/packages/material-theme/package.json index b158f34a..45d542b0 100644 --- a/packages/material-theme/package.json +++ b/packages/material-theme/package.json @@ -1,6 +1,6 @@ { "name": "@iq-firebolt/material-theme", - "version": "0.11.2", + "version": "0.11.3", "description": "> TODO: description", "author": "iq team", "homepage": "https://github.com/IQ-tech/firebolt#readme", diff --git a/packages/validators/package.json b/packages/validators/package.json index 64dacbeb..303bd531 100644 --- a/packages/validators/package.json +++ b/packages/validators/package.json @@ -1,6 +1,6 @@ { "name": "@iq-firebolt/validators", - "version": "0.11.2", + "version": "0.11.3", "description": "> TODO: description", "author": "iq team", "homepage": "https://github.com/IQ-tech/firebolt#readme",