
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
external-promise
Advanced tools
A promise that can be resolved or rejected externally.
npm install external-promise --save
// Initializing the promise
const p = new ExternalPromise();
// Resolving the promise after a timeout
setTimeout(() => { p.resolve(); }, 1000);
// Awaiting the promise
await p;
Example showing 2 API methods. The first method initializes the promise and awaits its resolution. The second method resolves it.
class Item {
private name: string;
private static counter = 1;
private isBeingRenamed = false;
private renamePromise: ExternalPromise<string> | null = null;
public costructor() {
this.name = `Item ${Item.counter}`;
Item.counter += 1;
}
// This is a simple example and reactions of UI to the state of the instance are not considered.
// This could easily be a MobX observable where the UI observes isBeingRenamed and name.
/**
* An API method that initializes the UI rename process and awaits the operation to complete.
*/
public async rename(): Promise<string | false> {
// Cancel previous rename if pending
if (this.renamePromise && this.renamePromise.getState() === 'pending') {
this.renamePromise.resolve(false);
}
this.isBeingRenamed = true;
// Initializing the promise
this.renamePromise = new ExternalPromise();
// Awaiting the promise
const result = await this.renamePromise;
this.isBeingRenamed = false;
if (result !== false) {
this.name = result;
}
return result;
}
/**
* A method that finalizes or cancels the rename that can be called from another part of the UI
* when the user has finished renaming.
*/
public resolveRename(name: string | false): void {
if (this.promiseRename_ === null) {
return;
}
if (this.promiseRename_?.getState() === 'pending') {
// Resolving the promise
this.promiseRename_.resolve(result);
}
this.promiseRename_ = null;
}
}
FAQs
A promise that can be resolved or rejected externally
We found that external-promise demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.