{"id":15136106,"url":"https://github.com/maxbeatty/auth0-rule-sandbox","last_synced_at":"2025-09-29T05:30:27.009Z","repository":{"id":57156742,"uuid":"83852316","full_name":"maxbeatty/auth0-rule-sandbox","owner":"maxbeatty","description":"Provides a test environment for Auth0 Rules similar to their sandbox","archived":true,"fork":false,"pushed_at":"2017-03-04T06:20:09.000Z","size":6,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-03T07:53:25.560Z","etag":null,"topics":["auth0","testing"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maxbeatty.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-04T00:05:35.000Z","updated_at":"2023-01-28T18:02:28.000Z","dependencies_parsed_at":"2022-09-07T20:32:38.450Z","dependency_job_id":null,"html_url":"https://github.com/maxbeatty/auth0-rule-sandbox","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxbeatty%2Fauth0-rule-sandbox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxbeatty%2Fauth0-rule-sandbox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxbeatty%2Fauth0-rule-sandbox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxbeatty%2Fauth0-rule-sandbox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxbeatty","download_url":"https://codeload.github.com/maxbeatty/auth0-rule-sandbox/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234594021,"owners_count":18857416,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["auth0","testing"],"created_at":"2024-09-26T06:04:07.041Z","updated_at":"2025-09-29T05:30:21.665Z","avatar_url":"https://github.com/maxbeatty.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# auth0-rule-sandbox\nProvides a test environment for Auth0 Rules similar to their sandbox environment.\n\n## Example\n\nAssuming you have a GitHub repository to deploy rules, pages, and custom database connections to Auth0 ([see example](https://github.com/auth0-samples/github-source-control-integration)), then this module will allow you to run your rules locally with controlled inputs.\n\n`rule.js`:\n\n```js\nfunction example(user, context, callback) {\n  // TODO: implement your rule\n  callback(null, user, context);\n}\n```\n\n`rule.test.js`:\n```js\nconst auth0runner = require('auth0-rule-sandbox');\n\nconst options = {\n  user: {\n    name: 'test'\n  },\n  context: {\n    clientID: '123456789'\n  },\n  configuration: {\n    key: 'value'\n  },\n  globals: {\n    request: require('request')\n  }\n};\n\nauth0runner('./relative/path/to/your/rule.js', options, function(err, user, context) {\n  if (err) {\n    console.error(err);\n  } else {\n    // TODO: assertions\n    console.log(user, context);\n  }\n});\n```\n\n## Usage\n\nExports a function that takes arguments:\n\n- `path` (string): relative path to your rule file\n- `options` (object):\n  - `user` (object): represents the logged in user that's passed through the Rules pipeline\n  - `context` (object): contains contextual information about the current authentication transaction\n  - `configuration` (object): key-value settings from the [Rules UI](https://manage.auth0.com/#/rules)\n  - `globals` (object): See section below\n- `callback` (function): send back the potentially modified user and context objects back to Auth0 (or an error)\n\n## Bring Your Own Dependencies\n\nIt looks like Auth0 Rules run in Node.js v4.4.5 based on `console.log(process.version)`. [These modules are provided](https://auth0.com/docs/appliance/modules) 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).\n\n```js\nconst options = {\n  // ...\n  globals: {\n    auth0: {\n      users: {\n        updateAppMetadata: function () { return Promise.resolve() }\n      }\n    },\n    jwt: require('jsonwebtoken')\n  }\n}\n```\n\n### built-in\n\nThese global properties are provided from the parent Node context:\n\n- process\n- Buffer\n- clearImmediate\n- clearInterval\n- clearTimeout\n- setImmediate\n- setInterval\n- setTimeout\n- console\n\n### require\n\n[Additional modules can be required](https://tehsis.github.io/webtaskio-canirequire/) but you'll have to roll your own `require` shim until one is added here.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxbeatty%2Fauth0-rule-sandbox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxbeatty%2Fauth0-rule-sandbox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxbeatty%2Fauth0-rule-sandbox/lists"}