Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
ataraxia-service-contracts
Advanced tools
Utils for defining contracts for use with ataraxia-services
Light-weight service contracts for defining how services act. Used for RPC in Ataraxia.
This library is provided as a way to define contracts for services that may be used with Ataraxia, but do not necessarily register or consume them on their own. If you're interested in registering or consuming services ataraxia-services is what you want to depend on.
To get started install the ataraxia-service-contracts
library:
npm install ataraxia-service-contracts
Contracts can then be defined using the ServiceContract class:
import { ServiceContract } from 'ataraxia-service-contracts';
const EchoService = new ServiceContract()
.defineMethod('echo', {
returnType: stringType,
parameters: [
{
name: 'message',
type: stringType
}
]
})
.defineEvent('onEcho', {
parameters: [
{
name: 'message',
type: stringType
}
]
});
Or together with TypeScript:
import { ServiceContract, AsyncSubscribable } from 'ataraxia-service-contracts';
interface EchoService {
onEcho: AsyncSubscribable<this, [ message: string ]>;
echo(message: string): Promise<string>;
}
const EchoService = new ServiceContract<EchoService>()
.defineMethod('echo', {
returnType: stringType,
parameters: [
{
name: 'message',
type: stringType
}
]
})
.defineEvent('onEcho', {
parameters: [
{
name: 'message',
type: stringType
}
]
});
When using classes the recommended way to mark what contract a class implements is to use the serviceContract decorator:
@serviceContract(EchoService)
class EchoServiceImpl {
async echo(message) {
return message;
}
}
If the decorator is not used you can define a static property called serviceContract instead:
class EchoServiceImpl {
static serviceContract = EchoService;
async echo(message) {
return message;
}
}
Contracts will traverse the prototype chain, so defining contract on extended classes work well:
@serviceContract(EchoService)
class AbstractEchoService {
async echo(message) {
return message;
}
}
class EchoServiceImpl extends AbstractEchoService {
}
For plain objects the easiest way to use a contract is to use implement:
const instance = EchoService.implement({
async echo(message) {
return message;
}
});
As with classes a property may be used instead:
const instance = {
serviceContract: EchoService,
async echo(message) {
return message;
}
};
FAQs
Utils for defining contracts for use with ataraxia-services
We found that ataraxia-service-contracts 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
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.