
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
@directus/errors
Advanced tools
Utility functions to help creating and checking against Directus errors.
pnpm add @directus/errors
createError(code: string, message: string | (T) => string, status = 500): DirectusErrorConstructor<T>
import { createError } from '@directus/errors';
const ForbiddenError = createError('FORBIDDEN', "You don't have permissions to see this.", 403);
throw new ForbiddenError();
You can configure additional extensions for the error class which should be communicated to the end user:
import { createError } from '@directus/errors';
interface ForbiddenErrorExtensions {
collection: string;
field: string;
}
const ForbiddenError = createError<ForbiddenErrorExtensions>(
'FORBIDDEN',
"You don't have permissions to see this.",
403,
);
throw new ForbiddenError({
collection: 'articles',
field: 'title',
});
You can then also use those extensions to generate out the error message:
import { createError } from '@directus/errors';
interface ForbiddenErrorExtensions {
collection: string;
field: string;
}
const messageConstructor = (extensions: ForbiddenErrorExtensions) =>
`You don't have permissions to see "${extensions.field}" in "${extensions.collection}".`;
const ForbiddenError = createError<ForbiddenErrorExtensions>('FORBIDDEN', messageConstructor, 403);
throw new ForbiddenError({
collection: 'articles',
field: 'title',
});
import { isDirectusError, createError } from '@directus/errors';
const ForbiddenError = createError('FORBIDDEN', "You don't have permissions to see this.", 403);
isDirectusError(new ForbiddenError()); // true
isDirectusError(new Error()); // false
FAQs
Create consistent error objects around the codebase
The npm package @directus/errors receives a total of 13,958 weekly downloads. As such, @directus/errors popularity was classified as popular.
We found that @directus/errors demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 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
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.