New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@5minds/processcube_engine_client

Package Overview
Dependencies
Maintainers
29
Versions
662
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@5minds/processcube_engine_client - npm Package Compare versions

Comparing version 6.0.0-renovate-5c6028-m5umu879 to 6.0.0-renovate-5d9909-m6i56utq

dist/commonjs/IdentityAccessorClientCredentials.js

7

dist/commonjs/ExternalTaskExecution.js

@@ -122,2 +122,9 @@ "use strict";

}
if (error.message?.match(/expired/i) && this.identityAccessor.canIdentityBeRefreshed()) {
this.logger.info('Identity has expired. Refreshing identity to get a new auth token...');
this.identityAccessor
.forceImmediateIdentityRefresh()
.then(() => this.logger.info('Identity refresh completed. Fetch and Lock will continue.'))
.catch((refreshError) => this.logger.error('Identity refresh failed', { err: refreshError }));
}
}

@@ -124,0 +131,0 @@ }

@@ -55,2 +55,3 @@ "use strict";

customErrorHandler = null;
onHeartbeatCallback = null;
abortController;

@@ -93,2 +94,5 @@ abortSignal;

}
onHeartbeat(callback) {
this.onHeartbeatCallback = callback;
}
start() {

@@ -118,2 +122,5 @@ this._pollingActive = true;

errorCount = 0;
if (typeof this.onHeartbeatCallback === 'function') {
this.onHeartbeatCallback();
}
}

