
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@styleshit/locker
Advanced tools
Control access to experimental or unstable methods in TypeScript applications with 100% type-safety.
Control access to experimental or unstable methods in TypeScript applications with 100% type-safety.
When developing modules that include experimental or unstable methods, it's crucial to ensure that users of your module handle these methods with caution. By locking certain pieces of data or methods, you can make sure that other developers accessing your module are explicitly aware of the risks and implications of using them. Essentially, by requiring them to unlock the data, you're asking for their acknowledgment that they understand and accept the associated risks.
This package aims to:
npm install @styleshit/locker
# OR
yarn add @styleshit/locker
# OR
pnpm add @styleshit/locker
For a module data-module.ts that wants to share data with another module:
// data-module.ts
import { lock } from '@styleshit/locker';
const experimentalFunction = () => {
console.log('This is an experimental function');
};
export const lockedFunction = lock(experimentalFunction);
Another module can then unlock this data, acknowledging the risks:
// consumer-module.ts
import { unlock } from '@styleshit/locker';
import { lockedFunction } from './data-module';
const unlockedFunction = unlock(lockedFunction);
console.log(unlockedFunction()); // Outputs: 'This is an experimental function'
In a module custom-locker.ts, you can create a custom locker:
// custom-locker.ts
import { createLocker } from '@styleshit/locker';
const uniqueKey = Symbol('myUniqueKey');
export const { lock, unlock } = createLocker(uniqueKey);
Then, in a module data-module.ts, you can lock data using this custom locker:
// data-module.ts
import { lock } from './custom-locker';
const data = { message: 'Custom Locker' };
export const lockedData = lock(data);
Subsequently, in a consumer module, the data can be unlocked:
// consumer-module.ts
import { unlock } from './custom-locker';
import { lockedData } from './data-module';
const unlockedData = customLocker.unlock(lockedData);
console.log(unlockedData); // Outputs: { message: 'Custom Locker' }
createLocker( key: Symbol ): { lock, unlock }Creates a new locker based on the provided unique key. Returns an object containing lock and unlock methods specific to that key.
key: A unique Symbol that will act as the identifier for the locker.lock(data: T): UnlockCallback<T>Locks the provided data, ensuring that it requires intentional unlocking by the user.
data: Any data you wish to lock.unlock(data: UnlockCallback<T>): TUnlocks the provided locked data, signaling the user's acknowledgment of potential risks.
data: The locked data to be unlocked.FAQs
Control access to experimental or unstable methods in TypeScript applications with 100% type-safety.
We found that @styleshit/locker 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.