
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.
branded-types
Advanced tools
Flippin' great branded types for TypeScript!
Use them like opaque types in Flow, except you get to control visibility.
Define a branded type:
import {Branded} from 'branded-types'
export class OrderId extends Branded<string, 'my-package.OrderId'>() {}
Import and use it
import {OrderId} from './other-module';
OrderId.brand('someUuid') === 'someString' // error
Want to hide the branding and un-branding functions?
import { Branded } from "branded-types";
namespace my {
export class OrderId extends Branded<string, 'my-package.OrderId'>() {}
}
export function safeCreateId() {
return my.OrderId.brand('x')
}
export type OrderId = my.OrderId;
The other module can only use the safe ID creation functions now:
import {safeCreateId, OrderId} from './other-module';
safeCreateId() == 'someString'; // error
let m: Map<OrderId, string> = new Map;
m.set(safeCreateId(), '1');
m.set('someString', '2'); // error
This condition will always return 'false' since
the types 'string' and 'OrderId' have no overlap.
and the incorrect map insertion above produces the error:
Argument of type 'string' is not assignable to parameter of type 'OrderId'.
+
, its not going to work. You have to use an explicit cast to the source type via e.g.
String(brandedVal)
or Number(brandedVal)
etc, then perform the operationFAQs
Flippin' great branded types for TypeScript!
The npm package branded-types receives a total of 11 weekly downloads. As such, branded-types popularity was classified as not popular.
We found that branded-types 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.