
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
remote-promises
Advanced tools
🕹️🤞
Create native ES6 promises and resolve them externally.
Ensure its installed as a dependency from your console:
npm i remote-promises
Then import the RemotePromise
class before attempting the following examples
import { RemotePromise } from 'remote-promises'
I guess this is why you're here – use .resolve()
or .reject()
to satisfy the promise.
When you do this, the status
property changes from "pending"
to either "resolved"
or "rejected"
.
// Instantiate a new remote promise
const rp = new RemotePromise()
rp.resolve('some resolved value')
//- rp.reject(new Error("500: The whole system's blown!"))
rp.status // 'resolved'
RemotePromise
can be used with the await
keyword just like the native promises.
const rp = new RemotePromise()
rp.resolve('any value')
// Use await in an asynchronous context
(async () => {
console.log(await rp) // 'any value'
})()
But when await
is used with a rejected promise, the rejection is thrown like an error and can be caught.
const rp = new RemotePromise()
// Gotta catch 'em all!
(async () => {
try {
await rp
} catch (reason) {
console.log(reason) // 'pocket monsters'
}
})()
rp.reject('pocket monsters')
If you're not a fan of the async
/await
style, then you can use then
/catch
as you normally would with promises. These can be chained too.
const rp = new RemotePromise()
// then/catch can be called the promise is satisfied
rp.then(value => console.log('success', value))
rp.catch(reason => console.log('flop', reason)) // 'flop', 'fish'
// Satisfy the promise
rp.reject('fish')
// Cheeky little example involving chains
rp
.catch(() => 'flip')
.then(value => console.log(value)) // 'flip'
As with the native promises, you're able to define an interface for a fulfilled promise value.
// Define your structure
interface SomeStructure {
status: 200
result: string
}
// Create a new typed remote promise
const rp = new RemotePromise<SomeStructure>()
// Must resolve with an object according to the type
rp.resolve({
status: 200,
result: 'samosas'
})
// Start writing a callback...
rp.then(val => {
// val is of type SomeStructure
})
FAQs
Create native ES6 promises and resolve them externally
The npm package remote-promises receives a total of 739 weekly downloads. As such, remote-promises popularity was classified as not popular.
We found that remote-promises 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.