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

auth0-bundler

v1.3.1

Published

Bundle rules, scripts and hooks to deploy them to Auth0.

Downloads

162

Readme

auth0-bundler

NPM version Build status License

Bundle rules, scripts and hooks to deploy them to Auth0.

This allows you to

  • test rules, scripts and hooks dedicated to be deployed to Auth0, as they can be required in node as well.
  • import other modules by using require statements with relative file paths. This way common functionality can be shared between rules.
  • write your rules using the whole ES2015 feature set, as the rules will be transpiled at bundle time.
  • pass in configuration at bundling time which can be used in your rule when it is executed.

API

createBundler

const createBundler = require('auth0-bundler');

const bundler = createBundler(options);

Options

  • nodeVersion: the node version that should be targeted (used for @babel/preset-env), the default is 4

bundler.bundleScript(injectedConfig, scriptFilename) -> Promise<bundledScript>

bundler.bundleRule(injectedConfig, ruleFilename) -> Promise<bundledRule>

bundler.bundleHook(injectedConfig, hookFilename) -> Promise<bundledHook>

Bundles a single script, rule or hook so it can be deployed to Auth0. The rule needs to be written as a commonjs module that exports a single function. This function takes an additional first parameter compared to being defined in Auth0: The injectedConfig that can be specified at bundle time. Modules required from the node_modules folder will not be bundled and will be required in the Auth0 environment as well. Auth0 provides a number of modules inside the Auth0 environment, to check whether a module can be required check webtaskio-canirequire.

Example:

Rule:

// my-rule.js
// Example rule to be deployed to auth0

// This dependency will be automatically bundled into the rule
const doRequest = require('../common/function');
// This dependency will be loaded using require
const R = require('ramda');

module.exports = function myRule(config, user, context, callback) {
    return doRequest(`${config.baseUrl}/some/endpoint`, user).then(function (result) {
        callback(null, R.merge({ some: 'result' }, result), context);
    });
};

Bundle dependencies:

const createBundler = require('auth0-bundler');
const bundler = createBundler();
const config = { baseUrl: 'https://www.example.com' };

bundler
    .bundleRule(config, `${__dirname}/my-rule.js`)
    .then(console.log);

Using auth0-bundler during deployment

This is an example on how to use auth0-bundler and the Auth0 Management API client to automatically deploy a rule using auth0-bundler. Like this you can automatically deploy rules e.g. during a CI run.

const ManagementClient = require('auth0').ManagementClient;
const management = new ManagementClient({
  token: '{YOUR_API_V2_TOKEN}',
  domain: '{YOUR_ACCOUNT}.auth0.com'
});
const createBundler = require('auth0-bundler');
const bundler = createBundler();
const config = { baseUrl: 'https://www.example.com' };

bundler.bundleRule(config, `${__dirname}/my-rule.js`).then((bundledRule) => {
    return management.createRule({
        enabled: true,
        name: 'my-rule',
        order: 1,
        stage: 'login_success',
        script: bundledRule
    });
});

License

This project is licensed under the MIT license. See the LICENSE file for more info.