Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
RPC-like client-service implementation over messaging queue. This module provides base set of abstract classes and decorators to build services and clients for them.
To provide fast and reliable way of communication between backend services.
IMQ-RPC provides a simple and reliable solution, using which developer can focus exactly on business logic implementation and be assured the services inter-communication is handled properly, performs fast and is scalable enough to handle any load.
npm i --save imq-rpc
For next examples it is expected redis server is running on localhost:6379
.
When building service doc-blocks for exposed service methods are mandatory. First of all it guarantees good level of documentation. From other hand it provides better types information for building service clients and complex types usages.
File service.ts
:
import { IMQService, expose } from 'imq-rpc';
class Hello extends IMQService {
/**
* Says hello using given name
*
* @param {string} [name] - name to use withing hello message
* @returns {string} - hello string
*/
@expose()
public hello(name?: string): string {
return `Hello, ${name}!`;
}
}
(async () => {
const service = new Hello();
await service.start();
})();
There are 3 ways of building service clients:
File: client.ts
(manually written client example):
import { IMQClient, IMQDelay, remote } from 'imq-rpc';
class HelloClient extends IMQClient {
/**
* Says hello using given name
*
* @param {string} name
* @returns {Promise<string>}
*/
@remote()
public async hello(name?: string, delay?: IMQDelay): Promise<string> {
return await this.remoteCall<string>(...arguments);
}
}
(async () => {
try {
const client = new HelloClient();
await client.start();
// client is now ready for use
console.log(await client.hello('IMQ'));
}
catch (err) {
console.error(err);
}
})();
Using dynamically built clients (for the same service described above):
import { IMQClient } from 'imq-rpc';
(async () => {
try {
const hello: any = await IMQClient.create('Hello');
const client = new hello.HelloClient();
await client.start();
console.log(await client.hello('IMQ'));
await client.destroy();
}
catch (err) {
console.error(err);
}
})();
In this case above, IMQClient.create()
will automatically generate client
code, compiles it to JS, loads and returns compiled module. As far as it
happens at runtime there is no possibility to refer type information
properly, but there is no need to take care if the client up-to-date with
the service code base. Each time client created it will be re-generated.
BTW, IMQClient.create()
supports a source code generation without a module
loading as well:
import { IMQClient } from 'imq-rpc';
(async () => {
await IMQClient.create('Hello', {
path: './clients',
compile: false
});
})();
In this case client code will be generated and written to a corresponding
file ./clients/Hello.ts
under specified path. Then it can be compiled and
imported within your project build process, and referred in your code
as expected:
import { hello } from './clients/Hello';
(async () => {
const client = new hello.HelloClient();
await client.start();
console.log(client.hello('IMQ'));
})();
In this case all complex types defined within service implementation will be available under imported namespace of the client.
For image containers builds assign machine UUID in /etc/machine-id
and
/var/lib/dbus/machine-id
respectively. UUID should be assigned once on
a first build then re-used each new build to make it work consistently.
FAQs
RPC-like client-service implementation over messaging queue
We found that imq-rpc demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.