@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.
- package/lib/AuthorizedApiBase.d.ts +8 -1
- package/lib/AuthorizedApiBase.js +4 -1
- package/lib/ignosportal-api.d.ts +101 -91
- package/lib/ignosportal-api.js +4 -1
- package/package.json +1 -1
- package/src/AuthorizedApiBase.ts +16 -3
- package/src/ignosportal-api.ts +110 -93
package/lib/ignosportal-api.js
CHANGED
|
@@ -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
package/src/AuthorizedApiBase.ts
CHANGED
|
@@ -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:
|
|
15
|
+
private readonly config: IApiClientConfig;
|
|
7
16
|
|
|
8
|
-
protected constructor(config:
|
|
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
|
|