npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@bearer/node-agent

v3.3.3

Published

Bearer Node Agent

Downloads

1,475

Readme

@bearer/node-agent

Build Status npm

Installation

From a terminal, install the Bearer agent module and save it into your project:

npm install --save @bearer/node-agent
# or
yarn add @bearer/node-agent

Now, open your application main script (e.g. index.js or main.js) and initialize the Bearer agent at the top:

const Bearer = require('@bearer/node-agent')

await Bearer.init({ secretKey: 'YOUR_BEARER_SECRET_KEY' })

http.request(...)

Your Secret Key is available on the Bearer dashboard

The init function returns a promise which you can use to ensure Bearer is fully loaded before performing any HTTP requests.

Note: We strongly recommend to initialize the Bearer agent as early as possible. This ensures that all external HTTP requests performed from your application are monitored.

Now, you can start your application (e.g. node index.js). All API calls will be monitored and available on your Bearer dashboard.

For detailed configuration options check the Agent's configuration page.

Keeping your data protected

We recommend you sanitize your data before sending it to the Bearer dashboard. We think it's best to setup the sanitization level that best suits your needs. An example using the default values is as follows:

Bearer.init({
  stripSensitiveData: true,
  stripSensitiveKeys: /^authorization$|^client.id$|^access.token$|^client.secret$/i,
  stripSensitiveRegex: /[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:.[a-zA-Z0-9-]+)*/,
})

Configuration options explained

  • stripSensitiveData - Globally enable/disable data sanitization. It's enabled by default. If you set it to false no sanitization will take place, and all the data will be sent to the Bearer dashboard as-is.

  • stripsSensitiveKeys - List of key names regex patterns that will be applied to sanitize values in headers, query parameters or response body. If you specify "stripSensitiveKeys": "^authorization$" the following sanitization actions would take place:

    • In headers: "authorization" header value will be sanitized and would be sent to the Bearer dashboard as "authorization: [FILTERED]"
    • In query string parameters: "authorization" query parameter value will be sanitized, and in the Bearer dashboard your URL will look like: "http://www.example.com/auth?authorizaiton=[FILTERED]"
    • In application/json response body: Any value of "authorization" key in response payload will be replaced with "[FILTERED]" (e.g., { "name": "John", "authorization": "granted" } will be sent to the Bearer dashboard as { "name": "John", "authorization": "[FILTERED]" }
  • stripSensitiveRegex - A regular expression that will be used to sanitize any value in headers, query string parameters or response body. Bearer will check all the values sent in the request or response and will replace matching patterns with "[FILTERED]".

Development

Release a new version

Bump version

npm version path|minor|major

# push things
git push
git push --tags

Debugging

@bearer/node-agent uses debug, so just run with environmental variable DEBUG set to bearer:agent:*.

$ DEBUG=bearer:agent:* node app.js