@io-orkes/conductor-javascript 1.2.0-rc.1 → 1.2.0-rc.2
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/dist/browser.d.mts +2 -2
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +53 -11
- package/dist/browser.js.map +1 -1
- package/dist/browser.mjs +53 -11
- package/dist/browser.mjs.map +1 -1
- package/dist/index.d.mts +11 -3
- package/dist/index.d.ts +11 -3
- package/dist/index.js +55 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +54 -11
- package/dist/index.mjs.map +1 -1
- package/dist/{types-e3d6bb0f.d.ts → types-7f82aacc.d.ts} +4 -2
- package/package.json +1 -1
package/dist/browser.mjs
CHANGED
|
@@ -2156,7 +2156,11 @@ var ConductorClient = class {
|
|
|
2156
2156
|
this.request = {
|
|
2157
2157
|
config: resolvedConfig,
|
|
2158
2158
|
request: (apiConfig) => {
|
|
2159
|
-
return requestHandler(
|
|
2159
|
+
return requestHandler(
|
|
2160
|
+
request,
|
|
2161
|
+
{ ...resolvedConfig, TOKEN: this.token },
|
|
2162
|
+
apiConfig
|
|
2163
|
+
);
|
|
2160
2164
|
}
|
|
2161
2165
|
};
|
|
2162
2166
|
this.token = config?.TOKEN;
|
|
@@ -2171,6 +2175,8 @@ var ConductorClient = class {
|
|
|
2171
2175
|
this.humanTask = new HumanTaskService(this.request);
|
|
2172
2176
|
this.humanTaskResource = new HumanTaskResourceService(this.request);
|
|
2173
2177
|
}
|
|
2178
|
+
stop() {
|
|
2179
|
+
}
|
|
2174
2180
|
};
|
|
2175
2181
|
|
|
2176
2182
|
// src/common/open-api/core/BaseHttpRequest.ts
|
|
@@ -3364,21 +3370,57 @@ var workflow = (name, tasks) => ({
|
|
|
3364
3370
|
|
|
3365
3371
|
// src/orkes/BaseOrkesConductorClient.ts
|
|
3366
3372
|
var defaultRequestHandler2 = (request2, config, options) => request2(config, options);
|
|
3373
|
+
var REFRESH_TOKEN_IN_MILLISECONDS = 30 * 60 * 1e3;
|
|
3374
|
+
var AuthConductorClient = class extends ConductorClient {
|
|
3375
|
+
constructor(config, requestHandler = defaultRequestHandler2) {
|
|
3376
|
+
super(config, requestHandler);
|
|
3377
|
+
}
|
|
3378
|
+
/**
|
|
3379
|
+
* Stops the interval that refreshes the token
|
|
3380
|
+
*/
|
|
3381
|
+
stop() {
|
|
3382
|
+
if (this.intervalId != null) {
|
|
3383
|
+
clearInterval(this.intervalId);
|
|
3384
|
+
}
|
|
3385
|
+
}
|
|
3386
|
+
};
|
|
3367
3387
|
var baseOrkesConductorClient = (fetchFn, baseRequestHandler = defaultRequestHandler2) => {
|
|
3388
|
+
const requestTokenForKeySecret = (keyId, keySecret, tokenUrl) => fetchFn(tokenUrl, {
|
|
3389
|
+
headers: {
|
|
3390
|
+
"Content-Type": "application/json",
|
|
3391
|
+
Accept: "application/json"
|
|
3392
|
+
},
|
|
3393
|
+
body: JSON.stringify({ keyId, keySecret }),
|
|
3394
|
+
method: "POST"
|
|
3395
|
+
});
|
|
3368
3396
|
return async (config, requestHandler = baseRequestHandler) => {
|
|
3369
3397
|
if (config?.keySecret != null && config?.keyId != null) {
|
|
3370
|
-
const {
|
|
3398
|
+
const {
|
|
3399
|
+
serverUrl,
|
|
3400
|
+
keyId,
|
|
3401
|
+
keySecret,
|
|
3402
|
+
refreshTokenInterval = REFRESH_TOKEN_IN_MILLISECONDS
|
|
3403
|
+
} = config;
|
|
3371
3404
|
const tokenUrl = `${serverUrl}/token`;
|
|
3372
|
-
const res = await
|
|
3373
|
-
headers: {
|
|
3374
|
-
"Content-Type": "application/json",
|
|
3375
|
-
Accept: "application/json"
|
|
3376
|
-
},
|
|
3377
|
-
body: JSON.stringify({ keyId, keySecret }),
|
|
3378
|
-
method: "POST"
|
|
3379
|
-
});
|
|
3405
|
+
const res = await requestTokenForKeySecret(keyId, keySecret, tokenUrl);
|
|
3380
3406
|
const { token } = await res.json();
|
|
3381
|
-
|
|
3407
|
+
const conductorClientInstance = new AuthConductorClient(
|
|
3408
|
+
{ ...config, TOKEN: token },
|
|
3409
|
+
requestHandler
|
|
3410
|
+
);
|
|
3411
|
+
if (token != null && refreshTokenInterval > 0) {
|
|
3412
|
+
const intervalId = setInterval(async () => {
|
|
3413
|
+
const res2 = await requestTokenForKeySecret(
|
|
3414
|
+
keyId,
|
|
3415
|
+
keySecret,
|
|
3416
|
+
tokenUrl
|
|
3417
|
+
);
|
|
3418
|
+
const { token: token2 } = await res2.json();
|
|
3419
|
+
conductorClientInstance.token = token2;
|
|
3420
|
+
}, refreshTokenInterval);
|
|
3421
|
+
conductorClientInstance.intervalId = intervalId;
|
|
3422
|
+
}
|
|
3423
|
+
return conductorClientInstance;
|
|
3382
3424
|
} else {
|
|
3383
3425
|
return new ConductorClient(config, requestHandler);
|
|
3384
3426
|
}
|