Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
nice-grpc-error-details
Advanced tools
Rich error model implementation for nice-grpc.
This package is experimental and its API should not be considered stable.
Provides extensions to
ServerError
and
ClientError
which carry extra
error details,
as well as server and client middleware to communicate these details via
trailing metadata.
npm install nice-grpc-error-details
Attach the middleware to a server:
import {errorDetailsServerMiddleware} from 'nice-grpc-error-details';
const server = createServer().use(errorDetailsServerMiddleware);
Throw RichServerError
from a service
implementation method:
import {ServerError, Status} from 'nice-grpc';
import {RichServerError, BadRequest} from 'nice-grpc-error-details';
const exampleServiceImpl: ServiceImplementation<
typeof ExampleServiceDefinition
> = {
async exampleUnaryMethod(
request: ExampleRequest,
): Promise<DeepPartial<ExampleResponse>> {
if (!request.someField)
throw new RichServerError(
Status.INVALID_ARGUMENT,
"Missing required field 'some_field'",
[
BadRequest.fromPartial({
fieldViolations: [
{
field: 'some_field',
description: 'Field is required',
},
],
}),
],
);
// ... method logic
},
};
Attach the middleware to a client factory:
import {errorDetailsClientMiddleware} from 'nice-grpc-error-details';
const clientFactory = createClientFactory().use(errorDetailsClientMiddleware);
If an error with details is returned from a server, the client will receive
RichClientError
:
import {Status} from 'nice-grpc';
import {RichClientError, BadRequest} from 'nice-grpc-error-details';
const fieldViolations: BadRequest_FieldViolation[] = [];
try {
await client.exampleUnaryMethod(request);
} catch (error: unknown) {
if (
error instanceof RichClientError &&
error.code === Status.INVALID_ARGUMENT
) {
// loop through error details to find `BadRequest`
for (const detail of error.extra) {
if (detail.$type === BadRequest.$type) {
fieldViolations.push(...detail.fieldViolations);
}
}
} else {
throw error;
}
}
FAQs
gRPC rich error model implementation for nice-grpc
The npm package nice-grpc-error-details receives a total of 17,169 weekly downloads. As such, nice-grpc-error-details popularity was classified as popular.
We found that nice-grpc-error-details demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.