Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

auth0-rule-sandbox

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

auth0-rule-sandbox

Provides a test environment for Auth0 Rules similar to their sandbox

  • 2.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

auth0-rule-sandbox

Provides a test environment for Auth0 Rules similar to their sandbox environment.

Example

Assuming you have a GitHub repository to deploy rules, pages, and custom database connections to Auth0 (see example), then this module will allow you to run your rules locally with controlled inputs.

rule.js:

function example(user, context, callback) {
  // TODO: implement your rule
  callback(null, user, context);
}

rule.test.js:

const auth0runner = require('auth0-rule-sandbox');

const options = {
  user: {
    name: 'test'
  },
  context: {
    clientID: '123456789'
  },
  configuration: {
    key: 'value'
  },
  globals: {
    request: require('request')
  }
};

auth0runner('./relative/path/to/your/rule.js', options, function(err, user, context) {
  if (err) {
    console.error(err);
  } else {
    // TODO: assertions
    console.log(user, context);
  }
});

Usage

Exports a function that takes arguments:

  • path (string): relative path to your rule file
  • options (object):
    • user (object): represents the logged in user that's passed through the Rules pipeline
    • context (object): contains contextual information about the current authentication transaction
    • configuration (object): key-value settings from the Rules UI
    • globals (object): See section below
  • callback (function): send back the potentially modified user and context objects back to Auth0 (or an error)

Bring Your Own Dependencies

It looks like Auth0 Rules run in Node.js v4.4.5 based on console.log(process.version). These modules are provided as part of the global object but not populated by this module. Instead, you can pick and choose which global modules are populated and how (actual vs mock).

const options = {
  // ...
  globals: {
    auth0: {
      users: {
        updateAppMetadata: function () { return Promise.resolve() }
      }
    },
    jwt: require('jsonwebtoken')
  }
}

built-in

These global properties are provided from the parent Node context:

  • process
  • Buffer
  • clearImmediate
  • clearInterval
  • clearTimeout
  • setImmediate
  • setInterval
  • setTimeout
  • console

require

Additional modules can be required but you'll have to roll your own require shim until one is added here.

Keywords

FAQs

Package last updated on 04 Mar 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc