パッケージの詳細

loopback4-helmet

sourcefuse14.4k7.0.3

A loopback-next extension for helmetjs.

loopback-extension, loopback

readme

ARC By SourceFuse logo

loopback4-helmet

npm version Sonar Quality Gate Synk Status GitHub contributors downloads License Powered By LoopBack 4

Overview

A simple loopback-next extension for helmetjs integration in loopback applications.

Install

npm install loopback4-helmet

Usage

In order to use this component into your LoopBack application, please follow below steps.

  • Add component to application.
this.component(Loopback4HelmetComponent);
  • By default, helmet will be initialized with only the default middlewares enabled as per here. However, you can override any of the middleware settings using the Config Binding like below.
this.bind(HelmetSecurityBindings.CONFIG).to({
  referrerPolicy: {
    policy: 'same-origin',
  },
  contentSecurityPolicy: {
    directives: {
      frameSrc: ["'self'"],
    },
  },
});
  • The component exposes a sequence action which can be added to your server sequence class. Adding this will trigger helmet middleware for all the requests passing through.
export class MySequence implements SequenceHandler {
  constructor(
    @inject(SequenceActions.FIND_ROUTE) protected findRoute: FindRoute,
    @inject(SequenceActions.PARSE_PARAMS) protected parseParams: ParseParams,
    @inject(SequenceActions.INVOKE_METHOD) protected invoke: InvokeMethod,
    @inject(SequenceActions.SEND) public send: Send,
    @inject(SequenceActions.REJECT) public reject: Reject,
    @inject(HelmetSecurityBindings.HELMET_SECURITY_ACTION)
    protected helmetAction: HelmetAction,
  ) {}

  async handle(context: RequestContext) {
    const requestTime = Date.now();
    try {
      const {request, response} = context;
      const route = this.findRoute(request);
      const args = await this.parseParams(request, route);

      // Helmet Action here
      await this.helmetAction(request, response);

      const result = await this.invoke(route, args);
      this.send(response, result);
    } catch (err) {
      ...
    } finally {
      ...
    }
  }
}

Feedback

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.

Contributing

Please read CONTRIBUTING.md for details on the process for submitting pull requests to us.

Code of conduct

Code of conduct guidelines here.

License

MIT

更新履歴

Release v7.0.2 June 4, 2024

Welcome to the June 4, 2024 release of loopback4-helmet. There are many updates in this version that we hope you will like, the key highlights include:

Clink on the above links to understand the changes in detail.


Release v7.0.1 May 15, 2024

Welcome to the May 15, 2024 release of loopback4-helmet. There are many updates in this version that we hope you will like, the key highlights include:

Clink on the above links to understand the changes in detail.


Release v5.0.1 July 14, 2023

Welcome to the July 14, 2023 release of loopback4-helmet. There are many updates in this version that we hope you will like, the key highlights include:

Clink on the above links to understand the changes in detail.


Release v5.0.0 June 7, 2023

Welcome to the June 7, 2023 release of loopback4-helmet. There are many updates in this version that we hope you will like, the key highlights include:

Clink on the above links to understand the changes in detail.


Release v4.2.3 April 24, 2023

Welcome to the April 24, 2023 release of loopback4-helmet. There are many updates in this version that we hope you will like, the key highlights include:

Clink on the above links to understand the changes in detail.


Release v4.2.2 March 10, 2023

Welcome to the March 10, 2023 release of loopback4-helmet. There are many updates in this version that we hope you will like, the key highlights include:

Clink on the above links to understand the changes in detail.


Release v4.2.1 February 20, 2023

Welcome to the February 20, 2023 release of loopback4-helmet. There are many updates in this version that we hope you will like, the key highlights include:

Clink on the above links to understand the changes in detail.


Release v4.2.0 January 11, 2023

Welcome to the January 11, 2023 release of loopback4-helmet. There are many updates in this version that we hope you will like, the key highlights include:

  • :- feat(chore): generate detailed and informative changelog was commited on January 10, 2023 by yeshamavani

      • feat(chore): generate detailed and informative changelog
    • Using Customizable npm package to generate changelog

    • GH-60

      • feat(chore): generate detailed and informative changelog
    • Using Customizable npm package to generate changelog

    • GH-60

Clink on the above links to understand the changes in detail.


4.1.4 (2022-12-05)

4.1.3 (2022-10-31)

4.1.2 (2022-09-09)

4.1.1 (2022-06-17)

4.1.0 (2022-05-26)

Bug Fixes

Features