@@ -125,2 +132,7 @@ catch (error) {

logger.error('Failed to fetch and lock External Tasks.', { err: error });
if (error.message?.match(/expired/i) && this.identityAccessor.canIdentityBeRefreshed()) {
logger.info('Identity has expired. Refreshing identity to get a new auth token...');
await this.identityAccessor.forceImmediateIdentityRefresh();
logger.info('Identity refresh completed. Fetch and Lock will continue.');
}
errorCount++;

@@ -127,0 +139,0 @@ const timeoutOffset = (Math.floor(Math.random() * 10) + 1) * 30;

63

dist/commonjs/IdentityAccessor.js

@@ -86,2 +86,3 @@ "use strict";

identityAvailableReject;
refreshFailedCritically = false;
refreshTimeout;

@@ -115,3 +116,3 @@ disposed = false;

initialize() {
this.refreshIdentityIfNeeded();
this.fetchIdentity().then(() => this.refreshIdentityPeriodically());
}

@@ -124,2 +125,5 @@ getId() {

}
canIdentityBeRefreshed() {
return this.isDynamicRefreshObject && this.expirationTimeInMs > 0 && !this.refreshFailedCritically && !this.disposed;
}
async getIdentity() {

@@ -129,2 +133,10 @@ await this.waitUntilIdentityIsAvailable();

}
async forceImmediateIdentityRefresh() {
if (!this.isDynamicRefreshObject) {
return;
}
clearTimeout(this.refreshTimeout);
await this.fetchIdentity();
this.refreshIdentityPeriodically();
}
/**

@@ -166,6 +178,20 @@ * This method only waits the first time the identity is retrieved from any remote source to ensure no missing references occur.

}
async refreshIdentityIfNeeded() {
refreshIdentityPeriodically() {
clearTimeout(this.refreshTimeout);
if (this.canIdentityBeRefreshed()) {
const timeUntilNextRefresh = Math.max((this.expirationTimeInMs ?? 0) - Date.now() - this.getBaseMinRefreshTimeInMs(), this.getBaseMinRefreshTimeInMs());
const timeUntilNextRefresh32Bit = Math.min(timeUntilNextRefresh, 2147483647);
this.refreshTimeout = setTimeout(async () => {
await this.fetchIdentity();
this.refreshIdentityPeriodically();
}, timeUntilNextRefresh32Bit);
}
else if (this.refreshFailedCritically) {
this.logger.error(`Identity refresh failed critically and won't be refreshed anymore.`);
this.identityAvailableReject(new Error('Identity refresh failed critically and wont be refreshed anymore.'));
}
}
async fetchIdentity() {
await this.asyncLock.acquire('refreshIdentity', async () => {
clearTimeout(this.refreshTimeout);
let failedCritically = false;
this.refreshFailedCritically = false;
try {

@@ -181,11 +207,8 @@ this.latestIdentity = await this.identityGetter();

this.identityAvailableResolve();
const announceNewIdentity = async () => {
try {
await Promise.all(this.newIdentityCallbacks.map((cb) => cb(this.latestIdentity)));
}
catch (err) {
this.logger.warn('Error while refreshing identity', { err });
}
};
announceNewIdentity();
try {
await Promise.all(this.newIdentityCallbacks.map((cb) => cb(this.latestIdentity)));
}
catch (err) {
this.logger.warn('Error while publishing new identity to listeners', { err });
}
}

@@ -198,18 +221,6 @@ else {

this.logger.error('Error while refreshing identity', { err });
failedCritically =
this.refreshFailedCritically =
!err.message ||
!['ETIMEDOUT', 'ECONNRESET', 'ECONNREFUSED', 'other side closed', 'SocketError', 'EAI_AGAIN', 'EHOSTUNREACH', 'EPIPE', 'ECONNABORTED', 'EHOSTDOWN'].some((errorString) => err.message.includes(errorString));
}
const canBeRefreshed = this.expirationTimeInMs > 0 && !failedCritically && !this.disposed && this.isDynamicRefreshObject;
if (canBeRefreshed) {
const timeUntilNextRefresh = Math.max((this.expirationTimeInMs ?? 0) - Date.now() - this.getBaseMinRefreshTimeInMs(), this.getBaseMinRefreshTimeInMs());
const timeUntilNextRefresh32Bit = Math.min(timeUntilNextRefresh, 2147483647);
this.refreshTimeout = setTimeout(() => {
this.refreshIdentityIfNeeded();
}, timeUntilNextRefresh32Bit);
}
else if (failedCritically) {
this.logger.error('Identity refresh failed critically and wont be refreshed anymore.');
this.identityAvailableReject(new Error('Identity refresh failed critically and wont be refreshed anymore.'));
}
});

@@ -216,0 +227,0 @@ }

@@ -25,4 +25,4 @@ "use strict";

Object.defineProperty(exports, "IdentityAccessor", { enumerable: true, get: function () { return IdentityAccessor_1.IdentityAccessor; } });
var ClientCredentialsIdentityAccessor_1 = require("./ClientCredentialsIdentityAccessor");
Object.defineProperty(exports, "ClientCredentialsIdentityAccessor", { enumerable: true, get: function () { return ClientCredentialsIdentityAccessor_1.ClientCredentialsIdentityAccessor; } });
var IdentityAccessorClientCredentials_1 = require("./IdentityAccessorClientCredentials");
Object.defineProperty(exports, "ClientCredentialsIdentityAccessor", { enumerable: true, get: function () { return IdentityAccessorClientCredentials_1.ClientCredentialsIdentityAccessor; } });
var processcube_engine_sdk_1 = require("@5minds/processcube_engine_sdk");

@@ -29,0 +29,0 @@ Object.defineProperty(exports, "BpmnType", { enumerable: true, get: function () { return processcube_engine_sdk_1.BpmnType; } });

@@ -15,2 +15,3 @@ import { Identity } from '@5minds/processcube_engine_sdk';

private customErrorHandler;
private onHeartbeatCallback;
private abortController;

@@ -31,2 +32,3 @@ private abortSignal;

onWorkerError(callback: WorkerErrorHandler): void;
onHeartbeat(callback: () => void): void;
start(): void;

@@ -33,0 +35,0 @@ stop(): void;

@@ -20,5 +20,6 @@ import { Identity, Logger } from '@5minds/processcube_engine_sdk';

private identityAvailableReject;
private refreshTimeout;
private disposed;
private isDynamicRefreshObject;
protected refreshFailedCritically: boolean;
protected refreshTimeout: NodeJS.Timeout;
protected disposed: boolean;
protected isDynamicRefreshObject: boolean;
protected logger: Logger;

@@ -31,3 +32,5 @@ private newIdentityCallbacks;

getIdentitySync(): Identity;
canIdentityBeRefreshed(): boolean;
getIdentity(): Promise<Identity>;
forceImmediateIdentityRefresh(): Promise<void>;
/**

@@ -50,4 +53,5 @@ * This method only waits the first time the identity is retrieved from any remote source to ensure no missing references occur.

protected getBaseMinRefreshTimeInMs(): number;
private refreshIdentityIfNeeded;
private refreshIdentityPeriodically;
private fetchIdentity;
private getDecodedToken;
}

@@ -7,3 +7,3 @@ export * from './Client';

export { ClientCredentialsConfig, IdentityAccessor, IdentityLike } from './IdentityAccessor';
export { ClientCredentialsIdentityAccessor } from './ClientCredentialsIdentityAccessor';
export { ClientCredentialsIdentityAccessor } from './IdentityAccessorClientCredentials';
export { BpmnType, DataModels, EventType, Identity, Model, EventReceivedCallback, Subscription } from '@5minds/processcube_engine_sdk';

@@ -7,3 +7,3 @@ {

"name": "@5minds/processcube_engine_client",
"version": "6.0.0-renovate-5c6028-m5umu879",
"version": "6.0.0-renovate-5d9909-m6i56utq",
"description": "Contains a typescript based client for accessing the Engine.",

@@ -10,0 +10,0 @@ "main": "dist/commonjs/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc