@ignos/api-client 20260529.143.1 → 20260604.145.1-alpha

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.
@@ -10,8 +10,11 @@ export class AuthorizedApiBase {
10
10
  this.transformOptions = async (options) => {
11
11
  options.headers = {
12
12
  ...options.headers,
13
- Authorization: "Bearer " + (await this.config.getAccessToken()),
13
+ Authorization: "Bearer " + (await this.config.accessTokenProvider.getAccessToken()),
14
14
  };
15
+ const tenantId = this.config.tenantIdProvider.getTenantId();
16
+ if (tenantId)
17
+ options.headers["x-tenantid"] = tenantId;
15
18
  return options;
16
19
  };
17
20
  this.jsonParseReviver = (_, value) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ignos/api-client",
3
- "version": "20260529.143.1",
3
+ "version": "20260604.145.1-alpha",
4
4
  "description": "IGNOS API Client",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -2,18 +2,31 @@ export interface IAccessTokenProvider {
2
2
  getAccessToken: () => Promise<string>;
3
3
  }
4
4
 
5
+ export interface ITenantIdProvider {
6
+ getTenantId: () => string | null;
7
+ }
8
+
9
+ export interface IApiClientConfig {
10
+ accessTokenProvider: IAccessTokenProvider;
11
+ tenantIdProvider: ITenantIdProvider;
12
+ }
13
+
5
14
  export class AuthorizedApiBase {
6
- private readonly config: IAccessTokenProvider;
15
+ private readonly config: IApiClientConfig;
7
16
 
8
- protected constructor(config: IAccessTokenProvider) {
17
+ protected constructor(config: IApiClientConfig) {
9
18
  this.config = config;
10
19
  }
11
20
 
12
21
  protected transformOptions = async (options: any): Promise<any> => {
13
22
  options.headers = {
14
23
  ...options.headers,
15
- Authorization: "Bearer " + (await this.config.getAccessToken()),
24
+ Authorization: "Bearer " + (await this.config.accessTokenProvider.getAccessToken()),
16
25
  };
26
+
27
+ const tenantId = this.config.tenantIdProvider.getTenantId();
28
+ if (tenantId) options.headers["x-tenantid"] = tenantId;
29
+
17
30
  return options;
18
31
  };
19
32