
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
@sourceloop/feature-toggle
Advanced tools
A simple loopback-next extension for checking the disabled features. Here a new decorator is introduced it has a simplistic approach to check if a particular feature is allowed or not to that user.
This extension provides a method level decorator @featureFlag that takes the name of the feature that needs to be checked as metadata and verifies if that particular feature is allowed or not. What it expects is that a list of disabled features is saved for the current user of the type IAuthUserWithDisabledFeat and compares that with the one passed in the metadata of the decorator.
The metadata also accepts an optional options that has a handler name parameter. If that handler name is provided that using an extendion point HandlerService appropriate handler is called. All the handlers must implement FeatureHandler interface.
Only feature check
@featureFlag({featureKey: 'feature_key'})
If you want to skip the check:
@featureFlag({featureKey: '*'})
Multiple feature check with operator
@featureFlag({
featureKey: ['feature_key1', 'feature_key2'],
options: {
operator: 'AND' | 'OR'
},
})
Feature Check plus handler call
@featureFlag({
featureKey: 'feature_key',
options: {
handler: 'handler_name',
},
})
This particular handler_name will be matched with the one in handler
@injectable(asFeatureHandler)
export class MyHandler implements FeatureHandler {
handlerName = 'handler_name';
handle(): void {
// your logic here
}
}
A good practice is to keep all feature strings in a separate enum file like this.
export enum FEATUREKEY {
CALENDAR = '1',
CHAT = '2',
CONTRACT = '3',
}
npm install @sourceloop/feature-toggle
In order to use this component into your application follow the easy steps given below.
authUser.disabledFeatures = ['1', '3'];
FeatureToggleComponent to your Loopback4 Application (in application.ts) where you need to check the features availability.// import the FeatureToggleComponent
import {FeatureToggleComponent} from '@sourceloop/feature-toggle';
// add Component for FeatureToggle
this.component(FeatureToggleComponent);
this.add(createBindingFromClass(MyHandler));
If you've noticed a bug or have a question or have a feature request, search the issue tracker to see if someone else in the community has already created a ticket. If not, go ahead and make one! All feature requests are welcome. Implementation time may vary. Feel free to contribute the same, if you can. If you think this extension is useful, please star it. Appreciation really helps in keeping this project alive.
Please read CONTRIBUTING.md for details on the process for submitting pull requests to us.
Code of conduct guidelines here.
FAQs
Package for feature toggle.
The npm package @sourceloop/feature-toggle receives a total of 844 weekly downloads. As such, @sourceloop/feature-toggle popularity was classified as not popular.
We found that @sourceloop/feature-toggle demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 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
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.