@hahnpro/hpc-api 2025.4.1-beta.2 → 2025.5.1
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/CHANGELOG.md +11 -0
- package/package.json +1 -1
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/lib/constants.d.ts +1 -0
- package/src/lib/constants.js +4 -0
- package/src/lib/interfaces/content.interface.d.ts +1 -0
- package/src/lib/mock/http-client.mock.service.js +1 -1
- package/src/lib/services/http-client.service.d.ts +2 -3
- package/src/lib/services/http-client.service.js +12 -27
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @hahnpro/hpc-api
|
|
2
2
|
|
|
3
|
+
## 2025.5.1
|
|
4
|
+
|
|
5
|
+
- Added Description to Content Interface
|
|
6
|
+
|
|
7
|
+
## 2025.5.0
|
|
8
|
+
|
|
9
|
+
### Major Changes
|
|
10
|
+
|
|
11
|
+
- Added activeOrg config parameter to HttpClientService to set the active organization for a request
|
|
12
|
+
- Converted HttpClientService constructor to config object to improve flexibility and readability
|
|
13
|
+
|
|
3
14
|
## 2025.4.0
|
|
4
15
|
|
|
5
16
|
### Major Changes
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
|
@@ -4,5 +4,6 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
tslib_1.__exportStar(require("./lib/interfaces"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./lib/services"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./lib/api"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./lib/constants"), exports);
|
|
7
8
|
tslib_1.__exportStar(require("./lib/mock"), exports);
|
|
8
9
|
tslib_1.__exportStar(require("./lib/utils"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ACTIVE_ORG_ID_HEADER = "active-org-id";
|
|
@@ -4,7 +4,7 @@ exports.HttpClientMockService = void 0;
|
|
|
4
4
|
const services_1 = require("../services");
|
|
5
5
|
class HttpClientMockService extends services_1.HttpClientService {
|
|
6
6
|
constructor() {
|
|
7
|
-
super(
|
|
7
|
+
super({ baseURL: '', realm: '' });
|
|
8
8
|
this.authAxiosInstance = null;
|
|
9
9
|
this.axiosInstance = null;
|
|
10
10
|
this.delete = (_url, _config) => Promise.resolve(undefined);
|
|
@@ -9,8 +9,8 @@ export interface HttpClientConfig {
|
|
|
9
9
|
baseURL: string;
|
|
10
10
|
authBaseURL?: string;
|
|
11
11
|
realm: string;
|
|
12
|
-
clientId
|
|
13
|
-
clientSecret
|
|
12
|
+
clientId?: string;
|
|
13
|
+
clientSecret?: string;
|
|
14
14
|
tokenSubject?: string;
|
|
15
15
|
activeOrg?: string;
|
|
16
16
|
}
|
|
@@ -34,7 +34,6 @@ export declare class HttpClientService {
|
|
|
34
34
|
errListener: (event: MessageEvent) => void;
|
|
35
35
|
}>;
|
|
36
36
|
constructor(config: HttpClientConfig);
|
|
37
|
-
constructor(baseURL: string, authBaseURL: string, realm: string, clientId: string, clientSecret: string, tokenSubject?: string, activeOrg?: string);
|
|
38
37
|
getQueueStats: () => {
|
|
39
38
|
peak: number;
|
|
40
39
|
pending: number;
|
|
@@ -7,10 +7,11 @@ const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
|
7
7
|
const eventsource_1 = require("eventsource");
|
|
8
8
|
const jose_1 = require("jose");
|
|
9
9
|
const rxjs_1 = require("rxjs");
|
|
10
|
+
const constants_1 = require("../constants");
|
|
10
11
|
const queue_1 = require("../queue");
|
|
11
12
|
const token_set_1 = require("../token-set");
|
|
12
13
|
class HttpClientService {
|
|
13
|
-
constructor(
|
|
14
|
+
constructor(config) {
|
|
14
15
|
this.discoveredIssuers = new Map();
|
|
15
16
|
this.eventSourcesMap = new Map();
|
|
16
17
|
this.getQueueStats = () => this.requestQueue?.getStats();
|
|
@@ -26,7 +27,7 @@ class HttpClientService {
|
|
|
26
27
|
.then((token) => {
|
|
27
28
|
const headers = { Authorization: `Bearer ${token}`, ...config.headers };
|
|
28
29
|
if (this.activeOrg) {
|
|
29
|
-
headers[
|
|
30
|
+
headers[constants_1.ACTIVE_ORG_ID_HEADER] = this.activeOrg;
|
|
30
31
|
}
|
|
31
32
|
return this.axiosInstance.request({ ...config, headers, method, url, data });
|
|
32
33
|
})
|
|
@@ -56,30 +57,13 @@ class HttpClientService {
|
|
|
56
57
|
return accessToken;
|
|
57
58
|
}
|
|
58
59
|
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
this.clientSecret = config.clientSecret;
|
|
67
|
-
this.tokenSubject = config.tokenSubject;
|
|
68
|
-
this.activeOrg = config.activeOrg;
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
// Handle individual parameters overload
|
|
72
|
-
if (!authBaseURL || !realm || !clientId || !clientSecret) {
|
|
73
|
-
throw new Error('Missing required parameters for HttpClientService constructor');
|
|
74
|
-
}
|
|
75
|
-
this.baseURL = configOrBaseURL;
|
|
76
|
-
this.authBaseURL = authBaseURL;
|
|
77
|
-
this.realm = realm;
|
|
78
|
-
this.clientId = clientId;
|
|
79
|
-
this.clientSecret = clientSecret;
|
|
80
|
-
this.tokenSubject = tokenSubject;
|
|
81
|
-
this.activeOrg = activeOrg;
|
|
82
|
-
}
|
|
60
|
+
this.baseURL = config.baseURL;
|
|
61
|
+
this.authBaseURL = config.authBaseURL || config.baseURL;
|
|
62
|
+
this.realm = config.realm;
|
|
63
|
+
this.clientId = config.clientId;
|
|
64
|
+
this.clientSecret = config.clientSecret;
|
|
65
|
+
this.tokenSubject = config.tokenSubject;
|
|
66
|
+
this.activeOrg = config.activeOrg;
|
|
83
67
|
this.axiosInstance = axios_1.default.create({ baseURL: this.baseURL, timeout: 60000 });
|
|
84
68
|
this.authAxiosInstance = axios_1.default.create({ baseURL: this.authBaseURL, timeout: 10000 });
|
|
85
69
|
this.requestQueue = new queue_1.Queue({ concurrency: 1, timeout: 70000, throwOnTimeout: true });
|
|
@@ -133,7 +117,7 @@ class HttpClientService {
|
|
|
133
117
|
Authorization: 'Bearer ' + token,
|
|
134
118
|
};
|
|
135
119
|
if (this.activeOrg) {
|
|
136
|
-
headers[
|
|
120
|
+
headers[constants_1.ACTIVE_ORG_ID_HEADER] = this.activeOrg;
|
|
137
121
|
}
|
|
138
122
|
return fetch(input, {
|
|
139
123
|
...init,
|
|
@@ -210,6 +194,7 @@ class HttpClientService {
|
|
|
210
194
|
client_assertion: assertion,
|
|
211
195
|
client_assertion_type: 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',
|
|
212
196
|
grant_type: 'client_credentials',
|
|
197
|
+
scope: 'openid profile email',
|
|
213
198
|
...additionalOpts,
|
|
214
199
|
};
|
|
215
200
|
const authResponse = await this.authAxiosInstance.post(issuer.token_endpoint, new URLSearchParams(opts).toString(), {
|